@haiilo/catalyst 5.3.0 → 6.0.0

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 (195) hide show
  1. package/dist/catalyst/catalyst.css +1127 -39
  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 -0
  5. package/dist/catalyst/index.esm.js +2 -2
  6. package/dist/catalyst/index.esm.js.map +1 -1
  7. package/dist/catalyst/p-ad5fca6b.entry.js +10 -0
  8. package/dist/catalyst/p-ad5fca6b.entry.js.map +1 -0
  9. package/dist/catalyst/{p-d1fb9d96.js → p-ce6a1db2.js} +1 -1
  10. package/dist/catalyst/p-ce6a1db2.js.map +1 -0
  11. package/dist/catalyst/p-d7dc291a.js +2 -0
  12. package/dist/catalyst/p-d7dc291a.js.map +1 -0
  13. package/dist/catalyst/scss/_snippets/_checkbox-hint.scss +20 -0
  14. package/dist/catalyst/scss/index.scss +2 -0
  15. package/dist/catalyst/scss/utils/_border.scss +14 -0
  16. package/dist/catalyst/scss/utils/_media.mixins.scss +0 -1
  17. package/dist/catalyst/scss/utils/_typography.mixins.scss +1 -0
  18. package/dist/catalyst/scss/vendor/_flatpickr.scss +314 -0
  19. package/dist/cjs/cat-alert_25.cjs.entry.js +3391 -506
  20. package/dist/cjs/cat-alert_25.cjs.entry.js.map +1 -1
  21. package/dist/cjs/{cat-icon-registry-671af264.js → cat-icon-registry-6161e2ee.js} +56 -3
  22. package/dist/cjs/cat-icon-registry-6161e2ee.js.map +1 -0
  23. package/dist/cjs/catalyst.cjs.js +3 -3
  24. package/dist/cjs/catalyst.cjs.js.map +1 -1
  25. package/dist/cjs/{index-01312a2e.js → index-4258b31e.js} +8 -1
  26. package/dist/{catalyst/p-d1fb9d96.js.map → cjs/index-4258b31e.js.map} +1 -1
  27. package/dist/cjs/index.cjs.js +13 -15
  28. package/dist/cjs/index.cjs.js.map +1 -1
  29. package/dist/cjs/loader.cjs.js +3 -3
  30. package/dist/cjs/loader.cjs.js.map +1 -1
  31. package/dist/collection/collection-manifest.json +3 -3
  32. package/dist/collection/components/cat-alert/cat-alert.js +5 -5
  33. package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
  34. package/dist/collection/components/cat-avatar/cat-avatar.js +5 -5
  35. package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -1
  36. package/dist/collection/components/cat-button/cat-button.css +7 -7
  37. package/dist/collection/components/cat-button/cat-button.js +11 -31
  38. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  39. package/dist/collection/components/cat-checkbox/cat-checkbox.css +24 -1
  40. package/dist/collection/components/cat-checkbox/cat-checkbox.js +38 -37
  41. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  42. package/dist/collection/components/cat-datepicker/cat-datepicker.config.js +22 -0
  43. package/dist/collection/components/cat-datepicker/cat-datepicker.config.js.map +1 -0
  44. package/dist/collection/components/cat-datepicker/cat-datepicker.css +18 -0
  45. package/dist/collection/components/cat-datepicker/cat-datepicker.js +669 -0
  46. package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -0
  47. package/dist/collection/components/cat-datepicker/cat-datepicker.locale.js +51 -0
  48. package/dist/collection/components/cat-datepicker/cat-datepicker.locale.js.map +1 -0
  49. package/dist/collection/components/cat-dropdown/cat-dropdown.css +1 -0
  50. package/dist/collection/components/cat-dropdown/cat-dropdown.js +18 -14
  51. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
  52. package/dist/collection/components/cat-form-group/cat-form-group.js +4 -5
  53. package/dist/collection/components/cat-form-group/cat-form-group.js.map +1 -1
  54. package/dist/collection/components/cat-form-hint/cat-form-hint.js +2 -6
  55. package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -1
  56. package/dist/collection/components/cat-i18n/cat-i18n-registry.js +13 -1
  57. package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
  58. package/dist/collection/components/cat-icon/cat-icon-registry.js +29 -1
  59. package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
  60. package/dist/collection/components/cat-input/cat-input.css +7 -11
  61. package/dist/collection/components/cat-input/cat-input.js +13 -35
  62. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  63. package/dist/collection/components/cat-input/input-type.js.map +1 -1
  64. package/dist/collection/components/cat-notification/cat-notification.js +12 -14
  65. package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
  66. package/dist/collection/components/cat-pagination/cat-pagination.js +28 -6
  67. package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -1
  68. package/dist/collection/components/cat-radio/cat-radio.css +24 -1
  69. package/dist/collection/components/cat-radio/cat-radio.js +10 -31
  70. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  71. package/dist/collection/components/cat-radio-group/cat-radio-group.js +40 -10
  72. package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
  73. package/dist/collection/components/cat-scrollable/cat-scrollable.css +1 -4
  74. package/dist/collection/components/cat-scrollable/cat-scrollable.js +2 -3
  75. package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
  76. package/dist/collection/components/cat-select/cat-select.css +8 -11
  77. package/dist/collection/components/cat-select/cat-select.js +76 -62
  78. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  79. package/dist/collection/components/cat-select-demo/cat-select-demo.js +21 -25
  80. package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
  81. package/dist/collection/components/cat-skeleton/cat-skeleton.css +1 -1
  82. package/dist/collection/components/cat-tabs/cat-tabs.js +4 -7
  83. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
  84. package/dist/collection/components/cat-textarea/cat-textarea.css +9 -12
  85. package/dist/collection/components/cat-textarea/cat-textarea.js +16 -16
  86. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  87. package/dist/collection/components/cat-toggle/cat-toggle.css +24 -1
  88. package/dist/collection/components/cat-toggle/cat-toggle.js +37 -36
  89. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  90. package/dist/collection/components/cat-tooltip/cat-tooltip.css +1 -1
  91. package/dist/collection/components/cat-tooltip/cat-tooltip.js +17 -22
  92. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  93. package/dist/collection/index.cdn.js +7 -0
  94. package/dist/collection/scss/_snippets/_checkbox-hint.scss +20 -0
  95. package/dist/collection/scss/index.scss +2 -0
  96. package/dist/collection/scss/utils/_border.scss +14 -0
  97. package/dist/collection/scss/utils/_media.mixins.scss +0 -1
  98. package/dist/collection/scss/utils/_typography.mixins.scss +1 -0
  99. package/dist/collection/scss/vendor/_flatpickr.scss +314 -0
  100. package/dist/collection/utils/platform.js +1 -1
  101. package/dist/collection/utils/platform.js.map +1 -1
  102. package/dist/components/cat-alert.js +5 -5
  103. package/dist/components/cat-alert.js.map +1 -1
  104. package/dist/components/cat-avatar2.js +5 -5
  105. package/dist/components/cat-avatar2.js.map +1 -1
  106. package/dist/components/cat-button2.js +13 -17
  107. package/dist/components/cat-button2.js.map +1 -1
  108. package/dist/components/cat-checkbox2.js +15 -16
  109. package/dist/components/cat-checkbox2.js.map +1 -1
  110. package/dist/components/{cat-label.d.ts → cat-datepicker.d.ts} +4 -4
  111. package/dist/components/cat-datepicker.js +2907 -0
  112. package/dist/components/cat-datepicker.js.map +1 -0
  113. package/dist/components/cat-dropdown2.js +188 -66
  114. package/dist/components/cat-dropdown2.js.map +1 -1
  115. package/dist/components/cat-form-group.js +4 -5
  116. package/dist/components/cat-form-group.js.map +1 -1
  117. package/dist/components/cat-form-hint.js +2 -6
  118. package/dist/components/cat-form-hint.js.map +1 -1
  119. package/dist/components/cat-i18n-registry.js +13 -1
  120. package/dist/components/cat-i18n-registry.js.map +1 -1
  121. package/dist/components/cat-icon-registry.js +42 -1
  122. package/dist/components/cat-icon-registry.js.map +1 -1
  123. package/dist/components/cat-input.js +1 -226
  124. package/dist/components/cat-input.js.map +1 -1
  125. package/dist/components/cat-input2.js +223 -0
  126. package/dist/components/cat-input2.js.map +1 -0
  127. package/dist/components/cat-pagination.js +10 -5
  128. package/dist/components/cat-pagination.js.map +1 -1
  129. package/dist/components/cat-radio-group.js +15 -9
  130. package/dist/components/cat-radio-group.js.map +1 -1
  131. package/dist/components/cat-radio.js +6 -13
  132. package/dist/components/cat-radio.js.map +1 -1
  133. package/dist/components/cat-scrollable2.js +9 -8
  134. package/dist/components/cat-scrollable2.js.map +1 -1
  135. package/dist/components/cat-select-demo.js +23 -27
  136. package/dist/components/cat-select-demo.js.map +1 -1
  137. package/dist/components/cat-select2.js +70 -60
  138. package/dist/components/cat-select2.js.map +1 -1
  139. package/dist/components/cat-skeleton2.js +1 -1
  140. package/dist/components/cat-skeleton2.js.map +1 -1
  141. package/dist/components/cat-tabs.js +4 -7
  142. package/dist/components/cat-tabs.js.map +1 -1
  143. package/dist/components/cat-textarea.js +13 -13
  144. package/dist/components/cat-textarea.js.map +1 -1
  145. package/dist/components/cat-toggle.js +15 -16
  146. package/dist/components/cat-toggle.js.map +1 -1
  147. package/dist/components/cat-tooltip.js +18 -23
  148. package/dist/components/cat-tooltip.js.map +1 -1
  149. package/dist/components/floating-ui.dom.esm.js +119 -130
  150. package/dist/components/floating-ui.dom.esm.js.map +1 -1
  151. package/dist/components/index.js +12 -14
  152. package/dist/components/index.js.map +1 -1
  153. package/dist/esm/cat-alert_25.entry.js +3391 -506
  154. package/dist/esm/cat-alert_25.entry.js.map +1 -1
  155. package/dist/esm/{cat-icon-registry-d6b80490.js → cat-icon-registry-f15b29d9.js} +56 -3
  156. package/dist/esm/cat-icon-registry-f15b29d9.js.map +1 -0
  157. package/dist/esm/catalyst.js +4 -4
  158. package/dist/esm/catalyst.js.map +1 -1
  159. package/dist/esm/{index-fc2f91a4.js → index-636ce8d6.js} +8 -1
  160. package/dist/esm/index-636ce8d6.js.map +1 -0
  161. package/dist/esm/index.js +14 -16
  162. package/dist/esm/index.js.map +1 -1
  163. package/dist/esm/loader.js +4 -4
  164. package/dist/esm/loader.js.map +1 -1
  165. package/dist/types/@types/Intl.d.ts +3 -0
  166. package/dist/types/components/cat-button/cat-button.d.ts +0 -5
  167. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +11 -9
  168. package/dist/types/components/cat-datepicker/cat-datepicker.config.d.ts +1 -0
  169. package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +143 -0
  170. package/dist/types/components/cat-datepicker/cat-datepicker.locale.d.ts +3 -0
  171. package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +3 -0
  172. package/dist/types/components/cat-input/cat-input.d.ts +2 -6
  173. package/dist/types/components/cat-input/input-type.d.ts +1 -1
  174. package/dist/types/components/cat-pagination/cat-pagination.d.ts +6 -0
  175. package/dist/types/components/cat-radio/cat-radio.d.ts +3 -7
  176. package/dist/types/components/cat-radio-group/cat-radio-group.d.ts +6 -1
  177. package/dist/types/components/cat-select/cat-select.d.ts +6 -1
  178. package/dist/types/components/cat-textarea/cat-textarea.d.ts +4 -4
  179. package/dist/types/components/cat-toggle/cat-toggle.d.ts +10 -8
  180. package/dist/types/components.d.ts +298 -117
  181. package/package.json +21 -19
  182. package/dist/catalyst/p-ba081831.entry.js +0 -10
  183. package/dist/catalyst/p-ba081831.entry.js.map +0 -1
  184. package/dist/catalyst/p-ccfebe33.js +0 -2
  185. package/dist/catalyst/p-ccfebe33.js.map +0 -1
  186. package/dist/cjs/cat-icon-registry-671af264.js.map +0 -1
  187. package/dist/cjs/index-01312a2e.js.map +0 -1
  188. package/dist/collection/components/cat-label/cat-label.css +0 -22
  189. package/dist/collection/components/cat-label/cat-label.js +0 -134
  190. package/dist/collection/components/cat-label/cat-label.js.map +0 -1
  191. package/dist/components/cat-label.js +0 -73
  192. package/dist/components/cat-label.js.map +0 -1
  193. package/dist/esm/cat-icon-registry-d6b80490.js.map +0 -1
  194. package/dist/esm/index-fc2f91a4.js.map +0 -1
  195. package/dist/types/components/cat-label/cat-label.d.ts +0 -27
