@chaibuilder/sdk 2.2.1 → 2.2.3

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