@aiaiai-pt/design-system 0.55.0 → 0.55.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  @component KpiRegister
3
3
 
4
4
  The two-register composition for one KPI: the more authoritative value above,
5
- the less authoritative beneath. It is where "measured out-ranks projected"
5
+ the less authoritative beneath. It is where "a reading out-ranks a forecast"
6
6
  becomes concrete — in type SIZE, in POSITION, and in SCREEN-READER READING
7
7
  ORDER, all three.
8
8
 
@@ -7,7 +7,7 @@ type KpiRegister = {
7
7
  * KpiRegister
8
8
  *
9
9
  * The two-register composition for one KPI: the more authoritative value above,
10
- * the less authoritative beneath. It is where "measured out-ranks projected"
10
+ * the less authoritative beneath. It is where "a reading out-ranks a forecast"
11
11
  * becomes concrete — in type SIZE, in POSITION, and in SCREEN-READER READING
12
12
  * ORDER, all three.
13
13
  *
@@ -46,14 +46,21 @@
46
46
  let typeaheadBuffer = $state('');
47
47
  let typeaheadTimer = $state(0);
48
48
 
49
+ /** Every WAI-ARIA menu item role: plain, radio and checkbox items. */
50
+ const ITEM_ROLES = ['menuitem', 'menuitemradio', 'menuitemcheckbox'];
51
+ const ITEM_SELECTOR = ITEM_ROLES.map((r) => `[role="${r}"]`).join(', ');
52
+
49
53
  /**
50
- * Get all enabled menu items inside the menu container.
54
+ * Get all enabled menu items (any item role) inside the menu container.
55
+ * Skips items that are aria-disabled or natively :disabled.
51
56
  * @returns {HTMLElement[]}
52
57
  */
53
58
  function getItems() {
54
59
  if (!menuEl) return [];
55
60
  return /** @type {HTMLElement[]} */ (
56
- Array.from(menuEl.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])'))
61
+ Array.from(menuEl.querySelectorAll(ITEM_SELECTOR)).filter(
62
+ (el) => !el.matches(':disabled, [aria-disabled="true"]')
63
+ )
57
64
  );
58
65
  }
59
66
 
@@ -101,7 +108,7 @@
101
108
  case 'Enter':
102
109
  case ' ': {
103
110
  e.preventDefault();
104
- if (current && current.getAttribute('role') === 'menuitem') {
111
+ if (current && ITEM_ROLES.includes(current.getAttribute('role') ?? '')) {
105
112
  current.click();
106
113
  }
107
114
  break;
@@ -3,6 +3,8 @@
3
3
 
4
4
  A single actionable row inside a Menu.
5
5
  Renders as <button role="menuitem"> with optional leading/trailing snippets.
6
+ Set role="menuitemradio" or role="menuitemcheckbox" with `checked` for
7
+ selectable items; aria-checked is rendered only for those two roles.
6
8
 
7
9
  Consumes --menu-item-* tokens from components.css.
8
10
 
@@ -18,6 +20,11 @@
18
20
  Delete
19
21
  </MenuItem>
20
22
 
23
+ @example Radio item
24
+ <MenuItem role="menuitemradio" checked={sort === 'name'} onclick={() => (sort = 'name')}>
25
+ Sort by name
26
+ </MenuItem>
27
+
21
28
  @example With keyboard shortcut
22
29
  <MenuItem onclick={handleCopy}>
23
30
  Copy
@@ -25,9 +32,29 @@
25
32
  </MenuItem>
26
33
  -->
27
34
  <script>
35
+ /**
36
+ * @typedef {'menuitem' | 'menuitemradio' | 'menuitemcheckbox'} MenuItemRole
37
+ * @typedef {{
38
+ * variant?: string,
39
+ * role?: MenuItemRole,
40
+ * checked?: boolean,
41
+ * disabled?: boolean,
42
+ * leading?: import('svelte').Snippet,
43
+ * trailing?: import('svelte').Snippet,
44
+ * children?: import('svelte').Snippet,
45
+ * class?: string,
46
+ * [key: string]: unknown,
47
+ * }} Props
48
+ */
49
+
50
+ /** @type {Props} */
28
51
  let {
29
52
  /** @type {'default' | 'destructive'} */
30
53
  variant = 'default',
54
+ /** @type {MenuItemRole} */
55
+ role = 'menuitem',
56
+ /** Checked state; rendered as aria-checked only for menuitemradio/menuitemcheckbox. @type {boolean} */
57
+ checked = false,
31
58
  /** @type {boolean} */
32
59
  disabled = false,
33
60
  /** @type {import('svelte').Snippet | undefined} */
@@ -40,10 +67,15 @@
40
67
  class: className = '',
41
68
  ...rest
42
69
  } = $props();
70
+
71
+ const ariaChecked = $derived(
72
+ role === 'menuitemradio' || role === 'menuitemcheckbox' ? (checked ? 'true' : 'false') : undefined
73
+ );
43
74
  </script>
44
75
 
45
76
  <button
46
- role="menuitem"
77
+ {role}
78
+ aria-checked={ariaChecked}
47
79
  class="menu-item menu-item-{variant} {className}"
48
80
  class:menu-item-disabled={disabled}
49
81
  disabled={disabled || undefined}
@@ -1,13 +1,15 @@
1
1
  export default MenuItem;
2
2
  type MenuItem = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<$$ComponentProps>): void;
4
+ $set?(props: Partial<Props>): void;
5
5
  };
