actual-css 0.16.1 → 0.17.1

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 (119) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +8 -4
  3. package/components.json +19 -4
  4. package/dist/actual.full.css +464 -80
  5. package/dist/actual.full.js +2 -1
  6. package/dist/actual.full.min.css +1 -1
  7. package/docs/design-notes/app-ui.md +37 -3
  8. package/docs/design-notes/enhancement-contract.md +3 -1
  9. package/docs/navigation.json +17 -3
  10. package/docs/pages/components/accordion.md +8 -0
  11. package/docs/pages/components/alert.md +47 -17
  12. package/docs/pages/components/app-navigation.md +2 -2
  13. package/docs/pages/components/aura.md +2 -2
  14. package/docs/pages/components/badge.md +4 -3
  15. package/docs/pages/components/button.md +3 -0
  16. package/docs/pages/components/card.md +1 -1
  17. package/docs/pages/components/chat.md +2 -2
  18. package/docs/pages/components/dialog.md +36 -0
  19. package/docs/pages/components/drawer.md +52 -8
  20. package/docs/pages/components/fab.md +2 -1
  21. package/docs/pages/components/list.md +1 -1
  22. package/docs/pages/components/meter.md +1 -1
  23. package/docs/pages/components/navbar.md +27 -3
  24. package/docs/pages/components/overview.md +17 -0
  25. package/docs/pages/components/rating.md +111 -12
  26. package/docs/pages/components/segmented.md +36 -1
  27. package/docs/pages/components/shimmer.md +2 -2
  28. package/docs/pages/components/spinner.md +2 -0
  29. package/docs/pages/components/table.md +77 -0
  30. package/docs/pages/components/timeline.md +3 -1
  31. package/docs/pages/enhancements/flyout.md +83 -14
  32. package/docs/pages/enhancements/overview.md +2 -2
  33. package/docs/pages/enhancements/status-bar.md +1 -1
  34. package/docs/pages/enhancements/tabs.md +5 -0
  35. package/docs/pages/examples/overview.md +5 -1
  36. package/docs/pages/forms/ajax.md +101 -0
  37. package/docs/pages/forms/choice-cards.md +1 -1
  38. package/docs/pages/forms/color-swatches.md +31 -2
  39. package/docs/pages/forms/detached-actions.md +1 -1
  40. package/docs/pages/forms/floating-field.md +5 -3
  41. package/docs/pages/forms/form-actions.md +1 -1
  42. package/docs/pages/forms/input-policy.md +1 -1
  43. package/docs/pages/forms/joined-controls.md +9 -4
  44. package/docs/pages/forms/otp.md +2 -2
  45. package/docs/pages/forms/overview.md +1 -1
  46. package/docs/pages/forms/password.md +1 -1
  47. package/docs/pages/forms/states-and-sizes.md +1 -1
  48. package/docs/pages/forms/sticky-actions.md +1 -1
  49. package/docs/pages/forms/unsaved-changes.md +198 -0
  50. package/docs/pages/foundations/philosophy.md +2 -1
  51. package/docs/pages/foundations/theming.md +4 -3
  52. package/docs/pages/foundations/tokens.md +30 -5
  53. package/docs/pages/foundations/typography.md +1 -1
  54. package/docs/pages/guides/introduction.md +1 -1
  55. package/docs/pages/guides/progressive-enhancement.md +31 -50
  56. package/docs/pages/guides/upgrading.md +15 -2
  57. package/docs/pages/layout/app-layout.md +1 -1
  58. package/docs/pages/layout/app-shell.md +1 -1
  59. package/docs/pages/layout/choosing.md +5 -0
  60. package/docs/pages/layout/column-layout.md +23 -9
  61. package/docs/pages/layout/media.md +1 -1
  62. package/docs/pages/layout/overview.md +1 -1
  63. package/docs/pages/layout/scroll-snap.md +1 -1
  64. package/docs/pages/layout/scroll-target.md +1 -1
  65. package/docs/pages/layout/sidebar-layout.md +1 -1
  66. package/docs/pages/layout/sidebar-shell.md +68 -0
  67. package/docs/pages/patterns/code-block.md +1 -1
  68. package/docs/pages/patterns/empty-state.md +74 -0
  69. package/docs/pages/patterns/exclusive-accordion.md +1 -1
  70. package/docs/pages/patterns/hierarchical-nav.md +41 -20
  71. package/docs/pages/patterns/icon-input.md +1 -1
  72. package/docs/pages/patterns/intent-nesting.md +1 -1
  73. package/docs/pages/patterns/navigation-list.md +5 -62
  74. package/docs/pages/patterns/overview.md +1 -1
  75. package/docs/pages/patterns/stat.md +61 -0
  76. package/docs/pages/patterns/structured-lists.md +1 -1
  77. package/docs/pages/utilities/accessibility.md +32 -10
  78. package/docs/pages/utilities/flex.md +1 -1
  79. package/docs/pages/utilities/links.md +1 -1
  80. package/docs/pages/utilities/list.md +1 -1
  81. package/docs/pages/utilities/shape.md +1 -1
  82. package/docs/pages/utilities/sizing-wrapping.md +1 -1
  83. package/docs/pages/utilities/spacing.md +1 -1
  84. package/docs/pages/utilities/text.md +1 -1
  85. package/package.json +4 -1
  86. package/reserved-classes.json +2 -0
  87. package/src/cli/actual-css.js +4 -4
  88. package/src/css/components/accordion.css +10 -6
  89. package/src/css/components/alert.css +4 -0
  90. package/src/css/components/busy.css +25 -0
  91. package/src/css/components/button.css +3 -0
  92. package/src/css/components/drawer.css +37 -3
  93. package/src/css/components/flyout.css +37 -0
  94. package/src/css/components/join.css +14 -0
  95. package/src/css/components/modal.css +3 -0
  96. package/src/css/components/navbar.css +102 -38
  97. package/src/css/components/rating.css +50 -5
  98. package/src/css/components/segmented.css +25 -2
  99. package/src/css/core/theme.css +20 -1
  100. package/src/css/core/tokens.css +4 -1
  101. package/src/css/forms/color-swatch.css +38 -19
  102. package/src/css/forms/custom-select.css +10 -0
  103. package/src/css/forms/input-icon.css +5 -3
  104. package/src/css/layout/index.css +2 -0
  105. package/src/css/layout/sidebar-shell.css +67 -0
  106. package/src/css/typography/prose.css +6 -0
  107. package/src/js/ajax.js +148 -0
  108. package/src/js/dialog.js +59 -2
  109. package/src/js/dirty.js +140 -0
  110. package/src/js/dismiss.js +25 -0
  111. package/src/js/events.js +17 -0
  112. package/src/js/focus.js +12 -0
  113. package/src/js/form-submission.js +34 -0
  114. package/src/js/full.js +2 -0
  115. package/src/js/tab.js +16 -2
  116. package/src/js/validation.js +12 -4
  117. package/src/tooling/design-tokens.js +1 -0
  118. package/src/tooling/theme-contrast.js +44 -4
  119. package/tokens.json +1 -0
