@six-group/ui-library 0.0.0-insider.9277796 → 0.0.0-insider.a358260

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 (88) 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-select.cjs.entry.js +298 -239
  10. package/dist/cjs/six-select.cjs.entry.js.map +1 -1
  11. package/dist/cjs/six-textarea.cjs.entry.js +97 -74
  12. package/dist/cjs/six-textarea.cjs.entry.js.map +1 -1
  13. package/dist/cjs/slot-ad537f24.js.map +1 -1
  14. package/dist/collection/components/six-checkbox/six-checkbox.js +62 -49
  15. package/dist/collection/components/six-checkbox/six-checkbox.js.map +1 -1
  16. package/dist/collection/components/six-input/six-input.js +130 -117
  17. package/dist/collection/components/six-input/six-input.js.map +1 -1
  18. package/dist/collection/components/six-radio/six-radio.js +60 -53
  19. package/dist/collection/components/six-radio/six-radio.js.map +1 -1
  20. package/dist/collection/components/six-range/six-range.js +121 -76
  21. package/dist/collection/components/six-range/six-range.js.map +1 -1
  22. package/dist/collection/components/six-select/six-select.js +248 -240
  23. package/dist/collection/components/six-select/six-select.js.map +1 -1
  24. package/dist/collection/components/six-select/util.js +52 -0
  25. package/dist/collection/components/six-select/util.js.map +1 -0
  26. package/dist/collection/components/six-textarea/six-textarea.js +115 -105
  27. package/dist/collection/components/six-textarea/six-textarea.js.map +1 -1
  28. package/dist/collection/utils/slot.js.map +1 -1
  29. package/dist/components/six-checkbox.js +57 -46
  30. package/dist/components/six-checkbox.js.map +1 -1
  31. package/dist/components/six-input2.js +107 -81
  32. package/dist/components/six-input2.js.map +1 -1
  33. package/dist/components/six-radio.js +56 -51
  34. package/dist/components/six-radio.js.map +1 -1
  35. package/dist/components/six-range.js +114 -75
  36. package/dist/components/six-range.js.map +1 -1
  37. package/dist/components/six-select.js +299 -240
  38. package/dist/components/six-select.js.map +1 -1
  39. package/dist/components/six-textarea.js +97 -74
  40. package/dist/components/six-textarea.js.map +1 -1
  41. package/dist/components/slot.js.map +1 -1
  42. package/dist/components.json +51 -41
  43. package/dist/esm/six-checkbox.entry.js +57 -46
  44. package/dist/esm/six-checkbox.entry.js.map +1 -1
  45. package/dist/esm/six-input.entry.js +107 -81
  46. package/dist/esm/six-input.entry.js.map +1 -1
  47. package/dist/esm/six-radio.entry.js +56 -51
  48. package/dist/esm/six-radio.entry.js.map +1 -1
  49. package/dist/esm/six-range.entry.js +114 -75
  50. package/dist/esm/six-range.entry.js.map +1 -1
  51. package/dist/esm/six-select.entry.js +299 -240
  52. package/dist/esm/six-select.entry.js.map +1 -1
  53. package/dist/esm/six-textarea.entry.js +97 -74
  54. package/dist/esm/six-textarea.entry.js.map +1 -1
  55. package/dist/esm/slot-6f3984c7.js.map +1 -1
  56. package/dist/types/components/six-checkbox/six-checkbox.d.ts +21 -17
  57. package/dist/types/components/six-input/six-input.d.ts +27 -36
  58. package/dist/types/components/six-radio/six-radio.d.ts +10 -11
  59. package/dist/types/components/six-range/six-range.d.ts +24 -20
  60. package/dist/types/components/six-select/six-select.d.ts +35 -40
  61. package/dist/types/components/six-select/util.d.ts +7 -0
  62. package/dist/types/components/six-textarea/six-textarea.d.ts +22 -31
  63. package/dist/types/components.d.ts +20 -28
  64. package/dist/types/utils/testing.d.ts +1 -1
  65. package/dist/ui-library/p-163f2bb0.entry.js +2 -0
  66. package/dist/ui-library/p-163f2bb0.entry.js.map +1 -0
  67. package/dist/ui-library/{p-14f20bbb.entry.js → p-394a2a12.entry.js} +2 -2
  68. package/dist/ui-library/p-394a2a12.entry.js.map +1 -0
  69. package/dist/ui-library/{p-7e0cc4ae.entry.js → p-3c635d0a.entry.js} +2 -2
  70. package/dist/ui-library/p-3c635d0a.entry.js.map +1 -0
  71. package/dist/ui-library/p-5a25d6fb.entry.js +2 -0
  72. package/dist/ui-library/p-5a25d6fb.entry.js.map +1 -0
  73. package/dist/ui-library/{p-90dc6af4.entry.js → p-97cc839c.entry.js} +2 -2
  74. package/dist/ui-library/p-97cc839c.entry.js.map +1 -0
  75. package/dist/ui-library/p-b4dfb7cf.js.map +1 -1
  76. package/dist/ui-library/p-f604e067.entry.js +2 -0
  77. package/dist/ui-library/p-f604e067.entry.js.map +1 -0
  78. package/dist/ui-library/ui-library.esm.js +1 -1
  79. package/package.json +13 -14
  80. package/dist/ui-library/p-0d79b0c6.entry.js +0 -2
  81. package/dist/ui-library/p-0d79b0c6.entry.js.map +0 -1
  82. package/dist/ui-library/p-14f20bbb.entry.js.map +0 -1
  83. package/dist/ui-library/p-7e0cc4ae.entry.js.map +0 -1
  84. package/dist/ui-library/p-835c3ff7.entry.js +0 -2
  85. package/dist/ui-library/p-835c3ff7.entry.js.map +0 -1
  86. package/dist/ui-library/p-90dc6af4.entry.js.map +0 -1
  87. package/dist/ui-library/p-edc96efc.entry.js +0 -2
  88. package/dist/ui-library/p-edc96efc.entry.js.map +0 -1
