@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,122 +1,123 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/KapiTagInput.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
5
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
6
|
+
import { assignRef as r, fieldControlProps as i, focusLeaves as a, joinIds as o, resolveReadOnly as ee } from "./fieldLogic.js";
|
|
7
|
+
import { useOwnField as s } from "./ownField.js";
|
|
8
|
+
import { useControllableState as te } from "../../hooks/useControllableState.js";
|
|
9
|
+
import { useFormReset as ne } from "../../hooks/useFormReset.js";
|
|
10
10
|
/* empty css */
|
|
11
|
-
import { addTags as re, hasSeparator as c, removeTagAt as l, spliceText as
|
|
12
|
-
import { KapiTag as
|
|
13
|
-
import { useCallback as
|
|
14
|
-
import { jsx as
|
|
11
|
+
import { addTags as re, hasSeparator as c, removeTagAt as l, spliceText as ie, splitDraft as ae, splitTags as u } from "./tagInputLogic.js";
|
|
12
|
+
import { KapiTag as oe } from "../display/KapiTag.js";
|
|
13
|
+
import { useCallback as d, useId as se, useRef as f, useState as p } from "react";
|
|
14
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/inputs/KapiTagInput.tsx
|
|
16
|
-
var
|
|
16
|
+
var g = {
|
|
17
17
|
remove: "Quitar",
|
|
18
18
|
duplicate: "Ya está en la lista:",
|
|
19
19
|
max: "Llegaste al máximo de"
|
|
20
|
-
},
|
|
21
|
-
function
|
|
22
|
-
let
|
|
20
|
+
}, _ = ({ size: t = "md", invalid: n, disabled: r, readOnly: i, className: a }) => e("kapi-taginput", t !== "md" && `kapi-taginput--${t}`, n && "kapi-taginput--err", r && "kapi-taginput--disabled", i && "kapi-taginput--readonly", a);
|
|
21
|
+
function v({ value: e, defaultValue: v = [], onChange: ce, validate: y, maxTags: b, allowDuplicates: le, caseSensitive: ue, placeholder: x, disabled: S = !1, size: C = "md", name: w, id: T, invalid: E, required: D, label: de, help: fe, error: pe, fieldClassName: O, readOnly: k, "aria-label": A, "aria-labelledby": j, "aria-describedby": M, onBlur: N, ref: P, labels: F, className: I, onClick: L, ...R }) {
|
|
22
|
+
let z = n("tagInput", g, F), B = s({
|
|
23
23
|
id: T,
|
|
24
24
|
label: de,
|
|
25
25
|
help: fe,
|
|
26
|
+
error: pe,
|
|
26
27
|
required: D,
|
|
27
28
|
invalid: E,
|
|
28
|
-
readOnly:
|
|
29
|
-
fieldClassName:
|
|
30
|
-
}),
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
let { values: n, rejected: r } = re(
|
|
34
|
-
validate:
|
|
35
|
-
maxTags:
|
|
36
|
-
allowDuplicates:
|
|
37
|
-
caseSensitive:
|
|
29
|
+
readOnly: k,
|
|
30
|
+
fieldClassName: O
|
|
31
|
+
}), V = B.field, H = ee(k, V), U = se(), [W, G, , me] = te(e, v, ce), [K, q] = p(""), [J, Y] = p(null), X = f(null), he = t(X, ne(me)), Z = f(null), ge = d((e) => {
|
|
32
|
+
Z.current = e, r(P, e);
|
|
33
|
+
}, [P]), _e = (e) => e.reason === "invalid" ? e.message : e.reason === "duplicate" ? `${z.duplicate} ${e.tag}` : `${z.max} ${b}`, Q = (e, t = "") => {
|
|
34
|
+
let { values: n, rejected: r } = re(W, e, {
|
|
35
|
+
validate: y,
|
|
36
|
+
maxTags: b,
|
|
37
|
+
allowDuplicates: le,
|
|
38
|
+
caseSensitive: ue
|
|
38
39
|
});
|
|
39
|
-
n.length !==
|
|
40
|
-
},
|
|
40
|
+
n.length !== W.length && G(n), Y(r[0] ? _e(r[0]) : null), q([...r.map((e) => e.tag), t].filter(Boolean).join(", "));
|
|
41
|
+
}, ve = (e) => {
|
|
41
42
|
let t = e.target.value;
|
|
42
|
-
if (
|
|
43
|
-
|
|
43
|
+
if (Y(null), !c(t)) {
|
|
44
|
+
q(t);
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
let { complete: n, tail: r } =
|
|
47
|
-
|
|
48
|
-
}, ve = (e) => {
|
|
49
|
-
S || V || (e.key === "Enter" && G.trim() ? (e.preventDefault(), Z(f(G))) : e.key === "Backspace" && G === "" && U.length > 0 && (e.preventDefault(), J(null), W(l(U, U.length - 1))));
|
|
47
|
+
let { complete: n, tail: r } = ae(t);
|
|
48
|
+
Q(n, r);
|
|
50
49
|
}, ye = (e) => {
|
|
51
|
-
|
|
50
|
+
S || H || (e.key === "Enter" && K.trim() ? (e.preventDefault(), Q(u(K))) : e.key === "Backspace" && K === "" && W.length > 0 && (e.preventDefault(), Y(null), G(l(W, W.length - 1))));
|
|
51
|
+
}, be = (e) => {
|
|
52
|
+
if (H) return;
|
|
52
53
|
let t = e.clipboardData.getData("text");
|
|
53
54
|
if (!c(t)) return;
|
|
54
55
|
e.preventDefault();
|
|
55
|
-
let n = e.currentTarget, r =
|
|
56
|
-
|
|
57
|
-
}, be = (e) => {
|
|
58
|
-
r(e.relatedTarget, Y.current) && (G.trim() && !V && Z(f(G)), M?.(e));
|
|
56
|
+
let n = e.currentTarget, r = ie(K, n.selectionStart ?? K.length, n.selectionEnd ?? K.length, t);
|
|
57
|
+
Q(u(r));
|
|
59
58
|
}, xe = (e) => {
|
|
60
|
-
|
|
59
|
+
a(e.relatedTarget, X.current) && (K.trim() && !H && Q(u(K)), N?.(e));
|
|
61
60
|
}, Se = (e) => {
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
L?.(e), !(e.defaultPrevented || S) && (e.target.closest("button, input") || Z.current?.focus());
|
|
62
|
+
}, Ce = (e) => {
|
|
63
|
+
Y(null), G(l(W, e)), Z.current?.focus();
|
|
64
|
+
}, $ = J !== null || (E ?? V?.invalid ?? !1);
|
|
65
|
+
return B.wrap(/* @__PURE__ */ h("div", {
|
|
66
|
+
...R,
|
|
66
67
|
ref: he,
|
|
67
|
-
className:
|
|
68
|
+
className: _({
|
|
68
69
|
size: C,
|
|
69
70
|
invalid: $,
|
|
70
71
|
disabled: S,
|
|
71
|
-
readOnly:
|
|
72
|
-
className:
|
|
72
|
+
readOnly: H,
|
|
73
|
+
className: I
|
|
73
74
|
}),
|
|
74
|
-
onClick:
|
|
75
|
-
onBlur:
|
|
75
|
+
onClick: Se,
|
|
76
|
+
onBlur: xe,
|
|
76
77
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
+
/* @__PURE__ */ h("div", {
|
|
78
79
|
className: "kapi-taginput__box",
|
|
79
|
-
children: [
|
|
80
|
+
children: [W.length > 0 && /* @__PURE__ */ m("ul", {
|
|
80
81
|
className: "kapi-taginput__tags",
|
|
81
|
-
children:
|
|
82
|
+
children: W.map((e, t) => /* @__PURE__ */ m("li", {
|
|
82
83
|
className: "kapi-taginput__item",
|
|
83
|
-
children: /* @__PURE__ */
|
|
84
|
+
children: /* @__PURE__ */ m(oe, {
|
|
84
85
|
tone: "primary",
|
|
85
86
|
size: C === "sm" ? "sm" : "md",
|
|
86
|
-
onRemove: S ||
|
|
87
|
-
removeLabel: `${
|
|
87
|
+
onRemove: S || H ? void 0 : () => Ce(t),
|
|
88
|
+
removeLabel: `${z.remove} ${e}`,
|
|
88
89
|
children: e
|
|
89
90
|
})
|
|
90
91
|
}, `${t}-${e}`))
|
|
91
|
-
}), /* @__PURE__ */
|
|
92
|
+
}), /* @__PURE__ */ m("input", {
|
|
92
93
|
ref: ge,
|
|
93
94
|
type: "text",
|
|
94
95
|
className: "kapi-taginput__input",
|
|
95
|
-
...
|
|
96
|
+
...i(V, {
|
|
96
97
|
id: T,
|
|
97
|
-
describedBy:
|
|
98
|
+
describedBy: o(J !== null && U, M),
|
|
98
99
|
invalid: $,
|
|
99
100
|
required: D
|
|
100
101
|
}),
|
|
101
|
-
"aria-label":
|
|
102
|
-
"aria-labelledby":
|
|
103
|
-
placeholder:
|
|
104
|
-
value:
|
|
102
|
+
"aria-label": A,
|
|
103
|
+
"aria-labelledby": j,
|
|
104
|
+
placeholder: W.length ? void 0 : x,
|
|
105
|
+
value: K,
|
|
105
106
|
disabled: S,
|
|
106
|
-
readOnly:
|
|
107
|
+
readOnly: H || void 0,
|
|
107
108
|
enterKeyHint: "enter",
|
|
108
|
-
onChange:
|
|
109
|
-
onKeyDown:
|
|
110
|
-
onPaste:
|
|
109
|
+
onChange: ve,
|
|
110
|
+
onKeyDown: ye,
|
|
111
|
+
onPaste: be
|
|
111
112
|
})]
|
|
112
113
|
}),
|
|
113
|
-
|
|
114
|
-
id:
|
|
114
|
+
J !== null && /* @__PURE__ */ m("span", {
|
|
115
|
+
id: U,
|
|
115
116
|
className: "kapi-taginput__error",
|
|
116
117
|
role: "alert",
|
|
117
|
-
children:
|
|
118
|
+
children: J
|
|
118
119
|
}),
|
|
119
|
-
w &&
|
|
120
|
+
w && W.map((e, t) => /* @__PURE__ */ m("input", {
|
|
120
121
|
type: "hidden",
|
|
121
122
|
name: w,
|
|
122
123
|
value: e
|
|
@@ -125,4 +126,4 @@ function y({ value: e, defaultValue: y = [], onChange: b, validate: se, maxTags:
|
|
|
125
126
|
}));
|
|
126
127
|
}
|
|
127
128
|
//#endregion
|
|
128
|
-
export {
|
|
129
|
+
export { g as DEFAULT_TAG_INPUT_LABELS, v as KapiTagInput, _ as tagInputClasses };
|
|
@@ -11,6 +11,12 @@ export type KapiTextareaFieldProps = TextareaHTMLAttributes<HTMLTextAreaElement>
|
|
|
11
11
|
required?: boolean | undefined;
|
|
12
12
|
/** Help / error message below the control (takes the color of `invalid` or `status`). */
|
|
13
13
|
help?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Why the field is wrong. Replaces `help` and marks the field invalid (red, icon and `role="alert"`).
|
|
16
|
+
* This is what form libraries hand you: a message, not a boolean. An error React does not paint
|
|
17
|
+
* (`true`, `""`, `null`) marks nothing. Wins over `invalid` and `status`.
|
|
18
|
+
*/
|
|
19
|
+
error?: ReactNode | undefined;
|
|
14
20
|
/** Class of the wrapping `KapiField` (if any). `className` goes to the control. */
|
|
15
21
|
fieldClassName?: string | undefined;
|
|
16
22
|
/** Grow with the content instead of showing a scrollbar. */
|
|
@@ -30,4 +36,4 @@ export declare const textareaClasses: ({ status, autosize, className }?: {
|
|
|
30
36
|
* Multiline text field of the design system (`.kapi-input` + `.kapi-textarea`). Works controlled or not.
|
|
31
37
|
* With `autosize` it grows with its content, optionally up to `maxRows`.
|
|
32
38
|
*/
|
|
33
|
-
export declare const KapiTextarea: ({ invalid: invalidProp, status: statusProp, label, required, help, fieldClassName, autosize, maxRows, className, id, rows, onInput, ref, ...rest }: KapiTextareaFieldProps) => ReactNode;
|
|
39
|
+
export declare const KapiTextarea: ({ invalid: invalidProp, status: statusProp, label, required, help, error, fieldClassName, autosize, maxRows, className, id, rows, onInput, ref, ...rest }: KapiTextareaFieldProps) => ReactNode;
|
|
@@ -1,89 +1,90 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/inputsExtra.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { computedStyleOf as e } from "../../hooks/ownerDocument.js";
|
|
4
|
+
import { fieldControlProps as t, joinIds as n, resolveFieldMessage as r } from "./fieldLogic.js";
|
|
5
|
+
import { useOwnField as i } from "./ownField.js";
|
|
5
6
|
/* empty css */
|
|
6
|
-
import { inputClasses as
|
|
7
|
-
import { computedStyleOf as a } from "../../hooks/ownerDocument.js";
|
|
7
|
+
import { inputClasses as a } from "./KapiInput.js";
|
|
8
8
|
import { rafThrottle as o } from "../../hooks/rafThrottle.js";
|
|
9
9
|
import { autosizeHeight as s, rowsToHeight as c } from "./textareaLogic.js";
|
|
10
10
|
import { useCallback as l, useEffect as u, useLayoutEffect as d, useRef as f } from "react";
|
|
11
11
|
import { jsx as p } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/inputs/KapiTextarea.tsx
|
|
13
|
-
var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) =>
|
|
13
|
+
var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => a({
|
|
14
14
|
status: e,
|
|
15
15
|
className: [
|
|
16
16
|
"kapi-textarea",
|
|
17
17
|
t && "kapi-textarea--auto",
|
|
18
18
|
n
|
|
19
19
|
].filter(Boolean).join(" ")
|
|
20
|
-
}), h = ({ invalid:
|
|
21
|
-
let { invalid:
|
|
22
|
-
id:
|
|
20
|
+
}), h = ({ invalid: a, status: h, label: g, required: _, help: v, error: y, fieldClassName: b, autosize: x, maxRows: S, className: C, id: w, rows: T = 3, onInput: E, ref: D, ...O }) => {
|
|
21
|
+
let { invalid: k, status: A } = r(y, v, a, h), j = i({
|
|
22
|
+
id: w,
|
|
23
23
|
label: g,
|
|
24
24
|
help: v,
|
|
25
|
+
error: y,
|
|
25
26
|
required: _,
|
|
26
|
-
invalid:
|
|
27
|
+
invalid: a,
|
|
27
28
|
status: h,
|
|
28
|
-
fieldClassName:
|
|
29
|
-
}), { controlId:
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
let
|
|
33
|
-
if (!
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
let { height: l, overflowing: u } = s(
|
|
39
|
-
minHeight: c(
|
|
40
|
-
maxHeight:
|
|
29
|
+
fieldClassName: b
|
|
30
|
+
}), { controlId: M, helpId: N } = j, P = f(null), F = l((e) => {
|
|
31
|
+
P.current = e, typeof D == "function" ? D(e) : D && (D.current = e);
|
|
32
|
+
}, [D]), I = f(null), L = l(() => {
|
|
33
|
+
let t = P.current;
|
|
34
|
+
if (!t || !x) return;
|
|
35
|
+
let n = e(t), r = (e) => parseFloat(e) || 0;
|
|
36
|
+
I.current = Math.max(0, t.clientWidth - r(n.paddingLeft) - r(n.paddingRight));
|
|
37
|
+
let i = r(n.lineHeight) || r(n.fontSize) * 1.5, a = r(n.borderTopWidth) + r(n.borderBottomWidth), o = r(n.paddingTop) + r(n.paddingBottom) + a;
|
|
38
|
+
t.style.height = "auto";
|
|
39
|
+
let { height: l, overflowing: u } = s(t.scrollHeight + a, {
|
|
40
|
+
minHeight: c(T, i, o),
|
|
41
|
+
maxHeight: S ? c(S, i, o) : void 0
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
+
t.style.height = `${l}px`, t.style.overflowY = u ? "auto" : "hidden";
|
|
43
44
|
}, [
|
|
44
|
-
b,
|
|
45
45
|
x,
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
S,
|
|
47
|
+
T
|
|
48
|
+
]), R = O.value;
|
|
48
49
|
d(() => {
|
|
49
|
-
|
|
50
|
-
}, [
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
let e =
|
|
54
|
-
if (!e || !
|
|
55
|
-
let t = null, n = o(() =>
|
|
50
|
+
L();
|
|
51
|
+
}, [L, R]);
|
|
52
|
+
let z = f(L);
|
|
53
|
+
z.current = L, u(() => {
|
|
54
|
+
let e = P.current;
|
|
55
|
+
if (!e || !x || typeof ResizeObserver > "u") return;
|
|
56
|
+
let t = null, n = o(() => z.current()), r = new ResizeObserver((e) => {
|
|
56
57
|
let r = e[e.length - 1]?.contentRect.width;
|
|
57
58
|
if (r === void 0 || r === t) return;
|
|
58
59
|
let i = t === null;
|
|
59
60
|
t = r;
|
|
60
|
-
let a =
|
|
61
|
+
let a = I.current;
|
|
61
62
|
i && a !== null && Math.abs(r - a) < 1 || n();
|
|
62
63
|
});
|
|
63
64
|
return r.observe(e), () => {
|
|
64
65
|
r.disconnect(), n.cancel();
|
|
65
66
|
};
|
|
66
|
-
}, [
|
|
67
|
-
let
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
...
|
|
71
|
-
ref:
|
|
72
|
-
...
|
|
73
|
-
id:
|
|
74
|
-
describedBy:
|
|
75
|
-
invalid:
|
|
67
|
+
}, [x]);
|
|
68
|
+
let B = (e) => {
|
|
69
|
+
L(), E?.(e);
|
|
70
|
+
}, V = /* @__PURE__ */ p("textarea", {
|
|
71
|
+
...O,
|
|
72
|
+
ref: F,
|
|
73
|
+
...t(j.outer, {
|
|
74
|
+
id: M,
|
|
75
|
+
describedBy: n(N, O["aria-describedby"]),
|
|
76
|
+
invalid: k
|
|
76
77
|
}),
|
|
77
|
-
rows:
|
|
78
|
+
rows: T,
|
|
78
79
|
required: _,
|
|
79
80
|
className: m({
|
|
80
|
-
status:
|
|
81
|
-
autosize:
|
|
82
|
-
className:
|
|
81
|
+
status: A,
|
|
82
|
+
autosize: x,
|
|
83
|
+
className: C
|
|
83
84
|
}),
|
|
84
|
-
onInput:
|
|
85
|
+
onInput: B
|
|
85
86
|
});
|
|
86
|
-
return
|
|
87
|
+
return j.wrap(V);
|
|
87
88
|
};
|
|
88
89
|
//#endregion
|
|
89
90
|
export { h as KapiTextarea, m as textareaClasses };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const copyText: (value: string, from?: Element | null) => Promise<boolean>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { winOf as e } from "../../hooks/ownerDocument.js";
|
|
2
|
+
//#region src/components/inputs/copyLogic.ts
|
|
3
|
+
var t = async (t, n) => {
|
|
4
|
+
try {
|
|
5
|
+
let r = (n ? e(n) : globalThis.window)?.navigator?.clipboard;
|
|
6
|
+
return r?.writeText ? (await r.writeText(t), !0) : !1;
|
|
7
|
+
} catch {
|
|
8
|
+
return !1;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as copyText };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AriaAttributes, Ref } from "react";
|
|
1
|
+
import type { AriaAttributes, ReactNode, Ref } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Estado de validación de un campo. `ok` (borde verde) y `pending` (validación asíncrona en curso:
|
|
4
4
|
* ocupado, todavía no inválido) no son errores. `err` es el alias deprecado de `invalid`.
|
|
@@ -105,5 +105,25 @@ export declare const resolveValidation: (invalid: boolean | undefined, status: K
|
|
|
105
105
|
invalid: boolean | undefined;
|
|
106
106
|
status: KapiFieldStatus | undefined;
|
|
107
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Único lugar donde se decide QUÉ mensaje se muestra bajo el control y si el campo es inválido.
|
|
110
|
+
*
|
|
111
|
+
* `help` es la pista; `error` es el motivo por el que el campo está mal. Cuando hay error, el error
|
|
112
|
+
* es el mensaje y el campo queda inválido: se pinta en rojo, con ícono y `role="alert"`.
|
|
113
|
+
*
|
|
114
|
+
* Existe porque sin ella el consumidor escribe dos props que tienen que coincidir
|
|
115
|
+
* (`invalid={Boolean(e)} help={e ?? "pista"}`), y si se desincronizan queda un campo rojo SIN motivo
|
|
116
|
+
* visible —un `aria-invalid` sin mensaje— sin que nada falle. Toda librería de formularios entrega un
|
|
117
|
+
* MENSAJE y no un booleano, así que esa traducción caía en cada campo de cada pantalla.
|
|
118
|
+
*
|
|
119
|
+
* `invalid={false}` NO apaga un error que se está mostrando: dejaría el mensaje en gris y sin alerta,
|
|
120
|
+
* que es el agujero que esta prop cierra. Un error que React no pinta (`true`, `""`, `null`) no marca
|
|
121
|
+
* nada, y eso lo decide `present`, no una regla nueva.
|
|
122
|
+
*/
|
|
123
|
+
export declare const resolveFieldMessage: (error: ReactNode, help: ReactNode, invalid: boolean | undefined, status: KapiFieldStatus | undefined) => {
|
|
124
|
+
message: ReactNode;
|
|
125
|
+
invalid: boolean | undefined;
|
|
126
|
+
status: KapiFieldStatus | undefined;
|
|
127
|
+
};
|
|
108
128
|
/** Clase del contenedor del campo: `fieldClassName` es la canónica; `wrapperClassName` (deprecada), el respaldo. */
|
|
109
129
|
export declare const resolveFieldClassName: (fieldClassName: string | undefined, wrapperClassName: string | undefined) => string | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { present as e } from "./inputLogic.js";
|
|
1
2
|
//#region src/components/inputs/fieldLogic.ts
|
|
2
|
-
var
|
|
3
|
+
var t = ({ controlId: e, labelId: t, helpId: n, required: r, status: i, readOnly: a }) => ({
|
|
3
4
|
controlId: e,
|
|
4
5
|
labelId: t,
|
|
5
6
|
helpId: n,
|
|
@@ -7,25 +8,25 @@ var e = ({ controlId: e, labelId: t, helpId: n, required: r, status: i, readOnly
|
|
|
7
8
|
invalid: i === "err",
|
|
8
9
|
busy: i === "pending",
|
|
9
10
|
...a ? { readOnly: !0 } : {}
|
|
10
|
-
}),
|
|
11
|
+
}), n = (e, t) => e ?? t?.readOnly ?? !1, r = (...e) => {
|
|
11
12
|
let t = [...new Set(e.flatMap((e) => e ? e.split(/\s+/).filter(Boolean) : []))];
|
|
12
13
|
return t.length ? t.join(" ") : void 0;
|
|
13
|
-
},
|
|
14
|
+
}, i = ({ htmlFor: e, autoId: t, helpId: n, hasHelp: r }) => {
|
|
14
15
|
let i = e ?? t;
|
|
15
16
|
return {
|
|
16
17
|
controlId: i,
|
|
17
18
|
labelId: `${i}-label`,
|
|
18
19
|
...r ? { helpId: n ?? `${i}-help` } : {}
|
|
19
20
|
};
|
|
20
|
-
},
|
|
21
|
+
}, a = (e, t) => ({
|
|
21
22
|
id: t.id ?? e?.controlId,
|
|
22
|
-
"aria-describedby":
|
|
23
|
+
"aria-describedby": r(e?.helpId, t.describedBy),
|
|
23
24
|
"aria-invalid": t.invalid ?? e?.invalid ? !0 : void 0,
|
|
24
25
|
"aria-required": t.required ?? e?.required ? !0 : void 0,
|
|
25
26
|
"aria-busy": t.busy ?? e?.busy ? !0 : void 0,
|
|
26
27
|
"aria-labelledby": t.labelable === !1 && !t.ariaLabel ? e?.labelId : void 0
|
|
27
|
-
}),
|
|
28
|
-
let n =
|
|
28
|
+
}), o = (e, t) => {
|
|
29
|
+
let n = a(e, {
|
|
29
30
|
id: t.id,
|
|
30
31
|
describedBy: t.describedBy,
|
|
31
32
|
invalid: t.invalid,
|
|
@@ -39,9 +40,9 @@ var e = ({ controlId: e, labelId: t, helpId: n, required: r, status: i, readOnly
|
|
|
39
40
|
"aria-required": t.ariaRequired ?? n["aria-required"],
|
|
40
41
|
"aria-busy": n["aria-busy"]
|
|
41
42
|
};
|
|
42
|
-
},
|
|
43
|
+
}, s = (e, ...t) => !(e instanceof Node && t.some((t) => t?.contains(e))), c = (e, t) => {
|
|
43
44
|
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
44
|
-
},
|
|
45
|
+
}, l = (e, t) => e === !0 ? {
|
|
45
46
|
invalid: !0,
|
|
46
47
|
status: "err"
|
|
47
48
|
} : e === !1 ? {
|
|
@@ -50,6 +51,12 @@ var e = ({ controlId: e, labelId: t, helpId: n, required: r, status: i, readOnly
|
|
|
50
51
|
} : {
|
|
51
52
|
invalid: t ? t === "err" : void 0,
|
|
52
53
|
status: t
|
|
53
|
-
},
|
|
54
|
+
}, u = (t, n, r, i) => e(t) ? {
|
|
55
|
+
message: t,
|
|
56
|
+
...l(!0, i)
|
|
57
|
+
} : {
|
|
58
|
+
message: n,
|
|
59
|
+
...l(r, i)
|
|
60
|
+
}, d = (e, t) => e ?? t;
|
|
54
61
|
//#endregion
|
|
55
|
-
export {
|
|
62
|
+
export { c as assignRef, t as fieldContextValue, a as fieldControlProps, i as fieldIds, s as focusLeaves, r as joinIds, o as nativeFieldProps, d as resolveFieldClassName, u as resolveFieldMessage, n as resolveReadOnly, l as resolveValidation };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { KapiButton, buttonClasses } from "./KapiButton.js";
|
|
2
|
+
export { KapiCopyButton, DEFAULT_COPY_BUTTON_LABELS, COPY_FEEDBACK_MS } from "./KapiCopyButton.js";
|
|
3
|
+
export type { KapiCopyButtonLabels, KapiCopyButtonProps } from "./KapiCopyButton.js";
|
|
2
4
|
export type { KapiButtonAppearance, KapiButtonProps, KapiButtonSize, KapiButtonTone, KapiButtonVariant } from "./KapiButton.js";
|
|
3
5
|
export { KapiIconButton,
|
|
4
6
|
/** @deprecated Interno, se quita en 1.0. */
|
|
@@ -29,6 +31,9 @@ export type { KapiFieldContextValue, KapiFieldProps, KapiFieldStatus } from "./K
|
|
|
29
31
|
export { fieldControlProps } from "./fieldLogic.js";
|
|
30
32
|
export { KapiCheckbox } from "./KapiCheckbox.js";
|
|
31
33
|
export type { KapiCheckboxProps } from "./KapiCheckbox.js";
|
|
34
|
+
export { DEFAULT_PIN_INPUT_LABELS, KapiPinInput } from "./KapiPinInput.js";
|
|
35
|
+
export type { KapiPinInputLabels, KapiPinInputProps } from "./KapiPinInput.js";
|
|
36
|
+
export type { KapiPinInputType } from "./pinInputLogic.js";
|
|
32
37
|
export { KapiRadio } from "./KapiRadio.js";
|
|
33
38
|
export type { KapiRadioProps } from "./KapiRadio.js";
|
|
34
39
|
export { KapiSwitch } from "./KapiSwitch.js";
|
|
@@ -54,7 +59,7 @@ export { KapiSelect,
|
|
|
54
59
|
/** @deprecated Interno, se quita en 1.0. */
|
|
55
60
|
selectClasses, DEFAULT_SELECT_LABELS } from "./KapiSelect.js";
|
|
56
61
|
export type { KapiSelectLabels, KapiSelectRenderContext } from "./KapiSelect.js";
|
|
57
|
-
export type { KapiSelectProps, KapiSelectBaseProps, KapiSelectSingleProps, KapiSelectMultiProps, KapiSelectSize, KapiSelectVariant, KapiSelectOption, KapiSelectGroup, KapiSelectEntry } from "./KapiSelect.js";
|
|
62
|
+
export type { KapiSelectClassNames, KapiSelectProps, KapiSelectBaseProps, KapiSelectSingleProps, KapiSelectMultiProps, KapiSelectSize, KapiSelectVariant, KapiSelectOption, KapiSelectGroup, KapiSelectEntry } from "./KapiSelect.js";
|
|
58
63
|
export { KapiCalendar } from "./KapiCalendar.js";
|
|
59
64
|
export { KapiDatePicker } from "./KapiDatePicker.js";
|
|
60
65
|
export { DEFAULT_CALENDAR_LABELS, DEFAULT_DATE_PATTERN,
|
|
@@ -116,3 +121,6 @@ toDateRangeValue,
|
|
|
116
121
|
/** @deprecated Interno; usa `KapiFacetedSearch` en su lugar. Se quita en 1.0. */
|
|
117
122
|
toDateValue } from "./facetedSearchLogic.js";
|
|
118
123
|
export type { KapiFacet, KapiFacetChip, KapiFacetKind, KapiFacetOption, KapiFacetKeyAction, KapiFacetMenuItem, KapiFacetOperator } from "./facetedSearchLogic.js";
|
|
124
|
+
export { KapiPropsForm } from "./KapiPropsForm.js";
|
|
125
|
+
export type { KapiPropsFormField, KapiPropsFormProps, KapiPropsFormValue, KapiPropsFormValues } from "./KapiPropsForm.js";
|
|
126
|
+
export { initialPropsFormValues, isPropsFormFieldEmpty, missingPropsFormFields, reconcilePropsFormValues } from "./propsFormLogic.js";
|
|
@@ -8,12 +8,13 @@ export type KapiInputAdornments = {
|
|
|
8
8
|
prefix?: ReactNode | undefined;
|
|
9
9
|
suffix?: ReactNode | undefined;
|
|
10
10
|
clearable?: boolean | undefined;
|
|
11
|
+
reveal?: boolean | undefined;
|
|
11
12
|
shortcut?: string | undefined;
|
|
12
13
|
};
|
|
13
14
|
/** ¿El adorno se dibuja? `null`, `undefined`, booleanos y `""` no (React no los pinta). */
|
|
14
15
|
export declare const present: (node: ReactNode) => boolean;
|
|
15
16
|
/** ¿Hay algún adorno? Sin adornos el input se renderiza igual que siempre (sin envoltorio). */
|
|
16
|
-
export declare const hasAdornments: ({ startIcon, endIcon, prefix, suffix, clearable, shortcut }: KapiInputAdornments) => boolean;
|
|
17
|
+
export declare const hasAdornments: ({ startIcon, endIcon, prefix, suffix, clearable, reveal, shortcut }: KapiInputAdornments) => boolean;
|
|
17
18
|
/** ¿El valor tiene algo? Decide si se muestra el botón de limpiar. */
|
|
18
19
|
export declare const hasValue: (value: unknown) => boolean;
|
|
19
20
|
/** Clases de la caja que envuelve input + adornos: es la que lleva borde, fondo y anillo de foco. */
|
|
@@ -23,3 +24,17 @@ export declare const inputBoxClasses: ({ size, status, disabled, className }?: {
|
|
|
23
24
|
disabled?: boolean | undefined;
|
|
24
25
|
className?: string | undefined;
|
|
25
26
|
}) => string;
|
|
27
|
+
/**
|
|
28
|
+
* El `type` que hay que forzar en el campo, o `undefined` para dejar el que pasó el consumidor.
|
|
29
|
+
*
|
|
30
|
+
* Vive acá y no dentro del componente para poder PROBAR el caso del `disabled`: es lo único que
|
|
31
|
+
* evita un frame con la contraseña en claro cuando el campo se deshabilita, porque React pinta y
|
|
32
|
+
* DESPUÉS corre el efecto que resetea el estado. Dentro del componente eso no se puede afirmar
|
|
33
|
+
* —`act()` vacía los efectos antes de que un test mire el render intermedio—, así que la decisión
|
|
34
|
+
* sale a una función pura y el test la fija.
|
|
35
|
+
*/
|
|
36
|
+
export declare const tipoDeCampo: ({ reveal, revealed, disabled }: {
|
|
37
|
+
reveal?: boolean | undefined;
|
|
38
|
+
revealed: boolean;
|
|
39
|
+
disabled?: boolean | undefined;
|
|
40
|
+
}) => "text" | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//#region src/components/inputs/inputLogic.ts
|
|
2
|
-
var e = (e) => e != null && typeof e != "boolean" && e !== "", t = ({ startIcon: t, endIcon: n, prefix: r, suffix: i, clearable: a,
|
|
2
|
+
var e = (e) => e != null && typeof e != "boolean" && e !== "", t = ({ startIcon: t, endIcon: n, prefix: r, suffix: i, clearable: a, reveal: o, shortcut: s }) => e(t) || e(n) || e(r) || e(i) || !!a || !!o || !!s, n = (e) => e == null ? !1 : Array.isArray(e) ? e.length > 0 : String(e) !== "", r = ({ size: e = "md", status: t, disabled: n = !1, className: r = "" } = {}) => [
|
|
3
3
|
"kapi-inputbox",
|
|
4
4
|
e !== "md" && `kapi-inputbox--${e}`,
|
|
5
5
|
t && `kapi-inputbox--${t}`,
|
|
6
6
|
n && "is-disabled",
|
|
7
7
|
r
|
|
8
|
-
].filter(Boolean).join(" ");
|
|
8
|
+
].filter(Boolean).join(" "), i = ({ reveal: e, revealed: t, disabled: n }) => e && t && !n ? "text" : void 0;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { t as hasAdornments, n as hasValue, r as inputBoxClasses, e as present };
|
|
10
|
+
export { t as hasAdornments, n as hasValue, r as inputBoxClasses, e as present, i as tipoDeCampo };
|
|
@@ -9,6 +9,8 @@ export type OwnFieldOptions = {
|
|
|
9
9
|
id?: string | undefined;
|
|
10
10
|
label?: ReactNode | undefined;
|
|
11
11
|
help?: ReactNode | undefined;
|
|
12
|
+
/** El motivo por el que el campo está mal: reemplaza a `help` y lo marca inválido. Ver `KapiFieldProps`. */
|
|
13
|
+
error?: ReactNode | undefined;
|
|
12
14
|
required?: boolean | undefined;
|
|
13
15
|
invalid?: boolean | undefined;
|
|
14
16
|
status?: KapiFieldStatus | undefined;
|
|
@@ -34,4 +36,4 @@ export type OwnField = {
|
|
|
34
36
|
/** Envuelve el control en el `KapiField` propio, o lo devuelve tal cual. */
|
|
35
37
|
wrap: (control: ReactNode) => ReactNode;
|
|
36
38
|
};
|
|
37
|
-
export declare const useOwnField: ({ id, label, help, required, invalid, status: statusProp, readOnly, fieldClassName }: OwnFieldOptions) => OwnField;
|
|
39
|
+
export declare const useOwnField: ({ id, label, help: helpProp, error, required, invalid, status: statusProp, readOnly, fieldClassName }: OwnFieldOptions) => OwnField;
|