@middag-io/react 0.51.1 → 0.52.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 (118) hide show
  1. package/dist-lib/{DateField-lPZsiWfC.js → DateField-CduB6lUv.js} +21 -23
  2. package/dist-lib/{DateRangeField-B7zWB48D.js → DateRangeField-DlA_9i4w.js} +17 -13
  3. package/dist-lib/{FormField-BGqAQLtX.js → FormField-CDdY7-md.js} +2090 -2054
  4. package/dist-lib/{FormPanelBlock-CGgA83Mu.js → FormPanelBlock-zo8tCgtS.js} +1 -2
  5. package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
  6. package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
  7. package/dist-lib/base/blocks/EmptyStateBlock.d.ts.map +1 -1
  8. package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
  9. package/dist-lib/base/blocks/MetricCardBlock.d.ts.map +1 -1
  10. package/dist-lib/base/form/FormField.d.ts +8 -1
  11. package/dist-lib/base/form/FormField.d.ts.map +1 -1
  12. package/dist-lib/base/form/fields/DateField.d.ts +1 -1
  13. package/dist-lib/base/form/fields/DateField.d.ts.map +1 -1
  14. package/dist-lib/base/form/fields/DateRangeField.d.ts +3 -1
  15. package/dist-lib/base/form/fields/DateRangeField.d.ts.map +1 -1
  16. package/dist-lib/base/form/fields/MultiSelectField.d.ts +3 -1
  17. package/dist-lib/base/form/fields/MultiSelectField.d.ts.map +1 -1
  18. package/dist-lib/base/form/fields/RadioField.d.ts +3 -1
  19. package/dist-lib/base/form/fields/RadioField.d.ts.map +1 -1
  20. package/dist-lib/base/form/fields/RatingField.d.ts +3 -1
  21. package/dist-lib/base/form/fields/RatingField.d.ts.map +1 -1
  22. package/dist-lib/base/form/fields/SliderField.d.ts +3 -1
  23. package/dist-lib/base/form/fields/SliderField.d.ts.map +1 -1
  24. package/dist-lib/base/form/fields/TagsField.d.ts.map +1 -1
  25. package/dist-lib/base/partials/DataTable/cell-renderers.d.ts.map +1 -1
  26. package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
  27. package/dist-lib/base/partials/DataTable/types.d.ts +2 -2
  28. package/dist-lib/base/partials/DataTable/types.d.ts.map +1 -1
  29. package/dist-lib/base/partials/EmptyPlaceholder/index.d.ts.map +1 -1
  30. package/dist-lib/base/shell/BasicShell.d.ts +12 -1
  31. package/dist-lib/base/shell/BasicShell.d.ts.map +1 -1
  32. package/dist-lib/base/shell/BasicShell.js +126 -111
  33. package/dist-lib/base/shell/partials/InlineEditablePanel.js +193 -176
  34. package/dist-lib/base/shell/partials/InspectorContext.js +1 -1
  35. package/dist-lib/base/theme/tailwind-theme.css +13 -5
  36. package/dist-lib/base/theme/theme-bridge.css +8 -0
  37. package/dist-lib/base/theme/themes/classic.css +15 -11
  38. package/dist-lib/base/theme/tokens.css +36 -10
  39. package/dist-lib/base/utils/php-wire.d.ts +33 -0
  40. package/dist-lib/base/utils/php-wire.d.ts.map +1 -0
  41. package/dist-lib/base/utils/php-wire.js +19 -0
  42. package/dist-lib/chunks/{subpath-DjkzcIPp.js → subpath-Bb5vw3A_.js} +21 -23
  43. package/dist-lib/chunks/{subpath-fEhy6n_U.js → subpath-CZB5_RY7.js} +2 -0
  44. package/dist-lib/chunks/subpath-DVHs9lfh.js +29 -0
  45. package/dist-lib/contracts/block-data/data-display.d.ts +12 -287
  46. package/dist-lib/contracts/block-data/data-display.d.ts.map +1 -1
  47. package/dist-lib/contracts/block-data/interactive.d.ts +14 -22
  48. package/dist-lib/contracts/block-data/interactive.d.ts.map +1 -1
  49. package/dist-lib/contracts/block-data/shared.d.ts +2 -17
  50. package/dist-lib/contracts/block-data/shared.d.ts.map +1 -1
  51. package/dist-lib/contracts/generated/index.d.ts +2 -2
  52. package/dist-lib/contracts/generated/schemas.d.ts +1584 -192
  53. package/dist-lib/contracts/generated/schemas.d.ts.map +1 -1
  54. package/dist-lib/contracts/generated/types.d.ts +288 -8
  55. package/dist-lib/contracts/generated/types.d.ts.map +1 -1
  56. package/dist-lib/contracts/page-contract-schema.d.ts +15 -0
  57. package/dist-lib/contracts/page-contract-schema.d.ts.map +1 -1
  58. package/dist-lib/i18n/I18nProvider.js +1 -1
  59. package/dist-lib/i18n/instance.js +1 -1
  60. package/dist-lib/i18n/locales/en/ui.json +1 -0
  61. package/dist-lib/i18n/locales/pt-BR/ui.json +1 -0
  62. package/dist-lib/i18n/register-strings.js +1 -1
  63. package/dist-lib/index.d.ts +2 -2
  64. package/dist-lib/index.d.ts.map +1 -1
  65. package/dist-lib/lib/hooks/use-prefers-reduced-motion.d.ts +6 -0
  66. package/dist-lib/lib/hooks/use-prefers-reduced-motion.d.ts.map +1 -0
  67. package/dist-lib/lib/hooks/use-prefers-reduced-motion.js +21 -0
  68. package/dist-lib/middag-react.css +1 -1
  69. package/dist-lib/middag-react.js +10407 -10012
  70. package/dist-lib/primitives/reui/badge.d.ts +5 -0
  71. package/dist-lib/primitives/reui/badge.d.ts.map +1 -1
  72. package/dist-lib/primitives/reui/badge.js +14 -14
  73. package/dist-lib/primitives/reui/sidebar.d.ts.map +1 -1
  74. package/dist-lib/primitives/reui/sidebar.js +46 -34
  75. package/docs/public/schemas/fragment.json +1258 -19
  76. package/docs/public/schemas/page-contract.json +1258 -19
  77. package/docs/public/schemas/shared-props.json +1258 -19
  78. package/package.json +6 -1
  79. package/src/base/blocks/CardGridBlock.tsx +10 -2
  80. package/src/base/blocks/DenseTableBlock.tsx +18 -11
  81. package/src/base/blocks/DetailPanelBlock.tsx +1 -1
  82. package/src/base/blocks/EmptyStateBlock.tsx +5 -1
  83. package/src/base/blocks/FormPanelBlock.tsx +0 -1
  84. package/src/base/blocks/MetricCardBlock.tsx +9 -2
  85. package/src/base/form/FormField.tsx +40 -7
  86. package/src/base/form/fields/DateField.tsx +3 -3
  87. package/src/base/form/fields/DateRangeField.tsx +19 -14
  88. package/src/base/form/fields/MultiSelectField.tsx +9 -8
  89. package/src/base/form/fields/RadioField.tsx +4 -0
  90. package/src/base/form/fields/RatingField.tsx +4 -0
  91. package/src/base/form/fields/SliderField.tsx +4 -1
  92. package/src/base/form/fields/TagsField.tsx +3 -0
  93. package/src/base/partials/DataTable/cell-renderers.tsx +23 -12
  94. package/src/base/partials/DataTable/index.tsx +5 -2
  95. package/src/base/partials/DataTable/types.ts +2 -5
  96. package/src/base/partials/DetailSection/index.tsx +2 -2
  97. package/src/base/partials/EmptyPlaceholder/index.tsx +7 -3
  98. package/src/base/partials/MarkdownContent/index.tsx +1 -1
  99. package/src/base/shell/BasicShell.tsx +47 -8
  100. package/src/base/shell/partials/InspectorContext.tsx +1 -1
  101. package/src/base/theme/tailwind-theme.css +13 -5
  102. package/src/base/theme/theme-bridge.css +8 -0
  103. package/src/base/theme/themes/classic.css +15 -11
  104. package/src/base/theme/tokens.css +36 -10
  105. package/src/base/utils/php-wire.ts +54 -0
  106. package/src/contracts/block-data/data-display.ts +46 -337
  107. package/src/contracts/block-data/interactive.ts +18 -23
  108. package/src/contracts/block-data/shared.ts +2 -14
  109. package/src/contracts/generated/index.ts +2 -2
  110. package/src/contracts/generated/schemas.ts +312 -9
  111. package/src/contracts/generated/types.ts +314 -8
  112. package/src/i18n/locales/en/ui.json +1 -0
  113. package/src/i18n/locales/pt-BR/ui.json +1 -0
  114. package/src/lib/hooks/use-prefers-reduced-motion.ts +32 -0
  115. package/src/primitives/reui/badge.tsx +19 -14
  116. package/src/primitives/reui/sidebar.tsx +30 -3
  117. package/src/theme.css +11 -5
  118. package/dist-lib/chunks/subpath-DoiyWIYV.js +0 -25
