@six-group/ui-library 0.0.0-insider.03e5196 → 0.0.0-insider.3f37dd4

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.
Files changed (71) hide show
  1. package/dist/cjs/six-checkbox.cjs.entry.js +57 -46
  2. package/dist/cjs/six-checkbox.cjs.entry.js.map +1 -1
  3. package/dist/cjs/six-input.cjs.entry.js +107 -81
  4. package/dist/cjs/six-input.cjs.entry.js.map +1 -1
  5. package/dist/cjs/six-radio.cjs.entry.js +56 -51
  6. package/dist/cjs/six-radio.cjs.entry.js.map +1 -1
  7. package/dist/cjs/six-range.cjs.entry.js +114 -75
  8. package/dist/cjs/six-range.cjs.entry.js.map +1 -1
  9. package/dist/cjs/six-textarea.cjs.entry.js +97 -74
  10. package/dist/cjs/six-textarea.cjs.entry.js.map +1 -1
  11. package/dist/cjs/slot-ad537f24.js.map +1 -1
  12. package/dist/collection/components/six-checkbox/six-checkbox.js +62 -49
  13. package/dist/collection/components/six-checkbox/six-checkbox.js.map +1 -1
  14. package/dist/collection/components/six-input/six-input.js +130 -117
  15. package/dist/collection/components/six-input/six-input.js.map +1 -1
  16. package/dist/collection/components/six-radio/six-radio.js +60 -53
  17. package/dist/collection/components/six-radio/six-radio.js.map +1 -1
  18. package/dist/collection/components/six-range/six-range.js +121 -76
  19. package/dist/collection/components/six-range/six-range.js.map +1 -1
  20. package/dist/collection/components/six-textarea/six-textarea.js +115 -105
  21. package/dist/collection/components/six-textarea/six-textarea.js.map +1 -1
  22. package/dist/collection/utils/slot.js.map +1 -1
  23. package/dist/components/six-checkbox.js +57 -46
  24. package/dist/components/six-checkbox.js.map +1 -1
  25. package/dist/components/six-input2.js +107 -81
  26. package/dist/components/six-input2.js.map +1 -1
  27. package/dist/components/six-radio.js +56 -51
  28. package/dist/components/six-radio.js.map +1 -1
  29. package/dist/components/six-range.js +114 -75
  30. package/dist/components/six-range.js.map +1 -1
  31. package/dist/components/six-textarea.js +97 -74
  32. package/dist/components/six-textarea.js.map +1 -1
  33. package/dist/components/slot.js.map +1 -1
  34. package/dist/components.json +45 -35
  35. package/dist/esm/six-checkbox.entry.js +57 -46
  36. package/dist/esm/six-checkbox.entry.js.map +1 -1
  37. package/dist/esm/six-input.entry.js +107 -81
  38. package/dist/esm/six-input.entry.js.map +1 -1
  39. package/dist/esm/six-radio.entry.js +56 -51
  40. package/dist/esm/six-radio.entry.js.map +1 -1
  41. package/dist/esm/six-range.entry.js +114 -75
  42. package/dist/esm/six-range.entry.js.map +1 -1
  43. package/dist/esm/six-textarea.entry.js +97 -74
  44. package/dist/esm/six-textarea.entry.js.map +1 -1
  45. package/dist/esm/slot-6f3984c7.js.map +1 -1
  46. package/dist/types/components/six-checkbox/six-checkbox.d.ts +21 -17
  47. package/dist/types/components/six-input/six-input.d.ts +27 -36
  48. package/dist/types/components/six-radio/six-radio.d.ts +10 -11
  49. package/dist/types/components/six-range/six-range.d.ts +24 -20
  50. package/dist/types/components/six-textarea/six-textarea.d.ts +22 -31
  51. package/dist/types/components.d.ts +19 -27
  52. package/dist/ui-library/{p-14f20bbb.entry.js → p-394a2a12.entry.js} +2 -2
  53. package/dist/ui-library/p-394a2a12.entry.js.map +1 -0
  54. package/dist/ui-library/{p-7e0cc4ae.entry.js → p-3c635d0a.entry.js} +2 -2
  55. package/dist/ui-library/p-3c635d0a.entry.js.map +1 -0
  56. package/dist/ui-library/p-5a25d6fb.entry.js +2 -0
  57. package/dist/ui-library/p-5a25d6fb.entry.js.map +1 -0
  58. package/dist/ui-library/{p-90dc6af4.entry.js → p-97cc839c.entry.js} +2 -2
  59. package/dist/ui-library/p-97cc839c.entry.js.map +1 -0
  60. package/dist/ui-library/p-b4dfb7cf.js.map +1 -1
  61. package/dist/ui-library/p-f604e067.entry.js +2 -0
  62. package/dist/ui-library/p-f604e067.entry.js.map +1 -0
  63. package/dist/ui-library/ui-library.esm.js +1 -1
  64. package/package.json +9 -9
  65. package/dist/ui-library/p-0d79b0c6.entry.js +0 -2
  66. package/dist/ui-library/p-0d79b0c6.entry.js.map +0 -1
  67. package/dist/ui-library/p-14f20bbb.entry.js.map +0 -1
  68. package/dist/ui-library/p-7e0cc4ae.entry.js.map +0 -1
  69. package/dist/ui-library/p-90dc6af4.entry.js.map +0 -1
  70. package/dist/ui-library/p-edc96efc.entry.js +0 -2
  71. package/dist/ui-library/p-edc96efc.entry.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2023-05-17T11:24:20",
2
+ "timestamp": "2023-05-24T16:07:24",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "3.2.1",
@@ -1214,6 +1214,7 @@
1214
1214
  "reflectToAttr": false,
1215
1215
  "docs": "The checkbox's name attribute.",
1216
1216
  "docsTags": [],