@@ -23,11 +23,31 @@ const SixCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class SixCheckbox extends
23
23
  this.eventListeners = new EventListeners();
24
24
  /** default state whether the radio button should be checked or not when resetting */
25
25
  this.defaultState = false;
26
+ this.handleChange = () => {
27
+ if (this.nativeInput != null) {
28
+ this.checked = this.nativeInput.checked;
29
+ this.indeterminate = false;
30
+ }
31
+ };
32
+ this.handleBlur = () => {
33
+ this.hasFocus = false;
34
+ this.sixBlur.emit();
35
+ };
36
+ this.handleFocus = () => {
37
+ this.hasFocus = true;
38
+ this.sixFocus.emit();
39
+ };
40
+ this.handleMouseDown = (event) => {
41
+ var _a;
42
+ // Prevent clicks on the label from briefly blurring the input
43
+ event.preventDefault();
44
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus();
45
+ };
26
46
  this.hasFocus = false;
27
47
  this.hasLabelSlot = false;
28
48
  this.hasErrorTextSlot = false;
29
- this.name = undefined;
30
- this.value = undefined;
49
+ this.name = '';
50
+ this.value = 'on';
31
51
  this.disabled = false;
32
52
  this.required = false;
33
53
  this.label = '';
@@ -38,27 +58,24 @@ const SixCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class SixCheckbox extends
38
58
  this.errorOnBlur = false;
39
59
  }
40
60
  handleCheckedChange() {
41
- if (!this.input) {
61
+ if (this.nativeInput == null) {
42
62
  return;
43
63
  }
44
- this.input.checked = this.checked;
45
- this.input.indeterminate = this.indeterminate;
46
- this.invalid = !this.input.checkValidity();
64
+ this.nativeInput.checked = this.checked;
65
+ this.nativeInput.indeterminate = this.indeterminate;
66
+ this.invalid = !this.nativeInput.checkValidity();
47
67
  this.sixChange.emit();
48
68
  }
49
69
  handleLabelChange() {
50
70
  this.handleSlotChange();
51
71
  }
52
72
  connectedCallback() {
53
- this.handleChange = this.handleChange.bind(this);
54
- this.handleBlur = this.handleBlur.bind(this);
55
- this.handleFocus = this.handleFocus.bind(this);
56
- this.handleMouseDown = this.handleMouseDown.bind(this);
57
- this.handleInvalid = this.handleInvalid.bind(this);
58
- this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);
73
+ var _a;
74
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener('slotchange', this.handleSlotChange);
59
75
  }
