@nectary/components 5.51.1 → 5.52.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/bundle.js +22 -4
- package/package.json +1 -1
- package/select-menu/index.d.ts +2 -0
- package/select-menu/index.js +22 -4
- package/select-menu/types.d.ts +2 -0
package/bundle.js
CHANGED
|
@@ -16029,9 +16029,10 @@ class SelectMenuOption extends NectaryElement {
|
|
|
16029
16029
|
}
|
|
16030
16030
|
defineCustomElement("sinch-select-menu-option", SelectMenuOption);
|
|
16031
16031
|
const isSelectMenuOption = (el) => el.localName === "sinch-select-menu-option";
|
|
16032
|
-
const templateHTML$h = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto;max-height:var(--sinch-comp-select-menu-font-max-height)}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#
|
|
16032
|
+
const templateHTML$h = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto;max-height:var(--sinch-comp-select-menu-font-max-height)}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#no-results{display:flex;align-items:center;justify-content:center;width:100%;height:30px;margin-bottom:10px;pointer-events:none;user-select:none;--sinch-comp-text-font:var(--sinch-comp-select-menu-font-not-found-text);--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-not-found-text-initial)}#no-results:not(.active){display:none}::slotted(.hidden){display:none}::slotted(sinch-title){padding:8px 16px;--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-title-initial)}</style><sinch-input id="search" size="s" placeholder="Search" aria-label="Search"><sinch-icon icons-version="2" name="magnifying-glass" id="icon-search" slot="icon"></sinch-icon><sinch-button id="search-clear" slot="right"><sinch-icon icons-version="2" name="fa-xmark" slot="icon"></sinch-icon></sinch-button></sinch-input><div id="no-results"><sinch-text id="no-results-text" type="m"></sinch-text></div><div id="listbox" role="listbox" tabindex="-1"><slot></slot></div>';
|
|
16033
16033
|
const ITEM_HEIGHT = 40;
|
|
16034
16034
|
const DEFAULT_SEARCH_LABEL = "Search";
|
|
16035
|
+
const DEFAULT_NO_RESULTS_TEXT = "No results";
|
|
16035
16036
|
const template$h = document.createElement("template");
|
|
16036
16037
|
template$h.innerHTML = templateHTML$h;
|
|
16037
16038
|
class SelectMenu extends NectaryElement {
|
|
@@ -16039,7 +16040,8 @@ class SelectMenu extends NectaryElement {
|
|
|
16039
16040
|
#$listbox;
|
|
16040
16041
|
#$search;
|
|
16041
16042
|
#$searchClear;
|
|
16042
|
-
#$
|
|
16043
|
+
#$noResults;
|
|
16044
|
+
#$noResultsText;
|
|
16043
16045
|
#controller = null;
|
|
16044
16046
|
#searchDebounce;
|
|
16045
16047
|
#internals;
|
|
@@ -16054,7 +16056,8 @@ class SelectMenu extends NectaryElement {
|
|
|
16054
16056
|
this.#$listbox = shadowRoot.querySelector("#listbox");
|
|
16055
16057
|
this.#$search = shadowRoot.querySelector("#search");
|
|
16056
16058
|
this.#$searchClear = shadowRoot.querySelector("#search-clear");
|
|
16057
|
-
this.#$
|
|
16059
|
+
this.#$noResults = shadowRoot.querySelector("#no-results");
|
|
16060
|
+
this.#$noResultsText = shadowRoot.querySelector("#no-results-text");
|
|
16058
16061
|
this.#searchDebounce = debounceTimeout(200)(this.#updateSearchValue);
|
|
16059
16062
|
}
|
|
16060
16063
|
connectedCallback() {
|
|
@@ -16065,6 +16068,7 @@ class SelectMenu extends NectaryElement {
|
|
|
16065
16068
|
};
|
|
16066
16069
|
this.setAttribute("role", "group");
|
|
16067
16070
|
this.tabIndex = 0;
|
|
16071
|
+
this.#updateNoResultsText(this.getAttribute("no-results-text"));
|
|
16068
16072
|
this.#syncListboxLabel();
|
|
16069
16073
|
this.addEventListener("keydown", this.#onListboxKeyDown, options);
|
|
16070
16074
|
this.addEventListener("focus", this.#onFocus, options);
|
|
@@ -16141,6 +16145,7 @@ class SelectMenu extends NectaryElement {
|
|
|
16141
16145
|
"search-value",
|
|
16142
16146
|
// eslint-disable-next-line @nectary/observed-attribute-accessor -- baseline backlog: missing set searchPlaceholder
|
|
16143
16147
|
"search-placeholder",
|
|
16148
|
+
"no-results-text",
|
|
16144
16149
|
// eslint-disable-next-line @nectary/observed-attribute-accessor -- baseline backlog: missing set searchAutocomplete
|
|
16145
16150
|
"search-autocomplete"
|
|
16146
16151
|
];
|
|
@@ -16184,6 +16189,10 @@ class SelectMenu extends NectaryElement {
|
|
|
16184
16189
|
this.#updateSearchPlaceholder(newVal);
|
|
16185
16190
|
break;
|
|
16186
16191
|
}
|
|
16192
|
+
case "no-results-text": {
|
|
16193
|
+
this.#updateNoResultsText(newVal);
|
|
16194
|
+
break;
|
|
16195
|
+
}
|
|
16187
16196
|
case "search-value": {
|
|
16188
16197
|
updateAttribute(this.#$search, "value", newVal);
|
|
16189
16198
|
this.#userManagedSearch = true;
|
|
@@ -16253,6 +16262,12 @@ class SelectMenu extends NectaryElement {
|
|
|
16253
16262
|
get "search-placeholder"() {
|
|
16254
16263
|
return getAttribute(this.#$search, "placeholder", "");
|
|
16255
16264
|
}
|
|
16265
|
+
set "no-results-text"(text) {
|
|
16266
|
+
updateAttribute(this, "no-results-text", text);
|
|
16267
|
+
}
|
|
16268
|
+
get "no-results-text"() {
|
|
16269
|
+
return getAttribute(this, "no-results-text", DEFAULT_NO_RESULTS_TEXT);
|
|
16270
|
+
}
|
|
16256
16271
|
set "search-value"(value) {
|
|
16257
16272
|
updateAttribute(this, "search-value", value);
|
|
16258
16273
|
this.#userManagedSearch = true;
|
|
@@ -16334,7 +16349,7 @@ class SelectMenu extends NectaryElement {
|
|
|
16334
16349
|
}
|
|
16335
16350
|
setClass($opt, "hidden", isHidden);
|
|
16336
16351
|
}
|
|
16337
|
-
setClass(this.#$
|
|
16352
|
+
setClass(this.#$noResults, "active", searchValue.length > 0 && !someFound);
|
|
16338
16353
|
this.#selectOption(null);
|
|
16339
16354
|
};
|
|
16340
16355
|
#onContextKeyDown = (e) => {
|
|
@@ -16396,6 +16411,9 @@ class SelectMenu extends NectaryElement {
|
|
|
16396
16411
|
updateAttribute(this.#$search, "aria-label", placeholder === null || placeholder === "" ? DEFAULT_SEARCH_LABEL : placeholder);
|
|
16397
16412
|
}
|
|
16398
16413
|
}
|
|
16414
|
+
#updateNoResultsText(text) {
|
|
16415
|
+
this.#$noResultsText.textContent = text ?? DEFAULT_NO_RESULTS_TEXT;
|
|
16416
|
+
}
|
|
16399
16417
|
#syncListboxChildren = () => {
|
|
16400
16418
|
for (const $element of this.#$optionSlot.assignedElements()) {
|
|
16401
16419
|
if (!isSelectMenuOption($element) && getAttribute($element, "aria-hidden") !== "true") {
|
package/package.json
CHANGED
package/select-menu/index.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export declare class SelectMenu extends NectaryElement implements Focusable {
|
|
|
33
33
|
get 'search-autocomplete'(): string;
|
|
34
34
|
set 'search-placeholder'(placeholder: string);
|
|
35
35
|
get 'search-placeholder'(): string;
|
|
36
|
+
set 'no-results-text'(text: string);
|
|
37
|
+
get 'no-results-text'(): string;
|
|
36
38
|
set 'search-value'(value: string);
|
|
37
39
|
get 'search-value'(): string;
|
|
38
40
|
get focusable(): boolean;
|
package/select-menu/index.js
CHANGED
|
@@ -10,9 +10,10 @@ import { debounceTimeout } from "../utils/debounce.js";
|
|
|
10
10
|
import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
11
11
|
import { isTargetEqual } from "../utils/event-target.js";
|
|
12
12
|
import { setFormValue, CSVToFormData } from "../utils/form.js";
|
|
13
|
-
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto;max-height:var(--sinch-comp-select-menu-font-max-height)}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#
|
|
13
|
+
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto;max-height:var(--sinch-comp-select-menu-font-max-height)}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#no-results{display:flex;align-items:center;justify-content:center;width:100%;height:30px;margin-bottom:10px;pointer-events:none;user-select:none;--sinch-comp-text-font:var(--sinch-comp-select-menu-font-not-found-text);--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-not-found-text-initial)}#no-results:not(.active){display:none}::slotted(.hidden){display:none}::slotted(sinch-title){padding:8px 16px;--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-title-initial)}</style><sinch-input id="search" size="s" placeholder="Search" aria-label="Search"><sinch-icon icons-version="2" name="magnifying-glass" id="icon-search" slot="icon"></sinch-icon><sinch-button id="search-clear" slot="right"><sinch-icon icons-version="2" name="fa-xmark" slot="icon"></sinch-icon></sinch-button></sinch-input><div id="no-results"><sinch-text id="no-results-text" type="m"></sinch-text></div><div id="listbox" role="listbox" tabindex="-1"><slot></slot></div>';
|
|
14
14
|
const ITEM_HEIGHT = 40;
|
|
15
15
|
const DEFAULT_SEARCH_LABEL = "Search";
|
|
16
|
+
const DEFAULT_NO_RESULTS_TEXT = "No results";
|
|
16
17
|
const template = document.createElement("template");
|
|
17
18
|
template.innerHTML = templateHTML;
|
|
18
19
|
class SelectMenu extends NectaryElement {
|
|
@@ -20,7 +21,8 @@ class SelectMenu extends NectaryElement {
|
|
|
20
21
|
#$listbox;
|
|
21
22
|
#$search;
|
|
22
23
|
#$searchClear;
|
|
23
|
-
#$
|
|
24
|
+
#$noResults;
|
|
25
|
+
#$noResultsText;
|
|
24
26
|
#controller = null;
|
|
25
27
|
#searchDebounce;
|
|
26
28
|
#internals;
|
|
@@ -35,7 +37,8 @@ class SelectMenu extends NectaryElement {
|
|
|
35
37
|
this.#$listbox = shadowRoot.querySelector("#listbox");
|
|
36
38
|
this.#$search = shadowRoot.querySelector("#search");
|
|
37
39
|
this.#$searchClear = shadowRoot.querySelector("#search-clear");
|
|
38
|
-
this.#$
|
|
40
|
+
this.#$noResults = shadowRoot.querySelector("#no-results");
|
|
41
|
+
this.#$noResultsText = shadowRoot.querySelector("#no-results-text");
|
|
39
42
|
this.#searchDebounce = debounceTimeout(200)(this.#updateSearchValue);
|
|
40
43
|
}
|
|
41
44
|
connectedCallback() {
|
|
@@ -46,6 +49,7 @@ class SelectMenu extends NectaryElement {
|
|
|
46
49
|
};
|
|
47
50
|
this.setAttribute("role", "group");
|
|
48
51
|
this.tabIndex = 0;
|
|
52
|
+
this.#updateNoResultsText(this.getAttribute("no-results-text"));
|
|
49
53
|
this.#syncListboxLabel();
|
|
50
54
|
this.addEventListener("keydown", this.#onListboxKeyDown, options);
|
|
51
55
|
this.addEventListener("focus", this.#onFocus, options);
|
|
@@ -122,6 +126,7 @@ class SelectMenu extends NectaryElement {
|
|
|
122
126
|
"search-value",
|
|
123
127
|
// eslint-disable-next-line @nectary/observed-attribute-accessor -- baseline backlog: missing set searchPlaceholder
|
|
124
128
|
"search-placeholder",
|
|
129
|
+
"no-results-text",
|
|
125
130
|
// eslint-disable-next-line @nectary/observed-attribute-accessor -- baseline backlog: missing set searchAutocomplete
|
|
126
131
|
"search-autocomplete"
|
|
127
132
|
];
|
|
@@ -165,6 +170,10 @@ class SelectMenu extends NectaryElement {
|
|
|
165
170
|
this.#updateSearchPlaceholder(newVal);
|
|
166
171
|
break;
|
|
167
172
|
}
|
|
173
|
+
case "no-results-text": {
|
|
174
|
+
this.#updateNoResultsText(newVal);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
168
177
|
case "search-value": {
|
|
169
178
|
updateAttribute(this.#$search, "value", newVal);
|
|
170
179
|
this.#userManagedSearch = true;
|
|
@@ -234,6 +243,12 @@ class SelectMenu extends NectaryElement {
|
|
|
234
243
|
get "search-placeholder"() {
|
|
235
244
|
return getAttribute(this.#$search, "placeholder", "");
|
|
236
245
|
}
|
|
246
|
+
set "no-results-text"(text) {
|
|
247
|
+
updateAttribute(this, "no-results-text", text);
|
|
248
|
+
}
|
|
249
|
+
get "no-results-text"() {
|
|
250
|
+
return getAttribute(this, "no-results-text", DEFAULT_NO_RESULTS_TEXT);
|
|
251
|
+
}
|
|
237
252
|
set "search-value"(value) {
|
|
238
253
|
updateAttribute(this, "search-value", value);
|
|
239
254
|
this.#userManagedSearch = true;
|
|
@@ -315,7 +330,7 @@ class SelectMenu extends NectaryElement {
|
|
|
315
330
|
}
|
|
316
331
|
setClass($opt, "hidden", isHidden);
|
|
317
332
|
}
|
|
318
|
-
setClass(this.#$
|
|
333
|
+
setClass(this.#$noResults, "active", searchValue.length > 0 && !someFound);
|
|
319
334
|
this.#selectOption(null);
|
|
320
335
|
};
|
|
321
336
|
#onContextKeyDown = (e) => {
|
|
@@ -377,6 +392,9 @@ class SelectMenu extends NectaryElement {
|
|
|
377
392
|
updateAttribute(this.#$search, "aria-label", placeholder === null || placeholder === "" ? DEFAULT_SEARCH_LABEL : placeholder);
|
|
378
393
|
}
|
|
379
394
|
}
|
|
395
|
+
#updateNoResultsText(text) {
|
|
396
|
+
this.#$noResultsText.textContent = text ?? DEFAULT_NO_RESULTS_TEXT;
|
|
397
|
+
}
|
|
380
398
|
#syncListboxChildren = () => {
|
|
381
399
|
for (const $element of this.#$optionSlot.assignedElements()) {
|
|
382
400
|
if (!isSelectMenuOption($element) && getAttribute($element, "aria-hidden") !== "true") {
|
package/select-menu/types.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type TSinchSelectMenuProps = {
|
|
|
16
16
|
'search-autocomplete'?: HTMLInputElement['autocomplete'];
|
|
17
17
|
/** Text for search bar's placeholder */
|
|
18
18
|
'search-placeholder'?: string;
|
|
19
|
+
/** Text shown when the search returns no results */
|
|
20
|
+
'no-results-text'?: string;
|
|
19
21
|
/** Label that is used for a11y */
|
|
20
22
|
'aria-label': string;
|
|
21
23
|
/** Element ID reference that labels the listbox */
|