@nocobase/flow-engine 2.0.0-alpha.2 → 2.0.0-alpha.20
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 +2 -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/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 +18 -12
- 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 +122 -94
- package/lib/flowContext.d.ts +33 -5
- package/lib/flowContext.js +145 -74
- package/lib/flowEngine.d.ts +8 -1
- package/lib/flowEngine.js +12 -2
- package/lib/flowSettings.d.ts +2 -1
- package/lib/flowSettings.js +7 -3
- package/lib/hooks/useApplyAutoFlows.js +2 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.js +29 -3
- 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 +110 -88
- package/lib/models/forkFlowModel.d.ts +2 -2
- package/lib/models/forkFlowModel.js +29 -6
- 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/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 +169 -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 +160 -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 +12 -6
- 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 +72 -0
- 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 +12 -11
- 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 +100 -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 +85 -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 +15 -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/index.d.ts +3 -2
- package/lib/utils/index.js +5 -2
- package/lib/utils/params-resolvers.js +2 -2
- package/lib/utils/safeGlobals.d.ts +5 -3
- package/lib/utils/safeGlobals.js +40 -0
- 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 +321 -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 +4 -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__/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/wrappers/contextual/StepSettingsDialog.tsx +14 -1
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +1 -0
- 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 +16 -10
- package/src/data-source/sortCollectionsByInherits.ts +61 -0
- package/src/executor/FlowExecutor.ts +160 -114
- package/src/executor/__tests__/flowExecutor.test.ts +151 -5
- package/src/flowContext.ts +196 -93
- package/src/flowEngine.ts +13 -2
- package/src/flowSettings.ts +8 -3
- package/src/hooks/useApplyAutoFlows.ts +3 -1
- package/src/index.ts +11 -1
- 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 +218 -95
- package/src/models/flowModel.tsx +146 -122
- package/src/models/forkFlowModel.ts +37 -5
- package/src/provider.tsx +10 -7
- package/src/resources/multiRecordResource.ts +2 -0
- package/src/resources/singleRecordResource.ts +1 -0
- 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 +155 -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 +176 -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/{jsblock → block}/render-button-handler.snippet.ts +15 -6
- 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 +53 -0
- package/src/runjs-context/snippets/scene/{jsblock → block}/render-react.snippet.ts +15 -11
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +81 -0
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +66 -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 +13 -0
- package/src/utils/__tests__/safeGlobals.test.ts +22 -1
- package/src/utils/buildSettingsViewInputArgs.ts +72 -0
- package/src/utils/index.ts +2 -2
- package/src/utils/params-resolvers.ts +1 -1
- package/src/utils/safeGlobals.ts +49 -3
- 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 +372 -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-card.snippet.js +0 -45
- 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-card.snippet.ts +0 -30
- 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
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
export declare const DEFAULT_GRID_COLUMNS = 24;
|
|
11
|
+
/** 最小 slot 厚度 */
|
|
12
|
+
export declare const MIN_SLOT_THICKNESS = 16;
|
|
13
|
+
/** 最大 slot 厚度 */
|
|
14
|
+
export declare const MAX_SLOT_THICKNESS = 48;
|
|
15
|
+
/** 列边缘最小宽度 */
|
|
16
|
+
export declare const COLUMN_EDGE_MIN_WIDTH = 12;
|
|
17
|
+
/** 列边缘最大宽度 */
|
|
18
|
+
export declare const COLUMN_EDGE_MAX_WIDTH = 28;
|
|
19
|
+
/** 列边缘宽度占列宽的比例(原来是 1/5) */
|
|
20
|
+
export declare const COLUMN_EDGE_WIDTH_RATIO = 0.2;
|
|
21
|
+
export interface Rect {
|
|
22
|
+
top: number;
|
|
23
|
+
left: number;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}
|
|
27
|
+
export interface Point {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}
|
|
31
|
+
export interface GridLayoutData {
|
|
32
|
+
rows: Record<string, string[][]>;
|
|
33
|
+
sizes: Record<string, number[]>;
|
|
34
|
+
}
|
|
35
|
+
export interface ColumnSlot {
|
|
36
|
+
type: 'column';
|
|
37
|
+
rowId: string;
|
|
38
|
+
columnIndex: number;
|
|
39
|
+
insertIndex: number;
|
|
40
|
+
position: 'before' | 'after';
|
|
41
|
+
rect: Rect;
|
|
42
|
+
}
|
|
43
|
+
export interface ColumnEdgeSlot {
|
|
44
|
+
type: 'column-edge';
|
|
45
|
+
rowId: string;
|
|
46
|
+
columnIndex: number;
|
|
47
|
+
direction: 'left' | 'right';
|
|
48
|
+
rect: Rect;
|
|
49
|
+
}
|
|
50
|
+
export interface RowGapSlot {
|
|
51
|
+
type: 'row-gap';
|
|
52
|
+
targetRowId: string;
|
|
53
|
+
position: 'above' | 'below';
|
|
54
|
+
rect: Rect;
|
|
55
|
+
}
|
|
56
|
+
export interface EmptyRowSlot {
|
|
57
|
+
type: 'empty-row';
|
|
58
|
+
rect: Rect;
|
|
59
|
+
}
|
|
60
|
+
export interface EmptyColumnSlot {
|
|
61
|
+
type: 'empty-column';
|
|
62
|
+
rowId: string;
|
|
63
|
+
columnIndex: number;
|
|
64
|
+
rect: Rect;
|
|
65
|
+
}
|
|
66
|
+
export type LayoutSlot = ColumnSlot | ColumnEdgeSlot | RowGapSlot | EmptyRowSlot | EmptyColumnSlot;
|
|
67
|
+
/**
|
|
68
|
+
* 列内插入的配置
|
|
69
|
+
*/
|
|
70
|
+
export interface ColumnInsertConfig {
|
|
71
|
+
/** 高亮区域的高度(像素) */
|
|
72
|
+
height?: number;
|
|
73
|
+
/** 垂直偏移(像素),正数向下,负数向上 */
|
|
74
|
+
offsetTop?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 列边缘的配置
|
|
78
|
+
*/
|
|
79
|
+
export interface ColumnEdgeConfig {
|
|
80
|
+
/** 高亮区域的宽度(像素) */
|
|
81
|
+
width?: number;
|
|
82
|
+
/** 水平偏移(像素),正数向右,负数向左 */
|
|
83
|
+
offsetLeft?: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 行间隙的配置
|
|
87
|
+
*/
|
|
88
|
+
export interface RowGapConfig {
|
|
89
|
+
/** 高亮区域的高度(像素) */
|
|
90
|
+
height?: number;
|
|
91
|
+
/** 垂直偏移(像素),正数向下,负数向上 */
|
|
92
|
+
offsetTop?: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 拖拽高亮区域的全局配置
|
|
96
|
+
*/
|
|
97
|
+
export interface DragOverlayConfig {
|
|
98
|
+
/** 列内插入(before 表示在区块上方插入,after 表示在区块下方插入) */
|
|
99
|
+
columnInsert?: {
|
|
100
|
+
before?: ColumnInsertConfig;
|
|
101
|
+
after?: ColumnInsertConfig;
|
|
102
|
+
};
|
|
103
|
+
/** 列边缘(left 表示在左侧新建列,right 表示在右侧新建列) */
|
|
104
|
+
columnEdge?: {
|
|
105
|
+
left?: ColumnEdgeConfig;
|
|
106
|
+
right?: ColumnEdgeConfig;
|
|
107
|
+
};
|
|
108
|
+
/** 行间隙(above 表示在行上方插入,below 表示在行下方插入) */
|
|
109
|
+
rowGap?: {
|
|
110
|
+
above?: RowGapConfig;
|
|
111
|
+
below?: RowGapConfig;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export interface LayoutSnapshot {
|
|
115
|
+
slots: LayoutSlot[];
|
|
116
|
+
containerRect: Rect;
|
|
117
|
+
}
|
|
118
|
+
export interface BuildLayoutSnapshotOptions {
|
|
119
|
+
container: HTMLElement | null;
|
|
120
|
+
}
|
|
121
|
+
export declare const buildLayoutSnapshot: ({ container }: BuildLayoutSnapshotOptions) => LayoutSnapshot;
|
|
122
|
+
export declare const getSlotKey: (slot: LayoutSlot) => string;
|
|
123
|
+
export declare const resolveDropIntent: (point: Point, slots: LayoutSlot[]) => LayoutSlot | null;
|
|
124
|
+
export interface SimulateLayoutOptions {
|
|
125
|
+
slot: LayoutSlot;
|
|
126
|
+
sourceUid: string;
|
|
127
|
+
layout: GridLayoutData;
|
|
128
|
+
generateRowId?: () => string;
|
|
129
|
+
}
|
|
130
|
+
export declare const simulateLayoutForSlot: ({ slot, sourceUid, layout, generateRowId, }: SimulateLayoutOptions) => GridLayoutData;
|
|
@@ -0,0 +1,497 @@
|
|
|
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
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var gridDragPlanner_exports = {};
|
|
39
|
+
__export(gridDragPlanner_exports, {
|
|
40
|
+
COLUMN_EDGE_MAX_WIDTH: () => COLUMN_EDGE_MAX_WIDTH,
|
|
41
|
+
COLUMN_EDGE_MIN_WIDTH: () => COLUMN_EDGE_MIN_WIDTH,
|
|
42
|
+
COLUMN_EDGE_WIDTH_RATIO: () => COLUMN_EDGE_WIDTH_RATIO,
|
|
43
|
+
DEFAULT_GRID_COLUMNS: () => DEFAULT_GRID_COLUMNS,
|
|
44
|
+
MAX_SLOT_THICKNESS: () => MAX_SLOT_THICKNESS,
|
|
45
|
+
MIN_SLOT_THICKNESS: () => MIN_SLOT_THICKNESS,
|
|
46
|
+
buildLayoutSnapshot: () => buildLayoutSnapshot,
|
|
47
|
+
getSlotKey: () => getSlotKey,
|
|
48
|
+
resolveDropIntent: () => resolveDropIntent,
|
|
49
|
+
simulateLayoutForSlot: () => simulateLayoutForSlot
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(gridDragPlanner_exports);
|
|
52
|
+
var import_shared = require("@formily/shared");
|
|
53
|
+
var import_lodash = __toESM(require("lodash"));
|
|
54
|
+
const DEFAULT_GRID_COLUMNS = 24;
|
|
55
|
+
const MIN_SLOT_THICKNESS = 16;
|
|
56
|
+
const MAX_SLOT_THICKNESS = 48;
|
|
57
|
+
const COLUMN_EDGE_MIN_WIDTH = 12;
|
|
58
|
+
const COLUMN_EDGE_MAX_WIDTH = 28;
|
|
59
|
+
const COLUMN_EDGE_WIDTH_RATIO = 0.2;
|
|
60
|
+
const COLUMN_INSERT_THICKNESS_RATIO = 0.5;
|
|
61
|
+
const ROW_GAP_HEIGHT_RATIO = 0.33;
|
|
62
|
+
const toRect = /* @__PURE__ */ __name((domRect) => ({
|
|
63
|
+
top: domRect.top,
|
|
64
|
+
left: domRect.left,
|
|
65
|
+
width: domRect.width,
|
|
66
|
+
height: domRect.height
|
|
67
|
+
}), "toRect");
|
|
68
|
+
const clampSlotHeight = /* @__PURE__ */ __name((value) => Math.max(MIN_SLOT_THICKNESS, Math.min(MAX_SLOT_THICKNESS, value)), "clampSlotHeight");
|
|
69
|
+
const createRect = /* @__PURE__ */ __name(({ top, left, width, height }) => ({
|
|
70
|
+
top,
|
|
71
|
+
left,
|
|
72
|
+
width,
|
|
73
|
+
height
|
|
74
|
+
}), "createRect");
|
|
75
|
+
const offsetRect = /* @__PURE__ */ __name((rect, offsets) => ({
|
|
76
|
+
top: offsets.top ?? rect.top,
|
|
77
|
+
left: offsets.left ?? rect.left,
|
|
78
|
+
width: offsets.width ?? rect.width,
|
|
79
|
+
height: offsets.height ?? rect.height
|
|
80
|
+
}), "offsetRect");
|
|
81
|
+
const createRowGapRect = /* @__PURE__ */ __name((source, position, containerRect) => {
|
|
82
|
+
const baseHeight = clampSlotHeight(source.height * ROW_GAP_HEIGHT_RATIO);
|
|
83
|
+
if (position === "above") {
|
|
84
|
+
const available2 = source.top - containerRect.top;
|
|
85
|
+
const height2 = clampSlotHeight(Math.max(baseHeight, available2));
|
|
86
|
+
return createRect({
|
|
87
|
+
top: source.top - height2,
|
|
88
|
+
left: containerRect.left,
|
|
89
|
+
width: containerRect.width,
|
|
90
|
+
height: height2
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const available = containerRect.top + containerRect.height - (source.top + source.height);
|
|
94
|
+
const height = clampSlotHeight(Math.max(baseHeight, available));
|
|
95
|
+
return createRect({
|
|
96
|
+
top: source.top + source.height,
|
|
97
|
+
left: containerRect.left,
|
|
98
|
+
width: containerRect.width,
|
|
99
|
+
height
|
|
100
|
+
});
|
|
101
|
+
}, "createRowGapRect");
|
|
102
|
+
const createColumnEdgeRect = /* @__PURE__ */ __name((source, side) => {
|
|
103
|
+
const width = Math.min(
|
|
104
|
+
Math.max(COLUMN_EDGE_MIN_WIDTH, source.width * COLUMN_EDGE_WIDTH_RATIO),
|
|
105
|
+
COLUMN_EDGE_MAX_WIDTH
|
|
106
|
+
);
|
|
107
|
+
return createRect({
|
|
108
|
+
top: source.top,
|
|
109
|
+
left: side === "left" ? source.left : source.left + source.width - width,
|
|
110
|
+
width,
|
|
111
|
+
height: source.height
|
|
112
|
+
});
|
|
113
|
+
}, "createColumnEdgeRect");
|
|
114
|
+
const createColumnInsertRect = /* @__PURE__ */ __name((itemRect, position) => {
|
|
115
|
+
const thickness = clampSlotHeight(itemRect.height * COLUMN_INSERT_THICKNESS_RATIO);
|
|
116
|
+
if (position === "before") {
|
|
117
|
+
return createRect({
|
|
118
|
+
top: itemRect.top,
|
|
119
|
+
left: itemRect.left,
|
|
120
|
+
width: itemRect.width,
|
|
121
|
+
height: thickness
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return createRect({
|
|
125
|
+
top: itemRect.top + itemRect.height - thickness,
|
|
126
|
+
left: itemRect.left,
|
|
127
|
+
width: itemRect.width,
|
|
128
|
+
height: thickness
|
|
129
|
+
});
|
|
130
|
+
}, "createColumnInsertRect");
|
|
131
|
+
const expandColumnRect = /* @__PURE__ */ __name((columnRect) => ({
|
|
132
|
+
top: columnRect.top,
|
|
133
|
+
left: columnRect.left,
|
|
134
|
+
width: columnRect.width,
|
|
135
|
+
height: Math.max(columnRect.height, MIN_SLOT_THICKNESS)
|
|
136
|
+
}), "expandColumnRect");
|
|
137
|
+
const buildLayoutSnapshot = /* @__PURE__ */ __name(({ container }) => {
|
|
138
|
+
if (!container) {
|
|
139
|
+
return {
|
|
140
|
+
slots: [],
|
|
141
|
+
containerRect: { top: 0, left: 0, width: 0, height: 0 }
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const containerRect = toRect(container.getBoundingClientRect());
|
|
145
|
+
const slots = [];
|
|
146
|
+
const allRowElements = Array.from(container.querySelectorAll("[data-grid-row-id]"));
|
|
147
|
+
const rowElements = allRowElements.filter((el) => {
|
|
148
|
+
const htmlEl = el;
|
|
149
|
+
let parent = htmlEl.parentElement;
|
|
150
|
+
while (parent && parent !== container) {
|
|
151
|
+
if (parent.hasAttribute("data-grid-row-id")) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
parent = parent.parentElement;
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
});
|
|
158
|
+
if (rowElements.length === 0) {
|
|
159
|
+
slots.push({
|
|
160
|
+
type: "empty-row",
|
|
161
|
+
rect: createRect({
|
|
162
|
+
top: containerRect.top,
|
|
163
|
+
left: containerRect.left,
|
|
164
|
+
width: containerRect.width,
|
|
165
|
+
height: Math.max(containerRect.height, MIN_SLOT_THICKNESS)
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
return { slots, containerRect };
|
|
169
|
+
}
|
|
170
|
+
rowElements.forEach((rowElement, rowIndex) => {
|
|
171
|
+
const rowId = rowElement.dataset.gridRowId;
|
|
172
|
+
if (!rowId) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const rowRect = toRect(rowElement.getBoundingClientRect());
|
|
176
|
+
if (rowIndex === 0) {
|
|
177
|
+
slots.push({
|
|
178
|
+
type: "row-gap",
|
|
179
|
+
targetRowId: rowId,
|
|
180
|
+
position: "above",
|
|
181
|
+
rect: createRowGapRect(rowRect, "above", containerRect)
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const columnElements = Array.from(
|
|
185
|
+
container.querySelectorAll(`[data-grid-column-row-id="${rowId}"][data-grid-column-index]`)
|
|
186
|
+
);
|
|
187
|
+
const sortedColumns = columnElements.sort((a, b) => {
|
|
188
|
+
const indexA = Number(a.dataset.gridColumnIndex || 0);
|
|
189
|
+
const indexB = Number(b.dataset.gridColumnIndex || 0);
|
|
190
|
+
return indexA - indexB;
|
|
191
|
+
});
|
|
192
|
+
sortedColumns.forEach((columnElement) => {
|
|
193
|
+
const columnIndex = Number(columnElement.dataset.gridColumnIndex || 0);
|
|
194
|
+
const columnRect = toRect(columnElement.getBoundingClientRect());
|
|
195
|
+
slots.push({
|
|
196
|
+
type: "column-edge",
|
|
197
|
+
rowId,
|
|
198
|
+
columnIndex,
|
|
199
|
+
direction: "left",
|
|
200
|
+
rect: createColumnEdgeRect(columnRect, "left")
|
|
201
|
+
});
|
|
202
|
+
slots.push({
|
|
203
|
+
type: "column-edge",
|
|
204
|
+
rowId,
|
|
205
|
+
columnIndex,
|
|
206
|
+
direction: "right",
|
|
207
|
+
rect: createColumnEdgeRect(columnRect, "right")
|
|
208
|
+
});
|
|
209
|
+
const itemElements = Array.from(
|
|
210
|
+
columnElement.querySelectorAll(`[data-grid-item-row-id="${rowId}"][data-grid-column-index="${columnIndex}"]`)
|
|
211
|
+
);
|
|
212
|
+
const sortedItems = itemElements.sort((a, b) => {
|
|
213
|
+
const indexA = Number(a.dataset.gridItemIndex || 0);
|
|
214
|
+
const indexB = Number(b.dataset.gridItemIndex || 0);
|
|
215
|
+
return indexA - indexB;
|
|
216
|
+
});
|
|
217
|
+
if (sortedItems.length === 0) {
|
|
218
|
+
slots.push({
|
|
219
|
+
type: "empty-column",
|
|
220
|
+
rowId,
|
|
221
|
+
columnIndex,
|
|
222
|
+
rect: expandColumnRect(columnRect)
|
|
223
|
+
});
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const firstItemRect = toRect(sortedItems[0].getBoundingClientRect());
|
|
227
|
+
slots.push({
|
|
228
|
+
type: "column",
|
|
229
|
+
rowId,
|
|
230
|
+
columnIndex,
|
|
231
|
+
insertIndex: 0,
|
|
232
|
+
position: "before",
|
|
233
|
+
rect: createColumnInsertRect(firstItemRect, "before")
|
|
234
|
+
});
|
|
235
|
+
sortedItems.forEach((itemElement, itemIndex) => {
|
|
236
|
+
const itemRect = toRect(itemElement.getBoundingClientRect());
|
|
237
|
+
slots.push({
|
|
238
|
+
type: "column",
|
|
239
|
+
rowId,
|
|
240
|
+
columnIndex,
|
|
241
|
+
insertIndex: itemIndex + 1,
|
|
242
|
+
position: "after",
|
|
243
|
+
rect: createColumnInsertRect(itemRect, "after")
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
slots.push({
|
|
248
|
+
type: "row-gap",
|
|
249
|
+
targetRowId: rowId,
|
|
250
|
+
position: "below",
|
|
251
|
+
rect: createRowGapRect(rowRect, "below", containerRect)
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
return {
|
|
255
|
+
slots,
|
|
256
|
+
containerRect
|
|
257
|
+
};
|
|
258
|
+
}, "buildLayoutSnapshot");
|
|
259
|
+
const getSlotKey = /* @__PURE__ */ __name((slot) => {
|
|
260
|
+
switch (slot.type) {
|
|
261
|
+
case "column":
|
|
262
|
+
return `${slot.type}:${slot.rowId}:${slot.columnIndex}:${slot.insertIndex}:${slot.position}`;
|
|
263
|
+
case "column-edge":
|
|
264
|
+
return `${slot.type}:${slot.rowId}:${slot.columnIndex}:${slot.direction}`;
|
|
265
|
+
case "row-gap":
|
|
266
|
+
return `${slot.type}:${slot.targetRowId}:${slot.position}`;
|
|
267
|
+
case "empty-row":
|
|
268
|
+
return `${slot.type}`;
|
|
269
|
+
case "empty-column":
|
|
270
|
+
return `${slot.type}:${slot.rowId}:${slot.columnIndex}`;
|
|
271
|
+
}
|
|
272
|
+
}, "getSlotKey");
|
|
273
|
+
const isPointInsideRect = /* @__PURE__ */ __name((point, rect) => {
|
|
274
|
+
return point.x >= rect.left && point.x <= rect.left + rect.width && point.y >= rect.top && point.y <= rect.top + rect.height;
|
|
275
|
+
}, "isPointInsideRect");
|
|
276
|
+
const distanceToRect = /* @__PURE__ */ __name((point, rect) => {
|
|
277
|
+
const dx = Math.max(rect.left - point.x, 0, point.x - (rect.left + rect.width));
|
|
278
|
+
const dy = Math.max(rect.top - point.y, 0, point.y - (rect.top + rect.height));
|
|
279
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
280
|
+
}, "distanceToRect");
|
|
281
|
+
const resolveDropIntent = /* @__PURE__ */ __name((point, slots) => {
|
|
282
|
+
if (!slots.length) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
const insideSlot = slots.find((slot) => isPointInsideRect(point, slot.rect));
|
|
286
|
+
if (insideSlot) {
|
|
287
|
+
return insideSlot;
|
|
288
|
+
}
|
|
289
|
+
let closest = null;
|
|
290
|
+
let minDistance = Number.POSITIVE_INFINITY;
|
|
291
|
+
slots.forEach((slot) => {
|
|
292
|
+
const distance = distanceToRect(point, slot.rect);
|
|
293
|
+
if (distance < minDistance) {
|
|
294
|
+
minDistance = distance;
|
|
295
|
+
closest = slot;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
return closest;
|
|
299
|
+
}, "resolveDropIntent");
|
|
300
|
+
const findUidPosition = /* @__PURE__ */ __name((rows, uidValue) => {
|
|
301
|
+
for (const [rowId, columns] of Object.entries(rows)) {
|
|
302
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex += 1) {
|
|
303
|
+
const column = columns[columnIndex];
|
|
304
|
+
const itemIndex = column.indexOf(uidValue);
|
|
305
|
+
if (itemIndex !== -1) {
|
|
306
|
+
return { rowId, columnIndex, itemIndex };
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}, "findUidPosition");
|
|
312
|
+
const removeItemFromLayout = /* @__PURE__ */ __name((layout, uidValue) => {
|
|
313
|
+
const position = findUidPosition(layout.rows, uidValue);
|
|
314
|
+
if (!position) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const { rowId, columnIndex, itemIndex } = position;
|
|
318
|
+
const columns = layout.rows[rowId];
|
|
319
|
+
const column = columns == null ? void 0 : columns[columnIndex];
|
|
320
|
+
if (!column) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
column.splice(itemIndex, 1);
|
|
324
|
+
if (column.length === 0) {
|
|
325
|
+
columns.splice(columnIndex, 1);
|
|
326
|
+
if (layout.sizes[rowId]) {
|
|
327
|
+
layout.sizes[rowId].splice(columnIndex, 1);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (columns.length === 0) {
|
|
331
|
+
delete layout.rows[rowId];
|
|
332
|
+
delete layout.sizes[rowId];
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
normalizeRowSizes(rowId, layout);
|
|
336
|
+
}, "removeItemFromLayout");
|
|
337
|
+
const toIntSizes = /* @__PURE__ */ __name((weights, count) => {
|
|
338
|
+
if (count === 0) {
|
|
339
|
+
return [];
|
|
340
|
+
}
|
|
341
|
+
const normalizedWeights = weights.map((weight) => Number.isFinite(weight) && weight > 0 ? weight : 1);
|
|
342
|
+
const total = normalizedWeights.reduce((sum, weight) => sum + weight, 0) || count;
|
|
343
|
+
const ratios = normalizedWeights.map((weight) => weight / total);
|
|
344
|
+
const raw = ratios.map((ratio) => ratio * DEFAULT_GRID_COLUMNS);
|
|
345
|
+
const floors = raw.map((value) => Math.max(1, Math.floor(value)));
|
|
346
|
+
let remainder = DEFAULT_GRID_COLUMNS - floors.reduce((sum, value) => sum + value, 0);
|
|
347
|
+
if (remainder > 0) {
|
|
348
|
+
const decimals = raw.map((value, index) => ({ index, decimal: value - Math.floor(value) })).sort((a, b) => b.decimal - a.decimal);
|
|
349
|
+
let pointer = 0;
|
|
350
|
+
while (remainder > 0 && decimals.length) {
|
|
351
|
+
const target = decimals[pointer % decimals.length].index;
|
|
352
|
+
floors[target] += 1;
|
|
353
|
+
remainder -= 1;
|
|
354
|
+
pointer += 1;
|
|
355
|
+
}
|
|
356
|
+
} else if (remainder < 0) {
|
|
357
|
+
const decimals = raw.map((value, index) => ({ index, decimal: value - Math.floor(value) })).sort((a, b) => a.decimal - b.decimal);
|
|
358
|
+
let pointer = 0;
|
|
359
|
+
while (remainder < 0 && decimals.length) {
|
|
360
|
+
const target = decimals[pointer % decimals.length].index;
|
|
361
|
+
if (floors[target] > 1) {
|
|
362
|
+
floors[target] -= 1;
|
|
363
|
+
remainder += 1;
|
|
364
|
+
}
|
|
365
|
+
pointer += 1;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const diff = DEFAULT_GRID_COLUMNS - floors.reduce((sum, value) => sum + value, 0);
|
|
369
|
+
if (diff !== 0 && floors.length) {
|
|
370
|
+
floors[floors.length - 1] += diff;
|
|
371
|
+
}
|
|
372
|
+
return floors;
|
|
373
|
+
}, "toIntSizes");
|
|
374
|
+
const normalizeRowSizes = /* @__PURE__ */ __name((rowId, layout) => {
|
|
375
|
+
const columns = layout.rows[rowId];
|
|
376
|
+
if (!columns || columns.length === 0) {
|
|
377
|
+
delete layout.sizes[rowId];
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const current = layout.sizes[rowId] || new Array(columns.length).fill(DEFAULT_GRID_COLUMNS / columns.length);
|
|
381
|
+
const weights = current.length === columns.length ? current : new Array(columns.length).fill(DEFAULT_GRID_COLUMNS / columns.length);
|
|
382
|
+
layout.sizes[rowId] = toIntSizes(weights, columns.length);
|
|
383
|
+
}, "normalizeRowSizes");
|
|
384
|
+
const insertRow = /* @__PURE__ */ __name((rows, referenceRowId, newRowId, position, value) => {
|
|
385
|
+
const entries = Object.entries(rows);
|
|
386
|
+
const result = {};
|
|
387
|
+
let inserted = false;
|
|
388
|
+
entries.forEach(([rowId, rowValue]) => {
|
|
389
|
+
if (!inserted && position === "before" && rowId === referenceRowId) {
|
|
390
|
+
result[newRowId] = value;
|
|
391
|
+
inserted = true;
|
|
392
|
+
}
|
|
393
|
+
result[rowId] = rowValue;
|
|
394
|
+
if (!inserted && position === "after" && rowId === referenceRowId) {
|
|
395
|
+
result[newRowId] = value;
|
|
396
|
+
inserted = true;
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
if (!inserted) {
|
|
400
|
+
result[newRowId] = value;
|
|
401
|
+
}
|
|
402
|
+
return result;
|
|
403
|
+
}, "insertRow");
|
|
404
|
+
const distributeSizesWithNewColumn = /* @__PURE__ */ __name((sizes, insertIndex, columnCount) => {
|
|
405
|
+
if (!sizes || sizes.length === 0) {
|
|
406
|
+
return toIntSizes(new Array(columnCount).fill(1), columnCount);
|
|
407
|
+
}
|
|
408
|
+
const normalized = sizes.map((size) => Number.isFinite(size) && size > 0 ? size : 1);
|
|
409
|
+
const referenceIndex = Math.max(0, Math.min(insertIndex, normalized.length - 1));
|
|
410
|
+
const reference = normalized[referenceIndex] ?? 1;
|
|
411
|
+
const weights = [...normalized];
|
|
412
|
+
weights.splice(insertIndex, 0, reference);
|
|
413
|
+
return toIntSizes(weights, columnCount);
|
|
414
|
+
}, "distributeSizesWithNewColumn");
|
|
415
|
+
const simulateLayoutForSlot = /* @__PURE__ */ __name(({
|
|
416
|
+
slot,
|
|
417
|
+
sourceUid,
|
|
418
|
+
layout,
|
|
419
|
+
generateRowId
|
|
420
|
+
}) => {
|
|
421
|
+
const cloned = {
|
|
422
|
+
rows: import_lodash.default.cloneDeep(layout.rows),
|
|
423
|
+
sizes: import_lodash.default.cloneDeep(layout.sizes)
|
|
424
|
+
};
|
|
425
|
+
removeItemFromLayout(cloned, sourceUid);
|
|
426
|
+
const createRowId = generateRowId ?? import_shared.uid;
|
|
427
|
+
switch (slot.type) {
|
|
428
|
+
case "column": {
|
|
429
|
+
const columns = cloned.rows[slot.rowId] || [];
|
|
430
|
+
if (!cloned.rows[slot.rowId]) {
|
|
431
|
+
cloned.rows[slot.rowId] = columns;
|
|
432
|
+
}
|
|
433
|
+
if (!columns[slot.columnIndex]) {
|
|
434
|
+
columns[slot.columnIndex] = [];
|
|
435
|
+
}
|
|
436
|
+
const targetColumn = columns[slot.columnIndex];
|
|
437
|
+
targetColumn.splice(slot.insertIndex, 0, sourceUid);
|
|
438
|
+
normalizeRowSizes(slot.rowId, cloned);
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
case "empty-column": {
|
|
442
|
+
const columns = cloned.rows[slot.rowId] || [];
|
|
443
|
+
if (!cloned.rows[slot.rowId]) {
|
|
444
|
+
cloned.rows[slot.rowId] = columns;
|
|
445
|
+
}
|
|
446
|
+
if (!columns[slot.columnIndex]) {
|
|
447
|
+
columns[slot.columnIndex] = [];
|
|
448
|
+
}
|
|
449
|
+
columns[slot.columnIndex] = [sourceUid];
|
|
450
|
+
normalizeRowSizes(slot.rowId, cloned);
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
case "column-edge": {
|
|
454
|
+
const columns = cloned.rows[slot.rowId] || [];
|
|
455
|
+
if (!cloned.rows[slot.rowId]) {
|
|
456
|
+
cloned.rows[slot.rowId] = columns;
|
|
457
|
+
}
|
|
458
|
+
const insertIndex = slot.direction === "left" ? slot.columnIndex : slot.columnIndex + 1;
|
|
459
|
+
columns.splice(insertIndex, 0, [sourceUid]);
|
|
460
|
+
cloned.sizes[slot.rowId] = distributeSizesWithNewColumn(cloned.sizes[slot.rowId], insertIndex, columns.length);
|
|
461
|
+
normalizeRowSizes(slot.rowId, cloned);
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
case "row-gap": {
|
|
465
|
+
const newRowId = createRowId();
|
|
466
|
+
const rowPosition = slot.position === "above" ? "before" : "after";
|
|
467
|
+
cloned.rows = insertRow(cloned.rows, slot.targetRowId, newRowId, rowPosition, [[sourceUid]]);
|
|
468
|
+
cloned.sizes[newRowId] = [DEFAULT_GRID_COLUMNS];
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
case "empty-row": {
|
|
472
|
+
const newRowId = createRowId();
|
|
473
|
+
cloned.rows = {
|
|
474
|
+
...cloned.rows,
|
|
475
|
+
[newRowId]: [[sourceUid]]
|
|
476
|
+
};
|
|
477
|
+
cloned.sizes[newRowId] = [DEFAULT_GRID_COLUMNS];
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
default:
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
return cloned;
|
|
484
|
+
}, "simulateLayoutForSlot");
|
|
485
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
486
|
+
0 && (module.exports = {
|
|
487
|
+
COLUMN_EDGE_MAX_WIDTH,
|
|
488
|
+
COLUMN_EDGE_MIN_WIDTH,
|
|
489
|
+
COLUMN_EDGE_WIDTH_RATIO,
|
|
490
|
+
DEFAULT_GRID_COLUMNS,
|
|
491
|
+
MAX_SLOT_THICKNESS,
|
|
492
|
+
MIN_SLOT_THICKNESS,
|
|
493
|
+
buildLayoutSnapshot,
|
|
494
|
+
getSlotKey,
|
|
495
|
+
resolveDropIntent,
|
|
496
|
+
simulateLayoutForSlot
|
|
497
|
+
});
|
|
@@ -10,8 +10,8 @@ import { DndContextProps } from '@dnd-kit/core';
|
|
|
10
10
|
import React, { FC } from 'react';
|
|
11
11
|
import { FlowModel } from '../../models';
|
|
12
12
|
import { PersistOptions } from '../../types';
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
13
|
+
export * from './findModelUidPosition';
|
|
14
|
+
export * from './gridDragPlanner';
|
|
15
15
|
export declare const EMPTY_COLUMN_UID = "EMPTY_COLUMN";
|
|
16
16
|
export declare const DragHandler: FC<{
|
|
17
17
|
model: FlowModel;
|
|
@@ -49,14 +49,14 @@ var import_core = require("@dnd-kit/core");
|
|
|
49
49
|
var import_react = __toESM(require("react"));
|
|
50
50
|
var import_react_dom = require("react-dom");
|
|
51
51
|
var import_provider = require("../../provider");
|
|
52
|
-
__reExport(dnd_exports, require("./
|
|
53
|
-
__reExport(dnd_exports, require("./
|
|
52
|
+
__reExport(dnd_exports, require("./findModelUidPosition"), module.exports);
|
|
53
|
+
__reExport(dnd_exports, require("./gridDragPlanner"), module.exports);
|
|
54
54
|
const EMPTY_COLUMN_UID = "EMPTY_COLUMN";
|
|
55
55
|
const DragHandler = /* @__PURE__ */ __name(({
|
|
56
56
|
model,
|
|
57
57
|
children = /* @__PURE__ */ import_react.default.createElement(import_icons.DragOutlined, null)
|
|
58
58
|
}) => {
|
|
59
|
-
const { attributes, listeners, setNodeRef
|
|
59
|
+
const { attributes, listeners, setNodeRef } = (0, import_core.useDraggable)({ id: model.uid });
|
|
60
60
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
61
61
|
"span",
|
|
62
62
|
{
|
|
@@ -159,6 +159,6 @@ const DndProvider = /* @__PURE__ */ __name(({
|
|
|
159
159
|
DragHandler,
|
|
160
160
|
Droppable,
|
|
161
161
|
EMPTY_COLUMN_UID,
|
|
162
|
-
...require("./
|
|
163
|
-
...require("./
|
|
162
|
+
...require("./findModelUidPosition"),
|
|
163
|
+
...require("./gridDragPlanner")
|
|
164
164
|
});
|
|
@@ -59,7 +59,7 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
59
59
|
uiModeProps,
|
|
60
60
|
cleanup
|
|
61
61
|
}) => {
|
|
62
|
-
var _a, _b, _c, _d;
|
|
62
|
+
var _a, _b, _c, _d, _e, _f;
|
|
63
63
|
const t = (0, import_utils.getT)(model);
|
|
64
64
|
const message = model.context.message;
|
|
65
65
|
if (!model) {
|
|
@@ -132,6 +132,12 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
132
132
|
width: dialogWidth,
|
|
133
133
|
destroyOnClose: true,
|
|
134
134
|
...(0, import_reactive.toJS)(uiModeProps),
|
|
135
|
+
// 透传 navigation,便于变量元信息根据真实视图栈推断父级弹窗
|
|
136
|
+
inputArgs: (0, import_utils.buildSettingsViewInputArgs)(
|
|
137
|
+
model,
|
|
138
|
+
{ ...((_e = (0, import_reactive.toJS)(uiModeProps)) == null ? void 0 : _e.inputArgs) || {}, __isSettingsPopup: true },
|
|
139
|
+
{ navigationOverride: (_f = ctx == null ? void 0 : ctx.view) == null ? void 0 : _f.navigation }
|
|
140
|
+
),
|
|
135
141
|
onClose: /* @__PURE__ */ __name(() => {
|
|
136
142
|
if (cleanup) {
|
|
137
143
|
cleanup();
|