@nordhealth/components 5.0.0-alpha.0 → 5.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/custom-elements.json +26353 -25540
- package/lib/Accordion.js.map +1 -1
- package/lib/AccordionHeader.js.map +1 -1
- package/lib/AccordionItem.js.map +1 -1
- package/lib/AccordionPanel.js.map +1 -1
- package/lib/AccordionTrigger.js +1 -1
- package/lib/AccordionTrigger.js.map +1 -1
- package/lib/Aside.js.map +1 -1
- package/lib/AsideDrawer.js.map +1 -1
- package/lib/Autocomplete.js +1 -1
- package/lib/Autocomplete.js.map +1 -1
- package/lib/Avatar.js.map +1 -1
- package/lib/Button.js +1 -1
- package/lib/Button.js.map +1 -1
- package/lib/Calendar-D47b20IT.js +2 -0
- package/lib/Calendar-D47b20IT.js.map +1 -0
- package/lib/Calendar.js +1 -1
- package/lib/Card.js.map +1 -1
- package/lib/Collapsible.js.map +1 -1
- package/lib/CollapsiblePanel.js.map +1 -1
- package/lib/CollapsibleTrigger.js.map +1 -1
- package/lib/Combobox-DBxXlbY7.js +2 -0
- package/lib/Combobox-DBxXlbY7.js.map +1 -0
- package/lib/Combobox.js +1 -1
- package/lib/Combobox.js.map +1 -1
- package/lib/ComboboxBase.js +1 -1
- package/lib/ComboboxBase.js.map +1 -1
- package/lib/CommandMenu.js +1 -1
- package/lib/CommandMenu.js.map +1 -1
- package/lib/DatePicker.js +1 -1
- package/lib/DatePicker.js.map +1 -1
- package/lib/DateRangePicker.js +1 -1
- package/lib/DateRangePicker.js.map +1 -1
- package/lib/Divider.js.map +1 -1
- package/lib/Drawer.js.map +1 -1
- package/lib/Dropdown.js +1 -1
- package/lib/Dropdown.js.map +1 -1
- package/lib/DropdownSubmenu.js +1 -1
- package/lib/DropdownSubmenu.js.map +1 -1
- package/lib/FilterAddButton.js +1 -1
- package/lib/FilterAddButton.js.map +1 -1
- package/lib/FilterDateRange.js +1 -1
- package/lib/FilterDateRange.js.map +1 -1
- package/lib/FilterDropdown.js +1 -1
- package/lib/FilterDropdown.js.map +1 -1
- package/lib/FilterField.js +1 -1
- package/lib/FilterField.js.map +1 -1
- package/lib/FilterInput.js +1 -1
- package/lib/FilterInput.js.map +1 -1
- package/lib/FilterResetButton.js +1 -1
- package/lib/FilterResetButton.js.map +1 -1
- package/lib/Footer.js.map +1 -1
- package/lib/Header.js.map +1 -1
- package/lib/Icon.js.map +1 -1
- package/lib/Item.js +1 -1
- package/lib/Item.js.map +1 -1
- package/lib/Kbd.js.map +1 -1
- package/lib/KbdGroup.js.map +1 -1
- package/lib/KeyboardController.js +1 -1
- package/lib/KeyboardController.js.map +1 -1
- package/lib/Layout.js +1 -1
- package/lib/Layout.js.map +1 -1
- package/lib/{LightDismissController-4pH8cdko.js → LightDismissController-wcL1ziJa.js} +2 -2
- package/lib/{LightDismissController-4pH8cdko.js.map → LightDismissController-wcL1ziJa.js.map} +1 -1
- package/lib/LocalizeController.js +1 -1
- package/lib/LocalizeController.js.map +1 -1
- package/lib/Message.js +1 -1
- package/lib/Message.js.map +1 -1
- package/lib/Meter.js +1 -1
- package/lib/Meter.js.map +1 -1
- package/lib/Modal.js +1 -1
- package/lib/Modal.js.map +1 -1
- package/lib/ModalController.js +1 -1
- package/lib/ModalController.js.map +1 -1
- package/lib/NavGroup.js +1 -1
- package/lib/NavGroup.js.map +1 -1
- package/lib/NavItem.js +1 -1
- package/lib/NavItem.js.map +1 -1
- package/lib/NavToggle-ROsuaJkW.js +2 -0
- package/lib/{NavToggle-BY83xpx0.js.map → NavToggle-ROsuaJkW.js.map} +1 -1
- package/lib/NavToggle.js +1 -1
- package/lib/Notification.js +1 -1
- package/lib/Notification.js.map +1 -1
- package/lib/NumberField.js +1 -1
- package/lib/NumberField.js.map +1 -1
- package/lib/OtpField.js +1 -1
- package/lib/OtpField.js.map +1 -1
- package/lib/Outline.js +2 -0
- package/lib/Outline.js.map +1 -0
- package/lib/OutlineItem.js +2 -0
- package/lib/OutlineItem.js.map +1 -0
- package/lib/Pagination.js +1 -1
- package/lib/Pagination.js.map +1 -1
- package/lib/Popout-B6Hirj3y.js +2 -0
- package/lib/{Popout-DpN7PP9h.js.map → Popout-B6Hirj3y.js.map} +1 -1
- package/lib/Popout.js +1 -1
- package/lib/Qrcode.js.map +1 -1
- package/lib/ScrollArea.js.map +1 -1
- package/lib/ShortcutController-CV5b0BZl.js +2 -0
- package/lib/ShortcutController-CV5b0BZl.js.map +1 -0
- package/lib/Stack.js.map +1 -1
- package/lib/Tag.js +1 -1
- package/lib/Tag.js.map +1 -1
- package/lib/TagGroup.js.map +1 -1
- package/lib/Textarea.js +1 -1
- package/lib/Textarea.js.map +1 -1
- package/lib/TimePicker.js +1 -1
- package/lib/TimePicker.js.map +1 -1
- package/lib/TopBar.js.map +1 -1
- package/lib/Truncate.js.map +1 -1
- package/lib/VisuallyHidden.js.map +1 -1
- package/lib/bundle.js +13 -13
- package/lib/bundle.js.map +1 -1
- package/lib/en-us.js +1 -1
- package/lib/en-us.js.map +1 -1
- package/lib/fi-fi.js +1 -1
- package/lib/fi-fi.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/localization13.js +1 -1
- package/lib/localization13.js.map +1 -1
- package/lib/localization14.js +1 -1
- package/lib/localization14.js.map +1 -1
- package/lib/localization15.js +1 -1
- package/lib/localization15.js.map +1 -1
- package/lib/localization16.js +1 -1
- package/lib/localization16.js.map +1 -1
- package/lib/localization17.js +1 -1
- package/lib/localization17.js.map +1 -1
- package/lib/localization18.js +1 -1
- package/lib/localization18.js.map +1 -1
- package/lib/localization19.js +1 -1
- package/lib/localization19.js.map +1 -1
- package/lib/localization20.js +1 -1
- package/lib/localization20.js.map +1 -1
- package/lib/localization21.js +1 -1
- package/lib/localization21.js.map +1 -1
- package/lib/localization22.js +1 -1
- package/lib/localization22.js.map +1 -1
- package/lib/localization23.js +2 -0
- package/lib/localization23.js.map +1 -0
- package/lib/localization24.js +2 -0
- package/lib/localization24.js.map +1 -0
- package/lib/nav-context.js +2 -0
- package/lib/nav-context.js.map +1 -0
- package/lib/react.d.ts +15 -0
- package/lib/src/accordion/Accordion.d.ts +1 -1
- package/lib/src/accordion/AccordionHeader.d.ts +1 -1
- package/lib/src/accordion/AccordionItem.d.ts +1 -1
- package/lib/src/accordion/AccordionPanel.d.ts +1 -1
- package/lib/src/accordion/AccordionTrigger.d.ts +4 -3
- package/lib/src/aside/Aside.d.ts +1 -1
- package/lib/src/aside-drawer/AsideDrawer.d.ts +1 -1
- package/lib/src/autocomplete/Autocomplete.d.ts +4 -4
- package/lib/src/avatar/Avatar.d.ts +1 -1
- package/lib/src/button/Button.d.ts +1 -0
- package/lib/src/calendar/Calendar.d.ts +1 -1
- package/lib/src/card/Card.d.ts +1 -1
- package/lib/src/collapsible/Collapsible.d.ts +1 -1
- package/lib/src/collapsible/CollapsiblePanel.d.ts +1 -1
- package/lib/src/collapsible/CollapsibleTrigger.d.ts +1 -1
- package/lib/src/combobox/ComboboxBase.d.ts +7 -7
- package/lib/src/common/controllers/ShortcutController.d.ts +5 -5
- package/lib/src/divider/Divider.d.ts +1 -1
- package/lib/src/drawer/Drawer.d.ts +1 -1
- package/lib/src/dropdown/Dropdown.d.ts +3 -0
- package/lib/src/footer/Footer.d.ts +1 -1
- package/lib/src/header/Header.d.ts +1 -1
- package/lib/src/icon/Icon.d.ts +1 -1
- package/lib/src/index.d.ts +2 -0
- package/lib/src/kbd/Kbd.d.ts +1 -1
- package/lib/src/kbd/KbdGroup.d.ts +1 -1
- package/lib/src/layout/Layout.d.ts +13 -1
- package/lib/src/layout/localization.d.ts +5 -0
- package/lib/src/localization/en-us.d.ts +7 -0
- package/lib/src/localization/translation.d.ts +7 -0
- package/lib/src/nav-group/NavGroup.d.ts +1 -0
- package/lib/src/nav-group/nav-context.d.ts +11 -0
- package/lib/src/nav-item/NavItem.d.ts +23 -0
- package/lib/src/otp-field/OtpField.d.ts +11 -0
- package/lib/src/outline/Outline.d.ts +111 -0
- package/lib/src/outline/OutlineItem.d.ts +42 -0
- package/lib/src/outline/localization.d.ts +4 -0
- package/lib/src/qrcode/Qrcode.d.ts +1 -1
- package/lib/src/scroll-area/ScrollArea.d.ts +1 -1
- package/lib/src/stack/Stack.d.ts +1 -1
- package/lib/src/tag/Tag.d.ts +1 -1
- package/lib/src/tag-group/TagGroup.d.ts +1 -1
- package/lib/src/top-bar/TopBar.d.ts +1 -1
- package/lib/src/truncate/Truncate.d.ts +1 -1
- package/lib/src/visually-hidden/VisuallyHidden.d.ts +1 -1
- package/lib/tinykeys-DwvDXsEb.js +2 -0
- package/lib/tinykeys-DwvDXsEb.js.map +1 -0
- package/lib/translation.js +1 -1
- package/lib/translation.js.map +1 -1
- package/lib/vue.d.ts +11 -0
- package/package.json +5 -5
- package/lib/Calendar-C1SxrlzN.js +0 -2
- package/lib/Calendar-C1SxrlzN.js.map +0 -1
- package/lib/Combobox-By4h1Sp-.js +0 -2
- package/lib/Combobox-By4h1Sp-.js.map +0 -1
- package/lib/NavToggle-BY83xpx0.js +0 -2
- package/lib/Popout-DpN7PP9h.js +0 -2
- package/lib/ShortcutController-BIb3WGzH.js +0 -2
- package/lib/ShortcutController-BIb3WGzH.js.map +0 -1
- package/lib/tinykeys.module-_6MZt7MP.js +0 -2
- package/lib/tinykeys.module-_6MZt7MP.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{css as o}from"lit";const n=o`nord-combobox,nord-combobox *,nord-combobox :after,nord-combobox :before{box-sizing:border-box}nord-combobox>.n-render-root{display:contents}nord-combobox-group,nord-combobox-option{display:none}nord-combobox{--_n-combobox-background:var(--n-input-background,var(--n-color-surface));--_n-combobox-border-color:var(--n-input-border-color,var(--n-color-border-strong));--_n-combobox-border-radius:var(--n-input-border-radius,var(--n-border-radius-s));--_n-combobox-block-size:var(--n-combobox-block-size,var(--n-space-xl));--_n-combobox-min-content-block-size:calc(var(--n-line-height-form) + var(--n-space-s)/1.6*2 + 2px);--_n-combobox-padding-block:calc(var(--_n-combobox-block-size)/2 - var(--n-line-height-form)/2 - 1px);--_n-combobox-padding-inline:calc(var(--n-space-s) + var(--n-space-xs));--_n-combobox-font-size:var(--n-font-size-m);--_n-combobox-divider-block-size:var(--n-space-m);--_n-combobox-tags-padding:calc(var(--n-space-xs)*0.75);display:block}nord-combobox[size=s]{--_n-combobox-block-size:var(--n-combobox-block-size,calc(var(--n-space-l) + var(--n-space-xs)));--_n-combobox-padding-block:calc(var(--_n-combobox-block-size)/2 - var(--n-line-height-form)/2 - 1px);--_n-combobox-padding-inline:calc(var(--n-space-xs)*1.5);--_n-combobox-divider-block-size:calc(var(--n-space-s) + var(--n-space-xs)/2);--_n-combobox-tags-padding:calc(var(--n-space-xs)/2)}nord-combobox[size=l]{--_n-combobox-border-radius:var(--n-input-border-radius,var(--n-border-radius));--_n-combobox-block-size:max(var(--n-combobox-block-size,calc(var(--n-space-xxl) - var(--n-space-l))),var(--_n-combobox-min-content-block-size));--_n-combobox-padding-block:calc(var(--_n-combobox-block-size)/2 - var(--n-line-height-form)/2 - 1px);--_n-combobox-padding-inline:calc(var(--n-space-s) + var(--n-space-xs));--_n-combobox-divider-block-size:var(--n-space-l)}nord-combobox .n-combobox{inline-size:100%;position:relative}nord-combobox .n-control{align-items:center;background:var(--_n-combobox-background);border:1px solid var(--_n-combobox-border-color);border-radius:var(--_n-combobox-border-radius);cursor:text;display:flex;gap:var(--n-space-s);inline-size:100%;min-block-size:var(--_n-combobox-block-size);padding-inline-end:var(--_n-combobox-padding-inline);padding-inline-start:var(--_n-combobox-padding-inline);transition:border var(--n-transition-quickly),box-shadow var(--n-transition-quickly),background var(--n-transition-quickly)}nord-combobox .n-tags{align-items:center;display:flex;flex:1;flex-wrap:wrap;gap:var(--_n-combobox-tags-padding);min-inline-size:0;padding-block-end:var(--_n-combobox-tags-padding);padding-block-start:var(--_n-combobox-tags-padding)}nord-combobox .n-tags .n-input{padding-block-end:0;padding-block-start:0}nord-combobox .n-control:hover{--_n-combobox-border-color:var(--n-input-border-color,var(--n-color-border-hover))}nord-combobox .n-control:focus-within{--_n-combobox-border-color:var(--n-input-border-color,var(--n-color-accent));box-shadow:0 0 0 1px var(--_n-combobox-border-color)}nord-combobox[disabled] .n-control{--_n-combobox-background:var(--n-input-background-inactive,var(--n-color-active));--_n-combobox-border-color:var(--n-input-border-color,var(--n-color-active));cursor:auto;pointer-events:none}nord-combobox[readonly] .n-control{--_n-combobox-background:var(--n-input-background-inactive,var(--n-color-active))}nord-combobox[readonly] input.n-input{background:#0000}nord-combobox .n-control.is-invalid{--_n-combobox-border-color:var(--n-color-border-danger)}nord-combobox .n-control.is-invalid:focus-within{--_n-combobox-border-color:var(--n-color-status-danger)}nord-combobox .n-slot{align-items:center;color:var(--n-color-icon);display:flex;flex-shrink:0}nord-combobox .n-slot:empty{display:none}nord-combobox[disabled] .n-slot{color:var(--n-color-text-weakest)}nord-combobox .n-slot nord-icon{--_n-icon-size:var(--n-size-icon-s)}nord-combobox .n-input{appearance:none;background:#0000;border:none;color:var(--n-color-text);flex:1;font-family:var(--n-font-family);font-feature-settings:var(--n-font-features);font-size:var(--_n-combobox-font-size);line-height:var(--n-line-height-form);margin:0;min-inline-size:3rem;outline:none;padding-block-end:var(--_n-combobox-padding-block);padding-block-start:var(--_n-combobox-padding-block);padding-inline-end:0;padding-inline-start:0}nord-combobox .n-control input.n-input:focus,nord-combobox .n-control input.n-input:focus-visible,nord-combobox .n-control input.n-input:focus-within{background:#0000;border:none;box-shadow:none;outline:none}nord-combobox .n-input::placeholder{color:var(--n-color-text-weakest);opacity:1}nord-combobox[disabled] .n-input{color:var(--n-color-text-weakest)}nord-combobox .n-divider{background:var(--n-color-border);block-size:var(--_n-combobox-divider-block-size);flex-shrink:0;inline-size:1px}nord-combobox .n-toggle{align-items:center;appearance:none;background:#0000;border:none;color:var(--n-color-icon);cursor:pointer;display:flex;flex-shrink:0;justify-content:center;margin:0;padding:0}nord-combobox .n-toggle nord-icon{--_n-icon-size:var(--n-size-icon-s)}nord-combobox[disabled] .n-toggle{color:var(--n-color-text-weakest);cursor:auto}nord-combobox .n-clear{align-items:center;appearance:none;background:#0000;border:none;border-radius:var(--n-border-radius-s);color:var(--n-color-icon);cursor:pointer;display:flex;flex-shrink:0;justify-content:center;margin:0;padding:0;transition:color var(--n-transition-quickly)}nord-combobox .n-clear:hover{color:var(--n-color-text)}nord-combobox .n-clear:focus-visible{outline:2px solid var(--n-color-accent);outline-offset:2px}nord-combobox .n-clear nord-icon{--_n-icon-size:var(--n-size-icon-xs)}nord-combobox .n-loading{flex-shrink:0}nord-combobox .n-chip{--n-tag-block-size:calc(var(--_n-combobox-block-size) - var(--n-space-s));flex-shrink:0}nord-combobox .n-listbox{inline-size:var(--n-combobox-list-inline-size,var(--_n-combobox-anchor-inline-size,100%));margin:0;max-block-size:calc(var(--n-space-xxl)*4);overflow-y:auto;padding-block-end:var(--n-space-s);padding-block-start:var(--n-space-s);padding-inline:0}nord-combobox .n-virtual-sizer{inline-size:100%;position:relative}nord-combobox .n-virtual-row{inset-block-start:0;inset-inline:0;position:absolute}nord-combobox .n-virtual-row>.n-option{block-size:100%;box-sizing:border-box;min-block-size:0;overflow:hidden}nord-combobox .n-group-label{color:var(--n-color-text-weaker);font-size:var(--n-font-size-xs);font-weight:var(--n-font-weight-heading);line-height:var(--n-line-height-tight);padding-block-end:var(--n-space-s);padding-block-start:var(--n-space-s);padding-inline-end:calc(var(--n-space-s) + var(--n-space-xs)/2);padding-inline-start:calc(var(--n-space-s) + var(--n-space-xs)/2)}nord-combobox [role=group]:not(:first-child):before{border-block-start:1px solid var(--n-color-border);content:"";display:block;margin-block-end:var(--n-space-s);margin-block-start:var(--n-space-s)}nord-combobox .n-option{align-items:center;color:var(--n-color-text);cursor:pointer;display:flex;font-size:var(--_n-combobox-font-size);gap:var(--n-space-s);line-height:var(--n-line-height);padding-block-end:calc(var(--n-space-xs)*1.5);padding-block-start:calc(var(--n-space-xs)*1.5);padding-inline-end:calc(var(--n-space-s) + var(--n-space-xs)/2);padding-inline-start:calc(var(--n-space-s) + var(--n-space-xs)/2);user-select:none}nord-combobox .n-option.is-active{background:var(--n-color-accent);color:var(--n-color-text-on-accent)}nord-combobox .n-option:active{opacity:.8}nord-combobox .n-option.is-disabled{color:var(--n-color-text-weakest);cursor:default;pointer-events:none}nord-combobox .n-option-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}nord-combobox .n-option-check{block-size:var(--n-space-m);color:var(--n-color-text-highlight);display:grid;flex:0 0 var(--n-space-m);inline-size:var(--n-space-m);place-items:center}nord-combobox .n-option.is-active .n-option-check{color:currentColor}nord-combobox .n-create{color:var(--n-color-text-link)}nord-combobox .n-create .n-option-label{font-weight:var(--n-font-weight-active)}nord-combobox .n-create-icon{--_n-icon-size:var(--n-size-icon-s);color:currentColor;flex-shrink:0}nord-combobox .n-create-kbd{flex-shrink:0}nord-combobox .n-empty{align-items:center;color:var(--n-color-text-weaker);display:flex;font-size:var(--_n-combobox-font-size);justify-content:center;padding:var(--n-space-s);text-align:center}`;export{n as s};
|
|
2
|
+
//# sourceMappingURL=Combobox-DBxXlbY7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox-DBxXlbY7.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/lib/Combobox.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{i}from"./context-provider-D8lrPLVi.js";import{a as e}from"./interface-add-small-B-hv2v9J.js";import{nothing as o,html as s}from"lit";import{property as r,state as l,customElement as a}from"lit/decorators.js";import{classMap as n}from"lit/directives/class-map.js";import{repeat as p}from"lit/directives/repeat.js";import{i as c}from"./light-dom-styles-DXsbiKU9.js";import m from"./Icon.js";import{comboboxRegistryContext as
|
|
1
|
+
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{i}from"./context-provider-D8lrPLVi.js";import{a as e}from"./interface-add-small-B-hv2v9J.js";import{nothing as o,html as s}from"lit";import{property as r,state as l,customElement as a}from"lit/decorators.js";import{classMap as n}from"lit/directives/class-map.js";import{repeat as p}from"lit/directives/repeat.js";import{i as c}from"./light-dom-styles-DXsbiKU9.js";import m from"./Icon.js";import{comboboxRegistryContext as h}from"./combobox-context.js";import{s as d}from"./Combobox-DBxXlbY7.js";import u from"./ComboboxBase.js";import{ComboboxClearEvent as j,ComboboxCreateEvent as v}from"./ComboboxEvents.js";import"./Kbd.js";import"./Tag.js";import"./ComboboxOption.js";import"./ComboboxGroup.js";import"./context-request-event-CCRlXoeR.js";import"lit/directives/if-defined.js";import"lit/directives/unsafe-html.js";import"./observe-D0n0zOfU.js";import"./cond-CI1KbneT.js";import"./Component-BJ5O5n8k.js";import"./IconManager.js";import"./create-context-CJ69ntlY.js";import"./ActiveDescendantController-BnMqM79O.js";import"./number-Dg2vCfGd.js";import"./interface-close-small-CnpAFMO3.js";import"./interface-dropdown-small-CYvgxudU.js";import"lit/directives/ref.js";import"lit/directives/style-map.js";import"./collection-Dvg2XbxV.js";import"./FormDataController-OUt5L5uC.js";import"./LightDismissController-wcL1ziJa.js";import"./EventController-BBOmvfLa.js";import"./ShortcutController-CV5b0BZl.js";import"./tinykeys-DwvDXsEb.js";import"./ResizeController-14PUwRQy.js";import"./StateAttributesController-BIh96sXZ.js";import"./events-Bv6wNHwJ.js";import"./AutocompleteMixin-D8eiOxvO.js";import"./DraftComponentMixin-4qug5Rky.js";import"./FieldControlMixin-BXNZJXu9.js";import"./context-consumer-BJVUulGf.js";import"./field-context.js";import"./SlotController-Z6eG7LSZ.js";import"./VisuallyHidden.js";import"./Popout-B6Hirj3y.js";import"./positioning-D-K8Mueq.js";import"./DirectionController-ChvNGESZ.js";import"./ScrollbarController-BFC67Y2x.js";import"./InputMixin-LetXsCyv.js";import"./SizeMixin-CU9cLbLC.js";import"./LocalizeController.js";import"./translation.js";import"./en-us.js";import"./localization.js";import"./localization2.js";import"./localization3.js";import"./localization4.js";import"./localization5.js";import"./localization6.js";import"./localization7.js";import"./localization8.js";import"./localization9.js";import"./localization10.js";import"./localization11.js";import"./localization12.js";import"./localization13.js";import"./localization14.js";import"./localization15.js";import"./localization16.js";import"./localization17.js";import"./localization18.js";import"./localization19.js";import"./localization20.js";import"./localization21.js";import"./localization22.js";import"./localization23.js";import"./localization24.js";import"./Spinner.js";import"./interface-checked-small-BQmkNgCI.js";import"./FocusableMixin-BlQLNPdJ.js";m.registerIcon(e);let b=class extends u{constructor(){super(...arguments),this.value="",this.multiple=!1,this.clearable=!0,this.creatable=!1,this.slottedOptions=[],this.createdOptions=[],this.optionElements=new Set,this.optionRegistry={add:t=>{this.optionElements.add(t),this.rebuildSlottedOptions()},remove:t=>{this.optionElements.delete(t),this.rebuildSlottedOptions()},notify:()=>this.rebuildSlottedOptions()},this.registryProvider=new i(this,{context:h,initialValue:this.optionRegistry})}connectedCallback(){super.connectedCallback(),c(this,d)}readOptionElement(t){var i,e,o,s,r;const l=(null===(i=t.closest("nord-combobox-group"))||void 0===i?void 0:i.getAttribute("label"))||void 0,a=null!==(s=null!==(e=t.getAttribute("label"))&&void 0!==e?e:null===(o=t.textContent)||void 0===o?void 0:o.trim())&&void 0!==s?s:"",n={value:null!==(r=t.getAttribute("value"))&&void 0!==r?r:"",label:a,disabled:t.hasAttribute("disabled")};return l&&(n.group=l),t.children.length>0&&(n.html=t.innerHTML),n}rebuildSlottedOptions(){const t=[...this.optionElements].sort(((t,i)=>t.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1));this.slottedOptions=t.map((t=>this.readOptionElement(t)))}get resolvedOptions(){const t=this.options.length?this.options:this.slottedOptions,i=this.createdOptions,e=this.resolvedCache;if(e&&e.options===this.options&&e.slotted===this.slottedOptions&&e.created===i)return e.result;const o=i.length?[...t,...i]:t;return this.resolvedCache={options:this.options,slotted:this.slottedOptions,created:i,result:o},o}get isMultiple(){return this.multiple}get showsQueryInInput(){return this.isMultiple||this.queryDirty}get inputPlaceholder(){return this.isMultiple&&this.hasValue?void 0:this.placeholder}get createIndex(){return this.canCreate?this.filteredOptions.length:-1}get canCreate(){const t=this.search.trim();return!(!this.creatable||!t)&&!this.resolvedOptions.some((i=>i.label.toLocaleLowerCase()===t.toLocaleLowerCase()))}get showClear(){return this.clearable&&this.hasValue&&!this.disabled&&!this.readonly}get ariaMultiselectable(){return this.isMultiple?"true":"false"}clear(){this.value=this.isMultiple?[]:"",this.search="",this.queryDirty=!1,this.dispatchEvent(new j),this.commit(),this.focus()}selectOption(t){if(!this.isMultiple)return super.selectOption(t);if(t.disabled)return;this.labelCache.set(t.value,t.label);const i=this.values.includes(t.value)?this.values.filter((i=>i!==t.value)):[...this.values,t.value];this.value=i,this.search="",this.queryDirty=!1,this.commit(),this.focus()}onInput(t){!this.isMultiple&&""===t.value&&this.hasValue&&(this.value="",this.commit())}emitCreate(){const t=this.search.trim();if(!t)return;if(!this.dispatchEvent(new v(t)))return;const i={value:t,label:t};this.resolvedOptions.some((t=>t.value===i.value))||(this.createdOptions=[...this.createdOptions,i]),this.labelCache.set(i.value,i.label),this.selectOption(i)}onUnhandledKeydown(t){"Backspace"===t.key&&this.isMultiple&&!this.search&&this.values.length&&this.removeValue(this.values[this.values.length-1])}removeValue(t){this.disabled||(this.value=this.values.filter((i=>i!==t)),this.commit(),this.focus())}renderLeadingControl(){return this.isMultiple?p(this.values,(t=>t),(t=>s`<nord-tag class="n-chip" size="s" variant="removable" ?disabled="${this.disabled}" @remove="${()=>this.removeValue(t)}" @click="${t=>t.stopPropagation()}">${this.labelFor(t)}</nord-tag>`)):o}renderCreate(){const t=this.activeDescendant.activeIndex===this.createIndex;return s`<div id="${this.createId}" class="${n({"n-option":!0,"n-create":!0,"is-active":t})}" role="option" aria-selected="false" @click="${this.emitCreate}" @mousemove="${()=>this.activeDescendant.setActiveIndex(this.createIndex)}"><nord-icon class="n-create-icon" name="interface-add-small"></nord-icon><span class="n-option-label">${this.localize.term("createLabel",this.search.trim())}</span><nord-kbd class="n-create-kbd" aria-hidden="true">⏎</nord-kbd></div>`}};t([r({attribute:!1})],b.prototype,"value",void 0),t([r({reflect:!0,type:Boolean})],b.prototype,"multiple",void 0),t([r({reflect:!0,type:Boolean})],b.prototype,"clearable",void 0),t([r({reflect:!0,type:Boolean})],b.prototype,"creatable",void 0),t([l()],b.prototype,"slottedOptions",void 0),t([l()],b.prototype,"createdOptions",void 0),b=t([a("nord-combobox")],b);var f=b;export{j as ComboboxClearEvent,v as ComboboxCreateEvent,f as default};
|
|
2
2
|
//# sourceMappingURL=Combobox.js.map
|
package/lib/Combobox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.js","sources":["../src/combobox/Combobox.ts"],"sourcesContent":["import type { ComboboxRegistry } from './combobox-context.js'\nimport type { ComboboxOption } from './ComboboxBase.js'\nimport { ContextProvider } from '@lit/context'\nimport * as addIcon from '@nordhealth/icons/lib/assets/interface-add-small.js'\nimport { html, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { repeat } from 'lit/directives/repeat.js'\n\nimport { injectLightDomStyles } from '../common/light-dom-styles.js'\nimport Icon from '../icon/Icon.js'\nimport { comboboxRegistryContext } from './combobox-context.js'\nimport style from './Combobox.css'\nimport ComboboxBase from './ComboboxBase.js'\nimport { ComboboxClearEvent, ComboboxCreateEvent } from './ComboboxEvents.js'\nimport '../kbd/Kbd.js'\nimport '../tag/Tag.js'\nimport './ComboboxOption.js'\nimport './ComboboxGroup.js'\n\nIcon.registerIcon(addIcon)\n\nexport type { ComboboxOption } from './ComboboxBase.js'\nexport { ComboboxClearEvent, ComboboxCreateEvent } from './ComboboxEvents.js'\n\n/**\n * Combobox lets users choose one option (or several) from a list by typing to\n * filter, then picking with the keyboard or pointer. Use it when a [Select](/components/select/)\n * would be unwieldy because there are many options to scan.\n *\n * Combobox is a control only — it has no built-in label, hint or error. Compose\n * it inside a [Field](/components/field/) to give it a label, hint and error\n * message, the same way you would a native input.\n *\n * The committed `value` is an option's `value` (or an array of them with\n * `multiple`); the input is a filter/search field whose text is discarded on\n * commit. For a free-text input with suggestions where the typed text is the\n * value, use [Autocomplete](/components/autocomplete/) instead.\n *\n * @status draft\n * @category form\n * @lightDom true\n *\n * @slot start - Optional slot used to place an icon or prefix at the start of the control.\n * @slot end - Optional slot used to place an icon or suffix at the end of the control.\n *\n * @fires {NordEvent} change - Dispatched when the committed value changes via user interaction.\n * @fires {NordEvent} input - Dispatched as the user types into the search input.\n * @fires {NordEvent} open - Dispatched when the listbox is opened.\n * @fires {NordEvent} close - Dispatched when the listbox is closed.\n * @fires {ComboboxClearEvent} clear - Dispatched when the value is cleared via the clear button or `clear()`.\n * @fires {ComboboxCreateEvent} create - Dispatched when the user chooses the \"Create\" affordance in a `creatable` combobox.\n *\n * @localization clearLabel - Accessible label for the clear button.\n * @localization createLabel - Label for the \"Create\" affordance, given the current query.\n * @localization noResults - Message shown when no options match the query.\n *\n * @cssprop [--n-combobox-list-inline-size] - Controls the inline size, or width, of the dropdown list. Defaults to the width of the combobox control.\n * @cssprop [--n-combobox-block-size] - Controls the block size, or height, of the control. The medium default is `var(--n-space-xl)`; the s and l sizes scale from it.\n *\n * @attr {boolean} data-invalid - Present while the control is invalid (mirrors the `invalid` property). Style hook for the whole control.\n * @attr {boolean} data-focused - Present while the control has focus. Style hook for focus-within treatments.\n */\n@customElement('nord-combobox')\nexport default class Combobox extends ComboboxBase {\n /**\n * The value of the combobox. A single string when `multiple` is `false`,\n * or an array of strings when `multiple` is `true`.\n */\n @property({ attribute: false })\n // @ts-expect-error - intentionally widens the inherited `value: string` to support multiple selection\n value: string | string[] = ''\n\n /**\n * Allows selecting more than one option. Selected options are shown as\n * removable chips and the listbox stays open after each selection.\n */\n @property({ reflect: true, type: Boolean }) multiple = false\n\n /**\n * Shows a clear (✕) button while there is a value. Pressing it resets the\n * value to `''` (or `[]` when `multiple`), then fires `clear` and `change`.\n * Defaults to `true`.\n *\n * This prop only toggles the button. A single-select value can always be\n * cleared by deleting the input text, regardless of this prop (Base UI\n * parity).\n */\n @property({ reflect: true, type: Boolean }) clearable = true\n\n /**\n * Offers a \"Create\" affordance when the query does not exactly match an\n * existing option. Choosing it (click or Enter) adds the typed value as an\n * option and selects it (in `multiple` mode it is appended as a chip), and\n * fires a cancelable `create` event. Call `event.preventDefault()` to opt out\n * and handle creation yourself (e.g. to map the value to a different `value`).\n */\n @property({ reflect: true, type: Boolean }) creatable = false\n\n /** Options contributed by declarative `<nord-combobox-option>` children. */\n @state() private slottedOptions: ComboboxOption[] = []\n\n /** Options the combobox created itself via the auto-add `creatable` flow. */\n @state() private createdOptions: ComboboxOption[] = []\n\n /** Registered declarative option elements (rebuilt into `slottedOptions`). */\n private optionElements = new Set<Element>()\n\n /** The registry the option/group children use to self-register (provide/inject). */\n private optionRegistry: ComboboxRegistry = {\n add: (option) => {\n this.optionElements.add(option)\n this.rebuildSlottedOptions()\n },\n remove: (option) => {\n this.optionElements.delete(option)\n this.rebuildSlottedOptions()\n },\n notify: () => this.rebuildSlottedOptions(),\n }\n\n private registryProvider = new ContextProvider(this, {\n context: comboboxRegistryContext,\n initialValue: this.optionRegistry,\n })\n\n connectedCallback() {\n super.connectedCallback()\n injectLightDomStyles(this, style)\n }\n\n /** Read a registered option element into a plain `ComboboxOption`. */\n private readOptionElement(el: Element): ComboboxOption {\n const group = el.closest('nord-combobox-group')?.getAttribute('label') || undefined\n const label = el.getAttribute('label') ?? el.textContent?.trim() ?? ''\n const option: ComboboxOption = {\n value: el.getAttribute('value') ?? '',\n label,\n disabled: el.hasAttribute('disabled'),\n }\n if (group) {\n option.group = group\n }\n // Custom markup (e.g. an avatar) becomes the rendered row content.\n if (el.children.length > 0) {\n option.html = el.innerHTML\n }\n return option\n }\n\n /** Rebuild `slottedOptions` from the registered elements, in DOM order. */\n private rebuildSlottedOptions() {\n const ordered = [...this.optionElements].sort((a, b) =>\n\n a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n )\n this.slottedOptions = ordered.map(el => this.readOptionElement(el))\n }\n\n /** Cache for the merged option list so `filtered`'s identity check stays stable. */\n private resolvedCache?: {\n options: ComboboxOption[]\n slotted: ComboboxOption[]\n created: ComboboxOption[]\n result: ComboboxOption[]\n }\n\n /**\n * The options to render: the `.options` property when set (dynamic/async data),\n * otherwise the declarative `<nord-combobox-option>` children, with any\n * auto-created options merged on top.\n */\n protected override get resolvedOptions(): ComboboxOption[] {\n const base = this.options.length ? this.options : this.slottedOptions\n const created = this.createdOptions\n const cache = this.resolvedCache\n if (cache && cache.options === this.options && cache.slotted === this.slottedOptions && cache.created === created) {\n return cache.result\n }\n const result = created.length ? [...base, ...created] : base\n this.resolvedCache = { options: this.options, slotted: this.slottedOptions, created, result }\n return result\n }\n\n /** Whether chip/array logic applies — i.e. `multiple` selection. */\n private get isMultiple(): boolean {\n return this.multiple\n }\n\n /**\n * In `multiple` mode the input is always a pure filter (selections live in\n * chips). In single-select it shows the live query only once the user types;\n * until then it keeps the selected option's label visible and editable (Base\n * UI parity — see `ComboboxBase.showsQueryInInput`).\n */\n protected override get showsQueryInInput(): boolean {\n return this.isMultiple || this.queryDirty\n }\n\n protected override get inputPlaceholder(): string | undefined {\n return this.isMultiple && this.hasValue ? undefined : this.placeholder\n }\n\n /** The index of the create row, or `-1` when it isn't shown. */\n protected override get createIndex(): number {\n return this.canCreate ? this.filteredOptions.length : -1\n }\n\n /** Whether the \"Create\" affordance should be offered for the current query. */\n protected override get canCreate(): boolean {\n const query = this.search.trim()\n\n if (!this.creatable || !query) {\n return false\n }\n\n // Don't offer to create something that already exists exactly.\n return !this.resolvedOptions.some(\n option => option.label.toLocaleLowerCase() === query.toLocaleLowerCase(),\n )\n }\n\n protected override get showClear(): boolean {\n return this.clearable && this.hasValue && !this.disabled\n }\n\n protected override get ariaMultiselectable(): 'true' | 'false' {\n return this.isMultiple ? 'true' : 'false'\n }\n\n /**\n * Clear the current value, firing `clear` then `change`.\n */\n override clear() {\n this.value = this.isMultiple ? [] : ''\n this.search = ''\n this.queryDirty = false\n this.dispatchEvent(new ComboboxClearEvent())\n this.commit()\n this.focus()\n }\n\n protected override selectOption(option: ComboboxOption) {\n // Single-select behaves exactly like the base (set value, close, restore\n // focus); only the multiple case — toggle membership, keep the popup open —\n // differs, so handle that here and delegate the rest.\n if (!this.isMultiple) {\n return super.selectOption(option)\n }\n\n if (option.disabled) {\n return\n }\n\n // Remember the label so it survives the option leaving the result set.\n this.labelCache.set(option.value, option.label)\n\n const next = this.values.includes(option.value)\n ? this.values.filter(value => value !== option.value)\n : [...this.values, option.value]\n\n this.value = next\n this.search = ''\n this.queryDirty = false\n this.commit()\n // Keep the popup open after selection in multiple mode.\n this.focus()\n }\n\n protected override onInput(input: HTMLInputElement): void {\n // Base UI parity: fully deleting the single-select input text clears the\n // committed selection (not just the filter). This is always available,\n // independent of the `clearable` button. In multiple mode the selections\n // live in chips, so an empty filter is not a clear (Backspace removes the\n // last chip instead — see `onUnhandledKeydown`).\n if (!this.isMultiple && input.value === '' && this.hasValue) {\n this.value = ''\n this.commit()\n }\n }\n\n protected override emitCreate() {\n const query = this.search.trim()\n\n if (!query) {\n return\n }\n\n /**\n * Fired when the user chooses the create affordance, carrying the typed\n * query. By default the combobox then adds the value as an option and selects\n * it; call `event.preventDefault()` to opt out and handle creation yourself.\n */\n const proceed = this.dispatchEvent(new ComboboxCreateEvent(query))\n if (!proceed) {\n // Consumer opted out — leave options/value untouched (legacy behaviour).\n return\n }\n\n const option: ComboboxOption = { value: query, label: query }\n\n // Add to our own additive list so it survives `.options` reassignment and\n // works regardless of the source (property, slotted, or external-filtering).\n if (!this.resolvedOptions.some(o => o.value === option.value)) {\n this.createdOptions = [...this.createdOptions, option]\n }\n this.labelCache.set(option.value, option.label)\n\n // Select it: single sets the value and closes; multiple appends a chip,\n // clears the query and keeps the popup open — same as picking any option.\n this.selectOption(option)\n }\n\n protected override onUnhandledKeydown(e: KeyboardEvent) {\n // In multiple mode, an empty query Backspace removes the last chip.\n if (e.key === 'Backspace' && this.isMultiple && !this.search && this.values.length) {\n this.removeValue(this.values[this.values.length - 1])\n }\n }\n\n private removeValue(value: string) {\n if (this.disabled) {\n return\n }\n\n this.value = this.values.filter(v => v !== value)\n this.commit()\n this.focus()\n }\n\n /** Multiple mode renders selected options as removable chips before the input. */\n protected override renderLeadingControl() {\n if (!this.isMultiple) {\n return nothing\n }\n\n return repeat(\n this.values,\n value => value,\n (value) => {\n return html`\n <nord-tag\n class=\"n-chip\"\n size=\"s\"\n variant=\"removable\"\n ?disabled=${this.disabled}\n @remove=${() => this.removeValue(value)}\n @click=${(e: Event) => e.stopPropagation()}\n >\n ${this.labelFor(value)}\n </nord-tag>\n `\n },\n )\n }\n\n protected override renderCreate() {\n const active = this.activeDescendant.activeIndex === this.createIndex\n\n return html`\n <div\n id=${this.createId}\n class=${classMap({ 'n-option': true, 'n-create': true, 'is-active': active })}\n role=\"option\"\n aria-selected=\"false\"\n @click=${this.emitCreate}\n @mousemove=${() => this.activeDescendant.setActiveIndex(this.createIndex)}\n >\n <nord-icon class=\"n-create-icon\" name=\"interface-add-small\"></nord-icon>\n <span class=\"n-option-label\">${this.localize.term('createLabel', this.search.trim())}</span>\n <nord-kbd class=\"n-create-kbd\" aria-hidden=\"true\">⏎</nord-kbd>\n </div>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-combobox': Combobox\n }\n}\n"],"names":["Icon","registerIcon","addIcon","Combobox","ComboboxBase","constructor","this","value","multiple","clearable","creatable","slottedOptions","createdOptions","optionElements","Set","optionRegistry","add","option","rebuildSlottedOptions","remove","delete","notify","registryProvider","ContextProvider","context","comboboxRegistryContext","initialValue","connectedCallback","super","injectLightDomStyles","style","readOptionElement","el","group","_a","closest","getAttribute","undefined","label","_d","_b","_c","textContent","trim","_e","disabled","hasAttribute","children","length","html","innerHTML","ordered","sort","a","b","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","map","resolvedOptions","base","options","created","cache","resolvedCache","slotted","result","isMultiple","showsQueryInInput","queryDirty","inputPlaceholder","hasValue","placeholder","createIndex","canCreate","filteredOptions","query","search","some","toLocaleLowerCase","showClear","ariaMultiselectable","clear","dispatchEvent","ComboboxClearEvent","commit","focus","selectOption","labelCache","set","next","values","includes","filter","onInput","input","emitCreate","ComboboxCreateEvent","o","onUnhandledKeydown","e","key","removeValue","v","renderLeadingControl","repeat","stopPropagation","labelFor","nothing","renderCreate","active","activeDescendant","activeIndex","createId","classMap","setActiveIndex","localize","term","__decorate","property","attribute","prototype","reflect","type","Boolean","state","customElement"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Combobox.js","sources":["../src/combobox/Combobox.ts"],"sourcesContent":["import type { ComboboxRegistry } from './combobox-context.js'\nimport type { ComboboxOption } from './ComboboxBase.js'\nimport { ContextProvider } from '@lit/context'\nimport * as addIcon from '@nordhealth/icons/lib/assets/interface-add-small.js'\nimport { html, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { repeat } from 'lit/directives/repeat.js'\n\nimport { injectLightDomStyles } from '../common/light-dom-styles.js'\nimport Icon from '../icon/Icon.js'\nimport { comboboxRegistryContext } from './combobox-context.js'\nimport style from './Combobox.css'\nimport ComboboxBase from './ComboboxBase.js'\nimport { ComboboxClearEvent, ComboboxCreateEvent } from './ComboboxEvents.js'\nimport '../kbd/Kbd.js'\nimport '../tag/Tag.js'\nimport './ComboboxOption.js'\nimport './ComboboxGroup.js'\n\nIcon.registerIcon(addIcon)\n\nexport type { ComboboxOption } from './ComboboxBase.js'\nexport { ComboboxClearEvent, ComboboxCreateEvent } from './ComboboxEvents.js'\n\n/**\n * Combobox lets users choose one option (or several) from a list by typing to\n * filter, then picking with the keyboard or pointer. Use it when a [Select](/components/select/)\n * would be unwieldy because there are many options to scan.\n *\n * Combobox is a control only — it has no built-in label, hint or error. Compose\n * it inside a [Field](/components/field/) to give it a label, hint and error\n * message, the same way you would a native input.\n *\n * The committed `value` is an option's `value` (or an array of them with\n * `multiple`); the input is a filter/search field whose text is discarded on\n * commit. For a free-text input with suggestions where the typed text is the\n * value, use [Autocomplete](/components/autocomplete/) instead.\n *\n * @status draft\n * @category form\n * @lightDom true\n *\n * @slot start - Optional slot used to place an icon or prefix at the start of the control.\n * @slot end - Optional slot used to place an icon or suffix at the end of the control.\n *\n * @fires {NordEvent} change - Dispatched when the committed value changes via user interaction.\n * @fires {NordEvent} input - Dispatched as the user types into the search input.\n * @fires {NordEvent} open - Dispatched when the listbox is opened.\n * @fires {NordEvent} close - Dispatched when the listbox is closed.\n * @fires {ComboboxClearEvent} clear - Dispatched when the value is cleared via the clear button or `clear()`.\n * @fires {ComboboxCreateEvent} create - Dispatched when the user chooses the \"Create\" affordance in a `creatable` combobox.\n *\n * @localization clearLabel - Accessible label for the clear button.\n * @localization createLabel - Label for the \"Create\" affordance, given the current query.\n * @localization noResults - Message shown when no options match the query.\n *\n * @cssprop [--n-combobox-list-inline-size] - Controls the inline size, or width, of the dropdown list. Defaults to the width of the combobox control.\n * @cssprop [--n-combobox-block-size] - Controls the block size, or height, of the control. The medium default is `var(--n-space-xl)`; the s and l sizes scale from it.\n *\n * @attr {boolean} data-invalid - Present while the control is invalid (mirrors the `invalid` property). Style hook for the whole control.\n * @attr {boolean} data-focused - Present while the control has focus. Style hook for focus-within treatments.\n */\n@customElement('nord-combobox')\nexport default class Combobox extends ComboboxBase {\n /**\n * The value of the combobox. A single string when `multiple` is `false`,\n * or an array of strings when `multiple` is `true`.\n */\n @property({ attribute: false })\n // @ts-expect-error - intentionally widens the inherited `value: string` to support multiple selection\n value: string | string[] = ''\n\n /**\n * Allows selecting more than one option. Selected options are shown as\n * removable chips and the listbox stays open after each selection.\n */\n @property({ reflect: true, type: Boolean }) multiple = false\n\n /**\n * Shows a clear (✕) button while there is a value. Pressing it resets the\n * value to `''` (or `[]` when `multiple`), then fires `clear` and `change`.\n * Defaults to `true`.\n *\n * This prop only toggles the button. A single-select value can always be\n * cleared by deleting the input text, regardless of this prop (Base UI\n * parity).\n */\n @property({ reflect: true, type: Boolean }) clearable = true\n\n /**\n * Offers a \"Create\" affordance when the query does not exactly match an\n * existing option. Choosing it (click or Enter) adds the typed value as an\n * option and selects it (in `multiple` mode it is appended as a chip), and\n * fires a cancelable `create` event. Call `event.preventDefault()` to opt out\n * and handle creation yourself (e.g. to map the value to a different `value`).\n */\n @property({ reflect: true, type: Boolean }) creatable = false\n\n /** Options contributed by declarative `<nord-combobox-option>` children. */\n @state() private slottedOptions: ComboboxOption[] = []\n\n /** Options the combobox created itself via the auto-add `creatable` flow. */\n @state() private createdOptions: ComboboxOption[] = []\n\n /** Registered declarative option elements (rebuilt into `slottedOptions`). */\n private optionElements = new Set<Element>()\n\n /** The registry the option/group children use to self-register (provide/inject). */\n private optionRegistry: ComboboxRegistry = {\n add: (option) => {\n this.optionElements.add(option)\n this.rebuildSlottedOptions()\n },\n remove: (option) => {\n this.optionElements.delete(option)\n this.rebuildSlottedOptions()\n },\n notify: () => this.rebuildSlottedOptions(),\n }\n\n private registryProvider = new ContextProvider(this, {\n context: comboboxRegistryContext,\n initialValue: this.optionRegistry,\n })\n\n connectedCallback() {\n super.connectedCallback()\n injectLightDomStyles(this, style)\n }\n\n /** Read a registered option element into a plain `ComboboxOption`. */\n private readOptionElement(el: Element): ComboboxOption {\n const group = el.closest('nord-combobox-group')?.getAttribute('label') || undefined\n const label = el.getAttribute('label') ?? el.textContent?.trim() ?? ''\n const option: ComboboxOption = {\n value: el.getAttribute('value') ?? '',\n label,\n disabled: el.hasAttribute('disabled'),\n }\n if (group) {\n option.group = group\n }\n // Custom markup (e.g. an avatar) becomes the rendered row content.\n if (el.children.length > 0) {\n option.html = el.innerHTML\n }\n return option\n }\n\n /** Rebuild `slottedOptions` from the registered elements, in DOM order. */\n private rebuildSlottedOptions() {\n const ordered = [...this.optionElements].sort((a, b) =>\n\n a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n )\n this.slottedOptions = ordered.map(el => this.readOptionElement(el))\n }\n\n /** Cache for the merged option list so `filtered`'s identity check stays stable. */\n private resolvedCache?: {\n options: ComboboxOption[]\n slotted: ComboboxOption[]\n created: ComboboxOption[]\n result: ComboboxOption[]\n }\n\n /**\n * The options to render: the `.options` property when set (dynamic/async data),\n * otherwise the declarative `<nord-combobox-option>` children, with any\n * auto-created options merged on top.\n */\n protected override get resolvedOptions(): ComboboxOption[] {\n const base = this.options.length ? this.options : this.slottedOptions\n const created = this.createdOptions\n const cache = this.resolvedCache\n if (cache && cache.options === this.options && cache.slotted === this.slottedOptions && cache.created === created) {\n return cache.result\n }\n const result = created.length ? [...base, ...created] : base\n this.resolvedCache = { options: this.options, slotted: this.slottedOptions, created, result }\n return result\n }\n\n /** Whether chip/array logic applies — i.e. `multiple` selection. */\n private get isMultiple(): boolean {\n return this.multiple\n }\n\n /**\n * In `multiple` mode the input is always a pure filter (selections live in\n * chips). In single-select it shows the live query only once the user types;\n * until then it keeps the selected option's label visible and editable (Base\n * UI parity — see `ComboboxBase.showsQueryInInput`).\n */\n protected override get showsQueryInInput(): boolean {\n return this.isMultiple || this.queryDirty\n }\n\n protected override get inputPlaceholder(): string | undefined {\n return this.isMultiple && this.hasValue ? undefined : this.placeholder\n }\n\n /** The index of the create row, or `-1` when it isn't shown. */\n protected override get createIndex(): number {\n return this.canCreate ? this.filteredOptions.length : -1\n }\n\n /** Whether the \"Create\" affordance should be offered for the current query. */\n protected override get canCreate(): boolean {\n const query = this.search.trim()\n\n if (!this.creatable || !query) {\n return false\n }\n\n // Don't offer to create something that already exists exactly.\n return !this.resolvedOptions.some(\n option => option.label.toLocaleLowerCase() === query.toLocaleLowerCase(),\n )\n }\n\n protected override get showClear(): boolean {\n return this.clearable && this.hasValue && !this.disabled && !this.readonly\n }\n\n protected override get ariaMultiselectable(): 'true' | 'false' {\n return this.isMultiple ? 'true' : 'false'\n }\n\n /**\n * Clear the current value, firing `clear` then `change`.\n */\n override clear() {\n this.value = this.isMultiple ? [] : ''\n this.search = ''\n this.queryDirty = false\n this.dispatchEvent(new ComboboxClearEvent())\n this.commit()\n this.focus()\n }\n\n protected override selectOption(option: ComboboxOption) {\n // Single-select behaves exactly like the base (set value, close, restore\n // focus); only the multiple case — toggle membership, keep the popup open —\n // differs, so handle that here and delegate the rest.\n if (!this.isMultiple) {\n return super.selectOption(option)\n }\n\n if (option.disabled) {\n return\n }\n\n // Remember the label so it survives the option leaving the result set.\n this.labelCache.set(option.value, option.label)\n\n const next = this.values.includes(option.value)\n ? this.values.filter(value => value !== option.value)\n : [...this.values, option.value]\n\n this.value = next\n this.search = ''\n this.queryDirty = false\n this.commit()\n // Keep the popup open after selection in multiple mode.\n this.focus()\n }\n\n protected override onInput(input: HTMLInputElement): void {\n // Base UI parity: fully deleting the single-select input text clears the\n // committed selection (not just the filter). This is always available,\n // independent of the `clearable` button. In multiple mode the selections\n // live in chips, so an empty filter is not a clear (Backspace removes the\n // last chip instead — see `onUnhandledKeydown`).\n if (!this.isMultiple && input.value === '' && this.hasValue) {\n this.value = ''\n this.commit()\n }\n }\n\n protected override emitCreate() {\n const query = this.search.trim()\n\n if (!query) {\n return\n }\n\n /**\n * Fired when the user chooses the create affordance, carrying the typed\n * query. By default the combobox then adds the value as an option and selects\n * it; call `event.preventDefault()` to opt out and handle creation yourself.\n */\n const proceed = this.dispatchEvent(new ComboboxCreateEvent(query))\n if (!proceed) {\n // Consumer opted out — leave options/value untouched (legacy behaviour).\n return\n }\n\n const option: ComboboxOption = { value: query, label: query }\n\n // Add to our own additive list so it survives `.options` reassignment and\n // works regardless of the source (property, slotted, or external-filtering).\n if (!this.resolvedOptions.some(o => o.value === option.value)) {\n this.createdOptions = [...this.createdOptions, option]\n }\n this.labelCache.set(option.value, option.label)\n\n // Select it: single sets the value and closes; multiple appends a chip,\n // clears the query and keeps the popup open — same as picking any option.\n this.selectOption(option)\n }\n\n protected override onUnhandledKeydown(e: KeyboardEvent) {\n // In multiple mode, an empty query Backspace removes the last chip.\n if (e.key === 'Backspace' && this.isMultiple && !this.search && this.values.length) {\n this.removeValue(this.values[this.values.length - 1])\n }\n }\n\n private removeValue(value: string) {\n if (this.disabled) {\n return\n }\n\n this.value = this.values.filter(v => v !== value)\n this.commit()\n this.focus()\n }\n\n /** Multiple mode renders selected options as removable chips before the input. */\n protected override renderLeadingControl() {\n if (!this.isMultiple) {\n return nothing\n }\n\n return repeat(\n this.values,\n value => value,\n (value) => {\n return html`\n <nord-tag\n class=\"n-chip\"\n size=\"s\"\n variant=\"removable\"\n ?disabled=${this.disabled}\n @remove=${() => this.removeValue(value)}\n @click=${(e: Event) => e.stopPropagation()}\n >\n ${this.labelFor(value)}\n </nord-tag>\n `\n },\n )\n }\n\n protected override renderCreate() {\n const active = this.activeDescendant.activeIndex === this.createIndex\n\n return html`\n <div\n id=${this.createId}\n class=${classMap({ 'n-option': true, 'n-create': true, 'is-active': active })}\n role=\"option\"\n aria-selected=\"false\"\n @click=${this.emitCreate}\n @mousemove=${() => this.activeDescendant.setActiveIndex(this.createIndex)}\n >\n <nord-icon class=\"n-create-icon\" name=\"interface-add-small\"></nord-icon>\n <span class=\"n-option-label\">${this.localize.term('createLabel', this.search.trim())}</span>\n <nord-kbd class=\"n-create-kbd\" aria-hidden=\"true\">⏎</nord-kbd>\n </div>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-combobox': Combobox\n }\n}\n"],"names":["Icon","registerIcon","addIcon","Combobox","ComboboxBase","constructor","this","value","multiple","clearable","creatable","slottedOptions","createdOptions","optionElements","Set","optionRegistry","add","option","rebuildSlottedOptions","remove","delete","notify","registryProvider","ContextProvider","context","comboboxRegistryContext","initialValue","connectedCallback","super","injectLightDomStyles","style","readOptionElement","el","group","_a","closest","getAttribute","undefined","label","_d","_b","_c","textContent","trim","_e","disabled","hasAttribute","children","length","html","innerHTML","ordered","sort","a","b","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","map","resolvedOptions","base","options","created","cache","resolvedCache","slotted","result","isMultiple","showsQueryInInput","queryDirty","inputPlaceholder","hasValue","placeholder","createIndex","canCreate","filteredOptions","query","search","some","toLocaleLowerCase","showClear","readonly","ariaMultiselectable","clear","dispatchEvent","ComboboxClearEvent","commit","focus","selectOption","labelCache","set","next","values","includes","filter","onInput","input","emitCreate","ComboboxCreateEvent","o","onUnhandledKeydown","e","key","removeValue","v","renderLeadingControl","repeat","stopPropagation","labelFor","nothing","renderCreate","active","activeDescendant","activeIndex","createId","classMap","setActiveIndex","localize","term","__decorate","property","attribute","prototype","reflect","type","Boolean","state","customElement"],"mappings":"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"}
|
package/lib/ComboboxBase.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{c as e,A as i}from"./ActiveDescendantController-BnMqM79O.js";import{c as s}from"./interface-close-small-CnpAFMO3.js";import{d as n}from"./interface-dropdown-small-CYvgxudU.js";import{nothing as o,isServer as r,html as l,unsafeCSS as a,LitElement as h}from"lit";import{query as c,property as d,state as u}from"lit/decorators.js";import{classMap as p}from"lit/directives/class-map.js";import{ifDefined as m}from"lit/directives/if-defined.js";import{createRef as f,ref as v}from"lit/directives/ref.js";import{repeat as g}from"lit/directives/repeat.js";import{styleMap as b}from"lit/directives/style-map.js";import{unsafeHTML as S}from"lit/directives/unsafe-html.js";import{g as y}from"./collection-Dvg2XbxV.js";import{F as x}from"./FormDataController-OUt5L5uC.js";import{L as O}from"./LightDismissController-4pH8cdko.js";import{R as z}from"./ResizeController-14PUwRQy.js";import{S as w}from"./StateAttributesController-BIh96sXZ.js";import{o as I}from"./observe-D0n0zOfU.js";import{c as C}from"./cond-CI1KbneT.js";import{N as E}from"./events-Bv6wNHwJ.js";import{A}from"./AutocompleteMixin-D8eiOxvO.js";import{D as M}from"./DraftComponentMixin-4qug5Rky.js";import{F as j}from"./FieldControlMixin-BXNZJXu9.js";import{F as T}from"./Popout-DpN7PP9h.js";import{I as $}from"./InputMixin-LetXsCyv.js";import{S as D}from"./SizeMixin-CU9cLbLC.js";import _ from"./Icon.js";import{LocalizeController as k}from"./LocalizeController.js";import"./Spinner.js";import"./number-Dg2vCfGd.js";import"./EventController-BBOmvfLa.js";import"./ShortcutController-BIb3WGzH.js";import"./tinykeys.module-_6MZt7MP.js";import"./context-consumer-BJVUulGf.js";import"./context-request-event-CCRlXoeR.js";import"./field-context.js";import"./create-context-CJ69ntlY.js";import"./SlotController-Z6eG7LSZ.js";import"./light-dom-styles-DXsbiKU9.js";import"./VisuallyHidden.js";import"./positioning-D-K8Mueq.js";import"./DirectionController-ChvNGESZ.js";import"./ScrollbarController-BFC67Y2x.js";import"./Component-BJ5O5n8k.js";import"./IconManager.js";import"./translation.js";import"./en-us.js";import"./localization.js";import"./localization2.js";import"./localization3.js";import"./localization4.js";import"./localization5.js";import"./localization6.js";import"./localization7.js";import"./localization8.js";import"./localization9.js";import"./localization10.js";import"./localization11.js";import"./localization12.js";import"./localization13.js";import"./localization14.js";import"./localization15.js";import"./localization16.js";import"./localization17.js";import"./localization18.js";import"./localization19.js";import"./localization20.js";import"./localization21.js";import"./localization22.js";function R(t,e,i){let s,n=i.initialDeps??[],o=!0;function r(){const r=t();return r.length!==n.length||r.some(((t,e)=>n[e]!==t))?(n=r,s=e(...r),!(null==i?void 0:i.onChange)||o&&i.skipInitialOnChange||i.onChange(s),o=!1,s):s}return r.updateDeps=t=>{n=t},r}function F(t,e){if(void 0===t)throw new Error("Unexpected undefined");return t}const V=(t,e,i)=>{let s;return function(...n){t.clearTimeout(s),s=t.setTimeout((()=>e.apply(this,n)),i)}};let L;const W=()=>{if(void 0!==L)return L;if("undefined"==typeof navigator)return L=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return L=!0;const t=navigator.maxTouchPoints;return L="MacIntel"===navigator.platform&&void 0!==t&&t>0},P=t=>{const{offsetWidth:e,offsetHeight:i}=t;return{width:e,height:i}},q=t=>t,H=t=>{const e=Math.max(t.startIndex-t.overscan,0),i=Math.min(t.endIndex+t.overscan,t.count-1)-e+1,s=new Array(i);for(let t=0;t<i;t++)s[t]=e+t;return s},K=(t,e)=>{const i=t.scrollElement;if(!i)return;const s=t.targetWindow;if(!s)return;const n=t=>{const{width:i,height:s}=t;e({width:Math.round(i),height:Math.round(s)})};if(n(P(i)),!s.ResizeObserver)return()=>{};const o=new s.ResizeObserver((e=>{const s=()=>{const t=e[0];if(null==t?void 0:t.borderBoxSize){const e=t.borderBoxSize[0];if(e)return void n({width:e.inlineSize,height:e.blockSize})}n(P(i))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()}));return o.observe(i,{box:"border-box"}),()=>{o.unobserve(i)}},B={passive:!0},U="undefined"==typeof window||"onscrollend"in window,N=(t,e)=>((t,e,i)=>{const s=t.scrollElement;if(!s)return;const n=t.targetWindow;if(!n)return;const o=t.options.useScrollendEvent&&U;let r=0;const l=o?null:V(n,(()=>e(r,!1)),t.options.isScrollingResetDelay),a=t=>()=>{r=i(s),null==l||l(),e(r,t)},h=a(!0),c=a(!1);return s.addEventListener("scroll",h,B),o&&s.addEventListener("scrollend",c,B),()=>{s.removeEventListener("scroll",h),o&&s.removeEventListener("scrollend",c)}})(t,e,(e=>{const{horizontal:i,isRtl:s}=t.options;return i?e.scrollLeft*(s?-1:1):e.scrollTop})),J=(t,e,i)=>{if(i.options.useCachedMeasurements){const e=i.indexFromElement(t),s=i.options.getItemKey(e);return i.itemSizeCache.get(s)??i.options.estimateSize(e)}if(null==e?void 0:e.borderBoxSize){const t=e.borderBoxSize[0];if(t){return Math.round(t[i.options.horizontal?"inlineSize":"blockSize"])}}if(!e){const e=i.indexFromElement(t),s=i.options.getItemKey(e),n=i.itemSizeCache.get(s);if(void 0!==n)return n}return t[i.options.horizontal?"offsetWidth":"offsetHeight"]},G=(t,{adjustments:e=0,behavior:i},s)=>{var n,o;null==(o=null==(n=s.scrollElement)?void 0:n.scrollTo)||o.call(n,{[s.options.horizontal?"left":"top"]:t+e,behavior:i})};class Q{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,e,i;return(null==(i=null==(e=null==(t=this.targetWindow)?void 0:t.performance)?void 0:e.now)?void 0:i.call(e))??Date.now()},this.observer=(()=>{let t=null;const e=()=>t||(this.targetWindow&&this.targetWindow.ResizeObserver?t=new this.targetWindow.ResizeObserver((t=>{t.forEach((t=>{const e=()=>{const e=t.target,i=this.indexFromElement(e);if(e.isConnected)this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(e,t,this));else{this.observer.unobserve(e);for(const[t,i]of this.elementsCache)if(i===e){this.elementsCache.delete(t);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(e):e()}))})):null);return{disconnect:()=>{var i;null==(i=e())||i.disconnect(),t=null},observe:t=>{var i;return null==(i=e())?void 0:i.observe(t,{box:"border-box"})},unobserve:t=>{var i;return null==(i=e())?void 0:i.unobserve(t)}}})(),this.range=null,this.setOptions=t=>{var e,i;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:q,rangeExtractor:H,onChange:()=>{},measureElement:J,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const e in t){const i=t[e];void 0!==i&&(s[e]=i)}const n=this.options;let o=null,r=null,l=!1;if(void 0!==n&&n.enabled&&s.enabled&&"end"===s.anchorTo&&null!==this.scrollElement){const t=n.count,a=s.count,h=this.getMeasurements(),c=t>0?(null==(e=h[0])?void 0:e.key)??n.getItemKey(0):null,d=t>0?(null==(i=h[t-1])?void 0:i.key)??n.getItemKey(t-1):null;if(a!==t||t>0&&a>0&&(s.getItemKey(0)!==c||s.getItemKey(a-1)!==d)){l=!0;const e=t>0?this.getVirtualItemForOffset(this.getScrollOffset())??h[0]:null;e&&(o=[e.key,this.getScrollOffset()-e.start]);const i=!0===s.followOnAppend?"auto":s.followOnAppend||null;i&&a>t&&this.isAtEnd(n.scrollEndThreshold)&&(0===t||s.getItemKey(a-1)!==d)&&(r=i)}}this.options=s,l&&(this.pendingMin=0,this.itemSizeCacheVersion++);let a=!1,h=0;if(o&&null!==this.scrollOffset){const[t,e]=o,i=this.getMeasurements(),{count:s,getItemKey:n}=this.options;let r=0;for(;r<s&&n(r)!==t;)r++;if(r<s){const t=i[r];if(t){const i=t.start+e;i!==this.scrollOffset&&(h=i-this.scrollOffset,this.scrollOffset=i,a=!0)}}}(a||r)&&(this.pendingScrollAnchor=[a?o[0]:null,a?o[1]:0,r,h])},this.notify=t=>{var e,i;null==(i=(e=this.options).onChange)||i.call(e,this,t)},this.maybeNotify=R((()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null])),(t=>{this.notify(t)}),{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach((t=>t())),this.unsubs=[],this.observer.disconnect(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e)return void this.maybeNotify();if(this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(t=this.scrollElement)?void 0:t.window)??null,this.elementsCache.forEach((t=>{this.observer.observe(t)})),this.unsubs.push(this.options.observeElementRect(this,(t=>{this.scrollRect=t,this.maybeNotify()}))),this.unsubs.push(this.options.observeElementOffset(this,((t,e)=>{null!==this._intendedScrollOffset&&Math.abs(t-this._intendedScrollOffset)<1.5&&(t=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=e?this.getScrollOffset()<t?"forward":"backward":null,this.scrollOffset=t,this.isScrolling=e,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()}))),"addEventListener"in this.scrollElement){const t=this.scrollElement,e=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},i=()=>{this._iosTouching=!1,W()&&null!=this.targetWindow&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout((()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()}),150))};t.addEventListener("touchstart",e,B),t.addEventListener("touchend",i,B),this.unsubs.push((()=>{t.removeEventListener("touchstart",e),t.removeEventListener("touchend",i),null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)}))}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[t,e,s,n]=i;null===t||s||(W()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?0!==n&&(this._iosDeferredAdjustment+=n):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),s&&this.scrollToEnd({behavior:s})}},this._flushIosDeferredIfReady=()=>{if(0===this._iosDeferredAdjustment)return;if(this.isScrolling)return;if(this._iosTouching)return;if(this._iosJustTouchEnded)return;const t=this.getScrollOffset(),e=this.getMaxScrollOffset();if(t<0||t>e)return;const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,e)=>{const i=new Map,s=new Map;for(let n=e-1;n>=0;n--){const e=t[n];if(i.has(e.lane))continue;const o=s.get(e.lane);if(null==o||e.end>o.end?s.set(e.lane,e):e.end<o.end&&i.set(e.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort(((t,e)=>t.end===e.end?t.index-e.index:t.end-e.end))[0]:void 0},this.getMeasurementOptions=R((()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode]),((t,e,i,s,n,o,r)=>(void 0!==this.prevLanes&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMin=null,{count:t,paddingStart:e,scrollMargin:i,getItemKey:s,enabled:n,lanes:o,laneAssignmentMode:r})),{key:!1}),this.getMeasurements=R((()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion]),(({count:t,paddingStart:e,scrollMargin:i,getItemKey:s,enabled:n,lanes:o,laneAssignmentMode:r},l)=>{const a=this.itemSizeCache;if(!n)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const e of this.laneAssignments.keys())e>=t&&this.laneAssignments.delete(e);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach((t=>{this.itemSizeCache.set(t.key,t.size)})));const h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),1===o){const n=this.options.gap,o=2*t;let r,l=this._flatMeasurements;if(!l||l.length<o){const t=new Float64Array(o);l&&h>0&&t.set(l.subarray(0,2*h)),l=t,this._flatMeasurements=l}if(0===h)r=e+i;else{const t=h-1;r=l[2*t]+l[2*t+1]+n}for(let e=h;e<t;e++){const t=s(e),i=a.get(t),o="number"==typeof i?i:this.options.estimateSize(e);l[2*e]=r,l[2*e+1]=o,r+=o+n}const c=function(t,e,i){const s=new Array(t);return new Proxy(s,{get(s,n,o){if("string"==typeof n){const o=n.charCodeAt(0);if(o>=48&&o<=57){const o=+n;if(Number.isInteger(o)&&o>=0&&o<t){let t=s[o];if(!t){const n=e[2*o];t=s[o]={index:o,key:i(o),start:n,size:e[2*o+1],end:n+e[2*o+1],lane:0}}return t}}if("length"===n)return t}return Reflect.get(s,n,o)}})}(t,l,s);return this.measurementsCache=c,c}const c=this.measurementsCache.slice(0,h),d=new Array(o).fill(void 0);for(let t=0;t<h;t++){const e=c[t];e&&(d[e.lane]=t)}for(let n=h;n<t;n++){const t=s(n),o=this.laneAssignments.get(n);let l,h;const u="estimate"===r||a.has(t);if(void 0!==o&&this.options.lanes>1){l=o;const t=d[l],s=void 0!==t?c[t]:void 0;h=s?s.end+this.options.gap:e+i}else{const t=1===this.options.lanes?c[n-1]:this.getFurthestMeasurement(c,n);h=t?t.end+this.options.gap:e+i,l=t?t.lane:n%this.options.lanes,this.options.lanes>1&&u&&this.laneAssignments.set(n,l)}const p=a.get(t),m="number"==typeof p?p:this.options.estimateSize(n),f=h+m;c[n]={index:n,start:h,size:m,end:f,key:t,lane:l},d[l]=n}return this.measurementsCache=c,c}),{key:!1,debug:()=>this.options.debug}),this.calculateRange=R((()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes]),((t,e,i,s)=>this.range=t.length>0&&e>0?function({measurements:t,outerSize:e,scrollOffset:i,lanes:s,flat:n}){const o=t.length-1,r=n?t=>n[2*t]:e=>t[e].start,l=n?t=>n[2*t]+n[2*t+1]:e=>t[e].end;if(t.length<=s)return{startIndex:0,endIndex:o};let a=Y(0,o,r,i),h=a;if(1===s)for(;h<o&&l(h)<i+e;)h++;else if(s>1){const n=Array(s).fill(0);for(;h<o&&n.some((t=>t<i+e));){const e=t[h];n[e.lane]=e.end,h++}const r=Array(s).fill(i+e);for(;a>=0&&r.some((t=>t>=i));){const e=t[a];r[e.lane]=e.start,a--}a=Math.max(0,a-a%s),h=Math.min(o,h+(s-1-h%s))}return{startIndex:a,endIndex:h}}({measurements:t,outerSize:e,scrollOffset:i,lanes:s,flat:1===s&&null!=this._flatMeasurements?this._flatMeasurements:null}):null),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=R((()=>{let t=null,e=null;const i=this.calculateRange();return i&&(t=i.startIndex,e=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,e]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,e]}),((t,e,i,s,n)=>null===s||null===n?[]:t({startIndex:s,endIndex:n,overscan:e,count:i})),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const e=this.options.indexAttribute,i=t.getAttribute(e);return i?parseInt(i,10):(console.warn(`Missing attribute name '${e}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var e;if(!this.scrollState||"smooth"!==this.scrollState.behavior)return!0;const i=this.scrollState.index??(null==(e=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:e.index);if(void 0!==i&&this.range){const e=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),s=Math.max(0,i-e),n=Math.min(this.options.count-1,i+e);return t>=s&&t<=n}return!0},this.measureElement=t=>{if(!t)return void this.elementsCache.forEach(((t,e)=>{t.isConnected||(this.observer.unobserve(t),this.elementsCache.delete(e))}));const e=this.indexFromElement(t),i=this.options.getItemKey(e),s=this.elementsCache.get(i);s!==t&&(s&&this.observer.unobserve(s),this.observer.observe(t),this.elementsCache.set(i,t)),this.isScrolling&&!this.scrollState||!this.shouldMeasureDuringScroll(e)||this.resizeItem(e,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,e)=>{var i,s;if(t<0||t>=this.options.count)return;let n,o,r;const l=this._flatMeasurements;if(1===this.options.lanes&&null!==l)r=this.options.getItemKey(t),o=l[2*t],n=l[2*t+1];else{const e=this.measurementsCache[t];if(!e)return;r=e.key,o=e.start,n=e.size}const a=e-(this.itemSizeCache.get(r)??n);if(0!==a){const l="end"===this.options.anchorTo&&"smooth"!==(null==(i=this.scrollState)?void 0:i.behavior)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=l?this.getTotalSize():0,c="smooth"!==(null==(s=this.scrollState)?void 0:s.behavior)&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:r,start:o,size:n,end:o+n,lane:0},a,this):o<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(r)||"backward"!==this.scrollDirection));(null===this.pendingMin||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(r,e),this.itemSizeCacheVersion++,l?this.applyScrollAdjustment(this.getTotalSize()-h):c&&this.applyScrollAdjustment(a),this.notify(!1)}},this.getVirtualItems=R((()=>[this.getVirtualIndexes(),this.getMeasurements()]),((t,e)=>{const i=[];for(let s=0,n=t.length;s<n;s++){const n=e[t[s]];i.push(n)}return i}),{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const e=this.getMeasurements();if(0===e.length)return;const i=this._flatMeasurements,s=1===this.options.lanes&&null!=i,n=Y(0,e.length-1,s?t=>i[2*t]:t=>F(e[t]).start,t);return F(e[n])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,e,i=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),n=this.getScrollOffset();"auto"===e&&(e=t>=n+s?"end":"start"),"center"===e?t+=(i-s)/2:"end"===e&&(t-=s);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,e="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getSize(),s=this.getScrollOffset(),n=this.measurementsCache[t];if(!n)return;if("auto"===e)if(n.end>=s+i-this.options.scrollPaddingEnd)e="end";else{if(!(n.start<=s+this.options.scrollPaddingStart))return[s,e];e="start"}if("end"===e&&t===this.options.count-1)return[this.getMaxScrollOffset(),e];const o="end"===e?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,e,n.size),e]},this.scrollToOffset=(t,{align:e="start",behavior:i="auto"}={})=>{const s=this.getOffsetForAlignment(t,e),n=this.now();this.scrollState={index:null,align:e,behavior:i,startedAt:n,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:e="auto",behavior:i="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const s=this.getOffsetForIndex(t,e);if(!s)return;const[n,o]=s,r=this.now();this.scrollState={index:t,align:o,behavior:i,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:e="auto"}={})=>{const i=this.getScrollOffset()+t,s=this.now();this.scrollState={index:null,align:"start",behavior:e,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:"end",behavior:t}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const e=this.getMeasurements();let i;if(0===e.length)i=this.options.paddingStart;else if(1===this.options.lanes){const s=e.length-1,n=this._flatMeasurements;i=null!=n?n[2*s]+n[2*s+1]:(null==(t=e[s])?void 0:t.end)??0}else{const t=Array(this.options.lanes).fill(null);let s=e.length-1;for(;s>=0&&t.some((t=>null===t));){const i=e[s];null===t[i.lane]&&(t[i.lane]=i.end),s--}i=Math.max(...t.filter((t=>null!==t)))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(0===this.itemSizeCache.size)return t;const e=this.getMeasurements();for(const i of e)i&&this.itemSizeCache.has(i.key)&&t.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return t},this._scrollToOffset=(t,{adjustments:e,behavior:i})=>{this._intendedScrollOffset=t+(e??0),this.options.scrollToFn(t,{behavior:i,adjustments:e},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,e){0!==t&&(W()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:e}))}scheduleScrollReconcile(){this.targetWindow?null==this.rafId&&(this.rafId=this.targetWindow.requestAnimationFrame((()=>{this.rafId=null,this.reconcileScroll()}))):this.scrollState=null}reconcileScroll(){if(!this.scrollState)return;if(!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3)return void(this.scrollState=null);const t=null!=this.scrollState.index?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,e=t?t[0]:this.scrollState.lastTargetOffset,i=e!==this.scrollState.lastTargetOffset;if(!i&&(s=e,n=this.getScrollOffset(),Math.abs(s-n)<1.01)){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1)return this.getScrollOffset()!==e&&this._scrollToOffset(e,{adjustments:void 0,behavior:"auto"}),void(this.scrollState=null)}else if(this.scrollState.stableFrames=0,i){const t=this.getSize()||600,i=Math.abs(e-this.getScrollOffset()),s="smooth"===this.scrollState.behavior&&i>t;this.scrollState.lastTargetOffset=e,s||(this.scrollState.behavior="auto"),this._scrollToOffset(e,{adjustments:void 0,behavior:s?"smooth":"auto"})}var s,n;this.scheduleScrollReconcile()}}const Y=(t,e,i,s)=>{for(;t<=e;){const n=(t+e)/2|0,o=i(n);if(o<s)t=n+1;else{if(!(o>s))return n;e=n-1}}return t>0?t-1:0};class Z{constructor(t,e){this.cleanup=()=>{};const i={...e,onChange:(t,i)=>{var s;this.host.updateComplete.then((()=>this.host.requestUpdate())),null==(s=e.onChange)||s.call(e,t,i)}};this.virtualizer=new Q(i),(this.host=t).addController(this)}getVirtualizer(){return this.virtualizer}hostConnected(){this.cleanup=this.virtualizer._didMount()}hostUpdated(){this.virtualizer._willUpdate()}hostDisconnected(){this.cleanup()}}class X extends Z{constructor(t,e){super(t,{observeElementRect:K,observeElementOffset:N,scrollToFn:G,...e})}}_.registerIcon(e),_.registerIcon(s),_.registerIcon(n);let tt=1;const et=t=>t?`${t}px`:void 0;function it(t,e){return a(t.cssText.replace(/nord-combobox/g,e))}class st extends(M(D(A(j($(T(h))))))){constructor(){super(...arguments),this.comboboxId=`${this.localName||"nord-combobox"}-${tt++}`,this.inputId=`${this.comboboxId}-input`,this.inputRef=f(),this.formData=new x(this,{value:()=>this.formValue}),this.labelCache=new Map,this.localize=new k(this),this.dismiss=new O(this,{isOpen:()=>this.open,onDismiss:()=>this.hide(),isDismissible:t=>t!==this}),this.stateAttributes=new w(this,(()=>({invalid:this.invalid})),{trackFocus:!0}),this.options=[],this.externalFiltering=!1,this.loading=!1,this.autoHighlight=!1,this.invalid=!1,this.readonly=!1,this.openOnFocus=!0,this.virtualized=!1,this.search="",this.queryDirty=!1,this.activeDescendant=new i(this,{count:()=>this.rowCount,isEnabled:t=>{var e;return!(null===(e=this.filteredOptions[t])||void 0===e?void 0:e.disabled)},optionId:t=>-1!==this.createIndex&&t===this.createIndex?this.createId:this.optionId(t)}),this.startObserver=new z(this,(()=>this.startSlot)),this.endObserver=new z(this,(()=>this.endSlot)),this.scrollActivePending=!1,this.virtualizer=new X(this,{count:0,overscan:st.VIRTUAL_OVERSCAN,estimateSize:()=>{var t;return null!==(t=this.measuredRowSize)&&void 0!==t?t:st.VIRTUAL_ROW_ESTIMATE},getScrollElement:()=>{var t;return null!==(t=this.listboxEl)&&void 0!==t?t:null},getItemKey:t=>{var e,i;return null!==(i=null===(e=this.filteredOptions[t])||void 0===e?void 0:e.value)&&void 0!==i?i:t}}),this.suppressFocusOpen=!1,this.navigated=!1}get ownInvalid(){return this.invalid||super.ownInvalid}get showsQueryInInput(){return this.queryDirty}get displayValue(){return this.showsQueryInInput?this.search:!this.value||Array.isArray(this.value)?"":this.labelFor(this.value)}get inputPlaceholder(){return this.placeholder}get filterQuery(){return this.search}isSelected(t){return this.values.includes(t.value)}get formValue(){const{value:t}=this;return Array.isArray(t)?t.length?t.join(","):void 0:t||void 0}get hasValue(){return this.values.length>0}get createIndex(){return-1}get canCreate(){return!1}renderLeadingControl(){return o}get ariaAutocomplete(){return"list"}selectOption(t){t.disabled||(this.labelCache.set(t.value,t.label),this.value=t.value,this.search="",this.queryDirty=!1,this.commit(),this.hide(),this.suppressFocusOpen=!0,this.focus(),this.suppressFocusOpen=!1)}handleEnter(t){return!1}onKeydown(t){}onBlur(){}afterUpdate(){}onOptionHover(){}onMove(){}get values(){const{value:t}=this;return Array.isArray(t)?t:t?[t]:[]}cacheLabels(t){for(const e of t)e.value&&this.labelCache.set(e.value,e.label);if(this.labelCache.size<=st.labelCacheLimit)return;const e=new Set(this.values);for(const t of this.labelCache.keys()){if(this.labelCache.size<=st.labelCacheLimit)break;e.has(t)||this.labelCache.delete(t)}}get resolvedOptions(){return this.options}get filtered(){const t=this.resolvedOptions,e=this.filterQuery,i=this.externalFiltering,s=this.filteredCache;if(s&&s.options===t&&s.query===e&&s.external===i)return s;s&&s.options===t||this.cacheLabels(t);const n=e.toLocaleLowerCase(),o=i||!e?t:t.filter((t=>t.label.toLocaleLowerCase().includes(n))),r=o.some((t=>t.group)),l=r?Array.from(y(o,"group"),(([,t])=>t)).flat():o;return this.filteredCache={options:t,query:e,external:i,result:l,hasGroups:r,groups:r?y(l,"group"):void 0},this.filteredCache}get filteredOptions(){return this.filtered.result}get rowCount(){return this.filteredOptions.length+(this.canCreate?1:0)}get activeOption(){return this.filteredOptions[this.activeDescendant.activeIndex]}get isVirtual(){if(!this.virtualized)return!1;const{result:t,hasGroups:e}=this.filtered;return t.length>0&&!e}connectedCallback(){var t,e,i;super.connectedCallback(),null!==(t=this.ariaObserver)&&void 0!==t||(this.ariaObserver=new MutationObserver((()=>this.requestUpdate()))),this.ariaObserver.observe(this,{attributes:!0,attributeFilter:["aria-label","aria-labelledby"]}),null!==(e=this.widthObserver)&&void 0!==e||(this.widthObserver=new ResizeObserver((()=>this.syncAnchorInlineSize()))),this.widthObserver.observe(this),this.syncAnchorInlineSize(),null!==(i=this.slotObserver)&&void 0!==i||(this.slotObserver=new MutationObserver((()=>this.requestUpdate()))),this.slotObserver.observe(this,{childList:!0})}disconnectedCallback(){var t,e,i;super.disconnectedCallback(),null===(t=this.ariaObserver)||void 0===t||t.disconnect(),this.ariaObserver=void 0,null===(e=this.widthObserver)||void 0===e||e.disconnect(),this.widthObserver=void 0,null===(i=this.slotObserver)||void 0===i||i.disconnect(),this.slotObserver=void 0}relocateSlots(){if(r)return;const t=(t,e)=>{if(e)for(const i of Array.from(this.children))i.getAttribute("slot")===t&&i.parentElement!==e&&e.appendChild(i)};t("start",this.startSlot),t("end",this.endSlot)}syncAnchorInlineSize(){const t=this.offsetWidth;t&&this.style.setProperty("--_n-combobox-anchor-inline-size",`${t}px`)}createRenderRoot(){if(r)return this;const t=document.createElement("div");return t.className="n-render-root",this.appendChild(t),t}show(){if(this.open||this.disabled||this.readonly)return;this.dispatchEvent(new E("open",{cancelable:!0}))&&(this.open=!0)}hide(){this.open&&(this.open=!1,this.onHide(),this.dispatchEvent(new E("close")))}onHide(){this.search="",this.queryDirty=!1}focus(t){var e;null===(e=this.inputRef.value)||void 0===e||e.focus(t)}handleOpenChange(){var t,e;this.open?(null===(t=this.popout)||void 0===t||t.show(),this.resetActiveIndex()):null===(e=this.popout)||void 0===e||e.hide(!1)}handleDisabledChange(){this.disabled&&this.open&&this.hide()}resetRowSample(){this.measuredRowSize=void 0}updated(t){super.updated(t),this.relocateSlots(),this.afterUpdate(),this.sampleRowSize(),this.scrollActivePending&&(this.scrollActivePending=!1,this.scrollActiveIntoView())}willUpdate(t){if(super.willUpdate(t),this.isVirtual){const t=this.virtualizer.getVirtualizer(),e=this.filteredOptions.length;t.options.count!==e&&t.setOptions({...t.options,count:e})}}scrollActiveIntoView(){var t;const e=this.listboxEl;if(!e)return;const i=this.activeDescendant.activeIndex;this.isVirtual&&i>=0&&i!==this.createIndex?this.virtualizer.getVirtualizer().scrollToIndex(i,{align:"auto"}):null===(t=e.querySelector(".n-option.is-active"))||void 0===t||t.scrollIntoView({block:"nearest"})}handlePopoutClose(t){t.stopPropagation(),this.open&&this.hide()}handlePopoutOpen(t){t.stopPropagation()}resetActiveIndex(){this.autoHighlight?this.activeDescendant.setActiveIndex(this.activeDescendant.nextEnabledIndex(0,1)):-1!==this.createIndex&&this.filteredOptions.every((t=>t.disabled))?this.activeDescendant.setActiveIndex(this.createIndex):this.activeDescendant.reset(),this.navigated=!1,this.scrollActivePending=!0}handleInput(t){if(t.stopPropagation(),this.readonly)return;const e=t.target;this.search=e.value,this.queryDirty=!0,this.open||this.show(),this.dispatchEvent(new E("input")),this.onInput(e)}onInput(t){}handleFocus(){!this.suppressFocusOpen&&this.openOnFocus&&this.show()}handleBlur(){this.onBlur()}handleKeydown(t){if(!this.readonly)switch(this.onKeydown(t),t.key){case"ArrowDown":if(t.preventDefault(),!this.open)return void this.show();this.move(1);break;case"ArrowUp":if(t.preventDefault(),!this.open)return void this.show();this.move(-1);break;case"End":this.open&&(t.preventDefault(),this.activeDescendant.last()&&(this.navigated=!0,this.scrollActivePending=!0));break;case"Home":this.open&&(t.preventDefault(),this.activeDescendant.first()&&(this.navigated=!0,this.scrollActivePending=!0));break;case"Enter":if(!this.open)break;if(this.handleEnter(t))break;if(-1!==this.createIndex&&this.activeDescendant.activeIndex===this.createIndex){t.preventDefault(),this.emitCreate();break}(this.navigated||this.autoHighlight)&&this.activeOption&&(t.preventDefault(),this.selectOption(this.activeOption));break;case"Escape":this.open&&(t.preventDefault(),this.hide());break;default:this.onUnhandledKeydown(t)}}onUnhandledKeydown(t){}emitCreate(){}move(t){0!==this.rowCount&&(this.onMove(),this.activeDescendant.move(t)&&(this.navigated=!0,this.scrollActivePending=!0))}commit(){this.requestUpdate(),this.dispatchEvent(new E("change"))}labelFor(t){var e,i;const s=this.resolvedOptions.find((e=>e.value===t));return null!==(i=null!==(e=null==s?void 0:s.label)&&void 0!==e?e:this.labelCache.get(t))&&void 0!==i?i:t}render(){const{result:t,hasGroups:e,groups:i}=this.filtered,s=this.virtualized&&!e&&t.length>0,n=s?this.virtualizer.getVirtualizer().getVirtualItems():void 0,r=e?new Map(t.map(((t,e)=>[t.value,e]))):void 0,a=this.activeDescendant.activeIndex,h=this.activeOption,c=!n||a===this.createIndex||n.some((t=>t.index===a)),d=-1!==this.createIndex&&a===this.createIndex?`${this.comboboxId}-create`:h&&c?this.optionId(a):void 0,u=`${this.comboboxId}-list`,f=`${this.comboboxId}-anchor`,S=this.showClear,y=this.controlAriaLabel,x=this.controlAriaLabelledby,O=this.controlAriaDescribedby,z=l`<input ${v(this.inputRef)} class="n-input" type="text" id="${this.comboboxId}-input" role="combobox" .value="${this.displayValue}" placeholder="${m(this.inputPlaceholder)}" ?disabled="${this.effectiveDisabled}" ?readonly="${this.readonly}" ?required="${this.required}" autocomplete="off" autocapitalize="off" spellcheck="false" aria-label="${m(y)}" aria-labelledby="${m(x)}" aria-describedby="${m(O)}" aria-autocomplete="${this.ariaAutocomplete}" aria-haspopup="listbox" aria-controls="${u}" aria-expanded="${this.open?"true":"false"}" aria-activedescendant="${m(this.open?d:void 0)}" aria-invalid="${m(this.controlAriaInvalid)}" @input="${this.handleInput}" @focus="${this.handleFocus}" @blur="${this.handleBlur}" @keydown="${this.handleKeydown}">`,w=this.renderLeadingControl();return l`${this.renderLabel()}<div class="n-combobox" id="${f}"><div class="${p({"n-control":!0,"is-invalid":this.effectiveInvalid})}" style="${b({"--_n-combobox-start-inline-size":et(this.startObserver.inlineSize),"--_n-combobox-end-inline-size":et(this.endObserver.inlineSize)})}" @click="${this.handleControlClick}"><span class="n-slot n-slot-start"></span> ${w===o?z:l`<div class="n-tags">${w}${z}</div>`} <span class="n-slot n-slot-end"></span> ${this.loading?l`<nord-spinner class="n-loading" size="s"></nord-spinner>`:o} ${S?l`<button class="n-clear" type="button" aria-label="${this.localize.term("clearLabel")}" ?disabled="${this.disabled||this.readonly}" @click="${this.handleClearClick}"><nord-icon name="interface-close-small"></nord-icon></button> ${this.showToggle?l`<span class="n-divider" aria-hidden="true"></span>`:o}`:o} ${this.showToggle?l`<button class="n-toggle" type="button" tabindex="-1" aria-hidden="true" ?disabled="${this.disabled||this.readonly}" @click="${this.handleToggleClick}"><nord-icon name="interface-dropdown-small"></nord-icon></button>`:o}</div><nord-popout id="${this.comboboxId}-popout" anchor="${f}" align="${m(this.align)}" position="${m(this.position)}" always-floating @open="${this.handlePopoutOpen}" @close="${this.handlePopoutClose}"><div id="${u}" class="n-listbox" role="${m(this.rowCount?"listbox":void 0)}" aria-label="${m(this.rowCount?y:void 0)}" aria-labelledby="${m(this.rowCount?x:void 0)}" aria-multiselectable="${m(this.rowCount?this.ariaMultiselectable:void 0)}">${0!==t.length||this.canCreate?e&&i&&r?Array.from(i,(([t,e])=>this.renderGroup(t,e,r))):s&&n?this.renderVirtualOptions(t,n):g(t,(t=>t.value),((t,e)=>this.renderListOption(t,e))):this.renderEmpty()} ${this.canCreate?this.renderCreate():o}</div></nord-popout></div>${this.renderError()} ${this.isHintBelow?this.renderHint():o}`}get showClear(){return!1}get showToggle(){return!0}get ariaMultiselectable(){return"false"}renderGroup(t,e,i){const s=`${this.comboboxId}-group-${t}`;return l`<div role="group" aria-labelledby="${C(t,s)}">${t?l`<div class="n-group-label" role="presentation" id="${s}">${t}</div>`:o} ${g(e,(t=>t.value),(t=>{var e;return this.renderListOption(t,null!==(e=i.get(t.value))&&void 0!==e?e:0)}))}</div>`}optionContent(t){return this.renderOption?this.renderOption(t):t.html?S(t.html):t.label}sampleRowSize(){var t;if(!this.isVirtual||void 0!==this.measuredRowSize)return;const e=null===(t=this.listboxEl)||void 0===t?void 0:t.querySelector(".n-virtual-row .n-option"),i=null==e?void 0:e.getBoundingClientRect().height;i&&i>0&&(this.measuredRowSize=i,this.virtualizer.getVirtualizer().measure())}renderVirtualOptions(t,e){const i=t.length,s=this.virtualizer.getVirtualizer().getTotalSize(),n=void 0!==this.measuredRowSize;return l`<div class="n-virtual-sizer" style="block-size:${s}">${g(e,(t=>t.key),(e=>l`<div class="n-virtual-row" data-index="${e.index}" style="${n?`block-size:${e.size}px; transform: translateY(${e.start}px)`:`transform: translateY(${e.start}px)`}">${this.renderListOption(t[e.index],e.index,i)}</div>`))}</div>`}renderListOption(t,e,i){const s=this.isSelected(t);return l`<div id="${this.optionId(e)}" class="${p({"n-option":!0,"is-active":e===this.activeDescendant.activeIndex,"is-disabled":Boolean(t.disabled)})}" role="option" aria-selected="${this.optionAriaSelected(s)}" aria-disabled="${t.disabled?"true":o}" aria-setsize="${m(i)}" aria-posinset="${m(void 0===i?void 0:e+1)}" @click="${()=>this.selectOption(t)}" @mousemove="${()=>this.handleOptionHover(e)}">${this.rendersCheck?l`<span class="n-option-check">${this.showCheck(s)?l`<nord-icon name="interface-checked" size="s"></nord-icon>`:o}</span>`:o} <span class="n-option-label">${this.optionContent(t)}</span></div>`}optionAriaSelected(t){return t?"true":"false"}showCheck(t){return t}get rendersCheck(){return!0}renderCreate(){return o}renderEmpty(){return this.loading?l`<div class="n-empty" role="status"><nord-spinner size="s"></nord-spinner></div>`:l`<div class="n-empty" role="status">${this.noResultsText||this.localize.term("noResults")}</div>`}optionId(t){return`${this.comboboxId}-option-${t}`}get createId(){return`${this.comboboxId}-create`}handleOptionHover(t){this.onOptionHover(),this.activeDescendant.setActiveIndex(t)}handleControlClick(){this.disabled||(!this.open&&this.openOnFocus&&this.show(),this.focus())}handleClearClick(t){t.stopPropagation(),this.disabled||this.readonly||this.clear()}clear(){}handleToggleClick(t){t.stopPropagation(),this.disabled||this.readonly||(this.open?this.hide():this.show(),this.focus())}}st.VIRTUAL_ROW_ESTIMATE=36,st.VIRTUAL_OVERSCAN=6,st.labelCacheLimit=500,t([c("nord-popout",!0)],st.prototype,"popout",void 0),t([d({attribute:!1})],st.prototype,"options",void 0),t([d({reflect:!0})],st.prototype,"placeholder",void 0),t([d({reflect:!0,type:Boolean,attribute:"external-filtering"})],st.prototype,"externalFiltering",void 0),t([d({reflect:!0,type:Boolean})],st.prototype,"loading",void 0),t([d({reflect:!0,type:Boolean,attribute:"auto-highlight"})],st.prototype,"autoHighlight",void 0),t([d({reflect:!0,type:Boolean})],st.prototype,"invalid",void 0),t([d({reflect:!0,type:Boolean})],st.prototype,"readonly",void 0),t([d({reflect:!0,type:Boolean,attribute:"open-on-focus"})],st.prototype,"openOnFocus",void 0),t([d({reflect:!0,attribute:"no-results-text"})],st.prototype,"noResultsText",void 0),t([d({reflect:!0,type:Boolean})],st.prototype,"virtualized",void 0),t([d({attribute:!1})],st.prototype,"renderOption",void 0),t([u()],st.prototype,"search",void 0),t([u()],st.prototype,"queryDirty",void 0),t([c(".n-listbox")],st.prototype,"listboxEl",void 0),t([c(".n-slot-start")],st.prototype,"startSlot",void 0),t([c(".n-slot-end")],st.prototype,"endSlot",void 0),t([I("open","updated")],st.prototype,"handleOpenChange",null),t([I("disabled")],st.prototype,"handleDisabledChange",null),t([I("size")],st.prototype,"resetRowSample",null),t([I("search")],st.prototype,"resetActiveIndex",null);export{st as default,it as retagComboboxStyles};
|
|
1
|
+
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{c as e,A as i}from"./ActiveDescendantController-BnMqM79O.js";import{c as s}from"./interface-close-small-CnpAFMO3.js";import{d as n}from"./interface-dropdown-small-CYvgxudU.js";import{nothing as o,isServer as r,html as l,unsafeCSS as a,LitElement as h}from"lit";import{query as c,property as d,state as u}from"lit/decorators.js";import{classMap as p}from"lit/directives/class-map.js";import{ifDefined as m}from"lit/directives/if-defined.js";import{createRef as f,ref as v}from"lit/directives/ref.js";import{repeat as g}from"lit/directives/repeat.js";import{styleMap as b}from"lit/directives/style-map.js";import{unsafeHTML as S}from"lit/directives/unsafe-html.js";import{g as y}from"./collection-Dvg2XbxV.js";import{F as x}from"./FormDataController-OUt5L5uC.js";import{L as O}from"./LightDismissController-wcL1ziJa.js";import{R as z}from"./ResizeController-14PUwRQy.js";import{S as I}from"./StateAttributesController-BIh96sXZ.js";import{o as w}from"./observe-D0n0zOfU.js";import{c as C}from"./cond-CI1KbneT.js";import{N as E}from"./events-Bv6wNHwJ.js";import{A}from"./AutocompleteMixin-D8eiOxvO.js";import{D as M}from"./DraftComponentMixin-4qug5Rky.js";import{F as j}from"./FieldControlMixin-BXNZJXu9.js";import{F as T}from"./Popout-B6Hirj3y.js";import{I as $}from"./InputMixin-LetXsCyv.js";import{S as k}from"./SizeMixin-CU9cLbLC.js";import D from"./Icon.js";import{LocalizeController as _}from"./LocalizeController.js";import"./Spinner.js";import"./number-Dg2vCfGd.js";import"./EventController-BBOmvfLa.js";import"./ShortcutController-CV5b0BZl.js";import"./tinykeys-DwvDXsEb.js";import"./context-consumer-BJVUulGf.js";import"./context-request-event-CCRlXoeR.js";import"./field-context.js";import"./create-context-CJ69ntlY.js";import"./SlotController-Z6eG7LSZ.js";import"./light-dom-styles-DXsbiKU9.js";import"./VisuallyHidden.js";import"./positioning-D-K8Mueq.js";import"./DirectionController-ChvNGESZ.js";import"./ScrollbarController-BFC67Y2x.js";import"./Component-BJ5O5n8k.js";import"./IconManager.js";import"./translation.js";import"./en-us.js";import"./localization.js";import"./localization2.js";import"./localization3.js";import"./localization4.js";import"./localization5.js";import"./localization6.js";import"./localization7.js";import"./localization8.js";import"./localization9.js";import"./localization10.js";import"./localization11.js";import"./localization12.js";import"./localization13.js";import"./localization14.js";import"./localization15.js";import"./localization16.js";import"./localization17.js";import"./localization18.js";import"./localization19.js";import"./localization20.js";import"./localization21.js";import"./localization22.js";import"./localization23.js";import"./localization24.js";function R(t,e,i){let s,n=i.initialDeps??[],o=!0;function r(){const r=t();return r.length!==n.length||r.some(((t,e)=>n[e]!==t))?(n=r,s=e(...r),!(null==i?void 0:i.onChange)||o&&i.skipInitialOnChange||i.onChange(s),o=!1,s):s}return r.updateDeps=t=>{n=t},r}function F(t,e){if(void 0===t)throw new Error("Unexpected undefined");return t}const V=(t,e,i)=>{let s;return function(...n){t.clearTimeout(s),s=t.setTimeout((()=>e.apply(this,n)),i)}};let L;const W=()=>{if(void 0!==L)return L;if("undefined"==typeof navigator)return L=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return L=!0;const t=navigator.maxTouchPoints;return L="MacIntel"===navigator.platform&&void 0!==t&&t>0},P=t=>{const{offsetWidth:e,offsetHeight:i}=t;return{width:e,height:i}},q=t=>t,H=t=>{const e=Math.max(t.startIndex-t.overscan,0),i=Math.min(t.endIndex+t.overscan,t.count-1)-e+1,s=new Array(i);for(let t=0;t<i;t++)s[t]=e+t;return s},K=(t,e)=>{const i=t.scrollElement;if(!i)return;const s=t.targetWindow;if(!s)return;const n=t=>{const{width:i,height:s}=t;e({width:Math.round(i),height:Math.round(s)})};if(n(P(i)),!s.ResizeObserver)return()=>{};const o=new s.ResizeObserver((e=>{const s=()=>{const t=e[0];if(null==t?void 0:t.borderBoxSize){const e=t.borderBoxSize[0];if(e)return void n({width:e.inlineSize,height:e.blockSize})}n(P(i))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()}));return o.observe(i,{box:"border-box"}),()=>{o.unobserve(i)}},B={passive:!0},U="undefined"==typeof window||"onscrollend"in window,N=(t,e)=>((t,e,i)=>{const s=t.scrollElement;if(!s)return;const n=t.targetWindow;if(!n)return;const o=t.options.useScrollendEvent&&U;let r=0;const l=o?null:V(n,(()=>e(r,!1)),t.options.isScrollingResetDelay),a=t=>()=>{r=i(s),null==l||l(),e(r,t)},h=a(!0),c=a(!1);return s.addEventListener("scroll",h,B),o&&s.addEventListener("scrollend",c,B),()=>{s.removeEventListener("scroll",h),o&&s.removeEventListener("scrollend",c)}})(t,e,(e=>{const{horizontal:i,isRtl:s}=t.options;return i?e.scrollLeft*(s?-1:1):e.scrollTop})),J=(t,e,i)=>{if(i.options.useCachedMeasurements){const e=i.indexFromElement(t),s=i.options.getItemKey(e);return i.itemSizeCache.get(s)??i.options.estimateSize(e)}if(null==e?void 0:e.borderBoxSize){const t=e.borderBoxSize[0];if(t){return Math.round(t[i.options.horizontal?"inlineSize":"blockSize"])}}if(!e){const e=i.indexFromElement(t),s=i.options.getItemKey(e),n=i.itemSizeCache.get(s);if(void 0!==n)return n}return t[i.options.horizontal?"offsetWidth":"offsetHeight"]},G=(t,{adjustments:e=0,behavior:i},s)=>{var n,o;null==(o=null==(n=s.scrollElement)?void 0:n.scrollTo)||o.call(n,{[s.options.horizontal?"left":"top"]:t+e,behavior:i})};class Q{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,e,i;return(null==(i=null==(e=null==(t=this.targetWindow)?void 0:t.performance)?void 0:e.now)?void 0:i.call(e))??Date.now()},this.observer=(()=>{let t=null;const e=()=>t||(this.targetWindow&&this.targetWindow.ResizeObserver?t=new this.targetWindow.ResizeObserver((t=>{t.forEach((t=>{const e=()=>{const e=t.target,i=this.indexFromElement(e);if(e.isConnected)this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(e,t,this));else{this.observer.unobserve(e);for(const[t,i]of this.elementsCache)if(i===e){this.elementsCache.delete(t);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(e):e()}))})):null);return{disconnect:()=>{var i;null==(i=e())||i.disconnect(),t=null},observe:t=>{var i;return null==(i=e())?void 0:i.observe(t,{box:"border-box"})},unobserve:t=>{var i;return null==(i=e())?void 0:i.unobserve(t)}}})(),this.range=null,this.setOptions=t=>{var e,i;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:q,rangeExtractor:H,onChange:()=>{},measureElement:J,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const e in t){const i=t[e];void 0!==i&&(s[e]=i)}const n=this.options;let o=null,r=null,l=!1;if(void 0!==n&&n.enabled&&s.enabled&&"end"===s.anchorTo&&null!==this.scrollElement){const t=n.count,a=s.count,h=this.getMeasurements(),c=t>0?(null==(e=h[0])?void 0:e.key)??n.getItemKey(0):null,d=t>0?(null==(i=h[t-1])?void 0:i.key)??n.getItemKey(t-1):null;if(a!==t||t>0&&a>0&&(s.getItemKey(0)!==c||s.getItemKey(a-1)!==d)){l=!0;const e=t>0?this.getVirtualItemForOffset(this.getScrollOffset())??h[0]:null;e&&(o=[e.key,this.getScrollOffset()-e.start]);const i=!0===s.followOnAppend?"auto":s.followOnAppend||null;i&&a>t&&this.isAtEnd(n.scrollEndThreshold)&&(0===t||s.getItemKey(a-1)!==d)&&(r=i)}}this.options=s,l&&(this.pendingMin=0,this.itemSizeCacheVersion++);let a=!1,h=0;if(o&&null!==this.scrollOffset){const[t,e]=o,i=this.getMeasurements(),{count:s,getItemKey:n}=this.options;let r=0;for(;r<s&&n(r)!==t;)r++;if(r<s){const t=i[r];if(t){const i=t.start+e;i!==this.scrollOffset&&(h=i-this.scrollOffset,this.scrollOffset=i,a=!0)}}}(a||r)&&(this.pendingScrollAnchor=[a?o[0]:null,a?o[1]:0,r,h])},this.notify=t=>{var e,i;null==(i=(e=this.options).onChange)||i.call(e,this,t)},this.maybeNotify=R((()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null])),(t=>{this.notify(t)}),{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach((t=>t())),this.unsubs=[],this.observer.disconnect(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e)return void this.maybeNotify();if(this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(t=this.scrollElement)?void 0:t.window)??null,this.elementsCache.forEach((t=>{this.observer.observe(t)})),this.unsubs.push(this.options.observeElementRect(this,(t=>{this.scrollRect=t,this.maybeNotify()}))),this.unsubs.push(this.options.observeElementOffset(this,((t,e)=>{null!==this._intendedScrollOffset&&Math.abs(t-this._intendedScrollOffset)<1.5&&(t=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=e?this.getScrollOffset()<t?"forward":"backward":null,this.scrollOffset=t,this.isScrolling=e,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()}))),"addEventListener"in this.scrollElement){const t=this.scrollElement,e=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},i=()=>{this._iosTouching=!1,W()&&null!=this.targetWindow&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout((()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()}),150))};t.addEventListener("touchstart",e,B),t.addEventListener("touchend",i,B),this.unsubs.push((()=>{t.removeEventListener("touchstart",e),t.removeEventListener("touchend",i),null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)}))}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[t,e,s,n]=i;null===t||s||(W()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?0!==n&&(this._iosDeferredAdjustment+=n):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),s&&this.scrollToEnd({behavior:s})}},this._flushIosDeferredIfReady=()=>{if(0===this._iosDeferredAdjustment)return;if(this.isScrolling)return;if(this._iosTouching)return;if(this._iosJustTouchEnded)return;const t=this.getScrollOffset(),e=this.getMaxScrollOffset();if(t<0||t>e)return;const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,e)=>{const i=new Map,s=new Map;for(let n=e-1;n>=0;n--){const e=t[n];if(i.has(e.lane))continue;const o=s.get(e.lane);if(null==o||e.end>o.end?s.set(e.lane,e):e.end<o.end&&i.set(e.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort(((t,e)=>t.end===e.end?t.index-e.index:t.end-e.end))[0]:void 0},this.getMeasurementOptions=R((()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode]),((t,e,i,s,n,o,r)=>(void 0!==this.prevLanes&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMin=null,{count:t,paddingStart:e,scrollMargin:i,getItemKey:s,enabled:n,lanes:o,laneAssignmentMode:r})),{key:!1}),this.getMeasurements=R((()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion]),(({count:t,paddingStart:e,scrollMargin:i,getItemKey:s,enabled:n,lanes:o,laneAssignmentMode:r},l)=>{const a=this.itemSizeCache;if(!n)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const e of this.laneAssignments.keys())e>=t&&this.laneAssignments.delete(e);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach((t=>{this.itemSizeCache.set(t.key,t.size)})));const h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),1===o){const n=this.options.gap,o=2*t;let r,l=this._flatMeasurements;if(!l||l.length<o){const t=new Float64Array(o);l&&h>0&&t.set(l.subarray(0,2*h)),l=t,this._flatMeasurements=l}if(0===h)r=e+i;else{const t=h-1;r=l[2*t]+l[2*t+1]+n}for(let e=h;e<t;e++){const t=s(e),i=a.get(t),o="number"==typeof i?i:this.options.estimateSize(e);l[2*e]=r,l[2*e+1]=o,r+=o+n}const c=function(t,e,i){const s=new Array(t);return new Proxy(s,{get(s,n,o){if("string"==typeof n){const o=n.charCodeAt(0);if(o>=48&&o<=57){const o=+n;if(Number.isInteger(o)&&o>=0&&o<t){let t=s[o];if(!t){const n=e[2*o];t=s[o]={index:o,key:i(o),start:n,size:e[2*o+1],end:n+e[2*o+1],lane:0}}return t}}if("length"===n)return t}return Reflect.get(s,n,o)}})}(t,l,s);return this.measurementsCache=c,c}const c=this.measurementsCache.slice(0,h),d=new Array(o).fill(void 0);for(let t=0;t<h;t++){const e=c[t];e&&(d[e.lane]=t)}for(let n=h;n<t;n++){const t=s(n),o=this.laneAssignments.get(n);let l,h;const u="estimate"===r||a.has(t);if(void 0!==o&&this.options.lanes>1){l=o;const t=d[l],s=void 0!==t?c[t]:void 0;h=s?s.end+this.options.gap:e+i}else{const t=1===this.options.lanes?c[n-1]:this.getFurthestMeasurement(c,n);h=t?t.end+this.options.gap:e+i,l=t?t.lane:n%this.options.lanes,this.options.lanes>1&&u&&this.laneAssignments.set(n,l)}const p=a.get(t),m="number"==typeof p?p:this.options.estimateSize(n),f=h+m;c[n]={index:n,start:h,size:m,end:f,key:t,lane:l},d[l]=n}return this.measurementsCache=c,c}),{key:!1,debug:()=>this.options.debug}),this.calculateRange=R((()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes]),((t,e,i,s)=>this.range=t.length>0&&e>0?function({measurements:t,outerSize:e,scrollOffset:i,lanes:s,flat:n}){const o=t.length-1,r=n?t=>n[2*t]:e=>t[e].start,l=n?t=>n[2*t]+n[2*t+1]:e=>t[e].end;if(t.length<=s)return{startIndex:0,endIndex:o};let a=Y(0,o,r,i),h=a;if(1===s)for(;h<o&&l(h)<i+e;)h++;else if(s>1){const n=Array(s).fill(0);for(;h<o&&n.some((t=>t<i+e));){const e=t[h];n[e.lane]=e.end,h++}const r=Array(s).fill(i+e);for(;a>=0&&r.some((t=>t>=i));){const e=t[a];r[e.lane]=e.start,a--}a=Math.max(0,a-a%s),h=Math.min(o,h+(s-1-h%s))}return{startIndex:a,endIndex:h}}({measurements:t,outerSize:e,scrollOffset:i,lanes:s,flat:1===s&&null!=this._flatMeasurements?this._flatMeasurements:null}):null),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=R((()=>{let t=null,e=null;const i=this.calculateRange();return i&&(t=i.startIndex,e=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,e]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,e]}),((t,e,i,s,n)=>null===s||null===n?[]:t({startIndex:s,endIndex:n,overscan:e,count:i})),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const e=this.options.indexAttribute,i=t.getAttribute(e);return i?parseInt(i,10):(console.warn(`Missing attribute name '${e}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var e;if(!this.scrollState||"smooth"!==this.scrollState.behavior)return!0;const i=this.scrollState.index??(null==(e=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:e.index);if(void 0!==i&&this.range){const e=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),s=Math.max(0,i-e),n=Math.min(this.options.count-1,i+e);return t>=s&&t<=n}return!0},this.measureElement=t=>{if(!t)return void this.elementsCache.forEach(((t,e)=>{t.isConnected||(this.observer.unobserve(t),this.elementsCache.delete(e))}));const e=this.indexFromElement(t),i=this.options.getItemKey(e),s=this.elementsCache.get(i);s!==t&&(s&&this.observer.unobserve(s),this.observer.observe(t),this.elementsCache.set(i,t)),this.isScrolling&&!this.scrollState||!this.shouldMeasureDuringScroll(e)||this.resizeItem(e,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,e)=>{var i,s;if(t<0||t>=this.options.count)return;let n,o,r;const l=this._flatMeasurements;if(1===this.options.lanes&&null!==l)r=this.options.getItemKey(t),o=l[2*t],n=l[2*t+1];else{const e=this.measurementsCache[t];if(!e)return;r=e.key,o=e.start,n=e.size}const a=e-(this.itemSizeCache.get(r)??n);if(0!==a){const l="end"===this.options.anchorTo&&"smooth"!==(null==(i=this.scrollState)?void 0:i.behavior)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=l?this.getTotalSize():0,c="smooth"!==(null==(s=this.scrollState)?void 0:s.behavior)&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:r,start:o,size:n,end:o+n,lane:0},a,this):o<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(r)||"backward"!==this.scrollDirection));(null===this.pendingMin||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(r,e),this.itemSizeCacheVersion++,l?this.applyScrollAdjustment(this.getTotalSize()-h):c&&this.applyScrollAdjustment(a),this.notify(!1)}},this.getVirtualItems=R((()=>[this.getVirtualIndexes(),this.getMeasurements()]),((t,e)=>{const i=[];for(let s=0,n=t.length;s<n;s++){const n=e[t[s]];i.push(n)}return i}),{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const e=this.getMeasurements();if(0===e.length)return;const i=this._flatMeasurements,s=1===this.options.lanes&&null!=i,n=Y(0,e.length-1,s?t=>i[2*t]:t=>F(e[t]).start,t);return F(e[n])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,e,i=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),n=this.getScrollOffset();"auto"===e&&(e=t>=n+s?"end":"start"),"center"===e?t+=(i-s)/2:"end"===e&&(t-=s);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,e="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getSize(),s=this.getScrollOffset(),n=this.measurementsCache[t];if(!n)return;if("auto"===e)if(n.end>=s+i-this.options.scrollPaddingEnd)e="end";else{if(!(n.start<=s+this.options.scrollPaddingStart))return[s,e];e="start"}if("end"===e&&t===this.options.count-1)return[this.getMaxScrollOffset(),e];const o="end"===e?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,e,n.size),e]},this.scrollToOffset=(t,{align:e="start",behavior:i="auto"}={})=>{const s=this.getOffsetForAlignment(t,e),n=this.now();this.scrollState={index:null,align:e,behavior:i,startedAt:n,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:e="auto",behavior:i="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const s=this.getOffsetForIndex(t,e);if(!s)return;const[n,o]=s,r=this.now();this.scrollState={index:t,align:o,behavior:i,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:e="auto"}={})=>{const i=this.getScrollOffset()+t,s=this.now();this.scrollState={index:null,align:"start",behavior:e,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:"end",behavior:t}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const e=this.getMeasurements();let i;if(0===e.length)i=this.options.paddingStart;else if(1===this.options.lanes){const s=e.length-1,n=this._flatMeasurements;i=null!=n?n[2*s]+n[2*s+1]:(null==(t=e[s])?void 0:t.end)??0}else{const t=Array(this.options.lanes).fill(null);let s=e.length-1;for(;s>=0&&t.some((t=>null===t));){const i=e[s];null===t[i.lane]&&(t[i.lane]=i.end),s--}i=Math.max(...t.filter((t=>null!==t)))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(0===this.itemSizeCache.size)return t;const e=this.getMeasurements();for(const i of e)i&&this.itemSizeCache.has(i.key)&&t.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return t},this._scrollToOffset=(t,{adjustments:e,behavior:i})=>{this._intendedScrollOffset=t+(e??0),this.options.scrollToFn(t,{behavior:i,adjustments:e},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,e){0!==t&&(W()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:e}))}scheduleScrollReconcile(){this.targetWindow?null==this.rafId&&(this.rafId=this.targetWindow.requestAnimationFrame((()=>{this.rafId=null,this.reconcileScroll()}))):this.scrollState=null}reconcileScroll(){if(!this.scrollState)return;if(!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3)return void(this.scrollState=null);const t=null!=this.scrollState.index?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,e=t?t[0]:this.scrollState.lastTargetOffset,i=e!==this.scrollState.lastTargetOffset;if(!i&&(s=e,n=this.getScrollOffset(),Math.abs(s-n)<1.01)){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1)return this.getScrollOffset()!==e&&this._scrollToOffset(e,{adjustments:void 0,behavior:"auto"}),void(this.scrollState=null)}else if(this.scrollState.stableFrames=0,i){const t=this.getSize()||600,i=Math.abs(e-this.getScrollOffset()),s="smooth"===this.scrollState.behavior&&i>t;this.scrollState.lastTargetOffset=e,s||(this.scrollState.behavior="auto"),this._scrollToOffset(e,{adjustments:void 0,behavior:s?"smooth":"auto"})}var s,n;this.scheduleScrollReconcile()}}const Y=(t,e,i,s)=>{for(;t<=e;){const n=(t+e)/2|0,o=i(n);if(o<s)t=n+1;else{if(!(o>s))return n;e=n-1}}return t>0?t-1:0};class Z{constructor(t,e){this.cleanup=()=>{};const i={...e,onChange:(t,i)=>{var s;this.host.updateComplete.then((()=>this.host.requestUpdate())),null==(s=e.onChange)||s.call(e,t,i)}};this.virtualizer=new Q(i),(this.host=t).addController(this)}getVirtualizer(){return this.virtualizer}hostConnected(){this.cleanup=this.virtualizer._didMount()}hostUpdated(){this.virtualizer._willUpdate()}hostDisconnected(){this.cleanup()}}class X extends Z{constructor(t,e){super(t,{observeElementRect:K,observeElementOffset:N,scrollToFn:G,...e})}}D.registerIcon(e),D.registerIcon(s),D.registerIcon(n);let tt=1;const et=t=>t?`${t}px`:void 0;function it(t,e){return a(t.cssText.replace(/nord-combobox/g,e))}class st extends(M(k(A(j($(T(h))))))){constructor(){super(...arguments),this.comboboxId=`${this.localName||"nord-combobox"}-${tt++}`,this.inputId=`${this.comboboxId}-input`,this.inputRef=f(),this.formData=new x(this,{value:()=>this.formValue}),this.labelCache=new Map,this.localize=new _(this),this.dismiss=new O(this,{isOpen:()=>this.open,onDismiss:()=>this.hide(),isDismissible:t=>t!==this}),this.stateAttributes=new I(this,(()=>({invalid:this.invalid})),{trackFocus:!0}),this.options=[],this.externalFiltering=!1,this.loading=!1,this.autoHighlight=!1,this.invalid=!1,this.readonly=!1,this.openOnInputClick=!0,this.virtualized=!1,this.search="",this.queryDirty=!1,this.activeDescendant=new i(this,{count:()=>this.rowCount,isEnabled:t=>{var e;return!(null===(e=this.filteredOptions[t])||void 0===e?void 0:e.disabled)},optionId:t=>-1!==this.createIndex&&t===this.createIndex?this.createId:this.optionId(t)}),this.startObserver=new z(this,(()=>this.startSlot)),this.endObserver=new z(this,(()=>this.endSlot)),this.scrollActivePending=!1,this.virtualizer=new X(this,{count:0,overscan:st.VIRTUAL_OVERSCAN,estimateSize:()=>{var t;return null!==(t=this.measuredRowSize)&&void 0!==t?t:st.VIRTUAL_ROW_ESTIMATE},getScrollElement:()=>{var t;return null!==(t=this.listboxEl)&&void 0!==t?t:null},getItemKey:t=>{var e,i;return null!==(i=null===(e=this.filteredOptions[t])||void 0===e?void 0:e.value)&&void 0!==i?i:t}}),this.navigated=!1}get ownInvalid(){return this.invalid||super.ownInvalid}get showsQueryInInput(){return this.queryDirty}get displayValue(){return this.showsQueryInInput?this.search:!this.value||Array.isArray(this.value)?"":this.labelFor(this.value)}get inputPlaceholder(){return this.placeholder}get filterQuery(){return this.search}isSelected(t){return this.values.includes(t.value)}get formValue(){const{value:t}=this;return Array.isArray(t)?t.length?t.join(","):void 0:t||void 0}get hasValue(){return this.values.length>0}get createIndex(){return-1}get canCreate(){return!1}renderLeadingControl(){return o}get ariaAutocomplete(){return"list"}selectOption(t){t.disabled||(this.labelCache.set(t.value,t.label),this.value=t.value,this.search="",this.queryDirty=!1,this.commit(),this.hide(),this.focus())}handleEnter(t){return!1}onKeydown(t){}onBlur(){}afterUpdate(){}onOptionHover(){}onMove(){}get values(){const{value:t}=this;return Array.isArray(t)?t:t?[t]:[]}cacheLabels(t){for(const e of t)e.value&&this.labelCache.set(e.value,e.label);if(this.labelCache.size<=st.labelCacheLimit)return;const e=new Set(this.values);for(const t of this.labelCache.keys()){if(this.labelCache.size<=st.labelCacheLimit)break;e.has(t)||this.labelCache.delete(t)}}get resolvedOptions(){return this.options}get filtered(){const t=this.resolvedOptions,e=this.filterQuery,i=this.externalFiltering,s=this.filteredCache;if(s&&s.options===t&&s.query===e&&s.external===i)return s;s&&s.options===t||this.cacheLabels(t);const n=e.toLocaleLowerCase(),o=i||!e?t:t.filter((t=>t.label.toLocaleLowerCase().includes(n))),r=o.some((t=>t.group)),l=r?Array.from(y(o,"group"),(([,t])=>t)).flat():o;return this.filteredCache={options:t,query:e,external:i,result:l,hasGroups:r,groups:r?y(l,"group"):void 0},this.filteredCache}get filteredOptions(){return this.filtered.result}get rowCount(){return this.filteredOptions.length+(this.canCreate?1:0)}get activeOption(){return this.filteredOptions[this.activeDescendant.activeIndex]}get isVirtual(){if(!this.virtualized)return!1;const{result:t,hasGroups:e}=this.filtered;return t.length>0&&!e}connectedCallback(){var t,e,i;super.connectedCallback(),null!==(t=this.ariaObserver)&&void 0!==t||(this.ariaObserver=new MutationObserver((()=>this.requestUpdate()))),this.ariaObserver.observe(this,{attributes:!0,attributeFilter:["aria-label","aria-labelledby"]}),null!==(e=this.widthObserver)&&void 0!==e||(this.widthObserver=new ResizeObserver((()=>this.syncAnchorInlineSize()))),this.widthObserver.observe(this),this.syncAnchorInlineSize(),null!==(i=this.slotObserver)&&void 0!==i||(this.slotObserver=new MutationObserver((()=>this.requestUpdate()))),this.slotObserver.observe(this,{childList:!0})}disconnectedCallback(){var t,e,i;super.disconnectedCallback(),null===(t=this.ariaObserver)||void 0===t||t.disconnect(),this.ariaObserver=void 0,null===(e=this.widthObserver)||void 0===e||e.disconnect(),this.widthObserver=void 0,null===(i=this.slotObserver)||void 0===i||i.disconnect(),this.slotObserver=void 0}relocateSlots(){if(r)return;const t=(t,e)=>{if(e)for(const i of Array.from(this.children))i.getAttribute("slot")===t&&i.parentElement!==e&&e.appendChild(i)};t("start",this.startSlot),t("end",this.endSlot)}syncAnchorInlineSize(){const t=this.offsetWidth;t&&this.style.setProperty("--_n-combobox-anchor-inline-size",`${t}px`)}createRenderRoot(){if(r)return this;const t=document.createElement("div");return t.className="n-render-root",this.appendChild(t),t}show(){if(this.open||this.disabled||this.readonly)return;this.dispatchEvent(new E("open",{cancelable:!0}))&&(this.open=!0)}hide(){this.open&&(this.open=!1,this.onHide(),this.dispatchEvent(new E("close")))}onHide(){this.search="",this.queryDirty=!1}focus(t){var e;null===(e=this.inputRef.value)||void 0===e||e.focus(t)}handleOpenChange(){var t,e;this.open?(null===(t=this.popout)||void 0===t||t.show(),this.resetActiveIndex()):null===(e=this.popout)||void 0===e||e.hide(!1)}handleDisabledChange(){this.disabled&&this.open&&this.hide()}resetRowSample(){this.measuredRowSize=void 0}updated(t){super.updated(t),this.relocateSlots(),this.afterUpdate(),this.sampleRowSize(),this.scrollActivePending&&(this.scrollActivePending=!1,this.scrollActiveIntoView())}willUpdate(t){if(super.willUpdate(t),this.isVirtual){const t=this.virtualizer.getVirtualizer(),e=this.filteredOptions.length;t.options.count!==e&&t.setOptions({...t.options,count:e})}}scrollActiveIntoView(){var t;const e=this.listboxEl;if(!e)return;const i=this.activeDescendant.activeIndex;this.isVirtual&&i>=0&&i!==this.createIndex?this.virtualizer.getVirtualizer().scrollToIndex(i,{align:"auto"}):null===(t=e.querySelector(".n-option.is-active"))||void 0===t||t.scrollIntoView({block:"nearest"})}handlePopoutClose(t){t.stopPropagation(),this.open&&this.hide()}handlePopoutOpen(t){t.stopPropagation()}resetActiveIndex(){this.autoHighlight?this.activeDescendant.setActiveIndex(this.activeDescendant.nextEnabledIndex(0,1)):-1!==this.createIndex&&this.filteredOptions.every((t=>t.disabled))?this.activeDescendant.setActiveIndex(this.createIndex):this.activeDescendant.reset(),this.navigated=!1,this.scrollActivePending=!0}handleInput(t){if(t.stopPropagation(),this.readonly)return;const e=t.target;this.search=e.value,this.queryDirty=!0,this.open||this.show(),this.dispatchEvent(new E("input")),this.onInput(e)}onInput(t){}handleBlur(){this.onBlur()}handleKeydown(t){if(!this.readonly)switch(this.onKeydown(t),t.key){case"ArrowDown":if(t.preventDefault(),!this.open)return void this.show();this.move(1);break;case"ArrowUp":if(t.preventDefault(),!this.open)return void this.show();this.move(-1);break;case"End":this.open&&(t.preventDefault(),this.activeDescendant.last()&&(this.navigated=!0,this.scrollActivePending=!0));break;case"Home":this.open&&(t.preventDefault(),this.activeDescendant.first()&&(this.navigated=!0,this.scrollActivePending=!0));break;case"Enter":if(!this.open)break;if(this.handleEnter(t))break;if(-1!==this.createIndex&&this.activeDescendant.activeIndex===this.createIndex){t.preventDefault(),this.emitCreate();break}(this.navigated||this.autoHighlight)&&this.activeOption&&(t.preventDefault(),this.selectOption(this.activeOption));break;case"Escape":this.open&&(t.preventDefault(),this.hide());break;default:this.onUnhandledKeydown(t)}}onUnhandledKeydown(t){}emitCreate(){}move(t){0!==this.rowCount&&(this.onMove(),this.activeDescendant.move(t)&&(this.navigated=!0,this.scrollActivePending=!0))}commit(){this.requestUpdate(),this.dispatchEvent(new E("change"))}labelFor(t){var e,i;const s=this.resolvedOptions.find((e=>e.value===t));return null!==(i=null!==(e=null==s?void 0:s.label)&&void 0!==e?e:this.labelCache.get(t))&&void 0!==i?i:t}render(){const{result:t,hasGroups:e,groups:i}=this.filtered,s=this.virtualized&&!e&&t.length>0,n=s?this.virtualizer.getVirtualizer().getVirtualItems():void 0,r=e?new Map(t.map(((t,e)=>[t.value,e]))):void 0,a=this.activeDescendant.activeIndex,h=this.activeOption,c=!n||a===this.createIndex||n.some((t=>t.index===a)),d=-1!==this.createIndex&&a===this.createIndex?`${this.comboboxId}-create`:h&&c?this.optionId(a):void 0,u=`${this.comboboxId}-list`,f=`${this.comboboxId}-anchor`,S=this.showClear,y=this.controlAriaLabel,x=this.controlAriaLabelledby,O=this.controlAriaDescribedby,z=l`<input ${v(this.inputRef)} class="n-input" type="text" id="${this.comboboxId}-input" role="combobox" .value="${this.displayValue}" placeholder="${m(this.inputPlaceholder)}" ?disabled="${this.effectiveDisabled}" ?readonly="${this.readonly}" ?required="${this.required}" autocomplete="off" autocapitalize="off" spellcheck="false" aria-label="${m(y)}" aria-labelledby="${m(x)}" aria-describedby="${m(O)}" aria-autocomplete="${this.ariaAutocomplete}" aria-haspopup="listbox" aria-controls="${u}" aria-expanded="${this.open?"true":"false"}" aria-activedescendant="${m(this.open?d:void 0)}" aria-invalid="${m(this.controlAriaInvalid)}" @input="${this.handleInput}" @blur="${this.handleBlur}" @keydown="${this.handleKeydown}">`,I=this.renderLeadingControl();return l`${this.renderLabel()}<div class="n-combobox" id="${f}"><div class="${p({"n-control":!0,"is-invalid":this.effectiveInvalid})}" style="${b({"--_n-combobox-start-inline-size":et(this.startObserver.inlineSize),"--_n-combobox-end-inline-size":et(this.endObserver.inlineSize)})}" @click="${this.handleControlClick}"><span class="n-slot n-slot-start"></span> ${I===o?z:l`<div class="n-tags">${I}${z}</div>`} <span class="n-slot n-slot-end"></span> ${this.loading?l`<nord-spinner class="n-loading" size="s"></nord-spinner>`:o} ${S?l`<button class="n-clear" type="button" aria-label="${this.localize.term("clearLabel")}" ?disabled="${this.disabled||this.readonly}" @click="${this.handleClearClick}"><nord-icon name="interface-close-small"></nord-icon></button> ${this.showToggle?l`<span class="n-divider" aria-hidden="true"></span>`:o}`:o} ${this.showToggle?l`<button class="n-toggle" type="button" tabindex="-1" aria-hidden="true" ?disabled="${this.disabled||this.readonly}" @click="${this.handleToggleClick}"><nord-icon name="interface-dropdown-small"></nord-icon></button>`:o}</div><nord-popout id="${this.comboboxId}-popout" anchor="${f}" align="${m(this.align)}" position="${m(this.position)}" always-floating @open="${this.handlePopoutOpen}" @close="${this.handlePopoutClose}"><div id="${u}" class="n-listbox" role="${m(this.rowCount?"listbox":void 0)}" aria-label="${m(this.rowCount?y:void 0)}" aria-labelledby="${m(this.rowCount?x:void 0)}" aria-multiselectable="${m(this.rowCount?this.ariaMultiselectable:void 0)}">${0!==t.length||this.canCreate?e&&i&&r?Array.from(i,(([t,e])=>this.renderGroup(t,e,r))):s&&n?this.renderVirtualOptions(t,n):g(t,(t=>t.value),((t,e)=>this.renderListOption(t,e))):this.renderEmpty()} ${this.canCreate?this.renderCreate():o}</div></nord-popout></div>${this.renderError()} ${this.isHintBelow?this.renderHint():o}`}get showClear(){return!1}get showToggle(){return!this.readonly}get ariaMultiselectable(){return"false"}renderGroup(t,e,i){const s=`${this.comboboxId}-group-${t}`;return l`<div role="group" aria-labelledby="${C(t,s)}">${t?l`<div class="n-group-label" role="presentation" id="${s}">${t}</div>`:o} ${g(e,(t=>t.value),(t=>{var e;return this.renderListOption(t,null!==(e=i.get(t.value))&&void 0!==e?e:0)}))}</div>`}optionContent(t){return this.renderOption?this.renderOption(t):t.html?S(t.html):t.label}sampleRowSize(){var t;if(!this.isVirtual||void 0!==this.measuredRowSize)return;const e=null===(t=this.listboxEl)||void 0===t?void 0:t.querySelector(".n-virtual-row .n-option"),i=null==e?void 0:e.getBoundingClientRect().height;i&&i>0&&(this.measuredRowSize=i,this.virtualizer.getVirtualizer().measure())}renderVirtualOptions(t,e){const i=t.length,s=this.virtualizer.getVirtualizer().getTotalSize(),n=void 0!==this.measuredRowSize;return l`<div class="n-virtual-sizer" style="block-size:${s}">${g(e,(t=>t.key),(e=>l`<div class="n-virtual-row" data-index="${e.index}" style="${n?`block-size:${e.size}px; transform: translateY(${e.start}px)`:`transform: translateY(${e.start}px)`}">${this.renderListOption(t[e.index],e.index,i)}</div>`))}</div>`}renderListOption(t,e,i){const s=this.isSelected(t);return l`<div id="${this.optionId(e)}" class="${p({"n-option":!0,"is-active":e===this.activeDescendant.activeIndex,"is-disabled":Boolean(t.disabled)})}" role="option" aria-selected="${this.optionAriaSelected(s)}" aria-disabled="${t.disabled?"true":o}" aria-setsize="${m(i)}" aria-posinset="${m(void 0===i?void 0:e+1)}" @click="${()=>this.selectOption(t)}" @mousemove="${()=>this.handleOptionHover(e)}">${this.rendersCheck?l`<span class="n-option-check">${this.showCheck(s)?l`<nord-icon name="interface-checked" size="s"></nord-icon>`:o}</span>`:o} <span class="n-option-label">${this.optionContent(t)}</span></div>`}optionAriaSelected(t){return t?"true":"false"}showCheck(t){return t}get rendersCheck(){return!0}renderCreate(){return o}renderEmpty(){return this.loading?l`<div class="n-empty" role="status"><nord-spinner size="s"></nord-spinner></div>`:l`<div class="n-empty" role="status">${this.noResultsText||this.localize.term("noResults")}</div>`}optionId(t){return`${this.comboboxId}-option-${t}`}get createId(){return`${this.comboboxId}-create`}handleOptionHover(t){this.onOptionHover(),this.activeDescendant.setActiveIndex(t)}handleControlClick(){this.disabled||(!this.open&&this.openOnInputClick&&this.show(),this.focus())}handleClearClick(t){t.stopPropagation(),this.disabled||this.readonly||this.clear()}clear(){}handleToggleClick(t){t.stopPropagation(),this.disabled||this.readonly||(this.open?this.hide():this.show(),this.focus())}}st.VIRTUAL_ROW_ESTIMATE=36,st.VIRTUAL_OVERSCAN=6,st.labelCacheLimit=500,t([c("nord-popout",!0)],st.prototype,"popout",void 0),t([d({attribute:!1})],st.prototype,"options",void 0),t([d({reflect:!0})],st.prototype,"placeholder",void 0),t([d({reflect:!0,type:Boolean,attribute:"external-filtering"})],st.prototype,"externalFiltering",void 0),t([d({reflect:!0,type:Boolean})],st.prototype,"loading",void 0),t([d({reflect:!0,type:Boolean,attribute:"auto-highlight"})],st.prototype,"autoHighlight",void 0),t([d({reflect:!0,type:Boolean})],st.prototype,"invalid",void 0),t([d({reflect:!0,type:Boolean})],st.prototype,"readonly",void 0),t([d({reflect:!0,type:Boolean,attribute:"open-on-input-click"})],st.prototype,"openOnInputClick",void 0),t([d({reflect:!0,attribute:"no-results-text"})],st.prototype,"noResultsText",void 0),t([d({reflect:!0,type:Boolean})],st.prototype,"virtualized",void 0),t([d({attribute:!1})],st.prototype,"renderOption",void 0),t([u()],st.prototype,"search",void 0),t([u()],st.prototype,"queryDirty",void 0),t([c(".n-listbox")],st.prototype,"listboxEl",void 0),t([c(".n-slot-start")],st.prototype,"startSlot",void 0),t([c(".n-slot-end")],st.prototype,"endSlot",void 0),t([w("open","updated")],st.prototype,"handleOpenChange",null),t([w("disabled")],st.prototype,"handleDisabledChange",null),t([w("size")],st.prototype,"resetRowSample",null),t([w("search")],st.prototype,"resetActiveIndex",null);export{st as default,it as retagComboboxStyles};
|
|
2
2
|
//# sourceMappingURL=ComboboxBase.js.map
|