@zohodesk/components 1.0.0-temp-225-1 → 1.0.0-temp-228

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 (29) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +16 -21
  3. package/assets/Appearance/dark/mode/Component_v2_DarkMode.module.css +11 -0
  4. package/assets/Appearance/light/mode/Component_v2_LightMode.module.css +11 -0
  5. package/assets/Appearance/pureDark/mode/Component_v2_PureDarkMode.module.css +11 -0
  6. package/es/ListItem/ListItem.js +3 -12
  7. package/es/ListItem/ListItem.module.css +0 -9
  8. package/es/ListItem/props/propTypes.js +1 -2
  9. package/es/Provider/LibraryContext.js +3 -1
  10. package/es/components-v2/Switch/Switch.js +151 -0
  11. package/es/components-v2/Switch/contants/index.js +12 -0
  12. package/es/components-v2/Switch/css/Switch_v2.module.css +140 -0
  13. package/es/components-v2/Switch/css/cssJSLogic.js +48 -0
  14. package/es/components-v2/Switch/props/defaultProps.js +12 -0
  15. package/es/components-v2/Switch/props/propTypes.js +32 -0
  16. package/es/components-v2/Switch/useSwitch.js +29 -0
  17. package/lib/ListItem/ListItem.js +3 -12
  18. package/lib/ListItem/ListItem.module.css +0 -9
  19. package/lib/ListItem/props/propTypes.js +1 -2
  20. package/lib/Provider/LibraryContext.js +3 -1
  21. package/lib/components-v2/Switch/Switch.js +169 -0
  22. package/lib/components-v2/Switch/contants/index.js +20 -0
  23. package/lib/components-v2/Switch/css/Switch_v2.module.css +140 -0
  24. package/lib/components-v2/Switch/css/cssJSLogic.js +37 -0
  25. package/lib/components-v2/Switch/props/defaultProps.js +19 -0
  26. package/lib/components-v2/Switch/props/propTypes.js +43 -0
  27. package/lib/components-v2/Switch/useSwitch.js +52 -0
  28. package/package.json +4 -3
  29. package/result.json +1 -1
@@ -122,8 +122,7 @@ var ListItem = /*#__PURE__*/function (_React$Component) {
122
122
  a11y = _this$props4.a11y,
123
123
  customClass = _this$props4.customClass,
124
124
  customProps = _this$props4.customProps,
125
- needMultiLineText = _this$props4.needMultiLineText,
126
- secondaryValue = _this$props4.secondaryValue;
125
+ needMultiLineText = _this$props4.needMultiLineText;
127
126
  var _customProps$ListItem = customProps.ListItemProps,
128
127
  ListItemProps = _customProps$ListItem === void 0 ? {} : _customProps$ListItem,
129
128
  _customProps$Containe = customProps.ContainerProps,
@@ -163,12 +162,7 @@ var ListItem = /*#__PURE__*/function (_React$Component) {
163
162
  onMouseEnter: this.handleMouseEnter,
164
163
  eleRef: this.getRef,
165
164
  customProps: ListItemProps
166
- }, ContainerProps), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
167
- flexible: true,
168
- className: _ListItemModule["default"].leftBox
169
- }, /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
170
- className: _ListItemModule["default"].titleBox
171
- }, value ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
165
+ }, ContainerProps), value ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
172
166
  shrink: true,
173
167
  adjust: true,
174
168
  className: needMultiLineText ? _ListItemModule["default"].multiLineValue : _ListItemModule["default"].value
@@ -176,10 +170,7 @@ var ListItem = /*#__PURE__*/function (_React$Component) {
176
170
  shrink: true,
177
171
  adjust: true,
178
172
  className: _ListItemModule["default"].children
179
- }, children) : null), secondaryValue ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
180
- "data-title": isDisabled ? null : secondaryValue,
181
- className: "".concat(_ListItemModule["default"].secondaryField, " ").concat(needMultiLineText ? _ListItemModule["default"].multiLine : _ListItemModule["default"].secondaryValue)
182
- }, secondaryValue) : null), needTick && active ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
173
+ }, children) : null, needTick && active ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
183
174
  className: "".concat(_ListItemModule["default"].tickIcon, " ").concat(tickIconPalette, " ").concat(customTickIcon),
