luxen-ui 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/custom-elements.json +203 -170
- package/cdn/elements/combobox/combobox.d.ts +6 -1
- package/cdn/elements/combobox/combobox.d.ts.map +1 -1
- package/cdn/elements/combobox/combobox.js +19 -17
- package/cdn/elements/combobox/combobox.js.map +1 -1
- package/cdn/elements/dropdown/dropdown.d.ts +6 -7
- package/cdn/elements/dropdown/dropdown.d.ts.map +1 -1
- package/cdn/elements/dropdown/dropdown.js +2 -2
- package/cdn/elements/dropdown/dropdown.js.map +1 -1
- package/cdn/elements/dropdown-item/dropdown-item.d.ts +0 -1
- package/cdn/elements/dropdown-item/dropdown-item.d.ts.map +1 -1
- package/cdn/elements/dropdown-item/dropdown-item.js +2 -2
- package/cdn/elements/dropdown-item/dropdown-item.js.map +1 -1
- package/cdn/elements/dropdown-label/dropdown-label.js +1 -1
- package/cdn/elements/dropdown-label/dropdown-label.js.map +1 -1
- package/cdn/elements/form-field/form-field.d.ts +1 -1
- package/cdn/elements/form-field/form-field.js.map +1 -1
- package/cdn/elements/input/input.meta.d.ts +2 -0
- package/cdn/elements/input/input.meta.d.ts.map +1 -1
- package/cdn/elements/input-otp/input-otp.d.ts +3 -3
- package/cdn/elements/input-otp/input-otp.js.map +1 -1
- package/cdn/elements/popover/popover.d.ts +3 -4
- package/cdn/elements/popover/popover.d.ts.map +1 -1
- package/cdn/elements/popover/popover.js +1 -1
- package/cdn/elements/popover/popover.js.map +1 -1
- package/cdn/elements/select/select.d.ts +6 -1
- package/cdn/elements/select/select.d.ts.map +1 -1
- package/cdn/elements/select/select.js +8 -7
- package/cdn/elements/select/select.js.map +1 -1
- package/cdn/elements/stories-viewer/stories-viewer.d.ts.map +1 -1
- package/cdn/elements/stories-viewer/stories-viewer.js +4 -4
- package/cdn/elements/stories-viewer/stories-viewer.js.map +1 -1
- package/cdn/elements/tooltip/tooltip.d.ts +0 -1
- package/cdn/elements/tooltip/tooltip.d.ts.map +1 -1
- package/cdn/elements/tooltip/tooltip.js +1 -1
- package/cdn/elements/tooltip/tooltip.js.map +1 -1
- package/cdn/shared/controllers/listbox-nav.d.ts +15 -1
- package/cdn/shared/controllers/listbox-nav.d.ts.map +1 -1
- package/cdn/shared/controllers/listbox-nav.js +1 -1
- package/cdn/shared/controllers/listbox-nav.js.map +1 -1
- package/cdn/shared/controllers/popover.d.ts +10 -2
- package/cdn/shared/controllers/popover.d.ts.map +1 -1
- package/cdn/shared/controllers/popover.js +1 -1
- package/cdn/shared/controllers/popover.js.map +1 -1
- package/cdn/shared/styles/checkbox-appearance.styles.js +1 -1
- package/cdn/shared/styles/checkbox-appearance.styles.js.map +1 -1
- package/cdn/shared/styles/menu-panel.styles.d.ts +8 -0
- package/cdn/shared/styles/menu-panel.styles.d.ts.map +1 -0
- package/cdn/shared/styles/menu-panel.styles.js +2 -0
- package/cdn/shared/styles/menu-panel.styles.js.map +1 -0
- package/cdn/shared/styles/picker-core.styles.d.ts +9 -0
- package/cdn/shared/styles/picker-core.styles.d.ts.map +1 -0
- package/cdn/shared/styles/picker-core.styles.js +2 -0
- package/cdn/shared/styles/picker-core.styles.js.map +1 -0
- package/cdn/shared/styles/select-item-suffix.styles.js +1 -1
- package/cdn/shared/styles/select-item-suffix.styles.js.map +1 -1
- package/cdn/shared/styles/select-item.styles.d.ts +8 -0
- package/cdn/shared/styles/select-item.styles.d.ts.map +1 -0
- package/cdn/shared/styles/select-item.styles.js +2 -0
- package/cdn/shared/styles/select-item.styles.js.map +1 -0
- package/cdn/shared/styles/visually-hidden.styles.d.ts +8 -0
- package/cdn/shared/styles/visually-hidden.styles.d.ts.map +1 -0
- package/cdn/shared/styles/visually-hidden.styles.js +2 -0
- package/cdn/shared/styles/visually-hidden.styles.js.map +1 -0
- package/cdn/standalone.css +365 -196
- package/cdn/standalone.js +148 -75
- package/cdn/standalone.js.map +1 -1
- package/cdn/styles/base.css +30 -20
- package/cdn/styles/elements/checkbox.css +2 -2
- package/cdn/styles/elements/form-field.css +16 -9
- package/cdn/styles/elements/input-otp.css +16 -9
- package/cdn/styles/elements/input-stepper/default.css +4 -4
- package/cdn/styles/elements/input-stepper/pill.css +4 -4
- package/cdn/styles/elements/input-stepper/rounded.css +3 -3
- package/cdn/styles/elements/input.css +82 -27
- package/cdn/styles/elements/radio.css +2 -2
- package/cdn/styles/elements/select.css +137 -80
- package/cdn/styles/elements/switch.css +3 -3
- package/cdn/styles/elements/textarea.css +5 -5
- package/cdn/styles/preset.css +92 -49
- package/cdn/styles/tokens/forms.css +33 -30
- package/cdn/styles/tokens.css +62 -29
- package/dist/css/base.css +30 -20
- package/dist/css/elements/checkbox.css +2 -2
- package/dist/css/elements/form-field.css +16 -9
- package/dist/css/elements/input-otp.css +16 -9
- package/dist/css/elements/input-stepper/default.css +4 -4
- package/dist/css/elements/input-stepper/pill.css +4 -4
- package/dist/css/elements/input-stepper/rounded.css +3 -3
- package/dist/css/elements/input.css +82 -27
- package/dist/css/elements/radio.css +2 -2
- package/dist/css/elements/select.css +137 -80
- package/dist/css/elements/switch.css +3 -3
- package/dist/css/elements/textarea.css +5 -5
- package/dist/css/preset.css +92 -49
- package/dist/css/tokens/forms.css +33 -30
- package/dist/css/tokens.css +62 -29
- package/dist/custom-elements.json +203 -170
- package/dist/elements/combobox/combobox.css +30 -187
- package/dist/elements/combobox/combobox.d.ts +6 -1
- package/dist/elements/combobox/combobox.d.ts.map +1 -1
- package/dist/elements/combobox/combobox.js +48 -20
- package/dist/elements/dropdown/dropdown.css +7 -30
- package/dist/elements/dropdown/dropdown.d.ts +6 -7
- package/dist/elements/dropdown/dropdown.d.ts.map +1 -1
- package/dist/elements/dropdown/dropdown.js +17 -14
- package/dist/elements/dropdown-item/dropdown-item.css +7 -36
- package/dist/elements/dropdown-item/dropdown-item.d.ts +0 -1
- package/dist/elements/dropdown-item/dropdown-item.d.ts.map +1 -1
- package/dist/elements/dropdown-item/dropdown-item.js +4 -7
- package/dist/elements/dropdown-label/dropdown-label.css +3 -3
- package/dist/elements/form-field/form-field.d.ts +1 -1
- package/dist/elements/form-field/form-field.js +2 -2
- package/dist/elements/input/input.meta.d.ts +2 -0
- package/dist/elements/input/input.meta.d.ts.map +1 -1
- package/dist/elements/input/input.meta.js +2 -0
- package/dist/elements/input-otp/input-otp.d.ts +3 -3
- package/dist/elements/input-otp/input-otp.js +3 -3
- package/dist/elements/popover/popover.css +4 -4
- package/dist/elements/popover/popover.d.ts +3 -4
- package/dist/elements/popover/popover.d.ts.map +1 -1
- package/dist/elements/popover/popover.js +5 -9
- package/dist/elements/select/select.css +24 -260
- package/dist/elements/select/select.d.ts +6 -1
- package/dist/elements/select/select.d.ts.map +1 -1
- package/dist/elements/select/select.js +27 -9
- package/dist/elements/stories-viewer/stories-viewer.css +0 -12
- package/dist/elements/stories-viewer/stories-viewer.d.ts.map +1 -1
- package/dist/elements/stories-viewer/stories-viewer.js +4 -3
- package/dist/elements/tooltip/tooltip.d.ts +0 -1
- package/dist/elements/tooltip/tooltip.d.ts.map +1 -1
- package/dist/elements/tooltip/tooltip.js +2 -6
- package/dist/metadata/combobox.json +16 -1
- package/dist/metadata/dropdown.json +10 -10
- package/dist/metadata/form-field.json +1 -1
- package/dist/metadata/index.json +57 -22
- package/dist/metadata/input-otp.json +3 -3
- package/dist/metadata/input.json +5 -0
- package/dist/metadata/popover.json +5 -5
- package/dist/metadata/select.json +16 -1
- package/dist/shared/controllers/listbox-nav.d.ts +15 -1
- package/dist/shared/controllers/listbox-nav.d.ts.map +1 -1
- package/dist/shared/controllers/listbox-nav.js +32 -1
- package/dist/shared/controllers/popover.d.ts +10 -2
- package/dist/shared/controllers/popover.d.ts.map +1 -1
- package/dist/shared/controllers/popover.js +16 -2
- package/dist/shared/styles/checkbox-appearance.css +2 -2
- package/dist/shared/styles/menu-panel.css +37 -0
- package/dist/shared/styles/menu-panel.styles.d.ts +8 -0
- package/dist/shared/styles/menu-panel.styles.d.ts.map +1 -0
- package/dist/shared/styles/menu-panel.styles.js +8 -0
- package/dist/shared/styles/picker-core.css +250 -0
- package/dist/shared/styles/picker-core.styles.d.ts +9 -0
- package/dist/shared/styles/picker-core.styles.d.ts.map +1 -0
- package/dist/shared/styles/picker-core.styles.js +9 -0
- package/dist/shared/styles/select-item-suffix.css +4 -4
- package/dist/shared/styles/select-item.css +98 -0
- package/dist/shared/styles/select-item.styles.d.ts +8 -0
- package/dist/shared/styles/select-item.styles.d.ts.map +1 -0
- package/dist/shared/styles/select-item.styles.js +8 -0
- package/dist/shared/styles/visually-hidden.css +27 -0
- package/dist/shared/styles/visually-hidden.styles.d.ts +8 -0
- package/dist/shared/styles/visually-hidden.styles.d.ts.map +1 -0
- package/dist/shared/styles/visually-hidden.styles.js +8 -0
- package/dist/templates/elements/combobox.md +26 -1
- package/dist/templates/elements/disclosure.md +2 -0
- package/dist/templates/elements/dropdown.md +6 -6
- package/dist/templates/elements/form-field.md +2 -2
- package/dist/templates/elements/input-otp.md +3 -3
- package/dist/templates/elements/input.md +1 -0
- package/dist/templates/elements/popover.md +3 -3
- package/dist/templates/elements/select.md +30 -1
- package/package.json +1 -1
|
@@ -52,7 +52,6 @@ export declare class Tooltip extends LuxenElement {
|
|
|
52
52
|
private _triggerFor;
|
|
53
53
|
private get _popover();
|
|
54
54
|
private get _arrowEl();
|
|
55
|
-
private _getDuration;
|
|
56
55
|
connectedCallback(): void;
|
|
57
56
|
disconnectedCallback(): void;
|
|
58
57
|
updated(changed: PropertyValues<this>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/html/elements/tooltip/tooltip.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAoBl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/lit.js";import{LuxenElement as t}from"../../shared/luxen-element.js";import{r as n,t as r}from"../../chunks/decorate.js";import{a as i,t as a}from"../../chunks/lit-html.js";import{PopoverController as o}from"../../shared/controllers/popover.js";import{uniqueId as s}from"../../registry.js";import c from"../../shared/styles/host.styles.js";var l=e(`:host{--background-color:var(--l-tooltip-background-color);--border-radius:4px;--max-width:180px;--arrow-size:6px;--show-duration:.15s;--hide-duration:.15s;display:contents}[popover]{inset:unset;box-sizing:border-box;width:max-content;max-width:var(--max-width);border-radius:var(--border-radius);background:var(--background-color);--_on:calc(255 * ( 1 - sign(.2126 * (r / 255) * (r / 255) + .7152 * (g / 255) * (g / 255) + .0722 * (b / 255) * (b / 255) - .2) ) / 2);color:var(--text-color,rgb(from var(--background-color) var(--_on) var(--_on) var(--_on)));filter:drop-shadow(0 1px 2px #00000029);pointer-events:none;border:0;padding:4px 8px;font-size:.8125rem;line-height:1.4;overflow:visible}@supports (color:contrast-color(red)){[popover]{color:var(--text-color,contrast-color(var(--background-color)))}}i{width:var(--arrow-size);height:var(--arrow-size);background:var(--background-color);display:block;position:absolute;transform:rotate(45deg)}`),u=new Set,d=null,f=class extends t{constructor(...e){super(...e),this._tooltipId=s(`tooltip`),this._floating=new o(this,{getTriggerElement:()=>this._trigger,getFloatingElement:()=>this._popover,getArrowElement:()=>this._arrowEl}),this.#e=``,this.#t=`top`,this.#n=8,this.#r=0,this.#i=0,this.#a=!1,this.#o=!1,this.#s=`hover focus`,this._onPointerEnter=()=>{if(this._hasTrigger(`hover`)){this._floating.cleanupSafePolygon();for(let e of u)e===this||e._hasTrigger(`manual`)||(e._floating.cleanupSafePolygon(),e.hide());clearTimeout(this._hideTimer),this._hideTimer=void 0,this.showDelay>0&&!this.open?(clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>this.show(),this.showDelay)):this.show()}},this._onPointerLeave=e=>{clearTimeout(this._showTimer),this._showTimer=void 0,this._hasTrigger(`hover`)&&this.open&&this._floating.handlePointerLeave(e,e=>{e===`settled`?this.hide():this._scheduleHide()})},this._onFocusIn=()=>{this._hasTrigger(`focus`)&&this._trigger?.matches(`:focus-visible`)&&(clearTimeout(this._hideTimer),this._hideTimer=void 0,this.show())},this._onFocusOut=()=>{this._hasTrigger(`focus`)&&(clearTimeout(this._showTimer),this._showTimer=void 0,this.hide())},this._onClick=()=>{this._hasTrigger(`click`)&&this.toggle()},this._onKeyDown=e=>{this.open&&e.key===`Escape`&&(e.stopPropagation(),this.hide())}}static{this.styles=[c,l]}#e;get for(){return this.#e}set for(e){this.#e=e}#t;get placement(){return this.#t}set placement(e){this.#t=e}#n;get distance(){return this.#n}set distance(e){this.#n=e}#r;get showDelay(){return this.#r}set showDelay(e){this.#r=e}#i;get hideDelay(){return this.#i}set hideDelay(e){this.#i=e}#a;get open(){return this.#a}set open(e){this.#a=e}#o;get withoutArrow(){return this.#o}set withoutArrow(e){this.#o=e}#s;get trigger(){return this.#s}set trigger(e){this.#s=e}_hasTrigger(e){return this.trigger.split(` `).includes(e)}get _trigger(){return this._triggerFor(this.for)}_triggerFor(e){if(!e)return null;let t=this.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.getElementById(e):null}get _popover(){return this.shadowRoot.querySelector(`[popover]`)}get _arrowEl(){return this.withoutArrow?null:this.shadowRoot.querySelector(`i`)}
|
|
1
|
+
import{i as e}from"../../chunks/lit.js";import{LuxenElement as t}from"../../shared/luxen-element.js";import{r as n,t as r}from"../../chunks/decorate.js";import{a as i,t as a}from"../../chunks/lit-html.js";import{PopoverController as o}from"../../shared/controllers/popover.js";import{uniqueId as s}from"../../registry.js";import c from"../../shared/styles/host.styles.js";var l=e(`:host{--background-color:var(--l-tooltip-background-color);--border-radius:4px;--max-width:180px;--arrow-size:6px;--show-duration:.15s;--hide-duration:.15s;display:contents}[popover]{inset:unset;box-sizing:border-box;width:max-content;max-width:var(--max-width);border-radius:var(--border-radius);background:var(--background-color);--_on:calc(255 * ( 1 - sign(.2126 * (r / 255) * (r / 255) + .7152 * (g / 255) * (g / 255) + .0722 * (b / 255) * (b / 255) - .2) ) / 2);color:var(--text-color,rgb(from var(--background-color) var(--_on) var(--_on) var(--_on)));filter:drop-shadow(0 1px 2px #00000029);pointer-events:none;border:0;padding:4px 8px;font-size:.8125rem;line-height:1.4;overflow:visible}@supports (color:contrast-color(red)){[popover]{color:var(--text-color,contrast-color(var(--background-color)))}}i{width:var(--arrow-size);height:var(--arrow-size);background:var(--background-color);display:block;position:absolute;transform:rotate(45deg)}`),u=new Set,d=null,f=class extends t{constructor(...e){super(...e),this._tooltipId=s(`tooltip`),this._floating=new o(this,{getTriggerElement:()=>this._trigger,getFloatingElement:()=>this._popover,getArrowElement:()=>this._arrowEl}),this.#e=``,this.#t=`top`,this.#n=8,this.#r=0,this.#i=0,this.#a=!1,this.#o=!1,this.#s=`hover focus`,this._onPointerEnter=()=>{if(this._hasTrigger(`hover`)){this._floating.cleanupSafePolygon();for(let e of u)e===this||e._hasTrigger(`manual`)||(e._floating.cleanupSafePolygon(),e.hide());clearTimeout(this._hideTimer),this._hideTimer=void 0,this.showDelay>0&&!this.open?(clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>this.show(),this.showDelay)):this.show()}},this._onPointerLeave=e=>{clearTimeout(this._showTimer),this._showTimer=void 0,this._hasTrigger(`hover`)&&this.open&&this._floating.handlePointerLeave(e,e=>{e===`settled`?this.hide():this._scheduleHide()})},this._onFocusIn=()=>{this._hasTrigger(`focus`)&&this._trigger?.matches(`:focus-visible`)&&(clearTimeout(this._hideTimer),this._hideTimer=void 0,this.show())},this._onFocusOut=()=>{this._hasTrigger(`focus`)&&(clearTimeout(this._showTimer),this._showTimer=void 0,this.hide())},this._onClick=()=>{this._hasTrigger(`click`)&&this.toggle()},this._onKeyDown=e=>{this.open&&e.key===`Escape`&&(e.stopPropagation(),this.hide())}}static{this.styles=[c,l]}#e;get for(){return this.#e}set for(e){this.#e=e}#t;get placement(){return this.#t}set placement(e){this.#t=e}#n;get distance(){return this.#n}set distance(e){this.#n=e}#r;get showDelay(){return this.#r}set showDelay(e){this.#r=e}#i;get hideDelay(){return this.#i}set hideDelay(e){this.#i=e}#a;get open(){return this.#a}set open(e){this.#a=e}#o;get withoutArrow(){return this.#o}set withoutArrow(e){this.#o=e}#s;get trigger(){return this.#s}set trigger(e){this.#s=e}_hasTrigger(e){return this.trigger.split(` `).includes(e)}get _trigger(){return this._triggerFor(this.for)}_triggerFor(e){if(!e)return null;let t=this.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.getElementById(e):null}get _popover(){return this.shadowRoot.querySelector(`[popover]`)}get _arrowEl(){return this.withoutArrow?null:this.shadowRoot.querySelector(`i`)}connectedCallback(){super.connectedCallback(),u.add(this),requestAnimationFrame(()=>this._addTriggerListeners())}disconnectedCallback(){super.disconnectedCallback(),u.delete(this),d===this&&(d=null),this._clearTimers(),this._removeTriggerListeners()}updated(e){e.has(`for`)&&(this._clearTimers(),this._removeTriggerListeners(e.get(`for`)),this._addTriggerListeners(),this.open&&!e.has(`open`)&&this._repositionToTrigger()),e.has(`open`)&&this._handleOpenChange()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=void 0,this._hideTimer=void 0}show(){this.open||=!0}hide(){this.open&&=!1}toggle(){this.open=!this.open}async reposition(){this.open&&await this._repositionToTrigger()}async _repositionToTrigger(){this._floating.cleanupSafePolygon();let e=this.for,t=await this._floating.reposition(this._positionOptions(),()=>this.open&&this.for===e);t!==`stale`&&(t===`no-anchor`?this.hide():this._floating.markTrigger(`aria-describedby`,this._tooltipId,null))}_positionOptions(){return{placement:this.placement,distance:this.distance}}async _handleOpenChange(){let e=this._popover;if(!e)return;let t=this._positionOptions();if(this.open){if(this._hasTrigger(`manual`)||(d&&d!==this&&d.hide(),d=this),e.showPopover(),await this._floating.updatePosition(t),!this.open)return;await this._floating.animateShow(e),this._floating.startPositioning(t),this._floating.markTrigger(`aria-describedby`,this._tooltipId,null)}else d===this&&(d=null),this._floating.stopPositioning(),this._floating.cleanupSafePolygon(),this._floating.releaseTrigger(null),await this._floating.animateHide(e),e.matches(`:popover-open`)&&e.hidePopover()}_scheduleHide(){this.hideDelay>0?(clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this.hide(),this.hideDelay)):this.hide()}_addTriggerListeners(){this._floating.addTriggerListeners({onPointerEnter:this._onPointerEnter,onPointerLeave:this._onPointerLeave,onFocusIn:this._onFocusIn,onFocusOut:this._onFocusOut,onClick:this._onClick,onKeyDown:this._onKeyDown})}_removeTriggerListeners(e){this._floating.removeTriggerListeners(e?this._triggerFor(e):void 0)}render(){return i`
|
|
2
2
|
<div
|
|
3
3
|
id=${this._tooltipId}
|
|
4
4
|
popover="manual"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","names":["unsafeCSS","rawStyles","hostStyles","nothing","_decorate","property","r","__decorate","b","A","host_styles_default","styles","tooltipInstances","activeTooltip","Tooltip","LuxenElement","_args","uniqueId","PopoverController","#_for_accessor_storage","#_placement_accessor_storage","#_distance_accessor_storage","#_showDelay_accessor_storage","#_hideDelay_accessor_storage","#_open_accessor_storage","#_withoutArrow_accessor_storage","#_trigger_accessor_storage","tooltip","reason","value","type","id","root","parsed","prop","changed","openFor","result","popover","posOpts","forId"],"sources":["../../../src/html/elements/tooltip/tooltip.css?inline","../../../src/html/elements/tooltip/tooltip.ts"],"sourcesContent":[":host {\n --background-color: var(--l-tooltip-background-color);\n --border-radius: 4px;\n --max-width: 180px;\n --arrow-size: 6px;\n --show-duration: 150ms;\n --hide-duration: 150ms;\n\n display: contents;\n}\n\n[popover] {\n inset: unset;\n overflow: visible;\n box-sizing: border-box;\n width: max-content;\n max-width: var(--max-width);\n padding: 4px 8px;\n border: 0;\n border-radius: var(--border-radius);\n background: var(--background-color);\n /*\n * Text over --background-color, decided by the background's own luminance —\n * never the document mode, since --background-color is consumer-set and\n * ignores light/dark. The contrast-color() block below is the primary path\n * (Baseline 2026); this --_on calc() is the fallback for browsers predating\n * it. It approximates WCAG relative luminance with squared sRGB channels\n * (Rec. 709 weights) and flips at 0.2, just above the black/white crossover\n * (~0.179) — holding AA across saturated custom colors where an\n * OKLCH-lightness threshold collapses to ≈1:1 (OKLCH L tracks hue, not\n * luminance). --text-color lets consumers force a specific text color.\n */\n --_on: calc(\n 255 *\n (\n 1 -\n sign(\n 0.2126 * (r / 255) * (r / 255) + 0.7152 * (g / 255) * (g / 255) + 0.0722 * (b / 255) *\n (b / 255) - 0.2\n )\n ) /\n 2\n );\n color: var(--text-color, rgb(from var(--background-color) var(--_on) var(--_on) var(--_on)));\n font-size: 0.8125rem;\n line-height: 1.4;\n filter: drop-shadow(0 1px 2px rgb(0 0 0 / 16%));\n pointer-events: none;\n}\n\n/* Primary path: native, guaranteed-contrast black/white. @supports (not\n * declaration order) is required — the value contains var(), so a non-supporting\n * browser treats contrast-color() as invalid-at-computed-value-time and resets to\n * inherit rather than falling back to the calc() line. */\n@supports (color: contrast-color(red)) {\n [popover] {\n color: var(--text-color, contrast-color(var(--background-color)));\n }\n}\n\ni {\n position: absolute;\n display: block;\n width: var(--arrow-size);\n height: var(--arrow-size);\n background: var(--background-color);\n transform: rotate(45deg);\n}\n","import { html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { LuxenElement } from '../../shared/luxen-element.js';\nimport { property } from 'lit/decorators.js';\nimport type { Placement } from '@floating-ui/dom';\nimport { PopoverController } from '../../shared/controllers/popover.js';\nimport { uniqueId } from '../../registry.js';\nimport hostStyles from '../../shared/styles/host.styles.js';\nimport rawStyles from './tooltip.css?inline';\n\nconst styles = unsafeCSS(rawStyles);\n\n/**\n * Module-level registry of connected tooltips. A tooltip behaves like a label,\n * not a dialog: at most one pointer/focus/click-triggered tooltip is visible at\n * a time. Without this, on a dense grid of small triggers the safe polygon of\n * the previous tooltip overlaps the neighbouring triggers and two (or more)\n * tooltips end up visible during a horizontal sweep. `trigger=\"manual\"`\n * tooltips opt out: they never claim the active slot and are never evicted, so\n * programmatic multi-tooltip scenarios (annotations, coach marks) keep working.\n */\nconst tooltipInstances = new Set<Tooltip>();\nlet activeTooltip: Tooltip | null = null;\n\n/**\n * @summary A tooltip that displays contextual text on hover or focus.\n * @customElement l-tooltip\n *\n * @slot - Tooltip content (text or rich HTML).\n *\n * @csspart body - The tooltip popover container.\n * @csspart arrow - The directional arrow element.\n *\n * @cssproperty --background-color - Background color for this tooltip instance. Defaults to the global `--l-tooltip-background-color` token (a neutral inverse surface, dark in light mode / light in dark mode) — override that token to re-skin every tooltip at once.\n * @cssproperty --text-color - Text color. If unset, auto-derived from `--background-color` luminance.\n * @cssproperty --border-radius - Border radius. Default `4px`.\n * @cssproperty --max-width - Maximum width. Default `180px`.\n * @cssproperty --arrow-size - Arrow size. Default `6px`.\n * @cssproperty --show-duration - Show animation duration. Default `150ms`.\n * @cssproperty --hide-duration - Hide animation duration. Default `150ms`.\n */\nexport class Tooltip extends LuxenElement {\n static override styles = [hostStyles, styles];\n\n private _tooltipId = uniqueId('tooltip');\n\n private _floating = new PopoverController(this, {\n getTriggerElement: () => this._trigger,\n getFloatingElement: () => this._popover,\n getArrowElement: () => this._arrowEl,\n });\n\n /** The HTML id of the element triggering the tooltip. */\n @property({ reflect: true })\n accessor for = '';\n\n /** The preferred placement of the tooltip. */\n @property()\n accessor placement: Placement = 'top';\n\n /** The distance in pixels from the target element. */\n @property({ type: Number })\n accessor distance = 8;\n\n /**\n * Milliseconds the pointer must dwell on the trigger before the tooltip\n * shows. Applies to `hover` only — focus shows immediately.\n */\n @property({ type: Number, attribute: 'show-delay' })\n accessor showDelay = 0;\n\n /**\n * Milliseconds to wait after the pointer leaves the trigger (and its safe\n * polygon) before hiding. Bridges a brief exit-and-return without flicker.\n * Applies to `hover` only.\n */\n @property({ type: Number, attribute: 'hide-delay' })\n accessor hideDelay = 0;\n\n private _showTimer?: ReturnType<typeof setTimeout>;\n private _hideTimer?: ReturnType<typeof setTimeout>;\n\n /** Whether or not the tooltip is visible. */\n @property({ type: Boolean, reflect: true })\n accessor open = false;\n\n /** Hide the directional arrow. */\n @property({ type: Boolean, reflect: true, attribute: 'without-arrow' })\n accessor withoutArrow = false;\n\n /** Space-separated list of trigger modes: `hover`, `focus`, `click`, `manual`. */\n @property()\n accessor trigger = 'hover focus';\n\n private _hasTrigger(type: string) {\n return this.trigger.split(' ').includes(type);\n }\n\n private get _trigger(): HTMLElement | null {\n return this._triggerFor(this.for);\n }\n\n private _triggerFor(id: string): HTMLElement | null {\n if (!id) return null;\n // A detached tooltip's root is a plain element with no getElementById —\n // async open/close work (e.g. an eviction) may land after removal.\n const root = this.getRootNode();\n return root instanceof Document || root instanceof ShadowRoot ? root.getElementById(id) : null;\n }\n\n private get _popover(): HTMLElement {\n return this.shadowRoot!.querySelector('[popover]')!;\n }\n\n private get _arrowEl(): HTMLElement | null {\n return this.withoutArrow ? null : this.shadowRoot!.querySelector('i');\n }\n\n private _getDuration(prop: '--show-duration' | '--hide-duration'): number {\n const parsed = parseFloat(getComputedStyle(this).getPropertyValue(prop));\n return Number.isNaN(parsed) ? 150 : parsed;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n tooltipInstances.add(this);\n requestAnimationFrame(() => this._addTriggerListeners());\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n tooltipInstances.delete(this);\n if (activeTooltip === this) activeTooltip = null;\n this._clearTimers();\n // `aria-describedby` is dropped by the controller's hostDisconnected: our\n // id stops resolving once we leave the tree.\n this._removeTriggerListeners();\n }\n\n override updated(changed: PropertyValues<this>) {\n // `for` before `open`: retargeting an already-open bubble has to settle\n // against the new anchor, and when both change in the same update the open\n // path owns the positioning outright (see the guard below).\n if (changed.has('for')) {\n // A queued show/hide targets the old trigger — drop it before rewiring.\n this._clearTimers();\n this._removeTriggerListeners(changed.get('for'));\n this._addTriggerListeners();\n if (this.open && !changed.has('open')) {\n void this._repositionToTrigger();\n }\n }\n if (changed.has('open')) {\n void this._handleOpenChange();\n }\n }\n\n /** Cancel any pending delayed show/hide (trigger gone, `for` changed, disconnect). */\n private _clearTimers() {\n clearTimeout(this._showTimer);\n clearTimeout(this._hideTimer);\n this._showTimer = undefined;\n this._hideTimer = undefined;\n }\n\n show() {\n if (!this.open) this.open = true;\n }\n\n hide() {\n if (this.open) this.open = false;\n }\n\n toggle() {\n this.open = !this.open;\n }\n\n /**\n * Recompute the position against the current trigger. Use it when you move\n * the anchor yourself and the tooltip has to follow. No-op when closed;\n * hides if the anchor is gone.\n */\n // Worth calling even though positioning is otherwise automatic: the\n // underlying observers detect a moved anchor a frame late, and an anchor\n // driven at frame rate (a marker following the pointer) can starve them for\n // as long as a second. An explicit call bypasses them.\n async reposition() {\n if (!this.open) return;\n await this._repositionToTrigger();\n }\n\n /**\n * Move the open bubble onto whatever `for` names now — a move, not a\n * re-open, so it deliberately bypasses `_handleOpenChange` and its show\n * animation. Shared by the public `reposition()` and the retarget path so\n * the two cannot drift apart.\n */\n private async _repositionToTrigger() {\n // The polygon was armed against the anchor's previous geometry.\n this._floating.cleanupSafePolygon();\n const openFor = this.for;\n const result = await this._floating.reposition(\n this._positionOptions(),\n () => this.open && this.for === openFor,\n );\n // Closed or retargeted again while `computePosition` was in flight —\n // whatever superseded us owns the bubble and its ARIA now.\n if (result === 'stale') return;\n // Retargeted onto an id that resolves to nothing — a virtualised row\n // recycled between `pointerenter` and here, say. A bubble left floating\n // over unrelated content while describing no element is worse than none.\n if (result === 'no-anchor') {\n this.hide();\n return;\n }\n this._floating.markTrigger('aria-describedby', this._tooltipId, null);\n }\n\n private _positionOptions() {\n return { placement: this.placement, distance: this.distance };\n }\n\n private async _handleOpenChange() {\n const popover = this._popover;\n if (!popover) return;\n\n const posOpts = this._positionOptions();\n\n if (this.open) {\n // Single-open invariant: opening a non-manual tooltip evicts the current\n // one. The evicted tooltip's hide flows back through this method, which\n // also removes its safe-polygon `pointermove` listener.\n if (!this._hasTrigger('manual')) {\n if (activeTooltip && activeTooltip !== this) activeTooltip.hide();\n activeTooltip = this;\n }\n popover.showPopover();\n await this._floating.updatePosition(posOpts);\n if (!this.open) return;\n await this._floating.animateShow(popover, this._getDuration('--show-duration'));\n this._floating.startPositioning(posOpts);\n this._floating.markTrigger('aria-describedby', this._tooltipId, null);\n } else {\n if (activeTooltip === this) activeTooltip = null;\n this._floating.stopPositioning();\n this._floating.cleanupSafePolygon();\n this._floating.releaseTrigger(null);\n await this._floating.animateHide(popover, this._getDuration('--hide-duration'));\n if (popover.matches(':popover-open')) popover.hidePopover();\n }\n }\n\n // --- Trigger event handlers ---\n\n private _onPointerEnter = () => {\n if (!this._hasTrigger('hover')) return;\n // The safe polygon means \"the pointer is travelling toward the bubble\" —\n // provably false once the pointer enters another tooltip's trigger. Drop\n // our own stale polygon, and close every peer now: invalidating a peer's\n // polygon without hiding it leaves the peer stuck open, because its only\n // remaining close path was eviction when *this* tooltip opens — and with\n // `show-delay` that can be much later, or never if the pointer moves on\n // before the dwell elapses (a fast sweep across a button group).\n this._floating.cleanupSafePolygon();\n for (const tooltip of tooltipInstances) {\n if (tooltip === this || tooltip._hasTrigger('manual')) continue;\n tooltip._floating.cleanupSafePolygon();\n tooltip.hide();\n }\n // The pointer is back on the trigger: cancel a pending hide (exit-and-return).\n clearTimeout(this._hideTimer);\n this._hideTimer = undefined;\n if (this.showDelay > 0 && !this.open) {\n clearTimeout(this._showTimer);\n this._showTimer = setTimeout(() => this.show(), this.showDelay);\n } else {\n this.show();\n }\n };\n\n private _onPointerLeave = (e: PointerEvent) => {\n // Cancel a still-pending show — the pointer left before the dwell elapsed.\n clearTimeout(this._showTimer);\n this._showTimer = undefined;\n if (!this._hasTrigger('hover') || !this.open) return;\n // `exit` — the pointer actively moved off the trigger/bubble: honour\n // `hide-delay` so a brief exit-and-return doesn't flicker. `settled` — the\n // pointer left and sat motionless in the corridor: there is no in-flight\n // gesture to bridge, so hide at once (never stack the delay on top).\n this._floating.handlePointerLeave(e, (reason) => {\n if (reason === 'settled') this.hide();\n else this._scheduleHide();\n });\n };\n\n /** Hide now, or after `hide-delay` if set (cancellable by a pointer return). */\n private _scheduleHide() {\n if (this.hideDelay > 0) {\n clearTimeout(this._hideTimer);\n this._hideTimer = setTimeout(() => this.hide(), this.hideDelay);\n } else {\n this.hide();\n }\n }\n\n private _onFocusIn = () => {\n if (!this._hasTrigger('focus')) return;\n // Keyboard focus only. A pointer click focuses the trigger too, but the\n // pointer already drives the `hover` trigger — showing on mouse focus would\n // resurrect the tooltip when a modal (e.g. `l-dialog`) restores focus to\n // the trigger on close. `:focus-visible` is exactly \"focus that warrants a\n // visible affordance\", matching the platform's own `title`/APG behaviour.\n if (!this._trigger?.matches(':focus-visible')) return;\n // Focus is a discrete affordance — show immediately, ignoring the dwell delay.\n clearTimeout(this._hideTimer);\n this._hideTimer = undefined;\n this.show();\n };\n private _onFocusOut = () => {\n if (this._hasTrigger('focus')) {\n // A hover may have queued a show; blur must not resurrect it.\n clearTimeout(this._showTimer);\n this._showTimer = undefined;\n this.hide();\n }\n };\n private _onClick = () => {\n if (this._hasTrigger('click')) this.toggle();\n };\n\n private _onKeyDown = (e: KeyboardEvent) => {\n if (this.open && e.key === 'Escape') {\n e.stopPropagation();\n this.hide();\n }\n };\n\n private _addTriggerListeners() {\n this._floating.addTriggerListeners({\n onPointerEnter: this._onPointerEnter,\n onPointerLeave: this._onPointerLeave,\n onFocusIn: this._onFocusIn,\n onFocusOut: this._onFocusOut,\n onClick: this._onClick,\n onKeyDown: this._onKeyDown,\n });\n }\n\n private _removeTriggerListeners(forId?: string) {\n this._floating.removeTriggerListeners(forId ? this._triggerFor(forId) : undefined);\n }\n\n override render() {\n return html`\n <div\n id=${this._tooltipId}\n popover=\"manual\"\n role=\"tooltip\"\n part=\"body\"\n >\n ${\n this.withoutArrow\n ? nothing\n : html`\n <i\n part=\"arrow\"\n role=\"presentation\"\n ></i>\n `\n }\n <slot></slot>\n </div>\n `;\n }\n}\n"],"mappings":"A,oXCSA,IAAMW,EAASX,EAAUC,w7BAAS,EAW5BW,EAAmB,IAAI,IACzBC,EAAgC,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,EAAA,CAAAC,EAAS,CAAE,KAAM,OAAQ,UAAW,YAAa,CAAC,CAAA,EAAAS,EAAA,UAAA,YAAA,IAAA,EAOlDV,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAS,EAAA,UAAA,OAAA,IAAA,EAIzCV,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,GAAM,UAAW,eAAgB,CAAC,CAAA,EAAAS,EAAA,UAAA,eAAA,IAAA,EAIrEV,EAAA,CAAAC,EAAS,CAAA,EAAAS,EAAA,UAAA,UAAA,IAAA,E"}
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":["unsafeCSS","rawStyles","hostStyles","nothing","_decorate","property","r","__decorate","b","A","host_styles_default","styles","tooltipInstances","activeTooltip","Tooltip","LuxenElement","_args","uniqueId","PopoverController","#_for_accessor_storage","#_placement_accessor_storage","#_distance_accessor_storage","#_showDelay_accessor_storage","#_hideDelay_accessor_storage","#_open_accessor_storage","#_withoutArrow_accessor_storage","#_trigger_accessor_storage","tooltip","reason","value","type","id","root","changed","openFor","result","popover","posOpts","forId"],"sources":["../../../src/html/elements/tooltip/tooltip.css?inline","../../../src/html/elements/tooltip/tooltip.ts"],"sourcesContent":[":host {\n --background-color: var(--l-tooltip-background-color);\n --border-radius: 4px;\n --max-width: 180px;\n --arrow-size: 6px;\n --show-duration: 150ms;\n --hide-duration: 150ms;\n\n display: contents;\n}\n\n[popover] {\n inset: unset;\n overflow: visible;\n box-sizing: border-box;\n width: max-content;\n max-width: var(--max-width);\n padding: 4px 8px;\n border: 0;\n border-radius: var(--border-radius);\n background: var(--background-color);\n /*\n * Text over --background-color, decided by the background's own luminance —\n * never the document mode, since --background-color is consumer-set and\n * ignores light/dark. The contrast-color() block below is the primary path\n * (Baseline 2026); this --_on calc() is the fallback for browsers predating\n * it. It approximates WCAG relative luminance with squared sRGB channels\n * (Rec. 709 weights) and flips at 0.2, just above the black/white crossover\n * (~0.179) — holding AA across saturated custom colors where an\n * OKLCH-lightness threshold collapses to ≈1:1 (OKLCH L tracks hue, not\n * luminance). --text-color lets consumers force a specific text color.\n */\n --_on: calc(\n 255 *\n (\n 1 -\n sign(\n 0.2126 * (r / 255) * (r / 255) + 0.7152 * (g / 255) * (g / 255) + 0.0722 * (b / 255) *\n (b / 255) - 0.2\n )\n ) /\n 2\n );\n color: var(--text-color, rgb(from var(--background-color) var(--_on) var(--_on) var(--_on)));\n font-size: 0.8125rem;\n line-height: 1.4;\n filter: drop-shadow(0 1px 2px rgb(0 0 0 / 16%));\n pointer-events: none;\n}\n\n/* Primary path: native, guaranteed-contrast black/white. @supports (not\n * declaration order) is required — the value contains var(), so a non-supporting\n * browser treats contrast-color() as invalid-at-computed-value-time and resets to\n * inherit rather than falling back to the calc() line. */\n@supports (color: contrast-color(red)) {\n [popover] {\n color: var(--text-color, contrast-color(var(--background-color)));\n }\n}\n\ni {\n position: absolute;\n display: block;\n width: var(--arrow-size);\n height: var(--arrow-size);\n background: var(--background-color);\n transform: rotate(45deg);\n}\n","import { html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { LuxenElement } from '../../shared/luxen-element.js';\nimport { property } from 'lit/decorators.js';\nimport type { Placement } from '@floating-ui/dom';\nimport { PopoverController } from '../../shared/controllers/popover.js';\nimport { uniqueId } from '../../registry.js';\nimport hostStyles from '../../shared/styles/host.styles.js';\nimport rawStyles from './tooltip.css?inline';\n\nconst styles = unsafeCSS(rawStyles);\n\n/**\n * Module-level registry of connected tooltips. A tooltip behaves like a label,\n * not a dialog: at most one pointer/focus/click-triggered tooltip is visible at\n * a time. Without this, on a dense grid of small triggers the safe polygon of\n * the previous tooltip overlaps the neighbouring triggers and two (or more)\n * tooltips end up visible during a horizontal sweep. `trigger=\"manual\"`\n * tooltips opt out: they never claim the active slot and are never evicted, so\n * programmatic multi-tooltip scenarios (annotations, coach marks) keep working.\n */\nconst tooltipInstances = new Set<Tooltip>();\nlet activeTooltip: Tooltip | null = null;\n\n/**\n * @summary A tooltip that displays contextual text on hover or focus.\n * @customElement l-tooltip\n *\n * @slot - Tooltip content (text or rich HTML).\n *\n * @csspart body - The tooltip popover container.\n * @csspart arrow - The directional arrow element.\n *\n * @cssproperty --background-color - Background color for this tooltip instance. Defaults to the global `--l-tooltip-background-color` token (a neutral inverse surface, dark in light mode / light in dark mode) — override that token to re-skin every tooltip at once.\n * @cssproperty --text-color - Text color. If unset, auto-derived from `--background-color` luminance.\n * @cssproperty --border-radius - Border radius. Default `4px`.\n * @cssproperty --max-width - Maximum width. Default `180px`.\n * @cssproperty --arrow-size - Arrow size. Default `6px`.\n * @cssproperty --show-duration - Show animation duration. Default `150ms`.\n * @cssproperty --hide-duration - Hide animation duration. Default `150ms`.\n */\nexport class Tooltip extends LuxenElement {\n static override styles = [hostStyles, styles];\n\n private _tooltipId = uniqueId('tooltip');\n\n private _floating = new PopoverController(this, {\n getTriggerElement: () => this._trigger,\n getFloatingElement: () => this._popover,\n getArrowElement: () => this._arrowEl,\n });\n\n /** The HTML id of the element triggering the tooltip. */\n @property({ reflect: true })\n accessor for = '';\n\n /** The preferred placement of the tooltip. */\n @property()\n accessor placement: Placement = 'top';\n\n /** The distance in pixels from the target element. */\n @property({ type: Number })\n accessor distance = 8;\n\n /**\n * Milliseconds the pointer must dwell on the trigger before the tooltip\n * shows. Applies to `hover` only — focus shows immediately.\n */\n @property({ type: Number, attribute: 'show-delay' })\n accessor showDelay = 0;\n\n /**\n * Milliseconds to wait after the pointer leaves the trigger (and its safe\n * polygon) before hiding. Bridges a brief exit-and-return without flicker.\n * Applies to `hover` only.\n */\n @property({ type: Number, attribute: 'hide-delay' })\n accessor hideDelay = 0;\n\n private _showTimer?: ReturnType<typeof setTimeout>;\n private _hideTimer?: ReturnType<typeof setTimeout>;\n\n /** Whether or not the tooltip is visible. */\n @property({ type: Boolean, reflect: true })\n accessor open = false;\n\n /** Hide the directional arrow. */\n @property({ type: Boolean, reflect: true, attribute: 'without-arrow' })\n accessor withoutArrow = false;\n\n /** Space-separated list of trigger modes: `hover`, `focus`, `click`, `manual`. */\n @property()\n accessor trigger = 'hover focus';\n\n private _hasTrigger(type: string) {\n return this.trigger.split(' ').includes(type);\n }\n\n private get _trigger(): HTMLElement | null {\n return this._triggerFor(this.for);\n }\n\n private _triggerFor(id: string): HTMLElement | null {\n if (!id) return null;\n // A detached tooltip's root is a plain element with no getElementById —\n // async open/close work (e.g. an eviction) may land after removal.\n const root = this.getRootNode();\n return root instanceof Document || root instanceof ShadowRoot ? root.getElementById(id) : null;\n }\n\n private get _popover(): HTMLElement {\n return this.shadowRoot!.querySelector('[popover]')!;\n }\n\n private get _arrowEl(): HTMLElement | null {\n return this.withoutArrow ? null : this.shadowRoot!.querySelector('i');\n }\n\n override connectedCallback() {\n super.connectedCallback();\n tooltipInstances.add(this);\n requestAnimationFrame(() => this._addTriggerListeners());\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n tooltipInstances.delete(this);\n if (activeTooltip === this) activeTooltip = null;\n this._clearTimers();\n // `aria-describedby` is dropped by the controller's hostDisconnected: our\n // id stops resolving once we leave the tree.\n this._removeTriggerListeners();\n }\n\n override updated(changed: PropertyValues<this>) {\n // `for` before `open`: retargeting an already-open bubble has to settle\n // against the new anchor, and when both change in the same update the open\n // path owns the positioning outright (see the guard below).\n if (changed.has('for')) {\n // A queued show/hide targets the old trigger — drop it before rewiring.\n this._clearTimers();\n this._removeTriggerListeners(changed.get('for'));\n this._addTriggerListeners();\n if (this.open && !changed.has('open')) {\n void this._repositionToTrigger();\n }\n }\n if (changed.has('open')) {\n void this._handleOpenChange();\n }\n }\n\n /** Cancel any pending delayed show/hide (trigger gone, `for` changed, disconnect). */\n private _clearTimers() {\n clearTimeout(this._showTimer);\n clearTimeout(this._hideTimer);\n this._showTimer = undefined;\n this._hideTimer = undefined;\n }\n\n show() {\n if (!this.open) this.open = true;\n }\n\n hide() {\n if (this.open) this.open = false;\n }\n\n toggle() {\n this.open = !this.open;\n }\n\n /**\n * Recompute the position against the current trigger. Use it when you move\n * the anchor yourself and the tooltip has to follow. No-op when closed;\n * hides if the anchor is gone.\n */\n // Worth calling even though positioning is otherwise automatic: the\n // underlying observers detect a moved anchor a frame late, and an anchor\n // driven at frame rate (a marker following the pointer) can starve them for\n // as long as a second. An explicit call bypasses them.\n async reposition() {\n if (!this.open) return;\n await this._repositionToTrigger();\n }\n\n /**\n * Move the open bubble onto whatever `for` names now — a move, not a\n * re-open, so it deliberately bypasses `_handleOpenChange` and its show\n * animation. Shared by the public `reposition()` and the retarget path so\n * the two cannot drift apart.\n */\n private async _repositionToTrigger() {\n // The polygon was armed against the anchor's previous geometry.\n this._floating.cleanupSafePolygon();\n const openFor = this.for;\n const result = await this._floating.reposition(\n this._positionOptions(),\n () => this.open && this.for === openFor,\n );\n // Closed or retargeted again while `computePosition` was in flight —\n // whatever superseded us owns the bubble and its ARIA now.\n if (result === 'stale') return;\n // Retargeted onto an id that resolves to nothing — a virtualised row\n // recycled between `pointerenter` and here, say. A bubble left floating\n // over unrelated content while describing no element is worse than none.\n if (result === 'no-anchor') {\n this.hide();\n return;\n }\n this._floating.markTrigger('aria-describedby', this._tooltipId, null);\n }\n\n private _positionOptions() {\n return { placement: this.placement, distance: this.distance };\n }\n\n private async _handleOpenChange() {\n const popover = this._popover;\n if (!popover) return;\n\n const posOpts = this._positionOptions();\n\n if (this.open) {\n // Single-open invariant: opening a non-manual tooltip evicts the current\n // one. The evicted tooltip's hide flows back through this method, which\n // also removes its safe-polygon `pointermove` listener.\n if (!this._hasTrigger('manual')) {\n if (activeTooltip && activeTooltip !== this) activeTooltip.hide();\n activeTooltip = this;\n }\n popover.showPopover();\n await this._floating.updatePosition(posOpts);\n if (!this.open) return;\n await this._floating.animateShow(popover);\n this._floating.startPositioning(posOpts);\n this._floating.markTrigger('aria-describedby', this._tooltipId, null);\n } else {\n if (activeTooltip === this) activeTooltip = null;\n this._floating.stopPositioning();\n this._floating.cleanupSafePolygon();\n this._floating.releaseTrigger(null);\n await this._floating.animateHide(popover);\n if (popover.matches(':popover-open')) popover.hidePopover();\n }\n }\n\n // --- Trigger event handlers ---\n\n private _onPointerEnter = () => {\n if (!this._hasTrigger('hover')) return;\n // The safe polygon means \"the pointer is travelling toward the bubble\" —\n // provably false once the pointer enters another tooltip's trigger. Drop\n // our own stale polygon, and close every peer now: invalidating a peer's\n // polygon without hiding it leaves the peer stuck open, because its only\n // remaining close path was eviction when *this* tooltip opens — and with\n // `show-delay` that can be much later, or never if the pointer moves on\n // before the dwell elapses (a fast sweep across a button group).\n this._floating.cleanupSafePolygon();\n for (const tooltip of tooltipInstances) {\n if (tooltip === this || tooltip._hasTrigger('manual')) continue;\n tooltip._floating.cleanupSafePolygon();\n tooltip.hide();\n }\n // The pointer is back on the trigger: cancel a pending hide (exit-and-return).\n clearTimeout(this._hideTimer);\n this._hideTimer = undefined;\n if (this.showDelay > 0 && !this.open) {\n clearTimeout(this._showTimer);\n this._showTimer = setTimeout(() => this.show(), this.showDelay);\n } else {\n this.show();\n }\n };\n\n private _onPointerLeave = (e: PointerEvent) => {\n // Cancel a still-pending show — the pointer left before the dwell elapsed.\n clearTimeout(this._showTimer);\n this._showTimer = undefined;\n if (!this._hasTrigger('hover') || !this.open) return;\n // `exit` — the pointer actively moved off the trigger/bubble: honour\n // `hide-delay` so a brief exit-and-return doesn't flicker. `settled` — the\n // pointer left and sat motionless in the corridor: there is no in-flight\n // gesture to bridge, so hide at once (never stack the delay on top).\n this._floating.handlePointerLeave(e, (reason) => {\n if (reason === 'settled') this.hide();\n else this._scheduleHide();\n });\n };\n\n /** Hide now, or after `hide-delay` if set (cancellable by a pointer return). */\n private _scheduleHide() {\n if (this.hideDelay > 0) {\n clearTimeout(this._hideTimer);\n this._hideTimer = setTimeout(() => this.hide(), this.hideDelay);\n } else {\n this.hide();\n }\n }\n\n private _onFocusIn = () => {\n if (!this._hasTrigger('focus')) return;\n // Keyboard focus only. A pointer click focuses the trigger too, but the\n // pointer already drives the `hover` trigger — showing on mouse focus would\n // resurrect the tooltip when a modal (e.g. `l-dialog`) restores focus to\n // the trigger on close. `:focus-visible` is exactly \"focus that warrants a\n // visible affordance\", matching the platform's own `title`/APG behaviour.\n if (!this._trigger?.matches(':focus-visible')) return;\n // Focus is a discrete affordance — show immediately, ignoring the dwell delay.\n clearTimeout(this._hideTimer);\n this._hideTimer = undefined;\n this.show();\n };\n private _onFocusOut = () => {\n if (this._hasTrigger('focus')) {\n // A hover may have queued a show; blur must not resurrect it.\n clearTimeout(this._showTimer);\n this._showTimer = undefined;\n this.hide();\n }\n };\n private _onClick = () => {\n if (this._hasTrigger('click')) this.toggle();\n };\n\n private _onKeyDown = (e: KeyboardEvent) => {\n if (this.open && e.key === 'Escape') {\n e.stopPropagation();\n this.hide();\n }\n };\n\n private _addTriggerListeners() {\n this._floating.addTriggerListeners({\n onPointerEnter: this._onPointerEnter,\n onPointerLeave: this._onPointerLeave,\n onFocusIn: this._onFocusIn,\n onFocusOut: this._onFocusOut,\n onClick: this._onClick,\n onKeyDown: this._onKeyDown,\n });\n }\n\n private _removeTriggerListeners(forId?: string) {\n this._floating.removeTriggerListeners(forId ? this._triggerFor(forId) : undefined);\n }\n\n override render() {\n return html`\n <div\n id=${this._tooltipId}\n popover=\"manual\"\n role=\"tooltip\"\n part=\"body\"\n >\n ${\n this.withoutArrow\n ? nothing\n : html`\n <i\n part=\"arrow\"\n role=\"presentation\"\n ></i>\n `\n }\n <slot></slot>\n </div>\n `;\n }\n}\n"],"mappings":"A,oXCSA,IAAMW,EAASX,EAAUC,w7BAAS,EAW5BW,EAAmB,IAAI,IACzBC,EAAgC,KAmBvBC,EAAb,cAA6BC,CAAa,C,8BAGnB,KAAA,WAAAE,EAAS,SAAS,EAEnB,KAAA,UAAA,IAAIC,EAAkB,KAAM,CAC9C,sBAAyB,KAAK,SAC9B,uBAA0B,KAAK,SAC/B,oBAAuB,KAAK,QAC9B,CAAC,EAIc,KAAAC,GAAA,GAIiB,KAAAC,GAAA,MAIZ,KAA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
25
|
* commit/close semantics.
|
|
26
26
|
*
|
|
27
27
|
* Home/End are intentionally not handled — an editable combobox reserves them
|
|
28
|
-
* for the text cursor (ARIA APG). Shared by `l-combobox` and
|
|
28
|
+
* for the text cursor (ARIA APG). Shared by `l-combobox` and `l-select`.
|
|
29
29
|
*/
|
|
30
30
|
export declare class ListboxNavController implements ReactiveController {
|
|
31
31
|
private host;
|
|
@@ -44,6 +44,20 @@ export declare class ListboxNavController implements ReactiveController {
|
|
|
44
44
|
setActive(index: number): void;
|
|
45
45
|
/** Move the active option by `diff`, opening the listbox first if closed. */
|
|
46
46
|
move(diff: 1 | -1): void;
|
|
47
|
+
/**
|
|
48
|
+
* Bind on the `role="listbox"` as `@pointermove`: the option under the mouse
|
|
49
|
+
* becomes the active one, so hover and keyboard share a single highlight (and
|
|
50
|
+
* Enter commits what is highlighted). One delegated, stable listener instead
|
|
51
|
+
* of one per option. Touch is ignored, or a finger scrolling the list would
|
|
52
|
+
* drag the active option along; a disabled row clears it, so the highlight
|
|
53
|
+
* never stays on a row the pointer has left.
|
|
54
|
+
*/
|
|
55
|
+
readonly onPointerMove: (e: PointerEvent) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Bind on the `role="listbox"` as `@pointerleave`: once the mouse leaves the
|
|
58
|
+
* list, the row it last crossed no longer decides what Enter commits.
|
|
59
|
+
*/
|
|
60
|
+
readonly onPointerLeave: (e: PointerEvent) => void;
|
|
47
61
|
/**
|
|
48
62
|
* Handle a keydown for listbox navigation. Returns `true` when the key was
|
|
49
63
|
* consumed, so the host can early-return before its own Enter/Escape/Tab
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox-nav.d.ts","sourceRoot":"","sources":["../../../src/html/shared/controllers/listbox-nav.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IAC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activeIndex=-1,this.host=e,this.config=t,e.addController(this)}hostConnected(){}optionId(e){return`${this.config.listboxId}-opt-${e}`}get activeDescendant(){return this.config.isOpen()&&this.activeIndex>=0?this.optionId(this.activeIndex):void 0}reset(){this.activeIndex!==-1&&(this.activeIndex=-1,this.host.requestUpdate())}setActive(e){this.activeIndex!==e&&(this.activeIndex=e,this.host.requestUpdate())}move(e){this.config.isOpen()||(this.config.open(),this.activeIndex=e>0?-1:this.config.getCount()),this._step(e)}onKeyDown(e){switch(e.key){case`ArrowDown`:return e.preventDefault(),this.move(1),!0;case`ArrowUp`:return e.preventDefault(),this.move(-1),!0;default:return!1}}_step(e){let t=this.config.getCount();if(t===0)return;let n=this.activeIndex+e;n<0&&(n=t-1),n>=t&&(n=0);let r=n;for(;this.config.isDisabled(n);)if(n+=e,n<0&&(n=t-1),n>=t&&(n=0),n===r)return;this.activeIndex=n,this.host.requestUpdate(),this.host.updateComplete.then(()=>this._scrollActiveIntoView())}_scrollActiveIntoView(){this.config.getOptionElements()?.[this.activeIndex]?.scrollIntoView({block:`nearest`})}};export{e as ListboxNavController};
|
|
1
|
+
var e=class{constructor(e,t){this.activeIndex=-1,this.onPointerMove=e=>{if(e.pointerType===`touch`)return;let t=e.target.closest(`[role="option"]`);if(!t)return;let n=Array.prototype.indexOf.call(this.config.getOptionElements()??[],t);n<0||(this.config.isDisabled(n)?this.reset():this.setActive(n))},this.onPointerLeave=e=>{e.pointerType!==`touch`&&this.reset()},this.host=e,this.config=t,e.addController(this)}hostConnected(){}optionId(e){return`${this.config.listboxId}-opt-${e}`}get activeDescendant(){return this.config.isOpen()&&this.activeIndex>=0?this.optionId(this.activeIndex):void 0}reset(){this.activeIndex!==-1&&(this.activeIndex=-1,this.host.requestUpdate())}setActive(e){this.activeIndex!==e&&(this.activeIndex=e,this.host.requestUpdate())}move(e){this.config.isOpen()||(this.config.open(),this.activeIndex=e>0?-1:this.config.getCount()),this._step(e)}onKeyDown(e){switch(e.key){case`ArrowDown`:return e.preventDefault(),this.move(1),!0;case`ArrowUp`:return e.preventDefault(),this.move(-1),!0;default:return!1}}_step(e){let t=this.config.getCount();if(t===0)return;let n=this.activeIndex+e;n<0&&(n=t-1),n>=t&&(n=0);let r=n;for(;this.config.isDisabled(n);)if(n+=e,n<0&&(n=t-1),n>=t&&(n=0),n===r)return;this.activeIndex=n,this.host.requestUpdate(),this.host.updateComplete.then(()=>this._scrollActiveIntoView())}_scrollActiveIntoView(){this.config.getOptionElements()?.[this.activeIndex]?.scrollIntoView({block:`nearest`})}};export{e as ListboxNavController};
|
|
2
2
|
//# sourceMappingURL=listbox-nav.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox-nav.js","names":["ListboxNavController","
|
|
1
|
+
{"version":3,"file":"listbox-nav.js","names":["ListboxNavController","row","index","host","config","diff","n","i","start"],"sources":["../../../src/html/shared/controllers/listbox-nav.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\n/**\n * Configuration for {@link ListboxNavController}. All accessors are read lazily,\n * so the host can back them with getters over its own reactive state.\n */\nexport interface ListboxNavConfig {\n /** Stable id of the `role=\"listbox\"`; option ids derive from it. */\n listboxId: string;\n /** Number of currently navigable options. */\n getCount: () => number;\n /** Whether the option at `index` is disabled (skipped while navigating). */\n isDisabled: (index: number) => boolean;\n /** Whether the listbox is currently open. */\n isOpen: () => boolean;\n /** Open the listbox — called when a navigation key is pressed while closed. */\n open: () => void;\n /** The rendered option elements, in order, for scroll-into-view. */\n getOptionElements: () => ArrayLike<HTMLElement> | null | undefined;\n}\n\n/**\n * Owns roving `aria-activedescendant` navigation for the combobox/listbox\n * pattern: Arrow Up/Down move a virtual cursor over a `role=\"listbox\"` while DOM\n * focus stays on the host input, skipping disabled options and scrolling the\n * active one into view. Enter/Escape/Tab stay with the host, which owns\n * commit/close semantics.\n *\n * Home/End are intentionally not handled — an editable combobox reserves them\n * for the text cursor (ARIA APG). Shared by `l-combobox` and `l-select`.\n */\nexport class ListboxNavController implements ReactiveController {\n private host: ReactiveControllerHost;\n private config: ListboxNavConfig;\n\n /** Index of the active option, or `-1` when none is active. */\n activeIndex = -1;\n\n constructor(host: ReactiveControllerHost, config: ListboxNavConfig) {\n this.host = host;\n this.config = config;\n host.addController(this);\n }\n\n hostConnected() {}\n\n /** The DOM id for the option at `index` (matches the rendered option `id`). */\n optionId(index: number): string {\n return `${this.config.listboxId}-opt-${index}`;\n }\n\n /** `aria-activedescendant` value for the input, or `undefined` when none. */\n get activeDescendant(): string | undefined {\n return this.config.isOpen() && this.activeIndex >= 0\n ? this.optionId(this.activeIndex)\n : undefined;\n }\n\n /** Clear the active option. */\n reset() {\n if (this.activeIndex === -1) return;\n this.activeIndex = -1;\n this.host.requestUpdate();\n }\n\n /** Set the active option explicitly (e.g. pre-activate the current value). */\n setActive(index: number) {\n if (this.activeIndex === index) return;\n this.activeIndex = index;\n this.host.requestUpdate();\n }\n\n /** Move the active option by `diff`, opening the listbox first if closed. */\n move(diff: 1 | -1) {\n if (!this.config.isOpen()) {\n this.config.open();\n // Land on the first (Down) or last (Up) option — APG.\n this.activeIndex = diff > 0 ? -1 : this.config.getCount();\n }\n this._step(diff);\n }\n\n /**\n * Bind on the `role=\"listbox\"` as `@pointermove`: the option under the mouse\n * becomes the active one, so hover and keyboard share a single highlight (and\n * Enter commits what is highlighted). One delegated, stable listener instead\n * of one per option. Touch is ignored, or a finger scrolling the list would\n * drag the active option along; a disabled row clears it, so the highlight\n * never stays on a row the pointer has left.\n */\n readonly onPointerMove = (e: PointerEvent) => {\n if (e.pointerType === 'touch') return;\n const row = (e.target as Element).closest('[role=\"option\"]');\n if (!row) return;\n const index = Array.prototype.indexOf.call(this.config.getOptionElements() ?? [], row);\n if (index < 0) return;\n if (this.config.isDisabled(index)) this.reset();\n else this.setActive(index);\n };\n\n /**\n * Bind on the `role=\"listbox\"` as `@pointerleave`: once the mouse leaves the\n * list, the row it last crossed no longer decides what Enter commits.\n */\n readonly onPointerLeave = (e: PointerEvent) => {\n if (e.pointerType === 'touch') return;\n this.reset();\n };\n\n /**\n * Handle a keydown for listbox navigation. Returns `true` when the key was\n * consumed, so the host can early-return before its own Enter/Escape/Tab\n * handling.\n */\n onKeyDown(e: KeyboardEvent): boolean {\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n this.move(1);\n return true;\n case 'ArrowUp':\n e.preventDefault();\n this.move(-1);\n return true;\n default:\n return false;\n }\n }\n\n private _step(diff: 1 | -1) {\n const n = this.config.getCount();\n if (n === 0) return;\n let i = this.activeIndex + diff;\n if (i < 0) i = n - 1;\n if (i >= n) i = 0;\n // Skip disabled options, bailing if every option is disabled.\n const start = i;\n while (this.config.isDisabled(i)) {\n i += diff;\n if (i < 0) i = n - 1;\n if (i >= n) i = 0;\n if (i === start) return;\n }\n this.activeIndex = i;\n this.host.requestUpdate();\n void this.host.updateComplete.then(() => this._scrollActiveIntoView());\n }\n\n private _scrollActiveIntoView() {\n const opts = this.config.getOptionElements();\n opts?.[this.activeIndex]?.scrollIntoView({ block: 'nearest' });\n }\n}\n"],"mappings":"AA+BA,IAAaA,EAAb,KAAgE,CAO9D,YAAY,EAA8B,EAA0B,CAFtD,KAAA,YAAA,GAsDY,KAAA,cAAA,GAAoB,CAC5C,GAAI,EAAE,cAAgB,QAAS,OAC/B,IAAMC,EAAO,EAAE,OAAmB,QAAQ,iBAAiB,EAC3D,GAAI,CAACA,EAAK,OACV,IAAMC,EAAQ,MAAM,UAAU,QAAQ,KAAK,KAAK,OAAO,kBAAkB,GAAK,CAAC,EAAGD,CAAG,EACjFC,EAAQ,IACR,KAAK,OAAO,WAAWA,CAAK,EAAG,KAAK,MAAM,EACzC,KAAK,UAAUA,CAAK,EAC3B,EAM2B,KAAA,eAAA,GAAoB,CACzC,EAAE,cAAgB,SACtB,KAAK,MAAM,CACb,EApEE,KAAK,KAAOC,EACZ,KAAK,OAASC,EACdD,EAAK,cAAc,IAAI,CACzB,CAEA,eAAgB,CAAC,CAGjB,SA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/D,CACF,E"}
|
|
@@ -82,8 +82,16 @@ export declare class PopoverController implements ReactiveController {
|
|
|
82
82
|
cleanupSafePolygon(): void;
|
|
83
83
|
addTriggerListeners(handlers: TriggerHandlers): void;
|
|
84
84
|
removeTriggerListeners(triggerOverride?: HTMLElement | null): void;
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
/**
|
|
86
|
+
* The host's `--show-duration` / `--hide-duration`, in ms. Accepts a CSS time
|
|
87
|
+
* or a bare number of ms (`150`, `150ms` and `0.15s` all read as 150); falls
|
|
88
|
+
* back to 150 when unset or unparsable.
|
|
89
|
+
*/
|
|
90
|
+
durationOf(prop: '--show-duration' | '--hide-duration'): number;
|
|
91
|
+
/** Fade/scale `el` in over `duration` ms — the host's `--show-duration` by default. */
|
|
92
|
+
animateShow(el: HTMLElement, duration?: number, keyframes?: Keyframe[]): Promise<void>;
|
|
93
|
+
/** Fade/scale `el` out over `duration` ms — the host's `--hide-duration` by default. */
|
|
94
|
+
animateHide(el: HTMLElement, duration?: number, keyframes?: Keyframe[]): Promise<void>;
|
|
87
95
|
}
|
|
88
96
|
export {};
|
|
89
97
|
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../../src/html/shared/controllers/popover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAC;AACtE,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AA+N1B,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAC5C,kBAAkB,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAC7C,eAAe,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAC1C,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED;;;;GAIG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E,OAAO,EAAE,MAAM,GAAG,IAAI,QAOnE;IAED;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,QAIlC;IAED,OAAO,CAAC,aAAa;IAQrB,IAAI,gBAAgB,WAEnB;IAIK,cAAc,CAAC,OAAO,EAAE,eAAe,iBAqD5C;IAED,gBAAgB,CAAC,OAAO,EAAE,eAAe,QAOxC;IAED;;;;;;;;;;;;;;OAcG;IACG,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAO9F;IAED,eAAe,SAGd;IAID,kBAAkB,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,QAgF/E;IAED,kBAAkB,SAGjB;IAID,mBAAmB,CAAC,QAAQ,EAAE,eAAe,QAkB5C;IAED,sBAAsB,CAAC,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,QAqB1D;IAID;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,GAAG,MAAM,CAK9D;IAED,uFAAuF;IACjF,WAAW,CACf,EAAE,EAAE,WAAW,EACf,QAAQ,SAAqC,EAC7C,SAAS,CAAC,EAAE,QAAQ,EAAE,iBAWvB;IAED,wFAAwF;IAClF,WAAW,CACf,EAAE,EAAE,WAAW,EACf,QAAQ,SAAqC,EAC7C,SAAS,CAAC,EAAE,QAAQ,EAAE,iBAWvB;CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"../../chunks/floating-ui.dom.js";var s=200;function c([e,t],n){let r=!1;for(let i=0,a=n.length-1;i<n.length;a=i++){let[o,s]=n[i],[c,l]=n[a];s>=t!=l>=t&&e<=(c-o)*(t-s)/(l-s)+o&&(r=!r)}return r}function l([e,t],n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function u(e,t,n,r,i){let a=i.split(`-`)[0],o=n.width>r.width,s=n.height>r.height,c=e>n.right-n.width/2,l=t>n.bottom-n.height/2;switch(a){case`top`:return[[o?e+1:c?e+8:e-8,t+2+1],[o?e-1:c?e+8:e-8,t+2+1],[n.left,c||o?n.bottom-2:n.top],[n.right,c?o?n.bottom-2:n.top:n.bottom-2]];case`bottom`:return[[o?e+1:c?e+8:e-8,t-2],[o?e-1:c?e+8:e-8,t-2],[n.left,c||o?n.top+2:n.bottom],[n.right,c?o?n.top+2:n.bottom:n.top+2]];case`left`:{let r=[e+2+1,s?t+1:l?t+8:t-8],i=[e+2+1,s?t-1:l?t+8:t-8];return[[l||s?n.right-2:n.left,n.top],[l?s?n.right-2:n.left:n.right-2,n.bottom],r,i]}case`right`:{let r=[e-2,s?t+1:l?t+8:t-8],i=[e-2,s?t-1:l?t+8:t-8];return[[l||s?n.left+2:n.right,n.top],[l?s?n.left+2:n.right:n.left+2,n.bottom],r,i]}default:return[]}}var d={top:`bottom`,right:`left`,bottom:`top`,left:`right`},f=typeof window<`u`?window.matchMedia(`(prefers-reduced-motion: reduce)`):void 0,p=class{constructor(e,t){this._currentPlacement=``,this._markedTrigger=null,this._markedAttribute=null,this._host=e,this._config=t,e.addController(this)}hostConnected(){}hostDisconnected(){this.stopPositioning(),this.cleanupSafePolygon(),this.releaseTrigger(null),this.removeTriggerListeners()}markTrigger(e,t,n){let r=this._config.getTriggerElement();(this._markedTrigger!==r||this._markedAttribute!==e)&&(this._settleMarked(n),r?.setAttribute(e,t),this._markedTrigger=r,this._markedAttribute=e)}releaseTrigger(e){this._settleMarked(e),this._markedTrigger=null,this._markedAttribute=null}_settleMarked(e){let t=this._markedTrigger,n=this._markedAttribute;t&&n&&(e===null?t.removeAttribute(n):t.setAttribute(n,e))}get currentPlacement(){return this._currentPlacement}async updatePosition(n){let s=this._config.getTriggerElement(),c=this._config.getFloatingElement(),l=this._config.getArrowElement();if(!s||!c)return;let u=[e({mainAxis:n.distance,crossAxis:n.skidding??0}),...n.minWidth===`trigger`?[a({apply({rects:e,elements:t}){t.floating.style.minWidth=`${e.reference.width}px`}})]:[],t(),r(),...l?[o({element:l,padding:8})]:[]],{x:f,y:p,placement:m,middlewareData:h}=await i(s,c,{placement:n.placement,strategy:`fixed`,middleware:u});if(Object.assign(c.style,{position:`fixed`,left:n.fullWidth?`0px`:`${f}px`,top:`${p}px`,width:n.fullWidth?`100vw`:``}),n.minWidth!==`trigger`&&(c.style.minWidth=``),m!==this._currentPlacement&&(this._currentPlacement=m,this._config.onPlacementChange?.(m)),h.arrow&&l){let{x:e,y:t}=h.arrow,n=d[m.split(`-`)[0]];Object.assign(l.style,{left:e==null?``:`${e}px`,top:t==null?``:`${t}px`,[n]:`${-l.offsetWidth/2}px`})}}startPositioning(e){let t=this._config.getTriggerElement(),r=this._config.getFloatingElement();t&&r&&(this._cleanupAutoUpdate?.(),this._cleanupAutoUpdate=n(t,r,()=>this.updatePosition(e)))}async reposition(e,t){return this._config.getTriggerElement()?(this.stopPositioning(),await this.updatePosition(e),t()?(this.startPositioning(e),`repositioned`):`stale`):`no-anchor`}stopPositioning(){this._cleanupAutoUpdate?.(),this._cleanupAutoUpdate=void 0}handlePointerLeave(e,t){let n=this._config.getFloatingElement(),r=this._config.getTriggerElement();if(!n||!r){t(`exit`);return}let i=e.clientX,a=e.clientY,o,d=e=>{h(),t(e)},f=()=>clearTimeout(o),p=()=>{clearTimeout(o),o=setTimeout(()=>d(`settled`),s)},m=e=>{let{clientX:t,clientY:o}=e,s=[t,o],m=n.getBoundingClientRect(),h=r.getBoundingClientRect(),g=this._currentPlacement.split(`-`)[0];l(s,m)||l(s,h)?f():g===`top`&&a>=h.bottom-1||g===`bottom`&&a<=h.top+1||g===`left`&&i>=h.right-1||g===`right`&&i<=h.left+1?d(`exit`):c(s,u(i,a,m,h,this._currentPlacement))?p():d(`exit`)},h=()=>{clearTimeout(o),document.removeEventListener(`pointermove`,m)};document.addEventListener(`pointermove`,m),p(),this._cleanupSafePolygon?.(),this._cleanupSafePolygon=h}cleanupSafePolygon(){this._cleanupSafePolygon?.(),this._cleanupSafePolygon=void 0}addTriggerListeners(e){let t=this._config.getTriggerElement();t&&(this._handlers=e,this._triggerElement=t,e.onPointerEnter&&t.addEventListener(`pointerenter`,e.onPointerEnter),e.onPointerLeave&&t.addEventListener(`pointerleave`,e.onPointerLeave),e.onFocusIn&&t.addEventListener(`focusin`,e.onFocusIn),e.onFocusOut&&t.addEventListener(`focusout`,e.onFocusOut),e.onClick&&t.addEventListener(`click`,e.onClick),e.onKeyDown&&t.addEventListener(`keydown`,e.onKeyDown))}removeTriggerListeners(e){let t=e??this._triggerElement,n=this._handlers;t&&n&&(n.onPointerEnter&&t.removeEventListener(`pointerenter`,n.onPointerEnter),n.onPointerLeave&&t.removeEventListener(`pointerleave`,n.onPointerLeave),n.onFocusIn&&t.removeEventListener(`focusin`,n.onFocusIn),n.onFocusOut&&t.removeEventListener(`focusout`,n.onFocusOut),n.onClick&&t.removeEventListener(`click`,n.onClick),n.onKeyDown&&t.removeEventListener(`keydown`,n.onKeyDown),e||(this._handlers=void 0,this._triggerElement=void 0))}async animateShow(e,t,n){let r=f?.matches?0:t;e.getAnimations().forEach(e=>e.cancel()),e.animate(n??[{opacity:0,scale:.96},{opacity:1,scale:1}],{duration:r,fill:`forwards`})}async animateHide(e,t,n){let r=f?.matches?0:t;await e.animate(n??[{opacity:1,scale:1},{opacity:0,scale:.96}],{duration:r,fill:`forwards`}).finished}};export{p as PopoverController};
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"../../chunks/floating-ui.dom.js";var s=200;function c([e,t],n){let r=!1;for(let i=0,a=n.length-1;i<n.length;a=i++){let[o,s]=n[i],[c,l]=n[a];s>=t!=l>=t&&e<=(c-o)*(t-s)/(l-s)+o&&(r=!r)}return r}function l([e,t],n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function u(e,t,n,r,i){let a=i.split(`-`)[0],o=n.width>r.width,s=n.height>r.height,c=e>n.right-n.width/2,l=t>n.bottom-n.height/2;switch(a){case`top`:return[[o?e+1:c?e+8:e-8,t+2+1],[o?e-1:c?e+8:e-8,t+2+1],[n.left,c||o?n.bottom-2:n.top],[n.right,c?o?n.bottom-2:n.top:n.bottom-2]];case`bottom`:return[[o?e+1:c?e+8:e-8,t-2],[o?e-1:c?e+8:e-8,t-2],[n.left,c||o?n.top+2:n.bottom],[n.right,c?o?n.top+2:n.bottom:n.top+2]];case`left`:{let r=[e+2+1,s?t+1:l?t+8:t-8],i=[e+2+1,s?t-1:l?t+8:t-8];return[[l||s?n.right-2:n.left,n.top],[l?s?n.right-2:n.left:n.right-2,n.bottom],r,i]}case`right`:{let r=[e-2,s?t+1:l?t+8:t-8],i=[e-2,s?t-1:l?t+8:t-8];return[[l||s?n.left+2:n.right,n.top],[l?s?n.left+2:n.right:n.left+2,n.bottom],r,i]}default:return[]}}var d={top:`bottom`,right:`left`,bottom:`top`,left:`right`},f=typeof window<`u`?window.matchMedia(`(prefers-reduced-motion: reduce)`):void 0,p=class{constructor(e,t){this._currentPlacement=``,this._markedTrigger=null,this._markedAttribute=null,this._host=e,this._config=t,e.addController(this)}hostConnected(){}hostDisconnected(){this.stopPositioning(),this.cleanupSafePolygon(),this.releaseTrigger(null),this.removeTriggerListeners()}markTrigger(e,t,n){let r=this._config.getTriggerElement();(this._markedTrigger!==r||this._markedAttribute!==e)&&(this._settleMarked(n),r?.setAttribute(e,t),this._markedTrigger=r,this._markedAttribute=e)}releaseTrigger(e){this._settleMarked(e),this._markedTrigger=null,this._markedAttribute=null}_settleMarked(e){let t=this._markedTrigger,n=this._markedAttribute;t&&n&&(e===null?t.removeAttribute(n):t.setAttribute(n,e))}get currentPlacement(){return this._currentPlacement}async updatePosition(n){let s=this._config.getTriggerElement(),c=this._config.getFloatingElement(),l=this._config.getArrowElement();if(!s||!c)return;let u=[e({mainAxis:n.distance,crossAxis:n.skidding??0}),...n.minWidth===`trigger`?[a({apply({rects:e,elements:t}){t.floating.style.minWidth=`${e.reference.width}px`}})]:[],t(),r(),...l?[o({element:l,padding:8})]:[]],{x:f,y:p,placement:m,middlewareData:h}=await i(s,c,{placement:n.placement,strategy:`fixed`,middleware:u});if(Object.assign(c.style,{position:`fixed`,left:n.fullWidth?`0px`:`${f}px`,top:`${p}px`,width:n.fullWidth?`100vw`:``}),n.minWidth!==`trigger`&&(c.style.minWidth=``),m!==this._currentPlacement&&(this._currentPlacement=m,this._config.onPlacementChange?.(m)),h.arrow&&l){let{x:e,y:t}=h.arrow,n=d[m.split(`-`)[0]];Object.assign(l.style,{left:e==null?``:`${e}px`,top:t==null?``:`${t}px`,[n]:`${-l.offsetWidth/2}px`})}}startPositioning(e){let t=this._config.getTriggerElement(),r=this._config.getFloatingElement();t&&r&&(this._cleanupAutoUpdate?.(),this._cleanupAutoUpdate=n(t,r,()=>this.updatePosition(e)))}async reposition(e,t){return this._config.getTriggerElement()?(this.stopPositioning(),await this.updatePosition(e),t()?(this.startPositioning(e),`repositioned`):`stale`):`no-anchor`}stopPositioning(){this._cleanupAutoUpdate?.(),this._cleanupAutoUpdate=void 0}handlePointerLeave(e,t){let n=this._config.getFloatingElement(),r=this._config.getTriggerElement();if(!n||!r){t(`exit`);return}let i=e.clientX,a=e.clientY,o,d=e=>{h(),t(e)},f=()=>clearTimeout(o),p=()=>{clearTimeout(o),o=setTimeout(()=>d(`settled`),s)},m=e=>{let{clientX:t,clientY:o}=e,s=[t,o],m=n.getBoundingClientRect(),h=r.getBoundingClientRect(),g=this._currentPlacement.split(`-`)[0];l(s,m)||l(s,h)?f():g===`top`&&a>=h.bottom-1||g===`bottom`&&a<=h.top+1||g===`left`&&i>=h.right-1||g===`right`&&i<=h.left+1?d(`exit`):c(s,u(i,a,m,h,this._currentPlacement))?p():d(`exit`)},h=()=>{clearTimeout(o),document.removeEventListener(`pointermove`,m)};document.addEventListener(`pointermove`,m),p(),this._cleanupSafePolygon?.(),this._cleanupSafePolygon=h}cleanupSafePolygon(){this._cleanupSafePolygon?.(),this._cleanupSafePolygon=void 0}addTriggerListeners(e){let t=this._config.getTriggerElement();t&&(this._handlers=e,this._triggerElement=t,e.onPointerEnter&&t.addEventListener(`pointerenter`,e.onPointerEnter),e.onPointerLeave&&t.addEventListener(`pointerleave`,e.onPointerLeave),e.onFocusIn&&t.addEventListener(`focusin`,e.onFocusIn),e.onFocusOut&&t.addEventListener(`focusout`,e.onFocusOut),e.onClick&&t.addEventListener(`click`,e.onClick),e.onKeyDown&&t.addEventListener(`keydown`,e.onKeyDown))}removeTriggerListeners(e){let t=e??this._triggerElement,n=this._handlers;t&&n&&(n.onPointerEnter&&t.removeEventListener(`pointerenter`,n.onPointerEnter),n.onPointerLeave&&t.removeEventListener(`pointerleave`,n.onPointerLeave),n.onFocusIn&&t.removeEventListener(`focusin`,n.onFocusIn),n.onFocusOut&&t.removeEventListener(`focusout`,n.onFocusOut),n.onClick&&t.removeEventListener(`click`,n.onClick),n.onKeyDown&&t.removeEventListener(`keydown`,n.onKeyDown),e||(this._handlers=void 0,this._triggerElement=void 0))}durationOf(e){let t=getComputedStyle(this._host).getPropertyValue(e).trim().toLowerCase(),n=parseFloat(t);return Number.isNaN(n)?150:t.endsWith(`s`)&&!t.endsWith(`ms`)?n*1e3:n}async animateShow(e,t=this.durationOf(`--show-duration`),n){let r=f?.matches?0:t;e.getAnimations().forEach(e=>e.cancel()),e.animate(n??[{opacity:0,scale:.96},{opacity:1,scale:1}],{duration:r,fill:`forwards`})}async animateHide(e,t=this.durationOf(`--hide-duration`),n){let r=f?.matches?0:t;await e.animate(n??[{opacity:1,scale:1},{opacity:0,scale:.96}],{duration:r,fill:`forwards`}).finished}};export{p as PopoverController};
|
|
2
2
|
//# sourceMappingURL=popover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":["offset","flip","shift","computePosition","size","arrow","SAFE_POLYGON_REST_HIDE_MS","isPointInPolygon","px","py","inside","j","polygon","xi","yi","xj","yj","isPointInRect","rect","getSafePolygon","side","placement","isFloatingWider","refRect","isFloatingTaller","cursorLeaveFromRight","cursorX","cursorLeaveFromBottom","cursorY","c1","c2","STATIC_SIDE","reducedMotion","PopoverController","host","config","next","attribute","resting","value","el","trigger","floating","arrowEl","middleware","options","rects","x","y","middlewareData","ax","ay","autoUpdate","isCurrent","onHide","fallback","hide","cleanup","reason","stayOpen","armRestHide","onMove","mx","my","moveEvent","cursor","handlers","triggerOverride","d","duration","a","keyframes"],"sources":["../../../src/html/shared/controllers/popover.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport {\n computePosition,\n autoUpdate,\n offset,\n flip,\n shift,\n arrow,\n size,\n type Placement,\n} from '@floating-ui/dom';\n\n// --- Pure geometry helpers ---\n\ntype Point = [number, number];\n\n/**\n * How long the pointer may rest, in the corridor between the trigger and the\n * bubble, before the safe polygon gives up and hides. The polygon is only\n * re-evaluated on `pointermove`, so a pointer that leaves and immediately stops\n * emits no further event to close on — this fallback guarantees the tooltip\n * still hides. Kept short so a genuine pause while travelling toward the bubble\n * re-arms it without a visible flicker. It is *not* armed while the pointer sits\n * on the bubble or the trigger themselves — those are stable \"stay open\" states.\n */\nconst SAFE_POLYGON_REST_HIDE_MS = 200;\n\n/** Check if a point is inside a polygon using ray-casting. */\nfunction isPointInPolygon([px, py]: Point, polygon: Point[]) {\n let inside = false;\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const [xi, yi] = polygon[i];\n const [xj, yj] = polygon[j];\n if (yi >= py !== yj >= py && px <= ((xj - xi) * (py - yi)) / (yj - yi) + xi) {\n inside = !inside;\n }\n }\n return inside;\n}\n\n/** Check if a point is inside a rect. */\nfunction isPointInRect([px, py]: Point, rect: DOMRect) {\n return px >= rect.left && px <= rect.right && py >= rect.top && py <= rect.bottom;\n}\n\n/**\n * Build a safe polygon (triangle/quadrilateral) from cursor to floating element edges.\n * Adapted from floating-ui/safePolygon.\n * @see https://github.com/floating-ui/floating-ui/blob/master/packages/react/src/safePolygon.ts\n */\nfunction getSafePolygon(\n cursorX: number,\n cursorY: number,\n rect: DOMRect,\n refRect: DOMRect,\n placement: string,\n): Point[] {\n const side = placement.split('-')[0] as 'top' | 'bottom' | 'left' | 'right';\n const buffer = 2;\n\n const isFloatingWider = rect.width > refRect.width;\n const isFloatingTaller = rect.height > refRect.height;\n\n const cursorLeaveFromRight = cursorX > rect.right - rect.width / 2;\n const cursorLeaveFromBottom = cursorY > rect.bottom - rect.height / 2;\n\n switch (side) {\n case 'top': {\n const c1: Point = [\n isFloatingWider\n ? cursorX + buffer / 2\n : cursorLeaveFromRight\n ? cursorX + buffer * 4\n : cursorX - buffer * 4,\n cursorY + buffer + 1,\n ];\n const c2: Point = [\n isFloatingWider\n ? cursorX - buffer / 2\n : cursorLeaveFromRight\n ? cursorX + buffer * 4\n : cursorX - buffer * 4,\n cursorY + buffer + 1,\n ];\n return [\n c1,\n c2,\n [\n rect.left,\n cursorLeaveFromRight\n ? rect.bottom - buffer\n : isFloatingWider\n ? rect.bottom - buffer\n : rect.top,\n ],\n [\n rect.right,\n cursorLeaveFromRight\n ? isFloatingWider\n ? rect.bottom - buffer\n : rect.top\n : rect.bottom - buffer,\n ],\n ];\n }\n case 'bottom': {\n const c1: Point = [\n isFloatingWider\n ? cursorX + buffer / 2\n : cursorLeaveFromRight\n ? cursorX + buffer * 4\n : cursorX - buffer * 4,\n cursorY - buffer,\n ];\n const c2: Point = [\n isFloatingWider\n ? cursorX - buffer / 2\n : cursorLeaveFromRight\n ? cursorX + buffer * 4\n : cursorX - buffer * 4,\n cursorY - buffer,\n ];\n return [\n c1,\n c2,\n [\n rect.left,\n cursorLeaveFromRight\n ? rect.top + buffer\n : isFloatingWider\n ? rect.top + buffer\n : rect.bottom,\n ],\n [\n rect.right,\n cursorLeaveFromRight\n ? isFloatingWider\n ? rect.top + buffer\n : rect.bottom\n : rect.top + buffer,\n ],\n ];\n }\n case 'left': {\n const c1: Point = [\n cursorX + buffer + 1,\n isFloatingTaller\n ? cursorY + buffer / 2\n : cursorLeaveFromBottom\n ? cursorY + buffer * 4\n : cursorY - buffer * 4,\n ];\n const c2: Point = [\n cursorX + buffer + 1,\n isFloatingTaller\n ? cursorY - buffer / 2\n : cursorLeaveFromBottom\n ? cursorY + buffer * 4\n : cursorY - buffer * 4,\n ];\n return [\n [\n cursorLeaveFromBottom\n ? rect.right - buffer\n : isFloatingTaller\n ? rect.right - buffer\n : rect.left,\n rect.top,\n ],\n [\n cursorLeaveFromBottom\n ? isFloatingTaller\n ? rect.right - buffer\n : rect.left\n : rect.right - buffer,\n rect.bottom,\n ],\n c1,\n c2,\n ];\n }\n case 'right': {\n const c1: Point = [\n cursorX - buffer,\n isFloatingTaller\n ? cursorY + buffer / 2\n : cursorLeaveFromBottom\n ? cursorY + buffer * 4\n : cursorY - buffer * 4,\n ];\n const c2: Point = [\n cursorX - buffer,\n isFloatingTaller\n ? cursorY - buffer / 2\n : cursorLeaveFromBottom\n ? cursorY + buffer * 4\n : cursorY - buffer * 4,\n ];\n return [\n [\n cursorLeaveFromBottom\n ? rect.left + buffer\n : isFloatingTaller\n ? rect.left + buffer\n : rect.right,\n rect.top,\n ],\n [\n cursorLeaveFromBottom\n ? isFloatingTaller\n ? rect.left + buffer\n : rect.right\n : rect.left + buffer,\n rect.bottom,\n ],\n c1,\n c2,\n ];\n }\n default:\n return [];\n }\n}\n\n// --- Constants ---\n\nconst STATIC_SIDE = { top: 'bottom', right: 'left', bottom: 'top', left: 'right' } as const;\n\nconst reducedMotion =\n typeof window !== 'undefined' ? window.matchMedia('(prefers-reduced-motion: reduce)') : undefined;\n\n// --- Controller ---\n\nexport interface PopoverControllerConfig {\n getTriggerElement: () => HTMLElement | null;\n getFloatingElement: () => HTMLElement | null;\n getArrowElement: () => HTMLElement | null;\n onPlacementChange?: (placement: string) => void;\n}\n\n/**\n * Outcome of {@link PopoverController.reposition}. `stale` means the host\n * closed or retargeted again while `computePosition` was in flight — the caller\n * must not act on it, because whatever superseded it owns the element now.\n */\nexport type RepositionResult = 'repositioned' | 'no-anchor' | 'stale';\n\nexport interface PositionOptions {\n placement: Placement;\n distance: number;\n /** Offset along the cross axis, in pixels (e.g. to align a submenu's first item with its trigger). */\n skidding?: number;\n fullWidth?: boolean;\n /** Floor the floating element's width at the trigger's width (`'trigger'`). */\n minWidth?: 'trigger';\n}\n\ntype TriggerHandlers = {\n onPointerEnter?: (e: PointerEvent) => void;\n onPointerLeave?: (e: PointerEvent) => void;\n onFocusIn?: (e: FocusEvent) => void;\n onFocusOut?: (e: FocusEvent) => void;\n onClick?: (e: MouseEvent) => void;\n onKeyDown?: (e: KeyboardEvent) => void;\n};\n\nexport class PopoverController implements ReactiveController {\n private _host: ReactiveControllerHost & HTMLElement;\n private _config: PopoverControllerConfig;\n private _cleanupAutoUpdate?: () => void;\n private _cleanupSafePolygon?: () => void;\n private _handlers?: TriggerHandlers;\n private _triggerElement?: HTMLElement | null;\n private _currentPlacement = '';\n\n constructor(host: ReactiveControllerHost & HTMLElement, config: PopoverControllerConfig) {\n this._host = host;\n this._config = config;\n host.addController(this);\n }\n\n hostConnected() {}\n\n hostDisconnected() {\n this.stopPositioning();\n this.cleanupSafePolygon();\n // The floating element is leaving the tree, so the state we wrote on the\n // trigger describes nothing any more — drop the attribute rather than\n // leave a resting value claiming a relationship that no longer exists.\n this.releaseTrigger(null);\n this.removeTriggerListeners();\n }\n\n // --- Trigger ARIA state ---\n\n private _markedTrigger: HTMLElement | null = null;\n private _markedAttribute: string | null = null;\n\n /**\n * Write an ARIA attribute on the current trigger, remembering the element\n * written to and settling the previously marked one at `resting`.\n *\n * Remembering matters: re-resolving the trigger from `for` at teardown time\n * is wrong the moment `for` moved in between — the attribute gets stripped\n * from the new anchor, which never had it, and stays on the old one for good.\n */\n markTrigger(attribute: string, value: string, resting: string | null) {\n const next = this._config.getTriggerElement();\n if (this._markedTrigger === next && this._markedAttribute === attribute) return;\n this._settleMarked(resting);\n next?.setAttribute(attribute, value);\n this._markedTrigger = next;\n this._markedAttribute = attribute;\n }\n\n /**\n * Undo `markTrigger` on the element that actually received it. Pass a resting\n * value when the trigger keeps its relationship in a closed state\n * (`aria-expanded=\"false\"`), or `null` to remove the attribute outright.\n */\n releaseTrigger(value: string | null) {\n this._settleMarked(value);\n this._markedTrigger = null;\n this._markedAttribute = null;\n }\n\n private _settleMarked(value: string | null) {\n const el = this._markedTrigger;\n const attribute = this._markedAttribute;\n if (!el || !attribute) return;\n if (value === null) el.removeAttribute(attribute);\n else el.setAttribute(attribute, value);\n }\n\n get currentPlacement() {\n return this._currentPlacement;\n }\n\n // --- Positioning ---\n\n async updatePosition(options: PositionOptions) {\n const trigger = this._config.getTriggerElement();\n const floating = this._config.getFloatingElement();\n const arrowEl = this._config.getArrowElement();\n if (!trigger || !floating) return;\n\n const middleware = [\n offset({ mainAxis: options.distance, crossAxis: options.skidding ?? 0 }),\n // Size before flip/shift so the adopted floor feeds collision detection.\n ...(options.minWidth === 'trigger'\n ? [\n size({\n apply({ rects, elements }) {\n elements.floating.style.minWidth = `${rects.reference.width}px`;\n },\n }),\n ]\n : []),\n flip(),\n shift(),\n ...(arrowEl ? [arrow({ element: arrowEl, padding: 8 })] : []),\n ];\n\n const { x, y, placement, middlewareData } = await computePosition(trigger, floating, {\n placement: options.placement,\n strategy: 'fixed',\n middleware,\n });\n\n Object.assign(floating.style, {\n position: 'fixed',\n left: options.fullWidth ? '0px' : `${x}px`,\n top: `${y}px`,\n width: options.fullWidth ? '100vw' : '',\n });\n\n // The `size` middleware (above) sets minWidth when syncing; clear it otherwise.\n if (options.minWidth !== 'trigger') floating.style.minWidth = '';\n\n if (placement !== this._currentPlacement) {\n this._currentPlacement = placement;\n this._config.onPlacementChange?.(placement);\n }\n\n if (middlewareData.arrow && arrowEl) {\n const { x: ax, y: ay } = middlewareData.arrow;\n const side = STATIC_SIDE[placement.split('-')[0] as keyof typeof STATIC_SIDE];\n Object.assign(arrowEl.style, {\n left: ax != null ? `${ax}px` : '',\n top: ay != null ? `${ay}px` : '',\n [side]: `${-arrowEl.offsetWidth / 2}px`,\n });\n }\n }\n\n startPositioning(options: PositionOptions) {\n const trigger = this._config.getTriggerElement();\n const floating = this._config.getFloatingElement();\n if (!trigger || !floating) return;\n\n this._cleanupAutoUpdate?.();\n this._cleanupAutoUpdate = autoUpdate(trigger, floating, () => this.updatePosition(options));\n }\n\n /**\n * Re-anchor an already-open floating element onto the current trigger.\n *\n * `startPositioning`'s `autoUpdate` observers are bound to whichever element\n * was the trigger when it ran, so they never see a retarget — the loop keeps\n * watching the old anchor while `updatePosition` resolves the new one. Tear\n * it down before recomputing, or the stale cleanup leaks and two loops drive\n * the same floating element.\n *\n * `isCurrent` is re-checked after the await, which is a real gap:\n * `computePosition` is async, so the host may have closed or retargeted again\n * meanwhile. Re-arming `autoUpdate` past that point would strand a loop on a\n * hidden element — the host's close path has already run its own\n * `stopPositioning` and will never run another.\n */\n async reposition(options: PositionOptions, isCurrent: () => boolean): Promise<RepositionResult> {\n if (!this._config.getTriggerElement()) return 'no-anchor';\n this.stopPositioning();\n await this.updatePosition(options);\n if (!isCurrent()) return 'stale';\n this.startPositioning(options);\n return 'repositioned';\n }\n\n stopPositioning() {\n this._cleanupAutoUpdate?.();\n this._cleanupAutoUpdate = undefined;\n }\n\n // --- Safe polygon ---\n\n handlePointerLeave(e: PointerEvent, onHide: (reason: 'exit' | 'settled') => void) {\n const floating = this._config.getFloatingElement();\n const trigger = this._config.getTriggerElement();\n if (!floating || !trigger) {\n onHide('exit');\n return;\n }\n\n const cursorX = e.clientX;\n const cursorY = e.clientY;\n\n // Armed only while the pointer sits in the corridor between the trigger and\n // the bubble: there we cannot tell \"paused mid-travel\" from \"gone\" without\n // waiting, so if no further `pointermove` re-evaluates the polygon the\n // pointer has settled and we hide. On the bubble or the trigger themselves\n // the answer is unambiguous — stay open — so the timer is cleared, never\n // armed (otherwise a pointer resting on the bubble to read it would hide).\n let fallback: ReturnType<typeof setTimeout> | undefined;\n\n const hide = (reason: 'exit' | 'settled') => {\n cleanup();\n onHide(reason);\n };\n\n // Stable \"stay open\" surface (bubble or trigger): cancel any pending rest-hide.\n const stayOpen = () => clearTimeout(fallback);\n\n // Transient corridor: keep open, but hide if the pointer comes to rest here.\n const armRestHide = () => {\n clearTimeout(fallback);\n fallback = setTimeout(() => hide('settled'), SAFE_POLYGON_REST_HIDE_MS);\n };\n\n const onMove = (moveEvent: PointerEvent) => {\n const { clientX: mx, clientY: my } = moveEvent;\n const cursor: Point = [mx, my];\n const rect = floating.getBoundingClientRect();\n const refRect = trigger.getBoundingClientRect();\n const side = this._currentPlacement.split('-')[0];\n\n if (isPointInRect(cursor, rect)) {\n stayOpen();\n return;\n }\n if (isPointInRect(cursor, refRect)) {\n stayOpen();\n return;\n }\n\n if (\n (side === 'top' && cursorY >= refRect.bottom - 1) ||\n (side === 'bottom' && cursorY <= refRect.top + 1) ||\n (side === 'left' && cursorX >= refRect.right - 1) ||\n (side === 'right' && cursorX <= refRect.left + 1)\n ) {\n hide('exit');\n return;\n }\n\n const polygon = getSafePolygon(cursorX, cursorY, rect, refRect, this._currentPlacement);\n if (isPointInPolygon(cursor, polygon)) {\n armRestHide();\n return;\n }\n\n hide('exit');\n };\n\n const cleanup = () => {\n clearTimeout(fallback);\n document.removeEventListener('pointermove', onMove);\n };\n\n document.addEventListener('pointermove', onMove);\n // Arm immediately: a leave with no subsequent move (flick-and-stop) lands in\n // the corridor and must still hide once the pointer has settled.\n armRestHide();\n\n this._cleanupSafePolygon?.();\n this._cleanupSafePolygon = cleanup;\n }\n\n cleanupSafePolygon() {\n this._cleanupSafePolygon?.();\n this._cleanupSafePolygon = undefined;\n }\n\n // --- Trigger listener management ---\n\n addTriggerListeners(handlers: TriggerHandlers) {\n const trigger = this._config.getTriggerElement();\n if (!trigger) return;\n\n this._handlers = handlers;\n this._triggerElement = trigger;\n\n if (handlers.onPointerEnter)\n trigger.addEventListener('pointerenter', handlers.onPointerEnter as EventListener);\n if (handlers.onPointerLeave)\n trigger.addEventListener('pointerleave', handlers.onPointerLeave as EventListener);\n if (handlers.onFocusIn)\n trigger.addEventListener('focusin', handlers.onFocusIn as EventListener);\n if (handlers.onFocusOut)\n trigger.addEventListener('focusout', handlers.onFocusOut as EventListener);\n if (handlers.onClick) trigger.addEventListener('click', handlers.onClick as EventListener);\n if (handlers.onKeyDown)\n trigger.addEventListener('keydown', handlers.onKeyDown as EventListener);\n }\n\n removeTriggerListeners(triggerOverride?: HTMLElement | null) {\n const trigger = triggerOverride ?? this._triggerElement;\n const handlers = this._handlers;\n if (!trigger || !handlers) return;\n\n if (handlers.onPointerEnter)\n trigger.removeEventListener('pointerenter', handlers.onPointerEnter as EventListener);\n if (handlers.onPointerLeave)\n trigger.removeEventListener('pointerleave', handlers.onPointerLeave as EventListener);\n if (handlers.onFocusIn)\n trigger.removeEventListener('focusin', handlers.onFocusIn as EventListener);\n if (handlers.onFocusOut)\n trigger.removeEventListener('focusout', handlers.onFocusOut as EventListener);\n if (handlers.onClick) trigger.removeEventListener('click', handlers.onClick as EventListener);\n if (handlers.onKeyDown)\n trigger.removeEventListener('keydown', handlers.onKeyDown as EventListener);\n\n if (!triggerOverride) {\n this._handlers = undefined;\n this._triggerElement = undefined;\n }\n }\n\n // --- Animation ---\n\n async animateShow(el: HTMLElement, duration: number, keyframes?: Keyframe[]) {\n const d = reducedMotion?.matches ? 0 : duration;\n el.getAnimations().forEach((a) => a.cancel());\n el.animate(\n keyframes ?? [\n { opacity: 0, scale: 0.96 },\n { opacity: 1, scale: 1 },\n ],\n { duration: d, fill: 'forwards' },\n );\n }\n\n async animateHide(el: HTMLElement, duration: number, keyframes?: Keyframe[]) {\n const d = reducedMotion?.matches ? 0 : duration;\n const anim = el.animate(\n keyframes ?? [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.96 },\n ],\n { duration: d, fill: 'forwards' },\n );\n await anim.finished;\n }\n}\n"],"mappings":"A,yFAyBA,IAAMM,EAA4B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AG,MAAO,GAAK,EAC1B,CAAE,QAAS,EAAG,MAAO,CAAE,CACzB,EACA,CAAE,SAAUH,EAAG,KAAM,UAAW,CAClC,CACF,CAEA,MAAM,YAAY,EAAiB,EAAkB,EAAwB,CAC3E,IAAMA,EAAIpC,GAAe,QAAU,EAAIqC,EAQvC,MAPa7B,EAAG,QACd+B,GAAa,CACX,CAAE,QAAS,EAAG,MAAO,CAAE,EACvB,CAAE,QAAS,EAAG,MAAO,GAAK,CAC5B,EACA,CAAE,SAAUH,EAAG,KAAM,UAAW,CAE5B,CAAA,CAAK,QACb,CACF,E"}
|
|
1
|
+
{"version":3,"file":"popover.js","names":["offset","flip","shift","computePosition","size","arrow","SAFE_POLYGON_REST_HIDE_MS","isPointInPolygon","px","py","inside","j","polygon","xi","yi","xj","yj","isPointInRect","rect","getSafePolygon","side","placement","isFloatingWider","refRect","isFloatingTaller","cursorLeaveFromRight","cursorX","cursorLeaveFromBottom","cursorY","c1","c2","STATIC_SIDE","reducedMotion","PopoverController","host","config","next","attribute","resting","value","el","trigger","floating","arrowEl","middleware","options","rects","x","y","middlewareData","ax","ay","autoUpdate","isCurrent","onHide","fallback","hide","cleanup","reason","stayOpen","armRestHide","onMove","mx","my","moveEvent","cursor","handlers","triggerOverride","raw","prop","parsed","d","duration","a","keyframes"],"sources":["../../../src/html/shared/controllers/popover.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport {\n computePosition,\n autoUpdate,\n offset,\n flip,\n shift,\n arrow,\n size,\n type Placement,\n} from '@floating-ui/dom';\n\n// --- Pure geometry helpers ---\n\ntype Point = [number, number];\n\n/**\n * How long the pointer may rest, in the corridor between the trigger and the\n * bubble, before the safe polygon gives up and hides. The polygon is only\n * re-evaluated on `pointermove`, so a pointer that leaves and immediately stops\n * emits no further event to close on — this fallback guarantees the tooltip\n * still hides. Kept short so a genuine pause while travelling toward the bubble\n * re-arms it without a visible flicker. It is *not* armed while the pointer sits\n * on the bubble or the trigger themselves — those are stable \"stay open\" states.\n */\nconst SAFE_POLYGON_REST_HIDE_MS = 200;\n\n/** Check if a point is inside a polygon using ray-casting. */\nfunction isPointInPolygon([px, py]: Point, polygon: Point[]) {\n let inside = false;\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const [xi, yi] = polygon[i];\n const [xj, yj] = polygon[j];\n if (yi >= py !== yj >= py && px <= ((xj - xi) * (py - yi)) / (yj - yi) + xi) {\n inside = !inside;\n }\n }\n return inside;\n}\n\n/** Check if a point is inside a rect. */\nfunction isPointInRect([px, py]: Point, rect: DOMRect) {\n return px >= rect.left && px <= rect.right && py >= rect.top && py <= rect.bottom;\n}\n\n/**\n * Build a safe polygon (triangle/quadrilateral) from cursor to floating element edges.\n * Adapted from floating-ui/safePolygon.\n * @see https://github.com/floating-ui/floating-ui/blob/master/packages/react/src/safePolygon.ts\n */\nfunction getSafePolygon(\n cursorX: number,\n cursorY: number,\n rect: DOMRect,\n refRect: DOMRect,\n placement: string,\n): Point[] {\n const side = placement.split('-')[0] as 'top' | 'bottom' | 'left' | 'right';\n const buffer = 2;\n\n const isFloatingWider = rect.width > refRect.width;\n const isFloatingTaller = rect.height > refRect.height;\n\n const cursorLeaveFromRight = cursorX > rect.right - rect.width / 2;\n const cursorLeaveFromBottom = cursorY > rect.bottom - rect.height / 2;\n\n switch (side) {\n case 'top': {\n const c1: Point = [\n isFloatingWider\n ? cursorX + buffer / 2\n : cursorLeaveFromRight\n ? cursorX + buffer * 4\n : cursorX - buffer * 4,\n cursorY + buffer + 1,\n ];\n const c2: Point = [\n isFloatingWider\n ? cursorX - buffer / 2\n : cursorLeaveFromRight\n ? cursorX + buffer * 4\n : cursorX - buffer * 4,\n cursorY + buffer + 1,\n ];\n return [\n c1,\n c2,\n [\n rect.left,\n cursorLeaveFromRight\n ? rect.bottom - buffer\n : isFloatingWider\n ? rect.bottom - buffer\n : rect.top,\n ],\n [\n rect.right,\n cursorLeaveFromRight\n ? isFloatingWider\n ? rect.bottom - buffer\n : rect.top\n : rect.bottom - buffer,\n ],\n ];\n }\n case 'bottom': {\n const c1: Point = [\n isFloatingWider\n ? cursorX + buffer / 2\n : cursorLeaveFromRight\n ? cursorX + buffer * 4\n : cursorX - buffer * 4,\n cursorY - buffer,\n ];\n const c2: Point = [\n isFloatingWider\n ? cursorX - buffer / 2\n : cursorLeaveFromRight\n ? cursorX + buffer * 4\n : cursorX - buffer * 4,\n cursorY - buffer,\n ];\n return [\n c1,\n c2,\n [\n rect.left,\n cursorLeaveFromRight\n ? rect.top + buffer\n : isFloatingWider\n ? rect.top + buffer\n : rect.bottom,\n ],\n [\n rect.right,\n cursorLeaveFromRight\n ? isFloatingWider\n ? rect.top + buffer\n : rect.bottom\n : rect.top + buffer,\n ],\n ];\n }\n case 'left': {\n const c1: Point = [\n cursorX + buffer + 1,\n isFloatingTaller\n ? cursorY + buffer / 2\n : cursorLeaveFromBottom\n ? cursorY + buffer * 4\n : cursorY - buffer * 4,\n ];\n const c2: Point = [\n cursorX + buffer + 1,\n isFloatingTaller\n ? cursorY - buffer / 2\n : cursorLeaveFromBottom\n ? cursorY + buffer * 4\n : cursorY - buffer * 4,\n ];\n return [\n [\n cursorLeaveFromBottom\n ? rect.right - buffer\n : isFloatingTaller\n ? rect.right - buffer\n : rect.left,\n rect.top,\n ],\n [\n cursorLeaveFromBottom\n ? isFloatingTaller\n ? rect.right - buffer\n : rect.left\n : rect.right - buffer,\n rect.bottom,\n ],\n c1,\n c2,\n ];\n }\n case 'right': {\n const c1: Point = [\n cursorX - buffer,\n isFloatingTaller\n ? cursorY + buffer / 2\n : cursorLeaveFromBottom\n ? cursorY + buffer * 4\n : cursorY - buffer * 4,\n ];\n const c2: Point = [\n cursorX - buffer,\n isFloatingTaller\n ? cursorY - buffer / 2\n : cursorLeaveFromBottom\n ? cursorY + buffer * 4\n : cursorY - buffer * 4,\n ];\n return [\n [\n cursorLeaveFromBottom\n ? rect.left + buffer\n : isFloatingTaller\n ? rect.left + buffer\n : rect.right,\n rect.top,\n ],\n [\n cursorLeaveFromBottom\n ? isFloatingTaller\n ? rect.left + buffer\n : rect.right\n : rect.left + buffer,\n rect.bottom,\n ],\n c1,\n c2,\n ];\n }\n default:\n return [];\n }\n}\n\n// --- Constants ---\n\nconst STATIC_SIDE = { top: 'bottom', right: 'left', bottom: 'top', left: 'right' } as const;\n\nconst reducedMotion =\n typeof window !== 'undefined' ? window.matchMedia('(prefers-reduced-motion: reduce)') : undefined;\n\n// --- Controller ---\n\nexport interface PopoverControllerConfig {\n getTriggerElement: () => HTMLElement | null;\n getFloatingElement: () => HTMLElement | null;\n getArrowElement: () => HTMLElement | null;\n onPlacementChange?: (placement: string) => void;\n}\n\n/**\n * Outcome of {@link PopoverController.reposition}. `stale` means the host\n * closed or retargeted again while `computePosition` was in flight — the caller\n * must not act on it, because whatever superseded it owns the element now.\n */\nexport type RepositionResult = 'repositioned' | 'no-anchor' | 'stale';\n\nexport interface PositionOptions {\n placement: Placement;\n distance: number;\n /** Offset along the cross axis, in pixels (e.g. to align a submenu's first item with its trigger). */\n skidding?: number;\n fullWidth?: boolean;\n /** Floor the floating element's width at the trigger's width (`'trigger'`). */\n minWidth?: 'trigger';\n}\n\ntype TriggerHandlers = {\n onPointerEnter?: (e: PointerEvent) => void;\n onPointerLeave?: (e: PointerEvent) => void;\n onFocusIn?: (e: FocusEvent) => void;\n onFocusOut?: (e: FocusEvent) => void;\n onClick?: (e: MouseEvent) => void;\n onKeyDown?: (e: KeyboardEvent) => void;\n};\n\nexport class PopoverController implements ReactiveController {\n private _host: ReactiveControllerHost & HTMLElement;\n private _config: PopoverControllerConfig;\n private _cleanupAutoUpdate?: () => void;\n private _cleanupSafePolygon?: () => void;\n private _handlers?: TriggerHandlers;\n private _triggerElement?: HTMLElement | null;\n private _currentPlacement = '';\n\n constructor(host: ReactiveControllerHost & HTMLElement, config: PopoverControllerConfig) {\n this._host = host;\n this._config = config;\n host.addController(this);\n }\n\n hostConnected() {}\n\n hostDisconnected() {\n this.stopPositioning();\n this.cleanupSafePolygon();\n // The floating element is leaving the tree, so the state we wrote on the\n // trigger describes nothing any more — drop the attribute rather than\n // leave a resting value claiming a relationship that no longer exists.\n this.releaseTrigger(null);\n this.removeTriggerListeners();\n }\n\n // --- Trigger ARIA state ---\n\n private _markedTrigger: HTMLElement | null = null;\n private _markedAttribute: string | null = null;\n\n /**\n * Write an ARIA attribute on the current trigger, remembering the element\n * written to and settling the previously marked one at `resting`.\n *\n * Remembering matters: re-resolving the trigger from `for` at teardown time\n * is wrong the moment `for` moved in between — the attribute gets stripped\n * from the new anchor, which never had it, and stays on the old one for good.\n */\n markTrigger(attribute: string, value: string, resting: string | null) {\n const next = this._config.getTriggerElement();\n if (this._markedTrigger === next && this._markedAttribute === attribute) return;\n this._settleMarked(resting);\n next?.setAttribute(attribute, value);\n this._markedTrigger = next;\n this._markedAttribute = attribute;\n }\n\n /**\n * Undo `markTrigger` on the element that actually received it. Pass a resting\n * value when the trigger keeps its relationship in a closed state\n * (`aria-expanded=\"false\"`), or `null` to remove the attribute outright.\n */\n releaseTrigger(value: string | null) {\n this._settleMarked(value);\n this._markedTrigger = null;\n this._markedAttribute = null;\n }\n\n private _settleMarked(value: string | null) {\n const el = this._markedTrigger;\n const attribute = this._markedAttribute;\n if (!el || !attribute) return;\n if (value === null) el.removeAttribute(attribute);\n else el.setAttribute(attribute, value);\n }\n\n get currentPlacement() {\n return this._currentPlacement;\n }\n\n // --- Positioning ---\n\n async updatePosition(options: PositionOptions) {\n const trigger = this._config.getTriggerElement();\n const floating = this._config.getFloatingElement();\n const arrowEl = this._config.getArrowElement();\n if (!trigger || !floating) return;\n\n const middleware = [\n offset({ mainAxis: options.distance, crossAxis: options.skidding ?? 0 }),\n // Size before flip/shift so the adopted floor feeds collision detection.\n ...(options.minWidth === 'trigger'\n ? [\n size({\n apply({ rects, elements }) {\n elements.floating.style.minWidth = `${rects.reference.width}px`;\n },\n }),\n ]\n : []),\n flip(),\n shift(),\n ...(arrowEl ? [arrow({ element: arrowEl, padding: 8 })] : []),\n ];\n\n const { x, y, placement, middlewareData } = await computePosition(trigger, floating, {\n placement: options.placement,\n strategy: 'fixed',\n middleware,\n });\n\n Object.assign(floating.style, {\n position: 'fixed',\n left: options.fullWidth ? '0px' : `${x}px`,\n top: `${y}px`,\n width: options.fullWidth ? '100vw' : '',\n });\n\n // The `size` middleware (above) sets minWidth when syncing; clear it otherwise.\n if (options.minWidth !== 'trigger') floating.style.minWidth = '';\n\n if (placement !== this._currentPlacement) {\n this._currentPlacement = placement;\n this._config.onPlacementChange?.(placement);\n }\n\n if (middlewareData.arrow && arrowEl) {\n const { x: ax, y: ay } = middlewareData.arrow;\n const side = STATIC_SIDE[placement.split('-')[0] as keyof typeof STATIC_SIDE];\n Object.assign(arrowEl.style, {\n left: ax != null ? `${ax}px` : '',\n top: ay != null ? `${ay}px` : '',\n [side]: `${-arrowEl.offsetWidth / 2}px`,\n });\n }\n }\n\n startPositioning(options: PositionOptions) {\n const trigger = this._config.getTriggerElement();\n const floating = this._config.getFloatingElement();\n if (!trigger || !floating) return;\n\n this._cleanupAutoUpdate?.();\n this._cleanupAutoUpdate = autoUpdate(trigger, floating, () => this.updatePosition(options));\n }\n\n /**\n * Re-anchor an already-open floating element onto the current trigger.\n *\n * `startPositioning`'s `autoUpdate` observers are bound to whichever element\n * was the trigger when it ran, so they never see a retarget — the loop keeps\n * watching the old anchor while `updatePosition` resolves the new one. Tear\n * it down before recomputing, or the stale cleanup leaks and two loops drive\n * the same floating element.\n *\n * `isCurrent` is re-checked after the await, which is a real gap:\n * `computePosition` is async, so the host may have closed or retargeted again\n * meanwhile. Re-arming `autoUpdate` past that point would strand a loop on a\n * hidden element — the host's close path has already run its own\n * `stopPositioning` and will never run another.\n */\n async reposition(options: PositionOptions, isCurrent: () => boolean): Promise<RepositionResult> {\n if (!this._config.getTriggerElement()) return 'no-anchor';\n this.stopPositioning();\n await this.updatePosition(options);\n if (!isCurrent()) return 'stale';\n this.startPositioning(options);\n return 'repositioned';\n }\n\n stopPositioning() {\n this._cleanupAutoUpdate?.();\n this._cleanupAutoUpdate = undefined;\n }\n\n // --- Safe polygon ---\n\n handlePointerLeave(e: PointerEvent, onHide: (reason: 'exit' | 'settled') => void) {\n const floating = this._config.getFloatingElement();\n const trigger = this._config.getTriggerElement();\n if (!floating || !trigger) {\n onHide('exit');\n return;\n }\n\n const cursorX = e.clientX;\n const cursorY = e.clientY;\n\n // Armed only while the pointer sits in the corridor between the trigger and\n // the bubble: there we cannot tell \"paused mid-travel\" from \"gone\" without\n // waiting, so if no further `pointermove` re-evaluates the polygon the\n // pointer has settled and we hide. On the bubble or the trigger themselves\n // the answer is unambiguous — stay open — so the timer is cleared, never\n // armed (otherwise a pointer resting on the bubble to read it would hide).\n let fallback: ReturnType<typeof setTimeout> | undefined;\n\n const hide = (reason: 'exit' | 'settled') => {\n cleanup();\n onHide(reason);\n };\n\n // Stable \"stay open\" surface (bubble or trigger): cancel any pending rest-hide.\n const stayOpen = () => clearTimeout(fallback);\n\n // Transient corridor: keep open, but hide if the pointer comes to rest here.\n const armRestHide = () => {\n clearTimeout(fallback);\n fallback = setTimeout(() => hide('settled'), SAFE_POLYGON_REST_HIDE_MS);\n };\n\n const onMove = (moveEvent: PointerEvent) => {\n const { clientX: mx, clientY: my } = moveEvent;\n const cursor: Point = [mx, my];\n const rect = floating.getBoundingClientRect();\n const refRect = trigger.getBoundingClientRect();\n const side = this._currentPlacement.split('-')[0];\n\n if (isPointInRect(cursor, rect)) {\n stayOpen();\n return;\n }\n if (isPointInRect(cursor, refRect)) {\n stayOpen();\n return;\n }\n\n if (\n (side === 'top' && cursorY >= refRect.bottom - 1) ||\n (side === 'bottom' && cursorY <= refRect.top + 1) ||\n (side === 'left' && cursorX >= refRect.right - 1) ||\n (side === 'right' && cursorX <= refRect.left + 1)\n ) {\n hide('exit');\n return;\n }\n\n const polygon = getSafePolygon(cursorX, cursorY, rect, refRect, this._currentPlacement);\n if (isPointInPolygon(cursor, polygon)) {\n armRestHide();\n return;\n }\n\n hide('exit');\n };\n\n const cleanup = () => {\n clearTimeout(fallback);\n document.removeEventListener('pointermove', onMove);\n };\n\n document.addEventListener('pointermove', onMove);\n // Arm immediately: a leave with no subsequent move (flick-and-stop) lands in\n // the corridor and must still hide once the pointer has settled.\n armRestHide();\n\n this._cleanupSafePolygon?.();\n this._cleanupSafePolygon = cleanup;\n }\n\n cleanupSafePolygon() {\n this._cleanupSafePolygon?.();\n this._cleanupSafePolygon = undefined;\n }\n\n // --- Trigger listener management ---\n\n addTriggerListeners(handlers: TriggerHandlers) {\n const trigger = this._config.getTriggerElement();\n if (!trigger) return;\n\n this._handlers = handlers;\n this._triggerElement = trigger;\n\n if (handlers.onPointerEnter)\n trigger.addEventListener('pointerenter', handlers.onPointerEnter as EventListener);\n if (handlers.onPointerLeave)\n trigger.addEventListener('pointerleave', handlers.onPointerLeave as EventListener);\n if (handlers.onFocusIn)\n trigger.addEventListener('focusin', handlers.onFocusIn as EventListener);\n if (handlers.onFocusOut)\n trigger.addEventListener('focusout', handlers.onFocusOut as EventListener);\n if (handlers.onClick) trigger.addEventListener('click', handlers.onClick as EventListener);\n if (handlers.onKeyDown)\n trigger.addEventListener('keydown', handlers.onKeyDown as EventListener);\n }\n\n removeTriggerListeners(triggerOverride?: HTMLElement | null) {\n const trigger = triggerOverride ?? this._triggerElement;\n const handlers = this._handlers;\n if (!trigger || !handlers) return;\n\n if (handlers.onPointerEnter)\n trigger.removeEventListener('pointerenter', handlers.onPointerEnter as EventListener);\n if (handlers.onPointerLeave)\n trigger.removeEventListener('pointerleave', handlers.onPointerLeave as EventListener);\n if (handlers.onFocusIn)\n trigger.removeEventListener('focusin', handlers.onFocusIn as EventListener);\n if (handlers.onFocusOut)\n trigger.removeEventListener('focusout', handlers.onFocusOut as EventListener);\n if (handlers.onClick) trigger.removeEventListener('click', handlers.onClick as EventListener);\n if (handlers.onKeyDown)\n trigger.removeEventListener('keydown', handlers.onKeyDown as EventListener);\n\n if (!triggerOverride) {\n this._handlers = undefined;\n this._triggerElement = undefined;\n }\n }\n\n // --- Animation ---\n\n /**\n * The host's `--show-duration` / `--hide-duration`, in ms. Accepts a CSS time\n * or a bare number of ms (`150`, `150ms` and `0.15s` all read as 150); falls\n * back to 150 when unset or unparsable.\n */\n durationOf(prop: '--show-duration' | '--hide-duration'): number {\n const raw = getComputedStyle(this._host).getPropertyValue(prop).trim().toLowerCase();\n const parsed = parseFloat(raw);\n if (Number.isNaN(parsed)) return 150;\n return raw.endsWith('s') && !raw.endsWith('ms') ? parsed * 1000 : parsed;\n }\n\n /** Fade/scale `el` in over `duration` ms — the host's `--show-duration` by default. */\n async animateShow(\n el: HTMLElement,\n duration = this.durationOf('--show-duration'),\n keyframes?: Keyframe[],\n ) {\n const d = reducedMotion?.matches ? 0 : duration;\n el.getAnimations().forEach((a) => a.cancel());\n el.animate(\n keyframes ?? [\n { opacity: 0, scale: 0.96 },\n { opacity: 1, scale: 1 },\n ],\n { duration: d, fill: 'forwards' },\n );\n }\n\n /** Fade/scale `el` out over `duration` ms — the host's `--hide-duration` by default. */\n async animateHide(\n el: HTMLElement,\n duration = this.durationOf('--hide-duration'),\n keyframes?: Keyframe[],\n ) {\n const d = reducedMotion?.matches ? 0 : duration;\n const anim = el.animate(\n keyframes ?? [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.96 },\n ],\n { duration: d, fill: 'forwards' },\n );\n await anim.finished;\n }\n}\n"],"mappings":"A,yFAyBA,IAAMM,EAA4B,IAGlC,SAASC,EAAiB,CAACC,EAAIC,GAAY,EAAkB,CAC3D,IAAIC,EAAS,GACb,IAAK,IAAI,EAAI,EAAGC,EAAIC,EAAQ,OAAS,EAAG,EAAIA,EAAQ,OAAQ,EAAI,IAAK,CACnE,GAAM,CAACC,EAAIC,GAAMF,EAAQ,GACnB,CAACG,EAAIC,GAAMJ,EAAQD,GACrBG,GAAML,GAAOO,GAAMP,GAAMD,IAAQO,EAAKF,IAAOJ,EAAKK,IAAQE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AC1B,CAAE,QAAS,EAAG,MAAO,CAAE,CACzB,EACA,CAAE,SAAUH,EAAG,KAAM,UAAW,CAClC,CACF,CAGA,MAAM,YACJ,EACA,EAAW,KAAK,WAAW,iBAAiB,EAC5C,EACA,CACA,IAAMA,EAAIvC,GAAe,QAAU,EAAIwC,EAQvC,MAPahC,EAAG,QACdkC,GAAa,CACX,CAAE,QAAS,EAAG,MAAO,CAAE,EACvB,CAAE,QAAS,EAAG,MAAO,GAAK,CAC5B,EACA,CAAE,SAAUH,EAAG,KAAM,UAAW,CAE5B,CAAA,CAAK,QACb,CACF,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"../../chunks/lit.js";var t=e(`@layer components{.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch]){--size:var(--l-form-control-toggle-size);--accent:var(--l-form-control-activated-color);--checkmark:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"none\\" stroke=\\"white\\" stroke-width=\\"2.5\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\"><polyline points=\\"20 6 9 17 4 12\\"/></svg>");--_dash:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"none\\" stroke=\\"white\\" stroke-width=\\"2.5\\" stroke-linecap=\\"round\\"><line x1=\\"5\\" y1=\\"12\\" x2=\\"19\\" y2=\\"12\\"/></svg>");box-sizing:border-box;inline-size:var(--size);block-size:var(--size);appearance:none;border:var(--l-form-control-border-width) solid var(--l-form-control-border-color);border-radius:calc(var(--size) * .2);background-color:var(--l-form-control-background-color);vertical-align:middle;cursor:pointer;background-position:50%;background-repeat:no-repeat;background-size:75%;flex:none;margin:0;padding:0;transition-property:background-color,border-color;transition-duration:.15s}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):checked,:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):indeterminate{border-color:var(--accent);background-color:var(--accent)}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):checked{background-image:var(--checkmark)}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):indeterminate{background-image:var(--_dash)}@media (hover:hover){:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):hover:not(:disabled){border-color:var(--l-form-control-border-color-hover)}}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):focus-visible{outline:2px solid var(--l-focus-ring);outline-offset:2px}@media (forced-colors:active){:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):checked,:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):indeterminate{background-color:highlight;border-color:highlight}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled{border-color:graytext}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled:is(:checked,:indeterminate){background-color:graytext}}:is(:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):user-invalid,:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch]))[aria-invalid=true]){--accent:var(--l-form-control-border-color-invalid);border-color:var(--l-form-control-border-color-invalid)}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled{cursor:not-allowed}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled:not(:checked,:indeterminate){border-color:var(--l-form-control-disabled
|
|
1
|
+
import{i as e}from"../../chunks/lit.js";var t=e(`@layer components{.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch]){--size:var(--l-form-control-toggle-size);--accent:var(--l-form-control-activated-color);--checkmark:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"none\\" stroke=\\"white\\" stroke-width=\\"2.5\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\"><polyline points=\\"20 6 9 17 4 12\\"/></svg>");--_dash:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"none\\" stroke=\\"white\\" stroke-width=\\"2.5\\" stroke-linecap=\\"round\\"><line x1=\\"5\\" y1=\\"12\\" x2=\\"19\\" y2=\\"12\\"/></svg>");box-sizing:border-box;inline-size:var(--size);block-size:var(--size);appearance:none;border:var(--l-form-control-border-width) solid var(--l-form-control-border-color);border-radius:calc(var(--size) * .2);background-color:var(--l-form-control-background-color);vertical-align:middle;cursor:pointer;background-position:50%;background-repeat:no-repeat;background-size:75%;flex:none;margin:0;padding:0;transition-property:background-color,border-color;transition-duration:.15s}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):checked,:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):indeterminate{border-color:var(--accent);background-color:var(--accent)}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):checked{background-image:var(--checkmark)}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):indeterminate{background-image:var(--_dash)}@media (hover:hover){:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):hover:not(:disabled){border-color:var(--l-form-control-border-color-hover)}}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):focus-visible{outline:2px solid var(--l-focus-ring);outline-offset:2px}@media (forced-colors:active){:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):checked,:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):indeterminate{background-color:highlight;border-color:highlight}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled{border-color:graytext}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled:is(:checked,:indeterminate){background-color:graytext}}:is(:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):user-invalid,:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch]))[aria-invalid=true]){--accent:var(--l-form-control-border-color-invalid);border-color:var(--l-form-control-border-color-invalid)}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled{cursor:not-allowed}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled:not(:checked,:indeterminate){border-color:var(--l-form-control-border-color-disabled);background-color:var(--l-form-control-background-color-disabled)}:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled:is(:checked,:indeterminate){opacity:.4}@media (forced-colors:active){:is(.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch])):disabled:is(:checked,:indeterminate){opacity:1}}@media (prefers-reduced-motion:reduce){.l-checkbox,:where(l-form-field:not([unstyled]))>input[type=checkbox]:not([role=switch]){transition-duration:0s}}}`);export{t as default};
|
|
2
2
|
//# sourceMappingURL=checkbox-appearance.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-appearance.styles.js","names":["unsafeCSS","raw","r","checkbox_appearance_styles_default"],"sources":["../../../src/html/shared/styles/checkbox-appearance.css?inline","../../../src/html/shared/styles/checkbox-appearance.styles.ts"],"sourcesContent":["/* Shared checkbox appearance — the visual skin behind `.l-checkbox`.\n\n Colocated with its `checkbox-appearance.styles.ts` wrapper so Shadow-DOM\n elements that render their own native checkbox (e.g. `<l-tree-item>` in\n `selection=\"multiple\"`) can pull in the exact same look via `static styles`.\n The global light-DOM `checkbox.css` primitive `@import`s this file too, so\n both surfaces stay in sync. The global `.l-checkbox` class cannot pierce a\n shadow boundary, but the `--l-form-control-*` tokens this rule relies on DO\n inherit across shadow roots.\n\n Shadow consumers must emit the class via `cls('checkbox')`, never a static\n `class=\"l-checkbox\"` literal. This file ships to dist as a real CSS file and\n is imported `?inline`, so the CONSUMER's Vite runs postcss-plugin-prefix over\n it and rewrites this selector to `.<cssPrefix>-checkbox`. The vite-plugin's\n `transform` hook only rewrites `_cssPrefix` in registry.js — it never touches\n template literals in element JS — so a hardcoded class attribute would stop\n matching the rewritten selector and the checkbox would render unstyled.\n\n The checkmark / indeterminate dash are drawn with a `background-image` SVG on\n the input itself — `::before`/`::after` do not paint on replaced elements\n like `<input>`. `background-image` can't read the host's `currentColor`, so\n the glyph color is baked white. This stays legible because the accent\n (`--l-form-control-activated-color`) is a stable color that does not invert\n between light and dark. Override `--checkmark` to swap the icon. */\n\n@layer components {\n .l-checkbox,\n :where(l-form-field:not([unstyled])) > input[type='checkbox']:not([role='switch']) {\n /* Public knobs */\n --size: var(--l-form-control-toggle-size);\n --accent: var(--l-form-control-activated-color);\n --checkmark: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"white\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20 6 9 17 4 12\"/></svg>');\n --_dash: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"white\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>');\n\n box-sizing: border-box;\n flex: 0 0 auto;\n inline-size: var(--size);\n block-size: var(--size);\n margin: 0;\n padding: 0;\n appearance: none;\n border: var(--l-form-control-border-width) solid var(--l-form-control-border-color);\n border-radius: calc(var(--size) * 0.2);\n background-color: var(--l-form-control-background-color);\n background-repeat: no-repeat;\n background-position: center;\n background-size: 75%;\n vertical-align: middle;\n cursor: pointer;\n transition-property: background-color, border-color;\n transition-duration: 150ms;\n\n &:checked,\n &:indeterminate {\n border-color: var(--accent);\n background-color: var(--accent);\n }\n\n &:checked {\n background-image: var(--checkmark);\n }\n\n &:indeterminate {\n background-image: var(--_dash);\n }\n\n @media (hover: hover) {\n &:hover:not(:disabled) {\n border-color: var(--l-form-control-border-color-hover);\n }\n }\n\n &:focus-visible {\n outline: 2px solid var(--l-focus-ring);\n outline-offset: 2px;\n }\n\n /* High contrast: the checked fill is forced to Canvas, hiding the accent and\n leaving the baked-white glyph invisible — pin the checked box to a system\n color so the checkmark/dash stays legible. */\n @media (forced-colors: active) {\n &:checked,\n &:indeterminate {\n border-color: Highlight;\n background-color: Highlight;\n }\n\n &:disabled {\n border-color: GrayText;\n }\n\n &:disabled:is(:checked, :indeterminate) {\n background-color: GrayText;\n }\n }\n\n /* Invalid: only after interaction (`:user-invalid`), or forced via\n `aria-invalid` (set by `l-form-field` / server-side validation).\n Overriding `--accent` makes a checked invalid box fill with the error\n color too (not just the border). */\n &:user-invalid,\n &[aria-invalid='true'] {\n --accent: var(--l-form-control-border-color-invalid);\n border-color: var(--l-form-control-border-color-invalid);\n }\n\n &:disabled {\n cursor: not-allowed;\n }\n\n /* Unchecked: the same three tokens as `input`/`select`/`textarea`, so a\n checkbox and an input in the same disabled form grey out identically.\n There is no mark here — only a box — so nothing can be washed out. */\n &:disabled:not(:checked, :indeterminate) {\n border-color: var(--l-form-control-disabled
|
|
1
|
+
{"version":3,"file":"checkbox-appearance.styles.js","names":["unsafeCSS","raw","r","checkbox_appearance_styles_default"],"sources":["../../../src/html/shared/styles/checkbox-appearance.css?inline","../../../src/html/shared/styles/checkbox-appearance.styles.ts"],"sourcesContent":["/* Shared checkbox appearance — the visual skin behind `.l-checkbox`.\n\n Colocated with its `checkbox-appearance.styles.ts` wrapper so Shadow-DOM\n elements that render their own native checkbox (e.g. `<l-tree-item>` in\n `selection=\"multiple\"`) can pull in the exact same look via `static styles`.\n The global light-DOM `checkbox.css` primitive `@import`s this file too, so\n both surfaces stay in sync. The global `.l-checkbox` class cannot pierce a\n shadow boundary, but the `--l-form-control-*` tokens this rule relies on DO\n inherit across shadow roots.\n\n Shadow consumers must emit the class via `cls('checkbox')`, never a static\n `class=\"l-checkbox\"` literal. This file ships to dist as a real CSS file and\n is imported `?inline`, so the CONSUMER's Vite runs postcss-plugin-prefix over\n it and rewrites this selector to `.<cssPrefix>-checkbox`. The vite-plugin's\n `transform` hook only rewrites `_cssPrefix` in registry.js — it never touches\n template literals in element JS — so a hardcoded class attribute would stop\n matching the rewritten selector and the checkbox would render unstyled.\n\n The checkmark / indeterminate dash are drawn with a `background-image` SVG on\n the input itself — `::before`/`::after` do not paint on replaced elements\n like `<input>`. `background-image` can't read the host's `currentColor`, so\n the glyph color is baked white. This stays legible because the accent\n (`--l-form-control-activated-color`) is a stable color that does not invert\n between light and dark. Override `--checkmark` to swap the icon. */\n\n@layer components {\n .l-checkbox,\n :where(l-form-field:not([unstyled])) > input[type='checkbox']:not([role='switch']) {\n /* Public knobs */\n --size: var(--l-form-control-toggle-size);\n --accent: var(--l-form-control-activated-color);\n --checkmark: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"white\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20 6 9 17 4 12\"/></svg>');\n --_dash: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"white\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>');\n\n box-sizing: border-box;\n flex: 0 0 auto;\n inline-size: var(--size);\n block-size: var(--size);\n margin: 0;\n padding: 0;\n appearance: none;\n border: var(--l-form-control-border-width) solid var(--l-form-control-border-color);\n border-radius: calc(var(--size) * 0.2);\n background-color: var(--l-form-control-background-color);\n background-repeat: no-repeat;\n background-position: center;\n background-size: 75%;\n vertical-align: middle;\n cursor: pointer;\n transition-property: background-color, border-color;\n transition-duration: 150ms;\n\n &:checked,\n &:indeterminate {\n border-color: var(--accent);\n background-color: var(--accent);\n }\n\n &:checked {\n background-image: var(--checkmark);\n }\n\n &:indeterminate {\n background-image: var(--_dash);\n }\n\n @media (hover: hover) {\n &:hover:not(:disabled) {\n border-color: var(--l-form-control-border-color-hover);\n }\n }\n\n &:focus-visible {\n outline: 2px solid var(--l-focus-ring);\n outline-offset: 2px;\n }\n\n /* High contrast: the checked fill is forced to Canvas, hiding the accent and\n leaving the baked-white glyph invisible — pin the checked box to a system\n color so the checkmark/dash stays legible. */\n @media (forced-colors: active) {\n &:checked,\n &:indeterminate {\n border-color: Highlight;\n background-color: Highlight;\n }\n\n &:disabled {\n border-color: GrayText;\n }\n\n &:disabled:is(:checked, :indeterminate) {\n background-color: GrayText;\n }\n }\n\n /* Invalid: only after interaction (`:user-invalid`), or forced via\n `aria-invalid` (set by `l-form-field` / server-side validation).\n Overriding `--accent` makes a checked invalid box fill with the error\n color too (not just the border). */\n &:user-invalid,\n &[aria-invalid='true'] {\n --accent: var(--l-form-control-border-color-invalid);\n border-color: var(--l-form-control-border-color-invalid);\n }\n\n &:disabled {\n cursor: not-allowed;\n }\n\n /* Unchecked: the same three tokens as `input`/`select`/`textarea`, so a\n checkbox and an input in the same disabled form grey out identically.\n There is no mark here — only a box — so nothing can be washed out. */\n &:disabled:not(:checked, :indeterminate) {\n border-color: var(--l-form-control-border-color-disabled);\n background-color: var(--l-form-control-background-color-disabled);\n }\n\n /* Checked: faded rather than greyed. A solid neutral fill keeps the glyph\n crisp but reads as a styled, still-live control; the fade reads as\n \"inactive\" at a glance, which is the message that matters more here.\n The cost is measured and accepted: the checkmark drops to 1.85:1 against\n its own box, and the residual accent tint (1.81:1 against the page) is\n what carries \"this one is checked\". WCAG 1.4.11 exempts inactive\n components, so this is a deliberate trade, not a shortfall.\n\n It assumes the accent is dark enough for the baked-white glyph — the same\n assumption `--l-form-control-activated-color` already documents, and which\n the enabled state depends on just as much (a pale accent scores 1.31:1\n there, before anything is disabled). */\n &:disabled:is(:checked, :indeterminate) {\n opacity: 0.4;\n }\n\n /* Forced colors replaces author colors with the user's palette, so a fade\n would only dim a system color — the box is already GrayText up in the\n forced-colors block above. Placed here, after the fade, because it needs\n to win at equal specificity. */\n @media (forced-colors: active) {\n &:disabled:is(:checked, :indeterminate) {\n opacity: 1;\n }\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .l-checkbox,\n :where(l-form-field:not([unstyled])) > input[type='checkbox']:not([role='switch']) {\n transition-duration: 0ms;\n }\n }\n}\n","import { unsafeCSS } from 'lit';\nimport raw from './checkbox-appearance.css?inline';\n\n/**\n * Shared `.l-checkbox` appearance for Shadow-DOM elements that render their own\n * native checkbox (e.g. `<l-tree-item>` in `selection=\"multiple\"`).\n * Wrapper module: `unsafeCSS()` is called once here so all importers share the\n * same `CSSResult` instance (one constructed `CSSStyleSheet`).\n */\nexport default unsafeCSS(raw);\n"],"mappings":"A,wCCSA,IAAAG,EAAeH,EAAUC,iwHAAG,E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper module for the menu panel shared by l-dropdown and l-dropdown-item
|
|
3
|
+
* submenus. `unsafeCSS()` is called once here so both share one `CSSResult`
|
|
4
|
+
* (one constructed `CSSStyleSheet`, not one per importer).
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: import("lit").CSSResult;
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=menu-panel.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-panel.styles.d.ts","sourceRoot":"","sources":["../../../src/html/shared/styles/menu-panel.styles.ts"],"names":[],"mappings":"AAGA;;;;GAIG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"../../chunks/lit.js";var t=e(`[popover]{inset:unset;width:max-content;padding:var(--padding,var(--l-popover-padding));border:1px solid var(--l-color-border-overlay);border-radius:var(--border-radius,var(--l-popover-border-radius));background:var(--background,var(--l-color-surface-overlay));color:var(--l-color-text-primary);box-shadow:var(--shadow,var(--l-popover-shadow));font-size:var(--l-popover-font-size);line-height:var(--l-popover-line-height);margin:0;overflow:visible}[popover] ::slotted(hr){height:1px;margin-block:var(--padding,var(--l-popover-padding));margin-inline:calc(var(--padding,var(--l-popover-padding)) * -1);background:var(--l-color-divider);border:0;display:block}`);export{t as default};
|
|
2
|
+
//# sourceMappingURL=menu-panel.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-panel.styles.js","names":["unsafeCSS","raw","r","menu_panel_styles_default"],"sources":["../../../src/html/shared/styles/menu-panel.css?inline","../../../src/html/shared/styles/menu-panel.styles.ts"],"sourcesContent":["/*\n * The menu panel shared by l-dropdown and the submenus of l-dropdown-item — the\n * `[popover]` element of each shadow root, and the `<hr>` separators slotted\n * into it.\n *\n * The public knobs (--padding, --border-radius, --background, --shadow) are set\n * on l-dropdown's :host and inherit through the light DOM into nested\n * l-dropdown-item submenus, so a themed dropdown themes its submenus too. The\n * fallbacks only serve a standalone l-dropdown-item.\n */\n\n[popover] {\n inset: unset;\n overflow: visible;\n width: max-content;\n padding: var(--padding, var(--l-popover-padding));\n margin: 0;\n border: 1px solid var(--l-color-border-overlay);\n border-radius: var(--border-radius, var(--l-popover-border-radius));\n background: var(--background, var(--l-color-surface-overlay));\n color: var(--l-color-text-primary);\n box-shadow: var(--shadow, var(--l-popover-shadow));\n font-size: var(--l-popover-font-size);\n line-height: var(--l-popover-line-height);\n}\n\n/* Lightweight separator alternative to <l-divider> — same dimensions, no extra\n import. Bleeds through the panel padding to span its edges. Scoped to slots\n inside the panel, so an item's own label slot never picks it up. */\n[popover] ::slotted(hr) {\n display: block;\n height: 1px;\n margin-block: var(--padding, var(--l-popover-padding));\n margin-inline: calc(var(--padding, var(--l-popover-padding)) * -1);\n border: 0;\n background: var(--l-color-divider);\n}\n","import { unsafeCSS } from 'lit';\nimport raw from './menu-panel.css?inline';\n\n/**\n * Wrapper module for the menu panel shared by l-dropdown and l-dropdown-item\n * submenus. `unsafeCSS()` is called once here so both share one `CSSResult`\n * (one constructed `CSSStyleSheet`, not one per importer).\n */\nexport default unsafeCSS(raw);\n"],"mappings":"A,wCCQA,IAAAG,EAAeH,EAAUC,opBAAG,E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper module for the shared picker core (field frame, chevron, clear,
|
|
3
|
+
* listbox popover). `unsafeCSS()` is called once here so l-select and
|
|
4
|
+
* l-combobox share one `CSSResult` (one constructed `CSSStyleSheet`, not one
|
|
5
|
+
* per importer).
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: import("lit").CSSResult;
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=picker-core.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker-core.styles.d.ts","sourceRoot":"","sources":["../../../src/html/shared/styles/picker-core.styles.ts"],"names":[],"mappings":"AAGA;;;;;GAKG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"../../chunks/lit.js";var t=e(`:host{--height:var(--l-form-control-height);--border-radius:var(--l-form-control-border-radius);--background:var(--l-color-surface-overlay);inline-size:100%;display:block}:host([size=xs]){--height:var(--l-size-control-xs)}:host([size=sm]){--height:var(--l-size-control-sm)}:host([size=lg]){--height:var(--l-size-control-lg)}:host([size=xl]){--height:var(--l-size-control-xl)}:host([disabled]){opacity:.5;pointer-events:none}.base{position:relative}:is(.control,.trigger){padding-inline:var(--l-form-control-padding-inline);border:var(--l-form-control-border-width) solid var(--l-form-control-border-color);border-radius:var(--border-radius);background-color:var(--l-form-control-background-color);align-items:center;display:flex}@media (hover:hover){:is(.control,.trigger):hover{border-color:var(--l-form-control-border-color-hover)}}.trigger:focus-visible{border-color:var(--l-focus-ring);box-shadow:0 0 0 3px color-mix(in oklab, var(--l-focus-ring) 22%, transparent)}.control:has(.input:focus-visible){border-color:var(--l-focus-ring);box-shadow:0 0 0 3px color-mix(in oklab, var(--l-focus-ring) 22%, transparent)}:host{--_action-size:calc(var(--height) - 2 * var(--l-form-control-border-width))}:is(.chevron,.clear-button){inline-size:var(--_action-size);color:var(--l-form-control-placeholder-color);flex:none;place-items:center;display:grid}:is(.chevron,.clear-button):before{content:"";inline-size:var(--l-form-control-icon-size);block-size:var(--l-form-control-icon-size);-webkit-mask:var(--_glyph) center / contain no-repeat;mask:var(--_glyph) center / contain no-repeat;background-color:currentColor}.chevron{--_glyph:var(--chevron-icon);align-self:stretch;margin-inline-end:calc(var(--l-form-control-padding-inline) * -1)}.chevron:before{transition:rotate .15s}.base:has([role=combobox][aria-expanded=true]) .chevron:before{rotate:180deg}.clear-button{--_glyph:var(--clear-icon);block-size:var(--_action-size);border-radius:calc(var(--border-radius) - var(--l-form-control-border-width));font:inherit;cursor:pointer;background:0 0;border:0;margin:0;padding:0;transition-property:background-color,color;transition-duration:.15s}@media (hover:hover){.clear-button:hover{color:var(--l-form-control-value-color);background-color:var(--l-color-bg-fill-neutral-soft)}}.clear-button:active{background-color:var(--l-color-bg-fill-neutral-subtle)}.clear-button:focus-visible{outline:2px solid var(--l-focus-ring);outline-offset:-2px}.panel{border:1px solid var(--l-color-border-overlay);border-radius:var(--border-radius);background-color:var(--background);box-shadow:var(--l-popover-shadow);color:var(--l-color-text-primary);font-size:var(--l-popover-font-size);line-height:var(--l-popover-line-height);opacity:0;transition:opacity .12s ease, scale .12s ease, display .12s allow-discrete, overlay .12s allow-discrete;margin:0;padding:0;inset:auto;overflow:hidden;scale:.98}.panel:popover-open{opacity:1;scale:1}@starting-style{.panel:popover-open{opacity:0;scale:.98}}.listbox{padding:var(--l-popover-padding);overscroll-behavior:contain;max-block-size:16rem;margin:0;list-style:none;overflow-y:auto}.option[aria-disabled=true]{opacity:.4;cursor:not-allowed}.option-label{text-overflow:ellipsis;white-space:nowrap;flex:1;min-inline-size:0;overflow:hidden}mark.match{background-color:var(--l-form-control-match-background-color);color:inherit;font-weight:var(--l-form-control-match-font-weight);-webkit-box-decoration-break:clone;box-decoration-break:clone;border-radius:.2em}.empty{color:var(--l-color-text-tertiary);text-align:center;padding:.5rem}:host{--chevron-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");--clear-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");--_check-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")}@media (prefers-reduced-motion:reduce){.panel,.chevron:before,.clear-button{transition-duration:0s}}`);export{t as default};
|
|
2
|
+
//# sourceMappingURL=picker-core.styles.js.map
|