@surreal-ui/catalog 0.12.0 → 0.14.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 (40) hide show
  1. package/README.md +16 -16
  2. package/dist/{chunk-ZYD3ZW7Q.js → chunk-FJC5GAN5.js} +1 -0
  3. package/dist/{chunk-BV22DQWK.js → chunk-K6AAK2NB.js} +121 -0
  4. package/dist/chunk-SMMBRN3D.js +41 -0
  5. package/dist/components.css +50 -0
  6. package/dist/index.js +1 -1
  7. package/dist/lazy.js +2 -1
  8. package/dist/node.d.ts +24 -1
  9. package/dist/node.js +90 -0
  10. package/dist/react/editor.js +1 -1
  11. package/dist/react/flair.js +1 -1
  12. package/dist/react/index.d.ts +34 -1
  13. package/dist/react/index.js +10 -0
  14. package/dist/react-FUBLM3VE.js +8 -0
  15. package/dist/registry.d.ts +8 -0
  16. package/dist/sources/bar-chart/react.tsx +1 -1
  17. package/dist/sources/braid/react.tsx +1 -1
  18. package/dist/sources/donut-chart/react.tsx +1 -1
  19. package/dist/sources/flow/react.tsx +1 -1
  20. package/dist/sources/gauge/react.tsx +1 -1
  21. package/dist/sources/line-chart/react.tsx +1 -1
  22. package/dist/sources/lineage/react.tsx +1 -1
  23. package/dist/sources/mindmap/react.tsx +1 -1
  24. package/dist/sources/sparkline/react.tsx +1 -1
  25. package/dist/sources/table/docs.md +30 -0
  26. package/dist/sources/table/element.ts +102 -0
  27. package/dist/sources/table/react.tsx +72 -0
  28. package/dist/sources/table/style.css +48 -0
  29. package/dist/sources/table/svelte.svelte +57 -0
  30. package/dist/sources/timeline/react.tsx +1 -1
  31. package/dist/sources/weave/react.tsx +1 -1
  32. package/dist/svelte/Table.svelte +57 -0
  33. package/dist/svelte/index.d.ts +1 -0
  34. package/dist/svelte/index.js +1 -0
  35. package/dist/svelte/lazy.js +1 -0
  36. package/dist/web/index.d.ts +19 -1
  37. package/dist/web/index.js +93 -0
  38. package/llms.txt +1 -0
  39. package/package.json +1 -1
  40. package/skills/surreal-use/references/components.md +1 -0
package/README.md CHANGED
@@ -40,22 +40,22 @@ npm install @surreal-ui/catalog
40
40
 
41
41
  React 18+ or Svelte 5. Install `@pixerate/flair` or `@pixerate/editor` only if you use the components that come from them.
42
42
 
43
- | Entry point | What it has |
44
- | ------------------------------------ | ---------------------------------------------------------------------------- |
45
- | `@surreal-ui/catalog` | The catalog API: components, categories, aesthetics, contracts, packs |
46
- | `@surreal-ui/catalog/lazy` | The same metadata, with each React component loaded on demand |
47
- | `@surreal-ui/catalog/react` | React components |
48
- | `@surreal-ui/catalog/react/flair` | Components drawn by Flair (needs `@pixerate/flair`) |
49
- | `@surreal-ui/catalog/react/editor` | Charts from editor (needs `@pixerate/editor`) |
50
- | `@surreal-ui/catalog/svelte` | Svelte 5 components (`/svelte/lazy` to load them on demand) |
51
- | `@surreal-ui/catalog/components.css` | The styles every component needs |
52
- | `@surreal-ui/catalog/aesthetics/*` | One CSS pack per aesthetic, e.g. `@surreal-ui/catalog/aesthetics/ink.css` |
53
- | `@surreal-ui/catalog/web` | WebComponents: importing it defines `<surreal-button>`, `<surreal-theme>`, … |
54
- | `@surreal-ui/catalog/node` | `installSkills` (Node only) |
55
- | `@surreal-ui/catalog/naming` | Naming helpers shared by the packages, the CLI and the service |
56
- | `@surreal-ui/catalog/registry` | The hosted registry's item types (shadcn registry-item compatible) |
57
- | `@surreal-ui/catalog/theme` | A `Theme` as Tailwind v4 custom properties |
58
- | `@surreal-ui/catalog/look` | The deterministic look checks (contrast, hit targets, reduced motion) |
43
+ | Entry point | What it has |
44
+ | ------------------------------------ | ----------------------------------------------------------------------------- |
45
+ | `@surreal-ui/catalog` | The catalog API: components, categories, aesthetics, contracts, packs |
46
+ | `@surreal-ui/catalog/lazy` | The same metadata, with each React component loaded on demand |
47
+ | `@surreal-ui/catalog/react` | React components, and `useRoleColors` for components drawn by a provider |
48
+ | `@surreal-ui/catalog/react/flair` | Components drawn by Flair (needs `@pixerate/flair`) |
49
+ | `@surreal-ui/catalog/react/editor` | Charts and diagrams from editor (needs `@pixerate/editor`; diagrams `dagre`) |
50
+ | `@surreal-ui/catalog/svelte` | Svelte 5 components (`/svelte/lazy` to load them on demand) |
51
+ | `@surreal-ui/catalog/components.css` | The styles every component needs |
52
+ | `@surreal-ui/catalog/aesthetics/*` | One CSS pack per aesthetic, e.g. `@surreal-ui/catalog/aesthetics/ink.css` |
53
+ | `@surreal-ui/catalog/web` | WebComponents: importing it defines `<surreal-button>`, `<surreal-theme>`, … |
54
+ | `@surreal-ui/catalog/node` | `installSkills`, `catalogRegistryItem` (what `surreal add` copies; Node only) |
55
+ | `@surreal-ui/catalog/naming` | Naming helpers shared by the packages, the CLI and the service |
56
+ | `@surreal-ui/catalog/registry` | The hosted registry's item types (shadcn registry-item compatible) |
57
+ | `@surreal-ui/catalog/theme` | A `Theme` as Tailwind v4 custom properties |
58
+ | `@surreal-ui/catalog/look` | The deterministic look checks (contrast, hit targets, reduced motion) |
59
59
 
60
60
  ## 🚀 Drop in
61
61
 
@@ -67,5 +67,6 @@ function useRoleColors(ref, roles) {
67
67
  }
68
68
 
69
69
  export {
70
+ readRoleColors,
70
71
  useRoleColors
71
72
  };
@@ -2518,6 +2518,127 @@ var CATALOG = {
2518
2518
  }
2519
2519
  ]
2520
2520
  },
