Skip to content

Commit

Permalink
Merge remote-tracking branch 'baidu/master' into fix-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Feb 18, 2024
2 parents 0b57f07 + 85995de commit be51236
Show file tree
Hide file tree
Showing 35 changed files with 517 additions and 402 deletions.
23 changes: 23 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true,
"react": {
"runtime": "classic"
}
},
"keepClassNames": true,
"externalHelpers": true,
"loose": false
},
"sourceMaps": true,
"minify": false
}
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ npm test --workspaces

# 测试某个用例
# <spec-name>为用例名称,比如inputImage
npm test --workspace amis <spec-name>
npm test --workspace amis -- -t <spec-name>

# 运行某个单测文件
./node_modules/.bin/jest packages/amis/__tests__/renderers/Form/buttonToolBar.test.tsx

# 运行某个单测文件里的某个例子
./node_modules/.bin/jest packages/amis/__tests__/renderers/Form/buttonToolBar.test.tsx -t 'Renderer:button-toolbar'

# 查看测试用例覆盖率
npm run coverage
Expand All @@ -73,7 +79,7 @@ npm run update-snapshot

# 更新单个 snapshot
# <spec-name>为用例名称,比如inputImage
npm run update-snapshot --workspace amis <spec-name>
npm run update-snapshot --workspace amis -- -t <spec-name>
```

### 发布版本
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
"@babel/types": "^7.22.5",
"@fortawesome/fontawesome-free": "^6.1.1",
"@rollup/plugin-replace": "^5.0.1",
"@swc/core": "^1.3.107",
"@swc/helpers": "^0.5.3",
"@swc/jest": "^0.2.34",
"@types/express": "^4.17.14",
"@types/jest": "^28.1.0",
"@types/js-yaml": "^4.0.5",
Expand Down Expand Up @@ -117,7 +120,9 @@
"tsx",
"js"
],
"preset": "ts-jest",
"transform": {
"^.+\\.(t|j)sx?$": "@swc/jest"
},
"setupFiles": [
"jest-canvas-mock"
],
Expand All @@ -144,4 +149,4 @@
"printBasicPrototype": false
}
}
}
}
22 changes: 22 additions & 0 deletions packages/amis-core/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true,
"react": {
"runtime": "classic"
}
},
"keepClassNames": true,
"externalHelpers": true,
"loose": false
},
"minify": false
}
9 changes: 2 additions & 7 deletions packages/amis-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,7 @@
"js"
],
"transform": {
"\\.(ts|tsx)$": [
"ts-jest",
{
"diagnostics": false
}
]
"^.+\\.(t|j)sx?$": "@swc/jest"
},
"setupFiles": [
"jest-canvas-mock"
Expand All @@ -109,4 +104,4 @@
]
},
"gitHead": "37d23b4a8eb1c663bc38e8dd9040889ea1526ec4"
}
}
6 changes: 3 additions & 3 deletions packages/amis-editor/src/plugin/CRUD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@ export class CRUDPlugin extends BasePlugin {

return {
...rest,
...(valueSchema.mode === 'table' ? {columns} : {}),
...(valueSchema.mode === 'cards'
? {
card: this.transformByMode({
Expand All @@ -882,15 +881,16 @@ export class CRUDPlugin extends BasePlugin {
schema: valueSchema
})
}
: {}),
...(valueSchema.mode === 'list'
: valueSchema.mode === 'list'
? {
listItem: this.transformByMode({
from: 'table',
to: 'list',
schema: valueSchema
})
}
: columns
? {columns}
: {})
};
},
Expand Down
4 changes: 3 additions & 1 deletion packages/amis-editor/src/plugin/TableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,15 @@ export class TableViewPlugin extends BasePlugin {
name: 'border',
type: 'switch',
mode: 'row',
pipeIn: defaultValue(true),
inputClassName: 'inline-flex justify-between flex-row-reverse'
},
{
label: '边框颜色',
type: 'input-color',
name: 'borderColor',
visibleOn: 'this.border',
visibleOn:
'this.border || typeof this.border === "undefined"',
pipeIn: defaultValue('#eceff8')
}
]
Expand Down
9 changes: 2 additions & 7 deletions packages/amis-formula/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,7 @@
"js"
],
"transform": {
"\\.(ts|tsx)$": [
"ts-jest",
{
"diagnostics": false
}
]
"^.+\\.(t|j)sx?$": "@swc/jest"
},
"setupFiles": [
"jest-canvas-mock"
Expand All @@ -119,4 +114,4 @@
}
},
"gitHead": "37d23b4a8eb1c663bc38e8dd9040889ea1526ec4"
}
}
2 changes: 1 addition & 1 deletion packages/amis-theme-editor-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"module": "esm/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\"",
"test": "echo \"Warnings: no test specified\"",
"build": "npm run clean-dist && NODE_ENV=production rollup -c ",
"clean-dist": "rimraf lib/** esm/**",
"i18n:update": "npx i18n update --config=./i18nConfig.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class ParseThemeData {

// 解析组件通用方法
parseComponentCommon(component: any) {
if (component.token) {
if (component.token && component.body) {
// 有token时结束递归
const token = component.token;
for (let key in component.body) {
Expand Down
9 changes: 2 additions & 7 deletions packages/amis-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,7 @@
"js"
],
"transform": {
"\\.(ts|tsx)$": [
"ts-jest",
{
"diagnostics": false
}
]
"^.+\\.(t|j)sx?$": "@swc/jest"
},
"setupFiles": [
"jest-canvas-mock"
Expand All @@ -148,4 +143,4 @@
]
},
"gitHead": "37d23b4a8eb1c663bc38e8dd9040889ea1526ec4"
}
}
11 changes: 10 additions & 1 deletion packages/amis-ui/src/components/TabsTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export interface TabsTransferProps
ctx?: Record<string, any>;
selectMode?: 'table' | 'list' | 'tree' | 'chained' | 'associated';
searchable?: boolean;
/**
* 是否默认都展开
*/
initiallyOpen?: boolean;
}

export interface TabsTransferState {
Expand Down Expand Up @@ -127,7 +131,6 @@ export class TabsTransfer extends React.Component<
if (!Array.isArray(result)) {
throw new Error('onSearch 需要返回数组');
}

this.setState({
searchResult: result
});
Expand Down Expand Up @@ -171,12 +174,15 @@ export class TabsTransfer extends React.Component<
onlyChildren,
selectMode,
loadingConfig,
activeKey,
options: optionsConfig,
valueField = 'value',
labelField = 'label'
} = this.props;
const options = searchResult || [];
const mode = searchResultMode || selectMode; // 没有配置时默认和左侧选项展示形式一致

const activeTab = optionsConfig[activeKey];
return mode === 'table' ? (
<TableCheckboxes
placeholder={noResultsText}
Expand Down Expand Up @@ -204,6 +210,7 @@ export class TabsTransfer extends React.Component<
showIcon={false}
multiple={true}
cascade={true}
autoCheckChildren={activeTab.autoCheckChildren}
itemRender={
optionItemRender
? (item: Option, states: ItemRenderStates) =>
Expand Down Expand Up @@ -349,6 +356,7 @@ export class TabsTransfer extends React.Component<
virtualThreshold,
onlyChildren,
loadingConfig,
initiallyOpen = true,
valueField = 'value',
labelField = 'label',
deferField = 'defer'
Expand Down Expand Up @@ -400,6 +408,7 @@ export class TabsTransfer extends React.Component<
virtualThreshold={virtualThreshold}
valueField={valueField}
labelField={labelField}
initiallyOpen={initiallyOpen}
/>
) : selectMode === 'chained' ? (
<ChainedCheckboxes
Expand Down
3 changes: 2 additions & 1 deletion packages/amis-ui/src/components/TabsTransferPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class TransferPicker extends React.Component<TabsTransferPickerProps> {
popOverContainer,
maxTagCount,
overflowTagPopover,
placeholder,
...rest
} = this.props;

Expand Down Expand Up @@ -100,7 +101,7 @@ export class TransferPicker extends React.Component<TabsTransferPickerProps> {
result={value}
onResultChange={onChange}
onResultClick={onClick}
placeholder={__('Select.placeholder')}
placeholder={placeholder ?? __('Select.placeholder')}
disabled={disabled}
itemRender={option => (
<span>{(option && option[labelField]) || 'undefiend'}</span>
Expand Down

0 comments on commit be51236

Please sign in to comment.