@zohodesk/components 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cli/config/variables/variableMapping.json +8 -1
- package/.cli/propValidation_report.html +1 -1
- package/README.md +9 -0
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +11 -0
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +11 -0
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +11 -0
- package/es/AppContainer/AppContainer.js +5 -4
- package/es/Provider/LibraryContext.js +7 -3
- package/es/deprecated/Switch/Switch.js +94 -0
- package/es/deprecated/Switch/props/defaultProps.js +11 -0
- package/es/deprecated/Switch/props/propTypes.js +28 -0
- package/es/v1/Switch/Switch.js +120 -78
- package/es/v1/Switch/__tests__/Switch.spec.js +30 -0
- package/es/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +137 -0
- package/es/v1/Switch/contants/index.js +18 -0
- package/es/v1/Switch/css/Switch_v1.module.css +133 -0
- package/es/v1/Switch/css/cssJSLogic.js +48 -0
- package/es/v1/Switch/props/defaultProps.js +10 -7
- package/es/v1/Switch/props/propTypes.js +30 -22
- package/es/v1/Switch/useSwitch.js +33 -0
- package/lib/AppContainer/AppContainer.js +7 -6
- package/lib/Provider/LibraryContext.js +7 -3
- package/lib/deprecated/Switch/Switch.js +108 -0
- package/lib/deprecated/Switch/props/defaultProps.js +18 -0
- package/lib/deprecated/Switch/props/propTypes.js +39 -0
- package/lib/v1/Switch/Switch.js +128 -79
- package/lib/v1/Switch/__tests__/Switch.spec.js +37 -0
- package/lib/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +137 -0
- package/lib/v1/Switch/contants/index.js +27 -0
- package/lib/v1/Switch/css/Switch_v1.module.css +133 -0
- package/lib/v1/Switch/css/cssJSLogic.js +37 -0
- package/lib/v1/Switch/props/defaultProps.js +12 -9
- package/lib/v1/Switch/props/propTypes.js +32 -24
- package/lib/v1/Switch/useSwitch.js +56 -0
- package/package.json +6 -2
- package/result.json +1 -1
package/lib/v1/Switch/Switch.js
CHANGED
|
@@ -7,102 +7,151 @@ 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
|
|
14
|
+
var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _utils = require("@zohodesk/utils");
|
|
17
17
|
|
|
18
|
-
var
|
|
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
|
|
26
|
-
name = props.name,
|
|
45
|
+
var name = props.name,
|
|
27
46
|
value = props.value,
|
|
28
|
-
|
|
29
|
-
disabled = props.disabled,
|
|
30
|
-
isReadOnly = props.isReadOnly,
|
|
47
|
+
id = props.id,
|
|
31
48
|
size = props.size,
|
|
32
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
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.LABEL_PLACEMENT[labelPlacement],
|
|
103
|
+
$ui_alignItems: "center",
|
|
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
|
+
})), /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
|
|
119
|
+
$flag_shrink: false,
|
|
120
|
+
$ui_className: trackWrapperClass
|
|
121
|
+
}, /*#__PURE__*/_react["default"].createElement("input", _extends({}, tagAttributes_switch, restA11yAttributes_switch, {
|
|
73
122
|
type: "checkbox",
|
|
74
123
|
id: id,
|
|
75
|
-
className: "".concat(_SwitchModule["default"].input, " ").concat(checked ? _SwitchModule["default"].checked : ''),
|
|
76
124
|
name: name,
|
|
77
125
|
value: value,
|
|
78
|
-
checked:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
className:
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
126
|
+
checked: isChecked,
|
|
127
|
+
onChange: handleChange,
|
|
128
|
+
className: trackClass,
|
|
129
|
+
"data-title": title,
|
|
130
|
+
role: "switch",
|
|
131
|
+
"aria-disabled": ariaDisabled,
|
|
132
|
+
"aria-label": isReadOnly ? readOnlyAriaLabel : ariaLabel
|
|
133
|
+
})), /*#__PURE__*/_react["default"].createElement("svg", {
|
|
134
|
+
className: thumbClass,
|
|
135
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
136
|
+
}, /*#__PURE__*/_react["default"].createElement("circle", {
|
|
137
|
+
cx: "50%",
|
|
138
|
+
cy: "50%",
|
|
139
|
+
r: _contants.THUMB_RADIUS[size]
|
|
140
|
+
})), hasStateIndication ? /*#__PURE__*/_react["default"].createElement("svg", {
|
|
141
|
+
className: labelIndicationClass,
|
|
142
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
143
|
+
}, isChecked ? /*#__PURE__*/_react["default"].createElement("rect", {
|
|
144
|
+
width: "100%",
|
|
145
|
+
height: "100%",
|
|
146
|
+
rx: "50%"
|
|
147
|
+
}) : /*#__PURE__*/_react["default"].createElement("circle", {
|
|
148
|
+
cx: "50%",
|
|
149
|
+
cy: "50%",
|
|
150
|
+
r: _contants.OFF_LABEL_RADIUS[size]
|
|
151
|
+
})) : null));
|
|
97
152
|
};
|
|
98
153
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// componentGroup: 'Form Elements',
|
|
104
|
-
// folderName: 'Style Guide'
|
|
105
|
-
// };
|
|
106
|
-
// }
|
|
107
|
-
|
|
108
|
-
exports["default"] = _default;
|
|
154
|
+
var _default = Switch;
|
|
155
|
+
exports["default"] = _default;
|
|
156
|
+
Switch.defaultProps = _defaultProps["default"];
|
|
157
|
+
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,137 @@
|
|
|
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
|
+
aria-disabled="false"
|
|
17
|
+
checked=""
|
|
18
|
+
class="track"
|
|
19
|
+
id="switch"
|
|
20
|
+
role="switch"
|
|
21
|
+
type="checkbox"
|
|
22
|
+
value=""
|
|
23
|
+
/>
|
|
24
|
+
<svg
|
|
25
|
+
class="thumb commonSvg"
|
|
26
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
+
>
|
|
28
|
+
<circle
|
|
29
|
+
cx="50%"
|
|
30
|
+
cy="50%"
|
|
31
|
+
r="42.85%"
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
<svg
|
|
35
|
+
class="onLabel commonSvg"
|
|
36
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
37
|
+
>
|
|
38
|
+
<rect
|
|
39
|
+
height="100%"
|
|
40
|
+
rx="50%"
|
|
41
|
+
width="100%"
|
|
42
|
+
/>
|
|
43
|
+
</svg>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</DocumentFragment>
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
exports[`Switch rendering the Switch with Disabled 1`] = `
|
|
50
|
+
<DocumentFragment>
|
|
51
|
+
<div
|
|
52
|
+
class="inlineFlex row alignItems_center container medium checked disabled"
|
|
53
|
+
data-id="flex"
|
|
54
|
+
data-test-id="flex"
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
class="noShrink trackWrapper"
|
|
58
|
+
data-id="flex"
|
|
59
|
+
data-test-id="flex"
|
|
60
|
+
>
|
|
61
|
+
<input
|
|
62
|
+
aria-disabled="true"
|
|
63
|
+
checked=""
|
|
64
|
+
class="track"
|
|
65
|
+
id="switch"
|
|
66
|
+
role="switch"
|
|
67
|
+
type="checkbox"
|
|
68
|
+
value=""
|
|
69
|
+
/>
|
|
70
|
+
<svg
|
|
71
|
+
class="thumb commonSvg"
|
|
72
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
73
|
+
>
|
|
74
|
+
<circle
|
|
75
|
+
cx="50%"
|
|
76
|
+
cy="50%"
|
|
77
|
+
r="42.85%"
|
|
78
|
+
/>
|
|
79
|
+
</svg>
|
|
80
|
+
<svg
|
|
81
|
+
class="onLabel commonSvg"
|
|
82
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
83
|
+
>
|
|
84
|
+
<rect
|
|
85
|
+
height="100%"
|
|
86
|
+
rx="50%"
|
|
87
|
+
width="100%"
|
|
88
|
+
/>
|
|
89
|
+
</svg>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</DocumentFragment>
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
exports[`Switch rendering the defult props 1`] = `
|
|
96
|
+
<DocumentFragment>
|
|
97
|
+
<div
|
|
98
|
+
class="inlineFlex row alignItems_center container medium unChecked enabled"
|
|
99
|
+
data-id="flex"
|
|
100
|
+
data-test-id="flex"
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
class="noShrink trackWrapper"
|
|
104
|
+
data-id="flex"
|
|
105
|
+
data-test-id="flex"
|
|
106
|
+
>
|
|
107
|
+
<input
|
|
108
|
+
aria-disabled="false"
|
|
109
|
+
class="track"
|
|
110
|
+
role="switch"
|
|
111
|
+
type="checkbox"
|
|
112
|
+
value=""
|
|
113
|
+
/>
|
|
114
|
+
<svg
|
|
115
|
+
class="thumb commonSvg"
|
|
116
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
117
|
+
>
|
|
118
|
+
<circle
|
|
119
|
+
cx="50%"
|
|
120
|
+
cy="50%"
|
|
121
|
+
r="42.85%"
|
|
122
|
+
/>
|
|
123
|
+
</svg>
|
|
124
|
+
<svg
|
|
125
|
+
class="offLabel commonSvg"
|
|
126
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
127
|
+
>
|
|
128
|
+
<circle
|
|
129
|
+
cx="50%"
|
|
130
|
+
cy="50%"
|
|
131
|
+
r="37.5%"
|
|
132
|
+
/>
|
|
133
|
+
</svg>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</DocumentFragment>
|
|
137
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.THUMB_RADIUS = exports.OFF_LABEL_RADIUS = exports.LABEL_PLACEMENT = 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 LABEL_PLACEMENT = {
|
|
22
|
+
start: 'row',
|
|
23
|
+
end: 'rowReverse',
|
|
24
|
+
top: 'column',
|
|
25
|
+
bottom: 'columnReverse'
|
|
26
|
+
};
|
|
27
|
+
exports.LABEL_PLACEMENT = LABEL_PLACEMENT;
|
|
@@ -0,0 +1,133 @@
|
|
|
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:hover {
|
|
54
|
+
--local-switch-track-background-color: var(--zdt_v1_switch_track_on_hover_bg);
|
|
55
|
+
}
|
|
56
|
+
.unChecked.enabled:hover {
|
|
57
|
+
--local-switch-track-background-color: var(--zdt_v1_switch_track_off_hover_bg);
|
|
58
|
+
}
|
|
59
|
+
.enabled: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
|
+
cursor: var(--local-switch-cursor);
|
|
100
|
+
}
|
|
101
|
+
.onLabel {
|
|
102
|
+
height: var(--local-switch-onLabel-height);
|
|
103
|
+
fill: var(--zdt_v1_switch_onLabel);
|
|
104
|
+
width: var(--zd_size1) ;
|
|
105
|
+
transform: translateY(-50%) scaleX(var(--local-switch-onLabel-scaleX));
|
|
106
|
+
}
|
|
107
|
+
[dir=ltr] .onLabel {
|
|
108
|
+
left: var(--local-switch-onLabel-left);
|
|
109
|
+
}
|
|
110
|
+
[dir=rtl] .onLabel {
|
|
111
|
+
right: var(--local-switch-onLabel-left);
|
|
112
|
+
}
|
|
113
|
+
.offLabel {
|
|
114
|
+
height: var(--local-switch-offLabel-size);
|
|
115
|
+
width: var(--local-switch-offLabel-size);
|
|
116
|
+
fill: transparent;
|
|
117
|
+
stroke: var(--local-switch-offLabel-stroke);
|
|
118
|
+
transform: translateY(-50%);
|
|
119
|
+
}
|
|
120
|
+
[dir=ltr] .offLabel {
|
|
121
|
+
right: var(--local-switch-offLabel-right);
|
|
122
|
+
}
|
|
123
|
+
[dir=rtl] .offLabel {
|
|
124
|
+
left: var(--local-switch-offLabel-right);
|
|
125
|
+
}
|
|
126
|
+
.checked {
|
|
127
|
+
--local-switch-track-background-color: var(--zdt_v1_switch_track_on_bg);
|
|
128
|
+
--local-switch-thumb-translateX: calc(var(--local-switch-track-width) - var(--local-switch-thumb-size) - 2px)
|
|
129
|
+
}
|
|
130
|
+
.unChecked {
|
|
131
|
+
--local-switch-track-background-color: var(--zdt_v1_switch_track_off_bg);
|
|
132
|
+
--local-switch-thumb-translateX: 0;
|
|
133
|
+
}
|
|
@@ -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,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
checked: false,
|
|
9
|
-
disabled: false,
|
|
10
|
-
labelPalette: 'primary',
|
|
11
|
-
labelSize: 'medium',
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _default = {
|
|
12
8
|
size: 'medium',
|
|
9
|
+
isDefaultChecked: false,
|
|
10
|
+
isDisabled: false,
|
|
13
11
|
isReadOnly: false,
|
|
14
|
-
|
|
12
|
+
hasStateIndication: true,
|
|
13
|
+
labelPlacement: 'start',
|
|
14
|
+
labelSize: 'medium',
|
|
15
15
|
customProps: {},
|
|
16
|
-
|
|
16
|
+
tagAttributes: {},
|
|
17
|
+
a11yAttributes: {},
|
|
18
|
+
i18nKeys: {},
|
|
19
|
+
customStyle: {}
|
|
17
20
|
};
|
|
18
|
-
exports
|
|
21
|
+
exports["default"] = _default;
|