@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
package/lib/JSRunner.d.ts
CHANGED
|
@@ -11,7 +11,22 @@ export interface JSRunnerOptions {
|
|
|
11
11
|
timeoutMs?: number;
|
|
12
12
|
globals?: Record<string, any>;
|
|
13
13
|
version?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Enable RunJS template compatibility preprocessing for `{{ ... }}`.
|
|
16
|
+
* When enabled (or falling back to version default),
|
|
17
|
+
* the code will be rewritten to call `ctx.resolveJsonTemplate(...)` at runtime.
|
|
18
|
+
*/
|
|
19
|
+
preprocessTemplates?: boolean;
|
|
14
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Decide whether RunJS `{{ ... }}` compatibility preprocessing should run.
|
|
23
|
+
*
|
|
24
|
+
* Priority:
|
|
25
|
+
* 1. Explicit `preprocessTemplates` option always wins.
|
|
26
|
+
* 2. Otherwise, `version === 'v2'` disables preprocessing.
|
|
27
|
+
* 3. Fallback keeps v1-compatible behavior (enabled).
|
|
28
|
+
*/
|
|
29
|
+
export declare function shouldPreprocessRunJSTemplates(options?: Pick<JSRunnerOptions, 'preprocessTemplates' | 'version'>): boolean;
|
|
15
30
|
export declare class JSRunner {
|
|
16
31
|
private globals;
|
|
17
32
|
private timeoutMs;
|
package/lib/JSRunner.js
CHANGED
|
@@ -27,14 +27,58 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var JSRunner_exports = {};
|
|
29
29
|
__export(JSRunner_exports, {
|
|
30
|
-
JSRunner: () => JSRunner
|
|
30
|
+
JSRunner: () => JSRunner,
|
|
31
|
+
shouldPreprocessRunJSTemplates: () => shouldPreprocessRunJSTemplates
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(JSRunner_exports);
|
|
33
34
|
var import_ses = require("ses");
|
|
35
|
+
var import_exceptions = require("./utils/exceptions");
|
|
36
|
+
function shouldPreprocessRunJSTemplates(options) {
|
|
37
|
+
if (typeof (options == null ? void 0 : options.preprocessTemplates) === "boolean") {
|
|
38
|
+
return options.preprocessTemplates;
|
|
39
|
+
}
|
|
40
|
+
return (options == null ? void 0 : options.version) !== "v2";
|
|
41
|
+
}
|
|
42
|
+
__name(shouldPreprocessRunJSTemplates, "shouldPreprocessRunJSTemplates");
|
|
43
|
+
const BARE_CTX_TEMPLATE_RE = /(^|[=(:,[\s)])(\{\{\s*(ctx(?:\.|\[|\?\.)[^}]*)\s*\}\})/m;
|
|
44
|
+
function extractDeprecatedCtxTemplateUsage(code) {
|
|
45
|
+
const src = String(code || "");
|
|
46
|
+
const m = src.match(BARE_CTX_TEMPLATE_RE);
|
|
47
|
+
if (!m) return null;
|
|
48
|
+
const placeholder = String(m[2] || "").trim();
|
|
49
|
+
const expression = String(m[3] || "").trim();
|
|
50
|
+
if (!placeholder || !expression) return null;
|
|
51
|
+
return { placeholder, expression };
|
|
52
|
+
}
|
|
53
|
+
__name(extractDeprecatedCtxTemplateUsage, "extractDeprecatedCtxTemplateUsage");
|
|
54
|
+
function shouldHintCtxTemplateSyntax(err, usage) {
|
|
55
|
+
const isSyntaxError = err instanceof SyntaxError || String((err == null ? void 0 : err.name) || "") === "SyntaxError";
|
|
56
|
+
if (!isSyntaxError) return false;
|
|
57
|
+
if (!usage) return false;
|
|
58
|
+
const msg = String((err == null ? void 0 : err.message) || err || "");
|
|
59
|
+
return /unexpected token/i.test(msg);
|
|
60
|
+
}
|
|
61
|
+
__name(shouldHintCtxTemplateSyntax, "shouldHintCtxTemplateSyntax");
|
|
62
|
+
function toCtxTemplateSyntaxHintError(err, usage) {
|
|
63
|
+
const hint = `"${usage.placeholder}" has been deprecated and cannot be used as executable RunJS syntax. Use await ctx.getVar("${usage.expression}") instead, or keep "${usage.placeholder}" as a plain string.`;
|
|
64
|
+
const out = new SyntaxError(hint);
|
|
65
|
+
try {
|
|
66
|
+
out.cause = err;
|
|
67
|
+
} catch (_) {
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
out.__runjsHideLocation = true;
|
|
71
|
+
out.stack = `${out.name}: ${out.message}`;
|
|
72
|
+
} catch (_) {
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
__name(toCtxTemplateSyntaxHintError, "toCtxTemplateSyntaxHintError");
|
|
34
77
|
const _JSRunner = class _JSRunner {
|
|
35
78
|
globals;
|
|
36
79
|
timeoutMs;
|
|
37
80
|
constructor(options = {}) {
|
|
81
|
+
var _a, _b;
|
|
38
82
|
const bindWindowFn = /* @__PURE__ */ __name((key) => {
|
|
39
83
|
if (typeof window !== "undefined" && typeof window[key] === "function") {
|
|
40
84
|
return window[key].bind(window);
|
|
@@ -42,13 +86,34 @@ const _JSRunner = class _JSRunner {
|
|
|
42
86
|
const fn = globalThis[key];
|
|
43
87
|
return typeof fn === "function" ? fn.bind(globalThis) : fn;
|
|
44
88
|
}, "bindWindowFn");
|
|
89
|
+
const providedGlobals = options.globals || {};
|
|
90
|
+
const liftedGlobals = {};
|
|
91
|
+
if (!Object.prototype.hasOwnProperty.call(providedGlobals, "Blob")) {
|
|
92
|
+
try {
|
|
93
|
+
const blobCtor = (_a = providedGlobals.window) == null ? void 0 : _a.Blob;
|
|
94
|
+
if (typeof blobCtor !== "undefined") {
|
|
95
|
+
liftedGlobals.Blob = blobCtor;
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!Object.prototype.hasOwnProperty.call(providedGlobals, "URL")) {
|
|
101
|
+
try {
|
|
102
|
+
const urlCtor = (_b = providedGlobals.window) == null ? void 0 : _b.URL;
|
|
103
|
+
if (typeof urlCtor !== "undefined") {
|
|
104
|
+
liftedGlobals.URL = urlCtor;
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
}
|
|
45
109
|
this.globals = {
|
|
46
110
|
console,
|
|
47
111
|
setTimeout: bindWindowFn("setTimeout"),
|
|
48
112
|
clearTimeout: bindWindowFn("clearTimeout"),
|
|
49
113
|
setInterval: bindWindowFn("setInterval"),
|
|
50
114
|
clearInterval: bindWindowFn("clearInterval"),
|
|
51
|
-
...
|
|
115
|
+
...liftedGlobals,
|
|
116
|
+
...providedGlobals
|
|
52
117
|
};
|
|
53
118
|
this.timeoutMs = options.timeoutMs ?? 5e3;
|
|
54
119
|
}
|
|
@@ -62,7 +127,8 @@ const _JSRunner = class _JSRunner {
|
|
|
62
127
|
* 异步运行代码,带错误处理和超时机制
|
|
63
128
|
*/
|
|
64
129
|
async run(code) {
|
|
65
|
-
|
|
130
|
+
const search = typeof location !== "undefined" ? location.search : void 0;
|
|
131
|
+
if (typeof search === "string" && search.includes("skipRunJs=true")) {
|
|
66
132
|
return { success: true, value: null };
|
|
67
133
|
}
|
|
68
134
|
const wrapped = `(async () => {
|
|
@@ -81,11 +147,19 @@ const _JSRunner = class _JSRunner {
|
|
|
81
147
|
const result = await Promise.race([task, timeoutPromise]);
|
|
82
148
|
return { success: true, value: result };
|
|
83
149
|
} catch (err) {
|
|
84
|
-
|
|
150
|
+
if (err instanceof import_exceptions.FlowExitException) {
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
if (err instanceof import_exceptions.FlowExitAllException) {
|
|
154
|
+
throw err;
|
|
155
|
+
}
|
|
156
|
+
const usage = extractDeprecatedCtxTemplateUsage(code);
|
|
157
|
+
const outErr = shouldHintCtxTemplateSyntax(err, usage) && usage ? toCtxTemplateSyntaxHintError(err, usage) : err;
|
|
158
|
+
console.error(outErr);
|
|
85
159
|
return {
|
|
86
160
|
success: false,
|
|
87
|
-
error:
|
|
88
|
-
timeout:
|
|
161
|
+
error: outErr,
|
|
162
|
+
timeout: (outErr == null ? void 0 : outErr.message) === "Execution timed out"
|
|
89
163
|
};
|
|
90
164
|
}
|
|
91
165
|
}
|
|
@@ -94,5 +168,6 @@ __name(_JSRunner, "JSRunner");
|
|
|
94
168
|
let JSRunner = _JSRunner;
|
|
95
169
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
170
|
0 && (module.exports = {
|
|
97
|
-
JSRunner
|
|
171
|
+
JSRunner,
|
|
172
|
+
shouldPreprocessRunJSTemplates
|
|
98
173
|
});
|
|
@@ -31,8 +31,10 @@ __export(ViewScopedFlowEngine_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(ViewScopedFlowEngine_exports);
|
|
33
33
|
var import_flowEngine = require("./flowEngine");
|
|
34
|
+
var import_viewEvents = require("./views/viewEvents");
|
|
34
35
|
function createViewScopedEngine(parent) {
|
|
35
36
|
const local = new import_flowEngine.FlowEngine();
|
|
37
|
+
Object.defineProperty(local, import_viewEvents.ENGINE_SCOPE_KEY, { value: import_viewEvents.VIEW_ENGINE_SCOPE, configurable: true });
|
|
36
38
|
if (parent.modelRepository) {
|
|
37
39
|
local.setModelRepository(parent.modelRepository);
|
|
38
40
|
}
|
|
@@ -48,6 +50,7 @@ function createViewScopedEngine(parent) {
|
|
|
48
50
|
"_applyFlowCache",
|
|
49
51
|
"executor",
|
|
50
52
|
"context",
|
|
53
|
+
import_viewEvents.ENGINE_SCOPE_KEY,
|
|
51
54
|
"previousEngine",
|
|
52
55
|
"nextEngine",
|
|
53
56
|
// 调度器与事件总线局部化
|
|
@@ -62,7 +65,11 @@ function createViewScopedEngine(parent) {
|
|
|
62
65
|
"_previousEngine",
|
|
63
66
|
"_nextEngine",
|
|
64
67
|
// getModel 需要在本地执行以确保全局查找时正确遍历整个引擎栈
|
|
65
|
-
"getModel"
|
|
68
|
+
"getModel",
|
|
69
|
+
// 视图销毁回调需要在本地存储,每个视图引擎有自己的销毁逻辑
|
|
70
|
+
"_destroyView",
|
|
71
|
+
"setDestroyView",
|
|
72
|
+
"destroyView"
|
|
66
73
|
]);
|
|
67
74
|
const handler = {
|
|
68
75
|
get(target, prop, receiver) {
|
package/lib/acl/Acl.js
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
17
|
var __export = (target, all) => {
|
|
@@ -24,13 +26,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
26
|
}
|
|
25
27
|
return to;
|
|
26
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
|
+
));
|
|
27
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
38
|
var Acl_exports = {};
|
|
29
39
|
__export(Acl_exports, {
|
|
30
40
|
ACL: () => ACL
|
|
31
41
|
});
|
|
32
42
|
module.exports = __toCommonJS(Acl_exports);
|
|
33
|
-
var import_lodash = require("lodash");
|
|
43
|
+
var import_lodash = __toESM(require("lodash"));
|
|
34
44
|
const _ACL = class _ACL {
|
|
35
45
|
constructor(flowEngine) {
|
|
36
46
|
this.flowEngine = flowEngine;
|
|
@@ -43,10 +53,10 @@ const _ACL = class _ACL {
|
|
|
43
53
|
// 记录上一次用于鉴权的 token,用于识别登录态变更
|
|
44
54
|
lastToken = null;
|
|
45
55
|
setData(data) {
|
|
46
|
-
this.data = data;
|
|
56
|
+
this.data = import_lodash.default.cloneDeep(data);
|
|
47
57
|
}
|
|
48
58
|
setMeta(data) {
|
|
49
|
-
this.meta = data;
|
|
59
|
+
this.meta = import_lodash.default.cloneDeep(data);
|
|
50
60
|
}
|
|
51
61
|
async load() {
|
|
52
62
|
var _a, _b, _c, _d;
|
|
@@ -57,6 +57,35 @@ const cascaderPopupAutoHeightClassName = import_css.css`
|
|
|
57
57
|
max-height: 50vh;
|
|
58
58
|
}
|
|
59
59
|
`;
|
|
60
|
+
const normalizePath = /* @__PURE__ */ __name((path) => {
|
|
61
|
+
if (!Array.isArray(path)) {
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
return path.map((segment) => String(segment));
|
|
65
|
+
}, "normalizePath");
|
|
66
|
+
const getSelectedPathInfo = /* @__PURE__ */ __name((path, options) => {
|
|
67
|
+
var _a;
|
|
68
|
+
if (!Array.isArray(path) || path.length === 0) {
|
|
69
|
+
return { text: "", meta: void 0 };
|
|
70
|
+
}
|
|
71
|
+
const labels = [];
|
|
72
|
+
let currentOptions = options;
|
|
73
|
+
let selectedMeta;
|
|
74
|
+
for (const segment of path) {
|
|
75
|
+
const matchedOption = currentOptions.find((item) => String(item.value) === String(segment));
|
|
76
|
+
if (!matchedOption) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
const label = typeof ((_a = matchedOption.meta) == null ? void 0 : _a.title) === "string" ? matchedOption.meta.title : typeof matchedOption.label === "string" ? matchedOption.label : String(matchedOption.value);
|
|
80
|
+
labels.push(label);
|
|
81
|
+
selectedMeta = matchedOption.meta;
|
|
82
|
+
currentOptions = Array.isArray(matchedOption.children) ? matchedOption.children : [];
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
text: labels.join(" / "),
|
|
86
|
+
meta: selectedMeta
|
|
87
|
+
};
|
|
88
|
+
}, "getSelectedPathInfo");
|
|
60
89
|
const FlowContextSelectorComponent = /* @__PURE__ */ __name(({
|
|
61
90
|
value,
|
|
62
91
|
onChange,
|
|
@@ -70,6 +99,7 @@ const FlowContextSelectorComponent = /* @__PURE__ */ __name(({
|
|
|
70
99
|
ignoreFieldNames,
|
|
71
100
|
...cascaderProps
|
|
72
101
|
}) => {
|
|
102
|
+
const { token } = import_antd.theme.useToken();
|
|
73
103
|
const lastSelectedRef = (0, import_react.useRef)(null);
|
|
74
104
|
const { resolvedMetaTree, loading } = (0, import_useResolvedMetaTree.useResolvedMetaTree)(metaTree);
|
|
75
105
|
const flowCtx = (0, import_FlowContextProvider.useFlowContext)();
|
|
@@ -102,16 +132,28 @@ const FlowContextSelectorComponent = /* @__PURE__ */ __name(({
|
|
|
102
132
|
[flowCtx]
|
|
103
133
|
);
|
|
104
134
|
const [updateFlag, setUpdateFlag] = (0, import_react.useState)(0);
|
|
135
|
+
const [searchText, setSearchText] = (0, import_react.useState)("");
|
|
136
|
+
const [dropdownOpen, setDropdownOpen] = (0, import_react.useState)(false);
|
|
137
|
+
const inlineFocusByPointerRef = (0, import_react.useRef)(false);
|
|
105
138
|
const triggerUpdate = (0, import_react.useCallback)(() => setUpdateFlag((prev) => prev + 1), []);
|
|
139
|
+
const isSearchEnabled = showSearch || children === null;
|
|
106
140
|
const options = (0, import_react.useMemo)(() => {
|
|
107
141
|
if (!resolvedMetaTree) return [];
|
|
142
|
+
const refreshSeq = updateFlag;
|
|
108
143
|
const base = (0, import_utils.buildContextSelectorItems)(resolvedMetaTree);
|
|
109
|
-
|
|
144
|
+
const filtered = translateOptions(base).filter((item) => {
|
|
110
145
|
var _a;
|
|
111
146
|
if (!ignoreFieldNames || ignoreFieldNames.length === 0) return true;
|
|
112
147
|
return !ignoreFieldNames.includes(((_a = item.meta) == null ? void 0 : _a.name) || "");
|
|
113
148
|
});
|
|
149
|
+
return refreshSeq >= 0 ? filtered : [];
|
|
114
150
|
}, [resolvedMetaTree, updateFlag, translateOptions, ignoreFieldNames]);
|
|
151
|
+
const displayOptions = (0, import_react.useMemo)(() => {
|
|
152
|
+
if (!isSearchEnabled || !searchText.trim()) {
|
|
153
|
+
return options;
|
|
154
|
+
}
|
|
155
|
+
return (0, import_utils.filterLoadedContextSelectorItems)(options, searchText);
|
|
156
|
+
}, [isSearchEnabled, options, searchText]);
|
|
115
157
|
const [tempSelectedPath, setTempSelectedPath] = (0, import_react.useState)([]);
|
|
116
158
|
const handleLoadData = (0, import_react.useCallback)(
|
|
117
159
|
async (selectedOptions) => {
|
|
@@ -147,18 +189,27 @@ const FlowContextSelectorComponent = /* @__PURE__ */ __name(({
|
|
|
147
189
|
triggerUpdate();
|
|
148
190
|
}
|
|
149
191
|
},
|
|
150
|
-
[triggerUpdate]
|
|
192
|
+
[triggerUpdate, translateOptions]
|
|
151
193
|
);
|
|
152
194
|
const currentPath = (0, import_react.useMemo)(() => {
|
|
153
|
-
return customParseValueToPath(value);
|
|
195
|
+
return normalizePath(customParseValueToPath(value));
|
|
154
196
|
}, [value, customParseValueToPath]);
|
|
155
197
|
const effectivePath = (0, import_react.useMemo)(() => {
|
|
156
198
|
if (!currentPath || currentPath.length === 0) return currentPath;
|
|
199
|
+
if (options.length === 0) {
|
|
200
|
+
return currentPath;
|
|
201
|
+
}
|
|
157
202
|
const topValues = new Set(options.map((o) => String(o.value)));
|
|
158
203
|
const needTrim = !topValues.has(String(currentPath[0]));
|
|
159
204
|
const fixed = needTrim ? currentPath.slice(1) : currentPath;
|
|
160
205
|
return fixed;
|
|
161
206
|
}, [currentPath, options]);
|
|
207
|
+
const cascaderValue = (0, import_react.useMemo)(() => {
|
|
208
|
+
if (tempSelectedPath.length > 0) {
|
|
209
|
+
return tempSelectedPath;
|
|
210
|
+
}
|
|
211
|
+
return Array.isArray(effectivePath) ? effectivePath : void 0;
|
|
212
|
+
}, [effectivePath, tempSelectedPath]);
|
|
162
213
|
const pathToPreload = (0, import_react.useMemo)(() => {
|
|
163
214
|
const finalPath = effectivePath && effectivePath.length > 0 ? effectivePath : tempSelectedPath;
|
|
164
215
|
return Array.isArray(finalPath) ? finalPath : [];
|
|
@@ -212,22 +263,116 @@ const FlowContextSelectorComponent = /* @__PURE__ */ __name(({
|
|
|
212
263
|
const mergedPopupClassName = (0, import_react.useMemo)(() => {
|
|
213
264
|
return (0, import_css.cx)(cascaderPopupAutoHeightClassName, cascaderProps.popupClassName);
|
|
214
265
|
}, [cascaderProps.popupClassName]);
|
|
266
|
+
const cascaderSearchInputClassName = (0, import_react.useMemo)(() => {
|
|
267
|
+
return import_css.css`
|
|
268
|
+
padding: 8px;
|
|
269
|
+
border-bottom: 1px solid ${token.colorSplit};
|
|
270
|
+
`;
|
|
271
|
+
}, [token.colorSplit]);
|
|
272
|
+
const {
|
|
273
|
+
onDropdownVisibleChange: cascaderOnDropdownVisibleChange,
|
|
274
|
+
dropdownRender: cascaderDropdownRender,
|
|
275
|
+
...restCascaderProps
|
|
276
|
+
} = cascaderProps;
|
|
277
|
+
const selectedPathInfo = (0, import_react.useMemo)(() => getSelectedPathInfo(effectivePath, options), [effectivePath, options]);
|
|
278
|
+
const mergedOpen = open !== void 0 ? open : children === null ? dropdownOpen : void 0;
|
|
279
|
+
const isDropdownVisible = !!mergedOpen;
|
|
280
|
+
const handleDropdownVisibleChange = (0, import_react.useCallback)(
|
|
281
|
+
(visible) => {
|
|
282
|
+
if (open === void 0) {
|
|
283
|
+
setDropdownOpen(visible);
|
|
284
|
+
}
|
|
285
|
+
if (!visible) {
|
|
286
|
+
setSearchText("");
|
|
287
|
+
}
|
|
288
|
+
cascaderOnDropdownVisibleChange == null ? void 0 : cascaderOnDropdownVisibleChange(visible);
|
|
289
|
+
},
|
|
290
|
+
[cascaderOnDropdownVisibleChange, open]
|
|
291
|
+
);
|
|
292
|
+
const renderDropdown = (0, import_react.useCallback)(
|
|
293
|
+
(menu) => {
|
|
294
|
+
const cascaderMenuNode = cascaderDropdownRender ? cascaderDropdownRender(menu) : menu;
|
|
295
|
+
const cascaderMenu = import_react.default.isValidElement(cascaderMenuNode) ? cascaderMenuNode : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, cascaderMenuNode);
|
|
296
|
+
if (!isSearchEnabled || children === null) {
|
|
297
|
+
return cascaderMenu;
|
|
298
|
+
}
|
|
299
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: cascaderSearchInputClassName }, /* @__PURE__ */ import_react.default.createElement(
|
|
300
|
+
import_antd.Input,
|
|
301
|
+
{
|
|
302
|
+
allowClear: true,
|
|
303
|
+
size: "small",
|
|
304
|
+
value: searchText,
|
|
305
|
+
placeholder: flowCtx.t("Search"),
|
|
306
|
+
onChange: (e) => setSearchText(e.target.value),
|
|
307
|
+
onKeyDown: (e) => e.stopPropagation()
|
|
308
|
+
}
|
|
309
|
+
)), cascaderMenu);
|
|
310
|
+
},
|
|
311
|
+
[cascaderDropdownRender, cascaderSearchInputClassName, children, flowCtx, isSearchEnabled, searchText]
|
|
312
|
+
);
|
|
313
|
+
const inlinePlaceholder = typeof restCascaderProps.placeholder === "string" ? restCascaderProps.placeholder : flowCtx.t("Search");
|
|
314
|
+
const hasSelectedPath = Array.isArray(effectivePath) && effectivePath.length > 0;
|
|
315
|
+
const handleInlineInputFocus = (0, import_react.useCallback)(() => {
|
|
316
|
+
if (open === void 0 && !inlineFocusByPointerRef.current) {
|
|
317
|
+
setDropdownOpen(true);
|
|
318
|
+
}
|
|
319
|
+
}, [open]);
|
|
320
|
+
const markInlineFocusByPointer = (0, import_react.useCallback)(() => {
|
|
321
|
+
inlineFocusByPointerRef.current = true;
|
|
322
|
+
}, []);
|
|
323
|
+
const resetInlineFocusByPointer = (0, import_react.useCallback)(() => {
|
|
324
|
+
inlineFocusByPointerRef.current = false;
|
|
325
|
+
}, []);
|
|
326
|
+
const handleInlineInputChange = (0, import_react.useCallback)(
|
|
327
|
+
(event) => {
|
|
328
|
+
const nextValue = event.target.value;
|
|
329
|
+
if (!isDropdownVisible && nextValue === "" && hasSelectedPath) {
|
|
330
|
+
setTempSelectedPath([]);
|
|
331
|
+
onChange == null ? void 0 : onChange("", void 0);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (open === void 0 && !isDropdownVisible) {
|
|
335
|
+
setDropdownOpen(true);
|
|
336
|
+
}
|
|
337
|
+
setSearchText(nextValue);
|
|
338
|
+
},
|
|
339
|
+
[hasSelectedPath, isDropdownVisible, onChange, open]
|
|
340
|
+
);
|
|
341
|
+
const inlinePathText = Array.isArray(effectivePath) ? effectivePath.join(" / ") : "";
|
|
342
|
+
const inlineInputValue = isDropdownVisible ? searchText : selectedPathInfo.text || inlinePathText;
|
|
215
343
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
216
344
|
import_antd.Cascader,
|
|
217
345
|
{
|
|
218
|
-
...
|
|
219
|
-
options,
|
|
220
|
-
value:
|
|
346
|
+
...restCascaderProps,
|
|
347
|
+
options: displayOptions,
|
|
348
|
+
value: cascaderValue,
|
|
221
349
|
onChange: handleChange,
|
|
222
350
|
loadData: handleLoadData,
|
|
223
351
|
loading,
|
|
224
352
|
changeOnSelect: !onlyLeafSelectable,
|
|
225
353
|
expandTrigger: "click",
|
|
226
|
-
open,
|
|
227
|
-
showSearch:
|
|
228
|
-
popupClassName: mergedPopupClassName
|
|
354
|
+
open: mergedOpen,
|
|
355
|
+
showSearch: false,
|
|
356
|
+
popupClassName: mergedPopupClassName,
|
|
357
|
+
dropdownRender: renderDropdown,
|
|
358
|
+
onDropdownVisibleChange: handleDropdownVisibleChange
|
|
229
359
|
},
|
|
230
|
-
children === null ?
|
|
360
|
+
children === null ? /* @__PURE__ */ import_react.default.createElement(
|
|
361
|
+
import_antd.Input,
|
|
362
|
+
{
|
|
363
|
+
allowClear: true,
|
|
364
|
+
value: inlineInputValue,
|
|
365
|
+
placeholder: inlinePlaceholder,
|
|
366
|
+
onMouseDown: markInlineFocusByPointer,
|
|
367
|
+
onMouseUp: resetInlineFocusByPointer,
|
|
368
|
+
onMouseLeave: resetInlineFocusByPointer,
|
|
369
|
+
onFocus: handleInlineInputFocus,
|
|
370
|
+
onBlur: resetInlineFocusByPointer,
|
|
371
|
+
onChange: handleInlineInputChange,
|
|
372
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
373
|
+
disabled: restCascaderProps.disabled
|
|
374
|
+
}
|
|
375
|
+
) : children || defaultChildren
|
|
231
376
|
);
|
|
232
377
|
}, "FlowContextSelectorComponent");
|
|
233
378
|
const FlowContextSelector = import_react.default.memo(FlowContextSelectorComponent);
|
|
@@ -41,11 +41,12 @@ __export(MobilePopup_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(MobilePopup_exports);
|
|
43
43
|
var import_antd = require("antd");
|
|
44
|
-
var import_antd_mobile = require("antd-mobile");
|
|
45
44
|
var import_react = __toESM(require("react"));
|
|
46
|
-
var import_antd_mobile_icons = require("antd-mobile-icons");
|
|
47
45
|
var import_MobilePopup = require("./MobilePopup.style");
|
|
48
46
|
var import_react_i18next = require("react-i18next");
|
|
47
|
+
var import_lazy_helper = require("../lazy-helper");
|
|
48
|
+
const { Popup } = (0, import_lazy_helper.lazy)(() => import("antd-mobile"), "Popup");
|
|
49
|
+
const { CloseOutline } = (0, import_lazy_helper.lazy)(() => import("antd-mobile-icons"), "CloseOutline");
|
|
49
50
|
const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
50
51
|
const { title, visible, onClose: closePopup, children, minHeight, className, footer } = props;
|
|
51
52
|
const { t } = (0, import_react_i18next.useTranslation)();
|
|
@@ -67,7 +68,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
|
67
68
|
};
|
|
68
69
|
}, []);
|
|
69
70
|
return /* @__PURE__ */ import_react.default.createElement(import_antd.ConfigProvider, { theme }, /* @__PURE__ */ import_react.default.createElement(
|
|
70
|
-
|
|
71
|
+
Popup,
|
|
71
72
|
{
|
|
72
73
|
className: `${componentCls} ${hashId} ${className || ""}`,
|
|
73
74
|
visible,
|
|
@@ -81,7 +82,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
|
81
82
|
style,
|
|
82
83
|
destroyOnClose: true
|
|
83
84
|
},
|
|
84
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-header" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-placeholder" }, /* @__PURE__ */ import_react.default.createElement(
|
|
85
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-header" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-placeholder" }, /* @__PURE__ */ import_react.default.createElement(CloseOutline, null)), /* @__PURE__ */ import_react.default.createElement("span", null, title), /* @__PURE__ */ import_react.default.createElement(
|
|
85
86
|
"span",
|
|
86
87
|
{
|
|
87
88
|
className: "nb-mobile-action-drawer-close-icon",
|
|
@@ -90,7 +91,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
|
90
91
|
tabIndex: 0,
|
|
91
92
|
"aria-label": t("Close")
|
|
92
93
|
},
|
|
93
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
94
|
+
/* @__PURE__ */ import_react.default.createElement(CloseOutline, null)
|
|
94
95
|
)),
|
|
95
96
|
children,
|
|
96
97
|
footer && /* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-footer" }, footer)
|
|
@@ -59,6 +59,43 @@ const COLUMN_EDGE_MAX_WIDTH = 28;
|
|
|
59
59
|
const COLUMN_EDGE_WIDTH_RATIO = 0.2;
|
|
60
60
|
const COLUMN_INSERT_THICKNESS_RATIO = 0.5;
|
|
61
61
|
const ROW_GAP_HEIGHT_RATIO = 0.33;
|
|
62
|
+
const deriveRowOrder = /* @__PURE__ */ __name((rows, provided) => {
|
|
63
|
+
const order = [];
|
|
64
|
+
const used = /* @__PURE__ */ new Set();
|
|
65
|
+
(provided || Object.keys(rows)).forEach((rowId) => {
|
|
66
|
+
if (rows[rowId] && !used.has(rowId)) {
|
|
67
|
+
order.push(rowId);
|
|
68
|
+
used.add(rowId);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
Object.keys(rows).forEach((rowId) => {
|
|
72
|
+
if (!used.has(rowId)) {
|
|
73
|
+
order.push(rowId);
|
|
74
|
+
used.add(rowId);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return order;
|
|
78
|
+
}, "deriveRowOrder");
|
|
79
|
+
const normalizeRowsWithOrder = /* @__PURE__ */ __name((rows, order) => {
|
|
80
|
+
const next = {};
|
|
81
|
+
order.forEach((rowId) => {
|
|
82
|
+
if (rows[rowId]) {
|
|
83
|
+
next[rowId] = rows[rowId];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
Object.keys(rows).forEach((rowId) => {
|
|
87
|
+
if (!next[rowId]) {
|
|
88
|
+
next[rowId] = rows[rowId];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return next;
|
|
92
|
+
}, "normalizeRowsWithOrder");
|
|
93
|
+
const ensureRowOrder = /* @__PURE__ */ __name((layout) => {
|
|
94
|
+
const order = deriveRowOrder(layout.rows, layout.rowOrder);
|
|
95
|
+
layout.rowOrder = order;
|
|
96
|
+
layout.rows = normalizeRowsWithOrder(layout.rows, order);
|
|
97
|
+
return order;
|
|
98
|
+
}, "ensureRowOrder");
|
|
62
99
|
const toRect = /* @__PURE__ */ __name((domRect) => ({
|
|
63
100
|
top: domRect.top,
|
|
64
101
|
left: domRect.left,
|
|
@@ -183,7 +220,9 @@ const buildLayoutSnapshot = /* @__PURE__ */ __name(({ container }) => {
|
|
|
183
220
|
}
|
|
184
221
|
const columnElements = Array.from(
|
|
185
222
|
container.querySelectorAll(`[data-grid-column-row-id="${rowId}"][data-grid-column-index]`)
|
|
186
|
-
)
|
|
223
|
+
).filter((el) => {
|
|
224
|
+
return el.closest("[data-grid-row-id]") === rowElement;
|
|
225
|
+
});
|
|
187
226
|
const sortedColumns = columnElements.sort((a, b) => {
|
|
188
227
|
const indexA = Number(a.dataset.gridColumnIndex || 0);
|
|
189
228
|
const indexB = Number(b.dataset.gridColumnIndex || 0);
|
|
@@ -208,7 +247,9 @@ const buildLayoutSnapshot = /* @__PURE__ */ __name(({ container }) => {
|
|
|
208
247
|
});
|
|
209
248
|
const itemElements = Array.from(
|
|
210
249
|
columnElement.querySelectorAll(`[data-grid-item-row-id="${rowId}"][data-grid-column-index="${columnIndex}"]`)
|
|
211
|
-
)
|
|
250
|
+
).filter((el) => {
|
|
251
|
+
return el.closest("[data-grid-column-row-id][data-grid-column-index]") === columnElement;
|
|
252
|
+
});
|
|
212
253
|
const sortedItems = itemElements.sort((a, b) => {
|
|
213
254
|
const indexA = Number(a.dataset.gridItemIndex || 0);
|
|
214
255
|
const indexB = Number(b.dataset.gridItemIndex || 0);
|
|
@@ -330,9 +371,11 @@ const removeItemFromLayout = /* @__PURE__ */ __name((layout, uidValue) => {
|
|
|
330
371
|
if (columns.length === 0) {
|
|
331
372
|
delete layout.rows[rowId];
|
|
332
373
|
delete layout.sizes[rowId];
|
|
374
|
+
ensureRowOrder(layout);
|
|
333
375
|
return;
|
|
334
376
|
}
|
|
335
377
|
normalizeRowSizes(rowId, layout);
|
|
378
|
+
ensureRowOrder(layout);
|
|
336
379
|
}, "removeItemFromLayout");
|
|
337
380
|
const toIntSizes = /* @__PURE__ */ __name((weights, count) => {
|
|
338
381
|
if (count === 0) {
|
|
@@ -420,8 +463,10 @@ const simulateLayoutForSlot = /* @__PURE__ */ __name(({
|
|
|
420
463
|
}) => {
|
|
421
464
|
const cloned = {
|
|
422
465
|
rows: import_lodash.default.cloneDeep(layout.rows),
|
|
423
|
-
sizes: import_lodash.default.cloneDeep(layout.sizes)
|
|
466
|
+
sizes: import_lodash.default.cloneDeep(layout.sizes),
|
|
467
|
+
rowOrder: layout.rowOrder ? [...layout.rowOrder] : void 0
|
|
424
468
|
};
|
|
469
|
+
ensureRowOrder(cloned);
|
|
425
470
|
removeItemFromLayout(cloned, sourceUid);
|
|
426
471
|
const createRowId = generateRowId ?? import_shared.uid;
|
|
427
472
|
switch (slot.type) {
|
|
@@ -464,8 +509,15 @@ const simulateLayoutForSlot = /* @__PURE__ */ __name(({
|
|
|
464
509
|
case "row-gap": {
|
|
465
510
|
const newRowId = createRowId();
|
|
466
511
|
const rowPosition = slot.position === "above" ? "before" : "after";
|
|
512
|
+
const currentOrder = deriveRowOrder(cloned.rows, cloned.rowOrder);
|
|
467
513
|
cloned.rows = insertRow(cloned.rows, slot.targetRowId, newRowId, rowPosition, [[sourceUid]]);
|
|
468
514
|
cloned.sizes[newRowId] = [DEFAULT_GRID_COLUMNS];
|
|
515
|
+
const targetIndex = currentOrder.indexOf(slot.targetRowId);
|
|
516
|
+
const insertIndex = targetIndex === -1 ? currentOrder.length : rowPosition === "before" ? targetIndex : targetIndex + 1;
|
|
517
|
+
const nextOrder = [...currentOrder];
|
|
518
|
+
nextOrder.splice(insertIndex, 0, newRowId);
|
|
519
|
+
cloned.rowOrder = nextOrder;
|
|
520
|
+
cloned.rows = normalizeRowsWithOrder(cloned.rows, nextOrder);
|
|
469
521
|
break;
|
|
470
522
|
}
|
|
471
523
|
case "empty-row": {
|
|
@@ -475,11 +527,15 @@ const simulateLayoutForSlot = /* @__PURE__ */ __name(({
|
|
|
475
527
|
[newRowId]: [[sourceUid]]
|
|
476
528
|
};
|
|
477
529
|
cloned.sizes[newRowId] = [DEFAULT_GRID_COLUMNS];
|
|
530
|
+
const currentOrder = deriveRowOrder(cloned.rows, cloned.rowOrder);
|
|
531
|
+
cloned.rowOrder = [...currentOrder.filter((id) => id !== newRowId), newRowId];
|
|
532
|
+
cloned.rows = normalizeRowsWithOrder(cloned.rows, cloned.rowOrder);
|
|
478
533
|
break;
|
|
479
534
|
}
|
|
480
535
|
default:
|
|
481
536
|
break;
|
|
482
537
|
}
|
|
538
|
+
ensureRowOrder(cloned);
|
|
483
539
|
return cloned;
|
|
484
540
|
}, "simulateLayoutForSlot");
|
|
485
541
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -73,7 +73,8 @@ const SwitchWithTitle = (0, import_reactive.observer)(
|
|
|
73
73
|
setChecked(val);
|
|
74
74
|
onChange == null ? void 0 : onChange({ [itemKey]: val });
|
|
75
75
|
}, "handleChange");
|
|
76
|
-
const handleWrapperClick = /* @__PURE__ */ __name(() => {
|
|
76
|
+
const handleWrapperClick = /* @__PURE__ */ __name((e) => {
|
|
77
|
+
e.stopPropagation();
|
|
77
78
|
if (disabled) return;
|
|
78
79
|
handleChange(!checked);
|
|
79
80
|
}, "handleWrapperClick");
|