@devalok/shilp-sutra 0.57.0 → 0.60.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/MIGRATION.md +163 -0
- package/dist/_chunks/badge-group.js +75 -188
- package/dist/_chunks/badge-group.js.map +1 -1
- package/dist/_chunks/chat.js +244 -243
- package/dist/_chunks/chat.js.map +1 -1
- package/dist/_chunks/image-preview.js +71 -70
- package/dist/_chunks/image-preview.js.map +1 -1
- package/dist/_chunks/motion-preference.js +15 -0
- package/dist/_chunks/motion-preference.js.map +1 -0
- package/dist/_chunks/motion-provider.js +1 -1
- package/dist/_chunks/motion-provider.js.map +1 -1
- package/dist/_chunks/popover.js +50 -49
- package/dist/_chunks/popover.js.map +1 -1
- package/dist/_chunks/primitives-internal.js +29 -29
- package/dist/_chunks/primitives-internal.js.map +1 -1
- package/dist/_chunks/shared.js +48 -47
- package/dist/_chunks/shared.js.map +1 -1
- package/dist/_chunks/success.js +34 -34
- package/dist/_chunks/tree-view.js +1 -1
- package/dist/_chunks/tree-view.js.map +1 -1
- package/dist/ai/block-renderer.js +8 -8
- package/dist/ai/command-bar.js +65 -65
- package/dist/ai/command-bar.js.map +1 -1
- package/dist/ai/conversation.js +35 -35
- package/dist/ai/conversation.js.map +1 -1
- package/dist/ai/index.js +4 -4
- package/dist/composed/activity-feed.d.ts.map +1 -1
- package/dist/composed/activity-feed.js +108 -107
- package/dist/composed/activity-feed.js.map +1 -1
- package/dist/composed/avatar-group.js +3 -3
- package/dist/composed/avatar-group.js.map +1 -1
- package/dist/composed/bulk-action-bar.d.ts +9 -35
- package/dist/composed/bulk-action-bar.d.ts.map +1 -1
- package/dist/composed/bulk-action-bar.js +2 -139
- package/dist/composed/command-palette.js +137 -137
- package/dist/composed/command-palette.js.map +1 -1
- package/dist/composed/content-card.js +1 -1
- package/dist/composed/content-card.js.map +1 -1
- package/dist/composed/date-picker/index.js +5 -5
- package/dist/composed/date-picker/index.js.map +1 -1
- package/dist/composed/empty-state.js +4 -4
- package/dist/composed/file-preview/image-preview.d.ts.map +1 -1
- package/dist/composed/file-preview/shared.d.ts.map +1 -1
- package/dist/composed/file-preview/video-preview.d.ts.map +1 -1
- package/dist/composed/file-preview.js +151 -150
- package/dist/composed/file-preview.js.map +1 -1
- package/dist/composed/filter-bar.d.ts.map +1 -1
- package/dist/composed/filter-bar.js +53 -52
- package/dist/composed/filter-bar.js.map +1 -1
- package/dist/composed/form-section.d.ts.map +1 -1
- package/dist/composed/form-section.js +38 -37
- package/dist/composed/form-section.js.map +1 -1
- package/dist/composed/index.js +6 -5
- package/dist/composed/master-detail.d.ts.map +1 -1
- package/dist/composed/master-detail.js +1 -1
- package/dist/composed/master-detail.js.map +1 -1
- package/dist/composed/multi-select-popover.d.ts.map +1 -1
- package/dist/composed/multi-select-popover.js +109 -108
- package/dist/composed/multi-select-popover.js.map +1 -1
- package/dist/composed/rich-chat-input/attachment-strip.d.ts.map +1 -1
- package/dist/composed/rich-chat-input/reply-banner.d.ts.map +1 -1
- package/dist/composed/rich-chat-input/schedule-send.d.ts.map +1 -1
- package/dist/composed/rich-chat-input.d.ts.map +1 -1
- package/dist/composed/rich-chat-input.js +467 -466
- package/dist/composed/rich-chat-input.js.map +1 -1
- package/dist/composed/rich-text-editor.js +3 -3
- package/dist/composed/rich-text-editor.js.map +1 -1
- package/dist/composed/schedule-view.js +2 -2
- package/dist/composed/schedule-view.js.map +1 -1
- package/dist/composed/status-badge.d.ts.map +1 -1
- package/dist/composed/status-badge.js +29 -28
- package/dist/composed/status-badge.js.map +1 -1
- package/dist/motion/index.d.ts +1 -0
- package/dist/motion/index.d.ts.map +1 -1
- package/dist/motion/index.js +2 -15
- package/dist/motion/motion-preference.d.ts +36 -0
- package/dist/motion/motion-preference.d.ts.map +1 -0
- package/dist/motion/motion-provider.d.ts +2 -1
- package/dist/motion/motion-provider.d.ts.map +1 -1
- package/dist/motion/primitives-index.js +103 -102
- package/dist/motion/primitives-index.js.map +1 -1
- package/dist/motion/primitives.d.ts.map +1 -1
- package/dist/shell/bottom-navbar.js +19 -19
- package/dist/shell/bottom-navbar.js.map +1 -1
- package/dist/shell/index.d.ts +1 -1
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/notification-center.d.ts +17 -0
- package/dist/shell/notification-center.d.ts.map +1 -1
- package/dist/shell/notification-center.js +109 -104
- package/dist/shell/notification-center.js.map +1 -1
- package/dist/shell/notification-preferences.js +1 -1
- package/dist/shell/notification-preferences.js.map +1 -1
- package/dist/shell/top-bar.js +1 -1
- package/dist/shell/top-bar.js.map +1 -1
- package/dist/tokens/index.css +1 -0
- package/dist/tokens/palettes.css +292 -0
- package/dist/tokens/semantic.css +157 -11
- package/dist/tokens/shilp-sutra.css +1 -0
- package/dist/tokens/utilities.css +10 -7
- package/dist/ui/accordion.d.ts.map +1 -1
- package/dist/ui/accordion.js +27 -26
- package/dist/ui/accordion.js.map +1 -1
- package/dist/ui/alert-dialog.d.ts.map +1 -1
- package/dist/ui/alert-dialog.js +60 -59
- package/dist/ui/alert-dialog.js.map +1 -1
- package/dist/ui/alert.d.ts.map +1 -1
- package/dist/ui/alert.js +55 -113
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/autocomplete.js +80 -80
- package/dist/ui/autocomplete.js.map +1 -1
- package/dist/ui/avatar.d.ts.map +1 -1
- package/dist/ui/avatar.js +71 -70
- package/dist/ui/avatar.js.map +1 -1
- package/dist/ui/badge-indicator.d.ts +4 -8
- package/dist/ui/badge-indicator.d.ts.map +1 -1
- package/dist/ui/badge-indicator.js +3 -8
- package/dist/ui/badge-indicator.js.map +1 -1
- package/dist/ui/badge.d.ts +8 -1
- package/dist/ui/badge.d.ts.map +1 -1
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +42 -40
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/bulk-action-bar.d.ts +59 -0
- package/dist/ui/bulk-action-bar.d.ts.map +1 -0
- package/dist/ui/bulk-action-bar.js +145 -0
- package/dist/ui/bulk-action-bar.js.map +1 -0
- package/dist/ui/button-group.d.ts.map +1 -1
- package/dist/ui/button-group.js +3 -23
- package/dist/ui/button-group.js.map +1 -1
- package/dist/ui/button.d.ts +10 -1
- package/dist/ui/button.d.ts.map +1 -1
- package/dist/ui/button.js +79 -212
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/card.d.ts.map +1 -1
- package/dist/ui/card.js +75 -72
- package/dist/ui/card.js.map +1 -1
- package/dist/ui/charts/radar-chart.d.ts.map +1 -1
- package/dist/ui/charts/radar-chart.js +1 -1
- package/dist/ui/charts/radar-chart.js.map +1 -1
- package/dist/ui/chat/message-list.d.ts.map +1 -1
- package/dist/ui/chat/message.d.ts.map +1 -1
- package/dist/ui/chat/typing-indicator.d.ts.map +1 -1
- package/dist/ui/checkbox.d.ts.map +1 -1
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/code.js +1 -1
- package/dist/ui/code.js.map +1 -1
- package/dist/ui/color-input.d.ts.map +1 -1
- package/dist/ui/color-input.js +151 -150
- package/dist/ui/color-input.js.map +1 -1
- package/dist/ui/combobox.d.ts +14 -0
- package/dist/ui/combobox.d.ts.map +1 -1
- package/dist/ui/combobox.js +162 -158
- package/dist/ui/combobox.js.map +1 -1
- package/dist/ui/context-menu.d.ts.map +1 -1
- package/dist/ui/context-menu.js +70 -69
- package/dist/ui/context-menu.js.map +1 -1
- package/dist/ui/data-table-body.d.ts.map +1 -1
- package/dist/ui/data-table-body.js +4 -3
- package/dist/ui/data-table-body.js.map +1 -1
- package/dist/ui/data-table-bulk-actions.d.ts +26 -1
- package/dist/ui/data-table-bulk-actions.d.ts.map +1 -1
- package/dist/ui/data-table-bulk-actions.js +21 -46
- package/dist/ui/data-table-bulk-actions.js.map +1 -1
- package/dist/ui/data-table-context.d.ts +36 -2
- package/dist/ui/data-table-context.d.ts.map +1 -1
- package/dist/ui/data-table-context.js +25 -21
- package/dist/ui/data-table-context.js.map +1 -1
- package/dist/ui/data-table-header.d.ts.map +1 -1
- package/dist/ui/data-table-header.js +42 -40
- package/dist/ui/data-table-header.js.map +1 -1
- package/dist/ui/data-table-pagination.js +2 -2
- package/dist/ui/data-table-pagination.js.map +1 -1
- package/dist/ui/dialog.d.ts.map +1 -1
- package/dist/ui/dialog.js +61 -60
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/dot.d.ts.map +1 -1
- package/dist/ui/dot.js +10 -41
- package/dist/ui/dot.js.map +1 -1
- package/dist/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/ui/dropdown-menu.js +79 -78
- package/dist/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/file-upload.d.ts.map +1 -1
- package/dist/ui/file-upload.js +116 -115
- package/dist/ui/file-upload.js.map +1 -1
- package/dist/ui/form.d.ts.map +1 -1
- package/dist/ui/form.js +27 -26
- package/dist/ui/form.js.map +1 -1
- package/dist/ui/hover-card.d.ts.map +1 -1
- package/dist/ui/hover-card.js +26 -25
- package/dist/ui/hover-card.js.map +1 -1
- package/dist/ui/icon.js +7 -7
- package/dist/ui/index.d.ts +3 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +60 -59
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/input.d.ts.map +1 -1
- package/dist/ui/input.js +7 -7
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/menubar.d.ts.map +1 -1
- package/dist/ui/menubar.js +73 -72
- package/dist/ui/menubar.js.map +1 -1
- package/dist/ui/navigation-menu.d.ts.map +1 -1
- package/dist/ui/navigation-menu.js +80 -79
- package/dist/ui/navigation-menu.js.map +1 -1
- package/dist/ui/popover.d.ts.map +1 -1
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +72 -68
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/radio.d.ts.map +1 -1
- package/dist/ui/radio.js +35 -34
- package/dist/ui/radio.js.map +1 -1
- package/dist/ui/search-input.d.ts.map +1 -1
- package/dist/ui/search-input.js +28 -27
- package/dist/ui/search-input.js.map +1 -1
- package/dist/ui/select.d.ts.map +1 -1
- package/dist/ui/select.js +70 -69
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/sidebar.d.ts.map +1 -1
- package/dist/ui/sidebar.js +4 -4
- package/dist/ui/sidebar.js.map +1 -1
- package/dist/ui/slider.d.ts +63 -9
- package/dist/ui/slider.d.ts.map +1 -1
- package/dist/ui/slider.js +74 -32
- package/dist/ui/slider.js.map +1 -1
- package/dist/ui/split-button.d.ts +8 -2
- package/dist/ui/split-button.d.ts.map +1 -1
- package/dist/ui/split-button.js +49 -95
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/stat-card.d.ts.map +1 -1
- package/dist/ui/stat-card.js +89 -88
- package/dist/ui/stat-card.js.map +1 -1
- package/dist/ui/stat-flash.js +16 -16
- package/dist/ui/stepper.d.ts.map +1 -1
- package/dist/ui/stepper.js +63 -62
- package/dist/ui/stepper.js.map +1 -1
- package/dist/ui/switch.d.ts.map +1 -1
- package/dist/ui/switch.js +2 -2
- package/dist/ui/switch.js.map +1 -1
- package/dist/ui/table.d.ts.map +1 -1
- package/dist/ui/table.js +3 -3
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/tabs.d.ts.map +1 -1
- package/dist/ui/tabs.js +67 -66
- package/dist/ui/tabs.js.map +1 -1
- package/dist/ui/textarea.d.ts.map +1 -1
- package/dist/ui/textarea.js +7 -7
- package/dist/ui/textarea.js.map +1 -1
- package/dist/ui/toast.d.ts.map +1 -1
- package/dist/ui/toast.js +196 -195
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/toggle.d.ts.map +1 -1
- package/dist/ui/toggle.js +24 -22
- package/dist/ui/toggle.js.map +1 -1
- package/dist/ui/tooltip.d.ts.map +1 -1
- package/dist/ui/tooltip.js +37 -36
- package/dist/ui/tooltip.js.map +1 -1
- package/dist/ui/tree-view/tree-item.d.ts.map +1 -1
- package/docs/components/composed/bulk-action-bar.md +14 -7
- package/docs/components/ui/bulk-action-bar.md +72 -0
- package/docs/recipes/customize-brand.md +58 -0
- package/docs/recipes/install-astro.md +1 -1
- package/docs/recipes/install-next-app-router.md +1 -1
- package/docs/recipes/install-next-pages.md +22 -1
- package/docs/recipes/install-remix.md +1 -1
- package/docs/recipes/install-tanstack-start.md +1 -1
- package/docs/recipes/install-vite.md +2 -1
- package/docs/recipes/server-components.md +7 -4
- package/docs/recipes/troubleshoot.md +1 -0
- package/llms.txt +2 -2
- package/make-kit/foundations/color.md +3 -1
- package/mcp-manifest.json +184 -151
- package/package.json +8 -2
- package/skill/SKILL.md +1 -1
- package/skill/references/components.md +2 -2
- package/skill/references/customize-brand.md +58 -0
- package/skill/references/server-components.md +7 -4
- package/skill/references/setup-astro.md +1 -1
- package/skill/references/setup-next-app-router.md +1 -1
- package/skill/references/setup-next-pages.md +22 -1
- package/skill/references/setup-remix.md +1 -1
- package/skill/references/setup-tanstack-start.md +1 -1
- package/skill/references/setup-vite.md +2 -1
- package/skill/references/troubleshoot.md +1 -0
- package/dist/composed/bulk-action-bar.js.map +0 -1
- package/dist/motion/check-motion-provider.d.ts +0 -2
- package/dist/motion/check-motion-provider.d.ts.map +0 -1
- package/dist/motion/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../src/ui/context-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,oBAAoB,MAAM,gCAAgC,CAAA;AAGtE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../src/ui/context-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,oBAAoB,MAAM,gCAAgC,CAAA;AAGtE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,oBAA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ED
|
@@ -1,57 +1,58 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { springs as e, tweens as t } from "./lib/motion.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { MotionPreference as n } from "../_chunks/motion-preference.js";
|
|
4
|
+
import { cn as r } from "./lib/utils.js";
|
|
5
|
+
import { Icon as i } from "./icon.js";
|
|
6
|
+
import { CheckboxItem2 as a, Content2 as o, Group2 as s, Item2 as c, ItemIndicator2 as l, Label2 as u, Portal2 as d, RadioGroup2 as f, RadioItem2 as p, Root2 as m, Separator2 as h, Sub2 as g, SubContent2 as _, SubTrigger2 as v, Trigger as y } from "../_chunks/primitives/react-context-menu.js";
|
|
7
|
+
import * as b from "react";
|
|
8
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
9
|
+
import { IconCheck as C, IconChevronRight as w, IconCircle as T } from "@tabler/icons-react";
|
|
10
|
+
import { AnimatePresence as E, motion as D } from "framer-motion";
|
|
10
11
|
//#region src/ui/context-menu.tsx
|
|
11
|
-
var
|
|
12
|
-
let [n, r] =
|
|
12
|
+
var O = b.createContext(!1), k = b.createContext(!1), A = ({ onOpenChange: e, ...t }) => {
|
|
13
|
+
let [n, r] = b.useState(!1), i = b.useCallback((t) => {
|
|
13
14
|
r(t), e?.(t);
|
|
14
15
|
}, [e]);
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ x(O.Provider, {
|
|
16
17
|
value: n,
|
|
17
|
-
children: /* @__PURE__ */
|
|
18
|
+
children: /* @__PURE__ */ x(m, {
|
|
18
19
|
onOpenChange: i,
|
|
19
20
|
...t
|
|
20
21
|
})
|
|
21
22
|
});
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
let [i, a] =
|
|
24
|
+
A.displayName = "ContextMenu";
|
|
25
|
+
var j = y, M = s, N = d, P = ({ open: e, defaultOpen: t = !1, onOpenChange: n, ...r }) => {
|
|
26
|
+
let [i, a] = b.useState(t), o = e !== void 0, s = o ? e : i, c = b.useCallback((e) => {
|
|
26
27
|
o || a(e), n?.(e);
|
|
27
28
|
}, [o, n]);
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ x(k.Provider, {
|
|
29
30
|
value: s,
|
|
30
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ x(g, {
|
|
31
32
|
open: s,
|
|
32
33
|
onOpenChange: c,
|
|
33
34
|
...r
|
|
34
35
|
})
|
|
35
36
|
});
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
var
|
|
38
|
+
P.displayName = "ContextMenuSub";
|
|
39
|
+
var F = f, I = b.forwardRef(({ className: e, inset: t, children: n, ...a }, o) => /* @__PURE__ */ S(v, {
|
|
39
40
|
ref: o,
|
|
40
|
-
className:
|
|
41
|
+
className: r("flex cursor-default select-none items-center rounded-control px-ds-03 py-ds-02b text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[state=open]:bg-surface-panel-hover data-[state=open]:text-surface-fg", t && "pl-ds-07", e),
|
|
41
42
|
...a,
|
|
42
|
-
children: [
|
|
43
|
-
icon:
|
|
43
|
+
children: [n, /* @__PURE__ */ x(i, {
|
|
44
|
+
icon: w,
|
|
44
45
|
size: "sm",
|
|
45
46
|
className: "ml-auto"
|
|
46
47
|
})]
|
|
47
48
|
}));
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
ref:
|
|
49
|
+
I.displayName = v.displayName;
|
|
50
|
+
var L = b.forwardRef(({ className: i, children: a, ...o }, s) => /* @__PURE__ */ x(n, { children: /* @__PURE__ */ x(E, { children: b.useContext(k) && /* @__PURE__ */ x(_, {
|
|
51
|
+
ref: s,
|
|
51
52
|
forceMount: !0,
|
|
52
53
|
asChild: !0,
|
|
53
|
-
...
|
|
54
|
-
children: /* @__PURE__ */
|
|
54
|
+
...o,
|
|
55
|
+
children: /* @__PURE__ */ x(D.div, {
|
|
55
56
|
initial: {
|
|
56
57
|
opacity: 0,
|
|
57
58
|
scale: .95
|
|
@@ -68,19 +69,19 @@ var I = y.forwardRef(({ className: r, children: i, ...a }, o) => /* @__PURE__ */
|
|
|
68
69
|
...e.snappy,
|
|
69
70
|
opacity: t.fade
|
|
70
71
|
},
|
|
71
|
-
className:
|
|
72
|
-
children:
|
|
72
|
+
className: r("z-popover min-w-[8rem] overflow-hidden rounded-overlay bg-surface-overlay p-ds-02 text-surface-fg shadow-floating", i),
|
|
73
|
+
children: a
|
|
73
74
|
})
|
|
74
|
-
}) }));
|
|
75
|
-
|
|
76
|
-
var
|
|
75
|
+
}) }) }));
|
|
76
|
+
L.displayName = _.displayName;
|
|
77
|
+
var R = b.forwardRef(({ className: i, children: a, ...s }, c) => /* @__PURE__ */ x(n, { children: /* @__PURE__ */ x(E, { children: b.useContext(O) && /* @__PURE__ */ x(d, {
|
|
77
78
|
forceMount: !0,
|
|
78
|
-
children: /* @__PURE__ */
|
|
79
|
-
ref:
|
|
79
|
+
children: /* @__PURE__ */ x(o, {
|
|
80
|
+
ref: c,
|
|
80
81
|
forceMount: !0,
|
|
81
82
|
asChild: !0,
|
|
82
|
-
...
|
|
83
|
-
children: /* @__PURE__ */
|
|
83
|
+
...s,
|
|
84
|
+
children: /* @__PURE__ */ x(D.div, {
|
|
84
85
|
initial: {
|
|
85
86
|
opacity: 0,
|
|
86
87
|
scale: .95
|
|
@@ -97,62 +98,62 @@ var L = y.forwardRef(({ className: r, children: i, ...o }, s) => /* @__PURE__ */
|
|
|
97
98
|
...e.snappy,
|
|
98
99
|
opacity: t.fade
|
|
99
100
|
},
|
|
100
|
-
className:
|
|
101
|
-
children:
|
|
101
|
+
className: r("z-popover rounded-overlay bg-surface-overlay p-ds-02 text-surface-fg shadow-floating", i),
|
|
102
|
+
children: a
|
|
102
103
|
})
|
|
103
104
|
})
|
|
104
|
-
}) }));
|
|
105
|
-
|
|
106
|
-
var
|
|
105
|
+
}) }) }));
|
|
106
|
+
R.displayName = o.displayName;
|
|
107
|
+
var z = b.forwardRef(({ className: e, inset: t, ...n }, i) => /* @__PURE__ */ x(c, {
|
|
107
108
|
ref: i,
|
|
108
|
-
className:
|
|
109
|
-
...
|
|
109
|
+
className: r("relative flex cursor-default select-none items-center rounded-control px-ds-03 py-ds-02b text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled", t && "pl-ds-07", e),
|
|
110
|
+
...n
|
|
110
111
|
}));
|
|
111
|
-
|
|
112
|
-
var
|
|
112
|
+
z.displayName = c.displayName;
|
|
113
|
+
var B = b.forwardRef(({ className: e, children: t, checked: n, ...o }, s) => /* @__PURE__ */ S(a, {
|
|
113
114
|
ref: s,
|
|
114
|
-
className:
|
|
115
|
-
checked:
|
|
115
|
+
className: r("relative flex cursor-default select-none items-center rounded-control py-ds-02b pl-ds-07 pr-ds-03 text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled", e),
|
|
116
|
+
checked: n,
|
|
116
117
|
...o,
|
|
117
|
-
children: [/* @__PURE__ */
|
|
118
|
+
children: [/* @__PURE__ */ x("span", {
|
|
118
119
|
className: "absolute left-ds-03 flex h-ico-sm w-ico-sm items-center justify-center",
|
|
119
|
-
children: /* @__PURE__ */
|
|
120
|
-
icon:
|
|
120
|
+
children: /* @__PURE__ */ x(l, { children: /* @__PURE__ */ x(i, {
|
|
121
|
+
icon: C,
|
|
121
122
|
size: "sm"
|
|
122
123
|
}) })
|
|
123
124
|
}), t]
|
|
124
125
|
}));
|
|
125
|
-
|
|
126
|
-
var
|
|
126
|
+
B.displayName = a.displayName;
|
|
127
|
+
var V = b.forwardRef(({ className: e, children: t, ...n }, a) => /* @__PURE__ */ S(p, {
|
|
127
128
|
ref: a,
|
|
128
|
-
className:
|
|
129
|
-
...
|
|
130
|
-
children: [/* @__PURE__ */
|
|
129
|
+
className: r("relative flex cursor-default select-none items-center rounded-control py-ds-02b pl-ds-07 pr-ds-03 text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled", e),
|
|
130
|
+
...n,
|
|
131
|
+
children: [/* @__PURE__ */ x("span", {
|
|
131
132
|
className: "absolute left-ds-03 flex h-ico-sm w-ico-sm items-center justify-center",
|
|
132
|
-
children: /* @__PURE__ */
|
|
133
|
-
icon:
|
|
133
|
+
children: /* @__PURE__ */ x(l, { children: /* @__PURE__ */ x(i, {
|
|
134
|
+
icon: T,
|
|
134
135
|
size: "sm",
|
|
135
136
|
className: "fill-current"
|
|
136
137
|
}) })
|
|
137
138
|
}), t]
|
|
138
139
|
}));
|
|
139
|
-
|
|
140
|
-
var
|
|
140
|
+
V.displayName = p.displayName;
|
|
141
|
+
var H = b.forwardRef(({ className: e, inset: t, ...n }, i) => /* @__PURE__ */ x(u, {
|
|
141
142
|
ref: i,
|
|
142
|
-
className:
|
|
143
|
-
...
|
|
143
|
+
className: r("px-ds-03 py-ds-02b text-body-md font-semibold text-surface-fg", t && "pl-ds-07", e),
|
|
144
|
+
...n
|
|
144
145
|
}));
|
|
145
|
-
|
|
146
|
-
var
|
|
147
|
-
ref:
|
|
148
|
-
className:
|
|
146
|
+
H.displayName = u.displayName;
|
|
147
|
+
var U = b.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ x(h, {
|
|
148
|
+
ref: n,
|
|
149
|
+
className: r("-mx-ds-01 my-ds-02 h-px bg-surface-border", e),
|
|
149
150
|
...t
|
|
150
151
|
}));
|
|
151
|
-
|
|
152
|
-
var
|
|
153
|
-
className:
|
|
152
|
+
U.displayName = h.displayName;
|
|
153
|
+
var W = ({ className: e, ...t }) => /* @__PURE__ */ x("span", {
|
|
154
|
+
className: r("ml-auto text-body-sm text-surface-fg-subtle", e),
|
|
154
155
|
...t
|
|
155
156
|
});
|
|
156
|
-
|
|
157
|
+
W.displayName = "ContextMenuShortcut";
|
|
157
158
|
//#endregion
|
|
158
|
-
export {
|
|
159
|
+
export { A as ContextMenu, B as ContextMenuCheckboxItem, R as ContextMenuContent, M as ContextMenuGroup, z as ContextMenuItem, H as ContextMenuLabel, N as ContextMenuPortal, F as ContextMenuRadioGroup, V as ContextMenuRadioItem, U as ContextMenuSeparator, W as ContextMenuShortcut, P as ContextMenuSub, L as ContextMenuSubContent, I as ContextMenuSubTrigger, j as ContextMenuTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.js","names":[],"sources":["../../src/ui/context-menu.tsx"],"sourcesContent":["'use client'\n\nimport * as ContextMenuPrimitive from \"@primitives/react-context-menu\"\nimport { IconCheck, IconChevronRight, IconCircle } from '@tabler/icons-react'\nimport { AnimatePresence,motion } from 'framer-motion'\nimport * as React from \"react\"\n\nimport { Icon } from './icon'\nimport { springs, tweens } from './lib/motion'\nimport { cn } from \"./lib/utils\"\n\n// ── Internal contexts to thread open state ──\n\nconst ContextMenuOpenContext = React.createContext(false)\nconst ContextMenuSubOpenContext = React.createContext(false)\n\nconst ContextMenu: React.FC<React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Root>> = ({\n onOpenChange,\n ...props\n}) => {\n const [open, setOpen] = React.useState(false)\n\n const handleOpenChange = React.useCallback(\n (value: boolean) => {\n setOpen(value)\n onOpenChange?.(value)\n },\n [onOpenChange],\n )\n\n return (\n <ContextMenuOpenContext.Provider value={open}>\n <ContextMenuPrimitive.Root onOpenChange={handleOpenChange} {...props} />\n </ContextMenuOpenContext.Provider>\n )\n}\nContextMenu.displayName = 'ContextMenu'\n\nconst ContextMenuTrigger = ContextMenuPrimitive.Trigger\n\nconst ContextMenuGroup = ContextMenuPrimitive.Group\n\nconst ContextMenuPortal = ContextMenuPrimitive.Portal\n\nconst ContextMenuSub: React.FC<React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Sub>> = ({\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n ...props\n}) => {\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n const isControlled = controlledOpen !== undefined\n const open = isControlled ? controlledOpen : uncontrolledOpen\n\n const handleOpenChange = React.useCallback(\n (value: boolean) => {\n if (!isControlled) setUncontrolledOpen(value)\n onOpenChange?.(value)\n },\n [isControlled, onOpenChange],\n )\n\n return (\n <ContextMenuSubOpenContext.Provider value={open}>\n <ContextMenuPrimitive.Sub open={open} onOpenChange={handleOpenChange} {...props} />\n </ContextMenuSubOpenContext.Provider>\n )\n}\nContextMenuSub.displayName = 'ContextMenuSub'\n\nconst ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup\n\nconst ContextMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {\n inset?: boolean\n }\n>(({ className, inset, children, ...props }, ref) => (\n <ContextMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n \"flex cursor-default select-none items-center rounded-control px-ds-03 py-ds-02b text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[state=open]:bg-surface-panel-hover data-[state=open]:text-surface-fg\",\n inset && \"pl-ds-07\",\n className\n )}\n {...props}\n >\n {children}\n <Icon icon={IconChevronRight} size=\"sm\" className=\"ml-auto\" />\n </ContextMenuPrimitive.SubTrigger>\n))\nContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName\n\nconst ContextMenuSubContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>\n>(({ className, children, ...props }, ref) => {\n const open = React.useContext(ContextMenuSubOpenContext)\n\n return (\n <AnimatePresence>\n {open && (\n <ContextMenuPrimitive.SubContent\n ref={ref}\n forceMount\n asChild\n {...props}\n >\n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.95 }}\n transition={{ ...springs.snappy, opacity: tweens.fade }}\n className={cn(\n \"z-popover min-w-[8rem] overflow-hidden rounded-overlay bg-surface-overlay p-ds-02 text-surface-fg shadow-floating\",\n className\n )}\n >\n {children}\n </motion.div>\n </ContextMenuPrimitive.SubContent>\n )}\n </AnimatePresence>\n )\n})\nContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName\n\nconst ContextMenuContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(({ className, children, ...props }, ref) => {\n const open = React.useContext(ContextMenuOpenContext)\n\n return (\n <AnimatePresence>\n {open && (\n <ContextMenuPrimitive.Portal forceMount>\n <ContextMenuPrimitive.Content\n ref={ref}\n forceMount\n asChild\n {...props}\n >\n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.95 }}\n transition={{ ...springs.snappy, opacity: tweens.fade }}\n className={cn(\n \"z-popover rounded-overlay bg-surface-overlay p-ds-02 text-surface-fg shadow-floating\",\n className\n )}\n >\n {children}\n </motion.div>\n </ContextMenuPrimitive.Content>\n </ContextMenuPrimitive.Portal>\n )}\n </AnimatePresence>\n )\n})\nContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName\n\nconst ContextMenuItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean\n }\n>(({ className, inset, ...props }, ref) => (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-control px-ds-03 py-ds-02b text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled\",\n inset && \"pl-ds-07\",\n className\n )}\n {...props}\n />\n))\nContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName\n\nconst ContextMenuCheckboxItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>\n>(({ className, children, checked, ...props }, ref) => (\n <ContextMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-control py-ds-02b pl-ds-07 pr-ds-03 text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled\",\n className\n )}\n checked={checked}\n {...props}\n >\n <span className=\"absolute left-ds-03 flex h-ico-sm w-ico-sm items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Icon icon={IconCheck} size=\"sm\" />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n))\nContextMenuCheckboxItem.displayName =\n ContextMenuPrimitive.CheckboxItem.displayName\n\nconst ContextMenuRadioItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>\n>(({ className, children, ...props }, ref) => (\n <ContextMenuPrimitive.RadioItem\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-control py-ds-02b pl-ds-07 pr-ds-03 text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled\",\n className\n )}\n {...props}\n >\n <span className=\"absolute left-ds-03 flex h-ico-sm w-ico-sm items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Icon icon={IconCircle} size=\"sm\" className=\"fill-current\" />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n))\nContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName\n\nconst ContextMenuLabel = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {\n inset?: boolean\n }\n>(({ className, inset, ...props }, ref) => (\n <ContextMenuPrimitive.Label\n ref={ref}\n className={cn(\n \"px-ds-03 py-ds-02b text-body-md font-semibold text-surface-fg\",\n inset && \"pl-ds-07\",\n className\n )}\n {...props}\n />\n))\nContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName\n\nconst ContextMenuSeparator = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-ds-01 my-ds-02 h-px bg-surface-border\", className)}\n {...props}\n />\n))\nContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName\n\nconst ContextMenuShortcut = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\n \"ml-auto text-body-sm text-surface-fg-subtle\",\n className\n )}\n {...props}\n />\n )\n}\nContextMenuShortcut.displayName = \"ContextMenuShortcut\"\n\nexport type ContextMenuContentProps = React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\nexport type ContextMenuItemProps = React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item>\n\nexport {\n ContextMenu,\n ContextMenuCheckboxItem,\n ContextMenuContent,\n ContextMenuGroup,\n ContextMenuItem,\n ContextMenuLabel,\n ContextMenuPortal,\n ContextMenuRadioGroup,\n ContextMenuRadioItem,\n ContextMenuSeparator,\n ContextMenuShortcut,\n ContextMenuSub,\n ContextMenuSubContent,\n ContextMenuSubTrigger,\n ContextMenuTrigger,\n}\n"],"mappings":";;;;;;;;;;AAaA,IAAM,IAAyB,EAAM,cAAc,EAAK,GAClD,IAA4B,EAAM,cAAc,EAAK,GAErD,KAA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;GAAM,MAAM;GAAW,MAAK;EAAM,CAAA,EACA,CAAA;CAChC,CAAA,GACL,CACgC;EACpC;AACD,EAAwB,cAAA,EACY;AAEpC,IAAM,IAAuB,EAAM,YAGhC,EAAE,cAAW,aAAU,GAAG,KAAS,MACpC,kBAAC,GAAD;CACO;CACL,WAAW,EACT,gQACA,CACF;CACA,GAAI;WANN,CAQE,kBAAC,QAAD;EAAM,WAAU;YACd,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GAAM,MAAM;GAAY,MAAK;GAAK,WAAU;EAAgB,CAAA,EAC1B,CAAA;CAChC,CAAA,GACL,CAC6B;EACjC;AACD,EAAqB,cAAA,EAA6C;AAElE,IAAM,IAAmB,EAAM,YAK5B,EAAE,cAAW,UAAO,GAAG,KAAS,MACjC,kBAAC,GAAD;CACO;CACL,WAAW,EACT,iEACA,KAAS,YACT,CACF;CACA,GAAI;AACL,CAAA,CACF;AACD,EAAiB,cAAA,EAAyC;AAE1D,IAAM,IAAuB,EAAM,YAGhC,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,GAAD;CACO;CACL,WAAW,EAAG,6CAA6C,CAAS;CACpE,GAAI;AACL,CAAA,CACF;AACD,EAAqB,cAAA,EAA6C;AAElE,IAAM,KAAuB,EAC3B,cACA,GAAG,QAGD,kBAAC,QAAD;CACE,WAAW,EACT,+CACA,CACF;CACA,GAAI;AACL,CAAA;AAGL,EAAoB,cAAc"}
|
|
1
|
+
{"version":3,"file":"context-menu.js","names":[],"sources":["../../src/ui/context-menu.tsx"],"sourcesContent":["'use client'\n\nimport * as ContextMenuPrimitive from \"@primitives/react-context-menu\"\nimport { IconCheck, IconChevronRight, IconCircle } from '@tabler/icons-react'\nimport { AnimatePresence,motion } from 'framer-motion'\nimport * as React from \"react\"\n\nimport { MotionPreference } from '../motion/motion-preference'\nimport { Icon } from './icon'\nimport { springs, tweens } from './lib/motion'\nimport { cn } from \"./lib/utils\"\n\n// ── Internal contexts to thread open state ──\n\nconst ContextMenuOpenContext = React.createContext(false)\nconst ContextMenuSubOpenContext = React.createContext(false)\n\nconst ContextMenu: React.FC<React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Root>> = ({\n onOpenChange,\n ...props\n}) => {\n const [open, setOpen] = React.useState(false)\n\n const handleOpenChange = React.useCallback(\n (value: boolean) => {\n setOpen(value)\n onOpenChange?.(value)\n },\n [onOpenChange],\n )\n\n return (\n <ContextMenuOpenContext.Provider value={open}>\n <ContextMenuPrimitive.Root onOpenChange={handleOpenChange} {...props} />\n </ContextMenuOpenContext.Provider>\n )\n}\nContextMenu.displayName = 'ContextMenu'\n\nconst ContextMenuTrigger = ContextMenuPrimitive.Trigger\n\nconst ContextMenuGroup = ContextMenuPrimitive.Group\n\nconst ContextMenuPortal = ContextMenuPrimitive.Portal\n\nconst ContextMenuSub: React.FC<React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Sub>> = ({\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n ...props\n}) => {\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n const isControlled = controlledOpen !== undefined\n const open = isControlled ? controlledOpen : uncontrolledOpen\n\n const handleOpenChange = React.useCallback(\n (value: boolean) => {\n if (!isControlled) setUncontrolledOpen(value)\n onOpenChange?.(value)\n },\n [isControlled, onOpenChange],\n )\n\n return (\n <ContextMenuSubOpenContext.Provider value={open}>\n <ContextMenuPrimitive.Sub open={open} onOpenChange={handleOpenChange} {...props} />\n </ContextMenuSubOpenContext.Provider>\n )\n}\nContextMenuSub.displayName = 'ContextMenuSub'\n\nconst ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup\n\nconst ContextMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {\n inset?: boolean\n }\n>(({ className, inset, children, ...props }, ref) => (\n <ContextMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n \"flex cursor-default select-none items-center rounded-control px-ds-03 py-ds-02b text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[state=open]:bg-surface-panel-hover data-[state=open]:text-surface-fg\",\n inset && \"pl-ds-07\",\n className\n )}\n {...props}\n >\n {children}\n <Icon icon={IconChevronRight} size=\"sm\" className=\"ml-auto\" />\n </ContextMenuPrimitive.SubTrigger>\n))\nContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName\n\nconst ContextMenuSubContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>\n>(({ className, children, ...props }, ref) => {\n const open = React.useContext(ContextMenuSubOpenContext)\n\n return (\n <MotionPreference>\n <AnimatePresence>\n {open && (\n <ContextMenuPrimitive.SubContent\n ref={ref}\n forceMount\n asChild\n {...props}\n >\n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.95 }}\n transition={{ ...springs.snappy, opacity: tweens.fade }}\n className={cn(\n \"z-popover min-w-[8rem] overflow-hidden rounded-overlay bg-surface-overlay p-ds-02 text-surface-fg shadow-floating\",\n className\n )}\n >\n {children}\n </motion.div>\n </ContextMenuPrimitive.SubContent>\n )}\n </AnimatePresence>\n </MotionPreference>\n )\n})\nContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName\n\nconst ContextMenuContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(({ className, children, ...props }, ref) => {\n const open = React.useContext(ContextMenuOpenContext)\n\n return (\n <MotionPreference>\n <AnimatePresence>\n {open && (\n <ContextMenuPrimitive.Portal forceMount>\n <ContextMenuPrimitive.Content\n ref={ref}\n forceMount\n asChild\n {...props}\n >\n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.95 }}\n transition={{ ...springs.snappy, opacity: tweens.fade }}\n className={cn(\n \"z-popover rounded-overlay bg-surface-overlay p-ds-02 text-surface-fg shadow-floating\",\n className\n )}\n >\n {children}\n </motion.div>\n </ContextMenuPrimitive.Content>\n </ContextMenuPrimitive.Portal>\n )}\n </AnimatePresence>\n </MotionPreference>\n )\n})\nContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName\n\nconst ContextMenuItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean\n }\n>(({ className, inset, ...props }, ref) => (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-control px-ds-03 py-ds-02b text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled\",\n inset && \"pl-ds-07\",\n className\n )}\n {...props}\n />\n))\nContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName\n\nconst ContextMenuCheckboxItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>\n>(({ className, children, checked, ...props }, ref) => (\n <ContextMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-control py-ds-02b pl-ds-07 pr-ds-03 text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled\",\n className\n )}\n checked={checked}\n {...props}\n >\n <span className=\"absolute left-ds-03 flex h-ico-sm w-ico-sm items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Icon icon={IconCheck} size=\"sm\" />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n))\nContextMenuCheckboxItem.displayName =\n ContextMenuPrimitive.CheckboxItem.displayName\n\nconst ContextMenuRadioItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>\n>(({ className, children, ...props }, ref) => (\n <ContextMenuPrimitive.RadioItem\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-control py-ds-02b pl-ds-07 pr-ds-03 text-body-md outline-hidden focus:bg-surface-panel-hover focus:text-surface-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-action-disabled\",\n className\n )}\n {...props}\n >\n <span className=\"absolute left-ds-03 flex h-ico-sm w-ico-sm items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Icon icon={IconCircle} size=\"sm\" className=\"fill-current\" />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n))\nContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName\n\nconst ContextMenuLabel = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {\n inset?: boolean\n }\n>(({ className, inset, ...props }, ref) => (\n <ContextMenuPrimitive.Label\n ref={ref}\n className={cn(\n \"px-ds-03 py-ds-02b text-body-md font-semibold text-surface-fg\",\n inset && \"pl-ds-07\",\n className\n )}\n {...props}\n />\n))\nContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName\n\nconst ContextMenuSeparator = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-ds-01 my-ds-02 h-px bg-surface-border\", className)}\n {...props}\n />\n))\nContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName\n\nconst ContextMenuShortcut = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\n \"ml-auto text-body-sm text-surface-fg-subtle\",\n className\n )}\n {...props}\n />\n )\n}\nContextMenuShortcut.displayName = \"ContextMenuShortcut\"\n\nexport type ContextMenuContentProps = React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\nexport type ContextMenuItemProps = React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item>\n\nexport {\n ContextMenu,\n ContextMenuCheckboxItem,\n ContextMenuContent,\n ContextMenuGroup,\n ContextMenuItem,\n ContextMenuLabel,\n ContextMenuPortal,\n ContextMenuRadioGroup,\n ContextMenuRadioItem,\n ContextMenuSeparator,\n ContextMenuShortcut,\n ContextMenuSub,\n ContextMenuSubContent,\n ContextMenuSubTrigger,\n ContextMenuTrigger,\n}\n"],"mappings":";;;;;;;;;;;AAcA,IAAM,IAAyB,EAAM,cAAc,EAAK,GAClD,IAA4B,EAAM,cAAc,EAAK,GAErD,KAA2F,EAC/F,iBACA,GAAG,QACC;CACJ,IAAM,CAAC,GAAM,KAAW,EAAM,SAAS,EAAK,GAEtC,IAAmB,EAAM,aAC5B,MAAmB;EAElB,AADA,EAAQ,CAAK,GACb,IAAe,CAAK;CACtB,GACA,CAAC,CAAY,CACf;CAEA,OACE,kBAAC,EAAuB,UAAxB;EAAiC,OAAO;YACtC,kBAAC,GAAD;GAA2B,cAAc;GAAkB,GAAI;EAAQ,CAAA;CACxC,CAAA;AAErC;AACA,EAAY,cAAc;AAE1B,IAAM,IAAqB,GAErB,IAAmB,GAEnB,IAAoB,GAEpB,KAA6F,EACjG,MAAM,GACN,iBAAc,IACd,iBACA,GAAG,QACC;CACJ,IAAM,CAAC,GAAkB,KAAuB,EAAM,SAAS,CAAW,GACpE,IAAe,MAAmB,KAAA,GAClC,IAAO,IAAe,IAAiB,GAEvC,IAAmB,EAAM,aAC5B,MAAmB;EAElB,AADK,KAAc,EAAoB,CAAK,GAC5C,IAAe,CAAK;CAC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A,GAAI;AACL,CAAA,CACF;AACD,EAAiB,cAAA,EAAyC;AAE1D,IAAM,IAAuB,EAAM,YAGhC,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,GAAD;CACO;CACL,WAAW,EAAG,6CAA6C,CAAS;CACpE,GAAI;AACL,CAAA,CACF;AACD,EAAqB,cAAA,EAA6C;AAElE,IAAM,KAAuB,EAC3B,cACA,GAAG,QAGD,kBAAC,QAAD;CACE,WAAW,EACT,+CACA,CACF;CACA,GAAI;AACL,CAAA;AAGL,EAAoB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-body.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-body.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAmD,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"data-table-body.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-body.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAmD,MAAM,OAAO,CAAA;AAoQvE,wBAAgB,aAAa,CAAC,KAAK,EAAE,EACnC,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,wEAAwE;IACxE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,KAAK,IAAI,CAAA;CAC5D,qBAoFA"}
|
|
@@ -39,10 +39,11 @@ function C({ row: e }) {
|
|
|
39
39
|
className: t(h && "cursor-pointer", _?.(e.original)),
|
|
40
40
|
onClick: h ? v : void 0,
|
|
41
41
|
children: y.map((o) => {
|
|
42
|
-
let l = i(o.column.id, s), d = f?.rowIndex === e.index && f?.columnId === o.column.id;
|
|
42
|
+
let l = i(o.column.id, s, o.column), d = f?.rowIndex === e.index && f?.columnId === o.column.id;
|
|
43
43
|
return /* @__PURE__ */ g(c, {
|
|
44
44
|
className: t(l.className, r(o.column.columnDef.meta)),
|
|
45
45
|
style: l.style,
|
|
46
|
+
"data-pinned": l["data-pinned"],
|
|
46
47
|
onDoubleClick: () => {
|
|
47
48
|
a(o.column.id, u, n) && p({
|
|
48
49
|
rowIndex: e.index,
|
|
@@ -66,13 +67,13 @@ function w({ row: t }) {
|
|
|
66
67
|
let u = t.getIsExpanded();
|
|
67
68
|
return a ? u ? /* @__PURE__ */ g(l, { children: /* @__PURE__ */ g(c, {
|
|
68
69
|
colSpan: n.length,
|
|
69
|
-
className: "bg-surface-
|
|
70
|
+
className: "bg-surface-sunken p-ds-05",
|
|
70
71
|
children: i(t.original)
|
|
71
72
|
}) }) : null : /* @__PURE__ */ g(v, {
|
|
72
73
|
initial: !1,
|
|
73
74
|
children: u && /* @__PURE__ */ g(l, { children: /* @__PURE__ */ g(c, {
|
|
74
75
|
colSpan: n.length,
|
|
75
|
-
className: "bg-surface-
|
|
76
|
+
className: "bg-surface-sunken p-0",
|
|
76
77
|
children: /* @__PURE__ */ g(y.div, {
|
|
77
78
|
className: "overflow-hidden",
|
|
78
79
|
initial: !s && {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-body.js","names":[],"sources":["../../src/ui/data-table-body.tsx"],"sourcesContent":["'use client'\n\nimport { flexRender,type Row } from '@tanstack/react-table'\nimport { type VirtualItem } from '@tanstack/react-virtual'\nimport { AnimatePresence, motion, useReducedMotion } from 'framer-motion'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport {\n getColumnMetaClasses,\n getPinnedCellStyle,\n INTERACTIVE_SELECTOR,\n isColumnEditable,\n useDataTableContext,\n} from './data-table-context'\nimport { springs } from './lib/motion'\nimport { cn } from './lib/utils'\nimport { Skeleton } from './skeleton'\nimport { TableBody, TableCell, TableRow } from './table'\n\n// ── CellEditInput ───────────────────────────────────────────────\n\n/**\n * Inline edit input rendered inside a table cell.\n * Auto-focuses, saves on Enter/blur, cancels on Escape.\n */\nfunction CellEditInput({\n initialValue,\n onSave,\n onCancel,\n}: {\n initialValue: string\n onSave: (value: string) => void\n onCancel: () => void\n}) {\n const [value, setValue] = useState(initialValue)\n const inputRef = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n inputRef.current?.focus()\n inputRef.current?.select()\n }, [])\n\n const handleSave = useCallback(() => {\n onSave(value)\n }, [onSave, value])\n\n return (\n <input\n ref={inputRef}\n type=\"text\"\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onBlur={handleSave}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault()\n handleSave()\n } else if (e.key === 'Escape') {\n e.preventDefault()\n onCancel()\n }\n }}\n className={cn(\n 'h-ds-xs-plus w-full rounded-control',\n 'border border-accent-7 bg-surface-panel-hover',\n 'px-ds-02 text-body-sm',\n 'text-surface-fg placeholder:text-surface-fg-subtle',\n 'outline-hidden focus:border-accent-7',\n )}\n aria-label=\"Edit cell value\"\n />\n )\n}\n\n// ── DataRow ─────────────────────────────────────────────────────\n\n/** Render a single data row (shared between virtual and non-virtual paths) */\nfunction DataTableRow<TData>({ row }: { row: Row<TData> }) {\n const {\n table,\n columnPinningState,\n editable,\n editingCell,\n setEditingCell,\n onCellEdit,\n onRowClick,\n rowClassName,\n } = useDataTableContext<TData>()\n\n const handleRowClick = useCallback(\n (e: React.MouseEvent<HTMLTableRowElement>) => {\n if (!onRowClick) return\n const target = e.target as HTMLElement\n if (target.closest(INTERACTIVE_SELECTOR)) return\n onRowClick(row.original)\n },\n [onRowClick, row.original],\n )\n\n const visibleCells = row.getVisibleCells()\n\n return (\n <TableRow\n data-state={row.getIsSelected() && 'selected'}\n className={cn(\n onRowClick && 'cursor-pointer',\n rowClassName?.(row.original),\n )}\n onClick={onRowClick ? handleRowClick : undefined}\n >\n {visibleCells.map((cell) => {\n const pinned = getPinnedCellStyle(cell.column.id, columnPinningState)\n const isEditing =\n editingCell?.rowIndex === row.index &&\n editingCell?.columnId === cell.column.id\n\n return (\n <TableCell\n key={cell.id}\n className={cn(\n pinned.className,\n getColumnMetaClasses(\n cell.column.columnDef.meta as Record<string, unknown>,\n ),\n )}\n style={pinned.style}\n onDoubleClick={() => {\n if (isColumnEditable(cell.column.id, editable, table)) {\n setEditingCell({\n rowIndex: row.index,\n columnId: cell.column.id,\n })\n }\n }}\n >\n {isEditing ? (\n <CellEditInput\n initialValue={String(cell.getValue() ?? '')}\n onSave={(value) => {\n onCellEdit?.(row.index, cell.column.id, value)\n setEditingCell(null)\n }}\n onCancel={() => setEditingCell(null)}\n />\n ) : (\n flexRender(cell.column.columnDef.cell, cell.getContext())\n )}\n </TableCell>\n )\n })}\n </TableRow>\n )\n}\n\n// ── ExpandedRow ─────────────────────────────────────────────────\n\n/** Render expanded content row below the data row */\nfunction DataTableExpandedRow<TData>({ row }: { row: Row<TData> }) {\n const { allColumns, expandable, renderExpanded, virtualRows } =\n useDataTableContext<TData>()\n // Self-guarded (StatFlash pattern) — reveal collapses to an instant swap\n // without relying on a consumer MotionProvider.\n const prefersReduced = useReducedMotion()\n\n if (!expandable || !renderExpanded) return null\n\n const expanded = row.getIsExpanded()\n\n // In virtual mode the reveal is instant: the row group's height is watched by\n // the virtualizer's ResizeObserver, and an animating height would fire a\n // resize on every frame of the spring.\n if (virtualRows) {\n if (!expanded) return null\n return (\n <TableRow>\n <TableCell colSpan={allColumns.length} className=\"bg-surface-base p-ds-05\">\n {renderExpanded(row.original)}\n </TableCell>\n </TableRow>\n )\n }\n\n return (\n <AnimatePresence initial={false}>\n {expanded && (\n <TableRow>\n <TableCell\n colSpan={allColumns.length}\n // A recess, not a raised layer — surface-panel would vanish on a\n // card. Padding moves to the inner div so the collapsed state has\n // zero height.\n className=\"bg-surface-base p-0\"\n >\n <motion.div\n className=\"overflow-hidden\"\n initial={prefersReduced ? false : { height: 0, opacity: 0 }}\n animate={{ height: 'auto', opacity: 1 }}\n exit={prefersReduced ? undefined : { height: 0, opacity: 0 }}\n transition={\n prefersReduced ? { duration: 0 } : { ...springs.smooth }\n }\n >\n <div className=\"p-ds-05\">{renderExpanded(row.original)}</div>\n </motion.div>\n </TableCell>\n </TableRow>\n )}\n </AnimatePresence>\n )\n}\n\n// ── SkeletonRows ────────────────────────────────────────────────\n\nfunction DataTableSkeletonRows({\n rowCount,\n}: {\n rowCount: number\n}) {\n const { allColumns } = useDataTableContext()\n const visibleColumnCount = allColumns.length\n const skeletonWidths = ['w-3/4', 'w-1/2', 'w-2/3', 'w-full']\n\n return (\n <TableBody>\n {Array.from({ length: rowCount }, (_, rowIdx) => (\n <TableRow key={`skeleton-${rowIdx}`}>\n {Array.from({ length: visibleColumnCount }, (_, colIdx) => {\n const colId = allColumns[colIdx]?.id ?? allColumns[colIdx]?.header\n const isSelect = colId === '_select'\n return (\n <TableCell key={`skeleton-${rowIdx}-${colIdx}`}>\n {isSelect ? (\n <Skeleton\n variant=\"text\"\n className=\"h-4 w-4\"\n animation=\"pulse\"\n />\n ) : (\n <Skeleton\n variant=\"text\"\n className={cn(\n 'h-4',\n skeletonWidths[colIdx % skeletonWidths.length],\n )}\n animation=\"pulse\"\n />\n )}\n </TableCell>\n )\n })}\n </TableRow>\n ))}\n </TableBody>\n )\n}\n\n// ── DataTableBody (orchestrates all body rendering) ─────────────\n\nexport function DataTableBody<TData>({\n loading,\n skeletonRowCount,\n noResultsText,\n emptyState,\n virtualItems,\n totalVirtualSize,\n measureRow,\n}: {\n loading?: boolean\n skeletonRowCount: number\n noResultsText?: string\n emptyState?: React.ReactNode\n virtualItems?: VirtualItem[]\n totalVirtualSize?: number\n /** `virtualizer.measureElement` — attached to each virtual row group */\n measureRow?: (node: HTMLTableSectionElement | null) => void\n}) {\n const { table, allColumns, virtualRows } = useDataTableContext<TData>()\n const rows = table.getRowModel().rows\n\n // Loading state: show skeleton rows\n if (loading) {\n return <DataTableSkeletonRows rowCount={skeletonRowCount} />\n }\n\n if (!rows.length) {\n return (\n <TableBody>\n <TableRow>\n <TableCell\n colSpan={allColumns.length}\n className={cn(\n 'py-ds-07 text-center',\n !emptyState && 'text-surface-fg-subtle',\n )}\n >\n {emptyState || noResultsText || 'No results.'}\n </TableCell>\n </TableRow>\n </TableBody>\n )\n }\n\n if (virtualRows && virtualItems) {\n // Each windowed row gets its OWN <tbody> (valid HTML — a table may hold any\n // number of row groups) carrying `data-index` + the virtualizer's\n // `measureElement` ref. That group is what gets measured, so a row's height\n // INCLUDES its expanded detail row and `getTotalSize()` stays truthful.\n //\n // Rows stay in normal table flow; the window is positioned by spacer row\n // groups above and below instead of absolute offsets. Two consequences worth\n // knowing: an expanded panel can never paint on top of the next row (flow\n // layout forbids it), and column widths keep tracking <thead> because the\n // cells are still real table cells.\n const firstItem = virtualItems[0]\n const lastItem = virtualItems[virtualItems.length - 1]\n const padTop = firstItem ? firstItem.start : 0\n const padBottom = lastItem ? Math.max(0, (totalVirtualSize ?? 0) - lastItem.end) : 0\n const spacerCell = (height: number) => (\n <tbody aria-hidden=\"true\">\n <tr>\n <td colSpan={allColumns.length} style={{ height, padding: 0, border: 0 }} />\n </tr>\n </tbody>\n )\n\n return (\n <>\n {padTop > 0 && spacerCell(padTop)}\n {virtualItems.map((virtualRow) => {\n const row = rows[virtualRow.index]\n const isLastRow = virtualRow.index === rows.length - 1\n return (\n <tbody\n key={row.id}\n ref={measureRow}\n data-index={virtualRow.index}\n className={cn(isLastRow && '[&_tr:last-child]:border-0')}\n >\n <DataTableRow row={row} />\n <DataTableExpandedRow row={row} />\n </tbody>\n )\n })}\n {padBottom > 0 && spacerCell(padBottom)}\n </>\n )\n }\n\n // Standard (non-virtual) rendering\n return (\n <TableBody>\n {rows.map((row) => (\n <React.Fragment key={row.id}>\n <DataTableRow row={row} />\n <DataTableExpandedRow row={row} />\n </React.Fragment>\n ))}\n </TableBody>\n )\n}\n"],"mappings":";;;;;;;;;;;AAyBA,SAAS,EAAc,EACrB,iBACA,WACA,eAKC;CACD,IAAM,CAAC,GAAO,KAAY,EAAS,CAAY,GACzC,IAAW,EAAyB,IAAI;CAE9C,QAAgB;EAEd,AADA,EAAS,SAAS,MAAM,GACxB,EAAS,SAAS,OAAO;CAC3B,GAAG,CAAC,CAAC;CAEL,IAAM,IAAa,QAAkB;EACnC,EAAO,CAAK;CACd,GAAG,CAAC,GAAQ,CAAK,CAAC;CAElB,OACE,kBAAC,SAAD;EACE,KAAK;EACL,MAAK;EACE;EACP,WAAW,MAAM,EAAS,EAAE,OAAO,KAAK;EACxC,QAAQ;EACR,YAAY,MAAM;GAChB,AAAI,EAAE,QAAQ,WACZ,EAAE,eAAe,GACjB,EAAW,KACF,EAAE,QAAQ,aACnB,EAAE,eAAe,GACjB,EAAS;EAEb;EACA,WAAW,EACT,uCACA,iDACA,yBACA,sDACA,sCACF;EACA,cAAW;CACZ,CAAA;AAEL;AAKA,SAAS,EAAoB,EAAE,UAA4B;CACzD,IAAM,EACJ,UACA,uBACA,aACA,gBACA,mBACA,eACA,eACA,oBACE,EAA2B,GAEzB,IAAiB,GACpB,MAA6C;EACvC,MACU,EAAE,OACN,QAAA,yDAA4B,KACvC,EAAW,EAAI,QAAQ;CACzB,GACA,CAAC,GAAY,EAAI,QAAQ,CAC3B,GAEM,IAAe,EAAI,gBAAgB;CAEzC,OACE,kBAAC,GAAD;EACE,cAAY,EAAI,cAAc,KAAK;EACnC,WAAW,EACT,KAAc,kBACd,IAAe,EAAI,QAAQ,CAC7B;EACA,SAAS,IAAa,IAAiB,KAAA;YAEtC,EAAa,KAAK,MAAS;GAC1B,IAAM,IAAS,EAAmB,EAAK,OAAO,IAAI,C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AAA,EACD,CAAA;CAIf,IAAI,KAAe,GAAc;EAW/B,IAAM,IAAY,EAAa,IACzB,IAAW,EAAa,EAAa,SAAS,IAC9C,IAAS,IAAY,EAAU,QAAQ,GACvC,IAAY,IAAW,KAAK,IAAI,IAAI,KAAoB,KAAK,EAAS,GAAG,IAAI,GAC7E,KAAc,MAClB,kBAAC,SAAD;GAAO,eAAY;aACjB,kBAAC,MAAD,EAAA,UACE,kBAAC,MAAD;IAAI,SAAS,EAAW;IAAQ,OAAO;KAAE;KAAQ,SAAS;KAAG,QAAQ;IAAE;GAAI,CAAA,EACzE,CAAA;EACC,CAAA;EAGT,OACE,kBAAA,GAAA,EAAA,UAAA;GACG,IAAS,KAAK,EAAW,CAAM;GAC/B,EAAa,KAAK,MAAe;IAChC,IAAM,IAAM,EAAK,EAAW,QACtB,IAAY,EAAW,UAAU,EAAK,SAAS;IACrD,OACE,kBAAC,SAAD;KAEE,KAAK;KACL,cAAY,EAAW;KACvB,WAAW,EAAG,KAAa,4BAA4B;eAJzD,CAME,kBAAC,GAAD,EAAmB,OAAM,CAAA,GACzB,kBAAC,GAAD,EAA2B,OAAM,CAAA,CAC5B;OAPA,EAAI,EAOJ;GAEX,CAAC;GACA,IAAY,KAAK,EAAW,CAAS;EACtC,EAAA,CAAA;CAEN;CAGA,OACE,kBAAC,GAAD,EAAA,UACG,EAAK,KAAK,MACT,kBAAC,EAAM,UAAP,EAAA,UAAA,CACE,kBAAC,GAAD,EAAmB,OAAM,CAAA,GACzB,kBAAC,GAAD,EAA2B,OAAM,CAAA,CACnB,EAAA,GAHK,EAAI,EAGT,CACjB,EACQ,CAAA;AAEf"}
|
|
1
|
+
{"version":3,"file":"data-table-body.js","names":[],"sources":["../../src/ui/data-table-body.tsx"],"sourcesContent":["'use client'\n\nimport { flexRender,type Row } from '@tanstack/react-table'\nimport { type VirtualItem } from '@tanstack/react-virtual'\nimport { AnimatePresence, motion, useReducedMotion } from 'framer-motion'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport {\n getColumnMetaClasses,\n getPinnedCellStyle,\n INTERACTIVE_SELECTOR,\n isColumnEditable,\n useDataTableContext,\n} from './data-table-context'\nimport { springs } from './lib/motion'\nimport { cn } from './lib/utils'\nimport { Skeleton } from './skeleton'\nimport { TableBody, TableCell, TableRow } from './table'\n\n// ── CellEditInput ───────────────────────────────────────────────\n\n/**\n * Inline edit input rendered inside a table cell.\n * Auto-focuses, saves on Enter/blur, cancels on Escape.\n */\nfunction CellEditInput({\n initialValue,\n onSave,\n onCancel,\n}: {\n initialValue: string\n onSave: (value: string) => void\n onCancel: () => void\n}) {\n const [value, setValue] = useState(initialValue)\n const inputRef = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n inputRef.current?.focus()\n inputRef.current?.select()\n }, [])\n\n const handleSave = useCallback(() => {\n onSave(value)\n }, [onSave, value])\n\n return (\n <input\n ref={inputRef}\n type=\"text\"\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onBlur={handleSave}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault()\n handleSave()\n } else if (e.key === 'Escape') {\n e.preventDefault()\n onCancel()\n }\n }}\n className={cn(\n 'h-ds-xs-plus w-full rounded-control',\n 'border border-accent-7 bg-surface-panel-hover',\n 'px-ds-02 text-body-sm',\n 'text-surface-fg placeholder:text-surface-fg-subtle',\n 'outline-hidden focus:border-accent-7',\n )}\n aria-label=\"Edit cell value\"\n />\n )\n}\n\n// ── DataRow ─────────────────────────────────────────────────────\n\n/** Render a single data row (shared between virtual and non-virtual paths) */\nfunction DataTableRow<TData>({ row }: { row: Row<TData> }) {\n const {\n table,\n columnPinningState,\n editable,\n editingCell,\n setEditingCell,\n onCellEdit,\n onRowClick,\n rowClassName,\n } = useDataTableContext<TData>()\n\n const handleRowClick = useCallback(\n (e: React.MouseEvent<HTMLTableRowElement>) => {\n if (!onRowClick) return\n const target = e.target as HTMLElement\n if (target.closest(INTERACTIVE_SELECTOR)) return\n onRowClick(row.original)\n },\n [onRowClick, row.original],\n )\n\n const visibleCells = row.getVisibleCells()\n\n return (\n <TableRow\n data-state={row.getIsSelected() && 'selected'}\n className={cn(\n onRowClick && 'cursor-pointer',\n rowClassName?.(row.original),\n )}\n onClick={onRowClick ? handleRowClick : undefined}\n >\n {visibleCells.map((cell) => {\n // `cell.column` is what makes the offset cumulative — without it every\n // pinned column resolves to the same edge and they stack.\n const pinned = getPinnedCellStyle(\n cell.column.id,\n columnPinningState,\n cell.column,\n )\n const isEditing =\n editingCell?.rowIndex === row.index &&\n editingCell?.columnId === cell.column.id\n\n return (\n <TableCell\n key={cell.id}\n className={cn(\n pinned.className,\n getColumnMetaClasses(\n cell.column.columnDef.meta as Record<string, unknown>,\n ),\n )}\n style={pinned.style}\n data-pinned={pinned['data-pinned']}\n onDoubleClick={() => {\n if (isColumnEditable(cell.column.id, editable, table)) {\n setEditingCell({\n rowIndex: row.index,\n columnId: cell.column.id,\n })\n }\n }}\n >\n {isEditing ? (\n <CellEditInput\n initialValue={String(cell.getValue() ?? '')}\n onSave={(value) => {\n onCellEdit?.(row.index, cell.column.id, value)\n setEditingCell(null)\n }}\n onCancel={() => setEditingCell(null)}\n />\n ) : (\n flexRender(cell.column.columnDef.cell, cell.getContext())\n )}\n </TableCell>\n )\n })}\n </TableRow>\n )\n}\n\n// ── ExpandedRow ─────────────────────────────────────────────────\n\n/** Render expanded content row below the data row */\nfunction DataTableExpandedRow<TData>({ row }: { row: Row<TData> }) {\n const { allColumns, expandable, renderExpanded, virtualRows } =\n useDataTableContext<TData>()\n // Self-guarded (StatFlash pattern) — reveal collapses to an instant swap\n // without relying on a consumer MotionProvider.\n const prefersReduced = useReducedMotion()\n\n if (!expandable || !renderExpanded) return null\n\n const expanded = row.getIsExpanded()\n\n // In virtual mode the reveal is instant: the row group's height is watched by\n // the virtualizer's ResizeObserver, and an animating height would fire a\n // resize on every frame of the spring.\n if (virtualRows) {\n if (!expanded) return null\n return (\n <TableRow>\n <TableCell colSpan={allColumns.length} className=\"bg-surface-sunken p-ds-05\">\n {renderExpanded(row.original)}\n </TableCell>\n </TableRow>\n )\n }\n\n return (\n <AnimatePresence initial={false}>\n {expanded && (\n <TableRow>\n <TableCell\n colSpan={allColumns.length}\n // A recess, not a raised layer — surface-panel would vanish on a\n // card. Padding moves to the inner div so the collapsed state has\n // zero height.\n className=\"bg-surface-sunken p-0\"\n >\n <motion.div\n className=\"overflow-hidden\"\n initial={prefersReduced ? false : { height: 0, opacity: 0 }}\n animate={{ height: 'auto', opacity: 1 }}\n exit={prefersReduced ? undefined : { height: 0, opacity: 0 }}\n transition={\n prefersReduced ? { duration: 0 } : { ...springs.smooth }\n }\n >\n <div className=\"p-ds-05\">{renderExpanded(row.original)}</div>\n </motion.div>\n </TableCell>\n </TableRow>\n )}\n </AnimatePresence>\n )\n}\n\n// ── SkeletonRows ────────────────────────────────────────────────\n\nfunction DataTableSkeletonRows({\n rowCount,\n}: {\n rowCount: number\n}) {\n const { allColumns } = useDataTableContext()\n const visibleColumnCount = allColumns.length\n const skeletonWidths = ['w-3/4', 'w-1/2', 'w-2/3', 'w-full']\n\n return (\n <TableBody>\n {Array.from({ length: rowCount }, (_, rowIdx) => (\n <TableRow key={`skeleton-${rowIdx}`}>\n {Array.from({ length: visibleColumnCount }, (_, colIdx) => {\n const colId = allColumns[colIdx]?.id ?? allColumns[colIdx]?.header\n const isSelect = colId === '_select'\n return (\n <TableCell key={`skeleton-${rowIdx}-${colIdx}`}>\n {isSelect ? (\n <Skeleton\n variant=\"text\"\n className=\"h-4 w-4\"\n animation=\"pulse\"\n />\n ) : (\n <Skeleton\n variant=\"text\"\n className={cn(\n 'h-4',\n skeletonWidths[colIdx % skeletonWidths.length],\n )}\n animation=\"pulse\"\n />\n )}\n </TableCell>\n )\n })}\n </TableRow>\n ))}\n </TableBody>\n )\n}\n\n// ── DataTableBody (orchestrates all body rendering) ─────────────\n\nexport function DataTableBody<TData>({\n loading,\n skeletonRowCount,\n noResultsText,\n emptyState,\n virtualItems,\n totalVirtualSize,\n measureRow,\n}: {\n loading?: boolean\n skeletonRowCount: number\n noResultsText?: string\n emptyState?: React.ReactNode\n virtualItems?: VirtualItem[]\n totalVirtualSize?: number\n /** `virtualizer.measureElement` — attached to each virtual row group */\n measureRow?: (node: HTMLTableSectionElement | null) => void\n}) {\n const { table, allColumns, virtualRows } = useDataTableContext<TData>()\n const rows = table.getRowModel().rows\n\n // Loading state: show skeleton rows\n if (loading) {\n return <DataTableSkeletonRows rowCount={skeletonRowCount} />\n }\n\n if (!rows.length) {\n return (\n <TableBody>\n <TableRow>\n <TableCell\n colSpan={allColumns.length}\n className={cn(\n 'py-ds-07 text-center',\n !emptyState && 'text-surface-fg-subtle',\n )}\n >\n {emptyState || noResultsText || 'No results.'}\n </TableCell>\n </TableRow>\n </TableBody>\n )\n }\n\n if (virtualRows && virtualItems) {\n // Each windowed row gets its OWN <tbody> (valid HTML — a table may hold any\n // number of row groups) carrying `data-index` + the virtualizer's\n // `measureElement` ref. That group is what gets measured, so a row's height\n // INCLUDES its expanded detail row and `getTotalSize()` stays truthful.\n //\n // Rows stay in normal table flow; the window is positioned by spacer row\n // groups above and below instead of absolute offsets. Two consequences worth\n // knowing: an expanded panel can never paint on top of the next row (flow\n // layout forbids it), and column widths keep tracking <thead> because the\n // cells are still real table cells.\n const firstItem = virtualItems[0]\n const lastItem = virtualItems[virtualItems.length - 1]\n const padTop = firstItem ? firstItem.start : 0\n const padBottom = lastItem ? Math.max(0, (totalVirtualSize ?? 0) - lastItem.end) : 0\n const spacerCell = (height: number) => (\n <tbody aria-hidden=\"true\">\n <tr>\n <td colSpan={allColumns.length} style={{ height, padding: 0, border: 0 }} />\n </tr>\n </tbody>\n )\n\n return (\n <>\n {padTop > 0 && spacerCell(padTop)}\n {virtualItems.map((virtualRow) => {\n const row = rows[virtualRow.index]\n const isLastRow = virtualRow.index === rows.length - 1\n return (\n <tbody\n key={row.id}\n ref={measureRow}\n data-index={virtualRow.index}\n className={cn(isLastRow && '[&_tr:last-child]:border-0')}\n >\n <DataTableRow row={row} />\n <DataTableExpandedRow row={row} />\n </tbody>\n )\n })}\n {padBottom > 0 && spacerCell(padBottom)}\n </>\n )\n }\n\n // Standard (non-virtual) rendering\n return (\n <TableBody>\n {rows.map((row) => (\n <React.Fragment key={row.id}>\n <DataTableRow row={row} />\n <DataTableExpandedRow row={row} />\n </React.Fragment>\n ))}\n </TableBody>\n )\n}\n"],"mappings":";;;;;;;;;;;AAyBA,SAAS,EAAc,EACrB,iBACA,WACA,eAKC;CACD,IAAM,CAAC,GAAO,KAAY,EAAS,CAAY,GACzC,IAAW,EAAyB,IAAI;CAE9C,QAAgB;EAEd,AADA,EAAS,SAAS,MAAM,GACxB,EAAS,SAAS,OAAO;CAC3B,GAAG,CAAC,CAAC;CAEL,IAAM,IAAa,QAAkB;EACnC,EAAO,CAAK;CACd,GAAG,CAAC,GAAQ,CAAK,CAAC;CAElB,OACE,kBAAC,SAAD;EACE,KAAK;EACL,MAAK;EACE;EACP,WAAW,MAAM,EAAS,EAAE,OAAO,KAAK;EACxC,QAAQ;EACR,YAAY,MAAM;GAChB,AAAI,EAAE,QAAQ,WACZ,EAAE,eAAe,GACjB,EAAW,KACF,EAAE,QAAQ,aACnB,EAAE,eAAe,GACjB,EAAS;EAEb;EACA,WAAW,EACT,uCACA,iDACA,yBACA,sDACA,sCACF;EACA,cAAW;CACZ,CAAA;AAEL;AAKA,SAAS,EAAoB,EAAE,UAA4B;CACzD,IAAM,EACJ,UACA,uBACA,aACA,gBACA,mBACA,eACA,eACA,oBACE,EAA2B,GAEzB,IAAiB,GACpB,MAA6C;EACvC,MACU,EAAE,OACN,QAAA,yDAA4B,KACvC,EAAW,EAAI,QAAQ;CACzB,GACA,CAAC,GAAY,EAAI,QAAQ,CAC3B,GAEM,IAAe,EAAI,gBAAgB;CAEzC,OACE,kBAAC,GAAD;EACE,cAAY,EAAI,cAAc,KAAK;EACnC,WAAW,EACT,KAAc,kBACd,IAAe,EAAI,QAAQ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: 'accent' | 'error';
|
|
13
13
|
disabled?: boolean;
|
|
14
|
+
/** Show an inline "Are you sure?" step before running. */
|
|
15
|
+
requiresConfirmation?: boolean;
|
|
16
|
+
/** Overrides the default "Are you sure?" prompt. */
|
|
17
|
+
confirmMessage?: string;
|
|
18
|
+
/** Spinner on this action while its work is in flight. */
|
|
19
|
+
loading?: boolean;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
|
-
*
|
|
22
|
+
* DataTable's bulk-action bar. An adapter over the shared `BulkActionBar`
|
|
23
|
+
* rather than a second implementation.
|
|
24
|
+
*
|
|
25
|
+
* It used to be a parallel, thinner copy — and the copy drifted in four ways
|
|
26
|
+
* inside one release cycle (raw `bottom-6` instead of the spacing token, a
|
|
27
|
+
* non-RTL `left-1/2`, `outline` against the repo's documented soft-over-outline
|
|
28
|
+
* preference, and a bare `<button>` where `Button` belonged). Worse, it
|
|
29
|
+
* declared `role="toolbar"` while implementing plain tab stops, so it told
|
|
30
|
+
* screen-reader users to expect arrow-key navigation and one tab stop, and
|
|
31
|
+
* delivered neither. That is the class of bug a single implementation cannot
|
|
32
|
+
* have, and it was sitting on the higher-traffic path.
|
|
33
|
+
*
|
|
34
|
+
* The adapter is deliberately thin. Everything DataTable-specific stays here:
|
|
35
|
+
*
|
|
36
|
+
* - `onClick(selectedRows)` keeps its row payload, closed over per render. The
|
|
37
|
+
* shared bar's actions take no argument, and changing DataTable's signature
|
|
38
|
+
* to match would have broken every consumer for no benefit.
|
|
39
|
+
* - Clearing still calls `table.resetRowSelection()` itself, so consumers do
|
|
40
|
+
* not have to wire it.
|
|
41
|
+
*
|
|
17
42
|
* Internal — not exported to consumers.
|
|
18
43
|
*/
|
|
19
44
|
export declare function DataTableBulkActions<TData>({ table, selectedRows, bulkActions, position, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-bulk-actions.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-bulk-actions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-table-bulk-actions.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-bulk-actions.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE7D,yDAAyD;AACzD,MAAM,WAAW,UAAU,CAAC,KAAK;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,IAAI,CAAA;IACxC,uEAAuE;IACvE,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,WAAW,EACX,QAAmB,GACpB,EAAE;IACD,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACnB,YAAY,EAAE,KAAK,EAAE,CAAA;IACrB,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAA;IAChC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;CAC/B,qBAyBA"}
|
|
@@ -1,51 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import "react";
|
|
6
|
-
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
7
|
-
import { IconX as a } from "@tabler/icons-react";
|
|
2
|
+
import { BulkActionBar as e } from "./bulk-action-bar.js";
|
|
3
|
+
import t from "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
8
5
|
//#region src/ui/data-table-bulk-actions.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"aria-hidden": "true"
|
|
27
|
-
}),
|
|
28
|
-
l.map((e) => /* @__PURE__ */ r(n, {
|
|
29
|
-
size: "sm",
|
|
30
|
-
variant: e.color === "error" ? "solid" : "outline",
|
|
31
|
-
color: e.color === "error" ? "error" : void 0,
|
|
32
|
-
disabled: e.disabled,
|
|
33
|
-
startIcon: e.icon,
|
|
34
|
-
onClick: () => e.onClick(c),
|
|
35
|
-
children: e.label
|
|
36
|
-
}, e.label)),
|
|
37
|
-
/* @__PURE__ */ r("button", {
|
|
38
|
-
type: "button",
|
|
39
|
-
onClick: () => s.resetRowSelection(),
|
|
40
|
-
"aria-label": "Clear selection",
|
|
41
|
-
className: e("flex items-center justify-center p-ds-01", "rounded-control-inner hover:bg-surface-panel-hover transition-colors", "text-surface-fg-muted hover:text-surface-fg"),
|
|
42
|
-
children: /* @__PURE__ */ r(t, {
|
|
43
|
-
icon: a,
|
|
44
|
-
size: "sm"
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
]
|
|
6
|
+
function r({ table: r, selectedRows: i, bulkActions: a, position: o = "bottom" }) {
|
|
7
|
+
let s = t.useMemo(() => a.map((e) => ({
|
|
8
|
+
label: e.label,
|
|
9
|
+
icon: e.icon,
|
|
10
|
+
color: e.color,
|
|
11
|
+
disabled: e.disabled,
|
|
12
|
+
loading: e.loading,
|
|
13
|
+
requiresConfirmation: e.requiresConfirmation,
|
|
14
|
+
confirmMessage: e.confirmMessage,
|
|
15
|
+
onClick: () => e.onClick(i)
|
|
16
|
+
})), [a, i]);
|
|
17
|
+
return /* @__PURE__ */ n(e, {
|
|
18
|
+
show: !0,
|
|
19
|
+
count: i.length,
|
|
20
|
+
actions: s,
|
|
21
|
+
placement: o,
|
|
22
|
+
onClearSelection: () => r.resetRowSelection()
|
|
48
23
|
});
|
|
49
24
|
}
|
|
50
25
|
//#endregion
|
|
51
|
-
export {
|
|
26
|
+
export { r as DataTableBulkActions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-bulk-actions.js","names":[],"sources":["../../src/ui/data-table-bulk-actions.tsx"],"sourcesContent":["'use client'\n\nimport {
|
|
1
|
+
{"version":3,"file":"data-table-bulk-actions.js","names":[],"sources":["../../src/ui/data-table-bulk-actions.tsx"],"sourcesContent":["'use client'\n\nimport { type Table } from '@tanstack/react-table'\nimport React from 'react'\n\nimport { BulkActionBar,type BulkActionBarAction } from './bulk-action-bar'\nimport type { IconInput } from './lib/icon-input'\n\n/** Where the floating bulk-action bar renders. @default 'bottom' */\nexport type BulkActionsPosition = 'bottom' | 'top' | 'inline'\n\n/** Bulk action definition for the floating action bar */\nexport interface BulkAction<TData> {\n label: string\n onClick: (selectedRows: TData[]) => void\n /** Icon rendered before the label — useful for compact/mobile bars. */\n icon?: IconInput\n color?: 'accent' | 'error'\n disabled?: boolean\n /** Show an inline \"Are you sure?\" step before running. */\n requiresConfirmation?: boolean\n /** Overrides the default \"Are you sure?\" prompt. */\n confirmMessage?: string\n /** Spinner on this action while its work is in flight. */\n loading?: boolean\n}\n\n/**\n * DataTable's bulk-action bar. An adapter over the shared `BulkActionBar`\n * rather than a second implementation.\n *\n * It used to be a parallel, thinner copy — and the copy drifted in four ways\n * inside one release cycle (raw `bottom-6` instead of the spacing token, a\n * non-RTL `left-1/2`, `outline` against the repo's documented soft-over-outline\n * preference, and a bare `<button>` where `Button` belonged). Worse, it\n * declared `role=\"toolbar\"` while implementing plain tab stops, so it told\n * screen-reader users to expect arrow-key navigation and one tab stop, and\n * delivered neither. That is the class of bug a single implementation cannot\n * have, and it was sitting on the higher-traffic path.\n *\n * The adapter is deliberately thin. Everything DataTable-specific stays here:\n *\n * - `onClick(selectedRows)` keeps its row payload, closed over per render. The\n * shared bar's actions take no argument, and changing DataTable's signature\n * to match would have broken every consumer for no benefit.\n * - Clearing still calls `table.resetRowSelection()` itself, so consumers do\n * not have to wire it.\n *\n * Internal — not exported to consumers.\n */\nexport function DataTableBulkActions<TData>({\n table,\n selectedRows,\n bulkActions,\n position = 'bottom',\n}: {\n table: Table<TData>\n selectedRows: TData[]\n bulkActions: BulkAction<TData>[]\n position?: BulkActionsPosition\n}) {\n const actions = React.useMemo<BulkActionBarAction[]>(\n () =>\n bulkActions.map((a) => ({\n label: a.label,\n icon: a.icon,\n color: a.color,\n disabled: a.disabled,\n loading: a.loading,\n requiresConfirmation: a.requiresConfirmation,\n confirmMessage: a.confirmMessage,\n onClick: () => a.onClick(selectedRows),\n })),\n [bulkActions, selectedRows],\n )\n\n return (\n <BulkActionBar\n show\n count={selectedRows.length}\n actions={actions}\n placement={position}\n onClearSelection={() => table.resetRowSelection()}\n />\n )\n}\n"],"mappings":";;;;;AAkDA,SAAgB,EAA4B,EAC1C,UACA,iBACA,gBACA,cAAW,YAMV;CACD,IAAM,IAAU,EAAM,cAElB,EAAY,KAAK,OAAO;EACtB,OAAO,EAAE;EACT,MAAM,EAAE;EACR,OAAO,EAAE;EACT,UAAU,EAAE;EACZ,SAAS,EAAE;EACX,sBAAsB,EAAE;EACxB,gBAAgB,EAAE;EAClB,eAAe,EAAE,QAAQ,CAAY;CACvC,EAAE,GACJ,CAAC,GAAa,CAAY,CAC5B;CAEA,OACE,kBAAC,GAAD;EACE,MAAA;EACA,OAAO,EAAa;EACX;EACT,WAAW;EACX,wBAAwB,EAAM,kBAAkB;CACjD,CAAA;AAEL"}
|
|
@@ -51,10 +51,44 @@ export declare function DataTableProvider<TData>({ children, value, }: {
|
|
|
51
51
|
value: DataTableContextValue<TData>;
|
|
52
52
|
}): React.JSX.Element;
|
|
53
53
|
export declare function useDataTableContext<TData = unknown>(): DataTableContextValue<TData>;
|
|
54
|
-
/**
|
|
55
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Compute sticky positioning styles for pinned columns.
|
|
56
|
+
*
|
|
57
|
+
* `column` is optional so existing callers keep working, but WITHOUT it every
|
|
58
|
+
* pinned column resolves to the same edge. Pass it.
|
|
59
|
+
*
|
|
60
|
+
* Three things were wrong here and all three had the same root: the function
|
|
61
|
+
* knew a column's *identity* but nothing about its *geometry*.
|
|
62
|
+
*
|
|
63
|
+
* - The offset was hardcoded to 0, so two left-pinned columns stacked on top of
|
|
64
|
+
* each other. `leftIndex` was computed and then thrown away. TanStack already
|
|
65
|
+
* knows the cumulative width — `getStart('left')` / `getAfter('right')` — so
|
|
66
|
+
* the fix is to ask it rather than to sum widths here.
|
|
67
|
+
* - The cell painted `bg-surface-panel` unconditionally, which is right for
|
|
68
|
+
* occluding scrolled content underneath and wrong for everything else: a
|
|
69
|
+
* selected row's pinned cell stayed panel-coloured and a striped row's showed
|
|
70
|
+
* a white notch. It now inherits the row's background and only falls back to
|
|
71
|
+
* the panel colour when the row has none of its own (`bg-inherit`), so the
|
|
72
|
+
* occlusion still works.
|
|
73
|
+
* - There was no edge, so a pinned column was invisible unscrolled and had
|
|
74
|
+
* content slide under it with no seam when scrolled. The last left-pinned and
|
|
75
|
+
* first right-pinned column now carry a hairline on the boundary.
|
|
76
|
+
*/
|
|
77
|
+
export declare function getPinnedCellStyle(columnId: string, columnPinningState: ColumnPinningState, column?: {
|
|
78
|
+
getStart: (p?: 'left') => number;
|
|
79
|
+
getAfter: (p?: 'right') => number;
|
|
80
|
+
}): {
|
|
56
81
|
className: string;
|
|
57
82
|
style: React.CSSProperties;
|
|
83
|
+
'data-pinned': "left";
|
|
84
|
+
} | {
|
|
85
|
+
className: string;
|
|
86
|
+
style: React.CSSProperties;
|
|
87
|
+
'data-pinned': "right";
|
|
88
|
+
} | {
|
|
89
|
+
className: string;
|
|
90
|
+
style: React.CSSProperties;
|
|
91
|
+
'data-pinned': undefined;
|
|
58
92
|
};
|
|
59
93
|
/** Check if a column allows editing */
|
|
60
94
|
export declare function isColumnEditable<TData>(columnId: string, editable: boolean, table: Table<TData>): boolean;
|