@faasjs/ant-design 0.0.3-beta.38 → 0.0.3-beta.40
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/dist/index.js +664 -646
- package/dist/index.mjs +640 -630
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
8
|
var __export = (target, all) => {
|
|
26
9
|
for (var name in all)
|
|
27
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -49,7 +32,7 @@ __export(src_exports, {
|
|
|
49
32
|
Description: () => Description,
|
|
50
33
|
Drawer: () => import_antd4.Drawer,
|
|
51
34
|
ErrorBoundary: () => ErrorBoundary,
|
|
52
|
-
FaasDataWrapper: () =>
|
|
35
|
+
FaasDataWrapper: () => FaasDataWrapper,
|
|
53
36
|
Form: () => Form,
|
|
54
37
|
FormItem: () => FormItem,
|
|
55
38
|
Link: () => Link,
|
|
@@ -133,17 +116,23 @@ function ConfigProvider({
|
|
|
133
116
|
} else
|
|
134
117
|
setValues((0, import_lodash_es.defaultsDeep)(config, values));
|
|
135
118
|
}, []);
|
|
136
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, {
|
|
119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, {
|
|
120
|
+
value: values,
|
|
121
|
+
children
|
|
122
|
+
});
|
|
137
123
|
}
|
|
138
124
|
function useConfigContext() {
|
|
139
125
|
return (0, import_react2.useContext)(ConfigContext);
|
|
140
126
|
}
|
|
141
127
|
|
|
142
128
|
// src/Blank.tsx
|
|
143
|
-
var
|
|
129
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
144
130
|
function Blank(options) {
|
|
145
131
|
const { Blank: Blank2 } = useConfigContext();
|
|
146
|
-
return !options || (0, import_lodash_es2.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ (0,
|
|
132
|
+
return !options || (0, import_lodash_es2.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Typography.Text, {
|
|
133
|
+
disabled: true,
|
|
134
|
+
children: (options == null ? void 0 : options.text) || Blank2.text
|
|
135
|
+
}) : options.value;
|
|
147
136
|
}
|
|
148
137
|
|
|
149
138
|
// src/data.ts
|
|
@@ -177,63 +166,52 @@ function transferValue(type, value) {
|
|
|
177
166
|
var import_icons = require("@ant-design/icons");
|
|
178
167
|
var import_antd3 = require("antd");
|
|
179
168
|
var import_lodash_es4 = require("lodash-es");
|
|
180
|
-
var
|
|
169
|
+
var import_react4 = require("react");
|
|
181
170
|
|
|
182
|
-
//
|
|
183
|
-
var import_react3 = require("react");
|
|
184
|
-
var clients = {};
|
|
185
|
-
function getClient(domain) {
|
|
186
|
-
const client = clients[domain || Object.keys(clients)[0]];
|
|
187
|
-
if (!client)
|
|
188
|
-
throw Error("FaasReactClient is not initialized");
|
|
189
|
-
return client;
|
|
190
|
-
}
|
|
191
|
-
async function faas(action, params) {
|
|
192
|
-
return getClient().faas(action, params);
|
|
193
|
-
}
|
|
194
|
-
function FaasDataWrapper(props) {
|
|
195
|
-
const [client, setClient] = (0, import_react3.useState)();
|
|
196
|
-
(0, import_react3.useEffect)(() => {
|
|
197
|
-
if (client)
|
|
198
|
-
return;
|
|
199
|
-
setClient(getClient());
|
|
200
|
-
}, []);
|
|
201
|
-
if (!client)
|
|
202
|
-
return props.fallback || null;
|
|
203
|
-
return (0, import_react3.createElement)(client.FaasDataWrapper, props);
|
|
204
|
-
}
|
|
171
|
+
// src/FaasDataWrapper.tsx
|
|
172
|
+
var import_react3 = require("@faasjs/react");
|
|
205
173
|
|
|
206
174
|
// src/Loading.tsx
|
|
207
175
|
var import_antd2 = require("antd");
|
|
208
|
-
var
|
|
176
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
209
177
|
function Loading(props) {
|
|
210
178
|
if (props.loading === false)
|
|
211
|
-
return /* @__PURE__ */ (0,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
180
|
+
children: props.children
|
|
181
|
+
});
|
|
182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
183
|
+
style: {
|
|
184
|
+
...props.style || {},
|
|
185
|
+
...!props.size || props.size === "large" ? {
|
|
186
|
+
margin: "20vh auto",
|
|
187
|
+
textAlign: "center"
|
|
188
|
+
} : {}
|
|
189
|
+
},
|
|
190
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Spin, {
|
|
191
|
+
size: props.size || "large"
|
|
192
|
+
})
|
|
193
|
+
});
|
|
216
194
|
}
|
|
217
195
|
|
|
218
196
|
// src/FaasDataWrapper.tsx
|
|
219
|
-
var
|
|
220
|
-
function
|
|
221
|
-
return /* @__PURE__ */ (0,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
);
|
|
197
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
198
|
+
function FaasDataWrapper(props) {
|
|
199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.FaasDataWrapper, {
|
|
200
|
+
fallback: props.loading || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {
|
|
201
|
+
...props.loadingProps
|
|
202
|
+
}),
|
|
203
|
+
...props
|
|
204
|
+
});
|
|
227
205
|
}
|
|
228
206
|
|
|
229
207
|
// src/Description.tsx
|
|
230
|
-
var
|
|
208
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
231
209
|
function DescriptionItemContent(props) {
|
|
232
210
|
var _a;
|
|
233
|
-
const [computedProps, setComputedProps] = (0,
|
|
234
|
-
(0,
|
|
211
|
+
const [computedProps, setComputedProps] = (0, import_react4.useState)();
|
|
212
|
+
(0, import_react4.useEffect)(() => {
|
|
235
213
|
var _a2, _b;
|
|
236
|
-
const propsCopy =
|
|
214
|
+
const propsCopy = { ...props };
|
|
237
215
|
if (!propsCopy.item.title)
|
|
238
216
|
propsCopy.item.title = (0, import_lodash_es4.upperFirst)(propsCopy.item.id);
|
|
239
217
|
if (!propsCopy.item.type)
|
|
@@ -261,7 +239,7 @@ function DescriptionItemContent(props) {
|
|
|
261
239
|
return null;
|
|
262
240
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
263
241
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
264
|
-
return (0,
|
|
242
|
+
return (0, import_react4.cloneElement)(
|
|
265
243
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
266
244
|
{
|
|
267
245
|
scene: "description",
|
|
@@ -270,13 +248,15 @@ function DescriptionItemContent(props) {
|
|
|
270
248
|
}
|
|
271
249
|
);
|
|
272
250
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
273
|
-
return /* @__PURE__ */ (0,
|
|
251
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
252
|
+
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
|
|
253
|
+
});
|
|
274
254
|
else
|
|
275
255
|
throw Error(computedProps.item.type + " requires children or render");
|
|
276
256
|
if (computedProps.item.descriptionChildren === null)
|
|
277
257
|
return null;
|
|
278
258
|
if (computedProps.item.descriptionChildren)
|
|
279
|
-
return (0,
|
|
259
|
+
return (0, import_react4.cloneElement)(computedProps.item.descriptionChildren, {
|
|
280
260
|
scene: "description",
|
|
281
261
|
value: computedProps.value,
|
|
282
262
|
values: computedProps.values
|
|
@@ -284,7 +264,7 @@ function DescriptionItemContent(props) {
|
|
|
284
264
|
if (computedProps.item.children === null)
|
|
285
265
|
return null;
|
|
286
266
|
if (computedProps.item.children)
|
|
287
|
-
return (0,
|
|
267
|
+
return (0, import_react4.cloneElement)(computedProps.item.children, {
|
|
288
268
|
scene: "description",
|
|
289
269
|
value: computedProps.value,
|
|
290
270
|
values: computedProps.values
|
|
@@ -294,137 +274,132 @@ function DescriptionItemContent(props) {
|
|
|
294
274
|
if (computedProps.item.render)
|
|
295
275
|
return computedProps.item.render(computedProps.value, computedProps.values, 0, "description");
|
|
296
276
|
if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
|
|
297
|
-
return /* @__PURE__ */ (0,
|
|
277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
298
278
|
switch (computedProps.item.type) {
|
|
299
279
|
case "string[]":
|
|
300
|
-
return /* @__PURE__ */ (0,
|
|
280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
281
|
+
children: computedProps.value.join(", ")
|
|
282
|
+
});
|
|
301
283
|
case "number":
|
|
302
284
|
return computedProps.value || null;
|
|
303
285
|
case "number[]":
|
|
304
|
-
return /* @__PURE__ */ (0,
|
|
286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
287
|
+
children: computedProps.value.join(", ")
|
|
288
|
+
});
|
|
305
289
|
case "boolean":
|
|
306
|
-
return computedProps.value ? /* @__PURE__ */ (0,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
290
|
+
return computedProps.value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CheckOutlined, {
|
|
291
|
+
style: {
|
|
292
|
+
marginTop: "4px",
|
|
293
|
+
color: "#52c41a"
|
|
294
|
+
}
|
|
295
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {
|
|
296
|
+
style: {
|
|
297
|
+
marginTop: "4px",
|
|
298
|
+
color: "#ff4d4f"
|
|
299
|
+
}
|
|
300
|
+
});
|
|
313
301
|
case "time":
|
|
314
|
-
return /* @__PURE__ */ (0,
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
303
|
+
children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
|
|
304
|
+
});
|
|
315
305
|
case "date":
|
|
316
|
-
return /* @__PURE__ */ (0,
|
|
306
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
307
|
+
children: computedProps.value.format("YYYY-MM-DD")
|
|
308
|
+
});
|
|
317
309
|
case "object":
|
|
318
310
|
if (!computedProps.value)
|
|
319
|
-
return /* @__PURE__ */ (0,
|
|
320
|
-
return /* @__PURE__ */ (0,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
column: 1
|
|
326
|
-
}
|
|
327
|
-
);
|
|
311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
313
|
+
items: computedProps.item.object,
|
|
314
|
+
dataSource: computedProps.value,
|
|
315
|
+
column: 1
|
|
316
|
+
});
|
|
328
317
|
case "object[]":
|
|
329
318
|
if (!((_a = computedProps.value) == null ? void 0 : _a.length))
|
|
330
|
-
return /* @__PURE__ */ (0,
|
|
331
|
-
return /* @__PURE__ */ (0,
|
|
332
|
-
|
|
333
|
-
{
|
|
319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Space, {
|
|
321
|
+
direction: "vertical",
|
|
322
|
+
children: computedProps.value.map((value, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
334
323
|
items: computedProps.item.object,
|
|
335
324
|
dataSource: value,
|
|
336
325
|
column: 1
|
|
337
|
-
},
|
|
338
|
-
|
|
339
|
-
)) });
|
|
326
|
+
}, index))
|
|
327
|
+
});
|
|
340
328
|
default:
|
|
341
329
|
return computedProps.value || null;
|
|
342
330
|
}
|
|
343
331
|
}
|
|
344
332
|
function Description(props) {
|
|
345
333
|
if (!props.faasData)
|
|
346
|
-
return /* @__PURE__ */ (0,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions, {
|
|
335
|
+
...props,
|
|
336
|
+
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
337
|
+
children: props.items.map((item) => {
|
|
338
|
+
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions.Item, {
|
|
339
|
+
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
340
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
341
|
+
item,
|
|
342
|
+
value: props.dataSource[item.id],
|
|
343
|
+
values: props.dataSource,
|
|
344
|
+
extendTypes: props.extendTypes
|
|
345
|
+
})
|
|
346
|
+
}, item.id) : null;
|
|
347
|
+
}).filter(Boolean)
|
|
348
|
+
});
|
|
349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
350
|
+
render: ({ data }) => {
|
|
351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions, {
|
|
352
|
+
...props,
|
|
353
|
+
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
350
354
|
children: props.items.map((item) => {
|
|
351
|
-
return !item.if || item.if(
|
|
352
|
-
|
|
353
|
-
{
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
values: props.dataSource,
|
|
361
|
-
extendTypes: props.extendTypes
|
|
362
|
-
}
|
|
363
|
-
)
|
|
364
|
-
},
|
|
365
|
-
item.id
|
|
366
|
-
) : null;
|
|
355
|
+
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions.Item, {
|
|
356
|
+
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
357
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
358
|
+
item,
|
|
359
|
+
value: data[item.id],
|
|
360
|
+
values: data,
|
|
361
|
+
extendTypes: props.extendTypes
|
|
362
|
+
})
|
|
363
|
+
}, item.id) : null;
|
|
367
364
|
}).filter(Boolean)
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
__spreadValues({
|
|
373
|
-
render: ({ data }) => {
|
|
374
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
375
|
-
import_antd3.Descriptions,
|
|
376
|
-
__spreadProps(__spreadValues({}, props), {
|
|
377
|
-
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
378
|
-
children: props.items.map((item) => {
|
|
379
|
-
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
380
|
-
import_antd3.Descriptions.Item,
|
|
381
|
-
{
|
|
382
|
-
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
383
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
384
|
-
DescriptionItemContent,
|
|
385
|
-
{
|
|
386
|
-
item,
|
|
387
|
-
value: data[item.id],
|
|
388
|
-
values: data,
|
|
389
|
-
extendTypes: props.extendTypes
|
|
390
|
-
}
|
|
391
|
-
)
|
|
392
|
-
},
|
|
393
|
-
item.id
|
|
394
|
-
) : null;
|
|
395
|
-
}).filter(Boolean)
|
|
396
|
-
})
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
|
-
}, props.faasData)
|
|
400
|
-
);
|
|
365
|
+
});
|
|
366
|
+
},
|
|
367
|
+
...props.faasData
|
|
368
|
+
});
|
|
401
369
|
}
|
|
402
370
|
|
|
403
371
|
// src/Drawer.tsx
|
|
404
372
|
var import_antd4 = require("antd");
|
|
405
|
-
var
|
|
406
|
-
var
|
|
373
|
+
var import_react5 = require("react");
|
|
374
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
407
375
|
function useDrawer(init) {
|
|
408
|
-
const [props, setProps] = (0,
|
|
376
|
+
const [props, setProps] = (0, import_react5.useState)({
|
|
409
377
|
open: false,
|
|
410
|
-
onClose: () => setProps((prev) =>
|
|
378
|
+
onClose: () => setProps((prev) => ({
|
|
379
|
+
...prev,
|
|
411
380
|
open: false
|
|
412
|
-
}))
|
|
413
|
-
|
|
381
|
+
})),
|
|
382
|
+
...init
|
|
383
|
+
});
|
|
414
384
|
return {
|
|
415
|
-
drawer: /* @__PURE__ */ (0,
|
|
385
|
+
drawer: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Drawer, {
|
|
386
|
+
...props
|
|
387
|
+
}),
|
|
416
388
|
drawerProps: props,
|
|
417
389
|
setDrawerProps(changes) {
|
|
418
|
-
setProps((prev) =>
|
|
390
|
+
setProps((prev) => ({
|
|
391
|
+
...prev,
|
|
392
|
+
...changes
|
|
393
|
+
}));
|
|
419
394
|
}
|
|
420
395
|
};
|
|
421
396
|
}
|
|
422
397
|
|
|
423
398
|
// src/ErrorBoundary.tsx
|
|
424
|
-
var
|
|
399
|
+
var import_react6 = require("react");
|
|
425
400
|
var import_antd5 = require("antd");
|
|
426
|
-
var
|
|
427
|
-
var ErrorBoundary = class extends
|
|
401
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
402
|
+
var ErrorBoundary = class extends import_react6.Component {
|
|
428
403
|
constructor(props) {
|
|
429
404
|
super(props);
|
|
430
405
|
this.state = {
|
|
@@ -451,32 +426,33 @@ var ErrorBoundary = class extends import_react7.Component {
|
|
|
451
426
|
if (error) {
|
|
452
427
|
if (this.props.onError)
|
|
453
428
|
return this.props.onError(error, info);
|
|
454
|
-
return /* @__PURE__ */ (0,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
description: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("pre", { style: {
|
|
429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Alert, {
|
|
430
|
+
type: "error",
|
|
431
|
+
message: errorMessage,
|
|
432
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
|
|
433
|
+
style: {
|
|
460
434
|
fontSize: "0.9em",
|
|
461
435
|
overflowX: "auto"
|
|
462
|
-
},
|
|
463
|
-
|
|
464
|
-
|
|
436
|
+
},
|
|
437
|
+
children: errorDescription
|
|
438
|
+
})
|
|
439
|
+
});
|
|
465
440
|
}
|
|
466
441
|
return children;
|
|
467
442
|
}
|
|
468
443
|
};
|
|
469
444
|
|
|
470
445
|
// src/Form.tsx
|
|
446
|
+
var import_react8 = require("@faasjs/react");
|
|
471
447
|
var import_antd7 = require("antd");
|
|
472
|
-
var
|
|
448
|
+
var import_react9 = require("react");
|
|
473
449
|
|
|
474
450
|
// src/FormItem.tsx
|
|
475
451
|
var import_antd6 = require("antd");
|
|
476
452
|
var import_icons2 = require("@ant-design/icons");
|
|
477
|
-
var
|
|
453
|
+
var import_react7 = require("react");
|
|
478
454
|
var import_lodash_es5 = require("lodash-es");
|
|
479
|
-
var
|
|
455
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
480
456
|
function processProps(propsCopy, config) {
|
|
481
457
|
if (!propsCopy.title)
|
|
482
458
|
propsCopy.title = (0, import_lodash_es5.upperFirst)(propsCopy.id);
|
|
@@ -525,12 +501,12 @@ function processProps(propsCopy, config) {
|
|
|
525
501
|
}
|
|
526
502
|
function FormItem(props) {
|
|
527
503
|
var _a;
|
|
528
|
-
const [computedProps, setComputedProps] = (0,
|
|
529
|
-
const [extendTypes, setExtendTypes] = (0,
|
|
504
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
505
|
+
const [extendTypes, setExtendTypes] = (0, import_react7.useState)();
|
|
530
506
|
const { common: common2 } = useConfigContext();
|
|
531
|
-
const [hidden, setHidden] = (0,
|
|
532
|
-
(0,
|
|
533
|
-
const propsCopy =
|
|
507
|
+
const [hidden, setHidden] = (0, import_react7.useState)(props.hidden || false);
|
|
508
|
+
(0, import_react7.useEffect)(() => {
|
|
509
|
+
const propsCopy = { ...props };
|
|
534
510
|
if (propsCopy.extendTypes) {
|
|
535
511
|
setExtendTypes(propsCopy.extendTypes);
|
|
536
512
|
delete propsCopy.extendTypes;
|
|
@@ -553,245 +529,300 @@ function FormItem(props) {
|
|
|
553
529
|
if (!computedProps)
|
|
554
530
|
return null;
|
|
555
531
|
if (hidden)
|
|
556
|
-
return /* @__PURE__ */ (0,
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
533
|
+
...computedProps,
|
|
534
|
+
noStyle: true,
|
|
535
|
+
rules: [],
|
|
536
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
|
|
537
|
+
hidden: true
|
|
562
538
|
})
|
|
563
|
-
);
|
|
539
|
+
});
|
|
564
540
|
if (extendTypes && extendTypes[computedProps.type])
|
|
565
|
-
return /* @__PURE__ */ (0,
|
|
541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
542
|
+
...computedProps,
|
|
543
|
+
children: extendTypes[computedProps.type].children
|
|
544
|
+
});
|
|
566
545
|
if (computedProps.formChildren === null)
|
|
567
546
|
return null;
|
|
568
547
|
if (computedProps.formChildren)
|
|
569
|
-
return /* @__PURE__ */ (0,
|
|
548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
549
|
+
...computedProps,
|
|
550
|
+
children: (0, import_react7.cloneElement)(computedProps.formChildren, { scene: "form" })
|
|
551
|
+
});
|
|
570
552
|
if (computedProps.children === null)
|
|
571
553
|
return null;
|
|
572
554
|
if (computedProps.children)
|
|
573
|
-
return /* @__PURE__ */ (0,
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
556
|
+
...computedProps,
|
|
557
|
+
children: (0, import_react7.cloneElement)(computedProps.children, { scene: "form" })
|
|
558
|
+
});
|
|
574
559
|
if (computedProps.formRender)
|
|
575
|
-
return /* @__PURE__ */ (0,
|
|
560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
561
|
+
...computedProps,
|
|
562
|
+
children: computedProps.formRender(null, null, 0, "form")
|
|
563
|
+
});
|
|
576
564
|
if (computedProps.render)
|
|
577
|
-
return /* @__PURE__ */ (0,
|
|
565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
566
|
+
...computedProps,
|
|
567
|
+
children: computedProps.render(null, null, 0, "form")
|
|
568
|
+
});
|
|
578
569
|
switch (computedProps.type) {
|
|
579
570
|
case "string":
|
|
580
|
-
return /* @__PURE__ */ (0,
|
|
571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
572
|
+
...computedProps,
|
|
573
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
|
|
574
|
+
...computedProps.input
|
|
575
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
|
|
576
|
+
...computedProps.input
|
|
577
|
+
})
|
|
578
|
+
});
|
|
581
579
|
case "string[]":
|
|
582
580
|
if (computedProps.options)
|
|
583
|
-
return /* @__PURE__ */ (0,
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
mode: "multiple"
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
computedProps.label && /* @__PURE__ */ (0,
|
|
581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
582
|
+
...computedProps,
|
|
583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
|
|
584
|
+
mode: "multiple",
|
|
585
|
+
...computedProps.input
|
|
586
|
+
})
|
|
587
|
+
});
|
|
588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
|
|
589
|
+
name: computedProps.name,
|
|
590
|
+
rules: computedProps.rules,
|
|
591
|
+
children: (fields, { add, remove }, { errors }) => {
|
|
592
|
+
var _a2;
|
|
593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
594
|
+
children: [
|
|
595
|
+
computedProps.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
596
|
+
className: "ant-form-item-label",
|
|
597
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
|
|
598
|
+
className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
|
|
599
|
+
children: computedProps.label
|
|
600
|
+
})
|
|
601
|
+
}),
|
|
598
602
|
fields.map((field) => {
|
|
599
603
|
var _a3;
|
|
600
|
-
return /* @__PURE__ */ (0,
|
|
601
|
-
import_antd6.Row,
|
|
602
|
-
{
|
|
604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
605
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Row, {
|
|
603
606
|
gutter: 24,
|
|
604
607
|
style: { flexFlow: "row nowrap" },
|
|
605
608
|
children: [
|
|
606
|
-
/* @__PURE__ */ (0,
|
|
607
|
-
|
|
608
|
-
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
610
|
+
span: 23,
|
|
611
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
612
|
+
...field,
|
|
609
613
|
noStyle: true,
|
|
610
|
-
children: /* @__PURE__ */ (0,
|
|
614
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
|
|
615
|
+
...computedProps.input
|
|
616
|
+
})
|
|
611
617
|
})
|
|
612
|
-
|
|
613
|
-
/* @__PURE__ */ (0,
|
|
614
|
-
|
|
615
|
-
{
|
|
618
|
+
}),
|
|
619
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
620
|
+
span: 1,
|
|
621
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
616
622
|
danger: true,
|
|
617
623
|
type: "link",
|
|
618
624
|
style: { float: "right" },
|
|
619
|
-
icon: /* @__PURE__ */ (0,
|
|
625
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.MinusCircleOutlined, {}),
|
|
620
626
|
onClick: () => remove(field.name)
|
|
621
|
-
}
|
|
622
|
-
|
|
627
|
+
})
|
|
628
|
+
})
|
|
623
629
|
]
|
|
624
|
-
}
|
|
625
|
-
|
|
630
|
+
})
|
|
631
|
+
}, field.key);
|
|
626
632
|
}),
|
|
627
|
-
/* @__PURE__ */ (0,
|
|
628
|
-
|
|
629
|
-
import_antd6.Button,
|
|
630
|
-
{
|
|
633
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
|
|
634
|
+
children: [
|
|
635
|
+
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
631
636
|
type: "dashed",
|
|
632
637
|
block: true,
|
|
633
638
|
onClick: () => add(),
|
|
634
|
-
icon: /* @__PURE__ */ (0,
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
639
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
|
|
640
|
+
}),
|
|
641
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
|
|
642
|
+
errors
|
|
643
|
+
})
|
|
644
|
+
]
|
|
645
|
+
})
|
|
646
|
+
]
|
|
647
|
+
});
|
|
641
648
|
}
|
|
642
|
-
);
|
|
649
|
+
});
|
|
643
650
|
case "number":
|
|
644
|
-
return /* @__PURE__ */ (0,
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
},
|
|
649
|
-
|
|
651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
652
|
+
...computedProps,
|
|
653
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
|
|
654
|
+
...computedProps.input
|
|
655
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.InputNumber, {
|
|
656
|
+
style: { width: "100%" },
|
|
657
|
+
...computedProps.input
|
|
658
|
+
})
|
|
659
|
+
});
|
|
650
660
|
case "number[]":
|
|
651
661
|
if (computedProps.options)
|
|
652
|
-
return /* @__PURE__ */ (0,
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
mode: "multiple"
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
computedProps.label && /* @__PURE__ */ (0,
|
|
662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
663
|
+
...computedProps,
|
|
664
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
|
|
665
|
+
mode: "multiple",
|
|
666
|
+
...computedProps.input
|
|
667
|
+
})
|
|
668
|
+
});
|
|
669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
|
|
670
|
+
name: computedProps.name,
|
|
671
|
+
rules: computedProps.rules,
|
|
672
|
+
children: (fields, { add, remove }, { errors }) => {
|
|
673
|
+
var _a2, _b;
|
|
674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
675
|
+
children: [
|
|
676
|
+
computedProps.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
677
|
+
className: "ant-form-item-label",
|
|
678
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
|
|
679
|
+
className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
|
|
680
|
+
children: computedProps.label
|
|
681
|
+
})
|
|
682
|
+
}),
|
|
667
683
|
fields.map((field) => {
|
|
668
684
|
var _a3;
|
|
669
|
-
return /* @__PURE__ */ (0,
|
|
670
|
-
import_antd6.Row,
|
|
671
|
-
{
|
|
685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
686
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Row, {
|
|
672
687
|
gutter: 24,
|
|
673
688
|
style: { flexFlow: "row nowrap" },
|
|
674
689
|
children: [
|
|
675
|
-
/* @__PURE__ */ (0,
|
|
676
|
-
|
|
677
|
-
|
|
690
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
691
|
+
span: 23,
|
|
692
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
693
|
+
...field,
|
|
678
694
|
noStyle: true,
|
|
679
|
-
children: /* @__PURE__ */ (0,
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}, computedProps.input)
|
|
684
|
-
)
|
|
695
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.InputNumber, {
|
|
696
|
+
style: { width: "100%" },
|
|
697
|
+
...computedProps.input
|
|
698
|
+
})
|
|
685
699
|
})
|
|
686
|
-
|
|
687
|
-
/* @__PURE__ */ (0,
|
|
688
|
-
|
|
689
|
-
{
|
|
700
|
+
}),
|
|
701
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
702
|
+
span: 1,
|
|
703
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
690
704
|
danger: true,
|
|
691
705
|
type: "link",
|
|
692
706
|
style: { float: "right" },
|
|
693
|
-
icon: /* @__PURE__ */ (0,
|
|
707
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.MinusCircleOutlined, {}),
|
|
694
708
|
onClick: () => remove(field.name)
|
|
695
|
-
}
|
|
696
|
-
|
|
709
|
+
})
|
|
710
|
+
})
|
|
697
711
|
]
|
|
698
|
-
}
|
|
699
|
-
|
|
712
|
+
})
|
|
713
|
+
}, field.key);
|
|
700
714
|
}),
|
|
701
|
-
/* @__PURE__ */ (0,
|
|
702
|
-
|
|
703
|
-
import_antd6.Button,
|
|
704
|
-
{
|
|
715
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
|
|
716
|
+
children: [
|
|
717
|
+
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
705
718
|
type: "dashed",
|
|
706
719
|
block: true,
|
|
707
720
|
onClick: () => add(),
|
|
708
|
-
icon: /* @__PURE__ */ (0,
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
721
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
|
|
722
|
+
}),
|
|
723
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
|
|
724
|
+
errors
|
|
725
|
+
})
|
|
726
|
+
]
|
|
727
|
+
})
|
|
728
|
+
]
|
|
729
|
+
});
|
|
715
730
|
}
|
|
716
|
-
);
|
|
731
|
+
});
|
|
717
732
|
case "boolean":
|
|
718
|
-
return /* @__PURE__ */ (0,
|
|
733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
734
|
+
...computedProps,
|
|
735
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Switch, {
|
|
736
|
+
...computedProps.input
|
|
737
|
+
})
|
|
738
|
+
});
|
|
719
739
|
case "date":
|
|
720
|
-
return /* @__PURE__ */ (0,
|
|
740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
741
|
+
...computedProps,
|
|
742
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.DatePicker, {
|
|
743
|
+
...computedProps.input
|
|
744
|
+
})
|
|
745
|
+
});
|
|
721
746
|
case "time":
|
|
722
|
-
return /* @__PURE__ */ (0,
|
|
747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
748
|
+
...computedProps,
|
|
749
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.TimePicker, {
|
|
750
|
+
...computedProps.input
|
|
751
|
+
})
|
|
752
|
+
});
|
|
723
753
|
case "object":
|
|
724
|
-
return /* @__PURE__ */ (0,
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
755
|
+
children: [
|
|
756
|
+
computedProps.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
757
|
+
className: "ant-form-item-label",
|
|
758
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
|
|
759
|
+
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
|
|
760
|
+
children: computedProps.label
|
|
761
|
+
})
|
|
762
|
+
}),
|
|
763
|
+
computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
764
|
+
...o
|
|
765
|
+
}, o.id))
|
|
766
|
+
]
|
|
767
|
+
});
|
|
732
768
|
case "object[]":
|
|
733
|
-
return /* @__PURE__ */ (0,
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
import_antd6.Button,
|
|
750
|
-
{
|
|
769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
|
|
770
|
+
name: computedProps.name,
|
|
771
|
+
rules: computedProps.rules,
|
|
772
|
+
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
773
|
+
children: [
|
|
774
|
+
fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
|
|
775
|
+
style: { marginBottom: 0 },
|
|
776
|
+
children: [
|
|
777
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
778
|
+
className: "ant-form-item-label",
|
|
779
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
780
|
+
children: [
|
|
781
|
+
computedProps.label,
|
|
782
|
+
" ",
|
|
783
|
+
field.name + 1,
|
|
784
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
751
785
|
danger: true,
|
|
752
786
|
type: "link",
|
|
753
787
|
onClick: () => remove(field.name),
|
|
754
788
|
children: common2.delete
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
)),
|
|
775
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_antd6.Form.Item, { children: [
|
|
776
|
-
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
777
|
-
import_antd6.Button,
|
|
778
|
-
{
|
|
789
|
+
})
|
|
790
|
+
]
|
|
791
|
+
})
|
|
792
|
+
}),
|
|
793
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Row, {
|
|
794
|
+
gutter: 24,
|
|
795
|
+
children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
796
|
+
span: o.col || 24,
|
|
797
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
798
|
+
...o,
|
|
799
|
+
name: [field.name, o.id]
|
|
800
|
+
})
|
|
801
|
+
}, o.id))
|
|
802
|
+
})
|
|
803
|
+
]
|
|
804
|
+
}, field.key)),
|
|
805
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
|
|
806
|
+
children: [
|
|
807
|
+
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Button, {
|
|
779
808
|
type: "dashed",
|
|
780
809
|
block: true,
|
|
781
810
|
onClick: () => add(),
|
|
782
|
-
icon: /* @__PURE__ */ (0,
|
|
811
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {}),
|
|
783
812
|
children: [
|
|
784
813
|
common2.add,
|
|
785
814
|
" ",
|
|
786
815
|
computedProps.label
|
|
787
816
|
]
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
817
|
+
}),
|
|
818
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
|
|
819
|
+
errors
|
|
820
|
+
})
|
|
821
|
+
]
|
|
822
|
+
})
|
|
823
|
+
]
|
|
824
|
+
})
|
|
825
|
+
});
|
|
795
826
|
default:
|
|
796
827
|
return null;
|
|
797
828
|
}
|
|
@@ -799,20 +830,21 @@ function FormItem(props) {
|
|
|
799
830
|
FormItem.useStatus = import_antd6.Form.Item.useStatus;
|
|
800
831
|
|
|
801
832
|
// src/Form.tsx
|
|
802
|
-
var
|
|
833
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
803
834
|
function Form(props) {
|
|
804
835
|
var _a, _b;
|
|
805
|
-
const [loading, setLoading] = (0,
|
|
806
|
-
const [computedProps, setComputedProps] = (0,
|
|
836
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
837
|
+
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
807
838
|
const config = useConfigContext();
|
|
808
|
-
const [extendTypes, setExtendTypes] = (0,
|
|
839
|
+
const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
|
|
809
840
|
const [form] = import_antd7.Form.useForm(props.form);
|
|
810
|
-
const [initialValues, setInitialValues] = (0,
|
|
811
|
-
(0,
|
|
841
|
+
const [initialValues, setInitialValues] = (0, import_react9.useState)(props.initialValues);
|
|
842
|
+
(0, import_react9.useEffect)(() => {
|
|
812
843
|
var _a2, _b2, _c;
|
|
813
|
-
const propsCopy =
|
|
844
|
+
const propsCopy = {
|
|
845
|
+
...props,
|
|
814
846
|
form
|
|
815
|
-
}
|
|
847
|
+
};
|
|
816
848
|
if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
|
|
817
849
|
for (const key in propsCopy.initialValues) {
|
|
818
850
|
propsCopy.initialValues[key] = transferValue(
|
|
@@ -836,7 +868,10 @@ function Form(props) {
|
|
|
836
868
|
setLoading(true);
|
|
837
869
|
try {
|
|
838
870
|
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
839
|
-
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
871
|
+
await props.onFinish(values, async (values2) => (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
872
|
+
...values2,
|
|
873
|
+
...propsCopy.submit.to.params
|
|
874
|
+
} : values2));
|
|
840
875
|
} else
|
|
841
876
|
await props.onFinish(values);
|
|
842
877
|
} catch (error) {
|
|
@@ -847,7 +882,10 @@ function Form(props) {
|
|
|
847
882
|
} else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
|
|
848
883
|
propsCopy.onFinish = async (values) => {
|
|
849
884
|
setLoading(true);
|
|
850
|
-
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
885
|
+
return (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
886
|
+
...values,
|
|
887
|
+
...propsCopy.submit.to.params
|
|
888
|
+
} : values).then((result) => {
|
|
851
889
|
if (propsCopy.submit.to.then)
|
|
852
890
|
propsCopy.submit.to.then(result);
|
|
853
891
|
return result;
|
|
@@ -868,7 +906,7 @@ function Form(props) {
|
|
|
868
906
|
}
|
|
869
907
|
setComputedProps(propsCopy);
|
|
870
908
|
}, [props]);
|
|
871
|
-
const onValuesChange = (0,
|
|
909
|
+
const onValuesChange = (0, import_react9.useCallback)((changedValues, allValues) => {
|
|
872
910
|
console.debug("Form:onValuesChange", changedValues, allValues);
|
|
873
911
|
if (props.onValuesChange) {
|
|
874
912
|
props.onValuesChange(changedValues, allValues);
|
|
@@ -881,7 +919,7 @@ function Form(props) {
|
|
|
881
919
|
item.onValueChange(changedValues[key], allValues, form);
|
|
882
920
|
}
|
|
883
921
|
}, [computedProps]);
|
|
884
|
-
(0,
|
|
922
|
+
(0, import_react9.useEffect)(() => {
|
|
885
923
|
if (!initialValues)
|
|
886
924
|
return;
|
|
887
925
|
console.debug("Form:initialValues", initialValues);
|
|
@@ -890,33 +928,25 @@ function Form(props) {
|
|
|
890
928
|
}, [computedProps]);
|
|
891
929
|
if (!computedProps)
|
|
892
930
|
return null;
|
|
893
|
-
return /* @__PURE__ */ (0,
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
computedProps.submit
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
loading,
|
|
913
|
-
children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
|
|
914
|
-
}
|
|
915
|
-
),
|
|
916
|
-
computedProps.footer
|
|
917
|
-
]
|
|
918
|
-
})
|
|
919
|
-
);
|
|
931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd7.Form, {
|
|
932
|
+
...computedProps,
|
|
933
|
+
onValuesChange,
|
|
934
|
+
children: [
|
|
935
|
+
computedProps.beforeItems,
|
|
936
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => (0, import_react9.isValidElement)(item) ? item : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
937
|
+
...item,
|
|
938
|
+
extendTypes
|
|
939
|
+
}, item.id)),
|
|
940
|
+
computedProps.children,
|
|
941
|
+
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Button, {
|
|
942
|
+
htmlType: "submit",
|
|
943
|
+
type: "primary",
|
|
944
|
+
loading,
|
|
945
|
+
children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
|
|
946
|
+
}),
|
|
947
|
+
computedProps.footer
|
|
948
|
+
]
|
|
949
|
+
});
|
|
920
950
|
}
|
|
921
951
|
Form.useForm = import_antd7.Form.useForm;
|
|
922
952
|
Form.useFormInstance = import_antd7.Form.useFormInstance;
|
|
@@ -929,13 +959,15 @@ Form.Provider = import_antd7.Form.Provider;
|
|
|
929
959
|
// src/Link.tsx
|
|
930
960
|
var import_react_router_dom = require("react-router-dom");
|
|
931
961
|
var import_antd8 = require("antd");
|
|
932
|
-
var
|
|
962
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
933
963
|
function Link(props) {
|
|
934
964
|
var _a, _b, _c, _d;
|
|
935
965
|
const { Link: Link2 } = useConfigContext();
|
|
936
|
-
let style =
|
|
937
|
-
|
|
938
|
-
|
|
966
|
+
let style = {
|
|
967
|
+
...Link2.style || {},
|
|
968
|
+
cursor: "pointer",
|
|
969
|
+
...props.style
|
|
970
|
+
};
|
|
939
971
|
if (props.block)
|
|
940
972
|
style = Object.assign({
|
|
941
973
|
display: "block",
|
|
@@ -943,118 +975,112 @@ function Link(props) {
|
|
|
943
975
|
}, style);
|
|
944
976
|
if (props.href.startsWith("http")) {
|
|
945
977
|
if (props.button)
|
|
946
|
-
return /* @__PURE__ */ (0,
|
|
947
|
-
|
|
948
|
-
__spreadProps(__spreadValues({}, props.button), {
|
|
949
|
-
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
950
|
-
style,
|
|
951
|
-
href: props.href,
|
|
952
|
-
children: (_a = props.text) != null ? _a : props.children
|
|
953
|
-
})
|
|
954
|
-
);
|
|
955
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
956
|
-
"a",
|
|
957
|
-
{
|
|
958
|
-
href: props.href,
|
|
978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
979
|
+
...props.button,
|
|
959
980
|
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
960
981
|
style,
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
982
|
+
href: props.href,
|
|
983
|
+
children: (_a = props.text) != null ? _a : props.children
|
|
984
|
+
});
|
|
985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
986
|
+
href: props.href,
|
|
987
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
988
|
+
style,
|
|
989
|
+
children: (_b = props.text) != null ? _b : props.children
|
|
990
|
+
});
|
|
964
991
|
}
|
|
965
992
|
if (props.button)
|
|
966
|
-
return /* @__PURE__ */ (0,
|
|
967
|
-
import_react_router_dom.Link,
|
|
968
|
-
{
|
|
969
|
-
to: props.href,
|
|
970
|
-
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
971
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
972
|
-
import_antd8.Button,
|
|
973
|
-
__spreadProps(__spreadValues({}, props.button), {
|
|
974
|
-
style,
|
|
975
|
-
children: (_c = props.text) != null ? _c : props.children
|
|
976
|
-
})
|
|
977
|
-
)
|
|
978
|
-
}
|
|
979
|
-
);
|
|
980
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
981
|
-
import_react_router_dom.Link,
|
|
982
|
-
{
|
|
993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
|
|
983
994
|
to: props.href,
|
|
984
995
|
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
996
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
997
|
+
...props.button,
|
|
998
|
+
style,
|
|
999
|
+
children: (_c = props.text) != null ? _c : props.children
|
|
1000
|
+
})
|
|
1001
|
+
});
|
|
1002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
|
|
1003
|
+
to: props.href,
|
|
1004
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1005
|
+
style,
|
|
1006
|
+
children: (_d = props.text) != null ? _d : props.children
|
|
1007
|
+
});
|
|
989
1008
|
}
|
|
990
1009
|
|
|
991
1010
|
// src/Modal.tsx
|
|
992
1011
|
var import_antd9 = require("antd");
|
|
993
|
-
var
|
|
994
|
-
var
|
|
1012
|
+
var import_react10 = require("react");
|
|
1013
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
995
1014
|
function useModal(init) {
|
|
996
|
-
const [props, setProps] = (0,
|
|
1015
|
+
const [props, setProps] = (0, import_react10.useState)({
|
|
997
1016
|
open: false,
|
|
998
|
-
onCancel: () => setProps((prev) =>
|
|
1017
|
+
onCancel: () => setProps((prev) => ({
|
|
1018
|
+
...prev,
|
|
999
1019
|
open: false
|
|
1000
|
-
}))
|
|
1001
|
-
|
|
1020
|
+
})),
|
|
1021
|
+
...init
|
|
1022
|
+
});
|
|
1002
1023
|
return {
|
|
1003
|
-
modal: /* @__PURE__ */ (0,
|
|
1024
|
+
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Modal, {
|
|
1025
|
+
...props
|
|
1026
|
+
}),
|
|
1004
1027
|
modalProps: props,
|
|
1005
1028
|
setModalProps(changes) {
|
|
1006
|
-
setProps((prev) =>
|
|
1029
|
+
setProps((prev) => ({
|
|
1030
|
+
...prev,
|
|
1031
|
+
...changes
|
|
1032
|
+
}));
|
|
1007
1033
|
}
|
|
1008
1034
|
};
|
|
1009
1035
|
}
|
|
1010
1036
|
|
|
1011
1037
|
// src/Routers.tsx
|
|
1012
1038
|
var import_antd10 = require("antd");
|
|
1013
|
-
var
|
|
1039
|
+
var import_react11 = require("react");
|
|
1014
1040
|
var import_react_router_dom2 = require("react-router-dom");
|
|
1015
|
-
var
|
|
1041
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1016
1042
|
function PageNotFound() {
|
|
1017
1043
|
const config = useConfigContext();
|
|
1018
|
-
return /* @__PURE__ */ (0,
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
title: config.common.pageNotFound
|
|
1023
|
-
}
|
|
1024
|
-
);
|
|
1044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Result, {
|
|
1045
|
+
status: "404",
|
|
1046
|
+
title: config.common.pageNotFound
|
|
1047
|
+
});
|
|
1025
1048
|
}
|
|
1026
1049
|
function Routes(props) {
|
|
1027
|
-
return /* @__PURE__ */ (0,
|
|
1028
|
-
|
|
1029
|
-
import_react_router_dom2.Route,
|
|
1030
|
-
|
|
1031
|
-
element: r.element || /* @__PURE__ */ (0,
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_router_dom2.Routes, {
|
|
1051
|
+
children: [
|
|
1052
|
+
props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom2.Route, {
|
|
1053
|
+
...r,
|
|
1054
|
+
element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react11.Suspense, {
|
|
1055
|
+
fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1056
|
+
style: { padding: "24px" },
|
|
1057
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Skeleton, {
|
|
1058
|
+
active: true
|
|
1059
|
+
})
|
|
1060
|
+
}),
|
|
1061
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(r.page, {})
|
|
1062
|
+
})
|
|
1063
|
+
}, r.path)),
|
|
1064
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom2.Route, {
|
|
1038
1065
|
path: "*",
|
|
1039
|
-
element: props.notFound || /* @__PURE__ */ (0,
|
|
1040
|
-
},
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
] });
|
|
1066
|
+
element: props.notFound || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageNotFound, {})
|
|
1067
|
+
}, "*")
|
|
1068
|
+
]
|
|
1069
|
+
});
|
|
1044
1070
|
}
|
|
1045
1071
|
|
|
1046
1072
|
// src/Table.tsx
|
|
1047
|
-
var
|
|
1073
|
+
var import_react12 = require("react");
|
|
1048
1074
|
var import_antd11 = require("antd");
|
|
1049
1075
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
1050
1076
|
var import_icons3 = require("@ant-design/icons");
|
|
1051
1077
|
var import_lodash_es6 = require("lodash-es");
|
|
1052
|
-
var
|
|
1078
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1053
1079
|
function processValue(item, value) {
|
|
1054
1080
|
var _a;
|
|
1055
1081
|
const transferred = transferValue(item.type, value);
|
|
1056
1082
|
if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
|
|
1057
|
-
return /* @__PURE__ */ (0,
|
|
1083
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
1058
1084
|
if (item.options) {
|
|
1059
1085
|
if (item.type.endsWith("[]"))
|
|
1060
1086
|
return transferred.map((v) => {
|
|
@@ -1075,9 +1101,9 @@ function processValue(item, value) {
|
|
|
1075
1101
|
return value;
|
|
1076
1102
|
}
|
|
1077
1103
|
function Table(props) {
|
|
1078
|
-
const [columns, setColumns] = (0,
|
|
1104
|
+
const [columns, setColumns] = (0, import_react12.useState)();
|
|
1079
1105
|
const { common: common2 } = useConfigContext();
|
|
1080
|
-
(0,
|
|
1106
|
+
(0, import_react12.useEffect)(() => {
|
|
1081
1107
|
var _a;
|
|
1082
1108
|
for (const item of props.items) {
|
|
1083
1109
|
if (!item.key)
|
|
@@ -1094,14 +1120,14 @@ function Table(props) {
|
|
|
1094
1120
|
text: o.label,
|
|
1095
1121
|
value: o.value
|
|
1096
1122
|
})).concat({
|
|
1097
|
-
text: /* @__PURE__ */ (0,
|
|
1123
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1098
1124
|
value: null
|
|
1099
1125
|
});
|
|
1100
1126
|
}
|
|
1101
1127
|
if (item.tableChildren === null)
|
|
1102
1128
|
item.render = () => null;
|
|
1103
1129
|
else if (item.tableChildren)
|
|
1104
|
-
item.render = (value, values) => (0,
|
|
1130
|
+
item.render = (value, values) => (0, import_react12.cloneElement)(
|
|
1105
1131
|
item.tableChildren,
|
|
1106
1132
|
{
|
|
1107
1133
|
scene: "table",
|
|
@@ -1112,7 +1138,7 @@ function Table(props) {
|
|
|
1112
1138
|
else if (item.children === null)
|
|
1113
1139
|
item.render = () => null;
|
|
1114
1140
|
else if (item.children)
|
|
1115
|
-
item.render = (value, values) => (0,
|
|
1141
|
+
item.render = (value, values) => (0, import_react12.cloneElement)(
|
|
1116
1142
|
item.children,
|
|
1117
1143
|
{
|
|
1118
1144
|
scene: "table",
|
|
@@ -1122,7 +1148,7 @@ function Table(props) {
|
|
|
1122
1148
|
);
|
|
1123
1149
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1124
1150
|
if (props.extendTypes[item.type].children)
|
|
1125
|
-
item.render = (value, values) => (0,
|
|
1151
|
+
item.render = (value, values) => (0, import_react12.cloneElement)(
|
|
1126
1152
|
props.extendTypes[item.type].children,
|
|
1127
1153
|
{
|
|
1128
1154
|
scene: "table",
|
|
@@ -1153,22 +1179,19 @@ function Table(props) {
|
|
|
1153
1179
|
setSelectedKeys,
|
|
1154
1180
|
confirm,
|
|
1155
1181
|
clearFilters
|
|
1156
|
-
}) => /* @__PURE__ */ (0,
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
setSelectedKeys([]);
|
|
1166
|
-
clearFilters();
|
|
1167
|
-
}
|
|
1168
|
-
confirm();
|
|
1182
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
|
|
1183
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1184
|
+
allowClear: true,
|
|
1185
|
+
onSearch: (v) => {
|
|
1186
|
+
if (v) {
|
|
1187
|
+
setSelectedKeys([v]);
|
|
1188
|
+
} else {
|
|
1189
|
+
setSelectedKeys([]);
|
|
1190
|
+
clearFilters();
|
|
1169
1191
|
}
|
|
1192
|
+
confirm();
|
|
1170
1193
|
}
|
|
1171
|
-
);
|
|
1194
|
+
});
|
|
1172
1195
|
break;
|
|
1173
1196
|
case "string[]":
|
|
1174
1197
|
if (!item.render)
|
|
@@ -1186,22 +1209,19 @@ function Table(props) {
|
|
|
1186
1209
|
setSelectedKeys,
|
|
1187
1210
|
confirm,
|
|
1188
1211
|
clearFilters
|
|
1189
|
-
}) => /* @__PURE__ */ (0,
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
setSelectedKeys([]);
|
|
1199
|
-
clearFilters();
|
|
1200
|
-
}
|
|
1201
|
-
confirm();
|
|
1212
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
|
|
1213
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1214
|
+
allowClear: true,
|
|
1215
|
+
onSearch: (v) => {
|
|
1216
|
+
if (v) {
|
|
1217
|
+
setSelectedKeys([v]);
|
|
1218
|
+
} else {
|
|
1219
|
+
setSelectedKeys([]);
|
|
1220
|
+
clearFilters();
|
|
1202
1221
|
}
|
|
1222
|
+
confirm();
|
|
1203
1223
|
}
|
|
1204
|
-
);
|
|
1224
|
+
});
|
|
1205
1225
|
break;
|
|
1206
1226
|
case "number":
|
|
1207
1227
|
if (!item.render)
|
|
@@ -1219,22 +1239,19 @@ function Table(props) {
|
|
|
1219
1239
|
setSelectedKeys,
|
|
1220
1240
|
confirm,
|
|
1221
1241
|
clearFilters
|
|
1222
|
-
}) => /* @__PURE__ */ (0,
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
setSelectedKeys([]);
|
|
1232
|
-
clearFilters();
|
|
1233
|
-
}
|
|
1234
|
-
confirm();
|
|
1242
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
|
|
1243
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1244
|
+
allowClear: true,
|
|
1245
|
+
onSearch: (v) => {
|
|
1246
|
+
if (v) {
|
|
1247
|
+
setSelectedKeys([Number(v)]);
|
|
1248
|
+
} else {
|
|
1249
|
+
setSelectedKeys([]);
|
|
1250
|
+
clearFilters();
|
|
1235
1251
|
}
|
|
1252
|
+
confirm();
|
|
1236
1253
|
}
|
|
1237
|
-
);
|
|
1254
|
+
});
|
|
1238
1255
|
break;
|
|
1239
1256
|
case "number[]":
|
|
1240
1257
|
if (!item.render)
|
|
@@ -1252,61 +1269,74 @@ function Table(props) {
|
|
|
1252
1269
|
setSelectedKeys,
|
|
1253
1270
|
confirm,
|
|
1254
1271
|
clearFilters
|
|
1255
|
-
}) => /* @__PURE__ */ (0,
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
setSelectedKeys([]);
|
|
1265
|
-
clearFilters();
|
|
1266
|
-
}
|
|
1267
|
-
confirm();
|
|
1272
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
|
|
1273
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1274
|
+
allowClear: true,
|
|
1275
|
+
onSearch: (v) => {
|
|
1276
|
+
if (v) {
|
|
1277
|
+
setSelectedKeys([Number(v)]);
|
|
1278
|
+
} else {
|
|
1279
|
+
setSelectedKeys([]);
|
|
1280
|
+
clearFilters();
|
|
1268
1281
|
}
|
|
1282
|
+
confirm();
|
|
1269
1283
|
}
|
|
1270
|
-
);
|
|
1284
|
+
});
|
|
1271
1285
|
break;
|
|
1272
1286
|
case "boolean":
|
|
1273
1287
|
if (!item.render)
|
|
1274
|
-
item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ (0,
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1288
|
+
item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}) : value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
|
|
1289
|
+
style: {
|
|
1290
|
+
marginTop: "4px",
|
|
1291
|
+
color: "#52c41a"
|
|
1292
|
+
}
|
|
1293
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
|
|
1294
|
+
style: {
|
|
1295
|
+
marginTop: "4px",
|
|
1296
|
+
color: "#ff4d4f"
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1281
1299
|
if (item.filterDropdown !== false)
|
|
1282
1300
|
item.filterDropdown = ({
|
|
1283
1301
|
setSelectedKeys,
|
|
1284
1302
|
selectedKeys,
|
|
1285
1303
|
confirm
|
|
1286
|
-
}) => /* @__PURE__ */ (0,
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
value:
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1304
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd11.Radio.Group, {
|
|
1305
|
+
style: { padding: 8 },
|
|
1306
|
+
buttonStyle: "solid",
|
|
1307
|
+
value: selectedKeys[0],
|
|
1308
|
+
onChange: (e) => {
|
|
1309
|
+
setSelectedKeys(e.target.value ? [e.target.value] : []);
|
|
1310
|
+
confirm();
|
|
1311
|
+
},
|
|
1312
|
+
children: [
|
|
1313
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
|
|
1314
|
+
children: common2.all
|
|
1315
|
+
}),
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
|
|
1317
|
+
value: "true",
|
|
1318
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
|
|
1319
|
+
style: {
|
|
1320
|
+
color: "#52c41a",
|
|
1321
|
+
verticalAlign: "middle"
|
|
1322
|
+
}
|
|
1323
|
+
})
|
|
1324
|
+
}),
|
|
1325
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
|
|
1326
|
+
value: "false",
|
|
1327
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
|
|
1328
|
+
style: {
|
|
1329
|
+
verticalAlign: "middle",
|
|
1330
|
+
color: "#ff4d4f"
|
|
1331
|
+
}
|
|
1332
|
+
})
|
|
1333
|
+
}),
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
|
|
1335
|
+
value: "empty",
|
|
1336
|
+
children: common2.blank
|
|
1337
|
+
})
|
|
1338
|
+
]
|
|
1339
|
+
});
|
|
1310
1340
|
if (!item.onFilter)
|
|
1311
1341
|
item.onFilter = (value, row) => {
|
|
1312
1342
|
switch (value) {
|
|
@@ -1339,26 +1369,21 @@ function Table(props) {
|
|
|
1339
1369
|
break;
|
|
1340
1370
|
case "object":
|
|
1341
1371
|
if (!item.render)
|
|
1342
|
-
item.render = (value) => /* @__PURE__ */ (0,
|
|
1343
|
-
|
|
1344
|
-
{
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
column: 1
|
|
1348
|
-
}
|
|
1349
|
-
);
|
|
1372
|
+
item.render = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
1373
|
+
items: item.object,
|
|
1374
|
+
dataSource: value || {},
|
|
1375
|
+
column: 1
|
|
1376
|
+
});
|
|
1350
1377
|
break;
|
|
1351
1378
|
case "object[]":
|
|
1352
1379
|
if (!item.render)
|
|
1353
|
-
item.render = (value) => /* @__PURE__ */ (0,
|
|
1354
|
-
Description,
|
|
1355
|
-
{
|
|
1380
|
+
item.render = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
1381
|
+
children: value.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
1356
1382
|
items: item.object,
|
|
1357
1383
|
dataSource: v || [],
|
|
1358
1384
|
column: 1
|
|
1359
|
-
},
|
|
1360
|
-
|
|
1361
|
-
)) });
|
|
1385
|
+
}, i))
|
|
1386
|
+
});
|
|
1362
1387
|
break;
|
|
1363
1388
|
default:
|
|
1364
1389
|
if (!item.render)
|
|
@@ -1374,7 +1399,7 @@ function Table(props) {
|
|
|
1374
1399
|
}
|
|
1375
1400
|
setColumns(props.items);
|
|
1376
1401
|
}, [props.items]);
|
|
1377
|
-
(0,
|
|
1402
|
+
(0, import_react12.useEffect)(() => {
|
|
1378
1403
|
if (!props.dataSource || !columns)
|
|
1379
1404
|
return;
|
|
1380
1405
|
for (const column of columns) {
|
|
@@ -1388,7 +1413,7 @@ function Table(props) {
|
|
|
1388
1413
|
const newColumns = [...prev];
|
|
1389
1414
|
const index = newColumns.findIndex((item) => item.id === column.id);
|
|
1390
1415
|
newColumns[index].filters = filters.concat({
|
|
1391
|
-
text: /* @__PURE__ */ (0,
|
|
1416
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1392
1417
|
value: null
|
|
1393
1418
|
});
|
|
1394
1419
|
return newColumns;
|
|
@@ -1399,26 +1424,19 @@ function Table(props) {
|
|
|
1399
1424
|
if (!columns)
|
|
1400
1425
|
return null;
|
|
1401
1426
|
if (!props.faasData)
|
|
1402
|
-
return /* @__PURE__ */ (0,
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1414
|
-
FaasDataTable,
|
|
1415
|
-
{
|
|
1416
|
-
props,
|
|
1417
|
-
columns
|
|
1418
|
-
}
|
|
1419
|
-
)
|
|
1427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
|
|
1428
|
+
...props,
|
|
1429
|
+
rowKey: props.rowKey || "id",
|
|
1430
|
+
columns,
|
|
1431
|
+
dataSource: props.dataSource
|
|
1432
|
+
});
|
|
1433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
1434
|
+
...props.faasData,
|
|
1435
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataTable, {
|
|
1436
|
+
props,
|
|
1437
|
+
columns
|
|
1420
1438
|
})
|
|
1421
|
-
);
|
|
1439
|
+
});
|
|
1422
1440
|
}
|
|
1423
1441
|
function FaasDataTable({
|
|
1424
1442
|
props,
|
|
@@ -1427,8 +1445,8 @@ function FaasDataTable({
|
|
|
1427
1445
|
params,
|
|
1428
1446
|
reload
|
|
1429
1447
|
}) {
|
|
1430
|
-
const [currentColumns, setCurrentColumns] = (0,
|
|
1431
|
-
(0,
|
|
1448
|
+
const [currentColumns, setCurrentColumns] = (0, import_react12.useState)(columns);
|
|
1449
|
+
(0, import_react12.useEffect)(() => {
|
|
1432
1450
|
if (!data || Array.isArray(data))
|
|
1433
1451
|
return;
|
|
1434
1452
|
setCurrentColumns((prev) => {
|
|
@@ -1440,7 +1458,7 @@ function FaasDataTable({
|
|
|
1440
1458
|
text: v.label,
|
|
1441
1459
|
value: v.value
|
|
1442
1460
|
})).concat({
|
|
1443
|
-
text: /* @__PURE__ */ (0,
|
|
1461
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1444
1462
|
value: null
|
|
1445
1463
|
});
|
|
1446
1464
|
column.render = (value) => processValue(column, value);
|
|
@@ -1455,7 +1473,7 @@ function FaasDataTable({
|
|
|
1455
1473
|
}));
|
|
1456
1474
|
if (filters.length)
|
|
1457
1475
|
column.filters = filters.concat({
|
|
1458
|
-
text: /* @__PURE__ */ (0,
|
|
1476
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1459
1477
|
value: null
|
|
1460
1478
|
});
|
|
1461
1479
|
}
|
|
@@ -1464,75 +1482,75 @@ function FaasDataTable({
|
|
|
1464
1482
|
});
|
|
1465
1483
|
}, [columns, data]);
|
|
1466
1484
|
if (!data)
|
|
1467
|
-
return /* @__PURE__ */ (0,
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
})
|
|
1474
|
-
);
|
|
1485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
|
|
1486
|
+
...props,
|
|
1487
|
+
rowKey: props.rowKey || "id",
|
|
1488
|
+
columns: currentColumns,
|
|
1489
|
+
dataSource: []
|
|
1490
|
+
});
|
|
1475
1491
|
if (Array.isArray(data))
|
|
1476
|
-
return /* @__PURE__ */ (0,
|
|
1477
|
-
|
|
1478
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1479
|
-
rowKey: props.rowKey || "id",
|
|
1480
|
-
columns: currentColumns,
|
|
1481
|
-
dataSource: data
|
|
1482
|
-
})
|
|
1483
|
-
);
|
|
1484
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1485
|
-
import_antd11.Table,
|
|
1486
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
|
|
1493
|
+
...props,
|
|
1487
1494
|
rowKey: props.rowKey || "id",
|
|
1488
1495
|
columns: currentColumns,
|
|
1489
|
-
dataSource: data
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1496
|
+
dataSource: data
|
|
1497
|
+
});
|
|
1498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
|
|
1499
|
+
...props,
|
|
1500
|
+
rowKey: props.rowKey || "id",
|
|
1501
|
+
columns: currentColumns,
|
|
1502
|
+
dataSource: data.rows,
|
|
1503
|
+
pagination: {
|
|
1504
|
+
...props.pagination,
|
|
1505
|
+
...data.pagination
|
|
1506
|
+
},
|
|
1507
|
+
onChange: (pagination, filters, sorter, extra) => {
|
|
1508
|
+
if (props.onChange) {
|
|
1509
|
+
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
1510
|
+
reload({
|
|
1511
|
+
...params,
|
|
1512
|
+
pagination: processed.pagination,
|
|
1513
|
+
filters: processed.filters,
|
|
1514
|
+
sorter: processed.sorter
|
|
1515
|
+
});
|
|
1516
|
+
return;
|
|
1506
1517
|
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1518
|
+
reload({
|
|
1519
|
+
...params,
|
|
1520
|
+
pagination,
|
|
1521
|
+
filters,
|
|
1522
|
+
sorter
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1509
1526
|
}
|
|
1510
1527
|
|
|
1511
1528
|
// src/Title.tsx
|
|
1512
|
-
var
|
|
1513
|
-
var
|
|
1529
|
+
var import_react13 = require("react");
|
|
1530
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1514
1531
|
function Title(props) {
|
|
1515
1532
|
const { Title: Title2 } = useConfigContext();
|
|
1516
|
-
(0,
|
|
1533
|
+
(0, import_react13.useEffect)(() => {
|
|
1517
1534
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1518
1535
|
document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
|
|
1519
1536
|
}, [props]);
|
|
1520
1537
|
if (props.h1) {
|
|
1521
1538
|
if (typeof props.h1 === "boolean")
|
|
1522
|
-
return /* @__PURE__ */ (0,
|
|
1523
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1524
|
-
"h1",
|
|
1525
|
-
{
|
|
1526
|
-
className: props.h1.className,
|
|
1527
|
-
style: props.h1.style,
|
|
1539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
1528
1540
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1529
|
-
}
|
|
1530
|
-
)
|
|
1541
|
+
});
|
|
1542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
1543
|
+
className: props.h1.className,
|
|
1544
|
+
style: props.h1.style,
|
|
1545
|
+
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1546
|
+
});
|
|
1531
1547
|
}
|
|
1532
1548
|
if (props.plain)
|
|
1533
|
-
return /* @__PURE__ */ (0,
|
|
1549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
1550
|
+
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1551
|
+
});
|
|
1534
1552
|
if (props.children)
|
|
1535
|
-
return (0,
|
|
1553
|
+
return (0, import_react13.cloneElement)(props.children, { title: props.title });
|
|
1536
1554
|
return null;
|
|
1537
1555
|
}
|
|
1538
1556
|
// Annotate the CommonJS export names for ESM import in node:
|