@commercetools-uikit/checkbox-input 16.0.0 → 16.1.1

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.
@@ -35,14 +35,12 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
35
35
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
36
36
 
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
-
39
38
  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
39
  const iconSizes$1 = {
41
40
  small: 12,
42
41
  medium: 16,
43
42
  big: 24
44
43
  };
45
-
46
44
  const getSizeDimensions$1 = size => {
47
45
  switch (size) {
48
46
  case 'scale':
@@ -50,7 +48,6 @@ const getSizeDimensions$1 = size => {
50
48
  width: '100%',
51
49
  height: 'auto'
52
50
  };
53
-
54
51
  case 'small':
55
52
  case 'medium':
56
53
  case 'big':
@@ -58,7 +55,6 @@ const getSizeDimensions$1 = size => {
58
55
  width: "".concat(iconSizes$1[size], "px"),
59
56
  height: "".concat(iconSizes$1[size], "px")
60
57
  };
61
-
62
58
  default:
63
59
  return {
64
60
  width: "".concat(iconSizes$1.big, "px"),
@@ -66,68 +62,51 @@ const getSizeDimensions$1 = size => {
66
62
  };
67
63
  }
68
64
  };
69
-
70
65
  const getSizeStyle$1 = size => {
71
66
  var _context, _context2;
72
-
73
67
  const dimensions = getSizeDimensions$1(size);
74
-
75
68
  switch (size) {
76
69
  case 'scale':
77
70
  return _concatInstanceProperty__default["default"](_context = "\n &:not(:root) {\n width: ".concat(dimensions.width, ";\n height: ")).call(_context, dimensions.height, ";\n }\n ");
78
-
79
71
  default:
80
72
  return _concatInstanceProperty__default["default"](_context2 = "\n width: ".concat(dimensions.width, ";\n height: ")).call(_context2, dimensions.height, ";\n ");
81
73
  }
82
74
  };
83
-
84
75
  const getColor$1 = color => {
85
76
  if (!color) return 'inherit';
86
77
  let iconColor;
87
-
88
78
  switch (color) {
89
79
  case 'solid':
90
80
  iconColor = designSystem.designTokens.colorSolid;
91
81
  break;
92
-
93
82
  case 'neutral60':
94
83
  iconColor = designSystem.designTokens.colorNeutral60;
95
84
  break;
96
-
97
85
  case 'surface':
98
86
  iconColor = designSystem.designTokens.colorSurface;
99
87
  break;
100
-
101
88
  case 'info':
102
89
  iconColor = designSystem.designTokens.colorInfo;
103
90
  break;
104
-
105
91
  case 'primary':
106
92
  iconColor = designSystem.designTokens.colorPrimary;
107
93
  break;
108
-
109
94
  case 'primary40':
110
95
  iconColor = designSystem.designTokens.colorPrimary40;
111
96
  break;
112
-
113
97
  case 'warning':
114
98
  iconColor = designSystem.designTokens.colorWarning;
115
99
  break;
116
-
117
100
  case 'error':
118
101
  iconColor = designSystem.designTokens.colorError;
119
102
  break;
120
103
  }
121
-
122
104
  if (!iconColor) {
123
105
  return 'inherit';
124
106
  }
125
-
126
107
  return iconColor;
127
108
  };
128
-
129
109
  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
110
  const SvgChecked = props => jsxRuntime.jsxs("svg", _objectSpread$3(_objectSpread$3({
132
111
  xmlns: "http://www.w3.org/2000/svg",
133
112
  width: 12,
@@ -148,9 +127,7 @@ const SvgChecked = props => jsxRuntime.jsxs("svg", _objectSpread$3(_objectSpread
148
127
  clipRule: "evenodd"
149
128
  })]
150
129
  }));
151
-
152
130
  SvgChecked.displayName = 'SvgChecked';
153
-
154
131
  const CheckedIcon = props => jsxRuntime.jsx(react.ClassNames, {
155
132
  children: _ref => {
156
133
  let createClass = _ref.css;
@@ -159,19 +136,16 @@ const CheckedIcon = props => jsxRuntime.jsx(react.ClassNames, {
159
136
  }));
160
137
  }
161
138
  });
