@nocobase/client-v2 2.1.0-beta.30 → 2.1.0-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/BaseApplication.d.ts +1 -0
- package/es/PluginManager.d.ts +1 -0
- package/es/components/form/DrawerFormLayout.d.ts +49 -0
- package/es/components/form/EnvVariableInput.d.ts +42 -0
- package/es/components/form/FileSizeInput.d.ts +27 -0
- package/es/components/form/createFormRegistry.d.ts +33 -0
- package/es/components/form/index.d.ts +13 -0
- package/es/components/index.d.ts +1 -1
- package/es/flow/components/FieldAssignRulesEditor.d.ts +1 -0
- package/es/flow/internal/utils/enumOptionsUtils.d.ts +5 -0
- package/es/flow/models/actions/AssociationActionUtils.d.ts +5 -0
- package/es/flow/models/blocks/filter-form/FilterFormBlockModel.d.ts +4 -0
- package/es/flow/models/blocks/filter-manager/FilterManager.d.ts +5 -1
- package/es/flow/models/blocks/table/TableSelectModel.d.ts +8 -0
- package/es/flow/models/fields/DisplayTitleFieldModel.d.ts +1 -1
- package/es/flow/models/utils/displayValueUtils.d.ts +12 -0
- package/es/flow-compat/passwordUtils.d.ts +1 -1
- package/es/index.mjs +87 -76
- package/es/utils/remotePlugins.d.ts +0 -4
- package/lib/index.js +97 -86
- package/package.json +6 -5
- package/src/BaseApplication.tsx +14 -8
- package/src/PluginManager.ts +1 -0
- package/src/__tests__/app.test.tsx +28 -1
- package/src/__tests__/remotePlugins.test.ts +29 -18
- package/src/components/form/DrawerFormLayout.tsx +103 -0
- package/src/components/form/EnvVariableInput.tsx +126 -0
- package/src/components/form/FileSizeInput.tsx +105 -0
- package/src/components/form/createFormRegistry.ts +60 -0
- package/src/components/form/index.tsx +14 -0
- package/src/components/index.ts +1 -1
- package/src/flow/actions/__tests__/dataScopeFilter.test.ts +92 -13
- package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +476 -1
- package/src/flow/actions/linkageRules.tsx +240 -258
- package/src/flow/actions/setTargetDataScope.tsx +32 -3
- package/src/flow/components/FieldAssignRulesEditor.tsx +2 -0
- package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +81 -4
- package/src/flow/components/filter/LinkageFilterItem.tsx +9 -2
- package/src/flow/components/filter/VariableFilterItem.tsx +2 -6
- package/src/flow/components/filter/__tests__/LinkageFilterItem.test.tsx +71 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +48 -0
- package/src/flow/internal/utils/__tests__/enumOptionsUtils.test.ts +10 -1
- package/src/flow/internal/utils/enumOptionsUtils.ts +29 -0
- package/src/flow/models/actions/AssociateActionModel.tsx +2 -2
- package/src/flow/models/actions/AssociationActionUtils.ts +14 -0
- package/src/flow/models/actions/__tests__/AssociationActionModel.test.ts +63 -0
- package/src/flow/models/base/CollectionBlockModel.tsx +7 -0
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +33 -9
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +53 -13
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.getFilterValue.test.ts +63 -3
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +33 -1
- package/src/flow/models/blocks/filter-manager/FilterManager.ts +66 -2
- package/src/flow/models/blocks/filter-manager/__tests__/FilterManager.test.ts +270 -0
- package/src/flow/models/blocks/form/FormBlockModel.tsx +8 -5
- package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +30 -0
- package/src/flow/models/blocks/form/value-runtime/rules.ts +6 -1
- package/src/flow/models/blocks/form/value-runtime/runtime.ts +6 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +11 -6
- package/src/flow/models/blocks/table/TableColumnModel.tsx +3 -0
- package/src/flow/models/blocks/table/TableSelectModel.tsx +36 -26
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowClick.test.ts +69 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +96 -1
- package/src/flow/models/blocks/table/__tests__/TableSelectModel.test.ts +41 -0
- package/src/flow/models/fields/ClickableFieldModel.tsx +9 -4
- package/src/flow/models/fields/DisplayTitleFieldModel.tsx +12 -4
- package/src/flow/models/fields/SelectFieldModel.tsx +31 -1
- package/src/flow/models/fields/__tests__/ClickableFieldModel.test.ts +23 -0
- package/src/flow/models/fields/mobile-components/MobileSelect.tsx +2 -1
- package/src/flow/models/fields/mobile-components/__tests__/MobileSelect.test.tsx +7 -0
- package/src/flow/models/utils/displayValueUtils.ts +57 -0
- package/src/utils/globalDeps.ts +2 -0
- package/src/utils/remotePlugins.ts +7 -27
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { isValidElement } from 'react';
|
|
11
|
+
|
|
12
|
+
export function hasDisplayValue(value: any) {
|
|
13
|
+
return value !== undefined && value !== null && value !== '';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getTitleFieldName(collectionField: any) {
|
|
17
|
+
const targetCollection = collectionField?.targetCollection;
|
|
18
|
+
return (
|
|
19
|
+
collectionField?.targetCollectionTitleFieldName ||
|
|
20
|
+
targetCollection?.titleCollectionField?.name ||
|
|
21
|
+
targetCollection?.titleField ||
|
|
22
|
+
targetCollection?.options?.titleField
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getTitleCollectionField(collectionField: any, titleFieldName: string) {
|
|
27
|
+
return (
|
|
28
|
+
collectionField?.targetCollection?.getField?.(titleFieldName) ||
|
|
29
|
+
collectionField?.targetCollection?.titleCollectionField
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function normalizeDisplayValue(value: any, options: { collectionField?: any } = {}): any {
|
|
34
|
+
if (!hasDisplayValue(value) || isValidElement(value)) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
if (['string', 'number', 'boolean'].includes(typeof value)) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
const parts = value.map((item) => normalizeDisplayValue(item, options)).filter(hasDisplayValue);
|
|
42
|
+
return parts.length ? parts.map(String).join(', ') : undefined;
|
|
43
|
+
}
|
|
44
|
+
if (value instanceof Date) {
|
|
45
|
+
return value.toISOString();
|
|
46
|
+
}
|
|
47
|
+
if (typeof value === 'object') {
|
|
48
|
+
const titleFieldName = getTitleFieldName(options.collectionField);
|
|
49
|
+
if (titleFieldName) {
|
|
50
|
+
return normalizeDisplayValue(value[titleFieldName], {
|
|
51
|
+
collectionField: getTitleCollectionField(options.collectionField, titleFieldName),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}
|
package/src/utils/globalDeps.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { dayjs } from '@nocobase/utils/client';
|
|
|
19
19
|
import * as nocobaseFlowEngine from '@nocobase/flow-engine';
|
|
20
20
|
import * as ahooks from 'ahooks';
|
|
21
21
|
import * as antd from 'antd';
|
|
22
|
+
import axios from 'axios';
|
|
22
23
|
import * as i18next from 'i18next';
|
|
23
24
|
import lodash from 'lodash';
|
|
24
25
|
import React from 'react';
|
|
@@ -68,6 +69,7 @@ export function defineGlobalDeps(requirejs: RequireJS) {
|
|
|
68
69
|
|
|
69
70
|
// utils
|
|
70
71
|
requirejs.define('ahooks', () => ahooks);
|
|
72
|
+
requirejs.define('axios', () => axios);
|
|
71
73
|
requirejs.define('dayjs', () => dayjs);
|
|
72
74
|
requirejs.define('lodash', () => lodash);
|
|
73
75
|
requirejs.define('@emotion/css', () => emotionCss);
|
|
@@ -12,33 +12,16 @@ import type { PluginClass } from '../PluginManager';
|
|
|
12
12
|
import type { PluginData } from '../PluginManager';
|
|
13
13
|
import type { RequireJS } from './requirejs';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*/
|
|
18
|
-
export function defineDevPlugins(plugins: Record<string, PluginClass>) {
|
|
19
|
-
Object.entries(plugins).forEach(([packageName, plugin]) => {
|
|
20
|
-
window.define(`${packageName}/client-v2`, () => plugin);
|
|
21
|
-
});
|
|
15
|
+
function getClientV2ModuleId(packageName: string) {
|
|
16
|
+
return `${packageName}/client-v2`;
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
/**
|
|
25
20
|
* @internal
|
|
26
21
|
*/
|
|
27
|
-
export function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
value: true,
|
|
31
|
-
});
|
|
32
|
-
Object.keys(_pluginExports).forEach(function (key) {
|
|
33
|
-
if (key === '__esModule') return;
|
|
34
|
-
if (key in _exports && _exports[key] === _pluginExports[key]) return;
|
|
35
|
-
Object.defineProperty(_exports, key, {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function () {
|
|
38
|
-
return _pluginExports[key];
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
});
|
|
22
|
+
export function defineDevPlugins(plugins: Record<string, PluginClass>) {
|
|
23
|
+
Object.entries(plugins).forEach(([packageName, plugin]) => {
|
|
24
|
+
window.define(getClientV2ModuleId(packageName), () => plugin);
|
|
42
25
|
});
|
|
43
26
|
}
|
|
44
27
|
|
|
@@ -49,7 +32,7 @@ export function configRequirejs(requirejs: any, pluginData: PluginData[]) {
|
|
|
49
32
|
requirejs.requirejs.config({
|
|
50
33
|
waitSeconds: 120,
|
|
51
34
|
paths: pluginData.reduce<Record<string, string>>((acc, cur) => {
|
|
52
|
-
acc[cur.packageName] = cur.url;
|
|
35
|
+
acc[getClientV2ModuleId(cur.packageName)] = cur.url;
|
|
53
36
|
return acc;
|
|
54
37
|
}, {}),
|
|
55
38
|
});
|
|
@@ -85,10 +68,7 @@ export function processRemotePlugins(pluginData: PluginData[], resolve: (plugins
|
|
|
85
68
|
export function getRemotePlugins(requirejs: any, pluginData: PluginData[] = []): Promise<Array<[string, PluginClass]>> {
|
|
86
69
|
configRequirejs(requirejs, pluginData);
|
|
87
70
|
|
|
88
|
-
const packageNames = pluginData.map((item) => item.packageName);
|
|
89
|
-
packageNames.forEach((packageName) => {
|
|
90
|
-
definePluginClient(packageName);
|
|
91
|
-
});
|
|
71
|
+
const packageNames = pluginData.map((item) => getClientV2ModuleId(item.packageName));
|
|
92
72
|
|
|
93
73
|
return new Promise((resolve, reject) => {
|
|
94
74
|
requirejs.requirejs(packageNames, processRemotePlugins(pluginData, resolve), reject);
|