6
6
  /**
7
7
  * MenuItem
8
8
  *
9
9
  * A single actionable row inside a Menu.
10
10
  * Renders as <button role="menuitem"> with optional leading/trailing snippets.
11
+ * Set role="menuitemradio" or role="menuitemcheckbox" with `checked` for
12
+ * selectable items; aria-checked is rendered only for those two roles.
11
13
  *
12
14
  * Consumes --menu-item-* tokens from components.css.
13
15
  *
@@ -23,6 +25,11 @@ type MenuItem = {
23
25
  * Delete
24
26
  * </MenuItem>
25
27
  *
28
+ * @example Radio item
29
+ * <MenuItem role="menuitemradio" checked={sort === 'name'} onclick={() => (sort = 'name')}>
30
+ * Sort by name
31
+ * </MenuItem>
32
+ *
26
33
  * @example With keyboard shortcut
27
34
  * <MenuItem onclick={handleCopy}>
28
35
  * Copy
@@ -30,18 +37,24 @@ type MenuItem = {
30
37
  * </MenuItem>
31
38
  */
32
39
  declare const MenuItem: import("svelte").Component<{
40
+ [key: string]: unknown;
33
41
  variant?: string;
42
+ role?: "menuitem" | "menuitemradio" | "menuitemcheckbox";
43
+ checked?: boolean;
34
44
  disabled?: boolean;
35
- leading?: any;
36
- trailing?: any;
37
- children?: any;
45
+ leading?: import("svelte").Snippet;
46
+ trailing?: import("svelte").Snippet;
47
+ children?: import("svelte").Snippet;
38
48
  class?: string;
39
- } & Record<string, any>, {}, "">;
40
- type $$ComponentProps = {
49
+ }, {}, "">;
50
+ type Props = {
41
51
  variant?: string;
52
+ role?: "menuitem" | "menuitemradio" | "menuitemcheckbox";
53
+ checked?: boolean;
42
54
  disabled?: boolean;
43
- leading?: any;
44
- trailing?: any;
45
- children?: any;
55
+ leading?: import("svelte").Snippet;
56
+ trailing?: import("svelte").Snippet;
57
+ children?: import("svelte").Snippet;
46
58
  class?: string;
47
- } & Record<string, any>;
59
+ [key: string]: unknown;
60
+ };
@@ -99,11 +99,15 @@
99
99
  /** @type {HTMLElement | null} */
100
100
  const previouslyFocused = /** @type {HTMLElement | null} */ (document.activeElement);
101
101
 
102
- // Focus first focusable child
102
+ // Focus the first focusable child that is enabled (not :disabled and not
103
+ // aria-disabled). With none, leave focus where it is.
103
104
  requestAnimationFrame(() => {
104
- const focusable = popoverEl?.querySelector(
105
- 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
106
- );
105
+ if (!popoverEl) return;
106
+ const focusable = Array.from(
107
+ popoverEl.querySelectorAll(
108
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
109
+ )
110
+ ).find((el) => !el.matches(':disabled, [aria-disabled="true"]'));
107
111
  if (focusable) /** @type {HTMLElement} */ (focusable).focus();
108
112
  });
109
113
 
@@ -28,13 +28,13 @@
28
28
  H1 Slice 2 — westeuropeco/atelier-urban-workspace#57.
29
29
 
30
30
  @example A reading, using whatever terms the deployment declares
31
- <SealChip value="+14 cm/h" evidence={{ value: 'measured', label: 'medido', tone: 'positive' }} />
31
+ <SealChip value="+14 cm/h" evidence={{ value: 'term-a', label: 'leitura', tone: 'positive' }} />
32
32
 