1217
+ "default": "''",
1217
1218
  "values": [
1218
1219
  {
1219
1220
  "type": "string"
@@ -1245,8 +1246,9 @@
1245
1246
  "mutable": false,
1246
1247
  "attr": "value",
1247
1248
  "reflectToAttr": false,
1248
- "docs": "The checkbox's value attribute.",
1249
+ "docs": "The value of the checkbox does not mean if it's checked or not, use the `checked`\nproperty for that.\n\nThe value of a checkbox is analogous to the value of an `<input type=\"checkbox\">`,\nit's only used when the checkbox participates in a native `<form>`.",
1249
1250
  "docsTags": [],
1251
+ "default": "'on'",
1250
1252
  "values": [
1251
1253
  {
1252
1254
  "type": "string"
@@ -5052,6 +5054,7 @@
5052
5054
  "reflectToAttr": false,
5053
5055
  "docs": "The input's autocaptialize attribute.",
5054
5056
  "docsTags": [],
5057
+ "default": "'off'",
5055
5058
  "values": [
5056
5059
  {
5057
5060
  "type": "string"
@@ -5068,6 +5071,7 @@
5068
5071
  "reflectToAttr": false,
5069
5072
  "docs": "The input's autocomplete attribute.",
5070
5073
  "docsTags": [],
5074
+ "default": "'off'",
5071
5075
  "values": [
5072
5076
  {
5073
5077
  "type": "string"
@@ -5078,14 +5082,20 @@
5078
5082
  },
5079
5083
  {
5080
5084
  "name": "autocorrect",
5081
- "type": "string",
5085
+ "type": "\"off\" | \"on\"",
5082
5086
  "mutable": false,
5083
5087
  "attr": "autocorrect",
5084
5088
  "reflectToAttr": false,
5085
5089
  "docs": "The input's autocorrect attribute.",
5086
5090
  "docsTags": [],
5091
+ "default": "'off'",
5087
5092
  "values": [
5088
5093
  {
5094
+ "value": "off",
5095
+ "type": "string"
5096
+ },
5097
+ {
5098
+ "value": "on",
5089
5099
  "type": "string"
5090
5100
  }
5091
5101
  ],
@@ -5100,6 +5110,7 @@
5100
5110
  "reflectToAttr": false,
5101
5111
  "docs": "The input's autofocus attribute.",
5102
5112
  "docsTags": [],
5113
+ "default": "false",
5103
5114
  "values": [
5104
5115
  {
5105
5116
  "type": "boolean"
@@ -5235,7 +5246,7 @@
5235
5246
  "type": "string"
5236
5247
  }
5237
5248
  ],
5238
- "optional": false,
5249
+ "optional": true,
5239
5250
  "required": false
5240
5251
  },
5241
5252
  {
@@ -5302,7 +5313,7 @@
5302
5313
  "type": "number"
5303
5314
  }
5304
5315
  ],
5305
- "optional": false,
5316
+ "optional": true,
5306
5317
  "required": false
5307
5318
  },
5308
5319
  {
@@ -5318,7 +5329,7 @@
5318
5329
  "type": "number"
5319
5330
  }
5320
5331
  ],
5321
- "optional": false,
5332
+ "optional": true,
5322
5333
  "required": false
5323
5334
  },
5324
5335
  {
@@ -5334,7 +5345,7 @@
5334
5345
  "type": "number"
5335
5346
  }
5336
5347
  ],
5337
- "optional": false,
5348
+ "optional": true,
5338
5349
  "required": false
5339
5350
  },
5340
5351
  {
@@ -5350,7 +5361,7 @@
5350
5361
  "type": "number"
5351
5362
  }
5352
5363
  ],
5353
- "optional": false,
5364
+ "optional": true,
5354
5365
  "required": false
5355
5366
  },
5356
5367
  {
@@ -5383,7 +5394,7 @@
5383
5394
  "type": "string"
5384
5395
  }
5385
5396
  ],
5386
- "optional": false,
5397
+ "optional": true,
5387
5398
  "required": false
5388
5399
  },
5389
5400
  {
@@ -5416,7 +5427,7 @@
5416
5427
  "type": "string"
5417
5428
  }
5418
5429
  ],
5419
- "optional": false,
5430
+ "optional": true,
5420
5431
  "required": false
5421
5432
  },
5422
5433
  {
@@ -5444,6 +5455,7 @@
5444
5455
  "reflectToAttr": true,
5445
5456
  "docs": "Set to true to make the input a required field.",
5446
5457
  "docsTags": [],
5458
+ "default": "false",
5447
5459
  "values": [
5448
5460
  {
5449
5461
  "type": "boolean"
@@ -5486,6 +5498,7 @@
5486
5498
  "reflectToAttr": false,
5487
5499
  "docs": "Enables spell checking on the input.",
5488
5500
  "docsTags": [],
5501
+ "default": "false",
5489
5502
  "values": [
5490
5503
  {
5491
5504
  "type": "boolean"
@@ -5507,7 +5520,7 @@
5507
5520
  "type": "number"
5508
5521
  }
5509
5522
  ],
5510
- "optional": false,
5523
+ "optional": true,
5511
5524
  "required": false
5512
5525
  },
5513
5526
  {
@@ -5616,7 +5629,7 @@
5616
5629
  "type": "Promise<ValidityState>",
5617
5630
  "docs": ""
5618
5631
  },
5619
- "signature": "getValidity() => Promise<ValidityState>",
5632
+ "signature": "getValidity() => Promise<ValidityState | undefined>",
5620
5633
  "parameters": [],
5621
5634
  "docs": "Returns the native input's validity",
5622
5635
  "docsTags": []
@@ -5766,15 +5779,6 @@
5766
5779
  "composed": true,
5767
5780
  "docs": "Emitted when the control receives input. Access the new value via event.target.value.",
5768
5781
  "docsTags": []
5769
- },
5770
- {
5771
- "event": "six-input-value-change",
5772
- "detail": "undefined",
5773
- "bubbles": true,
5774
- "cancelable": true,
5775
- "composed": true,
5776
- "docs": "Emitted whenever the value changes. Access the new value via event.target.value.\nsix-input-value-change will emit whenever the value changes.\nSo be it on input or when dynamically set. six-input-input will only be emitted when the user enters data,\nbut not when a value is dynamically set. six-input-change will only be emitted when the user either presses enter\nor leaves the input field after entering some data.",
5777
- "docsTags": []
5778
5782
  }
5779
5783
  ],
