@surreal-ui/catalog 0.14.1 → 0.16.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.
package/README.md CHANGED
@@ -151,6 +151,32 @@ getComponent('gauge'); // { entry: '@surreal-ui/catalog/react/flair', export: 'G
151
151
 
152
152
  `findComponents` takes `group` (`baseline`, `data-visual`, `paradigm`), `category`, `tags`, `implements`, `platform`, `provider` and `text`. Every component reports its `category`, `group`, `runtime` (`engine` for a paradigm drawn by a runtime) and, where it can't run everywhere, a `fallback` type.
153
153
 
154
+ An engine type's provider also maps its data to that fallback, so a host without the engine (no WebGL, reduced motion, no script) shows the same thing as a baseline component. `engineFallback(component, data)` from `@surreal-ui/catalog/node` asks the provider (an optional peer) for it:
155
+
156
+ ```ts
157
+ import { getComponent } from '@surreal-ui/catalog';
158
+ import { engineFallback } from '@surreal-ui/catalog/node';
159
+
160
+ await engineFallback(getComponent('gauge')!, {
161
+ value: 88,
162
+ max: 160,
163
+ unit: ' km/h',
164
+ label: 'Speed'
165
+ });
166
+ // { implements: 'progress', props: { value: 55, label: 'Speed: 88 km/h' } }
167
+ ```
168
+
169
+ Editor charts and diagrams fall back to a `table`; Flair's gauge and loaders to `progress` (a loader whose `value` is `null` gives a `spinner`).
170
+
171
+ A data visual or paradigm from a provider also says how to read it: `encodings` lists each visual channel, the prop it shows (a path such as `series[].values[]`) and what it means, and marks the parts that are only decoration, which name no prop:
172
+
173
+ ```ts
174
+ getComponent('gauge')!.encodings;
175
+ // [{ channel: 'Needle angle', field: 'value', meaning: 'How far the reading is along the scale: …' },
176
+ // …,
177
+ // { channel: 'Green, amber and red bands', decoration: true, meaning: 'Fixed shares of the scale …' }]
178
+ ```
179
+
154
180
  ### Loading components on demand
155
181
 
156
182
  Where the catalog is browsed or offered to an agent and only some components are drawn, import `@surreal-ui/catalog/lazy`: it has the same metadata and queries, and `loadComponent(id)` imports one React component on first use (each component is its own chunk).
@@ -194,7 +220,7 @@ pnpm --filter @surreal-ui/catalog sync # after bumping @pixerate/flair or
194
220
  MIT © Pixerate. Some components follow the structure and documentation of [shadcn/ui](https://ui.shadcn.com) and [Radix UI](https://www.radix-ui.com) (both MIT); see `THIRD_PARTY_NOTICES.md`.
195
221
  An item that implements a type the catalog already has (Flair's toggle implements `switch`) is an
196
222
  **alternative** for that type (`getComponent('switch').alternatives`,
197
- `findComponents({ implements: 'switch' })`); any other item is a new type. After bumping a provider,
223
+ `findComponents({ implements: 'switch' })`); any other item is a new type, and later items implementing that type are its alternatives. A type's `fallback` and `encodings` come from the descriptor. After bumping a provider,
198
224
  run `pnpm --filter @surreal-ui/catalog sync`: it rewrites the synced folders (never hand-written
199
225
  ones), removes items the provider dropped, and regenerates the catalog. CI fails if the repo is
200
226
  behind its installed providers (`check:sync`).