@faasjs/ant-design 0.0.2-beta.439 → 0.0.2-beta.441
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 +4 -3
- package/dist/index.js +21 -12
- package/dist/index.mjs +21 -12
- 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';
|
|
@@ -246,10 +246,12 @@ declare type ExtendTypes = {
|
|
|
246
246
|
declare type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
247
247
|
declare type FormItemProps<T = any> = {
|
|
248
248
|
children?: ReactNode;
|
|
249
|
-
render?: (value?:
|
|
249
|
+
render?: (value?: T) => ReactNode | JSX.Element;
|
|
250
250
|
rules?: RuleObject[];
|
|
251
251
|
label?: string | false;
|
|
252
252
|
extendTypes?: ExtendTypes;
|
|
253
|
+
/** trigger when current item's value changed */
|
|
254
|
+
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
253
255
|
} & FormItemInputProps & FaasItemProps & Omit<FormItemProps$1<T>, 'children'>;
|
|
254
256
|
/**
|
|
255
257
|
* FormItem, can be used without Form.
|
|
@@ -318,7 +320,6 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
|
318
320
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
319
321
|
declare namespace Form {
|
|
320
322
|
var useForm: typeof antd_lib_form_Form.useForm;
|
|
321
|
-
var Item: typeof FormItem;
|
|
322
323
|
}
|
|
323
324
|
|
|
324
325
|
declare type LinkProps = {
|
package/dist/index.js
CHANGED
|
@@ -747,9 +747,13 @@ function Form(props) {
|
|
|
747
747
|
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
748
748
|
const config = useConfigContext();
|
|
749
749
|
const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
|
|
750
|
+
const [form] = import_antd6.Form.useForm(props.form);
|
|
750
751
|
(0, import_react9.useEffect)(() => {
|
|
751
752
|
var _a2, _b2;
|
|
752
|
-
const propsCopy = {
|
|
753
|
+
const propsCopy = {
|
|
754
|
+
...props,
|
|
755
|
+
form
|
|
756
|
+
};
|
|
753
757
|
if (propsCopy.initialValues)
|
|
754
758
|
for (const key in propsCopy.initialValues)
|
|
755
759
|
propsCopy.initialValues[key] = transferValue(
|
|
@@ -786,6 +790,20 @@ function Form(props) {
|
|
|
786
790
|
setExtendTypes(propsCopy.extendTypes);
|
|
787
791
|
delete propsCopy.extendTypes;
|
|
788
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
|
+
};
|
|
789
807
|
setComputedProps(propsCopy);
|
|
790
808
|
}, []);
|
|
791
809
|
if (!computedProps)
|
|
@@ -810,7 +828,6 @@ function Form(props) {
|
|
|
810
828
|
});
|
|
811
829
|
}
|
|
812
830
|
Form.useForm = import_antd6.Form.useForm;
|
|
813
|
-
Form.Item = FormItem;
|
|
814
831
|
|
|
815
832
|
// src/Link.tsx
|
|
816
833
|
var import_react_router_dom = require("react-router-dom");
|
|
@@ -1014,17 +1031,15 @@ function Table(props) {
|
|
|
1014
1031
|
item.onFilter = (value, row) => {
|
|
1015
1032
|
if (!row[item.id])
|
|
1016
1033
|
return false;
|
|
1017
|
-
return row[item.id].includes(value);
|
|
1034
|
+
return row[item.id].toLowerCase().includes(value.toLowerCase());
|
|
1018
1035
|
};
|
|
1019
1036
|
if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
|
|
1020
1037
|
item.filterDropdown = ({
|
|
1021
1038
|
setSelectedKeys,
|
|
1022
|
-
selectedKeys,
|
|
1023
1039
|
confirm,
|
|
1024
1040
|
clearFilters
|
|
1025
1041
|
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Input.Search, {
|
|
1026
1042
|
placeholder: `${common2.search} ${item.title}`,
|
|
1027
|
-
value: selectedKeys[0],
|
|
1028
1043
|
allowClear: true,
|
|
1029
1044
|
onSearch: (v) => {
|
|
1030
1045
|
if (v) {
|
|
@@ -1044,17 +1059,15 @@ function Table(props) {
|
|
|
1044
1059
|
item.onFilter = (value, row) => {
|
|
1045
1060
|
if (!row[item.id] || !row[item.id].length)
|
|
1046
1061
|
return false;
|
|
1047
|
-
return row[item.id].some((v) => v.includes(value));
|
|
1062
|
+
return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
|
|
1048
1063
|
};
|
|
1049
1064
|
if (!item.filters && item.filterDropdown !== false)
|
|
1050
1065
|
item.filterDropdown = ({
|
|
1051
1066
|
setSelectedKeys,
|
|
1052
|
-
selectedKeys,
|
|
1053
1067
|
confirm,
|
|
1054
1068
|
clearFilters
|
|
1055
1069
|
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Input.Search, {
|
|
1056
1070
|
placeholder: `${common2.search} ${item.title}`,
|
|
1057
|
-
value: selectedKeys[0],
|
|
1058
1071
|
allowClear: true,
|
|
1059
1072
|
onSearch: (v) => {
|
|
1060
1073
|
if (v) {
|
|
@@ -1077,12 +1090,10 @@ function Table(props) {
|
|
|
1077
1090
|
if (!item.filters && item.filterDropdown !== false)
|
|
1078
1091
|
item.filterDropdown = ({
|
|
1079
1092
|
setSelectedKeys,
|
|
1080
|
-
selectedKeys,
|
|
1081
1093
|
confirm,
|
|
1082
1094
|
clearFilters
|
|
1083
1095
|
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Input.Search, {
|
|
1084
1096
|
placeholder: `${common2.search} ${item.title}`,
|
|
1085
|
-
value: selectedKeys[0],
|
|
1086
1097
|
allowClear: true,
|
|
1087
1098
|
onSearch: (v) => {
|
|
1088
1099
|
if (v) {
|
|
@@ -1103,12 +1114,10 @@ function Table(props) {
|
|
|
1103
1114
|
if (!item.filters && item.filterDropdown !== false)
|
|
1104
1115
|
item.filterDropdown = ({
|
|
1105
1116
|
setSelectedKeys,
|
|
1106
|
-
selectedKeys,
|
|
1107
1117
|
confirm,
|
|
1108
1118
|
clearFilters
|
|
1109
1119
|
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Input.Search, {
|
|
1110
1120
|
placeholder: `${common2.search} ${item.title}`,
|
|
1111
|
-
value: selectedKeys[0],
|
|
1112
1121
|
allowClear: true,
|
|
1113
1122
|
onSearch: (v) => {
|
|
1114
1123
|
if (v) {
|
package/dist/index.mjs
CHANGED
|
@@ -726,9 +726,13 @@ function Form(props) {
|
|
|
726
726
|
const [computedProps, setComputedProps] = useState5();
|
|
727
727
|
const config = useConfigContext();
|
|
728
728
|
const [extendTypes, setExtendTypes] = useState5();
|
|
729
|
+
const [form] = AntdForm2.useForm(props.form);
|
|
729
730
|
useEffect4(() => {
|
|
730
731
|
var _a2, _b2;
|
|
731
|
-
const propsCopy = {
|
|
732
|
+
const propsCopy = {
|
|
733
|
+
...props,
|
|
734
|
+
form
|
|
735
|
+
};
|
|
732
736
|
if (propsCopy.initialValues)
|
|
733
737
|
for (const key in propsCopy.initialValues)
|
|
734
738
|
propsCopy.initialValues[key] = transferValue(
|
|
@@ -765,6 +769,20 @@ function Form(props) {
|
|
|
765
769
|
setExtendTypes(propsCopy.extendTypes);
|
|
766
770
|
delete propsCopy.extendTypes;
|
|
767
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
|
+
};
|
|
768
786
|
setComputedProps(propsCopy);
|
|
769
787
|
}, []);
|
|
770
788
|
if (!computedProps)
|
|
@@ -789,7 +807,6 @@ function Form(props) {
|
|
|
789
807
|
});
|
|
790
808
|
}
|
|
791
809
|
Form.useForm = AntdForm2.useForm;
|
|
792
|
-
Form.Item = FormItem;
|
|
793
810
|
|
|
794
811
|
// src/Link.tsx
|
|
795
812
|
import { Link as RouterLink } from "react-router-dom";
|
|
@@ -1011,17 +1028,15 @@ function Table(props) {
|
|
|
1011
1028
|
item.onFilter = (value, row) => {
|
|
1012
1029
|
if (!row[item.id])
|
|
1013
1030
|
return false;
|
|
1014
|
-
return row[item.id].includes(value);
|
|
1031
|
+
return row[item.id].toLowerCase().includes(value.toLowerCase());
|
|
1015
1032
|
};
|
|
1016
1033
|
if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
|
|
1017
1034
|
item.filterDropdown = ({
|
|
1018
1035
|
setSelectedKeys,
|
|
1019
|
-
selectedKeys,
|
|
1020
1036
|
confirm,
|
|
1021
1037
|
clearFilters
|
|
1022
1038
|
}) => /* @__PURE__ */ jsx11(Input2.Search, {
|
|
1023
1039
|
placeholder: `${common2.search} ${item.title}`,
|
|
1024
|
-
value: selectedKeys[0],
|
|
1025
1040
|
allowClear: true,
|
|
1026
1041
|
onSearch: (v) => {
|
|
1027
1042
|
if (v) {
|
|
@@ -1041,17 +1056,15 @@ function Table(props) {
|
|
|
1041
1056
|
item.onFilter = (value, row) => {
|
|
1042
1057
|
if (!row[item.id] || !row[item.id].length)
|
|
1043
1058
|
return false;
|
|
1044
|
-
return row[item.id].some((v) => v.includes(value));
|
|
1059
|
+
return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
|
|
1045
1060
|
};
|
|
1046
1061
|
if (!item.filters && item.filterDropdown !== false)
|
|
1047
1062
|
item.filterDropdown = ({
|
|
1048
1063
|
setSelectedKeys,
|
|
1049
|
-
selectedKeys,
|
|
1050
1064
|
confirm,
|
|
1051
1065
|
clearFilters
|
|
1052
1066
|
}) => /* @__PURE__ */ jsx11(Input2.Search, {
|
|
1053
1067
|
placeholder: `${common2.search} ${item.title}`,
|
|
1054
|
-
value: selectedKeys[0],
|
|
1055
1068
|
allowClear: true,
|
|
1056
1069
|
onSearch: (v) => {
|
|
1057
1070
|
if (v) {
|
|
@@ -1074,12 +1087,10 @@ function Table(props) {
|
|
|
1074
1087
|
if (!item.filters && item.filterDropdown !== false)
|
|
1075
1088
|
item.filterDropdown = ({
|
|
1076
1089
|
setSelectedKeys,
|
|
1077
|
-
selectedKeys,
|
|
1078
1090
|
confirm,
|
|
1079
1091
|
clearFilters
|
|
1080
1092
|
}) => /* @__PURE__ */ jsx11(Input2.Search, {
|
|
1081
1093
|
placeholder: `${common2.search} ${item.title}`,
|
|
1082
|
-
value: selectedKeys[0],
|
|
1083
1094
|
allowClear: true,
|
|
1084
1095
|
onSearch: (v) => {
|
|
1085
1096
|
if (v) {
|
|
@@ -1100,12 +1111,10 @@ function Table(props) {
|
|
|
1100
1111
|
if (!item.filters && item.filterDropdown !== false)
|
|
1101
1112
|
item.filterDropdown = ({
|
|
1102
1113
|
setSelectedKeys,
|
|
1103
|
-
selectedKeys,
|
|
1104
1114
|
confirm,
|
|
1105
1115
|
clearFilters
|
|
1106
1116
|
}) => /* @__PURE__ */ jsx11(Input2.Search, {
|
|
1107
1117
|
placeholder: `${common2.search} ${item.title}`,
|
|
1108
|
-
value: selectedKeys[0],
|
|
1109
1118
|
allowClear: true,
|
|
1110
1119
|
onSearch: (v) => {
|
|
1111
1120
|
if (v) {
|
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.441",
|
|
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.441",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|