@editora/ui-core 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +3 -3
- package/dist/alert-dialog.cjs.js +32 -32
- package/dist/alert-dialog.esm.js +95 -75
- package/dist/alert.cjs.js +6 -6
- package/dist/alert.esm.js +6 -6
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +4 -4
- package/dist/animated-text.cjs.js +4 -4
- package/dist/animated-text.esm.js +4 -4
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +3 -3
- package/dist/aspect-ratio.cjs.js +3 -3
- package/dist/aspect-ratio.esm.js +3 -3
- package/dist/avatar.cjs.js +14 -14
- package/dist/avatar.esm.js +31 -29
- package/dist/badge.cjs.js +4 -4
- package/dist/badge.esm.js +4 -4
- package/dist/block-controls.cjs.js +4 -4
- package/dist/block-controls.esm.js +4 -4
- package/dist/box.cjs.js +2 -2
- package/dist/box.esm.js +2 -2
- package/dist/breadcrumb.cjs.js +5 -5
- package/dist/breadcrumb.esm.js +5 -5
- package/dist/button.cjs.js +1 -1
- package/dist/button.esm.js +1 -1
- package/dist/{calendar-DLY4acgn.mjs → calendar-DbxYRdlv.mjs} +227 -183
- package/dist/{calendar-Dkof-FTK.js → calendar-Qa-cFOp3.js} +74 -35
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +1 -1
- package/dist/card.cjs.js +8 -8
- package/dist/card.esm.js +63 -20
- package/dist/chart.cjs.js +4 -4
- package/dist/chart.esm.js +6 -6
- package/dist/checkbox.cjs.js +2 -2
- package/dist/checkbox.esm.js +2 -2
- package/dist/collapsible.cjs.js +7 -7
- package/dist/collapsible.esm.js +7 -7
- package/dist/color-picker.cjs.js +30 -10
- package/dist/color-picker.esm.js +82 -60
- package/dist/combobox.cjs.js +29 -27
- package/dist/combobox.esm.js +51 -45
- package/dist/command.cjs.js +2 -2
- package/dist/command.esm.js +2 -2
- package/dist/components/ui-alert-dialog.d.ts +1 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-avatar.d.ts +1 -0
- package/dist/components/ui-avatar.d.ts.map +1 -1
- package/dist/components/ui-button.d.ts +1 -0
- package/dist/components/ui-button.d.ts.map +1 -1
- package/dist/components/ui-calendar.d.ts.map +1 -1
- package/dist/components/ui-card.d.ts +3 -0
- package/dist/components/ui-card.d.ts.map +1 -1
- package/dist/components/ui-checkbox.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-data-table.d.ts.map +1 -1
- package/dist/components/ui-date-field.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dock.d.ts +1 -0
- package/dist/components/ui-dock.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-dropdown.d.ts.map +1 -1
- package/dist/components/ui-field.d.ts.map +1 -1
- package/dist/components/ui-file-upload.d.ts.map +1 -1
- package/dist/components/ui-gantt.d.ts.map +1 -1
- package/dist/components/ui-input.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-number-field.d.ts.map +1 -1
- package/dist/components/ui-password-field.d.ts.map +1 -1
- package/dist/components/ui-pin-input.d.ts +1 -0
- package/dist/components/ui-pin-input.d.ts.map +1 -1
- package/dist/components/ui-placement-grid.d.ts.map +1 -1
- package/dist/components/ui-progress.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts.map +1 -1
- package/dist/components/ui-rating.d.ts +1 -0
- package/dist/components/ui-rating.d.ts.map +1 -1
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts.map +1 -1
- package/dist/components/ui-switch.d.ts.map +1 -1
- package/dist/components/ui-table.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts +1 -0
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-tags-input.d.ts +1 -0
- package/dist/components/ui-tags-input.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/components/ui-time-field.d.ts.map +1 -1
- package/dist/components/ui-toggle-group.d.ts.map +1 -1
- package/dist/components/ui-toggle.d.ts.map +1 -1
- package/dist/components/ui-tree.d.ts.map +1 -1
- package/dist/components/ui-wizard.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +3 -3
- package/dist/context-menu.esm.js +4 -4
- package/dist/control-name-BmoI1m3a.js +1 -0
- package/dist/control-name-Bpj7F34X.mjs +48 -0
- package/dist/data-table.cjs.js +5 -2
- package/dist/data-table.esm.js +145 -142
- package/dist/date-field.cjs.js +5 -5
- package/dist/date-field.esm.js +34 -31
- package/dist/date-picker.cjs.js +16 -16
- package/dist/date-picker.esm.js +48 -44
- package/dist/date-range-picker.cjs.js +5 -5
- package/dist/date-range-picker.esm.js +120 -118
- package/dist/date-range-time-picker.cjs.js +22 -22
- package/dist/date-range-time-picker.esm.js +88 -84
- package/dist/date-time-picker.cjs.js +23 -23
- package/dist/date-time-picker.esm.js +102 -98
- package/dist/{date-time-utils-Dmost5Ee.js → date-time-utils-BzfTpeU-.js} +1 -1
- package/dist/{date-time-utils-y1N2gvG2.mjs → date-time-utils-Cps2aSu2.mjs} +1 -1
- package/dist/description.cjs.js +3 -3
- package/dist/description.esm.js +3 -3
- package/dist/dialog.cjs.js +2 -2
- package/dist/dialog.esm.js +2 -2
- package/dist/dock.cjs.js +12 -12
- package/dist/dock.esm.js +72 -74
- package/dist/drawer.cjs.js +19 -19
- package/dist/drawer.esm.js +58 -58
- package/dist/dropdown.cjs.js +13 -13
- package/dist/dropdown.esm.js +49 -48
- package/dist/empty-state.cjs.js +3 -3
- package/dist/empty-state.esm.js +3 -3
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +1 -1
- package/dist/field.cjs.js +12 -12
- package/dist/field.esm.js +84 -75
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +4 -4
- package/dist/file-upload.cjs.js +3 -3
- package/dist/file-upload.esm.js +5 -3
- package/dist/floating-toolbar.cjs.js +8 -8
- package/dist/floating-toolbar.esm.js +9 -9
- package/dist/form.cjs.js +11 -11
- package/dist/form.esm.js +11 -11
- package/dist/gantt.cjs.js +43 -32
- package/dist/gantt.esm.js +99 -88
- package/dist/icon-cloud.cjs.js +3 -3
- package/dist/icon-cloud.esm.js +3 -3
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +121 -118
- package/dist/inline-edit.cjs.js +1 -1
- package/dist/inline-edit.esm.js +1 -1
- package/dist/input.cjs.js +14 -14
- package/dist/input.esm.js +39 -32
- package/dist/label.cjs.js +3 -3
- package/dist/label.esm.js +3 -3
- package/dist/{listbox-B6QgECax.js → listbox-CTpRpuF7.js} +1 -1
- package/dist/{listbox-DJamVeFj.mjs → listbox-hMVOhKHC.mjs} +1 -1
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +1 -1
- package/dist/marquee.cjs.js +3 -3
- package/dist/marquee.esm.js +3 -3
- package/dist/{menu-item-styles-CbNUEwP2.js → menu-item-styles-B4onAr4C.js} +3 -3
- package/dist/{menu-item-styles-CZiPwPwl.mjs → menu-item-styles-IGSFLAHu.mjs} +3 -3
- package/dist/menu.cjs.js +7 -7
- package/dist/menu.esm.js +29 -28
- package/dist/menubar.cjs.js +1 -1
- package/dist/menubar.esm.js +2 -2
- package/dist/meter.cjs.js +1 -1
- package/dist/meter.esm.js +1 -1
- package/dist/multi-select.cjs.js +17 -17
- package/dist/multi-select.esm.js +51 -43
- package/dist/navigation-menu.cjs.js +1 -1
- package/dist/navigation-menu.esm.js +1 -1
- package/dist/number-field.cjs.js +11 -13
- package/dist/number-field.esm.js +29 -27
- package/dist/number-ticker.cjs.js +4 -4
- package/dist/number-ticker.esm.js +4 -4
- package/dist/odometer.cjs.js +2 -2
- package/dist/odometer.esm.js +2 -2
- package/dist/orbiter.cjs.js +3 -3
- package/dist/orbiter.esm.js +3 -3
- package/dist/pagination.cjs.js +1 -1
- package/dist/pagination.esm.js +1 -1
- package/dist/password-field.cjs.js +23 -23
- package/dist/password-field.esm.js +48 -47
- package/dist/pin-input.cjs.js +8 -6
- package/dist/pin-input.esm.js +21 -15
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +58 -58
- package/dist/plugin-panel.cjs.js +1 -1
- package/dist/plugin-panel.esm.js +1 -1
- package/dist/popover.cjs.js +5 -5
- package/dist/popover.esm.js +4 -4
- package/dist/primitives/control-name.d.ts +30 -0
- package/dist/primitives/control-name.d.ts.map +1 -0
- package/dist/primitives/trigger.d.ts +2 -0
- package/dist/primitives/trigger.d.ts.map +1 -0
- package/dist/progress.cjs.js +4 -4
- package/dist/progress.esm.js +20 -18
- package/dist/quick-actions.cjs.js +3 -3
- package/dist/quick-actions.esm.js +3 -3
- package/dist/radio-group.cjs.js +1 -1
- package/dist/radio-group.esm.js +1 -1
- package/dist/radio.cjs.js +2 -2
- package/dist/radio.esm.js +2 -2
- package/dist/rating.cjs.js +17 -16
- package/dist/rating.esm.js +91 -92
- package/dist/{runtime-D1gFh1fS.mjs → runtime-CFnK53iC.mjs} +133 -94
- package/dist/runtime-DwE-tizc.js +1 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.esm.js +29 -26
- package/dist/select.cjs.js +20 -19
- package/dist/select.esm.js +36 -32
- package/dist/selection-popup.cjs.js +2 -2
- package/dist/selection-popup.esm.js +2 -2
- package/dist/separator.cjs.js +7 -7
- package/dist/separator.esm.js +7 -7
- package/dist/sidebar.cjs.js +7 -7
- package/dist/sidebar.esm.js +7 -7
- package/dist/skeleton.cjs.js +7 -7
- package/dist/skeleton.esm.js +7 -7
- package/dist/slider.cjs.js +3 -3
- package/dist/slider.esm.js +3 -3
- package/dist/slot.cjs.js +3 -3
- package/dist/slot.esm.js +3 -3
- package/dist/sortable.cjs.js +41 -42
- package/dist/sortable.esm.js +98 -99
- package/dist/spinning-text.cjs.js +3 -3
- package/dist/spinning-text.esm.js +3 -3
- package/dist/split-button.cjs.js +1 -1
- package/dist/split-button.esm.js +1 -1
- package/dist/stepper.cjs.js +1 -1
- package/dist/stepper.esm.js +1 -1
- package/dist/switch.cjs.js +10 -12
- package/dist/switch.esm.js +10 -12
- package/dist/table.cjs.js +9 -6
- package/dist/table.esm.js +46 -43
- package/dist/tabs.cjs.js +20 -21
- package/dist/tabs.esm.js +70 -66
- package/dist/tags-input.cjs.js +9 -9
- package/dist/tags-input.esm.js +32 -25
- package/dist/textarea.cjs.js +10 -10
- package/dist/textarea.esm.js +30 -21
- package/dist/theme.d.ts +18 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/time-field.cjs.js +5 -5
- package/dist/time-field.esm.js +21 -18
- package/dist/time-picker.cjs.js +4 -4
- package/dist/time-picker.esm.js +5 -5
- package/dist/timeline.cjs.js +2 -2
- package/dist/timeline.esm.js +4 -4
- package/dist/toast.cjs.js +6 -6
- package/dist/toast.esm.js +13 -13
- package/dist/toggle-group.cjs.js +5 -6
- package/dist/toggle-group.esm.js +63 -60
- package/dist/toggle.cjs.js +18 -18
- package/dist/toggle.esm.js +32 -31
- package/dist/tooltip.cjs.js +4 -4
- package/dist/tooltip.esm.js +4 -4
- package/dist/transfer-list.cjs.js +3 -3
- package/dist/transfer-list.esm.js +3 -3
- package/dist/tree-7qbVnpGp.js +39 -0
- package/dist/{tree-B3kE8ESs.mjs → tree-Deoft-kO.mjs} +34 -33
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +1 -1
- package/dist/trigger-BjnxLCeQ.mjs +9 -0
- package/dist/trigger-DkPsKxsP.js +1 -0
- package/dist/{ui-button-rXQOS9QJ.js → ui-button-BInsgSbr.js} +27 -26
- package/dist/{ui-button-Q0GNNWKC.mjs → ui-button-rfiuUnUD.mjs} +65 -48
- package/dist/{ui-icon-YI6lyuqU.mjs → ui-icon-BSi_GtqO.mjs} +2 -2
- package/dist/{ui-icon-BzVNC_lr.js → ui-icon-Bvt9oIIR.js} +5 -5
- package/dist/wizard.cjs.js +12 -13
- package/dist/wizard.esm.js +17 -15
- package/package.json +1 -1
- package/dist/runtime-CTaOSmBj.js +0 -1
- package/dist/tree-Dx_kv_ih.js +0 -39
package/dist/drawer.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("./ElementBase-EV6mVBUV.js"),v=require("./overlayManager-CSy3fJmJ.js");function k(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>i()):window.setTimeout(i,16)}function F(i){if(i){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(i);return}window.clearTimeout(i)}}const L='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',D=new Set(["side","dismissible","headless","variant","density","shape","elevation","tone","size","inset","close-on-overlay","close-on-esc","lock-while-loading","show-close","state","role","aria-label","aria-labelledby","aria-describedby","initial-focus"]),$=`
|
|
2
2
|
:host {
|
|
3
3
|
position: fixed;
|
|
4
4
|
inset: 0;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
color-mix(in srgb, var(--ui-color-surface-elevated, #f8fafc) 20%, var(--ui-color-surface, #ffffff)) 100%
|
|
16
16
|
);
|
|
17
17
|
--ui-drawer-color: var(--ui-color-text, #0f172a);
|
|
18
|
-
--ui-drawer-muted: var(--ui-color-muted, #
|
|
18
|
+
--ui-drawer-muted: var(--ui-color-muted, #526175);
|
|
19
19
|
--ui-drawer-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 74%, transparent);
|
|
20
20
|
--ui-drawer-border: 1px solid var(--ui-drawer-border-color);
|
|
21
21
|
--ui-drawer-shadow: none;
|
|
@@ -370,13 +370,13 @@
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
:host([tone='success']) {
|
|
373
|
-
--ui-drawer-focus-ring: var(--ui-color-success, #
|
|
374
|
-
--ui-drawer-control-bg-hover: color-mix(in srgb, var(--ui-color-success, #
|
|
373
|
+
--ui-drawer-focus-ring: var(--ui-color-success, #15803d);
|
|
374
|
+
--ui-drawer-control-bg-hover: color-mix(in srgb, var(--ui-color-success, #15803d) 12%, transparent);
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
:host([tone='warning']) {
|
|
378
|
-
--ui-drawer-focus-ring: var(--ui-color-warning, #
|
|
379
|
-
--ui-drawer-control-bg-hover: color-mix(in srgb, var(--ui-color-warning, #
|
|
378
|
+
--ui-drawer-focus-ring: var(--ui-color-warning, #b45309);
|
|
379
|
+
--ui-drawer-control-bg-hover: color-mix(in srgb, var(--ui-color-warning, #b45309) 16%, transparent);
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
:host([state='error']) .panel {
|
|
@@ -384,7 +384,7 @@
|
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
:host([state='success']) .panel {
|
|
387
|
-
border-color: color-mix(in srgb, var(--ui-color-success, #
|
|
387
|
+
border-color: color-mix(in srgb, var(--ui-color-success, #15803d) 40%, var(--ui-drawer-border-color));
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
:host([state='loading']) .body {
|
|
@@ -498,25 +498,25 @@
|
|
|
498
498
|
display: none;
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
`;function w(i,e){if(i==null)return e;const t=i.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}function v(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function C(i,e){return i==="top"||i==="bottom"||i==="left"||i==="right"?i:i==="start"?e==="rtl"?"right":"left":i==="end"?e==="rtl"?"left":"right":"left"}function A(i,e){const t=i.querySelector(`[slot="${e}"]`);return t?t.textContent?.trim().length!==0||t.children.length>0:!1}function L(){return typeof window<"u"&&typeof document<"u"}class I extends O.ElementBase{constructor(){super(),this._uid=Math.random().toString(36).slice(2,10),this._isOpen=!1,this._restoreFocusEl=null,this._globalListenersBound=!1,this._closeReason="programmatic",this._focusInitialFrame=0,this._focusTrapFrame=0,this._restoreFocusFrame=0,this._onRootClick=this._onRootClick.bind(this),this._onDocumentKeyDown=this._onDocumentKeyDown.bind(this),this._onDocumentFocusIn=this._onDocumentFocusIn.bind(this)}static get observedAttributes(){return["open","side","dismissible","headless","variant","density","shape","elevation","tone","size","inset","close-on-overlay","close-on-esc","lock-while-loading","show-close","state","title","description","aria-label","aria-labelledby","aria-describedby","initial-focus"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onRootClick),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClick),this._unbindGlobalListeners(),this._cancelScheduledFocusWork(),this._releaseOpenResources(),this._restoreFocusEl=null,this._isOpen=!1,super.disconnectedCallback()}attributeChangedCallback(e,t,r){if(t!==r){if(e==="open"){this._syncOpenState();return}if(S.has(e)){this._syncLiveUi(),this._isOpen&&(e==="initial-focus"||e==="dismissible"||e==="show-close")&&this._scheduleEnsureFocusTrap();return}this.isConnected&&this.requestRender()}}open(){this.setAttribute("open","")}close(e="programmatic"){this._closeReason=e,this.removeAttribute("open")}closeDrawer(e="programmatic"){if(this.hasAttribute("open")){if(e==="programmatic"){this.close("programmatic");return}this._requestClose(e)}}toggle(){this.hasAttribute("open")?this.close("programmatic"):this.open()}get dismissible(){const e=this.getAttribute("dismissible");return e==null?!1:w(e,!0)}set dismissible(e){e?this.setAttribute("dismissible",""):this.removeAttribute("dismissible")}get closeOnOverlay(){return w(this.getAttribute("close-on-overlay"),!0)}set closeOnOverlay(e){this.setAttribute("close-on-overlay",String(e))}get closeOnEsc(){return w(this.getAttribute("close-on-esc"),!0)}set closeOnEsc(e){this.setAttribute("close-on-esc",String(e))}get lockWhileLoading(){return w(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(e){this.setAttribute("lock-while-loading",String(e))}get showClose(){return this.hasAttribute("show-close")?w(this.getAttribute("show-close"),!0):this.dismissible}set showClose(e){this.setAttribute("show-close",String(e))}get state(){const e=this.getAttribute("state");return e==="loading"||e==="error"||e==="success"?e:"idle"}set state(e){if(e==="idle"){this.removeAttribute("state");return}this.setAttribute("state",e)}get inset(){return this.hasAttribute("inset")}set inset(e){e?this.setAttribute("inset",""):this.removeAttribute("inset")}_getPanel(){return this.root.querySelector(".panel")}_getOverlay(){return this.root.querySelector(".overlay")}_getHeader(){return this.root.querySelector(".header")}_titleId(){return`ui-drawer-title-${this._uid}`}_descriptionId(){return`ui-drawer-description-${this._uid}`}_bodyId(){return`ui-drawer-body-${this._uid}`}_resolvedSide(){const e=this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"ltr";return C(this.getAttribute("side"),e==="rtl"?"rtl":"ltr")}_isTopMost(){const e=m.OverlayManager.top();return e?e===this:!0}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_isNodeInsideDrawer(e){if(!e)return!1;const t=this._getPanel();return t&&t.contains(e)?!0:this.contains(e)}_isFocusable(e){if(!e||!e.isConnected||e.disabled||e.matches('[inert], [aria-hidden="true"]')||e.closest('[inert], [aria-hidden="true"]'))return!1;if(!L())return!0;const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}_collectFocusable(){const e=this._getPanel(),t=[],r=s=>{this._isFocusable(s)&&(t.includes(s)||t.push(s))};return this.querySelectorAll(E).forEach(r),e&&e.querySelectorAll(E).forEach(r),t}_cancelScheduledFocusWork(){this._focusInitialFrame&&(_(this._focusInitialFrame),this._focusInitialFrame=0),this._focusTrapFrame&&(_(this._focusTrapFrame),this._focusTrapFrame=0),this._restoreFocusFrame&&(_(this._restoreFocusFrame),this._restoreFocusFrame=0)}_scheduleFocusInitial(){this._isOpen&&(this._focusInitialFrame||(this._focusInitialFrame=F(()=>{this._focusInitialFrame=0,this._focusInitial()})))}_scheduleEnsureFocusTrap(){this._isOpen&&(this._focusTrapFrame||(this._focusTrapFrame=F(()=>{this._focusTrapFrame=0,this._ensureFocusTrap()})))}_scheduleRestoreFocus(e){!e||!this._canRestoreFocus(e)||(this._restoreFocusFrame&&_(this._restoreFocusFrame),this._restoreFocusFrame=F(()=>{this._restoreFocusFrame=0;try{this._canRestoreFocus(e)&&e.focus({preventScroll:!0})}catch{try{this._canRestoreFocus(e)&&e.focus()}catch{}}}))}_syncLiveUi(){const e=this.hasAttribute("open"),t=this._getOverlay(),r=this._getPanel(),s=this._getHeader(),a=this.root.querySelector(".close-btn");if(t&&t.setAttribute("aria-hidden",e?"false":"true"),!r)return;const o=this._resolvedSide();r.classList.remove("side-left","side-right","side-top","side-bottom"),r.classList.add(`side-${o}`);const n=this.state==="loading";n?r.setAttribute("aria-busy","true"):r.removeAttribute("aria-busy");const y=this.getAttribute("role")||"dialog";r.setAttribute("role",y);const u=(this.getAttribute("title")||"").trim(),h=(this.getAttribute("description")||"").trim(),b=A(this,"header"),p=this.showClose,x=p||b||!!u||!!h;s&&s.classList.toggle("empty",!x),a&&(a.hidden=!p,a.disabled=n&&this.lockWhileLoading);const f=this.getAttribute("aria-label")||"",g=this.getAttribute("aria-labelledby")||"",l=this.getAttribute("aria-describedby")||"",c=g||(!f&&(b||u)?this._titleId():""),d=[];l?d.push(l):(h&&d.push(this._descriptionId()),d.push(this._bodyId()));const k=f||(c?"":"Drawer");k?r.setAttribute("aria-label",k):r.removeAttribute("aria-label"),c?r.setAttribute("aria-labelledby",c):r.removeAttribute("aria-labelledby"),d.length?r.setAttribute("aria-describedby",d.join(" ")):r.removeAttribute("aria-describedby")}_focusInitial(){if(!this._isOpen)return;const e=this._getPanel();if(!e)return;const t=this.getAttribute("initial-focus")||"";if(t){const o=this.querySelector(t)||e.querySelector(t);if(o&&this._isFocusable(o))try{o.focus({preventScroll:!0});return}catch{try{o.focus();return}catch{}}}const r=this._collectFocusable(),a=r.find(o=>o.hasAttribute("autofocus"))||r[0]||e;a===e&&!a.hasAttribute("tabindex")&&a.setAttribute("tabindex","-1");try{a.focus({preventScroll:!0})}catch{try{a.focus()}catch{}}}_ensureFocusTrap(){if(!this._isOpen||!this._isTopMost())return;const e=document.activeElement;this._isNodeInsideDrawer(e)||this._focusInitial()}_releaseOpenResources(){try{m.OverlayManager.unregister(this),m.OverlayManager.releaseLock()}catch{}}_canRestoreFocus(e){if(!e||!e.isConnected||e.disabled)return!1;if(!L())return!0;const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}_syncOpenState(){const e=this.hasAttribute("open");if(this._syncLiveUi(),e===this._isOpen){e?(this._bindGlobalListeners(),this._scheduleEnsureFocusTrap()):(this._unbindGlobalListeners(),this._cancelScheduledFocusWork());return}if(this._isOpen=e,e){this._cancelScheduledFocusWork(),this._bindGlobalListeners(),this._restoreFocusEl=document.activeElement||null,this._closeReason="programmatic";try{m.OverlayManager.register(this),m.OverlayManager.acquireLock()}catch{}this._scheduleFocusInitial(),this._scheduleEnsureFocusTrap(),this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("show",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0,reason:"programmatic"}}));return}this._unbindGlobalListeners(),this._cancelScheduledFocusWork(),this._releaseOpenResources();const t=this._closeReason;this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("hide",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:t}}));const r=this._restoreFocusEl;this._restoreFocusEl=null,this._closeReason="programmatic",this._scheduleRestoreFocus(r)}_requestClose(e){if(!this._isOpen||this._isInteractionLocked())return;const t=new CustomEvent("request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t);const r=new CustomEvent("ui-request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(r),!(t.defaultPrevented||r.defaultPrevented)&&this.close(e)}_onRootClick(e){const t=e.target;if(!t||!this._isOpen)return;if(t.closest(".close-btn")){this._requestClose("button");return}t.closest(".overlay")&&(!this.dismissible||!this.closeOnOverlay||this._isTopMost()&&this._requestClose("overlay"))}_handleTab(e){const t=this._getPanel();if(!t)return;const r=this._collectFocusable();if(!r.length){e.preventDefault(),t.focus();return}const s=r[0],a=r[r.length-1],o=document.activeElement,n=!!o&&this._isNodeInsideDrawer(o);if(e.shiftKey){if(!n||o===s){e.preventDefault();try{a.focus({preventScroll:!0})}catch{a.focus()}}return}if(!n||o===a){e.preventDefault();try{s.focus({preventScroll:!0})}catch{s.focus()}}}_onDocumentKeyDown(e){if(!(!this._isOpen||!this._isTopMost())){if(e.key==="Escape"){if(!this.dismissible||!this.closeOnEsc||this._isInteractionLocked())return;e.preventDefault(),e.stopPropagation(),this._requestClose("escape");return}e.key==="Tab"&&this._handleTab(e)}}_onDocumentFocusIn(e){if(!this._isOpen||!this._isTopMost())return;const t=e.target,r=this._getPanel(),s=typeof e.composedPath=="function"?e.composedPath():[];t&&this._isNodeInsideDrawer(t)||s.includes(this)||r&&s.includes(r)||this._scheduleFocusInitial()}render(){const e=this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"ltr",t=C(this.getAttribute("side"),e==="rtl"?"rtl":"ltr"),r=this.showClose,s=A(this,"header"),a=A(this,"footer"),o=(this.getAttribute("title")||"").trim(),n=(this.getAttribute("description")||"").trim(),y=r||s||!!o||!!n,u=`ui-drawer-title-${this._uid}`,h=`ui-drawer-description-${this._uid}`,b=`ui-drawer-body-${this._uid}`,p=this.getAttribute("aria-label")||"",x=this.getAttribute("aria-labelledby")||"",f=this.getAttribute("aria-describedby")||"",g=x||(!p&&(s||o)?u:""),l=[];f?l.push(f):(n&&l.push(h),l.push(b));const c=p||(g?"":"Drawer"),d=this.state==="loading";this.setContent(`
|
|
502
|
-
<style>${
|
|
501
|
+
`;function _(i,e){if(i==null)return e;const t=i.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}function y(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function S(i,e){return i==="top"||i==="bottom"||i==="left"||i==="right"?i:i==="start"?e==="rtl"?"right":"left":i==="end"?e==="rtl"?"left":"right":"left"}function C(i,e){const t=i.querySelector(`[slot="${e}"]`);return t?t.textContent?.trim().length!==0||t.children.length>0:!1}function I(){return typeof window<"u"&&typeof document<"u"}class O extends T.ElementBase{constructor(){super(),this._uid=Math.random().toString(36).slice(2,10),this._isOpen=!1,this._restoreFocusEl=null,this._globalListenersBound=!1,this._closeReason="programmatic",this._focusInitialFrame=0,this._focusTrapFrame=0,this._restoreFocusFrame=0,this._onRootClick=this._onRootClick.bind(this),this._onDocumentKeyDown=this._onDocumentKeyDown.bind(this),this._onDocumentFocusIn=this._onDocumentFocusIn.bind(this)}static get observedAttributes(){return["open","side","dismissible","headless","variant","density","shape","elevation","tone","size","inset","close-on-overlay","close-on-esc","lock-while-loading","show-close","state","title","description","aria-label","aria-labelledby","aria-describedby","initial-focus"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onRootClick),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClick),this._unbindGlobalListeners(),this._cancelScheduledFocusWork(),this._releaseOpenResources(),this._restoreFocusEl=null,this._isOpen=!1,super.disconnectedCallback()}attributeChangedCallback(e,t,r){if(t!==r){if(e==="open"){this._syncOpenState();return}if(D.has(e)){this._syncLiveUi(),this._isOpen&&(e==="initial-focus"||e==="dismissible"||e==="show-close")&&this._scheduleEnsureFocusTrap();return}this.isConnected&&this.requestRender()}}open(){this.setAttribute("open","")}close(e="programmatic"){this._closeReason=e,this.removeAttribute("open")}closeDrawer(e="programmatic"){if(this.hasAttribute("open")){if(e==="programmatic"){this.close("programmatic");return}this._requestClose(e)}}toggle(){this.hasAttribute("open")?this.close("programmatic"):this.open()}get dismissible(){const e=this.getAttribute("dismissible");return e==null?!1:_(e,!0)}set dismissible(e){e?this.setAttribute("dismissible",""):this.removeAttribute("dismissible")}get closeOnOverlay(){return _(this.getAttribute("close-on-overlay"),!0)}set closeOnOverlay(e){this.setAttribute("close-on-overlay",String(e))}get closeOnEsc(){return _(this.getAttribute("close-on-esc"),!0)}set closeOnEsc(e){this.setAttribute("close-on-esc",String(e))}get lockWhileLoading(){return _(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(e){this.setAttribute("lock-while-loading",String(e))}get showClose(){return this.hasAttribute("show-close")?_(this.getAttribute("show-close"),!0):this.dismissible}set showClose(e){this.setAttribute("show-close",String(e))}get state(){const e=this.getAttribute("state");return e==="loading"||e==="error"||e==="success"?e:"idle"}set state(e){if(e==="idle"){this.removeAttribute("state");return}this.setAttribute("state",e)}get inset(){return this.hasAttribute("inset")}set inset(e){e?this.setAttribute("inset",""):this.removeAttribute("inset")}_getPanel(){return this.root.querySelector(".panel")}_getOverlay(){return this.root.querySelector(".overlay")}_getHeader(){return this.root.querySelector(".header")}_titleId(){return`ui-drawer-title-${this._uid}`}_descriptionId(){return`ui-drawer-description-${this._uid}`}_bodyId(){return`ui-drawer-body-${this._uid}`}_resolvedSide(){const e=this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"ltr";return S(this.getAttribute("side"),e==="rtl"?"rtl":"ltr")}_isTopMost(){const e=v.OverlayManager.top();return e?e===this:!0}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_isNodeInsideDrawer(e){if(!e)return!1;const t=this._getPanel();return t&&t.contains(e)?!0:this.contains(e)}_isFocusable(e){if(!e||!e.isConnected||e.disabled||e.matches('[inert], [aria-hidden="true"]')||e.closest('[inert], [aria-hidden="true"]'))return!1;if(!I())return!0;const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}_collectFocusable(){const e=this._getPanel(),t=[],r=s=>{this._isFocusable(s)&&(t.includes(s)||t.push(s))};return this.querySelectorAll(L).forEach(r),e&&e.querySelectorAll(L).forEach(r),t}_cancelScheduledFocusWork(){this._focusInitialFrame&&(F(this._focusInitialFrame),this._focusInitialFrame=0),this._focusTrapFrame&&(F(this._focusTrapFrame),this._focusTrapFrame=0),this._restoreFocusFrame&&(F(this._restoreFocusFrame),this._restoreFocusFrame=0)}_scheduleFocusInitial(){this._isOpen&&(this._focusInitialFrame||(this._focusInitialFrame=k(()=>{this._focusInitialFrame=0,this._focusInitial()})))}_scheduleEnsureFocusTrap(){this._isOpen&&(this._focusTrapFrame||(this._focusTrapFrame=k(()=>{this._focusTrapFrame=0,this._ensureFocusTrap()})))}_scheduleRestoreFocus(e){!e||!this._canRestoreFocus(e)||(this._restoreFocusFrame&&F(this._restoreFocusFrame),this._restoreFocusFrame=k(()=>{this._restoreFocusFrame=0;try{this._canRestoreFocus(e)&&e.focus({preventScroll:!0})}catch{try{this._canRestoreFocus(e)&&e.focus()}catch{}}}))}_syncLiveUi(){const e=this.hasAttribute("open"),t=this._getOverlay(),r=this._getPanel(),s=this._getHeader(),a=this.root.querySelector(".close-btn");if(t&&t.setAttribute("aria-hidden",e?"false":"true"),!r)return;const o=this._resolvedSide();r.classList.remove("side-left","side-right","side-top","side-bottom"),r.classList.add(`side-${o}`);const n=this.state==="loading";n?r.setAttribute("aria-busy","true"):r.removeAttribute("aria-busy");const A=this.getAttribute("role")||"dialog";r.setAttribute("role",A);const u=(this.getAttribute("title")||"").trim(),g=(this.getAttribute("description")||"").trim(),c=C(this,"header"),h=this.showClose,x=h||c||!!u||!!g;s&&s.classList.toggle("empty",!x),a&&(a.hidden=!h,a.disabled=n&&this.lockWhileLoading);const b=this.getAttribute("aria-label")||"",m=this.getAttribute("aria-labelledby")||"",w=this.getAttribute("aria-describedby")||"",p=c?(this.querySelector('[slot="header"]')?.textContent||"").replace(/\s+/g," ").trim():"",l=!b&&!m&&!!p,f=m||(!b&&!l&&(c||u)?this._titleId():""),d=[];w?d.push(w):(g&&d.push(this._descriptionId()),d.push(this._bodyId()));const E=b||(l?p:f?"":"Drawer");E?r.setAttribute("aria-label",E):r.removeAttribute("aria-label"),f?r.setAttribute("aria-labelledby",f):r.removeAttribute("aria-labelledby"),d.length?r.setAttribute("aria-describedby",d.join(" ")):r.removeAttribute("aria-describedby")}_focusInitial(){if(!this._isOpen)return;const e=this._getPanel();if(!e)return;const t=this.getAttribute("initial-focus")||"";if(t){const o=this.querySelector(t)||e.querySelector(t);if(o&&this._isFocusable(o))try{o.focus({preventScroll:!0});return}catch{try{o.focus();return}catch{}}}const r=this._collectFocusable(),a=r.find(o=>o.hasAttribute("autofocus"))||r[0]||e;a===e&&!a.hasAttribute("tabindex")&&a.setAttribute("tabindex","-1");try{a.focus({preventScroll:!0})}catch{try{a.focus()}catch{}}}_ensureFocusTrap(){if(!this._isOpen||!this._isTopMost())return;const e=document.activeElement;this._isNodeInsideDrawer(e)||this._focusInitial()}_releaseOpenResources(){try{v.OverlayManager.unregister(this),v.OverlayManager.releaseLock()}catch{}}_canRestoreFocus(e){if(!e||!e.isConnected||e.disabled)return!1;if(!I())return!0;const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}_syncOpenState(){const e=this.hasAttribute("open");if(this._syncLiveUi(),e===this._isOpen){e?(this._bindGlobalListeners(),this._scheduleEnsureFocusTrap()):(this._unbindGlobalListeners(),this._cancelScheduledFocusWork());return}if(this._isOpen=e,e){this._cancelScheduledFocusWork(),this._bindGlobalListeners(),this._restoreFocusEl=document.activeElement||null,this._closeReason="programmatic";try{v.OverlayManager.register(this),v.OverlayManager.acquireLock()}catch{}this._scheduleFocusInitial(),this._scheduleEnsureFocusTrap(),this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("show",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0,reason:"programmatic"}}));return}this._unbindGlobalListeners(),this._cancelScheduledFocusWork(),this._releaseOpenResources();const t=this._closeReason;this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("hide",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:t}}));const r=this._restoreFocusEl;this._restoreFocusEl=null,this._closeReason="programmatic",this._scheduleRestoreFocus(r)}_requestClose(e){if(!this._isOpen||this._isInteractionLocked())return;const t=new CustomEvent("request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t);const r=new CustomEvent("ui-request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(r),!(t.defaultPrevented||r.defaultPrevented)&&this.close(e)}_onRootClick(e){const t=e.target;if(!t||!this._isOpen)return;if(t.closest(".close-btn")){this._requestClose("button");return}t.closest(".overlay")&&(!this.dismissible||!this.closeOnOverlay||this._isTopMost()&&this._requestClose("overlay"))}_handleTab(e){const t=this._getPanel();if(!t)return;const r=this._collectFocusable();if(!r.length){e.preventDefault(),t.focus();return}const s=r[0],a=r[r.length-1],o=document.activeElement,n=!!o&&this._isNodeInsideDrawer(o);if(e.shiftKey){if(!n||o===s){e.preventDefault();try{a.focus({preventScroll:!0})}catch{a.focus()}}return}if(!n||o===a){e.preventDefault();try{s.focus({preventScroll:!0})}catch{s.focus()}}}_onDocumentKeyDown(e){if(!(!this._isOpen||!this._isTopMost())){if(e.key==="Escape"){if(!this.dismissible||!this.closeOnEsc||this._isInteractionLocked())return;e.preventDefault(),e.stopPropagation(),this._requestClose("escape");return}e.key==="Tab"&&this._handleTab(e)}}_onDocumentFocusIn(e){if(!this._isOpen||!this._isTopMost())return;const t=e.target,r=this._getPanel(),s=typeof e.composedPath=="function"?e.composedPath():[];t&&this._isNodeInsideDrawer(t)||s.includes(this)||r&&s.includes(r)||this._scheduleFocusInitial()}render(){const e=this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"ltr",t=S(this.getAttribute("side"),e==="rtl"?"rtl":"ltr"),r=this.showClose,s=C(this,"header"),a=C(this,"footer"),o=(this.getAttribute("title")||"").trim(),n=(this.getAttribute("description")||"").trim(),A=r||s||!!o||!!n,u=`ui-drawer-title-${this._uid}`,g=`ui-drawer-description-${this._uid}`,c=`ui-drawer-body-${this._uid}`,h=this.getAttribute("aria-label")||"",x=this.getAttribute("aria-labelledby")||"",b=this.getAttribute("aria-describedby")||"",m=s?(this.querySelector('[slot="header"]')?.textContent||"").replace(/\s+/g," ").trim():"",w=!h&&!x&&!!m,p=x||(!h&&!w&&(s||o)?u:""),l=[];b?l.push(b):(n&&l.push(g),l.push(c));const f=h||(w?m:p?"":"Drawer"),d=this.state==="loading";this.setContent(`
|
|
502
|
+
<style>${$}</style>
|
|
503
503
|
<div class="overlay" part="overlay" aria-hidden="true"></div>
|
|
504
|
-
<
|
|
504
|
+
<div
|
|
505
505
|
class="panel side-${t}"
|
|
506
506
|
part="panel"
|
|
507
507
|
role="dialog"
|
|
508
508
|
aria-modal="true"
|
|
509
|
-
${
|
|
510
|
-
${
|
|
511
|
-
${l.length?`aria-describedby="${
|
|
509
|
+
${f?`aria-label="${y(f)}"`:""}
|
|
510
|
+
${p?`aria-labelledby="${y(p)}"`:""}
|
|
511
|
+
${l.length?`aria-describedby="${y(l.join(" "))}"`:""}
|
|
512
512
|
${d?'aria-busy="true"':""}
|
|
513
513
|
tabindex="-1"
|
|
514
514
|
>
|
|
515
|
-
<header class="header ${
|
|
515
|
+
<header class="header ${A?"":"empty"}" part="header">
|
|
516
516
|
<div class="header-main">
|
|
517
517
|
${s?`<slot name="header" id="${u}"></slot>`:""}
|
|
518
|
-
${!s&&o?`<h2 class="title" id="${u}">${
|
|
519
|
-
${n?`<p class="subtitle" id="${
|
|
518
|
+
${!s&&o?`<h2 class="title" id="${u}">${y(o)}</h2>`:""}
|
|
519
|
+
${n?`<p class="subtitle" id="${g}">${y(n)}</p>`:""}
|
|
520
520
|
</div>
|
|
521
521
|
<button
|
|
522
522
|
type="button"
|
|
@@ -532,7 +532,7 @@
|
|
|
532
532
|
</svg>
|
|
533
533
|
</button>
|
|
534
534
|
</header>
|
|
535
|
-
<div class="body" part="body" id="${
|
|
535
|
+
<div class="body" part="body" id="${c}"><slot></slot></div>
|
|
536
536
|
<footer class="footer ${a?"":"empty"}" part="footer"><slot name="footer"></slot></footer>
|
|
537
|
-
</
|
|
538
|
-
`),this._syncLiveUi(),this._isOpen&&this._scheduleEnsureFocusTrap()}_bindGlobalListeners(){this._globalListenersBound||(document.addEventListener("keydown",this._onDocumentKeyDown,!0),document.addEventListener("focusin",this._onDocumentFocusIn,!0),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(document.removeEventListener("keydown",this._onDocumentKeyDown,!0),document.removeEventListener("focusin",this._onDocumentFocusIn,!0),this._globalListenersBound=!1)}}typeof customElements<"u"&&!customElements.get("ui-drawer")&&customElements.define("ui-drawer",
|
|
537
|
+
</div>
|
|
538
|
+
`),this._syncLiveUi(),this._isOpen&&this._scheduleEnsureFocusTrap()}_bindGlobalListeners(){this._globalListenersBound||(document.addEventListener("keydown",this._onDocumentKeyDown,!0),document.addEventListener("focusin",this._onDocumentFocusIn,!0),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(document.removeEventListener("keydown",this._onDocumentKeyDown,!0),document.removeEventListener("focusin",this._onDocumentFocusIn,!0),this._globalListenersBound=!1)}}typeof customElements<"u"&&!customElements.get("ui-drawer")&&customElements.define("ui-drawer",O);exports.UIDrawer=O;
|
package/dist/drawer.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { O as
|
|
3
|
-
function
|
|
1
|
+
import { E as O } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { O as v } from "./overlayManager-BJjU1VA8.mjs";
|
|
3
|
+
function k(i) {
|
|
4
4
|
return typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => i()) : window.setTimeout(i, 16);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function F(i) {
|
|
7
7
|
if (i) {
|
|
8
8
|
if (typeof cancelAnimationFrame == "function") {
|
|
9
9
|
cancelAnimationFrame(i);
|
|
@@ -12,7 +12,7 @@ function _(i) {
|
|
|
12
12
|
window.clearTimeout(i);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const L = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', T = /* @__PURE__ */ new Set([
|
|
16
16
|
"side",
|
|
17
17
|
"dismissible",
|
|
18
18
|
"headless",
|
|
@@ -33,7 +33,7 @@ const E = 'button:not([disabled]), [href], input:not([disabled]), select:not([di
|
|
|
33
33
|
"aria-labelledby",
|
|
34
34
|
"aria-describedby",
|
|
35
35
|
"initial-focus"
|
|
36
|
-
]),
|
|
36
|
+
]), D = `
|
|
37
37
|
:host {
|
|
38
38
|
position: fixed;
|
|
39
39
|
inset: 0;
|
|
@@ -50,7 +50,7 @@ const E = 'button:not([disabled]), [href], input:not([disabled]), select:not([di
|
|
|
50
50
|
color-mix(in srgb, var(--ui-color-surface-elevated, #f8fafc) 20%, var(--ui-color-surface, #ffffff)) 100%
|
|
51
51
|
);
|
|
52
52
|
--ui-drawer-color: var(--ui-color-text, #0f172a);
|
|
53
|
-
--ui-drawer-muted: var(--ui-color-muted, #
|
|
53
|
+
--ui-drawer-muted: var(--ui-color-muted, #526175);
|
|
54
54
|
--ui-drawer-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 74%, transparent);
|
|
55
55
|
--ui-drawer-border: 1px solid var(--ui-drawer-border-color);
|
|
56
56
|
--ui-drawer-shadow: none;
|
|
@@ -405,13 +405,13 @@ const E = 'button:not([disabled]), [href], input:not([disabled]), select:not([di
|
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
:host([tone='success']) {
|
|
408
|
-
--ui-drawer-focus-ring: var(--ui-color-success, #
|
|
409
|
-
--ui-drawer-control-bg-hover: color-mix(in srgb, var(--ui-color-success, #
|
|
408
|
+
--ui-drawer-focus-ring: var(--ui-color-success, #15803d);
|
|
409
|
+
--ui-drawer-control-bg-hover: color-mix(in srgb, var(--ui-color-success, #15803d) 12%, transparent);
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
:host([tone='warning']) {
|
|
413
|
-
--ui-drawer-focus-ring: var(--ui-color-warning, #
|
|
414
|
-
--ui-drawer-control-bg-hover: color-mix(in srgb, var(--ui-color-warning, #
|
|
413
|
+
--ui-drawer-focus-ring: var(--ui-color-warning, #b45309);
|
|
414
|
+
--ui-drawer-control-bg-hover: color-mix(in srgb, var(--ui-color-warning, #b45309) 16%, transparent);
|
|
415
415
|
}
|
|
416
416
|
|
|
417
417
|
:host([state='error']) .panel {
|
|
@@ -419,7 +419,7 @@ const E = 'button:not([disabled]), [href], input:not([disabled]), select:not([di
|
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
:host([state='success']) .panel {
|
|
422
|
-
border-color: color-mix(in srgb, var(--ui-color-success, #
|
|
422
|
+
border-color: color-mix(in srgb, var(--ui-color-success, #15803d) 40%, var(--ui-drawer-border-color));
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
:host([state='loading']) .body {
|
|
@@ -534,25 +534,25 @@ const E = 'button:not([disabled]), [href], input:not([disabled]), select:not([di
|
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
`;
|
|
537
|
-
function
|
|
537
|
+
function _(i, e) {
|
|
538
538
|
if (i == null) return e;
|
|
539
539
|
const t = i.trim().toLowerCase();
|
|
540
540
|
return t !== "false" && t !== "0" && t !== "off";
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function y(i) {
|
|
543
543
|
return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function I(i, e) {
|
|
546
546
|
return i === "top" || i === "bottom" || i === "left" || i === "right" ? i : i === "start" ? e === "rtl" ? "right" : "left" : i === "end" ? e === "rtl" ? "left" : "right" : "left";
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function C(i, e) {
|
|
549
549
|
const t = i.querySelector(`[slot="${e}"]`);
|
|
550
550
|
return t ? t.textContent?.trim().length !== 0 || t.children.length > 0 : !1;
|
|
551
551
|
}
|
|
552
|
-
function
|
|
552
|
+
function S() {
|
|
553
553
|
return typeof window < "u" && typeof document < "u";
|
|
554
554
|
}
|
|
555
|
-
class
|
|
555
|
+
class $ extends O {
|
|
556
556
|
constructor() {
|
|
557
557
|
super(), this._uid = Math.random().toString(36).slice(2, 10), this._isOpen = !1, this._restoreFocusEl = null, this._globalListenersBound = !1, this._closeReason = "programmatic", this._focusInitialFrame = 0, this._focusTrapFrame = 0, this._restoreFocusFrame = 0, this._onRootClick = this._onRootClick.bind(this), this._onDocumentKeyDown = this._onDocumentKeyDown.bind(this), this._onDocumentFocusIn = this._onDocumentFocusIn.bind(this);
|
|
558
558
|
}
|
|
@@ -594,7 +594,7 @@ class T extends I {
|
|
|
594
594
|
this._syncOpenState();
|
|
595
595
|
return;
|
|
596
596
|
}
|
|
597
|
-
if (
|
|
597
|
+
if (T.has(e)) {
|
|
598
598
|
this._syncLiveUi(), this._isOpen && (e === "initial-focus" || e === "dismissible" || e === "show-close") && this._scheduleEnsureFocusTrap();
|
|
599
599
|
return;
|
|
600
600
|
}
|
|
@@ -621,31 +621,31 @@ class T extends I {
|
|
|
621
621
|
}
|
|
622
622
|
get dismissible() {
|
|
623
623
|
const e = this.getAttribute("dismissible");
|
|
624
|
-
return e == null ? !1 :
|
|
624
|
+
return e == null ? !1 : _(e, !0);
|
|
625
625
|
}
|
|
626
626
|
set dismissible(e) {
|
|
627
627
|
e ? this.setAttribute("dismissible", "") : this.removeAttribute("dismissible");
|
|
628
628
|
}
|
|
629
629
|
get closeOnOverlay() {
|
|
630
|
-
return
|
|
630
|
+
return _(this.getAttribute("close-on-overlay"), !0);
|
|
631
631
|
}
|
|
632
632
|
set closeOnOverlay(e) {
|
|
633
633
|
this.setAttribute("close-on-overlay", String(e));
|
|
634
634
|
}
|
|
635
635
|
get closeOnEsc() {
|
|
636
|
-
return
|
|
636
|
+
return _(this.getAttribute("close-on-esc"), !0);
|
|
637
637
|
}
|
|
638
638
|
set closeOnEsc(e) {
|
|
639
639
|
this.setAttribute("close-on-esc", String(e));
|
|
640
640
|
}
|
|
641
641
|
get lockWhileLoading() {
|
|
642
|
-
return
|
|
642
|
+
return _(this.getAttribute("lock-while-loading"), !0);
|
|
643
643
|
}
|
|
644
644
|
set lockWhileLoading(e) {
|
|
645
645
|
this.setAttribute("lock-while-loading", String(e));
|
|
646
646
|
}
|
|
647
647
|
get showClose() {
|
|
648
|
-
return this.hasAttribute("show-close") ?
|
|
648
|
+
return this.hasAttribute("show-close") ? _(this.getAttribute("show-close"), !0) : this.dismissible;
|
|
649
649
|
}
|
|
650
650
|
set showClose(e) {
|
|
651
651
|
this.setAttribute("show-close", String(e));
|
|
@@ -687,10 +687,10 @@ class T extends I {
|
|
|
687
687
|
}
|
|
688
688
|
_resolvedSide() {
|
|
689
689
|
const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr";
|
|
690
|
-
return
|
|
690
|
+
return I(this.getAttribute("side"), e === "rtl" ? "rtl" : "ltr");
|
|
691
691
|
}
|
|
692
692
|
_isTopMost() {
|
|
693
|
-
const e =
|
|
693
|
+
const e = v.top();
|
|
694
694
|
return e ? e === this : !0;
|
|
695
695
|
}
|
|
696
696
|
_isInteractionLocked() {
|
|
@@ -703,7 +703,7 @@ class T extends I {
|
|
|
703
703
|
}
|
|
704
704
|
_isFocusable(e) {
|
|
705
705
|
if (!e || !e.isConnected || e.disabled || e.matches('[inert], [aria-hidden="true"]') || e.closest('[inert], [aria-hidden="true"]')) return !1;
|
|
706
|
-
if (!
|
|
706
|
+
if (!S()) return !0;
|
|
707
707
|
const t = window.getComputedStyle(e);
|
|
708
708
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
709
709
|
}
|
|
@@ -711,23 +711,23 @@ class T extends I {
|
|
|
711
711
|
const e = this._getPanel(), t = [], r = (s) => {
|
|
712
712
|
this._isFocusable(s) && (t.includes(s) || t.push(s));
|
|
713
713
|
};
|
|
714
|
-
return this.querySelectorAll(
|
|
714
|
+
return this.querySelectorAll(L).forEach(r), e && e.querySelectorAll(L).forEach(r), t;
|
|
715
715
|
}
|
|
716
716
|
_cancelScheduledFocusWork() {
|
|
717
|
-
this._focusInitialFrame && (
|
|
717
|
+
this._focusInitialFrame && (F(this._focusInitialFrame), this._focusInitialFrame = 0), this._focusTrapFrame && (F(this._focusTrapFrame), this._focusTrapFrame = 0), this._restoreFocusFrame && (F(this._restoreFocusFrame), this._restoreFocusFrame = 0);
|
|
718
718
|
}
|
|
719
719
|
_scheduleFocusInitial() {
|
|
720
|
-
this._isOpen && (this._focusInitialFrame || (this._focusInitialFrame =
|
|
720
|
+
this._isOpen && (this._focusInitialFrame || (this._focusInitialFrame = k(() => {
|
|
721
721
|
this._focusInitialFrame = 0, this._focusInitial();
|
|
722
722
|
})));
|
|
723
723
|
}
|
|
724
724
|
_scheduleEnsureFocusTrap() {
|
|
725
|
-
this._isOpen && (this._focusTrapFrame || (this._focusTrapFrame =
|
|
725
|
+
this._isOpen && (this._focusTrapFrame || (this._focusTrapFrame = k(() => {
|
|
726
726
|
this._focusTrapFrame = 0, this._ensureFocusTrap();
|
|
727
727
|
})));
|
|
728
728
|
}
|
|
729
729
|
_scheduleRestoreFocus(e) {
|
|
730
|
-
!e || !this._canRestoreFocus(e) || (this._restoreFocusFrame &&
|
|
730
|
+
!e || !this._canRestoreFocus(e) || (this._restoreFocusFrame && F(this._restoreFocusFrame), this._restoreFocusFrame = k(() => {
|
|
731
731
|
this._restoreFocusFrame = 0;
|
|
732
732
|
try {
|
|
733
733
|
this._canRestoreFocus(e) && e.focus({ preventScroll: !0 });
|
|
@@ -746,14 +746,14 @@ class T extends I {
|
|
|
746
746
|
r.classList.remove("side-left", "side-right", "side-top", "side-bottom"), r.classList.add(`side-${o}`);
|
|
747
747
|
const n = this.state === "loading";
|
|
748
748
|
n ? r.setAttribute("aria-busy", "true") : r.removeAttribute("aria-busy");
|
|
749
|
-
const
|
|
750
|
-
r.setAttribute("role",
|
|
751
|
-
const u = (this.getAttribute("title") || "").trim(),
|
|
752
|
-
s && s.classList.toggle("empty", !x), a && (a.hidden = !
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
const
|
|
756
|
-
|
|
749
|
+
const A = this.getAttribute("role") || "dialog";
|
|
750
|
+
r.setAttribute("role", A);
|
|
751
|
+
const u = (this.getAttribute("title") || "").trim(), g = (this.getAttribute("description") || "").trim(), c = C(this, "header"), h = this.showClose, x = h || c || !!u || !!g;
|
|
752
|
+
s && s.classList.toggle("empty", !x), a && (a.hidden = !h, a.disabled = n && this.lockWhileLoading);
|
|
753
|
+
const p = this.getAttribute("aria-label") || "", m = this.getAttribute("aria-labelledby") || "", w = this.getAttribute("aria-describedby") || "", b = c ? (this.querySelector('[slot="header"]')?.textContent || "").replace(/\s+/g, " ").trim() : "", l = !p && !m && !!b, f = m || (!p && !l && (c || u) ? this._titleId() : ""), d = [];
|
|
754
|
+
w ? d.push(w) : (g && d.push(this._descriptionId()), d.push(this._bodyId()));
|
|
755
|
+
const E = p || (l ? b : f ? "" : "Drawer");
|
|
756
|
+
E ? r.setAttribute("aria-label", E) : r.removeAttribute("aria-label"), f ? r.setAttribute("aria-labelledby", f) : r.removeAttribute("aria-labelledby"), d.length ? r.setAttribute("aria-describedby", d.join(" ")) : r.removeAttribute("aria-describedby");
|
|
757
757
|
}
|
|
758
758
|
_focusInitial() {
|
|
759
759
|
if (!this._isOpen) return;
|
|
@@ -792,13 +792,13 @@ class T extends I {
|
|
|
792
792
|
}
|
|
793
793
|
_releaseOpenResources() {
|
|
794
794
|
try {
|
|
795
|
-
|
|
795
|
+
v.unregister(this), v.releaseLock();
|
|
796
796
|
} catch {
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
_canRestoreFocus(e) {
|
|
800
800
|
if (!e || !e.isConnected || e.disabled) return !1;
|
|
801
|
-
if (!
|
|
801
|
+
if (!S()) return !0;
|
|
802
802
|
const t = window.getComputedStyle(e);
|
|
803
803
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
804
804
|
}
|
|
@@ -811,7 +811,7 @@ class T extends I {
|
|
|
811
811
|
if (this._isOpen = e, e) {
|
|
812
812
|
this._cancelScheduledFocusWork(), this._bindGlobalListeners(), this._restoreFocusEl = document.activeElement || null, this._closeReason = "programmatic";
|
|
813
813
|
try {
|
|
814
|
-
|
|
814
|
+
v.register(this), v.acquireLock();
|
|
815
815
|
} catch {
|
|
816
816
|
}
|
|
817
817
|
this._scheduleFocusInitial(), this._scheduleEnsureFocusTrap(), this.dispatchEvent(new CustomEvent("open", { bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("show", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
@@ -918,28 +918,28 @@ class T extends I {
|
|
|
918
918
|
t && this._isNodeInsideDrawer(t) || s.includes(this) || r && s.includes(r) || this._scheduleFocusInitial();
|
|
919
919
|
}
|
|
920
920
|
render() {
|
|
921
|
-
const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr", t =
|
|
922
|
-
|
|
923
|
-
const
|
|
921
|
+
const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr", t = I(this.getAttribute("side"), e === "rtl" ? "rtl" : "ltr"), r = this.showClose, s = C(this, "header"), a = C(this, "footer"), o = (this.getAttribute("title") || "").trim(), n = (this.getAttribute("description") || "").trim(), A = r || s || !!o || !!n, u = `ui-drawer-title-${this._uid}`, g = `ui-drawer-description-${this._uid}`, c = `ui-drawer-body-${this._uid}`, h = this.getAttribute("aria-label") || "", x = this.getAttribute("aria-labelledby") || "", p = this.getAttribute("aria-describedby") || "", m = s ? (this.querySelector('[slot="header"]')?.textContent || "").replace(/\s+/g, " ").trim() : "", w = !h && !x && !!m, b = x || (!h && !w && (s || o) ? u : ""), l = [];
|
|
922
|
+
p ? l.push(p) : (n && l.push(g), l.push(c));
|
|
923
|
+
const f = h || (w ? m : b ? "" : "Drawer"), d = this.state === "loading";
|
|
924
924
|
this.setContent(`
|
|
925
|
-
<style>${
|
|
925
|
+
<style>${D}</style>
|
|
926
926
|
<div class="overlay" part="overlay" aria-hidden="true"></div>
|
|
927
|
-
<
|
|
927
|
+
<div
|
|
928
928
|
class="panel side-${t}"
|
|
929
929
|
part="panel"
|
|
930
930
|
role="dialog"
|
|
931
931
|
aria-modal="true"
|
|
932
|
-
${
|
|
933
|
-
${
|
|
934
|
-
${l.length ? `aria-describedby="${
|
|
932
|
+
${f ? `aria-label="${y(f)}"` : ""}
|
|
933
|
+
${b ? `aria-labelledby="${y(b)}"` : ""}
|
|
934
|
+
${l.length ? `aria-describedby="${y(l.join(" "))}"` : ""}
|
|
935
935
|
${d ? 'aria-busy="true"' : ""}
|
|
936
936
|
tabindex="-1"
|
|
937
937
|
>
|
|
938
|
-
<header class="header ${
|
|
938
|
+
<header class="header ${A ? "" : "empty"}" part="header">
|
|
939
939
|
<div class="header-main">
|
|
940
940
|
${s ? `<slot name="header" id="${u}"></slot>` : ""}
|
|
941
|
-
${!s && o ? `<h2 class="title" id="${u}">${
|
|
942
|
-
${n ? `<p class="subtitle" id="${
|
|
941
|
+
${!s && o ? `<h2 class="title" id="${u}">${y(o)}</h2>` : ""}
|
|
942
|
+
${n ? `<p class="subtitle" id="${g}">${y(n)}</p>` : ""}
|
|
943
943
|
</div>
|
|
944
944
|
<button
|
|
945
945
|
type="button"
|
|
@@ -955,9 +955,9 @@ class T extends I {
|
|
|
955
955
|
</svg>
|
|
956
956
|
</button>
|
|
957
957
|
</header>
|
|
958
|
-
<div class="body" part="body" id="${
|
|
958
|
+
<div class="body" part="body" id="${c}"><slot></slot></div>
|
|
959
959
|
<footer class="footer ${a ? "" : "empty"}" part="footer"><slot name="footer"></slot></footer>
|
|
960
|
-
</
|
|
960
|
+
</div>
|
|
961
961
|
`), this._syncLiveUi(), this._isOpen && this._scheduleEnsureFocusTrap();
|
|
962
962
|
}
|
|
963
963
|
_bindGlobalListeners() {
|
|
@@ -967,7 +967,7 @@ class T extends I {
|
|
|
967
967
|
this._globalListenersBound && (document.removeEventListener("keydown", this._onDocumentKeyDown, !0), document.removeEventListener("focusin", this._onDocumentFocusIn, !0), this._globalListenersBound = !1);
|
|
968
968
|
}
|
|
969
969
|
}
|
|
970
|
-
typeof customElements < "u" && !customElements.get("ui-drawer") && customElements.define("ui-drawer",
|
|
970
|
+
typeof customElements < "u" && !customElements.get("ui-drawer") && customElements.define("ui-drawer", $);
|
|
971
971
|
export {
|
|
972
|
-
|
|
972
|
+
$ as UIDrawer
|
|
973
973
|
};
|
package/dist/dropdown.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./ElementBase-EV6mVBUV.js"),y=require("./menu-item-styles-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./ElementBase-EV6mVBUV.js"),y=require("./trigger-DkPsKxsP.js"),k=require("./menu-item-styles-B4onAr4C.js"),l=['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]',".item","[data-menu-item]"].join(", "),A=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-dropdown-bg: var(
|
|
4
4
|
--ui-dropdown-menu-bg,
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
.menu[data-tone='neutral'] {
|
|
246
|
-
--ui-dropdown-ring: color-mix(in srgb, var(--ui-color-muted, #
|
|
246
|
+
--ui-dropdown-ring: color-mix(in srgb, var(--ui-color-muted, #526175) 60%, var(--ui-dropdown-color));
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
.menu[data-tone='danger'] {
|
|
@@ -254,20 +254,20 @@
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
.menu[data-tone='success'] {
|
|
257
|
-
--ui-dropdown-ring: var(--ui-color-success, #
|
|
258
|
-
--ui-dropdown-item-hover-bg: color-mix(in srgb, var(--ui-color-success, #
|
|
259
|
-
--ui-dropdown-item-active-bg: color-mix(in srgb, var(--ui-color-success, #
|
|
260
|
-
--ui-dropdown-item-checked-bg: color-mix(in srgb, var(--ui-color-success, #
|
|
257
|
+
--ui-dropdown-ring: var(--ui-color-success, #15803d);
|
|
258
|
+
--ui-dropdown-item-hover-bg: color-mix(in srgb, var(--ui-color-success, #15803d) 12%, transparent);
|
|
259
|
+
--ui-dropdown-item-active-bg: color-mix(in srgb, var(--ui-color-success, #15803d) 18%, transparent);
|
|
260
|
+
--ui-dropdown-item-checked-bg: color-mix(in srgb, var(--ui-color-success, #15803d) 16%, transparent);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
.menu[data-tone='warning'] {
|
|
264
|
-
--ui-dropdown-ring: var(--ui-color-warning, #
|
|
265
|
-
--ui-dropdown-item-hover-bg: color-mix(in srgb, var(--ui-color-warning, #
|
|
266
|
-
--ui-dropdown-item-active-bg: color-mix(in srgb, var(--ui-color-warning, #
|
|
267
|
-
--ui-dropdown-item-checked-bg: color-mix(in srgb, var(--ui-color-warning, #
|
|
264
|
+
--ui-dropdown-ring: var(--ui-color-warning, #b45309);
|
|
265
|
+
--ui-dropdown-item-hover-bg: color-mix(in srgb, var(--ui-color-warning, #b45309) 15%, transparent);
|
|
266
|
+
--ui-dropdown-item-active-bg: color-mix(in srgb, var(--ui-color-warning, #b45309) 20%, transparent);
|
|
267
|
+
--ui-dropdown-item-checked-bg: color-mix(in srgb, var(--ui-color-warning, #b45309) 17%, transparent);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
${
|
|
270
|
+
${k.createSharedMenuItemCss({scopes:[".menu"],prefix:"--ui-dropdown",shortcutSelectors:[".shortcut",".meta"],activeStateSelectors:['.item[data-active="true"]','[role="menuitem"][data-active="true"]','[role="menuitemcheckbox"][data-active="true"]','[role="menuitemradio"][data-active="true"]','[data-menu-item][data-active="true"]']})}
|
|
271
271
|
|
|
272
272
|
.menu [role='menuitem'],
|
|
273
273
|
.menu [role='menuitemcheckbox'],
|
|
@@ -488,8 +488,8 @@
|
|
|
488
488
|
color: HighlightText;
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
|
-
`;function A(i){return i==="top"||i==="left"||i==="right"?i:"bottom"}function S(i){const e=(i||"").trim().toLowerCase();return e==="sm"||e==="1"||e==="compact"?"sm":e==="lg"||e==="3"||e==="comfortable"?"lg":"md"}function C(i){const e=(i||"").trim().toLowerCase();return!e||e==="default"?null:e==="none"?"0px":e==="sm"?"8px":e==="md"?"12px":e==="lg"||e==="large"?"16px":e==="full"||e==="pill"?"999px":e==="square"?"6px":e==="soft"||e==="rounded"?"14px":/^\d+(\.\d+)?$/.test(e)?`${e}px`:/^\d+(\.\d+)?(px|rem|em|%)$/.test(e)?e:i}function h(i,e){return i.getAttribute(e)||""}function f(i,e){if(i==null)return e;const t=i.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}function p(){return typeof window<"u"&&typeof document<"u"}function b(i){return i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true"||i.disabled===!0}function E(i){return(i.getAttribute("aria-label")||i.textContent||"").trim()}function g(i){if(i)try{i.focus({preventScroll:!0})}catch{i.focus()}}function I(i,e){const t=i.offsetTop,r=t+i.offsetHeight,o=e.scrollTop,a=o+e.clientHeight;if(t<o){e.scrollTop=t;return}r>a&&(e.scrollTop=Math.max(0,r-e.clientHeight))}function T(i){return w(i)}function w(i){if(i.nodeType===Node.TEXT_NODE)return document.createTextNode(i.textContent||"");if(!(i instanceof HTMLElement))return i.cloneNode(!1);const e=i.tagName==="UI-BOX",t=document.createElement(e?"div":i.tagName.toLowerCase());return Array.from(i.attributes).forEach(r=>{r.name!=="slot"&&t.setAttribute(r.name,r.value)}),Array.from(i.childNodes).forEach(r=>{t.appendChild(w(r))}),t}function M(i,e,t){for(let r=e+t;r>=0&&r<i.length;r+=t)if(!b(i[r]))return r;return-1}function O(i,e,t){if(!e)return null;const r=i.filter(a=>!b(a));if(!r.length)return null;const o=t?r.indexOf(t):-1;for(let a=1;a<=r.length;a+=1){const n=r[(o+a+r.length)%r.length];if(E(n).toLowerCase().startsWith(e))return n}return null}const P=new Set(["variant","density","shape","elevation","tone","size","radius"]),D=new Set(["aria-label","aria-labelledby","aria-describedby"]),F=["--ui-dropdown-bg","--ui-dropdown-color","--ui-dropdown-muted","--ui-dropdown-border-color","--ui-dropdown-border","--ui-dropdown-shadow","--ui-dropdown-radius","--ui-dropdown-padding","--ui-dropdown-min-width","--ui-dropdown-gap","--ui-dropdown-ring","--ui-dropdown-backdrop","--ui-dropdown-item-radius","--ui-dropdown-item-font-weight","--ui-dropdown-item-hover-bg","--ui-dropdown-item-active-bg","--ui-dropdown-item-checked-bg","--ui-dropdown-item-active-color","--ui-dropdown-duration","--ui-dropdown-easing"];class _ extends x.ElementBase{constructor(){super(),this._isOpen=!1,this._panelEl=null,this._portalEl=null,this._restoreFocusEl=null,this._typeaheadBuffer="",this._typeaheadTimer=null,this._placement="bottom",this._openListenersBound=!1,this._openFrame=0,this._checkboxState=new Map,this._radioState=new Map,this._menuId=`ui-dropdown-menu-${Math.random().toString(36).slice(2,10)}`,this._triggerId=`ui-dropdown-trigger-${Math.random().toString(36).slice(2,10)}`,this._onHostClick=this._onHostClick.bind(this),this._onHostKeyDown=this._onHostKeyDown.bind(this),this._onDocumentPointerDown=this._onDocumentPointerDown.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["open","disabled","placement","variant","size","density","radius","shape","elevation","tone","close-on-select","close-on-scroll","typeahead","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onHostClick),this.addEventListener("keydown",this._onHostKeyDown),this.root.addEventListener("slotchange",this._onSlotChange),this._syncOpenState(),this._syncTriggerA11y()}disconnectedCallback(){this.removeEventListener("click",this._onHostClick),this.removeEventListener("keydown",this._onHostKeyDown),this.root.removeEventListener("slotchange",this._onSlotChange),this._teardownOpenListeners(),this._openFrame&&cancelAnimationFrame(this._openFrame),super.disconnectedCallback()}attributeChangedCallback(e,t,r){if(t!==r){if(e==="open"){this._syncOpenState();return}if(!(e==="close-on-select"||e==="close-on-scroll"||e==="typeahead")){if(e==="disabled"){this.hasAttribute("disabled")&&this._isOpen&&this.close("disabled"),this._syncTriggerA11y();return}if(this._isOpen&&(e==="placement"||P.has(e))){this._syncMenuPresentation(),this._schedulePanelSync();return}this._isOpen&&D.has(e)&&this._syncMenuA11y()}}}open(){this.hasAttribute("disabled")||this.hasAttribute("open")||this.setAttribute("open","")}close(e="programmatic"){!this.hasAttribute("open")&&!this._isOpen||this._close(e)}closeDropdown(e="programmatic"){if(!(!this.hasAttribute("open")&&!this._isOpen)){if(e==="programmatic"){this.close(e);return}this._requestClose(e)}}toggle(){if(this._isOpen){this._requestClose("trigger");return}this.open()}get closeOnSelect(){return f(this.getAttribute("close-on-select"),!0)}set closeOnSelect(e){this.setAttribute("close-on-select",e?"true":"false")}get closeOnScroll(){return f(this.getAttribute("close-on-scroll"),!0)}set closeOnScroll(e){this.setAttribute("close-on-scroll",e?"true":"false")}get typeahead(){return f(this.getAttribute("typeahead"),!0)}set typeahead(e){this.setAttribute("typeahead",e?"true":"false")}_getTrigger(){return this.querySelector('[slot="trigger"]')}_getContentSource(){return this.querySelector('[slot="content"]')}_getMenu(){return this._portalEl}_isFocusable(e){if(!e||!e.isConnected||e.disabled||e.getAttribute("aria-hidden")==="true")return!1;if(!p())return!0;const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}_currentFocusedItem(){const e=this.root.activeElement||document.activeElement;return e instanceof HTMLElement?e.closest(l):null}_queryItems(e=!0){const t=this._getMenu();if(!t)return[];const r=Array.from(t.querySelectorAll(l));return e?r:r.filter(o=>!b(o))}_requestClose(e){if(!this._isOpen)return;const t=new CustomEvent("request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t);const r=new CustomEvent("ui-request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(r),!(t.defaultPrevented||r.defaultPrevented)&&this.close(e)}_close(e,t={}){if(this._openFrame&&cancelAnimationFrame(this._openFrame),this._openFrame=0,this._isOpen=!1,this._teardownOpenListeners(),this.hasAttribute("open")&&this.removeAttribute("open"),this._syncControlState(),this._syncTriggerA11y(),this._clearActiveItem(),this._clearMenuContent(),this._resetTypeahead(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:e}})),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:e}})),t.restoreFocus!==!1){const r=this._getTrigger();r&&this._isFocusable(r)?g(r):this._restoreFocusEl&&this._isFocusable(this._restoreFocusEl)&&g(this._restoreFocusEl)}this._restoreFocusEl=null}_syncOpenState(){const e=this.hasAttribute("open")&&!this.hasAttribute("disabled");if(e===this._isOpen){this._syncControlState(),this._syncTriggerA11y(),e&&(this._syncMenuPresentation(),this._syncMenuA11y(),this._schedulePanelSync());return}if(e){this._isOpen=!0,this._restoreFocusEl=document.activeElement,this._renderMenuContent(),this._syncMenuPresentation(),this._syncMenuA11y(),this._syncControlState(),this._syncTriggerA11y(),this._attachOpenListeners(),this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0}})),this._schedulePanelSync("first");return}this._close("programmatic",{restoreFocus:!1})}_attachOpenListeners(){this._openListenersBound||(document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),this._openListenersBound=!0)}_teardownOpenListeners(){this._openListenersBound&&(document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),this._openListenersBound=!1)}_syncTriggerA11y(){const e=this._getTrigger();if(e){if(e.id||(e.id=this._triggerId),e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded",this._isOpen?"true":"false"),this._isOpen?e.setAttribute("aria-controls",this._menuId):e.removeAttribute("aria-controls"),this.hasAttribute("disabled")){e.setAttribute("aria-disabled","true"),e.setAttribute("tabindex","-1");return}e.getAttribute("aria-disabled")==="true"&&e.removeAttribute("aria-disabled"),e.getAttribute("tabindex")==="-1"&&e.removeAttribute("tabindex")}}_renderMenuContent(){const e=this._getMenu();if(!e)return;e.replaceChildren();const t=this._getContentSource();if(t&&e.appendChild(T(t)),!e.querySelector(l)){const r=document.createElement("div");r.className="empty-state",r.textContent="No items",e.appendChild(r)}this._syncMenuItemSemantics()}_syncMenuItemSemantics(){this._queryItems(!0).forEach((e,t)=>{e.getAttribute("role")||e.setAttribute("role","menuitem"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.dataset.sourceIndex=String(t),e.hasAttribute("disabled")&&e.getAttribute("aria-disabled")!=="true"&&e.setAttribute("aria-disabled","true");const r=e.getAttribute("role");(r==="menuitemcheckbox"||r==="menuitemradio")&&!e.hasAttribute("aria-checked")&&e.setAttribute("aria-checked","false"),this._applyStoredItemState(e,t)})}_clearMenuContent(){const e=this._getMenu();e&&e.replaceChildren()}_applyStoredItemState(e,t){const r=e.getAttribute("role");if(r==="menuitemcheckbox"){if(!this._checkboxState.has(t))return;const n=this._checkboxState.get(t)===!0;e.setAttribute("aria-checked",n?"true":"false"),e.setAttribute("data-state",n?"checked":"unchecked");return}if(r!=="menuitemradio")return;const o=e.getAttribute("data-group")||e.getAttribute("name")||"__default__";if(!this._radioState.has(o))return;const a=this._radioState.get(o)===t;e.setAttribute("aria-checked",a?"true":"false"),e.setAttribute("data-state",a?"checked":"unchecked")}_syncMenuPresentation(){const e=this._getMenu();if(!e)return;const t=p()?window.getComputedStyle(this):null;t&&F.forEach(c=>{const m=t.getPropertyValue(c).trim();m?e.style.setProperty(c,m):e.style.removeProperty(c)});const r=h(this,"variant"),o=S(this.getAttribute("size")||this.getAttribute("density")),a=h(this,"density"),n=h(this,"shape"),u=h(this,"elevation"),s=h(this,"tone"),d=C(this.getAttribute("radius")||n||null);if(r&&r!=="default"?e.setAttribute("data-variant",r):e.removeAttribute("data-variant"),o!=="md"?e.setAttribute("data-size",o):e.removeAttribute("data-size"),a&&a!=="default"?e.setAttribute("data-density",a):e.removeAttribute("data-density"),n&&n!=="default"?e.setAttribute("data-shape",n):e.removeAttribute("data-shape"),u&&u!=="default"?e.setAttribute("data-elevation",u):e.removeAttribute("data-elevation"),s&&s!=="default"&&s!=="brand"?e.setAttribute("data-tone",s):e.removeAttribute("data-tone"),d){e.style.setProperty("--ui-dropdown-radius",d),e.style.setProperty("--ui-dropdown-item-radius",d==="999px"?"999px":`max(0px, calc(${d} - 2px))`);return}e.style.removeProperty("--ui-dropdown-radius"),e.style.removeProperty("--ui-dropdown-item-radius")}_syncMenuA11y(){const e=this._getMenu();if(!e)return;const t=this._getTrigger(),r=this.getAttribute("aria-label")||"",o=this.getAttribute("aria-labelledby")||"",a=this.getAttribute("aria-describedby")||"",n=o||(!r&&t?.id?t.id:"");r?e.setAttribute("aria-label",r):e.removeAttribute("aria-label"),n?e.setAttribute("aria-labelledby",n):e.removeAttribute("aria-labelledby"),a?e.setAttribute("aria-describedby",a):e.removeAttribute("aria-describedby")}_syncControlState(){const e=this._panelEl,t=this._getMenu();!e||!t||(e.hidden=!this._isOpen,e.setAttribute("data-placement",this._placement))}_schedulePanelSync(e){this._openFrame&&cancelAnimationFrame(this._openFrame),this._openFrame=requestAnimationFrame(()=>{this._openFrame=0,this._syncPanelState(),e==="first"&&this._focusFirstItem(),e==="last"&&this._focusLastItem()})}_syncPanelState(){const e=this._panelEl;!e||!this._isOpen||(this._placement=this._resolvePlacement(),e.setAttribute("data-placement",this._placement),this.style.setProperty("--ui-dropdown-available-width",`${Math.max(0,Math.floor(this._availableWidth(this._placement)))}px`),this.style.setProperty("--ui-dropdown-available-height",`${Math.max(0,Math.floor(this._availableHeight(this._placement)))}px`))}_availableWidth(e){const t=this._getTrigger();if(!t||!p())return 380;const r=t.getBoundingClientRect(),o=window.innerWidth||document.documentElement.clientWidth||0;return e==="left"?r.left-12:e==="right"?o-r.right-12:o-r.left-12}_availableHeight(e){const t=this._getTrigger();if(!t||!p())return 440;const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight||0;return e==="top"?r.top-12:o-r.bottom-12}_resolvePlacement(){const e=A(this.getAttribute("placement")),t=this._getTrigger(),r=this._getMenu();if(!t||!r||!p())return e;const o=t.getBoundingClientRect(),a=window.innerWidth||document.documentElement.clientWidth||0,n=window.innerHeight||document.documentElement.clientHeight||0,u=Math.max(0,n-o.bottom-12),s=Math.max(0,o.top-12),d=Math.max(0,a-o.right-12),c=Math.max(0,o.left-12),m=Math.min(Math.max(r.scrollHeight,r.offsetHeight)+4,320),v=Math.min(Math.max(r.scrollWidth,r.offsetWidth)+4,360);return e==="top"?s>=m||s>u?"top":"bottom":e==="left"?c>=v||c>d?"left":"right":e==="right"?d>=v||d>=c?"right":"left":u>=m||u>=s?"bottom":"top"}_clearActiveItem(){this._queryItems(!0).forEach(e=>e.removeAttribute("data-active"))}_setActiveItem(e,t={}){if(this._clearActiveItem(),!!e&&(e.setAttribute("data-active","true"),t.focus&&g(e),t.scroll)){const r=this._getMenu();r&&I(e,r)}}_focusFirstItem(){const e=this._queryItems(!1);this._setActiveItem(e[0]||null,{focus:!0,scroll:!0})}_focusLastItem(){const e=this._queryItems(!1);this._setActiveItem(e[e.length-1]||null,{focus:!0,scroll:!0})}_moveFocus(e){const t=this._queryItems(!0);if(!t.length)return;const r=this._currentFocusedItem()||this._queryItems(!0).find(n=>n.getAttribute("data-active")==="true")||null,o=r?t.indexOf(r):e>0?-1:t.length,a=M(t,o,e);if(a>=0){this._setActiveItem(t[a],{focus:!0,scroll:!0});return}e>0?this._focusFirstItem():this._focusLastItem()}_resetTypeahead(){this._typeaheadBuffer="",this._typeaheadTimer!=null&&(window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null)}_isTypeaheadKey(e){return e.ctrlKey||e.metaKey||e.altKey?!1:e.key.length===1&&/\S/.test(e.key)}_handleTypeahead(e){if(!this.typeahead||!this._isTypeaheadKey(e))return!1;const t=e.key.toLowerCase();this._typeaheadBuffer=`${this._typeaheadBuffer}${t}`.slice(0,24),this._typeaheadTimer!=null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>this._resetTypeahead(),460);const r=O(this._queryItems(!0),this._typeaheadBuffer,this._currentFocusedItem());return r?(this._setActiveItem(r,{focus:!0,scroll:!0}),e.preventDefault(),!0):!1}_querySourceItems(){const e=this._getContentSource();return e?Array.from(e.querySelectorAll(l)):[]}_applySelectionBehavior(e){const t=e.getAttribute("role"),r=Number(e.dataset.sourceIndex||"-1");if(t==="menuitemcheckbox"){const n=e.getAttribute("aria-checked")!=="true";e.setAttribute("aria-checked",n?"true":"false"),e.setAttribute("data-state",n?"checked":"unchecked"),r>=0&&this._checkboxState.set(r,n);return}if(t!=="menuitemradio")return;const a=e.getAttribute("data-group")||e.getAttribute("name")||""||"__default__";r>=0&&this._radioState.set(a,r),this._queryItems(!0).filter(n=>n.getAttribute("role")==="menuitemradio").forEach(n=>{if((n.getAttribute("data-group")||n.getAttribute("name")||""||"__default__")!==a)return;const s=n===e;n.setAttribute("aria-checked",s?"true":"false"),n.setAttribute("data-state",s?"checked":"unchecked")})}_findMenuItemFromEvent(e){const t=typeof e.composedPath=="function"?e.composedPath():[];for(const o of t)if(o instanceof HTMLElement&&o.matches(l))return o;const r=e.target;return r instanceof HTMLElement?r.closest(l):null}_isEventInsideTrigger(e){const t=this._getTrigger();return t?(typeof e.composedPath=="function"?e.composedPath():[]).includes(t):!1}_emitSelect(e){const t={value:e.getAttribute("data-value")||e.getAttribute("value")||void 0,label:e.getAttribute("aria-label")||e.textContent?.trim()||void 0,checked:e.getAttribute("aria-checked")==="true",item:e};this.dispatchEvent(new CustomEvent("select",{bubbles:!0,composed:!0,detail:t}))}_onHostClick(e){if(this.hasAttribute("disabled"))return;const t=this._isOpen?this._findMenuItemFromEvent(e):null;if(t&&this._getMenu()?.contains(t)&&!b(t)){this._applySelectionBehavior(t),this._setActiveItem(t,{focus:!0,scroll:!0}),this._emitSelect(t),this.closeOnSelect&&this._requestClose("select");return}if(this._isEventInsideTrigger(e)){if(e.preventDefault(),this._isOpen){this._requestClose("trigger");return}this.open()}}_onHostKeyDown(e){if(!this._isOpen){if(!this._isEventInsideTrigger(e)||!["ArrowDown","ArrowUp","Enter"," "].includes(e.key))return;e.preventDefault(),this.open(),this._schedulePanelSync(e.key==="ArrowUp"?"last":"first");return}if(!this._handleTypeahead(e)){if(e.key==="Escape"){e.preventDefault(),this._requestClose("escape");return}if(e.key==="ArrowDown"){e.preventDefault(),this._moveFocus(1);return}if(e.key==="ArrowUp"){e.preventDefault(),this._moveFocus(-1);return}if(e.key==="Home"){e.preventDefault(),this._focusFirstItem();return}if(e.key==="End"){e.preventDefault(),this._focusLastItem();return}if(e.key==="Tab"){this._requestClose("tab");return}if(e.key==="Enter"||e.key===" "){const t=this._currentFocusedItem();if(!t||!this._getMenu()?.contains(t)||b(t))return;e.preventDefault(),t.click()}}}_onDocumentPointerDown(e){!this._isOpen||(typeof e.composedPath=="function"?e.composedPath():[]).includes(this)||this._requestClose("outside")}_onSlotChange(){this._syncTriggerA11y(),this._isOpen&&(this._renderMenuContent(),this._syncMenuPresentation(),this._syncMenuA11y(),this._schedulePanelSync())}render(){this.setContent(`
|
|
492
|
-
<style>${
|
|
491
|
+
`;function S(i){return i==="top"||i==="left"||i==="right"?i:"bottom"}function C(i){const e=(i||"").trim().toLowerCase();return e==="sm"||e==="1"||e==="compact"?"sm":e==="lg"||e==="3"||e==="comfortable"?"lg":"md"}function E(i){const e=(i||"").trim().toLowerCase();return!e||e==="default"?null:e==="none"?"0px":e==="sm"?"8px":e==="md"?"12px":e==="lg"||e==="large"?"16px":e==="full"||e==="pill"?"999px":e==="square"?"6px":e==="soft"||e==="rounded"?"14px":/^\d+(\.\d+)?$/.test(e)?`${e}px`:/^\d+(\.\d+)?(px|rem|em|%)$/.test(e)?e:i}function p(i,e){return i.getAttribute(e)||""}function f(i,e){if(i==null)return e;const t=i.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}function h(){return typeof window<"u"&&typeof document<"u"}function b(i){return i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true"||i.disabled===!0}function I(i){return(i.getAttribute("aria-label")||i.textContent||"").trim()}function g(i){if(i)try{i.focus({preventScroll:!0})}catch{i.focus()}}function T(i,e){const t=i.offsetTop,r=t+i.offsetHeight,o=e.scrollTop,a=o+e.clientHeight;if(t<o){e.scrollTop=t;return}r>a&&(e.scrollTop=Math.max(0,r-e.clientHeight))}function M(i){return w(i)}function w(i){if(i.nodeType===Node.TEXT_NODE)return document.createTextNode(i.textContent||"");if(!(i instanceof HTMLElement))return i.cloneNode(!1);const e=i.tagName==="UI-BOX",t=document.createElement(e?"div":i.tagName.toLowerCase());return Array.from(i.attributes).forEach(r=>{r.name!=="slot"&&t.setAttribute(r.name,r.value)}),Array.from(i.childNodes).forEach(r=>{t.appendChild(w(r))}),t}function O(i,e,t){for(let r=e+t;r>=0&&r<i.length;r+=t)if(!b(i[r]))return r;return-1}function P(i,e,t){if(!e)return null;const r=i.filter(a=>!b(a));if(!r.length)return null;const o=t?r.indexOf(t):-1;for(let a=1;a<=r.length;a+=1){const n=r[(o+a+r.length)%r.length];if(I(n).toLowerCase().startsWith(e))return n}return null}const D=new Set(["variant","density","shape","elevation","tone","size","radius"]),F=new Set(["aria-label","aria-labelledby","aria-describedby"]),L=["--ui-dropdown-bg","--ui-dropdown-color","--ui-dropdown-muted","--ui-dropdown-border-color","--ui-dropdown-border","--ui-dropdown-shadow","--ui-dropdown-radius","--ui-dropdown-padding","--ui-dropdown-min-width","--ui-dropdown-gap","--ui-dropdown-ring","--ui-dropdown-backdrop","--ui-dropdown-item-radius","--ui-dropdown-item-font-weight","--ui-dropdown-item-hover-bg","--ui-dropdown-item-active-bg","--ui-dropdown-item-checked-bg","--ui-dropdown-item-active-color","--ui-dropdown-duration","--ui-dropdown-easing"];class _ extends x.ElementBase{constructor(){super(),this._isOpen=!1,this._panelEl=null,this._portalEl=null,this._restoreFocusEl=null,this._typeaheadBuffer="",this._typeaheadTimer=null,this._placement="bottom",this._openListenersBound=!1,this._openFrame=0,this._checkboxState=new Map,this._radioState=new Map,this._menuId=`ui-dropdown-menu-${Math.random().toString(36).slice(2,10)}`,this._triggerId=`ui-dropdown-trigger-${Math.random().toString(36).slice(2,10)}`,this._onHostClick=this._onHostClick.bind(this),this._onHostKeyDown=this._onHostKeyDown.bind(this),this._onDocumentPointerDown=this._onDocumentPointerDown.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["open","disabled","placement","variant","size","density","radius","shape","elevation","tone","close-on-select","close-on-scroll","typeahead","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onHostClick),this.addEventListener("keydown",this._onHostKeyDown),this.root.addEventListener("slotchange",this._onSlotChange),this._syncOpenState(),this._syncTriggerA11y()}disconnectedCallback(){this.removeEventListener("click",this._onHostClick),this.removeEventListener("keydown",this._onHostKeyDown),this.root.removeEventListener("slotchange",this._onSlotChange),this._teardownOpenListeners(),this._openFrame&&cancelAnimationFrame(this._openFrame),super.disconnectedCallback()}attributeChangedCallback(e,t,r){if(t!==r){if(e==="open"){this._syncOpenState();return}if(!(e==="close-on-select"||e==="close-on-scroll"||e==="typeahead")){if(e==="disabled"){this.hasAttribute("disabled")&&this._isOpen&&this.close("disabled"),this._syncTriggerA11y();return}if(this._isOpen&&(e==="placement"||D.has(e))){this._syncMenuPresentation(),this._schedulePanelSync();return}this._isOpen&&F.has(e)&&this._syncMenuA11y()}}}open(){this.hasAttribute("disabled")||this.hasAttribute("open")||this.setAttribute("open","")}close(e="programmatic"){!this.hasAttribute("open")&&!this._isOpen||this._close(e)}closeDropdown(e="programmatic"){if(!(!this.hasAttribute("open")&&!this._isOpen)){if(e==="programmatic"){this.close(e);return}this._requestClose(e)}}toggle(){if(this._isOpen){this._requestClose("trigger");return}this.open()}get closeOnSelect(){return f(this.getAttribute("close-on-select"),!0)}set closeOnSelect(e){this.setAttribute("close-on-select",e?"true":"false")}get closeOnScroll(){return f(this.getAttribute("close-on-scroll"),!0)}set closeOnScroll(e){this.setAttribute("close-on-scroll",e?"true":"false")}get typeahead(){return f(this.getAttribute("typeahead"),!0)}set typeahead(e){this.setAttribute("typeahead",e?"true":"false")}_getTrigger(){return this.querySelector('[slot="trigger"]')}_getContentSource(){return this.querySelector('[slot="content"]')}_getMenu(){return this._portalEl}_isFocusable(e){if(!e||!e.isConnected||e.disabled||e.getAttribute("aria-hidden")==="true")return!1;if(!h())return!0;const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}_currentFocusedItem(){const e=this.root.activeElement||document.activeElement;return e instanceof HTMLElement?e.closest(l):null}_queryItems(e=!0){const t=this._getMenu();if(!t)return[];const r=Array.from(t.querySelectorAll(l));return e?r:r.filter(o=>!b(o))}_requestClose(e){if(!this._isOpen)return;const t=new CustomEvent("request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t);const r=new CustomEvent("ui-request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(r),!(t.defaultPrevented||r.defaultPrevented)&&this.close(e)}_close(e,t={}){if(this._openFrame&&cancelAnimationFrame(this._openFrame),this._openFrame=0,this._isOpen=!1,this._teardownOpenListeners(),this.hasAttribute("open")&&this.removeAttribute("open"),this._syncControlState(),this._syncTriggerA11y(),this._clearActiveItem(),this._clearMenuContent(),this._resetTypeahead(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:e}})),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:e}})),t.restoreFocus!==!1){const r=this._getTrigger();r&&this._isFocusable(r)?g(r):this._restoreFocusEl&&this._isFocusable(this._restoreFocusEl)&&g(this._restoreFocusEl)}this._restoreFocusEl=null}_syncOpenState(){const e=this.hasAttribute("open")&&!this.hasAttribute("disabled");if(e===this._isOpen){this._syncControlState(),this._syncTriggerA11y(),e&&(this._syncMenuPresentation(),this._syncMenuA11y(),this._schedulePanelSync());return}if(e){this._isOpen=!0,this._restoreFocusEl=document.activeElement,this._renderMenuContent(),this._syncMenuPresentation(),this._syncMenuA11y(),this._syncControlState(),this._syncTriggerA11y(),this._attachOpenListeners(),this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0}})),this._schedulePanelSync("first");return}this._close("programmatic",{restoreFocus:!1})}_attachOpenListeners(){this._openListenersBound||(document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),this._openListenersBound=!0)}_teardownOpenListeners(){this._openListenersBound&&(document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),this._openListenersBound=!1)}_syncTriggerA11y(){const e=this._getTrigger();if(!e)return;const t=y.resolveTriggerControl(e);if(t.id||(t.id=this._triggerId),t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded",this._isOpen?"true":"false"),this._isOpen?t.setAttribute("aria-controls",this._menuId):t.removeAttribute("aria-controls"),this.hasAttribute("disabled")){t.setAttribute("aria-disabled","true"),t.setAttribute("tabindex","-1");return}t.getAttribute("aria-disabled")==="true"&&t.removeAttribute("aria-disabled"),t.getAttribute("tabindex")==="-1"&&t.removeAttribute("tabindex")}_renderMenuContent(){const e=this._getMenu();if(!e)return;e.replaceChildren();const t=this._getContentSource();if(t&&e.appendChild(M(t)),!e.querySelector(l)){const r=document.createElement("div");r.className="empty-state",r.textContent="No items",e.appendChild(r)}this._syncMenuItemSemantics()}_syncMenuItemSemantics(){this._queryItems(!0).forEach((e,t)=>{e.getAttribute("role")||e.setAttribute("role","menuitem"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.dataset.sourceIndex=String(t),e.hasAttribute("disabled")&&e.getAttribute("aria-disabled")!=="true"&&e.setAttribute("aria-disabled","true");const r=e.getAttribute("role");(r==="menuitemcheckbox"||r==="menuitemradio")&&!e.hasAttribute("aria-checked")&&e.setAttribute("aria-checked","false"),this._applyStoredItemState(e,t)})}_clearMenuContent(){const e=this._getMenu();e&&e.replaceChildren()}_applyStoredItemState(e,t){const r=e.getAttribute("role");if(r==="menuitemcheckbox"){if(!this._checkboxState.has(t))return;const n=this._checkboxState.get(t)===!0;e.setAttribute("aria-checked",n?"true":"false"),e.setAttribute("data-state",n?"checked":"unchecked");return}if(r!=="menuitemradio")return;const o=e.getAttribute("data-group")||e.getAttribute("name")||"__default__";if(!this._radioState.has(o))return;const a=this._radioState.get(o)===t;e.setAttribute("aria-checked",a?"true":"false"),e.setAttribute("data-state",a?"checked":"unchecked")}_syncMenuPresentation(){const e=this._getMenu();if(!e)return;const t=h()?window.getComputedStyle(this):null;t&&L.forEach(c=>{const m=t.getPropertyValue(c).trim();m?e.style.setProperty(c,m):e.style.removeProperty(c)});const r=p(this,"variant"),o=C(this.getAttribute("size")||this.getAttribute("density")),a=p(this,"density"),n=p(this,"shape"),u=p(this,"elevation"),s=p(this,"tone"),d=E(this.getAttribute("radius")||n||null);if(r&&r!=="default"?e.setAttribute("data-variant",r):e.removeAttribute("data-variant"),o!=="md"?e.setAttribute("data-size",o):e.removeAttribute("data-size"),a&&a!=="default"?e.setAttribute("data-density",a):e.removeAttribute("data-density"),n&&n!=="default"?e.setAttribute("data-shape",n):e.removeAttribute("data-shape"),u&&u!=="default"?e.setAttribute("data-elevation",u):e.removeAttribute("data-elevation"),s&&s!=="default"&&s!=="brand"?e.setAttribute("data-tone",s):e.removeAttribute("data-tone"),d){e.style.setProperty("--ui-dropdown-radius",d),e.style.setProperty("--ui-dropdown-item-radius",d==="999px"?"999px":`max(0px, calc(${d} - 2px))`);return}e.style.removeProperty("--ui-dropdown-radius"),e.style.removeProperty("--ui-dropdown-item-radius")}_syncMenuA11y(){const e=this._getMenu();if(!e)return;const t=this._getTrigger(),r=this.getAttribute("aria-label")||"",o=this.getAttribute("aria-labelledby")||"",a=this.getAttribute("aria-describedby")||"",n=o||(!r&&t?.id?t.id:"");r?e.setAttribute("aria-label",r):e.removeAttribute("aria-label"),n?e.setAttribute("aria-labelledby",n):e.removeAttribute("aria-labelledby"),a?e.setAttribute("aria-describedby",a):e.removeAttribute("aria-describedby")}_syncControlState(){const e=this._panelEl,t=this._getMenu();!e||!t||(e.hidden=!this._isOpen,e.setAttribute("data-placement",this._placement))}_schedulePanelSync(e){this._openFrame&&cancelAnimationFrame(this._openFrame),this._openFrame=requestAnimationFrame(()=>{this._openFrame=0,this._syncPanelState(),e==="first"&&this._focusFirstItem(),e==="last"&&this._focusLastItem()})}_syncPanelState(){const e=this._panelEl;!e||!this._isOpen||(this._placement=this._resolvePlacement(),e.setAttribute("data-placement",this._placement),this.style.setProperty("--ui-dropdown-available-width",`${Math.max(0,Math.floor(this._availableWidth(this._placement)))}px`),this.style.setProperty("--ui-dropdown-available-height",`${Math.max(0,Math.floor(this._availableHeight(this._placement)))}px`))}_availableWidth(e){const t=this._getTrigger();if(!t||!h())return 380;const r=t.getBoundingClientRect(),o=window.innerWidth||document.documentElement.clientWidth||0;return e==="left"?r.left-12:e==="right"?o-r.right-12:o-r.left-12}_availableHeight(e){const t=this._getTrigger();if(!t||!h())return 440;const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight||0;return e==="top"?r.top-12:o-r.bottom-12}_resolvePlacement(){const e=S(this.getAttribute("placement")),t=this._getTrigger(),r=this._getMenu();if(!t||!r||!h())return e;const o=t.getBoundingClientRect(),a=window.innerWidth||document.documentElement.clientWidth||0,n=window.innerHeight||document.documentElement.clientHeight||0,u=Math.max(0,n-o.bottom-12),s=Math.max(0,o.top-12),d=Math.max(0,a-o.right-12),c=Math.max(0,o.left-12),m=Math.min(Math.max(r.scrollHeight,r.offsetHeight)+4,320),v=Math.min(Math.max(r.scrollWidth,r.offsetWidth)+4,360);return e==="top"?s>=m||s>u?"top":"bottom":e==="left"?c>=v||c>d?"left":"right":e==="right"?d>=v||d>=c?"right":"left":u>=m||u>=s?"bottom":"top"}_clearActiveItem(){this._queryItems(!0).forEach(e=>e.removeAttribute("data-active"))}_setActiveItem(e,t={}){if(this._clearActiveItem(),!!e&&(e.setAttribute("data-active","true"),t.focus&&g(e),t.scroll)){const r=this._getMenu();r&&T(e,r)}}_focusFirstItem(){const e=this._queryItems(!1);this._setActiveItem(e[0]||null,{focus:!0,scroll:!0})}_focusLastItem(){const e=this._queryItems(!1);this._setActiveItem(e[e.length-1]||null,{focus:!0,scroll:!0})}_moveFocus(e){const t=this._queryItems(!0);if(!t.length)return;const r=this._currentFocusedItem()||this._queryItems(!0).find(n=>n.getAttribute("data-active")==="true")||null,o=r?t.indexOf(r):e>0?-1:t.length,a=O(t,o,e);if(a>=0){this._setActiveItem(t[a],{focus:!0,scroll:!0});return}e>0?this._focusFirstItem():this._focusLastItem()}_resetTypeahead(){this._typeaheadBuffer="",this._typeaheadTimer!=null&&(window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null)}_isTypeaheadKey(e){return e.ctrlKey||e.metaKey||e.altKey?!1:e.key.length===1&&/\S/.test(e.key)}_handleTypeahead(e){if(!this.typeahead||!this._isTypeaheadKey(e))return!1;const t=e.key.toLowerCase();this._typeaheadBuffer=`${this._typeaheadBuffer}${t}`.slice(0,24),this._typeaheadTimer!=null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>this._resetTypeahead(),460);const r=P(this._queryItems(!0),this._typeaheadBuffer,this._currentFocusedItem());return r?(this._setActiveItem(r,{focus:!0,scroll:!0}),e.preventDefault(),!0):!1}_querySourceItems(){const e=this._getContentSource();return e?Array.from(e.querySelectorAll(l)):[]}_applySelectionBehavior(e){const t=e.getAttribute("role"),r=Number(e.dataset.sourceIndex||"-1");if(t==="menuitemcheckbox"){const n=e.getAttribute("aria-checked")!=="true";e.setAttribute("aria-checked",n?"true":"false"),e.setAttribute("data-state",n?"checked":"unchecked"),r>=0&&this._checkboxState.set(r,n);return}if(t!=="menuitemradio")return;const a=e.getAttribute("data-group")||e.getAttribute("name")||""||"__default__";r>=0&&this._radioState.set(a,r),this._queryItems(!0).filter(n=>n.getAttribute("role")==="menuitemradio").forEach(n=>{if((n.getAttribute("data-group")||n.getAttribute("name")||""||"__default__")!==a)return;const s=n===e;n.setAttribute("aria-checked",s?"true":"false"),n.setAttribute("data-state",s?"checked":"unchecked")})}_findMenuItemFromEvent(e){const t=typeof e.composedPath=="function"?e.composedPath():[];for(const o of t)if(o instanceof HTMLElement&&o.matches(l))return o;const r=e.target;return r instanceof HTMLElement?r.closest(l):null}_isEventInsideTrigger(e){const t=this._getTrigger();return t?(typeof e.composedPath=="function"?e.composedPath():[]).includes(t):!1}_emitSelect(e){const t={value:e.getAttribute("data-value")||e.getAttribute("value")||void 0,label:e.getAttribute("aria-label")||e.textContent?.trim()||void 0,checked:e.getAttribute("aria-checked")==="true",item:e};this.dispatchEvent(new CustomEvent("select",{bubbles:!0,composed:!0,detail:t}))}_onHostClick(e){if(this.hasAttribute("disabled"))return;const t=this._isOpen?this._findMenuItemFromEvent(e):null;if(t&&this._getMenu()?.contains(t)&&!b(t)){this._applySelectionBehavior(t),this._setActiveItem(t,{focus:!0,scroll:!0}),this._emitSelect(t),this.closeOnSelect&&this._requestClose("select");return}if(this._isEventInsideTrigger(e)){if(e.preventDefault(),this._isOpen){this._requestClose("trigger");return}this.open()}}_onHostKeyDown(e){if(!this._isOpen){if(!this._isEventInsideTrigger(e)||!["ArrowDown","ArrowUp","Enter"," "].includes(e.key))return;e.preventDefault(),this.open(),this._schedulePanelSync(e.key==="ArrowUp"?"last":"first");return}if(!this._handleTypeahead(e)){if(e.key==="Escape"){e.preventDefault(),this._requestClose("escape");return}if(e.key==="ArrowDown"){e.preventDefault(),this._moveFocus(1);return}if(e.key==="ArrowUp"){e.preventDefault(),this._moveFocus(-1);return}if(e.key==="Home"){e.preventDefault(),this._focusFirstItem();return}if(e.key==="End"){e.preventDefault(),this._focusLastItem();return}if(e.key==="Tab"){this._requestClose("tab");return}if(e.key==="Enter"||e.key===" "){const t=this._currentFocusedItem();if(!t||!this._getMenu()?.contains(t)||b(t))return;e.preventDefault(),t.click()}}}_onDocumentPointerDown(e){!this._isOpen||(typeof e.composedPath=="function"?e.composedPath():[]).includes(this)||this._requestClose("outside")}_onSlotChange(){this._syncTriggerA11y(),this._isOpen&&(this._renderMenuContent(),this._syncMenuPresentation(),this._syncMenuA11y(),this._schedulePanelSync())}render(){this.setContent(`
|
|
492
|
+
<style>${A}</style>
|
|
493
493
|
<div class="root" part="root">
|
|
494
494
|
<div class="trigger" part="trigger">
|
|
495
495
|
<slot name="trigger"></slot>
|