actual-css 0.16.0 → 0.17.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 (79) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +8 -4
  3. package/components.json +21 -5
  4. package/dist/actual.full.css +410 -75
  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/design-notes/tokens.md +2 -0
  10. package/docs/navigation.json +14 -1
  11. package/docs/pages/components/accordion.md +5 -0
  12. package/docs/pages/components/alert.md +45 -17
  13. package/docs/pages/components/button.md +3 -0
  14. package/docs/pages/components/chat.md +20 -0
  15. package/docs/pages/components/dialog.md +36 -0
  16. package/docs/pages/components/drawer.md +52 -8
  17. package/docs/pages/components/navbar.md +26 -2
  18. package/docs/pages/components/rating.md +111 -12
  19. package/docs/pages/components/segmented.md +36 -1
  20. package/docs/pages/components/spinner.md +2 -0
  21. package/docs/pages/components/table.md +77 -0
  22. package/docs/pages/components/timeline.md +3 -1
  23. package/docs/pages/enhancements/flyout.md +83 -14
  24. package/docs/pages/enhancements/status-bar.md +1 -0
  25. package/docs/pages/enhancements/tabs.md +5 -0
  26. package/docs/pages/examples/overview.md +7 -1
  27. package/docs/pages/forms/ajax.md +101 -0
  28. package/docs/pages/forms/color-swatches.md +31 -2
  29. package/docs/pages/forms/date-picker.md +6 -0
  30. package/docs/pages/forms/joined-controls.md +8 -3
  31. package/docs/pages/forms/overview.md +2 -2
  32. package/docs/pages/forms/sticky-actions.md +2 -0
  33. package/docs/pages/forms/unsaved-changes.md +198 -0
  34. package/docs/pages/foundations/philosophy.md +2 -1
  35. package/docs/pages/foundations/theming.md +21 -4
  36. package/docs/pages/foundations/tokens.md +1 -1
  37. package/docs/pages/guides/introduction.md +1 -1
  38. package/docs/pages/guides/progressive-enhancement.md +30 -49
  39. package/docs/pages/guides/upgrading.md +16 -3
  40. package/docs/pages/layout/choosing.md +5 -0
  41. package/docs/pages/layout/column-layout.md +22 -8
  42. package/docs/pages/layout/scroll-snap.md +69 -2
  43. package/docs/pages/layout/sidebar-shell.md +68 -0
  44. package/docs/pages/patterns/empty-state.md +74 -0
  45. package/docs/pages/patterns/hierarchical-nav.md +40 -19
  46. package/docs/pages/patterns/navigation-list.md +3 -60
  47. package/docs/pages/patterns/stat.md +61 -0
  48. package/docs/pages/utilities/accessibility.md +32 -10
  49. package/package.json +4 -1
  50. package/reserved-classes.json +2 -0
  51. package/src/css/components/busy.css +25 -0
  52. package/src/css/components/button.css +3 -0
  53. package/src/css/components/chat.css +5 -1
  54. package/src/css/components/drawer.css +37 -3
  55. package/src/css/components/flyout.css +37 -0
  56. package/src/css/components/modal.css +3 -0
  57. package/src/css/components/navbar.css +99 -38
  58. package/src/css/components/rating.css +50 -5
  59. package/src/css/components/segmented.css +25 -2
  60. package/src/css/components/status-bar.css +4 -2
  61. package/src/css/forms/choice-card.css +5 -2
  62. package/src/css/forms/color-swatch.css +38 -19
  63. package/src/css/forms/custom-select.css +5 -0
  64. package/src/css/forms/form.css +3 -1
  65. package/src/css/layout/index.css +2 -0
  66. package/src/css/layout/sidebar-shell.css +67 -0
  67. package/src/js/ajax.js +148 -0
  68. package/src/js/dialog.js +59 -2
  69. package/src/js/dirty.js +140 -0
  70. package/src/js/dismiss.js +25 -0
  71. package/src/js/events.js +17 -0
  72. package/src/js/focus.js +12 -0
  73. package/src/js/form-submission.js +34 -0
  74. package/src/js/full.js +2 -0
  75. package/src/js/selectors.js +10 -2
  76. package/src/js/status.js +71 -10
  77. package/src/js/tab.js +16 -2
  78. package/src/js/validation.js +12 -4
  79. package/src/tooling/theme-contrast.js +3 -2
package/src/js/tab.js CHANGED
@@ -11,6 +11,8 @@
11
11
  * [hidden], disabled and panel-less tabs are skipped