2521
+ {
2522
+ "id": "table",
2523
+ "name": "Table",
2524
+ "description": "Rows and columns of data with a caption, column headings and optional row headings; numbers line up on the right.",
2525
+ "tags": [
2526
+ "display",
2527
+ "data"
2528
+ ],
2529
+ "group": "baseline",
2530
+ "contract": {
2531
+ "props": {
2532
+ "type": "object",
2533
+ "properties": {
2534
+ "caption": {
2535
+ "type": "string",
2536
+ "description": "What the table shows; also its accessible name."
2537
+ },
2538
+ "columns": {
2539
+ "type": "array",
2540
+ "items": {
2541
+ "type": "string"
2542
+ },
2543
+ "minItems": 1,
2544
+ "description": "Column headings, in order."
2545
+ },
2546
+ "rows": {
2547
+ "type": "array",
2548
+ "items": {
2549
+ "type": "array",
2550
+ "items": {
2551
+ "type": [
2552
+ "string",
2553
+ "number",
2554
+ "null"
2555
+ ]
2556
+ }
2557
+ },
2558
+ "description": "Rows of cells, one per column; null for an empty cell."
2559
+ },
2560
+ "rowHeaders": {
2561
+ "type": "boolean",
2562
+ "description": "The first cell of each row names the row."
2563
+ }
2564
+ },
2565
+ "required": [
2566
+ "columns",
2567
+ "rows"
2568
+ ],
2569
+ "additionalProperties": false
2570
+ },
2571
+ "state": [],
2572
+ "events": [],
2573
+ "a11y": {
2574
+ "role": "table",
2575
+ "keyboard": {},
2576
+ "labelFrom": "prop"
2577
+ },
2578
+ "colorRoles": [
2579
+ "surface-raised",
2580
+ "border",
2581
+ "ink",
2582
+ "ink-muted"
2583
+ ],
2584
+ "motion": false,
2585
+ "sizing": {
2586
+ "mode": "fill",
2587
+ "minWidth": 200
2588
+ }
2589
+ },
2590
+ "examples": [
2591
+ {
2592
+ "name": "revenue",
2593
+ "props": {
2594
+ "caption": "Quarterly revenue (k)",
2595
+ "columns": [
2596
+ "Quarter",
2597
+ "2025",
2598
+ "2026"
2599
+ ],
2600
+ "rows": [
2601
+ [
2602
+ "Q1",
2603
+ 120,
2604
+ 140
2605
+ ],
2606
+ [
2607
+ "Q2",
2608
+ 135,
2609
+ 152
2610
+ ],
2611
+ [
2612
+ "Q3",
2613
+ 128,
2614
+ null
2615
+ ],
2616
+ [
2617
+ "Q4",
2618
+ 160,
2619
+ 181
2620
+ ]
2621
+ ],
2622
+ "rowHeaders": true
2623
+ }
2624
+ }
2625
+ ],
2626
+ "source": {
2627
+ "provider": "manual"
2628
+ },
2629
+ "category": "display",
2630
+ "runtime": "code",
2631
+ "platforms": [
2632
+ "react",
2633
+ "svelte",
2634
+ "web"
2635
+ ],
2636
+ "entry": "@surreal-ui/catalog/react",
2637
+ "export": "Table",
2638
+ "contentHash": "a03aa01420e3c6b9925bcf8286364b10bd396c4323909ab328e1baa383a32231",
2639
+ "path": "components/table",
2640
+ "alternatives": []
2641
+ },
2521
2642
  {
2522
2643
  "id": "textarea",
2523
2644
  "name": "Textarea",
@@ -0,0 +1,41 @@
1
+ // ../../components/table/react.tsx
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ function numericColumns(columns, rows) {
4
+ return columns.map(
5
+ (_, c) => rows.some((r) => typeof r[c] === "number") && rows.every((r) => r[c] === null || r[c] === void 0 || typeof r[c] === "number")
6
+ );
7
+ }
8
+ function Table({ caption, columns, rows, rowHeaders, className, ...props }) {
9
+ const numeric = numericColumns(columns, rows);
10
+ return /* @__PURE__ */ jsx("div", { className: "sui-table", children: /* @__PURE__ */ jsxs("table", { className: ["sui-table__table", className].filter(Boolean).join(" "), ...props, children: [
11
+ caption && /* @__PURE__ */ jsx("caption", { className: "sui-table__caption", children: caption }),
12
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((column, i) => /* @__PURE__ */ jsx(
13
+ "th",
14
+ {
15
+ scope: "col",
16
+ className: "sui-table__heading",
17
+ "data-numeric": numeric[i] || void 0,
18
+ children: column
19
+ },
20
+ i
21
+ )) }) }),
22
+ /* @__PURE__ */ jsx("tbody", { children: rows.map((row, r) => /* @__PURE__ */ jsx("tr", { children: columns.map((_, c) => {
23
+ const cell = row[c] ?? null;
24
+ const text = cell === null ? "" : String(cell);
25
+ return rowHeaders && c === 0 ? /* @__PURE__ */ jsx("th", { scope: "row", className: "sui-table__row-heading", children: text }, c) : /* @__PURE__ */ jsx(
26
+ "td",
27
+ {
28
+ className: "sui-table__cell",
29
+ "data-numeric": typeof cell === "number" || void 0,
30
+ children: text
31
+ },
32
+ c
33
+ );
34
+ }) }, r)) })
35
+ ] }) });
36
+ }
37
+
38
+ export {
39
+ numericColumns,
40
+ Table
41
+ };
@@ -441,6 +441,56 @@
441
441
  }
442
442
 
443
443
 
444
+ /* table */
445
+ /* A data table: wide tables scroll sideways inside their box rather than the page. */
446
+ .sui-table {
447
+ max-width: 100%;
448
+ overflow-x: auto;
449
+ background: var(--sui-surface-raised);
450
+ border: var(--sui-border-width, 1px) solid var(--sui-border);
451
+ border-radius: var(--sui-radius, 6px);
452
+ }
453
+ .sui-table__table {
454
+ width: 100%;
455
+ border-collapse: collapse;
456
+ color: var(--sui-ink);
457
+ font: 400 14px/1.45 var(--sui-font, system-ui, sans-serif);
458
+ font-variant-numeric: tabular-nums;
459
+ }
460
+ .sui-table__caption {
461
+ caption-side: top;
462
+ padding: 12px 14px 4px;
463
+ text-align: left;
464
+ color: var(--sui-ink);
465
+ font-weight: 600;
466
+ }
467
+ .sui-table__heading,
468
+ .sui-table__row-heading,
469
+ .sui-table__cell {
470
+ padding: 8px 14px;
471
+ text-align: left;
472
+ vertical-align: top;
473
+ }
474
+ .sui-table__heading {
475
+ color: var(--sui-ink-muted);
476
+ font-size: 12px;
477
+ font-weight: 600;
478
+ letter-spacing: 0.02em;
479
+ border-bottom: var(--sui-border-width, 1px) solid var(--sui-border);
480
+ }
481
+ .sui-table__row-heading {
482
+ font-weight: 600;
483
+ }
484
+ .sui-table__cell[data-numeric] {
485
+ text-align: right;
486
+ }
487
+ .sui-table__heading[data-numeric] {
488
+ text-align: right;
489
+ }
490
+ .sui-table__table tbody tr + tr > * {
491
+ border-top: var(--sui-border-width, 1px) solid var(--sui-border);
492
+ }
493
+
444
494
  /* textarea */
