@starasia/theme 2.0.1 → 3.0.0

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.
package/dist/index.es.js CHANGED
@@ -1,170 +1,170 @@
1
1
  import { jsx as w } from "react/jsx-runtime";
2
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} */
3
+ function S(r, t = "") {
4
+ let o = "";
5
+ for (const n in r)
6
+ if (Object.hasOwnProperty.call(r, n)) {
7
+ const e = r[n];
8
+ o += `/* ${n} */
9
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};
10
+ for (const s in e)
11
+ if (Object.hasOwnProperty.call(e, s)) {
12
+ const i = e[s];
13
+ o += `--${t}-${n}-${s}: ${i};
14
14
  `;
15
15
  }
16
16
  }
17
- return t;
17
+ return o;
18
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};
19
+ function C(r, t) {
20
+ let o = "";
21
+ for (const n in r) {
22
+ const e = r[n];
23
+ for (const s in e) {
24
+ const i = e[s], c = s ? `${t}-${n}-${s}` : `${t}-${n}`;
25
+ o += `--${c}: ${i};
26
26
  `;
27
27
  }
28
28
  }
29
- return t;
29
+ return o;
30
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};
31
+ function M(r, t) {
32
+ let o = "";
33
+ function n(e, s, i = "", c = "", l = "") {
34
+ if (l) {
35
+ const a = `${i}${l}-${c}-${e}`;
36
+ o += `--${a}: ${s};
37
37
  `;
38
38
  } else {
39
- const l = `${a}${n}-${c}`;
40
- t += `--${l}: ${e};
39
+ const a = `${i}${e}-${c}`;
40
+ o += `--${a}: ${s};
41
41
  `;
42
42
  }
43
43
  }
44
- for (const n in r) {
45
- const e = r[n];
46
- for (const a in e) {
47
- const c = e[a];
44
+ for (const e in r) {
45
+ const s = r[e];
46
+ for (const i in s) {
47
+ const c = s[i];
48
48
  if (typeof c == "object")
49
- for (const i in c) {
50
- const l = c[i], u = `${o}-`;
51
- s(
49
+ for (const l in c) {
50
+ const a = c[l], u = `${t}-`;
51
+ n(
52
+ i,
52
53
  a,
53
- l,
54
54
  u,
55
- n,
56
- i
55
+ e,
56
+ l
57
57
  );
58
58
  }
59
59
  else {
60
- const i = `${o}-`;
61
- s(a, c, i, n);
60
+ const l = `${t}-`;
61
+ n(i, c, l, e);
62
62
  }
63
63
  }
64
64
  }
65
- return t;
65
+ return o;
66
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};
67
+ function B(r, t = "") {
68
+ let o = "";
69
+ function n(e, s, i = "") {
70
+ if (typeof s == "object")
71
+ for (const c in s) {
72
+ const l = s[c], a = `--${i}-${e}-${c}`;
73
+ o += `${a}: ${l};
74
74
  `;
75
75
  }
76
76
  else {
77
- const c = `--${a}-${n}`;
78
- t += `${c}: ${e};
77
+ const c = `--${i}-${e}`;
78
+ o += `${c}: ${s};
79
79
  `;
80
80
  }
81
81
  }
82
- for (const n in r) {
83
- const e = r[n];
84
- if (typeof e == "object")
85
- s(n, e, `${o}`);
82
+ for (const e in r) {
83
+ const s = r[e];
84
+ if (typeof s == "object")
85
+ n(e, s, `${t}`);
86
86
  else {
87
- const a = `--${o}-${n}`;
88
- t += `${a}: ${e};
87
+ const i = `--${t}-${e}`;
88
+ o += `${i}: ${s};
89
89
  `;
90
90
  }
91
91
  }
92
- return t;
92
+ return o;
93
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};
94
+ function D(r, t = "") {
95
+ let o = "";
96
+ for (const n in r) {
97
+ const e = r[n];
98
+ for (const s in e) {
99
+ const i = `--${t}-${n}-${s}`, c = e[s];
100
+ o += `${i}: ${c};
101
101
  `;
102
102
  }
103
103
  }
104
- return t;
104
+ return o;
105
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};
106
+ function H(r, t) {
107
+ let o = "";
108
+ for (const n in r)
109
+ if (Object.hasOwnProperty.call(r, n)) {
110
+ const e = r[n];
111
+ n === "default" ? o += `--${t}: ${e};
112
+ ` : o += `--${t}-${n}: ${e};
113
113
  `;
114
114
  }
115
- return t;
115
+ return o;
116
116
  }
117
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;
118
+ const t = document.getElementById(r);
119
+ if (t)
120
+ return t;
121
+ const o = document.createElement("style");
122
+ return o.id = r, document.head.appendChild(o), o;
123
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}`);
124
+ function g(r, t) {
125
+ let o = "";
126
+ return Object.keys(r).forEach((n) => {
127
+ const e = r[n];
128
+ if (e && typeof e == "object") {
129
+ o += g(e, `${t}-${n}`);
130
130
  return;
131
131
  }
132
- t += `${o}-${s}: ${n};
132
+ o += `${t}-${n}: ${e};
133
133
  `;
134
- }), t;
134
+ }), o;
135
135
  }
