@haiilo/catalyst 0.14.3 → 0.15.2

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 (65) 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/index.cdn.js +17 -12
  4. package/dist/catalyst/p-7fff102c.entry.js +12 -0
  5. package/dist/catalyst/p-7fff102c.entry.js.map +1 -0
  6. package/dist/cjs/{cat-alert_22.cjs.entry.js → cat-alert_24.cjs.entry.js} +2234 -19
  7. package/dist/cjs/cat-alert_24.cjs.entry.js.map +1 -0
  8. package/dist/cjs/catalyst.cjs.js +1 -1
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/collection/collection-manifest.json +2 -0
  11. package/dist/collection/components/cat-badge/cat-badge.css +5 -5
  12. package/dist/collection/components/cat-button/cat-button.css +4 -0
  13. package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -0
  14. package/dist/collection/components/cat-input/cat-input.css +1 -0
  15. package/dist/collection/components/cat-scrollable/cat-scrollable.css +0 -1
  16. package/dist/collection/components/cat-select-remote/cat-select-remote.css +210 -0
  17. package/dist/collection/components/cat-select-remote/cat-select-remote.js +818 -0
  18. package/dist/collection/components/cat-select-remote/cat-select-remote.js.map +1 -0
  19. package/dist/collection/components/cat-select-remote-test/cat-select-remote-test.js +1288 -0
  20. package/dist/collection/components/cat-select-remote-test/cat-select-remote-test.js.map +1 -0
  21. package/dist/collection/index.cdn.js +17 -12
  22. package/dist/collection/index.js.map +1 -1
  23. package/dist/components/cat-badge.js +1 -1
  24. package/dist/components/cat-badge.js.map +1 -1
  25. package/dist/components/cat-button2.js +1 -1
  26. package/dist/components/cat-button2.js.map +1 -1
  27. package/dist/components/cat-checkbox.js +1 -115
  28. package/dist/components/cat-checkbox.js.map +1 -1
  29. package/dist/components/cat-checkbox2.js +119 -0
  30. package/dist/components/cat-checkbox2.js.map +1 -0
  31. package/dist/components/cat-input.js +1 -1
  32. package/dist/components/cat-input.js.map +1 -1
  33. package/dist/components/cat-scrollable.js +1 -1355
  34. package/dist/components/cat-scrollable.js.map +1 -1
  35. package/dist/components/cat-scrollable2.js +1359 -0
  36. package/dist/components/cat-scrollable2.js.map +1 -0
  37. package/dist/components/cat-select-remote-test.d.ts +11 -0
  38. package/dist/components/cat-select-remote-test.js +1368 -0
  39. package/dist/components/cat-select-remote-test.js.map +1 -0
  40. package/dist/components/cat-select-remote.d.ts +11 -0
  41. package/dist/components/cat-select-remote.js +8 -0
  42. package/dist/components/cat-select-remote.js.map +1 -0
  43. package/dist/components/cat-select-remote2.js +987 -0
  44. package/dist/components/cat-select-remote2.js.map +1 -0
  45. package/dist/components/cat-skeleton.js +1 -71
  46. package/dist/components/cat-skeleton.js.map +1 -1
  47. package/dist/components/cat-skeleton2.js +75 -0
  48. package/dist/components/cat-skeleton2.js.map +1 -0
  49. package/dist/components/index.d.ts +2 -0
  50. package/dist/components/index.js +2 -0
  51. package/dist/components/index.js.map +1 -1
  52. package/dist/esm/{cat-alert_22.entry.js → cat-alert_24.entry.js} +2233 -20
  53. package/dist/esm/cat-alert_24.entry.js.map +1 -0
  54. package/dist/esm/catalyst.js +1 -1
  55. package/dist/esm/loader.js +1 -1
  56. package/dist/types/components/cat-select-remote/autosize.d.ts +1 -0
  57. package/dist/types/components/cat-select-remote/cat-select-remote.d.ts +164 -0
  58. package/dist/types/components/cat-select-remote-test/cat-select-remote-test.d.ts +6 -0
  59. package/dist/types/components.d.ts +149 -0
  60. package/dist/types/index.d.ts +3 -0
  61. package/package.json +5 -4
  62. package/dist/catalyst/p-45547af1.entry.js +0 -12
  63. package/dist/catalyst/p-45547af1.entry.js.map +0 -1
  64. package/dist/cjs/cat-alert_22.cjs.entry.js.map +0 -1
  65. package/dist/esm/cat-alert_22.entry.js.map +0 -1
