@faasjs/ant-design 0.0.2-beta.438 → 0.0.2-beta.440
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 +8 -5
- package/dist/index.js +58 -21
- package/dist/index.mjs +55 -19
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as antd_es_calendar_generateCalendar_js from 'antd/es/calendar/generateCalendar.js';
|
|
2
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, ButtonProps, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, PageHeaderProps } from 'antd';
|
|
3
|
+
import { CalendarProps as CalendarProps$1, DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, FormInstance, InputProps, InputNumberProps, SwitchProps, DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1, SelectProps, FormProps as FormProps$1, ButtonProps, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, PageHeaderProps } from 'antd';
|
|
4
4
|
export { Drawer, Modal } from 'antd';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { CSSProperties, ReactNode, LazyExoticComponent, ComponentType } from 'react';
|
|
@@ -121,6 +121,7 @@ declare function transferOptions(options: BaseOption[]): {
|
|
|
121
121
|
label: string;
|
|
122
122
|
value?: string | number;
|
|
123
123
|
}[];
|
|
124
|
+
declare function transferValue(type: FaasItemType, value: any): any;
|
|
124
125
|
|
|
125
126
|
declare type DatePickerProps = PickerDateProps<Dayjs>;
|
|
126
127
|
declare const DatePicker: antd_es_date_picker_generatePicker_interface.PickerComponentClass<antd_es_date_picker_generatePicker.PickerProps<Dayjs> & {
|
|
@@ -245,10 +246,12 @@ declare type ExtendTypes = {
|
|
|
245
246
|
declare type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
246
247
|
declare type FormItemProps<T = any> = {
|
|
247
248
|
children?: ReactNode;
|
|
248
|
-
render?: (value?:
|
|
249
|
+
render?: (value?: T) => ReactNode | JSX.Element;
|
|
249
250
|
rules?: RuleObject[];
|
|
250
251
|
label?: string | false;
|
|
251
252
|
extendTypes?: ExtendTypes;
|
|
253
|
+
/** trigger when current item's value changed */
|
|
254
|
+
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
252
255
|
} & FormItemInputProps & FaasItemProps & Omit<FormItemProps$1<T>, 'children'>;
|
|
253
256
|
/**
|
|
254
257
|
* FormItem, can be used without Form.
|
|
@@ -307,7 +310,8 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
|
307
310
|
footer?: JSX.Element | JSX.Element[];
|
|
308
311
|
extendTypes?: ExtendTypes;
|
|
309
312
|
children?: ReactNode;
|
|
310
|
-
|
|
313
|
+
initialValues?: Values;
|
|
314
|
+
} & Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'>;
|
|
311
315
|
/**
|
|
312
316
|
* Form component with Ant Design & FaasJS
|
|
313
317
|
*
|
|
@@ -316,7 +320,6 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
|
316
320
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
317
321
|
declare namespace Form {
|
|
318
322
|
var useForm: typeof antd_lib_form_Form.useForm;
|
|
319
|
-
var Item: typeof FormItem;
|
|
320
323
|
}
|
|
321
324
|
|
|
322
325
|
declare type LinkProps = {
|
|
@@ -460,4 +463,4 @@ declare type TitleProps = {
|
|
|
460
463
|
*/
|
|
461
464
|
declare function Title(props: TitleProps): JSX.Element;
|
|
462
465
|
|
|
463
|
-
export { BaseItemProps, BaseOption, Blank, BlankProps, Calendar, CalendarProps, ConfigContext, ConfigProvider, ConfigProviderProps, DatePicker, DatePickerProps, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, Link, LinkProps, ModalProps, PageNotFound, Routes, RoutesProps, Table, TableItemProps, TableProps, TimePicker, TimePickerProps, Title, TitleProps, setDrawerProps, setModalProps, transferOptions, useConfigContext, useDrawer, useModal };
|
|
466
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, Calendar, CalendarProps, ConfigContext, ConfigProvider, ConfigProviderProps, DatePicker, DatePickerProps, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, Link, LinkProps, ModalProps, PageNotFound, Routes, RoutesProps, Table, TableItemProps, TableProps, TimePicker, TimePickerProps, Title, TitleProps, setDrawerProps, setModalProps, transferOptions, transferValue, useConfigContext, useDrawer, useModal };
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,7 @@ __export(src_exports, {
|
|
|
43
43
|
TimePicker: () => TimePicker,
|
|
44
44
|
Title: () => Title,
|
|
45
45
|
transferOptions: () => transferOptions,
|
|
46
|
+
transferValue: () => transferValue,
|
|
46
47
|
useConfigContext: () => useConfigContext,
|
|
47
48
|
useDrawer: () => useDrawer,
|
|
48
49
|
useModal: () => useModal
|
|
@@ -146,6 +147,7 @@ var Calendar = (0, import_generateCalendar.default)(import_dayjs.default);
|
|
|
146
147
|
|
|
147
148
|
// src/data.ts
|
|
148
149
|
var import_lodash3 = require("lodash");
|
|
150
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
149
151
|
function transferOptions(options) {
|
|
150
152
|
if (!options)
|
|
151
153
|
return [];
|
|
@@ -154,19 +156,33 @@ function transferOptions(options) {
|
|
|
154
156
|
value: item
|
|
155
157
|
});
|
|
156
158
|
}
|
|
159
|
+
function transferValue(type, value) {
|
|
160
|
+
if (typeof value === "undefined" || value === null || value === "" || Array.isArray(value) && !value.length)
|
|
161
|
+
return null;
|
|
162
|
+
if (!type)
|
|
163
|
+
type = "string";
|
|
164
|
+
if (type.endsWith("[]") && typeof value === "string")
|
|
165
|
+
value = value.split(",");
|
|
166
|
+
if (["date", "time"].includes(type)) {
|
|
167
|
+
if (typeof value === "number" && value.toString().length === 10)
|
|
168
|
+
value = value * 1e3;
|
|
169
|
+
if (!import_dayjs2.default.isDayjs(value))
|
|
170
|
+
value = (0, import_dayjs2.default)(value);
|
|
171
|
+
}
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
157
174
|
|
|
158
175
|
// src/DatePicker.tsx
|
|
159
|
-
var
|
|
176
|
+
var import_dayjs3 = __toESM(require("rc-picker/es/generate/dayjs.js"));
|
|
160
177
|
var import_generatePicker = __toESM(require("antd/es/date-picker/generatePicker/index.js"));
|
|
161
178
|
var import_style2 = require("antd/es/date-picker/style/index.js");
|
|
162
|
-
var DatePicker = (0, import_generatePicker.default)(
|
|
179
|
+
var DatePicker = (0, import_generatePicker.default)(import_dayjs3.default);
|
|
163
180
|
|
|
164
181
|
// src/Description.tsx
|
|
165
182
|
var import_icons = require("@ant-design/icons");
|
|
166
183
|
var import_antd3 = require("antd");
|
|
167
184
|
var import_lodash4 = require("lodash");
|
|
168
185
|
var import_react3 = require("react");
|
|
169
|
-
var import_dayjs3 = __toESM(require("dayjs"));
|
|
170
186
|
var import_react4 = require("@faasjs/react");
|
|
171
187
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
172
188
|
function DescriptionItemContent(props) {
|
|
@@ -182,6 +198,7 @@ function DescriptionItemContent(props) {
|
|
|
182
198
|
if ((_a2 = propsCopy.item.options) == null ? void 0 : _a2.length) {
|
|
183
199
|
propsCopy.item.options = transferOptions(propsCopy.item.options);
|
|
184
200
|
}
|
|
201
|
+
propsCopy.value = transferValue(propsCopy.item.type, propsCopy.value);
|
|
185
202
|
if (propsCopy.item.options && typeof propsCopy.value !== "undefined" && propsCopy.value !== null) {
|
|
186
203
|
if (propsCopy.item.type.endsWith("[]"))
|
|
187
204
|
propsCopy.value = propsCopy.value.map((v) => {
|
|
@@ -220,7 +237,7 @@ function DescriptionItemContent(props) {
|
|
|
220
237
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {
|
|
221
238
|
children: computedProps.item.render(computedProps.value, computedProps.values)
|
|
222
239
|
});
|
|
223
|
-
if (
|
|
240
|
+
if (computedProps.value === null)
|
|
224
241
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Blank, {});
|
|
225
242
|
switch (computedProps.item.type) {
|
|
226
243
|
case "string[]":
|
|
@@ -247,11 +264,11 @@ function DescriptionItemContent(props) {
|
|
|
247
264
|
});
|
|
248
265
|
case "time":
|
|
249
266
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {
|
|
250
|
-
children:
|
|
267
|
+
children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
|
|
251
268
|
});
|
|
252
269
|
case "date":
|
|
253
270
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {
|
|
254
|
-
children:
|
|
271
|
+
children: computedProps.value.format("YYYY-MM-DD")
|
|
255
272
|
});
|
|
256
273
|
case "object":
|
|
257
274
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Description, {
|
|
@@ -730,9 +747,19 @@ function Form(props) {
|
|
|
730
747
|
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
731
748
|
const config = useConfigContext();
|
|
732
749
|
const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
|
|
750
|
+
const [form] = import_antd6.Form.useForm(props.form);
|
|
733
751
|
(0, import_react9.useEffect)(() => {
|
|
734
|
-
var _a2;
|
|
735
|
-
const propsCopy = {
|
|
752
|
+
var _a2, _b2;
|
|
753
|
+
const propsCopy = {
|
|
754
|
+
...props,
|
|
755
|
+
form
|
|
756
|
+
};
|
|
757
|
+
if (propsCopy.initialValues)
|
|
758
|
+
for (const key in propsCopy.initialValues)
|
|
759
|
+
propsCopy.initialValues[key] = transferValue(
|
|
760
|
+
(_a2 = propsCopy.items.find((i) => i.id === key)) == null ? void 0 : _a2.type,
|
|
761
|
+
propsCopy.initialValues[key]
|
|
762
|
+
);
|
|
736
763
|
if (propsCopy.onFinish) {
|
|
737
764
|
propsCopy.onFinish = async (values) => {
|
|
738
765
|
var _a3;
|
|
@@ -750,7 +777,7 @@ function Form(props) {
|
|
|
750
777
|
}
|
|
751
778
|
setLoading(false);
|
|
752
779
|
};
|
|
753
|
-
} else if (propsCopy.submit && ((
|
|
780
|
+
} else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
|
|
754
781
|
propsCopy.onFinish = async (values) => {
|
|
755
782
|
setLoading(true);
|
|
756
783
|
return (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
@@ -763,6 +790,20 @@ function Form(props) {
|
|
|
763
790
|
setExtendTypes(propsCopy.extendTypes);
|
|
764
791
|
delete propsCopy.extendTypes;
|
|
765
792
|
}
|
|
793
|
+
let originValuesChange;
|
|
794
|
+
if (propsCopy.onValuesChange)
|
|
795
|
+
originValuesChange = propsCopy.onValuesChange;
|
|
796
|
+
propsCopy.onValuesChange = (changedValues, allValues) => {
|
|
797
|
+
if (originValuesChange)
|
|
798
|
+
originValuesChange(changedValues, allValues);
|
|
799
|
+
if (!propsCopy.items)
|
|
800
|
+
return;
|
|
801
|
+
for (const key in changedValues) {
|
|
802
|
+
const item = propsCopy.items.find((i) => i.id === key);
|
|
803
|
+
if (item == null ? void 0 : item.onValueChange)
|
|
804
|
+
item.onValueChange(changedValues[key], allValues, form);
|
|
805
|
+
}
|
|
806
|
+
};
|
|
766
807
|
setComputedProps(propsCopy);
|
|
767
808
|
}, []);
|
|
768
809
|
if (!computedProps)
|
|
@@ -787,7 +828,6 @@ function Form(props) {
|
|
|
787
828
|
});
|
|
788
829
|
}
|
|
789
830
|
Form.useForm = import_antd6.Form.useForm;
|
|
790
|
-
Form.Item = FormItem;
|
|
791
831
|
|
|
792
832
|
// src/Link.tsx
|
|
793
833
|
var import_react_router_dom = require("react-router-dom");
|
|
@@ -923,13 +963,12 @@ var import_react13 = require("@faasjs/react");
|
|
|
923
963
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
924
964
|
function processValue(item, value) {
|
|
925
965
|
var _a;
|
|
926
|
-
|
|
966
|
+
const transferred = transferValue(item.type, value);
|
|
967
|
+
if (transferred === null)
|
|
927
968
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Blank, {});
|
|
928
|
-
if (item.type.endsWith("[]") && typeof value === "string")
|
|
929
|
-
value = value.split(",");
|
|
930
969
|
if (item.options) {
|
|
931
970
|
if (item.type.endsWith("[]"))
|
|
932
|
-
return
|
|
971
|
+
return transferred.map((v) => {
|
|
933
972
|
var _a2;
|
|
934
973
|
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
935
974
|
}).join(", ");
|
|
@@ -938,15 +977,12 @@ function processValue(item, value) {
|
|
|
938
977
|
"number",
|
|
939
978
|
"boolean"
|
|
940
979
|
].includes(item.type))
|
|
941
|
-
return ((_a = item.options.find((option) => option.value ===
|
|
980
|
+
return ((_a = item.options.find((option) => option.value === transferred)) == null ? void 0 : _a.label) || transferred;
|
|
942
981
|
}
|
|
943
982
|
if (item.type.endsWith("[]"))
|
|
944
|
-
return
|
|
945
|
-
if (["date", "time"].includes(item.type))
|
|
946
|
-
|
|
947
|
-
value = value * 1e3;
|
|
948
|
-
return (0, import_dayjs5.default)(value).format(item.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss");
|
|
949
|
-
}
|
|
983
|
+
return transferred.join(", ");
|
|
984
|
+
if (["date", "time"].includes(item.type))
|
|
985
|
+
return transferred.format(item.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss");
|
|
950
986
|
return value;
|
|
951
987
|
}
|
|
952
988
|
function Table(props) {
|
|
@@ -1331,6 +1367,7 @@ function Title(props) {
|
|
|
1331
1367
|
TimePicker,
|
|
1332
1368
|
Title,
|
|
1333
1369
|
transferOptions,
|
|
1370
|
+
transferValue,
|
|
1334
1371
|
useConfigContext,
|
|
1335
1372
|
useDrawer,
|
|
1336
1373
|
useModal
|
package/dist/index.mjs
CHANGED
|
@@ -100,6 +100,7 @@ var Calendar = generateCalendar(dayjsGenerateConfig);
|
|
|
100
100
|
|
|
101
101
|
// src/data.ts
|
|
102
102
|
import { upperFirst } from "lodash";
|
|
103
|
+
import dayjs from "dayjs";
|
|
103
104
|
function transferOptions(options) {
|
|
104
105
|
if (!options)
|
|
105
106
|
return [];
|
|
@@ -108,6 +109,21 @@ function transferOptions(options) {
|
|
|
108
109
|
value: item
|
|
109
110
|
});
|
|
110
111
|
}
|
|
112
|
+
function transferValue(type, value) {
|
|
113
|
+
if (typeof value === "undefined" || value === null || value === "" || Array.isArray(value) && !value.length)
|
|
114
|
+
return null;
|
|
115
|
+
if (!type)
|
|
116
|
+
type = "string";
|
|
117
|
+
if (type.endsWith("[]") && typeof value === "string")
|
|
118
|
+
value = value.split(",");
|
|
119
|
+
if (["date", "time"].includes(type)) {
|
|
120
|
+
if (typeof value === "number" && value.toString().length === 10)
|
|
121
|
+
value = value * 1e3;
|
|
122
|
+
if (!dayjs.isDayjs(value))
|
|
123
|
+
value = dayjs(value);
|
|
124
|
+
}
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
111
127
|
|
|
112
128
|
// src/DatePicker.tsx
|
|
113
129
|
import dayjsGenerateConfig2 from "rc-picker/es/generate/dayjs.js";
|
|
@@ -128,7 +144,6 @@ import {
|
|
|
128
144
|
useEffect as useEffect2,
|
|
129
145
|
useState as useState2
|
|
130
146
|
} from "react";
|
|
131
|
-
import dayjs from "dayjs";
|
|
132
147
|
import { FaasDataWrapper } from "@faasjs/react";
|
|
133
148
|
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
134
149
|
function DescriptionItemContent(props) {
|
|
@@ -144,6 +159,7 @@ function DescriptionItemContent(props) {
|
|
|
144
159
|
if ((_a2 = propsCopy.item.options) == null ? void 0 : _a2.length) {
|
|
145
160
|
propsCopy.item.options = transferOptions(propsCopy.item.options);
|
|
146
161
|
}
|
|
162
|
+
propsCopy.value = transferValue(propsCopy.item.type, propsCopy.value);
|
|
147
163
|
if (propsCopy.item.options && typeof propsCopy.value !== "undefined" && propsCopy.value !== null) {
|
|
148
164
|
if (propsCopy.item.type.endsWith("[]"))
|
|
149
165
|
propsCopy.value = propsCopy.value.map((v) => {
|
|
@@ -182,7 +198,7 @@ function DescriptionItemContent(props) {
|
|
|
182
198
|
return /* @__PURE__ */ jsx3(Fragment, {
|
|
183
199
|
children: computedProps.item.render(computedProps.value, computedProps.values)
|
|
184
200
|
});
|
|
185
|
-
if (
|
|
201
|
+
if (computedProps.value === null)
|
|
186
202
|
return /* @__PURE__ */ jsx3(Blank, {});
|
|
187
203
|
switch (computedProps.item.type) {
|
|
188
204
|
case "string[]":
|
|
@@ -209,11 +225,11 @@ function DescriptionItemContent(props) {
|
|
|
209
225
|
});
|
|
210
226
|
case "time":
|
|
211
227
|
return /* @__PURE__ */ jsx3(Fragment, {
|
|
212
|
-
children:
|
|
228
|
+
children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
|
|
213
229
|
});
|
|
214
230
|
case "date":
|
|
215
231
|
return /* @__PURE__ */ jsx3(Fragment, {
|
|
216
|
-
children:
|
|
232
|
+
children: computedProps.value.format("YYYY-MM-DD")
|
|
217
233
|
});
|
|
218
234
|
case "object":
|
|
219
235
|
return /* @__PURE__ */ jsx3(Description, {
|
|
@@ -710,9 +726,19 @@ function Form(props) {
|
|
|
710
726
|
const [computedProps, setComputedProps] = useState5();
|
|
711
727
|
const config = useConfigContext();
|
|
712
728
|
const [extendTypes, setExtendTypes] = useState5();
|
|
729
|
+
const [form] = AntdForm2.useForm(props.form);
|
|
713
730
|
useEffect4(() => {
|
|
714
|
-
var _a2;
|
|
715
|
-
const propsCopy = {
|
|
731
|
+
var _a2, _b2;
|
|
732
|
+
const propsCopy = {
|
|
733
|
+
...props,
|
|
734
|
+
form
|
|
735
|
+
};
|
|
736
|
+
if (propsCopy.initialValues)
|
|
737
|
+
for (const key in propsCopy.initialValues)
|
|
738
|
+
propsCopy.initialValues[key] = transferValue(
|
|
739
|
+
(_a2 = propsCopy.items.find((i) => i.id === key)) == null ? void 0 : _a2.type,
|
|
740
|
+
propsCopy.initialValues[key]
|
|
741
|
+
);
|
|
716
742
|
if (propsCopy.onFinish) {
|
|
717
743
|
propsCopy.onFinish = async (values) => {
|
|
718
744
|
var _a3;
|
|
@@ -730,7 +756,7 @@ function Form(props) {
|
|
|
730
756
|
}
|
|
731
757
|
setLoading(false);
|
|
732
758
|
};
|
|
733
|
-
} else if (propsCopy.submit && ((
|
|
759
|
+
} else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
|
|
734
760
|
propsCopy.onFinish = async (values) => {
|
|
735
761
|
setLoading(true);
|
|
736
762
|
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
@@ -743,6 +769,20 @@ function Form(props) {
|
|
|
743
769
|
setExtendTypes(propsCopy.extendTypes);
|
|
744
770
|
delete propsCopy.extendTypes;
|
|
745
771
|
}
|
|
772
|
+
let originValuesChange;
|
|
773
|
+
if (propsCopy.onValuesChange)
|
|
774
|
+
originValuesChange = propsCopy.onValuesChange;
|
|
775
|
+
propsCopy.onValuesChange = (changedValues, allValues) => {
|
|
776
|
+
if (originValuesChange)
|
|
777
|
+
originValuesChange(changedValues, allValues);
|
|
778
|
+
if (!propsCopy.items)
|
|
779
|
+
return;
|
|
780
|
+
for (const key in changedValues) {
|
|
781
|
+
const item = propsCopy.items.find((i) => i.id === key);
|
|
782
|
+
if (item == null ? void 0 : item.onValueChange)
|
|
783
|
+
item.onValueChange(changedValues[key], allValues, form);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
746
786
|
setComputedProps(propsCopy);
|
|
747
787
|
}, []);
|
|
748
788
|
if (!computedProps)
|
|
@@ -767,7 +807,6 @@ function Form(props) {
|
|
|
767
807
|
});
|
|
768
808
|
}
|
|
769
809
|
Form.useForm = AntdForm2.useForm;
|
|
770
|
-
Form.Item = FormItem;
|
|
771
810
|
|
|
772
811
|
// src/Link.tsx
|
|
773
812
|
import { Link as RouterLink } from "react-router-dom";
|
|
@@ -921,13 +960,12 @@ import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
|
921
960
|
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
922
961
|
function processValue(item, value) {
|
|
923
962
|
var _a;
|
|
924
|
-
|
|
963
|
+
const transferred = transferValue(item.type, value);
|
|
964
|
+
if (transferred === null)
|
|
925
965
|
return /* @__PURE__ */ jsx11(Blank, {});
|
|
926
|
-
if (item.type.endsWith("[]") && typeof value === "string")
|
|
927
|
-
value = value.split(",");
|
|
928
966
|
if (item.options) {
|
|
929
967
|
if (item.type.endsWith("[]"))
|
|
930
|
-
return
|
|
968
|
+
return transferred.map((v) => {
|
|
931
969
|
var _a2;
|
|
932
970
|
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
933
971
|
}).join(", ");
|
|
@@ -936,15 +974,12 @@ function processValue(item, value) {
|
|
|
936
974
|
"number",
|
|
937
975
|
"boolean"
|
|
938
976
|
].includes(item.type))
|
|
939
|
-
return ((_a = item.options.find((option) => option.value ===
|
|
977
|
+
return ((_a = item.options.find((option) => option.value === transferred)) == null ? void 0 : _a.label) || transferred;
|
|
940
978
|
}
|
|
941
979
|
if (item.type.endsWith("[]"))
|
|
942
|
-
return
|
|
943
|
-
if (["date", "time"].includes(item.type))
|
|
944
|
-
|
|
945
|
-
value = value * 1e3;
|
|
946
|
-
return dayjs3(value).format(item.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss");
|
|
947
|
-
}
|
|
980
|
+
return transferred.join(", ");
|
|
981
|
+
if (["date", "time"].includes(item.type))
|
|
982
|
+
return transferred.format(item.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss");
|
|
948
983
|
return value;
|
|
949
984
|
}
|
|
950
985
|
function Table(props) {
|
|
@@ -1328,6 +1363,7 @@ export {
|
|
|
1328
1363
|
TimePicker,
|
|
1329
1364
|
Title,
|
|
1330
1365
|
transferOptions,
|
|
1366
|
+
transferValue,
|
|
1331
1367
|
useConfigContext,
|
|
1332
1368
|
useDrawer,
|
|
1333
1369
|
useModal
|
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.440",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.440",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|