@nocobase/client-v2 2.2.0-beta.9 → 2.2.1

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.
Files changed (224) hide show
  1. package/es/APIClient.d.ts +13 -3
  2. package/es/BaseApplication.d.ts +1 -0
  3. package/es/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
  4. package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +1 -0
  5. package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
  6. package/es/components/category-tabs/index.d.ts +9 -0
  7. package/es/components/form/ScanInput/useCodeScanner.d.ts +3 -2
  8. package/es/components/form/TypedVariableInput.d.ts +31 -5
  9. package/es/components/form/filter/CollectionFilter.d.ts +2 -0
  10. package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
  11. package/es/components/form/filter/CollectionFilterPanel.d.ts +2 -0
  12. package/es/components/form/filter/index.d.ts +2 -0
  13. package/es/components/form/filter/useFilterActionProps.d.ts +2 -0
  14. package/es/components/index.d.ts +1 -0
  15. package/es/flow/actions/index.d.ts +1 -1
  16. package/es/flow/actions/linkageRules.d.ts +27 -0
  17. package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
  18. package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
  19. package/es/flow/components/FieldAssignValueInput.d.ts +7 -24
  20. package/es/flow/components/FlowRoute.d.ts +2 -2
  21. package/es/flow/components/RunJSValueEditor.d.ts +1 -0
  22. package/es/flow/components/field-value-variable/DateVariableEditor.d.ts +24 -0
  23. package/es/flow/components/field-value-variable/FieldValueVariableInput.d.ts +31 -0
  24. package/es/flow/components/field-value-variable/dateValue.d.ts +36 -0
  25. package/es/flow/components/field-value-variable/index.d.ts +11 -0
  26. package/es/flow/components/filter/FilterGroup.d.ts +1 -0
  27. package/es/flow/components/filter/VariableFilterItem.d.ts +6 -1
  28. package/es/flow/components/placeholders/BlockPlaceholder.d.ts +1 -0
  29. package/es/flow/index.d.ts +1 -0
  30. package/es/flow/internal/registerDeviceTypeContext.d.ts +10 -0
  31. package/es/flow/internal/utils/operatorSchemaHelper.d.ts +2 -2
  32. package/es/flow/models/actions/UpdateRecordActionUtils.d.ts +8 -2
  33. package/es/flow/models/base/ActionModelCore.d.ts +4 -2
  34. package/es/flow/models/base/BlockGridModel.d.ts +3 -0
  35. package/es/flow/models/base/CollectionBlockModel.d.ts +3 -0
  36. package/es/flow/models/base/PageModel/PageModel.d.ts +12 -0
  37. package/es/flow/models/base/PageModel/PageModelTabBar.d.ts +22 -0
  38. package/es/flow/models/base/PageModel/PageTabModel.d.ts +12 -0
  39. package/es/flow/models/blocks/details/DetailsBlockModel.d.ts +3 -0
  40. package/es/flow/models/blocks/filter-form/FilterFormGridModel.d.ts +1 -0
  41. package/es/flow/models/blocks/filter-form/FilterFormSubmitActionModel.d.ts +3 -1
  42. package/es/flow/models/blocks/form/FormBlockModel.d.ts +7 -0
  43. package/es/flow/models/blocks/form/FormGridModel.d.ts +6 -0
  44. package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +17 -2
  45. package/es/flow/models/blocks/form/value-runtime/rules.d.ts +1 -0
  46. package/es/flow/models/blocks/table/JSColumnModel.d.ts +2 -0
  47. package/es/flow/models/blocks/table/TableBlockModel.d.ts +1 -0
  48. package/es/flow/models/blocks/table/TableColumnModel.d.ts +12 -0
  49. package/es/flow/models/blocks/table/utils.d.ts +1 -0
  50. package/es/flow/models/fields/AssociationFieldModel/RecordPickerFieldModel.d.ts +2 -1
  51. package/es/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.d.ts +0 -17
  52. package/es/flow/models/fields/AssociationFieldModel/recordSelectShared.d.ts +41 -0
  53. package/es/flow/models/fields/DateTimeFieldModel/dateLimit.d.ts +15 -7
  54. package/es/flow-compat/fieldValidationConstants.d.ts +1 -1
  55. package/es/flow-compat/passwordUtils.d.ts +1 -1
  56. package/es/flow-compat/routeTypes.d.ts +1 -0
  57. package/es/index.d.ts +5 -0
  58. package/es/index.mjs +199 -161
  59. package/es/ui-operation/index.d.ts +15 -0
  60. package/es/ui-operation/ui-operation-codec.d.ts +10 -0
  61. package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
  62. package/es/utils/index.d.ts +1 -0
  63. package/lib/index.js +215 -177
  64. package/lib/locale/languageCodes.js +3 -1
  65. package/package.json +9 -7
  66. package/src/APIClient.ts +90 -7
  67. package/src/Application.tsx +7 -1
  68. package/src/BaseApplication.tsx +11 -6
  69. package/src/__tests__/APIClient.test.tsx +58 -0
  70. package/src/__tests__/app.test.tsx +73 -0
  71. package/src/__tests__/browserChecker.test.ts +61 -0
  72. package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
  73. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +35 -2
  74. package/src/__tests__/settings-center.test.tsx +270 -6
  75. package/src/acl/ACLProvider.tsx +2 -0
  76. package/src/acl/__tests__/ACLProvider.test.tsx +92 -0
  77. package/src/collection-field-interface/CollectionFieldInterface.ts +1 -0
  78. package/src/collection-field-interface/CollectionFieldInterfaceManager.ts +1 -0
  79. package/src/collection-manager/field-validation.ts +1 -1
  80. package/src/components/README.md +7 -1
  81. package/src/components/README.zh-CN.md +6 -1
  82. package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
  83. package/src/components/category-tabs/index.ts +10 -0
  84. package/src/components/form/JsonTextArea.tsx +4 -0
  85. package/src/components/form/ScanInput/CodeScanner.tsx +79 -35
  86. package/src/components/form/ScanInput/__tests__/CodeScanner.test.tsx +101 -0
  87. package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +284 -11
  88. package/src/components/form/ScanInput/useCodeScanner.ts +332 -24
  89. package/src/components/form/TypedVariableInput.tsx +452 -101
  90. package/src/components/form/__tests__/TypedVariableInput.test.tsx +364 -12
  91. package/src/components/form/filter/CollectionFilter.tsx +4 -0
  92. package/src/components/form/filter/CollectionFilterItem.tsx +36 -9
  93. package/src/components/form/filter/CollectionFilterPanel.tsx +4 -0
  94. package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +55 -0
  95. package/src/components/form/filter/__tests__/useFilterActionProps.test.tsx +95 -0
  96. package/src/components/form/filter/index.ts +2 -0
  97. package/src/components/form/filter/useFilterActionProps.ts +37 -6
  98. package/src/components/form/table/Table.tsx +81 -6
  99. package/src/components/form/table/__tests__/Table.columnWidth.test.tsx +433 -0
  100. package/src/components/index.ts +1 -0
  101. package/src/flow/FlowPage.tsx +9 -1
  102. package/src/flow/__tests__/FlowPage.test.tsx +50 -3
  103. package/src/flow/__tests__/FlowRoute.test.tsx +128 -10
  104. package/src/flow/__tests__/PluginFlowEngine.test.ts +58 -0
  105. package/src/flow/actions/__tests__/actionLinkageRules.forkProps.test.ts +314 -0
  106. package/src/flow/actions/__tests__/dataScopeFormValueClear.test.ts +102 -0
  107. package/src/flow/actions/__tests__/linkageRules.actionStates.test.ts +33 -0
  108. package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +72 -0
  109. package/src/flow/actions/__tests__/linkageRules.tab.test.ts +171 -0
  110. package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +7 -3
  111. package/src/flow/actions/index.ts +2 -0
  112. package/src/flow/actions/linkageRules.tsx +144 -26
  113. package/src/flow/actions/linkageRulesRefresh.tsx +2 -6
  114. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +0 -1
  115. package/src/flow/admin-shell/admin-layout/AdminLayoutMenuUtils.tsx +78 -59
  116. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
  117. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +228 -0
  118. package/src/flow/common/Markdown/style.ts +4 -0
  119. package/src/flow/components/BlockItemCard.tsx +2 -2
  120. package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
  121. package/src/flow/components/FieldAssignValueInput.tsx +72 -584
  122. package/src/flow/components/FlowRoute.tsx +78 -32
  123. package/src/flow/components/RunJSValueEditor.tsx +9 -1
  124. package/src/flow/components/__tests__/FieldAssignValueInput.context.test.tsx +216 -0
  125. package/src/flow/components/field-value-variable/DateVariableEditor.tsx +181 -0
  126. package/src/flow/components/field-value-variable/FieldValueVariableInput.tsx +326 -0
  127. package/src/flow/components/field-value-variable/__tests__/FieldValueVariableInput.test.tsx +380 -0
  128. package/src/flow/components/field-value-variable/dateValue.ts +223 -0
  129. package/src/flow/components/field-value-variable/index.ts +12 -0
  130. package/src/flow/components/filter/FilterGroup.tsx +33 -5
  131. package/src/flow/components/filter/VariableFilterItem.tsx +170 -13
  132. package/src/flow/components/filter/__tests__/FilterGroup.test.tsx +45 -0
  133. package/src/flow/components/filter/__tests__/VariableFilterItem.leftMetaTree.test.tsx +9 -0
  134. package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +195 -1
  135. package/src/flow/components/placeholders/BlockPlaceholder.tsx +70 -23
  136. package/src/flow/components/placeholders/__tests__/BlockPlaceholder.test.tsx +57 -7
  137. package/src/flow/index.ts +3 -0
  138. package/src/flow/internal/registerDeviceTypeContext.ts +39 -0
  139. package/src/flow/internal/utils/operatorSchemaHelper.ts +3 -2
  140. package/src/flow/models/actions/UpdateRecordActionModel.tsx +18 -1
  141. package/src/flow/models/actions/UpdateRecordActionUtils.ts +18 -6
  142. package/src/flow/models/actions/__tests__/UpdateRecordActionModel.test.ts +76 -4
  143. package/src/flow/models/base/ActionModelCore.tsx +11 -2
  144. package/src/flow/models/base/BlockGridModel.tsx +26 -0
  145. package/src/flow/models/base/CollectionBlockModel.tsx +38 -3
  146. package/src/flow/models/base/PageModel/PageModel.tsx +387 -53
  147. package/src/flow/models/base/PageModel/PageModelTabBar.tsx +114 -0
  148. package/src/flow/models/base/PageModel/PageTabModel.tsx +249 -18
  149. package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +790 -10
  150. package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.module-isolation.test.tsx +130 -0
  151. package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.test.tsx +118 -0
  152. package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +1075 -7
  153. package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +49 -0
  154. package/src/flow/models/base/__tests__/BlockGridModel.selectSceneActivation.test.ts +124 -0
  155. package/src/flow/models/base/__tests__/CollectionBlockModel.addAppends.test.ts +41 -0
  156. package/src/flow/models/base/__tests__/CollectionBlockModel.initialBeforeRenderRefresh.test.ts +125 -9
  157. package/src/flow/models/blocks/assign-form/AssignFormItemModel.tsx +28 -53
  158. package/src/flow/models/blocks/details/DetailsBlockModel.tsx +8 -3
  159. package/src/flow/models/blocks/details/__tests__/DetailsBlockModel.initialPaginationChangeRefresh.test.ts +32 -1
  160. package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +28 -3
  161. package/src/flow/models/blocks/filter-form/FilterFormGridModel.tsx +36 -5
  162. package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +155 -25
  163. package/src/flow/models/blocks/filter-form/FilterFormSubmitActionModel.tsx +57 -4
  164. package/src/flow/models/blocks/filter-form/__tests__/FilterFormGridModel.onModelCreated.test.ts +174 -1
  165. package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +395 -1
  166. package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.getFilterValue.test.ts +72 -0
  167. package/src/flow/models/blocks/filter-form/__tests__/FilterFormSubmitActionModel.lifecycle.test.ts +90 -0
  168. package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +66 -4
  169. package/src/flow/models/blocks/filter-manager/FilterManager.ts +5 -0
  170. package/src/flow/models/blocks/filter-manager/__tests__/FilterManager.test.ts +40 -0
  171. package/src/flow/models/blocks/form/FormBlockModel.tsx +47 -0
  172. package/src/flow/models/blocks/form/FormGridModel.tsx +4 -0
  173. package/src/flow/models/blocks/form/QuickEditFormModel.tsx +189 -36
  174. package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +8 -2
  175. package/src/flow/models/blocks/form/__tests__/QuickEditFormModel.quickEdit.test.ts +350 -2
  176. package/src/flow/models/blocks/form/__tests__/runJsFormSubmit.test.ts +131 -0
  177. package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +435 -0
  178. package/src/flow/models/blocks/form/value-runtime/rules.ts +67 -14
  179. package/src/flow/models/blocks/form/value-runtime/runtime.ts +43 -19
  180. package/src/flow/models/blocks/js-block/JSBlock.tsx +1 -1
  181. package/src/flow/models/blocks/table/JSColumnModel.tsx +10 -1
  182. package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +2 -1
  183. package/src/flow/models/blocks/table/TableBlockModel.tsx +29 -3
  184. package/src/flow/models/blocks/table/TableColumnModel.tsx +48 -9
  185. package/src/flow/models/blocks/table/__tests__/JSColumnModel.test.tsx +52 -5
  186. package/src/flow/models/blocks/table/__tests__/TableBlockModel.filterReset.test.ts +78 -0
  187. package/src/flow/models/blocks/table/__tests__/TableBlockModel.quickEditRefresh.test.ts +12 -0
  188. package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +33 -0
  189. package/src/flow/models/blocks/table/utils.ts +7 -0
  190. package/src/flow/models/fields/AssociationFieldModel/CascadeSelectFieldModel.tsx +33 -1
  191. package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +10 -1
  192. package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/__tests__/popupContext.test.ts +120 -0
  193. package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableEditActionModel.tsx +10 -2
  194. package/src/flow/models/fields/AssociationFieldModel/RecordPickerFieldModel.tsx +24 -1
  195. package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +9 -136
  196. package/src/flow/models/fields/AssociationFieldModel/__tests__/RecordPickerFieldModel.itemContext.test.ts +167 -3
  197. package/src/flow/models/fields/AssociationFieldModel/recordSelectShared.tsx +156 -0
  198. package/src/flow/models/fields/DateTimeFieldModel/__tests__/DateTimeNoTzFieldModel.dateLimit.test.tsx +149 -0
  199. package/src/flow/models/fields/DateTimeFieldModel/dateLimit.ts +149 -113
  200. package/src/flow/models/fields/DisplayNumberFieldModel.tsx +1 -1
  201. package/src/flow/models/fields/JsonFieldModel.tsx +31 -8
  202. package/src/flow/models/fields/NumberFieldModel.tsx +1 -1
  203. package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
  204. package/src/flow/models/fields/__tests__/DisplayNumberFieldModel.test.ts +33 -0
  205. package/src/flow/models/fields/__tests__/JsonFieldModel.test.ts +82 -0
  206. package/src/flow/models/fields/__tests__/NumberFieldModel.test.tsx +47 -0
  207. package/src/flow/models/fields/__tests__/VariableFieldFormModel.test.tsx +51 -0
  208. package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +26 -10
  209. package/src/flow/models/fields/mobile-components/MobileSelect.tsx +51 -14
  210. package/src/flow/models/fields/mobile-components/__tests__/MobileSelect.test.tsx +139 -13
  211. package/src/flow/utils/dataScopeFormValueClear.ts +4 -3
  212. package/src/flow-compat/fieldValidationConstants.ts +1 -1
  213. package/src/flow-compat/routeTypes.ts +1 -0
  214. package/src/index.ts +5 -0
  215. package/src/layout-manager/LayoutContentRoute.tsx +2 -1
  216. package/src/layout-manager/LayoutRoute.tsx +2 -1
  217. package/src/layout-manager/__tests__/LayoutRoute.test.tsx +87 -1
  218. package/src/locale/languageCodes.ts +3 -1
  219. package/src/nocobase-buildin-plugin/index.tsx +12 -0
  220. package/src/settings-center/AdminSettingsLayout.tsx +23 -2
  221. package/src/ui-operation/index.ts +33 -0
  222. package/src/ui-operation/ui-operation-codec.ts +54 -0
  223. package/src/utils/getRouteRuntimeVersion.ts +185 -0
  224. package/src/utils/index.tsx +1 -0