445
495
  .sui-textarea {
446
496
  display: flex;
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  getComponent,
17
17
  replacementFor,
18
18
  resolveRole
19
- } from "./chunk-BV22DQWK.js";
19
+ } from "./chunk-K6AAK2NB.js";
20
20
  import {
21
21
  mapDeprecatedProps,
22
22
  resolveStructure
package/dist/lazy.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  getAesthetic,
12
12
  getComponent,
13
13
  replacementFor
14
- } from "./chunk-BV22DQWK.js";
14
+ } from "./chunk-K6AAK2NB.js";
15
15
  import "./chunk-HMNTTISG.js";
16
16
 
17
17
  // src/lazy.generated.ts
@@ -28,6 +28,7 @@ var REACT_LOADERS = {
28
28
  "skeleton": () => import("./react-DXQG3CE5.js").then((m) => m.Skeleton),
29
29
  "spinner": () => import("./react-NUMFK32C.js").then((m) => m.Spinner),
30
30
  "switch": () => import("./react-AGH5W4PH.js").then((m) => m.Switch),
31
+ "table": () => import("./react-FUBLM3VE.js").then((m) => m.Table),
31
32
  "textarea": () => import("./react-XUETU4ES.js").then((m) => m.Textarea)
32
33
  };
33
34
 
package/dist/node.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ import { CatalogComponent } from './index.js';
2
+ import { RegistryItem } from './registry.js';
3
+ import { PlatformLanguage } from '@pixerate/schemas';
4
+ import '@pixerate/schemas/genui';
5
+ import './theme-V1Iz-HmC.js';
6
+
1
7
  /** The skills in the package, by folder name. */
2
8
  declare const SURREAL_SKILLS: readonly [{
3
9
  readonly name: "surreal-use";
@@ -42,4 +48,21 @@ declare function skillsSource(): string;
42
48
  */
43
49
  declare function installSkills(options?: InstallSkillsOptions): InstalledSkills;
44
50
 
45
- export { DEFAULT_SKILLS_DIR, type InstallSkillsOptions, type InstalledSkillFile, type InstalledSkills, SURREAL_SKILLS, type SurrealSkillName, installSkills, skillsSource };
51
+ /** This package's dist folder: beside the built module, or ../dist from the sources. */
52
+ declare function catalogDistDir(): string;
53
+ /**
54
+ * The npm packages a component's code imports (bare specifiers, by package name), plus the peers
55
+ * those entries need, without the framework itself. Sorted.
56
+ */
57
+ declare function codeDependencies(code: string): string[];
58
+ /** The frameworks this release ships a type's source for. */
59
+ declare function catalogFrameworks(component: CatalogComponent, dist?: string): PlatformLanguage[];
60
+ /**
61
+ * The files `surreal add` writes for a catalog type: its implementation for the framework, its
62
+ * stylesheet and the aesthetic's pack, with every package the code imports as a dependency (for an
63
+ * engine type, its provider). Null if the release has no source for that framework; throws for an
64
+ * unknown aesthetic.
65
+ */
66
+ declare function catalogRegistryItem(component: CatalogComponent, framework: PlatformLanguage, aestheticId: string, dist?: string): RegistryItem | null;
67
+
68
+ export { DEFAULT_SKILLS_DIR, type InstallSkillsOptions, type InstalledSkillFile, type InstalledSkills, SURREAL_SKILLS, type SurrealSkillName, catalogDistDir, catalogFrameworks, catalogRegistryItem, codeDependencies, installSkills, skillsSource };
package/dist/node.js CHANGED
@@ -1,3 +1,9 @@
1
+ import {
2
+ AESTHETICS,
3
+ getAesthetic
4
+ } from "./chunk-K6AAK2NB.js";
5
+ import "./chunk-HMNTTISG.js";
6
+
1
7
  // src/skills.ts
2
8
  import fs from "fs";
3
9
  import path from "path";
@@ -67,9 +73,93 @@ function installSkills(options = {}) {
67
73
  }
68
74
  return { dir, skills: wanted, files };
69
75
  }
76
+
77
+ // src/registry-item.ts
78
+ import fs2 from "fs";
79
+ import path2 from "path";
80
+ import { fileURLToPath as fileURLToPath2 } from "url";
81
+ var SOURCE = {
82
+ react: { file: "react.tsx", ext: "tsx" },
83
+ svelte: { file: "svelte.svelte", ext: "svelte" },
84
+ webcomponent: { file: "element.ts", ext: "ts" }
85
+ };
86
+ var FRAMEWORKS = /* @__PURE__ */ new Set(["react", "react-dom", "svelte"]);
87
+ var ENTRY_PEERS = {
88
+ // Diagram layout (diagramUiComponents) needs dagre.
89
+ "@pixerate/editor/canvas": ["@dagrejs/dagre"]
90
+ };
91
+ function catalogDistDir() {
92
+ const here = path2.dirname(fileURLToPath2(import.meta.url));
93
+ return fs2.existsSync(path2.join(here, "sources")) ? here : path2.resolve(here, "../dist");
94
+ }
95
+ function codeDependencies(code) {
96
+ const deps = /* @__PURE__ */ new Set();
97
+ for (const m of code.matchAll(/(?:from\s+|import\s+|import\()\s*['"]([^'"./][^'"]*)['"]/g)) {
98
+ const spec = m[1];
99
+ const parts = spec.split("/");
100
+ const name = spec.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
101
+ if (FRAMEWORKS.has(name)) continue;
102
+ deps.add(name);
103
+ for (const peer of ENTRY_PEERS[spec] ?? []) deps.add(peer);
104
+ }
105
+ return [...deps].sort();
106
+ }
107
+ function catalogFrameworks(component, dist = catalogDistDir()) {
108
+ const dir = path2.join(dist, "sources", component.id);
109
+ return Object.keys(SOURCE).filter(
110
+ (f) => fs2.existsSync(path2.join(dir, SOURCE[f].file))
111
+ );
112
+ }
113
+ function catalogRegistryItem(component, framework, aestheticId, dist = catalogDistDir()) {
114
+ const src = SOURCE[framework];
115
+ const dir = path2.join(dist, "sources", component.id);
116
+ const main = path2.join(dir, src.file);
117
+ if (!fs2.existsSync(main)) return null;
118
+ if (!getAesthetic(aestheticId))
119
+ throw new Error(
120
+ `Unknown aesthetic "${aestheticId}". Available: ${AESTHETICS.map((a) => a.id).join(", ")}`
121
+ );
122
+ const code = fs2.readFileSync(main, "utf8");
123
+ const files = [
124
+ { path: `${component.export}.${src.ext}`, content: code, type: "registry:ui" }
125
+ ];
126
+ const style = path2.join(dir, "style.css");
127
+ if (fs2.existsSync(style))
128
+ files.push({
129
+ path: `${component.id}.css`,
130
+ content: fs2.readFileSync(style, "utf8"),
131
+ type: "registry:ui"
132
+ });
133
+ files.push({
134
+ path: `aesthetic-${aestheticId}.css`,
135
+ content: fs2.readFileSync(path2.join(dist, "aesthetics", `${aestheticId}.css`), "utf8"),
136
+ type: "registry:ui"
137
+ });
138
+ return {
139
+ name: component.id,
140
+ type: "registry:ui",
141
+ title: component.name,
142
+ description: component.description,
143
+ dependencies: codeDependencies(code),
144
+ files,
145
+ meta: {
146
+ aestheticId,
147
+ componentTypeId: component.id,
148
+ version: component.source.version ?? "",
149
+ framework,
150
+ symbolName: component.export,
151
+ runtime: component.runtime,
152
+ ...component.source.provider !== "manual" ? { provider: component.source.provider } : {}
153
+ }
154
+ };
155
+ }
70
156
  export {
71
157
  DEFAULT_SKILLS_DIR,
72
158
  SURREAL_SKILLS,
159
+ catalogDistDir,
160
+ catalogFrameworks,
161
+ catalogRegistryItem,
162
+ codeDependencies,
73
163
  installSkills,
74
164
  skillsSource
75
165
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useRoleColors
3
- } from "../chunk-ZYD3ZW7Q.js";
3
+ } from "../chunk-FJC5GAN5.js";
4
4
 
5
5
  // ../../components/bar-chart/react.tsx
6
6
  import * as React from "react";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useRoleColors
3
- } from "../chunk-ZYD3ZW7Q.js";
3
+ } from "../chunk-FJC5GAN5.js";
4
4
 