@@ -13,6 +13,7 @@ const INIT_STATE = {
13
13
  isResolving: false,
14
14
  options: [],
15
15
  selection: [],
16
+ tempSelection: [],
16
17
  activeOptionIndex: -1,
17
18
  activeSelectionIndex: -1
18
19
  };
@@ -75,7 +76,7 @@ export class CatSelect {
75
76
  }
76
77
  else {
77
78
  this.errorMapSrc = Array.isArray(value)
78
- ? value.reduce((acc, err) => (Object.assign(Object.assign({}, acc), { [err]: undefined })), {})
79
+ ? value.reduce((acc, err) => ({ ...acc, [err]: undefined }), {})
79
80
  : value === true
80
81
  ? {}
81
82
  : value || undefined;
@@ -83,13 +84,14 @@ export class CatSelect {
83
84
  }
84
85
  }
85
86
  onStateChange(newState, oldState) {
86
- var _a, _b;
87
87
  const changed = (key) => newState[key] !== oldState[key];
88
88
  if (changed('isOpen')) {
89
89
  this.update();
90
90
  }
91
91
  if (changed('activeOptionIndex') && this.state.activeOptionIndex >= 0) {
92
- (_b = (_a = this.dropdown) === null || _a === void 0 ? void 0 : _a.querySelector(`#select-${this.id}-option-${this.state.activeOptionIndex}`)) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ block: 'nearest' });
92
+ this.dropdown
93
+ ?.querySelector(`#select-${this.id}-option-${this.state.activeOptionIndex}`)
94
+ ?.scrollIntoView({ block: 'nearest' });
93
95
  }