136
- function L(r, o) {
137
- let t = "";
138
- return r && (t += g(r, o)), t;
136
+ function L(r, t) {
137
+ let o = "";
138
+ return r && (o += g(r, t)), o;
139
139
  }
140
140
  function V(r) {
141
141
  var u, $, p, f, b, d;
142
142
  if (!r)
143
143
  return;
144
- const o = (u = r.colors) != null && u.raw ? C(
144
+ const t = (u = r.colors) != null && u.raw ? C(
145
145
  r.colors.raw,
146
- "starasia-ui-raw-color"
147
- ) : "", t = ($ = r.colors) != null && $.computed ? C(
146
+ "sa-ui-raw-color"
147
+ ) : "", o = ($ = r.colors) != null && $.computed ? C(
148
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(
149
+ "sa-ui-color"
150
+ ) : "", n = (p = r.colors) != null && p.main ? M(r.colors.main, "sa-ui") : "", e = (f = r.colors) != null && f.brand ? S(r.colors.brand, "sa-ui-brand") : "", s = (b = r.colors) != null && b.utility ? S(
151
151
  r.colors.utility,
152
- "starasia-ui-utility"
153
- ) : "", a = (d = r.colors) != null && d.text ? H(
152
+ "sa-ui-utility"
153
+ ) : "", i = (d = r.colors) != null && d.text ? H(
154
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") : "";
155
+ "sa-ui-color-text"
156
+ ) : "", c = r.metrics ? B(r.metrics, "sa-ui") : "", l = r.font ? D(r.font, "sa-ui") : "", a = r.components ? L(r.components, "--sa-ui") : "";
157
157
  return `
158
158
  :root {
159
- ${o}
160
159
  ${t}
161
- ${s}
160
+ ${o}
162
161
  ${n}
163
162
  ${e}
164
- ${a}
165
- ${c}
163
+ ${s}
166
164
  ${i}
165
+ ${c}
167
166
  ${l}
167
+ ${a}
168
168
  }
169
169
  `;
170
170
  }
@@ -172,40 +172,40 @@ const j = O({
172
172
  theme: void 0,
173
173
  setTheme: () => {
174
174
  }
175
- }), _ = "starasia-theme-style";
175
+ }), _ = "sa-theme-style";
176
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("");
177
+ const t = r.split(",").map((o) => Number(o.trim()));
178
+ return t.length !== 3 || t.some((o) => !Number.isFinite(o) || o < 0 || o > 255) ? null : "#" + t.map((o) => Math.round(o).toString(16).padStart(2, "0")).join("");
179
179
  }
180
180
  function A(r) {
181
181
  if (!r)
182
182
  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};` : "";
183
+ const t = /* @__PURE__ */ new Set(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), o = Object.entries(r).filter(([n]) => t.has(n)).map(([n, e]) => {
184
+ const s = z(e);
185
+ return s ? ` --sa-color-brand-${n}: ${s};` : "";
186
186
  }).filter(Boolean).join(`
