actual-css 0.20.1 → 0.20.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.
@@ -63,6 +63,10 @@ export type TooltipState = {
63
63
  * Pointer is over the tooltip.
64
64
  */
65
65
  overTip: boolean;
66
+ /**
67
+ * A touch tap pinned the tip open.
68
+ */
69
+ tapped: boolean;
66
70
  };
67
71
  /** True while the tip is promoted. The runtime's state, not :popover-open. */
68
72
  export declare function isTooltipVisible(tip: any): boolean;
@@ -73,6 +73,7 @@ marker to that background rather than to the neutral intent.
73
73
  - `--meter-track` — track color; raise it when the meter sits on a
74
74
  `--surface-subtle` card, where the default track would disappear.
75
75
  - `--bar-height` — bar thickness, shared with `.progress`.
76
+ - `--bar-radius` — corner of the track and the value, shared with `.progress`; `0` squares the bar.
76
77
  - `--meter-value` — relative weight of a direct child in a segmented meter.
77
78
 
78
79
  `.sm` / `.lg` are intentionally not supported: a bar keeps its inline size and only changes
@@ -32,6 +32,7 @@
32
32
  - `--progress-track` — unfilled track color.
33
33
  - `--progress-value` — filled bar color. Prefer an intent class over setting this directly.
34
34
  - `--bar-height` — bar thickness, shared with `.meter`.
35
+ - `--bar-radius` — corner of the track and the value, shared with `.meter`; `0` squares the bar.
35
36
 
36
37
  `.sm` / `.lg` are intentionally not supported: a bar keeps its inline size and only changes
37
38
  thickness, and a design asks for a 4px or a 12px bar, not for a "small" one. Set the hook
@@ -170,6 +170,38 @@ from assistive technology.
170
170
  </section>
171
171
  ```
172
172
 
173
+ ## Dates at the start
174
+
175
+ `.timeline-dates-start` sets every `<time>` in a column before the rail, as a
176
+ log or an audit trail reads: the eye runs down the times, then across to the
177
+ events. The column is as wide as the longest dateline, so every rail lines up
178
+ whatever the dates say, and the list keeps that alignment in a wide column.
179
+
180
+ Write the `<time>` first, after an optional icon or avatar, and make every
181
+ other piece of the event an element: bare text beside the time would become
182
+ its own grid item. Wrap a sentence that mixes text and links in one `<span>`
183
+ or `<p>`. Without subgrid support the dateline stays above the title.
184
+
185
+ ```html demo
186
+ <ol class="timeline timeline-dates-start">
187
+ <li>
188
+ <time datetime="2026-11-22T21:04">21:04</time>
189
+ <strong>Mara Voss</strong>
190
+ <p class="muted">Posted the job: a ledger out of the archive annex.</p>
191
+ </li>
192
+ <li class="primary">
193
+ <time datetime="2026-11-22T21:32">21:32</time>
194
+ <strong>Ghostwrite</strong>
195
+ <p class="muted">Rewrote the badge log for the service lift.</p>
196
+ </li>
197
+ <li class="warning">
198
+ <time datetime="2026-11-21">Yesterday</time>
199
+ <strong>Relay</strong>
200
+ <p class="muted">Trace detected on node 3F. <a href="#">Link rerouted</a>.</p>
201
+ </li>
202
+ </ol>
203
+ ```
204
+
173
205
  ## Activity feed
174
206
 
175
207
  Avatars as markers, the actor and verb as one sentence, and richer content
@@ -14,6 +14,8 @@ by promoting it to the top layer with `popover="manual"`.
14
14
  tooltip. Use a [flyout](flyout.md#contextual-help) for contextual help with
15
15
  links or buttons.
16
16
  - Show on hover and keyboard focus. Hide on Escape, blur, pointer leave, or a pointer press on the trigger.
17
+ - On touch, a tap opens the tooltip and still activates the trigger. A second tap, a tap elsewhere, Escape, or a dialog or popover opening closes it.
18
+ - Add `data-tooltip-no-tap` when the tooltip only repeats the trigger's accessible name, such as an icon button's `aria-label`: the tap then just runs the action.
17
19
  - A trigger scrolled out of view takes its tooltip down and brings it back when it returns; only a dismissal ends the tooltip.
18
20
  - Escape dismisses the tooltip without moving the pointer or focus (WCAG 2.1 SC 1.4.13).
19
21
  - After Escape or a pointer press dismisses a hover or focus tooltip, move the pointer away and back or return with keyboard focus to show it again.
@@ -90,7 +92,9 @@ floating content contains controls.
90
92
  The `data-tooltip="…"` shorthand is intentionally plain text. For trusted HTML,
91
93
  use an explicit tooltip referenced by `aria-describedby`. Keep its content
92
94
  non-interactive and concise; long content wraps up to the tooltip's
93
- viewport-aware maximum width.
95
+ viewport-aware maximum width. A hover card (preview card, profile peek) is the
96
+ same explicit tooltip with a richer body; once it holds links or buttons, it is
97
+ a flyout.
94
98
 
95
99
  ```html demo
