@surreal-ui/catalog 0.10.0 → 0.11.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.
@@ -0,0 +1,68 @@
1
+ // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.334.1 (mindmap). Do not edit.
2
+ import * as React from 'react';
3
+ import { diagramUiComponents } from '@pixerate/editor/canvas';
4
+ import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
5
+
6
+ const ROLES = ['surface', 'surface-raised', 'ink', 'ink-muted', 'border', 'accent'] as const;
7
+ const COMPONENT = diagramUiComponents().find((c) => c.id === 'mindmap')!;
8
+
9
+ export interface MindmapProps {
10
+ /** The central idea. */
11
+ root: string;
12
+ /** Branches round the root, each with up to two levels of children. */
13
+ branches: { label: string; children?: { label: string; children?: { label: string }[] }[] }[];
14
+ /** Accessible name (default: built from the root). */
15
+ title?: string;
16
+ /** Width in CSS px. */
17
+ width?: number;
18
+ /** Height in CSS px. */
19
+ height?: number;
20
+ className?: string;
21
+ style?: React.CSSProperties;
22
+ }
23
+
24
+ /** A central idea with branches and sub-branches spread round it, one colour per branch. (editor `mindmap`, coloured by the aesthetic's roles.) */
25
+ export function Mindmap({ root, branches, title, width, height, className, style }: MindmapProps) {
26
+ const ref = React.useRef<HTMLSpanElement>(null);
27
+ const colors = useRoleColors(ref, ROLES);
28
+ // Fills its container: render at the container's width, and again when it changes.
29
+ const [measured, setMeasured] = React.useState<number | undefined>(undefined);
30
+ React.useEffect(() => {
31
+ const el = ref.current?.parentElement;
32
+ if (!el || width !== undefined) return;
33
+ const observer = new ResizeObserver(([entry]) =>
34
+ setMeasured(Math.max(280, Math.round(entry!.contentRect.width)))
35
+ );
36
+ observer.observe(el);
37
+ return () => observer.disconnect();
38
+ }, [width]);
39
+ const w = width ?? measured;
40
+ const h = height ?? 240;
41
+ const data = React.useMemo(
42
+ () =>
43
+ Object.fromEntries(
44
+ Object.entries({ root, branches, title }).filter(([, v]) => v !== undefined)
45
+ ),
46
+ [root, branches, title]
47
+ );
48
+ const svg = React.useMemo(
49
+ () =>
50
+ w === undefined
51
+ ? ''
52
+ : COMPONENT.render(data, {
53
+ width: w,
54
+ height: h,
55
+ theme: colors?.scheme ?? 'light',
56
+ ...(colors ? { colors: colors.css } : {})
57
+ }),
58
+ [data, w, h, colors]
59
+ );
60
+ return (
61
+ <span
62
+ ref={ref}
63
+ className={['sui-provider', className].filter(Boolean).join(' ')}
64
+ style={{ display: 'inline-block', width: w ?? '100%', height: h, ...style }}
65
+ dangerouslySetInnerHTML={{ __html: svg }}
66
+ />
67
+ );
68
+ }
@@ -1,4 +1,4 @@
1
- // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.322.0 (sparkline). Do not edit.
1
+ // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.334.1 (sparkline). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
4
  import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
