@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
@@ -7,102 +7,153 @@ exports["default"] = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
- var _defaultProps = require("./props/defaultProps");
10
+ var _defaultProps = _interopRequireDefault(require("./props/defaultProps"));
11
11
 
12
- var _propTypes = require("./props/propTypes");
12
+ var _propTypes = _interopRequireDefault(require("./props/propTypes"));
13
13
 
14
- var _Layout = require("../Layout");
14
+ var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
15
15
 
16
- var _Label = _interopRequireDefault(require("../Label/Label"));
16
+ var _utils = require("@zohodesk/utils");
17
17
 
18
- var _SwitchModule = _interopRequireDefault(require("../../Switch/Switch.module.css"));
18
+ var _useSwitch2 = _interopRequireDefault(require("./useSwitch"));
19
+
20
+ var _contants = require("./contants");
21
+
22
+ var _Flex = _interopRequireDefault(require("@zohodesk/layout/es/Flex/Flex"));
23
+
24
+ var _Label = _interopRequireDefault(require("../../Label/Label"));
25
+
26
+ var _Switch_v1Module = _interopRequireDefault(require("./css/Switch_v1.module.css"));
27
+
28
+ var _excluded = ["ariaDisabled", "ariaLabel"];
19
29
 
20
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
31
 
22
32
  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); }
23
33
 
