amis 1.9.1-beta.21 → 1.9.1-beta.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. package/lib/components/AssociatedSelection.d.ts +40 -40
  2. package/lib/components/Badge.d.ts +1 -1
  3. package/lib/components/Badge.js.map +1 -1
  4. package/lib/components/ChainedSelection.d.ts +40 -40
  5. package/lib/components/GroupedSelection.d.ts +40 -40
  6. package/lib/components/GroupedSelection.js +2 -3
  7. package/lib/components/GroupedSelection.js.map +2 -2
  8. package/lib/components/PickerContainer.d.ts +0 -1
  9. package/lib/components/PickerContainer.js +4 -4
  10. package/lib/components/PickerContainer.js.map +2 -2
  11. package/lib/components/ResultBox.js +3 -1
  12. package/lib/components/ResultBox.js.map +2 -2
  13. package/lib/components/ResultList.d.ts +53 -43
  14. package/lib/components/ResultList.js +22 -34
  15. package/lib/components/ResultList.js.map +2 -2
  16. package/lib/components/ResultTableList.d.ts +40 -40
  17. package/lib/components/ResultTreeList.d.ts +40 -40
  18. package/lib/components/Select.js +10 -6
  19. package/lib/components/Select.js.map +2 -2
  20. package/lib/components/Selection.d.ts +40 -41
  21. package/lib/components/Selection.js.map +2 -2
  22. package/lib/components/TableSelection.d.ts +40 -40
  23. package/lib/components/TabsTransfer.d.ts +2 -2
  24. package/lib/components/TabsTransfer.js.map +1 -1
  25. package/lib/components/Transfer.d.ts +40 -40
  26. package/lib/components/Transfer.js +1 -1
  27. package/lib/components/Transfer.js.map +2 -2
  28. package/lib/components/TransferDropDown.d.ts +40 -40
  29. package/lib/components/TreeSelection.d.ts +40 -40
  30. package/lib/components/TreeSelection.js +2 -3
  31. package/lib/components/TreeSelection.js.map +2 -2
  32. package/lib/components/formula/Editor.d.ts +45 -45
  33. package/lib/components/formula/Editor.js +16 -11
  34. package/lib/components/formula/Editor.js.map +2 -2
  35. package/lib/components/formula/Picker.d.ts +85 -40
  36. package/lib/components/formula/Picker.js +12 -6
  37. package/lib/components/formula/Picker.js.map +2 -2
  38. package/lib/components/formula/VariableList.d.ts +0 -2
  39. package/lib/components/formula/VariableList.js +5 -15
  40. package/lib/components/formula/VariableList.js.map +2 -2
  41. package/lib/components/index.d.ts +1 -3
  42. package/lib/components/index.js +1 -5
  43. package/lib/components/index.js.map +2 -2
  44. package/lib/components/schema-editor/SchemaVariableList.d.ts +0 -1
  45. package/lib/components/schema-editor/SchemaVariableList.js +2 -2
  46. package/lib/components/schema-editor/SchemaVariableList.js.map +2 -2
  47. package/lib/components/schema-editor/SchemaVariableListPicker.d.ts +0 -1
  48. package/lib/components/schema-editor/SchemaVariableListPicker.js +2 -2
  49. package/lib/components/schema-editor/SchemaVariableListPicker.js.map +2 -2
  50. package/lib/helper.css.map +1 -1
  51. package/lib/index.js +1 -1
  52. package/lib/renderers/CRUD.js +3 -3
  53. package/lib/renderers/CRUD.js.map +2 -2
  54. package/lib/renderers/Form/DiffEditor.d.ts +66 -20
  55. package/lib/renderers/Form/Editor.d.ts +66 -20
  56. package/lib/renderers/Form/Group.js +1 -1
  57. package/lib/renderers/Form/Group.js.map +2 -2
  58. package/lib/renderers/Form/InputFormula.d.ts +5 -5
  59. package/lib/renderers/Form/InputFormula.js +4 -3
  60. package/lib/renderers/Form/InputFormula.js.map +2 -2
  61. package/lib/renderers/Form/InputTag.d.ts +1 -1
  62. package/lib/renderers/Form/InputTag.js.map +1 -1
  63. package/lib/renderers/Form/Options.js +7 -7
  64. package/lib/renderers/Form/Options.js.map +2 -2
  65. package/lib/renderers/Form/Select.d.ts +6 -1
  66. package/lib/renderers/Form/Select.js +3 -1
  67. package/lib/renderers/Form/Select.js.map +2 -2
  68. package/lib/renderers/Form/TreeSelect.d.ts +0 -1
  69. package/lib/renderers/Form/TreeSelect.js +1 -9
  70. package/lib/renderers/Form/TreeSelect.js.map +2 -2
  71. package/lib/renderers/Form/index.js +9 -4
  72. package/lib/renderers/Form/index.js.map +2 -2
  73. package/lib/renderers/Table/exportExcel.js +1 -1
  74. package/lib/renderers/Table/exportExcel.js.map +2 -2
  75. package/lib/renderers/Table/index.d.ts +2 -0
  76. package/lib/renderers/Table/index.js +37 -5
  77. package/lib/renderers/Table/index.js.map +2 -2
  78. package/lib/renderers/Tpl.d.ts +4 -0
  79. package/lib/renderers/Tpl.js +6 -3
  80. package/lib/renderers/Tpl.js.map +2 -2
  81. package/lib/store/combo.d.ts +72 -22
  82. package/lib/store/form.d.ts +30 -9
  83. package/lib/store/form.js +28 -10
  84. package/lib/store/form.js.map +2 -2
  85. package/lib/store/formItem.d.ts +3 -1
  86. package/lib/store/formItem.js +3 -5
  87. package/lib/store/formItem.js.map +2 -2
  88. package/lib/store/table.d.ts +60 -18
  89. package/lib/themes/ang-ie11.css +33 -9
  90. package/lib/themes/ang.css +27 -9
  91. package/lib/themes/ang.css.map +1 -1
  92. package/lib/themes/antd-ie11.css +33 -9
  93. package/lib/themes/antd.css +27 -9
  94. package/lib/themes/antd.css.map +1 -1
  95. package/lib/themes/cxd-ie11.css +35 -15
  96. package/lib/themes/cxd.css +31 -17
  97. package/lib/themes/cxd.css.map +1 -1
  98. package/lib/themes/dark-ie11.css +33 -9
  99. package/lib/themes/dark.css +27 -9
  100. package/lib/themes/dark.css.map +1 -1
  101. package/lib/themes/default-ie11.css +35 -15
  102. package/lib/themes/default.css +31 -17
  103. package/lib/themes/default.css.map +1 -1
  104. package/lib/utils/formula.js +2 -3
  105. package/lib/utils/formula.js.map +2 -2
  106. package/lib/utils/helper.js +1 -1
  107. package/lib/utils/helper.js.map +2 -2
  108. package/package.json +1 -1
  109. package/schema.json +22 -16
  110. package/scss/_mixins.scss +1 -1
  111. package/scss/components/form/_date.scss +9 -10
  112. package/scss/components/form/_select.scss +14 -0
  113. package/scss/components/form/_transfer.scss +1 -2
  114. package/scss/themes/cxd.scss +4 -9
  115. package/sdk/ang-ie11.css +36 -9
  116. package/sdk/ang.css +30 -9
  117. package/sdk/antd-ie11.css +36 -9
  118. package/sdk/antd.css +30 -9
  119. package/sdk/barcode.js +51 -51
  120. package/sdk/charts.js +14 -14
  121. package/sdk/codemirror.js +7 -7
  122. package/sdk/color-picker.js +65 -65
  123. package/sdk/cropperjs.js +2 -2
  124. package/sdk/cxd-ie11.css +38 -16
  125. package/sdk/cxd.css +34 -18
  126. package/sdk/dark-ie11.css +36 -9
  127. package/sdk/dark.css +30 -9
  128. package/sdk/exceljs.js +1 -1
  129. package/sdk/helper.css.map +1 -1
  130. package/sdk/markdown.js +69 -69
  131. package/sdk/papaparse.js +1 -1
  132. package/sdk/renderers/Form/CityDB.js +1 -1
  133. package/sdk/rest.js +16 -16
  134. package/sdk/rich-text.js +62 -62
  135. package/sdk/sdk-ie11.css +38 -16
  136. package/sdk/sdk.css +34 -18
  137. package/sdk/sdk.js +1356 -1354
  138. package/sdk/thirds/hls.js/hls.js +1 -1
  139. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  140. package/sdk/tinymce.js +57 -57
  141. package/src/components/Badge.tsx +1 -1
  142. package/src/components/GroupedSelection.tsx +2 -3
  143. package/src/components/PickerContainer.tsx +8 -13
  144. package/src/components/ResultBox.tsx +3 -1
  145. package/src/components/ResultList.tsx +51 -48
  146. package/src/components/Select.tsx +16 -8
  147. package/src/components/Selection.tsx +0 -1
  148. package/src/components/TabsTransfer.tsx +2 -2
  149. package/src/components/Transfer.tsx +4 -0
  150. package/src/components/TreeSelection.tsx +1 -2
  151. package/src/components/formula/Editor.tsx +51 -38
  152. package/src/components/formula/Picker.tsx +26 -7
  153. package/src/components/formula/VariableList.tsx +2 -36
  154. package/src/components/index.tsx +0 -4
  155. package/src/components/schema-editor/SchemaVariableList.tsx +2 -4
  156. package/src/components/schema-editor/SchemaVariableListPicker.tsx +1 -4
  157. package/src/renderers/CRUD.tsx +3 -3
  158. package/src/renderers/Form/Group.tsx +1 -1
  159. package/src/renderers/Form/InputFormula.tsx +11 -10
  160. package/src/renderers/Form/InputTag.tsx +1 -1
  161. package/src/renderers/Form/Options.tsx +7 -9
  162. package/src/renderers/Form/Select.tsx +10 -2
  163. package/src/renderers/Form/TreeSelect.tsx +14 -16
  164. package/src/renderers/Form/index.tsx +13 -2
  165. package/src/renderers/Table/exportExcel.ts +1 -1
  166. package/src/renderers/Table/index.tsx +42 -6
  167. package/src/renderers/Tpl.tsx +11 -1
  168. package/src/store/form.ts +31 -24
  169. package/src/store/formItem.ts +65 -52
  170. package/src/utils/formula.ts +2 -2
  171. package/src/utils/helper.ts +2 -2
