@chaibuilder/sdk 2.0.9 → 2.0.10

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.
@@ -1,8 +1,9 @@
1
- import { isEmpty as $, uniq as b, keys as _, flatten as v } from "lodash-es";
1
+ import { getAllRegisteredFonts as y } from "@chaibuilder/runtime";
2
+ import { keys as _, flatten as b, get as v } from "lodash-es";
2
3
  function P(e) {
3
4
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
5
  }
5
- const k = {
6
+ const R = {
6
7
  fontFamily: {
7
8
  "font-heading": "Inter",
8
9
  "font-body": "Inter"
@@ -75,69 +76,69 @@ const k = {
75
76
  }
76
77
  ]
77
78
  };
78
- var l = {}, c = {}, p;
79
- function j() {
80
- return p || (p = 1, function(e) {
79
+ var l = {}, c = {}, g;
80
+ function h() {
81
+ return g || (g = 1, function(e) {
81
82
  Object.defineProperty(e, "__esModule", {
82
83
  value: !0
83
84
  }), Object.defineProperty(e, "default", {
84
85
  enumerable: !0,
85
86
  get: function() {
86
- return r;
87
+ return t;
87
88
  }
88
89
  });
89
- function n(t, o) {
90
+ function r(n, o) {
90
91
  return {
91
- handler: t,
92
+ handler: n,
92
93
  config: o
93
94
  };
94
95
  }
95
- n.withOptions = function(t, o = () => ({})) {
96
+ r.withOptions = function(n, o = () => ({})) {
96
97
  const u = function(a) {
97
98
  return {
98
99
  __options: a,
99
- handler: t(a),
100
+ handler: n(a),
100
101
  config: o(a)
101
102
  };
102
103
  };
103
- return u.__isOptionsFunction = !0, u.__pluginFunction = t, u.__configFunction = o, u;
104
+ return u.__isOptionsFunction = !0, u.__pluginFunction = n, u.__configFunction = o, u;
104
105
  };
105
- const r = n;
106
+ const t = r;
106
107
  }(c)), c;
107
108
  }
108
- var g;
109
- function C() {
110
- return g || (g = 1, function(e) {
109
+ var p;
110
+ function j() {
111
+ return p || (p = 1, function(e) {
111
112
  Object.defineProperty(e, "__esModule", {
112
113
  value: !0
113
114
  }), Object.defineProperty(e, "default", {
114
115
  enumerable: !0,
115
116
  get: function() {
116
- return t;
117
+ return n;
117
118
  }
118
119
  });
119
- const n = /* @__PURE__ */ r(j());
120
- function r(o) {
120
+ const r = /* @__PURE__ */ t(h());
121
+ function t(o) {
121
122
  return o && o.__esModule ? o : {
122
123
  default: o
123
124
  };
124
125
  }
125
- const t = n.default;
126
+ const n = r.default;
126
127
  }(l)), l;
127
128
  }
128
129
  var d, m;
129
- function E() {
130
+ function C() {
130
131
  if (m) return d;
131
132
  m = 1;
132
- let e = C();
133
+ let e = j();
133
134
  return d = (e.__esModule ? e : { default: e }).default, d;
134
135
  }
135
- var M = E();
136
- const B = /* @__PURE__ */ P(M), R = (e) => ({
136
+ var M = C();
137
+ const S = /* @__PURE__ */ P(M), k = (e) => ({
137
138
  fontFamily: e.fontFamily ? _(e.fontFamily).reduce(
138
- (r, t) => ({
139
- ...r,
140
- [t.replace("font-", "")]: `var(--${t})`
139
+ (t, n) => ({
140
+ ...t,
141
+ [n.replace("font-", "")]: `var(--${n})`
141
142
  }),
142
143
  {}
143
144
  ) : {},
@@ -146,56 +147,70 @@ const B = /* @__PURE__ */ P(M), R = (e) => ({
146
147
  md: "calc(var(--radius) - 2px)",
147
148
  sm: "calc(var(--radius) - 4px)"
148
149
  } : {},
149
- colors: e.colors ? v(e.colors.map((r) => Object.entries(r.items))).reduce(
150
- (r, [t]) => ({ ...r, [t]: `hsl(var(--${t}))` }),
150
+ colors: e.colors ? b(e.colors.map((t) => Object.entries(t.items))).reduce(
151
+ (t, [n]) => ({ ...t, [n]: `hsl(var(--${n}))` }),
151
152
  {}
152
153
  ) : {}
153
154
  });
154
- function y(e) {
155
- const n = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
156
- let r = parseInt(n[1], 16), t = parseInt(n[2], 16), o = parseInt(n[3], 16);
157
- r /= 255, t /= 255, o /= 255;
158
- const u = Math.max(r, t, o), a = Math.min(r, t, o);
159
- let s, F;
155
+ function $(e) {
156
+ const r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
157
+ let t = parseInt(r[1], 16), n = parseInt(r[2], 16), o = parseInt(r[3], 16);
158
+ t /= 255, n /= 255, o /= 255;
159
+ const u = Math.max(t, n, o), a = Math.min(t, n, o);
160
+ let i, s;
160
161
  const f = (u + a) / 2;
161
162
  if (u == a)
162
- s = F = 0;
163
+ i = s = 0;
163
164
  else {
164
- const i = u - a;
165
- switch (F = f > 0.5 ? i / (2 - u - a) : i / (u + a), u) {
166
- case r:
167
- s = (t - o) / i + (t < o ? 6 : 0);
168
- break;
165
+ const F = u - a;
166
+ switch (s = f > 0.5 ? F / (2 - u - a) : F / (u + a), u) {
169
167
  case t:
170
- s = (o - r) / i + 2;
168
+ i = (n - o) / F + (n < o ? 6 : 0);
169
+ break;
170
+ case n:
171
+ i = (o - t) / F + 2;
171
172
  break;
172
173
  case o:
173
- s = (r - t) / i + 4;
174
+ i = (t - n) / F + 4;
174
175
  break;
175
176
  }
176
- s /= 6;
177
+ i /= 6;
177
178
  }
178
- return `${Math.round(s * 360)} ${Math.round(F * 100)}% ${Math.round(f * 100)}%`;
179
+ return `${Math.round(i * 360)} ${Math.round(s * 100)}% ${Math.round(f * 100)}%`;
179
180
  }
180
- const q = (e) => `:root {
181
- ${e.fontFamily && Object.entries(e.fontFamily).map(([n, r]) => `--font-${n}: "${r}";`).join(`
181
+ const E = (e) => {
182
+ const t = y().find((n) => n.name === e);
183
+ return v(t, "family", e);
184
+ }, q = (e) => `:root {
185
+ ${e.fontFamily && Object.entries(e.fontFamily).map(([r, t]) => `--font-${r}: ${E(t)};`).join(`
182
186
  `)}
183
187
  ${e.borderRadius && `--radius: ${e.borderRadius};`}
184
- ${e.colors && Object.entries(e.colors).map(([n, r]) => `--${n}: ${y(r[0])};`).join(`
188
+ ${e.colors && Object.entries(e.colors).map(([r, t]) => `--${r}: ${$(t[0])};`).join(`
185
189
  `)}
186
190
  }
187
191
  .dark {
188
- ${e.colors && Object.entries(e.colors).map(([n, r]) => `--${n}: ${y(r[1])};`).join(`
192
+ ${e.colors && Object.entries(e.colors).map(([r, t]) => `--${r}: ${$(t[1])};`).join(`
189
193
  `)}
190
- }`, I = (e) => $(e.fontFamily) ? "" : b(Object.entries(e.fontFamily).map(([, r]) => r)).map((r) => `<link rel="stylesheet" href="${`https://fonts.googleapis.com/css2?family=${r.replace(/\s+/g, "+")}&display=swap`}">`).join(`
191
- `), w = (e) => $(e.fontFamily) ? "" : b(Object.entries(e.fontFamily).map(([, r]) => r)).map((r) => `@import url("${`https://fonts.googleapis.com/css2?family=${r.replace(/\s+/g, "+")}&display=swap`}");`).join(`
194
+ }`, I = (e) => !e || e.length === 0 ? "" : e.map((r) => `<link rel="stylesheet" href="${r.url}" />`).join(`
195
+ `), A = (e) => !e || e.length === 0 ? "" : e.map((r) => `@import url("${r.url}");`).join(`
196
+ `), D = (e) => !e || e.length === 0 ? "" : e.map(
197
+ (r) => `@font-face {
198
+ font-family: "${r.family}";
199
+ src: ${r.src.map((t) => `url("${t.url}") format("${t.format}")`).join(", ")};
200
+ ${r.fontWeight ? `font-weight: ${r.fontWeight};` : ""}
201
+ ${r.fontStyle ? `font-style: ${r.fontStyle};` : ""}
202
+ ${r.fontDisplay ? `font-display: ${r.fontDisplay};` : ""}
203
+ ${r.fontStretch ? `font-stretch: ${r.fontStretch};` : ""}
204
+ }`
205
+ ).join(`
192
206
  `);
193
207
  export {
194
208
  q as a,
195
- w as b,
209
+ A as b,
196
210
  I as c,
197
- k as d,
211
+ R as d,
198
212
  P as e,
199
- R as g,
200
- B as p
213
+ D as f,
214
+ k as g,
215
+ S as p
201
216
  };
@@ -0,0 +1,21 @@
1
+ "use strict";const _=require("@chaibuilder/runtime"),f=require("lodash-es");function h(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const b={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]};var l={},c={},p;function v(){return p||(p=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});function r(n,o){return{handler:n,config:o}}r.withOptions=function(n,o=()=>({})){const u=function(i){return{__options:i,handler:n(i),config:o(i)}};return u.__isOptionsFunction=!0,u.__pluginFunction=n,u.__configFunction=o,u};const t=r}(c)),c}var m;function C(){return m||(m=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const r=t(v());function t(o){return o&&o.__esModule?o:{default:o}}const n=r.default}(l)),l}var d,$;function P(){if($)return d;$=1;let e=C();return d=(e.__esModule?e:{default:e}).default,d}var j=P();const E=h(j),M=e=>({fontFamily:e.fontFamily?f.keys(e.fontFamily).reduce((t,n)=>({...t,[n.replace("font-","")]:`var(--${n})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?f.flatten(e.colors.map(t=>Object.entries(t.items))).reduce((t,[n])=>({...t,[n]:`hsl(var(--${n}))`}),{}):{}});function y(e){const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let t=parseInt(r[1],16),n=parseInt(r[2],16),o=parseInt(r[3],16);t/=255,n/=255,o/=255;const u=Math.max(t,n,o),i=Math.min(t,n,o);let a,s;const g=(u+i)/2;if(u==i)a=s=0;else{const F=u-i;switch(s=g>.5?F/(2-u-i):F/(u+i),u){case t:a=(n-o)/F+(n<o?6:0);break;case n:a=(o-t)/F+2;break;case o:a=(t-n)/F+4;break}a/=6}return`${Math.round(a*360)} ${Math.round(s*100)}% ${Math.round(g*100)}%`}const O=e=>{const t=_.getAllRegisteredFonts().find(n=>n.name===e);return f.get(t,"family",e)},B=e=>`:root {
2
+ ${e.fontFamily&&Object.entries(e.fontFamily).map(([r,t])=>`--font-${r}: ${O(t)};`).join(`
3
+ `)}
4
+ ${e.borderRadius&&`--radius: ${e.borderRadius};`}
5
+ ${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${y(t[0])};`).join(`
6
+ `)}
7
+ }
8
+ .dark {
9
+ ${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${y(t[1])};`).join(`
10
+ `)}
11
+ }`,R=e=>!e||e.length===0?"":e.map(r=>`<link rel="stylesheet" href="${r.url}" />`).join(`
12
+ `),S=e=>!e||e.length===0?"":e.map(r=>`@import url("${r.url}");`).join(`
13
+ `),k=e=>!e||e.length===0?"":e.map(r=>`@font-face {
14
+ font-family: "${r.family}";
15
+ src: ${r.src.map(t=>`url("${t.url}") format("${t.format}")`).join(", ")};
16
+ ${r.fontWeight?`font-weight: ${r.fontWeight};`:""}
17
+ ${r.fontStyle?`font-style: ${r.fontStyle};`:""}
18
+ ${r.fontDisplay?`font-display: ${r.fontDisplay};`:""}
19
+ ${r.fontStretch?`font-stretch: ${r.fontStretch};`:""}
20
+ }`).join(`
21
+ `);exports.defaultThemeOptions=b;exports.getChaiThemeCssVariables=B;exports.getChaiThemeOptions=M;exports.getDefaultExportFromCjs=h;exports.getThemeCustomFontFace=k;exports.getThemeFontsCSSImport=S;exports.getThemeFontsLinkMarkup=R;exports.plugin=E;