@bridge-ds/core 0.5.0 → 0.6.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.
@@ -14,11 +14,39 @@ export interface SpecGeneratorOptions {
14
14
  styleSuffix?: string | undefined;
15
15
  /** Repo-relative ESM build of lucide-react ("node_modules/lucide-react/dist/esm"), for the icons section. */
16
16
  lucideDir?: string | undefined;
17
+ /** Every component folder, to find components a file exports besides its own (Radio in RadioGroup.tsx). */
18
+ components?: string[] | undefined;
19
+ /** Repo-relative global stylesheet apps load before the components (inherited text styles, tag rules). */
20
+ baseCss?: string | undefined;
21
+ /** Repo-relative folder of specs drafted with Claude; default `component-spec-overrides` next to the specs file. */
22
+ overridesDir?: string | undefined;
17
23
  }
18
24
  /** "iconStart" -> "Icon start". */
19
25
  export declare const sentenceCase: (prop: string) => string;
26
+ /**
27
+ * JSX text as React renders it (Babel's rule): lines trimmed where they meet a line break, empty lines dropped, the
28
+ * others joined with one space; spaces inside a line, and at the ends of a single line, are kept.
29
+ */
30
+ export declare function jsxText(text: string): string;
31
+ /** Renders the main component for one set of axis values, with stable part ids. */
32
+ /**
33
+ * Which part of a component with a popup a set draws: the component without its popup (a select's trigger), or the
34
+ * popup alone drawn open (`*.Popup` under the `*.Portal`), the way a Figma UI kit draws menus and dialogs.
35
+ */
36
+ export type SpecView = 'without-popup' | 'popup';
37
+ /**
38
+ * Why a component cannot be drawn faithfully: thrown by the generator, recorded in the coverage list as the reason
39
+ * ("opens a popup", "uses CSS grid"). The message is plain language for designers.
40
+ */
41
+ export declare class UnsupportedComponentError extends Error {
42
+ component: string;
43
+ reason: string;
44
+ constructor(component: string, reason: string);
45
+ }
20
46
  /** The spec of one component, or an error message when it cannot be derived. */
21
- export declare function generateComponentSpec(name: string, opts: SpecGeneratorOptions): ComponentSpec;
47
+ export declare function generateComponentSpec(name: string, opts: SpecGeneratorOptions, view?: SpecView, setName?: string, fixed?: Record<string, string>): ComponentSpec;
48
+ /** Whether a spec draws anything: a fill, a border, an icon or a text of its own. Layout helpers draw nothing. */
49
+ export declare function specDrawsSomething(spec: ComponentSpec): boolean;
22
50
  /** Icons every pulled file gets besides the ones the components use, so designers can swap without importing. */
23
51
  export declare const COMMON_ICONS: string[];
24
52
  /** The icon components themselves: Icon.tsx draws `sm` by default; Lucide's grid is 24, the `lg` size. */
@@ -32,16 +60,41 @@ export declare const MEDIA_SLOT: SpecSlot;
32
60
  export declare function generateIcons(components: ComponentSpec[], opts: SpecGeneratorOptions, slots?: SpecSlot[]): SpecIcon[];
33
61
  /** Content components the specs' slots swap to: each component's text slot (its default variant's text fields), then Media. */
34
62
  export declare function generateSlots(components: ComponentSpec[]): SpecSlot[];
63
+ /** Specs of the named components (sets), in that order. Throws when one cannot be generated. */
35
64
  export declare function generateComponentSpecs(names: string[], opts: SpecGeneratorOptions): ComponentSpecsFile;
36
- /** The 6 base components of the first version. The generator works on any component folder. */
37
- export declare const SPEC_COMPONENTS: string[];
65
+ /**
66
+ * Every component folder, generated when the generator can draw it faithfully, else recorded with the reason it
67
+ * cannot (unsupported) or as a layout helper with no visual of its own. Support is decided here, from what the generator
68
+ * can read: no list to maintain. A folder's other exports (Radio in RadioGroup) get their own set when they draw
69
+ * something; exports drawn inside the main set (CardHeader) do not.
70
+ */
71
+ export declare function generateAllComponentSpecs(folders: string[], opts: SpecGeneratorOptions): ComponentSpecsFile;
72
+ /** Where drafted specs live: next to component-specs.json (packages/react/component-spec-overrides). */
73
+ export declare const overridesDirOf: (componentsDir: string) => string;
74
+ /** FNV-1a of the code a drafted spec was read from, to tell when the code changed since. */
75
+ export declare function draftedCodeHash(files: string[], read: (path: string) => string | undefined): string;
76
+ /**
77
+ * A spec Claude drafted for a component the generator cannot read: `component-spec-overrides/<Folder>.json`, a
78
+ * ComponentSpec marked `"source": "drafted"` with the files it was read from (`files`), the generator's reason and the
79
+ * code's hash when drafted (`codeHash`). Validated like a generated spec, against the repo's tokens: an invalid one
80
+ * fails `npm run specs`. Never counted as generated: its coverage is `drafted`, and it is `stale` once the code changed.
81
+ */
82
+ export declare function draftedSpec(folder: string, opts: SpecGeneratorOptions): ComponentSpec | undefined;
38
83
  /** CSS custom property -> token, for every token of the repo (all tiers), with the repo's cssVar convention. */
39
84
  export declare function tokenCssIndex(files: Record<string, string>, opts?: {
40
85
  prefix?: string;
41
86
  separator?: string;
42
87
  layout?: Parameters<typeof buildTokenSet>[1];
43
88
  }): Map<string, TokenInfo>;
44
- /** Specs of `names` for the repo at `root`, with bridge.config.json (tokens root, components dir, cssVar). */
89
+ /** Generator options for the repo at `root` from bridge.config.json (tokens root, components dir, cssVar), and its component folders. */
90
+ export declare function repoSpecOptions(root: string): {
91
+ opts: SpecGeneratorOptions;
92
+ folders: string[];
93
+ };
94
+ /**
95
+ * Specs for the repo at `root`. With `names`, those sets only (throws when one cannot be generated). Without, every
96
+ * component folder: the sets the generator can draw, and the coverage of all of them (what `npm run specs` writes).
97
+ */
45
98
  export declare function generateRepoComponentSpecs(root: string, names?: string[]): ComponentSpecsFile;
46
99
  /** The JSON text written to disk: stable, two-space indent, trailing newline. */
47
100
  export declare const serializeComponentSpecs: (f: ComponentSpecsFile) => string;