luxen-ui 0.15.0 → 0.16.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.
@@ -2849,6 +2849,10 @@
2849
2849
  "description": "arrow | plus — Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross.",
2850
2850
  "name": "data-marker"
2851
2851
  },
2852
+ {
2853
+ "description": "start | end — Marker side. Defaults to `end`.",
2854
+ "name": "data-marker-placement"
2855
+ },
2852
2856
  {
2853
2857
  "description": "bordered — Adds border, background, and border-radius.",
2854
2858
  "name": "data-variant"
@@ -2893,6 +2897,14 @@
2893
2897
  ],
2894
2898
  "description": "Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross."
2895
2899
  },
2900
+ {
2901
+ "name": "data-marker-placement",
2902
+ "values": [
2903
+ "start",
2904
+ "end"
2905
+ ],
2906
+ "description": "Marker side. Defaults to `end`."
2907
+ },
2896
2908
  {
2897
2909
  "name": "data-variant",
2898
2910
  "description": "bordered — Adds border, background, and border-radius."
@@ -9215,6 +9227,26 @@
9215
9227
  "description": "The distance in pixels from the target element.",
9216
9228
  "attribute": "distance"
9217
9229
  },
9230
+ {
9231
+ "kind": "field",
9232
+ "name": "showDelay",
9233
+ "type": {
9234
+ "text": "number"
9235
+ },
9236
+ "default": "0",
9237
+ "description": "Milliseconds the pointer must dwell on the trigger before the tooltip\nshows. Applies to `hover` only — focus shows immediately.",
9238
+ "attribute": "show-delay"
9239
+ },
9240
+ {
9241
+ "kind": "field",
9242
+ "name": "hideDelay",
9243
+ "type": {
9244
+ "text": "number"
9245
+ },
9246
+ "default": "0",
9247
+ "description": "Milliseconds to wait after the pointer leaves the trigger (and its safe\npolygon) before hiding. Bridges a brief exit-and-return without flicker.\nApplies to `hover` only.",
9248
+ "attribute": "hide-delay"
9249
+ },
9218
9250
  {
9219
9251
  "kind": "field",
9220
9252
  "name": "open",
@@ -9288,6 +9320,24 @@
9288
9320
  "description": "The distance in pixels from the target element.",
9289
9321
  "fieldName": "distance"
9290
9322
  },
