@commercetools-uikit/checkbox-input 15.12.0 → 15.13.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.
@@ -2,21 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
6
+ var _styled = require('@emotion/styled/base');
7
+ require('prop-types');
8
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
5
9
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
6
10
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
7
- var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
8
11
  var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
9
12
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
10
13
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
11
14
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
12
15
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
- var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
- var _styled = require('@emotion/styled/base');
15
- require('prop-types');
16
16
  var react = require('@emotion/react');
17
17
  var designSystem = require('@commercetools-uikit/design-system');
18
18
  var utils = require('@commercetools-uikit/utils');
19
- var Text = require('@commercetools-uikit/text');
20
19
  var react$1 = require('react');
21
20
  var inputUtils = require('@commercetools-uikit/input-utils');
22
21
  var jsxRuntime = require('@emotion/react/jsx-runtime');
@@ -24,168 +23,17 @@ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
24
23
 
25
24
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
26
25
 
26
+ var _styled__default = /*#__PURE__*/_interopDefault(_styled);
27
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
27
28
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
28
29
  var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
29
- var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
30
30
  var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
31
31
  var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
32
32
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
33
33
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
34
34
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
35
- var _styled__default = /*#__PURE__*/_interopDefault(_styled);
36
- var Text__default = /*#__PURE__*/_interopDefault(Text);
37
35
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
38
36
 
