@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
|
@@ -7,99 +7,100 @@ import "./navBadgeLogic.js";
|
|
|
7
7
|
import { KapiNavBadge as r } from "./KapiNavBadge.js";
|
|
8
8
|
import { CtxSlidingList as i } from "./CtxSlidingList.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
10
|
+
import { renderNavLink as a } from "./navLink.js";
|
|
11
|
+
import { useKapiPanelMini as o } from "./panelMini.js";
|
|
12
|
+
import { MiniNavItem as s } from "./MiniNavItem.js";
|
|
13
|
+
import { activeIdIn as c } from "./activeItemLogic.js";
|
|
14
|
+
import { formatCount as l, panelGroupClasses as u } from "./panelGroupLogic.js";
|
|
15
|
+
import { useId as d } from "react";
|
|
16
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
17
|
+
import { ChevronRight as h, ExternalLink as g } from "lucide-react";
|
|
17
18
|
//#region src/components/navigation/KapiPanelGroup.tsx
|
|
18
|
-
var
|
|
19
|
-
let t =
|
|
20
|
-
return t === null ? null : /* @__PURE__ */
|
|
19
|
+
var _ = ({ value: e }) => {
|
|
20
|
+
let t = l(e);
|
|
21
|
+
return t === null ? null : /* @__PURE__ */ p("span", {
|
|
21
22
|
className: "kapi-panelgroup__count",
|
|
22
23
|
children: t
|
|
23
24
|
});
|
|
24
|
-
},
|
|
25
|
-
let
|
|
25
|
+
}, v = ({ item: e, active: t, onSelect: n, newTabLabel: i }) => {
|
|
26
|
+
let o = `kapi-ctxitem${t ? " kapi-ctxitem--on" : ""}`, s = /* @__PURE__ */ m("span", {
|
|
26
27
|
className: "kapi-ctxitem__main",
|
|
27
28
|
children: [e.icon, e.label]
|
|
28
29
|
});
|
|
29
|
-
return e.href
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
return e.href !== void 0 || e.render !== void 0 ? a({
|
|
31
|
+
render: e.render,
|
|
32
|
+
href: e.href,
|
|
33
|
+
newTab: e.newTab,
|
|
33
34
|
disabled: e.disabled,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
tone: e.badgeTone,
|
|
40
|
-
label: e.badgeLabel,
|
|
41
|
-
max: 999
|
|
42
|
-
}),
|
|
43
|
-
/* @__PURE__ */ d(h, { value: e.count })
|
|
44
|
-
]
|
|
45
|
-
}) : /* @__PURE__ */ f("a", {
|
|
46
|
-
className: `${a} kapi-ctxitem--link`,
|
|
47
|
-
href: e.disabled ? void 0 : e.href,
|
|
48
|
-
rel: "noopener noreferrer",
|
|
49
|
-
target: e.newTab ? "_blank" : void 0,
|
|
50
|
-
"aria-current": t ? "page" : void 0,
|
|
51
|
-
"aria-disabled": e.disabled || void 0,
|
|
52
|
-
children: [
|
|
53
|
-
o,
|
|
54
|
-
/* @__PURE__ */ d(r, {
|
|
35
|
+
active: t,
|
|
36
|
+
className: `${o} kapi-ctxitem--link`,
|
|
37
|
+
children: /* @__PURE__ */ m(f, { children: [
|
|
38
|
+
s,
|
|
39
|
+
/* @__PURE__ */ p(r, {
|
|
55
40
|
value: e.badge,
|
|
56
41
|
tone: e.badgeTone,
|
|
57
42
|
label: e.badgeLabel,
|
|
58
43
|
max: 999
|
|
59
44
|
}),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
e.external && /* @__PURE__ */
|
|
45
|
+
/* @__PURE__ */ p(_, { value: e.count }),
|
|
46
|
+
e.external && /* @__PURE__ */ p(g, {
|
|
62
47
|
className: "kapi-ctxitem__ext",
|
|
63
48
|
size: 14,
|
|
64
49
|
"aria-hidden": "true"
|
|
65
50
|
}),
|
|
66
|
-
e.newTab && /* @__PURE__ */
|
|
51
|
+
e.newTab && /* @__PURE__ */ p("span", {
|
|
67
52
|
className: "kapi-ctxitem__sr",
|
|
68
53
|
children: i
|
|
69
54
|
})
|
|
55
|
+
] })
|
|
56
|
+
}) : /* @__PURE__ */ m("button", {
|
|
57
|
+
type: "button",
|
|
58
|
+
className: o,
|
|
59
|
+
"aria-current": t ? "page" : void 0,
|
|
60
|
+
disabled: e.disabled,
|
|
61
|
+
onClick: () => n?.(e.id),
|
|
62
|
+
children: [
|
|
63
|
+
s,
|
|
64
|
+
/* @__PURE__ */ p(r, {
|
|
65
|
+
value: e.badge,
|
|
66
|
+
tone: e.badgeTone,
|
|
67
|
+
label: e.badgeLabel,
|
|
68
|
+
max: 999
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ p(_, { value: e.count })
|
|
70
71
|
]
|
|
71
72
|
});
|
|
72
73
|
};
|
|
73
|
-
function
|
|
74
|
-
let N = e("link", n, M), P =
|
|
75
|
-
return B ? /* @__PURE__ */
|
|
74
|
+
function y({ label: a, count: l, badge: f, badgeTone: g, badgeLabel: y, icon: b, items: x, activeId: S, onSelect: C, open: w, defaultOpen: T = !1, onOpenChange: E, className: D, style: O, id: k, ref: A, "aria-label": j, labels: M }) {
|
|
75
|
+
let N = e("link", n, M), P = d(), F = `${P}-body`, I = `${P}-head`, [L, R] = t(w, T, E), z = () => R(!L), { mini: B, expand: V } = o();
|
|
76
|
+
return B ? /* @__PURE__ */ p("div", {
|
|
76
77
|
ref: A,
|
|
77
|
-
className:
|
|
78
|
+
className: u({
|
|
78
79
|
open: !1,
|
|
79
80
|
className: D
|
|
80
81
|
}),
|
|
81
82
|
style: O,
|
|
82
83
|
id: k,
|
|
83
|
-
children: /* @__PURE__ */
|
|
84
|
-
label:
|
|
84
|
+
children: /* @__PURE__ */ p(s, {
|
|
85
|
+
label: a,
|
|
85
86
|
icon: b,
|
|
86
|
-
active:
|
|
87
|
-
badge:
|
|
88
|
-
badgeTone:
|
|
87
|
+
active: c(x, S) !== null,
|
|
88
|
+
badge: f,
|
|
89
|
+
badgeTone: g,
|
|
89
90
|
badgeLabel: y,
|
|
90
91
|
onClick: () => {
|
|
91
92
|
V(), L || R(!0);
|
|
92
93
|
}
|
|
93
94
|
})
|
|
94
|
-
}) : /* @__PURE__ */
|
|
95
|
+
}) : /* @__PURE__ */ m("div", {
|
|
95
96
|
ref: A,
|
|
96
|
-
className:
|
|
97
|
+
className: u({
|
|
97
98
|
open: L,
|
|
98
99
|
className: D
|
|
99
100
|
}),
|
|
100
101
|
style: O,
|
|
101
102
|
id: k,
|
|
102
|
-
children: [/* @__PURE__ */
|
|
103
|
+
children: [/* @__PURE__ */ m("button", {
|
|
103
104
|
type: "button",
|
|
104
105
|
id: I,
|
|
105
106
|
className: "kapi-panelgroup__head",
|
|
@@ -107,36 +108,36 @@ function _({ label: c, count: m, badge: _, badgeTone: v, badgeLabel: y, icon: b,
|
|
|
107
108
|
"aria-controls": F,
|
|
108
109
|
onClick: z,
|
|
109
110
|
children: [
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ m("span", {
|
|
111
112
|
className: "kapi-panelgroup__label",
|
|
112
|
-
children: [b,
|
|
113
|
+
children: [b, a]
|
|
113
114
|
}),
|
|
114
|
-
/* @__PURE__ */
|
|
115
|
-
value:
|
|
116
|
-
tone:
|
|
115
|
+
/* @__PURE__ */ p(r, {
|
|
116
|
+
value: f,
|
|
117
|
+
tone: g,
|
|
117
118
|
label: y,
|
|
118
119
|
max: 999
|
|
119
120
|
}),
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
121
|
+
/* @__PURE__ */ p(_, { value: l }),
|
|
122
|
+
/* @__PURE__ */ p(h, {
|
|
122
123
|
className: "kapi-panelgroup__chevron kapi-flip-rtl",
|
|
123
124
|
size: 16,
|
|
124
125
|
strokeWidth: 2,
|
|
125
126
|
"aria-hidden": "true"
|
|
126
127
|
})
|
|
127
128
|
]
|
|
128
|
-
}), /* @__PURE__ */
|
|
129
|
+
}), /* @__PURE__ */ p("div", {
|
|
129
130
|
id: F,
|
|
130
131
|
role: "region",
|
|
131
132
|
"aria-label": j,
|
|
132
133
|
"aria-labelledby": j ? void 0 : I,
|
|
133
134
|
className: "kapi-panelgroup__body",
|
|
134
135
|
inert: !L,
|
|
135
|
-
children: /* @__PURE__ */
|
|
136
|
+
children: /* @__PURE__ */ p("div", {
|
|
136
137
|
className: "kapi-panelgroup__clip",
|
|
137
|
-
children: /* @__PURE__ */
|
|
138
|
-
active:
|
|
139
|
-
children: x.map((e) => /* @__PURE__ */
|
|
138
|
+
children: /* @__PURE__ */ p(i, {
|
|
139
|
+
active: c(x, S),
|
|
140
|
+
children: x.map((e) => /* @__PURE__ */ p(v, {
|
|
140
141
|
item: e,
|
|
141
142
|
active: e.id === S,
|
|
142
143
|
onSelect: C,
|
|
@@ -148,4 +149,4 @@ function _({ label: c, count: m, badge: _, badgeTone: v, badgeLabel: y, icon: b,
|
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
151
|
//#endregion
|
|
151
|
-
export {
|
|
152
|
+
export { y as KapiPanelGroup };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties } from "react";
|
|
2
2
|
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
3
|
+
import { type KapiRender } from "../renderSlot.js";
|
|
3
4
|
/** Pestaña de `KapiTabs`. `Id` acota los ids (p. ej. una unión de literales). */
|
|
4
5
|
export type KapiTabItem<Id extends string = string> = {
|
|
5
6
|
/** Id único de la pestaña (es el `value` cuando está activa). */
|
|
@@ -14,6 +15,17 @@ export type KapiTabItem<Id extends string = string> = {
|
|
|
14
15
|
count?: number | undefined;
|
|
15
16
|
/** Pestaña no elegible: se ve atenuada y el teclado la saltea. */
|
|
16
17
|
disabled?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* El elemento que dibuja la pestaña: el `<Link>` de tu router, para pestañas que son rutas y navegan
|
|
20
|
+
* sin recargar la página. Conserva `role="tab"`, `aria-selected`, el id y el roving tabindex (no se
|
|
21
|
+
* negocian); las clases se unen, los estilos se funden y los handlers corren los dos (primero el tuyo).
|
|
22
|
+
* Con `value` (controlado) el clic NO llama a `onChange`: el enlace navega solo y la ruta decide la
|
|
23
|
+
* pestaña activa. Las flechas sí lo llaman (no hay clic que navegue): ahí navega tú. Apagada, va por
|
|
24
|
+
* `aria-disabled` y el clic se frena.
|
|
25
|
+
*
|
|
26
|
+
* { id: "altas", label: "Altas", render: <Link to="/altas" /> }
|
|
27
|
+
*/
|
|
28
|
+
render?: KapiRender | undefined;
|
|
17
29
|
};
|
|
18
30
|
/** Escala de las pestañas: `sm` para barras compactas, `md` la de siempre (mismo vocabulario que `KapiSegmentedSize`). */
|
|
19
31
|
export type KapiTabsSize = "sm" | "md";
|
|
@@ -1,94 +1,110 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/navigation/navigation.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
4
|
+
import { renderSlot as t } from "../renderSlot.js";
|
|
5
|
+
import { useKapiFormatLocale as n } from "../locale/KapiLocaleProvider.js";
|
|
6
|
+
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
7
|
+
import { logicalKeyOf as i } from "../../hooks/directionLogic.js";
|
|
8
|
+
import { useDuplicateValueWarning as a, useMutedControlWarning as o } from "../inputs/misuseWarnings.js";
|
|
9
|
+
import { useMergedRefs as s } from "../../hooks/mergeRefs.js";
|
|
10
|
+
import { useSlidingIndicator as c } from "../../hooks/useSlidingIndicator.js";
|
|
11
|
+
import { formatCount as l } from "../../hooks/numberFormatLogic.js";
|
|
12
|
+
import { useScrollEdges as u } from "../../hooks/useScrollEdges.js";
|
|
12
13
|
/* empty css */
|
|
13
|
-
import { nextTabId as
|
|
14
|
-
import { useCallback as
|
|
15
|
-
import { Fragment as
|
|
14
|
+
import { nextTabId as d, tabClasses as f, tabId as p, tabPanelId as m } from "./tabsLogic.js";
|
|
15
|
+
import { Fragment as h, useCallback as g, useId as _, useLayoutEffect as v, useMemo as y, useRef as b } from "react";
|
|
16
|
+
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
16
17
|
//#region src/components/navigation/KapiTabs.tsx
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
controlled:
|
|
22
|
-
hasOnChange: !!
|
|
23
|
-
disabled:
|
|
18
|
+
var w = [];
|
|
19
|
+
function T({ items: T, tabs: E, value: D, defaultValue: O, onChange: k, className: A, idBase: j, disabled: M = !1, size: N = "md", onKeyDown: P, ref: F, ...I }) {
|
|
20
|
+
let L = n(), R = T ?? E ?? w, z = _(), B = j ?? z, V = b({}), [H, U] = r(D, () => O ?? R[0]?.id, k), W = y(() => R.map((e) => e.id), [R]);
|
|
21
|
+
a("KapiTabs", W), o("KapiTabs", {
|
|
22
|
+
controlled: D !== void 0,
|
|
23
|
+
hasOnChange: !!k,
|
|
24
|
+
disabled: M
|
|
24
25
|
});
|
|
25
|
-
let { containerRef:
|
|
26
|
-
active:
|
|
27
|
-
deps: [
|
|
26
|
+
let { containerRef: G, indicatorRef: K } = c({
|
|
27
|
+
active: H ?? null,
|
|
28
|
+
deps: [R],
|
|
28
29
|
findActive: (e) => e.querySelector("[role=\"tab\"][aria-selected=\"true\"]")
|
|
29
|
-
}), { ref:
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
|
|
33
|
-
let e =
|
|
34
|
-
e &&
|
|
30
|
+
}), { ref: q, edges: J, reveal: Y } = u({ axis: "x" }), X = g((e) => {
|
|
31
|
+
G.current = e, q.current = e;
|
|
32
|
+
}, [G, q]), Z = s(X, F), Q = b(!1);
|
|
33
|
+
v(() => {
|
|
34
|
+
let e = G.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
|
|
35
|
+
e && Y(e, { instant: !Q.current }), Q.current = !0;
|
|
35
36
|
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
H,
|
|
38
|
+
G,
|
|
39
|
+
Y
|
|
39
40
|
]);
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
let t =
|
|
43
|
-
t !== void 0 && (e.preventDefault(),
|
|
41
|
+
let $ = (e) => M || R.some((t) => t.id === e && t.disabled === !0), ee = H !== void 0 && R.some((e) => e.id === H) && !$(H) ? H : R.find((e) => !$(e.id))?.id, te = (e) => {
|
|
42
|
+
if (P?.(e), e.defaultPrevented || H === void 0) return;
|
|
43
|
+
let t = d(R.map((e) => e.id), H, i(e), $);
|
|
44
|
+
t !== void 0 && (e.preventDefault(), U(t), V.current[t]?.focus());
|
|
44
45
|
};
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
...
|
|
47
|
-
ref:
|
|
48
|
-
className: e("kapi-tabs", "kapi-fade-x",
|
|
49
|
-
"data-edge-start":
|
|
50
|
-
"data-edge-end":
|
|
46
|
+
return /* @__PURE__ */ C("div", {
|
|
47
|
+
...I,
|
|
48
|
+
ref: Z,
|
|
49
|
+
className: e("kapi-tabs", "kapi-fade-x", N === "sm" && "kapi-tabs--sm", A),
|
|
50
|
+
"data-edge-start": J.start ? "" : void 0,
|
|
51
|
+
"data-edge-end": J.end ? "" : void 0,
|
|
51
52
|
role: "tablist",
|
|
52
|
-
"aria-disabled":
|
|
53
|
-
onKeyDown:
|
|
54
|
-
children: [/* @__PURE__ */
|
|
55
|
-
ref:
|
|
53
|
+
"aria-disabled": M || void 0,
|
|
54
|
+
onKeyDown: te,
|
|
55
|
+
children: [/* @__PURE__ */ S("span", {
|
|
56
|
+
ref: K,
|
|
56
57
|
className: "kapi-tabs__indicator",
|
|
57
58
|
"aria-hidden": "true"
|
|
58
|
-
}),
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
}), R.map((e) => {
|
|
60
|
+
let n = e.id === H, r = /* @__PURE__ */ C(x, { children: [
|
|
61
|
+
e.icon,
|
|
62
|
+
e.label,
|
|
63
|
+
e.count !== void 0 && /* @__PURE__ */ C(x, { children: [" ", /* @__PURE__ */ S("span", {
|
|
64
|
+
className: "kapi-tabs__count",
|
|
65
|
+
children: l(e.count, L)
|
|
66
|
+
})] })
|
|
67
|
+
] }), i = (t) => {
|
|
68
|
+
V.current[e.id] = t;
|
|
69
|
+
}, a = {
|
|
70
|
+
id: p(B, e.id),
|
|
66
71
|
role: "tab",
|
|
67
|
-
"aria-controls":
|
|
68
|
-
"aria-selected":
|
|
69
|
-
tabIndex: e.id ===
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
children:
|
|
74
|
-
|
|
75
|
-
e.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
"aria-controls": j ? m(j, e.id) : void 0,
|
|
73
|
+
"aria-selected": n,
|
|
74
|
+
tabIndex: e.id === ee ? 0 : -1
|
|
75
|
+
};
|
|
76
|
+
if (e.render !== void 0) {
|
|
77
|
+
let o = $(e.id);
|
|
78
|
+
return /* @__PURE__ */ S(h, { children: t(e.render, {
|
|
79
|
+
className: f(n),
|
|
80
|
+
...D === void 0 ? { onClick: () => U(e.id) } : {}
|
|
81
|
+
}, {
|
|
82
|
+
...a,
|
|
83
|
+
"aria-disabled": o || void 0,
|
|
84
|
+
...o ? { onClick: (e) => e.preventDefault() } : {},
|
|
85
|
+
ref: i,
|
|
86
|
+
children: r
|
|
87
|
+
}, (e) => /* @__PURE__ */ S("a", { ...e })) }, e.id);
|
|
88
|
+
}
|
|
89
|
+
return /* @__PURE__ */ S("button", {
|
|
90
|
+
ref: i,
|
|
91
|
+
type: "button",
|
|
92
|
+
...a,
|
|
93
|
+
disabled: $(e.id) || void 0,
|
|
94
|
+
className: f(n),
|
|
95
|
+
onClick: () => U(e.id),
|
|
96
|
+
children: r
|
|
81
97
|
}, e.id);
|
|
82
98
|
})]
|
|
83
99
|
});
|
|
84
100
|
}
|
|
85
|
-
function
|
|
86
|
-
return /* @__PURE__ */
|
|
101
|
+
function E({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, style: a, children: o, ref: s }) {
|
|
102
|
+
return /* @__PURE__ */ S("div", {
|
|
87
103
|
ref: s,
|
|
88
104
|
style: a,
|
|
89
|
-
id:
|
|
105
|
+
id: m(e, t),
|
|
90
106
|
role: "tabpanel",
|
|
91
|
-
"aria-labelledby":
|
|
107
|
+
"aria-labelledby": p(e, t),
|
|
92
108
|
tabIndex: 0,
|
|
93
109
|
hidden: !n,
|
|
94
110
|
className: i,
|
|
@@ -96,4 +112,4 @@ function w({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i,
|
|
|
96
112
|
});
|
|
97
113
|
}
|
|
98
114
|
//#endregion
|
|
99
|
-
export {
|
|
115
|
+
export { E as KapiTabPanel, T as KapiTabs };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode, Ref } from "react";
|
|
2
2
|
import type { KapiTone } from "../tone.js";
|
|
3
|
+
import type { KapiRender } from "../renderSlot.js";
|
|
3
4
|
import { type KapiNavBadgeValue } from "./navBadgeLogic.js";
|
|
4
5
|
type MiniNavItemProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
6
|
+
/** Ref al `<button>` (o al elemento de `render`). */
|
|
7
|
+
ref?: Ref<HTMLButtonElement> | undefined;
|
|
5
8
|
/** Etiqueta del ítem: queda oculta a la vista pero es el nombre accesible y el texto del tooltip. */
|
|
6
9
|
label: ReactNode;
|
|
7
10
|
/** Ícono; sin él se muestran las iniciales o la inicial de la etiqueta. */
|
|
@@ -18,6 +21,8 @@ type MiniNavItemProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"
|
|
|
18
21
|
badgeLabel?: string | undefined;
|
|
19
22
|
/** Enlace real en vez de botón. */
|
|
20
23
|
href?: string | undefined;
|
|
24
|
+
/** El elemento que dibuja el enlace (el `<Link>` del router); `onClick` corre después del suyo. Con `render`, `href` se ignora. */
|
|
25
|
+
render?: KapiRender | undefined;
|
|
21
26
|
/** Abre el enlace en una pestaña nueva. */
|
|
22
27
|
newTab?: boolean | undefined;
|
|
23
28
|
/** Aviso de pestaña nueva para lectores de pantalla. */
|
|
@@ -30,5 +35,5 @@ type MiniNavItemProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"
|
|
|
30
35
|
* Ítem de navegación del panel plegado en modo mini: sólo el ícono (o la inicial), el aviso en la esquina y
|
|
31
36
|
* un tooltip con el título y el aviso. La etiqueta sigue en el DOM (oculta a la vista) como nombre accesible.
|
|
32
37
|
*/
|
|
33
|
-
export declare const MiniNavItem: ({ label, icon, initials, active, badge, badgeTone, badgeLabel, href, newTab, newTabLabel, className, disabled, type, ...rest }: MiniNavItemProps) => import("react").JSX.Element;
|
|
38
|
+
export declare const MiniNavItem: ({ label, icon, initials, active, badge, badgeTone, badgeLabel, href, render, newTab, newTabLabel, className, disabled, onClick, ref, type, ...rest }: MiniNavItemProps) => import("react").JSX.Element;
|
|
34
39
|
export {};
|
|
@@ -5,54 +5,59 @@ import { KapiTooltip as t } from "../overlays/KapiTooltip.js";
|
|
|
5
5
|
import { navBadgeA11yText as n } from "./navBadgeLogic.js";
|
|
6
6
|
import { KapiNavBadge as r } from "./KapiNavBadge.js";
|
|
7
7
|
/* empty css */
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { renderNavLink as i } from "./navLink.js";
|
|
9
|
+
import { useKapiPanelMini as a } from "./panelMini.js";
|
|
10
|
+
import { miniInitial as o, miniTooltipLabel as s, nodeText as c } from "./panelMiniLogic.js";
|
|
11
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
12
|
//#region src/components/navigation/MiniNavItem.tsx
|
|
12
|
-
var
|
|
13
|
-
let { tooltipSide:
|
|
13
|
+
var f = ({ label: f, icon: p, initials: m, active: h = !1, badge: g, badgeTone: _, badgeLabel: v, href: y, render: b, newTab: x, newTabLabel: S, className: C, disabled: w, onClick: T, ref: E, type: D = "button", ...O }) => {
|
|
14
|
+
let { tooltipSide: k } = a(), A = c(f), j = s(A, n(g, v)), M = e("kapi-ctxitem", "kapi-ctxitem--mini", h && "kapi-ctxitem--on", C), N = p == null || p === !1 ? /* @__PURE__ */ u("span", {
|
|
14
15
|
className: "kapi-ctxitem__initial",
|
|
15
|
-
children:
|
|
16
|
-
}) :
|
|
17
|
-
/* @__PURE__ */
|
|
16
|
+
children: m ?? o(A)
|
|
17
|
+
}) : p, P = /* @__PURE__ */ d(l, { children: [
|
|
18
|
+
/* @__PURE__ */ u("span", {
|
|
18
19
|
className: "kapi-ctxitem__miniicon",
|
|
19
20
|
"aria-hidden": "true",
|
|
20
|
-
children:
|
|
21
|
+
children: N
|
|
21
22
|
}),
|
|
22
|
-
/* @__PURE__ */
|
|
23
|
+
/* @__PURE__ */ u("span", {
|
|
23
24
|
className: "kapi-ctxitem__sr",
|
|
24
|
-
children:
|
|
25
|
+
children: f
|
|
25
26
|
}),
|
|
26
|
-
/* @__PURE__ */
|
|
27
|
-
value:
|
|
28
|
-
tone:
|
|
29
|
-
label:
|
|
27
|
+
/* @__PURE__ */ u(r, {
|
|
28
|
+
value: g,
|
|
29
|
+
tone: _,
|
|
30
|
+
label: v,
|
|
30
31
|
placement: "corner"
|
|
31
32
|
})
|
|
32
33
|
] });
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
label:
|
|
35
|
-
prefer:
|
|
36
|
-
children:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
disabled:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
rel: "noopener noreferrer",
|
|
47
|
-
target: y ? "_blank" : void 0,
|
|
48
|
-
"aria-current": m ? "page" : void 0,
|
|
49
|
-
"aria-disabled": S || void 0,
|
|
50
|
-
children: [A, y && /* @__PURE__ */ u(c, { children: [" ", /* @__PURE__ */ l("span", {
|
|
34
|
+
return /* @__PURE__ */ u(t, {
|
|
35
|
+
label: j,
|
|
36
|
+
prefer: k,
|
|
37
|
+
children: y !== void 0 || b !== void 0 ? i({
|
|
38
|
+
render: b,
|
|
39
|
+
href: y,
|
|
40
|
+
newTab: x,
|
|
41
|
+
disabled: w,
|
|
42
|
+
active: h,
|
|
43
|
+
className: e(M, "kapi-ctxitem--link"),
|
|
44
|
+
onClick: b === void 0 ? void 0 : T,
|
|
45
|
+
ref: E,
|
|
46
|
+
children: /* @__PURE__ */ d(l, { children: [P, x && /* @__PURE__ */ d(l, { children: [" ", /* @__PURE__ */ u("span", {
|
|
51
47
|
className: "kapi-ctxitem__sr",
|
|
52
|
-
children:
|
|
53
|
-
})] })]
|
|
48
|
+
children: S
|
|
49
|
+
})] })] })
|
|
50
|
+
}) : /* @__PURE__ */ u("button", {
|
|
51
|
+
...O,
|
|
52
|
+
ref: E,
|
|
53
|
+
type: D,
|
|
54
|
+
className: M,
|
|
55
|
+
disabled: w,
|
|
56
|
+
onClick: T,
|
|
57
|
+
"aria-current": h ? "page" : void 0,
|
|
58
|
+
children: P
|
|
54
59
|
})
|
|
55
60
|
});
|
|
56
61
|
};
|
|
57
62
|
//#endregion
|
|
58
|
-
export {
|
|
63
|
+
export { f as MiniNavItem };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export type KapiBreadcrumbItemKind = "link" | "text" | "current";
|
|
2
2
|
/**
|
|
3
3
|
* Rol de cada ítem: el último es la ubicación actual; los anteriores con
|
|
4
|
-
* `onClick` son
|
|
4
|
+
* `onClick`, `href` o `render` son enlaces (una miga ES un enlace); el resto es texto plano.
|
|
5
5
|
*/
|
|
6
6
|
export declare const breadcrumbKinds: (items: ReadonlyArray<{
|
|
7
|
-
onClick?:
|
|
7
|
+
onClick?: unknown;
|
|
8
|
+
href?: string | undefined;
|
|
9
|
+
render?: unknown;
|
|
8
10
|
}>) => KapiBreadcrumbItemKind[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/components/navigation/breadcrumbLogic.ts
|
|
2
|
-
var e = (e) => e.map((t, n) => n === e.length - 1 ? "current" : t.onClick ? "link" : "text");
|
|
2
|
+
var e = (e) => e.map((t, n) => n === e.length - 1 ? "current" : t.onClick || t.href !== void 0 || t.render !== void 0 ? "link" : "text");
|
|
3
3
|
//#endregion
|
|
4
4
|
export { e as breadcrumbKinds };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode, Ref } from "react";
|
|
2
|
+
import { type KapiRender, type SlotProps } from "../renderSlot.js";
|
|
3
|
+
export type RenderNavLinkArgs = {
|
|
4
|
+
render: KapiRender | undefined;
|
|
5
|
+
href: string | undefined;
|
|
6
|
+
newTab?: boolean | undefined;
|
|
7
|
+
disabled?: boolean | undefined;
|
|
8
|
+
active?: boolean | undefined;
|
|
9
|
+
className: string;
|
|
10
|
+
/** Handler propio del ítem. Con `render` corre DESPUÉS del handler del consumidor. */
|
|
11
|
+
onClick?: ((event: never) => void) | undefined;
|
|
12
|
+
/** Atributos propios extra (`aria-label`…); el consumidor los puede pisar. */
|
|
13
|
+
extra?: SlotProps | undefined;
|
|
14
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Dibuja el enlace de un ítem de navegación: un `<a href>` nativo, o el elemento que trajo el consumidor en
|
|
19
|
+
* `render`. Un solo camino para rail, panel, grupo y menú plegado, así los cuatro se comportan igual.
|
|
20
|
+
*/
|
|
21
|
+
export declare const renderNavLink: ({ render, href, newTab, disabled, active, className, onClick, extra, ref, children }: RenderNavLinkArgs) => ReactElement;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { renderSlot as e } from "../renderSlot.js";
|
|
3
|
+
import { navLinkProps as t } from "./navLinkLogic.js";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/navigation/navLink.tsx
|
|
6
|
+
var r = ({ render: r, href: i, newTab: a, disabled: o, active: s, className: c, onClick: l, extra: u, ref: d, children: f }) => {
|
|
7
|
+
let { propias: p, fijas: m } = t({
|
|
8
|
+
render: r,
|
|
9
|
+
href: i,
|
|
10
|
+
newTab: a,
|
|
11
|
+
disabled: o,
|
|
12
|
+
active: s
|
|
13
|
+
});
|
|
14
|
+
return e(r, {
|
|
15
|
+
className: c,
|
|
16
|
+
...l ? { onClick: l } : {},
|
|
17
|
+
...u,
|
|
18
|
+
...p
|
|
19
|
+
}, {
|
|
20
|
+
...m,
|
|
21
|
+
ref: d,
|
|
22
|
+
children: f
|
|
23
|
+
}, (e) => /* @__PURE__ */ n("a", { ...e }));
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { r as renderNavLink };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SlotProps } from "../renderSlot.js";
|
|
2
|
+
export type NavLinkArgs = {
|
|
3
|
+
/** El elemento del consumidor, si lo hay. */
|
|
4
|
+
render: unknown;
|
|
5
|
+
/** Destino nativo. Con `render` no se usa. */
|
|
6
|
+
href: string | undefined;
|
|
7
|
+
/** El destino abre en otra pestaña. */
|
|
8
|
+
newTab?: boolean | undefined;
|
|
9
|
+
/** El ítem no se puede elegir. */
|
|
10
|
+
disabled?: boolean | undefined;
|
|
11
|
+
/** Es la página actual. */
|
|
12
|
+
active?: boolean | undefined;
|
|
13
|
+
};
|
|
14
|
+
/** Reparte las props del enlace entre las que el consumidor puede pisar (`propias`) y las que no (`fijas`). */
|
|
15
|
+
export declare const navLinkProps: ({ render, href, newTab, disabled, active }: NavLinkArgs) => {
|
|
16
|
+
propias: SlotProps;
|
|
17
|
+
fijas: SlotProps;
|
|
18
|
+
};
|