@chaibuilder/sdk 2.0.10 → 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,9 +1,9 @@
1
- import { getAllRegisteredFonts as y } from "@chaibuilder/runtime";
2
- import { keys as _, flatten as b, get as v } from "lodash-es";
3
- 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) {
4
4
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5
5
  }
6
- const R = {
6
+ const k = {
7
7
  fontFamily: {
8
8
  "font-heading": "Inter",
9
9
  "font-body": "Inter"
@@ -76,24 +76,24 @@ const R = {
76
76
  }
77
77
  ]
78
78
  };
79
- var l = {}, c = {}, g;
80
- function h() {
81
- return g || (g = 1, function(e) {
79
+ var s = {}, d = {}, p;
80
+ function j() {
81
+ return p || (p = 1, function(e) {
82
82
  Object.defineProperty(e, "__esModule", {
83
83
  value: !0
84
84
  }), Object.defineProperty(e, "default", {
85
85
  enumerable: !0,
86
86
  get: function() {
87
- return t;
87
+ return r;
88
88
  }
89
89
  });
90
- function r(n, o) {
90
+ function t(n, o) {
91
91
  return {
92
92
  handler: n,
93
93
  config: o
94
94
  };
95
95
  }
96
- r.withOptions = function(n, o = () => ({})) {
96
+ t.withOptions = function(n, o = () => ({})) {
97
97
  const u = function(a) {
98
98
  return {
99
99
  __options: a,
@@ -103,12 +103,12 @@ function h() {
103
103
  };
104
104
  return u.__isOptionsFunction = !0, u.__pluginFunction = n, u.__configFunction = o, u;
105
105
  };
106
- const t = r;
107
- }(c)), c;
106
+ const r = t;
107
+ }(d)), d;
108
108
  }
109
- var p;
110
- function j() {
111
- return p || (p = 1, function(e) {
109
+ var m;
110
+ function C() {
111
+ return m || (m = 1, function(e) {
112
112
  Object.defineProperty(e, "__esModule", {
113
113
  value: !0
114
114
  }), Object.defineProperty(e, "default", {
@@ -117,27 +117,27 @@ function j() {
117
117
  return n;
118
118
  }
119
119
  });
120
- const r = /* @__PURE__ */ t(h());
121
- function t(o) {
120
+ const t = /* @__PURE__ */ r(j());
121
+ function r(o) {
122
122
  return o && o.__esModule ? o : {
123
123
  default: o
124
124
  };
125
125
  }
126
- const n = r.default;
127
- }(l)), l;
126
+ const n = t.default;
127
+ }(s)), s;
128
128
  }
129
- var d, m;
130
- function C() {
131
- if (m) return d;
132
- m = 1;
133
- let e = j();
134
- return d = (e.__esModule ? e : { default: e }).default, d;
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;
135
135
  }
136
- var M = C();
137
- const S = /* @__PURE__ */ P(M), k = (e) => ({
138
- fontFamily: e.fontFamily ? _(e.fontFamily).reduce(
139
- (t, n) => ({
140
- ...t,
136
+ var B = M();
137
+ const q = /* @__PURE__ */ h(B), S = (e) => ({
138
+ fontFamily: e.fontFamily ? b(e.fontFamily).reduce(
139
+ (r, n) => ({
140
+ ...r,
141
141
  [n.replace("font-", "")]: `var(--${n})`
142
142
  }),
143
143
  {}
@@ -147,70 +147,73 @@ const S = /* @__PURE__ */ P(M), k = (e) => ({
147
147
  md: "calc(var(--radius) - 2px)",
148
148
  sm: "calc(var(--radius) - 4px)"
149
149
  } : {},
150
- colors: e.colors ? b(e.colors.map((t) => Object.entries(t.items))).reduce(
151
- (t, [n]) => ({ ...t, [n]: `hsl(var(--${n}))` }),
150
+ colors: e.colors ? v(e.colors.map((r) => Object.entries(r.items))).reduce(
151
+ (r, [n]) => ({ ...r, [n]: `hsl(var(--${n}))` }),
152
152
  {}
153
153
  ) : {}
154
154
  });
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;
161
- const f = (u + a) / 2;
155
+ function y(e) {
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;
162
162
  if (u == a)
163
- i = s = 0;
163
+ i = l = 0;
164
164
  else {
165
165
  const F = u - a;
166
- switch (s = f > 0.5 ? F / (2 - u - a) : F / (u + a), u) {
167
- case t:
166
+ switch (l = g > 0.5 ? F / (2 - u - a) : F / (u + a), u) {
167
+ case r:
168
168
  i = (n - o) / F + (n < o ? 6 : 0);
169
169
  break;
170
170
  case n:
171
- i = (o - t) / F + 2;
171
+ i = (o - r) / F + 2;
172
172
  break;
173
173
  case o:
174
- i = (t - n) / F + 4;
174
+ i = (r - n) / F + 4;
175
175
  break;
176
176
  }
177
177
  i /= 6;
178
178
  }
179
- return `${Math.round(i * 360)} ${Math.round(s * 100)}% ${Math.round(f * 100)}%`;
179
+ return `${Math.round(i * 360)} ${Math.round(l * 100)}% ${Math.round(g * 100)}%`;
180
180
  }
181
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
+ 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(`
186
186
  `)}
187
187
  ${e.borderRadius && `--radius: ${e.borderRadius};`}
188
- ${e.colors && Object.entries(e.colors).map(([r, t]) => `--${r}: ${$(t[0])};`).join(`
188
+ ${e.colors && Object.entries(e.colors).map(([t, r]) => `--${t}: ${y(r[0])};`).join(`
189
189
  `)}
190
190
  }
191
191
  .dark {
192
- ${e.colors && Object.entries(e.colors).map(([r, t]) => `--${r}: ${$(t[1])};`).join(`
192
+ ${e.colors && Object.entries(e.colors).map(([t, r]) => `--${t}: ${y(r[1])};`).join(`
193
193
  `)}
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
- }`
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
+ `)
205
208
  ).join(`
206
209
  `);
207
210
  export {
208
- q as a,
211
+ I as a,
209
212
  A as b,
210
- I as c,
211
- R as d,
212
- P as e,
213
- D as f,
214
- k as g,
215
- S as p
213
+ w as c,
214
+ k as d,
215
+ h as e,
216
+ x as f,
217
+ S as g,
218
+ q as p
216
219
  };
@@ -1,21 +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 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(`
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
3
  `)}
4
4
  ${e.borderRadius&&`--radius: ${e.borderRadius};`}
5
- ${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${y(t[0])};`).join(`
5
+ ${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${$(t[0])};`).join(`
6
6
  `)}
7
7
  }
8
8
  .dark {
9
- ${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${y(t[1])};`).join(`
9
+ ${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${$(t[1])};`).join(`
10
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;
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;