@zohodesk/components 1.0.0-temp-217.2 → 1.0.0-temp-219
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/README.md +6 -1
- package/es/Button/Button.js +10 -2
- package/es/CheckBox/CheckBox.js +1 -1
- package/es/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +2 -2
- package/es/Provider/LibraryContext.js +1 -3
- package/es/Select/Select.js +4 -1
- package/es/Switch/Switch.js +14 -29
- package/es/Switch/Switch.module.css +15 -126
- package/es/TextBox/TextBox.js +9 -2
- package/es/index.js +0 -1
- package/lib/Button/Button.js +12 -2
- package/lib/CheckBox/CheckBox.js +1 -1
- package/lib/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +2 -2
- package/lib/Provider/LibraryContext.js +1 -3
- package/lib/Select/Select.js +7 -1
- package/lib/Switch/Switch.js +15 -36
- package/lib/Switch/Switch.module.css +15 -126
- package/lib/TextBox/TextBox.js +9 -2
- package/lib/index.js +0 -9
- package/package.json +4 -2
- package/result.json +1 -1
- package/es/SwitchNew/SwitchNew.js +0 -118
- package/es/SwitchNew/SwitchNew.module.css +0 -229
- package/es/SwitchNew/props/defaultProps.js +0 -9
- package/es/SwitchNew/props/propTypes.js +0 -32
- package/lib/SwitchNew/SwitchNew.js +0 -148
- package/lib/SwitchNew/SwitchNew.module.css +0 -229
- package/lib/SwitchNew/props/defaultProps.js +0 -16
- package/lib/SwitchNew/props/propTypes.js +0 -43
|
@@ -1,118 +0,0 @@
|
|
|
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(--switch-off-label-size)'} ${checked ? 'var(--switch-on-label-height)' : 'var(--switch-off-label-size)'}`,
|
|
91
|
-
className: `${checked ? style[`${size}OnLabelWrapper`] : style[`${size}OffLabelWrapper`]} ${style.labelWrapper}`
|
|
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;
|
|
@@ -1,229 +0,0 @@
|
|
|
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(--switch-track-width);
|
|
16
|
-
height: var(--switch-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(--switch-thumb-size);
|
|
26
|
-
height: var(--switch-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(--switch-track-width) - var(--switch-thumb-size) - 4px));
|
|
49
|
-
}
|
|
50
|
-
[dir=rtl] .track:checked + .thumb {
|
|
51
|
-
transform: translateX(calc(-1*(var(--switch-track-width) - var(--switch-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
|
-
--switch-track-width: var(--zd_size22);
|
|
66
|
-
--switch-track-height: var(--zd_size12);
|
|
67
|
-
--switch-thumb-size: var(--zd_size8);
|
|
68
|
-
/* --switch-off-label-size: 7px;
|
|
69
|
-
--switch-off-label-radius: 2.5px;
|
|
70
|
-
--switch-off-label-top: 2.5px;
|
|
71
|
-
--switch-off-label-right: 3px;
|
|
72
|
-
--switch-off-label-stroke: 1px;
|
|
73
|
-
--switch-on-label-width: 1.2px;
|
|
74
|
-
--switch-on-label-height: 6px;
|
|
75
|
-
--switch-on-label-top: 3px;
|
|
76
|
-
--switch-on-label-left: 5px; */
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.medium_switch {
|
|
80
|
-
--switch-track-width: var(--zd_size28);
|
|
81
|
-
--switch-track-height: var(--zd_size16);
|
|
82
|
-
--switch-thumb-size: var(--zd_size12);
|
|
83
|
-
/* --switch-off-label-size: 8px;
|
|
84
|
-
--switch-off-label-radius: 3px;
|
|
85
|
-
--switch-off-label-top: 4px;
|
|
86
|
-
--switch-off-label-right: 3.5px;
|
|
87
|
-
--switch-off-label-stroke: 1.1px;
|
|
88
|
-
--switch-on-label-width: 1.4px;
|
|
89
|
-
--switch-on-label-height: 8px;
|
|
90
|
-
--switch-on-label-top: 4px;
|
|
91
|
-
--switch-on-label-left: 6px; */
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.large_switch {
|
|
95
|
-
--switch-track-width: var(--zd_size34);
|
|
96
|
-
--switch-track-height: var(--zd_size20);
|
|
97
|
-
--switch-thumb-size: var(--zd_size16);
|
|
98
|
-
/* --switch-off-label-size: 9px;
|
|
99
|
-
--switch-off-label-radius: 3.5px;
|
|
100
|
-
--switch-off-label-top: 5.5px;
|
|
101
|
-
--switch-off-label-right: 4px;
|
|
102
|
-
--switch-off-label-stroke: 1.2px;
|
|
103
|
-
--switch-on-label-width: 1.6px;
|
|
104
|
-
--switch-on-label-height: 11px;
|
|
105
|
-
--switch-on-label-top: 4.5px;
|
|
106
|
-
--switch-on-label-left: 7px; */
|
|
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(--switch-off-label-size);
|
|
127
|
-
height: var(--switch-off-label-size);
|
|
128
|
-
top: var(--switch-off-label-top);
|
|
129
|
-
right: var(--switch-off-label-right);
|
|
130
|
-
}
|
|
131
|
-
.onLabelWrapper {
|
|
132
|
-
width: var(--switch-on-label-width);
|
|
133
|
-
height: var(--switch-on-label-height);
|
|
134
|
-
top: var(--switch-on-label-top);
|
|
135
|
-
left: var(--switch-on-label-left);
|
|
136
|
-
} */
|
|
137
|
-
.labelWrapper {
|
|
138
|
-
position: absolute;
|
|
139
|
-
pointer-events: none;
|
|
140
|
-
}
|
|
141
|
-
.smallOnLabelWrapper {
|
|
142
|
-
width: 1.2px;
|
|
143
|
-
height: var(--zd_size6) ;
|
|
144
|
-
top: var(--zd_size3) ;
|
|
145
|
-
}
|
|
146
|
-
[dir=ltr] .smallOnLabelWrapper {
|
|
147
|
-
left: var(--zd_size5) ;
|
|
148
|
-
}
|
|
149
|
-
[dir=rtl] .smallOnLabelWrapper {
|
|
150
|
-
right: var(--zd_size5) ;
|
|
151
|
-
}
|
|
152
|
-
.mediumOnLabelWrapper {
|
|
153
|
-
width: 1.4px;
|
|
154
|
-
height: var(--zd_size8) ;
|
|
155
|
-
top: var(--zd_size4) ;
|
|
156
|
-
}
|
|
157
|
-
[dir=ltr] .mediumOnLabelWrapper {
|
|
158
|
-
left: var(--zd_size6) ;
|
|
159
|
-
}
|
|
160
|
-
[dir=rtl] .mediumOnLabelWrapper {
|
|
161
|
-
right: var(--zd_size6) ;
|
|
162
|
-
}
|
|
163
|
-
.largeOnLabelWrapper {
|
|
164
|
-
width: 1.6px;
|
|
165
|
-
height: var(--zd_size11) ;
|
|
166
|
-
top: 4.5px;
|
|
167
|
-
}
|
|
168
|
-
[dir=ltr] .largeOnLabelWrapper {
|
|
169
|
-
left: var(--zd_size7) ;
|
|
170
|
-
}
|
|
171
|
-
[dir=rtl] .largeOnLabelWrapper {
|
|
172
|
-
right: var(--zd_size7) ;
|
|
173
|
-
}
|
|
174
|
-
.smallOffLabelWrapper {
|
|
175
|
-
width: var(--zd_size7) ;
|
|
176
|
-
height: var(--zd_size7) ;
|
|
177
|
-
top: 2.5px;
|
|
178
|
-
}
|
|
179
|
-
[dir=ltr] .smallOffLabelWrapper {
|
|
180
|
-
right: var(--zd_size3) ;
|
|
181
|
-
}
|
|
182
|
-
[dir=rtl] .smallOffLabelWrapper {
|
|
183
|
-
left: var(--zd_size3) ;
|
|
184
|
-
}
|
|
185
|
-
.mediumOffLabelWrapper {
|
|
186
|
-
width: var(--zd_size8) ;
|
|
187
|
-
height: var(--zd_size8) ;
|
|
188
|
-
top: var(--zd_size4) ;
|
|
189
|
-
}
|
|
190
|
-
[dir=ltr] .mediumOffLabelWrapper {
|
|
191
|
-
right: 3.5px;
|
|
192
|
-
}
|
|
193
|
-
[dir=rtl] .mediumOffLabelWrapper {
|
|
194
|
-
left: 3.5px;
|
|
195
|
-
}
|
|
196
|
-
.largeOffLabelWrapper {
|
|
197
|
-
width: var(--zd_size9) ;
|
|
198
|
-
height: var(--zd_size9) ;
|
|
199
|
-
top: 5.5px;
|
|
200
|
-
}
|
|
201
|
-
[dir=ltr] .largeOffLabelWrapper {
|
|
202
|
-
right: var(--zd_size4) ;
|
|
203
|
-
}
|
|
204
|
-
[dir=rtl] .largeOffLabelWrapper {
|
|
205
|
-
left: var(--zd_size4) ;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.offLabel {
|
|
209
|
-
stroke: var(--dot_shuttleGrey);
|
|
210
|
-
/* stroke-width: var(--switch-off-label-stroke); */
|
|
211
|
-
/* r: var(--switch-off-label-radius); */
|
|
212
|
-
fill: none;
|
|
213
|
-
}
|
|
214
|
-
.smallOffLabelWrapper .offLabel {
|
|
215
|
-
stroke-width: 1px;
|
|
216
|
-
r: 2.5px;
|
|
217
|
-
}
|
|
218
|
-
.mediumOffLabelWrapper .offLabel {
|
|
219
|
-
stroke-width: 1.1px;
|
|
220
|
-
r: 3px;
|
|
221
|
-
}
|
|
222
|
-
.largeOffLabelWrapper .offLabel {
|
|
223
|
-
stroke-width: 1.2px;
|
|
224
|
-
r: 3.5px;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
.onLabel {
|
|
228
|
-
fill: var(--dot_white);
|
|
229
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,148 +0,0 @@
|
|
|
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 _Layout = require("../Layout");
|
|
13
|
-
|
|
14
|
-
var _Label = _interopRequireDefault(require("../Label/Label"));
|
|
15
|
-
|
|
16
|
-
var _SwitchNewModule = _interopRequireDefault(require("./SwitchNew.module.css"));
|
|
17
|
-
|
|
18
|
-
var _defaultProps = require("./props/defaultProps");
|
|
19
|
-
|
|
20
|
-
var _propTypes = require("./props/propTypes");
|
|
21
|
-
|
|
22
|
-
var _LibraryContextInit = _interopRequireDefault(require("../Provider/LibraryContextInit"));
|
|
23
|
-
|
|
24
|
-
var _excluded = ["role"];
|
|
25
|
-
|
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
|
-
|
|
28
|
-
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); }
|
|
29
|
-
|
|
30
|
-
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; }
|
|
31
|
-
|
|
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); }
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
|
|
36
|
-
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; }
|
|
37
|
-
|
|
38
|
-
var SwitchNew = function SwitchNew(props) {
|
|
39
|
-
var id = props.id,
|
|
40
|
-
title = props.title,
|
|
41
|
-
name = props.name,
|
|
42
|
-
value = props.value,
|
|
43
|
-
checked = props.checked,
|
|
44
|
-
disabled = props.disabled,
|
|
45
|
-
isReadOnly = props.isReadOnly,
|
|
46
|
-
size = props.size,
|
|
47
|
-
text = props.text,
|
|
48
|
-
disableTitle = props.disableTitle,
|
|
49
|
-
dataId = props.dataId,
|
|
50
|
-
dataSelectorId = props.dataSelectorId,
|
|
51
|
-
onChange = props.onChange,
|
|
52
|
-
customProps = props.customProps,
|
|
53
|
-
customClass = props.customClass,
|
|
54
|
-
labelSize = props.labelSize,
|
|
55
|
-
labelPlacement = props.labelPlacement,
|
|
56
|
-
a11y = props.a11y;
|
|
57
|
-
|
|
58
|
-
var handleChange = function handleChange(e) {
|
|
59
|
-
if (!disabled && !isReadOnly && onChange) {
|
|
60
|
-
onChange(!checked, e);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
var _ref = customProps || {},
|
|
65
|
-
_ref$SwitchProps = _ref.SwitchProps,
|
|
66
|
-
SwitchProps = _ref$SwitchProps === void 0 ? {} : _ref$SwitchProps,
|
|
67
|
-
_ref$LabelProps = _ref.LabelProps,
|
|
68
|
-
LabelProps = _ref$LabelProps === void 0 ? {} : _ref$LabelProps;
|
|
69
|
-
|
|
70
|
-
var _SwitchProps$WrapperP = SwitchProps.WrapperProps,
|
|
71
|
-
WrapperProps = _SwitchProps$WrapperP === void 0 ? {} : _SwitchProps$WrapperP,
|
|
72
|
-
_SwitchProps$TrackPro = SwitchProps.TrackProps,
|
|
73
|
-
TrackProps = _SwitchProps$TrackPro === void 0 ? {} : _SwitchProps$TrackPro;
|
|
74
|
-
|
|
75
|
-
var _ref2 = customClass || {},
|
|
76
|
-
_ref2$customSwitchWra = _ref2.customSwitchWrap,
|
|
77
|
-
customSwitchWrap = _ref2$customSwitchWra === void 0 ? '' : _ref2$customSwitchWra,
|
|
78
|
-
_ref2$customSwitch = _ref2.customSwitch,
|
|
79
|
-
customSwitch = _ref2$customSwitch === void 0 ? '' : _ref2$customSwitch,
|
|
80
|
-
_ref2$customLabel = _ref2.customLabel,
|
|
81
|
-
customLabel = _ref2$customLabel === void 0 ? '' : _ref2$customLabel;
|
|
82
|
-
|
|
83
|
-
var _ref3 = a11y || {},
|
|
84
|
-
_ref3$role = _ref3.role,
|
|
85
|
-
role = _ref3$role === void 0 ? 'switch' : _ref3$role,
|
|
86
|
-
a11yAttributes = _objectWithoutProperties(_ref3, _excluded);
|
|
87
|
-
|
|
88
|
-
var context = (0, _react.useContext)(_LibraryContextInit["default"]);
|
|
89
|
-
var _context$a11y_onOffLa = context.a11y_onOffLabel,
|
|
90
|
-
a11y_onOffLabel = _context$a11y_onOffLa === void 0 ? true : _context$a11y_onOffLa;
|
|
91
|
-
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, _extends({
|
|
92
|
-
align: "vertical",
|
|
93
|
-
isCover: false,
|
|
94
|
-
isInline: true,
|
|
95
|
-
alignBox: labelPlacement == 'right' ? 'row' : 'row-reverse',
|
|
96
|
-
"data-title": disabled ? disableTitle : title,
|
|
97
|
-
dataSelectorId: dataSelectorId,
|
|
98
|
-
className: customSwitchWrap ? customSwitchWrap : ''
|
|
99
|
-
}, WrapperProps), /*#__PURE__*/_react["default"].createElement("div", {
|
|
100
|
-
className: "".concat(_SwitchNewModule["default"].switchWrapper, " ").concat(_SwitchNewModule["default"]["".concat(size, "_switch")], " ").concat(!disabled && !isReadOnly ? _SwitchNewModule["default"].effect : '', " ").concat(disabled ? _SwitchNewModule["default"].disabled : '')
|
|
101
|
-
}, /*#__PURE__*/_react["default"].createElement("input", _extends({
|
|
102
|
-
type: "checkbox",
|
|
103
|
-
id: id,
|
|
104
|
-
name: name,
|
|
105
|
-
value: value,
|
|
106
|
-
checked: checked,
|
|
107
|
-
disabled: disabled,
|
|
108
|
-
readOnly: isReadOnly,
|
|
109
|
-
onChange: handleChange,
|
|
110
|
-
role: role,
|
|
111
|
-
"aria-checked": checked,
|
|
112
|
-
tabIndex: disabled ? -1 : 0,
|
|
113
|
-
"data-id": dataId,
|
|
114
|
-
"data-test-id": dataId,
|
|
115
|
-
className: "".concat(_SwitchNewModule["default"].track, " ").concat(customSwitch, " ").concat(a11y_onOffLabel ? checked ? _SwitchNewModule["default"].onLabel : _SwitchNewModule["default"].offLabel : '')
|
|
116
|
-
}, a11yAttributes, TrackProps)), /*#__PURE__*/_react["default"].createElement("span", {
|
|
117
|
-
className: _SwitchNewModule["default"].thumb
|
|
118
|
-
}), a11y_onOffLabel ? /*#__PURE__*/_react["default"].createElement("svg", {
|
|
119
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
120
|
-
viewBox: "0 0 ".concat(checked ? '2' : 'var(--switch-off-label-size)', " ").concat(checked ? 'var(--switch-on-label-height)' : 'var(--switch-off-label-size)'),
|
|
121
|
-
className: "".concat(checked ? _SwitchNewModule["default"]["".concat(size, "OnLabelWrapper")] : _SwitchNewModule["default"]["".concat(size, "OffLabelWrapper")], " ").concat(_SwitchNewModule["default"].labelWrapper)
|
|
122
|
-
}, checked ? /*#__PURE__*/_react["default"].createElement("rect", {
|
|
123
|
-
x: "0",
|
|
124
|
-
rx: "0.8",
|
|
125
|
-
ry: "0.8",
|
|
126
|
-
width: "100%",
|
|
127
|
-
height: "100%",
|
|
128
|
-
className: _SwitchNewModule["default"].onLabel
|
|
129
|
-
}) : /*#__PURE__*/_react["default"].createElement("circle", {
|
|
130
|
-
className: _SwitchNewModule["default"].offLabel,
|
|
131
|
-
cx: "50%",
|
|
132
|
-
cy: "50%",
|
|
133
|
-
width: "100%",
|
|
134
|
-
height: "100%",
|
|
135
|
-
fill: "none"
|
|
136
|
-
})) : null), text && /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({
|
|
137
|
-
customClass: " ".concat(_SwitchNewModule["default"]["switchLabel_".concat(labelPlacement)], " ").concat(customLabel ? customLabel : ''),
|
|
138
|
-
htmlFor: id,
|
|
139
|
-
size: labelSize,
|
|
140
|
-
type: "subtitle",
|
|
141
|
-
text: text
|
|
142
|
-
}, LabelProps)));
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
var _default = SwitchNew;
|
|
146
|
-
exports["default"] = _default;
|
|
147
|
-
SwitchNew.defaultProps = _defaultProps.defaultProps;
|
|
148
|
-
SwitchNew.propTypes = _propTypes.propTypes;
|