@haiilo/catalyst 10.21.4 → 10.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/catalyst.esm.js.map +1 -1
  3. package/dist/catalyst/{p-4866485c.entry.js → p-594e46b4.entry.js} +4 -4
  4. package/dist/catalyst/p-594e46b4.entry.js.map +1 -0
  5. package/dist/cjs/{cat-alert_29.cjs.entry.js → cat-alert_30.cjs.entry.js} +160 -22
  6. package/dist/cjs/cat-alert_30.cjs.entry.js.map +1 -0
  7. package/dist/cjs/catalyst.cjs.js +1 -1
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/collection/collection-manifest.json +1 -0
  10. package/dist/collection/components/cat-tag/cat-tag.css +553 -0
  11. package/dist/collection/components/cat-tag/cat-tag.e2e.js +14 -0
  12. package/dist/collection/components/cat-tag/cat-tag.e2e.js.map +1 -0
  13. package/dist/collection/components/cat-tag/cat-tag.js +490 -0
  14. package/dist/collection/components/cat-tag/cat-tag.js.map +1 -0
  15. package/dist/collection/components/cat-tag/cat-tag.spec.js +23 -0
  16. package/dist/collection/components/cat-tag/cat-tag.spec.js.map +1 -0
  17. package/dist/collection/components/cat-textarea/cat-textarea.js +3 -3
  18. package/dist/collection/components/cat-time/cat-time.js +2 -2
  19. package/dist/collection/components/cat-toggle/cat-toggle.js +2 -2
  20. package/dist/components/cat-tag.d.ts +11 -0
  21. package/dist/components/cat-tag.js +203 -0
  22. package/dist/components/cat-tag.js.map +1 -0
  23. package/dist/components/cat-textarea.js +3 -3
  24. package/dist/components/cat-time.js +2 -2
  25. package/dist/components/cat-toggle.js +2 -2
  26. package/dist/esm/{cat-alert_29.entry.js → cat-alert_30.entry.js} +160 -23
  27. package/dist/esm/cat-alert_30.entry.js.map +1 -0
  28. package/dist/esm/catalyst.js +1 -1
  29. package/dist/esm/loader.js +1 -1
  30. package/dist/types/components/cat-tag/cat-tag.d.ts +110 -0
  31. package/dist/types/components.d.ts +162 -0
  32. package/package.json +2 -2
  33. package/dist/catalyst/p-4866485c.entry.js.map +0 -1
  34. package/dist/cjs/cat-alert_29.cjs.entry.js.map +0 -1
  35. package/dist/esm/cat-alert_29.entry.js.map +0 -1
