@nocobase/flow-engine 2.1.0-alpha.1 → 2.1.0-alpha.11
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/LICENSE +201 -661
- package/README.md +79 -10
- package/lib/BlockScopedFlowEngine.js +0 -1
- package/lib/FlowDefinition.d.ts +6 -0
- package/lib/FlowSchemaRegistry.d.ts +154 -0
- package/lib/FlowSchemaRegistry.js +1427 -0
- package/lib/JSRunner.d.ts +15 -0
- package/lib/JSRunner.js +82 -7
- package/lib/ViewScopedFlowEngine.js +8 -1
- package/lib/acl/Acl.js +13 -3
- package/lib/components/FlowContextSelector.js +155 -10
- package/lib/components/MobilePopup.js +6 -5
- package/lib/components/dnd/gridDragPlanner.d.ts +1 -0
- package/lib/components/dnd/gridDragPlanner.js +59 -3
- package/lib/components/settings/wrappers/component/SwitchWithTitle.js +2 -1
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -15
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +24 -4
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +21 -3
- package/lib/components/subModel/AddSubModelButton.js +27 -1
- package/lib/components/subModel/utils.js +2 -2
- package/lib/components/variables/VariableInput.js +9 -4
- package/lib/components/variables/VariableTag.js +46 -39
- package/lib/components/variables/utils.d.ts +7 -0
- package/lib/components/variables/utils.js +42 -2
- package/lib/data-source/index.d.ts +7 -27
- package/lib/data-source/index.js +84 -51
- package/lib/executor/FlowExecutor.d.ts +2 -1
- package/lib/executor/FlowExecutor.js +190 -26
- package/lib/flow-schema-registry/fieldBinding.d.ts +32 -0
- package/lib/flow-schema-registry/fieldBinding.js +165 -0
- package/lib/flow-schema-registry/modelPatches.d.ts +16 -0
- package/lib/flow-schema-registry/modelPatches.js +235 -0
- package/lib/flow-schema-registry/schemaInference.d.ts +17 -0
- package/lib/flow-schema-registry/schemaInference.js +207 -0
- package/lib/flow-schema-registry/utils.d.ts +25 -0
- package/lib/flow-schema-registry/utils.js +293 -0
- package/lib/flowContext.d.ts +230 -7
- package/lib/flowContext.js +2270 -148
- package/lib/flowEngine.d.ts +160 -1
- package/lib/flowEngine.js +387 -27
- package/lib/flowI18n.js +6 -4
- package/lib/flowSettings.d.ts +14 -6
- package/lib/flowSettings.js +51 -17
- package/lib/index.d.ts +8 -1
- package/lib/index.js +24 -1
- package/lib/lazy-helper.d.ts +14 -0
- package/lib/lazy-helper.js +71 -0
- package/lib/locale/en-US.json +9 -2
- package/lib/locale/index.d.ts +14 -0
- package/lib/locale/zh-CN.json +8 -1
- package/lib/models/CollectionFieldModel.d.ts +1 -0
- package/lib/models/CollectionFieldModel.js +3 -2
- package/lib/models/DisplayItemModel.d.ts +1 -1
- package/lib/models/EditableItemModel.d.ts +1 -1
- package/lib/models/FilterableItemModel.d.ts +1 -1
- package/lib/models/flowModel.d.ts +7 -0
- package/lib/models/flowModel.js +83 -8
- package/lib/provider.js +7 -6
- package/lib/resources/baseRecordResource.d.ts +5 -0
- package/lib/resources/baseRecordResource.js +24 -0
- package/lib/resources/multiRecordResource.d.ts +1 -0
- package/lib/resources/multiRecordResource.js +11 -4
- package/lib/resources/singleRecordResource.js +2 -0
- package/lib/resources/sqlResource.d.ts +4 -3
- package/lib/resources/sqlResource.js +8 -3
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +2 -2
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +125 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/base.js +706 -41
- package/lib/runjs-context/contributions.d.ts +33 -0
- package/lib/runjs-context/contributions.js +88 -0
- package/lib/runjs-context/helpers.js +12 -1
- package/lib/runjs-context/registry.d.ts +1 -1
- package/lib/runjs-context/setup.js +23 -9
- package/lib/runjs-context/snippets/global/api-request.snippet.js +3 -3
- package/lib/runjs-context/snippets/global/import-esm.snippet.js +2 -3
- package/lib/runjs-context/snippets/global/query-selector.snippet.js +8 -3
- package/lib/runjs-context/snippets/global/require-amd.snippet.js +1 -1
- package/lib/runjs-context/snippets/index.d.ts +11 -1
- package/lib/runjs-context/snippets/index.js +61 -40
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +10 -7
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +5 -5
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +6 -6
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +3 -4
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +20 -3
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +6 -3
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +3 -1
- package/lib/runjsLibs.d.ts +28 -0
- package/lib/runjsLibs.js +532 -0
- package/lib/scheduler/ModelOperationScheduler.d.ts +7 -1
- package/lib/scheduler/ModelOperationScheduler.js +28 -23
- package/lib/server.d.ts +10 -0
- package/lib/server.js +32 -0
- package/lib/types.d.ts +296 -1
- package/lib/utils/associationObjectVariable.d.ts +2 -2
- package/lib/utils/createCollectionContextMeta.js +1 -0
- package/lib/utils/createEphemeralContext.js +2 -2
- package/lib/utils/dateVariable.d.ts +16 -0
- package/lib/utils/dateVariable.js +380 -0
- package/lib/utils/exceptions.d.ts +7 -0
- package/lib/utils/exceptions.js +10 -0
- package/lib/utils/index.d.ts +8 -3
- package/lib/utils/index.js +49 -0
- package/lib/utils/params-resolvers.js +16 -9
- package/lib/utils/parsePathnameToViewParams.js +1 -1
- package/lib/utils/resolveModuleUrl.d.ts +58 -0
- package/lib/utils/resolveModuleUrl.js +65 -0
- package/lib/utils/resolveRunJSObjectValues.d.ts +16 -0
- package/lib/utils/resolveRunJSObjectValues.js +61 -0
- package/lib/utils/runjsModuleLoader.d.ts +58 -0
- package/lib/utils/runjsModuleLoader.js +422 -0
- package/lib/utils/runjsTemplateCompat.d.ts +35 -0
- package/lib/utils/runjsTemplateCompat.js +743 -0
- package/lib/utils/runjsValue.d.ts +29 -0
- package/lib/utils/runjsValue.js +275 -0
- package/lib/utils/safeGlobals.d.ts +18 -8
- package/lib/utils/safeGlobals.js +164 -17
- package/lib/utils/schema-utils.d.ts +17 -1
- package/lib/utils/schema-utils.js +80 -0
- package/lib/views/FlowView.d.ts +7 -1
- package/lib/views/createViewMeta.d.ts +0 -7
- package/lib/views/createViewMeta.js +19 -70
- package/lib/views/index.d.ts +1 -2
- package/lib/views/index.js +4 -3
- package/lib/views/runViewBeforeClose.d.ts +10 -0
- package/lib/views/runViewBeforeClose.js +45 -0
- package/lib/views/useDialog.d.ts +2 -1
- package/lib/views/useDialog.js +28 -6
- package/lib/views/useDrawer.d.ts +2 -1
- package/lib/views/useDrawer.js +27 -5
- package/lib/views/usePage.d.ts +6 -1
- package/lib/views/usePage.js +53 -9
- package/lib/views/usePopover.js +4 -1
- package/lib/views/viewEvents.d.ts +17 -0
- package/lib/views/viewEvents.js +90 -0
- package/package.json +5 -5
- package/server.d.ts +1 -0
- package/server.js +1 -0
- package/src/BlockScopedFlowEngine.ts +2 -5
- package/src/FlowSchemaRegistry.ts +1799 -0
- package/src/JSRunner.ts +111 -5
- package/src/ViewScopedFlowEngine.ts +8 -0
- package/src/__tests__/FlowSchemaRegistry.test.ts +1951 -0
- package/src/__tests__/JSRunner.test.ts +91 -1
- package/src/__tests__/createViewMeta.popup.test.ts +62 -1
- package/src/__tests__/flow-engine.test.ts +48 -0
- package/src/__tests__/flowContext.test.ts +693 -1
- package/src/__tests__/flowEngine.dataSourceDirty.test.ts +63 -0
- package/src/__tests__/flowEngine.modelLoaders.test.ts +249 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +4 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +28 -0
- package/src/__tests__/flowRunJSContextDefine.test.ts +63 -0
- package/src/__tests__/flowRuntimeContext.test.ts +2 -1
- package/src/__tests__/flowSettings.open.test.tsx +123 -19
- package/src/__tests__/flowSettings.test.ts +94 -15
- package/src/__tests__/provider.test.tsx +0 -5
- package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
- package/src/__tests__/runjsContext.test.ts +26 -7
- package/src/__tests__/runjsContextImplementations.test.ts +34 -3
- package/src/__tests__/runjsContextRuntime.test.ts +5 -3
- package/src/__tests__/runjsContributions.test.ts +89 -0
- package/src/__tests__/runjsExternalLibs.test.ts +242 -0
- package/src/__tests__/runjsLibsLazyLoading.test.ts +44 -0
- package/src/__tests__/runjsLocales.test.ts +4 -1
- package/src/__tests__/runjsPreprocessDefault.test.ts +72 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +166 -0
- package/src/__tests__/runjsSnippets.test.ts +40 -3
- package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
- package/src/acl/Acl.tsx +3 -3
- package/src/components/FlowContextSelector.tsx +208 -12
- package/src/components/MobilePopup.tsx +4 -2
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +3 -3
- package/src/components/__tests__/gridDragPlanner.test.ts +229 -1
- package/src/components/dnd/gridDragPlanner.ts +68 -2
- package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +2 -1
- package/src/components/settings/wrappers/component/__tests__/InlineControls.test.tsx +74 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +109 -16
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +41 -7
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +31 -4
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +157 -5
- package/src/components/subModel/AddSubModelButton.tsx +32 -2
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +143 -32
- package/src/components/subModel/utils.ts +1 -1
- package/src/components/variables/VariableInput.tsx +12 -4
- package/src/components/variables/VariableTag.tsx +54 -45
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +260 -3
- package/src/components/variables/__tests__/VariableTag.test.tsx +50 -0
- package/src/components/variables/__tests__/utils.test.ts +81 -3
- package/src/components/variables/utils.ts +67 -6
- package/src/data-source/index.ts +88 -110
- package/src/executor/FlowExecutor.ts +230 -28
- package/src/executor/__tests__/flowExecutor.test.ts +123 -0
- package/src/flow-schema-registry/fieldBinding.ts +171 -0
- package/src/flow-schema-registry/modelPatches.ts +260 -0
- package/src/flow-schema-registry/schemaInference.ts +210 -0
- package/src/flow-schema-registry/utils.ts +268 -0
- package/src/flowContext.ts +2989 -212
- package/src/flowEngine.ts +434 -23
- package/src/flowI18n.ts +7 -5
- package/src/flowSettings.ts +58 -18
- package/src/index.ts +15 -1
- package/src/lazy-helper.tsx +57 -0
- package/src/locale/en-US.json +9 -2
- package/src/locale/zh-CN.json +8 -1
- package/src/models/CollectionFieldModel.tsx +3 -1
- package/src/models/DisplayItemModel.tsx +1 -1
- package/src/models/EditableItemModel.tsx +1 -1
- package/src/models/FilterableItemModel.tsx +1 -1
- package/src/models/__tests__/dispatchEvent.when.test.ts +768 -0
- package/src/models/__tests__/flowModel.clone.test.ts +416 -0
- package/src/models/__tests__/flowModel.test.ts +20 -4
- package/src/models/flowModel.tsx +112 -7
- package/src/provider.tsx +9 -7
- package/src/resources/__tests__/multiRecordResource.test.ts +44 -0
- package/src/resources/__tests__/sqlResource.test.ts +60 -0
- package/src/resources/baseRecordResource.ts +31 -0
- package/src/resources/multiRecordResource.ts +11 -4
- package/src/resources/singleRecordResource.ts +3 -0
- package/src/resources/sqlResource.ts +11 -6
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +6 -2
- package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +106 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/base.ts +715 -44
- package/src/runjs-context/contributions.ts +88 -0
- package/src/runjs-context/helpers.ts +11 -1
- package/src/runjs-context/registry.ts +1 -1
- package/src/runjs-context/setup.ts +25 -9
- package/src/runjs-context/snippets/global/api-request.snippet.ts +3 -3
- package/src/runjs-context/snippets/global/import-esm.snippet.ts +2 -3
- package/src/runjs-context/snippets/global/query-selector.snippet.ts +8 -3
- package/src/runjs-context/snippets/global/require-amd.snippet.ts +1 -1
- package/src/runjs-context/snippets/index.ts +75 -41
- package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +11 -13
- package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +6 -11
- package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +6 -6
- package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +3 -4
- package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +20 -3
- package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +3 -8
- package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +6 -3
- package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +3 -1
- package/src/runjsLibs.ts +622 -0
- package/src/scheduler/ModelOperationScheduler.ts +41 -24
- package/src/server.ts +11 -0
- package/src/types.ts +359 -1
- package/src/utils/__tests__/dateVariable.test.ts +101 -0
- package/src/utils/__tests__/params-resolvers.test.ts +40 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +7 -0
- package/src/utils/__tests__/runjsRequireAsyncAutoWhitelist.test.ts +38 -0
- package/src/utils/__tests__/runjsTemplateCompat.test.ts +159 -0
- package/src/utils/__tests__/runjsValue.test.ts +44 -0
- package/src/utils/__tests__/safeGlobals.test.ts +57 -2
- package/src/utils/__tests__/utils.test.ts +157 -0
- package/src/utils/associationObjectVariable.ts +2 -2
- package/src/utils/createCollectionContextMeta.ts +1 -0
- package/src/utils/createEphemeralContext.ts +5 -4
- package/src/utils/dateVariable.ts +397 -0
- package/src/utils/exceptions.ts +11 -0
- package/src/utils/index.ts +38 -3
- package/src/utils/params-resolvers.ts +23 -9
- package/src/utils/parsePathnameToViewParams.ts +2 -2
- package/src/utils/resolveModuleUrl.ts +91 -0
- package/src/utils/resolveRunJSObjectValues.ts +46 -0
- package/src/utils/runjsModuleLoader.ts +553 -0
- package/src/utils/runjsTemplateCompat.ts +828 -0
- package/src/utils/runjsValue.ts +287 -0
- package/src/utils/safeGlobals.ts +188 -17
- package/src/utils/schema-utils.ts +109 -1
- package/src/views/FlowView.tsx +11 -1
- package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
- package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +44 -16
- package/src/views/__tests__/viewEvents.resolveOpenerEngine.test.ts +28 -0
- package/src/views/createViewMeta.ts +22 -75
- package/src/views/index.tsx +1 -2
- package/src/views/runViewBeforeClose.ts +19 -0
- package/src/views/useDialog.tsx +34 -5
- package/src/views/useDrawer.tsx +33 -4
- package/src/views/usePage.tsx +63 -8
- package/src/views/usePopover.tsx +4 -1
- package/src/views/viewEvents.ts +55 -0
|
@@ -135,10 +135,19 @@ const componentMap = {
|
|
|
135
135
|
const MenuLabelItem = /* @__PURE__ */ __name(({ title, uiMode, itemProps }) => {
|
|
136
136
|
const type = (uiMode == null ? void 0 : uiMode.type) || uiMode;
|
|
137
137
|
const Component = type ? componentMap[type] : null;
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
const disabled = !!(itemProps == null ? void 0 : itemProps.disabled);
|
|
139
|
+
const disabledReason = itemProps == null ? void 0 : itemProps.disabledReason;
|
|
140
|
+
const disabledIconColor = itemProps == null ? void 0 : itemProps.disabledIconColor;
|
|
141
|
+
const content = (() => {
|
|
142
|
+
if (!Component) {
|
|
143
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, title);
|
|
144
|
+
}
|
|
145
|
+
return /* @__PURE__ */ import_react.default.createElement(Component, { title, ...itemProps });
|
|
146
|
+
})();
|
|
147
|
+
if (!disabled) {
|
|
148
|
+
return content;
|
|
140
149
|
}
|
|
141
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
150
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: 6 } }, content, /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: disabledReason, placement: "right", destroyTooltipOnHide: true }, /* @__PURE__ */ import_react.default.createElement(import_icons.QuestionCircleOutlined, { style: { color: disabledIconColor } })));
|
|
142
151
|
}, "MenuLabelItem");
|
|
143
152
|
const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
144
153
|
model,
|
|
@@ -150,9 +159,16 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
150
159
|
}) => {
|
|
151
160
|
const { message } = import_antd.App.useApp();
|
|
152
161
|
const t = (0, import_react.useMemo)(() => (0, import_utils.getT)(model), [model]);
|
|
162
|
+
const { token } = import_antd.theme.useToken();
|
|
163
|
+
const disabledIconColor = (token == null ? void 0 : token.colorTextTertiary) || (token == null ? void 0 : token.colorTextDescription) || (token == null ? void 0 : token.colorTextSecondary);
|
|
153
164
|
const [visible, setVisible] = (0, import_react.useState)(false);
|
|
154
165
|
const [refreshTick, setRefreshTick] = (0, import_react.useState)(0);
|
|
155
166
|
const [extraMenuItems, setExtraMenuItems] = (0, import_react.useState)([]);
|
|
167
|
+
const [configurableFlowsAndSteps, setConfigurableFlowsAndSteps] = (0, import_react.useState)([]);
|
|
168
|
+
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
169
|
+
const closeDropdown = (0, import_react.useCallback)(() => {
|
|
170
|
+
setVisible(false);
|
|
171
|
+
}, []);
|
|
156
172
|
const handleOpenChange = (0, import_react.useCallback)((nextOpen, info) => {
|
|
157
173
|
if (info.source === "trigger" || nextOpen) {
|
|
158
174
|
(0, import_react.startTransition)(() => {
|
|
@@ -200,7 +216,7 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
200
216
|
return () => {
|
|
201
217
|
mounted = false;
|
|
202
218
|
};
|
|
203
|
-
}, [model, menuLevels, t, refreshTick, visible
|
|
219
|
+
}, [model, menuLevels, t, refreshTick, visible]);
|
|
204
220
|
const copyUidToClipboard = (0, import_react.useCallback)(
|
|
205
221
|
async (uid) => {
|
|
206
222
|
var _a;
|
|
@@ -249,6 +265,7 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
249
265
|
[model, copyUidToClipboard]
|
|
250
266
|
);
|
|
251
267
|
const handleDelete = (0, import_react.useCallback)(() => {
|
|
268
|
+
closeDropdown();
|
|
252
269
|
import_antd.Modal.confirm({
|
|
253
270
|
title: t("Confirm delete"),
|
|
254
271
|
icon: /* @__PURE__ */ import_react.default.createElement(import_icons.ExclamationCircleOutlined, null),
|
|
@@ -269,7 +286,7 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
269
286
|
}
|
|
270
287
|
}
|
|
271
288
|
});
|
|
272
|
-
}, [model]);
|
|
289
|
+
}, [closeDropdown, model, t]);
|
|
273
290
|
const handleStepConfiguration = (0, import_react.useCallback)(
|
|
274
291
|
(key) => {
|
|
275
292
|
const keyParts = key.split(":");
|
|
@@ -294,6 +311,7 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
294
311
|
[flowKey, stepKey] = keyParts;
|
|
295
312
|
}
|
|
296
313
|
try {
|
|
314
|
+
closeDropdown();
|
|
297
315
|
targetModel.openFlowSettings({
|
|
298
316
|
flowKey,
|
|
299
317
|
stepKey
|
|
@@ -302,23 +320,51 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
302
320
|
console.log(t("Configuration popup cancelled or error"), ":", error);
|
|
303
321
|
}
|
|
304
322
|
},
|
|
305
|
-
[model]
|
|
323
|
+
[closeDropdown, model, t]
|
|
324
|
+
);
|
|
325
|
+
const isStepMenuItemDisabled = (0, import_react.useCallback)(
|
|
326
|
+
(key) => {
|
|
327
|
+
const cleanKey = key.includes("-") && /^(.+)-\d+$/.test(key) ? key.replace(/-\d+$/, "") : key;
|
|
328
|
+
const keys = cleanKey.split(":");
|
|
329
|
+
let modelKey;
|
|
330
|
+
let flowKey;
|
|
331
|
+
let stepKey;
|
|
332
|
+
if (keys.length === 3) {
|
|
333
|
+
[modelKey, flowKey, stepKey] = keys;
|
|
334
|
+
} else if (keys.length === 2) {
|
|
335
|
+
[flowKey, stepKey] = keys;
|
|
336
|
+
} else {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
return configurableFlowsAndSteps.some(({ flow, steps, modelKey: flowModelKey }) => {
|
|
340
|
+
const sameModel = (flowModelKey || void 0) === modelKey;
|
|
341
|
+
if (!sameModel || flow.key !== flowKey) return false;
|
|
342
|
+
return steps.some((stepInfo) => stepInfo.stepKey === stepKey && !!stepInfo.disabled);
|
|
343
|
+
});
|
|
344
|
+
},
|
|
345
|
+
[configurableFlowsAndSteps]
|
|
306
346
|
);
|
|
307
347
|
const handleMenuClick = (0, import_react.useCallback)(
|
|
308
348
|
({ key }) => {
|
|
309
349
|
const originalKey = key;
|
|
310
350
|
const cleanKey = key.includes("-") && /^(.+)-\d+$/.test(key) ? key.replace(/-\d+$/, "") : key;
|
|
311
351
|
if (cleanKey.startsWith("copy-pop-uid:")) {
|
|
352
|
+
closeDropdown();
|
|
312
353
|
handleCopyPopupUid(cleanKey);
|
|
313
354
|
return;
|
|
314
355
|
}
|
|
315
356
|
const extra = extraMenuItems.find((it) => (it == null ? void 0 : it.key) === originalKey || (it == null ? void 0 : it.key) === cleanKey);
|
|
316
357
|
if (extra == null ? void 0 : extra.onClick) {
|
|
358
|
+
closeDropdown();
|
|
317
359
|
extra.onClick();
|
|
318
360
|
return;
|
|
319
361
|
}
|
|
362
|
+
if (isStepMenuItemDisabled(cleanKey)) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
320
365
|
switch (cleanKey) {
|
|
321
366
|
case "copy-uid":
|
|
367
|
+
closeDropdown();
|
|
322
368
|
handleCopyUid();
|
|
323
369
|
break;
|
|
324
370
|
case "delete":
|
|
@@ -329,7 +375,15 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
329
375
|
break;
|
|
330
376
|
}
|
|
331
377
|
},
|
|
332
|
-
[
|
|
378
|
+
[
|
|
379
|
+
closeDropdown,
|
|
380
|
+
handleCopyUid,
|
|
381
|
+
handleDelete,
|
|
382
|
+
handleStepConfiguration,
|
|
383
|
+
handleCopyPopupUid,
|
|
384
|
+
extraMenuItems,
|
|
385
|
+
isStepMenuItemDisabled
|
|
386
|
+
]
|
|
333
387
|
);
|
|
334
388
|
const getModelConfigurableFlowsAndSteps = (0, import_react.useCallback)(
|
|
335
389
|
async (targetModel, modelKey) => {
|
|
@@ -347,6 +401,7 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
347
401
|
if (await (0, import_utils.shouldHideStepInSettings)(targetModel, flow, actionStep)) {
|
|
348
402
|
return null;
|
|
349
403
|
}
|
|
404
|
+
const disabledState = await (0, import_utils.resolveStepDisabledInSettings)(targetModel, flow, actionStep);
|
|
350
405
|
let uiMode = await (0, import_utils.resolveUiMode)(actionStep.uiMode, targetModel.context);
|
|
351
406
|
const hasStepUiSchema = actionStep.uiSchema != null;
|
|
352
407
|
let hasActionUiSchema = false;
|
|
@@ -384,7 +439,9 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
384
439
|
title: t(stepTitle) || stepKey,
|
|
385
440
|
modelKey,
|
|
386
441
|
// 添加模型标识
|
|
387
|
-
uiMode
|
|
442
|
+
uiMode,
|
|
443
|
+
disabled: disabledState.disabled,
|
|
444
|
+
disabledReason: disabledState.reason
|
|
388
445
|
};
|
|
389
446
|
})
|
|
390
447
|
).then((steps) => steps.filter(Boolean));
|
|
@@ -415,8 +472,6 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
415
472
|
}
|
|
416
473
|
return result;
|
|
417
474
|
}, [model, menuLevels, getModelConfigurableFlowsAndSteps]);
|
|
418
|
-
const [configurableFlowsAndSteps, setConfigurableFlowsAndSteps] = (0, import_react.useState)([]);
|
|
419
|
-
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
420
475
|
(0, import_react.useEffect)(() => {
|
|
421
476
|
const triggerRebuild = /* @__PURE__ */ __name(() => {
|
|
422
477
|
setRefreshTick((v) => v + 1);
|
|
@@ -509,11 +564,15 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
509
564
|
}
|
|
510
565
|
}, "onChange"),
|
|
511
566
|
...(uiMode == null ? void 0 : uiMode.props) || {},
|
|
512
|
-
itemKey: uiMode == null ? void 0 : uiMode.key
|
|
567
|
+
itemKey: uiMode == null ? void 0 : uiMode.key,
|
|
568
|
+
disabled: !!stepInfo.disabled,
|
|
569
|
+
disabledReason: stepInfo.disabledReason,
|
|
570
|
+
disabledIconColor
|
|
513
571
|
};
|
|
514
572
|
items.push({
|
|
515
573
|
key: uniqueKey,
|
|
516
|
-
label: /* @__PURE__ */ import_react.default.createElement(MenuLabelItem, { title:
|
|
574
|
+
label: /* @__PURE__ */ import_react.default.createElement(MenuLabelItem, { title: stepInfo.title, uiMode, itemProps }),
|
|
575
|
+
disabled: !!stepInfo.disabled
|
|
517
576
|
});
|
|
518
577
|
});
|
|
519
578
|
if (flow.options.divider === "bottom") {
|
|
@@ -547,7 +606,8 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
547
606
|
const uniqueKey = generateUniqueKey(`${flow.key}:${stepInfo.stepKey}`);
|
|
548
607
|
items.push({
|
|
549
608
|
key: uniqueKey,
|
|
550
|
-
label:
|
|
609
|
+
label: stepInfo.disabled ? /* @__PURE__ */ import_react.default.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: 6 } }, stepInfo.title, /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: stepInfo.disabledReason, placement: "right", destroyTooltipOnHide: true }, /* @__PURE__ */ import_react.default.createElement(import_icons.QuestionCircleOutlined, { style: { color: disabledIconColor } }))) : stepInfo.title,
|
|
610
|
+
disabled: !!stepInfo.disabled
|
|
551
611
|
});
|
|
552
612
|
});
|
|
553
613
|
});
|
|
@@ -559,7 +619,8 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
559
619
|
const uniqueKey = generateUniqueKey(`${modelKey}:${flow.key}:${stepInfo.stepKey}`);
|
|
560
620
|
subMenuChildren.push({
|
|
561
621
|
key: uniqueKey,
|
|
562
|
-
label:
|
|
622
|
+
label: stepInfo.disabled ? /* @__PURE__ */ import_react.default.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: 6 } }, stepInfo.title, /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: stepInfo.disabledReason, placement: "right", destroyTooltipOnHide: true }, /* @__PURE__ */ import_react.default.createElement(import_icons.QuestionCircleOutlined, { style: { color: disabledIconColor } }))) : stepInfo.title,
|
|
623
|
+
disabled: !!stepInfo.disabled
|
|
563
624
|
});
|
|
564
625
|
});
|
|
565
626
|
});
|
|
@@ -573,7 +634,7 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
573
634
|
}
|
|
574
635
|
}
|
|
575
636
|
return items;
|
|
576
|
-
}, [configurableFlowsAndSteps, flattenSubMenus, t]);
|
|
637
|
+
}, [configurableFlowsAndSteps, disabledIconColor, flattenSubMenus, t]);
|
|
577
638
|
const finalMenuItems = (0, import_react.useMemo)(() => {
|
|
578
639
|
const items = [...menuItems];
|
|
579
640
|
const commonExtras = extraMenuItems.filter((it) => it.group === "common-actions").sort((a, b) => (a.sort ?? 0) - (b.sort ?? 0));
|
|
@@ -61,6 +61,20 @@ const FlowsContextMenu = /* @__PURE__ */ __name((props) => {
|
|
|
61
61
|
const FlowsContextMenuWithModel = (0, import_reactive.observer)(
|
|
62
62
|
({ model, children, enabled = true, position = "right", showDeleteButton = true }) => {
|
|
63
63
|
const t = (0, import_utils.getT)(model);
|
|
64
|
+
const { token } = import_antd.theme.useToken();
|
|
65
|
+
const disabledIconColor = (token == null ? void 0 : token.colorTextTertiary) || (token == null ? void 0 : token.colorTextDescription) || (token == null ? void 0 : token.colorTextSecondary);
|
|
66
|
+
const [configurableFlowsAndSteps, setConfigurableFlowsAndSteps] = (0, import_react.useState)([]);
|
|
67
|
+
const isStepMenuItemDisabled = (0, import_react.useCallback)(
|
|
68
|
+
(key) => {
|
|
69
|
+
const [flowKey, stepKey] = key.split(":");
|
|
70
|
+
if (!flowKey || !stepKey) return false;
|
|
71
|
+
return configurableFlowsAndSteps.some(({ flow, steps }) => {
|
|
72
|
+
if (flow.key !== flowKey) return false;
|
|
73
|
+
return steps.some((stepInfo) => stepInfo.stepKey === stepKey && !!stepInfo.disabled);
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
[configurableFlowsAndSteps]
|
|
77
|
+
);
|
|
64
78
|
const handleMenuClick = (0, import_react.useCallback)(
|
|
65
79
|
({ key }) => {
|
|
66
80
|
var _a;
|
|
@@ -86,6 +100,9 @@ const FlowsContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
86
100
|
}
|
|
87
101
|
});
|
|
88
102
|
} else {
|
|
103
|
+
if (isStepMenuItemDisabled(key)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
89
106
|
const [flowKey, stepKey] = key.split(":");
|
|
90
107
|
try {
|
|
91
108
|
const flow = model.getFlow(flowKey);
|
|
@@ -108,7 +125,7 @@ const FlowsContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
108
125
|
}
|
|
109
126
|
}
|
|
110
127
|
},
|
|
111
|
-
[model]
|
|
128
|
+
[isStepMenuItemDisabled, model]
|
|
112
129
|
);
|
|
113
130
|
if (!model) {
|
|
114
131
|
return /* @__PURE__ */ import_react.default.createElement(import_antd.Alert, { message: "\u63D0\u4F9B\u7684\u6A21\u578B\u65E0\u6548", type: "error" });
|
|
@@ -129,6 +146,7 @@ const FlowsContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
129
146
|
if (await (0, import_utils.shouldHideStepInSettings)(model, flow, actionStep)) {
|
|
130
147
|
return null;
|
|
131
148
|
}
|
|
149
|
+
const disabledState = await (0, import_utils.resolveStepDisabledInSettings)(model, flow, actionStep);
|
|
132
150
|
const stepUiSchema = actionStep.uiSchema || {};
|
|
133
151
|
let actionUiSchema = {};
|
|
134
152
|
if (actionStep.use) {
|
|
@@ -152,7 +170,9 @@ const FlowsContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
152
170
|
stepKey,
|
|
153
171
|
step: actionStep,
|
|
154
172
|
uiSchema: mergedUiSchema,
|
|
155
|
-
title: actionStep.title || stepKey
|
|
173
|
+
title: actionStep.title || stepKey,
|
|
174
|
+
disabled: disabledState.disabled,
|
|
175
|
+
disabledReason: disabledState.reason
|
|
156
176
|
};
|
|
157
177
|
})
|
|
158
178
|
).then((steps) => steps.filter(Boolean));
|
|
@@ -165,7 +185,6 @@ const FlowsContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
165
185
|
return [];
|
|
166
186
|
}
|
|
167
187
|
}, [model]);
|
|
168
|
-
const [configurableFlowsAndSteps, setConfigurableFlowsAndSteps] = (0, import_react.useState)([]);
|
|
169
188
|
(0, import_react.useEffect)(() => {
|
|
170
189
|
let mounted = true;
|
|
171
190
|
(async () => {
|
|
@@ -193,7 +212,8 @@ const FlowsContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
193
212
|
menuItems.push({
|
|
194
213
|
key: `${flow.key}:${stepInfo.stepKey}`,
|
|
195
214
|
icon: /* @__PURE__ */ import_react.default.createElement(import_icons.SettingOutlined, null),
|
|
196
|
-
label: stepInfo.title
|
|
215
|
+
label: stepInfo.disabled ? /* @__PURE__ */ import_react.default.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: 6 } }, stepInfo.title, /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: stepInfo.disabledReason, placement: "right", destroyTooltipOnHide: true }, /* @__PURE__ */ import_react.default.createElement(import_icons.QuestionCircleOutlined, { style: { color: disabledIconColor } }))) : stepInfo.title,
|
|
216
|
+
disabled: !!stepInfo.disabled
|
|
197
217
|
});
|
|
198
218
|
});
|
|
199
219
|
});
|
|
@@ -47,6 +47,7 @@ var import_antd = require("antd");
|
|
|
47
47
|
var import_react2 = __toESM(require("react"));
|
|
48
48
|
var import_useFlowSettingsContext = require("../../../../hooks/useFlowSettingsContext");
|
|
49
49
|
var import_utils = require("../../../../utils");
|
|
50
|
+
var import_exceptions = require("../../../../utils/exceptions");
|
|
50
51
|
var import_reactive2 = require("../../../../reactive");
|
|
51
52
|
const SchemaField = (0, import_react.createSchemaField)();
|
|
52
53
|
const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
@@ -125,6 +126,15 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
125
126
|
}
|
|
126
127
|
};
|
|
127
128
|
const openView = model.context.viewer[mode].bind(model.context.viewer);
|
|
129
|
+
const resolvedUiModeProps = (0, import_reactive.toJS)(uiModeProps) || {};
|
|
130
|
+
const { zIndex: uiModeZIndex, ...restUiModeProps } = resolvedUiModeProps;
|
|
131
|
+
const resolveDialogZIndex = /* @__PURE__ */ __name((rawZIndex) => {
|
|
132
|
+
var _a2, _b2;
|
|
133
|
+
const nextZIndex = typeof ((_a2 = model.context.viewer) == null ? void 0 : _a2.getNextZIndex) === "function" ? model.context.viewer.getNextZIndex() : (((_b2 = model.context.themeToken) == null ? void 0 : _b2.zIndexPopupBase) || 1e3) + 1;
|
|
134
|
+
const inputZIndex = Number(rawZIndex) || 0;
|
|
135
|
+
return Math.max(nextZIndex, inputZIndex);
|
|
136
|
+
}, "resolveDialogZIndex");
|
|
137
|
+
const mergedZIndex = resolveDialogZIndex(uiModeZIndex);
|
|
128
138
|
const form = (0, import_core.createForm)({
|
|
129
139
|
initialValues: (0, import_utils.compileUiSchema)(scopes, initialValues)
|
|
130
140
|
});
|
|
@@ -140,7 +150,8 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
140
150
|
title: dialogTitle || t(title),
|
|
141
151
|
width: dialogWidth,
|
|
142
152
|
destroyOnClose: true,
|
|
143
|
-
...
|
|
153
|
+
...restUiModeProps,
|
|
154
|
+
zIndex: mergedZIndex,
|
|
144
155
|
// 透传 navigation,便于变量元信息根据真实视图栈推断父级弹窗
|
|
145
156
|
inputArgs,
|
|
146
157
|
onClose: /* @__PURE__ */ __name(() => {
|
|
@@ -154,7 +165,11 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
154
165
|
(0, import_react2.useEffect)(() => {
|
|
155
166
|
return (0, import_reactive.autorun)(() => {
|
|
156
167
|
const dynamicProps = (0, import_reactive.toJS)(uiModeProps);
|
|
157
|
-
|
|
168
|
+
const { zIndex, ...restDynamicProps } = dynamicProps || {};
|
|
169
|
+
currentDialog.update({
|
|
170
|
+
...restDynamicProps,
|
|
171
|
+
zIndex: resolveDialogZIndex(zIndex)
|
|
172
|
+
});
|
|
158
173
|
});
|
|
159
174
|
}, []);
|
|
160
175
|
const compiledFormSchema = (0, import_utils.compileUiSchema)(scopes, formSchema);
|
|
@@ -195,7 +210,10 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
195
210
|
await afterParamsSave(flowRuntimeContext, currentValues, previousParams);
|
|
196
211
|
}
|
|
197
212
|
} catch (error) {
|
|
198
|
-
if (error instanceof import_utils.
|
|
213
|
+
if (error instanceof import_utils.FlowCancelSaveException) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (error instanceof import_utils.FlowExitException || error instanceof import_exceptions.FlowExitAllException) {
|
|
199
217
|
currentDialog.close();
|
|
200
218
|
return;
|
|
201
219
|
}
|
|
@@ -376,6 +376,21 @@ const AddSubModelButtonCore = /* @__PURE__ */ __name(function AddSubModelButton(
|
|
|
376
376
|
}),
|
|
377
377
|
[model, subModelKey, subModelType]
|
|
378
378
|
);
|
|
379
|
+
import_react.default.useEffect(() => {
|
|
380
|
+
var _a, _b, _c;
|
|
381
|
+
const handleSubModelChanged = /* @__PURE__ */ __name(() => {
|
|
382
|
+
setRefreshTick((x) => x + 1);
|
|
383
|
+
}, "handleSubModelChanged");
|
|
384
|
+
(_a = model.emitter) == null ? void 0 : _a.on("onSubModelAdded", handleSubModelChanged);
|
|
385
|
+
(_b = model.emitter) == null ? void 0 : _b.on("onSubModelRemoved", handleSubModelChanged);
|
|
386
|
+
(_c = model.emitter) == null ? void 0 : _c.on("onSubModelReplaced", handleSubModelChanged);
|
|
387
|
+
return () => {
|
|
388
|
+
var _a2, _b2, _c2;
|
|
389
|
+
(_a2 = model.emitter) == null ? void 0 : _a2.off("onSubModelAdded", handleSubModelChanged);
|
|
390
|
+
(_b2 = model.emitter) == null ? void 0 : _b2.off("onSubModelRemoved", handleSubModelChanged);
|
|
391
|
+
(_c2 = model.emitter) == null ? void 0 : _c2.off("onSubModelReplaced", handleSubModelChanged);
|
|
392
|
+
};
|
|
393
|
+
}, [model]);
|
|
379
394
|
const onClick = /* @__PURE__ */ __name(async (info) => {
|
|
380
395
|
const clickedItem = info.originalItem || info;
|
|
381
396
|
const item = clickedItem.originalItem || clickedItem;
|
|
@@ -415,7 +430,7 @@ const AddSubModelButtonCore = /* @__PURE__ */ __name(function AddSubModelButton(
|
|
|
415
430
|
}
|
|
416
431
|
let addedModel;
|
|
417
432
|
try {
|
|
418
|
-
addedModel = model.flowEngine.
|
|
433
|
+
addedModel = await model.flowEngine.createModelAsync({
|
|
419
434
|
...import_lodash.default.cloneDeep(createOpts),
|
|
420
435
|
parentId: model.uid,
|
|
421
436
|
subKey: subModelKey,
|
|
@@ -461,6 +476,17 @@ const AddSubModelButtonCore = /* @__PURE__ */ __name(function AddSubModelButton(
|
|
|
461
476
|
() => transformItems(finalItems, model, subModelKey, subModelType),
|
|
462
477
|
[finalItems, model, subModelKey, subModelType]
|
|
463
478
|
);
|
|
479
|
+
(0, import_react.useEffect)(() => {
|
|
480
|
+
const handleSubModelChange = /* @__PURE__ */ __name(() => {
|
|
481
|
+
setRefreshTick((x) => x + 1);
|
|
482
|
+
}, "handleSubModelChange");
|
|
483
|
+
model.emitter.on("onSubModelAdded", handleSubModelChange);
|
|
484
|
+
model.emitter.on("onSubModelRemoved", handleSubModelChange);
|
|
485
|
+
return () => {
|
|
486
|
+
model.emitter.off("onSubModelAdded", handleSubModelChange);
|
|
487
|
+
model.emitter.off("onSubModelRemoved", handleSubModelChange);
|
|
488
|
+
};
|
|
489
|
+
}, [model]);
|
|
464
490
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
465
491
|
import_LazyDropdown.default,
|
|
466
492
|
{
|
|
@@ -44,7 +44,7 @@ __export(utils_exports, {
|
|
|
44
44
|
buildWrapperFieldChildren: () => buildWrapperFieldChildren
|
|
45
45
|
});
|
|
46
46
|
module.exports = __toCommonJS(utils_exports);
|
|
47
|
-
var
|
|
47
|
+
var import_lodash = __toESM(require("lodash"));
|
|
48
48
|
var import_utils = require("../../utils");
|
|
49
49
|
async function callHideFunction(hide, ctx) {
|
|
50
50
|
if (typeof hide === "function") {
|
|
@@ -107,7 +107,7 @@ function buildSubModelChildren(M, ctx) {
|
|
|
107
107
|
const extraArg = args && args.length > 0 ? args[args.length - 1] : void 0;
|
|
108
108
|
const defaultOpts = await (0, import_utils.resolveCreateModelOptions)(meta == null ? void 0 : meta.createModelOptions, ctx, extraArg);
|
|
109
109
|
const childOpts = await (0, import_utils.resolveCreateModelOptions)(src, ctx, extraArg);
|
|
110
|
-
return
|
|
110
|
+
return import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaultOpts), childOpts);
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
return node;
|
|
@@ -198,8 +198,7 @@ const VariableInputComponent = /* @__PURE__ */ __name(({
|
|
|
198
198
|
(0, import_react.useEffect)(() => {
|
|
199
199
|
if (!resolvedMetaTreeNode) return;
|
|
200
200
|
if (!Array.isArray(resolvedMetaTree) || innerValue == null) return;
|
|
201
|
-
|
|
202
|
-
emitChange(finalValue, resolvedMetaTreeNode);
|
|
201
|
+
emitChange(innerValue, resolvedMetaTreeNode);
|
|
203
202
|
setCurrentMetaTreeNode(resolvedMetaTreeNode);
|
|
204
203
|
}, [resolvedMetaTreeNode]);
|
|
205
204
|
const composingRef = (0, import_react.useRef)(false);
|
|
@@ -230,12 +229,18 @@ const VariableInputComponent = /* @__PURE__ */ __name(({
|
|
|
230
229
|
);
|
|
231
230
|
const handleVariableSelect = (0, import_react.useCallback)(
|
|
232
231
|
(variableValue, metaTreeNode) => {
|
|
232
|
+
if (!metaTreeNode && variableValue === "") {
|
|
233
|
+
const cleared = clearValue !== void 0 ? clearValue : null;
|
|
234
|
+
setInnerValue(cleared);
|
|
235
|
+
emitChange(cleared);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
233
238
|
setCurrentMetaTreeNode(metaTreeNode);
|
|
234
239
|
const finalValue = (resolveValueFromPath == null ? void 0 : resolveValueFromPath(metaTreeNode)) || variableValue;
|
|
235
240
|
setInnerValue(finalValue);
|
|
236
241
|
emitChange(finalValue, metaTreeNode);
|
|
237
242
|
},
|
|
238
|
-
[emitChange, resolveValueFromPath]
|
|
243
|
+
[emitChange, resolveValueFromPath, clearValue]
|
|
239
244
|
);
|
|
240
245
|
const { disabled } = restProps;
|
|
241
246
|
const handleClear = (0, import_react.useCallback)(() => {
|
|
@@ -265,7 +270,7 @@ const VariableInputComponent = /* @__PURE__ */ __name(({
|
|
|
265
270
|
}, [restProps]);
|
|
266
271
|
const inputProps = (0, import_react.useMemo)(() => {
|
|
267
272
|
const baseProps = {
|
|
268
|
-
value: innerValue ?? "",
|
|
273
|
+
value: ValueComponent === import_antd.Input ? innerValue ?? "" : innerValue,
|
|
269
274
|
onChange: handleInputChange,
|
|
270
275
|
disabled
|
|
271
276
|
};
|
|
@@ -59,53 +59,60 @@ const VariableTagComponent = /* @__PURE__ */ __name(({
|
|
|
59
59
|
const ctx = (0, import_FlowContextProvider.useFlowContext)();
|
|
60
60
|
const { data: displayedValue } = (0, import_ahooks.useRequest)(
|
|
61
61
|
async () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} catch {
|
|
62
|
+
const resolveLabelFromPath = /* @__PURE__ */ __name(async (rawPath2) => {
|
|
63
|
+
if (!rawPath2) return null;
|
|
64
|
+
if (!Array.isArray(rawPath2)) return null;
|
|
65
|
+
if (!Array.isArray(resolvedMetaTree)) return null;
|
|
66
|
+
const topNames = new Set((resolvedMetaTree || []).map((n) => String(n == null ? void 0 : n.name)));
|
|
67
|
+
const path = !topNames.has(String(rawPath2[0])) ? rawPath2.slice(1) : rawPath2;
|
|
68
|
+
if (!path.length) return "";
|
|
69
|
+
let nodes = resolvedMetaTree;
|
|
70
|
+
const titleChain = [];
|
|
71
|
+
let matchedCount = 0;
|
|
72
|
+
for (let i = 0; i < path.length; i++) {
|
|
73
|
+
if (!nodes) break;
|
|
74
|
+
const seg = String(path[i]);
|
|
75
|
+
const node = nodes.find((n) => String(n == null ? void 0 : n.name) === seg);
|
|
76
|
+
if (!node) break;
|
|
77
|
+
titleChain.push(String(node.title ?? node.name ?? seg));
|
|
78
|
+
matchedCount = i + 1;
|
|
79
|
+
if (i < path.length - 1) {
|
|
80
|
+
if (Array.isArray(node.children)) {
|
|
81
|
+
nodes = node.children;
|
|
82
|
+
} else if (typeof node.children === "function") {
|
|
83
|
+
try {
|
|
84
|
+
const childNodes = await node.children();
|
|
85
|
+
node.children = childNodes;
|
|
86
|
+
nodes = childNodes;
|
|
87
|
+
} catch {
|
|
88
|
+
nodes = void 0;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
92
91
|
nodes = void 0;
|
|
93
92
|
}
|
|
94
|
-
} else {
|
|
95
|
-
nodes = void 0;
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const titles = deepest.parentTitles ? [...deepest.parentTitles, deepest.title] : [deepest.title];
|
|
101
|
-
let label = titles.map(ctx.t).join("/");
|
|
95
|
+
if (matchedCount === 0) return null;
|
|
96
|
+
let label2 = titleChain.map(ctx.t).join("/");
|
|
102
97
|
if (matchedCount < path.length) {
|
|
103
98
|
const tail = path.slice(matchedCount).join("/");
|
|
104
|
-
|
|
99
|
+
label2 = tail ? `${label2}/${tail}` : label2;
|
|
105
100
|
}
|
|
106
|
-
return
|
|
101
|
+
return label2;
|
|
102
|
+
}, "resolveLabelFromPath");
|
|
103
|
+
if (metaTreeNode == null ? void 0 : metaTreeNode.parentTitles) {
|
|
104
|
+
return [...metaTreeNode.parentTitles, metaTreeNode.title].map(ctx.t).join("/");
|
|
105
|
+
}
|
|
106
|
+
if (metaTreeNode) {
|
|
107
|
+
const rawPath2 = (0, import_utils.parseValueToPath)(value) || metaTreeNode.paths;
|
|
108
|
+
const label2 = await resolveLabelFromPath(rawPath2);
|
|
109
|
+
return label2 ?? ctx.t(metaTreeNode.title) ?? "";
|
|
107
110
|
}
|
|
108
|
-
return
|
|
111
|
+
if (!value) return String(value);
|
|
112
|
+
const rawPath = (0, import_utils.parseValueToPath)(value);
|
|
113
|
+
const label = await resolveLabelFromPath(rawPath);
|
|
114
|
+
if (label != null) return label;
|
|
115
|
+
return Array.isArray(rawPath) ? rawPath.join("/") : String(value);
|
|
109
116
|
},
|
|
110
117
|
{ refreshDeps: [resolvedMetaTree, value, metaTreeNode] }
|
|
111
118
|
);
|
|
@@ -12,6 +12,13 @@ export declare const parseValueToPath: (value: string) => string[] | undefined;
|
|
|
12
12
|
export declare const formatPathToValue: (item: MetaTreeNode) => string;
|
|
13
13
|
export declare const loadMetaTreeChildren: (metaNode: MetaTreeNode) => Promise<MetaTreeNode[]>;
|
|
14
14
|
export declare const searchInLoadedNodes: (options: ContextSelectorItem[], searchText: string, parentPaths?: string[]) => ContextSelectorItem[];
|
|
15
|
+
/**
|
|
16
|
+
* 仅在“已加载节点”范围内按关键字过滤 options(保留树结构)。
|
|
17
|
+
* - 匹配父节点:保留原节点引用(含原 children),避免不必要的实体重建。
|
|
18
|
+
* - 匹配子节点:返回裁剪后的父节点副本,children 仅包含命中分支。
|
|
19
|
+
* - 未加载 children(即 children 不为数组)不会递归搜索。
|
|
20
|
+
*/
|
|
21
|
+
export declare const filterLoadedContextSelectorItems: (options: ContextSelectorItem[] | undefined, keyword: string) => ContextSelectorItem[];
|
|
15
22
|
export declare const buildContextSelectorItems: (metaTree: MetaTreeNode[]) => ContextSelectorItem[];
|
|
16
23
|
/**
|
|
17
24
|
* 预加载:根据路径逐级加载 ContextSelectorItem 的 children,保证打开时已展开对应层级。
|
|
@@ -30,6 +30,7 @@ __export(utils_exports, {
|
|
|
30
30
|
buildContextSelectorItems: () => buildContextSelectorItems,
|
|
31
31
|
createDefaultConverters: () => createDefaultConverters,
|
|
32
32
|
createFinalConverters: () => createFinalConverters,
|
|
33
|
+
filterLoadedContextSelectorItems: () => filterLoadedContextSelectorItems,
|
|
33
34
|
formatPathToValue: () => formatPathToValue,
|
|
34
35
|
isVariableValue: () => isVariableValue,
|
|
35
36
|
loadMetaTreeChildren: () => loadMetaTreeChildren,
|
|
@@ -39,6 +40,16 @@ __export(utils_exports, {
|
|
|
39
40
|
});
|
|
40
41
|
module.exports = __toCommonJS(utils_exports);
|
|
41
42
|
var import_utils = require("../../utils");
|
|
43
|
+
const getContextSelectorLabelText = /* @__PURE__ */ __name((node) => {
|
|
44
|
+
var _a;
|
|
45
|
+
if (typeof node.label === "string") {
|
|
46
|
+
return node.label;
|
|
47
|
+
}
|
|
48
|
+
if (typeof ((_a = node.meta) == null ? void 0 : _a.title) === "string") {
|
|
49
|
+
return node.meta.title;
|
|
50
|
+
}
|
|
51
|
+
return node.value;
|
|
52
|
+
}, "getContextSelectorLabelText");
|
|
42
53
|
const parseValueToPath = /* @__PURE__ */ __name((value) => {
|
|
43
54
|
if (typeof value !== "string") return void 0;
|
|
44
55
|
const trimmed = value.trim();
|
|
@@ -71,10 +82,9 @@ const searchInLoadedNodes = /* @__PURE__ */ __name((options, searchText, parentP
|
|
|
71
82
|
const lowerSearchText = searchText.toLowerCase().trim();
|
|
72
83
|
const results = [];
|
|
73
84
|
const searchRecursive = /* @__PURE__ */ __name((nodes, currentPath = []) => {
|
|
74
|
-
var _a;
|
|
75
85
|
for (const node of nodes) {
|
|
76
86
|
const nodePath = [...currentPath, node.value];
|
|
77
|
-
const labelText =
|
|
87
|
+
const labelText = getContextSelectorLabelText(node);
|
|
78
88
|
if (labelText.toLowerCase().includes(lowerSearchText)) {
|
|
79
89
|
results.push(node);
|
|
80
90
|
}
|
|
@@ -86,6 +96,35 @@ const searchInLoadedNodes = /* @__PURE__ */ __name((options, searchText, parentP
|
|
|
86
96
|
searchRecursive(options, []);
|
|
87
97
|
return results;
|
|
88
98
|
}, "searchInLoadedNodes");
|
|
99
|
+
const filterLoadedContextSelectorItems = /* @__PURE__ */ __name((options, keyword) => {
|
|
100
|
+
if (!Array.isArray(options) || options.length === 0) return [];
|
|
101
|
+
const normalizedKeyword = keyword.trim().toLowerCase();
|
|
102
|
+
if (!normalizedKeyword) {
|
|
103
|
+
return options;
|
|
104
|
+
}
|
|
105
|
+
const filterNode = /* @__PURE__ */ __name((node) => {
|
|
106
|
+
const labelText = getContextSelectorLabelText(node).toLowerCase();
|
|
107
|
+
const selfMatched = labelText.includes(normalizedKeyword);
|
|
108
|
+
if (selfMatched) {
|
|
109
|
+
return node;
|
|
110
|
+
}
|
|
111
|
+
if (!Array.isArray(node.children) || node.children.length === 0) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const filteredChildren = node.children.map((child) => filterNode(child)).filter((item) => item !== null);
|
|
115
|
+
if (filteredChildren.length === 0) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
if (filteredChildren.length === node.children.length && filteredChildren.every((child, idx) => child === node.children[idx])) {
|
|
119
|
+
return node;
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
...node,
|
|
123
|
+
children: filteredChildren
|
|
124
|
+
};
|
|
125
|
+
}, "filterNode");
|
|
126
|
+
return options.map((node) => filterNode(node)).filter((item) => item !== null);
|
|
127
|
+
}, "filterLoadedContextSelectorItems");
|
|
89
128
|
const buildContextSelectorItems = /* @__PURE__ */ __name((metaTree) => {
|
|
90
129
|
if (!metaTree || !Array.isArray(metaTree)) {
|
|
91
130
|
console.warn("buildContextSelectorItems received invalid metaTree:", metaTree);
|
|
@@ -170,6 +209,7 @@ const createFinalConverters = /* @__PURE__ */ __name((propConverters) => {
|
|
|
170
209
|
buildContextSelectorItems,
|
|
171
210
|
createDefaultConverters,
|
|
172
211
|
createFinalConverters,
|
|
212
|
+
filterLoadedContextSelectorItems,
|
|
173
213
|
formatPathToValue,
|
|
174
214
|
isVariableValue,
|
|
175
215
|
loadMetaTreeChildren,
|