@@ -8,21 +8,12 @@
8
8
  */
9
9
 
10
10
  import React from 'react';
11
- import { css } from '@emotion/css';
12
- import { Divider, Input, InputNumber, Select, Space, theme } from 'antd';
13
- import { dayjs } from '@nocobase/utils/client';
11
+ import { Input } from 'antd';
14
12
  import {
15
13
  FlowModelRenderer,
16
- VariableInput,
17
- tExpr,
18
- isVariableExpression,
19
- parseValueToPath,
20
- isRunJSValue,
21
- isCtxDateExpression,
22
- parseCtxDateExpression,
23
- serializeCtxDateValue,
24
14
  type CollectionField,
25
15
  type MetaTreeNode,
16
+ type VariableInputProps,
26
17
  useFlowContext,
27
18
  EditableItemModel,
28
19
  FlowModelContext,
@@ -39,283 +30,21 @@ import { RunJSValueEditor } from './RunJSValueEditor';
39
30
  import { pickOperatorStyle as pickStyle, resolveOperatorComponent } from '../internal/utils/operatorSchemaHelper';
40
31
  import { InputFieldModel } from '../models/fields/InputFieldModel';
41
32
  import { normalizeFilterValueByOperator } from '../models/blocks/filter-form/valueNormalization';
42
- import { FieldAssignExactDatePicker, type ExactDatePickerMode } from './FieldAssignExactDatePicker';
43
33
  import { limitAssociationMetaTree } from './filter/metaTreeAssociationDepth';
44
-
45
- const DATE_FIELD_INTERFACES = new Set(['date', 'datetime', 'datetimeNoTz', 'createdAt', 'updatedAt', 'unixTimestamp']);
46
-
47
- const TZ_AWARE_DATE_INTERFACES = new Set(['datetime', 'createdAt', 'updatedAt', 'unixTimestamp']);
48
-
49
- const DATE_ONLY_OUTPUT_FORMAT = 'YYYY-MM-DD';
50
- const DATETIME_NO_TZ_OUTPUT_FORMAT = 'YYYY-MM-DD HH:mm:ss';
51
-
52
- export type DateVariableExactNormalizeMode = 'none' | 'date' | 'datetimeNoTz' | 'iso';
53
-
54
- const DATE_DYNAMIC_OPTION_KEYS = [
55
- 'exact',
56
- 'past',
57
- 'next',
58
- 'today',
59
- 'yesterday',
60
- 'tomorrow',
61
- 'thisWeek',
62
- 'lastWeek',
63
- 'nextWeek',
64
- 'thisMonth',
65
- 'lastMonth',
66
- 'nextMonth',
67
- 'thisQuarter',
68
- 'lastQuarter',
69
- 'nextQuarter',
70
- 'thisYear',
71
- 'lastYear',
72
- 'nextYear',
73
- ] as const;
74
-
75
- type DateDynamicOptionValue = (typeof DATE_DYNAMIC_OPTION_KEYS)[number] | 'now';
76
-
77
- const DATE_DYNAMIC_OPTION_LABELS: Record<(typeof DATE_DYNAMIC_OPTION_KEYS)[number], string> = {
78
- exact: 'Exact day',
79
- past: 'Past',
80
- next: 'Next',
81
- today: 'Today',
82
- yesterday: 'Yesterday',
83
- tomorrow: 'Tomorrow',
84
- thisWeek: 'This Week',
85
- lastWeek: 'Last Week',
86
- nextWeek: 'Next Week',
87
- thisMonth: 'This Month',
88
- lastMonth: 'Last Month',
89
- nextMonth: 'Next Month',
90
- thisQuarter: 'This Quarter',
91
- lastQuarter: 'Last Quarter',
92
- nextQuarter: 'Next Quarter',
93
- thisYear: 'This Year',
94
- lastYear: 'Last Year',
95
- nextYear: 'Next Year',
96
- };
97
-
98
- function buildDateDynamicOptions(t?: (key: string) => string, includeNow = false) {
99
- const options: Array<{ value: DateDynamicOptionValue; label: string }> = DATE_DYNAMIC_OPTION_KEYS.map((key) => ({
100
- value: key,
101
- label: t?.(DATE_DYNAMIC_OPTION_LABELS[key]) ?? DATE_DYNAMIC_OPTION_LABELS[key],
102
- }));
103
-
104
- if (includeNow) {
105
- options.splice(3, 0, { value: 'now', label: t?.('Now') ?? 'Now' });
106
- }
107
-
108
- return options;
109
- }
110
-
111
- function parseDateByFormat(value: string, format: string): dayjs.Dayjs | null {
112
- const raw = String(value || '').trim();
113
- if (!raw) return null;
114
-
115
- const hasTimezone = /(?:Z|[+-]\d{2}:\d{2})$/i.test(raw);
116
- if (hasTimezone) {
117
- const parsed = dayjs(raw);
118
- if (parsed.isValid()) {
119
- return parsed;
120
- }
121
- }
122
-
123
- if (format) {
124
- const strict = dayjs(raw, format, true);
125
- if (strict.isValid()) {
126
- return strict;
127
- }
128
- }
129
-
130
- const fallback = dayjs(raw);
131
- if (fallback.isValid()) {
132
- return fallback;
133
- }
134
-
135
- if (format) {
136
- const loose = dayjs(raw, format);
137
- if (loose.isValid()) {
138
- return loose;
139
- }
140
- }
141
-
142
- return null;
143
- }
144
-
145
- function parseDateFromRawValue(value: unknown, format: string): dayjs.Dayjs | null {
146
- if (dayjs.isDayjs(value)) {
147
- return value;
148
- }
149
-
150
- if (value instanceof Date) {
151
- const parsedDate = dayjs(value);
152
- return parsedDate.isValid() ? parsedDate : null;
153
- }
154
-
155
- if (typeof value === 'string') {
156
- return parseDateByFormat(value, format);
157
- }
158
-
159
- return null;
160
- }
161
-
162
- function normalizeExactDateValue(
163
- value: unknown,
164
- options: {
165
- format: string;
166
- showTime: boolean;
167
- exactNormalizeMode: DateVariableExactNormalizeMode;
168
- },
169
- ): unknown {
170
- const parsed = parseDateFromRawValue(value, options.format);
171
- if (!parsed?.isValid()) {
172
- return value;
173
- }
174
-
175
- switch (options.exactNormalizeMode) {
176
- case 'date':
177
- return parsed.format(DATE_ONLY_OUTPUT_FORMAT);
178
- case 'datetimeNoTz':
179
- return parsed.format(options.showTime ? DATETIME_NO_TZ_OUTPUT_FORMAT : DATE_ONLY_OUTPUT_FORMAT);
180
- case 'iso':
181
- return parsed.toISOString();
182
- default:
183
- return value;
184
- }
185
- }
186
-
187
- function toExactPickerSingleValue(rawValue: unknown, format: string): dayjs.Dayjs | null {
188
- const parsed = parseDateFromRawValue(rawValue, format);
189
- return parsed?.isValid() ? parsed : null;
190
- }
191
-
192
- function toExactPickerRangeValue(rawValue: unknown, format: string): [dayjs.Dayjs, dayjs.Dayjs] | null {
193
- if (!Array.isArray(rawValue)) return null;
194
- const left = toExactPickerSingleValue(rawValue[0], format);
195
- const right = toExactPickerSingleValue(rawValue[1], format);
196
- if (!left || !right) return null;
197
- return [left, right];
198
- }
199
-
200
- export function toExactPickerDisplayValue(
201
- rawValue: unknown,
202
- options: {
203
- format: string;
204
- isRange: boolean;
205
- },
206
- ): dayjs.Dayjs | [dayjs.Dayjs, dayjs.Dayjs] | null {
207
- if (options.isRange) {
208
- return toExactPickerRangeValue(rawValue, options.format);
209
- }
210
- return toExactPickerSingleValue(rawValue, options.format);
211
- }
212
-
213
- function getDateVariableExactNormalizeMode(fieldInterface: string): DateVariableExactNormalizeMode {
214
- if (fieldInterface === 'date') {
215
- return 'date';
216
- }
217
-
218
- if (fieldInterface === 'datetimeNoTz') {
219
- return 'datetimeNoTz';
220
- }
221
-
222
- if (TZ_AWARE_DATE_INTERFACES.has(fieldInterface)) {
223
- return 'iso';
224
- }
225
-
226
- return 'none';
227
- }
228
-
229
- export function normalizeDateVariableExactValue(
230
- rawValue: any,
231
- options: {
232
- exactNormalizeMode: DateVariableExactNormalizeMode;
233
- format: string;
234
- showTime: boolean;
235
- },
236
- ): any {
237
- if (options.exactNormalizeMode === 'none') {
238
- return rawValue;
239
- }
240
-
241
- if (typeof rawValue === 'string') {
242
- return normalizeExactDateValue(rawValue, options);
243
- }
244
-
245
- if (dayjs.isDayjs(rawValue) || rawValue instanceof Date) {
246
- return normalizeExactDateValue(rawValue, options);
247
- }
248
-
249
- if (Array.isArray(rawValue)) {
250
- return rawValue.map((item) => {
251
- if (typeof item === 'string' || dayjs.isDayjs(item) || item instanceof Date) {
252
- return normalizeExactDateValue(item, options);
253
- }
254
- return item;
255
- });
256
- }
257
-
258
- return rawValue;
259
- }
260
-
261
- type DateVariableComponentProps = {
262
- picker: ExactDatePickerMode;
263
- showTime: boolean;
264
- timeFormat: string;
265
- format: string;
266
- exactNormalizeMode: DateVariableExactNormalizeMode;
267
- };
268
-
269
- function normalizeExactDatePickerMode(value: unknown): ExactDatePickerMode {
270
- if (value === 'year' || value === 'quarter' || value === 'month' || value === 'date') {
271
- return value;
272
- }
273
-
274
- return 'date';
275
- }
276
-
277
- const DEFAULT_DATE_VARIABLE_COMPONENT_PROPS: DateVariableComponentProps = {
278
- picker: 'date',
279
- showTime: false,
280
- timeFormat: 'HH:mm:ss',
281
- format: 'YYYY-MM-DD',
282
- exactNormalizeMode: 'none',
283
- };
284
-
285
- function getFieldInterface(field: any): string {
286
- return typeof field?.interface === 'string' ? field.interface : '';
287
- }
288
-
289
- function getFieldComponentProps(field: any): Record<string, any> {
290
- return (
291
- (typeof field?.getComponentProps === 'function' ? field.getComponentProps() : null) ||
292
- field?.uiSchema?.['x-component-props'] ||
293
- {}
294
- );
295
- }
296
-
297
- export function normalizeDateVariableOutput(rawValue: any, options: DateVariableComponentProps): any {
298
- if (rawValue === null || isRunJSValue(rawValue)) {
299
- return rawValue;
300
- }
301
-
302
- if (typeof rawValue === 'string' && isVariableExpression(rawValue) && !isCtxDateExpression(rawValue)) {
303
- return rawValue;
304
- }
305
-
306
- if (rawValue === '' || typeof rawValue === 'undefined') {
307
- return '';
308
- }
309
-
310
- const normalized = normalizeDateVariableExactValue(rawValue, {
311
- exactNormalizeMode: options.exactNormalizeMode,
312
- format: options.format || 'YYYY-MM-DD HH:mm:ss',
313
- showTime: options.showTime,
314
- });
315
-
316
- const serialized = serializeCtxDateValue(normalized);
317
- return serialized || normalized;
318
- }
34
+ import {
35
+ DEFAULT_DATE_VARIABLE_COMPONENT_PROPS,
36
+ FieldValueVariableInput,
37
+ getFieldInterface,
38
+ isDateLikeField as isDateLikeCollectionField,
39
+ resolveDateVariableComponentProps,
40
+ } from './field-value-variable';
41
+
42
+ export {
43
+ normalizeDateVariableExactValue,
44
+ normalizeDateVariableOutput,
45
+ toExactPickerDisplayValue,
46
+ type DateVariableExactNormalizeMode,
47
+ } from './field-value-variable';
319
48
 
320
49
  interface Props {
321
50
  /** 赋值目标路径,例如 `title` / `users.nickname` / `user.name` */
@@ -337,11 +66,14 @@ interface Props {
337
66
  value?: string;
338
67
  };
339
68
  /**
340
- * 在日期字段场景下,用日期变量编辑器替换 Constant 位。
341
- * 默认 false,保持历史行为。
69
+ * @deprecated Date 已作为独立一级变量提供,此参数仅为调用兼容保留。
342
70
  */
343
71
  enableDateVariableAsConstant?: boolean;
72
+ /** 是否允许在变量选择器中使用 RunJS。默认 true,保持历史行为。 */
73
+ allowRunJS?: boolean;
344
74
  maxAssociationFieldDepth?: number;
75
+ disabled?: boolean;
76
+ variableConverters?: VariableInputProps['converters'];
345
77
  }
346
78
 
347
79
  type ResolvedFieldContext = {
@@ -711,8 +443,10 @@ export const FieldAssignValueInput: React.FC<Props> = ({
711
443
  operatorMetaList,
712
444
  preferFormItemFieldModel,
713
445
  associationFieldNamesOverride,
714
- enableDateVariableAsConstant = false,
446
+ allowRunJS = true,
715
447
  maxAssociationFieldDepth = 2,
448
+ disabled = false,
449
+ variableConverters,
716
450
  }) => {
717
451
  const flowCtx = useFlowContext<FlowModelContext>();
718
452
  const normalizeEventValue = React.useCallback((eventOrValue: unknown) => {
@@ -892,69 +626,18 @@ export const FieldAssignValueInput: React.FC<Props> = ({
892
626
  }, [cf, currentAllowMultiple, itemCollectionField]);
893
627
 
894
628
  const isDateLikeField = React.useMemo(() => {
895
- if (sourceInterface && DATE_FIELD_INTERFACES.has(sourceInterface)) {
896
- return true;
897
- }
898
-
899
629
  const leaf =
900
630
  (typeof fieldName === 'string' && fieldName) ||
901
631
  (typeof targetPath === 'string' ? targetPath.split('.').filter(Boolean).slice(-1)[0] : '');
902
632
 
903
- return leaf === 'createdAt' || leaf === 'updatedAt';
904
- }, [fieldName, sourceInterface, targetPath]);
905
-
906
- const useDateVariableConstant = enableDateVariableAsConstant && isDateLikeField;
633
+ return isDateLikeCollectionField(sourceCollectionField, leaf, sourceInterface);
634
+ }, [fieldName, sourceCollectionField, sourceInterface, targetPath]);
907
635
 
908
636
  const dateVariableComponentProps = React.useMemo(() => {
909
- if (!useDateVariableConstant) {
910
- return DEFAULT_DATE_VARIABLE_COMPONENT_PROPS;
911
- }
912
-
913
- const componentProps = getFieldComponentProps(sourceCollectionField);
914
-
915
- const picker = normalizeExactDatePickerMode(componentProps?.picker);
916
- const inferredShowTime = ['datetime', 'datetimeNoTz', 'createdAt', 'updatedAt', 'unixTimestamp'].includes(
917
- sourceInterface,
918
- );
919
- const showTime = typeof componentProps?.showTime === 'boolean' ? componentProps.showTime : inferredShowTime;
920
-
921
- const dateFormat =
922
- typeof componentProps?.dateFormat === 'string' && componentProps.dateFormat
923
- ? componentProps.dateFormat
924
- : typeof componentProps?.format === 'string' && componentProps.format
925
- ? componentProps.format.split(' ')[0]
926
- : 'YYYY-MM-DD';
927
- const timeFormat =
928
- typeof componentProps?.timeFormat === 'string' && componentProps.timeFormat
929
- ? componentProps.timeFormat
930
- : 'HH:mm:ss';
931
-
932
- const format =
933
- typeof componentProps?.format === 'string' && componentProps.format
934
- ? componentProps.format
935
- : showTime
936
- ? `${dateFormat} ${timeFormat}`
937
- : dateFormat;
938
-
939
- return {
940
- picker,
941
- showTime,
942
- timeFormat,
943
- format,
944
- exactNormalizeMode: getDateVariableExactNormalizeMode(sourceInterface),
945
- };
946
- }, [sourceCollectionField, sourceInterface, useDateVariableConstant]);
947
-
948
- const dateVariableDisplayProps = React.useMemo(() => {
949
- const { exactNormalizeMode, ...rest } = dateVariableComponentProps;
950
- return rest;
951
- }, [dateVariableComponentProps]);
952
-
953
- const dateVariableDisplayPropsRef = React.useRef(dateVariableDisplayProps);
954
- dateVariableDisplayPropsRef.current = dateVariableDisplayProps;
955
-
956
- const dateVariableTranslateRef = React.useRef(flowCtx.t);
957
- dateVariableTranslateRef.current = flowCtx.t;
637
+ return isDateLikeField
638
+ ? resolveDateVariableComponentProps(sourceCollectionField, sourceInterface)
639
+ : DEFAULT_DATE_VARIABLE_COMPONENT_PROPS;
640
+ }, [isDateLikeField, sourceCollectionField, sourceInterface]);
958
641
 
959
642
  const coerceEmptyValueForRenderer = React.useCallback(
960
643
  (v: any) => {
@@ -1028,18 +711,22 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1028
711
  collectionField: effectiveCollectionField,
1029
712
  });
1030
713
 
1031
- const created = engine?.createModel?.({
1032
- use: 'VariableFieldFormModel',
1033
- subModels: {
1034
- fields: [
1035
- {
1036
- use: effectiveFieldModelUse,
1037
- stepParams: tempFieldStepParams,
1038
- props: tempFieldProps,
1039
- },
1040
- ],
714
+ const sourceContext = resolved?.itemModel?.context || flowCtx.model?.context;
715
+ const created = engine?.createModel?.(
716
+ {
717
+ use: 'VariableFieldFormModel',
718
+ subModels: {
719
+ fields: [
720
+ {
721
+ use: effectiveFieldModelUse,
722
+ stepParams: tempFieldStepParams,
723
+ props: tempFieldProps,
724
+ },
725
+ ],
726
+ },
1041
727
  },
1042
- });
728
+ sourceContext ? { delegate: sourceContext } : undefined,
729
+ );
1043
730
  if (!created) return;
1044
731
 
1045
732
  // 注入上下文(集合/数据源/字段/区块/资源)
@@ -1073,7 +760,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1073
760
  fm.setStepParams('selectSettings', 'fieldNames', { label: overrideLabel });
1074
761
  }
1075
762
  fm?.setProps?.({
1076
- disabled: false,
763
+ disabled,
1077
764
  readPretty: false,
1078
765
  pattern: 'editable',
1079
766
  updateAssociation: false,
@@ -1136,6 +823,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1136
823
  preferFormItemFieldModel,
1137
824
  associationFieldNamesOverride?.label,
1138
825
  associationFieldNamesOverride?.value,
826
+ disabled,
1139
827
  ]);
1140
828
 
1141
829
  // 当传入 operator / operatorMetaList 时,按 operator schema 适配临时字段的输入组件与 props。
@@ -1188,6 +876,9 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1188
876
  React.useEffect(() => {
1189
877
  const coercedValue = coerceEmptyValueForRenderer(inputProps?.value);
1190
878
  const handleChange = (ev: any) => {
879
+ if (inputProps?.disabled) {
880
+ return;
881
+ }
1191
882
  const nextRaw = normalizeEventValue(ev);
1192
883
  const normalizedForStore = operator ? normalizeFilterValueByOperator(operator, nextRaw) : nextRaw;
1193
884
  const nextValue = coerceEmptyValueForRenderer(normalizedForStore);
@@ -1219,6 +910,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1219
910
  value={inputProps?.value}
1220
911
  onChange={(e) => inputProps?.onChange?.(normalizeEventValue(e))}
1221
912
  placeholder={placeholder}
913
+ disabled={inputProps?.disabled}
1222
914
  style={withFullWidthStyle(wrapperStyle)}
1223
915
  />
1224
916
  );
@@ -1233,158 +925,6 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1233
925
  return C;
1234
926
  }, [placeholder, tempRoot, coerceEmptyValueForRenderer, normalizeEventValue, operator]);
1235
927
 
1236
- const DateVariableConstantEditor = React.useMemo(() => {
1237
- const C: React.FC<any> = (inputProps) => {
1238
- const wrapperStyle = pickStyle(inputProps?.style);
1239
- const raw = inputProps?.value;
1240
- const parsed = isCtxDateExpression(raw) ? parseCtxDateExpression(raw) : raw;
1241
- const parsedValue = typeof parsed === 'undefined' ? undefined : parsed;
1242
- const { token } = theme.useToken();
1243
- const [open, setOpen] = React.useState(false);
1244
- const t = dateVariableTranslateRef.current;
1245
- const datePickerProps = dateVariableDisplayPropsRef.current;
1246
- const options = React.useMemo(() => buildDateDynamicOptions(t, true), [t]);
1247
-
1248
- const dynamicType =
1249
- parsedValue && typeof parsedValue === 'object' && !Array.isArray(parsedValue)
1250
- ? (parsedValue as any)?.type
1251
- : undefined;
1252
- const selectedType = typeof dynamicType === 'string' && dynamicType ? dynamicType : 'exact';
1253
- const isRange = Array.isArray(parsedValue);
1254
- const exactSingleValue = toExactPickerDisplayValue(parsedValue, {
1255
- format: datePickerProps.format,
1256
- isRange: false,
1257
- });
1258
- const exactRangeValue = toExactPickerDisplayValue(parsedValue, {
1259
- format: datePickerProps.format,
1260
- isRange: true,
1261
- });
1262
-
1263
- const handleSelect = (val: string) => {
1264
- setOpen(false);
1265
- if (val === 'exact') {
1266
- inputProps?.onChange?.('');
1267
- return;
1268
- }
1269
- const next: any = { type: val };
1270
- if (val === 'past' || val === 'next') {
1271
- next.number = 1;
1272
- next.unit = 'day';
1273
- }
1274
- inputProps?.onChange?.(next);
1275
- };
1276
-
1277
- const handleExactSingleChange = (nextValue: any) => {
1278
- inputProps?.onChange?.(nextValue || '');
1279
- };
1280
-
1281
- const handleExactRangeChange = (nextValue: any) => {
1282
- inputProps?.onChange?.(nextValue || '');
1283
- };
1284
-
1285
- const dropdownRender = () => {
1286
- const firstPart = options.slice(0, 3);
1287
- const secondPart = options.slice(3);
1288
- const optionStyle = css`
1289
- padding: 3px 10px;
1290
- cursor: pointer;
1291
- white-space: nowrap;
1292
- overflow: hidden;
1293
- text-overflow: ellipsis;
1294
- &:hover {
1295
- background-color: ${token.colorFillSecondary};
1296
- }
1297
- `;
1298
- return (
1299
- <div style={{ maxHeight: 300, overflowY: 'auto' }}>
1300
- {firstPart.map((opt) => (
1301
- <div key={opt.value} role="option" onClick={() => handleSelect(opt.value)} className={optionStyle}>
1302
- {opt.label}
1303
- </div>
1304
- ))}
1305
- <Divider style={{ margin: '4px 0' }} />
1306
- {secondPart.map((opt) => (
1307
- <div
1308
- key={opt.value}
1309
- role="option"
1310
- className={optionStyle}
1311
- onClick={() => handleSelect(opt.value)}
1312
- title={opt.label}
1313
- >
1314
- {opt.label}
1315
- </div>
1316
- ))}
1317
- </div>
1318
- );
1319
- };
1320
-
1321
- return (
1322
- <Space.Compact style={withFullWidthStyle(wrapperStyle)}>
1323
- <Select
1324
- options={options}
1325
- open={open}
1326
- onDropdownVisibleChange={setOpen}
1327
- allowClear={false}
1328
- style={{
1329
- width: '100%',
1330
- minWidth: 100,
1331
- maxWidth: ['past', 'next', 'exact', undefined].includes(dynamicType) ? 100 : null,
1332
- }}
1333
- value={selectedType}
1334
- onChange={handleSelect}
1335
- dropdownRender={dropdownRender}
1336
- />
1337
- {['past', 'next'].includes(selectedType) && [
1338
- <InputNumber
1339
- key="number"
1340
- style={{ flex: 1 }}
1341
- value={(parsedValue as any)?.number}
1342
- onChange={(nextNumber) => {
1343
- inputProps?.onChange?.({
1344
- ...(parsedValue as any),
1345
- type: selectedType,
1346
- number: nextNumber,
1347
- unit: (parsedValue as any)?.unit || 'day',
1348
- });
1349
- }}
1350
- />,
1351
- <Select
1352
- key="unit"
1353
- value={(parsedValue as any)?.unit}
1354
- style={{ minWidth: 130, maxWidth: 140 }}
1355
- onChange={(nextUnit) => {
1356
- inputProps?.onChange?.({
1357
- ...(parsedValue as any),
1358
- type: selectedType,
1359
- unit: nextUnit,
1360
- number: (parsedValue as any)?.number || 1,
1361
- });
1362
- }}
1363
- options={[
1364
- { value: 'day', label: t?.('Day') ?? 'Day' },
1365
- { value: 'week', label: t?.('Calendar week') ?? 'Calendar week' },
1366
- { value: 'month', label: t?.('Calendar Month') ?? 'Calendar Month' },
1367
- { value: 'year', label: t?.('Calendar Year') ?? 'Calendar Year' },
1368
- ]}
1369
- popupMatchSelectWidth
1370
- />,
1371
- ]}
1372
- {(selectedType === 'exact' || !selectedType) && (
1373
- <FieldAssignExactDatePicker
1374
- {...datePickerProps}
1375
- isRange={isRange}
1376
- value={isRange ? exactRangeValue : exactSingleValue}
1377
- onChange={isRange ? handleExactRangeChange : handleExactSingleChange}
1378
- style={{ flex: 1 }}
1379
- />
1380
- )}
1381
- </Space.Compact>
1382
- );
1383
- };
1384
-
1385
- return C;
1386
- }, []);
1387
-
1388
928
  const NullComponent = React.useMemo(() => {
1389
929
  const N: React.FC = () => (
1390
930
  <Input placeholder={`<${flowCtx.t?.('Null') ?? 'Null'}>`} readOnly style={{ width: '100%' }} />
@@ -1394,59 +934,25 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1394
934
 
1395
935
  const RunJSComponent = React.useMemo(() => {
1396
936
  const C: React.FC<any> = (inputProps) => (
1397
- <RunJSValueEditor t={flowCtx.t} value={inputProps?.value} onChange={inputProps?.onChange} />
937
+ <RunJSValueEditor
938
+ t={flowCtx.t}
939
+ value={inputProps?.value}
940
+ onChange={inputProps?.onChange}
941
+ disabled={inputProps?.disabled}
942
+ />
1398
943
  );
1399
944
  return C;
1400
945
  }, [flowCtx]);
1401
946
 
1402
- const ConstantEditor = useDateVariableConstant ? DateVariableConstantEditor : ConstantValueEditor;
1403
-
1404
- const metaTree = React.useMemo<() => Promise<any[]>>(() => {
947
+ const baseMetaTree = React.useMemo<() => Promise<MetaTreeNode[]>>(() => {
1405
948
  return async () => {
1406
949
  const base = (await flowCtx.getPropertyMetaTree?.()) || [];
1407
950
  const extra = extraMetaTreeRef.current;
1408
951
  const extraTree = Array.isArray(extra) ? extra : [];
1409
952
  const mergedBase = mergeItemMetaTreeForAssignValue(base as MetaTreeNode[], extraTree as MetaTreeNode[]);
1410
- const limitedBase = limitAssociationMetaTree(mergedBase, { maxAssociationDepth: maxAssociationFieldDepth });
1411
- return [
1412
- {
1413
- title: tExpr('Constant'),
1414
- name: 'constant',
1415
- type: 'string',
1416
- paths: ['constant'],
1417
- render: ConstantEditor,
1418
- },
1419
- { title: tExpr('Null'), name: 'null', type: 'object', paths: ['null'], render: NullComponent },
1420
- { title: tExpr('RunJS'), name: 'runjs', type: 'object', paths: ['runjs'], render: RunJSComponent },
1421
- ...limitedBase,
1422
- ];
953
+ return limitAssociationMetaTree(mergedBase, { maxAssociationDepth: maxAssociationFieldDepth });
1423
954
  };
1424
- }, [flowCtx, ConstantEditor, NullComponent, RunJSComponent, maxAssociationFieldDepth]);
1425
-
1426
- const displayValue = React.useMemo(() => {
1427
- if (!useDateVariableConstant) {
1428
- return value;
1429
- }
1430
-
1431
- if (isCtxDateExpression(value)) {
1432
- const parsed = parseCtxDateExpression(value);
1433
- return typeof parsed === 'undefined' ? '' : parsed;
1434
- }
1435
-
1436
- return value;
1437
- }, [useDateVariableConstant, value]);
1438
-
1439
- const handleVariableInputChange = React.useCallback(
1440
- (nextValue: any) => {
1441
- if (!useDateVariableConstant) {
1442
- onChange(nextValue);
1443
- return;
1444
- }
1445
-
1446
- onChange(normalizeDateVariableOutput(nextValue, dateVariableComponentProps));
1447
- },
1448
- [dateVariableComponentProps, onChange, useDateVariableConstant],
1449
- );
955
+ }, [flowCtx, maxAssociationFieldDepth]);
1450
956
 
1451
957
  if (!fieldPath) {
1452
958
  // 不可用占位
@@ -1454,38 +960,20 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1454
960
  }
1455
961
 
1456
962
  return (
1457
- <VariableInput
1458
- value={displayValue}
1459
- onChange={handleVariableInputChange}
1460
- metaTree={metaTree}
963
+ <FieldValueVariableInput
964
+ value={value}
965
+ onChange={onChange}
966
+ baseMetaTree={baseMetaTree}
967
+ constantComponent={ConstantValueEditor}
968
+ nullComponent={NullComponent}
969
+ runJSComponent={RunJSComponent}
970
+ isDateLikeField={isDateLikeField}
971
+ dateComponentProps={dateVariableComponentProps}
1461
972
  style={{ width: '100%' }}
1462
973
  clearValue={''}
1463
- converters={{
1464
- renderInputComponent: (meta) => {
1465
- const firstPath = meta?.paths?.[0];
1466
- if (firstPath === 'constant') return ConstantEditor;
1467
- if (firstPath === 'null') return NullComponent;
1468
- if (firstPath === 'runjs') return RunJSComponent;
1469
- return null;
1470
- },
1471
- resolveValueFromPath: (item) => {
1472
- const firstPath = item?.paths?.[0];
1473
- if (firstPath === 'constant') {
1474
- return useDateVariableConstant ? { type: 'today' } : '';
1475
- }
1476
- if (firstPath === 'null') return null;
1477
- if (firstPath === 'runjs') return { code: '', version: 'v2' };
1478
- return undefined;
1479
- },
1480
- resolvePathFromValue: (currentValue) => {
1481
- if (currentValue === null) return ['null'];
1482
- if (isRunJSValue(currentValue)) return ['runjs'];
1483
- if (useDateVariableConstant && isCtxDateExpression(currentValue)) {
1484
- return ['constant'];
1485
- }
1486
- return isVariableExpression(currentValue) ? parseValueToPath(currentValue) : ['constant'];
1487
- },
1488
- }}
974
+ allowRunJS={allowRunJS}
975
+ disabled={disabled}
976
+ converters={variableConverters}
1489
977
  />
1490
978
  );
1491
979
  };