@adea-ai/ui 0.156.0 → 0.157.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 (81) hide show
  1. package/README.md +3 -3
  2. package/dist/components/theme/theme-document.d.ts +1 -1
  3. package/dist/components/theme/theme-document.js.map +1 -1
  4. package/dist/components/theme/theme-provider-value.d.ts +1 -1
  5. package/dist/components/theme/theme-provider-value.js.map +1 -1
  6. package/dist/components/ui/button/button.d.ts.map +1 -1
  7. package/dist/components/ui/button/button.js +3 -3
  8. package/dist/components/ui/button/button.js.map +1 -1
  9. package/dist/lib/fast-icon.d.ts +2 -1
  10. package/dist/lib/fast-icon.d.ts.map +1 -1
  11. package/dist/lib/fast-icon.js +4 -3
  12. package/dist/lib/fast-icon.js.map +1 -1
  13. package/dist/lib/theme-defaults.generated.d.ts.map +1 -1
  14. package/dist/lib/theme-defaults.generated.js +88 -60
  15. package/dist/lib/theme-defaults.generated.js.map +1 -1
  16. package/dist/lib/theme-projection.d.ts +2 -0
  17. package/dist/lib/theme-projection.d.ts.map +1 -1
  18. package/dist/lib/theme-projection.js +2 -2
  19. package/dist/lib/theme-projection.js.map +1 -1
  20. package/dist/lib/theme-types.d.ts +7 -0
  21. package/dist/lib/theme-types.d.ts.map +1 -1
  22. package/dist/lib/theme-types.js +7 -0
  23. package/dist/lib/theme-types.js.map +1 -1
  24. package/dist/r/appearance-editor.json +1 -1
  25. package/dist/r/lib.json +1 -1
  26. package/dist/r/registry.json +3 -3
  27. package/dist/r/src/components/theme/theme-document.ts +1 -1
  28. package/dist/r/src/components/theme/theme-provider-value.ts +1 -1
  29. package/dist/r/src/components/ui/button/button.tsx +12 -3
  30. package/dist/r/src/lib/fast-icon.ts +11 -4
  31. package/dist/r/src/lib/theme-defaults.generated.ts +88 -60
  32. package/dist/r/src/lib/theme-projection.ts +2 -0
  33. package/dist/r/src/lib/theme-types.ts +7 -0
  34. package/dist/r/src/styles/theme-variants.css +608 -370
  35. package/dist/r/src/styles/theme.css +4 -4
  36. package/dist/r/theming.json +1 -1
  37. package/package.json +2 -2
  38. package/registry.json +3 -3
  39. package/src/components/theme/theme-document.ts +1 -1
  40. package/src/components/theme/theme-provider-value.ts +1 -1
  41. package/src/components/ui/button/button.tsx +12 -3
  42. package/src/lib/fast-icon.ts +11 -4
  43. package/src/lib/theme-defaults.generated.ts +88 -60
  44. package/src/lib/theme-projection.ts +2 -0
  45. package/src/lib/theme-types.ts +7 -0
  46. package/src/styles/theme-variants.css +608 -370
  47. package/src/styles/theme.css +4 -4
  48. package/src/styles/themes/aardvark-blue.css +7 -0
  49. package/src/styles/themes/aardvark-ink.css +7 -0
  50. package/src/styles/themes/adea-dark-colorblind.css +22 -15
  51. package/src/styles/themes/adea-dark-high-contrast.css +22 -15
  52. package/src/styles/themes/adea-dark.css +22 -15
  53. package/src/styles/themes/adea-light-colorblind.css +21 -14
  54. package/src/styles/themes/adea-light-high-contrast.css +21 -14
  55. package/src/styles/themes/adea-light.css +22 -15
  56. package/src/styles/themes/ayu-light.css +20 -13
  57. package/src/styles/themes/ayu-mirage.css +21 -14
  58. package/src/styles/themes/ayu.css +22 -15
  59. package/src/styles/themes/catppuccin-frappe.css +16 -9
  60. package/src/styles/themes/catppuccin-latte.css +15 -8
  61. package/src/styles/themes/catppuccin-macchiato.css +16 -9
  62. package/src/styles/themes/catppuccin-mocha.css +16 -9
  63. package/src/styles/themes/dracula.css +16 -9
  64. package/src/styles/themes/everforest-dark.css +19 -12
  65. package/src/styles/themes/everforest-light.css +21 -14
  66. package/src/styles/themes/gruvbox-dark.css +21 -14
  67. package/src/styles/themes/gruvbox-light.css +20 -13
  68. package/src/styles/themes/kanagawa.css +18 -11
  69. package/src/styles/themes/monokai.css +19 -12
  70. package/src/styles/themes/nord-light.css +7 -0
  71. package/src/styles/themes/nord.css +19 -12
  72. package/src/styles/themes/one-dark.css +16 -9
  73. package/src/styles/themes/rosepine-dawn.css +19 -12
  74. package/src/styles/themes/rosepine-moon.css +20 -13
  75. package/src/styles/themes/rosepine.css +20 -13
  76. package/src/styles/themes/solarized-dark.css +19 -12
  77. package/src/styles/themes/solarized-light.css +19 -12
  78. package/src/styles/themes/tokyonight-day.css +7 -0
  79. package/src/styles/themes/tokyonight-night.css +18 -11
  80. package/src/styles/themes/tokyonight-storm.css +18 -11
  81. package/src/styles/themes/vesper.css +22 -15
package/README.md CHANGED
@@ -754,7 +754,7 @@ the committed figures drift from what it measures.
754
754
 
755
755
  | Public import | Gzipped | What it brings |
756
756
  | --------------------------------------------------------------- | ---------- | ------------------------------------- |
757
- | `@adea-ai/ui` → `Button` | 22.5 kB | the floor: Solid, `clsx`, `tw-merge` |
757
+ | `@adea-ai/ui` → `Button` | 22.4 kB | the floor: Solid, `clsx`, `tw-merge` |
758
758
  | `@adea-ai/ui` → `Board` | 22.8 kB | nothing |
759
759
  | `@adea-ai/ui/components/composites/list-row` → `ListRowControl` | 21.9 kB | nothing: the row without its tooltip |
760
760
  | `@adea-ai/ui` → `DiffBlock` | 23.2 kB | lucide icons |
@@ -762,11 +762,11 @@ the committed figures drift from what it measures.
762
762
  | `@adea-ai/ui` → `MessageRow` | 27.8 kB | nothing |
763
763
  | `@adea-ai/ui` → `CalendarSurface` | 30.7 kB | corvu calendar |
764
764
  | `@adea-ai/ui` → `ModalDialog` | 51.2 kB | Kobalte dialog, the shared tooltip |
765
- | `@adea-ai/ui/components/ui/carousel` → `Carousel` | 35.0 kB | embla |
765
+ | `@adea-ai/ui/components/ui/carousel` → `Carousel` | 34.9 kB | embla |
766
766
  | `@adea-ai/ui/components/composites/list-row` → `ListRow` | 42.4 kB | Kobalte tooltip |
767
767
  | `@adea-ai/ui` → `NavigationMenu` | 59.1 kB | Kobalte navigation menu |
768
768
  | `@adea-ai/ui/components/ui/chart` → `LineChart` | 89.9 kB | chart.js, the line controller only |
769
- | _root plus chart and carousel entries_ | _463.1 kB_ | and `Button` is 4.9% of it |
769
+ | _root plus chart and carousel entries_ | _470.3 kB_ | and `Button` is 4.8% of it |
770
770
 
771
771
  The chart splits from itself, which is why chart.js was chosen: `LineChart` is
772
772
  10.6 kB smaller than importing all seven chart types together (89.9 kB against 100.5 kB), because the
