actual-css 0.20.1 → 0.21.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +6 -6
  3. package/components.json +29 -7
  4. package/dist/actual.full.css +542 -135
  5. package/dist/actual.full.js +2 -2
  6. package/dist/actual.full.min.css +1 -1
  7. package/dist/types/data-flag.d.ts +1 -0
  8. package/dist/types/enhancement-loader-state.d.ts +6 -0
  9. package/dist/types/enhancement-loader.d.ts +0 -2
  10. package/dist/types/parse-config.d.ts +0 -1
  11. package/dist/types/popover-transport.d.ts +2 -0
  12. package/dist/types/status.d.ts +0 -1
  13. package/dist/types/tooltip.d.ts +4 -0
  14. package/dist/types/validation.d.ts +6 -2
  15. package/docs/pages/components/app-navigation.md +67 -0
  16. package/docs/pages/components/button.md +3 -0
  17. package/docs/pages/components/dialog.md +3 -0
  18. package/docs/pages/components/list.md +13 -0
  19. package/docs/pages/components/meter.md +1 -0
  20. package/docs/pages/components/progress.md +1 -0
  21. package/docs/pages/components/segmented.md +7 -4
  22. package/docs/pages/components/table.md +4 -1
  23. package/docs/pages/components/timeline.md +32 -0
  24. package/docs/pages/enhancements/flyout.md +12 -3
  25. package/docs/pages/enhancements/tooltip.md +6 -1
  26. package/docs/pages/examples/overview.md +30 -1
  27. package/docs/pages/forms/combobox.md +14 -10
  28. package/docs/pages/forms/labels.md +7 -0
  29. package/docs/pages/forms/overview.md +13 -10
  30. package/docs/pages/forms/range.md +3 -1
  31. package/docs/pages/forms/validation.md +3 -3
  32. package/docs/pages/foundations/philosophy.md +26 -0
  33. package/docs/pages/foundations/theming.md +80 -7
  34. package/docs/pages/foundations/tokens.md +39 -2
  35. package/docs/pages/guides/coding-agents.md +11 -0
  36. package/docs/pages/guides/introduction.md +1 -1
  37. package/docs/pages/guides/progressive-enhancement.md +109 -19
  38. package/docs/pages/guides/tailwind.md +12 -6
  39. package/docs/pages/guides/upgrading.md +52 -0
  40. package/docs/pages/layout/app-layout.md +50 -1
  41. package/docs/pages/patterns/empty-state.md +48 -10
  42. package/forms.json +325 -0
  43. package/llms.txt +2 -1
  44. package/package.json +3 -1
  45. package/reserved-classes.json +2 -0
  46. package/skills/actual-css/SKILL.md +1 -1
  47. package/skills/actual-css/references/api-and-vocabulary.md +2 -1
  48. package/src/cli/actual-css.js +8 -2
  49. package/src/css/components/app-nav.css +75 -18
  50. package/src/css/components/avatar.css +1 -0
  51. package/src/css/components/badge.css +7 -1
  52. package/src/css/components/button.css +20 -3
  53. package/src/css/components/flyout.css +8 -2
  54. package/src/css/components/list.css +28 -13
  55. package/src/css/components/menu.css +18 -0
  56. package/src/css/components/meter.css +11 -6
  57. package/src/css/components/progress.css +14 -6
  58. package/src/css/components/rating.css +2 -0
  59. package/src/css/components/segmented.css +22 -12
  60. package/src/css/components/table.css +21 -2
  61. package/src/css/components/timeline.css +50 -1
  62. package/src/css/core/theme.css +11 -1
  63. package/src/css/core/tokens.css +20 -2
  64. package/src/css/forms/choice-card.css +6 -4
  65. package/src/css/forms/choice.css +28 -16
  66. package/src/css/forms/control.css +23 -16
  67. package/src/css/forms/custom-select.css +3 -1
  68. package/src/css/forms/form.css +8 -5
  69. package/src/css/forms/otp.css +7 -1
  70. package/src/css/forms/range.css +31 -11
  71. package/src/css/forms/select.css +13 -4
  72. package/src/css/forms/switch.css +11 -5
  73. package/src/css/layout/app-layout.css +104 -5
  74. package/src/js/data-flag.js +4 -0
  75. package/src/js/dialog.js +24 -8
  76. package/src/js/enhancement-loader-state.js +7 -0
  77. package/src/js/enhancement-loader.js +4 -21
  78. package/src/js/keys.js +5 -7
  79. package/src/js/parse-config.js +0 -2
  80. package/src/js/popover-transport.js +18 -0
  81. package/src/js/status.js +0 -2
  82. package/src/js/surface.js +35 -41
  83. package/src/js/tooltip.js +70 -36
  84. package/src/js/validation.js +24 -10
  85. package/src/tooling/css-bundle.js +5 -0
  86. package/src/tooling/design-tokens.js +9 -2
  87. package/src/tooling/theme-contrast.js +45 -17
  88. package/tokens.json +5 -0