162
-
163
139
  CheckedIcon.displayName = 'CheckedIcon';
164
140
  var CheckedIcon$1 = CheckedIcon;
165
141
 
166
142
  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; }
167
-
168
143
  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; }
169
144
  const iconSizes = {
170
145
  small: 12,
171
146
  medium: 16,
172
147
  big: 24
173
148
  };
174
-
175
149
  const getSizeDimensions = size => {
176
150
  switch (size) {
177
151
  case 'scale':
@@ -179,7 +153,6 @@ const getSizeDimensions = size => {
179
153
  width: '100%',
180
154
  height: 'auto'
181
155
  };
182
-
183
156
  case 'small':
184
157
  case 'medium':
185
158
  case 'big':
@@ -187,7 +160,6 @@ const getSizeDimensions = size => {
187
160
  width: "".concat(iconSizes[size], "px"),
188
161
  height: "".concat(iconSizes[size], "px")
189
162
  };
190
-
191
163
  default:
192
164
  return {
193
165
  width: "".concat(iconSizes.big, "px"),
@@ -195,68 +167,51 @@ const getSizeDimensions = size => {
195
167
  };
196
168
  }
197
169
  };
198
-
199
170
  const getSizeStyle = size => {
200
171
  var _context, _context2;
201
-
202
172
  const dimensions = getSizeDimensions(size);
203
-
204
173
  switch (size) {
205
174
  case 'scale':
206
175
  return _concatInstanceProperty__default["default"](_context = "\n &:not(:root) {\n width: ".concat(dimensions.width, ";\n height: ")).call(_context, dimensions.height, ";\n }\n ");
207
-
208
176
  default:
209
177
  return _concatInstanceProperty__default["default"](_context2 = "\n width: ".concat(dimensions.width, ";\n height: ")).call(_context2, dimensions.height, ";\n ");
210
178
  }
211
179
  };
212
-
213
180
  const getColor = color => {
214
181
  if (!color) return 'inherit';
215
182
  let iconColor;
216
-
217
183
  switch (color) {
218
184
  case 'solid':
219
185
  iconColor = designSystem.designTokens.colorSolid;
220
186
  break;
221
-
222
187
  case 'neutral60':
223
188
  iconColor = designSystem.designTokens.colorNeutral60;
224
189
  break;
225
-
226
190
  case 'surface':
227
191
  iconColor = designSystem.designTokens.colorSurface;
228
192
  break;
229
-
230
193
  case 'info':
231
194
  iconColor = designSystem.designTokens.colorInfo;
232
195
  break;
233
-
234
196
  case 'primary':
235
197
  iconColor = designSystem.designTokens.colorPrimary;
236
198
  break;
237
-
238
199
  case 'primary40':
239
200
  iconColor = designSystem.designTokens.colorPrimary40;
240
201
  break;
241
-
242
202
  case 'warning':
243
203
  iconColor = designSystem.designTokens.colorWarning;
244
204
  break;
245
-
246
205
  case 'error':
247
206
  iconColor = designSystem.designTokens.colorError;
248
207
  break;
249
208
  }
250
-
251
209
  if (!iconColor) {
252
210
  return 'inherit';
253
211
  }
254
-
255
212
  return iconColor;
256
213
  };
257
-
258
214
  const getIconStyles = props => /*#__PURE__*/react.css("*:not([fill='none']){fill:", getColor(props.color), ";}&,image{", getSizeStyle(props.size), ";}flex-shrink:0;" + ("" ), "" );
259
-
260
215
  const SvgIndeterminate = props => jsxRuntime.jsx("svg", _objectSpread$2(_objectSpread$2({
261
216
  xmlns: "http://www.w3.org/2000/svg",
262
217
  width: 12,
@@ -272,9 +227,7 @@ const SvgIndeterminate = props => jsxRuntime.jsx("svg", _objectSpread$2(_objectS
272
227
  d: "M11 1H1"
273
228
  })
274
229
  }));
275
-
276
230
  SvgIndeterminate.displayName = 'SvgIndeterminate';
277
-
278
231
  const IndeterminateIcon = props => jsxRuntime.jsx(react.ClassNames, {
279
232
  children: _ref => {
280
233
  let createClass = _ref.css;
@@ -283,14 +236,11 @@ const IndeterminateIcon = props => jsxRuntime.jsx(react.ClassNames, {
283
236
  }));
284
237
  }
285
238
  });
286
-
287
239
  IndeterminateIcon.displayName = 'IndeterminateIcon';
288
240
  var IndeterminateIcon$1 = IndeterminateIcon;
289
241
 
290
242
  function ownKeys$1(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; }
291
-
292
243
  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; }