@@ -65,7 +65,7 @@ export type ThemeDocumentOptions = {
65
65
  *
66
66
  * With `palette: 'stylesheet'`, `floor` is the one palette write a catalogue
67
67
  * variant still gets: the stylesheet is generated for the default projection, so
68
- * the sixteen `--editor-*` properties are written inline over it. The rest of the
68
+ * the `--editor-*` properties are written inline over it. The rest of the
69
69
  * palette stays in the stylesheet.
70
70
  */
71
71
  editorRoles?: EditorRolesMode;
@@ -1 +1 @@
1
- {"version":3,"file":"theme-document.js","names":[],"sources":["../../../src/components/theme/theme-document.ts"],"sourcesContent":["import {\n applyAppearanceFontSettings,\n normalizeAppearanceEditorFontSettings,\n} from '#lib/appearance-font-settings'\nimport { terminalCssVariables } from '#lib/theme-css'\nimport type { ThemeTokenProjectionOptions } from './token-projection'\nimport { assertThemeTokenProjectionConfig } from './token-projection-options'\nimport type { ThemeEngine } from '#lib/theme-engine'\nimport type { EditorRolesMode, ThemeAppearance, ThemeVariant } from '#lib/theme-types'\nimport { isCustomAccent } from '#lib/accent-roles'\nimport { surfaceAlpha, type SurfaceState } from '#lib/theme-surface'\nimport { resolvedDensity, type ThemeSelection } from './theme-state'\n\n/**\n * The document half of the theme provider: the single writer of `<html>`.\n *\n * Written against the few members of an element it uses, so the rules can be tested\n * on a stand-in. Every question the catalogue answers goes through the\n * {@link ThemeEngine} it is given, so it imports no catalogue code or data.\n */\nexport type ThemeRoot = Pick<\n HTMLElement,\n 'classList' | 'dataset' | 'style' | 'removeAttribute' | 'setAttribute'\n>\n\nexport type ThemeDocumentState = {\n /** What the document shows: the committed selection, or a preview laid over it. */\n selection: ThemeSelection\n appearance: ThemeAppearance\n variant: ThemeVariant\n /**\n * The variant whose terminal palette is pinned over the interface variant's.\n * Absent, the terminal follows the interface theme.\n */\n terminalVariant?: ThemeVariant\n /**\n * The variant whose syntax palette, and the canvas it was measured on, is pinned\n * over the interface variant's `--editor-*` ramp. Absent, code follows the\n * interface theme and no `--editor-background` family is written.\n */\n codeVariant?: ThemeVariant\n /**\n * The resolved surface axis. Absent, the axis is off: no attribute and no\n * `--surface-alpha` is written, and any this writer wrote before is removed.\n */\n surface?: SurfaceState\n}\n\nexport type ThemeDocumentOptions = {\n /**\n * Rewrites the custom properties just before they are written: the variant's\n * roles with the accent laid over them. It sees every property of the pass and\n * must return the full map; a name it drops is not written.\n */\n transformTokens?: (tokens: Record<string, string>) => Record<string, string>\n /**\n * The contrast an accent is held to against the variant's background. Absent, a\n * preset is painted verbatim (the catalogue measured it for its own themes) and\n * only a custom `#rrggbb` is held to the default floor of 3:1.\n */\n accentContrastFloor?: number\n /**\n * Where a catalogue variant's palette comes from. `inline` (the default) writes\n * every role onto the root. `stylesheet` writes none for a catalogue variant,\n * because the host loads a stylesheet that carries a `[data-theme]` block for it;\n * a variant the catalogue does not hold (a host's imported theme) is still written\n * inline, since no stylesheet can know it. The accent, the terminal pin, the\n * surface alpha and the fonts are written the same in both.\n *\n * Switching from an imported variant back to a catalogue one removes what the\n * imported one wrote, so nothing inline outlives it to beat the stylesheet.\n */\n palette?: 'inline' | 'stylesheet'\n /**\n * The `--editor-*` projection. `syntax` (the default) is the catalogue's quiet\n * syntax roles, which is what `theme-variants.css` carries; `floor` holds every\n * editor role to 4.5:1 on the canvas, as hex.\n *\n * With `palette: 'stylesheet'`, `floor` is the one palette write a catalogue\n * variant still gets: the stylesheet is generated for the default projection, so\n * the sixteen `--editor-*` properties are written inline over it. The rest of the\n * palette stays in the stylesheet.\n */\n editorRoles?: EditorRolesMode\n} & ThemeTokenProjectionOptions\n\n/**\n * What a catalogue variant still writes inline when its palette is the stylesheet's:\n * nothing, unless the editor projection is not the one the stylesheet was generated\n * for.\n */\nfunction stylesheetOverrides(\n engine: ThemeEngine,\n variant: ThemeVariant,\n editorRoles: EditorRolesMode | undefined\n): Record<string, string> {\n if (editorRoles !== 'floor') return {}\n return Object.fromEntries(\n Object.entries(engine.themeCssVariables(variant, { editor: 'floor' })).filter(([name]) =>\n name.startsWith('--editor-')\n )\n )\n}\n\n/**\n * The properties a pinned code theme writes: its `--editor-*` syntax ramp under the\n * host's projection, and the four canvas roles that ramp was measured against. Code\n * surfaces read the canvas as `var(--editor-background, var(--background))`, so the\n * interface canvas is the fallback whenever nothing is pinned.\n */\nexport function codeCssVariables(\n engine: ThemeEngine,\n variant: ThemeVariant,\n editorRoles?: EditorRolesMode\n): Record<string, string> {\n const all = engine.themeCssVariables(variant, { editor: editorRoles })\n const properties: Record<string, string> = {}\n for (const [name, value] of Object.entries(all)) {\n if (name.startsWith('--editor-')) properties[name] = value\n }\n properties['--editor-background'] = all['--background'] ?? variant.colors.background\n properties['--editor-foreground'] = all['--foreground'] ?? variant.colors.foreground\n properties['--editor-muted-foreground'] =\n all['--muted-foreground'] ?? variant.colors.mutedForeground\n properties['--editor-border'] = all['--border'] ?? variant.colors.border\n return properties\n}\n\n/**\n * The custom properties a state paints: the variant's roles, an optional projection\n * from the raw host map, the accent, the pinned terminal and code palettes, the surface alpha,\n * then `transformTokens`.\n *\n * The accent is applied *here* rather than left to the `[data-accent]` blocks in\n * `theme.css`, because the properties are written inline and an inline declaration\n * outranks every stylesheet selector however specific it is. The blocks still exist\n * and are still correct — they are what styles the window before this runs — but\n * they cannot win from here, so leaving the accent to them meant the attribute was\n * set, the rules were present, and nothing changed on screen.\n */\nexport function themeDocumentTokens(\n engine: ThemeEngine,\n state: ThemeDocumentState,\n options: ThemeDocumentOptions = {}\n): { tokens: Record<string, string>; accented: boolean } {\n assertThemeTokenProjectionConfig(options.tokenProjection)\n const fromStylesheet =\n options.palette === 'stylesheet' && engine.isCatalogueVariant(state.variant)\n const properties = fromStylesheet\n ? stylesheetOverrides(engine, state.variant, options.editorRoles)\n : { ...engine.themeCssVariables(state.variant, { editor: options.editorRoles }) }\n if (options.tokenProjection && !engine.isCatalogueVariant(state.variant)) {\n const rawTokens = state.variant.tokens ?? {}\n const projected = options.tokenProjection.project(rawTokens, options.tokenProjection.rules)\n for (const rule of options.tokenProjection.rules) {\n if (!rule || typeof rule.target !== 'string') continue\n if (Object.hasOwn(projected, rule.target)) {\n properties[rule.target] = projected[rule.target]!\n }\n }\n }\n const accent = engine.accentVariables(state.selection.accent, state.appearance, state.selection, {\n background: state.variant.colors.background,\n floor: options.accentContrastFloor,\n variantId: state.variant.id,\n })\n if (accent) Object.assign(properties, accent)\n // Written after the variant and the accent, so it wins over the interface\n // variant's own terminal ramp (and over the stylesheet's, which it outranks as an\n // inline declaration). Dropping the pin needs no removal of its own: the ramp is\n // then rewritten by the variant, or swept back to the stylesheet.\n if (state.terminalVariant) Object.assign(properties, terminalCssVariables(state.terminalVariant))\n // The same rule for code: the pinned ramp wins over the interface variant's, and its\n // canvas comes with it. Unpinning drops the canvas properties from this pass, so the\n // previous-set sweep removes them and code falls back to the interface canvas.\n if (state.codeVariant)\n Object.assign(properties, codeCssVariables(engine, state.codeVariant, options.editorRoles))\n if (state.surface) properties['--surface-alpha'] = surfaceAlpha[state.surface.surface]\n return {\n tokens: options.transformTokens ? options.transformTokens(properties) : properties,\n accented: accent !== undefined,\n }\n}\n\n/**\n * Write a state onto a root and report which custom properties it owns.\n *\n * Pass the previous call's return as `previous` and any palette property that pass\n * wrote and this one does not is removed. For the catalogue the two sets are the\n * same, so nothing is ever removed; it matters for a host variant that carries\n * `tokens` the catalogue does not, which would otherwise stay inline, beating the\n * stylesheet, after the user switched away from it.\n */\nexport function applyThemeToRoot(\n engine: ThemeEngine,\n root: ThemeRoot,\n state: ThemeDocumentState,\n options: ThemeDocumentOptions = {},\n previous?: ReadonlySet<string>\n): ReadonlySet<string> {\n const { tokens, accented } = themeDocumentTokens(engine, state, options)\n\n // Every pass recomputes the whole token set (an accent or font step included);\n // only the values that changed are written, so an unchanged palette does not\n // dirty the document's style. Custom property values read back as written.\n for (const [name, value] of Object.entries(tokens)) {\n if (root.style.getPropertyValue(name) !== value) root.style.setProperty(name, value)\n }\n if (previous) {\n for (const name of previous) {\n if (!(name in tokens)) root.style.removeProperty(name)\n }\n }\n\n root.classList.toggle('dark', state.appearance === 'dark')\n setData(root, 'theme', state.variant.id)\n setData(root, 'appearance', state.appearance)\n if (root.style.colorScheme !== state.appearance) root.style.colorScheme = state.appearance\n\n // A custom colour has no stylesheet block to select, and its value is the\n // attribute's worst possible content, so it is reported as `custom`.\n if (!accented) root.removeAttribute('data-accent')\n else\n setData(\n root,\n 'accent',\n isCustomAccent(state.selection.accent) ? 'custom' : state.selection.accent\n )\n\n // The surface axis is opt-in, so its absence removes rather than defaults: a host\n // that never enables it keeps an `<html>` with neither attribute, and one that\n // turns it off leaves nothing behind. (`--surface-alpha` is swept with the tokens.)\n if (state.surface) {\n setData(root, 'surface', state.surface.surface)\n setData(root, 'reduceTransparency', state.surface.reduceTransparencyActive ? 'true' : 'false')\n } else {\n root.removeAttribute('data-surface')\n root.removeAttribute('data-reduce-transparency')\n }\n\n applyAppearanceFontSettings(\n root,\n normalizeAppearanceEditorFontSettings(state.selection.fonts, state.selection.font).settings\n )\n\n const density = resolvedDensity(state.selection)\n if (density === 'comfortable') root.removeAttribute('data-density')\n else setData(root, 'density', density)\n\n return new Set(Object.keys(tokens))\n}\n\n/** Rewriting an attribute with its own value still queues a mutation and a style check. */\nfunction setData(root: ThemeRoot, key: string, value: string) {\n if (root.dataset[key] !== value) root.dataset[key] = value\n}\n\n/** What {@link applyWithoutTransitions} needs of a document. */\nexport type TransitionDocument = {\n head: { appendChild(node: unknown): unknown }\n createElement(tag: 'style'): {\n textContent: string | null\n offsetHeight?: number\n remove(): void\n }\n}\n\n/**\n * Run `apply` with every CSS transition switched off for the frame that carries\n * it, so a theme switch cannot animate page-wide.\n *\n * Without this, flipping the custom properties on `<html>` starts a transition on\n * every element that declares one, and each fades from the old palette to the new\n * over its own duration: a theme change that looks like a rendering fault. The\n * rule is removed two frames later, after the browser has committed the new styles\n * with transitions off, and `restore` runs it early (the provider calls it when it\n * is disposed mid-switch).\n *\n * `schedule` is the frame source; it defaults to `requestAnimationFrame` and falls\n * back to running at once where there is none, which leaves transitions on rather\n * than off.\n */\nexport function applyWithoutTransitions(\n doc: TransitionDocument,\n apply: () => void,\n schedule: (callback: () => void) => void = defaultSchedule\n): () => void {\n const style = doc.createElement('style')\n style.textContent = '*{transition:none !important}'\n doc.head.appendChild(style)\n // Reading a layout property forces the browser to commit the rule before the\n // properties change; without it the two can be batched into one style recalc.\n void style.offsetHeight\n let removed = false\n const restore = () => {\n if (removed) return\n removed = true\n style.remove()\n }\n try {\n apply()\n } catch (error) {\n restore()\n throw error\n }\n schedule(() => schedule(restore))\n return restore\n}\n\nfunction defaultSchedule(callback: () => void): void {\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(callback)\n else callback()\n}\n"],"mappings":";;;;;;;;;;;;AA2FA,SAAS,oBACP,QACA,SACA,aACwB;CACxB,IAAI,gBAAgB,SAAS,OAAO,CAAC;CACrC,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,kBAAkB,SAAS,EAAE,QAAQ,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAC9E,KAAK,WAAW,WAAW,CAC7B,CACF;AACF;;;;;;;AAQA,SAAgB,iBACd,QACA,SACA,aACwB;CACxB,MAAM,MAAM,OAAO,kBAAkB,SAAS,EAAE,QAAQ,YAAY,CAAC;CACrE,MAAM,aAAqC,CAAC;CAC5C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,GAAG,GAC5C,IAAI,KAAK,WAAW,WAAW,GAAG,WAAW,QAAQ;CAEvD,WAAW,yBAAyB,IAAI,mBAAmB,QAAQ,OAAO;CAC1E,WAAW,yBAAyB,IAAI,mBAAmB,QAAQ,OAAO;CAC1E,WAAW,+BACT,IAAI,yBAAyB,QAAQ,OAAO;CAC9C,WAAW,qBAAqB,IAAI,eAAe,QAAQ,OAAO;CAClE,OAAO;AACT;;;;;;;;;;;;;AAcA,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A2C,iBAC/B;CACZ,MAAM,QAAQ,IAAI,cAAc,OAAO;CACvC,MAAM,cAAc;CACpB,IAAI,KAAK,YAAY,KAAK;CAG1B,MAAW;CACX,IAAI,UAAU;CACd,MAAM,gBAAgB;EACpB,IAAI,SAAS;EACb,UAAU;EACV,MAAM,OAAO;CACf;CACA,IAAI;EACF,MAAM;CACR,SAAS,OAAO;EACd,QAAQ;EACR,MAAM;CACR;CACA,eAAe,SAAS,OAAO,CAAC;CAChC,OAAO;AACT;AAEA,SAAS,gBAAgB,UAA4B;CACnD,IAAI,OAAO,0BAA0B,YAAY,sBAAsB,QAAQ;MAC1E,SAAS;AAChB"}
1
+ {"version":3,"file":"theme-document.js","names":[],"sources":["../../../src/components/theme/theme-document.ts"],"sourcesContent":["import {\n applyAppearanceFontSettings,\n normalizeAppearanceEditorFontSettings,\n} from '#lib/appearance-font-settings'\nimport { terminalCssVariables } from '#lib/theme-css'\nimport type { ThemeTokenProjectionOptions } from './token-projection'\nimport { assertThemeTokenProjectionConfig } from './token-projection-options'\nimport type { ThemeEngine } from '#lib/theme-engine'\nimport type { EditorRolesMode, ThemeAppearance, ThemeVariant } from '#lib/theme-types'\nimport { isCustomAccent } from '#lib/accent-roles'\nimport { surfaceAlpha, type SurfaceState } from '#lib/theme-surface'\nimport { resolvedDensity, type ThemeSelection } from './theme-state'\n\n/**\n * The document half of the theme provider: the single writer of `<html>`.\n *\n * Written against the few members of an element it uses, so the rules can be tested\n * on a stand-in. Every question the catalogue answers goes through the\n * {@link ThemeEngine} it is given, so it imports no catalogue code or data.\n */\nexport type ThemeRoot = Pick<\n HTMLElement,\n 'classList' | 'dataset' | 'style' | 'removeAttribute' | 'setAttribute'\n>\n\nexport type ThemeDocumentState = {\n /** What the document shows: the committed selection, or a preview laid over it. */\n selection: ThemeSelection\n appearance: ThemeAppearance\n variant: ThemeVariant\n /**\n * The variant whose terminal palette is pinned over the interface variant's.\n * Absent, the terminal follows the interface theme.\n */\n terminalVariant?: ThemeVariant\n /**\n * The variant whose syntax palette, and the canvas it was measured on, is pinned\n * over the interface variant's `--editor-*` ramp. Absent, code follows the\n * interface theme and no `--editor-background` family is written.\n */\n codeVariant?: ThemeVariant\n /**\n * The resolved surface axis. Absent, the axis is off: no attribute and no\n * `--surface-alpha` is written, and any this writer wrote before is removed.\n */\n surface?: SurfaceState\n}\n\nexport type ThemeDocumentOptions = {\n /**\n * Rewrites the custom properties just before they are written: the variant's\n * roles with the accent laid over them. It sees every property of the pass and\n * must return the full map; a name it drops is not written.\n */\n transformTokens?: (tokens: Record<string, string>) => Record<string, string>\n /**\n * The contrast an accent is held to against the variant's background. Absent, a\n * preset is painted verbatim (the catalogue measured it for its own themes) and\n * only a custom `#rrggbb` is held to the default floor of 3:1.\n */\n accentContrastFloor?: number\n /**\n * Where a catalogue variant's palette comes from. `inline` (the default) writes\n * every role onto the root. `stylesheet` writes none for a catalogue variant,\n * because the host loads a stylesheet that carries a `[data-theme]` block for it;\n * a variant the catalogue does not hold (a host's imported theme) is still written\n * inline, since no stylesheet can know it. The accent, the terminal pin, the\n * surface alpha and the fonts are written the same in both.\n *\n * Switching from an imported variant back to a catalogue one removes what the\n * imported one wrote, so nothing inline outlives it to beat the stylesheet.\n */\n palette?: 'inline' | 'stylesheet'\n /**\n * The `--editor-*` projection. `syntax` (the default) is the catalogue's quiet\n * syntax roles, which is what `theme-variants.css` carries; `floor` holds every\n * editor role to 4.5:1 on the canvas, as hex.\n *\n * With `palette: 'stylesheet'`, `floor` is the one palette write a catalogue\n * variant still gets: the stylesheet is generated for the default projection, so\n * the `--editor-*` properties are written inline over it. The rest of the\n * palette stays in the stylesheet.\n */\n editorRoles?: EditorRolesMode\n} & ThemeTokenProjectionOptions\n\n/**\n * What a catalogue variant still writes inline when its palette is the stylesheet's:\n * nothing, unless the editor projection is not the one the stylesheet was generated\n * for.\n */\nfunction stylesheetOverrides(\n engine: ThemeEngine,\n variant: ThemeVariant,\n editorRoles: EditorRolesMode | undefined\n): Record<string, string> {\n if (editorRoles !== 'floor') return {}\n return Object.fromEntries(\n Object.entries(engine.themeCssVariables(variant, { editor: 'floor' })).filter(([name]) =>\n name.startsWith('--editor-')\n )\n )\n}\n\n/**\n * The properties a pinned code theme writes: its `--editor-*` syntax ramp under the\n * host's projection, and the four canvas roles that ramp was measured against. Code\n * surfaces read the canvas as `var(--editor-background, var(--background))`, so the\n * interface canvas is the fallback whenever nothing is pinned.\n */\nexport function codeCssVariables(\n engine: ThemeEngine,\n variant: ThemeVariant,\n editorRoles?: EditorRolesMode\n): Record<string, string> {\n const all = engine.themeCssVariables(variant, { editor: editorRoles })\n const properties: Record<string, string> = {}\n for (const [name, value] of Object.entries(all)) {\n if (name.startsWith('--editor-')) properties[name] = value\n }\n properties['--editor-background'] = all['--background'] ?? variant.colors.background\n properties['--editor-foreground'] = all['--foreground'] ?? variant.colors.foreground\n properties['--editor-muted-foreground'] =\n all['--muted-foreground'] ?? variant.colors.mutedForeground\n properties['--editor-border'] = all['--border'] ?? variant.colors.border\n return properties\n}\n\n/**\n * The custom properties a state paints: the variant's roles, an optional projection\n * from the raw host map, the accent, the pinned terminal and code palettes, the surface alpha,\n * then `transformTokens`.\n *\n * The accent is applied *here* rather than left to the `[data-accent]` blocks in\n * `theme.css`, because the properties are written inline and an inline declaration\n * outranks every stylesheet selector however specific it is. The blocks still exist\n * and are still correct — they are what styles the window before this runs — but\n * they cannot win from here, so leaving the accent to them meant the attribute was\n * set, the rules were present, and nothing changed on screen.\n */\nexport function themeDocumentTokens(\n engine: ThemeEngine,\n state: ThemeDocumentState,\n options: ThemeDocumentOptions = {}\n): { tokens: Record<string, string>; accented: boolean } {\n assertThemeTokenProjectionConfig(options.tokenProjection)\n const fromStylesheet =\n options.palette === 'stylesheet' && engine.isCatalogueVariant(state.variant)\n const properties = fromStylesheet\n ? stylesheetOverrides(engine, state.variant, options.editorRoles)\n : { ...engine.themeCssVariables(state.variant, { editor: options.editorRoles }) }\n if (options.tokenProjection && !engine.isCatalogueVariant(state.variant)) {\n const rawTokens = state.variant.tokens ?? {}\n const projected = options.tokenProjection.project(rawTokens, options.tokenProjection.rules)\n for (const rule of options.tokenProjection.rules) {\n if (!rule || typeof rule.target !== 'string') continue\n if (Object.hasOwn(projected, rule.target)) {\n properties[rule.target] = projected[rule.target]!\n }\n }\n }\n const accent = engine.accentVariables(state.selection.accent, state.appearance, state.selection, {\n background: state.variant.colors.background,\n floor: options.accentContrastFloor,\n variantId: state.variant.id,\n })\n if (accent) Object.assign(properties, accent)\n // Written after the variant and the accent, so it wins over the interface\n // variant's own terminal ramp (and over the stylesheet's, which it outranks as an\n // inline declaration). Dropping the pin needs no removal of its own: the ramp is\n // then rewritten by the variant, or swept back to the stylesheet.\n if (state.terminalVariant) Object.assign(properties, terminalCssVariables(state.terminalVariant))\n // The same rule for code: the pinned ramp wins over the interface variant's, and its\n // canvas comes with it. Unpinning drops the canvas properties from this pass, so the\n // previous-set sweep removes them and code falls back to the interface canvas.\n if (state.codeVariant)\n Object.assign(properties, codeCssVariables(engine, state.codeVariant, options.editorRoles))\n if (state.surface) properties['--surface-alpha'] = surfaceAlpha[state.surface.surface]\n return {\n tokens: options.transformTokens ? options.transformTokens(properties) : properties,\n accented: accent !== undefined,\n }\n}\n\n/**\n * Write a state onto a root and report which custom properties it owns.\n *\n * Pass the previous call's return as `previous` and any palette property that pass\n * wrote and this one does not is removed. For the catalogue the two sets are the\n * same, so nothing is ever removed; it matters for a host variant that carries\n * `tokens` the catalogue does not, which would otherwise stay inline, beating the\n * stylesheet, after the user switched away from it.\n */\nexport function applyThemeToRoot(\n engine: ThemeEngine,\n root: ThemeRoot,\n state: ThemeDocumentState,\n options: ThemeDocumentOptions = {},\n previous?: ReadonlySet<string>\n): ReadonlySet<string> {\n const { tokens, accented } = themeDocumentTokens(engine, state, options)\n\n // Every pass recomputes the whole token set (an accent or font step included);\n // only the values that changed are written, so an unchanged palette does not\n // dirty the document's style. Custom property values read back as written.\n for (const [name, value] of Object.entries(tokens)) {\n if (root.style.getPropertyValue(name) !== value) root.style.setProperty(name, value)\n }\n if (previous) {\n for (const name of previous) {\n if (!(name in tokens)) root.style.removeProperty(name)\n }\n }\n\n root.classList.toggle('dark', state.appearance === 'dark')\n setData(root, 'theme', state.variant.id)\n setData(root, 'appearance', state.appearance)\n if (root.style.colorScheme !== state.appearance) root.style.colorScheme = state.appearance\n\n // A custom colour has no stylesheet block to select, and its value is the\n // attribute's worst possible content, so it is reported as `custom`.\n if (!accented) root.removeAttribute('data-accent')\n else\n setData(\n root,\n 'accent',\n isCustomAccent(state.selection.accent) ? 'custom' : state.selection.accent\n )\n\n // The surface axis is opt-in, so its absence removes rather than defaults: a host\n // that never enables it keeps an `<html>` with neither attribute, and one that\n // turns it off leaves nothing behind. (`--surface-alpha` is swept with the tokens.)\n if (state.surface) {\n setData(root, 'surface', state.surface.surface)\n setData(root, 'reduceTransparency', state.surface.reduceTransparencyActive ? 'true' : 'false')\n } else {\n root.removeAttribute('data-surface')\n root.removeAttribute('data-reduce-transparency')\n }\n\n applyAppearanceFontSettings(\n root,\n normalizeAppearanceEditorFontSettings(state.selection.fonts, state.selection.font).settings\n )\n\n const density = resolvedDensity(state.selection)\n if (density === 'comfortable') root.removeAttribute('data-density')\n else setData(root, 'density', density)\n\n return new Set(Object.keys(tokens))\n}\n\n/** Rewriting an attribute with its own value still queues a mutation and a style check. */\nfunction setData(root: ThemeRoot, key: string, value: string) {\n if (root.dataset[key] !== value) root.dataset[key] = value\n}\n\n/** What {@link applyWithoutTransitions} needs of a document. */\nexport type TransitionDocument = {\n head: { appendChild(node: unknown): unknown }\n createElement(tag: 'style'): {\n textContent: string | null\n offsetHeight?: number\n remove(): void\n }\n}\n\n/**\n * Run `apply` with every CSS transition switched off for the frame that carries\n * it, so a theme switch cannot animate page-wide.\n *\n * Without this, flipping the custom properties on `<html>` starts a transition on\n * every element that declares one, and each fades from the old palette to the new\n * over its own duration: a theme change that looks like a rendering fault. The\n * rule is removed two frames later, after the browser has committed the new styles\n * with transitions off, and `restore` runs it early (the provider calls it when it\n * is disposed mid-switch).\n *\n * `schedule` is the frame source; it defaults to `requestAnimationFrame` and falls\n * back to running at once where there is none, which leaves transitions on rather\n * than off.\n */\nexport function applyWithoutTransitions(\n doc: TransitionDocument,\n apply: () => void,\n schedule: (callback: () => void) => void = defaultSchedule\n): () => void {\n const style = doc.createElement('style')\n style.textContent = '*{transition:none !important}'\n doc.head.appendChild(style)\n // Reading a layout property forces the browser to commit the rule before the\n // properties change; without it the two can be batched into one style recalc.\n void style.offsetHeight\n let removed = false\n const restore = () => {\n if (removed) return\n removed = true\n style.remove()\n }\n try {\n apply()\n } catch (error) {\n restore()\n throw error\n }\n schedule(() => schedule(restore))\n return restore\n}\n\nfunction defaultSchedule(callback: () => void): void {\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(callback)\n else callback()\n}\n"],"mappings":";;;;;;;;;;;;AA2FA,SAAS,oBACP,QACA,SACA,aACwB;CACxB,IAAI,gBAAgB,SAAS,OAAO,CAAC;CACrC,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,kBAAkB,SAAS,EAAE,QAAQ,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAC9E,KAAK,WAAW,WAAW,CAC7B,CACF;AACF;;;;;;;AAQA,SAAgB,iBACd,QACA,SACA,aACwB;CACxB,MAAM,MAAM,OAAO,kBAAkB,SAAS,EAAE,QAAQ,YAAY,CAAC;CACrE,MAAM,aAAqC,CAAC;CAC5C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,GAAG,GAC5C,IAAI,KAAK,WAAW,WAAW,GAAG,WAAW,QAAQ;CAEvD,WAAW,yBAAyB,IAAI,mBAAmB,QAAQ,OAAO;CAC1E,WAAW,yBAAyB,IAAI,mBAAmB,QAAQ,OAAO;CAC1E,WAAW,+BACT,IAAI,yBAAyB,QAAQ,OAAO;CAC9C,WAAW,qBAAqB,IAAI,eAAe,QAAQ,OAAO;CAClE,OAAO;AACT;;;;;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ACd,KACA,OACA,WAA2C,iBAC/B;CACZ,MAAM,QAAQ,IAAI,cAAc,OAAO;CACvC,MAAM,cAAc;CACpB,IAAI,KAAK,YAAY,KAAK;CAG1B,MAAW;CACX,IAAI,UAAU;CACd,MAAM,gBAAgB;EACpB,IAAI,SAAS;EACb,UAAU;EACV,MAAM,OAAO;CACf;CACA,IAAI;EACF,MAAM;CACR,SAAS,OAAO;EACd,QAAQ;EACR,MAAM;CACR;CACA,eAAe,SAAS,OAAO,CAAC;CAChC,OAAO;AACT;AAEA,SAAS,gBAAgB,UAA4B;CACnD,IAAI,OAAO,0BAA0B,YAAY,sBAAsB,QAAQ;MAC1E,SAAS;AAChB"}
@@ -117,7 +117,7 @@ export type ThemeProviderProps = {
117
117
  /**
118
118
  * The projection behind the `--editor-*` ramp. `syntax` (the default) is the
119
119
  * catalogue's quiet syntax roles, a comment among them deliberately below
120
- * body-text contrast. `floor` holds all sixteen roles to 4.5:1 on the canvas, as
120
+ * body-text contrast. `floor` holds every role to 4.5:1 on the canvas, as
121
121
  * hex, for a host that renders code as content (a diff, a file view) rather than
122
122
  * as decoration.
123
123
  *
@@ -1 +1 @@
1
- {"version":3,"file":"theme-provider-value.js","names":[],"sources":["../../../src/components/theme/theme-provider-value.ts"],"sourcesContent":["import type { JSX } from 'solid-js'\nimport {\n createComponent,\n createEffect,\n createMemo,\n createSignal,\n onCleanup,\n splitProps,\n untrack,\n} from 'solid-js'\nimport type { ThemeTokenProjectionOptions } from './token-projection'\nimport { assertThemeTokenProjectionConfig } from './token-projection-options'\nimport { fontZoomShortcut, type FontZoomIntent } from '#lib/font-zoom'\nimport { DEFAULT_THEME_STORAGE_KEY } from '#lib/theme-defaults'\nimport { REDUCED_TRANSPARENCY_QUERY, resolveSurfaceState } from '#lib/theme-surface'\nimport { needsCatalogue, pairNeedsData, type ThemeEngine } from '#lib/theme-engine'\nimport type { EditorRolesMode, ThemeAppearance, ThemeVariant } from '#lib/theme-types'\nimport { themeContext } from './theme-context'\nimport { applyThemeToRoot, applyWithoutTransitions } from './theme-document'\nimport {\n localStoragePersistence,\n readPersisted,\n writePersisted,\n type ThemePersistence,\n} from './theme-persistence'\nimport {\n accentRolesForState,\n initialThemeSelection,\n mergeRegistry,\n mergeThemeSelection,\n resolveCodeVariant,\n resolveTerminalVariant,\n resolveThemeState,\n zoomedFontSettings,\n type ThemeContextValue,\n type ThemeSelection,\n} from './theme-state'\n\n/**\n * The props both `ThemeProvider`s take.\n *\n * ## What a preference is\n *\n * Four independent choices (`ThemeSelection`), and keeping them independent is the\n * point: appearance, a theme per appearance, an accent and fonts. They compose: a\n * user who wants Nord with a violet accent and the system font should not need\n * someone to author that combination.\n *\n * ## Where the rules live\n *\n * The provider is wiring. What a selection merges to and resolves to is\n * `theme-state.ts`; what lands on `<html>` is `theme-document.ts`; where the\n * preference is kept is `theme-persistence.ts`.\n *\n * ## Why the variants are applied as inline properties\n *\n * The catalogue is data, and a theme is applied by writing its roles onto\n * `<html>` as custom properties. That is what makes an imported palette work\n * without a hand-written `[data-theme]` block per theme, and it is why a settings\n * UI can show a preview by reading the same object rather than by loading a\n * stylesheet. `theme.css` keeps the default theme's values so the first paint is\n * correct before any script runs.\n */\nexport type ThemeProviderProps = {\n children?: JSX.Element\n /** Where the preference is persisted. Distinct per application. */\n storageKey?: string\n /** Start from this instead of the stored preference. */\n initial?: Partial<ThemeSelection>\n /**\n * The selection, owned by the caller.\n *\n * For a consumer that keeps the state itself — a settings store, or a workshop\n * whose selection lives in Storybook globals — rather than handing it to this\n * provider's signal. Each change lands here and the document follows; nothing is\n * written to the store, because the caller is the one who persists. A picker\n * below the provider still works, and its change is the caller's to read back.\n *\n * Absent, the provider is the whole owner: it reads `storageKey` on mount,\n * seeds from `initial`, and persists every `setSelection`.\n */\n selection?: Partial<ThemeSelection>\n /**\n * Where the preference is kept, in place of `localStorage` under `storageKey`.\n *\n * Read once when the provider is created, so changing the prop later does not\n * move the store. `storageKey` is ignored when this is given.\n */\n persistence?: ThemePersistence\n /**\n * Variants the host adds to the built-in catalogue — themes a user imported.\n *\n * A function is read inside the provider's reactive scope, so one that reads a\n * signal keeps the picker and the document current when the set changes. A\n * stored id that names no variant, built in or added, paints the default of its\n * appearance and stays in the selection untouched.\n */\n themes?: readonly ThemeVariant[] | (() => readonly ThemeVariant[])\n /**\n * Rewrites the custom properties of each pass before they are written to\n * `<html>`: the variant's roles with the accent over them. `tokensAsHex` from\n * `lib/themes` is the one the system ships.\n */\n transformTokens?: (tokens: Record<string, string>) => Record<string, string>\n /**\n * Switch CSS transitions off for the frame that carries a change, so a theme\n * switch cannot animate the whole page. Off by default: it adds a `<style>`\n * element to `<head>` for two frames on every change.\n */\n disableTransitionOnChange?: boolean\n /**\n * The contrast ratio an accent is held to against the variant's background,\n * repaired to the nearest passing colour when it falls short. Absent, presets\n * are painted verbatim — the catalogue measured them for its own themes — and\n * only a custom `#rrggbb` is held to 3:1. A host that adds themes the catalogue\n * never measured passes 3 to hold the presets to it as well; for the catalogue's\n * own themes the floor changes no preset.\n */\n accentContrastFloor?: number\n /**\n * Turns the surface axis on: `selection.surface` and `selection.reduceTransparency`\n * are resolved against the operating system's Reduce Transparency setting and the\n * host's capability, and `data-surface`, `data-reduce-transparency` and\n * `--surface-alpha` are written to `<html>` (the frost rule in `theme.css` reads\n * them). Off by default: a provider that never opts in writes none of them, adds no\n * media-query listener, and stores nothing new.\n *\n * An object also states the host's capability. `nativeTranslucency` is whether the\n * window can render the OS's own translucency; without it a `translucent`\n * preference paints the tokenized `frosted` surface instead of pretending to\n * vibrancy. A function is read inside the provider's reactive scope, for a\n * capability that is learned after mount.\n *\n * A selection that already carries a `surface` turns the axis on for itself, so a\n * host that stores the field gets the same document without the prop.\n */\n surface?: boolean | { nativeTranslucency?: boolean | (() => boolean) }\n /**\n * Where a catalogue variant's palette comes from. `inline` (the default) writes\n * every role onto `<html>`. `stylesheet` leaves a catalogue variant to the host's\n * `[data-theme]` stylesheet and writes inline only what no stylesheet can know: a\n * host's own `themes`, the accent, the pinned terminal palette, the surface alpha\n * and the fonts. Switching from a host variant back to a catalogue one removes the\n * properties the host variant wrote.\n */\n palette?: 'inline' | 'stylesheet'\n /**\n * The projection behind the `--editor-*` ramp. `syntax` (the default) is the\n * catalogue's quiet syntax roles, a comment among them deliberately below\n * body-text contrast. `floor` holds all sixteen roles to 4.5:1 on the canvas, as\n * hex, for a host that renders code as content (a diff, a file view) rather than\n * as decoration.\n *\n * Applies to catalogue variants; a host's own `themes` keep their `editor` and\n * their `tokens`. With `palette=\"stylesheet\"` it is the one palette property a\n * catalogue variant still writes inline, because `theme-variants.css` is generated\n * for `syntax`. Absent, nothing changes.\n */\n editorRoles?: EditorRolesMode\n /**\n * Bind the platform zoom chords (Cmd or Ctrl with `=`, `+`, `-`, `0`) to the three\n * text sizes instead of the browser's page zoom: stepping them together is zoom\n * inside the persisted type system. Off by default: it adds a capturing `keydown`\n * listener to `window`, and an event already handled elsewhere is left alone.\n * `zoomFonts` on the context does the same from a menu or a host's own binding.\n */\n fontZoom?: boolean\n} & ThemeTokenProjectionOptions\n\n/**\n * Where the provider's catalogue questions are answered, and whether the whole\n * catalogue is available yet.\n *\n * The eager provider's source is the full catalogue and is always loaded. The lazy\n * provider's source starts on the default pair that ships with it and swaps to the\n * full catalogue when {@link ThemeCatalogueSource.load} resolves. Both read the same\n * way in the provider: `engine()` is reactive, so everything derived from it follows\n * the swap.\n */\nexport type ThemeCatalogueSource = {\n /** The engine answering catalogue questions now. Changes once, when loading completes. */\n engine: () => ThemeEngine\n /** True when `engine()` is the full catalogue. */\n loaded: () => boolean\n /** True when loading failed; the provider then paints what it can without the rest. */\n failed: () => boolean\n /** Start loading the full catalogue (idempotent). Resolves when `loaded()` is true. */\n load: () => Promise<void>\n}\n\n/** The operating system's Reduce Transparency query, where there is a window to ask. */\nfunction reducedTransparencyMedia(): MediaQueryList | undefined {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function'\n ? window.matchMedia(REDUCED_TRANSPARENCY_QUERY)\n : undefined\n}\n\n/**\n * The provider, parameterised by where its catalogue comes from: the eager\n * `ThemeProvider` passes the whole catalogue, the lazy one a source that loads it.\n * Nothing here imports catalogue code or data, which is what lets the lazy entry keep\n * them out of a consumer's start-up chunk.\n */\n\n/** Selections are small plain records built in one key order, so this is exact. */\nfunction sameThemeSelection(a: ThemeSelection, b: ThemeSelection) {\n return a === b || JSON.stringify(a) === JSON.stringify(b)\n}\n\nexport function ThemeProviderWith(\n props: ThemeProviderProps & { catalogue: ThemeCatalogueSource }\n): JSX.Element {\n const value = createThemeContextValue(props)\n return createComponent(themeContext().Provider, {\n value,\n get children() {\n return props.children\n },\n })\n}\n\n/**\n * Everything the provider is, as a value: the context object, with its effects and\n * listeners created in the caller's reactive scope.\n */\nexport function createThemeContextValue(\n props: ThemeProviderProps & { catalogue: ThemeCatalogueSource }\n): ThemeContextValue {\n assertThemeTokenProjectionConfig(props.tokenProjection)\n const [local] = splitProps(props, [\n 'catalogue',\n 'storageKey',\n 'initial',\n 'selection',\n 'persistence',\n 'themes',\n 'transformTokens',\n 'tokenProjection',\n 'disableTransitionOnChange',\n 'accentContrastFloor',\n 'surface',\n 'palette',\n 'editorRoles',\n 'fontZoom',\n ])\n const storageKey = () => local.storageKey ?? DEFAULT_THEME_STORAGE_KEY\n const persistence = local.persistence ?? localStoragePersistence(storageKey)\n\n // Read before the first resolution and before the store is, so a persistence whose\n // answer depends on the extras (an id it only accepts if the theme exists) sees\n // them.\n const extraThemes = createMemo(() =>\n typeof local.themes === 'function' ? local.themes() : (local.themes ?? [])\n )\n const source = () => local.catalogue\n const engine = () => source().engine()\n const registry = createMemo(() => mergeRegistry(engine().builtinThemes, extraThemes()))\n\n // A patch that changes nothing (pressing the current toggle again, a font step\n // that clamps) leaves the signal alone, so the document pass and the store write\n // that follow every change do not run for it.\n const [selection, setSelectionState] = createSignal<ThemeSelection>(\n initialThemeSelection(readPersisted(persistence), local.initial),\n { equals: sameThemeSelection }\n )\n\n // The controlled half of the contract. A patch from the owner replaces the\n // matching axes; the stored preference is untouched, since the owner is the one\n // that persists. Reading `local.selection` — a prop getter, not a destructured\n // value — is what keeps this subscribed for the provider's lifetime.\n createEffect(() => {\n const incoming = local.selection\n if (incoming) setSelectionState((current) => mergeThemeSelection(current, incoming))\n })\n\n const [systemAppearance, setSystemAppearance] = createSignal<ThemeAppearance>('light')\n\n if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {\n const query = window.matchMedia('(prefers-color-scheme: dark)')\n setSystemAppearance(query.matches ? 'dark' : 'light')\n const onChange = (event: MediaQueryListEvent) =>\n setSystemAppearance(event.matches ? 'dark' : 'light')\n query.addEventListener('change', onChange)\n onCleanup(() => query.removeEventListener('change', onChange))\n }\n\n // What the stored preference resolves to. `selection()`, `variant()` and\n // `resolvedAppearance()` answer from this and never from a preview, so a picker\n // that previews a draft still reads back what is committed.\n const committed = createMemo(() => resolveThemeState(selection(), systemAppearance(), registry()))\n const resolvedAppearance = createMemo<ThemeAppearance>(() => committed().appearance)\n const variant = createMemo<ThemeVariant>(() => committed().variant)\n\n const [draft, setDraft] = createSignal<Partial<ThemeSelection> | undefined>()\n const shownSelection = createMemo(() => {\n const preview = draft()\n return preview ? mergeThemeSelection(selection(), preview) : selection()\n })\n const shown = createMemo(() =>\n draft() ? resolveThemeState(shownSelection(), systemAppearance(), registry()) : committed()\n )\n const shownAppearance = createMemo<ThemeAppearance>(() => shown().appearance)\n\n // The surface axis. Off, none of this reads the operating system: the media query\n // is subscribed only while the axis is on, so a provider that never opts in adds no\n // listener and no repaint.\n const surfaceOn = (candidate: ThemeSelection) =>\n local.surface === true || typeof local.surface === 'object' || candidate.surface !== undefined\n const nativeTranslucency = () => {\n const capability = typeof local.surface === 'object' ? local.surface.nativeTranslucency : false\n return (typeof capability === 'function' ? capability() : capability) === true\n }\n const [osReducedTransparency, setOsReducedTransparency] = createSignal(\n surfaceOn(untrack(shownSelection)) ? (reducedTransparencyMedia()?.matches ?? false) : false\n )\n const axisOn = createMemo(() => surfaceOn(shownSelection()))\n createEffect(() => {\n const query = axisOn() ? reducedTransparencyMedia() : undefined\n setOsReducedTransparency(query?.matches ?? false)\n if (!query) return\n const onChange = (event: MediaQueryListEvent) => setOsReducedTransparency(event.matches)\n query.addEventListener('change', onChange)\n onCleanup(() => query.removeEventListener('change', onChange))\n })\n const surfaceStateOf = (candidate: ThemeSelection) =>\n resolveSurfaceState(candidate.surface, {\n osReducedTransparency: osReducedTransparency(),\n userReducedTransparency: candidate.reduceTransparency === true,\n nativeTranslucency: nativeTranslucency(),\n })\n const committedSurface = createMemo(() =>\n surfaceOn(selection()) ? surfaceStateOf(selection()) : undefined\n )\n\n // A selection that names a catalogue theme beyond the shipped default pair cannot be\n // painted or previewed until the whole catalogue has loaded. Once a load has failed\n // the provider paints what the shipped data can.\n const waitingFor = (candidate: ThemeSelection, appearance: ThemeAppearance) =>\n !source().loaded() && !source().failed() && needsCatalogue(candidate, appearance)\n createEffect(() => {\n if (\n needsCatalogue(selection(), committed().appearance) ||\n needsCatalogue(shownSelection(), shown().appearance)\n )\n void source().load()\n })\n\n let written: ReadonlySet<string> | undefined\n let restoreTransitions: (() => void) | undefined\n createEffect(() => {\n if (typeof document === 'undefined') return\n const current = engine()\n const display = shown()\n // Until the catalogue arrives the document keeps what is already on it — the\n // stylesheet's theme, set before first paint by `themeScript` — instead of\n // flashing the default for a theme that is only not loaded yet.\n if (waitingFor(shownSelection(), display.appearance)) return\n const state = {\n selection: shownSelection(),\n appearance: display.appearance,\n variant: display.variant,\n terminalVariant: resolveTerminalVariant(shownSelection().terminalThemeId, registry()),\n codeVariant: resolveCodeVariant(shownSelection().codeThemeId, registry()),\n surface: axisOn() ? surfaceStateOf(shownSelection()) : undefined,\n }\n const projectionOptions = local.tokenProjection\n ? { tokenProjection: local.tokenProjection }\n : {}\n const options = {\n transformTokens: local.transformTokens,\n ...projectionOptions,\n accentContrastFloor: local.accentContrastFloor,\n palette: local.palette,\n editorRoles: local.editorRoles,\n }\n const apply = () => {\n written = applyThemeToRoot(current, document.documentElement, state, options, written)\n }\n if (local.disableTransitionOnChange) {\n restoreTransitions?.()\n restoreTransitions = applyWithoutTransitions(document, apply)\n } else {\n apply()\n }\n })\n onCleanup(() => restoreTransitions?.())\n\n // A pair beyond the defaults offers its accents once the catalogue is here; reading\n // them is not a reason to load it.\n const lightThemeId = createMemo(() => selection().lightThemeId)\n const darkThemeId = createMemo(() => selection().darkThemeId)\n const themeAccents = createMemo(() => {\n const pair = { lightThemeId: lightThemeId(), darkThemeId: darkThemeId() }\n return !source().loaded() && pairNeedsData(pair)\n ? []\n : engine().themeAccentsFor(pair.lightThemeId, pair.darkThemeId)\n })\n\n const zoomFonts = (intent: FontZoomIntent) =>\n value.setSelection({ fonts: zoomedFontSettings(selection(), intent) })\n\n // The platform zoom chords drive the three text sizes, captured like the other\n // global chords; an event something else already handled never double-steps.\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.defaultPrevented) return\n const intent = fontZoomShortcut(event)\n if (!intent) return\n event.preventDefault()\n zoomFonts(intent)\n }\n createEffect(() => {\n if (!local.fontZoom || typeof window === 'undefined') return\n window.addEventListener('keydown', onKeyDown, { capture: true })\n onCleanup(() => window.removeEventListener('keydown', onKeyDown, { capture: true }))\n })\n\n const value: ThemeContextValue = {\n selection,\n resolvedAppearance,\n shownAppearance,\n variant,\n get themes() {\n return engine().builtinThemes\n },\n themeAccents,\n allThemes: registry,\n preview(next) {\n setDraft(next ? { ...next } : undefined)\n },\n previewing: () => draft() !== undefined,\n accentRolesFor(accent, variantId) {\n // Before the catalogue arrives the light engine answers provisionally and asks\n // for it; reading `engine()` re-runs a reactive caller on arrival.\n return accentRolesForState(engine(), accent, variantId, {\n selection: selection(),\n variant: variant(),\n registry: registry(),\n accentContrastFloor: local.accentContrastFloor,\n })\n },\n catalogueReady: () => source().loaded(),\n loadCatalogue: () => source().load(),\n effectiveSurface: () => committedSurface()?.surface ?? 'opaque',\n reduceTransparencyActive: () => committedSurface()?.reduceTransparencyActive ?? false,\n zoomFonts,\n setSelection(patch) {\n const current = selection()\n const next = mergeThemeSelection(current, patch)\n setDraft(undefined)\n if (sameThemeSelection(current, next)) return\n setSelectionState(next)\n writePersisted(persistence, next)\n },\n }\n\n return value\n}\n"],"mappings":";;;;;;;;;;;;AA+LA,SAAS,2BAAuD;CAC9D,OAAO,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,aACjE,OAAO,WAAW,0BAA0B,IAC5C,KAAA;AACN;;;;;;;;AAUA,SAAS,mBAAmB,GAAmB,GAAmB;CAChE,OAAO,MAAM,KAAK,KAAK,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC;AAC1D;AAEA,SAAgB,kBACd,OACa;CACb,MAAM,QAAQ,wBAAwB,KAAK;CAC3C,OAAO,gBAAgB,aAAa,CAAC,CAAC,UAAU;EAC9C;EACA,IAAI,WAAW;GACb,OAAO,MAAM;EACf;CACF,CAAC;AACH;;;;;AAMA,SAAgB,wBACd,OACmB;CACnB,iCAAiC,MAAM,eAAe;CACtD,MAAM,CAAC,SAAS,WAAW,OAAO;EAChC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,mBAAmB,MAAM,cAAA;CAC/B,MAAM,cAAc,MAAM,eAAe,wBAAwB,UAAU;CAK3E,MAAM,cAAc,iBAClB,OAAO,MAAM,WAAW,aAAa,MAAM,OAAO,IAAK,MAAM,UAAU,CAAC,CAC1E;CACA,MAAM,eAAe,MAAM;CAC3B,MAAM,eAAe,OAAO,CAAC,CAAC,OAAO;CACrC,MAAM,WAAW,iBAAiB,cAAc,OAAO,CAAC,CAAC,eAAe,YAAY,CAAC,CAAC;CAKtF,MAAM,CAAC,WAAW,qBAAqB,aACrC,sBAAsB,cAAc,WAAW,GAAG,MAAM,OAAO,GAC/D,EAAE,QAAQ,mBAAmB,CAC/B;CAMA,mBAAmB;EACjB,MAAM,WAAW,MAAM;EACvB,IAAI,UAAU,mBAAmB,YAA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CAAC;EAClB;EACA;EACA,WAAW;EACX,QAAQ,MAAM;GACZ,SAAS,OAAO,EAAE,GAAG,KAAK,IAAI,KAAA,CAAS;EACzC;EACA,kBAAkB,MAAM,MAAM,KAAA;EAC9B,eAAe,QAAQ,WAAW;GAGhC,OAAO,oBAAoB,OAAO,GAAG,QAAQ,WAAW;IACtD,WAAW,UAAU;IACrB,SAAS,QAAQ;IACjB,UAAU,SAAS;IACnB,qBAAqB,MAAM;GAC7B,CAAC;EACH;EACA,sBAAsB,OAAO,CAAC,CAAC,OAAO;EACtC,qBAAqB,OAAO,CAAC,CAAC,KAAK;EACnC,wBAAwB,iBAAiB,CAAC,EAAE,WAAW;EACvD,gCAAgC,iBAAiB,CAAC,EAAE,4BAA4B;EAChF;EACA,aAAa,OAAO;GAClB,MAAM,UAAU,UAAU;GAC1B,MAAM,OAAO,oBAAoB,SAAS,KAAK;GAC/C,SAAS,KAAA,CAAS;GAClB,IAAI,mBAAmB,SAAS,IAAI,GAAG;GACvC,kBAAkB,IAAI;GACtB,eAAe,aAAa,IAAI;EAClC;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"theme-provider-value.js","names":[],"sources":["../../../src/components/theme/theme-provider-value.ts"],"sourcesContent":["import type { JSX } from 'solid-js'\nimport {\n createComponent,\n createEffect,\n createMemo,\n createSignal,\n onCleanup,\n splitProps,\n untrack,\n} from 'solid-js'\nimport type { ThemeTokenProjectionOptions } from './token-projection'\nimport { assertThemeTokenProjectionConfig } from './token-projection-options'\nimport { fontZoomShortcut, type FontZoomIntent } from '#lib/font-zoom'\nimport { DEFAULT_THEME_STORAGE_KEY } from '#lib/theme-defaults'\nimport { REDUCED_TRANSPARENCY_QUERY, resolveSurfaceState } from '#lib/theme-surface'\nimport { needsCatalogue, pairNeedsData, type ThemeEngine } from '#lib/theme-engine'\nimport type { EditorRolesMode, ThemeAppearance, ThemeVariant } from '#lib/theme-types'\nimport { themeContext } from './theme-context'\nimport { applyThemeToRoot, applyWithoutTransitions } from './theme-document'\nimport {\n localStoragePersistence,\n readPersisted,\n writePersisted,\n type ThemePersistence,\n} from './theme-persistence'\nimport {\n accentRolesForState,\n initialThemeSelection,\n mergeRegistry,\n mergeThemeSelection,\n resolveCodeVariant,\n resolveTerminalVariant,\n resolveThemeState,\n zoomedFontSettings,\n type ThemeContextValue,\n type ThemeSelection,\n} from './theme-state'\n\n/**\n * The props both `ThemeProvider`s take.\n *\n * ## What a preference is\n *\n * Four independent choices (`ThemeSelection`), and keeping them independent is the\n * point: appearance, a theme per appearance, an accent and fonts. They compose: a\n * user who wants Nord with a violet accent and the system font should not need\n * someone to author that combination.\n *\n * ## Where the rules live\n *\n * The provider is wiring. What a selection merges to and resolves to is\n * `theme-state.ts`; what lands on `<html>` is `theme-document.ts`; where the\n * preference is kept is `theme-persistence.ts`.\n *\n * ## Why the variants are applied as inline properties\n *\n * The catalogue is data, and a theme is applied by writing its roles onto\n * `<html>` as custom properties. That is what makes an imported palette work\n * without a hand-written `[data-theme]` block per theme, and it is why a settings\n * UI can show a preview by reading the same object rather than by loading a\n * stylesheet. `theme.css` keeps the default theme's values so the first paint is\n * correct before any script runs.\n */\nexport type ThemeProviderProps = {\n children?: JSX.Element\n /** Where the preference is persisted. Distinct per application. */\n storageKey?: string\n /** Start from this instead of the stored preference. */\n initial?: Partial<ThemeSelection>\n /**\n * The selection, owned by the caller.\n *\n * For a consumer that keeps the state itself — a settings store, or a workshop\n * whose selection lives in Storybook globals — rather than handing it to this\n * provider's signal. Each change lands here and the document follows; nothing is\n * written to the store, because the caller is the one who persists. A picker\n * below the provider still works, and its change is the caller's to read back.\n *\n * Absent, the provider is the whole owner: it reads `storageKey` on mount,\n * seeds from `initial`, and persists every `setSelection`.\n */\n selection?: Partial<ThemeSelection>\n /**\n * Where the preference is kept, in place of `localStorage` under `storageKey`.\n *\n * Read once when the provider is created, so changing the prop later does not\n * move the store. `storageKey` is ignored when this is given.\n */\n persistence?: ThemePersistence\n /**\n * Variants the host adds to the built-in catalogue — themes a user imported.\n *\n * A function is read inside the provider's reactive scope, so one that reads a\n * signal keeps the picker and the document current when the set changes. A\n * stored id that names no variant, built in or added, paints the default of its\n * appearance and stays in the selection untouched.\n */\n themes?: readonly ThemeVariant[] | (() => readonly ThemeVariant[])\n /**\n * Rewrites the custom properties of each pass before they are written to\n * `<html>`: the variant's roles with the accent over them. `tokensAsHex` from\n * `lib/themes` is the one the system ships.\n */\n transformTokens?: (tokens: Record<string, string>) => Record<string, string>\n /**\n * Switch CSS transitions off for the frame that carries a change, so a theme\n * switch cannot animate the whole page. Off by default: it adds a `<style>`\n * element to `<head>` for two frames on every change.\n */\n disableTransitionOnChange?: boolean\n /**\n * The contrast ratio an accent is held to against the variant's background,\n * repaired to the nearest passing colour when it falls short. Absent, presets\n * are painted verbatim — the catalogue measured them for its own themes — and\n * only a custom `#rrggbb` is held to 3:1. A host that adds themes the catalogue\n * never measured passes 3 to hold the presets to it as well; for the catalogue's\n * own themes the floor changes no preset.\n */\n accentContrastFloor?: number\n /**\n * Turns the surface axis on: `selection.surface` and `selection.reduceTransparency`\n * are resolved against the operating system's Reduce Transparency setting and the\n * host's capability, and `data-surface`, `data-reduce-transparency` and\n * `--surface-alpha` are written to `<html>` (the frost rule in `theme.css` reads\n * them). Off by default: a provider that never opts in writes none of them, adds no\n * media-query listener, and stores nothing new.\n *\n * An object also states the host's capability. `nativeTranslucency` is whether the\n * window can render the OS's own translucency; without it a `translucent`\n * preference paints the tokenized `frosted` surface instead of pretending to\n * vibrancy. A function is read inside the provider's reactive scope, for a\n * capability that is learned after mount.\n *\n * A selection that already carries a `surface` turns the axis on for itself, so a\n * host that stores the field gets the same document without the prop.\n */\n surface?: boolean | { nativeTranslucency?: boolean | (() => boolean) }\n /**\n * Where a catalogue variant's palette comes from. `inline` (the default) writes\n * every role onto `<html>`. `stylesheet` leaves a catalogue variant to the host's\n * `[data-theme]` stylesheet and writes inline only what no stylesheet can know: a\n * host's own `themes`, the accent, the pinned terminal palette, the surface alpha\n * and the fonts. Switching from a host variant back to a catalogue one removes the\n * properties the host variant wrote.\n */\n palette?: 'inline' | 'stylesheet'\n /**\n * The projection behind the `--editor-*` ramp. `syntax` (the default) is the\n * catalogue's quiet syntax roles, a comment among them deliberately below\n * body-text contrast. `floor` holds every role to 4.5:1 on the canvas, as\n * hex, for a host that renders code as content (a diff, a file view) rather than\n * as decoration.\n *\n * Applies to catalogue variants; a host's own `themes` keep their `editor` and\n * their `tokens`. With `palette=\"stylesheet\"` it is the one palette property a\n * catalogue variant still writes inline, because `theme-variants.css` is generated\n * for `syntax`. Absent, nothing changes.\n */\n editorRoles?: EditorRolesMode\n /**\n * Bind the platform zoom chords (Cmd or Ctrl with `=`, `+`, `-`, `0`) to the three\n * text sizes instead of the browser's page zoom: stepping them together is zoom\n * inside the persisted type system. Off by default: it adds a capturing `keydown`\n * listener to `window`, and an event already handled elsewhere is left alone.\n * `zoomFonts` on the context does the same from a menu or a host's own binding.\n */\n fontZoom?: boolean\n} & ThemeTokenProjectionOptions\n\n/**\n * Where the provider's catalogue questions are answered, and whether the whole\n * catalogue is available yet.\n *\n * The eager provider's source is the full catalogue and is always loaded. The lazy\n * provider's source starts on the default pair that ships with it and swaps to the\n * full catalogue when {@link ThemeCatalogueSource.load} resolves. Both read the same\n * way in the provider: `engine()` is reactive, so everything derived from it follows\n * the swap.\n */\nexport type ThemeCatalogueSource = {\n /** The engine answering catalogue questions now. Changes once, when loading completes. */\n engine: () => ThemeEngine\n /** True when `engine()` is the full catalogue. */\n loaded: () => boolean\n /** True when loading failed; the provider then paints what it can without the rest. */\n failed: () => boolean\n /** Start loading the full catalogue (idempotent). Resolves when `loaded()` is true. */\n load: () => Promise<void>\n}\n\n/** The operating system's Reduce Transparency query, where there is a window to ask. */\nfunction reducedTransparencyMedia(): MediaQueryList | undefined {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function'\n ? window.matchMedia(REDUCED_TRANSPARENCY_QUERY)\n : undefined\n}\n\n/**\n * The provider, parameterised by where its catalogue comes from: the eager\n * `ThemeProvider` passes the whole catalogue, the lazy one a source that loads it.\n * Nothing here imports catalogue code or data, which is what lets the lazy entry keep\n * them out of a consumer's start-up chunk.\n */\n\n/** Selections are small plain records built in one key order, so this is exact. */\nfunction sameThemeSelection(a: ThemeSelection, b: ThemeSelection) {\n return a === b || JSON.stringify(a) === JSON.stringify(b)\n}\n\nexport function ThemeProviderWith(\n props: ThemeProviderProps & { catalogue: ThemeCatalogueSource }\n): JSX.Element {\n const value = createThemeContextValue(props)\n return createComponent(themeContext().Provider, {\n value,\n get children() {\n return props.children\n },\n })\n}\n\n/**\n * Everything the provider is, as a value: the context object, with its effects and\n * listeners created in the caller's reactive scope.\n */\nexport function createThemeContextValue(\n props: ThemeProviderProps & { catalogue: ThemeCatalogueSource }\n): ThemeContextValue {\n assertThemeTokenProjectionConfig(props.tokenProjection)\n const [local] = splitProps(props, [\n 'catalogue',\n 'storageKey',\n 'initial',\n 'selection',\n 'persistence',\n 'themes',\n 'transformTokens',\n 'tokenProjection',\n 'disableTransitionOnChange',\n 'accentContrastFloor',\n 'surface',\n 'palette',\n 'editorRoles',\n 'fontZoom',\n ])\n const storageKey = () => local.storageKey ?? DEFAULT_THEME_STORAGE_KEY\n const persistence = local.persistence ?? localStoragePersistence(storageKey)\n\n // Read before the first resolution and before the store is, so a persistence whose\n // answer depends on the extras (an id it only accepts if the theme exists) sees\n // them.\n const extraThemes = createMemo(() =>\n typeof local.themes === 'function' ? local.themes() : (local.themes ?? [])\n )\n const source = () => local.catalogue\n const engine = () => source().engine()\n const registry = createMemo(() => mergeRegistry(engine().builtinThemes, extraThemes()))\n\n // A patch that changes nothing (pressing the current toggle again, a font step\n // that clamps) leaves the signal alone, so the document pass and the store write\n // that follow every change do not run for it.\n const [selection, setSelectionState] = createSignal<ThemeSelection>(\n initialThemeSelection(readPersisted(persistence), local.initial),\n { equals: sameThemeSelection }\n )\n\n // The controlled half of the contract. A patch from the owner replaces the\n // matching axes; the stored preference is untouched, since the owner is the one\n // that persists. Reading `local.selection` — a prop getter, not a destructured\n // value — is what keeps this subscribed for the provider's lifetime.\n createEffect(() => {\n const incoming = local.selection\n if (incoming) setSelectionState((current) => mergeThemeSelection(current, incoming))\n })\n\n const [systemAppearance, setSystemAppearance] = createSignal<ThemeAppearance>('light')\n\n if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {\n const query = window.matchMedia('(prefers-color-scheme: dark)')\n setSystemAppearance(query.matches ? 'dark' : 'light')\n const onChange = (event: MediaQueryListEvent) =>\n setSystemAppearance(event.matches ? 'dark' : 'light')\n query.addEventListener('change', onChange)\n onCleanup(() => query.removeEventListener('change', onChange))\n }\n\n // What the stored preference resolves to. `selection()`, `variant()` and\n // `resolvedAppearance()` answer from this and never from a preview, so a picker\n // that previews a draft still reads back what is committed.\n const committed = createMemo(() => resolveThemeState(selection(), systemAppearance(), registry()))\n const resolvedAppearance = createMemo<ThemeAppearance>(() => committed().appearance)\n const variant = createMemo<ThemeVariant>(() => committed().variant)\n\n const [draft, setDraft] = createSignal<Partial<ThemeSelection> | undefined>()\n const shownSelection = createMemo(() => {\n const preview = draft()\n return preview ? mergeThemeSelection(selection(), preview) : selection()\n })\n const shown = createMemo(() =>\n draft() ? resolveThemeState(shownSelection(), systemAppearance(), registry()) : committed()\n )\n const shownAppearance = createMemo<ThemeAppearance>(() => shown().appearance)\n\n // The surface axis. Off, none of this reads the operating system: the media query\n // is subscribed only while the axis is on, so a provider that never opts in adds no\n // listener and no repaint.\n const surfaceOn = (candidate: ThemeSelection) =>\n local.surface === true || typeof local.surface === 'object' || candidate.surface !== undefined\n const nativeTranslucency = () => {\n const capability = typeof local.surface === 'object' ? local.surface.nativeTranslucency : false\n return (typeof capability === 'function' ? capability() : capability) === true\n }\n const [osReducedTransparency, setOsReducedTransparency] = createSignal(\n surfaceOn(untrack(shownSelection)) ? (reducedTransparencyMedia()?.matches ?? false) : false\n )\n const axisOn = createMemo(() => surfaceOn(shownSelection()))\n createEffect(() => {\n const query = axisOn() ? reducedTransparencyMedia() : undefined\n setOsReducedTransparency(query?.matches ?? false)\n if (!query) return\n const onChange = (event: MediaQueryListEvent) => setOsReducedTransparency(event.matches)\n query.addEventListener('change', onChange)\n onCleanup(() => query.removeEventListener('change', onChange))\n })\n const surfaceStateOf = (candidate: ThemeSelection) =>\n resolveSurfaceState(candidate.surface, {\n osReducedTransparency: osReducedTransparency(),\n userReducedTransparency: candidate.reduceTransparency === true,\n nativeTranslucency: nativeTranslucency(),\n })\n const committedSurface = createMemo(() =>\n surfaceOn(selection()) ? surfaceStateOf(selection()) : undefined\n )\n\n // A selection that names a catalogue theme beyond the shipped default pair cannot be\n // painted or previewed until the whole catalogue has loaded. Once a load has failed\n // the provider paints what the shipped data can.\n const waitingFor = (candidate: ThemeSelection, appearance: ThemeAppearance) =>\n !source().loaded() && !source().failed() && needsCatalogue(candidate, appearance)\n createEffect(() => {\n if (\n needsCatalogue(selection(), committed().appearance) ||\n needsCatalogue(shownSelection(), shown().appearance)\n )\n void source().load()\n })\n\n let written: ReadonlySet<string> | undefined\n let restoreTransitions: (() => void) | undefined\n createEffect(() => {\n if (typeof document === 'undefined') return\n const current = engine()\n const display = shown()\n // Until the catalogue arrives the document keeps what is already on it — the\n // stylesheet's theme, set before first paint by `themeScript` — instead of\n // flashing the default for a theme that is only not loaded yet.\n if (waitingFor(shownSelection(), display.appearance)) return\n const state = {\n selection: shownSelection(),\n appearance: display.appearance,\n variant: display.variant,\n terminalVariant: resolveTerminalVariant(shownSelection().terminalThemeId, registry()),\n codeVariant: resolveCodeVariant(shownSelection().codeThemeId, registry()),\n surface: axisOn() ? surfaceStateOf(shownSelection()) : undefined,\n }\n const projectionOptions = local.tokenProjection\n ? { tokenProjection: local.tokenProjection }\n : {}\n const options = {\n transformTokens: local.transformTokens,\n ...projectionOptions,\n accentContrastFloor: local.accentContrastFloor,\n palette: local.palette,\n editorRoles: local.editorRoles,\n }\n const apply = () => {\n written = applyThemeToRoot(current, document.documentElement, state, options, written)\n }\n if (local.disableTransitionOnChange) {\n restoreTransitions?.()\n restoreTransitions = applyWithoutTransitions(document, apply)\n } else {\n apply()\n }\n })\n onCleanup(() => restoreTransitions?.())\n\n // A pair beyond the defaults offers its accents once the catalogue is here; reading\n // them is not a reason to load it.\n const lightThemeId = createMemo(() => selection().lightThemeId)\n const darkThemeId = createMemo(() => selection().darkThemeId)\n const themeAccents = createMemo(() => {\n const pair = { lightThemeId: lightThemeId(), darkThemeId: darkThemeId() }\n return !source().loaded() && pairNeedsData(pair)\n ? []\n : engine().themeAccentsFor(pair.lightThemeId, pair.darkThemeId)\n })\n\n const zoomFonts = (intent: FontZoomIntent) =>\n value.setSelection({ fonts: zoomedFontSettings(selection(), intent) })\n\n // The platform zoom chords drive the three text sizes, captured like the other\n // global chords; an event something else already handled never double-steps.\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.defaultPrevented) return\n const intent = fontZoomShortcut(event)\n if (!intent) return\n event.preventDefault()\n zoomFonts(intent)\n }\n createEffect(() => {\n if (!local.fontZoom || typeof window === 'undefined') return\n window.addEventListener('keydown', onKeyDown, { capture: true })\n onCleanup(() => window.removeEventListener('keydown', onKeyDown, { capture: true }))\n })\n\n const value: ThemeContextValue = {\n selection,\n resolvedAppearance,\n shownAppearance,\n variant,\n get themes() {\n return engine().builtinThemes\n },\n themeAccents,\n allThemes: registry,\n preview(next) {\n setDraft(next ? { ...next } : undefined)\n },\n previewing: () => draft() !== undefined,\n accentRolesFor(accent, variantId) {\n // Before the catalogue arrives the light engine answers provisionally and asks\n // for it; reading `engine()` re-runs a reactive caller on arrival.\n return accentRolesForState(engine(), accent, variantId, {\n selection: selection(),\n variant: variant(),\n registry: registry(),\n accentContrastFloor: local.accentContrastFloor,\n })\n },\n catalogueReady: () => source().loaded(),\n loadCatalogue: () => source().load(),\n effectiveSurface: () => committedSurface()?.surface ?? 'opaque',\n reduceTransparencyActive: () => committedSurface()?.reduceTransparencyActive ?? false,\n zoomFonts,\n setSelection(patch) {\n const current = selection()\n const next = mergeThemeSelection(current, patch)\n setDraft(undefined)\n if (sameThemeSelection(current, next)) return\n setSelectionState(next)\n writePersisted(persistence, next)\n },\n }\n\n return value\n}\n"],"mappings":";;;;;;;;;;;;AA+LA,SAAS,2BAAuD;CAC9D,OAAO,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,aACjE,OAAO,WAAW,0BAA0B,IAC5C,KAAA;AACN;;;;;;;;AAUA,SAAS,mBAAmB,GAAmB,GAAmB;CAChE,OAAO,MAAM,KAAK,KAAK,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC;AAC1D;AAEA,SAAgB,kBACd,OACa;CACb,MAAM,QAAQ,wBAAwB,KAAK;CAC3C,OAAO,gBAAgB,aAAa,CAAC,CAAC,UAAU;EAC9C;EACA,IAAI,WAAW;GACb,OAAO,MAAM;EACf;CACF,CAAC;AACH;;;;;AAMA,SAAgB,wBACd,OACmB;CACnB,iCAAiC,MAAM,eAAe;CACtD,MAAM,CAAC,SAAS,WAAW,OAAO;EAChC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,mBAAmB,MAAM,cAAA;CAC/B,MAAM,cAAc,MAAM,eAAe,wBAAwB,UAAU;CAK3E,MAAM,cAAc,iBAClB,OAAO,MAAM,WAAW,aAAa,MAAM,OAAO,IAAK,MAAM,UAAU,CAAC,CAC1E;CACA,MAAM,eAAe,MAAM;CAC3B,MAAM,eAAe,OAAO,CAAC,CAAC,OAAO;CACrC,MAAM,WAAW,iBAAiB,cAAc,OAAO,CAAC,CAAC,eAAe,YAAY,CAAC,CAAC;CAKtF,MAAM,CAAC,WAAW,qBAAqB,aACrC,sBAAsB,cAAc,WAAW,GAAG,MAAM,OAAO,GAC/D,EAAE,QAAQ,mBAAmB,CAC/B;CAMA,mBAAmB;EACjB,MAAM,WAAW,MAAM;EACvB,IAAI,UAAU,mBAAmB,YAAY,oBAAoB,SAAS,QAAQ,CAAC;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AAM,CAAC,CAAC,SAAS,cAAc,GAAG,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,kCAsDhF"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/button/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC9E,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAwC,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AAGvF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc;;;;8EA6D1B,CAAA;AAED,KAAK,kBAAkB,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,CAAA;AAE7D,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,cAAc,GAAG,QAAQ,IAAI,gBAAgB,CAC7E,CAAC,EACD,kBAAkB,GAAG;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CACF,CAAA;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,cAAc,GAAG,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,kCAwDhF"}
@@ -1,7 +1,7 @@
1
1
  import { controlInteractive, controlSize, cva } from "../../../lib/variants.js";
2
2
  import { cn } from "../../../lib/utils.js";
3
- import { createComponent, isServer, mergeProps, spread } from "solid-js/web";
4
- import { Show, mergeProps as mergeProps$1, splitProps } from "solid-js";
3
+ import { createComponent, isServer, memo, mergeProps, spread } from "solid-js/web";
4
+ import { Show, mergeProps as mergeProps$1, sharedConfig, splitProps } from "solid-js";
5
5
  import { Polymorphic } from "@kobalte/core/polymorphic";
6
6
  // src/components/ui/button/button.tsx
7
7
  /**
@@ -95,7 +95,7 @@ function Button(props) {
95
95
  };
96
96
  return createComponent(Show, {
97
97
  get when() {
98
- return !isServer && (local.as === void 0 || local.as === "button");
98
+ return memo(() => !!(!isServer && !sharedConfig.context))() && (local.as === void 0 || local.as === "button");
99
99
  },
100
100
  get fallback() {
101
101
  return createComponent(Polymorphic, mergeProps({
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","names":["Polymorphic","mergeProps","Show","splitProps","isServer","spread","cva","controlInteractive","controlSize","cn","buttonVariants","variants","variant","default","secondary","destructive","outline","ghost","toolbar","subtle","success","link","size","xs","sm","md","lg","xl","touchTarget","comfortable","defaultVariants","class","Button","props","local","rest","as","className","native","element","document","createElement","type","_$createComponent","when","undefined","fallback","_$mergeProps","children"],"sources":["../../../../src/components/ui/button/button.tsx"],"sourcesContent":["import { Polymorphic, type PolymorphicProps } from '@kobalte/core/polymorphic'\nimport { type ComponentProps, mergeProps, Show, splitProps, type ValidComponent } from 'solid-js'\nimport { isServer, spread } from 'solid-js/web'\nimport { cva, controlInteractive, controlSize, type VariantProps } from '#lib/variants'\nimport { cn } from '#lib/utils'\n\n/**\n * Button.\n *\n * One appearance ladder shared by every pressable thing in the system: a\n * button, a toolbar control, a dialog action, and a menu row all draw from the\n * same tokens, so a row of them cannot drift apart.\n *\n * The variants answer \"what is this for\", never \"what colour is it\". A caller\n * that wants a red button writes `variant=\"destructive\"`; the red lives here.\n * That is also what lets the design-system linter tell a caller which variant\n * to use instead of only which class was wrong.\n *\n * Polymorphic: pass `as=\"a\"` (or any component) and the button becomes it\n * while keeping the same styling contract. This replaces the React-era\n * `asChild` primitive, which has no Solid equivalent that preserves props.\n */\nexport const buttonVariants = cva(\n `${controlInteractive} inline-flex shrink-0 items-center justify-center rounded-md font-medium whitespace-nowrap select-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,\n {\n variants: {\n variant: {\n /** The one primary action in a view. */\n default: 'bg-primary text-primary-foreground hover:bg-primary-hover',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-surface-hover',\n /** For the action that destroys something. Never the default. */\n destructive:\n 'bg-destructive-action text-destructive-action-foreground hover:bg-destructive-action/90 focus-visible:ring-destructive-subtle',\n /** A bordered button for a surface that already has a fill. */\n outline:\n 'border border-border bg-transparent text-foreground hover:bg-surface-hover hover:border-input',\n /** No chrome until hover. The default for toolbar and row actions. */\n ghost: 'text-foreground hover:bg-surface-hover',\n /**\n * A ghost that opens something: a sheet, menu or popover trigger in a\n * toolbar. While its surface is open it holds the accent's own tint,\n * the same treatment that drives the side rail's active destination,\n * so the open control never reads identical to its closed neighbours\n * and the app's pressed chrome reads as one accent chroma. The\n * compound hover keeps the tint when an open control is pointed at.\n */\n toolbar:\n 'text-foreground hover:bg-surface-hover data-[expanded]:bg-primary-subtle data-[expanded]:text-primary data-[expanded]:hover:bg-primary-subtle',\n /** A tinted primary, for a secondary action inside a primary flow. */\n subtle: 'bg-primary-subtle text-primary hover:bg-primary-subtle/80',\n success: 'bg-success text-success-foreground hover:bg-success/90',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n '2xs': `${controlSize['2xs']} [&_svg]:size-3`,\n xs: `${controlSize.xs} [&_svg]:size-3.5`,\n sm: `${controlSize.sm} [&_svg]:size-3.5`,\n md: `${controlSize.md} [&_svg]:size-4`,\n lg: `${controlSize.lg} [&_svg]:size-4`,\n xl: `${controlSize.xl} [&_svg]:size-5`,\n '2xl': `${controlSize['2xl']} [&_svg]:size-6`,\n /* Square, for an icon with no label. The accessible name then has to\n come from `aria-label` or a visually hidden label — an icon-only\n button with neither is the accessibility finding the Storybook lane\n catches on every story. */\n 'icon-2xs': 'size-control-2xs p-0 [&_svg]:size-3',\n 'icon-xs': 'size-control-xs p-0 [&_svg]:size-3.5',\n 'icon-sm': 'size-control-sm p-0 [&_svg]:size-3.5',\n 'icon-md': 'size-control-md p-0 [&_svg]:size-4',\n 'icon-lg': 'size-control-lg p-0 [&_svg]:size-4',\n 'icon-xl': 'size-control-xl p-0 [&_svg]:size-5',\n 'icon-2xl': 'size-control-2xl p-0 [&_svg]:size-6',\n },\n /** Opt in to a stable touch target on devices with any coarse pointer. */\n touchTarget: {\n comfortable: 'touch-target-comfortable',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n },\n }\n)\n\ntype ButtonVariantProps = VariantProps<typeof buttonVariants>\n\nexport type ButtonProps<T extends ValidComponent = 'button'> = PolymorphicProps<\n T,\n ButtonVariantProps & {\n class?: string\n }\n>\n\nexport function Button<T extends ValidComponent = 'button'>(props: ButtonProps<T>) {\n const [local, rest] = splitProps(props as ButtonProps & { as?: ValidComponent }, [\n 'as',\n 'variant',\n 'size',\n 'touchTarget',\n 'class',\n ])\n const className = () =>\n cn(\n buttonVariants({\n variant: local.variant,\n size: local.size,\n touchTarget: local.touchTarget,\n }),\n local.class\n )\n\n // A native button, the common case, is written directly: Polymorphic goes\n // through Dynamic, two prop proxies and a memo per button. It is built with\n // createElement and spread, which is what the compiled JSX would do, so the\n // module holds no template: `buttonVariants` stays importable in plain Node\n // (a server renderer reads the class contract from this entry). A server\n // render has no document, so it takes the Polymorphic path.\n const native = () => {\n const element = document.createElement('button')\n spread(\n element,\n mergeProps({ type: 'button', 'data-slot': 'button' }, rest as ComponentProps<'button'>, {\n get class() {\n return className()\n },\n }),\n false,\n false\n )\n return element\n }\n return (\n <Show\n when={!isServer && (local.as === undefined || local.as === 'button')}\n fallback={\n <Polymorphic\n as={local.as ?? 'button'}\n type=\"button\"\n data-slot=\"button\"\n class={className()}\n {...(rest as ComponentProps<'button'>)}\n />\n }\n >\n {native()}\n </Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAaU,iBAAiBJ,IAC5B,GAAGC,mBAAkB,sJACrB;CACEI,UAAU;EACRC,SAAS;;GAEPC,SAAS;GACTC,WAAW;;GAEXC,aACE;;GAEFC,SACE;;GAEFC,OAAO;;;;;;;;;GASPC,SACE;;GAEFC,QAAQ;GACRC,SAAS;GACTC,MAAM;EACR;EACAC,MAAM;GACJ,OAAO,GAAGd,YAAY,OAAM;GAC5Be,IAAI,GAAGf,YAAYe,GAAE;GACrBC,IAAI,GAAGhB,YAAYgB,GAAE;GACrBC,IAAI,GAAGjB,YAAYiB,GAAE;GACrBC,IAAI,GAAGlB,YAAYkB,GAAE;GACrBC,IAAI,GAAGnB,YAAYmB,GAAE;GACrB,OAAO,GAAGnB,YAAY,OAAM;GAK5B,YAAY;GACZ,WAAW;GACX,WAAW;GACX,WAAW;GACX,WAAW;GACX,WAAW;GACX,YAAY;EACd;;EAEAoB,aAAa,EACXC,aAAa,2BACf;CACF;CACAC,iBAAiB;EACflB,SAAS;EACTU,MAAM;CACR;AACF,CACF;AAWA,SAAgBU,OAA4CC,OAAuB;CACjF,MAAM,CAACC,OAAOC,QAAQhC,WAAW8B,OAAgD;EAC/E;EACA;EACA;EACA;EACA;CAAO,CACR;CACD,MAAMI,kBACJ5B,GACEC,eAAe;EACbE,SAASsB,MAAMtB;EACfU,MAAMY,MAAMZ;EACZM,aAAaM,MAAMN;CACrB,CAAC,GACDM,MAAMH,KACR;CAQF,MAAMO,eAAe;EACnB,MAAMC,UAAUC,SAASC,cAAc,QAAQ;EAC/CpC,OACEkC,SACAtC,aAAW;GAAEyC,MAAM;GAAU,aAAa;EAAS,GAAGP,MAAkC,EACtF,IAAIJ,QAAQ;GACV,OAAOM,UAAU;EACnB,EACF,CAAC,GACD,OACA,KACF;EACA,OAAOE;CACT;CACA,OAAAI,gBACGzC,MAAI;EAAA,IACH0C,OAAI;GAAA,OAAE,CAACxC,aAAa8B,MAAME,OAAOS,KAAAA,KAAaX,MAAME,OAAO;EAAS;EAAA,IACpEU,WAAQ;GAAA,OAAAH,gBACL3C,aAAW+C,WAAA;IAAA,IACVX,KAAE;KAAA,OAAEF,MAAME,MAAM;IAAQ;IACxBM,MAAI;IAAA,aAAA;IAAA,KAAA,WAAA;KAAA,OAEGL,UAAU;IAAC;GAAA,GACbF,IAAgC,CAAA;EAAA;EAAA,IAAAa,WAAA;GAAA,OAIxCV,OAAO;EAAC;CAAA,CAAA;AAGf"}
1
+ {"version":3,"file":"button.js","names":["Polymorphic","mergeProps","sharedConfig","Show","splitProps","isServer","spread","cva","controlInteractive","controlSize","cn","buttonVariants","variants","variant","default","secondary","destructive","outline","ghost","toolbar","subtle","success","link","size","xs","sm","md","lg","xl","touchTarget","comfortable","defaultVariants","class","Button","props","local","rest","as","className","native","element","document","createElement","type","_$createComponent","when","_$memo","context","undefined","fallback","_$mergeProps","children"],"sources":["../../../../src/components/ui/button/button.tsx"],"sourcesContent":["import { Polymorphic, type PolymorphicProps } from '@kobalte/core/polymorphic'\nimport {\n type ComponentProps,\n mergeProps,\n sharedConfig,\n Show,\n splitProps,\n type ValidComponent,\n} from 'solid-js'\nimport { isServer, spread } from 'solid-js/web'\nimport { cva, controlInteractive, controlSize, type VariantProps } from '#lib/variants'\nimport { cn } from '#lib/utils'\n\n/**\n * Button.\n *\n * One appearance ladder shared by every pressable thing in the system: a\n * button, a toolbar control, a dialog action, and a menu row all draw from the\n * same tokens, so a row of them cannot drift apart.\n *\n * The variants answer \"what is this for\", never \"what colour is it\". A caller\n * that wants a red button writes `variant=\"destructive\"`; the red lives here.\n * That is also what lets the design-system linter tell a caller which variant\n * to use instead of only which class was wrong.\n *\n * Polymorphic: pass `as=\"a\"` (or any component) and the button becomes it\n * while keeping the same styling contract. This replaces the React-era\n * `asChild` primitive, which has no Solid equivalent that preserves props.\n */\nexport const buttonVariants = cva(\n `${controlInteractive} inline-flex shrink-0 items-center justify-center rounded-md font-medium whitespace-nowrap select-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,\n {\n variants: {\n variant: {\n /** The one primary action in a view. */\n default: 'bg-primary text-primary-foreground hover:bg-primary-hover',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-surface-hover',\n /** For the action that destroys something. Never the default. */\n destructive:\n 'bg-destructive-action text-destructive-action-foreground hover:bg-destructive-action/90 focus-visible:ring-destructive-subtle',\n /** A bordered button for a surface that already has a fill. */\n outline:\n 'border border-border bg-transparent text-foreground hover:bg-surface-hover hover:border-input',\n /** No chrome until hover. The default for toolbar and row actions. */\n ghost: 'text-foreground hover:bg-surface-hover',\n /**\n * A ghost that opens something: a sheet, menu or popover trigger in a\n * toolbar. While its surface is open it holds the accent's own tint,\n * the same treatment that drives the side rail's active destination,\n * so the open control never reads identical to its closed neighbours\n * and the app's pressed chrome reads as one accent chroma. The\n * compound hover keeps the tint when an open control is pointed at.\n */\n toolbar:\n 'text-foreground hover:bg-surface-hover data-[expanded]:bg-primary-subtle data-[expanded]:text-primary data-[expanded]:hover:bg-primary-subtle',\n /** A tinted primary, for a secondary action inside a primary flow. */\n subtle: 'bg-primary-subtle text-primary hover:bg-primary-subtle/80',\n success: 'bg-success text-success-foreground hover:bg-success/90',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n '2xs': `${controlSize['2xs']} [&_svg]:size-3`,\n xs: `${controlSize.xs} [&_svg]:size-3.5`,\n sm: `${controlSize.sm} [&_svg]:size-3.5`,\n md: `${controlSize.md} [&_svg]:size-4`,\n lg: `${controlSize.lg} [&_svg]:size-4`,\n xl: `${controlSize.xl} [&_svg]:size-5`,\n '2xl': `${controlSize['2xl']} [&_svg]:size-6`,\n /* Square, for an icon with no label. The accessible name then has to\n come from `aria-label` or a visually hidden label — an icon-only\n button with neither is the accessibility finding the Storybook lane\n catches on every story. */\n 'icon-2xs': 'size-control-2xs p-0 [&_svg]:size-3',\n 'icon-xs': 'size-control-xs p-0 [&_svg]:size-3.5',\n 'icon-sm': 'size-control-sm p-0 [&_svg]:size-3.5',\n 'icon-md': 'size-control-md p-0 [&_svg]:size-4',\n 'icon-lg': 'size-control-lg p-0 [&_svg]:size-4',\n 'icon-xl': 'size-control-xl p-0 [&_svg]:size-5',\n 'icon-2xl': 'size-control-2xl p-0 [&_svg]:size-6',\n },\n /** Opt in to a stable touch target on devices with any coarse pointer. */\n touchTarget: {\n comfortable: 'touch-target-comfortable',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n },\n }\n)\n\ntype ButtonVariantProps = VariantProps<typeof buttonVariants>\n\nexport type ButtonProps<T extends ValidComponent = 'button'> = PolymorphicProps<\n T,\n ButtonVariantProps & {\n class?: string\n }\n>\n\nexport function Button<T extends ValidComponent = 'button'>(props: ButtonProps<T>) {\n const [local, rest] = splitProps(props as ButtonProps & { as?: ValidComponent }, [\n 'as',\n 'variant',\n 'size',\n 'touchTarget',\n 'class',\n ])\n const className = () =>\n cn(\n buttonVariants({\n variant: local.variant,\n size: local.size,\n touchTarget: local.touchTarget,\n }),\n local.class\n )\n\n // A native button, the common case, is written directly: Polymorphic goes\n // through Dynamic, two prop proxies and a memo per button. It is built with\n // createElement and spread, which is what the compiled JSX would do, so the\n // module holds no template: `buttonVariants` stays importable in plain Node\n // (a server renderer reads the class contract from this entry). A server\n // render has no document, so it takes the Polymorphic path. So does a button\n // the client hydrates: a fresh element would not adopt the server's node, and\n // its children would look for server nodes that were never claimed.\n const native = () => {\n const element = document.createElement('button')\n spread(\n element,\n mergeProps({ type: 'button', 'data-slot': 'button' }, rest as ComponentProps<'button'>, {\n get class() {\n return className()\n },\n }),\n false,\n false\n )\n return element\n }\n return (\n <Show\n when={!isServer && !sharedConfig.context && (local.as === undefined || local.as === 'button')}\n fallback={\n <Polymorphic\n as={local.as ?? 'button'}\n type=\"button\"\n data-slot=\"button\"\n class={className()}\n {...(rest as ComponentProps<'button'>)}\n />\n }\n >\n {native()}\n </Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAaW,iBAAiBJ,IAC5B,GAAGC,mBAAkB,sJACrB;CACEI,UAAU;EACRC,SAAS;;GAEPC,SAAS;GACTC,WAAW;;GAEXC,aACE;;GAEFC,SACE;;GAEFC,OAAO;;;;;;;;;GASPC,SACE;;GAEFC,QAAQ;GACRC,SAAS;GACTC,MAAM;EACR;EACAC,MAAM;GACJ,OAAO,GAAGd,YAAY,OAAM;GAC5Be,IAAI,GAAGf,YAAYe,GAAE;GACrBC,IAAI,GAAGhB,YAAYgB,GAAE;GACrBC,IAAI,GAAGjB,YAAYiB,GAAE;GACrBC,IAAI,GAAGlB,YAAYk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class names, path keys) stays exactly
13
13
  * lucide's. Props that change the drawing (`size`, `color`, `strokeWidth`,
14
14
  * `absoluteStrokeWidth`) or a `LucideProvider` are not supported: those callers
15
- * keep the lucide component. On the server the lucide component renders as is.
15
+ * keep the lucide component. On the server, and while the client hydrates, the
16
+ * lucide component renders as is.
16
17
  */
17
18
  export declare function fastIcon<T extends (props: never) => JSX.Element>(LucideIcon: T): T;
18
19
  //# sourceMappingURL=fast-icon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fast-icon.d.ts","sourceRoot":"","sources":["../../src/lib/fast-icon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAoBnC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CA+BlF"}
1
+ {"version":3,"file":"fast-icon.d.ts","sourceRoot":"","sources":["../../src/lib/fast-icon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAoBnC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAqClF"}
@@ -1,5 +1,5 @@
1
1
  import { isServer, spread } from "solid-js/web";
2
- import { createRoot, mergeProps as mergeProps$1, splitProps } from "solid-js";
2
+ import { createRoot, mergeProps as mergeProps$1, sharedConfig, splitProps } from "solid-js";
3
3
  // src/lib/fast-icon.ts
4
4
  var DRAWING = [
5
5
  "size",
@@ -25,12 +25,13 @@ var A11Y = /^(aria-|role$|title$)/;
25
25
  * drew, so the markup (attributes, class names, path keys) stays exactly
26
26
  * lucide's. Props that change the drawing (`size`, `color`, `strokeWidth`,
27
27
  * `absoluteStrokeWidth`) or a `LucideProvider` are not supported: those callers
28
- * keep the lucide component. On the server the lucide component renders as is.
28
+ * keep the lucide component. On the server, and while the client hydrates, the
29
+ * lucide component renders as is.
29
30
  */
30
31
  function fastIcon(LucideIcon) {
31
32
  const Icon = LucideIcon;
32
33
  const Fast = (props) => {
33
- if (isServer || props.children !== void 0 || DRAWING.some((key) => key in props)) return Icon(props);
34
+ if (isServer || sharedConfig.context || props.children !== void 0 || DRAWING.some((key) => key in props)) return Icon(props);
34
35
  const template = capture(Icon);
35
36
  const [local, rest] = splitProps(props, ["class"]);
36
37
  const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
@@ -1 +1 @@
1
- {"version":3,"file":"fast-icon.js","names":["mergeProps"],"sources":["../../src/lib/fast-icon.ts"],"sourcesContent":["import type { JSX } from 'solid-js'\nimport { createRoot, mergeProps, splitProps } from 'solid-js'\nimport { isServer, spread } from 'solid-js/web'\n\ntype IconComponent = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => JSX.Element\n// lucide's own drawing props: an icon given one keeps lucide's component.\nconst DRAWING = [\n 'size',\n 'color',\n 'strokeWidth',\n 'absoluteStrokeWidth',\n 'nonScalingStroke',\n 'width',\n 'height',\n]\ntype Captured = { attributes: [string, string][]; className: string; body: DocumentFragment }\n\nconst captured = new WeakMap<IconComponent, Captured>()\nconst A11Y = /^(aria-|role$|title$)/\n\n/**\n * The same lucide icon, built by cloning a template instead of by components.\n *\n * lucide-solid builds every icon as a `<For>` of `<Dynamic>` children, one\n * component and one spread effect per path. A plain six-path icon cost as much\n * to mount as a Button, and a transcript row spent a quarter of its mount time\n * in its avatar's icon. The paths never change, so they are drawn once per icon\n * and cloned after that; only the outer `<svg>` takes props.\n *\n * The first instance renders the lucide component itself and records what it\n * drew, so the markup (attributes, class names, path keys) stays exactly\n * lucide's. Props that change the drawing (`size`, `color`, `strokeWidth`,\n * `absoluteStrokeWidth`) or a `LucideProvider` are not supported: those callers\n * keep the lucide component. On the server the lucide component renders as is.\n */\nexport function fastIcon<T extends (props: never) => JSX.Element>(LucideIcon: T): T {\n const Icon = LucideIcon as unknown as IconComponent\n const Fast = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => {\n // Children (a <title>), drawing props and the server keep lucide's component.\n if (isServer || props.children !== undefined || DRAWING.some((key) => key in props))\n return Icon(props)\n const template = capture(Icon)\n const [local, rest] = splitProps(props, ['class'])\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')\n let labelled = false\n for (const key in rest) if (A11Y.test(key)) labelled = true\n for (const [name, value] of template.attributes) svg.setAttribute(name, value)\n svg.append(template.body.cloneNode(true))\n // In lucide's order: its attributes, the class, aria-hidden, then the caller's.\n spread(\n svg,\n mergeProps(\n {\n get class() {\n return local.class ? `${template.className} ${local.class}` : template.className\n },\n ...(labelled ? {} : { 'aria-hidden': 'true' }),\n },\n rest\n ) as never,\n true,\n true\n )\n return svg as unknown as JSX.Element\n }\n return Fast as unknown as T\n}\n\nfunction capture(Icon: IconComponent): Captured {\n const known = captured.get(Icon)\n if (known) return known\n const svg = createRoot((dispose) => {\n const element = Icon({}) as unknown as SVGSVGElement\n dispose()\n return element\n })\n const attributes: [string, string][] = []\n let className = ''\n for (const attribute of Array.from(svg.attributes)) {\n if (attribute.name === 'class') className = attribute.value\n else if (attribute.name !== 'aria-hidden') attributes.push([attribute.name, attribute.value])\n }\n const body = document.createDocumentFragment()\n for (const child of Array.from(svg.childNodes)) body.append(child.cloneNode(true))\n const result = { attributes, className, body }\n captured.set(Icon, result)\n return result\n}\n"],"mappings":";;;AAMA,IAAM,UAAU;CACd;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,IAAM,2BAAW,IAAI,QAAiC;AACtD,IAAM,OAAO;;;;;;;;;;;;;;;;AAiBb,SAAgB,SAAkD,YAAkB;CAClF,MAAM,OAAO;CACb,MAAM,QAAQ,UAA+C;EAE3D,IAAI,YAAY,MAAM,aAAa,KAAA,KAAa,QAAQ,MAAM,QAAQ,OAA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"file":"fast-icon.js","names":["mergeProps"],"sources":["../../src/lib/fast-icon.ts"],"sourcesContent":["import type { JSX } from 'solid-js'\nimport { createRoot, mergeProps, sharedConfig, splitProps } from 'solid-js'\nimport { isServer, spread } from 'solid-js/web'\n\ntype IconComponent = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => JSX.Element\n// lucide's own drawing props: an icon given one keeps lucide's component.\nconst DRAWING = [\n 'size',\n 'color',\n 'strokeWidth',\n 'absoluteStrokeWidth',\n 'nonScalingStroke',\n 'width',\n 'height',\n]\ntype Captured = { attributes: [string, string][]; className: string; body: DocumentFragment }\n\nconst captured = new WeakMap<IconComponent, Captured>()\nconst A11Y = /^(aria-|role$|title$)/\n\n/**\n * The same lucide icon, built by cloning a template instead of by components.\n *\n * lucide-solid builds every icon as a `<For>` of `<Dynamic>` children, one\n * component and one spread effect per path. A plain six-path icon cost as much\n * to mount as a Button, and a transcript row spent a quarter of its mount time\n * in its avatar's icon. The paths never change, so they are drawn once per icon\n * and cloned after that; only the outer `<svg>` takes props.\n *\n * The first instance renders the lucide component itself and records what it\n * drew, so the markup (attributes, class names, path keys) stays exactly\n * lucide's. Props that change the drawing (`size`, `color`, `strokeWidth`,\n * `absoluteStrokeWidth`) or a `LucideProvider` are not supported: those callers\n * keep the lucide component. On the server, and while the client hydrates, the\n * lucide component renders as is.\n */\nexport function fastIcon<T extends (props: never) => JSX.Element>(LucideIcon: T): T {\n const Icon = LucideIcon as unknown as IconComponent\n const Fast = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => {\n // Children (a <title>), drawing props, the server and hydration keep lucide's\n // component: a hydrating icon must claim the server's nodes, not build its own.\n if (\n isServer ||\n sharedConfig.context ||\n props.children !== undefined ||\n DRAWING.some((key) => key in props)\n )\n return Icon(props)\n const template = capture(Icon)\n const [local, rest] = splitProps(props, ['class'])\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')\n let labelled = false\n for (const key in rest) if (A11Y.test(key)) labelled = true\n for (const [name, value] of template.attributes) svg.setAttribute(name, value)\n svg.append(template.body.cloneNode(true))\n // In lucide's order: its attributes, the class, aria-hidden, then the caller's.\n spread(\n svg,\n mergeProps(\n {\n get class() {\n return local.class ? `${template.className} ${local.class}` : template.className\n },\n ...(labelled ? {} : { 'aria-hidden': 'true' }),\n },\n rest\n ) as never,\n true,\n true\n )\n return svg as unknown as JSX.Element\n }\n return Fast as unknown as T\n}\n\nfunction capture(Icon: IconComponent): Captured {\n const known = captured.get(Icon)\n if (known) return known\n const svg = createRoot((dispose) => {\n const element = Icon({}) as unknown as SVGSVGElement\n dispose()\n return element\n })\n const attributes: [string, string][] = []\n let className = ''\n for (const attribute of Array.from(svg.attributes)) {\n if (attribute.name === 'class') className = attribute.value\n else if (attribute.name !== 'aria-hidden') attributes.push([attribute.name, attribute.value])\n }\n const body = document.createDocumentFragment()\n for (const child of Array.from(svg.childNodes)) body.append(child.cloneNode(true))\n const result = { attributes, className, body }\n captured.set(Icon, result)\n return result\n}\n"],"mappings":";;;AAMA,IAAM,UAAU;CACd;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,IAAM,2BAAW,IAAI,QAAiC;AACtD,IAAM,OAAO;;;;;;;;;;;;;;;;;AAkBb,SAAgB,SAAkD,YAAkB;CAClF,MAAM,OAAO;CACb,MAAM,QAAQ,UAA+C;EAG3D,IACE,YACA,aAAa,WACb,MAAM,aAAa,KAAA,KACnB,QAAQ,MAAM,QAAQ,OAAO,KAAK,GAElC,OAAO,KAAK,KAAK;EACnB,MAAM,WAAW,QAAQ,IAAI;EAC7B,MAAM,CAAC,OAAO,QAAQ,WAAW,OAAO,CAAC,OAAO,CAAC;EACjD,MAAM,MAAM,SAAS,gBAAgB,8BAA8B,KAAK;EACxE,IAAI,WAAW;EACf,KAAK,MAAM,OAAO,MAAM,IAAI,KAAK,KAAK,GAAG,GAAG,WAAW;EACvD,KAAK,MAAM,CAAC,MAAM,UAAU,SAAS,YAAY,IAAI,aAAa,MAAM,KAAK;EAC7E,IAAI,OAAO,SAAS,KAAK,UAAU,IAAI,CAAC;EAExC,OACE,KACAA,aACE;GACE,IAAI,QAAQ;IACV,OAAO,MAAM,QAAQ,GAAG,SAAS,UAAU,GAAG,MAAM,UAAU,SAAS;GACzE;GACA,GAAI,WAAW,CAAC,IAAI,EAAE,eAAe,OAAO;EAC9C,GACA,IACF,GACA,MACA,IACF;EACA,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAS,QAAQ,MAA+B;CAC9C,MAAM,QAAQ,SAAS,IAAI,IAAI;CAC/B,IAAI,OAAO,OAAO;CAClB,MAAM,MAAM,YAAY,YAAY;EAClC,MAAM,UAAU,KAAK,CAAC,CAAC;EACvB,QAAQ;EACR,OAAO;CACT,CAAC;CACD,MAAM,aAAiC,CAAC;CACxC,IAAI,YAAY;CAChB,KAAK,MAAM,aAAa,MAAM,KAAK,IAAI,UAAU,GAC/C,IAAI,UAAU,SAAS,SAAS,YAAY,UAAU;MACjD,IAAI,UAAU,SAAS,eAAe,WAAW,KAAK,CAAC,UAAU,MAAM,UAAU,KAAK,CAAC;CAE9F,MAAM,OAAO,SAAS,uBAAuB;CAC7C,KAAK,MAAM,SAAS,MAAM,KAAK,IAAI,UAAU,GAAG,KAAK,OAAO,MAAM,UAAU,IAAI,CAAC;CACjF,MAAM,SAAS;EAAE;EAAY;EAAW;CAAK;CAC7C,SAAS,IAAI,MAAM,MAAM;CACzB,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"theme-defaults.generated.d.ts","sourceRoot":"","sources":["../../src/lib/theme-defaults.generated.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAErE,uEAAuE;AACvE,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,MAA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 -106,21 +106,28 @@ var DEFAULT_VARIANTS = {
106
106
  brightWhite: "oklch(0.6658 0.0181 250.92)"
107
107
  },
108
108
  editor: {
109
- keyword: "oklch(0.5143 0.1668 301.69)",
110
- string: "oklch(0.4771 0.1809 145.62)",
111
- number: "oklch(0.5016 0.1401 79.91)",
112
- comment: "oklch(0.4849 0.0196 251.02)",
113
- function: "oklch(0.4973 0.1518 253.31)",
114
- variable: "oklch(0.2785 0.0132 253.04)",
115
- type: "oklch(0.5375 0.1155 202.14)",
116
- tag: "oklch(0.5165 0.1626 25.78)",
117
- attribute: "oklch(0.5016 0.1401 79.91)",
118
- operator: "oklch(0.2785 0.0132 253.04)",
119
- heading: "oklch(0.5143 0.1668 301.69)",
120
- link: "oklch(0.4973 0.1518 253.31)",
121
- diffAdd: "oklch(0.4771 0.1809 145.62)",
122
- diffDelete: "oklch(0.5165 0.1626 25.78)",
123
- diffHunk: "oklch(0.5375 0.1155 202.14)",
109
+ keyword: "oklch(0.5517 0.2051 24.53)",
110
+ storage: "oklch(0.5517 0.2051 24.53)",
111
+ string: "oklch(0.321 0.1084 259.11)",
112
+ number: "oklch(0.4509 0.1641 258.18)",
113
+ comment: "oklch(0.5651 0.0189 250.97)",
114
+ function: "oklch(0.5631 0.2069 294.97)",
115
+ variable: "oklch(0.2542 0.0111 254.04)",
116
+ parameter: "oklch(0.4657 0.1371 43.35)",
117
+ property: "oklch(0.2542 0.0111 254.04)",
118
+ field: "oklch(0.2542 0.0111 254.04)",
119
+ member: "oklch(0.2542 0.0111 254.04)",
120
+ type: "oklch(0.4657 0.1371 43.35)",
121
+ tag: "oklch(0.4391 0.1179 148.07)",
122
+ attribute: "oklch(0.4509 0.1641 258.18)",
123
+ operator: "oklch(0.5517 0.2051 24.53)",
124
+ heading: "oklch(0.4509 0.1641 258.18)",
125
+ link: "oklch(0.2542 0.0111 254.04)",
126
+ constant: "oklch(0.4509 0.1641 258.18)",
127
+ punctuation: "oklch(0.2542 0.0111 254.04)",
128
+ diffAdd: "oklch(0.4391 0.1179 148.07)",
129
+ diffDelete: "oklch(0.387 0.1507 20.77)",
130
+ diffHunk: "oklch(0.5631 0.2069 294.97)",
124
131
  searchMatch: "oklch(0.5016 0.1401 79.91)"
125
132
  },
126
133
  chart: [
@@ -205,21 +212,28 @@ var DEFAULT_VARIANTS = {
205
212
  brightWhite: "oklch(1 0 0)"
206
213
  },
207
214
  editor: {
208
- keyword: "oklch(0.7323 0.1668 301.69)",
209
- string: "oklch(0.6951 0.1809 145.62)",
210
- number: "oklch(0.7196 0.1401 79.91)",
211
- comment: "oklch(0.5627 0.0094 301.22)",
212
- function: "oklch(0.7153 0.1518 253.31)",
213
- variable: "oklch(0.786 0.0087 301.32)",
214
- type: "oklch(0.7555 0.1155 202.14)",
215
- tag: "oklch(0.7345 0.1626 25.78)",
216
- attribute: "oklch(0.7196 0.1401 79.91)",
217
- operator: "oklch(0.786 0.0087 301.32)",
218
- heading: "oklch(0.7323 0.1668 301.69)",
219
- link: "oklch(0.7153 0.1518 253.31)",
220
- diffAdd: "oklch(0.6951 0.1809 145.62)",
221
- diffDelete: "oklch(0.7345 0.1626 25.78)",
222
- diffHunk: "oklch(0.7555 0.1155 202.14)",
215
+ keyword: "oklch(0.7345 0.1626 25.78)",
216
+ storage: "oklch(0.7345 0.1626 25.78)",
217
+ string: "oklch(0.856 0.0768 244.09)",
218
+ number: "oklch(0.7857 0.1153 246.66)",
219
+ comment: "oklch(0.6625 0.0181 250.92)",
220
+ function: "oklch(0.8005 0.1275 305.86)",
221
+ variable: "oklch(0.9425 0.0111 243.66)",
222
+ parameter: "oklch(0.7991 0.1412 60.1)",
223
+ property: "oklch(0.9425 0.0111 243.66)",
224
+ field: "oklch(0.9425 0.0111 243.66)",
225
+ member: "oklch(0.9425 0.0111 243.66)",
226
+ type: "oklch(0.7991 0.1412 60.1)",
227
+ tag: "oklch(0.8416 0.1641 145.75)",
228
+ attribute: "oklch(0.7857 0.1153 246.66)",
229
+ operator: "oklch(0.7345 0.1626 25.78)",
230
+ heading: "oklch(0.7857 0.1153 246.66)",
231
+ link: "oklch(0.9425 0.0111 243.66)",
232
+ constant: "oklch(0.7857 0.1153 246.66)",
233
+ punctuation: "oklch(0.9425 0.0111 243.66)",
234
+ diffAdd: "oklch(0.8416 0.1641 145.75)",
235
+ diffDelete: "oklch(0.8014 0.1134 25.81)",
236
+ diffHunk: "oklch(0.8005 0.1275 305.86)",
223
237
  searchMatch: "oklch(0.7196 0.1401 79.91)"
224
238
  },
225
239
  chart: [
@@ -276,39 +290,53 @@ var DEFAULT_PRIMARY_SUBTLE = {
276
290
  /** Each default's `--editor-*` ramp held to 4.5:1 on its canvas (`editorRoles: 'floor'`). */
277
291
  var DEFAULT_FLOOR_EDITOR = {
278
292
  "adea-light": {
279
- keyword: "#7a49b5",
280
- string: "#00711f",
281
- number: "#825c00",
282
- comment: "#57606a",
283
- function: "#0662b5",
284
- variable: "#24292f",
285
- type: "#007d85",
286
- tag: "#b23533",
287
- attribute: "#825c00",
288
- operator: "#24292f",
289
- heading: "#7a49b5",
290
- link: "#0662b5",
291
- diffAdd: "#00711f",
292
- diffDelete: "#b23533",
293
- diffHunk: "#007d85",
293
+ keyword: "#cf222e",
294
+ storage: "#cf222e",
295
+ string: "#0a3069",
296
+ number: "#0550ae",
297
+ comment: "#6e7781",
298
+ function: "#8250df",
299
+ variable: "#1f2328",
300
+ parameter: "#953800",
301
+ property: "#1f2328",
302
+ field: "#1f2328",
303
+ member: "#1f2328",
304
+ type: "#953800",
305
+ tag: "#116329",
306
+ attribute: "#0550ae",
307
+ operator: "#cf222e",
308
+ heading: "#0550ae",
309
+ link: "#1f2328",
310
+ constant: "#0550ae",
311
+ punctuation: "#1f2328",
312
+ diffAdd: "#116329",
313
+ diffDelete: "#82071e",
314
+ diffHunk: "#8250df",
294
315
  searchMatch: "#825c00"
295
316
  },
296
317
  "adea-dark": {
297
- keyword: "#bc8cff",
298
- string: "#3fb950",
299
- number: "#d29922",
300
- comment: "#7d7b81",
301
- function: "#58a6ff",
302
- variable: "#bab8be",
303
- type: "#39c5cf",
304
- tag: "#ff7b72",
305
- attribute: "#d29922",
306
- operator: "#bab8be",
307
- heading: "#bc8cff",
308
- link: "#58a6ff",
309
- diffAdd: "#3fb950",
310
- diffDelete: "#ff7b72",
311
- diffHunk: "#39c5cf",
318
+ keyword: "#ff7b72",
319
+ storage: "#ff7b72",
320
+ string: "#a5d6ff",
321
+ number: "#79c0ff",
322
+ comment: "#8b949e",
323
+ function: "#d2a8ff",
324
+ variable: "#e6edf3",
325
+ parameter: "#ffa657",
326
+ property: "#e6edf3",
327
+ field: "#e6edf3",
328
+ member: "#e6edf3",
329
+ type: "#ffa657",
330
+ tag: "#7ee787",
331
+ attribute: "#79c0ff",
332
+ operator: "#ff7b72",
333
+ heading: "#79c0ff",
334
+ link: "#e6edf3",
335
+ constant: "#79c0ff",
336
+ punctuation: "#e6edf3",
337
+ diffAdd: "#7ee787",
338
+ diffDelete: "#ffa198",
339
+ diffHunk: "#d2a8ff",
312
340
  searchMatch: "#d29922"
313
341
  }
314
342
  };