@commercetools-uikit/checkbox-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.
@@ -37,13 +37,13 @@ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInsta
37
37
  function ownKeys$3(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; }
38
38
 
39
39
  function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$3(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$3(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
40
- var iconSizes$1 = {
40
+ const iconSizes$1 = {
41
41
  small: 12,
42
42
  medium: 16,
43
43
  big: 24
44
44
  };
45
45
 
46
- var getSizeDimensions$1 = function getSizeDimensions(size) {
46
+ const getSizeDimensions$1 = size => {
47
47
  switch (size) {
48
48
  case 'scale':
49
49
  return {
@@ -67,10 +67,10 @@ var getSizeDimensions$1 = function getSizeDimensions(size) {
67
67
  }
68
68
  };
69
69
 
70
- var getSizeStyle$1 = function getSizeStyle(size) {
70
+ const getSizeStyle$1 = size => {
71
71
  var _context, _context2;
72
72
 
73
- var dimensions = getSizeDimensions$1(size);
73
+ const dimensions = getSizeDimensions$1(size);
74
74
 
75
75
  switch (size) {
76
76
  case 'scale':
@@ -81,9 +81,9 @@ var getSizeStyle$1 = function getSizeStyle(size) {
81
81
  }
82
82
  };
83
83
 
84
- var getColor$1 = function getColor(color) {
84
+ const getColor$1 = color => {
85
85
  if (!color) return 'inherit';
86
- var iconColor;
86
+ let iconColor;
87
87
 
88
88
  switch (color) {
89
89
  case 'solid':
@@ -126,45 +126,39 @@ var getColor$1 = function getColor(color) {
126
126
  return iconColor;
127
127
  };
128
128
 
129
- var getIconStyles$1 = function getIconStyles(props) {
130
- return /*#__PURE__*/react.css("*:not([fill='none']){fill:", getColor$1(props.color), ";}&,image{", getSizeStyle$1(props.size), ";}flex-shrink:0;" + ("" ), "" );
131
- };
132
-
133
- var SvgChecked = function SvgChecked(props) {
134
- return jsxRuntime.jsxs("svg", _objectSpread$3(_objectSpread$3({
135
- xmlns: "http://www.w3.org/2000/svg",
136
- width: 12,
137
- height: 9,
138
- fill: "none",
139
- viewBox: "0 0 12 9",
140
- role: "img"
141
- }, props), {}, {
142
- children: [jsxRuntime.jsx("path", {
143
- fill: "#000",
144
- fillRule: "evenodd",
145
- d: "M.293 4.293a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1-1.414 1.414l-3-3a1 1 0 0 1 0-1.414Z",
146
- clipRule: "evenodd"
147
- }), jsxRuntime.jsx("path", {
148
- fill: "#000",
149
- fillRule: "evenodd",
150
- d: "M11.707.293a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414l7-7a1 1 0 0 1 1.414 0Z",
151
- clipRule: "evenodd"
152
- })]
153
- }));
154
- };
129
+ const getIconStyles$1 = props => /*#__PURE__*/react.css("*:not([fill='none']){fill:", getColor$1(props.color), ";}&,image{", getSizeStyle$1(props.size), ";}flex-shrink:0;" + ("" ), "" );
130
+
131
+ const SvgChecked = props => jsxRuntime.jsxs("svg", _objectSpread$3(_objectSpread$3({
132
+ xmlns: "http://www.w3.org/2000/svg",
133
+ width: 12,
134
+ height: 9,
135
+ fill: "none",
136
+ viewBox: "0 0 12 9",
137
+ role: "img"
138
+ }, props), {}, {
139
+ children: [jsxRuntime.jsx("path", {
140
+ fill: "#000",
141
+ fillRule: "evenodd",
142
+ d: "M.293 4.293a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1-1.414 1.414l-3-3a1 1 0 0 1 0-1.414Z",
143
+ clipRule: "evenodd"
144
+ }), jsxRuntime.jsx("path", {
145
+ fill: "#000",
146
+ fillRule: "evenodd",
147
+ d: "M11.707.293a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414l7-7a1 1 0 0 1 1.414 0Z",
148
+ clipRule: "evenodd"
149
+ })]
150
+ }));
155
151
 
156
152
  SvgChecked.displayName = 'SvgChecked';
157
153
 
158
- var CheckedIcon = function CheckedIcon(props) {
159
- return jsxRuntime.jsx(react.ClassNames, {
160
- children: function children(_ref) {
161
- var createClass = _ref.css;
162
- return jsxRuntime.jsx(SvgChecked, _objectSpread$3(_objectSpread$3({}, props), {}, {
163
- className: createClass(getIconStyles$1(props))
164
- }));
165
- }
166
- });
167
- };
154
+ const CheckedIcon = props => jsxRuntime.jsx(react.ClassNames, {
155
+ children: _ref => {
156
+ let createClass = _ref.css;
157
+ return jsxRuntime.jsx(SvgChecked, _objectSpread$3(_objectSpread$3({}, props), {}, {
158
+ className: createClass(getIconStyles$1(props))
159
+ }));
160
+ }
161
+ });
168
162
 
169
163
  CheckedIcon.displayName = 'CheckedIcon';
170
164
  var CheckedIcon$1 = CheckedIcon;
@@ -172,13 +166,13 @@ var CheckedIcon$1 = CheckedIcon;
172
166
  function ownKeys$2(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; }
173
167
 
174
168
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$2(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$2(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
175
- var iconSizes = {
169
+ const iconSizes = {
176
170
  small: 12,
177
171
  medium: 16,
178
172
  big: 24
179
173
  };
180
174
 
181
- var getSizeDimensions = function getSizeDimensions(size) {
175
+ const getSizeDimensions = size => {
182
176
  switch (size) {
183
177
  case 'scale':
184
178
  return {
@@ -202,10 +196,10 @@ var getSizeDimensions = function getSizeDimensions(size) {
202
196
  }
203
197
  };
204
198
 
205
- var getSizeStyle = function getSizeStyle(size) {
199
+ const getSizeStyle = size => {
206
200
  var _context, _context2;
207
201
 
208
- var dimensions = getSizeDimensions(size);
202
+ const dimensions = getSizeDimensions(size);
209
203
 
210
204
  switch (size) {
211
205
  case 'scale':
@@ -216,9 +210,9 @@ var getSizeStyle = function getSizeStyle(size) {
216
210
  }
217
211
  };
218
212
 
219
- var getColor = function getColor(color) {
213
+ const getColor = color => {
220
214
  if (!color) return 'inherit';
221
- var iconColor;
215
+ let iconColor;
222
216
 
223
217
  switch (color) {
224
218
  case 'solid':
@@ -261,40 +255,34 @@ var getColor = function getColor(color) {
261
255
  return iconColor;
262
256
  };
263
257
 
264
- var getIconStyles = function getIconStyles(props) {
265
- return /*#__PURE__*/react.css("*:not([fill='none']){fill:", getColor(props.color), ";}&,image{", getSizeStyle(props.size), ";}flex-shrink:0;" + ("" ), "" );
266
- };
267
-
268
- var SvgIndeterminate = function SvgIndeterminate(props) {
269
- return jsxRuntime.jsx("svg", _objectSpread$2(_objectSpread$2({
270
- xmlns: "http://www.w3.org/2000/svg",
271
- width: 12,
272
- height: 2,
273
- fill: "none",
274
- viewBox: "0 0 12 2",
275
- role: "img"
276
- }, props), {}, {
277
- children: jsxRuntime.jsx("path", {
278
- stroke: "#000",
279
- strokeLinecap: "round",
280
- strokeWidth: 2,
281
- d: "M11 1H1"
282
- })
283
- }));
284
- };
258
+ const getIconStyles = props => /*#__PURE__*/react.css("*:not([fill='none']){fill:", getColor(props.color), ";}&,image{", getSizeStyle(props.size), ";}flex-shrink:0;" + ("" ), "" );
259
+
260
+ const SvgIndeterminate = props => jsxRuntime.jsx("svg", _objectSpread$2(_objectSpread$2({
261
+ xmlns: "http://www.w3.org/2000/svg",
262
+ width: 12,
263
+ height: 2,
264
+ fill: "none",
265
+ viewBox: "0 0 12 2",
266
+ role: "img"
267
+ }, props), {}, {
268
+ children: jsxRuntime.jsx("path", {
269
+ stroke: "#000",
270
+ strokeLinecap: "round",
271
+ strokeWidth: 2,
272
+ d: "M11 1H1"
273
+ })
274
+ }));
285
275
 
286
276
  SvgIndeterminate.displayName = 'SvgIndeterminate';
287
277
 
288
- var IndeterminateIcon = function IndeterminateIcon(props) {
289
- return jsxRuntime.jsx(react.ClassNames, {
290
- children: function children(_ref) {
291
- var createClass = _ref.css;
292
- return jsxRuntime.jsx(SvgIndeterminate, _objectSpread$2(_objectSpread$2({}, props), {}, {
293
- className: createClass(getIconStyles(props))
294
- }));
295
- }
296
- });
297
- };
278
+ const IndeterminateIcon = props => jsxRuntime.jsx(react.ClassNames, {
279
+ children: _ref => {
280
+ let createClass = _ref.css;
281
+ return jsxRuntime.jsx(SvgIndeterminate, _objectSpread$2(_objectSpread$2({}, props), {}, {
282
+ className: createClass(getIconStyles(props))
283
+ }));
284
+ }
285
+ });
298
286
 
299
287
  IndeterminateIcon.displayName = 'IndeterminateIcon';
300
288
  var IndeterminateIcon$1 = IndeterminateIcon;
@@ -303,11 +291,11 @@ function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["d
303
291
 
304
292
  function _objectSpread$1(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$1(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$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
305
293
 
306
- var Checkbox = function Checkbox(props) {
307
- var ref = react$1.useRef({
294
+ const Checkbox = props => {
295
+ const ref = react$1.useRef({
308
296
  indeterminate: false
309
297
  });
310
- react$1.useEffect(function () {
298
+ react$1.useEffect(() => {
311
299
  if (props.isIndeterminate) {
312
300
  ref.current.indeterminate = true;
313
301
  }
@@ -337,14 +325,14 @@ var Checkbox$1 = Checkbox;
337
325
  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; }
338
326
 
339
327
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
340
- var sequentialId = utils.createSequentialId('checkbox-input-');
341
- var defaultProps = {
328
+ const sequentialId = utils.createSequentialId('checkbox-input-');
329
+ const defaultProps = {
342
330
  isChecked: false,
343
331
  isDisabled: false,
344
332
  hasError: false
345
333
  };
346
334
 
347
- var getBorderColor = function getBorderColor(props) {
335
+ const getBorderColor = props => {
348
336
  if (props.hasError) {
349
337
  return designSystem.designTokens.borderColorForCheckboxInputIconWhenError;
350
338
  }
@@ -360,7 +348,7 @@ var getBorderColor = function getBorderColor(props) {
360
348
  return designSystem.designTokens.borderColorForCheckboxInputIcon;
361
349
  };
362
350
 
363
- var getBackgroundColor = function getBackgroundColor(props) {
351
+ const getBackgroundColor = props => {
364
352
  if (props.isChecked || props.isIndeterminate) {
365
353
  if (props.hasError) {
366
354
  return designSystem.designTokens.backgroundColorForCheckboxInputIconWhenError;
@@ -380,7 +368,7 @@ var getBackgroundColor = function getBackgroundColor(props) {
380
368
  return designSystem.designTokens.colorSurface;
381
369
  };
382
370
 
383
- var getTextColor = function getTextColor(props) {
371
+ const getTextColor = props => {
384
372
  if (props.hasError) {
385
373
  return designSystem.designTokens.fontColorForCheckboxInputLabelWhenError;
386
374
  }
@@ -396,39 +384,31 @@ var getTextColor = function getTextColor(props) {
396
384
  return designSystem.designTokens.fontColorForCheckboxInputLabel;
397
385
  };
398
386
 
399
- var LabelTextWrapper = /*#__PURE__*/_styled__default["default"]("div", {
387
+ const LabelTextWrapper = /*#__PURE__*/_styled__default["default"]("div", {
400
388
  target: "e6nn4mw2"
401
- } )("margin-left:calc(\n ", designSystem.designTokens.spacing20, " - ", designSystem.designTokens.borderWidthForCheckboxInputIcon, "\n );outline:none;border-radius:", designSystem.designTokens.borderRadiusForTag, ";font-size:", designSystem.designTokens.fontSizeForTextAsBody, ";line-height:", designSystem.designTokens.lineHeightForTextAsBody, ";font-weight:", designSystem.designTokens.fontWeightForTextAsBody, ";color:", function (props) {
402
- return getTextColor(props);
403
- }, ";" + ("" ));
389
+ } )("margin-left:calc(\n ", designSystem.designTokens.spacing20, " - ", designSystem.designTokens.borderWidthForCheckboxInputIcon, "\n );outline:none;border-radius:", designSystem.designTokens.borderRadiusForTag, ";font-size:", designSystem.designTokens.fontSizeForTextAsBody, ";line-height:", designSystem.designTokens.lineHeightForTextAsBody, ";font-weight:", designSystem.designTokens.fontWeightForTextAsBody, ";color:", props => getTextColor(props), ";" + ("" ));
404
390
 
405
- var CheckboxIconWrapper = /*#__PURE__*/_styled__default["default"]("div", {
391
+ const CheckboxIconWrapper = /*#__PURE__*/_styled__default["default"]("div", {
406
392
  target: "e6nn4mw1"
407
- } )("width:", function (props) {
408
- return props.width;
409
- }, ";height:", function (props) {
410
- return props.height;
411
- }, ";display:flex;align-items:center;justify-content:center;border-radius:", designSystem.designTokens.borderRadius6, ";", function (props) {
412
- return props.isHovered ? /*#__PURE__*/react.css("background-color:", designSystem.designTokens.backgroundColorForCheckboxInputIconWhenHovered, ";" + ("" ), "" ) : '';
413
- }, ";" + ("" ));
414
-
415
- var CheckboxIcon = function CheckboxIcon(props) {
393
+ } )("width:", props => props.width, ";height:", props => props.height, ";display:flex;align-items:center;justify-content:center;border-radius:", designSystem.designTokens.borderRadius6, ";", props => props.isHovered ? /*#__PURE__*/react.css("background-color:", designSystem.designTokens.backgroundColorForCheckboxInputIconWhenHovered, ";" + ("" ), "" ) : '', ";" + ("" ));
394
+
395
+ const CheckboxIcon = props => {
416
396
  var _context;
417
397
 
418
- var _useTheme = designSystem.useTheme(),
419
- isNewTheme = _useTheme.isNewTheme,
420
- themedValue = _useTheme.themedValue;
398
+ const _useTheme = designSystem.useTheme(),
399
+ isNewTheme = _useTheme.isNewTheme,
400
+ themedValue = _useTheme.themedValue;
421
401
 
422
- var isDisabledOrReadOnlyState = props.isDisabled || props.isReadOnly;
423
- var isDefaultState = !(props.hasError || isDisabledOrReadOnlyState);
424
- var canForcedHoverEffect = Boolean(props.isHovered && !isDisabledOrReadOnlyState);
402
+ const isDisabledOrReadOnlyState = props.isDisabled || props.isReadOnly;
403
+ const isDefaultState = !(props.hasError || isDisabledOrReadOnlyState);
404
+ const canForcedHoverEffect = Boolean(props.isHovered && !isDisabledOrReadOnlyState);
425
405
  return jsxRuntime.jsx(CheckboxIconWrapper, {
426
406
  width: themedValue('auto', '26px'),
427
407
  height: themedValue('auto', '26px'),
428
408
  isHovered: canForcedHoverEffect,
429
409
  children: jsxRuntime.jsx("div", {
430
410
  css: _filterInstanceProperty__default["default"](_context = [/*#__PURE__*/react.css("border-width:", designSystem.designTokens.borderWidthForCheckboxInputIcon, ";border-radius:", designSystem.designTokens.borderRadius2, ";border-color:", getBorderColor(props), ";border-style:solid;background-color:", getBackgroundColor(props), ";padding:1px;width:", themedValue('16px', '18px'), ";height:", themedValue('16px', '18px'), ";display:flex;align-items:center;justify-content:center;svg>path[stroke]{stroke:", themedValue(designSystem.designTokens.colorPrimary, designSystem.designTokens.colorSurface), ";}" + ("" ), "" ), !isNewTheme && /*#__PURE__*/react.css("svg>path[fill]{fill:", getTextColor(props), ";}svg>path[stroke]{stroke:", getTextColor(props), ";}" + ("" ), "" ), !isNewTheme && isDefaultState && /*#__PURE__*/react.css("svg>path[fill]{fill:", designSystem.designTokens.colorPrimary, ";}svg>path[stroke]{stroke:", designSystem.designTokens.colorPrimary, ";}&:hover{border-color:", isDisabledOrReadOnlyState ? 'unset' : designSystem.designTokens.colorPrimary, ";}" + ("" ), "" ), !isNewTheme && canForcedHoverEffect && /*#__PURE__*/react.css("border-color:", designSystem.designTokens.colorPrimary, ";" + ("" ), "" )]).call(_context, Boolean),
431
- children: function () {
411
+ children: (() => {
432
412
  if (props.isIndeterminate) return jsxRuntime.jsx(IndeterminateIcon$1, {
433
413
  color: themedValue('primary', 'surface'),
434
414
  size: "scale"
@@ -438,25 +418,23 @@ var CheckboxIcon = function CheckboxIcon(props) {
438
418
  size: "scale"
439
419
  });
440
420
  return null;
441
- }()
421
+ })()
442
422
  })
443
423
  });
444
424
  };
445
425
 
446
- var Label = /*#__PURE__*/_styled__default["default"]("label", {
426
+ const Label = /*#__PURE__*/_styled__default["default"]("label", {
447
427
  target: "e6nn4mw0"
448
- } )("display:flex;align-items:center;cursor:", function (props) {
428
+ } )("display:flex;align-items:center;cursor:", props => {
449
429
  if (props.isDisabled) return 'not-allowed';
450
430
  if (props.isReadOnly) return 'default';
451
431
  return 'pointer';
452
- }, ";position:relative;&:focus-within ", LabelTextWrapper, "{box-shadow:0 0 0 2px ", designSystem.designTokens.borderColorForInputWhenFocused, ";}&:hover ", CheckboxIconWrapper, "{background-color:", function (props) {
453
- return props.isDisabled || props.isReadOnly ? 'unset' : designSystem.designTokens.backgroundColorForCheckboxInputIconWhenHovered;
454
- }, ";}" + ("" ));
432
+ }, ";position:relative;&:focus-within ", LabelTextWrapper, "{box-shadow:0 0 0 2px ", designSystem.designTokens.borderColorForInputWhenFocused, ";}&:hover ", CheckboxIconWrapper, "{background-color:", props => props.isDisabled || props.isReadOnly ? 'unset' : designSystem.designTokens.backgroundColorForCheckboxInputIconWhenHovered, ";}" + ("" ));
455
433
 
456
- var CheckboxInput = function CheckboxInput(props) {
434
+ const CheckboxInput = props => {
457
435
  // We generate an id in case no id is provided by the parent to attach the
458
436
  // label to the input component.
459
- var id = props.id || sequentialId();
437
+ const id = props.id || sequentialId();
460
438
  return jsxRuntime.jsxs(Label, {
461
439
  htmlFor: id,
462
440
  hasError: props.hasError,
@@ -494,7 +472,7 @@ CheckboxInput.defaultProps = defaultProps;
494
472
  var CheckboxInput$1 = CheckboxInput;
495
473
 
496
474
  // NOTE: This string will be replaced on build time with the package version.
497
- var version = "15.15.0";
475
+ var version = "16.0.0";
498
476
 
499
477
  exports["default"] = CheckboxInput$1;
500
478
  exports.version = version;