@@ -0,0 +1,63 @@
1
+ // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.334.1 (timeline). Do not edit.
2
+ import * as React from 'react';
3
+ import { diagramUiComponents } from '@pixerate/editor/canvas';
4
+ import { useRoleColors } from '../../packages/catalog/src/runtime/role-colors';
5
+
6
+ const ROLES = ['surface', 'surface-raised', 'ink', 'ink-muted', 'border', 'accent'] as const;
7
+ const COMPONENT = diagramUiComponents().find((c) => c.id === 'timeline')!;
8
+
9
+ export interface TimelineProps {
10
+ /** Periods in order, each with its events. */
11
+ periods: { label: string; events: string[] }[];
12
+ /** Title drawn above the timeline and used as its accessible name. */
13
+ title?: string;
14
+ /** Width in CSS px. */
15
+ width?: number;
16
+ /** Height in CSS px. */
17
+ height?: number;
18
+ className?: string;
19
+ style?: React.CSSProperties;
20
+ }
21
+
22
+ /** Periods along an axis, each with its events stacked under it, one colour per period. (editor `timeline`, coloured by the aesthetic's roles.) */
23
+ export function Timeline({ periods, title, width, height, className, style }: TimelineProps) {
24
+ const ref = React.useRef<HTMLSpanElement>(null);
25
+ const colors = useRoleColors(ref, ROLES);
26
+ // Fills its container: render at the container's width, and again when it changes.
27
+ const [measured, setMeasured] = React.useState<number | undefined>(undefined);
28
+ React.useEffect(() => {
29
+ const el = ref.current?.parentElement;
30
+ if (!el || width !== undefined) return;
31
+ const observer = new ResizeObserver(([entry]) =>
32
+ setMeasured(Math.max(280, Math.round(entry!.contentRect.width)))
33
+ );
34
+ observer.observe(el);
35
+ return () => observer.disconnect();
36
+ }, [width]);
37
+ const w = width ?? measured;
38
+ const h = height ?? 240;
39
+ const data = React.useMemo(
40
+ () => Object.fromEntries(Object.entries({ periods, title }).filter(([, v]) => v !== undefined)),
41
+ [periods, title]
42
+ );
43
+ const svg = React.useMemo(
44
+ () =>
45
+ w === undefined
46
+ ? ''
47
+ : COMPONENT.render(data, {
48
+ width: w,
49
+ height: h,
50
+ theme: colors?.scheme ?? 'light',
51
+ ...(colors ? { colors: colors.css } : {})
52
+ }),
53
+ [data, w, h, colors]
54
+ );
55
+ return (
56
+ <span
57
+ ref={ref}
58
+ className={['sui-provider', className].filter(Boolean).join(' ')}
59
+ style={{ display: 'inline-block', width: w ?? '100%', height: h, ...style }}
60
+ dangerouslySetInnerHTML={{ __html: svg }}
61
+ />
62
+ );
63
+ }
@@ -1,4 +1,4 @@
1
- // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.322.0 (weave). Do not edit.
1
+ // Generated by packages/catalog/scripts/sync-providers.ts from @pixerate/editor 0.334.1 (weave). Do not edit.
2
2
  import * as React from 'react';
3
3
  import { uiComponents } from '@pixerate/editor/chart';
4
4
  import { createLinkFocus } from '@pixerate/editor/tools';
package/llms.txt CHANGED
@@ -37,12 +37,14 @@
37
37
  - card: Card (layout). Displays a card with header, content, and footer. Import `Card` from `@surreal-ui/catalog/react`; element `<surreal-card>`.
38
38
  - checkbox: Checkbox (form). A control that allows the user to toggle between checked and not checked. Import `Checkbox` from `@surreal-ui/catalog/react`; element `<surreal-checkbox>`.
39
39
  - donut-chart: Donut chart (data-visual). Parts of a whole as slices of a ring, one colour per slice, with a legend. Import `DonutChart` from `@surreal-ui/catalog/react/editor`.
40
+ - flow: Flow (data-visual). A process as boxes joined by arrows, left to right or top down, in the diagram editor's layout. Import `Flow` from `@surreal-ui/catalog/react/editor`.
40
41
  - gauge: Gauge (data-visual). A speedometer gauge: its coloured band draws on, the needle sweeps past the value and settles, and the reading counts up beneath. Import `Gauge` from `@surreal-ui/catalog/react/flair`.
41
42
  - input: Input (form). Displays a form input field or a component that looks like an input field. Import `Input` from `@surreal-ui/catalog/react`; element `<surreal-input>`.
42
43
  - kbd: Kbd (display). Represents keyboard input or a hotkey combination. Import `Kbd` from `@surreal-ui/catalog/react`; element `<surreal-kbd>`.
43
44
  - label: Label (form). Accessible labeling for form controls. Import `Label` from `@surreal-ui/catalog/react`; element `<surreal-label>`.
44
45
  - line-chart: Line chart (data-visual). Lines showing how values change across ordered categories (time), one colour per series, with a value axis and a legend for several series. Import `LineChart` from `@surreal-ui/catalog/react/editor`.
45
46
  - lineage: Lineage (data-visual). One root fanned out to a row of items with rounded connectors that never cross, labels sized to fit their columns; draws on from the root, and focusing an item lights its branch. Import `Lineage` from `@surreal-ui/catalog/react/editor`.
47
+ - mindmap: Mind map (data-visual). A central idea with branches and sub-branches spread round it, one colour per branch. Import `Mindmap` from `@surreal-ui/catalog/react/editor`.
46
48
  - progress: Progress (feedback). Displays an indicator showing the completion progress of a task. Import `Progress` from `@surreal-ui/catalog/react`; element `<surreal-progress>`.
47
49
  - flair-progress-bar: Progress bar (feedback, implements progress). A striped progress bar filling to a value while its percentage counts up, the stripes marching all the while. Import `FlairProgressBar` from `@surreal-ui/catalog/react/flair`.