@@ -7,11 +7,24 @@
7
7
  `.color-swatch` is a `<label>` wrapping a native radio, with the color in
8
8
  `--color-swatch-value`. The radio stays the control: it submits, takes the
9
9
  arrow keys and carries the name in `aria-label`. The checked swatch shows a
10
- double ring that reads on any color. Use checkboxes for several colors at once.
10
+ ring around the color, which reads on any color and any background. Use
11
+ checkboxes for several colors at once.
11
12
 
12
13
  For a free color, use the native [`.color`](controls.md) picker; a custom
13
14
  spectrum or RGB sliders are outside Actual.
14
15
 
16
+ ## Anatomy
17
+
18
+ ```text
19
+ fieldset.field-group.cluster the palette, or a .grid; spaced with --gap
20
+ ├── legend
21
+ └── label.color-swatch ×N, --color-swatch-value
22
+ └── input[type="radio"] aria-label names the color; checkbox for several
23
+
24
+ button.color-swatch flyout trigger, --color-swatch-value
25
+ └── .sr-only the current color's name
26
+ ```
27
+
15
28
  ## Palette
16
29
 
17
30
  Lay the swatches out with `.cluster` or `.grid`, and space them with `--gap`
@@ -31,6 +44,21 @@ the column count with `--grid-columns: repeat(6, max-content)` on `.grid`.
31
44
  </fieldset>