96
100
  <button class="btn" type="button"
@@ -38,6 +38,7 @@ Whole pages, composed the way a real product would.
38
38
  - [iOS-style settings](../../demo/templates/settings-ios.html) - iOS-like controls and grouped settings from unchanged framework markup, a local theme, and its findings listed rule by rule
39
39
  - [Card compositions](../../demo/templates/card-compositions.html) - editorial, team, sign-in and horizontal cards composed from existing primitives
40
40
  - [Neo-brutalist](../../demo/templates/neo-brutalist.html) - a risograph print studio on the `neo-brutalist` theme (order alerts, plus-marker FAQ, ruled testimonial grid, docked cookie banner) with the page loading its own fonts
41
+ - [Cyberdeck](../../demo/templates/cyberdeck.html) - a relay station console on the `cyberdeck` theme (bevelled frames, segmented gauges, diamond markers, printed switch states, link-card reticle) with page-level micro-print
41
42
  - [Register form](../../demo/templates/register-form.html) - registration page with choice cards, masks, the password toggle, `tel-prefix` validation, an OTP verification dialog, and status feedback
42
43
 
43
44
  ### Layout references
@@ -72,7 +72,7 @@ contrast contracts apply to the combobox for free:
72
72
  .actual-combobox {
73
73
  --cb-bg: var(--control-default-bg, var(--surface));
74
74
  --cb-color: var(--text);
75
- --cb-border-color: var(--form-invalid-border, var(--border));
75
+ --cb-border-color: var(--form-invalid-border, var(--control-default-border, var(--border-control)));
76
76
  --cb-border-radius: var(--radius);
77
77
  --cb-focus-color: var(--focus);
78
78
  --cb-muted-color: var(--text-muted);
@@ -121,7 +121,9 @@ turn danger together.
121
121
 
122
122
  ### Limits
123
123
 
124
- The bridge shares the inherited resting field fill through `--control-default-bg`.
124
+ The bridge shares the inherited resting field fill and edge through
125
+ `--control-default-bg` and `--control-default-border`, falling back to
126
+ `--surface` and `--border-control` like `.input`.
125
127
  It follows tokens, not native-control selectors: local `--control-bg` overrides
126
128
  and theme-specific invalid or disabled fills need matching widget state rules.
127
129
 
@@ -127,7 +127,9 @@ deletion once `::slider-fill` is interoperable — see
127
127
 
128
128
  ## CSS hooks
129
129
 
130
- - `--range-thumb-size` — thumb diameter.
130
+ - `--range-thumb-size` — thumb height, which is also the control's height.
131
+ - `--range-thumb-inline-size` — thumb width; follows `--range-thumb-size` (a round thumb) unless set.
132
+ - `--range-thumb-radius` — thumb corner; `0` with a narrower width makes a block thumb. The focus ring follows both.
131
133
  - `--range-track-height` — track thickness.
132
134
  - `--range-thumb-bg` — thumb color. Defaults to the local intent, then `--primary`.
133
135
  - `--range-track-bg` — track color.
@@ -590,6 +590,28 @@ connect function receives the element plus `{ config, signal, emit }`; `emit`
590
590
  dispatches `actual:<name>:<type>` events. Connect must be synchronous and may
591
591
  return a cleanup function or nothing; the loader owns the AbortController.
592
592
 
593
+ #### Without a build
594
+
595
+ The plain `<script src="actual.full.js">` bundle exposes no global, so a page
596
+ without a bundler cannot call `registerEnhancement()`. It does not need to: the
597
+ bundle watches manifests, so a page declares its own module and the runtime
598
+ imports and registers it, on the same lifecycle as the built-in behaviors.
599
+
600
+ ```html
601
+ <script type="application/json" data-enhance-modules>
602
+ { "autosubmit": "/js/autosubmit.js" }
603
+ </script>
604
+ <script src="/dist/actual.full.js" defer></script>
605
+
606
+ <form data-enhance="autosubmit">…</form>
607
+ ```
608
+
609
+ `/js/autosubmit.js` is an ES module with the default export shown above; no
610
+ import of Actual is needed. Serve the page over HTTP: browsers refuse module
611
+ imports from a page opened as `file://`, and the behavior silently never
612
+ connects. A behavior that owns its own attribute instead of a
613
+ `data-enhance` token can stay a classic script.
614
+
593
615
  `loadScript(url)` and `loadStyle(url)` are public helpers for non-ESM assets.
594
616
  Names are reserved once per manifest set — redeclaring a name from a different
595
617
  URL throws, and duplicate declarations share one import promise. The
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "actual-css",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "description": "Plain CSS component framework with semantic classes, universal variants, small tokens, theme hooks, and progressive enhancements.",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.4.4",
@@ -262,6 +262,7 @@
262
262
  "tight",
263
263
  "timeline",
264
264
  "timeline-dates-end",
265
+ "timeline-dates-start",
265
266
  "tooltip",
266
267
  "topbar",
267
268
  "touch-target",
@@ -104,6 +104,7 @@
104
104
 
105
105
  button.avatar {
106
106
  appearance: none;
107
+ -webkit-appearance: none;
107
108
  cursor: pointer;
108
109
  }
109
110
 
@@ -97,6 +97,9 @@
97
97
  .flyout[popover] {
98
98
  position: fixed;
99
99
  inset: auto;
100
+ /* why: the UA's height: fit-content made Safari 18 size this grid to its
101
+ max-block-size and spread the spare room between menu rows. */
102
+ block-size: auto;
100
103
  }
101
104
 
102
105
  /* A presentation class may own its *visible* display type, but must not
@@ -14,6 +14,7 @@
14
14
  * --meter-track
15
15
  * --meter-value
16
16
  * --bar-height
17
+ * --bar-radius
17
18
  */
18
19
 
19
20
  .meter {
@@ -26,7 +27,7 @@
26
27
  block-size: var(--bar-height);
27
28
  overflow: hidden;
28
29
  border: 0;
29
- border-radius: var(--radius-full);
30
+ border-radius: var(--bar-radius);
30
31
  background: var(--meter-track);
31
32
  }
32
33
 
@@ -53,31 +54,31 @@
53
54
  -webkit-appearance: none;
54
55
  block-size: var(--bar-height);
55
56
  border: 0;
56
- border-radius: var(--radius-full);
57
+ border-radius: var(--bar-radius);
57
58
  background: var(--meter-track);
58
59
  }
