@kapiuara/ui 0.17.0 → 0.19.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 (94) hide show
  1. package/README.md +259 -9
  2. package/dist/components/data/KapiDataTable.d.ts +12 -2
  3. package/dist/components/data/KapiDataTable.js +78 -76
  4. package/dist/components/data/KapiScatterChart.d.ts +56 -0
  5. package/dist/components/data/KapiScatterChart.js +90 -0
  6. package/dist/components/data/KapiTable.d.ts +2 -2
  7. package/dist/components/data/KapiTable.js +229 -227
  8. package/dist/components/data/chartFrame.d.ts +20 -2
  9. package/dist/components/data/chartFrame.js +33 -24
  10. package/dist/components/data/index.d.ts +5 -1
  11. package/dist/components/data/scatterLogic.d.ts +56 -0
  12. package/dist/components/data/scatterLogic.js +43 -0
  13. package/dist/components/data/tableTypes.d.ts +37 -0
  14. package/dist/components/data/useRowKeyWarning.d.ts +9 -3
  15. package/dist/components/data/useRowKeyWarning.js +7 -7
  16. package/dist/components/data/useTableSelection.d.ts +3 -2
  17. package/dist/components/data/useTableSelection.js +3 -3
  18. package/dist/components/display/KapiAvatarGroup.d.ts +14 -2
  19. package/dist/components/display/KapiAvatarGroup.js +25 -23
  20. package/dist/components/display/KapiTimeline.d.ts +14 -0
  21. package/dist/components/display/KapiTimeline.js +28 -21
  22. package/dist/components/display/avatarGroupSlots.d.ts +6 -0
  23. package/dist/components/display/avatarGroupSlots.js +9 -0
  24. package/dist/components/display/index.d.ts +1 -1
  25. package/dist/components/feedback/KapiAlert.d.ts +6 -1
  26. package/dist/components/feedback/KapiAlert.js +45 -44
  27. package/dist/components/feedback/KapiCountdown.d.ts +12 -1
  28. package/dist/components/feedback/KapiCountdown.js +34 -31
  29. package/dist/components/feedback/KapiEmpty.d.ts +6 -1
  30. package/dist/components/feedback/KapiEmpty.js +20 -18
  31. package/dist/components/feedback/KapiProgress.js +1 -1
  32. package/dist/components/feedback/KapiSpinner.d.ts +48 -0
  33. package/dist/components/feedback/KapiSpinner.js +27 -0
  34. package/dist/components/feedback/KapiToastContainer.js +1 -1
  35. package/dist/components/feedback/KapiTour.js +1 -1
  36. package/dist/components/feedback/alertSlots.d.ts +9 -0
  37. package/dist/components/feedback/alertSlots.js +12 -0
  38. package/dist/components/feedback/countdownSlots.d.ts +6 -0
  39. package/dist/components/feedback/countdownSlots.js +9 -0
  40. package/dist/components/feedback/emptySlots.d.ts +8 -0
  41. package/dist/components/feedback/emptySlots.js +11 -0
  42. package/dist/components/feedback/index.d.ts +5 -3
  43. package/dist/components/inputs/KapiFileUpload.d.ts +14 -1
  44. package/dist/components/inputs/KapiFileUpload.js +80 -67
  45. package/dist/components/inputs/formBridgeLogic.d.ts +104 -0
  46. package/dist/components/inputs/formBridgeLogic.js +25 -0
  47. package/dist/components/inputs/index.d.ts +2 -0
  48. package/dist/components/locale/labelRegistry.d.ts +8 -0
  49. package/dist/components/navigation/KapiSteps.d.ts +26 -5
  50. package/dist/components/navigation/KapiSteps.js +55 -43
  51. package/dist/components/overlays/KapiImageViewer.d.ts +63 -0
  52. package/dist/components/overlays/KapiImageViewer.js +106 -0
  53. package/dist/components/overlays/KapiShortcutsHelp.d.ts +53 -0
  54. package/dist/components/overlays/KapiShortcutsHelp.js +55 -0
  55. package/dist/components/overlays/KapiTooltip.d.ts +49 -10
  56. package/dist/components/overlays/KapiTooltip.js +110 -58
  57. package/dist/components/overlays/KapiViewport.d.ts +63 -0
  58. package/dist/components/overlays/KapiViewport.js +195 -0
  59. package/dist/components/overlays/index.d.ts +8 -0
  60. package/dist/components/overlays/shortcutsHelpSlots.d.ts +9 -0
  61. package/dist/components/overlays/shortcutsHelpSlots.js +12 -0
  62. package/dist/components/overlays/viewportLogic.d.ts +73 -0
  63. package/dist/components/overlays/viewportLogic.js +54 -0
  64. package/dist/components/slotCatalog.d.ts +33 -0
  65. package/dist/components/slotCatalog.js +30 -20
  66. package/dist/css/base.css +1 -1
  67. package/dist/css/components/data/KapiScatterChart.css +1 -0
  68. package/dist/css/components/display/display.css +1 -1
  69. package/dist/css/components/inputs/KapiFileUpload.css +1 -1
  70. package/dist/css/components/navigation/KapiSteps.css +1 -1
  71. package/dist/css/components/overlays/KapiViewport.css +1 -0
  72. package/dist/css/components/overlays/overlays.css +1 -1
  73. package/dist/hooks/elementSizeLogic.d.ts +15 -0
  74. package/dist/hooks/elementSizeLogic.js +7 -0
  75. package/dist/hooks/hotkeyLogic.d.ts +9 -0
  76. package/dist/hooks/hotkeyLogic.js +16 -15
  77. package/dist/hooks/hotkeyRegistry.d.ts +44 -0
  78. package/dist/hooks/hotkeyRegistry.js +32 -0
  79. package/dist/hooks/index.d.ts +10 -0
  80. package/dist/hooks/themeDeriveLogic.js +2 -2
  81. package/dist/hooks/useDebouncedValue.d.ts +30 -0
  82. package/dist/hooks/useDebouncedValue.js +26 -0
  83. package/dist/hooks/useDisclosure.d.ts +39 -0
  84. package/dist/hooks/useDisclosure.js +35 -0
  85. package/dist/hooks/useElementSize.d.ts +27 -0
  86. package/dist/hooks/useElementSize.js +29 -0
  87. package/dist/hooks/useHotkey.d.ts +8 -0
  88. package/dist/hooks/useHotkey.js +27 -15
  89. package/dist/index.js +201 -188
  90. package/dist/kapi.css +1 -1
  91. package/dist/kapi.layered.css +1 -1
  92. package/dist/logic.d.ts +4 -0
  93. package/dist/logic.js +33 -29
  94. package/package.json +2 -2
