@nocobase/client-v2 2.2.0-beta.8 → 2.3.0-alpha.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.
- package/es/APIClient.d.ts +1 -3
- package/es/BaseApplication.d.ts +3 -0
- package/es/RouteRepository.d.ts +8 -0
- package/es/RouterManager.d.ts +15 -0
- package/es/authRedirect.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +1 -0
- package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
- package/es/components/category-tabs/index.d.ts +9 -0
- package/es/components/form/ScanInput/useCodeScanner.d.ts +2 -1
- package/es/components/form/TypedVariableInput.d.ts +31 -5
- package/es/components/form/filter/CollectionFilter.d.ts +2 -0
- package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
- package/es/components/form/filter/CollectionFilterPanel.d.ts +2 -0
- package/es/components/form/filter/index.d.ts +2 -0
- package/es/components/form/filter/useFilterActionProps.d.ts +2 -0
- package/es/components/index.d.ts +1 -0
- package/es/entry-actions/EntryActionManager.d.ts +24 -0
- package/es/entry-actions/index.d.ts +9 -0
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/actions/linkageRules.d.ts +2 -0
- package/es/flow/admin-shell/BaseLayoutModel.d.ts +6 -0
- package/es/flow/admin-shell/BaseLayoutRouteCoordinator.d.ts +7 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/AppListRender.d.ts +2 -1
- package/es/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.d.ts +24 -0
- package/es/flow/admin-shell/admin-layout/index.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/useApplications.d.ts +7 -2
- package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
- package/es/flow/components/FieldAssignValueInput.d.ts +9 -0
- package/es/flow/components/RunJSValueEditor.d.ts +1 -0
- package/es/flow/components/filter/FilterGroup.d.ts +1 -0
- package/es/flow/components/filter/VariableFilterItem.d.ts +6 -1
- package/es/flow/index.d.ts +1 -0
- package/es/flow/models/base/ActionModelCore.d.ts +2 -0
- package/es/flow/models/base/PageModel/PageModel.d.ts +12 -0
- package/es/flow/models/base/PageModel/PageModelTabBar.d.ts +22 -0
- package/es/flow/models/base/PageModel/PageTabModel.d.ts +12 -0
- package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +17 -2
- package/es/flow/routeTransientInputArgs.d.ts +14 -0
- package/es/flow-compat/fieldValidationConstants.d.ts +1 -1
- package/es/flow-compat/routeTypes.d.ts +1 -0
- package/es/index.d.ts +6 -0
- package/es/index.mjs +279 -158
- package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/markdownSanitize.d.ts +11 -0
- package/lib/index.js +280 -159
- package/lib/locale/languageCodes.js +2 -1
- package/package.json +8 -7
- package/src/APIClient.ts +1 -10
- package/src/Application.tsx +4 -0
- package/src/BaseApplication.tsx +13 -6
- package/src/RouteRepository.ts +25 -0
- package/src/RouterManager.tsx +142 -1
- package/src/__tests__/RouteRepository.test.ts +23 -0
- package/src/__tests__/RouterManager.test.ts +125 -0
- package/src/__tests__/app.test.tsx +73 -0
- package/src/__tests__/authRedirect.test.ts +17 -0
- package/src/__tests__/browserChecker.test.ts +61 -0
- package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +28 -0
- package/src/authRedirect.ts +38 -0
- package/src/collection-field-interface/CollectionFieldInterface.ts +1 -0
- package/src/collection-field-interface/CollectionFieldInterfaceManager.ts +1 -0
- package/src/collection-manager/field-validation.ts +1 -1
- package/src/components/README.md +7 -1
- package/src/components/README.zh-CN.md +6 -1
- package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
- package/src/components/category-tabs/index.ts +10 -0
- package/src/components/form/JsonTextArea.tsx +4 -0
- package/src/components/form/ScanInput/CodeScanner.tsx +23 -6
- package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +180 -3
- package/src/components/form/ScanInput/useCodeScanner.ts +170 -5
- package/src/components/form/TypedVariableInput.tsx +452 -101
- package/src/components/form/__tests__/TypedVariableInput.test.tsx +364 -12
- package/src/components/form/filter/CollectionFilter.tsx +4 -0
- package/src/components/form/filter/CollectionFilterItem.tsx +32 -7
- package/src/components/form/filter/CollectionFilterPanel.tsx +4 -0
- package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +38 -0
- package/src/components/form/filter/__tests__/useFilterActionProps.test.tsx +95 -0
- package/src/components/form/filter/index.ts +2 -0
- package/src/components/form/filter/useFilterActionProps.ts +37 -6
- package/src/components/index.ts +1 -0
- package/src/entry-actions/EntryActionManager.ts +76 -0
- package/src/entry-actions/index.ts +10 -0
- package/src/flow/FlowPage.tsx +38 -3
- package/src/flow/__tests__/FlowPage.test.tsx +201 -27
- package/src/flow/__tests__/FlowRoute.test.tsx +549 -4
- package/src/flow/actions/__tests__/dataScopeFilter.test.ts +62 -0
- package/src/flow/actions/__tests__/linkageRules.tab.test.ts +171 -0
- package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +7 -3
- package/src/flow/actions/__tests__/openView.defineProps.route.test.tsx +80 -20
- package/src/flow/actions/dataScopeFilter.ts +10 -1
- package/src/flow/actions/dateTimeFormat.tsx +2 -2
- package/src/flow/actions/index.ts +2 -0
- package/src/flow/actions/linkageRules.tsx +86 -11
- package/src/flow/actions/linkageRulesRefresh.tsx +2 -6
- package/src/flow/actions/openView.tsx +21 -1
- package/src/flow/admin-shell/BaseLayoutModel.tsx +124 -0
- package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +184 -42
- package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +1016 -119
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +41 -5
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.test.tsx +177 -1
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +20 -0
- package/src/flow/admin-shell/admin-layout/AppListRender.tsx +13 -2
- package/src/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.tsx +289 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +436 -2
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +48 -0
- package/src/flow/admin-shell/admin-layout/index.ts +1 -0
- package/src/flow/admin-shell/admin-layout/useApplications.tsx +81 -12
- package/src/flow/common/Markdown/Display.tsx +14 -3
- package/src/flow/common/Markdown/Edit.tsx +19 -7
- package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
- package/src/flow/components/FieldAssignValueInput.tsx +91 -20
- package/src/flow/components/FlowRoute.tsx +134 -18
- package/src/flow/components/RunJSValueEditor.tsx +9 -1
- package/src/flow/components/__tests__/FieldAssignValueInput.context.test.tsx +216 -0
- package/src/flow/components/filter/FilterGroup.tsx +33 -5
- package/src/flow/components/filter/VariableFilterItem.tsx +158 -10
- package/src/flow/components/filter/__tests__/FilterGroup.test.tsx +45 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.leftMetaTree.test.tsx +9 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +70 -1
- package/src/flow/index.ts +1 -0
- package/src/flow/internal/components/Markdown/util.ts +2 -1
- package/src/flow/models/base/ActionModel.tsx +10 -8
- package/src/flow/models/base/ActionModelCore.tsx +5 -0
- package/src/flow/models/base/PageModel/PageModel.tsx +387 -53
- package/src/flow/models/base/PageModel/PageModelTabBar.tsx +114 -0
- package/src/flow/models/base/PageModel/PageTabModel.tsx +184 -3
- package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +790 -10
- package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.module-isolation.test.tsx +130 -0
- package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.test.tsx +118 -0
- package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +572 -1
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +1 -0
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +27 -12
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +36 -0
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +34 -0
- package/src/flow/models/blocks/form/QuickEditFormModel.tsx +189 -36
- package/src/flow/models/blocks/form/__tests__/QuickEditFormModel.quickEdit.test.ts +350 -2
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +2 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +1 -1
- package/src/flow/models/blocks/table/TableColumnModel.tsx +6 -2
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +51 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +2 -1
- package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +45 -13
- package/src/flow/models/fields/TextareaFieldModel.tsx +42 -19
- package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
- package/src/flow/models/fields/__tests__/TextareaFieldModel.test.tsx +32 -1
- package/src/flow/models/fields/__tests__/VariableFieldFormModel.test.tsx +51 -0
- package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +20 -10
- package/src/flow/models/fields/mobile-components/MobileSelect.tsx +24 -12
- package/src/flow/models/topbar/TopbarActionModel.tsx +78 -3
- package/src/flow/routeTransientInputArgs.ts +27 -0
- package/src/flow/utils/__tests__/dateTimeFormat.test.ts +42 -0
- package/src/flow-compat/fieldValidationConstants.ts +1 -1
- package/src/flow-compat/routeTypes.ts +1 -0
- package/src/index.ts +6 -0
- package/src/locale/languageCodes.ts +2 -1
- package/src/nocobase-buildin-plugin/index.tsx +19 -1
- package/src/utils/getRouteRuntimeVersion.ts +185 -0
- package/src/utils/index.tsx +1 -0
- package/src/utils/markdownSanitize.ts +88 -0
|
@@ -12,6 +12,7 @@ import { css } from '@emotion/css';
|
|
|
12
12
|
import { createRoot } from 'react-dom/client';
|
|
13
13
|
import React, { CSSProperties, useCallback, useEffect, useRef, useState } from 'react';
|
|
14
14
|
import Vditor from 'vditor';
|
|
15
|
+
import { removeMarkdownIframes, stripMarkdownIframes } from '../../../utils/markdownSanitize';
|
|
15
16
|
import { useCDN } from './useCDN';
|
|
16
17
|
import useStyle from './style';
|
|
17
18
|
|
|
@@ -51,8 +52,15 @@ function DisplayInner(props: { value: string; style?: CSSProperties; loadImages?
|
|
|
51
52
|
Vditor.preview(containerRef.current, props.value ?? '', {
|
|
52
53
|
mode: 'light',
|
|
53
54
|
cdn,
|
|
54
|
-
|
|
55
|
+
markdown: {
|
|
56
|
+
sanitize: true,
|
|
57
|
+
},
|
|
58
|
+
transform: stripMarkdownIframes,
|
|
59
|
+
})
|
|
60
|
+
.then(() => removeMarkdownIframes(containerRef.current))
|
|
61
|
+
.catch(() => removeMarkdownIframes(containerRef.current));
|
|
55
62
|
setTimeout(() => {
|
|
63
|
+
removeMarkdownIframes(containerRef.current);
|
|
56
64
|
containerRef.current?.querySelectorAll('img').forEach((img: HTMLImageElement) => {
|
|
57
65
|
img.style.cursor = 'zoom-in';
|
|
58
66
|
img.addEventListener('click', () => {
|
|
@@ -129,13 +137,16 @@ export const Display = (props) => {
|
|
|
129
137
|
Vditor.md2html(props.value, {
|
|
130
138
|
mode: 'light',
|
|
131
139
|
cdn,
|
|
140
|
+
markdown: {
|
|
141
|
+
sanitize: true,
|
|
142
|
+
},
|
|
132
143
|
})
|
|
133
144
|
.then((html) => {
|
|
134
|
-
setText(convertToText(html));
|
|
145
|
+
setText(convertToText(stripMarkdownIframes(html)));
|
|
135
146
|
})
|
|
136
147
|
.catch(() => setText(''));
|
|
137
148
|
}
|
|
138
|
-
}, [props.value, textOnly]);
|
|
149
|
+
}, [props.value, textOnly, cdn]);
|
|
139
150
|
|
|
140
151
|
const isOverflowTooltip = useCallback(() => {
|
|
141
152
|
if (!elRef.current) return false;
|
|
@@ -17,6 +17,7 @@ import React, { useEffect, useCallback, useLayoutEffect, useMemo, useRef, useSta
|
|
|
17
17
|
import { useTranslation } from 'react-i18next';
|
|
18
18
|
import Vditor from 'vditor';
|
|
19
19
|
import 'vditor/dist/index.css';
|
|
20
|
+
import { stripMarkdownIframeTags, stripMarkdownIframes } from '../../../utils/markdownSanitize';
|
|
20
21
|
import { useCDN } from './useCDN';
|
|
21
22
|
import useStyle from './style';
|
|
22
23
|
|
|
@@ -102,13 +103,20 @@ const Edit = (props) => {
|
|
|
102
103
|
if (!containerRef.current) return;
|
|
103
104
|
|
|
104
105
|
const toolbarConfig = placeToolbarTooltipsBelow(toolbar ?? defaultToolbar);
|
|
106
|
+
const safeValue = stripMarkdownIframeTags(value ?? '');
|
|
105
107
|
const vditor = new Vditor(containerRef.current, {
|
|
106
|
-
value:
|
|
108
|
+
value: safeValue,
|
|
107
109
|
lang,
|
|
108
110
|
cache: { enable: false },
|
|
109
111
|
undoDelay: 0,
|
|
110
112
|
mode: props.mode || 'ir',
|
|
111
|
-
preview: {
|
|
113
|
+
preview: {
|
|
114
|
+
markdown: {
|
|
115
|
+
sanitize: true,
|
|
116
|
+
},
|
|
117
|
+
math: { engine: 'KaTeX' },
|
|
118
|
+
transform: stripMarkdownIframes,
|
|
119
|
+
},
|
|
112
120
|
toolbar: toolbarConfig,
|
|
113
121
|
fullscreen: { index: 1200 },
|
|
114
122
|
cdn,
|
|
@@ -117,7 +125,6 @@ const Edit = (props) => {
|
|
|
117
125
|
after: () => {
|
|
118
126
|
vdRef.current = vditor;
|
|
119
127
|
setEditorReady(true); // Notify that the editor is ready
|
|
120
|
-
vditor.setValue(value ?? '');
|
|
121
128
|
if (disabled) {
|
|
122
129
|
vditor.disabled();
|
|
123
130
|
} else {
|
|
@@ -131,8 +138,12 @@ const Edit = (props) => {
|
|
|
131
138
|
});
|
|
132
139
|
}
|
|
133
140
|
},
|
|
134
|
-
input(
|
|
135
|
-
|
|
141
|
+
input(nextValue) {
|
|
142
|
+
const safeNextValue = stripMarkdownIframeTags(nextValue);
|
|
143
|
+
if (safeNextValue !== nextValue) {
|
|
144
|
+
vditor.setValue(safeNextValue);
|
|
145
|
+
}
|
|
146
|
+
onChange(safeNextValue);
|
|
136
147
|
},
|
|
137
148
|
upload: {
|
|
138
149
|
multiple: false,
|
|
@@ -229,8 +240,9 @@ const Edit = (props) => {
|
|
|
229
240
|
useEffect(() => {
|
|
230
241
|
if (editorReady && vdRef.current) {
|
|
231
242
|
const editor = vdRef.current;
|
|
232
|
-
|
|
233
|
-
|
|
243
|
+
const safeValue = stripMarkdownIframeTags(value ?? '');
|
|
244
|
+
if (safeValue !== editor.getValue()) {
|
|
245
|
+
editor.setValue(safeValue);
|
|
234
246
|
|
|
235
247
|
const preArea = containerRef.current?.querySelector(
|
|
236
248
|
'div.vditor-content > div.vditor-ir > pre',
|
|
@@ -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 = (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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) => {
|
|
@@ -1028,18 +1041,22 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1028
1041
|
collectionField: effectiveCollectionField,
|
|
1029
1042
|
});
|
|
1030
1043
|
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1044
|
+
const sourceContext = resolved?.itemModel?.context || flowCtx.model?.context;
|
|
1045
|
+
const created = engine?.createModel?.(
|
|
1046
|
+
{
|
|
1047
|
+
use: 'VariableFieldFormModel',
|
|
1048
|
+
subModels: {
|
|
1049
|
+
fields: [
|
|
1050
|
+
{
|
|
1051
|
+
use: effectiveFieldModelUse,
|
|
1052
|
+
stepParams: tempFieldStepParams,
|
|
1053
|
+
props: tempFieldProps,
|
|
1054
|
+
},
|
|
1055
|
+
],
|
|
1056
|
+
},
|
|
1041
1057
|
},
|
|
1042
|
-
|
|
1058
|
+
sourceContext ? { delegate: sourceContext } : undefined,
|
|
1059
|
+
);
|
|
1043
1060
|
if (!created) return;
|
|
1044
1061
|
|
|
1045
1062
|
// 注入上下文(集合/数据源/字段/区块/资源)
|
|
@@ -1073,7 +1090,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1073
1090
|
fm.setStepParams('selectSettings', 'fieldNames', { label: overrideLabel });
|
|
1074
1091
|
}
|
|
1075
1092
|
fm?.setProps?.({
|
|
1076
|
-
disabled
|
|
1093
|
+
disabled,
|
|
1077
1094
|
readPretty: false,
|
|
1078
1095
|
pattern: 'editable',
|
|
1079
1096
|
updateAssociation: false,
|
|
@@ -1136,6 +1153,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1136
1153
|
preferFormItemFieldModel,
|
|
1137
1154
|
associationFieldNamesOverride?.label,
|
|
1138
1155
|
associationFieldNamesOverride?.value,
|
|
1156
|
+
disabled,
|
|
1139
1157
|
]);
|
|
1140
1158
|
|
|
1141
1159
|
// 当传入 operator / operatorMetaList 时,按 operator schema 适配临时字段的输入组件与 props。
|
|
@@ -1188,6 +1206,9 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1188
1206
|
React.useEffect(() => {
|
|
1189
1207
|
const coercedValue = coerceEmptyValueForRenderer(inputProps?.value);
|
|
1190
1208
|
const handleChange = (ev: any) => {
|
|
1209
|
+
if (inputProps?.disabled) {
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1191
1212
|
const nextRaw = normalizeEventValue(ev);
|
|
1192
1213
|
const normalizedForStore = operator ? normalizeFilterValueByOperator(operator, nextRaw) : nextRaw;
|
|
1193
1214
|
const nextValue = coerceEmptyValueForRenderer(normalizedForStore);
|
|
@@ -1219,6 +1240,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1219
1240
|
value={inputProps?.value}
|
|
1220
1241
|
onChange={(e) => inputProps?.onChange?.(normalizeEventValue(e))}
|
|
1221
1242
|
placeholder={placeholder}
|
|
1243
|
+
disabled={inputProps?.disabled}
|
|
1222
1244
|
style={withFullWidthStyle(wrapperStyle)}
|
|
1223
1245
|
/>
|
|
1224
1246
|
);
|
|
@@ -1237,6 +1259,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1237
1259
|
const C: React.FC<any> = (inputProps) => {
|
|
1238
1260
|
const wrapperStyle = pickStyle(inputProps?.style);
|
|
1239
1261
|
const raw = inputProps?.value;
|
|
1262
|
+
const isDisabled = Boolean(inputProps?.disabled);
|
|
1240
1263
|
const parsed = isCtxDateExpression(raw) ? parseCtxDateExpression(raw) : raw;
|
|
1241
1264
|
const parsedValue = typeof parsed === 'undefined' ? undefined : parsed;
|
|
1242
1265
|
const { token } = theme.useToken();
|
|
@@ -1261,6 +1284,9 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1261
1284
|
});
|
|
1262
1285
|
|
|
1263
1286
|
const handleSelect = (val: string) => {
|
|
1287
|
+
if (isDisabled) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1264
1290
|
setOpen(false);
|
|
1265
1291
|
if (val === 'exact') {
|
|
1266
1292
|
inputProps?.onChange?.('');
|
|
@@ -1275,10 +1301,16 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1275
1301
|
};
|
|
1276
1302
|
|
|
1277
1303
|
const handleExactSingleChange = (nextValue: any) => {
|
|
1304
|
+
if (isDisabled) {
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1278
1307
|
inputProps?.onChange?.(nextValue || '');
|
|
1279
1308
|
};
|
|
1280
1309
|
|
|
1281
1310
|
const handleExactRangeChange = (nextValue: any) => {
|
|
1311
|
+
if (isDisabled) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1282
1314
|
inputProps?.onChange?.(nextValue || '');
|
|
1283
1315
|
};
|
|
1284
1316
|
|
|
@@ -1323,7 +1355,11 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1323
1355
|
<Select
|
|
1324
1356
|
options={options}
|
|
1325
1357
|
open={open}
|
|
1326
|
-
onDropdownVisibleChange={
|
|
1358
|
+
onDropdownVisibleChange={(nextOpen) => {
|
|
1359
|
+
if (!isDisabled) {
|
|
1360
|
+
setOpen(nextOpen);
|
|
1361
|
+
}
|
|
1362
|
+
}}
|
|
1327
1363
|
allowClear={false}
|
|
1328
1364
|
style={{
|
|
1329
1365
|
width: '100%',
|
|
@@ -1333,13 +1369,18 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1333
1369
|
value={selectedType}
|
|
1334
1370
|
onChange={handleSelect}
|
|
1335
1371
|
dropdownRender={dropdownRender}
|
|
1372
|
+
disabled={isDisabled}
|
|
1336
1373
|
/>
|
|
1337
1374
|
{['past', 'next'].includes(selectedType) && [
|
|
1338
1375
|
<InputNumber
|
|
1339
1376
|
key="number"
|
|
1340
1377
|
style={{ flex: 1 }}
|
|
1341
1378
|
value={(parsedValue as any)?.number}
|
|
1379
|
+
disabled={isDisabled}
|
|
1342
1380
|
onChange={(nextNumber) => {
|
|
1381
|
+
if (isDisabled) {
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1343
1384
|
inputProps?.onChange?.({
|
|
1344
1385
|
...(parsedValue as any),
|
|
1345
1386
|
type: selectedType,
|
|
@@ -1352,7 +1393,11 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1352
1393
|
key="unit"
|
|
1353
1394
|
value={(parsedValue as any)?.unit}
|
|
1354
1395
|
style={{ minWidth: 130, maxWidth: 140 }}
|
|
1396
|
+
disabled={isDisabled}
|
|
1355
1397
|
onChange={(nextUnit) => {
|
|
1398
|
+
if (isDisabled) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1356
1401
|
inputProps?.onChange?.({
|
|
1357
1402
|
...(parsedValue as any),
|
|
1358
1403
|
type: selectedType,
|
|
@@ -1375,6 +1420,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1375
1420
|
isRange={isRange}
|
|
1376
1421
|
value={isRange ? exactRangeValue : exactSingleValue}
|
|
1377
1422
|
onChange={isRange ? handleExactRangeChange : handleExactSingleChange}
|
|
1423
|
+
disabled={isDisabled}
|
|
1378
1424
|
style={{ flex: 1 }}
|
|
1379
1425
|
/>
|
|
1380
1426
|
)}
|
|
@@ -1394,7 +1440,12 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1394
1440
|
|
|
1395
1441
|
const RunJSComponent = React.useMemo(() => {
|
|
1396
1442
|
const C: React.FC<any> = (inputProps) => (
|
|
1397
|
-
<RunJSValueEditor
|
|
1443
|
+
<RunJSValueEditor
|
|
1444
|
+
t={flowCtx.t}
|
|
1445
|
+
value={inputProps?.value}
|
|
1446
|
+
onChange={inputProps?.onChange}
|
|
1447
|
+
disabled={inputProps?.disabled}
|
|
1448
|
+
/>
|
|
1398
1449
|
);
|
|
1399
1450
|
return C;
|
|
1400
1451
|
}, [flowCtx]);
|
|
@@ -1417,11 +1468,13 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1417
1468
|
render: ConstantEditor,
|
|
1418
1469
|
},
|
|
1419
1470
|
{ title: tExpr('Null'), name: 'null', type: 'object', paths: ['null'], render: NullComponent },
|
|
1420
|
-
|
|
1471
|
+
...(allowRunJS
|
|
1472
|
+
? [{ title: tExpr('RunJS'), name: 'runjs', type: 'object', paths: ['runjs'], render: RunJSComponent }]
|
|
1473
|
+
: []),
|
|
1421
1474
|
...limitedBase,
|
|
1422
1475
|
];
|
|
1423
1476
|
};
|
|
1424
|
-
}, [flowCtx, ConstantEditor, NullComponent, RunJSComponent, maxAssociationFieldDepth]);
|
|
1477
|
+
}, [flowCtx, ConstantEditor, NullComponent, RunJSComponent, allowRunJS, maxAssociationFieldDepth]);
|
|
1425
1478
|
|
|
1426
1479
|
const displayValue = React.useMemo(() => {
|
|
1427
1480
|
if (!useDateVariableConstant) {
|
|
@@ -1438,6 +1491,10 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1438
1491
|
|
|
1439
1492
|
const handleVariableInputChange = React.useCallback(
|
|
1440
1493
|
(nextValue: any) => {
|
|
1494
|
+
if (disabled) {
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1441
1498
|
if (!useDateVariableConstant) {
|
|
1442
1499
|
onChange(nextValue);
|
|
1443
1500
|
return;
|
|
@@ -1445,7 +1502,7 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1445
1502
|
|
|
1446
1503
|
onChange(normalizeDateVariableOutput(nextValue, dateVariableComponentProps));
|
|
1447
1504
|
},
|
|
1448
|
-
[dateVariableComponentProps, onChange, useDateVariableConstant],
|
|
1505
|
+
[dateVariableComponentProps, disabled, onChange, useDateVariableConstant],
|
|
1449
1506
|
);
|
|
1450
1507
|
|
|
1451
1508
|
if (!fieldPath) {
|
|
@@ -1460,26 +1517,40 @@ export const FieldAssignValueInput: React.FC<Props> = ({
|
|
|
1460
1517
|
metaTree={metaTree}
|
|
1461
1518
|
style={{ width: '100%' }}
|
|
1462
1519
|
clearValue={''}
|
|
1520
|
+
disabled={disabled}
|
|
1463
1521
|
converters={{
|
|
1522
|
+
...variableConverters,
|
|
1464
1523
|
renderInputComponent: (meta) => {
|
|
1524
|
+
const external = variableConverters?.renderInputComponent?.(meta ?? null);
|
|
1525
|
+
if (external) {
|
|
1526
|
+
return external;
|
|
1527
|
+
}
|
|
1465
1528
|
const firstPath = meta?.paths?.[0];
|
|
1466
1529
|
if (firstPath === 'constant') return ConstantEditor;
|
|
1467
1530
|
if (firstPath === 'null') return NullComponent;
|
|
1468
|
-
if (firstPath === 'runjs') return RunJSComponent;
|
|
1531
|
+
if (allowRunJS && firstPath === 'runjs') return RunJSComponent;
|
|
1469
1532
|
return null;
|
|
1470
1533
|
},
|
|
1471
1534
|
resolveValueFromPath: (item) => {
|
|
1535
|
+
const external = variableConverters?.resolveValueFromPath?.(item);
|
|
1536
|
+
if (external !== undefined) {
|
|
1537
|
+
return external;
|
|
1538
|
+
}
|
|
1472
1539
|
const firstPath = item?.paths?.[0];
|
|
1473
1540
|
if (firstPath === 'constant') {
|
|
1474
1541
|
return useDateVariableConstant ? { type: 'today' } : '';
|
|
1475
1542
|
}
|
|
1476
1543
|
if (firstPath === 'null') return null;
|
|
1477
|
-
if (firstPath === 'runjs') return { code: '', version: 'v2' };
|
|
1544
|
+
if (allowRunJS && firstPath === 'runjs') return { code: '', version: 'v2' };
|
|
1478
1545
|
return undefined;
|
|
1479
1546
|
},
|
|
1480
1547
|
resolvePathFromValue: (currentValue) => {
|
|
1548
|
+
const external = variableConverters?.resolvePathFromValue?.(currentValue);
|
|
1549
|
+
if (external !== undefined) {
|
|
1550
|
+
return external;
|
|
1551
|
+
}
|
|
1481
1552
|
if (currentValue === null) return ['null'];
|
|
1482
|
-
if (isRunJSValue(currentValue)) return ['runjs'];
|
|
1553
|
+
if (allowRunJS && isRunJSValue(currentValue)) return ['runjs'];
|
|
1483
1554
|
if (useDateVariableConstant && isCtxDateExpression(currentValue)) {
|
|
1484
1555
|
return ['constant'];
|
|
1485
1556
|
}
|