48
50
  - separator: Separator (layout). Visually or semantically separates content. Import `Separator` from `@surreal-ui/catalog/react`; element `<surreal-separator>`.
@@ -52,6 +54,7 @@
52
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>`.
53
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`.
54
56
  - textarea: Textarea (form). A multi-line text input control. Import `Textarea` from `@surreal-ui/catalog/react`; element `<surreal-textarea>`.
57
+ - 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`.
55
58
  - 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`.
56
59
 
57
60
  ## Aesthetics
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surreal-ui/catalog",
3
- "version": "0.10.0",
3
+ "version": "0.11.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",
@@ -103,7 +103,8 @@
103
103
  "@pixerate/schemas": "^1.52.0"
104
104
  },
105
105
  "peerDependencies": {
106
- "@pixerate/editor": ">=0.322.0",
106
+ "@dagrejs/dagre": ">=1.1.8",
107
+ "@pixerate/editor": ">=0.334.1",
107
108
  "@pixerate/flair": ">=0.121.0",
108
109
  "react": ">=18.0.0",
109
110
  "svelte": ">=5.20.0"
@@ -120,10 +121,14 @@
120
121
  },
121
122
  "@pixerate/editor": {
122
123
  "optional": true
124
+ },
125
+ "@dagrejs/dagre": {
126
+ "optional": true
123
127
  }
124
128
  },
125
129
  "devDependencies": {
126
- "@pixerate/editor": "^0.322.0",
130
+ "@dagrejs/dagre": "^1.1.8",
131
+ "@pixerate/editor": "^0.334.1",
127
132
  "@pixerate/flair": "^0.121.0",
128
133
  "@playwright/test": "^1.64.1",
129
134
  "@types/node": "^22.20.1",
@@ -49,8 +49,11 @@ Draw numbers: charts, gauges, sparklines.
49
49
  - `bar-chart` **Bar chart**: Vertical bars comparing values across categories, one colour per series, with a value axis and a legend for several series; React `BarChart` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `categories`, `series`, `title`, `unit`; examples `example`; group data-visual; tags editor, data-visual.
50
50
  - `braid` **Braid**: Strands twisted into one root, passing over and under, weighted by value and labelled at the open end; draws on along the braid, and focusing a strand lights it; React `Braid` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `root`, `strands`, `turns`, `title`; state focus (event focus); examples `example`; group data-visual; tags editor, data-visual.
51
51
  - `donut-chart` **Donut chart**: Parts of a whole as slices of a ring, one colour per slice, with a legend; React `DonutChart` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `slices`, `title`, `unit`; examples `example`; group data-visual; tags editor, data-visual.
52
+ - `flow` **Flow**: A process as boxes joined by arrows, left to right or top down, in the diagram editor's layout; React `Flow` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `steps`, `links`, `direction`, `title`; examples `example`; group data-visual; tags editor, data-visual.
52
53
  - `gauge` **Gauge**: A speedometer gauge: its coloured band draws on, the needle sweeps past the value and settles, and the reading counts up beneath; React `Gauge` from `@surreal-ui/catalog/react/flair` (needs @pixerate/flair); props `value`, `max`, `unit`, `label`; examples `example`; group data-visual; tags flair, data-visual.
53
54
  - `line-chart` **Line chart**: Lines showing how values change across ordered categories (time), one colour per series, with a value axis and a legend for several series; React `LineChart` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `categories`, `series`, `title`, `unit`; examples `example`; group data-visual; tags editor, data-visual.
54
55
  - `lineage` **Lineage**: One root fanned out to a row of items with rounded connectors that never cross, labels sized to fit their columns; draws on from the root, and focusing an item lights its branch; React `Lineage` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `root`, `items`, `title`; state focus (event focus); examples `example`; group data-visual; tags editor, data-visual.
56
+ - `mindmap` **Mind map**: A central idea with branches and sub-branches spread round it, one colour per branch; React `Mindmap` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `root`, `branches`, `title`; examples `example`; group data-visual; tags editor, data-visual.
55
57
  - `sparkline` **Sparkline**: A word-sized line chart of one run of values, without axes or labels; React `Sparkline` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `values`, `label`; examples `example`; group data-visual; tags editor, data-visual.
58
+ - `timeline` **Timeline**: Periods along an axis, each with its events stacked under it, one colour per period; React `Timeline` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `periods`, `title`; examples `example`; group data-visual; tags editor, data-visual.
56
59
  - `weave` **Weave**: 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; React `Weave` from `@surreal-ui/catalog/react/editor` (needs @pixerate/editor); props `items`, `title`; state focus (event focus); examples `example`; group data-visual; tags editor, data-visual.