@kapiuara/ui 0.16.0 → 0.18.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/README.md +430 -20
- package/dist/components/chat/KapiChatThread.js +4 -4
- package/dist/components/chat/KapiComposer.js +8 -8
- package/dist/components/data/KapiDataTable.js +4 -4
- package/dist/components/data/KapiScatterChart.d.ts +56 -0
- package/dist/components/data/KapiScatterChart.js +90 -0
- package/dist/components/data/KapiSparkline.d.ts +2 -1
- package/dist/components/data/KapiSparkline.js +29 -26
- package/dist/components/data/KapiTableFilter.js +6 -6
- package/dist/components/data/chartFrame.d.ts +20 -2
- package/dist/components/data/chartFrame.js +33 -24
- package/dist/components/data/index.d.ts +4 -0
- package/dist/components/data/scatterLogic.d.ts +56 -0
- package/dist/components/data/scatterLogic.js +43 -0
- package/dist/components/data/tableCells.d.ts +12 -1
- package/dist/components/data/tableCells.js +49 -51
- package/dist/components/data/useTableSelection.js +3 -3
- package/dist/components/display/KapiAnnotation.js +68 -63
- package/dist/components/display/KapiAvatar.d.ts +6 -4
- package/dist/components/display/KapiAvatar.js +33 -28
- package/dist/components/display/KapiAvatarGroup.d.ts +14 -2
- package/dist/components/display/KapiAvatarGroup.js +25 -23
- package/dist/components/display/KapiCodeBlock.d.ts +48 -0
- package/dist/components/display/KapiCodeBlock.js +44 -0
- package/dist/components/display/KapiCommentComposer.js +6 -6
- package/dist/components/display/KapiDiff.d.ts +62 -0
- package/dist/components/display/KapiDiff.js +118 -0
- package/dist/components/display/KapiHighlight.d.ts +27 -0
- package/dist/components/display/KapiHighlight.js +21 -0
- package/dist/components/display/KapiIconTile.d.ts +2 -1
- package/dist/components/display/KapiIconTile.js +23 -21
- package/dist/components/display/KapiStat.d.ts +3 -2
- package/dist/components/display/KapiStat.js +32 -26
- package/dist/components/display/KapiTag.d.ts +4 -3
- package/dist/components/display/KapiTag.js +29 -24
- package/dist/components/display/KapiTimeline.d.ts +19 -2
- package/dist/components/display/KapiTimeline.js +38 -23
- package/dist/components/display/annotationLogic.d.ts +2 -1
- package/dist/components/display/annotationLogic.js +7 -6
- package/dist/components/display/avatarGroupSlots.d.ts +6 -0
- package/dist/components/display/avatarGroupSlots.js +9 -0
- package/dist/components/display/codeBlockSlots.d.ts +10 -0
- package/dist/components/display/codeBlockSlots.js +13 -0
- package/dist/components/display/diffLogic.d.ts +58 -0
- package/dist/components/display/diffLogic.js +96 -0
- package/dist/components/display/diffSlots.d.ts +14 -0
- package/dist/components/display/diffSlots.js +17 -0
- package/dist/components/display/highlightLogic.d.ts +18 -0
- package/dist/components/display/highlightLogic.js +26 -0
- package/dist/components/display/highlightSlots.d.ts +5 -0
- package/dist/components/display/highlightSlots.js +8 -0
- package/dist/components/display/iconTileLogic.d.ts +2 -2
- package/dist/components/display/iconTileLogic.js +7 -6
- package/dist/components/display/index.d.ts +9 -1
- package/dist/components/display/statLogic.d.ts +2 -1
- package/dist/components/display/statLogic.js +7 -6
- package/dist/components/display/tagLogic.d.ts +2 -1
- package/dist/components/display/tagLogic.js +7 -6
- package/dist/components/display/timelineLogic.d.ts +20 -2
- package/dist/components/display/timelineLogic.js +10 -2
- package/dist/components/feedback/KapiAlert.d.ts +6 -1
- package/dist/components/feedback/KapiAlert.js +45 -44
- package/dist/components/feedback/KapiCountdown.d.ts +12 -1
- package/dist/components/feedback/KapiCountdown.js +34 -31
- package/dist/components/feedback/KapiEmpty.d.ts +6 -1
- package/dist/components/feedback/KapiEmpty.js +20 -18
- package/dist/components/feedback/KapiFab.js +108 -108
- package/dist/components/feedback/KapiProgress.js +63 -54
- package/dist/components/feedback/KapiSpinner.d.ts +48 -0
- package/dist/components/feedback/KapiSpinner.js +27 -0
- package/dist/components/feedback/KapiToastContainer.js +10 -10
- package/dist/components/feedback/KapiTour.js +13 -13
- package/dist/components/feedback/alertSlots.d.ts +9 -0
- package/dist/components/feedback/alertSlots.js +12 -0
- package/dist/components/feedback/countdownSlots.d.ts +6 -0
- package/dist/components/feedback/countdownSlots.js +9 -0
- package/dist/components/feedback/emptySlots.d.ts +8 -0
- package/dist/components/feedback/emptySlots.js +11 -0
- package/dist/components/feedback/index.d.ts +5 -3
- package/dist/components/feedback/progressLogic.d.ts +2 -1
- package/dist/components/feedback/progressLogic.js +9 -8
- package/dist/components/inputs/KapiAutocomplete.d.ts +6 -0
- package/dist/components/inputs/KapiAutocomplete.js +86 -85
- package/dist/components/inputs/KapiChecklist.d.ts +7 -1
- package/dist/components/inputs/KapiChecklist.js +53 -52
- package/dist/components/inputs/KapiCopyButton.d.ts +40 -0
- package/dist/components/inputs/KapiCopyButton.js +35 -0
- package/dist/components/inputs/KapiDatePicker.d.ts +7 -1
- package/dist/components/inputs/KapiDatePicker.js +118 -116
- package/dist/components/inputs/KapiDateRangePicker.d.ts +7 -1
- package/dist/components/inputs/KapiDateRangePicker.js +136 -135
- package/dist/components/inputs/KapiFacetedSearch.js +5 -5
- package/dist/components/inputs/KapiField.d.ts +9 -1
- package/dist/components/inputs/KapiField.js +43 -42
- package/dist/components/inputs/KapiFileUpload.d.ts +14 -1
- package/dist/components/inputs/KapiFileUpload.js +83 -70
- package/dist/components/inputs/KapiInput.d.ts +29 -1
- package/dist/components/inputs/KapiInput.js +74 -51
- package/dist/components/inputs/KapiMaskedInput.js +26 -26
- package/dist/components/inputs/KapiNumberStepper.d.ts +7 -1
- package/dist/components/inputs/KapiNumberStepper.js +24 -23
- package/dist/components/inputs/KapiPinInput.d.ts +72 -0
- package/dist/components/inputs/KapiPinInput.js +75 -0
- package/dist/components/inputs/KapiPropsForm.d.ts +34 -0
- package/dist/components/inputs/KapiPropsForm.js +78 -0
- package/dist/components/inputs/KapiRating.d.ts +7 -1
- package/dist/components/inputs/KapiRating.js +39 -38
- package/dist/components/inputs/KapiSearchChip.js +5 -5
- package/dist/components/inputs/KapiSegmented.d.ts +13 -5
- package/dist/components/inputs/KapiSegmented.js +81 -77
- package/dist/components/inputs/KapiSelect.d.ts +9 -1
- package/dist/components/inputs/KapiSelect.js +236 -233
- package/dist/components/inputs/KapiSlider.d.ts +10 -3
- package/dist/components/inputs/KapiSlider.js +67 -63
- package/dist/components/inputs/KapiTagInput.d.ts +7 -1
- package/dist/components/inputs/KapiTagInput.js +70 -69
- package/dist/components/inputs/KapiTextarea.d.ts +7 -1
- package/dist/components/inputs/KapiTextarea.js +51 -50
- package/dist/components/inputs/copyLogic.d.ts +1 -0
- package/dist/components/inputs/copyLogic.js +12 -0
- package/dist/components/inputs/fieldLogic.d.ts +23 -3
- package/dist/components/inputs/fieldLogic.js +18 -11
- package/dist/components/inputs/formBridgeLogic.d.ts +104 -0
- package/dist/components/inputs/formBridgeLogic.js +25 -0
- package/dist/components/inputs/index.d.ts +10 -0
- package/dist/components/inputs/inputLogic.d.ts +16 -1
- package/dist/components/inputs/inputLogic.js +3 -3
- package/dist/components/inputs/ownField.d.ts +3 -1
- package/dist/components/inputs/ownField.js +28 -27
- package/dist/components/inputs/pinInputLogic.d.ts +34 -0
- package/dist/components/inputs/pinInputLogic.js +37 -0
- package/dist/components/inputs/propsFormLogic.d.ts +53 -0
- package/dist/components/inputs/propsFormLogic.js +11 -0
- package/dist/components/inputs/segmentedLogic.d.ts +7 -0
- package/dist/components/inputs/segmentedLogic.js +2 -2
- package/dist/components/layout/KapiAccessCard.d.ts +5 -1
- package/dist/components/layout/KapiAccessCard.js +43 -39
- package/dist/components/layout/KapiAccountMenu.js +7 -7
- package/dist/components/layout/KapiCollapse.d.ts +39 -0
- package/dist/components/layout/KapiCollapse.js +20 -0
- package/dist/components/layout/KapiContextSlot.js +4 -4
- package/dist/components/layout/KapiDivider.d.ts +11 -2
- package/dist/components/layout/KapiDivider.js +30 -24
- package/dist/components/layout/KapiGrid.js +2 -2
- package/dist/components/layout/KapiNotificationBell.js +10 -10
- package/dist/components/layout/KapiPageHeader.js +22 -22
- package/dist/components/layout/KapiRail.js +4 -4
- package/dist/components/layout/KapiRoot.d.ts +22 -2
- package/dist/components/layout/KapiRoot.js +33 -29
- package/dist/components/layout/KapiShell.d.ts +9 -1
- package/dist/components/layout/KapiShell.js +28 -27
- package/dist/components/layout/accessCardLogic.d.ts +8 -1
- package/dist/components/layout/accessCardLogic.js +11 -7
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/locale/labelRegistry.d.ts +18 -0
- package/dist/components/navigation/KapiAccordion.js +9 -9
- package/dist/components/navigation/KapiContextPanel.js +12 -12
- package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
- package/dist/components/navigation/KapiNavBadge.js +26 -22
- package/dist/components/navigation/KapiSteps.d.ts +26 -5
- package/dist/components/navigation/KapiSteps.js +55 -43
- package/dist/components/navigation/KapiTabs.js +9 -9
- package/dist/components/navigation/KapiToc.d.ts +48 -0
- package/dist/components/navigation/KapiToc.js +66 -0
- package/dist/components/navigation/KapiTree.js +10 -10
- package/dist/components/navigation/index.d.ts +3 -0
- package/dist/components/navigation/tocLogic.d.ts +35 -0
- package/dist/components/navigation/tocLogic.js +11 -0
- package/dist/components/navigation/tocSlots.d.ts +8 -0
- package/dist/components/navigation/tocSlots.js +11 -0
- package/dist/components/overlays/KapiCommandPalette.js +6 -6
- package/dist/components/overlays/KapiContextMenu.js +5 -5
- package/dist/components/overlays/KapiImageViewer.d.ts +63 -0
- package/dist/components/overlays/KapiImageViewer.js +106 -0
- package/dist/components/overlays/KapiMenuButton.js +7 -7
- package/dist/components/overlays/KapiModal.js +3 -3
- package/dist/components/overlays/KapiOffcanvas.js +24 -24
- package/dist/components/overlays/KapiPhotoView.js +10 -10
- package/dist/components/overlays/KapiPopover.js +6 -6
- package/dist/components/overlays/KapiShapeSheet.js +4 -4
- package/dist/components/overlays/KapiShortcutsHelp.d.ts +53 -0
- package/dist/components/overlays/KapiShortcutsHelp.js +55 -0
- package/dist/components/overlays/KapiTooltip.d.ts +49 -10
- package/dist/components/overlays/KapiTooltip.js +120 -68
- package/dist/components/overlays/KapiViewport.d.ts +63 -0
- package/dist/components/overlays/KapiViewport.js +195 -0
- package/dist/components/overlays/index.d.ts +8 -0
- package/dist/components/overlays/menuList.js +22 -22
- package/dist/components/overlays/shortcutsHelpSlots.d.ts +9 -0
- package/dist/components/overlays/shortcutsHelpSlots.js +12 -0
- package/dist/components/overlays/viewportLogic.d.ts +73 -0
- package/dist/components/overlays/viewportLogic.js +54 -0
- package/dist/components/slotCatalog.d.ts +66 -0
- package/dist/components/slotCatalog.js +30 -12
- package/dist/css/base.css +1 -1
- package/dist/css/components/data/KapiScatterChart.css +1 -0
- package/dist/css/components/display/KapiAnnotation.css +1 -1
- package/dist/css/components/display/KapiCodeBlock.css +1 -0
- package/dist/css/components/display/KapiDiff.css +1 -0
- package/dist/css/components/display/display.css +1 -1
- package/dist/css/components/feedback/feedback.css +1 -1
- package/dist/css/components/inputs/KapiFileUpload.css +1 -1
- package/dist/css/components/inputs/KapiPinInput.css +1 -0
- package/dist/css/components/inputs/KapiSelect.css +1 -1
- package/dist/css/components/inputs/inputsExtra.css +1 -1
- package/dist/css/components/layout/KapiAccessCard.css +1 -1
- package/dist/css/components/layout/KapiCollapse.css +1 -0
- package/dist/css/components/layout/KapiDivider.css +1 -1
- package/dist/css/components/navigation/KapiSteps.css +1 -1
- package/dist/css/components/navigation/KapiToc.css +1 -0
- package/dist/css/components/overlays/KapiViewport.css +1 -0
- package/dist/css/components/overlays/overlays.css +1 -1
- package/dist/hooks/asyncResourceLogic.d.ts +11 -0
- package/dist/hooks/asyncResourceLogic.js +4 -0
- package/dist/hooks/elementSizeLogic.d.ts +15 -0
- package/dist/hooks/elementSizeLogic.js +7 -0
- package/dist/hooks/hotkeyLogic.d.ts +9 -0
- package/dist/hooks/hotkeyLogic.js +16 -15
- package/dist/hooks/hotkeyRegistry.d.ts +44 -0
- package/dist/hooks/hotkeyRegistry.js +32 -0
- package/dist/hooks/index.d.ts +13 -0
- package/dist/hooks/toneFamilyLogic.d.ts +26 -2
- package/dist/hooks/toneFamilyLogic.js +19 -6
- package/dist/hooks/useAsyncResource.d.ts +45 -0
- package/dist/hooks/useAsyncResource.js +24 -0
- package/dist/hooks/useDebouncedValue.d.ts +30 -0
- package/dist/hooks/useDebouncedValue.js +26 -0
- package/dist/hooks/useDisclosure.d.ts +39 -0
- package/dist/hooks/useDisclosure.js +35 -0
- package/dist/hooks/useElementSize.d.ts +27 -0
- package/dist/hooks/useElementSize.js +29 -0
- package/dist/hooks/useHotkey.d.ts +8 -0
- package/dist/hooks/useHotkey.js +27 -15
- package/dist/hooks/useKapiTheme.d.ts +8 -1
- package/dist/hooks/useKapiTheme.js +57 -57
- package/dist/hooks/useToneFamilies.d.ts +14 -4
- package/dist/hooks/useToneFamilies.js +27 -23
- package/dist/index.js +234 -207
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/logic.d.ts +45 -0
- package/dist/logic.js +46 -0
- package/package.json +13 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/chat/chat.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { useLabels as t } from "../locale/KapiLocaleProvider.js";
|
|
5
|
+
import { KapiIconButton as n } from "../inputs/KapiIconButton.js";
|
|
6
|
+
import { assignRef as r, joinIds as i } from "../inputs/fieldLogic.js";
|
|
7
|
+
import { useKapiField as a } from "../inputs/KapiField.js";
|
|
8
8
|
import { KapiTextarea as o } from "../inputs/KapiTextarea.js";
|
|
9
9
|
import { isSubmitShortcut as s } from "../display/commentLogic.js";
|
|
10
10
|
import { useSubmitDraft as c } from "../../hooks/useSubmitDraft.js";
|
|
@@ -19,7 +19,7 @@ var p = {
|
|
|
19
19
|
send: "Enviar",
|
|
20
20
|
shortcut: "Enter envía, Shift + Enter hace un salto de línea"
|
|
21
21
|
}, m = ({ value: m, defaultValue: h, onChange: g, onSubmit: _, submitOn: v = "enter", loading: y = !1, invalid: b, required: x, disabled: S, leading: C, trailing: w, maxRows: T = 6, rows: E = 1, className: D, style: O, labels: k, ref: A, placeholder: j, onKeyDown: M, "aria-label": N, "aria-labelledby": P, "aria-describedby": F, ...I }) => {
|
|
22
|
-
let L =
|
|
22
|
+
let L = t("composer", p, k), R = a(), z = l(), { text: B, setText: V, submit: H, busy: U, canSubmit: W, boxRef: G } = c({
|
|
23
23
|
value: m,
|
|
24
24
|
defaultValue: h,
|
|
25
25
|
onChange: g,
|
|
@@ -48,7 +48,7 @@ var p = {
|
|
|
48
48
|
/* @__PURE__ */ u(o, {
|
|
49
49
|
...I,
|
|
50
50
|
ref: (e) => {
|
|
51
|
-
G.current = e,
|
|
51
|
+
G.current = e, r(A, e);
|
|
52
52
|
},
|
|
53
53
|
className: "kapi-chatcomposer__input",
|
|
54
54
|
autosize: !0,
|
|
@@ -59,7 +59,7 @@ var p = {
|
|
|
59
59
|
placeholder: j ?? L.placeholder,
|
|
60
60
|
"aria-label": q ? N : L.label,
|
|
61
61
|
"aria-labelledby": P,
|
|
62
|
-
"aria-describedby":
|
|
62
|
+
"aria-describedby": i(F, z),
|
|
63
63
|
...x === void 0 ? {} : { required: x },
|
|
64
64
|
...b ? { invalid: !0 } : {},
|
|
65
65
|
onChange: (e) => V(e.target.value),
|
|
@@ -75,7 +75,7 @@ var p = {
|
|
|
75
75
|
children: w
|
|
76
76
|
})
|
|
77
77
|
]
|
|
78
|
-
}), /* @__PURE__ */ u(
|
|
78
|
+
}), /* @__PURE__ */ u(n, {
|
|
79
79
|
className: "kapi-chatcomposer__send",
|
|
80
80
|
icon: /* @__PURE__ */ u(f, {
|
|
81
81
|
size: 18,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import "#kapi-css/components/data/KapiTable.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
4
|
import { useKapiLocale as t, useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { winOf as r } from "../../hooks/ownerDocument.js";
|
|
6
|
+
import { useControllableState as i } from "../../hooks/useControllableState.js";
|
|
7
7
|
import { columnAlign as ee, computeStickyOffsets as te, computeStickyRightOffsets as ne, effectiveColumnWidth as re, firstRightStickyIndex as ie, lastStickyIndex as ae, nextSortState as oe, sortRowsByColumn as a, stickySideOf as o, tableWrapClass as s } from "./tableLogic.js";
|
|
8
8
|
import { KapiSkeleton as c } from "../feedback/KapiSkeleton.js";
|
|
9
9
|
/* empty css */
|
|
@@ -19,7 +19,7 @@ var x = {};
|
|
|
19
19
|
function S({ columns: S, rows: C, keyField: w = "id", ref: T, maxHeight: E = "58vh", fill: D = !1, card: O = !1, density: k = "default", rowHover: A = !1, mobileCards: j = !1, labels: M, sort: N, defaultSort: P = null, onSortChange: F, manualSort: I = !1, loading: L = !1, loadingRows: R = 5, loadingMessage: z, emptyMessage: B, onCopy: ge, actions: V, onRowClick: H, getRowProps: _e, className: ve, style: ye, id: be }) {
|
|
20
20
|
let U = n("table", l, M);
|
|
21
21
|
le("KapiDataTable", C, w);
|
|
22
|
-
let W = t(), [G, xe] =
|
|
22
|
+
let W = t(), [G, xe] = i(N, P, F), Se = (e) => xe(oe(G, e)), K = _(() => I ? C : a(C, S, G, W), [
|
|
23
23
|
I,
|
|
24
24
|
C,
|
|
25
25
|
S,
|
|
@@ -56,7 +56,7 @@ function S({ columns: S, rows: C, keyField: w = "id", ref: T, maxHeight: E = "58
|
|
|
56
56
|
className: "is-clickable",
|
|
57
57
|
tabIndex: 0,
|
|
58
58
|
onClick: (t) => {
|
|
59
|
-
pe(t.target, t.currentTarget,
|
|
59
|
+
pe(t.target, t.currentTarget, r(t.currentTarget)?.getSelection() ?? null) && H(e, t);
|
|
60
60
|
},
|
|
61
61
|
onKeyDown: (t) => {
|
|
62
62
|
let n = {
|
|
@@ -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,4 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributes, type Ref } from "react";
|
|
2
|
+
import { type KapiFamilyTone } from "../tone.js";
|
|
2
3
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
3
4
|
import { type KapiSparklineLabelParts } from "./sparklineLogic.js";
|
|
4
5
|
/** Textos del sparkline: sólo su nombre accesible. */
|
|
@@ -16,7 +17,7 @@ export type KapiSparklineProps = Omit<HTMLAttributes<HTMLSpanElement>, "children
|
|
|
16
17
|
* Usa un color de estado en vez de la paleta. Es para cuando la línea **significa** algo —una
|
|
17
18
|
* métrica que empeoró—, no para distinguirla de otra: para eso está `slot`.
|
|
18
19
|
*/
|
|
19
|
-
tone?: "success" | "warning" | "danger" | "info" | undefined;
|
|
20
|
+
tone?: "success" | "warning" | "danger" | "info" | KapiFamilyTone | undefined;
|
|
20
21
|
/** Rellena el área bajo la línea. @default false */
|
|
21
22
|
area?: boolean | undefined;
|
|
22
23
|
/** Marca el último punto, que es donde se lee «dónde quedó». @default true */
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/data/KapiSparkline.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { isFamilyTone as t } from "../tone.js";
|
|
5
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
6
|
+
import { formatDataValue as r } from "../../hooks/numberFormatLogic.js";
|
|
7
|
+
import { chartVars as i } from "./chartFrame.js";
|
|
8
|
+
import { areaPath as a, linePath as o, linePoints as s } from "./lineChartLogic.js";
|
|
9
|
+
import { sparklineLabel as c, sparklineMax as l } from "./sparklineLogic.js";
|
|
8
10
|
/* empty css */
|
|
9
11
|
import "react";
|
|
10
|
-
import { jsx as
|
|
12
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
13
|
//#region src/components/data/KapiSparkline.tsx
|
|
12
|
-
var
|
|
14
|
+
var f = {
|
|
13
15
|
trend: "Tendencia",
|
|
14
16
|
up: "sube",
|
|
15
17
|
down: "baja",
|
|
@@ -17,40 +19,41 @@ var u = {
|
|
|
17
19
|
from: "de",
|
|
18
20
|
to: "a"
|
|
19
21
|
};
|
|
20
|
-
function
|
|
21
|
-
let
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
...
|
|
24
|
-
ref:
|
|
25
|
-
className: ["kapi-sparkline",
|
|
22
|
+
function p({ values: p, slot: m = 1, tone: h, area: g = !1, last: _ = !0, labels: v, className: y, ref: b, ...x }) {
|
|
23
|
+
let S = n("sparkline", f, v), C = l(p), w = s(p, C), T = w[w.length - 1], E = i({ slot: Math.max(1, Math.floor(m)) - 1 }), D = e("KapiSparkline", h), O = t(h) ? "var(--kapi-tone)" : h ? `var(--kapi-${h})` : E["--kapi-chart-slot"];
|
|
24
|
+
return /* @__PURE__ */ d("span", {
|
|
25
|
+
...x,
|
|
26
|
+
ref: b,
|
|
27
|
+
className: ["kapi-sparkline", y].filter(Boolean).join(" "),
|
|
26
28
|
role: "img",
|
|
27
|
-
"aria-label":
|
|
29
|
+
"aria-label": x["aria-label"] ?? c(p, S, r),
|
|
28
30
|
style: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
...D.style,
|
|
32
|
+
"--kapi-chart-slot": O,
|
|
33
|
+
...x.style
|
|
31
34
|
},
|
|
32
|
-
children: [/* @__PURE__ */
|
|
35
|
+
children: [/* @__PURE__ */ d("svg", {
|
|
33
36
|
className: "kapi-sparkline__svg",
|
|
34
37
|
viewBox: "0 0 100 100",
|
|
35
38
|
preserveAspectRatio: "none",
|
|
36
39
|
"aria-hidden": "true",
|
|
37
40
|
focusable: "false",
|
|
38
|
-
children: [
|
|
41
|
+
children: [g ? /* @__PURE__ */ u("path", {
|
|
39
42
|
className: "kapi-sparkline__area",
|
|
40
|
-
d:
|
|
41
|
-
}) : null, /* @__PURE__ */
|
|
43
|
+
d: a(w)
|
|
44
|
+
}) : null, /* @__PURE__ */ u("path", {
|
|
42
45
|
className: "kapi-sparkline__line",
|
|
43
|
-
d:
|
|
46
|
+
d: o(w),
|
|
44
47
|
vectorEffect: "non-scaling-stroke"
|
|
45
48
|
})]
|
|
46
|
-
}),
|
|
49
|
+
}), _ && T ? /* @__PURE__ */ u("span", {
|
|
47
50
|
className: "kapi-sparkline__last",
|
|
48
|
-
style:
|
|
49
|
-
x:
|
|
50
|
-
y:
|
|
51
|
+
style: i({
|
|
52
|
+
x: T.x,
|
|
53
|
+
y: T.y
|
|
51
54
|
})
|
|
52
55
|
}) : null]
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
//#endregion
|
|
56
|
-
export {
|
|
59
|
+
export { f as DEFAULT_SPARKLINE_LABELS, p as KapiSparkline };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/data/KapiTableFilter.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { useLabels as t } from "../locale/KapiLocaleProvider.js";
|
|
5
|
+
import { KapiField as n } from "../inputs/KapiField.js";
|
|
6
|
+
import { KapiInputGroup as r } from "../inputs/KapiInputGroup.js";
|
|
7
7
|
import { KapiInput as i } from "../inputs/KapiInput.js";
|
|
8
8
|
import { KapiSelect as a } from "../inputs/KapiSelect.js";
|
|
9
9
|
import { filterColumnOptions as o, isFilterActive as s } from "./tableLogic.js";
|
|
@@ -22,7 +22,7 @@ var _ = {
|
|
|
22
22
|
region: c
|
|
23
23
|
}, v = "\0all", y = (e, t) => e.text === t.text && e.column === t.column;
|
|
24
24
|
function b({ value: c, onChange: b, columns: x, count: S, loadDelay: C, debounce: w, label: T, size: E = "sm", labels: D, className: O, "aria-label": k, ...A }) {
|
|
25
|
-
let j =
|
|
25
|
+
let j = t("tableFilter", _, D), M = C ?? w ?? 0, N = d(() => o(x), [x]), [P, F] = p(c), I = f(c), [L, R] = p(c);
|
|
26
26
|
y(L, c) || (R(c), y(I.current, c) || F(c));
|
|
27
27
|
let z = f(void 0);
|
|
28
28
|
l(() => () => clearTimeout(z.current), []);
|
|
@@ -30,7 +30,7 @@ function b({ value: c, onChange: b, columns: x, count: S, loadDelay: C, debounce
|
|
|
30
30
|
clearTimeout(z.current), I.current = e, b(e);
|
|
31
31
|
}, V = (e, t) => {
|
|
32
32
|
F(e), clearTimeout(z.current), !t && M > 0 ? z.current = setTimeout(() => B(e), M) : B(e);
|
|
33
|
-
}, H = u(), U = /* @__PURE__ */ h(
|
|
33
|
+
}, H = u(), U = /* @__PURE__ */ h(r, {
|
|
34
34
|
size: E,
|
|
35
35
|
className: "kapi-tablefilter__group",
|
|
36
36
|
children: [/* @__PURE__ */ m(a, {
|
|
@@ -69,7 +69,7 @@ function b({ value: c, onChange: b, columns: x, count: S, loadDelay: C, debounce
|
|
|
69
69
|
className: e("kapi-tablefilter", O),
|
|
70
70
|
role: "search",
|
|
71
71
|
"aria-label": k ?? j.region,
|
|
72
|
-
children: [T == null ? U : /* @__PURE__ */ m(
|
|
72
|
+
children: [T == null ? U : /* @__PURE__ */ m(n, {
|
|
73
73
|
label: T,
|
|
74
74
|
htmlFor: H,
|
|
75
75
|
className: "kapi-tablefilter__field",
|
|
@@ -46,7 +46,7 @@ export type KapiChartView = "chart" | "table";
|
|
|
46
46
|
* El prefijo de clases del gráfico concreto. Es una unión y no un `string` porque un typo acá
|
|
47
47
|
* produce marcado sin estilo que nada detecta: el CSS simplemente no engancha.
|
|
48
48
|
*/
|
|
49
|
-
export type KapiChartBlock = "kapi-barchart" | "kapi-linechart";
|
|
49
|
+
export type KapiChartBlock = "kapi-barchart" | "kapi-linechart" | "kapi-scatterchart";
|
|
50
50
|
/** Lo mínimo que la cáscara necesita saber de una serie para la leyenda y la tabla. */
|
|
51
51
|
export type KapiChartSeriesInfo = {
|
|
52
52
|
/** Id estable; clave de React y de la fila. */
|
|
@@ -54,6 +54,17 @@ export type KapiChartSeriesInfo = {
|
|
|
54
54
|
/** Nombre en la leyenda y en la tabla. */
|
|
55
55
|
label: string;
|
|
56
56
|
};
|
|
57
|
+
/** Una fila de la tabla cuando el dato no es categoría × serie (ver `tableRows`). */
|
|
58
|
+
export type KapiChartTableRow = {
|
|
59
|
+
/** Clave de React. */
|
|
60
|
+
id: string;
|
|
61
|
+
/** Índice de la serie, para pintar su muestra de color. */
|
|
62
|
+
slot: number;
|
|
63
|
+
/** Nombre de la fila (la primera celda, en `<th scope="row">`). */
|
|
64
|
+
header: string;
|
|
65
|
+
/** Celdas ya formateadas, en el orden de `categories`. */
|
|
66
|
+
cells: readonly string[];
|
|
67
|
+
};
|
|
57
68
|
export type KapiChartFrameProps = {
|
|
58
69
|
/** Título visible; sin él hace falta `aria-label` en la raíz. */
|
|
59
70
|
title?: ReactNode | undefined;
|
|
@@ -65,6 +76,13 @@ export type KapiChartFrameProps = {
|
|
|
65
76
|
categories: readonly string[];
|
|
66
77
|
/** El valor de una celda, por índice de serie y de categoría. */
|
|
67
78
|
valueAt: (seriesIndex: number, categoryIndex: number) => number;
|
|
79
|
+
/**
|
|
80
|
+
* Filas propias de la tabla, para un gráfico cuyo dato **no** es categoría × serie. La dispersión
|
|
81
|
+
* es ese caso: cada punto tiene DOS valores (x, y) y no hay una celda por categoría, así que sin
|
|
82
|
+
* esto su tabla tendría que tirar una de las dos coordenadas. Con `tableRows`, `categories` pasa a
|
|
83
|
+
* ser el encabezado de las columnas y cada fila trae su propio nombre y sus celdas ya formateadas.
|
|
84
|
+
*/
|
|
85
|
+
tableRows?: readonly KapiChartTableRow[] | undefined;
|
|
68
86
|
/** La unidad del valor, aplicada a las celdas de la tabla. Ver `KapiChartUnit`. */
|
|
69
87
|
unit?: KapiChartUnit | undefined;
|
|
70
88
|
/** Vista mostrada. */
|
|
@@ -107,6 +125,6 @@ export declare const ChartSwatch: ({ block, slot }: {
|
|
|
107
125
|
block: KapiChartBlock;
|
|
108
126
|
slot: number;
|
|
109
127
|
}) => import("react").JSX.Element;
|
|
110
|
-
export declare const KapiChartFrame: ({ title, titleId, series, categories, valueAt, unit, view, onViewChange, text, block, children }: KapiChartFrameProps) => import("react").JSX.Element;
|
|
128
|
+
export declare const KapiChartFrame: ({ title, titleId, series, categories, valueAt, tableRows, unit, view, onViewChange, text, block, children }: KapiChartFrameProps) => import("react").JSX.Element;
|
|
111
129
|
/** El `useId` de la cáscara, para que el gráfico ate su título sin repetir el hook. */
|
|
112
130
|
export declare const useChartTitleId: () => string;
|
|
@@ -29,60 +29,69 @@ var l = {
|
|
|
29
29
|
}), h = ({ block: e, slot: t }) => /* @__PURE__ */ s("span", {
|
|
30
30
|
className: `${e}__swatch`,
|
|
31
31
|
style: m({ slot: t })
|
|
32
|
-
}), g = ({ title: t, titleId: n, series: a, categories: l, valueAt: u,
|
|
33
|
-
let
|
|
32
|
+
}), g = ({ title: t, titleId: n, series: a, categories: l, valueAt: u, tableRows: f, unit: p, view: m, onViewChange: g, text: _, block: v, children: y }) => {
|
|
33
|
+
let b = e(), x = a.length === 0 || l.length === 0;
|
|
34
34
|
return /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c("div", {
|
|
35
|
-
className: `${
|
|
35
|
+
className: `${v}__head`,
|
|
36
36
|
children: [t ? /* @__PURE__ */ s("div", {
|
|
37
|
-
className: `${
|
|
37
|
+
className: `${v}__title`,
|
|
38
38
|
id: n,
|
|
39
39
|
children: t
|
|
40
40
|
}) : null, /* @__PURE__ */ s(i, {
|
|
41
|
-
"aria-label":
|
|
41
|
+
"aria-label": _.view,
|
|
42
42
|
items: [{
|
|
43
43
|
id: "chart",
|
|
44
|
-
label:
|
|
44
|
+
label: _.chartView
|
|
45
45
|
}, {
|
|
46
46
|
id: "table",
|
|
47
|
-
label:
|
|
47
|
+
label: _.tableView
|
|
48
48
|
}],
|
|
49
|
-
value:
|
|
50
|
-
onChange:
|
|
49
|
+
value: m,
|
|
50
|
+
onChange: g
|
|
51
51
|
})]
|
|
52
|
-
}),
|
|
53
|
-
className: `${
|
|
54
|
-
children:
|
|
55
|
-
}) :
|
|
56
|
-
className: `${
|
|
52
|
+
}), x ? /* @__PURE__ */ s("p", {
|
|
53
|
+
className: `${v}__empty kapi-muted`,
|
|
54
|
+
children: _.empty
|
|
55
|
+
}) : m === "table" ? /* @__PURE__ */ s("div", {
|
|
56
|
+
className: `${v}__tablewrap`,
|
|
57
57
|
children: /* @__PURE__ */ c("table", {
|
|
58
|
-
className: `${
|
|
58
|
+
className: `${v}__table`,
|
|
59
59
|
children: [/* @__PURE__ */ s("thead", { children: /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
|
|
60
60
|
scope: "col",
|
|
61
|
-
children:
|
|
61
|
+
children: _.series
|
|
62
62
|
}), l.map((e, t) => /* @__PURE__ */ s("th", {
|
|
63
63
|
scope: "col",
|
|
64
64
|
children: e
|
|
65
|
-
}, `${e}-${t}`))] }) }), /* @__PURE__ */ s("tbody", { children:
|
|
65
|
+
}, `${e}-${t}`))] }) }), /* @__PURE__ */ s("tbody", { children: f ? f.map((e) => /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
|
|
66
66
|
scope: "row",
|
|
67
67
|
children: /* @__PURE__ */ c("span", {
|
|
68
|
-
className: `${
|
|
68
|
+
className: `${v}__serie`,
|
|
69
69
|
children: [/* @__PURE__ */ s(h, {
|
|
70
|
-
block:
|
|
70
|
+
block: v,
|
|
71
|
+
slot: e.slot
|
|
72
|
+
}), e.header]
|
|
73
|
+
})
|
|
74
|
+
}), e.cells.map((e, t) => /* @__PURE__ */ s("td", { children: e }, t))] }, e.id)) : a.map((e, t) => /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
|
|
75
|
+
scope: "row",
|
|
76
|
+
children: /* @__PURE__ */ c("span", {
|
|
77
|
+
className: `${v}__serie`,
|
|
78
|
+
children: [/* @__PURE__ */ s(h, {
|
|
79
|
+
block: v,
|
|
71
80
|
slot: t
|
|
72
81
|
}), e.label]
|
|
73
82
|
})
|
|
74
|
-
}), l.map((e, n) => /* @__PURE__ */ s("td", { children: d(r(u(t, n),
|
|
83
|
+
}), l.map((e, n) => /* @__PURE__ */ s("td", { children: d(r(u(t, n), b), p) }, `${e}-${n}`))] }, e.id)) })]
|
|
75
84
|
})
|
|
76
85
|
}) : /* @__PURE__ */ c(o, { children: [a.length > 1 ? /* @__PURE__ */ s("ul", {
|
|
77
|
-
className: `${
|
|
86
|
+
className: `${v}__legend`,
|
|
78
87
|
children: a.map((e, t) => /* @__PURE__ */ c("li", {
|
|
79
|
-
className: `${
|
|
88
|
+
className: `${v}__legenditem`,
|
|
80
89
|
children: [/* @__PURE__ */ s(h, {
|
|
81
|
-
block:
|
|
90
|
+
block: v,
|
|
82
91
|
slot: t
|
|
83
92
|
}), e.label]
|
|
84
93
|
}, e.id))
|
|
85
|
-
}) : null,
|
|
94
|
+
}) : null, y] })] });
|
|
86
95
|
}, _ = () => a();
|
|
87
96
|
//#endregion
|
|
88
97
|
export { h as ChartSwatch, l as DEFAULT_CHART_LABELS, g as KapiChartFrame, u as chartSummary, m as chartVars, f as useChartLabels, _ as useChartTitleId, p as useChartView, d as withChartUnit };
|
|
@@ -108,3 +108,7 @@ rowMatchesFilter,
|
|
|
108
108
|
/** @deprecated Interno, se quita en 1.0. */
|
|
109
109
|
filterTerms, normalizeFilterText, buildCsv, csvCell } from "./tableLogic.js";
|
|
110
110
|
export type { KapiTableColumnPinning, KapiTableHeaderAction, KapiTableSticky, KapiTableStickySide, KapiTableColumnVisibility, KapiTableColumnWidths, KapiTableFilterState } from "./tableLogic.js";
|
|
111
|
+
export { KapiScatterChart } from "./KapiScatterChart.js";
|
|
112
|
+
export type { KapiScatterChartProps, KapiScatterSeries, KapiScatterPoint } from "./KapiScatterChart.js";
|
|
113
|
+
export { scatterAxis, scatterInside, scatterPosition, scatterTickLabel } from "./scatterLogic.js";
|
|
114
|
+
export type { KapiScatterAxis } from "./scatterLogic.js";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Un punto de dispersión: dos valores numéricos y una etiqueta opcional. */
|
|
2
|
+
export type KapiScatterPoint = {
|
|
3
|
+
/** Valor sobre el eje horizontal. */
|
|
4
|
+
x: number;
|
|
5
|
+
/** Valor sobre el eje vertical. */
|
|
6
|
+
y: number;
|
|
7
|
+
/**
|
|
8
|
+
* Nombre del punto: es la cabecera de su fila en la tabla y abre su descripción accesible. Sin
|
|
9
|
+
* él, la fila se llama con el nombre de la serie y la posición del punto (`Ventas 3`).
|
|
10
|
+
*/
|
|
11
|
+
label?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
/** Eje de dispersión: su ventana y las marcas de adentro, en unidades de dato. */
|
|
14
|
+
export type KapiScatterAxis = {
|
|
15
|
+
/** Valor del borde inferior. */
|
|
16
|
+
min: number;
|
|
17
|
+
/** Valor del borde superior. */
|
|
18
|
+
max: number;
|
|
19
|
+
/** Marcas, de `min` a `max` inclusive. */
|
|
20
|
+
ticks: readonly number[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Ventana redondeada que cubre `values`, con a lo sumo `tickCount` tramos.
|
|
24
|
+
*
|
|
25
|
+
* **No es `barScale` y no debe serlo.** El eje de un gráfico de barras tiene que arrancar en CERO,
|
|
26
|
+
* porque el largo de la barra ES el valor y truncar el eje miente sobre las proporciones. El de una
|
|
27
|
+
* dispersión es una ventana sobre los datos: forzarlo a cero aplastaría la nube contra una esquina
|
|
28
|
+
* cuando los valores están lejos del origen (sueldos, años, temperaturas). Son dos reglas distintas
|
|
29
|
+
* sobre el mismo problema, no la misma regla escrita dos veces.
|
|
30
|
+
*/
|
|
31
|
+
export declare const scatterAxis: (values: readonly number[], tickCount?: number) => KapiScatterAxis;
|
|
32
|
+
/**
|
|
33
|
+
* Posición de un punto en porcentaje de la ventana (0 a 100 en los dos ejes). `cy` se mide **desde
|
|
34
|
+
* arriba**, que es la convención de la que vienen los nombres `cx`/`cy`; el gráfico no usa SVG,
|
|
35
|
+
* posiciona HTML desde abajo y da vuelta el valor al aplicarlo (`y: 100 - cy`).
|
|
36
|
+
*
|
|
37
|
+
* Un eje de ancho cero devuelve el centro en vez de dividir por cero.
|
|
38
|
+
*/
|
|
39
|
+
export declare const scatterPosition: (point: KapiScatterPoint, x: KapiScatterAxis, y: KapiScatterAxis) => {
|
|
40
|
+
cx: number;
|
|
41
|
+
cy: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* ¿El punto cae dentro de la ventana? Sirve para no dibujar un punto pisado contra el borde, donde
|
|
45
|
+
* mentiría sobre su valor.
|
|
46
|
+
*
|
|
47
|
+
* Qué filtra HOY en `KapiScatterChart`, que es lo único que lo usa: sólo los puntos **no finitos**
|
|
48
|
+
* (`NaN`, infinitos), porque toda comparación con ellos es falsa. Un punto finito no puede quedar
|
|
49
|
+
* afuera, porque los dos ejes salen de `scatterAxis` sobre esos mismos puntos y esa función
|
|
50
|
+
* redondea la ventana hacia afuera. El componente no acepta ejes fijos del consumidor; la función
|
|
51
|
+
* es pública y sí sirve para eso, pero esa combinación todavía no existe acá. Ojo con el filtro:
|
|
52
|
+
* un punto no finito desaparece del dibujo y la tabla lo sigue listando.
|
|
53
|
+
*/
|
|
54
|
+
export declare const scatterInside: (point: KapiScatterPoint, x: KapiScatterAxis, y: KapiScatterAxis) => boolean;
|
|
55
|
+
/** Texto corto de una marca: entero si lo es, si no con los decimales que haga falta (hasta 2). */
|
|
56
|
+
export declare const scatterTickLabel: (value: number) => string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/components/data/scatterLogic.ts
|
|
2
|
+
var e = (e, t = 0) => Number.isFinite(e) ? e : t, t = (e, t) => {
|
|
3
|
+
let n = e / Math.max(1, t), r = 10 ** Math.floor(Math.log10(n)), i = n / r;
|
|
4
|
+
return (i <= 1 ? 1 : i <= 2 ? 2 : i <= 5 ? 5 : 10) * r;
|
|
5
|
+
}, n = (n, r = 4) => {
|
|
6
|
+
let i = Math.max(1, Math.floor(e(r, 4))), a = n.filter((e) => Number.isFinite(e));
|
|
7
|
+
if (a.length === 0) return {
|
|
8
|
+
min: 0,
|
|
9
|
+
max: 1,
|
|
10
|
+
ticks: [0, 1]
|
|
11
|
+
};
|
|
12
|
+
let o = a[0], s = o;
|
|
13
|
+
for (let e of a) e < o && (o = e), e > s && (s = e);
|
|
14
|
+
if (o === s) {
|
|
15
|
+
let e = Math.abs(o) > 0 ? Math.abs(o) / 10 : 1;
|
|
16
|
+
o -= e, s += e;
|
|
17
|
+
}
|
|
18
|
+
let c = t(s - o, i);
|
|
19
|
+
if (!(c > 0) || !Number.isFinite(c)) return {
|
|
20
|
+
min: 0,
|
|
21
|
+
max: 1,
|
|
22
|
+
ticks: [0, 1]
|
|
23
|
+
};
|
|
24
|
+
let l = Math.floor(o / c) * c, u = Math.ceil(s / c) * c, d = Math.max(1, Math.round((u - l) / c)), f = [...new Set(Array.from({ length: d + 1 }, (e, t) => Number((l + t * c).toPrecision(12))))];
|
|
25
|
+
return {
|
|
26
|
+
min: Number(l.toPrecision(12)),
|
|
27
|
+
max: Number(u.toPrecision(12)),
|
|
28
|
+
ticks: f
|
|
29
|
+
};
|
|
30
|
+
}, r = (e, t, n) => {
|
|
31
|
+
let r = t.max - t.min, i = n.max - n.min, a = r === 0 ? 50 : (e.x - t.min) / r * 100, o = i === 0 ? 50 : 100 - (e.y - n.min) / i * 100;
|
|
32
|
+
return {
|
|
33
|
+
cx: Number(a.toFixed(3)),
|
|
34
|
+
cy: Number(o.toFixed(3))
|
|
35
|
+
};
|
|
36
|
+
}, i = (e, t, n) => e.x >= t.min && e.x <= t.max && e.y >= n.min && e.y <= n.max, a = (e) => {
|
|
37
|
+
if (!Number.isFinite(e)) return "";
|
|
38
|
+
if (Number.isInteger(e)) return String(e);
|
|
39
|
+
let t = Math.abs(e);
|
|
40
|
+
return e.toFixed(t < 1 ? 2 : 1);
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { n as scatterAxis, i as scatterInside, r as scatterPosition, a as scatterTickLabel };
|
|
@@ -2,7 +2,18 @@ import type { CSSProperties, ReactNode } from "react";
|
|
|
2
2
|
import { columnAlign, type KapiTableColumnWidths, type KapiTableSortState } from "./tableLogic.js";
|
|
3
3
|
import type { KapiTableLabels } from "./tableLabels.js";
|
|
4
4
|
import type { KapiTableColumn } from "./tableTypes.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Copia el valor de una celda y avisa SÓLO si el portapapeles lo aceptó.
|
|
7
|
+
*
|
|
8
|
+
* Antes avisaba siempre: la escritura salía sin esperar y el `onCopy` se disparaba fuera del `try`,
|
|
9
|
+
* así que una app que muestra «¡Copiado!» en ese callback mentía cada vez que el portapapeles no
|
|
10
|
+
* estaba o rechazaba —sin permiso, sin foco, dentro de un iframe—. Su JSDoc dice «se llama tras
|
|
11
|
+
* copiar una celda», y ahora eso es cierto.
|
|
12
|
+
*
|
|
13
|
+
* Usa `copyText`, el mismo motor de `KapiCopyButton`: una sola implementación, y es la que resuelve
|
|
14
|
+
* el portapapeles por el documento dueño (iframe o shadow DOM) a partir del botón.
|
|
15
|
+
*/
|
|
16
|
+
export declare const copyToClipboard: (value: unknown, onCopy?: (value: unknown) => void, from?: Element | null) => Promise<void>;
|
|
6
17
|
/** Caja de la columna: sin override reproduce el comportamiento original. */
|
|
7
18
|
export declare const columnBoxStyle: <T>(c: KapiTableColumn<T>, kind: "th" | "td", widths: KapiTableColumnWidths) => CSSProperties;
|
|
8
19
|
/** Geometría de las columnas fijas, compartida por encabezado, filas y esqueleto (memoizada). */
|