184
175
  "aria-hidden": ariaHidden,
185
176
  dataId: "".concat(dataIdString, "_tickIcon"),
@@ -250,12 +250,3 @@
250
250
  padding-top: var(--zd_size10) ;
251
251
  padding-bottom: var(--zd_size10) ;
252
252
  }
253
-
254
-
255
- .leftBox {
256
- composes: dflex flexcolumn from '../common/common.module.css';
257
- }
258
-
259
- .titleBox {
260
- composes: dflex alignVertical from '../common/common.module.css';
261
- }
@@ -81,8 +81,7 @@ var ListItem_Props = {
81
81
  }),
82
82
  customProps: _propTypes["default"].shape({
83
83
  ListItemProps: _propTypes["default"].object
84
- }),
85
- secondaryValue: _propTypes["default"].string
84
+ })
86
85
  };
87
86
  exports.ListItem_Props = ListItem_Props;
88
87
  var ListItemWithAvatar_Props = (_ListItemWithAvatar_P = {
@@ -44,13 +44,15 @@ var LibraryContextProvider = function LibraryContextProvider(_ref) {
44
44
  direction = _ref.direction,
45
45
  coloredTagVariant = _ref.coloredTagVariant,
46
46
  hasTagColorInheritedToText = _ref.hasTagColorInheritedToText,
47
+ shouldIndicateSwitchState = _ref.shouldIndicateSwitchState,
47
48
  children = _ref.children;
48
49
 
49
50
  var _useState = (0, _react.useState)({
50
51
  isReducedMotion: isReducedMotion,
51
52
  direction: direction,
52
53
  coloredTagVariant: coloredTagVariant,
53
- hasTagColorInheritedToText: hasTagColorInheritedToText
54
+ hasTagColorInheritedToText: hasTagColorInheritedToText,
55
+ shouldIndicateSwitchState: shouldIndicateSwitchState
54
56
  }),
55
57
  _useState2 = _slicedToArray(_useState, 2),
56
58
  value = _useState2[0],
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _defaultProps = _interopRequireDefault(require("./props/defaultProps"));
13
+
14
+ var _propTypes = require("./props/propTypes");
15
+
16
+ var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
17
+
18
+ var _utils = require("@zohodesk/utils");
19
+
20
+ var _useSwitch2 = _interopRequireDefault(require("./useSwitch"));
21
+
22
+ var _contants = require("./contants");
23
+
24
+ var _Flex = _interopRequireDefault(require("@zohodesk/layout/es/Flex/Flex"));
25
+
26
+ var _Label = _interopRequireDefault(require("../../Label/Label"));
27
+
28
+ var _LibraryContextInit = _interopRequireDefault(require("../../Provider/LibraryContextInit"));
29
+
30
+ var _Switch_v2Module = _interopRequireDefault(require("./css/Switch_v2.module.css"));
31
+
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
33
+
34
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
+
36
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
+
38
+ 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); }
39
+
40
+ 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; }
41
+
42
+ 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; }
43
+
44
+ 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; }
45
+
46
+ var Switch = function Switch(props) {
47
+ var name = props.name,
48
+ value = props.value,
49
+ id = props.id,
50
+ size = props.size,
51
+ isCheckedProp = props.isChecked,
52
+ isDefaultChecked = props.isDefaultChecked,
53
+ isDisabled = props.isDisabled,
54
+ isReadOnly = props.isReadOnly,
55
+ onChange = props.onChange,
56
+ hasStateIndication = props.hasStateIndication,
57
+ label = props.label,
58
+ labelPlacement = props.labelPlacement,
59
+ labelSize = props.labelSize,
60
+ title = props.title,
61
+ customProps = props.customProps,
62
+ tagAttributes = props.tagAttributes,
63
+ a11yAttributes = props.a11yAttributes,
64
+ customId = props.customId,
65
+ testId = props.testId,
66
+ customStyle = props.customStyle;
67
+
68
+ var _useContext = (0, _react.useContext)(_LibraryContextInit["default"]),
69
+ shouldIndicateSwitchState = _useContext.shouldIndicateSwitchState;
70
+
71
+ var customProps_container = customProps.container,
72
+ customProps_label = customProps.label;
73
+ var tagAttributes_container = tagAttributes.container,
74
+ tagAttributes_switch = tagAttributes["switch"];
75
+ var a11yAttributes_container = a11yAttributes.container,
76
+ _a11yAttributes$switc = a11yAttributes["switch"],
77
+ a11yAttributes_switch = _a11yAttributes$switc === void 0 ? {} : _a11yAttributes$switc,
78
+ a11yAttributes_label = a11yAttributes.label;
79
+ var _a11yAttributes_switc = a11yAttributes_switch.role,
80
+ role = _a11yAttributes_switc === void 0 ? 'switch' : _a11yAttributes_switc,
81
+ _a11yAttributes_switc2 = a11yAttributes_switch.ariaDisabled,
82
+ ariaDisabled = _a11yAttributes_switc2 === void 0 ? isDisabled : _a11yAttributes_switc2,
83
+ restA11yAttributes_switch = a11yAttributes_switch.restA11yAttributes_switch;
84
+
85
+ var _useSwitch = (0, _useSwitch2["default"])({
86
+ isCheckedProp: isCheckedProp,
87
+ isDefaultChecked: isDefaultChecked,
88
+ onChange: onChange
89
+ }),
90
+ isChecked = _useSwitch.isChecked,
91
+ handleChange = _useSwitch.handleChange;
92
+
93
+ var style = (0, _utils.mergeStyle)(_Switch_v2Module["default"], customStyle);
94
+
95
+ var _cssJSLogic = (0, _cssJSLogic2["default"])({
96
+ props: _objectSpread(_objectSpread({}, props), {}, {
97
+ isChecked: isChecked
98
+ }),
99
+ style: style
100
+ }),
101
+ containerClass = _cssJSLogic.containerClass,
102
+ labelClass = _cssJSLogic.labelClass,
103
+ trackClass = _cssJSLogic.trackClass,
104
+ trackWrapperClass = _cssJSLogic.trackWrapperClass,
105
+ thumbClass = _cssJSLogic.thumbClass,
106
+ labelIndicationClass = _cssJSLogic.labelIndicationClass;
107
+
108
+ return /*#__PURE__*/_react["default"].createElement(_Flex["default"], _extends({
109
+ $ui_displayMode: "inline",
110
+ $ui_direction: labelPlacement === 'left' ? 'row' : 'rowReverse',
111
+ $ui_alignItems: "center",
112
+ $tagAttributes_container: _objectSpread({
113
+ 'data-selector-id': customId
114
+ }, tagAttributes_container),
115
+ testId: testId,
116
+ customId: customId,
117
+ customStyle: {
118
+ inlineFlex: containerClass
119
+ },
120
+ $a11yAttributes_container: a11yAttributes_container
121
+ }, customProps_container), label && /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({
122
+ text: label,
123
+ palette: isDisabled || isReadOnly ? 'primary' : 'default',
124
+ size: labelSize,
125
+ htmlFor: id,
126
+ customClass: labelClass,
127
+ a11y: a11yAttributes_label
128
+ }, customProps_label)), /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
129
+ $flag_shrink: false,
130
+ customStyle: {
131
+ noShrink: trackWrapperClass
132
+ }
133
+ }, /*#__PURE__*/_react["default"].createElement("input", _extends({
134
+ type: "checkbox",
135
+ id: id,
136
+ name: name,
137
+ value: value,
138
+ checked: isChecked,
139
+ readOnly: isReadOnly,
140
+ onChange: !isDisabled && !isReadOnly ? handleChange : null,
141
+ className: trackClass,
142
+ "data-title": title,
143
+ role: role,
144
+ "aria-disabled": ariaDisabled
145
+ }, tagAttributes_switch, restA11yAttributes_switch)), /*#__PURE__*/_react["default"].createElement("svg", {
146
+ className: thumbClass,
147
+ xmlns: "http://www.w3.org/2000/svg"
148
+ }, /*#__PURE__*/_react["default"].createElement("circle", {
149
+ cx: "50%",
150
+ cy: "50%",
151
+ r: _contants.THUMB_RADIUS[size]
152
+ })), hasStateIndication || shouldIndicateSwitchState ? /*#__PURE__*/_react["default"].createElement("svg", {
153
+ className: labelIndicationClass,
154
+ xmlns: "http://www.w3.org/2000/svg"
155
+ }, isChecked ? /*#__PURE__*/_react["default"].createElement("rect", {
156
+ width: "100%",
157
+ height: "100%",
158
+ rx: "50%"
159
+ }) : /*#__PURE__*/_react["default"].createElement("circle", {
160
+ cx: "50%",
161
+ cy: "50%",
162
+ r: _contants.OFF_LABEL_RADIUS[size]
163
+ })) : null));
164
+ };
165
+
166
+ var _default = Switch;
167
+ exports["default"] = _default;
168
+ Switch.defaultProps = _defaultProps["default"];
169
+ Switch.propTypes = _propTypes.propTypes;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.THUMB_RADIUS = exports.OFF_LABEL_RADIUS = 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;
@@ -0,0 +1,140 @@
1
+ .container {
2
+ --switch-cursor: pointer;
3
+ --switch-offLabel-stroke: var(--zdt_v2_switch_offLabel);
4
+ gap: var(--zd_size6) ;
5
+ }
6
+ .small {
7
+ --switch-track-width: var(--zd_size22);
8
+ --switch-track-height: var(--zd_size12);
9
+ --switch-track-border-radius: 8px;
10
+ --switch-thumb-size: 10px;
11
+ --switch-onLabel-height: var(--zd_size6);
12
+ --switch-onLabel-left: var(--zd_size5);
13
+ --switch-offLabel-size: var(--zd_size7);
14
+ --switch-offLabel-right: var(--zd_size2);
15
+ }
16
+ .medium {
17
+ --switch-track-width: var(--zd_size28);
18
+ --switch-track-height: var(--zd_size16);
19
+ --switch-track-border-radius: 16px;
20
+ --switch-thumb-size: 14px;
21
+ --switch-onLabel-height: var(--zd_size8);
22
+ --switch-onLabel-left: var(--zd_size6);
23
+ --switch-offLabel-size: var(--zd_size8);
24
+ --switch-offLabel-right: var(--zd_size3);
25
+ }
26
+ .large {
27
+ --switch-track-width: var(--zd_size34);
28
+ --switch-track-height: var(--zd_size20);
29
+ --switch-track-border-radius: 10px;
30
+ --switch-thumb-size: 18px;
31
+ --switch-onLabel-height: var(--zd_size10);
32
+ --switch-onLabel-left: var(--zd_size7);
33
+ --switch-offLabel-size: var(--zd_size9);
34
+ --switch-offLabel-right: var(--zd_size4);
35
+ }
36
+ .xlarge {
37
+ --switch-track-width: var(--zd_size40);
38
+ --switch-track-height: var(--zd_size24);
39
+ --switch-track-border-radius: 12px;
40
+ --switch-thumb-size: 22px;
41
+ --switch-onLabel-height: var(--zd_size12);
42
+ --switch-onLabel-left: var(--zd_size8);
43
+ --switch-offLabel-size: var(--zd_size10);
44
+ --switch-offLabel-right: var(--zd_size5);
45
+ }
46
+ .checked {
47
+ --switch-track-background-color: var(--zdt_v2_switch_track_on_bg);
48
+ --switch-thumb-translateX-value: calc(var(--switch-track-width) - var(--switch-thumb-size) - 2px)
49
+ }
50
+ .unChecked {
51
+ --switch-track-background-color: var(--zdt_v2_switch_track_off_bg);
52
+ --switch-thumb-translateX-value: 0;
53
+ }
54
+ .disabled, .readonly {
55
+ --switch-cursor: not-allowed;
56
+ }
57
+ .checked.enabled:hover {
58
+ --switch-track-background-color: var(--zdt_v2_switch_track_on_hover_bg);
59
+ }
60
+ .unChecked.enabled:hover {
61
+ --switch-track-background-color: var(--zdt_v2_switch_track_off_hover_bg);
62
+ }
63
+ .enabled:hover {
64
+ --switch-offLabel-stroke: var(--zdt_v2_switch_offLabel_hover);
65
+ }
66
+ .trackWrapper {
67
+ position: relative;
68
+ }
69
+ .disabled .trackWrapper {
70
+ opacity: 0.4;
71
+ }
72
+ .track {
73
+ appearance: none;
74
+ display: block;
75
+ position: relative;
76
+ height: var(--switch-track-height);
77
+ width: var(--switch-track-width);
78
+ margin: 0 ;
79
+ border-radius: var(--switch-track-border-radius);
80
+ background-color: var(--switch-track-background-color);
81
+ cursor: var(--switch-cursor);
82
+ }
83
+ .commonSvg {
84
+ display: block;
85
+ position: absolute;
86
+ pointer-events: none;
87
+ top: 50% ;
88
+ }
89
+ .thumb {
90
+ transition: transform var(--zd_transition2) cubic-bezier(0.4, 0, 0.2, 1);
91
+ fill: var(--zdt_v2_switch_thumb_bg);
92
+ height: var(--switch-thumb-size);
93
+ width: var(--switch-thumb-size);
94
+ transform: translateX(var(--switch-thumb-translateX-value)) translateY(-50%);
95
+ }
96
+ [dir=ltr] .thumb {
97
+ left: var(--zd_size1) ;
98
+ }
99
+ [dir=rtl] .thumb {
100
+ right: var(--zd_size1) ;
101
+ }
102
+ .label {
103
+ cursor: var(--switch-cursor);
104
+ }
105
+ .onLabel {
106
+ height: var(--switch-onLabel-height);
107
+ fill: var(--zdt_v2_switch_onLabel);
108
+ transform: translateY(-50%);
109
+ }
110
+ [dir=ltr] .onLabel {
111
+ left: var(--switch-onLabel-left);
112
+ }
113
+ [dir=rtl] .onLabel {
114
+ right: var(--switch-onLabel-left);
115
+ }
116
+ .offLabel {
117
+ height: var(--switch-offLabel-size);
118
+ width: var(--switch-offLabel-size);
119
+ fill: transparent;
120
+ stroke: var(--switch-offLabel-stroke);
121
+ transform: translateY(-50%);
122
+ }
123
+ [dir=ltr] .offLabel {
124
+ right: var(--switch-offLabel-right);
125
+ }
126
+ [dir=rtl] .offLabel {
127
+ left: var(--switch-offLabel-right);
128
+ }
129
+ .small .onLabel {
130
+ width: 1.2px;
131
+ }
132
+ .medium .onLabel {
133
+ width: 1.4px;
134
+ }
135
+ .large .onLabel {
136
+ width: 1.6px;
137
+ }
138
+ .xlarge .onLabel {
139
+ width: 1.8px;
140
+ }
@@ -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], true), _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
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _default = {
8
+ size: 'medium',
9
+ isDisabled: false,
10
+ isReadOnly: false,
11
+ // hasStateIndication: true,
12
+ labelPlacement: 'left',
13
+ labelSize: 'medium',
14
+ customProps: {},
15
+ tagAttributes: {},
16
+ a11yAttributes: {},
17
+ customStyle: {}
18
+ };
19
+ exports["default"] = _default;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ var _default = {
13
+ name: _propTypes["default"].string,
14
+ value: _propTypes["default"].string,
15
+ id: _propTypes["default"].string,
16
+ size: _propTypes["default"].oneOf(['small', 'medium', 'large', 'xlarge']),
17
+ isChecked: _propTypes["default"].bool,
18
+ isDisabled: _propTypes["default"].bool,
19
+ isReadOnly: _propTypes["default"].bool,
20
+ onChange: _propTypes["default"].func,
21
+ hasStateIndication: _propTypes["default"].bool,
22
+ label: _propTypes["default"].string,
23
+ labelPlacement: _propTypes["default"].oneOf(['left', 'right']),
24
+ labelSize: _propTypes["default"].oneOf(['xsmall', 'small', 'medium', 'large']),
25
+ title: _propTypes["default"].string,
26
+ customProps: _propTypes["default"].shape({
27
+ container: _propTypes["default"].object,
28
+ label: _propTypes["default"].object
29
+ }),
30
+ tagAttributes: _propTypes["default"].shape({
31
+ container: _propTypes["default"].object,
32
+ "switch": _propTypes["default"].object
33
+ }),
34
+ a11yAttributes: _propTypes["default"].shape({
35
+ container: _propTypes["default"].object,
36
+ "switch": _propTypes["default"].object,
37
+ label: _propTypes["default"].object
38
+ }),
39
+ customId: _propTypes["default"].string,
40
+ testId: _propTypes["default"].string,
41
+ customStyle: _propTypes["default"].object
42
+ };
43
+ exports["default"] = _default;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
+
18
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
19
+
20
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
+
22
+ var useSwitch = function useSwitch(props) {
23
+ var isCheckedProp = props.isCheckedProp,
24
+ isDefaultChecked = props.isDefaultChecked,
25
+ onChange = props.onChange;
26
+ var isControlled = isCheckedProp !== undefined;
27
+
28
+ var _useState = (0, _react.useState)(isDefaultChecked),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ internalChecked = _useState2[0],
31
+ setInternalChecked = _useState2[1];
32
+
33
+ var isChecked = isControlled ? isCheckedProp : internalChecked;
34
+
35
+ var handleChange = function handleChange(e) {
36
+ if (!isControlled) {
37
+ setInternalChecked(!isChecked);
38
+ }
39
+
40
+ if (onChange) {
41
+ onChange(!isChecked, e);
42
+ }
43
+ };
44
+
45
+ return {
46
+ isChecked: isChecked,
47
+ handleChange: handleChange
48
+ };
49
+ };
50
+
51
+ var _default = useSwitch;
52
+ exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/components",
3
- "version": "1.0.0-temp-225-1",
3
+ "version": "1.0.0-temp-228",
4
4
  "main": "es/index.js",
5
5
  "module": "es/index.js",
6
6
  "private": false,
@@ -38,7 +38,7 @@
38
38
  "build:css:umd": "npm run clean && npm run init && react-cli build:css:umd",
39
39
  "coverage": "react-cli coverage",
40
40
  "prepare": "npm run init && npm run build && npm run rtl && npm run cssVariableConvert ",
41
- "prepublishOnly": "node prePublish.js && npm run download && npm run css:review && npm run review:props ",
41
+ "prepublishOnly": "node prePublish.js && npm run download",
42
42
  "postpublish": "node postPublish.js",
43
43
  "report": "react-cli publish:report",
44
44
  "test": "react-cli test",
@@ -94,6 +94,7 @@
94
94
  "react-sortable-hoc": "^0.8.3",
95
95
  "@zohodesk/hooks": "2.0.5",
96
96
  "@zohodesk/utils": "1.3.14",
97
- "@zohodesk/a11y": "2.3.4"
97
+ "@zohodesk/a11y": "2.3.4",
98
+ "@zohodesk/layout": "3.1.0"
98
99
  }
99
100
  }