foldkit-mixins 0.3.0 → 0.5.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 (71) hide show
  1. package/README.md +459 -10
  2. package/dist/app.d.mts +46 -0
  3. package/dist/app.d.mts.map +1 -0
  4. package/dist/app.mjs +45 -0
  5. package/dist/app.mjs.map +1 -0
  6. package/dist/core-Bxj0UQDF.mjs +53 -0
  7. package/dist/core-Bxj0UQDF.mjs.map +1 -0
  8. package/dist/core-CUw_n1Nd.d.mts +40 -0
  9. package/dist/core-CUw_n1Nd.d.mts.map +1 -0
  10. package/dist/defaults.d.mts +31 -0
  11. package/dist/defaults.d.mts.map +1 -0
  12. package/dist/defaults.mjs +75 -0
  13. package/dist/defaults.mjs.map +1 -0
  14. package/dist/foundations.d.mts +30 -0
  15. package/dist/foundations.d.mts.map +1 -0
  16. package/dist/foundations.mjs +71 -0
  17. package/dist/foundations.mjs.map +1 -0
  18. package/dist/index.d.mts +137 -536
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +261 -1017
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/layers-B31M0tDi.mjs +193 -0
  23. package/dist/layers-B31M0tDi.mjs.map +1 -0
  24. package/dist/layers.d.mts +47 -0
  25. package/dist/layers.d.mts.map +1 -0
  26. package/dist/layers.mjs +2 -0
  27. package/dist/layout.d.mts +114 -0
  28. package/dist/layout.d.mts.map +1 -0
  29. package/dist/layout.mjs +154 -0
  30. package/dist/layout.mjs.map +1 -0
  31. package/dist/oklch-BxvCD0oi.d.mts +135 -0
  32. package/dist/oklch-BxvCD0oi.d.mts.map +1 -0
  33. package/dist/prose.d.mts +30 -0
  34. package/dist/prose.d.mts.map +1 -0
  35. package/dist/prose.mjs +61 -0
  36. package/dist/prose.mjs.map +1 -0
  37. package/dist/root-C1u12YMD.mjs +37 -0
  38. package/dist/root-C1u12YMD.mjs.map +1 -0
  39. package/dist/root-xyWS6geK.d.mts +25 -0
  40. package/dist/root-xyWS6geK.d.mts.map +1 -0
  41. package/dist/slotItem-D6_m6IqP.d.mts +18 -0
  42. package/dist/slotItem-D6_m6IqP.d.mts.map +1 -0
  43. package/dist/slotMark-Rdsjb7XI.mjs +135 -0
  44. package/dist/slotMark-Rdsjb7XI.mjs.map +1 -0
  45. package/dist/slotView-BtIF2pHo.d.mts +476 -0
  46. package/dist/slotView-BtIF2pHo.d.mts.map +1 -0
  47. package/dist/style-CKjLee4e.mjs +1266 -0
  48. package/dist/style-CKjLee4e.mjs.map +1 -0
  49. package/dist/style-CtCqaL0l.d.mts +182 -0
  50. package/dist/style-CtCqaL0l.d.mts.map +1 -0
  51. package/dist/styleValue-BavTe9MZ.d.mts +72 -0
  52. package/dist/styleValue-BavTe9MZ.d.mts.map +1 -0
  53. package/dist/styleValue-_G9jwb17.mjs +248 -0
  54. package/dist/styleValue-_G9jwb17.mjs.map +1 -0
  55. package/dist/testing.d.mts +30 -0
  56. package/dist/testing.d.mts.map +1 -0
  57. package/dist/testing.mjs +167 -0
  58. package/dist/testing.mjs.map +1 -0
  59. package/dist/theme.d.mts +193 -0
  60. package/dist/theme.d.mts.map +1 -0
  61. package/dist/theme.mjs +146 -0
  62. package/dist/theme.mjs.map +1 -0
  63. package/dist/tokens-BR_qxDR7.d.mts +91 -0
  64. package/dist/tokens-BR_qxDR7.d.mts.map +1 -0
  65. package/dist/tokens-DteBJVN-.mjs +117 -0
  66. package/dist/tokens-DteBJVN-.mjs.map +1 -0
  67. package/dist/utilities.d.mts +73 -0
  68. package/dist/utilities.d.mts.map +1 -0
  69. package/dist/utilities.mjs +90 -0
  70. package/dist/utilities.mjs.map +1 -0
  71. package/package.json +59 -7