59
60
 
60
61
  .meter::-webkit-meter-optimum-value {
61
62
  block-size: var(--bar-height);
62
- border-radius: var(--radius-full);
63
+ border-radius: var(--bar-radius);
63
64
  background: var(--success);
64
65
  }
65
66
 
66
67
  .meter::-webkit-meter-suboptimum-value {
67
68
  block-size: var(--bar-height);
68
- border-radius: var(--radius-full);
69
+ border-radius: var(--bar-radius);
69
70
  background: var(--warning);
70
71
  }
71
72
 
72
73
  .meter::-webkit-meter-even-less-good-value {
73
74
  block-size: var(--bar-height);
74
- border-radius: var(--radius-full);
75
+ border-radius: var(--bar-radius);
75
76
  background: var(--danger);
76
77
  }
77
78
 
78
79
  .meter::-moz-meter-bar {
79
80
  block-size: var(--bar-height);
80
- border-radius: var(--radius-full);
81
+ border-radius: var(--bar-radius);
81
82
  }
82
83
 
83
84
  /* The background shorthand clears Gecko's native gradient. Keep state
@@ -14,6 +14,7 @@
14
14
  * --progress-track
15
15
  * --progress-value
16
16
  * --bar-height
17
+ * --bar-radius
17
18
  */
