@zyncat/ui 0.8.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 +21 -0
- package/README.md +133 -0
- package/dist/alert.css +132 -0
- package/dist/alert.d.ts +46 -0
- package/dist/alert.js +80 -0
- package/dist/alert.js.map +1 -0
- package/dist/avatar-group.d.ts +24 -0
- package/dist/avatar-group.js +23 -0
- package/dist/avatar-group.js.map +1 -0
- package/dist/avatar.css +200 -0
- package/dist/avatar.d.ts +35 -0
- package/dist/avatar.js +67 -0
- package/dist/avatar.js.map +1 -0
- package/dist/badge.css +182 -0
- package/dist/badge.d.ts +34 -0
- package/dist/badge.js +4 -0
- package/dist/badge.js.map +1 -0
- package/dist/button.css +269 -0
- package/dist/button.d.ts +44 -0
- package/dist/button.js +4 -0
- package/dist/button.js.map +1 -0
- package/dist/checkbox.css +177 -0
- package/dist/checkbox.d.ts +35 -0
- package/dist/checkbox.js +5 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/chunk-2ERBBFZS.js +12 -0
- package/dist/chunk-2ERBBFZS.js.map +1 -0
- package/dist/chunk-2HORSLXJ.js +191 -0
- package/dist/chunk-2HORSLXJ.js.map +1 -0
- package/dist/chunk-36WVAQKL.js +40 -0
- package/dist/chunk-36WVAQKL.js.map +1 -0
- package/dist/chunk-3SBCBYB7.js +575 -0
- package/dist/chunk-3SBCBYB7.js.map +1 -0
- package/dist/chunk-4R2GQO43.js +125 -0
- package/dist/chunk-4R2GQO43.js.map +1 -0
- package/dist/chunk-64UU4LGU.js +258 -0
- package/dist/chunk-64UU4LGU.js.map +1 -0
- package/dist/chunk-7SZCJ7WI.js +35 -0
- package/dist/chunk-7SZCJ7WI.js.map +1 -0
- package/dist/chunk-BIDVNLJO.js +38 -0
- package/dist/chunk-BIDVNLJO.js.map +1 -0
- package/dist/chunk-CONSWNIV.js +17 -0
- package/dist/chunk-CONSWNIV.js.map +1 -0
- package/dist/chunk-EQ32F2QJ.js +75 -0
- package/dist/chunk-EQ32F2QJ.js.map +1 -0
- package/dist/chunk-GY7JOPUQ.js +111 -0
- package/dist/chunk-GY7JOPUQ.js.map +1 -0
- package/dist/chunk-I4XQ4PV2.js +30 -0
- package/dist/chunk-I4XQ4PV2.js.map +1 -0
- package/dist/chunk-JSKXZMLH.js +67 -0
- package/dist/chunk-JSKXZMLH.js.map +1 -0
- package/dist/chunk-L3Q3VDIW.js +295 -0
- package/dist/chunk-L3Q3VDIW.js.map +1 -0
- package/dist/chunk-LDC3RIYA.js +62 -0
- package/dist/chunk-LDC3RIYA.js.map +1 -0
- package/dist/chunk-MKIQFK7S.js +43 -0
- package/dist/chunk-MKIQFK7S.js.map +1 -0
- package/dist/chunk-MMRIQNEN.js +20 -0
- package/dist/chunk-MMRIQNEN.js.map +1 -0
- package/dist/chunk-MXOPCFWR.js +59 -0
- package/dist/chunk-MXOPCFWR.js.map +1 -0
- package/dist/chunk-NEF5XAHG.js +17 -0
- package/dist/chunk-NEF5XAHG.js.map +1 -0
- package/dist/chunk-NNXJCLTV.js +22 -0
- package/dist/chunk-NNXJCLTV.js.map +1 -0
- package/dist/chunk-O4N2OBTR.js +94 -0
- package/dist/chunk-O4N2OBTR.js.map +1 -0
- package/dist/chunk-PMECHR3A.js +38 -0
- package/dist/chunk-PMECHR3A.js.map +1 -0
- package/dist/chunk-QDK66S4G.js +44 -0
- package/dist/chunk-QDK66S4G.js.map +1 -0
- package/dist/chunk-QGNC7LH5.js +8 -0
- package/dist/chunk-QGNC7LH5.js.map +1 -0
- package/dist/chunk-QMSJZCK3.js +398 -0
- package/dist/chunk-QMSJZCK3.js.map +1 -0
- package/dist/chunk-S5ZTZANS.js +57 -0
- package/dist/chunk-S5ZTZANS.js.map +1 -0
- package/dist/chunk-S7B34VGN.js +14 -0
- package/dist/chunk-S7B34VGN.js.map +1 -0
- package/dist/chunk-TCUCYFT7.js +25 -0
- package/dist/chunk-TCUCYFT7.js.map +1 -0
- package/dist/chunk-TYHR4VNM.js +193 -0
- package/dist/chunk-TYHR4VNM.js.map +1 -0
- package/dist/chunk-U5QQZC3U.js +56 -0
- package/dist/chunk-U5QQZC3U.js.map +1 -0
- package/dist/chunk-UE63OOVG.js +13 -0
- package/dist/chunk-UE63OOVG.js.map +1 -0
- package/dist/chunk-VTJTGVZZ.js +22 -0
- package/dist/chunk-VTJTGVZZ.js.map +1 -0
- package/dist/chunk-W3SHPKSB.js +49 -0
- package/dist/chunk-W3SHPKSB.js.map +1 -0
- package/dist/chunk-XZAEIQDR.js +188 -0
- package/dist/chunk-XZAEIQDR.js.map +1 -0
- package/dist/chunk-YGGCQNNU.js +92 -0
- package/dist/chunk-YGGCQNNU.js.map +1 -0
- package/dist/collapse.css +88 -0
- package/dist/collapse.d.ts +46 -0
- package/dist/collapse.js +5 -0
- package/dist/collapse.js.map +1 -0
- package/dist/count-badge.d.ts +13 -0
- package/dist/count-badge.js +13 -0
- package/dist/count-badge.js.map +1 -0
- package/dist/date-field.d.ts +25 -0
- package/dist/date-field.js +87 -0
- package/dist/date-field.js.map +1 -0
- package/dist/date-picker.css +595 -0
- package/dist/date-range-field.d.ts +33 -0
- package/dist/date-range-field.js +404 -0
- package/dist/date-range-field.js.map +1 -0
- package/dist/datetime-field.d.ts +29 -0
- package/dist/datetime-field.js +155 -0
- package/dist/datetime-field.js.map +1 -0
- package/dist/dialog.css +180 -0
- package/dist/dialog.d.ts +42 -0
- package/dist/dialog.js +128 -0
- package/dist/dialog.js.map +1 -0
- package/dist/dom-props-C0jrllBw.d.ts +5 -0
- package/dist/field-chrome-CMPOQSLs.d.ts +28 -0
- package/dist/field-shell-Cuda-feL.d.ts +24 -0
- package/dist/glide.d.ts +15 -0
- package/dist/glide.js +5 -0
- package/dist/glide.js.map +1 -0
- package/dist/icon.css +33 -0
- package/dist/input.css +333 -0
- package/dist/mcp.js +359 -0
- package/dist/motion-devtools.css +265 -0
- package/dist/motion-devtools.d.ts +51 -0
- package/dist/motion-devtools.js +354 -0
- package/dist/motion-devtools.js.map +1 -0
- package/dist/motion-scale-Canq4stZ.d.ts +18 -0
- package/dist/motion-tokens.d.ts +28 -0
- package/dist/motion-tokens.js +3 -0
- package/dist/motion-tokens.js.map +1 -0
- package/dist/multi-select.d.ts +44 -0
- package/dist/multi-select.js +109 -0
- package/dist/multi-select.js.map +1 -0
- package/dist/number-field.d.ts +36 -0
- package/dist/number-field.js +112 -0
- package/dist/number-field.js.map +1 -0
- package/dist/odometer.css +62 -0
- package/dist/otp-field.d.ts +31 -0
- package/dist/otp-field.js +98 -0
- package/dist/otp-field.js.map +1 -0
- package/dist/overlay.css +23 -0
- package/dist/pagination.css +43 -0
- package/dist/pagination.d.ts +29 -0
- package/dist/pagination.js +107 -0
- package/dist/pagination.js.map +1 -0
- package/dist/popover.css +69 -0
- package/dist/popover.d.ts +35 -0
- package/dist/popover.js +15 -0
- package/dist/popover.js.map +1 -0
- package/dist/radio-group.css +300 -0
- package/dist/radio-group.d.ts +52 -0
- package/dist/radio-group.js +115 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/select.css +416 -0
- package/dist/select.d.ts +49 -0
- package/dist/select.js +99 -0
- package/dist/select.js.map +1 -0
- package/dist/sheet.css +26 -0
- package/dist/sheet.d.ts +31 -0
- package/dist/sheet.js +14 -0
- package/dist/sheet.js.map +1 -0
- package/dist/status-badge.d.ts +19 -0
- package/dist/status-badge.js +72 -0
- package/dist/status-badge.js.map +1 -0
- package/dist/table.css +348 -0
- package/dist/table.d.ts +75 -0
- package/dist/table.js +262 -0
- package/dist/table.js.map +1 -0
- package/dist/tabs.css +208 -0
- package/dist/tabs.d.ts +71 -0
- package/dist/tabs.js +181 -0
- package/dist/tabs.js.map +1 -0
- package/dist/tag.css +248 -0
- package/dist/tag.d.ts +52 -0
- package/dist/tag.js +72 -0
- package/dist/tag.js.map +1 -0
- package/dist/text-field.d.ts +28 -0
- package/dist/text-field.js +69 -0
- package/dist/text-field.js.map +1 -0
- package/dist/textarea.css +219 -0
- package/dist/textarea.d.ts +38 -0
- package/dist/textarea.js +144 -0
- package/dist/textarea.js.map +1 -0
- package/dist/time-field.d.ts +28 -0
- package/dist/time-field.js +66 -0
- package/dist/time-field.js.map +1 -0
- package/dist/timing-7JA_zQHP.d.ts +27 -0
- package/dist/toast-store.d.ts +86 -0
- package/dist/toast-store.js +3 -0
- package/dist/toast-store.js.map +1 -0
- package/dist/toast.css +257 -0
- package/dist/toast.d.ts +12 -0
- package/dist/toast.js +310 -0
- package/dist/toast.js.map +1 -0
- package/dist/toggle-tag.d.ts +34 -0
- package/dist/toggle-tag.js +57 -0
- package/dist/toggle-tag.js.map +1 -0
- package/dist/toggle.css +152 -0
- package/dist/toggle.d.ts +31 -0
- package/dist/toggle.js +75 -0
- package/dist/toggle.js.map +1 -0
- package/dist/tooltip.css +86 -0
- package/dist/tooltip.d.ts +30 -0
- package/dist/tooltip.js +268 -0
- package/dist/tooltip.js.map +1 -0
- package/dist/types-SGMShK7R.d.ts +22 -0
- package/llms.txt +196 -0
- package/next.d.mts +7 -0
- package/next.mjs +59 -0
- package/package.json +257 -0
- package/src/components/composites/alert/Alert.tsx +141 -0
- package/src/components/composites/alert/alert.css +132 -0
- package/src/components/composites/date-picker/DateField.tsx +80 -0
- package/src/components/composites/date-picker/DateRangeField.tsx +110 -0
- package/src/components/composites/date-picker/DateTimeField.tsx +162 -0
- package/src/components/composites/date-picker/TimeField.tsx +78 -0
- package/src/components/composites/date-picker/calendar-panel.tsx +216 -0
- package/src/components/composites/date-picker/date-picker.css +595 -0
- package/src/components/composites/date-picker/date-utils.ts +56 -0
- package/src/components/composites/date-picker/field-shell.tsx +85 -0
- package/src/components/composites/date-picker/range-panel.tsx +363 -0
- package/src/components/composites/date-picker/time-core.tsx +290 -0
- package/src/components/composites/date-picker/use-day-focus.ts +35 -0
- package/src/components/composites/dialog/Dialog.tsx +198 -0
- package/src/components/composites/dialog/dialog.css +180 -0
- package/src/components/composites/pagination/Pagination.tsx +131 -0
- package/src/components/composites/pagination/pagination.css +43 -0
- package/src/components/composites/popover/Popover.tsx +141 -0
- package/src/components/composites/popover/popover.css +69 -0
- package/src/components/composites/select/MultiSelect.tsx +133 -0
- package/src/components/composites/select/Select.tsx +122 -0
- package/src/components/composites/select/core/index.ts +4 -0
- package/src/components/composites/select/core/menu.tsx +100 -0
- package/src/components/composites/select/core/panel.tsx +154 -0
- package/src/components/composites/select/core/trigger.tsx +74 -0
- package/src/components/composites/select/core/types.ts +39 -0
- package/src/components/composites/select/core/use-listbox.ts +182 -0
- package/src/components/composites/select/select.css +416 -0
- package/src/components/composites/sheet/Sheet.tsx +135 -0
- package/src/components/composites/sheet/sheet.css +26 -0
- package/src/components/composites/sheet/use-sheet-drag.ts +126 -0
- package/src/components/composites/table/Table.tsx +377 -0
- package/src/components/composites/table/table.css +348 -0
- package/src/components/composites/tabs/Tabs.tsx +278 -0
- package/src/components/composites/tabs/tabs.css +208 -0
- package/src/components/composites/toast/Toast.tsx +380 -0
- package/src/components/composites/toast/toast-store.ts +295 -0
- package/src/components/composites/toast/toast.css +257 -0
- package/src/components/composites/tooltip/Tooltip.tsx +110 -0
- package/src/components/composites/tooltip/tooltip-host.tsx +184 -0
- package/src/components/composites/tooltip/tooltip-store.ts +81 -0
- package/src/components/composites/tooltip/tooltip.css +86 -0
- package/src/components/dev/MotionDevtools.tsx +200 -0
- package/src/components/dev/motion-devtools.css +265 -0
- package/src/components/dev/slowmo-engine.ts +230 -0
- package/src/components/internal/glass/glass.css +100 -0
- package/src/components/internal/glass/glint.ts +9 -0
- package/src/components/internal/hooks/use-controllable.ts +21 -0
- package/src/components/internal/hooks/use-scroll-edges.ts +46 -0
- package/src/components/internal/icon/Icon.tsx +66 -0
- package/src/components/internal/icon/IconSlot.tsx +10 -0
- package/src/components/internal/icon/icon.css +33 -0
- package/src/components/internal/overlay/focus.ts +68 -0
- package/src/components/internal/overlay/layer.tsx +149 -0
- package/src/components/internal/overlay/modal.tsx +141 -0
- package/src/components/internal/overlay/overlay.css +23 -0
- package/src/components/internal/overlay/position.ts +103 -0
- package/src/components/internal/utils/cx.ts +3 -0
- package/src/components/internal/utils/token-px.ts +8 -0
- package/src/components/primitives/avatar/Avatar.tsx +120 -0
- package/src/components/primitives/avatar/AvatarGroup.tsx +56 -0
- package/src/components/primitives/avatar/avatar.css +200 -0
- package/src/components/primitives/badge/Badge.tsx +75 -0
- package/src/components/primitives/badge/CountBadge.tsx +20 -0
- package/src/components/primitives/badge/StatusBadge.tsx +111 -0
- package/src/components/primitives/badge/badge.css +182 -0
- package/src/components/primitives/badge/odometer.css +62 -0
- package/src/components/primitives/badge/odometer.tsx +36 -0
- package/src/components/primitives/button/Button.tsx +102 -0
- package/src/components/primitives/button/button.css +269 -0
- package/src/components/primitives/checkbox/Checkbox.tsx +76 -0
- package/src/components/primitives/checkbox/check-glyph.tsx +28 -0
- package/src/components/primitives/checkbox/checkbox.css +177 -0
- package/src/components/primitives/collapse/Collapse.tsx +86 -0
- package/src/components/primitives/collapse/collapse.css +88 -0
- package/src/components/primitives/collapse/collapse.typecheck.tsx +29 -0
- package/src/components/primitives/input/NumberField.tsx +139 -0
- package/src/components/primitives/input/OtpField.tsx +134 -0
- package/src/components/primitives/input/TextField.tsx +110 -0
- package/src/components/primitives/input/field-chrome.tsx +83 -0
- package/src/components/primitives/input/input.css +333 -0
- package/src/components/primitives/radio-group/RadioGroup.tsx +183 -0
- package/src/components/primitives/radio-group/radio-group.css +300 -0
- package/src/components/primitives/tag/Tag.tsx +143 -0
- package/src/components/primitives/tag/ToggleTag.tsx +97 -0
- package/src/components/primitives/tag/tag.css +248 -0
- package/src/components/primitives/textarea/Textarea.tsx +190 -0
- package/src/components/primitives/textarea/textarea.css +219 -0
- package/src/components/primitives/toggle/Toggle.tsx +105 -0
- package/src/components/primitives/toggle/toggle.css +152 -0
- package/src/css.d.ts +1 -0
- package/src/dom-props.ts +1 -0
- package/src/engine/animate.ts +141 -0
- package/src/engine/drag.ts +53 -0
- package/src/engine/ease.ts +155 -0
- package/src/engine/flip.ts +59 -0
- package/src/engine/index.ts +13 -0
- package/src/mcp/server.ts +420 -0
- package/src/motion/element.tsx +53 -0
- package/src/motion/flip.tsx +87 -0
- package/src/motion/glide.tsx +47 -0
- package/src/motion/motion-timing.ts +33 -0
- package/src/motion/presence-context.ts +18 -0
- package/src/motion/presence.tsx +91 -0
- package/src/motion/timing.ts +49 -0
- package/src/motion/use-motion.ts +64 -0
- package/src/styles.css +26 -0
- package/src/tokens/avatar.css +20 -0
- package/src/tokens/color.css +58 -0
- package/src/tokens/elevation.css +22 -0
- package/src/tokens/fonts.css +3 -0
- package/src/tokens/glass.css +20 -0
- package/src/tokens/icons.css +7 -0
- package/src/tokens/layers.css +6 -0
- package/src/tokens/motion-scale.ts +17 -0
- package/src/tokens/motion-tokens.ts +92 -0
- package/src/tokens/motion.css +49 -0
- package/src/tokens/radius.css +11 -0
- package/src/tokens/semantic.css +65 -0
- package/src/tokens/spacing.css +26 -0
- package/src/tokens/typography.css +52 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';import { fireGlint } from './chunk-S7B34VGN.js';
|
|
2
|
+
import { UIMotion } from './chunk-S5ZTZANS.js';
|
|
3
|
+
import { Badge } from './chunk-PMECHR3A.js';
|
|
4
|
+
import { cx } from './chunk-QGNC7LH5.js';
|
|
5
|
+
import './badge.css';
|
|
6
|
+
import { useRef, useState, useLayoutEffect, useEffect } from 'react';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var SM = UIMotion;
|
|
10
|
+
var POST_STATUS = {
|
|
11
|
+
draft: { tone: "neutral", label: "Draft" },
|
|
12
|
+
scheduled: { tone: "info", label: "Scheduled" },
|
|
13
|
+
processing: { tone: "warning", label: "Processing", live: true },
|
|
14
|
+
published: { tone: "success", label: "Published" },
|
|
15
|
+
failed: { tone: "danger", label: "Failed" }
|
|
16
|
+
};
|
|
17
|
+
var TERMINAL = { published: true, failed: true };
|
|
18
|
+
function StatusBadge({ status, morph = false, ...rest }) {
|
|
19
|
+
if (!morph) {
|
|
20
|
+
const s = POST_STATUS[status] || POST_STATUS.draft;
|
|
21
|
+
return /* @__PURE__ */ jsx(Badge, { tone: s.tone, dot: true, live: !!s.live, ...rest, children: s.label });
|
|
22
|
+
}
|
|
23
|
+
return /* @__PURE__ */ jsx(StatusMorph, { status, ...rest });
|
|
24
|
+
}
|
|
25
|
+
function StatusMorph({ status, className = "", ...rest }) {
|
|
26
|
+
const s = POST_STATUS[status] || POST_STATUS.draft;
|
|
27
|
+
const prev = useRef(status);
|
|
28
|
+
const keyRef = useRef(1);
|
|
29
|
+
const labelRef = useRef(null);
|
|
30
|
+
const ghostRef = useRef(null);
|
|
31
|
+
const [words, setWords] = useState([{ key: 0, label: s.label, cls: "" }]);
|
|
32
|
+
const [boxW, setBoxW] = useState();
|
|
33
|
+
useLayoutEffect(() => {
|
|
34
|
+
if (ghostRef.current) setBoxW(ghostRef.current.offsetWidth);
|
|
35
|
+
}, []);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (prev.current === status) return;
|
|
38
|
+
prev.current = status;
|
|
39
|
+
const next = POST_STATUS[status] || POST_STATUS.draft;
|
|
40
|
+
const nk = keyRef.current++;
|
|
41
|
+
const nextW = ghostRef.current?.offsetWidth;
|
|
42
|
+
setWords((ws) => ws.concat({ key: nk, label: next.label, cls: "badge__word--in" }));
|
|
43
|
+
const raf = requestAnimationFrame(
|
|
44
|
+
() => requestAnimationFrame(() => {
|
|
45
|
+
setWords((ws) => ws.map((w) => w.key === nk ? { ...w, cls: "" } : { ...w, cls: "badge__word--out" }));
|
|
46
|
+
if (nextW) setBoxW(nextW);
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
const drop = setTimeout(
|
|
50
|
+
() => setWords((ws) => ws.filter((w) => !w.cls.includes("--out"))),
|
|
51
|
+
SM.dur.base * 1e3 + 80
|
|
52
|
+
);
|
|
53
|
+
let stopGlint;
|
|
54
|
+
if (TERMINAL[status] && labelRef.current) {
|
|
55
|
+
const chip = labelRef.current.closest(".badge");
|
|
56
|
+
if (chip) stopGlint = fireGlint(chip);
|
|
57
|
+
}
|
|
58
|
+
return () => {
|
|
59
|
+
cancelAnimationFrame(raf);
|
|
60
|
+
clearTimeout(drop);
|
|
61
|
+
stopGlint?.();
|
|
62
|
+
};
|
|
63
|
+
}, [status]);
|
|
64
|
+
return /* @__PURE__ */ jsx(Badge, { tone: s.tone, dot: true, live: !!s.live, className: cx("badge--morph", className), ...rest, children: /* @__PURE__ */ jsxs("span", { className: "badge__morph", ref: labelRef, style: boxW ? { width: boxW } : void 0, children: [
|
|
65
|
+
/* @__PURE__ */ jsx("span", { className: "badge__ghost", ref: ghostRef, "aria-hidden": "true", children: s.label }),
|
|
66
|
+
words.map((w) => /* @__PURE__ */ jsx("span", { className: cx("badge__word", w.cls), children: w.label }, w.key))
|
|
67
|
+
] }) });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { POST_STATUS, StatusBadge };
|
|
71
|
+
//# sourceMappingURL=status-badge.js.map
|
|
72
|
+
//# sourceMappingURL=status-badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/primitives/badge/StatusBadge.tsx"],"names":[],"mappings":"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","file":"status-badge.js","sourcesContent":["'use client';\n\nimport './badge.css';\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { Badge, type BadgeProps } from './Badge';\nimport { UIMotion } from '../../../tokens/motion-tokens';\nimport { fireGlint } from '../../internal/glass/glint';\nimport { cx } from '../../internal/utils/cx';\n\nconst SM = UIMotion;\n\nexport type PostStatus = 'draft' | 'scheduled' | 'processing' | 'published' | 'failed';\n\nexport const POST_STATUS: Record<PostStatus, { tone: BadgeProps['tone']; label: string; live?: boolean }> = {\n draft: { tone: 'neutral', label: 'Draft' },\n scheduled: { tone: 'info', label: 'Scheduled' },\n processing: { tone: 'warning', label: 'Processing', live: true },\n published: { tone: 'success', label: 'Published' },\n failed: { tone: 'danger', label: 'Failed' },\n};\n\nconst TERMINAL: Partial<Record<PostStatus, boolean>> = { published: true, failed: true };\n\nexport interface StatusBadgeProps extends Omit<BadgeProps, 'children' | 'tone'> {\n /** Lifecycle state - maps to a canonical `tone` + label (`processing` also pulses live). Unknown falls back to `draft`. */\n status: PostStatus;\n /** Morph in place as `status` changes instead of swapping. */\n morph?: boolean;\n}\n\nexport function StatusBadge({ status, morph = false, ...rest }: StatusBadgeProps) {\n if (!morph) {\n const s = POST_STATUS[status] || POST_STATUS.draft;\n return (\n <Badge tone={s.tone} dot live={!!s.live} {...rest}>\n {s.label}\n </Badge>\n );\n }\n return <StatusMorph status={status} {...rest} />;\n}\n\ninterface StatusMorphProps extends Omit<BadgeProps, 'children' | 'tone'> {\n status: PostStatus;\n}\n\ninterface Word {\n key: number;\n label: string;\n cls: string;\n}\n\nfunction StatusMorph({ status, className = '', ...rest }: StatusMorphProps) {\n const s = POST_STATUS[status] || POST_STATUS.draft;\n\n const prev = useRef(status);\n const keyRef = useRef(1);\n const labelRef = useRef<HTMLSpanElement>(null);\n const ghostRef = useRef<HTMLSpanElement>(null);\n const [words, setWords] = useState<Word[]>([{ key: 0, label: s.label, cls: '' }]);\n const [boxW, setBoxW] = useState<number>();\n\n useLayoutEffect(() => {\n if (ghostRef.current) setBoxW(ghostRef.current.offsetWidth);\n }, []);\n\n useEffect(() => {\n if (prev.current === status) return;\n prev.current = status;\n const next = POST_STATUS[status] || POST_STATUS.draft;\n const nk = keyRef.current++;\n const nextW = ghostRef.current?.offsetWidth;\n\n setWords((ws) => ws.concat({ key: nk, label: next.label, cls: 'badge__word--in' }));\n const raf = requestAnimationFrame(() =>\n requestAnimationFrame(() => {\n setWords((ws) => ws.map((w) => (w.key === nk ? { ...w, cls: '' } : { ...w, cls: 'badge__word--out' })));\n if (nextW) setBoxW(nextW);\n }),\n );\n const drop = setTimeout(\n () => setWords((ws) => ws.filter((w) => !w.cls.includes('--out'))),\n SM.dur.base * 1000 + 80,\n );\n let stopGlint: (() => void) | undefined;\n if (TERMINAL[status] && labelRef.current) {\n const chip = labelRef.current.closest('.badge') as HTMLElement | null;\n if (chip) stopGlint = fireGlint(chip);\n }\n return () => {\n cancelAnimationFrame(raf);\n clearTimeout(drop);\n stopGlint?.();\n };\n }, [status]);\n\n return (\n <Badge tone={s.tone} dot live={!!s.live} className={cx('badge--morph', className)} {...rest}>\n <span className=\"badge__morph\" ref={labelRef} style={boxW ? { width: boxW } : undefined}>\n <span className=\"badge__ghost\" ref={ghostRef} aria-hidden=\"true\">\n {s.label}\n </span>\n {words.map((w) => (\n <span key={w.key} className={cx('badge__word', w.cls)}>\n {w.label}\n </span>\n ))}\n </span>\n </Badge>\n );\n}\n"]}
|
package/dist/table.css
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/* Table - geometry + paint: sticky header, sortable columns, row selection + bulk bar, pinned identity column. */
|
|
2
|
+
|
|
3
|
+
.tbl,
|
|
4
|
+
.tbl * {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.tbl {
|
|
9
|
+
--tbl-pad-y: var(--space-3);
|
|
10
|
+
--tbl-head-py: var(--space-3);
|
|
11
|
+
--tbl-head-h: calc(var(--leading-caption) + 2 * var(--tbl-head-py));
|
|
12
|
+
/* checkbox column: pad 8 + (8 + 18 + 8 hit area) + pad 8 - all tokens */
|
|
13
|
+
--tbl-check-w: calc(var(--control-box) + 4 * var(--space-2));
|
|
14
|
+
|
|
15
|
+
position: relative;
|
|
16
|
+
container-type: inline-size;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
max-height: 100%;
|
|
20
|
+
background: var(--bg-surface);
|
|
21
|
+
border: var(--border-hairline) solid var(--border-default);
|
|
22
|
+
border-radius: var(--radius-lg);
|
|
23
|
+
box-shadow: var(--shadow-xs);
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.tbl--compact {
|
|
28
|
+
--tbl-pad-y: var(--space-2);
|
|
29
|
+
--tbl-head-py: var(--space-2);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.tbl__viewport {
|
|
33
|
+
position: relative;
|
|
34
|
+
display: flex; /* flex sizing, not % height - % inside a max-height parent resolves to auto, scroller would grow to content */
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
flex: 1 1 auto;
|
|
37
|
+
min-height: 0;
|
|
38
|
+
}
|
|
39
|
+
.tbl__scroll {
|
|
40
|
+
flex: 1 1 auto;
|
|
41
|
+
min-height: 0;
|
|
42
|
+
overflow: auto;
|
|
43
|
+
overscroll-behavior: contain;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.tbl__table {
|
|
47
|
+
width: 100%;
|
|
48
|
+
border-collapse: separate; /* collapse breaks sticky borders */
|
|
49
|
+
border-spacing: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.tbl__table thead th {
|
|
53
|
+
position: sticky;
|
|
54
|
+
top: 0;
|
|
55
|
+
z-index: 2;
|
|
56
|
+
height: var(--tbl-head-h);
|
|
57
|
+
padding: var(--tbl-head-py) var(--space-3);
|
|
58
|
+
background: var(--bg-surface);
|
|
59
|
+
border-bottom: var(--border-hairline) solid var(--border-default);
|
|
60
|
+
font: var(--type-caption);
|
|
61
|
+
font-weight: var(--weight-medium);
|
|
62
|
+
color: var(--text-muted);
|
|
63
|
+
text-align: left;
|
|
64
|
+
vertical-align: middle;
|
|
65
|
+
white-space: nowrap;
|
|
66
|
+
transition: box-shadow var(--duration-base) var(--ease-standard);
|
|
67
|
+
}
|
|
68
|
+
.tbl[data-scrolled] .tbl__table thead th {
|
|
69
|
+
box-shadow: var(--shadow-sm);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.tbl__table td {
|
|
73
|
+
padding: var(--tbl-pad-y) var(--space-3);
|
|
74
|
+
border-bottom: var(--border-hairline) solid var(--border-subtle);
|
|
75
|
+
background: var(--row-bg, var(--bg-surface));
|
|
76
|
+
font: var(--type-body);
|
|
77
|
+
color: var(--text-body);
|
|
78
|
+
vertical-align: middle;
|
|
79
|
+
white-space: nowrap; /* data tables don't wrap - grow column absorbs slack; overflow scrolls + pins */
|
|
80
|
+
transition: background-color var(--duration-fast) var(--ease-standard);
|
|
81
|
+
}
|
|
82
|
+
.tbl__table tbody tr:last-child td {
|
|
83
|
+
border-bottom: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* outermost cells breathe a step more (16) - sortables do it via the button */
|
|
87
|
+
.tbl__table th:first-child:not(.tbl__cell--check):not(.tbl__cell--sortable),
|
|
88
|
+
.tbl__table td:first-child:not(.tbl__cell--check) {
|
|
89
|
+
padding-inline-start: var(--space-4);
|
|
90
|
+
}
|
|
91
|
+
.tbl__table th:last-child:not(.tbl__cell--sortable),
|
|
92
|
+
.tbl__table td:last-child {
|
|
93
|
+
padding-inline-end: var(--space-4);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* one opaque --row-bg per row, read by every cell - stays opaque so sticky cells cover scrolled content */
|
|
97
|
+
.tbl__row {
|
|
98
|
+
--row-bg: var(--bg-surface);
|
|
99
|
+
}
|
|
100
|
+
.tbl__row:hover {
|
|
101
|
+
--row-bg: var(--bg-subtle);
|
|
102
|
+
}
|
|
103
|
+
.tbl__row[data-selected] {
|
|
104
|
+
--row-bg: color-mix(in oklab, var(--accent) 5%, var(--bg-surface));
|
|
105
|
+
}
|
|
106
|
+
.tbl__row[data-selected]:hover {
|
|
107
|
+
--row-bg: color-mix(in oklab, var(--accent) 5%, var(--bg-subtle));
|
|
108
|
+
}
|
|
109
|
+
.tbl--clickable tbody .tbl__row {
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.tbl__table td.tbl__cell--mono {
|
|
114
|
+
font: var(--type-mono);
|
|
115
|
+
font-variant-numeric: tabular-nums;
|
|
116
|
+
}
|
|
117
|
+
.tbl__table td.tbl__cell--strong {
|
|
118
|
+
color: var(--text-strong);
|
|
119
|
+
font-weight: var(--weight-medium);
|
|
120
|
+
}
|
|
121
|
+
.tbl__cell--end {
|
|
122
|
+
text-align: right;
|
|
123
|
+
}
|
|
124
|
+
.tbl__cell--center {
|
|
125
|
+
text-align: center;
|
|
126
|
+
}
|
|
127
|
+
.tbl__cell--grow {
|
|
128
|
+
width: 100%;
|
|
129
|
+
} /* greedy column; auto table layout sizes the others to content */
|
|
130
|
+
|
|
131
|
+
/* sort: full-cell button, inset by a margin so its focus ring isn't clipped */
|
|
132
|
+
.tbl__table th.tbl__cell--sortable {
|
|
133
|
+
padding: 0;
|
|
134
|
+
}
|
|
135
|
+
.tbl__sort {
|
|
136
|
+
appearance: none;
|
|
137
|
+
border: 0;
|
|
138
|
+
background: transparent;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
gap: var(--space-1);
|
|
143
|
+
width: calc(100% - 2 * var(--space-1));
|
|
144
|
+
height: calc(var(--tbl-head-h) - 2 * var(--space-1));
|
|
145
|
+
margin: var(--space-1);
|
|
146
|
+
padding-inline: var(--space-2);
|
|
147
|
+
border-radius: var(--radius-sm);
|
|
148
|
+
font: inherit;
|
|
149
|
+
font-weight: inherit;
|
|
150
|
+
color: inherit;
|
|
151
|
+
white-space: nowrap;
|
|
152
|
+
transition: var(--transition-colors);
|
|
153
|
+
}
|
|
154
|
+
.tbl__table th.tbl__cell--sortable:first-child .tbl__sort {
|
|
155
|
+
padding-inline-start: var(--space-3);
|
|
156
|
+
}
|
|
157
|
+
.tbl__table th.tbl__cell--sortable:last-child .tbl__sort {
|
|
158
|
+
padding-inline-end: var(--space-3);
|
|
159
|
+
}
|
|
160
|
+
.tbl__cell--end .tbl__sort {
|
|
161
|
+
justify-content: flex-end;
|
|
162
|
+
}
|
|
163
|
+
.tbl__cell--center .tbl__sort {
|
|
164
|
+
justify-content: center;
|
|
165
|
+
}
|
|
166
|
+
.tbl__sort:hover {
|
|
167
|
+
color: var(--text-strong);
|
|
168
|
+
background: var(--neutral-wash);
|
|
169
|
+
}
|
|
170
|
+
.tbl__sort:focus-visible {
|
|
171
|
+
outline: none;
|
|
172
|
+
box-shadow: var(--focus-ring);
|
|
173
|
+
}
|
|
174
|
+
.tbl__table th[aria-sort] .tbl__sort {
|
|
175
|
+
color: var(--text-strong);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.tbl__sortIcon {
|
|
179
|
+
display: inline-flex;
|
|
180
|
+
flex: none;
|
|
181
|
+
opacity: 0;
|
|
182
|
+
transition:
|
|
183
|
+
opacity var(--duration-fast) var(--ease-standard),
|
|
184
|
+
transform var(--duration-base) var(--ease-glide);
|
|
185
|
+
}
|
|
186
|
+
.tbl__sort:hover .tbl__sortIcon,
|
|
187
|
+
.tbl__sort:focus-visible .tbl__sortIcon {
|
|
188
|
+
opacity: 0.5;
|
|
189
|
+
}
|
|
190
|
+
.tbl__sortIcon.is-on {
|
|
191
|
+
opacity: 1;
|
|
192
|
+
}
|
|
193
|
+
.tbl__sortIcon.is-desc {
|
|
194
|
+
transform: rotate(180deg);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.tbl__table .tbl__cell--check {
|
|
198
|
+
width: var(--tbl-check-w);
|
|
199
|
+
padding: 0 var(--space-2);
|
|
200
|
+
}
|
|
201
|
+
.tbl__cbx {
|
|
202
|
+
display: inline-flex;
|
|
203
|
+
}
|
|
204
|
+
.tbl__cbx .cbx__box {
|
|
205
|
+
margin-top: 0;
|
|
206
|
+
} /* no label - no baseline offset */
|
|
207
|
+
|
|
208
|
+
/* bulk bar: absolute overlay that morphs from the header; the delayed visibility flip removes it from paint + tab order only after the exit fade, while pointer-events dies on close */
|
|
209
|
+
.tbl__bulk {
|
|
210
|
+
position: absolute;
|
|
211
|
+
top: 0;
|
|
212
|
+
left: 0;
|
|
213
|
+
right: 0;
|
|
214
|
+
z-index: 4;
|
|
215
|
+
height: calc(var(--tbl-head-h) + var(--border-hairline));
|
|
216
|
+
display: flex;
|
|
217
|
+
align-items: center;
|
|
218
|
+
gap: var(--space-2);
|
|
219
|
+
padding-inline: var(--space-2);
|
|
220
|
+
background: var(--accent-subtle);
|
|
221
|
+
border-bottom: var(--border-hairline) solid var(--accent-border);
|
|
222
|
+
opacity: 0;
|
|
223
|
+
transform: translateY(calc(-1 * var(--space-2)));
|
|
224
|
+
visibility: hidden;
|
|
225
|
+
pointer-events: none;
|
|
226
|
+
transition:
|
|
227
|
+
opacity var(--duration-fast) var(--ease-exit),
|
|
228
|
+
transform var(--duration-fast) var(--ease-exit),
|
|
229
|
+
visibility 0s linear var(--duration-fast);
|
|
230
|
+
}
|
|
231
|
+
.tbl__bulk[data-open] {
|
|
232
|
+
opacity: 1;
|
|
233
|
+
transform: none;
|
|
234
|
+
visibility: visible;
|
|
235
|
+
pointer-events: auto;
|
|
236
|
+
transition:
|
|
237
|
+
opacity var(--duration-base) var(--ease-standard),
|
|
238
|
+
transform var(--duration-base) var(--ease-entrance),
|
|
239
|
+
visibility 0s;
|
|
240
|
+
}
|
|
241
|
+
.tbl__bulk .cbx:not(.cbx--disabled):hover {
|
|
242
|
+
background: var(--accent-wash);
|
|
243
|
+
}
|
|
244
|
+
.tbl__bulkCount {
|
|
245
|
+
display: inline-flex;
|
|
246
|
+
align-items: baseline;
|
|
247
|
+
font-family: var(--font-mono);
|
|
248
|
+
font-size: var(--size-caption);
|
|
249
|
+
line-height: var(--leading-caption);
|
|
250
|
+
font-weight: var(--weight-medium);
|
|
251
|
+
font-variant-numeric: tabular-nums;
|
|
252
|
+
color: var(--text-accent);
|
|
253
|
+
white-space: pre; /* keep the space before "selected" */
|
|
254
|
+
}
|
|
255
|
+
.tbl__bulkSpacer {
|
|
256
|
+
flex: 1 1 auto;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.tbl--pin .tbl__cell--pin {
|
|
260
|
+
position: sticky;
|
|
261
|
+
left: 0;
|
|
262
|
+
z-index: 1;
|
|
263
|
+
}
|
|
264
|
+
.tbl--pin thead .tbl__cell--pin {
|
|
265
|
+
z-index: 3;
|
|
266
|
+
}
|
|
267
|
+
.tbl--pin .tbl__cell--pinOff {
|
|
268
|
+
left: var(--tbl-check-w);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/* soft cast off the pinned edge once content scrolls behind it (gradient exception, section B3) */
|
|
272
|
+
.tbl--pin .tbl__cell--pinEdge::after {
|
|
273
|
+
content: '';
|
|
274
|
+
position: absolute;
|
|
275
|
+
top: 0;
|
|
276
|
+
bottom: calc(-1 * var(--border-hairline));
|
|
277
|
+
left: 100%;
|
|
278
|
+
width: var(--space-3);
|
|
279
|
+
background: linear-gradient(to right, var(--gray-wash), transparent);
|
|
280
|
+
opacity: 0;
|
|
281
|
+
transition: var(--transition-opacity);
|
|
282
|
+
pointer-events: none;
|
|
283
|
+
}
|
|
284
|
+
.tbl[data-x-back] .tbl__cell--pinEdge::after {
|
|
285
|
+
opacity: 1;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.tbl__edge {
|
|
289
|
+
position: absolute;
|
|
290
|
+
top: 0;
|
|
291
|
+
bottom: 0;
|
|
292
|
+
width: var(--space-6);
|
|
293
|
+
z-index: 3;
|
|
294
|
+
opacity: 0;
|
|
295
|
+
transition: var(--transition-opacity);
|
|
296
|
+
pointer-events: none;
|
|
297
|
+
}
|
|
298
|
+
.tbl__edge--l {
|
|
299
|
+
left: 0;
|
|
300
|
+
background: linear-gradient(to right, var(--bg-surface), transparent);
|
|
301
|
+
}
|
|
302
|
+
.tbl__edge--r {
|
|
303
|
+
right: 0;
|
|
304
|
+
background: linear-gradient(to left, var(--bg-surface), transparent);
|
|
305
|
+
}
|
|
306
|
+
.tbl[data-x-more] .tbl__edge--r {
|
|
307
|
+
opacity: 1;
|
|
308
|
+
}
|
|
309
|
+
.tbl[data-x-back]:not(.tbl--pin) .tbl__edge--l {
|
|
310
|
+
opacity: 1;
|
|
311
|
+
} /* when pinned, the pinned column itself is the left-edge signal */
|
|
312
|
+
|
|
313
|
+
.tbl__emptyCell {
|
|
314
|
+
padding: var(--space-7) var(--space-4);
|
|
315
|
+
text-align: center;
|
|
316
|
+
font: var(--type-body);
|
|
317
|
+
color: var(--text-muted);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.tbl__table tbody {
|
|
321
|
+
transition: var(--transition-opacity);
|
|
322
|
+
}
|
|
323
|
+
.tbl--loading .tbl__table tbody {
|
|
324
|
+
opacity: 0.45;
|
|
325
|
+
pointer-events: none;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.tbl__foot {
|
|
329
|
+
display: flex;
|
|
330
|
+
align-items: center;
|
|
331
|
+
justify-content: flex-end;
|
|
332
|
+
gap: var(--space-3);
|
|
333
|
+
padding: var(--space-2) var(--space-3);
|
|
334
|
+
background: var(--bg-subtle);
|
|
335
|
+
border-top: var(--border-hairline) solid var(--border-subtle);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* column collapse at container breakpoints - 30rem / 42rem are intentional constants (no breakpoint tokens yet) */
|
|
339
|
+
@container (max-width: 42rem) {
|
|
340
|
+
.tbl__cell--hide-md {
|
|
341
|
+
display: none;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
@container (max-width: 30rem) {
|
|
345
|
+
.tbl__cell--hide-sm {
|
|
346
|
+
display: none;
|
|
347
|
+
}
|
|
348
|
+
}
|
package/dist/table.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, HTMLAttributes } from 'react';
|
|
3
|
+
import { D as DataAttributes } from './dom-props-C0jrllBw.js';
|
|
4
|
+
|
|
5
|
+
type TableAlign = 'start' | 'end' | 'center';
|
|
6
|
+
type TableHideBelow = 'sm' | 'md';
|
|
7
|
+
interface TableColumn<Row = any> {
|
|
8
|
+
/** Unique column id; also the default data accessor (row[key]). */
|
|
9
|
+
key: string;
|
|
10
|
+
/** Header cell content; omit for a header-less column (e.g. an actions column). */
|
|
11
|
+
label?: ReactNode;
|
|
12
|
+
/** Cell + header alignment. Default 'start'. */
|
|
13
|
+
align?: TableAlign;
|
|
14
|
+
/** Mono + tabular numerals (timestamps, counts, IDs - section E). */
|
|
15
|
+
mono?: boolean;
|
|
16
|
+
/** Identity emphasis: strong text, medium weight. */
|
|
17
|
+
strong?: boolean;
|
|
18
|
+
/** The one greedy column - absorbs slack width. Others size to content. */
|
|
19
|
+
grow?: boolean;
|
|
20
|
+
/** Header becomes a sort control. Sort is local; asc - desc, no third state. */
|
|
21
|
+
sortable?: boolean;
|
|
22
|
+
/** Sort accessor: a row property name, or a function. Defaults to row[key]. */
|
|
23
|
+
sortBy?: string | ((row: Row) => unknown);
|
|
24
|
+
/** Collapse this column below a container breakpoint (30rem / 42rem). */
|
|
25
|
+
hideBelow?: TableHideBelow;
|
|
26
|
+
/** Custom cell renderer. Defaults to row[key]. */
|
|
27
|
+
render?: (row: Row) => ReactNode;
|
|
28
|
+
}
|
|
29
|
+
interface TableSort {
|
|
30
|
+
/** `key` of the column being sorted by. */
|
|
31
|
+
key: string;
|
|
32
|
+
/** Sort direction - `asc` or `desc`. */
|
|
33
|
+
dir: 'asc' | 'desc';
|
|
34
|
+
}
|
|
35
|
+
interface TableProps<Row = any> {
|
|
36
|
+
/** Column defs, rendered left to right. */
|
|
37
|
+
columns: TableColumn<Row>[];
|
|
38
|
+
/** The row data; sorted locally per the active sort before render. */
|
|
39
|
+
rows: Row[];
|
|
40
|
+
/** Row identity property. Default 'id'. Must be unique and stable. */
|
|
41
|
+
rowKey?: string;
|
|
42
|
+
/** Accessible name for the <table>. */
|
|
43
|
+
ariaLabel?: string;
|
|
44
|
+
/** Checkbox column + bulk bar. Selection is a Set of row keys, owned here. */
|
|
45
|
+
selectable?: boolean;
|
|
46
|
+
/** Fires with the selected row keys after every selection change. */
|
|
47
|
+
onSelectionChange?: (keys: Array<string | number>) => void;
|
|
48
|
+
/** Rendered in the bulk bar between the count and the built-in Clear. */
|
|
49
|
+
bulkActions?: (keys: Array<string | number>, clear: () => void) => ReactNode;
|
|
50
|
+
/** Per-row checkbox aria-label. Default 'Select row'. */
|
|
51
|
+
selectionLabel?: (row: Row) => string;
|
|
52
|
+
/** Initial sort; sorting stays local and uncontrolled after that. */
|
|
53
|
+
defaultSort?: TableSort | null;
|
|
54
|
+
/** Notification only - fires after the local sort updates. */
|
|
55
|
+
onSortChange?: (sort: TableSort) => void;
|
|
56
|
+
/** Row rhythm. Default 'cozy' (46px rows); 'compact' is 38px. */
|
|
57
|
+
density?: 'cozy' | 'compact';
|
|
58
|
+
/** Pin checkbox + first column under horizontal overflow. Default true. */
|
|
59
|
+
pinFirst?: boolean;
|
|
60
|
+
/** Rows recede and go inert (list-fetch convention). */
|
|
61
|
+
loading?: boolean;
|
|
62
|
+
/** Shown when rows is empty and not loading. Default 'Nothing to show'. */
|
|
63
|
+
empty?: ReactNode;
|
|
64
|
+
/** Footer strip - pagination, summaries. */
|
|
65
|
+
footer?: ReactNode;
|
|
66
|
+
/** Makes rows clickable (checkbox cell excluded). */
|
|
67
|
+
onRowClick?: (row: Row) => void;
|
|
68
|
+
/** Size the table here - the internal scroller absorbs the constraint. */
|
|
69
|
+
className?: string;
|
|
70
|
+
/** Standard <div> attributes (style, data-*, aria-*, ...) forwarded to the table wrapper. */
|
|
71
|
+
htmlProps?: Omit<HTMLAttributes<HTMLDivElement>, 'className'> & DataAttributes;
|
|
72
|
+
}
|
|
73
|
+
declare function Table<Row = any>({ columns, rows, rowKey, ariaLabel, selectable, onSelectionChange, bulkActions, selectionLabel, defaultSort, onSortChange, density, pinFirst, loading, empty, footer, onRowClick, className, htmlProps, }: TableProps<Row>): react.JSX.Element;
|
|
74
|
+
|
|
75
|
+
export { Table, type TableAlign, type TableColumn, type TableHideBelow, type TableProps, type TableSort };
|