34
+ 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; }
35
+
36
+ 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; }
37
+
38
+ 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; }
39
+
40
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
41
+
42
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
43
+
24
44
  var Switch = function Switch(props) {
25
- var id = props.id,
26
- name = props.name,
45
+ var name = props.name,
27
46
  value = props.value,
28
- checked = props.checked,
29
- disabled = props.disabled,
30
- isReadOnly = props.isReadOnly,
47
+ id = props.id,
31
48
  size = props.size,
32
- text = props.text,
49
+ isDisabled = props.isDisabled,
50
+ isReadOnly = props.isReadOnly,
51
+ hasStateIndication = props.hasStateIndication,
52
+ label = props.label,
53
+ labelPlacement = props.labelPlacement,
33
54
  labelSize = props.labelSize,
34
- labelPalette = props.labelPalette,
35
55
  title = props.title,
36
- disableTitle = props.disableTitle,
37
- dataId = props.dataId,
38
- dataSelectorId = props.dataSelectorId,
39
- customClass = props.customClass,
40
- customProps = props.customProps;
41
-
42
- function onChange(e) {
43
- var onChange = props.onChange;
44
- onChange && onChange(!checked, e);
45
- }
46
-
47
- var _customProps$SwitchPr = customProps.SwitchProps,
48
- SwitchProps = _customProps$SwitchPr === void 0 ? {} : _customProps$SwitchPr,
49
- _customProps$LabelPro = customProps.LabelProps,
50
- LabelProps = _customProps$LabelPro === void 0 ? {} : _customProps$LabelPro;
51
- var _customClass$customSw = customClass.customSwitchWrap,
52
- customSwitchWrap = _customClass$customSw === void 0 ? '' : _customClass$customSw,
53
- _customClass$customSw2 = customClass.customSwitch,
54
- customSwitch = _customClass$customSw2 === void 0 ? '' : _customClass$customSw2,
55
- _customClass$customSw3 = customClass.customSwitchSize,
56
- customSwitchSize = _customClass$customSw3 === void 0 ? '' : _customClass$customSw3,
57
- _customClass$customLa = customClass.customLabel,
58
- customLabel = _customClass$customLa === void 0 ? '' : _customClass$customLa;
59
- size !== 'small' ? size = 'switch_medium' : size = 'switch_small';
60
- return /*#__PURE__*/_react["default"].createElement(_Layout.Container, _extends({
61
- align: "vertical",
62
- isCover: false,
63
- alignBox: "row",
64
- isInline: true,
65
- className: "".concat(_SwitchModule["default"].container, " ").concat(customSwitchWrap, " ").concat(disabled ? _SwitchModule["default"].disabled : isReadOnly ? _SwitchModule["default"].readonly : _SwitchModule["default"].effect),
66
- "data-title": disabled ? disableTitle : title,
67
- "aria-checked": checked,
68
- role: "switch",
69
- dataSelectorId: dataSelectorId
70
- }, SwitchProps), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
71
- className: "".concat(_SwitchModule["default"][size], " ").concat(customSwitchSize)
72
- }, /*#__PURE__*/_react["default"].createElement("input", {
56
+ customProps = props.customProps,
57
+ tagAttributes = props.tagAttributes,
58
+ a11yAttributes = props.a11yAttributes,
59
+ i18nKeys = props.i18nKeys,
60
+ customId = props.customId,
61
+ testId = props.testId,
62
+ customStyle = props.customStyle;
63
+ var customProps_container = customProps.container,
64
+ customProps_label = customProps.label;
65
+ var tagAttributes_container = tagAttributes.container,
66
+ tagAttributes_switch = tagAttributes["switch"];
67
+ var a11yAttributes_container = a11yAttributes.container,
68
+ _a11yAttributes$switc = a11yAttributes["switch"],
69
+ a11yAttributes_switch = _a11yAttributes$switc === void 0 ? {} : _a11yAttributes$switc,
70
+ a11yAttributes_label = a11yAttributes.label;
71
+
72
+ var _a11yAttributes_switc = a11yAttributes_switch.ariaDisabled,
73
+ ariaDisabled = _a11yAttributes_switc === void 0 ? isDisabled : _a11yAttributes_switc,
74
+ ariaLabel = a11yAttributes_switch.ariaLabel,
75
+ restA11yAttributes_switch = _objectWithoutProperties(a11yAttributes_switch, _excluded);
76
+
77
+ var _i18nKeys$readOnlyAri = i18nKeys.readOnlyAriaLabel,
78
+ i18n_readOnlyAriaLabel = _i18nKeys$readOnlyAri === void 0 ? 'Read Only' : _i18nKeys$readOnlyAri;
79
+ var readOnlyAriaLabel = label ? "".concat(label, ", ").concat(i18n_readOnlyAriaLabel) : i18n_readOnlyAriaLabel;
80
+
81
+ var _useSwitch = (0, _useSwitch2["default"])(props),
82
+ isChecked = _useSwitch.isChecked,
83
+ handleChange = _useSwitch.handleChange;
84
+
85
+ var style = (0, _utils.mergeStyle)(_Switch_v1Module["default"], customStyle);
86
+
87
+ var _cssJSLogic = (0, _cssJSLogic2["default"])({
88
+ props: _objectSpread(_objectSpread({}, props), {}, {
89
+ isChecked: isChecked
90
+ }),
91
+ style: style
92
+ }),
93
+ containerClass = _cssJSLogic.containerClass,
94
+ labelClass = _cssJSLogic.labelClass,
95
+ trackClass = _cssJSLogic.trackClass,
96
+ trackWrapperClass = _cssJSLogic.trackWrapperClass,
97
+ thumbClass = _cssJSLogic.thumbClass,
98
+ labelIndicationClass = _cssJSLogic.labelIndicationClass;
99
+
100
+ return /*#__PURE__*/_react["default"].createElement(_Flex["default"], _extends({}, customProps_container, {
101
+ $ui_displayMode: "inline",
102
+ $ui_direction: _contants.ITEMS_DIRECTION[labelPlacement],
103
+ $ui_alignItems: _contants.ALIGN_ITEMS[labelPlacement],
104
+ $tagAttributes_container: _objectSpread(_objectSpread({}, tagAttributes_container), {}, {
105
+ 'data-selector-id': customId
106
+ }),
107
+ testId: testId,
108
+ customId: customId,
109
+ $ui_className: containerClass,
110
+ $a11yAttributes_container: a11yAttributes_container
111
+ }), label && /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({}, customProps_label, {
112
+ text: label,
113
+ palette: isDisabled ? 'primary' : 'default',
114
+ size: labelSize,
115
+ htmlFor: id,
116
+ customClass: labelClass,
117
+ a11y: a11yAttributes_label,
118
+ clipped: true,
119
+ title: label
120
+ })), /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
121
+ $flag_shrink: false,
122
+ $ui_className: trackWrapperClass
123
+ }, /*#__PURE__*/_react["default"].createElement("input", _extends({}, tagAttributes_switch, restA11yAttributes_switch, {
73
124
  type: "checkbox",
74
125
  id: id,
75
- className: "".concat(_SwitchModule["default"].input, " ").concat(checked ? _SwitchModule["default"].checked : ''),
76
126
  name: name,
77
127
  value: value,
78
- checked: checked,
79
- disabled: disabled,
80
- readOnly: isReadOnly,
81
- onClick: !disabled || !isReadOnly ? onChange : null
82
- }), /*#__PURE__*/_react["default"].createElement("label", {
83
- htmlFor: id,
84
- "data-id": dataId,
85
- "data-test-id": dataId,
86
- className: "".concat(_SwitchModule["default"].label, " ").concat(_SwitchModule["default"]["".concat(size, "Label")], " ").concat(customSwitch),
87
- tabIndex: isReadOnly || disabled ? '-1' : '0'
88
- })), text && /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({
89
- text: text,
90
- palette: labelPalette,
91
- id: id,
92
- size: labelSize,
93
- type: "subtitle",
94
- onClick: !disabled || !isReadOnly ? onChange : null,
95
- customClass: customLabel
96
- }, LabelProps)));
128
+ checked: isChecked,
129
+ onChange: handleChange,
130
+ className: trackClass,
131
+ "data-title": title,
132
+ role: "switch",
133
+ "aria-disabled": ariaDisabled,
134
+ "aria-label": isReadOnly ? readOnlyAriaLabel : ariaLabel
135
+ })), /*#__PURE__*/_react["default"].createElement("svg", {
136
+ className: thumbClass,
137
+ xmlns: "http://www.w3.org/2000/svg"
138
+ }, /*#__PURE__*/_react["default"].createElement("circle", {
139
+ cx: "50%",
140
+ cy: "50%",
141
+ r: _contants.THUMB_RADIUS[size]
142
+ })), hasStateIndication ? /*#__PURE__*/_react["default"].createElement("svg", {
143
+ className: labelIndicationClass,
144
+ xmlns: "http://www.w3.org/2000/svg"
145
+ }, isChecked ? /*#__PURE__*/_react["default"].createElement("rect", {
146
+ width: "100%",
147
+ height: "100%",
148
+ rx: "50%"
149
+ }) : /*#__PURE__*/_react["default"].createElement("circle", {
150
+ cx: "50%",
151
+ cy: "50%",
152
+ r: _contants.OFF_LABEL_RADIUS[size]
153
+ })) : null));
97
154
  };