9323
+ {
9324
+ "name": "show-delay",
9325
+ "type": {
9326
+ "text": "number"
9327
+ },
9328
+ "default": "0",
9329
+ "description": "Milliseconds the pointer must dwell on the trigger before the tooltip\nshows. Applies to `hover` only — focus shows immediately.",
9330
+ "fieldName": "showDelay"
9331
+ },
9332
+ {
9333
+ "name": "hide-delay",
9334
+ "type": {
9335
+ "text": "number"
9336
+ },
9337
+ "default": "0",
9338
+ "description": "Milliseconds to wait after the pointer leaves the trigger (and its safe\npolygon) before hiding. Bridges a brief exit-and-return without flicker.\nApplies to `hover` only.",
9339
+ "fieldName": "hideDelay"
9340
+ },
9291
9341
  {
9292
9342
  "name": "open",
9293
9343
  "type": {
@@ -7,6 +7,7 @@
7
7
  * @attribute open - Native attribute — starts the disclosure expanded.
8
8
  * @attribute name - Native attribute — groups disclosures into an exclusive accordion.
9
9
  * @attribute data-marker - arrow | plus — Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross.
10
+ * @attribute data-marker-placement - start | end — Marker side. Defaults to `end`.
10
11
  * @attribute data-variant - bordered — Adds border, background, and border-radius.
11
12
  * @attribute disabled - Disables interaction (set on `<details>` or `<summary>`).
12
13
  *
@@ -1 +1 @@
1
- {"version":3,"file":"disclosure.meta.d.ts","sourceRoot":"","sources":["../../../src/html/elements/disclosure/disclosure.meta.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qBAAa,cAAc;CAAG"}
1
+ {"version":3,"file":"disclosure.meta.d.ts","sourceRoot":"","sources":["../../../src/html/elements/disclosure/disclosure.meta.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,qBAAa,cAAc;CAAG"}
@@ -28,6 +28,19 @@ export declare class Tooltip extends LuxenElement {
28
28
  accessor placement: Placement;
29
29
  /** The distance in pixels from the target element. */
30
30
  accessor distance: number;
31
+ /**
32
+ * Milliseconds the pointer must dwell on the trigger before the tooltip
33
+ * shows. Applies to `hover` only — focus shows immediately.
34
+ */
35
+ accessor showDelay: number;
36
+ /**
37
+ * Milliseconds to wait after the pointer leaves the trigger (and its safe
38
+ * polygon) before hiding. Bridges a brief exit-and-return without flicker.
39
+ * Applies to `hover` only.
40
+ */
41
+ accessor hideDelay: number;
42
+ private _showTimer?;
43
+ private _hideTimer?;
31
44
  /** Whether or not the tooltip is visible. */
32
45
  accessor open: boolean;
33
46
  /** Hide the directional arrow. */
@@ -42,12 +55,16 @@ export declare class Tooltip extends LuxenElement {
42
55
  connectedCallback(): void;
43
56
  disconnectedCallback(): void;
44
57
  updated(changed: PropertyValues<this>): void;
58
+ /** Cancel any pending delayed show/hide (trigger gone, `for` changed, disconnect). */
59
+ private _clearTimers;
45
60
  show(): void;
46
61
  hide(): void;
47
62
  toggle(): void;
48
63
  private _handleOpenChange;
49
64
  private _onPointerEnter;
50
65
  private _onPointerLeave;
66
+ /** Hide now, or after `hide-delay` if set (cancellable by a pointer return). */
67
+ private _scheduleHide;
51
68
  private _onFocusIn;
52
69
  private _onFocusOut;
53
70
  private _onClick;
@@ -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;AAoBlD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,OAAQ,SAAQ,YAAY;IACvC,OAAgB,MAAM,4BAAwB;IAE9C,OAAO,CAAC,UAAU,CAAuB;IAEzC,OAAO,CAAC,SAAS,CAId;IAEH,yDAAyD;IAEzD,QAAQ,CAAC,GAAG,SAAM;IAElB,8CAA8C;IAE9C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAS;IAEtC,sDAA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AAS,CAAS;IAEtC,sDAAsD;IAEtD,QAAQ,CAAC,QAAQ,SAAK;IAEtB;;;OAGG;IAEH,QAAQ,CAAC,SAAS,SAAK;IAEvB;;;;OAIG;IAEH,QAAQ,CAAC,SAAS,SAAK;IAEvB,OAAO,CAAC,UAAU,CAAC,CAAgC;IACnD,OAAO,CAAC,UAAU,CAAC,CAAgC;IAEnD,6CAA6C;IAE7C,QAAQ,CAAC,IAAI,UAAS;IAEtB,kCAAkC;IAElC,QAAQ,CAAC,YAAY,UAAS;IAE9B,kFAAkF;IAElF,QAAQ,CAAC,OAAO,SAAiB;IAEjC,OAAO,CAAC,WAAW;IAInB,OAAO,KAAK,QAAQ,GAQnB;IAED,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,CAAC,YAAY;IAKX,iBAAiB;IAMjB,oBAAoB;IAQpB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC;IAY9C,sFAAsF;IACtF,OAAO,CAAC,YAAY;IAOpB,IAAI;IAIJ,IAAI;IAIJ,MAAM;YAIQ,iBAAiB;IAgC/B,OAAO,CAAC,eAAe,CAkBrB;IAEF,OAAO,CAAC,eAAe,CAMrB;IAEF,gFAAgF;IAChF,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,UAAU,CAOhB;IACF,OAAO,CAAC,WAAW,CAOjB;IACF,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,UAAU,CAKhB;IAEF,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,uBAAuB;IAOtB,MAAM;CAoBhB"}
@@ -1,4 +1,4 @@
1
- import{uniqueId as e}from"../../registry.js";import{i as t}from"../../chunks/lit.js";import{i as n,t as r}from"../../chunks/decorate.js";import{a as i,t as a}from"../../chunks/lit-html.js";import{LuxenElement as o}from"../../shared/luxen-element.js";import s from"../../shared/styles/host.styles.js";import{PopoverController as c}from"../../shared/controllers/popover.js";var l=t(`: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 o{constructor(...t){super(...t),this._tooltipId=e(`tooltip`),this._floating=new c(this,{getTriggerElement:()=>this._trigger,getFloatingElement:()=>this._popover,getArrowElement:()=>this._arrowEl}),this.#e=``,this.#t=`top`,this.#n=8,this.#r=!1,this.#i=!1,this.#a=`hover focus`,this._onPointerEnter=()=>{if(this._hasTrigger(`hover`)){for(let e of u)e._floating.cleanupSafePolygon();this.show()}},this._onPointerLeave=e=>{!this._hasTrigger(`hover`)||!this.open||this._floating.handlePointerLeave(e,()=>this.hide())},this._onFocusIn=()=>{this._hasTrigger(`focus`)&&this.show()},this._onFocusOut=()=>{this._hasTrigger(`focus`)&&this.hide()},this._onClick=()=>{this._hasTrigger(`click`)&&this.toggle()},this._onKeyDown=e=>{this.open&&e.key===`Escape`&&(e.stopPropagation(),this.hide())}}static{this.styles=[s,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 open(){return this.#r}set open(e){this.#r=e}#i;get withoutArrow(){return this.#i}set withoutArrow(e){this.#i=e}#a;get trigger(){return this.#a}set trigger(e){this.#a=e}_hasTrigger(e){return this.trigger.split(` `).includes(e)}get _trigger(){if(!this.for)return null;let e=this.getRootNode();return e instanceof Document||e instanceof ShadowRoot?e.getElementById(this.for):null}get _popover(){return this.shadowRoot.querySelector(`[popover]`)}get _arrowEl(){return this.withoutArrow?null:this.shadowRoot.querySelector(`i`)}_getDuration(e){let t=parseFloat(getComputedStyle(this).getPropertyValue(e));return Number.isNaN(t)?150:t}connectedCallback(){super.connectedCallback(),u.add(this),requestAnimationFrame(()=>this._addTriggerListeners())}disconnectedCallback(){super.disconnectedCallback(),u.delete(this),d===this&&(d=null),this._removeTriggerListeners()}updated(e){e.has(`open`)&&this._handleOpenChange(),e.has(`for`)&&(this._removeTriggerListeners(e.get(`for`)),this._addTriggerListeners())}show(){this.open||=!0}hide(){this.open&&=!1}toggle(){this.open=!this.open}async _handleOpenChange(){let e=this._popover;if(!e)return;let t={placement:this.placement,distance:this.distance};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._getDuration(`--show-duration`)),this._floating.startPositioning(t),this._trigger?.setAttribute(`aria-describedby`,this._tooltipId)}else d===this&&(d=null),this._floating.stopPositioning(),this._floating.cleanupSafePolygon(),this._trigger?.removeAttribute(`aria-describedby`),await this._floating.animateHide(e,this._getDuration(`--hide-duration`)),e.matches(`:popover-open`)&&e.hidePopover()}_addTriggerListeners(){this._floating.addTriggerListeners({onPointerEnter:this._onPointerEnter,onPointerLeave:this._onPointerLeave,onFocusIn:this._onFocusIn,onFocusOut:this._onFocusOut,onClick:this._onClick,onKeyDown:this._onKeyDown})}_removeTriggerListeners(e){let t=e?this.getRootNode().getElementById(e):void 0;this._floating.removeTriggerListeners(t)}render(){return i`
1
+ import{uniqueId as e}from"../../registry.js";import{i as t}from"../../chunks/lit.js";import{i as n,t as r}from"../../chunks/decorate.js";import{a as i,t as a}from"../../chunks/lit-html.js";import{LuxenElement as o}from"../../shared/luxen-element.js";import s from"../../shared/styles/host.styles.js";import{PopoverController as c}from"../../shared/controllers/popover.js";var l=t(`: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 o{constructor(...t){super(...t),this._tooltipId=e(`tooltip`),this._floating=new c(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`)){for(let e of u)e._floating.cleanupSafePolygon();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,()=>this._scheduleHide())},this._onFocusIn=()=>{this._hasTrigger(`focus`)&&(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=[s,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(){if(!this.for)return null;let e=this.getRootNode();return e instanceof Document||e instanceof ShadowRoot?e.getElementById(this.for):null}get _popover(){return this.shadowRoot.querySelector(`[popover]`)}get _arrowEl(){return this.withoutArrow?null:this.shadowRoot.querySelector(`i`)}_getDuration(e){let t=parseFloat(getComputedStyle(this).getPropertyValue(e));return Number.isNaN(t)?150:t}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(`open`)&&this._handleOpenChange(),e.has(`for`)&&(this._clearTimers(),this._removeTriggerListeners(e.get(`for`)),this._addTriggerListeners())}_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 _handleOpenChange(){let e=this._popover;if(!e)return;let t={placement:this.placement,distance:this.distance};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._getDuration(`--show-duration`)),this._floating.startPositioning(t),this._trigger?.setAttribute(`aria-describedby`,this._tooltipId)}else d===this&&(d=null),this._floating.stopPositioning(),this._floating.cleanupSafePolygon(),this._trigger?.removeAttribute(`aria-describedby`),await this._floating.animateHide(e,this._getDuration(`--hide-duration`)),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){let t=e?this.getRootNode().getElementById(e):void 0;this._floating.removeTriggerListeners(t)}render(){return i`
2
2
  <div
3
3
  id=${this._tooltipId}
4
4
  popover="manual"
@@ -13,5 +13,5 @@ import{uniqueId as e}from"../../registry.js";import{i as t}from"../../chunks/lit
13
13
  `}
14
14
  <slot></slot>
15
15
  </div>
16
- `}};r([n({reflect:!0})],f.prototype,`for`,null),r([n()],f.prototype,`placement`,null),r([n({type:Number})],f.prototype,`distance`,null),r([n({type:Boolean,reflect:!0})],f.prototype,`open`,null),r([n({type:Boolean,reflect:!0,attribute:`without-arrow`})],f.prototype,`withoutArrow`,null),r([n()],f.prototype,`trigger`,null);export{f as Tooltip};
16
+ `}};r([n({reflect:!0})],f.prototype,`for`,null),r([n()],f.prototype,`placement`,null),r([n({type:Number})],f.prototype,`distance`,null),r([n({type:Number,attribute:`show-delay`})],f.prototype,`showDelay`,null),r([n({type:Number,attribute:`hide-delay`})],f.prototype,`hideDelay`,null),r([n({type:Boolean,reflect:!0})],f.prototype,`open`,null),r([n({type:Boolean,reflect:!0,attribute:`without-arrow`})],f.prototype,`withoutArrow`,null),r([n()],f.prototype,`trigger`,null);export{f as Tooltip};
17
17
  //# sourceMappingURL=tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","names":[],"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 /** 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 if (!this.for) 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\n ? root.getElementById(this.for)\n : 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._removeTriggerListeners();\n }\n\n override updated(changed: PropertyValues<this>) {\n if (changed.has('open')) {\n void this._handleOpenChange();\n }\n if (changed.has('for')) {\n this._removeTriggerListeners(changed.get('for') as string);\n this._addTriggerListeners();\n }\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 private async _handleOpenChange() {\n const popover = this._popover;\n if (!popover) return;\n\n const posOpts = { placement: this.placement, distance: this.distance };\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._trigger?.setAttribute('aria-describedby', this._tooltipId);\n } else {\n if (activeTooltip === this) activeTooltip = null;\n this._floating.stopPositioning();\n this._floating.cleanupSafePolygon();\n this._trigger?.removeAttribute('aria-describedby');\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, so\n // invalidate every peer's polygon (and drop its stale `pointermove`\n // listener) along with our own.\n for (const tooltip of tooltipInstances) {\n tooltip._floating.cleanupSafePolygon();\n }\n this.show();\n };\n\n private _onPointerLeave = (e: PointerEvent) => {\n if (!this._hasTrigger('hover') || !this.open) return;\n this._floating.handlePointerLeave(e, () => this.hide());\n };\n\n private _onFocusIn = () => {\n if (this._hasTrigger('focus')) this.show();\n };\n private _onFocusOut = () => {\n if (this._hasTrigger('focus')) this.hide();\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 const trigger = forId\n ? (this.getRootNode() as Document | ShadowRoot).getElementById(forId)\n : undefined;\n this._floating.removeTriggerListeners(trigger);\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 ${this.withoutArrow\n ? nothing\n : html`\n <i\n part=\"arrow\"\n role=\"presentation\"\n ></i>\n `}\n <slot></slot>\n </div>\n `;\n }\n}\n"],"mappings":"oXCSA,IAAM,EAAS,EAAU,w7BAAS,EAW5B,EAAmB,IAAI,IACzB,EAAgC,KAmBvB,EAAb,cAA6B,CAAa,+CAGnB,EAAS,SAAS,iBAEnB,IAAI,EAAkB,KAAM,CAC9C,sBAAyB,KAAK,SAC9B,uBAA0B,KAAK,SAC/B,oBAAuB,KAAK,QAC9B,CAAC,UAIc,WAIiB,cAIZ,UAIJ,WAIQ,WAIL,uCAgGa,CACzB,QAAK,YAAY,OAAO,EAK7B,KAAK,IAAM,KAAW,EACpB,EAAQ,UAAU,mBAAmB,EAEvC,KAAK,KAAK,CAF6B,CAGzC,uBAE2B,GAAoB,CACzC,CAAC,KAAK,YAAY,OAAO,GAAK,CAAC,KAAK,MACxC,KAAK,UAAU,mBAAmB,MAAS,KAAK,KAAK,CAAC,CACxD,sBAE2B,CACrB,KAAK,YAAY,OAAO,GAAG,KAAK,KAAK,CAC3C,uBAC4B,CACtB,KAAK,YAAY,OAAO,GAAG,KAAK,KAAK,CAC3C,oBACyB,CACnB,KAAK,YAAY,OAAO,GAAG,KAAK,OAAO,CAC7C,kBAEsB,GAAqB,CACrC,KAAK,MAAQ,EAAE,MAAQ,WACzB,EAAE,gBAAgB,EAClB,KAAK,KAAK,EAEd,qBAhKyB,CAAC,EAAY,CAAM,SAYnC,KAAA,4CAIA,WAAA,kDAIA,UAAA,iDAIA,MAAA,6CAIA,cAAA,qDAIA,SAAA,yCAET,YAAoB,EAAc,CAChC,OAAO,KAAK,QAAQ,MAAM,GAAG,CAAC,CAAC,SAAS,CAAI,CAC9C,CAEA,IAAY,UAA+B,CACzC,GAAI,CAAC,KAAK,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 {"version":3,"file":"tooltip.js","names":[],"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 if (!this.for) 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\n ? root.getElementById(this.for)\n : 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 this._removeTriggerListeners();\n }\n\n override updated(changed: PropertyValues<this>) {\n if (changed.has('open')) {\n void this._handleOpenChange();\n }\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') as string);\n this._addTriggerListeners();\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 private async _handleOpenChange() {\n const popover = this._popover;\n if (!popover) return;\n\n const posOpts = { placement: this.placement, distance: this.distance };\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._trigger?.setAttribute('aria-describedby', this._tooltipId);\n } else {\n if (activeTooltip === this) activeTooltip = null;\n this._floating.stopPositioning();\n this._floating.cleanupSafePolygon();\n this._trigger?.removeAttribute('aria-describedby');\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, so\n // invalidate every peer's polygon (and drop its stale `pointermove`\n // listener) along with our own.\n for (const tooltip of tooltipInstances) {\n tooltip._floating.cleanupSafePolygon();\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 this._floating.handlePointerLeave(e, () => this._scheduleHide());\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 // Focus is a discrete affordance — show immediately, ignoring the dwell delay.\n if (this._hasTrigger('focus')) {\n clearTimeout(this._hideTimer);\n this._hideTimer = undefined;\n this.show();\n }\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 const trigger = forId\n ? (this.getRootNode() as Document | ShadowRoot).getElementById(forId)\n : undefined;\n this._floating.removeTriggerListeners(trigger);\n }\n\n override render() {\n return html`\n <div\n id=${this._tooltipId}\n popover=\"manual\"\n role=\"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AO,CAC/C,CAEA,QAAkB,CAChB,MAAO,EAAI;;aAEF,KAAK,WAAW;;;;;UAKnB,KAAK,aACH,EACA,CAAI;;;;;cAKF;;;KAIZ,CACF,KAzPG,EAAS,CAAE,QAAS,EAAK,CAAC,CAAA,EAAA,EAAA,UAAA,MAAA,IAAA,KAI1B,EAAS,CAAA,EAAA,EAAA,UAAA,YAAA,IAAA,KAIT,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAA,EAAA,UAAA,WAAA,IAAA,KAOzB,EAAS,CAAE,KAAM,OAAQ,UAAW,YAAa,CAAC,CAAA,EAAA,EAAA,UAAA,YAAA,IAAA,KAQlD,EAAS,CAAE,KAAM,OAAQ,UAAW,YAAa,CAAC,CAAA,EAAA,EAAA,UAAA,YAAA,IAAA,KAOlD,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAA,EAAA,UAAA,OAAA,IAAA,KAIzC,EAAS,CAAE,KAAM,QAAS,QAAS,GAAM,UAAW,eAAgB,CAAC,CAAA,EAAA,EAAA,UAAA,eAAA,IAAA,KAIrE,EAAS,CAAA,EAAA,EAAA,UAAA,UAAA,IAAA"}
@@ -2289,6 +2289,22 @@ In dark mode, mixes the base color with black (default 15% black).
2289
2289
  .l-disclosure[data-marker='plus'][open] summary::after {
2290
2290
  rotate: 45deg;
2291
2291
  }
2292
+
2293
+ /*
2294
+ ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
2295
+ Marker: placement
2296
+ ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
2297
+ */
2298
+
2299
+ .l-disclosure[data-marker-placement='start'] summary {
2300
+ justify-content: flex-start;
2301
+ /* Match the summary's inline padding so the space around the marker is symmetric */
2302
+ gap: calc(var(--spacing) * 4);
2303
+ }
2304
+
2305
+ .l-disclosure[data-marker-placement='start'] summary::after {
2306
+ order: -1;
2307
+ }
2292
2308
  }
2293
2309
 
2294
2310
  /* divider.css */
@@ -134,4 +134,20 @@
134
134
  .l-disclosure[data-marker='plus'][open] summary::after {
135
135
  rotate: 45deg;
136
136
  }
137
+
138
+ /*
139
+ ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
140
+ Marker: placement
141
+ ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
142
+ */
143
+
144
+ .l-disclosure[data-marker-placement='start'] summary {
145
+ justify-content: flex-start;
146
+ /* Match the summary's inline padding so the space around the marker is symmetric */
147
+ gap: calc(var(--spacing) * 4);
148
+ }
149
+
150
+ .l-disclosure[data-marker-placement='start'] summary::after {
151
+ order: -1;
152
+ }
137
153
  }
@@ -134,4 +134,20 @@
134
134
  .l-disclosure[data-marker='plus'][open] summary::after {
135
135
  rotate: 45deg;
136
136
  }
137
+
138
+ /*
139
+ ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
140
+ Marker: placement
141
+ ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
142
+ */
143
+
144
+ .l-disclosure[data-marker-placement='start'] summary {
145
+ justify-content: flex-start;
146
+ /* Match the summary's inline padding so the space around the marker is symmetric */
147
+ gap: calc(var(--spacing) * 4);
148
+ }
149
+
150
+ .l-disclosure[data-marker-placement='start'] summary::after {
151
+ order: -1;
152
+ }
137
153
  }
