actual-css 0.20.2 → 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 (80) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +6 -6
  3. package/components.json +19 -4
  4. package/dist/actual.full.css +451 -118
  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/validation.d.ts +6 -2
  14. package/docs/pages/components/app-navigation.md +67 -0
  15. package/docs/pages/components/button.md +3 -0
  16. package/docs/pages/components/dialog.md +3 -0
  17. package/docs/pages/components/list.md +13 -0
  18. package/docs/pages/components/segmented.md +7 -4
  19. package/docs/pages/components/table.md +4 -1
  20. package/docs/pages/enhancements/flyout.md +12 -3
  21. package/docs/pages/enhancements/tooltip.md +1 -0
  22. package/docs/pages/examples/overview.md +29 -1
  23. package/docs/pages/forms/combobox.md +10 -8
  24. package/docs/pages/forms/labels.md +7 -0
  25. package/docs/pages/forms/overview.md +13 -10
  26. package/docs/pages/forms/validation.md +3 -3
  27. package/docs/pages/foundations/philosophy.md +26 -0
  28. package/docs/pages/foundations/theming.md +80 -7
  29. package/docs/pages/foundations/tokens.md +39 -2
  30. package/docs/pages/guides/coding-agents.md +11 -0
  31. package/docs/pages/guides/introduction.md +1 -1
  32. package/docs/pages/guides/progressive-enhancement.md +88 -20
  33. package/docs/pages/guides/tailwind.md +12 -6
  34. package/docs/pages/guides/upgrading.md +52 -0
  35. package/docs/pages/layout/app-layout.md +50 -1
  36. package/docs/pages/patterns/empty-state.md +48 -10
  37. package/forms.json +325 -0
  38. package/llms.txt +2 -1
  39. package/package.json +3 -1
  40. package/reserved-classes.json +1 -0
  41. package/skills/actual-css/SKILL.md +1 -1
  42. package/skills/actual-css/references/api-and-vocabulary.md +2 -1
  43. package/src/cli/actual-css.js +8 -2
  44. package/src/css/components/app-nav.css +75 -18
  45. package/src/css/components/badge.css +7 -1
  46. package/src/css/components/button.css +20 -3
  47. package/src/css/components/flyout.css +5 -2
  48. package/src/css/components/list.css +28 -13
  49. package/src/css/components/menu.css +18 -0
  50. package/src/css/components/meter.css +4 -0
  51. package/src/css/components/progress.css +9 -2
  52. package/src/css/components/segmented.css +22 -12
  53. package/src/css/components/table.css +21 -2
  54. package/src/css/core/theme.css +11 -1
  55. package/src/css/core/tokens.css +16 -2
  56. package/src/css/forms/choice-card.css +4 -3
  57. package/src/css/forms/choice.css +28 -16
  58. package/src/css/forms/control.css +23 -16
  59. package/src/css/forms/custom-select.css +3 -1
  60. package/src/css/forms/form.css +8 -5
  61. package/src/css/forms/otp.css +2 -1
  62. package/src/css/forms/range.css +20 -6
  63. package/src/css/forms/select.css +12 -4
  64. package/src/css/forms/switch.css +11 -5
  65. package/src/css/layout/app-layout.css +104 -5
  66. package/src/js/data-flag.js +4 -0
  67. package/src/js/dialog.js +5 -8
  68. package/src/js/enhancement-loader-state.js +7 -0
  69. package/src/js/enhancement-loader.js +4 -21
  70. package/src/js/keys.js +5 -7
  71. package/src/js/parse-config.js +0 -2
  72. package/src/js/popover-transport.js +18 -0
  73. package/src/js/status.js +0 -2
  74. package/src/js/surface.js +35 -41
  75. package/src/js/tooltip.js +8 -36
  76. package/src/js/validation.js +24 -10
  77. package/src/tooling/css-bundle.js +5 -0
  78. package/src/tooling/design-tokens.js +8 -1
  79. package/src/tooling/theme-contrast.js +45 -17
  80. package/tokens.json +4 -0
package/src/js/tooltip.js CHANGED
@@ -56,9 +56,11 @@
56
56
  */
57
57
 
58
58
  import { autoUpdate, reposition } from "@lekoala/floating";