32
45
  ```
33
46
 
47
+ ## Shape
48
+
49
+ Set `--color-swatch-radius` on the palette for square or rounded swatches; the
50
+ selection ring follows the corners.
51
+
52
+ ```html demo
53
+ <fieldset class="field-group cluster" style="--color-swatch-radius: var(--radius-sm)">
54
+ <legend>Label color</legend>
55
+ <label class="color-swatch" style="--color-swatch-value: #7c3aed"><input type="radio" name="label" value="#7c3aed" aria-label="Violet" checked></label>
56
+ <label class="color-swatch" style="--color-swatch-value: #0891b2"><input type="radio" name="label" value="#0891b2" aria-label="Cyan"></label>
57
+ <label class="color-swatch" style="--color-swatch-value: #65a30d"><input type="radio" name="label" value="#65a30d" aria-label="Lime"></label>
58
+ <label class="color-swatch" style="--color-swatch-value: #111827"><input type="radio" name="label" value="#111827" aria-label="Black"></label>
59
+ </fieldset>
60
+ ```
61
+
34
62
  ## Palette in a flyout
35
63
 
36
64
  A `<button class="color-swatch">` shows the current color and opens the
@@ -128,4 +156,5 @@ The color dialog is the browser's own and looks different on each platform.
128
156
  - `--color-swatch-value` — the color, set on each swatch.
129
157
  - `--color-swatch-size` — visible swatch size, the height of a `.switch` track
130
158
  by default. `.sm` and `.lg` scale it and the hit area.
131
- - `--color-swatch-radius` — corner radius; round by default.
159
+ - `--color-swatch-radius` — corner radius; round by default. Inherited, so one
160
+ declaration on the palette shapes every swatch.
@@ -1,4 +1,4 @@
1
- # Detached Actions
1
+ # Detached actions
2
2
 
3
3
  > `.form-actions` is class-only. It may live inside or outside the `<form>`. Use the native `form` attribute to connect a detached submit button to its form.
4
4
 
@@ -1,10 +1,12 @@
1
1
  # Floating labels
2
2
 
3
- > **Module** — import `actual-css/css/forms/floating-field` or `actual-css/css/forms/all`.
4
-
5
3
  `.floating-field` turns a control and its label into a floating-label cell:
6
4
  the label rests inside the control and floats to the top when the control is
7
- focused or filled. It composes the existing `.field` layout and the text
5
+ focused or filled.
6
+
7
+ > **Module** — import `actual-css/css/forms/floating-field` or `actual-css/css/forms/all`.
8
+
9
+ It composes the existing `.field` layout and the text
8
10
  controls (`.input`, `.textarea`, `.select`) with zero JavaScript.
9
11
 
10
12
  The cell holds exactly one control and its label, in either order: a form
@@ -1,4 +1,4 @@
1
- # Form Actions
1
+ # Form actions
2
2
 
3
3
  > `.form-actions` is the role of the `.cluster` row that closes a form. It may
4
4
  > live inside or outside the `<form>` (see Detached Actions) and has an opt-in
@@ -1,4 +1,4 @@
1
- # Input Policy
1
+ # Input policy
2
2
 
3
3
  > Native input intent first. Actual's runtime filters values only when explicitly asked, and fixed-shape masks stay opt-in through `data-mask`.
4
4
 
@@ -1,4 +1,4 @@
1
- # Joined Controls
1
+ # Joined controls
2
2
 
3
3
  > Use `.join` when controls need to be visually joined into a single unit.
4
4
 
@@ -15,7 +15,12 @@ choice among a few on a shared track, use a
15
15
  | `.join` | Composition | Joins adjacent controls into a single unit. |
16
16
  | `.join-addon` | Composition | Static prefix or suffix content. |
17
17
 
18
- Add `.join` to the wrapper that groups the controls. Use `.join-addon` for static prefix/suffix content such as currency symbols, units, or protocol text. Action buttons inside the group should use `.btn`. The wrapper should still carry `role="group"` with a label for accessibility.
18
+ Add `.join` to the wrapper that groups the controls. Use `.join-addon` for static prefix/suffix content such as currency symbols, units, or protocol text. Action buttons inside the group should use `.btn`.
19
+
20
+ Give the wrapper `role="group"` and a label when it holds several controls
21
+ that act as a set, such as a button group. A labelled input with an addon or
22
+ one attached button takes no group role: the field label already names the
23
+ input, and the group would repeat it.
19
24
 
20
25
  Each child keeps its own variant. Use the same variant across the group, and
21
26
  change it only to mark state, such as a solid pressed toggle among outlines.
@@ -25,8 +30,8 @@ controls it groups so joined corners take precedence.
25
30
 
26
31
  ```html demo
27
32
  <div class="field">
28
- <label class="field-label" id="amount-label" for="amount">Amount</label>
29
- <div class="join" role="group" aria-labelledby="amount-label">
33
+ <label class="field-label" for="amount">Amount</label>
34
+ <div class="join">
30
35
  <span class="join-addon">$</span>
31
36
  <input class="input" id="amount" name="amount" inputmode="decimal" />
32
37
  <button class="btn outline" type="button">Clear</button>
@@ -1,11 +1,11 @@
1
1
  # One-time code input
2
2
 
3
- > **Module** — import `actual-css/css/forms/otp` or `actual-css/css/forms/all`.
4
-
5
3
  OTP presents one native input as separate visual cells. Keeping a single input
6
4
  preserves paste, selection, autofill, password-manager, and
7
5
  `autocomplete="one-time-code"` behavior without JavaScript.
8
6
 
