@lobehub/ui 5.23.1 → 5.23.3
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import Center from "../Flex/Center.mjs";
|
|
3
3
|
import Icon from "../Icon/Icon.mjs";
|
|
4
4
|
import { handleVariants, panelVariants, styles, toggleVariants } from "./style.mjs";
|
|
5
|
-
import { reversePlacement } from "./utils.mjs";
|
|
5
|
+
import { isBelowCollapseThreshold, reversePlacement } from "./utils.mjs";
|
|
6
6
|
import { memo, startTransition, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { ConfigProvider } from "antd";
|
|
@@ -40,7 +40,7 @@ const toCssSize = (value, fallback) => {
|
|
|
40
40
|
if (typeof value === "string" && value.length > 0) return value;
|
|
41
41
|
return fallback;
|
|
42
42
|
};
|
|
43
|
-
const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = true, mode = "fixed", children, placement = "right", resize, style, showBorder = true, showHandleHighlight = false, showHandleWideArea = true, backgroundColor, size, stableLayout = false, defaultSize: customizeDefaultSize, minWidth, minHeight, maxWidth, onSizeChange, onSizeDragging, expandable = true, expand, defaultExpand = true, onExpandChange, className, showHandleWhenCollapsed, destroyOnClose, styles: customStyles, classNames, dir }) => {
|
|
43
|
+
const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = true, mode = "fixed", children, placement = "right", resize, style, showBorder = true, showHandleHighlight = false, showHandleWideArea = true, backgroundColor, collapseThreshold, size, stableLayout = false, defaultSize: customizeDefaultSize, minWidth, minHeight, maxWidth, onSizeChange, onSizeDragging, expandable = true, expand, defaultExpand = true, onExpandChange, className, showHandleWhenCollapsed, destroyOnClose, styles: customStyles, classNames, dir }) => {
|
|
44
44
|
const ref = useRef(null);
|
|
45
45
|
const isHovering = useHover(ref);
|
|
46
46
|
const isVertical = placement === "top" || placement === "bottom";
|
|
@@ -48,6 +48,7 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
48
48
|
const resetTransitionTimeoutRef = useRef(void 0);
|
|
49
49
|
const resizableRef = useRef(null);
|
|
50
50
|
const initialExpandedSizeRef = useRef(void 0);
|
|
51
|
+
const resizeStartSizeRef = useRef(void 0);
|
|
51
52
|
const outerRef = useRef(null);
|
|
52
53
|
const { direction: antdDirection } = use(ConfigProvider.ConfigContext);
|
|
53
54
|
const direction = dir ?? antdDirection;
|
|
@@ -67,6 +68,7 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
67
68
|
});
|
|
68
69
|
const [shouldTransition, setShouldTransition] = useState(true);
|
|
69
70
|
const [showExpand, setShowExpand] = useState(true);
|
|
71
|
+
const usesStableLayout = stableLayout || collapseThreshold !== void 0;
|
|
70
72
|
useEffect(() => {
|
|
71
73
|
if (pin) return;
|
|
72
74
|
if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
|
|
@@ -120,7 +122,7 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
120
122
|
const normalizedMinHeight = typeof minHeight === "number" ? Math.max(minHeight, 0) : void 0;
|
|
121
123
|
const normalizedMinWidth = typeof minWidth === "number" ? Math.max(minWidth, 0) : void 0;
|
|
122
124
|
const sizeProps = useMemo(() => {
|
|
123
|
-
if (!
|
|
125
|
+
if (!usesStableLayout && !isExpand) return isVertical ? {
|
|
124
126
|
minHeight: 0,
|
|
125
127
|
size: { height: 0 }
|
|
126
128
|
} : {
|
|
@@ -136,7 +138,7 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
136
138
|
size
|
|
137
139
|
};
|
|
138
140
|
}, [
|
|
139
|
-
|
|
141
|
+
usesStableLayout,
|
|
140
142
|
isExpand,
|
|
141
143
|
isVertical,
|
|
142
144
|
defaultSize,
|
|
@@ -169,7 +171,7 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
169
171
|
const [resizedExpandedSize, setResizedExpandedSize] = useState({});
|
|
170
172
|
const expandedOuterSize = controlledExpandedSize ?? (isVertical ? resizedExpandedSize.vertical : resizedExpandedSize.horizontal) ?? defaultExpandedSize;
|
|
171
173
|
const setExpandedMainSize = useCallback((nextSize) => {
|
|
172
|
-
if (!
|
|
174
|
+
if (!usesStableLayout) return;
|
|
173
175
|
const currentSize = isVertical ? nextSize.height : nextSize.width;
|
|
174
176
|
if (!currentSize) return;
|
|
175
177
|
const normalizedSize = toCssSize(currentSize, fallbackExpandedSize);
|
|
@@ -183,22 +185,26 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
183
185
|
}, [
|
|
184
186
|
fallbackExpandedSize,
|
|
185
187
|
isVertical,
|
|
186
|
-
|
|
188
|
+
usesStableLayout
|
|
187
189
|
]);
|
|
188
|
-
const
|
|
189
|
-
if (initialExpandedSizeRef.current) return initialExpandedSizeRef.current;
|
|
190
|
+
const readCurrentSize = useCallback(() => {
|
|
190
191
|
const rect = resizableRef.current?.resizable?.getBoundingClientRect();
|
|
191
192
|
if (!rect) return void 0;
|
|
192
|
-
|
|
193
|
+
return isVertical ? {
|
|
193
194
|
height: rect.height,
|
|
194
195
|
width: "100%"
|
|
195
196
|
} : {
|
|
196
197
|
height: "100%",
|
|
197
198
|
width: rect.width
|
|
198
199
|
};
|
|
200
|
+
}, [isVertical]);
|
|
201
|
+
const captureInitialExpandedSize = useCallback(() => {
|
|
202
|
+
if (initialExpandedSizeRef.current) return initialExpandedSizeRef.current;
|
|
203
|
+
const nextInitialSize = readCurrentSize();
|
|
204
|
+
if (!nextInitialSize) return void 0;
|
|
199
205
|
initialExpandedSizeRef.current = nextInitialSize;
|
|
200
206
|
return nextInitialSize;
|
|
201
|
-
}, [
|
|
207
|
+
}, [readCurrentSize]);
|
|
202
208
|
useEffect(() => {
|
|
203
209
|
if (!isExpand) return;
|
|
204
210
|
captureInitialExpandedSize();
|
|
@@ -241,19 +247,28 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
241
247
|
]);
|
|
242
248
|
const handleResize = useCallback((_event, _direction, el, delta) => {
|
|
243
249
|
const nextSize = clampResizeSize(el);
|
|
244
|
-
|
|
250
|
+
const nextCollapsePreview = isBelowCollapseThreshold({
|
|
251
|
+
axis: isVertical ? "height" : "width",
|
|
252
|
+
collapseThreshold,
|
|
253
|
+
size: nextSize
|
|
254
|
+
});
|
|
255
|
+
if (usesStableLayout && outerRef.current) {
|
|
245
256
|
const dimension = isVertical ? nextSize.height : nextSize.width;
|
|
246
|
-
if (dimension)
|
|
247
|
-
|
|
257
|
+
if (dimension) {
|
|
258
|
+
const previewDimension = nextCollapsePreview ? "0px" : dimension;
|
|
259
|
+
if (isVertical) outerRef.current.style.height = previewDimension;
|
|
260
|
+
else outerRef.current.style.width = previewDimension;
|
|
261
|
+
}
|
|
248
262
|
}
|
|
249
|
-
setExpandedMainSize(nextSize);
|
|
263
|
+
if (collapseThreshold === void 0) setExpandedMainSize(nextSize);
|
|
250
264
|
onSizeDragging?.(delta, nextSize);
|
|
251
265
|
}, [
|
|
252
266
|
clampResizeSize,
|
|
267
|
+
collapseThreshold,
|
|
253
268
|
isVertical,
|
|
254
269
|
onSizeDragging,
|
|
255
270
|
setExpandedMainSize,
|
|
256
|
-
|
|
271
|
+
usesStableLayout
|
|
257
272
|
]);
|
|
258
273
|
const triggerResetWithoutTransition = useCallback(() => {
|
|
259
274
|
if (resetTransitionTimeoutRef.current) clearTimeout(resetTransitionTimeoutRef.current);
|
|
@@ -297,26 +312,47 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
297
312
|
clearTimeout(resetTransitionTimeoutRef.current);
|
|
298
313
|
resetTransitionTimeoutRef.current = void 0;
|
|
299
314
|
}
|
|
300
|
-
|
|
315
|
+
resizeStartSizeRef.current = readCurrentSize();
|
|
316
|
+
if (usesStableLayout && outerRef.current) outerRef.current.style.transition = "none";
|
|
301
317
|
setShouldTransition(false);
|
|
302
318
|
setShowExpand(false);
|
|
303
|
-
}, [
|
|
319
|
+
}, [
|
|
320
|
+
handleResetSize,
|
|
321
|
+
readCurrentSize,
|
|
322
|
+
usesStableLayout
|
|
323
|
+
]);
|
|
304
324
|
const handleResizeStop = useCallback((_event, _direction, el, delta) => {
|
|
305
325
|
const nextSize = clampResizeSize(el);
|
|
306
|
-
|
|
326
|
+
const shouldCollapse = isBelowCollapseThreshold({
|
|
327
|
+
axis: isVertical ? "height" : "width",
|
|
328
|
+
collapseThreshold,
|
|
329
|
+
size: nextSize
|
|
330
|
+
});
|
|
331
|
+
const committedSize = shouldCollapse ? resizeStartSizeRef.current ?? nextSize : nextSize;
|
|
332
|
+
resizableRef.current?.updateSize(committedSize);
|
|
333
|
+
if (!shouldCollapse) setExpandedMainSize(committedSize);
|
|
307
334
|
setShouldTransition(true);
|
|
308
335
|
setShowExpand(true);
|
|
309
|
-
if (
|
|
310
|
-
outerRef.current.style.removeProperty("width");
|
|
311
|
-
outerRef.current.style.removeProperty("height");
|
|
336
|
+
if (usesStableLayout && outerRef.current) {
|
|
312
337
|
outerRef.current.style.removeProperty("transition");
|
|
338
|
+
if (shouldCollapse) if (isVertical) outerRef.current.style.height = "0px";
|
|
339
|
+
else outerRef.current.style.width = "0px";
|
|
340
|
+
else {
|
|
341
|
+
outerRef.current.style.removeProperty("width");
|
|
342
|
+
outerRef.current.style.removeProperty("height");
|
|
343
|
+
}
|
|
313
344
|
}
|
|
314
|
-
|
|
345
|
+
if (shouldCollapse) setIsExpand(false);
|
|
346
|
+
resizeStartSizeRef.current = void 0;
|
|
347
|
+
onSizeChange?.(delta, committedSize);
|
|
315
348
|
}, [
|
|
316
349
|
clampResizeSize,
|
|
350
|
+
collapseThreshold,
|
|
351
|
+
isVertical,
|
|
317
352
|
onSizeChange,
|
|
318
353
|
setExpandedMainSize,
|
|
319
|
-
|
|
354
|
+
setIsExpand,
|
|
355
|
+
usesStableLayout
|
|
320
356
|
]);
|
|
321
357
|
const resizeHandleClassName = useMemo(() => cx(handleVariants({ placement: reversed }), showHandleHighlight && styles.handleHighlight), [reversed, showHandleHighlight]);
|
|
322
358
|
if (fullscreen) return /* @__PURE__ */ jsx("div", {
|
|
@@ -325,7 +361,7 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
325
361
|
children
|
|
326
362
|
});
|
|
327
363
|
const Arrow = ARROW_MAP[internalPlacement] ?? ChevronLeft;
|
|
328
|
-
const stableOuterFlex =
|
|
364
|
+
const stableOuterFlex = usesStableLayout ? {
|
|
329
365
|
display: "flex",
|
|
330
366
|
flexDirection: "column",
|
|
331
367
|
minHeight: 0
|
|
@@ -340,14 +376,14 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
340
376
|
overflow: "hidden",
|
|
341
377
|
transition: shouldTransition ? "width 0.2s var(--ant-motion-ease-out, ease)" : "none",
|
|
342
378
|
width: isExpand ? expandedOuterSize : 0,
|
|
343
|
-
...
|
|
379
|
+
...usesStableLayout ? {
|
|
344
380
|
...stableOuterFlex,
|
|
345
381
|
flex: 1,
|
|
346
382
|
minWidth: 0,
|
|
347
383
|
height: "100%"
|
|
348
384
|
} : {}
|
|
349
385
|
};
|
|
350
|
-
const sidebarInnerStyle =
|
|
386
|
+
const sidebarInnerStyle = usesStableLayout ? {
|
|
351
387
|
display: "flex",
|
|
352
388
|
flex: 1,
|
|
353
389
|
flexDirection: "column",
|
|
@@ -359,7 +395,7 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
359
395
|
height: "100%",
|
|
360
396
|
width: "100%"
|
|
361
397
|
} : { width: "100%" };
|
|
362
|
-
const stableAsideStyle =
|
|
398
|
+
const stableAsideStyle = usesStableLayout ? {
|
|
363
399
|
display: "flex",
|
|
364
400
|
flexDirection: "column",
|
|
365
401
|
minHeight: 0,
|
|
@@ -383,13 +419,13 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
383
419
|
style: {
|
|
384
420
|
...cssVariables,
|
|
385
421
|
transition: shouldTransition ? void 0 : "none",
|
|
386
|
-
...
|
|
422
|
+
...usesStableLayout ? stableResizableStyle : {},
|
|
387
423
|
...style
|
|
388
424
|
},
|
|
389
425
|
onResize: handleResize,
|
|
390
426
|
onResizeStart: handleResizeStart,
|
|
391
427
|
onResizeStop: handleResizeStop,
|
|
392
|
-
children:
|
|
428
|
+
children: usesStableLayout ? /* @__PURE__ */ jsx("div", {
|
|
393
429
|
style: sidebarInnerStyle,
|
|
394
430
|
children
|
|
395
431
|
}) : children
|
|
@@ -428,7 +464,7 @@ const DraggablePanel = memo(({ headerHeight = 0, fullscreen, maxHeight, pin = tr
|
|
|
428
464
|
}
|
|
429
465
|
})
|
|
430
466
|
})
|
|
431
|
-
}),
|
|
467
|
+
}), usesStableLayout ? /* @__PURE__ */ jsx("div", {
|
|
432
468
|
ref: outerRef,
|
|
433
469
|
style: sidebarOuterStyle,
|
|
434
470
|
children: panelNode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DraggablePanel.mjs","names":["useControlledState"],"sources":["../../src/DraggablePanel/DraggablePanel.tsx"],"sourcesContent":["'use client';\n\nimport { useHover } from 'ahooks';\nimport { ConfigProvider } from 'antd';\nimport { cx } from 'antd-style';\nimport isEqual from 'fast-deep-equal';\nimport { ChevronDown, ChevronLeft, ChevronRight, ChevronUp } from 'lucide-react';\nimport type { Enable, NumberSize, Size } from 're-resizable';\nimport { Resizable } from 're-resizable';\nimport {\n type CSSProperties,\n memo,\n startTransition,\n use,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport useControlledState from 'use-merge-value';\n\nimport { Center } from '@/Flex';\nimport Icon from '@/Icon';\n\nimport { handleVariants, panelVariants, styles, toggleVariants } from './style';\nimport type { DraggablePanelProps } from './type';\nimport { reversePlacement } from './utils';\n\nconst ARROW_MAP = {\n bottom: ChevronUp,\n left: ChevronRight,\n right: ChevronLeft,\n top: ChevronDown,\n} as const;\n\nconst MARGIN_MAP = {\n bottom: { marginTop: 4 },\n left: { marginRight: 4 },\n right: { marginLeft: 4 },\n top: { marginBottom: 4 },\n} as const;\n\nconst DISABLED_RESIZING: Enable = {\n bottom: false,\n bottomLeft: false,\n bottomRight: false,\n left: false,\n right: false,\n top: false,\n topLeft: false,\n topRight: false,\n};\n\nconst toCssSize = (value: string | number | undefined, fallback: string) => {\n if (typeof value === 'number') return `${Math.max(value, 0)}px`;\n if (typeof value === 'string' && value.length > 0) return value;\n return fallback;\n};\n\nconst DraggablePanel = memo<DraggablePanelProps>(\n ({\n headerHeight = 0,\n fullscreen,\n maxHeight,\n pin = true,\n mode = 'fixed',\n children,\n placement = 'right',\n resize,\n style,\n showBorder = true,\n showHandleHighlight = false,\n showHandleWideArea = true,\n backgroundColor,\n size,\n stableLayout = false,\n defaultSize: customizeDefaultSize,\n minWidth,\n minHeight,\n maxWidth,\n onSizeChange,\n onSizeDragging,\n expandable = true,\n expand,\n defaultExpand = true,\n onExpandChange,\n className,\n showHandleWhenCollapsed,\n destroyOnClose,\n styles: customStyles,\n classNames,\n dir,\n }) => {\n const ref = useRef<HTMLDivElement>(null);\n const isHovering = useHover(ref);\n const isVertical = placement === 'top' || placement === 'bottom';\n const hoverTimeoutRef = useRef<ReturnType<typeof setTimeout>>(undefined);\n const resetTransitionTimeoutRef = useRef<ReturnType<typeof setTimeout>>(undefined);\n const resizableRef = useRef<Resizable>(null);\n const initialExpandedSizeRef = useRef<Size | undefined>(undefined);\n const outerRef = useRef<HTMLDivElement>(null);\n\n const { direction: antdDirection } = use(ConfigProvider.ConfigContext);\n const direction = dir ?? antdDirection;\n\n const internalPlacement = useMemo(() => {\n if (direction !== 'rtl') return placement;\n if (placement === 'left') return 'right';\n if (placement === 'right') return 'left';\n return placement;\n }, [direction, placement]);\n\n const cssVariables = {\n '--draggable-panel-bg': backgroundColor || '',\n '--draggable-panel-header-height': `${headerHeight}px`,\n } as Record<string, string>;\n\n const [isExpand, setIsExpand] = useControlledState(defaultExpand, {\n onChange: onExpandChange,\n value: expand,\n });\n\n const [shouldTransition, setShouldTransition] = useState(true);\n const [showExpand, setShowExpand] = useState(true);\n\n useEffect(() => {\n if (pin) return;\n\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current);\n }\n\n if (isHovering && !isExpand) {\n startTransition(() => setIsExpand(true));\n } else if (!isHovering && isExpand) {\n hoverTimeoutRef.current = setTimeout(() => {\n startTransition(() => setIsExpand(false));\n }, 150);\n }\n }, [pin, isHovering, isExpand, setIsExpand]);\n\n useEffect(() => {\n return () => {\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current);\n }\n if (resetTransitionTimeoutRef.current) {\n clearTimeout(resetTransitionTimeoutRef.current);\n }\n };\n }, []);\n\n useEffect(() => {\n initialExpandedSizeRef.current = undefined;\n }, [internalPlacement]);\n\n const reversed = reversePlacement(internalPlacement);\n const canResizing = resize !== false && isExpand;\n\n const resizing = useMemo(\n () => ({\n bottom: false,\n bottomLeft: false,\n bottomRight: false,\n left: false,\n right: false,\n top: false,\n topLeft: false,\n topRight: false,\n [reversed]: true,\n ...(resize as Enable),\n }),\n [reversed, resize],\n );\n\n const defaultSize: Size = useMemo(() => {\n if (isVertical) return { height: 180, width: '100%', ...customizeDefaultSize };\n return { height: '100%', width: 280, ...customizeDefaultSize };\n }, [isVertical, customizeDefaultSize]);\n const normalizedMaxHeight = typeof maxHeight === 'number' ? Math.max(maxHeight, 0) : undefined;\n const normalizedMaxWidth = typeof maxWidth === 'number' ? Math.max(maxWidth, 0) : undefined;\n const normalizedMinHeight = typeof minHeight === 'number' ? Math.max(minHeight, 0) : undefined;\n const normalizedMinWidth = typeof minWidth === 'number' ? Math.max(minWidth, 0) : undefined;\n\n const sizeProps = useMemo(() => {\n if (!stableLayout && !isExpand) {\n return isVertical\n ? { minHeight: 0, size: { height: 0 } }\n : { minWidth: 0, size: { width: 0 } };\n }\n\n return {\n defaultSize,\n maxHeight: normalizedMaxHeight,\n maxWidth: normalizedMaxWidth,\n minHeight: normalizedMinHeight,\n minWidth: normalizedMinWidth,\n size: size as Size,\n };\n }, [\n stableLayout,\n isExpand,\n isVertical,\n defaultSize,\n normalizedMaxHeight,\n normalizedMaxWidth,\n normalizedMinHeight,\n normalizedMinWidth,\n size,\n ]);\n\n const fallbackExpandedSize = isVertical ? '180px' : '280px';\n const controlledExpandedSize = useMemo(() => {\n const controlledSize = isVertical ? size?.height : size?.width;\n if (controlledSize === undefined) return undefined;\n return toCssSize(controlledSize, fallbackExpandedSize);\n }, [isVertical, size?.height, size?.width, fallbackExpandedSize]);\n const defaultExpandedSize = useMemo(() => {\n const initialSize = isVertical ? defaultSize.height : defaultSize.width;\n return toCssSize(initialSize, fallbackExpandedSize);\n }, [isVertical, defaultSize.height, defaultSize.width, fallbackExpandedSize]);\n const [resizedExpandedSize, setResizedExpandedSize] = useState<{\n horizontal?: string;\n vertical?: string;\n }>({});\n const expandedOuterSize =\n controlledExpandedSize ??\n (isVertical ? resizedExpandedSize.vertical : resizedExpandedSize.horizontal) ??\n defaultExpandedSize;\n\n const setExpandedMainSize = useCallback(\n (nextSize: Size) => {\n if (!stableLayout) return;\n\n const currentSize = isVertical ? nextSize.height : nextSize.width;\n if (!currentSize) return;\n\n const normalizedSize = toCssSize(currentSize, fallbackExpandedSize);\n setResizedExpandedSize((state) =>\n isVertical\n ? { ...state, vertical: normalizedSize }\n : { ...state, horizontal: normalizedSize },\n );\n },\n [fallbackExpandedSize, isVertical, stableLayout],\n );\n\n const captureInitialExpandedSize = useCallback(() => {\n if (initialExpandedSizeRef.current) return initialExpandedSizeRef.current;\n\n const rect = resizableRef.current?.resizable?.getBoundingClientRect();\n if (!rect) return undefined;\n\n const nextInitialSize = isVertical\n ? ({ height: rect.height, width: '100%' } as Size)\n : ({ height: '100%', width: rect.width } as Size);\n\n initialExpandedSizeRef.current = nextInitialSize;\n return nextInitialSize;\n }, [isVertical]);\n\n useEffect(() => {\n if (!isExpand) return;\n captureInitialExpandedSize();\n }, [captureInitialExpandedSize, isExpand]);\n\n const toggleExpand = useCallback(() => {\n if (expandable) setIsExpand(!isExpand);\n }, [expandable, isExpand, setIsExpand]);\n\n const clampResizeSize = useCallback(\n (el: HTMLElement) => {\n const rect = el.getBoundingClientRect();\n const currentMainSize = isVertical ? rect.height : rect.width;\n const minMainSize = isVertical ? normalizedMinHeight : normalizedMinWidth;\n const maxMainSize = isVertical ? normalizedMaxHeight : normalizedMaxWidth;\n\n let clampedMainSize = currentMainSize;\n if (typeof minMainSize === 'number')\n clampedMainSize = Math.max(clampedMainSize, minMainSize);\n if (typeof maxMainSize === 'number')\n clampedMainSize = Math.min(clampedMainSize, maxMainSize);\n\n if (\n !Number.isFinite(clampedMainSize) ||\n Math.abs(clampedMainSize - currentMainSize) < 0.5\n ) {\n return { height: el.style.height, width: el.style.width };\n }\n\n const width = isVertical ? el.style.width || '100%' : `${clampedMainSize}px`;\n const height = isVertical ? `${clampedMainSize}px` : el.style.height || '100%';\n resizableRef.current?.updateSize({ height, width });\n\n return { height, width };\n },\n [\n isVertical,\n normalizedMaxHeight,\n normalizedMaxWidth,\n normalizedMinHeight,\n normalizedMinWidth,\n ],\n );\n\n const handleResize = useCallback(\n (_event: unknown, _direction: unknown, el: HTMLElement, delta: NumberSize) => {\n const nextSize = clampResizeSize(el);\n if (stableLayout && outerRef.current) {\n // Sync outer DOM width immediately so it doesn't lag behind the\n // re-resizable inline style (which would otherwise trigger a 0.2s\n // width transition on the outer/aside each frame during drag).\n const dimension = isVertical ? nextSize.height : nextSize.width;\n if (dimension) {\n if (isVertical) outerRef.current.style.height = dimension;\n else outerRef.current.style.width = dimension;\n }\n }\n setExpandedMainSize(nextSize);\n onSizeDragging?.(delta, nextSize);\n },\n [clampResizeSize, isVertical, onSizeDragging, setExpandedMainSize, stableLayout],\n );\n\n const triggerResetWithoutTransition = useCallback(() => {\n if (resetTransitionTimeoutRef.current) {\n clearTimeout(resetTransitionTimeoutRef.current);\n }\n\n setShouldTransition(false);\n resetTransitionTimeoutRef.current = setTimeout(() => {\n setShouldTransition(true);\n }, 0);\n }, []);\n\n const handleResetSize = useCallback(() => {\n if (!canResizing) return;\n\n const resetSize = captureInitialExpandedSize();\n if (!resetSize) return;\n\n triggerResetWithoutTransition();\n\n const rect = resizableRef.current?.resizable?.getBoundingClientRect();\n const prevMainSize = rect ? (isVertical ? rect.height : rect.width) : 0;\n const resetMainSize = isVertical ? resetSize.height : resetSize.width;\n const nextMainSize = typeof resetMainSize === 'number' ? resetMainSize : prevMainSize;\n\n resizableRef.current?.updateSize(resetSize);\n setExpandedMainSize(resetSize);\n\n onSizeChange?.(\n isVertical\n ? { height: nextMainSize - prevMainSize, width: 0 }\n : { height: 0, width: nextMainSize - prevMainSize },\n resetSize,\n );\n }, [\n canResizing,\n captureInitialExpandedSize,\n isVertical,\n onSizeChange,\n setExpandedMainSize,\n triggerResetWithoutTransition,\n ]);\n\n const handleResizeStart = useCallback(\n (event: { detail?: number }) => {\n if (event.detail === 2) {\n handleResetSize();\n return false;\n }\n\n if (resetTransitionTimeoutRef.current) {\n clearTimeout(resetTransitionTimeoutRef.current);\n resetTransitionTimeoutRef.current = undefined;\n }\n\n // Synchronously disable the outer transition so the first drag frame\n // does not animate. `setShouldTransition(false)` below is asynchronous\n // and would only take effect after the next React commit.\n if (stableLayout && outerRef.current) {\n outerRef.current.style.transition = 'none';\n }\n setShouldTransition(false);\n setShowExpand(false);\n },\n [handleResetSize, stableLayout],\n );\n\n const handleResizeStop = useCallback(\n (_event: unknown, _direction: unknown, el: HTMLElement, delta: NumberSize) => {\n const nextSize = clampResizeSize(el);\n setExpandedMainSize(nextSize);\n setShouldTransition(true);\n setShowExpand(true);\n // Clear imperative inline overrides so React resumes owning the outer\n // width/transition on the next render.\n if (stableLayout && outerRef.current) {\n outerRef.current.style.removeProperty('width');\n outerRef.current.style.removeProperty('height');\n outerRef.current.style.removeProperty('transition');\n }\n onSizeChange?.(delta, nextSize);\n },\n [clampResizeSize, onSizeChange, setExpandedMainSize, stableLayout],\n );\n\n const resizeHandleClassName = useMemo(\n () =>\n cx(handleVariants({ placement: reversed }), showHandleHighlight && styles.handleHighlight),\n [reversed, showHandleHighlight],\n );\n\n if (fullscreen) {\n return (\n <div className={cx(styles.fullscreen, className)} style={cssVariables}>\n {children}\n </div>\n );\n }\n\n const Arrow = ARROW_MAP[internalPlacement] ?? ChevronLeft;\n const stableOuterFlex = stableLayout\n ? ({\n display: 'flex',\n flexDirection: 'column',\n minHeight: 0,\n } as const)\n : {};\n\n const sidebarOuterStyle = isVertical\n ? {\n height: isExpand ? expandedOuterSize : 0,\n overflow: 'hidden',\n transition: shouldTransition ? 'height 0.2s var(--ant-motion-ease-out, ease)' : 'none',\n width: '100%',\n ...stableOuterFlex,\n }\n : {\n overflow: 'hidden',\n transition: shouldTransition ? 'width 0.2s var(--ant-motion-ease-out, ease)' : 'none',\n width: isExpand ? expandedOuterSize : 0,\n ...(stableLayout\n ? {\n ...stableOuterFlex,\n flex: 1,\n minWidth: 0,\n height: '100%',\n }\n : {}),\n };\n\n const stableInnerStyle: CSSProperties = {\n display: 'flex',\n flex: 1,\n flexDirection: 'column',\n height: '100%',\n minHeight: 0,\n minWidth: 0,\n width: '100%',\n };\n const sidebarInnerStyle: CSSProperties = stableLayout\n ? stableInnerStyle\n : isVertical\n ? { height: '100%', width: '100%' }\n : { width: '100%' };\n\n const stableAsideStyle: CSSProperties = stableLayout\n ? {\n display: 'flex',\n flexDirection: 'column',\n minHeight: 0,\n ...(mode === 'fixed' ? { height: '100%' } : {}),\n }\n : {};\n\n const stableResizableStyle: CSSProperties = {\n display: 'flex',\n flex: 1,\n flexDirection: 'column',\n height: '100%',\n minHeight: 0,\n minWidth: 0,\n width: '100%',\n };\n\n const panelNode = (!destroyOnClose || isExpand) && (\n <Resizable\n ref={resizableRef}\n {...sizeProps}\n className={cx(styles.panel, classNames?.content)}\n enable={canResizing ? (resizing as Enable) : DISABLED_RESIZING}\n handleClasses={\n canResizing\n ? {\n [reversed]: resizeHandleClassName,\n }\n : {}\n }\n style={{\n ...cssVariables,\n transition: shouldTransition ? undefined : 'none',\n ...(stableLayout ? stableResizableStyle : {}),\n ...style,\n }}\n onResize={handleResize}\n onResizeStart={handleResizeStart}\n onResizeStop={handleResizeStop}\n >\n {stableLayout ? <div style={sidebarInnerStyle}>{children}</div> : children}\n </Resizable>\n );\n\n return (\n <aside\n dir={dir}\n ref={ref}\n style={{ ...cssVariables, ...stableAsideStyle }}\n className={cx(\n panelVariants({ isExpand, mode, placement: internalPlacement, showBorder }),\n className,\n )}\n >\n {expandable && showExpand && (\n <Center\n className={toggleVariants({ placement: internalPlacement, showHandleWideArea })}\n style={{\n opacity: isExpand ? (pin ? undefined : 0) : showHandleWhenCollapsed ? 1 : 0,\n }}\n >\n <Center\n className={classNames?.handle}\n style={customStyles?.handle}\n onClick={toggleExpand}\n >\n <Icon\n className={styles.handlerIcon}\n icon={Arrow}\n size={16}\n style={{\n ...MARGIN_MAP[internalPlacement],\n transform: `rotate(${isExpand ? 180 : 0}deg)`,\n transition: 'transform 0.3s ease',\n }}\n />\n </Center>\n </Center>\n )}\n {stableLayout ? (\n <div ref={outerRef} style={sidebarOuterStyle}>\n {panelNode}\n </div>\n ) : (\n panelNode\n )}\n </aside>\n );\n },\n isEqual,\n);\n\nDraggablePanel.displayName = 'DraggablePanel';\n\nexport default DraggablePanel;\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,YAAY;CAChB,QAAQ;CACR,MAAM;CACN,OAAO;CACP,KAAK;AACP;AAEA,MAAM,aAAa;CACjB,QAAQ,EAAE,WAAW,EAAE;CACvB,MAAM,EAAE,aAAa,EAAE;CACvB,OAAO,E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,WAAW,OAAO;KAClB,MAAM;KACN,MAAM;KACN,OAAO;MACL,GAAG,WAAW;MACd,WAAW,UAAU,WAAW,MAAM,EAAE;MACxC,YAAY;KACd;IACD,CAAA;GACK,CAAA;EACF,CAAA,GAET,eACC,oBAAC,OAAD;GAAK,KAAK;GAAU,OAAO;aACxB;EACE,CAAA,IAEL,SAEG;;AAEX,GACA,OACF;AAEA,eAAe,cAAc"}
|
|
1
|
+
{"version":3,"file":"DraggablePanel.mjs","names":["useControlledState"],"sources":["../../src/DraggablePanel/DraggablePanel.tsx"],"sourcesContent":["'use client';\n\nimport { useHover } from 'ahooks';\nimport { ConfigProvider } from 'antd';\nimport { cx } from 'antd-style';\nimport isEqual from 'fast-deep-equal';\nimport { ChevronDown, ChevronLeft, ChevronRight, ChevronUp } from 'lucide-react';\nimport type { Enable, NumberSize, Size } from 're-resizable';\nimport { Resizable } from 're-resizable';\nimport {\n type CSSProperties,\n memo,\n startTransition,\n use,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport useControlledState from 'use-merge-value';\n\nimport { Center } from '@/Flex';\nimport Icon from '@/Icon';\n\nimport { handleVariants, panelVariants, styles, toggleVariants } from './style';\nimport type { DraggablePanelProps } from './type';\nimport { isBelowCollapseThreshold, reversePlacement } from './utils';\n\nconst ARROW_MAP = {\n bottom: ChevronUp,\n left: ChevronRight,\n right: ChevronLeft,\n top: ChevronDown,\n} as const;\n\nconst MARGIN_MAP = {\n bottom: { marginTop: 4 },\n left: { marginRight: 4 },\n right: { marginLeft: 4 },\n top: { marginBottom: 4 },\n} as const;\n\nconst DISABLED_RESIZING: Enable = {\n bottom: false,\n bottomLeft: false,\n bottomRight: false,\n left: false,\n right: false,\n top: false,\n topLeft: false,\n topRight: false,\n};\n\nconst toCssSize = (value: string | number | undefined, fallback: string) => {\n if (typeof value === 'number') return `${Math.max(value, 0)}px`;\n if (typeof value === 'string' && value.length > 0) return value;\n return fallback;\n};\n\nconst DraggablePanel = memo<DraggablePanelProps>(\n ({\n headerHeight = 0,\n fullscreen,\n maxHeight,\n pin = true,\n mode = 'fixed',\n children,\n placement = 'right',\n resize,\n style,\n showBorder = true,\n showHandleHighlight = false,\n showHandleWideArea = true,\n backgroundColor,\n collapseThreshold,\n size,\n stableLayout = false,\n defaultSize: customizeDefaultSize,\n minWidth,\n minHeight,\n maxWidth,\n onSizeChange,\n onSizeDragging,\n expandable = true,\n expand,\n defaultExpand = true,\n onExpandChange,\n className,\n showHandleWhenCollapsed,\n destroyOnClose,\n styles: customStyles,\n classNames,\n dir,\n }) => {\n const ref = useRef<HTMLDivElement>(null);\n const isHovering = useHover(ref);\n const isVertical = placement === 'top' || placement === 'bottom';\n const hoverTimeoutRef = useRef<ReturnType<typeof setTimeout>>(undefined);\n const resetTransitionTimeoutRef = useRef<ReturnType<typeof setTimeout>>(undefined);\n const resizableRef = useRef<Resizable>(null);\n const initialExpandedSizeRef = useRef<Size | undefined>(undefined);\n const resizeStartSizeRef = useRef<Size | undefined>(undefined);\n const outerRef = useRef<HTMLDivElement>(null);\n\n const { direction: antdDirection } = use(ConfigProvider.ConfigContext);\n const direction = dir ?? antdDirection;\n\n const internalPlacement = useMemo(() => {\n if (direction !== 'rtl') return placement;\n if (placement === 'left') return 'right';\n if (placement === 'right') return 'left';\n return placement;\n }, [direction, placement]);\n\n const cssVariables = {\n '--draggable-panel-bg': backgroundColor || '',\n '--draggable-panel-header-height': `${headerHeight}px`,\n } as Record<string, string>;\n\n const [isExpand, setIsExpand] = useControlledState(defaultExpand, {\n onChange: onExpandChange,\n value: expand,\n });\n\n const [shouldTransition, setShouldTransition] = useState(true);\n const [showExpand, setShowExpand] = useState(true);\n const usesStableLayout = stableLayout || collapseThreshold !== undefined;\n\n useEffect(() => {\n if (pin) return;\n\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current);\n }\n\n if (isHovering && !isExpand) {\n startTransition(() => setIsExpand(true));\n } else if (!isHovering && isExpand) {\n hoverTimeoutRef.current = setTimeout(() => {\n startTransition(() => setIsExpand(false));\n }, 150);\n }\n }, [pin, isHovering, isExpand, setIsExpand]);\n\n useEffect(() => {\n return () => {\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current);\n }\n if (resetTransitionTimeoutRef.current) {\n clearTimeout(resetTransitionTimeoutRef.current);\n }\n };\n }, []);\n\n useEffect(() => {\n initialExpandedSizeRef.current = undefined;\n }, [internalPlacement]);\n\n const reversed = reversePlacement(internalPlacement);\n const canResizing = resize !== false && isExpand;\n\n const resizing = useMemo(\n () => ({\n bottom: false,\n bottomLeft: false,\n bottomRight: false,\n left: false,\n right: false,\n top: false,\n topLeft: false,\n topRight: false,\n [reversed]: true,\n ...(resize as Enable),\n }),\n [reversed, resize],\n );\n\n const defaultSize: Size = useMemo(() => {\n if (isVertical) return { height: 180, width: '100%', ...customizeDefaultSize };\n return { height: '100%', width: 280, ...customizeDefaultSize };\n }, [isVertical, customizeDefaultSize]);\n const normalizedMaxHeight = typeof maxHeight === 'number' ? Math.max(maxHeight, 0) : undefined;\n const normalizedMaxWidth = typeof maxWidth === 'number' ? Math.max(maxWidth, 0) : undefined;\n const normalizedMinHeight = typeof minHeight === 'number' ? Math.max(minHeight, 0) : undefined;\n const normalizedMinWidth = typeof minWidth === 'number' ? Math.max(minWidth, 0) : undefined;\n\n const sizeProps = useMemo(() => {\n if (!usesStableLayout && !isExpand) {\n return isVertical\n ? { minHeight: 0, size: { height: 0 } }\n : { minWidth: 0, size: { width: 0 } };\n }\n\n return {\n defaultSize,\n maxHeight: normalizedMaxHeight,\n maxWidth: normalizedMaxWidth,\n minHeight: normalizedMinHeight,\n minWidth: normalizedMinWidth,\n size: size as Size,\n };\n }, [\n usesStableLayout,\n isExpand,\n isVertical,\n defaultSize,\n normalizedMaxHeight,\n normalizedMaxWidth,\n normalizedMinHeight,\n normalizedMinWidth,\n size,\n ]);\n\n const fallbackExpandedSize = isVertical ? '180px' : '280px';\n const controlledExpandedSize = useMemo(() => {\n const controlledSize = isVertical ? size?.height : size?.width;\n if (controlledSize === undefined) return undefined;\n return toCssSize(controlledSize, fallbackExpandedSize);\n }, [isVertical, size?.height, size?.width, fallbackExpandedSize]);\n const defaultExpandedSize = useMemo(() => {\n const initialSize = isVertical ? defaultSize.height : defaultSize.width;\n return toCssSize(initialSize, fallbackExpandedSize);\n }, [isVertical, defaultSize.height, defaultSize.width, fallbackExpandedSize]);\n const [resizedExpandedSize, setResizedExpandedSize] = useState<{\n horizontal?: string;\n vertical?: string;\n }>({});\n const expandedOuterSize =\n controlledExpandedSize ??\n (isVertical ? resizedExpandedSize.vertical : resizedExpandedSize.horizontal) ??\n defaultExpandedSize;\n\n const setExpandedMainSize = useCallback(\n (nextSize: Size) => {\n if (!usesStableLayout) return;\n\n const currentSize = isVertical ? nextSize.height : nextSize.width;\n if (!currentSize) return;\n\n const normalizedSize = toCssSize(currentSize, fallbackExpandedSize);\n setResizedExpandedSize((state) =>\n isVertical\n ? { ...state, vertical: normalizedSize }\n : { ...state, horizontal: normalizedSize },\n );\n },\n [fallbackExpandedSize, isVertical, usesStableLayout],\n );\n\n const readCurrentSize = useCallback((): Size | undefined => {\n const rect = resizableRef.current?.resizable?.getBoundingClientRect();\n if (!rect) return undefined;\n\n return isVertical\n ? { height: rect.height, width: '100%' }\n : { height: '100%', width: rect.width };\n }, [isVertical]);\n\n const captureInitialExpandedSize = useCallback(() => {\n if (initialExpandedSizeRef.current) return initialExpandedSizeRef.current;\n\n const nextInitialSize = readCurrentSize();\n if (!nextInitialSize) return undefined;\n\n initialExpandedSizeRef.current = nextInitialSize;\n return nextInitialSize;\n }, [readCurrentSize]);\n\n useEffect(() => {\n if (!isExpand) return;\n captureInitialExpandedSize();\n }, [captureInitialExpandedSize, isExpand]);\n\n const toggleExpand = useCallback(() => {\n if (expandable) setIsExpand(!isExpand);\n }, [expandable, isExpand, setIsExpand]);\n\n const clampResizeSize = useCallback(\n (el: HTMLElement) => {\n const rect = el.getBoundingClientRect();\n const currentMainSize = isVertical ? rect.height : rect.width;\n const minMainSize = isVertical ? normalizedMinHeight : normalizedMinWidth;\n const maxMainSize = isVertical ? normalizedMaxHeight : normalizedMaxWidth;\n\n let clampedMainSize = currentMainSize;\n if (typeof minMainSize === 'number')\n clampedMainSize = Math.max(clampedMainSize, minMainSize);\n if (typeof maxMainSize === 'number')\n clampedMainSize = Math.min(clampedMainSize, maxMainSize);\n\n if (\n !Number.isFinite(clampedMainSize) ||\n Math.abs(clampedMainSize - currentMainSize) < 0.5\n ) {\n return { height: el.style.height, width: el.style.width };\n }\n\n const width = isVertical ? el.style.width || '100%' : `${clampedMainSize}px`;\n const height = isVertical ? `${clampedMainSize}px` : el.style.height || '100%';\n resizableRef.current?.updateSize({ height, width });\n\n return { height, width };\n },\n [\n isVertical,\n normalizedMaxHeight,\n normalizedMaxWidth,\n normalizedMinHeight,\n normalizedMinWidth,\n ],\n );\n\n const handleResize = useCallback(\n (_event: unknown, _direction: unknown, el: HTMLElement, delta: NumberSize) => {\n const nextSize = clampResizeSize(el);\n const nextCollapsePreview = isBelowCollapseThreshold({\n axis: isVertical ? 'height' : 'width',\n collapseThreshold,\n size: nextSize,\n });\n\n if (usesStableLayout && outerRef.current) {\n // Sync outer DOM width immediately so it doesn't lag behind the\n // re-resizable inline style (which would otherwise trigger a 0.2s\n // width transition on the outer/aside each frame during drag).\n const dimension = isVertical ? nextSize.height : nextSize.width;\n if (dimension) {\n const previewDimension = nextCollapsePreview ? '0px' : dimension;\n if (isVertical) outerRef.current.style.height = previewDimension;\n else outerRef.current.style.width = previewDimension;\n }\n }\n // With drag-to-collapse enabled, defer the persisted expanded size until\n // pointer release. This keeps the pre-drag width as the single source of\n // truth while the outer stable-layout layer previews collapse/restore.\n if (collapseThreshold === undefined) setExpandedMainSize(nextSize);\n onSizeDragging?.(delta, nextSize);\n },\n [\n clampResizeSize,\n collapseThreshold,\n isVertical,\n onSizeDragging,\n setExpandedMainSize,\n usesStableLayout,\n ],\n );\n\n const triggerResetWithoutTransition = useCallback(() => {\n if (resetTransitionTimeoutRef.current) {\n clearTimeout(resetTransitionTimeoutRef.current);\n }\n\n setShouldTransition(false);\n resetTransitionTimeoutRef.current = setTimeout(() => {\n setShouldTransition(true);\n }, 0);\n }, []);\n\n const handleResetSize = useCallback(() => {\n if (!canResizing) return;\n\n const resetSize = captureInitialExpandedSize();\n if (!resetSize) return;\n\n triggerResetWithoutTransition();\n\n const rect = resizableRef.current?.resizable?.getBoundingClientRect();\n const prevMainSize = rect ? (isVertical ? rect.height : rect.width) : 0;\n const resetMainSize = isVertical ? resetSize.height : resetSize.width;\n const nextMainSize = typeof resetMainSize === 'number' ? resetMainSize : prevMainSize;\n\n resizableRef.current?.updateSize(resetSize);\n setExpandedMainSize(resetSize);\n\n onSizeChange?.(\n isVertical\n ? { height: nextMainSize - prevMainSize, width: 0 }\n : { height: 0, width: nextMainSize - prevMainSize },\n resetSize,\n );\n }, [\n canResizing,\n captureInitialExpandedSize,\n isVertical,\n onSizeChange,\n setExpandedMainSize,\n triggerResetWithoutTransition,\n ]);\n\n const handleResizeStart = useCallback(\n (event: { detail?: number }) => {\n if (event.detail === 2) {\n handleResetSize();\n return false;\n }\n\n if (resetTransitionTimeoutRef.current) {\n clearTimeout(resetTransitionTimeoutRef.current);\n resetTransitionTimeoutRef.current = undefined;\n }\n\n resizeStartSizeRef.current = readCurrentSize();\n\n // Synchronously disable the outer transition so the first drag frame\n // does not animate. `setShouldTransition(false)` below is asynchronous\n // and would only take effect after the next React commit.\n if (usesStableLayout && outerRef.current) {\n outerRef.current.style.transition = 'none';\n }\n setShouldTransition(false);\n setShowExpand(false);\n },\n [handleResetSize, readCurrentSize, usesStableLayout],\n );\n\n const handleResizeStop = useCallback(\n (_event: unknown, _direction: unknown, el: HTMLElement, delta: NumberSize) => {\n const nextSize = clampResizeSize(el);\n const shouldCollapse = isBelowCollapseThreshold({\n axis: isVertical ? 'height' : 'width',\n collapseThreshold,\n size: nextSize,\n });\n const committedSize = shouldCollapse ? (resizeStartSizeRef.current ?? nextSize) : nextSize;\n\n resizableRef.current?.updateSize(committedSize);\n if (!shouldCollapse) setExpandedMainSize(committedSize);\n setShouldTransition(true);\n setShowExpand(true);\n // Keep the collapsed main-axis size at zero until the controlled\n // `expand=false` value arrives. Clearing it here would reveal the panel\n // for one render between preview teardown and controlled-state commit.\n if (usesStableLayout && outerRef.current) {\n outerRef.current.style.removeProperty('transition');\n if (shouldCollapse) {\n if (isVertical) outerRef.current.style.height = '0px';\n else outerRef.current.style.width = '0px';\n } else {\n outerRef.current.style.removeProperty('width');\n outerRef.current.style.removeProperty('height');\n }\n }\n if (shouldCollapse) setIsExpand(false);\n\n resizeStartSizeRef.current = undefined;\n onSizeChange?.(delta, committedSize);\n },\n [\n clampResizeSize,\n collapseThreshold,\n isVertical,\n onSizeChange,\n setExpandedMainSize,\n setIsExpand,\n usesStableLayout,\n ],\n );\n\n const resizeHandleClassName = useMemo(\n () =>\n cx(handleVariants({ placement: reversed }), showHandleHighlight && styles.handleHighlight),\n [reversed, showHandleHighlight],\n );\n\n if (fullscreen) {\n return (\n <div className={cx(styles.fullscreen, className)} style={cssVariables}>\n {children}\n </div>\n );\n }\n\n const Arrow = ARROW_MAP[internalPlacement] ?? ChevronLeft;\n const stableOuterFlex = usesStableLayout\n ? ({\n display: 'flex',\n flexDirection: 'column',\n minHeight: 0,\n } as const)\n : {};\n\n const sidebarOuterStyle = isVertical\n ? {\n height: isExpand ? expandedOuterSize : 0,\n overflow: 'hidden',\n transition: shouldTransition ? 'height 0.2s var(--ant-motion-ease-out, ease)' : 'none',\n width: '100%',\n ...stableOuterFlex,\n }\n : {\n overflow: 'hidden',\n transition: shouldTransition ? 'width 0.2s var(--ant-motion-ease-out, ease)' : 'none',\n width: isExpand ? expandedOuterSize : 0,\n ...(usesStableLayout\n ? {\n ...stableOuterFlex,\n flex: 1,\n minWidth: 0,\n height: '100%',\n }\n : {}),\n };\n\n const stableInnerStyle: CSSProperties = {\n display: 'flex',\n flex: 1,\n flexDirection: 'column',\n height: '100%',\n minHeight: 0,\n minWidth: 0,\n width: '100%',\n };\n const sidebarInnerStyle: CSSProperties = usesStableLayout\n ? stableInnerStyle\n : isVertical\n ? { height: '100%', width: '100%' }\n : { width: '100%' };\n\n const stableAsideStyle: CSSProperties = usesStableLayout\n ? {\n display: 'flex',\n flexDirection: 'column',\n minHeight: 0,\n ...(mode === 'fixed' ? { height: '100%' } : {}),\n }\n : {};\n\n const stableResizableStyle: CSSProperties = {\n display: 'flex',\n flex: 1,\n flexDirection: 'column',\n height: '100%',\n minHeight: 0,\n minWidth: 0,\n width: '100%',\n };\n\n const panelNode = (!destroyOnClose || isExpand) && (\n <Resizable\n ref={resizableRef}\n {...sizeProps}\n className={cx(styles.panel, classNames?.content)}\n enable={canResizing ? (resizing as Enable) : DISABLED_RESIZING}\n handleClasses={\n canResizing\n ? {\n [reversed]: resizeHandleClassName,\n }\n : {}\n }\n style={{\n ...cssVariables,\n transition: shouldTransition ? undefined : 'none',\n ...(usesStableLayout ? stableResizableStyle : {}),\n ...style,\n }}\n onResize={handleResize}\n onResizeStart={handleResizeStart}\n onResizeStop={handleResizeStop}\n >\n {usesStableLayout ? <div style={sidebarInnerStyle}>{children}</div> : children}\n </Resizable>\n );\n\n return (\n <aside\n dir={dir}\n ref={ref}\n style={{ ...cssVariables, ...stableAsideStyle }}\n className={cx(\n panelVariants({ isExpand, mode, placement: internalPlacement, showBorder }),\n className,\n )}\n >\n {expandable && showExpand && (\n <Center\n className={toggleVariants({ placement: internalPlacement, showHandleWideArea })}\n style={{\n opacity: isExpand ? (pin ? undefined : 0) : showHandleWhenCollapsed ? 1 : 0,\n }}\n >\n <Center\n className={classNames?.handle}\n style={customStyles?.handle}\n onClick={toggleExpand}\n >\n <Icon\n className={styles.handlerIcon}\n icon={Arrow}\n size={16}\n style={{\n ...MARGIN_MAP[internalPlacement],\n transform: `rotate(${isExpand ? 180 : 0}deg)`,\n transition: 'transform 0.3s ease',\n }}\n />\n </Center>\n </Center>\n )}\n {usesStableLayout ? (\n <div ref={outerRef} style={sidebarOuterStyle}>\n {panelNode}\n </div>\n ) : (\n panelNode\n )}\n </aside>\n );\n },\n isEqual,\n);\n\nDraggablePanel.displayName = 'DraggablePanel';\n\nexport default DraggablePanel;\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,YAAY;CAChB,QAAQ;CACR,MAAM;CACN,OAAO;CACP,KAAK;AACP;AAEA,MAAM,aAAa;CACjB,QAAQ,EAAE,WAAW,EAAE;CACvB,MAAM,EAAE,aAAa,EAAE;CACvB,OAAO,EAAE,YAAY,EAAE;CACvB,KAAK,EAAE,cAAc,EAAE;AACzB;AAEA,MAAM,oBAA4B;CAChC,QAAQ;CACR,YAAY;CACZ,aAAa;CACb,MAAM;CACN,OAAO;CACP,KAAK;CACL,SAAS;CACT,UAAU;AACZ;AAEA,MAAM,aAAa,OAAoC,aAAqB;CAC1E,IAAI,OAAO,UAAU,UAAU,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,EAAE;CAC5D,IAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG,OAAO;CAC1D,OAAO;AACT;AAEA,MAAM,iBAAiB,MACpB,EACC,eAAe,GACf,YACA,WACA,MAAM,MACN,OAAO,SACP,UACA,YAAY,SACZ,QACA,OACA,aAAa,MACb,sBAAsB,OACtB,qBAAqB,MACrB,iBACA,mBACA,MACA,eAAe,OACf,aAAa,sBACb,UACA,WACA,UACA,cACA,gBACA,aAAa,MACb,QACA,gBAAgB,MAChB,gBACA,WACA,yBACA,gBACA,QAAQ,cACR,YACA,UACI;CACJ,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,aAAa,SAAS,GAAG;CAC/B,MAAM,aAAa,cAAc,SAAS,cAAc;CACxD,MAAM,kBAAkB,OAAsC,KAAA,CAAS;CACvE,MAAM,4BAA4B,OAAsC,KAAA,CAAS;CACjF,MAAM,eAAe,OAAkB,IAAI;CAC3C,MAAM,yBAAyB,OAAyB,KAA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D,CAAA;GACK,CAAA;EACF,CAAA,GAET,mBACC,oBAAC,OAAD;GAAK,KAAK;GAAU,OAAO;aACxB;EACE,CAAA,IAEL,SAEG;;AAEX,GACA,OACF;AAEA,eAAe,cAAc"}
|
|
@@ -10,6 +10,14 @@ interface DraggablePanelProps extends DivProps {
|
|
|
10
10
|
content?: string;
|
|
11
11
|
handle?: string;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Preview a collapsed panel while resizing at or below this size, then commit
|
|
15
|
+
* the collapsed state on pointer release. Dragging back above the threshold
|
|
16
|
+
* before release restores the panel.
|
|
17
|
+
* Applies to width for left/right placement and height for top/bottom placement.
|
|
18
|
+
* Omit to disable drag-to-collapse behavior.
|
|
19
|
+
*/
|
|
20
|
+
collapseThreshold?: number;
|
|
13
21
|
defaultExpand?: boolean;
|
|
14
22
|
defaultSize?: Partial<Size>;
|
|
15
23
|
destroyOnClose?: boolean;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
//#region src/DraggablePanel/utils.ts
|
|
2
|
+
const isBelowCollapseThreshold = ({ axis, collapseThreshold, size }) => {
|
|
3
|
+
if (collapseThreshold === void 0) return false;
|
|
4
|
+
const currentSize = size[axis];
|
|
5
|
+
if (currentSize === void 0) return false;
|
|
6
|
+
const numericSize = typeof currentSize === "number" ? currentSize : Number.parseFloat(currentSize);
|
|
7
|
+
return Number.isFinite(numericSize) && numericSize <= Math.max(collapseThreshold, 0);
|
|
8
|
+
};
|
|
2
9
|
const reversePlacement = (placement) => {
|
|
3
10
|
switch (placement) {
|
|
4
11
|
case "bottom": return "top";
|
|
@@ -8,6 +15,6 @@ const reversePlacement = (placement) => {
|
|
|
8
15
|
}
|
|
9
16
|
};
|
|
10
17
|
//#endregion
|
|
11
|
-
export { reversePlacement };
|
|
18
|
+
export { isBelowCollapseThreshold, reversePlacement };
|
|
12
19
|
|
|
13
20
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/DraggablePanel/utils.ts"],"sourcesContent":["import type { DraggablePanelProps } from './type';\n\nexport const reversePlacement = (placement: DraggablePanelProps['placement']) => {\n switch (placement) {\n case 'bottom': {\n return 'top';\n }\n case 'top': {\n return 'bottom';\n }\n case 'right': {\n return 'left';\n }\n case 'left': {\n return 'right';\n }\n }\n};\n"],"mappings":";AAEA,MAAa,oBAAoB,cAAgD;CAC/E,QAAQ,WAAR;EACE,KAAK,UACH,OAAO;EAET,KAAK,OACH,OAAO;EAET,KAAK,SACH,OAAO;EAET,KAAK,QACH,OAAO;CAEX;AACF"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/DraggablePanel/utils.ts"],"sourcesContent":["import type { Size } from 're-resizable';\n\nimport type { DraggablePanelProps } from './type';\n\ninterface IsBelowCollapseThresholdOptions {\n axis: 'height' | 'width';\n collapseThreshold?: number;\n size: Size;\n}\n\nexport const isBelowCollapseThreshold = ({\n axis,\n collapseThreshold,\n size,\n}: IsBelowCollapseThresholdOptions): boolean => {\n if (collapseThreshold === undefined) return false;\n\n const currentSize = size[axis];\n if (currentSize === undefined) return false;\n\n const numericSize =\n typeof currentSize === 'number' ? currentSize : Number.parseFloat(currentSize);\n\n return Number.isFinite(numericSize) && numericSize <= Math.max(collapseThreshold, 0);\n};\n\nexport const reversePlacement = (placement: DraggablePanelProps['placement']) => {\n switch (placement) {\n case 'bottom': {\n return 'top';\n }\n case 'top': {\n return 'bottom';\n }\n case 'right': {\n return 'left';\n }\n case 'left': {\n return 'right';\n }\n }\n};\n"],"mappings":";AAUA,MAAa,4BAA4B,EACvC,MACA,mBACA,WAC8C;CAC9C,IAAI,sBAAsB,KAAA,GAAW,OAAO;CAE5C,MAAM,cAAc,KAAK;CACzB,IAAI,gBAAgB,KAAA,GAAW,OAAO;CAEtC,MAAM,cACJ,OAAO,gBAAgB,WAAW,cAAc,OAAO,WAAW,WAAW;CAE/E,OAAO,OAAO,SAAS,WAAW,KAAK,eAAe,KAAK,IAAI,mBAAmB,CAAC;AACrF;AAEA,MAAa,oBAAoB,cAAgD;CAC/E,QAAQ,WAAR;EACE,KAAK,UACH,OAAO;EAET,KAAK,OACH,OAAO;EAET,KAAK,SACH,OAAO;EAET,KAAK,QACH,OAAO;CAEX;AACF"}
|