@upbound/monarch-blocks 0.15.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/data-table.d.ts +8 -1
- package/dist/data-table.js +129 -97
- package/dist/data-table.js.map +1 -1
- package/dist/index.js +174 -142
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -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,
|
|
4746
|
+
/* @__PURE__ */ jsxs12(
|
|
4747
|
+
Select2,
|
|
4717
4748
|
{
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
) }),
|
|
4726
|
-
resolved.arrows && /* @__PURE__ */ jsx13(PaginationItem, { children: /* @__PURE__ */ jsx13(
|
|
4727
|
-
Button7,
|
|
4728
|
-
{
|
|
4729
|
-
variant: "outline",
|
|
4730
|
-
size: "icon",
|
|
4731
|
-
"aria-label": "Go to previous page",
|
|
4732
|
-
disabled: currentPage <= 1,
|
|
4733
|
-
onClick: () => onPageChange(currentPage - 1),
|
|
4734
|
-
children: /* @__PURE__ */ jsx13(Icon9, { name: "chevron-left", className: "cn-rtl-flip" })
|
|
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 {
|
|
@@ -5108,7 +5117,7 @@ function DataTableHeader({
|
|
|
5108
5117
|
}
|
|
5109
5118
|
return /* @__PURE__ */ jsx14(BaseTableHeader, { children: headerGroups.map((headerGroup, headerGroupIndex) => /* @__PURE__ */ jsx14(BaseTableRow, { children: renderHeaders(headerGroup, headerGroupIndex) }, headerGroup.id)) });
|
|
5110
5119
|
}
|
|
5111
|
-
var DataTableRow =
|
|
5120
|
+
var DataTableRow = React10.forwardRef(
|
|
5112
5121
|
(_a, ref) => {
|
|
5113
5122
|
var _b = _a, { hoverable, disabled, className, layout = "auto" } = _b, props = __objRest(_b, ["hoverable", "disabled", "className", "layout"]);
|
|
5114
5123
|
const classes = cn(
|
|
@@ -5211,6 +5220,10 @@ function DataTableGroupRow({
|
|
|
5211
5220
|
}
|
|
5212
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 }) });
|
|
5213
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
|
+
}
|
|
5214
5227
|
function DataTableSkeletonBody({
|
|
5215
5228
|
rowCount = 10,
|
|
5216
5229
|
columns,
|
|
@@ -5227,14 +5240,14 @@ function DataTableSkeletonBody({
|
|
|
5227
5240
|
role: "cell",
|
|
5228
5241
|
className: cn(TABLE_CELL_CLASSES, "flex items-center overflow-hidden"),
|
|
5229
5242
|
style: { minWidth: col.minSize },
|
|
5230
|
-
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 })
|
|
5231
5244
|
},
|
|
5232
5245
|
`skeleton-col-${col.id}-row-${rowIndex}`
|
|
5233
5246
|
) : /* @__PURE__ */ jsx14(
|
|
5234
5247
|
BaseTableCell,
|
|
5235
5248
|
{
|
|
5236
5249
|
style: { width: col.size, minWidth: col.minSize, maxWidth: col.maxSize },
|
|
5237
|
-
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 })
|
|
5238
5251
|
},
|
|
5239
5252
|
`skeleton-col-${col.id}-row-${rowIndex}`
|
|
5240
5253
|
);
|
|
@@ -5275,12 +5288,16 @@ function DataTableBody({
|
|
|
5275
5288
|
const visibleColumns = columns.filter((column) => !isFilterOnlyColumn(column));
|
|
5276
5289
|
const colSpan = visibleColumns.length;
|
|
5277
5290
|
if (tableState === "loading") {
|
|
5278
|
-
const skeletonColumns = visibleColumns.map((c) =>
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
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
|
+
});
|
|
5284
5301
|
return /* @__PURE__ */ jsx14(
|
|
5285
5302
|
DataTableSkeletonBody,
|
|
5286
5303
|
{
|
|
@@ -5299,7 +5316,7 @@ function DataTableBody({
|
|
|
5299
5316
|
}
|
|
5300
5317
|
const isExpanded = !!(((_d = row.getCanExpand) == null ? void 0 : _d.call(row)) && ((_e = row.getIsExpanded) == null ? void 0 : _e.call(row)));
|
|
5301
5318
|
const expandedRow = renderExpandedRow && isExpanded ? renderExpandedRow(row.original) : null;
|
|
5302
|
-
return /* @__PURE__ */ jsxs13(
|
|
5319
|
+
return /* @__PURE__ */ jsxs13(React10.Fragment, { children: [
|
|
5303
5320
|
/* @__PURE__ */ jsx14(
|
|
5304
5321
|
DataTableRow,
|
|
5305
5322
|
__spreadProps(__spreadValues({}, onRowRender ? onRowRender(row.original, row) : {}), {
|
|
@@ -5330,10 +5347,10 @@ function DataTableBody({
|
|
|
5330
5347
|
}
|
|
5331
5348
|
|
|
5332
5349
|
// src/data-table/view-filter.tsx
|
|
5333
|
-
import * as
|
|
5350
|
+
import * as React12 from "react";
|
|
5334
5351
|
|
|
5335
5352
|
// src/filter-bar/filter-bar.tsx
|
|
5336
|
-
import * as
|
|
5353
|
+
import * as React11 from "react";
|
|
5337
5354
|
import { Icon as Icon11 } from "@upbound/monarch-core";
|
|
5338
5355
|
import { Badge as Badge4 } from "@upbound/monarch-core";
|
|
5339
5356
|
import { Button as Button8 } from "@upbound/monarch-core";
|
|
@@ -5433,12 +5450,12 @@ function FilterBar(_a) {
|
|
|
5433
5450
|
const remainingFilters = filters.filter((f) => !usedKeys.has(f.key));
|
|
5434
5451
|
const availableFilters = filters.some(hasOrder) ? remainingFilters : sortBy(remainingFilters, (f) => f.label);
|
|
5435
5452
|
const shouldShowFilters = availableFilters.length > 0 || activeFilters.length > 0;
|
|
5436
|
-
const [pendingOpenKey, setPendingOpenKey] =
|
|
5453
|
+
const [pendingOpenKey, setPendingOpenKey] = React11.useState(null);
|
|
5437
5454
|
function handleAddFilter(key) {
|
|
5438
5455
|
onAddFilter(key);
|
|
5439
5456
|
setPendingOpenKey(key);
|
|
5440
5457
|
}
|
|
5441
|
-
const containerRef =
|
|
5458
|
+
const containerRef = React11.useRef(null);
|
|
5442
5459
|
return /* @__PURE__ */ jsxs14(
|
|
5443
5460
|
"div",
|
|
5444
5461
|
__spreadProps(__spreadValues({
|
|
@@ -5723,7 +5740,7 @@ function TextFilterChip({
|
|
|
5723
5740
|
}) {
|
|
5724
5741
|
const { label, placeholder } = definition;
|
|
5725
5742
|
const text = asTextValue(value);
|
|
5726
|
-
const [open, setOpen] =
|
|
5743
|
+
const [open, setOpen] = React11.useState(!!autoOpen);
|
|
5727
5744
|
return /* @__PURE__ */ jsxs14(ButtonGroup2, { children: [
|
|
5728
5745
|
/* @__PURE__ */ jsx15(ButtonGroupText2, { children: label }),
|
|
5729
5746
|
/* @__PURE__ */ jsxs14(Popover2, { open, onOpenChange: setOpen, children: [
|
|
@@ -5753,7 +5770,7 @@ function MultiTextFilterChip({
|
|
|
5753
5770
|
}) {
|
|
5754
5771
|
const { label, placeholder } = definition;
|
|
5755
5772
|
const tokens = asMultiTextValue(value);
|
|
5756
|
-
const [draft, setDraft] =
|
|
5773
|
+
const [draft, setDraft] = React11.useState("");
|
|
5757
5774
|
const displayLabel = tokens.length === 0 ? "Any" : tokens.length === 1 ? tokens[0] : `${tokens.length} values`;
|
|
5758
5775
|
function addToken() {
|
|
5759
5776
|
const token = draft.trim();
|
|
@@ -5941,7 +5958,7 @@ function ViewFilter({
|
|
|
5941
5958
|
onColumnFiltersChange,
|
|
5942
5959
|
className
|
|
5943
5960
|
}) {
|
|
5944
|
-
const filterableColumns =
|
|
5961
|
+
const filterableColumns = React12.useMemo(
|
|
5945
5962
|
() => columns.filter((column) => column.getCanFilter()).flatMap((column) => {
|
|
5946
5963
|
var _a;
|
|
5947
5964
|
const filter = (_a = column.columnDef.meta) == null ? void 0 : _a.filter;
|
|
@@ -5949,7 +5966,7 @@ function ViewFilter({
|
|
|
5949
5966
|
}),
|
|
5950
5967
|
[columns]
|
|
5951
5968
|
);
|
|
5952
|
-
const filterDefinitions =
|
|
5969
|
+
const filterDefinitions = React12.useMemo(
|
|
5953
5970
|
() => filterableColumns.map(({ key, filter }) => toFilterBarDefinition(key, filter)).sort((a, b) => {
|
|
5954
5971
|
if (a.order == null && b.order == null) return 0;
|
|
5955
5972
|
if (a.order == null) return 1;
|
|
@@ -5958,11 +5975,11 @@ function ViewFilter({
|
|
|
5958
5975
|
}),
|
|
5959
5976
|
[filterableColumns]
|
|
5960
5977
|
);
|
|
5961
|
-
const emptyValueByKey =
|
|
5978
|
+
const emptyValueByKey = React12.useMemo(
|
|
5962
5979
|
() => new Map(filterableColumns.map(({ key, filter }) => [key, emptyValueFor(filter)])),
|
|
5963
5980
|
[filterableColumns]
|
|
5964
5981
|
);
|
|
5965
|
-
const activeFilters =
|
|
5982
|
+
const activeFilters = React12.useMemo(
|
|
5966
5983
|
() => columnFilters.map((filter) => ({ key: filter.id, value: filter.value })),
|
|
5967
5984
|
[columnFilters]
|
|
5968
5985
|
);
|
|
@@ -6033,6 +6050,9 @@ import { Fragment as Fragment9, jsx as jsx18, jsxs as jsxs15 } from "react/jsx-r
|
|
|
6033
6050
|
var DEFAULT_PAGE_SIZE = 20;
|
|
6034
6051
|
var noop = () => {
|
|
6035
6052
|
};
|
|
6053
|
+
function isSamePage(a, b) {
|
|
6054
|
+
return a.pageIndex === b.pageIndex && a.pageSize === b.pageSize;
|
|
6055
|
+
}
|
|
6036
6056
|
var STICKY_HEADER_MAX_HEIGHT_CLASS = "max-h-[calc(100svh-250px)]";
|
|
6037
6057
|
function DataTable({
|
|
6038
6058
|
id,
|
|
@@ -6089,19 +6109,19 @@ function DataTable({
|
|
|
6089
6109
|
}) {
|
|
6090
6110
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
6091
6111
|
const isGrid = layout === "grid";
|
|
6092
|
-
const tableBodyScrollRef =
|
|
6093
|
-
const [innerGlobalFilter, setInnerGlobalFilter] =
|
|
6094
|
-
const [innerColumnOrdering, setInnerColumnOrdering] =
|
|
6095
|
-
const [innerColumnFilters, setInnerColumnFilters] =
|
|
6096
|
-
const [innerSorting, setInnerSorting] =
|
|
6097
|
-
const [innerColumnPinning, setInnerColumnPinning] =
|
|
6098
|
-
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({
|
|
6099
6119
|
pageIndex: ((_c = (_b = config.state) == null ? void 0 : _b.pagination) == null ? void 0 : _c.pageIndex) || 0,
|
|
6100
6120
|
pageSize: ((_e = (_d = config.state) == null ? void 0 : _d.pagination) == null ? void 0 : _e.pageSize) || DEFAULT_PAGE_SIZE
|
|
6101
6121
|
});
|
|
6102
|
-
const [innerGrouping, setInnerGrouping] =
|
|
6103
|
-
const [innerColumnVisibility, setInnerColumnVisibility] =
|
|
6104
|
-
const [innerExpanded, setInnerExpanded] =
|
|
6122
|
+
const [innerGrouping, setInnerGrouping] = React13.useState([]);
|
|
6123
|
+
const [innerColumnVisibility, setInnerColumnVisibility] = React13.useState({});
|
|
6124
|
+
const [innerExpanded, setInnerExpanded] = React13.useState({});
|
|
6105
6125
|
const {
|
|
6106
6126
|
columnSizing,
|
|
6107
6127
|
handleColumnSizingChange,
|
|
@@ -6128,25 +6148,36 @@ function DataTable({
|
|
|
6128
6148
|
const pagination = parentPagination || innerPagination;
|
|
6129
6149
|
const setPagination = parentSetPagination != null ? parentSetPagination : setInnerPagination;
|
|
6130
6150
|
const shouldDisablePagination = paginationConfig === false;
|
|
6131
|
-
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(() => {
|
|
6132
6163
|
if (!serverSidePagination || pagination.pageIndex === 0) return;
|
|
6133
6164
|
setPagination((prev) => __spreadProps(__spreadValues({}, prev), { pageIndex: 0 }));
|
|
6134
6165
|
}, [serverSidePagination, pagination.pageIndex, setPagination]);
|
|
6135
|
-
const setGlobalFilter =
|
|
6166
|
+
const setGlobalFilter = React13.useCallback(
|
|
6136
6167
|
(value) => {
|
|
6137
6168
|
applyGlobalFilter(value);
|
|
6138
6169
|
resetPageIndexOnFilterChange();
|
|
6139
6170
|
},
|
|
6140
6171
|
[applyGlobalFilter, resetPageIndexOnFilterChange]
|
|
6141
6172
|
);
|
|
6142
|
-
const setColumnFilters =
|
|
6173
|
+
const setColumnFilters = React13.useCallback(
|
|
6143
6174
|
(value) => {
|
|
6144
6175
|
applyColumnFilters(value);
|
|
6145
6176
|
resetPageIndexOnFilterChange();
|
|
6146
6177
|
},
|
|
6147
6178
|
[applyColumnFilters, resetPageIndexOnFilterChange]
|
|
6148
6179
|
);
|
|
6149
|
-
|
|
6180
|
+
React13.useLayoutEffect(() => {
|
|
6150
6181
|
var _a2;
|
|
6151
6182
|
if (shouldDisablePagination) return;
|
|
6152
6183
|
(_a2 = tableBodyScrollRef.current) == null ? void 0 : _a2.scrollTo({ top: 0 });
|
|
@@ -6170,8 +6201,8 @@ function DataTable({
|
|
|
6170
6201
|
const hasExternalSearch = parentGlobalFilter !== void 0;
|
|
6171
6202
|
const hasExternalFilters = parentColumnFilters !== void 0;
|
|
6172
6203
|
const shouldDisableFiltersModels = !!disableFilters && !!disableSearch && !hasExternalSearch && !hasExternalFilters;
|
|
6173
|
-
const columns =
|
|
6174
|
-
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), {
|
|
6175
6206
|
columns,
|
|
6176
6207
|
features: dataTableFeatures,
|
|
6177
6208
|
// Row models are registered statically in `dataTableFeatures`, so a disabled stage is switched
|
|
@@ -6230,7 +6261,7 @@ function DataTable({
|
|
|
6230
6261
|
const orderedVisibleColumns = table.getVisibleLeafColumns().filter((col) => !isFilterOnlyColumn(col));
|
|
6231
6262
|
const hasFilters = !!celFilterConfig || hasFilterableColumns(flatColumns);
|
|
6232
6263
|
const showFilterToggle = filterToggleRequested && !disableFilters && hasFilters;
|
|
6233
|
-
const [gridMeasuredMins, setGridMeasuredMins] =
|
|
6264
|
+
const [gridMeasuredMins, setGridMeasuredMins] = React13.useState({});
|
|
6234
6265
|
const { gridTemplateColumns, gridRootRef, handleAutosizeAll, handleAutosizeColumn, handleResetColumnSize } = useGridLayout({
|
|
6235
6266
|
layout,
|
|
6236
6267
|
table,
|
|
@@ -6244,7 +6275,7 @@ function DataTable({
|
|
|
6244
6275
|
rawHandleAutosizeColumn,
|
|
6245
6276
|
rawHandleResetColumnSize
|
|
6246
6277
|
});
|
|
6247
|
-
const handleContextCell =
|
|
6278
|
+
const handleContextCell = React13.useCallback(
|
|
6248
6279
|
(filter, cell) => {
|
|
6249
6280
|
var _a2, _b2;
|
|
6250
6281
|
if (celFilterConfig == null ? void 0 : celFilterConfig.onContextualFilter) {
|
|
@@ -6261,13 +6292,13 @@ function DataTable({
|
|
|
6261
6292
|
},
|
|
6262
6293
|
[celFilterConfig, onContextCell, setColumnFilters, table]
|
|
6263
6294
|
);
|
|
6264
|
-
const handleContextSearch =
|
|
6295
|
+
const handleContextSearch = React13.useCallback(
|
|
6265
6296
|
(searchTerm) => {
|
|
6266
6297
|
setGlobalFilter(searchTerm);
|
|
6267
6298
|
},
|
|
6268
6299
|
[setGlobalFilter]
|
|
6269
6300
|
);
|
|
6270
|
-
const totalTableWidth =
|
|
6301
|
+
const totalTableWidth = React13.useMemo(() => {
|
|
6271
6302
|
if (isGrid) return 0;
|
|
6272
6303
|
const firstGroup = headerGroups[0];
|
|
6273
6304
|
if (!firstGroup) return 0;
|
|
@@ -6280,7 +6311,7 @@ function DataTable({
|
|
|
6280
6311
|
return getColumnFilterCount(value, (_b2 = (_a2 = table.getColumn(columnFilterId)) == null ? void 0 : _a2.columnDef.meta) == null ? void 0 : _b2.filter);
|
|
6281
6312
|
}
|
|
6282
6313
|
).reduce((prev, curr) => prev + curr, 0);
|
|
6283
|
-
const tableState = getTableState({ error: !!showError, loading, rowCount });
|
|
6314
|
+
const tableState = getTableState({ error: !!showError, loading: loading && !pageLoading, rowCount });
|
|
6284
6315
|
const shouldDisable = tableState === "error";
|
|
6285
6316
|
const shouldRenderTableContent = tableState !== "error" && tableState !== "empty";
|
|
6286
6317
|
const resetFilters = () => {
|
|
@@ -6291,7 +6322,7 @@ function DataTable({
|
|
|
6291
6322
|
}
|
|
6292
6323
|
setGlobalFilter("");
|
|
6293
6324
|
};
|
|
6294
|
-
|
|
6325
|
+
React13.useEffect(() => {
|
|
6295
6326
|
if (disableColumnReordering) return;
|
|
6296
6327
|
const allColumnIds = flatColumns.map((col) => col.id);
|
|
6297
6328
|
const normalizedColumnOrdering = normalizeColumnOrdering(columnOrdering, allColumnIds);
|
|
@@ -6417,12 +6448,13 @@ function DataTable({
|
|
|
6417
6448
|
DataTablePagination,
|
|
6418
6449
|
{
|
|
6419
6450
|
rowCount,
|
|
6420
|
-
rowCountRelation: (_g =
|
|
6451
|
+
rowCountRelation: (_g = shownConfig.rowCountRelation) != null ? _g : "eq",
|
|
6421
6452
|
paginationConfig,
|
|
6453
|
+
loading: pageLoading,
|
|
6422
6454
|
pageSize: pagination.pageSize,
|
|
6423
6455
|
pageIndex: pagination.pageIndex,
|
|
6424
|
-
onPageChange: (p) =>
|
|
6425
|
-
onPageSizeChange: (
|
|
6456
|
+
onPageChange: (p) => requestPage(__spreadProps(__spreadValues({}, pagination), { pageIndex: p - 1 })),
|
|
6457
|
+
onPageSizeChange: (pageSize) => requestPage({ pageIndex: 0, pageSize })
|
|
6426
6458
|
}
|
|
6427
6459
|
)
|
|
6428
6460
|
] }) : /* @__PURE__ */ jsx18(
|
|
@@ -6445,19 +6477,19 @@ import {
|
|
|
6445
6477
|
} from "@tanstack/react-table";
|
|
6446
6478
|
|
|
6447
6479
|
// src/floating-widget.tsx
|
|
6448
|
-
import * as
|
|
6480
|
+
import * as React14 from "react";
|
|
6449
6481
|
import { Button as Button9 } from "@upbound/monarch-core";
|
|
6450
6482
|
import { DropdownMenu as DropdownMenu6, DropdownMenuContent as DropdownMenuContent6, DropdownMenuTrigger as DropdownMenuTrigger6 } from "@upbound/monarch-core";
|
|
6451
6483
|
import { Icon as Icon12 } from "@upbound/monarch-core";
|
|
6452
6484
|
import { Kbd as Kbd2 } from "@upbound/monarch-core";
|
|
6453
6485
|
import { Tooltip as Tooltip8, TooltipContent as TooltipContent7, TooltipTrigger as TooltipTrigger7 } from "@upbound/monarch-core";
|
|
6454
6486
|
import { jsx as jsx19, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6455
|
-
var FloatingWidgetContext =
|
|
6487
|
+
var FloatingWidgetContext = React14.createContext(null);
|
|
6456
6488
|
function FloatingWidgetProvider({ children }) {
|
|
6457
|
-
const [isOpen, setIsOpen] =
|
|
6458
|
-
const [isCollapsed, setIsCollapsed] =
|
|
6459
|
-
const [isExpanded, setIsExpanded] =
|
|
6460
|
-
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(
|
|
6461
6493
|
() => ({
|
|
6462
6494
|
isOpen,
|
|
6463
6495
|
isCollapsed,
|
|
@@ -6492,7 +6524,7 @@ function FloatingWidgetProvider({ children }) {
|
|
|
6492
6524
|
return /* @__PURE__ */ jsx19(FloatingWidgetContext.Provider, { value, children });
|
|
6493
6525
|
}
|
|
6494
6526
|
function useFloatingWidget() {
|
|
6495
|
-
const ctx =
|
|
6527
|
+
const ctx = React14.useContext(FloatingWidgetContext);
|
|
6496
6528
|
if (!ctx) {
|
|
6497
6529
|
throw new Error("useFloatingWidget must be used inside <FloatingWidgetProvider>.");
|
|
6498
6530
|
}
|
|
@@ -6500,14 +6532,14 @@ function useFloatingWidget() {
|
|
|
6500
6532
|
}
|
|
6501
6533
|
function FloatingWidget({ title = "Ask AI", subtitle, menuItems, children, className }) {
|
|
6502
6534
|
const { isOpen, isCollapsed, isExpanded, close, collapse, restore, toggleExpand } = useFloatingWidget();
|
|
6503
|
-
const [dragWidth, setDragWidth] =
|
|
6504
|
-
const [isDragging, setIsDragging] =
|
|
6505
|
-
|
|
6535
|
+
const [dragWidth, setDragWidth] = React14.useState(null);
|
|
6536
|
+
const [isDragging, setIsDragging] = React14.useState(false);
|
|
6537
|
+
React14.useEffect(() => {
|
|
6506
6538
|
setDragWidth(null);
|
|
6507
6539
|
}, [isExpanded]);
|
|
6508
6540
|
const MIN_WIDTH = 420;
|
|
6509
|
-
const widgetRef =
|
|
6510
|
-
const handleResizeMouseDown =
|
|
6541
|
+
const widgetRef = React14.useRef(null);
|
|
6542
|
+
const handleResizeMouseDown = React14.useCallback((e) => {
|
|
6511
6543
|
var _a, _b;
|
|
6512
6544
|
e.preventDefault();
|
|
6513
6545
|
setIsDragging(true);
|
|
@@ -6527,7 +6559,7 @@ function FloatingWidget({ title = "Ask AI", subtitle, menuItems, children, class
|
|
|
6527
6559
|
window.addEventListener("mousemove", onMove);
|
|
6528
6560
|
window.addEventListener("mouseup", onUp);
|
|
6529
6561
|
}, []);
|
|
6530
|
-
|
|
6562
|
+
React14.useEffect(() => {
|
|
6531
6563
|
if (!isOpen) return;
|
|
6532
6564
|
function handleKeydown(e) {
|
|
6533
6565
|
if (e.key === "Escape") {
|
|
@@ -6621,7 +6653,7 @@ function FloatingWidget({ title = "Ask AI", subtitle, menuItems, children, class
|
|
|
6621
6653
|
}
|
|
6622
6654
|
|
|
6623
6655
|
// src/graph/graph-actions-provider.tsx
|
|
6624
|
-
import * as
|
|
6656
|
+
import * as React16 from "react";
|
|
6625
6657
|
|
|
6626
6658
|
// src/graph/hooks/useGraphActionsContext.ts
|
|
6627
6659
|
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
@@ -6635,10 +6667,10 @@ var useGraphActionsContext = () => {
|
|
|
6635
6667
|
};
|
|
6636
6668
|
|
|
6637
6669
|
// src/graph/hooks/useGraphActions.ts
|
|
6638
|
-
import { useCallback as useCallback10, useState as
|
|
6670
|
+
import { useCallback as useCallback10, useState as useState14 } from "react";
|
|
6639
6671
|
|
|
6640
6672
|
// src/graph/graph-node.tsx
|
|
6641
|
-
import * as
|
|
6673
|
+
import * as React15 from "react";
|
|
6642
6674
|
import { getIncomers, getOutgoers, Handle, Position as Position2 } from "reactflow";
|
|
6643
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";
|
|
6644
6676
|
|
|
@@ -6694,13 +6726,13 @@ function GraphNode(_a) {
|
|
|
6694
6726
|
const { nodes: originalNodes, edges: originalEdges } = useGraphActionsContext();
|
|
6695
6727
|
const nodes = originalNodes;
|
|
6696
6728
|
const edges = originalEdges;
|
|
6697
|
-
const handleClick =
|
|
6729
|
+
const handleClick = React15.useCallback(() => {
|
|
6698
6730
|
var _a3;
|
|
6699
6731
|
(_a3 = data == null ? void 0 : data.onClick) == null ? void 0 : _a3.call(data, id, data);
|
|
6700
6732
|
}, [data, id]);
|
|
6701
6733
|
const compact = (_a2 = data == null ? void 0 : data.compact) != null ? _a2 : false;
|
|
6702
6734
|
const state = (_b2 = data == null ? void 0 : data.state) != null ? _b2 : "default";
|
|
6703
|
-
const compactBadges =
|
|
6735
|
+
const compactBadges = React15.useMemo(() => {
|
|
6704
6736
|
const badges = data.badges.compact || [];
|
|
6705
6737
|
if (state === "paused") {
|
|
6706
6738
|
return [
|
|
@@ -6710,7 +6742,7 @@ function GraphNode(_a) {
|
|
|
6710
6742
|
}
|
|
6711
6743
|
return badges;
|
|
6712
6744
|
}, [data.badges.compact, state]);
|
|
6713
|
-
const defaultBadges =
|
|
6745
|
+
const defaultBadges = React15.useMemo(() => {
|
|
6714
6746
|
const badges = data.badges.default || [];
|
|
6715
6747
|
if (state === "paused") {
|
|
6716
6748
|
return [
|
|
@@ -6727,7 +6759,7 @@ function GraphNode(_a) {
|
|
|
6727
6759
|
}
|
|
6728
6760
|
return badges;
|
|
6729
6761
|
}, [data.badges.default, state]);
|
|
6730
|
-
const currentNode =
|
|
6762
|
+
const currentNode = React15.useMemo(
|
|
6731
6763
|
() => ({
|
|
6732
6764
|
id,
|
|
6733
6765
|
position: { x: 0, y: 0 },
|
|
@@ -6737,10 +6769,10 @@ function GraphNode(_a) {
|
|
|
6737
6769
|
}),
|
|
6738
6770
|
[id, data, props.type]
|
|
6739
6771
|
);
|
|
6740
|
-
const _hasIncomingEdge =
|
|
6772
|
+
const _hasIncomingEdge = React15.useMemo(() => {
|
|
6741
6773
|
return getIncomers(currentNode, nodes, edges).length > 0;
|
|
6742
6774
|
}, [currentNode, nodes, edges]);
|
|
6743
|
-
const hasOutgoingEdge =
|
|
6775
|
+
const hasOutgoingEdge = React15.useMemo(() => {
|
|
6744
6776
|
return getOutgoers(currentNode, nodes, edges).length > 0;
|
|
6745
6777
|
}, [currentNode, nodes, edges]);
|
|
6746
6778
|
const targetX = GRAPH_NODE_WIDTH / 2 - 4;
|
|
@@ -6926,8 +6958,8 @@ function GraphNodeSkeleton(_props) {
|
|
|
6926
6958
|
|
|
6927
6959
|
// src/graph/hooks/useGraphActions.ts
|
|
6928
6960
|
var useGraphActions = (initialNodes = [], initialEdges = []) => {
|
|
6929
|
-
const [nodes, setNodes] =
|
|
6930
|
-
const [edges, setEdges] =
|
|
6961
|
+
const [nodes, setNodes] = useState14(initialNodes);
|
|
6962
|
+
const [edges, setEdges] = useState14(initialEdges);
|
|
6931
6963
|
const addNodes = useCallback10((newNodes) => {
|
|
6932
6964
|
setNodes((prevNodes) => {
|
|
6933
6965
|
const existingIds = new Set(prevNodes.map((node) => node.id));
|
|
@@ -6989,10 +7021,10 @@ var useGraphActions = (initialNodes = [], initialEdges = []) => {
|
|
|
6989
7021
|
|
|
6990
7022
|
// src/graph/graph-actions-provider.tsx
|
|
6991
7023
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
6992
|
-
var GraphActionsProvider =
|
|
7024
|
+
var GraphActionsProvider = React16.forwardRef(
|
|
6993
7025
|
({ initialNodes = [], initialEdges = [], children }, ref) => {
|
|
6994
7026
|
const graphActions = useGraphActions(initialNodes, initialEdges);
|
|
6995
|
-
|
|
7027
|
+
React16.useImperativeHandle(
|
|
6996
7028
|
ref,
|
|
6997
7029
|
() => ({
|
|
6998
7030
|
addNodes: graphActions.addNodes,
|
|
@@ -7011,12 +7043,12 @@ var GraphActionsProvider = React15.forwardRef(
|
|
|
7011
7043
|
GraphActionsProvider.displayName = "GraphActionsProvider";
|
|
7012
7044
|
|
|
7013
7045
|
// src/graph/graph.tsx
|
|
7014
|
-
import * as
|
|
7046
|
+
import * as React19 from "react";
|
|
7015
7047
|
import { useTable as useTable2 } from "@tanstack/react-table";
|
|
7016
7048
|
import { Icon as Icon14 } from "@upbound/monarch-core";
|
|
7017
7049
|
|
|
7018
7050
|
// src/graph/graph-view.tsx
|
|
7019
|
-
import * as
|
|
7051
|
+
import * as React18 from "react";
|
|
7020
7052
|
import { Background, Controls, MiniMap, ReactFlow, ReactFlowProvider } from "reactflow";
|
|
7021
7053
|
|
|
7022
7054
|
// src/graph/hooks/useAutoLayout.ts
|
|
@@ -7224,7 +7256,7 @@ var useNodeVisibility = (nodes, edges) => {
|
|
|
7224
7256
|
};
|
|
7225
7257
|
|
|
7226
7258
|
// src/graph/hooks/useViewportFocus.ts
|
|
7227
|
-
import * as
|
|
7259
|
+
import * as React17 from "react";
|
|
7228
7260
|
import { useReactFlow, useStore } from "reactflow";
|
|
7229
7261
|
function getViewportFocusCenter(node) {
|
|
7230
7262
|
var _a;
|
|
@@ -7239,7 +7271,7 @@ function useViewportFocus(nodeMap, viewportFocusNodeId) {
|
|
|
7239
7271
|
const { setCenter } = useReactFlow();
|
|
7240
7272
|
const viewportReady = useStore((state) => state.width > 0 && state.height > 0);
|
|
7241
7273
|
const node = viewportFocusNodeId ? nodeMap.get(viewportFocusNodeId) : void 0;
|
|
7242
|
-
|
|
7274
|
+
React17.useEffect(() => {
|
|
7243
7275
|
if (!node || !viewportReady) {
|
|
7244
7276
|
return;
|
|
7245
7277
|
}
|
|
@@ -7260,21 +7292,21 @@ var GraphViewInternal = ({
|
|
|
7260
7292
|
hideControls = false
|
|
7261
7293
|
}) => {
|
|
7262
7294
|
const { nodes, edges, toggleNodeExpansion } = useGraphActionsContext();
|
|
7263
|
-
const nodeTypes =
|
|
7295
|
+
const nodeTypes = React18.useMemo(
|
|
7264
7296
|
() => __spreadValues({
|
|
7265
7297
|
default: GraphNode,
|
|
7266
7298
|
loading: GraphNodeSkeleton
|
|
7267
7299
|
}, parentNodeTypes),
|
|
7268
7300
|
[parentNodeTypes]
|
|
7269
7301
|
);
|
|
7270
|
-
const edgeTypes =
|
|
7302
|
+
const edgeTypes = React18.useMemo(
|
|
7271
7303
|
() => __spreadValues({
|
|
7272
7304
|
default: GraphEdge
|
|
7273
7305
|
}, parentEdgeTypes),
|
|
7274
7306
|
[parentEdgeTypes]
|
|
7275
7307
|
);
|
|
7276
7308
|
const { nodes: visibleNodes, edges: visibleEdges } = useNodeVisibility(nodes, edges);
|
|
7277
|
-
const nodesWithExpansion =
|
|
7309
|
+
const nodesWithExpansion = React18.useMemo(() => {
|
|
7278
7310
|
return visibleNodes.map((node) => {
|
|
7279
7311
|
if (isDefaultNode(node) && !node.data.onExpandToggle) {
|
|
7280
7312
|
return __spreadProps(__spreadValues({}, node), {
|
|
@@ -7322,7 +7354,7 @@ var GraphViewInternal = ({
|
|
|
7322
7354
|
}
|
|
7323
7355
|
);
|
|
7324
7356
|
};
|
|
7325
|
-
var GraphView =
|
|
7357
|
+
var GraphView = React18.forwardRef(
|
|
7326
7358
|
({
|
|
7327
7359
|
defaultNodes = [],
|
|
7328
7360
|
defaultEdges = [],
|
|
@@ -7390,9 +7422,9 @@ function Graph({
|
|
|
7390
7422
|
children
|
|
7391
7423
|
}) {
|
|
7392
7424
|
var _a, _b, _c;
|
|
7393
|
-
const graphRef =
|
|
7394
|
-
const [innerGlobalFilter, setInnerGlobalFilter] =
|
|
7395
|
-
const [innerColumnFilters, setInnerColumnFilters] =
|
|
7425
|
+
const graphRef = React19.useRef(null);
|
|
7426
|
+
const [innerGlobalFilter, setInnerGlobalFilter] = React19.useState("");
|
|
7427
|
+
const [innerColumnFilters, setInnerColumnFilters] = React19.useState([]);
|
|
7396
7428
|
if (parentGlobalFilter !== void 0 && parentGlobalFilter !== innerGlobalFilter) {
|
|
7397
7429
|
setInnerGlobalFilter(parentGlobalFilter);
|
|
7398
7430
|
}
|
|
@@ -7400,7 +7432,7 @@ function Graph({
|
|
|
7400
7432
|
const setGlobalFilter = parentSetGlobalFilter != null ? parentSetGlobalFilter : setInnerGlobalFilter;
|
|
7401
7433
|
const columnFilters = parentColumnFilters != null ? parentColumnFilters : innerColumnFilters;
|
|
7402
7434
|
const setColumnFilters = parentSetColumnFilters != null ? parentSetColumnFilters : setInnerColumnFilters;
|
|
7403
|
-
const columns =
|
|
7435
|
+
const columns = React19.useMemo(() => withDefaultFilterFns(columnDefinitions), [columnDefinitions]);
|
|
7404
7436
|
const table = useTable2({
|
|
7405
7437
|
features: dataTableFeatures,
|
|
7406
7438
|
data: config.data,
|
|
@@ -7412,7 +7444,7 @@ function Graph({
|
|
|
7412
7444
|
});
|
|
7413
7445
|
const flatColumns = table.getAllFlatColumns();
|
|
7414
7446
|
const filteredRows = table.getFilteredRowModel().rows;
|
|
7415
|
-
const filteredData =
|
|
7447
|
+
const filteredData = React19.useMemo(() => filteredRows.map((row) => row.original), [filteredRows]);
|
|
7416
7448
|
const filterCount = columnFilters.map(
|
|
7417
7449
|
({ id: columnFilterId, value }) => {
|
|
7418
7450
|
var _a2, _b2;
|
|
@@ -7426,10 +7458,10 @@ function Graph({
|
|
|
7426
7458
|
setColumnFilters([]);
|
|
7427
7459
|
setGlobalFilter("");
|
|
7428
7460
|
};
|
|
7429
|
-
const memoizedNodeTypes =
|
|
7430
|
-
const memoizedEdgeTypes =
|
|
7431
|
-
const memoizedConfig =
|
|
7432
|
-
|
|
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(() => {
|
|
7433
7465
|
if (!graphRef.current) {
|
|
7434
7466
|
return;
|
|
7435
7467
|
}
|
|
@@ -7492,11 +7524,11 @@ function Graph({
|
|
|
7492
7524
|
}
|
|
7493
7525
|
|
|
7494
7526
|
// src/graph/hooks/useGetViewportNodeIds.ts
|
|
7495
|
-
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";
|
|
7496
7528
|
import { useStore as useStore2, useViewport } from "reactflow";
|
|
7497
7529
|
var useGetDebouncedViewport = (debounceDelay = 1e3) => {
|
|
7498
7530
|
const timerRef = useRef11(null);
|
|
7499
|
-
const [debouncedValues, setDebouncedValues] =
|
|
7531
|
+
const [debouncedValues, setDebouncedValues] = useState16({ x: 0, y: 0, zoom: 1, width: 0, height: 0, nodes: [] });
|
|
7500
7532
|
const { x, y, zoom } = useViewport();
|
|
7501
7533
|
const { width, height, nodes } = useStore2((state) => ({
|
|
7502
7534
|
width: state.width,
|