@starasia/theme 3.0.1 → 3.0.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.
- package/dist/default.json.d.ts +7 -7
- package/dist/helpers/injector.d.ts +1 -1
- package/dist/index.es.js +53 -51
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/default.json.d.ts
CHANGED
|
@@ -174,13 +174,13 @@ declare const _default: {
|
|
|
174
174
|
"fontWeights": {
|
|
175
175
|
"hairline": 100,
|
|
176
176
|
"thin": 100,
|
|
177
|
-
"light":
|
|
178
|
-
"normal":
|
|
179
|
-
"medium":
|
|
180
|
-
"semibold":
|
|
181
|
-
"bold":
|
|
182
|
-
"extrabold":
|
|
183
|
-
"black":
|
|
177
|
+
"light": 300,
|
|
178
|
+
"normal": 400,
|
|
179
|
+
"medium": 500,
|
|
180
|
+
"semibold": 600,
|
|
181
|
+
"bold": 700,
|
|
182
|
+
"extrabold": 800,
|
|
183
|
+
"black": 900
|
|
184
184
|
},
|
|
185
185
|
"lineHeights": {
|
|
186
186
|
"3": "0.75rem",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const injectStyles: (css: string, styleId: string) => void;
|
|
2
|
-
export declare const createStyleElement: (styleId: string) => HTMLElement;
|
|
2
|
+
export declare const createStyleElement: (styleId: string) => HTMLElement | null;
|
package/dist/index.es.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import { jsx as S } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
2
|
+
import { createContext as f, useState as E, useMemo as a, useRef as g, useEffect as v, useContext as j } from "react";
|
|
3
3
|
const w = (r) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
if (typeof document > "u")
|
|
5
|
+
return null;
|
|
6
|
+
const e = document.getElementById(r);
|
|
7
|
+
if (e)
|
|
8
|
+
return e;
|
|
9
|
+
const t = document.createElement("style");
|
|
10
|
+
return t.id = r, document.head.appendChild(t), t;
|
|
11
|
+
}, u = f({
|
|
10
12
|
theme: void 0,
|
|
11
13
|
setTheme: () => {
|
|
12
14
|
}
|
|
13
15
|
}), C = "sa-theme-style";
|
|
14
16
|
function O(r) {
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
+
const e = r.split(",").map((t) => Number(t.trim()));
|
|
18
|
+
return e.length !== 3 || e.some((t) => !Number.isFinite(t) || t < 0 || t > 255) ? null : "#" + e.map((t) => Math.round(t).toString(16).padStart(2, "0")).join("");
|
|
17
19
|
}
|
|
18
20
|
function N(r) {
|
|
19
21
|
if (!r)
|
|
20
22
|
return "";
|
|
21
|
-
const
|
|
23
|
+
const e = /* @__PURE__ */ new Set(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), t = Object.entries(r).filter(([n]) => e.has(n)).map(([n, o]) => {
|
|
22
24
|
const s = O(o);
|
|
23
25
|
return s ? ` --sa-color-brand-${n}: ${s};` : "";
|
|
24
26
|
}).filter(Boolean).join(`
|
|
25
27
|
`);
|
|
26
|
-
return
|
|
27
|
-
${
|
|
28
|
+
return t ? `:root {
|
|
29
|
+
${t}
|
|
28
30
|
}` : "";
|
|
29
31
|
}
|
|
30
|
-
function
|
|
31
|
-
const [
|
|
32
|
-
() =>
|
|
33
|
-
[
|
|
34
|
-
), s =
|
|
32
|
+
function y({ value: r, children: e }) {
|
|
33
|
+
const [t, n] = E(r), o = a(
|
|
34
|
+
() => t ? JSON.stringify(t) : "",
|
|
35
|
+
[t]
|
|
36
|
+
), s = g(w(C));
|
|
35
37
|
v(() => {
|
|
36
38
|
var c, i;
|
|
37
39
|
if (o) {
|
|
@@ -42,7 +44,7 @@ function B({ value: r, children: t }) {
|
|
|
42
44
|
const d = (c) => {
|
|
43
45
|
c && n(c);
|
|
44
46
|
};
|
|
45
|
-
return /* @__PURE__ */ S(u.Provider, { value: { theme:
|
|
47
|
+
return /* @__PURE__ */ S(u.Provider, { value: { theme: t, setTheme: d }, children: e });
|
|
46
48
|
}
|
|
47
49
|
const D = {
|
|
48
50
|
raw: {
|
|
@@ -217,13 +219,13 @@ const D = {
|
|
|
217
219
|
fontWeights: {
|
|
218
220
|
hairline: 100,
|
|
219
221
|
thin: 100,
|
|
220
|
-
light:
|
|
221
|
-
normal:
|
|
222
|
-
medium:
|
|
223
|
-
semibold:
|
|
224
|
-
bold:
|
|
225
|
-
extrabold:
|
|
226
|
-
black:
|
|
222
|
+
light: 300,
|
|
223
|
+
normal: 400,
|
|
224
|
+
medium: 500,
|
|
225
|
+
semibold: 600,
|
|
226
|
+
bold: 700,
|
|
227
|
+
extrabold: 800,
|
|
228
|
+
black: 900
|
|
227
229
|
},
|
|
228
230
|
lineHeights: {
|
|
229
231
|
3: "0.75rem",
|
|
@@ -245,22 +247,22 @@ const D = {
|
|
|
245
247
|
colors: D,
|
|
246
248
|
metrics: H,
|
|
247
249
|
font: J
|
|
248
|
-
}, p = M, b = (r,
|
|
249
|
-
const
|
|
250
|
+
}, p = M, b = (r, e) => {
|
|
251
|
+
const t = {};
|
|
250
252
|
return Object.keys(r).forEach((n) => {
|
|
251
253
|
if (r != null && r[n] && typeof (r == null ? void 0 : r[n]) == "object") {
|
|
252
|
-
|
|
254
|
+
t[n] = {
|
|
253
255
|
...r == null ? void 0 : r[n],
|
|
254
|
-
...
|
|
255
|
-
...b(r == null ? void 0 : r[n],
|
|
256
|
+
...e == null ? void 0 : e[n],
|
|
257
|
+
...b(r == null ? void 0 : r[n], e == null ? void 0 : e[n])
|
|
256
258
|
};
|
|
257
259
|
return;
|
|
258
260
|
}
|
|
259
|
-
|
|
260
|
-
}),
|
|
261
|
+
t[n] = (e == null ? void 0 : e[n]) || (r == null ? void 0 : r[n]);
|
|
262
|
+
}), t;
|
|
261
263
|
};
|
|
262
264
|
function x() {
|
|
263
|
-
const r = j(u),
|
|
265
|
+
const r = j(u), e = a(
|
|
264
266
|
() => ({
|
|
265
267
|
...p,
|
|
266
268
|
...r.theme,
|
|
@@ -268,37 +270,37 @@ function x() {
|
|
|
268
270
|
}),
|
|
269
271
|
[r.theme, p]
|
|
270
272
|
);
|
|
271
|
-
return { ...r, theme:
|
|
273
|
+
return { ...r, theme: e };
|
|
272
274
|
}
|
|
273
|
-
function
|
|
275
|
+
function B() {
|
|
274
276
|
const { theme: r } = x();
|
|
275
277
|
return r.colors;
|
|
276
278
|
}
|
|
277
|
-
function
|
|
278
|
-
var
|
|
279
|
+
function F() {
|
|
280
|
+
var e;
|
|
279
281
|
const { theme: r } = x();
|
|
280
|
-
return (
|
|
282
|
+
return (e = r.metrics) == null ? void 0 : e.spacing;
|
|
281
283
|
}
|
|
282
|
-
function
|
|
283
|
-
var
|
|
284
|
+
function L() {
|
|
285
|
+
var e;
|
|
284
286
|
const { theme: r } = x();
|
|
285
|
-
return (
|
|
287
|
+
return (e = r.metrics) == null ? void 0 : e.radii;
|
|
286
288
|
}
|
|
287
|
-
function
|
|
288
|
-
var
|
|
289
|
+
function P() {
|
|
290
|
+
var e;
|
|
289
291
|
const { theme: r } = x();
|
|
290
|
-
return (
|
|
292
|
+
return (e = r == null ? void 0 : r.metrics) == null ? void 0 : e.shadows;
|
|
291
293
|
}
|
|
292
|
-
function
|
|
294
|
+
function _(r) {
|
|
293
295
|
return r;
|
|
294
296
|
}
|
|
295
297
|
export {
|
|
296
298
|
u as ThemeContext,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
y as ThemeProvider,
|
|
300
|
+
_ as createTheme,
|
|
301
|
+
B as useColor,
|
|
302
|
+
L as useRadius,
|
|
303
|
+
P as useShadow,
|
|
304
|
+
F as useSpacing,
|
|
303
305
|
x as useTheme
|
|
304
306
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
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=>{if(typeof document>"u")return null;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,u])=>{const i=j(u);return i?` --sa-color-brand-${n}: ${i};`:""}).filter(Boolean).join(`
|
|
2
2
|
`);return t?`:root {
|
|
3
3
|
${t}
|
|
4
|
-
}`:""}function g({value:e,children:r}){const[t,n]=o.useState(e),
|
|
4
|
+
}`:""}function g({value:e,children:r}){const[t,n]=o.useState(e),u=o.useMemo(()=>t?JSON.stringify(t):"",[t]),i=o.useRef(S(E));o.useEffect(()=>{var x,b;if(u){const a=JSON.parse(u),f=h((b=(x=a==null?void 0:a.colors)==null?void 0:x.raw)==null?void 0:b.blue);f&&(i!=null&&i.current)&&(i.current.textContent=f)}},[u]);const M=x=>{x&&n(x)};return c.jsx(p.Provider,{value:{theme:t,setTheme:M},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:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800,black:900},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 y(e){return e}s.ThemeContext=p,s.ThemeProvider=g,s.createTheme=y,s.useColor=v,s.useRadius=w,s.useShadow=O,s.useSpacing=C,s.useTheme=m,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|