@@ -0,0 +1,53 @@
1
+ import { u as inline } from "./styleValue-_G9jwb17.mjs";
2
+ //#region src/theme/core.ts
3
+ /**
4
+ * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)
5
+ * belongs in the Foldkit Model; `variables` compiles the tokens to CSS custom
6
+ * properties so switching a class or a root style is cheap and SSR-safe.
7
+ */
8
+ const VAR_PREFIX = "--fk";
9
+ const define = (tokens) => Object.freeze(Object.fromEntries(Object.entries(tokens).map(([group, names]) => [group, Object.freeze({ ...names })])));
10
+ const refsByTheme = /* @__PURE__ */ new WeakMap();
11
+ /**
12
+ * The theme's tokens as references: `Theme.ref(theme).surface.overt` is
13
+ * `var(--fk-surface-overt)`, and a group or name the theme lacks is a type
14
+ * error. Only the names are read, never the values. Built once per theme.
15
+ */
16
+ const ref = (theme) => {
17
+ const cached = refsByTheme.get(theme);
18
+ if (cached !== void 0) return cached;
19
+ const built = Object.freeze(Object.fromEntries(Object.entries(theme).map(([group, names]) => [group, Object.freeze(Object.fromEntries(Object.keys(names).map((name) => [name, `var(${VAR_PREFIX}-${group}-${name})`])))])));
20
+ refsByTheme.set(theme, built);
21
+ return built;
22
+ };
23
+ const variables = (theme) => {
24
+ const style = {};
25
+ for (const [group, names] of Object.entries(theme)) for (const [name, value] of Object.entries(names)) style[`${VAR_PREFIX}-${group}-${name}`] = value;
26
+ return inline(style);
27
+ };
28
+ /**
29
+ * A token that follows the user's color scheme with CSS `light-dark()`: no
30
+ * JavaScript and no Model field. A theme the user chooses is the other case,
31
+ * and belongs in the Model as a class on the root; `variables` compiles both.
32
+ */
33
+ const lightDark = (light, dark) => `light-dark(${light}, ${dark})`;
34
+ /** Themes merged at definition time, later tokens winning within a group. */
35
+ const compose = (base, over) => {
36
+ const merged = {};
37
+ for (const source of [base, over]) for (const [group, names] of Object.entries(source)) merged[group] = {
38
+ ...merged[group],
39
+ ...names
40
+ };
41
+ return define(merged);
42
+ };
43
+ const Theme = {
44
+ define,
45
+ ref,
46
+ variables,
47
+ lightDark,
48
+ compose
49
+ };
50
+ //#endregion
51
+ export { lightDark as a, define as i, VAR_PREFIX as n, ref as o, compose as r, variables as s, Theme as t };
52
+
53
+ //# sourceMappingURL=core-Bxj0UQDF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-Bxj0UQDF.mjs","names":[],"sources":["../src/theme/core.ts"],"sourcesContent":["/**\n * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)\n * belongs in the Foldkit Model; `variables` compiles the tokens to CSS custom\n * properties so switching a class or a root style is cheap and SSR-safe.\n */\nimport { inline, type StyleValue } from '../styleValue.js'\n\nexport type ThemeTokens = {\n readonly [group: string]: { readonly [name: string]: string }\n}\n\nexport type Theme<T extends ThemeTokens = ThemeTokens> = T\n\nexport const VAR_PREFIX = '--fk'\n\nexport const define = <T extends ThemeTokens>(tokens: T): Readonly<T> =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([group, names]) => [group, Object.freeze({ ...names })]),\n ),\n ) as Readonly<T>\n\n/** `var(--fk-group-name)` for every token, by the theme's own group and token names. */\nexport type Refs<T extends ThemeTokens> = {\n readonly [G in keyof T & string]: { readonly [N in keyof T[G] & string]: string }\n}\n\nconst refsByTheme = new WeakMap<ThemeTokens, Refs<ThemeTokens>>()\n\n/**\n * The theme's tokens as references: `Theme.ref(theme).surface.overt` is\n * `var(--fk-surface-overt)`, and a group or name the theme lacks is a type\n * error. Only the names are read, never the values. Built once per theme.\n */\nexport const ref = <T extends ThemeTokens>(theme: T): Refs<T> => {\n const cached = refsByTheme.get(theme)\n if (cached !== undefined) return cached as Refs<T>\n const built = Object.freeze(\n Object.fromEntries(\n Object.entries(theme).map(([group, names]) => [\n group,\n Object.freeze(\n Object.fromEntries(\n Object.keys(names).map(name => [name, `var(${VAR_PREFIX}-${group}-${name})`]),\n ),\n ),\n ]),\n ),\n )\n refsByTheme.set(theme, built)\n return built as Refs<T>\n}\n\nexport const variables = <T extends ThemeTokens>(theme: T): StyleValue => {\n const style: Record<`--${string}`, string> = {}\n for (const [group, names] of Object.entries(theme)) {\n for (const [name, value] of Object.entries(names as Record<string, string>)) {\n style[`${VAR_PREFIX}-${group}-${name}`] = value\n }\n }\n return inline(style)\n}\n\n/**\n * A token that follows the user's color scheme with CSS `light-dark()`: no\n * JavaScript and no Model field. A theme the user chooses is the other case,\n * and belongs in the Model as a class on the root; `variables` compiles both.\n */\nexport const lightDark = (light: string, dark: string): string => `light-dark(${light}, ${dark})`\n\ntype Merge<A, B> = {\n readonly [G in keyof A | keyof B]: G extends keyof B\n ? G extends keyof A\n ? A[G] & B[G]\n : B[G]\n : G extends keyof A\n ? A[G]\n : never\n}\n\n/** Themes merged at definition time, later tokens winning within a group. */\nexport const compose = <A extends ThemeTokens, B extends ThemeTokens>(\n base: A,\n over: B,\n): Readonly<Merge<A, B>> => {\n const merged: Record<string, Record<string, string>> = {}\n for (const source of [base, over]) {\n for (const [group, names] of Object.entries(source)) {\n merged[group] = { ...merged[group], ...(names as Record<string, string>) }\n }\n }\n return define(merged) as unknown as Readonly<Merge<A, B>>\n}\n\nexport const Theme = { define, ref, variables, lightDark, compose } as const\n"],"mappings":";;;;;;;AAaA,MAAa,aAAa;AAE1B,MAAa,UAAiC,WAC5C,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,OAAO,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CACrF,CACF;AAOF,MAAM,8BAAc,IAAI,QAAwC;;;;;;AAOhE,MAAa,OAA8B,UAAsB;CAC/D,MAAM,SAAS,YAAY,IAAI,KAAK;CACpC,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,QAAQ,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAC5C,OACA,OAAO,OACL,OAAO,YACL,OAAO,KAAK,KAAK,CAAC,CAAC,KAAI,SAAQ,CAAC,MAAM,OAAO,WAAW,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAC9E,CACF,CACF,CAAC,CACH,CACF;CACA,YAAY,IAAI,OAAO,KAAK;CAC5B,OAAO;AACT;AAEA,MAAa,aAAoC,UAAyB;CACxE,MAAM,QAAuC,CAAC;CAC9C,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,GAC/C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAA+B,GACxE,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU;CAG9C,OAAO,OAAO,KAAK;AACrB;;;;;;AAOA,MAAa,aAAa,OAAe,SAAyB,cAAc,MAAM,IAAI,KAAK;;AAa/F,MAAa,WACX,MACA,SAC0B;CAC1B,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,UAAU,CAAC,MAAM,IAAI,GAC9B,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,MAAM,GAChD,OAAO,SAAS;EAAE,GAAG,OAAO;EAAQ,GAAI;CAAiC;CAG7E,OAAO,OAAO,MAAM;AACtB;AAEA,MAAa,QAAQ;CAAE;CAAQ;CAAK;CAAW;CAAW;AAAQ"}
@@ -0,0 +1,40 @@
1
+ import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
2
+ declare namespace core_d_exports {
3
+ export { Refs, Theme, ThemeTokens, VAR_PREFIX, compose, define, lightDark, ref, variables };
4
+ }
5
+ type ThemeTokens = {
6
+ readonly [group: string]: {
7
+ readonly [name: string]: string;
8
+ };
9
+ };
10
+ type Theme<T extends ThemeTokens = ThemeTokens> = T;
11
+ declare const VAR_PREFIX = "--fk";
12
+ declare const define: <T extends ThemeTokens>(tokens: T) => Readonly<T>;
13
+ /** `var(--fk-group-name)` for every token, by the theme's own group and token names. */
14
+ type Refs<T extends ThemeTokens> = { readonly [G in keyof T & string]: { readonly [N in keyof T[G] & string]: string; }; };
15
+ /**
16
+ * The theme's tokens as references: `Theme.ref(theme).surface.overt` is
17
+ * `var(--fk-surface-overt)`, and a group or name the theme lacks is a type
18
+ * error. Only the names are read, never the values. Built once per theme.
19
+ */
20
+ declare const ref: <T extends ThemeTokens>(theme: T) => Refs<T>;
21
+ declare const variables: <T extends ThemeTokens>(theme: T) => StyleValue;
22
+ /**
23
+ * A token that follows the user's color scheme with CSS `light-dark()`: no
24
+ * JavaScript and no Model field. A theme the user chooses is the other case,
25
+ * and belongs in the Model as a class on the root; `variables` compiles both.
26
+ */
27
+ declare const lightDark: (light: string, dark: string) => string;
28
+ type Merge<A, B> = { readonly [G in keyof A | keyof B]: G extends keyof B ? G extends keyof A ? A[G] & B[G] : B[G] : G extends keyof A ? A[G] : never; };
29
+ /** Themes merged at definition time, later tokens winning within a group. */
30
+ declare const compose: <A extends ThemeTokens, B extends ThemeTokens>(base: A, over: B) => Readonly<Merge<A, B>>;
31
+ declare const Theme: {
32
+ readonly define: <T extends ThemeTokens>(tokens: T) => Readonly<T>;
33
+ readonly ref: <T extends ThemeTokens>(theme: T) => Refs<T>;
34
+ readonly variables: <T extends ThemeTokens>(theme: T) => StyleValue;
35
+ readonly lightDark: (light: string, dark: string) => string;
36
+ readonly compose: <A extends ThemeTokens, B extends ThemeTokens>(base: A, over: B) => Readonly<Merge<A, B>>;
37
+ };
38
+ //#endregion
39
+ export { compose as a, lightDark as c, VAR_PREFIX as i, ref as l, Theme as n, core_d_exports as o, ThemeTokens as r, define as s, Refs as t, variables as u };
40
+ //# sourceMappingURL=core-CUw_n1Nd.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-CUw_n1Nd.d.mts","names":[],"sources":["../src/theme/core.ts"],"mappings":";;;;KAOY;YACA;cAA4B;;;KAG5B,MAAM,UAAU,cAAc,eAAe;cAE5C;cAEA,SAAU,UAAU,aAAa,QAAQ,MAAI,SAAS;;KAQvD,KAAK,UAAU,2BACf,WAAW,yBAAyB,WAAW,EAAE;;;;;;cAUhD,MAAO,UAAU,aAAa,OAAO,MAAI,KAAK;cAmB9C,YAAa,UAAU,aAAa,OAAO,MAAI;;;;;;cAe/C,YAAa,eAAe;KAEpC,MAAM,GAAG,iBACF,WAAW,UAAU,IAAI,gBAAgB,IAC/C,gBAAgB,IACd,EAAE,KAAK,EAAE,KACT,EAAE,KACJ,gBAAgB,IACd,EAAE;;cAKG,UAAW,UAAU,aAAa,UAAU,aACvD,MAAM,GACN,MAAM,MACL,SAAS,MAAM,GAAG;cAUR;WA/EU,SAAA,UAAU,aAAW,QAAU,MAAI,SAAS;WAmB/C,MAAA,UAAU,aAAW,OAAS,MAAI,KAAK;WAmBjC,YAAA,UAAU,aAAW,OAAS,MAAI;WAe3B,YAAA,eAAM;WAaf,UAAA,UAAU,aAAa,UAAU,aAAW,MAC5D,GAAC,MACD,MACL,SAAS,MAAM,GAAG"}
@@ -0,0 +1,31 @@
1
+ import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
2
+ //#region src/defaults.d.ts
3
+ /** Box model, margins, media, form-control fonts: what every page assumes. */
4
+ export declare const reset: StyleValue;
5
+ /** The page's font, color, background, and color scheme. */
6
+ export declare const body: StyleValue;
7
+ /**
8
+ * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A
9
+ * container drawn in a color of its own, such as a band on the accent, sets
10
+ * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.
11
+ */
12
+ export declare const headings: StyleValue;
13
+ /** Link color, hover, and a visible focus ring. */
14
+ export declare const links: StyleValue;
15
+ /** Inline code and code blocks on the subtle surface. */
16
+ export declare const code: StyleValue;
17
+ /** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */
18
+ export declare const controls: StyleValue;
19
+ /** Every default except `reset`, which belongs in its own layer. */
20
+ export declare const all: StyleValue;
21
+ export declare const Defaults: {
22
+ readonly reset: StyleValue;
23
+ readonly body: StyleValue;
24
+ readonly headings: StyleValue;
25
+ readonly links: StyleValue;
26
+ readonly code: StyleValue;
27
+ readonly controls: StyleValue;
28
+ readonly all: StyleValue;
29
+ };
30
+ //#endregion
31
+ //# sourceMappingURL=defaults.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;qBAcP,MAAM;;;;;;qBASN,UAAU;;qBAaV,OAAO;;qBASP,MAAM;;qBASN,UAAU;;qBAaV,KAAK;qBAEL"}
@@ -0,0 +1,75 @@
1
+ import { c as global, i as compose } from "./styleValue-_G9jwb17.mjs";
2
+ //#region src/defaults.ts
3
+ /**
4
+ * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is
5
+ * styled. Every member is element-selector CSS over `--fk-*` tokens with a
6
+ * fallback, so it re-themes with the tokens and still reads without them.
7
+ * The pieces are unlayered; a page puts `reset` in `reset` and the rest in
8
+ * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any
9
+ * class rule beats them.
10
+ */
11
+ const v = (name, fallback) => `var(--fk-${name}, ${fallback})`;
12
+ /** Box model, margins, media, form-control fonts: what every page assumes. */
13
+ const reset = global([
14
+ "*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}",
15
+ ":where(html){text-size-adjust:none;-webkit-text-size-adjust:none;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}",
16
+ ":where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}",
17
+ ":where(:is(input,button,textarea,select)){font:inherit;color:inherit}",
18
+ ":where(textarea){field-sizing:content;min-block-size:2lh}",
19
+ ":where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}",
20
+ ":where(p){text-wrap:pretty;overflow-wrap:break-word}",
21
+ `@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`
22
+ ].join(""));
23
+ /** The page's font, color, background, and color scheme. */
24
+ const body = global(`:where(body){font-family:${v("font-body", "system-ui, sans-serif")};font-size:${v("size-md", "1rem")};line-height:${v("leading-normal", "1.5")};font-weight:${v("weight-normal", "400")};color:${v("text-default", "CanvasText")};background:${v("surface-base", "Canvas")};-webkit-font-smoothing:antialiased}`);
25
+ /**
26
+ * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A
27
+ * container drawn in a color of its own, such as a band on the accent, sets
28
+ * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.
29
+ */
30
+ const headings = global([
31
+ `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v("font-heading", "inherit")};font-weight:${v("weight-bold", "700")};line-height:${v("leading-tight", "1.2")};color:${v("heading", v("text-overt", "inherit"))};letter-spacing:-0.01em}`,
32
+ `:where(h1){font-size:${v("size-4xl", "2.25rem")}}`,
33
+ `:where(h2){font-size:${v("size-3xl", "1.875rem")}}`,
34
+ `:where(h3){font-size:${v("size-2xl", "1.5rem")}}`,
35
+ `:where(h4){font-size:${v("size-xl", "1.25rem")}}`,
36
+ `:where(h5){font-size:${v("size-lg", "1.125rem")}}`,
37
+ `:where(h6){font-size:${v("size-md", "1rem")}}`
38
+ ].join(""));
39
+ /** Link color, hover, and a visible focus ring. */
40
+ const links = global([
41
+ `:where(a){color:${v("text-link", "LinkText")};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,
42
+ `:where(a:hover){color:${v("text-link-hover", "LinkText")}}`,
43
+ `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v("border-thick", "2px")} solid ${v("outline-focus", "Highlight")};outline-offset:2px}`
44
+ ].join(""));
45
+ /** Inline code and code blocks on the subtle surface. */
46
+ const code = global([
47
+ `:where(:is(code,kbd,samp,pre)){font-family:${v("font-mono", "ui-monospace, monospace")};font-size:${v("size-sm", "0.875rem")}}`,
48
+ `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v("radius-sm", "3px")};background:${v("surface-subtle", "transparent")};overflow-wrap:anywhere}`,
49
+ `:where(pre){padding:${v("space-md", "1rem")};border:${v("border-thin", "1px")} solid ${v("outline-subtle", "transparent")};border-radius:${v("radius-md", "6px")};background:${v("surface-subtle", "transparent")};overflow-x:auto;line-height:${v("leading-snug", "1.375")}}`
50
+ ].join(""));
51
+ /** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */
52
+ const controls = global([
53
+ `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v("space-xs", "0.5rem")} ${v("space-sm", "0.75rem")};border:${v("border-thin", "1px")} solid ${v("outline-default", "ButtonBorder")};border-radius:${v("radius-md", "6px")};background:${v("surface-base", "Field")};color:${v("text-default", "FieldText")};transition:border-color ${v("motion-fast", "150ms")} ${v("motion-ease", "ease-out")}}`,
54
+ `:where(:is(input,select,textarea):focus-visible){border-color:${v("accent-default", "Highlight")}}`,
55
+ `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v("error-default", "red")}}`,
56
+ `:where(button,[type=button],[type=submit],[type=reset]){padding:${v("space-xs", "0.5rem")} ${v("space-md", "1rem")};border:${v("border-thin", "1px")} solid ${v("outline-default", "ButtonBorder")};border-radius:${v("radius-md", "6px")};background:${v("surface-subtle", "ButtonFace")};color:${v("text-default", "ButtonText")};cursor:pointer;transition:background ${v("motion-fast", "150ms")} ${v("motion-ease", "ease-out")}}`,
57
+ `:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v("surface-muted", "ButtonFace")}}`,
58
+ `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,
59
+ `:where(:is(input,select,textarea,button)::placeholder){color:${v("text-muted", "GrayText")}}`
60
+ ].join(""));
61
+ /** Every default except `reset`, which belongs in its own layer. */
62
+ const all = compose(body, headings, links, code, controls);
63
+ const Defaults = {
64
+ reset,
65
+ body,
66
+ headings,
67
+ links,
68
+ code,
69
+ controls,
70
+ all
71
+ };
72
+ //#endregion
73
+ export { Defaults, all, body, code, controls, headings, links, reset };
74
+
75
+ //# sourceMappingURL=defaults.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.mjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n ':where(html){text-size-adjust:none;-webkit-text-size-adjust:none;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}',\n ':where(p){text-wrap:pretty;overflow-wrap:break-word}',\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n `:where(a:hover){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-subtle', 'transparent')};overflow-wrap:anywhere}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":"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"}
@@ -0,0 +1,30 @@
1
+ import { Plugin } from "vite";
2
+ //#region src/foundations.d.ts
3
+ /**
4
+ * Compiles the stylesheet a module exports: what the page's first paint is
5
+ * styled with before any script runs. The module is evaluated, so it must be
6
+ * pure (building a string, like the CMS example's sheet).
7
+ */
8
+ export declare const loadFoundations: (options: {
9
+ /** The stylesheet module, root-relative (`/src/styles/sheet.ts`). */
10
+ readonly module: string;
11
+ /** The export holding the stylesheet text. Default `stylesheet`. */
12
+ readonly export?: string | undefined;
13
+ /** What `vite build` runs from. Default the current directory. */
14
+ readonly root?: string | undefined;
15
+ }) => Promise<string>;
16
+ /**
17
+ * Writes the foundations into the page's head: in development through the
18
+ * running server, in a build through one of its own. Without it, each move
19
+ * between pages paints unstyled until the script runs.
20
+ */
21
+ export declare const foundations: (options: {
22
+ /** The stylesheet module, root-relative (`/src/styles/sheet.ts`). */
23
+ readonly module: string;
24
+ /** The export holding the stylesheet text. Default `stylesheet`. */
25
+ readonly export?: string | undefined;
26
+ /** What `vite build` runs from. Default the current directory. */
27
+ readonly root?: string | undefined;
28
+ }) => Plugin;
29
+ //#endregion
30
+ //# sourceMappingURL=foundations.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundations.d.mts","names":[],"sources":["../src/foundations.ts"],"mappings":";;;;;;;qBA4Ca,kBAAyB;;WAE3B;;WAEA;;WAEA;MACP;;;;;;qBA4BS,cAAe;;WAEjB;;WAEA;;WAEA;MACP"}
@@ -0,0 +1,71 @@
1
+ //#region src/foundations.ts
2
+ /** Workspace packages resolve to their source, so the foundations build as edited. */
3
+ const conditions = ["foldkit-plus:source"];
4
+ const loadVite = async () => {
5
+ try {
6
+ return await import("vite");
7
+ } catch {
8
+ throw new Error("foldkit-mixins/foundations needs the 'vite' package: add it where the build runs");
9
+ }
10
+ };
11
+ /** The stylesheet text a loaded module holds, or a refusal naming the export. */
12
+ const readStylesheet = (exported, module, name) => {
13
+ const stylesheet = exported[name];
14
+ if (typeof stylesheet !== "string") throw new Error(`foldkit-mixins/foundations: ${module} exports no ${name} stylesheet`);
15
+ return stylesheet;
16
+ };
17
+ /**
18
+ * Compiles the stylesheet a module exports: what the page's first paint is
19
+ * styled with before any script runs. The module is evaluated, so it must be
20
+ * pure (building a string, like the CMS example's sheet).
21
+ */
22
+ const loadFoundations = async (options) => {
23
+ const { createServer } = await loadVite();
24
+ const server = await createServer({
25
+ configFile: false,
26
+ root: options.root ?? process.cwd(),
27
+ logLevel: "error",
28
+ appType: "custom",
29
+ server: {
30
+ middlewareMode: true,
31
+ hmr: false
32
+ },
33
+ resolve: { conditions },
34
+ ssr: { resolve: { conditions } },
35
+ optimizeDeps: {
36
+ noDiscovery: true,
37
+ include: []
38
+ }
39
+ });
40
+ try {
41
+ return readStylesheet(await server.ssrLoadModule(options.module), options.module, options.export ?? "stylesheet");
42
+ } finally {
43
+ await server.close();
44
+ }
45
+ };
46
+ /**
47
+ * Writes the foundations into the page's head: in development through the
48
+ * running server, in a build through one of its own. Without it, each move
49
+ * between pages paints unstyled until the script runs.
50
+ */
51
+ const foundations = (options) => ({
52
+ name: "foldkit-foundations",
53
+ transformIndexHtml: {
54
+ order: "pre",
55
+ handler: async (_html, context) => {
56
+ return [{
57
+ tag: "style",
58
+ children: context.server === void 0 ? await loadFoundations({
59
+ module: options.module,
60
+ export: options.export,
61
+ root: options.root
62
+ }) : readStylesheet(await context.server.ssrLoadModule(options.module), options.module, options.export ?? "stylesheet"),
63
+ injectTo: "head"
64
+ }];
65
+ }
66
+ }
67
+ });
68
+ //#endregion
69
+ export { foundations, loadFoundations };
70
+
71
+ //# sourceMappingURL=foundations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundations.mjs","names":[],"sources":["../src/foundations.ts"],"sourcesContent":["/**\n * `foldkit-mixins/foundations`: the page's foundations (the reset, the\n * palette, the type) in the HTML, so its first paint already has the\n * theme's background. A view's own Styles still arrive as it draws; this is\n * the one stylesheet that belongs to no view.\n *\n * The stylesheet is compiled from a module the application owns, through a\n * server, as the page would compile it — so the build's foundations are the\n * application's, not a copy. `vite` is loaded only here, never by a page:\n * this subpath is node-only, and a page that imports it by mistake fails\n * fast naming `vite`.\n */\nimport type { HtmlTagDescriptor, Plugin, ViteDevServer } from 'vite'\n\n/** Workspace packages resolve to their source, so the foundations build as edited. */\nconst conditions = ['foldkit-plus:source']\n\nconst loadVite = async (): Promise<typeof import('vite')> => {\n try {\n return await import('vite')\n } catch {\n throw new Error(\n \"foldkit-mixins/foundations needs the 'vite' package: add it where the build runs\",\n )\n }\n}\n\n/** The stylesheet text a loaded module holds, or a refusal naming the export. */\nconst readStylesheet = (\n exported: Record<string, unknown>,\n module: string,\n name: string,\n): string => {\n const stylesheet = exported[name]\n if (typeof stylesheet !== 'string')\n throw new Error(`foldkit-mixins/foundations: ${module} exports no ${name} stylesheet`)\n return stylesheet\n}\n\n/**\n * Compiles the stylesheet a module exports: what the page's first paint is\n * styled with before any script runs. The module is evaluated, so it must be\n * pure (building a string, like the CMS example's sheet).\n */\nexport const loadFoundations = async (options: {\n /** The stylesheet module, root-relative (`/src/styles/sheet.ts`). */\n readonly module: string\n /** The export holding the stylesheet text. Default `stylesheet`. */\n readonly export?: string | undefined\n /** What `vite build` runs from. Default the current directory. */\n readonly root?: string | undefined\n}): Promise<string> => {\n const { createServer } = await loadVite()\n const server = await createServer({\n configFile: false,\n root: options.root ?? process.cwd(),\n logLevel: 'error',\n appType: 'custom',\n server: { middlewareMode: true, hmr: false },\n resolve: { conditions },\n ssr: { resolve: { conditions } },\n optimizeDeps: { noDiscovery: true, include: [] },\n })\n try {\n return readStylesheet(\n (await server.ssrLoadModule(options.module)) as Record<string, unknown>,\n options.module,\n options.export ?? 'stylesheet',\n )\n } finally {\n await server.close()\n }\n}\n\n/**\n * Writes the foundations into the page's head: in development through the\n * running server, in a build through one of its own. Without it, each move\n * between pages paints unstyled until the script runs.\n */\nexport const foundations = (options: {\n /** The stylesheet module, root-relative (`/src/styles/sheet.ts`). */\n readonly module: string\n /** The export holding the stylesheet text. Default `stylesheet`. */\n readonly export?: string | undefined\n /** What `vite build` runs from. Default the current directory. */\n readonly root?: string | undefined\n}): Plugin => ({\n name: 'foldkit-foundations',\n transformIndexHtml: {\n order: 'pre',\n handler: async (\n _html,\n context: { readonly server?: ViteDevServer | undefined },\n ): Promise<Array<HtmlTagDescriptor>> => {\n const stylesheet =\n context.server === undefined\n ? await loadFoundations({\n module: options.module,\n export: options.export,\n root: options.root,\n })\n : readStylesheet(\n (await context.server.ssrLoadModule(options.module)) as Record<string, unknown>,\n options.module,\n options.export ?? 'stylesheet',\n )\n return [{ tag: 'style', children: stylesheet, injectTo: 'head' as const }]\n },\n },\n})\n"],"mappings":";;AAeA,MAAM,aAAa,CAAC,qBAAqB;AAEzC,MAAM,WAAW,YAA4C;CAC3D,IAAI;EACF,OAAO,MAAM,OAAO;CACtB,QAAQ;EACN,MAAM,IAAI,MACR,kFACF;CACF;AACF;;AAGA,MAAM,kBACJ,UACA,QACA,SACW;CACX,MAAM,aAAa,SAAS;CAC5B,IAAI,OAAO,eAAe,UACxB,MAAM,IAAI,MAAM,+BAA+B,OAAO,cAAc,KAAK,YAAY;CACvF,OAAO;AACT;;;;;;AAOA,MAAa,kBAAkB,OAAO,YAOf;CACrB,MAAM,EAAE,iBAAiB,MAAM,SAAS;CACxC,MAAM,SAAS,MAAM,aAAa;EAChC,YAAY;EACZ,MAAM,QAAQ,QAAQ,QAAQ,IAAI;EAClC,UAAU;EACV,SAAS;EACT,QAAQ;GAAE,gBAAgB;GAAM,KAAK;EAAM;EAC3C,SAAS,EAAE,WAAW;EACtB,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE;EAC/B,cAAc;GAAE,aAAa;GAAM,SAAS,CAAC;EAAE;CACjD,CAAC;CACD,IAAI;EACF,OAAO,eACJ,MAAM,OAAO,cAAc,QAAQ,MAAM,GAC1C,QAAQ,QACR,QAAQ,UAAU,YACpB;CACF,UAAU;EACR,MAAM,OAAO,MAAM;CACrB;AACF;;;;;;AAOA,MAAa,eAAe,aAOb;CACb,MAAM;CACN,oBAAoB;EAClB,OAAO;EACP,SAAS,OACP,OACA,YACsC;GAatC,OAAO,CAAC;IAAE,KAAK;IAAS,UAXtB,QAAQ,WAAW,KAAA,IACf,MAAM,gBAAgB;KACpB,QAAQ,QAAQ;KAChB,QAAQ,QAAQ;KAChB,MAAM,QAAQ;IAChB,CAAC,IACD,eACG,MAAM,QAAQ,OAAO,cAAc,QAAQ,MAAM,GAClD,QAAQ,QACR,QAAQ,UAAU,YACpB;IACwC,UAAU;GAAgB,CAAC;EAC3E;CACF;AACF"}