60
76
  disconnectedCallback() {
61
- this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);
77
+ var _a;
78
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeEventListener('slotchange', this.handleSlotChange);
62
79
  this.eventListeners.removeAll();
63
80
  }
64
81
  componentWillLoad() {
@@ -66,65 +83,59 @@ const SixCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class SixCheckbox extends
66
83
  this.handleSlotChange();
67
84
  }
68
85
  componentDidLoad() {
69
- this.input.indeterminate = this.indeterminate;
70
- this.eventListeners.add(this.input, 'invalid', (event) => {
71
- if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {
72
- this.customErrorText = this.input.validationMessage;
86
+ const nativeInput = this.nativeInput;
87
+ if (nativeInput == null) {
88
+ return;
89
+ }
90
+ nativeInput.indeterminate = this.indeterminate;
91
+ this.eventListeners.add(nativeInput, 'invalid', (event) => {
92
+ this.invalid = true;
93
+ if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {
94
+ this.customErrorText = nativeInput.validationMessage;
73
95
  }
74
96
  event.preventDefault();
75
97
  });
76
98
  }
77
99
  /** Sets focus on the checkbox. */
78
100
  async setFocus(options) {
79
- this.input.focus(options);
101
+ var _a;
102
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus(options);
80
103
  }
81
104
  /** Removes focus from the checkbox. */
82
105
  async removeFocus() {
83
- this.input.blur();
106
+ var _a;
107
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.blur();
84
108
  }
85
109
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
86
110
  async reportValidity() {
87
- return this.input.reportValidity();
111
+ var _a;
112
+ return (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.reportValidity();
88
113
  }
89
114
  /** Checks for validity. */
90
115
  async checkValidity() {
91
- return this.input.validity.valid;
116
+ if (this.nativeInput == null) {
117
+ return true;
118
+ }
119
+ return this.nativeInput.validity.valid;
92
120
  }
93
121
  /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
94
122
  async setCustomValidity(message) {
95
123
  this.customErrorText = '';
96
124
  this.customValidation = message !== '';
97
- this.input.setCustomValidity(message);
98
- this.invalid = !this.input.checkValidity();
125
+ if (this.nativeInput != null) {
126
+ this.nativeInput.setCustomValidity(message);
127
+ this.invalid = !this.nativeInput.checkValidity();
128
+ }
99
129
  }
100
130
  /** Resets the formcontrol */
101
131
  async reset() {
132
+ var _a;
102
133
  this.checked = this.defaultState;
103
134
  this.customErrorText = '';
104
135
  this.customValidation = false;
105
- this.input.setCustomValidity('');
136
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.setCustomValidity('');
106
137
  this.invalid = false;
107
138
  }
108
- handleChange() {
109
- this.checked = this.input.checked;
110
- this.indeterminate = false;
111
- }
112
- handleBlur() {
113
- this.hasFocus = false;
114
- this.sixBlur.emit();
115
- }
116
- handleFocus() {
117
- this.hasFocus = true;
118
- this.sixFocus.emit();
119
- }
120
- handleMouseDown(event) {
121
- // Prevent clicks on the label from briefly blurring the input
122
- event.preventDefault();
123
- this.input.focus();
124
- }
125
- handleInvalid() {
126
- this.invalid = true;
127
- }
128
139
  handleSlotChange() {
129
140
  this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
130
141
  this.hasLabelSlot = hasSlot(this.host, 'label');
@@ -133,14 +144,14 @@ const SixCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class SixCheckbox extends
133
144
  return this.invalid && (!this.errorOnBlur || !this.hasFocus);
134
145
  }
135
146
  render() {
136
- 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: {
147
+ 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: {
137
148
  checkbox: true,
138
149
  'checkbox--checked': this.checked,
139
150
  'checkbox--disabled': this.disabled,
140
151
  'checkbox--focused': this.hasFocus,
141
152
  'checkbox--invalid': this.invalid,
142
153
  'checkbox--indeterminate': this.indeterminate,
143
- }, 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)))));
154
+ }, 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)))));
144
155
  }
