x-ui-design 0.6.98 → 0.6.99
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/esm/types/components/Switch/Switch.d.ts +1 -1
- package/dist/esm/types/types/switch.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +8 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/lib/components/Switch/Switch.tsx +8 -3
- package/lib/types/switch.ts +1 -0
- package/package.json +1 -1
- package/src/app/page.tsx +6 -2
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { SwitchProps } from '../../types/switch';
|
|
3
3
|
import './index.css';
|
|
4
4
|
declare const Switch: {
|
|
5
|
-
({ prefixCls, prefixClsV3, checked, onChange, onClick, disabled, className, style, defaultChecked, value }: SwitchProps): React.JSX.Element;
|
|
5
|
+
({ prefixCls, prefixClsV3, checked, onChange, onClick, disabled, className, style, defaultChecked, value, controlled }: SwitchProps): React.JSX.Element;
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
8
|
export default Switch;
|
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1632,7 +1632,8 @@ const Switch = ({
|
|
|
1632
1632
|
className = '',
|
|
1633
1633
|
style = {},
|
|
1634
1634
|
defaultChecked,
|
|
1635
|
-
value
|
|
1635
|
+
value,
|
|
1636
|
+
controlled = false
|
|
1636
1637
|
}) => {
|
|
1637
1638
|
const isChecked = checked !== undefined ? checked : defaultChecked || value;
|
|
1638
1639
|
const [internalChecked, setInternalChecked] = useState(isChecked);
|
|
@@ -1641,8 +1642,12 @@ const Switch = ({
|
|
|
1641
1642
|
if (disabled) {
|
|
1642
1643
|
return;
|
|
1643
1644
|
}
|
|
1644
|
-
|
|
1645
|
-
|
|
1645
|
+
if (!controlled) {
|
|
1646
|
+
setInternalChecked(!internalChecked);
|
|
1647
|
+
e.target.value = !internalChecked;
|
|
1648
|
+
} else {
|
|
1649
|
+
e.target.value = !checked;
|
|
1650
|
+
}
|
|
1646
1651
|
onClick?.(e.target.value);
|
|
1647
1652
|
onChange?.(e.target.value);
|
|
1648
1653
|
};
|