@haiilo/catalyst 5.4.0 → 6.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.
- package/dist/catalyst/catalyst.css +1071 -0
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.cdn.js +6 -0
- package/dist/catalyst/index.esm.js +2 -2
- package/dist/catalyst/index.esm.js.map +1 -1
- package/dist/catalyst/p-60298958.entry.js +10 -0
- package/dist/catalyst/p-60298958.entry.js.map +1 -0
- package/dist/catalyst/p-d7dc291a.js +2 -0
- package/dist/catalyst/p-d7dc291a.js.map +1 -0
- package/dist/catalyst/scss/index.scss +2 -0
- package/dist/catalyst/scss/vendor/_flatpickr.scss +314 -0
- package/dist/cjs/{cat-alert_27.cjs.entry.js → cat-alert_25.cjs.entry.js} +2927 -3476
- package/dist/cjs/cat-alert_25.cjs.entry.js.map +1 -0
- package/dist/cjs/{cat-icon-registry-228164a1.js → cat-icon-registry-6161e2ee.js} +14 -2
- package/dist/cjs/cat-icon-registry-6161e2ee.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +12 -14
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +0 -2
- package/dist/collection/components/cat-avatar/cat-avatar.js +5 -5
- package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -1
- package/dist/collection/components/cat-button/cat-button.js +5 -7
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +39 -42
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/cat-datepicker/cat-datepicker.config.js +22 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.config.js.map +1 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.css +6 -369
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +115 -310
- package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
- package/dist/collection/components/cat-datepicker/cat-datepicker.locale.js +51 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.locale.js.map +1 -0
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +6 -9
- package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
- package/dist/collection/components/cat-form-group/cat-form-group.js +4 -5
- package/dist/collection/components/cat-form-group/cat-form-group.js.map +1 -1
- package/dist/collection/components/cat-form-hint/cat-form-hint.js +2 -6
- package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -1
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js +13 -1
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +0 -377
- package/dist/collection/components/cat-input/cat-input.js +14 -40
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-input/input-type.js.map +1 -1
- package/dist/collection/components/cat-notification/cat-notification.js +11 -13
- package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.js +2 -2
- package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.js +11 -36
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +37 -11
- package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +2 -3
- package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.js +42 -53
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +21 -25
- package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.js +4 -7
- package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js +17 -21
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js +38 -41
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +17 -22
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/index.cdn.js +6 -0
- package/dist/collection/scss/index.scss +2 -0
- package/dist/collection/scss/vendor/_flatpickr.scss +314 -0
- package/dist/collection/utils/platform.js +1 -1
- package/dist/collection/utils/platform.js.map +1 -1
- package/dist/components/cat-avatar2.js +5 -5
- package/dist/components/cat-avatar2.js.map +1 -1
- package/dist/components/cat-button2.js +6 -8
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox2.js +14 -15
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/cat-datepicker.js +2730 -3024
- package/dist/components/cat-datepicker.js.map +1 -1
- package/dist/components/cat-dropdown2.js +6 -9
- package/dist/components/cat-dropdown2.js.map +1 -1
- package/dist/components/cat-form-group.js +4 -5
- package/dist/components/cat-form-group.js.map +1 -1
- package/dist/components/cat-form-hint.js +2 -6
- package/dist/components/cat-form-hint.js.map +1 -1
- package/dist/components/cat-i18n-registry.js +13 -1
- package/dist/components/cat-i18n-registry.js.map +1 -1
- package/dist/components/cat-input2.js +9 -16
- package/dist/components/cat-input2.js.map +1 -1
- package/dist/components/cat-pagination.js.map +1 -1
- package/dist/components/cat-radio-group.js +15 -9
- package/dist/components/cat-radio-group.js.map +1 -1
- package/dist/components/cat-radio.js +5 -12
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-scrollable2.js +2 -3
- package/dist/components/cat-scrollable2.js.map +1 -1
- package/dist/components/cat-select-demo.js +21 -25
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js +42 -53
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-tabs.js +4 -7
- package/dist/components/cat-tabs.js.map +1 -1
- package/dist/components/cat-textarea.js +11 -11
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +14 -15
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +17 -22
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +55 -68
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/components/index.js +11 -13
- package/dist/components/index.js.map +1 -1
- package/dist/esm/{cat-alert_27.entry.js → cat-alert_25.entry.js} +2927 -3474
- package/dist/esm/cat-alert_25.entry.js.map +1 -0
- package/dist/esm/{cat-icon-registry-4bd597f4.js → cat-icon-registry-f15b29d9.js} +14 -2
- package/dist/esm/cat-icon-registry-f15b29d9.js.map +1 -0
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/index.js +13 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/@types/Intl.d.ts +3 -0
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +11 -9
- package/dist/types/components/cat-datepicker/cat-datepicker.config.d.ts +1 -0
- package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +21 -64
- package/dist/types/components/cat-datepicker/cat-datepicker.locale.d.ts +3 -0
- package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +3 -0
- package/dist/types/components/cat-input/cat-input.d.ts +2 -6
- package/dist/types/components/cat-input/input-type.d.ts +1 -1
- package/dist/types/components/cat-pagination/cat-pagination.d.ts +1 -1
- package/dist/types/components/cat-radio/cat-radio.d.ts +3 -7
- package/dist/types/components/cat-radio-group/cat-radio-group.d.ts +6 -1
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +4 -4
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +10 -8
- package/dist/types/components.d.ts +83 -417
- package/package.json +8 -10
- package/dist/catalyst/p-34e0cbba.entry.js +0 -10
- package/dist/catalyst/p-34e0cbba.entry.js.map +0 -1
- package/dist/catalyst/p-cf32399c.js +0 -2
- package/dist/catalyst/p-cf32399c.js.map +0 -1
- package/dist/cjs/cat-alert_27.cjs.entry.js.map +0 -1
- package/dist/cjs/cat-icon-registry-228164a1.js.map +0 -1
- package/dist/collection/components/cat-datepicker/datepicker-type.js +0 -8
- package/dist/collection/components/cat-datepicker/datepicker-type.js.map +0 -1
- package/dist/collection/components/cat-datepicker/dayjs.config.js +0 -8
- package/dist/collection/components/cat-datepicker/dayjs.config.js.map +0 -1
- package/dist/collection/components/cat-datepicker/vanillajs-datepicker.config.js +0 -46
- package/dist/collection/components/cat-datepicker/vanillajs-datepicker.config.js.map +0 -1
- package/dist/collection/components/cat-label/cat-label.css +0 -22
- package/dist/collection/components/cat-label/cat-label.js +0 -134
- package/dist/collection/components/cat-label/cat-label.js.map +0 -1
- package/dist/collection/components/cat-timepicker/cat-timepicker.css +0 -5
- package/dist/collection/components/cat-timepicker/cat-timepicker.js +0 -668
- package/dist/collection/components/cat-timepicker/cat-timepicker.js.map +0 -1
- package/dist/components/cat-label.d.ts +0 -11
- package/dist/components/cat-label.js +0 -73
- package/dist/components/cat-label.js.map +0 -1
- package/dist/components/cat-timepicker.d.ts +0 -11
- package/dist/components/cat-timepicker.js +0 -258
- package/dist/components/cat-timepicker.js.map +0 -1
- package/dist/esm/cat-alert_27.entry.js.map +0 -1
- package/dist/esm/cat-icon-registry-4bd597f4.js.map +0 -1
- package/dist/types/components/cat-datepicker/datepicker-type.d.ts +0 -7
- package/dist/types/components/cat-datepicker/datepicker.d.ts +0 -1
- package/dist/types/components/cat-datepicker/dayjs.config.d.ts +0 -3
- package/dist/types/components/cat-datepicker/vanillajs-datepicker.config.d.ts +0 -4
- package/dist/types/components/cat-label/cat-label.d.ts +0 -27
- package/dist/types/components/cat-timepicker/cat-timepicker.d.ts +0 -158
|
@@ -76,7 +76,7 @@ export class CatSelect {
|
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
78
|
this.errorMapSrc = Array.isArray(value)
|
|
79
|
-
? value.reduce((acc, err) => (
|
|
79
|
+
? value.reduce((acc, err) => ({ ...acc, [err]: undefined }), {})
|
|
80
80
|
: value === true
|
|
81
81
|
? {}
|
|
82
82
|
: value || undefined;
|
|
@@ -84,13 +84,14 @@ export class CatSelect {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
onStateChange(newState, oldState) {
|
|
87
|
-
var _a, _b;
|
|
88
87
|
const changed = (key) => newState[key] !== oldState[key];
|
|
89
88
|
if (changed('isOpen')) {
|
|
90
89
|
this.update();
|
|
91
90
|
}
|
|
92
91
|
if (changed('activeOptionIndex') && this.state.activeOptionIndex >= 0) {
|
|
93
|
-
|
|
92
|
+
this.dropdown
|
|
93
|
+
?.querySelector(`#select-${this.id}-option-${this.state.activeOptionIndex}`)
|
|
94
|
+
?.scrollIntoView({ block: 'nearest' });
|
|
94
95
|
}
|
|
95
96
|
if (changed('selection')) {
|
|
96
97
|
let newValue;
|
|
@@ -143,7 +144,6 @@ export class CatSelect {
|
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
onBlur(event) {
|
|
146
|
-
var _a;
|
|
147
147
|
if (!this.multiple && this.state.activeOptionIndex >= 0) {
|
|
148
148
|
if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
|
|
149
149
|
this.createTag(this.state.term);
|
|
@@ -153,7 +153,7 @@ export class CatSelect {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
this.hide();
|
|
156
|
-
if (!this.multiple &&
|
|
156
|
+
if (!this.multiple && this.state.tempSelection?.length) {
|
|
157
157
|
this.patchState({
|
|
158
158
|
activeSelectionIndex: -1,
|
|
159
159
|
selection: this.state.tempSelection,
|
|
@@ -171,8 +171,7 @@ export class CatSelect {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
onKeyDown(event) {
|
|
174
|
-
|
|
175
|
-
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;
|
|
176
175
|
if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
177
176
|
this.onArrowKeyDown(event);
|
|
178
177
|
}
|
|
@@ -205,8 +204,8 @@ export class CatSelect {
|
|
|
205
204
|
this.hide();
|
|
206
205
|
}
|
|
207
206
|
else if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
208
|
-
|
|
209
|
-
if (!this.multiple || !this.state.term || (
|
|
207
|
+
this.input?.focus();
|
|
208
|
+
if (!this.multiple || !this.state.term || (this.input?.selectionStart === 0 && event.key === 'Backspace')) {
|
|
210
209
|
if (this.state.activeSelectionIndex >= 0) {
|
|
211
210
|
this.deselect(this.state.selection[this.state.activeSelectionIndex].item.id);
|
|
212
211
|
}
|
|
@@ -221,7 +220,7 @@ export class CatSelect {
|
|
|
221
220
|
}
|
|
222
221
|
}
|
|
223
222
|
else if (event.key === 'Tab') {
|
|
224
|
-
|
|
223
|
+
this.trigger?.setAttribute('tabindex', '-1');
|
|
225
224
|
if (this.multiple) {
|
|
226
225
|
this.patchState({ activeSelectionIndex: -1, activeOptionIndex: -1 });
|
|
227
226
|
}
|
|
@@ -235,21 +234,20 @@ export class CatSelect {
|
|
|
235
234
|
}
|
|
236
235
|
}
|
|
237
236
|
else if (event.key.length === 1) {
|
|
238
|
-
|
|
237
|
+
this.input?.focus();
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
240
|
onKeyUp(event) {
|
|
242
|
-
var _a, _b, _c, _d, _e;
|
|
243
241
|
if (event.key === 'Tab' && !event.shiftKey) {
|
|
244
|
-
|
|
245
|
-
if (
|
|
242
|
+
this.hostElement.shadowRoot?.activeElement === this.trigger && this.input?.focus();
|
|
243
|
+
if (this.hostElement.shadowRoot?.activeElement === this.input) {
|
|
246
244
|
this.show();
|
|
247
245
|
}
|
|
248
246
|
}
|
|
249
247
|
else if (event.key === 'Tab' && event.shiftKey) {
|
|
250
|
-
const clearButton =
|
|
248
|
+
const clearButton = this.trigger?.querySelector(`#select-clear-btn-${this.id}`);
|
|
251
249
|
if (clearButton) {
|
|
252
|
-
|
|
250
|
+
this.hostElement.shadowRoot?.activeElement === clearButton && this.show();
|
|
253
251
|
}
|
|
254
252
|
else {
|
|
255
253
|
this.show();
|
|
@@ -262,22 +260,21 @@ export class CatSelect {
|
|
|
262
260
|
* @param connector - The {@link CatSelectConnector} of the select.
|
|
263
261
|
*/
|
|
264
262
|
async connect(connector) {
|
|
265
|
-
var _a;
|
|
266
263
|
this.connector = connector;
|
|
267
264
|
let number$;
|
|
268
|
-
|
|
265
|
+
this.subscription?.unsubscribe();
|
|
269
266
|
this.subscription = this.term$
|
|
270
267
|
.asObservable()
|
|
271
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], []))))
|
|
272
269
|
.subscribe(items => {
|
|
273
|
-
var _a;
|
|
274
270
|
const options = this.toSelectItems(connector, items);
|
|
275
271
|
if (this.tags &&
|
|
276
272
|
this.state.term.trim().length &&
|
|
277
273
|
!options.find(value1 => value1.render.label.toLowerCase() === this.state.term.toLowerCase())) {
|
|
278
274
|
let label;
|
|
279
275
|
if (this.isTagSelected(this.state.term)) {
|
|
280
|
-
label =
|
|
276
|
+
label = this.state.selection.find(item => item.render.label.toLowerCase() === this.state.term.toLowerCase())
|
|
277
|
+
?.render.label;
|
|
281
278
|
}
|
|
282
279
|
options.unshift({
|
|
283
280
|
item: { id: `select-${this.id}-option-tag` },
|
|
@@ -290,24 +287,23 @@ export class CatSelect {
|
|
|
290
287
|
});
|
|
291
288
|
}
|
|
292
289
|
render() {
|
|
293
|
-
var _a, _b;
|
|
294
290
|
return (h(Host, null, h("div", { class: {
|
|
295
291
|
'select-field': true,
|
|
296
292
|
'select-horizontal': this.horizontal
|
|
297
293
|
} }, h("div", { class: {
|
|
298
294
|
hidden: this.labelHidden,
|
|
299
295
|
'label-container': true
|
|
300
|
-
} }, (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) => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
'select-option-active': this.state.activeSelectionIndex === i
|
|
306
|
-
}, 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: (_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: "$cat:select-clear", iconOnly: true, a11yLabel: i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1 }))));
|
|
307
|
-
}))) : 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: (_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: "$cat:input-error", 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) &&
|
|
308
301
|
!this.disabled &&
|
|
309
302
|
!this.state.isResolving &&
|
|
310
|
-
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'),
|
|
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
|
|
311
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 }))))
|
|
312
308
|
: !this.state.options.length &&
|
|
313
309
|
!this.tags && (h("li", { class: "select-option-empty" }, this.noItems ? this.noItems : i18n.t('select.empty')))))))));
|
|
@@ -317,7 +313,6 @@ export class CatSelect {
|
|
|
317
313
|
}
|
|
318
314
|
get optionsList() {
|
|
319
315
|
return this.state.options.map((item, i) => {
|
|
320
|
-
var _a, _b;
|
|
321
316
|
const isTagOption = this.tags && item.item.id === `select-${this.id}-option-tag`;
|
|
322
317
|
const isOptionSelected = this.isSelected(item.item.id) || (this.tags && this.isTagSelected(item.render.label));
|
|
323
318
|
const getLabel = () => {
|
|
@@ -326,14 +321,14 @@ export class CatSelect {
|
|
|
326
321
|
}
|
|
327
322
|
return item.render.label;
|
|
328
323
|
};
|
|
329
|
-
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: () =>
|
|
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 => {
|
|
330
325
|
!isTagOption ? this.toggle(item) : this.toggleTag(item);
|
|
331
326
|
e.stopPropagation();
|
|
332
|
-
} }, 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:
|
|
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: {
|
|
333
328
|
'select-option-inner': true,
|
|
334
329
|
'select-option-single': true,
|
|
335
330
|
'select-option-active': this.state.activeOptionIndex === i
|
|
336
|
-
}, onFocus: () =>
|
|
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))))));
|
|
337
332
|
});
|
|
338
333
|
}
|
|
339
334
|
resolve() {
|
|
@@ -367,17 +362,16 @@ export class CatSelect {
|
|
|
367
362
|
}
|
|
368
363
|
toSelectItems(connector, items) {
|
|
369
364
|
return items.map(item => ({
|
|
370
|
-
item:
|
|
365
|
+
item: { ...item, id: connector.customId ? connector.customId(item) : item.id },
|
|
371
366
|
render: connector.render(item)
|
|
372
367
|
}));
|
|
373
368
|
}
|
|
374
369
|
show() {
|
|
375
|
-
var _a;
|
|
376
370
|
if (!this.state.isOpen) {
|
|
377
371
|
this.patchState({ isOpen: true });
|
|
378
372
|
this.catOpen.emit();
|
|
379
373
|
this.term$.next('');
|
|
380
|
-
|
|
374
|
+
this.input?.classList.remove('select-input-transparent-caret');
|
|
381
375
|
}
|
|
382
376
|
}
|
|
383
377
|
hide() {
|
|
@@ -438,20 +432,18 @@ export class CatSelect {
|
|
|
438
432
|
}
|
|
439
433
|
}
|
|
440
434
|
reset(connector) {
|
|
441
|
-
|
|
442
|
-
this.
|
|
443
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
435
|
+
this.connector = connector ?? this.connector;
|
|
436
|
+
this.subscription?.unsubscribe();
|
|
444
437
|
this.subscription = undefined;
|
|
445
438
|
this.state = INIT_STATE;
|
|
446
439
|
}
|
|
447
440
|
onClick(event) {
|
|
448
|
-
var _a, _b;
|
|
449
441
|
if (this.disabled) {
|
|
450
442
|
return;
|
|
451
443
|
}
|
|
452
444
|
const elem = event.target;
|
|
453
|
-
|
|
454
|
-
|
|
445
|
+
this.trigger?.setAttribute('tabindex', '0');
|
|
446
|
+
this.input?.focus();
|
|
455
447
|
if (elem === this.trigger ||
|
|
456
448
|
elem === this.input ||
|
|
457
449
|
elem.classList.contains('select-btn') ||
|
|
@@ -460,15 +452,14 @@ export class CatSelect {
|
|
|
460
452
|
}
|
|
461
453
|
}
|
|
462
454
|
onInput() {
|
|
463
|
-
|
|
464
|
-
this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value.trim()) || '');
|
|
455
|
+
this.search(this.input?.value.trim() || '');
|
|
465
456
|
if (!this.multiple) {
|
|
466
457
|
if (this.state.selection.length) {
|
|
467
458
|
const selectionClone = [...this.state.selection];
|
|
468
459
|
selectionClone.pop();
|
|
469
460
|
this.patchState({ selection: selectionClone, tempSelection: [...this.state.selection] });
|
|
470
461
|
}
|
|
471
|
-
if (!
|
|
462
|
+
if (!this.input?.value.trim()) {
|
|
472
463
|
this.patchState({ tempSelection: [] });
|
|
473
464
|
}
|
|
474
465
|
}
|
|
@@ -490,7 +481,7 @@ export class CatSelect {
|
|
|
490
481
|
}
|
|
491
482
|
}
|
|
492
483
|
patchState(update) {
|
|
493
|
-
this.state =
|
|
484
|
+
this.state = { ...this.state, ...update };
|
|
494
485
|
}
|
|
495
486
|
isPillboxActive() {
|
|
496
487
|
return this.state.activeSelectionIndex >= 0;
|
|
@@ -506,9 +497,8 @@ export class CatSelect {
|
|
|
506
497
|
return activeDescendant;
|
|
507
498
|
}
|
|
508
499
|
onArrowKeyDown(event) {
|
|
509
|
-
var _a, _b;
|
|
510
500
|
let preventDefault = false;
|
|
511
|
-
|
|
501
|
+
this.input?.focus();
|
|
512
502
|
switch (event.key) {
|
|
513
503
|
case 'ArrowDown':
|
|
514
504
|
preventDefault = true;
|
|
@@ -529,7 +519,7 @@ export class CatSelect {
|
|
|
529
519
|
: this.hide();
|
|
530
520
|
break;
|
|
531
521
|
case 'ArrowLeft':
|
|
532
|
-
if (
|
|
522
|
+
if (this.input?.selectionStart === 0) {
|
|
533
523
|
preventDefault = true;
|
|
534
524
|
let index;
|
|
535
525
|
this.state.activeSelectionIndex > 0
|
|
@@ -565,7 +555,7 @@ export class CatSelect {
|
|
|
565
555
|
createTag(term) {
|
|
566
556
|
if (term.trim().length && !this.isTagSelected(term)) {
|
|
567
557
|
const value = this.value;
|
|
568
|
-
const tags = value
|
|
558
|
+
const tags = value?.tags;
|
|
569
559
|
const tag = { id: `select-${this.id}-tag-${tags ? tags.length : 0}`, name: term };
|
|
570
560
|
this.select({ item: tag, render: { label: tag.name } });
|
|
571
561
|
}
|
|
@@ -619,10 +609,9 @@ export class CatSelect {
|
|
|
619
609
|
return tags;
|
|
620
610
|
}
|
|
621
611
|
setTransparentCaret() {
|
|
622
|
-
var _a;
|
|
623
612
|
if (!this.multiple) {
|
|
624
613
|
this.hide();
|
|
625
|
-
|
|
614
|
+
this.input?.classList.add('select-input-transparent-caret');
|
|
626
615
|
}
|
|
627
616
|
}
|
|
628
617
|
showErrors() {
|