@faasjs/ant-design 0.0.2-beta.403 → 0.0.2-beta.406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -7
- package/dist/index.js +42 -10
- package/dist/index.mjs +42 -10
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -222,15 +222,16 @@ declare type FormItemInputProps = StringProps | StringListProps | NumberProps |
|
|
|
222
222
|
declare type ExtendFormTypeProps = {
|
|
223
223
|
children?: JSX.Element | null;
|
|
224
224
|
};
|
|
225
|
+
declare type ExtendTypes = {
|
|
226
|
+
[type: string]: ExtendFormTypeProps;
|
|
227
|
+
};
|
|
225
228
|
declare type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
226
229
|
declare type FormItemProps<T = any> = {
|
|
227
230
|
children?: JSX.Element | null;
|
|
228
231
|
render?: () => JSX.Element | null;
|
|
229
232
|
rules?: RuleObject[];
|
|
230
233
|
label?: string | false;
|
|
231
|
-
extendTypes?:
|
|
232
|
-
[type: string]: ExtendFormTypeProps;
|
|
233
|
-
};
|
|
234
|
+
extendTypes?: ExtendTypes;
|
|
234
235
|
} & FormItemInputProps & FaasItemProps & Omit<FormItemProps$1<T>, 'children'>;
|
|
235
236
|
/**
|
|
236
237
|
* FormItem, can be used without Form.
|
|
@@ -287,9 +288,7 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
|
287
288
|
onFinish?: (values: Values, submit?: (values: any) => Promise<any>) => Promise<any>;
|
|
288
289
|
beforeItems?: JSX.Element | JSX.Element[];
|
|
289
290
|
footer?: JSX.Element | JSX.Element[];
|
|
290
|
-
extendTypes?:
|
|
291
|
-
[type: string]: ExtendFormTypeProps;
|
|
292
|
-
};
|
|
291
|
+
extendTypes?: ExtendTypes;
|
|
293
292
|
children?: ReactNode;
|
|
294
293
|
} & Omit<FormProps$1<Values>, 'onFinish' | 'children'>;
|
|
295
294
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
@@ -390,4 +389,4 @@ declare type TitleProps = {
|
|
|
390
389
|
*/
|
|
391
390
|
declare function Title(props: TitleProps): JSX.Element;
|
|
392
391
|
|
|
393
|
-
export { BaseItemProps, BaseOption, Blank, BlankProps, Calendar, CalendarProps, ConfigContext, ConfigProvider, 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, useConfigContext, useDrawer, useModal };
|
|
392
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, Calendar, CalendarProps, ConfigContext, ConfigProvider, DatePicker, DatePickerProps, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, FaasItemProps, FaasItemType, FaasItemTypeValue, FaasState, Form, FormItem, FormItemProps, FormProps, ModalProps, Routes, RoutesProps, Table, TableItemProps, TableProps, TimePicker, TimePickerProps, Title, TitleProps, setDrawerProps, setModalProps, transferOptions, useConfigContext, useDrawer, useModal };
|
package/dist/index.js
CHANGED
|
@@ -318,6 +318,7 @@ var TimePicker = (0, import_react6.forwardRef)((props, ref) => {
|
|
|
318
318
|
TimePicker.displayName = "TimePicker";
|
|
319
319
|
|
|
320
320
|
// src/FormItem.tsx
|
|
321
|
+
var import_dayjs4 = __toESM(require("dayjs"));
|
|
321
322
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
322
323
|
function processProps(propsCopy, config) {
|
|
323
324
|
if (!propsCopy.title)
|
|
@@ -365,19 +366,45 @@ function processProps(propsCopy, config) {
|
|
|
365
366
|
}
|
|
366
367
|
return propsCopy;
|
|
367
368
|
}
|
|
369
|
+
function DateItem(options) {
|
|
370
|
+
const [value, setValue] = (0, import_react7.useState)();
|
|
371
|
+
(0, import_react7.useEffect)(() => {
|
|
372
|
+
setValue(options.value && !(0, import_dayjs4.isDayjs)(options.value) ? (0, import_dayjs4.default)(options.value) : null);
|
|
373
|
+
}, [options.value]);
|
|
374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DatePicker, {
|
|
375
|
+
...options,
|
|
376
|
+
value
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
function TimeItem(options) {
|
|
380
|
+
const [value, setValue] = (0, import_react7.useState)();
|
|
381
|
+
(0, import_react7.useEffect)(() => {
|
|
382
|
+
setValue(options.value && !(0, import_dayjs4.isDayjs)(options.value) ? (0, import_dayjs4.default)(options.value) : null);
|
|
383
|
+
}, [options.value]);
|
|
384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimePicker, {
|
|
385
|
+
...options,
|
|
386
|
+
value
|
|
387
|
+
});
|
|
388
|
+
}
|
|
368
389
|
function FormItem(props) {
|
|
369
390
|
var _a;
|
|
370
391
|
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
392
|
+
const [extendTypes, setExtendTypes] = (0, import_react7.useState)();
|
|
371
393
|
const config = useConfigContext();
|
|
372
394
|
(0, import_react7.useEffect)(() => {
|
|
373
|
-
|
|
395
|
+
const propsCopy = { ...props };
|
|
396
|
+
if (propsCopy.extendTypes) {
|
|
397
|
+
setExtendTypes(propsCopy.extendTypes);
|
|
398
|
+
delete propsCopy.extendTypes;
|
|
399
|
+
}
|
|
400
|
+
setComputedProps(processProps(propsCopy, config));
|
|
374
401
|
}, [props]);
|
|
375
402
|
if (!computedProps)
|
|
376
403
|
return null;
|
|
377
|
-
if (
|
|
404
|
+
if (extendTypes && extendTypes[computedProps.type])
|
|
378
405
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
379
406
|
...computedProps,
|
|
380
|
-
children:
|
|
407
|
+
children: extendTypes[computedProps.type].children
|
|
381
408
|
});
|
|
382
409
|
if (computedProps.children)
|
|
383
410
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
@@ -562,14 +589,14 @@ function FormItem(props) {
|
|
|
562
589
|
case "date":
|
|
563
590
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
564
591
|
...computedProps,
|
|
565
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
592
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateItem, {
|
|
566
593
|
...computedProps.input
|
|
567
594
|
})
|
|
568
595
|
});
|
|
569
596
|
case "time":
|
|
570
597
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
571
598
|
...computedProps,
|
|
572
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
599
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimeItem, {
|
|
573
600
|
...computedProps.input
|
|
574
601
|
})
|
|
575
602
|
});
|
|
@@ -658,6 +685,7 @@ function Form(props) {
|
|
|
658
685
|
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
659
686
|
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
660
687
|
const config = useConfigContext();
|
|
688
|
+
const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
|
|
661
689
|
(0, import_react9.useEffect)(() => {
|
|
662
690
|
var _a2;
|
|
663
691
|
const propsCopy = { ...props };
|
|
@@ -686,6 +714,10 @@ function Form(props) {
|
|
|
686
714
|
} : values);
|
|
687
715
|
};
|
|
688
716
|
}
|
|
717
|
+
if (propsCopy.extendTypes) {
|
|
718
|
+
setExtendTypes(propsCopy.extendTypes);
|
|
719
|
+
delete propsCopy.extendTypes;
|
|
720
|
+
}
|
|
689
721
|
setComputedProps(propsCopy);
|
|
690
722
|
}, []);
|
|
691
723
|
if (!computedProps)
|
|
@@ -696,7 +728,7 @@ function Form(props) {
|
|
|
696
728
|
computedProps.beforeItems,
|
|
697
729
|
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
698
730
|
...item,
|
|
699
|
-
extendTypes
|
|
731
|
+
extendTypes
|
|
700
732
|
}, item.id)),
|
|
701
733
|
computedProps.children,
|
|
702
734
|
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Button, {
|
|
@@ -777,7 +809,7 @@ function Routes(props) {
|
|
|
777
809
|
// src/Table.tsx
|
|
778
810
|
var import_react12 = require("react");
|
|
779
811
|
var import_antd8 = require("antd");
|
|
780
|
-
var
|
|
812
|
+
var import_dayjs5 = __toESM(require("dayjs"));
|
|
781
813
|
var import_icons3 = require("@ant-design/icons");
|
|
782
814
|
var import_lodash5 = require("lodash");
|
|
783
815
|
var import_react13 = require("@faasjs/react");
|
|
@@ -806,7 +838,7 @@ function processValue(item, value) {
|
|
|
806
838
|
if (["date", "time"].includes(item.type)) {
|
|
807
839
|
if (typeof value === "number" && value.toString().length === 10)
|
|
808
840
|
value = value * 1e3;
|
|
809
|
-
value = (0,
|
|
841
|
+
value = (0, import_dayjs5.default)(value).format(dayjsFormat);
|
|
810
842
|
}
|
|
811
843
|
}
|
|
812
844
|
return value;
|
|
@@ -939,12 +971,12 @@ function Table(props) {
|
|
|
939
971
|
case "date":
|
|
940
972
|
item.render = (value) => processValue(item, value);
|
|
941
973
|
if (!item.onFilter)
|
|
942
|
-
item.onFilter = (value, row) => (0,
|
|
974
|
+
item.onFilter = (value, row) => (0, import_dayjs5.default)(row[item.id]).isSame((0, import_dayjs5.default)(value));
|
|
943
975
|
break;
|
|
944
976
|
case "time":
|
|
945
977
|
item.render = (value) => processValue(item, value);
|
|
946
978
|
if (!item.onFilter)
|
|
947
|
-
item.onFilter = (value, row) => (0,
|
|
979
|
+
item.onFilter = (value, row) => (0, import_dayjs5.default)(row[item.id]).isSame((0, import_dayjs5.default)(value));
|
|
948
980
|
break;
|
|
949
981
|
default:
|
|
950
982
|
item.render = (value) => processValue(item, value);
|
package/dist/index.mjs
CHANGED
|
@@ -291,6 +291,7 @@ var TimePicker = forwardRef((props, ref) => {
|
|
|
291
291
|
TimePicker.displayName = "TimePicker";
|
|
292
292
|
|
|
293
293
|
// src/FormItem.tsx
|
|
294
|
+
import dayjs2, { isDayjs } from "dayjs";
|
|
294
295
|
import { Fragment as Fragment2, jsx as jsx6, jsxs } from "react/jsx-runtime";
|
|
295
296
|
function processProps(propsCopy, config) {
|
|
296
297
|
if (!propsCopy.title)
|
|
@@ -338,19 +339,45 @@ function processProps(propsCopy, config) {
|
|
|
338
339
|
}
|
|
339
340
|
return propsCopy;
|
|
340
341
|
}
|
|
342
|
+
function DateItem(options) {
|
|
343
|
+
const [value, setValue] = useState3();
|
|
344
|
+
useEffect2(() => {
|
|
345
|
+
setValue(options.value && !isDayjs(options.value) ? dayjs2(options.value) : null);
|
|
346
|
+
}, [options.value]);
|
|
347
|
+
return /* @__PURE__ */ jsx6(DatePicker, {
|
|
348
|
+
...options,
|
|
349
|
+
value
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function TimeItem(options) {
|
|
353
|
+
const [value, setValue] = useState3();
|
|
354
|
+
useEffect2(() => {
|
|
355
|
+
setValue(options.value && !isDayjs(options.value) ? dayjs2(options.value) : null);
|
|
356
|
+
}, [options.value]);
|
|
357
|
+
return /* @__PURE__ */ jsx6(TimePicker, {
|
|
358
|
+
...options,
|
|
359
|
+
value
|
|
360
|
+
});
|
|
361
|
+
}
|
|
341
362
|
function FormItem(props) {
|
|
342
363
|
var _a;
|
|
343
364
|
const [computedProps, setComputedProps] = useState3();
|
|
365
|
+
const [extendTypes, setExtendTypes] = useState3();
|
|
344
366
|
const config = useConfigContext();
|
|
345
367
|
useEffect2(() => {
|
|
346
|
-
|
|
368
|
+
const propsCopy = { ...props };
|
|
369
|
+
if (propsCopy.extendTypes) {
|
|
370
|
+
setExtendTypes(propsCopy.extendTypes);
|
|
371
|
+
delete propsCopy.extendTypes;
|
|
372
|
+
}
|
|
373
|
+
setComputedProps(processProps(propsCopy, config));
|
|
347
374
|
}, [props]);
|
|
348
375
|
if (!computedProps)
|
|
349
376
|
return null;
|
|
350
|
-
if (
|
|
377
|
+
if (extendTypes && extendTypes[computedProps.type])
|
|
351
378
|
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
352
379
|
...computedProps,
|
|
353
|
-
children:
|
|
380
|
+
children: extendTypes[computedProps.type].children
|
|
354
381
|
});
|
|
355
382
|
if (computedProps.children)
|
|
356
383
|
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
@@ -535,14 +562,14 @@ function FormItem(props) {
|
|
|
535
562
|
case "date":
|
|
536
563
|
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
537
564
|
...computedProps,
|
|
538
|
-
children: /* @__PURE__ */ jsx6(
|
|
565
|
+
children: /* @__PURE__ */ jsx6(DateItem, {
|
|
539
566
|
...computedProps.input
|
|
540
567
|
})
|
|
541
568
|
});
|
|
542
569
|
case "time":
|
|
543
570
|
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
544
571
|
...computedProps,
|
|
545
|
-
children: /* @__PURE__ */ jsx6(
|
|
572
|
+
children: /* @__PURE__ */ jsx6(TimeItem, {
|
|
546
573
|
...computedProps.input
|
|
547
574
|
})
|
|
548
575
|
});
|
|
@@ -631,6 +658,7 @@ function Form(props) {
|
|
|
631
658
|
const [loading, setLoading] = useState4(false);
|
|
632
659
|
const [computedProps, setComputedProps] = useState4();
|
|
633
660
|
const config = useConfigContext();
|
|
661
|
+
const [extendTypes, setExtendTypes] = useState4();
|
|
634
662
|
useEffect3(() => {
|
|
635
663
|
var _a2;
|
|
636
664
|
const propsCopy = { ...props };
|
|
@@ -659,6 +687,10 @@ function Form(props) {
|
|
|
659
687
|
} : values);
|
|
660
688
|
};
|
|
661
689
|
}
|
|
690
|
+
if (propsCopy.extendTypes) {
|
|
691
|
+
setExtendTypes(propsCopy.extendTypes);
|
|
692
|
+
delete propsCopy.extendTypes;
|
|
693
|
+
}
|
|
662
694
|
setComputedProps(propsCopy);
|
|
663
695
|
}, []);
|
|
664
696
|
if (!computedProps)
|
|
@@ -669,7 +701,7 @@ function Form(props) {
|
|
|
669
701
|
computedProps.beforeItems,
|
|
670
702
|
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx7(FormItem, {
|
|
671
703
|
...item,
|
|
672
|
-
extendTypes
|
|
704
|
+
extendTypes
|
|
673
705
|
}, item.id)),
|
|
674
706
|
computedProps.children,
|
|
675
707
|
computedProps.submit !== false && /* @__PURE__ */ jsx7(Button2, {
|
|
@@ -763,7 +795,7 @@ import {
|
|
|
763
795
|
Radio,
|
|
764
796
|
Skeleton as Skeleton3
|
|
765
797
|
} from "antd";
|
|
766
|
-
import
|
|
798
|
+
import dayjs3 from "dayjs";
|
|
767
799
|
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
768
800
|
import { isNil as isNil2, upperFirst as upperFirst4 } from "lodash";
|
|
769
801
|
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
@@ -792,7 +824,7 @@ function processValue(item, value) {
|
|
|
792
824
|
if (["date", "time"].includes(item.type)) {
|
|
793
825
|
if (typeof value === "number" && value.toString().length === 10)
|
|
794
826
|
value = value * 1e3;
|
|
795
|
-
value =
|
|
827
|
+
value = dayjs3(value).format(dayjsFormat);
|
|
796
828
|
}
|
|
797
829
|
}
|
|
798
830
|
return value;
|
|
@@ -925,12 +957,12 @@ function Table(props) {
|
|
|
925
957
|
case "date":
|
|
926
958
|
item.render = (value) => processValue(item, value);
|
|
927
959
|
if (!item.onFilter)
|
|
928
|
-
item.onFilter = (value, row) =>
|
|
960
|
+
item.onFilter = (value, row) => dayjs3(row[item.id]).isSame(dayjs3(value));
|
|
929
961
|
break;
|
|
930
962
|
case "time":
|
|
931
963
|
item.render = (value) => processValue(item, value);
|
|
932
964
|
if (!item.onFilter)
|
|
933
|
-
item.onFilter = (value, row) =>
|
|
965
|
+
item.onFilter = (value, row) => dayjs3(row[item.id]).isSame(dayjs3(value));
|
|
934
966
|
break;
|
|
935
967
|
default:
|
|
936
968
|
item.render = (value) => processValue(item, value);
|
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.406",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
|
-
"
|
|
25
|
+
"dependencies": {
|
|
26
26
|
"@ant-design/icons": "*",
|
|
27
27
|
"antd": "*",
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.406",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|