@@ -0,0 +1,818 @@
1
+ import { autoUpdate, computePosition, offset } from '@floating-ui/dom';
2
+ import { Component, Element, Event, h, Host, Listen, Method, Prop, State, Watch } from '@stencil/core';
3
+ import autosizeInput from 'autosize-input';
4
+ import { catchError, debounce, distinctUntilChanged, filter, first, of, scan, startWith, Subject, switchMap, takeWhile, tap, timer } from 'rxjs';
5
+ import { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';
6
+ import log from 'loglevel';
7
+ import { CatFormHint } from '../cat-form-hint/cat-form-hint';
8
+ const INIT_STATE = {
9
+ term: '',
10
+ isOpen: false,
11
+ isLoading: false,
12
+ isResolving: false,
13
+ options: [],
14
+ selection: [],
15
+ activeOptionIndex: -1,
16
+ activeSelectionIndex: -1
17
+ };
18
+ let nextUniqueId = 0;
19
+ /**
20
+ * Select lets user choose one option from an options' menu. Consider using
21
+ * select when you have 6 or more options. Select component supports any content
22
+ * type.
23
+ *
24
+ * @slot hint - Optional hint element to be displayed with the select.
25
+ * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.
26
+ * @part label - The label content.
27
+ */
28
+ export class CatSelectRemote {
29
+ constructor() {
30
+ this.i18n = CatI18nRegistry.getInstance();
31
+ this.id = `cat-input-${nextUniqueId++}`;
32
+ this.term$ = new Subject();
33
+ this.more$ = new Subject();
34
+ this.state = INIT_STATE;
35
+ this.hasSlottedLabel = false;
36
+ /**
37
+ * Enable multiple selection.
38
+ */
39
+ this.multiple = false;
40
+ /**
41
+ * The debounce time for the search.
42
+ */
43
+ this.debounce = 250;
44
+ /**
45
+ * The placement of the select.
46
+ */
47
+ this.placement = 'bottom-start';
48
+ /**
49
+ * Whether the select is disabled.
50
+ */
51
+ this.disabled = false;
52
+ /**
53
+ * The label for the select.
54
+ */
55
+ this.label = '';
56
+ /**
57
+ * The name of the form control. Submitted with the form as part of a name/value pair.
58
+ */
59
+ this.name = '';
60
+ /**
61
+ * Visually hide the label, but still show it to assistive technologies like screen readers.
62
+ */
63
+ this.labelHidden = false;
64
+ /**
65
+ * A value is required or must be checked for the form to be submittable.
66
+ */
67
+ this.required = false;
68
+ /**
69
+ * Whether the select should show a clear button.
70
+ */
71
+ this.clearable = false;
72
+ }
73
+ onConnectorChange(connector) {
74
+ this.reset(connector);
75
+ this.resolve();
76
+ }
77
+ onStateChange(newState, oldState) {
78
+ var _a;
79
+ const changed = (key) => newState[key] !== oldState[key];
80
+ if (changed('activeOptionIndex')) {
81
+ if (this.state.activeOptionIndex >= 0) {
82
+ const option = (_a = this.dropdown) === null || _a === void 0 ? void 0 : _a.querySelector(`#select-${this.id}-option-${this.state.activeOptionIndex}`);
83
+ option === null || option === void 0 ? void 0 : option.scrollIntoView({ block: 'nearest' });
84
+ }
85
+ }
86
+ if (changed('selection')) {
87
+ if (!this.multiple && this.state.selection.length) {
88
+ this.hide();
89
+ }
90
+ const idsSelected = this.state.selection.map(item => item.item.id);
91
+ if (this.multiple) {
92
+ this.value = idsSelected;
93
+ }
94
+ else {
95
+ this.value = idsSelected.length ? idsSelected[0] : '';
96
+ }
97
+ this.catChange.emit();
98
+ }
99
+ }
100
+ componentDidLoad() {
101
+ if (this.input) {
102
+ autosizeInput(this.input);
103
+ }
104
+ if (this.trigger && this.dropdown) {
105
+ autoUpdate(this.trigger, this.dropdown, () => this.update());
106
+ }
107
+ }
108
+ componentWillRender() {
109
+ this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
110
+ if (!this.label && !this.hasSlottedLabel) {
111
+ log.error('[A11y] Missing ARIA label on select', this);
112
+ }
113
+ }
114
+ onBlur(event) {
115
+ if (!this.multiple && this.state.activeOptionIndex >= 0) {
116
+ this.select(this.state.options[this.state.activeOptionIndex]);
117
+ }
118
+ this.hide();
119
+ this.patchState({ activeSelectionIndex: -1 });
120
+ this.catBlur.emit(event);
121
+ }
122
+ onKeyDown(event) {
123
+ var _a, _b, _c, _d, _e;
124
+ const isInputFocused = ((_a = this.hostElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) === this.input;
125
+ if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
126
+ this.onArrowKeyDown(event);
127
+ }
128
+ else if (['Enter', ' '].includes(event.key)) {
129
+ if (isInputFocused && this.state.activeOptionIndex >= 0) {
130
+ event.preventDefault();
131
+ if (this.multiple) {
132
+ this.toggle(this.state.options[this.state.activeOptionIndex]);
133
+ }
134
+ else {
135
+ this.select(this.state.options[this.state.activeOptionIndex]);
136
+ }
137
+ }
138
+ }
139
+ else if (event.key === 'Escape') {
140
+ this.hide();
141
+ }
142
+ else if (event.key === 'Backspace' || event.key === 'Delete') {
143
+ (_b = this.input) === null || _b === void 0 ? void 0 : _b.focus();
144
+ if (!this.multiple || !this.state.term || (((_c = this.input) === null || _c === void 0 ? void 0 : _c.selectionStart) === 0 && event.key === 'Backspace')) {
145
+ if (this.state.activeSelectionIndex >= 0) {
146
+ this.deselect(this.state.selection[this.state.activeSelectionIndex].item.id);
147
+ }
148
+ else if (this.state.selection.length) {
149
+ const selectionClone = [...this.state.selection];
150
+ selectionClone.pop();
151
+ this.patchState({ selection: selectionClone });
152
+ }
153
+ }
154
+ }
155
+ else if (event.key === 'Tab') {
156
+ (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.setAttribute('tabindex', '-1');
157
+ if (this.multiple) {
158
+ this.patchState({ activeSelectionIndex: -1, activeOptionIndex: -1 });
159
+ }
160
+ else if (this.state.activeOptionIndex >= 0) {
161
+ this.select(this.state.options[this.state.activeOptionIndex]);
162
+ }
163
+ }
164
+ else if (event.key.length === 1) {
165
+ (_e = this.input) === null || _e === void 0 ? void 0 : _e.focus();
166
+ }
167
+ }
168
+ onKeyUp(event) {
169
+ var _a, _b, _c, _d, _e;
170
+ if (event.key === 'Tab' && !event.shiftKey) {
171
+ ((_a = this.hostElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) === this.trigger && ((_b = this.input) === null || _b === void 0 ? void 0 : _b.focus());
172
+ if (((_c = this.hostElement.shadowRoot) === null || _c === void 0 ? void 0 : _c.activeElement) === this.input) {
173
+ this.show();
174
+ }
175
+ }
176
+ else if (event.key === 'Tab' && event.shiftKey) {
177
+ const clearButton = (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.querySelector(`#select-clear-btn-${this.id}`);
178
+ if (clearButton) {
179
+ ((_e = this.hostElement.shadowRoot) === null || _e === void 0 ? void 0 : _e.activeElement) === clearButton && this.show();
180
+ }
181
+ else {
182
+ this.show();
183
+ }
184
+ }
185
+ }
186
+ /**
187
+ * Connect the functions of the select
188
+ *
189
+ * @param connector - The {@link CatSelectRemoteConnector} of the select.
190
+ */
191
+ async connect(connector) {
192
+ var _a;
193
+ this.connector = connector;
194
+ let number$;
195
+ (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
196
+ this.subscription = this.term$
197
+ .asObservable()
198
+ .pipe(debounce(term => (term ? timer(this.debounce) : of(0))), distinctUntilChanged(), tap(() => (number$ = this.more$.pipe(filter(() => !this.state.isLoading), scan(n => n + 1, 0), startWith(0)))), tap(() => this.patchState({ options: [] })), switchMap(term => number$.pipe(tap(() => this.patchState({ isLoading: true })), switchMap(number => this.connectorSafe.retrieve(term, number)), tap(page => this.patchState({ isLoading: false, totalElements: page.totalElements })), takeWhile(page => !page.last, true), scan((items, page) => [...items, ...page.content], []))))
199
+ .subscribe(items => this.patchState({
200
+ options: items === null || items === void 0 ? void 0 : items.map(item => ({
201
+ item,
202
+ render: this.connectorSafe.render(item)
203
+ }))
204
+ }));
205
+ }
206
+ render() {
207
+ return (h(Host, null,
208
+ (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
209
+ h("span", { part: "label" },
210
+ (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label,
211
+ !this.required && (h("span", { class: "input-optional", "aria-hidden": "true" },
212
+ "(",
213
+ this.i18n.t('input.optional'),
214
+ ")"))))),
215
+ h("div", { class: { 'select-wrapper': true, 'select-disabled': this.disabled }, ref: el => (this.trigger = el), id: this.id, role: "combobox", "aria-expanded": this.state.isOpen || this.isPillboxActive(), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-required": this.required, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) },
216
+ h("div", { class: "select-wrapper-inner" },
217
+ this.multiple && this.state.selection.length ? (h("div", { id: `select-pillbox-${this.id}`, role: "listbox", "aria-orientation": "horizontal", class: "select-pills" }, this.state.selection.map((item, i) => (h("span", { class: {
218
+ pill: true,
219
+ 'select-no-open': true,
220
+ 'select-option-active': this.state.activeSelectionIndex === i
221
+ }, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` },
222
+ h("span", null, item.render.label),
223
+ !this.disabled && (h("cat-button", { size: "xs", variant: "text", icon: "16-cross", iconOnly: true, a11yLabel: this.i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1 }))))))) : null,
224
+ h("input", { class: "select-input", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, onInput: () => this.onInput(), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving })),
225
+ this.state.isResolving && h("cat-spinner", null),
226
+ (this.state.selection.length || this.state.term.length) &&
227
+ !this.disabled &&
228
+ !this.state.isResolving &&
229
+ this.clearable ? (h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "cross-circle-outlined", variant: "text", size: "s", a11yLabel: this.i18n.t('select.clear'), onClick: () => this.clear() })) : null,
230
+ !this.state.isResolving && (h("cat-button", { iconOnly: true, icon: "chevron-down-outlined", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? this.i18n.t('select.close') : this.i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving }))),
231
+ this.hintSection,
232
+ h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() },
233
+ h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` },
234
+ this.state.options.map((item, i) => (h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": this.isSelected(item.item.id) ? 'true' : 'false' }, this.multiple ? (h("cat-checkbox", { class: { 'select-option-active': this.state.activeOptionIndex === i }, checked: this.isSelected(item.item.id), tabIndex: -1, labelLeft: true, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onCatChange: e => {
235
+ this.toggle(item);
236
+ e.stopPropagation();
237
+ } },
238
+ h("span", { slot: "label", class: "select-option" },
239
+ h("span", { class: "select-option-label" }, item.render.label),
240
+ h("span", { class: "select-option-description" }, item.render.description)))) : (h("div", { class: {
241
+ 'select-option-single': true,
242
+ 'select-option-active': this.state.activeOptionIndex === i
243
+ }, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => this.select(item), tabIndex: -1 },
244
+ h("span", { class: "select-option-label" }, item.render.label),
245
+ h("span", { class: "select-option-description" }, item.render.description)))))),
246
+ this.state.isLoading
247
+ ? Array.from(Array(CatSelectRemote.SKELETON_COUNT)).map(() => (h("li", { class: "select-option-loading" },
248
+ h("cat-skeleton", { variant: "body", lines: 1 }),
249
+ h("cat-skeleton", { variant: "body", lines: 1 }))))
250
+ : !this.state.options.length && h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
251
+ }
252
+ get hintSection() {
253
+ const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
254
+ return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
255
+ }
256
+ get connectorSafe() {
257
+ if (this.connector) {
258
+ return this.connector;
259
+ }
260
+ throw new Error('CatSelectRemoteConnector not set');
261
+ }
262
+ resolve() {
263
+ var _a;
264
+ this.patchState({ isResolving: true });
265
+ let ids;
266
+ if (this.multiple) {
267
+ ids = this.value;
268
+ }
269
+ else {
270
+ ids = [this.value];
271
+ }
272
+ const data$ = ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
273
+ data$.pipe(catchError(() => of([]))).subscribe(items => this.patchState({
274
+ isResolving: false,
275
+ selection: items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })),
276
+ term: !this.multiple && items.length ? this.connectorSafe.render(items[0]).label : ''
277
+ }));
278
+ }
279
+ show() {
280
+ var _a;
281
+ if (!this.state.isOpen) {
282
+ this.patchState({ isOpen: true });
283
+ this.catOpen.emit();
284
+ this.term$.next(this.state.term);
285
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.remove('select-input-transparent-caret');
286
+ }
287
+ }
288
+ hide() {
289
+ if (this.state.isOpen) {
290
+ this.patchState({ isOpen: false, activeOptionIndex: -1 });
291
+ this.catClose.emit();
292
+ }
293
+ }
294
+ search(term) {
295
+ this.patchState({ term, activeOptionIndex: -1, activeSelectionIndex: -1 });
296
+ this.term$.next(term);
297
+ }
298
+ isSelected(id) {
299
+ return this.state.selection.findIndex(s => s.item.id === id) >= 0;
300
+ }
301
+ select(item) {
302
+ var _a;
303
+ if (!this.isSelected(item.item.id)) {
304
+ let newSelection;
305
+ if (this.multiple) {
306
+ newSelection = [...this.state.selection, item];
307
+ }
308
+ else {
309
+ newSelection = [item];
310
+ this.search(item.render.label);
311
+ }
312
+ this.patchState({ selection: newSelection });
313
+ }
314
+ if (!this.multiple) {
315
+ this.hide();
316
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
317
+ }
318
+ }
319
+ deselect(id) {
320
+ if (this.isSelected(id)) {
321
+ this.patchState({
322
+ selection: this.state.selection.filter(item => item.item.id !== id),
323
+ activeSelectionIndex: -1
324
+ });
325
+ }
326
+ }
327
+ toggle(item) {
328
+ this.isSelected(item.item.id) ? this.deselect(item.item.id) : this.select(item);
329
+ }
330
+ clear() {
331
+ if (this.input && this.state.term) {
332
+ this.patchState({ selection: [], options: [], term: '', activeOptionIndex: -1 });
333
+ this.term$.next('');
334
+ this.input.value = '';
335
+ }
336
+ else {
337
+ this.patchState({ selection: [] });
338
+ }
339
+ }
340
+ reset(connector) {
341
+ var _a;
342
+ this.connector = connector !== null && connector !== void 0 ? connector : this.connector;
343
+ (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
344
+ this.subscription = undefined;
345
+ this.state = INIT_STATE;
346
+ }
347
+ onClick(event) {
348
+ var _a, _b;
349
+ const elem = event.target;
350
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
351
+ (_b = this.input) === null || _b === void 0 ? void 0 : _b.focus();
352
+ if (elem === this.trigger ||
353
+ elem === this.input ||
354
+ elem.classList.contains('select-btn') ||
355
+ elem.nodeName === 'SPAN') {
356
+ this.state.isOpen ? this.hide() : this.show();
357
+ }
358
+ }
359
+ onInput() {
360
+ var _a;
361
+ this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '');
362
+ this.show();
363
+ }
364
+ update() {
365
+ if (this.trigger && this.dropdown) {
366
+ computePosition(this.trigger, this.dropdown, {
367
+ placement: this.placement,
368
+ middleware: [offset(CatSelectRemote.DROPDOWN_OFFSET)]
369
+ }).then(({ x, y }) => {
370
+ if (this.dropdown) {
371
+ Object.assign(this.dropdown.style, {
372
+ left: `${x}px`,
373
+ top: `${y}px`
374
+ });
375
+ }
376
+ });
377
+ }
378
+ }
379
+ patchState(update) {
380
+ this.state = Object.assign(Object.assign({}, this.state), update);
381
+ }
382
+ isPillboxActive() {
383
+ return this.state.activeSelectionIndex >= 0;
384
+ }
385
+ get activeDescendant() {
386
+ let activeDescendant = undefined;
387
+ if (this.state.activeOptionIndex >= 0) {
388
+ activeDescendant = `select-${this.id}-option-${this.state.activeOptionIndex}`;
389
+ }
390
+ else if (this.state.activeSelectionIndex >= 0) {
391
+ activeDescendant = `select-${this.id}-selection-${this.state.activeSelectionIndex}`;
392
+ }
393
+ return activeDescendant;
394
+ }
395
+ onArrowKeyDown(event) {
396
+ var _a, _b;
397
+ let preventDefault = false;
398
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
399
+ if (event.key === 'ArrowDown') {
400
+ preventDefault = true;
401
+ this.state.isOpen
402
+ ? this.patchState({
403
+ activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
404
+ activeSelectionIndex: -1
405
+ })
406
+ : this.show();
407
+ }
408
+ else if (event.key === 'ArrowUp') {
409
+ preventDefault = true;
410
+ this.state.activeOptionIndex >= 0
411
+ ? this.patchState({
412
+ activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
413
+ activeSelectionIndex: -1
414
+ })
415
+ : this.hide();
416
+ }
417
+ else if (event.key === 'ArrowLeft') {
418
+ if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
419
+ preventDefault = true;
420
+ let index;
421
+ this.state.activeSelectionIndex > 0
422
+ ? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
423
+ : (index = this.state.selection.length - 1);
424
+ this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
425
+ }
426
+ }
427
+ else if (event.key === 'ArrowRight') {
428
+ if (this.state.activeSelectionIndex >= 0) {
429
+ preventDefault = true;
430
+ let index = -1;
431
+ if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
432
+ index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
433
+ }
434
+ else if (!this.state.term) {
435
+ index = 0;
436
+ }
437
+ this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
438
+ }
439
+ }
440
+ if (preventDefault) {
441
+ event.preventDefault();
442
+ event.stopPropagation();
443
+ }
444
+ }
445
+ static get is() { return "cat-select-remote"; }
446
+ static get encapsulation() { return "shadow"; }
447
+ static get originalStyleUrls() { return {
448
+ "$": ["cat-select-remote.scss"]
449
+ }; }
450
+ static get styleUrls() { return {
451
+ "$": ["cat-select-remote.css"]
452
+ }; }
453
+ static get properties() { return {
454
+ "multiple": {
455
+ "type": "boolean",
456
+ "mutable": false,
457
+ "complexType": {
458
+ "original": "boolean",
459
+ "resolved": "boolean",
460
+ "references": {}
461
+ },
462
+ "required": false,
463
+ "optional": false,
464
+ "docs": {
465
+ "tags": [],
466
+ "text": "Enable multiple selection."
467
+ },
468
+ "attribute": "multiple",
469
+ "reflect": false,
470
+ "defaultValue": "false"
471
+ },
472
+ "debounce": {
473
+ "type": "number",
474
+ "mutable": false,
475
+ "complexType": {
476
+ "original": "number",
477
+ "resolved": "number",
478
+ "references": {}
479
+ },
480
+ "required": false,
481
+ "optional": false,
482
+ "docs": {
483
+ "tags": [],
484
+ "text": "The debounce time for the search."
485
+ },
486
+ "attribute": "debounce",
487
+ "reflect": false,
488
+ "defaultValue": "250"
489
+ },
490
+ "placement": {
491
+ "type": "string",
492
+ "mutable": false,
493
+ "complexType": {
494
+ "original": "Placement",
495
+ "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
496
+ "references": {
497
+ "Placement": {
498
+ "location": "import",
499
+ "path": "@floating-ui/dom"
500
+ }
501
+ }
502
+ },
503
+ "required": false,
504
+ "optional": false,
505
+ "docs": {
506
+ "tags": [],
507
+ "text": "The placement of the select."
508
+ },
509
+ "attribute": "placement",
510
+ "reflect": false,
511
+ "defaultValue": "'bottom-start'"
512
+ },
513
+ "value": {
514
+ "type": "string",
515
+ "mutable": true,
516
+ "complexType": {
517
+ "original": "string | string[]",
518
+ "resolved": "string | string[] | undefined",
519
+ "references": {}
520
+ },
521
+ "required": false,
522
+ "optional": true,
523
+ "docs": {
524
+ "tags": [],
525
+ "text": "The value of the select."
526
+ },
527
+ "attribute": "value",
528
+ "reflect": false
529
+ },
530
+ "disabled": {
531
+ "type": "boolean",
532
+ "mutable": false,
533
+ "complexType": {
534
+ "original": "boolean",
535
+ "resolved": "boolean",
536
+ "references": {}
537
+ },
538
+ "required": false,
539
+ "optional": false,
540
+ "docs": {
541
+ "tags": [],
542
+ "text": "Whether the select is disabled."
543
+ },
544
+ "attribute": "disabled",
545
+ "reflect": false,
546
+ "defaultValue": "false"
547
+ },
548
+ "placeholder": {
549
+ "type": "string",
550
+ "mutable": false,
551
+ "complexType": {
552
+ "original": "string",
553
+ "resolved": "string | undefined",
554
+ "references": {}
555
+ },
556
+ "required": false,
557
+ "optional": true,
558
+ "docs": {
559
+ "tags": [],
560
+ "text": "The placeholder text to display within the select."
561
+ },
562
+ "attribute": "placeholder",
563
+ "reflect": false
564
+ },
565
+ "hint": {
566
+ "type": "string",
567
+ "mutable": false,
568
+ "complexType": {
569
+ "original": "string | string[]",
570
+ "resolved": "string | string[] | undefined",
571
+ "references": {}
572
+ },
573
+ "required": false,
574
+ "optional": true,
575
+ "docs": {
576
+ "tags": [],
577
+ "text": "Optional hint text(s) to be displayed with the select."
578
+ },
579
+ "attribute": "hint",
580
+ "reflect": false
581
+ },
582
+ "label": {
583
+ "type": "string",
584
+ "mutable": false,
585
+ "complexType": {
586
+ "original": "string",
587
+ "resolved": "string",
588
+ "references": {}
589
+ },
590
+ "required": false,
591
+ "optional": false,
592
+ "docs": {
593
+ "tags": [],
594
+ "text": "The label for the select."
595
+ },
596
+ "attribute": "label",
597
+ "reflect": false,
598
+ "defaultValue": "''"
599
+ },
600
+ "name": {
601
+ "type": "string",
602
+ "mutable": false,
603
+ "complexType": {
604
+ "original": "string",
605
+ "resolved": "string",
606
+ "references": {}
607
+ },
608
+ "required": false,
609
+ "optional": false,
610
+ "docs": {
611
+ "tags": [],
612
+ "text": "The name of the form control. Submitted with the form as part of a name/value pair."
613
+ },
614
+ "attribute": "name",
615
+ "reflect": false,
616
+ "defaultValue": "''"
617
+ },
618
+ "labelHidden": {
619
+ "type": "boolean",
620
+ "mutable": false,
621
+ "complexType": {
622
+ "original": "boolean",
623
+ "resolved": "boolean",
624
+ "references": {}
625
+ },
626
+ "required": false,
627
+ "optional": false,
628
+ "docs": {
629
+ "tags": [],
630
+ "text": "Visually hide the label, but still show it to assistive technologies like screen readers."
631
+ },
632
+ "attribute": "label-hidden",
633
+ "reflect": false,
634
+ "defaultValue": "false"
635
+ },
636
+ "required": {
637
+ "type": "boolean",
638
+ "mutable": false,
639
+ "complexType": {
640
+ "original": "boolean",
641
+ "resolved": "boolean",
642
+ "references": {}
643
+ },
644
+ "required": false,
645
+ "optional": false,
646
+ "docs": {
647
+ "tags": [],
648
+ "text": "A value is required or must be checked for the form to be submittable."
649
+ },
650
+ "attribute": "required",
651
+ "reflect": false,
652
+ "defaultValue": "false"
653
+ },
654
+ "clearable": {
655
+ "type": "boolean",
656
+ "mutable": false,
657
+ "complexType": {
658
+ "original": "boolean",
659
+ "resolved": "boolean",
660
+ "references": {}
661
+ },
662
+ "required": false,
663
+ "optional": false,
664
+ "docs": {
665
+ "tags": [],
666
+ "text": "Whether the select should show a clear button."
667
+ },
668
+ "attribute": "clearable",
669
+ "reflect": false,
670
+ "defaultValue": "false"
671
+ }
672
+ }; }
673
+ static get states() { return {
674
+ "connector": {},
675
+ "state": {},
676
+ "hasSlottedLabel": {}
677
+ }; }
678
+ static get events() { return [{
679
+ "method": "catOpen",
680
+ "name": "catOpen",
681
+ "bubbles": true,
682
+ "cancelable": true,
683
+ "composed": true,
684
+ "docs": {
685
+ "tags": [],
686
+ "text": "Emitted when the select dropdown is opened."
687
+ },
688
+ "complexType": {
689
+ "original": "FocusEvent",
690
+ "resolved": "FocusEvent",
691
+ "references": {
692
+ "FocusEvent": {
693
+ "location": "global"
694
+ }
695
+ }
696
+ }
697
+ }, {
698
+ "method": "catClose",
699
+ "name": "catClose",
700
+ "bubbles": true,
701
+ "cancelable": true,
702
+ "composed": true,
703
+ "docs": {
704
+ "tags": [],
705
+ "text": "Emitted when the select dropdown is closed."
706
+ },
707
+ "complexType": {
708
+ "original": "FocusEvent",
709
+ "resolved": "FocusEvent",
710
+ "references": {
711
+ "FocusEvent": {
712
+ "location": "global"
713
+ }
714
+ }
715
+ }
716
+ }, {
717
+ "method": "catChange",
718
+ "name": "catChange",
719
+ "bubbles": true,
720
+ "cancelable": true,
721
+ "composed": true,
722
+ "docs": {
723
+ "tags": [],
724
+ "text": "Emitted when the value is changed."
725
+ },
726
+ "complexType": {
727
+ "original": "any",
728
+ "resolved": "any",
729
+ "references": {}
730
+ }
731
+ }, {
732
+ "method": "catBlur",
733
+ "name": "catBlur",
734
+ "bubbles": true,
735
+ "cancelable": true,
736
+ "composed": true,
737
+ "docs": {
738
+ "tags": [],
739
+ "text": "Emitted when the select loses the focus."
740
+ },
741
+ "complexType": {
742
+ "original": "FocusEvent",
743
+ "resolved": "FocusEvent",
744
+ "references": {
745
+ "FocusEvent": {
746
+ "location": "global"
747
+ }
748
+ }
749
+ }
750
+ }]; }
751
+ static get methods() { return {
752
+ "connect": {
753
+ "complexType": {
754
+ "signature": "(connector: CatSelectRemoteConnector) => Promise<void>",
755
+ "parameters": [{
756
+ "tags": [{
757
+ "name": "param",
758
+ "text": "connector - The {@link CatSelectRemoteConnector } of the select."
759
+ }],
760
+ "text": "- The {@link CatSelectRemoteConnector} of the select."
761
+ }],
762
+ "references": {
763
+ "Promise": {
764
+ "location": "global"
765
+ },
766
+ "CatSelectRemoteConnector": {
767
+ "location": "local"
768
+ },
769
+ "Observable": {
770
+ "location": "import",
771
+ "path": "rxjs"
772
+ },
773
+ "Item": {
774
+ "location": "local"
775
+ }
776
+ },
777
+ "return": "Promise<void>"
778
+ },
779
+ "docs": {
780
+ "text": "Connect the functions of the select",
781
+ "tags": [{
782
+ "name": "param",
783
+ "text": "connector - The {@link CatSelectRemoteConnector} of the select."
784
+ }]
785
+ }
786
+ }
787
+ }; }
788
+ static get elementRef() { return "hostElement"; }
789
+ static get watchers() { return [{
790
+ "propName": "connector",
791
+ "methodName": "onConnectorChange"
792
+ }, {
793
+ "propName": "state",
794
+ "methodName": "onStateChange"
795
+ }]; }
796
+ static get listeners() { return [{
797
+ "name": "blur",
798
+ "method": "onBlur",
799
+ "target": undefined,
800
+ "capture": false,
801
+ "passive": false
802
+ }, {
803
+ "name": "keydown",
804
+ "method": "onKeyDown",
805
+ "target": undefined,
806
+ "capture": false,
807
+ "passive": false
808
+ }, {
809
+ "name": "keyup",
810
+ "method": "onKeyUp",
811
+ "target": undefined,
812
+ "capture": false,
813
+ "passive": false
814
+ }]; }
815
+ }
816
+ CatSelectRemote.SKELETON_COUNT = 4;
817
+ CatSelectRemote.DROPDOWN_OFFSET = 4;
818
+ //# sourceMappingURL=cat-select-remote.js.map