@nocobase/client-v2 2.1.0-alpha.3 → 2.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +99 -0
- package/es/Application.d.ts +46 -0
- package/es/BaseApplication.d.ts +177 -0
- package/es/PinnedPluginListContext.d.ts +22 -0
- package/es/Plugin.d.ts +59 -0
- package/es/PluginManager.d.ts +45 -0
- package/es/PluginSettingsManager.d.ts +206 -0
- package/es/RouteRepository.d.ts +124 -0
- package/{lib → es}/RouterManager.d.ts +26 -13
- package/{lib → 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/es/ai/skills-manager/index.d.ts +9 -0
- 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/{lib → 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/dataScopeFilter.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/es/flow/admin-shell/admin-layout/PinnedPluginListLite.d.ts +15 -0
- 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/es/flow/admin-shell/admin-layout/useApplications.d.ts +12 -0
- 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 +28 -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/es/flow/components/code-editor/extension/index.d.ts +9 -0
- 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 +33 -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/es/flow/components/placeholders/FieldPlaceholder.d.ts +10 -0
- 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/es/flow/internal/components/Markdown/markdown-it-plugins/mermaidPlugin.d.ts +13 -0
- 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/es/flow/internal/constants/HeightMode.d.ts +13 -0
- 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 +34 -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/es/flow/models/actions/JSActionModel.d.ts +13 -0
- 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 +116 -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 +44 -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/es/flow/models/blocks/filter-form/fields/FilterFormFieldModel.d.ts +11 -0
- 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/es/flow/models/blocks/table/TableSelectModel.d.ts +14 -0
- 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/es/flow/models/fields/AssociationFieldModel/index.d.ts +15 -0
- 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 +50 -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/es/flow-compat/passwordUtils.d.ts +9 -0
- 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 +12 -0
- package/{lib → es}/hooks/usePlugin.d.ts +2 -2
- package/{lib → es}/hooks/useRouter.d.ts +1 -1
- package/es/i18n.d.ts +22 -0
- package/es/index.d.ts +33 -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/globalDeps.d.ts +13 -0
- package/{lib → es}/utils/index.d.ts +1 -1
- package/{lib → 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 +30 -6
- package/src/Application.tsx +77 -424
- package/src/BaseApplication.tsx +652 -0
- package/src/PinnedPluginListContext.tsx +33 -0
- package/src/Plugin.ts +24 -8
- package/src/PluginManager.ts +31 -19
- package/src/PluginSettingsManager.ts +504 -98
- package/src/RouteRepository.ts +247 -0
- package/src/RouterManager.tsx +62 -17
- package/src/WebSocketClient.ts +4 -4
- package/src/__tests__/PluginSettingsManager.test.ts +228 -0
- package/src/__tests__/app.test.tsx +270 -33
- package/src/__tests__/authRedirect.test.ts +181 -0
- package/src/__tests__/dataSourceRuntime.test.tsx +34 -0
- package/src/__tests__/globalDeps.test.ts +28 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +185 -0
- package/src/__tests__/plugin.test.ts +61 -0
- package/src/__tests__/remotePlugins.test.ts +99 -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__/dataScopeFilter.test.ts +158 -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 +63 -0
- package/src/flow/actions/dataScopeFilter.ts +70 -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 +112 -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 +204 -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 +124 -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 +256 -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 +287 -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 +949 -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 +1141 -0
- package/src/flow/components/code-editor/types.ts +37 -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 +184 -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 +110 -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 +1286 -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.dragOverlayConfig.test.ts +44 -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 +452 -0
- package/src/flow/models/base/__tests__/GridModel.dragOverlay.test.ts +129 -0
- package/src/flow/models/base/__tests__/GridModel.dragSnapshotContainer.test.ts +286 -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.resizeLayout.test.ts +124 -0
- package/src/flow/models/base/__tests__/GridModel.visibleLayout.test.ts +257 -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 +338 -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 +258 -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__/FilterFormBlockModel.cleanup.test.ts +138 -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 +188 -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 +835 -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 +307 -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 +1080 -0
- package/src/flow/models/blocks/table/TableColumnModel.tsx +556 -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__/JSColumnModel.test.tsx +51 -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__/TableBlockModel.quickEditRefresh.test.ts +49 -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 +224 -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 +68 -0
- package/src/utils/index.tsx +8 -4
- package/src/utils/remotePlugins.ts +12 -15
- package/src/utils/requirejs.ts +1 -1
- package/LICENSE.txt +0 -172
- package/lib/Application.d.ts +0 -124
- package/lib/Application.js +0 -489
- 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 -67
- package/lib/PluginSettingsManager.js +0 -148
- package/lib/RouterManager.js +0 -198
- 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/index.js +0 -79
- package/lib/utils/remotePlugins.js +0 -131
- package/lib/utils/requirejs.js +0 -1361
- package/lib/utils/types.js +0 -28
- /package/{lib → es}/MockApplication.d.ts +0 -0
- /package/{lib → es}/components/BlankComponent.d.ts +0 -0
- /package/{lib → es}/components/MainComponent.d.ts +0 -0
- /package/{lib → es}/components/RouterBridge.d.ts +0 -0
- /package/{lib → es}/components/RouterContextCleaner.d.ts +0 -0
- /package/{lib → es}/context.d.ts +0 -0
- /package/{lib → es}/hooks/index.d.ts +0 -0
- /package/{lib → es}/utils/requirejs.d.ts +0 -0
- /package/{lib → es}/utils/types.d.ts +0 -0
|
@@ -0,0 +1,1930 @@
|
|
|
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 { isObservable, reaction, toJS } from '@formily/reactive';
|
|
11
|
+
import { FlowContext, FlowModel, isRunJSValue, normalizeRunJSValue, runjsWithSafeGlobals } from '@nocobase/flow-engine';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
import { dayjs } from '@nocobase/utils/client';
|
|
14
|
+
import { evaluateCondition } from './conditions';
|
|
15
|
+
import { collectStaticDepsFromRunJSValue, collectStaticDepsFromTemplateValue, DepCollector, recordDep } from './deps';
|
|
16
|
+
import { namePathToPathKey, parsePathString, pathKeyToNamePath } from './path';
|
|
17
|
+
import type { FormAssignRuleItem, FormValueWriteMeta, NamePath, Patch, SetOptions, ValueSource } from './types';
|
|
18
|
+
import { createTxId, isEmptyValue } from './utils';
|
|
19
|
+
import { isToManyAssociationField } from '../../../../internal/utils/modelUtils';
|
|
20
|
+
import { getSubTableRowIdentity } from '../../../fields/AssociationFieldModel/SubTableFieldModel/rowIdentity';
|
|
21
|
+
|
|
22
|
+
/** Symbol to indicate rule value resolution should be skipped */
|
|
23
|
+
const SKIP_RULE_VALUE = Symbol('SKIP_RULE_VALUE');
|
|
24
|
+
const UNRESOLVED_ASSOCIATION_IDENTITY = Symbol('UNRESOLVED_ASSOCIATION_IDENTITY');
|
|
25
|
+
|
|
26
|
+
// default 规则的优先级:
|
|
27
|
+
// - step 初始值(editItemSettings/formItemSettings.initialValue):priority=0(低于表单赋值)
|
|
28
|
+
// - props.initialValue(通常为联动规则临时写入):需要覆盖表单赋值,因此提升优先级
|
|
29
|
+
const LINKAGE_DEFAULT_RULE_PRIORITY = 1000;
|
|
30
|
+
|
|
31
|
+
type RuleDeps = Set<string>;
|
|
32
|
+
|
|
33
|
+
type RuleState = {
|
|
34
|
+
deps: RuleDeps;
|
|
35
|
+
depDisposers: Array<() => void>;
|
|
36
|
+
runSeq: number;
|
|
37
|
+
/** Write sequence when this rule was last scheduled */
|
|
38
|
+
scheduledAtWriteSeq: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type RuntimeRule = {
|
|
42
|
+
id: string;
|
|
43
|
+
source: ValueSource;
|
|
44
|
+
priority: number;
|
|
45
|
+
debounceMs: number;
|
|
46
|
+
getEnabled: () => boolean;
|
|
47
|
+
getTarget: () => string | NamePath;
|
|
48
|
+
getValue: () => any;
|
|
49
|
+
getCondition?: () => any;
|
|
50
|
+
getContext: () => any;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type ObservableBinding = {
|
|
54
|
+
source: ValueSource;
|
|
55
|
+
pathKey: string;
|
|
56
|
+
dispose: () => void;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type AssignMode = 'default' | 'assign';
|
|
60
|
+
|
|
61
|
+
export type RuleEngineOptions = {
|
|
62
|
+
getBlockModelUid: () => string;
|
|
63
|
+
getActionName: () => string | undefined;
|
|
64
|
+
getBlockContext: () => any;
|
|
65
|
+
getEngine: () => any;
|
|
66
|
+
getEngineModel: (uid: string) => FlowModel | null;
|
|
67
|
+
isDisposed: () => boolean;
|
|
68
|
+
valuesMirror: any;
|
|
69
|
+
changeTick: { value: number };
|
|
70
|
+
getWriteSeq: () => number;
|
|
71
|
+
txWriteCounts: Map<string, Map<string, number>>;
|
|
72
|
+
createTrackingFormValues: (collector: DepCollector) => any;
|
|
73
|
+
tryResolveNamePath: (callerCtx: any, path: string | NamePath) => NamePath | null;
|
|
74
|
+
getFormValueAtPath: (namePath: NamePath) => any;
|
|
75
|
+
setFormValues: (callerCtx: any, patch: Patch, options?: SetOptions) => Promise<void>;
|
|
76
|
+
findExplicitHit: (pathKey: string) => string | null;
|
|
77
|
+
lastDefaultValueByPathKey: Map<string, any>;
|
|
78
|
+
lastWriteMetaByPathKey: Map<string, FormValueWriteMeta>;
|
|
79
|
+
observableBindings: Map<string, ObservableBinding>;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export class RuleEngine {
|
|
83
|
+
private readonly options: RuleEngineOptions;
|
|
84
|
+
|
|
85
|
+
private readonly rules = new Map<string, { rule: RuntimeRule; state: RuleState }>();
|
|
86
|
+
// 仅用于 rule 引擎内部的“同源 default 规则”优先级仲裁;避免低优先级 default 在高优先级 default 写入后再次回写覆盖。
|
|
87
|
+
private readonly lastRuleWriteByTargetKey = new Map<
|
|
88
|
+
string,
|
|
89
|
+
{ source: ValueSource; priority: number; writeSeq: number }
|
|
90
|
+
>();
|
|
91
|
+
private readonly assignTemplatesByTargetPath = new Map<
|
|
92
|
+
string,
|
|
93
|
+
Array<FormAssignRuleItem & { __key: string; __order: number }>
|
|
94
|
+
>();
|
|
95
|
+
/** 当前表单中“已配置到 UI 的字段(FormItemModel)”的 targetPath 集合,用于避免对 row grid 重复注册规则 */
|
|
96
|
+
private readonly formItemTargetPaths = new Set<string>();
|
|
97
|
+
/** targetPath -> updateAssociation(SubForm/SubTable 等) */
|
|
98
|
+
private readonly updateAssociationByTargetPath = new Map<string, boolean>();
|
|
99
|
+
private readonly pendingRuleIds = new Set<string>();
|
|
100
|
+
private readonly ruleDebounceUntilById = new Map<string, number>();
|
|
101
|
+
private readonly ruleDebounceTimersById = new Map<string, ReturnType<typeof setTimeout>>();
|
|
102
|
+
|
|
103
|
+
private readonly defaultRuleIdsByMasterUid = new Map<string, Set<string>>();
|
|
104
|
+
private readonly defaultRuleMasterDisposers = new Map<string, () => void>();
|
|
105
|
+
|
|
106
|
+
private runningRules = false;
|
|
107
|
+
private rulesEnabled = false;
|
|
108
|
+
private currentRuleTxId: string | null = null;
|
|
109
|
+
|
|
110
|
+
constructor(options: RuleEngineOptions) {
|
|
111
|
+
this.options = options;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private getAssignRuleBlockId(templateKey: string) {
|
|
115
|
+
return `form-assign:${templateKey}:block`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private removeAssignRuleBlockInstance(templateKey: string) {
|
|
119
|
+
const blockId = this.getAssignRuleBlockId(templateKey);
|
|
120
|
+
if (this.rules.has(blockId)) {
|
|
121
|
+
this.removeRule(blockId);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private removeRowGridAssignRuleInstances(templateKey: string) {
|
|
126
|
+
const prefix = `form-assign:${templateKey}:`;
|
|
127
|
+
const blockId = this.getAssignRuleBlockId(templateKey);
|
|
128
|
+
const toRemove: string[] = [];
|
|
129
|
+
|
|
130
|
+
for (const [id, entry] of this.rules.entries()) {
|
|
131
|
+
if (!id.startsWith(prefix)) continue;
|
|
132
|
+
if (id === blockId) continue;
|
|
133
|
+
const ctx = entry?.rule?.getContext?.();
|
|
134
|
+
const ctxModel = ctx?.model;
|
|
135
|
+
if (ctxModel && this.isRowGridModel(ctxModel as any)) {
|
|
136
|
+
toRemove.push(id);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
for (const id of toRemove) {
|
|
141
|
+
this.removeRule(id);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private hasAnyNonBlockAssignRuleInstance(templateKey: string) {
|
|
146
|
+
const prefix = `form-assign:${templateKey}:`;
|
|
147
|
+
const blockId = this.getAssignRuleBlockId(templateKey);
|
|
148
|
+
for (const id of this.rules.keys()) {
|
|
149
|
+
if (!id.startsWith(prefix)) continue;
|
|
150
|
+
if (id === blockId) continue;
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private ensureBlockAssignRuleInstancesForTargetPath(targetPath: string) {
|
|
157
|
+
if (this.options.isDisposed()) return;
|
|
158
|
+
if (!targetPath) return;
|
|
159
|
+
if (!this.shouldCreateBlockLevelAssignRule(targetPath)) return;
|
|
160
|
+
|
|
161
|
+
const templates = this.assignTemplatesByTargetPath.get(targetPath) || [];
|
|
162
|
+
if (!templates.length) return;
|
|
163
|
+
|
|
164
|
+
for (const template of templates) {
|
|
165
|
+
const templateKey = template?.__key ? String(template.__key) : '';
|
|
166
|
+
if (!templateKey) continue;
|
|
167
|
+
if (this.hasAnyNonBlockAssignRuleInstance(templateKey)) continue;
|
|
168
|
+
|
|
169
|
+
const mode: AssignMode = template?.mode === 'default' ? 'default' : 'assign';
|
|
170
|
+
const source: ValueSource = mode === 'default' ? 'default' : 'system';
|
|
171
|
+
const enabled = template?.enable !== false;
|
|
172
|
+
const id = this.getAssignRuleBlockId(templateKey);
|
|
173
|
+
if (this.rules.has(id)) continue;
|
|
174
|
+
|
|
175
|
+
const rule: RuntimeRule = {
|
|
176
|
+
id,
|
|
177
|
+
source,
|
|
178
|
+
priority: 10 + (template.__order || 0),
|
|
179
|
+
debounceMs: 0,
|
|
180
|
+
getEnabled: () => enabled && !!targetPath,
|
|
181
|
+
getTarget: () => targetPath,
|
|
182
|
+
getValue: () => template?.value,
|
|
183
|
+
getCondition: () => template?.condition,
|
|
184
|
+
getContext: () => this.options.getBlockContext(),
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
this.rules.set(id, { rule, state: { deps: new Set(), depDisposers: [], runSeq: 0, scheduledAtWriteSeq: 0 } });
|
|
188
|
+
this.scheduleRule(id);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private getCollectionFromContext(baseCtx: any): any | undefined {
|
|
193
|
+
return baseCtx?.collection ?? baseCtx?.model?.context?.collection;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private getRootCollection(): any | undefined {
|
|
197
|
+
const blockCtx = this.options.getBlockContext();
|
|
198
|
+
return this.getCollectionFromContext(blockCtx);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private shouldCreateBlockLevelAssignRule(targetPath: string): boolean {
|
|
202
|
+
const blockCtx = this.options.getBlockContext();
|
|
203
|
+
let collection = this.getCollectionFromContext(blockCtx);
|
|
204
|
+
if (!collection?.getField) return true;
|
|
205
|
+
|
|
206
|
+
const segs = parsePathString(targetPath).filter((seg) => typeof seg !== 'object') as NamePath;
|
|
207
|
+
if (segs.length <= 1) return true;
|
|
208
|
+
|
|
209
|
+
for (let i = 0; i < segs.length - 1; i++) {
|
|
210
|
+
const seg = segs[i];
|
|
211
|
+
if (typeof seg !== 'string') continue;
|
|
212
|
+
|
|
213
|
+
const field = collection?.getField?.(seg);
|
|
214
|
+
if (!field?.isAssociationField?.()) break;
|
|
215
|
+
|
|
216
|
+
// 对多关联:若后续没有显式 index,则 block 级无法确定要写入哪一行,必须等 row fork 上下文
|
|
217
|
+
if (isToManyAssociationField(field)) {
|
|
218
|
+
const next = segs[i + 1];
|
|
219
|
+
if (typeof next !== 'number') {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
// 已显式指定 index(如 users[0].nickname):跳过 index 段继续解析
|
|
223
|
+
i += 1;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
collection = field?.targetCollection;
|
|
227
|
+
if (!collection?.getField) break;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 对关联字段嵌套属性(如 user.name / user.profile.name):
|
|
235
|
+
* - 依赖应包含关联对象本身(user / user.profile),否则当关联对象从 null -> {id} 时,user.name 仍为 undefined,无法触发 rule re-run。
|
|
236
|
+
* - 写入前需校验关联对象已存在,避免隐式创建关联对象。
|
|
237
|
+
*/
|
|
238
|
+
private collectAssociationPrefixPaths(baseCtx: any, targetNamePath: NamePath): NamePath[] {
|
|
239
|
+
const out: NamePath[] = [];
|
|
240
|
+
let collection = this.getRootCollection() || this.getCollectionFromContext(baseCtx);
|
|
241
|
+
if (!collection?.getField) return out;
|
|
242
|
+
|
|
243
|
+
const prefix: NamePath = [];
|
|
244
|
+
for (let i = 0; i < targetNamePath.length - 1; i++) {
|
|
245
|
+
const seg = targetNamePath[i];
|
|
246
|
+
if (typeof seg !== 'string') break;
|
|
247
|
+
|
|
248
|
+
const field = collection?.getField?.(seg);
|
|
249
|
+
if (!field?.isAssociationField?.()) break;
|
|
250
|
+
|
|
251
|
+
prefix.push(seg);
|
|
252
|
+
|
|
253
|
+
// 对多关联:需要将 index 一并纳入 prefix(如 users[0]),否则无法检查/追踪行内的关联对象
|
|
254
|
+
if (isToManyAssociationField(field)) {
|
|
255
|
+
const next = targetNamePath[i + 1];
|
|
256
|
+
if (typeof next !== 'number') break;
|
|
257
|
+
prefix.push(next);
|
|
258
|
+
i += 1;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
out.push([...prefix]);
|
|
262
|
+
collection = (field as any)?.targetCollection;
|
|
263
|
+
if (!collection?.getField) break;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
private shouldSkipToManyAssociationWriteWithoutIndex(baseCtx: any, targetNamePath: NamePath): boolean {
|
|
270
|
+
let collection = this.getRootCollection() || this.getCollectionFromContext(baseCtx);
|
|
271
|
+
if (!collection?.getField) return false;
|
|
272
|
+
|
|
273
|
+
for (let i = 0; i < targetNamePath.length - 1; i++) {
|
|
274
|
+
const seg = targetNamePath[i];
|
|
275
|
+
if (typeof seg !== 'string') continue;
|
|
276
|
+
|
|
277
|
+
const field = collection?.getField?.(seg);
|
|
278
|
+
if (!field?.isAssociationField?.()) break;
|
|
279
|
+
|
|
280
|
+
if (isToManyAssociationField(field)) {
|
|
281
|
+
const next = targetNamePath[i + 1];
|
|
282
|
+
if (typeof next !== 'number') {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
i += 1;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
collection = field?.targetCollection;
|
|
289
|
+
if (!collection?.getField) break;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private shouldSkipAssociationNestedWrite(baseCtx: any, targetNamePath: NamePath): boolean {
|
|
296
|
+
const prefixes = this.collectAssociationPrefixPaths(baseCtx, targetNamePath);
|
|
297
|
+
if (!prefixes.length) return false;
|
|
298
|
+
|
|
299
|
+
for (const p of prefixes) {
|
|
300
|
+
const v = this.options.getFormValueAtPath(p);
|
|
301
|
+
if (v == null) {
|
|
302
|
+
// updateAssociation(子表单/子表格)场景下允许隐式创建关联对象/行,
|
|
303
|
+
// 以便嵌套字段的默认值/复制模式在首次渲染时即可生效。
|
|
304
|
+
const targetPath = p.filter((seg) => typeof seg === 'string').join('.');
|
|
305
|
+
if (targetPath && this.getUpdateAssociationForTargetPath(targetPath)) {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
// 特殊:当目标为“关联记录主键/targetKey”(如 user.id)时,允许在关联对象为空时写入,
|
|
309
|
+
// 以支持通过主键为关联字段设置默认值/赋值(常见于 RecordSelect/RecordPicker)。
|
|
310
|
+
if (this.isAssociationTargetKeyWrite(baseCtx, targetNamePath, p)) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
if (typeof v !== 'object') return true;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private getAssociationTargetKeyFields(associationField: any): string[] {
|
|
322
|
+
const raw =
|
|
323
|
+
associationField?.targetKey ??
|
|
324
|
+
associationField?.targetCollection?.filterTargetKey ??
|
|
325
|
+
associationField?.targetCollection?.filterByTk ??
|
|
326
|
+
'id';
|
|
327
|
+
if (Array.isArray(raw)) {
|
|
328
|
+
return raw.filter((v): v is string => typeof v === 'string' && !!v);
|
|
329
|
+
}
|
|
330
|
+
if (typeof raw === 'string' && raw) return [raw];
|
|
331
|
+
return ['id'];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private resolveAssociationFieldByPrefixPath(baseCtx: any, prefixPath: NamePath): any | null {
|
|
335
|
+
let collection = this.getRootCollection() || this.getCollectionFromContext(baseCtx);
|
|
336
|
+
if (!collection?.getField) return null;
|
|
337
|
+
|
|
338
|
+
let lastAssociationField: any | null = null;
|
|
339
|
+
for (const seg of prefixPath) {
|
|
340
|
+
if (typeof seg === 'number') {
|
|
341
|
+
// index segment for to-many association
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (typeof seg !== 'string' || !seg) break;
|
|
345
|
+
const field: any = collection?.getField?.(seg);
|
|
346
|
+
if (!field?.isAssociationField?.()) break;
|
|
347
|
+
lastAssociationField = field;
|
|
348
|
+
collection = field?.targetCollection;
|
|
349
|
+
if (!collection?.getField) break;
|
|
350
|
+
}
|
|
351
|
+
return lastAssociationField;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
private isAssociationTargetKeyWrite(baseCtx: any, targetNamePath: NamePath, prefixPath: NamePath): boolean {
|
|
355
|
+
// Only allow direct `assoc.<targetKey>` writes (e.g. `user.id`).
|
|
356
|
+
if (!Array.isArray(targetNamePath) || !Array.isArray(prefixPath)) return false;
|
|
357
|
+
if (targetNamePath.length !== prefixPath.length + 1) return false;
|
|
358
|
+
const keySeg = targetNamePath[prefixPath.length];
|
|
359
|
+
if (typeof keySeg !== 'string' || !keySeg) return false;
|
|
360
|
+
|
|
361
|
+
const assocField = this.resolveAssociationFieldByPrefixPath(baseCtx, prefixPath);
|
|
362
|
+
if (!assocField?.isAssociationField?.()) return false;
|
|
363
|
+
if (isToManyAssociationField(assocField)) return false;
|
|
364
|
+
|
|
365
|
+
const keys = this.getAssociationTargetKeyFields(assocField);
|
|
366
|
+
return keys.includes(keySeg);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
private collectUpdateAssociationInitPatches(
|
|
370
|
+
baseCtx: any,
|
|
371
|
+
targetNamePath: NamePath,
|
|
372
|
+
): Array<{ path: NamePath; value: any }> | null {
|
|
373
|
+
const prefixes = this.collectAssociationPrefixPaths(baseCtx, targetNamePath);
|
|
374
|
+
if (!prefixes.length) return [];
|
|
375
|
+
|
|
376
|
+
const patches: Array<{ path: NamePath; value: any }> = [];
|
|
377
|
+
|
|
378
|
+
for (const p of prefixes) {
|
|
379
|
+
const v = this.options.getFormValueAtPath(p);
|
|
380
|
+
if (v == null) {
|
|
381
|
+
const targetPath = p.filter((seg) => typeof seg === 'string').join('.');
|
|
382
|
+
if (!targetPath) return null;
|
|
383
|
+
if (this.getUpdateAssociationForTargetPath(targetPath)) {
|
|
384
|
+
// 标记为“新增记录”,与子表单的 add({ __is_new__: true }) 行为一致。
|
|
385
|
+
patches.push({ path: [...p, '__is_new__'], value: true });
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// 特殊:当目标为“关联记录主键/targetKey”(如 user.id)时,
|
|
390
|
+
// 允许在关联对象为空时写入,并初始化为空对象以确保后续 setFieldValue 能正确落值。
|
|
391
|
+
if (this.isAssociationTargetKeyWrite(baseCtx, targetNamePath, p)) {
|
|
392
|
+
patches.push({ path: [...p], value: {} });
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
if (typeof v !== 'object') return null;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const byKey = new Map<string, { path: NamePath; value: any }>();
|
|
402
|
+
for (const it of patches) {
|
|
403
|
+
const k = namePathToPathKey(it.path as any);
|
|
404
|
+
if (!byKey.has(k)) {
|
|
405
|
+
byKey.set(k, it);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
return Array.from(byKey.values());
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
dispose() {
|
|
413
|
+
for (const { state } of this.rules.values()) {
|
|
414
|
+
state.depDisposers.forEach((d) => d());
|
|
415
|
+
}
|
|
416
|
+
this.rules.clear();
|
|
417
|
+
this.pendingRuleIds.clear();
|
|
418
|
+
this.assignTemplatesByTargetPath.clear();
|
|
419
|
+
|
|
420
|
+
for (const disposer of this.defaultRuleMasterDisposers.values()) {
|
|
421
|
+
disposer();
|
|
422
|
+
}
|
|
423
|
+
this.defaultRuleMasterDisposers.clear();
|
|
424
|
+
this.defaultRuleIdsByMasterUid.clear();
|
|
425
|
+
|
|
426
|
+
for (const timer of this.ruleDebounceTimersById.values()) {
|
|
427
|
+
clearTimeout(timer);
|
|
428
|
+
}
|
|
429
|
+
this.ruleDebounceTimersById.clear();
|
|
430
|
+
this.ruleDebounceUntilById.clear();
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
enable() {
|
|
434
|
+
this.rulesEnabled = true;
|
|
435
|
+
if (this.pendingRuleIds.size && !this.runningRules) {
|
|
436
|
+
void this.flushRules();
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
syncAssignRules(items: FormAssignRuleItem[]) {
|
|
441
|
+
if (this.options.isDisposed()) return;
|
|
442
|
+
const raw = Array.isArray(items) ? items : [];
|
|
443
|
+
const next = raw.map((item, index) => ({
|
|
444
|
+
...item,
|
|
445
|
+
key: item?.key ? String(item.key) : `idx:${index}`,
|
|
446
|
+
}));
|
|
447
|
+
const prefix = 'form-assign:';
|
|
448
|
+
|
|
449
|
+
// 1) 清理旧的 assign 规则实例(含 block 级与 fork 级)
|
|
450
|
+
for (const id of Array.from(this.rules.keys())) {
|
|
451
|
+
if (!id.startsWith(prefix)) continue;
|
|
452
|
+
this.removeRule(id);
|
|
453
|
+
}
|
|
454
|
+
this.assignTemplatesByTargetPath.clear();
|
|
455
|
+
this.formItemTargetPaths.clear();
|
|
456
|
+
this.updateAssociationByTargetPath.clear();
|
|
457
|
+
|
|
458
|
+
// 2) 归一化模板:按 targetPath 分组,后续在 model:mounted 时按实例注册
|
|
459
|
+
let order = 0;
|
|
460
|
+
for (const item of next) {
|
|
461
|
+
const targetPath = item?.targetPath ? String(item.targetPath) : '';
|
|
462
|
+
if (!targetPath) continue;
|
|
463
|
+
const arr = this.assignTemplatesByTargetPath.get(targetPath) || [];
|
|
464
|
+
order += 1;
|
|
465
|
+
arr.push({ ...(item as any), __key: String(item.key), __order: order });
|
|
466
|
+
this.assignTemplatesByTargetPath.set(targetPath, arr);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// 3) 为当前已存在的模型实例创建 rule(含 fork);对“无对应字段模型”的模板创建 block 级 rule
|
|
470
|
+
const engine = this.options.getEngine();
|
|
471
|
+
const matchedTargetPaths = new Set<string>();
|
|
472
|
+
if (engine?.forEachModel) {
|
|
473
|
+
// 3.1) 记录当前表单中已配置字段(FormItemModel)的 targetPath,避免在 row grid 上重复注册
|
|
474
|
+
engine.forEachModel((model: FlowModel) => {
|
|
475
|
+
if (!this.isModelInThisForm(model)) return;
|
|
476
|
+
if (!(model as any)?.subModels?.field) return;
|
|
477
|
+
const p = this.getModelTargetPath(model);
|
|
478
|
+
if (p) this.formItemTargetPaths.add(p);
|
|
479
|
+
this.cacheUpdateAssociationForModel(model);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
const visit = (model: FlowModel) => {
|
|
483
|
+
this.cacheUpdateAssociationForModel(model);
|
|
484
|
+
this.tryRegisterAssignRuleInstancesForModel(model, matchedTargetPaths);
|
|
485
|
+
|
|
486
|
+
// fork models(例如子表单行内 item fork / 字段 fork)不会被注册到 FlowEngine.modelInstances,
|
|
487
|
+
// 因此不会出现在 engine.forEachModel 中;需要从 master.forks 中补齐,确保保存后 syncAssignRules 也能覆盖已挂载的子表单行。
|
|
488
|
+
const forks: any = (model as any)?.forks;
|
|
489
|
+
if (forks && typeof forks.forEach === 'function') {
|
|
490
|
+
forks.forEach((fork: any) => {
|
|
491
|
+
if (!fork || (fork as any)?.disposed) return;
|
|
492
|
+
this.tryRegisterAssignRuleInstancesForModel(fork as any, matchedTargetPaths);
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
engine.forEachModel((model: FlowModel) => {
|
|
497
|
+
visit(model);
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// block 级(嵌套属性等):当当前 form 内没有任何模型命中该 targetPath 时,使用 blockContext 运行
|
|
502
|
+
for (const [targetPath, templates] of this.assignTemplatesByTargetPath.entries()) {
|
|
503
|
+
if (matchedTargetPaths.has(targetPath)) continue;
|
|
504
|
+
if (!this.shouldCreateBlockLevelAssignRule(targetPath)) continue;
|
|
505
|
+
for (const template of templates) {
|
|
506
|
+
const mode: AssignMode = template?.mode === 'default' ? 'default' : 'assign';
|
|
507
|
+
const source: ValueSource = mode === 'default' ? 'default' : 'system';
|
|
508
|
+
const enabled = template?.enable !== false;
|
|
509
|
+
const id = `${prefix}${template.__key}:block`;
|
|
510
|
+
if (this.rules.has(id)) this.removeRule(id);
|
|
511
|
+
|
|
512
|
+
const rule: RuntimeRule = {
|
|
513
|
+
id,
|
|
514
|
+
source,
|
|
515
|
+
priority: 10 + (template.__order || 0),
|
|
516
|
+
debounceMs: 0,
|
|
517
|
+
getEnabled: () => enabled && !!targetPath,
|
|
518
|
+
getTarget: () => targetPath,
|
|
519
|
+
getValue: () => template?.value,
|
|
520
|
+
getCondition: () => template?.condition,
|
|
521
|
+
getContext: () => this.options.getBlockContext(),
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
this.rules.set(id, { rule, state: { deps: new Set(), depDisposers: [], runSeq: 0, scheduledAtWriteSeq: 0 } });
|
|
525
|
+
this.scheduleRule(id);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
for (const id of Array.from(this.rules.keys())) {
|
|
530
|
+
if (!id.startsWith('default:')) continue;
|
|
531
|
+
this.scheduleRule(id);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
onModelMounted(model: FlowModel) {
|
|
536
|
+
// 维护“已配置到 UI 的字段 targetPath”集合:仅 master 参与(fork 不代表配置项存在/删除)
|
|
537
|
+
if (this.isModelInThisForm(model) && !(model as any)?.isFork && (model as any)?.subModels?.field) {
|
|
538
|
+
const p = this.getModelTargetPath(model);
|
|
539
|
+
if (p) this.formItemTargetPaths.add(p);
|
|
540
|
+
this.cacheUpdateAssociationForModel(model);
|
|
541
|
+
}
|
|
542
|
+
this.tryRegisterDefaultRuleInstance(model);
|
|
543
|
+
this.tryRegisterAssignRuleInstancesForModel(model);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
onModelUnmounted(model: FlowModel) {
|
|
547
|
+
this.tryUnregisterDefaultRuleInstance(model);
|
|
548
|
+
this.tryUnregisterAssignRuleInstancesForModel(model);
|
|
549
|
+
|
|
550
|
+
// 字段模型卸载后:为其对应的 targetPath(以及潜在的嵌套 targetPath)恢复 block-level 兜底实例,
|
|
551
|
+
// 以保证“先配置规则→后添加字段→再移除字段”行为稳定。
|
|
552
|
+
if (this.isModelInThisForm(model) && (model as any)?.subModels?.field) {
|
|
553
|
+
const p = this.getModelTargetPath(model);
|
|
554
|
+
if (p) {
|
|
555
|
+
this.ensureBlockAssignRuleInstancesForTargetPath(p);
|
|
556
|
+
|
|
557
|
+
if (!(model as any)?.isFork) {
|
|
558
|
+
this.updateAssociationByTargetPath.delete(p);
|
|
559
|
+
this.formItemTargetPaths.delete(p);
|
|
560
|
+
|
|
561
|
+
// 对一关联字段可能承载其子属性规则实例;卸载时这些子属性规则也需要回退到 block-level。
|
|
562
|
+
const prefix = `${p}.`;
|
|
563
|
+
for (const targetPath of this.assignTemplatesByTargetPath.keys()) {
|
|
564
|
+
if (!targetPath.startsWith(prefix)) continue;
|
|
565
|
+
this.ensureBlockAssignRuleInstancesForTargetPath(targetPath);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// 对多子表单场景:若该字段是 users.age 这类路径,row grid 模型仍在时需要重刷一次以便重新注册 row-grid 规则。
|
|
569
|
+
// 这里避免做全量 sync,仅触发一次按当前模型树的重新注册。
|
|
570
|
+
const engine = this.options.getEngine();
|
|
571
|
+
if (engine?.forEachModel) {
|
|
572
|
+
const visit = (m: FlowModel) => {
|
|
573
|
+
this.tryRegisterAssignRuleInstancesForModel(m);
|
|
574
|
+
const forks: any = (m as any)?.forks;
|
|
575
|
+
if (forks && typeof forks.forEach === 'function') {
|
|
576
|
+
forks.forEach((fork: any) => {
|
|
577
|
+
if (!fork || (fork as any)?.disposed) return;
|
|
578
|
+
this.tryRegisterAssignRuleInstancesForModel(fork as any);
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
engine.forEachModel((m: FlowModel) => visit(m));
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
private isModelInThisForm(model: FlowModel) {
|
|
590
|
+
const block = model?.context?.blockModel;
|
|
591
|
+
if (!block) return false;
|
|
592
|
+
return String(block.uid) === String(this.options.getBlockModelUid());
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
private cacheUpdateAssociationForModel(model: FlowModel) {
|
|
596
|
+
if (this.options.isDisposed()) return;
|
|
597
|
+
if (!this.isModelInThisForm(model)) return;
|
|
598
|
+
if (!model || typeof model !== 'object') return;
|
|
599
|
+
if ((model as any)?.isFork) return;
|
|
600
|
+
if (!(model as any)?.subModels?.field) return;
|
|
601
|
+
|
|
602
|
+
const p = this.getModelTargetPath(model);
|
|
603
|
+
if (!p) return;
|
|
604
|
+
|
|
605
|
+
const fieldModel: any = (model as any)?.subModels?.field;
|
|
606
|
+
const next = !!fieldModel?.updateAssociation;
|
|
607
|
+
const prev = this.updateAssociationByTargetPath.get(p);
|
|
608
|
+
|
|
609
|
+
// once true, keep true (avoid being overwritten by another model instance)
|
|
610
|
+
if (prev === true) return;
|
|
611
|
+
this.updateAssociationByTargetPath.set(p, next);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
private getUpdateAssociationForTargetPath(targetPath: string): boolean {
|
|
615
|
+
const key = String(targetPath || '');
|
|
616
|
+
if (!key) return false;
|
|
617
|
+
|
|
618
|
+
if (this.updateAssociationByTargetPath.has(key)) {
|
|
619
|
+
return !!this.updateAssociationByTargetPath.get(key);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// Fallback: scan existing models once (e.g. called before syncAssignRules finishes scanning).
|
|
623
|
+
const engine = this.options.getEngine();
|
|
624
|
+
if (engine?.forEachModel) {
|
|
625
|
+
engine.forEachModel((m: FlowModel) => {
|
|
626
|
+
this.cacheUpdateAssociationForModel(m);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
if (this.updateAssociationByTargetPath.has(key)) {
|
|
631
|
+
return !!this.updateAssociationByTargetPath.get(key);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// Cache negative result; model:mounted will override when applicable.
|
|
635
|
+
this.updateAssociationByTargetPath.set(key, false);
|
|
636
|
+
return false;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
private getDefaultRuleId(model: FlowModel) {
|
|
640
|
+
const forkId = model?.['isFork'] ? String(model?.['forkId'] ?? 'fork') : 'master';
|
|
641
|
+
const uid = model?.uid ? String(model.uid) : String(model);
|
|
642
|
+
return `default:${uid}:${forkId}`;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
private getModelTargetNamePath(model: FlowModel): NamePath | null {
|
|
646
|
+
const fp = model?.context?.fieldPathArray;
|
|
647
|
+
if (Array.isArray(fp) && fp.length) return fp as NamePath;
|
|
648
|
+
|
|
649
|
+
const props = typeof model?.getProps === 'function' ? model.getProps() : model?.props;
|
|
650
|
+
const name = props?.name;
|
|
651
|
+
if (Array.isArray(name)) return name as any;
|
|
652
|
+
if (typeof name === 'string') {
|
|
653
|
+
return name.includes('.') ? (name.split('.') as any) : ([name] as any);
|
|
654
|
+
}
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
private getAssignTemplateTargetPathForModel(model: FlowModel): string {
|
|
659
|
+
const direct = this.getModelTargetPath(model);
|
|
660
|
+
if (direct) return direct;
|
|
661
|
+
|
|
662
|
+
const targetNamePath = this.getModelTargetNamePath(model);
|
|
663
|
+
if (!targetNamePath?.length) return '';
|
|
664
|
+
|
|
665
|
+
const normalized = targetNamePath.filter((seg) => typeof seg !== 'number');
|
|
666
|
+
if (!normalized.length) return '';
|
|
667
|
+
|
|
668
|
+
return namePathToPathKey(normalized as NamePath);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
private hasAssignTemplateForTargetPath(targetPath: string): boolean {
|
|
672
|
+
const key = String(targetPath || '');
|
|
673
|
+
if (!key) return false;
|
|
674
|
+
return this.assignTemplatesByTargetPath.has(key);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
private tryRegisterDefaultRuleInstance(model: FlowModel) {
|
|
678
|
+
if (this.options.isDisposed()) return;
|
|
679
|
+
if (!this.isModelInThisForm(model)) return;
|
|
680
|
+
if (!model || typeof model !== 'object') return;
|
|
681
|
+
|
|
682
|
+
const props = typeof model.getProps === 'function' ? model.getProps() : (model as any).props;
|
|
683
|
+
if (!props || typeof props !== 'object') return;
|
|
684
|
+
|
|
685
|
+
const target = this.getModelTargetNamePath(model);
|
|
686
|
+
if (!target) return;
|
|
687
|
+
|
|
688
|
+
const id = this.getDefaultRuleId(model);
|
|
689
|
+
if (this.rules.has(id)) return;
|
|
690
|
+
|
|
691
|
+
const master = (model as any).master || model;
|
|
692
|
+
const assignTemplateTargetPath = this.getAssignTemplateTargetPathForModel(model);
|
|
693
|
+
this.bindMasterInitialValue(master, id);
|
|
694
|
+
|
|
695
|
+
const getRawPropsInitialValue = () => {
|
|
696
|
+
const p = (master as any)?.getProps?.() ?? (master as any)?.props;
|
|
697
|
+
return p?.initialValue;
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
const initialPropsInitialValue = getRawPropsInitialValue();
|
|
701
|
+
let hasRuntimePropsInitialValueChange = false;
|
|
702
|
+
|
|
703
|
+
const getPropsInitialValue = () => {
|
|
704
|
+
const next = getRawPropsInitialValue();
|
|
705
|
+
if (!hasRuntimePropsInitialValueChange && !_.isEqual(next, initialPropsInitialValue)) {
|
|
706
|
+
hasRuntimePropsInitialValueChange = true;
|
|
707
|
+
}
|
|
708
|
+
if (!this.hasAssignTemplateForTargetPath(assignTemplateTargetPath)) {
|
|
709
|
+
return next;
|
|
710
|
+
}
|
|
711
|
+
if (hasRuntimePropsInitialValueChange) {
|
|
712
|
+
return next;
|
|
713
|
+
}
|
|
714
|
+
if (typeof initialPropsInitialValue !== 'undefined') {
|
|
715
|
+
return undefined;
|
|
716
|
+
}
|
|
717
|
+
return next;
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
const getDefaultRulePriority = () => {
|
|
721
|
+
return typeof getPropsInitialValue() !== 'undefined' ? LINKAGE_DEFAULT_RULE_PRIORITY : 0;
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
const getStepDefaultValue = () => {
|
|
725
|
+
if (this.hasAssignTemplateForTargetPath(assignTemplateTargetPath)) {
|
|
726
|
+
return undefined;
|
|
727
|
+
}
|
|
728
|
+
try {
|
|
729
|
+
const fromEdit = master?.getStepParams?.('editItemSettings', 'initialValue')?.defaultValue;
|
|
730
|
+
if (typeof fromEdit !== 'undefined') return fromEdit;
|
|
731
|
+
const fromLegacy = master?.getStepParams?.('formItemSettings', 'initialValue')?.defaultValue;
|
|
732
|
+
if (typeof fromLegacy !== 'undefined') return fromLegacy;
|
|
733
|
+
} catch {
|
|
734
|
+
// ignore
|
|
735
|
+
}
|
|
736
|
+
return undefined;
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
const rule: RuntimeRule = {
|
|
740
|
+
id,
|
|
741
|
+
source: 'default',
|
|
742
|
+
priority: getDefaultRulePriority(),
|
|
743
|
+
debounceMs: 0,
|
|
744
|
+
getEnabled: () => {
|
|
745
|
+
const fromProps = getPropsInitialValue();
|
|
746
|
+
if (typeof fromProps !== 'undefined') return true;
|
|
747
|
+
const fromStep = getStepDefaultValue();
|
|
748
|
+
return typeof fromStep !== 'undefined';
|
|
749
|
+
},
|
|
750
|
+
getTarget: () => {
|
|
751
|
+
return this.getModelTargetNamePath(model) || target;
|
|
752
|
+
},
|
|
753
|
+
getValue: () => {
|
|
754
|
+
const fromProps = getPropsInitialValue();
|
|
755
|
+
if (typeof fromProps !== 'undefined') return fromProps;
|
|
756
|
+
return getStepDefaultValue();
|
|
757
|
+
},
|
|
758
|
+
getContext: () => model?.context,
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
this.rules.set(id, {
|
|
762
|
+
rule,
|
|
763
|
+
state: { deps: new Set(), depDisposers: [], runSeq: 0, scheduledAtWriteSeq: 0 },
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
this.scheduleRule(id);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
private getModelTargetPath(model: FlowModel): string | null {
|
|
770
|
+
try {
|
|
771
|
+
const init = (model as any)?.getStepParams?.('fieldSettings', 'init');
|
|
772
|
+
const fp = init?.fieldPath;
|
|
773
|
+
if (fp) return String(fp);
|
|
774
|
+
} catch {
|
|
775
|
+
// ignore
|
|
776
|
+
}
|
|
777
|
+
const fp2 = (model as any)?.fieldPath;
|
|
778
|
+
if (fp2) return String(fp2);
|
|
779
|
+
|
|
780
|
+
const np = this.getModelTargetNamePath(model);
|
|
781
|
+
if (np?.length) {
|
|
782
|
+
const normalized = np.filter((seg) => typeof seg === 'string').join('.');
|
|
783
|
+
return normalized || null;
|
|
784
|
+
}
|
|
785
|
+
return null;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
private getAssignRuleInstanceId(templateKey: string, model: FlowModel) {
|
|
789
|
+
const forkId = model?.['isFork'] ? String(model?.['forkId'] ?? 'fork') : 'master';
|
|
790
|
+
const uid = model?.uid ? String(model.uid) : String(model);
|
|
791
|
+
return `form-assign:${templateKey}:${uid}:${forkId}`;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
private getDeepestFieldIndexKey(baseCtx: any): string | null {
|
|
795
|
+
const fieldIndex = baseCtx?.model?.context?.fieldIndex ?? baseCtx?.fieldIndex;
|
|
796
|
+
const arr = Array.isArray(fieldIndex) ? fieldIndex : [];
|
|
797
|
+
if (!arr.length) return null;
|
|
798
|
+
const last = arr[arr.length - 1];
|
|
799
|
+
if (typeof last !== 'string') return null;
|
|
800
|
+
const [k, v] = last.split(':');
|
|
801
|
+
if (!k) return null;
|
|
802
|
+
const n = Number(v);
|
|
803
|
+
if (Number.isNaN(n)) return null;
|
|
804
|
+
return k;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
private getDeepestToManyAssociationKey(targetPath: string): string | null {
|
|
808
|
+
const rootCollection = this.getRootCollection();
|
|
809
|
+
if (!rootCollection?.getField) return null;
|
|
810
|
+
|
|
811
|
+
const segs = parsePathString(String(targetPath || '')).filter((seg) => typeof seg !== 'object') as NamePath;
|
|
812
|
+
if (segs.length < 2) return null;
|
|
813
|
+
|
|
814
|
+
let collection = rootCollection;
|
|
815
|
+
let deepest: string | null = null;
|
|
816
|
+
|
|
817
|
+
for (let i = 0; i < segs.length - 1; i++) {
|
|
818
|
+
const seg = segs[i];
|
|
819
|
+
if (typeof seg !== 'string') continue;
|
|
820
|
+
const field = collection?.getField?.(seg);
|
|
821
|
+
if (!field?.isAssociationField?.()) break;
|
|
822
|
+
|
|
823
|
+
const toMany = isToManyAssociationField(field);
|
|
824
|
+
if (toMany) deepest = seg;
|
|
825
|
+
|
|
826
|
+
// 对多关联:若包含显式 index(如 users[0]),跳过 index 段;否则按字段名继续
|
|
827
|
+
if (toMany) {
|
|
828
|
+
const next = segs[i + 1];
|
|
829
|
+
if (typeof next === 'number') {
|
|
830
|
+
i += 1;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
collection = field?.targetCollection;
|
|
835
|
+
if (!collection?.getField) break;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
return deepest;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
private isRowGridModel(model: FlowModel): boolean {
|
|
842
|
+
// grid fork(SubFormList 内每行一个 grid fork):有 subModels.items,但没有 subModels.field
|
|
843
|
+
if (!model || typeof model !== 'object') return false;
|
|
844
|
+
if ((model as any)?.subModels?.field) return false;
|
|
845
|
+
if (!(model as any)?.subModels?.items) return false;
|
|
846
|
+
|
|
847
|
+
const baseCtx: any = (model as any)?.context;
|
|
848
|
+
const rowKey = this.getDeepestFieldIndexKey(baseCtx);
|
|
849
|
+
return !!rowKey;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
private tryRegisterAssignRuleInstancesForModel(model: FlowModel, matchedTargetPaths?: Set<string>) {
|
|
853
|
+
if (this.options.isDisposed()) return;
|
|
854
|
+
if (!this.isModelInThisForm(model)) return;
|
|
855
|
+
|
|
856
|
+
const register = (
|
|
857
|
+
targetPathForRule: string,
|
|
858
|
+
ruleTemplates: Array<FormAssignRuleItem & { __key: string; __order: number }>,
|
|
859
|
+
) => {
|
|
860
|
+
if (!ruleTemplates || ruleTemplates.length === 0) return;
|
|
861
|
+
matchedTargetPaths?.add(targetPathForRule);
|
|
862
|
+
|
|
863
|
+
for (const template of ruleTemplates) {
|
|
864
|
+
// 若之前在无字段模型时创建了 block-level/row-grid 兜底实例,这里在字段模型可用时迁移到字段实例,避免双挂载。
|
|
865
|
+
this.removeAssignRuleBlockInstance(template.__key);
|
|
866
|
+
if ((model as any)?.subModels?.field) {
|
|
867
|
+
this.removeRowGridAssignRuleInstances(template.__key);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
const mode: AssignMode = template?.mode === 'default' ? 'default' : 'assign';
|
|
871
|
+
const source: ValueSource = mode === 'default' ? 'default' : 'system';
|
|
872
|
+
const enabled = template?.enable !== false;
|
|
873
|
+
const id = this.getAssignRuleInstanceId(template.__key, model);
|
|
874
|
+
|
|
875
|
+
// 若已存在则替换,避免残留旧 deps/binding
|
|
876
|
+
if (this.rules.has(id)) {
|
|
877
|
+
this.removeRule(id);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
const rule: RuntimeRule = {
|
|
881
|
+
id,
|
|
882
|
+
source,
|
|
883
|
+
priority: 10 + (template.__order || 0),
|
|
884
|
+
debounceMs: 0,
|
|
885
|
+
getEnabled: () => enabled && !!targetPathForRule,
|
|
886
|
+
getTarget: () => targetPathForRule,
|
|
887
|
+
getValue: () => template?.value,
|
|
888
|
+
getCondition: () => template?.condition,
|
|
889
|
+
getContext: () => model?.context,
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
this.rules.set(id, { rule, state: { deps: new Set(), depDisposers: [], runSeq: 0, scheduledAtWriteSeq: 0 } });
|
|
893
|
+
this.scheduleRule(id);
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
// A) row grid:支持对子表单/子表单列表中“未配置到 UI 的属性字段”赋值。
|
|
898
|
+
// 当 targetPath 穿过对多关联(例如 users.age / users.user.name)且不存在对应 FormItemModel 时,
|
|
899
|
+
// 将规则挂载到 row grid 的上下文上运行,以便自动插入数组 index 并按行评估条件。
|
|
900
|
+
if (this.isRowGridModel(model)) {
|
|
901
|
+
const baseCtx: any = (model as any)?.context;
|
|
902
|
+
const rowKey = this.getDeepestFieldIndexKey(baseCtx);
|
|
903
|
+
if (rowKey) {
|
|
904
|
+
for (const [templateTargetPath, templates] of this.assignTemplatesByTargetPath.entries()) {
|
|
905
|
+
// 已配置到 UI 的字段(存在 FormItemModel)仍由字段实例处理,避免重复运行
|
|
906
|
+
if (this.formItemTargetPaths.has(templateTargetPath)) continue;
|
|
907
|
+
|
|
908
|
+
const anchor = this.getDeepestToManyAssociationKey(templateTargetPath);
|
|
909
|
+
if (!anchor || anchor !== rowKey) continue;
|
|
910
|
+
|
|
911
|
+
register(templateTargetPath, templates);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// B) FormItemModel(及其 fork):常规字段赋值
|
|
918
|
+
if (!(model as any)?.subModels?.field) return;
|
|
919
|
+
|
|
920
|
+
const targetPath = this.getModelTargetPath(model);
|
|
921
|
+
if (!targetPath) return;
|
|
922
|
+
|
|
923
|
+
// 1) 精确命中:表单上存在对应字段模型
|
|
924
|
+
const exactTemplates = this.assignTemplatesByTargetPath.get(targetPath) || [];
|
|
925
|
+
if (exactTemplates.length) {
|
|
926
|
+
register(targetPath, exactTemplates);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// 2) 嵌套属性:当当前字段为对一关联(record picker 等)时,将其子属性赋值规则挂载到该字段实例上运行(包括对多子表单行内的对一关联)
|
|
930
|
+
const fieldModel: any = (model as any)?.subModels?.field;
|
|
931
|
+
const collectionField: any = fieldModel?.context?.collectionField;
|
|
932
|
+
const isAssoc = !!collectionField?.isAssociationField?.();
|
|
933
|
+
const isToMany = isToManyAssociationField(collectionField);
|
|
934
|
+
if (isAssoc && !isToMany) {
|
|
935
|
+
const prefix = `${targetPath}.`;
|
|
936
|
+
for (const [templateTargetPath, templates] of this.assignTemplatesByTargetPath.entries()) {
|
|
937
|
+
if (!templateTargetPath || typeof templateTargetPath !== 'string') continue;
|
|
938
|
+
if (!templateTargetPath.startsWith(prefix)) continue;
|
|
939
|
+
register(templateTargetPath, templates);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
private tryUnregisterAssignRuleInstancesForModel(model: FlowModel) {
|
|
945
|
+
if (this.options.isDisposed()) return;
|
|
946
|
+
if (!this.isModelInThisForm(model)) return;
|
|
947
|
+
|
|
948
|
+
const unregister = (templates: Array<FormAssignRuleItem & { __key: string }>) => {
|
|
949
|
+
for (const template of templates || []) {
|
|
950
|
+
const id = this.getAssignRuleInstanceId(template.__key, model);
|
|
951
|
+
if (!this.rules.has(id)) continue;
|
|
952
|
+
this.removeRule(id);
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
// A) row grid:清理挂载到 row grid 上的“未配置字段”规则
|
|
957
|
+
if (this.isRowGridModel(model)) {
|
|
958
|
+
const baseCtx: any = (model as any)?.context;
|
|
959
|
+
const rowKey = this.getDeepestFieldIndexKey(baseCtx);
|
|
960
|
+
if (!rowKey) return;
|
|
961
|
+
|
|
962
|
+
for (const [templateTargetPath, templates] of this.assignTemplatesByTargetPath.entries()) {
|
|
963
|
+
if (this.formItemTargetPaths.has(templateTargetPath)) continue;
|
|
964
|
+
const anchor = this.getDeepestToManyAssociationKey(templateTargetPath);
|
|
965
|
+
if (!anchor || anchor !== rowKey) continue;
|
|
966
|
+
unregister(templates);
|
|
967
|
+
}
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// B) FormItemModel(及其 fork):常规字段赋值
|
|
972
|
+
if (!(model as any)?.subModels?.field) return;
|
|
973
|
+
|
|
974
|
+
const targetPath = this.getModelTargetPath(model);
|
|
975
|
+
if (!targetPath) return;
|
|
976
|
+
|
|
977
|
+
// 1) 精确命中:按当前字段 targetPath 清理
|
|
978
|
+
const exactTemplates = this.assignTemplatesByTargetPath.get(targetPath) || [];
|
|
979
|
+
if (exactTemplates.length) {
|
|
980
|
+
unregister(exactTemplates);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// 2) 嵌套属性:对一关联字段会挂载子属性规则到自身实例,卸载时需要一并清理
|
|
984
|
+
const fieldModel: any = (model as any)?.subModels?.field;
|
|
985
|
+
const collectionField: any = fieldModel?.context?.collectionField;
|
|
986
|
+
const isAssoc = !!collectionField?.isAssociationField?.();
|
|
987
|
+
const isToMany = isToManyAssociationField(collectionField);
|
|
988
|
+
if (isAssoc && !isToMany) {
|
|
989
|
+
const prefix = `${targetPath}.`;
|
|
990
|
+
for (const [templateTargetPath, templates] of this.assignTemplatesByTargetPath.entries()) {
|
|
991
|
+
if (!templateTargetPath || typeof templateTargetPath !== 'string') continue;
|
|
992
|
+
if (!templateTargetPath.startsWith(prefix)) continue;
|
|
993
|
+
unregister(templates);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
private tryUnregisterDefaultRuleInstance(model: FlowModel) {
|
|
999
|
+
if (this.options.isDisposed()) return;
|
|
1000
|
+
if (!this.isModelInThisForm(model)) return;
|
|
1001
|
+
const id = this.getDefaultRuleId(model);
|
|
1002
|
+
if (!this.rules.has(id)) return;
|
|
1003
|
+
this.removeRule(id);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
private bindMasterInitialValue(master: any, ruleId: string) {
|
|
1007
|
+
const uid = master?.uid ? String(master.uid) : ruleId;
|
|
1008
|
+
const set = this.defaultRuleIdsByMasterUid.get(uid) || new Set<string>();
|
|
1009
|
+
set.add(ruleId);
|
|
1010
|
+
this.defaultRuleIdsByMasterUid.set(uid, set);
|
|
1011
|
+
|
|
1012
|
+
if (this.defaultRuleMasterDisposers.has(uid)) return;
|
|
1013
|
+
|
|
1014
|
+
const disposer = reaction(
|
|
1015
|
+
() => {
|
|
1016
|
+
const p = (master as any)?.getProps?.() ?? (master as any)?.props;
|
|
1017
|
+
return p?.initialValue;
|
|
1018
|
+
},
|
|
1019
|
+
(next, prev) => {
|
|
1020
|
+
if (_.isEqual(next, prev)) return;
|
|
1021
|
+
const ids = this.defaultRuleIdsByMasterUid.get(uid);
|
|
1022
|
+
if (!ids) return;
|
|
1023
|
+
const p = (master as any)?.getProps?.() ?? (master as any)?.props;
|
|
1024
|
+
const nextPriority = typeof p?.initialValue !== 'undefined' ? LINKAGE_DEFAULT_RULE_PRIORITY : 0;
|
|
1025
|
+
for (const id of ids) {
|
|
1026
|
+
const entry = this.rules.get(id);
|
|
1027
|
+
if (entry) {
|
|
1028
|
+
entry.rule.priority = nextPriority;
|
|
1029
|
+
}
|
|
1030
|
+
this.scheduleRule(id);
|
|
1031
|
+
}
|
|
1032
|
+
},
|
|
1033
|
+
);
|
|
1034
|
+
this.defaultRuleMasterDisposers.set(uid, disposer);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
private removeRule(id: string) {
|
|
1038
|
+
const entry = this.rules.get(id);
|
|
1039
|
+
if (!entry) return;
|
|
1040
|
+
|
|
1041
|
+
try {
|
|
1042
|
+
const baseCtx = entry.rule.getContext();
|
|
1043
|
+
const rawTarget = entry.rule.getTarget();
|
|
1044
|
+
const targetNamePath = this.options.tryResolveNamePath(baseCtx, rawTarget as any);
|
|
1045
|
+
if (targetNamePath) {
|
|
1046
|
+
const targetKey = namePathToPathKey(targetNamePath);
|
|
1047
|
+
const existing = this.options.observableBindings.get(targetKey);
|
|
1048
|
+
if (existing && existing.source === entry.rule.source) {
|
|
1049
|
+
existing.dispose();
|
|
1050
|
+
this.options.observableBindings.delete(targetKey);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
} catch {
|
|
1054
|
+
// ignore
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
entry.state.depDisposers.forEach((d) => d());
|
|
1058
|
+
this.rules.delete(id);
|
|
1059
|
+
this.pendingRuleIds.delete(id);
|
|
1060
|
+
const timer = this.ruleDebounceTimersById.get(id);
|
|
1061
|
+
if (timer) clearTimeout(timer);
|
|
1062
|
+
this.ruleDebounceTimersById.delete(id);
|
|
1063
|
+
this.ruleDebounceUntilById.delete(id);
|
|
1064
|
+
|
|
1065
|
+
for (const [masterUid, ids] of this.defaultRuleIdsByMasterUid.entries()) {
|
|
1066
|
+
if (!ids.has(id)) continue;
|
|
1067
|
+
ids.delete(id);
|
|
1068
|
+
if (ids.size > 0) continue;
|
|
1069
|
+
this.defaultRuleIdsByMasterUid.delete(masterUid);
|
|
1070
|
+
const disposer = this.defaultRuleMasterDisposers.get(masterUid);
|
|
1071
|
+
if (disposer) disposer();
|
|
1072
|
+
this.defaultRuleMasterDisposers.delete(masterUid);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
rescheduleAllRules() {
|
|
1077
|
+
if (this.options.isDisposed()) return;
|
|
1078
|
+
|
|
1079
|
+
this.lastRuleWriteByTargetKey.clear();
|
|
1080
|
+
for (const entry of this.rules.values()) {
|
|
1081
|
+
entry.state.runSeq += 1;
|
|
1082
|
+
}
|
|
1083
|
+
for (const id of this.rules.keys()) {
|
|
1084
|
+
this.scheduleRule(id);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
private scheduleRule(id: string) {
|
|
1089
|
+
if (this.options.isDisposed()) return;
|
|
1090
|
+
const entry = this.rules.get(id);
|
|
1091
|
+
if (!entry) return;
|
|
1092
|
+
const { rule, state } = entry;
|
|
1093
|
+
|
|
1094
|
+
// Used to detect "a higher priority source has already written the target after we were scheduled".
|
|
1095
|
+
state.scheduledAtWriteSeq = this.options.getWriteSeq();
|
|
1096
|
+
|
|
1097
|
+
const debounceMs = rule?.debounceMs ?? 0;
|
|
1098
|
+
this.pendingRuleIds.add(id);
|
|
1099
|
+
|
|
1100
|
+
// debounce:确保在 flush 时也能跳过未到期的 rule
|
|
1101
|
+
if (debounceMs > 0) {
|
|
1102
|
+
const until = Date.now() + debounceMs;
|
|
1103
|
+
const prevUntil = this.ruleDebounceUntilById.get(id) || 0;
|
|
1104
|
+
if (until > prevUntil) this.ruleDebounceUntilById.set(id, until);
|
|
1105
|
+
const existing = this.ruleDebounceTimersById.get(id);
|
|
1106
|
+
if (existing) clearTimeout(existing);
|
|
1107
|
+
const timer = setTimeout(() => {
|
|
1108
|
+
this.ruleDebounceTimersById.delete(id);
|
|
1109
|
+
if (!this.rulesEnabled) return;
|
|
1110
|
+
if (this.runningRules) return;
|
|
1111
|
+
if (!this.pendingRuleIds.has(id)) return;
|
|
1112
|
+
void this.flushRules();
|
|
1113
|
+
}, debounceMs);
|
|
1114
|
+
this.ruleDebounceTimersById.set(id, timer);
|
|
1115
|
+
} else {
|
|
1116
|
+
const existing = this.ruleDebounceTimersById.get(id);
|
|
1117
|
+
if (existing) clearTimeout(existing);
|
|
1118
|
+
this.ruleDebounceTimersById.delete(id);
|
|
1119
|
+
this.ruleDebounceUntilById.delete(id);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if (!this.rulesEnabled) return;
|
|
1123
|
+
if (this.runningRules) return;
|
|
1124
|
+
void this.flushRules();
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
private async flushRules() {
|
|
1128
|
+
if (this.runningRules) return;
|
|
1129
|
+
this.runningRules = true;
|
|
1130
|
+
const txId = this.currentRuleTxId || createTxId();
|
|
1131
|
+
this.currentRuleTxId = txId;
|
|
1132
|
+
try {
|
|
1133
|
+
while (this.pendingRuleIds.size) {
|
|
1134
|
+
const now = Date.now();
|
|
1135
|
+
const ready: string[] = [];
|
|
1136
|
+
for (const id of this.pendingRuleIds) {
|
|
1137
|
+
const until = this.ruleDebounceUntilById.get(id) || 0;
|
|
1138
|
+
if (until > now) continue;
|
|
1139
|
+
ready.push(id);
|
|
1140
|
+
}
|
|
1141
|
+
if (!ready.length) break;
|
|
1142
|
+
for (const id of ready) {
|
|
1143
|
+
this.pendingRuleIds.delete(id);
|
|
1144
|
+
this.ruleDebounceUntilById.delete(id);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
ready.sort((a, b) => {
|
|
1148
|
+
const ra = this.rules.get(a)?.rule;
|
|
1149
|
+
const rb = this.rules.get(b)?.rule;
|
|
1150
|
+
const pa = ra?.priority ?? 0;
|
|
1151
|
+
const pb = rb?.priority ?? 0;
|
|
1152
|
+
if (pa !== pb) return pa - pb;
|
|
1153
|
+
return a.localeCompare(b);
|
|
1154
|
+
});
|
|
1155
|
+
for (const id of ready) {
|
|
1156
|
+
await this.runRule(id);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
} finally {
|
|
1160
|
+
this.runningRules = false;
|
|
1161
|
+
this.currentRuleTxId = null;
|
|
1162
|
+
this.options.txWriteCounts.delete(txId);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
private async runRule(id: string) {
|
|
1167
|
+
const entry = this.rules.get(id);
|
|
1168
|
+
if (!entry) return;
|
|
1169
|
+
|
|
1170
|
+
const { rule, state } = entry;
|
|
1171
|
+
state.runSeq += 1;
|
|
1172
|
+
const seq = state.runSeq;
|
|
1173
|
+
const scheduledAtWriteSeq = state.scheduledAtWriteSeq;
|
|
1174
|
+
|
|
1175
|
+
const ruleContext = this.prepareRuleContext(rule);
|
|
1176
|
+
const { baseCtx, targetNamePath, targetKey, clearDeps, disposeBinding } = ruleContext;
|
|
1177
|
+
if (!this.shouldRunRule(rule, targetNamePath, targetKey, baseCtx)) {
|
|
1178
|
+
clearDeps(state);
|
|
1179
|
+
disposeBinding();
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
if (!targetNamePath || !targetKey) {
|
|
1183
|
+
clearDeps(state);
|
|
1184
|
+
disposeBinding();
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
const ensuredTargetNamePath = targetNamePath;
|
|
1188
|
+
const ensuredTargetKey = targetKey;
|
|
1189
|
+
|
|
1190
|
+
const { collector, evalCtx } = this.createRuleCollectorAndContext(rule, ruleContext);
|
|
1191
|
+
|
|
1192
|
+
if (rule.getCondition) {
|
|
1193
|
+
const shouldContinue = await this.evaluateRuleCondition(rule, state, seq, evalCtx, collector);
|
|
1194
|
+
if (!shouldContinue) return;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
const resolved = await this.resolveRuleValue(rule, state, seq, evalCtx, collector);
|
|
1198
|
+
if (resolved === SKIP_RULE_VALUE) return;
|
|
1199
|
+
if (seq !== state.runSeq) return;
|
|
1200
|
+
|
|
1201
|
+
this.commitRuleDeps(rule, state, collector);
|
|
1202
|
+
|
|
1203
|
+
const normalizedResolved = this.normalizeResolvedValueForTarget(baseCtx, resolved);
|
|
1204
|
+
const normalizedResolvedForTarget = this.normalizeResolvedValueForAssociationTarget(
|
|
1205
|
+
baseCtx,
|
|
1206
|
+
ensuredTargetNamePath,
|
|
1207
|
+
normalizedResolved,
|
|
1208
|
+
);
|
|
1209
|
+
|
|
1210
|
+
if (rule.source === 'default') {
|
|
1211
|
+
const shouldApply = this.checkDefaultRuleCanApply(
|
|
1212
|
+
normalizedResolvedForTarget,
|
|
1213
|
+
ensuredTargetNamePath,
|
|
1214
|
+
ensuredTargetKey,
|
|
1215
|
+
clearDeps,
|
|
1216
|
+
disposeBinding,
|
|
1217
|
+
state,
|
|
1218
|
+
);
|
|
1219
|
+
if (!shouldApply) return;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
if (rule.source === 'default') {
|
|
1223
|
+
const lastWrite = this.lastRuleWriteByTargetKey.get(ensuredTargetKey);
|
|
1224
|
+
if (
|
|
1225
|
+
lastWrite?.source === 'default' &&
|
|
1226
|
+
lastWrite.priority > rule.priority &&
|
|
1227
|
+
lastWrite.writeSeq >= scheduledAtWriteSeq
|
|
1228
|
+
) {
|
|
1229
|
+
disposeBinding();
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
if (rule.source === 'system') {
|
|
1235
|
+
const lastWrite = this.options.lastWriteMetaByPathKey.get(ensuredTargetKey);
|
|
1236
|
+
if (lastWrite?.source === 'linkage' && lastWrite.writeSeq >= scheduledAtWriteSeq) {
|
|
1237
|
+
disposeBinding();
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
if (this.shouldSkipAssociationNestedWrite(baseCtx, ensuredTargetNamePath)) return;
|
|
1243
|
+
|
|
1244
|
+
if (this.shouldSkipToManyAssociationWriteWithoutIndex(baseCtx, ensuredTargetNamePath)) return;
|
|
1245
|
+
|
|
1246
|
+
const nextSnapshot = normalizedResolvedForTarget;
|
|
1247
|
+
const semanticallyEqual = this.isAssociationTargetSemanticallyEqual(
|
|
1248
|
+
baseCtx,
|
|
1249
|
+
ensuredTargetNamePath,
|
|
1250
|
+
this.options.getFormValueAtPath(ensuredTargetNamePath),
|
|
1251
|
+
nextSnapshot,
|
|
1252
|
+
);
|
|
1253
|
+
if (semanticallyEqual) return;
|
|
1254
|
+
|
|
1255
|
+
const initPatches = this.collectUpdateAssociationInitPatches(baseCtx, ensuredTargetNamePath);
|
|
1256
|
+
if (initPatches == null) return;
|
|
1257
|
+
|
|
1258
|
+
if (rule.source === 'system' || rule.source === 'default') {
|
|
1259
|
+
const modelForUi = baseCtx?.model;
|
|
1260
|
+
const fieldModelForUi = modelForUi?.subModels?.field;
|
|
1261
|
+
if (fieldModelForUi) {
|
|
1262
|
+
const modelTarget = this.getModelTargetNamePath(modelForUi);
|
|
1263
|
+
if (modelTarget && namePathToPathKey(modelTarget) === ensuredTargetKey) {
|
|
1264
|
+
modelForUi.setProps({ value: normalizedResolvedForTarget });
|
|
1265
|
+
fieldModelForUi.setProps?.({ value: normalizedResolvedForTarget });
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
const beforeWriteSeq = this.options.getWriteSeq();
|
|
1271
|
+
const patches = [...initPatches, { path: ensuredTargetNamePath, value: normalizedResolvedForTarget }];
|
|
1272
|
+
await this.options.setFormValues(evalCtx, patches, {
|
|
1273
|
+
source: rule.source,
|
|
1274
|
+
txId: this.currentRuleTxId || undefined,
|
|
1275
|
+
});
|
|
1276
|
+
const afterWriteSeq = this.options.getWriteSeq();
|
|
1277
|
+
if (afterWriteSeq !== beforeWriteSeq) {
|
|
1278
|
+
this.lastRuleWriteByTargetKey.set(ensuredTargetKey, {
|
|
1279
|
+
source: rule.source,
|
|
1280
|
+
priority: rule.priority,
|
|
1281
|
+
writeSeq: afterWriteSeq,
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
private isTzAwareTargetInterface(targetInterface: unknown): boolean {
|
|
1287
|
+
if (typeof targetInterface !== 'string') {
|
|
1288
|
+
return false;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
return ['datetime', 'createdAt', 'updatedAt', 'unixTimestamp'].includes(targetInterface);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
private normalizeDateOnlyToStartOfDayIso(value: string): string {
|
|
1295
|
+
const raw = String(value || '').trim();
|
|
1296
|
+
if (!raw) return value;
|
|
1297
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(raw)) return value;
|
|
1298
|
+
|
|
1299
|
+
const parsed = dayjs(raw, 'YYYY-MM-DD', true);
|
|
1300
|
+
if (!parsed.isValid()) return value;
|
|
1301
|
+
return parsed.startOf('day').toISOString();
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
private normalizeResolvedValueForTarget(baseCtx: any, resolved: any): any {
|
|
1305
|
+
const targetInterface = baseCtx?.model?.context?.collectionField?.interface;
|
|
1306
|
+
if (!this.isTzAwareTargetInterface(targetInterface)) {
|
|
1307
|
+
return resolved;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
if (typeof resolved === 'string') {
|
|
1311
|
+
return this.normalizeDateOnlyToStartOfDayIso(resolved);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
if (Array.isArray(resolved)) {
|
|
1315
|
+
return resolved.map((item) => (typeof item === 'string' ? this.normalizeDateOnlyToStartOfDayIso(item) : item));
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
return resolved;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
private isPrimitiveAssociationTargetValue(value: unknown): value is string | number | boolean {
|
|
1322
|
+
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
private extractAssociationIdentity(associationField: any, value: any): any | typeof UNRESOLVED_ASSOCIATION_IDENTITY {
|
|
1326
|
+
const targetKeys = this.getAssociationTargetKeyFields(associationField);
|
|
1327
|
+
const singleTargetKey = targetKeys.length === 1 ? targetKeys[0] : null;
|
|
1328
|
+
|
|
1329
|
+
const toIdentity = (item: any): any | typeof UNRESOLVED_ASSOCIATION_IDENTITY => {
|
|
1330
|
+
if (item == null) return item;
|
|
1331
|
+
|
|
1332
|
+
if (this.isPrimitiveAssociationTargetValue(item)) {
|
|
1333
|
+
if (!singleTargetKey) return UNRESOLVED_ASSOCIATION_IDENTITY;
|
|
1334
|
+
return item;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
if (!item || typeof item !== 'object') {
|
|
1338
|
+
return UNRESOLVED_ASSOCIATION_IDENTITY;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
if (singleTargetKey) {
|
|
1342
|
+
if (typeof item[singleTargetKey] === 'undefined') {
|
|
1343
|
+
return UNRESOLVED_ASSOCIATION_IDENTITY;
|
|
1344
|
+
}
|
|
1345
|
+
return item[singleTargetKey];
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
const compositeIdentity: Record<string, any> = {};
|
|
1349
|
+
for (const key of targetKeys) {
|
|
1350
|
+
if (typeof item[key] === 'undefined') {
|
|
1351
|
+
return UNRESOLVED_ASSOCIATION_IDENTITY;
|
|
1352
|
+
}
|
|
1353
|
+
compositeIdentity[key] = item[key];
|
|
1354
|
+
}
|
|
1355
|
+
return compositeIdentity;
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
if (isToManyAssociationField(associationField)) {
|
|
1359
|
+
const arr = Array.isArray(value) ? value : [value];
|
|
1360
|
+
const identities: any[] = [];
|
|
1361
|
+
for (const item of arr) {
|
|
1362
|
+
if (item == null) continue;
|
|
1363
|
+
const identity = toIdentity(item);
|
|
1364
|
+
if (identity === UNRESOLVED_ASSOCIATION_IDENTITY) {
|
|
1365
|
+
return UNRESOLVED_ASSOCIATION_IDENTITY;
|
|
1366
|
+
}
|
|
1367
|
+
identities.push(identity);
|
|
1368
|
+
}
|
|
1369
|
+
return identities;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
const toOneValue = Array.isArray(value) ? value.find((item) => item != null) : value;
|
|
1373
|
+
if (toOneValue == null) return toOneValue;
|
|
1374
|
+
return toIdentity(toOneValue);
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
private isAssociationTargetSemanticallyEqual(
|
|
1378
|
+
baseCtx: any,
|
|
1379
|
+
targetNamePath: NamePath,
|
|
1380
|
+
currentValue: any,
|
|
1381
|
+
nextValue: any,
|
|
1382
|
+
): boolean {
|
|
1383
|
+
const targetField = this.resolveCollectionFieldByNamePath(baseCtx, targetNamePath);
|
|
1384
|
+
if (!targetField?.isAssociationField?.()) {
|
|
1385
|
+
return _.isEqual(currentValue, nextValue);
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
const currentIdentity = this.extractAssociationIdentity(targetField, currentValue);
|
|
1389
|
+
const nextIdentity = this.extractAssociationIdentity(targetField, nextValue);
|
|
1390
|
+
if (currentIdentity === UNRESOLVED_ASSOCIATION_IDENTITY || nextIdentity === UNRESOLVED_ASSOCIATION_IDENTITY) {
|
|
1391
|
+
return _.isEqual(currentValue, nextValue);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
return _.isEqual(currentIdentity, nextIdentity);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
private resolveCollectionFieldByNamePath(baseCtx: any, targetNamePath: NamePath): any | null {
|
|
1398
|
+
if (!Array.isArray(targetNamePath) || !targetNamePath.length) return null;
|
|
1399
|
+
|
|
1400
|
+
let collection = this.getRootCollection() || this.getCollectionFromContext(baseCtx);
|
|
1401
|
+
if (!collection?.getField) return null;
|
|
1402
|
+
|
|
1403
|
+
for (let i = 0; i < targetNamePath.length; i++) {
|
|
1404
|
+
const seg = targetNamePath[i];
|
|
1405
|
+
if (typeof seg !== 'string' || !seg) return null;
|
|
1406
|
+
|
|
1407
|
+
const field = collection?.getField?.(seg);
|
|
1408
|
+
if (!field) return null;
|
|
1409
|
+
|
|
1410
|
+
const isLast = i === targetNamePath.length - 1;
|
|
1411
|
+
if (isLast) return field;
|
|
1412
|
+
|
|
1413
|
+
if (!field?.isAssociationField?.() || !field?.targetCollection) {
|
|
1414
|
+
return null;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
if (isToManyAssociationField(field)) {
|
|
1418
|
+
const nextSeg = targetNamePath[i + 1];
|
|
1419
|
+
if (typeof nextSeg !== 'number') {
|
|
1420
|
+
return null;
|
|
1421
|
+
}
|
|
1422
|
+
i += 1;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
collection = field.targetCollection;
|
|
1426
|
+
if (!collection?.getField) return null;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
return null;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
private normalizeResolvedValueForAssociationTarget(baseCtx: any, targetNamePath: NamePath, resolved: any): any {
|
|
1433
|
+
const targetField = this.resolveCollectionFieldByNamePath(baseCtx, targetNamePath);
|
|
1434
|
+
if (!targetField?.isAssociationField?.()) return resolved;
|
|
1435
|
+
|
|
1436
|
+
const targetKeys = this.getAssociationTargetKeyFields(targetField);
|
|
1437
|
+
const singleTargetKey = targetKeys.length === 1 ? targetKeys[0] : null;
|
|
1438
|
+
const normalizeItem = (item: any) => {
|
|
1439
|
+
if (item == null) return undefined;
|
|
1440
|
+
if (singleTargetKey && this.isPrimitiveAssociationTargetValue(item)) {
|
|
1441
|
+
return { [singleTargetKey]: item };
|
|
1442
|
+
}
|
|
1443
|
+
return item;
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
if (isToManyAssociationField(targetField)) {
|
|
1447
|
+
const rawItems = Array.isArray(resolved) ? resolved : [resolved];
|
|
1448
|
+
return rawItems.map((item) => normalizeItem(item)).filter((item) => typeof item !== 'undefined' && item !== null);
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
const toOneValue = Array.isArray(resolved) ? resolved.find((item) => item != null) : resolved;
|
|
1452
|
+
if (toOneValue == null) return toOneValue;
|
|
1453
|
+
|
|
1454
|
+
const normalizedOne = normalizeItem(toOneValue);
|
|
1455
|
+
return normalizedOne;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
private prepareRuleContext(rule: RuntimeRule) {
|
|
1459
|
+
const baseCtx = rule.getContext();
|
|
1460
|
+
const rawTarget = rule.getTarget();
|
|
1461
|
+
const targetNamePath = this.options.tryResolveNamePath(baseCtx, rawTarget as any);
|
|
1462
|
+
const targetKey = targetNamePath ? namePathToPathKey(targetNamePath) : null;
|
|
1463
|
+
|
|
1464
|
+
const clearDeps = (state: RuleState) => {
|
|
1465
|
+
state.depDisposers.forEach((d) => d());
|
|
1466
|
+
state.depDisposers = [];
|
|
1467
|
+
state.deps = new Set();
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
const disposeBinding = () => {
|
|
1471
|
+
if (!targetKey) return;
|
|
1472
|
+
const existing = this.options.observableBindings.get(targetKey);
|
|
1473
|
+
if (!existing) return;
|
|
1474
|
+
if (existing.source !== rule.source) return;
|
|
1475
|
+
existing.dispose();
|
|
1476
|
+
this.options.observableBindings.delete(targetKey);
|
|
1477
|
+
};
|
|
1478
|
+
|
|
1479
|
+
return { baseCtx, targetNamePath, targetKey, clearDeps, disposeBinding };
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
private shouldApplyDefaultRuleInCurrentState(baseCtx: any): boolean {
|
|
1483
|
+
const actionName = this.options.getActionName?.();
|
|
1484
|
+
if (actionName !== 'update') {
|
|
1485
|
+
return true;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// 编辑态默认值规则:
|
|
1489
|
+
// - 顶层编辑表单:不应用默认值
|
|
1490
|
+
// - 子表单:仅对“新增行/新增对象”(__is_new__ = true)应用默认值
|
|
1491
|
+
return this.getItemContext(baseCtx)?.__is_new__ === true;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
private isStaleToManyItemContext(baseCtx: any): boolean {
|
|
1495
|
+
const item = this.getItemContext(baseCtx);
|
|
1496
|
+
if (!Number.isFinite(item?.index) || !Number.isFinite(item?.length)) return false;
|
|
1497
|
+
return item.index < 0 || item.index >= item.length;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
private getItemContext(baseCtx: any) {
|
|
1501
|
+
try {
|
|
1502
|
+
return baseCtx?.item;
|
|
1503
|
+
} catch {
|
|
1504
|
+
return undefined;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
private getRowTargetKey(baseCtx: any, rowPath: NamePath): string | string[] {
|
|
1509
|
+
let collection = this.getRootCollection() || this.getCollectionFromContext(baseCtx);
|
|
1510
|
+
let field: any;
|
|
1511
|
+
for (const seg of rowPath) {
|
|
1512
|
+
if (typeof seg === 'number') continue;
|
|
1513
|
+
if (typeof seg !== 'string' || !seg || !collection?.getField) break;
|
|
1514
|
+
|
|
1515
|
+
field = collection?.getField?.(seg);
|
|
1516
|
+
if (!field?.isAssociationField?.()) break;
|
|
1517
|
+
collection = field?.targetCollection;
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
const raw = field?.targetCollection?.filterTargetKey ?? field?.targetCollection?.filterByTk ?? field?.targetKey;
|
|
1521
|
+
if (Array.isArray(raw)) {
|
|
1522
|
+
const keys = raw.filter((key): key is string => typeof key === 'string' && !!key);
|
|
1523
|
+
return keys.length ? keys : 'id';
|
|
1524
|
+
}
|
|
1525
|
+
return typeof raw === 'string' && raw ? raw : 'id';
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
private isMismatchedToManyItemContext(baseCtx: any, targetNamePath: NamePath): boolean {
|
|
1529
|
+
const item = this.getItemContext(baseCtx);
|
|
1530
|
+
if (!item) return false;
|
|
1531
|
+
|
|
1532
|
+
for (let i = targetNamePath.length - 1; i >= 0; i--) {
|
|
1533
|
+
if (typeof targetNamePath[i] !== 'number') continue;
|
|
1534
|
+
|
|
1535
|
+
const rowPath = targetNamePath.slice(0, i + 1);
|
|
1536
|
+
const targetKey = this.getRowTargetKey(baseCtx, rowPath);
|
|
1537
|
+
const currentRow = this.options.getFormValueAtPath(rowPath);
|
|
1538
|
+
const currentIdentity = getSubTableRowIdentity(currentRow, targetKey);
|
|
1539
|
+
const itemIdentity = getSubTableRowIdentity(item.value, targetKey);
|
|
1540
|
+
return !!currentIdentity && !!itemIdentity && currentIdentity !== itemIdentity;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
return false;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
private shouldRunRule(
|
|
1547
|
+
rule: RuntimeRule,
|
|
1548
|
+
targetNamePath: NamePath | null,
|
|
1549
|
+
targetKey: string | null,
|
|
1550
|
+
baseCtx: any,
|
|
1551
|
+
): boolean {
|
|
1552
|
+
if (!rule.getEnabled()) return false;
|
|
1553
|
+
if (!targetNamePath || !targetKey) return false;
|
|
1554
|
+
if (this.isStaleToManyItemContext(baseCtx)) return false;
|
|
1555
|
+
if (this.isMismatchedToManyItemContext(baseCtx, targetNamePath)) return false;
|
|
1556
|
+
if (rule.source === 'default') {
|
|
1557
|
+
if (!this.shouldApplyDefaultRuleInCurrentState(baseCtx)) return false;
|
|
1558
|
+
if (this.options.findExplicitHit(targetKey)) return false;
|
|
1559
|
+
}
|
|
1560
|
+
return true;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
private createRuleCollectorAndContext(rule: RuntimeRule, ruleContext: ReturnType<typeof this.prepareRuleContext>) {
|
|
1564
|
+
const { baseCtx, targetNamePath } = ruleContext;
|
|
1565
|
+
const rawValue = rule.getValue();
|
|
1566
|
+
const isRunJS = isRunJSValue(rawValue);
|
|
1567
|
+
|
|
1568
|
+
const collector: DepCollector = { deps: new Set(), wildcard: false };
|
|
1569
|
+
|
|
1570
|
+
// 静态路径提取:覆盖"服务端解析但前端不触达 formValues 子路径"的场景
|
|
1571
|
+
if (rule.getCondition) {
|
|
1572
|
+
collectStaticDepsFromTemplateValue(rule.getCondition(), collector);
|
|
1573
|
+
}
|
|
1574
|
+
if (isRunJS) {
|
|
1575
|
+
collectStaticDepsFromRunJSValue(rawValue, collector);
|
|
1576
|
+
} else {
|
|
1577
|
+
collectStaticDepsFromTemplateValue(rawValue, collector);
|
|
1578
|
+
}
|
|
1579
|
+
// 规则可用性依赖 target 当前值(空/等于上次默认值)
|
|
1580
|
+
if (targetNamePath) {
|
|
1581
|
+
recordDep(targetNamePath, collector);
|
|
1582
|
+
// 关联字段嵌套属性:额外依赖关联对象本身,确保从 null -> {id} 时可触发重新计算
|
|
1583
|
+
for (const p of this.collectAssociationPrefixPaths(baseCtx, targetNamePath)) {
|
|
1584
|
+
recordDep(p, collector);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
const evalCtx = this.createRuleEvaluationContext(baseCtx, collector, targetNamePath);
|
|
1589
|
+
return { collector, evalCtx, rawValue, isRunJS };
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
private async evaluateRuleCondition(
|
|
1593
|
+
rule: RuntimeRule,
|
|
1594
|
+
state: RuleState,
|
|
1595
|
+
seq: number,
|
|
1596
|
+
evalCtx: any,
|
|
1597
|
+
collector: DepCollector,
|
|
1598
|
+
): Promise<boolean> {
|
|
1599
|
+
const getCondition = rule.getCondition;
|
|
1600
|
+
if (!getCondition) return true;
|
|
1601
|
+
const cond = getCondition();
|
|
1602
|
+
let resolvedCond = cond;
|
|
1603
|
+
if (cond) {
|
|
1604
|
+
try {
|
|
1605
|
+
resolvedCond = await evalCtx?.resolveJsonTemplate?.(cond);
|
|
1606
|
+
} catch {
|
|
1607
|
+
resolvedCond = cond;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
if (seq !== state.runSeq) return false;
|
|
1611
|
+
if (cond && !evaluateCondition(evalCtx, resolvedCond)) {
|
|
1612
|
+
this.commitRuleDeps(rule, state, collector);
|
|
1613
|
+
return false;
|
|
1614
|
+
}
|
|
1615
|
+
return true;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
private async resolveRuleValue(
|
|
1619
|
+
rule: RuntimeRule,
|
|
1620
|
+
state: RuleState,
|
|
1621
|
+
seq: number,
|
|
1622
|
+
evalCtx: any,
|
|
1623
|
+
collector: DepCollector,
|
|
1624
|
+
): Promise<any> {
|
|
1625
|
+
const rawValue = rule.getValue();
|
|
1626
|
+
const isRunJS = isRunJSValue(rawValue);
|
|
1627
|
+
|
|
1628
|
+
if (isRunJS) {
|
|
1629
|
+
return this.resolveRunJSValue(rawValue, state, seq, evalCtx, collector, rule);
|
|
1630
|
+
}
|
|
1631
|
+
return this.resolveTemplateValue(rawValue, state, seq, evalCtx, collector, rule);
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
private async resolveRunJSValue(
|
|
1635
|
+
rawValue: any,
|
|
1636
|
+
state: RuleState,
|
|
1637
|
+
seq: number,
|
|
1638
|
+
evalCtx: any,
|
|
1639
|
+
collector: DepCollector,
|
|
1640
|
+
rule: RuntimeRule,
|
|
1641
|
+
): Promise<any> {
|
|
1642
|
+
try {
|
|
1643
|
+
const { code, version } = normalizeRunJSValue(rawValue);
|
|
1644
|
+
const ret = await runjsWithSafeGlobals(evalCtx, code, { version });
|
|
1645
|
+
if (!ret?.success) {
|
|
1646
|
+
if (seq !== state.runSeq) return SKIP_RULE_VALUE;
|
|
1647
|
+
this.commitRuleDeps(rule, state, collector);
|
|
1648
|
+
return SKIP_RULE_VALUE;
|
|
1649
|
+
}
|
|
1650
|
+
return ret.value;
|
|
1651
|
+
} catch {
|
|
1652
|
+
if (seq !== state.runSeq) return SKIP_RULE_VALUE;
|
|
1653
|
+
this.commitRuleDeps(rule, state, collector);
|
|
1654
|
+
return SKIP_RULE_VALUE;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
private async resolveTemplateValue(
|
|
1659
|
+
rawValue: any,
|
|
1660
|
+
state: RuleState,
|
|
1661
|
+
seq: number,
|
|
1662
|
+
evalCtx: any,
|
|
1663
|
+
collector: DepCollector,
|
|
1664
|
+
rule: RuntimeRule,
|
|
1665
|
+
): Promise<any> {
|
|
1666
|
+
try {
|
|
1667
|
+
return await evalCtx?.resolveJsonTemplate?.(rawValue);
|
|
1668
|
+
} catch {
|
|
1669
|
+
if (seq !== state.runSeq) return SKIP_RULE_VALUE;
|
|
1670
|
+
this.commitRuleDeps(rule, state, collector);
|
|
1671
|
+
return SKIP_RULE_VALUE;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
private commitRuleDeps(rule: RuntimeRule, state: RuleState, collector: DepCollector) {
|
|
1676
|
+
const nextDeps: RuleDeps = new Set(collector.deps);
|
|
1677
|
+
if (collector.wildcard) {
|
|
1678
|
+
nextDeps.add('fv:*');
|
|
1679
|
+
}
|
|
1680
|
+
this.updateRuleDeps(rule, state, nextDeps);
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* Check if default rule value can be applied.
|
|
1685
|
+
* Default value can overwrite when:
|
|
1686
|
+
* 1. Current value is empty
|
|
1687
|
+
* 2. Current value equals the last default value (user hasn't modified it)
|
|
1688
|
+
*/
|
|
1689
|
+
private checkDefaultRuleCanApply(
|
|
1690
|
+
resolved: any,
|
|
1691
|
+
targetNamePath: NamePath,
|
|
1692
|
+
targetKey: string,
|
|
1693
|
+
clearDeps: (state: RuleState) => void,
|
|
1694
|
+
disposeBinding: () => void,
|
|
1695
|
+
state: RuleState,
|
|
1696
|
+
): boolean {
|
|
1697
|
+
if (typeof resolved === 'undefined') return false;
|
|
1698
|
+
|
|
1699
|
+
const explicitHitAfterResolve = this.options.findExplicitHit(targetKey);
|
|
1700
|
+
if (explicitHitAfterResolve) {
|
|
1701
|
+
clearDeps(state);
|
|
1702
|
+
disposeBinding();
|
|
1703
|
+
return false;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
const current = this.options.getFormValueAtPath(targetNamePath);
|
|
1707
|
+
const last = this.options.lastDefaultValueByPathKey.get(targetKey);
|
|
1708
|
+
const canOverwrite = isEmptyValue(current) || (typeof last !== 'undefined' && _.isEqual(current, last));
|
|
1709
|
+
|
|
1710
|
+
// 若外部已把当前值更新为"解析后的默认值",同步 lastDefault,避免后续默认值变更无法覆盖
|
|
1711
|
+
const nextSnapshot = isObservable(resolved) ? toJS(resolved) : resolved;
|
|
1712
|
+
if (!canOverwrite && _.isEqual(current, nextSnapshot)) {
|
|
1713
|
+
this.options.lastDefaultValueByPathKey.set(targetKey, nextSnapshot);
|
|
1714
|
+
return false;
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
return canOverwrite;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
private createRuleEvaluationContext(baseCtx: any, collector: DepCollector, targetNamePath: NamePath | null) {
|
|
1721
|
+
const trackingFormValues = this.options.createTrackingFormValues(collector);
|
|
1722
|
+
const ctx: any = new FlowContext();
|
|
1723
|
+
try {
|
|
1724
|
+
ctx.delegate(baseCtx);
|
|
1725
|
+
} catch {
|
|
1726
|
+
// ignore
|
|
1727
|
+
}
|
|
1728
|
+
const baseOptions = baseCtx?.getPropertyOptions?.('formValues');
|
|
1729
|
+
if (baseOptions && typeof baseOptions === 'object') {
|
|
1730
|
+
ctx.defineProperty('formValues', {
|
|
1731
|
+
...baseOptions,
|
|
1732
|
+
get: () => trackingFormValues,
|
|
1733
|
+
cache: false,
|
|
1734
|
+
});
|
|
1735
|
+
} else {
|
|
1736
|
+
ctx.defineProperty('formValues', { get: () => trackingFormValues, cache: false });
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
// “当前项”链:用于多层级关系字段条件
|
|
1740
|
+
// 语义:ctx.item -> { index?, length?, __is_new__?, __is_stored__?, value, parentItem? },其中:
|
|
1741
|
+
// - index:仅当当前对象位于对多关联行内时存在(0-based)
|
|
1742
|
+
// - length:仅当当前对象位于对多关联行内时存在,表示当前层数组总数
|
|
1743
|
+
// - value:当前对象的值(来自 formValues 的对应切片,支持无限嵌套属性访问)
|
|
1744
|
+
// - parentItem:上级项(同结构,可链式 parentItem.parentItem...)
|
|
1745
|
+
// 计算顺序:
|
|
1746
|
+
// 1) 优先按 targetNamePath 从 formValues 构建“关联链 item”
|
|
1747
|
+
// 2) 若无法构建(例如目标字段是顶层路径),回退到上游显式注入的 baseCtx.item
|
|
1748
|
+
// (如 PopupSubTable 新增弹窗传入的 parentItem 链)
|
|
1749
|
+
let itemCached: any;
|
|
1750
|
+
let itemCachedReady = false;
|
|
1751
|
+
const getItem = () => {
|
|
1752
|
+
if (!itemCachedReady) {
|
|
1753
|
+
const chainItem = this.buildItemChainValue(baseCtx, trackingFormValues, targetNamePath);
|
|
1754
|
+
itemCached = chainItem ?? baseCtx?.item;
|
|
1755
|
+
itemCachedReady = true;
|
|
1756
|
+
}
|
|
1757
|
+
return itemCached;
|
|
1758
|
+
};
|
|
1759
|
+
ctx.defineProperty('item', { get: getItem, cache: false });
|
|
1760
|
+
return ctx;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
private buildItemChainValue(baseCtx: any, trackingFormValues: any, targetNamePath: NamePath | null) {
|
|
1764
|
+
const rootCollection = this.getRootCollection() || this.getCollectionFromContext(baseCtx);
|
|
1765
|
+
const buildNode = (value: any, index: number | undefined, length: number | undefined, parentItem: any) => {
|
|
1766
|
+
return {
|
|
1767
|
+
index,
|
|
1768
|
+
length,
|
|
1769
|
+
__is_new__: value?.__is_new__,
|
|
1770
|
+
__is_stored__: value?.__is_stored__,
|
|
1771
|
+
value,
|
|
1772
|
+
parentItem,
|
|
1773
|
+
};
|
|
1774
|
+
};
|
|
1775
|
+
const defaultRoot = buildNode(trackingFormValues, undefined, undefined, undefined);
|
|
1776
|
+
// item 仅用于“关系字段的子路径”场景;
|
|
1777
|
+
// 顶层字段/非关联嵌套对象字段应使用 formValues。
|
|
1778
|
+
if (!targetNamePath || !Array.isArray(targetNamePath) || !targetNamePath.length) return undefined;
|
|
1779
|
+
if (!rootCollection?.getField) return undefined;
|
|
1780
|
+
|
|
1781
|
+
const assocEntries: Array<{ path: NamePath; toMany: boolean }> = [];
|
|
1782
|
+
const prefix: NamePath = [];
|
|
1783
|
+
let collection = rootCollection;
|
|
1784
|
+
|
|
1785
|
+
for (let i = 0; i < targetNamePath.length - 1; i++) {
|
|
1786
|
+
const seg = targetNamePath[i];
|
|
1787
|
+
if (typeof seg !== 'string') break;
|
|
1788
|
+
|
|
1789
|
+
const field = collection?.getField?.(seg);
|
|
1790
|
+
if (!field?.isAssociationField?.()) break;
|
|
1791
|
+
|
|
1792
|
+
const toMany = isToManyAssociationField(field);
|
|
1793
|
+
prefix.push(seg);
|
|
1794
|
+
|
|
1795
|
+
if (toMany) {
|
|
1796
|
+
const next = targetNamePath[i + 1];
|
|
1797
|
+
if (typeof next !== 'number') break;
|
|
1798
|
+
prefix.push(next);
|
|
1799
|
+
i += 1;
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
const targetCollection = field?.targetCollection;
|
|
1803
|
+
if (!targetCollection) break;
|
|
1804
|
+
|
|
1805
|
+
assocEntries.push({ path: [...prefix], toMany });
|
|
1806
|
+
collection = targetCollection;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
const build = (idx: number): any => {
|
|
1810
|
+
if (idx < 0) return defaultRoot;
|
|
1811
|
+
const assocEntry = assocEntries[idx];
|
|
1812
|
+
const value = _.get(trackingFormValues, assocEntry.path);
|
|
1813
|
+
const lastSeg = assocEntry.path[assocEntry.path.length - 1];
|
|
1814
|
+
const index = assocEntry.toMany && typeof lastSeg === 'number' ? lastSeg : undefined;
|
|
1815
|
+
const length = (() => {
|
|
1816
|
+
if (!assocEntry.toMany) return undefined;
|
|
1817
|
+
// assocEntry.path: [..., associationKey, rowIndex]
|
|
1818
|
+
const listPath = assocEntry.path.slice(0, -1);
|
|
1819
|
+
const list = _.get(trackingFormValues, listPath);
|
|
1820
|
+
return Array.isArray(list) ? list.length : undefined;
|
|
1821
|
+
})();
|
|
1822
|
+
return buildNode(value, index, length, build(idx - 1));
|
|
1823
|
+
};
|
|
1824
|
+
|
|
1825
|
+
return assocEntries.length ? build(assocEntries.length - 1) : undefined;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
private getFieldIndexSignature(baseCtx: any): string {
|
|
1829
|
+
const fieldIndex = baseCtx?.model?.context?.fieldIndex ?? baseCtx?.fieldIndex;
|
|
1830
|
+
const arr = Array.isArray(fieldIndex) ? fieldIndex : [];
|
|
1831
|
+
return arr.filter((it) => typeof it === 'string').join('|');
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
private updateRuleDeps(rule: RuntimeRule, state: RuleState, deps: RuleDeps) {
|
|
1835
|
+
state.depDisposers.forEach((d) => d());
|
|
1836
|
+
state.depDisposers = [];
|
|
1837
|
+
state.deps = deps;
|
|
1838
|
+
|
|
1839
|
+
if (deps.has('fv:*')) {
|
|
1840
|
+
const disposer = reaction(
|
|
1841
|
+
() => this.options.changeTick.value,
|
|
1842
|
+
() => this.scheduleRule(rule.id),
|
|
1843
|
+
);
|
|
1844
|
+
state.depDisposers.push(disposer);
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
const baseCtx: any = (() => {
|
|
1848
|
+
try {
|
|
1849
|
+
return rule.getContext();
|
|
1850
|
+
} catch {
|
|
1851
|
+
return undefined;
|
|
1852
|
+
}
|
|
1853
|
+
})();
|
|
1854
|
+
|
|
1855
|
+
// Row/grid rules resolve target paths through fieldIndex (for example `roles.title`
|
|
1856
|
+
// -> `roles[1].title`). When a row is deleted or reordered, the rule must reschedule
|
|
1857
|
+
// even if its value/condition does not reference ctx.item directly.
|
|
1858
|
+
const fieldIndex = baseCtx?.model?.context?.fieldIndex ?? baseCtx?.fieldIndex;
|
|
1859
|
+
const shouldWatchFieldIndex = Array.isArray(fieldIndex) && fieldIndex.some((it) => typeof it === 'string');
|
|
1860
|
+
if (shouldWatchFieldIndex) {
|
|
1861
|
+
const fieldIndexDisposer = reaction(
|
|
1862
|
+
() => this.getFieldIndexSignature(baseCtx),
|
|
1863
|
+
() => this.scheduleRule(rule.id),
|
|
1864
|
+
);
|
|
1865
|
+
state.depDisposers.push(fieldIndexDisposer);
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
for (const depKey of deps) {
|
|
1869
|
+
if (depKey === 'fv:*') {
|
|
1870
|
+
continue;
|
|
1871
|
+
}
|
|
1872
|
+
// backward compat: treat unknown keys as formValues deps
|
|
1873
|
+
if (!depKey.startsWith('fv:') && !depKey.startsWith('ctx:')) {
|
|
1874
|
+
const depPath = pathKeyToNamePath(depKey);
|
|
1875
|
+
const disposer = reaction(
|
|
1876
|
+
() => _.get(this.options.valuesMirror, depPath),
|
|
1877
|
+
() => this.scheduleRule(rule.id),
|
|
1878
|
+
);
|
|
1879
|
+
state.depDisposers.push(disposer);
|
|
1880
|
+
continue;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
if (depKey.startsWith('fv:')) {
|
|
1884
|
+
const inner = depKey.slice('fv:'.length);
|
|
1885
|
+
const depPath = pathKeyToNamePath(inner);
|
|
1886
|
+
const disposer = reaction(
|
|
1887
|
+
() => _.get(this.options.valuesMirror, depPath),
|
|
1888
|
+
() => this.scheduleRule(rule.id),
|
|
1889
|
+
);
|
|
1890
|
+
state.depDisposers.push(disposer);
|
|
1891
|
+
continue;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
// ctx deps: ctx:<varName>[:<subPath>]
|
|
1895
|
+
const rest = depKey.slice('ctx:'.length);
|
|
1896
|
+
const sep = rest.indexOf(':');
|
|
1897
|
+
const varName = sep >= 0 ? rest.slice(0, sep) : rest;
|
|
1898
|
+
const subPath = sep >= 0 ? rest.slice(sep + 1) : '';
|
|
1899
|
+
const depPath = subPath ? (parsePathString(subPath).filter((seg) => typeof seg !== 'object') as NamePath) : [];
|
|
1900
|
+
|
|
1901
|
+
// 特殊变量:item 为 RuleEngine 注入的计算属性(不直接存在于 baseCtx 上)。
|
|
1902
|
+
// fieldIndex 的变化已统一在上面监听,这里只补 item 自身取值的依赖。
|
|
1903
|
+
if (varName === 'item') {
|
|
1904
|
+
if (depPath.length) {
|
|
1905
|
+
const trackingFormValues = this.options.createTrackingFormValues({ deps: new Set(), wildcard: false });
|
|
1906
|
+
const itemValueDisposer = reaction(
|
|
1907
|
+
() => {
|
|
1908
|
+
const targetPath = rule.getTarget?.();
|
|
1909
|
+
const targetNamePath = targetPath ? this.options.tryResolveNamePath(baseCtx, targetPath) : null;
|
|
1910
|
+
const itemRoot = this.buildItemChainValue(baseCtx, trackingFormValues, targetNamePath) ?? baseCtx?.item;
|
|
1911
|
+
return _.get(itemRoot, depPath);
|
|
1912
|
+
},
|
|
1913
|
+
() => this.scheduleRule(rule.id),
|
|
1914
|
+
);
|
|
1915
|
+
state.depDisposers.push(itemValueDisposer);
|
|
1916
|
+
}
|
|
1917
|
+
continue;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
const disposer = reaction(
|
|
1921
|
+
() => {
|
|
1922
|
+
const root = baseCtx ? baseCtx[varName] : undefined;
|
|
1923
|
+
return depPath.length ? _.get(root, depPath) : root;
|
|
1924
|
+
},
|
|
1925
|
+
() => this.scheduleRule(rule.id),
|
|
1926
|
+
);
|
|
1927
|
+
state.depDisposers.push(disposer);
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
}
|