@nocobase/flow-engine 2.0.0-alpha.3 → 2.0.0-alpha.30
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/lib/BlockScopedFlowEngine.d.ts +23 -0
- package/lib/BlockScopedFlowEngine.js +90 -0
- package/lib/FlowContextProvider.d.ts +2 -2
- package/lib/FlowContextProvider.js +3 -3
- package/lib/FlowDefinition.d.ts +4 -2
- package/lib/JSRunner.js +3 -0
- package/lib/ViewScopedFlowEngine.d.ts +1 -1
- package/lib/components/FieldModelRenderer.js +10 -4
- package/lib/components/FieldSkeleton.d.ts +10 -0
- package/lib/components/FieldSkeleton.js +64 -0
- package/lib/components/FlowContextSelector.js +7 -2
- package/lib/components/FlowModelRenderer.d.ts +2 -5
- package/lib/components/FlowModelRenderer.js +16 -47
- package/lib/components/FormItem.js +5 -1
- package/lib/{runjs-context/snippets/global/requireAsync.snippet.d.ts → components/dnd/findModelUidPosition.d.ts} +4 -7
- package/lib/{runjs-context/snippets/scene/jsblock/jsx-mount.snippet.js → components/dnd/findModelUidPosition.js} +23 -19
- package/lib/components/dnd/gridDragPlanner.d.ts +130 -0
- package/lib/components/dnd/gridDragPlanner.js +497 -0
- package/lib/components/dnd/index.d.ts +2 -2
- package/lib/components/dnd/index.js +5 -5
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.js +2 -2
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +17 -5
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +2 -2
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +7 -1
- package/lib/components/variables/VariableInput.js +16 -2
- package/lib/components/variables/VariableTag.js +43 -2
- package/lib/components/variables/types.d.ts +2 -0
- package/lib/data-source/index.d.ts +12 -4
- package/lib/data-source/index.js +19 -13
- package/lib/data-source/sortCollectionsByInherits.d.ts +10 -0
- package/lib/data-source/sortCollectionsByInherits.js +71 -0
- package/lib/executor/FlowExecutor.d.ts +4 -5
- package/lib/executor/FlowExecutor.js +135 -100
- package/lib/flowContext.d.ts +33 -5
- package/lib/flowContext.js +193 -76
- package/lib/flowEngine.d.ts +8 -1
- package/lib/flowEngine.js +18 -6
- package/lib/flowSettings.d.ts +2 -1
- package/lib/flowSettings.js +12 -8
- package/lib/hooks/useApplyAutoFlows.js +2 -1
- package/lib/index.d.ts +7 -1
- package/lib/index.js +32 -3
- package/lib/locale/en-US.json +4 -2
- package/lib/locale/index.d.ts +4 -0
- package/lib/locale/zh-CN.json +4 -2
- package/lib/models/CollectionFieldModel.d.ts +2 -0
- package/lib/models/CollectionFieldModel.js +43 -3
- package/lib/models/flowModel.d.ts +28 -29
- package/lib/models/flowModel.js +114 -92
- package/lib/models/forkFlowModel.d.ts +4 -4
- package/lib/models/forkFlowModel.js +32 -8
- package/lib/provider.d.ts +3 -1
- package/lib/provider.js +7 -5
- package/lib/resources/multiRecordResource.js +2 -0
- package/lib/resources/singleRecordResource.js +1 -0
- package/lib/resources/sqlResource.d.ts +1 -0
- package/lib/resources/sqlResource.js +20 -24
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.d.ts +1 -6
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +27 -20
- package/lib/runjs-context/contexts/JSBlockRunJSContext.d.ts +1 -6
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +46 -33
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.d.ts +1 -2
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.js +14 -15
- package/lib/runjs-context/contexts/{LinkageRunJSContext.d.ts → JSColumnRunJSContext.d.ts} +6 -3
- package/lib/runjs-context/contexts/JSColumnRunJSContext.js +78 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.d.ts +1 -6
- package/lib/runjs-context/contexts/JSFieldRunJSContext.js +28 -24
- package/lib/runjs-context/contexts/JSItemRunJSContext.d.ts +1 -6
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +24 -20
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.d.ts +1 -2
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.js +16 -17
- package/lib/runjs-context/contexts/base.d.ts +9 -0
- package/lib/runjs-context/contexts/base.js +183 -0
- package/lib/runjs-context/helpers.d.ts +5 -2
- package/lib/runjs-context/helpers.js +36 -27
- package/lib/runjs-context/registry.d.ts +7 -4
- package/lib/runjs-context/registry.js +10 -42
- package/lib/runjs-context/setup.d.ts +9 -0
- package/lib/runjs-context/setup.js +82 -0
- package/lib/runjs-context/snippets/global/{copy-record-json.snippet.js → api-request.snippet.js} +25 -10
- package/lib/runjs-context/snippets/global/clipboard-copy-text.snippet.js +61 -0
- package/lib/runjs-context/snippets/global/{view-navigation-push.snippet.js → import-esm.snippet.js} +26 -12
- package/lib/runjs-context/snippets/global/message-error.snippet.js +6 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.js +6 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.d.ts +3 -8
- package/lib/runjs-context/snippets/global/notification-open.snippet.js +8 -1
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.js +10 -3
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.js +10 -3
- package/lib/runjs-context/snippets/global/query-selector.snippet.js +53 -0
- package/lib/runjs-context/snippets/global/require-amd.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/{requireAsync.snippet.js → require-amd.snippet.js} +16 -13
- package/lib/runjs-context/snippets/global/window-open.snippet.d.ts +3 -8
- package/lib/runjs-context/snippets/global/window-open.snippet.js +8 -1
- package/lib/runjs-context/snippets/index.d.ts +14 -3
- package/lib/runjs-context/snippets/index.js +161 -40
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{jsblock → block}/add-event-listener.snippet.js +11 -2
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +99 -0
- package/lib/runjs-context/snippets/{libs → scene/block}/echarts-init.snippet.js +24 -7
- package/lib/runjs-context/snippets/scene/block/render-button-handler.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{jsblock → block}/render-button-handler.snippet.js +17 -9
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +57 -0
- package/lib/runjs-context/snippets/scene/block/render-info-card.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-info-card.snippet.js +71 -0
- package/lib/runjs-context/snippets/scene/block/render-react-jsx.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{jsblock/render-card.snippet.js → block/render-react-jsx.snippet.js} +26 -13
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{jsblock → block}/render-react.snippet.js +18 -17
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +95 -0
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +84 -0
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +283 -0
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +124 -0
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{jsfield → detail}/color-by-value.snippet.js +13 -3
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/{global → scene/detail}/copy-to-clipboard.snippet.js +28 -6
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{jsfield → detail}/format-number.snippet.js +13 -3
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{jsfield → detail}/innerHTML-value.snippet.js +13 -3
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +82 -0
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +80 -0
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +74 -0
- package/lib/runjs-context/snippets/scene/form/calculate-total.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/calculate-total.snippet.js +63 -0
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +81 -0
- package/lib/runjs-context/snippets/scene/form/conditional-required.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/conditional-required.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/form/copy-field-values.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/copy-field-values.snippet.js +74 -0
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{jsitem → form}/render-basic.snippet.js +11 -2
- package/lib/runjs-context/snippets/scene/form/set-disabled.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{linkage → form}/set-disabled.snippet.js +12 -3
- package/lib/runjs-context/snippets/scene/form/set-field-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{linkage → form}/set-field-value.snippet.js +12 -3
- package/lib/runjs-context/snippets/scene/form/set-required.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{linkage → form}/set-required.snippet.js +12 -3
- package/lib/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.js +67 -0
- package/lib/runjs-context/snippets/scene/form/toggle-visible.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{linkage → form}/toggle-visible.snippet.js +12 -3
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/table/collection-selected-count.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{actions → table}/collection-selected-count.snippet.js +11 -2
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +79 -0
- package/lib/runjs-context/snippets/scene/table/destroy-selected.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/{global/log-json-record.snippet.js → scene/table/destroy-selected.snippet.js} +24 -11
- package/lib/runjs-context/snippets/scene/table/export-selected-json.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/export-selected-json.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/table/iterate-selected-rows.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/{actions → table}/iterate-selected-rows.snippet.js +11 -2
- package/lib/runjs-context/snippets/types.d.ts +9 -1
- package/lib/types.d.ts +28 -3
- package/lib/types.js +4 -3
- package/lib/utils/buildSettingsViewInputArgs.d.ts +19 -0
- package/lib/utils/buildSettingsViewInputArgs.js +75 -0
- package/lib/utils/createEphemeralContext.d.ts +13 -0
- package/lib/utils/createEphemeralContext.js +140 -0
- package/lib/utils/index.d.ts +3 -2
- package/lib/utils/index.js +5 -2
- package/lib/utils/jsxTransform.d.ts +15 -0
- package/lib/utils/jsxTransform.js +68 -0
- package/lib/utils/params-resolvers.js +3 -3
- package/lib/utils/safeGlobals.d.ts +5 -3
- package/lib/utils/safeGlobals.js +40 -0
- package/lib/utils/schema-utils.js +2 -2
- package/lib/utils/serverContextParams.d.ts +1 -0
- package/lib/utils/variablesParams.d.ts +9 -5
- package/lib/utils/variablesParams.js +47 -36
- package/lib/views/PageComponent.js +2 -1
- package/lib/views/createViewMeta.d.ts +29 -1
- package/lib/views/createViewMeta.js +338 -72
- package/lib/views/index.d.ts +1 -0
- package/lib/views/index.js +3 -0
- package/lib/views/useDialog.d.ts +8 -8
- package/lib/views/useDialog.js +8 -7
- package/lib/views/useDrawer.d.ts +8 -8
- package/lib/views/useDrawer.js +40 -26
- package/lib/views/usePage.d.ts +8 -8
- package/lib/views/usePage.js +8 -7
- package/package.json +5 -3
- package/src/BlockScopedFlowEngine.ts +86 -0
- package/src/FlowContextProvider.tsx +4 -2
- package/src/JSRunner.ts +3 -0
- package/src/ViewScopedFlowEngine.ts +1 -1
- package/src/__tests__/JSRunner.test.ts +62 -53
- package/src/__tests__/blockScopedFlowEngine.test.ts +154 -0
- package/src/__tests__/createViewMeta.popup.test.ts +132 -0
- package/src/__tests__/flow-engine.test.ts +3 -0
- package/src/__tests__/flowContextCreateJSRunner.test.ts +163 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +4 -0
- package/src/__tests__/flowRunJSContextDefine.test.ts +508 -0
- package/src/__tests__/globalFlowRegistry.test.ts +1 -1
- package/src/__tests__/runjsContext.test.ts +216 -35
- package/src/__tests__/runjsContextImplementations.test.ts +217 -0
- package/src/__tests__/runjsContextRuntime.test.ts +269 -0
- package/src/__tests__/runjsEdgeCases.test.ts +281 -0
- package/src/__tests__/runjsLocales.test.ts +36 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +449 -0
- package/src/__tests__/runjsSnippets.test.ts +140 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
- package/src/components/DynamicFlowsEditor.tsx +3 -4
- package/src/components/FieldModelRenderer.tsx +16 -5
- package/src/components/FieldSkeleton.tsx +27 -0
- package/src/components/FlowContextSelector.tsx +6 -2
- package/src/components/FlowModelRenderer.tsx +30 -78
- package/src/components/FormItem.tsx +8 -1
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +5 -5
- package/src/components/__tests__/gridDragPlanner.test.ts +494 -0
- package/src/components/dnd/README.md +149 -0
- package/src/components/dnd/findModelUidPosition.ts +26 -0
- package/src/components/dnd/gridDragPlanner.ts +659 -0
- package/src/components/dnd/index.tsx +3 -3
- package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +1 -1
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +17 -4
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +1 -1
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +14 -1
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +424 -0
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +5 -7
- package/src/components/variables/VariableInput.tsx +22 -2
- package/src/components/variables/VariableTag.tsx +54 -2
- package/src/components/variables/types.ts +2 -0
- package/src/data-source/__tests__/sortCollectionsByInherits.test.ts +125 -0
- package/src/data-source/index.ts +17 -11
- package/src/data-source/sortCollectionsByInherits.ts +61 -0
- package/src/executor/FlowExecutor.ts +178 -121
- package/src/executor/__tests__/ctx-defs-injection.test.ts +197 -0
- package/src/executor/__tests__/flowExecutor.test.ts +151 -5
- package/src/flowContext.ts +266 -97
- package/src/flowEngine.ts +21 -6
- package/src/flowSettings.ts +9 -4
- package/src/hooks/useApplyAutoFlows.ts +3 -1
- package/src/index.ts +12 -1
- package/src/locale/en-US.json +4 -2
- package/src/locale/zh-CN.json +4 -2
- package/src/models/CollectionFieldModel.tsx +43 -4
- package/src/models/__tests__/flowModel.getFlows.sort.test.ts +4 -4
- package/src/models/__tests__/flowModel.test.ts +234 -111
- package/src/models/__tests__/forkFlowModel.test.ts +22 -7
- package/src/models/flowModel.tsx +149 -125
- package/src/models/forkFlowModel.ts +41 -8
- package/src/provider.tsx +10 -7
- package/src/resources/multiRecordResource.ts +2 -0
- package/src/resources/singleRecordResource.ts +1 -0
- package/src/resources/sqlResource.ts +20 -25
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +28 -21
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +46 -34
- package/src/runjs-context/contexts/JSCollectionActionRunJSContext.ts +15 -16
- package/src/runjs-context/contexts/JSColumnRunJSContext.ts +58 -0
- package/src/runjs-context/contexts/JSFieldRunJSContext.ts +30 -25
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +25 -21
- package/src/runjs-context/contexts/JSRecordActionRunJSContext.ts +17 -18
- package/src/runjs-context/contexts/base.ts +171 -0
- package/src/runjs-context/helpers.ts +32 -30
- package/src/runjs-context/registry.ts +16 -47
- package/src/runjs-context/setup.ts +51 -0
- package/src/runjs-context/snippets/global/api-request.snippet.ts +38 -0
- package/src/runjs-context/snippets/global/clipboard-copy-text.snippet.ts +42 -0
- package/src/runjs-context/snippets/global/import-esm.snippet.ts +39 -0
- package/src/runjs-context/snippets/global/message-error.snippet.ts +6 -0
- package/src/runjs-context/snippets/global/message-success.snippet.ts +6 -0
- package/src/runjs-context/snippets/global/notification-open.snippet.ts +11 -1
- package/src/runjs-context/snippets/global/open-view-dialog.snippet.ts +10 -3
- package/src/runjs-context/snippets/global/open-view-drawer.snippet.ts +10 -3
- package/src/runjs-context/snippets/global/query-selector.snippet.ts +34 -0
- package/src/runjs-context/snippets/global/require-amd.snippet.ts +30 -0
- package/src/runjs-context/snippets/global/window-open.snippet.ts +11 -1
- package/src/runjs-context/snippets/index.ts +177 -39
- package/src/runjs-context/snippets/scene/{jsblock → block}/add-event-listener.snippet.ts +14 -2
- package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +80 -0
- package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +44 -0
- package/src/runjs-context/snippets/scene/block/render-button-handler.snippet.ts +35 -0
- package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/block/render-info-card.snippet.ts +52 -0
- package/src/runjs-context/snippets/scene/block/render-react-jsx.snippet.ts +39 -0
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +76 -0
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +65 -0
- package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +46 -0
- package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +264 -0
- package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +105 -0
- package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +33 -0
- package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +32 -0
- package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +31 -0
- package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +63 -0
- package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +61 -0
- package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +55 -0
- package/src/runjs-context/snippets/scene/form/calculate-total.snippet.ts +44 -0
- package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +62 -0
- package/src/runjs-context/snippets/scene/form/conditional-required.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/form/copy-field-values.snippet.ts +55 -0
- package/src/runjs-context/snippets/scene/{jsitem → form}/render-basic.snippet.ts +14 -2
- package/src/runjs-context/snippets/scene/{linkage → form}/set-disabled.snippet.ts +15 -3
- package/src/runjs-context/snippets/scene/{linkage → form}/set-field-value.snippet.ts +15 -3
- package/src/runjs-context/snippets/scene/{linkage → form}/set-required.snippet.ts +15 -3
- package/src/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.ts +48 -0
- package/src/runjs-context/snippets/scene/{linkage → form}/toggle-visible.snippet.ts +15 -3
- package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/{actions → table}/collection-selected-count.snippet.ts +14 -2
- package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +60 -0
- package/src/runjs-context/snippets/scene/table/destroy-selected.snippet.ts +36 -0
- package/src/runjs-context/snippets/scene/table/export-selected-json.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/{actions → table}/iterate-selected-rows.snippet.ts +14 -2
- package/src/runjs-context/snippets/types.ts +5 -1
- package/src/types.ts +34 -0
- package/src/utils/__tests__/jsxTransform.test.ts +38 -0
- package/src/utils/__tests__/safeGlobals.test.ts +22 -1
- package/src/utils/buildSettingsViewInputArgs.ts +72 -0
- package/src/utils/createEphemeralContext.ts +142 -0
- package/src/utils/index.ts +2 -2
- package/src/utils/jsxTransform.ts +39 -0
- package/src/utils/params-resolvers.ts +2 -2
- package/src/utils/safeGlobals.ts +49 -3
- package/src/utils/schema-utils.ts +1 -1
- package/src/utils/serverContextParams.ts +1 -0
- package/src/utils/variablesParams.ts +50 -38
- package/src/views/PageComponent.tsx +1 -1
- package/src/views/createViewMeta.ts +393 -70
- package/src/views/index.tsx +1 -0
- package/src/views/useDialog.tsx +12 -10
- package/src/views/useDrawer.tsx +60 -36
- package/src/views/usePage.tsx +13 -10
- package/lib/components/dnd/getMousePositionOnElement.d.ts +0 -50
- package/lib/components/dnd/getMousePositionOnElement.js +0 -95
- package/lib/components/dnd/moveBlock.d.ts +0 -33
- package/lib/components/dnd/moveBlock.js +0 -302
- package/lib/runjs-context/contexts/FlowRunJSContext.d.ts +0 -38
- package/lib/runjs-context/contexts/FlowRunJSContext.js +0 -217
- package/lib/runjs-context/contexts/LinkageRunJSContext.js +0 -62
- package/lib/runjs-context/index.d.ts +0 -19
- package/lib/runjs-context/index.js +0 -57
- package/lib/runjs-context/snippets/global/api-request-get.snippet.d.ts +0 -16
- package/lib/runjs-context/snippets/global/api-request-get.snippet.js +0 -42
- package/lib/runjs-context/snippets/global/api-request-post.snippet.d.ts +0 -16
- package/lib/runjs-context/snippets/global/api-request-post.snippet.js +0 -42
- package/lib/runjs-context/snippets/global/console-log-ctx.snippet.d.ts +0 -16
- package/lib/runjs-context/snippets/global/console-log-ctx.snippet.js +0 -41
- package/lib/runjs-context/snippets/global/sleep.snippet.d.ts +0 -16
- package/lib/runjs-context/snippets/global/sleep.snippet.js +0 -43
- package/lib/runjs-context/snippets/global/try-catch-async.snippet.d.ts +0 -16
- package/lib/runjs-context/snippets/global/try-catch-async.snippet.js +0 -44
- package/lib/runjs-context/snippets/libs/echarts-init.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.js +0 -43
- package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.js +0 -40
- package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.js +0 -42
- package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.js +0 -41
- package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.js +0 -41
- package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.d.ts +0 -15
- package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.d.ts +0 -15
- package/src/components/dnd/getMousePositionOnElement.ts +0 -115
- package/src/components/dnd/moveBlock.ts +0 -379
- package/src/runjs-context/contexts/FlowRunJSContext.ts +0 -190
- package/src/runjs-context/contexts/LinkageRunJSContext.ts +0 -35
- package/src/runjs-context/index.ts +0 -20
- package/src/runjs-context/snippets/global/api-request-get.snippet.ts +0 -20
- package/src/runjs-context/snippets/global/api-request-post.snippet.ts +0 -20
- package/src/runjs-context/snippets/global/console-log-ctx.snippet.ts +0 -19
- package/src/runjs-context/snippets/global/copy-record-json.snippet.ts +0 -21
- package/src/runjs-context/snippets/global/copy-to-clipboard.snippet.ts +0 -21
- package/src/runjs-context/snippets/global/log-json-record.snippet.ts +0 -21
- package/src/runjs-context/snippets/global/requireAsync.snippet.ts +0 -24
- package/src/runjs-context/snippets/global/sleep.snippet.ts +0 -21
- package/src/runjs-context/snippets/global/try-catch-async.snippet.ts +0 -22
- package/src/runjs-context/snippets/global/view-navigation-push.snippet.ts +0 -23
- package/src/runjs-context/snippets/libs/echarts-init.snippet.ts +0 -24
- package/src/runjs-context/snippets/scene/actions/record-id-message.snippet.ts +0 -21
- package/src/runjs-context/snippets/scene/actions/run-action-basic.snippet.ts +0 -18
- package/src/runjs-context/snippets/scene/jsblock/append-style.snippet.ts +0 -20
- package/src/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.ts +0 -24
- package/src/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.ts +0 -19
- package/src/runjs-context/snippets/scene/jsblock/render-basic.snippet.ts +0 -24
- package/src/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.ts +0 -24
- package/src/runjs-context/snippets/scene/jsblock/render-card.snippet.ts +0 -30
- package/src/runjs-context/snippets/scene/jsblock/render-react.snippet.ts +0 -34
- package/src/runjs-context/snippets/scene/jsfield/color-by-value.snippet.ts +0 -20
- package/src/runjs-context/snippets/scene/jsfield/format-number.snippet.ts +0 -19
- package/src/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.ts +0 -18
- /package/lib/runjs-context/snippets/global/{copy-record-json.snippet.d.ts → api-request.snippet.d.ts} +0 -0
- /package/lib/runjs-context/snippets/global/{copy-to-clipboard.snippet.d.ts → clipboard-copy-text.snippet.d.ts} +0 -0
- /package/lib/runjs-context/snippets/global/{log-json-record.snippet.d.ts → import-esm.snippet.d.ts} +0 -0
- /package/lib/runjs-context/snippets/global/{view-navigation-push.snippet.d.ts → query-selector.snippet.d.ts} +0 -0
- /package/lib/runjs-context/snippets/scene/{jsblock/render-card.snippet.d.ts → block/echarts-init.snippet.d.ts} +0 -0
|
@@ -11,6 +11,7 @@ import { observable } from '@formily/reactive';
|
|
|
11
11
|
import _ from 'lodash';
|
|
12
12
|
import { FlowContext, FlowEngineContext } from '../flowContext';
|
|
13
13
|
import { BaseRecordResource } from './baseRecordResource';
|
|
14
|
+
import { parseLiquidContext, transformSQL } from '@nocobase/utils/client';
|
|
14
15
|
|
|
15
16
|
type SQLRunOptions = {
|
|
16
17
|
bind?: Record<string, any>;
|
|
@@ -25,20 +26,6 @@ type SQLSaveOptions = {
|
|
|
25
26
|
dataSourceKey?: string;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
function transformSQL(template: string) {
|
|
29
|
-
let index = 1;
|
|
30
|
-
const bind = {};
|
|
31
|
-
|
|
32
|
-
const sql = template.replace(/{{\s*([^}]+)\s*}}/g, (_, expr) => {
|
|
33
|
-
const key = `__var${index}`;
|
|
34
|
-
bind[key] = `{{${expr.trim()}}}`;
|
|
35
|
-
index++;
|
|
36
|
-
return `$${key}`;
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return { sql, bind };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
29
|
export class FlowSQLRepository {
|
|
43
30
|
protected ctx: FlowEngineContext;
|
|
44
31
|
|
|
@@ -56,16 +43,17 @@ export class FlowSQLRepository {
|
|
|
56
43
|
}
|
|
57
44
|
|
|
58
45
|
async run(sql: string, options: SQLRunOptions = {}) {
|
|
59
|
-
const
|
|
60
|
-
const
|
|
46
|
+
const { sql: transformedSQL, bind, liquidContext } = await transformSQL(sql);
|
|
47
|
+
const resolved = await this.ctx.resolveJsonTemplate({ bind, liquidContext });
|
|
48
|
+
const parsedSQL = await parseLiquidContext(transformedSQL, resolved.liquidContext);
|
|
61
49
|
const { data } = await this.ctx.api.request({
|
|
62
50
|
method: 'POST',
|
|
63
51
|
url: 'flowSql:run',
|
|
64
52
|
data: {
|
|
65
|
-
sql:
|
|
53
|
+
sql: parsedSQL,
|
|
66
54
|
...options,
|
|
67
55
|
bind: {
|
|
68
|
-
...bind,
|
|
56
|
+
...resolved.bind,
|
|
69
57
|
...options.bind,
|
|
70
58
|
},
|
|
71
59
|
},
|
|
@@ -91,7 +79,7 @@ export class FlowSQLRepository {
|
|
|
91
79
|
uid,
|
|
92
80
|
},
|
|
93
81
|
});
|
|
94
|
-
const bind = await this.ctx.resolveJsonTemplate(response.data.data || {});
|
|
82
|
+
const { bind, liquidContext } = await this.ctx.resolveJsonTemplate(response.data.data || {});
|
|
95
83
|
const { data } = await this.ctx.api.request({
|
|
96
84
|
method: 'POST',
|
|
97
85
|
url: 'flowSql:runById',
|
|
@@ -100,8 +88,9 @@ export class FlowSQLRepository {
|
|
|
100
88
|
...options,
|
|
101
89
|
bind: {
|
|
102
90
|
...bind,
|
|
103
|
-
...options
|
|
91
|
+
...options?.bind,
|
|
104
92
|
},
|
|
93
|
+
liquidContext,
|
|
105
94
|
},
|
|
106
95
|
});
|
|
107
96
|
return data?.data;
|
|
@@ -233,20 +222,25 @@ export class SQLResource<TData = any> extends BaseRecordResource<TData> {
|
|
|
233
222
|
return this;
|
|
234
223
|
}
|
|
235
224
|
|
|
225
|
+
setLiquidContext(liquidContext: Record<string, any>) {
|
|
226
|
+
this.request.data.liquidContext = liquidContext;
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
|
|
236
230
|
async run() {
|
|
237
231
|
return this._debugEnabled ? await this.runBySQL() : await this.runById();
|
|
238
232
|
}
|
|
239
233
|
|
|
240
234
|
async runBySQL() {
|
|
241
235
|
const sql = this._sql;
|
|
242
|
-
const
|
|
243
|
-
const
|
|
236
|
+
const { sql: transformedSQL, bind, liquidContext } = await transformSQL(sql);
|
|
237
|
+
const resolved = await this.context.resolveJsonTemplate({ bind, liquidContext });
|
|
244
238
|
const options = _.cloneDeep({
|
|
245
239
|
method: 'post',
|
|
246
240
|
...this.getRefreshRequestOptions(),
|
|
247
241
|
});
|
|
248
|
-
options.data.
|
|
249
|
-
options.data.
|
|
242
|
+
options.data.sql = await parseLiquidContext(transformedSQL, resolved.liquidContext);
|
|
243
|
+
options.data.bind = resolved.bind;
|
|
250
244
|
return await this.runAction<TData, any>('run', options);
|
|
251
245
|
}
|
|
252
246
|
|
|
@@ -257,8 +251,9 @@ export class SQLResource<TData = any> extends BaseRecordResource<TData> {
|
|
|
257
251
|
uid: this.request.data.uid,
|
|
258
252
|
},
|
|
259
253
|
});
|
|
260
|
-
const bind = await this.context.resolveJsonTemplate(data);
|
|
254
|
+
const { bind, liquidContext } = await this.context.resolveJsonTemplate(data);
|
|
261
255
|
this.setBind(bind);
|
|
256
|
+
this.setLiquidContext(liquidContext);
|
|
262
257
|
return await this.runAction<TData, any>('runById', {
|
|
263
258
|
method: 'post',
|
|
264
259
|
...this.getRefreshRequestOptions(),
|
|
@@ -7,33 +7,40 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { FlowRunJSContext } from '
|
|
11
|
-
import { createSafeDocument, createSafeWindow } from '../../utils';
|
|
10
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
12
11
|
|
|
13
|
-
export class FormJSFieldItemRunJSContext extends FlowRunJSContext {
|
|
14
|
-
static injectDefaultGlobals() {
|
|
15
|
-
return { window: createSafeWindow(), document: createSafeDocument() };
|
|
16
|
-
}
|
|
17
|
-
constructor(delegate: any) {
|
|
18
|
-
super(delegate);
|
|
19
|
-
this.defineProperty('element', { get: () => (this as any)._delegate['element'] });
|
|
20
|
-
this.defineProperty('record', { get: () => (this as any)._delegate['record'] });
|
|
21
|
-
this.defineProperty('value', { get: () => (this as any)._delegate['value'] });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
12
|
+
export class FormJSFieldItemRunJSContext extends FlowRunJSContext {}
|
|
24
13
|
|
|
25
14
|
FormJSFieldItemRunJSContext.define({
|
|
26
15
|
label: 'FormJSFieldItem RunJS context',
|
|
27
16
|
properties: {
|
|
28
|
-
element:
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
element: `ElementProxy instance providing a safe DOM container for form field rendering.
|
|
18
|
+
Supports innerHTML, append, and other DOM manipulation methods.`,
|
|
19
|
+
value: `Current field value (read-only in display mode; in controlled scenarios, use setProps to modify).`,
|
|
20
|
+
record: `Current record data object (read-only).
|
|
21
|
+
Contains all field values of the parent record.`,
|
|
31
22
|
},
|
|
32
23
|
methods: {
|
|
33
|
-
onRefReady:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
onRefReady: `Wait for form field container DOM element to be ready before executing callback.
|
|
25
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,
|
|
26
|
+
setProps: `Set form field properties programmatically.
|
|
27
|
+
Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
|
|
28
|
+
Example: ctx.setProps(fieldModel, { value: "new value" })`,
|
|
38
29
|
},
|
|
39
30
|
});
|
|
31
|
+
|
|
32
|
+
FormJSFieldItemRunJSContext.define(
|
|
33
|
+
{
|
|
34
|
+
label: '表单 JS 字段项 RunJS 上下文',
|
|
35
|
+
properties: {
|
|
36
|
+
element: 'ElementProxy,表单字段容器',
|
|
37
|
+
value: '字段值(展示模式为只读;受控场景用 setProps 修改)',
|
|
38
|
+
record: '当前记录(只读)',
|
|
39
|
+
},
|
|
40
|
+
methods: {
|
|
41
|
+
onRefReady: '容器就绪回调',
|
|
42
|
+
setProps: '设置表单项属性:`setProps(fieldModel, { value })`(由联动/表单上下文提供)',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{ locale: 'zh-CN' },
|
|
46
|
+
);
|
|
@@ -7,46 +7,58 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { FlowRunJSContext } from '
|
|
11
|
-
import { createSafeDocument, createSafeWindow } from '../../utils';
|
|
10
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
12
11
|
|
|
13
|
-
export class JSBlockRunJSContext extends FlowRunJSContext {
|
|
14
|
-
static injectDefaultGlobals() {
|
|
15
|
-
return { window: createSafeWindow(), document: createSafeDocument() };
|
|
16
|
-
}
|
|
17
|
-
constructor(delegate: any) {
|
|
18
|
-
super(delegate);
|
|
19
|
-
// 显式暴露本场景所需属性
|
|
20
|
-
this.defineProperty('element', { get: () => (this as any)._delegate['element'] });
|
|
21
|
-
this.defineProperty('record', { get: () => (this as any)._delegate['record'] });
|
|
22
|
-
this.defineProperty('value', { get: () => (this as any)._delegate['value'] });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
12
|
+
export class JSBlockRunJSContext extends FlowRunJSContext {}
|
|
25
13
|
|
|
26
14
|
JSBlockRunJSContext.define({
|
|
27
|
-
label: '
|
|
15
|
+
label: 'RunJS context',
|
|
28
16
|
properties: {
|
|
29
|
-
element:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
element: {
|
|
18
|
+
description: `ElementProxy instance providing a safe DOM container.
|
|
19
|
+
Supports innerHTML, append, and other DOM manipulation methods.
|
|
20
|
+
Use this to render content in the JS block.`,
|
|
21
|
+
detail: 'ElementProxy',
|
|
22
|
+
properties: {
|
|
23
|
+
innerHTML: 'Set or read the HTML content of the container element.',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
record: `Current record data object (read-only).
|
|
27
|
+
Available when the JS block is within a data block or detail view context.`,
|
|
28
|
+
value: 'Current value of the field or component, if available in the current context.',
|
|
29
|
+
React: 'React library',
|
|
30
|
+
antd: 'Ant Design library',
|
|
34
31
|
},
|
|
35
32
|
methods: {
|
|
36
|
-
onRefReady:
|
|
33
|
+
onRefReady: `Wait for container DOM element to be ready before executing callback.
|
|
34
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
|
|
35
|
+
Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,
|
|
37
36
|
requireAsync: 'Load external library: `const lib = await ctx.requireAsync(url)`',
|
|
38
|
-
|
|
39
|
-
snipastes: {
|
|
40
|
-
'Render HTML': { $ref: 'scene/jsblock/render-basic', prefix: 'sn-jsb-html' },
|
|
41
|
-
'Render React': { $ref: 'scene/jsblock/render-react', prefix: 'sn-jsb-react' },
|
|
42
|
-
'Init ECharts': { $ref: 'libs/echarts-init', prefix: 'sn-echarts' },
|
|
43
|
-
'Render card': { $ref: 'scene/jsblock/render-card', prefix: 'sn-jsb-card' },
|
|
44
|
-
'Button handler': { $ref: 'scene/jsblock/render-button-handler', prefix: 'sn-jsb-button' },
|
|
45
|
-
'JSX mount': { $ref: 'scene/jsblock/jsx-mount', prefix: 'sn-jsx-mount' },
|
|
46
|
-
'JSX unmount': { $ref: 'scene/jsblock/jsx-unmount', prefix: 'sn-jsx-unmount' },
|
|
47
|
-
Notification: { $ref: 'global/notification-open', prefix: 'sn-notify' },
|
|
48
|
-
'Window open': { $ref: 'global/window-open', prefix: 'sn-window-open' },
|
|
49
|
-
'Add click listener': { $ref: 'scene/jsblock/add-event-listener', prefix: 'sn-jsb-click' },
|
|
50
|
-
'Append style': { $ref: 'scene/jsblock/append-style', prefix: 'sn-jsb-style' },
|
|
37
|
+
importAsync: 'Dynamically import ESM module: `const mod = await ctx.importAsync(url)`',
|
|
51
38
|
},
|
|
52
39
|
});
|
|
40
|
+
|
|
41
|
+
JSBlockRunJSContext.define(
|
|
42
|
+
{
|
|
43
|
+
label: 'RunJS 上下文',
|
|
44
|
+
properties: {
|
|
45
|
+
element: {
|
|
46
|
+
description: 'ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等',
|
|
47
|
+
detail: 'ElementProxy',
|
|
48
|
+
properties: {
|
|
49
|
+
innerHTML: '读取或设置容器的 HTML 内容',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
record: '当前记录(只读,用于数据区块/详情等场景)',
|
|
53
|
+
value: '当前值(若存在)',
|
|
54
|
+
React: 'React 库',
|
|
55
|
+
antd: 'Ant Design 库',
|
|
56
|
+
},
|
|
57
|
+
methods: {
|
|
58
|
+
onRefReady: '容器 ref 就绪回调:\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```',
|
|
59
|
+
requireAsync: '加载外部库:`const lib = await ctx.requireAsync(url)`',
|
|
60
|
+
importAsync: '按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{ locale: 'zh-CN' },
|
|
64
|
+
);
|
|
@@ -7,26 +7,25 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { FlowRunJSContext } from '
|
|
10
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
11
|
|
|
12
|
-
export class JSCollectionActionRunJSContext extends FlowRunJSContext {
|
|
13
|
-
constructor(delegate: any) {
|
|
14
|
-
super(delegate);
|
|
15
|
-
this.defineProperty('resource', { get: () => (this as any)._delegate['resource'] });
|
|
16
|
-
}
|
|
17
|
-
}
|
|
12
|
+
export class JSCollectionActionRunJSContext extends FlowRunJSContext {}
|
|
18
13
|
|
|
19
14
|
JSCollectionActionRunJSContext.define({
|
|
20
15
|
label: 'JSCollectionAction RunJS context',
|
|
21
16
|
properties: {
|
|
22
|
-
resource:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
runAction: 'Run action',
|
|
26
|
-
message: 'Message API',
|
|
27
|
-
},
|
|
28
|
-
snipastes: {
|
|
29
|
-
'Selected count': { $ref: 'scene/actions/collection-selected-count', prefix: 'sn-act-selected-count' },
|
|
30
|
-
'Iterate selected rows': { $ref: 'scene/actions/iterate-selected-rows', prefix: 'sn-act-iterate' },
|
|
17
|
+
resource: `Collection resource instance providing access to selected rows, pagination, and data operations.
|
|
18
|
+
Use ctx.resource.selectedRows to get selected records.
|
|
19
|
+
Use ctx.resource.pagination for page info.`,
|
|
31
20
|
},
|
|
32
21
|
});
|
|
22
|
+
|
|
23
|
+
JSCollectionActionRunJSContext.define(
|
|
24
|
+
{
|
|
25
|
+
label: 'JS 集合动作 RunJS 上下文',
|
|
26
|
+
properties: {
|
|
27
|
+
resource: '列表资源(包含选中行/分页信息等)',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{ locale: 'zh-CN' },
|
|
31
|
+
);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* RunJS context for JSColumnModel (table custom column).
|
|
14
|
+
* Focused on per-row rendering with access to current record and cell element.
|
|
15
|
+
*/
|
|
16
|
+
export class JSColumnRunJSContext extends FlowRunJSContext {}
|
|
17
|
+
|
|
18
|
+
JSColumnRunJSContext.define({
|
|
19
|
+
label: 'JSColumn RunJS context',
|
|
20
|
+
properties: {
|
|
21
|
+
element:
|
|
22
|
+
'ElementProxy instance providing a safe DOM container for the current table cell. Supports innerHTML/append and basic DOM APIs.',
|
|
23
|
+
record: 'Current row record object (read-only).',
|
|
24
|
+
recordIndex: 'Index of the current row in the page (0-based).',
|
|
25
|
+
collection: 'Collection definition metadata (read-only).',
|
|
26
|
+
viewer:
|
|
27
|
+
'View controller providing dialog/drawer/embed helpers for interactions initiated from the cell (e.g., open details).',
|
|
28
|
+
React: 'React library',
|
|
29
|
+
antd: 'Ant Design library',
|
|
30
|
+
},
|
|
31
|
+
methods: {
|
|
32
|
+
onRefReady:
|
|
33
|
+
'Wait for cell DOM element to be ready before executing callback. Parameters: (ref, callback, timeout?) => void',
|
|
34
|
+
requireAsync: 'Load external library by URL: `const lib = await ctx.requireAsync(url)`',
|
|
35
|
+
importAsync: 'Dynamically import ESM module by URL: `const mod = await ctx.importAsync(url)`',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
JSColumnRunJSContext.define(
|
|
40
|
+
{
|
|
41
|
+
label: 'JS 列 RunJS 上下文',
|
|
42
|
+
properties: {
|
|
43
|
+
element: 'ElementProxy,表格单元格的安全 DOM 容器,支持 innerHTML/append 等',
|
|
44
|
+
record: '当前行记录对象(只读)',
|
|
45
|
+
recordIndex: '当前行索引(从 0 开始)',
|
|
46
|
+
collection: '集合定义元数据(只读)',
|
|
47
|
+
viewer: '视图控制器,可用于在单元格中触发抽屉/对话框/内嵌等交互',
|
|
48
|
+
React: 'React 库',
|
|
49
|
+
antd: 'Ant Design 库',
|
|
50
|
+
},
|
|
51
|
+
methods: {
|
|
52
|
+
onRefReady: '等待单元格 DOM 就绪后执行回调。参数:(ref, callback, timeout?)',
|
|
53
|
+
requireAsync: '按 URL 异步加载外部库:`const lib = await ctx.requireAsync(url)`',
|
|
54
|
+
importAsync: '按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{ locale: 'zh-CN' },
|
|
58
|
+
);
|
|
@@ -7,37 +7,42 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { FlowRunJSContext } from '
|
|
11
|
-
import { createSafeDocument, createSafeWindow } from '../../utils';
|
|
10
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
12
11
|
|
|
13
|
-
export class JSFieldRunJSContext extends FlowRunJSContext {
|
|
14
|
-
static injectDefaultGlobals() {
|
|
15
|
-
return { window: createSafeWindow(), document: createSafeDocument() };
|
|
16
|
-
}
|
|
17
|
-
constructor(delegate: any) {
|
|
18
|
-
super(delegate);
|
|
19
|
-
this.defineProperty('element', { get: () => (this as any)._delegate['element'] });
|
|
20
|
-
this.defineProperty('value', { get: () => (this as any)._delegate['value'] });
|
|
21
|
-
this.defineProperty('record', { get: () => (this as any)._delegate['record'] });
|
|
22
|
-
this.defineProperty('collection', { get: () => (this as any)._delegate['collection'] });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
12
|
+
export class JSFieldRunJSContext extends FlowRunJSContext {}
|
|
25
13
|
|
|
26
14
|
JSFieldRunJSContext.define({
|
|
27
15
|
label: 'JSField RunJS context',
|
|
28
16
|
properties: {
|
|
29
|
-
element:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
element: `ElementProxy instance providing a safe DOM container for field rendering.
|
|
18
|
+
Supports innerHTML, append, and other DOM manipulation methods.`,
|
|
19
|
+
value: `Current value of the field (read-only).
|
|
20
|
+
Contains the data value stored in this field.`,
|
|
21
|
+
record: `Current record data object (read-only).
|
|
22
|
+
Contains all field values of the parent record.`,
|
|
23
|
+
collection: `Collection definition metadata (read-only).
|
|
24
|
+
Provides schema information about the collection this field belongs to.`,
|
|
33
25
|
},
|
|
34
26
|
methods: {
|
|
35
|
-
onRefReady:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
'Render value': { $ref: 'scene/jsfield/innerHTML-value', prefix: 'sn-jsf-value' },
|
|
39
|
-
'Message success': { $ref: 'global/message-success', prefix: 'sn-msg-ok' },
|
|
40
|
-
'Format number': { $ref: 'scene/jsfield/format-number', prefix: 'sn-jsf-num' },
|
|
41
|
-
'Color by value': { $ref: 'scene/jsfield/color-by-value', prefix: 'sn-jsf-color' },
|
|
27
|
+
onRefReady: `Wait for field container DOM element to be ready before executing callback.
|
|
28
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
|
|
29
|
+
Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = ctx.value })`,
|
|
42
30
|
},
|
|
43
31
|
});
|
|
32
|
+
|
|
33
|
+
JSFieldRunJSContext.define(
|
|
34
|
+
{
|
|
35
|
+
label: 'JS 字段 RunJS 上下文',
|
|
36
|
+
properties: {
|
|
37
|
+
element: 'ElementProxy,字段渲染容器,支持 innerHTML/append 等 DOM 操作',
|
|
38
|
+
value: '字段当前值(只读)',
|
|
39
|
+
record: '当前记录对象(只读,包含父记录全部字段值)',
|
|
40
|
+
collection: '集合定义元数据(只读,描述字段所属集合的 Schema)',
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
onRefReady:
|
|
44
|
+
'在字段容器 DOM 就绪后执行回调。参数:(ref, callback, timeout?);示例:ctx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{ locale: 'zh-CN' },
|
|
48
|
+
);
|
|
@@ -7,33 +7,37 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { FlowRunJSContext } from '
|
|
11
|
-
import { createSafeDocument, createSafeWindow } from '../../utils';
|
|
10
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
12
11
|
|
|
13
|
-
export class JSItemRunJSContext extends FlowRunJSContext {
|
|
14
|
-
static injectDefaultGlobals() {
|
|
15
|
-
return { window: createSafeWindow(), document: createSafeDocument() };
|
|
16
|
-
}
|
|
17
|
-
constructor(delegate: any) {
|
|
18
|
-
super(delegate);
|
|
19
|
-
this.defineProperty('element', { get: () => (this as any)._delegate['element'] });
|
|
20
|
-
this.defineProperty('record', { get: () => (this as any)._delegate['record'] });
|
|
21
|
-
this.defineProperty('resource', { get: () => (this as any)._delegate['resource'] });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
12
|
+
export class JSItemRunJSContext extends FlowRunJSContext {}
|
|
24
13
|
|
|
25
14
|
JSItemRunJSContext.define({
|
|
26
15
|
label: 'JSItem RunJS context',
|
|
27
16
|
properties: {
|
|
28
|
-
element:
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
element: `ElementProxy instance providing a safe DOM container for form item rendering.
|
|
18
|
+
Supports innerHTML, append, and other DOM manipulation methods.`,
|
|
19
|
+
resource: `Current resource instance (read-only).
|
|
20
|
+
Provides access to the data resource associated with the current form context.`,
|
|
21
|
+
record: `Current record data object (read-only).
|
|
22
|
+
Contains all field values of the parent record.`,
|
|
31
23
|
},
|
|
32
24
|
methods: {
|
|
33
|
-
onRefReady:
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
snipastes: {
|
|
37
|
-
'Render form item': { $ref: 'scene/jsitem/render-basic', prefix: 'sn-jsitem-basic' },
|
|
25
|
+
onRefReady: `Wait for form item container DOM element to be ready before executing callback.
|
|
26
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,
|
|
38
27
|
},
|
|
39
28
|
});
|
|
29
|
+
|
|
30
|
+
JSItemRunJSContext.define(
|
|
31
|
+
{
|
|
32
|
+
label: 'JS 表单项 RunJS 上下文',
|
|
33
|
+
properties: {
|
|
34
|
+
element: 'ElementProxy,表单项渲染容器,支持 innerHTML/append 等 DOM 操作',
|
|
35
|
+
resource: '当前资源(只读)',
|
|
36
|
+
record: '当前记录(只读)',
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
onRefReady: '容器就绪后执行回调。参数:(ref, callback, timeout?)',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{ locale: 'zh-CN' },
|
|
43
|
+
);
|
|
@@ -7,28 +7,27 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { FlowRunJSContext } from '
|
|
10
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
11
|
|
|
12
|
-
export class JSRecordActionRunJSContext extends FlowRunJSContext {
|
|
13
|
-
constructor(delegate: any) {
|
|
14
|
-
super(delegate);
|
|
15
|
-
this.defineProperty('record', { get: () => (this as any)._delegate['record'] });
|
|
16
|
-
this.defineProperty('filterByTk', { get: () => (this as any)._delegate['filterByTk'] });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
12
|
+
export class JSRecordActionRunJSContext extends FlowRunJSContext {}
|
|
19
13
|
|
|
20
14
|
JSRecordActionRunJSContext.define({
|
|
21
15
|
label: 'JSRecordAction RunJS context',
|
|
22
16
|
properties: {
|
|
23
|
-
record:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
runAction: 'Run action: `await ctx.runAction(name, params)`',
|
|
28
|
-
message: 'Message API',
|
|
29
|
-
},
|
|
30
|
-
snipastes: {
|
|
31
|
-
'Show record id': { $ref: 'scene/actions/record-id-message', prefix: 'sn-act-record-id' },
|
|
32
|
-
'Run action': { $ref: 'scene/actions/run-action-basic', prefix: 'sn-act-run' },
|
|
17
|
+
record: `Current record data object (read-only).
|
|
18
|
+
Contains all field values of the record associated with this action.`,
|
|
19
|
+
filterByTk: `Primary key or filter key of the current record (read-only).
|
|
20
|
+
Used to identify the specific record in database operations.`,
|
|
33
21
|
},
|
|
34
22
|
});
|
|
23
|
+
|
|
24
|
+
JSRecordActionRunJSContext.define(
|
|
25
|
+
{
|
|
26
|
+
label: 'JS 记录动作 RunJS 上下文',
|
|
27
|
+
properties: {
|
|
28
|
+
record: '当前记录(只读)',
|
|
29
|
+
filterByTk: '主键/过滤键(只读)',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{ locale: 'zh-CN' },
|
|
33
|
+
);
|