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