@zohodesk/components 1.3.5 → 1.4.1

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.
Files changed (34) hide show
  1. package/.cli/config/variables/variableMapping.json +8 -1
  2. package/.cli/propValidation_report.html +1 -1
  3. package/README.md +10 -0
  4. package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +11 -0
  5. package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +11 -0
  6. package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +11 -0
  7. package/es/Provider/LibraryContext.js +7 -3
  8. package/es/deprecated/Switch/Switch.js +94 -0
  9. package/es/deprecated/Switch/props/defaultProps.js +11 -0
  10. package/es/deprecated/Switch/props/propTypes.js +28 -0
  11. package/es/v1/Switch/Switch.js +122 -78
  12. package/es/v1/Switch/__tests__/Switch.spec.js +30 -0
  13. package/es/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +135 -0
  14. package/es/v1/Switch/contants/index.js +24 -0
  15. package/es/v1/Switch/css/Switch_v1.module.css +134 -0
  16. package/es/v1/Switch/css/cssJSLogic.js +48 -0
  17. package/es/v1/Switch/props/defaultProps.js +8 -8
  18. package/es/v1/Switch/props/propTypes.js +30 -22
  19. package/es/v1/Switch/useSwitch.js +33 -0
  20. package/lib/Provider/LibraryContext.js +7 -3
  21. package/lib/deprecated/Switch/Switch.js +108 -0
  22. package/lib/deprecated/Switch/props/defaultProps.js +18 -0
  23. package/lib/deprecated/Switch/props/propTypes.js +39 -0
  24. package/lib/v1/Switch/Switch.js +130 -79
  25. package/lib/v1/Switch/__tests__/Switch.spec.js +37 -0
  26. package/lib/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +135 -0
  27. package/lib/v1/Switch/contants/index.js +34 -0
  28. package/lib/v1/Switch/css/Switch_v1.module.css +134 -0
  29. package/lib/v1/Switch/css/cssJSLogic.js +37 -0
  30. package/lib/v1/Switch/props/defaultProps.js +10 -10
  31. package/lib/v1/Switch/props/propTypes.js +32 -24
  32. package/lib/v1/Switch/useSwitch.js +56 -0
  33. package/package.json +8 -4
  34. package/result.json +1 -1
package/README.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
4
4
 
5
+ # 1.4.1
6
+
7
+ - **Switch(v1)** - labelPlacement top | bottom alignment and hover style issue fixed.
8
+
9
+ # 1.4.0
10
+
11
+ - **Switch(v1)** - Existing v1 Switch moved to depreacated folder and all New component Switch created with required accessibility and customization.
12
+ - Theme entry for component_v1 added.
13
+ - **LibraryContext** - `shouldIndicateSwitchState` key added for Switch component.
14
+
5
15
  # 1.3.5
6
16
 
7
17
  - **AppContainer** - Memory leak issue resolved.
