@commercetools-uikit/toggle-input 15.15.0 → 16.0.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/dist/commercetools-uikit-toggle-input.cjs.d.ts +1 -0
- package/dist/commercetools-uikit-toggle-input.cjs.d.ts.map +1 -0
- package/dist/commercetools-uikit-toggle-input.cjs.dev.js +75 -101
- package/dist/commercetools-uikit-toggle-input.cjs.prod.js +75 -101
- package/dist/commercetools-uikit-toggle-input.esm.js +75 -101
- package/package.json +5 -5
|
@@ -33,150 +33,124 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
|
|
|
33
33
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
34
34
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return /*#__PURE__*/react.css("height:", props.themedTrack[props.size].height, ";width:", props.themedTrack[props.size].width, ";" + ("" ), "" );
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
var getThumbSize = function getThumbSize(props) {
|
|
89
|
-
return props.themedThumb[props.size].diameter;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
var getThumbShift = function getThumbShift(props) {
|
|
36
|
+
const getThemedTrack = themedValue => themedValue({
|
|
37
|
+
small: {
|
|
38
|
+
width: '32px',
|
|
39
|
+
height: '16px'
|
|
40
|
+
},
|
|
41
|
+
big: {
|
|
42
|
+
width: '64px',
|
|
43
|
+
height: '32px'
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
small: {
|
|
47
|
+
width: '29px',
|
|
48
|
+
height: '12px'
|
|
49
|
+
},
|
|
50
|
+
big: {
|
|
51
|
+
width: '56px',
|
|
52
|
+
height: '24px'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const getThemedThumb = themedValue => themedValue({
|
|
57
|
+
small: {
|
|
58
|
+
diameter: '13px',
|
|
59
|
+
shift: '2px',
|
|
60
|
+
hoverAreaWidth: '0px'
|
|
61
|
+
},
|
|
62
|
+
big: {
|
|
63
|
+
diameter: '26px',
|
|
64
|
+
shift: '3px',
|
|
65
|
+
hoverAreaWidth: '0px'
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
small: {
|
|
69
|
+
diameter: '18px',
|
|
70
|
+
shift: '3px',
|
|
71
|
+
hoverAreaWidth: '4px'
|
|
72
|
+
},
|
|
73
|
+
big: {
|
|
74
|
+
diameter: '32px',
|
|
75
|
+
shift: '4px',
|
|
76
|
+
hoverAreaWidth: '8px'
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const labelSizeStyles = props => /*#__PURE__*/react.css("height:", props.themedTrack[props.size].height, ";width:", props.themedTrack[props.size].width, ";" + ("" ), "" );
|
|
81
|
+
|
|
82
|
+
const getThumbSize = props => props.themedThumb[props.size].diameter;
|
|
83
|
+
|
|
84
|
+
const getThumbShift = props => {
|
|
93
85
|
var _context;
|
|
94
86
|
|
|
95
87
|
return _concatInstanceProperty__default["default"](_context = "".concat(props.isNewTheme ? '-' : '')).call(_context, props.themedThumb[props.size].shift);
|
|
96
88
|
};
|
|
97
89
|
|
|
98
|
-
|
|
90
|
+
const getNewThemeTransformation = props => {
|
|
99
91
|
var _context2, _context3;
|
|
100
92
|
|
|
101
93
|
return _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "calc(".concat(props.themedThumb[props.size].shift, " * 2 + ")).call(_context3, props.themedTrack[props.size].width, " - ")).call(_context2, props.themedThumb[props.size].diameter, ")");
|
|
102
94
|
};
|
|
103
95
|
|
|
104
|
-
|
|
105
|
-
return props.size === 'small' ? '117%' : '127%';
|
|
106
|
-
};
|
|
96
|
+
const getOldThemeTransformation = props => props.size === 'small' ? '117%' : '127%';
|
|
107
97
|
|
|
108
|
-
|
|
98
|
+
const getFocusIndicatorWidth = props => {
|
|
109
99
|
var _context4, _context5;
|
|
110
100
|
|
|
111
101
|
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "\n calc(\n ".concat(props.themedTrack[props.size].width, " + 2 *\n ")).call(_context5, props.themedThumb[props.size].hoverAreaWidth, " + 2 *\n ")).call(_context4, props.themedThumb[props.size].shift, " + 2px\n )");
|
|
112
102
|
};
|
|
113
103
|
|
|
114
|
-
|
|
104
|
+
const getFocusIndicatorHeight = props => {
|
|
115
105
|
var _context6;
|
|
116
106
|
|
|
117
107
|
return _concatInstanceProperty__default["default"](_context6 = "\n calc(\n ".concat(props.themedThumb[props.size].diameter, " + 2 *\n ")).call(_context6, props.themedThumb[props.size].hoverAreaWidth, " + 2px\n )\n");
|
|
118
108
|
};
|
|
119
109
|
|
|
120
|
-
|
|
110
|
+
const getFocusIndicatorLeftPositioning = props => {
|
|
121
111
|
var _context7;
|
|
122
112
|
|
|
123
113
|
return _concatInstanceProperty__default["default"](_context7 = "\n calc(\n -".concat(props.themedThumb[props.size].hoverAreaWidth, " - ")).call(_context7, props.themedThumb[props.size].shift, " - 1px\n )\n");
|
|
124
114
|
};
|
|
125
115
|
|
|
126
|
-
|
|
127
|
-
return "calc(-50% - ".concat(props.size === 'small' ? '2px' : '1px', ")");
|
|
128
|
-
};
|
|
116
|
+
const getFocusIndicatorTopPositioning = props => "calc(-50% - ".concat(props.size === 'small' ? '2px' : '1px', ")");
|
|
129
117
|
|
|
130
|
-
|
|
131
|
-
return /*#__PURE__*/react.css("&::after{content:'';position:absolute;outline:auto 2px ", designSystem.designTokens.borderColorForInputWhenFocused, ";height:", getFocusIndicatorHeight(props), ";top:", getFocusIndicatorTopPositioning(props), ";width:", getFocusIndicatorWidth(props), ";left:", getFocusIndicatorLeftPositioning(props), ";}" + ("" ), "" );
|
|
132
|
-
};
|
|
118
|
+
const getNewThemeFocusIndicator = props => /*#__PURE__*/react.css("&::after{content:'';position:absolute;outline:auto 2px ", designSystem.designTokens.borderColorForInputWhenFocused, ";height:", getFocusIndicatorHeight(props), ";top:", getFocusIndicatorTopPositioning(props), ";width:", getFocusIndicatorWidth(props), ";left:", getFocusIndicatorLeftPositioning(props), ";}" + ("" ), "" );
|
|
133
119
|
|
|
134
|
-
|
|
120
|
+
const getNewThemeMargin = props => {
|
|
135
121
|
var _context8, _context9;
|
|
136
122
|
|
|
137
123
|
return _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = "calc(2px + ".concat(props.themedThumb[props.size].hoverAreaWidth, " + (")).call(_context9, props.themedThumb[props.size].diameter, " - ")).call(_context8, props.themedTrack[props.size].height, ") / 2)");
|
|
138
124
|
};
|
|
139
125
|
|
|
140
|
-
|
|
141
|
-
return /*#__PURE__*/react.css("margin:", props.isNewTheme ? "".concat(getNewThemeMargin(props), " !important") : 'unset', ";" + ("" ), "" );
|
|
142
|
-
};
|
|
126
|
+
const getMargin = props => /*#__PURE__*/react.css("margin:", props.isNewTheme ? "".concat(getNewThemeMargin(props), " !important") : 'unset', ";" + ("" ), "" );
|
|
143
127
|
|
|
144
|
-
|
|
128
|
+
const Label = /*#__PURE__*/_styled__default["default"]("label", {
|
|
145
129
|
target: "e1p8kklm1"
|
|
146
|
-
} )("position:relative;display:inline-block;cursor:",
|
|
147
|
-
return props.isDisabled ? 'not-allowed' : 'pointer';
|
|
148
|
-
}, ";align-self:center;", getMargin, " ", labelSizeStyles, " &:focus-within{", function (props) {
|
|
149
|
-
return props.isNewTheme ? getNewThemeFocusIndicator : "outline: auto 2px ".concat(designSystem.designTokens.borderColorForInputWhenFocused, ";\n outline-offset: 3px;\n ");
|
|
150
|
-
}, ";}" + ("" ));
|
|
130
|
+
} )("position:relative;display:inline-block;cursor:", props => props.isDisabled ? 'not-allowed' : 'pointer', ";align-self:center;", getMargin, " ", labelSizeStyles, " &:focus-within{", props => props.isNewTheme ? getNewThemeFocusIndicator : "outline: auto 2px ".concat(designSystem.designTokens.borderColorForInputWhenFocused, ";\n outline-offset: 3px;\n "), ";}" + ("" ));
|
|
151
131
|
|
|
152
|
-
|
|
132
|
+
const Span = /*#__PURE__*/_styled__default["default"]("span", {
|
|
153
133
|
target: "e1p8kklm0"
|
|
154
|
-
} )("&::before{border-radius:",
|
|
155
|
-
|
|
156
|
-
}, ";box-shadow:",
|
|
157
|
-
return props.isNewTheme ? 'none' : designSystem.designTokens.shadow9;
|
|
158
|
-
}, ";background-color:", designSystem.designTokens.backgroundColorForToggleInputTrack, ";left:0;top:50%;transition:background 0.2s ease-in-out;content:'';position:absolute;transform:translateY(-50%);height:100%;width:100%;}&::after{content:'';position:absolute;transform:translateY(-50%);top:50%;left:", getThumbShift, ";height:", getThumbSize, ";width:", getThumbSize, ";background-color:", designSystem.designTokens.colorSurface, ";box-shadow:", designSystem.designTokens.shadowForToggleInputThumb, ";border-radius:50%;transition:transform 0.2s ease,background 0.2s ease;}" + ("" ));
|
|
159
|
-
|
|
160
|
-
var getInputStyles = function getInputStyles(props) {
|
|
161
|
-
return /*#__PURE__*/react.css("&:checked{+span::before{background:", designSystem.designTokens.backgroundColorForToggleInputTrackWhenChecked, ";}&+span::after{background:", designSystem.designTokens.backgroundColorForToggleInputThumbWhenChecked, ";transform:translate(\n ", props.isNewTheme ? getNewThemeTransformation(props) : getOldThemeTransformation(props), ",\n -50%\n );}}&:disabled{&+span::before{background:", designSystem.designTokens.backgroundColorForToggleInputTrackWhenDisabled, ";box-shadow:none;}&+span::after{background:", designSystem.designTokens.backgroundColorForToggleInputThumbWhenDisabled, ";box-shadow:", props.isNewTheme ? designSystem.designTokens.shadowForToggleInputThumb : 'none', ";}}&:disabled&:checked{&+span::before{background:", designSystem.designTokens.backgroundColorForToggleInputTrackWhenCheckedAndDisabled, ";}&+span::after{background:", designSystem.designTokens.backgroundColorForToggleInputThumbWhenCheckedAndDisabled, ";}}:not(:disabled)&:hover+span::after,:not(:disabled)&:focus+span::after{box-shadow:", props.isNewTheme ? 'none' : designSystem.designTokens.shadow16, ";outline:", props.isNewTheme ? "".concat(props.themedThumb[props.size].hoverAreaWidth, " solid rgba(0, 0, 0, 0.1)") : 'none', ";}" + ("" ), "" );
|
|
162
|
-
};
|
|
134
|
+
} )("&::before{border-radius:", props => props.isNewTheme ? '12px' : '16px', ";box-shadow:", props => props.isNewTheme ? 'none' : designSystem.designTokens.shadow9, ";background-color:", designSystem.designTokens.backgroundColorForToggleInputTrack, ";left:0;top:50%;transition:background 0.2s ease-in-out;content:'';position:absolute;transform:translateY(-50%);height:100%;width:100%;}&::after{content:'';position:absolute;transform:translateY(-50%);top:50%;left:", getThumbShift, ";height:", getThumbSize, ";width:", getThumbSize, ";background-color:", designSystem.designTokens.colorSurface, ";box-shadow:", designSystem.designTokens.shadowForToggleInputThumb, ";border-radius:50%;transition:transform 0.2s ease,background 0.2s ease;}" + ("" ));
|
|
135
|
+
|
|
136
|
+
const getInputStyles = props => /*#__PURE__*/react.css("&:checked{+span::before{background:", designSystem.designTokens.backgroundColorForToggleInputTrackWhenChecked, ";}&+span::after{background:", designSystem.designTokens.backgroundColorForToggleInputThumbWhenChecked, ";transform:translate(\n ", props.isNewTheme ? getNewThemeTransformation(props) : getOldThemeTransformation(props), ",\n -50%\n );}}&:disabled{&+span::before{background:", designSystem.designTokens.backgroundColorForToggleInputTrackWhenDisabled, ";box-shadow:none;}&+span::after{background:", designSystem.designTokens.backgroundColorForToggleInputThumbWhenDisabled, ";box-shadow:", props.isNewTheme ? designSystem.designTokens.shadowForToggleInputThumb : 'none', ";}}&:disabled&:checked{&+span::before{background:", designSystem.designTokens.backgroundColorForToggleInputTrackWhenCheckedAndDisabled, ";}&+span::after{background:", designSystem.designTokens.backgroundColorForToggleInputThumbWhenCheckedAndDisabled, ";}}:not(:disabled)&:hover+span::after,:not(:disabled)&:focus+span::after{box-shadow:", props.isNewTheme ? 'none' : designSystem.designTokens.shadow16, ";outline:", props.isNewTheme ? "".concat(props.themedThumb[props.size].hoverAreaWidth, " solid rgba(0, 0, 0, 0.1)") : 'none', ";}" + ("" ), "" );
|
|
163
137
|
|
|
164
138
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
165
139
|
|
|
166
140
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
167
|
-
|
|
141
|
+
const defaultProps = {
|
|
168
142
|
isDisabled: false,
|
|
169
143
|
isChecked: false,
|
|
170
144
|
size: 'big'
|
|
171
145
|
};
|
|
172
146
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
147
|
+
const ToggleInput = props => {
|
|
148
|
+
const _useTheme = designSystem.useTheme(),
|
|
149
|
+
isNewTheme = _useTheme.isNewTheme,
|
|
150
|
+
themedValue = _useTheme.themedValue;
|
|
177
151
|
|
|
178
|
-
|
|
179
|
-
|
|
152
|
+
const themedTrack = getThemedTrack(themedValue);
|
|
153
|
+
const themedThumb = getThemedThumb(themedValue);
|
|
180
154
|
return jsxRuntime.jsxs(Label, {
|
|
181
155
|
htmlFor: props.id,
|
|
182
156
|
size: props.size,
|
|
@@ -187,9 +161,9 @@ var ToggleInput = function ToggleInput(props) {
|
|
|
187
161
|
children: [jsxRuntime.jsx("input", _objectSpread(_objectSpread({
|
|
188
162
|
type: "checkbox",
|
|
189
163
|
css: [inputUtils.accessibleHiddenInputStyles, getInputStyles(_objectSpread(_objectSpread({}, props), {}, {
|
|
190
|
-
isNewTheme
|
|
191
|
-
themedTrack
|
|
192
|
-
themedThumb
|
|
164
|
+
isNewTheme,
|
|
165
|
+
themedTrack,
|
|
166
|
+
themedThumb
|
|
193
167
|
})), "" , "" ],
|
|
194
168
|
id: props.id,
|
|
195
169
|
name: props.name,
|
|
@@ -213,7 +187,7 @@ ToggleInput.defaultProps = defaultProps;
|
|
|
213
187
|
var ToggleInput$1 = ToggleInput;
|
|
214
188
|
|
|
215
189
|
// NOTE: This string will be replaced on build time with the package version.
|
|
216
|
-
var version = "
|
|
190
|
+
var version = "16.0.0";
|
|
217
191
|
|
|
218
192
|
exports["default"] = ToggleInput$1;
|
|
219
193
|
exports.version = version;
|