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
package/esm/SchemaRenderer.js
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* amis-core v2.6.0
|
|
3
|
-
* Copyright 2018-2022 fex
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { __extends, __assign, __awaiter, __generator, __rest, __decorate, __metadata } from 'tslib';
|
|
7
|
-
import difference from 'lodash/difference';
|
|
8
|
-
import omit from 'lodash/omit';
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import LazyComponent from './components/LazyComponent.js';
|
|
11
|
-
import { resolveRenderer, loadRenderer, filterSchema } from './factory.js';
|
|
12
|
-
import { asFormItem } from './renderers/Item.js';
|
|
13
|
-
import { ScopedContext } from './Scoped.js';
|
|
14
|
-
import { DebugWrapper } from './utils/debug.js';
|
|
15
|
-
import { getExprProperties } from './utils/filter-schema.js';
|
|
16
|
-
import { anyChanged, chainEvents, autobind } from './utils/helper.js';
|
|
17
|
-
import { SimpleMap } from './utils/SimpleMap.js';
|
|
18
|
-
import { bindEvent, dispatchEvent } from './utils/renderer-event.js';
|
|
19
|
-
import { isAlive } from 'mobx-state-tree';
|
|
20
|
-
import { reaction } from 'mobx';
|
|
21
|
-
import 'amis-formula';
|
|
22
|
-
import 'moment';
|
|
23
|
-
import 'lodash/isPlainObject';
|
|
24
|
-
import { resolveVariableAndFilter } from './utils/resolveVariableAndFilter.js';
|
|
25
|
-
import './utils/filter.js';
|
|
26
|
-
import { buildStyle } from './utils/style.js';
|
|
27
|
-
|
|
28
|
-
var defaultOmitList = [
|
|
29
|
-
'type',
|
|
30
|
-
'name',
|
|
31
|
-
'$ref',
|
|
32
|
-
'className',
|
|
33
|
-
'style',
|
|
34
|
-
'data',
|
|
35
|
-
'children',
|
|
36
|
-
'ref',
|
|
37
|
-
'visible',
|
|
38
|
-
'visibleOn',
|
|
39
|
-
'hidden',
|
|
40
|
-
'hiddenOn',
|
|
41
|
-
'disabled',
|
|
42
|
-
'disabledOn',
|
|
43
|
-
'component',
|
|
44
|
-
'detectField',
|
|
45
|
-
'defaultValue',
|
|
46
|
-
'defaultData',
|
|
47
|
-
'required',
|
|
48
|
-
'requiredOn',
|
|
49
|
-
'syncSuperStore',
|
|
50
|
-
'mode',
|
|
51
|
-
'body',
|
|
52
|
-
'id'
|
|
53
|
-
];
|
|
54
|
-
var componentCache = new SimpleMap();
|
|
55
|
-
var SchemaRenderer = /** @class */ (function (_super) {
|
|
56
|
-
__extends(SchemaRenderer, _super);
|
|
57
|
-
function SchemaRenderer(props) {
|
|
58
|
-
var _this = _super.call(this, props) || this;
|
|
59
|
-
_this.rendererKey = '';
|
|
60
|
-
_this.unbindEvent = undefined;
|
|
61
|
-
_this.refFn = _this.refFn.bind(_this);
|
|
62
|
-
_this.renderChild = _this.renderChild.bind(_this);
|
|
63
|
-
_this.reRender = _this.reRender.bind(_this);
|
|
64
|
-
_this.resolveRenderer(_this.props);
|
|
65
|
-
_this.dispatchEvent = _this.dispatchEvent.bind(_this);
|
|
66
|
-
// 监听topStore更新
|
|
67
|
-
_this.reaction = reaction(function () {
|
|
68
|
-
return "".concat(props.topStore.visibleState[props.schema.id || props.$path]).concat(props.topStore.disableState[props.schema.id || props.$path]).concat(props.topStore.staticState[props.schema.id || props.$path]);
|
|
69
|
-
}, function () { return _this.forceUpdate(); });
|
|
70
|
-
return _this;
|
|
71
|
-
}
|
|
72
|
-
SchemaRenderer.prototype.componentDidMount = function () {
|
|
73
|
-
// 这里无法区分监听的是不是广播,所以又bind一下,主要是为了绑广播
|
|
74
|
-
this.unbindEvent = bindEvent(this.cRef);
|
|
75
|
-
};
|
|
76
|
-
SchemaRenderer.prototype.componentWillUnmount = function () {
|
|
77
|
-
var _a, _b;
|
|
78
|
-
(_a = this.reaction) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
79
|
-
(_b = this.unbindEvent) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
80
|
-
};
|
|
81
|
-
// 限制:只有 schema 除外的 props 变化,或者 schema 里面的某个成员值发生变化才更新。
|
|
82
|
-
SchemaRenderer.prototype.shouldComponentUpdate = function (nextProps) {
|
|
83
|
-
var props = this.props;
|
|
84
|
-
var list = difference(Object.keys(nextProps), [
|
|
85
|
-
'schema',
|
|
86
|
-
'scope'
|
|
87
|
-
]);
|
|
88
|
-
if (difference(Object.keys(props), ['schema', 'scope']).length !==
|
|
89
|
-
list.length ||
|
|
90
|
-
anyChanged(list, this.props, nextProps)) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
var list_1 = Object.keys(nextProps.schema);
|
|
95
|
-
if (Object.keys(props.schema).length !== list_1.length ||
|
|
96
|
-
anyChanged(list_1, props.schema, nextProps.schema)) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
};
|
|
102
|
-
SchemaRenderer.prototype.resolveRenderer = function (props, force) {
|
|
103
|
-
if (force === void 0) { force = false; }
|
|
104
|
-
var schema = props.schema;
|
|
105
|
-
var path = props.$path;
|
|
106
|
-
if (schema && schema.$ref) {
|
|
107
|
-
schema = __assign(__assign({}, props.resolveDefinitions(schema.$ref)), schema);
|
|
108
|
-
path = path.replace(/(?!.*\/).*/, schema.type);
|
|
109
|
-
}
|
|
110
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) &&
|
|
111
|
-
(force ||
|
|
112
|
-
!this.renderer ||
|
|
113
|
-
this.rendererKey !== "".concat(schema.type, "-").concat(schema.$$id))) {
|
|
114
|
-
var rendererResolver = props.env.rendererResolver || resolveRenderer;
|
|
115
|
-
this.renderer = rendererResolver(path, schema, props);
|
|
116
|
-
this.rendererKey = "".concat(schema.type, "-").concat(schema.$$id);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
// 自定义组件如果在节点设置了 label name 什么的,就用 formItem 包一层
|
|
120
|
-
// 至少自动支持了 valdiations, label, description 等逻辑。
|
|
121
|
-
if (schema.children && !schema.component && schema.asFormItem) {
|
|
122
|
-
schema.component = PlaceholderComponent;
|
|
123
|
-
schema.renderChildren = schema.children;
|
|
124
|
-
delete schema.children;
|
|
125
|
-
}
|
|
126
|
-
if (schema.component &&
|
|
127
|
-
!schema.component.wrapedAsFormItem &&
|
|
128
|
-
schema.asFormItem) {
|
|
129
|
-
var cache = componentCache.get(schema.component);
|
|
130
|
-
if (cache) {
|
|
131
|
-
schema.component = cache;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
var cache_1 = asFormItem(__assign({ strictMode: false }, schema.asFormItem))(schema.component);
|
|
135
|
-
componentCache.set(schema.component, cache_1);
|
|
136
|
-
cache_1.wrapedAsFormItem = true;
|
|
137
|
-
schema.component = cache_1;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return { path: path, schema: schema };
|
|
142
|
-
};
|
|
143
|
-
SchemaRenderer.prototype.getWrappedInstance = function () {
|
|
144
|
-
return this.cRef;
|
|
145
|
-
};
|
|
146
|
-
SchemaRenderer.prototype.refFn = function (ref) {
|
|
147
|
-
this.ref = ref;
|
|
148
|
-
};
|
|
149
|
-
SchemaRenderer.prototype.childRef = function (ref) {
|
|
150
|
-
while (ref && ref.getWrappedInstance) {
|
|
151
|
-
ref = ref.getWrappedInstance();
|
|
152
|
-
}
|
|
153
|
-
this.cRef = ref;
|
|
154
|
-
};
|
|
155
|
-
SchemaRenderer.prototype.dispatchEvent = function (e, data, renderer // for didmount
|
|
156
|
-
) {
|
|
157
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
return __generator(this, function (_a) {
|
|
159
|
-
switch (_a.label) {
|
|
160
|
-
case 0: return [4 /*yield*/, dispatchEvent(e, this.cRef || renderer, this.context, data)];
|
|
161
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
SchemaRenderer.prototype.renderChild = function (region, node, subProps) {
|
|
167
|
-
if (subProps === void 0) { subProps = {}; }
|
|
168
|
-
var _a = this.props; _a.schema; _a.$path; var env = _a.env, render = _a.render, rest = __rest(_a, ["schema", "$path", "env", "render"]);
|
|
169
|
-
var $path = this.resolveRenderer(this.props).path;
|
|
170
|
-
var omitList = defaultOmitList.concat();
|
|
171
|
-
if (this.renderer) {
|
|
172
|
-
var Component = this.renderer.component;
|
|
173
|
-
Component.propsList &&
|
|
174
|
-
omitList.push.apply(omitList, Component.propsList);
|
|
175
|
-
}
|
|
176
|
-
return render("".concat($path).concat(region ? "/".concat(region) : ''), node || '', __assign(__assign(__assign({}, omit(rest, omitList)), subProps), { data: subProps.data || rest.data, env: env }));
|
|
177
|
-
};
|
|
178
|
-
SchemaRenderer.prototype.reRender = function () {
|
|
179
|
-
this.resolveRenderer(this.props, true);
|
|
180
|
-
this.forceUpdate();
|
|
181
|
-
};
|
|
182
|
-
SchemaRenderer.prototype.render = function () {
|
|
183
|
-
var _this = this;
|
|
184
|
-
var _a, _b, _c;
|
|
185
|
-
var _d = this.props; _d.$path; var __ = _d.schema, rootStore = _d.rootStore, topStore = _d.topStore, render = _d.render, rest = __rest(_d, ["$path", "schema", "rootStore", "topStore", "render"]);
|
|
186
|
-
if (__ == null) {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
var _e = this.resolveRenderer(this.props), $path = _e.path, schema = _e.schema;
|
|
190
|
-
var theme = this.props.env.theme;
|
|
191
|
-
if (Array.isArray(schema)) {
|
|
192
|
-
return render($path, schema, rest);
|
|
193
|
-
}
|
|
194
|
-
var detectData = schema &&
|
|
195
|
-
(schema.detectField === '&' ? rest : rest[schema.detectField || 'data']);
|
|
196
|
-
var exprProps = detectData
|
|
197
|
-
? getExprProperties(schema, detectData, undefined, rest)
|
|
198
|
-
: {};
|
|
199
|
-
// 控制显隐
|
|
200
|
-
var visible = isAlive(topStore)
|
|
201
|
-
? topStore.visibleState[schema.id || $path]
|
|
202
|
-
: undefined;
|
|
203
|
-
var disable = isAlive(topStore)
|
|
204
|
-
? topStore.disableState[schema.id || $path]
|
|
205
|
-
: undefined;
|
|
206
|
-
var isStatic = isAlive(topStore)
|
|
207
|
-
? topStore.staticState[schema.id || $path]
|
|
208
|
-
: undefined;
|
|
209
|
-
if (visible === false ||
|
|
210
|
-
(visible !== true &&
|
|
211
|
-
exprProps &&
|
|
212
|
-
(exprProps.hidden ||
|
|
213
|
-
exprProps.visible === false ||
|
|
214
|
-
schema.hidden ||
|
|
215
|
-
schema.visible === false ||
|
|
216
|
-
rest.hidden ||
|
|
217
|
-
rest.visible === false))) {
|
|
218
|
-
rest.invisible = true;
|
|
219
|
-
}
|
|
220
|
-
if (schema.children) {
|
|
221
|
-
return rest.invisible
|
|
222
|
-
? null
|
|
223
|
-
: React.isValidElement(schema.children)
|
|
224
|
-
? schema.children
|
|
225
|
-
: schema.children(__assign(__assign(__assign({}, rest), exprProps), { $path: $path, $schema: schema, render: this.renderChild, forwardedRef: this.refFn, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent }));
|
|
226
|
-
}
|
|
227
|
-
else if (typeof schema.component === 'function') {
|
|
228
|
-
var isSFC = !(schema.component.prototype instanceof React.Component);
|
|
229
|
-
var defaultData_1 = schema.data, defaultValue_1 = schema.value, // render时的value改放defaultValue中
|
|
230
|
-
defaultActiveKey_1 = schema.activeKey, propKey_1 = schema.key, restSchema_1 = __rest(schema, ["data", "value", "activeKey", "key"]);
|
|
231
|
-
return rest.invisible
|
|
232
|
-
? null
|
|
233
|
-
: React.createElement(schema.component, __assign(__assign(__assign(__assign({}, rest), restSchema_1), exprProps), {
|
|
234
|
-
// value: defaultValue, // 备注: 此处并没有将value传递给渲染器
|
|
235
|
-
defaultData: defaultData_1, defaultValue: defaultValue_1, defaultActiveKey: defaultActiveKey_1, propKey: propKey_1, $path: $path, $schema: schema, ref: isSFC ? undefined : this.refFn, forwardedRef: isSFC ? this.refFn : undefined, render: this.renderChild, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent }));
|
|
236
|
-
}
|
|
237
|
-
else if (Object.keys(schema).length === 0) {
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
else if (!this.renderer) {
|
|
241
|
-
return rest.invisible ? null : (React.createElement(LazyComponent, __assign({}, rest, exprProps, { getComponent: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
242
|
-
var result;
|
|
243
|
-
return __generator(this, function (_a) {
|
|
244
|
-
switch (_a.label) {
|
|
245
|
-
case 0: return [4 /*yield*/, rest.env.loadRenderer(schema, $path, this.reRender)];
|
|
246
|
-
case 1:
|
|
247
|
-
result = _a.sent();
|
|
248
|
-
if (result && typeof result === 'function') {
|
|
249
|
-
return [2 /*return*/, result];
|
|
250
|
-
}
|
|
251
|
-
else if (result && React.isValidElement(result)) {
|
|
252
|
-
return [2 /*return*/, function () { return result; }];
|
|
253
|
-
}
|
|
254
|
-
this.reRender();
|
|
255
|
-
return [2 /*return*/, function () { return loadRenderer(schema, $path); }];
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
}); }, "$path": $path, "$schema": schema, retry: this.reRender, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent })));
|
|
259
|
-
}
|
|
260
|
-
var renderer = this.renderer;
|
|
261
|
-
schema = filterSchema(schema, renderer, rest);
|
|
262
|
-
var defaultData = schema.data, defaultValue = schema.value, propKey = schema.key, defaultActiveKey = schema.activeKey, restSchema = __rest(schema, ["data", "value", "key", "activeKey"]);
|
|
263
|
-
var Component = renderer.component;
|
|
264
|
-
// 原来表单项的 visible: false 和 hidden: true 表单项的值和验证是有效的
|
|
265
|
-
// 而 visibleOn 和 hiddenOn 是无效的,
|
|
266
|
-
// 这个本来就是个bug,但是已经被广泛使用了
|
|
267
|
-
// 我只能继续实现这个bug了
|
|
268
|
-
if (rest.invisible &&
|
|
269
|
-
(exprProps.hidden ||
|
|
270
|
-
exprProps.visible === false ||
|
|
271
|
-
!renderer.isFormItem ||
|
|
272
|
-
(schema.visible !== false && !schema.hidden))) {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
// withStore 里面会处理,而且会实时处理
|
|
276
|
-
// 这里处理反而导致了问题
|
|
277
|
-
if (renderer.storeType) {
|
|
278
|
-
exprProps = {};
|
|
279
|
-
}
|
|
280
|
-
// style 支持公式
|
|
281
|
-
if (schema.style) {
|
|
282
|
-
schema.style = buildStyle(schema.style, detectData);
|
|
283
|
-
}
|
|
284
|
-
var isClassComponent = (_a = Component.prototype) === null || _a === void 0 ? void 0 : _a.isReactComponent;
|
|
285
|
-
var $schema = __assign(__assign({}, schema), exprProps);
|
|
286
|
-
var props = __assign(__assign(__assign(__assign(__assign({}, theme.getRendererConfig(renderer.name)), restSchema), chainEvents(rest, restSchema)), exprProps), {
|
|
287
|
-
// value: defaultValue, // 备注: 此处并没有将value传递给渲染器
|
|
288
|
-
defaultData: (_b = restSchema.defaultData) !== null && _b !== void 0 ? _b : defaultData, defaultValue: (_c = restSchema.defaultValue) !== null && _c !== void 0 ? _c : defaultValue, defaultActiveKey: defaultActiveKey, propKey: propKey, $path: $path, $schema: $schema, ref: this.refFn, render: this.renderChild, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent });
|
|
289
|
-
if (disable !== undefined) {
|
|
290
|
-
props.disabled = disable;
|
|
291
|
-
}
|
|
292
|
-
if (isStatic !== undefined) {
|
|
293
|
-
props.static = isStatic;
|
|
294
|
-
}
|
|
295
|
-
// 自动解析变量模式,主要是方便直接引入第三方组件库,无需为了支持变量封装一层
|
|
296
|
-
if (renderer.autoVar) {
|
|
297
|
-
for (var _i = 0, _f = Object.keys($schema); _i < _f.length; _i++) {
|
|
298
|
-
var key = _f[_i];
|
|
299
|
-
if (typeof props[key] === 'string') {
|
|
300
|
-
props[key] = resolveVariableAndFilter(props[key], props.data, '| raw');
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
var component = isClassComponent ? (React.createElement(Component, __assign({}, props, { ref: this.childRef }))) : (React.createElement(Component, __assign({}, props)));
|
|
305
|
-
return this.props.env.enableAMISDebug ? (React.createElement(DebugWrapper, { renderer: renderer }, component)) : (component);
|
|
306
|
-
};
|
|
307
|
-
SchemaRenderer.displayName = 'Renderer';
|
|
308
|
-
SchemaRenderer.contextType = ScopedContext;
|
|
309
|
-
__decorate([
|
|
310
|
-
autobind,
|
|
311
|
-
__metadata("design:type", Function),
|
|
312
|
-
__metadata("design:paramtypes", [Object]),
|
|
313
|
-
__metadata("design:returntype", void 0)
|
|
314
|
-
], SchemaRenderer.prototype, "childRef", null);
|
|
315
|
-
return SchemaRenderer;
|
|
316
|
-
}(React.Component));
|
|
317
|
-
var PlaceholderComponent = /** @class */ (function (_super) {
|
|
318
|
-
__extends(PlaceholderComponent, _super);
|
|
319
|
-
function PlaceholderComponent() {
|
|
320
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
321
|
-
}
|
|
322
|
-
PlaceholderComponent.prototype.render = function () {
|
|
323
|
-
var _a = this.props, renderChildren = _a.renderChildren, rest = __rest(_a, ["renderChildren"]);
|
|
324
|
-
if (typeof renderChildren === 'function') {
|
|
325
|
-
return renderChildren(rest);
|
|
326
|
-
}
|
|
327
|
-
return null;
|
|
328
|
-
};
|
|
329
|
-
return PlaceholderComponent;
|
|
330
|
-
}(React.Component));
|
|
331
|
-
|
|
332
|
-
export { SchemaRenderer };
|
package/esm/Scoped.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file 用来创建一个域,在这个域里面会把里面的运行时实例注册进来,方便组件之间的通信。
|
|
3
|
-
* @author fex
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { RendererEnv, RendererProps } from './factory';
|
|
7
|
-
import { RendererData, ActionObject } from './types';
|
|
8
|
-
export interface ScopedComponentType extends React.Component<RendererProps> {
|
|
9
|
-
focus?: () => void;
|
|
10
|
-
doAction?: (action: ActionObject, data: RendererData, throwErrors?: boolean) => void;
|
|
11
|
-
receive?: (values: RendererData, subPath?: string, replace?: boolean) => void;
|
|
12
|
-
reload?: (subPath?: string, query?: RendererData | null, ctx?: RendererData) => void;
|
|
13
|
-
context: any;
|
|
14
|
-
}
|
|
15
|
-
export interface IScopedContext {
|
|
16
|
-
parent?: AliasIScopedContext;
|
|
17
|
-
children?: AliasIScopedContext[];
|
|
18
|
-
registerComponent: (component: ScopedComponentType) => void;
|
|
19
|
-
unRegisterComponent: (component: ScopedComponentType) => void;
|
|
20
|
-
getComponentByName: (name: string) => ScopedComponentType;
|
|
21
|
-
getComponentById: (id: string) => ScopedComponentType | undefined;
|
|
22
|
-
getComponents: () => Array<ScopedComponentType>;
|
|
23
|
-
reload: (target: string, ctx: RendererData) => void;
|
|
24
|
-
send: (target: string, ctx: RendererData) => void;
|
|
25
|
-
close: (target: string) => void;
|
|
26
|
-
closeById: (target: string) => void;
|
|
27
|
-
}
|
|
28
|
-
type AliasIScopedContext = IScopedContext;
|
|
29
|
-
export declare const ScopedContext: React.Context<IScopedContext>;
|
|
30
|
-
export declare function HocScoped<T extends {
|
|
31
|
-
$path?: string;
|
|
32
|
-
env: RendererEnv;
|
|
33
|
-
}>(ComposedComponent: React.ComponentType<T>): React.ComponentType<T & {
|
|
34
|
-
scopeRef?: (ref: any) => void;
|
|
35
|
-
}> & {
|
|
36
|
-
ComposedComponent: React.ComponentType<T>;
|
|
37
|
-
};
|
|
38
|
-
export default HocScoped;
|
package/esm/Scoped.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* amis-core v2.6.0
|
|
3
|
-
* Copyright 2018-2022 fex
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { __assign, __extends, __rest, __decorate, __metadata } from 'tslib';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import find from 'lodash/find';
|
|
9
|
-
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
10
|
-
import { registerFunction } from 'amis-formula';
|
|
11
|
-
import 'moment';
|
|
12
|
-
import 'lodash/isPlainObject';
|
|
13
|
-
import { getVariable } from './utils/getVariable.js';
|
|
14
|
-
import { dataMapping } from './utils/dataMapping.js';
|
|
15
|
-
import './utils/filter.js';
|
|
16
|
-
import { findTree, qsparse, qsstringify, parseQuery, autobind } from './utils/helper.js';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @file 用来创建一个域,在这个域里面会把里面的运行时实例注册进来,方便组件之间的通信。
|
|
20
|
-
* @author fex
|
|
21
|
-
*/
|
|
22
|
-
var ScopedContext = React.createContext(createScopedTools(''));
|
|
23
|
-
function createScopedTools(path, parent, env) {
|
|
24
|
-
var components = [];
|
|
25
|
-
var self = {
|
|
26
|
-
parent: parent,
|
|
27
|
-
registerComponent: function (component) {
|
|
28
|
-
// 不要把自己注册在自己的 Scoped 上,自己的 Scoped 是给子节点们注册的。
|
|
29
|
-
if (component.props.$path === path && parent) {
|
|
30
|
-
return parent.registerComponent(component);
|
|
31
|
-
}
|
|
32
|
-
if (!~components.indexOf(component)) {
|
|
33
|
-
components.push(component);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
unRegisterComponent: function (component) {
|
|
37
|
-
// 自己本身实际上注册在父级 Scoped 上。
|
|
38
|
-
if (component.props.$path === path && parent) {
|
|
39
|
-
return parent.unRegisterComponent(component);
|
|
40
|
-
}
|
|
41
|
-
var idx = components.indexOf(component);
|
|
42
|
-
if (~idx) {
|
|
43
|
-
components.splice(idx, 1);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
getComponentByName: function (name) {
|
|
47
|
-
if (~name.indexOf('.')) {
|
|
48
|
-
var paths = name.split('.');
|
|
49
|
-
var len_1 = paths.length;
|
|
50
|
-
return paths.reduce(function (scope, name, idx) {
|
|
51
|
-
if (scope && scope.getComponentByName) {
|
|
52
|
-
var result = scope.getComponentByName(name);
|
|
53
|
-
return result && idx < len_1 - 1 ? result.context : result;
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}, this);
|
|
57
|
-
}
|
|
58
|
-
var resolved = find(components, function (component) {
|
|
59
|
-
return component.props.name === name || component.props.id === name;
|
|
60
|
-
});
|
|
61
|
-
return resolved || (parent && parent.getComponentByName(name));
|
|
62
|
-
},
|
|
63
|
-
getComponentById: function (id) {
|
|
64
|
-
var root = this;
|
|
65
|
-
// 找到顶端scoped
|
|
66
|
-
while (root.parent) {
|
|
67
|
-
root = root.parent;
|
|
68
|
-
}
|
|
69
|
-
// 向下查找
|
|
70
|
-
var component = undefined;
|
|
71
|
-
findTree([root], function (item) {
|
|
72
|
-
return item.getComponents().find(function (cmpt) {
|
|
73
|
-
if (cmpt.props.id === id) {
|
|
74
|
-
component = cmpt;
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
return component;
|
|
81
|
-
},
|
|
82
|
-
getComponents: function () {
|
|
83
|
-
return components.concat();
|
|
84
|
-
},
|
|
85
|
-
reload: function (target, ctx) {
|
|
86
|
-
var scoped = this;
|
|
87
|
-
var targets = typeof target === 'string' ? target.split(/\s*,\s*/) : target;
|
|
88
|
-
targets.forEach(function (name) {
|
|
89
|
-
var idx2 = name.indexOf('?');
|
|
90
|
-
var query = null;
|
|
91
|
-
if (~idx2) {
|
|
92
|
-
var queryObj = qsparse(name
|
|
93
|
-
.substring(idx2 + 1)
|
|
94
|
-
.replace(/\$\{(.*?)\}/, function (_, match) { return '${' + encodeURIComponent(match) + '}'; }));
|
|
95
|
-
query = dataMapping(queryObj, ctx);
|
|
96
|
-
name = name.substring(0, idx2);
|
|
97
|
-
}
|
|
98
|
-
var idx = name.indexOf('.');
|
|
99
|
-
var subPath = '';
|
|
100
|
-
if (~idx) {
|
|
101
|
-
subPath = name.substring(1 + idx);
|
|
102
|
-
name = name.substring(0, idx);
|
|
103
|
-
}
|
|
104
|
-
if (name === 'window') {
|
|
105
|
-
if (query) {
|
|
106
|
-
var link = location.pathname + '?' + qsstringify(query);
|
|
107
|
-
env ? env.updateLocation(link, true) : location.replace(link);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
location.reload();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
var component = scoped.getComponentByName(name);
|
|
115
|
-
component &&
|
|
116
|
-
component.reload &&
|
|
117
|
-
component.reload(subPath, query, ctx);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
send: function (receive, values) {
|
|
122
|
-
var scoped = this;
|
|
123
|
-
var receives = typeof receive === 'string' ? receive.split(/\s*,\s*/) : receive;
|
|
124
|
-
// todo 没找到做提示!
|
|
125
|
-
receives.forEach(function (name) {
|
|
126
|
-
var askIdx = name.indexOf('?');
|
|
127
|
-
if (~askIdx) {
|
|
128
|
-
var query = name.substring(askIdx + 1);
|
|
129
|
-
var queryObj = qsparse(query.replace(/\$\{(.*?)\}/, function (_, match) { return '${' + encodeURIComponent(match) + '}'; }));
|
|
130
|
-
name = name.substring(0, askIdx);
|
|
131
|
-
values = dataMapping(queryObj, values);
|
|
132
|
-
}
|
|
133
|
-
var idx = name.indexOf('.');
|
|
134
|
-
var subPath = '';
|
|
135
|
-
if (~idx) {
|
|
136
|
-
subPath = name.substring(1 + idx);
|
|
137
|
-
name = name.substring(0, idx);
|
|
138
|
-
}
|
|
139
|
-
var component = scoped.getComponentByName(name);
|
|
140
|
-
if (component && component.receive) {
|
|
141
|
-
component.receive(values, subPath);
|
|
142
|
-
}
|
|
143
|
-
else if (name === 'window' && env && env.updateLocation) {
|
|
144
|
-
var query = __assign(__assign({}, parseQuery(location)), values);
|
|
145
|
-
var link = location.pathname + '?' + qsstringify(query);
|
|
146
|
-
env.updateLocation(link, true);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
},
|
|
150
|
-
/**
|
|
151
|
-
* 主要是用来关闭指定弹框的
|
|
152
|
-
*
|
|
153
|
-
* @param target 目标 name
|
|
154
|
-
*/
|
|
155
|
-
close: function (target) {
|
|
156
|
-
var scoped = this;
|
|
157
|
-
if (typeof target === 'string') {
|
|
158
|
-
// 过滤已经关掉的,当用户 close 配置多个弹框 name 时会出现这种情况
|
|
159
|
-
target
|
|
160
|
-
.split(/\s*,\s*/)
|
|
161
|
-
.map(function (name) { return scoped.getComponentByName(name); })
|
|
162
|
-
.filter(function (component) { return component && component.props.show; })
|
|
163
|
-
.forEach(closeDialog);
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
/**
|
|
167
|
-
* 关闭指定id的弹窗
|
|
168
|
-
* @param id
|
|
169
|
-
*/
|
|
170
|
-
closeById: function (id) {
|
|
171
|
-
var scoped = this;
|
|
172
|
-
var component = scoped.getComponentById(id);
|
|
173
|
-
if (component && component.props.show) {
|
|
174
|
-
closeDialog(component);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
registerFunction('GETRENDERERDATA', function (componentId, path, scoped) {
|
|
179
|
-
var _a;
|
|
180
|
-
if (scoped === void 0) { scoped = self; }
|
|
181
|
-
var component = scoped.getComponentById(componentId);
|
|
182
|
-
var data = (_a = component === null || component === void 0 ? void 0 : component.getData) === null || _a === void 0 ? void 0 : _a.call(component);
|
|
183
|
-
if (path) {
|
|
184
|
-
var variable = getVariable(data, path);
|
|
185
|
-
return variable;
|
|
186
|
-
}
|
|
187
|
-
return data;
|
|
188
|
-
});
|
|
189
|
-
registerFunction('GETRENDERERPROP', function (componentId, path, scoped) {
|
|
190
|
-
if (scoped === void 0) { scoped = self; }
|
|
191
|
-
var component = scoped.getComponentById(componentId);
|
|
192
|
-
var props = component === null || component === void 0 ? void 0 : component.props;
|
|
193
|
-
if (path) {
|
|
194
|
-
var variable = getVariable(props, path);
|
|
195
|
-
return variable;
|
|
196
|
-
}
|
|
197
|
-
return props;
|
|
198
|
-
});
|
|
199
|
-
if (!parent) {
|
|
200
|
-
return self;
|
|
201
|
-
}
|
|
202
|
-
!parent.children && (parent.children = []);
|
|
203
|
-
// 把孩子带上
|
|
204
|
-
parent.children.push(self);
|
|
205
|
-
return self;
|
|
206
|
-
}
|
|
207
|
-
function closeDialog(component) {
|
|
208
|
-
component.context
|
|
209
|
-
.getComponents()
|
|
210
|
-
.filter(function (item) {
|
|
211
|
-
return item &&
|
|
212
|
-
(item.props.type === 'dialog' || item.props.type === 'drawer') &&
|
|
213
|
-
item.props.show;
|
|
214
|
-
})
|
|
215
|
-
.forEach(closeDialog);
|
|
216
|
-
component.props.onClose && component.props.onClose();
|
|
217
|
-
}
|
|
218
|
-
function HocScoped(ComposedComponent) {
|
|
219
|
-
var ScopedComponent = /** @class */ (function (_super) {
|
|
220
|
-
__extends(ScopedComponent, _super);
|
|
221
|
-
function ScopedComponent(props, context) {
|
|
222
|
-
var _this = _super.call(this, props) || this;
|
|
223
|
-
_this.scoped = createScopedTools(_this.props.$path, context, _this.props.env);
|
|
224
|
-
var scopeRef = props.scopeRef;
|
|
225
|
-
scopeRef && scopeRef(_this.scoped);
|
|
226
|
-
return _this;
|
|
227
|
-
}
|
|
228
|
-
ScopedComponent.prototype.getWrappedInstance = function () {
|
|
229
|
-
return this.ref;
|
|
230
|
-
};
|
|
231
|
-
ScopedComponent.prototype.childRef = function (ref) {
|
|
232
|
-
while (ref && ref.getWrappedInstance) {
|
|
233
|
-
ref = ref.getWrappedInstance();
|
|
234
|
-
}
|
|
235
|
-
this.ref = ref;
|
|
236
|
-
};
|
|
237
|
-
ScopedComponent.prototype.componentWillUnmount = function () {
|
|
238
|
-
var scopeRef = this.props.scopeRef;
|
|
239
|
-
scopeRef && scopeRef(null);
|
|
240
|
-
delete this.scoped;
|
|
241
|
-
};
|
|
242
|
-
ScopedComponent.prototype.render = function () {
|
|
243
|
-
var _a = this.props; _a.scopeRef; var rest = __rest(_a, ["scopeRef"]);
|
|
244
|
-
return (React.createElement(ScopedContext.Provider, { value: this.scoped },
|
|
245
|
-
React.createElement(ComposedComponent, __assign({}, rest /* todo */, { ref: this.childRef }))));
|
|
246
|
-
};
|
|
247
|
-
ScopedComponent.displayName = "Scoped(".concat(ComposedComponent.displayName || ComposedComponent.name, ")");
|
|
248
|
-
ScopedComponent.contextType = ScopedContext;
|
|
249
|
-
ScopedComponent.ComposedComponent = ComposedComponent;
|
|
250
|
-
__decorate([
|
|
251
|
-
autobind,
|
|
252
|
-
__metadata("design:type", Function),
|
|
253
|
-
__metadata("design:paramtypes", [Object]),
|
|
254
|
-
__metadata("design:returntype", void 0)
|
|
255
|
-
], ScopedComponent.prototype, "childRef", null);
|
|
256
|
-
return ScopedComponent;
|
|
257
|
-
}(React.Component));
|
|
258
|
-
hoistNonReactStatic(ScopedComponent, ComposedComponent);
|
|
259
|
-
return ScopedComponent;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export { HocScoped, ScopedContext, HocScoped as default };
|