@wordpress/theme 0.4.1-next.8fd3f8831.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/LICENSE.md +1 -1
  3. package/README.md +72 -18
  4. package/build/color-ramps/index.cjs +1 -1
  5. package/build/color-ramps/index.cjs.map +2 -2
  6. package/build/color-ramps/lib/color-utils.cjs +2 -1
  7. package/build/color-ramps/lib/color-utils.cjs.map +2 -2
  8. package/build/color-ramps/lib/default-ramps.cjs +2 -2
  9. package/build/color-ramps/lib/default-ramps.cjs.map +1 -1
  10. package/build/color-ramps/lib/index.cjs +1 -1
  11. package/build/color-ramps/lib/index.cjs.map +2 -2
  12. package/build/color-ramps/lib/taper-chroma.cjs +2 -2
  13. package/build/color-ramps/lib/taper-chroma.cjs.map +2 -2
  14. package/build/prebuilt/js/design-tokens.cjs +16 -29
  15. package/build/prebuilt/js/design-tokens.cjs.map +3 -3
  16. package/build/prebuilt/ts/color-tokens.cjs +4 -24
  17. package/build/prebuilt/ts/color-tokens.cjs.map +2 -2
  18. package/build/prebuilt/ts/token-types.cjs.map +1 -1
  19. package/build/stylelint-plugins/no-setting-wpds-custom-properties.cjs +69 -0
  20. package/build/stylelint-plugins/no-setting-wpds-custom-properties.cjs.map +7 -0
  21. package/build/stylelint-plugins/no-unknown-ds-tokens.cjs +98 -0
  22. package/build/stylelint-plugins/no-unknown-ds-tokens.cjs.map +7 -0
  23. package/build/use-theme-provider-styles.cjs +19 -43
  24. package/build/use-theme-provider-styles.cjs.map +2 -2
  25. package/build-module/color-ramps/{index.js → index.mjs} +10 -10
  26. package/build-module/color-ramps/index.mjs.map +7 -0
  27. package/build-module/color-ramps/lib/{color-utils.js → color-utils.mjs} +4 -3
  28. package/build-module/color-ramps/lib/color-utils.mjs.map +7 -0
  29. package/build-module/color-ramps/lib/{constants.js → constants.mjs} +2 -2
  30. package/build-module/color-ramps/lib/{default-ramps.js → default-ramps.mjs} +3 -3
  31. package/build-module/color-ramps/lib/{default-ramps.js.map → default-ramps.mjs.map} +1 -1
  32. package/build-module/color-ramps/lib/{find-color-with-constraints.js → find-color-with-constraints.mjs} +6 -6
  33. package/build-module/color-ramps/lib/{index.js → index.mjs} +7 -8
  34. package/build-module/color-ramps/lib/index.mjs.map +7 -0
  35. package/build-module/color-ramps/lib/{ramp-configs.js → ramp-configs.mjs} +1 -1
  36. package/build-module/color-ramps/lib/{register-color-spaces.js → register-color-spaces.mjs} +1 -1
  37. package/build-module/color-ramps/lib/{taper-chroma.js → taper-chroma.mjs} +4 -4
  38. package/build-module/color-ramps/lib/{taper-chroma.js.map → taper-chroma.mjs.map} +2 -2
  39. package/build-module/color-ramps/lib/types.mjs +1 -0
  40. package/build-module/color-ramps/lib/{utils.js → utils.mjs} +4 -4
  41. package/build-module/{context.js → context.mjs} +1 -1
  42. package/build-module/index.mjs +6 -0
  43. package/build-module/{lock-unlock.js → lock-unlock.mjs} +1 -1
  44. package/build-module/prebuilt/js/{design-tokens.js → design-tokens.mjs} +17 -30
  45. package/build-module/prebuilt/js/design-tokens.mjs.map +7 -0
  46. package/build-module/prebuilt/ts/{color-tokens.js → color-tokens.mjs} +5 -25
  47. package/build-module/prebuilt/ts/color-tokens.mjs.map +7 -0
  48. package/build-module/prebuilt/ts/token-types.mjs +1 -0
  49. package/build-module/{private-apis.js → private-apis.mjs} +4 -4
  50. package/build-module/stylelint-plugins/no-setting-wpds-custom-properties.mjs +39 -0
  51. package/build-module/stylelint-plugins/no-setting-wpds-custom-properties.mjs.map +7 -0
  52. package/build-module/stylelint-plugins/no-unknown-ds-tokens.mjs +68 -0
  53. package/build-module/stylelint-plugins/no-unknown-ds-tokens.mjs.map +7 -0
  54. package/build-module/{theme-provider.js → theme-provider.mjs} +3 -3
  55. package/build-module/types.mjs +1 -0
  56. package/build-module/{use-theme-provider-styles.js → use-theme-provider-styles.mjs} +24 -49
  57. package/build-module/use-theme-provider-styles.mjs.map +7 -0
  58. package/build-types/color-ramps/lib/color-utils.d.ts +1 -1
  59. package/build-types/color-ramps/lib/color-utils.d.ts.map +1 -1
  60. package/build-types/color-ramps/lib/constants.d.ts +2 -2
  61. package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
  62. package/build-types/color-ramps/lib/index.d.ts.map +1 -1
  63. package/build-types/color-ramps/stories/index.story.d.ts +1 -1
  64. package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
  65. package/build-types/prebuilt/js/{design-tokens.d.ts → design-tokens.d.mts} +1 -1
  66. package/build-types/prebuilt/js/design-tokens.d.mts.map +1 -0
  67. package/build-types/prebuilt/ts/color-tokens.d.ts +0 -4
  68. package/build-types/prebuilt/ts/color-tokens.d.ts.map +1 -1
  69. package/build-types/prebuilt/ts/token-types.d.ts +21 -5
  70. package/build-types/prebuilt/ts/token-types.d.ts.map +1 -1
  71. package/build-types/stories/index.story.d.ts +1 -1
  72. package/build-types/stories/index.story.d.ts.map +1 -1
  73. package/build-types/stylelint-plugins/no-setting-wpds-custom-properties.d.mts +4 -0
  74. package/build-types/stylelint-plugins/no-setting-wpds-custom-properties.d.mts.map +1 -0
  75. package/build-types/stylelint-plugins/no-unknown-ds-tokens.d.mts +4 -0
  76. package/build-types/stylelint-plugins/no-unknown-ds-tokens.d.mts.map +1 -0
  77. package/build-types/use-theme-provider-styles.d.ts.map +1 -1
  78. package/package.json +42 -13
  79. package/src/color-ramps/index.ts +2 -2
  80. package/src/color-ramps/lib/color-utils.ts +2 -1
  81. package/src/color-ramps/lib/default-ramps.ts +2 -2
  82. package/src/color-ramps/lib/index.ts +1 -2
  83. package/src/color-ramps/lib/taper-chroma.ts +2 -2
  84. package/src/color-ramps/stories/index.story.tsx +2 -2
  85. package/src/color-ramps/test/__snapshots__/index.test.ts.snap +7136 -7117
  86. package/src/color-ramps/test/index.test.ts +8 -33
  87. package/src/prebuilt/css/design-tokens.css +22 -35
  88. package/src/prebuilt/js/{design-tokens.js → design-tokens.mjs} +17 -30
  89. package/src/prebuilt/ts/color-tokens.ts +5 -25
  90. package/src/prebuilt/ts/token-types.ts +51 -3
  91. package/src/stories/index.story.tsx +4 -4
  92. package/src/stories/introduction.mdx +6 -0
  93. package/src/stylelint-plugins/no-setting-wpds-custom-properties.mjs +45 -0
  94. package/src/stylelint-plugins/no-unknown-ds-tokens.mjs +101 -0
  95. package/src/stylelint-plugins/test/.stylelintignore +1 -0
  96. package/src/stylelint-plugins/test/.stylelintrc.json +10 -0
  97. package/src/stylelint-plugins/test/__snapshots__/no-setting-wpds-custom-properties.test.ts.snap +24 -0
  98. package/src/stylelint-plugins/test/__snapshots__/no-unknown-ds-tokens.test.ts.snap +24 -0
  99. package/src/stylelint-plugins/test/fixtures/no-setting-wpds-custom-properties-invalid.css +9 -0
  100. package/src/stylelint-plugins/test/fixtures/no-setting-wpds-custom-properties-valid.css +12 -0
  101. package/src/stylelint-plugins/test/fixtures/no-unknown-ds-tokens-invalid.css +9 -0
  102. package/src/stylelint-plugins/test/fixtures/no-unknown-ds-tokens-valid.css +19 -0
  103. package/src/stylelint-plugins/test/no-setting-wpds-custom-properties.test.ts +47 -0
  104. package/src/stylelint-plugins/test/no-unknown-ds-tokens.test.ts +47 -0
  105. package/src/stylelint-plugins/test/utils/index.ts +29 -0
  106. package/src/use-theme-provider-styles.ts +22 -42
  107. package/build-module/color-ramps/index.js.map +0 -7
  108. package/build-module/color-ramps/lib/color-utils.js.map +0 -7
  109. package/build-module/color-ramps/lib/index.js.map +0 -7
  110. package/build-module/color-ramps/lib/types.js +0 -1
  111. package/build-module/index.js +0 -6
  112. package/build-module/prebuilt/js/design-tokens.js.map +0 -7
  113. package/build-module/prebuilt/ts/color-tokens.js.map +0 -7
  114. package/build-module/prebuilt/ts/token-types.js +0 -1
  115. package/build-module/types.js +0 -1
  116. package/build-module/use-theme-provider-styles.js.map +0 -7
  117. package/build-types/prebuilt/js/design-tokens.d.ts.map +0 -1
  118. /package/build-module/color-ramps/lib/{constants.js.map → constants.mjs.map} +0 -0
  119. /package/build-module/color-ramps/lib/{find-color-with-constraints.js.map → find-color-with-constraints.mjs.map} +0 -0
  120. /package/build-module/color-ramps/lib/{ramp-configs.js.map → ramp-configs.mjs.map} +0 -0
  121. /package/build-module/color-ramps/lib/{register-color-spaces.js.map → register-color-spaces.mjs.map} +0 -0
  122. /package/build-module/color-ramps/lib/{types.js.map → types.mjs.map} +0 -0
  123. /package/build-module/color-ramps/lib/{utils.js.map → utils.mjs.map} +0 -0
  124. /package/build-module/{context.js.map → context.mjs.map} +0 -0
  125. /package/build-module/{index.js.map → index.mjs.map} +0 -0
  126. /package/build-module/{lock-unlock.js.map → lock-unlock.mjs.map} +0 -0
  127. /package/build-module/prebuilt/ts/{token-types.js.map → token-types.mjs.map} +0 -0
  128. /package/build-module/{private-apis.js.map → private-apis.mjs.map} +0 -0
  129. /package/build-module/{theme-provider.js.map → theme-provider.mjs.map} +0 -0
  130. /package/build-module/{types.js.map → types.mjs.map} +0 -0
