@faasjs/ant-design 0.0.2-beta.368 → 0.0.2-beta.372

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 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 |
package/dist/index.d.ts CHANGED
@@ -1,9 +1,15 @@
1
- import * as react_use_lib_misc_hookState from 'react-use/lib/misc/hookState';
2
- import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, FormProps as FormProps$1, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1 } from 'antd';
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,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,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");
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 import_react7 = require("react");
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 import_react6 = require("react");
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, import_react6.useState)();
250
- (0, import_react6.useEffect)(() => {
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, import_react7.useState)(false);
402
- const [computedProps, setComputedProps] = (0, import_react7.useState)();
442
+ const [loading, setLoading] = (0, import_react8.useState)(false);
443
+ const [computedProps, setComputedProps] = (0, import_react8.useState)();
403
444
  const [config] = useFaasState();
404
- (0, import_react7.useEffect)(() => {
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,14 @@ Form.Item = FormItem;
433
474
 
434
475
  // src/Modal.tsx
435
476
  var import_antd6 = require("antd");
436
- var import_react8 = require("react");
477
+ var import_react9 = require("react");
437
478
  function useModal(init) {
438
- const [props, setProps] = (0, import_react8.useState)(init);
479
+ const [props, setProps] = (0, import_react9.useState)(__spreadValues({
480
+ visible: false,
481
+ onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
482
+ visible: false
483
+ }))
484
+ }, init));
439
485
  return {
440
486
  modal: /* @__PURE__ */ import_react.default.createElement(import_antd6.Modal, __spreadValues({}, props)),
441
487
  modalProps: props,
@@ -447,7 +493,7 @@ function useModal(init) {
447
493
 
448
494
  // src/Routers.tsx
449
495
  var import_antd7 = require("antd");
450
- var import_react9 = require("react");
496
+ var import_react10 = require("react");
451
497
  var import_react_router_dom = require("react-router-dom");
452
498
  function NotFound() {
453
499
  const [config] = useFaasState();
@@ -460,7 +506,7 @@ function Routes(props) {
460
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({
461
507
  key: r.path
462
508
  }, r), {
463
- element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react9.Suspense, {
509
+ element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react10.Suspense, {
464
510
  fallback: props.fallback || /* @__PURE__ */ import_react.default.createElement("div", {
465
511
  style: { padding: "24px" }
466
512
  }, /* @__PURE__ */ import_react.default.createElement(import_antd7.Skeleton, {
@@ -475,28 +521,45 @@ function Routes(props) {
475
521
  }
476
522
 
477
523
  // src/Table.tsx
478
- var import_react10 = require("react");
524
+ var import_react11 = require("react");
479
525
  var import_antd8 = require("antd");
526
+ var import_dayjs4 = __toESM(require("dayjs"));
480
527
  var import_icons3 = require("@ant-design/icons");
481
528
  var import_lodash5 = require("lodash");
482
- var import_react11 = require("@faasjs/react");
529
+ var import_react12 = require("@faasjs/react");
483
530
  function processValue(item, value) {
484
531
  var _a;
485
- if (item.options && typeof value !== "undefined" && value !== null) {
486
- if (item.type.endsWith("[]"))
487
- return value.map((v) => {
488
- var _a2;
489
- return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
490
- });
491
- else
492
- return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
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
+ }
493
556
  }
494
557
  return value;
495
558
  }
496
559
  function Table(props) {
497
- const [columns, setColumns] = (0, import_react10.useState)();
560
+ const [columns, setColumns] = (0, import_react11.useState)();
498
561
  const [config] = useFaasState();
499
- (0, import_react10.useEffect)(() => {
562
+ (0, import_react11.useEffect)(() => {
500
563
  var _a;
501
564
  for (const item of props.items) {
502
565
  if (!item.key)
@@ -520,7 +583,7 @@ function Table(props) {
520
583
  delete item.children;
521
584
  if (props.extendTypes && props.extendTypes[item.type]) {
522
585
  if (props.extendTypes[item.type].children) {
523
- item.render = (value, values) => (0, import_react10.cloneElement)(props.extendTypes[item.type].children, {
586
+ item.render = (value, values) => (0, import_react11.cloneElement)(props.extendTypes[item.type].children, {
524
587
  value,
525
588
  values
526
589
  });
@@ -604,6 +667,16 @@ function Table(props) {
604
667
  }
605
668
  };
606
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;
607
680
  default:
608
681
  item.render = (value) => processValue(item, value);
609
682
  if (!item.onFilter)
@@ -621,7 +694,7 @@ function Table(props) {
621
694
  columns,
622
695
  dataSource: props.dataSource
623
696
  }));
624
- return /* @__PURE__ */ import_react.default.createElement(import_react11.FaasDataWrapper, __spreadValues({
697
+ return /* @__PURE__ */ import_react.default.createElement(import_react12.FaasDataWrapper, __spreadValues({
625
698
  fallback: props.faasData.fallback || /* @__PURE__ */ import_react.default.createElement(import_antd8.Skeleton, {
626
699
  active: true
627
700
  }),
@@ -669,20 +742,30 @@ function Table(props) {
669
742
  }
670
743
 
671
744
  // src/Title.tsx
672
- var import_react12 = require("react");
745
+ var import_react13 = require("react");
673
746
  function Title(props) {
674
747
  const [config] = useFaasState();
675
- (0, import_react12.useEffect)(() => {
748
+ (0, import_react13.useEffect)(() => {
676
749
  const title = Array.isArray(props.title) ? props.title : [props.title];
677
750
  document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
678
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
+ }
679
760
  return null;
680
761
  }
681
762
  module.exports = __toCommonJS(src_exports);
682
763
  // Annotate the CommonJS export names for ESM import in node:
683
764
  0 && (module.exports = {
684
765
  Blank,
766
+ Calendar,
685
767
  Config,
768
+ DatePicker,
686
769
  Description,
687
770
  Drawer,
688
771
  Form,
@@ -690,6 +773,7 @@ module.exports = __toCommonJS(src_exports);
690
773
  Modal,
691
774
  Routes,
692
775
  Table,
776
+ TimePicker,
693
777
  Title,
694
778
  transferOptions,
695
779
  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";
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
  }
@@ -410,7 +448,12 @@ Form.Item = FormItem;
410
448
  import { Modal } from "antd";
411
449
  import { useState as useState5 } from "react";
412
450
  function useModal(init) {
413
- const [props, setProps] = useState5(init);
451
+ const [props, setProps] = useState5(__spreadValues({
452
+ visible: false,
453
+ onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
454
+ visible: false
455
+ }))
456
+ }, init));
414
457
  return {
415
458
  modal: /* @__PURE__ */ React.createElement(Modal, __spreadValues({}, props)),
416
459
  modalProps: props,
@@ -465,19 +508,36 @@ import {
465
508
  Radio,
466
509
  Skeleton as Skeleton3
467
510
  } from "antd";
511
+ import dayjs2 from "dayjs";
468
512
  import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
469
513
  import { isNil as isNil2, upperFirst as upperFirst4 } from "lodash";
470
514
  import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
471
515
  function processValue(item, value) {
472
516
  var _a;
473
- if (item.options && typeof value !== "undefined" && value !== null) {
474
- if (item.type.endsWith("[]"))
475
- return value.map((v) => {
476
- var _a2;
477
- return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
478
- });
479
- else
480
- return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
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
+ }
481
541
  }
482
542
  return value;
483
543
  }
@@ -592,6 +652,16 @@ function Table(props) {
592
652
  }
593
653
  };
594
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;
595
665
  default:
596
666
  item.render = (value) => processValue(item, value);
597
667
  if (!item.onFilter)
@@ -664,11 +734,21 @@ function Title(props) {
664
734
  const title = Array.isArray(props.title) ? props.title : [props.title];
665
735
  document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
666
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
+ }
667
745
  return null;
668
746
  }
669
747
  export {
670
748
  Blank,
749
+ Calendar,
671
750
  Config,
751
+ DatePicker,
672
752
  Description,
673
753
  Drawer,
674
754
  Form,
@@ -676,6 +756,7 @@ export {
676
756
  Modal,
677
757
  Routes,
678
758
  Table,
759
+ TimePicker,
679
760
  Title,
680
761
  transferOptions,
681
762
  useDrawer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.2-beta.368",
3
+ "version": "0.0.2-beta.372",
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.368",
31
+ "@faasjs/react": "^0.0.2-beta.372",
32
32
  "react-use": "*",
33
- "react-router-dom": "*"
33
+ "react-router-dom": "*",
34
+ "dayjs": "*"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@types/lodash": "*",