@rojaostudio/ds-core 1.1.0-next.0 → 1.1.0-next.1

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.
@@ -681,16 +681,25 @@ var WHITE = "#ffffff";
681
681
  var BLACK = "#000000";
682
682
  var black = (pct) => BLACK + Math.round(pct / 100 * 255).toString(16).padStart(2, "0");
683
683
  var white = (pct) => WHITE + Math.round(pct / 100 * 255).toString(16).padStart(2, "0");
684
- function palette(name) {
684
+ function palette(name, custom) {
685
+ const own = custom == null ? void 0 : custom[name];
686
+ if (typeof own === "string") {
687
+ if (!isHex(own)) throw new Error(`rdsTheme: palette "${name}" is not a hex colour`);
688
+ return buildScale(own);
689
+ }
690
+ if (own) return own;
685
691
  const p = palettes[name];
686
692
  if (!p || typeof p === "string") throw new Error(`rdsTheme: unknown palette "${name}"`);
687
693
  return p;
688
694
  }
689
- function ramp(c) {
695
+ function ramp(c, custom) {
690
696
  var _a;
691
697
  if (isHex(c)) return { base: c, scale: buildScale(c) };
692
- const m = c.match(/^([a-zA-Z]+)-(\d{2,3})$/);
693
- if (m) return { base: (_a = refToHex(c)) != null ? _a : palette(m[1])[Number(m[2])], scale: palette(m[1]) };
698
+ const m = c.match(/^([a-zA-Z][a-zA-Z0-9]*)-(\d{2,3})$/);
699
+ if (m) {
700
+ const scale = palette(m[1], custom);
701
+ return { base: (_a = scale[Number(m[2])]) != null ? _a : refToHex(c), scale };
702
+ }
694
703
  const hex = refToHex(c);
695
704
  if (!hex) throw new Error(`rdsTheme: cannot resolve colour "${c}"`);
696
705
  return { base: hex, scale: buildScale(hex) };
@@ -806,15 +815,16 @@ var lighterStep = (s) => s - 100 ;
806
815
  var roleVar = (role) => `--${role.replaceAll("/", "-")}`;
807
816
  function generateRdsTheme(def) {
808
817
  const b = def.brand;
809
- const P = ramp(b.primary);
810
- const S = b.secondary ? ramp(b.secondary) : P;
811
- const A = b.accent ? ramp(b.accent) : P;
812
- const N = palette(def.text && palettes[def.text] && typeof palettes[def.text] !== "string" ? def.text : "zinc");
818
+ const own = def.palettes;
819
+ const P = ramp(b.primary, own);
820
+ const S = b.secondary ? ramp(b.secondary, own) : P;
821
+ const A = b.accent ? ramp(b.accent, own) : P;
822
+ const N = def.text && ((own == null ? void 0 : own[def.text]) || palettes[def.text] && typeof palettes[def.text] !== "string") ? palette(def.text, own) : palette("zinc");
813
823
  const L = palette("blue");
814
824
  const red = palette("red"), green = palette("green"), orange = palette("orange");
815
825
  const teal = palette("teal"), purple = palette("purple");
816
- const heading = b.heading ? ramp(b.heading).base : P.base;
817
- const invert = b.invert ? ramp(b.invert).base : WHITE;
826
+ const heading = b.heading ? ramp(b.heading, own).base : P.base;
827
+ const invert = b.invert ? ramp(b.invert, own).base : WHITE;
818
828
  const l = {
819
829
  "colors/primary/light": P.scale[500],
820
830
  "colors/primary/default": P.base,
package/dist/generate.js CHANGED
@@ -1,3 +1,3 @@
1
- export { ROLES as RDS_ROLES, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, onColor, rdsContrast, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-CFCKPKAF.js';
1
+ export { ROLES as RDS_ROLES, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, onColor, rdsContrast, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-CFOS2RAD.js';
2
2
  import './chunk-FRWRLCYM.js';
3
3
  import './chunk-ORMEWXMH.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { recipes } from './chunk-3QTDO2HW.js';
2
- export { ROLES as RDS_ROLES, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, onColor, rdsContrast, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-CFCKPKAF.js';
2
+ export { ROLES as RDS_ROLES, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, onColor, rdsContrast, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-CFOS2RAD.js';
3
3
  export { primitives, tokens } from './chunk-FRWRLCYM.js';
4
4
  import './chunk-ORMEWXMH.js';
package/dist/themes.js CHANGED
@@ -1,4 +1,4 @@
1
- import { generateTheme } from './chunk-CFCKPKAF.js';
1
+ import { generateTheme } from './chunk-CFOS2RAD.js';
2
2
  import './chunk-FRWRLCYM.js';
3
3
  import { __spreadValues, __objRest } from './chunk-ORMEWXMH.js';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rojaostudio/ds-core",
3
- "version": "1.1.0-next.0",
3
+ "version": "1.1.0-next.1",
4
4
  "description": "O motor do Rojão DS — tokens, derivação de tema e emissores. Sem React, sem Tailwind, sem CSS.",
5
5
  "license": "MIT",
6
6
  "author": "Rojão Studio (https://rojao.studio)",
@@ -68,7 +68,7 @@
68
68
  "publishConfig": {
69
69
  "registry": "https://registry.npmjs.org",
70
70
  "access": "public",
71
- "provenance": false
71
+ "provenance": true
72
72
  },
73
73
  "scripts": {
74
74
  "build": "tsup",