@@ -0,0 +1,56 @@
1
+ import type { HTMLAttributes, ReactNode, Ref } from "react";
2
+ import { type KapiChartUnit, type KapiChartView } from "./chartFrame.js";
3
+ import type { KapiLabelsOverride } from "../labelsLogic.js";
4
+ import type { KapiChartLabels } from "./chartFrame.js";
5
+ import { type KapiScatterPoint } from "./scatterLogic.js";
6
+ export type { KapiScatterPoint };
7
+ /** Una serie de puntos: su nombre para la leyenda y sus pares (x, y). */
8
+ export type KapiScatterSeries = {
9
+ /** Id estable; clave de React y de la fila de la tabla. */
10
+ id: string;
11
+ /** Nombre en la leyenda y en la tabla. */
12
+ label: string;
13
+ /** Los puntos de la serie. */
14
+ points: readonly KapiScatterPoint[];
15
+ };
16
+ /** Atributos nativos (`id`, `style`, `data-*`…) van a la raíz. */
17
+ export type KapiScatterChartProps = Omit<HTMLAttributes<HTMLDivElement>, "title"> & {
18
+ /** Ref al `<div>` raíz. */
19
+ ref?: Ref<HTMLDivElement> | undefined;
20
+ /** Series de puntos. Más de los slots de la paleta se recortan, como en el resto de los gráficos. */
21
+ series: readonly KapiScatterSeries[];
22
+ /** Título visible; sin él hace falta `aria-label` en la raíz. */
23
+ title?: ReactNode;
24
+ /** Nombre del eje horizontal (encabezado de columna en la tabla). @default "X" */
25
+ xLabel?: string | undefined;
26
+ /** Nombre del eje vertical (encabezado de columna en la tabla). @default "Y" */
27
+ yLabel?: string | undefined;
28
+ /** Marcas como mucho en cada eje. @default 4 */
29
+ tickCount?: number | undefined;
30
+ /** Unidad del eje horizontal, aplicada a sus marcas y a su columna de la tabla. */
31
+ xUnit?: KapiChartUnit | undefined;
32
+ /** Unidad del eje vertical. */
33
+ yUnit?: KapiChartUnit | undefined;
34
+ /** Vista mostrada (gráfico o tabla). */
35
+ view?: KapiChartView | undefined;
36
+ /** Vista inicial. @default "chart" */
37
+ defaultView?: KapiChartView | undefined;
38
+ /** Avisa el cambio de vista. */
39
+ onViewChange?: ((view: KapiChartView) => void) | undefined;
40
+ /** Textos fijos del marco (leyenda, tabla, vacío). */
41
+ labels?: KapiLabelsOverride<KapiChartLabels> | undefined;
42
+ };
43
+ /**
44
+ * Gráfico de dispersión: una nube de puntos con **dos ejes numéricos**.
45
+ *
46
+ * Es una forma nueva y no una prop de otra, y el motivo es el dato: todas las demás formas del
47
+ * sistema llevan un eje categórico (`categories: readonly string[]`) y una serie de valores contra
48
+ * él. Acá cada punto tiene dos números y no hay categorías, así que ni el eje ni la tabla del resto
49
+ * sirven tal cual (por eso el marco acepta `tableRows`).
50
+ *
51
+ * Los puntos son HTML posicionado en porcentajes, no círculos de un SVG estirado: dentro de un
52
+ * `viewBox` con `preserveAspectRatio="none"` un círculo sale ovalado.
53
+ *
54
+ * Igual que las barras y las líneas: la vista de tabla no es opcional y el plot es `role="img"`.
55
+ */
56
+ export declare function KapiScatterChart({ series, title, xLabel, yLabel, tickCount, xUnit, yUnit, view, defaultView, onViewChange, labels, className, ref, ...rest }: KapiScatterChartProps): import("react").JSX.Element;
@@ -0,0 +1,90 @@
1
+ "use client";
2
+ import "#kapi-css/components/data/KapiScatterChart.css";
3
+ import { useKapiFormatLocale as e } from "../locale/KapiLocaleProvider.js";
4
+ import { formatDataValue as t } from "../../hooks/numberFormatLogic.js";
5
+ import { KapiTooltip as n } from "../overlays/KapiTooltip.js";
6
+ import { KapiChartFrame as r, chartSummary as i, chartVars as a, useChartLabels as o, useChartTitleId as s, useChartView as c, withChartUnit as l } from "./chartFrame.js";
7
+ import { scatterAxis as u, scatterInside as d, scatterPosition as f, scatterTickLabel as p } from "./scatterLogic.js";
8
+ /* empty css */
9
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
10
+ //#region src/components/data/KapiScatterChart.tsx
11
+ function g({ series: g, title: _, xLabel: v = "X", yLabel: y = "Y", tickCount: b = 4, xUnit: x, yUnit: S, view: C, defaultView: w = "chart", onViewChange: T, labels: E, className: D, ref: O, ...k }) {
12
+ let A = e(), j = o(E), M = s(), { current: N, setView: P } = c(C, w, T), F = g.slice(0, 8);
13
+ g.length > 8 && process.env.NODE_ENV !== "production" && console.warn(`KapiScatterChart: ${g.length} series y la paleta tiene 8 slots. Se dibujan las primeras 8; agrupá el resto en vez de perderlo.`);
14
+ let I = F.flatMap((e) => e.points), L = u(I.map((e) => e.x), b), R = u(I.map((e) => e.y), b), z = (e, n) => l(t(e, A), n), B = F.flatMap((e, t) => e.points.map((n, r) => ({
15
+ id: `${e.id}-${r}`,
16
+ slot: t,
17
+ header: n.label ?? `${e.label} ${r + 1}`,
18
+ cells: [z(n.x, x), z(n.y, S)]
19
+ }))), V = i(j.kindLine, j, F.length, I.length);
20
+ return /* @__PURE__ */ m("div", {
21
+ ...k,
22
+ ref: O,
23
+ className: ["kapi-scatterchart", D].filter(Boolean).join(" "),
24
+ role: "group",
25
+ ..._ ? { "aria-labelledby": M } : {},
26
+ children: /* @__PURE__ */ m(r, {
27
+ title: _,
28
+ titleId: M,
29
+ series: F,
30
+ categories: [v, y],
31
+ valueAt: () => 0,
32
+ tableRows: B,
33
+ view: N,
34
+ onViewChange: P,
35
+ text: j,
36
+ block: "kapi-scatterchart",
37
+ children: /* @__PURE__ */ h("div", {
38
+ className: "kapi-scatterchart__plot",
39
+ role: "img",
40
+ "aria-label": V,
41
+ dir: "ltr",
42
+ children: [
43
+ /* @__PURE__ */ m("div", {
44
+ className: "kapi-scatterchart__axisy",
45
+ children: R.ticks.map((e) => /* @__PURE__ */ m("div", {
46
+ className: "kapi-scatterchart__ticky",
47
+ style: a({ y: (e - R.min) / (R.max - R.min || 1) * 100 }),
48
+ children: /* @__PURE__ */ m("span", {
49
+ className: "kapi-scatterchart__ticklabel",
50
+ children: l(p(e), S)
51
+ })
52
+ }, e))
53
+ }),
54
+ /* @__PURE__ */ m("div", {
55
+ className: "kapi-scatterchart__canvas",
56
+ children: F.map((e, t) => e.points.map((e, t) => ({
57
+ p: e,
58
+ i: t
59
+ })).filter(({ p: e }) => d(e, L, R)).map(({ p: r, i }) => {
60
+ let { cx: o, cy: s } = f(r, L, R);
61
+ return /* @__PURE__ */ m(n, {
62
+ label: `${r.label ?? e.label} · ${v} ${z(r.x, x)} · ${y} ${z(r.y, S)}`,
63
+ className: "kapi-scatterchart__dotwrap",
64
+ style: a({
65
+ slot: t,
66
+ x: o,
67
+ y: 100 - s
68
+ }),
69
+ children: /* @__PURE__ */ m("span", { className: "kapi-scatterchart__dot" })
70
+ }, `${e.id}-${i}`);
71
+ }))
72
+ }),
73
+ /* @__PURE__ */ m("div", {
74
+ className: "kapi-scatterchart__axisx",
75
+ children: L.ticks.map((e) => /* @__PURE__ */ m("div", {
76
+ className: "kapi-scatterchart__tickx",
77
+ style: a({ x: (e - L.min) / (L.max - L.min || 1) * 100 }),
78
+ children: /* @__PURE__ */ m("span", {
79
+ className: "kapi-scatterchart__ticklabel",
80
+ children: l(p(e), x)
81
+ })
82
+ }, e))
83
+ })
84
+ ]
85
+ })
86
+ })
87
+ });
88
+ }
89
+ //#endregion
90
+ export { g as KapiScatterChart };
@@ -1,6 +1,6 @@
1
1
  import type { KapiTableKeyField, KapiTableProps } from "./tableTypes.js";