7
+ > **Module** — import `actual-css/css/forms/otp` or `actual-css/css/forms/all`.
8
+
9
9
  ```html demo
10
10
  <label class="field">
11
11
  <span class="field-label">Verification code</span>
@@ -197,7 +197,7 @@ root; keyboard focus and an open custom select keep it.
197
197
  - For a switch, use `class="switch"` and `role="switch"`.
198
198
  - `.range` skins the native range control (`appearance: none` track, thumb, and focus ring). Add `data-enhance="range"` for the fill share, named `datalist` values, and output sync.
199
199
  - `.form-actions` is the role of a `.cluster` row (`class="cluster form-actions"`) and carries no outer margin: `.stack` on the form spaces it from the fields. It is class-only and may live inside or outside `<form>`. See Detached Actions below.
200
- - `.join` visually joins adjacent controls into a single unit. Use `.join-addon` for static prefix/suffix content. The container still carries `role="group"` for accessibility.
200
+ - `.join` visually joins adjacent controls into a single unit. Use `.join-addon` for static prefix/suffix content. The container carries `role="group"` and a label only when it holds several controls acting as a set.
201
201
 
202
202
  ## Optional automatic required marks
203
203
 
@@ -1,4 +1,4 @@
1
- # Password Toggle
1
+ # Password toggle
2
2
 
3
3
  > A password field reveals its value through a linked button. The markup is a
4
4
  > plain command invoker; the behavior ships with the full JS runtime
@@ -1,4 +1,4 @@
1
- # States And Sizes
1
+ # States and sizes
2
2
 
3
3
  > Read-only, disabled, and shared size modifiers for form controls.
4
4
 
@@ -1,4 +1,4 @@
1
- # Sticky Actions
1
+ # Sticky actions
2
2
 
3
3
  > Use `.cluster.form-actions.sticky` when long forms need reachable submit actions while scrolling.
4
4
 
@@ -0,0 +1,198 @@
1
+ # Unsaved changes
2
+
3
+ > Track whether a form holds data that differs from what was last saved.
4
+
5
+ **Related terms:** dirty form, modified form, unsaved edits, leave page warning, discard changes.
6
+
7
+ ## Dirty state
8
+
9
+ Opt in with `data-enhance="dirty"` on the form. While the data it would submit
10
+ differs from its baseline, the form carries `data-dirty`. The baseline is the
11
+ data present when the form is enhanced.
12
+
13
+ ```html demo
14
+ <form class="stack" data-enhance="dirty">
15
+ <label class="field">
16
+ <span class="field-label">Name</span>
17
+ <input class="input" name="name" value="Alice" />
18
+ </label>
19
+ <div class="cluster form-actions">
20
+ <button class="btn primary" type="submit">Save</button>
21
+ <button class="btn neutral outline" type="reset">Reset</button>
22
+ </div>
23
+ </form>
24
+ ```
25
+
26
+ Style the state from application CSS, for example a hint shown only while there
27
+ is something to save:
28
+
29
+ ```css
30
+ form:not([data-dirty]) .save-hint { visibility: hidden; }
31
+ ```
32
+
33
+ The comparison covers what a submission would send: disabled and unnamed
34
+ controls do not count, controls associated through `form="…"` and
35
+ form-associated custom elements do. Add `data-dirty-ignore` to a control to
36
+ leave its name out, such as a CSRF token. Files compare by name, size and
37
+ modification time.
38
+
39
+ Each comparison fires the form's `formdata` event. An entry a listener adds
40
+ there counts too, so a volatile one (a nonce) keeps the form dirty: give it the
41
+ name of a hidden `data-dirty-ignore` input.
42
+
43
+ `actual:dirty-change` bubbles from the form after each transition, with
44
+ `{ form, dirty }`. It reports the state and cannot be canceled.
45
+
46
+ The module is part of the full runtime and importable on its own as
47
+ `actual-css/js/dirty`. It works alongside `validation` and never submits the
48
+ form or blocks navigation.
49
+
50
+ ## After saving
51
+
52
+ A native submission reloads the page and the new form starts clean. When the
53
+ form stays on the page, tell the module what was saved:
54
+
55
+ ```js
56
+ import { FormDirty } from "actual-css/js/dirty";
57
+
58
+ const snapshot = FormDirty.capture(form); // when the request starts
59
+ // … request succeeds …
60
+ FormDirty.markClean(form, snapshot);
61
+ ```
62
+
63
+ Passing the snapshot keeps edits made during the request dirty. Without one,
64
+ `markClean()` accepts the current data. A failed or rejected save should not
65
+ call it.
66
+
67
+ Edits through events update the state on their own. After setting values or
68
+ adding controls from code, call `FormDirty.refresh(form)`. A widget with no
69
+ form control of its own (a canvas, a sortable list) marks the form dirty by
70
+ writing its state to a hidden input, then calling `refresh()`.
71
+
72
+ Reset restores the HTML default values, which are the baseline only until the
73
+ first `markClean()`. A removed and reinserted form keeps its baseline. A form
74
+ replaced by new server markup starts a new one, even when the save failed.
75
+
76
+ With the [Ajax Submission](ajax.md) enhancer, wire the snapshot to its events
77
+ as shown there.
78
+
79
+ ## Autosave
80
+
81
+ Save a `form[data-autosave]` after a pause in typing, without a submit
82
+ button. The form keeps its `action` and `method`, so it still saves without
83
+ JavaScript.
84
+
85
+ ```html
86
+ <form class="stack" action="/notes" method="post" data-enhance="dirty" data-autosave>
87
+ <label class="field">
88
+ <span class="field-label">Notes</span>
89
+ <textarea class="input" name="notes" required></textarea>
90
+ </label>
91
+ <p class="muted" aria-hidden="true">
92
+ <span data-autosave-when="dirty">Saving…</span>
93
+ <span data-autosave-when="clean">All changes saved</span>
94
+ </p>
95
+ <noscript><button class="btn primary" type="submit">Save</button></noscript>
96
+ </form>
97
+ ```
98
+
99
+ ```css
100
+ form[data-dirty] [data-autosave-when="clean"],
101
+ form:not([data-dirty]) [data-autosave-when="dirty"] { display: none; }
102
+ ```
103
+
104
+ ```js
105
+ import { FormDirty } from "actual-css/js/dirty";
106
+ import { status } from "actual-css/js/status";
107
+
108
+ const DELAY = 1500; // idle time before saving
109
+ const timers = new WeakMap();
110
+
111
+ const schedule = (form) => {
112
+ clearTimeout(timers.get(form));
113
+ timers.set(form, setTimeout(() => save(form), DELAY));
114
+ };
115
+
116
+ async function save(form) {
117
+ if (!form.hasAttribute("data-dirty")) return;
118
+ if (form.getAttribute("aria-busy") === "true") return; // the running save reschedules
119
+ // checkValidity() stays silent; requestSubmit() would show errors mid-typing.
120
+ if (!form.checkValidity()) return;
121
+
122
+ const snapshot = FormDirty.capture(form);
123
+ form.setAttribute("aria-busy", "true");
124
+ try {
125
+ const response = await fetch(form.action, { method: form.method, body: new FormData(form) });
126
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
127
+ FormDirty.markClean(form, snapshot);
128
+ if (form.hasAttribute("data-dirty")) schedule(form); // typed during the request
129
+ } catch {
130
+ status("Changes not saved. Check your connection.", { intent: "danger" });
131
+ } finally {
132
+ form.removeAttribute("aria-busy");
133
+ }
134
+ }
135
+
136
+ document.addEventListener("input", ({ target }) => {
137
+ if (target.form?.matches("[data-autosave]")) schedule(target.form);
138
+ });
139
+ ```
140
+
141
+ - Edits made during a request stay dirty and trigger the next save.
142
+ - Invalid data is never saved. The form stays dirty until it becomes valid.
143
+ - A failed save is not retried in a loop. The next edit tries again, and the
144
+ warning below still protects the page.
145
+ - The status bar reports failures only. Announcing every successful save
146
+ would interrupt screen readers at each pause; the inline state is hidden
147
+ from them for the same reason.
148
+
149
+ ## Warning before leaving
150
+
151
+ The module does not guard navigation. This recipe asks for confirmation when
152
+ the page unloads with a dirty form, except the one being submitted natively:
153
+
154
+ ```js
155
+ let lastSubmit = null;
156
+ // Read at unload time, once every submit listener has had its say: a
157
+ // canceled submission (validation, Ajax), a dialog close or a submission into
158
+ // another window or frame does not leave.
159
+ const leavesBySubmit = (form) => {
160
+ if (lastSubmit?.target !== form || lastSubmit.defaultPrevented) return false;
161
+ const { submitter } = lastSubmit;
162
+ // Attributes, not form.method / form.target: a control with that name
163
+ // shadows the property. An empty formtarget="" still means the page itself.
164
+ const method = submitter?.getAttribute("formmethod") ?? form.getAttribute("method") ?? "";
165
+ const target =
166
+ submitter?.getAttribute("formtarget") ??
167
+ form.getAttribute("target") ??
168
+ document.querySelector("base[target]")?.getAttribute("target") ??
169
+ "";
170
+ if (target && !["_self", "_top", "_parent"].includes(target.toLowerCase())) return false;
171
+ return method.toLowerCase() !== "dialog";
172
+ };
173
+ const guard = (event) => {
174
+ for (const form of document.querySelectorAll("form[data-dirty]")) {
175
+ if (leavesBySubmit(form)) continue;
176
+ event.preventDefault();
177
+ event.returnValue = true; // Chromium before 119
178
+ return;
179
+ }
180
+ };
181
+
182
+ document.addEventListener("submit", (event) => { lastSubmit = event; });
183
+ addEventListener("pageshow", () => { lastSubmit = null; });
184
+
185
+ // Register only while needed: some browsers skip the back/forward cache for
186
+ // pages that listen to beforeunload.
187
+ document.addEventListener("actual:dirty-change", () => {
188
+ if (document.querySelector("form[data-dirty]")) addEventListener("beforeunload", guard);
189
+ else removeEventListener("beforeunload", guard);
190
+ });
191
+ ```
192
+
193
+ `beforeunload` covers reloads, closing the tab and full-page navigation.
194
+ Navigation inside the page (a client router, a region swap) does not fire it:
195
+ guard it in that router. Mobile browsers may skip the prompt when the page is
196
+ discarded in the background. A submission answered with a download keeps the
197
+ page, but the recipe cannot tell in advance: that form stays unguarded until
198
+ the next submission.
@@ -166,7 +166,8 @@ inside them. `.sm` on a plain element has no effect.
166
166
 
167
167
  Density affects controls and layout spacing. Badges, avatars, spinners,
168
168
  ratings, keys, prose, and inline choices keep their own size. One density
169
- class applies to the whole subtree:
169
+ class applies to the whole subtree; for a product-wide density, put
170
+ `class="compact"` on `<html>`:
170
171
 
171
172
  ```html demo
