@haiilo/catalyst 0.15.2 → 1.0.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 (131) hide show
  1. package/dist/catalyst/catalyst.css +2 -2
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/index.cdn.js +7 -17
  5. package/dist/catalyst/index.esm.js +1 -1
  6. package/dist/catalyst/p-081aece8.entry.js +10 -0
  7. package/dist/catalyst/p-081aece8.entry.js.map +1 -0
  8. package/dist/catalyst/p-10b0d7a2.js +10 -0
  9. package/dist/catalyst/p-10b0d7a2.js.map +1 -0
  10. package/dist/catalyst/{p-a255bd64.js → p-f80e3399.js} +1 -1
  11. package/dist/catalyst/p-f80e3399.js.map +1 -0
  12. package/dist/catalyst/scss/_variables.scss +4 -13
  13. package/dist/catalyst/scss/core/_nav.scss +1 -1
  14. package/dist/catalyst/scss/core/_typography.scss +20 -11
  15. package/dist/catalyst/scss/index.scss +0 -52
  16. package/dist/cjs/cat-alert_23.cjs.entry.js +7534 -0
  17. package/dist/cjs/cat-alert_23.cjs.entry.js.map +1 -0
  18. package/dist/cjs/{cat-notification-6a438ad1.js → cat-notification-bcb9fb86.js} +14 -12
  19. package/dist/cjs/cat-notification-bcb9fb86.js.map +1 -0
  20. package/dist/cjs/catalyst.cjs.js +2 -2
  21. package/dist/cjs/catalyst.cjs.js.map +1 -1
  22. package/dist/cjs/{index-c7955116.js → index-8ab22379.js} +1 -1
  23. package/dist/cjs/index-8ab22379.js.map +1 -0
  24. package/dist/cjs/index.cjs.js +1 -1
  25. package/dist/cjs/loader.cjs.js +2 -2
  26. package/dist/cjs/loader.cjs.js.map +1 -1
  27. package/dist/collection/collection-manifest.json +1 -2
  28. package/dist/collection/components/cat-alert/cat-alert.css +12 -13
  29. package/dist/collection/components/cat-badge/cat-badge.css +7 -9
  30. package/dist/collection/components/cat-card/cat-card.css +1 -1
  31. package/dist/collection/components/cat-checkbox/cat-checkbox.css +15 -1
  32. package/dist/collection/components/cat-input/cat-input.css +12 -1
  33. package/dist/collection/components/cat-radio/cat-radio.css +12 -1
  34. package/dist/collection/components/cat-select/cat-select.css +121 -552
  35. package/dist/collection/components/cat-select/cat-select.js +534 -343
  36. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  37. package/dist/collection/components/{cat-select-remote-test/cat-select-remote-test.js → cat-select-demo/cat-select-demo.js} +71 -7
  38. package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -0
  39. package/dist/collection/components/cat-tabs/cat-tabs.css +1 -1
  40. package/dist/collection/components/cat-textarea/cat-textarea.css +5 -1
  41. package/dist/collection/components/cat-toggle/cat-toggle.css +16 -1
  42. package/dist/collection/index.cdn.js +7 -17
  43. package/dist/collection/index.js.map +1 -1
  44. package/dist/collection/scss/_variables.scss +4 -13
  45. package/dist/collection/scss/core/_nav.scss +1 -1
  46. package/dist/collection/scss/core/_typography.scss +20 -11
  47. package/dist/collection/scss/index.scss +0 -52
  48. package/dist/components/cat-alert.js +1 -1
  49. package/dist/components/cat-alert.js.map +1 -1
  50. package/dist/components/cat-avatar.js +1 -118
  51. package/dist/components/cat-avatar.js.map +1 -1
  52. package/dist/components/cat-avatar2.js +122 -0
  53. package/dist/components/cat-avatar2.js.map +1 -0
  54. package/dist/components/cat-badge.js +1 -1
  55. package/dist/components/cat-badge.js.map +1 -1
  56. package/dist/components/cat-button2.js.map +1 -1
  57. package/dist/components/cat-card.js +1 -1
  58. package/dist/components/cat-card.js.map +1 -1
  59. package/dist/components/cat-checkbox2.js +1 -1
  60. package/dist/components/cat-checkbox2.js.map +1 -1
  61. package/dist/components/cat-input.js +1 -1
  62. package/dist/components/cat-input.js.map +1 -1
  63. package/dist/components/cat-modal.js.map +1 -1
  64. package/dist/components/cat-radio.js +1 -1
  65. package/dist/components/cat-radio.js.map +1 -1
  66. package/dist/components/cat-scrollable2.js.map +1 -1
  67. package/dist/components/{cat-select-remote.d.ts → cat-select-demo.d.ts} +4 -4
  68. package/dist/components/{cat-select-remote-test.js → cat-select-demo.js} +81 -13
  69. package/dist/components/cat-select-demo.js.map +1 -0
  70. package/dist/components/cat-select.js +1 -7864
  71. package/dist/components/cat-select.js.map +1 -1
  72. package/dist/components/{cat-select-remote2.js → cat-select2.js} +26 -19
  73. package/dist/components/cat-select2.js.map +1 -0
  74. package/dist/components/cat-tabs.js +1 -1
  75. package/dist/components/cat-tabs.js.map +1 -1
  76. package/dist/components/cat-textarea.js +1 -1
  77. package/dist/components/cat-textarea.js.map +1 -1
  78. package/dist/components/cat-toast-demo.js +13 -5
  79. package/dist/components/cat-toast-demo.js.map +1 -1
  80. package/dist/components/cat-toggle.js +1 -1
  81. package/dist/components/cat-toggle.js.map +1 -1
  82. package/dist/components/first-tabbable.js +110 -12
  83. package/dist/components/first-tabbable.js.map +1 -1
  84. package/dist/components/focus-trap.esm.js +27 -10
  85. package/dist/components/focus-trap.esm.js.map +1 -1
  86. package/dist/components/index.d.ts +1 -2
  87. package/dist/components/index.js +1 -2
  88. package/dist/components/index.js.map +1 -1
  89. package/dist/components/loglevel.js +1 -5
  90. package/dist/components/loglevel.js.map +1 -1
  91. package/dist/esm/cat-alert_23.entry.js +7508 -0
  92. package/dist/esm/cat-alert_23.entry.js.map +1 -0
  93. package/dist/esm/{cat-notification-5b6a2cd9.js → cat-notification-8bcf6fa2.js} +15 -11
  94. package/dist/esm/cat-notification-8bcf6fa2.js.map +1 -0
  95. package/dist/esm/catalyst.js +2 -2
  96. package/dist/esm/catalyst.js.map +1 -1
  97. package/dist/esm/{index-17d2bcf3.js → index-df195301.js} +1 -1
  98. package/dist/esm/index-df195301.js.map +1 -0
  99. package/dist/esm/index.js +1 -1
  100. package/dist/esm/loader.js +2 -2
  101. package/dist/esm/loader.js.map +1 -1
  102. package/dist/types/components/{cat-select-remote → cat-select}/autosize.d.ts +0 -0
  103. package/dist/types/components/cat-select/cat-select.d.ts +116 -58
  104. package/dist/types/components/cat-select-demo/cat-select-demo.d.ts +8 -0
  105. package/dist/types/components.d.ts +16 -138
  106. package/dist/types/index.d.ts +1 -4
  107. package/package.json +9 -11
  108. package/dist/catalyst/p-7fff102c.entry.js +0 -12
  109. package/dist/catalyst/p-7fff102c.entry.js.map +0 -1
  110. package/dist/catalyst/p-933b6a7a.js +0 -10
  111. package/dist/catalyst/p-933b6a7a.js.map +0 -1
  112. package/dist/catalyst/p-a255bd64.js.map +0 -1
  113. package/dist/cjs/cat-alert_24.cjs.entry.js +0 -15171
  114. package/dist/cjs/cat-alert_24.cjs.entry.js.map +0 -1
  115. package/dist/cjs/cat-notification-6a438ad1.js.map +0 -1
  116. package/dist/cjs/index-c7955116.js.map +0 -1
  117. package/dist/collection/components/cat-select-remote/cat-select-remote.css +0 -210
  118. package/dist/collection/components/cat-select-remote/cat-select-remote.js +0 -818
  119. package/dist/collection/components/cat-select-remote/cat-select-remote.js.map +0 -1
  120. package/dist/collection/components/cat-select-remote-test/cat-select-remote-test.js.map +0 -1
  121. package/dist/components/cat-select-remote-test.d.ts +0 -11
  122. package/dist/components/cat-select-remote-test.js.map +0 -1
  123. package/dist/components/cat-select-remote.js +0 -8
  124. package/dist/components/cat-select-remote.js.map +0 -1
  125. package/dist/components/cat-select-remote2.js.map +0 -1
  126. package/dist/esm/cat-alert_24.entry.js +0 -15144
  127. package/dist/esm/cat-alert_24.entry.js.map +0 -1
  128. package/dist/esm/cat-notification-5b6a2cd9.js.map +0 -1
  129. package/dist/esm/index-17d2bcf3.js.map +0 -1
  130. package/dist/types/components/cat-select-remote/cat-select-remote.d.ts +0 -164
  131. package/dist/types/components/cat-select-remote-test/cat-select-remote-test.d.ts +0 -6
