amis-core 2.0.2 → 2.2.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.
- package/esm/Root.js +1 -1
- package/esm/RootRenderer.js +1 -1
- package/esm/SchemaRenderer.js +2 -2
- package/esm/Scoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/_virtual/index.js +1 -1
- package/esm/_virtual/index2.js +1 -1
- package/esm/_virtual/react-is.development.js +1 -1
- package/esm/_virtual/react-is.production.min.js +1 -1
- package/esm/actions/Action.js +1 -1
- package/esm/actions/AjaxAction.js +39 -38
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +1 -1
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +32 -6
- package/esm/actions/Decorators.js +1 -1
- package/esm/actions/DialogAction.js +1 -1
- package/esm/actions/DrawerAction.js +1 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.d.ts +2 -0
- package/esm/components/Overlay.js +19 -2
- package/esm/components/PopOver.js +1 -1
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.d.ts +4 -1
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +2 -2
- package/esm/index.js +107 -25
- package/esm/locale.js +3 -2
- package/esm/node_modules/@restart/hooks/esm/useCommittedRef.js +1 -1
- package/esm/node_modules/@restart/hooks/esm/useEventCallback.js +1 -1
- package/esm/node_modules/dom-helpers/esm/addEventListener.js +1 -1
- package/esm/node_modules/dom-helpers/esm/canUseDOM.js +1 -1
- package/esm/node_modules/dom-helpers/esm/contains.js +1 -1
- package/esm/node_modules/dom-helpers/esm/listen.js +1 -1
- package/esm/node_modules/dom-helpers/esm/ownerDocument.js +1 -1
- package/esm/node_modules/dom-helpers/esm/removeEventListener.js +1 -1
- package/esm/node_modules/object-assign/index.js +1 -1
- package/esm/node_modules/prop-types/checkPropTypes.js +1 -1
- package/esm/node_modules/prop-types/factoryWithThrowingShims.js +1 -1
- package/esm/node_modules/prop-types/factoryWithTypeCheckers.js +1 -1
- package/esm/node_modules/prop-types/index.js +1 -1
- package/esm/node_modules/prop-types/lib/ReactPropTypesSecret.js +1 -1
- package/esm/node_modules/prop-types/lib/has.js +1 -1
- package/esm/node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js +1 -1
- package/esm/node_modules/prop-types/node_modules/react-is/cjs/react-is.production.min.js +1 -1
- package/esm/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/esm/node_modules/react-overlays/esm/Portal.js +1 -1
- package/esm/node_modules/react-overlays/esm/ownerDocument.js +1 -1
- package/esm/node_modules/react-overlays/esm/safeFindDOMNode.js +1 -1
- package/esm/node_modules/react-overlays/esm/useRootClose.js +1 -1
- package/esm/node_modules/react-overlays/esm/useWaitForDOMRef.js +1 -1
- package/esm/node_modules/warning/warning.js +1 -1
- package/esm/renderers/Form.d.ts +32 -2
- package/esm/renderers/Form.js +28 -10
- package/esm/renderers/Item.d.ts +127 -0
- package/esm/renderers/Item.js +8 -6
- package/esm/renderers/Options.d.ts +8 -0
- package/esm/renderers/Options.js +67 -39
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/wrapControl.js +11 -3
- package/esm/store/app.js +2 -2
- package/esm/store/combo.d.ts +24 -0
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.d.ts +1 -0
- package/esm/store/crud.js +35 -20
- package/esm/store/form.d.ts +10 -0
- package/esm/store/form.js +48 -22
- package/esm/store/formItem.d.ts +1 -0
- package/esm/store/formItem.js +12 -5
- package/esm/store/iRenderer.js +1 -1
- package/esm/store/index.d.ts +2 -2
- package/esm/store/index.js +4 -4
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.js +1 -1
- package/esm/store/service.js +11 -11
- package/esm/store/table.d.ts +30 -4
- package/esm/store/table.js +34 -25
- package/{lib/store/table-v2.d.ts → esm/store/table2.d.ts} +32 -32
- package/esm/store/{table-v2.js → table2.js} +17 -17
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +3 -2
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +7 -0
- package/esm/utils/api.js +49 -7
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.d.ts +6 -0
- package/esm/utils/dataMapping.js +16 -2
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.js +1 -1
- package/esm/utils/dom.js +1 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +1 -1
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +30 -4
- package/esm/utils/helper.js +45 -14
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/isPureVariable.js +1 -1
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.js +1 -1
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +1 -1
- package/esm/utils/position.d.ts +1 -1
- package/esm/utils/position.js +9 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.js +1 -1
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveVariable.d.ts +1 -1
- package/esm/utils/resolveVariable.js +3 -3
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/scrollPosition.d.ts +1 -1
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +2 -2
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.d.ts +7 -0
- package/esm/utils/toNumber.js +18 -0
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.d.ts +2 -2
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +2 -2
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.d.ts +1 -1
- package/esm/utils/validations.js +60 -3
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.js +1 -1
- package/lib/SchemaRenderer.js +2 -2
- package/lib/Scoped.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +1 -1
- package/lib/_virtual/index.js +1 -1
- package/lib/_virtual/index2.js +1 -1
- package/lib/_virtual/react-is.development.js +1 -1
- package/lib/_virtual/react-is.production.min.js +1 -1
- package/lib/actions/Action.js +1 -1
- package/lib/actions/AjaxAction.js +38 -37
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +1 -1
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +32 -6
- package/lib/actions/Decorators.js +1 -1
- package/lib/actions/DialogAction.js +1 -1
- package/lib/actions/DrawerAction.js +1 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.d.ts +2 -0
- package/lib/components/Overlay.js +19 -2
- package/lib/components/PopOver.js +1 -1
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.d.ts +4 -1
- package/lib/factory.js +2 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +191 -113
- package/lib/locale.js +3 -2
- package/lib/node_modules/@restart/hooks/esm/useCommittedRef.js +1 -1
- package/lib/node_modules/@restart/hooks/esm/useEventCallback.js +1 -1
- package/lib/node_modules/dom-helpers/esm/addEventListener.js +1 -1
- package/lib/node_modules/dom-helpers/esm/canUseDOM.js +1 -1
- package/lib/node_modules/dom-helpers/esm/contains.js +1 -1
- package/lib/node_modules/dom-helpers/esm/listen.js +1 -1
- package/lib/node_modules/dom-helpers/esm/ownerDocument.js +1 -1
- package/lib/node_modules/dom-helpers/esm/removeEventListener.js +1 -1
- package/lib/node_modules/object-assign/index.js +1 -1
- package/lib/node_modules/prop-types/checkPropTypes.js +1 -1
- package/lib/node_modules/prop-types/factoryWithThrowingShims.js +1 -1
- package/lib/node_modules/prop-types/factoryWithTypeCheckers.js +1 -1
- package/lib/node_modules/prop-types/index.js +1 -1
- package/lib/node_modules/prop-types/lib/ReactPropTypesSecret.js +1 -1
- package/lib/node_modules/prop-types/lib/has.js +1 -1
- package/lib/node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js +1 -1
- package/lib/node_modules/prop-types/node_modules/react-is/cjs/react-is.production.min.js +1 -1
- package/lib/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/lib/node_modules/react-overlays/esm/Portal.js +1 -1
- package/lib/node_modules/react-overlays/esm/ownerDocument.js +1 -1
- package/lib/node_modules/react-overlays/esm/safeFindDOMNode.js +1 -1
- package/lib/node_modules/react-overlays/esm/useRootClose.js +1 -1
- package/lib/node_modules/react-overlays/esm/useWaitForDOMRef.js +1 -1
- package/lib/node_modules/warning/warning.js +1 -1
- package/lib/renderers/Form.d.ts +32 -2
- package/lib/renderers/Form.js +29 -10
- package/lib/renderers/Item.d.ts +127 -0
- package/lib/renderers/Item.js +7 -4
- package/lib/renderers/Options.d.ts +8 -0
- package/lib/renderers/Options.js +67 -40
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/wrapControl.js +11 -3
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +24 -0
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.d.ts +1 -0
- package/lib/store/crud.js +35 -20
- package/lib/store/form.d.ts +10 -0
- package/lib/store/form.js +49 -22
- package/lib/store/formItem.d.ts +1 -0
- package/lib/store/formItem.js +13 -6
- package/lib/store/iRenderer.js +1 -1
- package/lib/store/index.d.ts +2 -2
- package/lib/store/index.js +4 -4
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.js +1 -1
- package/lib/store/service.js +11 -11
- package/lib/store/table.d.ts +30 -4
- package/lib/store/table.js +33 -24
- package/{esm/store/table-v2.d.ts → lib/store/table2.d.ts} +32 -32
- package/lib/store/{table-v2.js → table2.js} +16 -16
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +3 -2
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +7 -0
- package/lib/utils/api.js +50 -6
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/dataMapping.d.ts +6 -0
- package/lib/utils/dataMapping.js +16 -1
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.js +1 -1
- package/lib/utils/dom.js +1 -1
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.js +1 -1
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.js +1 -1
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +30 -4
- package/lib/utils/helper.js +44 -12
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.js +1 -1
- package/lib/utils/image.js +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/isPureVariable.js +1 -1
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +1 -1
- package/lib/utils/position.d.ts +1 -1
- package/lib/utils/position.js +9 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.js +1 -1
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveVariable.d.ts +1 -1
- package/lib/utils/resolveVariable.js +3 -3
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/scrollPosition.d.ts +1 -1
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +2 -2
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.d.ts +7 -0
- package/lib/utils/toNumber.js +22 -0
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.d.ts +2 -2
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.d.ts +1 -1
- package/lib/utils/validations.js +61 -3
- package/package.json +9 -8
- package/esm/index2.js +0 -134
- package/lib/index2.js +0 -330
package/esm/renderers/Item.d.ts
CHANGED
|
@@ -119,6 +119,18 @@ export interface FormBaseControl extends BaseSchemaWithoutType {
|
|
|
119
119
|
maximum?: string;
|
|
120
120
|
minLength?: string;
|
|
121
121
|
minimum?: string;
|
|
122
|
+
isDateTimeSame?: string;
|
|
123
|
+
isDateTimeBefore?: string;
|
|
124
|
+
isDateTimeAfter?: string;
|
|
125
|
+
isDateTimeSameOrBefore?: string;
|
|
126
|
+
isDateTimeSameOrAfter?: string;
|
|
127
|
+
isDateTimeBetween?: string;
|
|
128
|
+
isTimeSame?: string;
|
|
129
|
+
isTimeBefore?: string;
|
|
130
|
+
isTimeAfter?: string;
|
|
131
|
+
isTimeSameOrBefore?: string;
|
|
132
|
+
isTimeSameOrAfter?: string;
|
|
133
|
+
isTimeBetween?: string;
|
|
122
134
|
[propName: string]: any;
|
|
123
135
|
};
|
|
124
136
|
validations?: string | {
|
|
@@ -202,6 +214,66 @@ export interface FormBaseControl extends BaseSchemaWithoutType {
|
|
|
202
214
|
* 最小值为指定值
|
|
203
215
|
*/
|
|
204
216
|
minimum?: number;
|
|
217
|
+
/**
|
|
218
|
+
* 和目标日期相同,支持指定粒度,默认到毫秒
|
|
219
|
+
* @version 2.2.0
|
|
220
|
+
*/
|
|
221
|
+
isDateTimeSame?: string | string[];
|
|
222
|
+
/**
|
|
223
|
+
* 早于目标日期,支持指定粒度,默认到毫秒
|
|
224
|
+
* @version 2.2.0
|
|
225
|
+
*/
|
|
226
|
+
isDateTimeBefore?: string | string[];
|
|
227
|
+
/**
|
|
228
|
+
* 晚于目标日期,支持指定粒度,默认到毫秒
|
|
229
|
+
* @version 2.2.0
|
|
230
|
+
*/
|
|
231
|
+
isDateTimeAfter?: string | string[];
|
|
232
|
+
/**
|
|
233
|
+
* 早于目标日期或和目标日期相同,支持指定粒度,默认到毫秒
|
|
234
|
+
* @version 2.2.0
|
|
235
|
+
*/
|
|
236
|
+
isDateTimeSameOrBefore?: string | string[];
|
|
237
|
+
/**
|
|
238
|
+
* 晚于目标日期或和目标日期相同,支持指定粒度,默认到毫秒
|
|
239
|
+
* @version 2.2.0
|
|
240
|
+
*/
|
|
241
|
+
isDateTimeSameOrAfter?: string | string[];
|
|
242
|
+
/**
|
|
243
|
+
* 日期处于目标日期范围,支持指定粒度和区间的开闭形式,默认到毫秒, 左右开区间
|
|
244
|
+
* @version 2.2.0
|
|
245
|
+
*/
|
|
246
|
+
isDateTimeBetween?: string | string[];
|
|
247
|
+
/**
|
|
248
|
+
* 和目标时间相同,支持指定粒度,默认到毫秒
|
|
249
|
+
* @version 2.2.0
|
|
250
|
+
*/
|
|
251
|
+
isTimeSame?: string | string[];
|
|
252
|
+
/**
|
|
253
|
+
* 早于目标时间,支持指定粒度,默认到毫秒
|
|
254
|
+
* @version 2.2.0
|
|
255
|
+
*/
|
|
256
|
+
isTimeBefore?: string | string[];
|
|
257
|
+
/**
|
|
258
|
+
* 晚于目标时间,支持指定粒度,默认到毫秒
|
|
259
|
+
* @version 2.2.0
|
|
260
|
+
*/
|
|
261
|
+
isTimeAfter?: string | string[];
|
|
262
|
+
/**
|
|
263
|
+
* 早于目标时间或和目标时间相同,支持指定粒度,默认到毫秒
|
|
264
|
+
* @version 2.2.0
|
|
265
|
+
*/
|
|
266
|
+
isTimeSameOrBefore?: string | string[];
|
|
267
|
+
/**
|
|
268
|
+
* 晚于目标时间或和目标时间相同,支持指定粒度,默认到毫秒
|
|
269
|
+
* @version 2.2.0
|
|
270
|
+
*/
|
|
271
|
+
isTimeSameOrAfter?: string | string[];
|
|
272
|
+
/**
|
|
273
|
+
* 时间处于目标时间范围,支持指定粒度和区间的开闭形式,默认到毫秒, 左右开区间
|
|
274
|
+
* @version 2.2.0
|
|
275
|
+
*/
|
|
276
|
+
isTimeBetween?: string | string[];
|
|
205
277
|
[propName: string]: any;
|
|
206
278
|
};
|
|
207
279
|
/**
|
|
@@ -444,6 +516,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
444
516
|
readonly fetcher: any;
|
|
445
517
|
readonly notify: any;
|
|
446
518
|
readonly isCancel: (value: any) => boolean;
|
|
519
|
+
/**
|
|
520
|
+
* 输入提示,聚焦的时候显示
|
|
521
|
+
*/
|
|
447
522
|
readonly __: import("..").TranslateFn<any>;
|
|
448
523
|
getStoreById(id: string): {
|
|
449
524
|
id: string;
|
|
@@ -462,6 +537,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
462
537
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
463
538
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
464
539
|
addChildId: (id: string) => void;
|
|
540
|
+
/**
|
|
541
|
+
* 表单 control 是否为 inline 模式。
|
|
542
|
+
*/
|
|
465
543
|
removeChildId: (id: string) => void;
|
|
466
544
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
467
545
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -480,6 +558,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
480
558
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
481
559
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
482
560
|
addChildId: (id: string) => void;
|
|
561
|
+
/**
|
|
562
|
+
* 表单 control 是否为 inline 模式。
|
|
563
|
+
*/
|
|
483
564
|
removeChildId: (id: string) => void;
|
|
484
565
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
485
566
|
readonly stores: {
|
|
@@ -500,6 +581,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
500
581
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
501
582
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
502
583
|
addChildId: (id: string) => void;
|
|
584
|
+
/**
|
|
585
|
+
* 表单 control 是否为 inline 模式。
|
|
586
|
+
*/
|
|
503
587
|
removeChildId: (id: string) => void;
|
|
504
588
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
505
589
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -518,6 +602,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
518
602
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
519
603
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
520
604
|
addChildId: (id: string) => void;
|
|
605
|
+
/**
|
|
606
|
+
* 表单 control 是否为 inline 模式。
|
|
607
|
+
*/
|
|
521
608
|
removeChildId: (id: string) => void;
|
|
522
609
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
523
610
|
};
|
|
@@ -545,6 +632,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
545
632
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
546
633
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
547
634
|
addChildId: (id: string) => void;
|
|
635
|
+
/**
|
|
636
|
+
* 表单 control 是否为 inline 模式。
|
|
637
|
+
*/
|
|
548
638
|
removeChildId: (id: string) => void;
|
|
549
639
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
550
640
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -563,6 +653,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
563
653
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
564
654
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
565
655
|
addChildId: (id: string) => void;
|
|
656
|
+
/**
|
|
657
|
+
* 表单 control 是否为 inline 模式。
|
|
658
|
+
*/
|
|
566
659
|
removeChildId: (id: string) => void;
|
|
567
660
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
568
661
|
removeStore(store: {
|
|
@@ -582,6 +675,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
582
675
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
583
676
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
584
677
|
addChildId: (id: string) => void;
|
|
678
|
+
/**
|
|
679
|
+
* 表单 control 是否为 inline 模式。
|
|
680
|
+
*/
|
|
585
681
|
removeChildId: (id: string) => void;
|
|
586
682
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
587
683
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -600,6 +696,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
600
696
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
601
697
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
602
698
|
addChildId: (id: string) => void;
|
|
699
|
+
/**
|
|
700
|
+
* 表单 control 是否为 inline 模式。
|
|
701
|
+
*/
|
|
603
702
|
removeChildId: (id: string) => void;
|
|
604
703
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>): void;
|
|
605
704
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
@@ -608,6 +707,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
608
707
|
readonly fetcher: any;
|
|
609
708
|
readonly notify: any;
|
|
610
709
|
readonly isCancel: (value: any) => boolean;
|
|
710
|
+
/**
|
|
711
|
+
* 输入提示,聚焦的时候显示
|
|
712
|
+
*/
|
|
611
713
|
readonly __: import("..").TranslateFn<any>;
|
|
612
714
|
getStoreById(id: string): {
|
|
613
715
|
id: string;
|
|
@@ -626,6 +728,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
626
728
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
627
729
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
628
730
|
addChildId: (id: string) => void;
|
|
731
|
+
/**
|
|
732
|
+
* 表单 control 是否为 inline 模式。
|
|
733
|
+
*/
|
|
629
734
|
removeChildId: (id: string) => void;
|
|
630
735
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
631
736
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -644,6 +749,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
644
749
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
645
750
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
646
751
|
addChildId: (id: string) => void;
|
|
752
|
+
/**
|
|
753
|
+
* 表单 control 是否为 inline 模式。
|
|
754
|
+
*/
|
|
647
755
|
removeChildId: (id: string) => void;
|
|
648
756
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
649
757
|
readonly stores: {
|
|
@@ -664,6 +772,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
664
772
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
665
773
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
666
774
|
addChildId: (id: string) => void;
|
|
775
|
+
/**
|
|
776
|
+
* 表单 control 是否为 inline 模式。
|
|
777
|
+
*/
|
|
667
778
|
removeChildId: (id: string) => void;
|
|
668
779
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
669
780
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -682,6 +793,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
682
793
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
683
794
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
684
795
|
addChildId: (id: string) => void;
|
|
796
|
+
/**
|
|
797
|
+
* 表单 control 是否为 inline 模式。
|
|
798
|
+
*/
|
|
685
799
|
removeChildId: (id: string) => void;
|
|
686
800
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
687
801
|
};
|
|
@@ -709,6 +823,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
709
823
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
710
824
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
711
825
|
addChildId: (id: string) => void;
|
|
826
|
+
/**
|
|
827
|
+
* 表单 control 是否为 inline 模式。
|
|
828
|
+
*/
|
|
712
829
|
removeChildId: (id: string) => void;
|
|
713
830
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
714
831
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -727,6 +844,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
727
844
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
728
845
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
729
846
|
addChildId: (id: string) => void;
|
|
847
|
+
/**
|
|
848
|
+
* 表单 control 是否为 inline 模式。
|
|
849
|
+
*/
|
|
730
850
|
removeChildId: (id: string) => void;
|
|
731
851
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
732
852
|
removeStore(store: {
|
|
@@ -746,6 +866,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
746
866
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
747
867
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
748
868
|
addChildId: (id: string) => void;
|
|
869
|
+
/**
|
|
870
|
+
* 表单 control 是否为 inline 模式。
|
|
871
|
+
*/
|
|
749
872
|
removeChildId: (id: string) => void;
|
|
750
873
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
751
874
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -764,6 +887,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
764
887
|
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
765
888
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
766
889
|
addChildId: (id: string) => void;
|
|
890
|
+
/**
|
|
891
|
+
* 表单 control 是否为 inline 模式。
|
|
892
|
+
*/
|
|
767
893
|
removeChildId: (id: string) => void;
|
|
768
894
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>): void;
|
|
769
895
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>;
|
|
@@ -775,4 +901,5 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
775
901
|
};
|
|
776
902
|
export declare function registerFormItem(config: FormItemConfig): RendererConfig;
|
|
777
903
|
export declare function FormItem(config: FormItemBasicConfig): (component: FormControlComponent) => any;
|
|
904
|
+
export declare function getFormItemByName(name: string): boolean;
|
|
778
905
|
export default FormItem;
|
package/esm/renderers/Item.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.0
|
|
2
|
+
* amis-core v2.2.0
|
|
3
3
|
* Copyright 2018-2022 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import { __extends, __awaiter, __generator, __assign, __rest, __decorate, __meta
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
9
9
|
import { reaction } from 'mobx';
|
|
10
|
-
import { registerRenderer } from '../factory.js';
|
|
10
|
+
import { registerRenderer, renderersMap } from '../factory.js';
|
|
11
11
|
import { isMobile, ucFirst, getWidthRate, autobind, anyChanged } from '../utils/helper.js';
|
|
12
12
|
import { observer } from 'mobx-react';
|
|
13
13
|
import { filter } from '../utils/tpl.js';
|
|
@@ -80,9 +80,8 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
80
80
|
return [4 /*yield*/, (formItem === null || formItem === void 0 ? void 0 : formItem.loadAutoUpdateData(autoFill.api, ctx, !!((_c = autoFill.api) === null || _c === void 0 ? void 0 : _c.silent)))];
|
|
81
81
|
case 2:
|
|
82
82
|
result = _e.sent();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.lastSearchTerm = (_d = getVariable(result, itemName)) !== null && _d !== void 0 ? _d : term;
|
|
83
|
+
this.lastSearchTerm =
|
|
84
|
+
(_d = (result && getVariable(result, itemName))) !== null && _d !== void 0 ? _d : term;
|
|
86
85
|
if (autoFill === null || autoFill === void 0 ? void 0 : autoFill.fillMapping) {
|
|
87
86
|
result = dataMapping(autoFill.fillMapping, result);
|
|
88
87
|
}
|
|
@@ -841,5 +840,8 @@ function FormItem(config) {
|
|
|
841
840
|
return renderer.component;
|
|
842
841
|
};
|
|
843
842
|
}
|
|
843
|
+
function getFormItemByName(name) {
|
|
844
|
+
return renderersMap[name];
|
|
845
|
+
}
|
|
844
846
|
|
|
845
|
-
export { FormItem, FormItemWrap, asFormItem, FormItem as default, detectProps, registerFormItem };
|
|
847
|
+
export { FormItem, FormItemWrap, asFormItem, FormItem as default, detectProps, getFormItemByName, registerFormItem };
|
|
@@ -72,6 +72,10 @@ export interface FormOptionsControl extends FormBaseControl {
|
|
|
72
72
|
* 新增时的表单项。
|
|
73
73
|
*/
|
|
74
74
|
addControls?: Array<PlainObject>;
|
|
75
|
+
/**
|
|
76
|
+
* 控制新增弹框设置项
|
|
77
|
+
*/
|
|
78
|
+
addDialog?: PlainObject;
|
|
75
79
|
/**
|
|
76
80
|
* 是否可以新增
|
|
77
81
|
*/
|
|
@@ -92,6 +96,10 @@ export interface FormOptionsControl extends FormBaseControl {
|
|
|
92
96
|
* 选项修改的表单项
|
|
93
97
|
*/
|
|
94
98
|
editControls?: Array<PlainObject>;
|
|
99
|
+
/**
|
|
100
|
+
* 控制编辑弹框设置项
|
|
101
|
+
*/
|
|
102
|
+
editDialog?: PlainObject;
|
|
95
103
|
/**
|
|
96
104
|
* 是否可删除
|
|
97
105
|
*/
|
package/esm/renderers/Options.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.0
|
|
2
|
+
* amis-core v2.2.0
|
|
3
3
|
* Copyright 2018-2022 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -14,15 +14,17 @@ import 'amis-formula';
|
|
|
14
14
|
import 'moment';
|
|
15
15
|
import { createObject, setVariable } from '../utils/object.js';
|
|
16
16
|
import { isPureVariable } from '../utils/isPureVariable.js';
|
|
17
|
+
import { getVariable } from '../utils/getVariable.js';
|
|
17
18
|
import { resolveVariableAndFilter } from '../utils/resolveVariableAndFilter.js';
|
|
18
19
|
import { dataMapping } from '../utils/dataMapping.js';
|
|
19
20
|
import '../utils/filter.js';
|
|
20
21
|
import { filter } from '../utils/tpl.js';
|
|
21
22
|
import findIndex from 'lodash/findIndex';
|
|
22
23
|
import isPlainObject from 'lodash/isPlainObject';
|
|
23
|
-
import merge from 'lodash/merge';
|
|
24
24
|
import { normalizeOptions } from '../utils/normalizeOptions.js';
|
|
25
25
|
import { optionValueCompare } from '../utils/optionValueCompare.js';
|
|
26
|
+
import { isEqual } from 'lodash';
|
|
27
|
+
import { keyToPath } from '../utils/keyToPath.js';
|
|
26
28
|
|
|
27
29
|
var detectProps = detectProps$1.concat([
|
|
28
30
|
'value',
|
|
@@ -136,6 +138,9 @@ function registerOptionsControl(config) {
|
|
|
136
138
|
.then(function () { return _this.normalizeValue(); });
|
|
137
139
|
}
|
|
138
140
|
}
|
|
141
|
+
else if (!isEqual(props.value, prevProps.value) && props.formInited) {
|
|
142
|
+
this.normalizeValue();
|
|
143
|
+
}
|
|
139
144
|
if (prevProps.value !== props.value || (formItem === null || formItem === void 0 ? void 0 : formItem.expressionsInOptions)) {
|
|
140
145
|
formItem === null || formItem === void 0 ? void 0 : formItem.syncOptions(undefined, props.data);
|
|
141
146
|
}
|
|
@@ -194,9 +199,16 @@ function registerOptionsControl(config) {
|
|
|
194
199
|
})
|
|
195
200
|
}
|
|
196
201
|
: createObject(__assign(__assign({}, data), { ancestors: getTreeAncestors(formItem.filteredOptions, selectedOptions[0], true) }), selectedOptions[0]));
|
|
197
|
-
Object.keys(
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
Object.keys(autoFill).forEach(function (key) {
|
|
203
|
+
var keys = keyToPath(key);
|
|
204
|
+
// 如果左边的 key 是一个路径
|
|
205
|
+
// 这里不希望直接把原始对象都给覆盖没了
|
|
206
|
+
// 而是保留原始的对象,只修改指定的属性
|
|
207
|
+
if (keys.length > 1 && isPlainObject(data[keys[0]])) {
|
|
208
|
+
var obj = __assign({}, data[keys[0]]);
|
|
209
|
+
var value = getVariable(toSync_1, key);
|
|
210
|
+
toSync_1[keys[0]] = obj;
|
|
211
|
+
setVariable(toSync_1, key, value);
|
|
200
212
|
}
|
|
201
213
|
});
|
|
202
214
|
onBulkChange(toSync_1);
|
|
@@ -204,21 +216,40 @@ function registerOptionsControl(config) {
|
|
|
204
216
|
};
|
|
205
217
|
// 当前值,跟设置预期的值格式不一致时自动转换。
|
|
206
218
|
FormOptionsItem.prototype.normalizeValue = function () {
|
|
207
|
-
var _a = this.props, joinValues = _a.joinValues, extractValue = _a.extractValue, value = _a.value, multiple = _a.multiple, formItem = _a.formItem, valueField = _a.valueField; _a.enableNodePath; _a.pathSeparator; var onChange = _a.onChange;
|
|
208
|
-
if (!formItem ||
|
|
219
|
+
var _a = this.props, joinValues = _a.joinValues, extractValue = _a.extractValue, value = _a.value, multiple = _a.multiple, formItem = _a.formItem, valueField = _a.valueField, delimiter = _a.delimiter; _a.enableNodePath; _a.pathSeparator; var onChange = _a.onChange;
|
|
220
|
+
if (!formItem || !formItem.options.length) {
|
|
209
221
|
return;
|
|
210
222
|
}
|
|
211
|
-
if (
|
|
223
|
+
if (joinValues !== false) {
|
|
224
|
+
// 只处理多选且值为 array 的情况,因为理应为分隔符隔开的字符串
|
|
225
|
+
if (!(multiple && Array.isArray(value)))
|
|
226
|
+
return;
|
|
227
|
+
var selectedOptions = formItem.getSelectedOptions(value);
|
|
228
|
+
onChange === null || onChange === void 0 ? void 0 : onChange((multiple
|
|
229
|
+
? selectedOptions.concat()
|
|
230
|
+
: selectedOptions.length
|
|
231
|
+
? [selectedOptions[0]]
|
|
232
|
+
: [])
|
|
233
|
+
.map(function (selectedOption) {
|
|
234
|
+
return typeof selectedOption === 'string' ||
|
|
235
|
+
typeof selectedOption === 'number'
|
|
236
|
+
? selectedOption
|
|
237
|
+
: selectedOption[valueField || 'value'];
|
|
238
|
+
})
|
|
239
|
+
.join(delimiter || ','));
|
|
240
|
+
}
|
|
241
|
+
else if (extractValue === false &&
|
|
212
242
|
(typeof value === 'string' || typeof value === 'number')) {
|
|
213
243
|
var selectedOptions = formItem.getSelectedOptions(value);
|
|
214
244
|
onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? selectedOptions.concat() : selectedOptions[0]);
|
|
215
245
|
}
|
|
216
246
|
else if (extractValue === true &&
|
|
217
247
|
value &&
|
|
218
|
-
!((
|
|
248
|
+
!((multiple &&
|
|
249
|
+
Array.isArray(value) &&
|
|
219
250
|
value.every(function (val) { return typeof val === 'string' || typeof val === 'number'; })) ||
|
|
220
|
-
|
|
221
|
-
|
|
251
|
+
(!multiple &&
|
|
252
|
+
(typeof value === 'string' || typeof value === 'number')))) {
|
|
222
253
|
var selectedOptions = formItem
|
|
223
254
|
.getSelectedOptions(value)
|
|
224
255
|
.map(function (selectedOption) { return selectedOption[valueField || 'value']; });
|
|
@@ -474,12 +505,12 @@ function registerOptionsControl(config) {
|
|
|
474
505
|
if (idx === void 0) { idx = -1; }
|
|
475
506
|
if (skipForm === void 0) { skipForm = false; }
|
|
476
507
|
return __awaiter(this, void 0, void 0, function () {
|
|
477
|
-
var _a, addControls, disabled, labelField, onOpenDialog, optionLabel, addApi, source, data, valueField, model, createBtnLabel, env, __, parent, ctx, result, _b, payload, e_1, isPrevented, options;
|
|
508
|
+
var _a, addControls, addDialog, disabled, labelField, onOpenDialog, optionLabel, addApi, source, data, valueField, model, createBtnLabel, env, __, parent, ctx, result, _b, payload, e_1, isPrevented, options;
|
|
478
509
|
var _c;
|
|
479
510
|
return __generator(this, function (_d) {
|
|
480
511
|
switch (_d.label) {
|
|
481
512
|
case 0:
|
|
482
|
-
_a = this.props, addControls = _a.addControls, disabled = _a.disabled, labelField = _a.labelField, onOpenDialog = _a.onOpenDialog, optionLabel = _a.optionLabel, addApi = _a.addApi, source = _a.source, data = _a.data, valueField = _a.valueField, model = _a.formItem, createBtnLabel = _a.createBtnLabel, env = _a.env, __ = _a.translate;
|
|
513
|
+
_a = this.props, addControls = _a.addControls, addDialog = _a.addDialog, disabled = _a.disabled, labelField = _a.labelField, onOpenDialog = _a.onOpenDialog, optionLabel = _a.optionLabel, addApi = _a.addApi, source = _a.source, data = _a.data, valueField = _a.valueField, model = _a.formItem, createBtnLabel = _a.createBtnLabel, env = _a.env, __ = _a.translate;
|
|
483
514
|
// 禁用或者没有配置 name
|
|
484
515
|
if (disabled || !model) {
|
|
485
516
|
return [2 /*return*/];
|
|
@@ -504,10 +535,7 @@ function registerOptionsControl(config) {
|
|
|
504
535
|
if (!skipForm) return [3 /*break*/, 1];
|
|
505
536
|
_b = ctx;
|
|
506
537
|
return [3 /*break*/, 3];
|
|
507
|
-
case 1: return [4 /*yield*/, onOpenDialog({
|
|
508
|
-
type: 'dialog',
|
|
509
|
-
title: createBtnLabel || "\u65B0\u589E".concat(optionLabel || '选项'),
|
|
510
|
-
body: {
|
|
538
|
+
case 1: return [4 /*yield*/, onOpenDialog(__assign(__assign({ type: 'dialog', title: createBtnLabel || "\u65B0\u589E".concat(optionLabel || '选项') }, addDialog), { body: {
|
|
511
539
|
type: 'form',
|
|
512
540
|
api: addApi,
|
|
513
541
|
controls: __spreadArray([
|
|
@@ -522,8 +550,7 @@ function registerOptionsControl(config) {
|
|
|
522
550
|
value: parent
|
|
523
551
|
}
|
|
524
552
|
], (addControls || []), true)
|
|
525
|
-
}
|
|
526
|
-
}, ctx)];
|
|
553
|
+
} }), ctx)];
|
|
527
554
|
case 2:
|
|
528
555
|
_b = _d.sent();
|
|
529
556
|
_d.label = 3;
|
|
@@ -600,11 +627,11 @@ function registerOptionsControl(config) {
|
|
|
600
627
|
if (origin === void 0) { origin = value; }
|
|
601
628
|
if (skipForm === void 0) { skipForm = false; }
|
|
602
629
|
return __awaiter(this, void 0, void 0, function () {
|
|
603
|
-
var _a, editControls, disabled, labelField, onOpenDialog, editApi, env, source, data, model, optionLabel, __, result, _b, payload, e_2, isPrevented, indexes;
|
|
630
|
+
var _a, editControls, editDialog, disabled, labelField, onOpenDialog, editApi, env, source, data, model, optionLabel, __, result, _b, payload, e_2, isPrevented, indexes;
|
|
604
631
|
return __generator(this, function (_c) {
|
|
605
632
|
switch (_c.label) {
|
|
606
633
|
case 0:
|
|
607
|
-
_a = this.props, editControls = _a.editControls, disabled = _a.disabled, labelField = _a.labelField, onOpenDialog = _a.onOpenDialog, editApi = _a.editApi, env = _a.env, source = _a.source, data = _a.data, model = _a.formItem, optionLabel = _a.optionLabel, __ = _a.translate;
|
|
634
|
+
_a = this.props, editControls = _a.editControls, editDialog = _a.editDialog, disabled = _a.disabled, labelField = _a.labelField, onOpenDialog = _a.onOpenDialog, editApi = _a.editApi, env = _a.env, source = _a.source, data = _a.data, model = _a.formItem, optionLabel = _a.optionLabel, __ = _a.translate;
|
|
608
635
|
if (disabled || !model) {
|
|
609
636
|
return [2 /*return*/];
|
|
610
637
|
}
|
|
@@ -621,17 +648,13 @@ function registerOptionsControl(config) {
|
|
|
621
648
|
if (!skipForm) return [3 /*break*/, 1];
|
|
622
649
|
_b = value;
|
|
623
650
|
return [3 /*break*/, 3];
|
|
624
|
-
case 1: return [4 /*yield*/, onOpenDialog({
|
|
625
|
-
type: 'dialog',
|
|
626
|
-
title: __('Options.editLabel', {
|
|
651
|
+
case 1: return [4 /*yield*/, onOpenDialog(__assign(__assign({ type: 'dialog', title: __('Options.editLabel', {
|
|
627
652
|
label: optionLabel || __('Options.label')
|
|
628
|
-
}),
|
|
629
|
-
body: {
|
|
653
|
+
}) }, editDialog), { body: {
|
|
630
654
|
type: 'form',
|
|
631
655
|
api: editApi,
|
|
632
656
|
controls: editControls
|
|
633
|
-
}
|
|
634
|
-
}, createObject(data, value))];
|
|
657
|
+
} }), createObject(data, value))];
|
|
635
658
|
case 2:
|
|
636
659
|
_b = _c.sent();
|
|
637
660
|
_c.label = 3;
|
|
@@ -687,11 +710,11 @@ function registerOptionsControl(config) {
|
|
|
687
710
|
};
|
|
688
711
|
FormOptionsItem.prototype.handleOptionDelete = function (value) {
|
|
689
712
|
return __awaiter(this, void 0, void 0, function () {
|
|
690
|
-
var _a, deleteConfirmText, disabled, data, deleteApi, env, model, source, valueField, __, ctx, confirmed, _b, isPrevented, result, options, indexes, e_3;
|
|
713
|
+
var _a, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _b, isPrevented, result, options, indexes, e_3;
|
|
691
714
|
return __generator(this, function (_c) {
|
|
692
715
|
switch (_c.label) {
|
|
693
716
|
case 0:
|
|
694
|
-
_a = this.props, deleteConfirmText = _a.deleteConfirmText, disabled = _a.disabled, data = _a.data, deleteApi = _a.deleteApi, env = _a.env, model = _a.formItem, source = _a.source, valueField = _a.valueField, __ = _a.translate;
|
|
717
|
+
_a = this.props, deleteConfirmText = _a.deleteConfirmText, disabled = _a.disabled, data = _a.data, deleteApi = _a.deleteApi, onDelete = _a.onDelete, env = _a.env, model = _a.formItem, source = _a.source, valueField = _a.valueField, __ = _a.translate;
|
|
695
718
|
if (disabled || !model) {
|
|
696
719
|
return [2 /*return*/];
|
|
697
720
|
}
|
|
@@ -717,10 +740,8 @@ function registerOptionsControl(config) {
|
|
|
717
740
|
}
|
|
718
741
|
_c.label = 5;
|
|
719
742
|
case 5:
|
|
720
|
-
_c.trys.push([5,
|
|
721
|
-
if (!deleteApi)
|
|
722
|
-
throw new Error(__('Options.deleteAPI'));
|
|
723
|
-
}
|
|
743
|
+
_c.trys.push([5, 8, , 9]);
|
|
744
|
+
if (!deleteApi) return [3 /*break*/, 7];
|
|
724
745
|
return [4 /*yield*/, env.fetcher(deleteApi, ctx, {
|
|
725
746
|
method: 'delete'
|
|
726
747
|
})];
|
|
@@ -728,8 +749,15 @@ function registerOptionsControl(config) {
|
|
|
728
749
|
result = _c.sent();
|
|
729
750
|
if (!result.ok) {
|
|
730
751
|
env.notify('error', result.msg || __('deleteFailed'));
|
|
752
|
+
return [2 /*return*/];
|
|
753
|
+
}
|
|
754
|
+
_c.label = 7;
|
|
755
|
+
case 7:
|
|
756
|
+
// 由外部代码实现删除逻辑
|
|
757
|
+
if (onDelete) {
|
|
758
|
+
onDelete(ctx);
|
|
731
759
|
}
|
|
732
|
-
|
|
760
|
+
if (source) {
|
|
733
761
|
this.reload();
|
|
734
762
|
}
|
|
735
763
|
else {
|
|
@@ -739,13 +767,13 @@ function registerOptionsControl(config) {
|
|
|
739
767
|
model.setOptions(spliceTree(options, indexes, 1), this.changeOptionValue, data);
|
|
740
768
|
}
|
|
741
769
|
}
|
|
742
|
-
return [3 /*break*/,
|
|
743
|
-
case
|
|
770
|
+
return [3 /*break*/, 9];
|
|
771
|
+
case 8:
|
|
744
772
|
e_3 = _c.sent();
|
|
745
773
|
console.error(e_3);
|
|
746
774
|
env.notify('error', e_3.message);
|
|
747
|
-
return [3 /*break*/,
|
|
748
|
-
case
|
|
775
|
+
return [3 /*break*/, 9];
|
|
776
|
+
case 9: return [2 /*return*/];
|
|
749
777
|
}
|
|
750
778
|
});
|
|
751
779
|
});
|
package/esm/renderers/builtin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.0
|
|
2
|
+
* amis-core v2.2.0
|
|
3
3
|
* Copyright 2018-2022 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -40,6 +40,15 @@ function wrapControl(ComposedComponent) {
|
|
|
40
40
|
_this.controlRef = _this.controlRef.bind(_this);
|
|
41
41
|
_this.handleBlur = _this.handleBlur.bind(_this);
|
|
42
42
|
if (!name) {
|
|
43
|
+
// 一般情况下这些表单项都是需要 name 的,提示一下
|
|
44
|
+
if (typeof type === 'string' &&
|
|
45
|
+
(type.startsWith('input-') ||
|
|
46
|
+
type.endsWith('select') ||
|
|
47
|
+
type === 'switch' ||
|
|
48
|
+
type === 'textarea' ||
|
|
49
|
+
type === 'radios')) {
|
|
50
|
+
console.warn('name is required', _this.props.$schema);
|
|
51
|
+
}
|
|
43
52
|
return _this;
|
|
44
53
|
}
|
|
45
54
|
var propValue = _this.props.value;
|
|
@@ -213,8 +222,7 @@ function wrapControl(ComposedComponent) {
|
|
|
213
222
|
}
|
|
214
223
|
else if (model) {
|
|
215
224
|
var valueByName = getVariable(props.data, model.name);
|
|
216
|
-
if (
|
|
217
|
-
isEqual(props.defaultValue, prevProps.defaultValue)) {
|
|
225
|
+
if (isEqual(props.defaultValue, prevProps.defaultValue)) {
|
|
218
226
|
// value 非公式表达式时,name 值优先,若 defaultValue 主动变动时,则使用 defaultValue
|
|
219
227
|
if (
|
|
220
228
|
// 然后才是查看关联的 name 属性值是否变化
|
package/esm/store/app.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.0
|
|
2
|
+
* amis-core v2.2.0
|
|
3
3
|
* Copyright 2018-2022 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __assign } from 'tslib';
|
|
7
7
|
import { types } from 'mobx-state-tree';
|
|
8
|
-
import { mapTree,
|
|
8
|
+
import { mapTree, findTree, guid } from '../utils/helper.js';
|
|
9
9
|
import { ServiceStore } from './service.js';
|
|
10
10
|
import { createObject } from '../utils/object.js';
|
|
11
11
|
|