172
173
  <div class="compact stack">
@@ -220,8 +220,8 @@ bunx --bun actual-css contrast --theme src/theme.css
220
220
  ```
221
221
 
222
222
  It reads the theme in headless Chrome, in every scheme it declares, and exits 1
223
- when a soft, focus, invalid-focus or inverse pair misses its threshold, so it
224
- can gate a CI job.
223
+ when a soft, control-edge, focus, invalid-focus or inverse pair misses its
224
+ threshold, so it can gate a CI job.
225
225
 
226
226
  Starting from a color scale (Open Props, Radix Colors, Uchū, Tailwind
227
227
  `--color-zinc-*`, a brand ramp): map one step per role rather than importing
@@ -273,6 +273,7 @@ lets the core derive everything else.
273
273
  - `gradient`: outer focus halos on fields.
274
274
  - `neo-brutalist`: hard shadows, pastel fills, and plus-shaped accordion
275
275
  markers. Use it as a page skin: its rules cross nested theme boundaries.
276
- - `material`: filled underline fields and pill buttons.
276
+ - `material`: filled underline fields, pill buttons, and a table hover that
277
+ slides between rows.
277
278
  - `glass`: translucent surfaces over a backdrop. Keep `--surface-opaque` and
278
279
  `--surface-solid-fg` opaque, and check soft fills against the actual backdrop.
@@ -58,6 +58,28 @@ children consume them; check their component pages when nesting layouts.
58
58
 
59
59
  Intent tokens are used by `.primary`, `.secondary`, `.success`, `.warning`, `.danger`, and `.neutral`. They are curated color/foreground pairs. Actual CSS does not compute foregrounds automatically in the core theme contract.
60
60
 
61
+ The swatches read the live tokens, so they follow the scheme and theme picked
62
+ in the header.
63
+
64
+ ```html demo
65
+ <div class="grid docs-swatches">
66
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--primary)"></span><figcaption><code>--primary</code></figcaption></figure>
67
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--secondary)"></span><figcaption><code>--secondary</code></figcaption></figure>
68
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--success)"></span><figcaption><code>--success</code></figcaption></figure>
69
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--warning)"></span><figcaption><code>--warning</code></figcaption></figure>
70
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--danger)"></span><figcaption><code>--danger</code></figcaption></figure>
71
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--neutral)"></span><figcaption><code>--neutral</code></figcaption></figure>
72
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--surface)"></span><figcaption><code>--surface</code></figcaption></figure>
73
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--surface-subtle)"></span><figcaption><code>--surface-subtle</code></figcaption></figure>
74
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--surface-solid)"></span><figcaption><code>--surface-solid</code></figcaption></figure>
75
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--text)"></span><figcaption><code>--text</code></figcaption></figure>
76
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--text-muted)"></span><figcaption><code>--text-muted</code></figcaption></figure>
77
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--border)"></span><figcaption><code>--border</code></figcaption></figure>
78
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--border-control)"></span><figcaption><code>--border-control</code></figcaption></figure>
79
+ <figure class="stack tight"><span class="docs-swatch" style="background: var(--focus)"></span><figcaption><code>--focus</code></figcaption></figure>
80
+ </div>
81
+ ```
82
+
61
83
  The values below are the light fallback. In browsers with `light-dark()` support, the default theme re-declares the same tokens as light/dark pairs so dark mode follows the OS automatically; without support, browsers receive the light fallback.
62
84
 
63
85
  ```css
