@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
@@ -30,6 +30,32 @@ export class SixTextarea {
30
30
  this.eventListeners = new EventListeners();
31
31
  /** default value the textarea will be reverted to when reset is executed */
32
32
  this.defaultValue = '';
33
+ this.handleChange = () => {
34
+ if (this.nativeTextarea != null) {
35
+ this.value = this.nativeTextarea.value;
36
+ this.sixChange.emit();
37
+ }
38
+ };
39
+ this.handleInput = () => {
40
+ if (this.nativeTextarea != null) {
41
+ this.value = this.nativeTextarea.value;
42
+ this.setTextareaHeight(this.nativeTextarea);
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.handleSlotChange = () => {
55
+ this.hasLabelSlot = hasSlot(this.host, 'label');
56
+ this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
57
+ this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
58
+ };
33
59
  this.hasFocus = false;
34
60
  this.hasHelpTextSlot = false;
35
61
  this.hasErrorTextSlot = false;
@@ -47,13 +73,13 @@ export class SixTextarea {
47
73
  this.readonly = false;
48
74
  this.minlength = undefined;
49
75
  this.maxlength = undefined;
50
- this.required = undefined;
76
+ this.required = false;
51
77
  this.invalid = false;
52
- this.autocapitalize = undefined;
53
- this.autocorrect = undefined;
54
- this.autocomplete = undefined;
55
- this.autofocus = undefined;
56
- this.spellcheck = undefined;
78
+ this.autocapitalize = 'off';
79
+ this.autocorrect = 'off';
80
+ this.autocomplete = 'off';
81
+ this.autofocus = false;
82
+ this.spellcheck = false;
57
83
  this.inputmode = undefined;
58
84
  this.errorOnBlur = false;
59
85
  }
@@ -61,135 +87,133 @@ export class SixTextarea {
61
87
  this.handleSlotChange();
62
88
  }
63
89
  handleRowsChange() {
64
- if (this.textarea) {
65
- this.setTextareaHeight();
90
+ if (this.nativeTextarea != null) {
91
+ this.setTextareaHeight(this.nativeTextarea);
66
92
  }
67
93
  }
68
94
  handleValueChange() {
69
- if (!this.textarea) {
70
- return;
95
+ this.value = this.getValue();
96
+ if (this.nativeTextarea != null) {
97
+ if (this.nativeTextarea.value !== this.value) {
98
+ this.nativeTextarea.value = this.value;
99
+ }
100
+ this.invalid = !this.nativeTextarea.checkValidity();
71
101
  }
72
- this.textarea.value = this.value;
73
- this.invalid = !this.textarea.checkValidity();
74
- this.sixValueChange.emit();
75
102
  }
76
103
  connectedCallback() {
77
- this.handleChange = this.handleChange.bind(this);
78
- this.handleInput = this.handleInput.bind(this);
79
- this.handleInvalid = this.handleInvalid.bind(this);
80
- this.handleBlur = this.handleBlur.bind(this);
81
- this.handleFocus = this.handleFocus.bind(this);
82
- this.handleSlotChange = this.handleSlotChange.bind(this);
83
- this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);
104
+ var _a;
105
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener('slotchange', this.handleSlotChange);
84
106
  }
85
107
  componentWillLoad() {
86
108
  this.defaultValue = this.value || '';
87
109
  this.handleSlotChange();
88
110
  }
89
111
  componentDidLoad() {
90
- this.setTextareaHeight();
91
- this.resizeObserver = new ResizeObserver(() => this.setTextareaHeight());
92
- this.resizeObserver.observe(this.textarea);
93
- this.eventListeners.add(this.textarea, 'invalid', (event) => {
94
- if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {
95
- this.customErrorText = this.textarea.validationMessage;
112
+ const nativeTextarea = this.nativeTextarea;
113
+ if (nativeTextarea == null) {
114
+ return;
115
+ }
116
+ this.setTextareaHeight(nativeTextarea);
117
+ this.resizeObserver = new ResizeObserver(() => this.setTextareaHeight(nativeTextarea));
118
+ this.resizeObserver.observe(nativeTextarea);
119
+ this.eventListeners.add(nativeTextarea, 'invalid', (event) => {
120
+ this.invalid = true;
121
+ if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {
122
+ this.customErrorText = nativeTextarea.validationMessage;
96
123
  }
97
124
  event.preventDefault();
98
125
  });
99
126
  }
100
127
  disconnectedCallback() {
101
- this.resizeObserver.unobserve(this.textarea);
102
- this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);
128
+ var _a, _b;
129
+ if (this.nativeTextarea != null) {
130
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.unobserve(this.nativeTextarea);
131
+ }
132
+ (_b = this.host.shadowRoot) === null || _b === void 0 ? void 0 : _b.removeEventListener('slotchange', this.handleSlotChange);
103
133
  this.eventListeners.removeAll();
104
134
  }
105
135
  /** Sets focus on the textarea. */
106
136
  async setFocus(options) {
107
- this.textarea.focus(options);
137
+ var _a;
138
+ (_a = this.nativeTextarea) === null || _a === void 0 ? void 0 : _a.focus(options);
108
139
  }
109
140
  /** Removes focus fromt the textarea. */
110
141
  async removeFocus() {
111
- this.textarea.blur();
142
+ var _a;
143
+ (_a = this.nativeTextarea) === null || _a === void 0 ? void 0 : _a.blur();
112
144
  }
113
145
  /** Selects all the text in the input. */
114
146
  async select() {
115
- return this.textarea.select();
147
+ var _a;
148
+ return (_a = this.nativeTextarea) === null || _a === void 0 ? void 0 : _a.select();
116
149
  }
117
150
  /** Sets the start and end positions of the text selection (0-based). */
118
151
  async setSelectionRange(selectionStart, selectionEnd, selectionDirection = 'none') {
119
- return this.textarea.setSelectionRange(selectionStart, selectionEnd, selectionDirection);
152
+ var _a;
153
+ return (_a = this.nativeTextarea) === null || _a === void 0 ? void 0 : _a.setSelectionRange(selectionStart, selectionEnd, selectionDirection);
120
154
  }
121
155
  /** Replaces a range of text with a new string. */
122
156
  async setRangeText(replacement, start, end, selectMode = 'preserve') {
123
- this.textarea.setRangeText(replacement, start, end, selectMode);
124
- if (this.value !== this.textarea.value) {
125
- this.value = this.textarea.value;
126
- this.setTextareaHeight();
157
+ if (this.nativeTextarea == null) {
158
+ return;
159
+ }
160
+ this.nativeTextarea.setRangeText(replacement, start, end, selectMode);
161
+ if (this.getValue() !== this.nativeTextarea.value) {
162
+ this.value = this.nativeTextarea.value;
163
+ this.setTextareaHeight(this.nativeTextarea);
127
164
  this.sixChange.emit();
128
165
  this.sixInput.emit();
129
166
  }
130
167
  }
131
168
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
132
169
  async reportValidity() {
133
- return this.textarea.reportValidity();
170
+ var _a;
171
+ return (_a = this.nativeTextarea) === null || _a === void 0 ? void 0 : _a.reportValidity();
134
172
  }
135
173
  /** Checks for validity. */
136
174
  async checkValidity() {
137
- return this.textarea.validity.valid;
175
+ if (this.nativeTextarea == null) {
176
+ return true;
177
+ }
178
+ return this.nativeTextarea.validity.valid;
138
179
  }
139
180
  /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
140
181
  async setCustomValidity(message) {
141
182
  this.customErrorText = '';
142
183
  this.customValidation = message !== '';
143
- this.textarea.setCustomValidity(message);
144
- this.invalid = !this.textarea.checkValidity();
184
+ if (this.nativeTextarea != null) {
185
+ this.nativeTextarea.setCustomValidity(message);
186
+ this.invalid = !this.nativeTextarea.checkValidity();
187
+ }
145
188
  }
146
189
  /** Resets the formcontrol */
147
190
  async reset() {
191
+ var _a;
148
192
  this.value = this.defaultValue;
149
193
  this.customErrorText = '';
150
194
  this.customValidation = false;
151
- this.textarea.setCustomValidity('');
195
+ (_a = this.nativeTextarea) === null || _a === void 0 ? void 0 : _a.setCustomValidity('');
152
196
  this.invalid = false;
153
197
  }
154
- handleChange() {
155
- this.sixChange.emit();
156
- }
157
- handleInput() {
158
- this.value = this.textarea.value;
159
- this.setTextareaHeight();
160
- this.sixInput.emit();
161
- }
162
- handleInvalid() {
163
- this.invalid = true;
164
- }
165
- handleBlur() {
166
- this.hasFocus = false;
167
- this.sixBlur.emit();
168
- }
169
- handleFocus() {
170
- this.hasFocus = true;
171
- this.sixFocus.emit();
172
- }
173
- handleSlotChange() {
174
- this.hasLabelSlot = hasSlot(this.host, 'label');
175
- this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
176
- this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
177
- }
178
- setTextareaHeight() {
198
+ setTextareaHeight(nativeTextarea) {
179
199
  if (this.resize === 'auto') {
180
- this.textarea.style.height = 'auto';
181
- this.textarea.style.height = this.textarea.scrollHeight + 'px';
200
+ nativeTextarea.style.height = 'auto';
201
+ const height = nativeTextarea.scrollHeight + 1;
202
+ nativeTextarea.style.height = height + 'px';
182
203
  }
183
204
  else {
184
- this.textarea.style.height = undefined;
205
+ nativeTextarea.style.height = '';
185
206
  }
186
207
  }
187
208
  displayError() {
188
209
  return this.invalid && (!this.errorOnBlur || !this.hasFocus);
189
210
  }
190
- render() {
211
+ getValue() {
191
212
  var _a;
192
- 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: {
213
+ return ((_a = this.value) !== null && _a !== void 0 ? _a : '').toString();
214
+ }
215
+ render() {
216
+ 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: {
193
217
  textarea: true,
194
218
  // Sizes
195
219
  'textarea--small': this.size === 'small',
@@ -198,13 +222,13 @@ export class SixTextarea {
198
222
  // States
199
223
  'textarea--disabled': this.disabled,
200
224
  'textarea--focused': this.hasFocus,
201
- 'textarea--empty': ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) === 0,
225
+ 'textarea--empty': this.getValue().length === 0,
202
226
  'textarea--invalid': this.invalid,
203
227
  // Modifiers
204
228
  'textarea--resize-none': this.resize === 'none',
205
229
  'textarea--resize-vertical': this.resize === 'vertical',
206
230
  'textarea--resize-auto': this.resize === 'auto',
207
- } }, h("textarea", { part: "textarea", ref: (el) => (this.textarea = el), id: this.inputId, class: "textarea__control", name: this.name, placeholder: this.placeholder, disabled: this.disabled, readOnly: this.readonly, rows: this.rows, minLength: this.minlength, maxLength: this.maxlength, value: this.value, autoCapitalize: this.autocapitalize, autoCorrect: this.autocorrect, autoFocus: this.autofocus, spellcheck: this.spellcheck, required: this.required, inputMode: this.inputmode, "aria-labelledby": this.labelId, onChange: this.handleChange, onInput: this.handleInput, onInvalid: this.handleInvalid, onFocus: this.handleFocus, onBlur: this.handleBlur }))));
231
+ } }, h("textarea", { part: "textarea", ref: (el) => (this.nativeTextarea = el), id: this.inputId, class: "textarea__control", name: this.name, placeholder: this.placeholder, disabled: this.disabled, readOnly: this.readonly, rows: this.rows, minLength: this.minlength, maxLength: this.maxlength, value: this.getValue(), autoCapitalize: this.autocapitalize, autoCorrect: this.autocorrect, autoFocus: this.autofocus, spellcheck: this.spellcheck, required: this.required, inputMode: this.inputmode, "aria-labelledby": this.labelId, onChange: this.handleChange, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur }))));
208
232
  }
209
233
  static get is() { return "six-textarea"; }
210
234
  static get encapsulation() { return "shadow"; }
@@ -337,7 +361,7 @@ export class SixTextarea {
337
361
  "references": {}
338
362
  },
339
363
  "required": false,
340
- "optional": false,
364
+ "optional": true,
341
365
  "docs": {
342
366
  "tags": [],
343
367
  "text": "The textarea's placeholder text."
@@ -426,7 +450,7 @@ export class SixTextarea {
426
450
  "references": {}
427
451
  },
428
452
  "required": false,
429
- "optional": false,
453
+ "optional": true,
430
454
  "docs": {
431
455
  "tags": [],
432
456
  "text": "The minimum length of input that will be considered valid."
@@ -443,7 +467,7 @@ export class SixTextarea {
443
467
  "references": {}
444
468
  },
445
469
  "required": false,
446
- "optional": false,
470
+ "optional": true,
447
471
  "docs": {
448
472
  "tags": [],
449
473
  "text": "The maximum length of input that will be considered valid."
@@ -466,7 +490,8 @@ export class SixTextarea {
466
490
  "text": "The textarea's required attribute."
467
491
  },
468
492
  "attribute": "required",
469
- "reflect": true
493
+ "reflect": true,
494
+ "defaultValue": "false"
470
495
  },
471
496
  "invalid": {
472
497
  "type": "boolean",
@@ -501,14 +526,15 @@ export class SixTextarea {
501
526
  "text": "The textarea's autocaptialize attribute."
502
527
  },
503
528
  "attribute": "autocapitalize",
504
- "reflect": false
529
+ "reflect": false,
530
+ "defaultValue": "'off'"
505
531
  },
506
532
  "autocorrect": {
507
533
  "type": "string",
508
534
  "mutable": false,
509
535
  "complexType": {
510
- "original": "string",
511
- "resolved": "string",
536
+ "original": "'on' | 'off'",
537
+ "resolved": "\"off\" | \"on\"",
512
538
  "references": {}
513
539
  },
514
540
  "required": false,
@@ -518,7 +544,8 @@ export class SixTextarea {
518
544
  "text": "The textarea's autocorrect attribute."
519
545
  },
520
546
  "attribute": "autocorrect",
521
- "reflect": false
547
+ "reflect": false,
548
+ "defaultValue": "'off'"
522
549
  },
523
550
  "autocomplete": {
524
551
  "type": "string",
@@ -535,7 +562,8 @@ export class SixTextarea {
535
562
  "text": "The textarea's autocomplete attribute."
536
563
  },
537
564
  "attribute": "autocomplete",
538
- "reflect": false
565
+ "reflect": false,
566
+ "defaultValue": "'off'"
539
567
  },
540
568
  "autofocus": {
541
569
  "type": "boolean",
@@ -552,7 +580,8 @@ export class SixTextarea {
552
580
  "text": "The textarea's autofocus attribute."
553
581
  },
554
582
  "attribute": "autofocus",
555
- "reflect": false
583
+ "reflect": false,
584
+ "defaultValue": "false"
556
585
  },
557
586
  "spellcheck": {
558
587
  "type": "boolean",
@@ -569,7 +598,8 @@ export class SixTextarea {
569
598
  "text": "The textarea's spellcheck attribute."
570
599
  },
571
600
  "attribute": "spellcheck",
572
- "reflect": false
601
+ "reflect": false,
602
+ "defaultValue": "false"
573
603
  },
574
604
  "inputmode": {
575
605
  "type": "string",
@@ -580,7 +610,7 @@ export class SixTextarea {
580
610
  "references": {}
581
611
  },
582
612
  "required": false,
583
- "optional": false,
613
+ "optional": true,
584
614
  "docs": {
585
615
  "tags": [],
586
616
  "text": "The textarea's inputmode attribute."
@@ -697,26 +727,6 @@ export class SixTextarea {
697
727
  }
698
728
  }
699
729
  }
700
- }, {
701
- "method": "sixValueChange",
702
- "name": "six-textarea-value-change",
703
- "bubbles": true,
704
- "cancelable": true,
705
- "composed": true,
706
- "docs": {
707
- "tags": [],
708
- "text": "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."
709
- },
710
- "complexType": {
711
- "original": "EmptyPayload",
712
- "resolved": "undefined",
713
- "references": {
714
- "EmptyPayload": {
715
- "location": "import",
716
- "path": "../../utils/types"
717
- }
718
- }
719
- }
720
730
  }];
721
731
  }