59
+ import { readDataFlag } from "./data-flag.js";
59
60
  import enhance from "./enhance.js";
60
61
  import { registerEscapeDismissal } from "./escape.js";
61
62
  import { positionModeFor, readPlacement } from "./floating-space.js";
63
+ import { hidePopover, showPopover } from "./popover-transport.js";
62
64
  import { CLASSES } from "./selectors.js";
63
65
 
64
66
  const SHOW_DELAY_MS = 150;
@@ -92,31 +94,6 @@ const tipStates = new WeakMap(); // tip -> { refs, activeRef, controller, stopTr
92
94
  /** @type {Element | null} The tip a tap pinned open; a tap elsewhere dismisses it. */
93
95
  let tappedTip = null;
94
96
 
95
- /*
96
- * Transport, the same shape surface.js uses and for the same reason: the
97
- * platform promotes the tip to the top layer and does nothing else, leaving
98
- * the hover/focus/click policy, the show delays and the Escape ordering here
99
- * untouched. showPopover/hidePopover throw on an out-of-order call, which the
100
- * state below should already have excluded — the try/catch is there so a
101
- * surprising DOM does not take the lifecycle down with it.
102
- */
103
- function showTransport(tip) {
104
- try {
105
- tip.showPopover();
106
- return true;
107
- } catch {
108
- return false;
109
- }
110
- }
111
-
112
- function hideTransport(tip) {
113
- try {
114
- tip.hidePopover();
115
- } catch {
116
- /* Already closed or detached; nothing left to hide. */
117
- }
118
- }
119
-
120
97
  /*
121
98
  * [hidden] stops being the runtime's state here and goes back to what the
122
99
  * author wrote: the state before enhancement. Wiring is lazy, so an explicit
@@ -157,23 +134,18 @@ function placementFor(ref) {
157
134
  return readPlacement(ref, "data-tooltip-placement") ?? "top";
158
135
  }
159
136
 
160
- function hasOption(trigger, name) {
161
- const value = trigger?.getAttribute(name);
162
- return value !== null && value.toLowerCase() !== "false";
163
- }
164
-
165
137
  function isClickTrigger(trigger) {
166
- return hasOption(trigger, "data-tooltip-click");
138
+ return readDataFlag(trigger, "data-tooltip-click");
167
139
  }
168
140
 
169
141
  // Taps open tooltips by default: the opt-out is explicit, so a tooltip never
170
142
  // fails silently under a finger.
171
143
  function isNoTapTrigger(trigger) {
172
- return hasOption(trigger, "data-tooltip-no-tap");
144
+ return readDataFlag(trigger, "data-tooltip-no-tap");
173
145
  }
174
146
 
175
147
  function isAlwaysVisible(trigger) {
176
- return hasOption(trigger, "data-tooltip-visible");
148
+ return readDataFlag(trigger, "data-tooltip-visible");
177
149
  }
178
150
 
179
151
  function describedByIds(trigger) {
@@ -243,13 +215,13 @@ function updateTrackedTip(tip, state) {
243
215
  if (!ref || !state.wanted) return;
244
216
 
245
217
  if (!state.visible) {
246
- if (!showTransport(tip)) return;
218
+ if (!showPopover(tip)) return;
247
219
  state.visible = true;
248
220
  }
249
221
 
250
222
  if (!repositionTip(ref, tip, state.space)) {
251
223
  state.visible = false;
252
- hideTransport(tip);
224
+ hidePopover(tip);
253
225
  }
254
226
  syncEscapeDismissal(tip, state);
255
227
  }
@@ -308,7 +280,7 @@ function hideTip(tip, force = false) {
308
280
  state.tapped = false;
309
281
  }
310
282
  if (tappedTip === tip) tappedTip = null;
311
- hideTransport(tip);
283
+ hidePopover(tip);
312
284
  state?.unregisterEscape?.();
313
285
  if (state) {
314
286
  state.unregisterEscape = null;
@@ -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",
@@ -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",
@@ -9,8 +9,8 @@
9
9
  * field, checkbox and radio, the track edge or knob of an unchecked switch
10
10
  * - soft ink against the resting and the hovered soft fill (4.5:1), on each
11
11
  * surface a soft element sits on
12
- * - the solid pairs, -fg on the intent fill (4.5:1); a fill painted by a
13
- * background-image reads n/a
12
+ * - the solid pairs, -fg on the intent fill (4.5:1), under the --finish
13
+ * veil; a fill a theme paints with its own background-image reads n/a
14
14
  * - selected ink on those surfaces: the current nav link at rest and on
15
15
  * hover, the selected tab and the current step number (4.5:1), and the
16
16
  * current step's ring (3:1)
@@ -61,7 +61,7 @@ function islandMarkup(id, scheme) {
61
61
  ).join("");
62
62
  return `<div${style} id="${id}">
63
63
  ${softPairs}
64
- ${INTENTS.map((i) => `<button class="btn solid ${i}" data-solid="${i}" type="button">t</button>`).join("")}
64
+ ${INTENTS.map((i) => `<button class="btn solid ${i}" data-solid="${i}" type="button" style="--finish: initial">t</button>`).join("")}
65
65
  <span data-pair="focus-surface" style="color: var(--focus); background: var(--surface)"></span>
66
66
  <span data-pair="focus-solid" style="color: var(--focus); background: var(--surface-solid)"></span>
67
67
  <span data-pair="inverse" style="color: var(--surface-solid-fg); background: var(--surface-solid)"></span>
@@ -74,7 +74,10 @@ function islandMarkup(id, scheme) {
74
74
 
75
75
  /* Controls whose resting edge is all that identifies them (WCAG 1.4.11): the
76
76
  edge against the surface around them needs 3:1. The field is read on its
77
- block-end side, the one an underline-only theme (material) keeps. An
77
+ block-end side, the one an underline-only theme (material) keeps, or on its
78
+ fill, whichever is stronger; under 3:1 it is a warning, not a miss: the
79
+ core's quiet field edge is a known trade-off (theme.css), and a field is
80
+ also identified by its label and place. An
78
81
  unchecked switch is read on its track edge or its knob, whichever is
79
82
  stronger: the core track is the --border-control edge, and a theme may move
80
83
  the cue to a dark knob on a quiet track (docs/pages/forms/switch.md). */
