@faasjs/ant-design 0.0.2-beta.367 → 0.0.2-beta.371
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 +113 -3
- package/dist/index.d.ts +56 -7
- package/dist/index.js +282 -30
- package/dist/index.mjs +261 -12
- package/package.json +4 -3
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)
|
|
@@ -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
|
|
|
@@ -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,63 @@ ___
|
|
|
344
375
|
|
|
345
376
|
| Name | Type | Description |
|
|
346
377
|
| :------ | :------ | :------ |
|
|
378
|
+
| `h1?` | `boolean` \| { `className?`: `string` ; `style?`: `React.CSSProperties` } | - |
|
|
347
379
|
| `separator?` | `string` | ` - ` as default |
|
|
348
380
|
| `suffix?` | `string` | - |
|
|
349
381
|
| `title` | `string` \| `string`[] | - |
|
|
350
382
|
|
|
383
|
+
___
|
|
384
|
+
|
|
385
|
+
### setDrawerProps
|
|
386
|
+
|
|
387
|
+
Ƭ **setDrawerProps**: (`changes`: `Partial`<[`DrawerProps`](#drawerprops)\>) => `void`
|
|
388
|
+
|
|
389
|
+
#### Type declaration
|
|
390
|
+
|
|
391
|
+
▸ (`changes`): `void`
|
|
392
|
+
|
|
393
|
+
##### Parameters
|
|
394
|
+
|
|
395
|
+
| Name | Type |
|
|
396
|
+
| :------ | :------ |
|
|
397
|
+
| `changes` | `Partial`<[`DrawerProps`](#drawerprops)\> |
|
|
398
|
+
|
|
399
|
+
##### Returns
|
|
400
|
+
|
|
401
|
+
`void`
|
|
402
|
+
|
|
403
|
+
___
|
|
404
|
+
|
|
405
|
+
### setModalProps
|
|
406
|
+
|
|
407
|
+
Ƭ **setModalProps**: (`changes`: `Partial`<[`ModalProps`](#modalprops)\>) => `void`
|
|
408
|
+
|
|
409
|
+
#### Type declaration
|
|
410
|
+
|
|
411
|
+
▸ (`changes`): `void`
|
|
412
|
+
|
|
413
|
+
##### Parameters
|
|
414
|
+
|
|
415
|
+
| Name | Type |
|
|
416
|
+
| :------ | :------ |
|
|
417
|
+
| `changes` | `Partial`<[`ModalProps`](#modalprops)\> |
|
|
418
|
+
|
|
419
|
+
##### Returns
|
|
420
|
+
|
|
421
|
+
`void`
|
|
422
|
+
|
|
423
|
+
## Variables
|
|
424
|
+
|
|
425
|
+
### DatePicker
|
|
426
|
+
|
|
427
|
+
• **DatePicker**: `PickerComponentClass`<`PickerProps`<`Dayjs`\>, `unknown`\> & {}
|
|
428
|
+
|
|
429
|
+
___
|
|
430
|
+
|
|
431
|
+
### TimePicker
|
|
432
|
+
|
|
433
|
+
• **TimePicker**: `ForwardRefExoticComponent`<[`TimePickerProps`](#timepickerprops) & `RefAttributes`<`any`\>\>
|
|
434
|
+
|
|
351
435
|
## Functions
|
|
352
436
|
|
|
353
437
|
### Blank
|
|
@@ -372,6 +456,22 @@ If value is undefined or null, return text, otherwise return value.
|
|
|
372
456
|
|
|
373
457
|
___
|
|
374
458
|
|
|
459
|
+
### Calendar
|
|
460
|
+
|
|
461
|
+
▸ `Const` **Calendar**(`props`): `Element`
|
|
462
|
+
|
|
463
|
+
#### Parameters
|
|
464
|
+
|
|
465
|
+
| Name | Type |
|
|
466
|
+
| :------ | :------ |
|
|
467
|
+
| `props` | `CalendarProps`<`Dayjs`\> |
|
|
468
|
+
|
|
469
|
+
#### Returns
|
|
470
|
+
|
|
471
|
+
`Element`
|
|
472
|
+
|
|
473
|
+
___
|
|
474
|
+
|
|
375
475
|
### Config
|
|
376
476
|
|
|
377
477
|
▸ **Config**(`props`): `JSX.Element`
|
|
@@ -520,6 +620,16 @@ ___
|
|
|
520
620
|
|
|
521
621
|
▸ **Title**(`props`): `JSX.Element`
|
|
522
622
|
|
|
623
|
+
Title is used to change the title of the page.
|
|
624
|
+
|
|
625
|
+
```ts
|
|
626
|
+
<Title title='hi' /> // => return null, change the document.title to 'hi'
|
|
627
|
+
<Title title={['a', 'b']} /> // => return null, change the document.title to 'a - b'
|
|
628
|
+
|
|
629
|
+
<Title title='hi' h1 /> // => return <h1>hi</h1>, change the document.title to 'hi'
|
|
630
|
+
<Title title={['a', 'b']} h1 /> // => return <h1>a</h1>, change the document.title to 'a - b'
|
|
631
|
+
```
|
|
632
|
+
|
|
523
633
|
#### Parameters
|
|
524
634
|
|
|
525
635
|
| Name | Type |
|
|
@@ -600,6 +710,6 @@ Hook style modal.
|
|
|
600
710
|
|
|
601
711
|
| Name | Type |
|
|
602
712
|
| :------ | :------ |
|
|
603
|
-
| `
|
|
604
|
-
| `
|
|
713
|
+
| `modal` | `Element` |
|
|
714
|
+
| `modalProps` | [`ModalProps`](#modalprops) |
|
|
605
715
|
| `setModalProps` | (`changes`: `Partial`<[`ModalProps`](#modalprops)\>) => `void` |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
1
|
+
import * as antd_es_calendar_generateCalendar from 'antd/es/calendar/generateCalendar';
|
|
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.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
|
|
@@ -228,8 +259,8 @@ declare type ModalProps = ModalProps$1 & {
|
|
|
228
259
|
* ```
|
|
229
260
|
*/
|
|
230
261
|
declare function useModal(init?: ModalProps): {
|
|
231
|
-
|
|
232
|
-
|
|
262
|
+
modal: JSX.Element;
|
|
263
|
+
modalProps: ModalProps;
|
|
233
264
|
setModalProps(changes: Partial<ModalProps>): void;
|
|
234
265
|
};
|
|
235
266
|
|
|
@@ -266,12 +297,30 @@ 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
|
+
h1?: boolean | {
|
|
309
|
+
className?: string;
|
|
310
|
+
style?: React.CSSProperties;
|
|
311
|
+
};
|
|
274
312
|
};
|
|
313
|
+
/**
|
|
314
|
+
* Title is used to change the title of the page.
|
|
315
|
+
*
|
|
316
|
+
* ```ts
|
|
317
|
+
* <Title title='hi' /> // => return null, change the document.title to 'hi'
|
|
318
|
+
* <Title title={['a', 'b']} /> // => return null, change the document.title to 'a - b'
|
|
319
|
+
*
|
|
320
|
+
* <Title title='hi' h1 /> // => return <h1>hi</h1>, change the document.title to 'hi'
|
|
321
|
+
* <Title title={['a', 'b']} h1 /> // => return <h1>a</h1>, change the document.title to 'a - b'
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
275
324
|
declare function Title(props: TitleProps): JSX.Element;
|
|
276
325
|
|
|
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 };
|
|
326
|
+
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,181 @@ function Blank(options) {
|
|
|
109
112
|
}, (options == null ? void 0 : options.text) || config.Blank.text) : options.value;
|
|
110
113
|
}
|
|
111
114
|
|
|
115
|
+
// ../../node_modules/rc-picker/es/generate/dayjs.js
|
|
116
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
117
|
+
|
|
118
|
+
// ../../node_modules/rc-util/es/warning.js
|
|
119
|
+
var warned = {};
|
|
120
|
+
function note(valid, message) {
|
|
121
|
+
if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
|
|
122
|
+
console.warn("Note: ".concat(message));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function call(method, valid, message) {
|
|
126
|
+
if (!valid && !warned[message]) {
|
|
127
|
+
method(false, message);
|
|
128
|
+
warned[message] = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function noteOnce(valid, message) {
|
|
132
|
+
call(note, valid, message);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ../../node_modules/rc-picker/es/generate/dayjs.js
|
|
136
|
+
var import_weekday = __toESM(require("dayjs/plugin/weekday"));
|
|
137
|
+
var import_localeData = __toESM(require("dayjs/plugin/localeData"));
|
|
138
|
+
var import_weekOfYear = __toESM(require("dayjs/plugin/weekOfYear"));
|
|
139
|
+
var import_weekYear = __toESM(require("dayjs/plugin/weekYear"));
|
|
140
|
+
var import_advancedFormat = __toESM(require("dayjs/plugin/advancedFormat"));
|
|
141
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
142
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
143
|
+
import_dayjs.default.extend(import_advancedFormat.default);
|
|
144
|
+
import_dayjs.default.extend(import_weekday.default);
|
|
145
|
+
import_dayjs.default.extend(import_localeData.default);
|
|
146
|
+
import_dayjs.default.extend(import_weekOfYear.default);
|
|
147
|
+
import_dayjs.default.extend(import_weekYear.default);
|
|
148
|
+
import_dayjs.default.extend(function(o, c) {
|
|
149
|
+
var proto = c.prototype;
|
|
150
|
+
var oldFormat = proto.format;
|
|
151
|
+
proto.format = function f(formatStr) {
|
|
152
|
+
var str = (formatStr || "").replace("Wo", "wo");
|
|
153
|
+
return oldFormat.bind(this)(str);
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
var localeMap = {
|
|
157
|
+
en_GB: "en-gb",
|
|
158
|
+
en_US: "en",
|
|
159
|
+
zh_CN: "zh-cn",
|
|
160
|
+
zh_TW: "zh-tw"
|
|
161
|
+
};
|
|
162
|
+
var parseLocale = function parseLocale2(locale) {
|
|
163
|
+
var mapLocale = localeMap[locale];
|
|
164
|
+
return mapLocale || locale.split("_")[0];
|
|
165
|
+
};
|
|
166
|
+
var parseNoMatchNotice = function parseNoMatchNotice2() {
|
|
167
|
+
noteOnce(false, "Not match any format. Please help to fire a issue about this.");
|
|
168
|
+
};
|
|
169
|
+
var generateConfig = {
|
|
170
|
+
getNow: function getNow() {
|
|
171
|
+
return (0, import_dayjs.default)();
|
|
172
|
+
},
|
|
173
|
+
getFixedDate: function getFixedDate(string) {
|
|
174
|
+
return (0, import_dayjs.default)(string, "YYYY-MM-DD");
|
|
175
|
+
},
|
|
176
|
+
getEndDate: function getEndDate(date) {
|
|
177
|
+
return date.endOf("month");
|
|
178
|
+
},
|
|
179
|
+
getWeekDay: function getWeekDay(date) {
|
|
180
|
+
var clone = date.locale("en");
|
|
181
|
+
return clone.weekday() + clone.localeData().firstDayOfWeek();
|
|
182
|
+
},
|
|
183
|
+
getYear: function getYear(date) {
|
|
184
|
+
return date.year();
|
|
185
|
+
},
|
|
186
|
+
getMonth: function getMonth(date) {
|
|
187
|
+
return date.month();
|
|
188
|
+
},
|
|
189
|
+
getDate: function getDate(date) {
|
|
190
|
+
return date.date();
|
|
191
|
+
},
|
|
192
|
+
getHour: function getHour(date) {
|
|
193
|
+
return date.hour();
|
|
194
|
+
},
|
|
195
|
+
getMinute: function getMinute(date) {
|
|
196
|
+
return date.minute();
|
|
197
|
+
},
|
|
198
|
+
getSecond: function getSecond(date) {
|
|
199
|
+
return date.second();
|
|
200
|
+
},
|
|
201
|
+
addYear: function addYear(date, diff) {
|
|
202
|
+
return date.add(diff, "year");
|
|
203
|
+
},
|
|
204
|
+
addMonth: function addMonth(date, diff) {
|
|
205
|
+
return date.add(diff, "month");
|
|
206
|
+
},
|
|
207
|
+
addDate: function addDate(date, diff) {
|
|
208
|
+
return date.add(diff, "day");
|
|
209
|
+
},
|
|
210
|
+
setYear: function setYear(date, year) {
|
|
211
|
+
return date.year(year);
|
|
212
|
+
},
|
|
213
|
+
setMonth: function setMonth(date, month) {
|
|
214
|
+
return date.month(month);
|
|
215
|
+
},
|
|
216
|
+
setDate: function setDate(date, num) {
|
|
217
|
+
return date.date(num);
|
|
218
|
+
},
|
|
219
|
+
setHour: function setHour(date, hour) {
|
|
220
|
+
return date.hour(hour);
|
|
221
|
+
},
|
|
222
|
+
setMinute: function setMinute(date, minute) {
|
|
223
|
+
return date.minute(minute);
|
|
224
|
+
},
|
|
225
|
+
setSecond: function setSecond(date, second) {
|
|
226
|
+
return date.second(second);
|
|
227
|
+
},
|
|
228
|
+
isAfter: function isAfter(date1, date2) {
|
|
229
|
+
return date1.isAfter(date2);
|
|
230
|
+
},
|
|
231
|
+
isValidate: function isValidate(date) {
|
|
232
|
+
return date.isValid();
|
|
233
|
+
},
|
|
234
|
+
locale: {
|
|
235
|
+
getWeekFirstDay: function getWeekFirstDay(locale) {
|
|
236
|
+
return (0, import_dayjs.default)().locale(parseLocale(locale)).localeData().firstDayOfWeek();
|
|
237
|
+
},
|
|
238
|
+
getWeekFirstDate: function getWeekFirstDate(locale, date) {
|
|
239
|
+
return date.locale(parseLocale(locale)).weekday(0);
|
|
240
|
+
},
|
|
241
|
+
getWeek: function getWeek(locale, date) {
|
|
242
|
+
return date.locale(parseLocale(locale)).week();
|
|
243
|
+
},
|
|
244
|
+
getShortWeekDays: function getShortWeekDays(locale) {
|
|
245
|
+
return (0, import_dayjs.default)().locale(parseLocale(locale)).localeData().weekdaysMin();
|
|
246
|
+
},
|
|
247
|
+
getShortMonths: function getShortMonths(locale) {
|
|
248
|
+
return (0, import_dayjs.default)().locale(parseLocale(locale)).localeData().monthsShort();
|
|
249
|
+
},
|
|
250
|
+
format: function format(locale, date, _format) {
|
|
251
|
+
return date.locale(parseLocale(locale)).format(_format);
|
|
252
|
+
},
|
|
253
|
+
parse: function parse(locale, text, formats) {
|
|
254
|
+
var localeStr = parseLocale(locale);
|
|
255
|
+
for (var i = 0; i < formats.length; i += 1) {
|
|
256
|
+
var format2 = formats[i];
|
|
257
|
+
var formatText = text;
|
|
258
|
+
if (format2.includes("wo") || format2.includes("Wo")) {
|
|
259
|
+
var year = formatText.split("-")[0];
|
|
260
|
+
var weekStr = formatText.split("-")[1];
|
|
261
|
+
var firstWeek = (0, import_dayjs.default)(year, "YYYY").startOf("year").locale(localeStr);
|
|
262
|
+
for (var j = 0; j <= 52; j += 1) {
|
|
263
|
+
var nextWeek = firstWeek.add(j, "week");
|
|
264
|
+
if (nextWeek.format("Wo") === weekStr) {
|
|
265
|
+
return nextWeek;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
parseNoMatchNotice();
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
var date = (0, import_dayjs.default)(formatText, format2).locale(localeStr);
|
|
272
|
+
if (date.isValid()) {
|
|
273
|
+
return date;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (text) {
|
|
277
|
+
parseNoMatchNotice();
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
var dayjs_default = generateConfig;
|
|
284
|
+
|
|
285
|
+
// src/Calendar.tsx
|
|
286
|
+
var import_generateCalendar = __toESM(require("antd/es/calendar/generateCalendar"));
|
|
287
|
+
var import_style = require("antd/es/calendar/style");
|
|
288
|
+
var Calendar = (0, import_generateCalendar.default)(dayjs_default);
|
|
289
|
+
|
|
112
290
|
// src/data.ts
|
|
113
291
|
var import_lodash2 = require("lodash");
|
|
114
292
|
function transferOptions(options) {
|
|
@@ -120,11 +298,17 @@ function transferOptions(options) {
|
|
|
120
298
|
});
|
|
121
299
|
}
|
|
122
300
|
|
|
301
|
+
// src/DatePicker.tsx
|
|
302
|
+
var import_generatePicker = __toESM(require("antd/es/date-picker/generatePicker"));
|
|
303
|
+
var import_style2 = require("antd/es/date-picker/style");
|
|
304
|
+
var DatePicker = (0, import_generatePicker.default)(dayjs_default);
|
|
305
|
+
|
|
123
306
|
// src/Description.tsx
|
|
124
307
|
var import_icons = require("@ant-design/icons");
|
|
125
308
|
var import_antd2 = require("antd");
|
|
126
309
|
var import_lodash3 = require("lodash");
|
|
127
310
|
var import_react3 = require("react");
|
|
311
|
+
var import_dayjs4 = __toESM(require("dayjs"));
|
|
128
312
|
var import_react4 = require("@faasjs/react");
|
|
129
313
|
function DescriptionItemContent(props) {
|
|
130
314
|
const [computedProps, setComputedProps] = (0, import_react3.useState)();
|
|
@@ -144,7 +328,11 @@ function DescriptionItemContent(props) {
|
|
|
144
328
|
var _a2;
|
|
145
329
|
return ((_a2 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
146
330
|
});
|
|
147
|
-
else
|
|
331
|
+
else if ([
|
|
332
|
+
"string",
|
|
333
|
+
"number",
|
|
334
|
+
"boolean"
|
|
335
|
+
].includes(propsCopy.item.type))
|
|
148
336
|
propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
|
|
149
337
|
}
|
|
150
338
|
setComputedProps(propsCopy);
|
|
@@ -186,6 +374,10 @@ function DescriptionItemContent(props) {
|
|
|
186
374
|
color: "#ff4d4f"
|
|
187
375
|
}
|
|
188
376
|
});
|
|
377
|
+
case "time":
|
|
378
|
+
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? import_dayjs4.default.unix(computedProps.value).format("YYYY-MM-DD HH:mm:ss") : (0, import_dayjs4.default)(computedProps.value).format("YYYY-MM-DD HH:mm:ss");
|
|
379
|
+
case "date":
|
|
380
|
+
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? import_dayjs4.default.unix(computedProps.value).format("YYYY-MM-DD") : (0, import_dayjs4.default)(computedProps.value).format("YYYY-MM-DD");
|
|
189
381
|
default:
|
|
190
382
|
return computedProps.value;
|
|
191
383
|
}
|
|
@@ -238,16 +430,29 @@ function useDrawer(init) {
|
|
|
238
430
|
|
|
239
431
|
// src/Form.tsx
|
|
240
432
|
var import_antd5 = require("antd");
|
|
241
|
-
var
|
|
433
|
+
var import_react8 = require("react");
|
|
242
434
|
|
|
243
435
|
// src/FormItem.tsx
|
|
244
436
|
var import_antd4 = require("antd");
|
|
245
437
|
var import_icons2 = require("@ant-design/icons");
|
|
246
|
-
var
|
|
438
|
+
var import_react7 = require("react");
|
|
247
439
|
var import_lodash4 = require("lodash");
|
|
440
|
+
|
|
441
|
+
// src/TimePicker.tsx
|
|
442
|
+
var import_react6 = require("react");
|
|
443
|
+
var TimePicker = (0, import_react6.forwardRef)((props, ref) => {
|
|
444
|
+
return /* @__PURE__ */ import_react.default.createElement(DatePicker, __spreadProps(__spreadValues({}, props), {
|
|
445
|
+
picker: "time",
|
|
446
|
+
mode: void 0,
|
|
447
|
+
ref
|
|
448
|
+
}));
|
|
449
|
+
});
|
|
450
|
+
TimePicker.displayName = "TimePicker";
|
|
451
|
+
|
|
452
|
+
// src/FormItem.tsx
|
|
248
453
|
function FormItem(props) {
|
|
249
|
-
const [computedProps, setComputedProps] = (0,
|
|
250
|
-
(0,
|
|
454
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
455
|
+
(0, import_react7.useEffect)(() => {
|
|
251
456
|
const propsCopy = __spreadValues({}, props);
|
|
252
457
|
if (!propsCopy.title)
|
|
253
458
|
propsCopy.title = (0, import_lodash4.upperFirst)(propsCopy.id);
|
|
@@ -390,6 +595,10 @@ function FormItem(props) {
|
|
|
390
595
|
});
|
|
391
596
|
case "boolean":
|
|
392
597
|
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), /* @__PURE__ */ import_react.default.createElement(import_antd4.Switch, __spreadValues({}, computedProps.input)));
|
|
598
|
+
case "date":
|
|
599
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), /* @__PURE__ */ import_react.default.createElement(DatePicker, __spreadValues({}, computedProps.input)));
|
|
600
|
+
case "time":
|
|
601
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), /* @__PURE__ */ import_react.default.createElement(TimePicker, __spreadValues({}, computedProps.input)));
|
|
393
602
|
default:
|
|
394
603
|
return null;
|
|
395
604
|
}
|
|
@@ -398,10 +607,10 @@ function FormItem(props) {
|
|
|
398
607
|
// src/Form.tsx
|
|
399
608
|
function Form(props) {
|
|
400
609
|
var _a, _b;
|
|
401
|
-
const [loading, setLoading] = (0,
|
|
402
|
-
const [computedProps, setComputedProps] = (0,
|
|
610
|
+
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
611
|
+
const [computedProps, setComputedProps] = (0, import_react8.useState)();
|
|
403
612
|
const [config] = useFaasState();
|
|
404
|
-
(0,
|
|
613
|
+
(0, import_react8.useEffect)(() => {
|
|
405
614
|
const propsCopy = __spreadValues({}, props);
|
|
406
615
|
if (propsCopy.onFinish) {
|
|
407
616
|
propsCopy.onFinish = async (values) => {
|
|
@@ -433,12 +642,17 @@ Form.Item = FormItem;
|
|
|
433
642
|
|
|
434
643
|
// src/Modal.tsx
|
|
435
644
|
var import_antd6 = require("antd");
|
|
436
|
-
var
|
|
645
|
+
var import_react9 = require("react");
|
|
437
646
|
function useModal(init) {
|
|
438
|
-
const [props, setProps] = (0,
|
|
647
|
+
const [props, setProps] = (0, import_react9.useState)(__spreadValues({
|
|
648
|
+
visible: false,
|
|
649
|
+
onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
650
|
+
visible: false
|
|
651
|
+
}))
|
|
652
|
+
}, init));
|
|
439
653
|
return {
|
|
440
|
-
|
|
441
|
-
|
|
654
|
+
modal: /* @__PURE__ */ import_react.default.createElement(import_antd6.Modal, __spreadValues({}, props)),
|
|
655
|
+
modalProps: props,
|
|
442
656
|
setModalProps(changes) {
|
|
443
657
|
setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
|
|
444
658
|
}
|
|
@@ -447,7 +661,7 @@ function useModal(init) {
|
|
|
447
661
|
|
|
448
662
|
// src/Routers.tsx
|
|
449
663
|
var import_antd7 = require("antd");
|
|
450
|
-
var
|
|
664
|
+
var import_react10 = require("react");
|
|
451
665
|
var import_react_router_dom = require("react-router-dom");
|
|
452
666
|
function NotFound() {
|
|
453
667
|
const [config] = useFaasState();
|
|
@@ -460,7 +674,7 @@ function Routes(props) {
|
|
|
460
674
|
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({
|
|
461
675
|
key: r.path
|
|
462
676
|
}, r), {
|
|
463
|
-
element: r.element || /* @__PURE__ */ import_react.default.createElement(
|
|
677
|
+
element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react10.Suspense, {
|
|
464
678
|
fallback: props.fallback || /* @__PURE__ */ import_react.default.createElement("div", {
|
|
465
679
|
style: { padding: "24px" }
|
|
466
680
|
}, /* @__PURE__ */ import_react.default.createElement(import_antd7.Skeleton, {
|
|
@@ -475,28 +689,45 @@ function Routes(props) {
|
|
|
475
689
|
}
|
|
476
690
|
|
|
477
691
|
// src/Table.tsx
|
|
478
|
-
var
|
|
692
|
+
var import_react11 = require("react");
|
|
479
693
|
var import_antd8 = require("antd");
|
|
694
|
+
var import_dayjs5 = __toESM(require("dayjs"));
|
|
480
695
|
var import_icons3 = require("@ant-design/icons");
|
|
481
696
|
var import_lodash5 = require("lodash");
|
|
482
|
-
var
|
|
697
|
+
var import_react12 = require("@faasjs/react");
|
|
483
698
|
function processValue(item, value) {
|
|
484
699
|
var _a;
|
|
485
|
-
if (
|
|
486
|
-
if (item.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
700
|
+
if (typeof value !== "undefined" && value !== null) {
|
|
701
|
+
if (item.options) {
|
|
702
|
+
if (item.type.endsWith("[]"))
|
|
703
|
+
return value.map((v) => {
|
|
704
|
+
var _a2;
|
|
705
|
+
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
706
|
+
});
|
|
707
|
+
else if ([
|
|
708
|
+
"string",
|
|
709
|
+
"number",
|
|
710
|
+
"boolean"
|
|
711
|
+
].includes(item.type))
|
|
712
|
+
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
713
|
+
}
|
|
714
|
+
let dayjsFormat = "";
|
|
715
|
+
if (item.type === "date")
|
|
716
|
+
dayjsFormat = "YYYY-MM-DD";
|
|
717
|
+
else if (item.type === "time")
|
|
718
|
+
dayjsFormat = "YYYY-MM-DD HH:mm:ss";
|
|
719
|
+
if (["date", "time"].includes(item.type)) {
|
|
720
|
+
if (typeof value === "number" && value.toString().length === 10)
|
|
721
|
+
value = value * 1e3;
|
|
722
|
+
value = (0, import_dayjs5.default)(value).format(dayjsFormat);
|
|
723
|
+
}
|
|
493
724
|
}
|
|
494
725
|
return value;
|
|
495
726
|
}
|
|
496
727
|
function Table(props) {
|
|
497
|
-
const [columns, setColumns] = (0,
|
|
728
|
+
const [columns, setColumns] = (0, import_react11.useState)();
|
|
498
729
|
const [config] = useFaasState();
|
|
499
|
-
(0,
|
|
730
|
+
(0, import_react11.useEffect)(() => {
|
|
500
731
|
var _a;
|
|
501
732
|
for (const item of props.items) {
|
|
502
733
|
if (!item.key)
|
|
@@ -520,7 +751,7 @@ function Table(props) {
|
|
|
520
751
|
delete item.children;
|
|
521
752
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
522
753
|
if (props.extendTypes[item.type].children) {
|
|
523
|
-
item.render = (value, values) => (0,
|
|
754
|
+
item.render = (value, values) => (0, import_react11.cloneElement)(props.extendTypes[item.type].children, {
|
|
524
755
|
value,
|
|
525
756
|
values
|
|
526
757
|
});
|
|
@@ -604,6 +835,16 @@ function Table(props) {
|
|
|
604
835
|
}
|
|
605
836
|
};
|
|
606
837
|
break;
|
|
838
|
+
case "date":
|
|
839
|
+
item.render = (value) => processValue(item, value);
|
|
840
|
+
if (!item.onFilter)
|
|
841
|
+
item.onFilter = (value, row) => (0, import_dayjs5.default)(row[item.id]).isSame((0, import_dayjs5.default)(value));
|
|
842
|
+
break;
|
|
843
|
+
case "time":
|
|
844
|
+
item.render = (value) => processValue(item, value);
|
|
845
|
+
if (!item.onFilter)
|
|
846
|
+
item.onFilter = (value, row) => (0, import_dayjs5.default)(row[item.id]).isSame((0, import_dayjs5.default)(value));
|
|
847
|
+
break;
|
|
607
848
|
default:
|
|
608
849
|
item.render = (value) => processValue(item, value);
|
|
609
850
|
if (!item.onFilter)
|
|
@@ -621,7 +862,7 @@ function Table(props) {
|
|
|
621
862
|
columns,
|
|
622
863
|
dataSource: props.dataSource
|
|
623
864
|
}));
|
|
624
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
865
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react12.FaasDataWrapper, __spreadValues({
|
|
625
866
|
fallback: props.faasData.fallback || /* @__PURE__ */ import_react.default.createElement(import_antd8.Skeleton, {
|
|
626
867
|
active: true
|
|
627
868
|
}),
|
|
@@ -669,20 +910,30 @@ function Table(props) {
|
|
|
669
910
|
}
|
|
670
911
|
|
|
671
912
|
// src/Title.tsx
|
|
672
|
-
var
|
|
913
|
+
var import_react13 = require("react");
|
|
673
914
|
function Title(props) {
|
|
674
915
|
const [config] = useFaasState();
|
|
675
|
-
(0,
|
|
916
|
+
(0, import_react13.useEffect)(() => {
|
|
676
917
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
677
918
|
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
678
919
|
}, []);
|
|
920
|
+
if (props.h1) {
|
|
921
|
+
if (typeof props.h1 === "boolean")
|
|
922
|
+
return /* @__PURE__ */ import_react.default.createElement("h1", null, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
923
|
+
return /* @__PURE__ */ import_react.default.createElement("h1", {
|
|
924
|
+
className: props.h1.className,
|
|
925
|
+
style: props.h1.style
|
|
926
|
+
}, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
927
|
+
}
|
|
679
928
|
return null;
|
|
680
929
|
}
|
|
681
930
|
module.exports = __toCommonJS(src_exports);
|
|
682
931
|
// Annotate the CommonJS export names for ESM import in node:
|
|
683
932
|
0 && (module.exports = {
|
|
684
933
|
Blank,
|
|
934
|
+
Calendar,
|
|
685
935
|
Config,
|
|
936
|
+
DatePicker,
|
|
686
937
|
Description,
|
|
687
938
|
Drawer,
|
|
688
939
|
Form,
|
|
@@ -690,6 +941,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
690
941
|
Modal,
|
|
691
942
|
Routes,
|
|
692
943
|
Table,
|
|
944
|
+
TimePicker,
|
|
693
945
|
Title,
|
|
694
946
|
transferOptions,
|
|
695
947
|
useDrawer,
|
package/dist/index.mjs
CHANGED
|
@@ -65,6 +65,181 @@ function Blank(options) {
|
|
|
65
65
|
}, (options == null ? void 0 : options.text) || config.Blank.text) : options.value;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// ../../node_modules/rc-picker/es/generate/dayjs.js
|
|
69
|
+
import dayjs from "dayjs";
|
|
70
|
+
|
|
71
|
+
// ../../node_modules/rc-util/es/warning.js
|
|
72
|
+
var warned = {};
|
|
73
|
+
function note(valid, message) {
|
|
74
|
+
if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
|
|
75
|
+
console.warn("Note: ".concat(message));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function call(method, valid, message) {
|
|
79
|
+
if (!valid && !warned[message]) {
|
|
80
|
+
method(false, message);
|
|
81
|
+
warned[message] = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function noteOnce(valid, message) {
|
|
85
|
+
call(note, valid, message);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ../../node_modules/rc-picker/es/generate/dayjs.js
|
|
89
|
+
import weekday from "dayjs/plugin/weekday";
|
|
90
|
+
import localeData from "dayjs/plugin/localeData";
|
|
91
|
+
import weekOfYear from "dayjs/plugin/weekOfYear";
|
|
92
|
+
import weekYear from "dayjs/plugin/weekYear";
|
|
93
|
+
import advancedFormat from "dayjs/plugin/advancedFormat";
|
|
94
|
+
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
95
|
+
dayjs.extend(customParseFormat);
|
|
96
|
+
dayjs.extend(advancedFormat);
|
|
97
|
+
dayjs.extend(weekday);
|
|
98
|
+
dayjs.extend(localeData);
|
|
99
|
+
dayjs.extend(weekOfYear);
|
|
100
|
+
dayjs.extend(weekYear);
|
|
101
|
+
dayjs.extend(function(o, c) {
|
|
102
|
+
var proto = c.prototype;
|
|
103
|
+
var oldFormat = proto.format;
|
|
104
|
+
proto.format = function f(formatStr) {
|
|
105
|
+
var str = (formatStr || "").replace("Wo", "wo");
|
|
106
|
+
return oldFormat.bind(this)(str);
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
var localeMap = {
|
|
110
|
+
en_GB: "en-gb",
|
|
111
|
+
en_US: "en",
|
|
112
|
+
zh_CN: "zh-cn",
|
|
113
|
+
zh_TW: "zh-tw"
|
|
114
|
+
};
|
|
115
|
+
var parseLocale = function parseLocale2(locale) {
|
|
116
|
+
var mapLocale = localeMap[locale];
|
|
117
|
+
return mapLocale || locale.split("_")[0];
|
|
118
|
+
};
|
|
119
|
+
var parseNoMatchNotice = function parseNoMatchNotice2() {
|
|
120
|
+
noteOnce(false, "Not match any format. Please help to fire a issue about this.");
|
|
121
|
+
};
|
|
122
|
+
var generateConfig = {
|
|
123
|
+
getNow: function getNow() {
|
|
124
|
+
return dayjs();
|
|
125
|
+
},
|
|
126
|
+
getFixedDate: function getFixedDate(string) {
|
|
127
|
+
return dayjs(string, "YYYY-MM-DD");
|
|
128
|
+
},
|
|
129
|
+
getEndDate: function getEndDate(date) {
|
|
130
|
+
return date.endOf("month");
|
|
131
|
+
},
|
|
132
|
+
getWeekDay: function getWeekDay(date) {
|
|
133
|
+
var clone = date.locale("en");
|
|
134
|
+
return clone.weekday() + clone.localeData().firstDayOfWeek();
|
|
135
|
+
},
|
|
136
|
+
getYear: function getYear(date) {
|
|
137
|
+
return date.year();
|
|
138
|
+
},
|
|
139
|
+
getMonth: function getMonth(date) {
|
|
140
|
+
return date.month();
|
|
141
|
+
},
|
|
142
|
+
getDate: function getDate(date) {
|
|
143
|
+
return date.date();
|
|
144
|
+
},
|
|
145
|
+
getHour: function getHour(date) {
|
|
146
|
+
return date.hour();
|
|
147
|
+
},
|
|
148
|
+
getMinute: function getMinute(date) {
|
|
149
|
+
return date.minute();
|
|
150
|
+
},
|
|
151
|
+
getSecond: function getSecond(date) {
|
|
152
|
+
return date.second();
|
|
153
|
+
},
|
|
154
|
+
addYear: function addYear(date, diff) {
|
|
155
|
+
return date.add(diff, "year");
|
|
156
|
+
},
|
|
157
|
+
addMonth: function addMonth(date, diff) {
|
|
158
|
+
return date.add(diff, "month");
|
|
159
|
+
},
|
|
160
|
+
addDate: function addDate(date, diff) {
|
|
161
|
+
return date.add(diff, "day");
|
|
162
|
+
},
|
|
163
|
+
setYear: function setYear(date, year) {
|
|
164
|
+
return date.year(year);
|
|
165
|
+
},
|
|
166
|
+
setMonth: function setMonth(date, month) {
|
|
167
|
+
return date.month(month);
|
|
168
|
+
},
|
|
169
|
+
setDate: function setDate(date, num) {
|
|
170
|
+
return date.date(num);
|
|
171
|
+
},
|
|
172
|
+
setHour: function setHour(date, hour) {
|
|
173
|
+
return date.hour(hour);
|
|
174
|
+
},
|
|
175
|
+
setMinute: function setMinute(date, minute) {
|
|
176
|
+
return date.minute(minute);
|
|
177
|
+
},
|
|
178
|
+
setSecond: function setSecond(date, second) {
|
|
179
|
+
return date.second(second);
|
|
180
|
+
},
|
|
181
|
+
isAfter: function isAfter(date1, date2) {
|
|
182
|
+
return date1.isAfter(date2);
|
|
183
|
+
},
|
|
184
|
+
isValidate: function isValidate(date) {
|
|
185
|
+
return date.isValid();
|
|
186
|
+
},
|
|
187
|
+
locale: {
|
|
188
|
+
getWeekFirstDay: function getWeekFirstDay(locale) {
|
|
189
|
+
return dayjs().locale(parseLocale(locale)).localeData().firstDayOfWeek();
|
|
190
|
+
},
|
|
191
|
+
getWeekFirstDate: function getWeekFirstDate(locale, date) {
|
|
192
|
+
return date.locale(parseLocale(locale)).weekday(0);
|
|
193
|
+
},
|
|
194
|
+
getWeek: function getWeek(locale, date) {
|
|
195
|
+
return date.locale(parseLocale(locale)).week();
|
|
196
|
+
},
|
|
197
|
+
getShortWeekDays: function getShortWeekDays(locale) {
|
|
198
|
+
return dayjs().locale(parseLocale(locale)).localeData().weekdaysMin();
|
|
199
|
+
},
|
|
200
|
+
getShortMonths: function getShortMonths(locale) {
|
|
201
|
+
return dayjs().locale(parseLocale(locale)).localeData().monthsShort();
|
|
202
|
+
},
|
|
203
|
+
format: function format(locale, date, _format) {
|
|
204
|
+
return date.locale(parseLocale(locale)).format(_format);
|
|
205
|
+
},
|
|
206
|
+
parse: function parse(locale, text, formats) {
|
|
207
|
+
var localeStr = parseLocale(locale);
|
|
208
|
+
for (var i = 0; i < formats.length; i += 1) {
|
|
209
|
+
var format2 = formats[i];
|
|
210
|
+
var formatText = text;
|
|
211
|
+
if (format2.includes("wo") || format2.includes("Wo")) {
|
|
212
|
+
var year = formatText.split("-")[0];
|
|
213
|
+
var weekStr = formatText.split("-")[1];
|
|
214
|
+
var firstWeek = dayjs(year, "YYYY").startOf("year").locale(localeStr);
|
|
215
|
+
for (var j = 0; j <= 52; j += 1) {
|
|
216
|
+
var nextWeek = firstWeek.add(j, "week");
|
|
217
|
+
if (nextWeek.format("Wo") === weekStr) {
|
|
218
|
+
return nextWeek;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
parseNoMatchNotice();
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
var date = dayjs(formatText, format2).locale(localeStr);
|
|
225
|
+
if (date.isValid()) {
|
|
226
|
+
return date;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (text) {
|
|
230
|
+
parseNoMatchNotice();
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
var dayjs_default = generateConfig;
|
|
237
|
+
|
|
238
|
+
// src/Calendar.tsx
|
|
239
|
+
import generateCalendar from "antd/es/calendar/generateCalendar";
|
|
240
|
+
import "antd/es/calendar/style";
|
|
241
|
+
var Calendar = generateCalendar(dayjs_default);
|
|
242
|
+
|
|
68
243
|
// src/data.ts
|
|
69
244
|
import { upperFirst } from "lodash";
|
|
70
245
|
function transferOptions(options) {
|
|
@@ -76,6 +251,11 @@ function transferOptions(options) {
|
|
|
76
251
|
});
|
|
77
252
|
}
|
|
78
253
|
|
|
254
|
+
// src/DatePicker.tsx
|
|
255
|
+
import generatePicker from "antd/es/date-picker/generatePicker";
|
|
256
|
+
import "antd/es/date-picker/style";
|
|
257
|
+
var DatePicker = generatePicker(dayjs_default);
|
|
258
|
+
|
|
79
259
|
// src/Description.tsx
|
|
80
260
|
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
|
|
81
261
|
import {
|
|
@@ -88,6 +268,7 @@ import {
|
|
|
88
268
|
useEffect as useEffect2,
|
|
89
269
|
useState
|
|
90
270
|
} from "react";
|
|
271
|
+
import dayjs2 from "dayjs";
|
|
91
272
|
import { FaasDataWrapper } from "@faasjs/react";
|
|
92
273
|
function DescriptionItemContent(props) {
|
|
93
274
|
const [computedProps, setComputedProps] = useState();
|
|
@@ -107,7 +288,11 @@ function DescriptionItemContent(props) {
|
|
|
107
288
|
var _a2;
|
|
108
289
|
return ((_a2 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
109
290
|
});
|
|
110
|
-
else
|
|
291
|
+
else if ([
|
|
292
|
+
"string",
|
|
293
|
+
"number",
|
|
294
|
+
"boolean"
|
|
295
|
+
].includes(propsCopy.item.type))
|
|
111
296
|
propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
|
|
112
297
|
}
|
|
113
298
|
setComputedProps(propsCopy);
|
|
@@ -149,6 +334,10 @@ function DescriptionItemContent(props) {
|
|
|
149
334
|
color: "#ff4d4f"
|
|
150
335
|
}
|
|
151
336
|
});
|
|
337
|
+
case "time":
|
|
338
|
+
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? dayjs2.unix(computedProps.value).format("YYYY-MM-DD HH:mm:ss") : dayjs2(computedProps.value).format("YYYY-MM-DD HH:mm:ss");
|
|
339
|
+
case "date":
|
|
340
|
+
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? dayjs2.unix(computedProps.value).format("YYYY-MM-DD") : dayjs2(computedProps.value).format("YYYY-MM-DD");
|
|
152
341
|
default:
|
|
153
342
|
return computedProps.value;
|
|
154
343
|
}
|
|
@@ -220,6 +409,19 @@ import {
|
|
|
220
409
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
221
410
|
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
222
411
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
412
|
+
|
|
413
|
+
// src/TimePicker.tsx
|
|
414
|
+
import { forwardRef } from "react";
|
|
415
|
+
var TimePicker = forwardRef((props, ref) => {
|
|
416
|
+
return /* @__PURE__ */ React.createElement(DatePicker, __spreadProps(__spreadValues({}, props), {
|
|
417
|
+
picker: "time",
|
|
418
|
+
mode: void 0,
|
|
419
|
+
ref
|
|
420
|
+
}));
|
|
421
|
+
});
|
|
422
|
+
TimePicker.displayName = "TimePicker";
|
|
423
|
+
|
|
424
|
+
// src/FormItem.tsx
|
|
223
425
|
function FormItem(props) {
|
|
224
426
|
const [computedProps, setComputedProps] = useState3();
|
|
225
427
|
useEffect3(() => {
|
|
@@ -365,6 +567,10 @@ function FormItem(props) {
|
|
|
365
567
|
});
|
|
366
568
|
case "boolean":
|
|
367
569
|
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), /* @__PURE__ */ React.createElement(Switch, __spreadValues({}, computedProps.input)));
|
|
570
|
+
case "date":
|
|
571
|
+
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), /* @__PURE__ */ React.createElement(DatePicker, __spreadValues({}, computedProps.input)));
|
|
572
|
+
case "time":
|
|
573
|
+
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), /* @__PURE__ */ React.createElement(TimePicker, __spreadValues({}, computedProps.input)));
|
|
368
574
|
default:
|
|
369
575
|
return null;
|
|
370
576
|
}
|
|
@@ -410,10 +616,15 @@ Form.Item = FormItem;
|
|
|
410
616
|
import { Modal } from "antd";
|
|
411
617
|
import { useState as useState5 } from "react";
|
|
412
618
|
function useModal(init) {
|
|
413
|
-
const [props, setProps] = useState5(
|
|
619
|
+
const [props, setProps] = useState5(__spreadValues({
|
|
620
|
+
visible: false,
|
|
621
|
+
onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
622
|
+
visible: false
|
|
623
|
+
}))
|
|
624
|
+
}, init));
|
|
414
625
|
return {
|
|
415
|
-
|
|
416
|
-
|
|
626
|
+
modal: /* @__PURE__ */ React.createElement(Modal, __spreadValues({}, props)),
|
|
627
|
+
modalProps: props,
|
|
417
628
|
setModalProps(changes) {
|
|
418
629
|
setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
|
|
419
630
|
}
|
|
@@ -465,19 +676,36 @@ import {
|
|
|
465
676
|
Radio,
|
|
466
677
|
Skeleton as Skeleton3
|
|
467
678
|
} from "antd";
|
|
679
|
+
import dayjs3 from "dayjs";
|
|
468
680
|
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
469
681
|
import { isNil as isNil2, upperFirst as upperFirst4 } from "lodash";
|
|
470
682
|
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
471
683
|
function processValue(item, value) {
|
|
472
684
|
var _a;
|
|
473
|
-
if (
|
|
474
|
-
if (item.
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
685
|
+
if (typeof value !== "undefined" && value !== null) {
|
|
686
|
+
if (item.options) {
|
|
687
|
+
if (item.type.endsWith("[]"))
|
|
688
|
+
return value.map((v) => {
|
|
689
|
+
var _a2;
|
|
690
|
+
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
691
|
+
});
|
|
692
|
+
else if ([
|
|
693
|
+
"string",
|
|
694
|
+
"number",
|
|
695
|
+
"boolean"
|
|
696
|
+
].includes(item.type))
|
|
697
|
+
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
698
|
+
}
|
|
699
|
+
let dayjsFormat = "";
|
|
700
|
+
if (item.type === "date")
|
|
701
|
+
dayjsFormat = "YYYY-MM-DD";
|
|
702
|
+
else if (item.type === "time")
|
|
703
|
+
dayjsFormat = "YYYY-MM-DD HH:mm:ss";
|
|
704
|
+
if (["date", "time"].includes(item.type)) {
|
|
705
|
+
if (typeof value === "number" && value.toString().length === 10)
|
|
706
|
+
value = value * 1e3;
|
|
707
|
+
value = dayjs3(value).format(dayjsFormat);
|
|
708
|
+
}
|
|
481
709
|
}
|
|
482
710
|
return value;
|
|
483
711
|
}
|
|
@@ -592,6 +820,16 @@ function Table(props) {
|
|
|
592
820
|
}
|
|
593
821
|
};
|
|
594
822
|
break;
|
|
823
|
+
case "date":
|
|
824
|
+
item.render = (value) => processValue(item, value);
|
|
825
|
+
if (!item.onFilter)
|
|
826
|
+
item.onFilter = (value, row) => dayjs3(row[item.id]).isSame(dayjs3(value));
|
|
827
|
+
break;
|
|
828
|
+
case "time":
|
|
829
|
+
item.render = (value) => processValue(item, value);
|
|
830
|
+
if (!item.onFilter)
|
|
831
|
+
item.onFilter = (value, row) => dayjs3(row[item.id]).isSame(dayjs3(value));
|
|
832
|
+
break;
|
|
595
833
|
default:
|
|
596
834
|
item.render = (value) => processValue(item, value);
|
|
597
835
|
if (!item.onFilter)
|
|
@@ -664,11 +902,21 @@ function Title(props) {
|
|
|
664
902
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
665
903
|
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
666
904
|
}, []);
|
|
905
|
+
if (props.h1) {
|
|
906
|
+
if (typeof props.h1 === "boolean")
|
|
907
|
+
return /* @__PURE__ */ React.createElement("h1", null, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
908
|
+
return /* @__PURE__ */ React.createElement("h1", {
|
|
909
|
+
className: props.h1.className,
|
|
910
|
+
style: props.h1.style
|
|
911
|
+
}, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
912
|
+
}
|
|
667
913
|
return null;
|
|
668
914
|
}
|
|
669
915
|
export {
|
|
670
916
|
Blank,
|
|
917
|
+
Calendar,
|
|
671
918
|
Config,
|
|
919
|
+
DatePicker,
|
|
672
920
|
Description,
|
|
673
921
|
Drawer,
|
|
674
922
|
Form,
|
|
@@ -676,6 +924,7 @@ export {
|
|
|
676
924
|
Modal,
|
|
677
925
|
Routes,
|
|
678
926
|
Table,
|
|
927
|
+
TimePicker,
|
|
679
928
|
Title,
|
|
680
929
|
transferOptions,
|
|
681
930
|
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.371",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -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.371",
|
|
32
32
|
"react-use": "*",
|
|
33
|
-
"react-router-dom": "*"
|
|
33
|
+
"react-router-dom": "*",
|
|
34
|
+
"dayjs": "*"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/lodash": "*",
|