187
187
  `);
188
- return t ? `:root {
189
- ${t}
188
+ return o ? `:root {
189
+ ${o}
190
190
  }` : "";
191
191
  }
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(_));
192
+ function q({ value: r, children: t }) {
193
+ const [o, n] = E(r), e = y(
194
+ () => o ? JSON.stringify(o) : "",
195
+ [o]
196
+ ), s = F(J(_));
197
197
  P(() => {
198
- 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(`
198
+ var c, l;
199
+ if (e) {
200
+ const a = JSON.parse(e), u = V(a) ?? "", $ = A((l = (c = a == null ? void 0 : a.colors) == null ? void 0 : c.raw) == null ? void 0 : l.blue), p = [u, $].filter(Boolean).join(`
201
201
  `);
202
- p && (e != null && e.current) && (e.current.textContent = p);
202
+ p && (s != null && s.current) && (s.current.textContent = p);
203
203
  }
204
- }, [n]);
205
- const a = (c) => {
206
- c && s(c);
204
+ }, [e]);
205
+ const i = (c) => {
206
+ c && n(c);
207
207
  };
208
- return /* @__PURE__ */ w(j.Provider, { value: { theme: t, setTheme: a }, children: o });
208
+ return /* @__PURE__ */ w(j.Provider, { value: { theme: o, setTheme: i }, children: t });
209
209
  }
210
210
  const I = {
211
211
  raw: {
@@ -408,22 +408,22 @@ const I = {
408
408
  colors: I,
409
409
  metrics: K,
410
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])
411
+ }, m = U, v = (r, t) => {
412
+ const o = {};
413
+ return Object.keys(r).forEach((n) => {
414
+ if (r != null && r[n] && typeof (r == null ? void 0 : r[n]) == "object") {
415
+ o[n] = {
416
+ ...r == null ? void 0 : r[n],
417
+ ...t == null ? void 0 : t[n],
418
+ ...v(r == null ? void 0 : r[n], t == null ? void 0 : t[n])
419
419
  };
420
420
  return;
421
421
  }
422
- t[s] = (o == null ? void 0 : o[s]) || (r == null ? void 0 : r[s]);
423
- }), t;
422
+ o[n] = (t == null ? void 0 : t[n]) || (r == null ? void 0 : r[n]);
423
+ }), o;
424
424
  };
425
425
  function x() {
426
- const r = N(j), o = y(
426
+ const r = N(j), t = y(
427
427
  () => ({
428
428
  ...m,
429
429
  ...r.theme,
@@ -431,26 +431,26 @@ function x() {
431
431
  }),
432
432
  [r.theme, m]
433
433
  );
434
- return { ...r, theme: o };
434
+ return { ...r, theme: t };
435
435
  }
436
436
  function G() {
437
437
  const { theme: r } = x();
438
438
  return r.colors;
439
439
  }
440
440
  function Q() {
441
- var o;
441
+ var t;
442
442
  const { theme: r } = x();
443
- return (o = r.metrics) == null ? void 0 : o.spacing;
443
+ return (t = r.metrics) == null ? void 0 : t.spacing;
444
444
  }
445
445
  function X() {
446
- var o;
446
+ var t;
447
447
  const { theme: r } = x();
448
- return (o = r.metrics) == null ? void 0 : o.radii;
448
+ return (t = r.metrics) == null ? void 0 : t.radii;
449
449
  }
450
450
  function Z() {
451
- var o;
451
+ var t;
452
452
  const { theme: r } = x();
453
- return (o = r == null ? void 0 : r.metrics) == null ? void 0 : o.shadows;
453
+ return (t = r == null ? void 0 : r.metrics) == null ? void 0 : t.shadows;
454
454
  }
455
455
  function k(r) {
456
456
  return r;
package/dist/index.umd.js CHANGED
@@ -1,29 +1,29 @@
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`
1
+ (function(l,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):(l=typeof globalThis<"u"?globalThis:l||self,p(l["@starasia/theme"]={},l.jsxRuntime,l.React))})(this,function(l,p,m){"use strict";function C(r,t=""){let o="";for(const e in r)if(Object.hasOwnProperty.call(r,e)){const n=r[e];o+=`/* ${e} */
2
+ `;for(const s in n)if(Object.hasOwnProperty.call(n,s)){const i=n[s];o+=`--${t}-${e}-${s}: ${i};
3
+ `}}return o}function y(r,t){let o="";for(const e in r){const n=r[e];for(const s in n){const i=n[s],c=s?`${t}-${e}-${s}`:`${t}-${e}`;o+=`--${c}: ${i};
4
+ `}}return o}function E(r,t){let o="";function e(n,s,i="",c="",a=""){if(a){const u=`${i}${a}-${c}-${n}`;o+=`--${u}: ${s};
5
+ `}else{const u=`${i}${n}-${c}`;o+=`--${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 a in c){const u=c[a],$=`${t}-`;e(i,u,$,n,a)}else{const a=`${t}-`;e(i,c,a,n)}}}return o}function P(r,t=""){let o="";function e(n,s,i=""){if(typeof s=="object")for(const c in s){const a=s[c],u=`--${i}-${n}-${c}`;o+=`${u}: ${a};
7
+ `}else{const c=`--${i}-${n}`;o+=`${c}: ${s};
8
+ `}}for(const n in r){const s=r[n];if(typeof s=="object")e(n,s,`${t}`);else{const i=`--${t}-${n}`;o+=`${i}: ${s};
9
+ `}}return o}function F(r,t=""){let o="";for(const e in r){const n=r[e];for(const s in n){const i=`--${t}-${e}-${s}`,c=n[s];o+=`${i}: ${c};
10
+ `}}return o}function N(r,t){let o="";for(const e in r)if(Object.hasOwnProperty.call(r,e)){const n=r[e];e==="default"?o+=`--${t}: ${n};
11
+ `:o+=`--${t}-${e}: ${n};
12
+ `}return o}const M=r=>{const t=document.getElementById(r);if(t)return t;const o=document.createElement("style");return o.id=r,document.head.appendChild(o),o};function j(r,t){let o="";return Object.keys(r).forEach(e=>{const n=r[e];if(n&&typeof n=="object"){o+=j(n,`${t}-${e}`);return}o+=`${t}-${e}: ${n};
13
+ `}),o}function B(r,t){let o="";return r&&(o+=j(r,t)),o}function D(r){var $,b,x,v,w,O;if(!r)return;const t=($=r.colors)!=null&&$.raw?y(r.colors.raw,"sa-ui-raw-color"):"",o=(b=r.colors)!=null&&b.computed?y(r.colors.computed,"sa-ui-color"):"",e=(x=r.colors)!=null&&x.main?E(r.colors.main,"sa-ui"):"",n=(v=r.colors)!=null&&v.brand?C(r.colors.brand,"sa-ui-brand"):"",s=(w=r.colors)!=null&&w.utility?C(r.colors.utility,"sa-ui-utility"):"",i=(O=r.colors)!=null&&O.text?N(r.colors.text,"sa-ui-color-text"):"",c=r.metrics?P(r.metrics,"sa-ui"):"",a=r.font?F(r.font,"sa-ui"):"",u=r.components?B(r.components,"--sa-ui"):"";return`
14
14
  :root {
15
- ${o}
16
15
  ${t}
16
+ ${o}
17
17
  ${e}
18
18
  ${n}
19
19
  ${s}
20
20
  ${i}
21
21
  ${c}
22
- ${l}
22
+ ${a}
23
23
  ${u}
24
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(`
26
- `);return t?`:root {
27
- ${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"})});
25
+ `}const d=m.createContext({theme:void 0,setTheme:()=>{}}),H="sa-theme-style";function R(r){const t=r.split(",").map(o=>Number(o.trim()));return t.length!==3||t.some(o=>!Number.isFinite(o)||o<0||o>255)?null:"#"+t.map(o=>Math.round(o).toString(16).padStart(2,"0")).join("")}function J(r){if(!r)return"";const t=new Set(["50","100","200","300","400","500","600","700","800","900"]),o=Object.entries(r).filter(([e])=>t.has(e)).map(([e,n])=>{const s=R(n);return s?` --sa-color-brand-${e}: ${s};`:""}).filter(Boolean).join(`
26
+ `);return o?`:root {
27
+ ${o}
28
+ }`:""}function L({value:r,children:t}){const[o,e]=m.useState(r),n=m.useMemo(()=>o?JSON.stringify(o):"",[o]),s=m.useRef(M(H));m.useEffect(()=>{var c,a;if(n){const u=JSON.parse(n),$=D(u)??"",b=J((a=(c=u==null?void 0:u.colors)==null?void 0:c.raw)==null?void 0:a.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:o,setTheme:i},children:t})}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,t)=>{const o={};return Object.keys(r).forEach(e=>{if(r!=null&&r[e]&&typeof(r==null?void 0:r[e])=="object"){o[e]={...r==null?void 0:r[e],...t==null?void 0:t[e],...g(r==null?void 0:r[e],t==null?void 0:t[e])};return}o[e]=(t==null?void 0:t[e])||(r==null?void 0:r[e])}),o};function f(){const r=m.useContext(d),t=m.useMemo(()=>({...S,...r.theme,...g(S,r.theme)}),[r.theme,S]);return{...r,theme:t}}function _(){const{theme:r}=f();return r.colors}function q(){var t;const{theme:r}=f();return(t=r.metrics)==null?void 0:t.spacing}function A(){var t;const{theme:r}=f();return(t=r.metrics)==null?void 0:t.radii}function U(){var t;const{theme:r}=f();return(t=r==null?void 0:r.metrics)==null?void 0:t.shadows}function V(r){return r}l.ThemeContext=d,l.ThemeProvider=L,l.createTheme=V,l.useColor=_,l.useRadius=A,l.useShadow=U,l.useSpacing=q,l.useTheme=f,Object.defineProperty(l,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.0",
5
5
  "description": "Theme component for starasia UI",
6
6
  "main": "dist/index.umd.js",
7
7
  "module": "dist/index.es.js",