2
2
  export { DEFAULT_TABLE_LABELS } from "./tableLabels.js";
3
- export type { KapiTableCellValue, KapiTableClassNames, KapiTableColumn, KapiTableContext, KapiTableActionHandler, KapiTableActionItem, KapiTableAction, KapiTableCsvOptions, KapiTableSelectionPreset, KapiTableDataset, KapiTableFooterCell, KapiTableFooterRow, KapiTablePagination, KapiTableClientPagination, KapiTableKey, KapiTableKeyField, KapiTableProps, KapiTableRowHooks } from "./tableTypes.js";
3
+ export type { KapiTableCellValue, KapiTableClassNames, KapiTableColumn, KapiTableContext, KapiTableActionHandler, KapiTableActionItem, KapiTableAction, KapiTableCsvOptions, KapiTableSelectionPreset, KapiTableDataset, KapiTableFooterCell, KapiTableFooterRow, KapiTablePagination, KapiTableClientPagination, KapiTableGetRowKey, KapiTableKey, KapiTableKeyField, KapiTableProps, KapiTableRowHooks } from "./tableTypes.js";
4
4
  export type { KapiTableRowAttributes } from "./rowClickLogic.js";
5
5
  export type { KapiTableLabels } from "./tableLabels.js";
6
6
  export type { KapiTableSortDirection, KapiTableSortState, KapiTableSortValue, KapiTableFilterState } from "./tableLogic.js";
