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