@nocobase/client-v2 2.2.0-beta.14 → 2.2.0-beta.15

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 (76) hide show
  1. package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
  2. package/es/components/category-tabs/index.d.ts +9 -0
  3. package/es/components/form/TypedVariableInput.d.ts +31 -5
  4. package/es/components/form/filter/CollectionFilter.d.ts +2 -0
  5. package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
  6. package/es/components/form/filter/CollectionFilterPanel.d.ts +2 -0
  7. package/es/components/form/filter/index.d.ts +2 -0
  8. package/es/components/form/filter/useFilterActionProps.d.ts +2 -0
  9. package/es/components/index.d.ts +1 -0
  10. package/es/flow/actions/index.d.ts +1 -1
  11. package/es/flow/actions/linkageRules.d.ts +2 -0
  12. package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
  13. package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
  14. package/es/flow/components/FieldAssignValueInput.d.ts +9 -0
  15. package/es/flow/components/RunJSValueEditor.d.ts +1 -0
  16. package/es/flow/components/filter/FilterGroup.d.ts +1 -0
  17. package/es/flow/components/filter/VariableFilterItem.d.ts +6 -1
  18. package/es/flow/index.d.ts +1 -0
  19. package/es/flow/models/base/PageModel/PageModel.d.ts +12 -0
  20. package/es/flow/models/base/PageModel/PageModelTabBar.d.ts +22 -0
  21. package/es/flow/models/base/PageModel/PageTabModel.d.ts +12 -0
  22. package/es/flow-compat/routeTypes.d.ts +1 -0
  23. package/es/index.d.ts +4 -0
  24. package/es/index.mjs +128 -94
  25. package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
  26. package/es/utils/index.d.ts +1 -0
  27. package/lib/index.js +139 -105
  28. package/lib/locale/languageCodes.js +2 -1
  29. package/package.json +7 -7
  30. package/src/__tests__/browserChecker.test.ts +61 -0
  31. package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
  32. package/src/components/README.md +7 -1
  33. package/src/components/README.zh-CN.md +6 -1
  34. package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
  35. package/src/components/category-tabs/index.ts +10 -0
  36. package/src/components/form/JsonTextArea.tsx +4 -0
  37. package/src/components/form/TypedVariableInput.tsx +452 -101
  38. package/src/components/form/__tests__/TypedVariableInput.test.tsx +364 -12
  39. package/src/components/form/filter/CollectionFilter.tsx +4 -0
  40. package/src/components/form/filter/CollectionFilterItem.tsx +32 -7
  41. package/src/components/form/filter/CollectionFilterPanel.tsx +4 -0
  42. package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +38 -0
  43. package/src/components/form/filter/__tests__/useFilterActionProps.test.tsx +95 -0
  44. package/src/components/form/filter/index.ts +2 -0
  45. package/src/components/form/filter/useFilterActionProps.ts +37 -6
  46. package/src/components/index.ts +1 -0
  47. package/src/flow/actions/__tests__/linkageRules.tab.test.ts +171 -0
  48. package/src/flow/actions/index.ts +2 -0
  49. package/src/flow/actions/linkageRules.tsx +86 -11
  50. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +0 -1
  51. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
  52. package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
  53. package/src/flow/components/FieldAssignValueInput.tsx +76 -9
  54. package/src/flow/components/RunJSValueEditor.tsx +9 -1
  55. package/src/flow/components/__tests__/FieldAssignValueInput.context.test.tsx +84 -2
  56. package/src/flow/components/filter/FilterGroup.tsx +33 -5
  57. package/src/flow/components/filter/VariableFilterItem.tsx +158 -10
  58. package/src/flow/components/filter/__tests__/FilterGroup.test.tsx +45 -0
  59. package/src/flow/components/filter/__tests__/VariableFilterItem.leftMetaTree.test.tsx +9 -0
  60. package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +70 -1
  61. package/src/flow/index.ts +1 -0
  62. package/src/flow/models/base/PageModel/PageModel.tsx +387 -53
  63. package/src/flow/models/base/PageModel/PageModelTabBar.tsx +114 -0
  64. package/src/flow/models/base/PageModel/PageTabModel.tsx +184 -3
  65. package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +790 -10
  66. package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.module-isolation.test.tsx +130 -0
  67. package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.test.tsx +118 -0
  68. package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +572 -1
  69. package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
  70. package/src/flow/models/fields/__tests__/VariableFieldFormModel.test.tsx +51 -0
  71. package/src/flow-compat/routeTypes.ts +1 -0
  72. package/src/index.ts +4 -0
  73. package/src/locale/languageCodes.ts +2 -1
  74. package/src/nocobase-buildin-plugin/index.tsx +2 -0
  75. package/src/utils/getRouteRuntimeVersion.ts +185 -0
  76. package/src/utils/index.tsx +1 -0
