@chaibuilder/sdk 2.0.9 → 2.0.11

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,5 +1,6 @@
1
- import { isEmpty as $, uniq as b, keys as _, flatten as v } from "lodash-es";
2
- function P(e) {
1
+ import { getAllRegisteredFonts as _ } from "@chaibuilder/runtime";
2
+ import { uniqBy as c, keys as b, flatten as v, get as P } from "lodash-es";
3
+ function h(e) {
3
4
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
5
  }
5
6
  const k = {
@@ -75,7 +76,7 @@ const k = {
75
76
  }
76
77
  ]
77
78
  };
78
- var l = {}, c = {}, p;
79
+ var s = {}, d = {}, p;
79
80
  function j() {
80
81
  return p || (p = 1, function(e) {
81
82
  Object.defineProperty(e, "__esModule", {
@@ -86,58 +87,58 @@ function j() {
86
87
  return r;
87
88
  }
88
89
  });
89
- function n(t, o) {
90
+ function t(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
+ t.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
- }(c)), c;
106
+ const r = t;
107
+ }(d)), d;
107
108
  }
108
- var g;
109
+ var m;
109
110
  function C() {
110
- return g || (g = 1, function(e) {
111
+ return m || (m = 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
+ const t = /* @__PURE__ */ r(j());
120
121
  function r(o) {
121
122
  return o && o.__esModule ? o : {
122
123
  default: o
123
124
  };
124
125
  }
125
- const t = n.default;
126
- }(l)), l;
126
+ const n = t.default;
127
+ }(s)), s;
127
128
  }
