@tachybase/client 1.0.6 → 1.0.25
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/application/Application.d.ts +2 -0
- package/es/application/Application.mjs +15 -0
- package/es/application/NoticesManager.d.ts +12 -3
- package/es/application/NoticesManager.mjs +27 -3
- package/es/application/TrackingManager.d.ts +13 -0
- package/es/application/TrackingManager.mjs +30 -0
- package/es/application/components/SharePage.d.ts +4 -0
- package/es/application/components/SharePage.mjs +113 -0
- package/es/application/components/ShareSchemaComponent.d.ts +1 -0
- package/es/application/components/ShareSchemaComponent.mjs +10 -0
- package/es/application/components/index.d.ts +2 -0
- package/es/application/components/index.mjs +2 -0
- package/es/built-in/admin-layout/index.d.ts +1 -0
- package/es/built-in/admin-layout/index.mjs +1 -0
- package/es/built-in/pm/PluginManager.mjs +45 -45
- package/es/collection-manager/interfaces/__tests__/json.mjs +2 -2
- package/es/collection-manager/interfaces/email.d.ts +0 -1
- package/es/collection-manager/interfaces/input.d.ts +0 -2
- package/es/collection-manager/interfaces/integer.d.ts +12 -2
- package/es/collection-manager/interfaces/integer.mjs +13 -1
- package/es/collection-manager/interfaces/number.d.ts +16 -1
- package/es/collection-manager/interfaces/number.mjs +22 -1
- package/es/collection-manager/interfaces/password.d.ts +0 -1
- package/es/collection-manager/interfaces/percent.d.ts +12 -1
- package/es/collection-manager/interfaces/percent.mjs +12 -0
- package/es/collection-manager/interfaces/phone.d.ts +0 -1
- package/es/collection-manager/interfaces/properties/index.d.ts +0 -2
- package/es/collection-manager/interfaces/properties/index.mjs +0 -2
- package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToFormInitializerItems.d.ts +3 -0
- package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToFormInitializerItems.mjs +67 -0
- package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToInitializerItems.d.ts +3 -0
- package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToInitializerItems.mjs +37 -0
- package/es/data-source/collection-fields-to-initializer-items/index.d.ts +1 -0
- package/es/data-source/collection-fields-to-initializer-items/index.mjs +1 -0
- package/es/data-source/collection-fields-to-initializer-items/items/AssociationCollectionFields.d.ts +3 -0
- package/es/data-source/collection-fields-to-initializer-items/items/AssociationCollectionFields.mjs +59 -0
- package/es/data-source/collection-fields-to-initializer-items/items/ParentCollectionFields.d.ts +3 -0
- package/es/data-source/collection-fields-to-initializer-items/items/ParentCollectionFields.mjs +34 -0
- package/es/data-source/collection-fields-to-initializer-items/items/SelfFields.d.ts +3 -0
- package/es/data-source/collection-fields-to-initializer-items/items/SelfFields.mjs +14 -0
- package/es/data-source/collection-fields-to-initializer-items/items/index.d.ts +3 -0
- package/es/data-source/collection-fields-to-initializer-items/items/index.mjs +7 -0
- package/es/data-source/collection-fields-to-initializer-items/utils/getInitializerItemsByFields.d.ts +5 -0
- package/es/data-source/collection-fields-to-initializer-items/utils/getInitializerItemsByFields.mjs +91 -0
- package/es/data-source/collection-fields-to-initializer-items/utils/index.d.ts +3 -0
- package/es/data-source/collection-fields-to-initializer-items/utils/index.mjs +3 -0
- package/es/data-source/collection-fields-to-initializer-items/utils/type.d.ts +108 -0
- package/es/data-source/collection-fields-to-initializer-items/utils/type.mjs +0 -0
- package/es/data-source/collection-fields-to-initializer-items/utils/useCollectionFieldContext.d.ts +21 -0
- package/es/data-source/collection-fields-to-initializer-items/utils/useCollectionFieldContext.mjs +31 -0
- package/es/data-source/index.d.ts +1 -0
- package/es/data-source/index.mjs +1 -0
- package/es/modules/blocks/data-blocks/form/fieldSettingsFormItem.mjs +0 -8
- package/es/modules/blocks/data-blocks/form/hooks/useEditFormBlockDecoratorProps.d.ts +1 -3
- package/es/modules/blocks/data-blocks/form/hooks/useEditFormBlockDecoratorProps.mjs +4 -1
- package/es/modules/fields/component/InputNumber/inputNumberComponentFieldSettings.mjs +91 -0
- package/es/schema-component/antd/index.d.ts +2 -0
- package/es/schema-component/antd/index.mjs +2 -0
- package/es/schema-component/antd/page/Page.Settings.mjs +33 -0
- package/es/schema-component/antd/page/Page.mjs +113 -18
- package/es/schema-component/antd/page/hooks/index.d.ts +1 -0
- package/es/schema-component/antd/page/hooks/index.mjs +1 -0
- package/es/schema-component/antd/page/hooks/useShareActions.d.ts +7 -0
- package/es/schema-component/antd/page/hooks/useShareActions.mjs +245 -0
- package/es/schema-component/antd/page/index.d.ts +1 -0
- package/es/schema-component/antd/page/index.mjs +1 -0
- package/es/schema-component/antd/page/style.d.ts +5 -0
- package/es/schema-component/antd/page/style.mjs +59 -2
- package/es/schema-component/antd/slider/index.d.ts +1 -0
- package/es/schema-component/antd/slider/index.mjs +1 -0
- package/es/schema-component/antd/slider/slider.d.ts +3 -0
- package/es/schema-component/antd/slider/slider.mjs +11 -0
- package/es/schema-component/antd/tracking-link/index.d.ts +10 -0
- package/es/schema-component/antd/tracking-link/index.mjs +25 -0
- package/es/schema-initializer/utils.d.ts +1 -0
- package/es/schema-initializer/utils.mjs +1 -1
- package/lib/application/Application.js +15 -0
- package/lib/application/NoticesManager.js +27 -3
- package/lib/application/TrackingManager.js +66 -0
- package/lib/application/components/SharePage.js +150 -0
- package/lib/application/components/ShareSchemaComponent.js +44 -0
- package/lib/application/components/index.js +18 -0
- package/lib/application/schema-initializer/hooks/index.js +2 -2
- package/lib/block-provider/hooks/index.js +2 -2
- package/lib/built-in/admin-layout/index.js +9 -0
- package/lib/built-in/pm/PluginManager.js +45 -45
- package/lib/collection-manager/interfaces/__tests__/json.js +4 -4
- package/lib/collection-manager/interfaces/integer.js +13 -1
- package/lib/collection-manager/interfaces/number.js +22 -1
- package/lib/collection-manager/interfaces/percent.js +12 -0
- package/lib/collection-manager/interfaces/properties/index.js +0 -2
- package/lib/data-source/collection-fields-to-initializer-items/CollectionFieldsToFormInitializerItems.js +102 -0
- package/lib/data-source/collection-fields-to-initializer-items/CollectionFieldsToInitializerItems.js +71 -0
- package/lib/data-source/collection-fields-to-initializer-items/index.js +65 -0
- package/lib/data-source/collection-fields-to-initializer-items/items/AssociationCollectionFields.js +93 -0
- package/lib/data-source/collection-fields-to-initializer-items/items/ParentCollectionFields.js +68 -0
- package/lib/data-source/collection-fields-to-initializer-items/items/SelfFields.js +48 -0
- package/lib/data-source/collection-fields-to-initializer-items/items/index.js +40 -0
- package/lib/data-source/collection-fields-to-initializer-items/utils/getInitializerItemsByFields.js +127 -0
- package/lib/data-source/collection-fields-to-initializer-items/utils/index.js +83 -0
- package/lib/data-source/collection-fields-to-initializer-items/utils/type.js +19 -0
- package/lib/data-source/collection-fields-to-initializer-items/utils/useCollectionFieldContext.js +65 -0
- package/lib/data-source/index.js +12 -3
- package/lib/locale/en_US.js +3 -0
- package/lib/locale/zh-CN.js +21 -0
- package/lib/modules/blocks/data-blocks/form/fieldSettingsFormItem.js +0 -8
- package/lib/modules/blocks/data-blocks/form/hooks/useEditFormBlockDecoratorProps.js +4 -1
- package/lib/modules/fields/component/InputNumber/inputNumberComponentFieldSettings.js +91 -0
- package/lib/schema-component/antd/index.js +161 -133
- package/lib/schema-component/antd/page/Page.Settings.js +33 -0
- package/lib/schema-component/antd/page/Page.js +113 -18
- package/lib/schema-component/antd/page/hooks/index.js +65 -0
- package/lib/schema-component/antd/page/hooks/useShareActions.js +293 -0
- package/lib/schema-component/antd/page/index.js +9 -0
- package/lib/schema-component/antd/page/style.js +60 -2
- package/lib/schema-component/antd/slider/index.js +65 -0
- package/lib/schema-component/antd/slider/slider.js +46 -0
- package/lib/schema-component/antd/tracking-link/index.js +59 -0
- package/lib/schema-initializer/utils.js +2 -1
- package/package.json +8 -7
|
@@ -33,7 +33,6 @@ export declare class PercentFieldInterface extends CollectionFieldInterface {
|
|
|
33
33
|
'x-content': string;
|
|
34
34
|
'x-decorator': string;
|
|
35
35
|
'x-component': string;
|
|
36
|
-
'x-disabled': string;
|
|
37
36
|
'x-reactions': {
|
|
38
37
|
dependencies: string[];
|
|
39
38
|
when: string;
|
|
@@ -55,6 +54,18 @@ export declare class PercentFieldInterface extends CollectionFieldInterface {
|
|
|
55
54
|
label: string;
|
|
56
55
|
}[];
|
|
57
56
|
};
|
|
57
|
+
'uiSchema.x-component-props.addonBefore': {
|
|
58
|
+
type: string;
|
|
59
|
+
title: string;
|
|
60
|
+
'x-decorator': string;
|
|
61
|
+
'x-component': string;
|
|
62
|
+
};
|
|
63
|
+
'uiSchema.x-component-props.addonAfter': {
|
|
64
|
+
type: string;
|
|
65
|
+
title: string;
|
|
66
|
+
'x-decorator': string;
|
|
67
|
+
'x-component': string;
|
|
68
|
+
};
|
|
58
69
|
'uiSchema.title': {
|
|
59
70
|
type: string;
|
|
60
71
|
title: string;
|
|
@@ -98,6 +98,18 @@ class PercentFieldInterface extends __WEBPACK_EXTERNAL_MODULE__data_source_colle
|
|
|
98
98
|
label: '1.00000%'
|
|
99
99
|
}
|
|
100
100
|
]
|
|
101
|
+
},
|
|
102
|
+
'uiSchema.x-component-props.addonBefore': {
|
|
103
|
+
type: 'string',
|
|
104
|
+
title: '{{t("Prefix")}}',
|
|
105
|
+
'x-decorator': 'FormItem',
|
|
106
|
+
'x-component': 'Input'
|
|
107
|
+
},
|
|
108
|
+
'uiSchema.x-component-props.addonAfter': {
|
|
109
|
+
type: 'string',
|
|
110
|
+
title: '{{t("Suffix")}}',
|
|
111
|
+
'x-decorator': 'FormItem',
|
|
112
|
+
'x-component': 'Input'
|
|
101
113
|
}
|
|
102
114
|
}), _define_property(this, "filterable", {
|
|
103
115
|
operators: __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.operators.number
|
|
@@ -6,7 +6,6 @@ export declare const unique: {
|
|
|
6
6
|
'x-content': string;
|
|
7
7
|
'x-decorator': string;
|
|
8
8
|
'x-component': string;
|
|
9
|
-
'x-disabled': string;
|
|
10
9
|
'x-reactions': {
|
|
11
10
|
dependencies: string[];
|
|
12
11
|
when: string;
|
|
@@ -22,7 +21,6 @@ export declare const primaryKey: {
|
|
|
22
21
|
'x-content': string;
|
|
23
22
|
'x-decorator': string;
|
|
24
23
|
'x-component': string;
|
|
25
|
-
'x-disabled': string;
|
|
26
24
|
'x-reactions': {
|
|
27
25
|
dependencies: string[];
|
|
28
26
|
when: string;
|
|
@@ -91,7 +91,6 @@ const unique = {
|
|
|
91
91
|
'x-content': '{{t("Unique")}}',
|
|
92
92
|
'x-decorator': 'FormItem',
|
|
93
93
|
'x-component': 'Checkbox',
|
|
94
|
-
'x-disabled': '{{ !createMainOnly }}',
|
|
95
94
|
'x-reactions': [
|
|
96
95
|
{
|
|
97
96
|
dependencies: [
|
|
@@ -111,7 +110,6 @@ const primaryKey = {
|
|
|
111
110
|
'x-content': '{{t("Primary")}}',
|
|
112
111
|
'x-decorator': 'FormItem',
|
|
113
112
|
'x-component': 'Checkbox',
|
|
114
|
-
'x-disabled': '{{ !createMainOnly }}',
|
|
115
113
|
'x-reactions': [
|
|
116
114
|
{
|
|
117
115
|
dependencies: [
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__schema_initializer_utils_mjs__ from "../../schema-initializer/utils.mjs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__CollectionFieldsToInitializerItems_mjs__ from "./CollectionFieldsToInitializerItems.mjs";
|
|
4
|
+
const findKanbanFormItem = (schema, key, action)=>{
|
|
5
|
+
const s = (0, __WEBPACK_EXTERNAL_MODULE__schema_initializer_utils_mjs__.findSchema)(schema, 'x-component', 'Kanban');
|
|
6
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__schema_initializer_utils_mjs__.findSchema)(s, key, action);
|
|
7
|
+
};
|
|
8
|
+
const CollectionFieldsToFormInitializerItems = (props)=>{
|
|
9
|
+
const block = (null == props ? void 0 : props.block) || 'Form';
|
|
10
|
+
const fieldItemSchema = {
|
|
11
|
+
'x-toolbar': 'FormItemSchemaToolbar',
|
|
12
|
+
'x-settings': 'fieldSettings:FormItem',
|
|
13
|
+
'x-decorator': 'FormItem'
|
|
14
|
+
};
|
|
15
|
+
const initializerItem = {
|
|
16
|
+
remove: __WEBPACK_EXTERNAL_MODULE__schema_initializer_utils_mjs__.removeGridFormItem
|
|
17
|
+
};
|
|
18
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__CollectionFieldsToInitializerItems_mjs__.CollectionFieldsToInitializerItems, {
|
|
19
|
+
block: block,
|
|
20
|
+
selfField: {
|
|
21
|
+
filter: (field)=>!field.treeChildren,
|
|
22
|
+
getSchema: (field, param)=>{
|
|
23
|
+
let { targetCollection } = param;
|
|
24
|
+
var _field_uiSchema_xcomponentprops, _field_uiSchema;
|
|
25
|
+
const isFileCollection = (null == targetCollection ? void 0 : targetCollection.template) === 'file';
|
|
26
|
+
const isAssociationField = targetCollection;
|
|
27
|
+
const fieldNames = null == field ? void 0 : null === (_field_uiSchema = field.uiSchema) || void 0 === _field_uiSchema ? void 0 : null === (_field_uiSchema_xcomponentprops = _field_uiSchema['x-component-props']) || void 0 === _field_uiSchema_xcomponentprops ? void 0 : _field_uiSchema_xcomponentprops['fieldNames'];
|
|
28
|
+
return {
|
|
29
|
+
...fieldItemSchema,
|
|
30
|
+
'x-component-props': isFileCollection ? {
|
|
31
|
+
fieldNames: {
|
|
32
|
+
label: 'preview',
|
|
33
|
+
value: 'id'
|
|
34
|
+
}
|
|
35
|
+
} : isAssociationField && fieldNames ? {
|
|
36
|
+
fieldNames: {
|
|
37
|
+
...fieldNames,
|
|
38
|
+
label: (null == targetCollection ? void 0 : targetCollection.titleField) || fieldNames.label
|
|
39
|
+
}
|
|
40
|
+
} : {}
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
getInitializerItem: ()=>({
|
|
44
|
+
...initializerItem,
|
|
45
|
+
find: (null == props ? void 0 : props.block) === 'Kanban' ? findKanbanFormItem : void 0
|
|
46
|
+
})
|
|
47
|
+
},
|
|
48
|
+
parentField: {
|
|
49
|
+
getSchema: ()=>fieldItemSchema,
|
|
50
|
+
getInitializerItem: ()=>initializerItem
|
|
51
|
+
},
|
|
52
|
+
associationField: {
|
|
53
|
+
filterSelfField: (field)=>{
|
|
54
|
+
if ('Form' !== block) return true;
|
|
55
|
+
return (null == field ? void 0 : field.interface) === 'm2o';
|
|
56
|
+
},
|
|
57
|
+
filterAssociationField (collectionField) {
|
|
58
|
+
return (null == collectionField ? void 0 : collectionField.interface) && ![
|
|
59
|
+
'subTable'
|
|
60
|
+
].includes(null == collectionField ? void 0 : collectionField.interface) && !collectionField.treeChildren;
|
|
61
|
+
},
|
|
62
|
+
getSchema: ()=>fieldItemSchema,
|
|
63
|
+
getInitializerItem: ()=>initializerItem
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
export { CollectionFieldsToFormInitializerItems, findKanbanFormItem };
|
package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToInitializerItems.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__items_index_mjs__ from "./items/index.mjs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__ from "./utils/index.mjs";
|
|
4
|
+
const CollectionFieldsToInitializerItems = (props)=>{
|
|
5
|
+
const { selfField, parentField, associationField, block } = props;
|
|
6
|
+
const context = (0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.useCollectionFieldContext)();
|
|
7
|
+
if (!context.collection) return null;
|
|
8
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment, {
|
|
9
|
+
children: [
|
|
10
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__items_index_mjs__.SelfFields, {
|
|
11
|
+
block: block,
|
|
12
|
+
...selfField,
|
|
13
|
+
context: {
|
|
14
|
+
...context,
|
|
15
|
+
collection: context.collection
|
|
16
|
+
}
|
|
17
|
+
}),
|
|
18
|
+
parentField && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__items_index_mjs__.ParentCollectionFields, {
|
|
19
|
+
block: block,
|
|
20
|
+
...parentField,
|
|
21
|
+
context: {
|
|
22
|
+
...context,
|
|
23
|
+
collection: context.collection
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
associationField && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__items_index_mjs__.AssociationCollectionFields, {
|
|
27
|
+
block: block,
|
|
28
|
+
...associationField,
|
|
29
|
+
context: {
|
|
30
|
+
...context,
|
|
31
|
+
collection: context.collection
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export { CollectionFieldsToInitializerItems };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CollectionFieldsToFormInitializerItems';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CollectionFieldsToFormInitializerItems.mjs";
|
package/es/data-source/collection-fields-to-initializer-items/items/AssociationCollectionFields.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__application_schema_initializer_index_mjs__ from "../../../application/schema-initializer/index.mjs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__ from "../utils/index.mjs";
|
|
4
|
+
const AssociationCollectionFields = (props)=>{
|
|
5
|
+
const { filterAssociationField, filterSelfField = ()=>true, getSchema, ...otherProps } = props;
|
|
6
|
+
const { collection, t, collectionManager } = props.context;
|
|
7
|
+
const fields = collection.getFields();
|
|
8
|
+
const associationInterfaces = [
|
|
9
|
+
'o2o',
|
|
10
|
+
'oho',
|
|
11
|
+
'obo',
|
|
12
|
+
'm2o'
|
|
13
|
+
];
|
|
14
|
+
const associationFields = fields.filter((field)=>associationInterfaces.includes(field.interface)).filter((field)=>filterSelfField(field, props.context));
|
|
15
|
+
if (!associationFields.length) return null;
|
|
16
|
+
const children = associationFields.map((associationField)=>{
|
|
17
|
+
const associationCollection = collectionManager.getCollection(associationField.target);
|
|
18
|
+
if (!associationCollection) return null;
|
|
19
|
+
const associationCollectionFields = null == associationCollection ? void 0 : associationCollection.getAllFields();
|
|
20
|
+
if (!associationCollectionFields.length) return null;
|
|
21
|
+
return {
|
|
22
|
+
associationField,
|
|
23
|
+
associationCollection,
|
|
24
|
+
associationCollectionFields
|
|
25
|
+
};
|
|
26
|
+
}).filter(Boolean).map((param)=>{
|
|
27
|
+
let { associationField, associationCollection, associationCollectionFields } = param;
|
|
28
|
+
var _associationField_uiSchema, _associationField_uiSchema1;
|
|
29
|
+
const newContext = {
|
|
30
|
+
...props.context,
|
|
31
|
+
collection: associationCollection
|
|
32
|
+
};
|
|
33
|
+
const getAssociationFieldSchema = (field, context)=>{
|
|
34
|
+
const schema = getSchema(field, context);
|
|
35
|
+
return {
|
|
36
|
+
...schema || {},
|
|
37
|
+
'x-read-pretty': true,
|
|
38
|
+
name: "".concat(associationField.name, ".").concat(field.name),
|
|
39
|
+
'x-collection-field': "".concat(collection.name, ".").concat(associationField.name, ".").concat(field.name)
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
type: 'subMenu',
|
|
44
|
+
name: null === (_associationField_uiSchema = associationField.uiSchema) || void 0 === _associationField_uiSchema ? void 0 : _associationField_uiSchema.title,
|
|
45
|
+
title: null === (_associationField_uiSchema1 = associationField.uiSchema) || void 0 === _associationField_uiSchema1 ? void 0 : _associationField_uiSchema1.title,
|
|
46
|
+
children: (0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.getInitializerItemsByFields)({
|
|
47
|
+
...otherProps,
|
|
48
|
+
filter: filterAssociationField,
|
|
49
|
+
getSchema: getAssociationFieldSchema
|
|
50
|
+
}, associationCollectionFields, newContext)
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
if (!children.length) return null;
|
|
54
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__application_schema_initializer_index_mjs__.SchemaInitializerItemGroup, {
|
|
55
|
+
title: t('Display association fields'),
|
|
56
|
+
children: children
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
export { AssociationCollectionFields };
|
package/es/data-source/collection-fields-to-initializer-items/items/ParentCollectionFields.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__application_schema_initializer_index_mjs__ from "../../../application/schema-initializer/index.mjs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__ from "../utils/index.mjs";
|
|
4
|
+
const ParentCollectionFields = (props)=>{
|
|
5
|
+
const context = (0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.useCollectionFieldContext)();
|
|
6
|
+
const { collection, t, collectionManager } = context;
|
|
7
|
+
const parentCollectionNames = collection.getParentCollectionsName();
|
|
8
|
+
if (!parentCollectionNames.length) return null;
|
|
9
|
+
const children = parentCollectionNames.map((parentCollectionName)=>{
|
|
10
|
+
const parentCollectionFields = collection.getParentCollectionFields(parentCollectionName);
|
|
11
|
+
if (0 === parentCollectionFields.length) return null;
|
|
12
|
+
const parentCollection = collectionManager.getCollection(parentCollectionName);
|
|
13
|
+
return {
|
|
14
|
+
parentCollection,
|
|
15
|
+
parentCollectionFields
|
|
16
|
+
};
|
|
17
|
+
}).filter(Boolean).map((options)=>{
|
|
18
|
+
const { parentCollection, parentCollectionFields } = options;
|
|
19
|
+
const newContext = {
|
|
20
|
+
...context,
|
|
21
|
+
collection: parentCollection
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
type: 'itemGroup',
|
|
25
|
+
divider: true,
|
|
26
|
+
title: t("Parent collection fields") + '(' + context.compile(parentCollection.title) + ')',
|
|
27
|
+
children: (0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.getInitializerItemsByFields)(props, parentCollectionFields, newContext)
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__application_schema_initializer_index_mjs__.SchemaInitializerChildren, {
|
|
31
|
+
children: children
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export { ParentCollectionFields };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__application_schema_initializer_index_mjs__ from "../../../application/schema-initializer/index.mjs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__ from "../utils/index.mjs";
|
|
4
|
+
const SelfFields = (props)=>{
|
|
5
|
+
const callbackContext = (0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.useCollectionFieldContext)();
|
|
6
|
+
const { t, collection } = callbackContext;
|
|
7
|
+
const fields = collection.getFields();
|
|
8
|
+
const children = (0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.getInitializerItemsByFields)(props, fields, callbackContext);
|
|
9
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__application_schema_initializer_index_mjs__.SchemaInitializerItemGroup, {
|
|
10
|
+
title: t('Display fields'),
|
|
11
|
+
children: children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export { SelfFields };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__SelfFields_mjs__ from "./SelfFields.mjs";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__ParentCollectionFields_mjs__ from "./ParentCollectionFields.mjs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AssociationCollectionFields_mjs__ from "./AssociationCollectionFields.mjs";
|
|
4
|
+
var __webpack_exports__AssociationCollectionFields = __WEBPACK_EXTERNAL_MODULE__AssociationCollectionFields_mjs__.AssociationCollectionFields;
|
|
5
|
+
var __webpack_exports__ParentCollectionFields = __WEBPACK_EXTERNAL_MODULE__ParentCollectionFields_mjs__.ParentCollectionFields;
|
|
6
|
+
var __webpack_exports__SelfFields = __WEBPACK_EXTERNAL_MODULE__SelfFields_mjs__.SelfFields;
|
|
7
|
+
export { __webpack_exports__AssociationCollectionFields as AssociationCollectionFields, __webpack_exports__ParentCollectionFields as ParentCollectionFields, __webpack_exports__SelfFields as SelfFields };
|
package/es/data-source/collection-fields-to-initializer-items/utils/getInitializerItemsByFields.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SchemaInitializerItemType } from '../../../application/schema-initializer';
|
|
2
|
+
import { CollectionFieldOptions } from '../../collection/Collection';
|
|
3
|
+
import { CommonCollectionFieldsProps } from './type';
|
|
4
|
+
import { CollectionFieldContext } from './useCollectionFieldContext';
|
|
5
|
+
export declare function getInitializerItemsByFields(props: CommonCollectionFieldsProps, fields: CollectionFieldOptions[], context: CollectionFieldContext): SchemaInitializerItemType[];
|
package/es/data-source/collection-fields-to-initializer-items/utils/getInitializerItemsByFields.mjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
function getInitializerItemsByFields(props, fields, context) {
|
|
2
|
+
var _actionContext_fieldSchema;
|
|
3
|
+
const { block, isReadPretty = (param)=>{
|
|
4
|
+
let { form } = param;
|
|
5
|
+
return form.readPretty;
|
|
6
|
+
}, filter = ()=>true, getInitializerItem = ()=>({}), getSchema = ()=>({}) } = props;
|
|
7
|
+
const { collectionManager, collection, dataSourceManager, actionContext } = context;
|
|
8
|
+
const action = null === (_actionContext_fieldSchema = actionContext.fieldSchema) || void 0 === _actionContext_fieldSchema ? void 0 : _actionContext_fieldSchema['x-action'];
|
|
9
|
+
if (!collection) return [];
|
|
10
|
+
return fields.map((collectionField)=>{
|
|
11
|
+
const targetCollection = collectionManager.getCollection(collectionField.target);
|
|
12
|
+
const collectionFieldInterface = dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(collectionField.interface);
|
|
13
|
+
return {
|
|
14
|
+
collectionField,
|
|
15
|
+
context: {
|
|
16
|
+
...context,
|
|
17
|
+
targetCollection,
|
|
18
|
+
collectionFieldInterface
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}).filter((param)=>{
|
|
22
|
+
let { collectionField } = param;
|
|
23
|
+
return collectionField.interface;
|
|
24
|
+
}).filter((param)=>{
|
|
25
|
+
let { collectionField, context } = param;
|
|
26
|
+
return filter(collectionField, context);
|
|
27
|
+
}).map((param)=>{
|
|
28
|
+
let { collectionField, context } = param;
|
|
29
|
+
var _collectionField_uiSchema, _collectionField_uiSchema1;
|
|
30
|
+
const defaultSchema = {
|
|
31
|
+
type: 'string',
|
|
32
|
+
title: (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema.title) || collectionField.name,
|
|
33
|
+
name: collectionField.name,
|
|
34
|
+
'x-component': 'CollectionField',
|
|
35
|
+
'x-collection-field': "".concat(collection.name, ".").concat(collectionField.name),
|
|
36
|
+
'x-read-pretty': null == collectionField ? void 0 : null === (_collectionField_uiSchema1 = collectionField.uiSchema) || void 0 === _collectionField_uiSchema1 ? void 0 : _collectionField_uiSchema1['x-read-pretty']
|
|
37
|
+
};
|
|
38
|
+
const customSchema = getSchema(collectionField, {
|
|
39
|
+
...context,
|
|
40
|
+
defaultSchema: defaultSchema
|
|
41
|
+
});
|
|
42
|
+
const schema = {
|
|
43
|
+
...defaultSchema,
|
|
44
|
+
...customSchema || {}
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
collectionField,
|
|
48
|
+
schema,
|
|
49
|
+
context: {
|
|
50
|
+
...context,
|
|
51
|
+
schema
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}).map((param)=>{
|
|
55
|
+
let { collectionField, context } = param;
|
|
56
|
+
var _collectionField_uiSchema;
|
|
57
|
+
const defaultInitializerItem = {
|
|
58
|
+
type: 'item',
|
|
59
|
+
name: collectionField.name,
|
|
60
|
+
title: (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema.title) || collectionField.name,
|
|
61
|
+
Component: 'CollectionFieldInitializer',
|
|
62
|
+
schemaInitialize: (s)=>{
|
|
63
|
+
var _context_collectionFieldInterface_schemaInitialize, _context_collectionFieldInterface;
|
|
64
|
+
null === (_context_collectionFieldInterface = context.collectionFieldInterface) || void 0 === _context_collectionFieldInterface || null === (_context_collectionFieldInterface_schemaInitialize = _context_collectionFieldInterface.schemaInitialize) || void 0 === _context_collectionFieldInterface_schemaInitialize || _context_collectionFieldInterface_schemaInitialize.call(_context_collectionFieldInterface, s, {
|
|
65
|
+
field: collectionField,
|
|
66
|
+
block,
|
|
67
|
+
readPretty: null == isReadPretty ? void 0 : isReadPretty(context),
|
|
68
|
+
action,
|
|
69
|
+
targetCollection: context.targetCollection
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
schema: context.schema
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
collectionField,
|
|
76
|
+
context,
|
|
77
|
+
defaultInitializerItem
|
|
78
|
+
};
|
|
79
|
+
}).map((param)=>{
|
|
80
|
+
let { collectionField, defaultInitializerItem, context } = param;
|
|
81
|
+
const customInitializerItem = getInitializerItem(collectionField, {
|
|
82
|
+
...context,
|
|
83
|
+
defaultInitializerItem
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
...defaultInitializerItem,
|
|
87
|
+
...customInitializerItem || {}
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export { getInitializerItemsByFields };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ISchema, Schema } from '@tachybase/schema';
|
|
2
|
+
import { CollectionFieldInterface } from '../../collection-field-interface';
|
|
3
|
+
import { Collection, CollectionFieldOptions } from '../../collection/Collection';
|
|
4
|
+
import { CollectionFieldContext } from './useCollectionFieldContext';
|
|
5
|
+
export interface CollectionFieldDefaultSchema {
|
|
6
|
+
/**
|
|
7
|
+
* @default 'string'
|
|
8
|
+
*/
|
|
9
|
+
type: string;
|
|
10
|
+
/**
|
|
11
|
+
* @default collectionField.name
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* @default 'CollectionField'
|
|
16
|
+
*/
|
|
17
|
+
'x-component': string;
|
|
18
|
+
/**
|
|
19
|
+
* @default `${collection.name}.${collectionField.name}`
|
|
20
|
+
*/
|
|
21
|
+
'x-collection-field': string;
|
|
22
|
+
/**
|
|
23
|
+
* @default collectionField?.uiSchema?.['x-read-pretty']
|
|
24
|
+
*/
|
|
25
|
+
'x-read-pretty'?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @default collectionField?.uiSchema?.title || collectionField.name
|
|
28
|
+
*/
|
|
29
|
+
title: string;
|
|
30
|
+
}
|
|
31
|
+
export interface CollectionFieldGetSchemaResult {
|
|
32
|
+
'x-toolbar'?: string;
|
|
33
|
+
'x-toolbar-props'?: any;
|
|
34
|
+
'x-settings'?: string;
|
|
35
|
+
'x-decorator'?: string;
|
|
36
|
+
'x-decorator-props'?: any;
|
|
37
|
+
'x-component-props'?: any;
|
|
38
|
+
'x-use-component-props'?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CollectionFieldDefaultInitializerItem {
|
|
41
|
+
/**
|
|
42
|
+
* @default 'item'
|
|
43
|
+
*/
|
|
44
|
+
type: string;
|
|
45
|
+
/**
|
|
46
|
+
* @default collectionField.name
|
|
47
|
+
*/
|
|
48
|
+
name: string;
|
|
49
|
+
/**
|
|
50
|
+
* @default collectionField?.uiSchema?.title || collectionField.name
|
|
51
|
+
*/
|
|
52
|
+
title: string;
|
|
53
|
+
/**
|
|
54
|
+
* @default 'CollectionFieldInitializer'
|
|
55
|
+
*/
|
|
56
|
+
Component: string;
|
|
57
|
+
schemaInitialize: (s: ISchema) => void;
|
|
58
|
+
/**
|
|
59
|
+
* @default schema
|
|
60
|
+
*/
|
|
61
|
+
schema: ISchema;
|
|
62
|
+
}
|
|
63
|
+
export interface CollectionFieldGetInitializerItemResult {
|
|
64
|
+
find?: (schema: Schema, key: string, action: string, name?: string) => any;
|
|
65
|
+
remove?: (schema: Schema, cb: (schema: Schema, stopProps: Record<string, any>) => void) => void;
|
|
66
|
+
}
|
|
67
|
+
export interface CommonCollectionFieldsProps {
|
|
68
|
+
block: string;
|
|
69
|
+
getSchema: (collectionField: CollectionFieldOptions, context: CollectionFieldContext & {
|
|
70
|
+
defaultSchema: CollectionFieldDefaultSchema;
|
|
71
|
+
targetCollection?: Collection;
|
|
72
|
+
collectionFieldInterface?: CollectionFieldInterface;
|
|
73
|
+
}) => CollectionFieldGetSchemaResult;
|
|
74
|
+
isReadPretty?: (context: CollectionFieldContext) => boolean;
|
|
75
|
+
filter?: (collectionField: CollectionFieldOptions, context: CollectionFieldContext) => boolean;
|
|
76
|
+
getInitializerItem?: (collectionField: CollectionFieldOptions, context: CollectionFieldContext & {
|
|
77
|
+
schema: ISchema;
|
|
78
|
+
defaultInitializerItem: CollectionFieldDefaultInitializerItem;
|
|
79
|
+
targetCollection?: Collection;
|
|
80
|
+
collectionFieldInterface?: CollectionFieldInterface;
|
|
81
|
+
}) => CollectionFieldGetInitializerItemResult;
|
|
82
|
+
}
|
|
83
|
+
export interface SelfCollectionFieldsProps extends CommonCollectionFieldsProps {
|
|
84
|
+
context: Omit<CollectionFieldContext, 'collection'> & {
|
|
85
|
+
collection: Collection;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface ParentCollectionFieldsProps extends CommonCollectionFieldsProps {
|
|
89
|
+
context: Omit<CollectionFieldContext, 'collection'> & {
|
|
90
|
+
collection: Collection;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export interface AssociationCollectionFieldsProps extends Omit<CommonCollectionFieldsProps, 'filter'> {
|
|
94
|
+
filterSelfField?: CommonCollectionFieldsProps['filter'];
|
|
95
|
+
filterAssociationField?: CommonCollectionFieldsProps['filter'];
|
|
96
|
+
context: Omit<CollectionFieldContext, 'collection'> & {
|
|
97
|
+
collection: CollectionFieldContext['collection'];
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface CollectionFieldsProps {
|
|
101
|
+
/**
|
|
102
|
+
* Block name.
|
|
103
|
+
*/
|
|
104
|
+
block: string;
|
|
105
|
+
selfField: Omit<SelfCollectionFieldsProps, 'block' | 'context'>;
|
|
106
|
+
parentField?: Omit<ParentCollectionFieldsProps, 'block' | 'context'>;
|
|
107
|
+
associationField?: Omit<AssociationCollectionFieldsProps, 'block' | 'context'>;
|
|
108
|
+
}
|
|
File without changes
|
package/es/data-source/collection-fields-to-initializer-items/utils/useCollectionFieldContext.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Form, ISchema } from '@tachybase/schema';
|
|
2
|
+
import { TFunction } from 'i18next';
|
|
3
|
+
import { InheritanceCollectionMixin } from '../../../collection-manager';
|
|
4
|
+
import { useActionContext } from '../../../schema-component/antd/action';
|
|
5
|
+
import { Collection } from '../../collection/Collection';
|
|
6
|
+
import { CollectionManager } from '../../collection/CollectionManager';
|
|
7
|
+
import { DataSource } from '../../data-source/DataSource';
|
|
8
|
+
import { DataSourceManager } from '../../data-source/DataSourceManager';
|
|
9
|
+
export interface CollectionFieldContext {
|
|
10
|
+
fieldSchema: ISchema;
|
|
11
|
+
collection?: InheritanceCollectionMixin & Collection;
|
|
12
|
+
dataSource: DataSource;
|
|
13
|
+
form: Form<any>;
|
|
14
|
+
actionContext: ReturnType<typeof useActionContext>;
|
|
15
|
+
t: TFunction<'translation', undefined>;
|
|
16
|
+
collectionManager: CollectionManager;
|
|
17
|
+
dataSourceManager: DataSourceManager;
|
|
18
|
+
compile: (source: any, ext?: any) => any;
|
|
19
|
+
targetCollection?: Collection;
|
|
20
|
+
}
|
|
21
|
+
export declare function useCollectionFieldContext(): CollectionFieldContext;
|
package/es/data-source/collection-fields-to-initializer-items/utils/useCollectionFieldContext.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../schema-component/index.mjs";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_action_index_mjs__ from "../../../schema-component/antd/action/index.mjs";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__collection_CollectionManagerProvider_mjs__ from "../../collection/CollectionManagerProvider.mjs";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__collection_CollectionProvider_mjs__ from "../../collection/CollectionProvider.mjs";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__data_source_DataSourceManagerProvider_mjs__ from "../../data-source/DataSourceManagerProvider.mjs";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__data_source_DataSourceProvider_mjs__ from "../../data-source/DataSourceProvider.mjs";
|
|
9
|
+
function useCollectionFieldContext() {
|
|
10
|
+
const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
|
|
11
|
+
const collection = (0, __WEBPACK_EXTERNAL_MODULE__collection_CollectionProvider_mjs__.useCollection)();
|
|
12
|
+
const dataSourceManager = (0, __WEBPACK_EXTERNAL_MODULE__data_source_DataSourceManagerProvider_mjs__.useDataSourceManager)();
|
|
13
|
+
const actionContext = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_action_index_mjs__.useActionContext)();
|
|
14
|
+
const dataSource = (0, __WEBPACK_EXTERNAL_MODULE__data_source_DataSourceProvider_mjs__.useDataSource)();
|
|
15
|
+
const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
|
|
16
|
+
const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
|
|
17
|
+
const collectionManager = (0, __WEBPACK_EXTERNAL_MODULE__collection_CollectionManagerProvider_mjs__.useCollectionManager)();
|
|
18
|
+
const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
|
|
19
|
+
return {
|
|
20
|
+
t,
|
|
21
|
+
compile,
|
|
22
|
+
actionContext,
|
|
23
|
+
fieldSchema,
|
|
24
|
+
collection,
|
|
25
|
+
dataSource,
|
|
26
|
+
form,
|
|
27
|
+
collectionManager,
|
|
28
|
+
dataSourceManager
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export { useCollectionFieldContext };
|
package/es/data-source/index.mjs
CHANGED
|
@@ -7,4 +7,5 @@ export * from "./data-block/index.mjs";
|
|
|
7
7
|
export * from "./data-source/index.mjs";
|
|
8
8
|
export * from "./collection-record/index.mjs";
|
|
9
9
|
export * from "./utils.mjs";
|
|
10
|
+
export * from "./collection-fields-to-initializer-items/index.mjs";
|
|
10
11
|
export * from "./commonsSettingsItem/index.mjs";
|