98
155
 
99
- Switch.defaultProps = _defaultProps.defaultProps;
100
- Switch.propTypes = _propTypes.propTypes;
101
- var _default = Switch; // if (__DOCS__) {
102
- // Switch.docs = {
103
- // componentGroup: 'Form Elements',
104
- // folderName: 'Style Guide'
105
- // };
106
- // }
107
-
108
- exports["default"] = _default;
156
+ var _default = Switch;
157
+ exports["default"] = _default;
158
+ Switch.defaultProps = _defaultProps["default"];
159
+ Switch.propTypes = _propTypes["default"];
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _react2 = require("@testing-library/react");
6
+
7
+ var _Switch = _interopRequireDefault(require("../Switch"));
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+
11
+ describe('Switch', function () {
12
+ test('rendering the defult props', function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], null)),
14
+ asFragment = _render.asFragment;
15
+
16
+ expect(asFragment()).toMatchSnapshot();
17
+ });
18
+ test('rendering the Switch with Checked', function () {
19
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
20
+ id: "switch",
21
+ isChecked: true
22
+ })),
23
+ asFragment = _render2.asFragment;
24
+
25
+ expect(asFragment()).toMatchSnapshot();
26
+ });
27
+ test('rendering the Switch with Disabled', function () {
28
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
29
+ id: "switch",
30
+ isChecked: true,
31
+ isDisabled: true
32
+ })),
33
+ asFragment = _render3.asFragment;
34
+
35
+ expect(asFragment()).toMatchSnapshot();
36
+ });
37
+ });
@@ -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,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.THUMB_RADIUS = exports.OFF_LABEL_RADIUS = exports.ITEMS_DIRECTION = exports.ALIGN_ITEMS = void 0;
7
+ var OFF_LABEL_RADIUS = {
8
+ small: '35.7%',
9
+ medium: '37.5%',
10
+ large: '38.9%',
11
+ xlarge: '40%'
12
+ };
13
+ exports.OFF_LABEL_RADIUS = OFF_LABEL_RADIUS;
14
+ var THUMB_RADIUS = {
15
+ small: '40%',
16
+ medium: '42.85%',
17
+ large: '44.45%',
18
+ xlarge: '45.45%'
19
+ };
20
+ exports.THUMB_RADIUS = THUMB_RADIUS;
21
+ var ITEMS_DIRECTION = {
22
+ start: 'row',
23
+ end: 'rowReverse',
24
+ top: 'column',
25
+ bottom: 'columnReverse'
26
+ };
27
+ exports.ITEMS_DIRECTION = ITEMS_DIRECTION;
28
+ var ALIGN_ITEMS = {
29
+ start: 'center',
30
+ end: 'center',
31
+ top: 'start',
32
+ bottom: 'start'
33
+ };
34
+ exports.ALIGN_ITEMS = ALIGN_ITEMS;
@@ -0,0 +1,134 @@
1
+ .container {
2
+ --local-switch-cursor: pointer;
3
+ --local-switch-offLabel-stroke: var(--zdt_v1_switch_offLabel);
4
+ gap: var(--zd_size6) ;
5
+ }
6
+ .small {
7
+ --local-switch-track-width: var(--zd_size22);
8
+ --local-switch-track-height: var(--zd_size12);
9
+ --local-switch-track-border-radius: 8px;
10
+ --local-switch-thumb-size: var(--zd_size10);
11
+ --local-switch-onLabel-height: var(--zd_size6);
12
+ --local-switch-onLabel-left: var(--zd_size5);
13
+ --local-switch-offLabel-size: var(--zd_size7);
14
+ --local-switch-offLabel-right: var(--zd_size2);
15
+ --local-switch-onLabel-scaleX: 1.2;
16
+ }
17
+ .medium {
18
+ --local-switch-track-width: var(--zd_size28);
19
+ --local-switch-track-height: var(--zd_size16);
20
+ --local-switch-track-border-radius: 16px;
21
+ --local-switch-thumb-size: var(--zd_size14);
22
+ --local-switch-onLabel-height: var(--zd_size8);
23
+ --local-switch-onLabel-left: var(--zd_size6);
24
+ --local-switch-offLabel-size: var(--zd_size8);
25
+ --local-switch-offLabel-right: var(--zd_size3);
26
+ --local-switch-onLabel-scaleX: 1.4;
27
+ }
28
+ .large {
29
+ --local-switch-track-width: var(--zd_size34);
30
+ --local-switch-track-height: var(--zd_size20);
31
+ --local-switch-track-border-radius: 10px;
32
+ --local-switch-thumb-size: var(--zd_size18);
33
+ --local-switch-onLabel-height: var(--zd_size10);
34
+ --local-switch-onLabel-left: var(--zd_size7);
35
+ --local-switch-offLabel-size: var(--zd_size9);
36
+ --local-switch-offLabel-right: var(--zd_size4);
37
+ --local-switch-onLabel-scaleX: 1.6;
38
+ }
39
+ .xlarge {
40
+ --local-switch-track-width: var(--zd_size40);
41
+ --local-switch-track-height: var(--zd_size24);
42
+ --local-switch-track-border-radius: 12px;
43
+ --local-switch-thumb-size: var(--zd_size22);
44
+ --local-switch-onLabel-height: var(--zd_size12);
45
+ --local-switch-onLabel-left: var(--zd_size8);
46
+ --local-switch-offLabel-size: var(--zd_size10);
47
+ --local-switch-offLabel-right: var(--zd_size5);
48
+ --local-switch-onLabel-scaleX: 1.8;
49
+ }
50
+ .disabled, .readonly {
51
+ --local-switch-cursor: not-allowed;
52
+ }
53
+ .checked.enabled > .trackWrapper:hover {
54
+ --local-switch-track-background-color: var(--zdt_v1_switch_track_on_hover_bg);
55
+ }
56
+ .unChecked.enabled > .trackWrapper:hover {
57
+ --local-switch-track-background-color: var(--zdt_v1_switch_track_off_hover_bg);
58
+ }
59
+ .enabled > .trackWrapper:hover {
60
+ --local-switch-offLabel-stroke: var(--zdt_v1_switch_offLabel_hover);
61
+ }
62
+ .trackWrapper {
63
+ position: relative;
64
+ }
65
+ .disabled > .trackWrapper {
66
+ opacity: 0.4;
67
+ }
68
+ .track {
69
+ appearance: none;
70
+ display: block;
71
+ position: relative;
72
+ height: var(--local-switch-track-height);
73
+ width: var(--local-switch-track-width);
74
+ margin: 0 ;
75
+ border-radius: var(--local-switch-track-border-radius);
76
+ background-color: var(--local-switch-track-background-color);
77
+ cursor: var(--local-switch-cursor);
78
+ }
79
+ .commonSvg {
80
+ display: block;
81
+ position: absolute;
82
+ pointer-events: none;
83
+ top: 50% ;
84
+ }
85
+ .thumb {
86
+ transition: transform var(--zd_transition2) cubic-bezier(0.4, 0, 0.2, 1);
87
+ fill: var(--zdt_v1_switch_thumb_bg);
88
+ height: var(--local-switch-thumb-size);
89
+ width: var(--local-switch-thumb-size);
90
+ transform: translateX(var(--local-switch-thumb-translateX)) translateY(-50%);
91
+ }
92
+ [dir=ltr] .thumb {
93
+ left: var(--zd_size1) ;
94
+ }
95
+ [dir=rtl] .thumb {
96
+ right: var(--zd_size1) ;
97
+ }
98
+ .label {
99
+ max-width: 100% ;
100
+ cursor: var(--local-switch-cursor);
101
+ }
102
+ .onLabel {
103
+ height: var(--local-switch-onLabel-height);
104
+ fill: var(--zdt_v1_switch_onLabel);
105
+ width: var(--zd_size1) ;
106
+ transform: translateY(-50%) scaleX(var(--local-switch-onLabel-scaleX));
107
+ }
108
+ [dir=ltr] .onLabel {
109
+ left: var(--local-switch-onLabel-left);
110
+ }
111
+ [dir=rtl] .onLabel {
112
+ right: var(--local-switch-onLabel-left);
113
+ }
114
+ .offLabel {
115
+ height: var(--local-switch-offLabel-size);
116
+ width: var(--local-switch-offLabel-size);
117
+ fill: transparent;
118
+ stroke: var(--local-switch-offLabel-stroke);
119
+ transform: translateY(-50%);
120
+ }
121
+ [dir=ltr] .offLabel {
122
+ right: var(--local-switch-offLabel-right);
123
+ }
124
+ [dir=rtl] .offLabel {
125
+ left: var(--local-switch-offLabel-right);
126
+ }
127
+ .checked {
128
+ --local-switch-track-background-color: var(--zdt_v1_switch_track_on_bg);
129
+ --local-switch-thumb-translateX: calc(var(--local-switch-track-width) - var(--local-switch-thumb-size) - 2px)
130
+ }
131
+ .unChecked {
132
+ --local-switch-track-background-color: var(--zdt_v1_switch_track_off_bg);
133
+ --local-switch-thumb-translateX: 0;
134
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = cssJSLogic;
7
+
8
+ var _compileClassNames7 = _interopRequireDefault(require("@zohodesk/utils/es/compileClassNames"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ 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; }
13
+
14
+ function cssJSLogic(_ref) {
15
+ var _compileClassNames, _compileClassNames5, _compileClassNames6;
16
+
17
+ var props = _ref.props,
18
+ style = _ref.style;
19
+ var size = props.size,
20
+ isChecked = props.isChecked,
21
+ isDisabled = props.isDisabled,
22
+ isReadOnly = props.isReadOnly;
23
+ var containerClass = (0, _compileClassNames7["default"])((_compileClassNames = {}, _defineProperty(_compileClassNames, style.container, true), _defineProperty(_compileClassNames, style[size], !!style[size]), _defineProperty(_compileClassNames, style.checked, isChecked), _defineProperty(_compileClassNames, style.unChecked, !isChecked), _defineProperty(_compileClassNames, style.disabled, isDisabled), _defineProperty(_compileClassNames, style.enabled, !isDisabled), _defineProperty(_compileClassNames, style.readonly, isReadOnly), _compileClassNames));
24
+ var trackClass = (0, _compileClassNames7["default"])(_defineProperty({}, style.track, true));
25
+ var labelClass = (0, _compileClassNames7["default"])(_defineProperty({}, style.label, true));
26
+ var trackWrapperClass = (0, _compileClassNames7["default"])(_defineProperty({}, style.trackWrapper, true));
27
+ var thumbClass = (0, _compileClassNames7["default"])((_compileClassNames5 = {}, _defineProperty(_compileClassNames5, style.thumb, true), _defineProperty(_compileClassNames5, style.commonSvg, true), _compileClassNames5));
28
+ var labelIndicationClass = (0, _compileClassNames7["default"])((_compileClassNames6 = {}, _defineProperty(_compileClassNames6, style.onLabel, isChecked), _defineProperty(_compileClassNames6, style.offLabel, !isChecked), _defineProperty(_compileClassNames6, style.commonSvg, true), _compileClassNames6));
29
+ return {
30
+ containerClass: containerClass,
31
+ trackClass: trackClass,
32
+ labelClass: labelClass,
33
+ trackWrapperClass: trackWrapperClass,
34
+ thumbClass: thumbClass,
35
+ labelIndicationClass: labelIndicationClass
36
+ };
37
+ }
@@ -3,16 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.defaultProps = void 0;
7
- var defaultProps = {
8
- checked: false,
9
- disabled: false,
10
- labelPalette: 'primary',
11
- labelSize: 'medium',
6
+ exports["default"] = void 0;
7
+ var _default = {
12
8
  size: 'medium',
13
- isReadOnly: false,
14
- customClass: {},
9
+ hasStateIndication: true,
10
+ labelPlacement: 'start',
11
+ labelSize: 'medium',
15
12
  customProps: {},
16
- dataSelectorId: 'switch'
13
+ tagAttributes: {},
14
+ a11yAttributes: {},
15
+ i18nKeys: {},
16
+ customStyle: {}
17
17
  };
18
- exports.defaultProps = defaultProps;
18
+ exports["default"] = _default;