293
-
294
244
  const Checkbox = props => {
295
245
  const ref = react$1.useRef({
296
246
  indeterminate: false
@@ -301,7 +251,8 @@ const Checkbox = props => {
301
251
  }
302
252
  }, [props.isIndeterminate]);
303
253
  return jsxRuntime.jsx("input", _objectSpread$1(_objectSpread$1(_objectSpread$1({
304
- type: "checkbox" // @ts-ignore
254
+ type: "checkbox"
255
+ // @ts-ignore
305
256
  ,
306
257
  ref: ref
307
258
  }, utils.filterDataAttributes(props)), utils.filterAriaAttributes(props)), {}, {
@@ -318,12 +269,10 @@ const Checkbox = props => {
318
269
  onChange: !props.isReadOnly ? props.onChange : undefined
319
270
  }));
320
271
  };
321
-
322
272
  Checkbox.displayName = 'Checkbox';
323
273
  var Checkbox$1 = Checkbox;
324
274
 
325
275
  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; }
326
-
327
276
  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; }
328
277
  const sequentialId = utils.createSequentialId('checkbox-input-');
329
278
  const defaultProps = {
@@ -331,90 +280,68 @@ const defaultProps = {
331
280
  isDisabled: false,
332
281
  hasError: false
333
282
  };
334
-
335
283
  const getBorderColor = props => {
336
284
  if (props.hasError) {
337
285
  return designSystem.designTokens.borderColorForCheckboxInputIconWhenError;
338
286
  }
339
-
340
287
  if (props.isDisabled) {
341
288
  return designSystem.designTokens.borderColorForCheckboxInputIconWhenDisabled;
342
289
  }
343
-
344
290
  if (props.isReadOnly) {
345
291
  return designSystem.designTokens.borderColorForCheckboxInputIconWhenReadonly;
346
292
  }
347
-
348
293
  return designSystem.designTokens.borderColorForCheckboxInputIcon;
349
294
  };
350
-
351
295
  const getBackgroundColor = props => {
352
296
  if (props.isChecked || props.isIndeterminate) {
353
297
  if (props.hasError) {
354
298
  return designSystem.designTokens.backgroundColorForCheckboxInputIconWhenError;
355
299
  }
356
-
357
300
  if (props.isDisabled) {
358
301
  return designSystem.designTokens.backgroundColorForCheckboxInputIconWhenDisabled;
359
302
  }
360
-
361
303
  if (props.isReadOnly) {
362
304
  return designSystem.designTokens.backgroundColorForCheckboxInputIconWhenReadonly;
363
305
  }
364
-
365
306
  return designSystem.designTokens.backgroundColorForCheckboxInputIcon;
366
307
  }
367
-
368
308
  return designSystem.designTokens.colorSurface;
369
309
  };
370
-
371
310
  const getTextColor = props => {
372
311
  if (props.hasError) {
373
312
  return designSystem.designTokens.fontColorForCheckboxInputLabelWhenError;
374
313
  }
375
-
376
314
  if (props.isDisabled) {
377
315
  return designSystem.designTokens.fontColorForCheckboxInputLabelWhenDisabled;
378
316
  }
379
-
380
317
  if (props.isReadOnly) {
381
318
  return designSystem.designTokens.fontColorForCheckboxInputLabelWhenReadonly;
382
319
  }
383
-
384
320
  return designSystem.designTokens.fontColorForCheckboxInputLabel;
385
321
  };
386
-
387
322
  const LabelTextWrapper = /*#__PURE__*/_styled__default["default"]("div", {
388
323
  target: "e6nn4mw2"
389
324
  } )("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), ";" + ("" ));
390
-
391
325
  const CheckboxIconWrapper = /*#__PURE__*/_styled__default["default"]("div", {
392
326
  target: "e6nn4mw1"
393
327
  } )("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
328
  const CheckboxIcon = props => {
396
329
  var _context;
397
-
398
- const _useTheme = designSystem.useTheme(),
399
- isNewTheme = _useTheme.isNewTheme,
400
- themedValue = _useTheme.themedValue;
401
-
402
330
  const isDisabledOrReadOnlyState = props.isDisabled || props.isReadOnly;
403
- const isDefaultState = !(props.hasError || isDisabledOrReadOnlyState);
404
331
  const canForcedHoverEffect = Boolean(props.isHovered && !isDisabledOrReadOnlyState);
405
332
  return jsxRuntime.jsx(CheckboxIconWrapper, {
406
- width: themedValue('auto', '26px'),
407
- height: themedValue('auto', '26px'),
333
+ width: "26px",
334
+ height: "26px",
408
335
  isHovered: canForcedHoverEffect,
409
336
  children: jsxRuntime.jsx("div", {
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),
337
+ 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:18px;height:18px;display:flex;align-items:center;justify-content:center;svg>path[stroke]{stroke:", designSystem.designTokens.colorSurface, ";}" + ("" ), "" )]).call(_context, Boolean),
411
338
  children: (() => {
412
339
  if (props.isIndeterminate) return jsxRuntime.jsx(IndeterminateIcon$1, {
413
- color: themedValue('primary', 'surface'),
340
+ color: "surface",
414
341
  size: "scale"
415
342
  });
416
343
  if (props.isChecked) return jsxRuntime.jsx(CheckedIcon$1, {
417
- color: themedValue('primary', 'surface'),
344
+ color: "surface",
418
345
  size: "scale"
419
346
  });
420
347
  return null;
@@ -422,7 +349,6 @@ const CheckboxIcon = props => {
422
349
  })
423
350
  });
424
351
  };
425
-
426
352
  const Label = /*#__PURE__*/_styled__default["default"]("label", {
427
353
  target: "e6nn4mw0"
428
354
  } )("display:flex;align-items:center;cursor:", props => {
@@ -430,7 +356,6 @@ const Label = /*#__PURE__*/_styled__default["default"]("label", {
430
356
  if (props.isReadOnly) return 'default';
431
357
  return 'pointer';
432
358
  }, ";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, ";}" + ("" ));
433
-
434
359
  const CheckboxInput = props => {
435
360
  // We generate an id in case no id is provided by the parent to attach the
436
361
  // label to the input component.
@@ -458,21 +383,21 @@ const CheckboxInput = props => {
458
383
  isReadOnly: props.isReadOnly,
459
384
  isChecked: props.isChecked,
460
385
  isHovered: props.isHovered,
461
- isIndeterminate: props.isIndeterminate // To allow focusing the Label in readOnly mode, because the checkbox gets disabled and therefore unfocusable
386
+ isIndeterminate: props.isIndeterminate
387
+ // To allow focusing the Label in readOnly mode, because the checkbox gets disabled and therefore unfocusable
462
388
  ,
463
389
  tabIndex: props.isReadOnly ? 0 : -1,
464
390
  children: props.children
465
391
  })]
466
392
  });
467
393
  };
468
-
469
394
  CheckboxInput.propTypes = {};
470
395
  CheckboxInput.displayName = 'CheckboxInput';
471
396
  CheckboxInput.defaultProps = defaultProps;
472
397
  var CheckboxInput$1 = CheckboxInput;
473
398
 
474
399
  // NOTE: This string will be replaced on build time with the package version.
475
- var version = "16.0.0";
400
+ var version = "16.1.1";
476
401
 
477
402
  exports["default"] = CheckboxInput$1;
478
403
  exports.version = version;