@@ -11,23 +11,58 @@ import { FlowEngine, FlowEngineProvider } from '@nocobase/flow-engine';
11
11
  import { act, render, screen, waitFor } from '@testing-library/react';
12
12
  import React, { useEffect } from 'react';
13
13
  import { createMemoryRouter, RouterProvider, useParams } from 'react-router-dom';
14
- import { describe, expect, it, vi } from 'vitest';
14
+ import { afterEach, describe, expect, it, vi } from 'vitest';
15
+ import { NocoBaseDesktopRouteType, type NocoBaseDesktopRoute } from '../../../../flow-compat';
15
16
  import type { LayoutDefinition } from '../../../../layout-manager/types';
16
17
  import { AdminLayoutComponent } from '../AdminLayoutComponent';
17
18
  import { AdminLayoutModel } from '../AdminLayoutModel';
19
+ import { AdminLayoutMenuItemModel } from '../AdminLayoutMenuModels';
18
20
  import { AdminLayoutContent } from '../AdminLayoutSlotModels';
19
21
 
22
+ const proLayoutLifecycle = vi.hoisted(() => ({
23
+ events: [] as string[],
24
+ routes: [] as Array<{ children?: Array<{ name?: React.ReactNode }> }>,
25
+ }));
26
+
20
27
  vi.mock('@ant-design/pro-layout', async () => {
21
28
  const ReactModule = await import('react');
22
29
  const RouteContext = ReactModule.createContext({ isMobile: false });
30
+ const ProLayoutMock = (props: {
31
+ children?: React.ReactNode;
32
+ route?: { children?: Array<{ name?: React.ReactNode }> };
33
+ }) => {
34
+ ReactModule.useEffect(() => {
35
+ proLayoutLifecycle.events.push('pro-layout:mount');
36
+ return () => {
37
+ proLayoutLifecycle.events.push('pro-layout:unmount');
38
+ };
39
+ }, []);
40
+ proLayoutLifecycle.routes.push(props.route || {});
23
41
 
24
- return {
25
- default: (props: { children?: React.ReactNode }) =>
42
+ return ReactModule.createElement(
43
+ RouteContext.Provider,
44
+ { value: { isMobile: false } },
26
45
  ReactModule.createElement(
27
- RouteContext.Provider,
28
- { value: { isMobile: false } },
29
- ReactModule.createElement('div', { 'data-testid': 'pro-layout' }, props.children),
46
+ 'div',
47
+ { 'data-testid': 'pro-layout' },
48
+ ReactModule.createElement(
49
+ 'nav',
50
+ { 'data-testid': 'pro-layout-menu' },
51
+ (props.route?.children || []).map((item) =>
52
+ ReactModule.createElement(
53
+ 'span',
54
+ { key: String(item.name), 'data-testid': 'pro-layout-menu-item' },
55
+ item.name,
56
+ ),
57
+ ),
58
+ ),
59
+ props.children,
30
60
  ),
61
+ );
62
+ };
63
+
64
+ return {
65
+ default: ProLayoutMock,
31
66
  RouteContext,
32
67
  };
33
68
  });
@@ -53,6 +88,10 @@ vi.mock('../AppListRender', () => ({
53
88
  useAppListRender: () => undefined,
54
89
  }));
55
90
 
91
+ afterEach(() => {
92
+ delete (window as Window & { __nocobase_modern_client_prefix__?: string }).__nocobase_modern_client_prefix__;
93
+ });
94
+
56
95
  describe('AdminLayoutComponent', () => {
57
96
  it('keeps custom admin layout pages alive by layout route name', async () => {
58
97
  const layout: LayoutDefinition = {
@@ -185,4 +224,212 @@ describe('AdminLayoutComponent', () => {
185
224
 
186
225
  expect(deactivateLayout).toHaveBeenCalledTimes(1);
187
226
  });
227
+
228
+ it('keeps layout content mounted when the menu route tree refreshes', async () => {
229
+ proLayoutLifecycle.events = [];
230
+ proLayoutLifecycle.routes = [];
231
+ const layout: LayoutDefinition = {
232
+ routeName: 'admin',
233
+ routePath: '/admin',
234
+ rootRouteName: 'admin',
235
+ uid: 'admin-layout-model',
236
+ layoutModelClass: 'AdminLayoutModel',
237
+ rootPageModelClass: 'RootPageModel',
238
+ childPageModelClass: 'ChildPageModel',
239
+ authCheck: true,
240
+ };
241
+ const events: string[] = [];
242
+ const engine = new FlowEngine();
243
+ engine.context.defineProperty('routeRepository', {
244
+ value: {
245
+ activateLayout: vi.fn(() => vi.fn()),
246
+ ensureAccessibleLoaded: vi.fn(async () => []),
247
+ listAccessible: () => [],
248
+ subscribe: vi.fn(),
249
+ unsubscribe: vi.fn(),
250
+ },
251
+ });
252
+ engine.context.defineProperty('t', {
253
+ value: (key: string) => key,
254
+ });
255
+ const model = engine.createModel<AdminLayoutModel>({
256
+ uid: layout.uid,
257
+ use: AdminLayoutModel,
258
+ props: {
259
+ layout,
260
+ },
261
+ });
262
+
263
+ const Page = () => {
264
+ useEffect(() => {
265
+ events.push('page:mount');
266
+ return () => {
267
+ events.push('page:unmount');
268
+ };
269
+ }, []);
270
+
271
+ return <div data-testid="custom-admin-route">Workflow tasks</div>;
272
+ };
273
+
274
+ const router = createMemoryRouter(
275
+ [
276
+ {
277
+ id: layout.routeName,
278
+ path: layout.routePath,
279
+ element: <AdminLayoutComponent model={model} />,
280
+ children: [
281
+ {
282
+ id: 'admin.workflow.tasks',
283
+ path: 'workflow/tasks/:taskType?/:status?/:popupId?',
284
+ element: <Page />,
285
+ },
286
+ ],
287
+ },
288
+ ],
289
+ {
290
+ initialEntries: ['/admin/workflow/tasks/approval-apply/pending'],
291
+ },
292
+ );
293
+
294
+ render(
295
+ <FlowEngineProvider engine={engine}>
296
+ <RouterProvider router={router} />
297
+ </FlowEngineProvider>,
298
+ );
299
+
300
+ expect(await screen.findByTestId('custom-admin-route')).toBeInTheDocument();
301
+ expect(proLayoutLifecycle.events).toEqual(['pro-layout:mount']);
302
+
303
+ act(() => {
304
+ model.refreshMenuRouteTree();
305
+ });
306
+
307
+ await act(async () => {
308
+ await router.navigate('/admin/workflow/tasks/approval-apply/pending/1');
309
+ });
310
+
311
+ expect(screen.getByTestId('custom-admin-route')).toBeInTheDocument();
312
+ expect(proLayoutLifecycle.events).toEqual(['pro-layout:mount']);
313
+ expect(events).toEqual(['page:mount']);
314
+ });
315
+
316
+ it('updates ProLayout menu routes after accessible routes change without remounting the layout', async () => {
317
+ proLayoutLifecycle.events = [];
318
+ proLayoutLifecycle.routes = [];
319
+ (window as Window & { __nocobase_modern_client_prefix__?: string }).__nocobase_modern_client_prefix__ = 'v2';
320
+ const layout: LayoutDefinition = {
321
+ routeName: 'admin',
322
+ routePath: '/admin',
323
+ rootRouteName: 'admin',
324
+ uid: 'admin-layout-model',
325
+ layoutModelClass: 'AdminLayoutModel',
326
+ rootPageModelClass: 'RootPageModel',
327
+ childPageModelClass: 'ChildPageModel',
328
+ authCheck: true,
329
+ };
330
+ let accessibleRoutes: NocoBaseDesktopRoute[] = [
331
+ {
332
+ id: 1,
333
+ title: 'Visible page',
334
+ schemaUid: 'visible-page',
335
+ type: NocoBaseDesktopRouteType.flowPage,
336
+ },
337
+ ];
338
+ let routeRepositorySubscriber: (() => void) | undefined;
339
+ const events: string[] = [];
340
+ const engine = new FlowEngine();
341
+ engine.registerModels({
342
+ AdminLayoutMenuItemModel,
343
+ });
344
+ engine.context.defineProperty('routeRepository', {
345
+ value: {
346
+ activateLayout: vi.fn(() => vi.fn()),
347
+ ensureAccessibleLoaded: vi.fn(async () => accessibleRoutes),
348
+ listAccessible: () => accessibleRoutes,
349
+ subscribe: vi.fn((subscriber: () => void) => {
350
+ routeRepositorySubscriber = subscriber;
351
+ }),
352
+ unsubscribe: vi.fn(),
353
+ },
354
+ });
355
+ engine.context.defineProperty('app', {
356
+ value: {
357
+ getPublicPath: () => '/v/',
358
+ router: {
359
+ getBasename: () => '/v',
360
+ },
361
+ },
362
+ });
363
+ engine.context.defineProperty('t', {
364
+ value: (key: string) => key,
365
+ });
366
+ const model = engine.createModel<AdminLayoutModel>({
367
+ uid: layout.uid,
368
+ use: AdminLayoutModel,
369
+ props: {
370
+ layout,
371
+ },
372
+ });
373
+
374
+ const Page = () => {
375
+ useEffect(() => {
376
+ events.push('page:mount');
377
+ return () => {
378
+ events.push('page:unmount');
379
+ };
380
+ }, []);
381
+
382
+ return <div data-testid="custom-admin-route">Workflow tasks</div>;
383
+ };
384
+
385
+ const router = createMemoryRouter(
386
+ [
387
+ {
388
+ id: layout.routeName,
389
+ path: layout.routePath,
390
+ element: <AdminLayoutComponent model={model} />,
391
+ children: [
392
+ {
393
+ id: 'admin.workflow.tasks',
394
+ path: 'workflow/tasks/:taskType?/:status?/:popupId?',
395
+ element: <Page />,
396
+ },
397
+ ],
398
+ },
399
+ ],
400
+ {
401
+ initialEntries: ['/admin/workflow/tasks/approval-apply/pending'],
402
+ },
403
+ );
404
+
405
+ render(
406
+ <FlowEngineProvider engine={engine}>
407
+ <RouterProvider router={router} />
408
+ </FlowEngineProvider>,
409
+ );
410
+
411
+ expect(await screen.findByText('Visible page')).toBeInTheDocument();
412
+ expect(proLayoutLifecycle.events).toEqual(['pro-layout:mount']);
413
+
414
+ act(() => {
415
+ accessibleRoutes = [];
416
+ routeRepositorySubscriber?.();
417
+ });
418
+
419
+ await waitFor(() => {
420
+ expect(screen.queryByText('Visible page')).not.toBeInTheDocument();
421
+ });
422
+
423
+ await act(async () => {
424
+ await router.navigate('/admin/workflow/tasks/approval-apply/pending/1');
425
+ });
426
+
427
+ expect(screen.getByTestId('custom-admin-route')).toBeInTheDocument();
428
+ expect(proLayoutLifecycle.events).toEqual(['pro-layout:mount']);
429
+ expect(events).toEqual(['page:mount']);
430
+ expect(
431
+ proLayoutLifecycle.routes.some((route) => route.children?.some((item) => item.name === 'Visible page')),
432
+ ).toBe(true);
433
+ expect(proLayoutLifecycle.routes.at(-1)?.children?.some((item) => item.name === 'Visible page')).toBe(false);
434
+ });
188
435
  });
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import React, { useMemo, useState } from 'react';
10
+ import React, { useCallback, useMemo, useState } from 'react';
11
11
  import { DatePicker, Select, Space } from 'antd';
12
12
  import { inferPickerType } from '../../flow-compat';
13
13
  import { dayjs, getDateTimeFormat, getPickerFormat } from '@nocobase/utils/client';
@@ -29,6 +29,7 @@ export interface FieldAssignExactDatePickerProps {
29
29
  isRange?: boolean;
30
30
  onChange?: (value: ExactDatePickerValue) => void;
31
31
  style?: React.CSSProperties;
32
+ disabled?: boolean;
32
33
  }
33
34
 
34
35
  function getRawSingleValue(value: unknown, isRange: boolean): unknown {
@@ -114,7 +115,7 @@ function parseRangeValue(value: unknown, format: string): [dayjs.Dayjs, dayjs.Da
114
115
  }
115
116
 
116
117
  export const FieldAssignExactDatePicker: React.FC<FieldAssignExactDatePickerProps> = (props) => {
117
- const { picker = 'date', format, showTime, timeFormat, value, isRange = false, onChange, style } = props;
118
+ const { picker = 'date', format, showTime, timeFormat, value, isRange = false, onChange, style, disabled } = props;
118
119
  const flowCtx = useFlowContext();
119
120
  const t = flowCtx.model.translate.bind(flowCtx.model);
120
121
 
@@ -124,17 +125,17 @@ export const FieldAssignExactDatePicker: React.FC<FieldAssignExactDatePickerProp
124
125
  return inferPickerFromRawValue(rawSingleValue, picker);
125
126
  });
126
127
 
127
- const getResolvedFormat = (nextPicker: ExactDatePickerMode) => {
128
- const baseFormat = nextPicker === picker && format ? format : getPickerFormat(nextPicker);
129
- const dateFormat = nextPicker === 'date' ? stripTimeFromFormat(baseFormat) : baseFormat;
130
- return getDateTimeFormat(nextPicker, dateFormat, showTime, timeFormat);
131
- };
132
-
133
- const resolvedFormat = useMemo(
134
- () => getResolvedFormat(targetPicker),
135
- [targetPicker, format, picker, showTime, timeFormat],
128
+ const getResolvedFormat = useCallback(
129
+ (nextPicker: ExactDatePickerMode) => {
130
+ const baseFormat = nextPicker === picker && format ? format : getPickerFormat(nextPicker);
131
+ const dateFormat = nextPicker === 'date' ? stripTimeFromFormat(baseFormat) : baseFormat;
132
+ return getDateTimeFormat(nextPicker, dateFormat, showTime, timeFormat);
133
+ },
134
+ [format, picker, showTime, timeFormat],
136
135
  );
137
136
 
137
+ const resolvedFormat = useMemo(() => getResolvedFormat(targetPicker), [getResolvedFormat, targetPicker]);
138
+
138
139
  const singleValue = useMemo(() => {
139
140
  if (isRange) return null;
140
141
  return parseDateFromRawValue(value, resolvedFormat);
@@ -156,6 +157,10 @@ export const FieldAssignExactDatePicker: React.FC<FieldAssignExactDatePickerProp
156
157
  );
157
158
 
158
159
  const handlePickerTypeChange = (nextPicker: ExactDatePickerMode) => {
160
+ if (disabled) {
161
+ return;
162
+ }
163
+
159
164
  setTargetPicker(nextPicker);
160
165
 
161
166
  if (!onChange) {
@@ -182,7 +187,11 @@ export const FieldAssignExactDatePicker: React.FC<FieldAssignExactDatePickerProp
182
187
  inputReadOnly: flowCtx.isMobileLayout,
183
188
  showTime: showTime ? { defaultValue: dayjs('00:00:00', 'HH:mm:ss') } : false,
184
189
  value: singleValue,
190
+ disabled,
185
191
  onChange: (nextDate: dayjs.Dayjs | null) => {
192
+ if (disabled) {
193
+ return;
194
+ }
186
195
  if (nextDate && dayjs.isDayjs(nextDate)) {
187
196
  onChange?.(nextDate);
188
197
  return;
@@ -200,7 +209,11 @@ export const FieldAssignExactDatePicker: React.FC<FieldAssignExactDatePickerProp
200
209
  inputReadOnly: flowCtx.isMobileLayout,
201
210
  showTime: showTime ? { defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('23:59:59', 'HH:mm:ss')] } : false,
202
211
  value: rangeValue,
212
+ disabled,
203
213
  onChange: (nextDates: [dayjs.Dayjs | null, dayjs.Dayjs | null] | null) => {
214
+ if (disabled) {
215
+ return;
216
+ }
204
217
  if (Array.isArray(nextDates) && nextDates[0] && nextDates[1]) {
205
218
  onChange?.([nextDates[0], nextDates[1]]);
206
219
  return;
@@ -218,6 +231,7 @@ export const FieldAssignExactDatePicker: React.FC<FieldAssignExactDatePickerProp
218
231
  value={targetPicker}
219
232
  options={pickerOptions}
220
233
  onChange={handlePickerTypeChange}
234
+ disabled={disabled}
221
235
  />
222
236
  {isRange ? <DatePicker.RangePicker {...rangePickerProps} /> : <DatePicker {...singlePickerProps} />}
223
237
  </Space.Compact>
@@ -42,6 +42,12 @@ import { normalizeFilterValueByOperator } from '../models/blocks/filter-form/val
42
42
  import { FieldAssignExactDatePicker, type ExactDatePickerMode } from './FieldAssignExactDatePicker';
43
43
  import { limitAssociationMetaTree } from './filter/metaTreeAssociationDepth';
44
44
 
45
+ type VariableInputConverters = {
46
+ renderInputComponent?: (metaTreeNode: MetaTreeNode | null) => React.ComponentType<any> | null;
47
+ resolvePathFromValue?: (value: any) => string[] | undefined;
48
+ resolveValueFromPath?: (metaTreeNode: MetaTreeNode) => any;
49
+ };
50
+
45
51
  const DATE_FIELD_INTERFACES = new Set(['date', 'datetime', 'datetimeNoTz', 'createdAt', 'updatedAt', 'unixTimestamp']);
46
52
 
47
53
  const TZ_AWARE_DATE_INTERFACES = new Set(['datetime', 'createdAt', 'updatedAt', 'unixTimestamp']);
@@ -341,7 +347,11 @@ interface Props {
341
347
  * 默认 false,保持历史行为。
342
348
  */
343
349
  enableDateVariableAsConstant?: boolean;
350
+ /** 是否允许在变量选择器中使用 RunJS。默认 true,保持历史行为。 */
351
+ allowRunJS?: boolean;
344
352
  maxAssociationFieldDepth?: number;
353
+ disabled?: boolean;
354
+ variableConverters?: VariableInputConverters;
345
355
  }
346
356
 
347
357
  type ResolvedFieldContext = {
@@ -712,7 +722,10 @@ export const FieldAssignValueInput: React.FC<Props> = ({
712
722
  preferFormItemFieldModel,
713
723
  associationFieldNamesOverride,
714
724
  enableDateVariableAsConstant = false,
725
+ allowRunJS = true,
715
726
  maxAssociationFieldDepth = 2,
727
+ disabled = false,
728
+ variableConverters,
716
729
  }) => {
717
730
  const flowCtx = useFlowContext<FlowModelContext>();
718
731
  const normalizeEventValue = React.useCallback((eventOrValue: unknown) => {
@@ -1077,7 +1090,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1077
1090
  fm.setStepParams('selectSettings', 'fieldNames', { label: overrideLabel });
1078
1091
  }
1079
1092
  fm?.setProps?.({
1080
- disabled: false,
1093
+ disabled,
1081
1094
  readPretty: false,
1082
1095
  pattern: 'editable',
1083
1096
  updateAssociation: false,
@@ -1140,6 +1153,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1140
1153
  preferFormItemFieldModel,
1141
1154
  associationFieldNamesOverride?.label,
1142
1155
  associationFieldNamesOverride?.value,
1156
+ disabled,
1143
1157
  ]);
1144
1158
 
1145
1159
  // 当传入 operator / operatorMetaList 时,按 operator schema 适配临时字段的输入组件与 props。
@@ -1192,6 +1206,9 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1192
1206
  React.useEffect(() => {
1193
1207
  const coercedValue = coerceEmptyValueForRenderer(inputProps?.value);
1194
1208
  const handleChange = (ev: any) => {
1209
+ if (inputProps?.disabled) {
1210
+ return;
1211
+ }
1195
1212
  const nextRaw = normalizeEventValue(ev);
1196
1213
  const normalizedForStore = operator ? normalizeFilterValueByOperator(operator, nextRaw) : nextRaw;
1197
1214
  const nextValue = coerceEmptyValueForRenderer(normalizedForStore);
@@ -1223,6 +1240,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1223
1240
  value={inputProps?.value}
1224
1241
  onChange={(e) => inputProps?.onChange?.(normalizeEventValue(e))}
1225
1242
  placeholder={placeholder}
1243
+ disabled={inputProps?.disabled}
1226
1244
  style={withFullWidthStyle(wrapperStyle)}
1227
1245
  />
1228
1246
  );
@@ -1241,6 +1259,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1241
1259
  const C: React.FC<any> = (inputProps) => {
1242
1260
  const wrapperStyle = pickStyle(inputProps?.style);
1243
1261
  const raw = inputProps?.value;
1262
+ const isDisabled = Boolean(inputProps?.disabled);
1244
1263
  const parsed = isCtxDateExpression(raw) ? parseCtxDateExpression(raw) : raw;
1245
1264
  const parsedValue = typeof parsed === 'undefined' ? undefined : parsed;
1246
1265
  const { token } = theme.useToken();
@@ -1265,6 +1284,9 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1265
1284
  });
1266
1285
 
1267
1286
  const handleSelect = (val: string) => {
1287
+ if (isDisabled) {
1288
+ return;
1289
+ }
1268
1290
  setOpen(false);
1269
1291
  if (val === 'exact') {
1270
1292
  inputProps?.onChange?.('');
@@ -1279,10 +1301,16 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1279
1301
  };
1280
1302
 
1281
1303
  const handleExactSingleChange = (nextValue: any) => {
1304
+ if (isDisabled) {
1305
+ return;
1306
+ }
1282
1307
  inputProps?.onChange?.(nextValue || '');
1283
1308
  };
1284
1309
 
1285
1310
  const handleExactRangeChange = (nextValue: any) => {
1311
+ if (isDisabled) {
1312
+ return;
1313
+ }
1286
1314
  inputProps?.onChange?.(nextValue || '');
1287
1315
  };
1288
1316
 
@@ -1327,7 +1355,11 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1327
1355
  <Select
1328
1356
  options={options}
1329
1357
  open={open}
1330
- onDropdownVisibleChange={setOpen}
1358
+ onDropdownVisibleChange={(nextOpen) => {
1359
+ if (!isDisabled) {
1360
+ setOpen(nextOpen);
1361
+ }
1362
+ }}
1331
1363
  allowClear={false}
1332
1364
  style={{
1333
1365
  width: '100%',
@@ -1337,13 +1369,18 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1337
1369
  value={selectedType}
1338
1370
  onChange={handleSelect}
1339
1371
  dropdownRender={dropdownRender}
1372
+ disabled={isDisabled}
1340
1373
  />
1341
1374
  {['past', 'next'].includes(selectedType) && [
1342
1375
  <InputNumber
1343
1376
  key="number"
1344
1377
  style={{ flex: 1 }}
1345
1378
  value={(parsedValue as any)?.number}
1379
+ disabled={isDisabled}
1346
1380
  onChange={(nextNumber) => {
1381
+ if (isDisabled) {
1382
+ return;
1383
+ }
1347
1384
  inputProps?.onChange?.({
1348
1385
  ...(parsedValue as any),
1349
1386
  type: selectedType,
@@ -1356,7 +1393,11 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1356
1393
  key="unit"
1357
1394
  value={(parsedValue as any)?.unit}
1358
1395
  style={{ minWidth: 130, maxWidth: 140 }}
1396
+ disabled={isDisabled}
1359
1397
  onChange={(nextUnit) => {
1398
+ if (isDisabled) {
1399
+ return;
1400
+ }
1360
1401
  inputProps?.onChange?.({
1361
1402
  ...(parsedValue as any),
1362
1403
  type: selectedType,
@@ -1379,6 +1420,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1379
1420
  isRange={isRange}
1380
1421
  value={isRange ? exactRangeValue : exactSingleValue}
1381
1422
  onChange={isRange ? handleExactRangeChange : handleExactSingleChange}
1423
+ disabled={isDisabled}
1382
1424
  style={{ flex: 1 }}
1383
1425
  />
1384
1426
  )}
@@ -1398,7 +1440,12 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1398
1440
 
1399
1441
  const RunJSComponent = React.useMemo(() => {
1400
1442
  const C: React.FC<any> = (inputProps) => (
1401
- <RunJSValueEditor t={flowCtx.t} value={inputProps?.value} onChange={inputProps?.onChange} />
1443
+ <RunJSValueEditor
1444
+ t={flowCtx.t}
1445
+ value={inputProps?.value}
1446
+ onChange={inputProps?.onChange}
1447
+ disabled={inputProps?.disabled}
1448
+ />
1402
1449
  );
1403
1450
  return C;
1404
1451
  }, [flowCtx]);
@@ -1421,11 +1468,13 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1421
1468
  render: ConstantEditor,
1422
1469
  },
1423
1470
  { title: tExpr('Null'), name: 'null', type: 'object', paths: ['null'], render: NullComponent },
1424
- { title: tExpr('RunJS'), name: 'runjs', type: 'object', paths: ['runjs'], render: RunJSComponent },
1471
+ ...(allowRunJS
1472
+ ? [{ title: tExpr('RunJS'), name: 'runjs', type: 'object', paths: ['runjs'], render: RunJSComponent }]
1473
+ : []),
1425
1474
  ...limitedBase,
1426
1475
  ];
1427
1476
  };
1428
- }, [flowCtx, ConstantEditor, NullComponent, RunJSComponent, maxAssociationFieldDepth]);
1477
+ }, [flowCtx, ConstantEditor, NullComponent, RunJSComponent, allowRunJS, maxAssociationFieldDepth]);
1429
1478
 
1430
1479
  const displayValue = React.useMemo(() => {
1431
1480
  if (!useDateVariableConstant) {
@@ -1442,6 +1491,10 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1442
1491
 
1443
1492
  const handleVariableInputChange = React.useCallback(
1444
1493
  (nextValue: any) => {
1494
+ if (disabled) {
1495
+ return;
1496
+ }
1497
+
1445
1498
  if (!useDateVariableConstant) {
1446
1499
  onChange(nextValue);
1447
1500
  return;
@@ -1449,7 +1502,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1449
1502
 
1450
1503
  onChange(normalizeDateVariableOutput(nextValue, dateVariableComponentProps));
1451
1504
  },
1452
- [dateVariableComponentProps, onChange, useDateVariableConstant],
1505
+ [dateVariableComponentProps, disabled, onChange, useDateVariableConstant],
1453
1506
  );
1454
1507
 
1455
1508
  if (!fieldPath) {
@@ -1464,26 +1517,40 @@ export const FieldAssignValueInput: React.FC<Props> = ({
1464
1517
  metaTree={metaTree}
1465
1518
  style={{ width: '100%' }}
1466
1519
  clearValue={''}
1520
+ disabled={disabled}
1467
1521
  converters={{
1522
+ ...variableConverters,
1468
1523
  renderInputComponent: (meta) => {
1524
+ const external = variableConverters?.renderInputComponent?.(meta ?? null);
1525
+ if (external) {
1526
+ return external;
1527
+ }
1469
1528
  const firstPath = meta?.paths?.[0];
1470
1529
  if (firstPath === 'constant') return ConstantEditor;
1471
1530
  if (firstPath === 'null') return NullComponent;
1472
- if (firstPath === 'runjs') return RunJSComponent;
1531
+ if (allowRunJS && firstPath === 'runjs') return RunJSComponent;
1473
1532
  return null;
1474
1533
  },
1475
1534
  resolveValueFromPath: (item) => {
1535
+ const external = variableConverters?.resolveValueFromPath?.(item);
1536
+ if (external !== undefined) {
1537
+ return external;
1538
+ }
1476
1539
  const firstPath = item?.paths?.[0];
1477
1540
  if (firstPath === 'constant') {
1478
1541
  return useDateVariableConstant ? { type: 'today' } : '';
1479
1542
  }
1480
1543
  if (firstPath === 'null') return null;
1481
- if (firstPath === 'runjs') return { code: '', version: 'v2' };
1544
+ if (allowRunJS && firstPath === 'runjs') return { code: '', version: 'v2' };
1482
1545
  return undefined;
1483
1546
  },
1484
1547
  resolvePathFromValue: (currentValue) => {
1548
+ const external = variableConverters?.resolvePathFromValue?.(currentValue);
1549
+ if (external !== undefined) {
1550
+ return external;
1551
+ }
1485
1552
  if (currentValue === null) return ['null'];
1486
- if (isRunJSValue(currentValue)) return ['runjs'];
1553
+ if (allowRunJS && isRunJSValue(currentValue)) return ['runjs'];
1487
1554
  if (useDateVariableConstant && isCtxDateExpression(currentValue)) {
1488
1555
  return ['constant'];
1489
1556
  }
@@ -15,6 +15,7 @@ export interface RunJSValueEditorProps {
15
15
  t?: (key: string) => string;
16
16
  value?: unknown;
17
17
  onChange?: (value: RunJSValue) => void;
18
+ disabled?: boolean;
18
19
  height?: string;
19
20
  scene?: string;
20
21
  containerStyle?: React.CSSProperties;
@@ -25,6 +26,7 @@ export const RunJSValueEditor: React.FC<RunJSValueEditorProps> = (props) => {
25
26
  t,
26
27
  value,
27
28
  onChange,
29
+ disabled,
28
30
  height = '200px',
29
31
  scene = 'formValue',
30
32
  containerStyle = { flex: 1, minWidth: 0 },
@@ -38,9 +40,15 @@ export const RunJSValueEditor: React.FC<RunJSValueEditorProps> = (props) => {
38
40
  <div style={containerStyle}>
39
41
  <CodeEditor
40
42
  value={current.code}
41
- onChange={(code) => onChange?.({ ...current, code })}
43
+ onChange={(code) => {
44
+ if (disabled) {
45
+ return;
46
+ }
47
+ onChange?.({ ...current, code });
48
+ }}
42
49
  version={current.version}
43
50
  height={height}
51
+ readonly={disabled}
44
52
  enableLinter
45
53
  placeholder={placeholderText}
46
54
  scene={scene}