@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,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/KapiAutocomplete.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
4
|
+
import { assignRef as t, fieldControlProps as n, joinIds as r, resolveFieldMessage as ee, resolveReadOnly as te } from "./fieldLogic.js";
|
|
5
|
+
import { useOwnField as ne } from "./ownField.js";
|
|
6
6
|
import { inputClasses as re } from "./KapiInput.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useControllableState as ie } from "../../hooks/useControllableState.js";
|
|
8
|
+
import { enabledIndexes as ae, nextEnabledIndex as oe } from "../overlays/menuKeyboardLogic.js";
|
|
9
9
|
import { resolveKapiRoot as se } from "../../hooks/kapiRoot.js";
|
|
10
10
|
import { AUTOCOMPLETE_MENU_PLACEMENT as ce, clampActiveIndex as le, defaultGetLabel as ue, filterOptions as de, highlightParts as fe, shouldOpen as pe } from "./autocompleteLogic.js";
|
|
11
11
|
import { usePlacement as me } from "../../hooks/usePlacement.js";
|
|
@@ -23,165 +23,166 @@ var l = {
|
|
|
23
23
|
data: [],
|
|
24
24
|
error: !1
|
|
25
25
|
}, d = (d) => {
|
|
26
|
-
let { value: xe, defaultValue: Se, onChange: Ce, onSelect: f, getLabel: p, getKey: m, renderOption: h, fillOnSelect: g = !0, minChars: we = 0, maxResults: _ = 8, loadDelay: Te, debounceMs: Ee, emptyMessage: De, loadingMessage: Oe, noResultsText: ke, loadingText: Ae, labels: je, size: Me, invalid: v, status: y, label: Ne, required: b, help:
|
|
27
|
-
id:
|
|
26
|
+
let { value: xe, defaultValue: Se, onChange: Ce, onSelect: f, getLabel: p, getKey: m, renderOption: h, fillOnSelect: g = !0, minChars: we = 0, maxResults: _ = 8, loadDelay: Te, debounceMs: Ee, emptyMessage: De, loadingMessage: Oe, noResultsText: ke, loadingText: Ae, labels: je, size: Me, invalid: v, status: y, label: Ne, required: b, help: x, error: S, fieldClassName: Pe, className: Fe, readOnly: C, ref: w, options: T, loadOptions: E, id: Ie, onFocus: Le, onBlur: Re, onKeyDown: ze, ...D } = d, O = e("autocomplete", l, je), Be = De ?? ke ?? O.noResults, Ve = Oe ?? Ae ?? O.loading, He = Te ?? Ee ?? 250, [k, A] = ie(xe, Se ?? "", Ce), { invalid: Ue, status: We } = ee(S, x, v, y), j = ne({
|
|
27
|
+
id: Ie,
|
|
28
28
|
label: Ne,
|
|
29
|
-
help:
|
|
29
|
+
help: x,
|
|
30
|
+
error: S,
|
|
30
31
|
required: b,
|
|
31
32
|
invalid: v,
|
|
32
33
|
status: y,
|
|
33
|
-
readOnly:
|
|
34
|
-
fieldClassName:
|
|
35
|
-
}),
|
|
36
|
-
|
|
37
|
-
}, [
|
|
34
|
+
readOnly: C,
|
|
35
|
+
fieldClassName: Pe
|
|
36
|
+
}), M = te(C, j.field), N = j.controlId ?? j.autoId, P = `${N}-listbox`, { helpId: Ge } = j, F = (e) => `${N}-opt-${e}`, I = p ?? ue, Ke = i((e) => {
|
|
37
|
+
t(w, e);
|
|
38
|
+
}, [w]), [qe, L] = o(!1), [Je, R] = o(!1), [Ye, z] = o(-1), B = a(null), V = a(null), H = a(null), U = E !== void 0, W = !M && pe({
|
|
38
39
|
focused: qe,
|
|
39
40
|
dismissed: Je,
|
|
40
|
-
query:
|
|
41
|
+
query: k,
|
|
41
42
|
minChars: we
|
|
42
|
-
}),
|
|
43
|
-
query:
|
|
44
|
-
enabled:
|
|
45
|
-
load:
|
|
43
|
+
}), G = k.trim(), K = he({
|
|
44
|
+
query: G,
|
|
45
|
+
enabled: U && W,
|
|
46
|
+
load: E,
|
|
46
47
|
delay: He,
|
|
47
48
|
revalidate: !0,
|
|
48
49
|
initial: u
|
|
49
|
-
}).last ?? u,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
}).last ?? u, q = U && W && K.key !== G, Xe = ve(() => U ? (K.data ?? []).slice(0, _ > 0 ? _ : void 0) : de(T ?? [], k, I, _), [
|
|
51
|
+
U,
|
|
52
|
+
K.data,
|
|
53
|
+
T,
|
|
54
|
+
k,
|
|
54
55
|
_
|
|
55
|
-
]),
|
|
56
|
+
]), J = q ? [] : Xe, Y = le(Ye, J.length);
|
|
56
57
|
ge(() => {
|
|
57
|
-
if (!
|
|
58
|
-
let e =
|
|
58
|
+
if (!W || Y < 0) return;
|
|
59
|
+
let e = B.current?.children[Y];
|
|
59
60
|
e instanceof HTMLElement && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
|
|
60
|
-
}, [
|
|
61
|
-
let
|
|
62
|
-
open:
|
|
63
|
-
anchor:
|
|
64
|
-
floatingRef:
|
|
61
|
+
}, [W, Y]);
|
|
62
|
+
let X = W && !q && J.length === 0, Z = W && (q || J.length > 0 || X), { placement: Ze, style: Qe, update: Q } = me({
|
|
63
|
+
open: Z,
|
|
64
|
+
anchor: V,
|
|
65
|
+
floatingRef: H,
|
|
65
66
|
...ce,
|
|
66
67
|
offset: be
|
|
67
68
|
});
|
|
68
69
|
_e(() => {
|
|
69
|
-
|
|
70
|
+
Z && Q();
|
|
70
71
|
}, [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
Z,
|
|
73
|
+
J.length,
|
|
74
|
+
q,
|
|
75
|
+
Q
|
|
75
76
|
]);
|
|
76
|
-
let
|
|
77
|
-
g &&
|
|
77
|
+
let $e = i((e) => {
|
|
78
|
+
g && A(I(e)), f?.(e), R(!0), z(-1);
|
|
78
79
|
}, [
|
|
79
80
|
g,
|
|
80
|
-
|
|
81
|
+
A,
|
|
81
82
|
f,
|
|
82
83
|
p
|
|
83
|
-
]),
|
|
84
|
-
|
|
85
|
-
},
|
|
84
|
+
]), et = (e) => {
|
|
85
|
+
A(e.target.value), R(!1), z(-1);
|
|
86
|
+
}, tt = (e) => {
|
|
86
87
|
if (ze?.(e), !e.defaultPrevented) switch (e.key) {
|
|
87
88
|
case "ArrowDown":
|
|
88
89
|
case "ArrowUp":
|
|
89
|
-
if (e.preventDefault(), !
|
|
90
|
-
|
|
90
|
+
if (e.preventDefault(), !W) {
|
|
91
|
+
R(!1);
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
z(oe(Y, e.key === "ArrowDown" ? "next" : "prev", ae(J.length)));
|
|
94
95
|
break;
|
|
95
96
|
case "Enter":
|
|
96
|
-
if (
|
|
97
|
+
if (W && Y >= 0) {
|
|
97
98
|
e.preventDefault();
|
|
98
|
-
let t =
|
|
99
|
-
t !== void 0 &&
|
|
99
|
+
let t = J[Y];
|
|
100
|
+
t !== void 0 && $e(t);
|
|
100
101
|
}
|
|
101
102
|
break;
|
|
102
|
-
case "Escape":
|
|
103
|
+
case "Escape": W && (e.preventDefault(), e.stopPropagation(), R(!0), z(-1));
|
|
103
104
|
}
|
|
104
|
-
}, tt = (e) => {
|
|
105
|
-
I(!0), L(!1), T?.(e);
|
|
106
105
|
}, nt = (e) => {
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
L(!0), R(!1), Le?.(e);
|
|
107
|
+
}, rt = (e) => {
|
|
108
|
+
L(!1), z(-1), Re?.(e);
|
|
109
|
+
}, $ = Z ? se(V.current) : null, it = /* @__PURE__ */ c("div", {
|
|
110
|
+
ref: V,
|
|
111
|
+
className: ["kapi-ac", q && "kapi-ac--loading"].filter(Boolean).join(" "),
|
|
111
112
|
children: [
|
|
112
113
|
/* @__PURE__ */ s("input", {
|
|
113
|
-
...
|
|
114
|
+
...D,
|
|
114
115
|
ref: Ke,
|
|
115
116
|
type: "text",
|
|
116
117
|
role: "combobox",
|
|
117
118
|
autoComplete: "off",
|
|
118
119
|
"aria-autocomplete": "list",
|
|
119
|
-
"aria-expanded":
|
|
120
|
-
"aria-controls":
|
|
121
|
-
"aria-activedescendant":
|
|
122
|
-
...
|
|
123
|
-
id:
|
|
124
|
-
describedBy:
|
|
125
|
-
busy:
|
|
120
|
+
"aria-expanded": Z,
|
|
121
|
+
"aria-controls": P,
|
|
122
|
+
"aria-activedescendant": Z && Y >= 0 ? F(Y) : void 0,
|
|
123
|
+
...n(j.outer, {
|
|
124
|
+
id: N,
|
|
125
|
+
describedBy: r(Ge, D["aria-describedby"]),
|
|
126
|
+
busy: q || void 0,
|
|
126
127
|
invalid: Ue
|
|
127
128
|
}),
|
|
128
129
|
required: b,
|
|
129
|
-
readOnly:
|
|
130
|
+
readOnly: M || void 0,
|
|
130
131
|
className: re({
|
|
131
132
|
size: Me,
|
|
132
133
|
status: We,
|
|
133
|
-
className:
|
|
134
|
+
className: Fe
|
|
134
135
|
}),
|
|
135
|
-
value:
|
|
136
|
-
onChange:
|
|
137
|
-
onKeyDown:
|
|
138
|
-
onFocus:
|
|
139
|
-
onBlur:
|
|
136
|
+
value: k,
|
|
137
|
+
onChange: et,
|
|
138
|
+
onKeyDown: tt,
|
|
139
|
+
onFocus: nt,
|
|
140
|
+
onBlur: rt
|
|
140
141
|
}),
|
|
141
|
-
|
|
142
|
+
q && /* @__PURE__ */ s("span", {
|
|
142
143
|
className: "kapi-ac__spinner kapi-spinner kapi-spinner--sm",
|
|
143
144
|
"aria-hidden": "true"
|
|
144
145
|
}),
|
|
145
146
|
$ && ye(/* @__PURE__ */ c("div", {
|
|
146
|
-
ref:
|
|
147
|
+
ref: H,
|
|
147
148
|
className: "kapi-ac__menu",
|
|
148
149
|
"data-side": Ze?.side ?? "bottom",
|
|
149
150
|
style: Qe,
|
|
150
151
|
onMouseDown: (e) => e.preventDefault(),
|
|
151
152
|
children: [/* @__PURE__ */ s("ul", {
|
|
152
|
-
ref:
|
|
153
|
-
id:
|
|
153
|
+
ref: B,
|
|
154
|
+
id: P,
|
|
154
155
|
role: "listbox",
|
|
155
156
|
className: "kapi-ac__list",
|
|
156
|
-
hidden:
|
|
157
|
-
children:
|
|
158
|
-
let n =
|
|
157
|
+
hidden: J.length === 0,
|
|
158
|
+
children: J.map((e, t) => {
|
|
159
|
+
let n = I(e), r = t === Y;
|
|
159
160
|
return /* @__PURE__ */ s("li", {
|
|
160
|
-
id:
|
|
161
|
+
id: F(t),
|
|
161
162
|
role: "option",
|
|
162
163
|
"aria-selected": r,
|
|
163
164
|
className: ["kapi-ac__opt", r && "kapi-ac__opt--active"].filter(Boolean).join(" "),
|
|
164
|
-
onMouseEnter: () =>
|
|
165
|
-
onClick: () =>
|
|
165
|
+
onMouseEnter: () => z(t),
|
|
166
|
+
onClick: () => $e(e),
|
|
166
167
|
children: h ? h(e, {
|
|
167
|
-
query:
|
|
168
|
+
query: k,
|
|
168
169
|
active: r
|
|
169
|
-
}) : fe(n,
|
|
170
|
+
}) : fe(n, k).map((e, t) => e.match ? /* @__PURE__ */ s("mark", {
|
|
170
171
|
className: "kapi-ac__mark",
|
|
171
172
|
children: e.text
|
|
172
173
|
}, t) : /* @__PURE__ */ s("span", { children: e.text }, t))
|
|
173
174
|
}, m ? m(e) : `${n}-${t}`);
|
|
174
175
|
})
|
|
175
|
-
}), (
|
|
176
|
+
}), (q || X) && /* @__PURE__ */ s("div", {
|
|
176
177
|
className: "kapi-ac__status",
|
|
177
178
|
role: "status",
|
|
178
179
|
"aria-live": "polite",
|
|
179
|
-
children:
|
|
180
|
+
children: q ? Ve : Be
|
|
180
181
|
})]
|
|
181
182
|
}), $)
|
|
182
183
|
]
|
|
183
184
|
});
|
|
184
|
-
return
|
|
185
|
+
return j.wrap(it);
|
|
185
186
|
};
|
|
186
187
|
//#endregion
|
|
187
188
|
export { l as DEFAULT_AUTOCOMPLETE_LABELS, d as KapiAutocomplete };
|
|
@@ -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;
|