sti-antd-package 0.0.41 → 0.0.42
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/components/Switch/types.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +4 -3
- package/dist/index.js +4 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formColLayout } from "../../constants";
|
|
2
2
|
import { ValidateStatus } from "antd/es/form/FormItem";
|
|
3
3
|
import { ShouldUpdate } from "rc-field-form/lib/Field";
|
|
4
|
-
import { NamePath, Rule
|
|
4
|
+
import { NamePath, Rule } from "rc-field-form/lib/interface";
|
|
5
5
|
import React from "react";
|
|
6
6
|
export interface SwitchComponentProps {
|
|
7
7
|
noItem?: boolean;
|
|
@@ -10,6 +10,7 @@ export interface SwitchComponentProps {
|
|
|
10
10
|
unCheckedChildren?: React.ReactNode;
|
|
11
11
|
loading?: boolean;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
value?: boolean;
|
|
13
14
|
checked?: boolean;
|
|
14
15
|
defaultChecked?: boolean;
|
|
15
16
|
removeError?: (name?: NamePath) => void;
|
|
@@ -19,7 +20,6 @@ export interface SwitchComponentProps {
|
|
|
19
20
|
label?: React.ReactNode;
|
|
20
21
|
required?: boolean;
|
|
21
22
|
rules?: Rule[];
|
|
22
|
-
ruleType?: RuleObject['type'];
|
|
23
23
|
ruleMessage?: string;
|
|
24
24
|
validateStatus?: ValidateStatus;
|
|
25
25
|
shouldUpdate?: ShouldUpdate<string | string[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -709,6 +709,7 @@ interface SwitchComponentProps {
|
|
|
709
709
|
unCheckedChildren?: React$1.ReactNode;
|
|
710
710
|
loading?: boolean;
|
|
711
711
|
disabled?: boolean;
|
|
712
|
+
value?: boolean;
|
|
712
713
|
checked?: boolean;
|
|
713
714
|
defaultChecked?: boolean;
|
|
714
715
|
removeError?: (name?: NamePath) => void;
|
|
@@ -718,7 +719,6 @@ interface SwitchComponentProps {
|
|
|
718
719
|
label?: React$1.ReactNode;
|
|
719
720
|
required?: boolean;
|
|
720
721
|
rules?: Rule$1[];
|
|
721
|
-
ruleType?: RuleObject$1['type'];
|
|
722
722
|
ruleMessage?: string;
|
|
723
723
|
validateStatus?: ValidateStatus;
|
|
724
724
|
shouldUpdate?: ShouldUpdate<string | string[]>;
|
package/dist/index.esm.js
CHANGED
|
@@ -8373,8 +8373,9 @@ const SelectAsyncComponent = (_a) => {
|
|
|
8373
8373
|
};
|
|
8374
8374
|
var SelectAsyncComponent$1 = React__default.memo(SelectAsyncComponent);
|
|
8375
8375
|
|
|
8376
|
-
const SwitchComponent = ({ noItem, icon, checkedChildren, unCheckedChildren, loading, disabled, checked, defaultChecked, removeError, onChange, formColLayout, name, label, required, rules,
|
|
8377
|
-
|
|
8376
|
+
const SwitchComponent = ({ noItem, icon, checkedChildren, unCheckedChildren, loading, disabled, value, checked, defaultChecked, removeError, onChange, formColLayout, name, label, required, rules, ruleMessage, validateStatus, help, shouldUpdate, }) => {
|
|
8377
|
+
var _a;
|
|
8378
|
+
const [checkedSwitch, setCheckedSwitch] = useState((_a = value !== null && value !== void 0 ? value : defaultChecked) !== null && _a !== void 0 ? _a : false);
|
|
8378
8379
|
const handleChange = (value, event) => {
|
|
8379
8380
|
setCheckedSwitch(value);
|
|
8380
8381
|
removeError === null || removeError === void 0 ? void 0 : removeError(name);
|
|
@@ -8388,7 +8389,7 @@ const SwitchComponent = ({ noItem, icon, checkedChildren, unCheckedChildren, loa
|
|
|
8388
8389
|
unCheckedChildren,
|
|
8389
8390
|
};
|
|
8390
8391
|
const switchComponent = !loading ? (jsxRuntimeExports.jsx(Switch, Object.assign({}, checkChildren, { onChange: handleChange, disabled: disabled, checked: checked !== null && checked !== void 0 ? checked : checkedSwitch, defaultChecked: checked !== null && checked !== void 0 ? checked : checkedSwitch }))) : jsxRuntimeExports.jsx(Skeleton.Input, { active: true });
|
|
8391
|
-
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !noItem ? (jsxRuntimeExports.jsx(FormItemComponent$1, Object.assign({}, formColLayout, { name: name, label: label, required: required, ruleType:
|
|
8392
|
+
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !noItem ? (jsxRuntimeExports.jsx(FormItemComponent$1, Object.assign({}, formColLayout, { name: name, label: label, required: required, ruleType: "boolean", ruleMessage: ruleMessage, rules: rules, valuePropName: "checked", validateStatus: validateStatus, help: help, shouldUpdate: shouldUpdate, children: switchComponent })))
|
|
8392
8393
|
: switchComponent }));
|
|
8393
8394
|
};
|
|
8394
8395
|
var SwitchComponent$1 = React__default.memo(SwitchComponent);
|
package/dist/index.js
CHANGED
|
@@ -8392,8 +8392,9 @@ const SelectAsyncComponent = (_a) => {
|
|
|
8392
8392
|
};
|
|
8393
8393
|
var SelectAsyncComponent$1 = React.memo(SelectAsyncComponent);
|
|
8394
8394
|
|
|
8395
|
-
const SwitchComponent = ({ noItem, icon, checkedChildren, unCheckedChildren, loading, disabled, checked, defaultChecked, removeError, onChange, formColLayout, name, label, required, rules,
|
|
8396
|
-
|
|
8395
|
+
const SwitchComponent = ({ noItem, icon, checkedChildren, unCheckedChildren, loading, disabled, value, checked, defaultChecked, removeError, onChange, formColLayout, name, label, required, rules, ruleMessage, validateStatus, help, shouldUpdate, }) => {
|
|
8396
|
+
var _a;
|
|
8397
|
+
const [checkedSwitch, setCheckedSwitch] = React.useState((_a = value !== null && value !== void 0 ? value : defaultChecked) !== null && _a !== void 0 ? _a : false);
|
|
8397
8398
|
const handleChange = (value, event) => {
|
|
8398
8399
|
setCheckedSwitch(value);
|
|
8399
8400
|
removeError === null || removeError === void 0 ? void 0 : removeError(name);
|
|
@@ -8407,7 +8408,7 @@ const SwitchComponent = ({ noItem, icon, checkedChildren, unCheckedChildren, loa
|
|
|
8407
8408
|
unCheckedChildren,
|
|
8408
8409
|
};
|
|
8409
8410
|
const switchComponent = !loading ? (jsxRuntimeExports.jsx(antd.Switch, Object.assign({}, checkChildren, { onChange: handleChange, disabled: disabled, checked: checked !== null && checked !== void 0 ? checked : checkedSwitch, defaultChecked: checked !== null && checked !== void 0 ? checked : checkedSwitch }))) : jsxRuntimeExports.jsx(antd.Skeleton.Input, { active: true });
|
|
8410
|
-
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !noItem ? (jsxRuntimeExports.jsx(FormItemComponent$1, Object.assign({}, formColLayout, { name: name, label: label, required: required, ruleType:
|
|
8411
|
+
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !noItem ? (jsxRuntimeExports.jsx(FormItemComponent$1, Object.assign({}, formColLayout, { name: name, label: label, required: required, ruleType: "boolean", ruleMessage: ruleMessage, rules: rules, valuePropName: "checked", validateStatus: validateStatus, help: help, shouldUpdate: shouldUpdate, children: switchComponent })))
|
|
8411
8412
|
: switchComponent }));
|
|
8412
8413
|
};
|
|
8413
8414
|
var SwitchComponent$1 = React.memo(SwitchComponent);
|