@nocobase/client-v2 2.1.0-beta.30 → 2.1.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/BaseApplication.d.ts +1 -0
- package/es/PluginManager.d.ts +1 -0
- package/es/components/form/DrawerFormLayout.d.ts +49 -0
- package/es/components/form/EnvVariableInput.d.ts +42 -0
- package/es/components/form/FileSizeInput.d.ts +27 -0
- package/es/components/form/createFormRegistry.d.ts +33 -0
- package/es/components/form/index.d.ts +13 -0
- package/es/components/index.d.ts +1 -1
- package/es/flow/components/FieldAssignRulesEditor.d.ts +1 -0
- package/es/flow/components/code-editor/index.d.ts +1 -0
- package/es/flow/internal/utils/enumOptionsUtils.d.ts +5 -0
- package/es/flow/models/actions/AssociationActionUtils.d.ts +5 -0
- package/es/flow/models/blocks/filter-form/FilterFormBlockModel.d.ts +4 -0
- package/es/flow/models/blocks/filter-manager/FilterManager.d.ts +5 -1
- package/es/flow/models/blocks/shared/legacyDefaultValueMigrationBase.d.ts +1 -0
- package/es/flow/models/blocks/table/TableSelectModel.d.ts +8 -0
- package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.d.ts +4 -0
- package/es/flow/models/fields/ClickableFieldModel.d.ts +3 -0
- package/es/flow/models/fields/DisplayEnumFieldModel.d.ts +6 -0
- package/es/flow/models/fields/DisplayTitleFieldModel.d.ts +2 -2
- package/es/flow/models/utils/displayValueUtils.d.ts +12 -0
- package/es/flow-compat/passwordUtils.d.ts +1 -1
- package/es/index.mjs +119 -108
- package/es/utils/remotePlugins.d.ts +0 -4
- package/lib/index.js +122 -111
- package/package.json +9 -5
- package/src/BaseApplication.tsx +14 -8
- package/src/PluginManager.ts +1 -0
- package/src/__tests__/app.test.tsx +28 -1
- package/src/__tests__/globalDeps.test.ts +1 -0
- package/src/__tests__/remotePlugins.test.ts +29 -18
- package/src/components/form/DrawerFormLayout.tsx +103 -0
- package/src/components/form/EnvVariableInput.tsx +126 -0
- package/src/components/form/FileSizeInput.tsx +105 -0
- package/src/components/form/createFormRegistry.ts +60 -0
- package/src/components/form/index.tsx +14 -0
- package/src/components/index.ts +1 -1
- package/src/flow/actions/__tests__/dataScopeFilter.test.ts +92 -13
- package/src/flow/actions/__tests__/formAssignRules.legacyMigration.test.tsx +173 -0
- package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +476 -1
- package/src/flow/actions/__tests__/pattern.test.ts +134 -0
- package/src/flow/actions/__tests__/titleField.test.ts +45 -0
- package/src/flow/actions/filterFormDefaultValues.tsx +30 -9
- package/src/flow/actions/formAssignRules.tsx +24 -9
- package/src/flow/actions/linkageRules.tsx +240 -258
- package/src/flow/actions/pattern.tsx +41 -6
- package/src/flow/actions/setTargetDataScope.tsx +32 -3
- package/src/flow/actions/titleField.tsx +4 -2
- package/src/flow/actions/validation.tsx +1 -1
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +0 -4
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +13 -5
- package/src/flow/components/DynamicFlowsIcon.tsx +87 -13
- package/src/flow/components/FieldAssignRulesEditor.tsx +2 -0
- package/src/flow/components/__tests__/DynamicFlowsIcon.test.tsx +195 -8
- package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +81 -4
- package/src/flow/components/code-editor/index.tsx +12 -8
- package/src/flow/components/filter/LinkageFilterItem.tsx +9 -2
- package/src/flow/components/filter/VariableFilterItem.tsx +2 -6
- package/src/flow/components/filter/__tests__/LinkageFilterItem.test.tsx +71 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +48 -0
- package/src/flow/internal/utils/__tests__/enumOptionsUtils.test.ts +10 -1
- package/src/flow/internal/utils/enumOptionsUtils.ts +29 -0
- package/src/flow/models/actions/AssociateActionModel.tsx +2 -2
- package/src/flow/models/actions/AssociationActionUtils.ts +14 -0
- package/src/flow/models/actions/__tests__/AssociationActionModel.test.ts +63 -0
- package/src/flow/models/base/CollectionBlockModel.tsx +7 -0
- package/src/flow/models/base/PageModel/RootPageModel.tsx +1 -1
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +33 -9
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +53 -13
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.getFilterValue.test.ts +63 -3
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +33 -1
- package/src/flow/models/blocks/filter-form/__tests__/legacyDefaultValueMigration.test.ts +3 -0
- package/src/flow/models/blocks/filter-manager/FilterManager.ts +66 -2
- package/src/flow/models/blocks/filter-manager/__tests__/FilterManager.test.ts +270 -0
- package/src/flow/models/blocks/form/FormActionModel.tsx +2 -8
- package/src/flow/models/blocks/form/FormBlockModel.tsx +8 -5
- package/src/flow/models/blocks/form/FormItemModel.tsx +1 -1
- package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +30 -0
- package/src/flow/models/blocks/form/__tests__/legacyDefaultValueMigration.test.ts +3 -0
- package/src/flow/models/blocks/form/value-runtime/rules.ts +6 -1
- package/src/flow/models/blocks/form/value-runtime/runtime.ts +6 -1
- package/src/flow/models/blocks/shared/legacyDefaultValueMigrationBase.ts +21 -5
- package/src/flow/models/blocks/table/TableBlockModel.tsx +11 -6
- package/src/flow/models/blocks/table/TableColumnModel.tsx +8 -2
- package/src/flow/models/blocks/table/TableSelectModel.tsx +36 -26
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowClick.test.ts +69 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +132 -1
- package/src/flow/models/blocks/table/__tests__/TableSelectModel.test.ts +41 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +144 -3
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/__tests__/SubTableColumnModel.rowRecord.test.ts +170 -1
- package/src/flow/models/fields/ClickableFieldModel.tsx +55 -6
- package/src/flow/models/fields/DisplayEnumFieldModel.tsx +44 -0
- package/src/flow/models/fields/DisplayTitleFieldModel.tsx +40 -7
- package/src/flow/models/fields/SelectFieldModel.tsx +31 -1
- package/src/flow/models/fields/__tests__/ClickableFieldModel.test.ts +202 -1
- package/src/flow/models/fields/__tests__/DisplayEnumFieldModel.test.tsx +39 -0
- package/src/flow/models/fields/mobile-components/MobileSelect.tsx +2 -1
- package/src/flow/models/fields/mobile-components/__tests__/MobileSelect.test.tsx +7 -0
- package/src/flow/models/utils/displayValueUtils.ts +57 -0
- package/src/utils/globalDeps.ts +11 -0
- package/src/utils/remotePlugins.ts +7 -27
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
import { defineAction, observer, tExpr, useFlowContext } from '@nocobase/flow-engine';
|
|
11
11
|
import { isEqual } from 'lodash';
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { FieldAssignRulesEditor
|
|
13
|
+
import { FieldAssignRulesEditor } from '../components/FieldAssignRulesEditor';
|
|
14
|
+
import type { FieldAssignRuleItem } from '../components/FieldAssignRulesEditor';
|
|
14
15
|
import { collectFieldAssignCascaderOptions } from '../components/fieldAssignOptions';
|
|
15
16
|
import { useAssociationTitleFieldSync } from '../components/useAssociationTitleFieldSync';
|
|
16
17
|
import { findFormItemModelByFieldPath, getCollectionFromModel } from '../internal/utils/modelUtils';
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
collectLegacyDefaultValueRulesFromFilterFormModel,
|
|
19
20
|
mergeAssignRulesWithLegacyDefaults,
|
|
20
21
|
} from '../models/blocks/filter-form/legacyDefaultValueMigration';
|
|
22
|
+
import { hasPersistedAssignRulesValue } from '../models/blocks/shared/legacyDefaultValueMigrationBase';
|
|
21
23
|
import { getDefaultOperator } from '../models/blocks/filter-manager/utils';
|
|
22
24
|
import { operators } from '../../flow-compat';
|
|
23
25
|
|
|
@@ -36,6 +38,10 @@ const FilterFormDefaultValuesUI = observer(
|
|
|
36
38
|
return collectLegacyDefaultValueRulesFromFilterFormModel(ctx.model);
|
|
37
39
|
}, [ctx.model]);
|
|
38
40
|
|
|
41
|
+
const hasPersistedValue = React.useMemo(() => {
|
|
42
|
+
return hasPersistedAssignRulesValue(ctx.model, 'formFilterBlockModelSettings', 'defaultValues');
|
|
43
|
+
}, [ctx.model]);
|
|
44
|
+
|
|
39
45
|
const getValueInputProps = React.useCallback(
|
|
40
46
|
(item: FieldAssignRuleItem) => {
|
|
41
47
|
const targetPath = item?.targetPath ? String(item.targetPath) : '';
|
|
@@ -57,7 +63,7 @@ const FilterFormDefaultValuesUI = observer(
|
|
|
57
63
|
);
|
|
58
64
|
|
|
59
65
|
// 兼容:将字段级默认值(filterFormItemSettings.initialValue)合并到表单级 defaultValues 里展示。
|
|
60
|
-
//
|
|
66
|
+
// 仅在表单级 defaultValues.value 尚未持久化时合并;已保存的空数组也代表用户显式删除。
|
|
61
67
|
const hasInitializedMergeRef = React.useRef(false);
|
|
62
68
|
const [hasInitializedMerge, setHasInitializedMerge] = React.useState(false);
|
|
63
69
|
const markInitialized = React.useCallback(() => {
|
|
@@ -66,12 +72,23 @@ const FilterFormDefaultValuesUI = observer(
|
|
|
66
72
|
setHasInitializedMerge(true);
|
|
67
73
|
}, []);
|
|
68
74
|
|
|
75
|
+
const normalizedValue = React.useMemo(() => {
|
|
76
|
+
return Array.isArray(props.value) ? props.value : [];
|
|
77
|
+
}, [props.value]);
|
|
78
|
+
|
|
79
|
+
const legacyAwareValue = React.useMemo(() => {
|
|
80
|
+
if (hasPersistedValue) {
|
|
81
|
+
return normalizedValue;
|
|
82
|
+
}
|
|
83
|
+
return mergeAssignRulesWithLegacyDefaults(props.value, legacyDefaults);
|
|
84
|
+
}, [hasPersistedValue, legacyDefaults, normalizedValue, props.value]);
|
|
85
|
+
|
|
69
86
|
const value = React.useMemo(() => {
|
|
70
87
|
if (!canEdit || !hasInitializedMerge) {
|
|
71
|
-
return
|
|
88
|
+
return legacyAwareValue;
|
|
72
89
|
}
|
|
73
|
-
return
|
|
74
|
-
}, [canEdit, hasInitializedMerge,
|
|
90
|
+
return normalizedValue;
|
|
91
|
+
}, [canEdit, hasInitializedMerge, legacyAwareValue, normalizedValue]);
|
|
75
92
|
|
|
76
93
|
const handleChange = React.useCallback(
|
|
77
94
|
(next: FieldAssignRuleItem[]) => {
|
|
@@ -87,12 +104,16 @@ const FilterFormDefaultValuesUI = observer(
|
|
|
87
104
|
if (hasInitializedMergeRef.current) return;
|
|
88
105
|
if (!canEdit) return;
|
|
89
106
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
107
|
+
if (hasPersistedValue) {
|
|
108
|
+
markInitialized();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!isEqual(normalizedValue, legacyAwareValue)) {
|
|
113
|
+
props.onChange?.(legacyAwareValue);
|
|
93
114
|
}
|
|
94
115
|
markInitialized();
|
|
95
|
-
}, [canEdit,
|
|
116
|
+
}, [canEdit, hasPersistedValue, legacyAwareValue, markInitialized, normalizedValue, props.onChange]);
|
|
96
117
|
|
|
97
118
|
return (
|
|
98
119
|
<FieldAssignRulesEditor
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
import { defineAction, observer, tExpr, useFlowContext } from '@nocobase/flow-engine';
|
|
11
11
|
import { isEqual } from 'lodash';
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { FieldAssignRulesEditor
|
|
13
|
+
import { FieldAssignRulesEditor } from '../components/FieldAssignRulesEditor';
|
|
14
|
+
import type { FieldAssignRuleItem } from '../components/FieldAssignRulesEditor';
|
|
14
15
|
import { collectFieldAssignCascaderOptions } from '../components/fieldAssignOptions';
|
|
15
16
|
import { useAssociationTitleFieldSync } from '../components/useAssociationTitleFieldSync';
|
|
16
17
|
import { getCollectionFromModel } from '../internal/utils/modelUtils';
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
collectLegacyDefaultValueRulesFromFormModel,
|
|
19
20
|
mergeAssignRulesWithLegacyDefaults,
|
|
20
21
|
} from '../models/blocks/form/legacyDefaultValueMigration';
|
|
22
|
+
import { hasPersistedAssignRulesValue } from '../models/blocks/shared/legacyDefaultValueMigrationBase';
|
|
21
23
|
|
|
22
24
|
const FormAssignRulesUI = observer(
|
|
23
25
|
(props: { value?: FieldAssignRuleItem[]; onChange?: (value: FieldAssignRuleItem[]) => void }) => {
|
|
@@ -34,8 +36,12 @@ const FormAssignRulesUI = observer(
|
|
|
34
36
|
return collectLegacyDefaultValueRulesFromFormModel(ctx.model);
|
|
35
37
|
}, [ctx.model]);
|
|
36
38
|
|
|
39
|
+
const hasPersistedValue = React.useMemo(() => {
|
|
40
|
+
return hasPersistedAssignRulesValue(ctx.model, 'formModelSettings', 'assignRules');
|
|
41
|
+
}, [ctx.model]);
|
|
42
|
+
|
|
37
43
|
// 兼容:将字段级默认值(editItemSettings/formItemSettings.initialValue)合并到表单级 assignRules 里展示。
|
|
38
|
-
//
|
|
44
|
+
// 仅在表单级 assignRules.value 尚未持久化时合并;已保存的空数组也代表用户显式删除。
|
|
39
45
|
const hasInitializedMergeRef = React.useRef(false);
|
|
40
46
|
const [hasInitializedMerge, setHasInitializedMerge] = React.useState(false);
|
|
41
47
|
const markInitialized = React.useCallback(() => {
|
|
@@ -49,12 +55,19 @@ const FormAssignRulesUI = observer(
|
|
|
49
55
|
return base;
|
|
50
56
|
}, [props.value]);
|
|
51
57
|
|
|
58
|
+
const legacyAwareValue = React.useMemo(() => {
|
|
59
|
+
if (hasPersistedValue) {
|
|
60
|
+
return normalizedValue;
|
|
61
|
+
}
|
|
62
|
+
return mergeAssignRulesWithLegacyDefaults(props.value, legacyDefaults);
|
|
63
|
+
}, [hasPersistedValue, legacyDefaults, normalizedValue, props.value]);
|
|
64
|
+
|
|
52
65
|
const value = React.useMemo(() => {
|
|
53
66
|
if (!canEdit || !hasInitializedMerge) {
|
|
54
|
-
return
|
|
67
|
+
return legacyAwareValue;
|
|
55
68
|
}
|
|
56
69
|
return normalizedValue;
|
|
57
|
-
}, [canEdit, hasInitializedMerge,
|
|
70
|
+
}, [canEdit, hasInitializedMerge, legacyAwareValue, normalizedValue]);
|
|
58
71
|
|
|
59
72
|
const handleChange = React.useCallback(
|
|
60
73
|
(next: FieldAssignRuleItem[]) => {
|
|
@@ -70,14 +83,16 @@ const FormAssignRulesUI = observer(
|
|
|
70
83
|
if (hasInitializedMergeRef.current) return;
|
|
71
84
|
if (!canEdit) return;
|
|
72
85
|
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
if (hasPersistedValue) {
|
|
87
|
+
markInitialized();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
75
90
|
|
|
76
|
-
if (!isEqual(
|
|
77
|
-
props.onChange?.(
|
|
91
|
+
if (!isEqual(normalizedValue, legacyAwareValue)) {
|
|
92
|
+
props.onChange?.(legacyAwareValue);
|
|
78
93
|
}
|
|
79
94
|
markInitialized();
|
|
80
|
-
}, [canEdit,
|
|
95
|
+
}, [canEdit, hasPersistedValue, legacyAwareValue, markInitialized, normalizedValue, props.onChange]);
|
|
81
96
|
|
|
82
97
|
return (
|
|
83
98
|
<FieldAssignRulesEditor
|