@tachybase/client 0.23.47 → 0.23.58
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 +3 -0
- package/es/application/Application.mjs +8 -0
- package/es/application/hooks/index.d.ts +1 -0
- package/es/application/hooks/index.mjs +1 -0
- package/es/application/hooks/useGlobalVariable.d.ts +1 -0
- package/es/application/hooks/useGlobalVariable.mjs +18 -0
- package/es/application/schema-settings/hooks/index.d.ts +1 -1
- package/es/application/schema-settings/hooks/index.mjs +6 -8
- package/es/block-provider/hooks/index.mjs +4 -1
- package/es/built-in/index.mjs +3 -0
- package/es/built-in/locale/LocalePlugin.mjs +5 -1
- package/es/built-in/system-settings/SystemSettingsProvider.d.ts +2 -3
- package/es/built-in/system-settings/SystemSettingsProvider.mjs +4 -3
- package/es/built-in/system-settings/SystemSettingsShortcut.mjs +11 -8
- package/es/collection-manager/Configuration/AddCollectionAction.mjs +12 -2
- package/es/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.d.ts +2 -0
- package/es/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.mjs +255 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.d.ts +89 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.mjs +96 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.d.ts +3 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.mjs +47 -0
- package/es/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.d.ts +3 -0
- package/es/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.mjs +44 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.mjs +380 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.d.ts +8 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.mjs +4 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxImportAction.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxImportAction.mjs +187 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.mjs +30 -0
- package/es/collection-manager/collectionPlugin.mjs +3 -1
- package/es/collection-manager/templates/import.mjs +1 -1
- package/es/collection-manager/templates/xlsx.d.ts +11 -0
- package/es/collection-manager/templates/xlsx.mjs +19 -0
- package/es/modules/blocks/data-blocks/table/hooks/useTableBlockProps.mjs +4 -2
- package/es/modules/fields/component/Radio/radioComponentFieldSettings.mjs +0 -4
- package/es/schema-component/antd/action/Action.Designer.mjs +5 -2
- package/es/schema-component/antd/action/Action.Modal.mjs +20 -31
- package/es/schema-component/antd/action/Action.Modal.style.d.ts +4 -0
- package/es/schema-component/antd/action/Action.Modal.style.mjs +35 -0
- package/es/schema-component/antd/action/utils.d.ts +1 -1
- package/es/schema-component/antd/action/utils.mjs +70 -70
- package/es/schema-component/antd/checkbox/Checkbox.mjs +6 -1
- package/es/schema-component/antd/page/Page.d.ts +1 -5
- package/es/schema-component/antd/page/Page.mjs +227 -146
- package/es/schema-component/antd/page/Page.style.d.ts +5 -0
- package/es/schema-component/antd/page/Page.style.mjs +45 -0
- package/es/schema-component/antd/page/PageDesigner.d.ts +3 -0
- package/es/schema-component/antd/page/PageDesigner.mjs +28 -0
- package/es/schema-component/antd/page/PageTabDesigner.d.ts +0 -3
- package/es/schema-component/antd/page/PageTabDesigner.mjs +3 -50
- package/es/schema-component/antd/page/style.d.ts +1 -1
- package/es/schema-component/antd/page/style.mjs +3 -13
- package/es/schema-component/antd/password/Password.d.ts +1 -1
- package/es/schema-component/antd/scroll-area/ScrollArea.d.ts +1 -1
- package/es/schema-component/antd/scroll-area/ScrollArea.mjs +2 -1
- package/es/schema-component/antd/variable/TextArea.mjs +1 -1
- package/es/schema-component/antd/variable/TextAreaWithGlobalScope.d.ts +13 -0
- package/es/schema-component/antd/variable/TextAreaWithGlobalScope.mjs +59 -0
- package/es/schema-component/antd/variable/index.d.ts +1 -0
- package/es/schema-component/antd/variable/index.mjs +3 -0
- package/lib/application/Application.js +8 -0
- package/lib/application/hooks/index.js +9 -0
- package/lib/application/hooks/useGlobalVariable.js +52 -0
- package/lib/application/schema-settings/hooks/index.js +6 -8
- package/lib/block-provider/hooks/index.js +4 -1
- package/lib/built-in/index.js +3 -0
- package/lib/built-in/locale/LocalePlugin.js +5 -1
- package/lib/built-in/system-settings/SystemSettingsProvider.js +4 -3
- package/lib/built-in/system-settings/SystemSettingsShortcut.js +11 -8
- package/lib/collection-manager/Configuration/AddCollectionAction.js +12 -2
- package/lib/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.js +304 -0
- package/lib/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.js +130 -0
- package/lib/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.js +81 -0
- package/lib/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.js +78 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.js +414 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.js +53 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxImportAction.js +235 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.js +64 -0
- package/lib/collection-manager/collectionPlugin.js +3 -1
- package/lib/collection-manager/templates/import.js +1 -1
- package/lib/collection-manager/templates/xlsx.js +53 -0
- package/lib/locale/zh-CN.js +4 -1
- package/lib/modules/blocks/data-blocks/table/hooks/useTableBlockProps.js +4 -2
- package/lib/modules/fields/component/Radio/radioComponentFieldSettings.js +0 -4
- package/lib/schema-component/antd/action/Action.Designer.js +5 -2
- package/lib/schema-component/antd/action/Action.Modal.js +20 -31
- package/lib/schema-component/antd/action/Action.Modal.style.js +69 -0
- package/lib/schema-component/antd/action/utils.js +70 -70
- package/lib/schema-component/antd/checkbox/Checkbox.js +6 -1
- package/lib/schema-component/antd/page/Page.js +227 -146
- package/lib/schema-component/antd/page/Page.style.js +79 -0
- package/lib/schema-component/antd/page/PageDesigner.js +62 -0
- package/lib/schema-component/antd/page/PageTabDesigner.js +2 -50
- package/lib/schema-component/antd/page/style.js +3 -13
- package/lib/schema-component/antd/scroll-area/ScrollArea.js +2 -1
- package/lib/schema-component/antd/variable/TextArea.js +1 -1
- package/lib/schema-component/antd/variable/TextAreaWithGlobalScope.js +94 -0
- package/lib/schema-component/antd/variable/index.js +13 -1
- package/package.json +7 -7
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
|
|
2
|
+
const createXlsxCollectionSchema = (filelist, filedata)=>{
|
|
3
|
+
var _filelist_;
|
|
4
|
+
return {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {
|
|
7
|
+
[(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.uid)()]: {
|
|
8
|
+
type: 'void',
|
|
9
|
+
'x-decorator': 'FormV2',
|
|
10
|
+
'x-component': 'Action.Drawer',
|
|
11
|
+
'x-component-props': {
|
|
12
|
+
width: '70%'
|
|
13
|
+
},
|
|
14
|
+
'x-use-component-props': 'useFormBlockProps',
|
|
15
|
+
properties: {
|
|
16
|
+
action: {
|
|
17
|
+
type: 'void',
|
|
18
|
+
'x-component': 'ActionBar',
|
|
19
|
+
'x-component-props': {
|
|
20
|
+
layout: 'one-column',
|
|
21
|
+
style: {
|
|
22
|
+
justifyContent: 'right'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
properties: {
|
|
26
|
+
cancel: {
|
|
27
|
+
title: 'Cancel',
|
|
28
|
+
'x-component': 'Action',
|
|
29
|
+
'x-use-component-props': 'useCancelActionProps'
|
|
30
|
+
},
|
|
31
|
+
submit: {
|
|
32
|
+
title: '{{t("Submit")}}',
|
|
33
|
+
'x-component': 'Action',
|
|
34
|
+
'x-component-props': {
|
|
35
|
+
type: 'primary',
|
|
36
|
+
htmlType: 'submit'
|
|
37
|
+
},
|
|
38
|
+
'x-use-component-props': 'xlsxImportAction'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
title: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
default: null === (_filelist_ = filelist[0]) || void 0 === _filelist_ ? void 0 : _filelist_.name.replace(/\.[^/.]+$/, ''),
|
|
45
|
+
title: '{{ t("Collection display name") }}',
|
|
46
|
+
required: true,
|
|
47
|
+
'x-decorator': 'FormItem',
|
|
48
|
+
'x-component': 'Input'
|
|
49
|
+
},
|
|
50
|
+
name: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
title: '{{t("Collection name")}}',
|
|
53
|
+
default: '{{ useNewId("t_") }}',
|
|
54
|
+
required: true,
|
|
55
|
+
'x-decorator': 'FormItem',
|
|
56
|
+
'x-component': 'Input',
|
|
57
|
+
'x-validator': 'uid',
|
|
58
|
+
description: "{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"
|
|
59
|
+
},
|
|
60
|
+
category: {
|
|
61
|
+
title: '{{t("Categories")}}',
|
|
62
|
+
type: 'hasMany',
|
|
63
|
+
name: 'category',
|
|
64
|
+
'x-decorator': 'FormItem',
|
|
65
|
+
'x-component': 'Select',
|
|
66
|
+
'x-component-props': {
|
|
67
|
+
mode: 'multiple'
|
|
68
|
+
},
|
|
69
|
+
'x-reactions': [
|
|
70
|
+
'{{useAsyncDataSource(loadCategories)}}'
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
description: {
|
|
74
|
+
title: '{{t("Description")}}',
|
|
75
|
+
type: 'string',
|
|
76
|
+
name: 'description',
|
|
77
|
+
'x-decorator': 'FormItem',
|
|
78
|
+
'x-component': 'Input.TextArea'
|
|
79
|
+
},
|
|
80
|
+
fields: {
|
|
81
|
+
type: 'array',
|
|
82
|
+
title: '{{t("Fields")}}',
|
|
83
|
+
default: filedata.fields,
|
|
84
|
+
'x-decorator': 'FormItem',
|
|
85
|
+
'x-component': 'xlsxFieldsConfigure',
|
|
86
|
+
'x-component-props': {
|
|
87
|
+
filedata
|
|
88
|
+
},
|
|
89
|
+
required: true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export { createXlsxCollectionSchema };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__ from "../../../api-client/index.mjs";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../schema-component/index.mjs";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../../hooks/index.mjs";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__ResourceActionProvider_mjs__ from "../../ResourceActionProvider.mjs";
|
|
9
|
+
const xlsxImportAction = ()=>{
|
|
10
|
+
const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
|
|
11
|
+
const ctx = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useActionContext)();
|
|
12
|
+
const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
|
|
13
|
+
const api = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useAPIClient)();
|
|
14
|
+
const { refresh } = (0, __WEBPACK_EXTERNAL_MODULE__ResourceActionProvider_mjs__.useResourceActionContext)();
|
|
15
|
+
const { refreshCM } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useCollectionManager_deprecated)();
|
|
16
|
+
const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
|
|
17
|
+
return {
|
|
18
|
+
async onClick () {
|
|
19
|
+
field.data = field.data || {};
|
|
20
|
+
field.data.loading = true;
|
|
21
|
+
try {
|
|
22
|
+
await form.submit();
|
|
23
|
+
const values = (0, __WEBPACK_EXTERNAL_MODULE_lodash__.cloneDeep)(form.values);
|
|
24
|
+
const { collectionData, ...collections } = values;
|
|
25
|
+
if (!collections.autoCreateReverseField) delete collections.reverseField;
|
|
26
|
+
delete collections.autoCreateReverseField;
|
|
27
|
+
await api.resource('collections').create({
|
|
28
|
+
values: {
|
|
29
|
+
logging: true,
|
|
30
|
+
...collections
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
api.resource("".concat(collections.name)).create({
|
|
34
|
+
values: collectionData
|
|
35
|
+
});
|
|
36
|
+
ctx.setVisible(false);
|
|
37
|
+
null == refresh || refresh();
|
|
38
|
+
await refreshCM();
|
|
39
|
+
field.data.loading = false;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
field.data.loading = false;
|
|
42
|
+
__WEBPACK_EXTERNAL_MODULE_antd__.message.error(t('Operation failed'));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export { xlsxImportAction };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../schema-component/index.mjs";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__xlsxFormValueContextProvider_mjs__ from "./xlsxFormValueContextProvider.mjs";
|
|
7
|
+
const setUpdateXlsxCollectionField = ()=>{
|
|
8
|
+
const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
|
|
9
|
+
const { value, setFormValue } = (0, __WEBPACK_EXTERNAL_MODULE__xlsxFormValueContextProvider_mjs__.useFormValueContext)();
|
|
10
|
+
const ctx = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useActionContext)();
|
|
11
|
+
const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
|
|
12
|
+
const handleFieldChange = (index, updatedField)=>{
|
|
13
|
+
const updatedFieldData = [
|
|
14
|
+
...value
|
|
15
|
+
];
|
|
16
|
+
if (updatedField.primaryKey) {
|
|
17
|
+
const existingPrimaryKey = updatedFieldData.find((field, i)=>true === field.primaryKey && i !== index);
|
|
18
|
+
if (existingPrimaryKey) {
|
|
19
|
+
__WEBPACK_EXTERNAL_MODULE_antd__.message.error(t('existingPrimaryKeyError', {
|
|
20
|
+
name: existingPrimaryKey.name
|
|
21
|
+
}));
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
updatedFieldData[index] = updatedField;
|
|
26
|
+
setFormValue(updatedFieldData);
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
async onClick () {
|
|
30
|
+
await form.submit();
|
|
31
|
+
const values = (0, __WEBPACK_EXTERNAL_MODULE_lodash__.cloneDeep)(form.values);
|
|
32
|
+
values.autoCreateReverseField || delete values.reverseField;
|
|
33
|
+
delete values.autoCreateReverseField;
|
|
34
|
+
const { index, ...updatedField } = values;
|
|
35
|
+
if (index < 0 || index >= value.length) {
|
|
36
|
+
__WEBPACK_EXTERNAL_MODULE_antd__.message.error('Invalid field index');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
handleFieldChange(index, updatedField);
|
|
40
|
+
ctx.setVisible(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export { setUpdateXlsxCollectionField };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const xlsxFieldsConfigure: import("react").MemoExoticComponent<import("@tachybase/schema").ReactFC<Omit<any, "ref">>>;
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../../data-source/index.mjs";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../schema-component/index.mjs";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../../hooks/index.mjs";
|
|
10
|
+
import * as __WEBPACK_EXTERNAL_MODULE__interfaces_mjs__ from "../interfaces.mjs";
|
|
11
|
+
import * as __WEBPACK_EXTERNAL_MODULE__xlsxFormValueContextProvider_mjs__ from "./xlsxFormValueContextProvider.mjs";
|
|
12
|
+
import * as __WEBPACK_EXTERNAL_MODULE__xlsxImportAction_mjs__ from "./xlsxImportAction.mjs";
|
|
13
|
+
const xlsxFieldsConfigure = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)((props)=>{
|
|
14
|
+
const { filedata } = props;
|
|
15
|
+
const { fields, data } = filedata;
|
|
16
|
+
(0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useDataSourceManager)();
|
|
17
|
+
const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
|
|
18
|
+
const initOptions = (0, __WEBPACK_EXTERNAL_MODULE__interfaces_mjs__.useFieldInterfaceOptions)();
|
|
19
|
+
const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
|
|
20
|
+
const [selectedTitleField, setSelectedTitleField] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)();
|
|
21
|
+
const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
|
|
22
|
+
const [formValue, setFormValue] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(fields);
|
|
23
|
+
const { getInterface } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useCollectionManager_deprecated)();
|
|
24
|
+
const getDefaultUiSchema = (interfaceType, title)=>{
|
|
25
|
+
var _interfaceConfigValues_default;
|
|
26
|
+
const interfaceConfig = getInterface(interfaceType) || {};
|
|
27
|
+
const interfaceConfigValues = (0, __WEBPACK_EXTERNAL_MODULE_lodash__.cloneDeep)(interfaceConfig);
|
|
28
|
+
const defaultUiSchema = (null == interfaceConfigValues ? void 0 : null === (_interfaceConfigValues_default = interfaceConfigValues.default) || void 0 === _interfaceConfigValues_default ? void 0 : _interfaceConfigValues_default.uiSchema) || {};
|
|
29
|
+
return {
|
|
30
|
+
...defaultUiSchema,
|
|
31
|
+
title
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const handleFieldChange = (updatedField, index)=>{
|
|
35
|
+
const updatedFieldData = [
|
|
36
|
+
...formValue
|
|
37
|
+
];
|
|
38
|
+
updatedFieldData[index] = updatedField;
|
|
39
|
+
setFormValue(updatedFieldData);
|
|
40
|
+
};
|
|
41
|
+
const handleFieldTypeChange = async (updatedField, index)=>{
|
|
42
|
+
const { type, name: dataIndex, uiSchema } = updatedField;
|
|
43
|
+
const updatedData = [
|
|
44
|
+
...data
|
|
45
|
+
];
|
|
46
|
+
let hasError = false;
|
|
47
|
+
const typeToInterface = {
|
|
48
|
+
json: 'json',
|
|
49
|
+
boolean: 'checkbox',
|
|
50
|
+
string: 'input',
|
|
51
|
+
integer: 'integer',
|
|
52
|
+
float: 'number',
|
|
53
|
+
date: 'datetime'
|
|
54
|
+
};
|
|
55
|
+
updatedField.interface = await typeToInterface[type] || null;
|
|
56
|
+
const currentUiSchema = await getDefaultUiSchema(updatedField.interface, uiSchema.title);
|
|
57
|
+
updatedField.uiSchema = currentUiSchema;
|
|
58
|
+
updatedData.forEach((row, rowIndex)=>{
|
|
59
|
+
try {
|
|
60
|
+
if (void 0 !== row[dataIndex]) row[dataIndex] = parseValue(row[dataIndex], type);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
hasError = true;
|
|
63
|
+
__WEBPACK_EXTERNAL_MODULE_antd__.message.error("Row ".concat(rowIndex + 1, ", Column ").concat(uiSchema.title, ": ").concat(error.message));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
if (!hasError) {
|
|
67
|
+
__WEBPACK_EXTERNAL_MODULE_antd__.message.success("".concat(t('Fields'), ' "').concat(uiSchema.title, '"').concat(t('Converted to'), " ").concat(type));
|
|
68
|
+
const updatedFieldData = [
|
|
69
|
+
...formValue
|
|
70
|
+
];
|
|
71
|
+
updatedFieldData[index] = updatedField;
|
|
72
|
+
setFormValue(updatedFieldData);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const handleFieldInterfaceChange = async (updatedField, index)=>{
|
|
76
|
+
const currentUiSchema = await getDefaultUiSchema(updatedField.interface, updatedField.uiSchema.title);
|
|
77
|
+
updatedField.uiSchema = currentUiSchema;
|
|
78
|
+
const updatedFieldData = [
|
|
79
|
+
...formValue
|
|
80
|
+
];
|
|
81
|
+
updatedFieldData[index] = updatedField;
|
|
82
|
+
setFormValue(updatedFieldData);
|
|
83
|
+
};
|
|
84
|
+
const parseValue = (value, type)=>{
|
|
85
|
+
try {
|
|
86
|
+
switch(type){
|
|
87
|
+
case 'boolean':
|
|
88
|
+
if ('true' === value.toLowerCase()) return true;
|
|
89
|
+
if ('false' === value.toLowerCase()) return false;
|
|
90
|
+
throw new Error('Invalid boolean');
|
|
91
|
+
case 'integer':
|
|
92
|
+
if (!/^-?\d+$/.test(value)) throw new Error('Invalid integer');
|
|
93
|
+
return parseInt(value, 10);
|
|
94
|
+
case 'float':
|
|
95
|
+
if (!/^-?\d+(\.\d+)?$/.test(value)) throw new Error('Invalid number');
|
|
96
|
+
return Number(value);
|
|
97
|
+
case 'json':
|
|
98
|
+
return JSON.parse(value);
|
|
99
|
+
case 'date':
|
|
100
|
+
if (isNaN(Date.parse(value))) throw new Error('Invalid date');
|
|
101
|
+
return new Date(value);
|
|
102
|
+
default:
|
|
103
|
+
if (null == value || '' === value) return '';
|
|
104
|
+
return value.toString();
|
|
105
|
+
}
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new Error("Type conversion error: ".concat(error.message));
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const handleTitleChange = (checked, field)=>{
|
|
111
|
+
const newTitleField = checked ? field.name : null;
|
|
112
|
+
setSelectedTitleField(newTitleField);
|
|
113
|
+
form.setValuesIn('titleField', newTitleField);
|
|
114
|
+
};
|
|
115
|
+
const isTitleField = (field)=>{
|
|
116
|
+
var _getInterface;
|
|
117
|
+
return !field.isForeignKey && (null === (_getInterface = getInterface(field.interface)) || void 0 === _getInterface ? void 0 : _getInterface.titleUsable);
|
|
118
|
+
};
|
|
119
|
+
const getOptions = (type)=>{
|
|
120
|
+
const InterfaceOptions = getInterfaceOptions(initOptions, type);
|
|
121
|
+
const options = InterfaceOptions.map((group)=>({
|
|
122
|
+
label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
123
|
+
children: compile(group.label)
|
|
124
|
+
}),
|
|
125
|
+
title: group.key,
|
|
126
|
+
options: group.children.map((item)=>({
|
|
127
|
+
label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
128
|
+
children: compile(item.label)
|
|
129
|
+
}),
|
|
130
|
+
value: item.name
|
|
131
|
+
}))
|
|
132
|
+
}));
|
|
133
|
+
return options;
|
|
134
|
+
};
|
|
135
|
+
const getInterfaceOptions = (data, type)=>{
|
|
136
|
+
const interfaceOptions = [];
|
|
137
|
+
data.forEach((item)=>{
|
|
138
|
+
const options = item.children.filter((h)=>{
|
|
139
|
+
var _h_availableTypes;
|
|
140
|
+
return null == h ? void 0 : null === (_h_availableTypes = h.availableTypes) || void 0 === _h_availableTypes ? void 0 : _h_availableTypes.includes(type);
|
|
141
|
+
});
|
|
142
|
+
interfaceOptions.push({
|
|
143
|
+
label: item.label,
|
|
144
|
+
key: item.key,
|
|
145
|
+
children: options
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
return interfaceOptions.filter((v)=>{
|
|
149
|
+
if ('sort' === type) return 'advanced' === v.key;
|
|
150
|
+
return v.children.length > 0;
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
const columns = [
|
|
154
|
+
{
|
|
155
|
+
title: t('Field display name'),
|
|
156
|
+
dataIndex: 'title',
|
|
157
|
+
key: 'title',
|
|
158
|
+
render: (text, record, index)=>{
|
|
159
|
+
const field = formValue[index];
|
|
160
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Input, {
|
|
161
|
+
value: field.uiSchema.title || text,
|
|
162
|
+
onChange: (e)=>handleFieldChange({
|
|
163
|
+
...field,
|
|
164
|
+
uiSchema: {
|
|
165
|
+
title: e.target.value
|
|
166
|
+
}
|
|
167
|
+
}, index)
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
title: t('Field name'),
|
|
173
|
+
dataIndex: 'name',
|
|
174
|
+
key: 'name',
|
|
175
|
+
render: (text, record, index)=>{
|
|
176
|
+
const field = formValue[index];
|
|
177
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Input, {
|
|
178
|
+
value: field.name || text,
|
|
179
|
+
variant: "borderless",
|
|
180
|
+
disabled: true
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
title: t('Field type'),
|
|
186
|
+
dataIndex: 'type',
|
|
187
|
+
key: 'type',
|
|
188
|
+
render: (text, record, index)=>{
|
|
189
|
+
const field = formValue[index];
|
|
190
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Select, {
|
|
191
|
+
value: field.type || text,
|
|
192
|
+
onChange: (e)=>handleFieldTypeChange({
|
|
193
|
+
...field,
|
|
194
|
+
type: e
|
|
195
|
+
}, index),
|
|
196
|
+
options: [
|
|
197
|
+
{
|
|
198
|
+
value: 'string',
|
|
199
|
+
label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
200
|
+
children: "string"
|
|
201
|
+
})
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
value: 'boolean',
|
|
205
|
+
label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
206
|
+
children: "boolean"
|
|
207
|
+
})
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
value: 'integer',
|
|
211
|
+
label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
212
|
+
children: "integer"
|
|
213
|
+
})
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
value: 'float',
|
|
217
|
+
label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
218
|
+
children: "float"
|
|
219
|
+
})
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
value: 'json',
|
|
223
|
+
label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
224
|
+
children: "json"
|
|
225
|
+
})
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
value: 'date',
|
|
229
|
+
label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
230
|
+
children: "date"
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
title: t('Field interface'),
|
|
239
|
+
dataIndex: 'interface',
|
|
240
|
+
key: 'interface',
|
|
241
|
+
render: (text, record, index)=>{
|
|
242
|
+
const field = formValue[index];
|
|
243
|
+
const options = getOptions(field.type);
|
|
244
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Select, {
|
|
245
|
+
"aria-label": "field-interface-".concat(null == field ? void 0 : field.type),
|
|
246
|
+
role: "button",
|
|
247
|
+
value: field.interface,
|
|
248
|
+
popupMatchSelectWidth: false,
|
|
249
|
+
onChange: (e)=>handleFieldInterfaceChange({
|
|
250
|
+
...field,
|
|
251
|
+
interface: e
|
|
252
|
+
}, index),
|
|
253
|
+
options: options
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
dataIndex: 'titleField',
|
|
259
|
+
title: t('Title field'),
|
|
260
|
+
render: function(_, record, index) {
|
|
261
|
+
const field = formValue[index];
|
|
262
|
+
return isTitleField(field) ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Tooltip, {
|
|
263
|
+
title: t('Default title for each record'),
|
|
264
|
+
placement: "right",
|
|
265
|
+
overlayInnerStyle: {
|
|
266
|
+
textAlign: 'center'
|
|
267
|
+
},
|
|
268
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Switch, {
|
|
269
|
+
"aria-label": "switch-title-field-".concat(field.name),
|
|
270
|
+
size: "small",
|
|
271
|
+
checked: field.name === selectedTitleField,
|
|
272
|
+
onChange: (checked)=>handleTitleChange(checked, field)
|
|
273
|
+
})
|
|
274
|
+
}) : null;
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
title: t('Description'),
|
|
279
|
+
dataIndex: 'description',
|
|
280
|
+
key: 'description',
|
|
281
|
+
render: (text, record, index)=>{
|
|
282
|
+
const field = formValue[index];
|
|
283
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Input.TextArea, {
|
|
284
|
+
value: field.description,
|
|
285
|
+
variant: "borderless",
|
|
286
|
+
disabled: true
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
title: t('Actions'),
|
|
292
|
+
dataIndex: 'actions',
|
|
293
|
+
key: 'actions',
|
|
294
|
+
render: (text, record, index)=>{
|
|
295
|
+
const field = formValue[index];
|
|
296
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Space, {
|
|
297
|
+
size: "middle",
|
|
298
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__xlsxImportAction_mjs__.XlsxEditFieldAction, {
|
|
299
|
+
record: {
|
|
300
|
+
index,
|
|
301
|
+
...field
|
|
302
|
+
},
|
|
303
|
+
...props
|
|
304
|
+
})
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
];
|
|
309
|
+
const previewTablecolumns = formValue.map((field)=>({
|
|
310
|
+
title: field.uiSchema.title,
|
|
311
|
+
dataIndex: field.name,
|
|
312
|
+
key: field.name,
|
|
313
|
+
render: (text)=>{
|
|
314
|
+
if ('boolean' == typeof text) return text ? 'True' : 'False';
|
|
315
|
+
if ('date' === field.type && text) return new Date(text).toLocaleString();
|
|
316
|
+
if ('json' === field.type && text) try {
|
|
317
|
+
return 'string' == typeof text ? text : JSON.stringify(text, null, 2);
|
|
318
|
+
} catch (error) {
|
|
319
|
+
return 'Invalid JSON';
|
|
320
|
+
}
|
|
321
|
+
return text;
|
|
322
|
+
},
|
|
323
|
+
width: 200
|
|
324
|
+
}));
|
|
325
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
326
|
+
form.setValuesIn('fields', formValue);
|
|
327
|
+
form.setValuesIn('collectionData', filedata.data);
|
|
328
|
+
console.log('%c Line:294 🍔 filedata.data', 'font-size:18px;color:#42b983;background:#3f7cff', filedata.data);
|
|
329
|
+
}, [
|
|
330
|
+
formValue
|
|
331
|
+
]);
|
|
332
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE__xlsxFormValueContextProvider_mjs__.xlsxFormValueContext.Provider, {
|
|
333
|
+
value: {
|
|
334
|
+
value: formValue,
|
|
335
|
+
setFormValue
|
|
336
|
+
},
|
|
337
|
+
children: [
|
|
338
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Table, {
|
|
339
|
+
bordered: true,
|
|
340
|
+
size: "small",
|
|
341
|
+
columns: columns,
|
|
342
|
+
dataSource: formValue,
|
|
343
|
+
scroll: {
|
|
344
|
+
y: 300
|
|
345
|
+
},
|
|
346
|
+
pagination: false,
|
|
347
|
+
rowClassName: "row",
|
|
348
|
+
rowKey: "uid",
|
|
349
|
+
style: {
|
|
350
|
+
marginBottom: '16px'
|
|
351
|
+
},
|
|
352
|
+
...props
|
|
353
|
+
}),
|
|
354
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
|
|
355
|
+
style: {
|
|
356
|
+
fontWeight: 'bold',
|
|
357
|
+
marginBottom: '10px'
|
|
358
|
+
},
|
|
359
|
+
children: [
|
|
360
|
+
t('Preview'),
|
|
361
|
+
":"
|
|
362
|
+
]
|
|
363
|
+
}),
|
|
364
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Table, {
|
|
365
|
+
bordered: true,
|
|
366
|
+
size: "small",
|
|
367
|
+
columns: previewTablecolumns,
|
|
368
|
+
dataSource: filedata.data,
|
|
369
|
+
scroll: {
|
|
370
|
+
y: 300,
|
|
371
|
+
x: 'max-content'
|
|
372
|
+
},
|
|
373
|
+
rowKey: "name"
|
|
374
|
+
})
|
|
375
|
+
]
|
|
376
|
+
});
|
|
377
|
+
}, {
|
|
378
|
+
displayName: 'FieldsConfigure'
|
|
379
|
+
});
|
|
380
|
+
export { xlsxFieldsConfigure };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
const xlsxFormValueContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext({});
|
|
3
|
+
const useFormValueContext = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(xlsxFormValueContext);
|
|
4
|
+
export { useFormValueContext, xlsxFormValueContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const XlsxEditFieldAction: (props: any) => import("react/jsx-runtime").JSX.Element;
|