@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
|
@@ -3,37 +3,45 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
checked: _propTypes["default"].bool,
|
|
14
|
-
dataId: _propTypes["default"].string,
|
|
15
|
-
dataSelectorId: _propTypes["default"].string,
|
|
16
|
-
disableTitle: _propTypes["default"].string,
|
|
17
|
-
disabled: _propTypes["default"].bool,
|
|
18
|
-
id: _propTypes["default"].string.isRequired,
|
|
19
|
-
isReadOnly: _propTypes["default"].bool,
|
|
20
|
-
labelPalette: _propTypes["default"].oneOf(['default', 'primary', 'secondary', 'danger', 'mandatory']),
|
|
21
|
-
labelSize: _propTypes["default"].oneOf(['small', 'medium', 'large']),
|
|
12
|
+
var _default = {
|
|
22
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
|
+
isDefaultChecked: _propTypes["default"].bool,
|
|
19
|
+
isDisabled: _propTypes["default"].bool,
|
|
20
|
+
isReadOnly: _propTypes["default"].bool,
|
|
23
21
|
onChange: _propTypes["default"].func,
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
hasStateIndication: _propTypes["default"].bool,
|
|
23
|
+
label: _propTypes["default"].string,
|
|
24
|
+
labelPlacement: _propTypes["default"].oneOf(['start', 'end', 'top', 'bottom']),
|
|
25
|
+
labelSize: _propTypes["default"].oneOf(['xsmall', 'small', 'medium', 'large']),
|
|
26
26
|
title: _propTypes["default"].string,
|
|
27
|
-
value: _propTypes["default"].bool,
|
|
28
|
-
customClass: _propTypes["default"].shape({
|
|
29
|
-
customSwitchWrap: _propTypes["default"].string,
|
|
30
|
-
customSwitch: _propTypes["default"].string,
|
|
31
|
-
customSwitchSize: _propTypes["default"].string,
|
|
32
|
-
customLabel: _propTypes["default"].string
|
|
33
|
-
}),
|
|
34
27
|
customProps: _propTypes["default"].shape({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
28
|
+
container: _propTypes["default"].object,
|
|
29
|
+
label: _propTypes["default"].object
|
|
30
|
+
}),
|
|
31
|
+
tagAttributes: _propTypes["default"].shape({
|
|
32
|
+
container: _propTypes["default"].object,
|
|
33
|
+
"switch": _propTypes["default"].object
|
|
34
|
+
}),
|
|
35
|
+
a11yAttributes: _propTypes["default"].shape({
|
|
36
|
+
container: _propTypes["default"].object,
|
|
37
|
+
"switch": _propTypes["default"].object,
|
|
38
|
+
label: _propTypes["default"].object
|
|
39
|
+
}),
|
|
40
|
+
i18nKeys: _propTypes["default"].shape({
|
|
41
|
+
readOnlyAriaLabel: _propTypes["default"].string
|
|
42
|
+
}),
|
|
43
|
+
customId: _propTypes["default"].string,
|
|
44
|
+
testId: _propTypes["default"].string,
|
|
45
|
+
customStyle: _propTypes["default"].object
|
|
38
46
|
};
|
|
39
|
-
exports
|
|
47
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
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.isChecked,
|
|
24
|
+
isDefaultChecked = props.isDefaultChecked,
|
|
25
|
+
onChange = props.onChange,
|
|
26
|
+
isReadOnly = props.isReadOnly,
|
|
27
|
+
isDisabled = props.isDisabled;
|
|
28
|
+
var isControlled = isCheckedProp !== undefined;
|
|
29
|
+
|
|
30
|
+
var _useState = (0, _react.useState)(isDefaultChecked),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
internalChecked = _useState2[0],
|
|
33
|
+
setInternalChecked = _useState2[1];
|
|
34
|
+
|
|
35
|
+
var isChecked = isControlled ? isCheckedProp : internalChecked;
|
|
36
|
+
|
|
37
|
+
var handleChange = function handleChange(e) {
|
|
38
|
+
if (isReadOnly || isDisabled) return;
|
|
39
|
+
|
|
40
|
+
if (!isControlled) {
|
|
41
|
+
setInternalChecked(!isChecked);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
45
|
+
isChecked: !isChecked
|
|
46
|
+
}, e);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
isChecked: isChecked,
|
|
51
|
+
handleChange: handleChange
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var _default = useSwitch;
|
|
56
|
+
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "es/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -70,8 +70,10 @@
|
|
|
70
70
|
"@zohodesk-private/react-prop-validator": "1.2.3",
|
|
71
71
|
"@zohodesk/a11y": "2.3.4",
|
|
72
72
|
"@zohodesk/docstool": "1.0.0-alpha-2",
|
|
73
|
+
"@zohodesk/dotkit": "1.0.2",
|
|
73
74
|
"@zohodesk/hooks": "2.0.5",
|
|
74
75
|
"@zohodesk/icons": "1.0.78",
|
|
76
|
+
"@zohodesk/layout": "3.1.0",
|
|
75
77
|
"@zohodesk/svg": "1.1.22",
|
|
76
78
|
"@zohodesk/utils": "1.3.14",
|
|
77
79
|
"@zohodesk/variables": "1.0.0",
|
|
@@ -94,6 +96,8 @@
|
|
|
94
96
|
"react-sortable-hoc": "^0.8.3",
|
|
95
97
|
"@zohodesk/hooks": "2.0.5",
|
|
96
98
|
"@zohodesk/utils": "1.3.14",
|
|
97
|
-
"@zohodesk/a11y": "2.3.4"
|
|
99
|
+
"@zohodesk/a11y": "2.3.4",
|
|
100
|
+
"@zohodesk/layout": "3.1.0",
|
|
101
|
+
"@zohodesk/dotkit": "1.0.2"
|
|
98
102
|
}
|
|
99
103
|
}
|