@zohodesk/components 1.0.0-temp-216 → 1.0.0-temp-217
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/propValidation_report.html +1 -1
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +0 -5
- package/assets/Appearance/dark/themes/blue/blue_ComponentTheme_DarkTheme.module.css +0 -4
- package/assets/Appearance/dark/themes/green/green_ComponentTheme_DarkTheme.module.css +0 -4
- package/assets/Appearance/dark/themes/orange/orange_ComponentTheme_DarkTheme.module.css +0 -4
- package/assets/Appearance/dark/themes/red/red_ComponentTheme_DarkTheme.module.css +0 -4
- package/assets/Appearance/dark/themes/yellow/yellow_ComponentTheme_DarkTheme.module.css +0 -4
- package/assets/Appearance/light/mode/Component_LightMode.module.css +0 -5
- package/assets/Appearance/light/themes/blue/blue_ComponentTheme_LightTheme.module.css +0 -4
- package/assets/Appearance/light/themes/green/green_ComponentTheme_LightTheme.module.css +0 -4
- package/assets/Appearance/light/themes/orange/orange_ComponentTheme_LightTheme.module.css +0 -4
- package/assets/Appearance/light/themes/red/red_ComponentTheme_LightTheme.module.css +0 -4
- package/assets/Appearance/light/themes/yellow/yellow_ComponentTheme_LightTheme.module.css +0 -4
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +0 -5
- package/assets/Appearance/pureDark/themes/blue/blue_ComponentTheme_PureDarkTheme.module.css +0 -4
- package/assets/Appearance/pureDark/themes/green/green_ComponentTheme_PureDarkTheme.module.css +0 -4
- package/assets/Appearance/pureDark/themes/orange/orange_ComponentTheme_PureDarkTheme.module.css +0 -4
- package/assets/Appearance/pureDark/themes/red/red_ComponentTheme_PureDarkTheme.module.css +0 -4
- package/assets/Appearance/pureDark/themes/yellow/yellow_ComponentTheme_PureDarkTheme.module.css +0 -4
- package/es/Button/Button.js +2 -9
- package/es/Button/css/Button.module.css +0 -82
- package/es/Button/css/cssJSLogic.js +1 -6
- package/es/Provider/LibraryContext.js +2 -2
- package/es/Switch/Switch.js +27 -3
- package/es/Switch/Switch.module.css +126 -15
- package/es/SwitchNew/SwitchNew.js +118 -0
- package/es/SwitchNew/SwitchNew.module.css +155 -0
- package/es/SwitchNew/props/defaultProps.js +9 -0
- package/es/SwitchNew/props/propTypes.js +32 -0
- package/es/index.js +1 -0
- package/lib/Button/Button.js +2 -24
- package/lib/Button/css/Button.module.css +0 -82
- package/lib/Button/css/cssJSLogic.js +2 -6
- package/lib/Provider/LibraryContext.js +2 -2
- package/lib/Switch/Switch.js +34 -4
- package/lib/Switch/Switch.module.css +126 -15
- package/lib/SwitchNew/SwitchNew.js +148 -0
- package/lib/SwitchNew/SwitchNew.module.css +155 -0
- package/lib/SwitchNew/props/defaultProps.js +16 -0
- package/lib/SwitchNew/props/propTypes.js +43 -0
- package/lib/index.js +9 -0
- package/package.json +1 -1
- package/result.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { Container, Box } from '../Layout';
|
|
3
|
+
import Label from '../Label/Label';
|
|
4
|
+
import style from './SwitchNew.module.css';
|
|
5
|
+
import { defaultProps } from './props/defaultProps';
|
|
6
|
+
import { propTypes } from './props/propTypes';
|
|
7
|
+
import LibraryContext from '../Provider/LibraryContextInit';
|
|
8
|
+
|
|
9
|
+
const SwitchNew = props => {
|
|
10
|
+
const {
|
|
11
|
+
id,
|
|
12
|
+
title,
|
|
13
|
+
name,
|
|
14
|
+
value,
|
|
15
|
+
checked,
|
|
16
|
+
disabled,
|
|
17
|
+
isReadOnly,
|
|
18
|
+
size,
|
|
19
|
+
text,
|
|
20
|
+
disableTitle,
|
|
21
|
+
dataId,
|
|
22
|
+
dataSelectorId,
|
|
23
|
+
onChange,
|
|
24
|
+
customProps,
|
|
25
|
+
customClass,
|
|
26
|
+
labelSize,
|
|
27
|
+
labelPlacement,
|
|
28
|
+
a11y
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const handleChange = e => {
|
|
32
|
+
if (!disabled && !isReadOnly && onChange) {
|
|
33
|
+
onChange(!checked, e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
SwitchProps = {},
|
|
39
|
+
LabelProps = {}
|
|
40
|
+
} = customProps || {};
|
|
41
|
+
const {
|
|
42
|
+
WrapperProps = {},
|
|
43
|
+
TrackProps = {}
|
|
44
|
+
} = SwitchProps;
|
|
45
|
+
const {
|
|
46
|
+
customSwitchWrap = '',
|
|
47
|
+
customSwitch = '',
|
|
48
|
+
customLabel = ''
|
|
49
|
+
} = customClass || {};
|
|
50
|
+
const {
|
|
51
|
+
role = 'switch',
|
|
52
|
+
...a11yAttributes
|
|
53
|
+
} = a11y || {};
|
|
54
|
+
const context = useContext(LibraryContext);
|
|
55
|
+
const {
|
|
56
|
+
a11y_onOffLabel = true
|
|
57
|
+
} = context;
|
|
58
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
59
|
+
align: "vertical",
|
|
60
|
+
isCover: false,
|
|
61
|
+
isInline: true,
|
|
62
|
+
alignBox: labelPlacement == 'right' ? 'row' : 'row-reverse',
|
|
63
|
+
"data-title": disabled ? disableTitle : title,
|
|
64
|
+
dataSelectorId: dataSelectorId,
|
|
65
|
+
className: customSwitchWrap ? customSwitchWrap : '',
|
|
66
|
+
...WrapperProps
|
|
67
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: `${style.switchWrapper} ${style[`${size}_switch`]} ${!disabled && !isReadOnly ? style.effect : ''} ${disabled ? style.disabled : ''}`
|
|
69
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
70
|
+
type: "checkbox",
|
|
71
|
+
id: id,
|
|
72
|
+
name: name,
|
|
73
|
+
value: value,
|
|
74
|
+
checked: checked,
|
|
75
|
+
disabled: disabled,
|
|
76
|
+
readOnly: isReadOnly,
|
|
77
|
+
onChange: handleChange,
|
|
78
|
+
role: role,
|
|
79
|
+
"aria-checked": checked,
|
|
80
|
+
tabIndex: disabled ? -1 : 0,
|
|
81
|
+
"data-id": dataId,
|
|
82
|
+
"data-test-id": dataId,
|
|
83
|
+
className: `${style.track} ${customSwitch} ${a11y_onOffLabel ? checked ? style.onLabel : style.offLabel : ''}`,
|
|
84
|
+
...a11yAttributes,
|
|
85
|
+
...TrackProps
|
|
86
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
87
|
+
className: style.thumb
|
|
88
|
+
}), a11y_onOffLabel ? /*#__PURE__*/React.createElement("svg", {
|
|
89
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
90
|
+
viewBox: `0 0 ${checked ? '2' : 'var(--off-label-size)'} ${checked ? 'var(--on-label-height)' : 'var(--off-label-size)'}`,
|
|
91
|
+
className: checked ? style.onLabelWrapper : style.offLabelWrapper
|
|
92
|
+
}, checked ? /*#__PURE__*/React.createElement("rect", {
|
|
93
|
+
x: "0",
|
|
94
|
+
rx: "0.8",
|
|
95
|
+
ry: "0.8",
|
|
96
|
+
width: "100%",
|
|
97
|
+
height: "100%",
|
|
98
|
+
className: style.onLabel
|
|
99
|
+
}) : /*#__PURE__*/React.createElement("circle", {
|
|
100
|
+
className: style.offLabel,
|
|
101
|
+
cx: "50%",
|
|
102
|
+
cy: "50%",
|
|
103
|
+
width: "100%",
|
|
104
|
+
height: "100%",
|
|
105
|
+
fill: "none"
|
|
106
|
+
})) : null), text && /*#__PURE__*/React.createElement(Label, {
|
|
107
|
+
customClass: ` ${style[`switchLabel_${labelPlacement}`]} ${customLabel ? customLabel : ''}`,
|
|
108
|
+
htmlFor: id,
|
|
109
|
+
size: labelSize,
|
|
110
|
+
type: "subtitle",
|
|
111
|
+
text: text,
|
|
112
|
+
...LabelProps
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default SwitchNew;
|
|
117
|
+
SwitchNew.defaultProps = defaultProps;
|
|
118
|
+
SwitchNew.propTypes = propTypes;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
.switchWrapper {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
}
|
|
6
|
+
.switchWrapper *, .switchWrapper:hover * {
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
}
|
|
9
|
+
.disabled {
|
|
10
|
+
opacity: 0.4;
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
cursor: not-allowed;
|
|
13
|
+
}
|
|
14
|
+
.track {
|
|
15
|
+
width: var(--track-width);
|
|
16
|
+
height: var(--track-height);
|
|
17
|
+
appearance: none;
|
|
18
|
+
/* css:theme-validation:ignore */
|
|
19
|
+
transition: background-color 0.3s ease-in-out;
|
|
20
|
+
border-radius: 10px;
|
|
21
|
+
background-color: var(--dot_paleBlue);
|
|
22
|
+
margin: 0 ;
|
|
23
|
+
}
|
|
24
|
+
.thumb {
|
|
25
|
+
width: var(--thumb-size);
|
|
26
|
+
height: var(--thumb-size);
|
|
27
|
+
/* css:theme-validation:ignore */
|
|
28
|
+
position: absolute;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
z-index: 1;
|
|
31
|
+
top: var(--zd_size2) ;
|
|
32
|
+
bottom: var(--zd_size2) ;
|
|
33
|
+
transition: transform 0.3s ease-in-out, background-color 0.3s ease-in-out;
|
|
34
|
+
border-radius: 50%;
|
|
35
|
+
background-color: var(--dot_white);
|
|
36
|
+
}
|
|
37
|
+
[dir=ltr] .thumb {
|
|
38
|
+
left: var(--zd_size2) ;
|
|
39
|
+
}
|
|
40
|
+
[dir=rtl] .thumb {
|
|
41
|
+
right: var(--zd_size2) ;
|
|
42
|
+
}
|
|
43
|
+
.track:checked {
|
|
44
|
+
/* css:theme-validation:ignore */
|
|
45
|
+
background-color: var(--dot_strongGreen);
|
|
46
|
+
}
|
|
47
|
+
[dir=ltr] .track:checked + .thumb {
|
|
48
|
+
transform: translateX(calc(var(--track-width) - var(--thumb-size) - 4px));
|
|
49
|
+
}
|
|
50
|
+
[dir=rtl] .track:checked + .thumb {
|
|
51
|
+
transform: translateX(calc(-1*(var(--track-width) - var(--thumb-size) - 4px)));
|
|
52
|
+
}
|
|
53
|
+
.switchWrapper:hover .track {
|
|
54
|
+
/* css:theme-validation:ignore */
|
|
55
|
+
background-color: var(--dot_paleNavy);
|
|
56
|
+
}
|
|
57
|
+
.switchWrapper:hover .track:checked {
|
|
58
|
+
/* css:theme-validation:ignore */
|
|
59
|
+
background-color: var(--dot_camarone);
|
|
60
|
+
}
|
|
61
|
+
.effect:hover .offLabelWrapper > .offLabel {
|
|
62
|
+
stroke: var(--dot_black);
|
|
63
|
+
}
|
|
64
|
+
.small_switch {
|
|
65
|
+
--track-width: var(--zd_size22);
|
|
66
|
+
--track-height: var(--zd_size12);
|
|
67
|
+
--thumb-size: var(--zd_size8);
|
|
68
|
+
--off-label-size: var(--zd_size7);
|
|
69
|
+
--off-label-radius: 2.5px;
|
|
70
|
+
--off-label-top: var(--zd_size2.5);
|
|
71
|
+
--off-label-right: var(--zd_size3);
|
|
72
|
+
--off-label-stroke: 1px;
|
|
73
|
+
--on-label-width: var(--zd_size1.2);
|
|
74
|
+
--on-label-height: var(--zd_size6);
|
|
75
|
+
--on-label-top: var(--zd_size3);
|
|
76
|
+
--on-label-left: var(--zd_size5);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.medium_switch {
|
|
80
|
+
--track-width: var(--zd_size28);
|
|
81
|
+
--track-height: var(--zd_size16);
|
|
82
|
+
--thumb-size: var(--zd_size12);
|
|
83
|
+
--off-label-size: var(--zd_size8);
|
|
84
|
+
--off-label-radius: 3px;
|
|
85
|
+
--off-label-top: var(--zd_size4);
|
|
86
|
+
--off-label-right: var(--zd_size3.5);
|
|
87
|
+
--off-label-stroke: 1.1px;
|
|
88
|
+
--on-label-width: var(--zd_size1.4);
|
|
89
|
+
--on-label-height: var(--zd_size8);
|
|
90
|
+
--on-label-top: var(--zd_size4);
|
|
91
|
+
--on-label-left: var(--zd_size6);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.large_switch {
|
|
95
|
+
--track-width: var(--zd_size34);
|
|
96
|
+
--track-height: var(--zd_size20);
|
|
97
|
+
--thumb-size: var(--zd_size16);
|
|
98
|
+
--off-label-size: var(--zd_size9);
|
|
99
|
+
--off-label-radius: 3.5px;
|
|
100
|
+
--off-label-top: var(--zd_size5.5);
|
|
101
|
+
--off-label-right: var(--zd_size4);
|
|
102
|
+
--off-label-stroke: 1.2px;
|
|
103
|
+
--on-label-width: var(--zd_size1.6);
|
|
104
|
+
--on-label-height: var(--zd_size11);
|
|
105
|
+
--on-label-top: var(--zd_size4.5);
|
|
106
|
+
--on-label-left: var(--zd_size7);
|
|
107
|
+
}
|
|
108
|
+
[dir=ltr] .switchLabel_right {
|
|
109
|
+
margin-right: var(--zd_size12) ;
|
|
110
|
+
}
|
|
111
|
+
[dir=rtl] .switchLabel_right {
|
|
112
|
+
margin-left: var(--zd_size12) ;
|
|
113
|
+
}
|
|
114
|
+
[dir=ltr] .switchLabel_left {
|
|
115
|
+
margin-left: var(--zd_size12) ;
|
|
116
|
+
}
|
|
117
|
+
[dir=rtl] .switchLabel_left {
|
|
118
|
+
margin-right: var(--zd_size12) ;
|
|
119
|
+
}
|
|
120
|
+
.offLabelWrapper,
|
|
121
|
+
.onLabelWrapper {
|
|
122
|
+
position: absolute;
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
}
|
|
125
|
+
.offLabelWrapper {
|
|
126
|
+
width: var(--off-label-size);
|
|
127
|
+
height: var(--off-label-size);
|
|
128
|
+
top: var(--off-label-top);
|
|
129
|
+
}
|
|
130
|
+
[dir=ltr] .offLabelWrapper {
|
|
131
|
+
right: var(--off-label-right);
|
|
132
|
+
}
|
|
133
|
+
[dir=rtl] .offLabelWrapper {
|
|
134
|
+
left: var(--off-label-right);
|
|
135
|
+
}
|
|
136
|
+
.onLabelWrapper {
|
|
137
|
+
width: var(--on-label-width);
|
|
138
|
+
height: var(--on-label-height);
|
|
139
|
+
top: var(--on-label-top);
|
|
140
|
+
}
|
|
141
|
+
[dir=ltr] .onLabelWrapper {
|
|
142
|
+
left: var(--on-label-left);
|
|
143
|
+
}
|
|
144
|
+
[dir=rtl] .onLabelWrapper {
|
|
145
|
+
right: var(--on-label-left);
|
|
146
|
+
}
|
|
147
|
+
.offLabel {
|
|
148
|
+
stroke: var(--dot_shuttleGrey);
|
|
149
|
+
stroke-width: var(--off-label-stroke);
|
|
150
|
+
r: var(--off-label-radius);
|
|
151
|
+
fill: none;
|
|
152
|
+
}
|
|
153
|
+
.onLabel {
|
|
154
|
+
fill: var(--dot_white);
|
|
155
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
export const propTypes = {
|
|
3
|
+
id: PropTypes.string,
|
|
4
|
+
title: PropTypes.string,
|
|
5
|
+
name: PropTypes.string,
|
|
6
|
+
value: PropTypes.bool,
|
|
7
|
+
checked: PropTypes.bool,
|
|
8
|
+
disabled: PropTypes.bool,
|
|
9
|
+
isReadOnly: PropTypes.bool,
|
|
10
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
11
|
+
text: PropTypes.string,
|
|
12
|
+
disableTitle: PropTypes.string,
|
|
13
|
+
dataId: PropTypes.string,
|
|
14
|
+
onChange: PropTypes.func,
|
|
15
|
+
dataSelectorId: PropTypes.string,
|
|
16
|
+
customClass: PropTypes.shape({
|
|
17
|
+
customSwitchWrap: PropTypes.string,
|
|
18
|
+
customSwitch: PropTypes.string,
|
|
19
|
+
customLabel: PropTypes.string
|
|
20
|
+
}),
|
|
21
|
+
customProps: PropTypes.shape({
|
|
22
|
+
SwitchProps: PropTypes.shape({
|
|
23
|
+
WrapperProps: PropTypes.object,
|
|
24
|
+
TrackProps: PropTypes.object
|
|
25
|
+
}),
|
|
26
|
+
LabelProps: PropTypes.object
|
|
27
|
+
}),
|
|
28
|
+
labelPalette: PropTypes.oneOf[("default", "primary", "secondary", "danger", "mandatory", "disable", "dark")],
|
|
29
|
+
labelSize: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large']),
|
|
30
|
+
labelPlacement: PropTypes.string,
|
|
31
|
+
a11y: PropTypes.object
|
|
32
|
+
};
|
package/es/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { default as RippleEffect } from './RippleEffect/RippleEffect';
|
|
|
29
29
|
export * from './Select';
|
|
30
30
|
export { default as Stencils } from './Stencils/Stencils';
|
|
31
31
|
export { default as Switch } from './Switch/Switch';
|
|
32
|
+
export { default as SwitchNew } from './SwitchNew/SwitchNew';
|
|
32
33
|
export * from './Tab';
|
|
33
34
|
export { default as Tag } from './Tag/Tag';
|
|
34
35
|
export { default as Textarea } from './Textarea/Textarea';
|
package/lib/Button/Button.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports["default"] = Button;
|
|
9
7
|
|
|
10
|
-
var _react =
|
|
11
|
-
|
|
12
|
-
var _LibraryContextInit = _interopRequireDefault(require("../Provider/LibraryContextInit"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
9
|
|
|
14
10
|
var _defaultProps = require("./props/defaultProps");
|
|
15
11
|
|
|
@@ -23,18 +19,8 @@ var _ButtonModule = _interopRequireDefault(require("./css/Button.module.css"));
|
|
|
23
19
|
|
|
24
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
21
|
|
|
26
|
-
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); }
|
|
27
|
-
|
|
28
|
-
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; }
|
|
29
|
-
|
|
30
22
|
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); }
|
|
31
23
|
|
|
32
|
-
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; }
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
|
|
36
|
-
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; }
|
|
37
|
-
|
|
38
24
|
/*
|
|
39
25
|
Button text and children props?
|
|
40
26
|
use children for both cases
|
|
@@ -57,18 +43,10 @@ function Button(props) {
|
|
|
57
43
|
customStyle = props.customStyle,
|
|
58
44
|
a11y = props.a11y,
|
|
59
45
|
id = props.id;
|
|
60
|
-
|
|
61
|
-
var _useContext = (0, _react.useContext)(_LibraryContextInit["default"]),
|
|
62
|
-
a11y_strikeThroughButtons = _useContext.a11y_strikeThroughButtons;
|
|
63
|
-
|
|
64
46
|
var finalStyle = (0, _utils.mergeStyle)(_ButtonModule["default"], customStyle);
|
|
65
47
|
|
|
66
|
-
var buttonProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
67
|
-
a11y_strikeThroughButtons: a11y_strikeThroughButtons
|
|
68
|
-
});
|
|
69
|
-
|
|
70
48
|
var _cssJSLogic = (0, _cssJSLogic2["default"])({
|
|
71
|
-
props:
|
|
49
|
+
props: props,
|
|
72
50
|
style: finalStyle
|
|
73
51
|
}),
|
|
74
52
|
buttonClass = _cssJSLogic.buttonClass,
|
|
@@ -525,86 +525,4 @@
|
|
|
525
525
|
|
|
526
526
|
.loader{
|
|
527
527
|
color:var(--dot_mirror)
|
|
528
|
-
}
|
|
529
|
-
[dir=ltr] .primaryStrike {
|
|
530
|
-
background: repeating-linear-gradient(120deg, var(--zdt_button_primary_strike), var(--zdt_button_primary_strike) 1px, transparent 0px,transparent 8px);
|
|
531
|
-
}
|
|
532
|
-
[dir=rtl] .primaryStrike {
|
|
533
|
-
background: repeating-linear-gradient(-120deg, var(--zdt_button_primary_strike), var(--zdt_button_primary_strike) 1px, transparent 0px,transparent 8px);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
.primaryfilledStrike {
|
|
537
|
-
--button_border_color: var(--zdt_button_primaryfill_bg);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
[dir=ltr] .primaryfilledStrike {
|
|
541
|
-
background: repeating-linear-gradient(120deg, var(--zdt_button_primary_filled_strike) , var(--zdt_button_primary_filled_strike) 1px, var(--zdt_button_primaryfill_bg) 1px,var(--zdt_button_primaryfill_bg) 8px), var(--zdt_button_primaryfill_bg);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
[dir=rtl] .primaryfilledStrike {
|
|
545
|
-
background: repeating-linear-gradient(-120deg, var(--zdt_button_primary_filled_strike) , var(--zdt_button_primary_filled_strike) 1px, var(--zdt_button_primaryfill_bg) 1px,var(--zdt_button_primaryfill_bg) 8px), var(--zdt_button_primaryfill_bg);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
[dir=ltr] .dangerStrike {
|
|
549
|
-
background: repeating-linear-gradient(120deg,var(--zd_dangertrans6), var(--zd_dangertrans6) 1px, transparent 0px, transparent 8px);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
[dir=rtl] .dangerStrike {
|
|
553
|
-
background: repeating-linear-gradient(-120deg,var(--zd_dangertrans6), var(--zd_dangertrans6) 1px, transparent 0px, transparent 8px);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
.dangerfilledStrike {
|
|
557
|
-
--button_border_color: var(--zdt_button_danger_border);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
[dir=ltr] .dangerfilledStrike {
|
|
561
|
-
background: repeating-linear-gradient(120deg,var(--zdt_button_danger_strike) , var(--zdt_button_danger_strike) 1px, var(--zdt_button_dangerfill_bg) 1px,var(--zdt_button_dangerfill_bg) 8px), var(--zdt_button_dangerfill_bg);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
[dir=rtl] .dangerfilledStrike {
|
|
565
|
-
background: repeating-linear-gradient(-120deg,var(--zdt_button_danger_strike) , var(--zdt_button_danger_strike) 1px, var(--zdt_button_dangerfill_bg) 1px,var(--zdt_button_dangerfill_bg) 8px), var(--zdt_button_dangerfill_bg);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
[dir=ltr] .secondaryStrike {
|
|
569
|
-
background: repeating-linear-gradient(120deg, var(--zdt_button_secondary_border), var(--zdt_button_secondary_border) 1px, transparent 0px,transparent 8px);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
[dir=rtl] .secondaryStrike {
|
|
573
|
-
background: repeating-linear-gradient(-120deg, var(--zdt_button_secondary_border), var(--zdt_button_secondary_border) 1px, transparent 0px,transparent 8px);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
.secondaryfilledStrike {
|
|
577
|
-
--button_border_color: var(--zdt_button_secondaryfill_bg);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
[dir=ltr] .secondaryfilledStrike {
|
|
581
|
-
background: repeating-linear-gradient(120deg,var(--zdt_secondaryfilled_strike) , var(--zdt_secondaryfilled_strike) 1px, var(--zdt_button_secondaryfill_bg) 1px,var(--zdt_button_secondaryfill_bg) 8px);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
[dir=rtl] .secondaryfilledStrike {
|
|
585
|
-
background: repeating-linear-gradient(-120deg,var(--zdt_secondaryfilled_strike) , var(--zdt_secondaryfilled_strike) 1px, var(--zdt_button_secondaryfill_bg) 1px,var(--zdt_button_secondaryfill_bg) 8px);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
.tertiaryfilledStrike {
|
|
589
|
-
--button_border_color: var(--zdt_button_tertiaryfill_bg);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
[dir=ltr] .tertiaryfilledStrike {
|
|
593
|
-
background: repeating-linear-gradient(120deg,var(--dot_slateGrey) , var(--dot_slateGrey) 1px, var(--zdt_button_tertiaryfill_bg) 1px,var(--zdt_button_tertiaryfill_bg) 8px);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
[dir=rtl] .tertiaryfilledStrike {
|
|
597
|
-
background: repeating-linear-gradient(-120deg,var(--dot_slateGrey) , var(--dot_slateGrey) 1px, var(--zdt_button_tertiaryfill_bg) 1px,var(--zdt_button_tertiaryfill_bg) 8px);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
.successfilledStrike {
|
|
601
|
-
--button_border_color: var(--zdt_button_successfill_border);
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
[dir=ltr] .successfilledStrike {
|
|
605
|
-
background: repeating-linear-gradient(120deg,var(--zdt_success_strike) , var(--zdt_success_strike) 1px, var(--zdt_button_successfill_bg) 1px,var(--zdt_button_successfill_bg) 8px);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
[dir=rtl] .successfilledStrike {
|
|
609
|
-
background: repeating-linear-gradient(-120deg,var(--zdt_success_strike) , var(--zdt_success_strike) 1px, var(--zdt_button_successfill_bg) 1px,var(--zdt_button_successfill_bg) 8px);
|
|
610
528
|
}
|
|
@@ -21,20 +21,16 @@ function cssJSLogic(_ref) {
|
|
|
21
21
|
size = props.size,
|
|
22
22
|
children = props.children,
|
|
23
23
|
palette = props.palette,
|
|
24
|
-
status = props.status
|
|
25
|
-
disabled = props.disabled,
|
|
26
|
-
a11y_strikeThroughButtons = props.a11y_strikeThroughButtons;
|
|
24
|
+
status = props.status;
|
|
27
25
|
var _customClass$customBu = customClass.customButton,
|
|
28
26
|
customButton = _customClass$customBu === void 0 ? '' : _customClass$customBu,
|
|
29
27
|
_customClass$customSt = customClass.customStatus,
|
|
30
28
|
customStatus = _customClass$customSt === void 0 ? '' : _customClass$customSt,
|
|
31
29
|
_customClass$customSt2 = customClass.customStatusSize,
|
|
32
30
|
customStatusSize = _customClass$customSt2 === void 0 ? '' : _customClass$customSt2;
|
|
33
|
-
var strikeExcluded = ['plainprimary', 'plainsecondary'];
|
|
34
31
|
var paletteLower = palette.toLowerCase();
|
|
35
32
|
var statusLower = status.toLowerCase();
|
|
36
|
-
var
|
|
37
|
-
var buttonClass = (0, _utils.compileClassNames)((_compileClassNames = {}, _defineProperty(_compileClassNames, customButton, !!customButton), _defineProperty(_compileClassNames, style.bold, isBold), _defineProperty(_compileClassNames, style["default"], !needAppearance), _defineProperty(_compileClassNames, style[paletteLower], needAppearance), _defineProperty(_compileClassNames, style.rounded, needAppearance && rounded), _defineProperty(_compileClassNames, style[size.toLowerCase()], needAppearance && !children), _defineProperty(_compileClassNames, style["".concat(size, "Btn")], needAppearance && children), _defineProperty(_compileClassNames, style["".concat(size, "Btn").concat(paletteLower)], needAppearance && children && rounded), _defineProperty(_compileClassNames, style["".concat(paletteLower, "Strike")], disabled && a11y_strikeThroughButtons && strikeEnabled), _defineProperty(_compileClassNames, style.loader, !!needAppearance && statusLower !== 'none'), _compileClassNames));
|
|
33
|
+
var buttonClass = (0, _utils.compileClassNames)((_compileClassNames = {}, _defineProperty(_compileClassNames, customButton, !!customButton), _defineProperty(_compileClassNames, style.bold, isBold), _defineProperty(_compileClassNames, style["default"], !needAppearance), _defineProperty(_compileClassNames, style[paletteLower], needAppearance), _defineProperty(_compileClassNames, style.rounded, needAppearance && rounded), _defineProperty(_compileClassNames, style[size.toLowerCase()], needAppearance && !children), _defineProperty(_compileClassNames, style["".concat(size, "Btn")], needAppearance && children), _defineProperty(_compileClassNames, style["".concat(size, "Btn").concat(paletteLower)], needAppearance && children && rounded), _defineProperty(_compileClassNames, style.loader, !!needAppearance && statusLower !== 'none'), _compileClassNames));
|
|
38
34
|
var loaderParentClass = (0, _utils.compileClassNames)((_compileClassNames2 = {}, _defineProperty(_compileClassNames2, customStatusSize, !!customStatusSize), _defineProperty(_compileClassNames2, style.loading, statusLower === 'loading'), _defineProperty(_compileClassNames2, style["".concat(size, "loading")], statusLower === 'loading'), _defineProperty(_compileClassNames2, style.success, statusLower != 'loading'), _compileClassNames2));
|
|
39
35
|
var loaderChildClass = (0, _utils.compileClassNames)((_compileClassNames3 = {}, _defineProperty(_compileClassNames3, customStatus, !!customStatus), _defineProperty(_compileClassNames3, style.loadingelement, statusLower === 'loading'), _defineProperty(_compileClassNames3, style["".concat(paletteLower, "element")], statusLower === 'loading'), _defineProperty(_compileClassNames3, style.successelement, statusLower != 'loading'), _defineProperty(_compileClassNames3, style["".concat(paletteLower, "success")], statusLower != 'loading'), _compileClassNames3));
|
|
40
36
|
return {
|
|
@@ -44,7 +44,7 @@ var LibraryContextProvider = function LibraryContextProvider(_ref) {
|
|
|
44
44
|
direction = _ref.direction,
|
|
45
45
|
coloredTagVariant = _ref.coloredTagVariant,
|
|
46
46
|
hasTagColorInheritedToText = _ref.hasTagColorInheritedToText,
|
|
47
|
-
|
|
47
|
+
a11y_onOffLabel = _ref.a11y_onOffLabel,
|
|
48
48
|
children = _ref.children;
|
|
49
49
|
|
|
50
50
|
var _useState = (0, _react.useState)({
|
|
@@ -52,7 +52,7 @@ var LibraryContextProvider = function LibraryContextProvider(_ref) {
|
|
|
52
52
|
direction: direction,
|
|
53
53
|
coloredTagVariant: coloredTagVariant,
|
|
54
54
|
hasTagColorInheritedToText: hasTagColorInheritedToText,
|
|
55
|
-
|
|
55
|
+
a11y_onOffLabel: a11y_onOffLabel
|
|
56
56
|
}),
|
|
57
57
|
_useState2 = _slicedToArray(_useState, 2),
|
|
58
58
|
value = _useState2[0],
|
package/lib/Switch/Switch.js
CHANGED
|
@@ -17,6 +17,8 @@ var _Layout = require("../Layout");
|
|
|
17
17
|
|
|
18
18
|
var _Label = _interopRequireDefault(require("../Label/Label"));
|
|
19
19
|
|
|
20
|
+
var _LibraryContextInit = _interopRequireDefault(require("../Provider/LibraryContextInit"));
|
|
21
|
+
|
|
20
22
|
var _SwitchModule = _interopRequireDefault(require("./Switch.module.css"));
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -67,8 +69,8 @@ var Switch = /*#__PURE__*/function (_React$Component) {
|
|
|
67
69
|
onChange && onChange(!checked, e);
|
|
68
70
|
}
|
|
69
71
|
}, {
|
|
70
|
-
key: "
|
|
71
|
-
value: function
|
|
72
|
+
key: "renderSwitch",
|
|
73
|
+
value: function renderSwitch(context) {
|
|
72
74
|
var _this$props2 = this.props,
|
|
73
75
|
id = _this$props2.id,
|
|
74
76
|
name = _this$props2.name,
|
|
@@ -99,6 +101,8 @@ var Switch = /*#__PURE__*/function (_React$Component) {
|
|
|
99
101
|
_customClass$customLa = customClass.customLabel,
|
|
100
102
|
customLabel = _customClass$customLa === void 0 ? '' : _customClass$customLa;
|
|
101
103
|
size !== 'small' ? size = 'switch_medium' : size = 'switch_small';
|
|
104
|
+
var isOnOffLabelEnabled = context.a11y_onOffLabel;
|
|
105
|
+
var onOffLabelType = '';
|
|
102
106
|
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, _extends({
|
|
103
107
|
align: "vertical",
|
|
104
108
|
isCover: false,
|
|
@@ -125,9 +129,26 @@ var Switch = /*#__PURE__*/function (_React$Component) {
|
|
|
125
129
|
htmlFor: id,
|
|
126
130
|
"data-id": dataId,
|
|
127
131
|
"data-test-id": dataId,
|
|
128
|
-
className: "".concat(_SwitchModule["default"].label, " ").concat(_SwitchModule["default"]["".concat(size, "Label")], " ").concat(customSwitch),
|
|
132
|
+
className: "".concat(_SwitchModule["default"].label, " ").concat(_SwitchModule["default"]["".concat(size, "Label")], " ").concat(customSwitch, " ").concat(onOffLabelType === 'labelOnTrack' && isOnOffLabelEnabled ? _SwitchModule["default"].labelOnTrack : ''),
|
|
129
133
|
tabIndex: isReadOnly || disabled ? '-1' : '0'
|
|
130
|
-
}
|
|
134
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
135
|
+
className: _SwitchModule["default"].thumb
|
|
136
|
+
}, isOnOffLabelEnabled && onOffLabelType === 'thumb' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
137
|
+
className: _SwitchModule["default"].onOffIndicationHolder
|
|
138
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
139
|
+
className: "".concat(_SwitchModule["default"].onOffIndication, " ").concat(checked ? _SwitchModule["default"].onIndication : _SwitchModule["default"].offIndication)
|
|
140
|
+
}))), isOnOffLabelEnabled && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
141
|
+
align: "vertical",
|
|
142
|
+
alignBox: checked ? 'row' : 'row-reverse',
|
|
143
|
+
className: _SwitchModule["default"].onOffLabel,
|
|
144
|
+
isCover: false
|
|
145
|
+
}, onOffLabelType === 'labelOnTrack' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
146
|
+
className: _SwitchModule["default"].onOffIndicationText
|
|
147
|
+
}, checked ? 'ON' : 'OFF'), isOnOffLabelEnabled && onOffLabelType === 'track' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
148
|
+
className: "".concat(_SwitchModule["default"].onOffIndication, " ").concat(checked ? _SwitchModule["default"].onIndication : _SwitchModule["default"].offIndication, " ").concat(_SwitchModule["default"].thumbIndication)
|
|
149
|
+
})))), isOnOffLabelEnabled && onOffLabelType === 'labelSide' && /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
150
|
+
className: "".concat(_SwitchModule["default"].labelText, " ").concat(size === "switch_medium" ? _SwitchModule["default"].mediumLabelText : _SwitchModule["default"].smallLabelText)
|
|
151
|
+
}, checked ? 'On' : 'Off'), text && /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({
|
|
131
152
|
text: text,
|
|
132
153
|
palette: labelPalette,
|
|
133
154
|
id: id,
|
|
@@ -137,6 +158,15 @@ var Switch = /*#__PURE__*/function (_React$Component) {
|
|
|
137
158
|
customClass: customLabel
|
|
138
159
|
}, LabelProps)));
|
|
139
160
|
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "render",
|
|
163
|
+
value: function render() {
|
|
164
|
+
var _this2 = this;
|
|
165
|
+
|
|
166
|
+
return /*#__PURE__*/_react["default"].createElement(_LibraryContextInit["default"].Consumer, null, function (context) {
|
|
167
|
+
return _this2.renderSwitch(context);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
140
170
|
}]);
|
|
141
171
|
|
|
142
172
|
return Switch;
|