@tldiagram/core-ui 1.94.3 → 1.94.5
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/components/PanelUI.d.ts +3 -2
- package/dist/components/ViewFloatingMenu.d.ts +3 -1
- package/dist/demo/viewEditor.d.ts +3 -1
- package/dist/index.js +5815 -5708
- package/package.json +1 -1
- package/src/components/PanelUI.tsx +3 -2
- package/src/components/ViewExplorer/TagManager/index.tsx +94 -43
- package/src/components/ViewExplorer/ViewNavigator.tsx +122 -36
- package/src/components/ViewExplorer/index.tsx +9 -33
- package/src/components/ViewFloatingMenu.tsx +46 -34
- package/src/demo/viewEditor.ts +7 -36
- package/src/pages/InfiniteZoom.tsx +2 -2
- package/src/pages/ViewEditor/index.tsx +2 -0
- package/src/utils/toast.ts +8 -0
package/src/demo/viewEditor.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo,
|
|
1
|
+
import { useCallback, useEffect, useMemo, type MutableRefObject, type RefObject } from 'react'
|
|
2
2
|
import { getNodesBounds, getViewportForBounds, type Node as RFNode, type ReactFlowInstance } from 'reactflow'
|
|
3
3
|
|
|
4
4
|
export interface ViewEditorDemoOptions {
|
|
@@ -6,24 +6,19 @@ export interface ViewEditorDemoOptions {
|
|
|
6
6
|
disableImportExport?: boolean
|
|
7
7
|
hideFlowControls?: boolean
|
|
8
8
|
disableOnboarding?: boolean
|
|
9
|
+
hideFocusView?: boolean
|
|
10
|
+
hideExpandExtras?: boolean
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export const DEMO_VIEW_EDITOR_OPTIONS: Omit<ViewEditorDemoOptions, 'revealProgress'> = {
|
|
12
14
|
disableImportExport: true,
|
|
13
15
|
hideFlowControls: true,
|
|
14
16
|
disableOnboarding: true,
|
|
17
|
+
hideFocusView: true,
|
|
18
|
+
hideExpandExtras: true,
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
function getCenteredViewport(bounds: { x: number; y: number; width: number; height: number }, width: number, height: number, zoom: number) {
|
|
18
|
-
const centerX = bounds.x + bounds.width / 2
|
|
19
|
-
const centerY = bounds.y + bounds.height / 2
|
|
20
21
|
|
|
21
|
-
return {
|
|
22
|
-
x: width / 2 - centerX * zoom,
|
|
23
|
-
y: height / 2 - centerY * zoom,
|
|
24
|
-
zoom,
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
22
|
|
|
28
23
|
interface UseDemoRevealViewportArgs {
|
|
29
24
|
demoOptions?: ViewEditorDemoOptions
|
|
@@ -44,19 +39,12 @@ export function useDemoRevealViewport({
|
|
|
44
39
|
needsFitViewRef,
|
|
45
40
|
computedMinZoom,
|
|
46
41
|
setViewport,
|
|
47
|
-
resetKey,
|
|
48
42
|
}: UseDemoRevealViewportArgs) {
|
|
49
43
|
const clampedRevealProgress = useMemo(() => {
|
|
50
44
|
if (typeof demoOptions?.revealProgress !== 'number') return null
|
|
51
45
|
return Math.max(0, Math.min(1, demoOptions.revealProgress))
|
|
52
46
|
}, [demoOptions?.revealProgress])
|
|
53
47
|
|
|
54
|
-
const revealZoomRef = useRef<number | null>(null)
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
revealZoomRef.current = null
|
|
58
|
-
}, [resetKey, clampedRevealProgress])
|
|
59
|
-
|
|
60
48
|
const applyDemoRevealViewport = useCallback(() => {
|
|
61
49
|
if (clampedRevealProgress === null) return false
|
|
62
50
|
|
|
@@ -73,24 +61,7 @@ export function useDemoRevealViewport({
|
|
|
73
61
|
const fittedViewport = getViewportForBounds(bounds, width, height, computedMinZoom, 2, 0.1)
|
|
74
62
|
if (![fittedViewport.x, fittedViewport.y, fittedViewport.zoom].every(Number.isFinite)) return false
|
|
75
63
|
|
|
76
|
-
|
|
77
|
-
revealZoomRef.current = fittedViewport.zoom
|
|
78
|
-
setViewport(fittedViewport, { duration: 0 })
|
|
79
|
-
return true
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const fixedZoom = revealZoomRef.current ?? fittedViewport.zoom
|
|
83
|
-
revealZoomRef.current = fixedZoom
|
|
84
|
-
|
|
85
|
-
const centeredViewport = getCenteredViewport(bounds, width, height, fixedZoom)
|
|
86
|
-
const reveal = 1 - Math.pow(1 - clampedRevealProgress, 3)
|
|
87
|
-
const hiddenOffsetX = Math.max(width * 1.15, bounds.width * fixedZoom * 0.75)
|
|
88
|
-
|
|
89
|
-
setViewport({
|
|
90
|
-
x: centeredViewport.x + hiddenOffsetX * (1 - reveal),
|
|
91
|
-
y: centeredViewport.y,
|
|
92
|
-
zoom: fixedZoom,
|
|
93
|
-
}, { duration: 0 })
|
|
64
|
+
setViewport(fittedViewport, { duration: 0 })
|
|
94
65
|
|
|
95
66
|
return true
|
|
96
67
|
}, [clampedRevealProgress, computedMinZoom, containerRef, rfNodesRef, setViewport])
|
|
@@ -107,4 +78,4 @@ export function useDemoRevealViewport({
|
|
|
107
78
|
disableImportExport: demoOptions?.disableImportExport ?? false,
|
|
108
79
|
hideFlowControls: demoOptions?.hideFlowControls ?? false,
|
|
109
80
|
}
|
|
110
|
-
}
|
|
81
|
+
}
|
|
@@ -193,7 +193,7 @@ function InfiniteZoomInner({ sharedToken, shareSlot }: Props, ref?: React.Ref<In
|
|
|
193
193
|
{noDiagrams ? 'Create First Diagram' : 'Go to Editor'}
|
|
194
194
|
</Button>
|
|
195
195
|
)}
|
|
196
|
-
{!noDiagrams && <ExplorePageOnboarding hasDiagrams={!noDiagrams} />}
|
|
196
|
+
{!noDiagrams && !sharedToken && <ExplorePageOnboarding hasDiagrams={!noDiagrams} />}
|
|
197
197
|
</Center>
|
|
198
198
|
)
|
|
199
199
|
}
|
|
@@ -231,7 +231,7 @@ function InfiniteZoomInner({ sharedToken, shareSlot }: Props, ref?: React.Ref<In
|
|
|
231
231
|
/>
|
|
232
232
|
|
|
233
233
|
{/* Onboarding overlay */}
|
|
234
|
-
{data && <ExploreOnboarding hasLinkedNodes={!!(data.navigations?.length > 0)} />}
|
|
234
|
+
{data && !sharedToken && <ExploreOnboarding hasLinkedNodes={!!(data.navigations?.length > 0)} />}
|
|
235
235
|
<MiniZoomOnboarding isVisible={showMiniOnboarding} />
|
|
236
236
|
|
|
237
237
|
{/* Bottom toolbar */}
|
|
@@ -1377,6 +1377,8 @@ function ViewEditorInner({
|
|
|
1377
1377
|
setHighlightColor={setHoveredLayerColor}
|
|
1378
1378
|
shareSlot={shareSlot}
|
|
1379
1379
|
toolbarSlot={toolbarSlot}
|
|
1380
|
+
hideFocusView={demoOptions?.hideFocusView}
|
|
1381
|
+
hideExpandExtras={demoOptions?.hideExpandExtras}
|
|
1380
1382
|
/>
|
|
1381
1383
|
</Box>
|
|
1382
1384
|
</Flex>
|
package/src/utils/toast.ts
CHANGED
|
@@ -52,6 +52,14 @@ const toast: CustomToast = (options: UseToastOptions) => {
|
|
|
52
52
|
const status = options.status || 'error'
|
|
53
53
|
|
|
54
54
|
if (status === 'error') {
|
|
55
|
+
// Silence error toasts if we are on a demo route
|
|
56
|
+
const isDemoRoute = window.location.pathname.includes('/demo') ||
|
|
57
|
+
window.location.pathname.includes('/app/demo');
|
|
58
|
+
|
|
59
|
+
if (isDemoRoute) {
|
|
60
|
+
return undefined
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
const summary = getErrorSummary(options)
|
|
56
64
|
|
|
57
65
|
// Check if an error toast is already active
|