@@ -0,0 +1,68 @@
1
+ // packages/theme/src/stylelint-plugins/no-unknown-ds-tokens.mjs
2
+ import stylelint from "stylelint";
3
+ import tokenList from "../prebuilt/js/design-tokens.mjs";
4
+ var DS_TOKEN_PREFIX = "wpds-";
5
+ function extractCSSVariables(value, prefix = "") {
6
+ const regex = /--[\w-]+/g;
7
+ const variables = /* @__PURE__ */ new Set();
8
+ let match;
9
+ while ((match = regex.exec(value)) !== null) {
10
+ const variableName = match[0];
11
+ if (variableName.startsWith(`--${prefix}`)) {
12
+ variables.add(variableName);
13
+ }
14
+ }
15
+ return variables;
16
+ }
17
+ var knownTokens = new Set(tokenList);
18
+ var wpdsTokensRegex = new RegExp(`[^\\w]--${DS_TOKEN_PREFIX}`, "i");
19
+ var {
20
+ createPlugin,
21
+ utils: { report, ruleMessages, validateOptions }
22
+ } = stylelint;
23
+ var ruleName = "plugin-wpds/no-unknown-ds-tokens";
24
+ var messages = ruleMessages(ruleName, {
25
+ rejected: (tokenNames) => `The following CSS variables are not valid Design System tokens: ${tokenNames}`
26
+ });
27
+ var ruleFunction = (primary) => {
28
+ return (root, result) => {
29
+ const validOptions = validateOptions(result, ruleName, {
30
+ actual: primary,
31
+ possible: [true]
32
+ });
33
+ if (!validOptions) {
34
+ return;
35
+ }
36
+ root.walkDecls((ruleNode) => {
37
+ const { value } = ruleNode;
38
+ if (wpdsTokensRegex.test(value)) {
39
+ const usedTokens = extractCSSVariables(
40
+ value,
41
+ DS_TOKEN_PREFIX
42
+ );
43
+ const unknownTokens = new Set(
44
+ [...usedTokens].filter(
45
+ (token) => !knownTokens.has(token)
46
+ )
47
+ );
48
+ if (unknownTokens.size > 0) {
49
+ report({
50
+ message: messages.rejected(
51
+ Array.from(unknownTokens).map((token) => `'${token}'`).join(", ")
52
+ ),
53
+ node: ruleNode,
54
+ result,
55
+ ruleName
56
+ });
57
+ }
58
+ }
59
+ });
60
+ };
61
+ };
62
+ ruleFunction.ruleName = ruleName;
63
+ ruleFunction.messages = messages;
64
+ var no_unknown_ds_tokens_default = createPlugin(ruleName, ruleFunction);
65
+ export {
66
+ no_unknown_ds_tokens_default as default
67
+ };
68
+ //# sourceMappingURL=no-unknown-ds-tokens.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/stylelint-plugins/no-unknown-ds-tokens.mjs"],
4
+ "sourcesContent": ["import stylelint from 'stylelint';\nimport tokenList from '../prebuilt/js/design-tokens.mjs';\n\nconst DS_TOKEN_PREFIX = 'wpds-';\n\n/**\n * Extracts all unique CSS custom properties (variables) from a given CSS value string,\n * including those in fallback positions, optionally filtering by a specific prefix.\n *\n * @param {string} value - The CSS value string to search for variables.\n * @param {string} [prefix=''] - Optional prefix to filter variables (e.g., 'wpds-').\n * @return {Set<string>} A Set of unique matched CSS variable names (e.g., Set { '--wpds-token' }).\n *\n * @example\n * extractCSSVariables(\n * 'border: 1px solid var(--wpds-border-color, var(--wpds-border-fallback)); ' +\n * 'color: var(--wpds-color-fg, black); ' +\n * 'background: var(--unrelated-bg);',\n * 'wpds'\n * );\n * // \u2192 Set { '--wpds-border-color', '--wpds-border-fallback', '--wpds-color-fg' }\n */\nfunction extractCSSVariables( value, prefix = '' ) {\n\tconst regex = /--[\\w-]+/g;\n\t/** @type {Set<string>} */\n\tconst variables = new Set();\n\n\tlet match;\n\twhile ( ( match = regex.exec( value ) ) !== null ) {\n\t\tconst variableName = match[ 0 ];\n\t\tif ( variableName.startsWith( `--${ prefix }` ) ) {\n\t\t\tvariables.add( variableName );\n\t\t}\n\t}\n\n\treturn variables;\n}\n\nconst knownTokens = new Set( tokenList );\nconst wpdsTokensRegex = new RegExp( `[^\\\\w]--${ DS_TOKEN_PREFIX }`, 'i' );\n\nconst {\n\tcreatePlugin,\n\tutils: { report, ruleMessages, validateOptions },\n} = stylelint;\n\nconst ruleName = 'plugin-wpds/no-unknown-ds-tokens';\n\nconst messages = ruleMessages( ruleName, {\n\trejected: ( tokenNames ) =>\n\t\t`The following CSS variables are not valid Design System tokens: ${ tokenNames }`,\n} );\n\n/** @type {import('stylelint').Rule} */\nconst ruleFunction = ( primary ) => {\n\treturn ( root, result ) => {\n\t\tconst validOptions = validateOptions( result, ruleName, {\n\t\t\tactual: primary,\n\t\t\tpossible: [ true ],\n\t\t} );\n\n\t\tif ( ! validOptions ) {\n\t\t\treturn;\n\t\t}\n\n\t\troot.walkDecls( ( ruleNode ) => {\n\t\t\tconst { value } = ruleNode;\n\t\t\t// Early match for WPDS tokens to avoid unnecessary processing.\n\t\t\tif ( wpdsTokensRegex.test( value ) ) {\n\t\t\t\tconst usedTokens = extractCSSVariables(\n\t\t\t\t\tvalue,\n\t\t\t\t\tDS_TOKEN_PREFIX\n\t\t\t\t);\n\t\t\t\tconst unknownTokens = new Set(\n\t\t\t\t\t[ ...usedTokens ].filter(\n\t\t\t\t\t\t( token ) => ! knownTokens.has( token )\n\t\t\t\t\t)\n\t\t\t\t);\n\n\t\t\t\tif ( unknownTokens.size > 0 ) {\n\t\t\t\t\treport( {\n\t\t\t\t\t\tmessage: messages.rejected(\n\t\t\t\t\t\t\tArray.from( unknownTokens )\n\t\t\t\t\t\t\t\t.map( ( token ) => `'${ token }'` )\n\t\t\t\t\t\t\t\t.join( ', ' )\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnode: ruleNode,\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\truleName,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t};\n};\n\nruleFunction.ruleName = ruleName;\nruleFunction.messages = messages;\n\n/** @type {import('stylelint').Plugin} */\nexport default createPlugin( ruleName, ruleFunction );\n"],
5
+ "mappings": ";AAAA,OAAO,eAAe;AACtB,OAAO,eAAe;AAEtB,IAAM,kBAAkB;AAmBxB,SAAS,oBAAqB,OAAO,SAAS,IAAK;AAClD,QAAM,QAAQ;AAEd,QAAM,YAAY,oBAAI,IAAI;AAE1B,MAAI;AACJ,UAAU,QAAQ,MAAM,KAAM,KAAM,OAAQ,MAAO;AAClD,UAAM,eAAe,MAAO,CAAE;AAC9B,QAAK,aAAa,WAAY,KAAM,MAAO,EAAG,GAAI;AACjD,gBAAU,IAAK,YAAa;AAAA,IAC7B;AAAA,EACD;AAEA,SAAO;AACR;AAEA,IAAM,cAAc,IAAI,IAAK,SAAU;AACvC,IAAM,kBAAkB,IAAI,OAAQ,WAAY,eAAgB,IAAI,GAAI;AAExE,IAAM;AAAA,EACL;AAAA,EACA,OAAO,EAAE,QAAQ,cAAc,gBAAgB;AAChD,IAAI;AAEJ,IAAM,WAAW;AAEjB,IAAM,WAAW,aAAc,UAAU;AAAA,EACxC,UAAU,CAAE,eACX,mEAAoE,UAAW;AACjF,CAAE;AAGF,IAAM,eAAe,CAAE,YAAa;AACnC,SAAO,CAAE,MAAM,WAAY;AAC1B,UAAM,eAAe,gBAAiB,QAAQ,UAAU;AAAA,MACvD,QAAQ;AAAA,MACR,UAAU,CAAE,IAAK;AAAA,IAClB,CAAE;AAEF,QAAK,CAAE,cAAe;AACrB;AAAA,IACD;AAEA,SAAK,UAAW,CAAE,aAAc;AAC/B,YAAM,EAAE,MAAM,IAAI;AAElB,UAAK,gBAAgB,KAAM,KAAM,GAAI;AACpC,cAAM,aAAa;AAAA,UAClB;AAAA,UACA;AAAA,QACD;AACA,cAAM,gBAAgB,IAAI;AAAA,UACzB,CAAE,GAAG,UAAW,EAAE;AAAA,YACjB,CAAE,UAAW,CAAE,YAAY,IAAK,KAAM;AAAA,UACvC;AAAA,QACD;AAEA,YAAK,cAAc,OAAO,GAAI;AAC7B,iBAAQ;AAAA,YACP,SAAS,SAAS;AAAA,cACjB,MAAM,KAAM,aAAc,EACxB,IAAK,CAAE,UAAW,IAAK,KAAM,GAAI,EACjC,KAAM,IAAK;AAAA,YACd;AAAA,YACA,MAAM;AAAA,YACN;AAAA,YACA;AAAA,UACD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH;AACD;AAEA,aAAa,WAAW;AACxB,aAAa,WAAW;AAGxB,IAAO,+BAAQ,aAAc,UAAU,YAAa;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  // packages/theme/src/theme-provider.tsx
2
2
  import { useMemo, useId } from "@wordpress/element";