5
5
  // ../../components/gauge/react.tsx
6
6
  import * as React from "react";
@@ -23,6 +23,25 @@ declare function withAesthetic<P extends object>(Component: React.ComponentType<
23
23
  /** An old aesthetic-prefixed export as the type plus its aesthetic, with the old props mapped. */
24
24
  declare function deprecatedAlias<P extends object>(Component: React.ComponentType<P>, spec: DeprecatedSpec): React.ForwardRefExoticComponent<Record<string, unknown> & React.RefAttributes<unknown>>;
25
25
 
26
+ /**
27
+ * For components synced from providers (Flair, editor): the aesthetic's colour roles and colour
28
+ * scheme where the component sits, read from the `--sui-<role>` variables its aesthetic pack sets.
29
+ * They are read after mount and again whenever an ancestor's class, data-theme or data-aesthetic
30
+ * changes, or the OS colour scheme does, so switching aesthetic or theme restyles them.
31
+ */
32
+ type Rgb = [number, number, number];
33
+ interface RoleColors {
34
+ /** Role → CSS colour as computed (`rgb(…)`). */
35
+ css: Record<string, string>;
36
+ /** Role → [r, g, b] in 0–1, as Flair's colour controls take. */
37
+ rgb: Record<string, Rgb>;
38
+ scheme: 'light' | 'dark';
39
+ }
40
+ /** Reads the roles at an element. Undefined until every role resolves (no aesthetic pack loaded yet). */
41
+ declare function readRoleColors(el: Element, roles: readonly string[]): RoleColors | undefined;
42
+ /** The roles at `ref`, kept current as aesthetics and themes change. */
43
+ declare function useRoleColors(ref: React.RefObject<Element | null>, roles: readonly string[]): RoleColors | undefined;
44
+
26
45
  interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
27
46
  tone?: 'neutral' | 'accent' | 'danger';
28
47
  }
@@ -116,6 +135,20 @@ interface SwitchProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>
116
135
  }
117
136
  declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
118
137
 
138
+ type TableCell = string | number | null;
139
+ interface TableProps extends Omit<React.TableHTMLAttributes<HTMLTableElement>, 'children'> {
140
+ /** What the table shows; also its accessible name. */
141
+ caption?: string;
142
+ /** Column headings, in order. */
143
+ columns: string[];
144
+ /** Rows of cells, one per column; null for an empty cell. */
145
+ rows: TableCell[][];
146
+ /** The first cell of each row names the row. */
147
+ rowHeaders?: boolean;
148
+ }
149
+ /** A data table: a caption, column headings and rows; numbers line up on the right. */
150
+ declare function Table({ caption, columns, rows, rowHeaders, className, ...props }: TableProps): React.JSX.Element;
151
+
119
152
  interface TextareaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'> {
120
153
  label?: string;
121
154
  onValueChange?: (value: string) => void;
@@ -123,4 +156,4 @@ interface TextareaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaEl
123
156
  }
124
157
  declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
125
158
 
126
- export { Badge, type BadgeProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, DeprecatedSpec, Input, type InputProps, Kbd, type KbdProps, Label, type LabelProps, Progress, type ProgressProps, Separator, type SeparatorProps, Skeleton, type SkeletonProps, Spinner, type SpinnerProps, SurrealTheme, type SurrealThemeProps, Switch, type SwitchProps, Textarea, type TextareaProps, ThemeMode, deprecatedAlias, useAesthetic, useStructure, withAesthetic };
159
+ export { Badge, type BadgeProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, DeprecatedSpec, Input, type InputProps, Kbd, type KbdProps, Label, type LabelProps, Progress, type ProgressProps, type Rgb, type RoleColors, Separator, type SeparatorProps, Skeleton, type SkeletonProps, Spinner, type SpinnerProps, SurrealTheme, type SurrealThemeProps, Switch, type SwitchProps, Table, type TableProps, Textarea, type TextareaProps, ThemeMode, deprecatedAlias, readRoleColors, useAesthetic, useRoleColors, useStructure, withAesthetic };
@@ -1,3 +1,6 @@
1
+ import {
2
+ Table
3
+ } from "../chunk-SMMBRN3D.js";
1
4
  import {
2
5
  Textarea
3
6
  } from "../chunk-GPANDAGY.js";
@@ -25,6 +28,10 @@ import {
25
28
  import {
26
29
  Switch
27
30
  } from "../chunk-F5CUZM5I.js";
31
+ import {
32
+ readRoleColors,
33
+ useRoleColors
34
+ } from "../chunk-FJC5GAN5.js";
28
35
  import {
29
36
  Badge
30
37
  } from "../chunk-LABYZELU.js";
@@ -57,9 +64,12 @@ export {
57
64
  Spinner,
58
65
  SurrealTheme,
59
66
  Switch,
67
+ Table,
60
68
  Textarea,
61
69
  deprecatedAlias,
70
+ readRoleColors,
62
71
  useAesthetic,
72
+ useRoleColors,
63
73
  useStructure,
64
74
  withAesthetic
65
75
  };
@@ -0,0 +1,8 @@
1
+ import {
2
+ Table,
3
+ numericColumns
4
+ } from "./chunk-SMMBRN3D.js";
5
+ export {
6
+ Table,
7
+ numericColumns
8
+ };
@@ -25,6 +25,10 @@ interface RegistryItem {
25
25
  framework: PlatformLanguage;
26
26
  themeSupport?: string;
27
27
  symbolName?: string;
28
+ /** `engine`: a provider's runtime draws it from data (#38); `code` otherwise. */
29
+ runtime?: 'code' | 'engine';
30
+ /** For a provider's component: who draws it (`editor`, `flair`). */
31
+ provider?: string;
28
32
  };
29
33
  }