5780
5784
  "listeners": [],
@@ -7339,6 +7343,7 @@
7339
7343
  "reflectToAttr": false,
7340
7344
  "docs": "The radio's name attribute.",
7341
7345
  "docsTags": [],
7346
+ "default": "''",
7342
7347
  "values": [
7343
7348
  {
7344
7349
  "type": "string"
@@ -7355,6 +7360,7 @@
7355
7360
  "reflectToAttr": false,
7356
7361
  "docs": "The radio's value attribute.",
7357
7362
  "docsTags": [],
7363
+ "default": "'on'",
7358
7364
  "values": [
7359
7365
  {
7360
7366
  "type": "string"
@@ -7694,6 +7700,7 @@
7694
7700
  "reflectToAttr": true,
7695
7701
  "docs": "Set to true to make the input a required field.",
7696
7702
  "docsTags": [],
7703
+ "default": "false",
7697
7704
  "values": [
7698
7705
  {
7699
7706
  "type": "boolean"
@@ -7769,6 +7776,7 @@
7769
7776
  "reflectToAttr": false,
7770
7777
  "docs": "The input's value attribute.",
7771
7778
  "docsTags": [],
7779
+ "default": "0",
7772
7780
  "values": [
7773
7781
  {
7774
7782
  "type": "number"
@@ -10467,6 +10475,7 @@
10467
10475
  "reflectToAttr": false,
10468
10476
  "docs": "The textarea's autocaptialize attribute.",
10469
10477
  "docsTags": [],
10478
+ "default": "'off'",
10470
10479
  "values": [
10471
10480
  {
10472
10481
  "type": "string"
@@ -10483,6 +10492,7 @@
10483
10492
  "reflectToAttr": false,
10484
10493
  "docs": "The textarea's autocomplete attribute.",
10485
10494
  "docsTags": [],
10495
+ "default": "'off'",
10486
10496
  "values": [
10487
10497
  {
10488
10498
  "type": "string"
@@ -10493,14 +10503,20 @@
10493
10503
  },
10494
10504
  {
10495
10505
  "name": "autocorrect",
10496
- "type": "string",
10506
+ "type": "\"off\" | \"on\"",
10497
10507
  "mutable": false,
10498
10508
  "attr": "autocorrect",
10499
10509
  "reflectToAttr": false,
10500
10510
  "docs": "The textarea's autocorrect attribute.",
10501
10511
  "docsTags": [],
10512
+ "default": "'off'",
10502
10513
  "values": [
10503
10514
  {
10515
+ "value": "off",
10516
+ "type": "string"
10517
+ },
10518
+ {
10519
+ "value": "on",
10504
10520
  "type": "string"
10505
10521
  }
10506
10522
  ],
@@ -10515,6 +10531,7 @@
10515
10531
  "reflectToAttr": false,
10516
10532
  "docs": "The textarea's autofocus attribute.",
10517
10533
  "docsTags": [],
10534
+ "default": "false",
10518
10535
  "values": [
10519
10536
  {
10520
10537
  "type": "boolean"
@@ -10633,7 +10650,7 @@
10633
10650
  "type": "string"
10634
10651
  }
10635
10652
  ],
10636
- "optional": false,
10653
+ "optional": true,
10637
10654
  "required": false
10638
10655
  },
10639
10656
  {
@@ -10683,7 +10700,7 @@
10683
10700
  "type": "number"
10684
10701
  }
10685
10702
  ],
10686
- "optional": false,
10703
+ "optional": true,
10687
10704
  "required": false
10688
10705
  },
10689
10706
  {
@@ -10699,7 +10716,7 @@
10699
10716
  "type": "number"
10700
10717
  }
10701
10718
  ],
10702
- "optional": false,
10719
+ "optional": true,
10703
10720
  "required": false
10704
10721
  },
10705
10722
  {
@@ -10732,7 +10749,7 @@
10732
10749
  "type": "string"
10733
10750
  }
10734
10751
  ],
10735
- "optional": false,
10752
+ "optional": true,
10736
10753
  "required": false
10737
10754
  },
10738
10755
  {
@@ -10760,6 +10777,7 @@
10760
10777
  "reflectToAttr": true,
10761
10778
  "docs": "The textarea's required attribute.",
10762
10779
  "docsTags": [],
10780
+ "default": "false",
10763
10781
  "values": [
10764
10782
  {
10765
10783
  "type": "boolean"
@@ -10845,6 +10863,7 @@
10845
10863
  "reflectToAttr": false,
10846
10864
  "docs": "The textarea's spellcheck attribute.",
10847
10865
  "docsTags": [],
10866
+ "default": "false",
10848
10867
  "values": [
10849
10868
  {
10850
10869
  "type": "boolean"
@@ -11008,15 +11027,6 @@
11008
11027
  "composed": true,
11009
11028
  "docs": "Emitted when the control receives input. Access the new value via event.target.value.",
11010
11029
  "docsTags": []
11011
- },
11012
- {
11013
- "event": "six-textarea-value-change",
11014
- "detail": "undefined",
11015
- "bubbles": true,
11016
- "cancelable": true,
11017
- "composed": true,
11018
- "docs": "Emitted whenever the value changes. Access the new value via event.target.value.\nsix-textarea-value-change will emit whenever the value changes.\nSo be it on textarea or when dynamically set. six-textarea-input will only be emitted when the user enters data,\nbut not when a value is dynamically set. six-textarea-change will only be emitted when the user either presses enter\nor leaves the textarea field after entering some data.",
11019
- "docsTags": []
11020
11030
  }
11021
11031
  ],
11022
11032
  "listeners": [],
@@ -21,11 +21,31 @@ const SixCheckbox = class {
21
21
  this.eventListeners = new EventListeners();
22
22
  /** default state whether the radio button should be checked or not when resetting */
23
23
  this.defaultState = false;
24
+ this.handleChange = () => {
25
+ if (this.nativeInput != null) {
26
+ this.checked = this.nativeInput.checked;
27
+ this.indeterminate = false;
28
+ }
29
+ };
30
+ this.handleBlur = () => {
31
+ this.hasFocus = false;
32
+ this.sixBlur.emit();
33
+ };
34
+ this.handleFocus = () => {
35
+ this.hasFocus = true;
36
+ this.sixFocus.emit();
37
+ };
38
+ this.handleMouseDown = (event) => {
39
+ var _a;
40
+ // Prevent clicks on the label from briefly blurring the input
41
+ event.preventDefault();
42
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus();
43
+ };
24
44
  this.hasFocus = false;
25
45
  this.hasLabelSlot = false;
26
46
  this.hasErrorTextSlot = false;
27
- this.name = undefined;
28
- this.value = undefined;
47
+ this.name = '';
48
+ this.value = 'on';
29
49
  this.disabled = false;
30
50
  this.required = false;
31
51
  this.label = '';
@@ -36,27 +56,24 @@ const SixCheckbox = class {
36
56
  this.errorOnBlur = false;
37
57
  }
38
58
  handleCheckedChange() {
39
- if (!this.input) {
59
+ if (this.nativeInput == null) {
40
60
  return;
41
61
  }
42
- this.input.checked = this.checked;
43
- this.input.indeterminate = this.indeterminate;
44
- this.invalid = !this.input.checkValidity();
62
+ this.nativeInput.checked = this.checked;
63
+ this.nativeInput.indeterminate = this.indeterminate;
64
+ this.invalid = !this.nativeInput.checkValidity();
45
65
  this.sixChange.emit();
46
66
  }
47
67
  handleLabelChange() {
48
68
  this.handleSlotChange();
49
69
  }
50
70
  connectedCallback() {
51
- this.handleChange = this.handleChange.bind(this);
52
- this.handleBlur = this.handleBlur.bind(this);
53
- this.handleFocus = this.handleFocus.bind(this);
54
- this.handleMouseDown = this.handleMouseDown.bind(this);
55
- this.handleInvalid = this.handleInvalid.bind(this);
56
- this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);
71
+ var _a;
72
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener('slotchange', this.handleSlotChange);
57
73
  }
58
74
  disconnectedCallback() {
59
- this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);
75
+ var _a;
76
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeEventListener('slotchange', this.handleSlotChange);
60
77
  this.eventListeners.removeAll();
61
78
  }
62
79
  componentWillLoad() {
@@ -64,65 +81,59 @@ const SixCheckbox = class {
64
81
  this.handleSlotChange();
65
82
  }
66
83
  componentDidLoad() {
67
- this.input.indeterminate = this.indeterminate;
68
- this.eventListeners.add(this.input, 'invalid', (event) => {
69
- if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {
70
- this.customErrorText = this.input.validationMessage;
84
+ const nativeInput = this.nativeInput;
85
+ if (nativeInput == null) {
86
+ return;
87
+ }
88
+ nativeInput.indeterminate = this.indeterminate;
89
+ this.eventListeners.add(nativeInput, 'invalid', (event) => {
90
+ this.invalid = true;
91
+ if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {
92
+ this.customErrorText = nativeInput.validationMessage;
71
93
  }
72
94
  event.preventDefault();
73
95
  });
74
96
  }
75
97
  /** Sets focus on the checkbox. */
76
98
  async setFocus(options) {
77
- this.input.focus(options);
99
+ var _a;
100
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus(options);
78
101
  }
79
102
  /** Removes focus from the checkbox. */
80
103
  async removeFocus() {
81
- this.input.blur();
104
+ var _a;
105
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.blur();
82
106
  }
83
107
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
84
108
  async reportValidity() {
85
- return this.input.reportValidity();
109
+ var _a;
110
+ return (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.reportValidity();
86
111
  }
87
112
  /** Checks for validity. */
88
113
  async checkValidity() {
89
- return this.input.validity.valid;
114
+ if (this.nativeInput == null) {
115
+ return true;
116
+ }
117
+ return this.nativeInput.validity.valid;
90
118
  }
91
119
  /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
92
120
  async setCustomValidity(message) {
93
121
  this.customErrorText = '';
94
122
  this.customValidation = message !== '';
95
- this.input.setCustomValidity(message);
96
- this.invalid = !this.input.checkValidity();
123
+ if (this.nativeInput != null) {
124
+ this.nativeInput.setCustomValidity(message);
125
+ this.invalid = !this.nativeInput.checkValidity();
126
+ }
97
127
  }
98
128
  /** Resets the formcontrol */
99
129
  async reset() {
130
+ var _a;
100
131
  this.checked = this.defaultState;
101
132
  this.customErrorText = '';
102
133
  this.customValidation = false;
103
- this.input.setCustomValidity('');
134
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.setCustomValidity('');
104
135
  this.invalid = false;
105
136
  }
106
- handleChange() {
107
- this.checked = this.input.checked;
108
- this.indeterminate = false;
109
- }
110
- handleBlur() {
111
- this.hasFocus = false;
112
- this.sixBlur.emit();
113
- }
114
- handleFocus() {
115
- this.hasFocus = true;
116
- this.sixFocus.emit();
117
- }
118
- handleMouseDown(event) {
119
- // Prevent clicks on the label from briefly blurring the input
120
- event.preventDefault();
121
- this.input.focus();
122
- }
123
- handleInvalid() {
124
- this.invalid = true;
125
- }
126
137
  handleSlotChange() {
127
138
  this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
128
139
  this.hasLabelSlot = hasSlot(this.host, 'label');
@@ -131,14 +142,14 @@ const SixCheckbox = class {
131
142
  return this.invalid && (!this.errorOnBlur || !this.hasFocus);
132
143
  }
133
144
  render() {
134
- return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, errorTextId: this.errorTextId, errorText: this.customErrorText ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, size: "medium", disabled: this.disabled, required: this.required, displayError: this.displayError() }, h("label", { part: "base", class: {
145
+ return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, errorTextId: this.errorTextId, errorText: this.customErrorText != null ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, size: "medium", disabled: this.disabled, required: this.required, displayError: this.displayError() }, h("label", { part: "base", class: {
135
146
  checkbox: true,
136
147
  'checkbox--checked': this.checked,
137
148
  'checkbox--disabled': this.disabled,
138
149
  'checkbox--focused': this.hasFocus,
139
150
  'checkbox--invalid': this.invalid,
140
151
  'checkbox--indeterminate': this.indeterminate,
141
- }, htmlFor: this.inputId, onMouseDown: this.handleMouseDown }, h("span", { part: "control", class: "checkbox__control" }, this.checked && (h("span", { part: "checked-icon", class: "checkbox__icon" }, h("svg", { viewBox: "0 0 16 16" }, h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd", "stroke-linecap": "round" }, h("g", { stroke: "currentColor", "stroke-width": "2" }, h("g", { transform: "translate(3.428571, 3.428571)" }, h("path", { d: "M0,5.71428571 L3.42857143,9.14285714" }), h("path", { d: "M9.14285714,0 L3.42857143,9.14285714" }))))))), !this.checked && this.indeterminate && (h("span", { part: "indeterminate-icon", class: "checkbox__icon" }, h("svg", { viewBox: "0 0 16 16" }, h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd", "stroke-linecap": "round" }, h("g", { stroke: "currentColor", "stroke-width": "2" }, h("g", { transform: "translate(2.285714, 6.857143)" }, h("path", { d: "M10.2857143,1.14285714 L1.14285714,1.14285714" }))))))), h("input", { ref: (el) => (this.input = el), id: this.inputId, type: "checkbox", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled, required: this.required, role: "checkbox", "aria-checked": this.checked ? 'true' : 'false', "aria-labelledby": this.labelId, onChange: this.handleChange, onBlur: this.handleBlur, onFocus: this.handleFocus, onInvalid: this.handleInvalid })), h("span", { part: "text", id: this.textId, class: "checkbox__text" }, h("slot", null)))));
152
+ }, htmlFor: this.inputId, onMouseDown: this.handleMouseDown }, h("span", { part: "control", class: "checkbox__control" }, this.checked && (h("span", { part: "checked-icon", class: "checkbox__icon" }, h("svg", { viewBox: "0 0 16 16" }, h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd", "stroke-linecap": "round" }, h("g", { stroke: "currentColor", "stroke-width": "2" }, h("g", { transform: "translate(3.428571, 3.428571)" }, h("path", { d: "M0,5.71428571 L3.42857143,9.14285714" }), h("path", { d: "M9.14285714,0 L3.42857143,9.14285714" }))))))), !this.checked && this.indeterminate && (h("span", { part: "indeterminate-icon", class: "checkbox__icon" }, h("svg", { viewBox: "0 0 16 16" }, h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd", "stroke-linecap": "round" }, h("g", { stroke: "currentColor", "stroke-width": "2" }, h("g", { transform: "translate(2.285714, 6.857143)" }, h("path", { d: "M10.2857143,1.14285714 L1.14285714,1.14285714" }))))))), h("input", { ref: (el) => (this.nativeInput = el), id: this.inputId, type: "checkbox", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled, required: this.required, role: "checkbox", "aria-checked": this.checked ? 'true' : 'false', "aria-labelledby": this.labelId, onChange: this.handleChange, onBlur: this.handleBlur, onFocus: this.handleFocus })), h("span", { part: "text", id: this.textId, class: "checkbox__text" }, h("slot", null)))));
142
153
  }
143
154
  get host() { return getElement(this); }
144
155
  static get watchers() { return {
@@ -1 +1 @@
1
- {"file":"six-checkbox.entry.js","mappings":";;;;;AAAA,MAAM,cAAc,GAAG,mnJAAmnJ;;ACM1oJ,IAAI,EAAE,GAAG,CAAC,CAAC;MAuBE,WAAW;;;;;;IACtB,YAAO,GAAG,YAAY,EAAE,EAAE,EAAE,CAAC;IAC7B,YAAO,GAAG,kBAAkB,EAAE,EAAE,CAAC;IACjC,WAA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-checkbox.scss?tag=six-checkbox&encapsulation=shadow","./src/components/six-checkbox/six-checkbox.tsx"],"sourcesContent":["@import 'src/global/component';\n@import '../../functional-components/form-control/form-control';\n\n:host {\n display: inline-block;\n}\n\n.checkbox {\n display: inline-flex;\n align-items: center;\n font-family: var(--six-font-family);\n font-size: var(--six-input-font-size-medium);\n font-weight: var(--six-input-font-weight);\n color: var(--six-input-color);\n vertical-align: middle;\n cursor: pointer;\n}\n\n.checkbox__control {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--six-selection-control-toggle-size);\n height: var(--six-selection-control-toggle-size);\n border: solid var(--six-border-width) var(--six-input-border-color);\n border-radius: 0;\n background-color: var(--six-input-background-color);\n color: var(--six-checkbox-color);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow;\n\n input[type='checkbox'] {\n position: absolute;\n opacity: 0;\n padding: 0;\n margin: 0;\n pointer-events: none;\n }\n\n .checkbox__icon {\n display: inline-flex;\n width: var(--six-selection-control-toggle-size);\n height: var(--six-selection-control-toggle-size);\n\n svg {\n width: 100%;\n height: 100%;\n }\n }\n}\n\n// Hover\n.checkbox:not(.checkbox--checked):not(.checkbox--disabled) .checkbox__control:hover {\n border-color: var(--six-input-border-color-hover);\n}\n\n// Checked/indeterminate\n.checkbox--checked .checkbox__control,\n.checkbox--indeterminate .checkbox__control {\n border-color: var(--six-selection-control-color);\n background-color: var(--six-selection-control-color);\n}\n\n// Checked/indeterminate + hover\n.checkbox.checkbox--checked:not(.checkbox--disabled) .checkbox__control:hover,\n.checkbox.checkbox--indeterminate:not(.checkbox--disabled) .checkbox__control:hover {\n border-color: var(--six-input-border-color-focus);\n background-color: var(--six-input-border-color-focus);\n}\n\n// Disabled\n.checkbox--disabled {\n cursor: not-allowed;\n color: var(--six-input-color-disabled);\n\n .checkbox__control {\n border-color: var(--six-input-border-color-disabled);\n }\n\n &.checkbox--checked .checkbox__control,\n &.checkbox--indeterminate .checkbox__control {\n background-color: var(--six-selection-control-color-disabled);\n }\n}\n\n// Invalid\n.checkbox--invalid:not(.checkbox--disabled) {\n .checkbox__control {\n border-color: var(--six-input-border-color-danger);\n }\n}\n\n.checkbox__text {\n line-height: var(--six-selection-control-toggle-size);\n margin-left: 0.5em;\n user-select: none;\n}\n","import { Component, Event, EventEmitter, Method, Prop, State, Watch, h, Element } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The checkbox label.\n * @slot error-text - Error text that is shown for validation errors. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part control - The checkbox control.\n * @part checked-icon - The container the wraps the checked icon.\n * @part indeterminate-icon - The container that wraps the indeterminate icon.\n * @part text - The checkbox text rendered to the right.\n */\n\n@Component({\n tag: 'six-checkbox',\n styleUrl: 'six-checkbox.scss',\n shadow: true,\n})\nexport class SixCheckbox {\n inputId = `checkbox-${++id}`;\n labelId = `checkbox-label-${id}`;\n textId = `checkbox-text-${id}`;\n errorTextId = `input-error-text-${id}`;\n input: HTMLInputElement;\n customErrorText = '';\n customValidation = false;\n\n readonly eventListeners = new EventListeners();\n\n @Element() host: HTMLSixCheckboxElement;\n\n @State() hasFocus = false;\n @State() hasLabelSlot = false;\n @State() hasErrorTextSlot = false;\n\n /** The checkbox's name attribute. */\n @Prop() name: string;\n\n /** The checkbox's value attribute. */\n @Prop() value: string;\n\n /** Set to true to disable the checkbox. */\n @Prop() disabled = false;\n\n /** Set to true to make the checkbox a required field. */\n @Prop() required = false;\n\n /** The checkbox label. Alternatively, you can use the label slot. */\n @Prop() label = '';\n\n /** The checkbox's error text. Alternatively, you can use the error-text slot. */\n @Prop() errorText = '';\n\n /** Set to true to draw the checkbox in a checked state. */\n @Prop({ mutable: true, reflect: true }) checked = false;\n\n /** Set to true to draw the checkbox in an indeterminate state. */\n @Prop({ mutable: true, reflect: true }) indeterminate = false;\n\n /** This will be true when the control is in an invalid state. Validity is determined by the `required` prop. */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** Set to display the error text on blur and not when typing */\n @Prop() errorOnBlur = false;\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-checkbox-blur' }) sixBlur: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control's checked state changes. */\n @Event({ eventName: 'six-checkbox-change' }) sixChange: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-checkbox-focus' }) sixFocus: EventEmitter<EmptyPayload>;\n\n @Watch('checked')\n @Watch('indeterminate')\n handleCheckedChange() {\n if (!this.input) {\n return;\n }\n this.input.checked = this.checked;\n this.input.indeterminate = this.indeterminate;\n this.invalid = !this.input.checkValidity();\n this.sixChange.emit();\n }\n\n @Watch('errorText')\n @Watch('label')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n /** default state whether the radio button should be checked or not when resetting */\n private defaultState = false;\n\n connectedCallback() {\n this.handleChange = this.handleChange.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.handleMouseDown = this.handleMouseDown.bind(this);\n this.handleInvalid = this.handleInvalid.bind(this);\n\n this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);\n }\n\n disconnectedCallback() {\n this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n componentWillLoad() {\n this.defaultState = this.checked;\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n this.input.indeterminate = this.indeterminate;\n this.eventListeners.add(this.input, 'invalid', (event) => {\n if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {\n this.customErrorText = this.input.validationMessage;\n }\n event.preventDefault();\n });\n }\n\n /** Sets focus on the checkbox. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the checkbox. */\n @Method()\n async removeFocus() {\n this.input.blur();\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n @Method()\n async reportValidity() {\n return this.input.reportValidity();\n }\n\n /** Checks for validity. */\n @Method()\n async checkValidity() {\n return this.input.validity.valid;\n }\n\n /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */\n @Method()\n async setCustomValidity(message: string) {\n this.customErrorText = '';\n this.customValidation = message !== '';\n this.input.setCustomValidity(message);\n this.invalid = !this.input.checkValidity();\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.checked = this.defaultState;\n this.customErrorText = '';\n this.customValidation = false;\n this.input.setCustomValidity('');\n this.invalid = false;\n }\n\n handleChange() {\n this.checked = this.input.checked;\n this.indeterminate = false;\n }\n\n handleBlur() {\n this.hasFocus = false;\n this.sixBlur.emit();\n }\n\n handleFocus() {\n this.hasFocus = true;\n this.sixFocus.emit();\n }\n\n handleMouseDown(event: MouseEvent) {\n // Prevent clicks on the label from briefly blurring the input\n event.preventDefault();\n this.input.focus();\n }\n\n handleInvalid() {\n this.invalid = true;\n }\n\n handleSlotChange() {\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n }\n\n displayError() {\n return this.invalid && (!this.errorOnBlur || !this.hasFocus);\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n errorTextId={this.errorTextId}\n errorText={this.customErrorText ? this.customErrorText : this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n size=\"medium\"\n disabled={this.disabled}\n required={this.required}\n displayError={this.displayError()}\n >\n <label\n part=\"base\"\n class={{\n checkbox: true,\n 'checkbox--checked': this.checked,\n 'checkbox--disabled': this.disabled,\n 'checkbox--focused': this.hasFocus,\n 'checkbox--invalid': this.invalid,\n 'checkbox--indeterminate': this.indeterminate,\n }}\n htmlFor={this.inputId}\n onMouseDown={this.handleMouseDown}\n >\n <span part=\"control\" class=\"checkbox__control\">\n {this.checked && (\n <span part=\"checked-icon\" class=\"checkbox__icon\">\n <svg viewBox=\"0 0 16 16\">\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" stroke-linecap=\"round\">\n <g stroke=\"currentColor\" stroke-width=\"2\">\n <g transform=\"translate(3.428571, 3.428571)\">\n <path d=\"M0,5.71428571 L3.42857143,9.14285714\"></path>\n <path d=\"M9.14285714,0 L3.42857143,9.14285714\"></path>\n </g>\n </g>\n </g>\n </svg>\n </span>\n )}\n\n {!this.checked && this.indeterminate && (\n <span part=\"indeterminate-icon\" class=\"checkbox__icon\">\n <svg viewBox=\"0 0 16 16\">\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" stroke-linecap=\"round\">\n <g stroke=\"currentColor\" stroke-width=\"2\">\n <g transform=\"translate(2.285714, 6.857143)\">\n <path d=\"M10.2857143,1.14285714 L1.14285714,1.14285714\"></path>\n </g>\n </g>\n </g>\n </svg>\n </span>\n )}\n\n <input\n ref={(el) => (this.input = el)}\n id={this.inputId}\n type=\"checkbox\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n disabled={this.disabled}\n required={this.required}\n role=\"checkbox\"\n aria-checked={this.checked ? 'true' : 'false'}\n aria-labelledby={this.labelId}\n onChange={this.handleChange}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n onInvalid={this.handleInvalid}\n />\n </span>\n\n <span part=\"text\" id={this.textId} class=\"checkbox__text\">\n <slot />\n </span>\n </label>\n </FormControl>\n );\n }\n}\n"],"version":3}
1
+ {"file":"six-checkbox.entry.js","mappings":";;;;;AAAA,MAAM,cAAc,GAAG,mnJAAmnJ;;ACM1oJ,IAAI,EAAE,GAAG,CAAC,CAAC;MAuBE,WAA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,CACH,CACD,CACI,EACd;GACH;;;;;;;;;;;;;","names":[],"sources":["./src/components/six-checkbox/six-checkbox.scss?tag=six-checkbox&encapsulation=shadow","./src/components/six-checkbox/six-checkbox.tsx"],"sourcesContent":["@import 'src/global/component';\n@import '../../functional-components/form-control/form-control';\n\n:host {\n display: inline-block;\n}\n\n.checkbox {\n display: inline-flex;\n align-items: center;\n font-family: var(--six-font-family);\n font-size: var(--six-input-font-size-medium);\n font-weight: var(--six-input-font-weight);\n color: var(--six-input-color);\n vertical-align: middle;\n cursor: pointer;\n}\n\n.checkbox__control {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--six-selection-control-toggle-size);\n height: var(--six-selection-control-toggle-size);\n border: solid var(--six-border-width) var(--six-input-border-color);\n border-radius: 0;\n background-color: var(--six-input-background-color);\n color: var(--six-checkbox-color);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow;\n\n input[type='checkbox'] {\n position: absolute;\n opacity: 0;\n padding: 0;\n margin: 0;\n pointer-events: none;\n }\n\n .checkbox__icon {\n display: inline-flex;\n width: var(--six-selection-control-toggle-size);\n height: var(--six-selection-control-toggle-size);\n\n svg {\n width: 100%;\n height: 100%;\n }\n }\n}\n\n// Hover\n.checkbox:not(.checkbox--checked):not(.checkbox--disabled) .checkbox__control:hover {\n border-color: var(--six-input-border-color-hover);\n}\n\n// Checked/indeterminate\n.checkbox--checked .checkbox__control,\n.checkbox--indeterminate .checkbox__control {\n border-color: var(--six-selection-control-color);\n background-color: var(--six-selection-control-color);\n}\n\n// Checked/indeterminate + hover\n.checkbox.checkbox--checked:not(.checkbox--disabled) .checkbox__control:hover,\n.checkbox.checkbox--indeterminate:not(.checkbox--disabled) .checkbox__control:hover {\n border-color: var(--six-input-border-color-focus);\n background-color: var(--six-input-border-color-focus);\n}\n\n// Disabled\n.checkbox--disabled {\n cursor: not-allowed;\n color: var(--six-input-color-disabled);\n\n .checkbox__control {\n border-color: var(--six-input-border-color-disabled);\n }\n\n &.checkbox--checked .checkbox__control,\n &.checkbox--indeterminate .checkbox__control {\n background-color: var(--six-selection-control-color-disabled);\n }\n}\n\n// Invalid\n.checkbox--invalid:not(.checkbox--disabled) {\n .checkbox__control {\n border-color: var(--six-input-border-color-danger);\n }\n}\n\n.checkbox__text {\n line-height: var(--six-selection-control-toggle-size);\n margin-left: 0.5em;\n user-select: none;\n}\n","import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The checkbox label.\n * @slot error-text - Error text that is shown for validation errors. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part control - The checkbox control.\n * @part checked-icon - The container the wraps the checked icon.\n * @part indeterminate-icon - The container that wraps the indeterminate icon.\n * @part text - The checkbox text rendered to the right.\n */\n\n@Component({\n tag: 'six-checkbox',\n styleUrl: 'six-checkbox.scss',\n shadow: true,\n})\nexport class SixCheckbox {\n private inputId = `checkbox-${++id}`;\n private labelId = `checkbox-label-${id}`;\n private textId = `checkbox-text-${id}`;\n private errorTextId = `input-error-text-${id}`;\n private nativeInput?: HTMLInputElement;\n private customErrorText = '';\n private customValidation = false;\n private eventListeners = new EventListeners();\n\n @Element() host!: HTMLSixCheckboxElement;\n\n @State() hasFocus = false;\n @State() hasLabelSlot = false;\n @State() hasErrorTextSlot = false;\n\n /** The checkbox's name attribute. */\n @Prop() name = '';\n\n /**\n * The value of the checkbox does not mean if it's checked or not, use the `checked`\n * property for that.\n *\n * The value of a checkbox is analogous to the value of an `<input type=\"checkbox\">`,\n * it's only used when the checkbox participates in a native `<form>`.\n */\n @Prop() value = 'on';\n\n /** Set to true to disable the checkbox. */\n @Prop() disabled = false;\n\n /** Set to true to make the checkbox a required field. */\n @Prop() required = false;\n\n /** The checkbox label. Alternatively, you can use the label slot. */\n @Prop() label = '';\n\n /** The checkbox's error text. Alternatively, you can use the error-text slot. */\n @Prop() errorText = '';\n\n /** Set to true to draw the checkbox in a checked state. */\n @Prop({ mutable: true, reflect: true }) checked = false;\n\n /** Set to true to draw the checkbox in an indeterminate state. */\n @Prop({ mutable: true, reflect: true }) indeterminate = false;\n\n /** This will be true when the control is in an invalid state. Validity is determined by the `required` prop. */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** Set to display the error text on blur and not when typing */\n @Prop() errorOnBlur = false;\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-checkbox-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control's checked state changes. */\n @Event({ eventName: 'six-checkbox-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-checkbox-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n @Watch('checked')\n @Watch('indeterminate')\n handleCheckedChange() {\n if (this.nativeInput == null) {\n return;\n }\n this.nativeInput.checked = this.checked;\n this.nativeInput.indeterminate = this.indeterminate;\n this.invalid = !this.nativeInput.checkValidity();\n this.sixChange.emit();\n }\n\n @Watch('errorText')\n @Watch('label')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n /** default state whether the radio button should be checked or not when resetting */\n private defaultState = false;\n\n connectedCallback() {\n this.host.shadowRoot?.addEventListener('slotchange', this.handleSlotChange);\n }\n\n disconnectedCallback() {\n this.host.shadowRoot?.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n componentWillLoad() {\n this.defaultState = this.checked;\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n const nativeInput = this.nativeInput;\n if (nativeInput == null) {\n return;\n }\n\n nativeInput.indeterminate = this.indeterminate;\n this.eventListeners.add(nativeInput, 'invalid', (event) => {\n this.invalid = true;\n if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {\n this.customErrorText = nativeInput.validationMessage;\n }\n event.preventDefault();\n });\n }\n\n /** Sets focus on the checkbox. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the checkbox. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n @Method()\n async reportValidity() {\n return this.nativeInput?.reportValidity();\n }\n\n /** Checks for validity. */\n @Method()\n async checkValidity() {\n if (this.nativeInput == null) {\n return true;\n }\n return this.nativeInput.validity.valid;\n }\n\n /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */\n @Method()\n async setCustomValidity(message: string) {\n this.customErrorText = '';\n this.customValidation = message !== '';\n if (this.nativeInput != null) {\n this.nativeInput.setCustomValidity(message);\n this.invalid = !this.nativeInput.checkValidity();\n }\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.checked = this.defaultState;\n this.customErrorText = '';\n this.customValidation = false;\n this.nativeInput?.setCustomValidity('');\n this.invalid = false;\n }\n\n private handleChange = () => {\n if (this.nativeInput != null) {\n this.checked = this.nativeInput.checked;\n this.indeterminate = false;\n }\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.sixBlur.emit();\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.sixFocus.emit();\n };\n\n private handleMouseDown = (event: MouseEvent) => {\n // Prevent clicks on the label from briefly blurring the input\n event.preventDefault();\n this.nativeInput?.focus();\n };\n\n private handleSlotChange() {\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n }\n\n private displayError() {\n return this.invalid && (!this.errorOnBlur || !this.hasFocus);\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n errorTextId={this.errorTextId}\n errorText={this.customErrorText != null ? this.customErrorText : this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n size=\"medium\"\n disabled={this.disabled}\n required={this.required}\n displayError={this.displayError()}\n >\n <label\n part=\"base\"\n class={{\n checkbox: true,\n 'checkbox--checked': this.checked,\n 'checkbox--disabled': this.disabled,\n 'checkbox--focused': this.hasFocus,\n 'checkbox--invalid': this.invalid,\n 'checkbox--indeterminate': this.indeterminate,\n }}\n htmlFor={this.inputId}\n onMouseDown={this.handleMouseDown}\n >\n <span part=\"control\" class=\"checkbox__control\">\n {this.checked && (\n <span part=\"checked-icon\" class=\"checkbox__icon\">\n <svg viewBox=\"0 0 16 16\">\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" stroke-linecap=\"round\">\n <g stroke=\"currentColor\" stroke-width=\"2\">\n <g transform=\"translate(3.428571, 3.428571)\">\n <path d=\"M0,5.71428571 L3.42857143,9.14285714\"></path>\n <path d=\"M9.14285714,0 L3.42857143,9.14285714\"></path>\n </g>\n </g>\n </g>\n </svg>\n </span>\n )}\n\n {!this.checked && this.indeterminate && (\n <span part=\"indeterminate-icon\" class=\"checkbox__icon\">\n <svg viewBox=\"0 0 16 16\">\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" stroke-linecap=\"round\">\n <g stroke=\"currentColor\" stroke-width=\"2\">\n <g transform=\"translate(2.285714, 6.857143)\">\n <path d=\"M10.2857143,1.14285714 L1.14285714,1.14285714\"></path>\n </g>\n </g>\n </g>\n </svg>\n </span>\n )}\n\n <input\n ref={(el) => (this.nativeInput = el)}\n id={this.inputId}\n type=\"checkbox\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n disabled={this.disabled}\n required={this.required}\n role=\"checkbox\"\n aria-checked={this.checked ? 'true' : 'false'}\n aria-labelledby={this.labelId}\n onChange={this.handleChange}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n />\n </span>\n\n <span part=\"text\" id={this.textId} class=\"checkbox__text\">\n <slot />\n </span>\n </label>\n </FormControl>\n );\n }\n}\n"],"version":3}