@g9tm/lynxcontrols-foundation 1.7.3 → 2.2.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 (112) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/culture/bidi.d.ts +8 -0
  3. package/dist/culture/bidi.d.ts.map +1 -0
  4. package/dist/culture/bidi.js +16 -0
  5. package/dist/culture/bidi.js.map +1 -0
  6. package/dist/culture/coordinates.d.ts +17 -0
  7. package/dist/culture/coordinates.d.ts.map +1 -0
  8. package/dist/culture/coordinates.js +18 -0
  9. package/dist/culture/coordinates.js.map +1 -0
  10. package/dist/culture/index.d.ts +4 -0
  11. package/dist/culture/index.d.ts.map +1 -1
  12. package/dist/culture/index.js +4 -0
  13. package/dist/culture/natural-date.d.ts +9 -0
  14. package/dist/culture/natural-date.d.ts.map +1 -0
  15. package/dist/culture/natural-date.js +208 -0
  16. package/dist/culture/natural-date.js.map +1 -0
  17. package/dist/culture/text.d.ts +73 -0
  18. package/dist/culture/text.d.ts.map +1 -0
  19. package/dist/culture/text.js +213 -0
  20. package/dist/culture/text.js.map +1 -0
  21. package/dist/enums/index.d.ts +6 -0
  22. package/dist/enums/index.d.ts.map +1 -1
  23. package/dist/enums/index.js +4 -1
  24. package/dist/enums/index.js.map +1 -1
  25. package/dist/icons/index.d.ts +2 -1
  26. package/dist/icons/index.d.ts.map +1 -1
  27. package/dist/icons/index.js +2 -1
  28. package/dist/icons/packs.d.ts +34 -0
  29. package/dist/icons/packs.d.ts.map +1 -0
  30. package/dist/icons/packs.js +70 -0
  31. package/dist/icons/packs.js.map +1 -0
  32. package/dist/icons/svg.d.ts +9 -2
  33. package/dist/icons/svg.d.ts.map +1 -1
  34. package/dist/icons/svg.js +13 -2
  35. package/dist/icons/svg.js.map +1 -1
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +1 -0
  39. package/dist/layout/index.d.ts +43 -0
  40. package/dist/layout/index.d.ts.map +1 -0
  41. package/dist/layout/index.js +31 -0
  42. package/dist/layout/index.js.map +1 -0
  43. package/dist/services/contracts.d.ts +32 -0
  44. package/dist/services/contracts.d.ts.map +1 -1
  45. package/dist/services/contracts.js.map +1 -1
  46. package/dist/services/feedback.d.ts +28 -0
  47. package/dist/services/feedback.d.ts.map +1 -0
  48. package/dist/services/feedback.js +27 -0
  49. package/dist/services/feedback.js.map +1 -0
  50. package/dist/services/index.d.ts +3 -1
  51. package/dist/services/index.d.ts.map +1 -1
  52. package/dist/services/index.js +2 -0
  53. package/dist/services/keys.d.ts +39 -0
  54. package/dist/services/keys.d.ts.map +1 -0
  55. package/dist/services/keys.js +96 -0
  56. package/dist/services/keys.js.map +1 -0
  57. package/dist/theme/aliases.d.ts +73 -0
  58. package/dist/theme/aliases.d.ts.map +1 -0
  59. package/dist/theme/aliases.js +76 -0
  60. package/dist/theme/aliases.js.map +1 -0
  61. package/dist/theme/appearance.d.ts +57 -0
  62. package/dist/theme/appearance.d.ts.map +1 -0
  63. package/dist/theme/appearance.js +275 -0
  64. package/dist/theme/appearance.js.map +1 -0
  65. package/dist/theme/brand.d.ts +40 -0
  66. package/dist/theme/brand.d.ts.map +1 -0
  67. package/dist/theme/brand.js +181 -0
  68. package/dist/theme/brand.js.map +1 -0
  69. package/dist/theme/contrast.d.ts +19 -0
  70. package/dist/theme/contrast.d.ts.map +1 -0
  71. package/dist/theme/contrast.js +119 -0
  72. package/dist/theme/contrast.js.map +1 -0
  73. package/dist/theme/css-color.d.ts +20 -0
  74. package/dist/theme/css-color.d.ts.map +1 -0
  75. package/dist/theme/css-color.js +149 -0
  76. package/dist/theme/css-color.js.map +1 -0
  77. package/dist/theme/design.d.ts +33 -0
  78. package/dist/theme/design.d.ts.map +1 -0
  79. package/dist/theme/design.js +162 -0
  80. package/dist/theme/design.js.map +1 -0
  81. package/dist/theme/index.d.ts +10 -2
  82. package/dist/theme/index.d.ts.map +1 -1
  83. package/dist/theme/index.js +10 -2
  84. package/dist/theme/oklch.d.ts +63 -0
  85. package/dist/theme/oklch.d.ts.map +1 -0
  86. package/dist/theme/oklch.js +258 -0
  87. package/dist/theme/oklch.js.map +1 -0
  88. package/dist/theme/recipe.d.ts +44 -0
  89. package/dist/theme/recipe.d.ts.map +1 -0
  90. package/dist/theme/recipe.js +156 -0
  91. package/dist/theme/recipe.js.map +1 -0
  92. package/dist/theme/theme.d.ts +43 -2
  93. package/dist/theme/theme.d.ts.map +1 -1
  94. package/dist/theme/theme.js +85 -9
  95. package/dist/theme/theme.js.map +1 -1
  96. package/dist/theme/variants.d.ts +10 -0
  97. package/dist/theme/variants.d.ts.map +1 -1
  98. package/dist/theme/variants.js +74 -1
  99. package/dist/theme/variants.js.map +1 -1
  100. package/dist/tokens/derived.d.ts +31 -0
  101. package/dist/tokens/derived.d.ts.map +1 -0
  102. package/dist/tokens/derived.js +42 -0
  103. package/dist/tokens/derived.js.map +1 -0
  104. package/dist/tokens/index.d.ts +2 -0
  105. package/dist/tokens/index.d.ts.map +1 -1
  106. package/dist/tokens/index.js +2 -0
  107. package/dist/tokens/shape.d.ts +46 -0
  108. package/dist/tokens/shape.d.ts.map +1 -0
  109. package/dist/tokens/shape.js +95 -0
  110. package/dist/tokens/shape.js.map +1 -0
  111. package/docs/api.md +135 -2
  112. package/package.json +6 -1
