amis 1.9.1-beta.21 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/lib/components/ResultBox.js +3 -1
  2. package/lib/components/ResultBox.js.map +2 -2
  3. package/lib/components/Select.js +1 -1
  4. package/lib/components/Select.js.map +2 -2
  5. package/lib/components/formula/Editor.js +3 -2
  6. package/lib/components/formula/Editor.js.map +2 -2
  7. package/lib/components/formula/Picker.js +2 -2
  8. package/lib/components/formula/Picker.js.map +2 -2
  9. package/lib/components/formula/VariableList.js +2 -2
  10. package/lib/components/formula/VariableList.js.map +1 -1
  11. package/lib/index.js +1 -1
  12. package/lib/renderers/Form/ConditionBuilder.js +8 -1
  13. package/lib/renderers/Form/ConditionBuilder.js.map +2 -2
  14. package/lib/renderers/Form/InputTag.d.ts +1 -1
  15. package/lib/renderers/Form/InputTag.js.map +1 -1
  16. package/lib/renderers/Form/Select.d.ts +6 -1
  17. package/lib/renderers/Form/Select.js +3 -1
  18. package/lib/renderers/Form/Select.js.map +2 -2
  19. package/lib/renderers/Table/index.d.ts +1 -0
  20. package/lib/renderers/Table/index.js +18 -0
  21. package/lib/renderers/Table/index.js.map +2 -2
  22. package/lib/renderers/Tpl.d.ts +4 -0
  23. package/lib/renderers/Tpl.js +6 -3
  24. package/lib/renderers/Tpl.js.map +2 -2
  25. package/lib/themes/ang-ie11.css +13 -1
  26. package/lib/themes/ang.css +13 -1
  27. package/lib/themes/ang.css.map +1 -1
  28. package/lib/themes/antd-ie11.css +13 -1
  29. package/lib/themes/antd.css +13 -1
  30. package/lib/themes/antd.css.map +1 -1
  31. package/lib/themes/cxd-ie11.css +13 -1
  32. package/lib/themes/cxd.css +13 -1
  33. package/lib/themes/cxd.css.map +1 -1
  34. package/lib/themes/dark-ie11.css +13 -1
  35. package/lib/themes/dark.css +13 -1
  36. package/lib/themes/dark.css.map +1 -1
  37. package/lib/themes/default-ie11.css +13 -1
  38. package/lib/themes/default.css +13 -1
  39. package/lib/themes/default.css.map +1 -1
  40. package/package.json +1 -1
  41. package/schema.json +22 -16
  42. package/scss/components/_formula.scss +4 -1
  43. package/scss/components/form/_select.scss +10 -0
  44. package/sdk/ang-ie11.css +14 -1
  45. package/sdk/ang.css +14 -1
  46. package/sdk/antd-ie11.css +14 -1
  47. package/sdk/antd.css +14 -1
  48. package/sdk/barcode.js +51 -51
  49. package/sdk/charts.js +14 -14
  50. package/sdk/codemirror.js +7 -7
  51. package/sdk/color-picker.js +65 -65
  52. package/sdk/cropperjs.js +2 -2
  53. package/sdk/cxd-ie11.css +14 -1
  54. package/sdk/cxd.css +14 -1
  55. package/sdk/dark-ie11.css +14 -1
  56. package/sdk/dark.css +14 -1
  57. package/sdk/exceljs.js +1 -1
  58. package/sdk/markdown.js +69 -69
  59. package/sdk/papaparse.js +1 -1
  60. package/sdk/renderers/Form/CityDB.js +1 -1
  61. package/sdk/rest.js +16 -16
  62. package/sdk/rich-text.js +62 -62
  63. package/sdk/sdk-ie11.css +14 -1
  64. package/sdk/sdk.css +14 -1
  65. package/sdk/sdk.js +1333 -1333
  66. package/sdk/thirds/hls.js/hls.js +1 -1
  67. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  68. package/sdk/tinymce.js +57 -57
  69. package/src/components/ResultBox.tsx +3 -1
  70. package/src/components/Select.tsx +6 -1
  71. package/src/components/formula/Editor.tsx +3 -2
  72. package/src/components/formula/Picker.tsx +2 -2
  73. package/src/components/formula/VariableList.tsx +2 -2
  74. package/src/renderers/Form/ConditionBuilder.tsx +16 -0
  75. package/src/renderers/Form/InputTag.tsx +1 -1
  76. package/src/renderers/Form/Select.tsx +10 -2
  77. package/src/renderers/Table/index.tsx +21 -1
  78. package/src/renderers/Tpl.tsx +11 -1
@@ -215,6 +215,8 @@ export class ResultBox extends React.Component<ResultBoxProps> {
215
215
  } = this.props;
216
216
  const isFocused = this.state.isFocused;
217
217
  const mobileUI = useMobileUI && isMobile();
