@middag-io/react 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist-lib/base/shell/AuthShell.js +39 -0
- package/dist-lib/base/shell/BasicShell.js +207 -0
- package/dist-lib/base/shell/ImmersiveShell.js +55 -0
- package/dist-lib/base/shell/partials/InspectorContext.js +60 -0
- package/dist-lib/base/shell/partials/InspectorPanel.js +22 -0
- package/dist-lib/base/shell/partials/NavErrorBoundary.js +66 -0
- package/dist-lib/base/shell/partials/OverlayScreen.js +36 -0
- package/dist-lib/base/shell/partials/PageActionButton.js +4 -0
- package/dist-lib/base/theme/appearance.js +39 -0
- package/dist-lib/base/theme/host-layout-detector.js +39 -0
- package/dist-lib/base/theme/host-theme-detector.js +131 -0
- package/dist-lib/base/theme/sidebar-safelist.txt +20 -0
- package/dist-lib/base/theme/theme-bridge.css +164 -0
- package/dist-lib/base/theme/theme-context.js +103 -0
- package/dist-lib/base/theme/themes/classic.css +174 -0
- package/dist-lib/base/theme/tokens.css +290 -0
- package/dist-lib/base/theme/useHostTheme.js +34 -0
- package/dist-lib/base/utils/clipboard.js +16 -0
- package/dist-lib/base/utils/conditions.js +13 -0
- package/dist-lib/base/utils/icon-registry.js +16 -0
- package/dist-lib/base/utils/icons.js +11 -0
- package/dist-lib/base/utils/interpolate.js +6 -0
- package/dist-lib/base/utils/register-default-icons.js +9 -0
- package/dist-lib/base/utils/storage.js +30 -0
- package/dist-lib/base/utils/time.js +59 -0
- package/dist-lib/chunks/subpath-BD_PKGUX.js +146 -0
- package/dist-lib/chunks/subpath-DLFO_UGQ.js +604 -0
- package/dist-lib/components/reui/accordion.js +43 -0
- package/dist-lib/components/reui/alert-dialog.js +101 -0
- package/dist-lib/components/reui/alert.js +55 -0
- package/dist-lib/components/reui/aspect-ratio.js +11 -0
- package/dist-lib/components/reui/autocomplete.js +170 -0
- package/dist-lib/components/reui/avatar.js +51 -0
- package/dist-lib/components/reui/badge.js +64 -0
- package/dist-lib/components/reui/breadcrumb.js +69 -0
- package/dist-lib/components/reui/button-group.js +38 -0
- package/dist-lib/components/reui/button.js +47 -0
- package/dist-lib/components/reui/calendar.js +89 -0
- package/dist-lib/components/reui/card.js +55 -0
- package/dist-lib/components/reui/carousel.js +110 -0
- package/dist-lib/components/reui/chart.js +130 -0
- package/dist-lib/components/reui/checkbox.js +20 -0
- package/dist-lib/components/reui/collapsible.js +23 -0
- package/dist-lib/components/reui/combobox.js +166 -0
- package/dist-lib/components/reui/command.js +85 -0
- package/dist-lib/components/reui/context-menu.js +121 -0
- package/dist-lib/components/reui/data-grid/data-grid-column-filter.js +108 -0
- package/dist-lib/components/reui/data-grid/data-grid-column-header.js +217 -0
- package/dist-lib/components/reui/data-grid/data-grid-column-visibility.js +25 -0
- package/dist-lib/components/reui/data-grid/data-grid-pagination.js +132 -0
- package/dist-lib/components/reui/data-grid/data-grid-scroll-area.js +183 -0
- package/dist-lib/components/reui/data-grid/data-grid-table-dnd-rows.js +125 -0
- package/dist-lib/components/reui/data-grid/data-grid-table-dnd.js +130 -0
- package/dist-lib/components/reui/data-grid/data-grid-table-virtual.js +156 -0
- package/dist-lib/components/reui/data-grid/data-grid-table.js +546 -0
- package/dist-lib/components/reui/data-grid/data-grid.js +113 -0
- package/dist-lib/components/reui/data-grid-pagination.js +131 -0
- package/dist-lib/components/reui/date-selector.js +642 -0
- package/dist-lib/components/reui/dialog.js +94 -0
- package/dist-lib/components/reui/drawer.js +77 -0
- package/dist-lib/components/reui/dropdown-menu.js +123 -0
- package/dist-lib/components/reui/empty.js +59 -0
- package/dist-lib/components/reui/field.js +115 -0
- package/dist-lib/components/reui/filters.js +873 -0
- package/dist-lib/components/reui/frame.js +97 -0
- package/dist-lib/components/reui/hover-card.js +31 -0
- package/dist-lib/components/reui/icon-placeholder.js +14 -0
- package/dist-lib/components/reui/index.js +18 -0
- package/dist-lib/components/reui/input-group.js +78 -0
- package/dist-lib/components/reui/input-otp.js +44 -0
- package/dist-lib/components/reui/input.js +14 -0
- package/dist-lib/components/reui/item.js +116 -0
- package/dist-lib/components/reui/kanban.js +316 -0
- package/dist-lib/components/reui/kbd.js +19 -0
- package/dist-lib/components/reui/label.js +14 -0
- package/dist-lib/components/reui/menubar.js +132 -0
- package/dist-lib/components/reui/native-select.js +37 -0
- package/dist-lib/components/reui/navigation-menu.js +80 -0
- package/dist-lib/components/reui/number-field.js +126 -0
- package/dist-lib/components/reui/pagination.js +78 -0
- package/dist-lib/components/reui/phone-input.js +124 -0
- package/dist-lib/components/reui/popover.js +55 -0
- package/dist-lib/components/reui/progress.js +20 -0
- package/dist-lib/components/reui/radio-group.js +27 -0
- package/dist-lib/components/reui/rating.js +81 -0
- package/dist-lib/components/reui/resizable.js +31 -0
- package/dist-lib/components/reui/scroll-area.js +36 -0
- package/dist-lib/components/reui/scrollspy.js +104 -0
- package/dist-lib/components/reui/select.js +97 -0
- package/dist-lib/components/reui/separator.js +17 -0
- package/dist-lib/components/reui/sheet.js +81 -0
- package/dist-lib/components/reui/sidebar.js +350 -0
- package/dist-lib/components/reui/skeleton.js +12 -0
- package/dist-lib/components/reui/slider.js +35 -0
- package/dist-lib/components/reui/sonner.js +28 -0
- package/dist-lib/components/reui/sortable.js +172 -0
- package/dist-lib/components/reui/spinner.js +14 -0
- package/dist-lib/components/reui/stepper.js +193 -0
- package/dist-lib/components/reui/svgs/claudeAiIcon.js +13 -0
- package/dist-lib/components/reui/svgs/gemini.js +257 -0
- package/dist-lib/components/reui/svgs/openai.js +10 -0
- package/dist-lib/components/reui/svgs/openaiDark.js +13 -0
- package/dist-lib/components/reui/switch.js +19 -0
- package/dist-lib/components/reui/table.js +66 -0
- package/dist-lib/components/reui/tabs.js +47 -0
- package/dist-lib/components/reui/textarea.js +13 -0
- package/dist-lib/components/reui/timeline.js +84 -0
- package/dist-lib/components/reui/toggle-group.js +48 -0
- package/dist-lib/components/reui/toggle.js +36 -0
- package/dist-lib/components/reui/tooltip.js +35 -0
- package/dist-lib/components/reui/tree.js +102 -0
- package/dist-lib/i18n/I18nProvider.js +23 -0
- package/dist-lib/i18n/host-resolver.js +10 -0
- package/dist-lib/i18n/instance.js +2 -0
- package/dist-lib/i18n/locales/en/ui.json +266 -0
- package/dist-lib/i18n/locales/en/validators.json +13 -0
- package/dist-lib/i18n/locales/pt-BR/ui.json +266 -0
- package/dist-lib/i18n/locales/pt-BR/validators.json +13 -0
- package/dist-lib/i18n/register-strings.js +7 -0
- package/dist-lib/i18n/render-label.js +13 -0
- package/dist-lib/i18n/resolve-field-error.js +10 -0
- package/dist-lib/i18n/useHostString.js +31 -0
- package/dist-lib/i18n/useTranslation.js +48 -0
- package/dist-lib/lib/actions/resolve-action-target.js +48 -0
- package/dist-lib/lib/hooks/use-copy-to-clipboard.js +18 -0
- package/dist-lib/lib/hooks/use-file-upload.js +171 -0
- package/dist-lib/lib/hooks/use-mobile.js +18 -0
- package/dist-lib/lib/portal-container.js +7 -0
- package/dist-lib/lib/utils.js +8 -0
- package/package.json +39 -7
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../../lib/utils.js";
|
|
3
|
+
import { Button as t } from "../button.js";
|
|
4
|
+
import { useDataGrid as n } from "./data-grid.js";
|
|
5
|
+
import { Select as r, SelectContent as i, SelectItem as a, SelectTrigger as o, SelectValue as s } from "../select.js";
|
|
6
|
+
import { Skeleton as c } from "../skeleton.js";
|
|
7
|
+
import "react";
|
|
8
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
|
+
import { HugeiconsIcon as f } from "@hugeicons/react";
|
|
10
|
+
import { ArrowLeft01Icon as p, ArrowRight01Icon as m } from "@hugeicons/core-free-icons";
|
|
11
|
+
//#region src/components/reui/data-grid/data-grid-pagination.tsx
|
|
12
|
+
function h(h) {
|
|
13
|
+
let { table: g, recordCount: _, isLoading: v } = n(), y = {
|
|
14
|
+
sizes: [
|
|
15
|
+
5,
|
|
16
|
+
10,
|
|
17
|
+
25,
|
|
18
|
+
50,
|
|
19
|
+
100
|
|
20
|
+
],
|
|
21
|
+
sizesLabel: "Show",
|
|
22
|
+
sizesDescription: "per page",
|
|
23
|
+
sizesSkeleton: /* @__PURE__ */ u(c, { className: "h-8 w-44" }),
|
|
24
|
+
moreLimit: 5,
|
|
25
|
+
more: !1,
|
|
26
|
+
info: "{from} - {to} of {count}",
|
|
27
|
+
infoSkeleton: /* @__PURE__ */ u(c, { className: "h-8 w-60" }),
|
|
28
|
+
rowsPerPageLabel: "Rows per page",
|
|
29
|
+
previousPageLabel: "Go to previous page",
|
|
30
|
+
nextPageLabel: "Go to next page",
|
|
31
|
+
ellipsisText: "...",
|
|
32
|
+
...h
|
|
33
|
+
}, b = "size-7 p-0 text-sm", x = b + " rtl:transform rtl:rotate-180", S = g.getState().pagination.pageIndex, C = g.getState().pagination.pageSize, w = S * C + 1, T = Math.min((S + 1) * C, _), E = g.getPageCount(), D = y?.info ? y.info.replace("{from}", w.toString()).replace("{to}", T.toString()).replace("{count}", _.toString()) : `${w} - ${T} of ${_}`, O = y?.moreLimit || 5, k = Math.floor(S / O) * O, A = Math.min(k + O, E), j = () => {
|
|
34
|
+
let n = [];
|
|
35
|
+
for (let r = k; r < A; r++) n.push(/* @__PURE__ */ u(t, {
|
|
36
|
+
size: "icon-sm",
|
|
37
|
+
variant: "ghost",
|
|
38
|
+
className: e(b, "text-muted-foreground", { "bg-accent text-accent-foreground": S === r }),
|
|
39
|
+
onClick: () => {
|
|
40
|
+
S !== r && g.setPageIndex(r);
|
|
41
|
+
},
|
|
42
|
+
children: r + 1
|
|
43
|
+
}, r));
|
|
44
|
+
return n;
|
|
45
|
+
}, M = () => k > 0 ? /* @__PURE__ */ u(t, {
|
|
46
|
+
size: "icon-sm",
|
|
47
|
+
className: b,
|
|
48
|
+
variant: "ghost",
|
|
49
|
+
onClick: () => g.setPageIndex(k - 1),
|
|
50
|
+
children: y.ellipsisText
|
|
51
|
+
}) : null, N = () => A < E ? /* @__PURE__ */ u(t, {
|
|
52
|
+
className: b,
|
|
53
|
+
variant: "ghost",
|
|
54
|
+
size: "icon-sm",
|
|
55
|
+
onClick: () => g.setPageIndex(A),
|
|
56
|
+
children: y.ellipsisText
|
|
57
|
+
}) : null;
|
|
58
|
+
return /* @__PURE__ */ d("div", {
|
|
59
|
+
"data-slot": "data-grid-pagination",
|
|
60
|
+
className: e("flex grow flex-col flex-wrap items-center justify-between gap-2.5 py-2.5 sm:flex-row sm:py-0", y?.className),
|
|
61
|
+
children: [/* @__PURE__ */ u("div", {
|
|
62
|
+
className: "order-2 flex flex-wrap items-center space-x-2.5 pb-2.5 sm:order-1 sm:pb-0",
|
|
63
|
+
children: v ? y?.sizesSkeleton : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
|
|
64
|
+
className: "text-muted-foreground text-sm",
|
|
65
|
+
children: y.rowsPerPageLabel
|
|
66
|
+
}), /* @__PURE__ */ d(r, {
|
|
67
|
+
value: `${C}`,
|
|
68
|
+
onValueChange: (e) => {
|
|
69
|
+
let t = Number(e);
|
|
70
|
+
g.setPageSize(t);
|
|
71
|
+
},
|
|
72
|
+
children: [/* @__PURE__ */ u(o, {
|
|
73
|
+
className: "w-14",
|
|
74
|
+
size: "sm",
|
|
75
|
+
children: /* @__PURE__ */ u(s, {})
|
|
76
|
+
}), /* @__PURE__ */ u(i, {
|
|
77
|
+
side: "top",
|
|
78
|
+
className: "min-w-18",
|
|
79
|
+
children: y?.sizes?.map((e) => /* @__PURE__ */ u(a, {
|
|
80
|
+
value: `${e}`,
|
|
81
|
+
children: e
|
|
82
|
+
}, e))
|
|
83
|
+
})]
|
|
84
|
+
})] })
|
|
85
|
+
}), /* @__PURE__ */ u("div", {
|
|
86
|
+
className: "order-1 flex flex-col items-center justify-center gap-2.5 pt-2.5 sm:order-2 sm:flex-row sm:justify-end sm:pt-0",
|
|
87
|
+
children: v ? y?.infoSkeleton : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
|
|
88
|
+
className: "text-muted-foreground text-sm order-2 text-nowrap sm:order-1",
|
|
89
|
+
children: D
|
|
90
|
+
}), E > 1 && /* @__PURE__ */ d("div", {
|
|
91
|
+
className: "order-1 flex items-center space-x-1 sm:order-2",
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ d(t, {
|
|
94
|
+
size: "icon-sm",
|
|
95
|
+
variant: "ghost",
|
|
96
|
+
className: x,
|
|
97
|
+
onClick: () => g.previousPage(),
|
|
98
|
+
disabled: !g.getCanPreviousPage(),
|
|
99
|
+
children: [/* @__PURE__ */ u("span", {
|
|
100
|
+
className: "sr-only",
|
|
101
|
+
children: y.previousPageLabel
|
|
102
|
+
}), /* @__PURE__ */ u(f, {
|
|
103
|
+
icon: p,
|
|
104
|
+
strokeWidth: 2,
|
|
105
|
+
className: "size-4"
|
|
106
|
+
})]
|
|
107
|
+
}),
|
|
108
|
+
M(),
|
|
109
|
+
j(),
|
|
110
|
+
N(),
|
|
111
|
+
/* @__PURE__ */ d(t, {
|
|
112
|
+
size: "icon-sm",
|
|
113
|
+
variant: "ghost",
|
|
114
|
+
className: x,
|
|
115
|
+
onClick: () => g.nextPage(),
|
|
116
|
+
disabled: !g.getCanNextPage(),
|
|
117
|
+
children: [/* @__PURE__ */ u("span", {
|
|
118
|
+
className: "sr-only",
|
|
119
|
+
children: y.nextPageLabel
|
|
120
|
+
}), /* @__PURE__ */ u(f, {
|
|
121
|
+
icon: m,
|
|
122
|
+
strokeWidth: 2,
|
|
123
|
+
className: "size-4"
|
|
124
|
+
})]
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
})] })
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { h as DataGridPagination };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { cn as e } from "../../../lib/utils.js";
|
|
2
|
+
import { useDataGrid as t } from "./data-grid.js";
|
|
3
|
+
import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
|
|
4
|
+
import { ScrollArea as o } from "radix-ui";
|
|
5
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/reui/data-grid/data-grid-scroll-area.tsx
|
|
7
|
+
var l = 24, u = 12, d = {
|
|
8
|
+
hasVerticalOverflow: !1,
|
|
9
|
+
headerHeight: 0,
|
|
10
|
+
horizontalScrollbarSize: 0,
|
|
11
|
+
thumbHeight: 0,
|
|
12
|
+
thumbTop: 0,
|
|
13
|
+
trackHeight: 0
|
|
14
|
+
};
|
|
15
|
+
function f(e, t, n) {
|
|
16
|
+
return Math.min(n, Math.max(t, e));
|
|
17
|
+
}
|
|
18
|
+
function p(e, t) {
|
|
19
|
+
return e.hasVerticalOverflow === t.hasVerticalOverflow && e.headerHeight === t.headerHeight && e.horizontalScrollbarSize === t.horizontalScrollbarSize && e.thumbHeight === t.thumbHeight && e.thumbTop === t.thumbTop && e.trackHeight === t.trackHeight;
|
|
20
|
+
}
|
|
21
|
+
function m(e, t) {
|
|
22
|
+
e.style.setProperty("--data-grid-scrollbar-header-height", `${t.headerHeight}px`), e.style.setProperty("--data-grid-scrollbar-thumb-height", `${t.thumbHeight}px`), e.style.setProperty("--data-grid-scrollbar-thumb-top", `${t.thumbTop}px`), e.style.setProperty("--data-grid-scrollbar-track-height", `${t.trackHeight}px`);
|
|
23
|
+
}
|
|
24
|
+
function h({ children: h, className: g, orientation: _ = "both", ...v }) {
|
|
25
|
+
let { props: y } = t(), b = i(null), x = i(null), S = i(null), C = i(d), w = i({
|
|
26
|
+
header: null,
|
|
27
|
+
horizontalScrollbar: null,
|
|
28
|
+
table: null,
|
|
29
|
+
tableViewport: null
|
|
30
|
+
}), T = _ !== "vertical", E = _ !== "horizontal", D = E && !!y.tableLayout?.headerSticky, [O, k] = a(!1), A = n(() => {
|
|
31
|
+
S.current = null, document.body.style.userSelect = "", document.body.style.webkitUserSelect = "";
|
|
32
|
+
}, []), j = n(() => {
|
|
33
|
+
let e = b.current;
|
|
34
|
+
e && !p(d, C.current) && (m(e, d), C.current = d), k((e) => e && !1);
|
|
35
|
+
}, []), M = n(() => {
|
|
36
|
+
let e = b.current, t = x.current;
|
|
37
|
+
if (!e || !t || !D) {
|
|
38
|
+
j();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let { header: n, horizontalScrollbar: r } = w.current, i = n?.getBoundingClientRect().height ?? 0, a = t.clientHeight, o = t.clientWidth, s = t.scrollHeight, c = t.scrollWidth, d = T && c > o + .5 ? r?.offsetHeight || u : 0, h = Math.max(0, a - i - d), g = Math.max(0, s - a), _;
|
|
42
|
+
if (h === 0 || g === 0) _ = {
|
|
43
|
+
hasVerticalOverflow: !1,
|
|
44
|
+
headerHeight: i,
|
|
45
|
+
horizontalScrollbarSize: d,
|
|
46
|
+
thumbHeight: h,
|
|
47
|
+
thumbTop: 0,
|
|
48
|
+
trackHeight: h
|
|
49
|
+
};
|
|
50
|
+
else {
|
|
51
|
+
let e = f(h * (h / Math.max(h, s - i)), l, h), n = Math.max(0, h - e);
|
|
52
|
+
_ = {
|
|
53
|
+
hasVerticalOverflow: !0,
|
|
54
|
+
headerHeight: i,
|
|
55
|
+
horizontalScrollbarSize: d,
|
|
56
|
+
thumbHeight: e,
|
|
57
|
+
thumbTop: n > 0 ? t.scrollTop / g * n : 0,
|
|
58
|
+
trackHeight: h
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
p(_, C.current) || (m(e, _), C.current = _), k((e) => e === _.hasVerticalOverflow ? e : _.hasVerticalOverflow);
|
|
62
|
+
}, [
|
|
63
|
+
j,
|
|
64
|
+
T,
|
|
65
|
+
D
|
|
66
|
+
]);
|
|
67
|
+
r(() => {
|
|
68
|
+
let e = b.current, t = x.current;
|
|
69
|
+
if (!e || !t) return;
|
|
70
|
+
if (!D) {
|
|
71
|
+
j();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
w.current = {
|
|
75
|
+
header: e.querySelector("[data-slot=\"data-grid-table\"] thead"),
|
|
76
|
+
horizontalScrollbar: e.querySelector("[data-slot=\"data-grid-scrollbar\"][data-orientation=\"horizontal\"]"),
|
|
77
|
+
table: e.querySelector("[data-slot=\"data-grid-table\"]"),
|
|
78
|
+
tableViewport: e.querySelector("[data-slot=\"data-grid-table-viewport\"]")
|
|
79
|
+
};
|
|
80
|
+
let n = 0, r = () => {
|
|
81
|
+
cancelAnimationFrame(n), n = window.requestAnimationFrame(M);
|
|
82
|
+
};
|
|
83
|
+
r(), t.addEventListener("scroll", r, { passive: !0 });
|
|
84
|
+
let i = typeof ResizeObserver > "u" ? null : new ResizeObserver(r);
|
|
85
|
+
return i?.observe(t), w.current.header && i?.observe(w.current.header), w.current.table && i?.observe(w.current.table), w.current.tableViewport && i?.observe(w.current.tableViewport), () => {
|
|
86
|
+
cancelAnimationFrame(n), i?.disconnect(), t.removeEventListener("scroll", r), A();
|
|
87
|
+
};
|
|
88
|
+
}, [
|
|
89
|
+
A,
|
|
90
|
+
j,
|
|
91
|
+
M,
|
|
92
|
+
D
|
|
93
|
+
]);
|
|
94
|
+
let N = (e) => {
|
|
95
|
+
let t = x.current, { thumbHeight: n, trackHeight: r } = C.current;
|
|
96
|
+
if (!t) return;
|
|
97
|
+
let i = Math.max(0, t.scrollHeight - t.clientHeight), a = Math.max(0, r - n);
|
|
98
|
+
if (i === 0 || a === 0) {
|
|
99
|
+
t.scrollTop = 0;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
t.scrollTop = f(e, 0, a) / a * i;
|
|
103
|
+
}, P = (e) => {
|
|
104
|
+
let t = x.current;
|
|
105
|
+
t && (e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture(e.pointerId), S.current = {
|
|
106
|
+
pointerId: e.pointerId,
|
|
107
|
+
startScrollTop: t.scrollTop,
|
|
108
|
+
startY: e.clientY
|
|
109
|
+
}, document.body.style.userSelect = "none", document.body.style.webkitUserSelect = "none");
|
|
110
|
+
}, F = (e) => {
|
|
111
|
+
let t = x.current, n = S.current, { thumbHeight: r, trackHeight: i } = C.current;
|
|
112
|
+
if (!t || !n || n.pointerId !== e.pointerId) return;
|
|
113
|
+
let a = Math.max(0, i - r), o = Math.max(0, t.scrollHeight - t.clientHeight);
|
|
114
|
+
if (a === 0 || o === 0) return;
|
|
115
|
+
let s = e.clientY - n.startY;
|
|
116
|
+
t.scrollTop = f(n.startScrollTop + s / a * o, 0, o);
|
|
117
|
+
}, I = (e) => {
|
|
118
|
+
S.current?.pointerId === e.pointerId && A();
|
|
119
|
+
}, L = (e) => {
|
|
120
|
+
let { thumbHeight: t } = C.current;
|
|
121
|
+
if (e.target !== e.currentTarget) return;
|
|
122
|
+
e.preventDefault(), e.stopPropagation();
|
|
123
|
+
let n = e.currentTarget.getBoundingClientRect();
|
|
124
|
+
N(e.clientY - n.top - t / 2);
|
|
125
|
+
};
|
|
126
|
+
return /* @__PURE__ */ c("div", {
|
|
127
|
+
ref: b,
|
|
128
|
+
className: "relative",
|
|
129
|
+
children: [/* @__PURE__ */ c(o.Root, {
|
|
130
|
+
"data-slot": "data-grid-scroll-area",
|
|
131
|
+
className: e("relative", g),
|
|
132
|
+
...v,
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ s(o.Viewport, {
|
|
135
|
+
ref: x,
|
|
136
|
+
"data-slot": "scroll-area-viewport",
|
|
137
|
+
className: "focus-visible:ring-ring/50 rounded-2xl size-full transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
|
|
138
|
+
children: /* @__PURE__ */ s("div", {
|
|
139
|
+
"data-slot": "scroll-area-content",
|
|
140
|
+
children: h
|
|
141
|
+
})
|
|
142
|
+
}),
|
|
143
|
+
T && /* @__PURE__ */ s(o.ScrollAreaScrollbar, {
|
|
144
|
+
"data-slot": "data-grid-scrollbar",
|
|
145
|
+
"data-orientation": "horizontal",
|
|
146
|
+
orientation: "horizontal",
|
|
147
|
+
className: "flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-s data-[orientation=vertical]:border-s-transparent",
|
|
148
|
+
children: /* @__PURE__ */ s(o.ScrollAreaThumb, {
|
|
149
|
+
"data-slot": "data-grid-thumb",
|
|
150
|
+
className: "bg-border rounded-full relative flex-1"
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
E && /* @__PURE__ */ s(o.ScrollAreaScrollbar, {
|
|
154
|
+
"data-slot": "data-grid-scrollbar",
|
|
155
|
+
"data-orientation": "vertical",
|
|
156
|
+
orientation: "vertical",
|
|
157
|
+
className: e("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-s data-[orientation=vertical]:border-s-transparent", D && "pointer-events-none opacity-0"),
|
|
158
|
+
children: /* @__PURE__ */ s(o.ScrollAreaThumb, {
|
|
159
|
+
"data-slot": "data-grid-thumb",
|
|
160
|
+
className: "bg-border rounded-full relative flex-1"
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
]
|
|
164
|
+
}), D && O && /* @__PURE__ */ s("div", {
|
|
165
|
+
"aria-hidden": "true",
|
|
166
|
+
className: "pointer-events-none absolute inset-e-0 top-(--data-grid-scrollbar-header-height) z-20 h-(--data-grid-scrollbar-track-height)",
|
|
167
|
+
children: /* @__PURE__ */ s("div", {
|
|
168
|
+
className: "pointer-events-auto relative h-full w-3 touch-none p-px",
|
|
169
|
+
onPointerDown: L,
|
|
170
|
+
children: /* @__PURE__ */ s("div", {
|
|
171
|
+
className: e("bg-border absolute end-px w-2", "top-(--data-grid-scrollbar-thumb-top) h-(--data-grid-scrollbar-thumb-height)", "rounded-full"),
|
|
172
|
+
onLostPointerCapture: A,
|
|
173
|
+
onPointerCancel: I,
|
|
174
|
+
onPointerDown: P,
|
|
175
|
+
onPointerMove: F,
|
|
176
|
+
onPointerUp: I
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
})]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
export { h as DataGridScrollArea };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../../lib/utils.js";
|
|
3
|
+
import { Button as t } from "../button.js";
|
|
4
|
+
import { useDataGrid as n } from "./data-grid.js";
|
|
5
|
+
import { DataGridTableBase as r, DataGridTableBody as i, DataGridTableBodyRow as a, DataGridTableBodyRowCell as o, DataGridTableBodyRowSkeleton as s, DataGridTableBodyRowSkeletonCell as c, DataGridTableEmpty as l, DataGridTableFoot as u, DataGridTableHead as d, DataGridTableHeadRow as f, DataGridTableHeadRowCell as p, DataGridTableHeadRowCellResize as m, DataGridTableRowSpacer as h, DataGridTableViewport as g } from "./data-grid-table.js";
|
|
6
|
+
import { createContext as _, useContext as v, useEffect as y, useId as b, useMemo as x, useRef as S, useState as C } from "react";
|
|
7
|
+
import { jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
8
|
+
import { HugeiconsIcon as E } from "@hugeicons/react";
|
|
9
|
+
import { DragDropHorizontalIcon as D } from "@hugeicons/core-free-icons";
|
|
10
|
+
import { flexRender as O } from "@tanstack/react-table";
|
|
11
|
+
import { DndContext as k, KeyboardSensor as A, MouseSensor as j, TouchSensor as M, closestCenter as N, useSensor as P, useSensors as F } from "@dnd-kit/core";
|
|
12
|
+
import { restrictToVerticalAxis as I } from "@dnd-kit/modifiers";
|
|
13
|
+
import { SortableContext as L, useSortable as R, verticalListSortingStrategy as z } from "@dnd-kit/sortable";
|
|
14
|
+
import { CSS as B } from "@dnd-kit/utilities";
|
|
15
|
+
//#region src/components/reui/data-grid/data-grid-table-dnd-rows.tsx
|
|
16
|
+
var V = _(null);
|
|
17
|
+
function H({ className: n }) {
|
|
18
|
+
let r = v(V);
|
|
19
|
+
return r ? /* @__PURE__ */ w(t, {
|
|
20
|
+
variant: "ghost",
|
|
21
|
+
size: "icon-sm",
|
|
22
|
+
className: e("size-7 cursor-grab opacity-70 hover:bg-transparent hover:opacity-100 active:cursor-grabbing", n),
|
|
23
|
+
...r.attributes,
|
|
24
|
+
...r.listeners,
|
|
25
|
+
children: /* @__PURE__ */ w(E, {
|
|
26
|
+
icon: D,
|
|
27
|
+
strokeWidth: 2
|
|
28
|
+
})
|
|
29
|
+
}) : /* @__PURE__ */ w(t, {
|
|
30
|
+
variant: "ghost",
|
|
31
|
+
size: "icon-sm",
|
|
32
|
+
className: e("size-7 cursor-grab opacity-70 hover:bg-transparent hover:opacity-100 active:cursor-grabbing", n),
|
|
33
|
+
disabled: !0,
|
|
34
|
+
children: /* @__PURE__ */ w(E, {
|
|
35
|
+
icon: D,
|
|
36
|
+
strokeWidth: 2
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function U({ row: e }) {
|
|
41
|
+
let { transform: t, transition: n, setNodeRef: r, isDragging: i, attributes: s, listeners: c } = R({ id: e.id }), l = {
|
|
42
|
+
transform: B.Transform.toString(t),
|
|
43
|
+
transition: n,
|
|
44
|
+
opacity: i ? .8 : 1,
|
|
45
|
+
zIndex: i ? 1 : 0,
|
|
46
|
+
position: "relative",
|
|
47
|
+
cursor: i ? "grabbing" : void 0
|
|
48
|
+
};
|
|
49
|
+
return /* @__PURE__ */ w(V.Provider, {
|
|
50
|
+
value: {
|
|
51
|
+
attributes: s,
|
|
52
|
+
listeners: c
|
|
53
|
+
},
|
|
54
|
+
children: /* @__PURE__ */ w(a, {
|
|
55
|
+
row: e,
|
|
56
|
+
dndRef: r,
|
|
57
|
+
dndStyle: l,
|
|
58
|
+
children: e.getVisibleCells().map((e, t) => /* @__PURE__ */ w(o, {
|
|
59
|
+
cell: e,
|
|
60
|
+
children: O(e.column.columnDef.cell, e.getContext())
|
|
61
|
+
}, t))
|
|
62
|
+
}, e.id)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function W({ handleDragEnd: e, dataIds: t, footerContent: a }) {
|
|
66
|
+
let { table: o, isLoading: _, props: v } = n(), E = o.getState().pagination, D = S(null), [R, B] = C(!1), V = F(P(j, {}), P(M, {}), P(A, {}));
|
|
67
|
+
y(() => {
|
|
68
|
+
if (!R) return;
|
|
69
|
+
let { body: e, documentElement: t } = document, n = e.style.cursor, r = t.style.cursor;
|
|
70
|
+
return e.style.cursor = "grabbing", t.style.cursor = "grabbing", () => {
|
|
71
|
+
e.style.cursor = n, t.style.cursor = r;
|
|
72
|
+
};
|
|
73
|
+
}, [R]);
|
|
74
|
+
let H = x(() => [I, ({ transform: e, draggingNodeRect: t }) => {
|
|
75
|
+
if (!D.current || !t) return e;
|
|
76
|
+
let n = D.current.getBoundingClientRect(), { x: r, y: i } = e, a = n.left - t.left, o = n.right - t.right, s = n.top - t.top, c = n.bottom - t.bottom;
|
|
77
|
+
return {
|
|
78
|
+
...e,
|
|
79
|
+
x: Math.max(a, Math.min(o, r)),
|
|
80
|
+
y: Math.max(s, Math.min(c, i))
|
|
81
|
+
};
|
|
82
|
+
}], []);
|
|
83
|
+
return /* @__PURE__ */ w(k, {
|
|
84
|
+
id: b(),
|
|
85
|
+
collisionDetection: N,
|
|
86
|
+
modifiers: H,
|
|
87
|
+
onDragCancel: () => B(!1),
|
|
88
|
+
onDragEnd: (t) => {
|
|
89
|
+
B(!1), e(t);
|
|
90
|
+
},
|
|
91
|
+
onDragStart: () => B(!0),
|
|
92
|
+
sensors: V,
|
|
93
|
+
children: /* @__PURE__ */ w(g, {
|
|
94
|
+
viewportRef: D,
|
|
95
|
+
className: R ? "relative cursor-grabbing [&_*]:cursor-grabbing!" : "relative",
|
|
96
|
+
children: /* @__PURE__ */ T(r, { children: [
|
|
97
|
+
/* @__PURE__ */ w(d, { children: o.getHeaderGroups().map((e, t) => /* @__PURE__ */ w(f, {
|
|
98
|
+
headerGroup: e,
|
|
99
|
+
children: e.headers.map((e, t) => {
|
|
100
|
+
let { column: n } = e;
|
|
101
|
+
return /* @__PURE__ */ T(p, {
|
|
102
|
+
header: e,
|
|
103
|
+
children: [e.isPlaceholder ? null : v.tableLayout?.columnsResizable && n.getCanResize() ? /* @__PURE__ */ w("div", {
|
|
104
|
+
className: "truncate",
|
|
105
|
+
children: O(e.column.columnDef.header, e.getContext())
|
|
106
|
+
}) : O(e.column.columnDef.header, e.getContext()), v.tableLayout?.columnsResizable && n.getCanResize() && /* @__PURE__ */ w(m, { header: e })]
|
|
107
|
+
}, t);
|
|
108
|
+
})
|
|
109
|
+
}, t)) }),
|
|
110
|
+
(v.tableLayout?.stripped || !v.tableLayout?.rowBorder) && /* @__PURE__ */ w(h, {}),
|
|
111
|
+
/* @__PURE__ */ w(i, { children: v.loadingMode === "skeleton" && _ && E?.pageSize ? Array.from({ length: E.pageSize }).map((e, t) => /* @__PURE__ */ w(s, { children: o.getVisibleFlatColumns().map((e, t) => /* @__PURE__ */ w(c, {
|
|
112
|
+
column: e,
|
|
113
|
+
children: e.columnDef.meta?.skeleton
|
|
114
|
+
}, t)) }, t)) : o.getRowModel().rows.length ? /* @__PURE__ */ w(L, {
|
|
115
|
+
items: t,
|
|
116
|
+
strategy: z,
|
|
117
|
+
children: o.getRowModel().rows.map((e) => /* @__PURE__ */ w(U, { row: e }, e.id))
|
|
118
|
+
}) : /* @__PURE__ */ w(l, {}) }),
|
|
119
|
+
a && /* @__PURE__ */ w(u, { children: a })
|
|
120
|
+
] })
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { H as DataGridTableDndRowHandle, W as DataGridTableDndRows };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Button as e } from "../button.js";
|
|
2
|
+
import { useDataGrid as t } from "./data-grid.js";
|
|
3
|
+
import { DataGridTableBase as n, DataGridTableBody as r, DataGridTableBodyRow as i, DataGridTableBodyRowCell as a, DataGridTableBodyRowExpandded as o, DataGridTableBodyRowSkeleton as s, DataGridTableBodyRowSkeletonCell as c, DataGridTableEmpty as l, DataGridTableFoot as u, DataGridTableHead as d, DataGridTableHeadRow as f, DataGridTableHeadRowCell as p, DataGridTableHeadRowCellResize as m, DataGridTableRowSpacer as h, DataGridTableViewport as g } from "./data-grid-table.js";
|
|
4
|
+
import { Fragment as _, useEffect as v, useId as y, useRef as b, useState as x } from "react";
|
|
5
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
6
|
+
import { HugeiconsIcon as w } from "@hugeicons/react";
|
|
7
|
+
import { DragDropVerticalIcon as T } from "@hugeicons/core-free-icons";
|
|
8
|
+
import { flexRender as E } from "@tanstack/react-table";
|
|
9
|
+
import { DndContext as D, KeyboardSensor as O, MouseSensor as k, TouchSensor as A, closestCenter as j, useSensor as M, useSensors as N } from "@dnd-kit/core";
|
|
10
|
+
import { SortableContext as P, horizontalListSortingStrategy as F, useSortable as I } from "@dnd-kit/sortable";
|
|
11
|
+
import { CSS as L } from "@dnd-kit/utilities";
|
|
12
|
+
//#region src/components/reui/data-grid/data-grid-table-dnd.tsx
|
|
13
|
+
function R({ header: n }) {
|
|
14
|
+
let { props: r } = t(), { column: i } = n, a = i.columnDef.enableColumnOrdering !== !1, { attributes: o, isDragging: s, listeners: c, setNodeRef: l, transform: u, transition: d } = I({ id: n.column.id });
|
|
15
|
+
return /* @__PURE__ */ S(p, {
|
|
16
|
+
header: n,
|
|
17
|
+
dndStyle: {
|
|
18
|
+
opacity: s ? .8 : 1,
|
|
19
|
+
position: "relative",
|
|
20
|
+
transform: L.Translate.toString(u),
|
|
21
|
+
transition: d,
|
|
22
|
+
cursor: s ? "grabbing" : void 0,
|
|
23
|
+
whiteSpace: "nowrap",
|
|
24
|
+
width: r.tableLayout?.columnsResizable ? `calc(var(--header-${n.id}-size) * 1px)` : n.column.getSize(),
|
|
25
|
+
zIndex: s ? 1 : 0
|
|
26
|
+
},
|
|
27
|
+
dndRef: l,
|
|
28
|
+
children: /* @__PURE__ */ C("div", {
|
|
29
|
+
className: "flex items-center justify-start gap-0.5",
|
|
30
|
+
children: [
|
|
31
|
+
a && /* @__PURE__ */ S(e, {
|
|
32
|
+
size: "icon-sm",
|
|
33
|
+
variant: "ghost",
|
|
34
|
+
className: `-ms-2 size-6 ${s ? "cursor-grabbing" : "cursor-grab active:cursor-grabbing"}`,
|
|
35
|
+
...o,
|
|
36
|
+
...c,
|
|
37
|
+
"aria-label": "Drag to reorder",
|
|
38
|
+
children: /* @__PURE__ */ S(w, {
|
|
39
|
+
icon: T,
|
|
40
|
+
strokeWidth: 2,
|
|
41
|
+
className: "opacity-60 hover:opacity-100",
|
|
42
|
+
"aria-hidden": "true"
|
|
43
|
+
})
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ S("span", {
|
|
46
|
+
className: "grow truncate",
|
|
47
|
+
children: n.isPlaceholder ? null : E(n.column.columnDef.header, n.getContext())
|
|
48
|
+
}),
|
|
49
|
+
r.tableLayout?.columnsResizable && i.getCanResize() && /* @__PURE__ */ S(m, { header: n })
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function z({ cell: e }) {
|
|
55
|
+
let { props: n } = t(), { isDragging: r, setNodeRef: i, transform: o, transition: s } = I({ id: e.column.id });
|
|
56
|
+
return /* @__PURE__ */ S(a, {
|
|
57
|
+
cell: e,
|
|
58
|
+
dndStyle: {
|
|
59
|
+
opacity: r ? .8 : 1,
|
|
60
|
+
position: "relative",
|
|
61
|
+
transform: L.Translate.toString(o),
|
|
62
|
+
transition: s,
|
|
63
|
+
cursor: r ? "grabbing" : void 0,
|
|
64
|
+
width: n.tableLayout?.columnsResizable ? `calc(var(--col-${e.column.id}-size) * 1px)` : e.column.getSize(),
|
|
65
|
+
zIndex: r ? 1 : 0
|
|
66
|
+
},
|
|
67
|
+
dndRef: i,
|
|
68
|
+
children: E(e.column.columnDef.cell, e.getContext())
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function B({ handleDragEnd: e, footerContent: a }) {
|
|
72
|
+
let { table: p, isLoading: m, props: w } = t(), T = p.getState().pagination, E = b(null), [I, L] = x(!1), B = N(M(k, {}), M(A, {}), M(O, {}));
|
|
73
|
+
return v(() => {
|
|
74
|
+
if (!I) return;
|
|
75
|
+
let { body: e, documentElement: t } = document, n = e.style.cursor, r = t.style.cursor;
|
|
76
|
+
return e.style.cursor = "grabbing", t.style.cursor = "grabbing", () => {
|
|
77
|
+
e.style.cursor = n, t.style.cursor = r;
|
|
78
|
+
};
|
|
79
|
+
}, [I]), /* @__PURE__ */ S(D, {
|
|
80
|
+
collisionDetection: j,
|
|
81
|
+
id: y(),
|
|
82
|
+
modifiers: [({ draggingNodeRect: e, transform: t }) => {
|
|
83
|
+
if (!e || !E.current) return {
|
|
84
|
+
...t,
|
|
85
|
+
y: 0
|
|
86
|
+
};
|
|
87
|
+
let n = E.current.getBoundingClientRect(), r = n.left - e.left - 0, i = n.right - e.left - e.width + 0;
|
|
88
|
+
return {
|
|
89
|
+
...t,
|
|
90
|
+
x: Math.min(Math.max(t.x, r), i),
|
|
91
|
+
y: 0
|
|
92
|
+
};
|
|
93
|
+
}],
|
|
94
|
+
onDragCancel: () => L(!1),
|
|
95
|
+
onDragEnd: (t) => {
|
|
96
|
+
L(!1), e(t);
|
|
97
|
+
},
|
|
98
|
+
onDragStart: () => L(!0),
|
|
99
|
+
sensors: B,
|
|
100
|
+
children: /* @__PURE__ */ S(g, {
|
|
101
|
+
viewportRef: E,
|
|
102
|
+
className: I ? "relative cursor-grabbing [&_*]:cursor-grabbing!" : "relative",
|
|
103
|
+
children: /* @__PURE__ */ C(n, { children: [
|
|
104
|
+
/* @__PURE__ */ S(d, { children: p.getHeaderGroups().map((e, t) => /* @__PURE__ */ S(f, {
|
|
105
|
+
headerGroup: e,
|
|
106
|
+
children: /* @__PURE__ */ S(P, {
|
|
107
|
+
items: p.getState().columnOrder,
|
|
108
|
+
strategy: F,
|
|
109
|
+
children: e.headers.map((e) => /* @__PURE__ */ S(R, { header: e }, e.id))
|
|
110
|
+
})
|
|
111
|
+
}, t)) }),
|
|
112
|
+
(w.tableLayout?.stripped || !w.tableLayout?.rowBorder) && /* @__PURE__ */ S(h, {}),
|
|
113
|
+
/* @__PURE__ */ S(r, { children: w.loadingMode === "skeleton" && m && T?.pageSize ? Array.from({ length: T.pageSize }).map((e, t) => /* @__PURE__ */ S(s, { children: p.getVisibleFlatColumns().map((e, t) => /* @__PURE__ */ S(c, {
|
|
114
|
+
column: e,
|
|
115
|
+
children: e.columnDef.meta?.skeleton
|
|
116
|
+
}, t)) }, t)) : p.getRowModel().rows.length ? p.getRowModel().rows.map((e) => /* @__PURE__ */ C(_, { children: [/* @__PURE__ */ S(i, {
|
|
117
|
+
row: e,
|
|
118
|
+
children: e.getVisibleCells().map((e) => /* @__PURE__ */ S(P, {
|
|
119
|
+
items: p.getState().columnOrder,
|
|
120
|
+
strategy: F,
|
|
121
|
+
children: /* @__PURE__ */ S(z, { cell: e })
|
|
122
|
+
}, e.id))
|
|
123
|
+
}), e.getIsExpanded() && /* @__PURE__ */ S(o, { row: e })] }, e.id)) : /* @__PURE__ */ S(l, {}) }),
|
|
124
|
+
a && /* @__PURE__ */ S(u, { children: a })
|
|
125
|
+
] })
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { B as DataGridTableDnd };
|