@@ -0,0 +1,11 @@
1
+ [data-mode='dark'] {
2
+ /* switch */
3
+ --zdt_v1_switch_track_on_bg: hsla(133, 48.36%, calc(52.16% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
+ --zdt_v1_switch_track_off_bg: hsla(223, 21.68%, calc(28.04% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
+ --zdt_v1_switch_track_on_hover_bg: hsla(134, 67.66%, calc(32.75% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
6
+ --zdt_v1_switch_track_off_hover_bg: hsla(216, 22.98%, calc(31.57% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
7
+ --zdt_v1_switch_thumb_bg: hsla(217, 23.08%, calc(17.84% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
+ --zdt_v1_switch_onLabel: hsla(217, 23.08%, calc(17.84% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
+ --zdt_v1_switch_offLabel: hsla(217, 13.73%, calc(70.00% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
+ --zdt_v1_switch_offLabel_hover: hsla(210, 7.41%, calc(89.41% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
11
+ }
@@ -0,0 +1,11 @@
1
+ [data-mode='light'] {
2
+ /* switch */
3
+ --zdt_v1_switch_track_on_bg: hsla(133, 63.29%, calc(40.59% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
+ --zdt_v1_switch_track_off_bg: hsla(213, 27.27%, calc(87.06% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
+ --zdt_v1_switch_track_on_hover_bg: hsla(134, 78.63%, calc(25.69% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
6
+ --zdt_v1_switch_track_off_hover_bg: hsla(231, 22.22%, calc(82.35% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
7
+ --zdt_v1_switch_thumb_bg: hsla(0, 0.00%, calc(100.00% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
+ --zdt_v1_switch_onLabel: hsla(0, 0.00%, calc(100.00% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
+ --zdt_v1_switch_offLabel: hsla(220, 10.45%, calc(39.41% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
+ --zdt_v1_switch_offLabel_hover: hsla(0, 0.00%, calc(0.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
11
+ }
@@ -0,0 +1,11 @@
1
+ [data-mode='pureDark'] {
2
+ /* switch */
3
+ --zdt_v1_switch_track_on_bg: hsla(133, 48.36%, calc(52.16% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
+ --zdt_v1_switch_track_off_bg: hsla(0, 0.00%, calc(20.00% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
+ --zdt_v1_switch_track_on_hover_bg: hsla(134, 67.66%, calc(32.75% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
6
+ --zdt_v1_switch_track_off_hover_bg: hsla(0, 0.00%, calc(34.51% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
7
+ --zdt_v1_switch_thumb_bg: hsla(0, 0.00%, calc(12.94% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
+ --zdt_v1_switch_onLabel: hsla(0, 0.00%, calc(12.94% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
+ --zdt_v1_switch_offLabel: hsla(0, 0.00%, calc(60.00% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
+ --zdt_v1_switch_offLabel_hover: hsla(210, 7.41%, calc(89.41% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
11
+ }
@@ -9,13 +9,15 @@ const LibraryContextProvider = _ref => {
9
9
  direction,
10
10
  coloredTagVariant,
11
11
  hasTagColorInheritedToText,
12
+ shouldIndicateSwitchState,
12
13
  children
13
14
  } = _ref;
14
15
  const [value, setValue] = useState({
15
16
  isReducedMotion,
16
17
  direction,
17
18
  coloredTagVariant,
18
- hasTagColorInheritedToText
19
+ hasTagColorInheritedToText,
20
+ shouldIndicateSwitchState
19
21
  });
20
22
 
21
23
  function setGlobalContext(key, data) {
@@ -38,12 +40,14 @@ LibraryContextProvider.propTypes = {
38
40
  isReducedMotion: PropTypes.bool,
39
41
  coloredTagVariant: PropTypes.oneOf(['bold', 'subtle', 'minimal']),
40
42
  hasTagColorInheritedToText: PropTypes.bool,
41
- direction: PropTypes.string
43
+ direction: PropTypes.string,
44
+ shouldIndicateSwitchState: PropTypes.bool
42
45
  };
43
46
  LibraryContextProvider.defaultProps = {
44
47
  isReducedMotion: getLibraryConfig('isReducedMotion'),
45
48
  direction: getLibraryConfig('direction'),
46
49
  coloredTagVariant: 'bold',
47
- hasTagColorInheritedToText: true
50
+ hasTagColorInheritedToText: true,
51
+ shouldIndicateSwitchState: false
48
52
  };
49
53
  export default LibraryContextProvider;
@@ -0,0 +1,94 @@
1
+ import React from 'react';
2
+ import { defaultProps } from "./props/defaultProps";
3
+ import { propTypes } from "./props/propTypes";
4
+ import { Container, Box } from "../../v1/Layout";
5
+ import Label from "../../v1/Label/Label";
6
+ import style from "../../Switch/Switch.module.css";
7
+
8
+ const Switch = props => {
9
+ let {
10
+ id,
11
+ name,
12
+ value,
13
+ checked,
14
+ disabled,
15
+ isReadOnly,
16
+ size,
17
+ text,
18
+ labelSize,
19
+ labelPalette,
20
+ title,
21
+ disableTitle,
22
+ dataId,
23
+ dataSelectorId,
24
+ customClass,
25
+ customProps
26
+ } = props;
27
+
28
+ function onChange(e) {
29
+ const {
30
+ onChange
31
+ } = props;
32
+ onChange && onChange(!checked, e);
33
+ }
34
+
35
+ let {
36
+ SwitchProps = {},
37
+ LabelProps = {}
38
+ } = customProps;
39
+ let {
40
+ customSwitchWrap = '',
41
+ customSwitch = '',
42
+ customSwitchSize = '',
43
+ customLabel = ''
44
+ } = customClass;
45
+ size !== 'small' ? size = 'switch_medium' : size = 'switch_small';
46
+ return /*#__PURE__*/React.createElement(Container, {
47
+ align: "vertical",
48
+ isCover: false,
49
+ alignBox: "row",
50
+ isInline: true,
51
+ className: `${style.container} ${customSwitchWrap} ${disabled ? style.disabled : isReadOnly ? style.readonly : style.effect}`,
52
+ "data-title": disabled ? disableTitle : title,
53
+ "aria-checked": checked,
54
+ role: "switch",
55
+ dataSelectorId: dataSelectorId,
56
+ ...SwitchProps
57
+ }, /*#__PURE__*/React.createElement(Box, {
58
+ className: `${style[size]} ${customSwitchSize}`
59
+ }, /*#__PURE__*/React.createElement("input", {
60
+ type: "checkbox",
61
+ id: id,
62
+ className: `${style.input} ${checked ? style.checked : ''}`,
63
+ name: name,
64
+ value: value,
65
+ checked: checked,
66
+ disabled: disabled,
67
+ readOnly: isReadOnly,
68
+ onClick: !disabled || !isReadOnly ? onChange : null
69
+ }), /*#__PURE__*/React.createElement("label", {
70
+ htmlFor: id,
71
+ "data-id": dataId,
72
+ "data-test-id": dataId,
73
+ className: `${style.label} ${style[`${size}Label`]} ${customSwitch}`,
74
+ tabIndex: isReadOnly || disabled ? '-1' : '0'
75
+ })), text && /*#__PURE__*/React.createElement(Label, {
76
+ text: text,
77
+ palette: labelPalette,
78
+ id: id,
79
+ size: labelSize,
80
+ type: "subtitle",
81
+ onClick: !disabled || !isReadOnly ? onChange : null,
82
+ customClass: customLabel,
83
+ ...LabelProps
84
+ }));
85
+ };
86
+
87
+ Switch.defaultProps = defaultProps;
88
+ Switch.propTypes = propTypes;
89
+ export default Switch; // if (__DOCS__) {
90
+ // Switch.docs = {
91
+ // componentGroup: 'Form Elements',
92
+ // folderName: 'Style Guide'
93
+ // };
94
+ // }
@@ -0,0 +1,11 @@
1
+ export const defaultProps = {
2
+ checked: false,
3
+ disabled: false,
4
+ labelPalette: 'primary',
5
+ labelSize: 'medium',
6
+ size: 'medium',
7
+ isReadOnly: false,
8
+ customClass: {},
9
+ customProps: {},
10
+ dataSelectorId: 'switch'
11
+ };
@@ -0,0 +1,28 @@
1
+ import PropTypes from 'prop-types';
2
+ export const propTypes = {
3
+ checked: PropTypes.bool,
4
+ dataId: PropTypes.string,
5
+ dataSelectorId: PropTypes.string,
6
+ disableTitle: PropTypes.string,
7
+ disabled: PropTypes.bool,
8
+ id: PropTypes.string.isRequired,
9
+ isReadOnly: PropTypes.bool,
10
+ labelPalette: PropTypes.oneOf(['default', 'primary', 'secondary', 'danger', 'mandatory']),
11
+ labelSize: PropTypes.oneOf(['small', 'medium', 'large']),
12
+ name: PropTypes.string,
13
+ onChange: PropTypes.func,
14
+ size: PropTypes.oneOf(['small', 'medium']),
15
+ text: PropTypes.string,
16
+ title: PropTypes.string,
17
+ value: PropTypes.bool,
18
+ customClass: PropTypes.shape({
19
+ customSwitchWrap: PropTypes.string,
20
+ customSwitch: PropTypes.string,
21
+ customSwitchSize: PropTypes.string,
22
+ customLabel: PropTypes.string
23
+ }),
24
+ customProps: PropTypes.shape({
25
+ SwitchProps: PropTypes.object,
26
+ LabelProps: PropTypes.object
27
+ })
28
+ };
@@ -1,94 +1,138 @@
1
- import React from 'react';
2
- import { defaultProps } from "./props/defaultProps";
3
- import { propTypes } from "./props/propTypes";
4
- import { Container, Box } from "../Layout";
5
- import Label from "../Label/Label";
6
- import style from "../../Switch/Switch.module.css";
1
+ import React from 'react'; // props
2
+
3
+ import defaultProps from "./props/defaultProps";
4
+ import propTypes from "./props/propTypes"; // methods
5
+
6
+ import cssJSLogic from "./css/cssJSLogic";
7
+ import { mergeStyle } from '@zohodesk/utils'; // hooks
8
+
9
+ import useSwitch from "./useSwitch"; // constants
10
+
11
+ import { ALIGN_ITEMS, ITEMS_DIRECTION, OFF_LABEL_RADIUS, THUMB_RADIUS } from "./contants"; // components
12
+
13
+ import Flex from '@zohodesk/layout/es/Flex/Flex';
14
+ import Label from "../../Label/Label"; // css
15
+
16
+ import defaultStyle from "./css/Switch_v1.module.css";
7
17
 
8
18
  const Switch = props => {
9
- let {
10
- id,
19
+ const {
11
20
  name,
12
21
  value,
13
- checked,
14
- disabled,
15
- isReadOnly,
22
+ id,
16
23
  size,
17
- text,
24
+ isDisabled,
25
+ isReadOnly,
26
+ hasStateIndication,
27
+ label,
28
+ labelPlacement,
18
29
  labelSize,
19
- labelPalette,
20
30
  title,
21
- disableTitle,
22
- dataId,
23
- dataSelectorId,
24
- customClass,
25
- customProps
31
+ customProps,
32
+ tagAttributes,
33
+ a11yAttributes,
34
+ i18nKeys,
35
+ customId,
36
+ testId,
37
+ customStyle
26
38
  } = props;
27
-
28
- function onChange(e) {
29
- const {
30
- onChange
31
- } = props;
32
- onChange && onChange(!checked, e);
33
- }
34
-
35
- let {
36
- SwitchProps = {},
37
- LabelProps = {}
39
+ const {
40
+ container: customProps_container,
41
+ label: customProps_label
38
42
  } = customProps;
39
- let {
40
- customSwitchWrap = '',
41
- customSwitch = '',
42
- customSwitchSize = '',
43
- customLabel = ''
44
- } = customClass;
45
- size !== 'small' ? size = 'switch_medium' : size = 'switch_small';
46
- return /*#__PURE__*/React.createElement(Container, {
47
- align: "vertical",
48
- isCover: false,
49
- alignBox: "row",
50
- isInline: true,
51
- className: `${style.container} ${customSwitchWrap} ${disabled ? style.disabled : isReadOnly ? style.readonly : style.effect}`,
52
- "data-title": disabled ? disableTitle : title,
53
- "aria-checked": checked,
54
- role: "switch",
55
- dataSelectorId: dataSelectorId,
56
- ...SwitchProps
57
- }, /*#__PURE__*/React.createElement(Box, {
58
- className: `${style[size]} ${customSwitchSize}`
59
- }, /*#__PURE__*/React.createElement("input", {
43
+ const {
44
+ container: tagAttributes_container,
45
+ switch: tagAttributes_switch
46
+ } = tagAttributes;
47
+ const {
48
+ container: a11yAttributes_container,
49
+ switch: a11yAttributes_switch = {},
50
+ label: a11yAttributes_label
51
+ } = a11yAttributes;
52
+ const {
53
+ ariaDisabled = isDisabled,
54
+ ariaLabel,
55
+ ...restA11yAttributes_switch
56
+ } = a11yAttributes_switch;
57
+ const {
58
+ readOnlyAriaLabel: i18n_readOnlyAriaLabel = 'Read Only'
59
+ } = i18nKeys;
60
+ const readOnlyAriaLabel = label ? `${label}, ${i18n_readOnlyAriaLabel}` : i18n_readOnlyAriaLabel;
61
+ const {
62
+ isChecked,
63
+ handleChange
64
+ } = useSwitch(props);
65
+ const style = mergeStyle(defaultStyle, customStyle);
66
+ const {
67
+ containerClass,
68
+ labelClass,
69
+ trackClass,
70
+ trackWrapperClass,
71
+ thumbClass,
72
+ labelIndicationClass
73
+ } = cssJSLogic({
74
+ props: { ...props,
75
+ isChecked
76
+ },
77
+ style
78
+ });
79
+ return /*#__PURE__*/React.createElement(Flex, { ...customProps_container,
80
+ $ui_displayMode: "inline",
81
+ $ui_direction: ITEMS_DIRECTION[labelPlacement],
82
+ $ui_alignItems: ALIGN_ITEMS[labelPlacement],
83
+ $tagAttributes_container: { ...tagAttributes_container,
84
+ 'data-selector-id': customId
85
+ },
86
+ testId: testId,
87
+ customId: customId,
88
+ $ui_className: containerClass,
89
+ $a11yAttributes_container: a11yAttributes_container
90
+ }, label && /*#__PURE__*/React.createElement(Label, { ...customProps_label,
91
+ text: label,
92
+ palette: isDisabled ? 'primary' : 'default',
93
+ size: labelSize,
94
+ htmlFor: id,
95
+ customClass: labelClass,
96
+ a11y: a11yAttributes_label,
97
+ clipped: true,
98
+ title: label
99
+ }), /*#__PURE__*/React.createElement(Flex, {
100
+ $flag_shrink: false,
101
+ $ui_className: trackWrapperClass
102
+ }, /*#__PURE__*/React.createElement("input", { ...tagAttributes_switch,
103
+ ...restA11yAttributes_switch,
60
104
  type: "checkbox",
61
105
  id: id,
62
- className: `${style.input} ${checked ? style.checked : ''}`,
63
106
  name: name,
64
107
  value: value,
65
- checked: checked,
66
- disabled: disabled,
67
- readOnly: isReadOnly,
68
- onClick: !disabled || !isReadOnly ? onChange : null
69
- }), /*#__PURE__*/React.createElement("label", {
70
- htmlFor: id,
71
- "data-id": dataId,
72
- "data-test-id": dataId,
73
- className: `${style.label} ${style[`${size}Label`]} ${customSwitch}`,
74
- tabIndex: isReadOnly || disabled ? '-1' : '0'
75
- })), text && /*#__PURE__*/React.createElement(Label, {
76
- text: text,
77
- palette: labelPalette,
78
- id: id,
79
- size: labelSize,
80
- type: "subtitle",
81
- onClick: !disabled || !isReadOnly ? onChange : null,
82
- customClass: customLabel,
83
- ...LabelProps
84
- }));
108
+ checked: isChecked,
109
+ onChange: handleChange,
110
+ className: trackClass,
111
+ "data-title": title,
112
+ role: "switch",
113
+ "aria-disabled": ariaDisabled,
114
+ "aria-label": isReadOnly ? readOnlyAriaLabel : ariaLabel
115
+ }), /*#__PURE__*/React.createElement("svg", {
116
+ className: thumbClass,
117
+ xmlns: "http://www.w3.org/2000/svg"
118
+ }, /*#__PURE__*/React.createElement("circle", {
119
+ cx: "50%",
120
+ cy: "50%",
121
+ r: THUMB_RADIUS[size]
122
+ })), hasStateIndication ? /*#__PURE__*/React.createElement("svg", {
123
+ className: labelIndicationClass,
124
+ xmlns: "http://www.w3.org/2000/svg"
125
+ }, isChecked ? /*#__PURE__*/React.createElement("rect", {
126
+ width: "100%",
127
+ height: "100%",
128
+ rx: "50%"
129
+ }) : /*#__PURE__*/React.createElement("circle", {
130
+ cx: "50%",
131
+ cy: "50%",
132
+ r: OFF_LABEL_RADIUS[size]
133
+ })) : null));
85
134
  };
86
135
 
136
+ export default Switch;
87
137
  Switch.defaultProps = defaultProps;
88
- Switch.propTypes = propTypes;
89
- export default Switch; // if (__DOCS__) {
90
- // Switch.docs = {
91
- // componentGroup: 'Form Elements',
92
- // folderName: 'Style Guide'
93
- // };
94
- // }
138
+ Switch.propTypes = propTypes;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import Switch from "../Switch";
4
+ describe('Switch', () => {
5
+ test('rendering the defult props', () => {
6
+ const {
7
+ asFragment
8
+ } = render( /*#__PURE__*/React.createElement(Switch, null));
9
+ expect(asFragment()).toMatchSnapshot();
10
+ });
11
+ test('rendering the Switch with Checked', () => {
12
+ const {
13
+ asFragment
14
+ } = render( /*#__PURE__*/React.createElement(Switch, {
15
+ id: "switch",
16
+ isChecked: true
17
+ }));
18
+ expect(asFragment()).toMatchSnapshot();
19
+ });
20
+ test('rendering the Switch with Disabled', () => {
21
+ const {
22
+ asFragment
23
+ } = render( /*#__PURE__*/React.createElement(Switch, {
24
+ id: "switch",
25
+ isChecked: true,
26
+ isDisabled: true
27
+ }));
28
+ expect(asFragment()).toMatchSnapshot();
29
+ });
30
+ });
@@ -0,0 +1,135 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Switch rendering the Switch with Checked 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="inlineFlex row alignItems_center container medium checked enabled"
7
+ data-id="flex"
8
+ data-test-id="flex"
9
+ >
10
+ <div
11
+ class="noShrink trackWrapper"
12
+ data-id="flex"
13
+ data-test-id="flex"
14
+ >
15
+ <input
16
+ checked=""
17
+ class="track"
18
+ id="switch"
19
+ role="switch"
20
+ type="checkbox"
21
+ value=""
22
+ />
23
+ <svg
24
+ class="thumb commonSvg"
25
+ xmlns="http://www.w3.org/2000/svg"
26
+ >
27
+ <circle
28
+ cx="50%"
29
+ cy="50%"
30
+ r="42.85%"
31
+ />
32
+ </svg>
33
+ <svg
34
+ class="onLabel commonSvg"
35
+ xmlns="http://www.w3.org/2000/svg"
36
+ >
37
+ <rect
38
+ height="100%"
39
+ rx="50%"
40
+ width="100%"
41
+ />
42
+ </svg>
43
+ </div>
44
+ </div>
45
+ </DocumentFragment>
46
+ `;
47
+
48
+ exports[`Switch rendering the Switch with Disabled 1`] = `
49
+ <DocumentFragment>
50
+ <div
51
+ class="inlineFlex row alignItems_center container medium checked disabled"
52
+ data-id="flex"
53
+ data-test-id="flex"
54
+ >
55
+ <div
56
+ class="noShrink trackWrapper"
57
+ data-id="flex"
58
+ data-test-id="flex"
59
+ >
60
+ <input
61
+ aria-disabled="true"
62
+ checked=""
63
+ class="track"
64
+ id="switch"
65
+ role="switch"
66
+ type="checkbox"
67
+ value=""
68
+ />
69
+ <svg
70
+ class="thumb commonSvg"
71
+ xmlns="http://www.w3.org/2000/svg"
72
+ >
73
+ <circle
74
+ cx="50%"
75
+ cy="50%"
76
+ r="42.85%"
77
+ />
78
+ </svg>
79
+ <svg
80
+ class="onLabel commonSvg"
81
+ xmlns="http://www.w3.org/2000/svg"
82
+ >
83
+ <rect
84
+ height="100%"
85
+ rx="50%"
86
+ width="100%"
87
+ />
88
+ </svg>
89
+ </div>
90
+ </div>
91
+ </DocumentFragment>
92
+ `;
93
+
94
+ exports[`Switch rendering the defult props 1`] = `
95
+ <DocumentFragment>
96
+ <div
97
+ class="inlineFlex row alignItems_center container medium unChecked enabled"
98
+ data-id="flex"
99
+ data-test-id="flex"
100
+ >
101
+ <div
102
+ class="noShrink trackWrapper"
103
+ data-id="flex"
104
+ data-test-id="flex"
105
+ >
106
+ <input
107
+ class="track"
108
+ role="switch"
109
+ type="checkbox"
110
+ value=""
111
+ />
112
+ <svg
113
+ class="thumb commonSvg"
114
+ xmlns="http://www.w3.org/2000/svg"
115
+ >
116
+ <circle
117
+ cx="50%"
118
+ cy="50%"
119
+ r="42.85%"
120
+ />
121
+ </svg>
122
+ <svg
123
+ class="offLabel commonSvg"
124
+ xmlns="http://www.w3.org/2000/svg"
125
+ >
126
+ <circle
127
+ cx="50%"
128
+ cy="50%"
129
+ r="37.5%"
130
+ />
131
+ </svg>
132
+ </div>
133
+ </div>
134
+ </DocumentFragment>
135
+ `;
@@ -0,0 +1,24 @@
1
+ export const OFF_LABEL_RADIUS = {
2
+ small: '35.7%',
3
+ medium: '37.5%',
4
+ large: '38.9%',
5
+ xlarge: '40%'
6
+ };
7
+ export const THUMB_RADIUS = {
8
+ small: '40%',
9
+ medium: '42.85%',
10
+ large: '44.45%',
11
+ xlarge: '45.45%'
12
+ };
13
+ export const ITEMS_DIRECTION = {
14
+ start: 'row',
15
+ end: 'rowReverse',
16
+ top: 'column',
17
+ bottom: 'columnReverse'
18
+ };
19
+ export const ALIGN_ITEMS = {
20
+ start: 'center',
21
+ end: 'center',
22
+ top: 'start',
23
+ bottom: 'start'
24
+ };