@@ -107,9 +129,12 @@ A theme with translucent surfaces overrides both with opaque values.
107
129
  `--border` separates surfaces: cards, tables, dividers, panels. `--border-control`
108
130
  is the resting edge that tells a control apart from the surface — fields,
109
131
  checkboxes and radios, switches, OTP cells, choice cards, join addons, the color
110
- and file inputs. It defaults to `--border`; set it alone to make controls
111
- stand out (input border, field outline, form control contrast) without
112
- darkening every separator. Hover, checked, invalid and disabled states keep
132
+ and file inputs. It is derived from `--text` and `--surface`; on the default
133
+ palette it holds 3:1 against the surface, and `actual-css contrast` reports it
134
+ for your theme. `--border-control-mix` sets the ink share; raise it when a
135
+ tinted surface pulls the edge under 3:1. Without `color-mix()` it falls back to
136
+ `--border`. Set `--border-control` itself to soften or strengthen controls (input border,
137
+ field outline, form control contrast) without touching any separator. Hover, checked, invalid and disabled states keep
113
138
  their own colors.
114
139
 
115
140
  Use `*-fg` pairs only for solid backgrounds where the component controls both foreground and background. Do not require a foreground token for every surface token.
@@ -517,7 +542,7 @@ A full theme can override:
517
542
  - intent colors and foreground pairs
518
543
  - surface, text, border, focus, and overlay colors
519
544
  - `--surface-opaque` and `--surface-solid-fg`, when surfaces are translucent
520
- - `--border-control`, when controls need a stronger edge than separators
545
+ - `--border-control-mix` or `--border-control`, when controls need a stronger edge than separators
521
546
  - radius tokens
522
547
  - optional shadow, motion, typography, and soft-variant mix tokens
523
548
 
@@ -569,7 +594,7 @@ Selected state has three roles:
569
594
 
570
595
  - `--state-selected` — the selected fill or accent: a pressed button, a checked switch, a completed step.
571
596
  - `--state-selected-fg` — ink on that fill.
572
- - `--state-selected-text` — selected ink on a regular surface: the current nav link, the selected tab, the current step's number and ring.
597
+ - `--state-selected-text` — selected ink on a regular surface: the selected tab, the current step's number and ring.
573
598
 
