@kapiuara/ui 0.15.3 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -15
- package/README.md +505 -13
- package/dist/components/chat/KapiChatThread.js +4 -4
- package/dist/components/chat/KapiComposer.js +8 -8
- package/dist/components/data/KapiDataTable.d.ts +1 -1
- package/dist/components/data/KapiDataTable.js +25 -25
- package/dist/components/data/KapiPaginationFooter.js +1 -1
- package/dist/components/data/KapiSheet.d.ts +105 -0
- package/dist/components/data/KapiSheet.js +75 -0
- package/dist/components/data/KapiSparkline.d.ts +2 -1
- package/dist/components/data/KapiSparkline.js +29 -26
- package/dist/components/data/KapiTable.d.ts +2 -2
- package/dist/components/data/KapiTable.js +347 -329
- package/dist/components/data/KapiTableFilter.js +6 -6
- package/dist/components/data/KapiTableFooter.d.ts +22 -0
- package/dist/components/data/KapiTableFooter.js +55 -0
- package/dist/components/data/KapiTableRow.js +53 -52
- package/dist/components/data/KapiTableToolbar.d.ts +4 -2
- package/dist/components/data/KapiTableToolbar.js +71 -69
- package/dist/components/data/index.d.ts +3 -1
- package/dist/components/data/tableCells.d.ts +17 -5
- package/dist/components/data/tableCells.js +52 -53
- package/dist/components/data/tableLogic.d.ts +2 -0
- package/dist/components/data/tableLogic.js +66 -66
- package/dist/components/data/tableSlots.d.ts +9 -0
- package/dist/components/data/tableSlots.js +12 -0
- package/dist/components/data/tableSpanLogic.d.ts +35 -0
- package/dist/components/data/tableSpanLogic.js +47 -0
- package/dist/components/data/tableTypes.d.ts +54 -1
- package/dist/components/data/useTableSelection.d.ts +4 -2
- package/dist/components/data/useTableSelection.js +29 -25
- package/dist/components/display/KapiAnchor.d.ts +36 -0
- package/dist/components/display/KapiAnchor.js +36 -0
- 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/KapiBadge.d.ts +6 -5
- package/dist/components/display/KapiBadge.js +25 -19
- 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/KapiText.d.ts +43 -0
- package/dist/components/display/KapiText.js +33 -0
- package/dist/components/display/KapiTimeline.d.ts +5 -2
- package/dist/components/display/KapiTimeline.js +31 -23
- package/dist/components/display/KapiTitle.d.ts +33 -0
- package/dist/components/display/KapiTitle.js +29 -0
- package/dist/components/display/annotationLogic.d.ts +2 -1
- package/dist/components/display/annotationLogic.js +7 -6
- 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 +15 -0
- 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/textLogic.d.ts +32 -0
- package/dist/components/display/textLogic.js +19 -0
- package/dist/components/display/timelineLogic.d.ts +20 -2
- package/dist/components/display/timelineLogic.js +10 -2
- package/dist/components/feedback/KapiAlert.d.ts +8 -4
- package/dist/components/feedback/KapiAlert.js +39 -34
- package/dist/components/feedback/KapiFab.js +108 -108
- package/dist/components/feedback/KapiProgress.js +63 -54
- package/dist/components/feedback/KapiToastContainer.js +9 -9
- package/dist/components/feedback/KapiTour.js +12 -12
- 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/KapiButton.d.ts +7 -4
- package/dist/components/inputs/KapiButton.js +47 -42
- 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.js +6 -6
- 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 +21 -1
- package/dist/components/inputs/KapiSelect.js +251 -245
- package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
- package/dist/components/inputs/KapiSelectMenu.js +131 -133
- 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 +21 -1
- package/dist/components/inputs/fieldLogic.js +18 -11
- package/dist/components/inputs/index.d.ts +9 -1
- 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/inputs/selectSlots.d.ts +24 -0
- package/dist/components/inputs/selectSlots.js +27 -0
- 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/KapiBox.d.ts +31 -0
- package/dist/components/layout/KapiBox.js +26 -0
- package/dist/components/layout/KapiCard.d.ts +16 -4
- package/dist/components/layout/KapiCard.js +46 -34
- package/dist/components/layout/KapiCenter.d.ts +13 -0
- package/dist/components/layout/KapiCenter.js +23 -0
- package/dist/components/layout/KapiCol.d.ts +22 -0
- package/dist/components/layout/KapiCol.js +23 -0
- package/dist/components/layout/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.d.ts +29 -3
- package/dist/components/layout/KapiGrid.js +39 -17
- package/dist/components/layout/KapiNotificationBell.js +10 -10
- package/dist/components/layout/KapiPageHeader.d.ts +10 -1
- package/dist/components/layout/KapiPageHeader.js +94 -92
- package/dist/components/layout/KapiPanelParts.d.ts +11 -2
- package/dist/components/layout/KapiPanelParts.js +73 -56
- package/dist/components/layout/KapiRail.d.ts +10 -1
- package/dist/components/layout/KapiRail.js +125 -122
- package/dist/components/layout/KapiRoot.d.ts +55 -5
- package/dist/components/layout/KapiRoot.js +57 -38
- package/dist/components/layout/KapiShell.d.ts +44 -3
- package/dist/components/layout/KapiShell.js +54 -50
- package/dist/components/layout/accessCardLogic.d.ts +8 -1
- package/dist/components/layout/accessCardLogic.js +11 -7
- package/dist/components/layout/cardSlots.d.ts +9 -0
- package/dist/components/layout/cardSlots.js +12 -0
- package/dist/components/layout/gridSpanLogic.d.ts +46 -0
- package/dist/components/layout/gridSpanLogic.js +39 -0
- package/dist/components/layout/index.d.ts +13 -4
- package/dist/components/layout/layoutPrimitives.d.ts +11 -0
- package/dist/components/layout/layoutPrimitives.js +12 -1
- package/dist/components/layout/pageHeaderSlots.d.ts +12 -0
- package/dist/components/layout/pageHeaderSlots.js +15 -0
- package/dist/components/layout/railLogic.d.ts +16 -3
- package/dist/components/layout/railSlots.d.ts +12 -0
- package/dist/components/layout/railSlots.js +15 -0
- package/dist/components/layout/shellSlots.d.ts +6 -0
- package/dist/components/layout/shellSlots.js +9 -0
- package/dist/components/layout/useGridBreakpoint.d.ts +12 -0
- package/dist/components/layout/useGridBreakpoint.js +35 -0
- package/dist/components/locale/labelRegistry.d.ts +10 -0
- package/dist/components/navigation/KapiAccordion.js +9 -9
- package/dist/components/navigation/KapiBreadcrumb.d.ts +18 -2
- package/dist/components/navigation/KapiBreadcrumb.js +23 -16
- package/dist/components/navigation/KapiContextPanel.d.ts +17 -4
- package/dist/components/navigation/KapiContextPanel.js +152 -136
- package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
- package/dist/components/navigation/KapiNavBadge.js +26 -22
- package/dist/components/navigation/KapiPanelGroup.d.ts +16 -4
- package/dist/components/navigation/KapiPanelGroup.js +66 -65
- package/dist/components/navigation/KapiTabs.d.ts +12 -0
- package/dist/components/navigation/KapiTabs.js +87 -71
- package/dist/components/navigation/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/MiniNavItem.d.ts +7 -2
- package/dist/components/navigation/MiniNavItem.js +41 -36
- package/dist/components/navigation/breadcrumbLogic.d.ts +4 -2
- package/dist/components/navigation/breadcrumbLogic.js +1 -1
- package/dist/components/navigation/index.d.ts +3 -0
- package/dist/components/navigation/navLink.d.ts +21 -0
- package/dist/components/navigation/navLink.js +26 -0
- package/dist/components/navigation/navLinkLogic.d.ts +18 -0
- package/dist/components/navigation/navLinkLogic.js +22 -0
- package/dist/components/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.d.ts +8 -0
- package/dist/components/overlays/KapiContextMenu.js +5 -5
- package/dist/components/overlays/KapiMenuButton.js +7 -7
- package/dist/components/overlays/KapiModal.d.ts +9 -0
- package/dist/components/overlays/KapiModal.js +79 -77
- 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/KapiTooltip.js +18 -18
- package/dist/components/overlays/index.d.ts +1 -1
- package/dist/components/overlays/menuList.js +127 -117
- package/dist/components/overlays/modalSlots.d.ts +11 -0
- package/dist/components/overlays/modalSlots.js +14 -0
- package/dist/components/slotCatalog.d.ts +123 -0
- package/dist/components/slotCatalog.js +27 -0
- package/dist/components/slotsLogic.d.ts +34 -0
- package/dist/components/slotsLogic.js +18 -0
- package/dist/components/tone.d.ts +26 -0
- package/dist/components/tone.js +15 -14
- package/dist/css/base.css +1 -1
- package/dist/css/components/data/KapiEventCalendar.css +1 -1
- package/dist/css/components/data/KapiTable.css +1 -1
- package/dist/css/components/display/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/display/typography.css +1 -0
- package/dist/css/components/feedback/feedback.css +1 -1
- package/dist/css/components/inputs/KapiButton.css +1 -1
- package/dist/css/components/inputs/KapiDatePicker.css +1 -1
- package/dist/css/components/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/KapiBox.css +1 -0
- package/dist/css/components/layout/KapiCollapse.css +1 -0
- package/dist/css/components/layout/KapiDivider.css +1 -1
- package/dist/css/components/layout/KapiRail.css +1 -1
- package/dist/css/components/layout/gridSpan.css +1 -0
- package/dist/css/components/navigation/KapiToc.css +1 -0
- package/dist/css/components/navigation/navigation.css +1 -1
- package/dist/hooks/asyncResourceLogic.d.ts +11 -0
- package/dist/hooks/asyncResourceLogic.js +4 -0
- package/dist/hooks/densityLogic.d.ts +15 -0
- package/dist/hooks/densityLogic.js +4 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/themeColorsLogic.d.ts +19 -0
- package/dist/hooks/themeColorsLogic.js +4 -2
- package/dist/hooks/themeDeriveLogic.d.ts +16 -0
- package/dist/hooks/themeDeriveLogic.js +27 -17
- package/dist/hooks/toneFamilyLogic.d.ts +146 -0
- package/dist/hooks/toneFamilyLogic.js +164 -0
- package/dist/hooks/useAsyncResource.d.ts +45 -0
- package/dist/hooks/useAsyncResource.js +24 -0
- package/dist/hooks/useKapiTheme.d.ts +16 -3
- package/dist/hooks/useKapiTheme.js +130 -117
- package/dist/hooks/useToneFamilies.d.ts +40 -0
- package/dist/hooks/useToneFamilies.js +50 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +227 -204
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/logic.d.ts +41 -0
- package/dist/logic.js +42 -0
- package/dist/styles/rawHeights.d.ts +8 -0
- package/package.json +14 -3
|
@@ -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
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
2
|
+
import { useControllableState as e } from "../../hooks/useControllableState.js";
|
|
3
|
+
import { useRangeSelect as t } from "../../hooks/useRangeSelect.js";
|
|
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
|
|
12
|
-
let [w, T] =
|
|
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] = e(c, u ?? g, _ && ((e) => _([...e]))), E = d(() => new Set(w), [w]), D = (e) => T([...e]), O = () => D(/* @__PURE__ */ new Set()), k = [...E], A = t(), 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
|
|
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__ */
|
|
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
|
|
33
|
+
label: a ? e.label : `${e.label} (${r(n, C)})`,
|
|
32
34
|
...o !== void 0 && { icon: o },
|
|
33
|
-
disabled: a ||
|
|
34
|
-
onClick: e.onSelect ?? (() => D(
|
|
35
|
+
disabled: a || n === 0,
|
|
36
|
+
onClick: e.onSelect ?? (() => D(i(E, N, t)))
|
|
35
37
|
};
|
|
36
|
-
}), F =
|
|
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 &&
|
|
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
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
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) :
|
|
71
|
-
})] }), t === "selected" && /* @__PURE__ */ f
|
|
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:
|
|
79
|
+
children: i
|
|
76
80
|
})] })]
|
|
77
81
|
});
|
|
78
82
|
}
|
|
79
83
|
//#endregion
|
|
80
|
-
export {
|
|
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,122 +1,127 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/display/KapiAnnotation.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
5
|
+
import { joinIds as ee } from "../inputs/fieldLogic.js";
|
|
6
|
+
import { resolveKapiRoot as n } from "../../hooks/kapiRoot.js";
|
|
7
|
+
import { usePlacement as r } from "../../hooks/usePlacement.js";
|
|
7
8
|
import { useDismiss as i } from "../../hooks/useDismiss.js";
|
|
8
9
|
import { KapiTooltip as a } from "../overlays/KapiTooltip.js";
|
|
9
10
|
import { annotationClasses as o, annotationRole as s } from "./annotationLogic.js";
|
|
10
11
|
/* empty css */
|
|
11
|
-
import { useEffect as c, useId as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { createPortal as
|
|
12
|
+
import { useEffect as c, useId as te, useRef as l, useState as u } from "react";
|
|
13
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
14
|
+
import { createPortal as p } from "react-dom";
|
|
14
15
|
//#region src/components/display/KapiAnnotation.tsx
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
let
|
|
18
|
-
underline:
|
|
19
|
-
tone:
|
|
20
|
-
clickable: !!
|
|
21
|
-
className:
|
|
16
|
+
var m = 8, h = 8, g = 150;
|
|
17
|
+
function _({ children: _, info: v, underline: y = "dotted", tone: ne = "primary", onClick: b, popover: x, interactive: S = !1, className: C, "aria-label": w, ref: T, ...E }) {
|
|
18
|
+
let D = te(), O = l(null), k = t(O, T), [A, j] = u(!1), [M, N] = u(!1), P = l(null), F = l(void 0), { element: I, tabIndex: L, mode: R } = s(b, x, v), z = e("KapiAnnotation", ne), B = o({
|
|
19
|
+
underline: y,
|
|
20
|
+
tone: z.tone,
|
|
21
|
+
clickable: !!b,
|
|
22
|
+
className: C
|
|
22
23
|
}), V = (e) => {
|
|
23
|
-
e.key === "Escape" && (
|
|
24
|
-
}, H = () => clearTimeout(
|
|
25
|
-
H(),
|
|
24
|
+
e.key === "Escape" && (j(!1), N(!0));
|
|
25
|
+
}, H = () => clearTimeout(F.current), U = () => {
|
|
26
|
+
H(), N(!1), j(!0);
|
|
26
27
|
}, W = () => {
|
|
27
|
-
H(),
|
|
28
|
+
H(), j(!1), N(!1);
|
|
28
29
|
}, G = () => {
|
|
29
|
-
if (!
|
|
30
|
-
H(),
|
|
30
|
+
if (!S) return W();
|
|
31
|
+
H(), F.current = setTimeout(W, g);
|
|
31
32
|
}, K = (e) => {
|
|
32
33
|
let t = e.relatedTarget;
|
|
33
|
-
|
|
34
|
-
}, { placement: q } =
|
|
35
|
-
open:
|
|
36
|
-
anchor:
|
|
37
|
-
floatingRef:
|
|
34
|
+
S && t && P.current?.contains(t) || W();
|
|
35
|
+
}, { placement: q } = r({
|
|
36
|
+
open: A,
|
|
37
|
+
anchor: O,
|
|
38
|
+
floatingRef: P,
|
|
38
39
|
side: "bottom",
|
|
39
40
|
align: "center",
|
|
40
|
-
offset:
|
|
41
|
-
margin:
|
|
41
|
+
offset: m,
|
|
42
|
+
margin: h
|
|
42
43
|
}), J = q ? {
|
|
43
44
|
top: q.top,
|
|
44
45
|
left: q.centerX,
|
|
45
46
|
side: q.side === "top" ? "top" : "bottom"
|
|
46
|
-
} : null, Y = i(
|
|
47
|
-
zones: [
|
|
47
|
+
} : null, Y = i(A && S, {
|
|
48
|
+
zones: [O, P],
|
|
48
49
|
onDismiss: (e) => {
|
|
49
50
|
if (e === "outside") return W();
|
|
50
|
-
|
|
51
|
+
j(!1), N(!0);
|
|
51
52
|
}
|
|
52
53
|
});
|
|
53
|
-
c(() => () => clearTimeout(
|
|
54
|
+
c(() => () => clearTimeout(F.current), []);
|
|
54
55
|
let X = {
|
|
55
|
-
...
|
|
56
|
-
|
|
56
|
+
...E,
|
|
57
|
+
style: z.style ? {
|
|
58
|
+
...z.style,
|
|
59
|
+
...E.style
|
|
60
|
+
} : E.style,
|
|
61
|
+
ref: k,
|
|
57
62
|
className: B,
|
|
58
63
|
onKeyDown: V,
|
|
59
|
-
onClick:
|
|
60
|
-
...
|
|
61
|
-
"data-dismissed":
|
|
64
|
+
onClick: b,
|
|
65
|
+
...w !== void 0 && { "aria-label": w },
|
|
66
|
+
"data-dismissed": M ? "" : void 0
|
|
62
67
|
};
|
|
63
|
-
if (
|
|
64
|
-
let e = String(
|
|
68
|
+
if (R === "tooltip") {
|
|
69
|
+
let e = String(v), t = I === "button" ? /* @__PURE__ */ d("button", {
|
|
65
70
|
...X,
|
|
66
71
|
type: "button",
|
|
67
72
|
onBlur: W,
|
|
68
|
-
children:
|
|
69
|
-
}) : /* @__PURE__ */
|
|
73
|
+
children: _
|
|
74
|
+
}) : /* @__PURE__ */ d("span", {
|
|
70
75
|
...X,
|
|
71
|
-
tabIndex:
|
|
76
|
+
tabIndex: L,
|
|
72
77
|
onBlur: W,
|
|
73
|
-
children:
|
|
78
|
+
children: _
|
|
74
79
|
});
|
|
75
|
-
return /* @__PURE__ */
|
|
80
|
+
return /* @__PURE__ */ d(a, {
|
|
76
81
|
label: e,
|
|
77
82
|
prefer: "top",
|
|
78
83
|
children: t
|
|
79
84
|
});
|
|
80
85
|
}
|
|
81
|
-
let Z =
|
|
86
|
+
let Z = x ?? { body: v }, Q = {
|
|
82
87
|
...X,
|
|
83
|
-
"aria-describedby":
|
|
88
|
+
"aria-describedby": ee(E["aria-describedby"], A && D),
|
|
84
89
|
onFocus: U,
|
|
85
90
|
onBlur: K
|
|
86
|
-
}, $ =
|
|
87
|
-
return /* @__PURE__ */
|
|
91
|
+
}, $ = A ? n(O.current) : null;
|
|
92
|
+
return /* @__PURE__ */ f("span", {
|
|
88
93
|
className: "kapi-annotation-wrap",
|
|
89
94
|
onMouseEnter: U,
|
|
90
95
|
onMouseLeave: G,
|
|
91
96
|
onKeyDown: Y,
|
|
92
|
-
children: [
|
|
97
|
+
children: [I === "button" ? /* @__PURE__ */ d("button", {
|
|
93
98
|
...Q,
|
|
94
99
|
type: "button",
|
|
95
|
-
children:
|
|
96
|
-
}) : /* @__PURE__ */
|
|
100
|
+
children: _
|
|
101
|
+
}) : /* @__PURE__ */ d("span", {
|
|
97
102
|
...Q,
|
|
98
|
-
tabIndex:
|
|
99
|
-
children:
|
|
100
|
-
}), $ &&
|
|
101
|
-
ref:
|
|
102
|
-
id:
|
|
103
|
+
tabIndex: L,
|
|
104
|
+
children: _
|
|
105
|
+
}), $ && p(/* @__PURE__ */ f("span", {
|
|
106
|
+
ref: P,
|
|
107
|
+
id: D,
|
|
103
108
|
role: "tooltip",
|
|
104
109
|
className: "kapi-annotation__pop",
|
|
105
110
|
"data-side": J?.side ?? "bottom",
|
|
106
|
-
"data-interactive":
|
|
111
|
+
"data-interactive": S ? "" : void 0,
|
|
107
112
|
style: {
|
|
108
113
|
top: J?.top ?? 0,
|
|
109
114
|
left: J?.left ?? 0,
|
|
110
115
|
visibility: J ? void 0 : "hidden"
|
|
111
116
|
},
|
|
112
|
-
tabIndex:
|
|
113
|
-
onMouseEnter:
|
|
114
|
-
onMouseLeave:
|
|
115
|
-
onBlur:
|
|
116
|
-
children: [Z.title && /* @__PURE__ */
|
|
117
|
+
tabIndex: S ? -1 : void 0,
|
|
118
|
+
onMouseEnter: S ? H : void 0,
|
|
119
|
+
onMouseLeave: S ? G : void 0,
|
|
120
|
+
onBlur: S ? K : void 0,
|
|
121
|
+
children: [Z.title && /* @__PURE__ */ d("span", {
|
|
117
122
|
className: "kapi-annotation__title",
|
|
118
123
|
children: Z.title
|
|
119
|
-
}), /* @__PURE__ */
|
|
124
|
+
}), /* @__PURE__ */ d("span", {
|
|
120
125
|
className: "kapi-annotation__body",
|
|
121
126
|
children: Z.body
|
|
122
127
|
})]
|
|
@@ -124,4 +129,4 @@ function v({ children: v, info: y, underline: b = "dotted", tone: x = "primary",
|
|
|
124
129
|
});
|
|
125
130
|
}
|
|
126
131
|
//#endregion
|
|
127
|
-
export {
|
|
132
|
+
export { _ as KapiAnnotation };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { HTMLAttributes, Ref } from "react";
|
|
2
|
-
import { type KapiTone } from "../tone.js";
|
|
2
|
+
import { type KapiFamilyTone, type KapiTone } from "../tone.js";
|
|
3
3
|
export type KapiAvatarSize = "sm" | "md" | "lg" | number;
|
|
4
|
-
/** Tono de un avatar: `auto` (según el nombre)
|
|
5
|
-
export type KapiAvatarTone = "auto" | KapiTone;
|
|
4
|
+
/** Tono de un avatar: `auto` (según el nombre), un `KapiTone` o una familia propia de la app. */
|
|
5
|
+
export type KapiAvatarTone = "auto" | KapiTone | KapiFamilyTone;
|
|
6
6
|
/** @deprecated Usar `KapiAvatarTone`. */
|
|
7
7
|
export type KapiAvatarColor = KapiAvatarTone;
|
|
8
8
|
export type KapiAvatarProps = Omit<HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
@@ -24,9 +24,11 @@ export type KapiAvatarProps = Omit<HTMLAttributes<HTMLSpanElement>, "children">
|
|
|
24
24
|
/** Orden fijo de los roles para el color automático (cambiarlo cambia los colores de todos). */
|
|
25
25
|
export declare const AVATAR_ROLES: ReadonlyArray<KapiTone>;
|
|
26
26
|
/** Clases de un avatar. Pura y exportada. */
|
|
27
|
-
export declare const avatarClasses: ({ size, role, className }: {
|
|
27
|
+
export declare const avatarClasses: ({ size, role, family, className }: {
|
|
28
28
|
size?: KapiAvatarSize | undefined;
|
|
29
29
|
role: KapiTone;
|
|
30
|
+
/** El color sale de una familia de la app: va por `--family`, que lee los slots locales. */
|
|
31
|
+
family?: boolean | undefined;
|
|
30
32
|
className?: string | undefined;
|
|
31
33
|
}) => string;
|
|
32
34
|
/** Avatar circular: imagen o iniciales sobre el color subtle del rol. */
|
|
@@ -1,45 +1,50 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/display/display.css";
|
|
3
|
-
import {
|
|
3
|
+
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { isFamilyTone as t, resolveTone as n } from "../tone.js";
|
|
4
5
|
/* empty css */
|
|
5
|
-
import { colorIndexFrom as
|
|
6
|
-
import { jsx as
|
|
6
|
+
import { colorIndexFrom as r, initialsFrom as i } from "./avatarLogic.js";
|
|
7
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
8
|
//#region src/components/display/KapiAvatar.tsx
|
|
8
|
-
var
|
|
9
|
+
var o = [
|
|
9
10
|
"primary",
|
|
10
11
|
"success",
|
|
11
12
|
"info",
|
|
12
13
|
"warning",
|
|
13
14
|
"danger",
|
|
14
15
|
"neutral"
|
|
15
|
-
],
|
|
16
|
+
], s = ({ size: e = "md", role: t, family: n = !1, className: r = "" }) => [
|
|
16
17
|
"kapi-avatar",
|
|
17
|
-
`kapi-avatar--${t}`,
|
|
18
|
+
n ? "kapi-avatar--family" : `kapi-avatar--${t}`,
|
|
18
19
|
typeof e == "string" && e !== "md" && `kapi-avatar--${e}`,
|
|
19
|
-
|
|
20
|
+
r
|
|
20
21
|
].filter(Boolean).join(" ");
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
width:
|
|
24
|
-
height:
|
|
25
|
-
fontSize: Math.round(
|
|
26
|
-
...
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
function c({ name: c = "", initials: l, src: u, size: d = "md", tone: f, color: p, className: m, style: h, ...g }) {
|
|
23
|
+
let _ = n(f, p, "auto"), v = t(_), y = e("KapiAvatar", v ? _ : void 0), b = v || _ === "auto" ? o[r(c, o.length)] ?? "neutral" : _, x = c || l || "", S = typeof d == "number" ? d : void 0, C = S === void 0 ? h : {
|
|
24
|
+
width: S,
|
|
25
|
+
height: S,
|
|
26
|
+
fontSize: Math.round(S * .38),
|
|
27
|
+
...h
|
|
28
|
+
}, w = y.style ? {
|
|
29
|
+
...y.style,
|
|
30
|
+
...C
|
|
31
|
+
} : C;
|
|
32
|
+
return /* @__PURE__ */ a("span", {
|
|
33
|
+
className: s({
|
|
34
|
+
size: d,
|
|
35
|
+
role: b,
|
|
36
|
+
family: y.style !== void 0,
|
|
37
|
+
className: m
|
|
33
38
|
}),
|
|
34
|
-
style:
|
|
35
|
-
role:
|
|
36
|
-
"aria-label":
|
|
37
|
-
...
|
|
38
|
-
children:
|
|
39
|
-
src:
|
|
40
|
-
alt:
|
|
41
|
-
}) :
|
|
39
|
+
style: w,
|
|
40
|
+
role: u || !x ? void 0 : "img",
|
|
41
|
+
"aria-label": u || !x ? void 0 : x,
|
|
42
|
+
...g,
|
|
43
|
+
children: u ? /* @__PURE__ */ a("img", {
|
|
44
|
+
src: u,
|
|
45
|
+
alt: c
|
|
46
|
+
}) : l ?? i(c)
|
|
42
47
|
});
|
|
43
48
|
}
|
|
44
49
|
//#endregion
|
|
45
|
-
export {
|
|
50
|
+
export { o as AVATAR_ROLES, c as KapiAvatar, s as avatarClasses };
|
|
@@ -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)
|
|
14
|
-
* acá están deprecados: la
|
|
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?:
|
|
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 {
|
|
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
|
|
6
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
7
|
//#region src/components/display/KapiBadge.tsx
|
|
7
|
-
var
|
|
8
|
-
let
|
|
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--${
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
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
|
-
}),
|
|
35
|
+
}), u]
|
|
30
36
|
});
|
|
31
37
|
}
|
|
32
38
|
//#endregion
|
|
33
|
-
export {
|
|
39
|
+
export { o as KapiBadge, a as badgeClasses };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode, Ref } from "react";
|
|
2
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
3
|
+
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
4
|
+
/** Textos de `KapiCodeBlock`; se pisan con `labels` o el `KapiLocaleProvider`. */
|
|
5
|
+
export type KapiCodeBlockLabels = {
|
|
6
|
+
/** Nombre accesible de la región, con `{lang}` = el lenguaje si se pasó. */
|
|
7
|
+
region: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const DEFAULT_CODE_BLOCK_LABELS: KapiCodeBlockLabels;
|
|
10
|
+
/** Atributos nativos (`id`, `style`, `data-*`…) van al `<figure>` raíz. */
|
|
11
|
+
export type KapiCodeBlockProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & {
|
|
12
|
+
/** Ref al `<figure>` raíz. */
|
|
13
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
14
|
+
/** El código, tal cual. Es lo que se copia, aunque `children` dibuje otra cosa. */
|
|
15
|
+
code: string;
|
|
16
|
+
/**
|
|
17
|
+
* El código ya resaltado. Sin esto se dibuja `code` plano.
|
|
18
|
+
*
|
|
19
|
+
* El resaltado lo inyecta la app a propósito: un highlighter adentro rompería la regla de cero
|
|
20
|
+
* dependencias de runtime, y además cada app ya tiene el suyo. Lo que se COPIA sigue saliendo de
|
|
21
|
+
* `code`, así que el resaltado nunca puede ensuciar el portapapeles.
|
|
22
|
+
*/
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
/** Lenguaje, para el rótulo y el `data-lang`. No cambia el dibujo. */
|
|
25
|
+
lang?: string | undefined;
|
|
26
|
+
/** Título sobre el bloque (nombre de archivo, ruta). */
|
|
27
|
+
title?: ReactNode;
|
|
28
|
+
/** Oculta el botón de copiar. @default false */
|
|
29
|
+
noCopy?: boolean | undefined;
|
|
30
|
+
/** Avisa el resultado REAL de copiar: `true` sólo si el portapapeles aceptó. */
|
|
31
|
+
onCopy?: ((ok: boolean) => void) | undefined;
|
|
32
|
+
/** Numera las líneas. @default false */
|
|
33
|
+
lineNumbers?: boolean | undefined;
|
|
34
|
+
/** Textos propios; pisan los del `KapiLocaleProvider` y los defaults. */
|
|
35
|
+
labels?: KapiLabelsOverride<KapiCodeBlockLabels> | undefined;
|
|
36
|
+
/** Clases por parte (`root`, `bar`, `title`, `copy`, `pre`, `numbers`, `code`). */
|
|
37
|
+
classNames?: KapiClassNames<"codeBlock"> | undefined;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Bloque de código con botón de copiar.
|
|
41
|
+
*
|
|
42
|
+
* Dos cosas que no se deducen del markup. **Lo que se copia es `code`, no lo que se ve**: si la
|
|
43
|
+
* app inyecta su resaltado por `children`, el portapapeles igual recibe el texto limpio, sin los
|
|
44
|
+
* `<span>` del highlighter ni los números de línea. Y **el botón confirma sólo si copió de
|
|
45
|
+
* verdad**, porque usa `KapiCopyButton`: en http sin TLS el portapapeles no existe y un «Copiado»
|
|
46
|
+
* ahí sería mentira.
|
|
47
|
+
*/
|
|
48
|
+
export declare function KapiCodeBlock({ code, children, lang, title, noCopy, onCopy, lineNumbers, labels, classNames, className, ...rest }: KapiCodeBlockProps): import("react").JSX.Element;
|