@kapiuara/ui 0.15.3 → 0.16.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/LICENSE +19 -15
- package/README.md +338 -6
- package/dist/components/data/KapiDataTable.d.ts +1 -1
- package/dist/components/data/KapiDataTable.js +22 -22
- package/dist/components/data/KapiPaginationFooter.js +1 -1
- package/dist/components/data/KapiSheet.d.ts +105 -0
- package/dist/components/data/KapiSheet.js +75 -0
- package/dist/components/data/KapiTable.d.ts +2 -2
- package/dist/components/data/KapiTable.js +347 -329
- package/dist/components/data/KapiTableFooter.d.ts +22 -0
- package/dist/components/data/KapiTableFooter.js +55 -0
- package/dist/components/data/KapiTableRow.js +53 -52
- package/dist/components/data/KapiTableToolbar.d.ts +4 -2
- package/dist/components/data/KapiTableToolbar.js +71 -69
- package/dist/components/data/index.d.ts +3 -1
- package/dist/components/data/tableCells.d.ts +5 -4
- package/dist/components/data/tableCells.js +42 -41
- package/dist/components/data/tableLogic.d.ts +2 -0
- package/dist/components/data/tableLogic.js +66 -66
- package/dist/components/data/tableSlots.d.ts +9 -0
- package/dist/components/data/tableSlots.js +12 -0
- package/dist/components/data/tableSpanLogic.d.ts +35 -0
- package/dist/components/data/tableSpanLogic.js +47 -0
- package/dist/components/data/tableTypes.d.ts +54 -1
- package/dist/components/data/useTableSelection.d.ts +4 -2
- package/dist/components/data/useTableSelection.js +27 -23
- package/dist/components/display/KapiAnchor.d.ts +36 -0
- package/dist/components/display/KapiAnchor.js +36 -0
- package/dist/components/display/KapiBadge.d.ts +6 -5
- package/dist/components/display/KapiBadge.js +25 -19
- package/dist/components/display/KapiText.d.ts +43 -0
- package/dist/components/display/KapiText.js +33 -0
- package/dist/components/display/KapiTitle.d.ts +33 -0
- package/dist/components/display/KapiTitle.js +29 -0
- package/dist/components/display/index.d.ts +7 -0
- package/dist/components/display/textLogic.d.ts +32 -0
- package/dist/components/display/textLogic.js +19 -0
- package/dist/components/feedback/KapiAlert.d.ts +8 -4
- package/dist/components/feedback/KapiAlert.js +39 -34
- package/dist/components/inputs/KapiButton.d.ts +7 -4
- package/dist/components/inputs/KapiButton.js +47 -42
- package/dist/components/inputs/KapiSelect.d.ts +12 -0
- package/dist/components/inputs/KapiSelect.js +215 -212
- package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
- package/dist/components/inputs/KapiSelectMenu.js +131 -133
- package/dist/components/inputs/fieldLogic.d.ts +2 -2
- package/dist/components/inputs/index.d.ts +1 -1
- package/dist/components/inputs/selectSlots.d.ts +24 -0
- package/dist/components/inputs/selectSlots.js +27 -0
- package/dist/components/layout/KapiBox.d.ts +31 -0
- package/dist/components/layout/KapiBox.js +26 -0
- package/dist/components/layout/KapiCard.d.ts +16 -4
- package/dist/components/layout/KapiCard.js +46 -34
- package/dist/components/layout/KapiCenter.d.ts +13 -0
- package/dist/components/layout/KapiCenter.js +23 -0
- package/dist/components/layout/KapiCol.d.ts +22 -0
- package/dist/components/layout/KapiCol.js +23 -0
- package/dist/components/layout/KapiGrid.d.ts +29 -3
- package/dist/components/layout/KapiGrid.js +39 -17
- package/dist/components/layout/KapiPageHeader.d.ts +10 -1
- package/dist/components/layout/KapiPageHeader.js +82 -80
- package/dist/components/layout/KapiPanelParts.d.ts +11 -2
- package/dist/components/layout/KapiPanelParts.js +73 -56
- package/dist/components/layout/KapiRail.d.ts +10 -1
- package/dist/components/layout/KapiRail.js +123 -120
- package/dist/components/layout/KapiRoot.d.ts +35 -5
- package/dist/components/layout/KapiRoot.js +54 -39
- package/dist/components/layout/KapiShell.d.ts +36 -3
- package/dist/components/layout/KapiShell.js +53 -50
- package/dist/components/layout/cardSlots.d.ts +9 -0
- package/dist/components/layout/cardSlots.js +12 -0
- package/dist/components/layout/gridSpanLogic.d.ts +46 -0
- package/dist/components/layout/gridSpanLogic.js +39 -0
- package/dist/components/layout/index.d.ts +11 -4
- package/dist/components/layout/layoutPrimitives.d.ts +11 -0
- package/dist/components/layout/layoutPrimitives.js +12 -1
- package/dist/components/layout/pageHeaderSlots.d.ts +12 -0
- package/dist/components/layout/pageHeaderSlots.js +15 -0
- package/dist/components/layout/railLogic.d.ts +16 -3
- package/dist/components/layout/railSlots.d.ts +12 -0
- package/dist/components/layout/railSlots.js +15 -0
- package/dist/components/layout/shellSlots.d.ts +6 -0
- package/dist/components/layout/shellSlots.js +9 -0
- package/dist/components/layout/useGridBreakpoint.d.ts +12 -0
- package/dist/components/layout/useGridBreakpoint.js +35 -0
- package/dist/components/navigation/KapiBreadcrumb.d.ts +18 -2
- package/dist/components/navigation/KapiBreadcrumb.js +23 -16
- package/dist/components/navigation/KapiContextPanel.d.ts +17 -4
- package/dist/components/navigation/KapiContextPanel.js +151 -135
- package/dist/components/navigation/KapiPanelGroup.d.ts +16 -4
- package/dist/components/navigation/KapiPanelGroup.js +66 -65
- package/dist/components/navigation/KapiTabs.d.ts +12 -0
- package/dist/components/navigation/KapiTabs.js +87 -71
- package/dist/components/navigation/MiniNavItem.d.ts +7 -2
- package/dist/components/navigation/MiniNavItem.js +41 -36
- package/dist/components/navigation/breadcrumbLogic.d.ts +4 -2
- package/dist/components/navigation/breadcrumbLogic.js +1 -1
- package/dist/components/navigation/navLink.d.ts +21 -0
- package/dist/components/navigation/navLink.js +26 -0
- package/dist/components/navigation/navLinkLogic.d.ts +18 -0
- package/dist/components/navigation/navLinkLogic.js +22 -0
- package/dist/components/overlays/KapiContextMenu.d.ts +8 -0
- package/dist/components/overlays/KapiModal.d.ts +9 -0
- package/dist/components/overlays/KapiModal.js +77 -75
- package/dist/components/overlays/index.d.ts +1 -1
- package/dist/components/overlays/menuList.js +123 -113
- package/dist/components/overlays/modalSlots.d.ts +11 -0
- package/dist/components/overlays/modalSlots.js +14 -0
- package/dist/components/slotCatalog.d.ts +90 -0
- package/dist/components/slotCatalog.js +19 -0
- package/dist/components/slotsLogic.d.ts +34 -0
- package/dist/components/slotsLogic.js +18 -0
- package/dist/components/tone.d.ts +26 -0
- package/dist/components/tone.js +15 -14
- package/dist/css/base.css +1 -1
- package/dist/css/components/data/KapiEventCalendar.css +1 -1
- package/dist/css/components/data/KapiTable.css +1 -1
- package/dist/css/components/display/display.css +1 -1
- package/dist/css/components/display/typography.css +1 -0
- package/dist/css/components/feedback/feedback.css +1 -1
- package/dist/css/components/inputs/KapiButton.css +1 -1
- package/dist/css/components/inputs/KapiDatePicker.css +1 -1
- package/dist/css/components/layout/KapiBox.css +1 -0
- package/dist/css/components/layout/KapiRail.css +1 -1
- package/dist/css/components/layout/gridSpan.css +1 -0
- package/dist/css/components/navigation/navigation.css +1 -1
- package/dist/hooks/densityLogic.d.ts +15 -0
- package/dist/hooks/densityLogic.js +4 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/themeColorsLogic.d.ts +19 -0
- package/dist/hooks/themeColorsLogic.js +4 -2
- package/dist/hooks/themeDeriveLogic.d.ts +16 -0
- package/dist/hooks/themeDeriveLogic.js +27 -17
- package/dist/hooks/toneFamilyLogic.d.ts +122 -0
- package/dist/hooks/toneFamilyLogic.js +151 -0
- package/dist/hooks/useKapiTheme.d.ts +8 -2
- package/dist/hooks/useKapiTheme.js +116 -103
- package/dist/hooks/useToneFamilies.d.ts +30 -0
- package/dist/hooks/useToneFamilies.js +46 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +213 -204
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/styles/rawHeights.d.ts +8 -0
- package/package.json +2 -2
|
@@ -1,57 +1,70 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { parseColor as e } from "./colorLogic.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { baseSurfaces as t, deriveTheme as n } from "./themeDeriveLogic.js";
|
|
4
|
+
import { resolveToneFamilies as r } from "./toneFamilyLogic.js";
|
|
5
|
+
import { defaultStorage as i, readWithLegacy as a, storageKey as o } from "./storageLogic.js";
|
|
6
|
+
import { useHydrated as s } from "./useHydrated.js";
|
|
7
|
+
import { useMediaQuery as c } from "./useMediaQuery.js";
|
|
8
|
+
import { NO_THEME_COLORS as l, mergeThemeColors as u, parseStoredThemeColors as d, resolveBrandTheme as f, sanitizeThemeColors as p, serializeThemeColors as m } from "./themeColorsLogic.js";
|
|
9
|
+
import { NO_THEME_RADII as h, mergeThemeRadii as g, parseStoredThemeRadii as _, sanitizeThemeRadii as v, serializeThemeRadii as y } from "./themeRadiiLogic.js";
|
|
10
|
+
import { createContext as b, useCallback as x, useContext as S, useEffect as C, useMemo as w, useState as T } from "react";
|
|
10
11
|
//#region src/hooks/useKapiTheme.ts
|
|
11
|
-
var
|
|
12
|
-
theme:
|
|
13
|
-
accent:
|
|
14
|
-
font:
|
|
15
|
-
motion:
|
|
16
|
-
customTheme:
|
|
17
|
-
radii:
|
|
18
|
-
}),
|
|
12
|
+
var E = "(prefers-color-scheme: dark)", D = (e) => ({
|
|
13
|
+
theme: o(e, "theme"),
|
|
14
|
+
accent: o(e, "accent"),
|
|
15
|
+
font: o(e, "font"),
|
|
16
|
+
motion: o(e, "motion"),
|
|
17
|
+
customTheme: o(e, "customTheme"),
|
|
18
|
+
radii: o(e, "radii")
|
|
19
|
+
}), O = {
|
|
19
20
|
theme: "v2_theme",
|
|
20
21
|
accent: "v2_accent",
|
|
21
22
|
font: "v2_font",
|
|
22
23
|
motion: "v2_motion"
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
-
var
|
|
25
|
+
D().theme, D().accent, D().font, D().motion;
|
|
26
|
+
var k = {
|
|
26
27
|
roboto: "'Roboto Variable', 'Roboto', system-ui, sans-serif",
|
|
27
28
|
system: "system-ui, -apple-system, 'Segoe UI', sans-serif"
|
|
28
|
-
},
|
|
29
|
+
}, A = (e, t, n) => a(i(), D(e)[t], O[t]) || n, j = (e, t) => {
|
|
29
30
|
try {
|
|
30
31
|
localStorage.setItem(e, t);
|
|
31
32
|
} catch {}
|
|
32
|
-
},
|
|
33
|
-
let t =
|
|
34
|
-
return
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
}, M = (e) => e === "light" || e === "dark", N = (e) => M(e) || e === "system", P = (e, t) => e === "system" ? t ? "dark" : "light" : e, F = (e) => {
|
|
34
|
+
let t = A(e, "theme", "light");
|
|
35
|
+
return N(t) ? t : "light";
|
|
36
|
+
}, I = (e) => e === "dark" ? "light" : "dark", L = (e) => Object.hasOwn(k, e), R = (e) => e === "auto" || e === "reduced", z = (n, i, a) => {
|
|
37
|
+
if (!n) return {};
|
|
38
|
+
let o = t(i), s = e(a["--kapi-card"] ?? o.card) ?? {
|
|
39
|
+
r: 255,
|
|
40
|
+
g: 255,
|
|
41
|
+
b: 255,
|
|
42
|
+
a: 1
|
|
43
|
+
}, c = e(a["--kapi-bg"] ?? o.bg) ?? s;
|
|
44
|
+
return r(n, i, s, c).tokens;
|
|
45
|
+
}, B = (t, r, i) => {
|
|
46
|
+
let a = f(r, t.theme ?? "light"), o = t.fontChosen && a ? {
|
|
47
|
+
...a,
|
|
38
48
|
font: void 0
|
|
39
|
-
} :
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
} : a, s = u(o, t.accent ? { primary: t.accent } : null, t.customTheme), c = s.primary && !e(s.primary) ? s.primary : void 0;
|
|
50
|
+
c && delete s.primary;
|
|
51
|
+
let l = t.theme ?? "light", d = n({
|
|
52
|
+
base: l,
|
|
53
|
+
colors: s,
|
|
54
|
+
radii: g(t.radii)
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
"--kapi-font": k[t.font] ?? k.roboto,
|
|
58
|
+
...d,
|
|
59
|
+
...c ? { "--kapi-primary": c } : {},
|
|
60
|
+
...z(i, l, d)
|
|
48
61
|
};
|
|
49
|
-
},
|
|
62
|
+
}, V = b({
|
|
50
63
|
theme: "light",
|
|
51
64
|
preference: "light",
|
|
52
65
|
accent: "",
|
|
53
|
-
customTheme:
|
|
54
|
-
radii:
|
|
66
|
+
customTheme: l,
|
|
67
|
+
radii: h,
|
|
55
68
|
font: "roboto",
|
|
56
69
|
fontChosen: !1,
|
|
57
70
|
motion: "auto",
|
|
@@ -64,109 +77,109 @@ var E = {
|
|
|
64
77
|
setFont: () => {},
|
|
65
78
|
setMotion: () => {},
|
|
66
79
|
toggleMotion: () => {}
|
|
67
|
-
}),
|
|
80
|
+
}), H = Symbol("server"), U = {
|
|
68
81
|
preference: "light",
|
|
69
82
|
accent: "",
|
|
70
|
-
customTheme:
|
|
71
|
-
radii:
|
|
83
|
+
customTheme: l,
|
|
84
|
+
radii: h,
|
|
72
85
|
font: "roboto",
|
|
73
86
|
fontChosen: !1,
|
|
74
87
|
motion: "auto"
|
|
75
|
-
},
|
|
76
|
-
if (e ===
|
|
77
|
-
let t =
|
|
88
|
+
}, W = (e) => {
|
|
89
|
+
if (e === H) return U;
|
|
90
|
+
let t = A(e, "font", ""), n = A(e, "motion", "auto");
|
|
78
91
|
return {
|
|
79
|
-
preference:
|
|
80
|
-
accent:
|
|
81
|
-
customTheme:
|
|
82
|
-
radii:
|
|
83
|
-
font:
|
|
84
|
-
fontChosen:
|
|
85
|
-
motion:
|
|
92
|
+
preference: F(e),
|
|
93
|
+
accent: A(e, "accent", ""),
|
|
94
|
+
customTheme: d(A(e, "customTheme", "")),
|
|
95
|
+
radii: _(A(e, "radii", "")),
|
|
96
|
+
font: L(t) ? t : "roboto",
|
|
97
|
+
fontChosen: L(t),
|
|
98
|
+
motion: R(n) ? n : "auto"
|
|
86
99
|
};
|
|
87
|
-
},
|
|
88
|
-
let t =
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
let e =
|
|
92
|
-
|
|
100
|
+
}, G = ({ namespace: e } = {}) => {
|
|
101
|
+
let t = w(() => D(e), [e]), n = s(), r = n ? e : H, [i] = T(() => W(r)), [a, o] = T(i.preference), l = P(a, c(E)), [u, d] = T(i.accent), [f, h] = T(i.customTheme), [g, _] = T(i.radii), [b, S] = T(i.fontChosen), [O, k] = T(i.font), [A, M] = T(i.motion), [N, F] = T(r);
|
|
102
|
+
if (N !== r) {
|
|
103
|
+
F(r);
|
|
104
|
+
let e = W(r);
|
|
105
|
+
o(e.preference), d(e.accent), h(e.customTheme), _(e.radii), k(e.font), S(e.fontChosen), M(e.motion);
|
|
93
106
|
}
|
|
94
|
-
|
|
95
|
-
n &&
|
|
107
|
+
C(() => {
|
|
108
|
+
n && j(t.theme, a);
|
|
96
109
|
}, [
|
|
97
110
|
t,
|
|
98
|
-
|
|
111
|
+
a,
|
|
99
112
|
n
|
|
100
|
-
]),
|
|
101
|
-
n &&
|
|
113
|
+
]), C(() => {
|
|
114
|
+
n && j(t.accent, u);
|
|
102
115
|
}, [
|
|
103
116
|
t,
|
|
104
|
-
|
|
117
|
+
u,
|
|
105
118
|
n
|
|
106
|
-
]),
|
|
107
|
-
n &&
|
|
119
|
+
]), C(() => {
|
|
120
|
+
n && j(t.customTheme, m(f));
|
|
108
121
|
}, [
|
|
109
122
|
t,
|
|
110
|
-
|
|
123
|
+
f,
|
|
111
124
|
n
|
|
112
|
-
]),
|
|
113
|
-
n &&
|
|
125
|
+
]), C(() => {
|
|
126
|
+
n && j(t.radii, y(g));
|
|
114
127
|
}, [
|
|
115
128
|
t,
|
|
116
|
-
|
|
129
|
+
g,
|
|
117
130
|
n
|
|
118
|
-
]),
|
|
119
|
-
n &&
|
|
131
|
+
]), C(() => {
|
|
132
|
+
n && b && j(t.font, O);
|
|
120
133
|
}, [
|
|
121
134
|
t,
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
O,
|
|
136
|
+
b,
|
|
124
137
|
n
|
|
125
|
-
]),
|
|
126
|
-
n &&
|
|
138
|
+
]), C(() => {
|
|
139
|
+
n && j(t.motion, A);
|
|
127
140
|
}, [
|
|
128
141
|
t,
|
|
129
|
-
|
|
142
|
+
A,
|
|
130
143
|
n
|
|
131
144
|
]);
|
|
132
|
-
let L =
|
|
133
|
-
|
|
134
|
-
}, []), G =
|
|
135
|
-
return
|
|
145
|
+
let L = x(() => o(I(l)), [l]), R = x((e) => o(e), []), z = x((e) => d(e || ""), []), B = x((e) => h(p(e)), []), V = x((e) => _(v(e)), []), U = x((e) => {
|
|
146
|
+
k(e), S(!0);
|
|
147
|
+
}, []), G = x(() => M((e) => e === "reduced" ? "auto" : "reduced"), []);
|
|
148
|
+
return w(() => ({
|
|
136
149
|
theme: l,
|
|
137
|
-
preference:
|
|
138
|
-
accent:
|
|
139
|
-
customTheme:
|
|
140
|
-
radii:
|
|
141
|
-
font:
|
|
142
|
-
fontChosen:
|
|
143
|
-
motion:
|
|
144
|
-
setTheme:
|
|
145
|
-
setPreference:
|
|
150
|
+
preference: a,
|
|
151
|
+
accent: u,
|
|
152
|
+
customTheme: f,
|
|
153
|
+
radii: g,
|
|
154
|
+
font: O,
|
|
155
|
+
fontChosen: b,
|
|
156
|
+
motion: A,
|
|
157
|
+
setTheme: R,
|
|
158
|
+
setPreference: o,
|
|
146
159
|
toggle: L,
|
|
147
|
-
setAccent:
|
|
148
|
-
setCustomTheme:
|
|
149
|
-
setRadii:
|
|
150
|
-
setFont:
|
|
151
|
-
setMotion:
|
|
160
|
+
setAccent: z,
|
|
161
|
+
setCustomTheme: B,
|
|
162
|
+
setRadii: V,
|
|
163
|
+
setFont: U,
|
|
164
|
+
setMotion: M,
|
|
152
165
|
toggleMotion: G
|
|
153
166
|
}), [
|
|
154
167
|
l,
|
|
155
|
-
|
|
168
|
+
a,
|
|
169
|
+
u,
|
|
156
170
|
f,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
z,
|
|
171
|
+
g,
|
|
172
|
+
O,
|
|
173
|
+
b,
|
|
174
|
+
A,
|
|
175
|
+
R,
|
|
163
176
|
L,
|
|
177
|
+
z,
|
|
178
|
+
B,
|
|
164
179
|
V,
|
|
165
|
-
H,
|
|
166
180
|
U,
|
|
167
|
-
W,
|
|
168
181
|
G
|
|
169
182
|
]);
|
|
170
|
-
},
|
|
183
|
+
}, K = () => S(V);
|
|
171
184
|
//#endregion
|
|
172
|
-
export {
|
|
185
|
+
export { E as DARK_SCHEME_QUERY, k as FONTS, V as KapiThemeContext, O as LEGACY_THEME_KEYS, L as isFontKey, R as isMotion, M as isTheme, N as isThemePreference, F as readThemePreference, P as resolveTheme, B as themeRootStyle, D as themeStorageKeys, I as toggledPreference, K as useKapiTheme, G as useKapiThemeState };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
import { type KapiToneFamilies, type KapiToneFamilyProblem } from "./toneFamilyLogic.js";
|
|
3
|
+
/** Nombres de las familias de tono registradas en la raíz `.kapi` más cercana. Interno. */
|
|
4
|
+
export declare const ToneFamilyNamesContext: import("react").Context<ReadonlySet<string>>;
|
|
5
|
+
/**
|
|
6
|
+
* Registro de una raíz: los nombres válidos (los de la raíz de arriba más los propios, porque las
|
|
7
|
+
* variables CSS se heredan y una raíz anidada sigue viendo las familias de la de afuera) y los
|
|
8
|
+
* problemas de lo que la app declaró. Los nombres y los problemas no dependen del esquema ni de la
|
|
9
|
+
* tarjeta, así que se resuelven una vez por objeto de familias. Interno.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useToneFamilyRegistry: (families: KapiToneFamilies | undefined) => {
|
|
12
|
+
names: ReadonlySet<string>;
|
|
13
|
+
problems: KapiToneFamilyProblem[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Aviso de desarrollo: una familia que la app declaró mal se descarta, y un `tone` que apunta a
|
|
17
|
+
* ella quedaría sin color. Una vez por familia y por raíz. En producción no hace nada. Interno.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useToneFamilyProblemWarning: (problems: readonly KapiToneFamilyProblem[]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Resuelve el `tone` de un componente. Un valor de la librería (o una forma como `solid`) pasa tal
|
|
22
|
+
* cual y no lleva estilo. Una familia registrada vuelve con los cuatro slots locales en `style`.
|
|
23
|
+
* Una que NO está registrada (typo, o una raíz sin `toneFamilies`) vuelve como `undefined`, o sea
|
|
24
|
+
* el default del componente, y avisa en desarrollo: sin esto, `var(--kapi-family-x)` no existe y
|
|
25
|
+
* el color se resuelve a nada, que es el fallo silencioso que esta librería no acepta. Interno.
|
|
26
|
+
*/
|
|
27
|
+
export declare const useToneLook: <T extends string>(component: string, tone: T | undefined) => {
|
|
28
|
+
tone: T | undefined;
|
|
29
|
+
style: CSSProperties | undefined;
|
|
30
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { RESERVED_TONE_NAMES as e, resolveToneFamilies as t, toneFamilyStyle as n } from "./toneFamilyLogic.js";
|
|
3
|
+
import { createContext as r, useContext as i, useEffect as a, useMemo as o, useRef as s } from "react";
|
|
4
|
+
var c = r(/* @__PURE__ */ new Set()), l = (e) => {
|
|
5
|
+
let n = i(c);
|
|
6
|
+
return o(() => {
|
|
7
|
+
if (!e) return {
|
|
8
|
+
names: n,
|
|
9
|
+
problems: []
|
|
10
|
+
};
|
|
11
|
+
let r = t(e, "light", {
|
|
12
|
+
r: 255,
|
|
13
|
+
g: 255,
|
|
14
|
+
b: 255,
|
|
15
|
+
a: 1
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
names: /* @__PURE__ */ new Set([...n, ...r.names]),
|
|
19
|
+
problems: r.problems
|
|
20
|
+
};
|
|
21
|
+
}, [e, n]);
|
|
22
|
+
}, u = (e) => {
|
|
23
|
+
let t = s(/* @__PURE__ */ new Set());
|
|
24
|
+
a(() => {
|
|
25
|
+
if (process.env.NODE_ENV !== "production") for (let n of e) t.current.has(n.name) || (t.current.add(n.name), console.warn(`KapiRoot toneFamilies: la familia "${n.name}" no se registró (${n.reason}). ${n.detail}`));
|
|
26
|
+
}, [e]);
|
|
27
|
+
}, d = (t, r) => {
|
|
28
|
+
let l = i(c), u = r !== void 0 && !e.has(r), d = u && l.has(r), f = s(null);
|
|
29
|
+
return a(() => {
|
|
30
|
+
process.env.NODE_ENV !== "production" && u && !d && f.current !== r && (f.current = r, console.warn(`${t}: tone="${r}" no es un tono de la librería ni una familia registrada (\`toneFamilies\` en KapiRoot / KapiShell). Se dibuja con el color por defecto del componente.`));
|
|
31
|
+
}, [
|
|
32
|
+
t,
|
|
33
|
+
r,
|
|
34
|
+
u,
|
|
35
|
+
d
|
|
36
|
+
]), o(() => ({
|
|
37
|
+
tone: u && !d ? void 0 : r,
|
|
38
|
+
style: d ? n(r) : void 0
|
|
39
|
+
}), [
|
|
40
|
+
r,
|
|
41
|
+
u,
|
|
42
|
+
d
|
|
43
|
+
]);
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { c as ToneFamilyNamesContext, u as useToneFamilyProblemWarning, l as useToneFamilyRegistry, d as useToneLook };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export * from "./components/locale/index.js";
|
|
|
10
10
|
export * from "./hooks/index.js";
|
|
11
11
|
export { withLabels } from "./components/labelsLogic.js";
|
|
12
12
|
export type { KapiLabelsOverride } from "./components/labelsLogic.js";
|
|
13
|
-
export type { KapiTone } from "./components/tone.js";
|
|
13
|
+
export type { KapiCustomTones, KapiFamilyTone, KapiTone, KapiToneName } from "./components/tone.js";
|
|
14
14
|
export type { KapiRender } from "./components/renderSlot.js";
|
|
15
|
+
export { KAPI_SLOTS } from "./components/slotCatalog.js";
|
|
16
|
+
export type { KapiClassNames, KapiSlotComponent, KapiSlotName } from "./components/slotCatalog.js";
|
|
15
17
|
export type { KapiCloseReason } from "./components/closeReason.js";
|