33
33
  @example Both axes, horizon passed, why one tap away
34
34
  <SealChip
35
35
  value="2,1 m"
36
- evidence={{ value: 'inferred', label: 'inferido', tone: 'info' }}
37
- probability={{ value: 'uncertain', label: 'incerto' }}
36
+ evidence={{ value: 'term-b', label: 'modelo', tone: 'info' }}
37
+ probability={{ value: 'rung-c', label: 'grau-c' }}
38
38
  stale
39
39
  why="the 16:00 window has already passed"
40
40
  />
@@ -250,7 +250,7 @@
250
250
 
251
251
  /*
252
252
  * TONES — the presentation scale the design system owns. Which declared term
253
- * wears which tone is data, declared beside the word and never inferred from
253
+ * wears which tone is data, declared beside the word and never guessed from
254
254
  * it, so these rules carry no vocabulary.
255
255
  */
256
256
  .seal-tone-positive {
@@ -33,13 +33,13 @@ type SealChip = {
33
33
  * H1 Slice 2 — westeuropeco/atelier-urban-workspace#57.
34
34
  *
35
35
  * @example A reading, using whatever terms the deployment declares
36
- * <SealChip value="+14 cm/h" evidence={{ value: 'measured', label: 'medido', tone: 'positive' }} />
36
+ * <SealChip value="+14 cm/h" evidence={{ value: 'term-a', label: 'leitura', tone: 'positive' }} />
37
37
  *
38
38
  * @example Both axes, horizon passed, why one tap away
39
39
  * <SealChip
40
40
  * value="2,1 m"
41
- * evidence={{ value: 'inferred', label: 'inferido', tone: 'info' }}
42
- * probability={{ value: 'uncertain', label: 'incerto' }}
41
+ * evidence={{ value: 'term-b', label: 'modelo', tone: 'info' }}
42
+ * probability={{ value: 'rung-c', label: 'grau-c' }}
43
43
  * stale
44
44
  * why="the 16:00 window has already passed"
45
45
  * />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiaiai-pt/design-system",
3
- "version": "0.55.0",
3
+ "version": "0.55.2",
4
4
  "description": "Design system tokens and Svelte components for aiaiai products",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -136,6 +136,7 @@
136
136
  "@codemirror/view": "^6.40.0",
137
137
  "@lezer/highlight": "^1.0.0",
138
138
  "@sveltejs/package": "^2.5.7",
139
+ "axe-core": "^4.14.0",
139
140
  "date-fns": "^4.1.0",
140
141
  "echarts": "^6.1.0",
141
142
  "jsdom": "^29.1.1",
@@ -147,8 +147,8 @@
147
147
  on their respective subtle backgrounds.
148
148
 
149
149
  Contrast on subtle backgrounds (AA = 4.5:1 for small badge text):
150
- measured #256f20 (green-700) on #f0fdf4 (success-subtle): ~5.46:1 [AA]
151
- projected #9e6308 (amber-700) on #fffbeb (warning-subtle): ~4.79:1 [AA]
150
+ positive #256f20 (green-700) on #f0fdf4 (success-subtle): ~5.46:1 [AA]
151
+ caution #9e6308 (amber-700) on #fffbeb (warning-subtle): ~4.79:1 [AA]
152
152
  --seal-info-text inherits --color-info (#2e63a3): 5.66:1 on
153
153
  info-subtle (#f0f5fa) — no override needed.
154
154
  --seal-stale-text inherits --color-text-muted (≥3.0:1 non-essential).
@@ -249,9 +249,9 @@
249
249
  coverage-gap note) — visual QA is the complement.
250
250
 
251
251
  Contrast on steel-900 (#0b182a, lum ≈ 0.0082):
252
- measured #4ade80 (green-400) lum ≈ 0.403 → ~7.76:1 [AAA]
253
- inferred #60a5fa (blue-400) lum ≈ 0.386 → ~7.49:1 [AAA]
254
- projected #fbbf24 (amber-400) lum ≈ 0.598 → ~11.14:1 [AAA]
252
+ positive #4ade80 (green-400) lum ≈ 0.403 → ~7.76:1 [AAA]
253
+ info #60a5fa (blue-400) lum ≈ 0.386 → ~7.49:1 [AAA]
254
+ caution #fbbf24 (amber-400) lum ≈ 0.598 → ~11.14:1 [AAA]
255
255
  stale inherits --seal-stale-text: var(--color-text-muted) = #60758a (3.74:1)
256
256
  ═══════════════════════════════════════════════════════════════ */
257
257
  --seal-positive-text: #4ade80;