@faasjs/ant-design 0.0.2-beta.352 → 0.0.2-beta.353
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.d.ts +47 -4
- package/dist/index.js +134 -62
- package/dist/index.mjs +119 -46
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
|
+
import * as react_use_lib_misc_hookState from 'react-use/lib/misc/hookState';
|
|
1
2
|
import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, FormProps as FormProps$1, TableColumnProps, TableProps as TableProps$1 } from 'antd';
|
|
2
3
|
export { Drawer } from 'antd';
|
|
3
|
-
import { Dispatch, SetStateAction } from 'react';
|
|
4
|
+
import { Dispatch, SetStateAction, LazyExoticComponent, ComponentType } from 'react';
|
|
4
5
|
import * as antd_lib_form_Form from 'antd/lib/form/Form';
|
|
5
6
|
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
7
|
+
import { RouteProps } from 'react-router-dom';
|
|
6
8
|
|
|
7
|
-
declare
|
|
9
|
+
declare type BlankProps = {
|
|
8
10
|
value?: any;
|
|
9
11
|
text?: string;
|
|
10
|
-
}
|
|
12
|
+
};
|
|
13
|
+
declare function Blank(options?: BlankProps): any;
|
|
14
|
+
|
|
15
|
+
declare type FaasState = {
|
|
16
|
+
common: {
|
|
17
|
+
blank: string;
|
|
18
|
+
all: string;
|
|
19
|
+
submit: string;
|
|
20
|
+
};
|
|
21
|
+
Blank: {
|
|
22
|
+
text: string;
|
|
23
|
+
};
|
|
24
|
+
Form: {
|
|
25
|
+
submit: {
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
Title: {
|
|
30
|
+
separator: string;
|
|
31
|
+
suffix: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
declare const useFaasState: () => [FaasState, (state: react_use_lib_misc_hookState.IHookStateSetAction<FaasState>) => void];
|
|
35
|
+
declare function Config(props: {
|
|
36
|
+
config: Partial<FaasState>;
|
|
37
|
+
}): JSX.Element;
|
|
11
38
|
|
|
12
39
|
declare type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean';
|
|
13
40
|
declare type FaasItemTypeValue = {
|
|
@@ -138,6 +165,14 @@ declare namespace Form {
|
|
|
138
165
|
var Item: typeof FormItem;
|
|
139
166
|
}
|
|
140
167
|
|
|
168
|
+
declare type RoutesProps = {
|
|
169
|
+
routes: (RouteProps & {
|
|
170
|
+
page?: LazyExoticComponent<ComponentType<any>>;
|
|
171
|
+
})[];
|
|
172
|
+
notFound?: JSX.Element;
|
|
173
|
+
};
|
|
174
|
+
declare function Routes(props: RoutesProps): JSX.Element;
|
|
175
|
+
|
|
141
176
|
declare type TableItemProps<T = any> = {
|
|
142
177
|
/** @deprecated use render */
|
|
143
178
|
children?: JSX.Element | null;
|
|
@@ -155,4 +190,12 @@ declare type TableProps<T = any, ExtendTypes = any> = {
|
|
|
155
190
|
} & FaasDataWrapperProps<T> & TableProps$1<T>;
|
|
156
191
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
157
192
|
|
|
158
|
-
|
|
193
|
+
declare type TitleProps = {
|
|
194
|
+
title: string | string[];
|
|
195
|
+
/** ` - ` as default */
|
|
196
|
+
separator?: string;
|
|
197
|
+
suffix?: string;
|
|
198
|
+
};
|
|
199
|
+
declare function Title(props: TitleProps): JSX.Element;
|
|
200
|
+
|
|
201
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, Config, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, FaasItemProps, FaasItemType, FaasItemTypeValue, FaasState, Form, FormItem, FormItemProps, FormProps, Routes, RoutesProps, Table, TableItemProps, TableProps, Title, TitleProps, transferOptions, useDrawer, useFaasState };
|
package/dist/index.js
CHANGED
|
@@ -47,13 +47,17 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
47
47
|
var src_exports = {};
|
|
48
48
|
__export(src_exports, {
|
|
49
49
|
Blank: () => Blank,
|
|
50
|
+
Config: () => Config,
|
|
50
51
|
Description: () => Description,
|
|
51
52
|
Drawer: () => import_antd3.Drawer,
|
|
52
53
|
Form: () => Form,
|
|
53
54
|
FormItem: () => FormItem,
|
|
55
|
+
Routes: () => Routes,
|
|
54
56
|
Table: () => Table,
|
|
57
|
+
Title: () => Title,
|
|
55
58
|
transferOptions: () => transferOptions,
|
|
56
|
-
useDrawer: () => useDrawer
|
|
59
|
+
useDrawer: () => useDrawer,
|
|
60
|
+
useFaasState: () => useFaasState
|
|
57
61
|
});
|
|
58
62
|
|
|
59
63
|
// react-shim.js
|
|
@@ -62,12 +66,39 @@ var import_react = __toESM(require("react"));
|
|
|
62
66
|
// src/Blank.tsx
|
|
63
67
|
var import_antd = require("antd");
|
|
64
68
|
var import_lodash = require("lodash");
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
|
|
70
|
+
// src/Config.tsx
|
|
71
|
+
var import_react2 = require("react");
|
|
72
|
+
var import_react_use = require("react-use");
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
var common = {
|
|
75
|
+
blank: ((_a = navigator.language) == null ? void 0 : _a.includes("CN")) ? "\u7A7A" : "Empty",
|
|
76
|
+
all: ((_b = navigator.language) == null ? void 0 : _b.includes("CN")) ? "\u5168\u90E8" : "All",
|
|
77
|
+
submit: ((_c = navigator.language) == null ? void 0 : _c.includes("CN")) ? "\u63D0\u4EA4" : "Submit"
|
|
78
|
+
};
|
|
79
|
+
var useFaasState = (0, import_react_use.createGlobalState)({
|
|
80
|
+
common,
|
|
81
|
+
Blank: { text: common.blank },
|
|
82
|
+
Form: { submit: { text: common.submit } },
|
|
83
|
+
Title: {
|
|
84
|
+
separator: " - ",
|
|
85
|
+
suffix: ""
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
function Config(props) {
|
|
89
|
+
const [_, setState] = useFaasState();
|
|
90
|
+
(0, import_react2.useEffect)(() => {
|
|
91
|
+
setState((prev) => __spreadValues(__spreadValues({}, prev), props.config));
|
|
92
|
+
}, []);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/Blank.tsx
|
|
67
97
|
function Blank(options) {
|
|
98
|
+
const [config] = useFaasState();
|
|
68
99
|
return !options || (0, import_lodash.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ import_react.default.createElement(import_antd.Typography.Text, {
|
|
69
100
|
disabled: true
|
|
70
|
-
}, (options == null ? void 0 : options.text) || text) : options.value;
|
|
101
|
+
}, (options == null ? void 0 : options.text) || config.Blank.text) : options.value;
|
|
71
102
|
}
|
|
72
103
|
|
|
73
104
|
// src/data.ts
|
|
@@ -85,22 +116,22 @@ function transferOptions(options) {
|
|
|
85
116
|
var import_icons = require("@ant-design/icons");
|
|
86
117
|
var import_antd2 = require("antd");
|
|
87
118
|
var import_lodash3 = require("lodash");
|
|
88
|
-
var
|
|
119
|
+
var import_react5 = require("react");
|
|
89
120
|
|
|
90
121
|
// src/FaasDataWrapper.tsx
|
|
91
|
-
var
|
|
92
|
-
var
|
|
122
|
+
var import_react3 = require("react");
|
|
123
|
+
var import_react4 = require("@faasjs/react");
|
|
93
124
|
function FaasDataWrapper({
|
|
94
125
|
dataSource,
|
|
95
126
|
faasData,
|
|
96
127
|
render,
|
|
97
128
|
fallback
|
|
98
129
|
}) {
|
|
99
|
-
const [data, setData] = (0,
|
|
100
|
-
(0,
|
|
130
|
+
const [data, setData] = (0, import_react3.useState)();
|
|
131
|
+
(0, import_react3.useEffect)(() => {
|
|
101
132
|
if (!faasData)
|
|
102
133
|
return;
|
|
103
|
-
(0,
|
|
134
|
+
(0, import_react4.getClient)().faas(faasData.action, faasData.params).then((res) => {
|
|
104
135
|
if (faasData.setData)
|
|
105
136
|
faasData.setData(res.data);
|
|
106
137
|
else
|
|
@@ -116,9 +147,9 @@ function FaasDataWrapper({
|
|
|
116
147
|
|
|
117
148
|
// src/Description.tsx
|
|
118
149
|
function DescriptionItemContent(props) {
|
|
119
|
-
const [computedProps, setComputedProps] = (0,
|
|
120
|
-
(0,
|
|
121
|
-
var _a2,
|
|
150
|
+
const [computedProps, setComputedProps] = (0, import_react5.useState)();
|
|
151
|
+
(0, import_react5.useEffect)(() => {
|
|
152
|
+
var _a2, _b2;
|
|
122
153
|
const propsCopy = __spreadValues({}, props);
|
|
123
154
|
if (!propsCopy.item.title)
|
|
124
155
|
propsCopy.item.title = (0, import_lodash3.upperFirst)(propsCopy.item.id);
|
|
@@ -134,7 +165,7 @@ function DescriptionItemContent(props) {
|
|
|
134
165
|
return ((_a3 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
|
|
135
166
|
});
|
|
136
167
|
else
|
|
137
|
-
propsCopy.value = ((
|
|
168
|
+
propsCopy.value = ((_b2 = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b2.label) || props.value;
|
|
138
169
|
}
|
|
139
170
|
setComputedProps(propsCopy);
|
|
140
171
|
}, [props]);
|
|
@@ -142,7 +173,7 @@ function DescriptionItemContent(props) {
|
|
|
142
173
|
return null;
|
|
143
174
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
144
175
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
145
|
-
return (0,
|
|
176
|
+
return (0, import_react5.cloneElement)(computedProps.extendTypes[computedProps.item.type].children, {
|
|
146
177
|
value: computedProps.value,
|
|
147
178
|
values: computedProps.values
|
|
148
179
|
});
|
|
@@ -151,7 +182,7 @@ function DescriptionItemContent(props) {
|
|
|
151
182
|
else
|
|
152
183
|
throw Error(computedProps.item.type + " requires children or render");
|
|
153
184
|
if (computedProps.item.children)
|
|
154
|
-
return (0,
|
|
185
|
+
return (0, import_react5.cloneElement)(computedProps.item.children, { value: computedProps.value });
|
|
155
186
|
if (computedProps.item.render)
|
|
156
187
|
return computedProps.item.render(computedProps.value, computedProps.values);
|
|
157
188
|
if (typeof computedProps.value === "undefined" || computedProps.value === null)
|
|
@@ -195,9 +226,9 @@ function Description(props) {
|
|
|
195
226
|
|
|
196
227
|
// src/Drawer.tsx
|
|
197
228
|
var import_antd3 = require("antd");
|
|
198
|
-
var
|
|
229
|
+
var import_react6 = require("react");
|
|
199
230
|
function useDrawer(init) {
|
|
200
|
-
const [props, setProps] = (0,
|
|
231
|
+
const [props, setProps] = (0, import_react6.useState)(__spreadValues({
|
|
201
232
|
visible: false,
|
|
202
233
|
onClose: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
203
234
|
visible: false
|
|
@@ -214,16 +245,16 @@ function useDrawer(init) {
|
|
|
214
245
|
|
|
215
246
|
// src/Form.tsx
|
|
216
247
|
var import_antd5 = require("antd");
|
|
217
|
-
var
|
|
248
|
+
var import_react8 = require("react");
|
|
218
249
|
|
|
219
250
|
// src/FormItem.tsx
|
|
220
251
|
var import_antd4 = require("antd");
|
|
221
252
|
var import_icons2 = require("@ant-design/icons");
|
|
222
|
-
var
|
|
253
|
+
var import_react7 = require("react");
|
|
223
254
|
var import_lodash4 = require("lodash");
|
|
224
255
|
function FormItem(props) {
|
|
225
|
-
const [computedProps, setComputedProps] = (0,
|
|
226
|
-
(0,
|
|
256
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
257
|
+
(0, import_react7.useEffect)(() => {
|
|
227
258
|
const propsCopy = __spreadValues({}, props);
|
|
228
259
|
if (!propsCopy.title)
|
|
229
260
|
propsCopy.title = (0, import_lodash4.upperFirst)(propsCopy.id);
|
|
@@ -362,10 +393,11 @@ function FormItem(props) {
|
|
|
362
393
|
|
|
363
394
|
// src/Form.tsx
|
|
364
395
|
function Form(props) {
|
|
365
|
-
var _a2,
|
|
366
|
-
const [loading, setLoading] = (0,
|
|
367
|
-
const [computedProps, setComputedProps] = (0,
|
|
368
|
-
|
|
396
|
+
var _a2, _b2;
|
|
397
|
+
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
398
|
+
const [computedProps, setComputedProps] = (0, import_react8.useState)();
|
|
399
|
+
const [config] = useFaasState();
|
|
400
|
+
(0, import_react8.useEffect)(() => {
|
|
369
401
|
const propsCopy = __spreadValues({}, props);
|
|
370
402
|
if (propsCopy.onFinish) {
|
|
371
403
|
propsCopy.onFinish = async (values) => {
|
|
@@ -390,14 +422,41 @@ function Form(props) {
|
|
|
390
422
|
htmlType: "submit",
|
|
391
423
|
type: "primary",
|
|
392
424
|
loading
|
|
393
|
-
}, ((
|
|
425
|
+
}, ((_b2 = props.submit) == null ? void 0 : _b2.text) || config.Form.submit.text));
|
|
394
426
|
}
|
|
395
427
|
Form.useForm = import_antd5.Form.useForm;
|
|
396
428
|
Form.Item = FormItem;
|
|
397
429
|
|
|
398
|
-
// src/
|
|
399
|
-
var import_react8 = require("react");
|
|
430
|
+
// src/Routers.tsx
|
|
400
431
|
var import_antd6 = require("antd");
|
|
432
|
+
var import_react9 = require("react");
|
|
433
|
+
var import_react_router_dom = require("react-router-dom");
|
|
434
|
+
function NoMatch() {
|
|
435
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd6.Result, {
|
|
436
|
+
status: "404",
|
|
437
|
+
title: "404",
|
|
438
|
+
subTitle: "Page not found"
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
function Routes(props) {
|
|
442
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Routes, null, props.routes.map((r) => /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Route, __spreadProps(__spreadValues({
|
|
443
|
+
key: r.path
|
|
444
|
+
}, r), {
|
|
445
|
+
element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react9.Suspense, {
|
|
446
|
+
fallback: /* @__PURE__ */ import_react.default.createElement(import_antd6.Skeleton, {
|
|
447
|
+
active: true
|
|
448
|
+
})
|
|
449
|
+
}, /* @__PURE__ */ import_react.default.createElement(r.page, null))
|
|
450
|
+
}))), /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Route, {
|
|
451
|
+
key: "*",
|
|
452
|
+
path: "*",
|
|
453
|
+
element: props.notFound || /* @__PURE__ */ import_react.default.createElement(NoMatch, null)
|
|
454
|
+
}));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// src/Table.tsx
|
|
458
|
+
var import_react10 = require("react");
|
|
459
|
+
var import_antd7 = require("antd");
|
|
401
460
|
var import_icons3 = require("@ant-design/icons");
|
|
402
461
|
var import_lodash5 = require("lodash");
|
|
403
462
|
function processValue(item, value) {
|
|
@@ -414,8 +473,9 @@ function processValue(item, value) {
|
|
|
414
473
|
return value;
|
|
415
474
|
}
|
|
416
475
|
function Table(props) {
|
|
417
|
-
const [columns, setColumns] = (0,
|
|
418
|
-
|
|
476
|
+
const [columns, setColumns] = (0, import_react10.useState)();
|
|
477
|
+
const [config] = useFaasState();
|
|
478
|
+
(0, import_react10.useEffect)(() => {
|
|
419
479
|
var _a2;
|
|
420
480
|
for (const item of props.items) {
|
|
421
481
|
if (!item.key)
|
|
@@ -439,7 +499,7 @@ function Table(props) {
|
|
|
439
499
|
delete item.children;
|
|
440
500
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
441
501
|
if (props.extendTypes[item.type].children) {
|
|
442
|
-
item.render = (value, values) => (0,
|
|
502
|
+
item.render = (value, values) => (0, import_react10.cloneElement)(props.extendTypes[item.type].children, {
|
|
443
503
|
value,
|
|
444
504
|
values
|
|
445
505
|
});
|
|
@@ -484,34 +544,31 @@ function Table(props) {
|
|
|
484
544
|
setSelectedKeys,
|
|
485
545
|
selectedKeys,
|
|
486
546
|
confirm
|
|
487
|
-
}) => {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
value:
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
value: "empty"
|
|
513
|
-
}, ((_b = navigator.language) == null ? void 0 : _b.includes("CN")) ? "\u7A7A" : "Empty"));
|
|
514
|
-
};
|
|
547
|
+
}) => /* @__PURE__ */ import_react.default.createElement(import_antd7.Radio.Group, {
|
|
548
|
+
style: { padding: 8 },
|
|
549
|
+
buttonStyle: "solid",
|
|
550
|
+
value: selectedKeys[0],
|
|
551
|
+
onChange: (e) => {
|
|
552
|
+
setSelectedKeys(e.target.value ? [e.target.value] : []);
|
|
553
|
+
confirm();
|
|
554
|
+
}
|
|
555
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd7.Radio.Button, null, config.common.all), /* @__PURE__ */ import_react.default.createElement(import_antd7.Radio.Button, {
|
|
556
|
+
value: "true"
|
|
557
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_icons3.CheckOutlined, {
|
|
558
|
+
style: {
|
|
559
|
+
color: "#52c41a",
|
|
560
|
+
verticalAlign: "middle"
|
|
561
|
+
}
|
|
562
|
+
})), /* @__PURE__ */ import_react.default.createElement(import_antd7.Radio.Button, {
|
|
563
|
+
value: "false"
|
|
564
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_icons3.CloseOutlined, {
|
|
565
|
+
style: {
|
|
566
|
+
verticalAlign: "middle",
|
|
567
|
+
color: "#ff4d4f"
|
|
568
|
+
}
|
|
569
|
+
})), /* @__PURE__ */ import_react.default.createElement(import_antd7.Radio.Button, {
|
|
570
|
+
value: "empty"
|
|
571
|
+
}, config.common.blank));
|
|
515
572
|
if (!item.onFilter)
|
|
516
573
|
item.onFilter = (value, row) => {
|
|
517
574
|
switch (value) {
|
|
@@ -538,22 +595,37 @@ function Table(props) {
|
|
|
538
595
|
if (!columns)
|
|
539
596
|
return null;
|
|
540
597
|
return /* @__PURE__ */ import_react.default.createElement(FaasDataWrapper, __spreadValues({
|
|
541
|
-
render: ({ data }) => /* @__PURE__ */ import_react.default.createElement(
|
|
598
|
+
render: ({ data }) => /* @__PURE__ */ import_react.default.createElement(import_antd7.Table, __spreadProps(__spreadValues({}, props), {
|
|
542
599
|
rowKey: props.rowKey || "id",
|
|
543
600
|
columns,
|
|
544
601
|
dataSource: data
|
|
545
602
|
}))
|
|
546
603
|
}, props));
|
|
547
604
|
}
|
|
605
|
+
|
|
606
|
+
// src/Title.tsx
|
|
607
|
+
var import_react11 = require("react");
|
|
608
|
+
function Title(props) {
|
|
609
|
+
const [config] = useFaasState();
|
|
610
|
+
(0, import_react11.useEffect)(() => {
|
|
611
|
+
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
612
|
+
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
613
|
+
}, []);
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
548
616
|
module.exports = __toCommonJS(src_exports);
|
|
549
617
|
// Annotate the CommonJS export names for ESM import in node:
|
|
550
618
|
0 && (module.exports = {
|
|
551
619
|
Blank,
|
|
620
|
+
Config,
|
|
552
621
|
Description,
|
|
553
622
|
Drawer,
|
|
554
623
|
Form,
|
|
555
624
|
FormItem,
|
|
625
|
+
Routes,
|
|
556
626
|
Table,
|
|
627
|
+
Title,
|
|
557
628
|
transferOptions,
|
|
558
|
-
useDrawer
|
|
629
|
+
useDrawer,
|
|
630
|
+
useFaasState
|
|
559
631
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -24,12 +24,39 @@ import React from "react";
|
|
|
24
24
|
// src/Blank.tsx
|
|
25
25
|
import { Typography } from "antd";
|
|
26
26
|
import { isNil } from "lodash";
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
// src/Config.tsx
|
|
29
|
+
import { useEffect } from "react";
|
|
30
|
+
import { createGlobalState } from "react-use";
|
|
31
|
+
var _a, _b, _c;
|
|
32
|
+
var common = {
|
|
33
|
+
blank: ((_a = navigator.language) == null ? void 0 : _a.includes("CN")) ? "\u7A7A" : "Empty",
|
|
34
|
+
all: ((_b = navigator.language) == null ? void 0 : _b.includes("CN")) ? "\u5168\u90E8" : "All",
|
|
35
|
+
submit: ((_c = navigator.language) == null ? void 0 : _c.includes("CN")) ? "\u63D0\u4EA4" : "Submit"
|
|
36
|
+
};
|
|
37
|
+
var useFaasState = createGlobalState({
|
|
38
|
+
common,
|
|
39
|
+
Blank: { text: common.blank },
|
|
40
|
+
Form: { submit: { text: common.submit } },
|
|
41
|
+
Title: {
|
|
42
|
+
separator: " - ",
|
|
43
|
+
suffix: ""
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
function Config(props) {
|
|
47
|
+
const [_, setState] = useFaasState();
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setState((prev) => __spreadValues(__spreadValues({}, prev), props.config));
|
|
50
|
+
}, []);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/Blank.tsx
|
|
29
55
|
function Blank(options) {
|
|
56
|
+
const [config] = useFaasState();
|
|
30
57
|
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ React.createElement(Typography.Text, {
|
|
31
58
|
disabled: true
|
|
32
|
-
}, (options == null ? void 0 : options.text) || text) : options.value;
|
|
59
|
+
}, (options == null ? void 0 : options.text) || config.Blank.text) : options.value;
|
|
33
60
|
}
|
|
34
61
|
|
|
35
62
|
// src/data.ts
|
|
@@ -49,13 +76,13 @@ import { Descriptions } from "antd";
|
|
|
49
76
|
import { upperFirst as upperFirst2 } from "lodash";
|
|
50
77
|
import {
|
|
51
78
|
cloneElement,
|
|
52
|
-
useEffect as
|
|
79
|
+
useEffect as useEffect3,
|
|
53
80
|
useState as useState2
|
|
54
81
|
} from "react";
|
|
55
82
|
|
|
56
83
|
// src/FaasDataWrapper.tsx
|
|
57
84
|
import {
|
|
58
|
-
useEffect,
|
|
85
|
+
useEffect as useEffect2,
|
|
59
86
|
useState
|
|
60
87
|
} from "react";
|
|
61
88
|
import { getClient } from "@faasjs/react";
|
|
@@ -66,7 +93,7 @@ function FaasDataWrapper({
|
|
|
66
93
|
fallback
|
|
67
94
|
}) {
|
|
68
95
|
const [data, setData] = useState();
|
|
69
|
-
|
|
96
|
+
useEffect2(() => {
|
|
70
97
|
if (!faasData)
|
|
71
98
|
return;
|
|
72
99
|
getClient().faas(faasData.action, faasData.params).then((res) => {
|
|
@@ -86,8 +113,8 @@ function FaasDataWrapper({
|
|
|
86
113
|
// src/Description.tsx
|
|
87
114
|
function DescriptionItemContent(props) {
|
|
88
115
|
const [computedProps, setComputedProps] = useState2();
|
|
89
|
-
|
|
90
|
-
var _a2,
|
|
116
|
+
useEffect3(() => {
|
|
117
|
+
var _a2, _b2;
|
|
91
118
|
const propsCopy = __spreadValues({}, props);
|
|
92
119
|
if (!propsCopy.item.title)
|
|
93
120
|
propsCopy.item.title = upperFirst2(propsCopy.item.id);
|
|
@@ -103,7 +130,7 @@ function DescriptionItemContent(props) {
|
|
|
103
130
|
return ((_a3 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
|
|
104
131
|
});
|
|
105
132
|
else
|
|
106
|
-
propsCopy.value = ((
|
|
133
|
+
propsCopy.value = ((_b2 = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b2.label) || props.value;
|
|
107
134
|
}
|
|
108
135
|
setComputedProps(propsCopy);
|
|
109
136
|
}, [props]);
|
|
@@ -186,7 +213,7 @@ import {
|
|
|
186
213
|
Button as Button2,
|
|
187
214
|
Form as AntdForm2
|
|
188
215
|
} from "antd";
|
|
189
|
-
import { useEffect as
|
|
216
|
+
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
190
217
|
|
|
191
218
|
// src/FormItem.tsx
|
|
192
219
|
import {
|
|
@@ -200,11 +227,11 @@ import {
|
|
|
200
227
|
Select
|
|
201
228
|
} from "antd";
|
|
202
229
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
203
|
-
import { useEffect as
|
|
230
|
+
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
204
231
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
205
232
|
function FormItem(props) {
|
|
206
233
|
const [computedProps, setComputedProps] = useState4();
|
|
207
|
-
|
|
234
|
+
useEffect4(() => {
|
|
208
235
|
const propsCopy = __spreadValues({}, props);
|
|
209
236
|
if (!propsCopy.title)
|
|
210
237
|
propsCopy.title = upperFirst3(propsCopy.id);
|
|
@@ -343,10 +370,11 @@ function FormItem(props) {
|
|
|
343
370
|
|
|
344
371
|
// src/Form.tsx
|
|
345
372
|
function Form(props) {
|
|
346
|
-
var _a2,
|
|
373
|
+
var _a2, _b2;
|
|
347
374
|
const [loading, setLoading] = useState5(false);
|
|
348
375
|
const [computedProps, setComputedProps] = useState5();
|
|
349
|
-
|
|
376
|
+
const [config] = useFaasState();
|
|
377
|
+
useEffect5(() => {
|
|
350
378
|
const propsCopy = __spreadValues({}, props);
|
|
351
379
|
if (propsCopy.onFinish) {
|
|
352
380
|
propsCopy.onFinish = async (values) => {
|
|
@@ -371,15 +399,47 @@ function Form(props) {
|
|
|
371
399
|
htmlType: "submit",
|
|
372
400
|
type: "primary",
|
|
373
401
|
loading
|
|
374
|
-
}, ((
|
|
402
|
+
}, ((_b2 = props.submit) == null ? void 0 : _b2.text) || config.Form.submit.text));
|
|
375
403
|
}
|
|
376
404
|
Form.useForm = AntdForm2.useForm;
|
|
377
405
|
Form.Item = FormItem;
|
|
378
406
|
|
|
407
|
+
// src/Routers.tsx
|
|
408
|
+
import { Result, Skeleton } from "antd";
|
|
409
|
+
import {
|
|
410
|
+
Suspense
|
|
411
|
+
} from "react";
|
|
412
|
+
import {
|
|
413
|
+
Routes as OriginRoutes,
|
|
414
|
+
Route
|
|
415
|
+
} from "react-router-dom";
|
|
416
|
+
function NoMatch() {
|
|
417
|
+
return /* @__PURE__ */ React.createElement(Result, {
|
|
418
|
+
status: "404",
|
|
419
|
+
title: "404",
|
|
420
|
+
subTitle: "Page not found"
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function Routes(props) {
|
|
424
|
+
return /* @__PURE__ */ React.createElement(OriginRoutes, null, props.routes.map((r) => /* @__PURE__ */ React.createElement(Route, __spreadProps(__spreadValues({
|
|
425
|
+
key: r.path
|
|
426
|
+
}, r), {
|
|
427
|
+
element: r.element || /* @__PURE__ */ React.createElement(Suspense, {
|
|
428
|
+
fallback: /* @__PURE__ */ React.createElement(Skeleton, {
|
|
429
|
+
active: true
|
|
430
|
+
})
|
|
431
|
+
}, /* @__PURE__ */ React.createElement(r.page, null))
|
|
432
|
+
}))), /* @__PURE__ */ React.createElement(Route, {
|
|
433
|
+
key: "*",
|
|
434
|
+
path: "*",
|
|
435
|
+
element: props.notFound || /* @__PURE__ */ React.createElement(NoMatch, null)
|
|
436
|
+
}));
|
|
437
|
+
}
|
|
438
|
+
|
|
379
439
|
// src/Table.tsx
|
|
380
440
|
import {
|
|
381
441
|
useState as useState6,
|
|
382
|
-
useEffect as
|
|
442
|
+
useEffect as useEffect6,
|
|
383
443
|
cloneElement as cloneElement2
|
|
384
444
|
} from "react";
|
|
385
445
|
import {
|
|
@@ -403,7 +463,8 @@ function processValue(item, value) {
|
|
|
403
463
|
}
|
|
404
464
|
function Table(props) {
|
|
405
465
|
const [columns, setColumns] = useState6();
|
|
406
|
-
|
|
466
|
+
const [config] = useFaasState();
|
|
467
|
+
useEffect6(() => {
|
|
407
468
|
var _a2;
|
|
408
469
|
for (const item of props.items) {
|
|
409
470
|
if (!item.key)
|
|
@@ -472,34 +533,31 @@ function Table(props) {
|
|
|
472
533
|
setSelectedKeys,
|
|
473
534
|
selectedKeys,
|
|
474
535
|
confirm
|
|
475
|
-
}) => {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
value:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
value: "empty"
|
|
501
|
-
}, ((_b = navigator.language) == null ? void 0 : _b.includes("CN")) ? "\u7A7A" : "Empty"));
|
|
502
|
-
};
|
|
536
|
+
}) => /* @__PURE__ */ React.createElement(Radio.Group, {
|
|
537
|
+
style: { padding: 8 },
|
|
538
|
+
buttonStyle: "solid",
|
|
539
|
+
value: selectedKeys[0],
|
|
540
|
+
onChange: (e) => {
|
|
541
|
+
setSelectedKeys(e.target.value ? [e.target.value] : []);
|
|
542
|
+
confirm();
|
|
543
|
+
}
|
|
544
|
+
}, /* @__PURE__ */ React.createElement(Radio.Button, null, config.common.all), /* @__PURE__ */ React.createElement(Radio.Button, {
|
|
545
|
+
value: "true"
|
|
546
|
+
}, /* @__PURE__ */ React.createElement(CheckOutlined2, {
|
|
547
|
+
style: {
|
|
548
|
+
color: "#52c41a",
|
|
549
|
+
verticalAlign: "middle"
|
|
550
|
+
}
|
|
551
|
+
})), /* @__PURE__ */ React.createElement(Radio.Button, {
|
|
552
|
+
value: "false"
|
|
553
|
+
}, /* @__PURE__ */ React.createElement(CloseOutlined2, {
|
|
554
|
+
style: {
|
|
555
|
+
verticalAlign: "middle",
|
|
556
|
+
color: "#ff4d4f"
|
|
557
|
+
}
|
|
558
|
+
})), /* @__PURE__ */ React.createElement(Radio.Button, {
|
|
559
|
+
value: "empty"
|
|
560
|
+
}, config.common.blank));
|
|
503
561
|
if (!item.onFilter)
|
|
504
562
|
item.onFilter = (value, row) => {
|
|
505
563
|
switch (value) {
|
|
@@ -533,13 +591,28 @@ function Table(props) {
|
|
|
533
591
|
}))
|
|
534
592
|
}, props));
|
|
535
593
|
}
|
|
594
|
+
|
|
595
|
+
// src/Title.tsx
|
|
596
|
+
import { useEffect as useEffect7 } from "react";
|
|
597
|
+
function Title(props) {
|
|
598
|
+
const [config] = useFaasState();
|
|
599
|
+
useEffect7(() => {
|
|
600
|
+
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
601
|
+
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
602
|
+
}, []);
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
536
605
|
export {
|
|
537
606
|
Blank,
|
|
607
|
+
Config,
|
|
538
608
|
Description,
|
|
539
609
|
Drawer,
|
|
540
610
|
Form,
|
|
541
611
|
FormItem,
|
|
612
|
+
Routes,
|
|
542
613
|
Table,
|
|
614
|
+
Title,
|
|
543
615
|
transferOptions,
|
|
544
|
-
useDrawer
|
|
616
|
+
useDrawer,
|
|
617
|
+
useFaasState
|
|
545
618
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.353",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"lodash": "*",
|
|
28
28
|
"react": "*",
|
|
29
29
|
"react-dom": "*",
|
|
30
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
30
|
+
"@faasjs/react": "^0.0.2-beta.353",
|
|
31
|
+
"react-use": "*",
|
|
32
|
+
"react-router-dom": "*"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@types/lodash": "*",
|