amis-core 2.6.0 → 2.7.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/package.json +2 -2
- package/esm/Root.d.ts +0 -46
- package/esm/Root.js +0 -89
- package/esm/RootRenderer.d.ts +0 -27
- package/esm/RootRenderer.js +0 -279
- package/esm/SchemaRenderer.d.ts +0 -37
- package/esm/SchemaRenderer.js +0 -332
- package/esm/Scoped.d.ts +0 -38
- package/esm/Scoped.js +0 -262
- package/esm/WithRootStore.d.ts +0 -719
- package/esm/WithRootStore.js +0 -34
- package/esm/WithStore.d.ts +0 -5
- package/esm/WithStore.js +0 -181
- package/esm/actions/Action.d.ts +0 -40
- package/esm/actions/Action.js +0 -186
- package/esm/actions/AjaxAction.d.ts +0 -27
- package/esm/actions/AjaxAction.js +0 -96
- package/esm/actions/BreakAction.d.ts +0 -15
- package/esm/actions/BreakAction.js +0 -31
- package/esm/actions/BroadcastAction.d.ts +0 -19
- package/esm/actions/BroadcastAction.js +0 -46
- package/esm/actions/CmptAction.d.ts +0 -21
- package/esm/actions/CmptAction.js +0 -66
- package/esm/actions/ContinueAction.d.ts +0 -15
- package/esm/actions/ContinueAction.js +0 -31
- package/esm/actions/CopyAction.d.ts +0 -20
- package/esm/actions/CopyAction.js +0 -39
- package/esm/actions/CustomAction.d.ts +0 -22
- package/esm/actions/CustomAction.js +0 -74
- package/esm/actions/DialogAction.d.ts +0 -60
- package/esm/actions/DialogAction.js +0 -101
- package/esm/actions/DrawerAction.d.ts +0 -33
- package/esm/actions/DrawerAction.js +0 -65
- package/esm/actions/EmailAction.d.ts +0 -23
- package/esm/actions/EmailAction.js +0 -39
- package/esm/actions/LinkAction.d.ts +0 -24
- package/esm/actions/LinkAction.js +0 -43
- package/esm/actions/LoopAction.d.ts +0 -19
- package/esm/actions/LoopAction.js +0 -103
- package/esm/actions/PageAction.d.ts +0 -39
- package/esm/actions/PageAction.js +0 -74
- package/esm/actions/ParallelAction.d.ts +0 -8
- package/esm/actions/ParallelAction.js +0 -36
- package/esm/actions/SwitchAction.d.ts +0 -11
- package/esm/actions/SwitchAction.js +0 -48
- package/esm/actions/ToastAction.d.ts +0 -19
- package/esm/actions/ToastAction.js +0 -31
- package/esm/actions/index.d.ts +0 -20
- package/esm/components/LazyComponent.d.ts +0 -32
- package/esm/components/LazyComponent.js +0 -90
- package/esm/components/Overlay.d.ts +0 -44
- package/esm/components/Overlay.js +0 -255
- package/esm/components/PopOver.d.ts +0 -90
- package/esm/components/PopOver.js +0 -120
- package/esm/env.d.ts +0 -176
- package/esm/env.js +0 -12
- package/esm/envOverwrite.d.ts +0 -4
- package/esm/envOverwrite.js +0 -39
- package/esm/factory.d.ts +0 -85
- package/esm/factory.js +0 -301
- package/esm/index.d.ts +0 -44
- package/esm/index.js +0 -174
- package/esm/locale.d.ts +0 -84
- package/esm/locale.js +0 -117
- package/esm/renderers/Form.d.ts +0 -389
- package/esm/renderers/Form.js +0 -1221
- package/esm/renderers/Item.d.ts +0 -906
- package/esm/renderers/Item.js +0 -863
- package/esm/renderers/Options.d.ts +0 -158
- package/esm/renderers/Options.js +0 -908
- package/esm/renderers/Placeholder.d.ts +0 -6
- package/esm/renderers/Placeholder.js +0 -23
- package/esm/renderers/builtin.d.ts +0 -1
- package/esm/renderers/builtin.js +0 -25
- package/esm/renderers/register.d.ts +0 -6
- package/esm/renderers/register.js +0 -79
- package/esm/renderers/wrapControl.d.ts +0 -437
- package/esm/renderers/wrapControl.js +0 -509
- package/esm/store/app.d.ts +0 -92
- package/esm/store/app.js +0 -189
- package/esm/store/combo.d.ts +0 -10223
- package/esm/store/combo.js +0 -149
- package/esm/store/crud.d.ts +0 -128
- package/esm/store/crud.js +0 -447
- package/esm/store/form.d.ts +0 -4252
- package/esm/store/form.js +0 -650
- package/esm/store/formItem.d.ts +0 -133
- package/esm/store/formItem.js +0 -847
- package/esm/store/iRenderer.d.ts +0 -46
- package/esm/store/iRenderer.js +0 -185
- package/esm/store/index.d.ts +0 -125
- package/esm/store/index.js +0 -90
- package/esm/store/list.d.ts +0 -272
- package/esm/store/list.js +0 -246
- package/esm/store/manager.d.ts +0 -115
- package/esm/store/manager.js +0 -49
- package/esm/store/modal.d.ts +0 -84
- package/esm/store/modal.js +0 -50
- package/esm/store/node.d.ts +0 -22
- package/esm/store/node.js +0 -89
- package/esm/store/pagination.d.ts +0 -58
- package/esm/store/pagination.js +0 -56
- package/esm/store/root.d.ts +0 -85
- package/esm/store/root.js +0 -53
- package/esm/store/service.d.ts +0 -71
- package/esm/store/service.js +0 -411
- package/esm/store/table.d.ts +0 -10085
- package/esm/store/table.js +0 -1136
- package/esm/store/table2.d.ts +0 -474
- package/esm/store/table2.js +0 -560
- package/esm/theme.d.ts +0 -89
- package/esm/theme.js +0 -127
- package/esm/types.d.ts +0 -489
- package/esm/utils/Animation.d.ts +0 -22
- package/esm/utils/Animation.js +0 -285
- package/esm/utils/ColorScale.d.ts +0 -19
- package/esm/utils/ColorScale.js +0 -100
- package/esm/utils/DataSchema.d.ts +0 -25
- package/esm/utils/DataSchema.js +0 -112
- package/esm/utils/DataScope.d.ts +0 -26
- package/esm/utils/DataScope.js +0 -158
- package/esm/utils/RootClose.d.ts +0 -4
- package/esm/utils/RootClose.js +0 -22
- package/esm/utils/SimpleMap.d.ts +0 -8
- package/esm/utils/SimpleMap.js +0 -37
- package/esm/utils/api.d.ts +0 -34
- package/esm/utils/api.js +0 -595
- package/esm/utils/attachmentAdpator.d.ts +0 -8
- package/esm/utils/attachmentAdpator.js +0 -86
- package/esm/utils/autobind.d.ts +0 -7
- package/esm/utils/autobind.js +0 -89
- package/esm/utils/columnsSplit.d.ts +0 -1
- package/esm/utils/columnsSplit.js +0 -42
- package/esm/utils/dataMapping.d.ts +0 -9
- package/esm/utils/dataMapping.js +0 -141
- package/esm/utils/date.d.ts +0 -4
- package/esm/utils/date.js +0 -80
- package/esm/utils/debug.d.ts +0 -29
- package/esm/utils/debug.js +0 -379
- package/esm/utils/decodeEntity.d.ts +0 -5
- package/esm/utils/decodeEntity.js +0 -16
- package/esm/utils/dom.d.ts +0 -13
- package/esm/utils/dom.js +0 -188
- package/esm/utils/errors.d.ts +0 -6
- package/esm/utils/errors.js +0 -19
- package/esm/utils/escapeHtml.d.ts +0 -1
- package/esm/utils/escapeHtml.js +0 -20
- package/esm/utils/filter-schema.d.ts +0 -13
- package/esm/utils/filter-schema.js +0 -68
- package/esm/utils/filter.d.ts +0 -1
- package/esm/utils/filter.js +0 -493
- package/esm/utils/formatDuration.d.ts +0 -1
- package/esm/utils/formatDuration.js +0 -23
- package/esm/utils/formula.d.ts +0 -16
- package/esm/utils/formula.js +0 -219
- package/esm/utils/getVariable.d.ts +0 -3
- package/esm/utils/getVariable.js +0 -25
- package/esm/utils/grammar.d.ts +0 -4
- package/esm/utils/grammar.js +0 -50
- package/esm/utils/handleAction.d.ts +0 -7
- package/esm/utils/handleAction.js +0 -34
- package/esm/utils/helper.d.ts +0 -323
- package/esm/utils/helper.js +0 -1261
- package/esm/utils/highlight.d.ts +0 -1
- package/esm/utils/highlight.js +0 -44
- package/esm/utils/icon.d.ts +0 -16
- package/esm/utils/icon.js +0 -35
- package/esm/utils/image.d.ts +0 -18
- package/esm/utils/image.js +0 -47
- package/esm/utils/index.d.ts +0 -55
- package/esm/utils/isPureVariable.d.ts +0 -1
- package/esm/utils/isPureVariable.js +0 -22
- package/esm/utils/json-schema-2-amis-schema.d.ts +0 -6
- package/esm/utils/json-schema-2-amis-schema.js +0 -56
- package/esm/utils/keyToPath.d.ts +0 -6
- package/esm/utils/keyToPath.js +0 -30
- package/esm/utils/makeSorter.d.ts +0 -1
- package/esm/utils/makeSorter.js +0 -26
- package/esm/utils/normalizeLink.d.ts +0 -1
- package/esm/utils/normalizeLink.js +0 -43
- package/esm/utils/normalizeOptions.d.ts +0 -7
- package/esm/utils/normalizeOptions.js +0 -84
- package/esm/utils/object.d.ts +0 -15
- package/esm/utils/object.js +0 -142
- package/esm/utils/offset.d.ts +0 -15
- package/esm/utils/offset.js +0 -32
- package/esm/utils/offsetParent.d.ts +0 -5
- package/esm/utils/offsetParent.js +0 -23
- package/esm/utils/optionValueCompare.d.ts +0 -3
- package/esm/utils/optionValueCompare.js +0 -25
- package/esm/utils/position.d.ts +0 -26
- package/esm/utils/position.js +0 -54
- package/esm/utils/prettyBytes.d.ts +0 -1
- package/esm/utils/prettyBytes.js +0 -25
- package/esm/utils/renderer-event.d.ts +0 -62
- package/esm/utils/renderer-event.js +0 -206
- package/esm/utils/replaceText.d.ts +0 -3
- package/esm/utils/replaceText.js +0 -38
- package/esm/utils/resize-sensor.d.ts +0 -6
- package/esm/utils/resize-sensor.js +0 -172
- package/esm/utils/resolveVariable.d.ts +0 -1
- package/esm/utils/resolveVariable.js +0 -35
- package/esm/utils/resolveVariableAndFilter.d.ts +0 -1
- package/esm/utils/resolveVariableAndFilter.js +0 -33
- package/esm/utils/scrollPosition.d.ts +0 -16
- package/esm/utils/scrollPosition.js +0 -33
- package/esm/utils/string2regExp.d.ts +0 -1
- package/esm/utils/string2regExp.js +0 -14
- package/esm/utils/stripNumber.d.ts +0 -1
- package/esm/utils/stripNumber.js +0 -16
- package/esm/utils/style.d.ts +0 -10
- package/esm/utils/style.js +0 -58
- package/esm/utils/toNumber.d.ts +0 -7
- package/esm/utils/toNumber.js +0 -18
- package/esm/utils/tokenize.d.ts +0 -1
- package/esm/utils/tokenize.js +0 -29
- package/esm/utils/tpl-builtin.d.ts +0 -18
- package/esm/utils/tpl-builtin.js +0 -59
- package/esm/utils/tpl-lodash.d.ts +0 -4
- package/esm/utils/tpl-lodash.js +0 -62
- package/esm/utils/tpl.d.ts +0 -11
- package/esm/utils/tpl.js +0 -131
- package/esm/utils/uncontrollable.d.ts +0 -4
- package/esm/utils/uncontrollable.js +0 -14
- package/esm/utils/validations.d.ts +0 -39
- package/esm/utils/validations.js +0 -440
- package/lib/Root.d.ts +0 -46
- package/lib/Root.js +0 -102
- package/lib/RootRenderer.d.ts +0 -27
- package/lib/RootRenderer.js +0 -290
- package/lib/SchemaRenderer.d.ts +0 -37
- package/lib/SchemaRenderer.js +0 -342
- package/lib/Scoped.d.ts +0 -38
- package/lib/Scoped.js +0 -274
- package/lib/WithRootStore.d.ts +0 -719
- package/lib/WithRootStore.js +0 -44
- package/lib/WithStore.d.ts +0 -5
- package/lib/WithStore.js +0 -190
- package/lib/actions/Action.d.ts +0 -40
- package/lib/actions/Action.js +0 -197
- package/lib/actions/AjaxAction.d.ts +0 -27
- package/lib/actions/AjaxAction.js +0 -100
- package/lib/actions/BreakAction.d.ts +0 -15
- package/lib/actions/BreakAction.js +0 -35
- package/lib/actions/BroadcastAction.d.ts +0 -19
- package/lib/actions/BroadcastAction.js +0 -50
- package/lib/actions/CmptAction.d.ts +0 -21
- package/lib/actions/CmptAction.js +0 -70
- package/lib/actions/ContinueAction.d.ts +0 -15
- package/lib/actions/ContinueAction.js +0 -35
- package/lib/actions/CopyAction.d.ts +0 -20
- package/lib/actions/CopyAction.js +0 -43
- package/lib/actions/CustomAction.d.ts +0 -22
- package/lib/actions/CustomAction.js +0 -78
- package/lib/actions/DialogAction.d.ts +0 -60
- package/lib/actions/DialogAction.js +0 -108
- package/lib/actions/DrawerAction.d.ts +0 -33
- package/lib/actions/DrawerAction.js +0 -70
- package/lib/actions/EmailAction.d.ts +0 -23
- package/lib/actions/EmailAction.js +0 -48
- package/lib/actions/LinkAction.d.ts +0 -24
- package/lib/actions/LinkAction.js +0 -47
- package/lib/actions/LoopAction.d.ts +0 -19
- package/lib/actions/LoopAction.js +0 -107
- package/lib/actions/PageAction.d.ts +0 -39
- package/lib/actions/PageAction.js +0 -80
- package/lib/actions/ParallelAction.d.ts +0 -8
- package/lib/actions/ParallelAction.js +0 -40
- package/lib/actions/SwitchAction.d.ts +0 -11
- package/lib/actions/SwitchAction.js +0 -52
- package/lib/actions/ToastAction.d.ts +0 -19
- package/lib/actions/ToastAction.js +0 -35
- package/lib/actions/index.d.ts +0 -20
- package/lib/components/LazyComponent.d.ts +0 -32
- package/lib/components/LazyComponent.js +0 -99
- package/lib/components/Overlay.d.ts +0 -44
- package/lib/components/Overlay.js +0 -266
- package/lib/components/PopOver.d.ts +0 -90
- package/lib/components/PopOver.js +0 -129
- package/lib/env.d.ts +0 -176
- package/lib/env.js +0 -20
- package/lib/envOverwrite.d.ts +0 -4
- package/lib/envOverwrite.js +0 -43
- package/lib/factory.d.ts +0 -85
- package/lib/factory.js +0 -324
- package/lib/index.d.ts +0 -44
- package/lib/index.js +0 -460
- package/lib/locale.d.ts +0 -84
- package/lib/locale.js +0 -133
- package/lib/renderers/Form.d.ts +0 -389
- package/lib/renderers/Form.js +0 -1234
- package/lib/renderers/Item.d.ts +0 -906
- package/lib/renderers/Item.js +0 -879
- package/lib/renderers/Options.d.ts +0 -158
- package/lib/renderers/Options.js +0 -920
- package/lib/renderers/Placeholder.d.ts +0 -6
- package/lib/renderers/Placeholder.js +0 -31
- package/lib/renderers/builtin.d.ts +0 -1
- package/lib/renderers/builtin.js +0 -27
- package/lib/renderers/register.d.ts +0 -6
- package/lib/renderers/register.js +0 -83
- package/lib/renderers/wrapControl.d.ts +0 -437
- package/lib/renderers/wrapControl.js +0 -520
- package/lib/store/app.d.ts +0 -92
- package/lib/store/app.js +0 -193
- package/lib/store/combo.d.ts +0 -10223
- package/lib/store/combo.js +0 -154
- package/lib/store/crud.d.ts +0 -128
- package/lib/store/crud.js +0 -455
- package/lib/store/form.d.ts +0 -4252
- package/lib/store/form.js +0 -664
- package/lib/store/formItem.d.ts +0 -133
- package/lib/store/formItem.js +0 -858
- package/lib/store/iRenderer.d.ts +0 -46
- package/lib/store/iRenderer.js +0 -189
- package/lib/store/index.d.ts +0 -125
- package/lib/store/index.js +0 -101
- package/lib/store/list.d.ts +0 -272
- package/lib/store/list.js +0 -256
- package/lib/store/manager.d.ts +0 -115
- package/lib/store/manager.js +0 -56
- package/lib/store/modal.d.ts +0 -84
- package/lib/store/modal.js +0 -54
- package/lib/store/node.d.ts +0 -22
- package/lib/store/node.js +0 -93
- package/lib/store/pagination.d.ts +0 -58
- package/lib/store/pagination.js +0 -60
- package/lib/store/root.d.ts +0 -85
- package/lib/store/root.js +0 -57
- package/lib/store/service.d.ts +0 -71
- package/lib/store/service.js +0 -415
- package/lib/store/table.d.ts +0 -10085
- package/lib/store/table.js +0 -1148
- package/lib/store/table2.d.ts +0 -474
- package/lib/store/table2.js +0 -571
- package/lib/theme.d.ts +0 -89
- package/lib/theme.js +0 -145
- package/lib/types.d.ts +0 -489
- package/lib/utils/Animation.d.ts +0 -22
- package/lib/utils/Animation.js +0 -290
- package/lib/utils/ColorScale.d.ts +0 -19
- package/lib/utils/ColorScale.js +0 -105
- package/lib/utils/DataSchema.d.ts +0 -25
- package/lib/utils/DataSchema.js +0 -116
- package/lib/utils/DataScope.d.ts +0 -26
- package/lib/utils/DataScope.js +0 -162
- package/lib/utils/RootClose.d.ts +0 -4
- package/lib/utils/RootClose.js +0 -30
- package/lib/utils/SimpleMap.d.ts +0 -8
- package/lib/utils/SimpleMap.js +0 -46
- package/lib/utils/api.d.ts +0 -34
- package/lib/utils/api.js +0 -621
- package/lib/utils/attachmentAdpator.d.ts +0 -8
- package/lib/utils/attachmentAdpator.js +0 -91
- package/lib/utils/autobind.d.ts +0 -7
- package/lib/utils/autobind.js +0 -94
- package/lib/utils/columnsSplit.d.ts +0 -1
- package/lib/utils/columnsSplit.js +0 -51
- package/lib/utils/dataMapping.d.ts +0 -9
- package/lib/utils/dataMapping.js +0 -151
- package/lib/utils/date.d.ts +0 -4
- package/lib/utils/date.js +0 -90
- package/lib/utils/debug.d.ts +0 -29
- package/lib/utils/debug.js +0 -392
- package/lib/utils/decodeEntity.d.ts +0 -5
- package/lib/utils/decodeEntity.js +0 -20
- package/lib/utils/dom.d.ts +0 -13
- package/lib/utils/dom.js +0 -199
- package/lib/utils/errors.d.ts +0 -6
- package/lib/utils/errors.js +0 -23
- package/lib/utils/escapeHtml.d.ts +0 -1
- package/lib/utils/escapeHtml.js +0 -24
- package/lib/utils/filter-schema.d.ts +0 -13
- package/lib/utils/filter-schema.js +0 -78
- package/lib/utils/filter.d.ts +0 -1
- package/lib/utils/filter.js +0 -503
- package/lib/utils/formatDuration.d.ts +0 -1
- package/lib/utils/formatDuration.js +0 -27
- package/lib/utils/formula.d.ts +0 -16
- package/lib/utils/formula.js +0 -234
- package/lib/utils/getVariable.d.ts +0 -3
- package/lib/utils/getVariable.js +0 -29
- package/lib/utils/grammar.d.ts +0 -4
- package/lib/utils/grammar.js +0 -54
- package/lib/utils/handleAction.d.ts +0 -7
- package/lib/utils/handleAction.js +0 -39
- package/lib/utils/helper.d.ts +0 -323
- package/lib/utils/helper.js +0 -1361
- package/lib/utils/highlight.d.ts +0 -1
- package/lib/utils/highlight.js +0 -52
- package/lib/utils/icon.d.ts +0 -16
- package/lib/utils/icon.js +0 -43
- package/lib/utils/image.d.ts +0 -18
- package/lib/utils/image.js +0 -56
- package/lib/utils/index.d.ts +0 -55
- package/lib/utils/isPureVariable.d.ts +0 -1
- package/lib/utils/isPureVariable.js +0 -26
- package/lib/utils/json-schema-2-amis-schema.d.ts +0 -6
- package/lib/utils/json-schema-2-amis-schema.js +0 -60
- package/lib/utils/keyToPath.d.ts +0 -6
- package/lib/utils/keyToPath.js +0 -34
- package/lib/utils/makeSorter.d.ts +0 -1
- package/lib/utils/makeSorter.js +0 -30
- package/lib/utils/normalizeLink.d.ts +0 -1
- package/lib/utils/normalizeLink.js +0 -47
- package/lib/utils/normalizeOptions.d.ts +0 -7
- package/lib/utils/normalizeOptions.js +0 -92
- package/lib/utils/object.d.ts +0 -15
- package/lib/utils/object.js +0 -156
- package/lib/utils/offset.d.ts +0 -15
- package/lib/utils/offset.js +0 -37
- package/lib/utils/offsetParent.d.ts +0 -5
- package/lib/utils/offsetParent.js +0 -28
- package/lib/utils/optionValueCompare.d.ts +0 -3
- package/lib/utils/optionValueCompare.js +0 -30
- package/lib/utils/position.d.ts +0 -26
- package/lib/utils/position.js +0 -59
- package/lib/utils/prettyBytes.d.ts +0 -1
- package/lib/utils/prettyBytes.js +0 -29
- package/lib/utils/renderer-event.d.ts +0 -62
- package/lib/utils/renderer-event.js +0 -218
- package/lib/utils/replaceText.d.ts +0 -3
- package/lib/utils/replaceText.js +0 -46
- package/lib/utils/resize-sensor.d.ts +0 -6
- package/lib/utils/resize-sensor.js +0 -177
- package/lib/utils/resolveVariable.d.ts +0 -1
- package/lib/utils/resolveVariable.js +0 -39
- package/lib/utils/resolveVariableAndFilter.d.ts +0 -1
- package/lib/utils/resolveVariableAndFilter.js +0 -37
- package/lib/utils/scrollPosition.d.ts +0 -16
- package/lib/utils/scrollPosition.js +0 -37
- package/lib/utils/string2regExp.d.ts +0 -1
- package/lib/utils/string2regExp.js +0 -18
- package/lib/utils/stripNumber.d.ts +0 -1
- package/lib/utils/stripNumber.js +0 -20
- package/lib/utils/style.d.ts +0 -10
- package/lib/utils/style.js +0 -67
- package/lib/utils/toNumber.d.ts +0 -7
- package/lib/utils/toNumber.js +0 -22
- package/lib/utils/tokenize.d.ts +0 -1
- package/lib/utils/tokenize.js +0 -33
- package/lib/utils/tpl-builtin.d.ts +0 -18
- package/lib/utils/tpl-builtin.js +0 -75
- package/lib/utils/tpl-lodash.d.ts +0 -4
- package/lib/utils/tpl-lodash.js +0 -71
- package/lib/utils/tpl.d.ts +0 -11
- package/lib/utils/tpl.js +0 -140
- package/lib/utils/uncontrollable.d.ts +0 -4
- package/lib/utils/uncontrollable.js +0 -22
- package/lib/utils/validations.d.ts +0 -39
- package/lib/utils/validations.js +0 -455
|
@@ -1,509 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* amis-core v2.6.0
|
|
3
|
-
* Copyright 2018-2022 fex
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { __extends, __awaiter, __generator, __assign } from 'tslib';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import debounce from 'lodash/debounce';
|
|
9
|
-
import isEqual from 'lodash/isEqual';
|
|
10
|
-
import { ComboStore } from '../store/combo.js';
|
|
11
|
-
import { guid, promisify, anyChanged } from '../utils/helper.js';
|
|
12
|
-
import { isExpression, FormulaExec, replaceExpression, isNeedFormula } from '../utils/formula.js';
|
|
13
|
-
import { ScopedContext } from '../Scoped.js';
|
|
14
|
-
import { FormItemStore } from '../store/formItem.js';
|
|
15
|
-
import { isAlive } from 'mobx-state-tree';
|
|
16
|
-
import { observer } from 'mobx-react';
|
|
17
|
-
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
18
|
-
import { withRootStore } from '../WithRootStore.js';
|
|
19
|
-
import { TableStore } from '../store/table.js';
|
|
20
|
-
import { getVariable } from '../utils/getVariable.js';
|
|
21
|
-
|
|
22
|
-
function wrapControl(ComposedComponent) {
|
|
23
|
-
var _a;
|
|
24
|
-
var result = hoistNonReactStatic(withRootStore(observer((_a = /** @class */ (function (_super) {
|
|
25
|
-
__extends(class_1, _super);
|
|
26
|
-
function class_1(props) {
|
|
27
|
-
var _this = this;
|
|
28
|
-
var _a, _b;
|
|
29
|
-
_this = _super.call(this, props) || this;
|
|
30
|
-
_this.value = undefined;
|
|
31
|
-
_this.lazyEmitChange = debounce(_this.emitChange.bind(_this), 250, {
|
|
32
|
-
trailing: true,
|
|
33
|
-
leading: false
|
|
34
|
-
});
|
|
35
|
-
var _c = _this.props, form = _c.formStore, formItem = _c.formItem, rootStore = _c.rootStore, store = _c.store, onChange = _c.onChange, data = _c.data, _d = _c.$schema, name = _d.name, id = _d.id, type = _d.type, required = _d.required, validations = _d.validations, validationErrors = _d.validationErrors, unique = _d.unique, value = _d.value, multiple = _d.multiple, delimiter = _d.delimiter, valueField = _d.valueField, labelField = _d.labelField, joinValues = _d.joinValues, extractValue = _d.extractValue, selectFirst = _d.selectFirst, autoFill = _d.autoFill, clearValueOnHidden = _d.clearValueOnHidden, validateApi = _d.validateApi, minLength = _d.minLength, maxLength = _d.maxLength, validateOnChange = _d.validateOnChange, label = _d.label;
|
|
36
|
-
_this.getValue = _this.getValue.bind(_this);
|
|
37
|
-
_this.setValue = _this.setValue.bind(_this);
|
|
38
|
-
_this.handleChange = _this.handleChange.bind(_this);
|
|
39
|
-
_this.setPrinstineValue = _this.setPrinstineValue.bind(_this);
|
|
40
|
-
_this.controlRef = _this.controlRef.bind(_this);
|
|
41
|
-
_this.handleBlur = _this.handleBlur.bind(_this);
|
|
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
|
-
type !== 'input-group') {
|
|
51
|
-
console.warn('name is required', _this.props.$schema);
|
|
52
|
-
}
|
|
53
|
-
return _this;
|
|
54
|
-
}
|
|
55
|
-
var propValue = _this.props.value;
|
|
56
|
-
var model = rootStore.addStore({
|
|
57
|
-
id: guid(),
|
|
58
|
-
path: _this.props.$path,
|
|
59
|
-
storeType: FormItemStore.name,
|
|
60
|
-
parentId: store === null || store === void 0 ? void 0 : store.id,
|
|
61
|
-
name: name
|
|
62
|
-
});
|
|
63
|
-
_this.model = model;
|
|
64
|
-
// @issue 打算干掉这个
|
|
65
|
-
formItem === null || formItem === void 0 ? void 0 : formItem.addSubFormItem(model);
|
|
66
|
-
model.config({
|
|
67
|
-
id: id,
|
|
68
|
-
type: type,
|
|
69
|
-
required: required,
|
|
70
|
-
unique: unique,
|
|
71
|
-
value: value,
|
|
72
|
-
rules: validations,
|
|
73
|
-
messages: validationErrors,
|
|
74
|
-
multiple: multiple,
|
|
75
|
-
delimiter: delimiter,
|
|
76
|
-
valueField: valueField,
|
|
77
|
-
labelField: labelField,
|
|
78
|
-
joinValues: joinValues,
|
|
79
|
-
extractValue: extractValue,
|
|
80
|
-
selectFirst: selectFirst,
|
|
81
|
-
autoFill: autoFill,
|
|
82
|
-
clearValueOnHidden: clearValueOnHidden,
|
|
83
|
-
validateApi: validateApi,
|
|
84
|
-
minLength: minLength,
|
|
85
|
-
maxLength: maxLength,
|
|
86
|
-
validateOnChange: validateOnChange,
|
|
87
|
-
label: label
|
|
88
|
-
});
|
|
89
|
-
// issue 这个逻辑应该在 combo 里面自己实现。
|
|
90
|
-
if (_this.model.unique &&
|
|
91
|
-
((_a = form === null || form === void 0 ? void 0 : form.parentStore) === null || _a === void 0 ? void 0 : _a.storeType) === ComboStore.name) {
|
|
92
|
-
var combo = form.parentStore;
|
|
93
|
-
combo.bindUniuqueItem(model);
|
|
94
|
-
}
|
|
95
|
-
if (propValue !== undefined && propValue !== null) {
|
|
96
|
-
// 同步 value: 优先使用 props 中的 value
|
|
97
|
-
model.changeTmpValue(propValue);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// 备注: 此处的 value 是 schema 中的 value(和props.defaultValue相同)
|
|
101
|
-
var curTmpValue = isExpression(value)
|
|
102
|
-
? FormulaExec['formula'](value, data) // 对组件默认值进行运算
|
|
103
|
-
: (_b = store === null || store === void 0 ? void 0 : store.getValueByName(model.name)) !== null && _b !== void 0 ? _b : replaceExpression(value); // 优先使用公式表达式
|
|
104
|
-
// 同步 value
|
|
105
|
-
model.changeTmpValue(curTmpValue);
|
|
106
|
-
if (onChange &&
|
|
107
|
-
value !== undefined &&
|
|
108
|
-
curTmpValue !== undefined) {
|
|
109
|
-
// 组件默认值支持表达式需要: 避免初始化时上下文中丢失组件默认值
|
|
110
|
-
onChange(model.tmpValue, model.name, false, true);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (onChange &&
|
|
114
|
-
typeof propValue === 'undefined' &&
|
|
115
|
-
typeof (store === null || store === void 0 ? void 0 : store.getValueByName(model.name, false)) === 'undefined' &&
|
|
116
|
-
// todo 后续再优化这个判断,
|
|
117
|
-
// 目前 input-table 中默认值会给冲掉,所以加上这个判断
|
|
118
|
-
// 对应 issue 为 https://github.com/baidu/amis/issues/2674
|
|
119
|
-
(store === null || store === void 0 ? void 0 : store.storeType) !== TableStore.name) {
|
|
120
|
-
// 如果没有初始值,通过 onChange 设置过去
|
|
121
|
-
onChange(model.tmpValue, model.name, false, true);
|
|
122
|
-
}
|
|
123
|
-
return _this;
|
|
124
|
-
}
|
|
125
|
-
class_1.prototype.componentDidMount = function () {
|
|
126
|
-
var _this = this;
|
|
127
|
-
var _a = this.props; _a.store; _a.formStore; var _b = _a.$schema, name = _b.name, validate = _b.validate, addHook = _a.addHook;
|
|
128
|
-
// 提交前先把之前的 lazyEmit 执行一下。
|
|
129
|
-
this.hook3 = function () {
|
|
130
|
-
_this.lazyEmitChange.flush();
|
|
131
|
-
};
|
|
132
|
-
addHook === null || addHook === void 0 ? void 0 : addHook(this.hook3, 'flush');
|
|
133
|
-
var formItem = this.model;
|
|
134
|
-
if (formItem && validate) {
|
|
135
|
-
var finalValidate_1 = promisify(validate.bind(formItem));
|
|
136
|
-
this.hook2 = function () {
|
|
137
|
-
formItem.clearError('control:valdiate');
|
|
138
|
-
return finalValidate_1(_this.props.data, _this.getValue(), name).then(function (ret) {
|
|
139
|
-
if ((typeof ret === 'string' || Array.isArray(ret)) && ret) {
|
|
140
|
-
formItem.addError(ret, 'control:valdiate');
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
addHook === null || addHook === void 0 ? void 0 : addHook(this.hook2);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
class_1.prototype.componentDidUpdate = function (prevProps) {
|
|
148
|
-
var props = this.props;
|
|
149
|
-
props.formStore;
|
|
150
|
-
var model = this.model;
|
|
151
|
-
if (model &&
|
|
152
|
-
anyChanged([
|
|
153
|
-
'id',
|
|
154
|
-
'validations',
|
|
155
|
-
'validationErrors',
|
|
156
|
-
'value',
|
|
157
|
-
'defaultValue',
|
|
158
|
-
'required',
|
|
159
|
-
'unique',
|
|
160
|
-
'multiple',
|
|
161
|
-
'delimiter',
|
|
162
|
-
'valueField',
|
|
163
|
-
'labelField',
|
|
164
|
-
'joinValues',
|
|
165
|
-
'extractValue',
|
|
166
|
-
'selectFirst',
|
|
167
|
-
'autoFill',
|
|
168
|
-
'clearValueOnHidden',
|
|
169
|
-
'validateApi',
|
|
170
|
-
'minLength',
|
|
171
|
-
'maxLength',
|
|
172
|
-
'label'
|
|
173
|
-
], prevProps.$schema, props.$schema)) {
|
|
174
|
-
model.config({
|
|
175
|
-
required: props.$schema.required,
|
|
176
|
-
id: props.$schema.id,
|
|
177
|
-
unique: props.$schema.unique,
|
|
178
|
-
value: props.$schema.value,
|
|
179
|
-
rules: props.$schema.validations,
|
|
180
|
-
multiple: props.$schema.multiple,
|
|
181
|
-
delimiter: props.$schema.delimiter,
|
|
182
|
-
valueField: props.$schema.valueField,
|
|
183
|
-
labelField: props.$schema.labelField,
|
|
184
|
-
joinValues: props.$schema.joinValues,
|
|
185
|
-
extractValue: props.$schema.extractValue,
|
|
186
|
-
messages: props.$schema.validationErrors,
|
|
187
|
-
selectFirst: props.$schema.selectFirst,
|
|
188
|
-
autoFill: props.$schema.autoFill,
|
|
189
|
-
clearValueOnHidden: props.$schema.clearValueOnHidden,
|
|
190
|
-
validateApi: props.$schema.validateApi,
|
|
191
|
-
minLength: props.$schema.minLength,
|
|
192
|
-
maxLength: props.$schema.maxLength,
|
|
193
|
-
label: props.$schema.label
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
// 此处需要同时考虑 defaultValue 和 value
|
|
197
|
-
if (model && typeof props.value !== 'undefined') {
|
|
198
|
-
// 渲染器中的 value 优先
|
|
199
|
-
if (!isEqual(props.value, prevProps.value) &&
|
|
200
|
-
!isEqual(props.value, model.tmpValue)) {
|
|
201
|
-
// 外部直接传入的 value 无需执行运算器
|
|
202
|
-
model.changeTmpValue(props.value);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else if (model &&
|
|
206
|
-
typeof props.defaultValue !== 'undefined' &&
|
|
207
|
-
isExpression(props.defaultValue)) {
|
|
208
|
-
// 渲染器中的 defaultValue 优先(备注: SchemaRenderer中会将 value 改成 defaultValue)
|
|
209
|
-
if (!isEqual(props.defaultValue, prevProps.defaultValue) ||
|
|
210
|
-
(props.data !== prevProps.data &&
|
|
211
|
-
isNeedFormula(props.defaultValue, props.data, prevProps.data))) {
|
|
212
|
-
var curResult = FormulaExec['formula'](props.defaultValue, props.data);
|
|
213
|
-
var prevResult = FormulaExec['formula'](prevProps.defaultValue, prevProps.data);
|
|
214
|
-
if (!isEqual(curResult, prevResult) &&
|
|
215
|
-
!isEqual(curResult, model.tmpValue)) {
|
|
216
|
-
// 识别上下文变动、自身数值变动、公式运算结果变动
|
|
217
|
-
model.changeTmpValue(curResult);
|
|
218
|
-
if (props.onChange) {
|
|
219
|
-
props.onChange(curResult, model.name, false);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
else if (model) {
|
|
225
|
-
var valueByName = getVariable(props.data, model.name);
|
|
226
|
-
if (isEqual(props.defaultValue, prevProps.defaultValue)) {
|
|
227
|
-
// value 非公式表达式时,name 值优先,若 defaultValue 主动变动时,则使用 defaultValue
|
|
228
|
-
if (
|
|
229
|
-
// 然后才是查看关联的 name 属性值是否变化
|
|
230
|
-
props.data !== prevProps.data &&
|
|
231
|
-
(!model.emitedValue ||
|
|
232
|
-
isEqual(model.emitedValue, model.tmpValue))) {
|
|
233
|
-
model.changeEmitedValue(undefined);
|
|
234
|
-
var prevValueByName = getVariable(props.data, model.name);
|
|
235
|
-
if ((!isEqual(valueByName, prevValueByName) ||
|
|
236
|
-
getVariable(props.data, model.name, false) !==
|
|
237
|
-
getVariable(prevProps.data, model.name, false)) &&
|
|
238
|
-
!isEqual(valueByName, model.tmpValue)) {
|
|
239
|
-
model.changeTmpValue(valueByName);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
else if (!isEqual(props.defaultValue, prevProps.defaultValue) &&
|
|
244
|
-
!isEqual(props.defaultValue, model.tmpValue)) {
|
|
245
|
-
// 组件默认值非公式
|
|
246
|
-
var curValue = replaceExpression(props.defaultValue);
|
|
247
|
-
model.changeTmpValue(curValue);
|
|
248
|
-
if (props.onChange) {
|
|
249
|
-
props.onChange(curValue, model.name, false);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
class_1.prototype.componentWillUnmount = function () {
|
|
255
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
256
|
-
this.hook && ((_b = (_a = this.props).removeHook) === null || _b === void 0 ? void 0 : _b.call(_a, this.hook));
|
|
257
|
-
this.hook2 && ((_d = (_c = this.props).removeHook) === null || _d === void 0 ? void 0 : _d.call(_c, this.hook2));
|
|
258
|
-
this.hook3 && ((_f = (_e = this.props).removeHook) === null || _f === void 0 ? void 0 : _f.call(_e, this.hook3, 'flush'));
|
|
259
|
-
// this.lazyEmitChange.flush();
|
|
260
|
-
this.lazyEmitChange.cancel();
|
|
261
|
-
(_g = this.reaction) === null || _g === void 0 ? void 0 : _g.call(this);
|
|
262
|
-
this.disposeModel();
|
|
263
|
-
};
|
|
264
|
-
class_1.prototype.disposeModel = function () {
|
|
265
|
-
var _a;
|
|
266
|
-
var _b = this.props, form = _b.formStore, formItem = _b.formItem, rootStore = _b.rootStore;
|
|
267
|
-
if (this.model &&
|
|
268
|
-
this.model.unique &&
|
|
269
|
-
(form === null || form === void 0 ? void 0 : form.parentStore) &&
|
|
270
|
-
(form === null || form === void 0 ? void 0 : form.parentStore.storeType) === ComboStore.name) {
|
|
271
|
-
var combo = form.parentStore;
|
|
272
|
-
combo.unBindUniuqueItem(this.model);
|
|
273
|
-
}
|
|
274
|
-
if (this.model) {
|
|
275
|
-
formItem &&
|
|
276
|
-
isAlive(formItem) &&
|
|
277
|
-
formItem.removeSubFormItem(this.model);
|
|
278
|
-
this.model.clearValueOnHidden &&
|
|
279
|
-
((_a = this.model.form) === null || _a === void 0 ? void 0 : _a.deleteValueByName(this.model.name));
|
|
280
|
-
isAlive(rootStore) && rootStore.removeStore(this.model);
|
|
281
|
-
}
|
|
282
|
-
delete this.model;
|
|
283
|
-
};
|
|
284
|
-
class_1.prototype.controlRef = function (control) {
|
|
285
|
-
var _this = this;
|
|
286
|
-
var _a = this.props, addHook = _a.addHook, removeHook = _a.removeHook; _a.formStore; var name = _a.$schema.name;
|
|
287
|
-
// 因为 control 有可能被 n 层 hoc 包裹。
|
|
288
|
-
while (control && control.getWrappedInstance) {
|
|
289
|
-
control = control.getWrappedInstance();
|
|
290
|
-
}
|
|
291
|
-
if (control && control.validate && this.model) {
|
|
292
|
-
var formItem_1 = this.model;
|
|
293
|
-
var validate_1 = promisify(control.validate.bind(control));
|
|
294
|
-
this.hook = function () {
|
|
295
|
-
formItem_1.clearError('component:valdiate');
|
|
296
|
-
return validate_1(_this.props.data, _this.getValue(), name).then(function (ret) {
|
|
297
|
-
if ((typeof ret === 'string' || Array.isArray(ret)) &&
|
|
298
|
-
ret) {
|
|
299
|
-
formItem_1.setError(ret, 'component:valdiate');
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
};
|
|
303
|
-
addHook === null || addHook === void 0 ? void 0 : addHook(this.hook);
|
|
304
|
-
}
|
|
305
|
-
else if (!control && this.hook) {
|
|
306
|
-
removeHook === null || removeHook === void 0 ? void 0 : removeHook(this.hook);
|
|
307
|
-
this.hook = undefined;
|
|
308
|
-
}
|
|
309
|
-
// 注册到 Scoped 上
|
|
310
|
-
var originRef = this.control;
|
|
311
|
-
this.control = control;
|
|
312
|
-
var scoped = this.context;
|
|
313
|
-
if (control) {
|
|
314
|
-
scoped.registerComponent(this.control);
|
|
315
|
-
}
|
|
316
|
-
else if (originRef) {
|
|
317
|
-
scoped.unRegisterComponent(originRef);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
class_1.prototype.validate = function () {
|
|
321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
-
var _a, form, data, formItemDispatchEvent, result, combo, group, validPromises, validPromises;
|
|
323
|
-
return __generator(this, function (_b) {
|
|
324
|
-
switch (_b.label) {
|
|
325
|
-
case 0:
|
|
326
|
-
_a = this.props, form = _a.formStore, data = _a.data, formItemDispatchEvent = _a.formItemDispatchEvent;
|
|
327
|
-
if (!this.model) return [3 /*break*/, 4];
|
|
328
|
-
if (!(this.model.unique &&
|
|
329
|
-
(form === null || form === void 0 ? void 0 : form.parentStore) &&
|
|
330
|
-
form.parentStore.storeType === ComboStore.name)) return [3 /*break*/, 2];
|
|
331
|
-
combo = form.parentStore;
|
|
332
|
-
group = combo.uniques.get(this.model.name);
|
|
333
|
-
validPromises = group.items.map(function (item) {
|
|
334
|
-
return item.validate(data);
|
|
335
|
-
});
|
|
336
|
-
return [4 /*yield*/, Promise.all(validPromises)];
|
|
337
|
-
case 1:
|
|
338
|
-
result = _b.sent();
|
|
339
|
-
return [3 /*break*/, 4];
|
|
340
|
-
case 2:
|
|
341
|
-
validPromises = form === null || form === void 0 ? void 0 : form.getItemsByName(this.model.name).map(function (item) { return item.validate(data); });
|
|
342
|
-
if (!(validPromises && validPromises.length)) return [3 /*break*/, 4];
|
|
343
|
-
return [4 /*yield*/, Promise.all(validPromises)];
|
|
344
|
-
case 3:
|
|
345
|
-
result = _b.sent();
|
|
346
|
-
_b.label = 4;
|
|
347
|
-
case 4:
|
|
348
|
-
if (result && result.length) {
|
|
349
|
-
if (result.indexOf(false) > -1) {
|
|
350
|
-
formItemDispatchEvent('formItemValidateError', data);
|
|
351
|
-
}
|
|
352
|
-
else {
|
|
353
|
-
formItemDispatchEvent('formItemValidateSucc', data);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return [2 /*return*/];
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
};
|
|
361
|
-
class_1.prototype.handleChange = function (value, submitOnChange, changeImmediately) {
|
|
362
|
-
if (submitOnChange === void 0) { submitOnChange = this.props.$schema.submitOnChange; }
|
|
363
|
-
if (changeImmediately === void 0) { changeImmediately = false; }
|
|
364
|
-
var _a = this.props; _a.formStore; var onChange = _a.onChange, _b = _a.$schema, type = _b.type, pipeOut = _b.pipeOut, conrolChangeImmediately = _b.changeImmediately, formInited = _a.formInited, data = _a.data;
|
|
365
|
-
if (!this.model ||
|
|
366
|
-
// todo 以后想办法不要強耦合类型。
|
|
367
|
-
~[
|
|
368
|
-
'service',
|
|
369
|
-
'group',
|
|
370
|
-
'hbox',
|
|
371
|
-
'panel',
|
|
372
|
-
'grid',
|
|
373
|
-
'input-group'
|
|
374
|
-
].indexOf(type)) {
|
|
375
|
-
onChange && onChange.apply(null, arguments);
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
if (pipeOut) {
|
|
379
|
-
var oldValue = this.model.value;
|
|
380
|
-
value = pipeOut(value, oldValue, data);
|
|
381
|
-
}
|
|
382
|
-
this.model.changeTmpValue(value);
|
|
383
|
-
if (changeImmediately || conrolChangeImmediately || !formInited) {
|
|
384
|
-
this.emitChange(submitOnChange);
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
// this.props.onTmpValueChange?.(value, this.model.name);
|
|
388
|
-
this.lazyEmitChange(submitOnChange);
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
class_1.prototype.emitChange = function (submitOnChange) {
|
|
392
|
-
var _a;
|
|
393
|
-
if (submitOnChange === void 0) { submitOnChange = this.props.$schema.submitOnChange; }
|
|
394
|
-
var _b = this.props, form = _b.formStore, onChange = _b.onChange, _c = _b.$schema, name = _c.name, id = _c.id, label = _c.label, type = _c.type, onFormItemChange = _c.onChange; _c.maxLength; _c.minLength; var data = _b.data, env = _b.env, validateOnChange = _b.validateOnChange, formSubmited = _b.formSubmited;
|
|
395
|
-
if (!this.model) {
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
var value = this.model.tmpValue;
|
|
399
|
-
var oldValue = getVariable(data, this.model.name, false);
|
|
400
|
-
if (oldValue === value) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
if (type !== 'input-password') {
|
|
404
|
-
env === null || env === void 0 ? void 0 : env.tracker({
|
|
405
|
-
eventType: 'formItemChange',
|
|
406
|
-
eventData: {
|
|
407
|
-
id: id,
|
|
408
|
-
name: name,
|
|
409
|
-
label: label,
|
|
410
|
-
type: type,
|
|
411
|
-
value: value
|
|
412
|
-
}
|
|
413
|
-
}, this.props);
|
|
414
|
-
}
|
|
415
|
-
this.model.changeEmitedValue(value);
|
|
416
|
-
if ((onFormItemChange === null || onFormItemChange === void 0 ? void 0 : onFormItemChange(value, oldValue, this.model, form)) === false) {
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
var validated = this.model.validated;
|
|
420
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, submitOnChange === true);
|
|
421
|
-
if (
|
|
422
|
-
// 如果配置了 minLength 或者 maxLength 就切成及时验证
|
|
423
|
-
// this.model.rules.minLength ||
|
|
424
|
-
// this.model.rules.maxLength ||
|
|
425
|
-
validateOnChange === true ||
|
|
426
|
-
(validateOnChange !== false && (formSubmited || validated))) {
|
|
427
|
-
this.validate();
|
|
428
|
-
}
|
|
429
|
-
else if (validateOnChange === false) {
|
|
430
|
-
(_a = this.model) === null || _a === void 0 ? void 0 : _a.reset();
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
class_1.prototype.handleBlur = function (e) {
|
|
434
|
-
var _a = this.props, onBlur = _a.onBlur, validateOnBlur = _a.$schema.validateOnBlur;
|
|
435
|
-
if (validateOnBlur && this.model) {
|
|
436
|
-
this.validate();
|
|
437
|
-
}
|
|
438
|
-
onBlur && onBlur(e);
|
|
439
|
-
};
|
|
440
|
-
class_1.prototype.setPrinstineValue = function (value) {
|
|
441
|
-
if (!this.model) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
var _a = this.props; _a.formStore; var name = _a.name, pipeOut = _a.$schema.pipeOut, onChange = _a.onChange, oldValue = _a.value, data = _a.data;
|
|
445
|
-
if (pipeOut) {
|
|
446
|
-
value = pipeOut(value, oldValue, data);
|
|
447
|
-
}
|
|
448
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, false, true);
|
|
449
|
-
};
|
|
450
|
-
class_1.prototype.getValue = function () {
|
|
451
|
-
var _a = this.props, data = _a.formStore, control = _a.$schema;
|
|
452
|
-
var value = this.model ? this.model.tmpValue : control.value;
|
|
453
|
-
if (control.pipeIn) {
|
|
454
|
-
value = control.pipeIn(value, data);
|
|
455
|
-
}
|
|
456
|
-
return value;
|
|
457
|
-
};
|
|
458
|
-
// 兼容老版本用法,新版本直接用 onChange 就可以。
|
|
459
|
-
class_1.prototype.setValue = function (value, key) {
|
|
460
|
-
var _a;
|
|
461
|
-
var _b = this.props, name = _b.$schema.name, onBulkChange = _b.onBulkChange;
|
|
462
|
-
if (!key || key === name) {
|
|
463
|
-
this.handleChange(value);
|
|
464
|
-
}
|
|
465
|
-
else {
|
|
466
|
-
onBulkChange &&
|
|
467
|
-
onBulkChange((_a = {},
|
|
468
|
-
_a[key] = value,
|
|
469
|
-
_a));
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
class_1.prototype.render = function () {
|
|
473
|
-
var _a;
|
|
474
|
-
var _b = this.props, controlWidth = _b.controlWidth, disabled = _b.disabled, formMode = _b.formMode, control = _b.$schema, store = _b.store, data = _b.data, invisible = _b.invisible;
|
|
475
|
-
if (invisible) {
|
|
476
|
-
return null;
|
|
477
|
-
}
|
|
478
|
-
var value = this.getValue();
|
|
479
|
-
var model = this.model;
|
|
480
|
-
var injectedProps = {
|
|
481
|
-
defaultSize: controlWidth,
|
|
482
|
-
disabled: disabled !== null && disabled !== void 0 ? disabled : control.disabled,
|
|
483
|
-
formItem: this.model,
|
|
484
|
-
formMode: control.mode || formMode,
|
|
485
|
-
ref: this.controlRef,
|
|
486
|
-
data: data || (store === null || store === void 0 ? void 0 : store.data),
|
|
487
|
-
value: value,
|
|
488
|
-
defaultValue: control.value,
|
|
489
|
-
formItemValue: value,
|
|
490
|
-
onChange: this.handleChange,
|
|
491
|
-
onBlur: this.handleBlur,
|
|
492
|
-
setValue: this.setValue,
|
|
493
|
-
getValue: this.getValue,
|
|
494
|
-
prinstine: model ? model.prinstine : undefined,
|
|
495
|
-
setPrinstineValue: this.setPrinstineValue,
|
|
496
|
-
// !没了这个, tree 里的 options 渲染会出问题
|
|
497
|
-
_filteredOptions: (_a = this.model) === null || _a === void 0 ? void 0 : _a.filteredOptions
|
|
498
|
-
};
|
|
499
|
-
return (React.createElement(ComposedComponent, __assign({}, this.props, injectedProps)));
|
|
500
|
-
};
|
|
501
|
-
return class_1;
|
|
502
|
-
}(React.Component)),
|
|
503
|
-
_a.contextType = ScopedContext,
|
|
504
|
-
_a.defaultProps = {},
|
|
505
|
-
_a))), ComposedComponent);
|
|
506
|
-
return result;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
export { wrapControl };
|
package/esm/store/app.d.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Instance, SnapshotIn } from 'mobx-state-tree';
|
|
2
|
-
import { RendererEnv } from '../factory';
|
|
3
|
-
import { NavigationObject } from '../types';
|
|
4
|
-
export declare const AppStore: import("mobx-state-tree").IModelType<{
|
|
5
|
-
id: import("mobx-state-tree").ISimpleType<string>;
|
|
6
|
-
path: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
7
|
-
storeType: import("mobx-state-tree").ISimpleType<string>;
|
|
8
|
-
disposed: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
9
|
-
parentId: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
10
|
-
childrenIds: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").ISimpleType<string>>, [undefined]>;
|
|
11
|
-
} & {
|
|
12
|
-
hasRemoteData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
13
|
-
data: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
14
|
-
initedAt: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
15
|
-
updatedAt: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
16
|
-
pristine: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
17
|
-
action: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
18
|
-
dialogOpen: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
19
|
-
dialogData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
20
|
-
drawerOpen: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
21
|
-
drawerData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
22
|
-
} & {
|
|
23
|
-
msg: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
24
|
-
error: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
25
|
-
fetching: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
26
|
-
saving: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
27
|
-
busying: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
28
|
-
checking: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
29
|
-
initializing: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
30
|
-
schema: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
31
|
-
schemaKey: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
32
|
-
} & {
|
|
33
|
-
pages: import("mobx-state-tree").IType<any, any, any>;
|
|
34
|
-
activePage: import("mobx-state-tree").IType<any, any, any>;
|
|
35
|
-
folded: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
36
|
-
offScreen: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
37
|
-
}, {
|
|
38
|
-
readonly parentStore: any;
|
|
39
|
-
readonly __: any;
|
|
40
|
-
readonly hasChildren: boolean;
|
|
41
|
-
readonly children: any[];
|
|
42
|
-
} & {
|
|
43
|
-
onChildStoreDispose(child: any): void;
|
|
44
|
-
syncProps(props: any, prevProps: any, list?: string[]): void;
|
|
45
|
-
dispose: (callback?: (() => void) | undefined) => void;
|
|
46
|
-
addChildId: (id: string) => void;
|
|
47
|
-
removeChildId: (id: string) => void;
|
|
48
|
-
} & {
|
|
49
|
-
getValueByName(name: string, canAccessSuper?: boolean): any;
|
|
50
|
-
getPristineValueByName(name: string): any;
|
|
51
|
-
} & {
|
|
52
|
-
initData(data?: object, skipSetPristine?: boolean): void;
|
|
53
|
-
reset(): void;
|
|
54
|
-
updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
|
|
55
|
-
changeValue(name: string, value: any, changePristine?: boolean | undefined, force?: boolean | undefined, otherModifier?: ((data: Object) => void) | undefined): void;
|
|
56
|
-
setCurrentAction(action: object): void;
|
|
57
|
-
openDialog(ctx: any, additonal?: object | undefined, callback?: ((ret: any) => void) | undefined): void;
|
|
58
|
-
closeDialog(result?: any): void;
|
|
59
|
-
openDrawer(ctx: any, additonal?: object | undefined, callback?: ((ret: any) => void) | undefined): void;
|
|
60
|
-
closeDrawer(result?: any): void;
|
|
61
|
-
} & {
|
|
62
|
-
readonly loading: boolean;
|
|
63
|
-
} & {
|
|
64
|
-
markFetching: (fetching?: boolean) => void;
|
|
65
|
-
markSaving: (saving?: boolean) => void;
|
|
66
|
-
markBusying: (busying?: boolean) => void;
|
|
67
|
-
fetchInitData: (api: import("../types").Api, data?: object | undefined, options?: import("../types").fetchOptions | undefined) => Promise<any>;
|
|
68
|
-
fetchData: (api: import("../types").Api, data?: object | undefined, options?: import("../types").fetchOptions | undefined) => Promise<any>;
|
|
69
|
-
reInitData: (data: object | undefined, replace?: boolean) => void;
|
|
70
|
-
updateMessage: (msg?: string | undefined, error?: boolean) => void;
|
|
71
|
-
clearMessage: () => void;
|
|
72
|
-
setHasRemoteData: () => void;
|
|
73
|
-
saveRemote: (api: import("../types").Api, data?: object | undefined, options?: import("../types").fetchOptions | undefined) => Promise<any>;
|
|
74
|
-
fetchSchema: (api: import("../types").Api, data?: object | undefined, options?: import("../types").fetchOptions | undefined) => Promise<any>;
|
|
75
|
-
checkRemote: (api: import("../types").Api, data?: object | undefined, options?: import("../types").fetchOptions | undefined) => Promise<any>;
|
|
76
|
-
} & {
|
|
77
|
-
readonly navigations: NavigationObject[];
|
|
78
|
-
readonly bcn: any;
|
|
79
|
-
readonly pageData: object;
|
|
80
|
-
} & {
|
|
81
|
-
toggleFolded(): void;
|
|
82
|
-
toggleOffScreen(): void;
|
|
83
|
-
setPages(pages: any): void;
|
|
84
|
-
rewrite(to: string, env: RendererEnv): void;
|
|
85
|
-
setActivePage(page: any, env: RendererEnv & {
|
|
86
|
-
showFullBreadcrumbPath?: boolean;
|
|
87
|
-
showBreadcrumbHomePath?: boolean;
|
|
88
|
-
}, params?: any): void;
|
|
89
|
-
updateActivePage(env: RendererEnv): void;
|
|
90
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
91
|
-
export type IAppStore = Instance<typeof AppStore>;
|
|
92
|
-
export type SAppStore = SnapshotIn<typeof AppStore>;
|