3
- import { ThemeContext } from "./context.js";
4
- import { useThemeProviderStyles } from "./use-theme-provider-styles.js";
3
+ import { ThemeContext } from "./context.mjs";
4
+ import { useThemeProviderStyles } from "./use-theme-provider-styles.mjs";
5
5
 
6
6
  // packages/theme/src/style.module.css
7
7
  var css = `.style-module__root__26kw6 {
@@ -69,4 +69,4 @@ var ThemeProvider = ({
69
69
  export {
70
70
  ThemeProvider
71
71
  };
72
- //# sourceMappingURL=theme-provider.js.map
72
+ //# sourceMappingURL=theme-provider.mjs.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.mjs.map
@@ -1,22 +1,22 @@
1
1
  // packages/theme/src/use-theme-provider-styles.ts
2
2
  import {
3
- parse,
3
+ clone,
4
+ set,
4
5
  to,
5
- get,
6
- serialize,
7
6
  sRGB,
8
7
  HSL
9
8
  } from "colorjs.io/fn";
10
9
  import memoize from "memize";
11
10
  import { useMemo, useContext } from "@wordpress/element";
12
- import "./color-ramps/lib/register-color-spaces.js";
13
- import { ThemeContext } from "./context.js";
14
- import colorTokens from "./prebuilt/ts/color-tokens.js";
11
+ import "./color-ramps/lib/register-color-spaces.mjs";
12
+ import { ThemeContext } from "./context.mjs";
13
+ import colorTokens from "./prebuilt/ts/color-tokens.mjs";
15
14
  import {
16
15
  buildBgRamp,
17
16
  buildAccentRamp,
18
17
  DEFAULT_SEED_COLORS
19
- } from "./color-ramps/index.js";
18
+ } from "./color-ramps/index.mjs";
19
+ import { getColorString } from "./color-ramps/lib/color-utils.mjs";
20
20
  var getCachedBgRamp = memoize(buildBgRamp, { maxSize: 10 });
21
21
  var getCachedAccentRamp = memoize(buildAccentRamp, { maxSize: 10 });
22
22
  var legacyWpComponentsOverridesCSS = [
@@ -76,57 +76,32 @@ var legacyWpComponentsOverridesCSS = [
76
76
  ];
77
77
  function customRgbFormat(color) {
78
78
  const rgb = to(color, sRGB);
79
- return [get(rgb, "srgb.r"), get(rgb, "srgb.g"), get(rgb, "srgb.b")].map((n) => Math.round(n * 255)).join(", ");
79
+ return rgb.coords.map((n) => Math.round((n ?? 0) * 255)).join(", ");
80
80
  }
81
81
  function legacyWpAdminThemeOverridesCSS(accent) {
82
- const parsedAccent = to(parse(accent), HSL);
83
- const coords = parsedAccent.coords;
84
- const darker10 = to(
85
- {
86
- space: HSL,
87
- coords: [
88
- coords[0],
89
- // h
90
- coords[1],
91
- // s
92
- Math.max(0, Math.min(100, coords[2] - 5))
93
- // l (reduced by 5%)
94
- ]
95
- },
96
- sRGB
82
+ const parsedAccent = to(accent, HSL);
83
+ const parsedL = parsedAccent.coords[2] ?? 0;
84
+ const darker10 = set(
85
+ clone(parsedAccent),
86
+ [HSL, "l"],
87
+ Math.max(0, parsedL - 5)
88
+ // L reduced by 5%
97
89
  );
98
- const darker20 = to(
99
- {
100
- space: HSL,
101
- coords: [
102
- coords[0],
103
- // h
104
- coords[1],
105
- // s
106
- Math.max(0, Math.min(100, coords[2] - 10))
107
- // l (reduced by 10%)
108
- ]
109
- },
110
- sRGB
90
+ const darker20 = set(
91
+ clone(parsedAccent),
92
+ [HSL, "l"],
93
+ Math.max(0, parsedL - 10)
94
+ // L reduced by 10%
111
95
  );
112
96
  return [
113
- [
114
- "--wp-admin-theme-color",
115
- serialize(to(parsedAccent, sRGB), { format: "hex" })
116
- ],
97
+ ["--wp-admin-theme-color", getColorString(parsedAccent)],
117
98
  ["--wp-admin-theme-color--rgb", customRgbFormat(parsedAccent)],
118
- [
119
- "--wp-admin-theme-color-darker-10",
120
- serialize(darker10, { format: "hex" })
121
- ],
99
+ ["--wp-admin-theme-color-darker-10", getColorString(darker10)],
122
100
  [
123
101
  "--wp-admin-theme-color-darker-10--rgb",
124
102
  customRgbFormat(darker10)
125
103
  ],
126
- [
127
- "--wp-admin-theme-color-darker-20",
128
- serialize(darker20, { format: "hex" })
129
- ],
104
+ ["--wp-admin-theme-color-darker-20", getColorString(darker20)],
130
105
  [
131
106
  "--wp-admin-theme-color-darker-20--rgb",
132
107
  customRgbFormat(darker20)
@@ -206,4 +181,4 @@ function useThemeProviderStyles({
206
181
  export {
207
182
  useThemeProviderStyles
208
183
  };
209
- //# sourceMappingURL=use-theme-provider-styles.js.map
184
+ //# sourceMappingURL=use-theme-provider-styles.mjs.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 {\n\tclone,\n\tset,\n\tto,\n\tsRGB,\n\tHSL,\n\ttype PlainColorObject,\n} from 'colorjs.io/fn';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport './color-ramps/lib/register-color-spaces';\nimport { ThemeContext } from './context';\nimport colorTokens from './prebuilt/ts/color-tokens';\nimport {\n\tbuildBgRamp,\n\tbuildAccentRamp,\n\tDEFAULT_SEED_COLORS,\n\ttype RampResult,\n} from './color-ramps';\nimport { getColorString } from './color-ramps/lib/color-utils';\nimport type { ThemeProviderProps } from './types';\n\ntype Entry = [ string, string ];\n\nconst getCachedBgRamp = memoize( buildBgRamp, { maxSize: 10 } );\nconst getCachedAccentRamp = memoize( buildAccentRamp, { maxSize: 10 } );\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: PlainColorObject ): string {\n\tconst rgb = to( color, sRGB );\n\treturn rgb.coords\n\t\t.map( ( n ) => Math.round( ( n ?? 0 ) * 255 ) )\n\t\t.join( ', ' );\n}\n\nfunction legacyWpAdminThemeOverridesCSS( accent: string ): Entry[] {\n\tconst parsedAccent = to( accent, HSL );\n\tconst parsedL = parsedAccent.coords[ 2 ] ?? 0;\n\n\t// Create darker version of accent \u2014\n\tconst darker10 = set(\n\t\tclone( parsedAccent ),\n\t\t[ HSL, 'l' ],\n\t\tMath.max( 0, parsedL - 5 ) // L reduced by 5%\n\t);\n\tconst darker20 = set(\n\t\tclone( parsedAccent ),\n\t\t[ HSL, 'l' ],\n\t\tMath.max( 0, parsedL - 10 ) // L reduced by 10%\n\t);\n\n\treturn [\n\t\t[ '--wp-admin-theme-color', getColorString( parsedAccent ) ],\n\t\t[ '--wp-admin-theme-color--rgb', customRgbFormat( parsedAccent ) ],\n\t\t[ '--wp-admin-theme-color-darker-10', getColorString( darker10 ) ],\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[ '--wp-admin-theme-color-darker-20', getColorString( darker20 ) ],\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 colorTokensCSS(\n\tcomputedColorRamps: Map< string, RampResult >\n): Entry[] {\n\tconst entries: Entry[] = [];\n\n\tfor ( const [ rampName, { ramp } ] of computedColorRamps ) {\n\t\tfor ( const [ tokenName, tokenValue ] of Object.entries( ramp ) ) {\n\t\t\tconst key = `${ rampName }-${ tokenName }`;\n\t\t\tconst aliasedBy = colorTokens[ key ] ?? [];\n\t\t\tfor ( const aliasedId of aliasedBy ) {\n\t\t\t\tentries.push( [ `--wpds-color-${ aliasedId }`, tokenValue ] );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\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// Semantic color tokens\n\t\t\tcolorTokensCSS( computedColorRamps ),\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 = getCachedBgRamp( 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\tgetCachedAccentRamp( seed, bgRamp )\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": "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",
6
+ "names": []
7
+ }
@@ -23,5 +23,5 @@ export declare function getContrast(colorA: ColorTypes, colorB: ColorTypes): num
23
23
  * Make sure that a color is valid in the sRGB gamut and convert it to OKLCH.
24
24
  * @param c
25
25
  */
26
- export declare function clampToGamut(c: ColorTypes): import("colorjs.io/fn").PlainColorObject;
26
+ export declare function clampToGamut(c: ColorTypes): import("colorjs.io/src/color.js").PlainColorObject;
27
27
  //# sourceMappingURL=color-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/color-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAON,KAAK,UAAU,EACf,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,cAAc,CAAE,KAAK,EAAE,UAAU,GAAI,MAAM,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAI,MAAM,CAE5E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAE,CAAC,EAAE,UAAU,4CAG1C"}
1
+ {"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/color-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAON,KAAK,UAAU,EACf,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,cAAc,CAAE,KAAK,EAAE,UAAU,GAAI,MAAM,CAG1D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAI,MAAM,CAE5E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAE,CAAC,EAAE,UAAU,sDAG1C"}
@@ -3,8 +3,8 @@
3
3
  */
4
4
  import './register-color-spaces';
5
5
  import type { Ramp } from './types';
6
- export declare const WHITE: import("colorjs.io/fn").PlainColorObject;
7
- export declare const BLACK: import("colorjs.io/fn").PlainColorObject;
6
+ export declare const WHITE: import("colorjs.io/src/color.js").PlainColorObject;
7
+ export declare const BLACK: import("colorjs.io/src/color.js").PlainColorObject;
8
8
  export declare const UNIVERSAL_CONTRAST_TOPUP = 0.02;
9
9
  export declare const WHITE_TEXT_CONTRAST_MARGIN = 3.1;
10
10
  export declare const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS: {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/constants.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,eAAO,MAAM,KAAK,0CAAuB,CAAC;AAC1C,eAAO,MAAM,KAAK,0CAAuB,CAAC;AAM1C,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAO7C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAO9C,eAAO,MAAM,sCAAsC;;;;;;;;;CAGzC,CAAC;AAGX,eAAO,MAAM,gBAAgB,QAAO,CAAC;AAErC,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;;;;;;;;CAQ/B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/constants.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,eAAO,MAAM,KAAK,oDAAuB,CAAC;AAC1C,eAAO,MAAM,KAAK,oDAAuB,CAAC;AAM1C,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAO7C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAO9C,eAAO,MAAM,sCAAsC;;;;;;;;;CAGzC,CAAC;AAGX,eAAO,MAAM,gBAAgB,QAAO,CAAC;AAErC,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;;;;;;;;CAQ/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/index.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAWjC,OAAO,KAAK,EAEX,IAAI,EACJ,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,SAAS,CAAC;AA6KjB,wBAAgB,SAAS,CACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,EAClB,EACC,aAAa,EACb,YAAY,EACZ,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;CACjC,GACJ,UAAU,CAgHZ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/index.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAWjC,OAAO,KAAK,EAEX,IAAI,EACJ,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,SAAS,CAAC;AA6KjB,wBAAgB,SAAS,CACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,EAClB,EACC,aAAa,EACb,YAAY,EACZ,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;CACjC,GACJ,UAAU,CAgHZ"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import type { Meta, StoryObj } from '@storybook/react';
4
+ import type { Meta, StoryObj } from '@storybook/react-vite';
5
5
  declare const ColorGen: (props: {
6
6
  background: string;
7
7
  primary: string;
@@ -1 +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,GAAK,OAAO;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,CA+H9C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAE,OAAO,QAAQ,CA4FzD,CAAC"}
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,uBAAuB,CAAC;AAS5D,QAAA,MAAM,QAAQ,GAAK,OAAO;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,CA+H9C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAE,OAAO,QAAQ,CA4FzD,CAAC"}
@@ -1,3 +1,3 @@
1
1
  declare const _default: string[];
2
2
  export default _default;
3
- //# sourceMappingURL=design-tokens.d.ts.map
3
+ //# sourceMappingURL=design-tokens.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-tokens.d.mts","sourceRoot":"","sources":["../../../src/prebuilt/js/design-tokens.mjs"],"names":[],"mappings":""}
@@ -1,7 +1,3 @@
1
- /**
2
- * This file is generated by the @wordpress/terrazzo-plugin-inline-alias-values plugin.
3
- * Do not edit this file directly.
4
- */
5
1
  declare const _default: Record<string, string[]>;
6
2
  export default _default;
7
3
  //# sourceMappingURL=color-tokens.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-tokens.d.ts","sourceRoot":"","sources":["../../../src/prebuilt/ts/color-tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG;wBAuIE,MAAM,CAAE,MAAM,EAAE,MAAM,EAAE,CAAE;AArI/B,wBAqIgC"}
1
+ {"version":3,"file":"color-tokens.d.ts","sourceRoot":"","sources":["../../../src/prebuilt/ts/color-tokens.ts"],"names":[],"mappings":"wBAsHK,MAAM,CAAE,MAAM,EAAE,MAAM,EAAE,CAAE;AAjH/B,wBAiHgC"}
@@ -1,7 +1,3 @@
1
- /**
2
- * This file is generated by the @wordpress/terrazzo-plugin-typescript-types plugin.
3
- * Do not edit this file directly.
4
- */
5
1
  /**
6
2
  * Size scale for padding tokens.
7
3
  */
@@ -29,7 +25,7 @@ export type SurfaceBackgroundColor = 'neutral' | 'neutral-strong' | 'neutral-wea
29
25
  /**
30
26
  * Background color variants for interactive elements.
31
27
  */
32
- export type InteractiveBackgroundColor = 'neutral' | 'neutral-strong' | 'neutral-weak' | 'brand' | 'brand-strong' | 'brand-weak' | 'error' | 'error-strong' | 'error-weak';
28
+ export type InteractiveBackgroundColor = 'neutral-strong' | 'neutral-weak' | 'brand-strong' | 'brand-weak' | 'error' | 'error-strong' | 'error-weak';
33
29
  /**
34
30
  * Foreground color variants for content text and icons.
35
31
  */
@@ -46,4 +42,24 @@ export type SurfaceStrokeColor = 'neutral' | 'neutral-weak' | 'neutral-strong' |
46
42
  * Stroke color variants for interactive element borders.
47
43
  */
48
44
  export type InteractiveStrokeColor = 'neutral' | 'neutral-strong' | 'brand' | 'error' | 'error-strong';
45
+ /**
46
+ * Foreground color variants for text elements.
47
+ */
48
+ export type ForegroundColor = 'neutral' | 'neutral-weak' | 'success' | 'success-weak' | 'info' | 'info-weak' | 'warning' | 'warning-weak' | 'caution' | 'caution-weak' | 'error' | 'error-weak' | 'neutral-active' | 'neutral-disabled' | 'neutral-strong' | 'neutral-strong-active' | 'neutral-strong-disabled' | 'neutral-weak-disabled' | 'brand' | 'brand-active' | 'brand-strong' | 'brand-strong-active' | 'error-active' | 'error-strong' | 'error-strong-active';
49
+ /**
50
+ * Font family variants.
51
+ */
52
+ export type FontFamily = 'heading' | 'body' | 'mono';
53
+ /**
54
+ * Font size scale.
55
+ */
56
+ export type FontSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
57
+ /**
58
+ * Font weight variants.
59
+ */
60
+ export type FontWeight = 'regular' | 'medium';
61
+ /**
62
+ * Line height scale.
63
+ */
64
+ export type LineHeight = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
49
65
  //# sourceMappingURL=token-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-types.d.ts","sourceRoot":"","sources":["../../../src/prebuilt/ts/token-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,MAAM,GACf,SAAS,GACT,aAAa,GACb,OAAO,GACP,OAAO,GACP,SAAS,GACT,OAAO,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC/B,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,SAAS,GACT,cAAc,GACd,MAAM,GACN,WAAW,GACX,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,OAAO,GACP,YAAY,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACnC,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,cAAc,GACd,YAAY,GACZ,OAAO,GACP,cAAc,GACd,YAAY,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC/B,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,MAAM,GACN,WAAW,GACX,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,OAAO,GACP,YAAY,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACnC,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,cAAc,GACd,OAAO,GACP,cAAc,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC3B,SAAS,GACT,cAAc,GACd,gBAAgB,GAChB,OAAO,GACP,cAAc,GACd,SAAS,GACT,gBAAgB,GAChB,MAAM,GACN,aAAa,GACb,SAAS,GACT,gBAAgB,GAChB,OAAO,GACP,cAAc,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC/B,SAAS,GACT,gBAAgB,GAChB,OAAO,GACP,OAAO,GACP,cAAc,CAAC"}
1
+ {"version":3,"file":"token-types.d.ts","sourceRoot":"","sources":["../../../src/prebuilt/ts/token-types.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,MAAM,GACf,SAAS,GACT,aAAa,GACb,OAAO,GACP,OAAO,GACP,SAAS,GACT,OAAO,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC/B,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,SAAS,GACT,cAAc,GACd,MAAM,GACN,WAAW,GACX,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,OAAO,GACP,YAAY,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACnC,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,YAAY,GACZ,OAAO,GACP,cAAc,GACd,YAAY,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC/B,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,MAAM,GACN,WAAW,GACX,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,OAAO,GACP,YAAY,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACnC,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,cAAc,GACd,OAAO,GACP,cAAc,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC3B,SAAS,GACT,cAAc,GACd,gBAAgB,GAChB,OAAO,GACP,cAAc,GACd,SAAS,GACT,gBAAgB,GAChB,MAAM,GACN,aAAa,GACb,SAAS,GACT,gBAAgB,GAChB,OAAO,GACP,cAAc,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC/B,SAAS,GACT,gBAAgB,GAChB,OAAO,GACP,OAAO,GACP,cAAc,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,eAAe,GACxB,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,MAAM,GACN,WAAW,GACX,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,OAAO,GACP,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,GAChB,uBAAuB,GACvB,yBAAyB,GACzB,uBAAuB,GACvB,OAAO,GACP,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,cAAc,GACd,cAAc,GACd,qBAAqB,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import type { Meta, StoryObj } from '@storybook/react';
4
+ import type { Meta, StoryObj } from '@storybook/react-vite';
5
5
  /**
6
6
  * Internal dependencies
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAavD;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,mCAAmC,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,aAAa,CAgBrC,CAAC;AACF,eAAe,IAAI,CAAC;AA2GpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,aAAa,CAInD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAE,OAAO,aAAa,CA+CtD,CAAC;AA6CF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAE,OAAO,aAAa,CA8DhE,CAAC;AA0EF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAE,OAAO,aAAa,CA6CzD,CAAC"}
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAa5D;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,mCAAmC,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,aAAa,CAgBrC,CAAC;AACF,eAAe,IAAI,CAAC;AA2GpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,aAAa,CAInD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAE,OAAO,aAAa,CA+CtD,CAAC;AA6CF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAE,OAAO,aAAa,CA8DhE,CAAC;AA0EF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAE,OAAO,aAAa,CA6CzD,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare const _default: stylelint.Plugin;
2
+ export default _default;
3
+ import stylelint from 'stylelint';
4
+ //# sourceMappingURL=no-setting-wpds-custom-properties.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-setting-wpds-custom-properties.d.mts","sourceRoot":"","sources":["../../src/stylelint-plugins/no-setting-wpds-custom-properties.mjs"],"names":[],"mappings":";;sBAAsB,WAAW"}
@@ -0,0 +1,4 @@
1
+ declare const _default: stylelint.Plugin;
2
+ export default _default;
3
+ import stylelint from 'stylelint';
4
+ //# sourceMappingURL=no-unknown-ds-tokens.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unknown-ds-tokens.d.mts","sourceRoot":"","sources":["../../src/stylelint-plugins/no-unknown-ds-tokens.mjs"],"names":[],"mappings":";;sBAAsB,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-theme-provider-styles.d.ts","sourceRoot":"","sources":["../src/use-theme-provider-styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAiB3C;;GAEG;AACH,OAAO,yCAAyC,CAAC;AASjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA8JlD,wBAAgB,sBAAsB,CAAE,EACvC,KAAU,GACV,GAAE;IACF,KAAK,CAAC,EAAE,kBAAkB,CAAE,OAAO,CAAE,CAAC;CACjC;;;;;;;;EAwDL"}
1
+ {"version":3,"file":"use-theme-provider-styles.d.ts","sourceRoot":"","sources":["../src/use-theme-provider-styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAgB3C;;GAEG;AACH,OAAO,yCAAyC,CAAC;AAUjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA0IlD,wBAAgB,sBAAsB,CAAE,EACvC,KAAU,GACV,GAAE;IACF,KAAK,CAAC,EAAE,kBAAkB,CAAE,OAAO,CAAE,CAAC;CACjC;;;;;;;;EAwDL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/theme",
3
- "version": "0.4.1-next.8fd3f8831.0",
3
+ "version": "0.5.0",
4
4
  "description": "Theme and context provider for the WordPress Design System.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -29,17 +29,30 @@
29
29
  "build-types",
30
30
  "*.md"
31
31
  ],
32
- "type": "module",
33
32
  "main": "build/index.cjs",
34
- "module": "build-module/index.js",
33
+ "module": "build-module/index.mjs",
35
34
  "exports": {
36
35
  ".": {
37
36
  "types": "./build-types/index.d.ts",
38
- "import": "./build-module/index.js",
37
+ "import": "./build-module/index.mjs",
39
38
  "default": "./build/index.cjs"
40
39
  },
41
40
  "./design-tokens.css": "./src/prebuilt/css/design-tokens.css",
42
- "./design-tokens.js": "./src/prebuilt/js/design-tokens.js",
41
+ "./design-tokens.js": {
42
+ "types": "./build-types/prebuilt/js/design-tokens.d.ts",
43
+ "import": "./build-module/prebuilt/js/design-tokens.mjs",
44
+ "default": "./build/prebuilt/js/design-tokens.cjs"
45
+ },
46
+ "./stylelint-plugins/no-unknown-ds-tokens": {
47
+ "types": "./build-types/stylelint-plugins/no-unknown-ds-tokens.d.ts",
48
+ "import": "./src/stylelint-plugins/no-unknown-ds-tokens.mjs",
49
+ "default": "./build/stylelint-plugins/no-unknown-ds-tokens.cjs"
50
+ },
51
+ "./stylelint-plugins/no-setting-wpds-custom-properties": {
52
+ "types": "./build-types/stylelint-plugins/no-setting-wpds-custom-properties.d.ts",
53
+ "import": "./src/stylelint-plugins/no-setting-wpds-custom-properties.mjs",
54
+ "default": "./build/stylelint-plugins/no-setting-wpds-custom-properties.cjs"
55
+ },
43
56
  "./package.json": "./package.json"
44
57
  },
45
58
  "react-native": "src/index",
@@ -48,29 +61,45 @@
48
61
  "sideEffects": [
49
62
  "src/color-ramps/lib/register-color-spaces.ts",
50
63
  "build/color-ramps/lib/register-color-spaces.js",
51
- "build-module/color-ramps/lib/register-color-spaces.js"
64
+ "build-module/color-ramps/lib/register-color-spaces.mjs"
52
65
  ],
53
66
  "dependencies": {
54
- "@wordpress/element": "^6.36.1-next.8fd3f8831.0",
55
- "@wordpress/private-apis": "^1.36.1-next.8fd3f8831.0",
56
- "colorjs.io": "^0.5.2",
67
+ "@wordpress/element": "^6.38.0",
68
+ "@wordpress/private-apis": "^1.38.0",
69
+ "colorjs.io": "^0.6.0",
57
70
  "memize": "^2.1.0"
58
71
  },
59
72
  "devDependencies": {
60
- "esbuild-esm-loader": "0.3.3"
73
+ "@storybook/react-vite": "^10.1.11",
74
+ "@terrazzo/cli": "^0.10.2",
75
+ "@terrazzo/plugin-css": "^0.10.2",
76
+ "@terrazzo/token-tools": "^0.10.2",
77
+ "@testing-library/jest-dom": "^6.6.3",
78
+ "@types/jest": "^29.5.14",
79
+ "@types/node": "^20.17.10",
80
+ "esbuild": "^0.27.2",
81
+ "esbuild-esm-loader": "^0.3.3",
82
+ "storybook": "^10.1.11"
61
83
  },
62
84
  "peerDependencies": {
63
85
  "react": "^18.0.0",
64
- "react-dom": "^18.0.0"
86
+ "react-dom": "^18.0.0",
87
+ "stylelint": "^16.8.2"
88
+ },
89
+ "peerDependenciesMeta": {
90
+ "stylelint": {
91
+ "optional": true
92
+ }
65
93
  },
66
94
  "publishConfig": {
67
95
  "access": "public"
68
96
  },
69
97
  "scripts": {
98
+ "prelint:js": "npx esbuild src/prebuilt/js/design-tokens.mjs --format=cjs --outfile=build/prebuilt/js/design-tokens.cjs && node -e \"\"",
70
99
  "build:default-ramps": "node --import=esbuild-esm-loader/register bin/generate-default-ramps/index.ts",
71
100
  "build:tokens": "node --import=esbuild-esm-loader/register bin/generate-primitive-tokens/index.ts && cross-env NODE_OPTIONS=--import=esbuild-esm-loader/register tz build --config terrazzo.config.ts",
72
- "build": "npm run build:tokens && npm run build:default-ramps",
101
+ "build": "npm run build:tokens && npm run build:default-ramps && npm run prelint:js",
73
102
  "postbuild": "prettier --write tokens/color.json tokens/modes src/prebuilt src/color-ramps/lib/default-ramps.ts docs"
74
103
  },
75
- "gitHead": "e582b351bc4c4b8734bb087f63a3beec9875c3c7"
104
+ "gitHead": "50c4c0f51e4797c217946ce42adfaa5eb026f33f"
76
105
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get, OKLCH, parse } from 'colorjs.io/fn';
4
+ import { get, OKLCH } from 'colorjs.io/fn';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -44,7 +44,7 @@ function getBgRampInfo( ramp: InternalRampResult ): {
44
44
  pinLightness: {
45
45
  stepName: STEP_TO_PIN,
46
46
  value: clampAccentScaleReferenceLightness(
47
- get( parse( ramp.ramp[ STEP_TO_PIN ] ), [ OKLCH, 'l' ] ),
47
+ get( ramp.ramp[ STEP_TO_PIN ], [ OKLCH, 'l' ] ),
48
48
  ramp.direction
49
49
  ),
50
50
  },
@@ -22,7 +22,8 @@ import './register-color-spaces';
22
22
  * @return String representation
23
23
  */
24
24
  export function getColorString( color: ColorTypes ): string {
25
- return serialize( to( color, sRGB ), { format: 'hex', inGamut: true } );
25
+ const rgbRounded = serialize( to( color, sRGB ) );
26
+ return serialize( rgbRounded, { format: 'hex' } );
26
27
  }
27
28
 
28
29
  /**
@@ -67,8 +67,8 @@ export const DEFAULT_RAMPS: Record<
67
67
  bgFill1: '#0090ff',
68
68
  fgFill: '#1a1f24',
69
69
  bgFill2: '#007fed',
70
- surface2: '#f3f9ff',
71
- surface6: '#bcd5f1',
70
+ surface2: '#f2f9ff',
71
+ surface6: '#bcd5f2',
72
72
  surface5: '#d3e4f7',
73
73
  surface4: '#deebfa',
74
74
  surface3: '#fff',
@@ -5,7 +5,6 @@ import {
5
5
  clone,
6
6
  get,
7
7
  OKLCH,
8
- parse,
9
8
  set,
10
9
  type ColorTypes,
11
10
  type PlainColorObject,
@@ -222,7 +221,7 @@ export function buildRamp(
222
221
  ): RampResult {
223
222
  let seed: PlainColorObject;
224
223
  try {
225
- seed = clampToGamut( parse( seedArg ) );
224
+ seed = clampToGamut( seedArg );
226
225
  } catch ( error ) {
227
226
  throw new Error(
228
227
  `Invalid seed color "${ seedArg }": ${
@@ -55,10 +55,10 @@ export function taperChroma(
55
55
  const achromaEpsilon = options.achromaEpsilon ?? 0.005;
56
56
 
57
57
  const cSeed = Math.max( 0, get( seed, [ OKLCH, 'c' ] ) );
58
- let hSeed = Number( get( seed, [ OKLCH, 'h' ] ) );
58
+ let hSeed = get( seed, [ OKLCH, 'h' ] );
59
59
 
60
60
  const chromaIsTiny = cSeed < achromaEpsilon;
61
- const hueIsInvalid = ! Number.isFinite( hSeed );
61
+ const hueIsInvalid = hSeed === null || ! Number.isFinite( hSeed );
62
62
 
63
63
  if ( chromaIsTiny || hueIsInvalid ) {
64
64
  if ( typeof options.hueFallback === 'number' ) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import type { Meta, StoryObj } from '@storybook/react';
4
+ import type { Meta, StoryObj } from '@storybook/react-vite';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -19,7 +19,7 @@ const ColorGen = ( props: {
19
19
  };
20
20
 
21
21
  const meta: Meta< typeof ColorGen > = {
22
- title: 'Design System/Theme Provider/Color Scales',
22
+ title: 'Design System/Theme/Theme Provider/Color Scales',
23
23
  component: ColorGen,
24
24
  argTypes: {
25
25
  background: {