@nocobase/client-v2 2.2.0-beta.9 → 3.0.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 +1 -0
- package/es/acl/ACLProvider.d.ts +10 -0
- package/es/authRedirect.d.ts +5 -0
- package/es/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +1 -0
- package/es/components/AttachmentUpload.d.ts +51 -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 +3 -2
- 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 +2 -0
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/actions/linkageRules.d.ts +3 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/NocoBaseLogo.d.ts +10 -0
- package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
- package/es/flow/components/FieldAssignValueInput.d.ts +9 -0
- package/es/flow/components/FlowRoute.d.ts +2 -2
- 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/internal/registerDeviceTypeContext.d.ts +10 -0
- package/es/flow/models/base/ActionModelCore.d.ts +4 -2
- package/es/flow/models/base/BlockGridModel.d.ts +3 -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/models/blocks/table/TableColumnModel.d.ts +1 -0
- package/es/flow/models/fields/DateTimeFieldModel/dateLimit.d.ts +15 -7
- package/es/flow-compat/fieldValidationConstants.d.ts +1 -1
- package/es/flow-compat/routeTypes.d.ts +1 -0
- package/es/index.d.ts +8 -1
- package/es/index.mjs +190 -141
- package/es/nocobase-buildin-plugin/currentUserAuthStatus.d.ts +11 -0
- package/es/nocobase-buildin-plugin/index.d.ts +9 -0
- package/es/settings-app/SettingsApplication.d.ts +18 -0
- package/es/settings-app/SettingsBrand.d.ts +16 -0
- package/es/settings-app/SettingsBuildInPlugin.d.ts +9 -0
- package/es/settings-app/SettingsDocumentRedirect.d.ts +10 -0
- package/es/settings-app/SettingsGroupNav.d.ts +17 -0
- package/es/settings-app/SettingsPluginSettingsManager.d.ts +14 -0
- package/es/settings-app/SettingsRouterManager.d.ts +15 -0
- package/es/settings-app/SettingsSearch.d.ts +17 -0
- package/es/settings-app/SettingsShell.d.ts +10 -0
- package/es/settings-app/isSettingsApp.d.ts +18 -0
- package/es/settings-app/runtimePaths.d.ts +18 -0
- package/es/settings-app/settingsDocumentPath.d.ts +14 -0
- package/es/settings-app/settingsTheme.d.ts +87 -0
- package/es/settings-app/useSettingsThemeConfig.d.ts +22 -0
- package/es/settings-center/AdminSettingsLayout.d.ts +2 -2
- package/es/settings-center/groups.d.ts +66 -0
- package/es/settings-center/useSettingsGroups.d.ts +36 -0
- package/es/settings-center/useSettingsSearch.d.ts +35 -0
- package/es/settings-center/utils.d.ts +24 -0
- package/es/theme/index.d.ts +1 -0
- package/es/theme/itemActive.d.ts +24 -0
- package/es/theme/type.d.ts +9 -0
- package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
- package/es/utils/index.d.ts +1 -0
- package/lib/index.js +195 -146
- package/lib/locale/languageCodes.js +3 -1
- package/package.json +9 -7
- package/src/APIClient.ts +1 -10
- package/src/Application.tsx +4 -0
- package/src/BaseApplication.tsx +11 -6
- package/src/__tests__/app.test.tsx +73 -0
- package/src/__tests__/authRedirect.test.ts +137 -0
- package/src/__tests__/browserChecker.test.ts +185 -6
- package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
- package/src/__tests__/mockSettingsApplication.ts +29 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +79 -10
- package/src/__tests__/plugin-manager.test.tsx +7 -6
- package/src/__tests__/settings-application.test.ts +164 -0
- package/src/__tests__/settings-auth-routes.test.ts +71 -0
- package/src/__tests__/settings-center.test.tsx +38 -37
- package/src/__tests__/settings-layout-root.test.tsx +260 -0
- package/src/__tests__/settings-runtime-paths.test.ts +99 -0
- package/src/__tests__/settings-shell.test.tsx +200 -0
- package/src/acl/ACLProvider.tsx +21 -0
- package/src/authRedirect.ts +72 -3
- 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/AttachmentUpload.tsx +275 -0
- 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 +79 -35
- package/src/components/form/ScanInput/__tests__/CodeScanner.test.tsx +101 -0
- package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +284 -11
- package/src/components/form/ScanInput/useCodeScanner.ts +332 -24
- 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 +2 -0
- package/src/flow/FlowPage.tsx +9 -1
- package/src/flow/__tests__/FlowPage.test.tsx +50 -3
- package/src/flow/__tests__/FlowRoute.test.tsx +128 -10
- package/src/flow/__tests__/PluginFlowEngine.test.ts +58 -0
- package/src/flow/actions/__tests__/actionLinkageRules.forkProps.test.ts +314 -0
- package/src/flow/actions/__tests__/dataScopeFormValueClear.test.ts +102 -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/index.ts +2 -0
- package/src/flow/actions/linkageRules.tsx +111 -16
- package/src/flow/actions/linkageRulesRefresh.tsx +2 -6
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +1 -57
- package/src/flow/admin-shell/admin-layout/NocoBaseLogo.tsx +77 -0
- package/src/flow/admin-shell/admin-layout/TopbarActionsBar.tsx +37 -14
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +77 -13
- package/src/flow/common/Markdown/style.ts +4 -0
- package/src/flow/components/BlockItemCard.tsx +2 -2
- package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
- package/src/flow/components/FieldAssignValueInput.tsx +91 -20
- package/src/flow/components/FlowRoute.tsx +78 -32
- 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 +3 -0
- package/src/flow/internal/registerDeviceTypeContext.ts +39 -0
- package/src/flow/models/base/ActionModelCore.tsx +11 -2
- package/src/flow/models/base/BlockGridModel.tsx +26 -0
- package/src/flow/models/base/CollectionBlockModel.tsx +6 -2
- 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 +249 -18
- 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 +1075 -7
- package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +49 -0
- package/src/flow/models/base/__tests__/BlockGridModel.selectSceneActivation.test.ts +124 -0
- package/src/flow/models/base/__tests__/CollectionBlockModel.addAppends.test.ts +41 -0
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +28 -3
- 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 +66 -4
- 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/js-block/JSBlock.tsx +1 -1
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +2 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +4 -2
- package/src/flow/models/blocks/table/TableColumnModel.tsx +30 -1
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.quickEditRefresh.test.ts +12 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +33 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +2 -1
- package/src/flow/models/fields/DateTimeFieldModel/__tests__/DateTimeNoTzFieldModel.dateLimit.test.tsx +149 -0
- package/src/flow/models/fields/DateTimeFieldModel/dateLimit.ts +149 -113
- package/src/flow/models/fields/JsonFieldModel.tsx +31 -8
- package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
- package/src/flow/models/fields/__tests__/JsonFieldModel.test.ts +82 -0
- 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 +52 -180
- package/src/flow/utils/dataScopeFormValueClear.ts +4 -3
- package/src/flow-compat/fieldValidationConstants.ts +1 -1
- package/src/flow-compat/routeTypes.ts +1 -0
- package/src/index.ts +14 -1
- package/src/locale/languageCodes.ts +3 -1
- package/src/nocobase-buildin-plugin/currentUserAuthStatus.ts +58 -0
- package/src/nocobase-buildin-plugin/index.tsx +110 -70
- package/src/settings-app/SettingsApplication.ts +31 -0
- package/src/settings-app/SettingsBrand.tsx +108 -0
- package/src/settings-app/SettingsBuildInPlugin.ts +10 -0
- package/src/settings-app/SettingsDocumentRedirect.tsx +26 -0
- package/src/settings-app/SettingsGroupNav.tsx +124 -0
- package/src/settings-app/SettingsPluginSettingsManager.ts +38 -0
- package/src/settings-app/SettingsRouterManager.ts +92 -0
- package/src/settings-app/SettingsSearch.tsx +238 -0
- package/src/settings-app/SettingsShell.tsx +167 -0
- package/src/settings-app/isSettingsApp.ts +21 -0
- package/src/settings-app/runtimePaths.ts +104 -0
- package/src/settings-app/settingsDocumentPath.ts +66 -0
- package/src/settings-app/settingsTheme.ts +301 -0
- package/src/settings-app/useSettingsThemeConfig.ts +100 -0
- package/src/settings-center/AdminSettingsLayout.tsx +122 -141
- package/src/settings-center/SystemSettingsPage.tsx +4 -170
- package/src/settings-center/groups.ts +108 -0
- package/src/settings-center/useSettingsGroups.ts +105 -0
- package/src/settings-center/useSettingsSearch.ts +173 -0
- package/src/settings-center/utils.tsx +50 -1
- package/src/theme/index.tsx +1 -0
- package/src/theme/itemActive.ts +31 -0
- package/src/theme/type.ts +10 -0
- package/src/utils/getRouteRuntimeVersion.ts +185 -0
- package/src/utils/index.tsx +1 -0
|
@@ -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
|
}
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { type FlowEngine, useFlowContext, useFlowEngine } from '@nocobase/flow-engine';
|
|
11
|
+
import { Button, Result } from 'antd';
|
|
11
12
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
12
|
-
import {
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
13
14
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
15
|
+
import { getModernClientPrefix, stripModernClientPrefix } from '../../authRedirect';
|
|
14
16
|
import { useApp } from '../../hooks/useApp';
|
|
15
17
|
import { NocoBaseDesktopRouteType, type NocoBaseDesktopRoute } from '../../flow-compat';
|
|
16
18
|
import {
|
|
@@ -22,12 +24,14 @@ import { getLayoutModel, type BaseLayoutModel } from '../admin-shell/BaseLayoutM
|
|
|
22
24
|
import { useLayoutRoutePage } from '../admin-shell/useLayoutRoutePage';
|
|
23
25
|
import { AppNotFound } from '../../components';
|
|
24
26
|
import { useKeepAlive } from '../../components/KeepAlive';
|
|
27
|
+
import { registerDeviceTypeContext } from '../internal/registerDeviceTypeContext';
|
|
25
28
|
|
|
26
29
|
type FlowRouteGuardState = {
|
|
27
30
|
pageUid?: string;
|
|
28
31
|
pending: boolean;
|
|
29
32
|
allowBridge: boolean;
|
|
30
33
|
notFound: boolean;
|
|
34
|
+
legacyPageUnsupported?: boolean;
|
|
31
35
|
};
|
|
32
36
|
|
|
33
37
|
export type LegacyPageBehavior = 'redirect' | 'notFound' | 'bridge';
|
|
@@ -156,31 +160,9 @@ const BridgeFlowRoute = ({
|
|
|
156
160
|
const layoutContentRef = useRef<HTMLDivElement>(null);
|
|
157
161
|
|
|
158
162
|
useEffect(() => {
|
|
159
|
-
flowEngine.context.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
meta: {
|
|
163
|
-
type: 'string',
|
|
164
|
-
title: flowEngine.translate('Current device type'),
|
|
165
|
-
interface: 'select',
|
|
166
|
-
uiSchema: {
|
|
167
|
-
enum: [
|
|
168
|
-
{ label: flowEngine.translate('Computer'), value: 'computer' },
|
|
169
|
-
{ label: flowEngine.translate('Mobile'), value: 'mobile' },
|
|
170
|
-
{ label: flowEngine.translate('Tablet'), value: 'tablet' },
|
|
171
|
-
{ label: flowEngine.translate('SmartTv'), value: 'smarttv' },
|
|
172
|
-
{ label: flowEngine.translate('Console'), value: 'console' },
|
|
173
|
-
{ label: flowEngine.translate('Wearable'), value: 'wearable' },
|
|
174
|
-
{ label: flowEngine.translate('Embedded'), value: 'embedded' },
|
|
175
|
-
],
|
|
176
|
-
'x-component': 'Select',
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
info: {
|
|
180
|
-
description: 'Current device type (computer/mobile/tablet/...).',
|
|
181
|
-
detail: 'string',
|
|
182
|
-
},
|
|
183
|
-
});
|
|
163
|
+
if (!flowEngine.context.getPropertyOptions('deviceType')) {
|
|
164
|
+
registerDeviceTypeContext(flowEngine);
|
|
165
|
+
}
|
|
184
166
|
}, [flowEngine]);
|
|
185
167
|
|
|
186
168
|
useLayoutRoutePage({
|
|
@@ -195,11 +177,58 @@ const BridgeFlowRoute = ({
|
|
|
195
177
|
return <div ref={layoutContentRef} />;
|
|
196
178
|
};
|
|
197
179
|
|
|
180
|
+
type RouteLocation = {
|
|
181
|
+
pathname: string;
|
|
182
|
+
search: string;
|
|
183
|
+
hash: string;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const getLegacyPageHref = (app: { getPublicPath: () => string }, location: RouteLocation) => {
|
|
187
|
+
const modernPublicPath = app.getPublicPath();
|
|
188
|
+
const browserLocationMatchesPublicPath = window.location.pathname.startsWith(modernPublicPath);
|
|
189
|
+
const currentLocation = browserLocationMatchesPublicPath ? window.location : location;
|
|
190
|
+
const pathWithinModernClient = currentLocation.pathname.startsWith(modernPublicPath)
|
|
191
|
+
? currentLocation.pathname.slice(modernPublicPath.length)
|
|
192
|
+
: currentLocation.pathname.replace(/^\/+/, '');
|
|
193
|
+
return `${stripModernClientPrefix(modernPublicPath)}${pathWithinModernClient}${currentLocation.search}${
|
|
194
|
+
currentLocation.hash
|
|
195
|
+
}`;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const LegacyPageUnsupported = ({
|
|
199
|
+
app,
|
|
200
|
+
location,
|
|
201
|
+
}: {
|
|
202
|
+
app: { getPublicPath: () => string };
|
|
203
|
+
location: RouteLocation;
|
|
204
|
+
}) => {
|
|
205
|
+
const { t } = useTranslation();
|
|
206
|
+
const modernClientPath = `/${getModernClientPrefix()}/`;
|
|
207
|
+
const withModernClientPath = (message: string) => message.replaceAll('{{modernClientPath}}', modernClientPath);
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<Result
|
|
211
|
+
status="warning"
|
|
212
|
+
title={withModernClientPath(t('This page is not supported in the {{modernClientPath}} branch'))}
|
|
213
|
+
subTitle={withModernClientPath(
|
|
214
|
+
t(
|
|
215
|
+
'The {{modernClientPath}} branch only supports new pages. This page is a legacy page. Please open it from the original entry.',
|
|
216
|
+
),
|
|
217
|
+
)}
|
|
218
|
+
extra={
|
|
219
|
+
<Button href={getLegacyPageHref(app, location)} type="primary">
|
|
220
|
+
{t('Open from the original entry')}
|
|
221
|
+
</Button>
|
|
222
|
+
}
|
|
223
|
+
/>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
198
227
|
/**
|
|
199
228
|
* 管理后台动态页面路由组件。
|
|
200
229
|
*
|
|
201
|
-
* 负责读取当前路由页面 UID
|
|
202
|
-
*
|
|
230
|
+
* 负责读取当前路由页面 UID,并把页面生命周期桥接到 AdminLayout host model。
|
|
231
|
+
* 设备变量通常由 PluginFlowEngine 共享初始化提供;独立渲染时会在挂载后补充注册。
|
|
203
232
|
*
|
|
204
233
|
* @example
|
|
205
234
|
* ```tsx
|
|
@@ -274,11 +303,12 @@ const FlowRoute = (props: FlowRouteProps = {}) => {
|
|
|
274
303
|
useEffect(() => {
|
|
275
304
|
let active = true;
|
|
276
305
|
const requestId = ++requestIdRef.current;
|
|
306
|
+
const requiresAccessibleRoute = shouldRequireAccessibleRoute(routeLayout);
|
|
277
307
|
|
|
278
308
|
const run = async () => {
|
|
279
309
|
setGuardState({ pageUid, pending: true, allowBridge: false, notFound: false });
|
|
280
310
|
|
|
281
|
-
if (!skipRouteRepositoryCheck && !routeRepository?.isAccessibleLoaded?.()) {
|
|
311
|
+
if (requiresAccessibleRoute && !skipRouteRepositoryCheck && !routeRepository?.isAccessibleLoaded?.()) {
|
|
282
312
|
try {
|
|
283
313
|
await routeRepository?.ensureAccessibleLoaded?.();
|
|
284
314
|
} catch (_error) {
|
|
@@ -293,8 +323,11 @@ const FlowRoute = (props: FlowRouteProps = {}) => {
|
|
|
293
323
|
return;
|
|
294
324
|
}
|
|
295
325
|
|
|
296
|
-
const route =
|
|
297
|
-
|
|
326
|
+
const route =
|
|
327
|
+
skipRouteRepositoryCheck || !requiresAccessibleRoute
|
|
328
|
+
? undefined
|
|
329
|
+
: getAccessibleRouteByPageUid(routeRepository, pageUid);
|
|
330
|
+
if (!route && !skipRouteRepositoryCheck && requiresAccessibleRoute) {
|
|
298
331
|
setGuardState({ pageUid, pending: false, allowBridge: false, notFound: true });
|
|
299
332
|
return;
|
|
300
333
|
}
|
|
@@ -373,7 +406,13 @@ const FlowRoute = (props: FlowRouteProps = {}) => {
|
|
|
373
406
|
|
|
374
407
|
if (target.reason === 'unsupportedV2Runtime') {
|
|
375
408
|
if (active && requestId === requestIdRef.current) {
|
|
376
|
-
setGuardState({
|
|
409
|
+
setGuardState({
|
|
410
|
+
pageUid,
|
|
411
|
+
pending: false,
|
|
412
|
+
allowBridge: false,
|
|
413
|
+
notFound: false,
|
|
414
|
+
legacyPageUnsupported: true,
|
|
415
|
+
});
|
|
377
416
|
}
|
|
378
417
|
return;
|
|
379
418
|
}
|
|
@@ -410,6 +449,10 @@ const FlowRoute = (props: FlowRouteProps = {}) => {
|
|
|
410
449
|
return <AppNotFound />;
|
|
411
450
|
}
|
|
412
451
|
|
|
452
|
+
if (guardState.legacyPageUnsupported) {
|
|
453
|
+
return <LegacyPageUnsupported app={app} location={location} />;
|
|
454
|
+
}
|
|
455
|
+
|
|
413
456
|
if (!guardState.allowBridge) {
|
|
414
457
|
return null;
|
|
415
458
|
}
|
|
@@ -417,11 +460,14 @@ const FlowRoute = (props: FlowRouteProps = {}) => {
|
|
|
417
460
|
return <BridgeFlowRoute pageUid={pageUid} active={active} getLayoutModel={getLayoutModel} />;
|
|
418
461
|
}, [
|
|
419
462
|
active,
|
|
463
|
+
app,
|
|
420
464
|
getLayoutModel,
|
|
421
465
|
guardState.allowBridge,
|
|
466
|
+
guardState.legacyPageUnsupported,
|
|
422
467
|
guardState.notFound,
|
|
423
468
|
guardState.pageUid,
|
|
424
469
|
guardState.pending,
|
|
470
|
+
location,
|
|
425
471
|
pageUid,
|
|
426
472
|
]);
|
|
427
473
|
|
|
@@ -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) =>
|
|
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}
|