@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.
- package/dist/catalyst/catalyst.css +1127 -39
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.cdn.js +7 -0
- package/dist/catalyst/index.esm.js +2 -2
- package/dist/catalyst/index.esm.js.map +1 -1
- package/dist/catalyst/p-ad5fca6b.entry.js +10 -0
- package/dist/catalyst/p-ad5fca6b.entry.js.map +1 -0
- package/dist/catalyst/{p-d1fb9d96.js → p-ce6a1db2.js} +1 -1
- package/dist/catalyst/p-ce6a1db2.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/_snippets/_checkbox-hint.scss +20 -0
- package/dist/catalyst/scss/index.scss +2 -0
- package/dist/catalyst/scss/utils/_border.scss +14 -0
- package/dist/catalyst/scss/utils/_media.mixins.scss +0 -1
- package/dist/catalyst/scss/utils/_typography.mixins.scss +1 -0
- package/dist/catalyst/scss/vendor/_flatpickr.scss +314 -0
- package/dist/cjs/cat-alert_25.cjs.entry.js +3391 -506
- package/dist/cjs/cat-alert_25.cjs.entry.js.map +1 -1
- package/dist/cjs/{cat-icon-registry-671af264.js → cat-icon-registry-6161e2ee.js} +56 -3
- package/dist/cjs/cat-icon-registry-6161e2ee.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +3 -3
- package/dist/cjs/catalyst.cjs.js.map +1 -1
- package/dist/cjs/{index-01312a2e.js → index-4258b31e.js} +8 -1
- package/dist/{catalyst/p-d1fb9d96.js.map → cjs/index-4258b31e.js.map} +1 -1
- package/dist/cjs/index.cjs.js +13 -15
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/components/cat-alert/cat-alert.js +5 -5
- package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
- 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.css +7 -7
- package/dist/collection/components/cat-button/cat-button.js +11 -31
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +24 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +38 -37
- 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 +18 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +669 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -0
- 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.css +1 -0
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +18 -14
- 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-icon/cat-icon-registry.js +29 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +7 -11
- package/dist/collection/components/cat-input/cat-input.js +13 -35
- 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 +12 -14
- package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.js +28 -6
- package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.css +24 -1
- package/dist/collection/components/cat-radio/cat-radio.js +10 -31
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +40 -10
- package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.css +1 -4
- 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.css +8 -11
- package/dist/collection/components/cat-select/cat-select.js +76 -62
- 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-skeleton/cat-skeleton.css +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.css +9 -12
- package/dist/collection/components/cat-textarea/cat-textarea.js +16 -16
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.css +24 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js +37 -36
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +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 +7 -0
- package/dist/collection/scss/_snippets/_checkbox-hint.scss +20 -0
- package/dist/collection/scss/index.scss +2 -0
- package/dist/collection/scss/utils/_border.scss +14 -0
- package/dist/collection/scss/utils/_media.mixins.scss +0 -1
- package/dist/collection/scss/utils/_typography.mixins.scss +1 -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-alert.js +5 -5
- package/dist/components/cat-alert.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 +13 -17
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox2.js +15 -16
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/{cat-label.d.ts → cat-datepicker.d.ts} +4 -4
- package/dist/components/cat-datepicker.js +2907 -0
- package/dist/components/cat-datepicker.js.map +1 -0
- package/dist/components/cat-dropdown2.js +188 -66
- 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-icon-registry.js +42 -1
- package/dist/components/cat-icon-registry.js.map +1 -1
- package/dist/components/cat-input.js +1 -226
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-input2.js +223 -0
- package/dist/components/cat-input2.js.map +1 -0
- package/dist/components/cat-pagination.js +10 -5
- 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 +6 -13
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-scrollable2.js +9 -8
- package/dist/components/cat-scrollable2.js.map +1 -1
- package/dist/components/cat-select-demo.js +23 -27
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js +70 -60
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-skeleton2.js +1 -1
- package/dist/components/cat-skeleton2.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 +13 -13
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +15 -16
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +18 -23
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +119 -130
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/components/index.js +12 -14
- package/dist/components/index.js.map +1 -1
- package/dist/esm/cat-alert_25.entry.js +3391 -506
- package/dist/esm/cat-alert_25.entry.js.map +1 -1
- package/dist/esm/{cat-icon-registry-d6b80490.js → cat-icon-registry-f15b29d9.js} +56 -3
- package/dist/esm/cat-icon-registry-f15b29d9.js.map +1 -0
- package/dist/esm/catalyst.js +4 -4
- package/dist/esm/catalyst.js.map +1 -1
- package/dist/esm/{index-fc2f91a4.js → index-636ce8d6.js} +8 -1
- package/dist/esm/index-636ce8d6.js.map +1 -0
- package/dist/esm/index.js +14 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +4 -4
- package/dist/esm/loader.js.map +1 -1
- package/dist/types/@types/Intl.d.ts +3 -0
- package/dist/types/components/cat-button/cat-button.d.ts +0 -5
- 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 +143 -0
- 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 +6 -0
- 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-select/cat-select.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 +298 -117
- package/package.json +21 -19
- package/dist/catalyst/p-ba081831.entry.js +0 -10
- package/dist/catalyst/p-ba081831.entry.js.map +0 -1
- package/dist/catalyst/p-ccfebe33.js +0 -2
- package/dist/catalyst/p-ccfebe33.js.map +0 -1
- package/dist/cjs/cat-icon-registry-671af264.js.map +0 -1
- package/dist/cjs/index-01312a2e.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/components/cat-label.js +0 -73
- package/dist/components/cat-label.js.map +0 -1
- package/dist/esm/cat-icon-registry-d6b80490.js.map +0 -1
- package/dist/esm/index-fc2f91a4.js.map +0 -1
- 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) => (
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
196
|
-
if (!this.multiple || !this.state.term || (
|
|
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({
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
229
|
-
if (
|
|
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 =
|
|
248
|
+
const clearButton = this.trigger?.querySelector(`#select-clear-btn-${this.id}`);
|
|
235
249
|
if (clearButton) {
|
|
236
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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: "
|
|
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: () =>
|
|
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,
|
|
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: () =>
|
|
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:
|
|
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(
|
|
364
|
-
|
|
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
|
-
|
|
426
|
-
this.
|
|
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
|
-
|
|
438
|
-
|
|
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
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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 =
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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
|
-
|
|
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": "
|
|
1087
|
-
"resolved": "
|
|
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",
|