@@ -0,0 +1,73 @@
1
+ import { type G9ColorToken, type G9PaletteValues } from '../tokens/generated/palettes.js';
2
+ /** App name → library token (`'TextPrimary'`) or a literal colour (`'#1B1512'`). */
3
+ export type G9TokenAliasMap = Readonly<Record<string, G9ColorToken | string>>;
4
+ /** The app's names with their colours in `palette` (for code that reads colours from an object, like `t.ink`). */
5
+ export declare function aliasPalette(palette: G9PaletteValues, map: G9TokenAliasMap): Readonly<Record<string, string>>;
6
+ /**
7
+ * CSS variables for the app's names, each a reference to the library's variable, so a stylesheet written against
8
+ * `var(--ink)` follows the library theme with no repaint code: `{ '--ink': 'var(--g9-text-primary)' }`.
9
+ * `prefix` is prepended to the alias (G9Hub: `'g9-'` keeps its `--g9-surface-2`).
10
+ */
11
+ export declare function aliasCssVariables(map: G9TokenAliasMap, prefix?: string): Readonly<Record<string, string>>;
12
+ /** Ready-made alias maps for the four G9 apps' existing names (the migration guides start from these). */
13
+ export declare const g9AliasPresets: Readonly<{
14
+ /** G9SACManagement / G9Berjis `Tokens` keys. */
15
+ berjis: {
16
+ ground: string;
17
+ surface: string;
18
+ sunken: string;
19
+ ink: string;
20
+ ink2: string;
21
+ ink3: string;
22
+ onInk: string;
23
+ line: string;
24
+ line2: string;
25
+ primary: string;
26
+ onPrimary: string;
27
+ primaryText: string;
28
+ primaryWash: string;
29
+ accent: string;
30
+ accentText: string;
31
+ positive: string;
32
+ positiveText: string;
33
+ alert: string;
34
+ };
35
+ /** G9Riskara `DARK`/`LIGHT` keys. */
36
+ riskara: {
37
+ bg: string;
38
+ surface: string;
39
+ surface2: string;
40
+ line: string;
41
+ line2: string;
42
+ text: string;
43
+ text2: string;
44
+ muted: string;
45
+ primary: string;
46
+ primarySoft: string;
47
+ primaryText: string;
48
+ onPrimary: string;
49
+ pos: string;
50
+ neg: string;
51
+ warn: string;
52
+ scrim: string;
53
+ };
54
+ /** G9Hub tailwind colour names (`--g9-<name>`). */
55
+ hub: {
56
+ bg: string;
57
+ 'bg-elev': string;
58
+ surface: string;
59
+ 'surface-2': string;
60
+ 'surface-3': string;
61
+ border: string;
62
+ 'border-strong': string;
63
+ text: string;
64
+ 'text-2': string;
65
+ 'text-3': string;
66
+ accent: string;
67
+ 'accent-contrast': string;
68
+ danger: string;
69
+ success: string;
70
+ warning: string;
71
+ };
72
+ }>;
73
+ //# sourceMappingURL=aliases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../src/theme/aliases.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAiB,MAAM,8BAA8B,CAAC;AAEtG,oFAAoF;AACpF,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC;AAI9E,kHAAkH;AAClH,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAI7G;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,SAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CASrG;AAED,0GAA0G;AAC1G,eAAO,MAAM,cAAc;IACzB,gDAAgD;;;;;;;;;;;;;;;;;;;;;IAqBhD,qCAAqC;;;;;;;;;;;;;;;;;;;IAmBrC,mDAAmD;;;;;;;;;;;;;;;;;;EAkBT,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { cssVariableName, toKebabCase } from "../tokens/css-vars.js";
2
+ import { g9ColorTokens } from "../tokens/generated/palettes.js";
3
+ const isToken = (v)=>g9ColorTokens.includes(v);
4
+ function aliasPalette(palette, map) {
5
+ const out = {};
6
+ for (const [name, target] of Object.entries(map))out[name] = isToken(target) ? palette[target] : target;
7
+ return Object.freeze(out);
8
+ }
9
+ function aliasCssVariables(map, prefix = '') {
10
+ const out = {};
11
+ for (const [name, target] of Object.entries(map)){
12
+ const variable = `--${prefix}${toKebabCase(name)}`.toLowerCase();
13
+ if (!isToken(target) || variable !== cssVariableName(target)) out[variable] = isToken(target) ? `var(${cssVariableName(target)})` : target;
14
+ }
15
+ return Object.freeze(out);
16
+ }
17
+ const g9AliasPresets = Object.freeze({
18
+ berjis: {
19
+ ground: 'Background',
20
+ surface: 'Surface',
21
+ sunken: 'SurfaceContainerHigh',
22
+ ink: 'TextPrimary',
23
+ ink2: 'TextSecondary',
24
+ ink3: 'TextTertiary',
25
+ onInk: 'InverseOnSurface',
26
+ line: 'OutlineVariant',
27
+ line2: 'Divider',
28
+ primary: 'Primary',
29
+ onPrimary: 'OnPrimary',
30
+ primaryText: 'Primary',
31
+ primaryWash: 'PrimaryContainer',
32
+ accent: 'Tertiary',
33
+ accentText: 'OnTertiaryContainer',
34
+ positive: 'Success',
35
+ positiveText: 'OnSuccessContainer',
36
+ alert: 'Error'
37
+ },
38
+ riskara: {
39
+ bg: 'Background',
40
+ surface: 'Surface',
41
+ surface2: 'SurfaceContainer',
42
+ line: 'OutlineVariant',
43
+ line2: 'Divider',
44
+ text: 'TextPrimary',
45
+ text2: 'TextSecondary',
46
+ muted: 'TextTertiary',
47
+ primary: 'Primary',
48
+ primarySoft: 'PrimaryContainer',
49
+ primaryText: 'Primary',
50
+ onPrimary: 'OnPrimary',
51
+ pos: 'Success',
52
+ neg: 'Error',
53
+ warn: 'Warning',
54
+ scrim: 'Scrim'
55
+ },
56
+ hub: {
57
+ bg: 'Background',
58
+ 'bg-elev': 'SurfaceContainerLow',
59
+ surface: 'Surface',
60
+ 'surface-2': 'SurfaceContainer',
61
+ 'surface-3': 'SurfaceContainerHigh',
62
+ border: 'OutlineVariant',
63
+ 'border-strong': 'Outline',
64
+ text: 'TextPrimary',
65
+ 'text-2': 'TextSecondary',
66
+ 'text-3': 'TextTertiary',
67
+ accent: 'Primary',
68
+ 'accent-contrast': 'OnPrimary',
69
+ danger: 'Error',
70
+ success: 'Success',
71
+ warning: 'Warning'
72
+ }
73
+ });
74
+ export { aliasCssVariables, aliasPalette, g9AliasPresets };
75
+
76
+ //# sourceMappingURL=aliases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme/aliases.js","sources":["../../src/theme/aliases.ts"],"sourcesContent":["// Token aliases: an app keeps its own colour names while it moves onto the library (SAC's `t.ink`, `t.ground`, Riskara's\n// `text2`, G9Hub's `--g9-surface-2`) — each name points at a library token (or a fixed colour), and the library's theme\n// drives both. Lynx lowercases custom property names, so alias variables are written lower-kebab on both sides.\nimport { cssVariableName, toKebabCase } from '../tokens/css-vars';\nimport { type G9ColorToken, type G9PaletteValues, g9ColorTokens } from '../tokens/generated/palettes';\n\n/** App name → library token (`'TextPrimary'`) or a literal colour (`'#1B1512'`). */\nexport type G9TokenAliasMap = Readonly<Record<string, G9ColorToken | string>>;\n\nconst isToken = (v: string): v is G9ColorToken => (g9ColorTokens as readonly string[]).includes(v);\n\n/** The app's names with their colours in `palette` (for code that reads colours from an object, like `t.ink`). */\nexport function aliasPalette(palette: G9PaletteValues, map: G9TokenAliasMap): Readonly<Record<string, string>> {\n const out: Record<string, string> = {};\n for (const [name, target] of Object.entries(map)) out[name] = isToken(target) ? palette[target] : target;\n return Object.freeze(out);\n}\n\n/**\n * CSS variables for the app's names, each a reference to the library's variable, so a stylesheet written against\n * `var(--ink)` follows the library theme with no repaint code: `{ '--ink': 'var(--g9-text-primary)' }`.\n * `prefix` is prepended to the alias (G9Hub: `'g9-'` keeps its `--g9-surface-2`).\n */\nexport function aliasCssVariables(map: G9TokenAliasMap, prefix = ''): Readonly<Record<string, string>> {\n const out: Record<string, string> = {};\n for (const [name, target] of Object.entries(map)) {\n const variable = `--${prefix}${toKebabCase(name)}`.toLowerCase();\n // An alias that IS the library variable (G9Hub's `--g9-surface`) would point at itself: leave the library's own.\n if (isToken(target) && variable === cssVariableName(target)) continue;\n out[variable] = isToken(target) ? `var(${cssVariableName(target)})` : target;\n }\n return Object.freeze(out);\n}\n\n/** Ready-made alias maps for the four G9 apps' existing names (the migration guides start from these). */\nexport const g9AliasPresets = Object.freeze({\n /** G9SACManagement / G9Berjis `Tokens` keys. */\n berjis: {\n ground: 'Background',\n surface: 'Surface',\n sunken: 'SurfaceContainerHigh',\n ink: 'TextPrimary',\n ink2: 'TextSecondary',\n ink3: 'TextTertiary',\n onInk: 'InverseOnSurface',\n line: 'OutlineVariant',\n line2: 'Divider',\n primary: 'Primary',\n onPrimary: 'OnPrimary',\n primaryText: 'Primary',\n primaryWash: 'PrimaryContainer',\n accent: 'Tertiary',\n accentText: 'OnTertiaryContainer',\n positive: 'Success',\n positiveText: 'OnSuccessContainer',\n alert: 'Error',\n },\n /** G9Riskara `DARK`/`LIGHT` keys. */\n riskara: {\n bg: 'Background',\n surface: 'Surface',\n surface2: 'SurfaceContainer',\n line: 'OutlineVariant',\n line2: 'Divider',\n text: 'TextPrimary',\n text2: 'TextSecondary',\n muted: 'TextTertiary',\n primary: 'Primary',\n primarySoft: 'PrimaryContainer',\n primaryText: 'Primary',\n onPrimary: 'OnPrimary',\n pos: 'Success',\n neg: 'Error',\n warn: 'Warning',\n scrim: 'Scrim',\n },\n /** G9Hub tailwind colour names (`--g9-<name>`). */\n hub: {\n bg: 'Background',\n 'bg-elev': 'SurfaceContainerLow',\n surface: 'Surface',\n 'surface-2': 'SurfaceContainer',\n 'surface-3': 'SurfaceContainerHigh',\n border: 'OutlineVariant',\n 'border-strong': 'Outline',\n text: 'TextPrimary',\n 'text-2': 'TextSecondary',\n 'text-3': 'TextTertiary',\n accent: 'Primary',\n 'accent-contrast': 'OnPrimary',\n danger: 'Error',\n success: 'Success',\n warning: 'Warning',\n },\n} satisfies Record<string, G9TokenAliasMap>);\n"],"names":["isToken","v","g9ColorTokens","aliasPalette","palette","map","out","name","target","Object","aliasCssVariables","prefix","variable","toKebabCase","cssVariableName","g9AliasPresets"],"mappings":";;AASA,MAAMA,UAAU,CAACC,IAAkCC,cAAAA,QAA4C,CAACD;AAGzF,SAASE,aAAaC,OAAwB,EAAEC,GAAoB;IACzE,MAAMC,MAA8B,CAAC;IACrC,KAAK,MAAM,CAACC,MAAMC,OAAO,IAAIC,OAAO,OAAO,CAACJ,KAAMC,GAAG,CAACC,KAAK,GAAGP,QAAQQ,UAAUJ,OAAO,CAACI,OAAO,GAAGA;IAClG,OAAOC,OAAO,MAAM,CAACH;AACvB;AAOO,SAASI,kBAAkBL,GAAoB,EAAEM,SAAS,EAAE;IACjE,MAAML,MAA8B,CAAC;IACrC,KAAK,MAAM,CAACC,MAAMC,OAAO,IAAIC,OAAO,OAAO,CAACJ,KAAM;QAChD,MAAMO,WAAW,CAAC,EAAE,EAAED,SAASE,YAAYN,OAAO,CAAC,WAAW;QAE9D,IAAIP,CAAAA,QAAQQ,WAAWI,aAAaE,gBAAgBN,SACpDF,GAAG,CAACM,SAAS,GAAGZ,QAAQQ,UAAU,CAAC,IAAI,EAAEM,gBAAgBN,QAAQ,CAAC,CAAC,GAAGA;IACxE;IACA,OAAOC,OAAO,MAAM,CAACH;AACvB;AAGO,MAAMS,iBAAiBN,OAAO,MAAM,CAAC;IAE1C,QAAQ;QACN,QAAQ;QACR,SAAS;QACT,QAAQ;QACR,KAAK;QACL,MAAM;QACN,MAAM;QACN,OAAO;QACP,MAAM;QACN,OAAO;QACP,SAAS;QACT,WAAW;QACX,aAAa;QACb,aAAa;QACb,QAAQ;QACR,YAAY;QACZ,UAAU;QACV,cAAc;QACd,OAAO;IACT;IAEA,SAAS;QACP,IAAI;QACJ,SAAS;QACT,UAAU;QACV,MAAM;QACN,OAAO;QACP,MAAM;QACN,OAAO;QACP,OAAO;QACP,SAAS;QACT,aAAa;QACb,aAAa;QACb,WAAW;QACX,KAAK;QACL,KAAK;QACL,MAAM;QACN,OAAO;IACT;IAEA,KAAK;QACH,IAAI;QACJ,WAAW;QACX,SAAS;QACT,aAAa;QACb,aAAa;QACb,QAAQ;QACR,iBAAiB;QACjB,MAAM;QACN,UAAU;QACV,UAAU;QACV,QAAQ;QACR,mBAAmB;QACnB,QAAQ;QACR,SAAS;QACT,SAAS;IACX;AACF"}
@@ -0,0 +1,57 @@
1
+ import type { G9ColorToken } from '../tokens/generated/palettes.js';
2
+ import { type G9ShapeSet } from '../tokens/shape.js';
3
+ import type { G9BrandColors } from './brand.js';
4
+ import { type G9ColorScheme, type G9PaletteOverrides, type G9ResolvedTheme, type G9ThemeMode, type G9ThemeStore } from './theme.js';
5
+ /** Where a theme definition comes from: built in, the organisation's, or the person's own. */
6
+ export type G9ThemeSource = 'builtin' | 'org' | 'personal';
7
+ /** One selectable theme. */
8
+ export interface G9ThemeDefinition {
9
+ readonly id: string;
10
+ /** Display name, one string or per language. */
11
+ readonly name: string | Readonly<Record<string, string>>;
12
+ readonly source: G9ThemeSource;
13
+ readonly recipe: string;
14
+ readonly brand: G9BrandColors;
15
+ /** Designer overrides on top of the recipe, per scheme. */
16
+ readonly overrides?: {
17
+ readonly light?: G9PaletteOverrides;
18
+ readonly dark?: G9PaletteOverrides;
19
+ };
20
+ readonly shape?: Partial<G9ShapeSet>;
21
+ /** A mode this theme forces (`'dark'` for a night theme); otherwise the user's mode stays. */
22
+ readonly mode?: G9ThemeMode;
23
+ /** An app-defined wallpaper key. */
24
+ readonly wallpaper?: string;
25
+ }
26
+ /** Accent colours offered by "pick a colour" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. */
27
+ export declare const g9AccentPresets: ReadonlyArray<{
28
+ readonly id: string;
29
+ readonly color: string;
30
+ readonly name: Readonly<Record<string, string>>;
31
+ }>;
32
+ /**
33
+ * Paints `theme` into `store` (one notification): the recipe's palettes for its brand, the designer overrides layered
34
+ * per scheme, the forced mode if any. Returns the theme's resolved shape for the provider's CSS variables.
35
+ */
36
+ export declare function applyThemeDefinition(store: G9ThemeStore, theme: G9ThemeDefinition): G9ShapeSet;
37
+ /**
38
+ * A theme definition resolved for one scheme without touching any store: what `G9ThemePreviewCard` shows (a theme
39
+ * picker's cards, an editor's draft). Only the asked scheme's palette is built (palettes are cached by recipe and
40
+ * brand, so showing the same card again costs nothing).
41
+ */
42
+ export declare function previewThemeDefinition(theme: G9ThemeDefinition, scheme?: G9ColorScheme): G9ResolvedTheme;
43
+ /** A theme as portable JSON (personal themes, sharing, backup). */
44
+ export declare function exportTheme(theme: G9ThemeDefinition): string;
45
+ /**
46
+ * Reads exported JSON back, checking every colour and the shape's numbers; the result is always a personal theme with
47
+ * a fresh id when `newId` is given (an import never overwrites a built-in).
48
+ * @throws {G9Error} `theme-import` with the reason.
49
+ */
50
+ export declare function importTheme(json: string, newId?: string): G9ThemeDefinition;
51
+ /** The built-in themes over the built-in recipes, one per accent preset family. */
52
+ export declare const g9BuiltInThemes: readonly G9ThemeDefinition[];
53
+ /** A theme's display name in `language` (falls back to English, then any). */
54
+ export declare function themeName(theme: G9ThemeDefinition, language: string): string;
55
+ /** Tokens a theme overrides (for a "what is changed" list in a theme editor). */
56
+ export declare const overriddenTokens: (theme: G9ThemeDefinition) => readonly G9ColorToken[];
57
+ //# sourceMappingURL=appearance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../src/theme/appearance.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,SAAS,CAAC;AAEjB,8FAA8F;AAC9F,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC;AAE3D,4BAA4B;AAC5B,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;QAAC,QAAQ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
2
+ import { resolveShape } from "../tokens/shape.js";
3
+ import { tryParseColor } from "./color.js";
4
+ import { recipePalettes } from "./recipe.js";
5
+ import { lazyPalettes } from "./theme.js";
6
+ const g9AccentPresets = Object.freeze([
7
+ {
8
+ id: 'emerald',
9
+ color: '#349D57',
10
+ name: {
11
+ en: 'Emerald',
12
+ fa: 'زمردی'
13
+ }
14
+ },
15
+ {
16
+ id: 'teal',
17
+ color: '#01A890',
18
+ name: {
19
+ en: 'Teal',
20
+ fa: 'فیروزه‌ای'
21
+ }
22
+ },
23
+ {
24
+ id: 'ocean',
25
+ color: '#2B6FB3',
26
+ name: {
27
+ en: 'Ocean',
28
+ fa: 'اقیانوسی'
29
+ }
30
+ },
31
+ {
32
+ id: 'indigo',
33
+ color: '#4F55D8',
34
+ name: {
35
+ en: 'Indigo',
36
+ fa: 'نیلی'
37
+ }
38
+ },
39
+ {
40
+ id: 'violet',
41
+ color: '#7B5EA7',
42
+ name: {
43
+ en: 'Violet',
44
+ fa: 'بنفش'
45
+ }
46
+ },
47
+ {
48
+ id: 'rose',
49
+ color: '#D0457A',
50
+ name: {
51
+ en: 'Rose',
52
+ fa: 'گلی'
53
+ }
54
+ },
55
+ {
56
+ id: 'terracotta',
57
+ color: '#C2552D',
58
+ name: {
59
+ en: 'Terracotta',
60
+ fa: 'آجری'
61
+ }
62
+ },
63
+ {
64
+ id: 'amber',
65
+ color: '#B7791F',
66
+ name: {
67
+ en: 'Amber',
68
+ fa: 'کهربایی'
69
+ }
70
+ },
71
+ {
72
+ id: 'olive',
73
+ color: '#6B7A2A',
74
+ name: {
75
+ en: 'Olive',
76
+ fa: 'زیتونی'
77
+ }
78
+ },
79
+ {
80
+ id: 'slate',
81
+ color: '#4A5A6A',
82
+ name: {
83
+ en: 'Slate',
84
+ fa: 'سنگی'
85
+ }
86
+ },
87
+ {
88
+ id: 'graphite',
89
+ color: '#2F3437',
90
+ name: {
91
+ en: 'Graphite',
92
+ fa: 'گرافیتی'
93
+ }
94
+ },
95
+ {
96
+ id: 'saffron',
97
+ color: '#E0A100',
98
+ name: {
99
+ en: 'Saffron',
100
+ fa: 'زعفرانی'
101
+ }
102
+ }
103
+ ]);
104
+ function applyThemeDefinition(store, theme) {
105
+ const base = recipePalettes(theme.recipe, theme.brand);
106
+ const layer = (palette, over)=>over ? Object.freeze({
107
+ ...palette,
108
+ ...stripUndefined(over)
109
+ }) : palette;
110
+ store.beginBatch();
111
+ try {
112
+ store.setPalettes(lazyPalettes((scheme)=>{
113
+ var _theme_overrides;
114
+ return layer(base[scheme], null == (_theme_overrides = theme.overrides) ? void 0 : _theme_overrides[scheme]);
115
+ }));
116
+ if (theme.mode) store.setMode(theme.mode);
117
+ } finally{
118
+ store.endBatch();
119
+ }
120
+ return resolveShape(theme.shape);
121
+ }
122
+ function previewThemeDefinition(theme, scheme = 'light') {
123
+ var _theme_overrides;
124
+ const base = recipePalettes(theme.recipe, theme.brand)[scheme];
125
+ const over = null == (_theme_overrides = theme.overrides) ? void 0 : _theme_overrides[scheme];
126
+ const palette = over ? Object.freeze({
127
+ ...base,
128
+ ...stripUndefined(over)
129
+ }) : base;
130
+ return Object.freeze({
131
+ mode: scheme,
132
+ systemScheme: scheme,
133
+ scheme,
134
+ palette
135
+ });
136
+ }
137
+ function stripUndefined(o) {
138
+ const out = {};
139
+ for (const [k, v] of Object.entries(o))if (void 0 !== v) out[k] = v;
140
+ return out;
141
+ }
142
+ const FORMAT = 'g9-theme';
143
+ const VERSION = 1;
144
+ function exportTheme(theme) {
145
+ return JSON.stringify({
146
+ format: FORMAT,
147
+ version: VERSION,
148
+ theme: {
149
+ ...theme,
150
+ source: 'personal'
151
+ }
152
+ });
153
+ }
154
+ function importTheme(json, newId) {
155
+ var _ref, _ref1;
156
+ var _t_overrides, _t_overrides1, _t_shape;
157
+ let data;
158
+ try {
159
+ data = JSON.parse(json);
160
+ } catch {
161
+ throw new G9Error('theme-import', 'Not a theme file (not JSON).');
162
+ }
163
+ const d = data;
164
+ if ((null == d ? void 0 : d.format) !== FORMAT) throw new G9Error('theme-import', 'Not a G9 theme file.');
165
+ if ('number' != typeof d.version || d.version > VERSION) throw new G9Error('theme-import', `Theme file version ${String(d.version)} is newer than this app reads (${VERSION}).`);
166
+ const t = d.theme;
167
+ if (!t || 'string' != typeof t.id || 'string' != typeof t.recipe || !t.brand || 'object' != typeof t.brand) throw new G9Error('theme-import', 'The theme lacks an id, a recipe or a brand.');
168
+ const colours = [
169
+ ...Object.entries(t.brand),
170
+ ...Object.entries(null != (_ref = null == (_t_overrides = t.overrides) ? void 0 : _t_overrides.light) ? _ref : {}),
171
+ ...Object.entries(null != (_ref1 = null == (_t_overrides1 = t.overrides) ? void 0 : _t_overrides1.dark) ? _ref1 : {})
172
+ ];
173
+ for (const [key, value] of colours)if (void 0 !== value && ('string' != typeof value || !tryParseColor(value))) throw new G9Error('theme-import', `"${key}" is not a colour: ${JSON.stringify(value)}.`);
174
+ if (null == (_t_shape = t.shape) ? void 0 : _t_shape.radii) {
175
+ for (const [key, value] of Object.entries(t.shape.radii))if ('number' != typeof value || value < 0 || value > 999) throw new G9Error('theme-import', `Radius "${key}" is not a number 0–999.`);
176
+ }
177
+ return Object.freeze({
178
+ ...t,
179
+ id: null != newId ? newId : t.id,
180
+ source: 'personal'
181
+ });
182
+ }
183
+ const g9BuiltInThemes = Object.freeze([
184
+ {
185
+ id: 'classic',
186
+ name: {
187
+ en: 'Classic',
188
+ fa: 'کلاسیک'
189
+ },
190
+ source: 'builtin',
191
+ recipe: 'stock',
192
+ brand: {
193
+ primary: '#349D57'
194
+ }
195
+ },
196
+ {
197
+ id: 'tonal',
198
+ name: {
199
+ en: 'Tonal',
200
+ fa: 'هم‌رنگ'
201
+ },
202
+ source: 'builtin',
203
+ recipe: 'tonal',
204
+ brand: {
205
+ primary: '#2B6FB3'
206
+ }
207
+ },
208
+ {
209
+ id: 'calm',
210
+ name: {
211
+ en: 'Calm',
212
+ fa: 'آرام'
213
+ },
214
+ source: 'builtin',
215
+ recipe: 'neutral',
216
+ brand: {
217
+ primary: '#4A5A6A'
218
+ }
219
+ },
220
+ {
221
+ id: 'vivid',
222
+ name: {
223
+ en: 'Vivid',
224
+ fa: 'شاد'
225
+ },
226
+ source: 'builtin',
227
+ recipe: 'tinted',
228
+ brand: {
229
+ primary: '#D0457A'
230
+ }
231
+ },
232
+ {
233
+ id: 'midnight',
234
+ name: {
235
+ en: 'Midnight',
236
+ fa: 'نیمه‌شب'
237
+ },
238
+ source: 'builtin',
239
+ recipe: 'midnight',
240
+ brand: {
241
+ primary: '#01C6AC'
242
+ },
243
+ mode: 'dark'
244
+ },
245
+ {
246
+ id: 'accessible',
247
+ name: {
248
+ en: 'High contrast',
249
+ fa: 'کنتراست بالا'
250
+ },
251
+ source: 'builtin',
252
+ recipe: 'contrast',
253
+ brand: {
254
+ primary: '#1F5FA8'
255
+ }
256
+ }
257
+ ]);
258
+ function themeName(theme, language) {
259
+ var _ref, _ref1, _theme_name_language;
260
+ if ('string' == typeof theme.name) return theme.name;
261
+ return null != (_ref = null != (_ref1 = null != (_theme_name_language = theme.name[language]) ? _theme_name_language : theme.name.en) ? _ref1 : Object.values(theme.name)[0]) ? _ref : theme.id;
262
+ }
263
+ const overriddenTokens = (theme)=>{
264
+ var _ref, _ref1;
265
+ var _theme_overrides, _theme_overrides1;
266
+ return [
267
+ ...new Set([
268
+ ...Object.keys(null != (_ref = null == (_theme_overrides = theme.overrides) ? void 0 : _theme_overrides.light) ? _ref : {}),
269
+ ...Object.keys(null != (_ref1 = null == (_theme_overrides1 = theme.overrides) ? void 0 : _theme_overrides1.dark) ? _ref1 : {})
270
+ ])
271
+ ];
272
+ };
273
+ export { applyThemeDefinition, exportTheme, g9AccentPresets, g9BuiltInThemes, importTheme, overriddenTokens, previewThemeDefinition, themeName };
274
+
275
+ //# sourceMappingURL=appearance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme/appearance.js","sources":["../../src/theme/appearance.ts"],"sourcesContent":["// Appearance: the themes a person can pick (built-in, the organisation's, their own), each a recipe + brand + optional\n// designer overrides and shape, applied to the theme store in one batch. Personal themes travel as versioned JSON\n// (export / import, G9Hub's PersonalThemeSheet). Pure: the app persists the choice and the personal list.\nimport { G9Error } from '../errors';\nimport type { G9ColorToken } from '../tokens/generated/palettes';\nimport { type G9ShapeSet, resolveShape } from '../tokens/shape';\nimport type { G9BrandColors } from './brand';\nimport { tryParseColor } from './color';\nimport { recipePalettes } from './recipe';\nimport {\n type G9ColorScheme,\n type G9PaletteOverrides,\n type G9ResolvedTheme,\n type G9ThemeMode,\n type G9ThemeStore,\n lazyPalettes,\n} from './theme';\n\n/** Where a theme definition comes from: built in, the organisation's, or the person's own. */\nexport type G9ThemeSource = 'builtin' | 'org' | 'personal';\n\n/** One selectable theme. */\nexport interface G9ThemeDefinition {\n readonly id: string;\n /** Display name, one string or per language. */\n readonly name: string | Readonly<Record<string, string>>;\n readonly source: G9ThemeSource;\n readonly recipe: string;\n readonly brand: G9BrandColors;\n /** Designer overrides on top of the recipe, per scheme. */\n readonly overrides?: { readonly light?: G9PaletteOverrides; readonly dark?: G9PaletteOverrides };\n readonly shape?: Partial<G9ShapeSet>;\n /** A mode this theme forces (`'dark'` for a night theme); otherwise the user's mode stays. */\n readonly mode?: G9ThemeMode;\n /** An app-defined wallpaper key. */\n readonly wallpaper?: string;\n}\n\n/** Accent colours offered by \"pick a colour\" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. */\nexport const g9AccentPresets: ReadonlyArray<{\n readonly id: string;\n readonly color: string;\n readonly name: Readonly<Record<string, string>>;\n}> = Object.freeze([\n { id: 'emerald', color: '#349D57', name: { en: 'Emerald', fa: 'زمردی' } },\n { id: 'teal', color: '#01A890', name: { en: 'Teal', fa: 'فیروزه‌ای' } },\n { id: 'ocean', color: '#2B6FB3', name: { en: 'Ocean', fa: 'اقیانوسی' } },\n { id: 'indigo', color: '#4F55D8', name: { en: 'Indigo', fa: 'نیلی' } },\n { id: 'violet', color: '#7B5EA7', name: { en: 'Violet', fa: 'بنفش' } },\n { id: 'rose', color: '#D0457A', name: { en: 'Rose', fa: 'گلی' } },\n { id: 'terracotta', color: '#C2552D', name: { en: 'Terracotta', fa: 'آجری' } },\n { id: 'amber', color: '#B7791F', name: { en: 'Amber', fa: 'کهربایی' } },\n { id: 'olive', color: '#6B7A2A', name: { en: 'Olive', fa: 'زیتونی' } },\n { id: 'slate', color: '#4A5A6A', name: { en: 'Slate', fa: 'سنگی' } },\n { id: 'graphite', color: '#2F3437', name: { en: 'Graphite', fa: 'گرافیتی' } },\n { id: 'saffron', color: '#E0A100', name: { en: 'Saffron', fa: 'زعفرانی' } },\n]);\n\n/**\n * Paints `theme` into `store` (one notification): the recipe's palettes for its brand, the designer overrides layered\n * per scheme, the forced mode if any. Returns the theme's resolved shape for the provider's CSS variables.\n */\nexport function applyThemeDefinition(store: G9ThemeStore, theme: G9ThemeDefinition): G9ShapeSet {\n const base = recipePalettes(theme.recipe, theme.brand);\n const layer = (palette: typeof base.light, over?: G9PaletteOverrides) =>\n over ? (Object.freeze({ ...palette, ...stripUndefined(over) }) as typeof palette) : palette;\n store.beginBatch();\n try {\n // each scheme built when the store first paints it (the dark one waits for dark mode)\n store.setPalettes(lazyPalettes((scheme) => layer(base[scheme], theme.overrides?.[scheme])));\n if (theme.mode) store.setMode(theme.mode);\n } finally {\n store.endBatch();\n }\n return resolveShape(theme.shape);\n}\n\n/**\n * A theme definition resolved for one scheme without touching any store: what `G9ThemePreviewCard` shows (a theme\n * picker's cards, an editor's draft). Only the asked scheme's palette is built (palettes are cached by recipe and\n * brand, so showing the same card again costs nothing).\n */\nexport function previewThemeDefinition(theme: G9ThemeDefinition, scheme: G9ColorScheme = 'light'): G9ResolvedTheme {\n const base = recipePalettes(theme.recipe, theme.brand)[scheme];\n const over = theme.overrides?.[scheme];\n const palette = over ? (Object.freeze({ ...base, ...stripUndefined(over) }) as typeof base) : base;\n return Object.freeze({ mode: scheme, systemScheme: scheme, scheme, palette });\n}\n\nfunction stripUndefined(o: G9PaletteOverrides): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(o)) if (v !== undefined) out[k] = v;\n return out;\n}\n\nconst FORMAT = 'g9-theme';\nconst VERSION = 1;\n\n/** A theme as portable JSON (personal themes, sharing, backup). */\nexport function exportTheme(theme: G9ThemeDefinition): string {\n return JSON.stringify({ format: FORMAT, version: VERSION, theme: { ...theme, source: 'personal' } });\n}\n\n/**\n * Reads exported JSON back, checking every colour and the shape's numbers; the result is always a personal theme with\n * a fresh id when `newId` is given (an import never overwrites a built-in).\n * @throws {G9Error} `theme-import` with the reason.\n */\nexport function importTheme(json: string, newId?: string): G9ThemeDefinition {\n let data: unknown;\n try {\n data = JSON.parse(json);\n } catch {\n throw new G9Error('theme-import', 'Not a theme file (not JSON).');\n }\n const d = data as { format?: unknown; version?: unknown; theme?: Partial<G9ThemeDefinition> };\n if (d?.format !== FORMAT) throw new G9Error('theme-import', 'Not a G9 theme file.');\n if (typeof d.version !== 'number' || d.version > VERSION)\n throw new G9Error(\n 'theme-import',\n `Theme file version ${String(d.version)} is newer than this app reads (${VERSION}).`,\n );\n const t = d.theme;\n if (!t || typeof t.id !== 'string' || typeof t.recipe !== 'string' || !t.brand || typeof t.brand !== 'object') {\n throw new G9Error('theme-import', 'The theme lacks an id, a recipe or a brand.');\n }\n const colours: [string, unknown][] = [\n ...Object.entries(t.brand),\n ...Object.entries(t.overrides?.light ?? {}),\n ...Object.entries(t.overrides?.dark ?? {}),\n ];\n for (const [key, value] of colours) {\n if (value !== undefined && (typeof value !== 'string' || !tryParseColor(value))) {\n throw new G9Error('theme-import', `\"${key}\" is not a colour: ${JSON.stringify(value)}.`);\n }\n }\n if (t.shape?.radii) {\n for (const [key, value] of Object.entries(t.shape.radii)) {\n if (typeof value !== 'number' || value < 0 || value > 999)\n throw new G9Error('theme-import', `Radius \"${key}\" is not a number 0–999.`);\n }\n }\n return Object.freeze({ ...(t as G9ThemeDefinition), id: newId ?? t.id, source: 'personal' as const });\n}\n\n/** The built-in themes over the built-in recipes, one per accent preset family. */\nexport const g9BuiltInThemes: readonly G9ThemeDefinition[] = Object.freeze([\n {\n id: 'classic',\n name: { en: 'Classic', fa: 'کلاسیک' },\n source: 'builtin',\n recipe: 'stock',\n brand: { primary: '#349D57' },\n },\n {\n id: 'tonal',\n name: { en: 'Tonal', fa: 'هم‌رنگ' },\n source: 'builtin',\n recipe: 'tonal',\n brand: { primary: '#2B6FB3' },\n },\n { id: 'calm', name: { en: 'Calm', fa: 'آرام' }, source: 'builtin', recipe: 'neutral', brand: { primary: '#4A5A6A' } },\n { id: 'vivid', name: { en: 'Vivid', fa: 'شاد' }, source: 'builtin', recipe: 'tinted', brand: { primary: '#D0457A' } },\n {\n id: 'midnight',\n name: { en: 'Midnight', fa: 'نیمه‌شب' },\n source: 'builtin',\n recipe: 'midnight',\n brand: { primary: '#01C6AC' },\n mode: 'dark',\n },\n {\n id: 'accessible',\n name: { en: 'High contrast', fa: 'کنتراست بالا' },\n source: 'builtin',\n recipe: 'contrast',\n brand: { primary: '#1F5FA8' },\n },\n] satisfies G9ThemeDefinition[]);\n\n/** A theme's display name in `language` (falls back to English, then any). */\nexport function themeName(theme: G9ThemeDefinition, language: string): string {\n if (typeof theme.name === 'string') return theme.name;\n return theme.name[language] ?? theme.name.en ?? Object.values(theme.name)[0] ?? theme.id;\n}\n\n/** Tokens a theme overrides (for a \"what is changed\" list in a theme editor). */\nexport const overriddenTokens = (theme: G9ThemeDefinition): readonly G9ColorToken[] =>\n [\n ...new Set([...Object.keys(theme.overrides?.light ?? {}), ...Object.keys(theme.overrides?.dark ?? {})]),\n ] as G9ColorToken[];\n"],"names":["g9AccentPresets","Object","applyThemeDefinition","store","theme","base","recipePalettes","layer","palette","over","stripUndefined","lazyPalettes","scheme","_theme_overrides","resolveShape","previewThemeDefinition","o","out","k","v","undefined","FORMAT","VERSION","exportTheme","JSON","importTheme","json","newId","_t_overrides","_t_overrides1","_t_shape","data","G9Error","d","String","t","colours","key","value","tryParseColor","g9BuiltInThemes","themeName","language","_ref","overriddenTokens","_theme_overrides1","Set"],"mappings":";;;;;AAuCO,MAAMA,kBAIRC,OAAO,MAAM,CAAC;IACjB;QAAE,IAAI;QAAW,OAAO;QAAW,MAAM;YAAE,IAAI;YAAW,IAAI;QAAQ;IAAE;IACxE;QAAE,IAAI;QAAQ,OAAO;QAAW,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAY;IAAE;IACtE;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAW;IAAE;IACvE;QAAE,IAAI;QAAU,OAAO;QAAW,MAAM;YAAE,IAAI;YAAU,IAAI;QAAO;IAAE;IACrE;QAAE,IAAI;QAAU,OAAO;QAAW,MAAM;YAAE,IAAI;YAAU,IAAI;QAAO;IAAE;IACrE;QAAE,IAAI;QAAQ,OAAO;QAAW,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAM;IAAE;IAChE;QAAE,IAAI;QAAc,OAAO;QAAW,MAAM;YAAE,IAAI;YAAc,IAAI;QAAO;IAAE;IAC7E;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAU;IAAE;IACtE;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAS;IAAE;IACrE;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAO;IAAE;IACnE;QAAE,IAAI;QAAY,OAAO;QAAW,MAAM;YAAE,IAAI;YAAY,IAAI;QAAU;IAAE;IAC5E;QAAE,IAAI;QAAW,OAAO;QAAW,MAAM;YAAE,IAAI;YAAW,IAAI;QAAU;IAAE;CAC3E;AAMM,SAASC,qBAAqBC,KAAmB,EAAEC,KAAwB;IAChF,MAAMC,OAAOC,eAAeF,MAAM,MAAM,EAAEA,MAAM,KAAK;IACrD,MAAMG,QAAQ,CAACC,SAA4BC,OACzCA,OAAQ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M;YAAE,IAAI;YAAiB,IAAI;QAAe;QAChD,QAAQ;QACR,QAAQ;QACR,OAAO;YAAE,SAAS;QAAU;IAC9B;CACD;AAGM,SAASwC,UAAUrC,KAAwB,EAAEsC,QAAgB;QAE3DC,MAAAA,OAAAA;IADP,IAAI,AAAsB,YAAtB,OAAOvC,MAAM,IAAI,EAAe,OAAOA,MAAM,IAAI;IACrD,OAAO,QAAAuC,CAAAA,OAAAA,QAAAA,CAAAA,QAAAA,QAAAA,CAAAA,uBAAAA,MAAM,IAAI,CAACD,SAAS,AAAD,IAAnBC,uBAAwBvC,MAAM,IAAI,CAAC,EAAE,AAAD,IAApCuC,QAAyC1C,OAAO,MAAM,CAACG,MAAM,IAAI,CAAC,CAAC,EAAE,AAAD,IAApEuC,OAAyEvC,MAAM,EAAE;AAC1F;AAGO,MAAMwC,mBAAmB,CAACxC;;QAEFS,kBAA8CgC;WAD3E;WACK,IAAIC,IAAI;eAAI7C,OAAO,IAAI,CAAC,QAAD,gBAACY,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,KAAAA,IAAAA,iBAAiB,KAAK,AAAD,IAAC,OAAI,CAAC;eAAOZ,OAAO,IAAI,CAAC,QAAD,iBAAC4C,CAAAA,oBAAAA,MAAM,SAAS,AAAD,IAAdA,KAAAA,IAAAA,kBAAiB,IAAI,AAAD,IAAC,QAAI,CAAC;SAAG;KACvG"}
@@ -0,0 +1,40 @@
1
+ import type { G9PaletteValues } from '../tokens/generated/palettes.js';
2
+ import { type G9ColorInput } from './color.js';
3
+ import type { G9ColorScheme } from './theme.js';
4
+ /** The colours a brand gives. Only `primary` is required; the rest are derived when missing. */
5
+ export interface G9BrandColors {
6
+ readonly primary: G9ColorInput;
7
+ readonly secondary?: G9ColorInput;
8
+ readonly tertiary?: G9ColorInput;
9
+ readonly quaternary?: G9ColorInput;
10
+ /** Status colours; derived from fixed hues tuned to the brand's chroma when missing. */
11
+ readonly error?: G9ColorInput;
12
+ readonly warning?: G9ColorInput;
13
+ readonly success?: G9ColorInput;
14
+ readonly info?: G9ColorInput;
15
+ /** The grey's hue source (default: primary). */
16
+ readonly neutral?: G9ColorInput;
17
+ }
18
+ /** How {@link createBrandPalette} builds a palette from a brand colour: grey tint, contrast target and whether the brand colour is kept as is. */
19
+ export interface G9BrandPaletteOptions {
20
+ /** How much of the brand hue the greys carry, 0 (pure grey) … 1. Default 0.35. */
21
+ readonly tint?: number;
22
+ /** Minimum contrast for text on its fill: `'AA'` 4.5 (default) or `'AAA'` 7. */
23
+ readonly contrast?: 'AA' | 'AAA';
24
+ /**
25
+ * Keep the brand colour itself as `Primary` (default true): the fill is the exact brand colour and its `On` colour is
26
+ * chosen for contrast. False lets the generator move the fill too when neither black nor white reaches the contrast.
27
+ */
28
+ readonly keepBrand?: boolean;
29
+ }
30
+ /**
31
+ * The full palette for `scheme`. Pure and deterministic: the same brand gives the same palette everywhere (app, web,
32
+ * server-side previews), so it can be computed at build time or on the device.
33
+ */
34
+ export declare function createBrandPalette(brand: G9BrandColors, scheme: G9ColorScheme, options?: G9BrandPaletteOptions): G9PaletteValues;
35
+ /** Both schemes at once (what a theme store's `palettes` option takes). */
36
+ export declare function createBrandPalettes(brand: G9BrandColors, options?: G9BrandPaletteOptions): {
37
+ light: G9PaletteValues;
38
+ dark: G9PaletteValues;
39
+ };
40
+ //# sourceMappingURL=brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/theme/brand.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAe,KAAK,YAAY,EAAoC,MAAM,SAAS,CAAC;AAE3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY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