@kapiuara/ui 0.16.0 → 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/README.md +171 -11
- 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/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/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/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 +5 -2
- package/dist/components/display/KapiTimeline.js +31 -23
- 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 +8 -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/timelineLogic.d.ts +20 -2
- package/dist/components/display/timelineLogic.js +10 -2
- 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/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 +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/index.d.ts +8 -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 +10 -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/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/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/KapiTooltip.js +18 -18
- package/dist/components/overlays/menuList.js +22 -22
- package/dist/components/slotCatalog.d.ts +33 -0
- package/dist/components/slotCatalog.js +18 -10
- package/dist/css/base.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/feedback/feedback.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/KapiToc.css +1 -0
- package/dist/hooks/asyncResourceLogic.d.ts +11 -0
- package/dist/hooks/asyncResourceLogic.js +4 -0
- package/dist/hooks/index.d.ts +3 -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/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 +221 -207
- 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/package.json +13 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { KapiInput as e } from "./KapiInput.js";
|
|
3
|
+
import { useControllableState as t } from "../../hooks/useControllableState.js";
|
|
4
|
+
import { KapiSwitch as n } from "./KapiSwitch.js";
|
|
5
|
+
import { KapiSelect as r } from "./KapiSelect.js";
|
|
6
|
+
import { KapiTextarea as i } from "./KapiTextarea.js";
|
|
7
|
+
import { KapiNumberStepper as a } from "./KapiNumberStepper.js";
|
|
8
|
+
import { KapiGrid as o } from "../layout/KapiGrid.js";
|
|
9
|
+
import { missingPropsFormFields as s, reconcilePropsFormValues as c } from "./propsFormLogic.js";
|
|
10
|
+
import { useMemo as l } from "react";
|
|
11
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
12
|
+
//#region src/components/inputs/KapiPropsForm.tsx
|
|
13
|
+
function d({ fields: d, values: f, defaultValues: p, onChange: m, showErrors: h = !1, disabled: g = !1, min: _ = 220, className: v, ...y }) {
|
|
14
|
+
let [b, x] = t(f, () => c(d, p ?? {}), m), S = l(() => c(d, b), [d, b]), C = l(() => h ? new Set(s(d, S)) : /* @__PURE__ */ new Set(), [
|
|
15
|
+
h,
|
|
16
|
+
d,
|
|
17
|
+
S
|
|
18
|
+
]), w = (e, t) => x({
|
|
19
|
+
...S,
|
|
20
|
+
[e]: t
|
|
21
|
+
});
|
|
22
|
+
return /* @__PURE__ */ u("div", {
|
|
23
|
+
...y,
|
|
24
|
+
className: ["kapi-propsform", v].filter(Boolean).join(" "),
|
|
25
|
+
children: /* @__PURE__ */ u(o, {
|
|
26
|
+
min: _,
|
|
27
|
+
gap: 4,
|
|
28
|
+
children: d.map((t) => {
|
|
29
|
+
let o = {
|
|
30
|
+
label: t.label,
|
|
31
|
+
name: t.name,
|
|
32
|
+
disabled: g || t.disabled === !0,
|
|
33
|
+
required: t.required === !0,
|
|
34
|
+
invalid: C.has(t.name),
|
|
35
|
+
...t.hint === void 0 ? {} : { help: t.hint }
|
|
36
|
+
}, s = S[t.name] ?? null;
|
|
37
|
+
if (t.kind === "boolean") return /* @__PURE__ */ u(n, {
|
|
38
|
+
...o,
|
|
39
|
+
checked: s === !0,
|
|
40
|
+
onChange: (e) => w(t.name, e.currentTarget.checked)
|
|
41
|
+
}, t.name);
|
|
42
|
+
if (t.kind === "number") return /* @__PURE__ */ u(a, {
|
|
43
|
+
...o,
|
|
44
|
+
...typeof s == "number" ? { value: s } : {},
|
|
45
|
+
onChange: (e) => w(t.name, e),
|
|
46
|
+
...t.min === void 0 ? {} : { min: t.min },
|
|
47
|
+
...t.max === void 0 ? {} : { max: t.max }
|
|
48
|
+
}, t.name);
|
|
49
|
+
if (t.kind === "select") return /* @__PURE__ */ u(r, {
|
|
50
|
+
...o,
|
|
51
|
+
options: (t.options ?? []).map((e) => ({
|
|
52
|
+
value: e.value,
|
|
53
|
+
label: e.label
|
|
54
|
+
})),
|
|
55
|
+
value: typeof s == "string" ? s : null,
|
|
56
|
+
onChange: (e) => w(t.name, e),
|
|
57
|
+
clearable: !0,
|
|
58
|
+
...t.placeholder === void 0 ? {} : { placeholder: t.placeholder }
|
|
59
|
+
}, t.name);
|
|
60
|
+
let c = typeof s == "string" ? s : "", l = t.placeholder === void 0 ? {} : { placeholder: t.placeholder };
|
|
61
|
+
return t.kind === "textarea" ? /* @__PURE__ */ u(i, {
|
|
62
|
+
...o,
|
|
63
|
+
...l,
|
|
64
|
+
rows: 3,
|
|
65
|
+
value: c,
|
|
66
|
+
onChange: (e) => w(t.name, e.currentTarget.value)
|
|
67
|
+
}, t.name) : /* @__PURE__ */ u(e, {
|
|
68
|
+
...o,
|
|
69
|
+
...l,
|
|
70
|
+
value: c,
|
|
71
|
+
onChange: (e) => w(t.name, e.currentTarget.value)
|
|
72
|
+
}, t.name);
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { d as KapiPropsForm };
|
|
@@ -43,6 +43,12 @@ export type KapiRatingProps = Omit<HTMLAttributes<HTMLDivElement>, "children" |
|
|
|
43
43
|
label?: ReactNode | undefined;
|
|
44
44
|
/** Ayuda / mensaje de error bajo la calificación (la envuelve en un `KapiField`). */
|
|
45
45
|
help?: ReactNode | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
|
|
48
|
+
* `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
|
|
49
|
+
* Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
|
|
50
|
+
*/
|
|
51
|
+
error?: ReactNode | undefined;
|
|
46
52
|
/** Clase del `KapiField` propio (con `label` o `help`). `className` va a la raíz. */
|
|
47
53
|
fieldClassName?: string | undefined;
|
|
48
54
|
/**
|
|
@@ -69,4 +75,4 @@ export declare const ratingClasses: ({ size, interactive, disabled, readOnly, cl
|
|
|
69
75
|
* Inside a `KapiField` the interactive slider takes the field id, name (`aria-labelledby`), help,
|
|
70
76
|
* `aria-invalid` and `aria-required`.
|
|
71
77
|
*/
|
|
72
|
-
export declare const KapiRating: ({ value: valueProp, defaultValue, onChange, max, size, disabled, allowHalf, className, labels, "aria-label": ariaLabelProp, name, invalid, required, label, help, fieldClassName, readOnly: readOnlyProp, id, "aria-describedby": describedBy, ref, ...rest }: KapiRatingProps) => ReactNode;
|
|
78
|
+
export declare const KapiRating: ({ value: valueProp, defaultValue, onChange, max, size, disabled, allowHalf, className, labels, "aria-label": ariaLabelProp, name, invalid, required, label, help, error, fieldClassName, readOnly: readOnlyProp, id, "aria-describedby": describedBy, ref, ...rest }: KapiRatingProps) => ReactNode;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/inputsExtra.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { useMergedRefs as e } from "../../hooks/mergeRefs.js";
|
|
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";
|
|
6
7
|
/* empty css */
|
|
7
|
-
import { useControllableState as
|
|
8
|
-
import { directionOf as
|
|
9
|
-
import { useFormReset as
|
|
10
|
-
import {
|
|
11
|
-
import { normalizeRating as o, ratingFromKey as s, ratingFromPointer as c, starFills as re } from "./ratingLogic.js";
|
|
8
|
+
import { useControllableState as a } from "../../hooks/useControllableState.js";
|
|
9
|
+
import { directionOf as o, logicalKeyOf as s } from "../../hooks/directionLogic.js";
|
|
10
|
+
import { useFormReset as ee } from "../../hooks/useFormReset.js";
|
|
11
|
+
import { normalizeRating as te, ratingFromKey as c, ratingFromPointer as ne, starFills as re } from "./ratingLogic.js";
|
|
12
12
|
import { useState as ie } from "react";
|
|
13
13
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
14
14
|
import { Star as d } from "lucide-react";
|
|
@@ -16,46 +16,47 @@ import { Star as d } from "lucide-react";
|
|
|
16
16
|
var f = {
|
|
17
17
|
rating: "Calificación",
|
|
18
18
|
of: "de"
|
|
19
|
-
},
|
|
19
|
+
}, ae = {
|
|
20
20
|
sm: 16,
|
|
21
21
|
md: 22,
|
|
22
22
|
lg: 30
|
|
23
|
-
},
|
|
23
|
+
}, p = ({ size: e = "md", interactive: t = !1, disabled: n = !1, readOnly: r = !1, className: i = "" } = {}) => [
|
|
24
24
|
"kapi-rating",
|
|
25
25
|
e !== "md" && `kapi-rating--${e}`,
|
|
26
26
|
t && "kapi-rating--interactive",
|
|
27
27
|
n && "kapi-rating--disabled",
|
|
28
28
|
r && "kapi-rating--readonly",
|
|
29
29
|
i
|
|
30
|
-
].filter(Boolean).join(" "),
|
|
31
|
-
let P =
|
|
30
|
+
].filter(Boolean).join(" "), m = ({ value: m, defaultValue: h, onChange: g, max: _ = 5, size: v = "md", disabled: y = !1, allowHalf: b = !1, className: x, labels: oe, "aria-label": S, name: C, invalid: w, required: T, label: E, help: D, error: O, fieldClassName: k, readOnly: A, id: j, "aria-describedby": M, ref: se, ...N }) => {
|
|
31
|
+
let P = t("rating", f, oe), F = i({
|
|
32
32
|
id: j,
|
|
33
|
-
label:
|
|
34
|
-
help:
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
label: E,
|
|
34
|
+
help: D,
|
|
35
|
+
error: O,
|
|
36
|
+
required: T,
|
|
37
|
+
invalid: w,
|
|
37
38
|
readOnly: A,
|
|
38
39
|
fieldClassName: k
|
|
39
|
-
}), I = F.field, L =
|
|
40
|
+
}), I = F.field, L = r(A, I), [R, z] = ie(null), [B, V, , H] = a(m, h ?? 0, g), U = e(se, ee(H)), W = (g !== void 0 || m === void 0 && h !== void 0) && !y, G = W && !L, K = n(W ? I : null, {
|
|
40
41
|
id: j,
|
|
41
42
|
describedBy: M,
|
|
42
|
-
invalid:
|
|
43
|
-
required:
|
|
43
|
+
invalid: w,
|
|
44
|
+
required: T,
|
|
44
45
|
labelable: !1,
|
|
45
|
-
ariaLabel:
|
|
46
|
-
}), q =
|
|
46
|
+
ariaLabel: S
|
|
47
|
+
}), q = S ?? P.rating, J = te(B, _, b), Y = C ? /* @__PURE__ */ l("input", {
|
|
47
48
|
type: "hidden",
|
|
48
|
-
name:
|
|
49
|
+
name: C,
|
|
49
50
|
value: J,
|
|
50
|
-
disabled:
|
|
51
|
-
}) : null,
|
|
52
|
-
let n = e.currentTarget.getBoundingClientRect(), r =
|
|
53
|
-
return
|
|
54
|
-
},
|
|
51
|
+
disabled: y
|
|
52
|
+
}) : null, ce = re(G && R !== null ? R : J, _, b), X = ae[v], Z = (e, t) => {
|
|
53
|
+
let n = e.currentTarget.getBoundingClientRect(), r = o(e.currentTarget) === "rtl" ? n.right - e.clientX : e.clientX - n.left, i = n.width > 0 ? r / n.width : 1;
|
|
54
|
+
return ne(t, i, b);
|
|
55
|
+
}, le = (e) => {
|
|
55
56
|
if (!G) return;
|
|
56
|
-
let t = s(
|
|
57
|
+
let t = c(s(e), J, _, b);
|
|
57
58
|
t !== null && (e.preventDefault(), t !== J && V(t));
|
|
58
|
-
}, Q =
|
|
59
|
+
}, Q = ce.map((e, t) => /* @__PURE__ */ u("span", {
|
|
59
60
|
className: "kapi-rating__star",
|
|
60
61
|
"data-fill": e,
|
|
61
62
|
onMouseMove: G ? (e) => z(Z(e, t)) : void 0,
|
|
@@ -78,12 +79,12 @@ var f = {
|
|
|
78
79
|
"aria-hidden": "true"
|
|
79
80
|
})
|
|
80
81
|
})]
|
|
81
|
-
}, t)), $ =
|
|
82
|
-
size:
|
|
82
|
+
}, t)), $ = p({
|
|
83
|
+
size: v,
|
|
83
84
|
interactive: W,
|
|
84
|
-
disabled:
|
|
85
|
+
disabled: y,
|
|
85
86
|
readOnly: W && L,
|
|
86
|
-
className:
|
|
87
|
+
className: x
|
|
87
88
|
});
|
|
88
89
|
return W ? F.wrap(/* @__PURE__ */ u("div", {
|
|
89
90
|
...N,
|
|
@@ -94,11 +95,11 @@ var f = {
|
|
|
94
95
|
tabIndex: 0,
|
|
95
96
|
"aria-label": K["aria-labelledby"] ? void 0 : q,
|
|
96
97
|
"aria-valuemin": 0,
|
|
97
|
-
"aria-valuemax":
|
|
98
|
+
"aria-valuemax": _,
|
|
98
99
|
"aria-valuenow": J,
|
|
99
|
-
"aria-valuetext": `${J} ${P.of} ${
|
|
100
|
+
"aria-valuetext": `${J} ${P.of} ${_}`,
|
|
100
101
|
"aria-readonly": L || void 0,
|
|
101
|
-
onKeyDown:
|
|
102
|
+
onKeyDown: le,
|
|
102
103
|
onMouseLeave: () => z(null),
|
|
103
104
|
children: [Q, Y]
|
|
104
105
|
})) : F.wrap(/* @__PURE__ */ u("div", {
|
|
@@ -108,9 +109,9 @@ var f = {
|
|
|
108
109
|
"aria-describedby": M,
|
|
109
110
|
className: $,
|
|
110
111
|
role: "img",
|
|
111
|
-
"aria-label": `${q}: ${J} ${P.of} ${
|
|
112
|
+
"aria-label": `${q}: ${J} ${P.of} ${_}`,
|
|
112
113
|
children: [Q, Y]
|
|
113
114
|
}));
|
|
114
115
|
};
|
|
115
116
|
//#endregion
|
|
116
|
-
export { f as DEFAULT_RATING_LABELS,
|
|
117
|
+
export { f as DEFAULT_RATING_LABELS, m as KapiRating, p as ratingClasses };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/KapiSearchChip.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
4
|
+
import { assignRef as t } from "./fieldLogic.js";
|
|
5
5
|
import { useControllableState as n } from "../../hooks/useControllableState.js";
|
|
6
6
|
import { searchChipClasses as r, searchChipName as i } from "./searchChipLogic.js";
|
|
7
7
|
/* empty css */
|
|
@@ -16,12 +16,12 @@ var u = {
|
|
|
16
16
|
}, d = (e) => {
|
|
17
17
|
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(e, ""), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
18
18
|
}, f = ({ value: f, defaultValue: p, onChange: m, onSubmit: h, disabled: g = !1, placeholder: _, "aria-label": v, labels: y, className: b, style: x, ref: S, onKeyDown: C, ...w }) => {
|
|
19
|
-
let T =
|
|
19
|
+
let T = e("searchChip", u, y), E = a(null), [D, O] = n(f, p ?? ""), k = _ ?? T.placeholder, A = i({
|
|
20
20
|
ariaLabel: v,
|
|
21
21
|
placeholder: k,
|
|
22
22
|
fallback: T.search
|
|
23
|
-
}), j = D !== "" && !g && !w.readOnly, M = (
|
|
24
|
-
E.current =
|
|
23
|
+
}), j = D !== "" && !g && !w.readOnly, M = (e) => {
|
|
24
|
+
E.current = e, t(S, e);
|
|
25
25
|
}, N = () => {
|
|
26
26
|
let e = E.current;
|
|
27
27
|
e && (d(e), e.focus());
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { FocusEvent, HTMLAttributes, ReactNode, Ref } from "react";
|
|
2
|
-
import { type KapiTone } from "../tone.js";
|
|
2
|
+
import { type KapiFamilyTone, type KapiTone } from "../tone.js";
|
|
3
3
|
export type KapiSegmentedVariant = "text" | "icon" | "both";
|
|
4
4
|
/** Escala del segmentado: `sm` para barras compactas (filtros de tabla), `md` el de siempre. */
|
|
5
5
|
export type KapiSegmentedSize = "sm" | "md";
|
|
6
6
|
/** Tonos de un ítem de `KapiSegmented` (subconjunto de `KapiTone`). */
|
|
7
7
|
export type KapiSegmentedTone = Extract<KapiTone, "success" | "warning" | "danger" | "info">;
|
|
8
|
+
/** Tono de un ítem: uno del subconjunto, o una familia propia de la app (`toneFamilies`). */
|
|
9
|
+
export type KapiSegmentedToneName = KapiSegmentedTone | KapiFamilyTone;
|
|
8
10
|
/** @deprecated Usar `KapiSegmentedTone`. */
|
|
9
11
|
export type KapiSegmentedColor = KapiSegmentedTone;
|
|
10
12
|
export type KapiSegmentedItem<Id extends string | number = string> = {
|
|
@@ -19,15 +21,15 @@ export type KapiSegmentedItem<Id extends string | number = string> = {
|
|
|
19
21
|
*/
|
|
20
22
|
count?: number | undefined;
|
|
21
23
|
/** Tono del ítem cuando está activo (en vez del primario); sin activar no se ve. */
|
|
22
|
-
activeTone?:
|
|
24
|
+
activeTone?: KapiSegmentedToneName | undefined;
|
|
23
25
|
/** Nombre anterior de `activeTone`, deprecado. @deprecated Usar `activeTone` (mismos valores). */
|
|
24
|
-
color?:
|
|
26
|
+
color?: KapiSegmentedToneName | undefined;
|
|
25
27
|
/**
|
|
26
28
|
* Estado permanente del ítem: tiñe el label y el contador **siempre**, sin tocar el fondo, para que una
|
|
27
29
|
* opción que necesita atención («Demorados 41») se vea sin tener que elegirla. Si además está activa, el
|
|
28
30
|
* tratamiento de `activeTone` gana.
|
|
29
31
|
*/
|
|
30
|
-
tone?:
|
|
32
|
+
tone?: KapiSegmentedToneName | undefined;
|
|
31
33
|
/** Opción no elegible: se ve atenuada y el teclado la saltea. */
|
|
32
34
|
disabled?: boolean | undefined;
|
|
33
35
|
};
|
|
@@ -58,6 +60,12 @@ export type KapiSegmentedProps<Id extends string | number = string> = Omit<HTMLA
|
|
|
58
60
|
label?: ReactNode | undefined;
|
|
59
61
|
/** Ayuda / mensaje de error bajo el grupo (lo envuelve en un `KapiField`). */
|
|
60
62
|
help?: ReactNode | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
|
|
65
|
+
* `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
|
|
66
|
+
* Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
|
|
67
|
+
*/
|
|
68
|
+
error?: ReactNode | undefined;
|
|
61
69
|
/** Clase del `KapiField` propio (con `label` o `help`). `className` va al `radiogroup`. */
|
|
62
70
|
fieldClassName?: string | undefined;
|
|
63
71
|
/** Deshabilita el grupo entero (cada opción también acepta `disabled`). */
|
|
@@ -78,4 +86,4 @@ export type KapiSegmentedProps<Id extends string | number = string> = Omit<HTMLA
|
|
|
78
86
|
* En variante `icon` cada tab muestra su label en un tooltip al hover.
|
|
79
87
|
* Dentro de un `KapiField` toma id, nombre (`aria-labelledby`), ayuda, `aria-invalid` y `aria-required`.
|
|
80
88
|
*/
|
|
81
|
-
export declare const KapiSegmented: <Id extends string | number = string>({ items, value: valueProp, defaultValue, onChange, variant, "aria-label": ariaLabel, className, name, onBlur, invalid, required, label, help, fieldClassName, disabled, readOnly: readOnlyProp, size, id, "aria-describedby": describedBy, ref, ...rest }: KapiSegmentedProps<Id>) => ReactNode;
|
|
89
|
+
export declare const KapiSegmented: <Id extends string | number = string>({ items, value: valueProp, defaultValue, onChange, variant, "aria-label": ariaLabel, className, name, onBlur, invalid, required, label, help, error, fieldClassName, disabled, readOnly: readOnlyProp, size, id, "aria-describedby": describedBy, ref, ...rest }: KapiSegmentedProps<Id>) => ReactNode;
|
|
@@ -1,116 +1,120 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/inputsExtra.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { useToneLookResolver as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { joinClasses as t } from "../rootProps.js";
|
|
5
|
+
import { resolveTone as n } from "../tone.js";
|
|
6
|
+
import { useKapiFormatLocale as r } from "../locale/KapiLocaleProvider.js";
|
|
7
|
+
import { assignRef as i, fieldControlProps as a, resolveReadOnly as o } from "./fieldLogic.js";
|
|
8
|
+
import { useOwnField as s } from "./ownField.js";
|
|
8
9
|
/* empty css */
|
|
9
|
-
import { useControllableState as
|
|
10
|
+
import { useControllableState as ee } from "../../hooks/useControllableState.js";
|
|
10
11
|
import { logicalKeyOf as c } from "../../hooks/directionLogic.js";
|
|
11
|
-
import { useDuplicateValueWarning as l, useMutedControlWarning as
|
|
12
|
-
import { useFormReset as
|
|
13
|
-
import { useSlidingIndicator as
|
|
14
|
-
import { formatCount as
|
|
15
|
-
import { KapiTooltip as
|
|
16
|
-
import { nextRadioIndex as m } from "./segmentedLogic.js";
|
|
17
|
-
import { useMemo as
|
|
18
|
-
import { Fragment as
|
|
12
|
+
import { useDuplicateValueWarning as l, useMutedControlWarning as te } from "./misuseWarnings.js";
|
|
13
|
+
import { useFormReset as ne } from "../../hooks/useFormReset.js";
|
|
14
|
+
import { useSlidingIndicator as u } from "../../hooks/useSlidingIndicator.js";
|
|
15
|
+
import { formatCount as d } from "../../hooks/numberFormatLogic.js";
|
|
16
|
+
import { KapiTooltip as f } from "../overlays/KapiTooltip.js";
|
|
17
|
+
import { nextRadioIndex as p, segmentedToneAttr as m } from "./segmentedLogic.js";
|
|
18
|
+
import { useMemo as re } from "react";
|
|
19
|
+
import { Fragment as ie, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
19
20
|
//#region src/components/inputs/KapiSegmented.tsx
|
|
20
|
-
var
|
|
21
|
-
let
|
|
22
|
-
id:
|
|
23
|
-
label:
|
|
24
|
-
help:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
var _ = (e) => n(e.activeTone, e.color, void 0), v = ({ items: n, value: v, defaultValue: y, onChange: b, variant: x = "text", "aria-label": S, className: C, name: w, onBlur: T, invalid: E, required: D, label: O, help: k, error: A, fieldClassName: j, disabled: M = !1, readOnly: N, size: P = "md", id: F, "aria-describedby": I, ref: L, ...R }) => {
|
|
22
|
+
let z = r(), B = s({
|
|
23
|
+
id: F,
|
|
24
|
+
label: O,
|
|
25
|
+
help: k,
|
|
26
|
+
error: A,
|
|
27
|
+
required: D,
|
|
28
|
+
invalid: E,
|
|
29
|
+
readOnly: N,
|
|
30
|
+
fieldClassName: j
|
|
31
|
+
}), V = o(N, B.field), H = (e) => M || n[e]?.disabled === !0, U = a(B.field, {
|
|
32
|
+
id: F,
|
|
33
|
+
describedBy: I,
|
|
34
|
+
invalid: E,
|
|
35
|
+
required: D,
|
|
34
36
|
labelable: !1,
|
|
35
|
-
ariaLabel:
|
|
36
|
-
}), [
|
|
37
|
-
l("KapiSegmented",
|
|
38
|
-
controlled:
|
|
39
|
-
hasOnChange: !!
|
|
40
|
-
readOnly:
|
|
41
|
-
disabled:
|
|
37
|
+
ariaLabel: S
|
|
38
|
+
}), [W, G, , K] = ee(v, () => y ?? n[0]?.id, b), q = ne(K), J = re(() => n.map((e) => e.id), [n]);
|
|
39
|
+
l("KapiSegmented", J), te("KapiSegmented", {
|
|
40
|
+
controlled: v !== void 0,
|
|
41
|
+
hasOnChange: !!b,
|
|
42
|
+
readOnly: V,
|
|
43
|
+
disabled: M
|
|
42
44
|
});
|
|
43
|
-
let
|
|
44
|
-
active:
|
|
45
|
-
deps: [
|
|
45
|
+
let Y = n.find((e) => e.id === W), X = e("KapiSegmented"), Z = X(Y ? _(Y) : void 0), { containerRef: Q, indicatorRef: ae } = u({
|
|
46
|
+
active: W ?? null,
|
|
47
|
+
deps: [n, x],
|
|
46
48
|
findActive: (e) => e.querySelector("[role=\"radio\"][aria-checked=\"true\"]")
|
|
47
|
-
}), $ =
|
|
48
|
-
if (
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
e.currentTarget.contains(e.relatedTarget) ||
|
|
49
|
+
}), $ = n.findIndex((e) => e.id === W), oe = $ >= 0 && !H($) ? $ : n.findIndex((e, t) => !H(t)), se = (e) => {
|
|
50
|
+
if (V) return;
|
|
51
|
+
let t = p(n.length, $, c(e), H), r = t === void 0 ? void 0 : n[t];
|
|
52
|
+
t !== void 0 && r && (e.preventDefault(), G(r.id), Q.current?.querySelectorAll("[role=\"radio\"]")[t]?.focus());
|
|
53
|
+
}, ce = (e) => {
|
|
54
|
+
e.currentTarget.contains(e.relatedTarget) || T?.(e);
|
|
53
55
|
};
|
|
54
|
-
return
|
|
55
|
-
...
|
|
56
|
-
...
|
|
56
|
+
return B.wrap(/* @__PURE__ */ g("div", {
|
|
57
|
+
...R,
|
|
58
|
+
...U,
|
|
57
59
|
ref: (e) => {
|
|
58
|
-
|
|
60
|
+
Q.current = e, q(e), i(L, e);
|
|
59
61
|
},
|
|
60
|
-
className:
|
|
62
|
+
className: t("kapi-seg", P === "sm" && "kapi-seg--sm", V && "kapi-seg--readonly", C),
|
|
61
63
|
role: "radiogroup",
|
|
62
|
-
"aria-label":
|
|
63
|
-
"aria-disabled":
|
|
64
|
-
"aria-readonly":
|
|
65
|
-
onKeyDown:
|
|
66
|
-
onBlur:
|
|
64
|
+
"aria-label": S,
|
|
65
|
+
"aria-disabled": M || void 0,
|
|
66
|
+
"aria-readonly": V || void 0,
|
|
67
|
+
onKeyDown: se,
|
|
68
|
+
onBlur: ce,
|
|
67
69
|
children: [
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
ref:
|
|
70
|
+
/* @__PURE__ */ h("span", {
|
|
71
|
+
ref: ae,
|
|
70
72
|
className: "kapi-seg__indicator",
|
|
71
|
-
"data-color":
|
|
73
|
+
"data-color": m(Z.tone, Z.style !== void 0),
|
|
74
|
+
style: Z.style,
|
|
72
75
|
"aria-hidden": "true"
|
|
73
76
|
}),
|
|
74
|
-
|
|
75
|
-
let n =
|
|
77
|
+
n.map((e, t) => {
|
|
78
|
+
let n = W === e.id, r = t === oe, i = X(e.tone), a = X(_(e)), o = n && a.style || i.style, s = /* @__PURE__ */ g("button", {
|
|
76
79
|
type: "button",
|
|
77
80
|
role: "radio",
|
|
78
81
|
"aria-checked": n,
|
|
79
|
-
tabIndex:
|
|
80
|
-
"aria-label":
|
|
82
|
+
tabIndex: r ? 0 : -1,
|
|
83
|
+
"aria-label": x === "icon" ? e.label : void 0,
|
|
81
84
|
className: `kapi-seg__btn${n ? " is-on" : ""}`,
|
|
82
|
-
"data-color": n ?
|
|
83
|
-
"data-tone":
|
|
84
|
-
|
|
85
|
+
"data-color": n ? m(a.tone, a.style !== void 0) : void 0,
|
|
86
|
+
"data-tone": m(i.tone, i.style !== void 0),
|
|
87
|
+
style: o,
|
|
88
|
+
disabled: H(t) || void 0,
|
|
85
89
|
onClick: () => {
|
|
86
|
-
|
|
90
|
+
V || G(e.id);
|
|
87
91
|
},
|
|
88
92
|
children: [
|
|
89
|
-
(
|
|
93
|
+
(x === "icon" || x === "both") && e.icon && /* @__PURE__ */ h("span", {
|
|
90
94
|
className: "kapi-seg__ico",
|
|
91
95
|
children: e.icon
|
|
92
96
|
}),
|
|
93
|
-
|
|
94
|
-
e.count != null && /* @__PURE__ */
|
|
97
|
+
x !== "icon" && /* @__PURE__ */ h("span", { children: e.label }),
|
|
98
|
+
e.count != null && /* @__PURE__ */ g(ie, { children: [" ", /* @__PURE__ */ h("span", {
|
|
95
99
|
className: "kapi-seg__n",
|
|
96
|
-
children:
|
|
100
|
+
children: d(e.count, z)
|
|
97
101
|
})] })
|
|
98
102
|
]
|
|
99
103
|
}, e.id);
|
|
100
|
-
return
|
|
104
|
+
return x === "icon" && e.label ? /* @__PURE__ */ h(f, {
|
|
101
105
|
label: e.label,
|
|
102
106
|
prefer: "top",
|
|
103
|
-
children:
|
|
104
|
-
}, e.id) :
|
|
107
|
+
children: s
|
|
108
|
+
}, e.id) : s;
|
|
105
109
|
}),
|
|
106
|
-
|
|
110
|
+
w && /* @__PURE__ */ h("input", {
|
|
107
111
|
type: "hidden",
|
|
108
|
-
name:
|
|
109
|
-
value:
|
|
110
|
-
disabled:
|
|
112
|
+
name: w,
|
|
113
|
+
value: W === void 0 ? "" : String(W),
|
|
114
|
+
disabled: M || void 0
|
|
111
115
|
})
|
|
112
116
|
]
|
|
113
117
|
}));
|
|
114
118
|
};
|
|
115
119
|
//#endregion
|
|
116
|
-
export {
|
|
120
|
+
export { v as KapiSegmented };
|
|
@@ -101,6 +101,12 @@ export interface KapiSelectBaseProps<T = unknown> {
|
|
|
101
101
|
chipLabel?: string | undefined;
|
|
102
102
|
/** Ayuda / mensaje de error bajo el control (envuelve el select en un `KapiField`). */
|
|
103
103
|
help?: ReactNode | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
|
|
106
|
+
* `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
|
|
107
|
+
* Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
|
|
108
|
+
*/
|
|
109
|
+
error?: ReactNode | undefined;
|
|
104
110
|
/** Clase del `KapiField` propio (con `label` o `help`). `className` va al select. */
|
|
105
111
|
fieldClassName?: string | undefined;
|
|
106
112
|
/**
|
|
@@ -163,13 +169,15 @@ export interface KapiSelectBaseProps<T = unknown> {
|
|
|
163
169
|
onBlur?: ((event: FocusEvent<HTMLElement>) => void) | undefined;
|
|
164
170
|
}
|
|
165
171
|
/** Clases del contenedor. Pura y exportada para testear. */
|
|
166
|
-
export declare const selectClasses: ({ size, open, disabled, readOnly, multi, chip, className }: {
|
|
172
|
+
export declare const selectClasses: ({ size, open, disabled, readOnly, multi, chip, invalid, className }: {
|
|
167
173
|
size?: KapiSelectSize | undefined;
|
|
168
174
|
open?: boolean | undefined;
|
|
169
175
|
disabled?: boolean | undefined;
|
|
170
176
|
readOnly?: boolean | undefined;
|
|
171
177
|
multi?: boolean | undefined;
|
|
172
178
|
chip?: boolean | undefined;
|
|
179
|
+
/** Pinta la caja en rojo, como ya hacían el input, el textarea y el stepper. */
|
|
180
|
+
invalid?: boolean | undefined;
|
|
173
181
|
className?: string | undefined;
|
|
174
182
|
}) => string;
|
|
175
183
|
/**
|