@@ -1,23 +1,23 @@
1
- import { Component, Element, Event, h, Host, Prop, State, Watch, Listen } from '@stencil/core';
2
- import Choices from 'choices.js';
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';
3
6
  import log from 'loglevel';
4
7
  import { CatFormHint } from '../cat-form-hint/cat-form-hint';
5
- import { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';
6
- let nextUniqueId = 0;
7
- const getOptionTemplate = (data) => {
8
- var _a;
9
- if ((_a = data.customProperties) === null || _a === void 0 ? void 0 : _a.imageUrl) {
10
- return `
11
- <div class="d-flex align-items-center">
12
- <img class="choices-option-icon" src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem" />
13
- ${data.label}
14
- </div>
15
- `;
16
- }
17
- return `<cat-checkbox label="${data.label}" checked="${data.selected}"></cat-checkbox>`;
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
18
17
  };
18
+ let nextUniqueId = 0;
19
19
  /**
20
- * Select lets user choose one option from an options menu. Consider using
20
+ * Select lets user choose one option from an options' menu. Consider using
21
21
  * select when you have 6 or more options. Select component supports any content
22
22
  * type.
23
23
  *
@@ -28,81 +28,82 @@ const getOptionTemplate = (data) => {
28
28
  export class CatSelect {
29
29
  constructor() {
30
30
  this.i18n = CatI18nRegistry.getInstance();
31
- this.id = `cat-select-${nextUniqueId++}`;
32
- this.resetItemsOnNextValueChange = true;
31
+ this.id = `cat-input-${nextUniqueId++}`;
32
+ this.term$ = new Subject();
33
+ this.more$ = new Subject();
34
+ this.state = INIT_STATE;
33
35
  this.hasSlottedLabel = false;
34
36
  /**
35
- * The label for the select.
37
+ * Enable multiple selection.
36
38
  */
37
- this.label = '';
39
+ this.multiple = false;
38
40
  /**
39
- * Visually hide the label, but still show it to assistive technologies like screen readers.
41
+ * The debounce time for the search.
40
42
  */
41
- this.labelHidden = false;
43
+ this.debounce = 250;
42
44
  /**
43
- * A value is required or must be check for the form to be submittable.
45
+ * The placement of the select.
44
46
  */
45
- this.required = false;
47
+ this.placement = 'bottom-start';
46
48
  /**
47
- * The available options for the input.
49
+ * Whether the select is disabled.
48
50
  */
49
- this.items = [];
51
+ this.disabled = false;
50
52
  /**
51
- * Disable the select.
53
+ * The label for the select.
52
54
  */
53
- this.disabled = false;
55
+ this.label = '';
54
56
  /**
55
- * Enable multiple selection.
57
+ * The name of the form control. Submitted with the form as part of a name/value pair.
56
58
  */
57
- this.multiple = false;
59
+ this.name = '';
58
60
  /**
59
- * The placeholder for the select.
61
+ * Visually hide the label, but still show it to assistive technologies like screen readers.
60
62
  */
61
- this.placeholder = '';
63
+ this.labelHidden = false;
62
64
  /**
63
- * Whether the dropdown should appear above `(top)` or below `(bottom)` the
64
- * input. By default, if there is not enough space within the window the
65
- * dropdown will appear above the input, otherwise below it.
65
+ * A value is required or must be checked for the form to be submittable.
66
66
  */
67
- this.position = 'auto';
67
+ this.required = false;
68
68
  /**
69
- * Enable search for the select.
69
+ * Whether the select should show a clear button.
70
70
  */
71
- this.search = false;
71
+ this.clearable = false;
72
72
  }
