@lofid/web 1.1.0 → 1.1.2

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.
@@ -3,7 +3,7 @@
3
3
  "readme": "README.md",
4
4
  "package": {
5
5
  "name": "@lofid/web",
6
- "version": "1.1.0"
6
+ "version": "1.1.2"
7
7
  },
8
8
  "modules": [
9
9
  {
@@ -7394,7 +7394,7 @@
7394
7394
  "declarations": [
7395
7395
  {
7396
7396
  "kind": "class",
7397
- "description": "`<lof-resizable-panel>` — one pane of a `<lof-resizable-group>`. Its size is a percentage of the group, set by the group as the host's `flex-basis`.",
7397
+ "description": "`<lof-resizable-panel>` — one pane of a `<lof-resizable-group>`. Its size is a percentage of the group, set by the group as the host's flex-grow: panels share what the handles leave, so the group never overflows, and a panel never grows past its share to fit its content (it scrolls).",
7398
7398
  "name": "LofResizablePanel",
7399
7399
  "tagName": "lof-resizable-panel",
7400
7400
  "customElement": true,
@@ -9619,7 +9619,7 @@
9619
9619
  {
9620
9620
  "kind": "field",
9621
9621
  "name": "trend",
9622
- "description": "Direction of the change: up (good, green), down (red) or neutral. Default: from the sign of `change`.",
9622
+ "description": "Whether the change is good (up: green), bad (down: red) or neutral. Default: from the sign of `change`. It sets the colour only: the arrow always follows the change itself, so a refund rate that falls can be green with a down arrow (`change=\"−0.4 pts\" trend=\"up\"`).",
9623
9623
  "type": {
9624
9624
  "text": "StatTrend"
9625
9625
  },
@@ -9678,7 +9678,7 @@
9678
9678
  "type": {
9679
9679
  "text": "StatTrend"
9680
9680
  },
9681
- "description": "Direction of the change: up (good, green), down (red) or neutral. Default: from the sign of `change`."
9681
+ "description": "Whether the change is good (up: green), bad (down: red) or neutral. Default: from the sign of `change`. It sets the colour only: the arrow always follows the change itself, so a refund rate that falls can be green with a down arrow (`change=\"−0.4 pts\" trend=\"up\"`)."
9682
9682
  },
9683
9683
  {
9684
9684
  "name": "change-label",
package/dist/index.d.ts CHANGED
@@ -1981,6 +1981,8 @@ declare class LofResizableGroup extends LofElement {
1981
1981
  private resize;
1982
1982
  private pairFor;
1983
1983
  private onPointerDown;
1984
+ /** Space the panels' flex-grow divides: their sizes minus padding and borders. */
1985
+ private sharedExtent;
1984
1986
  private onPointerMove;
1985
1987
  private onPointerEnd;
1986
1988
  private onKeyDown;
@@ -1994,7 +1996,8 @@ declare global {
1994
1996
 
1995
1997
  /**
1996
1998
  * `<lof-resizable-panel>` — one pane of a `<lof-resizable-group>`. Its size is
1997
- * a percentage of the group, set by the group as the host's `flex-basis`.
1999
+ * a percentage of the group, set by the group as the host's flex-grow: panels share what the handles
2000
+ * leave, so the group never overflows, and a panel never grows past its share to fit its content (it scrolls).
1998
2001
  */
1999
2002
  declare class LofResizablePanel extends LofElement {
2000
2003
  static styles: lit.CSSResult;
@@ -2468,7 +2471,11 @@ declare class LofStat extends LofElement {
2468
2471
  label: string;
2469
2472
  /** Trend text ("+2.7%"); renders the trend chip. */
2470
2473
  change: string;
2471
- /** Direction of the change: up (good, green), down (red) or neutral. Default: from the sign of `change`. */
2474
+ /**
2475
+ * Whether the change is good (up: green), bad (down: red) or neutral. Default: from the sign of `change`.
2476
+ * It sets the colour only: the arrow always follows the change itself, so a refund rate that falls
2477
+ * can be green with a down arrow (`change="−0.4 pts" trend="up"`).
2478
+ */
2472
2479
  trend?: StatTrend;
2473
2480
  /** Spoken direction words, e.g. "up 2.7% from last month". Default: "increase" / "decrease". */
2474
2481
  changeLabel: string;
@@ -2476,6 +2483,9 @@ declare class LofStat extends LofElement {
2476
2483
  appearance: StatAppearance;
2477
2484
  private hasIcon;
2478
2485
  private hasFooter;
2486
+ /** Which way the number moved, read from `change`: its sign, or the words lower / higher. */
2487
+ private get movement();
2488
+ /** Good / bad colour: `trend` when set, otherwise the movement. */
2479
2489
  private get direction();
2480
2490
  render(): lit_html.TemplateResult<1>;
2481
2491
  }
@@ -2517,6 +2527,14 @@ declare class LofStepper extends LofElement {
2517
2527
  private activate;
2518
2528
  private onKeydown;
2519
2529
  private indicatorContent;
2530
+ private resizeObserver?;
2531
+ connectedCallback(): void;
2532
+ disconnectedCallback(): void;
2533
+ protected updated(): void;
2534
+ /** Horizontal rows that overflow even with short connectors drop to compact titles. */
2535
+ private fit;
2536
+ /** The step whose title stays visible in compact rows. */
2537
+ private get current();
2520
2538
  render(): lit_html.TemplateResult<1>;
2521
2539
  }
2522
2540
  declare global {
@@ -2903,6 +2921,8 @@ declare class LofTooltip extends LofElement {
2903
2921
  */
2904
2922
  private onDocKeydown;
2905
2923
  private onEnter;
2924
+ /** Shifts a bubble that would cross the viewport edge back inside it (8px margin). */
2925
+ private keepInView;
2906
2926
  private onLeave;
2907
2927
  private reset;
2908
2928
  /** The text reaches screen readers as the focused control's description. */
package/dist/index.js CHANGED
@@ -1027,8 +1027,11 @@ LofTextfield.styles = [
1027
1027
  letter-spacing: var(--lof-body-field-label-letter-spacing);
1028
1028
  }
1029
1029
  .required-mark { color: var(--lof-text-danger); }
1030
- /* no label above (none / floating): hold the row so fields line up */
1031
- .reserve { height: calc(var(--lof-field-label-reserve, calc(var(--_label-lh) + 4px)) - 4px); }
1030
+ /* no label above (none / floating): nothing is held by default, so a search
1031
+ field lines up with the buttons beside it. A form row that mixes labelled and
1032
+ unlabelled fields opts in with --lof-field-label-reserve (label line-height
1033
+ + 4px). The -4px margin cancels the .field gap, so 0 really is 0. */
1034
+ .reserve { height: var(--lof-field-label-reserve, 0px); margin-bottom: -4px; }
1032
1035
 
1033
1036
  /* control box */
1034
1037
  .control {
@@ -2499,7 +2502,7 @@ ${row.supporting}` : nothing5;
2499
2502
  exportparts="label, control, input, helper, right-icon"
2500
2503
  right-icon-aria-label="Clear"
2501
2504
  variant=${this.variant}
2502
- ?fullwidth=${this.fullWidth}
2505
+ .fullWidth=${this.fullWidth}
2503
2506
  .label=${this.label}
2504
2507
  .placeholder=${this.placeholder}
2505
2508
  .value=${this.text}
@@ -2917,6 +2920,10 @@ LofAvatar.styles = css8`
2917
2920
  text-transform: uppercase;
2918
2921
  user-select: none;
2919
2922
  }
2923
+ /* initials move off an edge something covers (an avatar group's overlap) */
2924
+ [part="label"] {
2925
+ margin-inline-end: var(--lof-avatar-label-inset-end, 0px);
2926
+ }
2920
2927
  :host([variant="subtle"]) .avatar {
2921
2928
  background-color: var(--lof-avatar-bg-subtle, var(--lof-bg-muted, var(--lof-bg-neutral-elevated-1)));
2922
2929
  color: var(--lof-avatar-color-subtle, var(--lof-text-label));
@@ -3108,13 +3115,23 @@ LofAvatarGroup.styles = css9`
3108
3115
  display: inline-flex;
3109
3116
  vertical-align: middle;
3110
3117
  --_overlap: 8px;
3118
+ --_d: 32px;
3111
3119
  }
3112
3120
  :host([hidden]) {
3113
3121
  display: none;
3114
3122
  }
3115
- :host([size="large"]) { --_overlap: 10px; }
3116
- :host([size="small"]) { --_overlap: 6px; }
3117
- :host([size="extra-small"]) { --_overlap: 4px; }
3123
+ :host([size="large"]) { --_overlap: 10px; --_d: 40px; }
3124
+ :host([size="small"]) { --_overlap: 6px; --_d: 24px; }
3125
+ :host([size="extra-small"]) { --_overlap: 4px; --_d: 20px; }
3126
+ /* the next avatar covers the right edge: initials step down and centre in what stays visible
3127
+ (page styles on the avatar still win over ::slotted) */
3128
+ ::slotted(lof-avatar[type="text"]) {
3129
+ --lof-avatar-font-size: max(10px, calc(var(--_d) * 0.38));
3130
+ --lof-avatar-label-inset-end: var(--lof-avatar-group-overlap, var(--_overlap));
3131
+ }
3132
+ ::slotted(lof-avatar[type="text"]:last-child) {
3133
+ --lof-avatar-label-inset-end: 0px;
3134
+ }
3118
3135
  .base {
3119
3136
  display: inline-flex;
3120
3137
  align-items: center;
@@ -8926,7 +8943,7 @@ var LofMenubar = class extends LofElement {
8926
8943
  size="medium"
8927
8944
  density="compact"
8928
8945
  alignment="leading"
8929
- selectedvalue=${el.getAttribute("value") ?? ""}
8946
+ selected-value=${el.getAttribute("value") ?? ""}
8930
8947
  .options=${options}
8931
8948
  @lof-change=${(ev) => this.pickRadio(el, ev.detail.value)}
8932
8949
  ></lof-radio>`);
@@ -10293,7 +10310,8 @@ LofSelect.styles = [
10293
10310
  font-weight: var(--lof-body-field-label-font-weight);
10294
10311
  letter-spacing: var(--lof-body-field-label-letter-spacing);
10295
10312
  }
10296
- .reserve { height: var(--lof-field-label-reserve, calc(var(--_label-lh) + 4px)); }
10313
+ /* no label above: nothing held unless a form row opts in (see lof-textfield) */
10314
+ .reserve { height: var(--lof-field-label-reserve, 0px); }
10297
10315
 
10298
10316
  .trigger {
10299
10317
  all: unset;
@@ -13294,7 +13312,7 @@ var LofResizablePanel = class extends LofElement {
13294
13312
  /** @internal */
13295
13313
  applySize(pct) {
13296
13314
  this.size = pct;
13297
- this.style.flex = `0 0 ${pct}%`;
13315
+ this.style.flex = `${pct} 1 0px`;
13298
13316
  }
13299
13317
  render() {
13300
13318
  return html37`<slot></slot>`;
@@ -13308,6 +13326,8 @@ LofResizablePanel.styles = css36`
13308
13326
  padding: 16px;
13309
13327
  overflow: auto;
13310
13328
  flex: 0 0 auto;
13329
+ min-width: 0;
13330
+ min-height: 0;
13311
13331
  }
13312
13332
  :host([hidden]) { display: none; }
13313
13333
  /* a scrollable panel is a Tab stop: 2px ring inside the edge (the group clips outside) */
@@ -13528,7 +13548,8 @@ var LofResizableGroup = class extends LofElement {
13528
13548
  this.drag = {
13529
13549
  pair: pr,
13530
13550
  start: vertical ? e.clientY : e.clientX,
13531
- extent: vertical ? rect.height : rect.width,
13551
+ // panels divide what the handles and their own padding leave, so a drag is measured against that
13552
+ extent: this.sharedExtent(vertical) || (vertical ? rect.height : rect.width),
13532
13553
  a: this.sizes[pr.a],
13533
13554
  b: this.sizes[pr.b],
13534
13555
  id: e.pointerId
@@ -13536,6 +13557,14 @@ var LofResizableGroup = class extends LofElement {
13536
13557
  pr.handle.setAttribute("data-dragging", "");
13537
13558
  this.setPointerCapture?.(e.pointerId);
13538
13559
  }
13560
+ /** Space the panels' flex-grow divides: their sizes minus padding and borders. */
13561
+ sharedExtent(vertical) {
13562
+ return [...this.querySelectorAll(":scope > lof-resizable-panel")].reduce((sum, p) => {
13563
+ const r = p.getBoundingClientRect(), cs = getComputedStyle(p);
13564
+ const edges = vertical ? ["paddingTop", "paddingBottom", "borderTopWidth", "borderBottomWidth"] : ["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"];
13565
+ return sum + (vertical ? r.height : r.width) - edges.reduce((s, k) => s + (parseFloat(cs[k]) || 0), 0);
13566
+ }, 0);
13567
+ }
13539
13568
  onPointerMove(e) {
13540
13569
  const d = this.drag;
13541
13570
  if (!d || e.pointerId !== d.id) return;
@@ -16309,16 +16338,21 @@ var LofStat = class extends LofElement {
16309
16338
  this.hasIcon = false;
16310
16339
  this.hasFooter = false;
16311
16340
  }
16312
- get direction() {
16313
- if (this.trend) return this.trend;
16341
+ /** Which way the number moved, read from `change`: its sign, or the words lower / higher. */
16342
+ get movement() {
16314
16343
  const t = this.change.trim();
16315
- if (t.startsWith("-") || t.startsWith("\u2212")) return "down";
16316
- if (t.startsWith("+")) return "up";
16344
+ if (t.startsWith("-") || t.startsWith("\u2212") || /\b(lower|down|less|fewer|decrease)\b/i.test(t)) return "down";
16345
+ if (t.startsWith("+") || /\b(higher|up|more|increase)\b/i.test(t)) return "up";
16317
16346
  return "neutral";
16318
16347
  }
16348
+ /** Good / bad colour: `trend` when set, otherwise the movement. */
16349
+ get direction() {
16350
+ return this.trend ?? this.movement;
16351
+ }
16319
16352
  render() {
16320
16353
  const dir = this.direction;
16321
- const spoken = this.changeLabel || (dir === "up" ? "increase" : dir === "down" ? "decrease" : "change");
16354
+ const move = this.movement === "neutral" ? dir : this.movement;
16355
+ const spoken = this.changeLabel || (move === "up" ? "increase" : move === "down" ? "decrease" : "change");
16322
16356
  return html47`<div part="base" class="stat">
16323
16357
  <div part="icon" class="icon" ?hidden=${!this.hasIcon}>
16324
16358
  <slot name="icon" @slotchange=${(e) => this.hasIcon = e.target.assignedElements().length > 0}></slot>
@@ -16327,7 +16361,7 @@ var LofStat = class extends LofElement {
16327
16361
  <div class="row">
16328
16362
  <p part="value" class="value">${this.value}<slot name="value"></slot></p>
16329
16363
  ${this.change ? html47`<span part="trend" class="trend ${dir}"
16330
- >${dir === "neutral" ? nothing37 : html47`<svg viewBox="0 0 10 10" fill="none" aria-hidden="true"><path d=${dir === "up" ? "M5 8.5V1.5M2 4.5l3-3 3 3" : "M5 1.5v7M2 5.5l3 3 3-3"} stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" /></svg>`}<span class="sr-only">${spoken}: </span>${this.change}</span
16364
+ >${move === "neutral" ? nothing37 : html47`<svg viewBox="0 0 10 10" fill="none" aria-hidden="true"><path d=${move === "up" ? "M5 8.5V1.5M2 4.5l3-3 3 3" : "M5 1.5v7M2 5.5l3 3 3-3"} stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" /></svg>`}<span class="sr-only">${spoken}: </span>${this.change}</span
16331
16365
  >` : nothing37}
16332
16366
  </div>
16333
16367
  ${this.label ? html47`<p part="label" class="label">${this.label}</p>` : nothing37}
@@ -16519,14 +16553,50 @@ var LofStepper = class extends LofElement {
16519
16553
  return step.status === "done" ? check : html48`<span>${i + 1}</span>`;
16520
16554
  }
16521
16555
  }
16556
+ connectedCallback() {
16557
+ super.connectedCallback();
16558
+ if (typeof ResizeObserver !== "undefined") {
16559
+ this.resizeObserver = new ResizeObserver(() => this.fit());
16560
+ this.resizeObserver.observe(this);
16561
+ }
16562
+ }
16563
+ disconnectedCallback() {
16564
+ this.resizeObserver?.disconnect();
16565
+ this.resizeObserver = void 0;
16566
+ super.disconnectedCallback();
16567
+ }
16568
+ updated() {
16569
+ this.fit();
16570
+ }
16571
+ /** Horizontal rows that overflow even with short connectors drop to compact titles. */
16572
+ fit() {
16573
+ const row = this.renderRoot.querySelector(".lof-stepper");
16574
+ if (!row) return;
16575
+ if (row.classList.contains("vertical")) {
16576
+ row.classList.remove("compact");
16577
+ return;
16578
+ }
16579
+ if (row.clientWidth === 0) return;
16580
+ row.classList.remove("compact");
16581
+ row.classList.toggle("compact", row.scrollWidth > row.clientWidth + 1);
16582
+ }
16583
+ /** The step whose title stays visible in compact rows. */
16584
+ get current() {
16585
+ const steps = this.list;
16586
+ const p = steps.findIndex((s) => s.status === "progress");
16587
+ if (p >= 0) return p;
16588
+ for (let i = steps.length - 1; i >= 0; i--) if (steps[i].status === "done") return i;
16589
+ return 0;
16590
+ }
16522
16591
  render() {
16523
16592
  const steps = this.list;
16524
16593
  const n = steps.length;
16525
16594
  const layout = this.layout;
16526
16595
  const vertical = this.orientation === "vertical";
16596
+ const current = this.current;
16527
16597
  const cls = ["lof-stepper", vertical ? "vertical" : "horizontal", layout, this.labelPlacement === "top" ? "label-top" : ""].filter(Boolean).join(" ");
16528
16598
  return html48`
16529
- <div class=${cls} role="group" aria-label="Progress steps">
16599
+ <div class=${cls} style="--_rest:${Math.max(0, n - 1)}" role="group" aria-label="Progress steps">
16530
16600
  ${steps.map((step, i) => {
16531
16601
  const last = i === n - 1;
16532
16602
  const disabled = step.status === "disabled";
@@ -16536,9 +16606,9 @@ var LofStepper = class extends LofElement {
16536
16606
  const text = html48`<div part="label" class="step-label">${step.title}</div>
16537
16607
  ${step.subtitle ? html48`<div part="subtitle" class="step-subtitle">${step.subtitle}</div>` : nothing38}`;
16538
16608
  const label = `${step.title}, step ${i + 1} of ${n}${step.status === "done" ? ", completed" : ""}`;
16539
- const inner = vertical && layout === "text-right" ? html48`<div class="indicator-wrapper">${indicator}${conn}</div>${text}` : html48`${indicator}${text}${conn}`;
16540
- return html48`<div
16541
- class="lof-step ${step.status}"
16609
+ const inner = !vertical ? html48`${indicator}${text}` : layout === "text-right" ? html48`<div class="indicator-wrapper">${indicator}${conn}</div>${text}` : html48`${indicator}${text}${conn}`;
16610
+ const stepEl = html48`<div
16611
+ class="lof-step ${step.status} ${i === current ? "current" : ""}"
16542
16612
  role="button"
16543
16613
  tabindex=${disabled ? "-1" : "0"}
16544
16614
  aria-label=${label}
@@ -16549,6 +16619,7 @@ var LofStepper = class extends LofElement {
16549
16619
  >
16550
16620
  ${inner}
16551
16621
  </div>`;
16622
+ return vertical ? stepEl : html48`${stepEl}${conn}`;
16552
16623
  })}
16553
16624
  </div>
16554
16625
  `;
@@ -16569,12 +16640,21 @@ LofStepper.styles = [
16569
16640
  display: flex;
16570
16641
  color: var(--lof-text-default);
16571
16642
  --_len: var(--lof-stepper-connector-length, 96px);
16643
+ --_mark: var(--_ind);
16572
16644
  }
16645
+ :host([type="dot"]) .lof-stepper {
16646
+ --_mark: 10px;
16647
+ }
16648
+ /* horizontal: connectors sit between the steps and give up length first, so the
16649
+ row fits its container; when even short connectors don't fit, .compact keeps
16650
+ only the current step's title (the others stay in each step's aria-label) */
16573
16651
  .lof-stepper.horizontal {
16574
16652
  flex-direction: row;
16575
16653
  align-items: flex-start;
16576
16654
  justify-content: center;
16577
- gap: calc(var(--_len) + 24px);
16655
+ justify-content: safe center;
16656
+ gap: 12px;
16657
+ min-inline-size: 0;
16578
16658
  }
16579
16659
  .lof-stepper.vertical {
16580
16660
  flex-direction: column;
@@ -16605,7 +16685,26 @@ LofStepper.styles = [
16605
16685
  cursor: not-allowed;
16606
16686
  }
16607
16687
  .horizontal .lof-step {
16608
- flex: 0 1 0%;
16688
+ flex: none;
16689
+ }
16690
+ .compact .lof-step:not(.current) .step-label,
16691
+ .compact .lof-step:not(.current) .step-subtitle {
16692
+ display: none;
16693
+ }
16694
+ /* the current title may still be too long for a very narrow row: it gets what
16695
+ is left after the other indicators, 16px connectors and the 12px gaps
16696
+ (--_rest is the number of other steps) */
16697
+ .compact .lof-step.current {
16698
+ flex: none;
16699
+ max-inline-size: max(var(--_mark), calc(100% - var(--_rest, 0) * (var(--_mark) + 40px)));
16700
+ }
16701
+ .compact .lof-step.current .step-label,
16702
+ .compact .lof-step.current .step-subtitle {
16703
+ min-inline-size: 0;
16704
+ max-inline-size: 100%;
16705
+ overflow: hidden;
16706
+ text-overflow: ellipsis;
16707
+ white-space: nowrap;
16609
16708
  }
16610
16709
  .text-below .lof-step {
16611
16710
  flex-direction: column;
@@ -16666,8 +16765,8 @@ LofStepper.styles = [
16666
16765
  color: var(--lof-accent-foreground);
16667
16766
  }
16668
16767
  :host([type="dot"]) .indicator {
16669
- width: 10px;
16670
- height: 10px;
16768
+ width: var(--_mark);
16769
+ height: var(--_mark);
16671
16770
  }
16672
16771
  :host([type="dot"]) .progress .indicator { box-shadow: 0 0 0 3px var(--lof-focus-halo, transparent); }
16673
16772
  /* upcoming / unavailable steps recede in colour, not opacity, so they stay legible */
@@ -16726,14 +16825,19 @@ LofStepper.styles = [
16726
16825
  .vertical .connector.dashed.strong {
16727
16826
  background: repeating-linear-gradient(to bottom, var(--lof-accent) 0, var(--lof-accent) 2px, transparent 2px, transparent 4px);
16728
16827
  }
16729
- /* horizontal: from the step's right edge, at half the step's height */
16828
+ /* horizontal: a flex item between two steps, at half the row's height; it is
16829
+ --_len long when there is room and shrinks to 16px before the row overflows */
16730
16830
  .horizontal .connector {
16731
- top: 50%;
16732
- left: 100%;
16733
- width: var(--_len);
16831
+ position: relative;
16832
+ flex: 0 1 var(--_len);
16833
+ min-inline-size: 16px;
16734
16834
  height: 2px;
16735
- margin-left: 12px;
16736
- transform: translateY(-50%);
16835
+ align-self: center;
16836
+ }
16837
+ /* compact rows are mostly bare indicators: line up with their centres */
16838
+ .horizontal.compact .connector {
16839
+ align-self: flex-start;
16840
+ margin-top: calc(var(--_mark) / 2 - 1px);
16737
16841
  }
16738
16842
  /* vertical, label beside: from under the indicator */
16739
16843
  .vertical.text-right .connector {
@@ -19120,6 +19224,7 @@ var LofTooltip = class extends LofElement {
19120
19224
  };
19121
19225
  this.onEnter = () => {
19122
19226
  this.hovered = true;
19227
+ this.keepInView();
19123
19228
  };
19124
19229
  this.onLeave = () => {
19125
19230
  this.hovered = false;
@@ -19130,6 +19235,7 @@ var LofTooltip = class extends LofElement {
19130
19235
  };
19131
19236
  /** The text reaches screen readers as the focused control's description. */
19132
19237
  this.onFocusIn = () => {
19238
+ this.keepInView();
19133
19239
  let a = document.activeElement;
19134
19240
  while (a?.shadowRoot?.activeElement) a = a.shadowRoot.activeElement;
19135
19241
  if (a && a !== this) this.describe(a);
@@ -19151,6 +19257,22 @@ var LofTooltip = class extends LofElement {
19151
19257
  this.removeEventListener("focusin", this.onFocusIn);
19152
19258
  this.removeEventListener("focusout", this.reset);
19153
19259
  }
19260
+ /** Shifts a bubble that would cross the viewport edge back inside it (8px margin). */
19261
+ keepInView() {
19262
+ const b = this.renderRoot.querySelector(".tooltip-bubble");
19263
+ if (!b || this.position === "left" || this.position === "right") return;
19264
+ b.style.removeProperty("--_nudge");
19265
+ requestAnimationFrame(() => {
19266
+ const r = b.getBoundingClientRect();
19267
+ if (!r.width) return;
19268
+ const pad3 = 8;
19269
+ const vw = document.documentElement.clientWidth;
19270
+ let n = 0;
19271
+ if (r.right > vw - pad3) n = vw - pad3 - r.right;
19272
+ if (r.left + n < pad3) n = pad3 - r.left;
19273
+ if (n) b.style.setProperty("--_nudge", `${Math.round(n)}px`);
19274
+ });
19275
+ }
19154
19276
  describe(el) {
19155
19277
  this.described.add(el);
19156
19278
  if (this.text) el.setAttribute("aria-description", this.text);
@@ -19213,11 +19335,16 @@ LofTooltip.styles = css53`
19213
19335
  white-space: nowrap;
19214
19336
  filter: drop-shadow(0 4px 12px rgba(11, 11, 11, 0.14));
19215
19337
  pointer-events: none;
19338
+ /* hidden bubbles take no space: one at the edge of a phone screen would otherwise
19339
+ widen the page. display animates as a discrete step so the fade-out still plays. */
19340
+ display: none;
19216
19341
  opacity: 0;
19342
+ /* moves the bubble back inside the viewport (set from JS); the tail moves the other way */
19343
+ margin-inline-start: var(--_nudge, 0px);
19217
19344
  /* translate takes space-separated lengths (a comma makes the declaration invalid) */
19218
19345
  --_shift: 0px 4px;
19219
19346
  translate: var(--_shift);
19220
- transition: opacity 120ms ease, translate 160ms cubic-bezier(0.2, 0, 0, 1);
19347
+ transition: opacity 120ms ease, translate 160ms cubic-bezier(0.2, 0, 0, 1), display 160ms allow-discrete;
19221
19348
  }
19222
19349
  .below { --_shift: 0px -4px; }
19223
19350
  .left { --_shift: 4px 0px; }
@@ -19236,9 +19363,19 @@ LofTooltip.styles = css53`
19236
19363
  /* hover waits a beat so passing pointers don't flash tips; focus is immediate */
19237
19364
  :host(:hover) .tooltip-bubble:not(.dismissed),
19238
19365
  :host(:focus-within) .tooltip-bubble:not(.dismissed) {
19366
+ display: block;
19239
19367
  opacity: 1;
19240
19368
  translate: 0 0;
19241
19369
  }
19370
+ @starting-style {
19371
+ :host(:hover) .tooltip-bubble:not(.dismissed),
19372
+ :host(:focus-within) .tooltip-bubble:not(.dismissed) {
19373
+ opacity: 0;
19374
+ translate: var(--_shift);
19375
+ }
19376
+ }
19377
+ .above .tooltip-tail,
19378
+ .below .tooltip-tail { margin-inline-start: calc(-1 * var(--_nudge, 0px)); }
19242
19379
  :host(:hover) .tooltip-bubble:not(.dismissed) { transition-delay: 200ms; }
19243
19380
  :host(:focus-within) .tooltip-bubble:not(.dismissed) { transition-delay: 0ms; }
19244
19381