128
- var d, m;
129
- function E() {
130
- if (m) return d;
131
- m = 1;
129
+ var f, $;
130
+ function M() {
131
+ if ($) return f;
132
+ $ = 1;
132
133
  let e = C();
133
- return d = (e.__esModule ? e : { default: e }).default, d;
134
+ return f = (e.__esModule ? e : { default: e }).default, f;
134
135
  }
135
- var M = E();
136
- const B = /* @__PURE__ */ P(M), R = (e) => ({
137
- fontFamily: e.fontFamily ? _(e.fontFamily).reduce(
138
- (r, t) => ({
136
+ var B = M();
137
+ const q = /* @__PURE__ */ h(B), S = (e) => ({
138
+ fontFamily: e.fontFamily ? b(e.fontFamily).reduce(
139
+ (r, n) => ({
139
140
  ...r,
140
- [t.replace("font-", "")]: `var(--${t})`
141
+ [n.replace("font-", "")]: `var(--${n})`
141
142
  }),
142
143
  {}
143
144
  ) : {},
@@ -147,55 +148,72 @@ const B = /* @__PURE__ */ P(M), R = (e) => ({
147
148
  sm: "calc(var(--radius) - 4px)"
148
149
  } : {},
149
150
  colors: e.colors ? v(e.colors.map((r) => Object.entries(r.items))).reduce(
150
- (r, [t]) => ({ ...r, [t]: `hsl(var(--${t}))` }),
151
+ (r, [n]) => ({ ...r, [n]: `hsl(var(--${n}))` }),
151
152
  {}
152
153
  ) : {}
153
154
  });
154
155
  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;
160
- const f = (u + a) / 2;
156
+ const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
157
+ let r = parseInt(t[1], 16), n = parseInt(t[2], 16), o = parseInt(t[3], 16);
158
+ r /= 255, n /= 255, o /= 255;
159
+ const u = Math.max(r, n, o), a = Math.min(r, n, o);
160
+ let i, l;
161
+ const g = (u + a) / 2;
161
162
  if (u == a)
162
- s = F = 0;
163
+ i = l = 0;
163
164
  else {
164
- const i = u - a;
165
- switch (F = f > 0.5 ? i / (2 - u - a) : i / (u + a), u) {
165
+ const F = u - a;
166
+ switch (l = g > 0.5 ? F / (2 - u - a) : F / (u + a), u) {
166
167
  case r:
167
- s = (t - o) / i + (t < o ? 6 : 0);
168
+ i = (n - o) / F + (n < o ? 6 : 0);
168
169
  break;
169
- case t:
170
- s = (o - r) / i + 2;
170
+ case n:
171
+ i = (o - r) / F + 2;
171
172
  break;
172
173
  case o:
173
- s = (r - t) / i + 4;
174
+ i = (r - 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(l * 100)}% ${Math.round(g * 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 r = _().find((n) => n.family === e);
183
+ return `"${e}", ${P(r, "fallback", "")}`;
184
+ }, I = (e) => `:root {
185
+ ${e.fontFamily && Object.entries(e.fontFamily).map(([t, r]) => `--font-${t}: ${E(r)};`).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(([t, r]) => `--${t}: ${y(r[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(([t, r]) => `--${t}: ${y(r[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
+ }`, w = (e) => !e || e.length === 0 ? "" : c(e, "family").map((t) => `<link rel="stylesheet" href="${t.url}" />`).join(`
195
+ `), A = (e) => !e || e.length === 0 ? "" : c(e, "family").map((t) => `@import url("${t.url}");`).join(`
196
+ `), x = (e) => !e || e.length === 0 ? "" : c(e, "family").map(
197
+ (t) => t.src.map(
198
+ (r) => `@font-face {
199
+ font-family: "${t.family}";
200
+ src: url("${r.url}") format("${r.format}");
201
+ font-display: swap;
202
+ ${r.fontWeight ? `font-weight: ${r.fontWeight};` : ""}
203
+ ${r.fontStyle ? `font-style: ${r.fontStyle};` : ""}
204
+ ${r.fontStretch ? `font-stretch: ${r.fontStretch};` : ""}
205
+ }`
206
+ ).join(`
207
+ `)
208
+ ).join(`
192
209
  `);
193
210
  export {
194
- q as a,
195
- w as b,
196
- I as c,
211
+ I as a,
212
+ A as b,
213
+ w as c,
197
214
  k as d,
198
- P as e,
199
- R as g,
200
- B as p
215
+ h as e,
216
+ x as f,
217
+ S as g,
218
+ q as p
201
219
  };
@@ -0,0 +1,22 @@
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 d={},c={},m;function v(){return m||(m=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 p;function C(){return p||(p=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}(d)),d}var f,y;function P(){if(y)return f;y=1;let e=C();return f=(e.__esModule?e:{default:e}).default,f}var j=P();const B=h(j),E=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 $(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 l=u-i;switch(s=g>.5?l/(2-u-i):l/(u+i),u){case t:a=(n-o)/l+(n<o?6:0);break;case n:a=(o-t)/l+2;break;case o:a=(t-n)/l+4;break}a/=6}return`${Math.round(a*360)} ${Math.round(s*100)}% ${Math.round(g*100)}%`}const M=e=>{const t=_.getAllRegisteredFonts().find(n=>n.family===e);return`"${e}", ${F.get(t,"fallback","")}`},q=e=>`:root {
2
+ ${e.fontFamily&&Object.entries(e.fontFamily).map(([r,t])=>`--font-${r}: ${M(t)};`).join(`
3
+ `)}
4
+ ${e.borderRadius&&`--radius: ${e.borderRadius};`}
5
+ ${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${$(t[0])};`).join(`
6
+ `)}
7
+ }
8
+ .dark {
9
+ ${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${$(t[1])};`).join(`
10
+ `)}
11
+ }`,O=e=>!e||e.length===0?"":F.uniqBy(e,"family").map(r=>`<link rel="stylesheet" href="${r.url}" />`).join(`
12
+ `),k=e=>!e||e.length===0?"":F.uniqBy(e,"family").map(r=>`@import url("${r.url}");`).join(`
13
+ `),R=e=>!e||e.length===0?"":F.uniqBy(e,"family").map(r=>r.src.map(t=>`@font-face {
14
+ font-family: "${r.family}";
15
+ src: url("${t.url}") format("${t.format}");
16
+ font-display: swap;
17
+ ${t.fontWeight?`font-weight: ${t.fontWeight};`:""}
18
+ ${t.fontStyle?`font-style: ${t.fontStyle};`:""}
19
+ ${t.fontStretch?`font-stretch: ${t.fontStretch};`:""}
20
+ }`).join(`
21
+ `)).join(`
22
+ `);exports.defaultThemeOptions=b;exports.getChaiThemeCssVariables=q;exports.getChaiThemeOptions=E;exports.getDefaultExportFromCjs=h;exports.getThemeCustomFontFace=R;exports.getThemeFontsCSSImport=k;exports.getThemeFontsLinkMarkup=O;exports.plugin=B;