@gild-ui/core 0.0.0 → 0.1.0-alpha.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,66 @@
1
+ /**
2
+ * `theme.breakpoints`: an ascending list, or named breakpoints in their declared order.
3
+ * Each value is where its range starts; the range holds until the next breakpoint. A
4
+ * breakpoint that starts at 0 (`xs: '0px'`) is the base: it applies everywhere until the
5
+ * next one overrides it.
6
+ */
7
+ type Breakpoints = readonly (string | number)[] | Record<string, string | number>;
8
+ /** A breakpoint name, or a width: a number (px) or any CSS length. */
9
+ type BreakpointInput = string | number;
10
+ /** `up` / `down` / `only` / `between` / `not` - each returns an at-rule in range syntax. */
11
+ interface QueryHelpers {
12
+ /** From this breakpoint or width up: `@media (width >= 840px)`. */
13
+ up: (from: BreakpointInput) => string;
14
+ /** Below this breakpoint or width: `@media (width < 840px)`. */
15
+ down: (to: BreakpointInput) => string;
16
+ /** This breakpoint's range, up to the next one: `@media (840px <= width < 1200px)`. */
17
+ only: (key: string) => string;
18
+ /** From the first up to the second: `@media (600px <= width < 1200px)`. */
19
+ between: (from: BreakpointInput, to: BreakpointInput) => string;
20
+ /** Everywhere but this breakpoint's range: `@media (width < 840px), (width >= 1200px)`. */
21
+ not: (key: string) => string;
22
+ }
23
+ /** Container queries: the helpers unnamed, or `containerQueries('sidebar').up(400)` for a named container. */
24
+ interface ContainerQueries extends QueryHelpers {
25
+ (name: string): QueryHelpers;
26
+ }
27
+ /**
28
+ * The `@media` rule for one breakpoint value, from its start up: a length (a number gets
29
+ * `px`) becomes `@media (width >= <length>)`, and `null` when it starts at 0; a value
30
+ * starting with `@media` is used as written; anything else - a condition such as
31
+ * `(orientation: landscape)`, or a media type - follows `@media `.
32
+ */
33
+ declare const createMediaQuery: (value: string | number) => string | null;
34
+ /** Each breakpoint's `@media` rule (`null` for the base), in declared order, keyed by name or index. */
35
+ declare const breakpointQueries: (breakpoints: Breakpoints) => [string, string | null][];
36
+ /** `xs` -> `cqXs`: the prop key for a container query from a breakpoint up. */
37
+ declare const containerKey: (key: string) => string;
38
+ /** `up` / `down` / `only` / `between` / `not` as `@media` rules over a breakpoint scale. */
39
+ declare const createMediaHelpers: (breakpoints: Breakpoints) => QueryHelpers;
40
+ /** The same helpers as `@container` rules; call it with a name for a named container. */
41
+ declare const createContainerQueries: (breakpoints: Breakpoints) => ContainerQueries;
42
+ /** What a scale's responsive values compile to - shared by the prop parsers and `css()`. */
43
+ interface ResponsiveQueries {
44
+ /** One query per array position; `null` is the base. */
45
+ array: (string | null)[];
46
+ /** Object keys: breakpoint names (`null` for the base) and their `cq<Name>` container keys. */
47
+ keyed: Map<string, string | null>;
48
+ /** Every query in cascade order: the media blocks in breakpoint order, then the container blocks. */
49
+ order: string[];
50
+ }
51
+ declare const responsiveQueries: (breakpoints: Breakpoints) => ResponsiveQueries;
52
+ /**
53
+ * The query helpers a theme's breakpoint scale carries: `up` / `down` / `only` / `between` /
54
+ * `not` as `@media` rules, and `containerQueries` for the same sizes as `@container` rules.
55
+ */
56
+ interface BreakpointHelpers extends QueryHelpers {
57
+ containerQueries: ContainerQueries;
58
+ }
59
+ /**
60
+ * The scale with its helpers attached as non-enumerable methods: the engine, the theme's JSON
61
+ * and a spread see only the sizes, while `theme.breakpoints.up('md')` works. `createTheme`
62
+ * and `ThemeProvider` re-attach them after a merge, so they always follow the theme's own
63
+ * breakpoints.
64
+ */
65
+ declare const withBreakpointHelpers: <Scale extends Record<string, string | number>>(scale: Scale) => Scale & BreakpointHelpers;
66
+ export { ContainerQueries as a, breakpointQueries as c, createMediaHelpers as d, createMediaQuery as f, Breakpoints as i, containerKey as l, withBreakpointHelpers as n, QueryHelpers as o, responsiveQueries as p, BreakpointInput as r, ResponsiveQueries as s, BreakpointHelpers as t, createContainerQueries as u };
@@ -0,0 +1,106 @@
1
+ import { v as Theme } from "./types-DIyGsvvF.cjs";
2
+ /** A value that survives `JSON.stringify` - all a catalog holds. */
3
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
4
+ [key: string]: JsonValue;
5
+ };
6
+ /**
7
+ * An element as data: a component by name, its props, and its children - more nodes, or
8
+ * text. The same shape a tool writes into source: `{ component: 'MenuItem', props: { value:
9
+ * 'web' }, children: ['Web'] }` is `<MenuItem value="web">Web</MenuItem>`.
10
+ */
11
+ interface ExampleNode {
12
+ component: string;
13
+ props: Record<string, JsonValue>;
14
+ children: (ExampleNode | string)[];
15
+ }
16
+ /** A theme scale a prop's values come from - `palette` for `color`. The theme's own keys name it. */
17
+ type ThemeScale = keyof Theme;
18
+ /** A prop a picker offers, and where its values come from. */
19
+ interface CatalogOption {
20
+ /** The theme scale whose keys are the values, so an app's own theme widens them. */
21
+ scale?: ThemeScale;
22
+ /** A closed set of values, such as a variant's. */
23
+ values?: readonly (string | number | boolean)[];
24
+ /** The value the component takes when the prop is unset. */
25
+ default?: JsonValue;
26
+ }
27
+ /**
28
+ * How a node-taking prop is written: as children, as one child element, as text, or not at
29
+ * all (a prop a tool shouldn't write).
30
+ */
31
+ type CatalogContent = 'children' | 'child' | 'text' | 'none';
32
+ /** A prop that both shows a value and reports changes to it - and how to read the change. */
33
+ interface CatalogTwoWay {
34
+ prop: string;
35
+ event: string;
36
+ read: 'target.value' | 'target.checked' | 'argument';
37
+ }
38
+ /** A named look, shown as a picture. */
39
+ interface CatalogVariant {
40
+ name: string;
41
+ label: string;
42
+ example: ExampleNode;
43
+ }
44
+ /**
45
+ * One component, as a tool needs it on any platform. What belongs to one platform - the
46
+ * package a component is imported from - is added by that platform's library.
47
+ */
48
+ interface CatalogEntry {
49
+ name: string;
50
+ /** The path under a platform library's package it is served from: `'Select'`. A family's members share their family's. */
51
+ subpath: string;
52
+ /** Its category in the docs' taxonomy. */
53
+ category: string;
54
+ summary: string;
55
+ /** Offered in a palette to place by hand. Components a palette shouldn't offer - `Portal`, `TableCell` - still have entries, for editing pages that use them. */
56
+ isPlaceable: boolean;
57
+ /** What a freshly placed one is. */
58
+ example: ExampleNode;
59
+ variants: CatalogVariant[];
60
+ options: Record<string, CatalogOption>;
61
+ /** The slots a theme can style with `components.<Name>.styleOverrides`; absent for a component with no theme entry. */
62
+ slots?: string[];
63
+ /** The fields of its owner state, the props a theme may default; absent when open or when it has no theme entry. */
64
+ ownerState?: string[];
65
+ content: Record<string, CatalogContent>;
66
+ twoWay?: CatalogTwoWay;
67
+ /** Event handlers worth offering, named as the platform's components take them. */
68
+ domEvents?: string[];
69
+ /** The room its picture needs to look right, in pixels. */
70
+ preview?: {
71
+ width?: number;
72
+ height?: number;
73
+ };
74
+ }
75
+ /** Every component of the design system, as a tool needs it. */
76
+ interface DesignSystemCatalog {
77
+ /** The docs' categories, in their order, each with its components. */
78
+ categories: {
79
+ label: string;
80
+ components: string[];
81
+ }[];
82
+ /** A styled-system prop's theme scale: `p` → `space`, `borderRadius` → `radii`. */
83
+ styleScales: Record<string, string>;
84
+ components: Record<string, CatalogEntry>;
85
+ }
86
+ /** One thing wrong in a theme's `components`: where it is, and what is wrong there (the message starts with the path). */
87
+ interface ThemeProblem {
88
+ path: string;
89
+ message: string;
90
+ }
91
+ /**
92
+ * Checks a theme's `components` against the catalog, for a mistake the types cannot see (a theme
93
+ * whose types were cast away, plain JavaScript, a theme read from a file): a component the design
94
+ * system lacks, a slot a component has not, a default prop or a look's prop the component does not
95
+ * take, and a default value outside the values the catalog lists for that prop. It returns the
96
+ * problems; it never throws and never changes `components`.
97
+ */
98
+ declare const validateThemeComponents: (components: unknown) => ThemeProblem[];
99
+ /**
100
+ * @description Every component of the design system as data a tool can read - its
101
+ * category, the subpath it is imported from, what a freshly placed one is, its looks as
102
+ * pictures, the props a picker offers and their theme scales, and how its node props and
103
+ * two-way props are written. Pure data: it loads in Node with no DOM and no framework.
104
+ */
105
+ declare const catalog: DesignSystemCatalog;
106
+ export { CatalogEntry as a, CatalogVariant as c, JsonValue as d, ThemeScale as f, CatalogContent as i, DesignSystemCatalog as l, ThemeProblem as n, CatalogOption as o, validateThemeComponents as r, CatalogTwoWay as s, catalog as t, ExampleNode as u };
@@ -0,0 +1,106 @@
1
+ import { v as Theme } from "./types-DRIGCQQY.mjs";
2
+ /** A value that survives `JSON.stringify` - all a catalog holds. */
3
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
4
+ [key: string]: JsonValue;
5
+ };
6
+ /**
7
+ * An element as data: a component by name, its props, and its children - more nodes, or
8
+ * text. The same shape a tool writes into source: `{ component: 'MenuItem', props: { value:
9
+ * 'web' }, children: ['Web'] }` is `<MenuItem value="web">Web</MenuItem>`.
10
+ */
11
+ interface ExampleNode {
12
+ component: string;
13
+ props: Record<string, JsonValue>;
14
+ children: (ExampleNode | string)[];
15
+ }
16
+ /** A theme scale a prop's values come from - `palette` for `color`. The theme's own keys name it. */
17
+ type ThemeScale = keyof Theme;
18
+ /** A prop a picker offers, and where its values come from. */
19
+ interface CatalogOption {
20
+ /** The theme scale whose keys are the values, so an app's own theme widens them. */
21
+ scale?: ThemeScale;
22
+ /** A closed set of values, such as a variant's. */
23
+ values?: readonly (string | number | boolean)[];
24
+ /** The value the component takes when the prop is unset. */
25
+ default?: JsonValue;
26
+ }
27
+ /**
28
+ * How a node-taking prop is written: as children, as one child element, as text, or not at
29
+ * all (a prop a tool shouldn't write).
30
+ */
31
+ type CatalogContent = 'children' | 'child' | 'text' | 'none';
32
+ /** A prop that both shows a value and reports changes to it - and how to read the change. */
33
+ interface CatalogTwoWay {
34
+ prop: string;
35
+ event: string;
36
+ read: 'target.value' | 'target.checked' | 'argument';
37
+ }
38
+ /** A named look, shown as a picture. */
39
+ interface CatalogVariant {
40
+ name: string;
41
+ label: string;
42
+ example: ExampleNode;
43
+ }
44
+ /**
45
+ * One component, as a tool needs it on any platform. What belongs to one platform - the
46
+ * package a component is imported from - is added by that platform's library.
47
+ */
48
+ interface CatalogEntry {
49
+ name: string;
50
+ /** The path under a platform library's package it is served from: `'Select'`. A family's members share their family's. */
51
+ subpath: string;
52
+ /** Its category in the docs' taxonomy. */
53
+ category: string;
54
+ summary: string;
55
+ /** Offered in a palette to place by hand. Components a palette shouldn't offer - `Portal`, `TableCell` - still have entries, for editing pages that use them. */
56
+ isPlaceable: boolean;
57
+ /** What a freshly placed one is. */
58
+ example: ExampleNode;
59
+ variants: CatalogVariant[];
60
+ options: Record<string, CatalogOption>;
61
+ /** The slots a theme can style with `components.<Name>.styleOverrides`; absent for a component with no theme entry. */
62
+ slots?: string[];
63
+ /** The fields of its owner state, the props a theme may default; absent when open or when it has no theme entry. */
64
+ ownerState?: string[];
65
+ content: Record<string, CatalogContent>;
66
+ twoWay?: CatalogTwoWay;
67
+ /** Event handlers worth offering, named as the platform's components take them. */
68
+ domEvents?: string[];
69
+ /** The room its picture needs to look right, in pixels. */
70
+ preview?: {
71
+ width?: number;
72
+ height?: number;
73
+ };
74
+ }
75
+ /** Every component of the design system, as a tool needs it. */
76
+ interface DesignSystemCatalog {
77
+ /** The docs' categories, in their order, each with its components. */
78
+ categories: {
79
+ label: string;
80
+ components: string[];
81
+ }[];
82
+ /** A styled-system prop's theme scale: `p` → `space`, `borderRadius` → `radii`. */
83
+ styleScales: Record<string, string>;
84
+ components: Record<string, CatalogEntry>;
85
+ }
86
+ /** One thing wrong in a theme's `components`: where it is, and what is wrong there (the message starts with the path). */
87
+ interface ThemeProblem {
88
+ path: string;
89
+ message: string;
90
+ }
91
+ /**
92
+ * Checks a theme's `components` against the catalog, for a mistake the types cannot see (a theme
93
+ * whose types were cast away, plain JavaScript, a theme read from a file): a component the design
94
+ * system lacks, a slot a component has not, a default prop or a look's prop the component does not
95
+ * take, and a default value outside the values the catalog lists for that prop. It returns the
96
+ * problems; it never throws and never changes `components`.
97
+ */
98
+ declare const validateThemeComponents: (components: unknown) => ThemeProblem[];
99
+ /**
100
+ * @description Every component of the design system as data a tool can read - its
101
+ * category, the subpath it is imported from, what a freshly placed one is, its looks as
102
+ * pictures, the props a picker offers and their theme scales, and how its node props and
103
+ * two-way props are written. Pure data: it loads in Node with no DOM and no framework.
104
+ */
105
+ declare const catalog: DesignSystemCatalog;
106
+ export { CatalogEntry as a, CatalogVariant as c, JsonValue as d, ThemeScale as f, CatalogContent as i, DesignSystemCatalog as l, ThemeProblem as n, CatalogOption as o, validateThemeComponents as r, CatalogTwoWay as s, catalog as t, ExampleNode as u };