@@ -14,6 +14,7 @@ import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";
14
14
  import { router } from "@inertiajs/core";
15
15
 
16
16
  import { getIcon } from "@/base/utils/icons";
17
+ import { knownValue } from "@/base/utils/php-wire";
17
18
  import { formatTimestamp } from "@/base/utils/time";
18
19
  import type {
19
20
  AnnotatedValue,
@@ -33,14 +34,22 @@ import { sanitizeHtmlToReact } from "./sanitize-html";
33
34
  // Status-to-badge mapping
34
35
  // ---------------------------------------------------------------------------
35
36
 
36
- type StatusSemantic = "success" | "warning" | "destructive" | "info" | "default" | "secondary";
37
+ const STATUS_SEMANTICS = [
38
+ "success",
39
+ "warning",
40
+ "destructive",
41
+ "info",
42
+ "default",
43
+ "secondary",
44
+ ] as const;
45
+ type StatusSemantic = (typeof STATUS_SEMANTICS)[number];
37
46
 
38
47
  /** Status pill classes using subtle bg + muted (darker) text for readable contrast. */
39
48
  const STATUS_PILL_CLASSES: Record<StatusSemantic, string> = {
40
- success: "bg-success-subtle text-success",
41
- warning: "bg-warning-subtle text-warning",
42
- destructive: "bg-destructive-subtle text-destructive",
43
- info: "bg-info-subtle text-info",
49
+ success: "bg-success-subtle text-success-text",
50
+ warning: "bg-warning-subtle text-warning-text",
51
+ destructive: "bg-destructive-subtle text-destructive-text",
52
+ info: "bg-info-subtle text-info-text",
44
53
  default: "bg-muted text-muted-foreground",
45
54
  secondary: "bg-muted text-muted-foreground",
46
55
  };
@@ -108,8 +117,10 @@ function resolveStatusSemantic(status: string, statusMap?: Record<string, string
108
117
  const callerMap = Object.fromEntries(
109
118
  Object.entries(statusMap ?? {}).map(([key, intent]) => [key.toLowerCase(), intent]),
110
119
  );
111
- const merged = { ...DEFAULT_STATUS_MAP, ...callerMap };
112
- return (merged[status.toLowerCase()] ?? "secondary") as StatusSemantic;
120
+ const merged: Record<string, string> = { ...DEFAULT_STATUS_MAP, ...callerMap };
121
+ // statusMap values are an open enum: an intent this renderer does not know
122
+ // falls back to the neutral "secondary".
123
+ return knownValue(merged[status.toLowerCase()], STATUS_SEMANTICS) ?? "secondary";
113
124
  }
114
125
 
115
126
  // ---------------------------------------------------------------------------
@@ -136,7 +147,7 @@ export function StatusCell({ value, column }: CellRendererProps): ReactElement {
136
147
  export function BooleanCell({ value }: CellRendererProps): ReactElement {
137
148
  if (value == null) return <span className="text-muted-foreground">&mdash;</span>;
138
149
  return value ? (
139
- <HugeiconsIcon icon={Tick02Icon} className="text-success size-4" />
150
+ <HugeiconsIcon icon={Tick02Icon} className="text-success-text size-4" />
140
151
  ) : (
141
152
  <HugeiconsIcon icon={Cancel01Icon} className="text-muted-foreground size-4" />
142
153
  );
@@ -272,10 +283,10 @@ export function LinkGroupCell({ value }: CellRendererProps): ReactElement {
272
283
  }
273
284
 
274
285
  const ANNOTATED_APPEARANCE: Record<string, string> = {
275
- success: "text-success",
276
- warning: "text-warning",
277
- danger: "text-destructive",
278
- info: "text-info",
286
+ success: "text-success-text",
287
+ warning: "text-warning-text",
288
+ danger: "text-destructive-text",
289
+ info: "text-info-text",
279
290
  neutral: "text-muted-foreground",
280
291
  };
281
292
 
@@ -719,7 +719,10 @@ export function DataTable<TData extends object>({
719
719
  cell: ({ row }) => (
720
720
  <div
721
721
  className={
722
- actionsAlwaysVisible ? "" : "opacity-0 transition-opacity group-hover/row:opacity-100"
722
+ actionsAlwaysVisible
723
+ ? ""
724
+ : // Revealed on row hover and whenever keyboard focus is in the row.
725
+ "opacity-0 transition-opacity group-focus-within/row:opacity-100 group-hover/row:opacity-100 focus-within:opacity-100"
723
726
  }
724
727
  >
725
728
  <RowActionButtons row={row.original} actions={rowActions} />
@@ -1148,7 +1151,7 @@ export function DataTable<TData extends object>({
1148
1151
  aria-label={t("middag.ui.table.scroll_region")}
1149
1152
  tabIndex={0}
1150
1153
  >
1151
- <table className="w-full border-collapse" role="grid">
1154
+ <table className="w-full border-collapse">
1152
1155
  <thead>
1153
1156
  {table.getHeaderGroups().map((headerGroup) => (
1154
1157
  <tr key={headerGroup.id}>
@@ -6,7 +6,7 @@ import type { ReactNode } from "react";
6
6
 
7
7
  import type { EmptyPlaceholderCTA } from "@/base/partials/EmptyPlaceholder";
8
8
  import type { AppliedFilters, FilterDef } from "@/base/partials/FilterBar";
9
- import type { ExecutableAction, TimestampFormat } from "@/contracts/block-data";
9
+ import type { ExecutableAction, StatusIntent, TimestampFormat } from "@/contracts/block-data";
10
10
 
11
11
  // ---------------------------------------------------------------------------
12
12
  // Column
@@ -55,10 +55,7 @@ export interface DataTableColumn<TData> {
55
55
  /** Custom cell renderer. Overrides type-based rendering. */
56
56
  render?: (value: unknown, row: TData) => ReactNode;
57
57
  /** Status-to-semantic mapping for type="status" columns. Maps status string to a semantic intent. */
58
- statusMap?: Record<
59
- string,
60
- "success" | "warning" | "destructive" | "secondary" | "info" | "default"
61
- >;
58
+ statusMap?: Record<string, StatusIntent>;
62
59
  }
63
60
 
64
61
  // ---------------------------------------------------------------------------
@@ -112,7 +112,7 @@ function CopyButton({ text }: { text: string }): ReactElement {
112
112
  size={14}
113
113
  className={cn(
114
114
  "transition-colors",
115
- copied ? "text-success" : "text-muted-foreground hover:text-foreground",
115
+ copied ? "text-success-text" : "text-muted-foreground hover:text-foreground",
116
116
  )}
117
117
  />
118
118
  </button>
@@ -157,7 +157,7 @@ function FieldValue({ field }: { field: DetailField }): ReactElement {
157
157
  <HugeiconsIcon
158
158
  icon={value ? CheckmarkCircle01Icon : Cancel01Icon}
159
159
  size={16}
160
- className={value ? "text-success" : "text-muted-foreground"}
160
+ className={value ? "text-success-text" : "text-muted-foreground"}
161
161
  aria-label={value ? t("middag.ui.common.yes") : t("middag.ui.common.no")}
162
162
  />
163
163
  );
@@ -10,6 +10,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
10
10
  import { Link } from "@inertiajs/react";
11
11
 
12
12
  import { getIcon } from "@/base/utils/icons";
13
+ import { usePrefersReducedMotion } from "@/lib/hooks/use-prefers-reduced-motion";
13
14
  import { cn } from "@/lib/utils";
14
15
  import { Button } from "@/primitives/reui/button";
15
16
 
@@ -92,6 +93,9 @@ export function EmptyPlaceholder({
92
93
  const iconColor = resolveIconColor(variant);
93
94
  const showCTA = variant !== "permission" && cta;
94
95
  const lottieSize = config.iconSize * 1.8;
96
+ // The canvas animation ignores the CSS reduced-motion rule: with reduced
97
+ // motion it shows its first frame and does not play or loop.
98
+ const prefersReducedMotion = usePrefersReducedMotion();
95
99
 
96
100
  return (
97
101
  <div
@@ -105,8 +109,8 @@ export function EmptyPlaceholder({
105
109
  >
106
110
  <DotLottieReact
107
111
  src={lottieUrl}
108
- loop
109
- autoplay
112
+ loop={!prefersReducedMotion}
113
+ autoplay={!prefersReducedMotion}
110
114
  style={{ width: lottieSize, height: lottieSize }}
111
115
  className="mb-4"
112
116
  />
@@ -151,7 +155,7 @@ export function EmptyPlaceholder({
151
155
  )}
152
156
 
153
157
  {ctaSecondary && (
154
- <Link href={ctaSecondary.href} className="text-info mt-2.5 text-xs hover:underline">
158
+ <Link href={ctaSecondary.href} className="text-info-text mt-2.5 text-xs hover:underline">
155
159
  {ctaSecondary.label} &rarr;
156
160
  </Link>
157
161
  )}
@@ -71,7 +71,7 @@ function CodeBlockCopyButton({ code }: { code: string }): ReactElement {
71
71
  size={14}
72
72
  className={cn(
73
73
  "transition-colors",
74
- copied ? "text-success" : "text-muted-foreground hover:text-foreground",
74
+ copied ? "text-success-text" : "text-muted-foreground hover:text-foreground",
75
75
  )}
76
76
  />
77
77
  </button>
@@ -42,7 +42,6 @@ import {
42
42
  SidebarGroup,
43
43
  SidebarGroupLabel,
44
44
  SidebarHeader,
45
- SidebarInset,
46
45
  SidebarMenu,
47
46
  SidebarMenuButton,
48
47
  SidebarMenuItem,
@@ -158,7 +157,24 @@ function HeaderUserMenu({
158
157
  );
159
158
  }
160
159
 
161
- export function BasicShell({ children }: ShellProps): ReactElement {
160
+ /** Element that renders the page title in the BasicShell header. */
161
+ export type BasicShellTitleTag = "h1" | "h2" | "div";
162
+
163
+ export interface BasicShellProps extends ShellProps {
164
+ /**
165
+ * Element for the page title (default "h1"). Embedded hosts whose page
166
+ * already has an h1 pass "h2" or "div".
167
+ */
168
+ titleAs?: BasicShellTitleTag;
169
+ /** Render the skip-to-content link (default true). Hosts that already render one pass false. */
170
+ skipLink?: boolean;
171
+ }
172
+
173
+ export function BasicShell({
174
+ children,
175
+ titleAs: TitleTag = "h1",
176
+ skipLink = true,
177
+ }: BasicShellProps): ReactElement {
162
178
  const { t } = useTranslation();
163
179
  const { props } = usePage<SharedProps>();
164
180
  const isDark = useIsDark();
@@ -180,6 +196,20 @@ export function BasicShell({ children }: ShellProps): ReactElement {
180
196
 
181
197
  return (
182
198
  <SidebarProvider>
199
+ {/* First focusable element: lets keyboard users skip the navigation. */}
200
+ {/* Hidden until focused by an unlayered rule in tailwind.css, not by
201
+ sr-only: host themes (Bootstrap) ship their own unlayered .sr-only,
202
+ which would keep the link clipped even on focus. */}
203
+ {skipLink && (
204
+ <a
205
+ href="#middag-main-content"
206
+ data-slot="skip-link"
207
+ className="bg-background text-foreground focus-visible:ring-ring rounded-md px-3 py-2 text-sm font-medium shadow-md focus-visible:ring-2 focus-visible:outline-none"
208
+ >
209
+ {t("middag.ui.shell.skip_to_content")}
210
+ </a>
211
+ )}
212
+
183
213
  <Sidebar collapsible="offcanvas" className="border-sidebar-border bg-sidebar border-r">
184
214
  <SidebarHeader className="border-sidebar-border border-b px-4 py-3">
185
215
  <span className="text-sidebar-foreground text-sm font-semibold">MIDDAG</span>
@@ -241,7 +271,9 @@ export function BasicShell({ children }: ShellProps): ReactElement {
241
271
  </SidebarFooter>
242
272
  </Sidebar>
243
273
 
244
- <SidebarInset>
274
+ {/* Same box as SidebarInset, but a div: SidebarInset renders a <main>, and
275
+ the content area below is the page's only main landmark. */}
276
+ <div data-slot="sidebar-inset" className="bg-background relative flex w-full flex-1 flex-col">
245
277
  <header className="border-border flex h-14 shrink-0 items-center gap-3 border-b px-4">
246
278
  <SidebarTrigger className="text-muted-foreground hover:text-foreground" />
247
279
  <div className="flex min-w-0 flex-col">
@@ -264,10 +296,16 @@ export function BasicShell({ children }: ShellProps): ReactElement {
264
296
  ))}
265
297
  </nav>
266
298
  )}
299
+ {/* The page title is the level-1 heading. The wrapper carries the
300
+ look; the title element (h1 unless titleAs says otherwise)
301
+ inherits it (tailwind.css resets host h1 styles
302
+ such as Moodle's on [data-slot="page-title"]). */}
267
303
  {page.title && (
268
- <span className="text-foreground truncate text-sm font-medium">
269
- {renderLabel(page.title, t)}
270
- </span>
304
+ <div className="text-foreground min-w-0 text-sm font-medium">
305
+ <TitleTag data-slot="page-title" className="truncate">
306
+ {renderLabel(page.title, t)}
307
+ </TitleTag>
308
+ </div>
271
309
  )}
272
310
  </div>
273
311
 
@@ -286,13 +324,14 @@ export function BasicShell({ children }: ShellProps): ReactElement {
286
324
 
287
325
  <main
288
326
  id="middag-main-content"
289
- className="flex min-h-0 flex-1 flex-col overflow-auto"
327
+ tabIndex={-1}
328
+ className="flex min-h-0 flex-1 flex-col overflow-auto focus:outline-none"
290
329
  aria-live="polite"
291
330
  aria-busy="false"
292
331
  >
293
332
  {children}
294
333
  </main>
295
- </SidebarInset>
334
+ </div>
296
335
 
297
336
  <Toaster position="bottom-right" richColors />
298
337
  </SidebarProvider>
@@ -95,7 +95,7 @@ export function InspectorFieldValue({ field }: { field: InspectorField }) {
95
95
  if (field.kind === "status" || field.kind === "badge") {
96
96
  const color =
97
97
  field.value === "active" || field.value === "granted"
98
- ? "bg-success-subtle text-success"
98
+ ? "bg-success-subtle text-success-text"
99
99
  : field.value === "failed" || field.value === "revoked"
100
100
  ? "bg-destructive-subtle text-destructive"
101
101
  : "bg-muted text-muted-foreground";
@@ -62,6 +62,12 @@
62
62
  --color-info-subtle: var(--info-subtle);
63
63
  --color-info-muted: var(--info-muted);
64
64
 
65
+ /* ── Status text (AA on canvas, card, subtle and tinted fills) ── */
66
+ --color-destructive-text: var(--destructive-text);
67
+ --color-success-text: var(--success-text);
68
+ --color-warning-text: var(--warning-text);
69
+ --color-info-text: var(--info-text);
70
+
65
71
  /* ── Chart colors ── */
66
72
  --color-chart-1: var(--chart-1);
67
73
  --color-chart-2: var(--chart-2);
@@ -85,11 +91,13 @@
85
91
  --font-sans: var(--font-sans);
86
92
  --font-mono: var(--font-mono);
87
93
 
88
- --radius-sm: calc(var(--radius) - 4px);
89
- --radius-md: calc(var(--radius) - 2px);
90
- --radius-lg: var(--radius);
91
- --radius-xl: calc(var(--radius) + 4px);
92
- --radius-2xl: calc(var(--radius) + 6px);
94
+ /* Radius values live in tokens.css (the unlayered :root value is the one
95
+ that renders); the utilities only point at them. */
96
+ --radius-sm: var(--radius-sm);
97
+ --radius-md: var(--radius-md);
98
+ --radius-lg: var(--radius-lg);
99
+ --radius-xl: var(--radius-xl);
100
+ --radius-2xl: var(--radius-2xl);
93
101
 
94
102
  /* ── Spacing scale as Tailwind spacing ── */
95
103
  --spacing-0: var(--space-0);
@@ -41,24 +41,28 @@
41
41
  --color-destructive-foreground: var(--destructive-foreground);
42
42
  --color-destructive-subtle: var(--destructive-subtle);
43
43
  --color-destructive-muted: var(--destructive-muted);
44
+ --color-destructive-text: var(--destructive-text);
44
45
 
45
46
  /* Success */
46
47
  --color-success: var(--success);
47
48
  --color-success-foreground: var(--success-foreground);
48
49
  --color-success-subtle: var(--success-subtle);
49
50
  --color-success-muted: var(--success-muted);
51
+ --color-success-text: var(--success-text);
50
52
 
51
53
  /* Warning */
52
54
  --color-warning: var(--warning);
53
55
  --color-warning-foreground: var(--warning-foreground);
54
56
  --color-warning-subtle: var(--warning-subtle);
55
57
  --color-warning-muted: var(--warning-muted);
58
+ --color-warning-text: var(--warning-text);
56
59
 
57
60
  /* Info */
58
61
  --color-info: var(--info);
59
62
  --color-info-foreground: var(--info-foreground);
60
63
  --color-info-subtle: var(--info-subtle);
61
64
  --color-info-muted: var(--info-muted);
65
+ --color-info-text: var(--info-text);
62
66
 
63
67
  /* Neutral */
64
68
  --color-muted: var(--muted);
@@ -122,18 +126,22 @@
122
126
  --color-destructive-foreground: var(--destructive-foreground);
123
127
  --color-destructive-subtle: var(--destructive-subtle);
124
128
  --color-destructive-muted: var(--destructive-muted);
129
+ --color-destructive-text: var(--destructive-text);
125
130
  --color-success: var(--success);
126
131
  --color-success-foreground: var(--success-foreground);
127
132
  --color-success-subtle: var(--success-subtle);
128
133
  --color-success-muted: var(--success-muted);
134
+ --color-success-text: var(--success-text);
129
135
  --color-warning: var(--warning);
130
136
  --color-warning-foreground: var(--warning-foreground);
131
137
  --color-warning-subtle: var(--warning-subtle);
132
138
  --color-warning-muted: var(--warning-muted);
139
+ --color-warning-text: var(--warning-text);
133
140
  --color-info: var(--info);
134
141
  --color-info-foreground: var(--info-foreground);
135
142
  --color-info-subtle: var(--info-subtle);
136
143
  --color-info-muted: var(--info-muted);
144
+ --color-info-text: var(--info-text);
137
145
  --color-muted: var(--muted);
138
146
  --color-muted-foreground: var(--muted-foreground);
139
147
  --color-accent: var(--accent);
@@ -36,25 +36,29 @@
36
36
  --accent-foreground: oklch(0.21 0.014 285.82);
37
37
 
38
38
  /* --- Colors: status ---------------------------------------------------- */
39
- --success: oklch(0.55 0.17 155);
39
+ --success: oklch(0.52 0.16 155);
40
40
  --success-foreground: oklch(0.98 0 0);
41
41
  --success-subtle: oklch(0.95 0.04 155);
42
42
  --success-muted: oklch(0.88 0.06 155);
43
+ --success-text: oklch(0.45 0.13 155);
43
44
 
44
45
  --warning: oklch(0.75 0.18 75);
45
46
  --warning-foreground: oklch(0.18 0.02 75);
46
47
  --warning-subtle: oklch(0.96 0.04 75);
47
48
  --warning-muted: oklch(0.9 0.06 75);
49
+ --warning-text: oklch(0.48 0.11 60);
48
50
 
49
- --destructive: oklch(0.577 0.245 27.33);
51
+ --destructive: oklch(0.56 0.23 27.33);
50
52
  --destructive-foreground: oklch(0.98 0 0);
51
53
  --destructive-subtle: oklch(0.95 0.05 27.33);
52
54
  --destructive-muted: oklch(0.88 0.08 27.33);
55
+ --destructive-text: oklch(0.48 0.2 27.33);
53
56
 
54
- --info: oklch(0.58 0.16 250);
57
+ --info: oklch(0.54 0.16 250);
55
58
  --info-foreground: oklch(0.98 0 0);
56
59
  --info-subtle: oklch(0.95 0.04 250);
57
60
  --info-muted: oklch(0.88 0.06 250);
61
+ --info-text: oklch(0.47 0.15 250);
58
62
 
59
63
  /* --- Colors: surfaces & neutrals (warm) -------------------------------- */
60
64
  --background: oklch(0.99 0.001 286);
@@ -64,11 +68,11 @@
64
68
  --popover: oklch(1 0 0);
65
69
  --popover-foreground: oklch(0.145 0.014 285.82);
66
70
  --muted: oklch(0.97 0.001 286);
67
- --muted-foreground: oklch(0.58 0.008 286);
71
+ --muted-foreground: oklch(0.52 0.008 286);
68
72
 
69
73
  --border: oklch(0.975 0.001 286);
70
74
  --input: oklch(0.89 0.004 286);
71
- --ring: oklch(0.708 0.028 256.85);
75
+ --ring: oklch(0.64 0.03 256.85);
72
76
 
73
77
  /* --- Colors: sidebar --------------------------------------------------- */
74
78
  --sidebar: oklch(0.975 0.002 286);
@@ -89,11 +93,7 @@
89
93
 
90
94
  /* --- Radii (Maia — generous) ------------------------------------------- */
91
95
  --radius: 0.625rem;
92
- --radius-sm: 4px;
93
- --radius-md: 6px;
94
- --radius-lg: 8px;
95
- --radius-xl: 12px;
96
- --radius-2xl: 16px;
96
+ /* --radius-sm … --radius-2xl come from tokens.css (single source). */
97
97
 
98
98
  /* --- Layout ------------------------------------------------------------- */
99
99
  --sidebar-width: 260px;
@@ -128,21 +128,25 @@
128
128
  --success-foreground: oklch(0.1 0.01 155);
129
129
  --success-subtle: oklch(0.2 0.04 155);
130
130
  --success-muted: oklch(0.26 0.06 155);
131
+ --success-text: oklch(0.76 0.15 155);
131
132
 
132
133
  --warning: oklch(0.78 0.18 75);
133
134
  --warning-foreground: oklch(0.15 0.02 75);
134
135
  --warning-subtle: oklch(0.22 0.04 75);
135
136
  --warning-muted: oklch(0.28 0.06 75);
137
+ --warning-text: oklch(0.82 0.15 75);
136
138
 
137
139
  --destructive: oklch(0.63 0.24 27.33);
138
140
  --destructive-foreground: oklch(0.1 0.01 27.33);
139
141
  --destructive-subtle: oklch(0.22 0.06 27.33);
140
142
  --destructive-muted: oklch(0.28 0.08 27.33);
143
+ --destructive-text: oklch(0.74 0.16 27.33);
141
144
 
142
145
  --info: oklch(0.65 0.16 250);
143
146
  --info-foreground: oklch(0.1 0.01 250);
144
147
  --info-subtle: oklch(0.2 0.04 250);
145
148
  --info-muted: oklch(0.26 0.06 250);
149
+ --info-text: oklch(0.76 0.12 250);
146
150
 
147
151
  --background: oklch(0.13 0.01 285.82);
148
152
  --foreground: oklch(0.93 0.005 285.82);
@@ -151,7 +155,7 @@
151
155
  --popover: oklch(0.18 0.008 285.82);
152
156
  --popover-foreground: oklch(0.93 0.005 285.82);
153
157
  --muted: oklch(0.2 0.005 286.38);
154
- --muted-foreground: oklch(0.6 0.01 285.82);
158
+ --muted-foreground: oklch(0.62 0.01 285.82);
155
159
 
156
160
  --border: oklch(0.24 0.004 286.32);
157
161
  --input: oklch(0.32 0.005 286.32);
@@ -3,6 +3,13 @@
3
3
  *
4
4
  * Source of truth for all visual tokens.
5
5
  * Consumed by Tailwind CSS v4 via @theme in tailwind.css.
6
+ *
7
+ * Contrast: text pairs reach WCAG AA (4.5:1) in light and dark mode, the focus
8
+ * ring 3:1. `npm run theme:contrast` (scripts/check-contrast.mjs) measures
9
+ * them and runs in CI. A status color (--success, --warning, --info,
10
+ * --destructive) is a fill; text in a status color uses its `--*-text` token
11
+ * (`text-success-text`, ...), which stays readable on the canvas, the card,
12
+ * the `*-subtle` surface and the badge tints.
6
13
  */
7
14
 
8
15
  :root {
@@ -21,39 +28,43 @@
21
28
  --secondary-foreground: oklch(0.45 0.01 286);
22
29
 
23
30
  /* ── Destructive ── */
24
- --destructive: oklch(0.577 0.245 27.33);
31
+ --destructive: oklch(0.56 0.23 27.33);
25
32
  --destructive-foreground: oklch(0.98 0 0);
26
33
  --destructive-subtle: oklch(0.95 0.05 27.33);
27
34
  --destructive-muted: oklch(0.88 0.08 27.33);
35
+ --destructive-text: oklch(0.48 0.2 27.33);
28
36
 
29
37
  /* ── Success ── */
30
- --success: oklch(0.55 0.17 155);
38
+ --success: oklch(0.52 0.16 155);
31
39
  --success-foreground: oklch(0.98 0 0);
32
40
  --success-subtle: oklch(0.95 0.04 155);
33
41
  --success-muted: oklch(0.88 0.06 155);
42
+ --success-text: oklch(0.45 0.13 155);
34
43
 
35
44
  /* ── Warning ── */
36
45
  --warning: oklch(0.75 0.18 75);
37
46
  --warning-foreground: oklch(0.18 0.02 75);
38
47
  --warning-subtle: oklch(0.96 0.04 75);
39
48
  --warning-muted: oklch(0.9 0.06 75);
49
+ --warning-text: oklch(0.48 0.11 60);
40
50
 
41
51
  /* ── Info ── */
42
- --info: oklch(0.58 0.16 250);
52
+ --info: oklch(0.54 0.16 250);
43
53
  --info-foreground: oklch(0.98 0 0);
44
54
  --info-subtle: oklch(0.95 0.04 250);
45
55
  --info-muted: oklch(0.88 0.06 250);
56
+ --info-text: oklch(0.47 0.15 250);
46
57
 
47
58
  /* ── Neutral (Surface & Structure) ── */
48
59
  --muted: oklch(0.97 0.001 286);
49
- --muted-foreground: oklch(0.58 0.008 286);
60
+ --muted-foreground: oklch(0.52 0.008 286);
50
61
  --accent: oklch(0.97 0.001 286);
51
62
  --accent-foreground: oklch(0.21 0.014 285.82);
52
63
 
53
64
  /* ── Structure ── */
54
65
  --border: oklch(0.975 0.001 286);
55
66
  --input: oklch(0.89 0.004 286);
56
- --ring: oklch(0.708 0.028 256.85);
67
+ --ring: oklch(0.64 0.03 256.85);
57
68
 
58
69
  /* ── Overlays ── */
59
70
  --popover: oklch(1 0 0);
@@ -117,7 +128,10 @@
117
128
  --space-16: 64px;
118
129
  --space-20: 80px;
119
130
 
120
- /* ── Typography Scale ── */
131
+ /* ── Typography Scale ──
132
+ Public override points: no engine component reads --text-* today (the
133
+ components use Tailwind text utilities). Hosts may set or read them, so
134
+ they stay; do not remove them as unused. */
121
135
  --text-display: clamp(1.75rem, 4vw, 2rem); /* 32px — hero, page title destaque */
122
136
  --text-h1: 1.5rem; /* 24px — page title (1 per page) */
123
137
  --text-h2: 1.25rem; /* 20px — section title */
@@ -158,7 +172,10 @@
158
172
  --breakpoint-xl: 1280px;
159
173
  --breakpoint-2xl: 1536px;
160
174
 
161
- /* ── Component Sizing (touch targets) ── */
175
+ /* ── Component Sizing (touch targets) ──
176
+ Public override points: no engine component reads --size-* today
177
+ (tailwind-theme.css maps some of them, but no utility uses the mapping).
178
+ Hosts may set or read them, so they stay; do not remove them as unused. */
162
179
  --size-button-sm: 32px;
163
180
  --size-button-md: 36px;
164
181
  --size-button-lg: 44px;
@@ -169,7 +186,10 @@
169
186
  --size-avatar-md: 32px;
170
187
  --size-avatar-lg: 40px;
171
188
 
172
- /* ── Z-Index Scale ── */
189
+ /* ── Z-Index Scale ──
190
+ Public override points: only --z-toast is read by the engine (tailwind.css,
191
+ page progress bar). The rest are kept for hosts to set or read; do not
192
+ remove them as unused. */
173
193
  --z-base: 0;
174
194
  --z-sticky: 10;
175
195
  --z-dropdown: 20;
@@ -179,7 +199,9 @@
179
199
  --z-toast: 60;
180
200
  --z-command: 100;
181
201
 
182
- /* ── Border Radius Scale (Maia) ── */
202
+ /* ── Border Radius Scale (Maia) ──
203
+ Single source of the radius values: tailwind-theme.css, theme.css and the
204
+ named themes reference these, they do not redeclare them. */
183
205
  --radius-none: 0px;
184
206
  --radius-sm: 4px;
185
207
  --radius-md: 6px;
@@ -210,28 +232,32 @@
210
232
  --destructive-foreground: oklch(0.1 0.01 27.33);
211
233
  --destructive-subtle: oklch(0.22 0.06 27.33);
212
234
  --destructive-muted: oklch(0.28 0.08 27.33);
235
+ --destructive-text: oklch(0.74 0.16 27.33);
213
236
 
214
237
  /* ── Success ── */
215
238
  --success: oklch(0.62 0.17 155);
216
239
  --success-foreground: oklch(0.1 0.01 155);
217
240
  --success-subtle: oklch(0.2 0.04 155);
218
241
  --success-muted: oklch(0.26 0.06 155);
242
+ --success-text: oklch(0.76 0.15 155);
219
243
 
220
244
  /* ── Warning ── */
221
245
  --warning: oklch(0.78 0.18 75);
222
246
  --warning-foreground: oklch(0.15 0.02 75);
223
247
  --warning-subtle: oklch(0.22 0.04 75);
224
248
  --warning-muted: oklch(0.28 0.06 75);
249
+ --warning-text: oklch(0.82 0.15 75);
225
250
 
226
251
  /* ── Info ── */
227
252
  --info: oklch(0.65 0.16 250);
228
253
  --info-foreground: oklch(0.1 0.01 250);
229
254
  --info-subtle: oklch(0.2 0.04 250);
230
255
  --info-muted: oklch(0.26 0.06 250);
256
+ --info-text: oklch(0.76 0.12 250);
231
257
 
232
258
  /* ── Neutral (Surface & Structure) ── */
233
259
  --muted: oklch(0.2 0.005 286.38);
234
- --muted-foreground: oklch(0.6 0.01 285.82);
260
+ --muted-foreground: oklch(0.62 0.01 285.82);
235
261
  --accent: oklch(0.22 0.005 286.38);
236
262
  --accent-foreground: oklch(0.9 0.005 285.82);
237
263
 
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Boundary helpers for block data sent by a PHP producer.
3
+ *
4
+ * PHP encodes an empty associative array as a JSON list (`[]`), so the wire
5
+ * contract accepts `[]` wherever a map may be empty: table and card rows,
6
+ * `filters`, `filters.applied` and a column's `statusMap`. Blocks normalise
7
+ * those values here, once, before rendering. Open enums arrive as any string;
8
+ * `knownValue` keeps a value the renderer supports and drops the rest, so the
9
+ * caller falls back to its default.
10
+ */
11
+
12
+ /** A map as PHP may send it: the map, or `[]` when it is empty. */
13
+ export type PhpMap<T extends object> = T | [];
14
+
15
+ /** The map, or `undefined` when PHP sent an empty list or nothing. */
16
+ export function mapOrUndefined<T extends object>(
17
+ value: PhpMap<T> | null | undefined,
18
+ ): T | undefined {
19
+ if (value == null || Array.isArray(value)) return undefined;
20
+ return value;
21
+ }
22
+
23
+ /** Rows with every `[]` row turned into an empty record. */
24
+ export function normalizeRows(
25
+ rows: ReadonlyArray<PhpMap<Record<string, unknown>>>,
26
+ ): Record<string, unknown>[] {
27
+ return rows.map((row) => (Array.isArray(row) ? {} : row));
28
+ }
29
+
30
+ /** Applied filter values, as PHP may send them. */
31
+ type AppliedFilterValues = Record<string, string | string[]>;
32
+
33
+ /**
34
+ * A table's `filters` with `[]` normalised: no filters when the whole slot is
35
+ * an empty list, and no applied values when `applied` is one.
36
+ */
37
+ export function normalizeFilters<TFilter>(
38
+ filters:
39
+ | PhpMap<{ available: TFilter[]; applied: PhpMap<AppliedFilterValues> }>
40
+ | null
41
+ | undefined,
42
+ ): { available: TFilter[]; applied: AppliedFilterValues } | undefined {
43
+ const slot = mapOrUndefined(filters);
44
+ if (slot === undefined) return undefined;
45
+ return { available: slot.available, applied: mapOrUndefined(slot.applied) ?? {} };
46
+ }
47
+
48
+ /** The value when it is one of `known`, otherwise `undefined`. */
49
+ export function knownValue<T extends string>(
50
+ value: string | null | undefined,
51
+ known: readonly T[],
52
+ ): T | undefined {
53
+ return value != null && (known as readonly string[]).includes(value) ? (value as T) : undefined;
54
+ }