@tldiagram/core-ui 1.94.3 → 1.94.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tldiagram/core-ui",
3
- "version": "1.94.3",
3
+ "version": "1.94.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,6 +49,8 @@ export interface ViewFloatingMenuProps extends ViewFloatingMenuSlots {
49
49
  setHighlightColor: (color: string | null) => void
50
50
 
51
51
  toolbarSlot?: React.ReactNode
52
+ hideFocusView?: boolean
53
+ hideExpandExtras?: boolean
52
54
  }
53
55
 
54
56
  /**
@@ -83,6 +85,8 @@ function ViewFloatingMenu({
83
85
  setHighlightColor,
84
86
  shareSlot,
85
87
  toolbarSlot,
88
+ hideFocusView = false,
89
+ hideExpandExtras = false,
86
90
  }: ViewFloatingMenuProps) {
87
91
  const { canEdit } = useViewEditorContext()
88
92
  const { isOpen: isTagsOpen, onClose: onTagsClose, onToggle: onTagsToggle } = useDisclosure()
@@ -127,24 +131,28 @@ function ViewFloatingMenu({
127
131
  </Button>
128
132
  </Tooltip>
129
133
 
130
- <Box w="1px" h="16px" bg="whiteAlpha.100" flexShrink={0} mx={0.5} />
131
- <Tooltip label={focusMode ? 'Show context' : 'Focus on this view'} placement="top" openDelay={200}>
132
- <Button
133
- variant="ghost"
134
- h="28px"
135
- px={2.5}
136
- color={focusMode ? 'var(--accent)' : 'gray.300'}
137
- bg={focusMode ? 'rgba(var(--accent-rgb), 0.12)' : 'transparent'}
138
- _hover={{ bg: 'rgba(var(--accent-rgb), 0.12)', color: 'var(--accent)' }}
139
- onClick={() => onFocusModeChange(!focusMode)}
140
- >
141
- <HStack spacing={1.5}>
142
- <FocusSvg />
143
- <Text fontSize="11px" fontWeight="normal">Focus View</Text>
144
- <Box w="6px" h="6px" rounded="full" bg={focusMode ? 'var(--accent)' : 'gray.500'} />
145
- </HStack>
146
- </Button>
147
- </Tooltip>
134
+ {!hideFocusView && (
135
+ <>
136
+ <Box w="1px" h="16px" bg="whiteAlpha.100" flexShrink={0} mx={0.5} />
137
+ <Tooltip label={focusMode ? 'Show context' : 'Focus on this view'} placement="top" openDelay={200}>
138
+ <Button
139
+ variant="ghost"
140
+ h="28px"
141
+ px={2.5}
142
+ color={focusMode ? 'var(--accent)' : 'gray.300'}
143
+ bg={focusMode ? 'rgba(var(--accent-rgb), 0.12)' : 'transparent'}
144
+ _hover={{ bg: 'rgba(var(--accent-rgb), 0.12)', color: 'var(--accent)' }}
145
+ onClick={() => onFocusModeChange(!focusMode)}
146
+ >
147
+ <HStack spacing={1.5}>
148
+ <FocusSvg />
149
+ <Text fontSize="11px" fontWeight="normal">Focus View</Text>
150
+ <Box w="6px" h="6px" rounded="full" bg={focusMode ? 'var(--accent)' : 'gray.500'} />
151
+ </HStack>
152
+ </Button>
153
+ </Tooltip>
154
+ </>
155
+ )}
148
156
  <Box w="1px" h="16px" bg="whiteAlpha.100" flexShrink={0} mx={0.5} />
149
157
 
150
158
  {(allTags.length > 0 || layers.length > 0) && (
@@ -356,22 +364,26 @@ function ViewFloatingMenu({
356
364
  </>
357
365
  )}
358
366
 
359
- <Box w="1px" h="16px" bg="whiteAlpha.100" flexShrink={0} mx={0.5} />
360
- <Button
361
- variant="ghost"
362
- h="28px"
363
- minW="36px"
364
- px={2}
365
- display="inline-flex"
366
- alignItems="center"
367
- justifyContent="center"
368
- color="gray.300"
369
- _hover={{ bg: 'rgba(var(--accent-rgb), 0.12)', color: 'var(--accent)' }}
370
- onClick={() => setExtrasOpen((prev) => !prev)}
371
- aria-label={extrasOpen ? 'Collapse extras' : 'Expand extras'}
372
- >
373
- {extrasOpen ? <CollapseExtrasSvg /> : <ExpandExtrasSvg />}
374
- </Button>
367
+ {!hideExpandExtras && (
368
+ <>
369
+ <Box w="1px" h="16px" bg="whiteAlpha.100" flexShrink={0} mx={0.5} />
370
+ <Button
371
+ variant="ghost"
372
+ h="28px"
373
+ minW="36px"
374
+ px={2}
375
+ display="inline-flex"
376
+ alignItems="center"
377
+ justifyContent="center"
378
+ color="gray.300"
379
+ _hover={{ bg: 'rgba(var(--accent-rgb), 0.12)', color: 'var(--accent)' }}
380
+ onClick={() => setExtrasOpen((prev) => !prev)}
381
+ aria-label={extrasOpen ? 'Collapse extras' : 'Expand extras'}
382
+ >
383
+ {extrasOpen ? <CollapseExtrasSvg /> : <ExpandExtrasSvg />}
384
+ </Button>
385
+ </>
386
+ )}
375
387
  </HStack>
376
388
  )
377
389
  }
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useMemo, useRef, type MutableRefObject, type RefObject } from 'react'
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
- if (clampedRevealProgress >= 0.999) {
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
+ }
@@ -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>
@@ -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