722
732
  static get methods() {
@@ -1 +1 @@
1
- {"version":3,"file":"six-textarea.js","sourceRoot":"","sources":["../../../src/components/six-textarea/six-textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,WAAW,MAAM,uDAAuD,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,IAAI,EAAE,GAAG,CAAC,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AAMH,MAAM,OAAO,WAAW;;IACtB,YAAO,GAAG,YAAY,EAAE,EAAE,EAAE,CAAC;IAC7B,YAAO,GAAG,kBAAkB,EAAE,EAAE,CAAC;IACjC,eAAU,GAAG,sBAAsB,EAAE,EAAE,CAAC;IACxC,gBAAW,GAAG,oBAAoB,EAAE,EAAE,CAAC;IAGvC,oBAAe,GAAG,EAAE,CAAC;IACrB,qBAAgB,GAAG,KAAK,CAAC;IAEhB,mBAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IA4H/C,4EAA4E;IACpE,iBAAY,GAAG,EAAE,CAAC;oBAzHN,KAAK;2BACE,KAAK;4BACJ,KAAK;wBACT,KAAK;gBAGiC,QAAQ;gBAGtC,EAAE;iBAGc,EAAE;iBAGlC,EAAE;oBAGC,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S,EAAE,IAAI,CAAC,aAAa,EAC7B,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,GACvB,CACE,CACM,CACf,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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 { EventListeners } from '../../utils/event-listeners';\nimport { EmptyPayload } from '../../utils/types';\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 textarea's label. Alternatively, you can use the label prop.\n * @slot help-text - Help text that describes how to use the input.\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 form-control - The form control that wraps the label, textarea, and help text.\n * @part label - The textarea label.\n * @part textarea - The textarea control.\n * @part help-text - The textarea help text.\n */\n@Component({\n tag: 'six-textarea',\n styleUrl: 'six-textarea.scss',\n shadow: true,\n})\nexport class SixTextarea {\n inputId = `textarea-${++id}`;\n labelId = `textarea-label-${id}`;\n helpTextId = `textarea-help-text-${id}`;\n errorTextId = `input-error-text-${id}`;\n resizeObserver: ResizeObserver;\n textarea: HTMLTextAreaElement;\n customErrorText = '';\n customValidation = false;\n\n readonly eventListeners = new EventListeners();\n\n @Element() host: HTMLSixTextareaElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasErrorTextSlot = false;\n @State() hasLabelSlot = false;\n\n /** The textarea's size. */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** The textarea's name attribute. */\n @Prop({ reflect: true }) name = '';\n\n /** The textarea's value attribute. */\n @Prop({ mutable: true, reflect: true }) value = '';\n\n /** The textarea's label. Alternatively, you can use the label slot. */\n @Prop() label = '';\n\n /** The textarea's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** The textarea's error text. Alternatively, you can use the error-text slot. */\n @Prop() errorText = '';\n\n /** The textarea's placeholder text. */\n @Prop() placeholder: string;\n\n /** The number of rows to display by default. */\n @Prop() rows = 4;\n\n /** Controls how the textarea can be resized. */\n @Prop() resize: 'none' | 'vertical' | 'auto' = 'vertical';\n\n /** Set to true to disable the textarea. */\n @Prop({ reflect: true }) disabled = false;\n\n /** Set to true for a readonly textarea. */\n @Prop({ reflect: true }) readonly = false;\n\n /** The minimum length of input that will be considered valid. */\n @Prop({ reflect: true }) minlength: number;\n\n /** The maximum length of input that will be considered valid. */\n @Prop({ reflect: true }) maxlength: number;\n\n /** The textarea's required attribute. */\n @Prop({ reflect: true }) required: boolean;\n\n /**\n * This will be true when the control is in an invalid state. Validity is determined by props such as `required`,\n * `minlength`, and `maxlength` using the browser's constraint validation API.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** The textarea's autocaptialize attribute. */\n @Prop() autocapitalize: string;\n\n /** The textarea's autocorrect attribute. */\n @Prop() autocorrect: string;\n\n /** The textarea's autocomplete attribute. */\n @Prop() autocomplete: string;\n\n /** The textarea's autofocus attribute. */\n @Prop() autofocus: boolean;\n\n /** The textarea's spellcheck attribute. */\n @Prop() spellcheck: boolean;\n\n /** The textarea's inputmode attribute. */\n @Prop() inputmode: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';\n\n /** Set to display the error text on blur and not when typing */\n @Prop() errorOnBlur = false;\n\n /** Emitted when the control's value changes. Access the new value via event.target.value. */\n @Event({ eventName: 'six-textarea-change' }) sixChange: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control receives input. Access the new value via event.target.value. */\n @Event({ eventName: 'six-textarea-input' }) sixInput: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-textarea-focus' }) sixFocus: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. Access the new value via event.target.value. */\n @Event({ eventName: 'six-textarea-blur' }) sixBlur: EventEmitter<EmptyPayload>;\n\n /**\n * Emitted whenever the value changes. Access the new value via event.target.value.\n * six-textarea-value-change will emit whenever the value changes.\n * So be it on textarea or when dynamically set. six-textarea-input will only be emitted when the user enters data,\n * but not when a value is dynamically set. six-textarea-change will only be emitted when the user either presses enter\n * or leaves the textarea field after entering some data.\n * */\n\n @Event({ eventName: 'six-textarea-value-change' }) sixValueChange: EventEmitter<EmptyPayload>;\n\n @Watch('helpText')\n @Watch('errorText')\n @Watch('label')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('rows')\n handleRowsChange() {\n if (this.textarea) {\n this.setTextareaHeight();\n }\n }\n\n @Watch('value')\n handleValueChange() {\n if (!this.textarea) {\n return;\n }\n this.textarea.value = this.value;\n this.invalid = !this.textarea.checkValidity();\n this.sixValueChange.emit();\n }\n\n /** default value the textarea will be reverted to when reset is executed */\n private defaultValue = '';\n\n connectedCallback() {\n this.handleChange = this.handleChange.bind(this);\n this.handleInput = this.handleInput.bind(this);\n this.handleInvalid = this.handleInvalid.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.handleSlotChange = this.handleSlotChange.bind(this);\n\n this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);\n }\n\n componentWillLoad() {\n this.defaultValue = this.value || '';\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n this.setTextareaHeight();\n this.resizeObserver = new ResizeObserver(() => this.setTextareaHeight());\n this.resizeObserver.observe(this.textarea);\n this.eventListeners.add(this.textarea, 'invalid', (event) => {\n if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {\n this.customErrorText = this.textarea.validationMessage;\n }\n event.preventDefault();\n });\n }\n\n disconnectedCallback() {\n this.resizeObserver.unobserve(this.textarea);\n this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the textarea. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.textarea.focus(options);\n }\n\n /** Removes focus fromt the textarea. */\n @Method()\n async removeFocus() {\n this.textarea.blur();\n }\n\n /** Selects all the text in the input. */\n @Method()\n async select() {\n return this.textarea.select();\n }\n\n /** Sets the start and end positions of the text selection (0-based). */\n @Method()\n async setSelectionRange(\n selectionStart: number,\n selectionEnd: number,\n selectionDirection: 'forward' | 'backward' | 'none' = 'none'\n ) {\n return this.textarea.setSelectionRange(selectionStart, selectionEnd, selectionDirection);\n }\n\n /** Replaces a range of text with a new string. */\n @Method()\n async setRangeText(\n replacement: string,\n start: number,\n end: number,\n selectMode: 'select' | 'start' | 'end' | 'preserve' = 'preserve'\n ) {\n this.textarea.setRangeText(replacement, start, end, selectMode);\n\n if (this.value !== this.textarea.value) {\n this.value = this.textarea.value;\n this.setTextareaHeight();\n this.sixChange.emit();\n this.sixInput.emit();\n }\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.textarea.reportValidity();\n }\n\n /** Checks for validity. */\n @Method()\n async checkValidity() {\n return this.textarea.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.textarea.setCustomValidity(message);\n this.invalid = !this.textarea.checkValidity();\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.value = this.defaultValue;\n this.customErrorText = '';\n this.customValidation = false;\n this.textarea.setCustomValidity('');\n this.invalid = false;\n }\n\n handleChange() {\n this.sixChange.emit();\n }\n\n handleInput() {\n this.value = this.textarea.value;\n this.setTextareaHeight();\n this.sixInput.emit();\n }\n\n handleInvalid() {\n this.invalid = true;\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 handleSlotChange() {\n this.hasLabelSlot = hasSlot(this.host, 'label');\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n }\n\n setTextareaHeight() {\n if (this.resize === 'auto') {\n this.textarea.style.height = 'auto';\n this.textarea.style.height = this.textarea.scrollHeight + 'px';\n } else {\n this.textarea.style.height = undefined;\n }\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 helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n errorTextId={this.errorTextId}\n errorText={this.customErrorText ? this.customErrorText : this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n size={this.size}\n disabled={this.disabled}\n required={this.required}\n displayError={this.displayError()}\n >\n <div\n part=\"base\"\n class={{\n textarea: true,\n\n // Sizes\n 'textarea--small': this.size === 'small',\n 'textarea--medium': this.size === 'medium',\n 'textarea--large': this.size === 'large',\n\n // States\n 'textarea--disabled': this.disabled,\n 'textarea--focused': this.hasFocus,\n 'textarea--empty': this.value?.length === 0,\n 'textarea--invalid': this.invalid,\n\n // Modifiers\n 'textarea--resize-none': this.resize === 'none',\n 'textarea--resize-vertical': this.resize === 'vertical',\n 'textarea--resize-auto': this.resize === 'auto',\n }}\n >\n <textarea\n part=\"textarea\"\n ref={(el) => (this.textarea = el)}\n id={this.inputId}\n class=\"textarea__control\"\n name={this.name}\n placeholder={this.placeholder}\n disabled={this.disabled}\n readOnly={this.readonly}\n rows={this.rows}\n minLength={this.minlength}\n maxLength={this.maxlength}\n value={this.value}\n autoCapitalize={this.autocapitalize}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n spellcheck={this.spellcheck}\n required={this.required}\n inputMode={this.inputmode}\n aria-labelledby={this.labelId}\n onChange={this.handleChange}\n onInput={this.handleInput}\n onInvalid={this.handleInvalid}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n </div>\n </FormControl>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"six-textarea.js","sourceRoot":"","sources":["../../../src/components/six-textarea/six-textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,WAAW,MAAM,uDAAuD,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,6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J,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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 { EventListeners } from '../../utils/event-listeners';\nimport { EmptyPayload } from '../../utils/types';\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 textarea's label. Alternatively, you can use the label prop.\n * @slot help-text - Help text that describes how to use the input.\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 form-control - The form control that wraps the label, textarea, and help text.\n * @part label - The textarea label.\n * @part textarea - The textarea control.\n * @part help-text - The textarea help text.\n */\n@Component({\n tag: 'six-textarea',\n styleUrl: 'six-textarea.scss',\n shadow: true,\n})\nexport class SixTextarea {\n private inputId = `textarea-${++id}`;\n private labelId = `textarea-label-${id}`;\n private helpTextId = `textarea-help-text-${id}`;\n private errorTextId = `input-error-text-${id}`;\n private nativeTextarea?: HTMLTextAreaElement;\n private customErrorText = '';\n private customValidation = false;\n private eventListeners = new EventListeners();\n private resizeObserver?: ResizeObserver;\n\n @Element() host!: HTMLSixTextareaElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasErrorTextSlot = false;\n @State() hasLabelSlot = false;\n\n /** The textarea's size. */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** The textarea's name attribute. */\n @Prop({ reflect: true }) name = '';\n\n /** The textarea's value attribute. */\n @Prop({ mutable: true, reflect: true }) value = '';\n\n /** The textarea's label. Alternatively, you can use the label slot. */\n @Prop() label = '';\n\n /** The textarea's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** The textarea's error text. Alternatively, you can use the error-text slot. */\n @Prop() errorText = '';\n\n /** The textarea's placeholder text. */\n @Prop() placeholder?: string;\n\n /** The number of rows to display by default. */\n @Prop() rows = 4;\n\n /** Controls how the textarea can be resized. */\n @Prop() resize: 'none' | 'vertical' | 'auto' = 'vertical';\n\n /** Set to true to disable the textarea. */\n @Prop({ reflect: true }) disabled = false;\n\n /** Set to true for a readonly textarea. */\n @Prop({ reflect: true }) readonly = false;\n\n /** The minimum length of input that will be considered valid. */\n @Prop({ reflect: true }) minlength?: number;\n\n /** The maximum length of input that will be considered valid. */\n @Prop({ reflect: true }) maxlength?: number;\n\n /** The textarea's required attribute. */\n @Prop({ reflect: true }) required = false;\n\n /**\n * This will be true when the control is in an invalid state. Validity is determined by props such as `required`,\n * `minlength`, and `maxlength` using the browser's constraint validation API.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** The textarea's autocaptialize attribute. */\n @Prop() autocapitalize = 'off';\n\n /** The textarea's autocorrect attribute. */\n @Prop() autocorrect: 'on' | 'off' = 'off';\n\n /** The textarea's autocomplete attribute. */\n @Prop() autocomplete = 'off';\n\n /** The textarea's autofocus attribute. */\n @Prop() autofocus = false;\n\n /** The textarea's spellcheck attribute. */\n @Prop() spellcheck = false;\n\n /** The textarea's inputmode attribute. */\n @Prop() inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';\n\n /** Set to display the error text on blur and not when typing */\n @Prop() errorOnBlur = false;\n\n /** Emitted when the control's value changes. Access the new value via event.target.value. */\n @Event({ eventName: 'six-textarea-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control receives input. Access the new value via event.target.value. */\n @Event({ eventName: 'six-textarea-input' }) sixInput!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-textarea-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. Access the new value via event.target.value. */\n @Event({ eventName: 'six-textarea-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n @Watch('helpText')\n @Watch('errorText')\n @Watch('label')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('rows')\n handleRowsChange() {\n if (this.nativeTextarea != null) {\n this.setTextareaHeight(this.nativeTextarea);\n }\n }\n\n @Watch('value')\n handleValueChange() {\n this.value = this.getValue();\n if (this.nativeTextarea != null) {\n if (this.nativeTextarea.value !== this.value) {\n this.nativeTextarea.value = this.value;\n }\n this.invalid = !this.nativeTextarea.checkValidity();\n }\n }\n\n /** default value the textarea will be reverted to when reset is executed */\n private defaultValue = '';\n\n connectedCallback() {\n this.host.shadowRoot?.addEventListener('slotchange', this.handleSlotChange);\n }\n\n componentWillLoad() {\n this.defaultValue = this.value || '';\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n const nativeTextarea = this.nativeTextarea;\n if (nativeTextarea == null) {\n return;\n }\n this.setTextareaHeight(nativeTextarea);\n this.resizeObserver = new ResizeObserver(() => this.setTextareaHeight(nativeTextarea));\n this.resizeObserver.observe(nativeTextarea);\n this.eventListeners.add(nativeTextarea, 'invalid', (event) => {\n this.invalid = true;\n if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {\n this.customErrorText = nativeTextarea.validationMessage;\n }\n event.preventDefault();\n });\n }\n\n disconnectedCallback() {\n if (this.nativeTextarea != null) {\n this.resizeObserver?.unobserve(this.nativeTextarea);\n }\n this.host.shadowRoot?.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the textarea. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeTextarea?.focus(options);\n }\n\n /** Removes focus fromt the textarea. */\n @Method()\n async removeFocus() {\n this.nativeTextarea?.blur();\n }\n\n /** Selects all the text in the input. */\n @Method()\n async select() {\n return this.nativeTextarea?.select();\n }\n\n /** Sets the start and end positions of the text selection (0-based). */\n @Method()\n async setSelectionRange(\n selectionStart: number,\n selectionEnd: number,\n selectionDirection: 'forward' | 'backward' | 'none' = 'none'\n ) {\n return this.nativeTextarea?.setSelectionRange(selectionStart, selectionEnd, selectionDirection);\n }\n\n /** Replaces a range of text with a new string. */\n @Method()\n async setRangeText(\n replacement: string,\n start: number,\n end: number,\n selectMode: 'select' | 'start' | 'end' | 'preserve' = 'preserve'\n ) {\n if (this.nativeTextarea == null) {\n return;\n }\n this.nativeTextarea.setRangeText(replacement, start, end, selectMode);\n if (this.getValue() !== this.nativeTextarea.value) {\n this.value = this.nativeTextarea.value;\n this.setTextareaHeight(this.nativeTextarea);\n this.sixChange.emit();\n this.sixInput.emit();\n }\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.nativeTextarea?.reportValidity();\n }\n\n /** Checks for validity. */\n @Method()\n async checkValidity() {\n if (this.nativeTextarea == null) {\n return true;\n }\n return this.nativeTextarea.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.nativeTextarea != null) {\n this.nativeTextarea.setCustomValidity(message);\n this.invalid = !this.nativeTextarea.checkValidity();\n }\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.value = this.defaultValue;\n this.customErrorText = '';\n this.customValidation = false;\n this.nativeTextarea?.setCustomValidity('');\n this.invalid = false;\n }\n\n private handleChange = () => {\n if (this.nativeTextarea != null) {\n this.value = this.nativeTextarea.value;\n this.sixChange.emit();\n }\n };\n\n private handleInput = () => {\n if (this.nativeTextarea != null) {\n this.value = this.nativeTextarea.value;\n this.setTextareaHeight(this.nativeTextarea);\n this.sixInput.emit();\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 handleSlotChange = () => {\n this.hasLabelSlot = hasSlot(this.host, 'label');\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n };\n\n private setTextareaHeight(nativeTextarea: HTMLTextAreaElement) {\n if (this.resize === 'auto') {\n nativeTextarea.style.height = 'auto';\n const height = nativeTextarea.scrollHeight + 1;\n nativeTextarea.style.height = height + 'px';\n } else {\n nativeTextarea.style.height = '';\n }\n }\n\n private displayError() {\n return this.invalid && (!this.errorOnBlur || !this.hasFocus);\n }\n\n private getValue(): string {\n return (this.value ?? '').toString();\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 helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n errorTextId={this.errorTextId}\n errorText={this.customErrorText != null ? this.customErrorText : this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n size={this.size}\n disabled={this.disabled}\n required={this.required}\n displayError={this.displayError()}\n >\n <div\n part=\"base\"\n class={{\n textarea: true,\n\n // Sizes\n 'textarea--small': this.size === 'small',\n 'textarea--medium': this.size === 'medium',\n 'textarea--large': this.size === 'large',\n\n // States\n 'textarea--disabled': this.disabled,\n 'textarea--focused': this.hasFocus,\n 'textarea--empty': this.getValue().length === 0,\n 'textarea--invalid': this.invalid,\n\n // Modifiers\n 'textarea--resize-none': this.resize === 'none',\n 'textarea--resize-vertical': this.resize === 'vertical',\n 'textarea--resize-auto': this.resize === 'auto',\n }}\n >\n <textarea\n part=\"textarea\"\n ref={(el) => (this.nativeTextarea = el)}\n id={this.inputId}\n class=\"textarea__control\"\n name={this.name}\n placeholder={this.placeholder}\n disabled={this.disabled}\n readOnly={this.readonly}\n rows={this.rows}\n minLength={this.minlength}\n maxLength={this.maxlength}\n value={this.getValue()}\n autoCapitalize={this.autocapitalize}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n spellcheck={this.spellcheck}\n required={this.required}\n inputMode={this.inputmode}\n aria-labelledby={this.labelId}\n onChange={this.handleChange}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n </div>\n </FormControl>\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"slot.js","sourceRoot":"","sources":["../../src/utils/slot.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,oHAAoH;AACpH,0FAA0F;AAC1F,EAAE;AACF,MAAM,UAAU,YAAY,CAAC,IAAqB;EAChD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;EACpD,IAAI,IAAI,GAAG,EAAE,CAAC;EAEd,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;IACtB,I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AAO,IAAI,CAAC;KACb;IAED,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,EAAE;MACvC,MAAM,EAAE,GAAG,IAAmB,CAAC;MAC/B,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;QAC5B,OAAO,IAAI,CAAC;OACb;KACF;IAED,OAAO,KAAK,CAAC;EACf,CAAC,CAAC,CAAC;AACL,CAAC;AAID,MAAM,SAAS,GAAG,CAAmB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAe,EAAE,EAAE,CAAC,iCAAM,GAAG,KAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAG,CAAC;AAExF,MAAM,CAAC,MAAM,iBAAiB,GAC5B,CAAmB,KAAQ,EAAE,EAAE,CAC/B,CAAwB,IAAO,EAAqB,EAAE,CACpD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;GACjB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;GAC1C,MAAM,CAAC,SAAS,EAAE,EAAuB,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAwB,EAAe,EAAE,EAAE,WACxE,OAAA,MAAA,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,0CAAE,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAQ,CAAA,EAAA,CAAC","sourcesContent":["//\n// Given a slot, this function iterates over all of its assigned element and text nodes and returns the concatenated\n// HTML as a string. This is useful because we can't use slot.innerHTML as an alternative.\n//\nexport function getInnerHTML(slot: HTMLSlotElement): string {\n const nodes = slot.assignedNodes({ flatten: true });\n let html = '';\n\n [...nodes].map((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n html += (node as HTMLElement).outerHTML;\n }\n\n if (node.nodeType === Node.TEXT_NODE) {\n html += node.textContent;\n }\n });\n\n return html;\n}\n\n//\n// Given a slot, this function iterates over all of its assigned text nodes and returns the concatenated text as a\n// string. This is useful because we can't use slot.textContent as an alternative.\n//\nexport function getTextContent(slot: HTMLSlotElement): string {\n const nodes = slot ? slot.assignedNodes({ flatten: true }) : [];\n let text = '';\n\n [...nodes].map((node) => {\n if (node.nodeType === Node.TEXT_NODE) {\n text += node.textContent;\n }\n });\n\n return text;\n}\n\n//\n// Determines whether an element has a slot. If name is specified, the function will look for a corresponding named\n// slot, otherwise it will look for a \"default\" slot (e.g. a non-empty text node or an element with no slot attribute).\n//\nexport function hasSlot(el: HTMLElement, name?: string) {\n // Look for a named slot\n if (name) {\n return el.querySelector(`[slot=\"${name}\"]`) !== null;\n }\n\n // Look for a default slot\n return Array.from(el.childNodes).some((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent.trim() !== '') {\n return true;\n }\n\n if (node.nodeType === node.ELEMENT_NODE) {\n const el = node as HTMLElement;\n if (!el.hasAttribute('slot')) {\n return true;\n }\n }\n\n return false;\n });\n}\n\ntype AvailableSlots<T> = { readonly [K in keyof T]: boolean };\n\nconst fromPairs = <T extends string>(acc, [k, v]: [T, boolean]) => ({ ...acc, [k]: v });\n\nexport const getAvailableSlots =\n <T extends object>(slots: T) =>\n <E extends HTMLElement>(host: E): AvailableSlots<T> =>\n Object.values(slots)\n .map((name) => [name, hasSlot(host, name)])\n .reduce(fromPairs, {} as AvailableSlots<T>);\n\nexport const getSlotChildren = <T extends HTMLElement>(el: HTMLElement) =>\n el.querySelector('slot')?.assignedElements({ flatten: true }) as T[];\n"]}
1
+ {"version":3,"file":"slot.js","sourceRoot":"","sources":["../../src/utils/slot.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,oHAAoH;AACpH,0FAA0F;AAC1F,EAAE;AACF,MAAM,UAAU,YAAY,CAAC,IAAqB;EAChD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;EACpD,IAAI,IAAI,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AAQ,KAAK,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;MACtE,OAAO,IAAI,CAAC;KACb;IAED,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,EAAE;MACvC,MAAM,EAAE,GAAG,IAAmB,CAAC;MAC/B,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;QAC5B,OAAO,IAAI,CAAC;OACb;KACF;IAED,OAAO,KAAK,CAAC;EACf,CAAC,CAAC,CAAC;AACL,CAAC;AAID,MAAM,SAAS,GAAG,CAAmB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAe,EAAE,EAAE,CAAC,iCAAM,GAAG,KAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAG,CAAC;AAExF,MAAM,CAAC,MAAM,iBAAiB,GAC5B,CAAmB,KAAQ,EAAE,EAAE,CAC/B,CAAwB,IAAO,EAAqB,EAAE,CACpD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;GACjB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;GAC1C,MAAM,CAAC,SAAS,EAAE,EAAuB,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAwB,EAAe,EAAE,EAAE,WACxE,OAAA,MAAA,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,0CAAE,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAQ,CAAA,EAAA,CAAC","sourcesContent":["//\n// Given a slot, this function iterates over all of its assigned element and text nodes and returns the concatenated\n// HTML as a string. This is useful because we can't use slot.innerHTML as an alternative.\n//\nexport function getInnerHTML(slot: HTMLSlotElement): string {\n const nodes = slot.assignedNodes({ flatten: true });\n let html = '';\n\n [...nodes].map((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n html += (node as HTMLElement).outerHTML;\n }\n\n if (node.nodeType === Node.TEXT_NODE) {\n html += node.textContent;\n }\n });\n\n return html;\n}\n\n//\n// Given a slot, this function iterates over all of its assigned text nodes and returns the concatenated text as a\n// string. This is useful because we can't use slot.textContent as an alternative.\n//\nexport function getTextContent(slot: HTMLSlotElement): string {\n const nodes = slot ? slot.assignedNodes({ flatten: true }) : [];\n let text = '';\n\n [...nodes].map((node) => {\n if (node.nodeType === Node.TEXT_NODE) {\n text += node.textContent;\n }\n });\n\n return text;\n}\n\n//\n// Determines whether an element has a slot. If name is specified, the function will look for a corresponding named\n// slot, otherwise it will look for a \"default\" slot (e.g. a non-empty text node or an element with no slot attribute).\n//\nexport function hasSlot(el: HTMLElement, name?: string): boolean {\n // Look for a named slot\n if (name) {\n return el.querySelector(`[slot=\"${name}\"]`) !== null;\n }\n\n // Look for a default slot\n return Array.from(el.childNodes).some((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent.trim() !== '') {\n return true;\n }\n\n if (node.nodeType === node.ELEMENT_NODE) {\n const el = node as HTMLElement;\n if (!el.hasAttribute('slot')) {\n return true;\n }\n }\n\n return false;\n });\n}\n\ntype AvailableSlots<T> = { readonly [K in keyof T]: boolean };\n\nconst fromPairs = <T extends string>(acc, [k, v]: [T, boolean]) => ({ ...acc, [k]: v });\n\nexport const getAvailableSlots =\n <T extends object>(slots: T) =>\n <E extends HTMLElement>(host: E): AvailableSlots<T> =>\n Object.values(slots)\n .map((name) => [name, hasSlot(host, name)])\n .reduce(fromPairs, {} as AvailableSlots<T>);\n\nexport const getSlotChildren = <T extends HTMLElement>(el: HTMLElement) =>\n el.querySelector('slot')?.assignedElements({ flatten: true }) as T[];\n"]}