94
96
  if (changed('selection')) {
95
97
  let newValue;
@@ -151,15 +153,25 @@ export class CatSelect {
151
153
  }
152
154
  }
153
155
  this.hide();
154
- this.patchState({ activeSelectionIndex: -1 });
156
+ if (!this.multiple && this.state.tempSelection?.length) {
157
+ this.patchState({
158
+ activeSelectionIndex: -1,
159
+ selection: this.state.tempSelection,
160
+ tempSelection: [],
161
+ options: [],
162
+ term: this.state.tempSelection[0].render.label
163
+ });
164
+ }
165
+ else {
166
+ this.patchState({ activeSelectionIndex: -1 });
167
+ }
155
168
  this.catBlur.emit(event);
156
169
  if (coerceBoolean(this.errorUpdate)) {
157
170
  this.showErrors();
158
171
  }
159
172
  }
160
173
  onKeyDown(event) {
161
- var _a, _b, _c, _d, _e;
162
- const isInputFocused = ((_a = this.hostElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) === this.input;
174
+ const isInputFocused = this.hostElement.shadowRoot?.activeElement === this.input;
163
175
  if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
164
176
  this.onArrowKeyDown(event);
165
177
  }
@@ -192,20 +204,23 @@ export class CatSelect {
192
204
  this.hide();
193
205
  }
194
206
  else if (event.key === 'Backspace' || event.key === 'Delete') {
195
- (_b = this.input) === null || _b === void 0 ? void 0 : _b.focus();
196
- if (!this.multiple || !this.state.term || (((_c = this.input) === null || _c === void 0 ? void 0 : _c.selectionStart) === 0 && event.key === 'Backspace')) {
207
+ this.input?.focus();
208
+ if (!this.multiple || !this.state.term || (this.input?.selectionStart === 0 && event.key === 'Backspace')) {
197
209
  if (this.state.activeSelectionIndex >= 0) {
198
210
  this.deselect(this.state.selection[this.state.activeSelectionIndex].item.id);
199
211
  }
200
212
  else if (this.state.selection.length) {
201
213
  const selectionClone = [...this.state.selection];
202
214
  selectionClone.pop();
203
- this.patchState({ selection: selectionClone });
215
+ this.patchState({
216
+ selection: selectionClone,
217
+ tempSelection: this.state.term ? [...this.state.selection] : []
218
+ });
204
219
  }
205
220
  }
206
221
  }
207
222
  else if (event.key === 'Tab') {
208
- (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.setAttribute('tabindex', '-1');
223
+ this.trigger?.setAttribute('tabindex', '-1');
209
224
  if (this.multiple) {
210
225
  this.patchState({ activeSelectionIndex: -1, activeOptionIndex: -1 });
211
226
  }
@@ -219,21 +234,20 @@ export class CatSelect {
219
234
  }
220
235
  }
221
236
  else if (event.key.length === 1) {
222
- (_e = this.input) === null || _e === void 0 ? void 0 : _e.focus();
237
+ this.input?.focus();
223
238
  }
224
239
  }
225
240
  onKeyUp(event) {
226
- var _a, _b, _c, _d, _e;
227
241
  if (event.key === 'Tab' && !event.shiftKey) {
228
- ((_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());
229
- if (((_c = this.hostElement.shadowRoot) === null || _c === void 0 ? void 0 : _c.activeElement) === this.input) {
242
+ this.hostElement.shadowRoot?.activeElement === this.trigger && this.input?.focus();
243
+ if (this.hostElement.shadowRoot?.activeElement === this.input) {
230
244
  this.show();
231
245
  }
232
246
  }
233
247
  else if (event.key === 'Tab' && event.shiftKey) {
234
- const clearButton = (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.querySelector(`#select-clear-btn-${this.id}`);
248
+ const clearButton = this.trigger?.querySelector(`#select-clear-btn-${this.id}`);
235
249
  if (clearButton) {
236
- ((_e = this.hostElement.shadowRoot) === null || _e === void 0 ? void 0 : _e.activeElement) === clearButton && this.show();
250
+ this.hostElement.shadowRoot?.activeElement === clearButton && this.show();
237
251
  }
238
252
  else {
239
253
  this.show();
@@ -246,22 +260,21 @@ export class CatSelect {
246
260
  * @param connector - The {@link CatSelectConnector} of the select.
247
261
  */
248
262
  async connect(connector) {
249
- var _a;
250
263
  this.connector = connector;
251
264
  let number$;
252
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
265
+ this.subscription?.unsubscribe();
253
266
  this.subscription = this.term$
254
267
  .asObservable()
255
268
  .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 => connector.retrieve(term, number)), tap(page => this.patchState({ isLoading: false, totalElements: page.totalElements })), takeWhile(page => !page.last, true), scan((items, page) => [...items, ...page.content], []))))
256
269
  .subscribe(items => {
257
- var _a;
258
270
  const options = this.toSelectItems(connector, items);
259
271
  if (this.tags &&
260
272
  this.state.term.trim().length &&
261
273
  !options.find(value1 => value1.render.label.toLowerCase() === this.state.term.toLowerCase())) {
262
274
  let label;
263
275
  if (this.isTagSelected(this.state.term)) {
264
- label = (_a = this.state.selection.find(item => item.render.label.toLowerCase() === this.state.term.toLowerCase())) === null || _a === void 0 ? void 0 : _a.render.label;
276
+ label = this.state.selection.find(item => item.render.label.toLowerCase() === this.state.term.toLowerCase())
277
+ ?.render.label;
265
278
  }
266
279
  options.unshift({
267
280
  item: { id: `select-${this.id}-option-tag` },
@@ -274,24 +287,23 @@ export class CatSelect {
274
287
  });
275
288
  }
276
289
  render() {
277
- var _a, _b;
278
290
  return (h(Host, null, h("div", { class: {
279
291
  'select-field': true,
280
292
  'select-horizontal': this.horizontal
281
293
  } }, h("div", { class: {
282
294
  hidden: this.labelHidden,
283
295
  'label-container': true
284
- } }, (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id }, h("span", { class: "label-wrapper", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label, h("div", { class: "label-metadata" }, !this.required && this.requiredMarker.startsWith('optional') && (h("span", { class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker.startsWith('required') && (h("span", { class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")"))))))), h("div", { class: "select-container" }, h("div", { class: { 'select-wrapper': true, 'select-disabled': this.disabled, 'select-invalid': this.invalid }, 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 ? 'true' : false, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) }, h("div", { class: "select-wrapper-inner" }, 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) => {
285
- var _a;
286
- return (h("span", { class: {
287
- pill: true,
288
- 'select-no-open': true,
289
- 'select-option-active': this.state.activeSelectionIndex === i
290
- }, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: (_a = item.render.avatar.initials) !== null && _a !== void 0 ? _a : '' })) : null, h("span", null, item.render.label), !this.disabled && (h("cat-button", { size: "xs", variant: "text", icon: "16-cross", iconOnly: true, a11yLabel: i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1 }))));
291
- }))) : 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: (_a = this.state.selection[0].render.avatar.initials) !== null && _a !== void 0 ? _a : '' })) : null, h("input", Object.assign({}, this.nativeAttributes, { class: "select-input", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": ((_b = this.hint) === null || _b === void 0 ? void 0 : _b.length) ? this.id + '-hint' : undefined, onInput: this.onInput.bind(this), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving }))), this.state.isResolving && h("cat-spinner", null), this.invalid && (h("cat-icon", { icon: "alert-circle-outlined", class: "icon-suffix cat-text-danger", size: "l" })), (this.state.selection.length || this.state.term.length) &&
296
+ } }, (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id }, h("span", { class: "label-wrapper", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label, h("div", { class: "label-metadata" }, !this.required && this.requiredMarker.startsWith('optional') && (h("span", { class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker.startsWith('required') && (h("span", { class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")"))))))), h("div", { class: "select-container" }, h("div", { class: { 'select-wrapper': true, 'select-disabled': this.disabled, 'select-invalid': this.invalid }, 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 ? 'true' : false, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) }, h("div", { class: "select-wrapper-inner" }, 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: {
297
+ pill: true,
298
+ 'select-no-open': true,
299
+ 'select-option-active': this.state.activeSelectionIndex === i
300
+ }, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, h("span", null, item.render.label), !this.disabled && (h("cat-button", { size: "xs", variant: "text", icon: "$cat:select-clear", iconOnly: true, a11yLabel: i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1, onCatClick: event => event.stopPropagation() }))))))) : 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, icon: this.state.selection[0].render.avatar.icon, initials: this.state.selection[0].render.avatar.initials ?? '' })) : null, h("input", { ...this.nativeAttributes, class: "select-input", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hint?.length ? this.id + '-hint' : undefined, onInput: this.onInput.bind(this), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving })), this.state.isResolving && h("cat-spinner", null), this.invalid && (h("cat-icon", { icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" })), (this.state.selection.length || this.state.term.length) &&
292
301
  !this.disabled &&
293
302
  !this.state.isResolving &&
294
- this.clearable ? (h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "cross-circle-outlined", variant: "text", size: "s", a11yLabel: i18n.t('input.clear'), onClick: () => this.clear() })) : null, !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 ? i18n.t('select.close') : i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving }))), (this.hint || this.hasSlottedHint || !!Object.keys(this.errorMap || {}).length) && (h(CatFormHint, { id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))), 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() }, h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.optionsList, this.state.isLoading
303
+ this.clearable ? (h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "$cat:input-close", variant: "text", size: "s", a11yLabel: i18n.t('input.clear'), onCatClick: event => {
304
+ event.stopPropagation();
305
+ this.clear();
306
+ } })) : null, !this.state.isResolving && (h("cat-button", { iconOnly: true, icon: "$cat:select-open", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? i18n.t('select.close') : i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving, onCatClick: event => event.stopPropagation() }))), (this.hint || this.hasSlottedHint || !!Object.keys(this.errorMap || {}).length) && (h(CatFormHint, { id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))), 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() }, h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.optionsList, this.state.isLoading
295
307
  ? Array.from(Array(CatSelect.SKELETON_COUNT)).map(() => (h("li", { class: "select-option-loading" }, h("cat-skeleton", { variant: "body", lines: 1 }), h("cat-skeleton", { variant: "body", lines: 1 }))))
