@nocobase/client-v2 2.1.0-beta.22 → 2.1.0-beta.23
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/es/Application.d.ts +27 -105
- package/es/BaseApplication.d.ts +176 -0
- package/es/PinnedPluginListContext.d.ts +22 -0
- package/es/Plugin.d.ts +37 -11
- package/es/PluginManager.d.ts +19 -20
- package/es/PluginSettingsManager.d.ts +168 -30
- package/es/RouteRepository.d.ts +124 -0
- package/es/RouterManager.d.ts +18 -13
- package/es/WebSocketClient.d.ts +3 -3
- package/es/acl/ACLProvider.d.ts +81 -0
- package/es/acl/createAclSnippetAllow.d.ts +16 -0
- package/es/acl/index.d.ts +11 -0
- package/es/acl/useAclSnippets.d.ts +16 -0
- package/es/ai/ai-manager.d.ts +15 -0
- package/es/ai/index.d.ts +12 -0
- package/{lib/components → es/ai/skills-manager}/index.d.ts +1 -2
- package/es/ai/skills-manager/types.d.ts +23 -0
- package/es/ai/tools-manager/hooks/context.d.ts +17 -0
- package/es/ai/tools-manager/hooks/index.d.ts +11 -0
- package/es/ai/tools-manager/hooks/provider.d.ts +16 -0
- package/es/ai/tools-manager/index.d.ts +20 -0
- package/es/ai/tools-manager/types.d.ts +90 -0
- package/es/ai/utils.d.ts +10 -0
- package/es/authRedirect.d.ts +63 -0
- package/es/collection-field-interface/CollectionFieldInterface.d.ts +71 -0
- package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +109 -0
- package/es/collection-manager/interfaces/checkbox.d.ts +87 -0
- package/es/collection-manager/interfaces/checkboxGroup.d.ts +138 -0
- package/es/collection-manager/interfaces/collection.d.ts +145 -0
- package/es/collection-manager/interfaces/color.d.ts +62 -0
- package/es/collection-manager/interfaces/createdAt.d.ts +96 -0
- package/es/collection-manager/interfaces/createdBy.d.ts +63 -0
- package/es/collection-manager/interfaces/dateOnly.d.ts +103 -0
- package/es/collection-manager/interfaces/datetime.d.ts +121 -0
- package/es/collection-manager/interfaces/datetimeNoTz.d.ts +121 -0
- package/es/collection-manager/interfaces/email.d.ts +87 -0
- package/es/collection-manager/interfaces/icon.d.ts +44 -0
- package/es/collection-manager/interfaces/id.d.ts +71 -0
- package/es/collection-manager/interfaces/index.d.ts +49 -0
- package/es/collection-manager/interfaces/input.d.ts +187 -0
- package/es/collection-manager/interfaces/integer.d.ts +186 -0
- package/es/collection-manager/interfaces/json.d.ts +62 -0
- package/es/collection-manager/interfaces/linkTo.d.ts +90 -0
- package/es/collection-manager/interfaces/m2m.d.ts +268 -0
- package/es/collection-manager/interfaces/m2o.d.ts +215 -0
- package/es/collection-manager/interfaces/markdown.d.ts +108 -0
- package/es/collection-manager/interfaces/multipleSelect.d.ts +141 -0
- package/es/collection-manager/interfaces/nanoid.d.ts +131 -0
- package/es/collection-manager/interfaces/number.d.ts +187 -0
- package/es/collection-manager/interfaces/o2m.d.ts +243 -0
- package/es/collection-manager/interfaces/o2o.d.ts +621 -0
- package/es/collection-manager/interfaces/password.d.ts +112 -0
- package/es/collection-manager/interfaces/percent.d.ts +157 -0
- package/es/collection-manager/interfaces/phone.d.ts +85 -0
- package/es/collection-manager/interfaces/properties/index.d.ts +145 -0
- package/es/collection-manager/interfaces/properties/operators.d.ts +294 -0
- package/es/collection-manager/interfaces/radioGroup.d.ts +134 -0
- package/es/collection-manager/interfaces/richText.d.ts +110 -0
- package/es/collection-manager/interfaces/select.d.ts +139 -0
- package/es/collection-manager/interfaces/snowflake-id.d.ts +117 -0
- package/es/collection-manager/interfaces/subTable.d.ts +172 -0
- package/es/collection-manager/interfaces/tableoid.d.ts +59 -0
- package/es/collection-manager/interfaces/textarea.d.ts +107 -0
- package/es/collection-manager/interfaces/time.d.ts +64 -0
- package/es/collection-manager/interfaces/types.d.ts +38 -0
- package/es/collection-manager/interfaces/unixTimestamp.d.ts +124 -0
- package/es/collection-manager/interfaces/updatedAt.d.ts +96 -0
- package/es/collection-manager/interfaces/updatedBy.d.ts +63 -0
- package/es/collection-manager/interfaces/url.d.ts +72 -0
- package/es/collection-manager/interfaces/utils/index.d.ts +14 -0
- package/es/collection-manager/interfaces/uuid.d.ts +120 -0
- package/es/components/AppComponents.d.ts +27 -0
- package/es/components/Icon.d.ts +24 -0
- package/es/components/index.d.ts +2 -0
- package/es/css-variable/CSSVariableProvider.d.ts +15 -0
- package/es/flow/FlowModelRepository.d.ts +36 -0
- package/es/flow/FlowPage.d.ts +20 -0
- package/es/flow/actions/aclCheck.d.ts +9 -0
- package/es/flow/actions/aclCheckRefresh.d.ts +9 -0
- package/es/flow/actions/afterSuccess.d.ts +9 -0
- package/es/flow/actions/blockHeight.d.ts +9 -0
- package/es/flow/actions/columnFixed.d.ts +9 -0
- package/es/flow/actions/confirm.d.ts +9 -0
- package/es/flow/actions/customVariable.d.ts +9 -0
- package/es/flow/actions/dataLoadingMode.d.ts +9 -0
- package/es/flow/actions/dataScope.d.ts +9 -0
- package/es/flow/actions/dateTimeFormat.d.ts +9 -0
- package/es/flow/actions/displayFieldComponent.d.ts +19 -0
- package/es/flow/actions/fieldComponent.d.ts +9 -0
- package/es/flow/actions/filterFormDefaultValues.d.ts +9 -0
- package/es/flow/actions/formAssignRules.d.ts +9 -0
- package/es/flow/actions/index.d.ts +40 -0
- package/es/flow/actions/layout.d.ts +10 -0
- package/es/flow/actions/linkageRules.d.ts +23 -0
- package/es/flow/actions/linkageRulesRefresh.d.ts +9 -0
- package/es/flow/actions/navigateToURL.d.ts +9 -0
- package/es/flow/actions/numberFormat.d.ts +9 -0
- package/es/flow/actions/openView.d.ts +15 -0
- package/es/flow/actions/overflowMode.d.ts +9 -0
- package/es/flow/actions/pattern.d.ts +9 -0
- package/es/flow/actions/refreshTargetBlocks.d.ts +9 -0
- package/es/flow/actions/renderMode.d.ts +9 -0
- package/es/flow/actions/required.d.ts +9 -0
- package/es/flow/actions/runjs.d.ts +9 -0
- package/es/flow/actions/setTargetDataScope.d.ts +10 -0
- package/es/flow/actions/showMessage.d.ts +9 -0
- package/es/flow/actions/showNotification.d.ts +9 -0
- package/es/flow/actions/sortingRules.d.ts +9 -0
- package/es/flow/actions/titleField.d.ts +9 -0
- package/es/flow/actions/validation.d.ts +9 -0
- package/es/flow/admin-shell/AdminLayoutRouteCoordinator.d.ts +51 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutCompat.d.ts +112 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutComponent.d.ts +10 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuFlowUtils.d.ts +107 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +60 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuUtils.d.ts +167 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutModel.d.ts +150 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutSlotModels.d.ts +31 -0
- package/es/flow/admin-shell/admin-layout/HelpLite.d.ts +13 -0
- package/{lib/utils/requirejs.d.ts → es/flow/admin-shell/admin-layout/PinnedPluginListLite.d.ts} +5 -8
- package/es/flow/admin-shell/admin-layout/ResetThemeTokenAndKeepAlgorithm.d.ts +13 -0
- package/es/flow/admin-shell/admin-layout/TopbarActionsBar.d.ts +25 -0
- package/es/flow/admin-shell/admin-layout/constants.d.ts +9 -0
- package/es/flow/admin-shell/admin-layout/flowSettingsPreference.d.ts +23 -0
- package/es/flow/admin-shell/admin-layout/index.d.ts +19 -0
- package/es/flow/admin-shell/admin-layout/mobile-layout.d.ts +12 -0
- package/es/flow/admin-shell/admin-layout/mobileMenuNavigation.d.ts +15 -0
- package/es/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.d.ts +42 -0
- package/{lib/context.d.ts → es/flow/admin-shell/admin-layout/useApplications.d.ts} +3 -2
- package/es/flow/admin-shell/useAdminLayoutRoutePage.d.ts +28 -0
- package/es/flow/common/Liquid.d.ts +33 -0
- package/es/flow/common/Markdown/Display.d.ts +9 -0
- package/es/flow/common/Markdown/Edit.d.ts +23 -0
- package/es/flow/common/Markdown/Markdown.d.ts +24 -0
- package/es/flow/common/Markdown/style.d.ts +14 -0
- package/es/flow/common/Markdown/useCDN.d.ts +9 -0
- package/es/flow/components/AdminLayout.d.ts +11 -0
- package/es/flow/components/BlockItemCard.d.ts +16 -0
- package/es/flow/components/ConditionBuilder.d.ts +17 -0
- package/es/flow/components/DefaultValue.d.ts +20 -0
- package/es/flow/components/DynamicFlowsIcon.d.ts +13 -0
- package/es/flow/components/EllipsisWithTooltip.d.ts +17 -0
- package/es/flow/components/ExpiresRadio/index.d.ts +12 -0
- package/es/flow/components/FieldAssignEditor.d.ts +32 -0
- package/es/flow/components/FieldAssignExactDatePicker.d.ts +23 -0
- package/es/flow/components/FieldAssignRulesEditor.d.ts +70 -0
- package/es/flow/components/FieldAssignValueInput.d.ts +88 -0
- package/es/flow/components/FlowRoute.d.ts +28 -0
- package/es/flow/components/Grid/index.d.ts +26 -0
- package/es/flow/components/JsonEditor.d.ts +19 -0
- package/es/flow/components/RunJSValueEditor.d.ts +19 -0
- package/{lib/hooks/useApp.d.ts → es/flow/components/SkeletonFallback.d.ts} +2 -2
- package/es/flow/components/TextAreaWithContextSelector.d.ts +30 -0
- package/es/flow/components/code-editor/core/EditorCore.d.ts +25 -0
- package/es/flow/components/code-editor/core/tooltipParent.d.ts +9 -0
- package/es/flow/components/code-editor/errorHelpers.d.ts +17 -0
- package/es/flow/components/code-editor/extension/CodeEditorExtension.d.ts +14 -0
- package/{lib/hooks → es/flow/components/code-editor/extension}/index.d.ts +1 -3
- package/es/flow/components/code-editor/formatDocInfo.d.ts +17 -0
- package/es/flow/components/code-editor/hooks/useCodeRunner.d.ts +23 -0
- package/es/flow/components/code-editor/hooks/useRunJSDocCompletions.d.ts +15 -0
- package/es/flow/components/code-editor/htmlCompletion.d.ts +11 -0
- package/es/flow/components/code-editor/index.d.ts +31 -0
- package/es/flow/components/code-editor/javascriptCompletion.d.ts +11 -0
- package/es/flow/components/code-editor/javascriptHtmlTemplate.d.ts +16 -0
- package/es/flow/components/code-editor/jsxCompletion.d.ts +10 -0
- package/es/flow/components/code-editor/linter.d.ts +19 -0
- package/es/flow/components/code-editor/panels/LogsPanel.d.ts +15 -0
- package/es/flow/components/code-editor/panels/RightExtra.d.ts +18 -0
- package/es/flow/components/code-editor/panels/SnippetsDrawer.d.ts +18 -0
- package/es/flow/components/code-editor/resolveScenes.d.ts +10 -0
- package/es/flow/components/code-editor/runjsCompletionSource.d.ts +20 -0
- package/es/flow/components/code-editor/runjsCompletions.d.ts +23 -0
- package/es/flow/components/code-editor/runjsDiagnostics.d.ts +46 -0
- package/es/flow/components/code-editor/types.d.ts +32 -0
- package/es/flow/components/drag-drop/Sortable.d.ts +12 -0
- package/es/flow/components/drag-drop/SortableItem.d.ts +12 -0
- package/es/flow/components/drag-drop/index.d.ts +10 -0
- package/es/flow/components/fieldAssignOptions.d.ts +23 -0
- package/es/flow/components/filter/FilterContainer.d.ts +67 -0
- package/es/flow/components/filter/FilterGroup.d.ts +66 -0
- package/es/flow/components/filter/FilterItem.d.ts +40 -0
- package/es/flow/components/filter/LinkageFilterItem.d.ts +51 -0
- package/es/flow/components/filter/VariableFilterItem.d.ts +37 -0
- package/es/flow/components/filter/fieldsToOptions.d.ts +9 -0
- package/es/flow/components/filter/index.d.ts +16 -0
- package/es/flow/components/index.d.ts +14 -0
- package/es/flow/components/placeholders/BlockPlaceholder.d.ts +11 -0
- package/{lib/components/MainComponent.d.ts → es/flow/components/placeholders/FieldPlaceholder.d.ts} +1 -1
- package/es/flow/components/useAssociationTitleFieldSync.d.ts +13 -0
- package/es/flow/flows/editMarkdownFlow.d.ts +10 -0
- package/es/flow/flows/openViewFlow.d.ts +17 -0
- package/es/flow/formily/ReactiveField.d.ts +19 -0
- package/es/flow/formily/index.d.ts +8 -0
- package/es/flow/getViewDiffAndUpdateHidden.d.ts +21 -0
- package/es/flow/index.d.ts +30 -0
- package/es/flow/internal/components/Markdown/DisplayMarkdown.d.ts +10 -0
- package/{lib/utils/globalDeps.d.ts → es/flow/internal/components/Markdown/markdown-it-plugins/mermaidPlugin.d.ts} +3 -3
- package/es/flow/internal/components/Markdown/md.d.ts +11 -0
- package/es/flow/internal/components/Markdown/style.d.ts +9 -0
- package/es/flow/internal/components/Markdown/util.d.ts +15 -0
- package/{lib/components/BlankComponent.d.ts → es/flow/internal/constants/HeightMode.d.ts} +5 -4
- package/es/flow/internal/index.d.ts +11 -0
- package/es/flow/internal/utils/associationValueCoercion.d.ts +15 -0
- package/es/flow/internal/utils/dateTimeUtils.d.ts +10 -0
- package/es/flow/internal/utils/enumOptionsUtils.d.ts +23 -0
- package/es/flow/internal/utils/modelUtils.d.ts +27 -0
- package/es/flow/internal/utils/operatorSchemaHelper.d.ts +15 -0
- package/es/flow/internal/utils/rebuildFieldSubModel.d.ts +33 -0
- package/es/flow/internal/utils/saveStepParamsWithSubModels.d.ts +11 -0
- package/es/flow/internal/utils/titleFieldQuickSync.d.ts +36 -0
- package/es/flow/models/actions/AddChildActionModel.d.ts +16 -0
- package/es/flow/models/actions/AddNewActionModel.d.ts +16 -0
- package/es/flow/models/actions/BulkDeleteActionModel.d.ts +16 -0
- package/es/flow/models/actions/DeleteActionModel.d.ts +15 -0
- package/es/flow/models/actions/EditActionModel.d.ts +16 -0
- package/es/flow/models/actions/ExpandCollapseActionModel.d.ts +19 -0
- package/es/flow/models/actions/FilterActionModel.d.ts +26 -0
- package/{lib/components/RouterBridge.d.ts → es/flow/models/actions/JSActionModel.d.ts} +5 -5
- package/es/flow/models/actions/JSCollectionActionModel.d.ts +14 -0
- package/es/flow/models/actions/JSItemActionModel.d.ts +19 -0
- package/es/flow/models/actions/JSRecordActionModel.d.ts +14 -0
- package/es/flow/models/actions/LinkActionModel.d.ts +15 -0
- package/es/flow/models/actions/LinkActionUtils.d.ts +34 -0
- package/es/flow/models/actions/PopupCollectionActionModel.d.ts +14 -0
- package/es/flow/models/actions/RefreshActionModel.d.ts +14 -0
- package/es/flow/models/actions/UpdateRecordActionModel.d.ts +27 -0
- package/es/flow/models/actions/UpdateRecordActionUtils.d.ts +12 -0
- package/es/flow/models/actions/ViewActionModel.d.ts +15 -0
- package/es/flow/models/actions/index.d.ts +24 -0
- package/es/flow/models/actions/joinUrlSearch.d.ts +12 -0
- package/es/flow/models/base/ActionGroupModel.d.ts +9 -0
- package/es/flow/models/base/ActionGroupModelCore.d.ts +29 -0
- package/es/flow/models/base/ActionModel.d.ts +9 -0
- package/es/flow/models/base/ActionModelCore.d.ts +45 -0
- package/es/flow/models/base/AssociationFieldGroupModel.d.ts +49 -0
- package/es/flow/models/base/BlockGridModel.d.ts +22 -0
- package/es/flow/models/base/BlockModel.d.ts +57 -0
- package/es/flow/models/base/CollectionActionModel.d.ts +12 -0
- package/es/flow/models/base/CollectionBlockModel.d.ts +71 -0
- package/es/flow/models/base/CommonItemModel.d.ts +11 -0
- package/es/flow/models/base/DataBlockModel.d.ts +12 -0
- package/es/flow/models/base/FieldModel.d.ts +17 -0
- package/es/flow/models/base/FilterBlockModel.d.ts +12 -0
- package/es/flow/models/base/GridModel.d.ts +99 -0
- package/es/flow/models/base/PageModel/ChildPageModel.d.ts +21 -0
- package/es/flow/models/base/PageModel/MainPageModel.d.ts +17 -0
- package/es/flow/models/base/PageModel/OldPageModel.d.ts +21 -0
- package/es/flow/models/base/PageModel/PageModel.d.ts +53 -0
- package/es/flow/models/base/PageModel/PageTabModel.d.ts +42 -0
- package/es/flow/models/base/PageModel/RootPageModel.d.ts +24 -0
- package/es/flow/models/base/PageModel/SubPageModel.d.ts +17 -0
- package/es/flow/models/base/PageModel/closeGuard.d.ts +31 -0
- package/{lib → es/flow/models/base/PageModel}/index.d.ts +6 -6
- package/es/flow/models/base/PopupActionModel.d.ts +13 -0
- package/es/flow/models/base/RecordActionModel.d.ts +12 -0
- package/es/flow/models/base/RouteModel.d.ts +11 -0
- package/es/flow/models/base/index.d.ts +24 -0
- package/es/flow/models/blocks/assign-form/AssignFormGridModel.d.ts +15 -0
- package/es/flow/models/blocks/assign-form/AssignFormItemModel.d.ts +22 -0
- package/es/flow/models/blocks/assign-form/AssignFormModel.d.ts +26 -0
- package/es/flow/models/blocks/assign-form/index.d.ts +11 -0
- package/es/flow/models/blocks/details/DetailsAssociationFieldGroupModel.d.ts +12 -0
- package/es/flow/models/blocks/details/DetailsBlockModel.d.ts +41 -0
- package/es/flow/models/blocks/details/DetailsCustomItemModel.d.ts +13 -0
- package/es/flow/models/blocks/details/DetailsGridModel.d.ts +33 -0
- package/es/flow/models/blocks/details/DetailsItemModel.d.ts +60 -0
- package/es/flow/models/blocks/details/DetailsJSFieldItemModel.d.ts +19 -0
- package/es/flow/models/blocks/details/index.d.ts +14 -0
- package/es/flow/models/blocks/details/utils.d.ts +16 -0
- package/es/flow/models/blocks/filter-form/FieldModelSelect.d.ts +10 -0
- package/es/flow/models/blocks/filter-form/FieldOperatorSelect.d.ts +10 -0
- package/es/flow/models/blocks/filter-form/FilterFormActionGroupModel.d.ts +13 -0
- package/es/flow/models/blocks/filter-form/FilterFormActionModel.d.ts +11 -0
- package/es/flow/models/blocks/filter-form/FilterFormBlockModel.d.ts +39 -0
- package/es/flow/models/blocks/filter-form/FilterFormCollapseActionModel.d.ts +18 -0
- package/es/flow/models/blocks/filter-form/FilterFormCustomItemModel.d.ts +13 -0
- package/es/flow/models/blocks/filter-form/FilterFormGridModel.d.ts +43 -0
- package/es/flow/models/blocks/filter-form/FilterFormItemModel.d.ts +59 -0
- package/es/flow/models/blocks/filter-form/FilterFormJSActionModel.d.ts +11 -0
- package/es/flow/models/blocks/filter-form/FilterFormResetActionModel.d.ts +13 -0
- package/es/flow/models/blocks/filter-form/FilterFormSubmitActionModel.d.ts +15 -0
- package/es/flow/models/blocks/filter-form/SourceCascader.d.ts +10 -0
- package/es/flow/models/blocks/filter-form/customFieldOperators.d.ts +34 -0
- package/es/flow/models/blocks/filter-form/fields/FieldComponentProps.d.ts +13 -0
- package/es/flow/models/blocks/filter-form/fields/FilterFormCustomFieldModel.d.ts +52 -0
- package/es/flow/models/blocks/filter-form/fields/FilterFormCustomRecordSelectFieldModel.d.ts +20 -0
- package/{lib/components/RouterContextCleaner.d.ts → es/flow/models/blocks/filter-form/fields/FilterFormFieldModel.d.ts} +3 -4
- package/es/flow/models/blocks/filter-form/fields/FilterFormRecordSelectFieldModel.d.ts +12 -0
- package/es/flow/models/blocks/filter-form/fields/date-time/DateOnlyFilterFieldModel.d.ts +14 -0
- package/es/flow/models/blocks/filter-form/fields/date-time/DateTimeFilterFieldModel.d.ts +13 -0
- package/es/flow/models/blocks/filter-form/fields/date-time/DateTimeNoTzFilterFieldModel.d.ts +13 -0
- package/es/flow/models/blocks/filter-form/fields/date-time/DateTimeTzFilterFieldModel.d.ts +14 -0
- package/es/flow/models/blocks/filter-form/fields/date-time/components/DateFilterDynamicComponent.d.ts +10 -0
- package/es/flow/models/blocks/filter-form/fields/date-time/components/FilterDatePicker.d.ts +10 -0
- package/es/flow/models/blocks/filter-form/fields/date-time/components/FilterRangePicker.d.ts +10 -0
- package/es/flow/models/blocks/filter-form/fields/date-time/index.d.ts +12 -0
- package/es/flow/models/blocks/filter-form/fields/index.d.ts +13 -0
- package/es/flow/models/blocks/filter-form/index.d.ts +23 -0
- package/es/flow/models/blocks/filter-form/legacyDefaultValueMigration.d.ts +13 -0
- package/es/flow/models/blocks/filter-form/valueNormalization.d.ts +17 -0
- package/es/flow/models/blocks/filter-manager/FilterManager.d.ts +141 -0
- package/es/flow/models/blocks/filter-manager/flow-actions/connectFields.d.ts +10 -0
- package/es/flow/models/blocks/filter-manager/flow-actions/customizeFilterRender.d.ts +10 -0
- package/es/flow/models/blocks/filter-manager/flow-actions/defaultOperator.d.ts +9 -0
- package/es/flow/models/blocks/filter-manager/flow-actions/index.d.ts +12 -0
- package/es/flow/models/blocks/filter-manager/flow-actions/operatorComponentProps.d.ts +10 -0
- package/es/flow/models/blocks/filter-manager/index.d.ts +11 -0
- package/es/flow/models/blocks/filter-manager/utils.d.ts +21 -0
- package/es/flow/models/blocks/form/CreateFormModel.d.ts +22 -0
- package/es/flow/models/blocks/form/EditFormModel.d.ts +26 -0
- package/es/flow/models/blocks/form/FormActionGroupModel.d.ts +13 -0
- package/es/flow/models/blocks/form/FormActionModel.d.ts +21 -0
- package/es/flow/models/blocks/form/FormAssociationFieldGroupModel.d.ts +12 -0
- package/es/flow/models/blocks/form/FormAssociationItemModel.d.ts +39 -0
- package/es/flow/models/blocks/form/FormBlockModel.d.ts +96 -0
- package/es/flow/models/blocks/form/FormCustomItemModel.d.ts +13 -0
- package/es/flow/models/blocks/form/FormGridModel.d.ts +35 -0
- package/es/flow/models/blocks/form/FormItemModel.d.ts +39 -0
- package/es/flow/models/blocks/form/FormJSFieldItemModel.d.ts +18 -0
- package/es/flow/models/blocks/form/JSFormActionModel.d.ts +11 -0
- package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +44 -0
- package/es/flow/models/blocks/form/assignRulesUpdateAssociationValues.d.ts +18 -0
- package/es/flow/models/blocks/form/dynamicNamePath.d.ts +19 -0
- package/es/flow/models/blocks/form/index.d.ts +21 -0
- package/es/flow/models/blocks/form/legacyDefaultValueMigration.d.ts +13 -0
- package/es/flow/models/blocks/form/submitHandler.d.ts +9 -0
- package/es/flow/models/blocks/form/submitValues.d.ts +40 -0
- package/es/flow/models/blocks/form/value-runtime/conditions.d.ts +9 -0
- package/es/flow/models/blocks/form/value-runtime/deps.d.ts +23 -0
- package/es/flow/models/blocks/form/value-runtime/form-patch.d.ts +19 -0
- package/es/flow/models/blocks/form/value-runtime/index.d.ts +11 -0
- package/es/flow/models/blocks/form/value-runtime/path.d.ts +25 -0
- package/es/flow/models/blocks/form/value-runtime/rules.d.ts +137 -0
- package/es/flow/models/blocks/form/value-runtime/runtime.d.ts +88 -0
- package/es/flow/models/blocks/form/value-runtime/types.d.ts +62 -0
- package/es/flow/models/blocks/form/value-runtime/utils.d.ts +12 -0
- package/es/flow/models/blocks/index.d.ts +15 -0
- package/es/flow/models/blocks/js-block/JSBlock.d.ts +16 -0
- package/es/flow/models/blocks/js-block/index.d.ts +9 -0
- package/es/flow/models/blocks/shared/legacyDefaultValueMigrationBase.d.ts +20 -0
- package/es/flow/models/blocks/table/JSColumnModel.d.ts +21 -0
- package/es/flow/models/blocks/table/TableActionsColumnModel.d.ts +18 -0
- package/es/flow/models/blocks/table/TableAssociationFieldGroupModel.d.ts +12 -0
- package/es/flow/models/blocks/table/TableBlockModel.d.ts +69 -0
- package/es/flow/models/blocks/table/TableColumnModel.d.ts +29 -0
- package/es/flow/models/blocks/table/TableCustomColumnModel.d.ts +12 -0
- package/es/flow/models/blocks/table/TableJSFieldItemModel.d.ts +19 -0
- package/{lib/hooks/usePlugin.d.ts → es/flow/models/blocks/table/TableSelectModel.d.ts} +6 -3
- package/es/flow/models/blocks/table/dragSort/dragSortComponents.d.ts +14 -0
- package/es/flow/models/blocks/table/dragSort/dragSortHooks.d.ts +13 -0
- package/es/flow/models/blocks/table/dragSort/dragSortSettings.d.ts +39 -0
- package/es/flow/models/blocks/table/dragSort/dragSortUtils.d.ts +37 -0
- package/es/flow/models/blocks/table/dragSort/index.d.ts +12 -0
- package/es/flow/models/blocks/table/index.d.ts +16 -0
- package/es/flow/models/blocks/table/sortUtils.d.ts +32 -0
- package/es/flow/models/blocks/table/utils.d.ts +18 -0
- package/es/flow/models/blocks/utils/transformChildrenToJS.d.ts +42 -0
- package/es/flow/models/fields/AssociationFieldModel/AssociationFieldModel.d.ts +5 -0
- package/es/flow/models/fields/AssociationFieldModel/CascadeSelectFieldModel.d.ts +45 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableActionGroupModel.d.ts +11 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableActionsColumnModel.d.ts +19 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.d.ts +30 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableEditActionModel.d.ts +29 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableFormSubmitActionModel.d.ts +18 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableRemoveActionModel.d.ts +14 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/popupSubTableBeforeClose.d.ts +25 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/blocks/PopupSubTableFormModel.d.ts +36 -0
- package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/index.d.ts +17 -0
- package/es/flow/models/fields/AssociationFieldModel/RecordPickerFieldModel.d.ts +45 -0
- package/es/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.d.ts +46 -0
- package/es/flow/models/fields/AssociationFieldModel/SubFormFieldModel.d.ts +32 -0
- package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.d.ts +32 -0
- package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.d.ts +10 -0
- package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.d.ts +19 -0
- package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/rowIdentity.d.ts +18 -0
- package/{lib/utils → es/flow/models/fields/AssociationFieldModel}/index.d.ts +7 -3
- package/es/flow/models/fields/AssociationFieldModel/itemChain.d.ts +99 -0
- package/es/flow/models/fields/AssociationFieldModel/recordSelectShared.d.ts +48 -0
- package/es/flow/models/fields/CheckboxFieldModel.d.ts +13 -0
- package/es/flow/models/fields/CheckboxGroupFieldModel.d.ts +13 -0
- package/es/flow/models/fields/ClickableFieldModel.d.ts +25 -0
- package/es/flow/models/fields/CollectionSelectorFieldModel.d.ts +13 -0
- package/es/flow/models/fields/ColorFieldModel.d.ts +14 -0
- package/es/flow/models/fields/DateTimeFieldModel/DateOnlyFieldModel.d.ts +7 -0
- package/es/flow/models/fields/DateTimeFieldModel/DateTimeFieldModel.d.ts +3 -0
- package/es/flow/models/fields/DateTimeFieldModel/DateTimeNoTzFieldModel.d.ts +6 -0
- package/es/flow/models/fields/DateTimeFieldModel/DateTimeTzFieldModel.d.ts +7 -0
- package/es/flow/models/fields/DateTimeFieldModel/index.d.ts +11 -0
- package/es/flow/models/fields/DisplayAssociationField/DisplaySubItemFieldModel.d.ts +26 -0
- package/es/flow/models/fields/DisplayAssociationField/DisplaySubListFieldModel.d.ts +26 -0
- package/es/flow/models/fields/DisplayAssociationField/DisplaySubTableFieldModel.d.ts +20 -0
- package/es/flow/models/fields/DisplayAssociationField/displaySubListUtils.d.ts +14 -0
- package/es/flow/models/fields/DisplayAssociationField/index.d.ts +11 -0
- package/es/flow/models/fields/DisplayCheckboxFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayColorFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayDateTimeFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayEnumFieldModel.d.ts +14 -0
- package/es/flow/models/fields/DisplayHtmlFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayIconFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayJSONFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayNumberFieldModel.d.ts +33 -0
- package/es/flow/models/fields/DisplayPasswordFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayPercentFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayTextFieldModel.d.ts +14 -0
- package/es/flow/models/fields/DisplayTimeFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DisplayTitleFieldModel.d.ts +18 -0
- package/es/flow/models/fields/DisplayURLFieldModel.d.ts +13 -0
- package/es/flow/models/fields/DividerItemModel.d.ts +13 -0
- package/es/flow/models/fields/IconFieldModel.d.ts +13 -0
- package/es/flow/models/fields/InputFieldModel.d.ts +13 -0
- package/es/flow/models/fields/JSEditableFieldModel.d.ts +27 -0
- package/es/flow/models/fields/JSFieldModel.d.ts +45 -0
- package/es/flow/models/fields/JSItemModel.d.ts +27 -0
- package/es/flow/models/fields/JsonFieldModel.d.ts +6 -0
- package/es/flow/models/fields/MarkdownItemModel.d.ts +14 -0
- package/es/flow/models/fields/NumberFieldModel.d.ts +15 -0
- package/es/flow/models/fields/PasswordFieldModel.d.ts +13 -0
- package/es/flow/models/fields/PercentFieldModel.d.ts +14 -0
- package/es/flow/models/fields/RadioGroupFieldModel.d.ts +13 -0
- package/es/flow/models/fields/RichTextFieldModel/index.d.ts +14 -0
- package/es/flow/models/fields/RichTextFieldModel/registerFontSize.d.ts +9 -0
- package/es/flow/models/fields/RichTextFieldModel/registerImageResize.d.ts +9 -0
- package/es/flow/models/fields/RichTextFieldModel/registerSmartBreak.d.ts +12 -0
- package/es/flow/models/fields/RichTextFieldModel/style.d.ts +9 -0
- package/es/flow/models/fields/SelectFieldModel.d.ts +13 -0
- package/es/flow/models/fields/TextareaFieldModel.d.ts +13 -0
- package/es/flow/models/fields/TimeFieldModel.d.ts +5 -0
- package/es/flow/models/fields/VariableFieldFormModel.d.ts +18 -0
- package/es/flow/models/fields/index.d.ts +47 -0
- package/es/flow/models/fields/mobile-components/MobileDatePicker.d.ts +10 -0
- package/es/flow/models/fields/mobile-components/MobileLazySelect.d.ts +11 -0
- package/es/flow/models/fields/mobile-components/MobileSelect.d.ts +10 -0
- package/es/flow/models/fields/mobile-components/MobileTimePicker.d.ts +10 -0
- package/es/flow/models/index.d.ts +13 -0
- package/es/flow/models/topbar/TopbarActionModel.d.ts +114 -0
- package/es/flow/models/topbar/UserCenterTopbarActionModel.d.ts +68 -0
- package/es/flow/models/topbar/index.d.ts +10 -0
- package/es/flow/models/utils/resolveRunJsParams.d.ts +19 -0
- package/es/flow/resolveViewParamsToViewList.d.ts +20 -0
- package/es/flow/system-settings/SystemSettingsSource.d.ts +97 -0
- package/es/flow/system-settings/index.d.ts +10 -0
- package/es/flow/system-settings/useSystemSettings.d.ts +30 -0
- package/es/flow/utils/actionCapability.d.ts +60 -0
- package/es/flow/utils/blockUtils.d.ts +16 -0
- package/es/flow/utils/dispatchEventDeep.d.ts +20 -0
- package/es/flow/utils/index.d.ts +11 -0
- package/es/flow/utils/pagination.d.ts +29 -0
- package/es/flow/utils/useJsonTemplateResolver.d.ts +9 -0
- package/es/flow-compat/ColorPicker.d.ts +15 -0
- package/es/flow-compat/FieldValidation.d.ts +31 -0
- package/es/flow-compat/HighPerformanceSpin.d.ts +11 -0
- package/es/flow-compat/Icon.d.ts +10 -0
- package/es/flow-compat/IconPicker.d.ts +19 -0
- package/es/flow-compat/Password.d.ts +16 -0
- package/es/flow-compat/PasswordStrength.d.ts +16 -0
- package/es/flow-compat/Popover.d.ts +12 -0
- package/es/flow-compat/data.d.ts +15 -0
- package/es/flow-compat/date.d.ts +114 -0
- package/es/flow-compat/fieldValidationConstants.d.ts +383 -0
- package/es/flow-compat/index.d.ts +27 -0
- package/es/flow-compat/lazy.d.ts +17 -0
- package/es/flow-compat/operators.d.ts +582 -0
- package/{lib/hooks/useRouter.d.ts → es/flow-compat/passwordUtils.d.ts} +1 -1
- package/es/flow-compat/routeTypes.d.ts +56 -0
- package/es/flow-compat/useFullscreenOverlay.d.ts +20 -0
- package/es/flow-compat/zIndexContext.d.ts +12 -0
- package/es/hooks/useApp.d.ts +4 -2
- package/es/hooks/usePlugin.d.ts +2 -2
- package/es/hooks/useRouter.d.ts +1 -1
- package/es/i18n.d.ts +22 -0
- package/es/index.d.ts +19 -0
- package/es/index.mjs +1019 -0
- package/es/index.mjs.LICENSE.txt +1 -0
- package/es/locale/languageCodes.d.ts +13 -0
- package/es/nocobase-buildin-plugin/index.d.ts +24 -0
- package/es/nocobase-buildin-plugin/plugins/LocalePlugin.d.ts +15 -0
- package/es/nocobase-buildin-plugin/plugins/dayjsLocale.d.ts +76 -0
- package/es/nocobase-buildin-plugin/plugins/loadConstrueLocale.d.ts +9 -0
- package/es/settings-center/AdminSettingsLayout.d.ts +24 -0
- package/es/settings-center/AdminSettingsLayoutModel.d.ts +28 -0
- package/es/settings-center/PluginManagerPage.d.ts +17 -0
- package/es/settings-center/SystemSettingsPage.d.ts +17 -0
- package/es/settings-center/index.d.ts +13 -0
- package/es/settings-center/utils.d.ts +94 -0
- package/es/theme/AntdAppProvider.d.ts +18 -0
- package/es/theme/compatOldTheme.d.ts +11 -0
- package/es/theme/customAlgorithm.d.ts +12 -0
- package/es/theme/defaultTheme.d.ts +11 -0
- package/es/theme/index.d.ts +35 -0
- package/es/theme/type.d.ts +41 -0
- package/es/utils/index.d.ts +1 -1
- package/es/utils/remotePlugins.d.ts +6 -6
- package/lib/index.js +1019 -40
- package/lib/index.js.LICENSE.txt +1 -0
- package/lib/locale/languageCodes.js +96 -0
- package/package.json +28 -5
- package/src/Application.tsx +76 -432
- package/src/BaseApplication.tsx +648 -0
- package/src/PinnedPluginListContext.tsx +33 -0
- package/src/Plugin.ts +24 -8
- package/src/PluginManager.ts +31 -19
- package/src/PluginSettingsManager.ts +504 -100
- package/src/RouteRepository.ts +247 -0
- package/src/RouterManager.tsx +15 -16
- package/src/WebSocketClient.ts +4 -4
- package/src/__tests__/PluginSettingsManager.test.ts +228 -0
- package/src/__tests__/app.test.tsx +216 -34
- package/src/__tests__/authRedirect.test.ts +181 -0
- package/src/__tests__/dataSourceRuntime.test.tsx +34 -0
- package/src/__tests__/globalDeps.test.ts +1 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +185 -0
- package/src/__tests__/settings-center.test.tsx +363 -0
- package/src/acl/ACLProvider.tsx +284 -0
- package/src/acl/__tests__/createAclSnippetAllow.test.ts +42 -0
- package/src/acl/createAclSnippetAllow.ts +33 -0
- package/src/acl/index.ts +12 -0
- package/src/acl/useAclSnippets.ts +25 -0
- package/src/ai/ai-manager.ts +19 -0
- package/src/ai/index.ts +13 -0
- package/src/ai/skills-manager/index.ts +10 -0
- package/src/ai/skills-manager/types.ts +26 -0
- package/src/ai/tools-manager/hooks/context.ts +20 -0
- package/src/ai/tools-manager/hooks/index.ts +22 -0
- package/src/ai/tools-manager/hooks/provider.tsx +53 -0
- package/src/ai/tools-manager/index.ts +42 -0
- package/src/ai/tools-manager/types.ts +106 -0
- package/src/ai/utils.ts +12 -0
- package/src/authRedirect.ts +297 -0
- package/src/collection-field-interface/CollectionFieldInterface.ts +200 -0
- package/src/collection-field-interface/CollectionFieldInterfaceManager.ts +177 -0
- package/src/collection-manager/interfaces/checkbox.ts +41 -0
- package/src/collection-manager/interfaces/checkboxGroup.ts +45 -0
- package/src/collection-manager/interfaces/collection.ts +53 -0
- package/src/collection-manager/interfaces/color.ts +34 -0
- package/src/collection-manager/interfaces/createdAt.ts +41 -0
- package/src/collection-manager/interfaces/createdBy.ts +80 -0
- package/src/collection-manager/interfaces/dateOnly.ts +48 -0
- package/src/collection-manager/interfaces/datetime.ts +66 -0
- package/src/collection-manager/interfaces/datetimeNoTz.ts +66 -0
- package/src/collection-manager/interfaces/email.ts +47 -0
- package/src/collection-manager/interfaces/icon.ts +31 -0
- package/src/collection-manager/interfaces/id.ts +61 -0
- package/src/collection-manager/interfaces/index.ts +51 -0
- package/src/collection-manager/interfaces/input.ts +224 -0
- package/src/collection-manager/interfaces/integer.ts +135 -0
- package/src/collection-manager/interfaces/json.tsx +74 -0
- package/src/collection-manager/interfaces/linkTo.ts +120 -0
- package/src/collection-manager/interfaces/m2m.tsx +262 -0
- package/src/collection-manager/interfaces/m2o.tsx +196 -0
- package/src/collection-manager/interfaces/markdown.ts +84 -0
- package/src/collection-manager/interfaces/multipleSelect.ts +52 -0
- package/src/collection-manager/interfaces/nanoid.ts +82 -0
- package/src/collection-manager/interfaces/number.ts +173 -0
- package/src/collection-manager/interfaces/o2m.tsx +217 -0
- package/src/collection-manager/interfaces/o2o.tsx +561 -0
- package/src/collection-manager/interfaces/password.ts +80 -0
- package/src/collection-manager/interfaces/percent.ts +178 -0
- package/src/collection-manager/interfaces/phone.ts +43 -0
- package/src/collection-manager/interfaces/properties/index.ts +582 -0
- package/src/collection-manager/interfaces/properties/operators.ts +352 -0
- package/src/collection-manager/interfaces/radioGroup.ts +37 -0
- package/src/collection-manager/interfaces/richText.ts +84 -0
- package/src/collection-manager/interfaces/select.ts +50 -0
- package/src/collection-manager/interfaces/snowflake-id.ts +61 -0
- package/src/collection-manager/interfaces/subTable.ts +218 -0
- package/src/collection-manager/interfaces/tableoid.ts +53 -0
- package/src/collection-manager/interfaces/textarea.ts +93 -0
- package/src/collection-manager/interfaces/time.ts +37 -0
- package/src/collection-manager/interfaces/types.ts +41 -0
- package/src/collection-manager/interfaces/unixTimestamp.tsx +68 -0
- package/src/collection-manager/interfaces/updatedAt.ts +41 -0
- package/src/collection-manager/interfaces/updatedBy.ts +79 -0
- package/src/collection-manager/interfaces/url.ts +48 -0
- package/src/collection-manager/interfaces/utils/index.ts +20 -0
- package/src/collection-manager/interfaces/uuid.ts +72 -0
- package/src/components/AppComponents.tsx +245 -0
- package/src/components/Icon.tsx +68 -0
- package/src/components/index.ts +2 -0
- package/src/css-variable/CSSVariableProvider.tsx +108 -0
- package/src/flow/FlowModelRepository.ts +222 -0
- package/src/flow/FlowPage.tsx +118 -0
- package/src/flow/__tests__/FlowModelRepository.test.ts +61 -0
- package/src/flow/__tests__/FlowRoute.test.tsx +474 -0
- package/src/flow/__tests__/getKey.test.ts +61 -0
- package/src/flow/__tests__/getViewDiff.test.ts +180 -0
- package/src/flow/__tests__/helpers/mockFlowApp.ts +49 -0
- package/src/flow/__tests__/resolveViewParamsToViewList.test.ts +278 -0
- package/src/flow/actions/__tests__/aclCheckRefresh.test.ts +129 -0
- package/src/flow/actions/__tests__/dataLoadingMode.test.tsx +69 -0
- package/src/flow/actions/__tests__/dataScope.leftMetaTree.test.tsx +192 -0
- package/src/flow/actions/__tests__/fieldLinkageRules.scopeDepth.test.ts +538 -0
- package/src/flow/actions/__tests__/linkageAssignField.legacy.test.ts +470 -0
- package/src/flow/actions/__tests__/linkageRules.assignFieldOptions.test.tsx +56 -0
- package/src/flow/actions/__tests__/linkageRules.runjsTemplateResolution.test.ts +71 -0
- package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +109 -0
- package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +164 -0
- package/src/flow/actions/__tests__/openView.beforeClose.test.tsx +263 -0
- package/src/flow/actions/__tests__/openView.closeDestroy.test.tsx +95 -0
- package/src/flow/actions/__tests__/openView.defineProps.route.test.tsx +152 -0
- package/src/flow/actions/__tests__/openView.subModelKey.test.tsx +95 -0
- package/src/flow/actions/__tests__/setTargetDataScope.leftMetaTree.test.tsx +225 -0
- package/src/flow/actions/__tests__/showMessageNotification.test.ts +79 -0
- package/src/flow/actions/__tests__/subFormFieldLinkageRules.inputArgs.test.ts +173 -0
- package/src/flow/actions/aclCheck.tsx +46 -0
- package/src/flow/actions/aclCheckRefresh.tsx +168 -0
- package/src/flow/actions/afterSuccess.tsx +138 -0
- package/src/flow/actions/blockHeight.tsx +77 -0
- package/src/flow/actions/columnFixed.tsx +35 -0
- package/src/flow/actions/confirm.tsx +63 -0
- package/src/flow/actions/customVariable.tsx +399 -0
- package/src/flow/actions/dataLoadingMode.tsx +61 -0
- package/src/flow/actions/dataScope.tsx +61 -0
- package/src/flow/actions/dateTimeFormat.tsx +188 -0
- package/src/flow/actions/displayFieldComponent.tsx +103 -0
- package/src/flow/actions/fieldComponent.tsx +114 -0
- package/src/flow/actions/filterFormDefaultValues.tsx +134 -0
- package/src/flow/actions/formAssignRules.tsx +117 -0
- package/src/flow/actions/index.ts +55 -0
- package/src/flow/actions/layout.tsx +107 -0
- package/src/flow/actions/linkageRules.tsx +2584 -0
- package/src/flow/actions/linkageRulesRefresh.tsx +82 -0
- package/src/flow/actions/navigateToURL.tsx +142 -0
- package/src/flow/actions/numberFormat.tsx +145 -0
- package/src/flow/actions/openView.tsx +512 -0
- package/src/flow/actions/overflowMode.tsx +36 -0
- package/src/flow/actions/pattern.tsx +122 -0
- package/src/flow/actions/refreshTargetBlocks.tsx +91 -0
- package/src/flow/actions/renderMode.tsx +42 -0
- package/src/flow/actions/required.tsx +70 -0
- package/src/flow/actions/runjs.tsx +48 -0
- package/src/flow/actions/setTargetDataScope.tsx +111 -0
- package/src/flow/actions/showMessage.tsx +155 -0
- package/src/flow/actions/showNotification.tsx +179 -0
- package/src/flow/actions/sortingRules.tsx +125 -0
- package/src/flow/actions/titleField.tsx +141 -0
- package/src/flow/actions/validation.tsx +77 -0
- package/src/flow/admin-shell/AdminLayoutRouteCoordinator.ts +339 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutCompat.tsx +326 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +681 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuFlowUtils.ts +338 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +774 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuUtils.tsx +964 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutModel.tsx +330 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutSlotModels.tsx +127 -0
- package/src/flow/admin-shell/admin-layout/HelpLite.tsx +193 -0
- package/src/flow/admin-shell/admin-layout/PinnedPluginListLite.tsx +129 -0
- package/src/flow/admin-shell/admin-layout/ResetThemeTokenAndKeepAlgorithm.tsx +30 -0
- package/src/flow/admin-shell/admin-layout/TopbarActionsBar.tsx +211 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +2023 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +284 -0
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +211 -0
- package/src/flow/admin-shell/admin-layout/__tests__/flowSettingsPreference.test.ts +44 -0
- package/src/flow/admin-shell/admin-layout/constants.ts +10 -0
- package/src/flow/admin-shell/admin-layout/flowSettingsPreference.ts +54 -0
- package/src/flow/admin-shell/admin-layout/index.ts +20 -0
- package/src/flow/admin-shell/admin-layout/mobile-layout.tsx +35 -0
- package/src/flow/admin-shell/admin-layout/mobileMenuNavigation.ts +30 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.test.ts +214 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.ts +260 -0
- package/src/flow/admin-shell/admin-layout/useApplications.tsx +15 -0
- package/src/flow/admin-shell/useAdminLayoutRoutePage.ts +56 -0
- package/src/flow/common/Liquid.tsx +148 -0
- package/src/flow/common/Markdown/Display.tsx +213 -0
- package/src/flow/common/Markdown/Edit.tsx +437 -0
- package/src/flow/common/Markdown/Markdown.tsx +44 -0
- package/src/flow/common/Markdown/style.ts +53 -0
- package/src/flow/common/Markdown/useCDN.ts +21 -0
- package/src/flow/components/AdminLayout.tsx +167 -0
- package/src/flow/components/BlockItemCard.tsx +204 -0
- package/src/flow/components/ConditionBuilder.tsx +40 -0
- package/src/flow/components/DefaultValue.tsx +732 -0
- package/src/flow/components/DynamicFlowsIcon.tsx +764 -0
- package/src/flow/components/EllipsisWithTooltip.tsx +106 -0
- package/src/flow/components/ExpiresRadio/index.tsx +139 -0
- package/src/flow/components/FieldAssignEditor.tsx +80 -0
- package/src/flow/components/FieldAssignExactDatePicker.tsx +225 -0
- package/src/flow/components/FieldAssignRulesEditor.tsx +1013 -0
- package/src/flow/components/FieldAssignValueInput.tsx +1490 -0
- package/src/flow/components/FlowRoute.tsx +173 -0
- package/src/flow/components/Grid/index.tsx +158 -0
- package/src/flow/components/JsonEditor.tsx +53 -0
- package/src/flow/components/RunJSValueEditor.tsx +50 -0
- package/src/flow/components/SkeletonFallback.tsx +19 -0
- package/src/flow/components/TextAreaWithContextSelector.tsx +139 -0
- package/src/flow/components/__tests__/DefaultValue.test.tsx +1289 -0
- package/src/flow/components/__tests__/DynamicFlowsIcon.test.tsx +193 -0
- package/src/flow/components/__tests__/FieldAssignExactDatePicker.test.tsx +121 -0
- package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +758 -0
- package/src/flow/components/__tests__/FieldAssignValueInput.exactDate.test.tsx +180 -0
- package/src/flow/components/__tests__/FieldAssignValueInput.path.test.ts +298 -0
- package/src/flow/components/__tests__/fieldAssignOptions.test.ts +97 -0
- package/src/flow/components/code-editor/__tests__/SnippetsDrawer.test.tsx +51 -0
- package/src/flow/components/code-editor/__tests__/errorHelpers.test.ts +37 -0
- package/src/flow/components/code-editor/__tests__/javascriptHtmlTemplate.test.ts +101 -0
- package/src/flow/components/code-editor/__tests__/linter.test.ts +106 -0
- package/src/flow/components/code-editor/__tests__/resolveScenes.test.ts +44 -0
- package/src/flow/components/code-editor/__tests__/runjsCompletionSource.test.ts +251 -0
- package/src/flow/components/code-editor/__tests__/runjsCompletions.test.ts +245 -0
- package/src/flow/components/code-editor/__tests__/runjsDiagnostics.test.ts +233 -0
- package/src/flow/components/code-editor/__tests__/runjsLocales.test.ts +24 -0
- package/src/flow/components/code-editor/__tests__/useCodeRunner.test.tsx +273 -0
- package/src/flow/components/code-editor/core/EditorCore.tsx +216 -0
- package/src/flow/components/code-editor/core/tooltipParent.ts +28 -0
- package/src/flow/components/code-editor/errorHelpers.ts +92 -0
- package/src/flow/components/code-editor/extension/CodeEditorExtension.tsx +23 -0
- package/src/flow/components/code-editor/extension/index.ts +10 -0
- package/src/flow/components/code-editor/formatDocInfo.ts +98 -0
- package/src/flow/components/code-editor/hooks/useCodeRunner.ts +333 -0
- package/src/flow/components/code-editor/hooks/useRunJSDocCompletions.ts +41 -0
- package/src/flow/components/code-editor/htmlCompletion.ts +155 -0
- package/src/flow/components/code-editor/index.tsx +286 -0
- package/src/flow/components/code-editor/javascriptCompletion.ts +121 -0
- package/src/flow/components/code-editor/javascriptHtmlTemplate.ts +68 -0
- package/src/flow/components/code-editor/jsxCompletion.ts +244 -0
- package/src/flow/components/code-editor/linter.ts +885 -0
- package/src/flow/components/code-editor/panels/LogsPanel.tsx +68 -0
- package/src/flow/components/code-editor/panels/RightExtra.tsx +71 -0
- package/src/flow/components/code-editor/panels/SnippetsDrawer.tsx +104 -0
- package/src/flow/components/code-editor/resolveScenes.ts +38 -0
- package/src/flow/components/code-editor/runjsCompletionSource.ts +456 -0
- package/src/flow/components/code-editor/runjsCompletions.ts +306 -0
- package/src/flow/components/code-editor/runjsDiagnostics.ts +1077 -0
- package/src/flow/components/code-editor/types.ts +36 -0
- package/src/flow/components/drag-drop/Sortable.tsx +48 -0
- package/src/flow/components/drag-drop/SortableItem.tsx +28 -0
- package/src/flow/components/drag-drop/index.ts +11 -0
- package/src/flow/components/fieldAssignOptions.ts +212 -0
- package/src/flow/components/filter/FilterContainer.tsx +123 -0
- package/src/flow/components/filter/FilterGroup.tsx +320 -0
- package/src/flow/components/filter/FilterItem.tsx +144 -0
- package/src/flow/components/filter/LinkageFilterItem.tsx +511 -0
- package/src/flow/components/filter/VariableFilterItem.tsx +684 -0
- package/src/flow/components/filter/__tests__/FilterGroup.test.tsx +143 -0
- package/src/flow/components/filter/__tests__/LinkageFilterItem.metaTree.test.ts +167 -0
- package/src/flow/components/filter/__tests__/LinkageFilterItem.test.tsx +301 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.leftMetaTree.test.tsx +196 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +406 -0
- package/src/flow/components/filter/fieldsToOptions.ts +71 -0
- package/src/flow/components/filter/index.ts +17 -0
- package/src/flow/components/index.tsx +16 -0
- package/src/flow/components/placeholders/BlockPlaceholder.tsx +68 -0
- package/src/flow/components/placeholders/FieldPlaceholder.tsx +32 -0
- package/src/flow/components/useAssociationTitleFieldSync.ts +49 -0
- package/src/flow/flows/editMarkdownFlow.tsx +143 -0
- package/src/flow/flows/openViewFlow.ts +89 -0
- package/src/flow/formily/ReactiveField.tsx +106 -0
- package/src/flow/formily/index.tsx +8 -0
- package/src/flow/getViewDiffAndUpdateHidden.tsx +86 -0
- package/src/flow/index.ts +108 -0
- package/src/flow/internal/components/Markdown/DisplayMarkdown.tsx +85 -0
- package/src/flow/internal/components/Markdown/markdown-it-plugins/mermaidPlugin.ts +85 -0
- package/src/flow/internal/components/Markdown/md.ts +24 -0
- package/src/flow/internal/components/Markdown/style.ts +165 -0
- package/src/flow/internal/components/Markdown/util.ts +45 -0
- package/src/flow/internal/constants/HeightMode.ts +14 -0
- package/src/flow/internal/index.ts +16 -0
- package/src/flow/internal/utils/__tests__/associationValueCoercion.test.ts +57 -0
- package/src/flow/internal/utils/__tests__/enumOptionsUtils.test.ts +58 -0
- package/src/flow/internal/utils/__tests__/modelUtils.test.ts +66 -0
- package/src/flow/internal/utils/__tests__/rebuildFieldSubModel.test.ts +109 -0
- package/src/flow/internal/utils/__tests__/titleFieldQuickSync.test.ts +93 -0
- package/src/flow/internal/utils/associationValueCoercion.ts +29 -0
- package/src/flow/internal/utils/dateTimeUtils.ts +53 -0
- package/src/flow/internal/utils/enumOptionsUtils.ts +66 -0
- package/src/flow/internal/utils/modelUtils.ts +158 -0
- package/src/flow/internal/utils/operatorSchemaHelper.ts +30 -0
- package/src/flow/internal/utils/rebuildFieldSubModel.ts +94 -0
- package/src/flow/internal/utils/saveStepParamsWithSubModels.ts +40 -0
- package/src/flow/internal/utils/titleFieldQuickSync.ts +95 -0
- package/src/flow/models/actions/AddChildActionModel.tsx +69 -0
- package/src/flow/models/actions/AddNewActionModel.tsx +32 -0
- package/src/flow/models/actions/BulkDeleteActionModel.tsx +61 -0
- package/src/flow/models/actions/DeleteActionModel.tsx +61 -0
- package/src/flow/models/actions/EditActionModel.tsx +31 -0
- package/src/flow/models/actions/ExpandCollapseActionModel.tsx +113 -0
- package/src/flow/models/actions/FilterActionModel.tsx +320 -0
- package/src/flow/models/actions/JSActionModel.tsx +84 -0
- package/src/flow/models/actions/JSCollectionActionModel.tsx +90 -0
- package/src/flow/models/actions/JSItemActionModel.tsx +166 -0
- package/src/flow/models/actions/JSRecordActionModel.tsx +90 -0
- package/src/flow/models/actions/LinkActionModel.tsx +198 -0
- package/src/flow/models/actions/LinkActionUtils.ts +65 -0
- package/src/flow/models/actions/PopupCollectionActionModel.tsx +25 -0
- package/src/flow/models/actions/RefreshActionModel.tsx +45 -0
- package/src/flow/models/actions/UpdateRecordActionModel.tsx +201 -0
- package/src/flow/models/actions/UpdateRecordActionUtils.ts +89 -0
- package/src/flow/models/actions/ViewActionModel.tsx +31 -0
- package/src/flow/models/actions/__tests__/AssignFormRefill.test.ts +55 -0
- package/src/flow/models/actions/__tests__/JSItemActionModel.test.tsx +85 -0
- package/src/flow/models/actions/__tests__/LinkActionModel.test.ts +110 -0
- package/src/flow/models/actions/__tests__/UpdateRecordActionModel.test.ts +72 -0
- package/src/flow/models/actions/index.ts +26 -0
- package/src/flow/models/actions/joinUrlSearch.ts +42 -0
- package/src/flow/models/base/ActionGroupModel.tsx +10 -0
- package/src/flow/models/base/ActionGroupModelCore.tsx +117 -0
- package/src/flow/models/base/ActionModel.tsx +141 -0
- package/src/flow/models/base/ActionModelCore.tsx +174 -0
- package/src/flow/models/base/AssociationFieldGroupModel.tsx +100 -0
- package/src/flow/models/base/BlockGridModel.tsx +144 -0
- package/src/flow/models/base/BlockModel.tsx +247 -0
- package/src/flow/models/base/CollectionActionModel.tsx +23 -0
- package/src/flow/models/base/CollectionBlockModel.tsx +703 -0
- package/src/flow/models/base/CommonItemModel.tsx +12 -0
- package/src/flow/models/base/DataBlockModel.tsx +41 -0
- package/src/flow/models/base/FieldModel.tsx +26 -0
- package/src/flow/models/base/FilterBlockModel.tsx +15 -0
- package/src/flow/models/base/GridModel.tsx +1053 -0
- package/src/flow/models/base/PageModel/ChildPageModel.tsx +114 -0
- package/src/flow/models/base/PageModel/MainPageModel.tsx +32 -0
- package/src/flow/models/base/PageModel/OldPageModel.tsx +97 -0
- package/src/flow/models/base/PageModel/PageModel.tsx +486 -0
- package/src/flow/models/base/PageModel/PageTabModel.tsx +259 -0
- package/src/flow/models/base/PageModel/RootPageModel.tsx +161 -0
- package/src/flow/models/base/PageModel/SubPageModel.tsx +32 -0
- package/src/flow/models/base/PageModel/__tests__/ChildPageModel.test.ts +196 -0
- package/src/flow/models/base/PageModel/__tests__/PageModel.beforeCloseGuard.test.ts +111 -0
- package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +753 -0
- package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +225 -0
- package/src/flow/models/base/PageModel/__tests__/RootPageModel.test.ts +242 -0
- package/src/flow/models/base/PageModel/closeGuard.ts +48 -0
- package/src/flow/models/base/PageModel/index.tsx +16 -0
- package/src/flow/models/base/PopupActionModel.tsx +26 -0
- package/src/flow/models/base/RecordActionModel.tsx +23 -0
- package/src/flow/models/base/RouteModel.tsx +29 -0
- package/src/flow/models/base/__tests__/ActionGroupModel.test.ts +200 -0
- package/src/flow/models/base/__tests__/BlockGridModel.newScene.test.ts +37 -0
- package/src/flow/models/base/__tests__/BlockGridModel.selectSceneAddBlock.test.ts +83 -0
- package/src/flow/models/base/__tests__/CollectionBlockModel.capability.test.ts +96 -0
- package/src/flow/models/base/__tests__/CollectionBlockModel.dirtyRefresh.association.test.ts +110 -0
- package/src/flow/models/base/__tests__/CollectionBlockModel.initialBeforeRenderRefresh.test.ts +131 -0
- package/src/flow/models/base/__tests__/CollectionBlockModel.newScene.associatedRecordsVisibility.test.ts +161 -0
- package/src/flow/models/base/__tests__/CollectionBlockModel.title.test.ts +95 -0
- package/src/flow/models/base/__tests__/GridModel.computeOverlayRect.test.ts +423 -0
- package/src/flow/models/base/__tests__/GridModel.dragOverlay.test.ts +129 -0
- package/src/flow/models/base/__tests__/GridModel.dragSnapshotContainer.test.ts +107 -0
- package/src/flow/models/base/__tests__/GridModel.mergeRows.test.ts +107 -0
- package/src/flow/models/base/__tests__/GridModel.recalculateGridSizes.test.ts +67 -0
- package/src/flow/models/base/__tests__/GridModel.visibleLayout.test.ts +217 -0
- package/src/flow/models/base/__tests__/transformRowsToSingleColumn.test.ts +58 -0
- package/src/flow/models/base/index.ts +26 -0
- package/src/flow/models/blocks/assign-form/AssignFormGridModel.tsx +161 -0
- package/src/flow/models/blocks/assign-form/AssignFormItemModel.tsx +409 -0
- package/src/flow/models/blocks/assign-form/AssignFormModel.tsx +96 -0
- package/src/flow/models/blocks/assign-form/index.ts +12 -0
- package/src/flow/models/blocks/details/DetailsAssociationFieldGroupModel.tsx +18 -0
- package/src/flow/models/blocks/details/DetailsBlockModel.tsx +404 -0
- package/src/flow/models/blocks/details/DetailsCustomItemModel.tsx +51 -0
- package/src/flow/models/blocks/details/DetailsGridModel.tsx +106 -0
- package/src/flow/models/blocks/details/DetailsItemModel.tsx +384 -0
- package/src/flow/models/blocks/details/DetailsJSFieldItemModel.tsx +37 -0
- package/src/flow/models/blocks/details/__tests__/DetailsBlockModel.blockHeight.test.tsx +139 -0
- package/src/flow/models/blocks/details/__tests__/DetailsBlockModel.initialPaginationChangeRefresh.test.ts +128 -0
- package/src/flow/models/blocks/details/__tests__/DetailsItemModel.value.test.ts +49 -0
- package/src/flow/models/blocks/details/index.ts +16 -0
- package/src/flow/models/blocks/details/utils.ts +67 -0
- package/src/flow/models/blocks/filter-form/FieldModelSelect.tsx +59 -0
- package/src/flow/models/blocks/filter-form/FieldOperatorSelect.tsx +109 -0
- package/src/flow/models/blocks/filter-form/FilterFormActionGroupModel.tsx +15 -0
- package/src/flow/models/blocks/filter-form/FilterFormActionModel.tsx +12 -0
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +334 -0
- package/src/flow/models/blocks/filter-form/FilterFormCollapseActionModel.tsx +132 -0
- package/src/flow/models/blocks/filter-form/FilterFormCustomItemModel.tsx +42 -0
- package/src/flow/models/blocks/filter-form/FilterFormGridModel.tsx +218 -0
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +780 -0
- package/src/flow/models/blocks/filter-form/FilterFormJSActionModel.tsx +72 -0
- package/src/flow/models/blocks/filter-form/FilterFormResetActionModel.tsx +52 -0
- package/src/flow/models/blocks/filter-form/FilterFormSubmitActionModel.tsx +49 -0
- package/src/flow/models/blocks/filter-form/SourceCascader.tsx +137 -0
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormGridModel.onModelCreated.test.ts +247 -0
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormGridModel.toggleFormFieldsCollapse.test.ts +143 -0
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +329 -0
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.getFilterValue.test.ts +117 -0
- package/src/flow/models/blocks/filter-form/__tests__/customFieldOperators.test.tsx +642 -0
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +19 -0
- package/src/flow/models/blocks/filter-form/__tests__/legacyDefaultValueMigration.test.ts +107 -0
- package/src/flow/models/blocks/filter-form/__tests__/valueNormalization.test.ts +50 -0
- package/src/flow/models/blocks/filter-form/customFieldOperators.ts +225 -0
- package/src/flow/models/blocks/filter-form/fields/FieldComponentProps.tsx +474 -0
- package/src/flow/models/blocks/filter-form/fields/FilterFormCustomFieldModel.tsx +411 -0
- package/src/flow/models/blocks/filter-form/fields/FilterFormCustomRecordSelectFieldModel.tsx +543 -0
- package/src/flow/models/blocks/filter-form/fields/FilterFormFieldModel.tsx +12 -0
- package/src/flow/models/blocks/filter-form/fields/FilterFormRecordSelectFieldModel.tsx +85 -0
- package/src/flow/models/blocks/filter-form/fields/__tests__/FilterFormCustomFieldModel.recordSelect.test.tsx +633 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/DateOnlyFilterFieldModel.tsx +42 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/DateTimeFilterFieldModel.tsx +17 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/DateTimeNoTzFilterFieldModel.tsx +30 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/DateTimeTzFilterFieldModel.tsx +48 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/components/DateFilterDynamicComponent.tsx +184 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/components/FilterDatePicker.tsx +108 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/components/FilterRangePicker.tsx +84 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/components/__tests__/FilterDatePickers.test.tsx +121 -0
- package/src/flow/models/blocks/filter-form/fields/date-time/index.ts +13 -0
- package/src/flow/models/blocks/filter-form/fields/index.ts +14 -0
- package/src/flow/models/blocks/filter-form/index.ts +25 -0
- package/src/flow/models/blocks/filter-form/legacyDefaultValueMigration.ts +36 -0
- package/src/flow/models/blocks/filter-form/valueNormalization.ts +92 -0
- package/src/flow/models/blocks/filter-manager/FilterManager.ts +488 -0
- package/src/flow/models/blocks/filter-manager/__tests__/FilterManager.bindToTarget.test.ts +446 -0
- package/src/flow/models/blocks/filter-manager/__tests__/FilterManager.test.ts +627 -0
- package/src/flow/models/blocks/filter-manager/__tests__/FilterManager.unbindFromTarget.test.ts +242 -0
- package/src/flow/models/blocks/filter-manager/__tests__/getDefaultOperator.test.ts +69 -0
- package/src/flow/models/blocks/filter-manager/flow-actions/__tests__/defaultOperator.test.tsx +58 -0
- package/src/flow/models/blocks/filter-manager/flow-actions/connectFields.tsx +488 -0
- package/src/flow/models/blocks/filter-manager/flow-actions/customizeFilterRender.tsx +78 -0
- package/src/flow/models/blocks/filter-manager/flow-actions/defaultOperator.tsx +48 -0
- package/src/flow/models/blocks/filter-manager/flow-actions/index.ts +13 -0
- package/src/flow/models/blocks/filter-manager/flow-actions/operatorComponentProps.tsx +47 -0
- package/src/flow/models/blocks/filter-manager/index.ts +13 -0
- package/src/flow/models/blocks/filter-manager/utils.ts +71 -0
- package/src/flow/models/blocks/form/CreateFormModel.tsx +124 -0
- package/src/flow/models/blocks/form/EditFormModel.tsx +298 -0
- package/src/flow/models/blocks/form/FormActionGroupModel.tsx +15 -0
- package/src/flow/models/blocks/form/FormActionModel.tsx +118 -0
- package/src/flow/models/blocks/form/FormAssociationFieldGroupModel.tsx +18 -0
- package/src/flow/models/blocks/form/FormAssociationItemModel.tsx +359 -0
- package/src/flow/models/blocks/form/FormBlockModel.tsx +736 -0
- package/src/flow/models/blocks/form/FormCustomItemModel.tsx +54 -0
- package/src/flow/models/blocks/form/FormGridModel.tsx +106 -0
- package/src/flow/models/blocks/form/FormItemModel.tsx +472 -0
- package/src/flow/models/blocks/form/FormJSFieldItemModel.tsx +36 -0
- package/src/flow/models/blocks/form/JSFormActionModel.tsx +85 -0
- package/src/flow/models/blocks/form/QuickEditFormModel.tsx +303 -0
- package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +813 -0
- package/src/flow/models/blocks/form/__tests__/QuickEditFormModel.quickEdit.test.ts +69 -0
- package/src/flow/models/blocks/form/__tests__/assignRulesUpdateAssociationValues.test.ts +81 -0
- package/src/flow/models/blocks/form/__tests__/dynamicNamePath.test.ts +33 -0
- package/src/flow/models/blocks/form/__tests__/legacyDefaultValueMigration.test.ts +135 -0
- package/src/flow/models/blocks/form/__tests__/submitValues.test.ts +224 -0
- package/src/flow/models/blocks/form/assignRulesUpdateAssociationValues.ts +73 -0
- package/src/flow/models/blocks/form/dynamicNamePath.ts +68 -0
- package/src/flow/models/blocks/form/index.tsx +23 -0
- package/src/flow/models/blocks/form/legacyDefaultValueMigration.ts +32 -0
- package/src/flow/models/blocks/form/submitHandler.ts +63 -0
- package/src/flow/models/blocks/form/submitValues.ts +227 -0
- package/src/flow/models/blocks/form/value-runtime/__tests__/deps.test.ts +28 -0
- package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +3270 -0
- package/src/flow/models/blocks/form/value-runtime/__tests__/subtable-nested.test.ts +103 -0
- package/src/flow/models/blocks/form/value-runtime/conditions.ts +22 -0
- package/src/flow/models/blocks/form/value-runtime/deps.ts +181 -0
- package/src/flow/models/blocks/form/value-runtime/form-patch.ts +83 -0
- package/src/flow/models/blocks/form/value-runtime/index.ts +12 -0
- package/src/flow/models/blocks/form/value-runtime/path.ts +144 -0
- package/src/flow/models/blocks/form/value-runtime/rules.ts +1930 -0
- package/src/flow/models/blocks/form/value-runtime/runtime.ts +1118 -0
- package/src/flow/models/blocks/form/value-runtime/types.ts +72 -0
- package/src/flow/models/blocks/form/value-runtime/utils.ts +25 -0
- package/src/flow/models/blocks/index.ts +17 -0
- package/src/flow/models/blocks/js-block/JSBlock.tsx +180 -0
- package/src/flow/models/blocks/js-block/index.ts +10 -0
- package/src/flow/models/blocks/shared/legacyDefaultValueMigrationBase.ts +176 -0
- package/src/flow/models/blocks/table/JSColumnModel.tsx +279 -0
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +238 -0
- package/src/flow/models/blocks/table/TableAssociationFieldGroupModel.tsx +18 -0
- package/src/flow/models/blocks/table/TableBlockModel.tsx +1073 -0
- package/src/flow/models/blocks/table/TableColumnModel.tsx +555 -0
- package/src/flow/models/blocks/table/TableCustomColumnModel.tsx +116 -0
- package/src/flow/models/blocks/table/TableJSFieldItemModel.tsx +38 -0
- package/src/flow/models/blocks/table/TableSelectModel.tsx +75 -0
- package/src/flow/models/blocks/table/__tests__/TableActionsColumnModel.test.tsx +282 -0
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.blockHeight.test.tsx +120 -0
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.popupSourceId.test.ts +87 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +72 -0
- package/src/flow/models/blocks/table/__tests__/sortUtils.test.ts +58 -0
- package/src/flow/models/blocks/table/dragSort/dragSortComponents.tsx +90 -0
- package/src/flow/models/blocks/table/dragSort/dragSortHooks.tsx +130 -0
- package/src/flow/models/blocks/table/dragSort/dragSortSettings.ts +62 -0
- package/src/flow/models/blocks/table/dragSort/dragSortUtils.ts +57 -0
- package/src/flow/models/blocks/table/dragSort/index.ts +13 -0
- package/src/flow/models/blocks/table/index.ts +18 -0
- package/src/flow/models/blocks/table/sortUtils.ts +52 -0
- package/src/flow/models/blocks/table/utils.ts +125 -0
- package/src/flow/models/blocks/utils/__tests__/transformChildrenToJS.test.ts +216 -0
- package/src/flow/models/blocks/utils/transformChildrenToJS.ts +158 -0
- package/src/flow/models/fields/AssociationFieldModel/AssociationFieldModel.tsx +47 -0
- package/src/flow/models/fields/AssociationFieldModel/CascadeSelectFieldModel.tsx +822 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableActionGroupModel.tsx +19 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableActionsColumnModel.tsx +212 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +909 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableEditActionModel.tsx +383 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableFormSubmitActionModel.tsx +121 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableRemoveActionModel.tsx +101 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/__tests__/popupSubTableBeforeClose.test.ts +98 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/popupSubTableBeforeClose.ts +158 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/blocks/PopupSubTableFormModel.tsx +235 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/index.tsx +18 -0
- package/src/flow/models/fields/AssociationFieldModel/RecordPickerFieldModel.tsx +514 -0
- package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +1005 -0
- package/src/flow/models/fields/AssociationFieldModel/SubFormFieldModel.tsx +649 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +865 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.tsx +259 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.tsx +395 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/rowIdentity.ts +70 -0
- package/src/flow/models/fields/AssociationFieldModel/__tests__/RecordPickerFieldModel.itemContext.test.ts +248 -0
- package/src/flow/models/fields/AssociationFieldModel/__tests__/SubTableRowIdentity.test.ts +45 -0
- package/src/flow/models/fields/AssociationFieldModel/__tests__/recordSelectShared.fieldNames.test.ts +60 -0
- package/src/flow/models/fields/AssociationFieldModel/index.tsx +16 -0
- package/src/flow/models/fields/AssociationFieldModel/itemChain.ts +362 -0
- package/src/flow/models/fields/AssociationFieldModel/recordSelectShared.tsx +283 -0
- package/src/flow/models/fields/CheckboxFieldModel.tsx +31 -0
- package/src/flow/models/fields/CheckboxGroupFieldModel.tsx +25 -0
- package/src/flow/models/fields/ClickableFieldModel.tsx +286 -0
- package/src/flow/models/fields/CollectionSelectorFieldModel.tsx +94 -0
- package/src/flow/models/fields/ColorFieldModel.tsx +61 -0
- package/src/flow/models/fields/DateTimeFieldModel/DateOnlyFieldModel.tsx +61 -0
- package/src/flow/models/fields/DateTimeFieldModel/DateTimeFieldModel.tsx +26 -0
- package/src/flow/models/fields/DateTimeFieldModel/DateTimeNoTzFieldModel.tsx +53 -0
- package/src/flow/models/fields/DateTimeFieldModel/DateTimeTzFieldModel.tsx +96 -0
- package/src/flow/models/fields/DateTimeFieldModel/index.ts +12 -0
- package/src/flow/models/fields/DisplayAssociationField/DisplaySubItemFieldModel.tsx +70 -0
- package/src/flow/models/fields/DisplayAssociationField/DisplaySubListFieldModel.tsx +136 -0
- package/src/flow/models/fields/DisplayAssociationField/DisplaySubTableFieldModel.tsx +271 -0
- package/src/flow/models/fields/DisplayAssociationField/__tests__/DisplaySubListFieldModel.utils.test.ts +41 -0
- package/src/flow/models/fields/DisplayAssociationField/displaySubListUtils.ts +29 -0
- package/src/flow/models/fields/DisplayAssociationField/index.tsx +12 -0
- package/src/flow/models/fields/DisplayCheckboxFieldModel.tsx +36 -0
- package/src/flow/models/fields/DisplayColorFieldModel.tsx +45 -0
- package/src/flow/models/fields/DisplayDateTimeFieldModel.tsx +59 -0
- package/src/flow/models/fields/DisplayEnumFieldModel.tsx +123 -0
- package/src/flow/models/fields/DisplayHtmlFieldModel.tsx +39 -0
- package/src/flow/models/fields/DisplayIconFieldModel.tsx +24 -0
- package/src/flow/models/fields/DisplayJSONFieldModel.tsx +103 -0
- package/src/flow/models/fields/DisplayNumberFieldModel.tsx +239 -0
- package/src/flow/models/fields/DisplayPasswordFieldModel.tsx +30 -0
- package/src/flow/models/fields/DisplayPercentFieldModel.tsx +165 -0
- package/src/flow/models/fields/DisplayTextFieldModel.tsx +51 -0
- package/src/flow/models/fields/DisplayTimeFieldModel.tsx +47 -0
- package/src/flow/models/fields/DisplayTitleFieldModel.tsx +79 -0
- package/src/flow/models/fields/DisplayURLFieldModel.tsx +41 -0
- package/src/flow/models/fields/DividerItemModel.tsx +100 -0
- package/src/flow/models/fields/IconFieldModel.tsx +172 -0
- package/src/flow/models/fields/InputFieldModel.tsx +65 -0
- package/src/flow/models/fields/JSEditableFieldModel.tsx +219 -0
- package/src/flow/models/fields/JSFieldModel.tsx +184 -0
- package/src/flow/models/fields/JSItemModel.tsx +163 -0
- package/src/flow/models/fields/JsonFieldModel.tsx +121 -0
- package/src/flow/models/fields/MarkdownItemModel.tsx +68 -0
- package/src/flow/models/fields/NumberFieldModel.tsx +68 -0
- package/src/flow/models/fields/PasswordFieldModel.tsx +53 -0
- package/src/flow/models/fields/PercentFieldModel.tsx +53 -0
- package/src/flow/models/fields/RadioGroupFieldModel.tsx +26 -0
- package/src/flow/models/fields/RichTextFieldModel/index.tsx +115 -0
- package/src/flow/models/fields/RichTextFieldModel/registerFontSize.tsx +18 -0
- package/src/flow/models/fields/RichTextFieldModel/registerImageResize.tsx +56 -0
- package/src/flow/models/fields/RichTextFieldModel/registerSmartBreak.tsx +90 -0
- package/src/flow/models/fields/RichTextFieldModel/style.ts +493 -0
- package/src/flow/models/fields/SelectFieldModel.tsx +136 -0
- package/src/flow/models/fields/TextareaFieldModel.tsx +31 -0
- package/src/flow/models/fields/TimeFieldModel.tsx +66 -0
- package/src/flow/models/fields/VariableFieldFormModel.tsx +67 -0
- package/src/flow/models/fields/index.ts +52 -0
- package/src/flow/models/fields/mobile-components/MobileDatePicker.tsx +109 -0
- package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +319 -0
- package/src/flow/models/fields/mobile-components/MobileSelect.tsx +93 -0
- package/src/flow/models/fields/mobile-components/MobileTimePicker.tsx +37 -0
- package/src/flow/models/index.ts +14 -0
- package/src/flow/models/topbar/TopbarActionModel.tsx +414 -0
- package/src/flow/models/topbar/UserCenterTopbarActionModel.tsx +592 -0
- package/src/flow/models/topbar/index.ts +11 -0
- package/src/flow/models/utils/resolveRunJsParams.ts +24 -0
- package/src/flow/resolveViewParamsToViewList.tsx +79 -0
- package/src/flow/system-settings/SystemSettingsSource.ts +155 -0
- package/src/flow/system-settings/index.ts +11 -0
- package/src/flow/system-settings/useSystemSettings.tsx +51 -0
- package/src/flow/utils/__tests__/actionCapability.test.ts +79 -0
- package/src/flow/utils/__tests__/dispatchEventDeep.test.ts +72 -0
- package/src/flow/utils/__tests__/pagination.test.ts +64 -0
- package/src/flow/utils/actionCapability.ts +150 -0
- package/src/flow/utils/blockUtils.ts +32 -0
- package/src/flow/utils/dispatchEventDeep.ts +66 -0
- package/src/flow/utils/index.ts +12 -0
- package/src/flow/utils/pagination.ts +110 -0
- package/src/flow/utils/useJsonTemplateResolver.ts +25 -0
- package/src/flow-compat/ColorPicker.tsx +88 -0
- package/src/flow-compat/FieldValidation.tsx +598 -0
- package/src/flow-compat/HighPerformanceSpin.tsx +45 -0
- package/src/flow-compat/Icon.tsx +11 -0
- package/src/flow-compat/IconPicker.tsx +186 -0
- package/src/flow-compat/Password.tsx +78 -0
- package/src/flow-compat/PasswordStrength.tsx +27 -0
- package/src/flow-compat/Popover.tsx +60 -0
- package/src/flow-compat/data.ts +21 -0
- package/src/flow-compat/date.ts +116 -0
- package/src/flow-compat/fieldValidationConstants.ts +305 -0
- package/src/flow-compat/index.ts +28 -0
- package/src/flow-compat/lazy.tsx +110 -0
- package/src/flow-compat/operators.ts +367 -0
- package/src/flow-compat/passwordUtils.ts +153 -0
- package/src/flow-compat/routeTypes.ts +61 -0
- package/src/flow-compat/useFullscreenOverlay.ts +139 -0
- package/src/flow-compat/zIndexContext.tsx +28 -0
- package/src/hooks/useApp.ts +5 -3
- package/src/hooks/usePlugin.ts +2 -2
- package/src/i18n.ts +25 -0
- package/src/index.ts +20 -0
- package/src/locale/languageCodes.ts +83 -0
- package/src/nocobase-buildin-plugin/index.tsx +318 -0
- package/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts +61 -0
- package/src/nocobase-buildin-plugin/plugins/dayjsLocale.ts +77 -0
- package/src/nocobase-buildin-plugin/plugins/loadConstrueLocale.ts +182 -0
- package/src/react-is.d.ts +12 -0
- package/src/settings-center/AdminSettingsLayout.tsx +333 -0
- package/src/settings-center/AdminSettingsLayoutModel.tsx +32 -0
- package/src/settings-center/PluginManagerPage.tsx +162 -0
- package/src/settings-center/SystemSettingsPage.tsx +298 -0
- package/src/settings-center/index.ts +14 -0
- package/src/settings-center/utils.tsx +277 -0
- package/src/theme/AntdAppProvider.tsx +52 -0
- package/src/theme/compatOldTheme.ts +21 -0
- package/src/theme/customAlgorithm.ts +43 -0
- package/src/theme/defaultTheme.ts +32 -0
- package/src/theme/index.tsx +104 -0
- package/src/theme/type.ts +50 -0
- package/src/utils/globalDeps.ts +3 -0
- package/src/utils/index.tsx +8 -4
- package/src/utils/remotePlugins.ts +10 -13
- package/lib/Application.d.ts +0 -124
- package/lib/Application.js +0 -499
- package/lib/MockApplication.d.ts +0 -16
- package/lib/MockApplication.js +0 -96
- package/lib/Plugin.d.ts +0 -33
- package/lib/Plugin.js +0 -89
- package/lib/PluginManager.d.ts +0 -46
- package/lib/PluginManager.js +0 -114
- package/lib/PluginSettingsManager.d.ts +0 -68
- package/lib/PluginSettingsManager.js +0 -149
- package/lib/RouterManager.d.ts +0 -69
- package/lib/RouterManager.js +0 -231
- package/lib/WebSocketClient.d.ts +0 -45
- package/lib/WebSocketClient.js +0 -217
- package/lib/components/BlankComponent.js +0 -48
- package/lib/components/MainComponent.js +0 -54
- package/lib/components/RouterBridge.js +0 -66
- package/lib/components/RouterContextCleaner.js +0 -61
- package/lib/components/index.js +0 -32
- package/lib/context.js +0 -38
- package/lib/hooks/index.js +0 -34
- package/lib/hooks/useApp.js +0 -41
- package/lib/hooks/usePlugin.js +0 -42
- package/lib/hooks/useRouter.js +0 -41
- package/lib/utils/globalDeps.js +0 -82
- package/lib/utils/index.js +0 -79
- package/lib/utils/remotePlugins.d.ts +0 -44
- package/lib/utils/remotePlugins.js +0 -131
- package/lib/utils/requirejs.js +0 -1361
- package/lib/utils/types.d.ts +0 -330
- package/lib/utils/types.js +0 -28
|
@@ -0,0 +1,2584 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ActionScene,
|
|
12
|
+
defineAction,
|
|
13
|
+
tExpr,
|
|
14
|
+
FlowContext,
|
|
15
|
+
FlowModel,
|
|
16
|
+
FlowRuntimeContext,
|
|
17
|
+
useFlowContext,
|
|
18
|
+
useFlowEngine,
|
|
19
|
+
createSafeWindow,
|
|
20
|
+
createSafeDocument,
|
|
21
|
+
createSafeNavigator,
|
|
22
|
+
observer,
|
|
23
|
+
isRunJSValue,
|
|
24
|
+
normalizeRunJSValue,
|
|
25
|
+
runjsWithSafeGlobals,
|
|
26
|
+
} from '@nocobase/flow-engine';
|
|
27
|
+
import { evaluateConditions, FilterGroupType, removeInvalidFilterItems } from '@nocobase/utils/client';
|
|
28
|
+
import React from 'react';
|
|
29
|
+
import { Collapse, Input, Button, Switch, Space, Tooltip, Empty, Dropdown, Select } from 'antd';
|
|
30
|
+
import {
|
|
31
|
+
DeleteOutlined,
|
|
32
|
+
ArrowUpOutlined,
|
|
33
|
+
ArrowDownOutlined,
|
|
34
|
+
CopyOutlined,
|
|
35
|
+
PlusOutlined,
|
|
36
|
+
QuestionCircleOutlined,
|
|
37
|
+
} from '@ant-design/icons';
|
|
38
|
+
import { uid } from '@formily/shared';
|
|
39
|
+
import { FilterGroup } from '../components/filter/FilterGroup';
|
|
40
|
+
import { LinkageFilterItem } from '../components/filter';
|
|
41
|
+
import { CodeEditor } from '../components/code-editor';
|
|
42
|
+
import { FieldAssignRulesEditor } from '../components/FieldAssignRulesEditor';
|
|
43
|
+
import type { FieldAssignRuleItem } from '../components/FieldAssignRulesEditor';
|
|
44
|
+
import { collectFieldAssignCascaderOptions } from '../components/fieldAssignOptions';
|
|
45
|
+
import { useAssociationTitleFieldSync } from '../components/useAssociationTitleFieldSync';
|
|
46
|
+
import _ from 'lodash';
|
|
47
|
+
import { SubFormFieldModel, SubFormListFieldModel } from '../models';
|
|
48
|
+
import { coerceForToOneField } from '../internal/utils/associationValueCoercion';
|
|
49
|
+
import {
|
|
50
|
+
findFormItemModelByFieldPath,
|
|
51
|
+
getCollectionFromModel,
|
|
52
|
+
isToManyAssociationField,
|
|
53
|
+
} from '../internal/utils/modelUtils';
|
|
54
|
+
import { namePathToPathKey, parsePathString, resolveDynamicNamePath } from '../models/blocks/form/value-runtime/path';
|
|
55
|
+
|
|
56
|
+
interface LinkageRule {
|
|
57
|
+
/** 随机生成的字符串 */
|
|
58
|
+
key: string;
|
|
59
|
+
/** 联动规则的标题 */
|
|
60
|
+
title: string;
|
|
61
|
+
/** 是否启用,默认为 true */
|
|
62
|
+
enable: boolean;
|
|
63
|
+
/** 联动规则的条件部分 */
|
|
64
|
+
condition: FilterGroupType;
|
|
65
|
+
/** 联动规则的动作部分 */
|
|
66
|
+
actions: {
|
|
67
|
+
key: string;
|
|
68
|
+
name: string;
|
|
69
|
+
params?: any;
|
|
70
|
+
}[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const previewValueForLog = (value: any) => {
|
|
74
|
+
if (value == null) return value;
|
|
75
|
+
const t = typeof value;
|
|
76
|
+
if (t === 'string' || t === 'number' || t === 'boolean') return value;
|
|
77
|
+
if (Array.isArray(value)) {
|
|
78
|
+
if (value.length <= 3) return value;
|
|
79
|
+
return `[Array(${value.length})]`;
|
|
80
|
+
}
|
|
81
|
+
if (t === 'object') {
|
|
82
|
+
const id = (value as any)?.id;
|
|
83
|
+
if (id != null) return { id };
|
|
84
|
+
return '[Object]';
|
|
85
|
+
}
|
|
86
|
+
return `[${t}]`;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const getLinkageScopeDepthFromModel = (model: any): number => {
|
|
90
|
+
let depth = 0;
|
|
91
|
+
let cursor = model;
|
|
92
|
+
while (cursor) {
|
|
93
|
+
if (cursor instanceof SubFormFieldModel || cursor instanceof SubFormListFieldModel) {
|
|
94
|
+
depth += 1;
|
|
95
|
+
}
|
|
96
|
+
cursor = cursor?.parent;
|
|
97
|
+
}
|
|
98
|
+
return depth;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const getLinkageScopeDepthFromContext = (ctx: FlowContext): number => {
|
|
102
|
+
const fromCtx = Number((ctx as any)?.linkageScopeDepth);
|
|
103
|
+
if (Number.isFinite(fromCtx)) return fromCtx;
|
|
104
|
+
return getLinkageScopeDepthFromModel((ctx as any)?.model);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// 获取表单中所有字段的 model 实例的通用函数
|
|
108
|
+
const getFormFields = (ctx: any) => {
|
|
109
|
+
try {
|
|
110
|
+
const fieldModels = ctx.model?.subModels?.grid?.subModels?.items || [];
|
|
111
|
+
return fieldModels.map((model: any) => ({
|
|
112
|
+
label: model.props.label || model.props.name,
|
|
113
|
+
value: model.uid,
|
|
114
|
+
model,
|
|
115
|
+
}));
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.warn('Failed to get form fields:', error);
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const getFormFieldsByForkModel = (ctx: any) => {
|
|
123
|
+
try {
|
|
124
|
+
const fieldModels = ctx.model?.subModels?.grid?.subModels?.items || [];
|
|
125
|
+
return fieldModels.map((model: any) => {
|
|
126
|
+
const forkModel = Array.from(model.forks)[0] as any;
|
|
127
|
+
|
|
128
|
+
if (forkModel) {
|
|
129
|
+
return {
|
|
130
|
+
label: forkModel?.props.label || forkModel?.props.name,
|
|
131
|
+
value: forkModel?.uid || model.uid,
|
|
132
|
+
model: forkModel,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
label: model.props.label || model.props.name,
|
|
138
|
+
value: model.uid,
|
|
139
|
+
model,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.warn('Failed to get form fields:', error);
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
type ParsedFieldIndexEntry = {
|
|
149
|
+
fieldName: string;
|
|
150
|
+
index: number;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
function normalizeFieldKeyParts(fieldKey: string): string[] {
|
|
154
|
+
const s = fieldKey;
|
|
155
|
+
// tolerate array stringification like "a:0,b:1"
|
|
156
|
+
if (s.includes(',') && s.includes(':')) {
|
|
157
|
+
return s
|
|
158
|
+
.split(',')
|
|
159
|
+
.map((v) => v.trim())
|
|
160
|
+
.filter(Boolean);
|
|
161
|
+
}
|
|
162
|
+
return s ? [s] : [];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function parseFieldIndexEntry(entry: string): ParsedFieldIndexEntry | null {
|
|
166
|
+
const [fieldName, indexStr] = String(entry || '').split(':');
|
|
167
|
+
if (!fieldName) return null;
|
|
168
|
+
const index = Number(indexStr);
|
|
169
|
+
if (!Number.isFinite(index)) return null;
|
|
170
|
+
return { fieldName, index };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function buildAbsoluteFieldPathArray(
|
|
174
|
+
fieldPath: string | undefined,
|
|
175
|
+
fieldKey: any,
|
|
176
|
+
): {
|
|
177
|
+
fieldPathArray: Array<string | number>;
|
|
178
|
+
// path to the (innermost) Form.List root, e.g. ['user', 'comments'] (without index)
|
|
179
|
+
listRootPath?: Array<string | number>;
|
|
180
|
+
// row index for the innermost Form.List
|
|
181
|
+
listRowIndex?: number;
|
|
182
|
+
hasUnmatchedIndices: boolean;
|
|
183
|
+
} | null {
|
|
184
|
+
if (!fieldPath) return null;
|
|
185
|
+
|
|
186
|
+
const pathParts = String(fieldPath)
|
|
187
|
+
.split('.')
|
|
188
|
+
.map((v) => v.trim())
|
|
189
|
+
.filter(Boolean);
|
|
190
|
+
if (!pathParts.length) return null;
|
|
191
|
+
|
|
192
|
+
const indices = normalizeFieldKeyParts(fieldKey).map(parseFieldIndexEntry).filter(Boolean) as ParsedFieldIndexEntry[];
|
|
193
|
+
|
|
194
|
+
let idxPtr = 0;
|
|
195
|
+
const out: Array<string | number> = [];
|
|
196
|
+
let listRootPath: Array<string | number> | undefined;
|
|
197
|
+
let listRowIndex: number | undefined;
|
|
198
|
+
|
|
199
|
+
for (const part of pathParts) {
|
|
200
|
+
out.push(part);
|
|
201
|
+
const cur = indices[idxPtr];
|
|
202
|
+
if (cur && cur.fieldName === part) {
|
|
203
|
+
listRootPath = [...out];
|
|
204
|
+
listRowIndex = cur.index;
|
|
205
|
+
out.push(cur.index);
|
|
206
|
+
idxPtr += 1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
fieldPathArray: out,
|
|
212
|
+
listRootPath,
|
|
213
|
+
listRowIndex,
|
|
214
|
+
hasUnmatchedIndices: idxPtr < indices.length,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function normalizeAssignRuleItemsFromLinkageParams(
|
|
219
|
+
raw: any,
|
|
220
|
+
legacy: { mode: 'default' | 'assign'; valueKey: 'assignValue' | 'initialValue' },
|
|
221
|
+
resolveTargetPath?: (legacyFieldUid: string) => string | undefined,
|
|
222
|
+
): FieldAssignRuleItem[] {
|
|
223
|
+
if (Array.isArray(raw)) {
|
|
224
|
+
return raw as any;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (!raw || typeof raw !== 'object') return [];
|
|
228
|
+
|
|
229
|
+
// legacy object params: { field, assignValue } | { field, initialValue }
|
|
230
|
+
const legacyField = (raw as any)?.field;
|
|
231
|
+
const legacyValue = (raw as any)?.[legacy.valueKey];
|
|
232
|
+
if (legacyField) {
|
|
233
|
+
const targetPath = resolveTargetPath?.(String(legacyField));
|
|
234
|
+
if (!targetPath) return [];
|
|
235
|
+
return [
|
|
236
|
+
{
|
|
237
|
+
key: 'legacy',
|
|
238
|
+
enable: true,
|
|
239
|
+
targetPath,
|
|
240
|
+
mode: legacy.mode,
|
|
241
|
+
condition: { logic: '$and', items: [] },
|
|
242
|
+
value: legacyValue,
|
|
243
|
+
},
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// legacy empty: keep empty list
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function createLegacyTargetPathResolver(ctx: FlowContext) {
|
|
252
|
+
return (legacyFieldUid: string) => {
|
|
253
|
+
try {
|
|
254
|
+
const m: any = ctx.engine?.getModel?.(legacyFieldUid);
|
|
255
|
+
const fp = m?.getStepParams?.('fieldSettings', 'init')?.fieldPath || m?.fieldPath;
|
|
256
|
+
return fp ? String(fp) : undefined;
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.warn(`Failed to resolve legacy field uid ${legacyFieldUid}:`, error);
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const SKIP_RUNJS_ASSIGN_VALUE = Symbol('SKIP_RUNJS_ASSIGN_VALUE');
|
|
265
|
+
|
|
266
|
+
async function resolveLinkageAssignRuntimeValue(ctx: FlowContext, rawValue: any) {
|
|
267
|
+
if (!isRunJSValue(rawValue)) {
|
|
268
|
+
return rawValue;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
const { code, version } = normalizeRunJSValue(rawValue);
|
|
273
|
+
const ret = await runjsWithSafeGlobals(ctx, code, { version });
|
|
274
|
+
if (!ret?.success) {
|
|
275
|
+
return SKIP_RUNJS_ASSIGN_VALUE;
|
|
276
|
+
}
|
|
277
|
+
return ret.value;
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.warn('[linkageRules] Failed to evaluate RunJS assign value', error);
|
|
280
|
+
return SKIP_RUNJS_ASSIGN_VALUE;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function getSubFormHostFieldPath(ctx: FlowContext): string | null {
|
|
285
|
+
const tryReadFieldPath = (model: any): string | null => {
|
|
286
|
+
if (!model || typeof model !== 'object') return null;
|
|
287
|
+
const fromStepParams = model?.getStepParams?.('fieldSettings', 'init')?.fieldPath;
|
|
288
|
+
const fromFieldPath = model?.fieldPath;
|
|
289
|
+
const fieldPath =
|
|
290
|
+
(typeof fromStepParams === 'string' && fromStepParams) ||
|
|
291
|
+
(typeof fromFieldPath === 'string' && fromFieldPath) ||
|
|
292
|
+
'';
|
|
293
|
+
return fieldPath || null;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// row fork 场景下,直接 parent 常为 grid model,需要向上回溯到真正的子表单宿主字段模型
|
|
297
|
+
let cursor: any = (ctx.model as any)?.parent;
|
|
298
|
+
while (cursor) {
|
|
299
|
+
const fieldPath = tryReadFieldPath(cursor);
|
|
300
|
+
if (fieldPath) return fieldPath;
|
|
301
|
+
cursor = cursor?.parent;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// 兜底:部分上下文通过 delegate 暴露 prefixFieldPath
|
|
305
|
+
const fromPrefix = (ctx.model as any)?.context?.prefixFieldPath;
|
|
306
|
+
if (typeof fromPrefix === 'string' && fromPrefix) {
|
|
307
|
+
return fromPrefix;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function normalizeSubFormTargetPath(
|
|
314
|
+
ctx: FlowContext,
|
|
315
|
+
rawTargetPath: string,
|
|
316
|
+
): {
|
|
317
|
+
targetPath: string;
|
|
318
|
+
fieldModel: any;
|
|
319
|
+
} | null {
|
|
320
|
+
const targetPath = String(rawTargetPath || '').trim();
|
|
321
|
+
if (!targetPath) return null;
|
|
322
|
+
|
|
323
|
+
const hit = findFormItemModelByFieldPath(ctx.model, targetPath);
|
|
324
|
+
if (hit) {
|
|
325
|
+
return {
|
|
326
|
+
targetPath,
|
|
327
|
+
fieldModel: hit,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const hostFieldPath = getSubFormHostFieldPath(ctx);
|
|
332
|
+
if (!hostFieldPath) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const hostSegs = String(hostFieldPath)
|
|
337
|
+
.split('.')
|
|
338
|
+
.map((s) => s.trim())
|
|
339
|
+
.filter(Boolean);
|
|
340
|
+
const rawSegs = String(targetPath)
|
|
341
|
+
.split('.')
|
|
342
|
+
.map((s) => s.trim())
|
|
343
|
+
.filter(Boolean);
|
|
344
|
+
|
|
345
|
+
if (!hostSegs.length || !rawSegs.length) {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const joinSegs = (segs: string[]) => segs.filter(Boolean).join('.');
|
|
350
|
+
const candidates: string[] = [];
|
|
351
|
+
const pushCandidate = (path: string) => {
|
|
352
|
+
const normalized = String(path || '').trim();
|
|
353
|
+
if (!normalized) return;
|
|
354
|
+
if (!candidates.includes(normalized)) {
|
|
355
|
+
candidates.push(normalized);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
pushCandidate(targetPath);
|
|
360
|
+
|
|
361
|
+
// 重叠拼接:例如 host="M2M.M2M" + raw="M2M.Name" => "M2M.M2M.Name"
|
|
362
|
+
const overlapCandidates: string[] = [];
|
|
363
|
+
const maxOverlap = Math.min(hostSegs.length, rawSegs.length);
|
|
364
|
+
for (let overlap = maxOverlap; overlap >= 1; overlap--) {
|
|
365
|
+
const hostTail = hostSegs.slice(hostSegs.length - overlap);
|
|
366
|
+
const rawHead = rawSegs.slice(0, overlap);
|
|
367
|
+
if (!_.isEqual(hostTail, rawHead)) continue;
|
|
368
|
+
const merged = joinSegs([...hostSegs, ...rawSegs.slice(overlap)]);
|
|
369
|
+
if (merged && !overlapCandidates.includes(merged)) {
|
|
370
|
+
overlapCandidates.push(merged);
|
|
371
|
+
}
|
|
372
|
+
pushCandidate(merged);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const prefixed = joinSegs([...hostSegs, ...rawSegs]);
|
|
376
|
+
pushCandidate(prefixed);
|
|
377
|
+
|
|
378
|
+
for (const candidate of candidates) {
|
|
379
|
+
const matched = findFormItemModelByFieldPath(ctx.model, candidate);
|
|
380
|
+
if (matched) {
|
|
381
|
+
return {
|
|
382
|
+
targetPath: candidate,
|
|
383
|
+
fieldModel: matched,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// 无可命中字段模型时,按最安全且最可能正确的规则选择写入目标:
|
|
389
|
+
// 1) 单段路径默认视为“当前子表单相对路径” => host + raw
|
|
390
|
+
// 2) 多段路径若能与 host 后缀重叠,则优先重叠拼接结果
|
|
391
|
+
// 3) 否则保留原路径(避免盲目前缀导致越级)
|
|
392
|
+
const chosenPath = rawSegs.length === 1 ? prefixed : overlapCandidates.length > 0 ? overlapCandidates[0] : targetPath;
|
|
393
|
+
|
|
394
|
+
if (!chosenPath) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return {
|
|
399
|
+
targetPath: chosenPath,
|
|
400
|
+
fieldModel: null,
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export const linkageSetBlockProps = defineAction({
|
|
405
|
+
name: 'linkageSetBlockProps',
|
|
406
|
+
title: tExpr('Set block state'),
|
|
407
|
+
scene: ActionScene.BLOCK_LINKAGE_RULES,
|
|
408
|
+
sort: 100,
|
|
409
|
+
uiSchema: {
|
|
410
|
+
value: {
|
|
411
|
+
type: 'string',
|
|
412
|
+
'x-component': (props) => {
|
|
413
|
+
const { value, onChange } = props;
|
|
414
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
415
|
+
const ctx = useFlowContext();
|
|
416
|
+
const t = ctx.model.translate.bind(ctx.model);
|
|
417
|
+
|
|
418
|
+
return (
|
|
419
|
+
<Select
|
|
420
|
+
value={value}
|
|
421
|
+
onChange={onChange}
|
|
422
|
+
placeholder={t('Please select state')}
|
|
423
|
+
style={{ width: '100%' }}
|
|
424
|
+
options={[
|
|
425
|
+
{ label: t('Visible'), value: 'visible' },
|
|
426
|
+
{ label: t('Hidden'), value: 'hidden' },
|
|
427
|
+
]}
|
|
428
|
+
allowClear
|
|
429
|
+
/>
|
|
430
|
+
);
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
handler(ctx, { value, setProps }) {
|
|
435
|
+
setProps(ctx.model, { hiddenModel: value === 'hidden' });
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
export const linkageSetActionProps = defineAction({
|
|
440
|
+
name: 'linkageSetActionProps',
|
|
441
|
+
title: tExpr('Set button state'),
|
|
442
|
+
scene: ActionScene.ACTION_LINKAGE_RULES,
|
|
443
|
+
sort: 100,
|
|
444
|
+
uiSchema: {
|
|
445
|
+
value: {
|
|
446
|
+
type: 'string',
|
|
447
|
+
'x-component': (props) => {
|
|
448
|
+
const { value, onChange } = props;
|
|
449
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
450
|
+
const ctx = useFlowContext();
|
|
451
|
+
const t = ctx.model.translate.bind(ctx.model);
|
|
452
|
+
|
|
453
|
+
return (
|
|
454
|
+
<Select
|
|
455
|
+
value={value}
|
|
456
|
+
onChange={onChange}
|
|
457
|
+
placeholder={t('Please select state')}
|
|
458
|
+
style={{ width: '100%' }}
|
|
459
|
+
options={[
|
|
460
|
+
{ label: t('Visible'), value: 'visible' },
|
|
461
|
+
{ label: t('Hidden'), value: 'hidden' },
|
|
462
|
+
{ label: t('Hidden text'), value: 'hiddenText' },
|
|
463
|
+
{ label: t('Enabled'), value: 'enabled' },
|
|
464
|
+
{ label: t('Disabled'), value: 'disabled' },
|
|
465
|
+
]}
|
|
466
|
+
allowClear
|
|
467
|
+
/>
|
|
468
|
+
);
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
handler(ctx, { value, setProps }) {
|
|
473
|
+
setProps(ctx.model, {
|
|
474
|
+
hiddenModel: value === 'hidden',
|
|
475
|
+
disabled: value === 'disabled',
|
|
476
|
+
hiddenText: value === 'hiddenText',
|
|
477
|
+
});
|
|
478
|
+
},
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
export const linkageSetFieldProps = defineAction({
|
|
482
|
+
name: 'linkageSetFieldProps',
|
|
483
|
+
title: tExpr('Set field state'),
|
|
484
|
+
scene: ActionScene.FIELD_LINKAGE_RULES,
|
|
485
|
+
sort: 100,
|
|
486
|
+
uiSchema: {
|
|
487
|
+
value: {
|
|
488
|
+
type: 'object',
|
|
489
|
+
'x-component': (props) => {
|
|
490
|
+
const { value = { fields: [] }, onChange } = props;
|
|
491
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
492
|
+
const ctx = useFlowContext();
|
|
493
|
+
const t = ctx.model.translate.bind(ctx.model);
|
|
494
|
+
|
|
495
|
+
const fieldOptions = getFormFields(ctx);
|
|
496
|
+
|
|
497
|
+
// 状态选项
|
|
498
|
+
const stateOptions = [
|
|
499
|
+
{ label: t('Visible'), value: 'visible' },
|
|
500
|
+
{ label: t('Hidden'), value: 'hidden' },
|
|
501
|
+
{ label: t('Hidden (reserved value)'), value: 'hiddenReservedValue' },
|
|
502
|
+
{ label: t('Required'), value: 'required' },
|
|
503
|
+
{ label: t('Not required'), value: 'notRequired' },
|
|
504
|
+
{ label: t('Disabled'), value: 'disabled' },
|
|
505
|
+
{ label: t('Enabled'), value: 'enabled' },
|
|
506
|
+
];
|
|
507
|
+
|
|
508
|
+
const handleFieldsChange = (selectedFields: string[]) => {
|
|
509
|
+
onChange({
|
|
510
|
+
...value,
|
|
511
|
+
fields: selectedFields,
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
const handleStateChange = (selectedState: string) => {
|
|
516
|
+
onChange({
|
|
517
|
+
...value,
|
|
518
|
+
state: selectedState,
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
return (
|
|
523
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
524
|
+
<div>
|
|
525
|
+
<div style={{ marginBottom: '4px', fontSize: '14px' }}>{t('Fields')}</div>
|
|
526
|
+
<Select
|
|
527
|
+
mode="multiple"
|
|
528
|
+
value={value.fields}
|
|
529
|
+
onChange={handleFieldsChange}
|
|
530
|
+
placeholder={t('Please select fields')}
|
|
531
|
+
style={{ width: '100%' }}
|
|
532
|
+
options={fieldOptions}
|
|
533
|
+
showSearch
|
|
534
|
+
// @ts-ignore
|
|
535
|
+
filterOption={(input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase())}
|
|
536
|
+
allowClear
|
|
537
|
+
/>
|
|
538
|
+
</div>
|
|
539
|
+
<div>
|
|
540
|
+
<div style={{ marginBottom: '4px', fontSize: '14px' }}>{t('State')}</div>
|
|
541
|
+
<Select
|
|
542
|
+
value={value.state}
|
|
543
|
+
onChange={handleStateChange}
|
|
544
|
+
placeholder={t('Please select state')}
|
|
545
|
+
style={{ width: '100%' }}
|
|
546
|
+
options={stateOptions}
|
|
547
|
+
allowClear
|
|
548
|
+
/>
|
|
549
|
+
</div>
|
|
550
|
+
</div>
|
|
551
|
+
);
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
handler: (ctx, { value, setProps }) => {
|
|
556
|
+
const { fields, state } = value || {};
|
|
557
|
+
|
|
558
|
+
if (!fields || !Array.isArray(fields) || !state) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// 根据 uid 找到对应的字段 model 并设置属性
|
|
563
|
+
fields.forEach((fieldUid: string) => {
|
|
564
|
+
try {
|
|
565
|
+
const gridModels = ctx.model?.subModels?.grid?.subModels?.items || [];
|
|
566
|
+
const fieldModel = gridModels.find((model: any) => model.uid === fieldUid);
|
|
567
|
+
|
|
568
|
+
if (fieldModel) {
|
|
569
|
+
let props: any = {};
|
|
570
|
+
|
|
571
|
+
switch (state) {
|
|
572
|
+
case 'visible':
|
|
573
|
+
props = { hiddenModel: false };
|
|
574
|
+
break;
|
|
575
|
+
case 'hidden':
|
|
576
|
+
props = { hiddenModel: true };
|
|
577
|
+
break;
|
|
578
|
+
case 'hiddenReservedValue':
|
|
579
|
+
props = { hidden: true };
|
|
580
|
+
break;
|
|
581
|
+
case 'required':
|
|
582
|
+
props = { required: true };
|
|
583
|
+
break;
|
|
584
|
+
case 'notRequired':
|
|
585
|
+
props = { required: false };
|
|
586
|
+
break;
|
|
587
|
+
case 'disabled':
|
|
588
|
+
props = { disabled: true };
|
|
589
|
+
break;
|
|
590
|
+
case 'enabled':
|
|
591
|
+
props = { disabled: false };
|
|
592
|
+
break;
|
|
593
|
+
default:
|
|
594
|
+
console.warn(`Unknown state: ${state}`);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
setProps(fieldModel as FlowModel, props);
|
|
599
|
+
}
|
|
600
|
+
} catch (error) {
|
|
601
|
+
console.warn(`Failed to set props for field ${fieldUid}:`, error);
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
},
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
export const subFormLinkageSetFieldProps = defineAction({
|
|
608
|
+
name: 'subFormLinkageSetFieldProps',
|
|
609
|
+
title: tExpr('Set field state'),
|
|
610
|
+
scene: ActionScene.SUB_FORM_FIELD_LINKAGE_RULES,
|
|
611
|
+
sort: 100,
|
|
612
|
+
uiSchema: {
|
|
613
|
+
value: {
|
|
614
|
+
type: 'object',
|
|
615
|
+
'x-component': (props) => {
|
|
616
|
+
const { value = { fields: [] }, onChange } = props;
|
|
617
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
618
|
+
const ctx = useFlowContext();
|
|
619
|
+
const t = ctx.model.translate.bind(ctx.model);
|
|
620
|
+
|
|
621
|
+
const fieldOptions = getFormFieldsByForkModel(ctx);
|
|
622
|
+
|
|
623
|
+
// 状态选项
|
|
624
|
+
const stateOptions = [
|
|
625
|
+
{ label: t('Visible'), value: 'visible' },
|
|
626
|
+
{ label: t('Hidden'), value: 'hidden' },
|
|
627
|
+
{ label: t('Hidden (reserved value)'), value: 'hiddenReservedValue' },
|
|
628
|
+
{ label: t('Required'), value: 'required' },
|
|
629
|
+
{ label: t('Not required'), value: 'notRequired' },
|
|
630
|
+
{ label: t('Disabled'), value: 'disabled' },
|
|
631
|
+
{ label: t('Enabled'), value: 'enabled' },
|
|
632
|
+
];
|
|
633
|
+
|
|
634
|
+
const handleFieldsChange = (selectedFields: string[]) => {
|
|
635
|
+
onChange({
|
|
636
|
+
...value,
|
|
637
|
+
fields: selectedFields,
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
const handleStateChange = (selectedState: string) => {
|
|
642
|
+
onChange({
|
|
643
|
+
...value,
|
|
644
|
+
state: selectedState,
|
|
645
|
+
});
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
return (
|
|
649
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
650
|
+
<div>
|
|
651
|
+
<div style={{ marginBottom: '4px', fontSize: '14px' }}>{t('Fields')}</div>
|
|
652
|
+
<Select
|
|
653
|
+
mode="multiple"
|
|
654
|
+
value={value.fields}
|
|
655
|
+
onChange={handleFieldsChange}
|
|
656
|
+
placeholder={t('Please select fields')}
|
|
657
|
+
style={{ width: '100%' }}
|
|
658
|
+
options={fieldOptions}
|
|
659
|
+
showSearch
|
|
660
|
+
// @ts-ignore
|
|
661
|
+
filterOption={(input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase())}
|
|
662
|
+
allowClear
|
|
663
|
+
/>
|
|
664
|
+
</div>
|
|
665
|
+
<div>
|
|
666
|
+
<div style={{ marginBottom: '4px', fontSize: '14px' }}>{t('State')}</div>
|
|
667
|
+
<Select
|
|
668
|
+
value={value.state}
|
|
669
|
+
onChange={handleStateChange}
|
|
670
|
+
placeholder={t('Please select state')}
|
|
671
|
+
style={{ width: '100%' }}
|
|
672
|
+
options={stateOptions}
|
|
673
|
+
allowClear
|
|
674
|
+
/>
|
|
675
|
+
</div>
|
|
676
|
+
</div>
|
|
677
|
+
);
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
handler: (ctx, { value, setProps }) => {
|
|
682
|
+
const { fields, state } = value || {};
|
|
683
|
+
|
|
684
|
+
if (!fields || !Array.isArray(fields) || !state) {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// 根据 uid 找到对应的字段 model 并设置属性
|
|
689
|
+
fields.forEach((fieldUid: string) => {
|
|
690
|
+
try {
|
|
691
|
+
const formItemModel = ctx.engine?.getModel?.(fieldUid);
|
|
692
|
+
if (!formItemModel) {
|
|
693
|
+
console.warn('[subFormLinkageSetFieldProps] Target field model not found', {
|
|
694
|
+
fieldUid,
|
|
695
|
+
modelUid: ctx.model?.uid,
|
|
696
|
+
});
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const fieldKey = ctx.model?.context?.fieldKey;
|
|
701
|
+
const forkKey = fieldKey ? `${fieldKey}:${fieldUid}` : undefined;
|
|
702
|
+
const forkModel =
|
|
703
|
+
forkKey && typeof (formItemModel as any).getFork === 'function'
|
|
704
|
+
? (formItemModel as any).getFork(forkKey)
|
|
705
|
+
: null;
|
|
706
|
+
|
|
707
|
+
let model = forkModel;
|
|
708
|
+
|
|
709
|
+
// 适配对一子表单的场景
|
|
710
|
+
if (!forkModel) {
|
|
711
|
+
model = formItemModel;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (model) {
|
|
715
|
+
let props: any = {};
|
|
716
|
+
|
|
717
|
+
switch (state) {
|
|
718
|
+
case 'visible':
|
|
719
|
+
props = { hiddenModel: false };
|
|
720
|
+
break;
|
|
721
|
+
case 'hidden':
|
|
722
|
+
props = { hiddenModel: true };
|
|
723
|
+
break;
|
|
724
|
+
case 'hiddenReservedValue':
|
|
725
|
+
props = { hidden: true };
|
|
726
|
+
break;
|
|
727
|
+
case 'required':
|
|
728
|
+
props = { required: true };
|
|
729
|
+
break;
|
|
730
|
+
case 'notRequired':
|
|
731
|
+
props = { required: false };
|
|
732
|
+
break;
|
|
733
|
+
case 'disabled':
|
|
734
|
+
props = { disabled: true };
|
|
735
|
+
break;
|
|
736
|
+
case 'enabled':
|
|
737
|
+
props = { disabled: false };
|
|
738
|
+
break;
|
|
739
|
+
default:
|
|
740
|
+
console.warn(`Unknown state: ${state}`);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
setProps(model as FlowModel, props);
|
|
745
|
+
}
|
|
746
|
+
} catch (error) {
|
|
747
|
+
console.warn(`Failed to set props for field ${fieldUid}:`, error);
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
},
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
export const linkageSetDetailsFieldProps = defineAction({
|
|
754
|
+
name: 'linkageSetDetailsFieldProps',
|
|
755
|
+
title: tExpr('Set field state'),
|
|
756
|
+
scene: ActionScene.DETAILS_FIELD_LINKAGE_RULES,
|
|
757
|
+
sort: 100,
|
|
758
|
+
uiSchema: {
|
|
759
|
+
value: {
|
|
760
|
+
type: 'object',
|
|
761
|
+
'x-component': (props) => {
|
|
762
|
+
const { value = { fields: [] }, onChange } = props;
|
|
763
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
764
|
+
const ctx = useFlowContext();
|
|
765
|
+
const t = ctx.model.translate.bind(ctx.model);
|
|
766
|
+
|
|
767
|
+
const fieldOptions = getFormFields(ctx);
|
|
768
|
+
|
|
769
|
+
// 状态选项
|
|
770
|
+
const stateOptions = [
|
|
771
|
+
{ label: t('Visible'), value: 'visible' },
|
|
772
|
+
{ label: t('Hidden'), value: 'hidden' },
|
|
773
|
+
{ label: t('Hidden (reserved value)'), value: 'hiddenReservedValue' },
|
|
774
|
+
];
|
|
775
|
+
|
|
776
|
+
const handleFieldsChange = (selectedFields: string[]) => {
|
|
777
|
+
onChange({
|
|
778
|
+
...value,
|
|
779
|
+
fields: selectedFields,
|
|
780
|
+
});
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
const handleStateChange = (selectedState: string) => {
|
|
784
|
+
onChange({
|
|
785
|
+
...value,
|
|
786
|
+
state: selectedState,
|
|
787
|
+
});
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
return (
|
|
791
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
792
|
+
<div>
|
|
793
|
+
<div style={{ marginBottom: '4px', fontSize: '14px' }}>{t('Fields')}</div>
|
|
794
|
+
<Select
|
|
795
|
+
mode="multiple"
|
|
796
|
+
value={value.fields}
|
|
797
|
+
onChange={handleFieldsChange}
|
|
798
|
+
placeholder={t('Please select fields')}
|
|
799
|
+
style={{ width: '100%' }}
|
|
800
|
+
options={fieldOptions}
|
|
801
|
+
showSearch
|
|
802
|
+
// @ts-ignore
|
|
803
|
+
filterOption={(input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase())}
|
|
804
|
+
allowClear
|
|
805
|
+
/>
|
|
806
|
+
</div>
|
|
807
|
+
<div>
|
|
808
|
+
<div style={{ marginBottom: '4px', fontSize: '14px' }}>{t('State')}</div>
|
|
809
|
+
<Select
|
|
810
|
+
value={value.state}
|
|
811
|
+
onChange={handleStateChange}
|
|
812
|
+
placeholder={t('Please select state')}
|
|
813
|
+
style={{ width: '100%' }}
|
|
814
|
+
options={stateOptions}
|
|
815
|
+
allowClear
|
|
816
|
+
/>
|
|
817
|
+
</div>
|
|
818
|
+
</div>
|
|
819
|
+
);
|
|
820
|
+
},
|
|
821
|
+
},
|
|
822
|
+
},
|
|
823
|
+
handler: (ctx, { value, setProps }) => {
|
|
824
|
+
const { fields, state } = value || {};
|
|
825
|
+
|
|
826
|
+
if (!fields || !Array.isArray(fields) || !state) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// 根据 uid 找到对应的字段 model 并设置属性
|
|
831
|
+
fields.forEach((fieldUid: string) => {
|
|
832
|
+
try {
|
|
833
|
+
const gridModels = ctx.model?.subModels?.grid?.subModels?.items || [];
|
|
834
|
+
const fieldModel = gridModels.find((model: any) => model.uid === fieldUid);
|
|
835
|
+
|
|
836
|
+
if (fieldModel) {
|
|
837
|
+
let props: any = {};
|
|
838
|
+
|
|
839
|
+
switch (state) {
|
|
840
|
+
case 'visible':
|
|
841
|
+
props = { hiddenModel: false };
|
|
842
|
+
break;
|
|
843
|
+
case 'hidden':
|
|
844
|
+
props = { hiddenModel: true };
|
|
845
|
+
break;
|
|
846
|
+
case 'hiddenReservedValue':
|
|
847
|
+
props = { hidden: true };
|
|
848
|
+
break;
|
|
849
|
+
default:
|
|
850
|
+
console.warn(`Unknown state: ${state}`);
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
setProps(fieldModel as FlowModel, props);
|
|
855
|
+
}
|
|
856
|
+
} catch (error) {
|
|
857
|
+
console.warn(`Failed to set props for field ${fieldUid}:`, error);
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
},
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
type ArrayFieldComponentProps = {
|
|
864
|
+
value?: unknown;
|
|
865
|
+
onChange?: (value: unknown) => void;
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
const LEGACY_ASSIGN_RULE = { mode: 'assign', valueKey: 'assignValue' } as const;
|
|
869
|
+
const LEGACY_DEFAULT_RULE = { mode: 'default', valueKey: 'initialValue' } as const;
|
|
870
|
+
|
|
871
|
+
const FieldAssignRulesActionComponent: React.FC<
|
|
872
|
+
ArrayFieldComponentProps & {
|
|
873
|
+
legacy: typeof LEGACY_ASSIGN_RULE | typeof LEGACY_DEFAULT_RULE;
|
|
874
|
+
fixedMode?: 'assign' | 'default';
|
|
875
|
+
}
|
|
876
|
+
> = (props) => {
|
|
877
|
+
const { value, onChange, legacy, fixedMode } = props;
|
|
878
|
+
const ctx = useFlowContext();
|
|
879
|
+
|
|
880
|
+
const t = React.useCallback((key: string) => ctx.model.translate(key), [ctx.model]);
|
|
881
|
+
const { isTitleFieldCandidate, onSyncAssociationTitleField } = useAssociationTitleFieldSync(t);
|
|
882
|
+
|
|
883
|
+
const fieldOptions = React.useMemo(() => {
|
|
884
|
+
return collectFieldAssignCascaderOptions({
|
|
885
|
+
formBlockModel: ctx.model,
|
|
886
|
+
t,
|
|
887
|
+
maxFormItemDepth: 1,
|
|
888
|
+
});
|
|
889
|
+
}, [ctx.model, t]);
|
|
890
|
+
|
|
891
|
+
const normalized = normalizeAssignRuleItemsFromLinkageParams(value, legacy, createLegacyTargetPathResolver(ctx));
|
|
892
|
+
|
|
893
|
+
const handleChange = React.useCallback(
|
|
894
|
+
(next: FieldAssignRuleItem[]) => {
|
|
895
|
+
if (typeof onChange !== 'function') return;
|
|
896
|
+
onChange(next);
|
|
897
|
+
},
|
|
898
|
+
[onChange],
|
|
899
|
+
);
|
|
900
|
+
|
|
901
|
+
return (
|
|
902
|
+
<FieldAssignRulesEditor
|
|
903
|
+
t={t}
|
|
904
|
+
fieldOptions={fieldOptions}
|
|
905
|
+
rootCollection={getCollectionFromModel(ctx.model)}
|
|
906
|
+
value={normalized}
|
|
907
|
+
onChange={handleChange}
|
|
908
|
+
fixedMode={fixedMode}
|
|
909
|
+
isTitleFieldCandidate={isTitleFieldCandidate}
|
|
910
|
+
onSyncAssociationTitleField={onSyncAssociationTitleField}
|
|
911
|
+
enableDateVariableAsConstant
|
|
912
|
+
/>
|
|
913
|
+
);
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
const LinkageAssignFieldComponent: React.FC<ArrayFieldComponentProps> = (props) => {
|
|
917
|
+
return <FieldAssignRulesActionComponent {...props} legacy={LEGACY_ASSIGN_RULE} />;
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
const SubFormLinkageAssignFieldComponent: React.FC<ArrayFieldComponentProps> = (props) => {
|
|
921
|
+
return <FieldAssignRulesActionComponent {...props} legacy={LEGACY_ASSIGN_RULE} />;
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
const SetFieldsDefaultValueComponent: React.FC<ArrayFieldComponentProps> = (props) => {
|
|
925
|
+
return <FieldAssignRulesActionComponent {...props} legacy={LEGACY_DEFAULT_RULE} fixedMode="default" />;
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
export const linkageAssignField = defineAction({
|
|
929
|
+
name: 'linkageAssignField',
|
|
930
|
+
title: tExpr('Field assignment'),
|
|
931
|
+
scene: ActionScene.FIELD_LINKAGE_RULES,
|
|
932
|
+
sort: 200,
|
|
933
|
+
uiSchema: {
|
|
934
|
+
value: {
|
|
935
|
+
type: 'array',
|
|
936
|
+
'x-component': LinkageAssignFieldComponent,
|
|
937
|
+
},
|
|
938
|
+
},
|
|
939
|
+
handler: async (ctx, { value, setProps, addFormValuePatch }) => {
|
|
940
|
+
const items = normalizeAssignRuleItemsFromLinkageParams(
|
|
941
|
+
value,
|
|
942
|
+
{ mode: 'assign', valueKey: 'assignValue' },
|
|
943
|
+
createLegacyTargetPathResolver(ctx),
|
|
944
|
+
);
|
|
945
|
+
if (!items.length) return;
|
|
946
|
+
try {
|
|
947
|
+
const evaluator = (path: any, operator: string, right: any) => {
|
|
948
|
+
if (!operator) return true;
|
|
949
|
+
return ctx.app.jsonLogic.apply({ [operator]: [path, right] });
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
for (const it of items) {
|
|
953
|
+
if (it?.enable === false) continue;
|
|
954
|
+
const targetPath = it?.targetPath ? String(it.targetPath) : '';
|
|
955
|
+
if (!targetPath) continue;
|
|
956
|
+
|
|
957
|
+
const condition = it?.condition;
|
|
958
|
+
if (condition && !evaluateConditions(removeInvalidFilterItems(condition), evaluator as any)) {
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
const fieldModel = findFormItemModelByFieldPath(ctx.model, targetPath);
|
|
963
|
+
const top = targetPath.split('.')[0];
|
|
964
|
+
const collectionField =
|
|
965
|
+
(fieldModel as any)?.collectionField ?? getCollectionFromModel(ctx.model)?.getField?.(top);
|
|
966
|
+
let runtimeValue = it?.value;
|
|
967
|
+
if (isRunJSValue(runtimeValue)) {
|
|
968
|
+
runtimeValue = await resolveLinkageAssignRuntimeValue(ctx, runtimeValue);
|
|
969
|
+
if (runtimeValue === SKIP_RUNJS_ASSIGN_VALUE) {
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
const finalValue = coerceForToOneField(collectionField, runtimeValue);
|
|
975
|
+
|
|
976
|
+
// 若赋值为空(如切换字段后清空),调用一次 setProps 触发清空临时 props,避免旧值残留
|
|
977
|
+
if (typeof finalValue === 'undefined') {
|
|
978
|
+
if (fieldModel) {
|
|
979
|
+
setProps(fieldModel as FlowModel, {});
|
|
980
|
+
}
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
const mode = it?.mode === 'default' ? 'default' : 'assign';
|
|
985
|
+
if (fieldModel) {
|
|
986
|
+
if (mode === 'default') {
|
|
987
|
+
setProps(fieldModel as FlowModel, { initialValue: finalValue });
|
|
988
|
+
} else {
|
|
989
|
+
setProps(fieldModel as FlowModel, { value: finalValue });
|
|
990
|
+
}
|
|
991
|
+
} else if (typeof addFormValuePatch === 'function') {
|
|
992
|
+
// 对关联字段子属性(如 user.name)等没有独立 FormItemModel 的目标,直接写入表单值
|
|
993
|
+
addFormValuePatch({ path: targetPath, value: finalValue, whenEmpty: mode === 'default' });
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
} catch (error) {
|
|
997
|
+
console.warn('[linkageAssignField] Failed to assign value to fields', error);
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
export const subFormLinkageAssignField = defineAction({
|
|
1003
|
+
name: 'subFormLinkageAssignField',
|
|
1004
|
+
title: tExpr('Field assignment'),
|
|
1005
|
+
scene: ActionScene.SUB_FORM_FIELD_LINKAGE_RULES,
|
|
1006
|
+
sort: 200,
|
|
1007
|
+
uiSchema: {
|
|
1008
|
+
value: {
|
|
1009
|
+
type: 'array',
|
|
1010
|
+
'x-component': SubFormLinkageAssignFieldComponent,
|
|
1011
|
+
},
|
|
1012
|
+
},
|
|
1013
|
+
handler: async (ctx, { value, setProps, addFormValuePatch }) => {
|
|
1014
|
+
// 字段赋值处理逻辑
|
|
1015
|
+
const items = normalizeAssignRuleItemsFromLinkageParams(
|
|
1016
|
+
value,
|
|
1017
|
+
{ mode: 'assign', valueKey: 'assignValue' },
|
|
1018
|
+
createLegacyTargetPathResolver(ctx),
|
|
1019
|
+
);
|
|
1020
|
+
if (!items.length) return;
|
|
1021
|
+
try {
|
|
1022
|
+
const evaluator = (path: any, operator: string, right: any) => {
|
|
1023
|
+
if (!operator) return true;
|
|
1024
|
+
return ctx.app.jsonLogic.apply({ [operator]: [path, right] });
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
const getExplicitPathKeyStore = () => {
|
|
1028
|
+
const model = ctx.model as any;
|
|
1029
|
+
if (!(model?.__subFormLinkageExplicitPathKeys instanceof Set)) {
|
|
1030
|
+
model.__subFormLinkageExplicitPathKeys = new Set<string>();
|
|
1031
|
+
}
|
|
1032
|
+
return model.__subFormLinkageExplicitPathKeys as Set<string>;
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
const resolvePathKey = (path: string): string | null => {
|
|
1036
|
+
const namePath = resolveDynamicNamePath(path, (ctx.model as any)?.context?.fieldIndex);
|
|
1037
|
+
if (!Array.isArray(namePath) || !namePath.length) return null;
|
|
1038
|
+
const normalized = namePath.filter((seg) => typeof seg === 'string' || typeof seg === 'number') as Array<
|
|
1039
|
+
string | number
|
|
1040
|
+
>;
|
|
1041
|
+
if (!normalized.length) return null;
|
|
1042
|
+
return namePathToPathKey(normalized);
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
const markExplicitPathKeysFromInputArgs = () => {
|
|
1046
|
+
const inputArgs = (ctx as any)?.inputArgs as any;
|
|
1047
|
+
if (!inputArgs || inputArgs.source !== 'user') return;
|
|
1048
|
+
|
|
1049
|
+
const changedPaths = Array.isArray(inputArgs.changedPaths) ? inputArgs.changedPaths : [];
|
|
1050
|
+
if (!changedPaths.length) return;
|
|
1051
|
+
|
|
1052
|
+
const explicitPathKeys = getExplicitPathKeyStore();
|
|
1053
|
+
for (const rawPath of changedPaths) {
|
|
1054
|
+
let normalized: Array<string | number> | null = null;
|
|
1055
|
+
|
|
1056
|
+
if (Array.isArray(rawPath)) {
|
|
1057
|
+
const segs = rawPath.filter((seg) => typeof seg === 'string' || typeof seg === 'number') as Array<
|
|
1058
|
+
string | number
|
|
1059
|
+
>;
|
|
1060
|
+
normalized = segs.length ? segs : null;
|
|
1061
|
+
} else if (typeof rawPath === 'string') {
|
|
1062
|
+
const namePath = resolveDynamicNamePath(rawPath, (ctx.model as any)?.context?.fieldIndex);
|
|
1063
|
+
if (Array.isArray(namePath) && namePath.length) {
|
|
1064
|
+
const segs = namePath.filter((seg) => typeof seg === 'string' || typeof seg === 'number') as Array<
|
|
1065
|
+
string | number
|
|
1066
|
+
>;
|
|
1067
|
+
normalized = segs.length ? segs : null;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
if (!normalized?.length) continue;
|
|
1072
|
+
explicitPathKeys.add(namePathToPathKey(normalized));
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
const hasExplicitPathHit = (path: string): boolean => {
|
|
1077
|
+
const explicitPathKeys = getExplicitPathKeyStore();
|
|
1078
|
+
const targetPathKey = resolvePathKey(path);
|
|
1079
|
+
if (!targetPathKey) return false;
|
|
1080
|
+
if (explicitPathKeys.has(targetPathKey)) return true;
|
|
1081
|
+
|
|
1082
|
+
const targetNamePath = resolveDynamicNamePath(path, (ctx.model as any)?.context?.fieldIndex);
|
|
1083
|
+
if (!Array.isArray(targetNamePath) || !targetNamePath.length) return false;
|
|
1084
|
+
|
|
1085
|
+
const prefix: Array<string | number> = [];
|
|
1086
|
+
for (let i = 0; i < targetNamePath.length; i++) {
|
|
1087
|
+
const seg = targetNamePath[i];
|
|
1088
|
+
if (typeof seg !== 'string' && typeof seg !== 'number') continue;
|
|
1089
|
+
|
|
1090
|
+
prefix.push(seg);
|
|
1091
|
+
const key = namePathToPathKey(prefix);
|
|
1092
|
+
if (!explicitPathKeys.has(key)) continue;
|
|
1093
|
+
|
|
1094
|
+
const nextSeg = targetNamePath[i + 1];
|
|
1095
|
+
if (typeof nextSeg === 'number') {
|
|
1096
|
+
// ignore array container explicit hit (e.g. explicit `users` shouldn't block `users[0].name` defaults)
|
|
1097
|
+
continue;
|
|
1098
|
+
}
|
|
1099
|
+
return true;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
return false;
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
markExplicitPathKeysFromInputArgs();
|
|
1106
|
+
|
|
1107
|
+
const resolveTargetFieldModel = (fieldUid: string) => {
|
|
1108
|
+
const formItemModel = ctx.engine.getModel(fieldUid);
|
|
1109
|
+
if (!formItemModel) return null;
|
|
1110
|
+
|
|
1111
|
+
const fieldKey = ctx?.model?.context?.fieldKey;
|
|
1112
|
+
const forkKey = fieldKey ? `${fieldKey}:${fieldUid}` : null;
|
|
1113
|
+
|
|
1114
|
+
let model = forkKey ? formItemModel.getFork(forkKey) : null;
|
|
1115
|
+
|
|
1116
|
+
// 对多子表单(Form.List)场景:
|
|
1117
|
+
// - 确保用于写入的 fieldPathArray 为可落地的“绝对路径”
|
|
1118
|
+
if (fieldKey) {
|
|
1119
|
+
const fieldPath =
|
|
1120
|
+
formItemModel?.fieldPath || formItemModel?.getStepParams?.('fieldSettings', 'init')?.fieldPath;
|
|
1121
|
+
const built = buildAbsoluteFieldPathArray(fieldPath, fieldKey);
|
|
1122
|
+
|
|
1123
|
+
// 主动创建对应的 FormItem fork,并注入 fieldPathArray 供赋值使用
|
|
1124
|
+
if (!model && forkKey) {
|
|
1125
|
+
model = formItemModel.createFork({}, forkKey);
|
|
1126
|
+
}
|
|
1127
|
+
if (model?.isFork && built) {
|
|
1128
|
+
model?.context?.defineProperty?.('fieldPathArray', { value: built.fieldPathArray });
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// 适配对一子表单的场景(无行级 fieldKey)
|
|
1133
|
+
if (!model) {
|
|
1134
|
+
model = formItemModel as any;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
return model as any;
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
for (const it of items) {
|
|
1141
|
+
if (it?.enable === false) continue;
|
|
1142
|
+
const rawTargetPath = it?.targetPath ? String(it.targetPath) : '';
|
|
1143
|
+
if (!rawTargetPath) continue;
|
|
1144
|
+
|
|
1145
|
+
const normalized = normalizeSubFormTargetPath(ctx, rawTargetPath);
|
|
1146
|
+
if (!normalized?.targetPath) {
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
const targetPath = normalized.targetPath;
|
|
1151
|
+
const itemModel = normalized.fieldModel || null;
|
|
1152
|
+
const fieldUid = itemModel?.uid ? String(itemModel.uid) : '';
|
|
1153
|
+
|
|
1154
|
+
const condition = it?.condition;
|
|
1155
|
+
if (condition && !evaluateConditions(removeInvalidFilterItems(condition), evaluator as any)) {
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
const mode = it?.mode === 'default' ? 'default' : 'assign';
|
|
1160
|
+
const actionName = (ctx.model as any)?.getAclActionName?.() ?? (ctx.model as any)?.context?.actionName;
|
|
1161
|
+
const isEditForm = actionName === 'update';
|
|
1162
|
+
const isNewItem = (ctx as any)?.item?.__is_new__ === true;
|
|
1163
|
+
if (mode === 'default' && isEditForm && !isNewItem) {
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
const top = targetPath.split('.')[0];
|
|
1168
|
+
const collectionField =
|
|
1169
|
+
(itemModel as any)?.collectionField ??
|
|
1170
|
+
getCollectionFromModel((ctx.model as any)?.parent ?? ctx.model)?.getField?.(top);
|
|
1171
|
+
let runtimeValue = it?.value;
|
|
1172
|
+
if (isRunJSValue(runtimeValue)) {
|
|
1173
|
+
runtimeValue = await resolveLinkageAssignRuntimeValue(ctx, runtimeValue);
|
|
1174
|
+
if (runtimeValue === SKIP_RUNJS_ASSIGN_VALUE) {
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
const finalValue = coerceForToOneField(collectionField, runtimeValue);
|
|
1180
|
+
|
|
1181
|
+
// 若赋值为空(如切换字段后清空),调用一次 setProps 触发清空临时 props,避免旧值残留
|
|
1182
|
+
if (typeof finalValue === 'undefined') {
|
|
1183
|
+
if (!fieldUid) continue;
|
|
1184
|
+
const model = resolveTargetFieldModel(fieldUid);
|
|
1185
|
+
if (model) setProps(model, {});
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
if (!fieldUid) {
|
|
1190
|
+
if (mode === 'default' && hasExplicitPathHit(targetPath)) {
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
if (typeof addFormValuePatch === 'function') {
|
|
1194
|
+
addFormValuePatch({ path: targetPath, value: finalValue, whenEmpty: mode === 'default' });
|
|
1195
|
+
}
|
|
1196
|
+
continue;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
const model = resolveTargetFieldModel(fieldUid);
|
|
1200
|
+
if (!model) continue;
|
|
1201
|
+
|
|
1202
|
+
if (mode === 'default') {
|
|
1203
|
+
setProps(model, { initialValue: finalValue });
|
|
1204
|
+
} else {
|
|
1205
|
+
setProps(model, { value: finalValue });
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
} catch (error) {
|
|
1209
|
+
console.warn('[subFormLinkageAssignField] Failed to assign value to fields', error);
|
|
1210
|
+
}
|
|
1211
|
+
},
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
export const setFieldsDefaultValue = defineAction({
|
|
1215
|
+
name: 'setFieldsDefaultValue',
|
|
1216
|
+
title: tExpr('设置字段默认值'),
|
|
1217
|
+
scene: ActionScene.FIELD_LINKAGE_RULES,
|
|
1218
|
+
sort: 200,
|
|
1219
|
+
uiSchema: {
|
|
1220
|
+
value: {
|
|
1221
|
+
type: 'array',
|
|
1222
|
+
'x-component': SetFieldsDefaultValueComponent,
|
|
1223
|
+
},
|
|
1224
|
+
},
|
|
1225
|
+
handler: async (ctx, { value, setProps, addFormValuePatch }) => {
|
|
1226
|
+
const items = normalizeAssignRuleItemsFromLinkageParams(
|
|
1227
|
+
value,
|
|
1228
|
+
{ mode: 'default', valueKey: 'initialValue' },
|
|
1229
|
+
createLegacyTargetPathResolver(ctx),
|
|
1230
|
+
);
|
|
1231
|
+
if (!items.length) return;
|
|
1232
|
+
try {
|
|
1233
|
+
const evaluator = (path: any, operator: string, right: any) => {
|
|
1234
|
+
if (!operator) return true;
|
|
1235
|
+
return ctx.app.jsonLogic.apply({ [operator]: [path, right] });
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
for (const it of items) {
|
|
1239
|
+
if (it?.enable === false) continue;
|
|
1240
|
+
const targetPath = it?.targetPath ? String(it.targetPath) : '';
|
|
1241
|
+
if (!targetPath) continue;
|
|
1242
|
+
|
|
1243
|
+
const condition = it?.condition;
|
|
1244
|
+
if (condition && !evaluateConditions(removeInvalidFilterItems(condition), evaluator as any)) {
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
const fieldModel = findFormItemModelByFieldPath(ctx.model, targetPath);
|
|
1249
|
+
const top = targetPath.split('.')[0];
|
|
1250
|
+
const collectionField =
|
|
1251
|
+
(fieldModel as any)?.collectionField ?? getCollectionFromModel(ctx.model)?.getField?.(top);
|
|
1252
|
+
let runtimeValue = it?.value;
|
|
1253
|
+
if (isRunJSValue(runtimeValue)) {
|
|
1254
|
+
runtimeValue = await resolveLinkageAssignRuntimeValue(ctx, runtimeValue);
|
|
1255
|
+
if (runtimeValue === SKIP_RUNJS_ASSIGN_VALUE) {
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
const finalInitialValue = coerceForToOneField(collectionField, runtimeValue);
|
|
1261
|
+
|
|
1262
|
+
// 若赋值为空(如切换字段后清空),调用一次 setProps 触发清空临时 props,避免旧值残留
|
|
1263
|
+
if (typeof finalInitialValue === 'undefined') {
|
|
1264
|
+
if (fieldModel) {
|
|
1265
|
+
setProps(fieldModel as FlowModel, {});
|
|
1266
|
+
}
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
if (fieldModel) {
|
|
1271
|
+
setProps(fieldModel as FlowModel, { initialValue: finalInitialValue });
|
|
1272
|
+
} else if (typeof addFormValuePatch === 'function') {
|
|
1273
|
+
// 对关联字段子属性等没有独立 FormItemModel 的目标:仅当当前值为空时写入一次,避免覆盖用户输入
|
|
1274
|
+
addFormValuePatch({ path: targetPath, value: finalInitialValue, whenEmpty: true });
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
} catch (error) {
|
|
1278
|
+
console.warn('[setFieldsDefaultValue] Failed to set fields default value', error);
|
|
1279
|
+
}
|
|
1280
|
+
},
|
|
1281
|
+
});
|
|
1282
|
+
|
|
1283
|
+
export const linkageRunjs = defineAction({
|
|
1284
|
+
name: 'linkageRunjs',
|
|
1285
|
+
title: tExpr('Execute JavaScript'),
|
|
1286
|
+
scene: [
|
|
1287
|
+
ActionScene.BLOCK_LINKAGE_RULES,
|
|
1288
|
+
ActionScene.FIELD_LINKAGE_RULES,
|
|
1289
|
+
ActionScene.ACTION_LINKAGE_RULES,
|
|
1290
|
+
ActionScene.DETAILS_FIELD_LINKAGE_RULES,
|
|
1291
|
+
ActionScene.SUB_FORM_FIELD_LINKAGE_RULES,
|
|
1292
|
+
],
|
|
1293
|
+
sort: 300,
|
|
1294
|
+
useRawParams: true,
|
|
1295
|
+
uiSchema: {
|
|
1296
|
+
value: {
|
|
1297
|
+
type: 'object',
|
|
1298
|
+
'x-component': (props) => {
|
|
1299
|
+
const { value = { script: '' }, onChange } = props;
|
|
1300
|
+
const handleScriptChange = (script: string) => {
|
|
1301
|
+
onChange({
|
|
1302
|
+
...value,
|
|
1303
|
+
script,
|
|
1304
|
+
});
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
return (
|
|
1308
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
1309
|
+
{/* <div
|
|
1310
|
+
style={{
|
|
1311
|
+
backgroundColor: '#f6ffed',
|
|
1312
|
+
border: '1px solid #b7eb8f',
|
|
1313
|
+
borderRadius: '6px',
|
|
1314
|
+
padding: '12px',
|
|
1315
|
+
}}
|
|
1316
|
+
>
|
|
1317
|
+
<div style={{ color: '#666', fontSize: '12px', lineHeight: '1.5' }}>
|
|
1318
|
+
预留一个位置,用于显示一些提示信息
|
|
1319
|
+
</div>
|
|
1320
|
+
</div> */}
|
|
1321
|
+
<div>
|
|
1322
|
+
<CodeEditor
|
|
1323
|
+
value={value.script}
|
|
1324
|
+
onChange={handleScriptChange}
|
|
1325
|
+
height="200px"
|
|
1326
|
+
enableLinter={true}
|
|
1327
|
+
scene="linkage"
|
|
1328
|
+
/>
|
|
1329
|
+
</div>
|
|
1330
|
+
</div>
|
|
1331
|
+
);
|
|
1332
|
+
},
|
|
1333
|
+
},
|
|
1334
|
+
},
|
|
1335
|
+
handler: async (ctx, { value }) => {
|
|
1336
|
+
// 执行 JS 脚本处理逻辑
|
|
1337
|
+
const { script } = value || {};
|
|
1338
|
+
|
|
1339
|
+
if (!script || typeof script !== 'string') {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
try {
|
|
1344
|
+
const navigator = createSafeNavigator();
|
|
1345
|
+
await ctx.runjs(script, { window: createSafeWindow({ navigator }), document: createSafeDocument(), navigator });
|
|
1346
|
+
} catch (error) {
|
|
1347
|
+
console.error('Script execution error:', error);
|
|
1348
|
+
// 可以选择显示错误信息给用户
|
|
1349
|
+
if (ctx.app?.message) {
|
|
1350
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1351
|
+
ctx.app.message.error(`Script execution error: ${msg}`);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
});
|
|
1356
|
+
|
|
1357
|
+
function protectLinkageRunJsScripts(params: { value?: LinkageRule[] } & Record<string, any>) {
|
|
1358
|
+
const masked = _.cloneDeep(params || {}) as typeof params;
|
|
1359
|
+
const tokenToScript = new Map<string, string>();
|
|
1360
|
+
|
|
1361
|
+
const mask = (script: string) => {
|
|
1362
|
+
const token = `__ncb_linkage_runjs_script_mask__${uid()}__`;
|
|
1363
|
+
tokenToScript.set(token, script);
|
|
1364
|
+
return token;
|
|
1365
|
+
};
|
|
1366
|
+
|
|
1367
|
+
const rules = masked?.value;
|
|
1368
|
+
if (Array.isArray(rules)) {
|
|
1369
|
+
rules.forEach((rule) => {
|
|
1370
|
+
rule.actions.forEach((action) => {
|
|
1371
|
+
const actionName = action.name;
|
|
1372
|
+
if (actionName !== 'linkageRunjs' && actionName !== 'runjs') return;
|
|
1373
|
+
const script = _.get(action, ['params', 'value', 'script']);
|
|
1374
|
+
if (typeof script === 'string' && script.length) {
|
|
1375
|
+
_.set(action, ['params', 'value', 'script'], mask(script));
|
|
1376
|
+
}
|
|
1377
|
+
const code = _.get(action, ['params', 'code']);
|
|
1378
|
+
if (typeof code === 'string' && code.length) {
|
|
1379
|
+
_.set(action, ['params', 'code'], mask(code));
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
const restore = (resolved: any) => {
|
|
1386
|
+
const rulesResolved = resolved?.value;
|
|
1387
|
+
if (Array.isArray(rulesResolved)) {
|
|
1388
|
+
rulesResolved.forEach((rule: LinkageRule) => {
|
|
1389
|
+
rule.actions.forEach((action) => {
|
|
1390
|
+
const actionName = action.name;
|
|
1391
|
+
if (actionName !== 'linkageRunjs' && actionName !== 'runjs') return;
|
|
1392
|
+
const script = _.get(action, ['params', 'value', 'script']);
|
|
1393
|
+
if (typeof script === 'string' && tokenToScript.has(script)) {
|
|
1394
|
+
_.set(action, ['params', 'value', 'script'], tokenToScript.get(script));
|
|
1395
|
+
}
|
|
1396
|
+
const code = _.get(action, ['params', 'code']);
|
|
1397
|
+
if (typeof code === 'string' && tokenToScript.has(code)) {
|
|
1398
|
+
_.set(action, ['params', 'code'], tokenToScript.get(code));
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
return resolved;
|
|
1404
|
+
};
|
|
1405
|
+
|
|
1406
|
+
return { masked, restore };
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
async function resolveLinkageRulesParamsPreservingRunJsScripts(ctx: FlowContext, params: any) {
|
|
1410
|
+
const { masked, restore } = protectLinkageRunJsScripts(params);
|
|
1411
|
+
const resolved = await ctx.resolveJsonTemplate(masked);
|
|
1412
|
+
return restore(resolved);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
const LinkageRulesUI = observer(
|
|
1416
|
+
(props: { readonly value: LinkageRule[]; supportedActions: string[]; title?: string }) => {
|
|
1417
|
+
const { value: rules, supportedActions } = props;
|
|
1418
|
+
const ctx = useFlowContext();
|
|
1419
|
+
const flowEngine = useFlowEngine();
|
|
1420
|
+
const t = ctx.model.translate.bind(ctx.model);
|
|
1421
|
+
const assignPriorityTip = t('Assignment takes precedence over form field assignment');
|
|
1422
|
+
|
|
1423
|
+
// 创建新规则的默认值
|
|
1424
|
+
const createNewRule = (): LinkageRule => ({
|
|
1425
|
+
key: uid(),
|
|
1426
|
+
title: t('Linkage rule'),
|
|
1427
|
+
enable: true,
|
|
1428
|
+
condition: { logic: '$and', items: [] } as FilterGroupType,
|
|
1429
|
+
actions: [],
|
|
1430
|
+
});
|
|
1431
|
+
|
|
1432
|
+
// 添加新规则
|
|
1433
|
+
const handleAddRule = () => {
|
|
1434
|
+
rules.push(createNewRule());
|
|
1435
|
+
};
|
|
1436
|
+
|
|
1437
|
+
// 删除规则
|
|
1438
|
+
const handleDeleteRule = (index: number) => {
|
|
1439
|
+
rules.splice(index, 1);
|
|
1440
|
+
};
|
|
1441
|
+
|
|
1442
|
+
// 上移规则
|
|
1443
|
+
const handleMoveUp = (index: number) => {
|
|
1444
|
+
if (index > 0) {
|
|
1445
|
+
const rule = rules[index];
|
|
1446
|
+
rules.splice(index, 1);
|
|
1447
|
+
rules.splice(index - 1, 0, rule);
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
|
|
1451
|
+
// 下移规则
|
|
1452
|
+
const handleMoveDown = (index: number) => {
|
|
1453
|
+
if (index < rules.length - 1) {
|
|
1454
|
+
const rule = rules[index];
|
|
1455
|
+
rules.splice(index, 1);
|
|
1456
|
+
rules.splice(index + 1, 0, rule);
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
// 复制规则
|
|
1461
|
+
const handleCopyRule = (index: number) => {
|
|
1462
|
+
const originalRule = _.cloneDeep(rules[index]);
|
|
1463
|
+
const newRule: LinkageRule = {
|
|
1464
|
+
...originalRule,
|
|
1465
|
+
key: uid(),
|
|
1466
|
+
title: `${originalRule.title} (Copy)`,
|
|
1467
|
+
};
|
|
1468
|
+
rules.splice(index + 1, 0, newRule);
|
|
1469
|
+
};
|
|
1470
|
+
|
|
1471
|
+
// 更新规则标题
|
|
1472
|
+
const handleTitleChange = (index: number, title: string) => {
|
|
1473
|
+
rules[index].title = title;
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
// 切换规则启用状态
|
|
1477
|
+
const handleToggleEnable = (index: number, enable: boolean) => {
|
|
1478
|
+
rules[index].enable = enable;
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1481
|
+
// 获取可用的动作类型
|
|
1482
|
+
const getActionsDefinition = () => {
|
|
1483
|
+
return supportedActions.map((actionName: string) => ctx.getAction(actionName));
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
// 添加动作
|
|
1487
|
+
const handleAddAction = (ruleIndex: number, actionName: string) => {
|
|
1488
|
+
const newAction = {
|
|
1489
|
+
key: uid(),
|
|
1490
|
+
name: actionName,
|
|
1491
|
+
params: undefined,
|
|
1492
|
+
};
|
|
1493
|
+
rules[ruleIndex].actions.push(newAction);
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1496
|
+
// 删除动作
|
|
1497
|
+
const handleDeleteAction = (ruleIndex: number, actionIndex: number) => {
|
|
1498
|
+
rules[ruleIndex].actions.splice(actionIndex, 1);
|
|
1499
|
+
};
|
|
1500
|
+
|
|
1501
|
+
// 更新动作的值
|
|
1502
|
+
const handleActionValueChange = (ruleIndex: number, actionIndex: number, value: any) => {
|
|
1503
|
+
rules[ruleIndex].actions[actionIndex].params = value;
|
|
1504
|
+
};
|
|
1505
|
+
|
|
1506
|
+
// 生成折叠面板的自定义标题
|
|
1507
|
+
const renderPanelHeader = (rule: LinkageRule, index: number) => (
|
|
1508
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>
|
|
1509
|
+
<div style={{ flex: 1, marginRight: 16 }}>
|
|
1510
|
+
<Input
|
|
1511
|
+
value={rule.title}
|
|
1512
|
+
onChange={(e) => handleTitleChange(index, e.target.value)}
|
|
1513
|
+
onClick={(e) => e.stopPropagation()}
|
|
1514
|
+
placeholder="Enter rule title"
|
|
1515
|
+
/>
|
|
1516
|
+
</div>
|
|
1517
|
+
<Space onClick={(e) => e.stopPropagation()}>
|
|
1518
|
+
<Tooltip title={t('Delete')}>
|
|
1519
|
+
<Button type="text" size="small" icon={<DeleteOutlined />} onClick={() => handleDeleteRule(index)} />
|
|
1520
|
+
</Tooltip>
|
|
1521
|
+
<Tooltip title={t('Move up')}>
|
|
1522
|
+
<Button
|
|
1523
|
+
type="text"
|
|
1524
|
+
size="small"
|
|
1525
|
+
icon={<ArrowUpOutlined />}
|
|
1526
|
+
onClick={() => handleMoveUp(index)}
|
|
1527
|
+
disabled={index === 0}
|
|
1528
|
+
/>
|
|
1529
|
+
</Tooltip>
|
|
1530
|
+
<Tooltip title={t('Move down')}>
|
|
1531
|
+
<Button
|
|
1532
|
+
type="text"
|
|
1533
|
+
size="small"
|
|
1534
|
+
icon={<ArrowDownOutlined />}
|
|
1535
|
+
onClick={() => handleMoveDown(index)}
|
|
1536
|
+
disabled={index === rules.length - 1}
|
|
1537
|
+
/>
|
|
1538
|
+
</Tooltip>
|
|
1539
|
+
<Tooltip title={t('Copy')}>
|
|
1540
|
+
<Button type="text" size="small" icon={<CopyOutlined />} onClick={() => handleCopyRule(index)} />
|
|
1541
|
+
</Tooltip>
|
|
1542
|
+
<Switch
|
|
1543
|
+
size="small"
|
|
1544
|
+
checked={rule.enable}
|
|
1545
|
+
onChange={(checked) => handleToggleEnable(index, checked)}
|
|
1546
|
+
checkedChildren={t('Enable')}
|
|
1547
|
+
unCheckedChildren={t('Disable')}
|
|
1548
|
+
/>
|
|
1549
|
+
</Space>
|
|
1550
|
+
</div>
|
|
1551
|
+
);
|
|
1552
|
+
|
|
1553
|
+
// 生成折叠面板项
|
|
1554
|
+
const collapseItems = rules.map((rule, index) => ({
|
|
1555
|
+
key: rule.key,
|
|
1556
|
+
label: renderPanelHeader(rule, index),
|
|
1557
|
+
styles: {
|
|
1558
|
+
header: {
|
|
1559
|
+
display: 'flex',
|
|
1560
|
+
alignItems: 'center',
|
|
1561
|
+
},
|
|
1562
|
+
},
|
|
1563
|
+
children: (
|
|
1564
|
+
<div>
|
|
1565
|
+
{/* 条件部分 */}
|
|
1566
|
+
<div style={{ marginBottom: 32 }}>
|
|
1567
|
+
<div
|
|
1568
|
+
style={{
|
|
1569
|
+
display: 'flex',
|
|
1570
|
+
alignItems: 'center',
|
|
1571
|
+
marginBottom: 16,
|
|
1572
|
+
paddingBottom: 8,
|
|
1573
|
+
borderBottom: '1px solid #f0f0f0',
|
|
1574
|
+
}}
|
|
1575
|
+
>
|
|
1576
|
+
<div
|
|
1577
|
+
style={{
|
|
1578
|
+
width: '4px',
|
|
1579
|
+
height: '16px',
|
|
1580
|
+
backgroundColor: '#1890ff',
|
|
1581
|
+
borderRadius: '2px',
|
|
1582
|
+
marginRight: 8,
|
|
1583
|
+
}}
|
|
1584
|
+
></div>
|
|
1585
|
+
<h4
|
|
1586
|
+
style={{
|
|
1587
|
+
margin: 0,
|
|
1588
|
+
fontSize: 14,
|
|
1589
|
+
fontWeight: 500,
|
|
1590
|
+
color: '#262626',
|
|
1591
|
+
}}
|
|
1592
|
+
>
|
|
1593
|
+
{t('Condition')}
|
|
1594
|
+
</h4>
|
|
1595
|
+
</div>
|
|
1596
|
+
<div style={{ paddingLeft: 12 }}>
|
|
1597
|
+
<FilterGroup
|
|
1598
|
+
value={rule.condition}
|
|
1599
|
+
FilterItem={(props) => <LinkageFilterItem model={ctx.model} value={props.value} />}
|
|
1600
|
+
/>
|
|
1601
|
+
</div>
|
|
1602
|
+
</div>
|
|
1603
|
+
|
|
1604
|
+
{/* 动作部分 */}
|
|
1605
|
+
<div>
|
|
1606
|
+
<div
|
|
1607
|
+
style={{
|
|
1608
|
+
display: 'flex',
|
|
1609
|
+
alignItems: 'center',
|
|
1610
|
+
marginBottom: 16,
|
|
1611
|
+
paddingBottom: 8,
|
|
1612
|
+
borderBottom: '1px solid #f0f0f0',
|
|
1613
|
+
}}
|
|
1614
|
+
>
|
|
1615
|
+
<div
|
|
1616
|
+
style={{
|
|
1617
|
+
width: '4px',
|
|
1618
|
+
height: '16px',
|
|
1619
|
+
backgroundColor: '#52c41a',
|
|
1620
|
+
borderRadius: '2px',
|
|
1621
|
+
marginRight: 8,
|
|
1622
|
+
}}
|
|
1623
|
+
></div>
|
|
1624
|
+
<h4
|
|
1625
|
+
style={{
|
|
1626
|
+
margin: 0,
|
|
1627
|
+
fontSize: 14,
|
|
1628
|
+
fontWeight: 500,
|
|
1629
|
+
color: '#262626',
|
|
1630
|
+
}}
|
|
1631
|
+
>
|
|
1632
|
+
{t('Actions')}
|
|
1633
|
+
</h4>
|
|
1634
|
+
</div>
|
|
1635
|
+
<div style={{ paddingLeft: 12 }}>
|
|
1636
|
+
{/* 渲染已有的动作 */}
|
|
1637
|
+
{rule.actions.length > 0 ? (
|
|
1638
|
+
<div style={{ marginBottom: 16 }}>
|
|
1639
|
+
{rule.actions.map((action, actionIndex) => {
|
|
1640
|
+
const actionDef = ctx.getAction(action.name);
|
|
1641
|
+
if (!actionDef) return null;
|
|
1642
|
+
|
|
1643
|
+
return (
|
|
1644
|
+
<div
|
|
1645
|
+
key={action.key}
|
|
1646
|
+
style={{
|
|
1647
|
+
border: '1px solid #f0f0f0',
|
|
1648
|
+
borderRadius: '6px',
|
|
1649
|
+
padding: '12px',
|
|
1650
|
+
marginBottom: '8px',
|
|
1651
|
+
}}
|
|
1652
|
+
>
|
|
1653
|
+
<div
|
|
1654
|
+
style={{
|
|
1655
|
+
display: 'flex',
|
|
1656
|
+
alignItems: 'center',
|
|
1657
|
+
justifyContent: 'space-between',
|
|
1658
|
+
marginBottom: '8px',
|
|
1659
|
+
}}
|
|
1660
|
+
>
|
|
1661
|
+
<span style={{ fontWeight: 500, color: '#262626' }}>
|
|
1662
|
+
{t(actionDef.title)}
|
|
1663
|
+
{action.name === 'linkageAssignField' || action.name === 'subFormLinkageAssignField' ? (
|
|
1664
|
+
<Tooltip title={assignPriorityTip}>
|
|
1665
|
+
<QuestionCircleOutlined
|
|
1666
|
+
style={{ marginInlineStart: 4 }}
|
|
1667
|
+
onClick={(e) => e.stopPropagation()}
|
|
1668
|
+
/>
|
|
1669
|
+
</Tooltip>
|
|
1670
|
+
) : null}
|
|
1671
|
+
<span style={{ marginInlineStart: 2, marginInlineEnd: 8 }}>:</span>
|
|
1672
|
+
</span>
|
|
1673
|
+
<Tooltip title={t('Delete action')}>
|
|
1674
|
+
<Button
|
|
1675
|
+
type="text"
|
|
1676
|
+
size="small"
|
|
1677
|
+
icon={<DeleteOutlined />}
|
|
1678
|
+
onClick={() => handleDeleteAction(index, actionIndex)}
|
|
1679
|
+
/>
|
|
1680
|
+
</Tooltip>
|
|
1681
|
+
</div>
|
|
1682
|
+
<div>
|
|
1683
|
+
{flowEngine.flowSettings.renderStepForm({
|
|
1684
|
+
uiSchema: actionDef.uiSchema,
|
|
1685
|
+
initialValues: action.params,
|
|
1686
|
+
flowEngine,
|
|
1687
|
+
onFormValuesChange: (form: any) => handleActionValueChange(index, actionIndex, form.values),
|
|
1688
|
+
})}
|
|
1689
|
+
</div>
|
|
1690
|
+
</div>
|
|
1691
|
+
);
|
|
1692
|
+
})}
|
|
1693
|
+
</div>
|
|
1694
|
+
) : null}
|
|
1695
|
+
|
|
1696
|
+
{/* Add action 按钮 */}
|
|
1697
|
+
<Dropdown
|
|
1698
|
+
menu={{
|
|
1699
|
+
items: getActionsDefinition().map((action) => ({
|
|
1700
|
+
key: action.name,
|
|
1701
|
+
label: t(action.title || action.name),
|
|
1702
|
+
onClick: () => handleAddAction(index, action.name),
|
|
1703
|
+
})),
|
|
1704
|
+
}}
|
|
1705
|
+
trigger={['hover']}
|
|
1706
|
+
>
|
|
1707
|
+
<Button type="link" icon={<PlusOutlined />} style={{ padding: 0, height: 'auto', textAlign: 'left' }}>
|
|
1708
|
+
{t('Add action')}
|
|
1709
|
+
</Button>
|
|
1710
|
+
</Dropdown>
|
|
1711
|
+
</div>
|
|
1712
|
+
</div>
|
|
1713
|
+
</div>
|
|
1714
|
+
),
|
|
1715
|
+
}));
|
|
1716
|
+
|
|
1717
|
+
return (
|
|
1718
|
+
<>
|
|
1719
|
+
{rules.length > 0 ? (
|
|
1720
|
+
<Collapse
|
|
1721
|
+
items={collapseItems}
|
|
1722
|
+
size="small"
|
|
1723
|
+
style={{ marginBottom: 8 }}
|
|
1724
|
+
defaultActiveKey={rules.length > 0 ? [rules[0].key] : []}
|
|
1725
|
+
accordion
|
|
1726
|
+
/>
|
|
1727
|
+
) : (
|
|
1728
|
+
<div
|
|
1729
|
+
style={{
|
|
1730
|
+
border: '1px dashed #d9d9d9',
|
|
1731
|
+
borderRadius: '6px',
|
|
1732
|
+
backgroundColor: '#fafafa',
|
|
1733
|
+
marginBottom: '8px',
|
|
1734
|
+
}}
|
|
1735
|
+
>
|
|
1736
|
+
<Empty description={t('No linkage rules')} style={{ margin: '20px 0' }} />
|
|
1737
|
+
</div>
|
|
1738
|
+
)}
|
|
1739
|
+
<Button type="dashed" icon={<PlusOutlined />} onClick={handleAddRule} style={{ width: '100%' }}>
|
|
1740
|
+
{t('Add linkage rule')}
|
|
1741
|
+
</Button>
|
|
1742
|
+
</>
|
|
1743
|
+
);
|
|
1744
|
+
},
|
|
1745
|
+
);
|
|
1746
|
+
|
|
1747
|
+
const commonLinkageRulesHandler = async (ctx: FlowContext, params: any) => {
|
|
1748
|
+
const evaluator = (path: string, operator: string, value: any) => {
|
|
1749
|
+
if (!operator) {
|
|
1750
|
+
return true;
|
|
1751
|
+
}
|
|
1752
|
+
return ctx.app.jsonLogic.apply({ [operator]: [path, value] });
|
|
1753
|
+
};
|
|
1754
|
+
|
|
1755
|
+
const linkageRules: LinkageRule[] = params.value as LinkageRule[];
|
|
1756
|
+
const allModels: FlowModel[] = ctx.model.__allModels || (ctx.model.__allModels = []);
|
|
1757
|
+
const directValuePatches: Array<{ path: any; value: any }> = [];
|
|
1758
|
+
const rootCollection = getCollectionFromModel((ctx.model as any)?.context?.blockModel ?? ctx.model);
|
|
1759
|
+
const isSafeToWriteAssociationSubpath = (namePath: any): boolean => {
|
|
1760
|
+
if (!Array.isArray(namePath) || !namePath.length) return true;
|
|
1761
|
+
if (!rootCollection?.getField) return true;
|
|
1762
|
+
|
|
1763
|
+
let collection: any = rootCollection;
|
|
1764
|
+
for (let i = 0; i < namePath.length; i++) {
|
|
1765
|
+
const seg = namePath[i] as any;
|
|
1766
|
+
if (typeof seg === 'number') continue;
|
|
1767
|
+
if (typeof seg !== 'string') continue;
|
|
1768
|
+
|
|
1769
|
+
const field = collection?.getField?.(seg);
|
|
1770
|
+
if (!field) continue;
|
|
1771
|
+
|
|
1772
|
+
const isAssoc = !!field?.isAssociationField?.();
|
|
1773
|
+
const hasTarget = !!field?.targetCollection;
|
|
1774
|
+
const toMany = isToManyAssociationField(field);
|
|
1775
|
+
|
|
1776
|
+
if (toMany && i + 1 < namePath.length) {
|
|
1777
|
+
const next = namePath[i + 1] as any;
|
|
1778
|
+
if (typeof next !== 'number') return false;
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
if (isAssoc && hasTarget) {
|
|
1782
|
+
collection = field.targetCollection;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
return true;
|
|
1787
|
+
};
|
|
1788
|
+
const resolveNamePathForPatch = (path: any): Array<string | number> | null => {
|
|
1789
|
+
if (!path) return null;
|
|
1790
|
+
if (Array.isArray(path)) {
|
|
1791
|
+
const ok = path.length && path.every((seg) => typeof seg === 'string' || typeof seg === 'number');
|
|
1792
|
+
return ok ? (path as Array<string | number>) : null;
|
|
1793
|
+
}
|
|
1794
|
+
if (typeof path !== 'string') return null;
|
|
1795
|
+
const fieldIndex = (ctx.model as any)?.context?.fieldIndex;
|
|
1796
|
+
return resolveDynamicNamePath(path, fieldIndex);
|
|
1797
|
+
};
|
|
1798
|
+
const addFormValuePatch = (patch: { path: any; value: any; whenEmpty?: boolean }) => {
|
|
1799
|
+
if (!patch) return;
|
|
1800
|
+
const path = (patch as any)?.path;
|
|
1801
|
+
if (!path) return;
|
|
1802
|
+
const resolvedPath = resolveNamePathForPatch(path);
|
|
1803
|
+
if (!resolvedPath) {
|
|
1804
|
+
console.warn('[linkageRules] Skip linkage assignment due to failed path resolution', {
|
|
1805
|
+
flowKey: ctx.flowKey,
|
|
1806
|
+
modelUid: ctx.model?.uid,
|
|
1807
|
+
attemptedPath: path,
|
|
1808
|
+
});
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
if (!isSafeToWriteAssociationSubpath(resolvedPath)) {
|
|
1812
|
+
console.warn('[linkageRules] Skip linkage assignment for to-many association subpath without row index', {
|
|
1813
|
+
flowKey: ctx.flowKey,
|
|
1814
|
+
modelUid: ctx.model?.uid,
|
|
1815
|
+
attemptedPath: path,
|
|
1816
|
+
resolvedPath,
|
|
1817
|
+
});
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
const whenEmpty = !!(patch as any)?.whenEmpty;
|
|
1821
|
+
try {
|
|
1822
|
+
const form = ctx.model?.context?.form;
|
|
1823
|
+
const current = form?.getFieldValue?.(resolvedPath);
|
|
1824
|
+
if (whenEmpty && typeof current !== 'undefined' && current !== null && current !== '') {
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
if (_.isEqual(current, (patch as any)?.value)) {
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
} catch {
|
|
1831
|
+
// ignore
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
directValuePatches.push({ path: resolvedPath, value: (patch as any)?.value });
|
|
1835
|
+
};
|
|
1836
|
+
|
|
1837
|
+
const getModelTargetPathForPatch = (model: any): string | null => {
|
|
1838
|
+
if (!model || typeof model !== 'object') return null;
|
|
1839
|
+
try {
|
|
1840
|
+
const init = model?.getStepParams?.('fieldSettings', 'init') as any;
|
|
1841
|
+
const initFieldPath = typeof init?.fieldPath === 'string' ? init.fieldPath : '';
|
|
1842
|
+
const initAssocPath = typeof init?.associationPathName === 'string' ? init.associationPathName : '';
|
|
1843
|
+
|
|
1844
|
+
const fieldPath = initFieldPath || (typeof model?.fieldPath === 'string' ? model.fieldPath : '');
|
|
1845
|
+
const assocPath =
|
|
1846
|
+
initAssocPath || (typeof model?.associationPathName === 'string' ? model.associationPathName : '');
|
|
1847
|
+
|
|
1848
|
+
if (assocPath) {
|
|
1849
|
+
if (!fieldPath) return assocPath;
|
|
1850
|
+
if (fieldPath.startsWith(`${assocPath}.`)) return fieldPath;
|
|
1851
|
+
return `${assocPath}.${fieldPath}`;
|
|
1852
|
+
}
|
|
1853
|
+
if (fieldPath) return fieldPath;
|
|
1854
|
+
} catch {
|
|
1855
|
+
// ignore
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
const name = model?.props?.name;
|
|
1859
|
+
if (typeof name === 'string' && name) return name;
|
|
1860
|
+
if (Array.isArray(name) && name.length) {
|
|
1861
|
+
let out = '';
|
|
1862
|
+
for (const seg of name) {
|
|
1863
|
+
if (typeof seg === 'number') {
|
|
1864
|
+
out += `[${seg}]`;
|
|
1865
|
+
continue;
|
|
1866
|
+
}
|
|
1867
|
+
if (typeof seg !== 'string' || !seg) continue;
|
|
1868
|
+
if (!out) out = seg;
|
|
1869
|
+
else out += `.${seg}`;
|
|
1870
|
+
}
|
|
1871
|
+
return out || null;
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
return null;
|
|
1875
|
+
};
|
|
1876
|
+
|
|
1877
|
+
allModels.forEach((model: any) => {
|
|
1878
|
+
// 重置临时属性
|
|
1879
|
+
model.__props = {};
|
|
1880
|
+
});
|
|
1881
|
+
|
|
1882
|
+
// 1. 运行所有的联动规则
|
|
1883
|
+
for (const rule of linkageRules.filter((r) => r.enable)) {
|
|
1884
|
+
const { condition: conditions, actions } = rule;
|
|
1885
|
+
|
|
1886
|
+
const matched = evaluateConditions(removeInvalidFilterItems(conditions), evaluator);
|
|
1887
|
+
if (!matched) continue;
|
|
1888
|
+
|
|
1889
|
+
for (const action of actions) {
|
|
1890
|
+
const setProps = (
|
|
1891
|
+
model: FlowModel & { __originalProps?: any; __props?: any; __shouldReset?: boolean },
|
|
1892
|
+
props: any,
|
|
1893
|
+
) => {
|
|
1894
|
+
// 存储原始值,用于恢复
|
|
1895
|
+
if (!model.__originalProps) {
|
|
1896
|
+
model.__originalProps = {
|
|
1897
|
+
hiddenModel: model.hidden,
|
|
1898
|
+
hiddenText: undefined,
|
|
1899
|
+
disabled: undefined,
|
|
1900
|
+
required: undefined,
|
|
1901
|
+
hidden: undefined,
|
|
1902
|
+
...model.props,
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
if (!model.__props) {
|
|
1907
|
+
model.__props = {};
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
// 临时存起来,遍历完所有规则后,再统一处理
|
|
1911
|
+
model.__props = {
|
|
1912
|
+
...model.__props,
|
|
1913
|
+
...props,
|
|
1914
|
+
};
|
|
1915
|
+
|
|
1916
|
+
if (allModels.indexOf(model) === -1) {
|
|
1917
|
+
allModels.push(model);
|
|
1918
|
+
}
|
|
1919
|
+
};
|
|
1920
|
+
|
|
1921
|
+
// TODO: 需要改成 runAction 的写法。但 runAction 是异步的,用在这里会不符合预期。后面需要解决这个问题
|
|
1922
|
+
await ctx.getAction(action.name)?.handler(ctx, { ...action.params, setProps, addFormValuePatch });
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
// 2. 合并去重(按 uid)后再实际更改相关 model 的状态,避免重复项把“已设置的临时属性”覆盖掉
|
|
1927
|
+
const mergedByUid = new Map<
|
|
1928
|
+
string,
|
|
1929
|
+
FlowModel & { __originalProps?: any; __props?: any; isFork?: boolean; forkId?: number }
|
|
1930
|
+
>();
|
|
1931
|
+
const mergedPropsByUid = new Map<string, any>();
|
|
1932
|
+
|
|
1933
|
+
allModels.forEach((m: any) => {
|
|
1934
|
+
const uid = m?.uid || String(m);
|
|
1935
|
+
const curProps = m.__props || {};
|
|
1936
|
+
if (!mergedByUid.has(uid)) {
|
|
1937
|
+
mergedByUid.set(uid, m);
|
|
1938
|
+
mergedPropsByUid.set(uid, { ...curProps });
|
|
1939
|
+
} else {
|
|
1940
|
+
// 合并属性:后写覆盖先写;优先选择 fork 模型作为应用目标
|
|
1941
|
+
mergedPropsByUid.set(uid, { ...mergedPropsByUid.get(uid), ...curProps });
|
|
1942
|
+
const exist = mergedByUid.get(uid) as any;
|
|
1943
|
+
if (m.isFork && !exist.isFork) {
|
|
1944
|
+
mergedByUid.set(uid, m);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
});
|
|
1948
|
+
|
|
1949
|
+
mergedByUid.forEach((model: any, uid) => {
|
|
1950
|
+
const patchProps = mergedPropsByUid.get(uid) || {};
|
|
1951
|
+
const newProps = { ...model.__originalProps, ...patchProps };
|
|
1952
|
+
|
|
1953
|
+
model.setProps(_.omit(newProps, ['hiddenModel', 'value', 'hiddenText']));
|
|
1954
|
+
model.hidden = !!newProps.hiddenModel;
|
|
1955
|
+
|
|
1956
|
+
if (newProps.required === true) {
|
|
1957
|
+
const rules = (model.props.rules || []).filter((rule) => !rule.required);
|
|
1958
|
+
rules.push({
|
|
1959
|
+
required: true,
|
|
1960
|
+
message: ctx.t('The field value is required'),
|
|
1961
|
+
});
|
|
1962
|
+
model.setProps('rules', rules);
|
|
1963
|
+
} else if (newProps.required === false) {
|
|
1964
|
+
const rules = (model.props.rules || []).filter((rule) => !rule.required);
|
|
1965
|
+
model.setProps('rules', rules);
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
if (newProps.hiddenText) {
|
|
1969
|
+
model.setProps('title', '');
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
// 目前只有表单的“字段赋值”有 value 属性
|
|
1973
|
+
if ('value' in newProps && model.context.form) {
|
|
1974
|
+
const targetPath = getModelTargetPathForPatch(model);
|
|
1975
|
+
if (!targetPath) {
|
|
1976
|
+
console.warn('[linkageRules] Skip linkage assignment due to missing target path', {
|
|
1977
|
+
flowKey: ctx.flowKey,
|
|
1978
|
+
modelUid: ctx.model?.uid,
|
|
1979
|
+
targetUid: model?.uid,
|
|
1980
|
+
});
|
|
1981
|
+
} else {
|
|
1982
|
+
addFormValuePatch({ path: targetPath, value: newProps.value });
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
model.__props = null;
|
|
1987
|
+
});
|
|
1988
|
+
|
|
1989
|
+
const allPatches = [...directValuePatches];
|
|
1990
|
+
if (!allPatches.length) return;
|
|
1991
|
+
|
|
1992
|
+
const directCtx = ctx as any;
|
|
1993
|
+
const directSetter = directCtx?.setFormValues;
|
|
1994
|
+
const blockCtx = (ctx.model as any)?.context?.blockModel?.context;
|
|
1995
|
+
const blockSetter = blockCtx?.setFormValues;
|
|
1996
|
+
const rawInputArgs = directCtx?.inputArgs as any;
|
|
1997
|
+
const linkageTxId =
|
|
1998
|
+
typeof rawInputArgs?.linkageTxId === 'string' && rawInputArgs.linkageTxId
|
|
1999
|
+
? rawInputArgs.linkageTxId
|
|
2000
|
+
: typeof rawInputArgs?.txId === 'string'
|
|
2001
|
+
? rawInputArgs.txId
|
|
2002
|
+
: undefined;
|
|
2003
|
+
const linkageScopeDepth = getLinkageScopeDepthFromContext(ctx);
|
|
2004
|
+
|
|
2005
|
+
const trySetFormValues = async (fn: any, thisArg: any, source: string) => {
|
|
2006
|
+
await fn.call(thisArg, allPatches, {
|
|
2007
|
+
source,
|
|
2008
|
+
linkageTxId,
|
|
2009
|
+
linkageScopeDepth,
|
|
2010
|
+
});
|
|
2011
|
+
};
|
|
2012
|
+
|
|
2013
|
+
if (typeof directSetter === 'function') {
|
|
2014
|
+
try {
|
|
2015
|
+
await trySetFormValues(directSetter, directCtx, 'linkage');
|
|
2016
|
+
return;
|
|
2017
|
+
} catch (error) {
|
|
2018
|
+
console.warn('[linkageRules] Failed to set form values via setFormValues', {
|
|
2019
|
+
flowKey: ctx.flowKey,
|
|
2020
|
+
modelUid: (ctx.model as any)?.uid,
|
|
2021
|
+
setter: 'ctx',
|
|
2022
|
+
patchCount: allPatches.length,
|
|
2023
|
+
patches: allPatches.slice(0, 10).map((p) => ({ path: p.path, value: previewValueForLog(p.value) })),
|
|
2024
|
+
});
|
|
2025
|
+
console.warn(error);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
if (typeof blockSetter === 'function') {
|
|
2030
|
+
try {
|
|
2031
|
+
await trySetFormValues(blockSetter, blockCtx, 'linkage');
|
|
2032
|
+
return;
|
|
2033
|
+
} catch (error) {
|
|
2034
|
+
console.warn('[linkageRules] Failed to set form values via setFormValues', {
|
|
2035
|
+
flowKey: ctx.flowKey,
|
|
2036
|
+
modelUid: (ctx.model as any)?.uid,
|
|
2037
|
+
setter: 'blockModel',
|
|
2038
|
+
patchCount: allPatches.length,
|
|
2039
|
+
patches: allPatches.slice(0, 10).map((p) => ({ path: p.path, value: previewValueForLog(p.value) })),
|
|
2040
|
+
});
|
|
2041
|
+
console.warn(error);
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
// 最后兜底:无 setFormValues(非表单 block scope)或 setFormValues 失败时直接写入 antd form。
|
|
2046
|
+
// 注意:antd form 可能已被 FormValueRuntime patch;此处不要再手动触发 formValuesChange 以避免自触发循环。
|
|
2047
|
+
allPatches.forEach(({ path, value }) => {
|
|
2048
|
+
try {
|
|
2049
|
+
const form = ctx.model?.context?.form;
|
|
2050
|
+
if (typeof form?.getFieldValue === 'function') {
|
|
2051
|
+
const prev = form.getFieldValue(path);
|
|
2052
|
+
if (_.isEqual(prev, value)) {
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
form?.setFieldValue?.(path, value);
|
|
2057
|
+
} catch (error) {
|
|
2058
|
+
console.warn('[linkageRules] Failed to set form field value (fallback setFieldValue)', { path }, error);
|
|
2059
|
+
}
|
|
2060
|
+
});
|
|
2061
|
+
};
|
|
2062
|
+
|
|
2063
|
+
export const blockLinkageRules = defineAction({
|
|
2064
|
+
name: 'blockLinkageRules',
|
|
2065
|
+
title: tExpr('Block linkage rules'),
|
|
2066
|
+
uiMode: 'embed',
|
|
2067
|
+
uiSchema(ctx) {
|
|
2068
|
+
return {
|
|
2069
|
+
value: {
|
|
2070
|
+
type: 'array',
|
|
2071
|
+
'x-component': LinkageRulesUI,
|
|
2072
|
+
'x-component-props': {
|
|
2073
|
+
supportedActions: getSupportedActions(ctx, ActionScene.BLOCK_LINKAGE_RULES),
|
|
2074
|
+
title: tExpr('Block linkage rules'),
|
|
2075
|
+
},
|
|
2076
|
+
},
|
|
2077
|
+
};
|
|
2078
|
+
},
|
|
2079
|
+
defaultParams: {
|
|
2080
|
+
value: [],
|
|
2081
|
+
},
|
|
2082
|
+
useRawParams: true,
|
|
2083
|
+
handler: async (ctx, params) => {
|
|
2084
|
+
const resolved = await resolveLinkageRulesParamsPreservingRunJsScripts(ctx, params);
|
|
2085
|
+
return commonLinkageRulesHandler(ctx, resolved);
|
|
2086
|
+
},
|
|
2087
|
+
});
|
|
2088
|
+
|
|
2089
|
+
export const actionLinkageRules = defineAction({
|
|
2090
|
+
name: 'actionLinkageRules',
|
|
2091
|
+
title: tExpr('Linkage rules'),
|
|
2092
|
+
uiMode: 'embed',
|
|
2093
|
+
uiSchema(ctx) {
|
|
2094
|
+
return {
|
|
2095
|
+
value: {
|
|
2096
|
+
type: 'array',
|
|
2097
|
+
'x-component': LinkageRulesUI,
|
|
2098
|
+
'x-component-props': {
|
|
2099
|
+
supportedActions: getSupportedActions(ctx, ActionScene.ACTION_LINKAGE_RULES),
|
|
2100
|
+
title: tExpr('Linkage rules'),
|
|
2101
|
+
},
|
|
2102
|
+
},
|
|
2103
|
+
};
|
|
2104
|
+
},
|
|
2105
|
+
defaultParams: {
|
|
2106
|
+
value: [],
|
|
2107
|
+
},
|
|
2108
|
+
useRawParams: true,
|
|
2109
|
+
handler: async (ctx, params) => {
|
|
2110
|
+
const resolved = await resolveLinkageRulesParamsPreservingRunJsScripts(ctx, params);
|
|
2111
|
+
return commonLinkageRulesHandler(ctx, resolved);
|
|
2112
|
+
},
|
|
2113
|
+
});
|
|
2114
|
+
|
|
2115
|
+
export const fieldLinkageRules = defineAction({
|
|
2116
|
+
name: 'fieldLinkageRules',
|
|
2117
|
+
title: tExpr('Field linkage rules'),
|
|
2118
|
+
uiMode: 'embed',
|
|
2119
|
+
uiSchema(ctx) {
|
|
2120
|
+
return {
|
|
2121
|
+
value: {
|
|
2122
|
+
type: 'array',
|
|
2123
|
+
'x-component': LinkageRulesUI,
|
|
2124
|
+
'x-component-props': {
|
|
2125
|
+
supportedActions: getSupportedActions(ctx, ActionScene.FIELD_LINKAGE_RULES),
|
|
2126
|
+
title: tExpr('Field linkage rules'),
|
|
2127
|
+
},
|
|
2128
|
+
},
|
|
2129
|
+
};
|
|
2130
|
+
},
|
|
2131
|
+
defaultParams: {
|
|
2132
|
+
value: [],
|
|
2133
|
+
},
|
|
2134
|
+
useRawParams: true,
|
|
2135
|
+
handler: async (ctx, params) => {
|
|
2136
|
+
if (ctx.model.hidden) {
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
const rootLinkageScopeDepth = 0;
|
|
2141
|
+
const defineSharedRuntimeMeta = (targetCtx: any) => {
|
|
2142
|
+
if (!targetCtx || typeof targetCtx.defineProperty !== 'function') return;
|
|
2143
|
+
const inputArgs = (ctx as any)?.inputArgs;
|
|
2144
|
+
if (inputArgs && typeof inputArgs === 'object') {
|
|
2145
|
+
targetCtx.defineProperty('inputArgs', {
|
|
2146
|
+
value: {
|
|
2147
|
+
...inputArgs,
|
|
2148
|
+
},
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
targetCtx.defineProperty('linkageScopeDepth', {
|
|
2152
|
+
value: rootLinkageScopeDepth,
|
|
2153
|
+
});
|
|
2154
|
+
};
|
|
2155
|
+
|
|
2156
|
+
defineSharedRuntimeMeta(ctx as any);
|
|
2157
|
+
|
|
2158
|
+
const rootCollection = getCollectionFromModel((ctx.model as any)?.context?.blockModel ?? ctx.model);
|
|
2159
|
+
const getRowScopeKeyForTargetPath = (targetPath: string): string | null => {
|
|
2160
|
+
if (!rootCollection?.getField) return null;
|
|
2161
|
+
const segs = parsePathString(String(targetPath || '')).filter((seg) => typeof seg !== 'object');
|
|
2162
|
+
if (segs.length < 2) return null;
|
|
2163
|
+
let collection: any = rootCollection;
|
|
2164
|
+
const toManyChain: string[] = [];
|
|
2165
|
+
for (let i = 0; i < segs.length - 1; i++) {
|
|
2166
|
+
const seg = segs[i];
|
|
2167
|
+
if (typeof seg !== 'string') continue;
|
|
2168
|
+
const field = collection?.getField?.(seg);
|
|
2169
|
+
if (!field?.isAssociationField?.()) break;
|
|
2170
|
+
const toMany = isToManyAssociationField(field);
|
|
2171
|
+
if (toMany) toManyChain.push(seg);
|
|
2172
|
+
if (toMany) {
|
|
2173
|
+
const next = segs[i + 1] as any;
|
|
2174
|
+
if (typeof next === 'number') {
|
|
2175
|
+
i += 1;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
collection = field?.targetCollection;
|
|
2179
|
+
if (!collection?.getField) break;
|
|
2180
|
+
}
|
|
2181
|
+
if (!toManyChain.length) return null;
|
|
2182
|
+
const deepest = toManyChain[toManyChain.length - 1];
|
|
2183
|
+
const occurrence = toManyChain.filter((n) => n === deepest).length;
|
|
2184
|
+
return `${deepest}#${occurrence}`;
|
|
2185
|
+
};
|
|
2186
|
+
|
|
2187
|
+
const requiresRowIndexForTargetPath = (targetPath: string): boolean => {
|
|
2188
|
+
if (!rootCollection?.getField) return false;
|
|
2189
|
+
const segs = parsePathString(String(targetPath || '')).filter((seg) => typeof seg !== 'object');
|
|
2190
|
+
if (segs.length < 2) return false;
|
|
2191
|
+
let collection: any = rootCollection;
|
|
2192
|
+
for (let i = 0; i < segs.length - 1; i++) {
|
|
2193
|
+
const seg = segs[i];
|
|
2194
|
+
if (typeof seg !== 'string') continue;
|
|
2195
|
+
const field = collection?.getField?.(seg);
|
|
2196
|
+
if (!field?.isAssociationField?.()) break;
|
|
2197
|
+
const toMany = isToManyAssociationField(field);
|
|
2198
|
+
if (toMany) {
|
|
2199
|
+
const next = segs[i + 1] as any;
|
|
2200
|
+
if (typeof next !== 'number') return true;
|
|
2201
|
+
i += 1;
|
|
2202
|
+
}
|
|
2203
|
+
collection = field?.targetCollection;
|
|
2204
|
+
if (!collection?.getField) break;
|
|
2205
|
+
}
|
|
2206
|
+
return false;
|
|
2207
|
+
};
|
|
2208
|
+
|
|
2209
|
+
const legacyTargetPathResolver = createLegacyTargetPathResolver(ctx);
|
|
2210
|
+
const splitParams = () => {
|
|
2211
|
+
const rawRules = params?.value;
|
|
2212
|
+
if (!Array.isArray(rawRules) || !rawRules.length) {
|
|
2213
|
+
return { blockParams: params, rowParamsByKey: new Map<string, any>() };
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
const blockRules: any[] = [];
|
|
2217
|
+
const rowRulesByKey = new Map<string, any[]>();
|
|
2218
|
+
|
|
2219
|
+
const addRowRule = (rowKey: string, baseRule: any, actions: any[]) => {
|
|
2220
|
+
if (!rowKey || !actions.length) return;
|
|
2221
|
+
const arr = rowRulesByKey.get(rowKey) || [];
|
|
2222
|
+
arr.push({ ...baseRule, actions });
|
|
2223
|
+
rowRulesByKey.set(rowKey, arr);
|
|
2224
|
+
};
|
|
2225
|
+
|
|
2226
|
+
for (const rule of rawRules) {
|
|
2227
|
+
if (!rule || typeof rule !== 'object') continue;
|
|
2228
|
+
const baseRule = {
|
|
2229
|
+
key: (rule as any).key,
|
|
2230
|
+
title: (rule as any).title,
|
|
2231
|
+
enable: (rule as any).enable,
|
|
2232
|
+
condition: (rule as any).condition,
|
|
2233
|
+
};
|
|
2234
|
+
const actions = Array.isArray((rule as any).actions) ? ((rule as any).actions as any[]) : [];
|
|
2235
|
+
|
|
2236
|
+
const blockActions: any[] = [];
|
|
2237
|
+
const rowActionsByKey = new Map<string, any[]>();
|
|
2238
|
+
|
|
2239
|
+
for (const action of actions) {
|
|
2240
|
+
const actionName = (action as any)?.name;
|
|
2241
|
+
const actionParams = (action as any)?.params;
|
|
2242
|
+
const rawValue = actionParams?.value;
|
|
2243
|
+
|
|
2244
|
+
const splitAssignAction = (legacy: {
|
|
2245
|
+
mode: 'default' | 'assign';
|
|
2246
|
+
valueKey: 'assignValue' | 'initialValue';
|
|
2247
|
+
}) => {
|
|
2248
|
+
const items = normalizeAssignRuleItemsFromLinkageParams(rawValue, legacy, legacyTargetPathResolver);
|
|
2249
|
+
if (!items.length) return { block: null as any, rows: new Map<string, any>() };
|
|
2250
|
+
|
|
2251
|
+
const blockItems: any[] = [];
|
|
2252
|
+
const rowItemsByKey = new Map<string, any[]>();
|
|
2253
|
+
|
|
2254
|
+
for (const it of items) {
|
|
2255
|
+
const targetPath = it?.targetPath ? String(it.targetPath) : '';
|
|
2256
|
+
if (!targetPath) {
|
|
2257
|
+
blockItems.push(it);
|
|
2258
|
+
continue;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
const rowScopeKey = getRowScopeKeyForTargetPath(targetPath);
|
|
2262
|
+
if (rowScopeKey && requiresRowIndexForTargetPath(targetPath)) {
|
|
2263
|
+
const arr = rowItemsByKey.get(rowScopeKey) || [];
|
|
2264
|
+
arr.push(it);
|
|
2265
|
+
rowItemsByKey.set(rowScopeKey, arr);
|
|
2266
|
+
} else {
|
|
2267
|
+
blockItems.push(it);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
const blockAction =
|
|
2272
|
+
blockItems.length > 0
|
|
2273
|
+
? {
|
|
2274
|
+
...action,
|
|
2275
|
+
params: { ...actionParams, value: blockItems },
|
|
2276
|
+
}
|
|
2277
|
+
: null;
|
|
2278
|
+
|
|
2279
|
+
const rowActions = new Map<string, any>();
|
|
2280
|
+
for (const [rowScopeKey, rowItems] of rowItemsByKey.entries()) {
|
|
2281
|
+
if (!rowItems.length) continue;
|
|
2282
|
+
rowActions.set(rowScopeKey, {
|
|
2283
|
+
...action,
|
|
2284
|
+
params: { ...actionParams, value: rowItems },
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
return { block: blockAction, rows: rowActions };
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
if (actionName === 'linkageAssignField') {
|
|
2292
|
+
const split = splitAssignAction({ mode: 'assign', valueKey: 'assignValue' });
|
|
2293
|
+
if (split.block) blockActions.push(split.block);
|
|
2294
|
+
split.rows.forEach((a, rowKey) => {
|
|
2295
|
+
const arr = rowActionsByKey.get(rowKey) || [];
|
|
2296
|
+
arr.push(a);
|
|
2297
|
+
rowActionsByKey.set(rowKey, arr);
|
|
2298
|
+
});
|
|
2299
|
+
continue;
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
if (actionName === 'setFieldsDefaultValue') {
|
|
2303
|
+
const split = splitAssignAction({ mode: 'default', valueKey: 'initialValue' });
|
|
2304
|
+
if (split.block) blockActions.push(split.block);
|
|
2305
|
+
split.rows.forEach((a, rowKey) => {
|
|
2306
|
+
const arr = rowActionsByKey.get(rowKey) || [];
|
|
2307
|
+
arr.push(a);
|
|
2308
|
+
rowActionsByKey.set(rowKey, arr);
|
|
2309
|
+
});
|
|
2310
|
+
continue;
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
// other actions: run at block scope only
|
|
2314
|
+
blockActions.push(action);
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2317
|
+
if (blockActions.length) {
|
|
2318
|
+
blockRules.push({ ...baseRule, actions: blockActions });
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
rowActionsByKey.forEach((actionsForKey, rowKey) => {
|
|
2322
|
+
addRowRule(rowKey, baseRule, actionsForKey);
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
const blockParams = { ...params, value: blockRules };
|
|
2327
|
+
const rowParamsByKey = new Map<string, any>();
|
|
2328
|
+
rowRulesByKey.forEach((rulesForKey, rowKey) => {
|
|
2329
|
+
rowParamsByKey.set(rowKey, { ...params, value: rulesForKey });
|
|
2330
|
+
});
|
|
2331
|
+
|
|
2332
|
+
return { blockParams, rowParamsByKey };
|
|
2333
|
+
};
|
|
2334
|
+
|
|
2335
|
+
const { blockParams, rowParamsByKey } = splitParams();
|
|
2336
|
+
|
|
2337
|
+
const resolvedBlock = await resolveLinkageRulesParamsPreservingRunJsScripts(ctx, blockParams);
|
|
2338
|
+
await commonLinkageRulesHandler(ctx, resolvedBlock);
|
|
2339
|
+
|
|
2340
|
+
if (!rowParamsByKey.size) {
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
const getRowScopeKeyFromModel = (model: any): string | null => {
|
|
2345
|
+
const fieldIndex = model?.context?.fieldIndex;
|
|
2346
|
+
const arr = Array.isArray(fieldIndex) ? fieldIndex : [];
|
|
2347
|
+
if (!arr.length) return null;
|
|
2348
|
+
const entries: Array<{ name: string; index: number }> = [];
|
|
2349
|
+
for (const it of arr) {
|
|
2350
|
+
if (typeof it !== 'string') continue;
|
|
2351
|
+
const [name, indexStr] = it.split(':');
|
|
2352
|
+
const index = Number(indexStr);
|
|
2353
|
+
if (!name || Number.isNaN(index)) continue;
|
|
2354
|
+
entries.push({ name, index });
|
|
2355
|
+
}
|
|
2356
|
+
if (!entries.length) return null;
|
|
2357
|
+
const deepest = entries[entries.length - 1].name;
|
|
2358
|
+
const occurrence = entries.reduce((count, e) => (e.name === deepest ? count + 1 : count), 0);
|
|
2359
|
+
return `${deepest}#${occurrence}`;
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2362
|
+
const isRowGridForkModel = (model: any): boolean => {
|
|
2363
|
+
if (!model || typeof model !== 'object') return false;
|
|
2364
|
+
if ((model as any)?.subModels?.field) return false;
|
|
2365
|
+
if (!(model as any)?.subModels?.items) return false;
|
|
2366
|
+
return !!getRowScopeKeyFromModel(model);
|
|
2367
|
+
};
|
|
2368
|
+
|
|
2369
|
+
const collectRowGridForksByKey = (): Map<string, FlowModel[]> => {
|
|
2370
|
+
const out = new Map<string, FlowModel[]>();
|
|
2371
|
+
const engine = ctx.engine;
|
|
2372
|
+
if (!engine?.forEachModel) return out;
|
|
2373
|
+
|
|
2374
|
+
engine.forEachModel((m: FlowModel) => {
|
|
2375
|
+
const forks: any = (m as any)?.forks;
|
|
2376
|
+
if (!forks || typeof forks.forEach !== 'function') return;
|
|
2377
|
+
forks.forEach((fork: any) => {
|
|
2378
|
+
if (!fork || fork.disposed) return;
|
|
2379
|
+
if (!isRowGridForkModel(fork)) return;
|
|
2380
|
+
const rowScopeKey = getRowScopeKeyFromModel(fork);
|
|
2381
|
+
if (!rowScopeKey) return;
|
|
2382
|
+
const arr = out.get(rowScopeKey) || [];
|
|
2383
|
+
arr.push(fork as FlowModel);
|
|
2384
|
+
out.set(rowScopeKey, arr);
|
|
2385
|
+
});
|
|
2386
|
+
});
|
|
2387
|
+
|
|
2388
|
+
return out;
|
|
2389
|
+
};
|
|
2390
|
+
|
|
2391
|
+
const runRowScoped = async (): Promise<boolean> => {
|
|
2392
|
+
const forksByKey = collectRowGridForksByKey();
|
|
2393
|
+
let hasAnyRowFork = false;
|
|
2394
|
+
for (const [rowScopeKey, rowParams] of rowParamsByKey.entries()) {
|
|
2395
|
+
const forks = forksByKey.get(rowScopeKey) || [];
|
|
2396
|
+
if (forks.length) hasAnyRowFork = true;
|
|
2397
|
+
if (!forks.length) continue;
|
|
2398
|
+
for (const forkModel of forks) {
|
|
2399
|
+
const rowCtx = new FlowRuntimeContext(forkModel, ctx.flowKey);
|
|
2400
|
+
defineSharedRuntimeMeta(rowCtx as any);
|
|
2401
|
+
try {
|
|
2402
|
+
const resolvedRow = await resolveLinkageRulesParamsPreservingRunJsScripts(rowCtx, rowParams);
|
|
2403
|
+
await commonLinkageRulesHandler(rowCtx, resolvedRow);
|
|
2404
|
+
} catch (error) {
|
|
2405
|
+
console.warn('[linkageRules] Failed to run row-scoped linkage rules', {
|
|
2406
|
+
flowKey: ctx.flowKey,
|
|
2407
|
+
modelUid: ctx.model?.uid,
|
|
2408
|
+
rowScopeKey,
|
|
2409
|
+
forkUid: forkModel?.uid,
|
|
2410
|
+
});
|
|
2411
|
+
console.warn(error);
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
return hasAnyRowFork;
|
|
2416
|
+
};
|
|
2417
|
+
|
|
2418
|
+
const hasAnyRowFork = await runRowScoped();
|
|
2419
|
+
|
|
2420
|
+
// 如果当前未找到任何 row fork,但存在需要 row 上下文的赋值规则,延迟一帧再跑一次(解决 add 新行时 fork 尚未创建的问题)
|
|
2421
|
+
if (!hasAnyRowFork) {
|
|
2422
|
+
const flagKey = '__pendingLinkageRowScopedRetry__';
|
|
2423
|
+
const anyModel = ctx.model as any;
|
|
2424
|
+
if (!anyModel?.[flagKey]) {
|
|
2425
|
+
console.warn('[linkageRules] Row-scoped linkage assignment deferred (row forks not ready), will retry', {
|
|
2426
|
+
flowKey: ctx.flowKey,
|
|
2427
|
+
modelUid: (ctx.model as any)?.uid,
|
|
2428
|
+
rowKeys: Array.from(rowParamsByKey.keys()),
|
|
2429
|
+
});
|
|
2430
|
+
anyModel[flagKey] = true;
|
|
2431
|
+
setTimeout(() => {
|
|
2432
|
+
anyModel[flagKey] = false;
|
|
2433
|
+
const base = ctx.model as any;
|
|
2434
|
+
if (!base || base.disposed) return;
|
|
2435
|
+
void runRowScoped().catch((error) => {
|
|
2436
|
+
console.warn('[linkageRules] Failed to retry row-scoped linkage rules', error);
|
|
2437
|
+
});
|
|
2438
|
+
}, 0);
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
},
|
|
2442
|
+
});
|
|
2443
|
+
|
|
2444
|
+
export const subFormFieldLinkageRules = defineAction({
|
|
2445
|
+
name: 'subFormFieldLinkageRules',
|
|
2446
|
+
title: tExpr('Field linkage rules'),
|
|
2447
|
+
uiMode: 'embed',
|
|
2448
|
+
uiSchema(ctx) {
|
|
2449
|
+
return {
|
|
2450
|
+
value: {
|
|
2451
|
+
type: 'array',
|
|
2452
|
+
'x-component': LinkageRulesUI,
|
|
2453
|
+
'x-component-props': {
|
|
2454
|
+
supportedActions: getSupportedActions(ctx, ActionScene.SUB_FORM_FIELD_LINKAGE_RULES),
|
|
2455
|
+
title: tExpr('Field linkage rules'),
|
|
2456
|
+
},
|
|
2457
|
+
},
|
|
2458
|
+
};
|
|
2459
|
+
},
|
|
2460
|
+
defaultParams: {
|
|
2461
|
+
value: [],
|
|
2462
|
+
},
|
|
2463
|
+
useRawParams: true,
|
|
2464
|
+
handler: async (ctx, params) => {
|
|
2465
|
+
if (ctx.model.hidden) {
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2468
|
+
const grid = ctx.model?.subModels?.grid;
|
|
2469
|
+
if (!grid) {
|
|
2470
|
+
console.warn('[subFormFieldLinkageRules] Missing subModels.grid', {
|
|
2471
|
+
flowKey: ctx.flowKey,
|
|
2472
|
+
modelUid: ctx.model?.uid,
|
|
2473
|
+
});
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
const linkageScopeDepth = getLinkageScopeDepthFromModel((ctx as any)?.model);
|
|
2478
|
+
|
|
2479
|
+
const createScopedFlowContext = (model: FlowModel) => {
|
|
2480
|
+
const flowContext = new FlowRuntimeContext(model, ctx.flowKey);
|
|
2481
|
+
const inputArgs = (ctx as any)?.inputArgs;
|
|
2482
|
+
if (inputArgs && typeof inputArgs === 'object') {
|
|
2483
|
+
flowContext.defineProperty('inputArgs', {
|
|
2484
|
+
value: {
|
|
2485
|
+
...inputArgs,
|
|
2486
|
+
},
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
flowContext.defineProperty('linkageScopeDepth', {
|
|
2490
|
+
value: linkageScopeDepth,
|
|
2491
|
+
});
|
|
2492
|
+
return flowContext;
|
|
2493
|
+
};
|
|
2494
|
+
|
|
2495
|
+
// 适配对一子表单的场景
|
|
2496
|
+
if (ctx.model instanceof SubFormFieldModel) {
|
|
2497
|
+
if (grid.hidden) {
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
const flowContext = createScopedFlowContext(grid);
|
|
2501
|
+
try {
|
|
2502
|
+
const resolved = await resolveLinkageRulesParamsPreservingRunJsScripts(flowContext, params);
|
|
2503
|
+
await commonLinkageRulesHandler(flowContext, resolved);
|
|
2504
|
+
} catch (error) {
|
|
2505
|
+
console.warn('[subFormFieldLinkageRules] Failed to run linkage rules (to-one)', {
|
|
2506
|
+
flowKey: ctx.flowKey,
|
|
2507
|
+
modelUid: ctx.model?.uid,
|
|
2508
|
+
gridUid: grid?.uid,
|
|
2509
|
+
});
|
|
2510
|
+
console.warn(error);
|
|
2511
|
+
}
|
|
2512
|
+
} else {
|
|
2513
|
+
await Promise.all(
|
|
2514
|
+
(grid.forks || []).map(async (forkModel: FlowModel) => {
|
|
2515
|
+
if (forkModel.hidden) {
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
const flowContext = createScopedFlowContext(forkModel);
|
|
2519
|
+
try {
|
|
2520
|
+
const resolved = await resolveLinkageRulesParamsPreservingRunJsScripts(flowContext, params);
|
|
2521
|
+
await commonLinkageRulesHandler(flowContext, resolved);
|
|
2522
|
+
} catch (error) {
|
|
2523
|
+
console.warn('[subFormFieldLinkageRules] Failed to run linkage rules for fork', {
|
|
2524
|
+
flowKey: ctx.flowKey,
|
|
2525
|
+
modelUid: ctx.model?.uid,
|
|
2526
|
+
forkUid: forkModel?.uid,
|
|
2527
|
+
gridUid: grid?.uid,
|
|
2528
|
+
});
|
|
2529
|
+
console.warn(error);
|
|
2530
|
+
}
|
|
2531
|
+
}),
|
|
2532
|
+
);
|
|
2533
|
+
}
|
|
2534
|
+
},
|
|
2535
|
+
});
|
|
2536
|
+
|
|
2537
|
+
export const detailsFieldLinkageRules = defineAction({
|
|
2538
|
+
name: 'detailsFieldLinkageRules',
|
|
2539
|
+
title: tExpr('Field linkage rules'),
|
|
2540
|
+
uiMode: 'embed',
|
|
2541
|
+
uiSchema(ctx) {
|
|
2542
|
+
return {
|
|
2543
|
+
value: {
|
|
2544
|
+
type: 'array',
|
|
2545
|
+
'x-component': LinkageRulesUI,
|
|
2546
|
+
'x-component-props': {
|
|
2547
|
+
supportedActions: getSupportedActions(ctx, ActionScene.DETAILS_FIELD_LINKAGE_RULES),
|
|
2548
|
+
title: tExpr('Field linkage rules'),
|
|
2549
|
+
},
|
|
2550
|
+
},
|
|
2551
|
+
};
|
|
2552
|
+
},
|
|
2553
|
+
defaultParams: {
|
|
2554
|
+
value: [],
|
|
2555
|
+
},
|
|
2556
|
+
useRawParams: true,
|
|
2557
|
+
handler: async (ctx, params) => {
|
|
2558
|
+
if (ctx.model.hidden) {
|
|
2559
|
+
return;
|
|
2560
|
+
}
|
|
2561
|
+
const resolved = await resolveLinkageRulesParamsPreservingRunJsScripts(ctx, params);
|
|
2562
|
+
return commonLinkageRulesHandler(ctx, resolved);
|
|
2563
|
+
},
|
|
2564
|
+
});
|
|
2565
|
+
|
|
2566
|
+
function getSupportedActions(ctx: FlowContext, scene: ActionScene) {
|
|
2567
|
+
const result = [...ctx.getActions().values()]
|
|
2568
|
+
.filter((action) => {
|
|
2569
|
+
let scenes = action.scene;
|
|
2570
|
+
if (!scenes) {
|
|
2571
|
+
return false;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
if (!Array.isArray(scenes)) {
|
|
2575
|
+
scenes = [scenes];
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
return scenes.includes(scene);
|
|
2579
|
+
})
|
|
2580
|
+
.sort((a, b) => (a.sort || 0) - (b.sort || 0))
|
|
2581
|
+
.map((action) => action.name);
|
|
2582
|
+
|
|
2583
|
+
return result;
|
|
2584
|
+
}
|