@@ -6,7 +6,6 @@ import Tabs, {Tab} from '../Tabs';
6
6
  import TreeSelection from '../TreeSelection';
7
7
  import SearchBox from '../SearchBox';
8
8
  import {findTree} from '../../utils/helper';
9
- import {Badge} from '../Badge';
10
9
 
11
10
  import type {VariableItem} from './Editor';
12
11
  import type {ItemRenderStates} from '../Selection';
@@ -21,9 +20,7 @@ export interface VariableListProps extends ThemeProps {
21
20
  selectMode?: 'list' | 'tree' | 'tabs';
22
21
  tabsMode?: TabsMode;
23
22
  itemRender?: (option: Option, states: ItemRenderStates) => JSX.Element;
24
- placeholderRender?: (props: any) => JSX.Element | null;
25
23
  onSelect?: (item: VariableItem) => void;
26
- selfVariableName?: string;
27
24
  }
28
25
 
29
26
  function VariableList(props: VariableListProps) {
@@ -35,9 +32,7 @@ function VariableList(props: VariableListProps) {
35
32
  classPrefix: themePrefix,
36
33
  itemClassName,
37
34
  selectMode,
38
- onSelect,
39
- placeholderRender,
40
- selfVariableName
35
+ onSelect
41
36
  } = props;
42
37
  const [filterVars, setFilterVars] = React.useState(list);
43
38
  const classPrefix = `${themePrefix}FormulaEditor-VariableList`;
@@ -47,32 +42,7 @@ function VariableList(props: VariableListProps) {
47
42
  : (option: Option, states: ItemRenderStates): JSX.Element => {
48
43
  return (
49
44
  <span className={cx(`${classPrefix}-item`, itemClassName)}>
50
- {
51
- option.label && option.label === selfVariableName && (
52
- <Badge
53
- classnames={cx}
54
- badge={{
55
- mode: "text",
56
- text: "self",
57
- offset: [
58
- 15,
59
- 2
60
- ]
61
- }}
62
- >
63
- <label>
64
- {option.label}
65
- </label>
66
- </Badge>
67
- )
68
- }
69
- {
70
- option.label && option.label !== selfVariableName && (
71
- <label>
72
- {option.label}
73
- </label>
74
- )
75
- }
45
+ <label>{option.label}</label>
76
46
  {option?.tag ? (
77
47
  <span className={cx(`${classPrefix}-item-tag`)}>
78
48
  {option.tag}
@@ -120,11 +90,9 @@ function VariableList(props: VariableListProps) {
120
90
  classPrefix={`${classPrefix}-sub-`}
121
91
  className={cx(`${classPrefix}-sub`)}
122
92
  itemRender={itemRender}
123
- placeholderRender={placeholderRender}
124
93
  selectMode={item.selectMode}
125
94
  data={item.children!}
126
95
  onSelect={onSelect}
127
- selfVariableName={selfVariableName}
128
96
  />
129
97
  </Tab>
130
98
  ))}
@@ -134,7 +102,6 @@ function VariableList(props: VariableListProps) {
134
102
  {renderSearchBox()}
135
103
  <TreeSelection
136
104
  itemRender={itemRender}
137
- placeholderRender={placeholderRender}
138
105
  className={cx(`${classPrefix}-base`, 'is-scrollable')}
139
106
  multiple={false}
140
107
  options={filterVars}
@@ -146,7 +113,6 @@ function VariableList(props: VariableListProps) {
146
113
  {renderSearchBox()}
147
114
  <GroupedSelection
148
115
  itemRender={itemRender}
149
- placeholderRender={placeholderRender}
150
116
  className={cx(`${classPrefix}-base`, 'is-scrollable')}
151
117
  multiple={false}
152
118
  options={filterVars}
@@ -61,9 +61,7 @@ import PullRefresh from './PullRefresh';
61
61
  import Table from './table';
62
62
  import SchemaVariableListPicker from './schema-editor/SchemaVariableListPicker';
63
63
  import SchemaVariableList from './schema-editor/SchemaVariableList';
64
- import VariableList from './formula/VariableList';
65
64
  import FormulaPicker from './formula/Picker';
66
- import PickerContainer from './PickerContainer';
67
65
  import InputJSONSchema from './json-schema';
68
66
 
69
67
  export {
@@ -130,8 +128,6 @@ export {
130
128
  Table,
131
129
  SchemaVariableListPicker,
132
130
  SchemaVariableList,
133
- VariableList,
134
- PickerContainer,
135
131
  FormulaPicker,
136
132
  InputJSONSchema
137
133
  };
@@ -13,7 +13,6 @@ export interface SchemaVariableListProps extends LocaleProps, ThemeProps {
13
13
  value?: string;
14
14
  onSelect?: (value: string, schema: JSONSchema) => void;
15
15
  selectMode?: 'list' | 'tree' | 'tabs';
16
- placeholderRender?: (props: any) => JSX.Element | null;
17
16
  beforeBuildVariables?: (dataSchema: DataSchema) => void;
18
17
  }
19
18
 
@@ -78,16 +77,15 @@ export class SchemaVariableList extends React.Component<
78
77
  }
79
78
 
80
79
  render() {
81
- const {selectMode, value, placeholderRender} = this.props;
80
+ const {selectMode} = this.props;
82
81
 
83
82
  return (
84
83
  <VariableList
85
84
  data={this.state.variables}
86
- value={value}
85
+ value={this.props.value}
87
86
  onSelect={this.handleSelect}
88
87
  selectMode={selectMode || 'tree'}
89
88
  itemRender={this.itemRender}
90
- placeholderRender={placeholderRender}
91
89
  />
92
90
  );
93
91
  }
@@ -17,7 +17,6 @@ export interface SchemaVariableListPickerProps extends SchemaVariableListProps {
17
17
  onConfirm?: (value?: any) => void;
18
18
  onCancel?: () => void;
19
19
  onPickerOpen?: (props: any) => any;
20
- placeholderRender?: (props: any) => JSX.Element | null;
21
20
  }
22
21
 
23
22
  export class SchemaVariableListPicker extends React.Component<SchemaVariableListPickerProps> {
@@ -32,8 +31,7 @@ export class SchemaVariableListPicker extends React.Component<SchemaVariableList
32
31
  title,
33
32
  selectMode,
34
33
  beforeBuildVariables,
35
- onPickerOpen,
36
- placeholderRender
34
+ onPickerOpen
37
35
  } = this.props;
38
36
 
39
37
  return (
@@ -53,7 +51,6 @@ export class SchemaVariableListPicker extends React.Component<SchemaVariableList
53
51
  schemas={stateSchemas ?? schemas}
54
52
  selectMode={selectMode}
55
53
  beforeBuildVariables={beforeBuildVariables}
56
- placeholderRender={placeholderRender}
57
54
  />
58
55
  ) : (
59
56
  <></>
@@ -490,8 +490,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
490
490
  // 另外autoGenerateFilter时,table 里面会单独处理这块逻辑
491
491
  // 所以这里应该忽略 autoGenerateFilter 情况
492
492
  if (
493
- (!this.props.filter || (store.filterTogggable && !store.filterVisible)) &&
494
- !autoGenerateFilter
493
+ (!this.props.filter && !autoGenerateFilter) ||
494
+ (store.filterTogggable && !store.filterVisible)
495
495
  ) {
496
496
  this.handleFilterInit({});
497
497
  }
@@ -670,7 +670,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
670
670
  throw e;
671
671
  }
672
672
  });
673
- } else if (action.actionType === 'reload') {
673
+ } else if (action.actionType === 'reload' && !action.target) {
674
674
  this.reload();
675
675
  } else if (
676
676
  pickerMode &&
@@ -89,7 +89,7 @@ export class ControlGroupRenderer extends React.Component<InputGroupProps> {
89
89
  const subSchema: any = control;
90
90
 
91
91
  return render(`${index}`, subSchema, {
92
- disabled,
92
+ disabled: control.disabled || disabled,
93
93
  formMode: subFormMode || mode || formMode,
94
94
  formHorizontal: subFormHorizontal || horizontal || formHorizontal,
95
95
  ...otherProps
@@ -94,6 +94,11 @@ export interface InputFormulaControlSchema extends FormBaseControl {
94
94
  */
95
95
  borderMode?: 'full' | 'half' | 'none';
96
96
 
97
+ /**
98
+ * 只展示变量,不需要其他面板
99
+ */
100
+ onlyVariable?: boolean;
101
+
97
102
  /**
98
103
  * 输入框占位符
99
104
  */
@@ -108,11 +113,6 @@ export interface InputFormulaControlSchema extends FormBaseControl {
108
113
  * 函数面板CSS样式类名
109
114
  */
110
115
  functionClassName?: string;
111
-
112
- /**
113
- * 当前输入项字段 name: 用于避免循环绑定自身导致无限渲染
114
- */
115
- selfVariableName?: string;
116
116
  }
117
117
 
118
118
  export interface InputFormulaProps
@@ -128,11 +128,12 @@ export interface InputFormulaProps
128
128
  export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
129
129
  static defaultProps: Pick<
130
130
  InputFormulaControlSchema,
131
- 'inputMode' | 'borderMode' | 'evalMode'
131
+ 'inputMode' | 'borderMode' | 'evalMode' | 'onlyVariable'
132
132
  > = {
133
133
  inputMode: 'input-button',
134
134
  borderMode: 'full',
135
- evalMode: true
135
+ evalMode: true,
136
+ onlyVariable: false
136
137
  };
137
138
 
138
139
  ref: any;
@@ -167,6 +168,7 @@ export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
167
168
  onChange,
168
169
  evalMode,
169
170
  variableMode,
171
+ onlyVariable,
170
172
  header,
171
173
  label,
172
174
  value,
@@ -186,8 +188,7 @@ export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
186
188
  variableClassName,
187
189
  functionClassName,
188
190
  data,
189
- onPickerOpen,
190
- selfVariableName
191
+ onPickerOpen
191
192
  } = this.props;
192
193
  let {variables, functions} = this.props;
193
194
 
@@ -212,6 +213,7 @@ export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
212
213
  evalMode={evalMode}
213
214
  variables={variables}
214
215
  variableMode={variableMode}
216
+ onlyVariable={onlyVariable}
215
217
  functions={functions}
216
218
  header={header || label || ''}
217
219
  borderMode={borderMode}
@@ -227,7 +229,6 @@ export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
227
229
  functionClassName={functionClassName}
228
230
  data={data}
229
231
  onPickerOpen={onPickerOpen}
230
- selfVariableName={selfVariableName}
231
232
  />
232
233
  );
233
234
  }
@@ -41,7 +41,7 @@ export interface TagControlSchema extends FormOptionsControl {
41
41
  /**
42
42
  * 收纳标签的Popover配置
43
43
  */
44
- overflowTagPopover: object;
44
+ overflowTagPopover?: object;
45
45
  }
46
46
 
47
47
  // declare function matchSorter(items:Array<any>, input:any, options:any): Array<any>;
@@ -320,10 +320,14 @@ export function registerOptionsControl(config: OptionsConfig) {
320
320
 
321
321
  this.toDispose.push(
322
322
  reaction(
323
- () => JSON.stringify(formItem.options),
324
- () => this.mounted && this.syncAutoFill(formItem.tmpValue)
323
+ () =>
324
+ JSON.stringify(formItem.getSelectedOptions(formItem.tmpValue)),
325
+ () =>
326
+ this.mounted &&
327
+ this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue))
325
328
  )
326
329
  );
330
+
327
331
  // 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
328
332
  if (
329
333
  multiple &&
@@ -361,10 +365,6 @@ export function registerOptionsControl(config: OptionsConfig) {
361
365
  componentDidMount() {
362
366
  this.mounted = true;
363
367
  this.normalizeValue();
364
-
365
- if (this.props.value) {
366
- this.syncAutoFill(this.props.value);
367
- }
368
368
  }
369
369
 
370
370
  shouldComponentUpdate(nextProps: OptionsProps) {
@@ -448,7 +448,6 @@ export function registerOptionsControl(config: OptionsConfig) {
448
448
 
449
449
  if (prevProps.value !== props.value || formItem?.expressionsInOptions) {
450
450
  formItem.syncOptions(undefined, props.data);
451
- this.syncAutoFill(props.value);
452
451
  }
453
452
  }
454
453
 
@@ -482,7 +481,7 @@ export function registerOptionsControl(config: OptionsConfig) {
482
481
  }
483
482
  }
484
483
 
485
- syncAutoFill(value: any) {
484
+ syncAutoFill(selectedOptions: Array<any>) {
486
485
  const {autoFill, multiple, onBulkChange, data} = this.props;
487
486
  const formItem = this.props.formItem as IFormItemStore;
488
487
 
@@ -492,7 +491,6 @@ export function registerOptionsControl(config: OptionsConfig) {
492
491
  !isEmpty(autoFill) &&
493
492
  formItem.filteredOptions.length
494
493
  ) {
495
- const selectedOptions = formItem.getSelectedOptions(value);
496
494
  const toSync = dataMapping(
497
495
  autoFill,
498
496
  multiple
@@ -19,6 +19,7 @@ import {BaseTransferRenderer, TransferControlSchema} from './Transfer';
19
19
  import TransferDropDown from '../../components/TransferDropDown';
20
20
 
21
21
  import type {TooltipObject} from '../../components/TooltipWrapper';
22
+ import type {SchemaClassName} from '../../Schema';
22
23
 
23
24
  /**
24
25
  * Select 下拉选择框。
@@ -121,7 +122,12 @@ export interface SelectControlSchema extends FormOptionsControl {
121
122
  /**
122
123
  * 收纳标签的Popover配置
123
124
  */
124
- overflowTagPopover: object;
125
+ overflowTagPopover?: object;
126
+
127
+ /**
128
+ * 选项的自定义CSS类名
129
+ */
130
+ optionClassName?: SchemaClassName;
125
131
  }
126
132
 
127
133
  export interface SelectProps extends OptionsControlProps {
@@ -349,9 +355,11 @@ export default class SelectControl extends React.Component<SelectProps, any> {
349
355
 
350
356
  @autobind
351
357
  renderMenu(option: Option, state: any) {
352
- const {menuTpl, render, data} = this.props;
358
+ const {menuTpl, render, data, optionClassName} = this.props;
353
359
 
354
360
  return render(`menu/${state.index}`, menuTpl, {
361
+ showNativeTitle: true,
362
+ className: cx('Select-option-content', optionClassName),
355
363
  data: createObject(createObject(data, state), option)
356
364
  });
357
365
  }
@@ -112,7 +112,6 @@ export interface TreeSelectProps extends OptionsControlProps {
112
112
 
113
113
  export interface TreeSelectState {
114
114
  isOpened: boolean;
115
- isFocused: boolean;
116
115
  inputValue: string;
117
116
  }
118
117
 
@@ -157,8 +156,7 @@ export default class TreeSelectControl extends React.Component<
157
156
 
158
157
  this.state = {
159
158
  inputValue: '',
160
- isOpened: false,
161
- isFocused: false
159
+ isOpened: false
162
160
  };
163
161
 
164
162
  this.open = this.open.bind(this);
@@ -206,22 +204,23 @@ export default class TreeSelectControl extends React.Component<
206
204
 
207
205
  handleFocus(e: any) {
208
206
  const {dispatchEvent, value, data} = this.props;
209
- this.setState({
210
- isFocused: true
211
- });
212
- dispatchEvent('focus', createObject(data, {
213
- value
214
- }));
207
+
208
+ dispatchEvent(
209
+ 'focus',
210
+ createObject(data, {
211
+ value
212
+ })
213
+ );
215
214
  }
216
215
 
217
216
  handleBlur(e: any) {
218
217
  const {dispatchEvent, value, data} = this.props;
219
- this.setState({
220
- isFocused: false
221
- });
222
- dispatchEvent('blur', createObject(data, {
223
- value
224
- }));
218
+ dispatchEvent(
219
+ 'blur',
220
+ createObject(data, {
221
+ value
222
+ })
223
+ );
225
224
  }
226
225
 
227
226
  handleKeyPress(e: React.KeyboardEvent) {
@@ -645,7 +644,6 @@ export default class TreeSelectControl extends React.Component<
645
644
  'TreeSelect--searchable':
646
645
  searchable || isEffectiveApi(autoComplete),
647
646
  'is-opened': this.state.isOpened,
648
- 'is-focused': this.state.isFocused,
649
647
  'is-disabled': disabled
650
648
  })}
651
649
  result={
@@ -63,7 +63,7 @@ export interface FormSchemaHorizontal {
63
63
  right?: number;
64
64
  leftFixed?: boolean | number | 'xs' | 'sm' | 'md' | 'lg';
65
65
  justify?: boolean; // 两端对齐
66
- labelAlign?: 'left' | 'right' // label对齐方式
66
+ labelAlign?: 'left' | 'right'; // label对齐方式
67
67
  }
68
68
 
69
69
  /**
@@ -988,7 +988,14 @@ export default class Form extends React.Component<FormProps, object> {
988
988
  data = store.data;
989
989
  }
990
990
  if (Array.isArray(action.required) && action.required.length) {
991
- return store.validateFields(action.required).then(async result => {
991
+ store.clearErrors(); // 如果是按钮指定了required,则校验前先清空一下遗留的校验报错
992
+
993
+ const fields = action.required.map(item => ({
994
+ name: item,
995
+ rules: {isRequired: true}
996
+ }));
997
+
998
+ return store.validateFields(fields).then(async result => {
992
999
  if (!result) {
993
1000
  const dispatcher = await dispatchEvent(
994
1001
  'validateError',
@@ -997,6 +1004,9 @@ export default class Form extends React.Component<FormProps, object> {
997
1004
  if (!dispatcher?.prevented) {
998
1005
  env.notify('error', __('Form.validateFailed'));
999
1006
  }
1007
+
1008
+ /** 抛异常是为了在dialog中catch这个错误,避免弹窗直接关闭 */
1009
+ return Promise.reject(__('Form.validateFailed'));
1000
1010
  } else {
1001
1011
  dispatchEvent('validateSucc', this.props.data);
1002
1012
  this.handleAction(
@@ -1006,6 +1016,7 @@ export default class Form extends React.Component<FormProps, object> {
1006
1016
  throwErrors,
1007
1017
  delegate
1008
1018
  );
1019
+ return;
1009
1020
  }
1010
1021
  });
1011
1022
  }
@@ -221,7 +221,7 @@ export async function exportExcel(
221
221
  text: text || absoluteURL,
222
222
  hyperlink: absoluteURL
223
223
  };
224
- } else if (type === 'mapping') {
224
+ } else if (type === 'mapping' || (type as any) === 'static-mapping') {
225
225
  // 拷贝自 Mapping.tsx
226
226
  let map = column.pristine.map;
227
227
  const source = column.pristine.source;
@@ -1081,11 +1081,11 @@ export default class Table extends React.Component<TableProps, object> {
1081
1081
  } = (this.heights = {});
1082
1082
 
1083
1083
  heights.header = table
1084
- .querySelector('thead>tr:last-child')!
1085
- .getBoundingClientRect().height;
1086
- heights.header2 = table
1087
- .querySelector('thead>tr:first-child')!
1084
+ .querySelector('thead')!
1088
1085
  .getBoundingClientRect().height;
1086
+ // heights.header2 = table
1087
+ // .querySelector('thead>tr:first-child')!
1088
+ // .getBoundingClientRect().height;
1089
1089
 
1090
1090
  forEach(
1091
1091
  table.querySelectorAll('thead>tr:last-child>th'),
@@ -1132,7 +1132,7 @@ export default class Table extends React.Component<TableProps, object> {
1132
1132
  table.querySelectorAll('thead>tr:first-child>th'),
1133
1133
  (item: HTMLElement) => {
1134
1134
  const width = widths2[item.getAttribute('data-index') as string];
1135
- item.style.cssText += `width: ${width}px; height: ${heights.header2}px`;
1135
+ item.style.cssText += `width: ${width}px; height: ${heights.header}px`;
1136
1136
  totalWidth2 += width;
1137
1137
  }
1138
1138
  );
@@ -2797,6 +2797,42 @@ export default class Table extends React.Component<TableProps, object> {
2797
2797
  storeType: TableStore.name,
2798
2798
  name: 'table'
2799
2799
  })
2800
- export class TableRenderer extends Table {}
2800
+ export class TableRenderer extends Table {
2801
+ receive(values: any, subPath?: string) {
2802
+ const scoped = this.context as IScopedContext;
2803
+ const parents = scoped?.parent?.getComponents();
2804
+
2805
+ /**
2806
+ * 因为Table在scope上注册,导致getComponentByName查询组件时会优先找到Table,和CRUD联动的动作都会失效
2807
+ * 这里先做兼容处理,把动作交给上层的CRUD处理
2808
+ */
2809
+ if (Array.isArray(parents) && parents.length) {
2810
+ // CRUD的name会透传给Table,这样可以保证找到CRUD
2811
+ const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
2812
+
2813
+ return crud?.receive?.(values, subPath);
2814
+ }
2815
+
2816
+ if (subPath) {
2817
+ return scoped.send(subPath, values);
2818
+ }
2819
+ }
2820
+
2821
+ reload(subPath?: string, query?: any, ctx?: any) {
2822
+ const scoped = this.context as IScopedContext;
2823
+ const parents = scoped?.parent?.getComponents();
2824
+
2825
+ if (Array.isArray(parents) && parents.length) {
2826
+ // CRUD的name会透传给Table,这样可以保证找到CRUD
2827
+ const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
2828
+
2829
+ return crud?.reload?.(subPath, query, ctx);
2830
+ }
2831
+
2832
+ if (subPath) {
2833
+ return scoped.reload(subPath, ctx);
2834
+ }
2835
+ }
2836
+ }
2801
2837
 
2802
2838
  export {TableCell};
@@ -40,6 +40,11 @@ export interface TplSchema extends BaseSchema {
40
40
  * 角标
41
41
  */
42
42
  badge?: BadgeSchema;
43
+
44
+ /**
45
+ * 是否设置外层DOM节点的title属性为文本内容
46
+ */
47
+ showNativeTitle?: boolean;
43
48
  }
44
49
 
45
50
  export interface TplProps extends RendererProps, TplSchema {
@@ -117,17 +122,22 @@ export class Tpl extends React.Component<TplProps, object> {
117
122
  inline,
118
123
  classnames: cx,
119
124
  style,
125
+ showNativeTitle,
120
126
  data
121
127
  } = this.props;
122
128
  const Component = wrapperComponent || (inline ? 'span' : 'div');
129
+ const content = this.getContent();
123
130
 
124
131
  return (
125
132
  <Component
126
133
  ref={this.htmlRef}
127
134
  className={cx('TplField', className)}
128
135
  style={buildStyle(style, data)}
136
+ {...(showNativeTitle
137
+ ? {title: typeof content === 'string' ? content : ''}
138
+ : {})}
129
139
  >
130
- <span>{this.getContent()}</span>
140
+ <span>{content}</span>
131
141
  </Component>
132
142
  );
133
143
  }
package/src/store/form.ts CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  Instance
10
10
  } from 'mobx-state-tree';
11
11
  import debounce from 'lodash/debounce';
12
+ import find from 'lodash/find';
12
13
  import {ServiceStore} from './service';
13
14
  import {FormItemStore, IFormItemStore, SFormItemStore} from './formItem';
14
15
  import {Api, ApiObject, fetchOptions, Payload} from '../types';
@@ -326,7 +327,6 @@ export const FormStore = ServiceStore.named('FormStore')
326
327
  }
327
328
 
328
329
  if (!json.ok) {
329
-
330
330
  if (json.status === 422 && json.errors) {
331
331
  setFormItemErrors(json.errors);
332
332
 
@@ -359,22 +359,23 @@ export const FormStore = ServiceStore.named('FormStore')
359
359
  );
360
360
  if (!ret?.dispatcher?.prevented) {
361
361
  self.msg &&
362
- getEnv(self).notify(
363
- 'success',
364
- self.msg,
365
- json.msgTimeout !== undefined
366
- ? {
367
- closeButton: true,
368
- timeout: json.msgTimeout
369
- }
370
- : undefined
371
- );
362
+ getEnv(self).notify(
363
+ 'success',
364
+ self.msg,
365
+ json.msgTimeout !== undefined
366
+ ? {
367
+ closeButton: true,
368
+ timeout: json.msgTimeout
369
+ }
370
+ : undefined
371
+ );
372
372
  }
373
373
  return json.data;
374
374
  }
375
375
  } catch (e) {
376
376
  self.markSaving(false);
377
- let ret = options && options.onFailed && options.onFailed(e.response || {});
377
+ let ret =
378
+ options && options.onFailed && options.onFailed(e.response || {});
378
379
  if (ret?.then) {
379
380
  ret = yield ret;
380
381
  }
@@ -486,7 +487,7 @@ export const FormStore = ServiceStore.named('FormStore')
486
487
  if (dispatcher?.then) {
487
488
  dispatcher = yield dispatcher;
488
489
  }
489
- if (!dispatcher?.prevented){
490
+ if (!dispatcher?.prevented) {
490
491
  msg && env.notify('error', msg);
491
492
  }
492
493
  throw new Error(msg);
@@ -548,20 +549,26 @@ export const FormStore = ServiceStore.named('FormStore')
548
549
  return self.valid;
549
550
  });
550
551
 
551
- const validateFields: (fields: Array<string>) => Promise<boolean> = flow(
552
- function* validateFields(fields: Array<string>) {
553
- const items = self.items.concat();
554
- let result: Array<boolean> = [];
555
- for (let i = 0, len = items.length; i < len; i++) {
556
- let item = items[i] as IFormItemStore;
552
+ const validateFields: (
553
+ fields: Array<string | {name: string; rules: {[propName: string]: any}}>
554
+ ) => Promise<boolean> = flow(function* validateFields(
555
+ fields: Array<string | {name: string; rules: {[propName: string]: any}}>
556
+ ) {
557
+ const items = self.items.concat();
558
+ const normalizedfields = fields.map(field =>
559
+ typeof field === 'string' ? {name: field, rules: {}} : field
560
+ );
561
+ let result: Array<boolean> = [];
562
+ for (let i = 0, len = items.length; i < len; i++) {
563
+ let item = items[i] as IFormItemStore;
564
+ const field = find(normalizedfields, field => field.name === item.name);
557
565
 
558
- if (~fields.indexOf(item.name)) {
559
- result.push(yield item.validate(self.data));
560
- }
566
+ if (field) {
567
+ result.push(yield item.validate(self.data, undefined, field.rules));
561
568
  }
562
- return result.every(item => item);
563
569
  }
564
- );
570
+ return result.every(item => item);
571
+ });
565
572
 
566
573
  function clearErrors() {
567
574
  const items = self.items.concat();