574
599
  `--state-selected-text` falls back to `--state-selected` within each theme.
575
600
  Set it separately when the selected fill lacks contrast as text, especially
@@ -142,7 +142,7 @@ The framework exposes three line-height tokens:
142
142
 
143
143
  - `--line-height-tight` (1.25) — used by global headings and by display / title classes
144
144
  - `--line-height` (1.5) — body default
145
- - `--line-height-relaxed` (1.75) — used by `.lead` and `.text-lead` for intro text
145
+ - `--line-height-relaxed` (1.6) — used by `.lead` and `.text-lead` for intro text
146
146
 
147
147
  There is no `--line-height-normal`. It would be redundant with `--line-height`. Prose overrides line-height through `--prose-line-height` and `--prose-heading-line-height` because the readable values for long-form text are different from app UI.
148
148
 
@@ -52,7 +52,7 @@ optimizing — the bare `actual-css` entrypoint and `actual-css/full` both resol
52
52
  to the complete compiled framework:
53
53
 
54
54
  ```html
55
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/actual-css@0.16/dist/actual.full.min.css">
55
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/actual-css@0.17/dist/actual.full.min.css">
56
56
  ```
57
57
 
58
58
  The package does not maintain separate partial bundles. Modular entrypoints map
@@ -1,4 +1,4 @@
1
- # The JavaScript Runtime
1
+ # The JavaScript runtime
2
2
 
3
3
  > The optional JavaScript runtime that progressively enhances Actual's semantic markup — self-registering side-effect modules, the `enhance()` DOM lifecycle, stateless command routing, and the floating and surface contracts for custom widgets.
4
4
 
@@ -126,6 +126,8 @@ status bar, for example:
126
126
  | `actual-css/js/password` | Password reveal toggle |
127
127
  | `actual-css/js/range` | Range fill and named values (token `range`) |
128
128
  | `actual-css/js/validation` | Form validation (token `validation`) |
129
+ | `actual-css/js/dirty` | Unsaved-changes state on forms (token `dirty`) |
130
+ | `actual-css/js/ajax` | Form submission through `fetch` (token `ajax`) |
129
131
  | `actual-css/js/status` | Singleton status bar on `[data-status][role="status"]` |
130
132
  | `actual-css/js/enhancement-loader` | Declared enhancement manifests |
131
133
 
@@ -142,8 +144,9 @@ needed.
142
144
  The JS is designed to run on its own, without Actual's stylesheet.
143
145
 
144
146
  - **`data-enhance` tokens** register named behaviors. The runtime discovers
145
- components through `data-enhance="tabs"`, `data-enhance="flyout"`, `data-enhance="range"`, `data-enhance="scrollspy"`, and
146
- `data-enhance="validation"` — no Actual presentation class needed.
147
+ components through `data-enhance="tabs"`, `data-enhance="flyout"`, `data-enhance="range"`, `data-enhance="scrollspy"`,
148
+ `data-enhance="validation"`, `data-enhance="dirty"`, and
149
+ `data-enhance="ajax"` — no Actual presentation class needed.
147
150
  Self-describing attributes (`data-mask`, `data-tooltip`,
148
151
  `data-context-menu`) stay framework-neutral by construction.