12
12
  * Overflow: a horizontal strip shows its whole selected tab, at connect and
13
13
  * on every selection
14
+ * Event: actual:tab-change bubbles from the tablist when the selection
15
+ * changes, not at connect
14
16
  *
15
17
  * Self-registers via registerEnhancement: injected tablists wire automatically.
16
18
  * The tab→panel map is rebuilt from the live tablist on each interaction,
@@ -19,6 +21,7 @@
19
21
  */
20
22
 
21
23
  import { registerEnhancement } from "./enhance.js";
24
+ import { EVENTS } from "./events.js";
22
25
  import { ensureInlineVisible } from "./inline-visible.js";
23
26
  import { itemForKey, shouldIgnoreKey } from "./keys.js";
24
27
  import { afterParse } from "./parsed.js";
@@ -68,12 +71,16 @@ function makePanelFocusable(panel) {
68
71
  }
69
72
  }
70
73
 
71
- function activate(tab) {
74
+ /* Every selection path runs through here, so the change event cannot be
75
+ forgotten by one of them. Initialization passes notify: false: it settles
76
+ the markup's state, it is not a transition; read aria-selected for that. */
77
+ function activate(tab, { notify = true } = {}) {
72
78
  if (!tab || isTabDisabled(tab) || !panelFor(tab)) return;
73
79
  const list = tab.closest(TABLIST_SELECTOR);
74
80
  if (!list) return;
75
81
  const tabs = tabsOf(list);
76
82
  const panels = panelsOf(tabs);
83
+ const previousTab = tabs.find((t) => t.getAttribute("aria-selected") === "true") ?? null;
77
84
 
78
85
  for (const t of tabs) {
79
86
  t.setAttribute("aria-selected", "false");
@@ -89,6 +96,13 @@ function activate(tab) {
89
96
  makePanelFocusable(panel);
90
97
  panel.hidden = false;
91
98
  }
99
+
100
+ // After the DOM update, so a listener reads the new state.
101
+ if (notify && tab !== previousTab) {
102
+ list.dispatchEvent(
103
+ new CustomEvent(EVENTS.tabChange, { bubbles: true, detail: { tab, panel, previousTab } }),
104
+ );
105
+ }
92
106
  }
93
107
 
94
108
  /* An overflowing horizontal strip shows the whole tab. At connect a
@@ -110,7 +124,7 @@ function initialize(list) {
110
124
  const tabs = activatableTabs(list);
111
125
  if (!tabs.length) return;
112
126
  const selected = tabs.find((tab) => tab.getAttribute("aria-selected") === "true") || tabs[0];
113
- activate(selected);
127
+ activate(selected, { notify: false });
114
128
  reveal(list, selected);
115
129
  }
116
130
 
@@ -269,13 +269,21 @@ function validateField(el, trigger) {
269
269
 
270
270
  if (!wantsTrigger && !alreadyInvalid) return;
271
271
 
272
- if (checkRules(el)) {
273
- markValid(el);
274
- } else {
275
- markInvalid(el);
272
+ const valid = checkRules(el);
273
+ for (const member of radioGroup(el)) {
274
+ if (valid) markValid(member);
275
+ else markInvalid(member);
276
276
  }
277
277
  }
278
278
 
279
+ // A radio's validity is its group's: picking one fills a required group, so
280
+ // the result applies to every radio of the name. Marking only the picked one
281
+ // left its siblings aria-invalid and the field error showing.
282
+ function radioGroup(el) {
283
+ if (el.type !== "radio" || !el.name || !el.form) return [el];
284
+ return [...el.form.elements].filter((other) => other.type === "radio" && other.name === el.name);
285
+ }
286
+
279
287
  function connectForm(form) {
280
288
  const existing = connectedForms.get(form);
281
289
  if (existing) return existing;
@@ -210,8 +210,9 @@ export async function measureContrast({ css, themes, label = "default" }) {
210
210
  intent,
211
211
  value: solid[intent] ? ratio(solid[intent].fg, solid[intent].bg) : null,
212
212
  })),
213
- // Selected ink on a regular surface (--state-selected-text): text needs
214
- // 4.5:1, the current step's ring is a non-text accent at 3:1.
213
+ // Selected ink on a regular surface (--state-selected-text for tab and
214
+ // step; --text on its tint for the current nav link): text needs 4.5:1,
215
+ // the current step's ring is a non-text accent at 3:1.
215
216
  selected: SURFACES.flatMap((surface) => {
216
217
  const { selected } = soft[surface];
217
218
  return [