@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
|
*/
|
|
@@ -1461,9 +1461,9 @@ var Track = styled.div`
|
|
|
1461
1461
|
var Thumb = styled.div`
|
|
1462
1462
|
position: absolute;
|
|
1463
1463
|
top: 50%;
|
|
1464
|
-
transform: translateY(-50%);
|
|
1465
1464
|
border-style: solid;
|
|
1466
1465
|
box-sizing: border-box;
|
|
1466
|
+
left: 0;
|
|
1467
1467
|
transition: ${({ theme: theme3 }) => theme3.components.switch.transition || "all 0.2s ease"};
|
|
1468
1468
|
|
|
1469
1469
|
${({ $size, $checked, theme: theme3 }) => {
|
|
@@ -1472,12 +1472,17 @@ var Thumb = styled.div`
|
|
|
1472
1472
|
const thumbOffset = sizeConfig.thumb.offset;
|
|
1473
1473
|
const thumbBorderRadius = sizeConfig.thumb.borderRadius;
|
|
1474
1474
|
const thumbBorderWidth = sizeConfig.thumb.borderWidth;
|
|
1475
|
+
const trackWidth = sizeConfig.container.width;
|
|
1476
|
+
const thumbSizeNum = parseFloat(thumbSize);
|
|
1477
|
+
const offsetNum = parseFloat(thumbOffset);
|
|
1478
|
+
const trackWidthNum = parseFloat(trackWidth);
|
|
1479
|
+
const leftPosition = $checked ? `${trackWidthNum - thumbSizeNum - offsetNum}px` : thumbOffset;
|
|
1475
1480
|
return `
|
|
1476
1481
|
width: ${thumbSize};
|
|
1477
1482
|
height: ${thumbSize};
|
|
1478
1483
|
border-radius: ${thumbBorderRadius};
|
|
1479
1484
|
border-width: ${thumbBorderWidth};
|
|
1480
|
-
|
|
1485
|
+
transform: translate(${leftPosition}, -50%);
|
|
1481
1486
|
`;
|
|
1482
1487
|
}}
|
|
1483
1488
|
|
|
@@ -1667,6 +1672,7 @@ var RadioInner = styled.div`
|
|
|
1667
1672
|
}}
|
|
1668
1673
|
`;
|
|
1669
1674
|
var Radio = ({
|
|
1675
|
+
clickPreventDefault = false,
|
|
1670
1676
|
checked: controlledChecked,
|
|
1671
1677
|
defaultChecked = false,
|
|
1672
1678
|
disabled = false,
|
|
@@ -1699,12 +1705,18 @@ var Radio = ({
|
|
|
1699
1705
|
const handleBlur = useCallback(() => {
|
|
1700
1706
|
setIsFocused(false);
|
|
1701
1707
|
}, []);
|
|
1708
|
+
const handleContainerClick = useCallback((e) => {
|
|
1709
|
+
if (clickPreventDefault) {
|
|
1710
|
+
e.preventDefault();
|
|
1711
|
+
}
|
|
1712
|
+
}, []);
|
|
1702
1713
|
return /* @__PURE__ */ React3.createElement(
|
|
1703
1714
|
RadioContainer,
|
|
1704
1715
|
{
|
|
1705
1716
|
$disabled: disabled,
|
|
1706
1717
|
className,
|
|
1707
|
-
style
|
|
1718
|
+
style,
|
|
1719
|
+
onClick: handleContainerClick
|
|
1708
1720
|
},
|
|
1709
1721
|
/* @__PURE__ */ React3.createElement(
|
|
1710
1722
|
HiddenInput2,
|
|
@@ -1856,6 +1868,7 @@ var Checkbox = ({
|
|
|
1856
1868
|
name,
|
|
1857
1869
|
id,
|
|
1858
1870
|
onChange,
|
|
1871
|
+
clickPreventDefault = false,
|
|
1859
1872
|
className,
|
|
1860
1873
|
style
|
|
1861
1874
|
}) => {
|
|
@@ -1887,12 +1900,18 @@ var Checkbox = ({
|
|
|
1887
1900
|
const handleBlur = useCallback(() => {
|
|
1888
1901
|
setIsFocused(false);
|
|
1889
1902
|
}, []);
|
|
1903
|
+
const handleContainerClick = useCallback((e) => {
|
|
1904
|
+
if (clickPreventDefault) {
|
|
1905
|
+
e.preventDefault();
|
|
1906
|
+
}
|
|
1907
|
+
}, []);
|
|
1890
1908
|
return /* @__PURE__ */ React3.createElement(
|
|
1891
1909
|
CheckboxContainer,
|
|
1892
1910
|
{
|
|
1893
1911
|
$disabled: disabled,
|
|
1894
1912
|
className,
|
|
1895
|
-
style
|
|
1913
|
+
style,
|
|
1914
|
+
onClick: handleContainerClick
|
|
1896
1915
|
},
|
|
1897
1916
|
/* @__PURE__ */ React3.createElement(
|
|
1898
1917
|
HiddenInput3,
|