149
152
  - **`selectors.js`** lists the state classes the runtime *writes* (`is-open`,
@@ -322,14 +325,19 @@ The runtime dispatches a small set of public `actual:*` events. All are
322
325
  listenable on the document; cancelable events veto the associated action when
323
326
  `preventDefault()` is called.
324
327
 
325
- | Event | Dispatch | `detail` |
326
- | ---------------------- | ----------------------------- | ------------------------------------ |
327
- | `actual:surface-open` | before a surface opens | `{ surface, options }` |
328
- | `actual:context-menu` | before a context menu opens | `{ menu, context, origin, trigger }` |
329
- | `actual:status` | status module, or any code | `{ message, intent, duration }` |
330
- | `actual:invalid` | after a submit was blocked | `{ form, firstInvalid, message }` |
331
- | `actual:dialog-cancel` | before a native cancel close | `{ dialog, sourceEvent }` |
332
- | `actual:dismiss` | after a `--dismiss` dismissal | `{ trigger }` |
328
+ | Event | Dispatch | `detail` |
329
+ | ---------------------- | ------------------------------ | ------------------------------------ |
330
+ | `actual:surface-open` | before a surface opens | `{ surface, options }` |
331
+ | `actual:context-menu` | before a context menu opens | `{ menu, context, origin, trigger }` |
332
+ | `actual:status` | status module, or any code | `{ message, intent, duration }` |
333
+ | `actual:invalid` | after a submit was blocked | `{ form, firstInvalid, message }` |
334
+ | `actual:dirty-change` | after `data-dirty` flips | `{ form, dirty }` |
335
+ | `actual:ajax-start` | an ajax request starts | `{ form, submitter }` |
336
+ | `actual:ajax-response` | an ajax response arrived | `{ form, submitter, response }` |
337
+ | `actual:ajax-error` | an ajax request failed | `{ form, submitter, error }` |
338
+ | `actual:tab-change` | after the selected tab changed | `{ tab, panel, previousTab }` |
339
+ | `actual:dialog-cancel` | before a native cancel close | `{ dialog, sourceEvent }` |
340
+ | `actual:dismiss` | after a `--dismiss` dismissal | `{ trigger }` |
333
341
 
334
342
  `actual:surface-open`, `actual:context-menu` and `actual:dialog-cancel` are
335
343
  cancelable. `actual:status` both shows and clears the status bar — omit
@@ -379,9 +387,14 @@ or a direct dialog API call to delegate their commands to Actual.
379
387
 
380
388
  ### Dismiss command
381
389
 
382
- The runtime includes a generic `--dismiss` command for hiding any resolved
383
- target. It prevents the trigger's default action, sets `hidden`, and emits a
384
- bubbling `actual:dismiss` event with the trigger in `event.detail.trigger`.
390
+ The runtime includes a generic `--dismiss` command for hiding the element its
391
+ `commandfor` names; without a resolved target it does nothing. It prevents the
392
+ trigger's default action, sets `hidden`, and emits a bubbling `actual:dismiss`
393
+ event with the trigger in `event.detail.trigger`.
394
+
395
+ When focus was inside the target, it moves to the next tab stop after the
396
+ target, or to the nearest ancestor with a `tabindex` when nothing follows. A
397
+ listener that places focus itself keeps it.
385
398
  On an open surface (flyout, context menu), the surface consumes the event to
386
399
  close through its own lifecycle instead of staying hidden — by the time the
387
400
  event reaches document listeners, `hidden` has already been lifted again and
@@ -727,42 +740,10 @@ enhance({
727
740
  });
728
741
  ```
729
742
 
730
- ## Ajax forms
731
-
732
- Keep the native form as the baseline: set `action`, `method`, fields, and submit
733
- buttons normally. The enhancer can intercept submission only when JavaScript is
734
- available.
735
-
736
- ```js
737
- import enhance from "actual-css/js/enhance";
738
-
739
- enhance({
740
- "form[data-ajax]": (form) => {
741
- const controller = new AbortController();
742
-
743
- form.addEventListener("submit", async (event) => {
744
- event.preventDefault();
745
-
746
- const submitter = event.submitter;
747
- const data = new FormData(form, submitter);
748
- const response = await fetch(form.action, {
749
- method: form.method || "GET",
750
- body: form.method.toUpperCase() === "GET" ? null : data,
751
- signal: controller.signal,
752
- });
753
-
754
- form.dispatchEvent(new CustomEvent("actual:ajax", {
755
- bubbles: true,
756
- detail: { response },
757
- }));
758
- }, { signal: controller.signal });
759
-
760
- return () => controller.abort();
761
- },
762
- });
763
- ```
743
+ ## Ajax fragments
764
744
 
765
- For htmx-like fragment swaps, keep the first version narrow: one trigger, one
745
+ Forms submit through `fetch` with the built-in [Ajax Submission](../forms/ajax.md)
746
+ enhancer. For a trigger that loads a fragment, keep the first version narrow: one trigger, one
766
747
  target, one swap rule. If the behavior grows into history management, out-of-band
767
748
  swaps, request queues, and event policies, use a dedicated library.
768
749
 
@@ -780,7 +761,7 @@ enhance({
780
761
  const response = await fetch(trigger.dataset.get, {
781
762
  signal: controller.signal,
782
763
  });
783
- target.innerHTML = await response.text();
764
+ if (response.ok) target.innerHTML = await response.text();
784
765
  }, { signal: controller.signal });
785
766
 
786
767
  return () => controller.abort();
@@ -7,6 +7,19 @@ sections in order when skipping a release.
7
7
 
8
8
  **Related terms:** migration, breaking changes, update, version.
9
9
 
10
+ ## 0.16 to 0.17
11
+
12
+ ### Current nav link
13
+
14
+ The current `.nav-link` is neutral: `--text` ink on a fill one step above
15
+ hover, no inline-start trait outside forced colors. `--state-selected-text`
16
+ no longer reaches it.
17
+
18
+ - To keep a colored current link, set `--nav-current-fg` (and
19
+ `--nav-current-bg`) on the nav; check the pair with `actual-css contrast`.
20
+ - Rules that removed the trait (`.nav-list .nav-link[aria-current]::before {
21
+ content: none }`) now only remove the forced-colors cue: delete them.
22
+
10
23
  ## 0.14 to 0.15
11
24
 
12
25
  No class or hook is removed: markup and application CSS keep working.
@@ -124,8 +137,8 @@ row, set `--step-min: 7rem` on it.
124
137
 
125
138
  ### Current links and rows
126
139
 
127
- `.nav-link` shows its current state only for `aria-current="page"` or
128
- `aria-current="location"`, and `a.list-item` only for `aria-current="page"` or
140
+ `.nav-link` shows its current state only for `aria-current="page"`,
141
+ `aria-current="location"` or `aria-current="true"`, and `a.list-item` only for `aria-current="page"` or
129
142
  `aria-current="true"`. Search markup for other values on these classes and
130
143
  use the matching one.
131
144