@skiddph/prui 0.2.1 → 0.4.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/theme.js CHANGED
@@ -1,51 +1,120 @@
1
- const l = ["control", "workshop", "ember", "daylight"];
1
+ const u = ["control", "workshop", "ember", "daylight"], d = "prui-theme-", c = /* @__PURE__ */ new Map(), m = [
2
+ "background",
3
+ "surface",
4
+ "raise",
5
+ "line",
6
+ "fg",
7
+ "dim",
8
+ "brand",
9
+ "brand-fg",
10
+ "ok",
11
+ "warn",
12
+ "danger"
13
+ ];
2
14
  function s(e) {
15
+ return `--prui-${e}`;
16
+ }
17
+ function f(e) {
18
+ const t = [];
19
+ for (const [r, n] of Object.entries(e))
20
+ n !== void 0 && t.push(` ${s(r)}: ${n};`);
21
+ return t.join(`
22
+ `);
23
+ }
24
+ function E(e, t) {
25
+ const r = e.trim().toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "custom";
26
+ if (c.set(r, { ...t }), typeof document < "u") {
27
+ let n = document.getElementById(`prui-custom-theme-${r}`);
28
+ n || (n = document.createElement("style"), n.id = `prui-custom-theme-${r}`, document.head.appendChild(n)), n.textContent = `.${d}${r} {
29
+ ${f(t)}
30
+ }`;
31
+ }
32
+ return r;
33
+ }
34
+ function v() {
35
+ return [...u, ...c.keys()];
36
+ }
37
+ function p(e, t = {}) {
38
+ const r = t.target ?? (typeof document < "u" ? document.documentElement : null), n = [];
39
+ if (r) {
40
+ for (const [o, l] of Object.entries(e))
41
+ l !== void 0 && (r.style.setProperty(s(o), String(l)), n.push(s(o)));
42
+ e.radius !== void 0 && (r.style.setProperty("--prui-radius", String(e.radius)), n.push("--prui-radius")), e["dim-op"] !== void 0 && (r.style.setProperty("--prui-dim-op", String(e["dim-op"])), n.push("--prui-dim-op"));
43
+ }
44
+ const i = t.storageKey === void 0 ? "prui:tokens" : t.storageKey;
45
+ return i && typeof localStorage < "u" && localStorage.setItem(i, JSON.stringify(e)), n;
46
+ }
47
+ function $(e = {}) {
48
+ const t = e.target ?? (typeof document < "u" ? document.documentElement : null);
49
+ if (t) {
50
+ for (const n of [...m, "radius", "dim-op"])
51
+ t.style.removeProperty(s(n));
52
+ t.style.removeProperty("--prui-radius"), t.style.removeProperty("--prui-dim-op");
53
+ }
54
+ const r = e.storageKey === void 0 ? "prui:tokens" : e.storageKey;
55
+ r && typeof localStorage < "u" && localStorage.removeItem(r);
56
+ }
57
+ function w(e = {}) {
58
+ if (typeof localStorage > "u") return null;
59
+ const t = e.storageKey ?? "prui:tokens", r = localStorage.getItem(t);
60
+ if (!r) return null;
61
+ try {
62
+ const n = JSON.parse(r);
63
+ return p(n, { target: e.target, storageKey: null }), n;
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
68
+ function I(e) {
3
69
  return e === "dark" ? "control" : e === "light" ? "daylight" : e;
4
70
  }
5
- const u = ["control", "workshop", "ember"], d = ["daylight"];
6
- function m(e) {
7
- return u.includes(e);
71
+ const h = ["control", "workshop", "ember"], g = ["daylight"];
72
+ function y(e) {
73
+ return h.includes(e);
8
74
  }
9
- function p(e) {
10
- return d.includes(e);
75
+ function K(e) {
76
+ return g.includes(e);
11
77
  }
12
- function c(e) {
13
- return m(e) ? "dark" : "light";
78
+ function a(e) {
79
+ const t = c.get(e);
80
+ return t != null && t.mode ? t.mode : y(e) ? "dark" : "light";
14
81
  }
15
- const i = "prui-theme-";
16
- function h(e, t) {
17
- return [`${i}${e}`, "prui-root", `prui-mode-${t}`];
82
+ function k(e, t) {
83
+ return [`${d}${e}`, "prui-root", `prui-mode-${t}`];
18
84
  }
19
- function f(e) {
85
+ function S(e) {
20
86
  const t = [...e.classList].filter(
21
- (r) => r.startsWith(i) || r === "prui-root" || r.startsWith("prui-mode-")
87
+ (r) => r.startsWith(d) || r === "prui-root" || r.startsWith("prui-mode-")
22
88
  );
23
89
  t.length && e.classList.remove(...t);
24
90
  }
25
- function g(e = {}) {
26
- const t = s(e.theme ?? "control"), r = e.mode ?? c(t), n = e.target ?? (typeof document < "u" ? document.documentElement : null);
27
- n && (f(n), n.classList.add(...h(t, r)), n.dataset.pruiTheme = t, n.dataset.pruiMode = r, n.style.colorScheme = r);
28
- const o = e.storageKey === void 0 ? "prui:theme" : e.storageKey;
29
- return o && typeof localStorage < "u" && localStorage.setItem(o, JSON.stringify({ theme: t, mode: r })), { theme: t, mode: r };
91
+ function T(e = {}) {
92
+ const t = e.theme ?? "control";
93
+ if (!(t === "dark" || t === "light" || u.includes(t) || c.has(t)))
94
+ return T({ ...e, theme: "control" });
95
+ const n = t === "dark" ? "control" : t === "light" ? "daylight" : t, i = e.mode ?? a(n), o = e.target ?? (typeof document < "u" ? document.documentElement : null);
96
+ o && (S(o), o.classList.add(...k(n, i)), o.dataset.pruiTheme = n, o.dataset.pruiMode = i, o.style.colorScheme = i);
97
+ const l = e.storageKey === void 0 ? "prui:theme" : e.storageKey;
98
+ return l && typeof localStorage < "u" && localStorage.setItem(l, JSON.stringify({ theme: n, mode: i })), { theme: n, mode: i };
30
99
  }
31
- function y(e = "prui:theme") {
100
+ function P(e = "prui:theme") {
32
101
  if (typeof localStorage > "u") return null;
33
102
  const t = localStorage.getItem(e);
34
103
  if (!t) return null;
35
104
  try {
36
- const r = JSON.parse(t), n = l.find((a) => a === r.theme);
105
+ const r = JSON.parse(t), n = u.find((o) => o === r.theme);
37
106
  if (!n) return null;
38
- const o = r.mode === "light" || r.mode === "dark" ? r.mode : c(n);
39
- return { theme: n, mode: o };
107
+ const i = r.mode === "light" || r.mode === "dark" ? r.mode : a(n);
108
+ return { theme: n, mode: i };
40
109
  } catch {
41
110
  return null;
42
111
  }
43
112
  }
44
- function T(e) {
45
- const t = l.indexOf(e);
46
- return l[(t + 1) % l.length] ?? "control";
113
+ function M(e) {
114
+ const t = u.indexOf(e);
115
+ return u[(t + 1) % u.length] ?? "control";
47
116
  }
48
- const E = {
117
+ const b = {
49
118
  name: "applyTheme",
50
119
  description: "Apply a named PRUI theme and persist the choice.",
51
120
  props: [
@@ -56,13 +125,19 @@ const E = {
56
125
  ]
57
126
  };
58
127
  export {
59
- l as PRUI_THEMES,
60
- g as applyTheme,
61
- m as isDarkTheme,
62
- p as isLightTheme,
63
- T as nextTheme,
64
- y as readPersistedTheme,
65
- s as resolveThemeName,
66
- E as themeMeta,
67
- c as themeMode
128
+ u as PRUI_THEMES,
129
+ m as PRUI_TOKENS,
130
+ T as applyTheme,
131
+ p as applyThemeTokens,
132
+ $ as clearAppliedTokens,
133
+ E as defineTheme,
134
+ y as isDarkTheme,
135
+ K as isLightTheme,
136
+ v as listThemes,
137
+ M as nextTheme,
138
+ P as readPersistedTheme,
139
+ I as resolveThemeName,
140
+ w as restoreAppliedTokens,
141
+ b as themeMeta,
142
+ a as themeMode
68
143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skiddph/prui",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "PRUI component system: primitives, app-layer super-components, pages, and themes",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -27,6 +27,10 @@
27
27
  "types": "./dist/app/index.d.ts",
28
28
  "import": "./dist/app.js"
29
29
  },
30
+ "./forms": {
31
+ "types": "./dist/forms/index.d.ts",
32
+ "import": "./dist/forms.js"
33
+ },
30
34
  "./pages": {
31
35
  "types": "./dist/pages/index.d.ts",
32
36
  "import": "./dist/pages.js"
@@ -48,6 +52,7 @@
48
52
  "tailwind-merge": "^3.3.1"
49
53
  },
50
54
  "devDependencies": {
55
+ "@tailwindcss/cli": "^4.3.3",
51
56
  "@testing-library/jest-dom": "^6.6.3",
52
57
  "@testing-library/react": "^16.3.0",
53
58
  "@testing-library/user-event": "^14.6.1",
@@ -56,13 +61,14 @@
56
61
  "@types/react-dom": "^19.1.0",
57
62
  "@vitejs/plugin-react": "^4.5.0",
58
63
  "jsdom": "^26.1.0",
64
+ "lucide-react": "^0.525.0",
65
+ "react": "^19.1.0",
66
+ "react-dom": "^19.1.0",
67
+ "tailwindcss": "^4.3.3",
59
68
  "typescript": "^5.9.3",
60
69
  "vite": "^6.3.5",
61
70
  "vite-plugin-dts": "^4.5.4",
62
- "vitest": "^3.2.4",
63
- "lucide-react": "^0.525.0",
64
- "react": "^19.1.0",
65
- "react-dom": "^19.1.0"
71
+ "vitest": "^3.2.4"
66
72
  },
67
73
  "repository": {
68
74
  "type": "git",