39
- function ownKeys$4(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; }
40
-
41
- function _objectSpread$4(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$4(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$4(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
42
- var iconSizes$2 = {
43
- small: 12,
44
- medium: 16,
45
- big: 24
46
- };
47
-
48
- var getSizeDimensions$2 = function getSizeDimensions(size) {
49
- switch (size) {
50
- case 'scale':
51
- return {
52
- width: '100%',
53
- height: 'auto'
54
- };
55
-
56
- case 'small':
57
- case 'medium':
58
- case 'big':
59
- return {
60
- width: "".concat(iconSizes$2[size], "px"),
61
- height: "".concat(iconSizes$2[size], "px")
62
- };
63
-
64
- default:
65
- return {
66
- width: "".concat(iconSizes$2.big, "px"),
67
- height: "".concat(iconSizes$2.big, "px")
68
- };
69
- }
70
- };
71
-
72
- var getSizeStyle$2 = function getSizeStyle(size) {
73
- var _context, _context2;
74
-
75
- var dimensions = getSizeDimensions$2(size);
76
-
77
- switch (size) {
78
- case 'scale':
79
- return _concatInstanceProperty__default["default"](_context = "\n &:not(:root) {\n width: ".concat(dimensions.width, ";\n height: ")).call(_context, dimensions.height, ";\n }\n ");
80
-
81
- default:
82
- return _concatInstanceProperty__default["default"](_context2 = "\n width: ".concat(dimensions.width, ";\n height: ")).call(_context2, dimensions.height, ";\n ");
83
- }
84
- };
85
-
86
- var getColor$2 = function getColor(color) {
87
- if (!color) return 'inherit';
88
- var iconColor;
89
-
90
- switch (color) {
91
- case 'solid':
92
- iconColor = designSystem.designTokens.colorSolid;
93
- break;
94
-
95
- case 'neutral60':
96
- iconColor = designSystem.designTokens.colorNeutral60;
97
- break;
98
-
99
- case 'surface':
100
- iconColor = designSystem.designTokens.colorSurface;
101
- break;
102
-
103
- case 'info':
104
- iconColor = designSystem.designTokens.colorInfo;
105
- break;
106
-
107
- case 'primary':
108
- iconColor = designSystem.designTokens.colorPrimary;
109
- break;
110
-
111
- case 'primary40':
112
- iconColor = designSystem.designTokens.colorPrimary40;
113
- break;
114
-
115
- case 'warning':
116
- iconColor = designSystem.designTokens.colorWarning;
117
- break;
118
-
119
- case 'error':
120
- iconColor = designSystem.designTokens.colorError;
121
- break;
122
- }
123
-
124
- if (!iconColor) {
125
- return 'inherit';
126
- }
127
-
128
- return iconColor;
129
- };
130
-
131
- var getIconStyles$2 = function getIconStyles(props) {
132
- return /*#__PURE__*/react.css("*:not([fill='none']){fill:", getColor$2(props.color), ";}&,image{", getSizeStyle$2(props.size), ";}flex-shrink:0;" + ("" ), "" );
133
- };
134
-
135
- var SvgChecked = function SvgChecked(props) {
136
- return jsxRuntime.jsx("svg", _objectSpread$4(_objectSpread$4({
137
- width: 16,
138
- height: 16,
139
- viewBox: "0 0 16 16",
140
- xmlns: "http://www.w3.org/2000/svg",
141
- role: "img"
142
- }, props), {}, {
143
- children: jsxRuntime.jsxs("g", {
144
- transform: "translate(0 -1)",
145
- fillRule: "evenodd",
146
- children: [jsxRuntime.jsx("rect", {
147
- fill: "#FFF",
148
- y: 1,
149
- width: 16,
150
- height: 16,
151
- rx: 4
152
- }), jsxRuntime.jsxs("g", {
153
- transform: "translate(0 .5)",
154
- children: [jsxRuntime.jsx("rect", {
155
- "data-style": "checkbox__border",
156
- stroke: "#AFAFAF",
157
- x: 0.5,
158
- y: 1,
159
- width: 15,
160
- height: 15,
161
- rx: 4
162
- }), jsxRuntime.jsx("path", {
163
- "data-style": "checkbox__content",
164
- d: "M12.918 3.759a.497.497 0 0 0-.7 0L6.011 9.966a.497.497 0 0 1-.7 0L3.78 8.438a.497.497 0 0 0-.699 0l-.938.938a.497.497 0 0 0 0 .7l3.167 3.165a.497.497 0 0 0 .7 0l7.845-7.845a.496.496 0 0 0 0-.7l-.938-.937z",
165
- fill: "#20AD92",
166
- fillRule: "nonzero"
167
- })]
168
- })]
169
- })
170
- }));
171
- };
172
-
173
- SvgChecked.displayName = 'SvgChecked';
174
-
175
- var CheckedIcon = function CheckedIcon(props) {
176
- return jsxRuntime.jsx(react.ClassNames, {
177
- children: function children(_ref) {
178
- var createClass = _ref.css;
179
- return jsxRuntime.jsx(SvgChecked, _objectSpread$4(_objectSpread$4({}, props), {}, {
180
- className: createClass(getIconStyles$2(props))
181
- }));
182
- }
183
- });
184
- };
185
-
186
- CheckedIcon.displayName = 'CheckedIcon';
187
- var CheckedIcon$1 = CheckedIcon;
188
-
189
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; }
190
38
 
191
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; }
@@ -282,58 +130,44 @@ var getIconStyles$1 = function getIconStyles(props) {
282
130
  return /*#__PURE__*/react.css("*:not([fill='none']){fill:", getColor$1(props.color), ";}&,image{", getSizeStyle$1(props.size), ";}flex-shrink:0;" + ("" ), "" );
283
131
  };
284
132
 
285
- var SvgIndeterminate = function SvgIndeterminate(props) {
286
- return jsxRuntime.jsx("svg", _objectSpread$3(_objectSpread$3({
287
- width: 16,
288
- height: 16,
289
- viewBox: "0 0 16 16",
133
+ var SvgChecked = function SvgChecked(props) {
134
+ return jsxRuntime.jsxs("svg", _objectSpread$3(_objectSpread$3({
135
+ width: 12,
136
+ height: 9,
137
+ viewBox: "0 0 12 9",
138
+ fill: "none",
290
139
  xmlns: "http://www.w3.org/2000/svg",
291
140
  role: "img"
292
141
  }, props), {}, {
293
- children: jsxRuntime.jsxs("g", {
294
- transform: "translate(0 -1)",
142
+ children: [jsxRuntime.jsx("path", {
295
143
  fillRule: "evenodd",
296
- children: [jsxRuntime.jsx("rect", {
297
- fill: "#FFF",
298
- y: 1,
299
- width: 16,
300
- height: 16,
301
- rx: 4
302
- }), jsxRuntime.jsxs("g", {
303
- transform: "translate(0 .5)",
304
- children: [jsxRuntime.jsx("rect", {
305
- "data-style": "checkbox__border",
306
- stroke: "#AFAFAF",
307
- x: 0.5,
308
- y: 1,
309
- width: 15,
310
- height: 15,
311
- rx: 4
312
- }), jsxRuntime.jsx("path", {
313
- "data-style": "checkbox__content",
314
- fill: "#00B6A1",
315
- d: "M3 7.5h10v2H3z"
316
- })]
317
- })]
318
- })
144
+ clipRule: "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
+ fill: "#000"
147
+ }), jsxRuntime.jsx("path", {
148
+ fillRule: "evenodd",
149
+ clipRule: "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
+ fill: "#000"
152
+ })]
319
153
  }));
320
154
  };
321
155
 
322
- SvgIndeterminate.displayName = 'SvgIndeterminate';
156
+ SvgChecked.displayName = 'SvgChecked';
323
157
 
324
- var IndeterminateIcon = function IndeterminateIcon(props) {
158
+ var CheckedIcon = function CheckedIcon(props) {
325
159
  return jsxRuntime.jsx(react.ClassNames, {
326
160
  children: function children(_ref) {
327
161
  var createClass = _ref.css;
328
- return jsxRuntime.jsx(SvgIndeterminate, _objectSpread$3(_objectSpread$3({}, props), {}, {
162
+ return jsxRuntime.jsx(SvgChecked, _objectSpread$3(_objectSpread$3({}, props), {}, {
329
163
  className: createClass(getIconStyles$1(props))
330
164
  }));
331
165
  }
332
166
  });
333
167
  };
334
168
 
335
- IndeterminateIcon.displayName = 'IndeterminateIcon';
336
- var IndeterminateIcon$1 = IndeterminateIcon;
169
+ CheckedIcon.displayName = 'CheckedIcon';
170
+ var CheckedIcon$1 = CheckedIcon;
337
171
 
338
172
  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; }
339
173
 
@@ -431,102 +265,44 @@ var getIconStyles = function getIconStyles(props) {
431
265
  return /*#__PURE__*/react.css("*:not([fill='none']){fill:", getColor(props.color), ";}&,image{", getSizeStyle(props.size), ";}flex-shrink:0;" + ("" ), "" );
432
266
  };
433
267
 
434
- var SvgUnchecked = function SvgUnchecked(props) {
268
+ var SvgIndeterminate = function SvgIndeterminate(props) {
435
269
  return jsxRuntime.jsx("svg", _objectSpread$2(_objectSpread$2({
436
- width: 16,
437
- height: 16,
438
- viewBox: "0 0 16 16",
270
+ width: 12,
271
+ height: 2,
272
+ viewBox: "0 0 12 2",
273
+ fill: "none",
439
274
  xmlns: "http://www.w3.org/2000/svg",
440
275
  role: "img"
441
276
  }, props), {}, {
442
- children: jsxRuntime.jsxs("g", {
443
- transform: "translate(0 -1)",
444
- fillRule: "evenodd",
445
- children: [jsxRuntime.jsx("rect", {
446
- fill: "#FFF",
447
- y: 1,
448
- width: 16,
449
- height: 16,
450
- rx: 4
451
- }), jsxRuntime.jsx("rect", {
452
- "data-style": "checkbox__border",
453
- x: 0.5,
454
- y: 1,
455
- width: 15,
456
- height: 15,
457
- rx: 4,
458
- transform: "translate(0 .5)",
459
- stroke: "#AFAFAF"
460
- })]
277
+ children: jsxRuntime.jsx("path", {
278
+ stroke: "#000",
279
+ strokeWidth: 2,
280
+ strokeLinecap: "round",
281
+ d: "M11 1H1"
461
282
  })
462
283
  }));
463
284
  };
464
285
 
465
- SvgUnchecked.displayName = 'SvgUnchecked';
286
+ SvgIndeterminate.displayName = 'SvgIndeterminate';
466
287
 
467
- var UncheckedIcon = function UncheckedIcon(props) {
288
+ var IndeterminateIcon = function IndeterminateIcon(props) {
468
289
  return jsxRuntime.jsx(react.ClassNames, {
469
290
  children: function children(_ref) {
470
291
  var createClass = _ref.css;
471
- return jsxRuntime.jsx(SvgUnchecked, _objectSpread$2(_objectSpread$2({}, props), {}, {
292
+ return jsxRuntime.jsx(SvgIndeterminate, _objectSpread$2(_objectSpread$2({}, props), {}, {
472
293
  className: createClass(getIconStyles(props))
473
294
  }));
474
295
  }
475
296
  });
476
297
  };
477
298
 
478
- UncheckedIcon.displayName = 'UncheckedIcon';
479
- var UncheckedIcon$1 = UncheckedIcon;
480
-
481
- var getSvgBorderStroke = function getSvgBorderStroke(props) {
482
- if (props.isDisabled) {
483
- return designSystem.designTokens.borderColorForInputWhenDisabled;
484
- }
485
-
486
- if (props.hasError) {
487
- return designSystem.designTokens.borderColorForInputWhenError;
488
- }
489
-
490
- if (props.isReadOnly) {
491
- return designSystem.designTokens.borderColorForInputWhenReadonly;
492
- }
493
-
494
- if (props.isHovered && !props.isReadOnly && !props.isDisabled && !props.hasError) {
495
- return designSystem.designTokens.borderColorForInputWhenFocused;
496
- }
497
-
498
- return designSystem.designTokens.borderColorForInput;
499
- };
500
-
501
- var getSvgContentFill = function getSvgContentFill(props) {
502
- if (props.isDisabled) {
503
- return designSystem.designTokens.fontColorForInputWhenDisabled;
504
- }
505
-
506
- if (props.hasError) {
507
- return designSystem.designTokens.fontColorForInputWhenError;
508
- }
509
-
510
- if (props.isReadOnly) {
511
- return designSystem.designTokens.fontColorForInputWhenReadonly;
512
- }
513
-
514
- return designSystem.designTokens.borderColorForInputWhenFocused;
515
- };
516
-
517
- var getCheckboxWrapperStyles = function getCheckboxWrapperStyles(props) {
518
- /* resets from createStyledIcon styles */
519
- return /*#__PURE__*/react.css("*{fill:none;}display:flex;align-items:center;svg *[data-style='checkbox__border']{stroke:", getSvgBorderStroke(props), ";fill:", designSystem.designTokens.backgroundColorForInput, ";}svg *[data-style='checkbox__content']{fill:", getSvgContentFill(props), ";}" + ("" ), "" );
520
- }; // eslint-disable-next-line import/prefer-default-export
299
+ IndeterminateIcon.displayName = 'IndeterminateIcon';
300
+ var IndeterminateIcon$1 = IndeterminateIcon;
521
301
 
522
302
  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; }
523
303
 
524
304
  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; }
525
305
 
526
- var Input = /*#__PURE__*/_styled__default["default"]("input", {
527
- target: "e1ccch1p0"
528
- } )("&:focus+div>svg *[data-style='checkbox__border']{stroke:", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ));
529
-
530
306
  var Checkbox = function Checkbox(props) {
531
307
  var ref = react$1.useRef({
532
308
  indeterminate: false
@@ -536,12 +312,9 @@ var Checkbox = function Checkbox(props) {
536
312
  ref.current.indeterminate = true;
537
313
  }
538
314
  }, [props.isIndeterminate]);
539
- var onChange = props.onChange;
540
- var handleChange = react$1.useCallback(function (event) {
541
- return !props.isReadOnly && onChange && onChange(event);
542
- }, [props.isReadOnly, onChange]);
543
- return jsxRuntime.jsx(Input // @ts-ignore
544
- , _objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1({
315
+ return jsxRuntime.jsx("input", _objectSpread$1(_objectSpread$1(_objectSpread$1({
316
+ type: "checkbox" // @ts-ignore
317
+ ,
545
318
  ref: ref
546
319
  }, utils.filterDataAttributes(props)), utils.filterAriaAttributes(props)), {}, {
547
320
  /* ARIA */
@@ -553,19 +326,17 @@ var Checkbox = function Checkbox(props) {
553
326
  value: props.value,
554
327
  disabled: props.isDisabled || props.isReadOnly,
555
328
  readOnly: props.isReadOnly,
556
- checked: props.isChecked && !props.isIndeterminate
557
- }, props), {}, {
558
- onChange: handleChange
329
+ checked: props.isChecked && !props.isIndeterminate,
330
+ onChange: !props.isReadOnly ? props.onChange : undefined
559
331
  }));
560
332
  };
561
333
 
562
- Checkbox.propTypes = {};
563
334
  Checkbox.displayName = 'Checkbox';
564
335
  var Checkbox$1 = Checkbox;
565
336
 
566
337
  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; }
567
338
 
568
- 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; }
339
+ 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; }
569
340
  var sequentialId = utils.createSequentialId('checkbox-input-');
570
341
  var defaultProps = {
571
342
  isChecked: false,
@@ -573,25 +344,114 @@ var defaultProps = {
573
344
  hasError: false
574
345
  };
575
346
 
576
- var hoverStyles = function hoverStyles(props) {
577
- if (!props.hasError && !props.readOnly && !props.disabled) {
578
- return /*#__PURE__*/react.css("&:hover svg *[data-style='checkbox__border']{stroke:", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ), "" );
347
+ var getBorderColor = function getBorderColor(props) {
348
+ if (props.hasError) {
349
+ return designSystem.designTokens.borderColorForCheckboxInputIconWhenError;
350
+ }
351
+
352
+ if (props.isDisabled) {
353
+ return designSystem.designTokens.borderColorForCheckboxInputIconWhenDisabled;
354
+ }
355
+
356
+ if (props.isReadOnly) {
357
+ return designSystem.designTokens.borderColorForCheckboxInputIconWhenReadonly;
579
358
  }
580
359
 
581
- return /*#__PURE__*/react.css("" , "" );
360
+ return designSystem.designTokens.borderColorForCheckboxInputIcon;
361
+ };
362
+
363
+ var getBackgroundColor = function getBackgroundColor(props) {
364
+ if (props.isChecked || props.isIndeterminate) {
365
+ if (props.hasError) {
366
+ return designSystem.designTokens.backgroundColorForCheckboxInputIconWhenError;
367
+ }
368
+
369
+ if (props.isDisabled) {
370
+ return designSystem.designTokens.backgroundColorForCheckboxInputIconWhenDisabled;
371
+ }
372
+
373
+ if (props.isReadOnly) {
374
+ return designSystem.designTokens.backgroundColorForCheckboxInputIconWhenReadonly;
375
+ }
376
+
377
+ return designSystem.designTokens.backgroundColorForCheckboxInputIcon;
378
+ }
379
+
380
+ return designSystem.designTokens.colorSurface;
381
+ };
382
+
383
+ var getTextColor = function getTextColor(props) {
384
+ if (props.hasError) {
385
+ return designSystem.designTokens.fontColorForCheckboxInputLabelWhenError;
386
+ }
387
+
388
+ if (props.isDisabled) {
389
+ return designSystem.designTokens.fontColorForCheckboxInputLabelWhenDisabled;
390
+ }
391
+
392
+ if (props.isReadOnly) {
393
+ return designSystem.designTokens.fontColorForCheckboxInputLabelWhenReadonly;
394
+ }
395
+
396
+ return designSystem.designTokens.fontColorForCheckboxInputLabel;
582
397
  };
583
398
 
584
399
  var LabelTextWrapper = /*#__PURE__*/_styled__default["default"]("div", {
400
+ 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
+ }, ";" + ("" ));
404
+
405
+ var CheckboxIconWrapper = /*#__PURE__*/_styled__default["default"]("div", {
585
406
  target: "e6nn4mw1"
586
- } )("margin-left:", designSystem.designTokens.spacing20, ";outline:none;border-radius:", designSystem.designTokens.borderRadiusForTag, ";" + ("" ));
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) {
416
+ var _context;
417
+
418
+ var _useTheme = designSystem.useTheme(),
419
+ isNewTheme = _useTheme.isNewTheme,
420
+ themedValue = _useTheme.themedValue;
421
+
422
+ var isDisabledOrReadOnlyState = props.isDisabled || props.isReadOnly;
423
+ var isDefaultState = !(props.hasError || isDisabledOrReadOnlyState);
424
+ var canForcedHoverEffect = Boolean(props.isHovered && !isDisabledOrReadOnlyState);
425
+ return jsxRuntime.jsx(CheckboxIconWrapper, {
426
+ width: themedValue('auto', '26px'),
427
+ height: themedValue('auto', '26px'),
428
+ isHovered: canForcedHoverEffect,
429
+ children: jsxRuntime.jsx("div", {
430
+ 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 () {
432
+ if (props.isIndeterminate) return jsxRuntime.jsx(IndeterminateIcon$1, {
433
+ color: themedValue('primary', 'surface'),
434
+ size: "scale"
435
+ });
436
+ if (props.isChecked) return jsxRuntime.jsx(CheckedIcon$1, {
437
+ color: themedValue('primary', 'surface'),
438
+ size: "scale"
439
+ });
440
+ return null;
441
+ }()
442
+ })
443
+ });
444
+ };
587
445
 
588
446
  var Label = /*#__PURE__*/_styled__default["default"]("label", {
589
447
  target: "e6nn4mw0"
590
448
  } )("display:flex;align-items:center;cursor:", function (props) {
591
- if (props.disabled) return 'not-allowed';
592
- if (props.readOnly) return 'default';
449
+ if (props.isDisabled) return 'not-allowed';
450
+ if (props.isReadOnly) return 'default';
593
451
  return 'pointer';
594
- }, ";position:relative;", hoverStyles, " &:focus-within div{box-shadow:0 0 0 2px ", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ));
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
+ }, ";}" + ("" ));
595
455
 
596
456
  var CheckboxInput = function CheckboxInput(props) {
597
457
  // We generate an id in case no id is provided by the parent to attach the
@@ -600,40 +460,30 @@ var CheckboxInput = function CheckboxInput(props) {
600
460
  return jsxRuntime.jsxs(Label, {
601
461
  htmlFor: id,
602
462
  hasError: props.hasError,
603
- disabled: props.isDisabled,
604
- readOnly: props.isReadOnly,
605
- children: [jsxRuntime.jsx(Checkbox$1, _objectSpread(_objectSpread({
606
- type: "checkbox",
607
- id: id,
608
- name: props.name,
609
- value: props.value,
610
- onChange: props.onChange,
463
+ isDisabled: props.isDisabled,
464
+ isReadOnly: props.isReadOnly,
465
+ isChecked: props.isChecked,
466
+ isHovered: props.isHovered,
467
+ isIndeterminate: props.isIndeterminate,
468
+ children: [jsxRuntime.jsx(Checkbox$1, _objectSpread(_objectSpread({}, props), {}, {
469
+ id: id
470
+ })), jsxRuntime.jsx(CheckboxIcon, {
471
+ hasError: props.hasError,
611
472
  isDisabled: props.isDisabled,
612
473
  isReadOnly: props.isReadOnly,
613
474
  isChecked: props.isChecked,
475
+ isHovered: props.isHovered,
614
476
  isIndeterminate: props.isIndeterminate
615
- }, utils.filterDataAttributes(props)), utils.filterAriaAttributes(props))), jsxRuntime.jsx("div", {
616
- css: getCheckboxWrapperStyles(props),
617
- children: function () {
618
- if (props.isIndeterminate) return jsxRuntime.jsx(IndeterminateIcon$1, {
619
- size: "medium"
620
- });
621
- if (props.isChecked) return jsxRuntime.jsx(CheckedIcon$1, {
622
- size: "medium"
623
- });
624
- return jsxRuntime.jsx(UncheckedIcon$1, {
625
- size: "medium"
626
- });
627
- }()
628
- }), props.children && jsxRuntime.jsx(LabelTextWrapper // To allow focusing the Label in readOnly mode, because the checkbox gets disabled and therefore unfocusable
629
- , {
477
+ }), props.children && jsxRuntime.jsx(LabelTextWrapper, {
478
+ hasError: props.hasError,
479
+ isDisabled: props.isDisabled,
480
+ isReadOnly: props.isReadOnly,
481
+ isChecked: props.isChecked,
482
+ isHovered: props.isHovered,
483
+ isIndeterminate: props.isIndeterminate // To allow focusing the Label in readOnly mode, because the checkbox gets disabled and therefore unfocusable
484
+ ,
630
485
  tabIndex: props.isReadOnly ? 0 : -1,
631
- children: jsxRuntime.jsx(Text__default["default"].Body, {
632
- as: "span" // FIXME: add proper tones when we have disabled/primary in tones
633
- ,
634
- tone: props.isDisabled ? 'secondary' : undefined,
635
- children: props.children
636
- })
486
+ children: props.children
637
487
  })]
638
488
  });
639
489
  };
@@ -644,7 +494,7 @@ CheckboxInput.defaultProps = defaultProps;
644
494
  var CheckboxInput$1 = CheckboxInput;
645
495
 
646
496
  // NOTE: This string will be replaced on build time with the package version.
647
- var version = "15.12.0";
497
+ var version = "15.13.0";
648
498
 
649
499
  exports["default"] = CheckboxInput$1;
650
500
  exports.version = version;