@zohodesk/components 1.0.0-temp-217.5 → 1.0.0-temp-199.9

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 (87) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +9 -0
  3. package/es/DropBox/DropBoxElement/DropBoxElement.js +3 -1
  4. package/es/DropBox/DropBoxElement/__tests__/__snapshots__/DropBoxElement.spec.js.snap +4 -2
  5. package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +56 -53
  6. package/es/DropBox/DropBoxElement/css/cssJSLogic.js +4 -4
  7. package/es/DropBox/__tests__/__snapshots__/DropBox.spec.js.snap +4 -2
  8. package/es/DropDown/__tests__/__snapshots__/DropDown.spec.js.snap +3 -1
  9. package/es/ListItem/ListItem.js +2 -2
  10. package/es/ListItem/ListItem.module.css +15 -2
  11. package/es/ListItem/ListItemWithAvatar.js +3 -3
  12. package/es/ListItem/ListItemWithIcon.js +2 -2
  13. package/es/MultiSelect/AdvancedGroupMultiSelect.js +7 -2
  14. package/es/MultiSelect/MultiSelect.js +7 -2
  15. package/es/MultiSelect/Suggestions.js +14 -5
  16. package/es/MultiSelect/props/defaultProps.js +9 -4
  17. package/es/MultiSelect/props/propTypes.js +9 -3
  18. package/es/Popup/Popup.js +232 -83
  19. package/es/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +4 -2
  20. package/es/Select/GroupSelect.js +5 -1
  21. package/es/Select/SelectWithAvatar.js +7 -2
  22. package/es/Select/SelectWithIcon.js +4 -2
  23. package/es/Select/props/defaultProps.js +2 -1
  24. package/es/Select/props/propTypes.js +4 -2
  25. package/es/common/common.module.css +5 -0
  26. package/es/utils/Common.js +2 -1
  27. package/es/v1/ListItem/ListItem.js +1 -1
  28. package/es/v1/MultiSelect/AdvancedMultiSelect.js +2 -1
  29. package/es/v1/MultiSelect/MultiSelect.js +7 -2
  30. package/es/v1/MultiSelect/Suggestions.js +8 -4
  31. package/es/v1/MultiSelect/props/defaultProps.js +4 -2
  32. package/es/v1/MultiSelect/props/propTypes.js +6 -2
  33. package/es/v1/Select/GroupSelect.js +7 -2
  34. package/es/v1/Select/SelectWithAvatar.js +7 -2
  35. package/es/v1/Select/props/defaultProps.js +4 -2
  36. package/es/v1/Select/props/propTypes.js +6 -2
  37. package/lib/DropBox/DropBoxElement/DropBoxElement.js +3 -1
  38. package/lib/DropBox/DropBoxElement/__tests__/__snapshots__/DropBoxElement.spec.js.snap +4 -2
  39. package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +56 -53
  40. package/lib/DropBox/DropBoxElement/css/cssJSLogic.js +2 -2
  41. package/lib/DropBox/__tests__/__snapshots__/DropBox.spec.js.snap +4 -2
  42. package/lib/DropDown/__tests__/__snapshots__/DropDown.spec.js.snap +3 -1
  43. package/lib/ListItem/ListItem.js +2 -2
  44. package/lib/ListItem/ListItem.module.css +15 -2
  45. package/lib/ListItem/ListItemWithAvatar.js +3 -3
  46. package/lib/ListItem/ListItemWithIcon.js +2 -2
  47. package/lib/MultiSelect/AdvancedGroupMultiSelect.js +7 -3
  48. package/lib/MultiSelect/MultiSelect.js +6 -3
  49. package/lib/MultiSelect/Suggestions.js +12 -5
  50. package/lib/MultiSelect/props/defaultProps.js +9 -4
  51. package/lib/MultiSelect/props/propTypes.js +8 -3
  52. package/lib/Popup/Popup.js +282 -114
  53. package/lib/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +4 -2
  54. package/lib/Select/GroupSelect.js +4 -2
  55. package/lib/Select/SelectWithAvatar.js +8 -3
  56. package/lib/Select/SelectWithIcon.js +5 -3
  57. package/lib/Select/props/defaultProps.js +2 -1
  58. package/lib/Select/props/propTypes.js +4 -2
  59. package/lib/common/common.module.css +5 -0
  60. package/lib/utils/Common.js +5 -1
  61. package/lib/v1/ListItem/ListItem.js +1 -1
  62. package/lib/v1/MultiSelect/AdvancedMultiSelect.js +3 -1
  63. package/lib/v1/MultiSelect/MultiSelect.js +8 -3
  64. package/lib/v1/MultiSelect/Suggestions.js +8 -4
  65. package/lib/v1/MultiSelect/props/defaultProps.js +4 -2
  66. package/lib/v1/MultiSelect/props/propTypes.js +6 -2
  67. package/lib/v1/Select/GroupSelect.js +8 -3
  68. package/lib/v1/Select/SelectWithAvatar.js +8 -3
  69. package/lib/v1/Select/props/defaultProps.js +4 -2
  70. package/lib/v1/Select/props/propTypes.js +6 -2
  71. package/package.json +2 -2
  72. package/result.json +1 -1
  73. package/assets/Appearance/dark/mode/Component_v2_DarkMode.module.css +0 -10
  74. package/assets/Appearance/light/mode/Component_v2_LightMode.module.css +0 -10
  75. package/assets/Appearance/pureDark/mode/Component_v2_PureDarkMode.module.css +0 -10
  76. package/es/components-v2/Switch/Switch.js +0 -124
  77. package/es/components-v2/Switch/contants/index.js +0 -10
  78. package/es/components-v2/Switch/css/Switch_v2.module.css +0 -121
  79. package/es/components-v2/Switch/css/cssJSLogic.js +0 -45
  80. package/es/components-v2/Switch/props/defaultProps.js +0 -19
  81. package/es/components-v2/Switch/props/propTypes.js +0 -27
  82. package/lib/components-v2/Switch/Switch.js +0 -138
  83. package/lib/components-v2/Switch/contants/index.js +0 -18
  84. package/lib/components-v2/Switch/css/Switch_v2.module.css +0 -121
  85. package/lib/components-v2/Switch/css/cssJSLogic.js +0 -36
  86. package/lib/components-v2/Switch/props/defaultProps.js +0 -26
  87. package/lib/components-v2/Switch/props/propTypes.js +0 -38
