@tachybase/plugin-action-import 0.23.8
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/.turbo/turbo-build.log +14 -0
- package/README.md +222 -0
- package/README.zh-CN.md +222 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/ImportActionInitializer.d.ts +8 -0
- package/dist/client/ImportDesigner.d.ts +2 -0
- package/dist/client/ImportModal.d.ts +6 -0
- package/dist/client/ImportPluginProvider.d.ts +3 -0
- package/dist/client/constants.d.ts +1 -0
- package/dist/client/context.d.ts +28 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +24 -0
- package/dist/client/locale/index.d.ts +0 -0
- package/dist/client/schemaSettings.d.ts +2 -0
- package/dist/client/useFields.d.ts +1 -0
- package/dist/client/useImportAction.d.ts +6 -0
- package/dist/client/useShared.d.ts +75 -0
- package/dist/externalVersion.js +16 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +43 -0
- package/dist/locale/en-US.json +27 -0
- package/dist/locale/es-ES.json +27 -0
- package/dist/locale/ko_KR.json +28 -0
- package/dist/locale/pt-BR.json +27 -0
- package/dist/locale/zh-CN.json +28 -0
- package/dist/node_modules/node-xlsx/dist/bin/cli.cjs +95 -0
- package/dist/node_modules/node-xlsx/dist/bin/cli.d.cts +1 -0
- package/dist/node_modules/node-xlsx/dist/bin/cli.d.ts +1 -0
- package/dist/node_modules/node-xlsx/dist/bin/cli.js +37 -0
- package/dist/node_modules/node-xlsx/dist/chunk-ID6OMQGT.js +78 -0
- package/dist/node_modules/node-xlsx/dist/index.cjs +7 -0
- package/dist/node_modules/node-xlsx/dist/index.d.cts +46 -0
- package/dist/node_modules/node-xlsx/dist/index.d.ts +46 -0
- package/dist/node_modules/node-xlsx/dist/index.js +13 -0
- package/dist/node_modules/node-xlsx/node_modules/.bin/xlsx +17 -0
- package/dist/node_modules/node-xlsx/package.json +1 -0
- package/dist/node_modules/xlsx/LICENSE +201 -0
- package/dist/node_modules/xlsx/bin/xlsx.njs +310 -0
- package/dist/node_modules/xlsx/bower.json +22 -0
- package/dist/node_modules/xlsx/dist/cpexcel.js +1506 -0
- package/dist/node_modules/xlsx/dist/shim.min.js +2 -0
- package/dist/node_modules/xlsx/dist/xlsx.core.min.js +15 -0
- package/dist/node_modules/xlsx/dist/xlsx.extendscript.js +24642 -0
- package/dist/node_modules/xlsx/dist/xlsx.full.min.js +22 -0
- package/dist/node_modules/xlsx/dist/xlsx.mini.min.js +9 -0
- package/dist/node_modules/xlsx/dist/xlsx.zahl.js +4 -0
- package/dist/node_modules/xlsx/node_modules/.bin/crc32 +17 -0
- package/dist/node_modules/xlsx/package.json +1 -0
- package/dist/node_modules/xlsx/types/index.d.ts +900 -0
- package/dist/node_modules/xlsx/xlsx.js +7 -0
- package/dist/node_modules/xlsx/xlsxworker.js +14 -0
- package/dist/server/actions/downloadXlsxTemplate.d.ts +2 -0
- package/dist/server/actions/downloadXlsxTemplate.js +62 -0
- package/dist/server/actions/importXlsx.d.ts +2 -0
- package/dist/server/actions/importXlsx.js +187 -0
- package/dist/server/actions/index.d.ts +2 -0
- package/dist/server/actions/index.js +23 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +53 -0
- package/dist/server/locale/en-US.d.ts +11 -0
- package/dist/server/locale/en-US.js +32 -0
- package/dist/server/locale/fr-FR.d.ts +11 -0
- package/dist/server/locale/fr-FR.js +32 -0
- package/dist/server/locale/index.d.ts +2 -0
- package/dist/server/locale/index.js +40 -0
- package/dist/server/locale/zh-CN.d.ts +12 -0
- package/dist/server/locale/zh-CN.js +33 -0
- package/dist/server/middleware/index.d.ts +2 -0
- package/dist/server/middleware/index.js +34 -0
- package/dist/server/utils/index.d.ts +6 -0
- package/dist/server/utils/index.js +54 -0
- package/dist/server/utils/transform.d.ts +84 -0
- package/dist/server/utils/transform.js +226 -0
- package/dist/swagger/index.json +33 -0
- package/package.json +39 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @tachybase/plugin-import@0.22.38 build /Users/seal/Documents/projects/tachybase/packages/plugin-action-import
|
|
4
|
+
> tachybase-build --no-dts @tachybase/plugin-import
|
|
5
|
+
|
|
6
|
+
[33m[33mThe CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m[39m
|
|
7
|
+
[4m[95m@tachybase/plugin-import[39m[24m: [1mplugin-action-import[22m build start
|
|
8
|
+
[4m[95m@tachybase/plugin-import[39m[24m: build plugin client
|
|
9
|
+
[2K[1G[4m[95m@tachybase/plugin-import[39m[24m: build plugin server source
|
|
10
|
+
[4m[95m@tachybase/plugin-import[39m[24m: delete server files
|
|
11
|
+
[4m[95m@tachybase/plugin-import[39m[24m: build plugin server dependencies
|
|
12
|
+
[4m[95m@tachybase/plugin-import[39m[24m: These packages [33mnode-xlsx, xlsx[39m will be [3mbundled[23m to dist/node_modules. These packages [33m@tachybase/server, @tachybase/actions, @tachybase/database, @tachybase/utils, lodash, mathjs[39m will be [3mexclude[23m. For more information, please refer to: [34mhttps://docs.tachybase.com/development/deps[39m.
|
|
13
|
+
[4m[95m@tachybase/plugin-import[39m[24m: write external version
|
|
14
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# import
|
|
2
|
+
|
|
3
|
+
English | [中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Excel 数据导入插件。
|
|
6
|
+
|
|
7
|
+
## 安装激活
|
|
8
|
+
|
|
9
|
+
内置插件无需手动安装激活。
|
|
10
|
+
|
|
11
|
+
## 导入说明
|
|
12
|
+
|
|
13
|
+
### 数字类型字段
|
|
14
|
+
|
|
15
|
+
支持数字和百分比,`N/A` 或 `-` 的文案会被过滤掉
|
|
16
|
+
|
|
17
|
+
| 数字1 | 百分比 | 数字2 | 数字3 |
|
|
18
|
+
| -- | -- | -- | -- |
|
|
19
|
+
| 123 | 25% | N/A | - |
|
|
20
|
+
|
|
21
|
+
转 JSON 之后为
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
{
|
|
25
|
+
"数字1": 123,
|
|
26
|
+
"百分比": 0.25,
|
|
27
|
+
"数字2": null,
|
|
28
|
+
"数字3": null,
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 布尔类型字段
|
|
33
|
+
|
|
34
|
+
输入文案支持(英文不区分大小写):
|
|
35
|
+
|
|
36
|
+
- `Yes` `Y` `True` `1` `是`
|
|
37
|
+
- `No` `N` `False` `0` `否`
|
|
38
|
+
|
|
39
|
+
| 字段1 | 字段2 | 字段3 | 字段4 | 字段4 |
|
|
40
|
+
| -- | -- | -- | -- | -- |
|
|
41
|
+
| 否 | 是 | Y | true | 0 |
|
|
42
|
+
|
|
43
|
+
转 JSON 之后为
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
{
|
|
47
|
+
"字段1": false,
|
|
48
|
+
"字段2": true,
|
|
49
|
+
"字段3": true,
|
|
50
|
+
"字段4": true,
|
|
51
|
+
"字段5": false,
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 日期类型字段
|
|
56
|
+
|
|
57
|
+
| DateOnly | Local(+08:00) | GMT |
|
|
58
|
+
| -- | -- | -- |
|
|
59
|
+
| 2023-01-18 22:22:22 | 2023-01-18 22:22:22 | 2023-01-18 22:22:22 |
|
|
60
|
+
|
|
61
|
+
转 JSON 之后为
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
{
|
|
65
|
+
"DateOnly": "2023-01-18T00:00:00.000Z",
|
|
66
|
+
"Local(+08:00)": "2023-01-18T14:22:22.000Z",
|
|
67
|
+
"GMT": "2023-01-18T22:22:22.000Z",
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 选择类型字段
|
|
72
|
+
|
|
73
|
+
选项值和选项标签都可作为导入文案,多个选项之间以以逗号(`,` `,`)或顿号(`、`)区分
|
|
74
|
+
|
|
75
|
+
如字段 `优先级` 的可选项包括:
|
|
76
|
+
|
|
77
|
+
| 选项值 | 选项标签 |
|
|
78
|
+
| -- | -- |
|
|
79
|
+
| low | 低 |
|
|
80
|
+
| medium | 中 |
|
|
81
|
+
| high | 低 |
|
|
82
|
+
|
|
83
|
+
选项值和选项标签都可作为导入文案
|
|
84
|
+
|
|
85
|
+
| 优先级 |
|
|
86
|
+
| -- |
|
|
87
|
+
| 高 |
|
|
88
|
+
| low |
|
|
89
|
+
|
|
90
|
+
转 JSON 之后为
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
[
|
|
94
|
+
{ "优先级": "high" },
|
|
95
|
+
{ "优先级": "low" },
|
|
96
|
+
]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 中国行政区字段
|
|
100
|
+
|
|
101
|
+
| 地区1 | 地区2 |
|
|
102
|
+
| -- | -- |
|
|
103
|
+
| 北京市/市辖区 | 天津市/市辖区 |
|
|
104
|
+
|
|
105
|
+
转 JSON 之后为
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
{
|
|
109
|
+
"地区1": ["11","1101"],
|
|
110
|
+
"地区2": ["12","1201"]
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 附件字段
|
|
115
|
+
|
|
116
|
+
| 附件 |
|
|
117
|
+
| --|
|
|
118
|
+
| https://www.tachybase.com/images/logo.png |
|
|
119
|
+
|
|
120
|
+
转 JSON 之后为
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
{
|
|
124
|
+
"附件": [
|
|
125
|
+
{
|
|
126
|
+
"filename": "logo.png",
|
|
127
|
+
"title": "logo.png",
|
|
128
|
+
"extname": ".png",
|
|
129
|
+
"url": "https://www.tachybase.com/images/logo.png"
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 关系类型字段
|
|
136
|
+
|
|
137
|
+
多条数据以逗号(`,` `,`)或顿号(`、`)区分
|
|
138
|
+
|
|
139
|
+
| 部门/名称 | 分类/标题 |
|
|
140
|
+
| -- | -- |
|
|
141
|
+
| 开发组 | 分类1、分类2 |
|
|
142
|
+
|
|
143
|
+
转 JSON 之后为
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
{
|
|
147
|
+
"部门": [1], // 1 为部门名称为「开发组」的记录 ID
|
|
148
|
+
"分类": [1,2], // 1,2 为分类标题为「分类1」和「分类2」的记录 ID
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### JSON 类型字段
|
|
153
|
+
|
|
154
|
+
| JSON1 |
|
|
155
|
+
| -- |
|
|
156
|
+
| {"key":"value"} |
|
|
157
|
+
|
|
158
|
+
转 JSON 之后为
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
{
|
|
162
|
+
"JSON": {"key":"value"}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 地图几何图形类型
|
|
167
|
+
|
|
168
|
+
| Point | Line | Polygon | Circle |
|
|
169
|
+
| -- | -- | -- | -- |
|
|
170
|
+
| 1,2 | (1,2),(3,4) | (1,2),(3,4),(1,2) | 1,2,3 |
|
|
171
|
+
|
|
172
|
+
转 JSON 之后为
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
{
|
|
176
|
+
"Point": [1,2],
|
|
177
|
+
"Line": [[1,2], [3,4]],
|
|
178
|
+
"Polygon": [[1,2], [3,4], [1,2]],
|
|
179
|
+
"Circle": [1,2,3]
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 自定义导入格式
|
|
184
|
+
|
|
185
|
+
通过 `db.registerFieldValueParsers()` 方法注册自定义的 `ValueParser`,如:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { BaseValueParser } from '@tachybase/database';
|
|
189
|
+
|
|
190
|
+
class PointValueParser extends BaseValueParser {
|
|
191
|
+
async setValue(value) {
|
|
192
|
+
if (Array.isArray(value)) {
|
|
193
|
+
this.value = value;
|
|
194
|
+
} else if (typeof value === 'string') {
|
|
195
|
+
this.value = value.split(',');
|
|
196
|
+
} else {
|
|
197
|
+
this.errors.push('Value invalid');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const db = new Database();
|
|
203
|
+
|
|
204
|
+
// type=point 的字段导入时,将通过 PointValueParser 解析数据
|
|
205
|
+
db.registerFieldValueParsers({
|
|
206
|
+
point: PointValueParser,
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
导入示例
|
|
211
|
+
|
|
212
|
+
| Point |
|
|
213
|
+
| --|
|
|
214
|
+
| 1,2 |
|
|
215
|
+
|
|
216
|
+
转 JSON 之后为
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
{
|
|
220
|
+
"Point": [1,2]
|
|
221
|
+
}
|
|
222
|
+
```
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# import
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 中文
|
|
4
|
+
|
|
5
|
+
Excel 数据导入插件。
|
|
6
|
+
|
|
7
|
+
## 安装激活
|
|
8
|
+
|
|
9
|
+
内置插件无需手动安装激活。
|
|
10
|
+
|
|
11
|
+
## 导入说明
|
|
12
|
+
|
|
13
|
+
### 数字类型字段
|
|
14
|
+
|
|
15
|
+
支持数字和百分比,`N/A` 或 `-` 的文案会被过滤掉
|
|
16
|
+
|
|
17
|
+
| 数字1 | 百分比 | 数字2 | 数字3 |
|
|
18
|
+
| -- | -- | -- | -- |
|
|
19
|
+
| 123 | 25% | N/A | - |
|
|
20
|
+
|
|
21
|
+
转 JSON 之后为
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
{
|
|
25
|
+
"数字1": 123,
|
|
26
|
+
"百分比": 0.25,
|
|
27
|
+
"数字2": null,
|
|
28
|
+
"数字3": null,
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 布尔类型字段
|
|
33
|
+
|
|
34
|
+
输入文案支持(英文不区分大小写):
|
|
35
|
+
|
|
36
|
+
- `Yes` `Y` `True` `1` `是`
|
|
37
|
+
- `No` `N` `False` `0` `否`
|
|
38
|
+
|
|
39
|
+
| 字段1 | 字段2 | 字段3 | 字段4 | 字段4 |
|
|
40
|
+
| -- | -- | -- | -- | -- |
|
|
41
|
+
| 否 | 是 | Y | true | 0 |
|
|
42
|
+
|
|
43
|
+
转 JSON 之后为
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
{
|
|
47
|
+
"字段1": false,
|
|
48
|
+
"字段2": true,
|
|
49
|
+
"字段3": true,
|
|
50
|
+
"字段4": true,
|
|
51
|
+
"字段5": false,
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 日期类型字段
|
|
56
|
+
|
|
57
|
+
| DateOnly | Local(+08:00) | GMT |
|
|
58
|
+
| -- | -- | -- |
|
|
59
|
+
| 2023-01-18 22:22:22 | 2023-01-18 22:22:22 | 2023-01-18 22:22:22 |
|
|
60
|
+
|
|
61
|
+
转 JSON 之后为
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
{
|
|
65
|
+
"DateOnly": "2023-01-18T00:00:00.000Z",
|
|
66
|
+
"Local(+08:00)": "2023-01-18T14:22:22.000Z",
|
|
67
|
+
"GMT": "2023-01-18T22:22:22.000Z",
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 选择类型字段
|
|
72
|
+
|
|
73
|
+
选项值和选项标签都可作为导入文案,多个选项之间以以逗号(`,` `,`)或顿号(`、`)区分
|
|
74
|
+
|
|
75
|
+
如字段 `优先级` 的可选项包括:
|
|
76
|
+
|
|
77
|
+
| 选项值 | 选项标签 |
|
|
78
|
+
| -- | -- |
|
|
79
|
+
| low | 低 |
|
|
80
|
+
| medium | 中 |
|
|
81
|
+
| high | 低 |
|
|
82
|
+
|
|
83
|
+
选项值和选项标签都可作为导入文案
|
|
84
|
+
|
|
85
|
+
| 优先级 |
|
|
86
|
+
| -- |
|
|
87
|
+
| 高 |
|
|
88
|
+
| low |
|
|
89
|
+
|
|
90
|
+
转 JSON 之后为
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
[
|
|
94
|
+
{ "优先级": "high" },
|
|
95
|
+
{ "优先级": "low" },
|
|
96
|
+
]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 中国行政区字段
|
|
100
|
+
|
|
101
|
+
| 地区1 | 地区2 |
|
|
102
|
+
| -- | -- |
|
|
103
|
+
| 北京市/市辖区 | 天津市/市辖区 |
|
|
104
|
+
|
|
105
|
+
转 JSON 之后为
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
{
|
|
109
|
+
"地区1": ["11","1101"],
|
|
110
|
+
"地区2": ["12","1201"]
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 附件字段
|
|
115
|
+
|
|
116
|
+
| 附件 |
|
|
117
|
+
| --|
|
|
118
|
+
| https://www.tachybase.com/images/logo.png |
|
|
119
|
+
|
|
120
|
+
转 JSON 之后为
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
{
|
|
124
|
+
"附件": [
|
|
125
|
+
{
|
|
126
|
+
"filename": "logo.png",
|
|
127
|
+
"title": "logo.png",
|
|
128
|
+
"extname": ".png",
|
|
129
|
+
"url": "https://www.tachybase.com/images/logo.png"
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 关系类型字段
|
|
136
|
+
|
|
137
|
+
多条数据以逗号(`,` `,`)或顿号(`、`)区分
|
|
138
|
+
|
|
139
|
+
| 部门/名称 | 分类/标题 |
|
|
140
|
+
| -- | -- |
|
|
141
|
+
| 开发组 | 分类1、分类2 |
|
|
142
|
+
|
|
143
|
+
转 JSON 之后为
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
{
|
|
147
|
+
"部门": [1], // 1 为部门名称为「开发组」的记录 ID
|
|
148
|
+
"分类": [1,2], // 1,2 为分类标题为「分类1」和「分类2」的记录 ID
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### JSON 类型字段
|
|
153
|
+
|
|
154
|
+
| JSON1 |
|
|
155
|
+
| -- |
|
|
156
|
+
| {"key":"value"} |
|
|
157
|
+
|
|
158
|
+
转 JSON 之后为
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
{
|
|
162
|
+
"JSON": {"key":"value"}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 地图几何图形类型
|
|
167
|
+
|
|
168
|
+
| Point | Line | Polygon | Circle |
|
|
169
|
+
| -- | -- | -- | -- |
|
|
170
|
+
| 1,2 | (1,2),(3,4) | (1,2),(3,4),(1,2) | 1,2,3 |
|
|
171
|
+
|
|
172
|
+
转 JSON 之后为
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
{
|
|
176
|
+
"Point": [1,2],
|
|
177
|
+
"Line": [[1,2], [3,4]],
|
|
178
|
+
"Polygon": [[1,2], [3,4], [1,2]],
|
|
179
|
+
"Circle": [1,2,3]
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 自定义导入格式
|
|
184
|
+
|
|
185
|
+
通过 `db.registerFieldValueParsers()` 方法注册自定义的 `ValueParser`,如:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { BaseValueParser } from '@tachybase/database';
|
|
189
|
+
|
|
190
|
+
class PointValueParser extends BaseValueParser {
|
|
191
|
+
async setValue(value) {
|
|
192
|
+
if (Array.isArray(value)) {
|
|
193
|
+
this.value = value;
|
|
194
|
+
} else if (typeof value === 'string') {
|
|
195
|
+
this.value = value.split(',');
|
|
196
|
+
} else {
|
|
197
|
+
this.errors.push('Value invalid');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const db = new Database();
|
|
203
|
+
|
|
204
|
+
// type=point 的字段导入时,将通过 PointValueParser 解析数据
|
|
205
|
+
db.registerFieldValueParsers({
|
|
206
|
+
point: PointValueParser,
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
导入示例
|
|
211
|
+
|
|
212
|
+
| Point |
|
|
213
|
+
| --|
|
|
214
|
+
| 1,2 |
|
|
215
|
+
|
|
216
|
+
转 JSON 之后为
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
{
|
|
220
|
+
"Point": [1,2]
|
|
221
|
+
}
|
|
222
|
+
```
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Schema } from '@tachybase/schema';
|
|
3
|
+
export declare const useCurrentSchema: (action: string, key: string, find?: (schema: Schema, key: string, action: string) => any, rm?: (schema: any, cb: any) => any) => {
|
|
4
|
+
schema: any;
|
|
5
|
+
exists: boolean;
|
|
6
|
+
remove(): void;
|
|
7
|
+
};
|
|
8
|
+
export declare const ImportActionInitializer: () => React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NAMESPACE = "action-import";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ImportContextType {
|
|
2
|
+
importModalVisible: boolean;
|
|
3
|
+
setImportModalVisible: (visible: boolean) => void;
|
|
4
|
+
importStatus: number;
|
|
5
|
+
setImportStatus: (status: number) => void;
|
|
6
|
+
importResult: {
|
|
7
|
+
data: {
|
|
8
|
+
type: string;
|
|
9
|
+
data: any[];
|
|
10
|
+
};
|
|
11
|
+
meta: {
|
|
12
|
+
successCount: number;
|
|
13
|
+
failureCount: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
setImportResult: (result: {
|
|
17
|
+
data: {
|
|
18
|
+
type: string;
|
|
19
|
+
data: any[];
|
|
20
|
+
};
|
|
21
|
+
meta: {
|
|
22
|
+
successCount: number;
|
|
23
|
+
failureCount: number;
|
|
24
|
+
};
|
|
25
|
+
}) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const ImportContext: import("react").Context<ImportContextType>;
|
|
28
|
+
export declare const useImportContext: () => ImportContextType;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Plugin } from '@tachybase/client';
|
|
2
|
+
export * from './ImportActionInitializer';
|
|
3
|
+
export * from './ImportDesigner';
|
|
4
|
+
export * from './ImportPluginProvider';
|
|
5
|
+
export * from './useImportAction';
|
|
6
|
+
export declare class ImportPlugin extends Plugin {
|
|
7
|
+
load(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export default ImportPlugin;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
(function(l,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("react-dom"),require("@ant-design/icons"),require("antd"),require("react-i18next"),require("@tachybase/schema"),require("lodash"),require("@tachybase/components")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","react-dom","@ant-design/icons","antd","react-i18next","@tachybase/schema","lodash","@tachybase/components"],o):(l=typeof globalThis!="undefined"?globalThis:l||self,o(l["@tachybase/plugin-action-import"]={},l["@tachybase/client"],l.jsxRuntime,l.react,l["react-dom"],l["@ant-design/icons"],l.antd,l["react-i18next"],l["@tachybase/schema"],l.lodash,l["@tachybase/components"]))})(this,function(l,o,d,T,L,k,E,F,g,B,z){"use strict";var ye=Object.defineProperty,ve=Object.defineProperties;var Se=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var de=(l,o,d)=>o in l?ye(l,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[o]=d,D=(l,o)=>{for(var d in o||(o={}))Ie.call(o,d)&&de(l,d,o[d]);if(le)for(var d of le(o))be.call(o,d)&&de(l,d,o[d]);return l},V=(l,o)=>ve(l,Se(o));var N=(l,o,d)=>new Promise((T,L)=>{var k=g=>{try{F(d.next(g))}catch(B){L(B)}},E=g=>{try{F(d.throw(g))}catch(B){L(B)}},F=g=>g.done?T(g.value):Promise.resolve(g.value).then(k,E);F((d=d.apply(l,o)).next())});const q=T.createContext(null);q.displayName="ImportContext";const H=()=>T.useContext(q);var j=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},X={exports:{}};(function(t,e){(function(c,n){n()})(j,function(){function c(a,i){return typeof i=="undefined"?i={autoBom:!1}:typeof i!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),i={autoBom:!i}),i.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function n(a,i,f){var u=new XMLHttpRequest;u.open("GET",a),u.responseType="blob",u.onload=function(){h(u.response,i,f)},u.onerror=function(){console.error("could not download file")},u.send()}function x(a){var i=new XMLHttpRequest;i.open("HEAD",a,!1);try{i.send()}catch(f){}return 200<=i.status&&299>=i.status}function s(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(f){var i=document.createEvent("MouseEvents");i.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(i)}}var r=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof j=="object"&&j.global===j?j:void 0,p=r.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),h=r.saveAs||(typeof window!="object"||window!==r?function(){}:"download"in HTMLAnchorElement.prototype&&!p?function(a,i,f){var u=r.URL||r.webkitURL,m=document.createElement("a");i=i||a.name||"download",m.download=i,m.rel="noopener",typeof a=="string"?(m.href=a,m.origin===location.origin?s(m):x(m.href)?n(a,i,f):s(m,m.target="_blank")):(m.href=u.createObjectURL(a),setTimeout(function(){u.revokeObjectURL(m.href)},4e4),setTimeout(function(){s(m)},0))}:"msSaveOrOpenBlob"in navigator?function(a,i,f){if(i=i||a.name||"download",typeof a!="string")navigator.msSaveOrOpenBlob(c(a,f),i);else if(x(a))n(a,i,f);else{var u=document.createElement("a");u.href=a,u.target="_blank",setTimeout(function(){s(u)})}}:function(a,i,f,u){if(u=u||open("","_blank"),u&&(u.document.title=u.document.body.innerText="downloading..."),typeof a=="string")return n(a,i,f);var m=a.type==="application/octet-stream",y=/constructor/i.test(r.HTMLElement)||r.safari,S=/CriOS\/[\d]+/.test(navigator.userAgent);if((S||m&&y||p)&&typeof FileReader!="undefined"){var A=new FileReader;A.onloadend=function(){var I=A.result;I=S?I:I.replace(/^data:[^;]*;/,"data:attachment/file;"),u?u.location.href=I:location=I,u=null},A.readAsDataURL(a)}else{var w=r.URL||r.webkitURL,v=w.createObjectURL(a);u?u.location=v:location.href=v,u=null,setTimeout(function(){w.revokeObjectURL(v)},4e4)}});r.saveAs=h.saveAs=h,t.exports=h})})(X);var G=X.exports;const b="action-import",O={IMPORTING:1,IMPORTED:2},me=t=>{const{t:e}=F.useTranslation(b),{importModalVisible:c,importStatus:n,importResult:x,setImportModalVisible:s}=H(),{data:r,meta:p}=x!=null?x:{},h=()=>{s(!1)},a=()=>{const i=new Int8Array(r==null?void 0:r.data),f=new Blob([i],{type:"application/x-xls"});G.saveAs(f,"fail.xlsx")};return d.jsx(E.Modal,{title:e("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:c,footer:null,closable:n===O.IMPORTED,onCancel:h,children:d.jsxs("div",{className:o.css`
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: center;
|
|
4
|
+
align-items: center;
|
|
5
|
+
height: 100%;
|
|
6
|
+
`,children:[n===O.IMPORTING&&d.jsx(E.Spin,{indicator:d.jsx(k.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:e("Excel data importing")}),n===O.IMPORTED&&d.jsxs(E.Space,{direction:"vertical",align:"center",children:[d.jsx(k.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),d.jsx("p",{children:e("Import done, total success have {{successCount}} , total failure have {{failureCount}}",D({},p!=null?p:{}))}),d.jsxs(E.Space,{children:[(p==null?void 0:p.failureCount)>0&&d.jsx(E.Button,{onClick:a,children:e("To download the failure data")}),d.jsx(E.Button,{type:"primary",onClick:h,children:e("Done")})]})]})]})})},J=t=>{let e=t;for(;e&&e["x-action"]!=="importXlsx";)e=e.parent;return{schema:e}},W=t=>!t||!Array.isArray(t)?[]:t,K=()=>{const{service:t,resource:e}=o.useBlockRequestContext();o.useAPIClient();const c=g.useFieldSchema(),n=o.useCompile(),{getCollectionJoinField:x,getCollectionField:s}=o.useCollectionManager_deprecated(),{name:r,title:p,getField:h}=o.useCollection_deprecated();F.useTranslation(b);const{schema:a}=J(c);return{run(){return N(this,null,function*(){var A,w;const{importColumns:f,explain:u}=B.cloneDeep((w=(A=a==null?void 0:a["x-action-settings"])==null?void 0:A.importSettings)!=null?w:{}),m=W(f).map(v=>{var P,_;const I=s(`${r}.${v.dataIndex[0]}`);if(I){if(v.defaultTitle=n((P=I==null?void 0:I.uiSchema)==null?void 0:P.title)||I.name,v.dataIndex.length>1){const M=x(`${r}.${v.dataIndex.join(".")}`);if(!M)return;v.defaultTitle=v.defaultTitle+"/"+n((_=M==null?void 0:M.uiSchema)==null?void 0:_.title)||M.name}return I.interface==="chinaRegion"&&v.dataIndex.push("name"),v}}).filter(Boolean),{data:y}=yield e.downloadXlsxTemplate({values:{title:n(p),explain:u,columns:n(m)}},{method:"post",responseType:"blob"}),S=new Blob([y],{type:"application/x-xls"});G.saveAs(S,`${n(p)}.xlsx`)})}}},Y=()=>{const{service:t,resource:e}=o.useBlockRequestContext(),c=o.useAPIClient(),n=g.useFieldSchema(),x=o.useCompile(),{getCollectionJoinField:s,getCollectionField:r}=o.useCollectionManager_deprecated(),{name:p,title:h,getField:a}=o.useCollection_deprecated();F.useTranslation(b);const{schema:i}=J(n),f=g.useForm(),{setVisible:u}=o.useActionContext(),{setImportModalVisible:m,setImportStatus:y,setImportResult:S}=H();return{run(){return N(this,null,function*(){var M,se,ie;const{importColumns:w,explain:v}=B.cloneDeep((se=(M=i==null?void 0:i["x-action-settings"])==null?void 0:M.importSettings)!=null?se:{}),I=W(w).map(C=>{var ce,pe;const $=r(`${p}.${C.dataIndex[0]}`);if($){if(C.defaultTitle=x((ce=$==null?void 0:$.uiSchema)==null?void 0:ce.title)||$.name,C.dataIndex.length>1){const U=s(`${p}.${C.dataIndex.join(".")}`);if(!U)return;C.defaultTitle=C.defaultTitle+"/"+x((pe=U==null?void 0:U.uiSchema)==null?void 0:pe.title)||U.name}return $.interface==="chinaRegion"&&C.dataIndex.push("name"),C}}).filter(Boolean),P=new FormData,_=f.values.upload.map(C=>C.originFileObj);P.append("file",_[0]),P.append("columns",JSON.stringify(I)),P.append("explain",v),u(!1),m(!0),y(O.IMPORTING);try{const{data:C}=yield c.axios.post(`${p}:importXlsx`,P,{timeout:6e5});S(C),f.reset(),yield(ie=t==null?void 0:t.refresh)==null?void 0:ie.call(t),y(O.IMPORTED)}catch(C){m(!1),u(!0)}})}}},ue=["id","createdAt","createdBy","updatedAt","updatedBy"],Q=t=>{const{getCollectionFields:e}=o.useCollectionManager_deprecated(),c=e(t),n=(s,r)=>{var h;if(!s.interface||ue.includes(s.interface))return;const p={name:s.name,title:((h=s==null?void 0:s.uiSchema)==null?void 0:h.title)||s.name,schema:s==null?void 0:s.uiSchema};if(!s.target||r>=2)return p;if(s.target){const a=e(s.target),i=x(a,r+1).filter(Boolean);p.children=p.children||[],p.children.push(...i)}return p},x=(s,r)=>{const p=[];return s.forEach(h=>{const a=n(h,r);a&&p.push(a)}),p};return x(c,1)},xe=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],R=()=>{const{t}=F.useTranslation(b),{name:e}=o.useCollection_deprecated(),c=Q(e);return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:`{{ t("Import explain", {ns: "${b}"}) }}`,"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:o.css`
|
|
7
|
+
width: 100%;
|
|
8
|
+
& .ant-space-item:nth-child(2) {
|
|
9
|
+
flex: 1;
|
|
10
|
+
}
|
|
11
|
+
`},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":o.Cascader,required:!0,enum:c,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{ t("Add importable field", {ns: "${b}"}) }}`,"x-component":"ArrayItems.Addition","x-component-props":{className:o.css`
|
|
12
|
+
border-color: var(--colorSettings);
|
|
13
|
+
color: var(--colorSettings);
|
|
14
|
+
&.ant-btn-dashed:hover {
|
|
15
|
+
border-color: var(--colorSettings);
|
|
16
|
+
color: var(--colorSettings);
|
|
17
|
+
}
|
|
18
|
+
`}}}}}},beforeUploadHandler(){return!1},uploadValidator(n,x){var r;if(n.length>1)return{type:"error",message:t("Only one file is allowed to be uploaded")};const s=(r=n[0])!=null?r:{};return s.size>10*1024*1024?{type:"error",message:t("File size cannot exceed 10M")}:xe.includes(s.type)?"":{type:"error",message:t("Please upload the file of Excel")}},validateUpload(n,x,s){var p;const[r]=s;x.disabled=(r==null?void 0:r.length)===0,x.componentProps=V(D({},x.componentProps),{disabled:(r==null?void 0:r.length)===0||((p=n.errors)==null?void 0:p.length)>0})}}},Z=t=>{const{uploadValidator:e,beforeUploadHandler:c,validateUpload:n}=R();return d.jsx(o.SchemaComponentOptions,{components:{ImportActionInitializer:ne,ImportDesigner:re},scope:{uploadValidator:e,validateUpload:n,beforeUploadHandler:c,useDownloadXlsxTemplateAction:K,useImportStartAction:Y},children:d.jsx(ee,{children:t.children})})},ee=t=>{const[e,c]=T.useState(!1),[n,x]=T.useState(O.IMPORTING),[s,r]=T.useState(null);return d.jsxs(q.Provider,{value:{importModalVisible:e,setImportModalVisible:c,importStatus:n,setImportStatus:x,importResult:s,setImportResult:r},children:[L.createPortal(d.jsx(me,{}),document.body),t.children]})},he=new o.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:o.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=o.useSchemaToolbar();return t}},{name:"importableFields",type:"actionModal",useComponentProps(){var p,h,a;const t=g.useField(),e=g.useFieldSchema(),{t:c}=F.useTranslation(),{dn:n}=o.useDesignable(),[x,s]=T.useState(),{importSettingsSchema:r}=R();return T.useEffect(()=>{s(r)},[t.address,(p=e==null?void 0:e["x-action-settings"])==null?void 0:p.importSettings]),{title:c("Importable fields"),schema:x,initialValues:D({},(a=(h=e==null?void 0:e["x-action-settings"])==null?void 0:h.importSettings)!=null?a:{}),components:{ArrayItems:z.ArrayItems},onSubmit:({importColumns:i,explain:f})=>{const u=i==null?void 0:i.filter(m=>{var y;return(y=m==null?void 0:m.dataIndex)==null?void 0:y.length}).map(m=>({dataIndex:m.dataIndex.map(y=>{var S;return(S=y.name)!=null?S:y}),title:m.title}));e["x-action-settings"].importSettings={importColumns:u,explain:f},n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),n.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t}=F.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:t("Delete action")}}}}]}),te=(t,e,c)=>t.reduceProperties((n,x)=>{if(x[e]===c)return x;const s=te(x,e,c);return s||n}),fe=(t,e)=>e(t),oe=(t,e,c=te,n=fe)=>{const x=g.useFieldSchema(),{remove:s}=o.useDesignable(),r=c(x,e,t);return{schema:r,exists:!!r,remove(){r&&n(r,s)}}},ge=t=>({importColumns:t==null?void 0:t.filter(c=>!c.children).map(c=>({dataIndex:[c.name]})),explain:""}),ne=()=>{const t=o.useSchemaInitializerItem(),{insert:e}=o.useSchemaInitializer(),{exists:c,remove:n}=oe("importXlsx","x-action",t.find,t.remove),{name:x}=o.useCollection_deprecated(),s=Q(x),r={type:"void",title:'{{ t("Import") }}',"x-action":"importXlsx","x-action-settings":{importSettings:{importColumns:[],explain:""}},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:import","x-component":"Action","x-component-props":{icon:"CloudUploadOutlined",openMode:"modal"},properties:{modal:{type:"void",title:`{{ t("Import Data", {ns: "${b}" }) }}`,"x-component":"Action.Container","x-decorator":"Form","x-component-props":{width:"50%",className:o.css`
|
|
19
|
+
.ant-formily-item-label {
|
|
20
|
+
height: var(--controlHeightLG);
|
|
21
|
+
}
|
|
22
|
+
`},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{download:{type:"void",title:`{{ t("Step 1: Download template", {ns: "${b}" }) }}`,"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"Markdown.Void","x-editable":!1,"x-component-props":{style:{padding:"var(--paddingContentVerticalSM)",backgroundColor:"var(--colorInfoBg)",border:"1px solid var(--colorInfoBorder)",color:"var(--colorText)",marginBottom:"var(--marginSM)"},content:`{{ t("Download tip", {ns: "${b}" }) }}`}},downloadAction:{type:"void",title:`{{ t("Download template", {ns: "${b}" }) }}`,"x-component":"Action","x-component-props":{className:o.css`
|
|
23
|
+
margin-top: 5px;
|
|
24
|
+
`,useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:`{{ t("Step 2: Upload Excel", {ns: "${b}" }) }}`,"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":"{{ uploadValidator }}","x-component-props":{action:"",height:"150px",tipContent:`{{ t("Upload placeholder", {ns: "${b}" }) }}`,beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:`{{ t("Start import", {ns: "${b}" }) }}`,"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}}}};return d.jsx(o.SchemaInitializerSwitch,V(D({},t),{checked:c,title:t.title,onClick:()=>{var h;if(c)return n();r["x-action-settings"].importSettings=ge(s);const p=g.merge(r||{},t.schema||{});(h=t==null?void 0:t.schemaInitialize)==null||h.call(t,p),e(p)}}))},re=()=>{var p,h,a,i,f,u;const t=g.useField(),e=g.useFieldSchema(),{t:c}=F.useTranslation(),{dn:n}=o.useDesignable(),[x,s]=T.useState(),{importSettingsSchema:r}=R();return T.useEffect(()=>{s(r)},[t.address,(p=e==null?void 0:e["x-action-settings"])==null?void 0:p.importSettings]),d.jsxs(o.GeneralSchemaDesigner,{disableInitializer:!0,children:[d.jsx(o.SchemaSettingsModalItem,{title:c("Edit button"),schema:{type:"object",title:c("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:c("Button title"),default:e.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:c("Button icon"),default:(h=e==null?void 0:e["x-component-props"])==null?void 0:h.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Button background color"),default:(a=e==null?void 0:e["x-component-props"])!=null&&a.danger?"danger":((i=e==null?void 0:e["x-component-props"])==null?void 0:i.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:({title:m,icon:y,type:S})=>{e.title=m,t.title=m,t.componentProps.icon=y,t.componentProps.danger=S==="danger",t.componentProps.type=S,e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].icon=y,e["x-component-props"].danger=S==="danger",e["x-component-props"].type=S,n.emit("patch",{schema:{"x-uid":e["x-uid"],title:m,"x-component-props":D({},e["x-component-props"])}}),n.refresh()}}),d.jsx(o.SchemaSettingsActionModalItem,{title:c("Importable fields"),schema:x,initialValues:D({},(u=(f=e==null?void 0:e["x-action-settings"])==null?void 0:f.importSettings)!=null?u:{}),components:{ArrayItems:z.ArrayItems},onSubmit:({importColumns:m,explain:y})=>{const S=m==null?void 0:m.filter(A=>{var w;return(w=A==null?void 0:A.dataIndex)==null?void 0:w.length}).map(A=>({dataIndex:A.dataIndex.map(w=>{var v;return(v=w.name)!=null?v:w}),title:A.title}));e["x-action-settings"].importSettings={importColumns:S,explain:y},n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),n.refresh()}}),d.jsx(o.SchemaSettingsDivider,{}),d.jsx(o.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:m=>m["x-component"]==="Space"||m["x-component"].endsWith("ActionBar"),confirm:{title:c("Delete action")}})]})};class ae extends o.Plugin{load(){return N(this,null,function*(){this.app.use(Z);const e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){const n=o.useCollection_deprecated();return(n.template!=="view"||(n==null?void 0:n.writableView))&&n.template!=="file"&&n.template!=="sql"}},c=this.app.schemaInitializerManager.get("table:configureActions");c==null||c.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(he)})}}l.ImportActionInitializer=ne,l.ImportContextProvider=ee,l.ImportDesigner=re,l.ImportPlugin=ae,l.ImportPluginProvider=Z,l.default=ae,l.useCurrentSchema=oe,l.useDownloadXlsxTemplateAction=K,l.useImportStartAction=Y,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useFields: (collectionName: string) => any[];
|