@wordpress/theme 0.1.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 (168) hide show
  1. package/LICENSE.md +788 -0
  2. package/README.md +67 -0
  3. package/bin/build-tokens.js +83 -0
  4. package/bin/generate-primitive-tokens/index.ts +115 -0
  5. package/bin/terrazzo-plugin-ds-tokens-docs/index.ts +103 -0
  6. package/bin/terrazzo-plugin-figma-ds-token-manager/index.ts +210 -0
  7. package/bin/terrazzo-plugin-figma-ds-token-manager/lib.ts +1 -0
  8. package/bin/terrazzo-plugin-known-wpds-css-variables/index.ts +72 -0
  9. package/build/color-ramps/index.js +132 -0
  10. package/build/color-ramps/index.js.map +7 -0
  11. package/build/color-ramps/lib/cache-utils.js +57 -0
  12. package/build/color-ramps/lib/cache-utils.js.map +7 -0
  13. package/build/color-ramps/lib/constants.js +105 -0
  14. package/build/color-ramps/lib/constants.js.map +7 -0
  15. package/build/color-ramps/lib/find-color-with-constraints.js +141 -0
  16. package/build/color-ramps/lib/find-color-with-constraints.js.map +7 -0
  17. package/build/color-ramps/lib/index.js +264 -0
  18. package/build/color-ramps/lib/index.js.map +7 -0
  19. package/build/color-ramps/lib/ramp-configs.js +315 -0
  20. package/build/color-ramps/lib/ramp-configs.js.map +7 -0
  21. package/build/color-ramps/lib/taper-chroma.js +159 -0
  22. package/build/color-ramps/lib/taper-chroma.js.map +7 -0
  23. package/build/color-ramps/lib/types.js +17 -0
  24. package/build/color-ramps/lib/types.js.map +7 -0
  25. package/build/color-ramps/lib/utils.js +106 -0
  26. package/build/color-ramps/lib/utils.js.map +7 -0
  27. package/build/context.js +34 -0
  28. package/build/context.js.map +7 -0
  29. package/build/index.js +29 -0
  30. package/build/index.js.map +7 -0
  31. package/build/lock-unlock.js +35 -0
  32. package/build/lock-unlock.js.map +7 -0
  33. package/build/prebuilt/js/design-tokens.js +135 -0
  34. package/build/prebuilt/js/design-tokens.js.map +7 -0
  35. package/build/prebuilt/json/figma.json +1317 -0
  36. package/build/prebuilt/ts/design-tokens.js +354 -0
  37. package/build/prebuilt/ts/design-tokens.js.map +7 -0
  38. package/build/private-apis.js +36 -0
  39. package/build/private-apis.js.map +7 -0
  40. package/build/style.module.css.js +2 -0
  41. package/build/theme-provider.js +92 -0
  42. package/build/theme-provider.js.map +7 -0
  43. package/build/types/css-modules.d.js +2 -0
  44. package/build/types/css-modules.d.js.map +7 -0
  45. package/build/types.js +17 -0
  46. package/build/types.js.map +7 -0
  47. package/build/use-theme-provider-styles.js +230 -0
  48. package/build/use-theme-provider-styles.js.map +7 -0
  49. package/build-module/color-ramps/index.js +95 -0
  50. package/build-module/color-ramps/index.js.map +7 -0
  51. package/build-module/color-ramps/lib/cache-utils.js +31 -0
  52. package/build-module/color-ramps/lib/cache-utils.js.map +7 -0
  53. package/build-module/color-ramps/lib/constants.js +63 -0
  54. package/build-module/color-ramps/lib/constants.js.map +7 -0
  55. package/build-module/color-ramps/lib/find-color-with-constraints.js +112 -0
  56. package/build-module/color-ramps/lib/find-color-with-constraints.js.map +7 -0
  57. package/build-module/color-ramps/lib/index.js +235 -0
  58. package/build-module/color-ramps/lib/index.js.map +7 -0
  59. package/build-module/color-ramps/lib/ramp-configs.js +290 -0
  60. package/build-module/color-ramps/lib/ramp-configs.js.map +7 -0
  61. package/build-module/color-ramps/lib/taper-chroma.js +125 -0
  62. package/build-module/color-ramps/lib/taper-chroma.js.map +7 -0
  63. package/build-module/color-ramps/lib/types.js +1 -0
  64. package/build-module/color-ramps/lib/types.js.map +7 -0
  65. package/build-module/color-ramps/lib/utils.js +84 -0
  66. package/build-module/color-ramps/lib/utils.js.map +7 -0
  67. package/build-module/context.js +10 -0
  68. package/build-module/context.js.map +7 -0
  69. package/build-module/index.js +5 -0
  70. package/build-module/index.js.map +7 -0
  71. package/build-module/lock-unlock.js +10 -0
  72. package/build-module/lock-unlock.js.map +7 -0
  73. package/build-module/prebuilt/js/design-tokens.js +115 -0
  74. package/build-module/prebuilt/js/design-tokens.js.map +7 -0
  75. package/build-module/prebuilt/json/figma.json +1317 -0
  76. package/build-module/prebuilt/ts/design-tokens.js +334 -0
  77. package/build-module/prebuilt/ts/design-tokens.js.map +7 -0
  78. package/build-module/private-apis.js +12 -0
  79. package/build-module/private-apis.js.map +7 -0
  80. package/build-module/style.module.css.js +1 -0
  81. package/build-module/theme-provider.js +58 -0
  82. package/build-module/theme-provider.js.map +7 -0
  83. package/build-module/types/css-modules.d.js +1 -0
  84. package/build-module/types/css-modules.d.js.map +7 -0
  85. package/build-module/types.js +1 -0
  86. package/build-module/types.js.map +7 -0
  87. package/build-module/use-theme-provider-styles.js +200 -0
  88. package/build-module/use-theme-provider-styles.js.map +7 -0
  89. package/build-style/style.css +3 -0
  90. package/build-types/color-ramps/index.d.ts +44 -0
  91. package/build-types/color-ramps/index.d.ts.map +1 -0
  92. package/build-types/color-ramps/lib/cache-utils.d.ts +22 -0
  93. package/build-types/color-ramps/lib/cache-utils.d.ts.map +1 -0
  94. package/build-types/color-ramps/lib/constants.d.ts +38 -0
  95. package/build-types/color-ramps/lib/constants.d.ts.map +1 -0
  96. package/build-types/color-ramps/lib/find-color-with-constraints.d.ts +37 -0
  97. package/build-types/color-ramps/lib/find-color-with-constraints.d.ts.map +1 -0
  98. package/build-types/color-ramps/lib/index.d.ts +11 -0
  99. package/build-types/color-ramps/lib/index.d.ts.map +1 -0
  100. package/build-types/color-ramps/lib/ramp-configs.d.ts +7 -0
  101. package/build-types/color-ramps/lib/ramp-configs.d.ts.map +1 -0
  102. package/build-types/color-ramps/lib/taper-chroma.d.ts +32 -0
  103. package/build-types/color-ramps/lib/taper-chroma.d.ts.map +1 -0
  104. package/build-types/color-ramps/lib/types.d.ts +78 -0
  105. package/build-types/color-ramps/lib/types.d.ts.map +1 -0
  106. package/build-types/color-ramps/lib/utils.d.ts +38 -0
  107. package/build-types/color-ramps/lib/utils.d.ts.map +1 -0
  108. package/build-types/color-ramps/stories/index.story.d.ts +14 -0
  109. package/build-types/color-ramps/stories/index.story.d.ts.map +1 -0
  110. package/build-types/color-ramps/stories/ramp-table.d.ts +19 -0
  111. package/build-types/color-ramps/stories/ramp-table.d.ts.map +1 -0
  112. package/build-types/context.d.ts +10 -0
  113. package/build-types/context.d.ts.map +1 -0
  114. package/build-types/index.d.ts +2 -0
  115. package/build-types/index.d.ts.map +1 -0
  116. package/build-types/lock-unlock.d.ts +2 -0
  117. package/build-types/lock-unlock.d.ts.map +1 -0
  118. package/build-types/prebuilt/js/design-tokens.d.ts +3 -0
  119. package/build-types/prebuilt/js/design-tokens.d.ts.map +1 -0
  120. package/build-types/prebuilt/ts/design-tokens.d.ts +7 -0
  121. package/build-types/prebuilt/ts/design-tokens.d.ts.map +1 -0
  122. package/build-types/private-apis.d.ts +2 -0
  123. package/build-types/private-apis.d.ts.map +1 -0
  124. package/build-types/stories/index.story.d.ts +15 -0
  125. package/build-types/stories/index.story.d.ts.map +1 -0
  126. package/build-types/theme-provider.d.ts +3 -0
  127. package/build-types/theme-provider.d.ts.map +1 -0
  128. package/build-types/types.d.ts +42 -0
  129. package/build-types/types.d.ts.map +1 -0
  130. package/build-types/use-theme-provider-styles.d.ts +17 -0
  131. package/build-types/use-theme-provider-styles.d.ts.map +1 -0
  132. package/docs/ds-tokens.md +283 -0
  133. package/package.json +58 -0
  134. package/src/color-ramps/index.ts +155 -0
  135. package/src/color-ramps/lib/cache-utils.ts +56 -0
  136. package/src/color-ramps/lib/constants.ts +85 -0
  137. package/src/color-ramps/lib/find-color-with-constraints.ts +190 -0
  138. package/src/color-ramps/lib/index.ts +369 -0
  139. package/src/color-ramps/lib/ramp-configs.ts +309 -0
  140. package/src/color-ramps/lib/taper-chroma.ts +226 -0
  141. package/src/color-ramps/lib/types.ts +90 -0
  142. package/src/color-ramps/lib/utils.ts +161 -0
  143. package/src/color-ramps/stories/index.story.tsx +264 -0
  144. package/src/color-ramps/stories/ramp-table.tsx +212 -0
  145. package/src/color-ramps/test/__snapshots__/index.test.ts.snap +1280 -0
  146. package/src/color-ramps/test/index.test.ts +94 -0
  147. package/src/context.ts +19 -0
  148. package/src/index.ts +2 -0
  149. package/src/lock-unlock.ts +10 -0
  150. package/src/prebuilt/css/design-tokens.css +401 -0
  151. package/src/prebuilt/js/design-tokens.js +116 -0
  152. package/src/prebuilt/json/figma.json +1317 -0
  153. package/src/prebuilt/ts/design-tokens.ts +335 -0
  154. package/src/private-apis.ts +12 -0
  155. package/src/stories/index.story.tsx +426 -0
  156. package/src/style.module.css +3 -0
  157. package/src/theme-provider.tsx +87 -0
  158. package/src/types/css-modules.d.ts +4 -0
  159. package/src/types.ts +44 -0
  160. package/src/use-theme-provider-styles.ts +247 -0
  161. package/terrazzo.config.ts +102 -0
  162. package/tokens/border.json +34 -0
  163. package/tokens/color.json +877 -0
  164. package/tokens/elevation.json +201 -0
  165. package/tokens/spacing.json +45 -0
  166. package/tokens/typography.json +93 -0
  167. package/tsconfig.json +9 -0
  168. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,200 @@
