@starasia/theme 2.0.1 → 3.0.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.
@@ -1,6 +1 @@
1
- export * from './brandcolor';
2
- export * from './colorpalette';
3
- export * from './maincolor';
4
- export * from './metric';
5
- export * from './font';
6
1
  export * from './injector';
package/dist/index.es.js CHANGED
@@ -1,213 +1,50 @@
1
- import { jsx as w } from "react/jsx-runtime";
2
- import { createContext as O, useState as E, useMemo as y, useRef as F, useEffect as P, useContext as N } from "react";
3
- function S(r, o = "") {
4
- let t = "";
5
- for (const s in r)
6
- if (Object.hasOwnProperty.call(r, s)) {
7
- const n = r[s];
8
- t += `/* ${s} */
9
- `;
10
- for (const e in n)
11
- if (Object.hasOwnProperty.call(n, e)) {
12
- const a = n[e];
13
- t += `--${o}-${s}-${e}: ${a};
14
- `;
15
- }
16
- }
17
- return t;
18
- }
19
- function C(r, o) {
20
- let t = "";
21
- for (const s in r) {
22
- const n = r[s];
23
- for (const e in n) {
24
- const a = n[e], c = e ? `${o}-${s}-${e}` : `${o}-${s}`;
25
- t += `--${c}: ${a};
26
- `;
27
- }
28
- }
29
- return t;
30
- }
31
- function M(r, o) {
32
- let t = "";
33
- function s(n, e, a = "", c = "", i = "") {
34
- if (i) {
35
- const l = `${a}${i}-${c}-${n}`;
36
- t += `--${l}: ${e};
37
- `;
38
- } else {
39
- const l = `${a}${n}-${c}`;
40
- t += `--${l}: ${e};
41
- `;
42
- }
43
- }
44
- for (const n in r) {
45
- const e = r[n];
46
- for (const a in e) {
47
- const c = e[a];
48
- if (typeof c == "object")
49
- for (const i in c) {
50
- const l = c[i], u = `${o}-`;
51
- s(
52
- a,
53
- l,
54
- u,
55
- n,
56
- i
57
- );
58
- }
59
- else {
60
- const i = `${o}-`;
61
- s(a, c, i, n);
62
- }
63
- }
64
- }
65
- return t;
66
- }
67
- function B(r, o = "") {
68
- let t = "";
69
- function s(n, e, a = "") {
70
- if (typeof e == "object")
71
- for (const c in e) {
72
- const i = e[c], l = `--${a}-${n}-${c}`;
73
- t += `${l}: ${i};
74
- `;
75
- }
76
- else {
77
- const c = `--${a}-${n}`;
78
- t += `${c}: ${e};
79
- `;
80
- }
81
- }
82
- for (const n in r) {
83
- const e = r[n];
84
- if (typeof e == "object")
85
- s(n, e, `${o}`);
86
- else {
87
- const a = `--${o}-${n}`;
88
- t += `${a}: ${e};
89
- `;
90
- }
91
- }
92
- return t;
93
- }
94
- function D(r, o = "") {
95
- let t = "";
96
- for (const s in r) {
97
- const n = r[s];
98
- for (const e in n) {
99
- const a = `--${o}-${s}-${e}`, c = n[e];
100
- t += `${a}: ${c};
101
- `;
102
- }
103
- }
104
- return t;
105
- }
106
- function H(r, o) {
107
- let t = "";
108
- for (const s in r)
109
- if (Object.hasOwnProperty.call(r, s)) {
110
- const n = r[s];
111
- s === "default" ? t += `--${o}: ${n};
112
- ` : t += `--${o}-${s}: ${n};
113
- `;
114
- }
115
- return t;
116
- }
117
- const J = (r) => {
118
- const o = document.getElementById(r);
119
- if (o)
120
- return o;
121
- const t = document.createElement("style");
122
- return t.id = r, document.head.appendChild(t), t;
123
- };
124
- function g(r, o) {
125
- let t = "";
126
- return Object.keys(r).forEach((s) => {
127
- const n = r[s];
128
- if (n && typeof n == "object") {
129
- t += g(n, `${o}-${s}`);
130
- return;
131
- }
132
- t += `${o}-${s}: ${n};
133
- `;
134
- }), t;
135
- }
136
- function L(r, o) {
137
- let t = "";
138
- return r && (t += g(r, o)), t;
139
- }
140
- function V(r) {
141
- var u, $, p, f, b, d;
142
- if (!r)
143
- return;
144
- const o = (u = r.colors) != null && u.raw ? C(
145
- r.colors.raw,
146
- "starasia-ui-raw-color"
147
- ) : "", t = ($ = r.colors) != null && $.computed ? C(
148
- r.colors.computed,
149
- "starasia-ui-color"
150
- ) : "", s = (p = r.colors) != null && p.main ? M(r.colors.main, "starasia-ui") : "", n = (f = r.colors) != null && f.brand ? S(r.colors.brand, "starasia-ui-brand") : "", e = (b = r.colors) != null && b.utility ? S(
151
- r.colors.utility,
152
- "starasia-ui-utility"
153
- ) : "", a = (d = r.colors) != null && d.text ? H(
154
- r.colors.text,
155
- "starasia-ui-color-text"
156
- ) : "", c = r.metrics ? B(r.metrics, "starasia-ui") : "", i = r.font ? D(r.font, "starasia-ui") : "", l = r.components ? L(r.components, "--starasia-ui") : "";
157
- return `
158
- :root {
159
- ${o}
160
- ${t}
161
- ${s}
162
- ${n}
163
- ${e}
164
- ${a}
165
- ${c}
166
- ${i}
167
- ${l}
168
- }
169
- `;
170
- }
171
- const j = O({
1
+ import { jsx as S } from "react/jsx-runtime";
2
+ import { createContext as E, useState as g, useMemo as a, useRef as f, useEffect as v, useContext as j } from "react";
3
+ const w = (r) => {
4
+ const t = document.getElementById(r);
5
+ if (t)
6
+ return t;
7
+ const e = document.createElement("style");
8
+ return e.id = r, document.head.appendChild(e), e;
9
+ }, u = E({
172
10
  theme: void 0,
173
11
  setTheme: () => {
174
12
  }
175
- }), _ = "starasia-theme-style";
176
- function z(r) {
177
- const o = r.split(",").map((t) => Number(t.trim()));
178
- return o.length !== 3 || o.some((t) => !Number.isFinite(t) || t < 0 || t > 255) ? null : "#" + o.map((t) => Math.round(t).toString(16).padStart(2, "0")).join("");
13
+ }), C = "sa-theme-style";
14
+ function O(r) {
15
+ const t = r.split(",").map((e) => Number(e.trim()));
16
+ return t.length !== 3 || t.some((e) => !Number.isFinite(e) || e < 0 || e > 255) ? null : "#" + t.map((e) => Math.round(e).toString(16).padStart(2, "0")).join("");
179
17
  }
180
- function A(r) {
18
+ function N(r) {
181
19
  if (!r)
182
20
  return "";
183
- const o = /* @__PURE__ */ new Set(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), t = Object.entries(r).filter(([s]) => o.has(s)).map(([s, n]) => {
184
- const e = z(n);
185
- return e ? ` --sa-color-brand-${s}: ${e};` : "";
21
+ const t = /* @__PURE__ */ new Set(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), e = Object.entries(r).filter(([n]) => t.has(n)).map(([n, o]) => {
22
+ const s = O(o);
23
+ return s ? ` --sa-color-brand-${n}: ${s};` : "";
186
24
  }).filter(Boolean).join(`
187
25
  `);
188
- return t ? `:root {
189
- ${t}
26
+ return e ? `:root {
27
+ ${e}
190
28
  }` : "";
191
29
  }
192
- function q({ value: r, children: o }) {
193
- const [t, s] = E(r), n = y(
194
- () => t ? JSON.stringify(t) : "",
195
- [t]
196
- ), e = F(J(_));
197
- P(() => {
30
+ function B({ value: r, children: t }) {
31
+ const [e, n] = g(r), o = a(
32
+ () => e ? JSON.stringify(e) : "",
33
+ [e]
34
+ ), s = f(w(C));
35
+ v(() => {
198
36
  var c, i;
199
- if (n) {
200
- const l = JSON.parse(n), u = V(l) ?? "", $ = A((i = (c = l == null ? void 0 : l.colors) == null ? void 0 : c.raw) == null ? void 0 : i.blue), p = [u, $].filter(Boolean).join(`
201
- `);
202
- p && (e != null && e.current) && (e.current.textContent = p);
37
+ if (o) {
38
+ const m = JSON.parse(o), l = N((i = (c = m == null ? void 0 : m.colors) == null ? void 0 : c.raw) == null ? void 0 : i.blue);
39
+ l && (s != null && s.current) && (s.current.textContent = l);
203
40
  }
204
- }, [n]);
205
- const a = (c) => {
206
- c && s(c);
41
+ }, [o]);
42
+ const d = (c) => {
43
+ c && n(c);
207
44
  };
208
- return /* @__PURE__ */ w(j.Provider, { value: { theme: t, setTheme: a }, children: o });
45
+ return /* @__PURE__ */ S(u.Provider, { value: { theme: e, setTheme: d }, children: t });
209
46
  }
210
- const I = {
47
+ const D = {
211
48
  raw: {
212
49
  white: {
213
50
  900: "255, 255, 255"
@@ -306,7 +143,7 @@ const I = {
306
143
  tertiary: "230, 237, 246"
307
144
  }
308
145
  }
309
- }, K = {
146
+ }, H = {
310
147
  radii: {
311
148
  none: "0",
312
149
  xs: "0.25rem",
@@ -364,7 +201,7 @@ const I = {
364
201
  inner: "inset 0 2px 4px 0 #0000000d",
365
202
  card: "0px 4px 35px 0px #7090b040"
366
203
  }
367
- }, R = {
204
+ }, J = {
368
205
  fontSizes: {
369
206
  xs: "0.625rem",
370
207
  sm: "0.75rem",
@@ -404,64 +241,64 @@ const I = {
404
241
  relaxed: 1.625,
405
242
  loose: 2
406
243
  }
407
- }, U = {
408
- colors: I,
409
- metrics: K,
410
- font: R
411
- }, m = U, v = (r, o) => {
412
- const t = {};
413
- return Object.keys(r).forEach((s) => {
414
- if (r != null && r[s] && typeof (r == null ? void 0 : r[s]) == "object") {
415
- t[s] = {
416
- ...r == null ? void 0 : r[s],
417
- ...o == null ? void 0 : o[s],
418
- ...v(r == null ? void 0 : r[s], o == null ? void 0 : o[s])
244
+ }, M = {
245
+ colors: D,
246
+ metrics: H,
247
+ font: J
248
+ }, p = M, b = (r, t) => {
249
+ const e = {};
250
+ return Object.keys(r).forEach((n) => {
251
+ if (r != null && r[n] && typeof (r == null ? void 0 : r[n]) == "object") {
252
+ e[n] = {
253
+ ...r == null ? void 0 : r[n],
254
+ ...t == null ? void 0 : t[n],
255
+ ...b(r == null ? void 0 : r[n], t == null ? void 0 : t[n])
419
256
  };
420
257
  return;
421
258
  }
422
- t[s] = (o == null ? void 0 : o[s]) || (r == null ? void 0 : r[s]);
423
- }), t;
259
+ e[n] = (t == null ? void 0 : t[n]) || (r == null ? void 0 : r[n]);
260
+ }), e;
424
261
  };
425
262
  function x() {
426
- const r = N(j), o = y(
263
+ const r = j(u), t = a(
427
264
  () => ({
428
- ...m,
265
+ ...p,
429
266
  ...r.theme,
430
- ...v(m, r.theme)
267
+ ...b(p, r.theme)
431
268
  }),
432
- [r.theme, m]
269
+ [r.theme, p]
433
270
  );
434
- return { ...r, theme: o };
271
+ return { ...r, theme: t };
435
272
  }
436
- function G() {
273
+ function F() {
437
274
  const { theme: r } = x();
438
275
  return r.colors;
439
276
  }
440
- function Q() {
441
- var o;
277
+ function L() {
278
+ var t;
442
279
  const { theme: r } = x();
443
- return (o = r.metrics) == null ? void 0 : o.spacing;
280
+ return (t = r.metrics) == null ? void 0 : t.spacing;
444
281
  }
445
- function X() {
446
- var o;
282
+ function P() {
283
+ var t;
447
284
  const { theme: r } = x();
448
- return (o = r.metrics) == null ? void 0 : o.radii;
285
+ return (t = r.metrics) == null ? void 0 : t.radii;
449
286
  }
450
- function Z() {
451
- var o;
287
+ function _() {
288
+ var t;
452
289
  const { theme: r } = x();
453
- return (o = r == null ? void 0 : r.metrics) == null ? void 0 : o.shadows;
290
+ return (t = r == null ? void 0 : r.metrics) == null ? void 0 : t.shadows;
454
291
  }
455
- function k(r) {
292
+ function y(r) {
456
293
  return r;
457
294
  }
458
295
  export {
459
- j as ThemeContext,
460
- q as ThemeProvider,
461
- k as createTheme,
462
- G as useColor,
463
- X as useRadius,
464
- Z as useShadow,
465
- Q as useSpacing,
296
+ u as ThemeContext,
297
+ B as ThemeProvider,
298
+ y as createTheme,
299
+ F as useColor,
300
+ P as useRadius,
301
+ _ as useShadow,
302
+ L as useSpacing,
466
303
  x as useTheme
467
304
  };
package/dist/index.umd.js CHANGED
@@ -1,29 +1,4 @@
1
- (function(a,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],p):(a=typeof globalThis<"u"?globalThis:a||self,p(a["@starasia/theme"]={},a.jsxRuntime,a.React))})(this,function(a,p,m){"use strict";function C(r,o=""){let t="";for(const e in r)if(Object.hasOwnProperty.call(r,e)){const n=r[e];t+=`/* ${e} */
2
- `;for(const s in n)if(Object.hasOwnProperty.call(n,s)){const i=n[s];t+=`--${o}-${e}-${s}: ${i};
3
- `}}return t}function y(r,o){let t="";for(const e in r){const n=r[e];for(const s in n){const i=n[s],c=s?`${o}-${e}-${s}`:`${o}-${e}`;t+=`--${c}: ${i};
4
- `}}return t}function E(r,o){let t="";function e(n,s,i="",c="",l=""){if(l){const u=`${i}${l}-${c}-${n}`;t+=`--${u}: ${s};
5
- `}else{const u=`${i}${n}-${c}`;t+=`--${u}: ${s};
6
- `}}for(const n in r){const s=r[n];for(const i in s){const c=s[i];if(typeof c=="object")for(const l in c){const u=c[l],$=`${o}-`;e(i,u,$,n,l)}else{const l=`${o}-`;e(i,c,l,n)}}}return t}function P(r,o=""){let t="";function e(n,s,i=""){if(typeof s=="object")for(const c in s){const l=s[c],u=`--${i}-${n}-${c}`;t+=`${u}: ${l};
7
- `}else{const c=`--${i}-${n}`;t+=`${c}: ${s};
8
- `}}for(const n in r){const s=r[n];if(typeof s=="object")e(n,s,`${o}`);else{const i=`--${o}-${n}`;t+=`${i}: ${s};
9
- `}}return t}function F(r,o=""){let t="";for(const e in r){const n=r[e];for(const s in n){const i=`--${o}-${e}-${s}`,c=n[s];t+=`${i}: ${c};
10
- `}}return t}function N(r,o){let t="";for(const e in r)if(Object.hasOwnProperty.call(r,e)){const n=r[e];e==="default"?t+=`--${o}: ${n};
11
- `:t+=`--${o}-${e}: ${n};
12
- `}return t}const M=r=>{const o=document.getElementById(r);if(o)return o;const t=document.createElement("style");return t.id=r,document.head.appendChild(t),t};function j(r,o){let t="";return Object.keys(r).forEach(e=>{const n=r[e];if(n&&typeof n=="object"){t+=j(n,`${o}-${e}`);return}t+=`${o}-${e}: ${n};
13
- `}),t}function B(r,o){let t="";return r&&(t+=j(r,o)),t}function D(r){var $,b,x,v,w,O;if(!r)return;const o=($=r.colors)!=null&&$.raw?y(r.colors.raw,"starasia-ui-raw-color"):"",t=(b=r.colors)!=null&&b.computed?y(r.colors.computed,"starasia-ui-color"):"",e=(x=r.colors)!=null&&x.main?E(r.colors.main,"starasia-ui"):"",n=(v=r.colors)!=null&&v.brand?C(r.colors.brand,"starasia-ui-brand"):"",s=(w=r.colors)!=null&&w.utility?C(r.colors.utility,"starasia-ui-utility"):"",i=(O=r.colors)!=null&&O.text?N(r.colors.text,"starasia-ui-color-text"):"",c=r.metrics?P(r.metrics,"starasia-ui"):"",l=r.font?F(r.font,"starasia-ui"):"",u=r.components?B(r.components,"--starasia-ui"):"";return`
14
- :root {
15
- ${o}
16
- ${t}
17
- ${e}
18
- ${n}
19
- ${s}
20
- ${i}
21
- ${c}
22
- ${l}
23
- ${u}
24
- }
25
- `}const d=m.createContext({theme:void 0,setTheme:()=>{}}),H="starasia-theme-style";function R(r){const o=r.split(",").map(t=>Number(t.trim()));return o.length!==3||o.some(t=>!Number.isFinite(t)||t<0||t>255)?null:"#"+o.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}function J(r){if(!r)return"";const o=new Set(["50","100","200","300","400","500","600","700","800","900"]),t=Object.entries(r).filter(([e])=>o.has(e)).map(([e,n])=>{const s=R(n);return s?` --sa-color-brand-${e}: ${s};`:""}).filter(Boolean).join(`
1
+ (function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s["@starasia/theme"]={},s.jsxRuntime,s.React))})(this,function(s,c,o){"use strict";const S=e=>{const r=document.getElementById(e);if(r)return r;const t=document.createElement("style");return t.id=e,document.head.appendChild(t),t},p=o.createContext({theme:void 0,setTheme:()=>{}}),E="sa-theme-style";function j(e){const r=e.split(",").map(t=>Number(t.trim()));return r.length!==3||r.some(t=>!Number.isFinite(t)||t<0||t>255)?null:"#"+r.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}function h(e){if(!e)return"";const r=new Set(["50","100","200","300","400","500","600","700","800","900"]),t=Object.entries(e).filter(([n])=>r.has(n)).map(([n,x])=>{const i=j(x);return i?` --sa-color-brand-${n}: ${i};`:""}).filter(Boolean).join(`
26
2
  `);return t?`:root {
27
3
  ${t}
28
- }`:""}function L({value:r,children:o}){const[t,e]=m.useState(r),n=m.useMemo(()=>t?JSON.stringify(t):"",[t]),s=m.useRef(M(H));m.useEffect(()=>{var c,l;if(n){const u=JSON.parse(n),$=D(u)??"",b=J((l=(c=u==null?void 0:u.colors)==null?void 0:c.raw)==null?void 0:l.blue),x=[$,b].filter(Boolean).join(`
29
- `);x&&(s!=null&&s.current)&&(s.current.textContent=x)}},[n]);const i=c=>{c&&e(c)};return p.jsx(d.Provider,{value:{theme:t,setTheme:i},children:o})}const S={colors:{raw:{white:{900:"255, 255, 255"},black:{900:"0, 0, 0"},blue:{50:"230, 237, 246",100:"204, 217, 237",200:"153, 179, 219",300:"102, 140, 201",400:"51, 102, 183",500:"26, 79, 160",600:"4, 37, 79",700:"3, 31, 67",800:"2, 25, 55",900:"2, 19, 43"},pink:{50:"251, 219, 241",100:"248, 183, 228",200:"245, 147, 215",300:"241, 111, 202",400:"238, 75, 189",500:"235, 39, 176",600:"215, 19, 157",700:"179, 16, 131",800:"143, 13, 104",900:"107, 9, 78"},purple:{50:"249, 229, 252",100:"240, 196, 248",200:"230, 162, 244",300:"220, 128, 240",400:"210, 95, 236",500:"200, 61, 232",600:"180, 41, 212",700:"150, 34, 177",800:"120, 27, 142",900:"90, 21, 106"},red:{50:"251, 222, 222",100:"247, 188, 188",200:"243, 153, 153",300:"239, 119, 119",400:"235, 84, 84",500:"231, 50, 50",600:"212, 30, 30",700:"176, 25, 25",800:"141, 20, 20",900:"105, 15, 15"},orange:{50:"253, 235, 217",100:"251, 215, 179",200:"249, 195, 141",300:"247, 175, 103",400:"245, 155, 65",500:"243, 135, 27",600:"224, 116, 8",700:"187, 96, 7",800:"150, 77, 6",900:"112, 58, 4"},yellow:{50:"255, 250, 219",100:"255, 246, 184",200:"255, 241, 149",300:"255, 237, 114",400:"255, 232, 79",500:"255, 228, 44",600:"236, 209, 25",700:"197, 174, 21",800:"157, 139, 17",900:"118, 104, 12"},green:{50:"236, 255, 246",100:"151, 230, 193",200:"117, 222, 173",300:"82, 214, 152",400:"48, 206, 132",500:"40, 172, 110",600:"32, 137, 88",700:"24, 103, 66",800:"16, 68, 44",900:"16, 68, 44"},brand:{default:"4, 37, 79",active:"2, 19, 43",secondary:"153, 179, 219",tertiary:"230, 237, 246"}}},metrics:{radii:{none:"0",xs:"0.25rem",sm:"0.375rem",md:"0.5rem",lg:"0.75rem",xl:"0.875rem","2xl":"1rem",full:"12rem"},spacing:{0:"0rem",1:"0.063rem",2:"0.125rem",4:"0.25rem",6:"0.375rem",8:"0.5rem",10:"0.625rem",12:"0.75rem",14:"0.875rem",16:"1rem",18:"1.125rem",20:"1.25rem",24:"1.5rem",28:"1.75rem",32:"2rem",36:"2.25rem",40:"2.5rem",48:"3rem",64:"4rem",80:"5rem",96:"6rem",128:"8rem",160:"10rem",192:"12rem",224:"14rem",256:"16rem",xs:"0.25rem",sm:"0.5rem",md:"0.75rem",lg:"1rem",xl:"1.5rem","2xl":"2rem","3xl":"4rem"},border:{default:"1px solid var(--sa-border-subtle, #0b120e24)"},shadows:{sm:"0 1px 2px 0 #0000000d",md:"0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a",lg:"0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a",xl:"0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a","2xl":"0 25px 50px -12px #00000040",inner:"inset 0 2px 4px 0 #0000000d",card:"0px 4px 35px 0px #7090b040"}},font:{fontSizes:{xs:"0.625rem",sm:"0.75rem",md:"0.875rem",lg:"1rem",xl:"1.125rem","2xl":"1.25rem","3xl":"1.5rem","4xl":"2rem","5xl":"2.25rem","6xl":"3rem"},fontWeights:{hairline:100,thin:100,light:200,normal:300,medium:400,semibold:500,bold:600,extrabold:700,black:800},lineHeights:{3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"1.875rem",9:"2.25rem",10:"2.5rem",none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2}}},g=(r,o)=>{const t={};return Object.keys(r).forEach(e=>{if(r!=null&&r[e]&&typeof(r==null?void 0:r[e])=="object"){t[e]={...r==null?void 0:r[e],...o==null?void 0:o[e],...g(r==null?void 0:r[e],o==null?void 0:o[e])};return}t[e]=(o==null?void 0:o[e])||(r==null?void 0:r[e])}),t};function f(){const r=m.useContext(d),o=m.useMemo(()=>({...S,...r.theme,...g(S,r.theme)}),[r.theme,S]);return{...r,theme:o}}function _(){const{theme:r}=f();return r.colors}function q(){var o;const{theme:r}=f();return(o=r.metrics)==null?void 0:o.spacing}function A(){var o;const{theme:r}=f();return(o=r.metrics)==null?void 0:o.radii}function U(){var o;const{theme:r}=f();return(o=r==null?void 0:r.metrics)==null?void 0:o.shadows}function V(r){return r}a.ThemeContext=d,a.ThemeProvider=L,a.createTheme=V,a.useColor=_,a.useRadius=A,a.useShadow=U,a.useSpacing=q,a.useTheme=f,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
4
+ }`:""}function g({value:e,children:r}){const[t,n]=o.useState(e),x=o.useMemo(()=>t?JSON.stringify(t):"",[t]),i=o.useRef(S(E));o.useEffect(()=>{var u,b;if(x){const a=JSON.parse(x),f=h((b=(u=a==null?void 0:a.colors)==null?void 0:u.raw)==null?void 0:b.blue);f&&(i!=null&&i.current)&&(i.current.textContent=f)}},[x]);const y=u=>{u&&n(u)};return c.jsx(p.Provider,{value:{theme:t,setTheme:y},children:r})}const l={colors:{raw:{white:{900:"255, 255, 255"},black:{900:"0, 0, 0"},blue:{50:"230, 237, 246",100:"204, 217, 237",200:"153, 179, 219",300:"102, 140, 201",400:"51, 102, 183",500:"26, 79, 160",600:"4, 37, 79",700:"3, 31, 67",800:"2, 25, 55",900:"2, 19, 43"},pink:{50:"251, 219, 241",100:"248, 183, 228",200:"245, 147, 215",300:"241, 111, 202",400:"238, 75, 189",500:"235, 39, 176",600:"215, 19, 157",700:"179, 16, 131",800:"143, 13, 104",900:"107, 9, 78"},purple:{50:"249, 229, 252",100:"240, 196, 248",200:"230, 162, 244",300:"220, 128, 240",400:"210, 95, 236",500:"200, 61, 232",600:"180, 41, 212",700:"150, 34, 177",800:"120, 27, 142",900:"90, 21, 106"},red:{50:"251, 222, 222",100:"247, 188, 188",200:"243, 153, 153",300:"239, 119, 119",400:"235, 84, 84",500:"231, 50, 50",600:"212, 30, 30",700:"176, 25, 25",800:"141, 20, 20",900:"105, 15, 15"},orange:{50:"253, 235, 217",100:"251, 215, 179",200:"249, 195, 141",300:"247, 175, 103",400:"245, 155, 65",500:"243, 135, 27",600:"224, 116, 8",700:"187, 96, 7",800:"150, 77, 6",900:"112, 58, 4"},yellow:{50:"255, 250, 219",100:"255, 246, 184",200:"255, 241, 149",300:"255, 237, 114",400:"255, 232, 79",500:"255, 228, 44",600:"236, 209, 25",700:"197, 174, 21",800:"157, 139, 17",900:"118, 104, 12"},green:{50:"236, 255, 246",100:"151, 230, 193",200:"117, 222, 173",300:"82, 214, 152",400:"48, 206, 132",500:"40, 172, 110",600:"32, 137, 88",700:"24, 103, 66",800:"16, 68, 44",900:"16, 68, 44"},brand:{default:"4, 37, 79",active:"2, 19, 43",secondary:"153, 179, 219",tertiary:"230, 237, 246"}}},metrics:{radii:{none:"0",xs:"0.25rem",sm:"0.375rem",md:"0.5rem",lg:"0.75rem",xl:"0.875rem","2xl":"1rem",full:"12rem"},spacing:{0:"0rem",1:"0.063rem",2:"0.125rem",4:"0.25rem",6:"0.375rem",8:"0.5rem",10:"0.625rem",12:"0.75rem",14:"0.875rem",16:"1rem",18:"1.125rem",20:"1.25rem",24:"1.5rem",28:"1.75rem",32:"2rem",36:"2.25rem",40:"2.5rem",48:"3rem",64:"4rem",80:"5rem",96:"6rem",128:"8rem",160:"10rem",192:"12rem",224:"14rem",256:"16rem",xs:"0.25rem",sm:"0.5rem",md:"0.75rem",lg:"1rem",xl:"1.5rem","2xl":"2rem","3xl":"4rem"},border:{default:"1px solid var(--sa-border-subtle, #0b120e24)"},shadows:{sm:"0 1px 2px 0 #0000000d",md:"0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a",lg:"0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a",xl:"0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a","2xl":"0 25px 50px -12px #00000040",inner:"inset 0 2px 4px 0 #0000000d",card:"0px 4px 35px 0px #7090b040"}},font:{fontSizes:{xs:"0.625rem",sm:"0.75rem",md:"0.875rem",lg:"1rem",xl:"1.125rem","2xl":"1.25rem","3xl":"1.5rem","4xl":"2rem","5xl":"2.25rem","6xl":"3rem"},fontWeights:{hairline:100,thin:100,light:200,normal:300,medium:400,semibold:500,bold:600,extrabold:700,black:800},lineHeights:{3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"1.875rem",9:"2.25rem",10:"2.5rem",none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2}}},d=(e,r)=>{const t={};return Object.keys(e).forEach(n=>{if(e!=null&&e[n]&&typeof(e==null?void 0:e[n])=="object"){t[n]={...e==null?void 0:e[n],...r==null?void 0:r[n],...d(e==null?void 0:e[n],r==null?void 0:r[n])};return}t[n]=(r==null?void 0:r[n])||(e==null?void 0:e[n])}),t};function m(){const e=o.useContext(p),r=o.useMemo(()=>({...l,...e.theme,...d(l,e.theme)}),[e.theme,l]);return{...e,theme:r}}function v(){const{theme:e}=m();return e.colors}function C(){var r;const{theme:e}=m();return(r=e.metrics)==null?void 0:r.spacing}function w(){var r;const{theme:e}=m();return(r=e.metrics)==null?void 0:r.radii}function O(){var r;const{theme:e}=m();return(r=e==null?void 0:e.metrics)==null?void 0:r.shadows}function M(e){return e}s.ThemeContext=p,s.ThemeProvider=g,s.createTheme=M,s.useColor=v,s.useRadius=w,s.useShadow=O,s.useSpacing=C,s.useTheme=m,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@starasia/theme",
3
3
  "author": "Prawito Hudoro",
4
- "version": "2.0.1",
4
+ "version": "3.0.1",
5
5
  "description": "Theme component for starasia UI",
6
6
  "main": "dist/index.umd.js",
7
7
  "module": "dist/index.es.js",
@@ -1,3 +0,0 @@
1
- import { Brand, Utility } from '../types';
2
-
3
- export declare function generateBrandColorCSSFromTheme(theme: Brand & Utility, prefix?: string): string;
@@ -1,3 +0,0 @@
1
- import { Computed } from '../types/theme';
2
-
3
- export declare function generateColorPaletteCSSFromTheme(theme: Computed, variableNamePrefix: string): string;
@@ -1,3 +0,0 @@
1
- import { ThemeObject } from '../types';
2
-
3
- export declare function generateComponentCSSFromTheme(components?: ThemeObject["components"], prefix?: string): string;
@@ -1,8 +0,0 @@
1
- import { Font } from '../types/theme';
2
-
3
- export declare function generateFontCSSFromTheme(theme: Font, prefix?: string): string;
4
- interface Theme {
5
- [key: string]: string;
6
- }
7
- export declare function generateTextCSSFromTheme(theme: Theme, prefix: string): string;
8
- export {};
@@ -1,3 +0,0 @@
1
- import { ThemeObject } from '../types/theme';
2
-
3
- export declare function generateTheme(theme?: ThemeObject): string | undefined;
@@ -1,3 +0,0 @@
1
- import { Main } from '../types/theme';
2
-
3
- export declare function generateMainColorCSSFromTheme(theme: Main, variableNamePrefix: string): string;
@@ -1,3 +0,0 @@
1
- import { Metrics } from '../types/theme';
2
-
3
- export declare function generateMetricCSSFromTheme(theme: Metrics, prefix?: string): string;