@faasjs/ant-design 0.0.2-beta.370 → 0.0.2-beta.374
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 +122 -5
- package/dist/index.d.ts +63 -5
- package/dist/index.js +109 -28
- package/dist/index.mjs +88 -10
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -50,6 +50,8 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
|
|
|
50
50
|
- [BaseItemProps](#baseitemprops)
|
|
51
51
|
- [BaseOption](#baseoption)
|
|
52
52
|
- [BlankProps](#blankprops)
|
|
53
|
+
- [CalendarProps](#calendarprops)
|
|
54
|
+
- [DatePickerProps](#datepickerprops)
|
|
53
55
|
- [DescriptionItemProps](#descriptionitemprops)
|
|
54
56
|
- [DescriptionProps](#descriptionprops)
|
|
55
57
|
- [DrawerProps](#drawerprops)
|
|
@@ -69,11 +71,20 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
|
|
|
69
71
|
- [RoutesProps](#routesprops)
|
|
70
72
|
- [TableItemProps](#tableitemprops)
|
|
71
73
|
- [TableProps](#tableprops)
|
|
74
|
+
- [TimePickerProps](#timepickerprops)
|
|
72
75
|
- [TitleProps](#titleprops)
|
|
76
|
+
- [setDrawerProps](#setdrawerprops)
|
|
77
|
+
- [setModalProps](#setmodalprops)
|
|
78
|
+
|
|
79
|
+
### Variables
|
|
80
|
+
|
|
81
|
+
- [DatePicker](#datepicker)
|
|
82
|
+
- [TimePicker](#timepicker)
|
|
73
83
|
|
|
74
84
|
### Functions
|
|
75
85
|
|
|
76
86
|
- [Blank](#blank)
|
|
87
|
+
- [Calendar](#calendar)
|
|
77
88
|
- [Config](#config)
|
|
78
89
|
- [Description](#description)
|
|
79
90
|
- [Form](#form)
|
|
@@ -121,6 +132,18 @@ ___
|
|
|
121
132
|
|
|
122
133
|
___
|
|
123
134
|
|
|
135
|
+
### CalendarProps
|
|
136
|
+
|
|
137
|
+
Ƭ **CalendarProps**: `AntdProps`<`Dayjs`\>
|
|
138
|
+
|
|
139
|
+
___
|
|
140
|
+
|
|
141
|
+
### DatePickerProps
|
|
142
|
+
|
|
143
|
+
Ƭ **DatePickerProps**: `PickerDateProps`<`Dayjs`\>
|
|
144
|
+
|
|
145
|
+
___
|
|
146
|
+
|
|
124
147
|
### DescriptionItemProps
|
|
125
148
|
|
|
126
149
|
Ƭ **DescriptionItemProps**<`T`\>: { `children?`: `JSX.Element` ; `render?`: (`value`: `T`, `values`: `any`) => `string` \| `number` \| `boolean` \| `Element` } & [`FaasItemProps`](#faasitemprops)
|
|
@@ -135,7 +158,7 @@ ___
|
|
|
135
158
|
|
|
136
159
|
### DescriptionProps
|
|
137
160
|
|
|
138
|
-
Ƭ **DescriptionProps**<`T`, `ExtendItemProps`\>: { `dataSource?`: `T` ; `extendTypes?`: { [key: string]
|
|
161
|
+
Ƭ **DescriptionProps**<`T`, `ExtendItemProps`\>: { `dataSource?`: `T` ; `extendTypes?`: { `[key: string]`: [`ExtendDescriptionTypeProps`](#extenddescriptiontypeprops); } ; `faasData?`: `FaasDataWrapperProps`<`T`\> ; `items`: ([`DescriptionItemProps`](#descriptionitemprops) \| `ExtendItemProps`)[] } & `DescriptionsProps`
|
|
139
162
|
|
|
140
163
|
#### Type parameters
|
|
141
164
|
|
|
@@ -222,7 +245,7 @@ ___
|
|
|
222
245
|
|
|
223
246
|
### FaasItemType
|
|
224
247
|
|
|
225
|
-
Ƭ **FaasItemType**: ``"string"`` \| ``"string[]"`` \| ``"number"`` \| ``"number[]"`` \| ``"boolean"``
|
|
248
|
+
Ƭ **FaasItemType**: ``"string"`` \| ``"string[]"`` \| ``"number"`` \| ``"number[]"`` \| ``"boolean"`` \| ``"date"`` \| ``"time"``
|
|
226
249
|
|
|
227
250
|
___
|
|
228
251
|
|
|
@@ -235,10 +258,12 @@ ___
|
|
|
235
258
|
| Name | Type |
|
|
236
259
|
| :------ | :------ |
|
|
237
260
|
| `boolean` | `boolean` |
|
|
261
|
+
| `date` | `Dayjs` |
|
|
238
262
|
| `number` | `number` |
|
|
239
263
|
| `number[]` | `number`[] |
|
|
240
264
|
| `string` | `string` |
|
|
241
265
|
| `string[]` | `string`[] |
|
|
266
|
+
| `time` | `Dayjs` |
|
|
242
267
|
|
|
243
268
|
___
|
|
244
269
|
|
|
@@ -268,7 +293,7 @@ ___
|
|
|
268
293
|
|
|
269
294
|
### FormItemProps
|
|
270
295
|
|
|
271
|
-
Ƭ **FormItemProps**<`T`\>: { `children?`: `JSX.Element` \| ``null`` ; `extendTypes?`: { [type: string]
|
|
296
|
+
Ƭ **FormItemProps**<`T`\>: { `children?`: `JSX.Element` \| ``null`` ; `extendTypes?`: { `[type: string]`: [`ExtendFormTypeProps`](#extendformtypeprops); } ; `label?`: `string` \| ``false`` ; `rules?`: `RuleObject`[] ; `render?`: () => `Element` } & `FormItemInputProps`<`T`\> & [`FaasItemProps`](#faasitemprops) & `AntdFormItemProps`<`T`\>
|
|
272
297
|
|
|
273
298
|
#### Type parameters
|
|
274
299
|
|
|
@@ -280,7 +305,7 @@ ___
|
|
|
280
305
|
|
|
281
306
|
### FormProps
|
|
282
307
|
|
|
283
|
-
Ƭ **FormProps**<`Values`, `ExtendItemProps`\>: { `extendTypes?`: { [type: string]
|
|
308
|
+
Ƭ **FormProps**<`Values`, `ExtendItemProps`\>: { `extendTypes?`: { `[type: string]`: [`ExtendFormTypeProps`](#extendformtypeprops); } ; `items?`: ([`FormItemProps`](#formitemprops) \| `ExtendItemProps`)[] ; `submit?`: ``false`` \| { `text?`: `string` } } & `AntdFormProps`<`Values`\>
|
|
284
309
|
|
|
285
310
|
#### Type parameters
|
|
286
311
|
|
|
@@ -325,7 +350,7 @@ ___
|
|
|
325
350
|
|
|
326
351
|
### TableProps
|
|
327
352
|
|
|
328
|
-
Ƭ **TableProps**<`T`, `ExtendTypes`\>: { `extendTypes?`: { [key: string]
|
|
353
|
+
Ƭ **TableProps**<`T`, `ExtendTypes`\>: { `extendTypes?`: { `[key: string]`: [`ExtendTableTypeProps`](#extendtabletypeprops); } ; `faasData?`: `FaasDataWrapperProps`<`T`\> ; `items`: ([`TableItemProps`](#tableitemprops) \| `ExtendTypes` & [`ExtendTableItemProps`](#extendtableitemprops))[] ; `onChange?`: (`pagination`: `TablePaginationConfig`, `filters`: `Record`<`string`, `FilterValue`\>, `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[], `extra`: `TableCurrentDataSource`<`T`\>) => { `extra`: `TableCurrentDataSource`<`T`\> ; `filters`: `Record`<`string`, `FilterValue` \| ``null``\> ; `pagination`: `TablePaginationConfig` ; `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[] } } & `AntdTableProps`<`T`\>
|
|
329
354
|
|
|
330
355
|
#### Type parameters
|
|
331
356
|
|
|
@@ -336,6 +361,12 @@ ___
|
|
|
336
361
|
|
|
337
362
|
___
|
|
338
363
|
|
|
364
|
+
### TimePickerProps
|
|
365
|
+
|
|
366
|
+
Ƭ **TimePickerProps**: `Omit`<`PickerTimeProps`<`Dayjs`\>, ``"picker"``\>
|
|
367
|
+
|
|
368
|
+
___
|
|
369
|
+
|
|
339
370
|
### TitleProps
|
|
340
371
|
|
|
341
372
|
Ƭ **TitleProps**: `Object`
|
|
@@ -344,10 +375,64 @@ ___
|
|
|
344
375
|
|
|
345
376
|
| Name | Type | Description |
|
|
346
377
|
| :------ | :------ | :------ |
|
|
378
|
+
| `children?` | `JSX.Element` | return children |
|
|
379
|
+
| `h1?` | `boolean` \| { `className?`: `string` ; `style?`: `React.CSSProperties` } | return a h1 element |
|
|
347
380
|
| `separator?` | `string` | ` - ` as default |
|
|
348
381
|
| `suffix?` | `string` | - |
|
|
349
382
|
| `title` | `string` \| `string`[] | - |
|
|
350
383
|
|
|
384
|
+
___
|
|
385
|
+
|
|
386
|
+
### setDrawerProps
|
|
387
|
+
|
|
388
|
+
Ƭ **setDrawerProps**: (`changes`: `Partial`<[`DrawerProps`](#drawerprops)\>) => `void`
|
|
389
|
+
|
|
390
|
+
#### Type declaration
|
|
391
|
+
|
|
392
|
+
▸ (`changes`): `void`
|
|
393
|
+
|
|
394
|
+
##### Parameters
|
|
395
|
+
|
|
396
|
+
| Name | Type |
|
|
397
|
+
| :------ | :------ |
|
|
398
|
+
| `changes` | `Partial`<[`DrawerProps`](#drawerprops)\> |
|
|
399
|
+
|
|
400
|
+
##### Returns
|
|
401
|
+
|
|
402
|
+
`void`
|
|
403
|
+
|
|
404
|
+
___
|
|
405
|
+
|
|
406
|
+
### setModalProps
|
|
407
|
+
|
|
408
|
+
Ƭ **setModalProps**: (`changes`: `Partial`<[`ModalProps`](#modalprops)\>) => `void`
|
|
409
|
+
|
|
410
|
+
#### Type declaration
|
|
411
|
+
|
|
412
|
+
▸ (`changes`): `void`
|
|
413
|
+
|
|
414
|
+
##### Parameters
|
|
415
|
+
|
|
416
|
+
| Name | Type |
|
|
417
|
+
| :------ | :------ |
|
|
418
|
+
| `changes` | `Partial`<[`ModalProps`](#modalprops)\> |
|
|
419
|
+
|
|
420
|
+
##### Returns
|
|
421
|
+
|
|
422
|
+
`void`
|
|
423
|
+
|
|
424
|
+
## Variables
|
|
425
|
+
|
|
426
|
+
### DatePicker
|
|
427
|
+
|
|
428
|
+
• **DatePicker**: `PickerComponentClass`<`PickerProps`<`Dayjs`\>, `unknown`\> & {}
|
|
429
|
+
|
|
430
|
+
___
|
|
431
|
+
|
|
432
|
+
### TimePicker
|
|
433
|
+
|
|
434
|
+
• **TimePicker**: `ForwardRefExoticComponent`<[`TimePickerProps`](#timepickerprops) & `RefAttributes`<`any`\>\>
|
|
435
|
+
|
|
351
436
|
## Functions
|
|
352
437
|
|
|
353
438
|
### Blank
|
|
@@ -372,6 +457,22 @@ If value is undefined or null, return text, otherwise return value.
|
|
|
372
457
|
|
|
373
458
|
___
|
|
374
459
|
|
|
460
|
+
### Calendar
|
|
461
|
+
|
|
462
|
+
▸ `Const` **Calendar**(`props`): `Element`
|
|
463
|
+
|
|
464
|
+
#### Parameters
|
|
465
|
+
|
|
466
|
+
| Name | Type |
|
|
467
|
+
| :------ | :------ |
|
|
468
|
+
| `props` | `CalendarProps`<`Dayjs`\> |
|
|
469
|
+
|
|
470
|
+
#### Returns
|
|
471
|
+
|
|
472
|
+
`Element`
|
|
473
|
+
|
|
474
|
+
___
|
|
475
|
+
|
|
375
476
|
### Config
|
|
376
477
|
|
|
377
478
|
▸ **Config**(`props`): `JSX.Element`
|
|
@@ -520,6 +621,22 @@ ___
|
|
|
520
621
|
|
|
521
622
|
▸ **Title**(`props`): `JSX.Element`
|
|
522
623
|
|
|
624
|
+
Title is used to change the title of the page.
|
|
625
|
+
Return null by default.
|
|
626
|
+
|
|
627
|
+
```ts
|
|
628
|
+
// return null
|
|
629
|
+
<Title title='hi' /> // => change the document.title to 'hi'
|
|
630
|
+
<Title title={['a', 'b']} /> // => change the document.title to 'a - b'
|
|
631
|
+
|
|
632
|
+
// return h1
|
|
633
|
+
<Title title='hi' h1 /> // => <h1>hi</h1>
|
|
634
|
+
<Title title={['a', 'b']} h1 /> // => <h1>a</h1>
|
|
635
|
+
|
|
636
|
+
// return children
|
|
637
|
+
<Title title='hi'><CustomTitle /></Title> // => <CustomTitle />
|
|
638
|
+
```
|
|
639
|
+
|
|
523
640
|
#### Parameters
|
|
524
641
|
|
|
525
642
|
| Name | Type |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
1
|
+
import * as antd_es_calendar_generateCalendar_js from 'antd/es/calendar/generateCalendar.js';
|
|
2
|
+
import { Dayjs } from 'dayjs';
|
|
3
|
+
import { CalendarProps as CalendarProps$1, DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1, SelectProps, FormProps as FormProps$1, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1 } from 'antd';
|
|
3
4
|
export { Drawer, Modal } from 'antd';
|
|
5
|
+
import * as react_use_lib_misc_hookState from 'react-use/lib/misc/hookState';
|
|
6
|
+
import * as antd_es_date_picker_generatePicker_interface from 'antd/es/date-picker/generatePicker/interface';
|
|
7
|
+
import * as antd_es_date_picker_generatePicker from 'antd/es/date-picker/generatePicker';
|
|
8
|
+
import { PickerDateProps, PickerTimeProps } from 'antd/es/date-picker/generatePicker';
|
|
4
9
|
import { FaasDataWrapperProps } from '@faasjs/react';
|
|
5
10
|
import * as antd_lib_form_Form from 'antd/lib/form/Form';
|
|
6
11
|
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
12
|
+
import * as react from 'react';
|
|
7
13
|
import { LazyExoticComponent, ComponentType } from 'react';
|
|
8
14
|
import { RouteProps } from 'react-router-dom';
|
|
9
15
|
import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/lib/table/interface';
|
|
@@ -26,6 +32,9 @@ declare type BlankProps = {
|
|
|
26
32
|
*/
|
|
27
33
|
declare function Blank(options?: BlankProps): any;
|
|
28
34
|
|
|
35
|
+
declare type CalendarProps = CalendarProps$1<Dayjs>;
|
|
36
|
+
declare const Calendar: (props: antd_es_calendar_generateCalendar_js.CalendarProps<Dayjs>) => JSX.Element;
|
|
37
|
+
|
|
29
38
|
declare type FaasState = {
|
|
30
39
|
common: {
|
|
31
40
|
blank: string;
|
|
@@ -65,13 +74,15 @@ declare function Config(props: {
|
|
|
65
74
|
config: Partial<FaasState>;
|
|
66
75
|
}): JSX.Element;
|
|
67
76
|
|
|
68
|
-
declare type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean';
|
|
77
|
+
declare type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean' | 'date' | 'time';
|
|
69
78
|
declare type FaasItemTypeValue = {
|
|
70
79
|
string: string;
|
|
71
80
|
'string[]': string[];
|
|
72
81
|
number: number;
|
|
73
82
|
'number[]': number[];
|
|
74
83
|
boolean: boolean;
|
|
84
|
+
'date': Dayjs;
|
|
85
|
+
'time': Dayjs;
|
|
75
86
|
};
|
|
76
87
|
declare type BaseOption = string | number | {
|
|
77
88
|
label: string;
|
|
@@ -94,6 +105,16 @@ declare function transferOptions(options: BaseOption[]): {
|
|
|
94
105
|
value?: string | number;
|
|
95
106
|
}[];
|
|
96
107
|
|
|
108
|
+
declare type DatePickerProps = PickerDateProps<Dayjs>;
|
|
109
|
+
declare const DatePicker: antd_es_date_picker_generatePicker_interface.PickerComponentClass<antd_es_date_picker_generatePicker.PickerProps<Dayjs>, unknown> & {
|
|
110
|
+
WeekPicker: antd_es_date_picker_generatePicker_interface.PickerComponentClass<Omit<PickerDateProps<Dayjs>, "picker">, unknown>;
|
|
111
|
+
MonthPicker: antd_es_date_picker_generatePicker_interface.PickerComponentClass<Omit<PickerDateProps<Dayjs>, "picker">, unknown>;
|
|
112
|
+
YearPicker: antd_es_date_picker_generatePicker_interface.PickerComponentClass<Omit<PickerDateProps<Dayjs>, "picker">, unknown>;
|
|
113
|
+
RangePicker: antd_es_date_picker_generatePicker_interface.PickerComponentClass<antd_es_date_picker_generatePicker.RangePickerProps<Dayjs>, unknown>;
|
|
114
|
+
TimePicker: antd_es_date_picker_generatePicker_interface.PickerComponentClass<Omit<antd_es_date_picker_generatePicker.PickerTimeProps<Dayjs>, "picker">, unknown>;
|
|
115
|
+
QuarterPicker: antd_es_date_picker_generatePicker_interface.PickerComponentClass<Omit<antd_es_date_picker_generatePicker.PickerTimeProps<Dayjs>, "picker">, unknown>;
|
|
116
|
+
};
|
|
117
|
+
|
|
97
118
|
declare type ExtendDescriptionTypeProps = {
|
|
98
119
|
children?: JSX.Element | null;
|
|
99
120
|
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
@@ -116,6 +137,7 @@ declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
|
116
137
|
declare type DrawerProps = DrawerProps$1 & {
|
|
117
138
|
children?: JSX.Element | JSX.Element[];
|
|
118
139
|
};
|
|
140
|
+
declare type setDrawerProps = (changes: Partial<DrawerProps>) => void;
|
|
119
141
|
/**
|
|
120
142
|
* Hook style drawer.
|
|
121
143
|
* @param init initial props
|
|
@@ -161,12 +183,20 @@ declare type BooleanProps = {
|
|
|
161
183
|
type: 'boolean';
|
|
162
184
|
input?: SwitchProps;
|
|
163
185
|
};
|
|
186
|
+
declare type DateProps = {
|
|
187
|
+
type: 'date';
|
|
188
|
+
input?: DatePickerProps$1;
|
|
189
|
+
};
|
|
190
|
+
declare type TimeProps = {
|
|
191
|
+
type: 'time';
|
|
192
|
+
input?: TimePickerProps$1;
|
|
193
|
+
};
|
|
164
194
|
declare type OptionsProps = {
|
|
165
195
|
options?: BaseOption[];
|
|
166
196
|
type?: 'string' | 'string[]' | 'number' | 'number[]';
|
|
167
197
|
input?: SelectProps<any>;
|
|
168
198
|
};
|
|
169
|
-
declare type FormItemInputProps<T = any> = StringProps | StringListProps | NumberProps | NumberListProps | BooleanProps | OptionsProps;
|
|
199
|
+
declare type FormItemInputProps<T = any> = StringProps | StringListProps | NumberProps | NumberListProps | BooleanProps | OptionsProps | DateProps | TimeProps;
|
|
170
200
|
declare type ExtendFormTypeProps = {
|
|
171
201
|
children?: JSX.Element | null;
|
|
172
202
|
};
|
|
@@ -215,6 +245,7 @@ declare namespace Form {
|
|
|
215
245
|
declare type ModalProps = ModalProps$1 & {
|
|
216
246
|
children?: JSX.Element | JSX.Element[];
|
|
217
247
|
};
|
|
248
|
+
declare type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
218
249
|
/**
|
|
219
250
|
* Hook style modal.
|
|
220
251
|
* @param init initial props
|
|
@@ -266,12 +297,39 @@ declare type TableProps<T = any, ExtendTypes = any> = {
|
|
|
266
297
|
} & TableProps$1<T>;
|
|
267
298
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
268
299
|
|
|
300
|
+
declare type TimePickerProps = Omit<PickerTimeProps<Dayjs>, 'picker'>;
|
|
301
|
+
declare const TimePicker: react.ForwardRefExoticComponent<TimePickerProps & react.RefAttributes<any>>;
|
|
302
|
+
|
|
269
303
|
declare type TitleProps = {
|
|
270
304
|
title: string | string[];
|
|
271
305
|
/** ` - ` as default */
|
|
272
306
|
separator?: string;
|
|
273
307
|
suffix?: string;
|
|
308
|
+
/** return a h1 element */
|
|
309
|
+
h1?: boolean | {
|
|
310
|
+
className?: string;
|
|
311
|
+
style?: React.CSSProperties;
|
|
312
|
+
};
|
|
313
|
+
/** return children */
|
|
314
|
+
children?: JSX.Element;
|
|
274
315
|
};
|
|
316
|
+
/**
|
|
317
|
+
* Title is used to change the title of the page.
|
|
318
|
+
* Return null by default.
|
|
319
|
+
*
|
|
320
|
+
* ```ts
|
|
321
|
+
* // return null
|
|
322
|
+
* <Title title='hi' /> // => change the document.title to 'hi'
|
|
323
|
+
* <Title title={['a', 'b']} /> // => change the document.title to 'a - b'
|
|
324
|
+
*
|
|
325
|
+
* // return h1
|
|
326
|
+
* <Title title='hi' h1 /> // => <h1>hi</h1>
|
|
327
|
+
* <Title title={['a', 'b']} h1 /> // => <h1>a</h1>
|
|
328
|
+
*
|
|
329
|
+
* // return children
|
|
330
|
+
* <Title title='hi'><CustomTitle /></Title> // => <CustomTitle />
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
275
333
|
declare function Title(props: TitleProps): JSX.Element;
|
|
276
334
|
|
|
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 };
|
|
335
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, Calendar, CalendarProps, Config, DatePicker, DatePickerProps, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, FaasItemProps, FaasItemType, FaasItemTypeValue, FaasState, Form, FormItem, FormItemProps, FormProps, ModalProps, Routes, RoutesProps, Table, TableItemProps, TableProps, TimePicker, TimePickerProps, Title, TitleProps, setDrawerProps, setModalProps, transferOptions, useDrawer, useFaasState, useModal };
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,9 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
47
47
|
var src_exports = {};
|
|
48
48
|
__export(src_exports, {
|
|
49
49
|
Blank: () => Blank,
|
|
50
|
+
Calendar: () => Calendar,
|
|
50
51
|
Config: () => Config,
|
|
52
|
+
DatePicker: () => DatePicker,
|
|
51
53
|
Description: () => Description,
|
|
52
54
|
Drawer: () => import_antd3.Drawer,
|
|
53
55
|
Form: () => Form,
|
|
@@ -55,6 +57,7 @@ __export(src_exports, {
|
|
|
55
57
|
Modal: () => import_antd6.Modal,
|
|
56
58
|
Routes: () => Routes,
|
|
57
59
|
Table: () => Table,
|
|
60
|
+
TimePicker: () => TimePicker,
|
|
58
61
|
Title: () => Title,
|
|
59
62
|
transferOptions: () => transferOptions,
|
|
60
63
|
useDrawer: () => useDrawer,
|
|
@@ -109,6 +112,12 @@ function Blank(options) {
|
|
|
109
112
|
}, (options == null ? void 0 : options.text) || config.Blank.text) : options.value;
|
|
110
113
|
}
|
|
111
114
|
|
|
115
|
+
// src/Calendar.tsx
|
|
116
|
+
var import_dayjs = __toESM(require("rc-picker/es/generate/dayjs.js"));
|
|
117
|
+
var import_generateCalendar = __toESM(require("antd/es/calendar/generateCalendar.js"));
|
|
118
|
+
var import_style = require("antd/es/calendar/style/index.js");
|
|
119
|
+
var Calendar = (0, import_generateCalendar.default)(import_dayjs.default);
|
|
120
|
+
|
|
112
121
|
// src/data.ts
|
|
113
122
|
var import_lodash2 = require("lodash");
|
|
114
123
|
function transferOptions(options) {
|
|
@@ -120,11 +129,18 @@ function transferOptions(options) {
|
|
|
120
129
|
});
|
|
121
130
|
}
|
|
122
131
|
|
|
132
|
+
// src/DatePicker.tsx
|
|
133
|
+
var import_dayjs2 = __toESM(require("rc-picker/es/generate/dayjs.js"));
|
|
134
|
+
var import_generatePicker = __toESM(require("antd/es/date-picker/generatePicker/index.js"));
|
|
135
|
+
var import_style2 = require("antd/es/date-picker/style/index.js");
|
|
136
|
+
var DatePicker = (0, import_generatePicker.default)(import_dayjs2.default);
|
|
137
|
+
|
|
123
138
|
// src/Description.tsx
|
|
124
139
|
var import_icons = require("@ant-design/icons");
|
|
125
140
|
var import_antd2 = require("antd");
|
|
126
141
|
var import_lodash3 = require("lodash");
|
|
127
142
|
var import_react3 = require("react");
|
|
143
|
+
var import_dayjs3 = __toESM(require("dayjs"));
|
|
128
144
|
var import_react4 = require("@faasjs/react");
|
|
129
145
|
function DescriptionItemContent(props) {
|
|
130
146
|
const [computedProps, setComputedProps] = (0, import_react3.useState)();
|
|
@@ -144,7 +160,11 @@ function DescriptionItemContent(props) {
|
|
|
144
160
|
var _a2;
|
|
145
161
|
return ((_a2 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
146
162
|
});
|
|
147
|
-
else
|
|
163
|
+
else if ([
|
|
164
|
+
"string",
|
|
165
|
+
"number",
|
|
166
|
+
"boolean"
|
|
167
|
+
].includes(propsCopy.item.type))
|
|
148
168
|
propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
|
|
149
169
|
}
|
|
150
170
|
setComputedProps(propsCopy);
|
|
@@ -186,6 +206,10 @@ function DescriptionItemContent(props) {
|
|
|
186
206
|
color: "#ff4d4f"
|
|
187
207
|
}
|
|
188
208
|
});
|
|
209
|
+
case "time":
|
|
210
|
+
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? import_dayjs3.default.unix(computedProps.value).format("YYYY-MM-DD HH:mm:ss") : (0, import_dayjs3.default)(computedProps.value).format("YYYY-MM-DD HH:mm:ss");
|
|
211
|
+
case "date":
|
|
212
|
+
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? import_dayjs3.default.unix(computedProps.value).format("YYYY-MM-DD") : (0, import_dayjs3.default)(computedProps.value).format("YYYY-MM-DD");
|
|
189
213
|
default:
|
|
190
214
|
return computedProps.value;
|
|
191
215
|
}
|
|
@@ -238,16 +262,29 @@ function useDrawer(init) {
|
|
|
238
262
|
|
|
239
263
|
// src/Form.tsx
|
|
240
264
|
var import_antd5 = require("antd");
|
|
241
|
-
var
|
|
265
|
+
var import_react8 = require("react");
|
|
242
266
|
|
|
243
267
|
// src/FormItem.tsx
|
|
244
268
|
var import_antd4 = require("antd");
|
|
245
269
|
var import_icons2 = require("@ant-design/icons");
|
|
246
|
-
var
|
|
270
|
+
var import_react7 = require("react");
|
|
247
271
|
var import_lodash4 = require("lodash");
|
|
272
|
+
|
|
273
|
+
// src/TimePicker.tsx
|
|
274
|
+
var import_react6 = require("react");
|
|
275
|
+
var TimePicker = (0, import_react6.forwardRef)((props, ref) => {
|
|
276
|
+
return /* @__PURE__ */ import_react.default.createElement(DatePicker, __spreadProps(__spreadValues({}, props), {
|
|
277
|
+
picker: "time",
|
|
278
|
+
mode: void 0,
|
|
279
|
+
ref
|
|
280
|
+
}));
|
|
281
|
+
});
|
|
282
|
+
TimePicker.displayName = "TimePicker";
|
|
283
|
+
|
|
284
|
+
// src/FormItem.tsx
|
|
248
285
|
function FormItem(props) {
|
|
249
|
-
const [computedProps, setComputedProps] = (0,
|
|
250
|
-
(0,
|
|
286
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
287
|
+
(0, import_react7.useEffect)(() => {
|
|
251
288
|
const propsCopy = __spreadValues({}, props);
|
|
252
289
|
if (!propsCopy.title)
|
|
253
290
|
propsCopy.title = (0, import_lodash4.upperFirst)(propsCopy.id);
|
|
@@ -390,6 +427,10 @@ function FormItem(props) {
|
|
|
390
427
|
});
|
|
391
428
|
case "boolean":
|
|
392
429
|
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), /* @__PURE__ */ import_react.default.createElement(import_antd4.Switch, __spreadValues({}, computedProps.input)));
|
|
430
|
+
case "date":
|
|
431
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), /* @__PURE__ */ import_react.default.createElement(DatePicker, __spreadValues({}, computedProps.input)));
|
|
432
|
+
case "time":
|
|
433
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), /* @__PURE__ */ import_react.default.createElement(TimePicker, __spreadValues({}, computedProps.input)));
|
|
393
434
|
default:
|
|
394
435
|
return null;
|
|
395
436
|
}
|
|
@@ -398,10 +439,10 @@ function FormItem(props) {
|
|
|
398
439
|
// src/Form.tsx
|
|
399
440
|
function Form(props) {
|
|
400
441
|
var _a, _b;
|
|
401
|
-
const [loading, setLoading] = (0,
|
|
402
|
-
const [computedProps, setComputedProps] = (0,
|
|
442
|
+
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
443
|
+
const [computedProps, setComputedProps] = (0, import_react8.useState)();
|
|
403
444
|
const [config] = useFaasState();
|
|
404
|
-
(0,
|
|
445
|
+
(0, import_react8.useEffect)(() => {
|
|
405
446
|
const propsCopy = __spreadValues({}, props);
|
|
406
447
|
if (propsCopy.onFinish) {
|
|
407
448
|
propsCopy.onFinish = async (values) => {
|
|
@@ -433,9 +474,9 @@ Form.Item = FormItem;
|
|
|
433
474
|
|
|
434
475
|
// src/Modal.tsx
|
|
435
476
|
var import_antd6 = require("antd");
|
|
436
|
-
var
|
|
477
|
+
var import_react9 = require("react");
|
|
437
478
|
function useModal(init) {
|
|
438
|
-
const [props, setProps] = (0,
|
|
479
|
+
const [props, setProps] = (0, import_react9.useState)(__spreadValues({
|
|
439
480
|
visible: false,
|
|
440
481
|
onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
441
482
|
visible: false
|
|
@@ -452,7 +493,7 @@ function useModal(init) {
|
|
|
452
493
|
|
|
453
494
|
// src/Routers.tsx
|
|
454
495
|
var import_antd7 = require("antd");
|
|
455
|
-
var
|
|
496
|
+
var import_react10 = require("react");
|
|
456
497
|
var import_react_router_dom = require("react-router-dom");
|
|
457
498
|
function NotFound() {
|
|
458
499
|
const [config] = useFaasState();
|
|
@@ -465,7 +506,7 @@ function Routes(props) {
|
|
|
465
506
|
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({
|
|
466
507
|
key: r.path
|
|
467
508
|
}, r), {
|
|
468
|
-
element: r.element || /* @__PURE__ */ import_react.default.createElement(
|
|
509
|
+
element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react10.Suspense, {
|
|
469
510
|
fallback: props.fallback || /* @__PURE__ */ import_react.default.createElement("div", {
|
|
470
511
|
style: { padding: "24px" }
|
|
471
512
|
}, /* @__PURE__ */ import_react.default.createElement(import_antd7.Skeleton, {
|
|
@@ -480,28 +521,45 @@ function Routes(props) {
|
|
|
480
521
|
}
|
|
481
522
|
|
|
482
523
|
// src/Table.tsx
|
|
483
|
-
var
|
|
524
|
+
var import_react11 = require("react");
|
|
484
525
|
var import_antd8 = require("antd");
|
|
526
|
+
var import_dayjs4 = __toESM(require("dayjs"));
|
|
485
527
|
var import_icons3 = require("@ant-design/icons");
|
|
486
528
|
var import_lodash5 = require("lodash");
|
|
487
|
-
var
|
|
529
|
+
var import_react12 = require("@faasjs/react");
|
|
488
530
|
function processValue(item, value) {
|
|
489
531
|
var _a;
|
|
490
|
-
if (
|
|
491
|
-
if (item.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
532
|
+
if (typeof value !== "undefined" && value !== null) {
|
|
533
|
+
if (item.options) {
|
|
534
|
+
if (item.type.endsWith("[]"))
|
|
535
|
+
return value.map((v) => {
|
|
536
|
+
var _a2;
|
|
537
|
+
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
538
|
+
});
|
|
539
|
+
else if ([
|
|
540
|
+
"string",
|
|
541
|
+
"number",
|
|
542
|
+
"boolean"
|
|
543
|
+
].includes(item.type))
|
|
544
|
+
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
545
|
+
}
|
|
546
|
+
let dayjsFormat = "";
|
|
547
|
+
if (item.type === "date")
|
|
548
|
+
dayjsFormat = "YYYY-MM-DD";
|
|
549
|
+
else if (item.type === "time")
|
|
550
|
+
dayjsFormat = "YYYY-MM-DD HH:mm:ss";
|
|
551
|
+
if (["date", "time"].includes(item.type)) {
|
|
552
|
+
if (typeof value === "number" && value.toString().length === 10)
|
|
553
|
+
value = value * 1e3;
|
|
554
|
+
value = (0, import_dayjs4.default)(value).format(dayjsFormat);
|
|
555
|
+
}
|
|
498
556
|
}
|
|
499
557
|
return value;
|
|
500
558
|
}
|
|
501
559
|
function Table(props) {
|
|
502
|
-
const [columns, setColumns] = (0,
|
|
560
|
+
const [columns, setColumns] = (0, import_react11.useState)();
|
|
503
561
|
const [config] = useFaasState();
|
|
504
|
-
(0,
|
|
562
|
+
(0, import_react11.useEffect)(() => {
|
|
505
563
|
var _a;
|
|
506
564
|
for (const item of props.items) {
|
|
507
565
|
if (!item.key)
|
|
@@ -525,7 +583,7 @@ function Table(props) {
|
|
|
525
583
|
delete item.children;
|
|
526
584
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
527
585
|
if (props.extendTypes[item.type].children) {
|
|
528
|
-
item.render = (value, values) => (0,
|
|
586
|
+
item.render = (value, values) => (0, import_react11.cloneElement)(props.extendTypes[item.type].children, {
|
|
529
587
|
value,
|
|
530
588
|
values
|
|
531
589
|
});
|
|
@@ -609,6 +667,16 @@ function Table(props) {
|
|
|
609
667
|
}
|
|
610
668
|
};
|
|
611
669
|
break;
|
|
670
|
+
case "date":
|
|
671
|
+
item.render = (value) => processValue(item, value);
|
|
672
|
+
if (!item.onFilter)
|
|
673
|
+
item.onFilter = (value, row) => (0, import_dayjs4.default)(row[item.id]).isSame((0, import_dayjs4.default)(value));
|
|
674
|
+
break;
|
|
675
|
+
case "time":
|
|
676
|
+
item.render = (value) => processValue(item, value);
|
|
677
|
+
if (!item.onFilter)
|
|
678
|
+
item.onFilter = (value, row) => (0, import_dayjs4.default)(row[item.id]).isSame((0, import_dayjs4.default)(value));
|
|
679
|
+
break;
|
|
612
680
|
default:
|
|
613
681
|
item.render = (value) => processValue(item, value);
|
|
614
682
|
if (!item.onFilter)
|
|
@@ -626,7 +694,7 @@ function Table(props) {
|
|
|
626
694
|
columns,
|
|
627
695
|
dataSource: props.dataSource
|
|
628
696
|
}));
|
|
629
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
697
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react12.FaasDataWrapper, __spreadValues({
|
|
630
698
|
fallback: props.faasData.fallback || /* @__PURE__ */ import_react.default.createElement(import_antd8.Skeleton, {
|
|
631
699
|
active: true
|
|
632
700
|
}),
|
|
@@ -674,20 +742,32 @@ function Table(props) {
|
|
|
674
742
|
}
|
|
675
743
|
|
|
676
744
|
// src/Title.tsx
|
|
677
|
-
var
|
|
745
|
+
var import_react13 = require("react");
|
|
678
746
|
function Title(props) {
|
|
679
747
|
const [config] = useFaasState();
|
|
680
|
-
(0,
|
|
748
|
+
(0, import_react13.useEffect)(() => {
|
|
681
749
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
682
750
|
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
683
751
|
}, []);
|
|
752
|
+
if (props.h1) {
|
|
753
|
+
if (typeof props.h1 === "boolean")
|
|
754
|
+
return /* @__PURE__ */ import_react.default.createElement("h1", null, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
755
|
+
return /* @__PURE__ */ import_react.default.createElement("h1", {
|
|
756
|
+
className: props.h1.className,
|
|
757
|
+
style: props.h1.style
|
|
758
|
+
}, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
759
|
+
}
|
|
760
|
+
if (props.children)
|
|
761
|
+
return (0, import_react13.cloneElement)(props.children, { title: props.title });
|
|
684
762
|
return null;
|
|
685
763
|
}
|
|
686
764
|
module.exports = __toCommonJS(src_exports);
|
|
687
765
|
// Annotate the CommonJS export names for ESM import in node:
|
|
688
766
|
0 && (module.exports = {
|
|
689
767
|
Blank,
|
|
768
|
+
Calendar,
|
|
690
769
|
Config,
|
|
770
|
+
DatePicker,
|
|
691
771
|
Description,
|
|
692
772
|
Drawer,
|
|
693
773
|
Form,
|
|
@@ -695,6 +775,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
695
775
|
Modal,
|
|
696
776
|
Routes,
|
|
697
777
|
Table,
|
|
778
|
+
TimePicker,
|
|
698
779
|
Title,
|
|
699
780
|
transferOptions,
|
|
700
781
|
useDrawer,
|
package/dist/index.mjs
CHANGED
|
@@ -65,6 +65,12 @@ function Blank(options) {
|
|
|
65
65
|
}, (options == null ? void 0 : options.text) || config.Blank.text) : options.value;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// src/Calendar.tsx
|
|
69
|
+
import dayjsGenerateConfig from "rc-picker/es/generate/dayjs.js";
|
|
70
|
+
import generateCalendar from "antd/es/calendar/generateCalendar.js";
|
|
71
|
+
import "antd/es/calendar/style/index.js";
|
|
72
|
+
var Calendar = generateCalendar(dayjsGenerateConfig);
|
|
73
|
+
|
|
68
74
|
// src/data.ts
|
|
69
75
|
import { upperFirst } from "lodash";
|
|
70
76
|
function transferOptions(options) {
|
|
@@ -76,6 +82,12 @@ function transferOptions(options) {
|
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
84
|
|
|
85
|
+
// src/DatePicker.tsx
|
|
86
|
+
import dayjsGenerateConfig2 from "rc-picker/es/generate/dayjs.js";
|
|
87
|
+
import generatePicker from "antd/es/date-picker/generatePicker/index.js";
|
|
88
|
+
import "antd/es/date-picker/style/index.js";
|
|
89
|
+
var DatePicker = generatePicker(dayjsGenerateConfig2);
|
|
90
|
+
|
|
79
91
|
// src/Description.tsx
|
|
80
92
|
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
|
|
81
93
|
import {
|
|
@@ -88,6 +100,7 @@ import {
|
|
|
88
100
|
useEffect as useEffect2,
|
|
89
101
|
useState
|
|
90
102
|
} from "react";
|
|
103
|
+
import dayjs from "dayjs";
|
|
91
104
|
import { FaasDataWrapper } from "@faasjs/react";
|
|
92
105
|
function DescriptionItemContent(props) {
|
|
93
106
|
const [computedProps, setComputedProps] = useState();
|
|
@@ -107,7 +120,11 @@ function DescriptionItemContent(props) {
|
|
|
107
120
|
var _a2;
|
|
108
121
|
return ((_a2 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
109
122
|
});
|
|
110
|
-
else
|
|
123
|
+
else if ([
|
|
124
|
+
"string",
|
|
125
|
+
"number",
|
|
126
|
+
"boolean"
|
|
127
|
+
].includes(propsCopy.item.type))
|
|
111
128
|
propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
|
|
112
129
|
}
|
|
113
130
|
setComputedProps(propsCopy);
|
|
@@ -149,6 +166,10 @@ function DescriptionItemContent(props) {
|
|
|
149
166
|
color: "#ff4d4f"
|
|
150
167
|
}
|
|
151
168
|
});
|
|
169
|
+
case "time":
|
|
170
|
+
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? dayjs.unix(computedProps.value).format("YYYY-MM-DD HH:mm:ss") : dayjs(computedProps.value).format("YYYY-MM-DD HH:mm:ss");
|
|
171
|
+
case "date":
|
|
172
|
+
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? dayjs.unix(computedProps.value).format("YYYY-MM-DD") : dayjs(computedProps.value).format("YYYY-MM-DD");
|
|
152
173
|
default:
|
|
153
174
|
return computedProps.value;
|
|
154
175
|
}
|
|
@@ -220,6 +241,19 @@ import {
|
|
|
220
241
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
221
242
|
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
222
243
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
244
|
+
|
|
245
|
+
// src/TimePicker.tsx
|
|
246
|
+
import { forwardRef } from "react";
|
|
247
|
+
var TimePicker = forwardRef((props, ref) => {
|
|
248
|
+
return /* @__PURE__ */ React.createElement(DatePicker, __spreadProps(__spreadValues({}, props), {
|
|
249
|
+
picker: "time",
|
|
250
|
+
mode: void 0,
|
|
251
|
+
ref
|
|
252
|
+
}));
|
|
253
|
+
});
|
|
254
|
+
TimePicker.displayName = "TimePicker";
|
|
255
|
+
|
|
256
|
+
// src/FormItem.tsx
|
|
223
257
|
function FormItem(props) {
|
|
224
258
|
const [computedProps, setComputedProps] = useState3();
|
|
225
259
|
useEffect3(() => {
|
|
@@ -365,6 +399,10 @@ function FormItem(props) {
|
|
|
365
399
|
});
|
|
366
400
|
case "boolean":
|
|
367
401
|
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), /* @__PURE__ */ React.createElement(Switch, __spreadValues({}, computedProps.input)));
|
|
402
|
+
case "date":
|
|
403
|
+
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), /* @__PURE__ */ React.createElement(DatePicker, __spreadValues({}, computedProps.input)));
|
|
404
|
+
case "time":
|
|
405
|
+
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), /* @__PURE__ */ React.createElement(TimePicker, __spreadValues({}, computedProps.input)));
|
|
368
406
|
default:
|
|
369
407
|
return null;
|
|
370
408
|
}
|
|
@@ -470,19 +508,36 @@ import {
|
|
|
470
508
|
Radio,
|
|
471
509
|
Skeleton as Skeleton3
|
|
472
510
|
} from "antd";
|
|
511
|
+
import dayjs2 from "dayjs";
|
|
473
512
|
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
474
513
|
import { isNil as isNil2, upperFirst as upperFirst4 } from "lodash";
|
|
475
514
|
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
476
515
|
function processValue(item, value) {
|
|
477
516
|
var _a;
|
|
478
|
-
if (
|
|
479
|
-
if (item.
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
517
|
+
if (typeof value !== "undefined" && value !== null) {
|
|
518
|
+
if (item.options) {
|
|
519
|
+
if (item.type.endsWith("[]"))
|
|
520
|
+
return value.map((v) => {
|
|
521
|
+
var _a2;
|
|
522
|
+
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
523
|
+
});
|
|
524
|
+
else if ([
|
|
525
|
+
"string",
|
|
526
|
+
"number",
|
|
527
|
+
"boolean"
|
|
528
|
+
].includes(item.type))
|
|
529
|
+
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
530
|
+
}
|
|
531
|
+
let dayjsFormat = "";
|
|
532
|
+
if (item.type === "date")
|
|
533
|
+
dayjsFormat = "YYYY-MM-DD";
|
|
534
|
+
else if (item.type === "time")
|
|
535
|
+
dayjsFormat = "YYYY-MM-DD HH:mm:ss";
|
|
536
|
+
if (["date", "time"].includes(item.type)) {
|
|
537
|
+
if (typeof value === "number" && value.toString().length === 10)
|
|
538
|
+
value = value * 1e3;
|
|
539
|
+
value = dayjs2(value).format(dayjsFormat);
|
|
540
|
+
}
|
|
486
541
|
}
|
|
487
542
|
return value;
|
|
488
543
|
}
|
|
@@ -597,6 +652,16 @@ function Table(props) {
|
|
|
597
652
|
}
|
|
598
653
|
};
|
|
599
654
|
break;
|
|
655
|
+
case "date":
|
|
656
|
+
item.render = (value) => processValue(item, value);
|
|
657
|
+
if (!item.onFilter)
|
|
658
|
+
item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
|
|
659
|
+
break;
|
|
660
|
+
case "time":
|
|
661
|
+
item.render = (value) => processValue(item, value);
|
|
662
|
+
if (!item.onFilter)
|
|
663
|
+
item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
|
|
664
|
+
break;
|
|
600
665
|
default:
|
|
601
666
|
item.render = (value) => processValue(item, value);
|
|
602
667
|
if (!item.onFilter)
|
|
@@ -662,18 +727,30 @@ function Table(props) {
|
|
|
662
727
|
}
|
|
663
728
|
|
|
664
729
|
// src/Title.tsx
|
|
665
|
-
import { useEffect as useEffect6 } from "react";
|
|
730
|
+
import { useEffect as useEffect6, cloneElement as cloneElement3 } from "react";
|
|
666
731
|
function Title(props) {
|
|
667
732
|
const [config] = useFaasState();
|
|
668
733
|
useEffect6(() => {
|
|
669
734
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
670
735
|
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
671
736
|
}, []);
|
|
737
|
+
if (props.h1) {
|
|
738
|
+
if (typeof props.h1 === "boolean")
|
|
739
|
+
return /* @__PURE__ */ React.createElement("h1", null, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
740
|
+
return /* @__PURE__ */ React.createElement("h1", {
|
|
741
|
+
className: props.h1.className,
|
|
742
|
+
style: props.h1.style
|
|
743
|
+
}, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
744
|
+
}
|
|
745
|
+
if (props.children)
|
|
746
|
+
return cloneElement3(props.children, { title: props.title });
|
|
672
747
|
return null;
|
|
673
748
|
}
|
|
674
749
|
export {
|
|
675
750
|
Blank,
|
|
751
|
+
Calendar,
|
|
676
752
|
Config,
|
|
753
|
+
DatePicker,
|
|
677
754
|
Description,
|
|
678
755
|
Drawer,
|
|
679
756
|
Form,
|
|
@@ -681,6 +758,7 @@ export {
|
|
|
681
758
|
Modal,
|
|
682
759
|
Routes,
|
|
683
760
|
Table,
|
|
761
|
+
TimePicker,
|
|
684
762
|
Title,
|
|
685
763
|
transferOptions,
|
|
686
764
|
useDrawer,
|
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.374",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"funding": "https://github.com/sponsors/faasjs",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "tsup src/index.ts --format esm,cjs --inject react-shim.js",
|
|
19
|
+
"build": "tsup-node src/index.ts --format esm,cjs --inject react-shim.js",
|
|
20
20
|
"build:types": "tsup-node src/index.ts --dts-only"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.374",
|
|
32
32
|
"react-use": "*",
|
|
33
|
-
"react-router-dom": "*"
|
|
33
|
+
"react-router-dom": "*",
|
|
34
|
+
"dayjs": "*"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/lodash": "*",
|