@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.
Files changed (145) hide show
  1. package/LICENSE +19 -15
  2. package/README.md +338 -6
  3. package/dist/components/data/KapiDataTable.d.ts +1 -1
  4. package/dist/components/data/KapiDataTable.js +22 -22
  5. package/dist/components/data/KapiPaginationFooter.js +1 -1
  6. package/dist/components/data/KapiSheet.d.ts +105 -0
  7. package/dist/components/data/KapiSheet.js +75 -0
  8. package/dist/components/data/KapiTable.d.ts +2 -2
  9. package/dist/components/data/KapiTable.js +347 -329
  10. package/dist/components/data/KapiTableFooter.d.ts +22 -0
  11. package/dist/components/data/KapiTableFooter.js +55 -0
  12. package/dist/components/data/KapiTableRow.js +53 -52
  13. package/dist/components/data/KapiTableToolbar.d.ts +4 -2
  14. package/dist/components/data/KapiTableToolbar.js +71 -69
  15. package/dist/components/data/index.d.ts +3 -1
  16. package/dist/components/data/tableCells.d.ts +5 -4
  17. package/dist/components/data/tableCells.js +48 -43
  18. package/dist/components/data/tableLogic.d.ts +2 -0
  19. package/dist/components/data/tableLogic.js +66 -66
  20. package/dist/components/data/tableSlots.d.ts +9 -0
  21. package/dist/components/data/tableSlots.js +12 -0
  22. package/dist/components/data/tableSpanLogic.d.ts +35 -0
  23. package/dist/components/data/tableSpanLogic.js +47 -0
  24. package/dist/components/data/tableTypes.d.ts +66 -1
  25. package/dist/components/data/useTableSelection.d.ts +4 -2
  26. package/dist/components/data/useTableSelection.js +27 -23
  27. package/dist/components/display/KapiAnchor.d.ts +36 -0
  28. package/dist/components/display/KapiAnchor.js +36 -0
  29. package/dist/components/display/KapiBadge.d.ts +6 -5
  30. package/dist/components/display/KapiBadge.js +25 -19
  31. package/dist/components/display/KapiText.d.ts +43 -0
  32. package/dist/components/display/KapiText.js +33 -0
  33. package/dist/components/display/KapiTitle.d.ts +33 -0
  34. package/dist/components/display/KapiTitle.js +29 -0
  35. package/dist/components/display/index.d.ts +7 -0
  36. package/dist/components/display/textLogic.d.ts +32 -0
  37. package/dist/components/display/textLogic.js +19 -0
  38. package/dist/components/feedback/KapiAlert.d.ts +8 -4
  39. package/dist/components/feedback/KapiAlert.js +39 -34
  40. package/dist/components/inputs/KapiButton.d.ts +7 -4
  41. package/dist/components/inputs/KapiButton.js +47 -42
  42. package/dist/components/inputs/KapiSelect.d.ts +12 -0
  43. package/dist/components/inputs/KapiSelect.js +215 -212
  44. package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
  45. package/dist/components/inputs/KapiSelectMenu.js +131 -133
  46. package/dist/components/inputs/fieldLogic.d.ts +2 -2
  47. package/dist/components/inputs/index.d.ts +1 -1
  48. package/dist/components/inputs/selectSlots.d.ts +24 -0
  49. package/dist/components/inputs/selectSlots.js +27 -0
  50. package/dist/components/layout/KapiBox.d.ts +31 -0
  51. package/dist/components/layout/KapiBox.js +26 -0
  52. package/dist/components/layout/KapiCard.d.ts +16 -4
  53. package/dist/components/layout/KapiCard.js +46 -34
  54. package/dist/components/layout/KapiCenter.d.ts +13 -0
  55. package/dist/components/layout/KapiCenter.js +23 -0
  56. package/dist/components/layout/KapiCol.d.ts +22 -0
  57. package/dist/components/layout/KapiCol.js +23 -0
  58. package/dist/components/layout/KapiGrid.d.ts +29 -3
  59. package/dist/components/layout/KapiGrid.js +39 -17
  60. package/dist/components/layout/KapiPageHeader.d.ts +10 -1
  61. package/dist/components/layout/KapiPageHeader.js +82 -80
  62. package/dist/components/layout/KapiPanelParts.d.ts +11 -2
  63. package/dist/components/layout/KapiPanelParts.js +73 -56
  64. package/dist/components/layout/KapiRail.d.ts +10 -1
  65. package/dist/components/layout/KapiRail.js +123 -120
  66. package/dist/components/layout/KapiRoot.d.ts +35 -5
  67. package/dist/components/layout/KapiRoot.js +54 -39
  68. package/dist/components/layout/KapiShell.d.ts +36 -3
  69. package/dist/components/layout/KapiShell.js +53 -50
  70. package/dist/components/layout/cardSlots.d.ts +9 -0
  71. package/dist/components/layout/cardSlots.js +12 -0
  72. package/dist/components/layout/gridSpanLogic.d.ts +46 -0
  73. package/dist/components/layout/gridSpanLogic.js +39 -0
  74. package/dist/components/layout/index.d.ts +11 -4
  75. package/dist/components/layout/layoutPrimitives.d.ts +11 -0
  76. package/dist/components/layout/layoutPrimitives.js +12 -1
  77. package/dist/components/layout/pageHeaderSlots.d.ts +12 -0
  78. package/dist/components/layout/pageHeaderSlots.js +15 -0
  79. package/dist/components/layout/railLogic.d.ts +16 -3
  80. package/dist/components/layout/railSlots.d.ts +12 -0
  81. package/dist/components/layout/railSlots.js +15 -0
  82. package/dist/components/layout/shellSlots.d.ts +6 -0
  83. package/dist/components/layout/shellSlots.js +9 -0
  84. package/dist/components/layout/useGridBreakpoint.d.ts +12 -0
  85. package/dist/components/layout/useGridBreakpoint.js +35 -0
  86. package/dist/components/navigation/KapiBreadcrumb.d.ts +18 -2
  87. package/dist/components/navigation/KapiBreadcrumb.js +23 -16
  88. package/dist/components/navigation/KapiContextPanel.d.ts +17 -4
  89. package/dist/components/navigation/KapiContextPanel.js +151 -135
  90. package/dist/components/navigation/KapiPanelGroup.d.ts +16 -4
  91. package/dist/components/navigation/KapiPanelGroup.js +66 -65
  92. package/dist/components/navigation/KapiTabs.d.ts +12 -0
  93. package/dist/components/navigation/KapiTabs.js +87 -71
  94. package/dist/components/navigation/MiniNavItem.d.ts +7 -2
  95. package/dist/components/navigation/MiniNavItem.js +41 -36
  96. package/dist/components/navigation/breadcrumbLogic.d.ts +4 -2
  97. package/dist/components/navigation/breadcrumbLogic.js +1 -1
  98. package/dist/components/navigation/navLink.d.ts +21 -0
  99. package/dist/components/navigation/navLink.js +26 -0
  100. package/dist/components/navigation/navLinkLogic.d.ts +18 -0
  101. package/dist/components/navigation/navLinkLogic.js +22 -0
  102. package/dist/components/overlays/KapiContextMenu.d.ts +8 -0
  103. package/dist/components/overlays/KapiModal.d.ts +9 -0
  104. package/dist/components/overlays/KapiModal.js +77 -75
  105. package/dist/components/overlays/index.d.ts +1 -1
  106. package/dist/components/overlays/menuList.js +123 -113
  107. package/dist/components/overlays/modalSlots.d.ts +11 -0
  108. package/dist/components/overlays/modalSlots.js +14 -0
  109. package/dist/components/slotCatalog.d.ts +90 -0
  110. package/dist/components/slotCatalog.js +19 -0
  111. package/dist/components/slotsLogic.d.ts +34 -0
  112. package/dist/components/slotsLogic.js +18 -0
  113. package/dist/components/tone.d.ts +26 -0
  114. package/dist/components/tone.js +15 -14
  115. package/dist/css/base.css +1 -1
  116. package/dist/css/components/data/KapiEventCalendar.css +1 -1
  117. package/dist/css/components/data/KapiTable.css +1 -1
  118. package/dist/css/components/display/display.css +1 -1
  119. package/dist/css/components/display/typography.css +1 -0
  120. package/dist/css/components/feedback/feedback.css +1 -1
  121. package/dist/css/components/inputs/KapiButton.css +1 -1
  122. package/dist/css/components/inputs/KapiDatePicker.css +1 -1
  123. package/dist/css/components/layout/KapiBox.css +1 -0
  124. package/dist/css/components/layout/KapiRail.css +1 -1
  125. package/dist/css/components/layout/gridSpan.css +1 -0
  126. package/dist/css/components/navigation/navigation.css +1 -1
  127. package/dist/hooks/densityLogic.d.ts +15 -0
  128. package/dist/hooks/densityLogic.js +4 -0
  129. package/dist/hooks/index.d.ts +4 -0
  130. package/dist/hooks/themeColorsLogic.d.ts +19 -0
  131. package/dist/hooks/themeColorsLogic.js +4 -2
  132. package/dist/hooks/themeDeriveLogic.d.ts +16 -0
  133. package/dist/hooks/themeDeriveLogic.js +27 -17
  134. package/dist/hooks/toneFamilyLogic.d.ts +122 -0
  135. package/dist/hooks/toneFamilyLogic.js +151 -0
  136. package/dist/hooks/useKapiTheme.d.ts +8 -2
  137. package/dist/hooks/useKapiTheme.js +116 -103
  138. package/dist/hooks/useToneFamilies.d.ts +30 -0
  139. package/dist/hooks/useToneFamilies.js +46 -0
  140. package/dist/index.d.ts +3 -1
  141. package/dist/index.js +213 -204
  142. package/dist/kapi.css +1 -1
  143. package/dist/kapi.layered.css +1 -1
  144. package/dist/styles/rawHeights.d.ts +8 -0
  145. package/package.json +4 -4
