@kapiuara/ui 0.15.2 → 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 +48 -43
- 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 +66 -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 +4 -4
|
@@ -3,171 +3,174 @@ import "#kapi-css/components/layout/KapiRail.css";
|
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
4
|
import { assignRef as t } from "../inputs/fieldLogic.js";
|
|
5
5
|
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
6
|
+
import { slot as r } from "../slotsLogic.js";
|
|
7
|
+
import { useSlidingIndicator as i } from "../../hooks/useSlidingIndicator.js";
|
|
8
|
+
import { KapiTooltip as a } from "../overlays/KapiTooltip.js";
|
|
9
|
+
import { DEFAULT_LINK_LABELS as o } from "../locale/linkLabels.js";
|
|
10
|
+
import { KapiMenuButton as s } from "../overlays/KapiMenuButton.js";
|
|
11
|
+
import { navBadgeA11yText as c } from "../navigation/navBadgeLogic.js";
|
|
12
|
+
import { KapiNavBadge as l } from "../navigation/KapiNavBadge.js";
|
|
13
|
+
import { useScrollEdges as u } from "../../hooks/useScrollEdges.js";
|
|
14
|
+
import { renderNavLink as ee } from "../navigation/navLink.js";
|
|
15
|
+
import { SHELL_MOBILE_QUERY as d, useMediaQuery as f } from "../../hooks/useMediaQuery.js";
|
|
16
|
+
import { useBottomBarInset as p } from "../../hooks/useBottomBarInset.js";
|
|
17
|
+
import { isRailSeparator as m, railClasses as h, railItemClasses as g, railOverflowState as _, railShowsTooltip as v, splitRailEntries as y, splitRailOverflow as b } from "./railLogic.js";
|
|
18
|
+
import { useRailOverflow as x } from "./useRailOverflow.js";
|
|
19
|
+
import { RailVariantContext as S } from "./railContext.js";
|
|
18
20
|
/* empty css */
|
|
19
|
-
import {
|
|
20
|
-
import { Fragment as
|
|
21
|
-
import {
|
|
21
|
+
import { RAIL_SLOTS as C } from "./railSlots.js";
|
|
22
|
+
import { Fragment as te, useCallback as w, useState as T } from "react";
|
|
23
|
+
import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
24
|
+
import { ExternalLink as ne, MoreHorizontal as re } from "lucide-react";
|
|
22
25
|
//#region src/components/layout/KapiRail.tsx
|
|
23
|
-
var
|
|
26
|
+
var k = {
|
|
24
27
|
navigation: "Navegación principal",
|
|
25
28
|
more: "Más",
|
|
26
29
|
moreCurrent: "sección actual",
|
|
27
30
|
account: "Cuenta"
|
|
28
|
-
},
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
}, [
|
|
34
|
-
enabled:
|
|
31
|
+
}, A = ({ items: A, activeId: j, onSelect: M, brand: N, footer: P, variant: F = "labeled", "aria-label": ie, labels: I, className: L, classNames: R, ref: z, ...ae }) => {
|
|
32
|
+
let B = n("rail", k, I), oe = n("link", o, I), V = F === "compact", se = v(F), H = y(A), U = f(d), [W, G] = T(null);
|
|
33
|
+
p(W, U);
|
|
34
|
+
let ce = w((e) => {
|
|
35
|
+
G(e), t(z, e);
|
|
36
|
+
}, [z]), { ref: K, edges: q } = u({ axis: "y" }), J = H.scroll, Y = J.filter((e) => !m(e)).length, le = x(K, {
|
|
37
|
+
enabled: U,
|
|
35
38
|
count: Y,
|
|
36
39
|
separators: J.length - Y
|
|
37
|
-
}), { shown:
|
|
38
|
-
active:
|
|
40
|
+
}), { shown: ue, hidden: X } = b(J, le ?? Y), Z = _(X, j), { containerRef: Q, indicatorRef: de } = i({
|
|
41
|
+
active: j ?? null,
|
|
39
42
|
deps: [
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
A,
|
|
44
|
+
F,
|
|
42
45
|
X.length
|
|
43
46
|
],
|
|
44
47
|
findActive: (e) => e.querySelector(".kapi-rail__item[aria-current=\"page\"], .kapi-rail__more--on")
|
|
45
|
-
}),
|
|
48
|
+
}), fe = w((e) => {
|
|
46
49
|
Q.current = e, K.current = e;
|
|
47
|
-
}, [Q, K]),
|
|
48
|
-
let
|
|
49
|
-
value:
|
|
50
|
-
tone:
|
|
51
|
-
label:
|
|
50
|
+
}, [Q, K]), pe = ({ id: e, label: t, icon: n, href: i, render: o, external: s, newTab: u, badge: d, badgeTone: f, badgeLabel: p }) => {
|
|
51
|
+
let m = j === e, h = m ? "page" : void 0, _ = c(d, p), v = _ === null ? t : `${t} ${_}`, y = V ? v : void 0, b = /* @__PURE__ */ D(l, {
|
|
52
|
+
value: d,
|
|
53
|
+
tone: f,
|
|
54
|
+
label: p,
|
|
52
55
|
placement: "corner",
|
|
53
56
|
announce: !V
|
|
54
|
-
}),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}),
|
|
66
|
-
v
|
|
67
|
-
]
|
|
68
|
-
}, H ? void 0 : e) : /* @__PURE__ */ E("a", {
|
|
69
|
-
className: h({
|
|
70
|
-
active: f,
|
|
71
|
-
link: !0
|
|
57
|
+
}), x = /* @__PURE__ */ O(E, { children: [
|
|
58
|
+
n,
|
|
59
|
+
!V && /* @__PURE__ */ D("span", {
|
|
60
|
+
...r(C, "label", R),
|
|
61
|
+
children: t
|
|
62
|
+
}),
|
|
63
|
+
b,
|
|
64
|
+
(i !== void 0 || o !== void 0) && s && /* @__PURE__ */ D(ne, {
|
|
65
|
+
className: "kapi-rail__ext",
|
|
66
|
+
size: 12,
|
|
67
|
+
"aria-hidden": "true"
|
|
72
68
|
}),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
69
|
+
(i !== void 0 || o !== void 0) && u && /* @__PURE__ */ D("span", {
|
|
70
|
+
className: "kapi-rail__sr",
|
|
71
|
+
children: oe.newTab
|
|
72
|
+
})
|
|
73
|
+
] }), S = r(C, "item", R, g({
|
|
74
|
+
active: m,
|
|
75
|
+
link: !0
|
|
76
|
+
})), w = i !== void 0 || o !== void 0 ? ee({
|
|
77
|
+
render: o,
|
|
78
|
+
href: i,
|
|
79
|
+
newTab: u,
|
|
80
|
+
active: m,
|
|
81
|
+
className: S.className ?? "",
|
|
82
|
+
extra: {
|
|
83
|
+
"aria-label": y,
|
|
84
|
+
"data-slot": S["data-slot"]
|
|
85
|
+
},
|
|
86
|
+
children: x
|
|
87
|
+
}) : /* @__PURE__ */ D("button", {
|
|
88
|
+
type: "button",
|
|
89
|
+
...r(C, "item", R, g({ active: m })),
|
|
90
|
+
onClick: () => M?.(e),
|
|
91
|
+
"aria-current": h,
|
|
92
|
+
"aria-label": y,
|
|
93
|
+
children: x
|
|
94
|
+
});
|
|
95
|
+
return se ? /* @__PURE__ */ D(a, {
|
|
96
|
+
label: v,
|
|
97
|
+
children: w
|
|
98
|
+
}, e) : /* @__PURE__ */ D(te, { children: w }, e);
|
|
99
|
+
}, $ = (e) => e.map((e, t) => m(e) ? /* @__PURE__ */ D("div", {
|
|
100
|
+
...r(C, "separator", R),
|
|
102
101
|
role: "separator",
|
|
103
102
|
"aria-orientation": "horizontal"
|
|
104
|
-
}, e.id ?? `sep-${t}`) :
|
|
105
|
-
let
|
|
103
|
+
}, e.id ?? `sep-${t}`) : pe(e)), me = X.map(({ id: e, label: t, href: n, render: r, newTab: i, badge: a, badgeLabel: o }) => {
|
|
104
|
+
let s = c(a, o);
|
|
106
105
|
return {
|
|
107
|
-
label:
|
|
108
|
-
current:
|
|
106
|
+
label: s === null ? t : `${t} ${s}`,
|
|
107
|
+
current: j === e,
|
|
108
|
+
...r === void 0 ? n === void 0 ? {} : {
|
|
109
|
+
href: n,
|
|
110
|
+
...i ? { target: "_blank" } : {}
|
|
111
|
+
} : { render: r },
|
|
109
112
|
onClick: () => {
|
|
110
|
-
n === void 0
|
|
113
|
+
n === void 0 && r === void 0 && M?.(e);
|
|
111
114
|
}
|
|
112
115
|
};
|
|
113
116
|
});
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
...
|
|
116
|
-
ref:
|
|
117
|
-
|
|
118
|
-
"aria-label":
|
|
117
|
+
return /* @__PURE__ */ O("nav", {
|
|
118
|
+
...ae,
|
|
119
|
+
ref: ce,
|
|
120
|
+
...r(C, "root", R, h({ variant: F }), L),
|
|
121
|
+
"aria-label": ie ?? B.navigation,
|
|
119
122
|
children: [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
children:
|
|
123
|
+
N !== void 0 && /* @__PURE__ */ D("div", {
|
|
124
|
+
...r(C, "brand", R),
|
|
125
|
+
children: N
|
|
123
126
|
}),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
children: $(
|
|
127
|
+
H.start.length > 0 && /* @__PURE__ */ D("div", {
|
|
128
|
+
...r(C, "start", R),
|
|
129
|
+
children: $(H.start)
|
|
127
130
|
}),
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
ref:
|
|
130
|
-
|
|
131
|
-
"data-edge-start": !
|
|
132
|
-
"data-edge-end": !
|
|
131
|
+
/* @__PURE__ */ O("div", {
|
|
132
|
+
ref: fe,
|
|
133
|
+
...r(C, "scroll", R, !U && "kapi-fade-y"),
|
|
134
|
+
"data-edge-start": !U && q.start ? "" : void 0,
|
|
135
|
+
"data-edge-end": !U && q.end ? "" : void 0,
|
|
133
136
|
children: [
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
ref:
|
|
136
|
-
|
|
137
|
+
/* @__PURE__ */ D("span", {
|
|
138
|
+
ref: de,
|
|
139
|
+
...r(C, "indicator", R),
|
|
137
140
|
"aria-hidden": "true"
|
|
138
141
|
}),
|
|
139
|
-
$(
|
|
140
|
-
X.length > 0 && /* @__PURE__ */
|
|
142
|
+
$(ue),
|
|
143
|
+
X.length > 0 && /* @__PURE__ */ D(s, {
|
|
141
144
|
className: e("kapi-rail__more", Z.current && "kapi-rail__more--on"),
|
|
142
145
|
variant: "ghost",
|
|
143
146
|
drop: "up",
|
|
144
|
-
icon: /* @__PURE__ */
|
|
147
|
+
icon: /* @__PURE__ */ D(re, {
|
|
145
148
|
size: 21,
|
|
146
149
|
strokeWidth: 1.8
|
|
147
150
|
}),
|
|
148
|
-
...V || Z.current ? { "aria-label": Z.current ? `${
|
|
149
|
-
label: /* @__PURE__ */ E
|
|
150
|
-
|
|
151
|
-
children:
|
|
152
|
-
}), Z.notice && /* @__PURE__ */
|
|
151
|
+
...V || Z.current ? { "aria-label": Z.current ? `${B.more} · ${B.moreCurrent}: ${Z.current.label}` : B.more } : {},
|
|
152
|
+
label: /* @__PURE__ */ O(E, { children: [!V && /* @__PURE__ */ D("span", {
|
|
153
|
+
...r(C, "label", R),
|
|
154
|
+
children: B.more
|
|
155
|
+
}), Z.notice && /* @__PURE__ */ D(l, {
|
|
153
156
|
value: "dot",
|
|
154
157
|
tone: Z.notice.badgeTone,
|
|
155
158
|
placement: "corner"
|
|
156
159
|
})] }),
|
|
157
|
-
items:
|
|
160
|
+
items: me
|
|
158
161
|
})
|
|
159
162
|
]
|
|
160
163
|
}),
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
children: $(
|
|
164
|
+
H.end.length > 0 && /* @__PURE__ */ D("div", {
|
|
165
|
+
...r(C, "end", R),
|
|
166
|
+
children: $(H.end)
|
|
164
167
|
}),
|
|
165
|
-
|
|
166
|
-
value:
|
|
167
|
-
children:
|
|
168
|
+
P !== void 0 && /* @__PURE__ */ D(S.Provider, {
|
|
169
|
+
value: F,
|
|
170
|
+
children: P
|
|
168
171
|
})
|
|
169
172
|
]
|
|
170
173
|
});
|
|
171
174
|
};
|
|
172
175
|
//#endregion
|
|
173
|
-
export {
|
|
176
|
+
export { k as DEFAULT_RAIL_LABELS, A as KapiRail };
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { type CSSProperties, type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
2
2
|
import { type KapiThemeState } from "../../hooks/useKapiTheme.js";
|
|
3
|
+
import type { KapiDensity } from "../../hooks/densityLogic.js";
|
|
3
4
|
import type { KapiDir } from "../../hooks/directionLogic.js";
|
|
4
|
-
import type {
|
|
5
|
+
import type { KapiBrandTheme } from "../../hooks/themeColorsLogic.js";
|
|
6
|
+
import type { KapiToneFamilies } from "../../hooks/toneFamilyLogic.js";
|
|
5
7
|
/** Opciones de `useKapiRootWiring`: lo que una raíz `.kapi` recibe por props. Interno. */
|
|
6
8
|
export type KapiRootWiringOptions = {
|
|
7
9
|
/** Namespace de las preferencias guardadas. */
|
|
8
10
|
storageNamespace?: string | undefined;
|
|
9
11
|
/** Tema de marca (base de los colores). */
|
|
10
|
-
brandTheme?:
|
|
12
|
+
brandTheme?: KapiBrandTheme | undefined;
|
|
13
|
+
/** Familias de tono de la app (ver `KapiRootProps.toneFamilies`). */
|
|
14
|
+
toneFamilies?: KapiToneFamilies | undefined;
|
|
15
|
+
/** Densidad de la interfaz (ver `KapiRootProps.density`). */
|
|
16
|
+
density?: KapiDensity | undefined;
|
|
11
17
|
/** `style` del consumidor; las variables del tema van encima. */
|
|
12
18
|
style?: CSSProperties | undefined;
|
|
13
19
|
/** `ref` del consumidor al `<div>` raíz. */
|
|
@@ -17,6 +23,8 @@ export type KapiRootWiringOptions = {
|
|
|
17
23
|
export type KapiRootWiring = {
|
|
18
24
|
/** Estado del tema de esta raíz (va al `KapiThemeContext`). */
|
|
19
25
|
themeState: KapiThemeState;
|
|
26
|
+
/** Nombres de las familias de tono registradas (las de esta raíz y las heredadas). */
|
|
27
|
+
toneNames: ReadonlySet<string>;
|
|
20
28
|
/** `dir` del `KapiLocaleProvider`; se escribe ANTES del passthrough, así un `dir` propio gana. */
|
|
21
29
|
dir: KapiDir | undefined;
|
|
22
30
|
/** Atributos propios de la raíz; van DESPUÉS del passthrough (no se pisan). */
|
|
@@ -24,6 +32,7 @@ export type KapiRootWiring = {
|
|
|
24
32
|
ref: Ref<HTMLDivElement>;
|
|
25
33
|
"data-theme": KapiThemeState["theme"];
|
|
26
34
|
"data-motion": "reduced" | undefined;
|
|
35
|
+
"data-density": "compact" | "comfortable" | undefined;
|
|
27
36
|
style: CSSProperties;
|
|
28
37
|
suppressHydrationWarning: true;
|
|
29
38
|
};
|
|
@@ -37,7 +46,7 @@ export type KapiRootWiring = {
|
|
|
37
46
|
* `style`), `dir` y raíz de portales. Interno: lo comparten `KapiShell` y `KapiRoot`, que sólo
|
|
38
47
|
* difieren en lo que dibujan adentro.
|
|
39
48
|
*/
|
|
40
|
-
export declare const useKapiRootWiring: ({ storageNamespace, brandTheme, style, ref }: KapiRootWiringOptions) => KapiRootWiring;
|
|
49
|
+
export declare const useKapiRootWiring: ({ storageNamespace, brandTheme, toneFamilies, density, style, ref }: KapiRootWiringOptions) => KapiRootWiring;
|
|
41
50
|
/**
|
|
42
51
|
* Contextos que una raíz `.kapi` da a su subárbol: el tema y la raíz de portales. Los overlays sin
|
|
43
52
|
* ancla (modal, offcanvas, paleta de comandos, toasts…) se montan en ESTA raíz y no en el primer
|
|
@@ -65,8 +74,29 @@ export type KapiRootProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
|
65
74
|
/**
|
|
66
75
|
* Tema de marca: los colores de la identidad del producto (`primary`, `bg`, `ink`…). Es la base;
|
|
67
76
|
* el acento y lo que la persona personalizó se aplican encima, color por color.
|
|
77
|
+
* Plano (`{ primary, bg… }`) vale para los dos esquemas; `{ light, dark }` afina cada uno por
|
|
78
|
+
* separado (un esquema que falta no hereda del otro).
|
|
68
79
|
*/
|
|
69
|
-
brandTheme?:
|
|
80
|
+
brandTheme?: KapiBrandTheme | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Familias de tono propias de la app: colores semánticos nuevos (`ucuBlue`, `ember`…) que valen
|
|
83
|
+
* donde un componente acepta `tone`. Cada una es `{ color }` (el esquema claro; el oscuro se
|
|
84
|
+
* adapta solo hasta ser legible) o `{ light, dark }`; de `color` salen el tinte, el borde y la
|
|
85
|
+
* tinta, o se fijan a mano. Para que `tone="ucuBlue"` compile hay que declararla en
|
|
86
|
+
* `KapiCustomTones` (ver el README). Declararla fuera del componente o con `useMemo`: un objeto
|
|
87
|
+
* nuevo por render recalcula el tema. Los contrastes se miden con `checkToneFamilyContrast`.
|
|
88
|
+
*/
|
|
89
|
+
toneFamilies?: KapiToneFamilies | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Densidad de la interfaz: qué tan apretados o holgados son los controles. `compact` es para
|
|
92
|
+
* pantallas administrativas con mucha información, `comfortable` para portales públicos y uso
|
|
93
|
+
* táctil; `default` (lo de siempre) no cambia nada. Mueve los tres tamaños de control
|
|
94
|
+
* (`--kapi-ctl-h-sm`, `--kapi-ctl-h` y `--kapi-ctl-h-lg`) escribiendo `data-density` en la raíz,
|
|
95
|
+
* sin estilos inline, así que el CSS de la app sigue ganando. Con puntero táctil los controles
|
|
96
|
+
* no bajan de `--kapi-tap` (44px) en ninguna densidad. Es un ajuste de la app, no una preferencia
|
|
97
|
+
* de la persona: no se guarda. No reemplaza a `size` (que elige un tamaño de UN control).
|
|
98
|
+
*/
|
|
99
|
+
density?: KapiDensity | undefined;
|
|
70
100
|
};
|
|
71
101
|
/**
|
|
72
102
|
* Raíz mínima para embeber componentes en una página que ya existe (una isla en un sitio hecho con
|
|
@@ -82,4 +112,4 @@ export type KapiRootProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
|
82
112
|
* <KapiButton onClick={…}>Inscribirme</KapiButton>
|
|
83
113
|
* </KapiRoot>
|
|
84
114
|
*/
|
|
85
|
-
export declare const KapiRoot: ({ children, className, storageNamespace, brandTheme, style, ref, ...rest }: KapiRootProps) => import("react").JSX.Element;
|
|
115
|
+
export declare const KapiRoot: ({ children, className, storageNamespace, brandTheme, toneFamilies, density, style, ref, ...rest }: KapiRootProps) => import("react").JSX.Element;
|
|
@@ -1,58 +1,73 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/layout/KapiRoot.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { ToneFamilyNamesContext as e, useToneFamilyProblemWarning as t, useToneFamilyRegistry as n } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { joinClasses as r } from "../rootProps.js";
|
|
5
|
+
import { useKapiDir as i } from "../locale/KapiLocaleProvider.js";
|
|
6
|
+
import { KapiPortalRootProvider as a, usePortalRootOverride as o } from "../../hooks/portalRoot.js";
|
|
7
|
+
import { useMergedRefs as s } from "../../hooks/mergeRefs.js";
|
|
8
|
+
import { KapiThemeContext as c, themeRootStyle as l, useKapiThemeState as u } from "../../hooks/useKapiTheme.js";
|
|
9
|
+
import { densityAttribute as d } from "../../hooks/densityLogic.js";
|
|
8
10
|
/* empty css */
|
|
9
|
-
import { createContext as
|
|
10
|
-
import { jsx as
|
|
11
|
+
import { createContext as f, useContext as p, useMemo as m, useState as h } from "react";
|
|
12
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
11
13
|
//#region src/components/layout/KapiRoot.tsx
|
|
12
|
-
var
|
|
13
|
-
let
|
|
14
|
+
var _ = f(null), v = ({ storageNamespace: e, brandTheme: r, toneFamilies: a, density: c, style: f, ref: g }) => {
|
|
15
|
+
let v = u({ namespace: e }), y = i(), b = m(() => l(v, r, a), [
|
|
16
|
+
v,
|
|
17
|
+
r,
|
|
18
|
+
a
|
|
19
|
+
]), { names: x, problems: S } = n(a);
|
|
20
|
+
t(S);
|
|
21
|
+
let [C, w] = h(null), T = s(w, g), E = o(), D = p(_), O = E && E !== D ? E : C;
|
|
14
22
|
return {
|
|
15
|
-
themeState:
|
|
16
|
-
|
|
23
|
+
themeState: v,
|
|
24
|
+
toneNames: x,
|
|
25
|
+
dir: y,
|
|
17
26
|
attrs: {
|
|
18
|
-
ref:
|
|
19
|
-
"data-theme":
|
|
20
|
-
"data-motion":
|
|
27
|
+
ref: T,
|
|
28
|
+
"data-theme": v.theme,
|
|
29
|
+
"data-motion": v.motion === "reduced" ? "reduced" : void 0,
|
|
30
|
+
"data-density": d(c),
|
|
21
31
|
style: {
|
|
22
|
-
...
|
|
23
|
-
...
|
|
32
|
+
...f,
|
|
33
|
+
...b
|
|
24
34
|
},
|
|
25
35
|
suppressHydrationWarning: !0
|
|
26
36
|
},
|
|
27
|
-
element:
|
|
28
|
-
portalRoot:
|
|
37
|
+
element: C,
|
|
38
|
+
portalRoot: O
|
|
29
39
|
};
|
|
30
|
-
},
|
|
31
|
-
value:
|
|
32
|
-
children: /* @__PURE__ */
|
|
33
|
-
value:
|
|
34
|
-
children: /* @__PURE__ */
|
|
35
|
-
|
|
36
|
-
children:
|
|
40
|
+
}, y = ({ wiring: t, children: n }) => /* @__PURE__ */ g(c.Provider, {
|
|
41
|
+
value: t.themeState,
|
|
42
|
+
children: /* @__PURE__ */ g(e.Provider, {
|
|
43
|
+
value: t.toneNames,
|
|
44
|
+
children: /* @__PURE__ */ g(_.Provider, {
|
|
45
|
+
value: t.element,
|
|
46
|
+
children: /* @__PURE__ */ g(a, {
|
|
47
|
+
root: t.portalRoot,
|
|
48
|
+
children: n
|
|
49
|
+
})
|
|
37
50
|
})
|
|
38
51
|
})
|
|
39
|
-
}),
|
|
40
|
-
let
|
|
41
|
-
storageNamespace:
|
|
52
|
+
}), b = ({ children: e, className: t, storageNamespace: n, brandTheme: i, toneFamilies: a, density: o, style: s, ref: c, ...l }) => {
|
|
53
|
+
let u = v({
|
|
54
|
+
storageNamespace: n,
|
|
42
55
|
brandTheme: i,
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
toneFamilies: a,
|
|
57
|
+
density: o,
|
|
58
|
+
style: s,
|
|
59
|
+
ref: c
|
|
45
60
|
});
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
wiring:
|
|
48
|
-
children: /* @__PURE__ */
|
|
49
|
-
...
|
|
50
|
-
...
|
|
51
|
-
className:
|
|
52
|
-
...
|
|
53
|
-
children:
|
|
61
|
+
return /* @__PURE__ */ g(y, {
|
|
62
|
+
wiring: u,
|
|
63
|
+
children: /* @__PURE__ */ g("div", {
|
|
64
|
+
...u.dir ? { dir: u.dir } : {},
|
|
65
|
+
...l,
|
|
66
|
+
className: r("kapi", "kapi--embed", t),
|
|
67
|
+
...u.attrs,
|
|
68
|
+
children: e
|
|
54
69
|
})
|
|
55
70
|
});
|
|
56
71
|
};
|
|
57
72
|
//#endregion
|
|
58
|
-
export {
|
|
73
|
+
export { b as KapiRoot, y as KapiRootScope, v as useKapiRootWiring };
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { KapiDensity } from "../../hooks/densityLogic.js";
|
|
3
|
+
import type { KapiBrandTheme } from "../../hooks/themeColorsLogic.js";
|
|
4
|
+
import type { KapiToneFamilies } from "../../hooks/toneFamilyLogic.js";
|
|
3
5
|
import { type KapiMenuItem } from "../overlays/KapiContextMenu.js";
|
|
6
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
4
7
|
/**
|
|
5
8
|
* Atributos nativos (`id`, `style`, `data-*`…) van a la raíz `.kapi`. `data-theme`/`data-motion`
|
|
6
9
|
* son propios y las variables del tema (`--kapi-font`, `--kapi-primary`…) ganan sobre `style`.
|
|
7
10
|
*/
|
|
11
|
+
/** Partes de `KapiShell` que acepta `classNames`: `root`, `content` (el `<main>`) y `reopen`. */
|
|
12
|
+
export type KapiShellClassNames = KapiClassNames<"shell">;
|
|
8
13
|
export type KapiShellProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
9
14
|
/** Ref al `<div>` raíz del shell. */
|
|
10
15
|
ref?: Ref<HTMLDivElement> | undefined;
|
|
@@ -27,6 +32,13 @@ export type KapiShellProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> &
|
|
|
27
32
|
overlays?: ReactNode;
|
|
28
33
|
/** Clase extra del `<main>` que envuelve el contenido. */
|
|
29
34
|
contentClassName?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Clases por parte: `classNames={{ content: "mi-contenido" }}`. Se suman a las propias. `root` es el
|
|
37
|
+
* marco (lo mismo que `className`) y `content` el `<main>` (lo mismo que `contentClassName`, que se
|
|
38
|
+
* mantiene). Cada parte además lleva `data-slot="shell-<parte>"`. El rail, el panel y la cabecera son
|
|
39
|
+
* componentes aparte, con sus propias partes.
|
|
40
|
+
*/
|
|
41
|
+
classNames?: KapiShellClassNames | undefined;
|
|
30
42
|
/**
|
|
31
43
|
* Namespace de las preferencias guardadas (tema, acento, fuente, movimiento). Default `kapi`
|
|
32
44
|
* (`kapi:theme`…). Dos apps del design system en el mismo origen pasan uno distinto para no pisarse.
|
|
@@ -36,8 +48,29 @@ export type KapiShellProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> &
|
|
|
36
48
|
* Tema de marca: los colores de la identidad del producto (`primary`, `bg`, `ink`…). Es la base;
|
|
37
49
|
* el acento y lo que la persona personalizó se aplican encima, color por color. Se deriva sobre
|
|
38
50
|
* el tema claro u oscuro que se ve.
|
|
51
|
+
* Plano (`{ primary, bg… }`) vale para los dos esquemas; `{ light, dark }` afina cada uno por
|
|
52
|
+
* separado (un esquema que falta no hereda del otro).
|
|
53
|
+
*/
|
|
54
|
+
brandTheme?: KapiBrandTheme | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Familias de tono propias de la app: colores semánticos nuevos (`ucuBlue`, `ember`…) que valen
|
|
57
|
+
* donde un componente acepta `tone`. Cada una es `{ color }` (el esquema claro; el oscuro se
|
|
58
|
+
* adapta solo hasta ser legible) o `{ light, dark }`; de `color` salen el tinte, el borde y la
|
|
59
|
+
* tinta, o se fijan a mano. Para que `tone="ucuBlue"` compile hay que declararla en
|
|
60
|
+
* `KapiCustomTones` (ver el README). Declararla fuera del componente o con `useMemo`: un objeto
|
|
61
|
+
* nuevo por render recalcula el tema. Los contrastes se miden con `checkToneFamilyContrast`.
|
|
62
|
+
*/
|
|
63
|
+
toneFamilies?: KapiToneFamilies | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Densidad de la interfaz: qué tan apretados o holgados son los controles. `compact` es para
|
|
66
|
+
* pantallas administrativas con mucha información, `comfortable` para portales públicos y uso
|
|
67
|
+
* táctil; `default` (lo de siempre) no cambia nada. Mueve los tres tamaños de control
|
|
68
|
+
* (`--kapi-ctl-h-sm`, `--kapi-ctl-h` y `--kapi-ctl-h-lg`) escribiendo `data-density` en la raíz,
|
|
69
|
+
* sin estilos inline, así que el CSS de la app sigue ganando. Con puntero táctil los controles
|
|
70
|
+
* no bajan de `--kapi-tap` (44px) en ninguna densidad. Es un ajuste de la app, no una preferencia
|
|
71
|
+
* de la persona: no se guarda. No reemplaza a `size` (que elige un tamaño de UN control).
|
|
39
72
|
*/
|
|
40
|
-
|
|
73
|
+
density?: KapiDensity | undefined;
|
|
41
74
|
};
|
|
42
75
|
/**
|
|
43
76
|
* Marco de la app. Es la raíz `.kapi` (tokens, tema, fuente, raíz de portales) y compone:
|
|
@@ -65,4 +98,4 @@ export type KapiShellProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> &
|
|
|
65
98
|
* // sin rail (otra navegación, p. ej. tabs arriba o router propio)
|
|
66
99
|
* <KapiShell><MiTopNav /><Pagina /></KapiShell>
|
|
67
100
|
*/
|
|
68
|
-
export declare const KapiShell: ({ rail, panel, panelRight, children, contextMenuItems, rightClick, overlays, className, contentClassName, storageNamespace, brandTheme, style, ref, ...rest }: KapiShellProps) => import("react").JSX.Element;
|
|
101
|
+
export declare const KapiShell: ({ rail, panel, panelRight, children, contextMenuItems, rightClick, overlays, className, classNames, contentClassName, storageNamespace, brandTheme, toneFamilies, density, style, ref, ...rest }: KapiShellProps) => import("react").JSX.Element;
|