296
308
  : !this.state.options.length &&
297
309
  !this.tags && (h("li", { class: "select-option-empty" }, this.noItems ? this.noItems : i18n.t('select.empty')))))))));
@@ -301,7 +313,6 @@ export class CatSelect {
301
313
  }
302
314
  get optionsList() {
303
315
  return this.state.options.map((item, i) => {
304
- var _a, _b;
305
316
  const isTagOption = this.tags && item.item.id === `select-${this.id}-option-tag`;
306
317
  const isOptionSelected = this.isSelected(item.item.id) || (this.tags && this.isTagSelected(item.render.label));
307
318
  const getLabel = () => {
@@ -310,14 +321,14 @@ export class CatSelect {
310
321
  }
311
322
  return item.render.label;
312
323
  };
313
- return (h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": isOptionSelected ? 'true' : 'false' }, this.multiple ? (h("cat-checkbox", { class: { 'select-option-active': this.state.activeOptionIndex === i }, checked: isOptionSelected, tabIndex: -1, labelLeft: true, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onCatChange: e => {
324
+ return (h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": isOptionSelected ? 'true' : 'false' }, this.multiple ? (h("cat-checkbox", { class: { 'select-option-active': this.state.activeOptionIndex === i }, checked: isOptionSelected, tabIndex: -1, labelLeft: true, onFocus: () => this.input?.focus(), onCatChange: e => {
314
325
  !isTagOption ? this.toggle(item) : this.toggleTag(item);
315
326
  e.stopPropagation();
316
- } }, h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: (_a = item.render.avatar.initials) !== null && _a !== void 0 ? _a : '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
327
+ } }, h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
317
328
  'select-option-inner': true,
318
329
  'select-option-single': true,
319
330
  'select-option-active': this.state.activeOptionIndex === i
320
- }, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => (isTagOption ? this.createTag(item.render.label) : this.select(item)), tabIndex: -1 }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: (_b = item.render.avatar.initials) !== null && _b !== void 0 ? _b : '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))));
331
+ }, onFocus: () => this.input?.focus(), onClick: () => (isTagOption ? this.createTag(item.render.label) : this.select(item)), tabIndex: -1 }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))));
321
332
  });