@@ -1,6 +1,6 @@
1
1
  import type { KapiMenuItem } from "../overlays/KapiContextMenu.js";
2
2
  import { datasetNoticeState, type DatasetNoticeLabels } from "./datasetSelectionLogic.js";
3
- import type { KapiTableDataset, KapiTableKeyField, KapiTableSelectionPreset } from "./tableTypes.js";
3
+ import type { KapiTableClassNames, KapiTableDataset, KapiTableKeyField, KapiTableSelectionPreset } from "./tableTypes.js";
4
4
  type TableSelectionInput<T, K extends KapiTableKeyField<T>> = {
5
5
  /** Filas que la tabla muestra (ya filtradas y ordenadas). */
6
6
  rows: ReadonlyArray<T>;
@@ -37,7 +37,9 @@ export declare const useTableSelection: <T, K extends KapiTableKeyField<T>>({ ro
37
37
  * al mismo tiempo que su texto se queda muda. Vacía no tiene clase ni contenido, así que no ocupa nada.
38
38
  * Es el mismo patrón del contador del filtro y de `KapiBulkBar`.
39
39
  */
40
- export declare function TableDatasetNotice({ dataset, notice, shown, clearLabel, labels, locale }: {
40
+ export declare function TableDatasetNotice({ dataset, notice, shown, clearLabel, labels, locale, classNames }: {
41
+ /** `classNames` de la tabla: acá cuenta `datasetNotice`. */
42
+ classNames?: KapiTableClassNames | undefined;
41
43
  dataset: KapiTableDataset;
42
44
  notice: ReturnType<typeof datasetNoticeState>;
43
45
  /** Filas seleccionables que la tabla tiene. */
@@ -1,15 +1,17 @@
1
1
  "use client";
2
2
  import { useRangeSelect as e } from "../../hooks/useRangeSelect.js";
3
3
  import { useControllableState as t } from "../../hooks/useControllableState.js";
4
- import { formatCount as n } from "../../hooks/numberFormatLogic.js";
5
- import { selectOnlyWithin as r, selectionState as i } from "./tableLogic.js";
6
- import { datasetActionLabel as a, datasetHintLabel as o, datasetNoticeState as s, datasetSelectedLabel as c } from "./datasetSelectionLogic.js";
7
- import { useMemo as l } from "react";
8
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
9
- import { Loader2 as p } from "lucide-react";
4
+ import { slot as n } from "../slotsLogic.js";
5
+ import { formatCount as r } from "../../hooks/numberFormatLogic.js";
6
+ import { selectOnlyWithin as i, selectionState as a } from "./tableLogic.js";
7
+ import { TABLE_SLOTS as o } from "./tableSlots.js";
8
+ import { datasetActionLabel as s, datasetHintLabel as c, datasetNoticeState as l, datasetSelectedLabel as u } from "./datasetSelectionLogic.js";
9
+ import { useMemo as d } from "react";
10
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
11
+ import { Loader2 as h } from "lucide-react";
10
12
  //#region src/components/data/useTableSelection.tsx
11
- var m = [], h = ({ rows: a, keyField: o, selectable: c, selectedIds: h, defaultSelectedIds: g, onSelectedIdsChange: _, isRowSelectable: v, selectionPresets: y, rangeSelect: b, dataset: x, loadingLabel: S, locale: C }) => {
12
- let [w, T] = t(h, g ?? m, _ && ((e) => _([...e]))), E = l(() => new Set(w), [w]), D = (e) => T([...e]), O = () => D(/* @__PURE__ */ new Set()), k = [...E], A = e(), j = c && y !== void 0 && y.length > 0, M = l(() => a.filter((e) => !v || v(e)), [a, v]), N = l(() => M.map((e) => e[o]), [M, o]), P = l(() => j && y ? y.map((e) => ({
13
+ var g = [], _ = ({ rows: n, keyField: o, selectable: s, selectedIds: c, defaultSelectedIds: u, onSelectedIdsChange: _, isRowSelectable: v, selectionPresets: y, rangeSelect: b, dataset: x, loadingLabel: S, locale: C }) => {
14
+ let [w, T] = t(c, u ?? g, _ && ((e) => _([...e]))), E = d(() => new Set(w), [w]), D = (e) => T([...e]), O = () => D(/* @__PURE__ */ new Set()), k = [...E], A = e(), j = s && y !== void 0 && y.length > 0, M = d(() => n.filter((e) => !v || v(e)), [n, v]), N = d(() => M.map((e) => e[o]), [M, o]), P = d(() => j && y ? y.map((e) => ({
13
15
  preset: e,
14
16
  matching: e.match === void 0 ? [] : M.filter(e.match).map((e) => e[o])
15
17
  })) : [], [
@@ -18,22 +20,22 @@ var m = [], h = ({ rows: a, keyField: o, selectable: c, selectedIds: h, defaultS
18
20
  M,
19
21
  o
20
22
  ]).map(({ preset: e, matching: t }) => {
21
- let i = e.onSelect === void 0 ? t.length : e.count, a = e.pending === !0, o = a ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(p, {
23
+ let n = e.onSelect === void 0 ? t.length : e.count, a = e.pending === !0, o = a ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(h, {
22
24
  size: 14,
23
25
  strokeWidth: 2.2,
24
26
  className: "kapi-table-spin",
25
27
  "aria-hidden": !0
26
- }), /* @__PURE__ */ d("span", {
28
+ }), /* @__PURE__ */ p("span", {
27
29
  className: "kapi-sr-only",
28
30
  children: S
29
31
  })] }) : e.icon;
30
32
  return {
31
- label: a ? e.label : `${e.label} (${n(i, C)})`,
33
+ label: a ? e.label : `${e.label} (${r(n, C)})`,
32
34
  ...o !== void 0 && { icon: o },
33
- disabled: a || i === 0,
34
- onClick: e.onSelect ?? (() => D(r(E, N, t)))
35
+ disabled: a || n === 0,
36
+ onClick: e.onSelect ?? (() => D(i(E, N, t)))
35
37
  };
36
- }), F = i(N, E);
38
+ }), F = a(N, E);
37
39
  return {
38
40
  sel: E,
39
41
  commitSelection: D,
@@ -43,7 +45,7 @@ var m = [], h = ({ rows: a, keyField: o, selectable: c, selectedIds: h, defaultS
43
45
  hasPresets: j,
44
46
  presetItems: P,
45
47
  headerState: F,
46
- datasetNotice: x !== void 0 && c ? s({
48
+ datasetNotice: x !== void 0 && s ? l({
47
49
  headerState: F,
48
50
  shown: N.length,
49
51
  total: x.total,
@@ -59,22 +61,24 @@ var m = [], h = ({ rows: a, keyField: o, selectable: c, selectedIds: h, defaultS
59
61
  }
60
62
  };
61
63
  };
62
- function g({ dataset: e, notice: t, shown: n, clearLabel: r, labels: i, locale: s }) {
63
- return /* @__PURE__ */ f("div", {
64
- className: t === "none" ? void 0 : "kapi-table__dataset",
64
+ function v({ dataset: e, notice: t, shown: r, clearLabel: i, labels: a, locale: l, classNames: d }) {
65
+ let h = n(o, "datasetNotice", d);
66
+ return /* @__PURE__ */ m("div", {
67
+ ...h,
68
+ className: t === "none" ? void 0 : h.className,
65
69
  role: "status",
66
- children: [t === "offer" && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("span", { children: e.hintLabel ? e.hintLabel(n, e.total) : o(n, e.total, i, s) }), /* @__PURE__ */ d("button", {
70
+ children: [t === "offer" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", { children: e.hintLabel ? e.hintLabel(r, e.total) : c(r, e.total, a, l) }), /* @__PURE__ */ p("button", {
67
71
  type: "button",
68
72
  className: "kapi-link",
69
73
  onClick: e.onSelect,
70
- children: e.actionLabel ? e.actionLabel(e.total) : a(e.total, i, s)
71
- })] }), t === "selected" && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("span", { children: e.selectedLabel ? e.selectedLabel(e.total) : c(e.total, i, s) }), e.onClear && /* @__PURE__ */ d("button", {
74
+ children: e.actionLabel ? e.actionLabel(e.total) : s(e.total, a, l)
75
+ })] }), t === "selected" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", { children: e.selectedLabel ? e.selectedLabel(e.total) : u(e.total, a, l) }), e.onClear && /* @__PURE__ */ p("button", {
72
76
  type: "button",
73
77
  className: "kapi-link",
74
78
  onClick: e.onClear,
75
- children: r
79
+ children: i
76
80
  })] })]
77
81
  });
78
82
  }
79
83
  //#endregion
80
- export { g as TableDatasetNotice, h as useTableSelection };
84
+ export { v as TableDatasetNotice, _ as useTableSelection };
@@ -0,0 +1,36 @@
1
+ import type { AnchorHTMLAttributes, Ref } from "react";
2
+ import { type KapiRender } from "../renderSlot.js";
3
+ import type { KapiLabelsOverride } from "../labelsLogic.js";
4
+ import { type KapiLinkLabels } from "../locale/linkLabels.js";
5
+ import { type KapiTextSize, type KapiTextWeight } from "./textLogic.js";
6
+ /** Subrayado de un link: sólo al pasar el mouse, siempre o nunca. */
7
+ export type KapiAnchorUnderline = "hover" | "always" | "never";
8
+ export type KapiAnchorProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
9
+ /** Ref al `<a>` (o al elemento de `render`). */
10
+ ref?: Ref<HTMLAnchorElement> | undefined;
11
+ /** Tamaño, de la escala `--kapi-fs-*`. Sin `size` el link hereda el del texto que lo rodea. */
12
+ size?: KapiTextSize | undefined;
13
+ /** Peso de la letra. Sin `weight` hereda el del texto que lo rodea. */
14
+ weight?: KapiTextWeight | undefined;
15
+ /**
16
+ * Cuándo se subraya.
17
+ * @default "hover"
18
+ */
19
+ underline?: KapiAnchorUnderline | undefined;
20
+ /**
21
+ * Abre en una pestaña nueva (`target="_blank"` con `rel="noopener noreferrer"`) y se lo avisa a los
22
+ * lectores de pantalla con el texto compartido de la clave `link` del locale.
23
+ */
24
+ newTab?: boolean | undefined;
25
+ /** Textos fijos; `newTab` sale de la clave compartida `link`. */
26
+ labels?: KapiLabelsOverride<KapiLinkLabels> | undefined;
27
+ /**
28
+ * Dibuja OTRO elemento con el aspecto del link: el `<Link>` de tu router. Las clases se unen, los
29
+ * estilos se funden y los handlers corren los dos (primero el tuyo), como en `KapiButton`.
30
+ *
31
+ * <KapiAnchor render={<Link to="/altas" />}>Altas</KapiAnchor>
32
+ */
33
+ render?: KapiRender | undefined;
34
+ };
35
+ /** Link de texto del sistema, con `render` para el router y el aviso de «se abre en una pestaña nueva». */
36
+ export declare const KapiAnchor: ({ size, weight, underline, newTab, labels, render, className, target, rel, style, ref, children, ...rest }: KapiAnchorProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import "#kapi-css/components/display/typography.css";
3
+ import { joinClasses as e } from "../rootProps.js";
4
+ import { renderSlot as t } from "../renderSlot.js";
5
+ import { useLabels as n } from "../locale/KapiLocaleProvider.js";
6
+ import { DEFAULT_LINK_LABELS as r } from "../locale/linkLabels.js";
7
+ import { textClasses as i } from "./textLogic.js";
8
+ /* empty css */
9
+ import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
10
+ //#region src/components/display/KapiAnchor.tsx
11
+ var c = ({ size: c, weight: l, underline: u = "hover", newTab: d = !1, labels: f, render: p, className: m, target: h, rel: g, style: _, ref: v, children: y, ...b }) => {
12
+ let x = n("link", r, f), S = d || h === "_blank", C = {
13
+ className: e("kapi-link", "kapi-anchor", ...i({
14
+ size: c,
15
+ weight: l
16
+ }), u !== "hover" && `kapi-anchor--underline-${u}`, m),
17
+ style: _,
18
+ ...b
19
+ }, w = /* @__PURE__ */ s(a, { children: [y, d && /* @__PURE__ */ s(a, { children: [" ", /* @__PURE__ */ o("span", {
20
+ className: "kapi-sr-only",
21
+ children: x.newTab
22
+ })] })] }), T = {
23
+ ...S ? {
24
+ target: "_blank",
25
+ rel: g ?? "noopener noreferrer"
26
+ } : {
27
+ target: h,
28
+ rel: g
29
+ },
30
+ ref: v,
31
+ children: w
32
+ };
33
+ return t(p, C, T, (e) => /* @__PURE__ */ o("a", { ...e }));
34
+ };
35
+ //#endregion
36
+ export { c as KapiAnchor };
@@ -1,5 +1,5 @@
1
1
  import type { HTMLAttributes, ReactNode, Ref } from "react";
2
- import { type KapiBadgeAppearance, type KapiTone } from "../tone.js";
2
+ import { type KapiBadgeAppearance, type KapiTone, type KapiToneName } from "../tone.js";
3
3
  export type { KapiBadgeAppearance } from "../tone.js";
4
4
  /** @deprecated Usar `KapiTone` (el color del badge ahora va en `tone`). */
5
5
  export type KapiBadgeVariant = KapiTone;
@@ -10,10 +10,11 @@ export type KapiBadgeProps = Omit<HTMLAttributes<HTMLSpanElement>, "children"> &
10
10
  /** Ref al `<span>` del badge. */
11
11
  ref?: Ref<HTMLSpanElement> | undefined;
12
12
  /**
13
- * Rol semántico (color). `neutral` es el gris calmo por defecto. Los valores `subtle`/`solid`
14
- * acá están deprecados: la forma va en `variant`.
13
+ * Rol semántico (color): un `KapiTone` o una familia propia de la app (`toneFamilies`).
14
+ * `neutral` es el gris calmo por defecto. Los valores `subtle`/`solid` acá están deprecados: la
15
+ * forma va en `variant`.
15
16
  */
16
- tone?: KapiTone | KapiBadgeAppearance | undefined;
17
+ tone?: KapiToneName | KapiBadgeAppearance | undefined;
17
18
  /**
18
19
  * Forma: `subtle` = fondo suave + borde; `solid` = color pleno con texto `-fg`. Un color acá
19
20
  * (`variant="danger"`) está deprecado: el color va en `tone`.
@@ -29,4 +30,4 @@ export type KapiBadgeProps = Omit<HTMLAttributes<HTMLSpanElement>, "children"> &
29
30
  /** Clases de un badge. Pura y exportada: es lo que se testea (no el markup). */
30
31
  export declare const badgeClasses: ({ tone, variant, size, className }?: Pick<KapiBadgeProps, "variant" | "tone" | "size" | "className">) => string;
31
32
  /** Pastilla de estado/etiqueta, con los tokens semánticos por rol. */
32
- export declare function KapiBadge({ tone, variant, size, dot, className, children, ...rest }: KapiBadgeProps): import("react").JSX.Element;
33
+ export declare function KapiBadge({ tone, variant, size, dot, className, style, children, ...rest }: KapiBadgeProps): import("react").JSX.Element;
@@ -1,33 +1,39 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/display/display.css";
3
- import { resolveBadgeLook as e } from "../tone.js";
3
+ import { useToneLook as e } from "../../hooks/useToneFamilies.js";
4
+ import { isFamilyTone as t, resolveBadgeLook as n } from "../tone.js";
4
5
  /* empty css */
5
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
6
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
6
7
  //#region src/components/display/KapiBadge.tsx
7
- var r = ({ tone: t, variant: n, size: r = "md", className: i = "" } = {}) => {
8
- let a = e(t, n);
8
+ var a = ({ tone: e, variant: r, size: i = "md", className: a = "" } = {}) => {
9
+ let o = t(e), s = n(o ? void 0 : e, r);
9
10
  return [
10
11
  "kapi-badge",
11
- `kapi-badge--${a.tone}`,
12
- a.appearance === "solid" && "kapi-badge--solid",
13
- r !== "md" && `kapi-badge--${r}`,
14
- i
12
+ o ? "kapi-badge--family" : `kapi-badge--${s.tone}`,
13
+ s.appearance === "solid" && "kapi-badge--solid",
14
+ i !== "md" && `kapi-badge--${i}`,
15
+ a
15
16
  ].filter(Boolean).join(" ");
16
17
  };
17
- function i({ tone: e, variant: i, size: a = "md", dot: o = !1, className: s, children: c, ...l }) {
18
- return /* @__PURE__ */ n("span", {
19
- className: r({
20
- tone: e,
21
- variant: i,
22
- size: a,
23
- className: s
18
+ function o({ tone: t, variant: n, size: o = "md", dot: s = !1, className: c, style: l, children: u, ...d }) {
19
+ let f = e("KapiBadge", t);
20
+ return /* @__PURE__ */ i("span", {
21
+ className: a({
22
+ tone: f.tone,
23
+ variant: n,
24
+ size: o,
25
+ className: c
24
26
  }),
25
- ...l,
26
- children: [o && /* @__PURE__ */ t("span", {
27
+ style: f.style ? {
28
+ ...f.style,
29
+ ...l
30
+ } : l,
31
+ ...d,
32
+ children: [s && /* @__PURE__ */ r("span", {
27
33
  className: "kapi-badge__dot",
28
34
  "aria-hidden": !0
29
- }), c]
35
+ }), u]
30
36
  });
31
37
  }
32
38
  //#endregion
33
- export { i as KapiBadge, r as badgeClasses };
39
+ export { o as KapiBadge, a as badgeClasses };
@@ -0,0 +1,43 @@
1
+ import type { HTMLAttributes, Ref } from "react";
2
+ import { type KapiRender } from "../renderSlot.js";
3
+ import { type KapiTextAlign, type KapiTextSize, type KapiTextTone, type KapiTextWeight } from "./textLogic.js";
4
+ /** Elementos que puede dibujar `KapiText`: sólo los de texto, no contenedores ni tablas. */
5
+ export type KapiTextElement = "p" | "span" | "div" | "small" | "strong" | "em" | "code" | "kbd";
6
+ export type KapiTextProps = HTMLAttributes<HTMLElement> & {
7
+ /** Ref al elemento de texto. */
8
+ ref?: Ref<HTMLElement> | undefined;
9
+ /**
10
+ * Tamaño, de la escala `--kapi-fs-*`. Sin `size` el texto hereda el de su contexto.
11
+ * @default undefined
12
+ */
13
+ size?: KapiTextSize | undefined;
14
+ /** Color semántico (`KapiTone`). Sin `tone` el texto hereda el color de su contexto. */
15
+ tone?: KapiTextTone | undefined;
16
+ /** Color atenuado de texto secundario. Si llegan `tone` y `muted`, gana `tone`. */
17
+ muted?: boolean | undefined;
18
+ /** Peso de la letra. Sin `weight` hereda el de su contexto. */
19
+ weight?: KapiTextWeight | undefined;
20
+ /** Alineación del texto dentro de su caja. */
21
+ align?: KapiTextAlign | undefined;
22
+ /**
23
+ * Corta el texto con elipsis: `true` o `1` en una línea, un número mayor en esa cantidad de líneas.
24
+ * Un texto truncado pasa a ser de bloque, porque el elipsis no actúa en un elemento en línea.
25
+ */
26
+ truncate?: boolean | number | undefined;
27
+ /**
28
+ * Elemento que se dibuja. `code` y `kbd` suman las primitivas `.kapi-code` y `.kapi-kbd`.
29
+ * @default "p"
30
+ */
31
+ as?: KapiTextElement | undefined;
32
+ /**
33
+ * Dibuja OTRO elemento con el aspecto del texto (un `<label>`, el `<Link>` del router…), como en
34
+ * `KapiButton`: las clases se unen, los estilos se funden y los handlers corren los dos. Gana sobre
35
+ * `as`.
36
+ */
37
+ render?: KapiRender | undefined;
38
+ };
39
+ /**
40
+ * Texto con el vocabulario del sistema: tamaño de la escala, color semántico, peso y alineación por
41
+ * props con nombre, sin atajos de CSS. Hereda del contexto todo lo que no se pide.
42
+ */
43
+ export declare const KapiText: ({ size, tone, muted, weight, align, truncate, as, render, className, style, ref, children, ...rest }: KapiTextProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import "#kapi-css/components/display/typography.css";
3
+ import { useToneLook as e } from "../../hooks/useToneFamilies.js";
4
+ import { joinClasses as t } from "../rootProps.js";
5
+ import { renderSlot as n } from "../renderSlot.js";
6
+ import { textClasses as r, truncateLines as i } from "./textLogic.js";
7
+ /* empty css */
8
+ import { jsx as a } from "react/jsx-runtime";
9
+ //#region src/components/display/KapiText.tsx
10
+ var o = ({ size: o, tone: s, muted: c, weight: l, align: u, truncate: d, as: f = "p", render: p, className: m, style: h, ref: g, children: _, ...v }) => {
11
+ let y = i(d), b = e("KapiText", s), x = {
12
+ className: t(...r({
13
+ size: o,
14
+ tone: b.tone,
15
+ muted: c,
16
+ weight: l,
17
+ align: u,
18
+ truncate: d
19
+ }), f === "code" && "kapi-code", f === "kbd" && "kapi-kbd", m),
20
+ style: y === void 0 && !b.style ? h : {
21
+ ...y === void 0 ? {} : { "--kapi-text-lines": y },
22
+ ...b.style,
23
+ ...h
24
+ },
25
+ ...v
26
+ }, S = f;
27
+ return n(p, x, {
28
+ ref: g,
29
+ children: _
30
+ }, (e) => /* @__PURE__ */ a(S, { ...e }));
31
+ };
32
+ //#endregion
33
+ export { o as KapiText };
@@ -0,0 +1,33 @@
1
+ import type { HTMLAttributes, Ref } from "react";
2
+ import { type KapiTextAlign, type KapiTextSize, type KapiTextTone, type KapiTextWeight, type KapiTitleLevel } from "./textLogic.js";
3
+ export type KapiTitleProps = HTMLAttributes<HTMLHeadingElement> & {
4
+ /** Ref al `<h1>`–`<h6>`. */
5
+ ref?: Ref<HTMLHeadingElement> | undefined;
6
+ /**
7
+ * Nivel del encabezado (`h1` a `h6`): es la estructura del documento, lo que leen los lectores de
8
+ * pantalla. NO decide el tamaño; para eso está `size`.
9
+ * @default 2
10
+ */
11
+ level?: KapiTitleLevel | undefined;
12
+ /**
13
+ * Tamaño visual, de la escala `--kapi-fs-*`, independiente del nivel: un `h2` puede verse chico sin
14
+ * romper la jerarquía. Sin `size`, cada nivel trae el suyo.
15
+ */
16
+ size?: KapiTextSize | undefined;
17
+ /** Color semántico (`KapiTone`). Sin `tone` el título usa la tinta del sistema. */
18
+ tone?: KapiTextTone | undefined;
19
+ /**
20
+ * Peso de la letra.
21
+ * @default "bold"
22
+ */
23
+ weight?: KapiTextWeight | undefined;
24
+ /** Alineación del texto dentro de su caja. */
25
+ align?: KapiTextAlign | undefined;
26
+ /** Corta con elipsis: `true` o `1` en una línea, un número mayor en esa cantidad de líneas. */
27
+ truncate?: boolean | number | undefined;
28
+ };
29
+ /**
30
+ * Encabezado. El nivel (`level`) y el tamaño visual (`size`) son props separadas a propósito: elegir
31
+ * `h4` para que se vea chico rompe la estructura que usan los lectores de pantalla.
32
+ */
33
+ export declare const KapiTitle: ({ level, size, tone, weight, align, truncate, className, style, ref, ...rest }: KapiTitleProps) => import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import "#kapi-css/components/display/typography.css";
3
+ import { useToneLook as e } from "../../hooks/useToneFamilies.js";
4
+ import { joinClasses as t } from "../rootProps.js";
5
+ import { TITLE_DEFAULT_SIZE as n, textClasses as r, truncateLines as i } from "./textLogic.js";
6
+ /* empty css */
7
+ import { jsx as a } from "react/jsx-runtime";
8
+ //#region src/components/display/KapiTitle.tsx
9
+ var o = ({ level: o = 2, size: s, tone: c, weight: l, align: u, truncate: d, className: f, style: p, ref: m, ...h }) => {
10
+ let g = `h${o}`, _ = i(d), v = e("KapiTitle", c);
11
+ return /* @__PURE__ */ a(g, {
12
+ ...h,
13
+ ref: m,
14
+ className: t(...r({
15
+ size: s ?? n[o],
16
+ tone: v.tone,
17
+ weight: l,
18
+ align: u,
19
+ truncate: d
20
+ }), "kapi-heading", f),
21
+ style: _ === void 0 && !v.style ? p : {
22
+ ..._ === void 0 ? {} : { "--kapi-text-lines": _ },
23
+ ...v.style,
24
+ ...p
25
+ }
26
+ });
27
+ };
28
+ //#endregion
29
+ export { o as KapiTitle };
@@ -84,3 +84,10 @@ export type { KapiTruncateProps } from "./KapiTruncate.js";
84
84
  export {
85
85
  /** @deprecated Interno; usa `KapiTruncate` en su lugar. Se quita en 1.0. */
86
86
  isTruncated } from "./truncateLogic.js";
87
+ export { KapiText } from "./KapiText.js";
88
+ export type { KapiTextElement, KapiTextProps } from "./KapiText.js";
89
+ export { KapiTitle } from "./KapiTitle.js";
90
+ export type { KapiTitleProps } from "./KapiTitle.js";
91
+ export { KapiAnchor } from "./KapiAnchor.js";
92
+ export type { KapiAnchorProps, KapiAnchorUnderline } from "./KapiAnchor.js";
93
+ export type { KapiTextAlign, KapiTextSize, KapiTextTone, KapiTextWeight, KapiTitleLevel } from "./textLogic.js";
@@ -0,0 +1,32 @@
1
+ import { type KapiToneName } from "../tone.js";
2
+ /** Escala tipográfica de la librería: cada valor es el token `--kapi-fs-<valor>`. */
3
+ export type KapiTextSize = "3xs" | "2xs" | "xs" | "sm" | "base" | "body" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl";
4
+ /** Color de un texto: cualquier `KapiTone` o una familia propia de la app. */
5
+ export type KapiTextTone = KapiToneName;
6
+ /** Peso de la letra: 400, 500, 600 y 700. */
7
+ export type KapiTextWeight = "regular" | "medium" | "semibold" | "bold";
8
+ /** Alineación del texto dentro de su caja. */
9
+ export type KapiTextAlign = "start" | "center" | "end" | "justify";
10
+ /** Nivel de un título (`h1` a `h6`). */
11
+ export type KapiTitleLevel = 1 | 2 | 3 | 4 | 5 | 6;
12
+ /** Tamaño visual que trae cada nivel de título si no se pide otro. */
13
+ export declare const TITLE_DEFAULT_SIZE: Record<KapiTitleLevel, KapiTextSize>;
14
+ type TextLook = {
15
+ size?: KapiTextSize | undefined;
16
+ tone?: KapiTextTone | undefined;
17
+ muted?: boolean | undefined;
18
+ weight?: KapiTextWeight | undefined;
19
+ align?: KapiTextAlign | undefined;
20
+ truncate?: boolean | number | undefined;
21
+ };
22
+ /**
23
+ * Cuántas líneas se muestran antes de cortar, sólo cuando son MÁS de una: una línea (`true` o `1`) se
24
+ * resuelve con `text-overflow` y no necesita la custom property.
25
+ */
26
+ export declare const truncateLines: (truncate: boolean | number | undefined) => number | undefined;
27
+ /**
28
+ * Clases de la familia de texto (`KapiText`, `KapiTitle`, `KapiAnchor`). Sin props, la base sola: el
29
+ * texto hereda tamaño, color y peso de donde esté. `tone` gana sobre `muted`.
30
+ */
31
+ export declare const textClasses: ({ size, tone, muted, weight, align, truncate }: TextLook) => string[];
32
+ export {};
@@ -0,0 +1,19 @@
1
+ import { isFamilyTone as e } from "../tone.js";
2
+ //#region src/components/display/textLogic.ts
3
+ var t = {
4
+ 1: "4xl",
5
+ 2: "3xl",
6
+ 3: "2xl",
7
+ 4: "xl",
8
+ 5: "lg",
9
+ 6: "md"
10
+ }, n = (e) => typeof e == "number" && e > 1 ? e : void 0, r = ({ size: t, tone: r, muted: i, weight: a, align: o, truncate: s }) => [
11
+ "kapi-text",
12
+ t !== void 0 && `kapi-text--${t}`,
13
+ r === void 0 ? i === !0 && "kapi-text--muted" : `kapi-text--tone-${e(r) ? "family" : r}`,
14
+ a !== void 0 && `kapi-text--w-${a}`,
15
+ o !== void 0 && `kapi-text--align-${o}`,
16
+ n(s) === void 0 ? s !== void 0 && s !== !1 && s !== 0 && "kapi-text--truncate" : "kapi-text--clamp"
17
+ ].filter((e) => typeof e == "string");
18
+ //#endregion
19
+ export { t as TITLE_DEFAULT_SIZE, r as textClasses, n as truncateLines };
@@ -1,6 +1,6 @@
1
1
  import type { HTMLAttributes, ReactNode, Ref } from "react";
2
2
  import type { KapiCloseReason } from "../closeReason.js";
3
- import { type KapiTone } from "../tone.js";
3
+ import { type KapiFamilyTone, type KapiTone } from "../tone.js";
4
4
  import type { KapiLabelsOverride } from "../labelsLogic.js";
5
5
  export type KapiAlertLabels = {
6
6
  /** Nombre accesible del botón de cierre (con `onClose`). */
@@ -15,8 +15,12 @@ export type KapiAlertVariant = KapiAlertTone;
15
15
  export type KapiAlertProps = Omit<HTMLAttributes<HTMLDivElement>, "title" | "role" | "children"> & {
16
16
  /** Ref al `<div>` raíz del aviso. */
17
17
  ref?: Ref<HTMLDivElement> | undefined;
18
- /** Rol semántico: define color, ícono y si se anuncia como `alert` o `status`. @default "info" */
19
- tone?: KapiAlertTone | undefined;
18
+ /**
19
+ * Rol semántico: define color, ícono y si se anuncia como `alert` o `status`. Una familia propia
20
+ * de la app (`toneFamilies`) pinta el color y usa el ícono y el anuncio de `info`.
21
+ * @default "info"
22
+ */
23
+ tone?: KapiAlertTone | KapiFamilyTone | undefined;
20
24
  /** Nombre anterior de `tone`, deprecado. @deprecated Usar `tone` (mismos valores). */
21
25
  variant?: KapiAlertTone | undefined;
22
26
  /** Título en negrita sobre el mensaje. */
@@ -49,4 +53,4 @@ export declare const alertRole: (tone: KapiAlertTone, override?: KapiAlertRole)
49
53
  * Banner inline (info / success / warning / danger) para formularios, modales y pantallas.
50
54
  * `danger` se anuncia como `role="alert"`; el resto como `role="status"` (ver `role`).
51
55
  */
52
- export declare const KapiAlert: ({ tone: toneProp, variant, title, children, action, icon, onClose, labels, className, role, ...rest }: KapiAlertProps) => import("react").JSX.Element;
56
+ export declare const KapiAlert: ({ tone: toneProp, variant, title, children, action, icon, onClose, labels, className, role, style, ...rest }: KapiAlertProps) => import("react").JSX.Element;
@@ -1,77 +1,82 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/feedback/feedback.css";
3
- import { joinClasses as e } from "../rootProps.js";
4
- import { resolveTone as t } from "../tone.js";
5
- import { KapiButton as n } from "../inputs/KapiButton.js";
6
- import { useLabels as r } from "../locale/KapiLocaleProvider.js";
3
+ import { useToneLook as e } from "../../hooks/useToneFamilies.js";
4
+ import { joinClasses as t } from "../rootProps.js";
5
+ import { resolveTone as n } from "../tone.js";
6
+ import { KapiButton as r } from "../inputs/KapiButton.js";
7
+ import { useLabels as i } from "../locale/KapiLocaleProvider.js";
7
8
  /* empty css */
8
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
9
- import { AlertTriangle as o, CheckCircle2 as s, Info as c, X as l, XCircle as u } from "lucide-react";
9
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
10
+ import { AlertTriangle as s, CheckCircle2 as c, Info as l, X as u, XCircle as d } from "lucide-react";
10
11
  //#region src/components/feedback/KapiAlert.tsx
11
- var d = { close: "Cerrar aviso" }, f = (e, t) => {
12
+ var f = { close: "Cerrar aviso" }, p = (e, t) => {
12
13
  let n = t ?? (e === "danger" ? "alert" : "status");
13
14
  return n === "none" ? void 0 : n;
14
- }, p = {
15
+ }, m = {
15
16
  info: {
16
- Icon: c,
17
+ Icon: l,
17
18
  color: "var(--kapi-info)"
18
19
  },
19
20
  success: {
20
- Icon: s,
21
+ Icon: c,
21
22
  color: "var(--kapi-success)"
22
23
  },
23
24
  warning: {
24
- Icon: o,
25
+ Icon: s,
25
26
  color: "var(--kapi-warning)"
26
27
  },
27
28
  danger: {
28
- Icon: u,
29
+ Icon: d,
29
30
  color: "var(--kapi-danger)"
30
31
  }
31
- }, m = ({ tone: o, variant: s, title: c, children: u, action: m, icon: h, onClose: g, labels: _, className: v, role: y, ...b }) => {
32
- let x = r("alert", d, _), S = t(o, s, "info"), C = S in p ? S : "info", { Icon: w, color: T } = p[C];
33
- return /* @__PURE__ */ a("div", {
34
- ...b,
35
- className: e("kapi-alert", `kapi-alert--${C}`, v),
36
- role: f(C, y),
32
+ }, h = ({ tone: s, variant: c, title: l, children: d, action: h, icon: g, onClose: _, labels: v, className: y, role: b, style: x, ...S }) => {
33
+ let C = i("alert", f, v), w = e("KapiAlert", s), T = n(w.tone, c, "info"), E = T in m ? T : "info", { Icon: D } = m[E], O = w.style ? "var(--kapi-tone)" : m[E].color;
34
+ return /* @__PURE__ */ o("div", {
35
+ ...S,
36
+ style: w.style ? {
37
+ ...w.style,
38
+ ...x
39
+ } : x,
40
+ className: t("kapi-alert", w.style ? "kapi-alert--family" : `kapi-alert--${E}`, y),
41
+ role: p(E, b),
37
42
  children: [
38
- h === void 0 ? /* @__PURE__ */ i(w, {
43
+ g === void 0 ? /* @__PURE__ */ a(D, {
39
44
  className: "kapi-alert__ico",
40
45
  size: 19,
41
46
  strokeWidth: 2,
42
- color: T
43
- }) : h === !1 || h === null ? null : /* @__PURE__ */ i("span", {
47
+ color: O
48
+ }) : g === !1 || g === null ? null : /* @__PURE__ */ a("span", {
44
49
  className: "kapi-alert__ico kapi-alert__ico--custom",
45
- style: { color: T },
50
+ style: { color: O },
46
51
  "aria-hidden": "true",
47
- children: h
52
+ children: g
48
53
  }),
49
- /* @__PURE__ */ a("div", {
54
+ /* @__PURE__ */ o("div", {
50
55
  className: "kapi-alert__body",
51
- children: [c && /* @__PURE__ */ i("div", {
56
+ children: [l && /* @__PURE__ */ a("div", {
52
57
  className: "kapi-alert__title",
53
- children: c
54
- }), u && /* @__PURE__ */ i("div", {
58
+ children: l
59
+ }), d && /* @__PURE__ */ a("div", {
55
60
  className: "kapi-alert__msg",
56
- children: u
61
+ children: d
57
62
  })]
58
63
  }),
59
- m,
60
- g && /* @__PURE__ */ i(n, {
64
+ h,
65
+ _ && /* @__PURE__ */ a(r, {
61
66
  className: "kapi-alert__close",
62
67
  variant: "ghost",
63
68
  size: "sm",
64
69
  iconOnly: !0,
65
- icon: /* @__PURE__ */ i(l, {
70
+ icon: /* @__PURE__ */ a(u, {
66
71
  size: 16,
67
72
  strokeWidth: 2.2,
68
73
  "aria-hidden": "true"
69
74
  }),
70
- "aria-label": x.close,
71
- onClick: () => g?.("close-button")
75
+ "aria-label": C.close,
76
+ onClick: () => _?.("close-button")
72
77
  })
73
78
  ]
74
79
  });
75
80
  };
76
81
  //#endregion
77
- export { d as DEFAULT_ALERT_LABELS, m as KapiAlert, f as alertRole };
82
+ export { f as DEFAULT_ALERT_LABELS, h as KapiAlert, p as alertRole };