@@ -2849,6 +2849,10 @@
2849
2849
  "description": "arrow | plus — Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross.",
2850
2850
  "name": "data-marker"
2851
2851
  },
2852
+ {
2853
+ "description": "start | end — Marker side. Defaults to `end`.",
2854
+ "name": "data-marker-placement"
2855
+ },
2852
2856
  {
2853
2857
  "description": "bordered — Adds border, background, and border-radius.",
2854
2858
  "name": "data-variant"
@@ -2893,6 +2897,14 @@
2893
2897
  ],
2894
2898
  "description": "Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross."
2895
2899
  },
2900
+ {
2901
+ "name": "data-marker-placement",
2902
+ "values": [
2903
+ "start",
2904
+ "end"
2905
+ ],
2906
+ "description": "Marker side. Defaults to `end`."
2907
+ },
2896
2908
  {
2897
2909
  "name": "data-variant",
2898
2910
  "description": "bordered — Adds border, background, and border-radius."
@@ -9215,6 +9227,26 @@
9215
9227
  "description": "The distance in pixels from the target element.",
9216
9228
  "attribute": "distance"
9217
9229
  },
9230
+ {
9231
+ "kind": "field",
9232
+ "name": "showDelay",
9233
+ "type": {
9234
+ "text": "number"
9235
+ },
9236
+ "default": "0",
9237
+ "description": "Milliseconds the pointer must dwell on the trigger before the tooltip\nshows. Applies to `hover` only — focus shows immediately.",
9238
+ "attribute": "show-delay"
9239
+ },
9240
+ {
9241
+ "kind": "field",
9242
+ "name": "hideDelay",
9243
+ "type": {
9244
+ "text": "number"
9245
+ },
9246
+ "default": "0",
9247
+ "description": "Milliseconds to wait after the pointer leaves the trigger (and its safe\npolygon) before hiding. Bridges a brief exit-and-return without flicker.\nApplies to `hover` only.",
9248
+ "attribute": "hide-delay"
9249
+ },
9218
9250
  {
9219
9251
  "kind": "field",
9220
9252
  "name": "open",
@@ -9288,6 +9320,24 @@
9288
9320
  "description": "The distance in pixels from the target element.",
9289
9321
  "fieldName": "distance"
9290
9322
  },