73
- setChoicesHandler(items) {
74
- var _a, _b, _c, _d;
75
- const isSelected = (item) => { var _a; return (_a = this.value) === null || _a === void 0 ? void 0 : _a.includes(item.value); };
76
- const choices = items.map(item => (Object.assign(Object.assign({}, item), { selected: isSelected(item) })));
77
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.setChoices(choices, 'value', 'label', true);
78
- const vItems = ((_b = this.choice) === null || _b === void 0 ? void 0 : _b.getValue()) || [];
79
- const vItemsArray = (Array.isArray(vItems) ? vItems : [vItems]);
80
- const value = this.value || [];
81
- const vItemValues = [...value];
82
- // remove duplicate items
83
- (_c = this.choice) === null || _c === void 0 ? void 0 : _c.unhighlightAll();
84
- vItemsArray.forEach(vItem => {
85
- var _a;
86
- const index = vItemValues.indexOf(vItem.value);
87
- if (index > -1) {
88
- vItemValues.splice(index, 1);
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;
89
93
  }
90
94
  else {
91
- vItem.choiceId = -1; // disconnect item from choice
92
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.highlightItem(vItem, false);
95
+ this.value = idsSelected.length ? idsSelected[0] : '';
93
96
  }
94
- });
95
- (_d = this.choice) === null || _d === void 0 ? void 0 : _d.removeHighlightedItems(false);
97
+ this.catChange.emit();
98
+ }
96
99
  }
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- setValueHandler(value) {
99
- var _a, _b;
100
- if (this.resetItemsOnNextValueChange) {
101
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
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());
102
106
  }
103
- this.resetItemsOnNextValueChange = true;
104
- (_b = this.choice) === null || _b === void 0 ? void 0 : _b.setChoiceByValue(value);
105
- this.multiple && this.updateRemoveItemButtonVisibility();
106
107
  }
107
108
  componentWillRender() {
108
109
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
@@ -110,47 +111,97 @@ export class CatSelect {
110
111
  log.error('[A11y] Missing ARIA label on select', this);
111
112
  }
112
113
  }
