@krapwoo/ds-viewer 0.9.1 → 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.
Files changed (37) hide show
  1. package/README.md +82 -0
  2. package/dist/cli/doctor.js +182 -3
  3. package/dist/cli/staticPage.js +129 -0
  4. package/dist/native/catalog/catalogNavigation.js +62 -3
  5. package/dist/native/catalog/comparison.js +14 -3
  6. package/dist/native/catalog/pageApi.js +408 -0
  7. package/dist/native/catalog/tokens.js +67 -12
  8. package/native/catalog/BoundedOverlayViewport.tsx +2 -2
  9. package/native/catalog/CatalogButton.tsx +2 -2
  10. package/native/catalog/CatalogSearchInput.tsx +3 -3
  11. package/native/catalog/CatalogShell.tsx +213 -32
  12. package/native/catalog/CatalogSidebar.tsx +69 -19
  13. package/native/catalog/ComparisonGrid.tsx +4 -4
  14. package/native/catalog/ComparisonGroups.tsx +3 -3
  15. package/native/catalog/ComparisonList.tsx +2 -2
  16. package/native/catalog/FamilyPage.tsx +1188 -0
  17. package/native/catalog/MotionSpecimen.tsx +3 -3
  18. package/native/catalog/PhoneFrame.tsx +2 -2
  19. package/native/catalog/PropsTable.tsx +7 -7
  20. package/native/catalog/ReferenceDetails.tsx +33 -22
  21. package/native/catalog/SectionBlock.tsx +57 -27
  22. package/native/catalog/SpacingScaleGallery.tsx +3 -3
  23. package/native/catalog/Swatch.tsx +3 -3
  24. package/native/catalog/TokenLayouts.tsx +6 -9
  25. package/native/catalog/TokenRow.tsx +2 -2
  26. package/native/catalog/TypeScaleGallery.tsx +2 -2
  27. package/native/catalog/UpdatePanel.tsx +29 -30
  28. package/native/catalog/VariantGroup.tsx +3 -6
  29. package/native/catalog/catalogNavigation.ts +89 -3
  30. package/native/catalog/comparison.ts +17 -6
  31. package/native/catalog/familyModel.ts +192 -0
  32. package/native/catalog/index.ts +8 -2
  33. package/native/catalog/overlayViewport.ts +30 -10
  34. package/native/catalog/pageApi.ts +357 -15
  35. package/native/catalog/tokens.ts +70 -12
  36. package/native/catalog/types.ts +106 -0
  37. package/package.json +1 -1
@@ -72,6 +72,9 @@ export interface VariantSlot {
72
72
  * it only ever lowers the natural, width-based column count, never raises it. Omit to let the
73
73
  * slot's specimen size and available width decide alone (today's behavior, unchanged). */
74
74
  maxColumns?: 1 | 2 | 3 | 4 | 5;
75
+ /** Names the one property this grid varies (e.g. "Expression", "Shape"). Shown as the grid's
76
+ * label, including on family pages, which otherwise hide block labels. */
77
+ axis?: string;
75
78
  items: VariantExample[];
76
79
  }
77
80
 
@@ -274,6 +277,9 @@ export interface SectionDef<TId extends string = string> {
274
277
  * so the exemption is a visible declaration in the page rather than a silent gap — write an
275
278
  * example instead whenever the reader really does choose the value. */
276
279
  internalProps?: Record<string, string>;
280
+ /** Set when the authored page has `members`: the viewer renders a `FamilyPage` instead of the
281
+ * normal single-component layout. See `CatalogPageInput.members` and `FamilyDef`. */
282
+ family?: FamilyDef;
277
283
  }
278
284
 
279
285
  /** A labeled group of section ids in the sidebar (e.g. "Components" vs "Tokens"). */
@@ -313,6 +319,106 @@ export interface VersionStatus {
313
319
  update: UpdateNotice | null;
314
320
  }
315
321
 