18
19
  /* Intent boundary — inherited intents do not tint this component.
19
20
  Local intent classes still win because :where() has zero specificity. */
@@ -32,25 +33,25 @@
32
33
  block-size: var(--bar-height);
33
34
  overflow: hidden;
34
35
  border: 0;
35
- border-radius: var(--radius-full);
36
+ border-radius: var(--bar-radius);
36
37
  background: var(--progress-track);
37
38
  }
38
39
 
39
40
  .progress::-webkit-progress-bar {
40
41
  block-size: var(--bar-height);
41
- border-radius: var(--radius-full);
42
+ border-radius: var(--bar-radius);
42
43
  background: var(--progress-track);
43
44
  }
44
45
 
45
46
  .progress::-webkit-progress-value {
46
47
  block-size: var(--bar-height);
47
- border-radius: var(--radius-full);
48
+ border-radius: var(--bar-radius);
48
49
  background: var(--progress-value);
49
50
  }
50
51
 
51
52
  .progress::-moz-progress-bar {
52
53
  block-size: var(--bar-height);
53
- border-radius: var(--radius-full);
54
+ border-radius: var(--bar-radius);
54
55
  background: var(--progress-value);
55
56
  }
56
57
 
@@ -67,6 +67,7 @@
67
67
 
68
68
  .rating > input[type="radio"] {
69
69
  appearance: none;
70
+ -webkit-appearance: none;
70
71
  flex: 0 0 auto;
71
72
  inline-size: calc(var(--rating-size) + var(--rating-gap));
72
73
  /* Taller than the star: the hit area grows, the drawing does not. */
@@ -212,6 +213,7 @@
212
213
  @media (forced-colors: active) {
213
214
  .rating > input[type="radio"] {
214
215
  appearance: auto;
216
+ -webkit-appearance: auto;
215
217
  inline-size: auto;
216
218
  block-size: auto;
217
219
  background: Canvas;
@@ -17,7 +17,8 @@
17
17
  * block flow, so a sentence mixing text and links is never split into items.
18
18
  *
19
19
  * .timeline-dates-end moves every dateline to the inline end of the event's
20
- * first line, beside the title instead of above it.
20
+ * first line, beside the title instead of above it. .timeline-dates-start sets
21
+ * them in a shared column before the rail.
21
22
  *
22
23
  * Progress through a process is .steps, not a timeline.
23
24
  *
@@ -174,6 +175,54 @@
174
175
  font-size: calc(var(--timeline-line-box) / var(--line-height));
175
176
  }
176
177
 
178
+ /* Dates at the start: the datelines form a column before the rail, as in a
179
+ log. The list owns three tracks (dateline, rail, event) and every event
180
+ takes them as a subgrid, so the column is as wide as its longest dateline
181
+ and every rail lines up. The marker, the segment and a slot stay absolutely
182
+ positioned: placed in the rail track, that track becomes their containing
183
+ block, and the offsets above hold unchanged.
184
+
185
+ Contract: after the <time>, every piece of the event is an element. A
186
+ grid makes each run of bare text an item of its own, which could land in
187
+ the dateline track.
188
+
189
+ Guarded: without subgrid these rules would leave each event a lone grid
190
+ that scatters its children; the fallback is the default dateline above
191
+ the title. */
192
+ @supports (grid-template-columns: subgrid) {
193
+ .timeline-dates-start {
194
+ grid-template-columns: max-content var(--timeline-rail-size) minmax(0, 1fr);
195
+ column-gap: var(--timeline-inline-gap);
196
+ }
197
+
198
+ .timeline-dates-start > li {
199
+ display: grid;
200
+ grid-column: 1 / -1;
201
+ grid-template-columns: subgrid;
202
+ /* The smaller dateline shares the title's baseline on the first row. */
203
+ align-items: first baseline;
204
+ padding-inline-start: 0;
205
+ }
206
+
207
+ .timeline-dates-start > li > * {
208
+ grid-column: 3;
209
+ }
210
+
211
+ /* Row 1, so the dateline sits beside the title rather than above it, and
212
+ end-aligned, so ragged datelines hug the rail. */
213
+ .timeline-dates-start > li > time {
214
+ grid-row: 1;
215
+ grid-column: 1;
216
+ text-align: end;
217
+ }
218
+
219
+ .timeline-dates-start > li::before,
220
+ .timeline-dates-start > li::after,
221
+ .timeline-dates-start > li > :is(.avatar, [aria-hidden="true"]):first-child {
222
+ grid-column: 2;
223
+ }
224
+ }
225
+
177
226
  .timeline > li::before {
178
227
  content: "";
179
228
  position: absolute;
@@ -106,6 +106,10 @@
106
106
  the same geometry. Public: set it on the element or on an application
107
107
  class rather than reaching for a size variant. */
108
108
  --bar-height: 0.65rem;
109
+ /* Their corner, track and value alike. The value is drawn on vendor
110
+ pseudo-elements a theme cannot reach in one rule, so this is the way to
111
+ square a bar. */
112
+ --bar-radius: var(--radius-full);
109
113
 
110
114
  /* Controls — inputs and buttons share --control-size so heights always match.
111
115
  .compact/.spacious (variants.css) switch geometry (--control-size,
@@ -218,7 +218,8 @@
218
218
  border: 0;
219
219
  border-radius: inherit;
220
220
  background: var(--text-subtle);
221
- transform: none;
221
+ /* No transform here: the card's scale(0) keeps the dot hidden beside a
222
+ visible native input until the :has() block above reveals it. */
222
223
  clip-path: circle(0.1875em at var(--choice-chip-dot));
223
224
  z-index: -1;
224
225
  transition: clip-path var(--duration);
@@ -71,6 +71,11 @@
71
71
  font-family: var(--font-mono);
72
72
  font-size: var(--otp-font-size);
73
73
  font-variant-numeric: tabular-nums;
74
+ /* why: one glyph per cell. A code font (JetBrains Mono, Fira Code) joins
75
+ `+++` or `->` through ligatures and contextual alternates; Chromium drops
76
+ them under letter-spacing, Safari keeps them and the glyphs leave their
77
+ cells. */
78
+ font-variant-ligatures: none;
74
79
  line-height: var(--otp-cell-size);
75
80
  letter-spacing: calc(var(--otp-cell-size) + var(--otp-gap) - 1ch);
76
81
  text-align: start;
@@ -9,7 +9,9 @@
9
9
  * are not reliably applied across browsers.
10
10
  *
11
11
  * Public hooks:
12
- * --range-thumb-size
12
+ * --range-thumb-size (the thumb's block size, and the control's)
13
+ * --range-thumb-inline-size
14
+ * --range-thumb-radius
13
15
  * --range-track-height
14
16
  * --range-thumb-bg
15
17
  * --range-track-bg
@@ -27,6 +29,10 @@
27
29
 
28
30
  .range {
29
31
  --range-thumb-size: 1.125rem;
32
+ /* The thumb's shape, on vendor pseudo-elements a theme cannot reach in one
33
+ rule. The focus ring is a box-shadow, so it follows both. */
34
+ --range-thumb-inline-size: var(--range-thumb-size);
35
+ --range-thumb-radius: var(--radius-full);
30
36
  --range-track-height: 0.625rem;
31
37
  --range-thumb-bg: var(--intent, var(--primary));
32
38
  --range-track-bg: var(--border);
@@ -84,9 +90,9 @@
84
90
  .range::-webkit-slider-thumb {
85
91
  appearance: none;
86
92
  -webkit-appearance: none;
87
- inline-size: var(--range-thumb-size);
93
+ inline-size: var(--range-thumb-inline-size);
88
94
  block-size: var(--range-thumb-size);
89
- border-radius: var(--radius-full);
95
+ border-radius: var(--range-thumb-radius);
90
96
  border: 0;
91
97
  background: var(--range-thumb-bg);
92
98
  margin-block-start: calc((var(--range-track-height) - var(--range-thumb-size)) / 2);
@@ -99,9 +105,9 @@
99
105
  }
100
106
 
101
107
  .range::-moz-range-thumb {
102
- inline-size: var(--range-thumb-size);
108
+ inline-size: var(--range-thumb-inline-size);
103
109
  block-size: var(--range-thumb-size);
104
- border-radius: var(--radius-full);
110
+ border-radius: var(--range-thumb-radius);
105
111
  border: 0;
106
112
  background: var(--range-thumb-bg);
107
113
  cursor: inherit;
@@ -52,6 +52,7 @@
52
52
  @media (forced-colors: active), (prefers-contrast: more) {
53
53
  .select:not(:is([multiple], [size]:not([size="1"]))) {
54
54
  appearance: auto;
55
+ -webkit-appearance: auto;
55
56
  background-image: none;
56
57
  padding-inline-end: var(--control-pad-x);
57
58
  }
package/src/js/dialog.js CHANGED
@@ -359,6 +359,7 @@ function showDialog(dialog, focusReturn, forcedModal) {
359
359
  const viewport = dialog.ownerDocument.defaultView;
360
360
  const scrollX = viewport?.scrollX ?? 0;
361
361
  const scrollY = viewport?.scrollY ?? 0;
362
+ const indicated = dialog.ownerDocument.activeElement?.matches(":focus-visible") === true;
362
363
 
363
364
  if (modal) {
364
365
  dialog.showModal();
@@ -367,6 +368,7 @@ function showDialog(dialog, focusReturn, forcedModal) {
367
368
  dialog.show();
368
369
  state.modalOpen = false;
369
370
  }
371
+ if (!indicated) quietInitialFocus(dialog);
370
372
 
371
373
  if (scrollX !== 0 || scrollY > 0) {
372
374
  viewport?.scrollTo(scrollX, scrollY);
@@ -375,6 +377,23 @@ function showDialog(dialog, focusReturn, forcedModal) {
375
377
  syncModalOpenClass(dialog.ownerDocument);
376
378
  }
377
379
 
380
+ /*
381
+ * WebKit shows the focus ring on the control showModal() focuses even when a
382
+ * tap or a click opened the dialog, so a Cancel button looked pressed on an
383
+ * iPad. Chromium and Firefox follow the opening's modality: the ring shows
384
+ * only when the element focused before it showed one. Refocusing with
385
+ * focusVisible: false brings WebKit in line; it needs the blur, since focusing
386
+ * the active element again is a no-op. Text fields keep their ring in every
387
+ * engine, whatever the modality.
388
+ */
389
+ function quietInitialFocus(dialog) {
390
+ const focused = dialog.ownerDocument.activeElement;
391
+ if (!focused || !dialog.contains(focused) || !focused.matches(":focus-visible")) return;
392
+ if (focused.matches("input, textarea, select, [contenteditable]")) return;
393
+ focused.blur();
394
+ focused.focus({ focusVisible: false, preventScroll: true });
395
+ }
396
+
378
397
  function handleDialogPointerDown(event) {
379
398
  const dialog = event.currentTarget;
380
399
  const state = dialogMap.get(dialog);
package/src/js/tooltip.js CHANGED
@@ -5,6 +5,7 @@
5
5
  * Explicit: <button data-tooltip aria-describedby="tooltip-id">
6
6
  * <div role="tooltip" id="tooltip-id" hidden>Help <strong>text</strong></div>
7
7
  * Options: data-tooltip-click toggles on click instead of hover/focus.
8
+ * data-tooltip-no-tap keeps a touch tap from opening it.
8
9
  * data-tooltip-visible keeps the tooltip visible.
9
10
  *
10
11
  * Discovery: [data-tooltip] only. An empty data-tooltip marks an explicit
@@ -33,6 +34,11 @@
33
34
  * visible. Focus counts only when it matches :focus-visible, so
34
35
  * a pointer press, or focus handed back by a closing dialog after
35
36
  * a pointer close, shows nothing.
37
+ * Touch: a tap shows the tip at once and pins it, so no tooltip is
38
+ * silently out of reach of a finger; the tap still activates the
39
+ * trigger. A second tap, a tap elsewhere, Escape, or a dialog or
40
+ * popover opening hides it. A scroll or drag ends in
41
+ * pointercancel, not pointerup, so it is never a tap.
36
42
  * Hide: focus leaving the trigger (focusout), pointer leave, pressing
37
43
  * the trigger, or Escape.
38
44
  *
@@ -76,12 +82,15 @@ const HIDE_DELAY_MS = 100;
76
82
  * @property {boolean} hovered Pointer is over the active trigger.
77
83
  * @property {boolean} focused The active trigger has keyboard focus.
78
84
  * @property {boolean} overTip Pointer is over the tooltip.
85
+ * @property {boolean} tapped A touch tap pinned the tip open.
79
86
  */
80
87
 
81
88
  let uid = 0;
82
89
  const triggerStates = new WeakMap(); // trigger -> { tip, cleanup }
83
90
  /** @type {WeakMap<Element, TooltipState>} */
84
91
  const tipStates = new WeakMap(); // tip -> { refs, activeRef, controller, stopTracking, generated, visible, timer }
92
+ /** @type {Element | null} The tip a tap pinned open; a tap elsewhere dismisses it. */
93
+ let tappedTip = null;
85
94
 
86
95
  /*
87
96
  * Transport, the same shape surface.js uses and for the same reason: the
@@ -157,6 +166,12 @@ function isClickTrigger(trigger) {
157
166
  return hasOption(trigger, "data-tooltip-click");
158
167
  }
159
168
 
169
+ // Taps open tooltips by default: the opt-out is explicit, so a tooltip never
170
+ // fails silently under a finger.
171
+ function isNoTapTrigger(trigger) {
172
+ return hasOption(trigger, "data-tooltip-no-tap");
173
+ }
174
+
160
175
  function isAlwaysVisible(trigger) {
161
176
  return hasOption(trigger, "data-tooltip-visible");
162
177
  }
@@ -290,7 +305,9 @@ function hideTip(tip, force = false) {
290
305
  if (state) {
291
306
  state.wanted = false;
292
307
  state.visible = false;
308
+ state.tapped = false;
293
309
  }
310
+ if (tappedTip === tip) tappedTip = null;
294
311
  hideTransport(tip);
295
312
  state?.unregisterEscape?.();
296
313
  if (state) {
@@ -311,11 +328,11 @@ function scheduleHide(tip) {
311
328
  const state = tipStates.get(tip);
312
329
  if (!state) return;
313
330
  if (isClickTrigger(state.activeRef) || isAlwaysVisible(state.activeRef)) return;
314
- if (state.hovered || state.focused || state.overTip) return;
331
+ if (state.hovered || state.focused || state.overTip || state.tapped) return;
315
332
  if (state.hideTimer) clearTimeout(state.hideTimer);
316
333
  state.hideTimer = setTimeout(() => {
317
334
  state.hideTimer = null;
318
- if (!state.hovered && !state.focused && !state.overTip) hideTip(tip);
335
+ if (!state.hovered && !state.focused && !state.overTip && !state.tapped) hideTip(tip);
319
336
  }, HIDE_DELAY_MS);
320
337
  }
321
338
 
@@ -344,6 +361,7 @@ function wireTip(tip, options = {}) {
344
361
  hovered: false,
345
362
  focused: false,
346
363
  overTip: false,
364
+ tapped: false,
347
365
  };
348
366
 
349
367
  tip.addEventListener(
@@ -511,6 +529,8 @@ function show(tip, ref, immediate = false) {
511
529
  const SEL = "[data-tooltip]";
512
530
  /** @type {WeakRef<Element> | null} */
513
531
  let pressedTrigger = null;
532
+ // The current press hid its trigger's tip: its release must not reopen it.
533
+ let pressDismissed = false;
514
534
 
515
535
  function handleTriggerIntent(e) {
516
536
  const trigger = e.target.closest?.(SEL);
@@ -542,6 +562,7 @@ function handleTriggerIntent(e) {
542
562
  function handleTriggerPress(e) {
543
563
  const trigger = e.target.closest?.(SEL);
544
564
  pressedTrigger = trigger ? new WeakRef(trigger) : null;
565
+ pressDismissed = false;
545
566
  if (!trigger || isClickTrigger(trigger) || isAlwaysVisible(trigger)) return;
546
567
 
547
568
  const tip = triggerStates.get(trigger)?.tip;
@@ -554,6 +575,34 @@ function handleTriggerPress(e) {
554
575
  state.focused = false;
555
576
  state.overTip = false;
556
577
  hideTip(tip, true);
578
+ pressDismissed = true;
579
+ }
580
+
581
+ /*
582
+ * Touch has no hover, and a tap focuses without :focus-visible, so a finger
583
+ * reaches a tooltip only through this. Touch pointers are
584
+ * implicitly captured, so the release targets the element the press landed on.
585
+ * The outside dismissal runs for any pointer, so a hybrid device can close a
586
+ * pinned tip with the mouse too; it never stops the event.
587
+ */
588
+ function handleTap(e) {
589
+ const target = /** @type {Element} */ (e.target);
590
+ if (tappedTip && !tappedTip.contains(target)) {
591
+ const ref = tipStates.get(tappedTip)?.activeRef;
592
+ if (!ref?.contains(target)) hideTip(tappedTip, true);
593
+ }
594
+
595
+ if (e.pointerType !== "touch") return;
596
+ const trigger = target.closest?.(SEL);
597
+ if (!trigger || pressDismissed || pressedTrigger?.deref() !== trigger) return;
598
+ if (isNoTapTrigger(trigger) || isClickTrigger(trigger) || isAlwaysVisible(trigger)) return;
599
+
600
+ const tip = ensureTip(trigger);
601
+ if (!tip) return;
602
+ const state = tipStates.get(tip);
603
+ state.tapped = true;
604
+ tappedTip = tip;
605
+ show(tip, trigger, true);
557
606
  }
558
607
 
559
608
  function handleTriggerClick(e) {
@@ -574,6 +623,19 @@ if (typeof document !== "undefined") {
574
623
  document.addEventListener("focusin", handleTriggerIntent);
575
624
  // A drag handler can stop the press before it bubbles to the document.
576
625
  document.addEventListener("pointerdown", handleTriggerPress, { capture: true });
626
+ document.addEventListener("pointerup", handleTap, { capture: true });
627
+ // A tap that opens a dialog or a popover moved on from its trigger: the
628
+ // pinned label would linger under the new layer. toggle does not bubble.
629
+ document.addEventListener(
630
+ "toggle",
631
+ (e) => {
632
+ const opened = /** @type {ToggleEvent} */ (e).newState === "open";
633
+ if (opened && tappedTip && !e.target.matches?.('[role="tooltip"]')) {
634
+ hideTip(tappedTip, true);
635
+ }
636
+ },
637
+ { capture: true },
638
+ );
577
639
  document.addEventListener(
578
640
  "keydown",
579
641
  () => {
@@ -77,7 +77,7 @@ export const FOUNDATIONS = {
77
77
  "control-pad-x-lg",
78
78
  "control-pad-x",
79
79
  ],
80
- radius: ["radius-sm", "radius", "radius-lg", "radius-full"],
80
+ radius: ["radius-sm", "radius", "radius-lg", "radius-full", "bar-radius"],
81
81
  "border-width": ["border-width", "focus-ring-width"],
82
82
  "font-size": [
83
83
  "font-size-xs",