@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
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { joinClasses as e } from "../rootProps.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { copyText as t } from "../inputs/copyLogic.js";
|
|
4
|
+
import { columnAlign as n, readCell as r, stickySideOf as i } from "./tableLogic.js";
|
|
5
|
+
import { KapiSkeleton as a } from "../feedback/KapiSkeleton.js";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
import { ChevronDown as c, ChevronUp as l, ChevronsUpDown as u, Copy as d, Loader2 as f } from "lucide-react";
|
|
7
8
|
//#region src/components/data/tableCells.tsx
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} catch {}
|
|
12
|
-
t?.(e);
|
|
13
|
-
}, p = (e, t, n) => {
|
|
9
|
+
var p = async (e, n, r) => {
|
|
10
|
+
await t(String(e), r) && n?.(e);
|
|
11
|
+
}, m = (e, t, n) => {
|
|
14
12
|
let r = n[e.key];
|
|
15
13
|
return r === void 0 ? t === "th" ? {
|
|
16
14
|
width: e.flex ? "100%" : e.width,
|
|
@@ -24,103 +22,103 @@ var f = (e, t) => {
|
|
|
24
22
|
minWidth: r,
|
|
25
23
|
maxWidth: r
|
|
26
24
|
};
|
|
27
|
-
},
|
|
28
|
-
let
|
|
29
|
-
if (
|
|
30
|
-
},
|
|
31
|
-
let a =
|
|
32
|
-
return e(a && "is-sticky", a === "right" && "is-sticky-right", a === "left" && n ===
|
|
33
|
-
},
|
|
25
|
+
}, h = (e) => {
|
|
26
|
+
let t = n(e);
|
|
27
|
+
if (t) return `is-align-${t}${t === "start" ? " is-align-left" : t === "end" ? " is-align-right" : ""}`;
|
|
28
|
+
}, g = (t, n, r) => {
|
|
29
|
+
let a = i(t.sticky);
|
|
30
|
+
return e(a && "is-sticky", a === "right" && "is-sticky-right", a === "left" && n === r.lastLeft && "is-sticky-last", a === "right" && n === r.firstRight && "is-sticky-first-right", t.flex && "is-flex", h(t.align));
|
|
31
|
+
}, _ = (e, t) => ({
|
|
34
32
|
insetInlineStart: t.lefts[e],
|
|
35
33
|
insetInlineEnd: t.rights[e]
|
|
36
|
-
}),
|
|
37
|
-
let
|
|
34
|
+
}), v = (e) => `kapi-actcol${e.firstRight >= 0 ? " is-joined" : ""}`, y = (e, t, n, i) => {
|
|
35
|
+
let a = e.render ? e.render(t) : r(t, e.key), c = e.clamp === void 0 ? a : /* @__PURE__ */ o("span", {
|
|
38
36
|
className: "kapi-cell-clamp",
|
|
39
37
|
style: { "--kapi-cell-lines": String(e.clamp) },
|
|
40
|
-
children:
|
|
38
|
+
children: a
|
|
41
39
|
});
|
|
42
40
|
if (!e.copyable) return c;
|
|
43
|
-
let l = e.copyValue ? e.copyValue(t) :
|
|
44
|
-
return /* @__PURE__ */
|
|
41
|
+
let l = e.copyValue ? e.copyValue(t) : r(t, e.key);
|
|
42
|
+
return /* @__PURE__ */ s("span", {
|
|
45
43
|
className: "kapi-cell",
|
|
46
|
-
children: [/* @__PURE__ */
|
|
44
|
+
children: [/* @__PURE__ */ o("span", {
|
|
47
45
|
className: "kapi-cell__v",
|
|
48
46
|
children: c
|
|
49
|
-
}), /* @__PURE__ */
|
|
47
|
+
}), /* @__PURE__ */ o("button", {
|
|
50
48
|
type: "button",
|
|
51
49
|
className: "kapi-cell__copy",
|
|
52
|
-
"aria-label":
|
|
50
|
+
"aria-label": n.copy,
|
|
53
51
|
onClick: (e) => {
|
|
54
|
-
e.stopPropagation(),
|
|
52
|
+
e.stopPropagation(), p(l, i, e.currentTarget);
|
|
55
53
|
},
|
|
56
|
-
children: /* @__PURE__ */
|
|
54
|
+
children: /* @__PURE__ */ o(d, {
|
|
57
55
|
size: 13,
|
|
58
56
|
strokeWidth: 2
|
|
59
57
|
})
|
|
60
58
|
})]
|
|
61
59
|
});
|
|
62
|
-
},
|
|
60
|
+
}, b = (e) => e === "asc" ? /* @__PURE__ */ o(l, {
|
|
63
61
|
size: 13,
|
|
64
62
|
strokeWidth: 2.4
|
|
65
|
-
}) : e === "desc" ? /* @__PURE__ */
|
|
63
|
+
}) : e === "desc" ? /* @__PURE__ */ o(c, {
|
|
66
64
|
size: 13,
|
|
67
65
|
strokeWidth: 2.4
|
|
68
|
-
}) : /* @__PURE__ */
|
|
66
|
+
}) : /* @__PURE__ */ o(u, {
|
|
69
67
|
size: 13,
|
|
70
68
|
strokeWidth: 2
|
|
71
|
-
}),
|
|
69
|
+
}), x = (e, t) => t?.key === e.key ? t.direction : "none", S = (e, t) => {
|
|
72
70
|
if (!e.sortable) return;
|
|
73
|
-
let n =
|
|
71
|
+
let n = x(e, t);
|
|
74
72
|
return n === "none" ? "none" : n === "asc" ? "ascending" : "descending";
|
|
75
|
-
},
|
|
73
|
+
}, C = (e, t, n, r) => {
|
|
76
74
|
if (!e.sortable) return e.label;
|
|
77
|
-
let i =
|
|
78
|
-
return /* @__PURE__ */
|
|
75
|
+
let i = x(e, t);
|
|
76
|
+
return /* @__PURE__ */ s("button", {
|
|
79
77
|
type: "button",
|
|
80
78
|
className: `kapi-thsort${i === "none" ? "" : " is-active"}`,
|
|
81
79
|
onClick: () => n(e.key),
|
|
82
80
|
title: typeof e.label == "string" ? `${r.sortBy} ${e.label}` : void 0,
|
|
83
|
-
children: [/* @__PURE__ */
|
|
81
|
+
children: [/* @__PURE__ */ o("span", { children: e.label }), b(i)]
|
|
84
82
|
});
|
|
85
|
-
},
|
|
83
|
+
}, w = (e, t, n = !1) => /* @__PURE__ */ o("tr", {
|
|
86
84
|
className: "kapi-table-staterow",
|
|
87
|
-
children: /* @__PURE__ */
|
|
85
|
+
children: /* @__PURE__ */ s("td", {
|
|
88
86
|
colSpan: e,
|
|
89
87
|
className: "kapi-table-state",
|
|
90
|
-
children: [n && /* @__PURE__ */
|
|
88
|
+
children: [n && /* @__PURE__ */ o(f, {
|
|
91
89
|
size: 16,
|
|
92
90
|
strokeWidth: 2.2,
|
|
93
91
|
className: "kapi-table-spin",
|
|
94
92
|
"aria-hidden": !0
|
|
95
|
-
}), /* @__PURE__ */
|
|
93
|
+
}), /* @__PURE__ */ o("span", { children: t })]
|
|
96
94
|
})
|
|
97
|
-
}),
|
|
95
|
+
}), T = [
|
|
98
96
|
96,
|
|
99
97
|
72,
|
|
100
98
|
84,
|
|
101
99
|
60
|
|
102
|
-
],
|
|
100
|
+
], E = (e, t, n) => {
|
|
103
101
|
let r = e.flex ? `${[
|
|
104
102
|
70,
|
|
105
103
|
55,
|
|
106
104
|
80
|
|
107
|
-
][n % 3]}%` : Math.max(32, Math.min(
|
|
108
|
-
return /* @__PURE__ */ a
|
|
105
|
+
][n % 3]}%` : Math.max(32, Math.min(T[(t + n) % T.length] ?? 72, (e.width ?? 120) - 36));
|
|
106
|
+
return /* @__PURE__ */ o(a, {
|
|
109
107
|
width: r,
|
|
110
108
|
height: 14,
|
|
111
109
|
radius: 6
|
|
112
110
|
});
|
|
113
|
-
},
|
|
111
|
+
}, D = (e, t, r, i, a, s, c, l) => /* @__PURE__ */ o("td", {
|
|
114
112
|
"data-col": e.key,
|
|
115
113
|
colSpan: l !== void 0 && l > 1 ? l : void 0,
|
|
116
|
-
className:
|
|
114
|
+
className: g(e, t, i),
|
|
117
115
|
style: {
|
|
118
|
-
...
|
|
119
|
-
...
|
|
120
|
-
textAlign:
|
|
116
|
+
..._(t, i),
|
|
117
|
+
...m(e, "td", a),
|
|
118
|
+
textAlign: n(e.align)
|
|
121
119
|
},
|
|
122
120
|
"data-label": typeof e.label == "string" || typeof e.label == "number" ? String(e.label) : void 0,
|
|
123
|
-
children:
|
|
121
|
+
children: y(e, r, s, c)
|
|
124
122
|
}, e.key);
|
|
125
123
|
//#endregion
|
|
126
|
-
export {
|
|
124
|
+
export { v as actColClass, S as ariaSortOf, D as bodyCell, g as cellClass, n as columnAlign, m as columnBoxStyle, p as copyToClipboard, C as headerContent, y as renderCell, E as skeletonBar, x as sortDirectionOf, b as sortIcon, w as stateRow, _ as stickyInset };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useControllableState as e } from "../../hooks/useControllableState.js";
|
|
3
|
+
import { useRangeSelect as t } from "../../hooks/useRangeSelect.js";
|
|
4
4
|
import { slot as n } from "../slotsLogic.js";
|
|
5
5
|
import { formatCount as r } from "../../hooks/numberFormatLogic.js";
|
|
6
6
|
import { selectOnlyWithin as i, selectionState as a } from "./tableLogic.js";
|
|
@@ -11,7 +11,7 @@ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
|
11
11
|
import { Loader2 as h } from "lucide-react";
|
|
12
12
|
//#region src/components/data/useTableSelection.tsx
|
|
13
13
|
var g = [], _ = ({ rows: n, keyField: o, selectable: s, selectedIds: c, defaultSelectedIds: u, onSelectedIdsChange: _, isRowSelectable: v, selectionPresets: y, rangeSelect: b, dataset: x, loadingLabel: S, locale: C }) => {
|
|
14
|
-
let [w, T] =
|
|
14
|
+
let [w, T] = e(c, u ?? g, _ && ((e) => _([...e]))), E = d(() => new Set(w), [w]), D = (e) => T([...e]), O = () => D(/* @__PURE__ */ new Set()), k = [...E], A = t(), j = s && y !== void 0 && y.length > 0, M = d(() => n.filter((e) => !v || v(e)), [n, v]), N = d(() => M.map((e) => e[o]), [M, o]), P = d(() => j && y ? y.map((e) => ({
|
|
15
15
|
preset: e,
|
|
16
16
|
matching: e.match === void 0 ? [] : M.filter(e.match).map((e) => e[o])
|
|
17
17
|
})) : [], [
|
|
@@ -1,122 +1,127 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/display/KapiAnnotation.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
5
|
+
import { joinIds as ee } from "../inputs/fieldLogic.js";
|
|
6
|
+
import { resolveKapiRoot as n } from "../../hooks/kapiRoot.js";
|
|
7
|
+
import { usePlacement as r } from "../../hooks/usePlacement.js";
|
|
7
8
|
import { useDismiss as i } from "../../hooks/useDismiss.js";
|
|
8
9
|
import { KapiTooltip as a } from "../overlays/KapiTooltip.js";
|
|
9
10
|
import { annotationClasses as o, annotationRole as s } from "./annotationLogic.js";
|
|
10
11
|
/* empty css */
|
|
11
|
-
import { useEffect as c, useId as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { createPortal as
|
|
12
|
+
import { useEffect as c, useId as te, useRef as l, useState as u } from "react";
|
|
13
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
14
|
+
import { createPortal as p } from "react-dom";
|
|
14
15
|
//#region src/components/display/KapiAnnotation.tsx
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
let
|
|
18
|
-
underline:
|
|
19
|
-
tone:
|
|
20
|
-
clickable: !!
|
|
21
|
-
className:
|
|
16
|
+
var m = 8, h = 8, g = 150;
|
|
17
|
+
function _({ children: _, info: v, underline: y = "dotted", tone: ne = "primary", onClick: b, popover: x, interactive: S = !1, className: C, "aria-label": w, ref: T, ...E }) {
|
|
18
|
+
let D = te(), O = l(null), k = t(O, T), [A, j] = u(!1), [M, N] = u(!1), P = l(null), F = l(void 0), { element: I, tabIndex: L, mode: R } = s(b, x, v), z = e("KapiAnnotation", ne), B = o({
|
|
19
|
+
underline: y,
|
|
20
|
+
tone: z.tone,
|
|
21
|
+
clickable: !!b,
|
|
22
|
+
className: C
|
|
22
23
|
}), V = (e) => {
|
|
23
|
-
e.key === "Escape" && (
|
|
24
|
-
}, H = () => clearTimeout(
|
|
25
|
-
H(),
|
|
24
|
+
e.key === "Escape" && (j(!1), N(!0));
|
|
25
|
+
}, H = () => clearTimeout(F.current), U = () => {
|
|
26
|
+
H(), N(!1), j(!0);
|
|
26
27
|
}, W = () => {
|
|
27
|
-
H(),
|
|
28
|
+
H(), j(!1), N(!1);
|
|
28
29
|
}, G = () => {
|
|
29
|
-
if (!
|
|
30
|
-
H(),
|
|
30
|
+
if (!S) return W();
|
|
31
|
+
H(), F.current = setTimeout(W, g);
|
|
31
32
|
}, K = (e) => {
|
|
32
33
|
let t = e.relatedTarget;
|
|
33
|
-
|
|
34
|
-
}, { placement: q } =
|
|
35
|
-
open:
|
|
36
|
-
anchor:
|
|
37
|
-
floatingRef:
|
|
34
|
+
S && t && P.current?.contains(t) || W();
|
|
35
|
+
}, { placement: q } = r({
|
|
36
|
+
open: A,
|
|
37
|
+
anchor: O,
|
|
38
|
+
floatingRef: P,
|
|
38
39
|
side: "bottom",
|
|
39
40
|
align: "center",
|
|
40
|
-
offset:
|
|
41
|
-
margin:
|
|
41
|
+
offset: m,
|
|
42
|
+
margin: h
|
|
42
43
|
}), J = q ? {
|
|
43
44
|
top: q.top,
|
|
44
45
|
left: q.centerX,
|
|
45
46
|
side: q.side === "top" ? "top" : "bottom"
|
|
46
|
-
} : null, Y = i(
|
|
47
|
-
zones: [
|
|
47
|
+
} : null, Y = i(A && S, {
|
|
48
|
+
zones: [O, P],
|
|
48
49
|
onDismiss: (e) => {
|
|
49
50
|
if (e === "outside") return W();
|
|
50
|
-
|
|
51
|
+
j(!1), N(!0);
|
|
51
52
|
}
|
|
52
53
|
});
|
|
53
|
-
c(() => () => clearTimeout(
|
|
54
|
+
c(() => () => clearTimeout(F.current), []);
|
|
54
55
|
let X = {
|
|
55
|
-
...
|
|
56
|
-
|
|
56
|
+
...E,
|
|
57
|
+
style: z.style ? {
|
|
58
|
+
...z.style,
|
|
59
|
+
...E.style
|
|
60
|
+
} : E.style,
|
|
61
|
+
ref: k,
|
|
57
62
|
className: B,
|
|
58
63
|
onKeyDown: V,
|
|
59
|
-
onClick:
|
|
60
|
-
...
|
|
61
|
-
"data-dismissed":
|
|
64
|
+
onClick: b,
|
|
65
|
+
...w !== void 0 && { "aria-label": w },
|
|
66
|
+
"data-dismissed": M ? "" : void 0
|
|
62
67
|
};
|
|
63
|
-
if (
|
|
64
|
-
let e = String(
|
|
68
|
+
if (R === "tooltip") {
|
|
69
|
+
let e = String(v), t = I === "button" ? /* @__PURE__ */ d("button", {
|
|
65
70
|
...X,
|
|
66
71
|
type: "button",
|
|
67
72
|
onBlur: W,
|
|
68
|
-
children:
|
|
69
|
-
}) : /* @__PURE__ */
|
|
73
|
+
children: _
|
|
74
|
+
}) : /* @__PURE__ */ d("span", {
|
|
70
75
|
...X,
|
|
71
|
-
tabIndex:
|
|
76
|
+
tabIndex: L,
|
|
72
77
|
onBlur: W,
|
|
73
|
-
children:
|
|
78
|
+
children: _
|
|
74
79
|
});
|
|
75
|
-
return /* @__PURE__ */
|
|
80
|
+
return /* @__PURE__ */ d(a, {
|
|
76
81
|
label: e,
|
|
77
82
|
prefer: "top",
|
|
78
83
|
children: t
|
|
79
84
|
});
|
|
80
85
|
}
|
|
81
|
-
let Z =
|
|
86
|
+
let Z = x ?? { body: v }, Q = {
|
|
82
87
|
...X,
|
|
83
|
-
"aria-describedby":
|
|
88
|
+
"aria-describedby": ee(E["aria-describedby"], A && D),
|
|
84
89
|
onFocus: U,
|
|
85
90
|
onBlur: K
|
|
86
|
-
}, $ =
|
|
87
|
-
return /* @__PURE__ */
|
|
91
|
+
}, $ = A ? n(O.current) : null;
|
|
92
|
+
return /* @__PURE__ */ f("span", {
|
|
88
93
|
className: "kapi-annotation-wrap",
|
|
89
94
|
onMouseEnter: U,
|
|
90
95
|
onMouseLeave: G,
|
|
91
96
|
onKeyDown: Y,
|
|
92
|
-
children: [
|
|
97
|
+
children: [I === "button" ? /* @__PURE__ */ d("button", {
|
|
93
98
|
...Q,
|
|
94
99
|
type: "button",
|
|
95
|
-
children:
|
|
96
|
-
}) : /* @__PURE__ */
|
|
100
|
+
children: _
|
|
101
|
+
}) : /* @__PURE__ */ d("span", {
|
|
97
102
|
...Q,
|
|
98
|
-
tabIndex:
|
|
99
|
-
children:
|
|
100
|
-
}), $ &&
|
|
101
|
-
ref:
|
|
102
|
-
id:
|
|
103
|
+
tabIndex: L,
|
|
104
|
+
children: _
|
|
105
|
+
}), $ && p(/* @__PURE__ */ f("span", {
|
|
106
|
+
ref: P,
|
|
107
|
+
id: D,
|
|
103
108
|
role: "tooltip",
|
|
104
109
|
className: "kapi-annotation__pop",
|
|
105
110
|
"data-side": J?.side ?? "bottom",
|
|
106
|
-
"data-interactive":
|
|
111
|
+
"data-interactive": S ? "" : void 0,
|
|
107
112
|
style: {
|
|
108
113
|
top: J?.top ?? 0,
|
|
109
114
|
left: J?.left ?? 0,
|
|
110
115
|
visibility: J ? void 0 : "hidden"
|
|
111
116
|
},
|
|
112
|
-
tabIndex:
|
|
113
|
-
onMouseEnter:
|
|
114
|
-
onMouseLeave:
|
|
115
|
-
onBlur:
|
|
116
|
-
children: [Z.title && /* @__PURE__ */
|
|
117
|
+
tabIndex: S ? -1 : void 0,
|
|
118
|
+
onMouseEnter: S ? H : void 0,
|
|
119
|
+
onMouseLeave: S ? G : void 0,
|
|
120
|
+
onBlur: S ? K : void 0,
|
|
121
|
+
children: [Z.title && /* @__PURE__ */ d("span", {
|
|
117
122
|
className: "kapi-annotation__title",
|
|
118
123
|
children: Z.title
|
|
119
|
-
}), /* @__PURE__ */
|
|
124
|
+
}), /* @__PURE__ */ d("span", {
|
|
120
125
|
className: "kapi-annotation__body",
|
|
121
126
|
children: Z.body
|
|
122
127
|
})]
|
|
@@ -124,4 +129,4 @@ function v({ children: v, info: y, underline: b = "dotted", tone: x = "primary",
|
|
|
124
129
|
});
|
|
125
130
|
}
|
|
126
131
|
//#endregion
|
|
127
|
-
export {
|
|
132
|
+
export { _ as KapiAnnotation };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { HTMLAttributes, Ref } from "react";
|
|
2
|
-
import { type KapiTone } from "../tone.js";
|
|
2
|
+
import { type KapiFamilyTone, type KapiTone } from "../tone.js";
|
|
3
3
|
export type KapiAvatarSize = "sm" | "md" | "lg" | number;
|
|
4
|
-
/** Tono de un avatar: `auto` (según el nombre)
|
|
5
|
-
export type KapiAvatarTone = "auto" | KapiTone;
|
|
4
|
+
/** Tono de un avatar: `auto` (según el nombre), un `KapiTone` o una familia propia de la app. */
|
|
5
|
+
export type KapiAvatarTone = "auto" | KapiTone | KapiFamilyTone;
|
|
6
6
|
/** @deprecated Usar `KapiAvatarTone`. */
|
|
7
7
|
export type KapiAvatarColor = KapiAvatarTone;
|
|
8
8
|
export type KapiAvatarProps = Omit<HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
@@ -24,9 +24,11 @@ export type KapiAvatarProps = Omit<HTMLAttributes<HTMLSpanElement>, "children">
|
|
|
24
24
|
/** Orden fijo de los roles para el color automático (cambiarlo cambia los colores de todos). */
|
|
25
25
|
export declare const AVATAR_ROLES: ReadonlyArray<KapiTone>;
|
|
26
26
|
/** Clases de un avatar. Pura y exportada. */
|
|
27
|
-
export declare const avatarClasses: ({ size, role, className }: {
|
|
27
|
+
export declare const avatarClasses: ({ size, role, family, className }: {
|
|
28
28
|
size?: KapiAvatarSize | undefined;
|
|
29
29
|
role: KapiTone;
|
|
30
|
+
/** El color sale de una familia de la app: va por `--family`, que lee los slots locales. */
|
|
31
|
+
family?: boolean | undefined;
|
|
30
32
|
className?: string | undefined;
|
|
31
33
|
}) => string;
|
|
32
34
|
/** Avatar circular: imagen o iniciales sobre el color subtle del rol. */
|
|
@@ -1,45 +1,50 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/display/display.css";
|
|
3
|
-
import {
|
|
3
|
+
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { isFamilyTone as t, resolveTone as n } from "../tone.js";
|
|
4
5
|
/* empty css */
|
|
5
|
-
import { colorIndexFrom as
|
|
6
|
-
import { jsx as
|
|
6
|
+
import { colorIndexFrom as r, initialsFrom as i } from "./avatarLogic.js";
|
|
7
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
8
|
//#region src/components/display/KapiAvatar.tsx
|
|
8
|
-
var
|
|
9
|
+
var o = [
|
|
9
10
|
"primary",
|
|
10
11
|
"success",
|
|
11
12
|
"info",
|
|
12
13
|
"warning",
|
|
13
14
|
"danger",
|
|
14
15
|
"neutral"
|
|
15
|
-
],
|
|
16
|
+
], s = ({ size: e = "md", role: t, family: n = !1, className: r = "" }) => [
|
|
16
17
|
"kapi-avatar",
|
|
17
|
-
`kapi-avatar--${t}`,
|
|
18
|
+
n ? "kapi-avatar--family" : `kapi-avatar--${t}`,
|
|
18
19
|
typeof e == "string" && e !== "md" && `kapi-avatar--${e}`,
|
|
19
|
-
|
|
20
|
+
r
|
|
20
21
|
].filter(Boolean).join(" ");
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
width:
|
|
24
|
-
height:
|
|
25
|
-
fontSize: Math.round(
|
|
26
|
-
...
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
function c({ name: c = "", initials: l, src: u, size: d = "md", tone: f, color: p, className: m, style: h, ...g }) {
|
|
23
|
+
let _ = n(f, p, "auto"), v = t(_), y = e("KapiAvatar", v ? _ : void 0), b = v || _ === "auto" ? o[r(c, o.length)] ?? "neutral" : _, x = c || l || "", S = typeof d == "number" ? d : void 0, C = S === void 0 ? h : {
|
|
24
|
+
width: S,
|
|
25
|
+
height: S,
|
|
26
|
+
fontSize: Math.round(S * .38),
|
|
27
|
+
...h
|
|
28
|
+
}, w = y.style ? {
|
|
29
|
+
...y.style,
|
|
30
|
+
...C
|
|
31
|
+
} : C;
|
|
32
|
+
return /* @__PURE__ */ a("span", {
|
|
33
|
+
className: s({
|
|
34
|
+
size: d,
|
|
35
|
+
role: b,
|
|
36
|
+
family: y.style !== void 0,
|
|
37
|
+
className: m
|
|
33
38
|
}),
|
|
34
|
-
style:
|
|
35
|
-
role:
|
|
36
|
-
"aria-label":
|
|
37
|
-
...
|
|
38
|
-
children:
|
|
39
|
-
src:
|
|
40
|
-
alt:
|
|
41
|
-
}) :
|
|
39
|
+
style: w,
|
|
40
|
+
role: u || !x ? void 0 : "img",
|
|
41
|
+
"aria-label": u || !x ? void 0 : x,
|
|
42
|
+
...g,
|
|
43
|
+
children: u ? /* @__PURE__ */ a("img", {
|
|
44
|
+
src: u,
|
|
45
|
+
alt: c
|
|
46
|
+
}) : l ?? i(c)
|
|
42
47
|
});
|
|
43
48
|
}
|
|
44
49
|
//#endregion
|
|
45
|
-
export {
|
|
50
|
+
export { o as AVATAR_ROLES, c as KapiAvatar, s as avatarClasses };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode, Ref } from "react";
|
|
2
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
3
|
+
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
4
|
+
/** Textos de `KapiCodeBlock`; se pisan con `labels` o el `KapiLocaleProvider`. */
|
|
5
|
+
export type KapiCodeBlockLabels = {
|
|
6
|
+
/** Nombre accesible de la región, con `{lang}` = el lenguaje si se pasó. */
|
|
7
|
+
region: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const DEFAULT_CODE_BLOCK_LABELS: KapiCodeBlockLabels;
|
|
10
|
+
/** Atributos nativos (`id`, `style`, `data-*`…) van al `<figure>` raíz. */
|
|
11
|
+
export type KapiCodeBlockProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & {
|
|
12
|
+
/** Ref al `<figure>` raíz. */
|
|
13
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
14
|
+
/** El código, tal cual. Es lo que se copia, aunque `children` dibuje otra cosa. */
|
|
15
|
+
code: string;
|
|
16
|
+
/**
|
|
17
|
+
* El código ya resaltado. Sin esto se dibuja `code` plano.
|
|
18
|
+
*
|
|
19
|
+
* El resaltado lo inyecta la app a propósito: un highlighter adentro rompería la regla de cero
|
|
20
|
+
* dependencias de runtime, y además cada app ya tiene el suyo. Lo que se COPIA sigue saliendo de
|
|
21
|
+
* `code`, así que el resaltado nunca puede ensuciar el portapapeles.
|
|
22
|
+
*/
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
/** Lenguaje, para el rótulo y el `data-lang`. No cambia el dibujo. */
|
|
25
|
+
lang?: string | undefined;
|
|
26
|
+
/** Título sobre el bloque (nombre de archivo, ruta). */
|
|
27
|
+
title?: ReactNode;
|
|
28
|
+
/** Oculta el botón de copiar. @default false */
|
|
29
|
+
noCopy?: boolean | undefined;
|
|
30
|
+
/** Avisa el resultado REAL de copiar: `true` sólo si el portapapeles aceptó. */
|
|
31
|
+
onCopy?: ((ok: boolean) => void) | undefined;
|
|
32
|
+
/** Numera las líneas. @default false */
|
|
33
|
+
lineNumbers?: boolean | undefined;
|
|
34
|
+
/** Textos propios; pisan los del `KapiLocaleProvider` y los defaults. */
|
|
35
|
+
labels?: KapiLabelsOverride<KapiCodeBlockLabels> | undefined;
|
|
36
|
+
/** Clases por parte (`root`, `bar`, `title`, `copy`, `pre`, `numbers`, `code`). */
|
|
37
|
+
classNames?: KapiClassNames<"codeBlock"> | undefined;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Bloque de código con botón de copiar.
|
|
41
|
+
*
|
|
42
|
+
* Dos cosas que no se deducen del markup. **Lo que se copia es `code`, no lo que se ve**: si la
|
|
43
|
+
* app inyecta su resaltado por `children`, el portapapeles igual recibe el texto limpio, sin los
|
|
44
|
+
* `<span>` del highlighter ni los números de línea. Y **el botón confirma sólo si copió de
|
|
45
|
+
* verdad**, porque usa `KapiCopyButton`: en http sin TLS el portapapeles no existe y un «Copiado»
|
|
46
|
+
* ahí sería mentira.
|
|
47
|
+
*/
|
|
48
|
+
export declare function KapiCodeBlock({ code, children, lang, title, noCopy, onCopy, lineNumbers, labels, classNames, className, ...rest }: KapiCodeBlockProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "#kapi-css/components/display/KapiCodeBlock.css";
|
|
3
|
+
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
4
|
+
import { KapiCopyButton as t } from "../inputs/KapiCopyButton.js";
|
|
5
|
+
import { slot as n } from "../slotsLogic.js";
|
|
6
|
+
import { CODE_BLOCK_SLOTS as r } from "./codeBlockSlots.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/display/KapiCodeBlock.tsx
|
|
10
|
+
var o = { region: "Bloque de código {lang}" };
|
|
11
|
+
function s({ code: s, children: c, lang: l, title: u, noCopy: d = !1, onCopy: f, lineNumbers: p = !1, labels: m, classNames: h, className: g, ..._ }) {
|
|
12
|
+
let v = e("codeBlock", o, m), y = p ? s.split("\n") : null;
|
|
13
|
+
return /* @__PURE__ */ a("figure", {
|
|
14
|
+
..._,
|
|
15
|
+
...n(r, "root", h, g),
|
|
16
|
+
"data-lang": l,
|
|
17
|
+
"aria-label": v.region.replace("{lang}", l ?? "").trim(),
|
|
18
|
+
children: [(u !== void 0 || !d) && /* @__PURE__ */ a("figcaption", {
|
|
19
|
+
...n(r, "bar", h),
|
|
20
|
+
children: [/* @__PURE__ */ i("span", {
|
|
21
|
+
...n(r, "title", h),
|
|
22
|
+
children: u
|
|
23
|
+
}), !d && /* @__PURE__ */ i(t, {
|
|
24
|
+
value: s,
|
|
25
|
+
size: "sm",
|
|
26
|
+
variant: "ghost",
|
|
27
|
+
...f ? { onCopy: f } : {},
|
|
28
|
+
...n(r, "copy", h)
|
|
29
|
+
})]
|
|
30
|
+
}), /* @__PURE__ */ a("pre", {
|
|
31
|
+
...n(r, "pre", h),
|
|
32
|
+
children: [y && /* @__PURE__ */ i("span", {
|
|
33
|
+
...n(r, "numbers", h),
|
|
34
|
+
"aria-hidden": "true",
|
|
35
|
+
children: y.map((e, t) => /* @__PURE__ */ i("span", { children: t + 1 }, t))
|
|
36
|
+
}), /* @__PURE__ */ i("code", {
|
|
37
|
+
...n(r, "code", h),
|
|
38
|
+
children: c ?? s
|
|
39
|
+
})]
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { o as DEFAULT_CODE_BLOCK_LABELS, s as KapiCodeBlock };
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import "#kapi-css/components/display/KapiComment.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
4
|
import { KapiButton as t } from "../inputs/KapiButton.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
6
|
+
import { assignRef as r, joinIds as i } from "../inputs/fieldLogic.js";
|
|
7
|
+
import { useKapiField as a } from "../inputs/KapiField.js";
|
|
8
8
|
import { KapiTextarea as o } from "../inputs/KapiTextarea.js";
|
|
9
9
|
/* empty css */
|
|
10
10
|
import { isSubmitShortcut as s } from "./commentLogic.js";
|
|
@@ -18,7 +18,7 @@ var f = {
|
|
|
18
18
|
submit: "Comentar",
|
|
19
19
|
shortcut: "Ctrl o ⌘ + Enter para enviar"
|
|
20
20
|
}, p = ({ value: p, defaultValue: m, onChange: h, onSubmit: g, loading: _ = !1, invalid: v, required: y, disabled: b, className: x, style: S, labels: C, ref: w, placeholder: T, onKeyDown: E, "aria-label": D, "aria-labelledby": O, "aria-describedby": k, ...A }) => {
|
|
21
|
-
let j =
|
|
21
|
+
let j = n("commentComposer", f, C), M = a(), N = l(), { text: P, setText: F, submit: I, busy: L, canSubmit: R, boxRef: z } = c({
|
|
22
22
|
value: p,
|
|
23
23
|
defaultValue: m,
|
|
24
24
|
onChange: h,
|
|
@@ -37,7 +37,7 @@ var f = {
|
|
|
37
37
|
children: [/* @__PURE__ */ u(o, {
|
|
38
38
|
...A,
|
|
39
39
|
ref: (e) => {
|
|
40
|
-
z.current = e,
|
|
40
|
+
z.current = e, r(w, e);
|
|
41
41
|
},
|
|
42
42
|
className: "kapi-composer__input",
|
|
43
43
|
autosize: !0,
|
|
@@ -48,7 +48,7 @@ var f = {
|
|
|
48
48
|
placeholder: T ?? j.placeholder,
|
|
49
49
|
"aria-label": V ? D : j.label,
|
|
50
50
|
"aria-labelledby": O,
|
|
51
|
-
"aria-describedby":
|
|
51
|
+
"aria-describedby": i(k, N),
|
|
52
52
|
...y === void 0 ? {} : { required: y },
|
|
53
53
|
...v ? { invalid: !0 } : {},
|
|
54
54
|
onChange: (e) => F(e.target.value),
|