113
- componentDidLoad() {
114
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
115
- this.init();
116
- const attachedInternals = (_b = (_a = this.hostElement).attachInternals) === null || _b === void 0 ? void 0 : _b.call(_a);
117
- if (attachedInternals) {
118
- const root = attachedInternals.shadowRoot;
119
- this.choicesElement = (root === null || root === void 0 ? void 0 : root.querySelector('.choices')) || undefined;
120
- this.choiceInner = (root === null || root === void 0 ? void 0 : root.querySelector('.choices__inner')) || undefined;
121
- this.choiceDropdown = ((_c = root === null || root === void 0 ? void 0 : root.querySelector('.choices__list--dropdown')) === null || _c === void 0 ? void 0 : _c.firstElementChild) || undefined;
122
- }
123
- (_d = this.choicesElement) === null || _d === void 0 ? void 0 : _d.addEventListener('click', this.resetFocus.bind(this));
124
- (_e = this.choiceInner) === null || _e === void 0 ? void 0 : _e.addEventListener('click', this.showDropdownHandler.bind(this));
125
- (_f = this.selectElement) === null || _f === void 0 ? void 0 : _f.addEventListener('hideDropdown', this.showMultipleFocus.bind(this));
126
- (_g = this.selectElement) === null || _g === void 0 ? void 0 : _g.addEventListener('showDropdown', this.showMultipleFocus.bind(this));
127
- (_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.addEventListener('removeItem', this.resetFocus.bind(this));
128
- (_j = this.selectElement) === null || _j === void 0 ? void 0 : _j.addEventListener('change', this.onChange.bind(this));
129
- (_k = this.selectElement) === null || _k === void 0 ? void 0 : _k.addEventListener('search', this.onSearch.bind(this));
130
- (_l = this.choiceDropdown) === null || _l === void 0 ? void 0 : _l.addEventListener('scroll', this.onScrolledBottom.bind(this));
131
- if (this.multiple) {
132
- (_m = this.selectElement) === null || _m === void 0 ? void 0 : _m.addEventListener('choice', this.onChoice.bind(this));
133
- this.createRemoveItemButton();
114
+ onBlur(event) {
115
+ if (!this.multiple && this.state.activeOptionIndex >= 0) {
116
+ this.select(this.state.options[this.state.activeOptionIndex]);
134
117
  }
118
+ this.hide();
119
+ this.patchState({ activeSelectionIndex: -1 });
120
+ this.catBlur.emit(event);
135
121
  }
136
- disconnectedCallback() {
137
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
138
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.destroy();
139
- this.choice = undefined;
140
- (_b = this.choicesElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('click', this.resetFocus.bind(this));
141
- (_c = this.choiceInner) === null || _c === void 0 ? void 0 : _c.removeEventListener('click', this.showDropdownHandler.bind(this));
142
- (_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('hideDropdown', this.showMultipleFocus.bind(this));
143
- (_e = this.selectElement) === null || _e === void 0 ? void 0 : _e.removeEventListener('showDropdown', this.showMultipleFocus.bind(this));
144
- (_f = this.selectElement) === null || _f === void 0 ? void 0 : _f.removeEventListener('removeItem', this.resetFocus.bind(this));
145
- (_g = this.selectElement) === null || _g === void 0 ? void 0 : _g.removeEventListener('change', this.onChange.bind(this));
146
- (_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.removeEventListener('search', this.onSearch.bind(this));
147
- (_j = this.choiceDropdown) === null || _j === void 0 ? void 0 : _j.removeEventListener('scroll', this.onScrolledBottom.bind(this));
148
- if (this.multiple) {
149
- (_k = this.removeElement) === null || _k === void 0 ? void 0 : _k.removeEventListener('choice', this.onChoice.bind(this));
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();
150
166
  }
151
167
  }
152
- onBlur(event) {
153
- this.catBlur.emit(event);
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 CatSelectConnector} 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
+ }));
154
205
  }
155
206
  render() {
156
207
  return (h(Host, null,
@@ -161,182 +212,241 @@ export class CatSelect {
161
212
  "(",
162
213
  this.i18n.t('input.optional'),
163
214
  ")"))))),
164
- h("select", { id: this.id, ref: el => (this.selectElement = el), multiple: this.multiple, disabled: this.disabled }),
165
- this.hintSection));
166
- }
167
- init() {
168
- const component = this; // eslint-disable-line @typescript-eslint/no-this-alias
169
- const removeItemText = (value) => this.i18n.t('select.removeItem', { value });
170
- const config = {
171
- allowHTML: true,
172
- removeItemButton: true,
173
- duplicateItemsAllowed: false,
174
- delimiter: '',
175
- paste: false,
176
- searchEnabled: this.search,
177
- searchChoices: false,
178
- position: this.position,
179
- resetScrollPosition: false,
180
- placeholder: !!this.placeholder,
181
- placeholderValue: this.placeholder || '',
182
- searchPlaceholderValue: this.i18n.t('select.searchPlaceholder'),
183
- renderSelectedChoices: 'always',
184
- loadingText: this.i18n.t('select.loading'),
185
- noResultsText: this.i18n.t('select.noResults'),
186
- noChoicesText: this.i18n.t('select.noChoices'),
187
- itemSelectText: this.i18n.t('select.selectItem'),
188
- addItemText: (value) => this.i18n.t('select.addItem', { value }),
189
- maxItemText: (maxItemCount) => this.i18n.t('select.maxItem', { maxItemCount }),
190
- uniqueItemText: this.i18n.t('select.uniqueItem'),
191
- customAddItemText: this.i18n.t('select.customAddItem'),
192
- callbackOnInit: function () {
193
- const choice = this;
194
- choice.setChoices(component.items, 'value', 'label', true);
195
- choice.setChoiceByValue(component.value);
196
- }
197
- };
198
- const configSingle = {
199
- callbackOnCreateTemplates: (strToEl) => {
200
- return {
201
- item: ({ classNames }, data) => {
202
- var _a;
203
- const template = ((_a = data.customProperties) === null || _a === void 0 ? void 0 : _a.imageUrl)
204
- ? `<img class="choices-option-icon" src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem" />`
205
- : '';
206
- return strToEl(`
207
- <div class="${classNames.item} ${data.highlighted ? classNames.highlightedState : classNames.itemSelectable} ${data.placeholder ? classNames.placeholder : ''}" data-item data-id="${data.id}" data-value="${data.value}" ${data.active ? 'aria-selected="true"' : ''} ${data.disabled ? 'aria-disabled="true"' : ''}>
208
- <span>${template}</span> ${data.label}
209
- <button type="button"
210
- class="${classNames.button}"
211
- aria-label="${removeItemText(data.label)}"
212
- data-button>${removeItemText(data.label)}</button>
213
- </div>
214
- `);
215
- }
216
- };
217
- }
218
- };
219
- const configMultiple = {
220
- callbackOnCreateTemplates: (strToEl) => {
221
- const itemSelectText = config.itemSelectText;
222
- return {
223
- item: ({ classNames }, data) => {
224
- var _a;
225
- const template = ((_a = data.customProperties) === null || _a === void 0 ? void 0 : _a.imageUrl)
226
- ? `<img class="choices-option-icon" src="${data.customProperties.imageUrl}" style="margin-right: 0.5rem;" />`
227
- : '';
228
- return strToEl(`<div class="
229
- ${classNames.item}
230
- ${data.highlighted ? classNames.highlightedState : classNames.itemSelectable}
231
- ${data.placeholder ? classNames.placeholder : ''}"
232
- data-item data-id="${data.id}" data-value="${data.value}"
233
- ${data.active ? 'aria-selected="true"' : ''}
234
- ${data.disabled ? 'aria-disabled="true"' : ''}>
235
- ${template}
236
- ${data.label}
237
- <button type="button"
238
- class="${classNames.button}"
239
- aria-label="${removeItemText(data.label)}"
240
- data-button>${removeItemText(data.label)}</button>
241
- </div>`);
242
- },
243
- choice: function ({ classNames }, data) {
244
- const template = getOptionTemplate(data);
245
- const className = `${String(classNames.item)} ${String(classNames.itemChoice)}
246
- ${String(data.disabled ? classNames.itemDisabled : classNames.itemSelectable)}
247
- ${data.selected ? 'choices__item--selected' : ''}`;
248
- return strToEl(`<div class="${className}"
249
- data-select-text="${itemSelectText}"
250
- data-choice data-id="${String(data.id)}" data-value="${String(data.value)}"
251
- ${data.disabled ? 'data-choice-disabled aria-disabled="true"' : 'data-choice-selectable'}
252
- ${data.groupId && data.groupId > 0 ? 'role="treeitem"' : 'role="option"'}>
253
- ${template}
254
- </div>`);
255
- }
256
- };
257
- }
258
- };
259
- const settings = this.multiple
260
- ? Object.assign(Object.assign({}, config), configMultiple) : Object.assign(Object.assign({}, config), configSingle);
261
- this.choice = new Choices(this.selectElement, settings);
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
+ item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null,
223
+ h("span", null, item.render.label),
224
+ !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 }))))))) : this.state.selection.length && this.state.selection[0].render.avatar ? (h("cat-avatar", { label: this.state.selection[0].render.label, round: this.state.selection[0].render.avatar.round, src: this.state.selection[0].render.avatar.src, initials: '' })) : null,
225
+ 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 })),
226
+ this.state.isResolving && h("cat-spinner", null),
227
+ (this.state.selection.length || this.state.term.length) &&
228
+ !this.disabled &&
229
+ !this.state.isResolving &&
230
+ 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('input.clear'), onClick: () => this.clear() })) : null,
231
+ !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 }))),
232
+ this.hintSection,
233
+ 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() },
234
+ h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` },
235
+ 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 => {
236
+ this.toggle(item);
237
+ e.stopPropagation();
238
+ } },
239
+ h("span", { slot: "label", class: "select-option-inner" },
240
+ item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null,
241
+ h("span", { class: "select-option-text" },
242
+ h("span", { class: "select-option-label" }, item.render.label),
243
+ h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
244
+ 'select-option-inner': true,
245
+ 'select-option-single': true,
246
+ 'select-option-active': this.state.activeOptionIndex === i
247
+ }, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => this.select(item), tabIndex: -1 },
248
+ item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null,
249
+ h("span", { class: "select-option-text" },
250
+ h("span", { class: "select-option-label" }, item.render.label),
251
+ h("span", { class: "select-option-description" }, item.render.description))))))),
252
+ this.state.isLoading
253
+ ? Array.from(Array(CatSelect.SKELETON_COUNT)).map(() => (h("li", { class: "select-option-loading" },
254
+ h("cat-skeleton", { variant: "body", lines: 1 }),
255
+ h("cat-skeleton", { variant: "body", lines: 1 }))))
256
+ : !this.state.options.length && h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
262
257
  }
263
258
  get hintSection() {
264
259
  const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
265
260
  return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
266
261
  }
267
- onChange() {
262
+ get connectorSafe() {
263
+ if (this.connector) {
264
+ return this.connector;
265
+ }
266
+ throw new Error('CatSelectConnector not set');
267
+ }
268
+ resolve() {
268
269
  var _a;
269
- this.resetItemsOnNextValueChange = false;
270
- this.value = (_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue(true);
271
- this.catChange.emit(this.value);
270
+ this.patchState({ isResolving: true });
271
+ let ids;
272
+ if (this.multiple) {
273
+ ids = this.value;
274
+ }
275
+ else {
276
+ ids = [this.value];
277
+ }
278
+ const data$ = ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
279
+ data$.pipe(catchError(() => of([]))).subscribe(items => this.patchState({
280
+ isResolving: false,
281
+ selection: items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })),
282
+ term: !this.multiple && items.length ? this.connectorSafe.render(items[0]).label : ''
283
+ }));
272
284
  }
273
- showMultipleFocus() {
274
- var _a, _b;
275
- if (this.multiple && this.isFocused() && !((_a = this.choicesElement) === null || _a === void 0 ? void 0 : _a.classList.contains('is-focused'))) {
276
- (_b = this.choicesElement) === null || _b === void 0 ? void 0 : _b.classList.add('is-focused');
285
+ show() {
286
+ var _a;
287
+ if (!this.state.isOpen) {
288
+ this.patchState({ isOpen: true });
289
+ this.catOpen.emit();
290
+ this.term$.next(this.state.term);
291
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.remove('select-input-transparent-caret');
277
292
  }
278
293
  }
279
- resetFocus() {
280
- var _a, _b, _c;
281
- if (!this.isFocused()) {
282
- if (!((_a = this.choicesElement) === null || _a === void 0 ? void 0 : _a.hasAttribute('tabindex'))) {
283
- (_b = this.choicesElement) === null || _b === void 0 ? void 0 : _b.setAttribute('tabindex', '0');
284
- }
285
- (_c = this.choicesElement) === null || _c === void 0 ? void 0 : _c.focus();
294
+ hide() {
295
+ if (this.state.isOpen) {
296
+ this.patchState({ isOpen: false, activeOptionIndex: -1 });
297
+ this.catClose.emit();
286
298
  }
287
299
  }
288
- isFocused() {
289
- return document.activeElement === this.hostElement;
300
+ search(term) {
301
+ this.patchState({ term, activeOptionIndex: -1, activeSelectionIndex: -1 });
302
+ this.term$.next(term);
290
303
  }
291
- onChoice(event) {
304
+ isSelected(id) {
305
+ return this.state.selection.findIndex(s => s.item.id === id) >= 0;
306
+ }
307
+ select(item) {
292
308
  var _a;
293
- const customEvent = event;
294
- const choice = customEvent.detail.choice;
295
- if (choice.selected) {
296
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItemsByValue(choice.value);
297
- this.onChange();
309
+ if (!this.isSelected(item.item.id)) {
310
+ let newSelection;
311
+ if (this.multiple) {
312
+ newSelection = [...this.state.selection, item];
313
+ }
314
+ else {
315
+ newSelection = [item];
316
+ this.search(item.render.label);
317
+ }
318
+ this.patchState({ selection: newSelection });
319
+ }
320
+ if (!this.multiple) {
321
+ this.hide();
322
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
323
+ }
324
+ }
325
+ deselect(id) {
326
+ if (this.isSelected(id)) {
327
+ this.patchState({
328
+ selection: this.state.selection.filter(item => item.item.id !== id),
329
+ activeSelectionIndex: -1
330
+ });
298
331
  }
299
332
  }
300
- onSearch(event) {
301
- const customEvent = event;
302
- this.catSearch.emit(customEvent.detail.value);
333
+ toggle(item) {
334
+ this.isSelected(item.item.id) ? this.deselect(item.item.id) : this.select(item);
303
335
  }
304
- onScrolledBottom() {
305
- var _a, _b, _c;
306
- const scrolledBottom = ((_a = this.choiceDropdown) === null || _a === void 0 ? void 0 : _a.scrollHeight) ===
307
- (((_b = this.choiceDropdown) === null || _b === void 0 ? void 0 : _b.scrollTop) || 0) + (((_c = this.choiceDropdown) === null || _c === void 0 ? void 0 : _c.clientHeight) || 0);
308
- if (scrolledBottom) {
309
- this.catScrolledBottom.emit();
336
+ clear() {
337
+ if (this.input && this.state.term) {
338
+ this.patchState({ selection: [], options: [], term: '', activeOptionIndex: -1 });
339
+ this.term$.next('');
340
+ this.input.value = '';
341
+ }
342
+ else {
343
+ this.patchState({ selection: [] });
310
344
  }
311
345
  }
312
- showDropdownHandler() {
346
+ reset(connector) {
313
347
  var _a;
314
- !this.disabled && ((_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown());
348
+ this.connector = connector !== null && connector !== void 0 ? connector : this.connector;
349
+ (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
350
+ this.subscription = undefined;
351
+ this.state = INIT_STATE;
352
+ }
353
+ onClick(event) {
354
+ var _a, _b;
355
+ const elem = event.target;
356
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
357
+ (_b = this.input) === null || _b === void 0 ? void 0 : _b.focus();
358
+ if (elem === this.trigger ||
359
+ elem === this.input ||
360
+ elem.classList.contains('select-btn') ||
361
+ elem.nodeName === 'SPAN') {
362
+ this.state.isOpen ? this.hide() : this.show();
363
+ }
315
364
  }
316
- createRemoveItemButton() {
365
+ onInput() {
317
366
  var _a;
318
- this.removeElement = document.createElement('cat-button');
319
- this.removeElement.icon = 'cross-circle-outlined';
320
- this.removeElement.iconOnly = true;
321
- this.removeElement.a11yLabel = this.i18n.t('select.removeItem');
322
- this.updateRemoveItemButtonVisibility();
323
- this.removeElement.addEventListener('click', this.onRemoveItemButtonClick.bind(this));
324
- (_a = this.choiceInner) === null || _a === void 0 ? void 0 : _a.appendChild(this.removeElement);
367
+ this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '');
368
+ this.show();
325
369
  }
326
- updateRemoveItemButtonVisibility() {
327
- var _a, _b, _c;
328
- if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) {
329
- (_b = this.removeElement) === null || _b === void 0 ? void 0 : _b.removeAttribute('hidden');
370
+ update() {
371
+ if (this.trigger && this.dropdown) {
372
+ computePosition(this.trigger, this.dropdown, {
373
+ placement: this.placement,
374
+ middleware: [offset(CatSelect.DROPDOWN_OFFSET)]
375
+ }).then(({ x, y }) => {
376
+ if (this.dropdown) {
377
+ Object.assign(this.dropdown.style, {
378
+ left: `${x}px`,
379
+ top: `${y}px`
380
+ });
381
+ }
382
+ });
330
383
  }
331
- else {
332
- (_c = this.removeElement) === null || _c === void 0 ? void 0 : _c.setAttribute('hidden', 'true');
384
+ }
385
+ patchState(update) {
386
+ this.state = Object.assign(Object.assign({}, this.state), update);
387
+ }
388
+ isPillboxActive() {
389
+ return this.state.activeSelectionIndex >= 0;
390
+ }
391
+ get activeDescendant() {
392
+ let activeDescendant = undefined;
393
+ if (this.state.activeOptionIndex >= 0) {
394
+ activeDescendant = `select-${this.id}-option-${this.state.activeOptionIndex}`;
395
+ }
396
+ else if (this.state.activeSelectionIndex >= 0) {
397
+ activeDescendant = `select-${this.id}-selection-${this.state.activeSelectionIndex}`;
333
398
  }
399
+ return activeDescendant;
334
400
  }
335
- onRemoveItemButtonClick(event) {
336
- var _a;
337
- event.stopPropagation();
338
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
339
- this.onChange();
401
+ onArrowKeyDown(event) {
402
+ var _a, _b;
403
+ let preventDefault = false;
404
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
405
+ if (event.key === 'ArrowDown') {
406
+ preventDefault = true;
407
+ this.state.isOpen
408
+ ? this.patchState({
409
+ activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
410
+ activeSelectionIndex: -1
411
+ })
412
+ : this.show();
413
+ }
414
+ else if (event.key === 'ArrowUp') {
415
+ preventDefault = true;
416
+ this.state.activeOptionIndex >= 0
417
+ ? this.patchState({
418
+ activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
419
+ activeSelectionIndex: -1
420
+ })
421
+ : this.hide();
422
+ }
423
+ else if (event.key === 'ArrowLeft') {
424
+ if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
425
+ preventDefault = true;
426
+ let index;
427
+ this.state.activeSelectionIndex > 0
428
+ ? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
429
+ : (index = this.state.selection.length - 1);
430
+ this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
431
+ }
432
+ }
433
+ else if (event.key === 'ArrowRight') {
434
+ if (this.state.activeSelectionIndex >= 0) {
435
+ preventDefault = true;
436
+ let index = -1;
437
+ if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
438
+ index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
439
+ }
440
+ else if (!this.state.term) {
441
+ index = 0;
442
+ }
443
+ this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
444
+ }
445
+ }
446
+ if (preventDefault) {
447
+ event.preventDefault();
448
+ event.stopPropagation();
449
+ }
340
450
  }
341
451
  static get is() { return "cat-select"; }
342
452
  static get encapsulation() { return "shadow"; }
@@ -347,25 +457,7 @@ export class CatSelect {
347
457
  "$": ["cat-select.css"]
348
458
  }; }
349
459
  static get properties() { return {
350
- "label": {
351
- "type": "string",
352
- "mutable": false,
353
- "complexType": {
354
- "original": "string",
355
- "resolved": "string",
356
- "references": {}
357
- },
358
- "required": false,
359
- "optional": false,
360
- "docs": {
361
- "tags": [],
362
- "text": "The label for the select."
363
- },
364
- "attribute": "label",
365
- "reflect": false,
366
- "defaultValue": "''"
367
- },
368
- "labelHidden": {
460
+ "multiple": {
369
461
  "type": "boolean",
370
462
  "mutable": false,
371
463
  "complexType": {
@@ -377,39 +469,40 @@ export class CatSelect {
377
469
  "optional": false,
378
470
  "docs": {
379
471
  "tags": [],
380
- "text": "Visually hide the label, but still show it to assistive technologies like screen readers."
472
+ "text": "Enable multiple selection."
381
473
  },
382
- "attribute": "label-hidden",
474
+ "attribute": "multiple",
383
475
  "reflect": false,
384
476
  "defaultValue": "false"
385
477
  },
386
- "required": {
387
- "type": "boolean",
478
+ "debounce": {
479
+ "type": "number",
388
480
  "mutable": false,
389
481
  "complexType": {
390
- "original": "boolean",
391
- "resolved": "boolean",
482
+ "original": "number",
483
+ "resolved": "number",
392
484
  "references": {}
393
485
  },
394
486
  "required": false,
395
487
  "optional": false,
396
488
  "docs": {
397
489
  "tags": [],
398
- "text": "A value is required or must be check for the form to be submittable."
490
+ "text": "The debounce time for the search."
399
491
  },
400
- "attribute": "required",
492
+ "attribute": "debounce",
401
493
  "reflect": false,
402
- "defaultValue": "false"
494
+ "defaultValue": "250"
403
495
  },
404
- "items": {
405
- "type": "unknown",
496
+ "placement": {
497
+ "type": "string",
406
498
  "mutable": false,
407
499
  "complexType": {
408
- "original": "CatSelectItem[]",
409
- "resolved": "CatSelectItem[]",
500
+ "original": "Placement",
501
+ "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
410
502
  "references": {
411
- "CatSelectItem": {
412
- "location": "local"
503
+ "Placement": {
504
+ "location": "import",
505
+ "path": "@floating-ui/dom"
413
506
  }
414
507
  }
415
508
  },
@@ -417,16 +510,18 @@ export class CatSelect {
417
510
  "optional": false,
418
511
  "docs": {
419
512
  "tags": [],
420
- "text": "The available options for the input."
513
+ "text": "The placement of the select."
421
514
  },
422
- "defaultValue": "[]"
515
+ "attribute": "placement",
516
+ "reflect": false,
517
+ "defaultValue": "'bottom-start'"
423
518
  },
424
519
  "value": {
425
- "type": "any",
520
+ "type": "string",
426
521
  "mutable": true,
427
522
  "complexType": {
428
- "original": "any",
429
- "resolved": "any",
523
+ "original": "string | string[]",
524
+ "resolved": "string | string[] | undefined",
430
525
  "references": {}
431
526
  },
432
527
  "required": false,
@@ -450,31 +545,65 @@ export class CatSelect {
450
545
  "optional": false,
451
546
  "docs": {
452
547
  "tags": [],
453
- "text": "Disable the select."
548
+ "text": "Whether the select is disabled."
454
549
  },
455
550
  "attribute": "disabled",
456
551
  "reflect": false,
457
552
  "defaultValue": "false"
458
553
  },
459
- "multiple": {
460
- "type": "boolean",
554
+ "placeholder": {
555
+ "type": "string",
461
556
  "mutable": false,
462
557
  "complexType": {
463
- "original": "boolean",
464
- "resolved": "boolean",
558
+ "original": "string",
559
+ "resolved": "string | undefined",
560
+ "references": {}
561
+ },
562
+ "required": false,
563
+ "optional": true,
564
+ "docs": {
565
+ "tags": [],
566
+ "text": "The placeholder text to display within the select."
567
+ },
568
+ "attribute": "placeholder",
569
+ "reflect": false
570
+ },
571
+ "hint": {
572
+ "type": "string",
573
+ "mutable": false,
574
+ "complexType": {
575
+ "original": "string | string[]",
576
+ "resolved": "string | string[] | undefined",
577
+ "references": {}
578
+ },
579
+ "required": false,
580
+ "optional": true,
581
+ "docs": {
582
+ "tags": [],
583
+ "text": "Optional hint text(s) to be displayed with the select."
584
+ },
585
+ "attribute": "hint",
586
+ "reflect": false
587
+ },
588
+ "label": {
589
+ "type": "string",
590
+ "mutable": false,
591
+ "complexType": {
592
+ "original": "string",
593
+ "resolved": "string",
465
594
  "references": {}
466
595
  },
467
596
  "required": false,
468
597
  "optional": false,
469
598
  "docs": {
470
599
  "tags": [],
471
- "text": "Enable multiple selection."
600
+ "text": "The label for the select."
472
601
  },
473
- "attribute": "multiple",
602
+ "attribute": "label",
474
603
  "reflect": false,
475
- "defaultValue": "false"
604
+ "defaultValue": "''"
476
605
  },
477
- "placeholder": {
606
+ "name": {
478
607
  "type": "string",
479
608
  "mutable": false,
480
609
  "complexType": {
@@ -486,31 +615,31 @@ export class CatSelect {
486
615
  "optional": false,
487
616
  "docs": {
488
617
  "tags": [],
489
- "text": "The placeholder for the select."
618
+ "text": "The name of the form control. Submitted with the form as part of a name/value pair."
490
619
  },
491
- "attribute": "placeholder",
620
+ "attribute": "name",
492
621
  "reflect": false,
493
622
  "defaultValue": "''"
494
623
  },
495
- "position": {
496
- "type": "string",
624
+ "labelHidden": {
625
+ "type": "boolean",
497
626
  "mutable": false,
498
627
  "complexType": {
499
- "original": "'auto' | 'top' | 'bottom'",
500
- "resolved": "\"auto\" | \"bottom\" | \"top\"",
628
+ "original": "boolean",
629
+ "resolved": "boolean",
501
630
  "references": {}
502
631
  },
503
632
  "required": false,
504
633
  "optional": false,
505
634
  "docs": {
506
635
  "tags": [],
507
- "text": "Whether the dropdown should appear above `(top)` or below `(bottom)` the\ninput. By default, if there is not enough space within the window the\ndropdown will appear above the input, otherwise below it."
636
+ "text": "Visually hide the label, but still show it to assistive technologies like screen readers."
508
637
  },
509
- "attribute": "position",
638
+ "attribute": "label-hidden",
510
639
  "reflect": false,
511
- "defaultValue": "'auto'"
640
+ "defaultValue": "false"
512
641
  },
513
- "search": {
642
+ "required": {
514
643
  "type": "boolean",
515
644
  "mutable": false,
516
645
  "complexType": {
@@ -522,72 +651,83 @@ export class CatSelect {
522
651
  "optional": false,
523
652
  "docs": {
524
653
  "tags": [],
525
- "text": "Enable search for the select."
654
+ "text": "A value is required or must be checked for the form to be submittable."
526
655
  },
527
- "attribute": "search",
656
+ "attribute": "required",
528
657
  "reflect": false,
529
658
  "defaultValue": "false"
530
659
  },
531
- "hint": {
532
- "type": "string",
660
+ "clearable": {
661
+ "type": "boolean",
533
662
  "mutable": false,
534
663
  "complexType": {
535
- "original": "string | string[]",
536
- "resolved": "string | string[] | undefined",
664
+ "original": "boolean",
665
+ "resolved": "boolean",
537
666
  "references": {}
538
667
  },
539
668
  "required": false,
540
- "optional": true,
669
+ "optional": false,
541
670
  "docs": {
542
671
  "tags": [],
543
- "text": "Optional hint text(s) to be displayed with the select."
672
+ "text": "Whether the select should show a clear button."
544
673
  },
545
- "attribute": "hint",
546
- "reflect": false
674
+ "attribute": "clearable",
675
+ "reflect": false,
676
+ "defaultValue": "false"
547
677
  }
548
678
  }; }
549
679
  static get states() { return {
680
+ "connector": {},
681
+ "state": {},
550
682
  "hasSlottedLabel": {}
551
683
  }; }
552
684
  static get events() { return [{
553
- "method": "catChange",
554
- "name": "catChange",
685
+ "method": "catOpen",
686
+ "name": "catOpen",
555
687
  "bubbles": true,
556
688
  "cancelable": true,
557
689
  "composed": true,
558
690
  "docs": {
559
691
  "tags": [],
560
- "text": "Emitted when the value is changed."
692
+ "text": "Emitted when the select dropdown is opened."
561
693
  },
562
694
  "complexType": {
563
- "original": "any",
564
- "resolved": "any",
565
- "references": {}
695
+ "original": "FocusEvent",
696
+ "resolved": "FocusEvent",
697
+ "references": {
698
+ "FocusEvent": {
699
+ "location": "global"
700
+ }
701
+ }
566
702
  }
567
703
  }, {
568
- "method": "catSearch",
569
- "name": "catSearch",
704
+ "method": "catClose",
705
+ "name": "catClose",
570
706
  "bubbles": true,
571
707
  "cancelable": true,
572
708
  "composed": true,
573
709
  "docs": {
574
710
  "tags": [],
575
- "text": "Emitted when the search is triggered."
711
+ "text": "Emitted when the select dropdown is closed."
576
712
  },
577
713
  "complexType": {
578
- "original": "any",
579
- "resolved": "any",
580
- "references": {}
714
+ "original": "FocusEvent",
715
+ "resolved": "FocusEvent",
716
+ "references": {
717
+ "FocusEvent": {
718
+ "location": "global"
719
+ }
720
+ }
581
721
  }
582
722
  }, {
583
- "method": "catScrolledBottom",
584
- "name": "catScrolledBottom",
723
+ "method": "catChange",
724
+ "name": "catChange",
585
725
  "bubbles": true,
586
726
  "cancelable": true,
587
727
  "composed": true,
588
728
  "docs": {
589
729
  "tags": [],
590
- "text": "Emitted when scrolled to the bottom."
730
+ "text": "Emitted when the value is changed."
591
731
  },
592
732
  "complexType": {
593
733
  "original": "any",
@@ -602,7 +742,7 @@ export class CatSelect {
602
742
  "composed": true,
603
743
  "docs": {
604
744
  "tags": [],
605
- "text": "Emitted when the select loses focus."
745
+ "text": "Emitted when the select loses the focus."
606
746
  },
607
747
  "complexType": {
608
748
  "original": "FocusEvent",
@@ -614,20 +754,71 @@ export class CatSelect {
614
754
  }
615
755
  }
616
756
  }]; }
757
+ static get methods() { return {
758
+ "connect": {
759
+ "complexType": {
760
+ "signature": "(connector: CatSelectConnector) => Promise<void>",
761
+ "parameters": [{
762
+ "tags": [{
763
+ "name": "param",
764
+ "text": "connector - The {@link CatSelectConnector } of the select."
765
+ }],
766
+ "text": "- The {@link CatSelectConnector} of the select."
767
+ }],
768
+ "references": {
769
+ "Promise": {
770
+ "location": "global"
771
+ },
772
+ "CatSelectConnector": {
773
+ "location": "local"
774
+ },
775
+ "Observable": {
776
+ "location": "import",
777
+ "path": "rxjs"
778
+ },
779
+ "Item": {
780
+ "location": "local"
781
+ }
782
+ },
783
+ "return": "Promise<void>"
784
+ },
785
+ "docs": {
786
+ "text": "Connect the functions of the select",
787
+ "tags": [{
788
+ "name": "param",
789
+ "text": "connector - The {@link CatSelectConnector} of the select."
790
+ }]
791
+ }
792
+ }
793
+ }; }
617
794
  static get elementRef() { return "hostElement"; }
618
795
  static get watchers() { return [{
619
- "propName": "items",
620
- "methodName": "setChoicesHandler"
796
+ "propName": "connector",
797
+ "methodName": "onConnectorChange"
621
798
  }, {
622
- "propName": "value",
623
- "methodName": "setValueHandler"
799
+ "propName": "state",
800
+ "methodName": "onStateChange"
624
801
  }]; }
625
802
  static get listeners() { return [{
626
803
  "name": "blur",
627
804
  "method": "onBlur",
628
805
  "target": undefined,
629
- "capture": true,
806
+ "capture": false,
807
+ "passive": false
808
+ }, {
809
+ "name": "keydown",
810
+ "method": "onKeyDown",
811
+ "target": undefined,
812
+ "capture": false,
813
+ "passive": false
814
+ }, {
815
+ "name": "keyup",
816
+ "method": "onKeyUp",
817
+ "target": undefined,
818
+ "capture": false,
630
819
  "passive": false
631
820
  }]; }
632
821
  }
822
+ CatSelect.SKELETON_COUNT = 4;
823
+ CatSelect.DROPDOWN_OFFSET = 4;
633
824
  //# sourceMappingURL=cat-select.js.map