@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,58 +1,63 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/KapiButton.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { renderSlot as t } from "../renderSlot.js";
|
|
5
|
+
import { buttonLookModifier as n, isFamilyTone as r, resolveButtonLook as i } from "../tone.js";
|
|
5
6
|
/* empty css */
|
|
6
|
-
import { Fragment as
|
|
7
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
8
|
//#region src/components/inputs/KapiButton.tsx
|
|
8
|
-
var
|
|
9
|
-
let
|
|
9
|
+
var c = ({ tone: e, variant: t, size: a = "md", iconOnly: o = !1, bordered: s = !1, loading: c = !1, className: l = "" } = {}) => {
|
|
10
|
+
let u = r(e) ? `family-${i(void 0, t).appearance}` : n(i(e, t));
|
|
10
11
|
return [
|
|
11
12
|
"kapi-btn",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
u !== null && `kapi-btn--${u}`,
|
|
14
|
+
a !== "md" && `kapi-btn--${a}`,
|
|
15
|
+
o && "kapi-btn--iconbtn",
|
|
16
|
+
s && "kapi-btn--bordered",
|
|
17
|
+
c && "is-loading",
|
|
18
|
+
l
|
|
18
19
|
].filter(Boolean).join(" ");
|
|
19
|
-
},
|
|
20
|
-
let
|
|
20
|
+
}, l = ({ tone: n, variant: r, size: i = "md", iconOnly: l = !1, bordered: u = !1, icon: d, loading: f = !1, disabled: p, className: m, style: h, type: g = "button", children: _, ref: v, render: y, ...b }) => {
|
|
21
|
+
let x = e("KapiButton", n), S = f || p, C = f ? /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("span", {
|
|
21
22
|
className: "kapi-spinner kapi-btn__spinner",
|
|
22
23
|
"aria-hidden": "true"
|
|
23
|
-
}), /* @__PURE__ */
|
|
24
|
+
}), /* @__PURE__ */ s("span", {
|
|
24
25
|
className: "kapi-btn__content",
|
|
25
|
-
children: [
|
|
26
|
-
})] }) : /* @__PURE__ */ a
|
|
27
|
-
className:
|
|
28
|
-
tone:
|
|
29
|
-
variant:
|
|
30
|
-
size:
|
|
31
|
-
iconOnly:
|
|
32
|
-
bordered:
|
|
33
|
-
loading:
|
|
34
|
-
className:
|
|
26
|
+
children: [d, _]
|
|
27
|
+
})] }) : /* @__PURE__ */ s(a, { children: [d, _] }), w = {
|
|
28
|
+
className: c({
|
|
29
|
+
tone: x.tone,
|
|
30
|
+
variant: r,
|
|
31
|
+
size: i,
|
|
32
|
+
iconOnly: l,
|
|
33
|
+
bordered: u,
|
|
34
|
+
loading: f,
|
|
35
|
+
className: m
|
|
35
36
|
}),
|
|
36
|
-
...
|
|
37
|
+
...x.style || h ? { style: {
|
|
38
|
+
...x.style,
|
|
39
|
+
...h
|
|
40
|
+
} } : {},
|
|
41
|
+
...b
|
|
37
42
|
};
|
|
38
|
-
return
|
|
39
|
-
ref:
|
|
40
|
-
type:
|
|
41
|
-
...
|
|
42
|
-
disabled:
|
|
43
|
-
...
|
|
44
|
-
children:
|
|
45
|
-
}) :
|
|
46
|
-
"aria-disabled":
|
|
47
|
-
"aria-busy":
|
|
48
|
-
onClick:
|
|
49
|
-
ref:
|
|
50
|
-
children:
|
|
51
|
-
}, (e) => /* @__PURE__ */
|
|
43
|
+
return y === void 0 ? /* @__PURE__ */ o("button", {
|
|
44
|
+
ref: v,
|
|
45
|
+
type: g,
|
|
46
|
+
...w,
|
|
47
|
+
disabled: S,
|
|
48
|
+
...f ? { "aria-busy": !0 } : {},
|
|
49
|
+
children: C
|
|
50
|
+
}) : t(y, w, {
|
|
51
|
+
"aria-disabled": S || void 0,
|
|
52
|
+
"aria-busy": f || void 0,
|
|
53
|
+
onClick: S ? (e) => e.preventDefault() : void 0,
|
|
54
|
+
ref: v,
|
|
55
|
+
children: C
|
|
56
|
+
}, (e) => /* @__PURE__ */ o("button", {
|
|
52
57
|
...e,
|
|
53
|
-
type:
|
|
54
|
-
children:
|
|
58
|
+
type: g,
|
|
59
|
+
children: C
|
|
55
60
|
}));
|
|
56
61
|
};
|
|
57
62
|
//#endregion
|
|
58
|
-
export {
|
|
63
|
+
export { l as KapiButton, c as buttonClasses };
|
|
@@ -37,6 +37,12 @@ export type KapiChecklistProps<Id extends string = string> = Omit<HTMLAttributes
|
|
|
37
37
|
label?: ReactNode | undefined;
|
|
38
38
|
/** Ayuda / mensaje de error bajo la lista (la envuelve en un `KapiField` sin etiqueta). */
|
|
39
39
|
help?: ReactNode | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
|
|
42
|
+
* `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
|
|
43
|
+
* Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
|
|
44
|
+
*/
|
|
45
|
+
error?: ReactNode | undefined;
|
|
40
46
|
/** Clase del `KapiField` propio (con `help`). `className` va a la raíz de la lista. */
|
|
41
47
|
fieldClassName?: string | undefined;
|
|
42
48
|
/**
|
|
@@ -74,4 +80,4 @@ export type KapiChecklistProps<Id extends string = string> = Omit<HTMLAttributes
|
|
|
74
80
|
* desde el último alternado, Shift + flechas extienden la selección y Ctrl/Cmd + A marca o desmarca
|
|
75
81
|
* todo lo visible. Tipear con la lista enfocada escribe en el buscador.
|
|
76
82
|
*/
|
|
77
|
-
export declare function KapiChecklist<Id extends string = string>({ items, value, defaultValue, onChange, label, help, fieldClassName, readOnly: readOnlyProp, invalid, required, searchable, query: queryProp, defaultQuery, onQueryChange, selectAll, rangeSelect, disabled, labels, className, "aria-label": ariaLabel, ...rest }: KapiChecklistProps<Id>): ReactNode;
|
|
83
|
+
export declare function KapiChecklist<Id extends string = string>({ items, value, defaultValue, onChange, label, help, error, fieldClassName, readOnly: readOnlyProp, invalid, required, searchable, query: queryProp, defaultQuery, onQueryChange, selectAll, rangeSelect, disabled, labels, className, "aria-label": ariaLabel, ...rest }: KapiChecklistProps<Id>): ReactNode;
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/KapiChecklist.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 { fieldControlProps as n, resolveReadOnly as r } from "./fieldLogic.js";
|
|
6
|
+
import { useOwnField as i } from "./ownField.js";
|
|
7
7
|
import { KapiInput as ee } from "./KapiInput.js";
|
|
8
|
+
import { useControllableState as a } from "../../hooks/useControllableState.js";
|
|
8
9
|
import { useRangeSelect as te } from "../../hooks/useRangeSelect.js";
|
|
9
|
-
import { navKeyOf as ne, nextEnabledIndex as
|
|
10
|
-
import { checklistBulkState as re, filterChecklistItems as
|
|
10
|
+
import { navKeyOf as ne, nextEnabledIndex as o } from "../overlays/menuKeyboardLogic.js";
|
|
11
|
+
import { checklistBulkState as re, filterChecklistItems as ie, orderedChecklistValue as ae, setChecklistItems as oe } from "./checklistLogic.js";
|
|
11
12
|
/* empty css */
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { Check as ce, Search as p } from "lucide-react";
|
|
13
|
+
import { useEffect as se, useId as ce, useMemo as s, useRef as c, useState as l } from "react";
|
|
14
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
15
|
+
import { Check as f, Search as le } from "lucide-react";
|
|
16
16
|
//#region src/components/inputs/KapiChecklist.tsx
|
|
17
|
-
var
|
|
17
|
+
var p = {
|
|
18
18
|
search: "Buscar en la lista",
|
|
19
19
|
searchPlaceholder: "Buscar…",
|
|
20
20
|
selectAll: "Marcar todo",
|
|
21
21
|
clearAll: "Desmarcar todo",
|
|
22
22
|
empty: "Sin coincidencias"
|
|
23
|
-
},
|
|
24
|
-
function
|
|
25
|
-
let D =
|
|
26
|
-
help:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
}, m = 7;
|
|
24
|
+
function h({ items: m, value: h, defaultValue: ue, onChange: de, label: g, help: fe, error: _, fieldClassName: pe, readOnly: v, invalid: y, required: b, searchable: x, query: S, defaultQuery: C, onQueryChange: w, selectAll: me = !1, rangeSelect: T = !0, disabled: E = !1, labels: he, className: ge, "aria-label": _e, ...ve }) {
|
|
25
|
+
let D = t("checklist", p, he), O = i({
|
|
26
|
+
help: fe,
|
|
27
|
+
error: _,
|
|
28
|
+
required: b,
|
|
29
|
+
invalid: y,
|
|
30
|
+
readOnly: v,
|
|
31
|
+
fieldClassName: pe
|
|
32
|
+
}), k = O.field, A = r(v, k), j = ce(), M = `${j}-label`, N = c(null), P = c(null), [F, ye] = a(h, ue ?? [], de), I = s(() => new Set(F), [F]), L = (e) => {
|
|
33
|
+
A || ye(ae(m, e));
|
|
34
|
+
}, [R, z] = a(S, C ?? "", w), B = x ?? m.length > 7, V = s(() => ie(m, R), [m, R]), H = s(() => V.map((e) => e.id), [V]), U = s(() => E ? [] : V.flatMap((e, t) => e.disabled ? [] : [t]), [V, E]), W = (e) => !E && m.some((t) => t.id === e && !t.disabled), G = te(), [K, q] = l(null), J = K === null ? -1 : H.indexOf(K), Y = (e) => `${j}-opt-${m.findIndex((t) => t.id === e)}`;
|
|
35
|
+
se(() => {
|
|
35
36
|
J < 0 || N.current?.querySelector(`[data-index="${J}"]`)?.scrollIntoView?.({ block: "nearest" });
|
|
36
37
|
}, [J]);
|
|
37
38
|
let X = (e, t) => {
|
|
@@ -43,13 +44,13 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
|
|
|
43
44
|
isSelectable: W
|
|
44
45
|
}));
|
|
45
46
|
}, Z = re(V, I), Q = (e) => {
|
|
46
|
-
E || L(
|
|
47
|
-
},
|
|
47
|
+
E || L(oe(m, I, H, e));
|
|
48
|
+
}, be = (e) => {
|
|
48
49
|
if (E) return;
|
|
49
50
|
let t = ne(e.key, "vertical");
|
|
50
51
|
if (t) {
|
|
51
52
|
e.preventDefault();
|
|
52
|
-
let n =
|
|
53
|
+
let n = o(J, t, U);
|
|
53
54
|
if (n < 0) return;
|
|
54
55
|
let r = t === "next" && n < J || t === "prev" && n > J;
|
|
55
56
|
if (e.shiftKey && T && J >= 0) {
|
|
@@ -65,22 +66,22 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
|
|
|
65
66
|
}
|
|
66
67
|
q(H[n]);
|
|
67
68
|
} else e.key === " " || e.key === "Enter" ? (e.preventDefault(), K !== null && J >= 0 && X(K, e.shiftKey)) : (e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a" ? (e.preventDefault(), Q(Z !== "all")) : B && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), z(R + e.key), P.current?.focus());
|
|
68
|
-
},
|
|
69
|
+
}, xe = () => {
|
|
69
70
|
J < 0 && U.length > 0 && q(H[U[0]]), N.current?.focus();
|
|
70
|
-
},
|
|
71
|
-
invalid:
|
|
72
|
-
required:
|
|
71
|
+
}, Se = g == null ? { "aria-label": _e } : { "aria-labelledby": M }, $ = n(k, {
|
|
72
|
+
invalid: y,
|
|
73
|
+
required: b
|
|
73
74
|
});
|
|
74
|
-
return O.wrap(/* @__PURE__ */
|
|
75
|
-
...
|
|
76
|
-
className: e("kapi-checklist", E && "is-disabled", A && "is-readonly",
|
|
75
|
+
return O.wrap(/* @__PURE__ */ d("div", {
|
|
76
|
+
...ve,
|
|
77
|
+
className: e("kapi-checklist", E && "is-disabled", A && "is-readonly", ge),
|
|
77
78
|
children: [
|
|
78
|
-
|
|
79
|
+
g != null && /* @__PURE__ */ u("div", {
|
|
79
80
|
id: M,
|
|
80
81
|
className: "kapi-checklist__label",
|
|
81
|
-
children:
|
|
82
|
+
children: g
|
|
82
83
|
}),
|
|
83
|
-
B && /* @__PURE__ */
|
|
84
|
+
B && /* @__PURE__ */ u(ee, {
|
|
84
85
|
ref: P,
|
|
85
86
|
type: "search",
|
|
86
87
|
size: "sm",
|
|
@@ -88,30 +89,30 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
|
|
|
88
89
|
"aria-label": D.search,
|
|
89
90
|
placeholder: D.searchPlaceholder,
|
|
90
91
|
spellCheck: !1,
|
|
91
|
-
startIcon: /* @__PURE__ */
|
|
92
|
+
startIcon: /* @__PURE__ */ u(le, {}),
|
|
92
93
|
clearable: !0,
|
|
93
94
|
disabled: E,
|
|
94
95
|
value: R,
|
|
95
96
|
onChange: (e) => z(e.target.value),
|
|
96
97
|
onKeyDown: (e) => {
|
|
97
|
-
(e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(),
|
|
98
|
+
(e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), xe());
|
|
98
99
|
}
|
|
99
100
|
}),
|
|
100
|
-
|
|
101
|
+
me && /* @__PURE__ */ d("div", {
|
|
101
102
|
className: "kapi-checklist__bulk",
|
|
102
|
-
children: [/* @__PURE__ */
|
|
103
|
+
children: [/* @__PURE__ */ u("button", {
|
|
103
104
|
type: "button",
|
|
104
105
|
disabled: E || A || Z === "all",
|
|
105
106
|
onClick: () => Q(!0),
|
|
106
107
|
children: D.selectAll
|
|
107
|
-
}), /* @__PURE__ */
|
|
108
|
+
}), /* @__PURE__ */ u("button", {
|
|
108
109
|
type: "button",
|
|
109
110
|
disabled: E || A || Z === "none",
|
|
110
111
|
onClick: () => Q(!1),
|
|
111
112
|
children: D.clearAll
|
|
112
113
|
})]
|
|
113
114
|
}),
|
|
114
|
-
V.length > 0 ? /* @__PURE__ */
|
|
115
|
+
V.length > 0 ? /* @__PURE__ */ u("div", {
|
|
115
116
|
ref: N,
|
|
116
117
|
role: "listbox",
|
|
117
118
|
"aria-multiselectable": "true",
|
|
@@ -123,14 +124,14 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
|
|
|
123
124
|
"aria-activedescendant": J >= 0 && K !== null ? Y(K) : void 0,
|
|
124
125
|
tabIndex: E ? -1 : 0,
|
|
125
126
|
className: "kapi-checklist__list",
|
|
126
|
-
onKeyDown:
|
|
127
|
+
onKeyDown: be,
|
|
127
128
|
onFocus: (e) => {
|
|
128
129
|
e.target === e.currentTarget && J < 0 && U.length > 0 && q(H[U[0]]);
|
|
129
130
|
},
|
|
130
|
-
...
|
|
131
|
+
...Se,
|
|
131
132
|
children: V.map((t, n) => {
|
|
132
133
|
let r = I.has(t.id), i = E || t.disabled === !0;
|
|
133
|
-
return /* @__PURE__ */
|
|
134
|
+
return /* @__PURE__ */ d("div", {
|
|
134
135
|
id: Y(t.id),
|
|
135
136
|
"data-index": n,
|
|
136
137
|
role: "option",
|
|
@@ -144,32 +145,32 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
|
|
|
144
145
|
onClick: (e) => {
|
|
145
146
|
i || (q(t.id), X(t.id, e.shiftKey));
|
|
146
147
|
},
|
|
147
|
-
children: [/* @__PURE__ */
|
|
148
|
+
children: [/* @__PURE__ */ u("span", {
|
|
148
149
|
className: "kapi-checklist__box",
|
|
149
150
|
"aria-hidden": "true",
|
|
150
|
-
children: r && /* @__PURE__ */
|
|
151
|
+
children: r && /* @__PURE__ */ u(f, {
|
|
151
152
|
size: 12,
|
|
152
153
|
strokeWidth: 3
|
|
153
154
|
})
|
|
154
|
-
}), /* @__PURE__ */
|
|
155
|
+
}), /* @__PURE__ */ d("span", {
|
|
155
156
|
className: "kapi-checklist__text",
|
|
156
|
-
children: [/* @__PURE__ */
|
|
157
|
+
children: [/* @__PURE__ */ u("span", {
|
|
157
158
|
className: "kapi-checklist__name",
|
|
158
159
|
children: t.label
|
|
159
|
-
}), t.description != null && /* @__PURE__ */
|
|
160
|
+
}), t.description != null && /* @__PURE__ */ u("span", {
|
|
160
161
|
className: "kapi-checklist__desc",
|
|
161
162
|
children: t.description
|
|
162
163
|
})]
|
|
163
164
|
})]
|
|
164
165
|
}, t.id);
|
|
165
166
|
})
|
|
166
|
-
}) : /* @__PURE__ */
|
|
167
|
+
}) : /* @__PURE__ */ u("div", {
|
|
167
168
|
className: "kapi-checklist__empty",
|
|
168
169
|
role: "status",
|
|
169
|
-
children:
|
|
170
|
+
children: m.length > 0 ? D.empty : null
|
|
170
171
|
})
|
|
171
172
|
]
|
|
172
173
|
}));
|
|
173
174
|
}
|
|
174
175
|
//#endregion
|
|
175
|
-
export {
|
|
176
|
+
export { m as CHECKLIST_SEARCH_THRESHOLD, p as DEFAULT_CHECKLIST_LABELS, h as KapiChecklist };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
3
|
+
import { type KapiButtonProps } from "./KapiButton.js";
|
|
4
|
+
export type KapiCopyButtonLabels = {
|
|
5
|
+
/** Nombre del botón en reposo. */
|
|
6
|
+
copy: string;
|
|
7
|
+
/** Nombre y texto mientras muestra que copió. */
|
|
8
|
+
copied: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const DEFAULT_COPY_BUTTON_LABELS: KapiCopyButtonLabels;
|
|
11
|
+
/** Cuánto dura el «Copiado» antes de volver al estado normal. */
|
|
12
|
+
export declare const COPY_FEEDBACK_MS = 2000;
|
|
13
|
+
/** Lo de `KapiButton` (tono, variante, tamaño, `render`…) más lo propio. */
|
|
14
|
+
export type KapiCopyButtonProps = Omit<KapiButtonProps, "onClick" | "children" | "icon"> & {
|
|
15
|
+
/** Ref al `<button>`. */
|
|
16
|
+
ref?: Ref<HTMLButtonElement> | undefined;
|
|
17
|
+
/** Lo que se copia. */
|
|
18
|
+
value: string;
|
|
19
|
+
/** Texto del botón. Sin esto queda sólo el ícono, con el nombre del locale. */
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Avisa el resultado REAL: `true` si el portapapeles aceptó, `false` si no había portapapeles o
|
|
23
|
+
* rechazó. No es un «se intentó»: con `false` el botón tampoco confirma.
|
|
24
|
+
*/
|
|
25
|
+
onCopy?: ((ok: boolean) => void) | undefined;
|
|
26
|
+
/** Textos propios (`copy`, `copied`). */
|
|
27
|
+
labels?: KapiLabelsOverride<KapiCopyButtonLabels> | undefined;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Botón que copia un valor y **confirma sólo si copió de verdad**.
|
|
31
|
+
*
|
|
32
|
+
* Eso último es todo el componente. El portapapeles pide contexto seguro y permiso: en http sin
|
|
33
|
+
* TLS `navigator.clipboard` ni existe, y la promesa puede rechazar. Un botón que dice «Copiado»
|
|
34
|
+
* pase lo que pase es peor que uno que no dice nada, porque la persona se va creyendo que tiene el
|
|
35
|
+
* valor y lo descubre al pegar.
|
|
36
|
+
*
|
|
37
|
+
* La confirmación vuelve sola a los 2 s (`COPY_FEEDBACK_MS`) y el temporizador se limpia al
|
|
38
|
+
* desmontar.
|
|
39
|
+
*/
|
|
40
|
+
export declare function KapiCopyButton({ value, children, onCopy, labels, ref, ...rest }: KapiCopyButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { KapiButton as e } from "./KapiButton.js";
|
|
3
|
+
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
4
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
5
|
+
import { copyText as r } from "./copyLogic.js";
|
|
6
|
+
import { present as i } from "./inputLogic.js";
|
|
7
|
+
import { useEffect as a, useRef as o, useState as s } from "react";
|
|
8
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
9
|
+
import { Check as l, Copy as u } from "lucide-react";
|
|
10
|
+
//#region src/components/inputs/KapiCopyButton.tsx
|
|
11
|
+
var d = {
|
|
12
|
+
copy: "Copiar",
|
|
13
|
+
copied: "Copiado"
|
|
14
|
+
}, f = 2e3;
|
|
15
|
+
function p({ value: p, children: m, onCopy: h, labels: g, ref: _, ...v }) {
|
|
16
|
+
let y = n("copyButton", d, g), [b, x] = s(!1), S = o(null), C = o(void 0), w = o(!0), T = t(S, _);
|
|
17
|
+
a(() => (w.current = !0, () => {
|
|
18
|
+
w.current = !1, clearTimeout(C.current);
|
|
19
|
+
}), []);
|
|
20
|
+
let E = async () => {
|
|
21
|
+
let e = await r(p, S.current);
|
|
22
|
+
w.current && (h?.(e), e && (x(!0), clearTimeout(C.current), C.current = setTimeout(() => x(!1), f)));
|
|
23
|
+
}, D = i(m), O = b ? y.copied : y.copy;
|
|
24
|
+
return /* @__PURE__ */ c(e, {
|
|
25
|
+
...v,
|
|
26
|
+
ref: T,
|
|
27
|
+
icon: c(b ? l : u, { "aria-hidden": "true" }),
|
|
28
|
+
iconOnly: !D,
|
|
29
|
+
"aria-label": D && !b ? void 0 : O,
|
|
30
|
+
onClick: () => void E(),
|
|
31
|
+
children: D ? b ? y.copied : m : void 0
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { f as COPY_FEEDBACK_MS, d as DEFAULT_COPY_BUTTON_LABELS, p as KapiCopyButton };
|
|
@@ -37,6 +37,12 @@ export type KapiDatePickerProps = {
|
|
|
37
37
|
label?: ReactNode | undefined;
|
|
38
38
|
/** Ayuda / mensaje de error bajo el campo (envuelve el picker en un `KapiField`). */
|
|
39
39
|
help?: ReactNode | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
|
|
42
|
+
* `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
|
|
43
|
+
* Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
|
|
44
|
+
*/
|
|
45
|
+
error?: ReactNode | undefined;
|
|
40
46
|
/** Clase del `KapiField` propio (con `label` o `help`). `className` va al envoltorio del picker. */
|
|
41
47
|
fieldClassName?: string | undefined;
|
|
42
48
|
/**
|
|
@@ -87,4 +93,4 @@ export type KapiDatePickerProps = {
|
|
|
87
93
|
* Con `label` o `icon` el campo se dibuja como el chip de `KapiDropdown` (la misma clase
|
|
88
94
|
* `.kapi-filterchip`), para una fila de filtros que mezcle los dos.
|
|
89
95
|
*/
|
|
90
|
-
export declare const KapiDatePicker: ({ mode, value, defaultValue, onChange, placeholder, variant, icon, chipLabel: chipLabelProp, label: labelProp, help, fieldClassName, readOnly: readOnlyProp, disabled, id, name, className, style, "aria-label": ariaLabel, labels, minuteStep, invalid, required, ref, onBlur: onBlurProp, weekStartsOn }: KapiDatePickerProps) => ReactNode;
|
|
96
|
+
export declare const KapiDatePicker: ({ mode, value, defaultValue, onChange, placeholder, variant, icon, chipLabel: chipLabelProp, label: labelProp, help, error, fieldClassName, readOnly: readOnlyProp, disabled, id, name, className, style, "aria-label": ariaLabel, labels, minuteStep, invalid, required, ref, onBlur: onBlurProp, weekStartsOn }: KapiDatePickerProps) => ReactNode;
|