1
+ import Color from "colorjs.io";
2
+ import { useMemo, useContext } from "@wordpress/element";
3
+ import { ThemeContext } from "./context";
4
+ import semanticVariables from "./prebuilt/ts/design-tokens";
5
+ import {
6
+ buildBgRamp,
7
+ buildAccentRamp,
8
+ DEFAULT_SEED_COLORS
9
+ } from "./color-ramps";
10
+ const legacyWpComponentsOverridesCSS = [
11
+ ["--wp-components-color-accent", "var(--wp-admin-theme-color)"],
12
+ [
13
+ "--wp-components-color-accent-darker-10",
14
+ "var(--wp-admin-theme-color-darker-10)"
15
+ ],
16
+ [
17
+ "--wp-components-color-accent-darker-20",
18
+ "var(--wp-admin-theme-color-darker-20)"
19
+ ],
20
+ [
21
+ "--wp-components-color-accent-inverted",
22
+ "var(--wpds-color-fg-interactive-brand-strong)"
23
+ ],
24
+ [
25
+ "--wp-components-color-background",
26
+ "var(--wpds-color-bg-surface-neutral-strong)"
27
+ ],
28
+ [
29
+ "--wp-components-color-foreground",
30
+ "var(--wpds-color-fg-content-neutral)"
31
+ ],
32
+ [
33
+ "--wp-components-color-foreground-inverted",
34
+ "var(--wpds-color-bg-surface-neutral)"
35
+ ],
36
+ [
37
+ "--wp-components-color-gray-100",
38
+ "var(--wpds-color-bg-surface-neutral)"
39
+ ],
40
+ [
41
+ "--wp-components-color-gray-200",
42
+ "var(--wpds-color-stroke-surface-neutral)"
43
+ ],
44
+ [
45
+ "--wp-components-color-gray-300",
46
+ "var(--wpds-color-stroke-surface-neutral)"
47
+ ],
48
+ [
49
+ "--wp-components-color-gray-400",
50
+ "var(--wpds-color-stroke-interactive-neutral)"
51
+ ],
52
+ [
53
+ "--wp-components-color-gray-600",
54
+ "var(--wpds-color-stroke-interactive-neutral)"
55
+ ],
56
+ [
57
+ "--wp-components-color-gray-700",
58
+ "var(--wpds-color-fg-content-neutral-weak)"
59
+ ],
60
+ [
61
+ "--wp-components-color-gray-800",
62
+ "var(--wpds-color-fg-content-neutral)"
63
+ ]
64
+ ];
65
+ function customRgbFormat(color) {
66
+ const rgb = color.to("srgb");
67
+ return [rgb.r, rgb.g, rgb.b].map((n) => Math.round(n * 255)).join(", ");
68
+ }
69
+ function legacyWpAdminThemeOverridesCSS(accent) {
70
+ const parsedAccent = new Color(accent).to("hsl");
71
+ const hsl = parsedAccent.coords;
72
+ const darker10 = new Color("hsl", [
73
+ hsl[0],
74
+ // h
75
+ hsl[1],
76
+ // s
77
+ Math.max(0, Math.min(100, hsl[2] - 5))
78
+ // l (reduced by 5%)
79
+ ]).to("srgb");
80
+ const darker20 = new Color("hsl", [
81
+ hsl[0],
82
+ // h
83
+ hsl[1],
84
+ // s
85
+ Math.max(0, Math.min(100, hsl[2] - 10))
86
+ // l (reduced by 10%)
87
+ ]).to("srgb");
88
+ return [
89
+ [
90
+ "--wp-admin-theme-color",
91
+ parsedAccent.to("srgb").toString({ format: "hex" })
92
+ ],
93
+ ["--wp-admin-theme-color--rgb", customRgbFormat(parsedAccent)],
94
+ [
95
+ "--wp-admin-theme-color-darker-10",
96
+ darker10.toString({ format: "hex" })
97
+ ],
98
+ [
99
+ "--wp-admin-theme-color-darker-10--rgb",
100
+ customRgbFormat(darker10)
101
+ ],
102
+ [
103
+ "--wp-admin-theme-color-darker-20",
104
+ darker20.toString({ format: "hex" })
105
+ ],
106
+ [
107
+ "--wp-admin-theme-color-darker-20--rgb",
108
+ customRgbFormat(darker20)
109
+ ]
110
+ ];
111
+ }
112
+ function semanticTokensCSS(filterFn = () => true) {
113
+ return Object.entries(semanticVariables).filter(filterFn).map(([variableName, modesAndValues]) => [
114
+ variableName,
115
+ modesAndValues["."]
116
+ ]);
117
+ }
118
+ const toKebabCase = (str) => str.replace(
119
+ /[A-Z]+(?![a-z])|[A-Z]/g,
120
+ ($, ofs) => (ofs ? "-" : "") + $.toLowerCase()
121
+ );
122
+ function colorRampCSS(ramp, prefix) {
123
+ return [...Object.entries(ramp.ramp)].map(
124
+ ([tokenName, tokenValue]) => [
125
+ `${prefix}${toKebabCase(tokenName)}`,
126
+ tokenValue.color
127
+ ]
128
+ );
129
+ }
130
+ function generateStyles({
131
+ primary,
132
+ computedColorRamps
133
+ }) {
134
+ return Object.fromEntries(
135
+ [
136
+ // Primitive tokens
137
+ Array.from(computedColorRamps).map(([rampName, computedColorRamp]) => [
138
+ colorRampCSS(
139
+ computedColorRamp,
140
+ `--wpds-color-private-${rampName}-`
141
+ )
142
+ ]).flat(2),
143
+ // Semantic color tokens (other semantic tokens for now are static)
144
+ semanticTokensCSS(([key]) => /color/.test(key)),
145
+ // Legacy overrides
146
+ legacyWpAdminThemeOverridesCSS(primary),
147
+ legacyWpComponentsOverridesCSS
148
+ ].flat()
149
+ );
150
+ }
151
+ function useThemeProviderStyles({
152
+ color = {}
153
+ } = {}) {
154
+ const { resolvedSettings: inheritedSettings } = useContext(ThemeContext);
155
+ const primary = color.primary ?? inheritedSettings.color?.primary ?? DEFAULT_SEED_COLORS.primary;
156
+ const bg = color.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;
157
+ const resolvedSettings = useMemo(
158
+ () => ({
159
+ color: {
160
+ primary,
161
+ bg
162
+ }
163
+ }),
164
+ [primary, bg]
165
+ );
166
+ const themeProviderStyles = useMemo(() => {
167
+ const seeds = {
168
+ ...DEFAULT_SEED_COLORS,
169
+ bg,
170
+ primary
171
+ };
172
+ const computedColorRamps = /* @__PURE__ */ new Map();
173
+ const bgRamp = buildBgRamp({ seed: seeds.bg });
174
+ Object.entries(seeds).forEach(([rampName, seed]) => {
175
+ if (rampName === "bg") {
176
+ computedColorRamps.set(rampName, bgRamp);
177
+ } else {
178
+ computedColorRamps.set(
179
+ rampName,
180
+ buildAccentRamp({
181
+ seed,
182
+ bgRamp
183
+ })
184
+ );
185
+ }
186
+ });
187
+ return generateStyles({
188
+ primary: seeds.primary,
189
+ computedColorRamps
190
+ });
191
+ }, [primary, bg]);
192
+ return {
193
+ resolvedSettings,
194
+ themeProviderStyles
195
+ };
196
+ }
197
+ export {
198
+ useThemeProviderStyles
199
+ };
200
+ //# sourceMappingURL=use-theme-provider-styles.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/use-theme-provider-styles.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport Color from 'colorjs.io';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ThemeContext } from './context';\nimport semanticVariables from './prebuilt/ts/design-tokens';\nimport {\n\tbuildBgRamp,\n\tbuildAccentRamp,\n\tDEFAULT_SEED_COLORS,\n\ttype RampResult,\n} from './color-ramps';\nimport type { ThemeProviderProps } from './types';\n\ntype Entry = [ string, string ];\n\nconst legacyWpComponentsOverridesCSS: Entry[] = [\n\t[ '--wp-components-color-accent', 'var(--wp-admin-theme-color)' ],\n\t[\n\t\t'--wp-components-color-accent-darker-10',\n\t\t'var(--wp-admin-theme-color-darker-10)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-darker-20',\n\t\t'var(--wp-admin-theme-color-darker-20)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-inverted',\n\t\t'var(--wpds-color-fg-interactive-brand-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-background',\n\t\t'var(--wpds-color-bg-surface-neutral-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground-inverted',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-100',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-200',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-300',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-400',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-600',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-700',\n\t\t'var(--wpds-color-fg-content-neutral-weak)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-800',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n];\n\nfunction customRgbFormat( color: Color ) {\n\tconst rgb = color.to( 'srgb' );\n\treturn [ rgb.r, rgb.g, rgb.b ]\n\t\t.map( ( n ) => Math.round( n * 255 ) )\n\t\t.join( ', ' );\n}\n\nfunction legacyWpAdminThemeOverridesCSS( accent: string ): Entry[] {\n\tconst parsedAccent = new Color( accent ).to( 'hsl' );\n\n\tconst hsl = parsedAccent.coords;\n\tconst darker10 = new Color( 'hsl', [\n\t\thsl[ 0 ], // h\n\t\thsl[ 1 ], // s\n\t\tMath.max( 0, Math.min( 100, hsl[ 2 ] - 5 ) ), // l (reduced by 5%)\n\t] ).to( 'srgb' );\n\tconst darker20 = new Color( 'hsl', [\n\t\thsl[ 0 ], // h\n\t\thsl[ 1 ], // s\n\t\tMath.max( 0, Math.min( 100, hsl[ 2 ] - 10 ) ), // l (reduced by 10%)\n\t] ).to( 'srgb' );\n\n\treturn [\n\t\t[\n\t\t\t'--wp-admin-theme-color',\n\t\t\tparsedAccent.to( 'srgb' ).toString( { format: 'hex' } ),\n\t\t],\n\t\t[ '--wp-admin-theme-color--rgb', customRgbFormat( parsedAccent ) ],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10',\n\t\t\tdarker10.toString( { format: 'hex' } ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10--rgb',\n\t\t\tcustomRgbFormat( darker10 ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20',\n\t\t\tdarker20.toString( { format: 'hex' } ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20--rgb',\n\t\t\tcustomRgbFormat( darker20 ),\n\t\t],\n\t];\n}\n\nfunction semanticTokensCSS(\n\tfilterFn: ( entry: [ string, Record< string, string > ] ) => boolean = () =>\n\t\ttrue\n): Entry[] {\n\treturn Object.entries( semanticVariables )\n\t\t.filter( filterFn )\n\t\t.map( ( [ variableName, modesAndValues ] ) => [\n\t\t\tvariableName,\n\t\t\tmodesAndValues[ '.' ],\n\t\t] );\n}\n\nconst toKebabCase = ( str: string ) =>\n\tstr.replace(\n\t\t/[A-Z]+(?![a-z])|[A-Z]/g,\n\t\t( $, ofs ) => ( ofs ? '-' : '' ) + $.toLowerCase()\n\t);\n\nfunction colorRampCSS( ramp: RampResult, prefix: string ): Entry[] {\n\treturn [ ...Object.entries( ramp.ramp ) ].map(\n\t\t( [ tokenName, tokenValue ] ) => [\n\t\t\t`${ prefix }${ toKebabCase( tokenName ) }`,\n\t\t\ttokenValue.color,\n\t\t]\n\t);\n}\n\nfunction generateStyles( {\n\tprimary,\n\tcomputedColorRamps,\n}: {\n\tprimary: string;\n\tcomputedColorRamps: Map< string, RampResult >;\n} ): CSSProperties {\n\treturn Object.fromEntries(\n\t\t[\n\t\t\t// Primitive tokens\n\t\t\tArray.from( computedColorRamps )\n\t\t\t\t.map( ( [ rampName, computedColorRamp ] ) => [\n\t\t\t\t\tcolorRampCSS(\n\t\t\t\t\t\tcomputedColorRamp,\n\t\t\t\t\t\t`--wpds-color-private-${ rampName }-`\n\t\t\t\t\t),\n\t\t\t\t] )\n\t\t\t\t.flat( 2 ),\n\t\t\t// Semantic color tokens (other semantic tokens for now are static)\n\t\t\tsemanticTokensCSS( ( [ key ] ) => /color/.test( key ) ),\n\t\t\t// Legacy overrides\n\t\t\tlegacyWpAdminThemeOverridesCSS( primary ),\n\t\t\tlegacyWpComponentsOverridesCSS,\n\t\t].flat()\n\t);\n}\n\nexport function useThemeProviderStyles( {\n\tcolor = {},\n}: {\n\tcolor?: ThemeProviderProps[ 'color' ];\n} = {} ) {\n\tconst { resolvedSettings: inheritedSettings } = useContext( ThemeContext );\n\n\t// Compute settings:\n\t// - used provided prop value;\n\t// - otherwise, use inherited value from parent instance;\n\t// - otherwise, use fallback value (where applicable).\n\tconst primary =\n\t\tcolor.primary ??\n\t\tinheritedSettings.color?.primary ??\n\t\tDEFAULT_SEED_COLORS.primary;\n\tconst bg =\n\t\tcolor.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;\n\n\tconst resolvedSettings = useMemo(\n\t\t() => ( {\n\t\t\tcolor: {\n\t\t\t\tprimary,\n\t\t\t\tbg,\n\t\t\t},\n\t\t} ),\n\t\t[ primary, bg ]\n\t);\n\n\tconst themeProviderStyles = useMemo( () => {\n\t\t// Determine which seeds are needed for generating ramps.\n\t\tconst seeds = {\n\t\t\t...DEFAULT_SEED_COLORS,\n\t\t\tbg,\n\t\t\tprimary,\n\t\t};\n\n\t\t// Generate ramps.\n\t\tconst computedColorRamps = new Map< string, RampResult >();\n\t\tconst bgRamp = buildBgRamp( { seed: seeds.bg } );\n\t\tObject.entries( seeds ).forEach( ( [ rampName, seed ] ) => {\n\t\t\tif ( rampName === 'bg' ) {\n\t\t\t\tcomputedColorRamps.set( rampName, bgRamp );\n\t\t\t} else {\n\t\t\t\tcomputedColorRamps.set(\n\t\t\t\t\trampName,\n\t\t\t\t\tbuildAccentRamp( {\n\t\t\t\t\t\tseed,\n\t\t\t\t\t\tbgRamp,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn generateStyles( {\n\t\t\tprimary: seeds.primary,\n\t\t\tcomputedColorRamps,\n\t\t} );\n\t}, [ primary, bg ] );\n\n\treturn {\n\t\tresolvedSettings,\n\t\tthemeProviderStyles,\n\t};\n}\n"],
5
+ "mappings": "AAIA,OAAO,WAAW;AAKlB,SAAS,SAAS,kBAAkB;AAKpC,SAAS,oBAAoB;AAC7B,OAAO,uBAAuB;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AAKP,MAAM,iCAA0C;AAAA,EAC/C,CAAE,gCAAgC,6BAA8B;AAAA,EAChE;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AACD;AAEA,SAAS,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IACD;AAAA,IACA,CAAE,SAAS,EAAG;AAAA,EACf;AAEA,QAAM,sBAAsB,QAAS,MAAM;AAE1C,UAAM,QAAQ;AAAA,MACb,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACD;AAGA,UAAM,qBAAqB,oBAAI,IAA0B;AACzD,UAAM,SAAS,YAAa,EAAE,MAAM,MAAM,GAAG,CAAE;AAC/C,WAAO,QAAS,KAAM,EAAE,QAAS,CAAE,CAAE,UAAU,IAAK,MAAO;AAC1D,UAAK,aAAa,MAAO;AACxB,2BAAmB,IAAK,UAAU,MAAO;AAAA,MAC1C,OAAO;AACN,2BAAmB;AAAA,UAClB;AAAA,UACA,gBAAiB;AAAA,YAChB;AAAA,YACA;AAAA,UACD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,IACD,CAAE;AAEF,WAAO,eAAgB;AAAA,MACtB,SAAS,MAAM;AAAA,MACf;AAAA,IACD,CAAE;AAAA,EACH,GAAG,CAAE,SAAS,EAAG,CAAE;AAEnB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ ._root_th78q_1 {
2
+ display: contents;
3
+ }
@@ -0,0 +1,44 @@
1
+ import type { RampResult as InternalRampResult, Ramp } from './lib/types';
2
+ export { DEFAULT_SEED_COLORS } from './lib/constants';
3
+ /**
4
+ * Creates a background ramp.
5
+ * @param params
6
+ * @param params.seed
7
+ * @param params.debug
8
+ */
9
+ export declare function buildBgRamp({ seed, debug, }: {
10
+ seed: string;
11
+ debug?: boolean;
12
+ }): InternalRampResult;
13
+ /**
14
+ * Creates an accent ramp (ie used by primary, success, info, warning and error
15
+ * ramps).
16
+ * @param params
17
+ * @param params.seed
18
+ * @param params.bgRamp
19
+ * @param params.debug
20
+ */
21
+ export declare function buildAccentRamp({ seed, bgRamp, debug, }: {
22
+ seed: string;
23
+ bgRamp?: InternalRampResult;
24
+ debug?: boolean;
25
+ }): InternalRampResult;
26
+ /**
27
+ * Checks that all bg/fg combinations generated by the ramps meet contrast
28
+ * targets.
29
+ * @param params
30
+ * @param params.bgRamp
31
+ * @param params.accentRamps
32
+ */
33
+ export declare function checkAccessibleCombinations({ bgRamp, accentRamps, }: {
34
+ bgRamp: InternalRampResult;
35
+ accentRamps?: InternalRampResult[];
36
+ }): {
37
+ bgName: keyof Ramp;
38
+ bgColor: string;
39
+ fgName: keyof Ramp;
40
+ fgColor: string;
41
+ unmetContrast: number;
42
+ }[];
43
+ export type RampResult = InternalRampResult;
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/color-ramps/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACX,UAAU,IAAI,kBAAkB,EAEhC,IAAI,EACJ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,EAC5B,IAAI,EACJ,KAAK,GACL,EAAE;IACF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB,GAAI,kBAAkB,CAMtB;AAsBD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAE,EAChC,IAAI,EACJ,MAAM,EACN,KAAK,GACL,EAAE;IACF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB,GAAI,kBAAkB,CAUtB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAE,EAC5C,MAAM,EACN,WAAgB,GAChB,EAAE;IACF,MAAM,EAAE,kBAAkB,CAAC;IAC3B,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACnC;YAES,MAAM,IAAI;aACT,MAAM;YACP,MAAM,IAAI;aACT,MAAM;mBACA,MAAM;IA6CtB;AAED,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type Color from 'colorjs.io';
5
+ /**
6
+ * Get cached string representation of a color
7
+ * @param color - Color object to stringify
8
+ * @return Cached string representation
9
+ */
10
+ export declare function getColorString(color: Color): string;
11
+ /**
12
+ * Get cached contrast calculation between two colors
13
+ * @param colorA - First color
14
+ * @param colorB - Second color
15
+ * @return WCAG 2.1 contrast ratio
16
+ */
17
+ export declare function getCachedContrast(colorA: Color, colorB: Color): number;
18
+ /**
19
+ * Clear all caches - useful for memory management or testing
20
+ */
21
+ export declare function clearCaches(): void;
22
+ //# sourceMappingURL=cache-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-utils.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/cache-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAYpC;;;;GAIG;AACH,wBAAgB,cAAc,CAAE,KAAK,EAAE,KAAK,GAAI,MAAM,CAOrD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAI,MAAM,CAYxE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import Color from 'colorjs.io';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import type { Ramp } from './types';
9
+ export declare const WHITE: Color;
10
+ export declare const BLACK: Color;
11
+ export declare const UNIVERSAL_CONTRAST_TOPUP = 0.05;
12
+ export declare const WHITE_TEXT_CONTRAST_MARGIN = 3.1;
13
+ export declare const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS: {
14
+ readonly lighter: {
15
+ readonly min: 0.2;
16
+ readonly max: 0.4;
17
+ };
18
+ readonly darker: {
19
+ readonly min: 0.75;
20
+ readonly max: 0.98;
21
+ };
22
+ };
23
+ export declare const LIGHTNESS_EPSILON = 0.001;
24
+ export declare const MAX_BISECTION_ITERATIONS = 25;
25
+ export declare const CONTRAST_COMBINATIONS: {
26
+ bgs: (keyof Ramp)[];
27
+ fgs: (keyof Ramp)[];
28
+ target: number;
29
+ }[];
30
+ export declare const DEFAULT_SEED_COLORS: {
31
+ bg: string;
32
+ primary: string;
33
+ info: string;
34
+ success: string;
35
+ warning: string;
36
+ error: string;
37
+ };
38
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,eAAO,MAAM,KAAK,OAAoC,CAAC;AACvD,eAAO,MAAM,KAAK,OAAoC,CAAC;AAIvD,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAO7C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAO9C,eAAO,MAAM,sCAAsC;;;;;;;;;CAGzC,CAAC;AAGX,eAAO,MAAM,iBAAiB,QAAO,CAAC;AAEtC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,eAAO,MAAM,qBAAqB,EAAE;IACnC,GAAG,EAAE,CAAE,MAAM,IAAI,CAAE,EAAE,CAAC;IACtB,GAAG,EAAE,CAAE,MAAM,IAAI,CAAE,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CACf,EA+BA,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;;;CAO/B,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import Color from 'colorjs.io';
5
+ import { type TaperChromaOptions } from './taper-chroma';
6
+ /**
7
+ * Solve for L such that:
8
+ * - the L applied to the seed meets the contrast target against the reference
9
+ * - the search is performed in one direction (ie lighter / darker)
10
+ * - more constraints can be applied around lightness
11
+ * - chroma could be tapered
12
+ * @param reference
13
+ * @param seed
14
+ * @param target
15
+ * @param direction
16
+ * @param options
17
+ * @param options.strict
18
+ * @param options.debug
19
+ * @param options.lightnessConstraint
20
+ * @param options.lightnessConstraint.type
21
+ * @param options.lightnessConstraint.value
22
+ * @param options.taperChromaOptions
23
+ */
24
+ export declare function findColorMeetingRequirements(reference: Color, seed: Color, target: number, direction: 'lighter' | 'darker', { lightnessConstraint, taperChromaOptions, strict, debug, }?: {
25
+ lightnessConstraint?: {
26
+ type: 'force' | 'onlyIfSucceeds';
27
+ value: number;
28
+ };
29
+ taperChromaOptions?: TaperChromaOptions;
30
+ strict?: boolean;
31
+ debug?: boolean;
32
+ }): {
33
+ color: Color;
34
+ reached: boolean;
35
+ achieved: number;
36
+ };
37
+ //# sourceMappingURL=find-color-with-constraints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-color-with-constraints.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/find-color-with-constraints.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,YAAY,CAAC;AAa/B,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,gBAAgB,CAAC;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,4BAA4B,CAC3C,SAAS,EAAE,KAAK,EAChB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,GAAG,QAAQ,EAC/B,EACC,mBAAmB,EACnB,kBAAkB,EAClB,MAAa,EACb,KAAa,GACb,GAAE;IACF,mBAAmB,CAAC,EAAE;QACrB,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAAC;QACjC,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACX,GACJ;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAsItD"}
@@ -0,0 +1,11 @@
1
+ import type { Ramp, RampDirection, RampConfig, RampResult } from './types';
2
+ export declare function buildRamp(seedArg: string, config: RampConfig, { mainDirection, pinLightness, debug, rescaleToFitContrastTargets, }?: {
3
+ mainDirection?: RampDirection;
4
+ pinLightness?: {
5
+ stepName: keyof Ramp;
6
+ value: number;
7
+ };
8
+ rescaleToFitContrastTargets?: boolean;
9
+ debug?: boolean;
10
+ }): RampResult;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAEX,IAAI,EACJ,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,SAAS,CAAC;AA0LjB,wBAAgB,SAAS,CACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,EAClB,EACC,aAAa,EACb,YAAY,EACZ,KAAa,EACb,2BAAkC,GAClC,GAAE;IACF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE;QACd,QAAQ,EAAE,MAAM,IAAI,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;CACX,GACJ,UAAU,CA8IZ"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { RampConfig } from './types';
5
+ export declare const BG_RAMP_CONFIG: RampConfig;
6
+ export declare const ACCENT_RAMP_CONFIG: RampConfig;
7
+ //# sourceMappingURL=ramp-configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ramp-configs.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/ramp-configs.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAkB,UAAU,EAAiB,MAAM,SAAS,CAAC;AAoDzE,eAAO,MAAM,cAAc,EAAE,UAkL5B,CAAC;AAIF,eAAO,MAAM,kBAAkB,EAAE,UAuEhC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import Color from 'colorjs.io';
5
+ export interface TaperChromaOptions {
6
+ gamut?: 'p3' | 'srgb';
7
+ alpha?: number;
8
+ carry?: number;
9
+ cUpperBound?: number;
10
+ radiusLight?: number;
11
+ radiusDark?: number;
12
+ kLight?: number;
13
+ kDark?: number;
14
+ hueFallback?: number;
15
+ achromaEpsilon?: number;
16
+ }
17
+ /**
18
+ * Given the seed and the target lightness, tapers the chroma smoothly.
19
+ * - C_intended = Cmax(Lt,H0) * alpha * (seedRelative^carry)
20
+ * - Continuous taper vs |Lt - Ls| to softly reduce chroma for neighbors
21
+ * - Downward-only clamp on C (preserve L & H)
22
+ * @param seed
23
+ * @param lTarget
24
+ * @param options
25
+ */
26
+ export declare function taperChroma(seed: Color, // already OKLCH
27
+ lTarget: number, // [0..1]
28
+ options?: TaperChromaOptions): {
29
+ l: number;
30
+ c: number;
31
+ };
32
+ //# sourceMappingURL=taper-chroma.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taper-chroma.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/taper-chroma.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,MAAM,WAAW,kBAAkB;IAClC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAC1B,IAAI,EAAE,KAAK,EAAE,gBAAgB;AAC7B,OAAO,EAAE,MAAM,EAAE,SAAS;AAC1B,OAAO,GAAE,kBAAuB,GAC9B;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAkE1B"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { TaperChromaOptions } from './taper-chroma';
5
+ export type Ramp = {
6
+ surface1: string;
7
+ surface2: string;
8
+ surface3: string;
9
+ surface4: string;
10
+ surface5: string;
11
+ surface6: string;
12
+ stroke1: string;
13
+ stroke2: string;
14
+ stroke3: string;
15
+ stroke4: string;
16
+ bgFill1: string;
17
+ bgFill2: string;
18
+ bgFillInverted1: string;
19
+ bgFillInverted2: string;
20
+ bgFillDark: string;
21
+ fgSurface1: string;
22
+ fgSurface2: string;
23
+ fgSurface3: string;
24
+ fgSurface4: string;
25
+ fgFill: string;
26
+ fgFillInverted: string;
27
+ fgFillDark: string;
28
+ };
29
+ export type RampDirection = 'lighter' | 'darker';
30
+ export type FollowDirection = 'main' | 'opposite' | 'best' | RampDirection;
31
+ export type ContrastRequirement = {
32
+ /** The reference color against which to calculate the contrast */
33
+ reference: keyof Ramp | 'seed';
34
+ /**
35
+ * Which direction should the algorithm search a matching color in:
36
+ * - main: follow the same direction as the ramp's main direction
37
+ * - opposite: follow the opposite direction of the ramp
38
+ * - best: pick the direction that has the most contrast headroom
39
+ * - hardcoded ramp direction (useful for generating colors that always
40
+ * light/dark regardless of the ramp direction)
41
+ */
42
+ followDirection: FollowDirection;
43
+ /**
44
+ * Prefer "lighter" direction when searching for a contrasting color.
45
+ * Especially useful for foreground color to counter the poor results that the
46
+ * WCAG algo gives when contrasting white text over mid-lightness backgrounds.
47
+ */
48
+ preferLighter?: boolean;
49
+ /**
50
+ * The contrast target to meet.
51
+ */
52
+ target: number;
53
+ /**
54
+ * When true, the algorithm won't count a failure in meeting the contrast
55
+ * target as a reason to recalculate the ramp.
56
+ */
57
+ ignoreWhenAdjustingSeed?: boolean;
58
+ };
59
+ export type RampStepConfig = {
60
+ contrast: ContrastRequirement;
61
+ lightness?: (direction: RampDirection) => number;
62
+ taperChromaOptions?: TaperChromaOptions;
63
+ /**
64
+ * If specified, try to reuse the color from this step if it meets
65
+ * the contrast requirements. This reduces the number of unique colors
66
+ * in the ramp and improves consistency.
67
+ */
68
+ sameAsIfPossible?: keyof Ramp;
69
+ };
70
+ export type RampConfig = Record<keyof Ramp, RampStepConfig>;
71
+ export type RampResult = {
72
+ ramp: Record<keyof Ramp, {
73
+ color: string;
74
+ warning: boolean;
75
+ }>;
76
+ direction: RampDirection;
77
+ };
78
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,MAAM,IAAI,GAAG;IAElB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB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AE,aAAa,CAAC;CACzB,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type Color from 'colorjs.io';
5
+ import type { Ramp, RampStepConfig, RampDirection } from './types';
6
+ /**
7
+ * Make sure that a color is valid in the p3 gamut, and converts it to oklch.
8
+ * @param c
9
+ */
10
+ export declare const clampToGamut: (c: Color) => Color;
11
+ /**
12
+ * Topologically sort steps based on their dependencies
13
+ * @param config - The steps configuration object
14
+ */
15
+ export declare function sortByDependency(config: Record<keyof Ramp, RampStepConfig>): (keyof Ramp)[];
16
+ /**
17
+ * Finds out whether a lighter or a darker foreground color achieves a better
18
+ * contrast against the seed
19
+ * @param seed
20
+ * @param preferLighter Whether the check should favor white foreground color
21
+ * @return An object with "better" and "worse" properties, each holding a
22
+ * ramp direction value.
23
+ */
24
+ export declare function computeBetterFgColorDirection(seed: Color, preferLighter?: boolean): {
25
+ better: RampDirection;
26
+ worse: RampDirection;
27
+ };
28
+ export declare function adjustContrastTarget(target: number): number;
29
+ /**
30
+ * Prevent the accent scale from referencing a lightness value that
31
+ * would prevent the algorithm from complying with the requirements
32
+ * and cause it to generate unexpected results.
33
+ * @param rawLightness
34
+ * @param direction
35
+ * @return The clamped lightness value
36
+ */
37
+ export declare function clampAccentScaleReferenceLightness(rawLightness: number, direction: RampDirection): number;
38
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAYpC,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGnE;;;GAGG;AACH,eAAO,MAAM,YAAY,MAAQ,KAAK,UAGtB,CAAC;AAwCjB;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,MAAM,CAAE,MAAM,IAAI,EAAE,cAAc,CAAE,GAC1C,CAAE,MAAM,IAAI,CAAE,EAAE,CAuClB;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC5C,IAAI,EAAE,KAAK,EACX,aAAa,CAAC,EAAE,OAAO,GACrB;IACF,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,aAAa,CAAC;CACrB,CASA;AAED,wBAAgB,oBAAoB,CAAE,MAAM,EAAE,MAAM,UAOnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CACjD,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,aAAa,UAIxB"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ declare const ColorGen: (props: {
6
+ background: string;
7
+ primary: string;
8
+ children: React.ReactNode;
9
+ }) => import("react").JSX.Element;
10
+ declare const meta: Meta<typeof ColorGen>;
11
+ export default meta;
12
+ export declare const Default: StoryObj<typeof ColorGen>;
13
+ export declare const SampleCombinations: StoryObj<typeof ColorGen>;
14
+ //# sourceMappingURL=index.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AASvD,QAAA,MAAM,QAAQ,UAAY;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B,gCAEA,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,QAAQ,CAmBhC,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,QAAQ,CAkI9C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAE,OAAO,QAAQ,CAyFzD,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { Ramp } from '../lib/types';
5
+ type RampTableProps = {
6
+ ramps: {
7
+ seed: {
8
+ name: keyof Ramp;
9
+ value: string;
10
+ };
11
+ ramp: Record<keyof Ramp, {
12
+ color: string;
13
+ warning: boolean;
14
+ }>;
15
+ }[];
16
+ };
17
+ export declare const RampTable: import("react").ForwardRefExoticComponent<RampTableProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ export {};
19
+ //# sourceMappingURL=ramp-table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ramp-table.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/stories/ramp-table.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AA4BzC,KAAK,cAAc,GAAG;IACrB,KAAK,EAAE;QACN,IAAI,EAAE;YACL,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,KAAK,EAAE,MAAM,CAAC;SACd,CAAC;QACF,IAAI,EAAE,MAAM,CACX,MAAM,IAAI,EACV;YACC,KAAK,EAAE,MAAM,CAAC;YACd,OAAO,EAAE,OAAO,CAAC;SACjB,CACD,CAAC;KACF,EAAE,CAAC;CACJ,CAAC;AACF,eAAO,MAAM,SAAS,2GAgKrB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { ThemeProviderSettings } from './types';
5
+ interface ThemeContextType {
6
+ resolvedSettings: ThemeProviderSettings;
7
+ }
8
+ export declare const ThemeContext: import("react").Context<ThemeContextType>;
9
+ export {};
10
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,UAAU,gBAAgB;IACzB,gBAAgB,EAAE,qBAAqB,CAAC;CACxC;AAED,eAAO,MAAM,YAAY,2CAItB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { privateApis } from './private-apis';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const lock: (object: unknown, privateData: unknown) => void, unlock: <T = any>(object: unknown) => T;
2
+ //# sourceMappingURL=lock-unlock.d.ts.map