218
+ /** 不需要透传给Input的属性 */
219
+ const omitPropsList = ['maxTagCount', 'overflowTagPopover'];
218
220
 
219
221
  return (
220
222
  <div
@@ -248,7 +250,7 @@ export class ResultBox extends React.Component<ResultBoxProps> {
248
250
 
249
251
  {allowInput && !disabled ? (
250
252
  <Input
251
- {...rest}
253
+ {...omit(rest, omitPropsList)}
252
254
  onKeyPress={onKeyPress}
253
255
  ref={this.inputRef}
254
256
  value={value || ''}
@@ -1076,7 +1076,12 @@ export class Select extends React.Component<SelectProps, SelectState> {
1076
1076
  {item.tip}
1077
1077
  </Checkbox>
1078
1078
  ) : (
1079
- <span>
1079
+ <span
1080
+ className={cx('Select-option-content')}
1081
+ title={
1082
+ typeof item[labelField] === 'string' ? item[labelField] : ''
1083
+ }
1084
+ >
1080
1085
  {item.disabled
1081
1086
  ? item[labelField]
1082
1087
  : highlight(
@@ -167,7 +167,8 @@ export class FormulaEditor extends React.Component<
167
167
  let from = 0;
168
168
  let idx = -1;
169
169
  while (~(idx = content.indexOf(v, from))) {
170
- html = html.replace(v, `<span class="c-field">${varMap[v]}</span>`);
170
+ const curNameEg = new RegExp(`\\b${v}\\b`, 'g'); // 避免变量识别冲突,比如:name、me 被识别成 na「me」
171
+ html = html.replace(curNameEg, `<span class="c-field">${varMap[v]}</span>`);
171
172
  from = idx + v.length;
172
173
  }
173
174
  });
@@ -229,7 +230,7 @@ export class FormulaEditor extends React.Component<
229
230
  handleVariableSelect(item: VariableItem) {
230
231
  const {evalMode, selfVariableName} = this.props;
231
232
 
232
- if (item && item.label && selfVariableName === item.label) {
233
+ if (item && item.value && selfVariableName === item.value) {
233
234
  toast.warning('不能使用当前变量[self],避免循环引用。');
234
235
  return;
235
236
  }
@@ -268,13 +268,13 @@ export class FormulaPicker extends React.Component<
268
268
  classnames: cx,
269
269
  translate: __,
270
270
  disabled,
271
- allowInput,
271
+ allowInput = true,
272
272
  className,
273
273
  onChange,
274
274
  size,
275
275
  borderMode,
276
276
  placeholder,
277
- mode,
277
+ mode = 'input-button',
278
278
  btnLabel,
279
279
  level,
280
280
  btnSize,
@@ -48,7 +48,7 @@ function VariableList(props: VariableListProps) {
48
48
  return (
49
49
  <span className={cx(`${classPrefix}-item`, itemClassName)}>
50
50
  {
51
- option.label && option.label === selfVariableName && (
51
+ option.label && option.value === selfVariableName && (
52
52
  <Badge
53
53
  classnames={cx}
54
54
  badge={{
@@ -67,7 +67,7 @@ function VariableList(props: VariableListProps) {
67
67
  )
68
68
  }
69
69
  {
70
- option.label && option.label !== selfVariableName && (
70
+ option.label && option.value !== selfVariableName && (
71
71
  <label>
72
72
  {option.label}
73
73
  </label>
@@ -11,6 +11,10 @@ import {
11
11
  } from '../../components/WithRemoteConfig';
12
12
  import {Schema} from '../../types';
13
13
  import {autobind} from '../../utils/helper';
14
+ import {
15
+ isPureVariable,
16
+ resolveVariableAndFilter
17
+ } from '../../utils/tpl-builtin';
14
18
 
15
19
  /**
16
20
  * 条件组合控件
@@ -72,11 +76,23 @@ export default class ConditionBuilderControl extends React.PureComponent<Conditi
72
76
  render() {
73
77
  const {className, classnames: cx, ...rest} = this.props;
74
78
 
79
+ // 处理一下formula类型值的变量列表
80
+ let formula = this.props.formula ? {...this.props.formula} : undefined;
81
+ if (formula && formula.variables && isPureVariable(formula.variables)) {
82
+ // 如果 variables 是 ${xxx} 这种形式,将其处理成实际的值
83
+ formula.variables = resolveVariableAndFilter(
84
+ formula.variables,
85
+ this.props.data,
86
+ '| raw'
87
+ );
88
+ }
89
+
75
90
  return (
76
91
  <div className={cx(`ConditionBuilderControl`, className)}>
77
92
  <ConditionBuilderWithRemoteOptions
78
93
  renderEtrValue={this.renderEtrValue}
79
94
  {...rest}
95
+ formula={formula}
80
96
  />
81
97
  </div>
82
98
  );
@@ -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>;
@@ -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
  }
@@ -2797,6 +2797,26 @@ 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
+ }
2801
2821
 
2802
2822
  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
  }