@officesdk/design 0.1.9 → 0.1.11
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/cjs/index.d.ts +12 -0
- package/dist/components/cjs/index.js +23 -4
- package/dist/components/cjs/index.js.map +1 -1
- package/dist/components/esm/index.d.ts +12 -0
- package/dist/components/esm/index.js +23 -4
- package/dist/components/esm/index.js.map +1 -1
- package/package.json +5 -3
|
@@ -187,10 +187,12 @@ declare const Switch: React.FC<SwitchProps>;
|
|
|
187
187
|
interface RadioProps {
|
|
188
188
|
/**
|
|
189
189
|
* Whether the radio is checked
|
|
190
|
+
* @default false
|
|
190
191
|
*/
|
|
191
192
|
checked?: boolean;
|
|
192
193
|
/**
|
|
193
194
|
* Default checked state
|
|
195
|
+
* @default false
|
|
194
196
|
*/
|
|
195
197
|
defaultChecked?: boolean;
|
|
196
198
|
/**
|
|
@@ -213,6 +215,11 @@ interface RadioProps {
|
|
|
213
215
|
* Callback when checked state changes
|
|
214
216
|
*/
|
|
215
217
|
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
218
|
+
/**
|
|
219
|
+
* prevent default click event, if true, change event will not be triggered
|
|
220
|
+
* @default false
|
|
221
|
+
*/
|
|
222
|
+
clickPreventDefault?: boolean;
|
|
216
223
|
/**
|
|
217
224
|
* Custom className
|
|
218
225
|
*/
|
|
@@ -265,6 +272,11 @@ interface CheckboxProps {
|
|
|
265
272
|
* Callback when checked state changes
|
|
266
273
|
*/
|
|
267
274
|
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
275
|
+
/**
|
|
276
|
+
* prevent default click event, if true, change event will not be triggered
|
|
277
|
+
* @default false
|
|
278
|
+
*/
|
|
279
|
+
clickPreventDefault?: boolean;
|
|
268
280
|
/**
|
|
269
281
|
* Custom className
|
|
270
282
|
*/
|
|
@@ -1473,9 +1473,9 @@ var Track = exports.styled.div`
|
|
|
1473
1473
|
var Thumb = exports.styled.div`
|
|
1474
1474
|
position: absolute;
|
|
1475
1475
|
top: 50%;
|
|
1476
|
-
transform: translateY(-50%);
|
|
1477
1476
|
border-style: solid;
|
|
1478
1477
|
box-sizing: border-box;
|
|
1478
|
+
left: 0;
|
|
1479
1479
|
transition: ${({ theme: theme3 }) => theme3.components.switch.transition || "all 0.2s ease"};
|
|
1480
1480
|
|
|
1481
1481
|
${({ $size, $checked, theme: theme3 }) => {
|
|
@@ -1484,12 +1484,17 @@ var Thumb = exports.styled.div`
|
|
|
1484
1484
|
const thumbOffset = sizeConfig.thumb.offset;
|
|
1485
1485
|
const thumbBorderRadius = sizeConfig.thumb.borderRadius;
|
|
1486
1486
|
const thumbBorderWidth = sizeConfig.thumb.borderWidth;
|
|
1487
|
+
const trackWidth = sizeConfig.container.width;
|
|
1488
|
+
const thumbSizeNum = parseFloat(thumbSize);
|
|
1489
|
+
const offsetNum = parseFloat(thumbOffset);
|
|
1490
|
+
const trackWidthNum = parseFloat(trackWidth);
|
|
1491
|
+
const leftPosition = $checked ? `${trackWidthNum - thumbSizeNum - offsetNum}px` : thumbOffset;
|
|
1487
1492
|
return `
|
|
1488
1493
|
width: ${thumbSize};
|
|
1489
1494
|
height: ${thumbSize};
|
|
1490
1495
|
border-radius: ${thumbBorderRadius};
|
|
1491
1496
|
border-width: ${thumbBorderWidth};
|
|
1492
|
-
|
|
1497
|
+
transform: translate(${leftPosition}, -50%);
|
|
1493
1498
|
`;
|
|
1494
1499
|
}}
|
|
1495
1500
|
|
|
@@ -1679,6 +1684,7 @@ var RadioInner = exports.styled.div`
|
|
|
1679
1684
|
}}
|
|
1680
1685
|
`;
|
|
1681
1686
|
var Radio = ({
|
|
1687
|
+
clickPreventDefault = false,
|
|
1682
1688
|
checked: controlledChecked,
|
|
1683
1689
|
defaultChecked = false,
|
|
1684
1690
|
disabled = false,
|
|
@@ -1711,12 +1717,18 @@ var Radio = ({
|
|
|
1711
1717
|
const handleBlur = React3.useCallback(() => {
|
|
1712
1718
|
setIsFocused(false);
|
|
1713
1719
|
}, []);
|
|
1720
|
+
const handleContainerClick = React3.useCallback((e) => {
|
|
1721
|
+
if (clickPreventDefault) {
|
|
1722
|
+
e.preventDefault();
|
|
1723
|
+
}
|
|
1724
|
+
}, []);
|
|
1714
1725
|
return /* @__PURE__ */ React3__default.default.createElement(
|
|
1715
1726
|
RadioContainer,
|
|
1716
1727
|
{
|
|
1717
1728
|
$disabled: disabled,
|
|
1718
1729
|
className,
|
|
1719
|
-
style
|
|
1730
|
+
style,
|
|
1731
|
+
onClick: handleContainerClick
|
|
1720
1732
|
},
|
|
1721
1733
|
/* @__PURE__ */ React3__default.default.createElement(
|
|
1722
1734
|
HiddenInput2,
|
|
@@ -1868,6 +1880,7 @@ var Checkbox = ({
|
|
|
1868
1880
|
name,
|
|
1869
1881
|
id,
|
|
1870
1882
|
onChange,
|
|
1883
|
+
clickPreventDefault = false,
|
|
1871
1884
|
className,
|
|
1872
1885
|
style
|
|
1873
1886
|
}) => {
|
|
@@ -1899,12 +1912,18 @@ var Checkbox = ({
|
|
|
1899
1912
|
const handleBlur = React3.useCallback(() => {
|
|
1900
1913
|
setIsFocused(false);
|
|
1901
1914
|
}, []);
|
|
1915
|
+
const handleContainerClick = React3.useCallback((e) => {
|
|
1916
|
+
if (clickPreventDefault) {
|
|
1917
|
+
e.preventDefault();
|
|
1918
|
+
}
|
|
1919
|
+
}, []);
|
|
1902
1920
|
return /* @__PURE__ */ React3__default.default.createElement(
|
|
1903
1921
|
CheckboxContainer,
|
|
1904
1922
|
{
|
|
1905
1923
|
$disabled: disabled,
|
|
1906
1924
|
className,
|
|
1907
|
-
style
|
|
1925
|
+
style,
|
|
1926
|
+
onClick: handleContainerClick
|
|
1908
1927
|
},
|
|
1909
1928
|
/* @__PURE__ */ React3__default.default.createElement(
|
|
1910
1929
|
HiddenInput3,
|