@@ -1,10 +0,0 @@
1
- [data-mode='dark'] {
2
- /* switch */
3
- --zdt_v2_switch_track_on_bg: hsla(133, 48.36%, calc(52.16% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
- --zdt_v2_switch_track_off_bg: hsla(223, 21.68%, calc(28.04% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
- --zdt_v2_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_v2_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_v2_switch_thumb_bg: hsla(217, 23.08%, calc(17.84% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
- --zdt_v2_switch_on_indication_label: hsla(217, 23.08%, calc(17.84% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
- --zdt_v2_switch_off_indication_label: hsla(217, 13.73%, calc(70.00% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
- }
@@ -1,10 +0,0 @@
1
- [data-mode='light'] {
2
- /* switch */
3
- --zdt_v2_switch_track_on_bg: hsla(133, 63.29%, calc(40.59% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
- --zdt_v2_switch_track_off_bg: hsla(213, 27.27%, calc(87.06% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
- --zdt_v2_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_v2_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_v2_switch_thumb_bg: hsla(0, 0.00%, calc(100.00% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
- --zdt_v2_switch_on_indication_label: hsla(0, 0.00%, calc(100.00% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
- --zdt_v2_switch_off_indication_label: hsla(220, 10.45%, calc(39.41% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
- }
@@ -1,10 +0,0 @@
1
- [data-mode='pureDark'] {
2
- /* switch */
3
- --zdt_v2_switch_track_on_bg: hsla(133, 48.36%, calc(52.16% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
- --zdt_v2_switch_track_off_bg: hsla(0, 0.00%, calc(20.00% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
- --zdt_v2_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_v2_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_v2_switch_thumb_bg: hsla(0, 0.00%, calc(12.94% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
- --zdt_v2_switch_on_indication_label: hsla(0, 0.00%, calc(12.94% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
- --zdt_v2_switch_off_indication_label: hsla(0, 0.00%, calc(60.00% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
- }
@@ -1,124 +0,0 @@
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'; // constants
8
-
9
- import { offLabelRadius, thumbRadius } from "./contants"; // components
10
-
11
- import Flex from '@zohodesk/layout/es/Flex/Flex';
12
- import Label from "../../Label/Label"; // css
13
-
14
- import defaultStyle from "./css/Switch_v2.module.css";
15
-
16
- const Switch = props => {
17
- const {
18
- name,
19
- value,
20
- id,
21
- size,
22
- isChecked,
23
- isDisabled,
24
- isReadOnly,
25
- onChange,
26
- hasOnOffIndication,
27
- labelText,
28
- labelPalette,
29
- labelPlacement,
30
- labelSize,
31
- title,
32
- customProps_container,
33
- customProps_label,
34
- tagAttributes_container,
35
- tagAttributes_switch,
36
- a11yAttributes_container,
37
- a11yAttributes_switch,
38
- a11yAttributes_label,
39
- customId,
40
- testId,
41
- customStyle
42
- } = props;
43
- const {
44
- role = 'switch',
45
- extraA11yAttributes_switch
46
- } = a11yAttributes_switch;
47
- const style = mergeStyle(defaultStyle, customStyle);
48
- const {
49
- containerClass,
50
- labelClass,
51
- trackClass,
52
- trackWrapperClass,
53
- thumbClass,
54
- labelIndicationClass
55
- } = cssJSLogic({
56
- props,
57
- style
58
- });
59
- return /*#__PURE__*/React.createElement(Flex, {
60
- $ui_displayMode: "inline",
61
- $ui_direction: labelPlacement === 'left' ? 'row' : 'rowReverse',
62
- $ui_alignItems: "center",
63
- $tagAttributes_container: {
64
- 'data-selector-id': customId,
65
- ...tagAttributes_container
66
- },
67
- testId: testId,
68
- customId: customId,
69
- customStyle: {
70
- inlineFlex: containerClass
71
- },
72
- $a11yAttributes_container: a11yAttributes_container,
73
- ...customProps_container
74
- }, labelText && /*#__PURE__*/React.createElement(Label, {
75
- text: labelText,
76
- palette: labelPalette,
77
- size: labelSize,
78
- htmlFor: id,
79
- customClass: labelClass,
80
- a11y: a11yAttributes_label,
81
- ...customProps_label
82
- }), /*#__PURE__*/React.createElement(Flex, {
83
- $flag_shrink: false,
84
- customStyle: {
85
- noShrink: trackWrapperClass
86
- }
87
- }, /*#__PURE__*/React.createElement("input", {
88
- type: "checkbox",
89
- id: id,
90
- name: name,
91
- value: value,
92
- checked: isChecked,
93
- disabled: isDisabled,
94
- readOnly: isReadOnly,
95
- onChange: !isDisabled || !isReadOnly ? onChange : null,
96
- role: role,
97
- className: trackClass,
98
- "data-title": title,
99
- ...tagAttributes_switch,
100
- ...extraA11yAttributes_switch
101
- }), /*#__PURE__*/React.createElement("svg", {
102
- className: thumbClass,
103
- xmlns: "http://www.w3.org/2000/svg"
104
- }, /*#__PURE__*/React.createElement("circle", {
105
- cx: "50%",
106
- cy: "50%",
107
- r: thumbRadius[size]
108
- })), hasOnOffIndication ? /*#__PURE__*/React.createElement("svg", {
109
- className: labelIndicationClass,
110
- xmlns: "http://www.w3.org/2000/svg"
111
- }, isChecked ? /*#__PURE__*/React.createElement("rect", {
112
- width: "100%",
113
- height: "100%",
114
- rx: "50%"
115
- }) : /*#__PURE__*/React.createElement("circle", {
116
- cx: "50%",
117
- cy: "50%",
118
- r: offLabelRadius[size]
119
- })) : null));
120
- };
121
-
122
- export default Switch;
123
- Switch.defaultProps = defaultProps;
124
- Switch.propTypes = propTypes;
@@ -1,10 +0,0 @@
1
- export const offLabelRadius = {
2
- small: '35.7%',
3
- medium: '37.5%',
4
- large: '38.9%'
5
- };
6
- export const thumbRadius = {
7
- small: '40%',
8
- medium: '42.85%',
9
- large: '44.45%'
10
- };
@@ -1,121 +0,0 @@
1
- .container {
2
- --switch-cursor: pointer;
3
- gap: var(--zd_size4) ;
4
- }
5
- .small {
6
- --switch-track-width: var(--zd_size22);
7
- --switch-track-height: var(--zd_size12);
8
- --switch-track-border-radius: 8px;
9
- --switch-thumb-size: var(--zd_size10);
10
- --switch-onLabel-height: var(--zd_size6);
11
- --switch-onLabel-left: var(--zd_size5);
12
- --switch-offLabel-size: var(--zd_size7);
13
- --switch-offLabel-right: var(--zd_size2);
14
- }
15
- .medium {
16
- --switch-track-width: var(--zd_size28);
17
- --switch-track-height: var(--zd_size16);
18
- --switch-track-border-radius: 16px;
19
- --switch-thumb-size: var(--zd_size14);
20
- --switch-onLabel-height: var(--zd_size8);
21
- --switch-onLabel-left: var(--zd_size6);
22
- --switch-offLabel-size: var(--zd_size8);
23
- --switch-offLabel-right: var(--zd_size3);
24
- }
25
- .large {
26
- --switch-track-width: var(--zd_size34);
27
- --switch-track-height: var(--zd_size20);
28
- --switch-track-border-radius: 10px;
29
- --switch-thumb-size: var(--zd_size18);
30
- --switch-onLabel-height: var(--zd_size11);
31
- --switch-onLabel-left: var(--zd_size7);
32
- --switch-offLabel-size: var(--zd_size9);
33
- --switch-offLabel-right: var(--zd_size4);
34
- }
35
- .checked {
36
- --switch-track-background-color: var(--zdt_v2_switch_track_on_bg);
37
- --switch-thumb-translateX-value: 0
38
- }
39
- .unChecked {
40
- --switch-track-background-color: var(--zdt_v2_switch_track_off_bg);
41
- --switch-thumb-translateX-value: calc(var(--switch-thumb-size) + 2px - var(--switch-track-width));
42
- }
43
- .disabled {
44
- --switch-cursor: not-allowed;
45
- opacity: 0.4;
46
- }
47
- .trackWrapper {
48
- position: relative;
49
- }
50
- .track {
51
- appearance: none;
52
- display: block;
53
- position: relative;
54
- height: var(--switch-track-height);
55
- width: var(--switch-track-width);
56
- margin: 0 ;
57
- border-radius: var(--switch-track-border-radius);
58
- background-color: var(--switch-track-background-color);
59
- cursor: var(--switch-cursor);
60
- }
61
- .checked .track:not(:disabled):hover {
62
- --switch-track-background-color: var(--zdt_v2_switch_track_on_hover_bg);
63
- }
64
- .unChecked .track:not(:disabled):hover {
65
- --switch-track-background-color: var(--zdt_v2_switch_track_off_hover_bg);
66
- }
67
- .commonSvg {
68
- display: block;
69
- position: absolute;
70
- pointer-events: none;
71
- top: 50% ;
72
- }
73
- .thumb {
74
- transition: transform var(--zd_transition2);
75
- fill: var(--zdt_v2_switch_thumb_bg);
76
- height: var(--switch-thumb-size);
77
- width: var(--switch-thumb-size);
78
- transform: translateX(var(--switch-thumb-translateX-value)) translateY(-50%);
79
- }
80
- [dir=ltr] .thumb {
81
- right: var(--zd_size1) ;
82
- }
83
- [dir=rtl] .thumb {
84
- left: var(--zd_size1) ;
85
- }
86
- .label {
87
- cursor: var(--switch-cursor);
88
- }
89
- .onLabel {
90
- height: var(--switch-onLabel-height);
91
- fill: var(--zdt_v2_switch_on_indication_label);
92
- transform: translateY(-50%);
93
- }
94
- [dir=ltr] .onLabel {
95
- left: var(--switch-onLabel-left);
96
- }
97
- [dir=rtl] .onLabel {
98
- right: var(--switch-onLabel-left);
99
- }
100
- .offLabel {
101
- height: var(--switch-offLabel-size);
102
- width: var(--switch-offLabel-size);
103
- fill: transparent;
104
- stroke: var(--zdt_v2_switch_off_indication_label);
105
- transform: translateY(-50%);
106
- }
107
- [dir=ltr] .offLabel {
108
- right: var(--switch-offLabel-right);
109
- }
110
- [dir=rtl] .offLabel {
111
- left: var(--switch-offLabel-right);
112
- }
113
- .small .onLabel {
114
- width: 1.2px;
115
- }
116
- .medium .onLabel {
117
- width: 1.4px;
118
- }
119
- .large .onLabel {
120
- width: 1.6px;
121
- }
@@ -1,45 +0,0 @@
1
- import compileClassNames from '@zohodesk/utils/es/compileClassNames';
2
- export default function cssJSLogic(_ref) {
3
- let {
4
- props,
5
- style
6
- } = _ref;
7
- const {
8
- size,
9
- isChecked,
10
- isDisabled
11
- } = props;
12
- let containerClass = compileClassNames({
13
- [style.container]: true,
14
- [style[size]]: true,
15
- [style.checked]: isChecked,
16
- [style.unChecked]: !isChecked,
17
- [style.disabled]: isDisabled
18
- });
19
- let trackClass = compileClassNames({
20
- [style.track]: true
21
- });
22
- let labelClass = compileClassNames({
23
- [style.label]: true
24
- });
25
- let trackWrapperClass = compileClassNames({
26
- [style.trackWrapper]: true
27
- });
28
- let thumbClass = compileClassNames({
29
- [style.thumb]: true,
30
- [style.commonSvg]: true
31
- });
32
- let labelIndicationClass = compileClassNames({
33
- [style.onLabel]: isChecked,
34
- [style.offLabel]: !isChecked,
35
- [style.commonSvg]: true
36
- });
37
- return {
38
- containerClass,
39
- trackClass,
40
- labelClass,
41
- trackWrapperClass,
42
- thumbClass,
43
- labelIndicationClass
44
- };
45
- }
@@ -1,19 +0,0 @@
1
- export default {
2
- size: 'medium',
3
- isChecked: false,
4
- isDisabled: false,
5
- isReadOnly: false,
6
- hasOnOffIndication: true,
7
- labelPalette: 'default',
8
- labelPlacement: 'left',
9
- labelSize: 'medium',
10
- customProps_container: {},
11
- customProps_label: {},
12
- tagAttributes_container: {},
13
- tagAttributes_switch: {},
14
- a11yAttributes_container: {},
15
- a11yAttributes_switch: {},
16
- a11yAttributes_label: {},
17
- a11yAttributes: {},
18
- customStyle: {}
19
- };
@@ -1,27 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- export default {
3
- name: PropTypes.string,
4
- value: PropTypes.string,
5
- id: PropTypes.string,
6
- size: PropTypes.oneOf(['small', 'medium', 'large']),
7
- isChecked: PropTypes.bool,
8
- isDisabled: PropTypes.bool,
9
- isReadOnly: PropTypes.bool,
10
- onChange: PropTypes.func,
11
- hasOnOffIndication: PropTypes.bool,
12
- labelText: PropTypes.string,
13
- labelPalette: PropTypes.oneOf(['default', 'primary', 'secondary', 'danger', 'mandatory', 'disable', 'dark']),
14
- labelPlacement: PropTypes.oneOf(['left', 'right']),
15
- labelSize: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large']),
16
- title: PropTypes.string,
17
- customProps_container: PropTypes.object,
18
- customProps_label: PropTypes.object,
19
- tagAttributes_container: PropTypes.object,
20
- tagAttributes_switch: PropTypes.object,
21
- a11yAttributes_container: PropTypes.object,
22
- a11yAttributes_switch: PropTypes.object,
23
- a11yAttributes_label: PropTypes.object,
24
- customId: PropTypes.string,
25
- testId: PropTypes.string,
26
- customStyle: PropTypes.object
27
- };
@@ -1,138 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _defaultProps = _interopRequireDefault(require("./props/defaultProps"));
11
-
12
- var _propTypes = require("./props/propTypes");
13
-
14
- var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
15
-
16
- var _utils = require("@zohodesk/utils");
17
-
18
- var _contants = require("./contants");
19
-
20
- var _Flex = _interopRequireDefault(require("@zohodesk/layout/es/Flex/Flex"));
21
-
22
- var _Label = _interopRequireDefault(require("../../Label/Label"));
23
-
24
- var _Switch_v2Module = _interopRequireDefault(require("./css/Switch_v2.module.css"));
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
-
28
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
29
-
30
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
-
32
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
-
34
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
-
36
- var Switch = function Switch(props) {
37
- var name = props.name,
38
- value = props.value,
39
- id = props.id,
40
- size = props.size,
41
- isChecked = props.isChecked,
42
- isDisabled = props.isDisabled,
43
- isReadOnly = props.isReadOnly,
44
- onChange = props.onChange,
45
- hasOnOffIndication = props.hasOnOffIndication,
46
- labelText = props.labelText,
47
- labelPalette = props.labelPalette,
48
- labelPlacement = props.labelPlacement,
49
- labelSize = props.labelSize,
50
- title = props.title,
51
- customProps_container = props.customProps_container,
52
- customProps_label = props.customProps_label,
53
- tagAttributes_container = props.tagAttributes_container,
54
- tagAttributes_switch = props.tagAttributes_switch,
55
- a11yAttributes_container = props.a11yAttributes_container,
56
- a11yAttributes_switch = props.a11yAttributes_switch,
57
- a11yAttributes_label = props.a11yAttributes_label,
58
- customId = props.customId,
59
- testId = props.testId,
60
- customStyle = props.customStyle;
61
- var _a11yAttributes_switc = a11yAttributes_switch.role,
62
- role = _a11yAttributes_switc === void 0 ? 'switch' : _a11yAttributes_switc,
63
- extraA11yAttributes_switch = a11yAttributes_switch.extraA11yAttributes_switch;
64
- var style = (0, _utils.mergeStyle)(_Switch_v2Module["default"], customStyle);
65
-
66
- var _cssJSLogic = (0, _cssJSLogic2["default"])({
67
- props: props,
68
- style: style
69
- }),
70
- containerClass = _cssJSLogic.containerClass,
71
- labelClass = _cssJSLogic.labelClass,
72
- trackClass = _cssJSLogic.trackClass,
73
- trackWrapperClass = _cssJSLogic.trackWrapperClass,
74
- thumbClass = _cssJSLogic.thumbClass,
75
- labelIndicationClass = _cssJSLogic.labelIndicationClass;
76
-
77
- return /*#__PURE__*/_react["default"].createElement(_Flex["default"], _extends({
78
- $ui_displayMode: "inline",
79
- $ui_direction: labelPlacement === 'left' ? 'row' : 'rowReverse',
80
- $ui_alignItems: "center",
81
- $tagAttributes_container: _objectSpread({
82
- 'data-selector-id': customId
83
- }, tagAttributes_container),
84
- testId: testId,
85
- customId: customId,
86
- customStyle: {
87
- inlineFlex: containerClass
88
- },
89
- $a11yAttributes_container: a11yAttributes_container
90
- }, customProps_container), labelText && /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({
91
- text: labelText,
92
- palette: labelPalette,
93
- size: labelSize,
94
- htmlFor: id,
95
- customClass: labelClass,
96
- a11y: a11yAttributes_label
97
- }, customProps_label)), /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
98
- $flag_shrink: false,
99
- customStyle: {
100
- noShrink: trackWrapperClass
101
- }
102
- }, /*#__PURE__*/_react["default"].createElement("input", _extends({
103
- type: "checkbox",
104
- id: id,
105
- name: name,
106
- value: value,
107
- checked: isChecked,
108
- disabled: isDisabled,
109
- readOnly: isReadOnly,
110
- onChange: !isDisabled || !isReadOnly ? onChange : null,
111
- role: role,
112
- className: trackClass,
113
- "data-title": title
114
- }, tagAttributes_switch, extraA11yAttributes_switch)), /*#__PURE__*/_react["default"].createElement("svg", {
115
- className: thumbClass,
116
- xmlns: "http://www.w3.org/2000/svg"
117
- }, /*#__PURE__*/_react["default"].createElement("circle", {
118
- cx: "50%",
119
- cy: "50%",
120
- r: _contants.thumbRadius[size]
121
- })), hasOnOffIndication ? /*#__PURE__*/_react["default"].createElement("svg", {
122
- className: labelIndicationClass,
123
- xmlns: "http://www.w3.org/2000/svg"
124
- }, isChecked ? /*#__PURE__*/_react["default"].createElement("rect", {
125
- width: "100%",
126
- height: "100%",
127
- rx: "50%"
128
- }) : /*#__PURE__*/_react["default"].createElement("circle", {
129
- cx: "50%",
130
- cy: "50%",
131
- r: _contants.offLabelRadius[size]
132
- })) : null));
133
- };
134
-
135
- var _default = Switch;
136
- exports["default"] = _default;
137
- Switch.defaultProps = _defaultProps["default"];
138
- Switch.propTypes = _propTypes.propTypes;
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.thumbRadius = exports.offLabelRadius = void 0;
7
- var offLabelRadius = {
8
- small: '35.7%',
9
- medium: '37.5%',
10
- large: '38.9%'
11
- };
12
- exports.offLabelRadius = offLabelRadius;
13
- var thumbRadius = {
14
- small: '40%',
15
- medium: '42.85%',
16
- large: '44.45%'
17
- };
18
- exports.thumbRadius = thumbRadius;
@@ -1,121 +0,0 @@
1
- .container {
2
- --switch-cursor: pointer;
3
- gap: var(--zd_size4) ;
4
- }
5
- .small {
6
- --switch-track-width: var(--zd_size22);
7
- --switch-track-height: var(--zd_size12);
8
- --switch-track-border-radius: 8px;
9
- --switch-thumb-size: var(--zd_size10);
10
- --switch-onLabel-height: var(--zd_size6);
11
- --switch-onLabel-left: var(--zd_size5);
12
- --switch-offLabel-size: var(--zd_size7);
13
- --switch-offLabel-right: var(--zd_size2);
14
- }
15
- .medium {
16
- --switch-track-width: var(--zd_size28);
17
- --switch-track-height: var(--zd_size16);
18
- --switch-track-border-radius: 16px;
19
- --switch-thumb-size: var(--zd_size14);
20
- --switch-onLabel-height: var(--zd_size8);
21
- --switch-onLabel-left: var(--zd_size6);
22
- --switch-offLabel-size: var(--zd_size8);
23
- --switch-offLabel-right: var(--zd_size3);
24
- }
25
- .large {
26
- --switch-track-width: var(--zd_size34);
27
- --switch-track-height: var(--zd_size20);
28
- --switch-track-border-radius: 10px;
29
- --switch-thumb-size: var(--zd_size18);
30
- --switch-onLabel-height: var(--zd_size11);
31
- --switch-onLabel-left: var(--zd_size7);
32
- --switch-offLabel-size: var(--zd_size9);
33
- --switch-offLabel-right: var(--zd_size4);
34
- }
35
- .checked {
36
- --switch-track-background-color: var(--zdt_v2_switch_track_on_bg);
37
- --switch-thumb-translateX-value: 0
38
- }
39
- .unChecked {
40
- --switch-track-background-color: var(--zdt_v2_switch_track_off_bg);
41
- --switch-thumb-translateX-value: calc(var(--switch-thumb-size) + 2px - var(--switch-track-width));
42
- }
43
- .disabled {
44
- --switch-cursor: not-allowed;
45
- opacity: 0.4;
46
- }
47
- .trackWrapper {
48
- position: relative;
49
- }
50
- .track {
51
- appearance: none;
52
- display: block;
53
- position: relative;
54
- height: var(--switch-track-height);
55
- width: var(--switch-track-width);
56
- margin: 0 ;
57
- border-radius: var(--switch-track-border-radius);
58
- background-color: var(--switch-track-background-color);
59
- cursor: var(--switch-cursor);
60
- }
61
- .checked .track:not(:disabled):hover {
62
- --switch-track-background-color: var(--zdt_v2_switch_track_on_hover_bg);
63
- }
64
- .unChecked .track:not(:disabled):hover {
65
- --switch-track-background-color: var(--zdt_v2_switch_track_off_hover_bg);
66
- }
67
- .commonSvg {
68
- display: block;
69
- position: absolute;
70
- pointer-events: none;
71
- top: 50% ;
72
- }
73
- .thumb {
74
- transition: transform var(--zd_transition2);
75
- fill: var(--zdt_v2_switch_thumb_bg);
76
- height: var(--switch-thumb-size);
77
- width: var(--switch-thumb-size);
78
- transform: translateX(var(--switch-thumb-translateX-value)) translateY(-50%);
79
- }
80
- [dir=ltr] .thumb {
81
- right: var(--zd_size1) ;
82
- }
83
- [dir=rtl] .thumb {
84
- left: var(--zd_size1) ;
85
- }
86
- .label {
87
- cursor: var(--switch-cursor);
88
- }
89
- .onLabel {
90
- height: var(--switch-onLabel-height);
91
- fill: var(--zdt_v2_switch_on_indication_label);
92
- transform: translateY(-50%);
93
- }
94
- [dir=ltr] .onLabel {
95
- left: var(--switch-onLabel-left);
96
- }
97
- [dir=rtl] .onLabel {
98
- right: var(--switch-onLabel-left);
99
- }
100
- .offLabel {
101
- height: var(--switch-offLabel-size);
102
- width: var(--switch-offLabel-size);
103
- fill: transparent;
104
- stroke: var(--zdt_v2_switch_off_indication_label);
105
- transform: translateY(-50%);
106
- }
107
- [dir=ltr] .offLabel {
108
- right: var(--switch-offLabel-right);
109
- }
110
- [dir=rtl] .offLabel {
111
- left: var(--switch-offLabel-right);
112
- }
113
- .small .onLabel {
114
- width: 1.2px;
115
- }
116
- .medium .onLabel {
117
- width: 1.4px;
118
- }
119
- .large .onLabel {
120
- width: 1.6px;
121
- }