9323
+ {
9324
+ "name": "show-delay",
9325
+ "type": {
9326
+ "text": "number"
9327
+ },
9328
+ "default": "0",
9329
+ "description": "Milliseconds the pointer must dwell on the trigger before the tooltip\nshows. Applies to `hover` only — focus shows immediately.",
9330
+ "fieldName": "showDelay"
9331
+ },
9332
+ {
9333
+ "name": "hide-delay",
9334
+ "type": {
9335
+ "text": "number"
9336
+ },
9337
+ "default": "0",
9338
+ "description": "Milliseconds to wait after the pointer leaves the trigger (and its safe\npolygon) before hiding. Bridges a brief exit-and-return without flicker.\nApplies to `hover` only.",
9339
+ "fieldName": "hideDelay"
9340
+ },
9291
9341
  {
9292
9342
  "name": "open",
9293
9343
  "type": {
@@ -7,6 +7,7 @@
7
7
  * @attribute open - Native attribute — starts the disclosure expanded.
8
8
  * @attribute name - Native attribute — groups disclosures into an exclusive accordion.
9
9
  * @attribute data-marker - arrow | plus — Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross.
10
+ * @attribute data-marker-placement - start | end — Marker side. Defaults to `end`.
10
11
  * @attribute data-variant - bordered — Adds border, background, and border-radius.
11
12
  * @attribute disabled - Disables interaction (set on `<details>` or `<summary>`).
12
13
  *
@@ -1 +1 @@
1
- {"version":3,"file":"disclosure.meta.d.ts","sourceRoot":"","sources":["../../../src/html/elements/disclosure/disclosure.meta.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qBAAa,cAAc;CAAG"}
1
+ {"version":3,"file":"disclosure.meta.d.ts","sourceRoot":"","sources":["../../../src/html/elements/disclosure/disclosure.meta.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,qBAAa,cAAc;CAAG"}
@@ -13,6 +13,7 @@
13
13
  * @attribute open - Native attribute — starts the disclosure expanded.
14
14
  * @attribute name - Native attribute — groups disclosures into an exclusive accordion.
15
15
  * @attribute data-marker - arrow | plus — Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross.
16
+ * @attribute data-marker-placement - start | end — Marker side. Defaults to `end`.
16
17
  * @attribute data-variant - bordered — Adds border, background, and border-radius.
17
18
  * @attribute disabled - Disables interaction (set on `<details>` or `<summary>`).
18
19
  *
@@ -28,6 +28,19 @@ export declare class Tooltip extends LuxenElement {
28
28
  accessor placement: Placement;
29
29
  /** The distance in pixels from the target element. */
30
30
  accessor distance: number;
31
+ /**
32
+ * Milliseconds the pointer must dwell on the trigger before the tooltip
33
+ * shows. Applies to `hover` only — focus shows immediately.
34
+ */
35
+ accessor showDelay: number;
36
+ /**
37
+ * Milliseconds to wait after the pointer leaves the trigger (and its safe
38
+ * polygon) before hiding. Bridges a brief exit-and-return without flicker.
39
+ * Applies to `hover` only.
40
+ */
41
+ accessor hideDelay: number;
42
+ private _showTimer?;
43
+ private _hideTimer?;
31
44
  /** Whether or not the tooltip is visible. */
32
45
  accessor open: boolean;
33
46
  /** Hide the directional arrow. */
@@ -42,12 +55,16 @@ export declare class Tooltip extends LuxenElement {
42
55
  connectedCallback(): void;
43
56
  disconnectedCallback(): void;
44
57
  updated(changed: PropertyValues<this>): void;
58
+ /** Cancel any pending delayed show/hide (trigger gone, `for` changed, disconnect). */
59
+ private _clearTimers;
45
60
  show(): void;
46
61
  hide(): void;
47
62
  toggle(): void;
48
63
  private _handleOpenChange;
49
64
  private _onPointerEnter;
50
65
  private _onPointerLeave;
66
+ /** Hide now, or after `hide-delay` if set (cancellable by a pointer return). */
67
+ private _scheduleHide;
51
68
  private _onFocusIn;
52
69
  private _onFocusOut;
53
70
  private _onClick;
@@ -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;AAoBlD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,OAAQ,SAAQ,YAAY;IACvC,OAAgB,MAAM,4BAAwB;IAE9C,OAAO,CAAC,UAAU,CAAuB;IAEzC,OAAO,CAAC,SAAS,CAId;IAEH,yDAAyD;IAEzD,QAAQ,CAAC,GAAG,SAAM;IAElB,8CAA8C;IAE9C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAS;IAEtC,sDAAsD;IAEtD,QAAQ,CAAC,QAAQ,SAAK;IAEtB,6CAA6C;IAE7C,QAAQ,CAAC,IAAI,UAAS;IAEtB,kCAAkC;IAElC,QAAQ,CAAC,YAAY,UAAS;IAE9B,kFAAkF;IAElF,QAAQ,CAAC,OAAO,SAAiB;IAEjC,OAAO,CAAC,WAAW;IAInB,OAAO,KAAK,QAAQ,GAQnB;IAED,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,CAAC,YAAY;IAKX,iBAAiB;IAMjB,oBAAoB;IAOpB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC;IAU9C,IAAI;IAIJ,IAAI;IAIJ,MAAM;YAIQ,iBAAiB;IAgC/B,OAAO,CAAC,eAAe,CAUrB;IAEF,OAAO,CAAC,eAAe,CAGrB;IAEF,OAAO,CAAC,UAAU,CAEhB;IACF,OAAO,CAAC,WAAW,CAEjB;IACF,OAAO,CAAC,QAAQ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AAsF;IACtF,OAAO,CAAC,YAAY;IAOpB,IAAI;IAIJ,IAAI;IAIJ,MAAM;YAIQ,iBAAiB;IAgC/B,OAAO,CAAC,eAAe,CAkBrB;IAEF,OAAO,CAAC,eAAe,CAMrB;IAEF,gFAAgF;IAChF,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,UAAU,CAOhB;IACF,OAAO,CAAC,WAAW,CAOjB;IACF,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,UAAU,CAKhB;IAEF,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,uBAAuB;IAOtB,MAAM;CAoBhB"}
@@ -15,7 +15,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
15
15
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
16
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
17
  };
18
- var _Tooltip_for_accessor_storage, _Tooltip_placement_accessor_storage, _Tooltip_distance_accessor_storage, _Tooltip_open_accessor_storage, _Tooltip_withoutArrow_accessor_storage, _Tooltip_trigger_accessor_storage;
18
+ var _Tooltip_for_accessor_storage, _Tooltip_placement_accessor_storage, _Tooltip_distance_accessor_storage, _Tooltip_showDelay_accessor_storage, _Tooltip_hideDelay_accessor_storage, _Tooltip_open_accessor_storage, _Tooltip_withoutArrow_accessor_storage, _Tooltip_trigger_accessor_storage;
19
19
  import { html, nothing, unsafeCSS } from 'lit';
20
20
  import { LuxenElement } from '../../shared/luxen-element.js';
21
21
  import { property } from 'lit/decorators.js';
@@ -64,6 +64,8 @@ export class Tooltip extends LuxenElement {
64
64
  _Tooltip_for_accessor_storage.set(this, '');
65
65
  _Tooltip_placement_accessor_storage.set(this, 'top');
66
66
  _Tooltip_distance_accessor_storage.set(this, 8);
67
+ _Tooltip_showDelay_accessor_storage.set(this, 0);
68
+ _Tooltip_hideDelay_accessor_storage.set(this, 0);
67
69
  _Tooltip_open_accessor_storage.set(this, false);
68
70
  _Tooltip_withoutArrow_accessor_storage.set(this, false);
69
71
  _Tooltip_trigger_accessor_storage.set(this, 'hover focus');
@@ -78,20 +80,40 @@ export class Tooltip extends LuxenElement {
78
80
  for (const tooltip of tooltipInstances) {
79
81
  tooltip._floating.cleanupSafePolygon();
80
82
  }
81
- this.show();
83
+ // The pointer is back on the trigger: cancel a pending hide (exit-and-return).
84
+ clearTimeout(this._hideTimer);
85
+ this._hideTimer = undefined;
86
+ if (this.showDelay > 0 && !this.open) {
87
+ clearTimeout(this._showTimer);
88
+ this._showTimer = setTimeout(() => this.show(), this.showDelay);
89
+ }
90
+ else {
91
+ this.show();
92
+ }
82
93
  };
83
94
  this._onPointerLeave = (e) => {
95
+ // Cancel a still-pending show — the pointer left before the dwell elapsed.
96
+ clearTimeout(this._showTimer);
97
+ this._showTimer = undefined;
84
98
  if (!this._hasTrigger('hover') || !this.open)
85
99
  return;
86
- this._floating.handlePointerLeave(e, () => this.hide());
100
+ this._floating.handlePointerLeave(e, () => this._scheduleHide());
87
101
  };
88
102
  this._onFocusIn = () => {
89
- if (this._hasTrigger('focus'))
103
+ // Focus is a discrete affordance — show immediately, ignoring the dwell delay.
104
+ if (this._hasTrigger('focus')) {
105
+ clearTimeout(this._hideTimer);
106
+ this._hideTimer = undefined;
90
107
  this.show();
108
+ }
91
109
  };
92
110
  this._onFocusOut = () => {
93
- if (this._hasTrigger('focus'))
111
+ if (this._hasTrigger('focus')) {
112
+ // A hover may have queued a show; blur must not resurrect it.
113
+ clearTimeout(this._showTimer);
114
+ this._showTimer = undefined;
94
115
  this.hide();
116
+ }
95
117
  };
96
118
  this._onClick = () => {
97
119
  if (this._hasTrigger('click'))
@@ -113,6 +135,19 @@ export class Tooltip extends LuxenElement {
113
135
  /** The distance in pixels from the target element. */
114
136
  get distance() { return __classPrivateFieldGet(this, _Tooltip_distance_accessor_storage, "f"); }
115
137
  set distance(value) { __classPrivateFieldSet(this, _Tooltip_distance_accessor_storage, value, "f"); }
138
+ /**
139
+ * Milliseconds the pointer must dwell on the trigger before the tooltip
140
+ * shows. Applies to `hover` only — focus shows immediately.
141
+ */
142
+ get showDelay() { return __classPrivateFieldGet(this, _Tooltip_showDelay_accessor_storage, "f"); }
143
+ set showDelay(value) { __classPrivateFieldSet(this, _Tooltip_showDelay_accessor_storage, value, "f"); }
144
+ /**
145
+ * Milliseconds to wait after the pointer leaves the trigger (and its safe
146
+ * polygon) before hiding. Bridges a brief exit-and-return without flicker.
147
+ * Applies to `hover` only.
148
+ */
149
+ get hideDelay() { return __classPrivateFieldGet(this, _Tooltip_hideDelay_accessor_storage, "f"); }
150
+ set hideDelay(value) { __classPrivateFieldSet(this, _Tooltip_hideDelay_accessor_storage, value, "f"); }
116
151
  /** Whether or not the tooltip is visible. */
117
152
  get open() { return __classPrivateFieldGet(this, _Tooltip_open_accessor_storage, "f"); }
118
153
  set open(value) { __classPrivateFieldSet(this, _Tooltip_open_accessor_storage, value, "f"); }
@@ -155,6 +190,7 @@ export class Tooltip extends LuxenElement {
155
190
  tooltipInstances.delete(this);
156
191
  if (activeTooltip === this)
157
192
  activeTooltip = null;
193
+ this._clearTimers();
158
194
  this._removeTriggerListeners();
159
195
  }
160
196
  updated(changed) {
@@ -162,10 +198,19 @@ export class Tooltip extends LuxenElement {
162
198
  void this._handleOpenChange();
163
199
  }
164
200
  if (changed.has('for')) {
201
+ // A queued show/hide targets the old trigger — drop it before rewiring.
202
+ this._clearTimers();
165
203
  this._removeTriggerListeners(changed.get('for'));
166
204
  this._addTriggerListeners();
167
205
  }
168
206
  }
207
+ /** Cancel any pending delayed show/hide (trigger gone, `for` changed, disconnect). */
208
+ _clearTimers() {
209
+ clearTimeout(this._showTimer);
210
+ clearTimeout(this._hideTimer);
211
+ this._showTimer = undefined;
212
+ this._hideTimer = undefined;
213
+ }
169
214
  show() {
170
215
  if (!this.open)
171
216
  this.open = true;
@@ -210,6 +255,16 @@ export class Tooltip extends LuxenElement {
210
255
  popover.hidePopover();
211
256
  }
212
257
  }
258
+ /** Hide now, or after `hide-delay` if set (cancellable by a pointer return). */
259
+ _scheduleHide() {
260
+ if (this.hideDelay > 0) {
261
+ clearTimeout(this._hideTimer);
262
+ this._hideTimer = setTimeout(() => this.hide(), this.hideDelay);
263
+ }
264
+ else {
265
+ this.hide();
266
+ }
267
+ }
213
268
  _addTriggerListeners() {
214
269
  this._floating.addTriggerListeners({
215
270
  onPointerEnter: this._onPointerEnter,
@@ -247,7 +302,7 @@ export class Tooltip extends LuxenElement {
247
302
  `;
248
303
  }
249
304
  }
250
- _Tooltip_for_accessor_storage = new WeakMap(), _Tooltip_placement_accessor_storage = new WeakMap(), _Tooltip_distance_accessor_storage = new WeakMap(), _Tooltip_open_accessor_storage = new WeakMap(), _Tooltip_withoutArrow_accessor_storage = new WeakMap(), _Tooltip_trigger_accessor_storage = new WeakMap();
305
+ _Tooltip_for_accessor_storage = new WeakMap(), _Tooltip_placement_accessor_storage = new WeakMap(), _Tooltip_distance_accessor_storage = new WeakMap(), _Tooltip_showDelay_accessor_storage = new WeakMap(), _Tooltip_hideDelay_accessor_storage = new WeakMap(), _Tooltip_open_accessor_storage = new WeakMap(), _Tooltip_withoutArrow_accessor_storage = new WeakMap(), _Tooltip_trigger_accessor_storage = new WeakMap();
251
306
  Tooltip.styles = [hostStyles, styles];
252
307
  __decorate([
253
308
  property({ reflect: true })
@@ -258,6 +313,12 @@ __decorate([
258
313
  __decorate([
259
314
  property({ type: Number })
260
315
  ], Tooltip.prototype, "distance", null);
316
+ __decorate([
317
+ property({ type: Number, attribute: 'show-delay' })
318
+ ], Tooltip.prototype, "showDelay", null);
319
+ __decorate([
320
+ property({ type: Number, attribute: 'hide-delay' })
321
+ ], Tooltip.prototype, "hideDelay", null);
261
322
  __decorate([
262
323
  property({ type: Boolean, reflect: true })
263
324
  ], Tooltip.prototype, "open", null);
@@ -37,6 +37,15 @@
37
37
  ],
38
38
  "description": "Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross."
39
39
  },
40
+ {
41
+ "name": "data-marker-placement",
42
+ "data": true,
43
+ "values": [
44
+ "start",
45
+ "end"
46
+ ],
47
+ "description": "Marker side. Defaults to `end`."
48
+ },
40
49
  {
41
50
  "name": "data-variant",
42
51
  "data": true,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.15.0",
2
+ "version": "0.16.0",
3
3
  "elements": [
4
4
  {
5
5
  "name": "alert",
@@ -1762,6 +1762,15 @@
1762
1762
  ],
1763
1763
  "description": "Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross."
1764
1764
  },
1765
+ {
1766
+ "name": "data-marker-placement",
1767
+ "data": true,
1768
+ "values": [
1769
+ "start",
1770
+ "end"
1771
+ ],
1772
+ "description": "Marker side. Defaults to `end`."
1773
+ },
1765
1774
  {
1766
1775
  "name": "data-variant",
1767
1776
  "data": true,
@@ -5621,6 +5630,22 @@
5621
5630
  "reflects": false,
5622
5631
  "description": "The distance in pixels from the target element."
5623
5632
  },
5633
+ {
5634
+ "name": "showDelay",
5635
+ "attribute": "show-delay",
5636
+ "type": "number",
5637
+ "default": "0",
5638
+ "reflects": false,
5639
+ "description": "Milliseconds the pointer must dwell on the trigger before the tooltip\nshows. Applies to `hover` only — focus shows immediately."
5640
+ },
5641
+ {
5642
+ "name": "hideDelay",
5643
+ "attribute": "hide-delay",
5644
+ "type": "number",
5645
+ "default": "0",
5646
+ "reflects": false,
5647
+ "description": "Milliseconds to wait after the pointer leaves the trigger (and its safe\npolygon) before hiding. Bridges a brief exit-and-return without flicker.\nApplies to `hover` only."
5648
+ },
5624
5649
  {
5625
5650
  "name": "open",
5626
5651
  "attribute": "open",
@@ -39,6 +39,22 @@
39
39
  "reflects": false,
40
40
  "description": "The distance in pixels from the target element."
41
41
  },
42
+ {
43
+ "name": "showDelay",
44
+ "attribute": "show-delay",
45
+ "type": "number",
46
+ "default": "0",
47
+ "reflects": false,
48
+ "description": "Milliseconds the pointer must dwell on the trigger before the tooltip\nshows. Applies to `hover` only — focus shows immediately."
49
+ },
50
+ {
51
+ "name": "hideDelay",
52
+ "attribute": "hide-delay",
53
+ "type": "number",
54
+ "default": "0",
55
+ "reflects": false,
56
+ "description": "Milliseconds to wait after the pointer leaves the trigger (and its safe\npolygon) before hiding. Bridges a brief exit-and-return without flicker.\nApplies to `hover` only."
57
+ },
42
58
  {
43
59
  "name": "open",
44
60
  "attribute": "open",
@@ -66,6 +66,33 @@ Add `data-marker="arrow"` or `data-marker="plus"` for an animated icon indicator
66
66
  </div>
67
67
  ```
68
68
 
69
+ ### Marker placement
70
+
71
+ Add `data-marker-placement="start"` to move the marker before the label (defaults to `end`).
72
+
73
+ ```html
74
+ <div class="flex flex-col gap-3">
75
+ <details
76
+ class="l-disclosure"
77
+ data-variant="bordered"
78
+ data-marker="arrow"
79
+ data-marker-placement="start"
80
+ >
81
+ <summary>Arrow at the start</summary>
82
+ <div>The marker sits before the label instead of after it.</div>
83
+ </details>
84
+ <details
85
+ class="l-disclosure"
86
+ data-variant="bordered"
87
+ data-marker="plus"
88
+ data-marker-placement="start"
89
+ >
90
+ <summary>Plus at the start</summary>
91
+ <div>Works with any marker icon.</div>
92
+ </details>
93
+ </div>
94
+ ```
95
+
69
96
  ## Examples
70
97
 
71
98
  ### FAQ
@@ -154,6 +181,7 @@ Use the native `name` attribute to create an exclusive accordion — only one it
154
181
  - **open** — Native attribute — starts the disclosure expanded.
155
182
  - **name** — Native attribute — groups disclosures into an exclusive accordion.
156
183
  - **data-marker**: `arrow | plus` — Marker icon: `arrow` rotates 180° when open; `plus` rotates 45° into a cross.
184
+ - **data-marker-placement**: `start | end` — Marker side. Defaults to `end`.
157
185
  - **data-variant** — bordered — Adds border, background, and border-radius.
158
186
  - **disabled** — Disables interaction (set on `<details>` or `<summary>`).
159
187
 
@@ -100,6 +100,35 @@ At most one `hover`/`focus`/`click` tooltip is visible at a time — opening one
100
100
  >
101
101
  ```
102
102
 
103
+ ### Delay
104
+
105
+ Set `show-delay` to require the pointer to dwell before the tooltip shows — filtering out tooltips for controls the pointer merely passes over (toolbars, table action columns, dense grids). Set `hide-delay` to bridge a brief exit-and-return without flicker. Both are in milliseconds and apply to `hover` only; focus always shows immediately.
106
+
107
+ ```html
108
+ <div class="flex gap-3">
109
+ <button
110
+ id="tooltip-delay-a"
111
+ class="l-button"
112
+ >
113
+ Immediate
114
+ </button>
115
+ <l-tooltip for="tooltip-delay-a">Shows right away</l-tooltip>
116
+
117
+ <button
118
+ id="tooltip-delay-b"
119
+ class="l-button"
120
+ >
121
+ Dwell 400ms
122
+ </button>
123
+ <l-tooltip
124
+ for="tooltip-delay-b"
125
+ show-delay="400"
126
+ hide-delay="150"
127
+ >Only after the pointer rests</l-tooltip
128
+ >
129
+ </div>
130
+ ```
131
+
103
132
  ### Without arrow
104
133
 
105
134
  Add `without-arrow` to hide the directional arrow.
@@ -378,6 +407,11 @@ import 'luxen-ui/tooltip';
378
407
  - **for**: `string` — The HTML id of the element triggering the tooltip.
379
408
  - **placement**: `Placement` (default: `'top'`) — The preferred placement of the tooltip.
380
409
  - **distance**: `number` (default: `8`) — The distance in pixels from the target element.
410
+ - **show-delay**: `number` (default: `0`) — Milliseconds the pointer must dwell on the trigger before the tooltip
411
+ shows. Applies to `hover` only — focus shows immediately.
412
+ - **hide-delay**: `number` (default: `0`) — Milliseconds to wait after the pointer leaves the trigger (and its safe
413
+ polygon) before hiding. Bridges a brief exit-and-return without flicker.
414
+ Applies to `hover` only.
381
415
  - **open**: `boolean` (default: `false`) — Whether or not the tooltip is visible.
382
416
  - **without-arrow**: `boolean` (default: `false`) — Hide the directional arrow.
383
417
  - **trigger**: `string` (default: `'hover focus'`) — Space-separated list of trigger modes: `hover`, `focus`, `click`, `manual`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "luxen-ui",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Modern web components and CSS-first UI library built with Lit. Framework-agnostic, customizable prefix, design tokens.",
5
5
  "keywords": [
6
6
  "custom-elements",