@@ -0,0 +1,490 @@
1
+ import { Host, h } from "@stencil/core";
2
+ import { coerceBoolean, coerceNumber } from "../../utils/coerce";
3
+ import { CatFormHint } from "../cat-form-hint/cat-form-hint";
4
+ import { catI18nRegistry as i18n } from "../cat-i18n/cat-i18n-registry";
5
+ let nextUniqueId = 0;
6
+ export class CatTag {
7
+ constructor() {
8
+ this._id = `cat-input-${nextUniqueId++}`;
9
+ this.hasSlottedLabel = false;
10
+ this.hasSlottedHint = false;
11
+ this.tags = [];
12
+ this.errorMap = undefined;
13
+ this.requiredMarker = 'optional';
14
+ this.disabled = false;
15
+ this.placeholder = undefined;
16
+ this.hint = undefined;
17
+ this.identifier = undefined;
18
+ this.label = '';
19
+ this.name = undefined;
20
+ this.labelHidden = false;
21
+ this.required = false;
22
+ this.nativeAttributes = undefined;
23
+ this.value = undefined;
24
+ this.clearable = false;
25
+ this.errors = undefined;
26
+ this.errorUpdate = 0;
27
+ this.tagCreationChars = [' '];
28
+ }
29
+ get id() {
30
+ return this.identifier || this._id;
31
+ }
32
+ get invalid() {
33
+ return !!Object.keys(this.errorMap || {}).length;
34
+ }
35
+ get hasHint() {
36
+ return !!this.hint || this.invalid;
37
+ }
38
+ onKeyDown(event) {
39
+ const isInputFocused = this.hostElement.shadowRoot?.activeElement === this.input;
40
+ if (['Enter', ...this.tagCreationChars].includes(event.key) && isInputFocused) {
41
+ event.preventDefault();
42
+ if (this.input?.value.trim() && !this.value?.includes(this.input?.value.trim())) {
43
+ this.value = [...(this.value ?? []), this.input.value.trim()];
44
+ this.catChange.emit(this.value);
45
+ }
46
+ if (this.input) {
47
+ this.input.value = '';
48
+ }
49
+ }
50
+ else if (['Backspace'].includes(event.key) &&
51
+ this.input?.selectionStart === 0 &&
52
+ (this.value?.length ?? 0) > 0 &&
53
+ isInputFocused) {
54
+ this.value = this.value?.slice(0, -1) ?? [];
55
+ this.catChange.emit(this.value);
56
+ }
57
+ }
58
+ onErrorsChanged(value) {
59
+ if (!coerceBoolean(this.errorUpdate)) {
60
+ this.errorMap = undefined;
61
+ }
62
+ else {
63
+ this.errorMapSrc = Array.isArray(value)
64
+ ? value.reduce((acc, err) => ({ ...acc, [err]: undefined }), {})
65
+ : value === true
66
+ ? {}
67
+ : value || undefined;
68
+ this.showErrorsIfTimeout() || this.showErrorsIfNoFocus();
69
+ }
70
+ }
71
+ componentWillRender() {
72
+ this.onErrorsChanged(this.errors);
73
+ this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
74
+ this.hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
75
+ }
76
+ render() {
77
+ return (h(Host, { key: '398a4b7c4e4083354f0c2d6e0224144938d13c91' }, h("div", { key: '05f5813a7d630e814abb7a2fe83cd43a5e88e1e3', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { key: '4d4ddf228978a88f79ca6d0457e98ec13b260ff8', htmlFor: `tags-${this.id}-input`, part: "label" }, h("span", { key: '3d04af2eefcb408c2f9fc7345fc30babf1674002', class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { key: '7e0f92865f6a37c5b4702d3abd1d39e7e7c871ac', name: "label" })) || this.label, h("div", { key: '27f211e9409626760244007b1871deb78065b00c', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { key: 'cac179c8ab9d8fa28877fc619dacdf3890640b4c', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { key: '0d7587cf3d5706846ec635b0e9762faf3b5acd18', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")"))))))), h("div", { key: 'c26692159377a9f808f5052491eef1528d65c02e', class: { 'input-wrapper': true, 'input-disabled': this.disabled, 'input-invalid': this.invalid } }, this.value?.map(value => (h("div", { class: "tag-pill" }, h("span", null, value), !this.disabled && (h("cat-button", { size: "xs", variant: "text", icon: "$cat:select-clear", iconOnly: true, a11yLabel: i18n.t('select.deselect'), onClick: () => this.deselect(value), tabIndex: -1 }))))), h("div", { key: '843bc85ffc9ddb85612a2f7ad38a009fc90242f2', class: "input-inner-wrapper" }, h("input", { key: 'd952b031c057a055f4be1869ebdb9b9f33589120', ...this.nativeAttributes, part: "input", id: `tags-${this.id}-input`, class: "tags-input", role: "combobox", ref: el => (this.input = el), "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hasHint ? this.id + '-hint' : undefined, onInput: this.onInput.bind(this), placeholder: this.placeholder, disabled: this.disabled }), this.clearable && !this.disabled && (this.value?.length ?? 0) > 0 && (h("cat-button", { key: 'dc1cba0d616ad239c45b1db93c98bcd68b9c1cdd', class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": i18n.t('input.clear'), onClick: this.clear.bind(this), "data-dropdown-no-close": true })), this.invalid && h("cat-icon", { key: '62e89d1492b4c72a01c3d362171b76e7c9f9a9ae', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" }))), this.hasHint && (h(CatFormHint, { key: 'f291d121c8aee0c871b4d72f497a83778d0165c1', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap }))));
78
+ }
79
+ onInput() {
80
+ const currentValue = [
81
+ ...new Set(this.input?.value?.split(this.createSplitRegex(this.tagCreationChars)) ?? [])
82
+ ].filter(value => !!value && !this.value?.includes(value));
83
+ if (currentValue.length > 1) {
84
+ this.value = [...(this.value ?? []), ...currentValue];
85
+ this.catChange.emit(this.value);
86
+ if (this.input) {
87
+ this.input.value = '';
88
+ }
89
+ }
90
+ }
91
+ clear() {
92
+ this.value = [];
93
+ this.catChange.emit(this.value);
94
+ if (this.input) {
95
+ this.input.value = '';
96
+ }
97
+ }
98
+ deselect(value) {
99
+ this.value = this.value?.filter(element => element !== value);
100
+ }
101
+ showErrors() {
102
+ this.errorMap = this.errorMapSrc;
103
+ }
104
+ showErrorsIfTimeout() {
105
+ const errorUpdate = coerceNumber(this.errorUpdate, null);
106
+ if (errorUpdate !== null) {
107
+ typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);
108
+ this.errorUpdateTimeoutId = window.setTimeout(() => this.showErrors(), errorUpdate);
109
+ return true;
110
+ }
111
+ return false;
112
+ }
113
+ showErrorsIfNoFocus() {
114
+ const hasFocus = document.activeElement === this.hostElement || document.activeElement === this.input;
115
+ if (!hasFocus) {
116
+ this.showErrors();
117
+ }
118
+ }
119
+ createSplitRegex(delimiters) {
120
+ // Escape special regex characters in the array
121
+ const escapedDelimiters = delimiters.map(delimiter => delimiter.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
122
+ // Add newline characters to the list of delimiters
123
+ escapedDelimiters.push('\\n', '\\r');
124
+ // Join the escaped delimiters to create a character class
125
+ const regexPattern = `[${escapedDelimiters.join('')}]`;
126
+ return new RegExp(regexPattern, 'g');
127
+ }
128
+ static get is() { return "cat-tag"; }
129
+ static get encapsulation() { return "shadow"; }
130
+ static get originalStyleUrls() {
131
+ return {
132
+ "$": ["cat-tag.scss"]
133
+ };
134
+ }
135
+ static get styleUrls() {
136
+ return {
137
+ "$": ["cat-tag.css"]
138
+ };
139
+ }
140
+ static get properties() {
141
+ return {
142
+ "requiredMarker": {
143
+ "type": "string",
144
+ "mutable": false,
145
+ "complexType": {
146
+ "original": "'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!'",
147
+ "resolved": "\"none!\" | \"none\" | \"optional!\" | \"optional\" | \"required!\" | \"required\" | undefined",
148
+ "references": {}
149
+ },
150
+ "required": false,
151
+ "optional": true,
152
+ "docs": {
153
+ "tags": [],
154
+ "text": "Whether the label need a marker to shown if the select is required or optional."
155
+ },
156
+ "attribute": "required-marker",
157
+ "reflect": false,
158
+ "defaultValue": "'optional'"
159
+ },
160
+ "disabled": {
161
+ "type": "boolean",
162
+ "mutable": false,
163
+ "complexType": {
164
+ "original": "boolean",
165
+ "resolved": "boolean",
166
+ "references": {}
167
+ },
168
+ "required": false,
169
+ "optional": false,
170
+ "docs": {
171
+ "tags": [],
172
+ "text": "Whether the select is disabled."
173
+ },
174
+ "attribute": "disabled",
175
+ "reflect": false,
176
+ "defaultValue": "false"
177
+ },
178
+ "placeholder": {
179
+ "type": "string",
180
+ "mutable": false,
181
+ "complexType": {
182
+ "original": "string",
183
+ "resolved": "string | undefined",
184
+ "references": {}
185
+ },
186
+ "required": false,
187
+ "optional": true,
188
+ "docs": {
189
+ "tags": [],
190
+ "text": "The placeholder text to display within the select."
191
+ },
192
+ "attribute": "placeholder",
193
+ "reflect": false
194
+ },
195
+ "hint": {
196
+ "type": "string",
197
+ "mutable": false,
198
+ "complexType": {
199
+ "original": "string | string[]",
200
+ "resolved": "string | string[] | undefined",
201
+ "references": {}
202
+ },
203
+ "required": false,
204
+ "optional": true,
205
+ "docs": {
206
+ "tags": [],
207
+ "text": "Optional hint text(s) to be displayed with the select."
208
+ },
209
+ "attribute": "hint",
210
+ "reflect": false
211
+ },
212
+ "identifier": {
213
+ "type": "string",
214
+ "mutable": false,
215
+ "complexType": {
216
+ "original": "string",
217
+ "resolved": "string | undefined",
218
+ "references": {}
219
+ },
220
+ "required": false,
221
+ "optional": true,
222
+ "docs": {
223
+ "tags": [],
224
+ "text": "A unique identifier for the input."
225
+ },
226
+ "attribute": "identifier",
227
+ "reflect": false
228
+ },
229
+ "label": {
230
+ "type": "string",
231
+ "mutable": false,
232
+ "complexType": {
233
+ "original": "string",
234
+ "resolved": "string",
235
+ "references": {}
236
+ },
237
+ "required": false,
238
+ "optional": false,
239
+ "docs": {
240
+ "tags": [],
241
+ "text": "The label for the select."
242
+ },
243
+ "attribute": "label",
244
+ "reflect": false,
245
+ "defaultValue": "''"
246
+ },
247
+ "name": {
248
+ "type": "string",
249
+ "mutable": false,
250
+ "complexType": {
251
+ "original": "string",
252
+ "resolved": "string | undefined",
253
+ "references": {}
254
+ },
255
+ "required": false,
256
+ "optional": true,
257
+ "docs": {
258
+ "tags": [],
259
+ "text": "The name of the form control. Submitted with the form as part of a name/value pair."
260
+ },
261
+ "attribute": "name",
262
+ "reflect": false
263
+ },
264
+ "labelHidden": {
265
+ "type": "boolean",
266
+ "mutable": false,
267
+ "complexType": {
268
+ "original": "boolean",
269
+ "resolved": "boolean",
270
+ "references": {}
271
+ },
272
+ "required": false,
273
+ "optional": false,
274
+ "docs": {
275
+ "tags": [],
276
+ "text": "Visually hide the label, but still show it to assistive technologies like screen readers."
277
+ },
278
+ "attribute": "label-hidden",
279
+ "reflect": false,
280
+ "defaultValue": "false"
281
+ },
282
+ "required": {
283
+ "type": "boolean",
284
+ "mutable": false,
285
+ "complexType": {
286
+ "original": "boolean",
287
+ "resolved": "boolean",
288
+ "references": {}
289
+ },
290
+ "required": false,
291
+ "optional": false,
292
+ "docs": {
293
+ "tags": [],
294
+ "text": "A value is required or must be checked for the form to be submittable."
295
+ },
296
+ "attribute": "required",
297
+ "reflect": false,
298
+ "defaultValue": "false"
299
+ },
300
+ "nativeAttributes": {
301
+ "type": "unknown",
302
+ "mutable": false,
303
+ "complexType": {
304
+ "original": "{ [key: string]: string }",
305
+ "resolved": "undefined | { [key: string]: string; }",
306
+ "references": {}
307
+ },
308
+ "required": false,
309
+ "optional": true,
310
+ "docs": {
311
+ "tags": [],
312
+ "text": "Attributes that will be added to the native HTML input element."
313
+ }
314
+ },
315
+ "value": {
316
+ "type": "unknown",
317
+ "mutable": true,
318
+ "complexType": {
319
+ "original": "string[]",
320
+ "resolved": "string[] | undefined",
321
+ "references": {}
322
+ },
323
+ "required": false,
324
+ "optional": true,
325
+ "docs": {
326
+ "tags": [],
327
+ "text": "The value of the control."
328
+ }
329
+ },
330
+ "clearable": {
331
+ "type": "boolean",
332
+ "mutable": false,
333
+ "complexType": {
334
+ "original": "boolean",
335
+ "resolved": "boolean",
336
+ "references": {}
337
+ },
338
+ "required": false,
339
+ "optional": false,
340
+ "docs": {
341
+ "tags": [],
342
+ "text": "Whether the input should show a clear button."
343
+ },
344
+ "attribute": "clearable",
345
+ "reflect": false,
346
+ "defaultValue": "false"
347
+ },
348
+ "errors": {
349
+ "type": "boolean",
350
+ "mutable": false,
351
+ "complexType": {
352
+ "original": "boolean | string[] | ErrorMap",
353
+ "resolved": "boolean | string[] | undefined | { [key: string]: any; }",
354
+ "references": {
355
+ "ErrorMap": {
356
+ "location": "import",
357
+ "path": "../cat-form-hint/cat-form-hint",
358
+ "id": "src/components/cat-form-hint/cat-form-hint.tsx::ErrorMap"
359
+ }
360
+ }
361
+ },
362
+ "required": false,
363
+ "optional": true,
364
+ "docs": {
365
+ "tags": [],
366
+ "text": "The validation errors for this input. Will render a hint under the input\nwith the translated error message(s) `error.${key}`. If an object is\npassed, the keys will be used as error keys and the values translation\nparameters.\nIf the value is `true`, the input will be marked as invalid without any\nhints under the input."
367
+ },
368
+ "attribute": "errors",
369
+ "reflect": false
370
+ },
371
+ "errorUpdate": {
372
+ "type": "any",
373
+ "mutable": false,
374
+ "complexType": {
375
+ "original": "boolean | number",
376
+ "resolved": "boolean | number",
377
+ "references": {}
378
+ },
379
+ "required": false,
380
+ "optional": false,
381
+ "docs": {
382
+ "tags": [],
383
+ "text": "Fine-grained control over when the errors are shown. Can be `false` to\nnever show errors, `true` to show errors on blur, or a number to show\nerrors on change with the given delay in milliseconds."
384
+ },
385
+ "attribute": "error-update",
386
+ "reflect": false,
387
+ "defaultValue": "0"
388
+ },
389
+ "tagCreationChars": {
390
+ "type": "unknown",
391
+ "mutable": false,
392
+ "complexType": {
393
+ "original": "string[]",
394
+ "resolved": "string[]",
395
+ "references": {}
396
+ },
397
+ "required": false,
398
+ "optional": false,
399
+ "docs": {
400
+ "tags": [],
401
+ "text": "List of characters that should create a new tag. This need to be comparable to `keydownEvent.key`.\nPasted values will also be split by those chars.\nDefaults to `[' ']`."
402
+ },
403
+ "defaultValue": "[' ']"
404
+ }
405
+ };
406
+ }
407
+ static get states() {
408
+ return {
409
+ "hasSlottedLabel": {},
410
+ "hasSlottedHint": {},
411
+ "tags": {},
412
+ "errorMap": {}
413
+ };
414
+ }
415
+ static get events() {
416
+ return [{
417
+ "method": "catChange",
418
+ "name": "catChange",
419
+ "bubbles": true,
420
+ "cancelable": true,
421
+ "composed": true,
422
+ "docs": {
423
+ "tags": [],
424
+ "text": "Emitted when the value is changed."
425
+ },
426
+ "complexType": {
427
+ "original": "string[]",
428
+ "resolved": "string[]",
429
+ "references": {}
430
+ }
431
+ }, {
432
+ "method": "catFocus",
433
+ "name": "catFocus",
434
+ "bubbles": true,
435
+ "cancelable": true,
436
+ "composed": true,
437
+ "docs": {
438
+ "tags": [],
439
+ "text": "Emitted when the input received focus."
440
+ },
441
+ "complexType": {
442
+ "original": "FocusEvent",
443
+ "resolved": "FocusEvent",
444
+ "references": {
445
+ "FocusEvent": {
446
+ "location": "global",
447
+ "id": "global::FocusEvent"
448
+ }
449
+ }
450
+ }
451
+ }, {
452
+ "method": "catBlur",
453
+ "name": "catBlur",
454
+ "bubbles": true,
455
+ "cancelable": true,
456
+ "composed": true,
457
+ "docs": {
458
+ "tags": [],
459
+ "text": "Emitted when the input loses focus."
460
+ },
461
+ "complexType": {
462
+ "original": "FocusEvent",
463
+ "resolved": "FocusEvent",
464
+ "references": {
465
+ "FocusEvent": {
466
+ "location": "global",
467
+ "id": "global::FocusEvent"
468
+ }
469
+ }
470
+ }
471
+ }];
472
+ }
473
+ static get elementRef() { return "hostElement"; }
474
+ static get watchers() {
475
+ return [{
476
+ "propName": "errors",
477
+ "methodName": "onErrorsChanged"
478
+ }];
479
+ }
480
+ static get listeners() {
481
+ return [{
482
+ "name": "keydown",
483
+ "method": "onKeyDown",
484
+ "target": undefined,
485
+ "capture": false,
486
+ "passive": false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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, State, Prop, Event, EventEmitter, Listen, Element, Watch } from '@stencil/core';\nimport { coerceBoolean, coerceNumber } from '../../utils/coerce';\nimport { CatFormHint, ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tag',\n styleUrl: 'cat-tag.scss',\n shadow: true\n})\nexport class CatTag {\n private readonly _id = `cat-input-${nextUniqueId++}`;\n\n private input?: HTMLInputElement;\n private errorMapSrc?: ErrorMap;\n\n private get id() {\n return this.identifier || this._id;\n }\n\n private get invalid() {\n return !!Object.keys(this.errorMap || {}).length;\n }\n\n private get hasHint() {\n return !!this.hint || this.invalid;\n }\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n @State() hasSlottedHint = false;\n\n @State() tags: string[] = [];\n\n @State() errorMap?: ErrorMap;\n\n /**\n * Whether the label need a marker to shown if the select is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the select is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * The placeholder text to display within the select.\n */\n @Prop() placeholder?: string;\n\n /**\n * Optional hint text(s) to be displayed with the select.\n */\n @Prop() hint?: string | string[];\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the select.\n */\n @Prop() label = '';\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A value is required or must be checked for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * The value of the control.\n */\n @Prop({ mutable: true }) value?: string[];\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * List of characters that should create a new tag. This need to be comparable to `keydownEvent.key`.\n * Pasted values will also be split by those chars.\n * Defaults to `[' ']`.\n */\n @Prop() tagCreationChars: string[] = [' '];\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string[]>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Listen('keydown')\n onKeyDown(event: KeyboardEvent): void {\n const isInputFocused = this.hostElement.shadowRoot?.activeElement === this.input;\n if (['Enter', ...this.tagCreationChars].includes(event.key) && isInputFocused) {\n event.preventDefault();\n if (this.input?.value.trim() && !this.value?.includes(this.input?.value.trim())) {\n this.value = [...(this.value ?? []), this.input.value.trim()];\n this.catChange.emit(this.value);\n }\n if (this.input) {\n this.input.value = '';\n }\n } else if (\n ['Backspace'].includes(event.key) &&\n this.input?.selectionStart === 0 &&\n (this.value?.length ?? 0) > 0 &&\n isInputFocused\n ) {\n this.value = this.value?.slice(0, -1) ?? [];\n this.catChange.emit(this.value);\n }\n }\n\n @Watch('errors')\n onErrorsChanged(value?: boolean | string[] | ErrorMap) {\n if (!coerceBoolean(this.errorUpdate)) {\n this.errorMap = undefined;\n } else {\n this.errorMapSrc = Array.isArray(value)\n ? (value as string[]).reduce((acc, err) => ({ ...acc, [err]: undefined }), {})\n : value === true\n ? {}\n : value || undefined;\n this.showErrorsIfTimeout() || this.showErrorsIfNoFocus();\n }\n }\n\n componentWillRender(): void {\n this.onErrorsChanged(this.errors);\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n render() {\n return (\n <Host>\n <div class={{ 'label-container': true, hidden: this.labelHidden }}>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={`tags-${this.id}-input`} part=\"label\">\n <span class=\"label-wrapper\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n <div class=\"label-metadata\">\n {!this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.optional')})\n </span>\n )}\n {this.required && this.requiredMarker?.startsWith('required') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.required')})\n </span>\n )}\n </div>\n </span>\n </label>\n )}\n </div>\n <div class={{ 'input-wrapper': true, 'input-disabled': this.disabled, 'input-invalid': this.invalid }}>\n {this.value?.map(value => (\n <div class=\"tag-pill\">\n <span>{value}</span>\n {!this.disabled && (\n <cat-button\n size=\"xs\"\n variant=\"text\"\n icon=\"$cat:select-clear\"\n iconOnly\n a11yLabel={i18n.t('select.deselect')}\n onClick={() => this.deselect(value)}\n tabIndex={-1}\n ></cat-button>\n )}\n </div>\n ))}\n <div class=\"input-inner-wrapper\">\n <input\n {...this.nativeAttributes}\n part=\"input\"\n id={`tags-${this.id}-input`}\n class=\"tags-input\"\n role=\"combobox\"\n ref={el => (this.input = el)}\n aria-invalid={this.invalid ? 'true' : undefined}\n aria-describedby={this.hasHint ? this.id + '-hint' : undefined}\n onInput={this.onInput.bind(this)}\n placeholder={this.placeholder}\n disabled={this.disabled}\n ></input>\n {this.clearable && !this.disabled && (this.value?.length ?? 0) > 0 && (\n <cat-button\n class=\"clearable\"\n icon=\"$cat:input-close\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t('input.clear')}\n onClick={this.clear.bind(this)}\n data-dropdown-no-close\n ></cat-button>\n )}\n {this.invalid && <cat-icon icon=\"$cat:input-error\" class=\"icon-suffix cat-text-danger\" size=\"l\"></cat-icon>}\n </div>\n </div>\n {this.hasHint && (\n <CatFormHint\n id={this.id}\n hint={this.hint}\n slottedHint={this.hasSlottedHint && <slot name=\"hint\"></slot>}\n errorMap={this.errorMap}\n />\n )}\n </Host>\n );\n }\n\n private onInput() {\n const currentValue = [\n ...new Set(this.input?.value?.split(this.createSplitRegex(this.tagCreationChars)) ?? [])\n ].filter(value => !!value && !this.value?.includes(value));\n if (currentValue.length > 1) {\n this.value = [...(this.value ?? []), ...currentValue];\n this.catChange.emit(this.value);\n if (this.input) {\n this.input.value = '';\n }\n }\n }\n\n private clear() {\n this.value = [];\n this.catChange.emit(this.value);\n if (this.input) {\n this.input.value = '';\n }\n }\n\n private deselect(value: string) {\n this.value = this.value?.filter(element => element !== value);\n }\n\n private showErrors() {\n this.errorMap = this.errorMapSrc;\n }\n\n private errorUpdateTimeoutId?: number;\n private showErrorsIfTimeout() {\n const errorUpdate = coerceNumber(this.errorUpdate, null);\n if (errorUpdate !== null) {\n typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);\n this.errorUpdateTimeoutId = window.setTimeout(() => this.showErrors(), errorUpdate);\n return true;\n }\n return false;\n }\n\n private showErrorsIfNoFocus() {\n const hasFocus = document.activeElement === this.hostElement || document.activeElement === this.input;\n if (!hasFocus) {\n this.showErrors();\n }\n }\n\n private createSplitRegex(delimiters: string[]): RegExp {\n // Escape special regex characters in the array\n const escapedDelimiters = delimiters.map(delimiter => delimiter.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'));\n\n // Add newline characters to the list of delimiters\n escapedDelimiters.push('\\\\n', '\\\\r');\n\n // Join the escaped delimiters to create a character class\n const regexPattern = `[${escapedDelimiters.join('')}]`;\n\n return new RegExp(regexPattern, 'g');\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { newSpecPage } from "@stencil/core/testing";
2
+ import { CatTag } from "./cat-tag";
3
+ describe('cat-tag', () => {
4
+ it('renders', async () => {
5
+ const page = await newSpecPage({
6
+ components: [CatTag],
7
+ html: `<cat-tag></cat-tag>`
8
+ });
9
+ expect(page.root).toEqualHtml(`
10
+ <cat-tag>
11
+ <mock:shadow-root>
12
+ <div class="label-container"></div>
13
+ <div class="input-wrapper">
14
+ <div class="input-inner-wrapper">
15
+ <input class="tags-input" id="tags-cat-input-0-input" part="input" role="combobox">
16
+ </div>
17
+ </div>
18
+ </mock:shadow-root>
19
+ </cat-tag>
20
+ `);
21
+ });
22
+ });
23
+ //# sourceMappingURL=cat-tag.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-tag.spec.js","sourceRoot":"","sources":["../../../src/components/cat-tag/cat-tag.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,qBAAqB;SAC5B,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;KAW7B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { CatTag } from './cat-tag';\n\ndescribe('cat-tag', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [CatTag],\n html: `<cat-tag></cat-tag>`\n });\n expect(page.root).toEqualHtml(`\n <cat-tag>\n <mock:shadow-root>\n <div class=\"label-container\"></div>\n <div class=\"input-wrapper\">\n <div class=\"input-inner-wrapper\">\n <input class=\"tags-input\" id=\"tags-cat-input-0-input\" part=\"input\" role=\"combobox\">\n </div>\n </div>\n </mock:shadow-root>\n </cat-tag>\n `);\n });\n});\n"]}
@@ -88,15 +88,15 @@ export class CatTextarea {
88
88
  }
89
89
  }
90
90
  render() {
91
- return (h(Host, { key: '3fb70b99dd5e227421428c44b4a2f1b78e3a9624' }, h("div", { key: '1779847f30a6f47cfe36565dc3a73f13c25efb74', class: {
91
+ return (h(Host, { key: 'a0869be16c6763ab0a53c176ca2c62f359ac5e1f' }, h("div", { key: '9287759dd8d94f3ce19d1d7a6fcc4a79ac2d93d1', class: {
92
92
  'textarea-field': true,
93
93
  'textarea-horizontal': this.horizontal
94
- } }, h("div", { key: '3e52881679e5718256ae474de772e4ff6b7a6e04', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { key: '5a91b34d85f90d4ae0c1430d4824f48dd6345e1d', htmlFor: this.id, part: "label" }, h("span", { key: 'da5084e4e79b564795e534f7ab4928ca6b660f0b', class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { key: '63caadae96c67353d319524bec69caa39aaed134', name: "label" })) || this.label, h("div", { key: '2487576ec974be3157ea2bd88b351a7a2c69549e', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { key: 'e79283c2e1776f88a64be12b56e9360a579ddb01', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { key: '667b799f8d9650853bc9acc7be5fa2f5050b6533', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")")), this.maxLength && (h("div", { key: '715ff632acb1c2f33d3839ecbbf38b96ab0b1f94', class: "label-character-count", "aria-hidden": "true" }, this.value?.length ?? 0, "/", this.maxLength))))))), h("div", { key: '3c235dd0387974ec8319985a4faa14a62f130f5e', class: "textarea-container" }, h("div", { key: 'b57634d98428025e07df6a77e41545c08afa1d16', class: {
94
+ } }, h("div", { key: '9ea634678136006027e77c0c78f78d5e82d3b645', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { key: '555c51a445aec5c7aef96005b64a8c72b7984e8b', htmlFor: this.id, part: "label" }, h("span", { key: '90c76a8ad82c5b76f107ece9903ede13c393f804', class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { key: 'c3a63aa2bea65bda933b3d1b0da2020e838498e4', name: "label" })) || this.label, h("div", { key: 'd55eb901ef8ca67d039dfe35158e3b5368dfa45e', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { key: 'ff14b950bdf948f1722e317f7a8dd96acf74a3c4', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { key: 'b0aca208498cec359cd11ce4553d27d749f418da', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")")), this.maxLength && (h("div", { key: 'bf211a3f7947ea2b702253bf0cc526a4cb284d24', class: "label-character-count", "aria-hidden": "true" }, this.value?.length ?? 0, "/", this.maxLength))))))), h("div", { key: 'fc55f53090b133715cd25eaf01b4503b00978f9c', class: "textarea-container" }, h("div", { key: '7ae02ac97e0043845b07eec1a7db5c6ccde983e9', class: {
95
95
  'textarea-wrapper': true,
96
96
  'textarea-readonly': this.readonly,
97
97
  'textarea-disabled': this.disabled,
98
98
  'textarea-invalid': this.invalid
99
- } }, h("textarea", { key: 'eea177cb65a95b65e95458056bc24af8879207ee', ...this.nativeAttributes, part: "textarea", ref: el => (this.textarea = el), id: this.id, disabled: this.disabled, maxlength: this.maxLength, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, rows: this.rows, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hasHint ? this.id + '-hint' : undefined }), this.invalid && (h("cat-icon", { key: '9d21adf9b86a2c7487f7e3c976bd88773114322c', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l", onClick: () => this.textarea.focus() }))), this.hasHint && (h(CatFormHint, { key: '04c7af649b204b083ea83cfdcaf9a05829de5671', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap }))))));
99
+ } }, h("textarea", { key: 'e75a42ba20f04e17f2e463f75196530cbc197aec', ...this.nativeAttributes, part: "textarea", ref: el => (this.textarea = el), id: this.id, disabled: this.disabled, maxlength: this.maxLength, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, rows: this.rows, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hasHint ? this.id + '-hint' : undefined }), this.invalid && (h("cat-icon", { key: 'd452062caeed39cf3cf9f06bcaeccb36d62ff5fe', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l", onClick: () => this.textarea.focus() }))), this.hasHint && (h(CatFormHint, { key: '551c054a13ec4d51f43244b7215303ac5bcd1969', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap }))))));
100
100
  }
101
101
  get hasHint() {
102
102
  return !!this.hint || !!this.hasSlottedHint || this.invalid;
@@ -141,14 +141,14 @@ export class CatTime {
141
141
  this.input?.clear();
142
142
  }
143
143
  render() {
144
- return (h(Host, { key: '4a30c978fb4c4aa6f1c412084013ab86316feb5a' }, h("cat-input", { key: 'a41b9ee3fde454364ef48689b12359e11ebb58c8', class: "cat-time-input", ref: el => (this.input = el), requiredMarker: this.requiredMarker, horizontal: this.horizontal, autoComplete: this.autoComplete, clearable: this.clearable, disabled: this.disabled, hint: this.hint, icon: this.icon, iconRight: this.iconRight, identifier: this.identifier, label: this.label, labelHidden: this.labelHidden, name: this.name, placeholder: this.placeholder, textPrefix: this.textPrefix, textSuffix: this.textSuffix, readonly: this.readonly, required: this.required, value: this.format(this.selectionTime, false), errors: this.errors, errorUpdate: this.errorUpdate, nativeAttributes: this.nativeAttributes, onCatFocus: e => this.catFocus.emit(e.detail), onCatBlur: e => this.onInputBlur(e.detail) }, h("span", { key: '9d8f9b3984b2ad08c45dce0e24c0b70c1db0e4cd', slot: "label" }, this.hasSlottedLabel && h("slot", { key: '676c762a9769f97e1eb9df102fbbd72dfd1c54c2', name: "label" }), !this.hasSlottedLabel && this.label, h("span", { key: '4af7aa9f2ad7b46af678cfea678d86d9b0248739', class: "label-aria" }, " (HH:mm)")), h("div", { key: 'ac9ab4a5ff2fed403c013b99a96a9cc6f4f99f8c', slot: "addon", class: "cat-time-addon" }, this.locale.timeFormat === '12' && (h("cat-button", { key: '5ac32c5a59ac3bb4ca0489fda5fbbe4cf547901a', class: "cat-time-format", disabled: this.disabled || this.readonly, onCatClick: () => this.toggleAm() }, this.isAm ? 'AM' : 'PM')), h("cat-dropdown", { key: 'e68a03d15d25585829ea5f9b5972c9b463709ac5', slot: "addon", placement: this.placement }, h("cat-button", { key: '36d65533a6a5081513350a3c52283477a96613b8', slot: "trigger", class: "cat-time-toggle", disabled: this.disabled || this.readonly, icon: "$cat:timepicker-clock", iconOnly: true, a11yLabel: this.selectionTime ? `${this.locale.change}, ${this.format(this.selectionTime)}` : this.locale.choose }), h("nav", { key: 'd90d221857f4c5508cdc68476a732f62ba7a1c04', slot: "content", class: "cat-nav" }, h("ul", { key: '255fe6f4fe316000b2b79ebb4638feec636ea230' }, this.timeArray().map(time => {
144
+ return (h(Host, { key: '55e285241d8a5bf961a080839bf70d795c7ab108' }, h("cat-input", { key: '6c5641ac8ad4d352f66920cef8611947b4619d92', class: "cat-time-input", ref: el => (this.input = el), requiredMarker: this.requiredMarker, horizontal: this.horizontal, autoComplete: this.autoComplete, clearable: this.clearable, disabled: this.disabled, hint: this.hint, icon: this.icon, iconRight: this.iconRight, identifier: this.identifier, label: this.label, labelHidden: this.labelHidden, name: this.name, placeholder: this.placeholder, textPrefix: this.textPrefix, textSuffix: this.textSuffix, readonly: this.readonly, required: this.required, value: this.format(this.selectionTime, false), errors: this.errors, errorUpdate: this.errorUpdate, nativeAttributes: this.nativeAttributes, onCatFocus: e => this.catFocus.emit(e.detail), onCatBlur: e => this.onInputBlur(e.detail) }, h("span", { key: '3482556a1876b19688b4e103a13977af291bb44f', slot: "label" }, this.hasSlottedLabel && h("slot", { key: 'f095f65a021efcf4b96ecd53d9418039fd85935c', name: "label" }), !this.hasSlottedLabel && this.label, h("span", { key: '71287b6ed9276ecc58c40b5003feb5105550fddc', class: "label-aria" }, " (HH:mm)")), h("div", { key: '94fd09f72a3fb70e62b2108ada2b2bee616342d3', slot: "addon", class: "cat-time-addon" }, this.locale.timeFormat === '12' && (h("cat-button", { key: 'c86f00f677809baced1decc8be879830175365a0', class: "cat-time-format", disabled: this.disabled || this.readonly, onCatClick: () => this.toggleAm() }, this.isAm ? 'AM' : 'PM')), h("cat-dropdown", { key: 'e01c696cbaac7fd5fd81d2fea42d1714478973f6', slot: "addon", placement: this.placement }, h("cat-button", { key: '2acde78757bc009b10a9ee77522d53c88b31e633', slot: "trigger", class: "cat-time-toggle", disabled: this.disabled || this.readonly, icon: "$cat:timepicker-clock", iconOnly: true, a11yLabel: this.selectionTime ? `${this.locale.change}, ${this.format(this.selectionTime)}` : this.locale.choose }), h("nav", { key: '07c46ce342cf7589f691336cf06ce6ca173b97ac', slot: "content", class: "cat-nav" }, h("ul", { key: '6132f2e1e0d65c960dbb8f2930dc2e80a145b30e' }, this.timeArray().map(time => {
145
145
  const isoTime = formatIso(time);
146
146
  const disabled = isBefore(time, this.min ?? null) || isAfter(time, this.max ?? null);
147
147
  return (h("li", null, h("cat-button", { class: {
148
148
  'cat-nav-item': true,
149
149
  'time-disabled': disabled
150
150
  }, disabled: disabled, active: isoTime === this.value, color: isoTime === this.value ? 'primary' : 'secondary', variant: isoTime === this.value ? 'filled' : 'outlined', onCatClick: () => this.select(time), "data-time": isoTime }, this.format(time))));
151
- }))))), this.hasSlottedHint && (h("span", { key: '708612e8b91925ca2bce0c6e997fea9de5316ef2', slot: "hint" }, h("slot", { key: '13736745e51441ccfd65172a41b0aec13ec07d32', name: "hint" }))))));
151
+ }))))), this.hasSlottedHint && (h("span", { key: '0609dce2baff97ce679df5571e4f53ecf503bafd', slot: "hint" }, h("slot", { key: '8288f3f2bb0695edeba3e5f39a344e2364120ddd', name: "hint" }))))));
152
152
  }
153
153
  timeArray() {
154
154
  const result = [];
@@ -58,13 +58,13 @@ export class CatToggle {
58
58
  this.input.blur();
59
59
  }
60
60
  render() {
61
- return (h(Host, { key: 'b906a3bd143e55e0863dc0ac70fc46a376f4db43' }, h("label", { key: 'b02e86fbbced890b105613308913e3cb6a6a4b6f', htmlFor: this.id, class: {
61
+ return (h(Host, { key: 'db30b9f0e1b56af56a9ca385f8dd6f4a458c6bfb' }, h("label", { key: '6aa4f65e9ffd8075214738dd31e7684ac451828a', htmlFor: this.id, class: {
62
62
  'is-hidden': this.labelHidden,
63
63
  'is-disabled': this.disabled,
64
64
  'label-left': this.labelLeft,
65
65
  'align-center': this.alignment === 'center',
66
66
  'align-end': this.alignment === 'bottom'
67
- } }, h("input", { key: '002b1e2d072dd6af928f8f5a2d7587e9aff5c0ef', ...this.nativeAttributes, part: "input", ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, class: "form-check-input", role: "switch", onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), "aria-describedby": this.hasHint ? this.id + '-hint' : undefined }), h("span", { key: 'de90b93a6b57dafbf9b94b2a703561fa2fc1ad35', class: "toggle" }), h("span", { key: '728a1e8610898618ec56477d9b00b558e9273c43', class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { key: 'feb997c081900bc9fb9d6673b8c95309d1cd5fd5', name: "label" })) || this.label)), this.hasHint && (h("div", { key: '5c3836d9c44c4c69858afd27d9bddaaa88fc0ec8', class: { 'hint-wrapper': true, 'label-left': this.labelLeft } }, h("div", { key: '72d2727df085f120545889f1742fdd8c5600c8d1', class: "toggle-placeholder" }), h(CatFormHint, { key: '30f07216d0c4b9b19c425089c8b009b5a8ee6d75', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }) })))));
67
+ } }, h("input", { key: '872bb5e3105a095254b2e98b21bf3718a238a98e', ...this.nativeAttributes, part: "input", ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, class: "form-check-input", role: "switch", onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), "aria-describedby": this.hasHint ? this.id + '-hint' : undefined }), h("span", { key: 'a828a70dfbcaee3cb8b8a63c046b99496c16c9f5', class: "toggle" }), h("span", { key: '560090efe2c053936d3274b11d8eeb9cb10ecaef', class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { key: '5b5a246d71cb380eeb509db0de46a9a5f903ad01', name: "label" })) || this.label)), this.hasHint && (h("div", { key: 'a5686f0863a51f89515a1609f151b131858adda2', class: { 'hint-wrapper': true, 'label-left': this.labelLeft } }, h("div", { key: '229ac1985dd48349756d899617fb083acff08f8b', class: "toggle-placeholder" }), h(CatFormHint, { key: '3da05ddafe48eca22e5abdb402021dff3a5660eb', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }) })))));
68
68
  }
69
69
  get hasHint() {
70
70
  return !!this.hint || !!this.hasSlottedHint;