30
34
  interface RegistryIndexItem {
@@ -35,6 +39,10 @@ interface RegistryIndexItem {
35
39
  aesthetics: string[];
36
40
  dependencies: string[];
37
41
  registryDependencies?: string[];
42
+ /** `engine` types (#38) are drawn by a provider's runtime; served from the catalog release. */
43
+ runtime?: 'code' | 'engine';
44
+ /** Frameworks it can be added for, when not every one. */
45
+ frameworks?: PlatformLanguage[];
38
46
  }
39
47
 
40
48
  export { DEFAULT_REGISTRY_URL, type RegistryIndexItem, type RegistryItem, type RegistryItemFile };
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.336.0 (bar-chart). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
4
+ import { useRoleColors } from '@surreal-ui/catalog/react';
5
5
 
6
6
  const ROLES = ['surface', 'ink', 'ink-muted', 'border', 'accent'] as const;
7
7
  const COMPONENT = uiComponents().find((c) => c.id === 'bar-chart')!;
@@ -2,7 +2,7 @@
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
4
  import { createLinkFocus } from '@pixerate/editor/tools';
5
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
5
+ import { useRoleColors } from '@surreal-ui/catalog/react';
6
6
 
7
7
  const ROLES = ['surface', 'ink', 'accent'] as const;
8
8
  const COMPONENT = uiComponents().find((c) => c.id === 'braid')!;
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.336.0 (donut-chart). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
4
+ import { useRoleColors } from '@surreal-ui/catalog/react';
5
5
 
6
6
  const ROLES = ['surface', 'ink', 'accent'] as const;
7
7
  const COMPONENT = uiComponents().find((c) => c.id === 'donut-chart')!;
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.336.0 (flow). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { diagramUiComponents } from '@pixerate/editor/canvas';
4
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
4
+ import { useRoleColors } from '@surreal-ui/catalog/react';
5
5
 
6
6
  const ROLES = ['surface', 'surface-raised', 'ink', 'ink-muted', 'border', 'accent'] as const;
7
7
  const COMPONENT = diagramUiComponents().find((c) => c.id === 'flow')!;
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/flair 0.121.0 (gauge). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { FlairEffect } from '@pixerate/flair/react';
4
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
4
+ import { useRoleColors } from '@surreal-ui/catalog/react';
5
5
 
6
6
  const ROLES = ['success', 'warning', 'danger', 'accent', 'surface', 'ink'] as const;
7
7
  const CONTROLS: Record<string, string> = {
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.336.0 (line-chart). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
4
+ import { useRoleColors } from '@surreal-ui/catalog/react';
5
5
 
6
6
  const ROLES = ['surface', 'ink', 'ink-muted', 'border', 'accent'] as const;
7
7
  const COMPONENT = uiComponents().find((c) => c.id === 'line-chart')!;
@@ -2,7 +2,7 @@
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
4
  import { createLinkFocus } from '@pixerate/editor/tools';
5
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
5
+ import { useRoleColors } from '@surreal-ui/catalog/react';
6
6
 
7
7
  const ROLES = ['surface', 'ink', 'ink-muted', 'accent'] as const;
8
8
  const COMPONENT = uiComponents().find((c) => c.id === 'lineage')!;
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.336.0 (mindmap). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { diagramUiComponents } from '@pixerate/editor/canvas';
4
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
4
+ import { useRoleColors } from '@surreal-ui/catalog/react';
5
5
 
6
6
  const ROLES = ['surface', 'surface-raised', 'ink', 'ink-muted', 'border', 'accent'] as const;
7
7
  const COMPONENT = diagramUiComponents().find((c) => c.id === 'mindmap')!;
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.336.0 (sparkline). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
4
+ import { useRoleColors } from '@surreal-ui/catalog/react';
5
5
 
6
6
  const ROLES = ['accent'] as const;
7
7
  const COMPONENT = uiComponents().find((c) => c.id === 'sparkline')!;
@@ -0,0 +1,30 @@
1
+ # Table
2
+
3
+ ```tsx
4
+ import { Table, SurrealTheme } from '@surreal-ui/catalog/react';
5
+
6
+ <SurrealTheme aesthetic="minimalist">
7
+ <Table
8
+ caption="Quarterly revenue (k)"
9
+ columns={['Quarter', '2025', '2026']}
10
+ rows={[
11
+ ['Q1', 120, 140],
12
+ ['Q2', 135, 152]
13
+ ]}
14
+ rowHeaders
15
+ />
16
+ </SurrealTheme>;
17
+ ```
18
+
19
+ Svelte 5: `import { Table } from '@surreal-ui/catalog/svelte'`, with the same props.
20
+
21
+ WebComponent: `import '@surreal-ui/catalog/web'`, then
22
+ `<surreal-table caption="…" columns='["Quarter","2025"]' rows='[["Q1",120]]' row-headers></surreal-table>`
23
+ (or set its `columns` and `rows` properties).
24
+
25
+ The props are the schemas' `UiTableProps`, so a data visual's fallback (a chart as a table) renders
26
+ with it directly. Cells are text, numbers or `null` (empty); numbers line up on the right with
27
+ tabular figures. A wide table scrolls sideways inside its box.
28
+
29
+ The old per-aesthetic `Table`, `TableHeader`, `TableRow`, … were a compound component with a
30
+ different API, so they stay as they are rather than becoming aliases.
@@ -0,0 +1,102 @@
1
+ import { SurrealElement, define } from '@surreal-ui/catalog/web';
2
+
3
+ type TableCell = string | number | null;
4
+
5
+ /**
6
+ * `<surreal-table caption="…" columns='["Quarter","2025"]' rows='[["Q1",120]]' row-headers>`.
7
+ * `columns` and `rows` are JSON (or set the `columns` and `rows` properties); numbers line up on
8
+ * the right.
9
+ */
10
+ export class TableElement extends SurrealElement {
11
+ static get observedAttributes() {
12
+ return ['caption', 'columns', 'rows', 'row-headers'];
13
+ }
14
+ #columns: string[] | null = null;
15
+ #rows: TableCell[][] | null = null;
16
+ get columns(): string[] {
17
+ return this.#columns ?? this.#json<string[]>('columns', []);
18
+ }
19
+ set columns(value: string[]) {
20
+ this.#columns = value;
21
+ this.render();
22
+ }
23
+ get rows(): TableCell[][] {
24
+ return this.#rows ?? this.#json<TableCell[][]>('rows', []);
25
+ }
26
+ set rows(value: TableCell[][]) {
27
+ this.#rows = value;
28
+ this.render();
29
+ }
30
+ get rowHeaders(): boolean {
31
+ return this.hasAttribute('row-headers');
32
+ }
33
+ set rowHeaders(value: boolean) {
34
+ this.toggleAttribute('row-headers', value);
35
+ }
36
+ #json<T>(name: string, fallback: T): T {
37
+ try {
38
+ return JSON.parse(this.getAttribute(name) ?? '') as T;
39
+ } catch {
40
+ return fallback;
41
+ }
42
+ }
43
+ protected render(): void {
44
+ const columns = this.columns;
45
+ const rows = this.rows;
46
+ // A column is numeric when it has a number and every other cell is a number or empty.
47
+ const numeric = columns.map(
48
+ (_, c) =>
49
+ rows.some((r) => typeof r[c] === 'number') &&
50
+ rows.every((r) => r[c] === null || r[c] === undefined || typeof r[c] === 'number')
51
+ );
52
+ const rowHeaders = this.rowHeaders;
53
+ const wrap = document.createElement('div');
54
+ wrap.className = 'sui-table';
55
+ const table = document.createElement('table');
56
+ table.className = 'sui-table__table';
57
+ const caption = this.getAttribute('caption');
58
+ if (caption) {
59
+ const c = document.createElement('caption');
60
+ c.className = 'sui-table__caption';
61
+ c.textContent = caption;
62
+ table.append(c);
63
+ }
64
+ const head = document.createElement('thead');
65
+ const headRow = document.createElement('tr');
66
+ columns.forEach((column, i) => {
67
+ const th = document.createElement('th');
68
+ th.scope = 'col';
69
+ th.className = 'sui-table__heading';
70
+ if (numeric[i]) th.dataset.numeric = 'true';
71
+ th.textContent = column;
72
+ headRow.append(th);
73
+ });
74
+ head.append(headRow);
75
+ const body = document.createElement('tbody');
76
+ for (const row of rows) {
77
+ const tr = document.createElement('tr');
78
+ columns.forEach((_, c) => {
79
+ const cell = row[c] ?? null;
80
+ const text = cell === null ? '' : String(cell);
81
+ if (rowHeaders && c === 0) {
82
+ const th = document.createElement('th');
83
+ th.scope = 'row';
84
+ th.className = 'sui-table__row-heading';
85
+ th.textContent = text;
86
+ tr.append(th);
87
+ } else {
88
+ const td = document.createElement('td');
89
+ td.className = 'sui-table__cell';
90
+ if (typeof cell === 'number') td.dataset.numeric = 'true';
91
+ td.textContent = text;
92
+ tr.append(td);
93
+ }
94
+ });
95
+ body.append(tr);
96
+ }
97
+ table.append(head, body);
98
+ wrap.append(table);
99
+ this.replaceChildren(wrap);
100
+ }
101
+ }
102
+ define('surreal-table', TableElement);
@@ -0,0 +1,72 @@
1
+ import * as React from 'react';
2
+
3
+ export type TableCell = string | number | null;
4
+
5
+ export interface TableProps extends Omit<React.TableHTMLAttributes<HTMLTableElement>, 'children'> {
6
+ /** What the table shows; also its accessible name. */
7
+ caption?: string;
8
+ /** Column headings, in order. */
9
+ columns: string[];
10
+ /** Rows of cells, one per column; null for an empty cell. */
11
+ rows: TableCell[][];
12
+ /** The first cell of each row names the row. */
13
+ rowHeaders?: boolean;
14
+ }
15
+
16
+ /** A column is numeric when it has a number and every other cell is a number or empty. */
17
+ export function numericColumns(columns: string[], rows: TableCell[][]): boolean[] {
18
+ return columns.map(
19
+ (_, c) =>
20
+ rows.some((r) => typeof r[c] === 'number') &&
21
+ rows.every((r) => r[c] === null || r[c] === undefined || typeof r[c] === 'number')
22
+ );
23
+ }
24
+
25
+ /** A data table: a caption, column headings and rows; numbers line up on the right. */
26
+ export function Table({ caption, columns, rows, rowHeaders, className, ...props }: TableProps) {
27
+ const numeric = numericColumns(columns, rows);
28
+ return (
29
+ <div className="sui-table">
30
+ <table className={['sui-table__table', className].filter(Boolean).join(' ')} {...props}>
31
+ {caption && <caption className="sui-table__caption">{caption}</caption>}
32
+ <thead>
33
+ <tr>
34
+ {columns.map((column, i) => (
35
+ <th
36
+ key={i}
37
+ scope="col"
38
+ className="sui-table__heading"
39
+ data-numeric={numeric[i] || undefined}
40
+ >
41
+ {column}
42
+ </th>
43
+ ))}
44
+ </tr>
45
+ </thead>
46
+ <tbody>
47
+ {rows.map((row, r) => (
48
+ <tr key={r}>
49
+ {columns.map((_, c) => {
50
+ const cell = row[c] ?? null;
51
+ const text = cell === null ? '' : String(cell);
52
+ return rowHeaders && c === 0 ? (
53
+ <th key={c} scope="row" className="sui-table__row-heading">
54
+ {text}
55
+ </th>
56
+ ) : (
57
+ <td
58
+ key={c}
59
+ className="sui-table__cell"
60
+ data-numeric={typeof cell === 'number' || undefined}
61
+ >
62
+ {text}
63
+ </td>
64
+ );
65
+ })}
66
+ </tr>
67
+ ))}
68
+ </tbody>
69
+ </table>
70
+ </div>
71
+ );
72
+ }
@@ -0,0 +1,48 @@
1
+ /* A data table: wide tables scroll sideways inside their box rather than the page. */
2
+ .sui-table {
3
+ max-width: 100%;
4
+ overflow-x: auto;
5
+ background: var(--sui-surface-raised);
6
+ border: var(--sui-border-width, 1px) solid var(--sui-border);
7
+ border-radius: var(--sui-radius, 6px);
8
+ }
9
+ .sui-table__table {
10
+ width: 100%;
11
+ border-collapse: collapse;
12
+ color: var(--sui-ink);
13
+ font: 400 14px/1.45 var(--sui-font, system-ui, sans-serif);
14
+ font-variant-numeric: tabular-nums;
15
+ }
16
+ .sui-table__caption {
17
+ caption-side: top;
18
+ padding: 12px 14px 4px;
19
+ text-align: left;
20
+ color: var(--sui-ink);
21
+ font-weight: 600;
22
+ }
23
+ .sui-table__heading,
24
+ .sui-table__row-heading,
25
+ .sui-table__cell {
26
+ padding: 8px 14px;
27
+ text-align: left;
28
+ vertical-align: top;
29
+ }
30
+ .sui-table__heading {
31
+ color: var(--sui-ink-muted);
32
+ font-size: 12px;
33
+ font-weight: 600;
34
+ letter-spacing: 0.02em;
35
+ border-bottom: var(--sui-border-width, 1px) solid var(--sui-border);
36
+ }
37
+ .sui-table__row-heading {
38
+ font-weight: 600;
39
+ }
40
+ .sui-table__cell[data-numeric] {
41
+ text-align: right;
42
+ }
43
+ .sui-table__heading[data-numeric] {
44
+ text-align: right;
45
+ }
46
+ .sui-table__table tbody tr + tr > * {
47
+ border-top: var(--sui-border-width, 1px) solid var(--sui-border);
48
+ }
@@ -0,0 +1,57 @@
1
+ <script lang="ts">
2
+ import type { HTMLTableAttributes } from 'svelte/elements';
3
+
4
+ type TableCell = string | number | null;
5
+
6
+ interface Props extends Omit<HTMLTableAttributes, 'children'> {
7
+ /** What the table shows; also its accessible name. */
8
+ caption?: string;
9
+ /** Column headings, in order. */
10
+ columns: string[];
11
+ /** Rows of cells, one per column; null for an empty cell. */
12
+ rows: TableCell[][];
13
+ /** The first cell of each row names the row. */
14
+ rowHeaders?: boolean;
15
+ }
16
+
17
+ let {
18
+ caption,
19
+ columns,
20
+ rows,
21
+ rowHeaders = false,
22
+ class: className = '',
23
+ ...rest
24
+ }: Props = $props();
25
+ </script>
26
+
27
+ <div class="sui-table">
28
+ <table class={['sui-table__table', className].filter(Boolean).join(' ')} {...rest}>
29
+ {#if caption}<caption class="sui-table__caption">{caption}</caption>{/if}
30
+ <thead>
31
+ <tr>
32
+ {#each columns as column, i (i)}
33
+ <th scope="col" class="sui-table__heading" data-numeric={numeric[i] || undefined}
34
+ >{column}</th
35
+ >
36
+ {/each}
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ {#each rows as row, r (r)}
41
+ <tr>
42
+ {#each columns as _, c (c)}
43
+ {@const cell = row[c] ?? null}
44
+ {#if rowHeaders && c === 0}
45
+ <th scope="row" class="sui-table__row-heading">{cell === null ? '' : String(cell)}</th
46
+ >
47
+ {:else}
48
+ <td class="sui-table__cell" data-numeric={typeof cell === 'number' || undefined}>
49
+ {cell === null ? '' : String(cell)}
50
+ </td>
51
+ {/if}
52
+ {/each}
53
+ </tr>
54
+ {/each}
55
+ </tbody>
56
+ </table>
57
+ </div>
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.336.0 (timeline). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { diagramUiComponents } from '@pixerate/editor/canvas';
4
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
4
+ import { useRoleColors } from '@surreal-ui/catalog/react';
5
5
 
6
6
  const ROLES = ['surface', 'surface-raised', 'ink', 'ink-muted', 'border', 'accent'] as const;
7
7
  const COMPONENT = diagramUiComponents().find((c) => c.id === 'timeline')!;
@@ -2,7 +2,7 @@
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
4
  import { createLinkFocus } from '@pixerate/editor/tools';
5
- import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
5
+ import { useRoleColors } from '@surreal-ui/catalog/react';
6
6
 
7
7
  const ROLES = ['surface', 'surface-raised', 'ink', 'ink-muted', 'border', 'accent'] as const;
8
8
  const COMPONENT = uiComponents().find((c) => c.id === 'weave')!;
@@ -0,0 +1,57 @@
1
+ <script lang="ts">
2
+ import type { HTMLTableAttributes } from 'svelte/elements';
3
+
4
+ type TableCell = string | number | null;
5
+
6
+ interface Props extends Omit<HTMLTableAttributes, 'children'> {
7
+ /** What the table shows; also its accessible name. */
8
+ caption?: string;
9
+ /** Column headings, in order. */
10
+ columns: string[];
11
+ /** Rows of cells, one per column; null for an empty cell. */
12
+ rows: TableCell[][];
13
+ /** The first cell of each row names the row. */
14
+ rowHeaders?: boolean;
15
+ }
16
+
17
+ let {
18
+ caption,
19
+ columns,
20
+ rows,
21
+ rowHeaders = false,
22
+ class: className = '',
23
+ ...rest
24
+ }: Props = $props();
25
+ </script>
26
+
27
+ <div class="sui-table">
28
+ <table class={['sui-table__table', className].filter(Boolean).join(' ')} {...rest}>
29
+ {#if caption}<caption class="sui-table__caption">{caption}</caption>{/if}
30
+ <thead>
31
+ <tr>
32
+ {#each columns as column, i (i)}
33
+ <th scope="col" class="sui-table__heading" data-numeric={numeric[i] || undefined}
34
+ >{column}</th
35
+ >
36
+ {/each}
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ {#each rows as row, r (r)}
41
+ <tr>
42
+ {#each columns as _, c (c)}
43
+ {@const cell = row[c] ?? null}
44
+ {#if rowHeaders && c === 0}
45
+ <th scope="row" class="sui-table__row-heading">{cell === null ? '' : String(cell)}</th
46
+ >
47
+ {:else}
48
+ <td class="sui-table__cell" data-numeric={typeof cell === 'number' || undefined}>
49
+ {cell === null ? '' : String(cell)}
50
+ </td>
51
+ {/if}
52
+ {/each}
53
+ </tr>
54
+ {/each}
55
+ </tbody>
56
+ </table>
57
+ </div>
@@ -15,4 +15,5 @@ export declare const Separator: Component<Record<string, any>>;
15
15
  export declare const Skeleton: Component<Record<string, any>>;
16
16
  export declare const Spinner: Component<Record<string, any>>;
17
17
  export declare const Switch: Component<Record<string, any>>;
18
+ export declare const Table: Component<Record<string, any>>;
18
19
  export declare const Textarea: Component<Record<string, any>>;
@@ -12,4 +12,5 @@ export { default as Separator } from './Separator.svelte';
12
12
  export { default as Skeleton } from './Skeleton.svelte';
13
13
  export { default as Spinner } from './Spinner.svelte';
14
14
  export { default as Switch } from './Switch.svelte';
15
+ export { default as Table } from './Table.svelte';
15
16
  export { default as Textarea } from './Textarea.svelte';
@@ -12,6 +12,7 @@ const LOADERS = {
12
12
  "skeleton": () => import('./Skeleton.svelte'),
13
13
  "spinner": () => import('./Spinner.svelte'),
14
14
  "switch": () => import('./Switch.svelte'),
15
+ "table": () => import('./Table.svelte'),
15
16
  "textarea": () => import('./Textarea.svelte'),
16
17
  };
17
18
  const loaded = new Map();
@@ -123,6 +123,24 @@ declare class SwitchElement extends SurrealElement {
123
123
  protected render(): void;
124
124
  }
125
125
 
126
+ type TableCell = string | number | null;
127
+ /**
128
+ * `<surreal-table caption="…" columns='["Quarter","2025"]' rows='[["Q1",120]]' row-headers>`.
129
+ * `columns` and `rows` are JSON (or set the `columns` and `rows` properties); numbers line up on
130
+ * the right.
131
+ */
132
+ declare class TableElement extends SurrealElement {
133
+ #private;
134
+ static get observedAttributes(): string[];
135
+ get columns(): string[];
136
+ set columns(value: string[]);
137
+ get rows(): TableCell[][];
138
+ set rows(value: TableCell[][]);
139
+ get rowHeaders(): boolean;
140
+ set rowHeaders(value: boolean);
141
+ protected render(): void;
142
+ }
143
+
126
144
  /** `<surreal-textarea label="Notes" name="notes" rows="4">`. A native `<textarea>` in light DOM. */
127
145
  declare class TextareaElement extends SurrealElement {
128
146
  #private;
@@ -132,4 +150,4 @@ declare class TextareaElement extends SurrealElement {
132
150
  protected render(): void;
133
151
  }
134
152
 
135
- export { BadgeElement, ButtonElement, CardElement, CheckboxElement, InputElement, KbdElement, LabelElement, ProgressElement, SeparatorElement, SkeletonElement, SpinnerElement, SurrealElement, SurrealThemeElement, SwitchElement, TextareaElement, aestheticOf, define, structureFor };
153
+ export { BadgeElement, ButtonElement, CardElement, CheckboxElement, InputElement, KbdElement, LabelElement, ProgressElement, SeparatorElement, SkeletonElement, SpinnerElement, SurrealElement, SurrealThemeElement, SwitchElement, TableElement, TextareaElement, aestheticOf, define, structureFor };
package/dist/web/index.js CHANGED
@@ -463,6 +463,98 @@ var SwitchElement = class extends SurrealElement {
463
463
  };
464
464
  define("surreal-switch", SwitchElement);
465
465
 
466
+ // ../../components/table/element.ts
467
+ var TableElement = class extends SurrealElement {
468
+ static get observedAttributes() {
469
+ return ["caption", "columns", "rows", "row-headers"];
470
+ }
471
+ #columns = null;
472
+ #rows = null;
473
+ get columns() {
474
+ return this.#columns ?? this.#json("columns", []);
475
+ }
476
+ set columns(value) {
477
+ this.#columns = value;
478
+ this.render();
479
+ }
480
+ get rows() {
481
+ return this.#rows ?? this.#json("rows", []);
482
+ }
483
+ set rows(value) {
484
+ this.#rows = value;
485
+ this.render();
486
+ }
487
+ get rowHeaders() {
488
+ return this.hasAttribute("row-headers");
489
+ }
490
+ set rowHeaders(value) {
491
+ this.toggleAttribute("row-headers", value);
492
+ }
493
+ #json(name, fallback) {
494
+ try {
495
+ return JSON.parse(this.getAttribute(name) ?? "");
496
+ } catch {
497
+ return fallback;
498
+ }
499
+ }
500
+ render() {
501
+ const columns = this.columns;
502
+ const rows = this.rows;
503
+ const numeric = columns.map(
504
+ (_, c) => rows.some((r) => typeof r[c] === "number") && rows.every((r) => r[c] === null || r[c] === void 0 || typeof r[c] === "number")
505
+ );
506
+ const rowHeaders = this.rowHeaders;
507
+ const wrap = document.createElement("div");
508
+ wrap.className = "sui-table";
509
+ const table = document.createElement("table");
510
+ table.className = "sui-table__table";
511
+ const caption = this.getAttribute("caption");
512
+ if (caption) {
513
+ const c = document.createElement("caption");
514
+ c.className = "sui-table__caption";
515
+ c.textContent = caption;
516
+ table.append(c);
517
+ }
518
+ const head = document.createElement("thead");
519
+ const headRow = document.createElement("tr");
520
+ columns.forEach((column, i) => {
521
+ const th = document.createElement("th");
522
+ th.scope = "col";
523
+ th.className = "sui-table__heading";
524
+ if (numeric[i]) th.dataset.numeric = "true";
525
+ th.textContent = column;
526
+ headRow.append(th);
527
+ });
528
+ head.append(headRow);
529
+ const body = document.createElement("tbody");
530
+ for (const row of rows) {
531
+ const tr = document.createElement("tr");
532
+ columns.forEach((_, c) => {
533
+ const cell = row[c] ?? null;
534
+ const text = cell === null ? "" : String(cell);
535
+ if (rowHeaders && c === 0) {
536
+ const th = document.createElement("th");
537
+ th.scope = "row";
538
+ th.className = "sui-table__row-heading";
539
+ th.textContent = text;
540
+ tr.append(th);
541
+ } else {
542
+ const td = document.createElement("td");
543
+ td.className = "sui-table__cell";
544
+ if (typeof cell === "number") td.dataset.numeric = "true";
545
+ td.textContent = text;
546
+ tr.append(td);
547
+ }
548
+ });
549
+ body.append(tr);
550
+ }
551
+ table.append(head, body);
552
+ wrap.append(table);
553
+ this.replaceChildren(wrap);
554
+ }
555
+ };
556
+ define("surreal-table", TableElement);
557
+
466
558
  // ../../components/textarea/element.ts
467
559
  var FORWARD2 = ["name", "placeholder", "disabled", "required", "rows", "maxlength"];
468
560
  var TextareaElement = class extends SurrealElement {
@@ -519,6 +611,7 @@ export {
519
611
  SurrealElement,
520
612
  SurrealThemeElement,
521
613
  SwitchElement,
614
+ TableElement,
522
615
  TextareaElement,
523
616
  aestheticOf,
524
617
  define,
package/llms.txt CHANGED
@@ -53,6 +53,7 @@
53
53
  - spinner: Spinner (feedback). A visual loading/spinner indicator. Import `Spinner` from `@surreal-ui/catalog/react`; element `<surreal-spinner>`.
54
54
  - switch: Switch (form). A control that allows the user to toggle between checked and not checked. Import `Switch` from `@surreal-ui/catalog/react`; element `<surreal-switch>`.
55
55
  - flair-toggle-switch: Toggle switch (form, implements switch). A switch whose knob slides across, squashing a little mid-slide, as the track blends to its on colour; the next click slides it back. Import `FlairToggleSwitch` from `@surreal-ui/catalog/react/flair`.
56
+ - table: Table (display). Rows and columns of data with a caption, column headings and optional row headings; numbers line up on the right. Import `Table` from `@surreal-ui/catalog/react`; element `<surreal-table>`.
56
57
  - textarea: Textarea (form). A multi-line text input control. Import `Textarea` from `@surreal-ui/catalog/react`; element `<surreal-textarea>`.
57
58
  - timeline: Timeline (data-visual). Periods along an axis, each with its events stacked under it, one colour per period. Import `Timeline` from `@surreal-ui/catalog/react/editor`.
58
59
  - weave: Weave (data-visual). Items along the top joined to the tags they share along the bottom, many to many; focusing an item lights its tags, and focusing a tag lights its items. Import `Weave` from `@surreal-ui/catalog/react/editor`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surreal-ui/catalog",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Drop-in UI components with a catalog API and aesthetic packs: one implementation per component type, restyled by aesthetics defined as skills.",
5
5
  "license": "MIT",
6
6
  "author": "Pixerate",
@@ -25,6 +25,7 @@ Show content or status without taking input: badges, avatars, typography.
25
25
 
26
26
  - `badge` **Badge**: Displays a badge or a component that looks like a badge; React `Badge` from `@surreal-ui/catalog/react`; Svelte `Badge` from `@surreal-ui/catalog/svelte`; element `<surreal-badge>` from `@surreal-ui/catalog/web`; props `children`, `tone`; examples `neutral`, `accent`; replaces `MinimalistBadge`, `ShadcnBadge`; tags display.
27
27
  - `kbd` **Kbd**: Represents keyboard input or a hotkey combination; React `Kbd` from `@surreal-ui/catalog/react`; Svelte `Kbd` from `@surreal-ui/catalog/svelte`; element `<surreal-kbd>` from `@surreal-ui/catalog/web`; props `children`; examples `shortcut`; replaces `MinimalistKbd`, `ShadcnKbd`; tags display, typography.
28
+ - `table` **Table**: Rows and columns of data with a caption, column headings and optional row headings; numbers line up on the right; React `Table` from `@surreal-ui/catalog/react`; Svelte `Table` from `@surreal-ui/catalog/svelte`; element `<surreal-table>` from `@surreal-ui/catalog/web`; props `caption`, `columns`, `rows`, `rowHeaders`; examples `revenue`; tags display, data.
28
29
 
29
30
  ## Feedback (`feedback`)
30
31