draft-components 1.10.2 → 1.12.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/slide-over/slide-over-header.cjs +2 -2
- package/cjs/components/switch/switch.cjs +5 -3
- package/css/draft-components-utilities.css +24 -0
- package/css/draft-components.css +55 -28
- package/esm/components/checkbox/checkbox.js +9 -5
- package/esm/components/radio/radio.js +11 -7
- package/esm/components/slide-over/slide-over-header.js +2 -2
- package/esm/components/switch/switch.js +6 -4
- package/package.json +1 -1
- package/types/components/slide-over/slide-over-header.d.ts +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;
|
|
@@ -6,13 +6,13 @@ require('../button/button.cjs');
|
|
|
6
6
|
const iconButton = require('../button/icon-button.cjs');
|
|
7
7
|
const slideOverContext = require('./slide-over-context.cjs');
|
|
8
8
|
|
|
9
|
-
function SlideOverHeader({ className, htmlTitle, title, description, closeButtonAccessibleName, onClickCloseButton, ...props }) {
|
|
9
|
+
function SlideOverHeader({ className, htmlTitle, title, children, description, closeButtonAccessibleName, onClickCloseButton, ...props }) {
|
|
10
10
|
const { titleId, descriptionId, closePanel } = slideOverContext.useSlideOverContext();
|
|
11
11
|
const onCloseButtonClicked = (ev) => {
|
|
12
12
|
closePanel('close-button');
|
|
13
13
|
onClickCloseButton?.(ev);
|
|
14
14
|
};
|
|
15
|
-
return (jsxRuntime.jsxs("div", { className: reactHelpers.classNames('dc-slide-over-header', className), title: htmlTitle, ...props, children: [jsxRuntime.jsxs("div", { className: "dc-slide-over-header__title", children: [jsxRuntime.jsx("h2", { id: titleId, children: title }), jsxRuntime.jsx(iconButton.IconButton, { icon: jsxRuntime.jsx(XMarkIcon, {}), "aria-label": closeButtonAccessibleName, variant: "tinted", size: "xs", onClick: onCloseButtonClicked })] }), description ? (jsxRuntime.jsx("div", { id: descriptionId, className: "dc-slide-over-header__description", children: description })) : null] }));
|
|
15
|
+
return (jsxRuntime.jsxs("div", { className: reactHelpers.classNames('dc-slide-over-header', className), title: htmlTitle, ...props, children: [jsxRuntime.jsxs("div", { className: "dc-slide-over-header__title", children: [jsxRuntime.jsx("h2", { id: titleId, children: title }), jsxRuntime.jsx(iconButton.IconButton, { icon: jsxRuntime.jsx(XMarkIcon, {}), "aria-label": closeButtonAccessibleName, variant: "tinted", size: "xs", onClick: onCloseButtonClicked })] }), description ? (jsxRuntime.jsx("div", { id: descriptionId, className: "dc-slide-over-header__description", children: description })) : null, children ? (jsxRuntime.jsx("div", { className: "dc-slide-over-header__content", children: children })) : null] }));
|
|
16
16
|
}
|
|
17
17
|
function XMarkIcon(props) {
|
|
18
18
|
return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: 20, height: 20, fill: "none", stroke: "currentColor", strokeWidth: 1.5, ...props, children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }));
|
|
@@ -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
|
@@ -1275,6 +1275,12 @@
|
|
|
1275
1275
|
margin-top: 4px;
|
|
1276
1276
|
}
|
|
1277
1277
|
|
|
1278
|
+
.dc-slide-over-header__content {
|
|
1279
|
+
font: var(--dc-text-md);
|
|
1280
|
+
color: var(--dc-slide-over-text-color);
|
|
1281
|
+
margin-top: 8px;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1278
1284
|
.dc-slide-over-body {
|
|
1279
1285
|
color: var(--dc-slide-over-text-color);
|
|
1280
1286
|
overflow: auto;
|
|
@@ -1787,25 +1793,33 @@
|
|
|
1787
1793
|
--dc-switch-focus-ring-color: var(--dc-focus-ring-color);
|
|
1788
1794
|
|
|
1789
1795
|
color-scheme: light;
|
|
1796
|
+
position: relative;
|
|
1790
1797
|
display: inline-flex;
|
|
1798
|
+
flex-shrink: 0;
|
|
1799
|
+
width: var(--dc-switch-width);
|
|
1800
|
+
height: var(--dc-switch-height);
|
|
1801
|
+
text-align: left;
|
|
1791
1802
|
}
|
|
1792
1803
|
|
|
1793
1804
|
.dc-switch__input {
|
|
1794
|
-
-webkit-appearance: none;
|
|
1795
|
-
-moz-appearance: none;
|
|
1796
|
-
appearance: none;
|
|
1797
1805
|
position: absolute;
|
|
1806
|
+
overflow: hidden;
|
|
1807
|
+
width: 1px;
|
|
1808
|
+
height: 1px;
|
|
1809
|
+
margin: -1px;
|
|
1810
|
+
padding: 0;
|
|
1811
|
+
white-space: nowrap;
|
|
1812
|
+
border: 0;
|
|
1813
|
+
clip: rect(0, 0, 0, 0);
|
|
1798
1814
|
}
|
|
1799
1815
|
|
|
1800
1816
|
.dc-switch__track {
|
|
1801
|
-
|
|
1802
|
-
position: relative;
|
|
1803
|
-
display: inline-flex;
|
|
1817
|
+
display: inline-block;
|
|
1804
1818
|
cursor: pointer;
|
|
1805
1819
|
flex: none;
|
|
1806
1820
|
box-sizing: border-box;
|
|
1807
|
-
width:
|
|
1808
|
-
height:
|
|
1821
|
+
width: 100%;
|
|
1822
|
+
height: 100%;
|
|
1809
1823
|
transition-duration: 0.2s;
|
|
1810
1824
|
transition-property: opacity, background-color;
|
|
1811
1825
|
vertical-align: middle;
|
|
@@ -1817,7 +1831,7 @@
|
|
|
1817
1831
|
position: absolute;
|
|
1818
1832
|
top: 0;
|
|
1819
1833
|
left: 0;
|
|
1820
|
-
display: inline-
|
|
1834
|
+
display: inline-block;
|
|
1821
1835
|
align-items: center;
|
|
1822
1836
|
justify-content: center;
|
|
1823
1837
|
width: var(--dc-switch-thumb-size);
|
|
@@ -1837,6 +1851,8 @@
|
|
|
1837
1851
|
.dc-switch__icon {
|
|
1838
1852
|
color: var(--dc-switch-icon-color);
|
|
1839
1853
|
opacity: 0;
|
|
1854
|
+
width: var(--dc-switch-thumb-size);
|
|
1855
|
+
height: var(--dc-switch-thumb-size);
|
|
1840
1856
|
transition: opacity 0.2s;
|
|
1841
1857
|
}
|
|
1842
1858
|
|
|
@@ -1894,26 +1910,28 @@
|
|
|
1894
1910
|
|
|
1895
1911
|
color-scheme: light;
|
|
1896
1912
|
position: relative;
|
|
1897
|
-
display: inline-
|
|
1913
|
+
display: inline-flex;
|
|
1914
|
+
flex-shrink: 0;
|
|
1898
1915
|
width: var(--dc-checkbox-size);
|
|
1899
1916
|
height: var(--dc-checkbox-size);
|
|
1917
|
+
text-align: left;
|
|
1900
1918
|
}
|
|
1901
1919
|
|
|
1902
1920
|
.dc-checkbox__input {
|
|
1903
|
-
-webkit-appearance: none;
|
|
1904
|
-
-moz-appearance: none;
|
|
1905
|
-
appearance: none;
|
|
1906
1921
|
position: absolute;
|
|
1922
|
+
overflow: hidden;
|
|
1923
|
+
width: 1px;
|
|
1924
|
+
height: 1px;
|
|
1925
|
+
margin: -1px;
|
|
1926
|
+
padding: 0;
|
|
1927
|
+
white-space: nowrap;
|
|
1928
|
+
border: 0;
|
|
1929
|
+
clip: rect(0, 0, 0, 0);
|
|
1907
1930
|
}
|
|
1908
1931
|
|
|
1909
1932
|
.dc-checkbox__check {
|
|
1910
|
-
|
|
1911
|
-
position: absolute;
|
|
1912
|
-
display: inline-flex;
|
|
1933
|
+
display: inline-block;
|
|
1913
1934
|
cursor: pointer;
|
|
1914
|
-
flex: none;
|
|
1915
|
-
align-items: center;
|
|
1916
|
-
justify-content: center;
|
|
1917
1935
|
box-sizing: border-box;
|
|
1918
1936
|
width: 100%;
|
|
1919
1937
|
height: 100%;
|
|
@@ -1927,6 +1945,8 @@
|
|
|
1927
1945
|
.dc-checkbox__icon {
|
|
1928
1946
|
color: var(--dc-checkbox-icon-color);
|
|
1929
1947
|
display: none;
|
|
1948
|
+
width: 100%;
|
|
1949
|
+
height: 100%;
|
|
1930
1950
|
}
|
|
1931
1951
|
|
|
1932
1952
|
.dc-checkbox__input:checked + .dc-checkbox__check {
|
|
@@ -1970,24 +1990,29 @@
|
|
|
1970
1990
|
--dc-radio-color-focus-ring: var(--dc-focus-ring-color);
|
|
1971
1991
|
|
|
1972
1992
|
color-scheme: light;
|
|
1993
|
+
position: relative;
|
|
1973
1994
|
display: inline-flex;
|
|
1995
|
+
flex-shrink: 0;
|
|
1996
|
+
width: var(--dc-radio-size);
|
|
1997
|
+
height: var(--dc-radio-size);
|
|
1998
|
+
text-align: left;
|
|
1974
1999
|
}
|
|
1975
2000
|
|
|
1976
2001
|
.dc-radio__input {
|
|
1977
|
-
-webkit-appearance: none;
|
|
1978
|
-
-moz-appearance: none;
|
|
1979
|
-
appearance: none;
|
|
1980
2002
|
position: absolute;
|
|
2003
|
+
overflow: hidden;
|
|
2004
|
+
width: 1px;
|
|
2005
|
+
height: 1px;
|
|
2006
|
+
margin: -1px;
|
|
2007
|
+
padding: 0;
|
|
2008
|
+
white-space: nowrap;
|
|
2009
|
+
border: 0;
|
|
2010
|
+
clip: rect(0, 0, 0, 0);
|
|
1981
2011
|
}
|
|
1982
2012
|
|
|
1983
2013
|
.dc-radio__check {
|
|
1984
|
-
|
|
1985
|
-
position: relative;
|
|
1986
|
-
display: inline-flex;
|
|
2014
|
+
display: inline-block;
|
|
1987
2015
|
cursor: pointer;
|
|
1988
|
-
flex: none;
|
|
1989
|
-
align-items: center;
|
|
1990
|
-
justify-content: center;
|
|
1991
2016
|
box-sizing: border-box;
|
|
1992
2017
|
width: var(--dc-radio-size);
|
|
1993
2018
|
height: var(--dc-radio-size);
|
|
@@ -2001,6 +2026,8 @@
|
|
|
2001
2026
|
.dc-radio__icon {
|
|
2002
2027
|
color: var(--dc-radio-color-icon);
|
|
2003
2028
|
display: none;
|
|
2029
|
+
width: 100%;
|
|
2030
|
+
height: 100%;
|
|
2004
2031
|
}
|
|
2005
2032
|
|
|
2006
2033
|
.dc-radio__input:checked + .dc-radio__check {
|
|
@@ -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 };
|
|
@@ -4,13 +4,13 @@ import '../button/button.js';
|
|
|
4
4
|
import { IconButton } from '../button/icon-button.js';
|
|
5
5
|
import { useSlideOverContext } from './slide-over-context.js';
|
|
6
6
|
|
|
7
|
-
function SlideOverHeader({ className, htmlTitle, title, description, closeButtonAccessibleName, onClickCloseButton, ...props }) {
|
|
7
|
+
function SlideOverHeader({ className, htmlTitle, title, children, description, closeButtonAccessibleName, onClickCloseButton, ...props }) {
|
|
8
8
|
const { titleId, descriptionId, closePanel } = useSlideOverContext();
|
|
9
9
|
const onCloseButtonClicked = (ev) => {
|
|
10
10
|
closePanel('close-button');
|
|
11
11
|
onClickCloseButton?.(ev);
|
|
12
12
|
};
|
|
13
|
-
return (jsxs("div", { className: classNames('dc-slide-over-header', className), title: htmlTitle, ...props, children: [jsxs("div", { className: "dc-slide-over-header__title", children: [jsx("h2", { id: titleId, children: title }), jsx(IconButton, { icon: jsx(XMarkIcon, {}), "aria-label": closeButtonAccessibleName, variant: "tinted", size: "xs", onClick: onCloseButtonClicked })] }), description ? (jsx("div", { id: descriptionId, className: "dc-slide-over-header__description", children: description })) : null] }));
|
|
13
|
+
return (jsxs("div", { className: classNames('dc-slide-over-header', className), title: htmlTitle, ...props, children: [jsxs("div", { className: "dc-slide-over-header__title", children: [jsx("h2", { id: titleId, children: title }), jsx(IconButton, { icon: jsx(XMarkIcon, {}), "aria-label": closeButtonAccessibleName, variant: "tinted", size: "xs", onClick: onCloseButtonClicked })] }), description ? (jsx("div", { id: descriptionId, className: "dc-slide-over-header__description", children: description })) : null, children ? (jsx("div", { className: "dc-slide-over-header__content", children: children })) : null] }));
|
|
14
14
|
}
|
|
15
15
|
function XMarkIcon(props) {
|
|
16
16
|
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: 20, height: 20, fill: "none", stroke: "currentColor", strokeWidth: 1.5, ...props, children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }));
|
|
@@ -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 };
|
package/package.json
CHANGED
|
@@ -8,4 +8,4 @@ export type SlideOverHeaderProps = {
|
|
|
8
8
|
closeButtonAccessibleName?: string;
|
|
9
9
|
onClickCloseButton?: MouseEventHandler<HTMLButtonElement>;
|
|
10
10
|
} & SlideOverHeaderBaseProps;
|
|
11
|
-
export declare function SlideOverHeader({ className, htmlTitle, title, description, closeButtonAccessibleName, onClickCloseButton, ...props }: SlideOverHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function SlideOverHeader({ className, htmlTitle, title, children, description, closeButtonAccessibleName, onClickCloseButton, ...props }: SlideOverHeaderProps): import("react/jsx-runtime").JSX.Element;
|