@@ -16,22 +16,15 @@
16
16
  * One map keyed by name reserves the slot immediately, so concurrent calls
17
17
  * for the same name share one promise. The browser's native module cache
18
18
  * handles URL dedup. Script/style helpers fill the gap for non-ESM assets.
19
- *
20
- * Exports prefixed with `__` are test hooks and are not part of the
21
- * supported public API or SemVer contract.
22
19
  */
23
20
 
24
21
  import enhance, { registerEnhancement } from "./enhance.js";
22
+ import { loaderState } from "./enhancement-loader-state.js";
25
23
  import { parseConfig } from "./parse-config.js";
26
24
 
27
25
  const MANIFEST_SELECTOR = 'script[type="application/json"][data-enhance-modules]';
28
26
 
29
- const enhancements = new Map();
30
-
31
- const scriptLoads = new Map();
32
- const styleLoads = new Map();
33
-
34
- let moduleImporter = (url) => import(url);
27
+ const { enhancements, scriptLoads, styleLoads } = loaderState;
35
28
 
36
29
  function loadAsset(url, loads, kind) {
37
30
  const absoluteUrl = new URL(url, document.baseURI).href;
@@ -141,7 +134,8 @@ export function loadEnhancement(name, url) {
141
134
  return existing.promise.then(() => ({ name, status: "skipped" }));
142
135
  }
143
136
 
144
- const promise = moduleImporter(absoluteUrl)
137
+ const promise = loaderState
138
+ .importModule(absoluteUrl)
145
139
  .then(async (mod) => {
146
140
  if (typeof mod.default !== "function") {
147
141
  throw new TypeError(`Enhancement "${name}" must export a default function.`);
@@ -285,14 +279,3 @@ export async function loadResponse(response) {
285
279
 
286
280
  return loadManifest(Object.entries(manifest));
287
281
  }
288
-
289
- export function __setModuleImporter(fn) {
290
- moduleImporter = fn;
291
- }
292
-
293
- export function __reset() {
294
- enhancements.clear();
295
- scriptLoads.clear();
296
- styleLoads.clear();
297
- moduleImporter = (url) => import(url);
298
- }
package/src/js/keys.js CHANGED
@@ -30,14 +30,13 @@ export function lastItem(items) {
30
30
  export function nextItem(items, current, delta, opts = {}) {
31
31
  if (!items.length) return null;
32
32
 
33
- const wrap = opts.wrap !== false;
34
33
  const idx = items.indexOf(current);
35
34
  if (idx === -1) {
36
35
  return delta > 0 ? firstItem(items) : lastItem(items);
37
36
  }
38
37
 
39
38
  const next = idx + delta;
40
- if (!wrap) return items[next] || null;
39
+ if (opts.wrap !== true) return items[next] || null;
41
40
 
42
41
  const wrapped = ((next % items.length) + items.length) % items.length;
43
42
  return items[wrapped];
@@ -45,7 +44,6 @@ export function nextItem(items, current, delta, opts = {}) {
45
44
 
46
45
  export function itemForKey(items, current, key, opts = {}) {
47
46
  const orientation = opts.orientation || "horizontal";
48
- const wrap = opts.wrap === true;
49
47
  const direction = opts.direction || "ltr";
50
48
 
51
49
  switch (key) {
@@ -55,16 +53,16 @@ export function itemForKey(items, current, key, opts = {}) {
55
53
  return lastItem(items);
56
54
  case "ArrowRight":
57
55
  if (orientation !== "horizontal") return null;
58
- return nextItem(items, current, direction === "rtl" ? -1 : 1, { wrap });
56
+ return nextItem(items, current, direction === "rtl" ? -1 : 1, opts);
59
57
  case "ArrowLeft":
60
58
  if (orientation !== "horizontal") return null;
61
- return nextItem(items, current, direction === "rtl" ? 1 : -1, { wrap });
59
+ return nextItem(items, current, direction === "rtl" ? 1 : -1, opts);
62
60
  case "ArrowDown":
63
61
  if (orientation !== "vertical") return null;
64
- return nextItem(items, current, 1, { wrap });
62
+ return nextItem(items, current, 1, opts);
65
63
  case "ArrowUp":
66
64
  if (orientation !== "vertical") return null;
67
- return nextItem(items, current, -1, { wrap });
65
+ return nextItem(items, current, -1, opts);
68
66
  default:
69
67
  return null;
70
68
  }
@@ -46,5 +46,3 @@ export function parseConfig(source) {
46
46
 
47
47
  return value;
48
48
  }
49
-
50
- export default parseConfig;
@@ -0,0 +1,18 @@
1
+ // A popover can become detached before the native call. Let the caller handle
2
+ // a failed show and allow its own teardown to finish after a failed hide.
3
+ export function showPopover(element) {
4
+ try {
5
+ element.showPopover();
6
+ return true;
7
+ } catch {
8
+ return false;
9
+ }
10
+ }
11
+
12
+ export function hidePopover(element) {
13
+ try {
14
+ element.hidePopover();
15
+ } catch {
16
+ /* Already closed or detached; nothing left to hide. */
17
+ }
18
+ }
package/src/js/status.js CHANGED
@@ -346,5 +346,3 @@ if (typeof document !== "undefined") {
346
346
  },
347
347
  });
348
348
  }
349
-
350
- export default status;
package/src/js/surface.js CHANGED
@@ -3,7 +3,7 @@ import enhance from "./enhance.js";
3
3
  import { registerEscapeDismissal } from "./escape.js";
4
4
  import { EVENTS } from "./events.js";
5
5
  import { positionModeFor } from "./floating-space.js";
6
-
6
+ import { hidePopover, showPopover } from "./popover-transport.js";
7
7
  import { CLASSES } from "./selectors.js";
8
8
  import { surfaceFocusReturns } from "./surface-focus.js";
9
9
 
@@ -44,36 +44,6 @@ function reaperFor(menu) {
44
44
  return reaper;
45
45
  }
46
46
 
47
- /*
48
- * Transport: the top layer, via popover="manual".
49
- *
50
- * The runtime owns the whole lifecycle, so "manual" is the only usable mode —
51
- * it supplies promotion to the top layer and nothing else, leaving the
52
- * dismissal policy, Escape ordering and focus restoration below untouched.
53
- *
54
- * The attribute is set by the runtime, not asked of the author: a surface is
55
- * still marked up exactly as before. showPopover/hidePopover throw on an
56
- * out-of-order call (already open, not connected), which is a state Actual's
57
- * own guards should already have excluded — the try/catch is there so a
58
- * surprising DOM does not take the lifecycle down with it.
59
- */
60
- function showTransport(menu) {
61
- try {
62
- menu.showPopover();
63
- return true;
64
- } catch {
65
- return false;
66
- }
67
- }
68
-
69
- function hideTransport(menu) {
70
- try {
71
- menu.hidePopover();
72
- } catch {
73
- /* Already closed or detached; nothing left to hide. */
74
- }
75
- }
76
-
77
47
  /*
78
48
  * Trigger state sync stays Actual's job, deliberately.
79
49
  *
@@ -136,6 +106,7 @@ function ensureSurfaceWired(menu) {
136
106
  ensureDocumentClick(menu);
137
107
  const state = {
138
108
  stopTracking: null,
109
+ stopWatchingMove: null,
139
110
  stopScrollIntent: null,
140
111
  unregisterEscape: null,
141
112
  trigger: null,
@@ -220,6 +191,21 @@ function startSurfaceResources(menu, state) {
220
191
  if (type === "scroll" && state.dismissOnScroll) return;
221
192
  if (!positionSurface(menu)) closeSurface(menu);
222
193
  });
194
+
195
+ if (menu.matches(":popover-open")) {
196
+ // Moving a popover can close it without a toggle event. The reaper
197
+ // handles detachment, while this check follows the active opening.
198
+ const observer = new MutationObserver((records) => {
199
+ const moved = records.some(({ removedNodes }) =>
200
+ Array.from(removedNodes).some((node) => node.contains(menu)),
201
+ );
202
+ if (moved && menu.isConnected && !menu.matches(":popover-open")) {
203
+ closeSurface(menu, { restoreFocus: false });
204
+ }
205
+ });
206
+ observer.observe(menu.ownerDocument, { childList: true, subtree: true });
207
+ state.stopWatchingMove = () => observer.disconnect();
208
+ }
223
209
  }
224
210
 
225
211
  export function isSurfaceOpen(menu) {
@@ -230,7 +216,7 @@ export function isSurfaceOpen(menu) {
230
216
  }
231
217
 
232
218
  export function prepareSurface(menu) {
233
- if (!menu) return;
219
+ if (!menu || isSurfaceOpen(menu)) return;
234
220
  menu.style.position = "fixed";
235
221
  // A closed popover is hidden by the platform, so [hidden] is no longer the
236
222
  // closed state. Any left over from author markup would outrank it.
@@ -312,7 +298,7 @@ export function openSurface(menu, opts = {}) {
312
298
  // again, and that close must observe the open state to tear down.
313
299
  openSurfaces.add(menu);
314
300
  // Promote before measuring: a closed popover has no box to position.
315
- if (!showTransport(menu)) {
301
+ if (!showPopover(menu)) {
316
302
  openSurfaces.delete(menu);
317
303
  surfaceFocusReturns.delete(menu);
318
304
  return false;
@@ -365,12 +351,14 @@ export function closeSurface(menu, opts = {}) {
365
351
  const shouldRestoreFocus = opts.restoreFocus ?? menu.contains(activeElement);
366
352
  const restoreFocusTo = surfaceFocusReturns.get(menu);
367
353
  menu.classList.remove(CLASSES.open);
368
- hideTransport(menu);
354
+ hidePopover(menu);
369
355
  openSurfaces.delete(menu);
370
356
  syncExpanded(menu, false);
371
357
  state?.unregisterEscape?.();
372
358
  state?.stopScrollIntent?.();
373
359
  state?.stopTracking?.();
360
+ state?.stopWatchingMove?.();
361
+ if (state) state.stopWatchingMove = null;
374
362
 
375
363
  if (shouldRestoreFocus && restoreFocusTo?.isConnected) {
376
364
  restoreFocusTo.focus({ preventScroll: true });
@@ -399,6 +387,16 @@ function isKeyboardRadioMove(e) {
399
387
  return e.detail === 0 && e.target?.matches?.('input[type="radio"]') === true;
400
388
  }
401
389
 
390
+ /* A click on a field, or on its label, starts an edit, not a pick: closing on
391
+ it shut an account menu on the click that opened its theme select. A
392
+ checkbox or radio is still a pick (a palette closes on its color). */
393
+ const FIELD =
394
+ 'select,textarea,input:not([type="button"],[type="submit"],[type="reset"],[type="image"],[type="checkbox"],[type="radio"])';
395
+
396
+ function isFieldEdit(node) {
397
+ return node instanceof Element && (node.matches(FIELD) || !!node.control?.matches(FIELD));
398
+ }
399
+
402
400
  function onDocumentClick(e) {
403
401
  const path = e.composedPath();
404
402
  const radioMove = isKeyboardRadioMove(e);
@@ -411,16 +409,12 @@ function onDocumentClick(e) {
411
409
  const menuIndex = path.indexOf(menu);
412
410
  const isInside = menuIndex >= 0;
413
411
  if (isInside && radioMove) continue;
414
- const hasCloseTrigger =
415
- isInside &&
416
- path
417
- .slice(0, menuIndex)
418
- .some((node) => node instanceof Element && node.hasAttribute("data-flyout-close"));
419
-
420
- if (hasCloseTrigger) {
412
+ const inner = isInside ? path.slice(0, menuIndex) : [];
413
+ if (inner.some((node) => node instanceof Element && node.hasAttribute("data-flyout-close"))) {
421
414
  closeSurface(menu);
422
415
  continue;
423
416
  }
417
+ if (inner.some(isFieldEdit)) continue;
424
418
 
425
419
  const closesInside = state.autoClose === "true" || state.autoClose === "inside";
426
420
  const closesOutside = state.autoClose === "true" || state.autoClose === "outside";
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
  *
@@ -50,9 +56,11 @@
50
56
  */
51
57
 
52
58
  import { autoUpdate, reposition } from "@lekoala/floating";
59
+ import { readDataFlag } from "./data-flag.js";
53
60
  import enhance from "./enhance.js";
54
61
  import { registerEscapeDismissal } from "./escape.js";
55
62
  import { positionModeFor, readPlacement } from "./floating-space.js";
63
+ import { hidePopover, showPopover } from "./popover-transport.js";
56
64
  import { CLASSES } from "./selectors.js";
57
65
 
58
66
  const SHOW_DELAY_MS = 150;
@@ -76,37 +84,15 @@ const HIDE_DELAY_MS = 100;
76
84
  * @property {boolean} hovered Pointer is over the active trigger.
77
85
  * @property {boolean} focused The active trigger has keyboard focus.
78
86
  * @property {boolean} overTip Pointer is over the tooltip.
87
+ * @property {boolean} tapped A touch tap pinned the tip open.
79
88
  */
80
89
 
81
90
  let uid = 0;
82
91
  const triggerStates = new WeakMap(); // trigger -> { tip, cleanup }
83
92
  /** @type {WeakMap<Element, TooltipState>} */
84
93
  const tipStates = new WeakMap(); // tip -> { refs, activeRef, controller, stopTracking, generated, visible, timer }
85
-
86
- /*
87
- * Transport, the same shape surface.js uses and for the same reason: the
88
- * platform promotes the tip to the top layer and does nothing else, leaving
89
- * the hover/focus/click policy, the show delays and the Escape ordering here
90
- * untouched. showPopover/hidePopover throw on an out-of-order call, which the
91
- * state below should already have excluded — the try/catch is there so a
92
- * surprising DOM does not take the lifecycle down with it.
93
- */
94
- function showTransport(tip) {
95
- try {
96
- tip.showPopover();
97
- return true;
98
- } catch {
99
- return false;
100
- }
101
- }
102
-
103
- function hideTransport(tip) {
104
- try {
105
- tip.hidePopover();
106
- } catch {
107
- /* Already closed or detached; nothing left to hide. */
108
- }
109
- }
94
+ /** @type {Element | null} The tip a tap pinned open; a tap elsewhere dismisses it. */
95
+ let tappedTip = null;
110
96
 
111
97
  /*
112
98
  * [hidden] stops being the runtime's state here and goes back to what the
@@ -148,17 +134,18 @@ function placementFor(ref) {
148
134
  return readPlacement(ref, "data-tooltip-placement") ?? "top";
149
135
  }
150
136
 
151
- function hasOption(trigger, name) {
152
- const value = trigger?.getAttribute(name);
153
- return value !== null && value.toLowerCase() !== "false";
137
+ function isClickTrigger(trigger) {
138
+ return readDataFlag(trigger, "data-tooltip-click");
154
139
  }
155
140
 
156
- function isClickTrigger(trigger) {
157
- return hasOption(trigger, "data-tooltip-click");
141
+ // Taps open tooltips by default: the opt-out is explicit, so a tooltip never
142
+ // fails silently under a finger.
143
+ function isNoTapTrigger(trigger) {
144
+ return readDataFlag(trigger, "data-tooltip-no-tap");
158
145
  }
159
146
 
160
147
  function isAlwaysVisible(trigger) {
161
- return hasOption(trigger, "data-tooltip-visible");
148
+ return readDataFlag(trigger, "data-tooltip-visible");
162
149
  }
163
150
 
164
151
  function describedByIds(trigger) {
@@ -228,13 +215,13 @@ function updateTrackedTip(tip, state) {
228
215
  if (!ref || !state.wanted) return;
229
216
 
230
217
  if (!state.visible) {
231
- if (!showTransport(tip)) return;
218
+ if (!showPopover(tip)) return;
232
219
  state.visible = true;
233
220
  }
234
221
 
235
222
  if (!repositionTip(ref, tip, state.space)) {
236
223
  state.visible = false;
237
- hideTransport(tip);
224
+ hidePopover(tip);
238
225
  }
239
226
  syncEscapeDismissal(tip, state);
240
227
  }
@@ -290,8 +277,10 @@ function hideTip(tip, force = false) {
290
277
  if (state) {
291
278
  state.wanted = false;
292
279
  state.visible = false;
280
+ state.tapped = false;
293
281
  }
294
- hideTransport(tip);
282
+ if (tappedTip === tip) tappedTip = null;
283
+ hidePopover(tip);
295
284
  state?.unregisterEscape?.();
296
285
  if (state) {
297
286
  state.unregisterEscape = null;
@@ -311,11 +300,11 @@ function scheduleHide(tip) {
311
300
  const state = tipStates.get(tip);
312
301
  if (!state) return;
313
302
  if (isClickTrigger(state.activeRef) || isAlwaysVisible(state.activeRef)) return;
314
- if (state.hovered || state.focused || state.overTip) return;
303
+ if (state.hovered || state.focused || state.overTip || state.tapped) return;
315
304
  if (state.hideTimer) clearTimeout(state.hideTimer);
316
305
  state.hideTimer = setTimeout(() => {
317
306
  state.hideTimer = null;
318
- if (!state.hovered && !state.focused && !state.overTip) hideTip(tip);
307
+ if (!state.hovered && !state.focused && !state.overTip && !state.tapped) hideTip(tip);
319
308
  }, HIDE_DELAY_MS);
320
309
  }
321
310
 
@@ -344,6 +333,7 @@ function wireTip(tip, options = {}) {
344
333
  hovered: false,
345
334
  focused: false,
346
335
  overTip: false,
336
+ tapped: false,
347
337
  };
348
338
 
349
339
  tip.addEventListener(
@@ -511,6 +501,8 @@ function show(tip, ref, immediate = false) {
511
501
  const SEL = "[data-tooltip]";
512
502
  /** @type {WeakRef<Element> | null} */
513
503
  let pressedTrigger = null;
504
+ // The current press hid its trigger's tip: its release must not reopen it.
505
+ let pressDismissed = false;
514
506
 
515
507
  function handleTriggerIntent(e) {
516
508
  const trigger = e.target.closest?.(SEL);
@@ -542,6 +534,7 @@ function handleTriggerIntent(e) {
542
534
  function handleTriggerPress(e) {
543
535
  const trigger = e.target.closest?.(SEL);
544
536
  pressedTrigger = trigger ? new WeakRef(trigger) : null;
537
+ pressDismissed = false;
545
538
  if (!trigger || isClickTrigger(trigger) || isAlwaysVisible(trigger)) return;
546
539
 
547
540
  const tip = triggerStates.get(trigger)?.tip;
@@ -554,6 +547,34 @@ function handleTriggerPress(e) {
554
547
  state.focused = false;
555
548
  state.overTip = false;
556
549
  hideTip(tip, true);
550
+ pressDismissed = true;
551
+ }
552
+
553
+ /*
554
+ * Touch has no hover, and a tap focuses without :focus-visible, so a finger
555
+ * reaches a tooltip only through this. Touch pointers are
556
+ * implicitly captured, so the release targets the element the press landed on.
557
+ * The outside dismissal runs for any pointer, so a hybrid device can close a
558
+ * pinned tip with the mouse too; it never stops the event.
559
+ */
560
+ function handleTap(e) {
561
+ const target = /** @type {Element} */ (e.target);
562
+ if (tappedTip && !tappedTip.contains(target)) {
563
+ const ref = tipStates.get(tappedTip)?.activeRef;
564
+ if (!ref?.contains(target)) hideTip(tappedTip, true);
565
+ }
566
+
567
+ if (e.pointerType !== "touch") return;
568
+ const trigger = target.closest?.(SEL);
569
+ if (!trigger || pressDismissed || pressedTrigger?.deref() !== trigger) return;
570
+ if (isNoTapTrigger(trigger) || isClickTrigger(trigger) || isAlwaysVisible(trigger)) return;
571
+
572
+ const tip = ensureTip(trigger);
573
+ if (!tip) return;
574
+ const state = tipStates.get(tip);
575
+ state.tapped = true;
576
+ tappedTip = tip;
577
+ show(tip, trigger, true);
557
578
  }
558
579
 
559
580
  function handleTriggerClick(e) {
@@ -574,6 +595,19 @@ if (typeof document !== "undefined") {
574
595
  document.addEventListener("focusin", handleTriggerIntent);
575
596
  // A drag handler can stop the press before it bubbles to the document.
576
597
  document.addEventListener("pointerdown", handleTriggerPress, { capture: true });
598
+ document.addEventListener("pointerup", handleTap, { capture: true });
599
+ // A tap that opens a dialog or a popover moved on from its trigger: the
600
+ // pinned label would linger under the new layer. toggle does not bubble.
601
+ document.addEventListener(
602
+ "toggle",
603
+ (e) => {
604
+ const opened = /** @type {ToggleEvent} */ (e).newState === "open";
605
+ if (opened && tappedTip && !e.target.matches?.('[role="tooltip"]')) {
606
+ hideTip(tappedTip, true);
607
+ }
608
+ },
609
+ { capture: true },
610
+ );
577
611
  document.addEventListener(
578
612
  "keydown",
579
613
  () => {
@@ -37,20 +37,31 @@ function validDateParts(year, month, day) {
37
37
  return day <= days;
38
38
  }
39
39
 
40
- function isValidDate(value) {
40
+ function isValidDate(value, format) {
41
41
  const v = value.trim();
42
42
  const iso = /^(\d{4})-(\d{2})-(\d{2})$/.exec(v);
43
43
  if (iso) {
44
- return validDateParts(Number(iso[1]), Number(iso[2]), Number(iso[3]));
44
+ return (
45
+ (format === undefined || format === "yyyy-mm-dd") &&
46
+ validDateParts(Number(iso[1]), Number(iso[2]), Number(iso[3]))
47
+ );
45
48
  }
46
49
 
47
50
  const local = /^(\d{1,2})([/.-])(\d{1,2})\2(\d{4})$/.exec(v);
48
51
  if (!local) return false;
49
52
 
50
- const first = Number(local[1]);
51
- const second = Number(local[3]);
52
- const year = Number(local[4]);
53
- return validDateParts(year, second, first) || validDateParts(year, first, second);
53
+ const [, firstPart, separator, secondPart, yearPart] = local;
54
+ if (format !== undefined && (firstPart.length !== 2 || secondPart.length !== 2)) return false;
55
+
56
+ const dayFirst = format === undefined || format === `dd${separator}mm${separator}yyyy`;
57
+ const monthFirst = format === undefined || format === `mm${separator}dd${separator}yyyy`;
58
+ const first = Number(firstPart);
59
+ const second = Number(secondPart);
60
+ const year = Number(yearPart);
61
+ return (
62
+ (dayFirst && validDateParts(year, second, first)) ||
63
+ (monthFirst && validDateParts(year, first, second))
64
+ );
54
65
  }
55
66
 
56
67
  function warnUnknownRuleOnce(el, name) {
@@ -98,8 +109,13 @@ const rules = {
98
109
  const value = v.trim();
99
110
  return suffixes.length > 0 && suffixes.some((suffix) => value.endsWith(suffix));
100
111
  },
101
- date(v) {
102
- return isValidDate(v);
112
+ /**
113
+ * @param {string} v
114
+ * @param {Element | null} [_el]
115
+ * @param {string} [format]
116
+ */
117
+ date(v, _el, format) {
118
+ return isValidDate(v, format);
103
119
  },
104
120
  // Telephone origin policy, not telephone validation. A local number carries
105
121
  // nothing but its digits after the usual separators are ignored, so a value
@@ -441,5 +457,3 @@ export class FormValidator {
441
457
  // refreshes it like the other token behaviors. The token only means
442
458
  // something on a form.
443
459
  registerEnhancement("validation", (el) => (isFormElement(el) ? connectForm(el) : undefined));
444
-
445
- export default FormValidator;
@@ -2,6 +2,11 @@
2
2
  * Shared CSS bundling helpers: inline @import chains, strip comments, minify.
3
3
  * Used by build-dist.js (package artifacts), build-themes.js (demo asset),
4
4
  * and the public CLI.
5
+ *
6
+ * This is intentionally a pass-through flattener: no CSS parser or printer, so
7
+ * modern syntax and authored fallback ladders survive verbatim. The evaluated
8
+ * alternative (Bun's CSS bundler, `target: "bun"` only) still rewrites values;
9
+ * see docs/design-notes/css-bundling.md before replacing this path.
5
10
  */
6
11
  import { existsSync } from "node:fs";
7
12
  import { readFile } from "node:fs/promises";
@@ -45,6 +45,7 @@ export const THEME_COLORS = [
45
45
  "border",
46
46
  "border-control",
47
47
  "control-default-bg",
48
+ "control-default-border",
48
49
  "focus",
49
50
  "hover-overlay",
50
51
  "hover-overlay-solid",
@@ -77,7 +78,7 @@ export const FOUNDATIONS = {
77
78
  "control-pad-x-lg",
78
79
  "control-pad-x",
79
80
  ],
80
- radius: ["radius-sm", "radius", "radius-lg", "radius-full"],
81
+ radius: ["radius-sm", "radius", "radius-lg", "radius-full", "bar-radius"],
81
82
  "border-width": ["border-width", "focus-ring-width"],
82
83
  "font-size": [
83
84
  "font-size-xs",
@@ -123,7 +124,13 @@ export const NOT_EXPORTED = {
123
124
  "icon-close",
124
125
  "icon-plus",
125
126
  ],
126
- "composite DTCG types the export does not build yet": ["shadow", "shadow-popout"],
127
+ "composite DTCG types the export does not build yet": [
128
+ "shadow",
129
+ "shadow-popout",
130
+ "shadow-control",
131
+ "shadow-inset",
132
+ "finish",
133
+ ],
127
134
  "input of a derived value": [
128
135
  "backdrop-color",
129
136
  "backdrop-opacity",