145
156
  get host() { return this; }
146
157
  static get watchers() { return {
@@ -1 +1 @@
1
- {"file":"six-checkbox.js","mappings":";;;;;AAAA,MAAM,cAAc,GAAG,mnJAAmnJ;;ACM1oJ,IAAI,EAAE,GAAG,CAAC,CAAC;MAuBEA,aAAW;;;;;;;;IACtB,YAAO,GAAG,YAAY,EAAE,EAAE,EAAE,CAAC;IAC7B,YAAO,GAAG,kBAAkB,EAAE,EAAE,CAAC;IACjC,WAAM,GAAG,iBAAiB,EAAE,EAAE,CAAC;IAC/B,gBAAW,GAAG,oBAAoB,EAAE,EAAE,CAAC;IAEvC,oBAAe,GAAG,EAAE,CAAC;IACrB,qBAAgB,GAAG,KAAK,CAAC;IAEhB,mBAAc,GAAG,IAAI,cAAc,EAAE,CAAC;;IAkEvC,iBAAY,GAAG,KAAK,CAAC;oBA9DT,KAAK;wBACD,KAAK;4BACD,KAAK;;;oBASd,KAAK;oBAGL,KAAK;iBAGR,EAAE;qBAGE,EAAE;mBAG4B,KAAK;yBAGC,KAAK;mBAGX,KAAK;uBAGjC,KAAK;;EAa3B,mBAAm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SAAS,EAAC,+BAA+B,IAC1C,YAAM,CAAC,EAAC,+CAA+C,GAAQ,CAC7D,CACF,CACF,CACA,CACD,CACR,EAED,aACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC9B,EAAE,EAAE,IAAI,CAAC,OAAO,EAChB,IAAI,EAAC,UAAU,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAC,UAAU,kBACD,IAAI,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO,qBAC5B,IAAI,CAAC,OAAO,EAC7B,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,SAAS,EAAE,IAAI,CAAC,aAAa,GAC7B,CACG,EAEP,YAAM,IAAI,EAAC,MAAM,EAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAC,gBAAgB,IACvD,eAAQ,CACH,CACD,CACI,EACd;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SixCheckbox"],"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, 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.js","mappings":";;;;;AAAA,MAAM,cAAc,GAAG,mnJAAmnJ;;ACM1oJ,IAAI,EAAE,GAAG,CAAC,CAAC;MAuBEA,aAAW;;;;;;;;IACd,YAAO,GAAG,YAAY,EAAE,EAAE,EAAE,CAAC;IAC7B,YAAO,GAAG,kBAAkB,EAAE,EAAE,CAAC;IACjC,WAAM,GAAG,iBAAiB,EAAE,EAAE,CAAC;IAC/B,gBAAW,GAAG,oBAAoB,EAAE,EAAE,CAAC;IAEvC,oBAAe,GAAG,EAAE,CAAC;IACrB,qBAAgB,GAAG,KAAK,CAAC;IACzB,mBAAc,GAAG,IAAI,cAAc,EAAE,CAAC;;IAwEtC,iBAAY,GAAG,KAAK,CAAC;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AAC,WAAW,IACtB,SAAG,MAAM,EAAC,MAAM,kBAAc,GAAG,EAAC,IAAI,EAAC,MAAM,eAAW,SAAS,oBAAgB,OAAO,IACtF,SAAG,MAAM,EAAC,cAAc,kBAAc,GAAG,IACvC,SAAG,SAAS,EAAC,+BAA+B,IAC1C,YAAM,CAAC,EAAC,+CAA+C,GAAQ,CAC7D,CACF,CACF,CACA,CACD,CACR,EAED,aACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,EACpC,EAAE,EAAE,IAAI,CAAC,OAAO,EAChB,IAAI,EAAC,UAAU,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAC,UAAU,kBACD,IAAI,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO,qBAC5B,IAAI,CAAC,OAAO,EAC7B,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,GACzB,CACG,EAEP,YAAM,IAAI,EAAC,MAAM,EAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAC,gBAAgB,IACvD,eAAQ,CACH,CACD,CACI,EACd;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SixCheckbox"],"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}
@@ -22,7 +22,6 @@ const SixInput = /*@__PURE__*/ proxyCustomElement(class SixInput extends HTMLEle
22
22
  this.sixInput = createEvent(this, "six-input-input", 7);
23
23
  this.sixFocus = createEvent(this, "six-input-focus", 7);
24
24
  this.sixBlur = createEvent(this, "six-input-blur", 7);
25
- this.sixValueChange = createEvent(this, "six-input-value-change", 7);
26
25
  this.inputId = `input-${++id}`;
27
26
  this.labelId = `input-label-${id}`;
28
27
  this.helpTextId = `input-help-text-${id}`;
@@ -32,6 +31,44 @@ const SixInput = /*@__PURE__*/ proxyCustomElement(class SixInput extends HTMLEle
32
31
  this.eventListeners = new EventListeners();
33
32
  /** defaultValue which the input will be reverted to when executing reset */
34
33
  this.defaultValue = '';
34
+ this.handleChange = () => {
35
+ if (this.nativeInput != null) {
36
+ this.value = this.nativeInput.value;
37
+ this.sixChange.emit();
38
+ }
39
+ };
40
+ this.handleInput = () => {
41
+ if (this.nativeInput != null) {
42
+ this.value = this.nativeInput.value;
43
+ this.sixInput.emit();
44
+ }
45
+ };
46
+ this.handleBlur = () => {
47
+ this.hasFocus = false;
48
+ this.sixBlur.emit();
49
+ };
50
+ this.handleFocus = () => {
51
+ this.hasFocus = true;
52
+ this.sixFocus.emit();
53
+ };
54
+ this.handleClearClick = (event) => {
55
+ this.value = '';
56
+ this.sixClear.emit();
57
+ this.sixInput.emit();
58
+ this.sixChange.emit();
59
+ if (this.nativeInput != null) {
60
+ this.nativeInput.focus();
61
+ }
62
+ event.stopPropagation();
63
+ };
64
+ this.handlePasswordToggle = () => {
65
+ this.isPasswordVisible = !this.isPasswordVisible;
66
+ };
67
+ this.handleSlotChange = () => {
68
+ this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
69
+ this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
70
+ this.hasLabelSlot = hasSlot(this.host, 'label');
71
+ };
35
72
  this.hasFocus = false;
36
73
  this.hasHelpTextSlot = false;
37
74
  this.hasErrorTextSlot = false;
@@ -54,12 +91,12 @@ const SixInput = /*@__PURE__*/ proxyCustomElement(class SixInput extends HTMLEle
54
91
  this.max = undefined;
55
92
  this.step = undefined;
56
93
  this.pattern = undefined;
57
- this.required = undefined;
58
- this.autocapitalize = undefined;
59
- this.autocorrect = undefined;
60
- this.autocomplete = undefined;
61
- this.autofocus = undefined;
62
- this.spellcheck = undefined;
94
+ this.required = false;
95
+ this.autocapitalize = 'off';
96
+ this.autocorrect = 'off';
97
+ this.autocomplete = 'off';
98
+ this.autofocus = false;
99
+ this.spellcheck = false;
63
100
  this.invalid = false;
64
101
  this.clearable = false;
65
102
  this.togglePassword = false;
@@ -71,141 +108,130 @@ const SixInput = /*@__PURE__*/ proxyCustomElement(class SixInput extends HTMLEle
71
108
  this.handleSlotChange();
72
109
  }
73
110
  handleValueChange() {
74
- if (!this.input) {
75
- return;
111
+ this.value = this.getValue();
112
+ if (this.nativeInput != null) {
113
+ if (this.nativeInput.value !== this.value) {
114
+ this.nativeInput.value = this.value;
115
+ }
116
+ this.invalid = !this.nativeInput.checkValidity();
76
117
  }
77
- this.input.value = this.value;
78
- this.invalid = !this.input.checkValidity();
79
- this.sixValueChange.emit();
80
118
  }
81
119
  connectedCallback() {
82
- this.handleChange = this.handleChange.bind(this);
83
- this.handleInput = this.handleInput.bind(this);
84
- this.handleInvalid = this.handleInvalid.bind(this);
85
- this.handleBlur = this.handleBlur.bind(this);
86
- this.handleFocus = this.handleFocus.bind(this);
87
- this.handleClearClick = this.handleClearClick.bind(this);
88
- this.handlePasswordToggle = this.handlePasswordToggle.bind(this);
89
- this.handleSlotChange = this.handleSlotChange.bind(this);
90
- this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);
120
+ var _a;
121
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener('slotchange', this.handleSlotChange);
91
122
  }
92
123
  componentWillLoad() {
93
- this.defaultValue = this.value;
124
+ this.defaultValue = this.getValue();
94
125
  this.handleSlotChange();
95
126
  }
96
127
  componentDidLoad() {
97
- this.eventListeners.add(this.input, 'invalid', (event) => {
98
- if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {
99
- this.customErrorText = this.input.validationMessage;
128
+ const nativeInput = this.nativeInput;
129
+ if (nativeInput == null) {
130
+ return;
131
+ }
132
+ this.eventListeners.add(nativeInput, 'invalid', (event) => {
133
+ this.invalid = true;
134
+ if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {
135
+ this.customErrorText = nativeInput.validationMessage;
100
136
  }
101
137
  event.preventDefault();
102
138
  });
103
139
  }
104
140
  disconnectedCallback() {
105
- this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);
141
+ var _a;
142
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeEventListener('slotchange', this.handleSlotChange);
106
143
  this.eventListeners.removeAll();
107
144
  }
108
145
  /** Sets focus on the input. */
109
146
  async setFocus(options) {
110
- this.input.focus(options);
147
+ var _a;
148
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus(options);
111
149
  }
112
150
  /** Removes focus from the input. */
113
151
  async removeFocus() {
114
- this.input.blur();
152
+ var _a;
153
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.blur();
115
154
  }
116
155
  /** Selects all the text in the input. */
117
156
  async select() {
118
- return this.input.select();
157
+ var _a;
158
+ return (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.select();
119
159
  }
120
160
  /** Sets the start and end positions of the text selection (0-based). */
121
161
  async setSelectionRange(selectionStart, selectionEnd, selectionDirection = 'none') {
122
- return this.input.setSelectionRange(selectionStart, selectionEnd, selectionDirection);
162
+ var _a;
163
+ return (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.setSelectionRange(selectionStart, selectionEnd, selectionDirection);
123
164
  }
124
165
  /** Replaces a range of text with a new string. */
125
166
  async setRangeText(replacement, start, end, selectMode = 'preserve') {
126
- this.input.setRangeText(replacement, start, end, selectMode);
127
- if (this.value !== this.input.value) {
128
- this.value = this.input.value;
167
+ if (this.nativeInput == null) {
168
+ return;
169
+ }
170
+ this.nativeInput.setRangeText(replacement, start, end, selectMode);
171
+ if (this.getValue() !== this.nativeInput.value) {
172
+ this.value = this.nativeInput.value;
129
173
  this.sixChange.emit();
130
174
  this.sixInput.emit();
131
175
  }
132
176
  }
133
177
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
134
178
  async reportValidity() {
135
- return this.input.reportValidity();
179
+ var _a;
180
+ return (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.reportValidity();
136
181
  }
137
182
  /** Checks for validity. */
138
183
  async checkValidity() {
139
- return this.input.validity.valid;
184
+ if (this.nativeInput == null) {
185
+ return true;
186
+ }
187
+ return this.nativeInput.validity.valid;
140
188
  }
141
189
  /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
142
190
  async setCustomValidity(message) {
143
191
  this.customErrorText = '';
144
192
  this.customValidation = message !== '';
145
- this.input.setCustomValidity(message);
146
- this.invalid = !this.input.checkValidity();
193
+ if (this.nativeInput != null) {
194
+ this.nativeInput.setCustomValidity(message);
195
+ this.invalid = !this.nativeInput.checkValidity();
196
+ }
147
197
  }
148
198
  /** Returns the native input's validity */
149
199
  async getValidity() {
150
- return this.input.validity;
200
+ var _a;
201
+ return (_a = this === null || this === void 0 ? void 0 : this.nativeInput) === null || _a === void 0 ? void 0 : _a.validity;
151
202
  }
152
203
  /** Returns the native input's validity */
153
204
  async isValid() {
154
- return this.input.validity.valid;
205
+ if (this.nativeInput == null) {
206
+ return true;
207
+ }
208
+ return this.nativeInput.validity.valid;
155
209
  }
156
210
  /** Returns the native input's validationMessage */
157
211
  async getValidationMessage() {
158
- return this.input.validationMessage;
212
+ if (this.nativeInput == null) {
213
+ return '';
214
+ }
215
+ return this.nativeInput.validationMessage;
159
216
  }
160
217
  /** Resets the formcontrol */
161
218
  async reset() {
219
+ var _a;
162
220
  this.value = this.defaultValue;
163
221
  this.customErrorText = '';
164
222
  this.customValidation = false;
165
- this.input.setCustomValidity('');
223
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.setCustomValidity('');
166
224
  this.invalid = false;
167
225
  }
168
- handleChange() {
169
- this.value = this.input.value;
170
- this.sixChange.emit();
171
- }
172
- handleInput() {
173
- this.value = this.input.value;
174
- this.sixInput.emit();
175
- }
176
- handleInvalid() {
177
- this.invalid = true;
178
- }
179
- handleBlur() {
180
- this.hasFocus = false;
181
- this.sixBlur.emit();
182
- }
183
- handleFocus() {
184
- this.hasFocus = true;
185
- this.sixFocus.emit();
186
- }
187
- handleClearClick(event) {
188
- this.value = '';
189
- this.sixClear.emit();
190
- this.sixInput.emit();
191
- this.sixChange.emit();
192
- this.input.focus();
193
- event.stopPropagation();
194
- }
195
- handlePasswordToggle() {
196
- this.isPasswordVisible = !this.isPasswordVisible;
197
- }
198
- handleSlotChange() {
199
- this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
200
- this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
201
- this.hasLabelSlot = hasSlot(this.host, 'label');
202
- }
203
226
  displayError() {
204
227
  return this.invalid && (!this.errorOnBlur || !this.hasFocus);
205
228
  }
206
- render() {
229
+ getValue() {
207
230
  var _a;
208
- return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, errorTextId: this.errorTextId, errorText: this.customErrorText ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, size: this.size, disabled: this.disabled, required: this.required, displayError: this.displayError() }, h("div", { part: "base", class: {
231
+ return ((_a = this.value) !== null && _a !== void 0 ? _a : '').toString();
232
+ }
233
+ render() {
234
+ return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, errorTextId: this.errorTextId, errorText: this.customErrorText != null ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, size: this.size, disabled: this.disabled, required: this.required, displayError: this.displayError() }, h("div", { part: "base", class: {
209
235
  input: true,
210
236
  // Sizes
211
237
  'input--small': this.size === 'small',
@@ -216,12 +242,12 @@ const SixInput = /*@__PURE__*/ proxyCustomElement(class SixInput extends HTMLEle
216
242
  'input--pill': this.pill,
217
243
  'input--disabled': this.disabled,
218
244
  'input--focused': this.hasFocus,
219
- 'input--empty': ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) === 0,
245
+ 'input--empty': this.getValue().length === 0,
220
246
  'input--invalid': this.invalid,
221
- } }, h("span", { part: "prefix", class: "input__prefix" }, h("slot", { name: "prefix" })), h("input", { part: "input", ref: (el) => (this.input = el), id: this.inputId, size: 1, class: {
247
+ } }, h("span", { part: "prefix", class: "input__prefix" }, h("slot", { name: "prefix" })), h("input", { part: "input", ref: (el) => (this.nativeInput = el), id: this.inputId, size: 1, class: {
222
248
  input__control: true,
223
249
  input__control__prefix: hasSlot(this.host, 'prefix'),
224
- }, type: this.type === 'password' && this.isPasswordVisible ? 'text' : this.type, name: this.name, placeholder: this.placeholder, disabled: this.disabled, readonly: this.readonly, minLength: this.minlength, maxLength: this.maxlength, min: this.min, max: this.max, step: this.step, value: this.value, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, spellcheck: this.spellcheck, pattern: this.pattern, required: this.required, inputMode: this.inputmode, "aria-labelledby": this.labelId, "aria-describedby": this.helpTextId, "aria-invalid": this.invalid ? 'true' : 'false', onChange: this.handleChange, onInput: this.handleInput, onInvalid: this.handleInvalid, onFocus: this.handleFocus, onBlur: this.handleBlur, "data-testid": "input-control" }), this.clearable && (h("button", { part: "clear-button", class: "input__clear", type: "button", onClick: this.handleClearClick, tabindex: "-1", "data-testid": "input-clear-button" }, h("slot", { name: "clear-icon" }, h("six-icon", { size: ICON_SIZES[this.size] }, "clear")))), this.togglePassword && (h("button", { part: "password-toggle-button", class: "input__password-toggle", type: "button", onClick: this.handlePasswordToggle, tabindex: "-1" }, this.isPasswordVisible ? (h("slot", { name: "show-password-icon" }, h("six-icon", { size: ICON_SIZES[this.size] }, "visibility_off"))) : (h("slot", { name: "hide-password-icon" }, h("six-icon", { size: ICON_SIZES[this.size] }, "visibility"))))), h("span", { part: "suffix", class: "input__suffix" }, h("slot", { name: "suffix" })))));
250
+ }, type: this.type === 'password' && this.isPasswordVisible ? 'text' : this.type, name: this.name, placeholder: this.placeholder, disabled: this.disabled, readonly: this.readonly, minLength: this.minlength, maxLength: this.maxlength, min: this.min, max: this.max, step: this.step, value: this.getValue(), autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, spellcheck: this.spellcheck, pattern: this.pattern, required: this.required, inputMode: this.inputmode, "aria-labelledby": this.labelId, "aria-describedby": this.helpTextId, "aria-invalid": this.invalid ? 'true' : 'false', onChange: this.handleChange, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, "data-testid": "input-control" }), this.clearable && (h("button", { part: "clear-button", class: "input__clear", type: "button", onClick: this.handleClearClick, tabindex: "-1", "data-testid": "input-clear-button" }, h("slot", { name: "clear-icon" }, h("six-icon", { size: ICON_SIZES[this.size] }, "clear")))), this.togglePassword && (h("button", { part: "password-toggle-button", class: "input__password-toggle", type: "button", onClick: this.handlePasswordToggle, tabindex: "-1" }, this.isPasswordVisible ? (h("slot", { name: "show-password-icon" }, h("six-icon", { size: ICON_SIZES[this.size] }, "visibility_off"))) : (h("slot", { name: "hide-password-icon" }, h("six-icon", { size: ICON_SIZES[this.size] }, "visibility"))))), h("span", { part: "suffix", class: "input__suffix" }, h("slot", { name: "suffix" })))));
225
251
  }
226
252
  get host() { return this; }
227
253
  static get watchers() { return {