322
+ /** One documented declaration on a family page (spec §5.1): its name, source location, fidelity,
323
+ * specimens or reference text, and API. The whole (the page's own `id`) is a member too. */
324
+ export interface CatalogMember {
325
+ id: string;
326
+ /** A detected component export. Its generated props go in the disclosure, and its stub page is
327
+ * suppressed. Omit for a documentation-only member with no rendered specimen. */
328
+ component?: string;
329
+ /** The native source shown in the line below the specimens, `path:line`. */
330
+ source: string;
331
+ fidelity: 'replicated' | 'approximated' | 'documentation-only';
332
+ /** For example "Anatomy", "Native integration", "Helper". Slice D1 removed the below-specimens
333
+ * line's own relationship/section-label display entirely (the anatomy box replaced it); kept as
334
+ * authored data for your own reference, but not read by the renderer. */
335
+ relationship: string;
336
+ /** The member that contains or uses this one. Omitted on the whole and on related roots. */
337
+ parent?: string;
338
+ /** Short sentence for members outside the whole (e.g. "Wraps BotAvatarView"). Member names
339
+ * inside it become links to that member's address. */
340
+ related?: string;
341
+ description: string;
342
+ variants?: VariantSlot;
343
+ states?: VariantSlot;
344
+ comparison?: ComparisonDef;
345
+ /** Bullets inside the disclosure. */
346
+ notes?: string[];
347
+ whenToUse?: string;
348
+ a11y?: string;
349
+ /** Swift declaration excerpt, generated by the host app's scanner, shown in the disclosure. */
350
+ api?: string;
351
+ /** What this member is built from or composed with — same meaning as `SectionDef.composedOf`,
352
+ * shown in the disclosure as one "Uses …" line (`disclosureContent`'s `'uses'` part). */
353
+ composedOf?: ComposedOfEntry[];
354
+ notShown?: string;
355
+ /** Display only, same meaning as `SectionDef.hide` — not a doctor exemption. */
356
+ hide?: { accessibility?: boolean; props?: boolean };
357
+ /** Extra names (e.g. retired page ids) that resolve to this member. */
358
+ aliases?: string[];
359
+ /** Same meaning as `SectionDef.osComponent` — rendered as the same small badge in the member
360
+ * header. */
361
+ osComponent?: 'full' | 'partial';
362
+ previewWidths?: PreviewWidths;
363
+ previewLayout?: 'frames' | 'table';
364
+ specimenSize?: SpecimenSize;
365
+ specimenSurface?: SpecimenSurfaceKind;
366
+ /** Same meaning as `SectionDef.intentionalStaticPreview` — accepted per member, but not yet
367
+ * consumed by anything (neither the viewer nor `doctor`'s member-level checks read it). */
368
+ intentionalStaticPreview?: { reason: string };
369
+ }
370
+
371
+ /** One section of a family page (spec §5.1): `kind` alone decides full blocks versus the folded
372
+ * list card. `inWhole` sections come right after the whole; the others come after them — ordering
373
+ * only, numbering follows each member's own `parent` (see `numberFor`); a Related (non-`inWhole`)
374
+ * member is never numbered. */
375
+ export interface CatalogMemberSection {
376
+ label: string;
377
+ kind: 'blocks' | 'list';
378
+ inWhole: boolean;
379
+ members: string[];
380
+ }
381
+
382
+ /** Slice D1: one row of a family page's anatomy legend — either a `member` of this page (numbered,
383
+ * linked to that member's address) or a component `other`wise documented elsewhere (never
384
+ * numbered; linked only when the name resolves to a real catalog address). `description` is this
385
+ * legend row's own text, independent of the member's own `description`. */
386
+ export type CatalogAnatomyItem = ({ member: string } | { other: string }) & { description: string };
387
+
388
+ /** One labeled group of anatomy legend rows (e.g. "In this picture", "No area of their own",
389
+ * "From other pages") — a group never splits across legend columns (`AnatomyPin`/`FamilyPage`). */
390
+ export interface CatalogAnatomyGroup {
391
+ label: string;
392
+ items: CatalogAnatomyItem[];
393
+ }
394
+
395
+ /** Slice D1 item 1: the anatomy box at the top of a family page — a picture of the whole with
396
+ * numbered pins (via `AnatomyPin`, looked up through context so the picture never hardcodes a
397
+ * number), and a legend beside it (six items or fewer) or below it in up to three balanced
398
+ * columns. Omit for a family page with no anatomy picture. */
399
+ export interface CatalogAnatomy {
400
+ picture?: React.ReactNode;
401
+ groups: CatalogAnatomyGroup[];
402
+ }
403
+
404
+ /** A family page's members with resolved props and paths, the whole, sections, and the computed
405
+ * outline — set on `SectionDef.family` by `buildCatalogSections` when a page has `members`. */
406
+ export interface FamilyDef {
407
+ whole: string;
408
+ members: Array<CatalogMember & { props?: PropDef[]; path: string }>;
409
+ sections: CatalogMemberSection[];
410
+ outline: Map<string, { number: string; level: number }>;
411
+ notShown?: string;
412
+ /** Extra names for the page itself (its whole) — e.g. retired page ids. See
413
+ * `CatalogPageInput.aliases`. */
414
+ aliases?: string[];
415
+ /** Label for the disclosure's API part (`disclosureLabel`). See `CatalogPageInput.apiLabel`.
416
+ * Defaults to `'API'` when absent. */
417
+ apiLabel?: string;
418
+ /** Slice D1 item 1. See `CatalogPageInput.anatomy`. */
419
+ anatomy?: CatalogAnatomy;
420
+ }
421
+
316
422
  /** One titled card on a token page (`SectionDef.tokenSections`). */
317
423
  export interface TokenSection {
318
424
  /** The kind of token this card holds, e.g. "Semantic colours", "Palette", "Body". */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krapwoo/ds-viewer",
3
- "version": "0.9.1",
3
+ "version": "0.11.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A browsable, always-current catalog for an Expo / React Native design system.",