@faasjs/ant-design 0.0.2-beta.363 → 0.0.2-beta.367
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/README.md +54 -8
- package/dist/index.d.ts +54 -3
- package/dist/index.js +101 -74
- package/dist/index.mjs +78 -53
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,6 +65,7 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
|
|
|
65
65
|
- [FaasState](#faasstate)
|
|
66
66
|
- [FormItemProps](#formitemprops)
|
|
67
67
|
- [FormProps](#formprops)
|
|
68
|
+
- [ModalProps](#modalprops)
|
|
68
69
|
- [RoutesProps](#routesprops)
|
|
69
70
|
- [TableItemProps](#tableitemprops)
|
|
70
71
|
- [TableProps](#tableprops)
|
|
@@ -83,6 +84,7 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
|
|
|
83
84
|
- [transferOptions](#transferoptions)
|
|
84
85
|
- [useDrawer](#usedrawer)
|
|
85
86
|
- [useFaasState](#usefaasstate)
|
|
87
|
+
- [useModal](#usemodal)
|
|
86
88
|
|
|
87
89
|
## Type aliases
|
|
88
90
|
|
|
@@ -248,15 +250,15 @@ ___
|
|
|
248
250
|
|
|
249
251
|
| Name | Type |
|
|
250
252
|
| :------ | :------ |
|
|
251
|
-
| `Blank` | `
|
|
253
|
+
| `Blank` | { `text`: `string` } |
|
|
252
254
|
| `Blank.text` | `string` |
|
|
253
|
-
| `Form` | `
|
|
254
|
-
| `Form.submit` | `
|
|
255
|
+
| `Form` | { `submit`: { `text`: `string` } } |
|
|
256
|
+
| `Form.submit` | { `text`: `string` } |
|
|
255
257
|
| `Form.submit.text` | `string` |
|
|
256
|
-
| `Title` | `
|
|
258
|
+
| `Title` | { `separator`: `string` ; `suffix`: `string` } |
|
|
257
259
|
| `Title.separator` | `string` |
|
|
258
260
|
| `Title.suffix` | `string` |
|
|
259
|
-
| `common` | `
|
|
261
|
+
| `common` | { `all`: `string` ; `blank`: `string` ; `pageNotFound`: `string` ; `submit`: `string` } |
|
|
260
262
|
| `common.all` | `string` |
|
|
261
263
|
| `common.blank` | `string` |
|
|
262
264
|
| `common.pageNotFound` | `string` |
|
|
@@ -289,6 +291,12 @@ ___
|
|
|
289
291
|
|
|
290
292
|
___
|
|
291
293
|
|
|
294
|
+
### ModalProps
|
|
295
|
+
|
|
296
|
+
Ƭ **ModalProps**: `AntdModalProps` & { `children?`: `JSX.Element` \| `JSX.Element`[] }
|
|
297
|
+
|
|
298
|
+
___
|
|
299
|
+
|
|
292
300
|
### RoutesProps
|
|
293
301
|
|
|
294
302
|
Ƭ **RoutesProps**: `Object`
|
|
@@ -439,6 +447,18 @@ ___
|
|
|
439
447
|
|
|
440
448
|
▸ **FormItem**<`T`\>(`props`): `Element`
|
|
441
449
|
|
|
450
|
+
FormItem, can be used without Form.
|
|
451
|
+
|
|
452
|
+
```ts
|
|
453
|
+
// use inline type
|
|
454
|
+
<FormItem item={{ type: 'string', id: 'name' }} />
|
|
455
|
+
|
|
456
|
+
// use custom type
|
|
457
|
+
<FormItem item={{ id: 'password' }}>
|
|
458
|
+
<Input.Password />
|
|
459
|
+
</>
|
|
460
|
+
```
|
|
461
|
+
|
|
442
462
|
#### Type parameters
|
|
443
463
|
|
|
444
464
|
| Name | Type |
|
|
@@ -532,11 +552,13 @@ ___
|
|
|
532
552
|
|
|
533
553
|
▸ **useDrawer**(`init?`): `Object`
|
|
534
554
|
|
|
555
|
+
Hook style drawer.
|
|
556
|
+
|
|
535
557
|
#### Parameters
|
|
536
558
|
|
|
537
|
-
| Name | Type |
|
|
538
|
-
| :------ | :------ |
|
|
539
|
-
| `init?` | [`DrawerProps`](#drawerprops) |
|
|
559
|
+
| Name | Type | Description |
|
|
560
|
+
| :------ | :------ | :------ |
|
|
561
|
+
| `init?` | [`DrawerProps`](#drawerprops) | initial props ```ts function Example() { const { drawer, setDrawerProps } = useDrawer() return <> <Button onClick={ () => setDrawerProps(prev => ({ visible: !prev.visible})) }> Toggle </Button> {drawer} </> } ``` |
|
|
540
562
|
|
|
541
563
|
#### Returns
|
|
542
564
|
|
|
@@ -557,3 +579,27 @@ ___
|
|
|
557
579
|
#### Returns
|
|
558
580
|
|
|
559
581
|
[[`FaasState`](#faasstate), (`state`: `IHookStateSetAction`<[`FaasState`](#faasstate)\>) => `void`]
|
|
582
|
+
|
|
583
|
+
___
|
|
584
|
+
|
|
585
|
+
### useModal
|
|
586
|
+
|
|
587
|
+
▸ **useModal**(`init?`): `Object`
|
|
588
|
+
|
|
589
|
+
Hook style modal.
|
|
590
|
+
|
|
591
|
+
#### Parameters
|
|
592
|
+
|
|
593
|
+
| Name | Type | Description |
|
|
594
|
+
| :------ | :------ | :------ |
|
|
595
|
+
| `init?` | [`ModalProps`](#modalprops) | initial props ```ts function Example() { const { modal, setModalProps } = useModal() return <>{modal}</> } ``` |
|
|
596
|
+
|
|
597
|
+
#### Returns
|
|
598
|
+
|
|
599
|
+
`Object`
|
|
600
|
+
|
|
601
|
+
| Name | Type |
|
|
602
|
+
| :------ | :------ |
|
|
603
|
+
| `Modal` | `Element` |
|
|
604
|
+
| `ModalProps` | [`ModalProps`](#modalprops) |
|
|
605
|
+
| `setModalProps` | (`changes`: `Partial`<[`ModalProps`](#modalprops)\>) => `void` |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_use_lib_misc_hookState from 'react-use/lib/misc/hookState';
|
|
2
|
-
import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, FormProps as FormProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1 } from 'antd';
|
|
3
|
-
export { Drawer } from 'antd';
|
|
2
|
+
import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, FormProps as FormProps$1, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1 } from 'antd';
|
|
3
|
+
export { Drawer, Modal } from 'antd';
|
|
4
4
|
import { FaasDataWrapperProps } from '@faasjs/react';
|
|
5
5
|
import * as antd_lib_form_Form from 'antd/lib/form/Form';
|
|
6
6
|
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
@@ -116,6 +116,23 @@ declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
|
116
116
|
declare type DrawerProps = DrawerProps$1 & {
|
|
117
117
|
children?: JSX.Element | JSX.Element[];
|
|
118
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* Hook style drawer.
|
|
121
|
+
* @param init initial props
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* function Example() {
|
|
125
|
+
* const { drawer, setDrawerProps } = useDrawer()
|
|
126
|
+
*
|
|
127
|
+
* return <>
|
|
128
|
+
* <Button onClick={ () => setDrawerProps(prev => ({ visible: !prev.visible})) }>
|
|
129
|
+
* Toggle
|
|
130
|
+
* </Button>
|
|
131
|
+
* {drawer}
|
|
132
|
+
* </>
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
119
136
|
declare function useDrawer(init?: DrawerProps): {
|
|
120
137
|
drawer: JSX.Element;
|
|
121
138
|
drawerProps: DrawerProps;
|
|
@@ -163,6 +180,19 @@ declare type FormItemProps<T = any> = {
|
|
|
163
180
|
[type: string]: ExtendFormTypeProps;
|
|
164
181
|
};
|
|
165
182
|
} & FormItemInputProps<T> & FaasItemProps & FormItemProps$1<T>;
|
|
183
|
+
/**
|
|
184
|
+
* FormItem, can be used without Form.
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* // use inline type
|
|
188
|
+
* <FormItem item={{ type: 'string', id: 'name' }} />
|
|
189
|
+
*
|
|
190
|
+
* // use custom type
|
|
191
|
+
* <FormItem item={{ id: 'password' }}>
|
|
192
|
+
* <Input.Password />
|
|
193
|
+
* </>
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
166
196
|
declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
|
|
167
197
|
|
|
168
198
|
declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
@@ -182,6 +212,27 @@ declare namespace Form {
|
|
|
182
212
|
var Item: typeof FormItem;
|
|
183
213
|
}
|
|
184
214
|
|
|
215
|
+
declare type ModalProps = ModalProps$1 & {
|
|
216
|
+
children?: JSX.Element | JSX.Element[];
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Hook style modal.
|
|
220
|
+
* @param init initial props
|
|
221
|
+
*
|
|
222
|
+
* ```ts
|
|
223
|
+
* function Example() {
|
|
224
|
+
* const { modal, setModalProps } = useModal()
|
|
225
|
+
*
|
|
226
|
+
* return <>{modal}</>
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare function useModal(init?: ModalProps): {
|
|
231
|
+
Modal: JSX.Element;
|
|
232
|
+
ModalProps: ModalProps;
|
|
233
|
+
setModalProps(changes: Partial<ModalProps>): void;
|
|
234
|
+
};
|
|
235
|
+
|
|
185
236
|
declare type RoutesProps = {
|
|
186
237
|
routes: (RouteProps & {
|
|
187
238
|
page?: LazyExoticComponent<ComponentType<any>>;
|
|
@@ -223,4 +274,4 @@ declare type TitleProps = {
|
|
|
223
274
|
};
|
|
224
275
|
declare function Title(props: TitleProps): JSX.Element;
|
|
225
276
|
|
|
226
|
-
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 };
|
|
277
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, Config, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, FaasItemProps, FaasItemType, FaasItemTypeValue, FaasState, Form, FormItem, FormItemProps, FormProps, ModalProps, Routes, RoutesProps, Table, TableItemProps, TableProps, Title, TitleProps, transferOptions, useDrawer, useFaasState, useModal };
|
package/dist/index.js
CHANGED
|
@@ -52,12 +52,14 @@ __export(src_exports, {
|
|
|
52
52
|
Drawer: () => import_antd3.Drawer,
|
|
53
53
|
Form: () => Form,
|
|
54
54
|
FormItem: () => FormItem,
|
|
55
|
+
Modal: () => import_antd6.Modal,
|
|
55
56
|
Routes: () => Routes,
|
|
56
57
|
Table: () => Table,
|
|
57
58
|
Title: () => Title,
|
|
58
59
|
transferOptions: () => transferOptions,
|
|
59
60
|
useDrawer: () => useDrawer,
|
|
60
|
-
useFaasState: () => useFaasState
|
|
61
|
+
useFaasState: () => useFaasState,
|
|
62
|
+
useModal: () => useModal
|
|
61
63
|
});
|
|
62
64
|
|
|
63
65
|
// react-shim.js
|
|
@@ -302,35 +304,41 @@ function FormItem(props) {
|
|
|
302
304
|
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.List, {
|
|
303
305
|
name: computedProps.name,
|
|
304
306
|
rules: computedProps.rules
|
|
305
|
-
}, (fields, { add, remove }, { errors }) =>
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
307
|
+
}, (fields, { add, remove }, { errors }) => {
|
|
308
|
+
var _a;
|
|
309
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.label && /* @__PURE__ */ import_react.default.createElement("div", {
|
|
310
|
+
className: "ant-form-item-label"
|
|
311
|
+
}, /* @__PURE__ */ import_react.default.createElement("label", {
|
|
312
|
+
className: computedProps.rules.find((r) => r.required) && "ant-form-item-required"
|
|
313
|
+
}, computedProps.label)), fields.map((field) => {
|
|
314
|
+
var _a2;
|
|
315
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, {
|
|
316
|
+
key: field.key
|
|
317
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
|
|
318
|
+
gutter: 24,
|
|
319
|
+
style: { flexFlow: "row nowrap" }
|
|
320
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
|
|
321
|
+
span: 23
|
|
322
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadProps(__spreadValues({}, field), {
|
|
323
|
+
noStyle: true
|
|
324
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_antd4.Input, __spreadValues({}, computedProps.input)))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
|
|
325
|
+
span: 1
|
|
326
|
+
}, !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
|
|
327
|
+
danger: true,
|
|
328
|
+
type: "link",
|
|
329
|
+
style: { float: "right" },
|
|
330
|
+
icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.MinusCircleOutlined, null),
|
|
331
|
+
onClick: () => remove(field.name)
|
|
332
|
+
}))));
|
|
333
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, null, !((_a = computedProps.input) == null ? void 0 : _a.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
|
|
334
|
+
type: "dashed",
|
|
335
|
+
block: true,
|
|
336
|
+
onClick: () => add(),
|
|
337
|
+
icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.PlusOutlined, null)
|
|
338
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.ErrorList, {
|
|
339
|
+
errors
|
|
340
|
+
})));
|
|
341
|
+
});
|
|
334
342
|
case "number":
|
|
335
343
|
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.InputNumber, __spreadValues({
|
|
336
344
|
style: { width: "100%" }
|
|
@@ -344,31 +352,34 @@ function FormItem(props) {
|
|
|
344
352
|
name: computedProps.name,
|
|
345
353
|
rules: computedProps.rules
|
|
346
354
|
}, (fields, { add, remove }, { errors }) => {
|
|
347
|
-
var _a;
|
|
355
|
+
var _a, _b;
|
|
348
356
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.label && /* @__PURE__ */ import_react.default.createElement("div", {
|
|
349
357
|
className: "ant-form-item-label"
|
|
350
358
|
}, /* @__PURE__ */ import_react.default.createElement("label", {
|
|
351
359
|
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required"
|
|
352
|
-
}, computedProps.label)), fields.map((field) =>
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
360
|
+
}, computedProps.label)), fields.map((field) => {
|
|
361
|
+
var _a2;
|
|
362
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, {
|
|
363
|
+
key: field.key
|
|
364
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
|
|
365
|
+
gutter: 24,
|
|
366
|
+
style: { flexFlow: "row nowrap" }
|
|
367
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
|
|
368
|
+
span: 23
|
|
369
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadProps(__spreadValues({}, field), {
|
|
370
|
+
noStyle: true
|
|
371
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_antd4.InputNumber, __spreadValues({
|
|
372
|
+
style: { width: "100%" }
|
|
373
|
+
}, computedProps.input)))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
|
|
374
|
+
span: 1
|
|
375
|
+
}, !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
|
|
376
|
+
danger: true,
|
|
377
|
+
type: "link",
|
|
378
|
+
style: { float: "right" },
|
|
379
|
+
icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.MinusCircleOutlined, null),
|
|
380
|
+
onClick: () => remove(field.name)
|
|
381
|
+
}))));
|
|
382
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, null, !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
|
|
372
383
|
type: "dashed",
|
|
373
384
|
block: true,
|
|
374
385
|
onClick: () => add(),
|
|
@@ -420,13 +431,27 @@ function Form(props) {
|
|
|
420
431
|
Form.useForm = import_antd5.Form.useForm;
|
|
421
432
|
Form.Item = FormItem;
|
|
422
433
|
|
|
423
|
-
// src/
|
|
434
|
+
// src/Modal.tsx
|
|
424
435
|
var import_antd6 = require("antd");
|
|
425
436
|
var import_react8 = require("react");
|
|
437
|
+
function useModal(init) {
|
|
438
|
+
const [props, setProps] = (0, import_react8.useState)(init);
|
|
439
|
+
return {
|
|
440
|
+
Modal: /* @__PURE__ */ import_react.default.createElement(import_antd6.Modal, __spreadValues({}, props)),
|
|
441
|
+
ModalProps: props,
|
|
442
|
+
setModalProps(changes) {
|
|
443
|
+
setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// src/Routers.tsx
|
|
449
|
+
var import_antd7 = require("antd");
|
|
450
|
+
var import_react9 = require("react");
|
|
426
451
|
var import_react_router_dom = require("react-router-dom");
|
|
427
452
|
function NotFound() {
|
|
428
453
|
const [config] = useFaasState();
|
|
429
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
454
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd7.Result, {
|
|
430
455
|
status: "404",
|
|
431
456
|
title: config.common.pageNotFound
|
|
432
457
|
});
|
|
@@ -435,10 +460,10 @@ function Routes(props) {
|
|
|
435
460
|
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({
|
|
436
461
|
key: r.path
|
|
437
462
|
}, r), {
|
|
438
|
-
element: r.element || /* @__PURE__ */ import_react.default.createElement(
|
|
463
|
+
element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react9.Suspense, {
|
|
439
464
|
fallback: props.fallback || /* @__PURE__ */ import_react.default.createElement("div", {
|
|
440
465
|
style: { padding: "24px" }
|
|
441
|
-
}, /* @__PURE__ */ import_react.default.createElement(
|
|
466
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd7.Skeleton, {
|
|
442
467
|
active: true
|
|
443
468
|
}))
|
|
444
469
|
}, /* @__PURE__ */ import_react.default.createElement(r.page, null))
|
|
@@ -450,11 +475,11 @@ function Routes(props) {
|
|
|
450
475
|
}
|
|
451
476
|
|
|
452
477
|
// src/Table.tsx
|
|
453
|
-
var
|
|
454
|
-
var
|
|
478
|
+
var import_react10 = require("react");
|
|
479
|
+
var import_antd8 = require("antd");
|
|
455
480
|
var import_icons3 = require("@ant-design/icons");
|
|
456
481
|
var import_lodash5 = require("lodash");
|
|
457
|
-
var
|
|
482
|
+
var import_react11 = require("@faasjs/react");
|
|
458
483
|
function processValue(item, value) {
|
|
459
484
|
var _a;
|
|
460
485
|
if (item.options && typeof value !== "undefined" && value !== null) {
|
|
@@ -469,9 +494,9 @@ function processValue(item, value) {
|
|
|
469
494
|
return value;
|
|
470
495
|
}
|
|
471
496
|
function Table(props) {
|
|
472
|
-
const [columns, setColumns] = (0,
|
|
497
|
+
const [columns, setColumns] = (0, import_react10.useState)();
|
|
473
498
|
const [config] = useFaasState();
|
|
474
|
-
(0,
|
|
499
|
+
(0, import_react10.useEffect)(() => {
|
|
475
500
|
var _a;
|
|
476
501
|
for (const item of props.items) {
|
|
477
502
|
if (!item.key)
|
|
@@ -495,7 +520,7 @@ function Table(props) {
|
|
|
495
520
|
delete item.children;
|
|
496
521
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
497
522
|
if (props.extendTypes[item.type].children) {
|
|
498
|
-
item.render = (value, values) => (0,
|
|
523
|
+
item.render = (value, values) => (0, import_react10.cloneElement)(props.extendTypes[item.type].children, {
|
|
499
524
|
value,
|
|
500
525
|
values
|
|
501
526
|
});
|
|
@@ -540,7 +565,7 @@ function Table(props) {
|
|
|
540
565
|
setSelectedKeys,
|
|
541
566
|
selectedKeys,
|
|
542
567
|
confirm
|
|
543
|
-
}) => /* @__PURE__ */ import_react.default.createElement(
|
|
568
|
+
}) => /* @__PURE__ */ import_react.default.createElement(import_antd8.Radio.Group, {
|
|
544
569
|
style: { padding: 8 },
|
|
545
570
|
buttonStyle: "solid",
|
|
546
571
|
value: selectedKeys[0],
|
|
@@ -548,21 +573,21 @@ function Table(props) {
|
|
|
548
573
|
setSelectedKeys(e.target.value ? [e.target.value] : []);
|
|
549
574
|
confirm();
|
|
550
575
|
}
|
|
551
|
-
}, /* @__PURE__ */ import_react.default.createElement(
|
|
576
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd8.Radio.Button, null, config.common.all), /* @__PURE__ */ import_react.default.createElement(import_antd8.Radio.Button, {
|
|
552
577
|
value: "true"
|
|
553
578
|
}, /* @__PURE__ */ import_react.default.createElement(import_icons3.CheckOutlined, {
|
|
554
579
|
style: {
|
|
555
580
|
color: "#52c41a",
|
|
556
581
|
verticalAlign: "middle"
|
|
557
582
|
}
|
|
558
|
-
})), /* @__PURE__ */ import_react.default.createElement(
|
|
583
|
+
})), /* @__PURE__ */ import_react.default.createElement(import_antd8.Radio.Button, {
|
|
559
584
|
value: "false"
|
|
560
585
|
}, /* @__PURE__ */ import_react.default.createElement(import_icons3.CloseOutlined, {
|
|
561
586
|
style: {
|
|
562
587
|
verticalAlign: "middle",
|
|
563
588
|
color: "#ff4d4f"
|
|
564
589
|
}
|
|
565
|
-
})), /* @__PURE__ */ import_react.default.createElement(
|
|
590
|
+
})), /* @__PURE__ */ import_react.default.createElement(import_antd8.Radio.Button, {
|
|
566
591
|
value: "empty"
|
|
567
592
|
}, config.common.blank));
|
|
568
593
|
if (!item.onFilter)
|
|
@@ -591,13 +616,13 @@ function Table(props) {
|
|
|
591
616
|
if (!columns)
|
|
592
617
|
return null;
|
|
593
618
|
if (!props.faasData)
|
|
594
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
619
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd8.Table, __spreadProps(__spreadValues({}, props), {
|
|
595
620
|
rowKey: props.rowKey || "id",
|
|
596
621
|
columns,
|
|
597
622
|
dataSource: props.dataSource
|
|
598
623
|
}));
|
|
599
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
600
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ import_react.default.createElement(
|
|
624
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react11.FaasDataWrapper, __spreadValues({
|
|
625
|
+
fallback: props.faasData.fallback || /* @__PURE__ */ import_react.default.createElement(import_antd8.Skeleton, {
|
|
601
626
|
active: true
|
|
602
627
|
}),
|
|
603
628
|
render: ({
|
|
@@ -606,18 +631,18 @@ function Table(props) {
|
|
|
606
631
|
reload
|
|
607
632
|
}) => {
|
|
608
633
|
if (!data)
|
|
609
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
634
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd8.Table, __spreadProps(__spreadValues({}, props), {
|
|
610
635
|
rowKey: props.rowKey || "id",
|
|
611
636
|
columns,
|
|
612
637
|
dataSource: []
|
|
613
638
|
}));
|
|
614
639
|
if (Array.isArray(data))
|
|
615
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
640
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd8.Table, __spreadProps(__spreadValues({}, props), {
|
|
616
641
|
rowKey: props.rowKey || "id",
|
|
617
642
|
columns,
|
|
618
643
|
dataSource: data
|
|
619
644
|
}));
|
|
620
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
645
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd8.Table, __spreadProps(__spreadValues({}, props), {
|
|
621
646
|
rowKey: props.rowKey || "id",
|
|
622
647
|
columns,
|
|
623
648
|
dataSource: data.rows,
|
|
@@ -644,10 +669,10 @@ function Table(props) {
|
|
|
644
669
|
}
|
|
645
670
|
|
|
646
671
|
// src/Title.tsx
|
|
647
|
-
var
|
|
672
|
+
var import_react12 = require("react");
|
|
648
673
|
function Title(props) {
|
|
649
674
|
const [config] = useFaasState();
|
|
650
|
-
(0,
|
|
675
|
+
(0, import_react12.useEffect)(() => {
|
|
651
676
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
652
677
|
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
653
678
|
}, []);
|
|
@@ -662,10 +687,12 @@ module.exports = __toCommonJS(src_exports);
|
|
|
662
687
|
Drawer,
|
|
663
688
|
Form,
|
|
664
689
|
FormItem,
|
|
690
|
+
Modal,
|
|
665
691
|
Routes,
|
|
666
692
|
Table,
|
|
667
693
|
Title,
|
|
668
694
|
transferOptions,
|
|
669
695
|
useDrawer,
|
|
670
|
-
useFaasState
|
|
696
|
+
useFaasState,
|
|
697
|
+
useModal
|
|
671
698
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -279,35 +279,41 @@ function FormItem(props) {
|
|
|
279
279
|
return /* @__PURE__ */ React.createElement(AntdForm.List, {
|
|
280
280
|
name: computedProps.name,
|
|
281
281
|
rules: computedProps.rules
|
|
282
|
-
}, (fields, { add, remove }, { errors }) =>
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
282
|
+
}, (fields, { add, remove }, { errors }) => {
|
|
283
|
+
var _a;
|
|
284
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.label && /* @__PURE__ */ React.createElement("div", {
|
|
285
|
+
className: "ant-form-item-label"
|
|
286
|
+
}, /* @__PURE__ */ React.createElement("label", {
|
|
287
|
+
className: computedProps.rules.find((r) => r.required) && "ant-form-item-required"
|
|
288
|
+
}, computedProps.label)), fields.map((field) => {
|
|
289
|
+
var _a2;
|
|
290
|
+
return /* @__PURE__ */ React.createElement(AntdForm.Item, {
|
|
291
|
+
key: field.key
|
|
292
|
+
}, /* @__PURE__ */ React.createElement(Row, {
|
|
293
|
+
gutter: 24,
|
|
294
|
+
style: { flexFlow: "row nowrap" }
|
|
295
|
+
}, /* @__PURE__ */ React.createElement(Col, {
|
|
296
|
+
span: 23
|
|
297
|
+
}, /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadProps(__spreadValues({}, field), {
|
|
298
|
+
noStyle: true
|
|
299
|
+
}), /* @__PURE__ */ React.createElement(Input, __spreadValues({}, computedProps.input)))), /* @__PURE__ */ React.createElement(Col, {
|
|
300
|
+
span: 1
|
|
301
|
+
}, !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ React.createElement(Button, {
|
|
302
|
+
danger: true,
|
|
303
|
+
type: "link",
|
|
304
|
+
style: { float: "right" },
|
|
305
|
+
icon: /* @__PURE__ */ React.createElement(MinusCircleOutlined, null),
|
|
306
|
+
onClick: () => remove(field.name)
|
|
307
|
+
}))));
|
|
308
|
+
}), /* @__PURE__ */ React.createElement(AntdForm.Item, null, !((_a = computedProps.input) == null ? void 0 : _a.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ React.createElement(Button, {
|
|
309
|
+
type: "dashed",
|
|
310
|
+
block: true,
|
|
311
|
+
onClick: () => add(),
|
|
312
|
+
icon: /* @__PURE__ */ React.createElement(PlusOutlined, null)
|
|
313
|
+
}), /* @__PURE__ */ React.createElement(AntdForm.ErrorList, {
|
|
314
|
+
errors
|
|
315
|
+
})));
|
|
316
|
+
});
|
|
311
317
|
case "number":
|
|
312
318
|
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), computedProps.options ? /* @__PURE__ */ React.createElement(Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ React.createElement(InputNumber, __spreadValues({
|
|
313
319
|
style: { width: "100%" }
|
|
@@ -321,31 +327,34 @@ function FormItem(props) {
|
|
|
321
327
|
name: computedProps.name,
|
|
322
328
|
rules: computedProps.rules
|
|
323
329
|
}, (fields, { add, remove }, { errors }) => {
|
|
324
|
-
var _a;
|
|
330
|
+
var _a, _b;
|
|
325
331
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.label && /* @__PURE__ */ React.createElement("div", {
|
|
326
332
|
className: "ant-form-item-label"
|
|
327
333
|
}, /* @__PURE__ */ React.createElement("label", {
|
|
328
334
|
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required"
|
|
329
|
-
}, computedProps.label)), fields.map((field) =>
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
335
|
+
}, computedProps.label)), fields.map((field) => {
|
|
336
|
+
var _a2;
|
|
337
|
+
return /* @__PURE__ */ React.createElement(AntdForm.Item, {
|
|
338
|
+
key: field.key
|
|
339
|
+
}, /* @__PURE__ */ React.createElement(Row, {
|
|
340
|
+
gutter: 24,
|
|
341
|
+
style: { flexFlow: "row nowrap" }
|
|
342
|
+
}, /* @__PURE__ */ React.createElement(Col, {
|
|
343
|
+
span: 23
|
|
344
|
+
}, /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadProps(__spreadValues({}, field), {
|
|
345
|
+
noStyle: true
|
|
346
|
+
}), /* @__PURE__ */ React.createElement(InputNumber, __spreadValues({
|
|
347
|
+
style: { width: "100%" }
|
|
348
|
+
}, computedProps.input)))), /* @__PURE__ */ React.createElement(Col, {
|
|
349
|
+
span: 1
|
|
350
|
+
}, !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ React.createElement(Button, {
|
|
351
|
+
danger: true,
|
|
352
|
+
type: "link",
|
|
353
|
+
style: { float: "right" },
|
|
354
|
+
icon: /* @__PURE__ */ React.createElement(MinusCircleOutlined, null),
|
|
355
|
+
onClick: () => remove(field.name)
|
|
356
|
+
}))));
|
|
357
|
+
}), /* @__PURE__ */ React.createElement(AntdForm.Item, null, !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ React.createElement(Button, {
|
|
349
358
|
type: "dashed",
|
|
350
359
|
block: true,
|
|
351
360
|
onClick: () => add(),
|
|
@@ -397,6 +406,20 @@ function Form(props) {
|
|
|
397
406
|
Form.useForm = AntdForm2.useForm;
|
|
398
407
|
Form.Item = FormItem;
|
|
399
408
|
|
|
409
|
+
// src/Modal.tsx
|
|
410
|
+
import { Modal } from "antd";
|
|
411
|
+
import { useState as useState5 } from "react";
|
|
412
|
+
function useModal(init) {
|
|
413
|
+
const [props, setProps] = useState5(init);
|
|
414
|
+
return {
|
|
415
|
+
Modal: /* @__PURE__ */ React.createElement(Modal, __spreadValues({}, props)),
|
|
416
|
+
ModalProps: props,
|
|
417
|
+
setModalProps(changes) {
|
|
418
|
+
setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
400
423
|
// src/Routers.tsx
|
|
401
424
|
import { Result, Skeleton as Skeleton2 } from "antd";
|
|
402
425
|
import {
|
|
@@ -433,7 +456,7 @@ function Routes(props) {
|
|
|
433
456
|
|
|
434
457
|
// src/Table.tsx
|
|
435
458
|
import {
|
|
436
|
-
useState as
|
|
459
|
+
useState as useState6,
|
|
437
460
|
useEffect as useEffect5,
|
|
438
461
|
cloneElement as cloneElement2
|
|
439
462
|
} from "react";
|
|
@@ -459,7 +482,7 @@ function processValue(item, value) {
|
|
|
459
482
|
return value;
|
|
460
483
|
}
|
|
461
484
|
function Table(props) {
|
|
462
|
-
const [columns, setColumns] =
|
|
485
|
+
const [columns, setColumns] = useState6();
|
|
463
486
|
const [config] = useFaasState();
|
|
464
487
|
useEffect5(() => {
|
|
465
488
|
var _a;
|
|
@@ -650,10 +673,12 @@ export {
|
|
|
650
673
|
Drawer,
|
|
651
674
|
Form,
|
|
652
675
|
FormItem,
|
|
676
|
+
Modal,
|
|
653
677
|
Routes,
|
|
654
678
|
Table,
|
|
655
679
|
Title,
|
|
656
680
|
transferOptions,
|
|
657
681
|
useDrawer,
|
|
658
|
-
useFaasState
|
|
682
|
+
useFaasState,
|
|
683
|
+
useModal
|
|
659
684
|
};
|
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.367",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.367",
|
|
32
32
|
"react-use": "*",
|
|
33
33
|
"react-router-dom": "*"
|
|
34
34
|
},
|