@upbound/monarch-blocks 0.6.0 → 0.7.1
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/cel-filter-bar.js +2 -32
- package/dist/cel-filter-bar.js.map +1 -1
- package/dist/chart.js +1 -31
- package/dist/chart.js.map +1 -1
- package/dist/chat-interface.js +1 -31
- package/dist/chat-interface.js.map +1 -1
- package/dist/code-block.d.ts +20 -5
- package/dist/code-block.js +71 -43
- package/dist/code-block.js.map +1 -1
- package/dist/data-table.d.ts +10 -1
- package/dist/data-table.js +10 -39
- package/dist/data-table.js.map +1 -1
- package/dist/filter-bar.js +2 -32
- package/dist/filter-bar.js.map +1 -1
- package/dist/floating-widget.js +1 -31
- package/dist/floating-widget.js.map +1 -1
- package/dist/graph.js +45 -68
- package/dist/graph.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +128 -92
- package/dist/index.js.map +1 -1
- package/dist/page-header.js +1 -31
- package/dist/page-header.js.map +1 -1
- package/dist/relative-time.js +1 -31
- package/dist/relative-time.js.map +1 -1
- package/dist/section-header.js +1 -31
- package/dist/section-header.js.map +1 -1
- package/dist/section-nav.js +1 -31
- package/dist/section-nav.js.map +1 -1
- package/dist/timeline.js +1 -31
- package/dist/timeline.js.map +1 -1
- package/package.json +4 -5
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { CelFilterBar, RELATIVE_DURATION_PRESET_VALUES, allowsMultipleConditions
|
|
|
2
2
|
export { C as CelColumnDefinition, a as CelColumnOption, b as CelConditionValue, c as CelFilterBarProps, d as CelFilterCondition, e as CelFilterGroup, f as CelFilterSchema, g as CelFilterTree, h as CelOperator, i as CelRestrictedOptionSelectPayload, j as CheckboxCelValue, k as CompileResult, D as DateCelValue, M as MapKeyCelValue, l as MultiTextCelValue, P as PillActiveSurface, R as RadioCelValue, m as RelativeDurationPreset, V as ValidationIssue, n as isCelFilterCondition, o as isCelFilterGroup, p as isCheckboxCelValue, q as isDateCelValue, r as isMapKeyCelValue, s as isMultiTextCelValue } from './types-BULiU2qC.js';
|
|
3
3
|
export { ChartAction, ChartConfig, ChartContainer, ChartDescription, ChartFooter, ChartHeader, ChartLegend, ChartLegendContent, ChartStyle, ChartTitle, ChartTooltip, ChartTooltipContent } from './chart.js';
|
|
4
4
|
export { ChatInput, ChatInputProps, ChatInterface, ChatInterfaceProps, ChatMessage, ChatMessageBubble, ChatRoutine, ChatSession, ChatSessionList, ChatSessionListProps, ChatThread, ChatThreadProps, ChatToolCall } from './chat-interface.js';
|
|
5
|
-
export { CodeBlock, CodeBlockBody, CodeBlockCopyButton, CodeBlockDownloadButton, CodeBlockFooter, CodeBlockHeader } from './code-block.js';
|
|
5
|
+
export { CodeBlock, CodeBlockBody, CodeBlockCode, CodeBlockCopyButton, CodeBlockDownloadButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLanguage } from './code-block.js';
|
|
6
6
|
export { CellContextualFilter, CellContextualFilterProps, ColumnOptions, ColumnOptionsProps, ContextualMenuAction, DataTable, DataTableBody, DataTableCelFilterConfig, DataTableCell, DataTableExpandedRow, DataTableFilterVisibilityConfig, DataTableGroupRow, DataTableHeader, DataTablePagination, DataTablePaginationConfig, DataTablePaginationProps, DataTableProps, DataTableRow, DataTableRowProps, DataTableSkeletonBody, DataTableValueCell, DataTableValueCellProps, ExpandButton, RowActionItem, RowActions, RowCountRelation, StickyHeaderConfig, TableHookOptions, TableLayout, TimestampCell, ViewFilter, ViewFilterProps, getActionsColumnDefinition, getExpandColumnDefinition, normalizePageSizeOptions } from './data-table.js';
|
|
7
7
|
export { D as DataTableEmptyConfig, a as DataTableEmptyView, d as defaultEmptyConfig, b as defaultErrorConfig, c as defaultNoFilterFoundConfig } from './empty-view-DO36LNvk.js';
|
|
8
8
|
export { ActiveFilter, CheckboxFilterDefinition, CheckboxFilterValue, DateFilterDefinition, DateFilterValue, FilterBar, FilterBarProps, FilterChip, FilterDefinition, FilterOption, FilterType, FilterValue, MultiTextFilterDefinition, MultiTextFilterValue, RadioFilterDefinition, RadioFilterValue, TextFilterDefinition, TextFilterValue } from './filter-bar.js';
|
package/dist/index.js
CHANGED
|
@@ -36,37 +36,7 @@ import * as React from "react";
|
|
|
36
36
|
import { Icon } from "@upbound/monarch-core";
|
|
37
37
|
|
|
38
38
|
// src/lib/utils.ts
|
|
39
|
-
import {
|
|
40
|
-
import { extendTailwindMerge } from "tailwind-merge";
|
|
41
|
-
var twMerge = extendTailwindMerge({
|
|
42
|
-
extend: {
|
|
43
|
-
classGroups: {
|
|
44
|
-
"font-size": [
|
|
45
|
-
{
|
|
46
|
-
text: [
|
|
47
|
-
"display-hero",
|
|
48
|
-
"display-kpi-sm",
|
|
49
|
-
"display-kpi",
|
|
50
|
-
"display-kpi-lg",
|
|
51
|
-
"display-feature",
|
|
52
|
-
"h1",
|
|
53
|
-
"h2",
|
|
54
|
-
"h3",
|
|
55
|
-
"h4",
|
|
56
|
-
"body-lg",
|
|
57
|
-
"body",
|
|
58
|
-
"body-sm",
|
|
59
|
-
"caption",
|
|
60
|
-
"eyebrow"
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
function cn(...inputs) {
|
|
68
|
-
return twMerge(clsx(inputs));
|
|
69
|
-
}
|
|
39
|
+
import { cn } from "@upbound/monarch-core/utils";
|
|
70
40
|
function sortBy(items, getKey) {
|
|
71
41
|
return [...items].sort((a, b) => getKey(a).localeCompare(getKey(b)));
|
|
72
42
|
}
|
|
@@ -1296,7 +1266,7 @@ function CelAddFilterButton({
|
|
|
1296
1266
|
if (column) onSelect(column.id);
|
|
1297
1267
|
},
|
|
1298
1268
|
children: [
|
|
1299
|
-
/* @__PURE__ */ jsxs(ComboboxTrigger, { "aria-label": "Add filter", render: /* @__PURE__ */ jsx(Button, { variant: "outline" }), children: [
|
|
1269
|
+
/* @__PURE__ */ jsxs(ComboboxTrigger, { "aria-label": "Add filter", showIndicator: false, render: /* @__PURE__ */ jsx(Button, { variant: "outline" }), children: [
|
|
1300
1270
|
/* @__PURE__ */ jsx(Icon, { name: "plus", "data-icon": "inline-start" }),
|
|
1301
1271
|
"Add filter"
|
|
1302
1272
|
] }),
|
|
@@ -2892,7 +2862,7 @@ function ChatInterface(_a) {
|
|
|
2892
2862
|
}
|
|
2893
2863
|
|
|
2894
2864
|
// src/code-block.tsx
|
|
2895
|
-
import { useState as useState5 } from "react";
|
|
2865
|
+
import { useEffect as useEffect3, useState as useState5 } from "react";
|
|
2896
2866
|
import { Icon as Icon3 } from "@upbound/monarch-core";
|
|
2897
2867
|
import {
|
|
2898
2868
|
Card,
|
|
@@ -2903,6 +2873,36 @@ import {
|
|
|
2903
2873
|
TooltipContent as TooltipContent2,
|
|
2904
2874
|
TooltipTrigger as TooltipTrigger2
|
|
2905
2875
|
} from "@upbound/monarch-core";
|
|
2876
|
+
|
|
2877
|
+
// src/lib/highlight.ts
|
|
2878
|
+
import { createHighlighter } from "shiki";
|
|
2879
|
+
var CODE_BLOCK_LANGUAGES = ["tsx", "typescript", "bash", "shell", "json", "css", "yaml"];
|
|
2880
|
+
var HIGHLIGHTER_KEY = "__monarch_shiki_highlighter__";
|
|
2881
|
+
function getHighlighter() {
|
|
2882
|
+
const g = globalThis;
|
|
2883
|
+
if (!g[HIGHLIGHTER_KEY]) {
|
|
2884
|
+
g[HIGHLIGHTER_KEY] = createHighlighter({
|
|
2885
|
+
themes: ["github-light-high-contrast", "github-dark-dimmed"],
|
|
2886
|
+
langs: [...CODE_BLOCK_LANGUAGES]
|
|
2887
|
+
}).catch((error) => {
|
|
2888
|
+
delete g[HIGHLIGHTER_KEY];
|
|
2889
|
+
throw error;
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
return g[HIGHLIGHTER_KEY];
|
|
2893
|
+
}
|
|
2894
|
+
async function highlightCode(code, lang) {
|
|
2895
|
+
const hl = await getHighlighter();
|
|
2896
|
+
return hl.codeToHtml(code, {
|
|
2897
|
+
lang,
|
|
2898
|
+
themes: {
|
|
2899
|
+
light: "github-light-high-contrast",
|
|
2900
|
+
dark: "github-dark-dimmed"
|
|
2901
|
+
}
|
|
2902
|
+
});
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
// src/code-block.tsx
|
|
2906
2906
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2907
2907
|
function CodeBlock(_a) {
|
|
2908
2908
|
var _b = _a, {
|
|
@@ -2943,24 +2943,48 @@ function CodeBlockHeader(_a) {
|
|
|
2943
2943
|
}, props)
|
|
2944
2944
|
);
|
|
2945
2945
|
}
|
|
2946
|
+
var LINE_NUMBER_GUTTER = cn(
|
|
2947
|
+
"[&_code]:[counter-reset:line]",
|
|
2948
|
+
"[&_.line]:before:[counter-increment:line]",
|
|
2949
|
+
"[&_.line]:before:content-[counter(line)]",
|
|
2950
|
+
"[&_.line]:before:inline-block",
|
|
2951
|
+
"[&_.line]:before:w-6",
|
|
2952
|
+
"[&_.line]:before:mr-3",
|
|
2953
|
+
"[&_.line]:before:text-right",
|
|
2954
|
+
"[&_.line]:before:text-muted-foreground",
|
|
2955
|
+
"[&_.line]:before:text-[0.75rem]",
|
|
2956
|
+
"[&_.line]:before:select-none"
|
|
2957
|
+
);
|
|
2946
2958
|
function CodeBlockBody(_a) {
|
|
2947
2959
|
var _b = _a, {
|
|
2948
2960
|
className,
|
|
2949
2961
|
code,
|
|
2950
|
-
html,
|
|
2951
|
-
lineNumbers,
|
|
2952
2962
|
maxHeight,
|
|
2953
2963
|
copyButton,
|
|
2954
2964
|
downloadButton
|
|
2955
2965
|
} = _b, props = __objRest(_b, [
|
|
2956
2966
|
"className",
|
|
2957
2967
|
"code",
|
|
2958
|
-
"html",
|
|
2959
|
-
"lineNumbers",
|
|
2960
2968
|
"maxHeight",
|
|
2961
2969
|
"copyButton",
|
|
2962
2970
|
"downloadButton"
|
|
2963
2971
|
]);
|
|
2972
|
+
const { content, lineNumbers } = code;
|
|
2973
|
+
const [html, setHtml] = useState5(null);
|
|
2974
|
+
const language = code.type === "parsed" ? code.language : null;
|
|
2975
|
+
useEffect3(() => {
|
|
2976
|
+
if (!language) {
|
|
2977
|
+
setHtml(null);
|
|
2978
|
+
return;
|
|
2979
|
+
}
|
|
2980
|
+
let cancelled = false;
|
|
2981
|
+
highlightCode(content, language).then((result) => {
|
|
2982
|
+
if (!cancelled) setHtml(result);
|
|
2983
|
+
});
|
|
2984
|
+
return () => {
|
|
2985
|
+
cancelled = true;
|
|
2986
|
+
};
|
|
2987
|
+
}, [content, language]);
|
|
2964
2988
|
return /* @__PURE__ */ jsxs4(CardContent, __spreadProps(__spreadValues({ "data-line-numbers": lineNumbers || void 0, className: cn("relative p-0!", className) }, props), { children: [
|
|
2965
2989
|
(copyButton || downloadButton) && /* @__PURE__ */ jsxs4("div", { className: "absolute top-2 right-2 z-10 flex items-center gap-1 opacity-0 transition-opacity group-hover/code-block:opacity-100", children: [
|
|
2966
2990
|
copyButton,
|
|
@@ -2971,16 +2995,20 @@ function CodeBlockBody(_a) {
|
|
|
2971
2995
|
{
|
|
2972
2996
|
className: cn("overflow-x-auto", maxHeight && "overflow-y-auto"),
|
|
2973
2997
|
style: maxHeight ? { maxHeight } : void 0,
|
|
2974
|
-
children:
|
|
2998
|
+
children: /* @__PURE__ */ jsx6(
|
|
2975
2999
|
"div",
|
|
2976
3000
|
{
|
|
2977
|
-
className:
|
|
2978
|
-
|
|
3001
|
+
className: cn(
|
|
3002
|
+
"[&_code]:font-mono [&_pre]:m-0 [&_pre]:p-4 group-data-[size=sm]/code-block:[&_pre]:p-3",
|
|
3003
|
+
html && "[&_pre]:bg-transparent!",
|
|
3004
|
+
lineNumbers && LINE_NUMBER_GUTTER
|
|
3005
|
+
),
|
|
3006
|
+
children: html ? /* @__PURE__ */ jsx6("div", { dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ jsx6("pre", { children: /* @__PURE__ */ jsx6("code", { className: lineNumbers ? void 0 : "whitespace-pre", children: lineNumbers ? content.split("\n").map((line, i) => /* @__PURE__ */ jsxs4("span", { className: "line", children: [
|
|
3007
|
+
line,
|
|
3008
|
+
"\n"
|
|
3009
|
+
] }, i)) : content }) })
|
|
2979
3010
|
}
|
|
2980
|
-
)
|
|
2981
|
-
line,
|
|
2982
|
-
"\n"
|
|
2983
|
-
] }, i)) }) }) : /* @__PURE__ */ jsx6("pre", { className: "p-4 group-data-[size=sm]/code-block:p-3", children: /* @__PURE__ */ jsx6("code", { className: "font-mono whitespace-pre", children: code }) })
|
|
3011
|
+
)
|
|
2984
3012
|
}
|
|
2985
3013
|
)
|
|
2986
3014
|
] }));
|
|
@@ -3181,10 +3209,9 @@ import { Icon as Icon4 } from "@upbound/monarch-core";
|
|
|
3181
3209
|
// src/lib/data-table/utils.ts
|
|
3182
3210
|
var TO_EACH_SIDE = 2;
|
|
3183
3211
|
function normalizeColumnOrdering(columnOrdering, allColumnIds) {
|
|
3184
|
-
const validIds = new Set(allColumnIds);
|
|
3185
3212
|
const seenIds = /* @__PURE__ */ new Set();
|
|
3186
3213
|
const trackedColumnIds = columnOrdering.filter((columnId) => {
|
|
3187
|
-
if (
|
|
3214
|
+
if (seenIds.has(columnId)) return false;
|
|
3188
3215
|
seenIds.add(columnId);
|
|
3189
3216
|
return true;
|
|
3190
3217
|
});
|
|
@@ -3713,7 +3740,7 @@ function getColumnFilterCount(filterValue, filter) {
|
|
|
3713
3740
|
}
|
|
3714
3741
|
|
|
3715
3742
|
// src/hooks/use-table-column-resizing.ts
|
|
3716
|
-
import { useCallback as useCallback4, useEffect as
|
|
3743
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef3, useState as useState7 } from "react";
|
|
3717
3744
|
var RESIZE_MIN = 40;
|
|
3718
3745
|
var RESIZE_MAX = 500;
|
|
3719
3746
|
var RESIZE_MAX_UNBOUNDED = Number.MAX_SAFE_INTEGER;
|
|
@@ -3802,7 +3829,7 @@ function useTableColumnResizing({
|
|
|
3802
3829
|
} = {}) {
|
|
3803
3830
|
const [columnSizing, setColumnSizing] = useState7(() => clampSizing(initialSizing != null ? initialSizing : {}, maxSize));
|
|
3804
3831
|
const persistTimerRef = useRef3(null);
|
|
3805
|
-
|
|
3832
|
+
useEffect4(() => {
|
|
3806
3833
|
if (!initialSizing) return;
|
|
3807
3834
|
const next = clampSizing(initialSizing, maxSize);
|
|
3808
3835
|
setColumnSizing((prev) => {
|
|
@@ -3811,7 +3838,7 @@ function useTableColumnResizing({
|
|
|
3811
3838
|
return keys.every((k) => prev[k] === next[k]) ? prev : next;
|
|
3812
3839
|
});
|
|
3813
3840
|
}, [initialSizing, maxSize]);
|
|
3814
|
-
|
|
3841
|
+
useEffect4(() => {
|
|
3815
3842
|
return () => {
|
|
3816
3843
|
if (persistTimerRef.current) clearTimeout(persistTimerRef.current);
|
|
3817
3844
|
};
|
|
@@ -4523,9 +4550,9 @@ function DataTableSortIcon({ sortOrder }) {
|
|
|
4523
4550
|
return /* @__PURE__ */ jsx13(
|
|
4524
4551
|
Icon9,
|
|
4525
4552
|
{
|
|
4526
|
-
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
4527
4553
|
size: "xs",
|
|
4528
|
-
|
|
4554
|
+
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
4555
|
+
className: "text-foreground group-hover/col-actions:text-foreground group-data-[state=open]/col-actions:text-foreground mr-0.5 shrink-0"
|
|
4529
4556
|
}
|
|
4530
4557
|
);
|
|
4531
4558
|
}
|
|
@@ -4617,7 +4644,7 @@ function HeaderCellContent({
|
|
|
4617
4644
|
"aria-label": shouldShowActionsMenu ? headerTitle ? `${headerTitle} column actions` : "Column actions" : void 0,
|
|
4618
4645
|
className: cn(
|
|
4619
4646
|
"group/col-actions text-muted-foreground -mx-2 -my-1 flex min-w-0 items-center gap-1 truncate rounded-md px-2 py-1 text-left font-medium motion-safe:transition-colors",
|
|
4620
|
-
sorted && "text-
|
|
4647
|
+
sorted && "text-foreground",
|
|
4621
4648
|
shouldShowActionsMenu ? "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50 cursor-pointer" : "cursor-default"
|
|
4622
4649
|
),
|
|
4623
4650
|
children: [
|
|
@@ -5105,7 +5132,7 @@ function FilterBar(_a) {
|
|
|
5105
5132
|
if (filter) handleAddFilter(filter.key);
|
|
5106
5133
|
},
|
|
5107
5134
|
children: [
|
|
5108
|
-
/* @__PURE__ */ jsxs12(ComboboxTrigger2, { "aria-label": "Add filter", render: /* @__PURE__ */ jsx14(Button7, { variant: "outline" }), children: [
|
|
5135
|
+
/* @__PURE__ */ jsxs12(ComboboxTrigger2, { "aria-label": "Add filter", showIndicator: false, render: /* @__PURE__ */ jsx14(Button7, { variant: "outline" }), children: [
|
|
5109
5136
|
/* @__PURE__ */ jsx14(Icon10, { name: "plus", "data-icon": "inline-start" }),
|
|
5110
5137
|
"Add filter"
|
|
5111
5138
|
] }),
|
|
@@ -5683,6 +5710,7 @@ function SectionHeaderTabs(_a) {
|
|
|
5683
5710
|
// src/data-table/data-table.tsx
|
|
5684
5711
|
import { Fragment as Fragment9, jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
5685
5712
|
var DEFAULT_PAGE_SIZE = 20;
|
|
5713
|
+
var STICKY_HEADER_MAX_HEIGHT_CLASS = "max-h-[calc(100svh-250px)]";
|
|
5686
5714
|
function DataTable({
|
|
5687
5715
|
id,
|
|
5688
5716
|
config,
|
|
@@ -6020,9 +6048,10 @@ function DataTable({
|
|
|
6020
6048
|
"div",
|
|
6021
6049
|
{
|
|
6022
6050
|
ref: tableBodyScrollRef,
|
|
6051
|
+
"data-testid": "table-scroll-container",
|
|
6023
6052
|
className: cn(
|
|
6024
6053
|
"min-h-0 flex-1 overflow-auto rounded-lg border **:data-[slot=table-container]:overflow-visible",
|
|
6025
|
-
!!stickyHeader &&
|
|
6054
|
+
!!stickyHeader && !fitContent && STICKY_HEADER_MAX_HEIGHT_CLASS
|
|
6026
6055
|
),
|
|
6027
6056
|
children: /* @__PURE__ */ jsxs13(
|
|
6028
6057
|
DataTableRoot,
|
|
@@ -6660,7 +6689,7 @@ var GraphActionsProvider = React14.forwardRef(
|
|
|
6660
6689
|
GraphActionsProvider.displayName = "GraphActionsProvider";
|
|
6661
6690
|
|
|
6662
6691
|
// src/graph/graph.tsx
|
|
6663
|
-
import * as
|
|
6692
|
+
import * as React17 from "react";
|
|
6664
6693
|
import {
|
|
6665
6694
|
getCoreRowModel as getCoreRowModel2,
|
|
6666
6695
|
getFacetedRowModel as getFacetedRowModel2,
|
|
@@ -6671,15 +6700,8 @@ import {
|
|
|
6671
6700
|
import { Icon as Icon14, InputGroup as InputGroup4, InputGroupAddon as InputGroupAddon4, InputGroupInput as InputGroupInput3 } from "@upbound/monarch-core";
|
|
6672
6701
|
|
|
6673
6702
|
// src/graph/graph-view.tsx
|
|
6674
|
-
import * as
|
|
6675
|
-
import {
|
|
6676
|
-
Background,
|
|
6677
|
-
Controls,
|
|
6678
|
-
MiniMap,
|
|
6679
|
-
ReactFlow,
|
|
6680
|
-
ReactFlowProvider,
|
|
6681
|
-
useReactFlow
|
|
6682
|
-
} from "reactflow";
|
|
6703
|
+
import * as React16 from "react";
|
|
6704
|
+
import { Background, Controls, MiniMap, ReactFlow, ReactFlowProvider } from "reactflow";
|
|
6683
6705
|
|
|
6684
6706
|
// src/graph/hooks/useAutoLayout.ts
|
|
6685
6707
|
import { useMemo as useMemo10 } from "react";
|
|
@@ -6885,25 +6907,50 @@ var useNodeVisibility = (nodes, edges) => {
|
|
|
6885
6907
|
return { nodes: visibleNodes, edges: visibleEdges };
|
|
6886
6908
|
};
|
|
6887
6909
|
|
|
6910
|
+
// src/graph/hooks/useViewportFocus.ts
|
|
6911
|
+
import * as React15 from "react";
|
|
6912
|
+
import { useReactFlow, useStore } from "reactflow";
|
|
6913
|
+
function getViewportFocusCenter(node) {
|
|
6914
|
+
var _a;
|
|
6915
|
+
const compact = node.type !== "loading" && Boolean((_a = node.data) == null ? void 0 : _a.compact);
|
|
6916
|
+
const height = compact ? GRAPH_NODE_COLLAPSED_HEIGHT : GRAPH_NODE_HEIGHT;
|
|
6917
|
+
return {
|
|
6918
|
+
x: node.position.x + GRAPH_NODE_WIDTH / 2,
|
|
6919
|
+
y: node.position.y + height / 2
|
|
6920
|
+
};
|
|
6921
|
+
}
|
|
6922
|
+
function useViewportFocus(nodeMap, viewportFocusNodeId) {
|
|
6923
|
+
const { setCenter } = useReactFlow();
|
|
6924
|
+
const viewportReady = useStore((state) => state.width > 0 && state.height > 0);
|
|
6925
|
+
const node = viewportFocusNodeId ? nodeMap.get(viewportFocusNodeId) : void 0;
|
|
6926
|
+
React15.useEffect(() => {
|
|
6927
|
+
if (!node || !viewportReady) {
|
|
6928
|
+
return;
|
|
6929
|
+
}
|
|
6930
|
+
const { x, y } = getViewportFocusCenter(node);
|
|
6931
|
+
setCenter(x, y, { zoom: 1 });
|
|
6932
|
+
}, [node == null ? void 0 : node.id, viewportReady, setCenter]);
|
|
6933
|
+
}
|
|
6934
|
+
|
|
6888
6935
|
// src/graph/graph-view.tsx
|
|
6889
6936
|
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6890
6937
|
var GraphViewInternal = ({ nodeTypes: parentNodeTypes, edgeTypes: parentEdgeTypes, children, viewportFocusNodeId }) => {
|
|
6891
6938
|
const { nodes, edges, toggleNodeExpansion } = useGraphActionsContext();
|
|
6892
|
-
const nodeTypes =
|
|
6939
|
+
const nodeTypes = React16.useMemo(
|
|
6893
6940
|
() => __spreadValues({
|
|
6894
6941
|
default: GraphNode,
|
|
6895
6942
|
loading: GraphNodeSkeleton
|
|
6896
6943
|
}, parentNodeTypes),
|
|
6897
6944
|
[parentNodeTypes]
|
|
6898
6945
|
);
|
|
6899
|
-
const edgeTypes =
|
|
6946
|
+
const edgeTypes = React16.useMemo(
|
|
6900
6947
|
() => __spreadValues({
|
|
6901
6948
|
default: GraphEdge
|
|
6902
6949
|
}, parentEdgeTypes),
|
|
6903
6950
|
[parentEdgeTypes]
|
|
6904
6951
|
);
|
|
6905
6952
|
const { nodes: visibleNodes, edges: visibleEdges } = useNodeVisibility(nodes, edges);
|
|
6906
|
-
const nodesWithExpansion =
|
|
6953
|
+
const nodesWithExpansion = React16.useMemo(() => {
|
|
6907
6954
|
return visibleNodes.map((node) => {
|
|
6908
6955
|
if (isDefaultNode(node) && !node.data.onExpandToggle) {
|
|
6909
6956
|
return __spreadProps(__spreadValues({}, node), {
|
|
@@ -6950,21 +6997,10 @@ var GraphViewInternal = ({ nodeTypes: parentNodeTypes, edgeTypes: parentEdgeType
|
|
|
6950
6997
|
}
|
|
6951
6998
|
);
|
|
6952
6999
|
};
|
|
6953
|
-
var GraphView =
|
|
7000
|
+
var GraphView = React16.forwardRef(({ defaultNodes = [], defaultEdges = [], nodeTypes, edgeTypes, children, viewportFocusNodeId }, ref) => {
|
|
6954
7001
|
return /* @__PURE__ */ jsx22(ReactFlowProvider, { children: /* @__PURE__ */ jsx22(GraphActionsProvider, { ref, initialNodes: defaultNodes, initialEdges: defaultEdges, children: /* @__PURE__ */ jsx22(GraphViewInternal, { nodeTypes, edgeTypes, viewportFocusNodeId, children }) }) });
|
|
6955
7002
|
});
|
|
6956
7003
|
GraphView.displayName = "GraphView";
|
|
6957
|
-
function useViewportFocus(nodeMap, viewportFocusNodeId) {
|
|
6958
|
-
const flow = useReactFlow();
|
|
6959
|
-
React15.useEffect(() => {
|
|
6960
|
-
if (viewportFocusNodeId) {
|
|
6961
|
-
const focusNode = nodeMap.get(viewportFocusNodeId);
|
|
6962
|
-
if (focusNode) {
|
|
6963
|
-
flow.setCenter(focusNode.position.x, focusNode.position.y, { zoom: 1 });
|
|
6964
|
-
}
|
|
6965
|
-
}
|
|
6966
|
-
}, [viewportFocusNodeId, flow, nodeMap]);
|
|
6967
|
-
}
|
|
6968
7004
|
|
|
6969
7005
|
// src/graph/graph.tsx
|
|
6970
7006
|
import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
@@ -7003,12 +7039,12 @@ function Graph({
|
|
|
7003
7039
|
children
|
|
7004
7040
|
}) {
|
|
7005
7041
|
var _a, _b, _c;
|
|
7006
|
-
const graphRef =
|
|
7007
|
-
const [innerGlobalFilter, setInnerGlobalFilter] =
|
|
7008
|
-
const [innerColumnFilters, setInnerColumnFilters] =
|
|
7042
|
+
const graphRef = React17.useRef(null);
|
|
7043
|
+
const [innerGlobalFilter, setInnerGlobalFilter] = React17.useState("");
|
|
7044
|
+
const [innerColumnFilters, setInnerColumnFilters] = React17.useState([]);
|
|
7009
7045
|
const globalFilter = parentGlobalFilter != null ? parentGlobalFilter : innerGlobalFilter;
|
|
7010
7046
|
const setGlobalFilter = parentSetGlobalFilter != null ? parentSetGlobalFilter : setInnerGlobalFilter;
|
|
7011
|
-
|
|
7047
|
+
React17.useEffect(() => {
|
|
7012
7048
|
if (parentGlobalFilter !== void 0) {
|
|
7013
7049
|
setInnerGlobalFilter(parentGlobalFilter);
|
|
7014
7050
|
}
|
|
@@ -7029,7 +7065,7 @@ function Graph({
|
|
|
7029
7065
|
});
|
|
7030
7066
|
const flatColumns = table.getAllFlatColumns();
|
|
7031
7067
|
const filteredRows = table.getFilteredRowModel().rows;
|
|
7032
|
-
const filteredData =
|
|
7068
|
+
const filteredData = React17.useMemo(() => filteredRows.map((row) => row.original), [filteredRows]);
|
|
7033
7069
|
const filterCount = columnFilters.map(
|
|
7034
7070
|
({ id: columnFilterId, value }) => {
|
|
7035
7071
|
var _a2, _b2;
|
|
@@ -7043,10 +7079,10 @@ function Graph({
|
|
|
7043
7079
|
setColumnFilters([]);
|
|
7044
7080
|
setGlobalFilter("");
|
|
7045
7081
|
};
|
|
7046
|
-
const memoizedNodeTypes =
|
|
7047
|
-
const memoizedEdgeTypes =
|
|
7048
|
-
const memoizedConfig =
|
|
7049
|
-
|
|
7082
|
+
const memoizedNodeTypes = React17.useMemo(() => config.nodeTypes, [config.nodeTypes]);
|
|
7083
|
+
const memoizedEdgeTypes = React17.useMemo(() => config.edgeTypes, [config.edgeTypes]);
|
|
7084
|
+
const memoizedConfig = React17.useMemo(() => config, [config]);
|
|
7085
|
+
React17.useEffect(() => {
|
|
7050
7086
|
if (!graphRef.current) {
|
|
7051
7087
|
return;
|
|
7052
7088
|
}
|
|
@@ -7118,20 +7154,20 @@ function Graph({
|
|
|
7118
7154
|
}
|
|
7119
7155
|
|
|
7120
7156
|
// src/graph/hooks/useGetViewportNodeIds.ts
|
|
7121
|
-
import { useEffect as
|
|
7122
|
-
import { useStore, useViewport } from "reactflow";
|
|
7157
|
+
import { useEffect as useEffect10, useMemo as useMemo14, useRef as useRef9, useState as useState14 } from "react";
|
|
7158
|
+
import { useStore as useStore2, useViewport } from "reactflow";
|
|
7123
7159
|
var useGetDebouncedViewport = (debounceDelay = 1e3) => {
|
|
7124
7160
|
const timerRef = useRef9(null);
|
|
7125
7161
|
const [debouncedValues, setDebouncedValues] = useState14({ x: 0, y: 0, zoom: 1, width: 0, height: 0, nodes: [] });
|
|
7126
7162
|
const { x, y, zoom } = useViewport();
|
|
7127
|
-
const { width, height, nodes } =
|
|
7163
|
+
const { width, height, nodes } = useStore2((state) => ({
|
|
7128
7164
|
width: state.width,
|
|
7129
7165
|
height: state.height,
|
|
7130
7166
|
nodes: state.getNodes()
|
|
7131
7167
|
}));
|
|
7132
7168
|
const nodesHash = nodes.map((n) => n.id).sort().join(",");
|
|
7133
7169
|
const memoizedNodes = useMemo14(() => nodes, [nodesHash]);
|
|
7134
|
-
|
|
7170
|
+
useEffect10(() => {
|
|
7135
7171
|
if (timerRef.current) {
|
|
7136
7172
|
clearTimeout(timerRef.current);
|
|
7137
7173
|
}
|