@upbound/monarch-blocks 0.14.0 → 0.16.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/dist/chat-interface.js.map +1 -1
- package/dist/data-table.d.ts +10 -3
- package/dist/data-table.js +175 -117
- package/dist/data-table.js.map +1 -1
- package/dist/{empty-view-DQt8-Ho8.d.ts → empty-view-DHTvKsil.d.ts} +3 -0
- package/dist/graph.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +227 -163
- package/dist/index.js.map +1 -1
- package/dist/page-header.js +7 -1
- package/dist/page-header.js.map +1 -1
- package/dist/relative-time.d.ts +2 -2
- package/dist/relative-time.js +4 -4
- package/dist/relative-time.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2186,7 +2186,7 @@ function formatRelativeDefault(date, locale) {
|
|
|
2186
2186
|
if (hrs2 < 24) return `in ${hrs2} hour${hrs2 === 1 ? "" : "s"}`;
|
|
2187
2187
|
if (days2 < 7) return `in ${days2} day${days2 === 1 ? "" : "s"}`;
|
|
2188
2188
|
if (days2 < 30) return `in ${Math.floor(days2 / 7)} week${Math.floor(days2 / 7) === 1 ? "" : "s"}`;
|
|
2189
|
-
return
|
|
2189
|
+
return `${date.toLocaleDateString(locale, __spreadValues({
|
|
2190
2190
|
month: "short",
|
|
2191
2191
|
day: "numeric"
|
|
2192
2192
|
}, date.getFullYear() !== now.getFullYear() ? { year: "numeric" } : {}))}`;
|
|
@@ -2202,7 +2202,7 @@ function formatRelativeDefault(date, locale) {
|
|
|
2202
2202
|
if (days < 7) return `${days} days ago`;
|
|
2203
2203
|
if (days < 14) return "last week";
|
|
2204
2204
|
if (days < 30) return `${Math.floor(days / 7)} weeks ago`;
|
|
2205
|
-
return
|
|
2205
|
+
return `${date.toLocaleDateString(locale, __spreadValues({
|
|
2206
2206
|
month: "short",
|
|
2207
2207
|
day: "numeric"
|
|
2208
2208
|
}, date.getFullYear() !== now.getFullYear() ? { year: "numeric" } : {}))}`;
|
|
@@ -2220,7 +2220,7 @@ function formatRelativeCompact(date, locale) {
|
|
|
2220
2220
|
if (hrs2 < 24) return `in ${hrs2}h`;
|
|
2221
2221
|
if (days2 < 7) return `in ${days2}d`;
|
|
2222
2222
|
if (days2 < 30) return `in ${Math.floor(days2 / 7)}w`;
|
|
2223
|
-
return
|
|
2223
|
+
return `${date.toLocaleDateString(locale, __spreadValues({
|
|
2224
2224
|
month: "short",
|
|
2225
2225
|
day: "numeric"
|
|
2226
2226
|
}, date.getFullYear() !== now.getFullYear() ? { year: "numeric" } : {}))}`;
|
|
@@ -2234,7 +2234,7 @@ function formatRelativeCompact(date, locale) {
|
|
|
2234
2234
|
if (hrs < 24) return `${hrs}h ago`;
|
|
2235
2235
|
if (days < 7) return `${days}d ago`;
|
|
2236
2236
|
if (days < 30) return `${Math.floor(days / 7)}w ago`;
|
|
2237
|
-
return
|
|
2237
|
+
return `${date.toLocaleDateString(locale, __spreadValues({
|
|
2238
2238
|
month: "short",
|
|
2239
2239
|
day: "numeric"
|
|
2240
2240
|
}, date.getFullYear() !== now.getFullYear() ? { year: "numeric" } : {}))}`;
|
|
@@ -3851,7 +3851,7 @@ function TimestampCell({ timestamp }) {
|
|
|
3851
3851
|
}
|
|
3852
3852
|
|
|
3853
3853
|
// src/data-table/data-table.tsx
|
|
3854
|
-
import * as
|
|
3854
|
+
import * as React13 from "react";
|
|
3855
3855
|
import {
|
|
3856
3856
|
useTable
|
|
3857
3857
|
} from "@tanstack/react-table";
|
|
@@ -4632,6 +4632,7 @@ function FilterToggle({ pressed, onPressedChange, count }) {
|
|
|
4632
4632
|
}
|
|
4633
4633
|
|
|
4634
4634
|
// src/data-table/pagination.tsx
|
|
4635
|
+
import * as React9 from "react";
|
|
4635
4636
|
import { Button as Button7 } from "@upbound/monarch-core";
|
|
4636
4637
|
import { Icon as Icon9 } from "@upbound/monarch-core";
|
|
4637
4638
|
import { Label as Label2 } from "@upbound/monarch-core";
|
|
@@ -4643,6 +4644,7 @@ import {
|
|
|
4643
4644
|
PaginationLink
|
|
4644
4645
|
} from "@upbound/monarch-core";
|
|
4645
4646
|
import { Select as Select2, SelectContent as SelectContent2, SelectGroup as SelectGroup2, SelectItem as SelectItem2, SelectTrigger as SelectTrigger2, SelectValue as SelectValue2 } from "@upbound/monarch-core";
|
|
4647
|
+
import { Spinner } from "@upbound/monarch-core";
|
|
4646
4648
|
import { Tooltip as Tooltip6, TooltipContent as TooltipContent5, TooltipTrigger as TooltipTrigger5 } from "@upbound/monarch-core";
|
|
4647
4649
|
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4648
4650
|
var DEFAULT_PAGINATION_CONFIG = {
|
|
@@ -4653,6 +4655,12 @@ var DEFAULT_PAGINATION_CONFIG = {
|
|
|
4653
4655
|
pageSizeOptions: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
|
|
4654
4656
|
};
|
|
4655
4657
|
var PAGE_SIZE_SELECT_ID = "table-page-size-select";
|
|
4658
|
+
var PAGE_ARROWS = {
|
|
4659
|
+
first: { label: "Go to first page", icon: "chevrons-left" },
|
|
4660
|
+
previous: { label: "Go to previous page", icon: "chevron-left" },
|
|
4661
|
+
next: { label: "Go to next page", icon: "chevron-right" },
|
|
4662
|
+
last: { label: "Go to last page", icon: "chevrons-right" }
|
|
4663
|
+
};
|
|
4656
4664
|
function getPageSizeOptions(pageSizeOptions) {
|
|
4657
4665
|
return Array.from(new Set(pageSizeOptions)).filter((option) => option > 0).sort((a, b) => a - b);
|
|
4658
4666
|
}
|
|
@@ -4673,9 +4681,11 @@ function DataTablePagination({
|
|
|
4673
4681
|
rowCount,
|
|
4674
4682
|
rowCountRelation = "eq",
|
|
4675
4683
|
paginationConfig = true,
|
|
4684
|
+
loading = false,
|
|
4676
4685
|
onPageChange,
|
|
4677
4686
|
onPageSizeChange
|
|
4678
4687
|
}) {
|
|
4688
|
+
const [requestedControl, setRequestedControl] = React9.useState(null);
|
|
4679
4689
|
const isRowCountExact = rowCountRelation === "eq";
|
|
4680
4690
|
const resolved = typeof paginationConfig === "object" ? __spreadValues(__spreadValues({}, DEFAULT_PAGINATION_CONFIG), paginationConfig) : DEFAULT_PAGINATION_CONFIG;
|
|
4681
4691
|
const { normalizedPageSizeOptions, effectivePageSize } = normalizePageSizeOptions(pageSize, resolved.pageSizeOptions);
|
|
@@ -4683,6 +4693,33 @@ function DataTablePagination({
|
|
|
4683
4693
|
const currentPage = pageIndex + 1;
|
|
4684
4694
|
const mounted = useMounted();
|
|
4685
4695
|
const locale = mounted ? void 0 : "en-US";
|
|
4696
|
+
const isLoadingControl = (control) => loading && requestedControl === control;
|
|
4697
|
+
const goToPage = (page, control) => {
|
|
4698
|
+
if (loading) return;
|
|
4699
|
+
setRequestedControl(control);
|
|
4700
|
+
onPageChange(page);
|
|
4701
|
+
};
|
|
4702
|
+
const changePageSize = (nextPageSize) => {
|
|
4703
|
+
setRequestedControl(null);
|
|
4704
|
+
onPageSizeChange(nextPageSize);
|
|
4705
|
+
};
|
|
4706
|
+
const renderArrow = (arrow, page, disabled) => {
|
|
4707
|
+
const { label, icon } = PAGE_ARROWS[arrow];
|
|
4708
|
+
const isRequested = isLoadingControl(arrow);
|
|
4709
|
+
return /* @__PURE__ */ jsx13(PaginationItem, { children: /* @__PURE__ */ jsx13(
|
|
4710
|
+
Button7,
|
|
4711
|
+
{
|
|
4712
|
+
variant: "outline",
|
|
4713
|
+
size: "icon",
|
|
4714
|
+
"aria-label": label,
|
|
4715
|
+
"aria-busy": isRequested || void 0,
|
|
4716
|
+
"aria-disabled": isRequested || void 0,
|
|
4717
|
+
disabled: !isRequested && (disabled || loading),
|
|
4718
|
+
onClick: () => goToPage(page, arrow),
|
|
4719
|
+
children: isRequested ? /* @__PURE__ */ jsx13(Spinner, {}) : /* @__PURE__ */ jsx13(Icon9, { name: icon, className: "cn-rtl-flip" })
|
|
4720
|
+
}
|
|
4721
|
+
) });
|
|
4722
|
+
};
|
|
4686
4723
|
return /* @__PURE__ */ jsxs12("div", { "data-testid": "table-footer", className: "flex items-center justify-between px-2 pt-4", children: [
|
|
4687
4724
|
resolved.summary ? /* @__PURE__ */ jsxs12("div", { className: "text-body text-muted-foreground", "data-testid": "table-pagination-summary", children: [
|
|
4688
4725
|
"Showing ",
|
|
@@ -4706,34 +4743,22 @@ function DataTablePagination({
|
|
|
4706
4743
|
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-4", children: [
|
|
4707
4744
|
resolved.pageSizeSelector && /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
|
|
4708
4745
|
/* @__PURE__ */ jsx13(Label2, { htmlFor: PAGE_SIZE_SELECT_ID, className: "font-semibold", children: "Rows per page" }),
|
|
4709
|
-
/* @__PURE__ */ jsxs12(
|
|
4710
|
-
|
|
4711
|
-
/* @__PURE__ */ jsx13(SelectContent2, { align: "end", children: /* @__PURE__ */ jsx13(SelectGroup2, { children: normalizedPageSizeOptions.map((option) => /* @__PURE__ */ jsx13(SelectItem2, { value: String(option), children: option }, option)) }) })
|
|
4712
|
-
] })
|
|
4713
|
-
] }),
|
|
4714
|
-
pageCount > 1 && (resolved.arrows || resolved.numbers) && /* @__PURE__ */ jsx13(Pagination, { className: "mx-0 w-auto justify-end", children: /* @__PURE__ */ jsxs12(PaginationContent, { children: [
|
|
4715
|
-
resolved.arrows && /* @__PURE__ */ jsx13(PaginationItem, { children: /* @__PURE__ */ jsx13(
|
|
4716
|
-
Button7,
|
|
4717
|
-
{
|
|
4718
|
-
variant: "outline",
|
|
4719
|
-
size: "icon",
|
|
4720
|
-
"aria-label": "Go to first page",
|
|
4721
|
-
disabled: currentPage <= 1,
|
|
4722
|
-
onClick: () => onPageChange(1),
|
|
4723
|
-
children: /* @__PURE__ */ jsx13(Icon9, { name: "chevrons-left", className: "cn-rtl-flip" })
|
|
4724
|
-
}
|
|
4725
|
-
) }),
|
|
4726
|
-
resolved.arrows && /* @__PURE__ */ jsx13(PaginationItem, { children: /* @__PURE__ */ jsx13(
|
|
4727
|
-
Button7,
|
|
4746
|
+
/* @__PURE__ */ jsxs12(
|
|
4747
|
+
Select2,
|
|
4728
4748
|
{
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4749
|
+
value: String(effectivePageSize),
|
|
4750
|
+
onValueChange: (value) => changePageSize(Number(value)),
|
|
4751
|
+
disabled: loading,
|
|
4752
|
+
children: [
|
|
4753
|
+
/* @__PURE__ */ jsx13(SelectTrigger2, { id: PAGE_SIZE_SELECT_ID, size: "sm", className: "w-18", "data-testid": "table-page-size-select", children: /* @__PURE__ */ jsx13(SelectValue2, {}) }),
|
|
4754
|
+
/* @__PURE__ */ jsx13(SelectContent2, { align: "end", children: /* @__PURE__ */ jsx13(SelectGroup2, { children: normalizedPageSizeOptions.map((option) => /* @__PURE__ */ jsx13(SelectItem2, { value: String(option), children: option }, option)) }) })
|
|
4755
|
+
]
|
|
4735
4756
|
}
|
|
4736
|
-
)
|
|
4757
|
+
)
|
|
4758
|
+
] }),
|
|
4759
|
+
pageCount > 1 && (resolved.arrows || resolved.numbers) && /* @__PURE__ */ jsx13(Pagination, { className: "mx-0 w-auto justify-end", children: /* @__PURE__ */ jsxs12(PaginationContent, { children: [
|
|
4760
|
+
resolved.arrows && renderArrow("first", 1, currentPage <= 1),
|
|
4761
|
+
resolved.arrows && renderArrow("previous", currentPage - 1, currentPage <= 1),
|
|
4737
4762
|
resolved.numbers && visiblePages.map(
|
|
4738
4763
|
(page, index) => page === void 0 ? /* @__PURE__ */ jsx13(PaginationItem, { children: /* @__PURE__ */ jsx13(PaginationEllipsis, {}) }, `ellipsis-${index}`) : /* @__PURE__ */ jsx13(PaginationItem, { children: /* @__PURE__ */ jsx13(
|
|
4739
4764
|
PaginationLink,
|
|
@@ -4741,43 +4766,27 @@ function DataTablePagination({
|
|
|
4741
4766
|
href: "#",
|
|
4742
4767
|
size: "icon",
|
|
4743
4768
|
isActive: page === currentPage,
|
|
4769
|
+
"aria-label": `Go to page ${page}`,
|
|
4770
|
+
"aria-busy": isLoadingControl(page) || void 0,
|
|
4771
|
+
"aria-disabled": loading || void 0,
|
|
4772
|
+
className: cn(loading && !isLoadingControl(page) && "opacity-50"),
|
|
4744
4773
|
onClick: (e) => {
|
|
4745
4774
|
e.preventDefault();
|
|
4746
|
-
|
|
4775
|
+
goToPage(page, page);
|
|
4747
4776
|
},
|
|
4748
|
-
children: page
|
|
4777
|
+
children: isLoadingControl(page) ? /* @__PURE__ */ jsx13(Spinner, {}) : page
|
|
4749
4778
|
}
|
|
4750
4779
|
) }, page)
|
|
4751
4780
|
),
|
|
4752
|
-
resolved.arrows &&
|
|
4753
|
-
|
|
4754
|
-
{
|
|
4755
|
-
variant: "outline",
|
|
4756
|
-
size: "icon",
|
|
4757
|
-
"aria-label": "Go to next page",
|
|
4758
|
-
disabled: currentPage >= pageCount,
|
|
4759
|
-
onClick: () => onPageChange(currentPage + 1),
|
|
4760
|
-
children: /* @__PURE__ */ jsx13(Icon9, { name: "chevron-right", className: "cn-rtl-flip" })
|
|
4761
|
-
}
|
|
4762
|
-
) }),
|
|
4763
|
-
resolved.arrows && /* @__PURE__ */ jsx13(PaginationItem, { children: /* @__PURE__ */ jsx13(
|
|
4764
|
-
Button7,
|
|
4765
|
-
{
|
|
4766
|
-
variant: "outline",
|
|
4767
|
-
size: "icon",
|
|
4768
|
-
"aria-label": "Go to last page",
|
|
4769
|
-
disabled: currentPage >= pageCount,
|
|
4770
|
-
onClick: () => onPageChange(pageCount),
|
|
4771
|
-
children: /* @__PURE__ */ jsx13(Icon9, { name: "chevrons-right", className: "cn-rtl-flip" })
|
|
4772
|
-
}
|
|
4773
|
-
) })
|
|
4781
|
+
resolved.arrows && renderArrow("next", currentPage + 1, currentPage >= pageCount),
|
|
4782
|
+
resolved.arrows && renderArrow("last", pageCount, currentPage >= pageCount)
|
|
4774
4783
|
] }) })
|
|
4775
4784
|
] })
|
|
4776
4785
|
] });
|
|
4777
4786
|
}
|
|
4778
4787
|
|
|
4779
4788
|
// src/data-table/table-primitives.tsx
|
|
4780
|
-
import * as
|
|
4789
|
+
import * as React10 from "react";
|
|
4781
4790
|
import { flexRender as flexRender2 } from "@tanstack/react-table";
|
|
4782
4791
|
import { ContextMenu, ContextMenuTrigger } from "@upbound/monarch-core";
|
|
4783
4792
|
import {
|
|
@@ -4922,6 +4931,34 @@ function ColumnActionsMenuItems({
|
|
|
4922
4931
|
] })
|
|
4923
4932
|
] });
|
|
4924
4933
|
}
|
|
4934
|
+
function HeaderTooltip({ content, children }) {
|
|
4935
|
+
if (!content) return children;
|
|
4936
|
+
return /* @__PURE__ */ jsxs13(Tooltip7, { children: [
|
|
4937
|
+
/* @__PURE__ */ jsx14(TooltipTrigger6, { asChild: true, children }),
|
|
4938
|
+
/* @__PURE__ */ jsx14(TooltipContent6, { children: content })
|
|
4939
|
+
] });
|
|
4940
|
+
}
|
|
4941
|
+
function ColumnActionsMenu({
|
|
4942
|
+
header,
|
|
4943
|
+
tooltip,
|
|
4944
|
+
onAutosizeAll,
|
|
4945
|
+
onAutosizeColumn,
|
|
4946
|
+
layout,
|
|
4947
|
+
children
|
|
4948
|
+
}) {
|
|
4949
|
+
return /* @__PURE__ */ jsxs13(DropdownMenu4, { children: [
|
|
4950
|
+
/* @__PURE__ */ jsx14(HeaderTooltip, { content: tooltip, children: /* @__PURE__ */ jsx14(DropdownMenuTrigger4, { asChild: true, children }) }),
|
|
4951
|
+
/* @__PURE__ */ jsx14(
|
|
4952
|
+
ColumnActionsMenuItems,
|
|
4953
|
+
{
|
|
4954
|
+
header,
|
|
4955
|
+
onAutosizeAll,
|
|
4956
|
+
onAutosizeColumn,
|
|
4957
|
+
layout
|
|
4958
|
+
}
|
|
4959
|
+
)
|
|
4960
|
+
] });
|
|
4961
|
+
}
|
|
4925
4962
|
function HeaderCellContent({
|
|
4926
4963
|
header,
|
|
4927
4964
|
canResize,
|
|
@@ -4933,8 +4970,10 @@ function HeaderCellContent({
|
|
|
4933
4970
|
onResetColumnSize,
|
|
4934
4971
|
layout = "auto"
|
|
4935
4972
|
}) {
|
|
4973
|
+
var _a;
|
|
4936
4974
|
const resizeHandler = header.getResizeHandler();
|
|
4937
4975
|
const headerTitle = typeof header.column.columnDef.header === "string" ? header.column.columnDef.header : "";
|
|
4976
|
+
const headerTooltip = (_a = header.column.columnDef.meta) == null ? void 0 : _a.headerTooltip;
|
|
4938
4977
|
const sorted = header.column.getIsSorted();
|
|
4939
4978
|
const labelButton = /* @__PURE__ */ jsxs13(
|
|
4940
4979
|
"button",
|
|
@@ -4960,23 +4999,19 @@ function HeaderCellContent({
|
|
|
4960
4999
|
]
|
|
4961
5000
|
}
|
|
4962
5001
|
);
|
|
4963
|
-
const label = shouldShowActionsMenu ? /* @__PURE__ */
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
] }) : labelButton;
|
|
5002
|
+
const label = shouldShowActionsMenu ? /* @__PURE__ */ jsx14(
|
|
5003
|
+
ColumnActionsMenu,
|
|
5004
|
+
{
|
|
5005
|
+
header,
|
|
5006
|
+
tooltip: headerTooltip,
|
|
5007
|
+
onAutosizeAll,
|
|
5008
|
+
onAutosizeColumn,
|
|
5009
|
+
layout,
|
|
5010
|
+
children: labelButton
|
|
5011
|
+
}
|
|
5012
|
+
) : /* @__PURE__ */ jsx14(HeaderTooltip, { content: headerTooltip, children: labelButton });
|
|
4975
5013
|
return /* @__PURE__ */ jsxs13(Fragment7, { children: [
|
|
4976
|
-
/* @__PURE__ */ jsx14("div", { className: "flex min-w-0 flex-1 items-center gap-1", children: /* @__PURE__ */ jsx14("div", { className: "min-w-0 flex-1", children: !isActionColumn && !isGroupedColumn &&
|
|
4977
|
-
/* @__PURE__ */ jsx14(TooltipTrigger6, { asChild: true, children: label }),
|
|
4978
|
-
/* @__PURE__ */ jsx14(TooltipContent6, { children: headerTitle })
|
|
4979
|
-
] }) : label) }) }),
|
|
5014
|
+
/* @__PURE__ */ jsx14("div", { className: "flex min-w-0 flex-1 items-center gap-1", children: /* @__PURE__ */ jsx14("div", { className: "min-w-0 flex-1", children: !isActionColumn && !isGroupedColumn && label }) }),
|
|
4980
5015
|
canResize && /* @__PURE__ */ jsx14(
|
|
4981
5016
|
"button",
|
|
4982
5017
|
{
|
|
@@ -5082,7 +5117,7 @@ function DataTableHeader({
|
|
|
5082
5117
|
}
|
|
5083
5118
|
return /* @__PURE__ */ jsx14(BaseTableHeader, { children: headerGroups.map((headerGroup, headerGroupIndex) => /* @__PURE__ */ jsx14(BaseTableRow, { children: renderHeaders(headerGroup, headerGroupIndex) }, headerGroup.id)) });
|
|
5084
5119
|
}
|
|
5085
|
-
var DataTableRow =
|
|
5120
|
+
var DataTableRow = React10.forwardRef(
|
|
5086
5121
|
(_a, ref) => {
|
|
5087
5122
|
var _b = _a, { hoverable, disabled, className, layout = "auto" } = _b, props = __objRest(_b, ["hoverable", "disabled", "className", "layout"]);
|
|
5088
5123
|
const classes = cn(
|
|
@@ -5185,6 +5220,10 @@ function DataTableGroupRow({
|
|
|
5185
5220
|
}
|
|
5186
5221
|
return /* @__PURE__ */ jsx14(BaseTableRow, { className: "bg-muted/50 hover:bg-muted/50", children: /* @__PURE__ */ jsx14(BaseTableCell, { colSpan, className: "text-foreground border-b font-semibold whitespace-nowrap", children: groupLabel }) });
|
|
5187
5222
|
}
|
|
5223
|
+
function DefaultSkeletonCell({ actions }) {
|
|
5224
|
+
if (actions) return /* @__PURE__ */ jsx14(Skeleton, { className: "ml-auto size-6" });
|
|
5225
|
+
return /* @__PURE__ */ jsx14("div", { className: "flex h-lh w-full items-center", children: /* @__PURE__ */ jsx14(Skeleton, { className: "h-4 w-full" }) });
|
|
5226
|
+
}
|
|
5188
5227
|
function DataTableSkeletonBody({
|
|
5189
5228
|
rowCount = 10,
|
|
5190
5229
|
columns,
|
|
@@ -5201,14 +5240,14 @@ function DataTableSkeletonBody({
|
|
|
5201
5240
|
role: "cell",
|
|
5202
5241
|
className: cn(TABLE_CELL_CLASSES, "flex items-center overflow-hidden"),
|
|
5203
5242
|
style: { minWidth: col.minSize },
|
|
5204
|
-
children: (_a = renderCell == null ? void 0 : renderCell(col.id)) != null ? _a : /* @__PURE__ */ jsx14(
|
|
5243
|
+
children: (_a = renderCell == null ? void 0 : renderCell(col.id)) != null ? _a : /* @__PURE__ */ jsx14(DefaultSkeletonCell, { actions: col.actions })
|
|
5205
5244
|
},
|
|
5206
5245
|
`skeleton-col-${col.id}-row-${rowIndex}`
|
|
5207
5246
|
) : /* @__PURE__ */ jsx14(
|
|
5208
5247
|
BaseTableCell,
|
|
5209
5248
|
{
|
|
5210
5249
|
style: { width: col.size, minWidth: col.minSize, maxWidth: col.maxSize },
|
|
5211
|
-
children: (_b = renderCell == null ? void 0 : renderCell(col.id)) != null ? _b : /* @__PURE__ */ jsx14(
|
|
5250
|
+
children: (_b = renderCell == null ? void 0 : renderCell(col.id)) != null ? _b : /* @__PURE__ */ jsx14(DefaultSkeletonCell, { actions: col.actions })
|
|
5212
5251
|
},
|
|
5213
5252
|
`skeleton-col-${col.id}-row-${rowIndex}`
|
|
5214
5253
|
);
|
|
@@ -5249,12 +5288,16 @@ function DataTableBody({
|
|
|
5249
5288
|
const visibleColumns = columns.filter((column) => !isFilterOnlyColumn(column));
|
|
5250
5289
|
const colSpan = visibleColumns.length;
|
|
5251
5290
|
if (tableState === "loading") {
|
|
5252
|
-
const skeletonColumns = visibleColumns.map((c) =>
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5291
|
+
const skeletonColumns = visibleColumns.map((c) => {
|
|
5292
|
+
var _a;
|
|
5293
|
+
return {
|
|
5294
|
+
id: c.id,
|
|
5295
|
+
size: c.columnDef.size,
|
|
5296
|
+
minSize: c.columnDef.minSize,
|
|
5297
|
+
maxSize: c.columnDef.maxSize,
|
|
5298
|
+
actions: !!((_a = c.columnDef.meta) == null ? void 0 : _a.actions)
|
|
5299
|
+
};
|
|
5300
|
+
});
|
|
5258
5301
|
return /* @__PURE__ */ jsx14(
|
|
5259
5302
|
DataTableSkeletonBody,
|
|
5260
5303
|
{
|
|
@@ -5273,7 +5316,7 @@ function DataTableBody({
|
|
|
5273
5316
|
}
|
|
5274
5317
|
const isExpanded = !!(((_d = row.getCanExpand) == null ? void 0 : _d.call(row)) && ((_e = row.getIsExpanded) == null ? void 0 : _e.call(row)));
|
|
5275
5318
|
const expandedRow = renderExpandedRow && isExpanded ? renderExpandedRow(row.original) : null;
|
|
5276
|
-
return /* @__PURE__ */ jsxs13(
|
|
5319
|
+
return /* @__PURE__ */ jsxs13(React10.Fragment, { children: [
|
|
5277
5320
|
/* @__PURE__ */ jsx14(
|
|
5278
5321
|
DataTableRow,
|
|
5279
5322
|
__spreadProps(__spreadValues({}, onRowRender ? onRowRender(row.original, row) : {}), {
|
|
@@ -5304,10 +5347,10 @@ function DataTableBody({
|
|
|
5304
5347
|
}
|
|
5305
5348
|
|
|
5306
5349
|
// src/data-table/view-filter.tsx
|
|
5307
|
-
import * as
|
|
5350
|
+
import * as React12 from "react";
|
|
5308
5351
|
|
|
5309
5352
|
// src/filter-bar/filter-bar.tsx
|
|
5310
|
-
import * as
|
|
5353
|
+
import * as React11 from "react";
|
|
5311
5354
|
import { Icon as Icon11 } from "@upbound/monarch-core";
|
|
5312
5355
|
import { Badge as Badge4 } from "@upbound/monarch-core";
|
|
5313
5356
|
import { Button as Button8 } from "@upbound/monarch-core";
|
|
@@ -5407,12 +5450,12 @@ function FilterBar(_a) {
|
|
|
5407
5450
|
const remainingFilters = filters.filter((f) => !usedKeys.has(f.key));
|
|
5408
5451
|
const availableFilters = filters.some(hasOrder) ? remainingFilters : sortBy(remainingFilters, (f) => f.label);
|
|
5409
5452
|
const shouldShowFilters = availableFilters.length > 0 || activeFilters.length > 0;
|
|
5410
|
-
const [pendingOpenKey, setPendingOpenKey] =
|
|
5453
|
+
const [pendingOpenKey, setPendingOpenKey] = React11.useState(null);
|
|
5411
5454
|
function handleAddFilter(key) {
|
|
5412
5455
|
onAddFilter(key);
|
|
5413
5456
|
setPendingOpenKey(key);
|
|
5414
5457
|
}
|
|
5415
|
-
const containerRef =
|
|
5458
|
+
const containerRef = React11.useRef(null);
|
|
5416
5459
|
return /* @__PURE__ */ jsxs14(
|
|
5417
5460
|
"div",
|
|
5418
5461
|
__spreadProps(__spreadValues({
|
|
@@ -5697,7 +5740,7 @@ function TextFilterChip({
|
|
|
5697
5740
|
}) {
|
|
5698
5741
|
const { label, placeholder } = definition;
|
|
5699
5742
|
const text = asTextValue(value);
|
|
5700
|
-
const [open, setOpen] =
|
|
5743
|
+
const [open, setOpen] = React11.useState(!!autoOpen);
|
|
5701
5744
|
return /* @__PURE__ */ jsxs14(ButtonGroup2, { children: [
|
|
5702
5745
|
/* @__PURE__ */ jsx15(ButtonGroupText2, { children: label }),
|
|
5703
5746
|
/* @__PURE__ */ jsxs14(Popover2, { open, onOpenChange: setOpen, children: [
|
|
@@ -5727,7 +5770,7 @@ function MultiTextFilterChip({
|
|
|
5727
5770
|
}) {
|
|
5728
5771
|
const { label, placeholder } = definition;
|
|
5729
5772
|
const tokens = asMultiTextValue(value);
|
|
5730
|
-
const [draft, setDraft] =
|
|
5773
|
+
const [draft, setDraft] = React11.useState("");
|
|
5731
5774
|
const displayLabel = tokens.length === 0 ? "Any" : tokens.length === 1 ? tokens[0] : `${tokens.length} values`;
|
|
5732
5775
|
function addToken() {
|
|
5733
5776
|
const token = draft.trim();
|
|
@@ -5915,7 +5958,7 @@ function ViewFilter({
|
|
|
5915
5958
|
onColumnFiltersChange,
|
|
5916
5959
|
className
|
|
5917
5960
|
}) {
|
|
5918
|
-
const filterableColumns =
|
|
5961
|
+
const filterableColumns = React12.useMemo(
|
|
5919
5962
|
() => columns.filter((column) => column.getCanFilter()).flatMap((column) => {
|
|
5920
5963
|
var _a;
|
|
5921
5964
|
const filter = (_a = column.columnDef.meta) == null ? void 0 : _a.filter;
|
|
@@ -5923,7 +5966,7 @@ function ViewFilter({
|
|
|
5923
5966
|
}),
|
|
5924
5967
|
[columns]
|
|
5925
5968
|
);
|
|
5926
|
-
const filterDefinitions =
|
|
5969
|
+
const filterDefinitions = React12.useMemo(
|
|
5927
5970
|
() => filterableColumns.map(({ key, filter }) => toFilterBarDefinition(key, filter)).sort((a, b) => {
|
|
5928
5971
|
if (a.order == null && b.order == null) return 0;
|
|
5929
5972
|
if (a.order == null) return 1;
|
|
@@ -5932,11 +5975,11 @@ function ViewFilter({
|
|
|
5932
5975
|
}),
|
|
5933
5976
|
[filterableColumns]
|
|
5934
5977
|
);
|
|
5935
|
-
const emptyValueByKey =
|
|
5978
|
+
const emptyValueByKey = React12.useMemo(
|
|
5936
5979
|
() => new Map(filterableColumns.map(({ key, filter }) => [key, emptyValueFor(filter)])),
|
|
5937
5980
|
[filterableColumns]
|
|
5938
5981
|
);
|
|
5939
|
-
const activeFilters =
|
|
5982
|
+
const activeFilters = React12.useMemo(
|
|
5940
5983
|
() => columnFilters.map((filter) => ({ key: filter.id, value: filter.value })),
|
|
5941
5984
|
[columnFilters]
|
|
5942
5985
|
);
|
|
@@ -6007,6 +6050,9 @@ import { Fragment as Fragment9, jsx as jsx18, jsxs as jsxs15 } from "react/jsx-r
|
|
|
6007
6050
|
var DEFAULT_PAGE_SIZE = 20;
|
|
6008
6051
|
var noop = () => {
|
|
6009
6052
|
};
|
|
6053
|
+
function isSamePage(a, b) {
|
|
6054
|
+
return a.pageIndex === b.pageIndex && a.pageSize === b.pageSize;
|
|
6055
|
+
}
|
|
6010
6056
|
var STICKY_HEADER_MAX_HEIGHT_CLASS = "max-h-[calc(100svh-250px)]";
|
|
6011
6057
|
function DataTable({
|
|
6012
6058
|
id,
|
|
@@ -6063,19 +6109,19 @@ function DataTable({
|
|
|
6063
6109
|
}) {
|
|
6064
6110
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
6065
6111
|
const isGrid = layout === "grid";
|
|
6066
|
-
const tableBodyScrollRef =
|
|
6067
|
-
const [innerGlobalFilter, setInnerGlobalFilter] =
|
|
6068
|
-
const [innerColumnOrdering, setInnerColumnOrdering] =
|
|
6069
|
-
const [innerColumnFilters, setInnerColumnFilters] =
|
|
6070
|
-
const [innerSorting, setInnerSorting] =
|
|
6071
|
-
const [innerColumnPinning, setInnerColumnPinning] =
|
|
6072
|
-
const [innerPagination, setInnerPagination] =
|
|
6112
|
+
const tableBodyScrollRef = React13.useRef(null);
|
|
6113
|
+
const [innerGlobalFilter, setInnerGlobalFilter] = React13.useState("");
|
|
6114
|
+
const [innerColumnOrdering, setInnerColumnOrdering] = React13.useState([]);
|
|
6115
|
+
const [innerColumnFilters, setInnerColumnFilters] = React13.useState([]);
|
|
6116
|
+
const [innerSorting, setInnerSorting] = React13.useState(((_a = config.state) == null ? void 0 : _a.sorting) || []);
|
|
6117
|
+
const [innerColumnPinning, setInnerColumnPinning] = React13.useState({ start: [], end: [] });
|
|
6118
|
+
const [innerPagination, setInnerPagination] = React13.useState({
|
|
6073
6119
|
pageIndex: ((_c = (_b = config.state) == null ? void 0 : _b.pagination) == null ? void 0 : _c.pageIndex) || 0,
|
|
6074
6120
|
pageSize: ((_e = (_d = config.state) == null ? void 0 : _d.pagination) == null ? void 0 : _e.pageSize) || DEFAULT_PAGE_SIZE
|
|
6075
6121
|
});
|
|
6076
|
-
const [innerGrouping, setInnerGrouping] =
|
|
6077
|
-
const [innerColumnVisibility, setInnerColumnVisibility] =
|
|
6078
|
-
const [innerExpanded, setInnerExpanded] =
|
|
6122
|
+
const [innerGrouping, setInnerGrouping] = React13.useState([]);
|
|
6123
|
+
const [innerColumnVisibility, setInnerColumnVisibility] = React13.useState({});
|
|
6124
|
+
const [innerExpanded, setInnerExpanded] = React13.useState({});
|
|
6079
6125
|
const {
|
|
6080
6126
|
columnSizing,
|
|
6081
6127
|
handleColumnSizingChange,
|
|
@@ -6102,25 +6148,36 @@ function DataTable({
|
|
|
6102
6148
|
const pagination = parentPagination || innerPagination;
|
|
6103
6149
|
const setPagination = parentSetPagination != null ? parentSetPagination : setInnerPagination;
|
|
6104
6150
|
const shouldDisablePagination = paginationConfig === false;
|
|
6105
|
-
const
|
|
6151
|
+
const [pageRequest, setPageRequest] = React13.useState(null);
|
|
6152
|
+
if (pageRequest && !loading && isSamePage(pageRequest.pagination, pagination)) {
|
|
6153
|
+
setPageRequest(null);
|
|
6154
|
+
}
|
|
6155
|
+
const pageLoading = loading && pageRequest !== null;
|
|
6156
|
+
const shownConfig = pageLoading ? __spreadValues(__spreadValues({}, config), pageRequest.rows) : config;
|
|
6157
|
+
const requestPage = (nextPagination) => {
|
|
6158
|
+
const { data, rowCount: rowCount2, rowCountRelation } = config;
|
|
6159
|
+
setPageRequest({ pagination: nextPagination, rows: { data, rowCount: rowCount2, rowCountRelation } });
|
|
6160
|
+
setPagination(nextPagination);
|
|
6161
|
+
};
|
|
6162
|
+
const resetPageIndexOnFilterChange = React13.useCallback(() => {
|
|
6106
6163
|
if (!serverSidePagination || pagination.pageIndex === 0) return;
|
|
6107
6164
|
setPagination((prev) => __spreadProps(__spreadValues({}, prev), { pageIndex: 0 }));
|
|
6108
6165
|
}, [serverSidePagination, pagination.pageIndex, setPagination]);
|
|
6109
|
-
const setGlobalFilter =
|
|
6166
|
+
const setGlobalFilter = React13.useCallback(
|
|
6110
6167
|
(value) => {
|
|
6111
6168
|
applyGlobalFilter(value);
|
|
6112
6169
|
resetPageIndexOnFilterChange();
|
|
6113
6170
|
},
|
|
6114
6171
|
[applyGlobalFilter, resetPageIndexOnFilterChange]
|
|
6115
6172
|
);
|
|
6116
|
-
const setColumnFilters =
|
|
6173
|
+
const setColumnFilters = React13.useCallback(
|
|
6117
6174
|
(value) => {
|
|
6118
6175
|
applyColumnFilters(value);
|
|
6119
6176
|
resetPageIndexOnFilterChange();
|
|
6120
6177
|
},
|
|
6121
6178
|
[applyColumnFilters, resetPageIndexOnFilterChange]
|
|
6122
6179
|
);
|
|
6123
|
-
|
|
6180
|
+
React13.useLayoutEffect(() => {
|
|
6124
6181
|
var _a2;
|
|
6125
6182
|
if (shouldDisablePagination) return;
|
|
6126
6183
|
(_a2 = tableBodyScrollRef.current) == null ? void 0 : _a2.scrollTo({ top: 0 });
|
|
@@ -6144,8 +6201,8 @@ function DataTable({
|
|
|
6144
6201
|
const hasExternalSearch = parentGlobalFilter !== void 0;
|
|
6145
6202
|
const hasExternalFilters = parentColumnFilters !== void 0;
|
|
6146
6203
|
const shouldDisableFiltersModels = !!disableFilters && !!disableSearch && !hasExternalSearch && !hasExternalFilters;
|
|
6147
|
-
const columns =
|
|
6148
|
-
const table = useTable(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({},
|
|
6204
|
+
const columns = React13.useMemo(() => withDefaultFilterFns(config.columns), [config.columns]);
|
|
6205
|
+
const table = useTable(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, shownConfig), {
|
|
6149
6206
|
columns,
|
|
6150
6207
|
features: dataTableFeatures,
|
|
6151
6208
|
// Row models are registered statically in `dataTableFeatures`, so a disabled stage is switched
|
|
@@ -6204,7 +6261,7 @@ function DataTable({
|
|
|
6204
6261
|
const orderedVisibleColumns = table.getVisibleLeafColumns().filter((col) => !isFilterOnlyColumn(col));
|
|
6205
6262
|
const hasFilters = !!celFilterConfig || hasFilterableColumns(flatColumns);
|
|
6206
6263
|
const showFilterToggle = filterToggleRequested && !disableFilters && hasFilters;
|
|
6207
|
-
const [gridMeasuredMins, setGridMeasuredMins] =
|
|
6264
|
+
const [gridMeasuredMins, setGridMeasuredMins] = React13.useState({});
|
|
6208
6265
|
const { gridTemplateColumns, gridRootRef, handleAutosizeAll, handleAutosizeColumn, handleResetColumnSize } = useGridLayout({
|
|
6209
6266
|
layout,
|
|
6210
6267
|
table,
|
|
@@ -6218,7 +6275,7 @@ function DataTable({
|
|
|
6218
6275
|
rawHandleAutosizeColumn,
|
|
6219
6276
|
rawHandleResetColumnSize
|
|
6220
6277
|
});
|
|
6221
|
-
const handleContextCell =
|
|
6278
|
+
const handleContextCell = React13.useCallback(
|
|
6222
6279
|
(filter, cell) => {
|
|
6223
6280
|
var _a2, _b2;
|
|
6224
6281
|
if (celFilterConfig == null ? void 0 : celFilterConfig.onContextualFilter) {
|
|
@@ -6235,13 +6292,13 @@ function DataTable({
|
|
|
6235
6292
|
},
|
|
6236
6293
|
[celFilterConfig, onContextCell, setColumnFilters, table]
|
|
6237
6294
|
);
|
|
6238
|
-
const handleContextSearch =
|
|
6295
|
+
const handleContextSearch = React13.useCallback(
|
|
6239
6296
|
(searchTerm) => {
|
|
6240
6297
|
setGlobalFilter(searchTerm);
|
|
6241
6298
|
},
|
|
6242
6299
|
[setGlobalFilter]
|
|
6243
6300
|
);
|
|
6244
|
-
const totalTableWidth =
|
|
6301
|
+
const totalTableWidth = React13.useMemo(() => {
|
|
6245
6302
|
if (isGrid) return 0;
|
|
6246
6303
|
const firstGroup = headerGroups[0];
|
|
6247
6304
|
if (!firstGroup) return 0;
|
|
@@ -6254,7 +6311,7 @@ function DataTable({
|
|
|
6254
6311
|
return getColumnFilterCount(value, (_b2 = (_a2 = table.getColumn(columnFilterId)) == null ? void 0 : _a2.columnDef.meta) == null ? void 0 : _b2.filter);
|
|
6255
6312
|
}
|
|
6256
6313
|
).reduce((prev, curr) => prev + curr, 0);
|
|
6257
|
-
const tableState = getTableState({ error: !!showError, loading, rowCount });
|
|
6314
|
+
const tableState = getTableState({ error: !!showError, loading: loading && !pageLoading, rowCount });
|
|
6258
6315
|
const shouldDisable = tableState === "error";
|
|
6259
6316
|
const shouldRenderTableContent = tableState !== "error" && tableState !== "empty";
|
|
6260
6317
|
const resetFilters = () => {
|
|
@@ -6265,7 +6322,7 @@ function DataTable({
|
|
|
6265
6322
|
}
|
|
6266
6323
|
setGlobalFilter("");
|
|
6267
6324
|
};
|
|
6268
|
-
|
|
6325
|
+
React13.useEffect(() => {
|
|
6269
6326
|
if (disableColumnReordering) return;
|
|
6270
6327
|
const allColumnIds = flatColumns.map((col) => col.id);
|
|
6271
6328
|
const normalizedColumnOrdering = normalizeColumnOrdering(columnOrdering, allColumnIds);
|
|
@@ -6391,12 +6448,13 @@ function DataTable({
|
|
|
6391
6448
|
DataTablePagination,
|
|
6392
6449
|
{
|
|
6393
6450
|
rowCount,
|
|
6394
|
-
rowCountRelation: (_g =
|
|
6451
|
+
rowCountRelation: (_g = shownConfig.rowCountRelation) != null ? _g : "eq",
|
|
6395
6452
|
paginationConfig,
|
|
6453
|
+
loading: pageLoading,
|
|
6396
6454
|
pageSize: pagination.pageSize,
|
|
6397
6455
|
pageIndex: pagination.pageIndex,
|
|
6398
|
-
onPageChange: (p) =>
|
|
6399
|
-
onPageSizeChange: (
|
|
6456
|
+
onPageChange: (p) => requestPage(__spreadProps(__spreadValues({}, pagination), { pageIndex: p - 1 })),
|
|
6457
|
+
onPageSizeChange: (pageSize) => requestPage({ pageIndex: 0, pageSize })
|
|
6400
6458
|
}
|
|
6401
6459
|
)
|
|
6402
6460
|
] }) : /* @__PURE__ */ jsx18(
|
|
@@ -6419,19 +6477,19 @@ import {
|
|
|
6419
6477
|
} from "@tanstack/react-table";
|
|
6420
6478
|
|
|
6421
6479
|
// src/floating-widget.tsx
|
|
6422
|
-
import * as
|
|
6480
|
+
import * as React14 from "react";
|
|
6423
6481
|
import { Button as Button9 } from "@upbound/monarch-core";
|
|
6424
6482
|
import { DropdownMenu as DropdownMenu6, DropdownMenuContent as DropdownMenuContent6, DropdownMenuTrigger as DropdownMenuTrigger6 } from "@upbound/monarch-core";
|
|
6425
6483
|
import { Icon as Icon12 } from "@upbound/monarch-core";
|
|
6426
6484
|
import { Kbd as Kbd2 } from "@upbound/monarch-core";
|
|
6427
6485
|
import { Tooltip as Tooltip8, TooltipContent as TooltipContent7, TooltipTrigger as TooltipTrigger7 } from "@upbound/monarch-core";
|
|
6428
6486
|
import { jsx as jsx19, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6429
|
-
var FloatingWidgetContext =
|
|
6487
|
+
var FloatingWidgetContext = React14.createContext(null);
|
|
6430
6488
|
function FloatingWidgetProvider({ children }) {
|
|
6431
|
-
const [isOpen, setIsOpen] =
|
|
6432
|
-
const [isCollapsed, setIsCollapsed] =
|
|
6433
|
-
const [isExpanded, setIsExpanded] =
|
|
6434
|
-
const value =
|
|
6489
|
+
const [isOpen, setIsOpen] = React14.useState(false);
|
|
6490
|
+
const [isCollapsed, setIsCollapsed] = React14.useState(false);
|
|
6491
|
+
const [isExpanded, setIsExpanded] = React14.useState(false);
|
|
6492
|
+
const value = React14.useMemo(
|
|
6435
6493
|
() => ({
|
|
6436
6494
|
isOpen,
|
|
6437
6495
|
isCollapsed,
|
|
@@ -6466,7 +6524,7 @@ function FloatingWidgetProvider({ children }) {
|
|
|
6466
6524
|
return /* @__PURE__ */ jsx19(FloatingWidgetContext.Provider, { value, children });
|
|
6467
6525
|
}
|
|
6468
6526
|
function useFloatingWidget() {
|
|
6469
|
-
const ctx =
|
|
6527
|
+
const ctx = React14.useContext(FloatingWidgetContext);
|
|
6470
6528
|
if (!ctx) {
|
|
6471
6529
|
throw new Error("useFloatingWidget must be used inside <FloatingWidgetProvider>.");
|
|
6472
6530
|
}
|
|
@@ -6474,14 +6532,14 @@ function useFloatingWidget() {
|
|
|
6474
6532
|
}
|
|
6475
6533
|
function FloatingWidget({ title = "Ask AI", subtitle, menuItems, children, className }) {
|
|
6476
6534
|
const { isOpen, isCollapsed, isExpanded, close, collapse, restore, toggleExpand } = useFloatingWidget();
|
|
6477
|
-
const [dragWidth, setDragWidth] =
|
|
6478
|
-
const [isDragging, setIsDragging] =
|
|
6479
|
-
|
|
6535
|
+
const [dragWidth, setDragWidth] = React14.useState(null);
|
|
6536
|
+
const [isDragging, setIsDragging] = React14.useState(false);
|
|
6537
|
+
React14.useEffect(() => {
|
|
6480
6538
|
setDragWidth(null);
|
|
6481
6539
|
}, [isExpanded]);
|
|
6482
6540
|
const MIN_WIDTH = 420;
|
|
6483
|
-
const widgetRef =
|
|
6484
|
-
const handleResizeMouseDown =
|
|
6541
|
+
const widgetRef = React14.useRef(null);
|
|
6542
|
+
const handleResizeMouseDown = React14.useCallback((e) => {
|
|
6485
6543
|
var _a, _b;
|
|
6486
6544
|
e.preventDefault();
|
|
6487
6545
|
setIsDragging(true);
|
|
@@ -6501,7 +6559,7 @@ function FloatingWidget({ title = "Ask AI", subtitle, menuItems, children, class
|
|
|
6501
6559
|
window.addEventListener("mousemove", onMove);
|
|
6502
6560
|
window.addEventListener("mouseup", onUp);
|
|
6503
6561
|
}, []);
|
|
6504
|
-
|
|
6562
|
+
React14.useEffect(() => {
|
|
6505
6563
|
if (!isOpen) return;
|
|
6506
6564
|
function handleKeydown(e) {
|
|
6507
6565
|
if (e.key === "Escape") {
|
|
@@ -6595,7 +6653,7 @@ function FloatingWidget({ title = "Ask AI", subtitle, menuItems, children, class
|
|
|
6595
6653
|
}
|
|
6596
6654
|
|
|
6597
6655
|
// src/graph/graph-actions-provider.tsx
|
|
6598
|
-
import * as
|
|
6656
|
+
import * as React16 from "react";
|
|
6599
6657
|
|
|
6600
6658
|
// src/graph/hooks/useGraphActionsContext.ts
|
|
6601
6659
|
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
@@ -6609,10 +6667,10 @@ var useGraphActionsContext = () => {
|
|
|
6609
6667
|
};
|
|
6610
6668
|
|
|
6611
6669
|
// src/graph/hooks/useGraphActions.ts
|
|
6612
|
-
import { useCallback as useCallback10, useState as
|
|
6670
|
+
import { useCallback as useCallback10, useState as useState14 } from "react";
|
|
6613
6671
|
|
|
6614
6672
|
// src/graph/graph-node.tsx
|
|
6615
|
-
import * as
|
|
6673
|
+
import * as React15 from "react";
|
|
6616
6674
|
import { getIncomers, getOutgoers, Handle, Position as Position2 } from "reactflow";
|
|
6617
6675
|
import { Badge as Badge5, Button as Button10, Card as Card2, Icon as Icon13, Tooltip as Tooltip9, TooltipContent as TooltipContent8, TooltipTrigger as TooltipTrigger8 } from "@upbound/monarch-core";
|
|
6618
6676
|
|
|
@@ -6668,13 +6726,13 @@ function GraphNode(_a) {
|
|
|
6668
6726
|
const { nodes: originalNodes, edges: originalEdges } = useGraphActionsContext();
|
|
6669
6727
|
const nodes = originalNodes;
|
|
6670
6728
|
const edges = originalEdges;
|
|
6671
|
-
const handleClick =
|
|
6729
|
+
const handleClick = React15.useCallback(() => {
|
|
6672
6730
|
var _a3;
|
|
6673
6731
|
(_a3 = data == null ? void 0 : data.onClick) == null ? void 0 : _a3.call(data, id, data);
|
|
6674
6732
|
}, [data, id]);
|
|
6675
6733
|
const compact = (_a2 = data == null ? void 0 : data.compact) != null ? _a2 : false;
|
|
6676
6734
|
const state = (_b2 = data == null ? void 0 : data.state) != null ? _b2 : "default";
|
|
6677
|
-
const compactBadges =
|
|
6735
|
+
const compactBadges = React15.useMemo(() => {
|
|
6678
6736
|
const badges = data.badges.compact || [];
|
|
6679
6737
|
if (state === "paused") {
|
|
6680
6738
|
return [
|
|
@@ -6684,7 +6742,7 @@ function GraphNode(_a) {
|
|
|
6684
6742
|
}
|
|
6685
6743
|
return badges;
|
|
6686
6744
|
}, [data.badges.compact, state]);
|
|
6687
|
-
const defaultBadges =
|
|
6745
|
+
const defaultBadges = React15.useMemo(() => {
|
|
6688
6746
|
const badges = data.badges.default || [];
|
|
6689
6747
|
if (state === "paused") {
|
|
6690
6748
|
return [
|
|
@@ -6701,7 +6759,7 @@ function GraphNode(_a) {
|
|
|
6701
6759
|
}
|
|
6702
6760
|
return badges;
|
|
6703
6761
|
}, [data.badges.default, state]);
|
|
6704
|
-
const currentNode =
|
|
6762
|
+
const currentNode = React15.useMemo(
|
|
6705
6763
|
() => ({
|
|
6706
6764
|
id,
|
|
6707
6765
|
position: { x: 0, y: 0 },
|
|
@@ -6711,10 +6769,10 @@ function GraphNode(_a) {
|
|
|
6711
6769
|
}),
|
|
6712
6770
|
[id, data, props.type]
|
|
6713
6771
|
);
|
|
6714
|
-
const _hasIncomingEdge =
|
|
6772
|
+
const _hasIncomingEdge = React15.useMemo(() => {
|
|
6715
6773
|
return getIncomers(currentNode, nodes, edges).length > 0;
|
|
6716
6774
|
}, [currentNode, nodes, edges]);
|
|
6717
|
-
const hasOutgoingEdge =
|
|
6775
|
+
const hasOutgoingEdge = React15.useMemo(() => {
|
|
6718
6776
|
return getOutgoers(currentNode, nodes, edges).length > 0;
|
|
6719
6777
|
}, [currentNode, nodes, edges]);
|
|
6720
6778
|
const targetX = GRAPH_NODE_WIDTH / 2 - 4;
|
|
@@ -6900,8 +6958,8 @@ function GraphNodeSkeleton(_props) {
|
|
|
6900
6958
|
|
|
6901
6959
|
// src/graph/hooks/useGraphActions.ts
|
|
6902
6960
|
var useGraphActions = (initialNodes = [], initialEdges = []) => {
|
|
6903
|
-
const [nodes, setNodes] =
|
|
6904
|
-
const [edges, setEdges] =
|
|
6961
|
+
const [nodes, setNodes] = useState14(initialNodes);
|
|
6962
|
+
const [edges, setEdges] = useState14(initialEdges);
|
|
6905
6963
|
const addNodes = useCallback10((newNodes) => {
|
|
6906
6964
|
setNodes((prevNodes) => {
|
|
6907
6965
|
const existingIds = new Set(prevNodes.map((node) => node.id));
|
|
@@ -6963,10 +7021,10 @@ var useGraphActions = (initialNodes = [], initialEdges = []) => {
|
|
|
6963
7021
|
|
|
6964
7022
|
// src/graph/graph-actions-provider.tsx
|
|
6965
7023
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
6966
|
-
var GraphActionsProvider =
|
|
7024
|
+
var GraphActionsProvider = React16.forwardRef(
|
|
6967
7025
|
({ initialNodes = [], initialEdges = [], children }, ref) => {
|
|
6968
7026
|
const graphActions = useGraphActions(initialNodes, initialEdges);
|
|
6969
|
-
|
|
7027
|
+
React16.useImperativeHandle(
|
|
6970
7028
|
ref,
|
|
6971
7029
|
() => ({
|
|
6972
7030
|
addNodes: graphActions.addNodes,
|
|
@@ -6985,12 +7043,12 @@ var GraphActionsProvider = React15.forwardRef(
|
|
|
6985
7043
|
GraphActionsProvider.displayName = "GraphActionsProvider";
|
|
6986
7044
|
|
|
6987
7045
|
// src/graph/graph.tsx
|
|
6988
|
-
import * as
|
|
7046
|
+
import * as React19 from "react";
|
|
6989
7047
|
import { useTable as useTable2 } from "@tanstack/react-table";
|
|
6990
7048
|
import { Icon as Icon14 } from "@upbound/monarch-core";
|
|
6991
7049
|
|
|
6992
7050
|
// src/graph/graph-view.tsx
|
|
6993
|
-
import * as
|
|
7051
|
+
import * as React18 from "react";
|
|
6994
7052
|
import { Background, Controls, MiniMap, ReactFlow, ReactFlowProvider } from "reactflow";
|
|
6995
7053
|
|
|
6996
7054
|
// src/graph/hooks/useAutoLayout.ts
|
|
@@ -7198,7 +7256,7 @@ var useNodeVisibility = (nodes, edges) => {
|
|
|
7198
7256
|
};
|
|
7199
7257
|
|
|
7200
7258
|
// src/graph/hooks/useViewportFocus.ts
|
|
7201
|
-
import * as
|
|
7259
|
+
import * as React17 from "react";
|
|
7202
7260
|
import { useReactFlow, useStore } from "reactflow";
|
|
7203
7261
|
function getViewportFocusCenter(node) {
|
|
7204
7262
|
var _a;
|
|
@@ -7213,7 +7271,7 @@ function useViewportFocus(nodeMap, viewportFocusNodeId) {
|
|
|
7213
7271
|
const { setCenter } = useReactFlow();
|
|
7214
7272
|
const viewportReady = useStore((state) => state.width > 0 && state.height > 0);
|
|
7215
7273
|
const node = viewportFocusNodeId ? nodeMap.get(viewportFocusNodeId) : void 0;
|
|
7216
|
-
|
|
7274
|
+
React17.useEffect(() => {
|
|
7217
7275
|
if (!node || !viewportReady) {
|
|
7218
7276
|
return;
|
|
7219
7277
|
}
|
|
@@ -7234,21 +7292,21 @@ var GraphViewInternal = ({
|
|
|
7234
7292
|
hideControls = false
|
|
7235
7293
|
}) => {
|
|
7236
7294
|
const { nodes, edges, toggleNodeExpansion } = useGraphActionsContext();
|
|
7237
|
-
const nodeTypes =
|
|
7295
|
+
const nodeTypes = React18.useMemo(
|
|
7238
7296
|
() => __spreadValues({
|
|
7239
7297
|
default: GraphNode,
|
|
7240
7298
|
loading: GraphNodeSkeleton
|
|
7241
7299
|
}, parentNodeTypes),
|
|
7242
7300
|
[parentNodeTypes]
|
|
7243
7301
|
);
|
|
7244
|
-
const edgeTypes =
|
|
7302
|
+
const edgeTypes = React18.useMemo(
|
|
7245
7303
|
() => __spreadValues({
|
|
7246
7304
|
default: GraphEdge
|
|
7247
7305
|
}, parentEdgeTypes),
|
|
7248
7306
|
[parentEdgeTypes]
|
|
7249
7307
|
);
|
|
7250
7308
|
const { nodes: visibleNodes, edges: visibleEdges } = useNodeVisibility(nodes, edges);
|
|
7251
|
-
const nodesWithExpansion =
|
|
7309
|
+
const nodesWithExpansion = React18.useMemo(() => {
|
|
7252
7310
|
return visibleNodes.map((node) => {
|
|
7253
7311
|
if (isDefaultNode(node) && !node.data.onExpandToggle) {
|
|
7254
7312
|
return __spreadProps(__spreadValues({}, node), {
|
|
@@ -7296,7 +7354,7 @@ var GraphViewInternal = ({
|
|
|
7296
7354
|
}
|
|
7297
7355
|
);
|
|
7298
7356
|
};
|
|
7299
|
-
var GraphView =
|
|
7357
|
+
var GraphView = React18.forwardRef(
|
|
7300
7358
|
({
|
|
7301
7359
|
defaultNodes = [],
|
|
7302
7360
|
defaultEdges = [],
|
|
@@ -7364,9 +7422,9 @@ function Graph({
|
|
|
7364
7422
|
children
|
|
7365
7423
|
}) {
|
|
7366
7424
|
var _a, _b, _c;
|
|
7367
|
-
const graphRef =
|
|
7368
|
-
const [innerGlobalFilter, setInnerGlobalFilter] =
|
|
7369
|
-
const [innerColumnFilters, setInnerColumnFilters] =
|
|
7425
|
+
const graphRef = React19.useRef(null);
|
|
7426
|
+
const [innerGlobalFilter, setInnerGlobalFilter] = React19.useState("");
|
|
7427
|
+
const [innerColumnFilters, setInnerColumnFilters] = React19.useState([]);
|
|
7370
7428
|
if (parentGlobalFilter !== void 0 && parentGlobalFilter !== innerGlobalFilter) {
|
|
7371
7429
|
setInnerGlobalFilter(parentGlobalFilter);
|
|
7372
7430
|
}
|
|
@@ -7374,7 +7432,7 @@ function Graph({
|
|
|
7374
7432
|
const setGlobalFilter = parentSetGlobalFilter != null ? parentSetGlobalFilter : setInnerGlobalFilter;
|
|
7375
7433
|
const columnFilters = parentColumnFilters != null ? parentColumnFilters : innerColumnFilters;
|
|
7376
7434
|
const setColumnFilters = parentSetColumnFilters != null ? parentSetColumnFilters : setInnerColumnFilters;
|
|
7377
|
-
const columns =
|
|
7435
|
+
const columns = React19.useMemo(() => withDefaultFilterFns(columnDefinitions), [columnDefinitions]);
|
|
7378
7436
|
const table = useTable2({
|
|
7379
7437
|
features: dataTableFeatures,
|
|
7380
7438
|
data: config.data,
|
|
@@ -7386,7 +7444,7 @@ function Graph({
|
|
|
7386
7444
|
});
|
|
7387
7445
|
const flatColumns = table.getAllFlatColumns();
|
|
7388
7446
|
const filteredRows = table.getFilteredRowModel().rows;
|
|
7389
|
-
const filteredData =
|
|
7447
|
+
const filteredData = React19.useMemo(() => filteredRows.map((row) => row.original), [filteredRows]);
|
|
7390
7448
|
const filterCount = columnFilters.map(
|
|
7391
7449
|
({ id: columnFilterId, value }) => {
|
|
7392
7450
|
var _a2, _b2;
|
|
@@ -7400,10 +7458,10 @@ function Graph({
|
|
|
7400
7458
|
setColumnFilters([]);
|
|
7401
7459
|
setGlobalFilter("");
|
|
7402
7460
|
};
|
|
7403
|
-
const memoizedNodeTypes =
|
|
7404
|
-
const memoizedEdgeTypes =
|
|
7405
|
-
const memoizedConfig =
|
|
7406
|
-
|
|
7461
|
+
const memoizedNodeTypes = React19.useMemo(() => config.nodeTypes, [config.nodeTypes]);
|
|
7462
|
+
const memoizedEdgeTypes = React19.useMemo(() => config.edgeTypes, [config.edgeTypes]);
|
|
7463
|
+
const memoizedConfig = React19.useMemo(() => config, [config]);
|
|
7464
|
+
React19.useEffect(() => {
|
|
7407
7465
|
if (!graphRef.current) {
|
|
7408
7466
|
return;
|
|
7409
7467
|
}
|
|
@@ -7466,11 +7524,11 @@ function Graph({
|
|
|
7466
7524
|
}
|
|
7467
7525
|
|
|
7468
7526
|
// src/graph/hooks/useGetViewportNodeIds.ts
|
|
7469
|
-
import { useEffect as useEffect10, useMemo as useMemo14, useRef as useRef11, useState as
|
|
7527
|
+
import { useEffect as useEffect10, useMemo as useMemo14, useRef as useRef11, useState as useState16 } from "react";
|
|
7470
7528
|
import { useStore as useStore2, useViewport } from "reactflow";
|
|
7471
7529
|
var useGetDebouncedViewport = (debounceDelay = 1e3) => {
|
|
7472
7530
|
const timerRef = useRef11(null);
|
|
7473
|
-
const [debouncedValues, setDebouncedValues] =
|
|
7531
|
+
const [debouncedValues, setDebouncedValues] = useState16({ x: 0, y: 0, zoom: 1, width: 0, height: 0, nodes: [] });
|
|
7474
7532
|
const { x, y, zoom } = useViewport();
|
|
7475
7533
|
const { width, height, nodes } = useStore2((state) => ({
|
|
7476
7534
|
width: state.width,
|
|
@@ -7549,7 +7607,13 @@ function PageHeaderTitle(_a) {
|
|
|
7549
7607
|
}
|
|
7550
7608
|
function PageHeaderDescription(_a) {
|
|
7551
7609
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
7552
|
-
return /* @__PURE__ */ jsx25(
|
|
7610
|
+
return /* @__PURE__ */ jsx25(
|
|
7611
|
+
"p",
|
|
7612
|
+
__spreadValues({
|
|
7613
|
+
"data-slot": "page-header-description",
|
|
7614
|
+
className: cn("text-body text-muted-foreground max-w-160", className)
|
|
7615
|
+
}, props)
|
|
7616
|
+
);
|
|
7553
7617
|
}
|
|
7554
7618
|
function PageHeaderMeta(_a) {
|
|
7555
7619
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|