322
333
  }
323
334
  resolve() {
@@ -351,17 +362,16 @@ export class CatSelect {
351
362
  }
352
363
  toSelectItems(connector, items) {
353
364
  return items.map(item => ({
354
- item: Object.assign(Object.assign({}, item), { id: connector.customId ? connector.customId(item) : item.id }),
365
+ item: { ...item, id: connector.customId ? connector.customId(item) : item.id },
355
366
  render: connector.render(item)
356
367
  }));
357
368
  }
358
369
  show() {
359
- var _a;
360
370
  if (!this.state.isOpen) {
361
371
  this.patchState({ isOpen: true });
362
372
  this.catOpen.emit();
363
- this.term$.next(this.state.term);
364
- (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.remove('select-input-transparent-caret');
373
+ this.term$.next('');
374
+ this.input?.classList.remove('select-input-transparent-caret');
365
375
  }
366
376
  }
367
377
  hide() {
@@ -413,29 +423,27 @@ export class CatSelect {
413
423
  }
414
424
  clear() {
415
425
  if (this.input && this.state.term) {
416
- this.patchState({ selection: [], options: [], term: '', activeOptionIndex: -1 });
426
+ this.patchState({ selection: [], options: [], term: '', activeOptionIndex: -1, tempSelection: [] });
417
427
  this.term$.next('');
418
428
  this.input.value = '';
419
429
  }
420
430
  else {
421
- this.patchState({ selection: [] });
431
+ this.patchState({ selection: [], tempSelection: [] });
422
432
  }
423
433
  }
424
434
  reset(connector) {
425
- var _a;
426
- this.connector = connector !== null && connector !== void 0 ? connector : this.connector;
427
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
435
+ this.connector = connector ?? this.connector;
436
+ this.subscription?.unsubscribe();
428
437
  this.subscription = undefined;
429
438
  this.state = INIT_STATE;
430
439
  }
431
440
  onClick(event) {
432
- var _a, _b;
433
441
  if (this.disabled) {
434
442
  return;
435
443
  }
436
444
  const elem = event.target;
437
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
438
- (_b = this.input) === null || _b === void 0 ? void 0 : _b.focus();
445
+ this.trigger?.setAttribute('tabindex', '0');
446
+ this.input?.focus();
439
447
  if (elem === this.trigger ||
440
448
  elem === this.input ||
441
449
  elem.classList.contains('select-btn') ||
@@ -444,12 +452,16 @@ export class CatSelect {
444
452
  }
445
453
  }
446
454
  onInput() {
447
- var _a;
448
- this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value.trim()) || '');
449
- if (!this.multiple && this.state.selection.length) {
450
- const selectionClone = [...this.state.selection];
451
- selectionClone.pop();
452
- this.patchState({ selection: selectionClone });
455
+ this.search(this.input?.value.trim() || '');
456
+ if (!this.multiple) {
457
+ if (this.state.selection.length) {
458
+ const selectionClone = [...this.state.selection];
459
+ selectionClone.pop();
460
+ this.patchState({ selection: selectionClone, tempSelection: [...this.state.selection] });
461
+ }
462
+ if (!this.input?.value.trim()) {
463
+ this.patchState({ tempSelection: [] });
464
+ }
453
465
  }
454
466
  this.show();
455
467
  }
@@ -469,7 +481,7 @@ export class CatSelect {
469
481
  }
470
482
  }
471
483
  patchState(update) {
472
- this.state = Object.assign(Object.assign({}, this.state), update);
484
+ this.state = { ...this.state, ...update };
473
485
  }
474
486
  isPillboxActive() {
475
487
  return this.state.activeSelectionIndex >= 0;
@@ -485,9 +497,8 @@ export class CatSelect {
485
497
  return activeDescendant;
486
498
  }
487
499
  onArrowKeyDown(event) {
488
- var _a, _b;
489
500
  let preventDefault = false;
490
- (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
501
+ this.input?.focus();
491
502
  switch (event.key) {
492
503
  case 'ArrowDown':
493
504
  preventDefault = true;
@@ -508,7 +519,7 @@ export class CatSelect {
508
519
  : this.hide();
509
520
  break;
510
521
  case 'ArrowLeft':
511
- if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
522
+ if (this.input?.selectionStart === 0) {
512
523
  preventDefault = true;
513
524
  let index;
514
525
  this.state.activeSelectionIndex > 0
@@ -544,7 +555,7 @@ export class CatSelect {
544
555
  createTag(term) {
545
556
  if (term.trim().length && !this.isTagSelected(term)) {
546
557
  const value = this.value;
547
- const tags = value === null || value === void 0 ? void 0 : value.tags;
558
+ const tags = value?.tags;
548
559
  const tag = { id: `select-${this.id}-tag-${tags ? tags.length : 0}`, name: term };
549
560
  this.select({ item: tag, render: { label: tag.name } });
550
561
  }
@@ -598,10 +609,9 @@ export class CatSelect {
598
609
  return tags;
599
610
  }
600
611
  setTransparentCaret() {
601
- var _a;
602
612
  if (!this.multiple) {
603
613
  this.hide();
604
- (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
614
+ this.input?.classList.add('select-input-transparent-caret');
605
615
  }
606
616
  }
607
617
  showErrors() {
@@ -1083,9 +1093,13 @@ export class CatSelect {
1083
1093
  "text": "Emitted when the value is changed."
1084
1094
  },
1085
1095
  "complexType": {
1086
- "original": "any",
1087
- "resolved": "any",
1088
- "references": {}
1096
+ "original": "InputEvent",
1097
+ "resolved": "InputEvent",
1098
+ "references": {
1099
+ "InputEvent": {
1100
+ "location": "global"
1101
+ }
1102
+ }
1089
1103
  }
1090
1104
  }, {
1091
1105
  "method": "catBlur",