@@ -9,4 +9,4 @@ export type { KapiTableSortDirection, KapiTableSortState, KapiTableSortValue, Ka
9
9
  * por header, columna de acciones fija, copiar por celda, virtualización de altura fija,
10
10
  * drag-scroll con click derecho y menú contextual con doble click derecho.
11
11
  */
12
- export declare function KapiTable<T, K extends KapiTableKeyField<T> = KapiTableKeyField<T>>({ columns: columnsProp, rows, keyField, maxHeight, fill, footer, bulkActionsPlacement, className, classNames, style, id, ref: shellRef, labels, actions, rowMenu, contextMenu, onCopy, selectable, rowSelect, rowLabel, selectedIds, defaultSelectedIds, onSelectedIdsChange, bulkActions, rangeSelect, selectionPresets, virtual, rowHeight, estimatedRowHeight, sort, defaultSort, onSortChange, manualSort, pagination, dataset, loading, loadingRows, card, emptyMessage, loadingMessage, isRowSelectable, renderSubComponent, expandedIds, defaultExpandedIds, onExpandedIdsChange, density, rowHover, columnToggle, columnVisibility, defaultColumnVisibility, onColumnVisibilityChange, columnPinning, pinnedColumns, defaultPinnedColumns, onPinnedColumnsChange, headerMenu, resizableColumns, columnWidths, defaultColumnWidths, onColumnWidthsChange, filterable, filter, defaultFilter, onFilterChange, manualFilter, filterDebounce, exportCsv, toolbar, toolbarActions, onRefresh, mobileCards, onRowClick, getRowProps }: KapiTableProps<T, K>): import("react").JSX.Element;
12
+ export declare function KapiTable<T, K extends KapiTableKeyField<T> = KapiTableKeyField<T>>({ columns: columnsProp, rows, keyField, getRowKey, maxHeight, fill, footer, bulkActionsPlacement, className, classNames, style, id, ref: shellRef, labels, actions, rowMenu, contextMenu, onCopy, selectable, rowSelect, rowLabel, selectedIds, defaultSelectedIds, onSelectedIdsChange, bulkActions, rangeSelect, selectionPresets, virtual, rowHeight, estimatedRowHeight, sort, defaultSort, onSortChange, manualSort, pagination, dataset, loading, loadingRows, card, emptyMessage, loadingMessage, isRowSelectable, renderSubComponent, expandedIds, defaultExpandedIds, onExpandedIdsChange, density, rowHover, columnToggle, columnVisibility, defaultColumnVisibility, onColumnVisibilityChange, columnPinning, pinnedColumns, defaultPinnedColumns, onPinnedColumnsChange, headerMenu, resizableColumns, columnWidths, defaultColumnWidths, onColumnWidthsChange, filterable, filter, defaultFilter, onFilterChange, manualFilter, filterDebounce, exportCsv, toolbar, toolbarActions, onRefresh, mobileCards, onRowClick, getRowProps }: KapiTableProps<T, K>): import("react").JSX.Element;