draft-components 1.10.1 → 1.11.0
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/cjs/components/checkbox/checkbox.cjs +8 -4
- package/cjs/components/radio/radio.cjs +11 -7
- package/cjs/components/switch/switch.cjs +5 -3
- package/css/draft-components-utilities.css +24 -0
- package/css/draft-components.css +50 -29
- package/esm/components/checkbox/checkbox.js +9 -5
- package/esm/components/radio/radio.js +11 -7
- package/esm/components/switch/switch.js +6 -4
- package/package.json +1 -1
|
@@ -4,13 +4,17 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
const react = require('react');
|
|
5
5
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
const dashIcon = (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", className: "dc-checkbox__icon", "data-testid": "checkbox-dash-icon", children: jsxRuntime.jsx("path", { d: "M6 12H18", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" }) }));
|
|
9
|
-
const Checkbox = react.forwardRef(function Checkbox({ hasMixedState = false, style = {}, className = '', onChange, onToggle, ...props }, ref) {
|
|
7
|
+
const Checkbox = react.forwardRef(function Checkbox({ hasMixedState = false, style, className, onChange, onToggle, ...props }, ref) {
|
|
10
8
|
return (jsxRuntime.jsxs("label", { style: style, className: reactHelpers.classNames('dc-checkbox', className), children: [jsxRuntime.jsx("input", { ...props, ref: ref, type: "checkbox", className: "dc-checkbox__input", onChange: (event) => {
|
|
11
9
|
onChange?.(event);
|
|
12
10
|
onToggle?.(event.target.checked);
|
|
13
|
-
} }), jsxRuntime.jsx("span", { className: "dc-checkbox__check", "data-testid": "checkbox-check", "aria-hidden": true, children: hasMixedState ?
|
|
11
|
+
} }), jsxRuntime.jsx("span", { className: "dc-checkbox__check", "data-testid": "checkbox-check", "aria-hidden": true, children: hasMixedState ? (jsxRuntime.jsx(DashIcon, { className: "dc-checkbox__icon", "data-testid": "checkbox-dash-icon" })) : (jsxRuntime.jsx(CheckIcon, { className: "dc-checkbox__icon", "data-testid": "checkbox-check-icon" })) })] }));
|
|
14
12
|
});
|
|
13
|
+
function CheckIcon(props) {
|
|
14
|
+
return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsxRuntime.jsx("path", { d: "M5 10.4444L9 14L15 6", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
15
|
+
}
|
|
16
|
+
function DashIcon(props) {
|
|
17
|
+
return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsxRuntime.jsx("path", { d: "M5 10H15", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round" }) }));
|
|
18
|
+
}
|
|
15
19
|
|
|
16
20
|
exports.Checkbox = Checkbox;
|
|
@@ -4,21 +4,25 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
const react = require('react');
|
|
5
5
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const Radio = react.forwardRef(function Radio({ icon = 'dot', style = {}, className = '', onChange, onToggle, ...props }, ref) {
|
|
10
|
-
let renderedIcon;
|
|
7
|
+
const Radio = react.forwardRef(function Radio({ icon = 'dot', style, className, onChange, onToggle, ...props }, ref) {
|
|
8
|
+
let iconElement;
|
|
11
9
|
switch (icon) {
|
|
12
10
|
case 'check':
|
|
13
|
-
|
|
11
|
+
iconElement = jsxRuntime.jsx(CheckIcon, { className: "dc-radio__icon", "data-testid": "radio-check-icon" });
|
|
14
12
|
break;
|
|
15
13
|
default:
|
|
16
|
-
|
|
14
|
+
iconElement = jsxRuntime.jsx(DotIcon, { className: "dc-radio__icon", "data-testid": "radio-dot-icon" });
|
|
17
15
|
}
|
|
18
16
|
return (jsxRuntime.jsxs("label", { style: style, className: reactHelpers.classNames('dc-radio', className), children: [jsxRuntime.jsx("input", { ...props, ref: ref, type: "radio", className: "dc-radio__input", onChange: (event) => {
|
|
19
17
|
onChange?.(event);
|
|
20
18
|
onToggle?.(event.target.checked);
|
|
21
|
-
} }), jsxRuntime.jsx("span", { className: "dc-radio__check", "data-testid": "radio-check", "aria-hidden": true, children:
|
|
19
|
+
} }), jsxRuntime.jsx("span", { className: "dc-radio__check", "data-testid": "radio-check", "aria-hidden": true, children: iconElement })] }));
|
|
22
20
|
});
|
|
21
|
+
function CheckIcon(props) {
|
|
22
|
+
return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsxRuntime.jsx("path", { d: "M5 10.4444L9 14L15 6", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
23
|
+
}
|
|
24
|
+
function DotIcon(props) {
|
|
25
|
+
return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsxRuntime.jsx("circle", { cx: 10, cy: 10, r: 4, fill: "currentColor" }) }));
|
|
26
|
+
}
|
|
23
27
|
|
|
24
28
|
exports.Radio = Radio;
|
|
@@ -4,12 +4,14 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
const react = require('react');
|
|
5
5
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
const Switch = react.forwardRef(function Switch({ style = {}, className = '', showCheckIcon = true, onChange, onToggle, ...props }, ref) {
|
|
7
|
+
const Switch = react.forwardRef(function Switch({ showCheckIcon = true, style, className, onChange, onToggle, ...props }, ref) {
|
|
9
8
|
return (jsxRuntime.jsxs("label", { style: style, className: reactHelpers.classNames('dc-switch', className), children: [jsxRuntime.jsx("input", { ...props, ref: ref, className: "dc-switch__input", type: "checkbox", onChange: (event) => {
|
|
10
9
|
onChange?.(event);
|
|
11
10
|
onToggle?.(event.target.checked);
|
|
12
|
-
} }), jsxRuntime.jsx("span", { "data-testid": "switch-track", className: "dc-switch__track", "aria-hidden": true, children: jsxRuntime.jsx("span", { className: "dc-switch__thumb", children: showCheckIcon &&
|
|
11
|
+
} }), jsxRuntime.jsx("span", { "data-testid": "switch-track", className: "dc-switch__track", "aria-hidden": true, children: jsxRuntime.jsx("span", { className: "dc-switch__thumb", children: showCheckIcon && (jsxRuntime.jsx(CheckIcon, { className: "dc-switch__icon", "data-testid": "switch-check-icon" })) }) })] }));
|
|
13
12
|
});
|
|
13
|
+
function CheckIcon(props) {
|
|
14
|
+
return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsxRuntime.jsx("path", { d: "M6 10.353L9 13L13.5 7", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
15
|
+
}
|
|
14
16
|
|
|
15
17
|
exports.Switch = Switch;
|
|
@@ -1645,3 +1645,27 @@
|
|
|
1645
1645
|
border: 0 !important;
|
|
1646
1646
|
clip: rect(0, 0, 0, 0) !important;
|
|
1647
1647
|
}
|
|
1648
|
+
|
|
1649
|
+
.v-align-baseline {
|
|
1650
|
+
vertical-align: baseline;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
.v-align-top {
|
|
1654
|
+
vertical-align: top;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
.v-align-middle {
|
|
1658
|
+
vertical-align: middle;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
.v-align-bottom {
|
|
1662
|
+
vertical-align: bottom;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
.v-align-text-top {
|
|
1666
|
+
vertical-align: text-top;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
.v-align-text-bottom {
|
|
1670
|
+
vertical-align: text-bottom;
|
|
1671
|
+
}
|
package/css/draft-components.css
CHANGED
|
@@ -1787,25 +1787,33 @@
|
|
|
1787
1787
|
--dc-switch-focus-ring-color: var(--dc-focus-ring-color);
|
|
1788
1788
|
|
|
1789
1789
|
color-scheme: light;
|
|
1790
|
+
position: relative;
|
|
1790
1791
|
display: inline-flex;
|
|
1792
|
+
flex-shrink: 0;
|
|
1793
|
+
width: var(--dc-switch-width);
|
|
1794
|
+
height: var(--dc-switch-height);
|
|
1795
|
+
text-align: left;
|
|
1791
1796
|
}
|
|
1792
1797
|
|
|
1793
1798
|
.dc-switch__input {
|
|
1794
|
-
-webkit-appearance: none;
|
|
1795
|
-
-moz-appearance: none;
|
|
1796
|
-
appearance: none;
|
|
1797
1799
|
position: absolute;
|
|
1800
|
+
overflow: hidden;
|
|
1801
|
+
width: 1px;
|
|
1802
|
+
height: 1px;
|
|
1803
|
+
margin: -1px;
|
|
1804
|
+
padding: 0;
|
|
1805
|
+
white-space: nowrap;
|
|
1806
|
+
border: 0;
|
|
1807
|
+
clip: rect(0, 0, 0, 0);
|
|
1798
1808
|
}
|
|
1799
1809
|
|
|
1800
1810
|
.dc-switch__track {
|
|
1801
|
-
|
|
1802
|
-
position: relative;
|
|
1803
|
-
display: inline-flex;
|
|
1811
|
+
display: inline-block;
|
|
1804
1812
|
cursor: pointer;
|
|
1805
1813
|
flex: none;
|
|
1806
1814
|
box-sizing: border-box;
|
|
1807
|
-
width:
|
|
1808
|
-
height:
|
|
1815
|
+
width: 100%;
|
|
1816
|
+
height: 100%;
|
|
1809
1817
|
transition-duration: 0.2s;
|
|
1810
1818
|
transition-property: opacity, background-color;
|
|
1811
1819
|
vertical-align: middle;
|
|
@@ -1817,7 +1825,7 @@
|
|
|
1817
1825
|
position: absolute;
|
|
1818
1826
|
top: 0;
|
|
1819
1827
|
left: 0;
|
|
1820
|
-
display: inline-
|
|
1828
|
+
display: inline-block;
|
|
1821
1829
|
align-items: center;
|
|
1822
1830
|
justify-content: center;
|
|
1823
1831
|
width: var(--dc-switch-thumb-size);
|
|
@@ -1837,6 +1845,8 @@
|
|
|
1837
1845
|
.dc-switch__icon {
|
|
1838
1846
|
color: var(--dc-switch-icon-color);
|
|
1839
1847
|
opacity: 0;
|
|
1848
|
+
width: var(--dc-switch-thumb-size);
|
|
1849
|
+
height: var(--dc-switch-thumb-size);
|
|
1840
1850
|
transition: opacity 0.2s;
|
|
1841
1851
|
}
|
|
1842
1852
|
|
|
@@ -1894,26 +1904,28 @@
|
|
|
1894
1904
|
|
|
1895
1905
|
color-scheme: light;
|
|
1896
1906
|
position: relative;
|
|
1897
|
-
display: inline-
|
|
1907
|
+
display: inline-flex;
|
|
1908
|
+
flex-shrink: 0;
|
|
1898
1909
|
width: var(--dc-checkbox-size);
|
|
1899
1910
|
height: var(--dc-checkbox-size);
|
|
1911
|
+
text-align: left;
|
|
1900
1912
|
}
|
|
1901
1913
|
|
|
1902
1914
|
.dc-checkbox__input {
|
|
1903
|
-
-webkit-appearance: none;
|
|
1904
|
-
-moz-appearance: none;
|
|
1905
|
-
appearance: none;
|
|
1906
1915
|
position: absolute;
|
|
1916
|
+
overflow: hidden;
|
|
1917
|
+
width: 1px;
|
|
1918
|
+
height: 1px;
|
|
1919
|
+
margin: -1px;
|
|
1920
|
+
padding: 0;
|
|
1921
|
+
white-space: nowrap;
|
|
1922
|
+
border: 0;
|
|
1923
|
+
clip: rect(0, 0, 0, 0);
|
|
1907
1924
|
}
|
|
1908
1925
|
|
|
1909
1926
|
.dc-checkbox__check {
|
|
1910
|
-
|
|
1911
|
-
position: absolute;
|
|
1912
|
-
display: inline-flex;
|
|
1927
|
+
display: inline-block;
|
|
1913
1928
|
cursor: pointer;
|
|
1914
|
-
flex: none;
|
|
1915
|
-
align-items: center;
|
|
1916
|
-
justify-content: center;
|
|
1917
1929
|
box-sizing: border-box;
|
|
1918
1930
|
width: 100%;
|
|
1919
1931
|
height: 100%;
|
|
@@ -1927,6 +1939,8 @@
|
|
|
1927
1939
|
.dc-checkbox__icon {
|
|
1928
1940
|
color: var(--dc-checkbox-icon-color);
|
|
1929
1941
|
display: none;
|
|
1942
|
+
width: 100%;
|
|
1943
|
+
height: 100%;
|
|
1930
1944
|
}
|
|
1931
1945
|
|
|
1932
1946
|
.dc-checkbox__input:checked + .dc-checkbox__check {
|
|
@@ -1970,24 +1984,29 @@
|
|
|
1970
1984
|
--dc-radio-color-focus-ring: var(--dc-focus-ring-color);
|
|
1971
1985
|
|
|
1972
1986
|
color-scheme: light;
|
|
1987
|
+
position: relative;
|
|
1973
1988
|
display: inline-flex;
|
|
1989
|
+
flex-shrink: 0;
|
|
1990
|
+
width: var(--dc-radio-size);
|
|
1991
|
+
height: var(--dc-radio-size);
|
|
1992
|
+
text-align: left;
|
|
1974
1993
|
}
|
|
1975
1994
|
|
|
1976
1995
|
.dc-radio__input {
|
|
1977
|
-
-webkit-appearance: none;
|
|
1978
|
-
-moz-appearance: none;
|
|
1979
|
-
appearance: none;
|
|
1980
1996
|
position: absolute;
|
|
1997
|
+
overflow: hidden;
|
|
1998
|
+
width: 1px;
|
|
1999
|
+
height: 1px;
|
|
2000
|
+
margin: -1px;
|
|
2001
|
+
padding: 0;
|
|
2002
|
+
white-space: nowrap;
|
|
2003
|
+
border: 0;
|
|
2004
|
+
clip: rect(0, 0, 0, 0);
|
|
1981
2005
|
}
|
|
1982
2006
|
|
|
1983
2007
|
.dc-radio__check {
|
|
1984
|
-
|
|
1985
|
-
position: relative;
|
|
1986
|
-
display: inline-flex;
|
|
2008
|
+
display: inline-block;
|
|
1987
2009
|
cursor: pointer;
|
|
1988
|
-
flex: none;
|
|
1989
|
-
align-items: center;
|
|
1990
|
-
justify-content: center;
|
|
1991
2010
|
box-sizing: border-box;
|
|
1992
2011
|
width: var(--dc-radio-size);
|
|
1993
2012
|
height: var(--dc-radio-size);
|
|
@@ -2001,6 +2020,8 @@
|
|
|
2001
2020
|
.dc-radio__icon {
|
|
2002
2021
|
color: var(--dc-radio-color-icon);
|
|
2003
2022
|
display: none;
|
|
2023
|
+
width: 100%;
|
|
2024
|
+
height: 100%;
|
|
2004
2025
|
}
|
|
2005
2026
|
|
|
2006
2027
|
.dc-radio__input:checked + .dc-radio__check {
|
|
@@ -3937,7 +3958,6 @@
|
|
|
3937
3958
|
}
|
|
3938
3959
|
|
|
3939
3960
|
.dc-filtered-search__filters {
|
|
3940
|
-
z-index: var(--dc-overlay-z-index);
|
|
3941
3961
|
display: flex;
|
|
3942
3962
|
flex-grow: 1;
|
|
3943
3963
|
flex-wrap: wrap;
|
|
@@ -3984,6 +4004,7 @@
|
|
|
3984
4004
|
.dc-filtered-search__list-box {
|
|
3985
4005
|
font-size: var(--dc-filtered-search-font-size);
|
|
3986
4006
|
position: absolute;
|
|
4007
|
+
z-index: var(--dc-overlay-z-index);
|
|
3987
4008
|
top: calc(100% + 8px);
|
|
3988
4009
|
left: 0;
|
|
3989
4010
|
box-sizing: border-box;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const dashIcon = (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", className: "dc-checkbox__icon", "data-testid": "checkbox-dash-icon", children: jsx("path", { d: "M6 12H18", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" }) }));
|
|
7
|
-
const Checkbox = forwardRef(function Checkbox({ hasMixedState = false, style = {}, className = '', onChange, onToggle, ...props }, ref) {
|
|
5
|
+
const Checkbox = forwardRef(function Checkbox({ hasMixedState = false, style, className, onChange, onToggle, ...props }, ref) {
|
|
8
6
|
return (jsxs("label", { style: style, className: classNames('dc-checkbox', className), children: [jsx("input", { ...props, ref: ref, type: "checkbox", className: "dc-checkbox__input", onChange: (event) => {
|
|
9
7
|
onChange?.(event);
|
|
10
8
|
onToggle?.(event.target.checked);
|
|
11
|
-
} }), jsx("span", { className: "dc-checkbox__check", "data-testid": "checkbox-check", "aria-hidden": true, children: hasMixedState ?
|
|
9
|
+
} }), jsx("span", { className: "dc-checkbox__check", "data-testid": "checkbox-check", "aria-hidden": true, children: hasMixedState ? (jsx(DashIcon, { className: "dc-checkbox__icon", "data-testid": "checkbox-dash-icon" })) : (jsx(CheckIcon, { className: "dc-checkbox__icon", "data-testid": "checkbox-check-icon" })) })] }));
|
|
12
10
|
});
|
|
11
|
+
function CheckIcon(props) {
|
|
12
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsx("path", { d: "M5 10.4444L9 14L15 6", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
13
|
+
}
|
|
14
|
+
function DashIcon(props) {
|
|
15
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsx("path", { d: "M5 10H15", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round" }) }));
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
export { Checkbox };
|
|
@@ -2,21 +2,25 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const Radio = forwardRef(function Radio({ icon = 'dot', style = {}, className = '', onChange, onToggle, ...props }, ref) {
|
|
8
|
-
let renderedIcon;
|
|
5
|
+
const Radio = forwardRef(function Radio({ icon = 'dot', style, className, onChange, onToggle, ...props }, ref) {
|
|
6
|
+
let iconElement;
|
|
9
7
|
switch (icon) {
|
|
10
8
|
case 'check':
|
|
11
|
-
|
|
9
|
+
iconElement = jsx(CheckIcon, { className: "dc-radio__icon", "data-testid": "radio-check-icon" });
|
|
12
10
|
break;
|
|
13
11
|
default:
|
|
14
|
-
|
|
12
|
+
iconElement = jsx(DotIcon, { className: "dc-radio__icon", "data-testid": "radio-dot-icon" });
|
|
15
13
|
}
|
|
16
14
|
return (jsxs("label", { style: style, className: classNames('dc-radio', className), children: [jsx("input", { ...props, ref: ref, type: "radio", className: "dc-radio__input", onChange: (event) => {
|
|
17
15
|
onChange?.(event);
|
|
18
16
|
onToggle?.(event.target.checked);
|
|
19
|
-
} }), jsx("span", { className: "dc-radio__check", "data-testid": "radio-check", "aria-hidden": true, children:
|
|
17
|
+
} }), jsx("span", { className: "dc-radio__check", "data-testid": "radio-check", "aria-hidden": true, children: iconElement })] }));
|
|
20
18
|
});
|
|
19
|
+
function CheckIcon(props) {
|
|
20
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsx("path", { d: "M5 10.4444L9 14L15 6", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
21
|
+
}
|
|
22
|
+
function DotIcon(props) {
|
|
23
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsx("circle", { cx: 10, cy: 10, r: 4, fill: "currentColor" }) }));
|
|
24
|
+
}
|
|
21
25
|
|
|
22
26
|
export { Radio };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const Switch = forwardRef(function Switch({ style = {}, className = '', showCheckIcon = true, onChange, onToggle, ...props }, ref) {
|
|
5
|
+
const Switch = forwardRef(function Switch({ showCheckIcon = true, style, className, onChange, onToggle, ...props }, ref) {
|
|
7
6
|
return (jsxs("label", { style: style, className: classNames('dc-switch', className), children: [jsx("input", { ...props, ref: ref, className: "dc-switch__input", type: "checkbox", onChange: (event) => {
|
|
8
7
|
onChange?.(event);
|
|
9
8
|
onToggle?.(event.target.checked);
|
|
10
|
-
} }), jsx("span", { "data-testid": "switch-track", className: "dc-switch__track", "aria-hidden": true, children: jsx("span", { className: "dc-switch__thumb", children: showCheckIcon &&
|
|
9
|
+
} }), jsx("span", { "data-testid": "switch-track", className: "dc-switch__track", "aria-hidden": true, children: jsx("span", { className: "dc-switch__thumb", children: showCheckIcon && (jsx(CheckIcon, { className: "dc-switch__icon", "data-testid": "switch-check-icon" })) }) })] }));
|
|
11
10
|
});
|
|
11
|
+
function CheckIcon(props) {
|
|
12
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: jsx("path", { d: "M6 10.353L9 13L13.5 7", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
13
|
+
}
|
|
12
14
|
|
|
13
15
|
export { Switch };
|