@@ -148,14 +151,23 @@ export async function measureContrast({ css, themes, label = "default" }) {
148
151
  const cs = (el, pseudo = null) => getComputedStyle(el, pseudo);
149
152
  const pairs = {};
150
153
  for (const el of island.querySelectorAll("[data-pair]")) {
151
- // The invalid field's block-end border carries --form-invalid-border,
152
- // the hook its focus outline reads, even on an underline-only theme
153
- // (material) whose other sides are clear.
154
- const fg = el.dataset.pair === "invalid-field" ? cs(el).borderBlockEndColor : cs(el).color;
154
+ // The invalid field is measured focused (a focused text field always
155
+ // matches :focus-visible): its line is the outline in
156
+ // --form-invalid-border, against the focused fill. A theme that clears
157
+ // the outline for an inset line (material, minimal) keeps the hook on
158
+ // the block-end border; a theme that drops the invalid frame (plush)
159
+ // keeps it on the outline.
160
+ let fg = cs(el).color;
161
+ if (el.dataset.pair === "invalid-field") {
162
+ el.focus();
163
+ const outline = cs(el).outlineStyle === "none" ? null : rgba(cs(el).outlineColor);
164
+ fg = outline && outline[3] > 0 ? cs(el).outlineColor : cs(el).borderBlockEndColor;
165
+ }
155
166
  pairs[el.dataset.pair] = { fg: rgba(fg), bg: rgba(cs(el).backgroundColor) };
156
167
  }
157
- // A solid fill painted by a background-image (a gradient theme) has no
158
- // single color to measure: it is reported, not sampled.
168
+ // The --finish veil is cleared on these buttons (islandMarkup), so
169
+ // the pair is the intent fill. A fill a theme still paints with its own
170
+ // background-image has no single color: it is reported, not sampled.
159
171
  const solid = {};
160
172
  for (const el of island.querySelectorAll("[data-solid]")) {
161
173
  solid[el.dataset.solid] =
@@ -207,11 +219,11 @@ export async function measureContrast({ css, themes, label = "default" }) {
207
219
  const box = island.querySelector("[data-controls]");
208
220
  const controls = { backdrop: rgba(cs(box).backgroundColor), edges: {} };
209
221
  // The cues that can identify each control; the best one counts. A field
210
- // shows its lower edge, a switch its track edge or its knob (the core
211
- // pill, or a theme's dark knob on a quiet track), any other control its
212
- // edge.
222
+ // shows its lower edge or its fill, a switch its track edge or its knob
223
+ // (the core pill, or a theme's dark knob on a quiet track), any other
224
+ // control its edge.
213
225
  const cues = {
214
- field: (s) => [s.borderBlockEndColor],
226
+ field: (s) => [s.borderBlockEndColor, s.backgroundColor],
215
227
  switch: (s, el) => [cs(el, "::before").backgroundColor, s.borderTopColor],
216
228
  };
217
229
  for (const el of box.querySelectorAll("[data-control]")) {
@@ -297,9 +309,11 @@ export async function measureThemeFile({ themeFile, name }) {
297
309
  return measureContrast({ css, themes: [theme], label: themeFile ? ":root" : "default" });
298
310
  }
299
311
 
300
- /* Text tables for `rows`, and the number of pairs under their threshold. */
312
+ /* Text tables for `rows`, the number of pairs under their threshold, and the
313
+ number of warnings: fields with no 3:1 cue, a trade-off the core makes. */
301
314
  export function formatContrast(rows) {
302
315
  let misses = 0;
316
+ let warnings = 0;
303
317
  const cell = (value, min) => {
304
318
  if (value === null) return { text: "n/a", miss: false };
305
319
  const miss = value < min;
@@ -373,10 +387,24 @@ export function formatContrast(rows) {
373
387
  );
374
388
  }
375
389
 
376
- lines.push("", "Control cue at rest (edge, or a switch's knob, vs --surface), needs 3:1.", "");
390
+ lines.push(
391
+ "",
392
+ "Control cue at rest (edge, a field's fill, or a switch's knob, vs --surface), needs 3:1.",
393
+ "A field under 3:1 is a warning: it reads by its label and place, which a WCAG 2 AA",
394
+ "audit does not count. Set --control-default-border: var(--border-control) for strong",
395
+ "identification, or give fields a fill or an edge that reaches 3:1.",
396
+ "",
397
+ );
377
398
  lines.push(`${"theme".padEnd(width)} scheme control ratio`);
378
399
  for (const row of rows) {
379
400
  for (const { kind, value } of row.controls ?? []) {
401
+ if (kind === "field" && value !== null && value < 3) {
402
+ warnings += 1;
403
+ lines.push(
404
+ `${head(row)} ${kind.padEnd(9)} ${`${value.toFixed(2)}:1`.padStart(8)} <-- warning: under 3`,
405
+ );
406
+ continue;
407
+ }
380
408
  const c = cell(value, 3);
381
409
  lines.push(`${head(row)} ${kind.padEnd(9)} ${c.text.padStart(8)}${flag([c], 3)}`);
382
410
  }
@@ -397,5 +425,5 @@ export function formatContrast(rows) {
397
425
  4.5,
398
426
  );
399
427
 
400
- return { text: lines.join("\n"), misses };
428
+ return { text: lines.join("\n"), misses, warnings };
401
429
  }
package/tokens.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "--btn-font-size",
13
13
  "--choice-control-size",
14
14
  "--control-default-bg",
15
+ "--control-default-border",
15
16
  "--control-font-size",
16
17
  "--control-pad-x",
17
18
  "--control-pad-x-lg",
@@ -34,6 +35,7 @@
34
35
  "--duration-spin",
35
36
  "--ease-enter",
36
37
  "--ease-exit",
38
+ "--finish",
37
39
  "--focus",
38
40
  "--focus-outline",
39
41
  "--focus-outline-color",
@@ -82,6 +84,8 @@
82
84
  "--selection-fg",
83
85
  "--shadow",
84
86
  "--shadow-color",
87
+ "--shadow-control",
88
+ "--shadow-inset",
85
89
  "--shadow-popout",
86
90
  "--soft-bg-mix",
87
91
  "--soft-border-mix",