@lobehub/ui 5.26.0 → 5.28.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/README.md +6 -6
- package/es/Image/Image.mjs +3 -2
- package/es/Image/Image.mjs.map +1 -1
- package/es/Image/style.mjs +19 -13
- package/es/Image/style.mjs.map +1 -1
- package/es/Image/type.d.mts +3 -0
- package/es/Image/viewer/ActualSizeIcon.mjs +44 -0
- package/es/Image/viewer/ActualSizeIcon.mjs.map +1 -0
- package/es/Image/viewer/ImageViewer.mjs +12 -3
- package/es/Image/viewer/ImageViewer.mjs.map +1 -1
- package/es/Image/viewer/Toolbar.mjs +17 -13
- package/es/Image/viewer/Toolbar.mjs.map +1 -1
- package/es/Image/viewer/ViewerChrome.mjs.map +1 -1
- package/es/Image/viewer/geometry.d.mts +5 -0
- package/es/Image/viewer/geometry.mjs +13 -1
- package/es/Image/viewer/geometry.mjs.map +1 -1
- package/es/Image/viewer/registry.mjs.map +1 -1
- package/es/Image/viewer/useFlipTransition.mjs +7 -4
- package/es/Image/viewer/useFlipTransition.mjs.map +1 -1
- package/es/Image/viewer/useGalleryNav.mjs +6 -5
- package/es/Image/viewer/useGalleryNav.mjs.map +1 -1
- package/es/Image/viewer/useViewerGestures.mjs +2 -6
- package/es/Image/viewer/useViewerGestures.mjs.map +1 -1
- package/es/Image/viewer/useZoomPan.mjs +80 -23
- package/es/Image/viewer/useZoomPan.mjs.map +1 -1
- package/es/Markdown/SyntaxMarkdown/CachedMarkdown.mjs +1 -1
- package/es/Markdown/plugins/rehypeCustomFootnotes.mjs +1 -1
- package/es/Markdown/plugins/rehypeKatexDir.d.mts +1 -1
- package/es/Markdown/plugins/rehypeKatexDir.mjs +1 -1
- package/es/Markdown/plugins/rehypeStreamAnimated.d.mts +1 -1
- package/es/Markdown/plugins/rehypeStreamAnimated.mjs +1 -1
- package/es/Markdown/plugins/remarkBr.mjs +1 -1
- package/es/Markdown/plugins/remarkColor.mjs +1 -1
- package/es/Markdown/plugins/remarkCustomFootnotes.mjs +2 -2
- package/es/Markdown/plugins/remarkGfmPlus.mjs +1 -1
- package/es/Markdown/plugins/remarkVideo.mjs +1 -1
- package/es/base-ui/Toast/imperative.mjs +30 -15
- package/es/base-ui/Toast/imperative.mjs.map +1 -1
- package/es/base-ui/Toast/type.d.mts +7 -0
- package/es/i18n/resources/en/image.d.mts +2 -1
- package/es/i18n/resources/en/image.mjs +3 -2
- package/es/i18n/resources/en/image.mjs.map +1 -1
- package/es/i18n/resources/zhCn/image.d.mts +2 -1
- package/es/i18n/resources/zhCn/image.mjs +3 -2
- package/es/i18n/resources/zhCn/image.mjs.map +1 -1
- package/es/index.d.mts +2 -2
- package/es/mdx/mdxComponents/index.d.mts +1 -1
- package/es/node_modules/{.bun → .pnpm}/@types_hast@3.0.5/node_modules/@types/hast/index.d.mts +1 -1
- package/es/node_modules/{.bun → .pnpm}/@types_mdx@2.0.14/node_modules/@types/mdx/types.d.mts +1 -1
- package/es/node_modules/{.bun → .pnpm}/@types_unist@3.0.3/node_modules/@types/unist/index.d.mts +1 -1
- package/es/node_modules/{.bun → .pnpm}/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.mjs +1 -1
- package/es/node_modules/.pnpm/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.mjs.map +1 -0
- package/es/node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.mjs +12 -0
- package/es/node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.mjs.map +1 -0
- package/es/node_modules/{.bun → .pnpm}/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.mjs +1 -1
- package/es/node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.mjs.map +1 -0
- package/es/node_modules/{.bun → .pnpm}/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs +1 -1
- package/es/node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs.map +1 -0
- package/package.json +4 -5
- package/es/node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.mjs.map +0 -1
- package/es/node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.mjs +0 -12
- package/es/node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.mjs.map +0 -1
- package/es/node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.mjs.map +0 -1
- package/es/node_modules/.bun/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useZoomPan.mjs","names":[],"sources":["../../../src/Image/viewer/useZoomPan.ts"],"sourcesContent":["import type { MotionValue } from 'motion/react';\nimport { animate, motionValue } from 'motion/react';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { Point, Rect, Rotation, Size, TransformState } from './geometry';\nimport {\n anchoredZoom,\n clampPan,\n clampScale,\n computeFit,\n DEFAULT_MAX_SCALE,\n doubleClickTarget,\n normalizeRotation,\n panBounds,\n rubberBand,\n wheelZoomFactor,\n} from './geometry';\n\nconst WHEEL_CLOSE_THRESHOLD = 100;\nconst WHEEL_IDLE_MS = 300;\nconst ZOOM_STEP = 1.5;\nconst RESET_TRANSITION = { damping: 30, stiffness: 300, type: 'spring' as const };\nconst CLEAN_EPSILON = 0.01;\n\nexport interface WheelLikeEvent {\n clientX: number;\n clientY: number;\n ctrlKey?: boolean;\n deltaY: number;\n metaKey?: boolean;\n preventDefault?: () => void;\n}\n\nexport interface UseZoomPanOptions {\n fillViewport?: boolean;\n isClosing?: () => boolean;\n maxScale?: number;\n natural: Size;\n onCloseRequest?: () => void;\n viewport: Size;\n}\n\nexport interface UseZoomPanResult {\n canZoomIn: boolean;\n canZoomOut: boolean;\n dragBy: (delta: Point) => void;\n dragEnd: () => void;\n escIntent: () => 'reset' | 'close';\n flipHorizontal: () => void;\n flipVertical: () => void;\n flipX: MotionValue<boolean>;\n flipY: MotionValue<boolean>;\n handleDoubleClick: (point: Point) => void;\n handleWheel: (event: WheelLikeEvent) => void;\n isClean: boolean;\n isZoomed: boolean;\n reset: () => void;\n resetCloseTracking: () => void;\n rotate: MotionValue<number>;\n rotateLeft: () => void;\n rotateRight: () => void;\n rotation: Rotation;\n scale: MotionValue<number>;\n setNatural: (natural: Size) => void;\n setViewport: (viewport: Size) => void;\n x: MotionValue<number>;\n y: MotionValue<number>;\n zoomIn: () => void;\n zoomOut: () => void;\n}\n\ninterface DerivedState {\n canZoomIn: boolean;\n canZoomOut: boolean;\n isClean: boolean;\n isZoomed: boolean;\n rotation: Rotation;\n}\n\nexport const useZoomPan = ({\n natural,\n viewport,\n maxScale,\n onCloseRequest,\n isClosing,\n fillViewport,\n}: UseZoomPanOptions): UseZoomPanResult => {\n const [{ scale, x, y, rotate, flipX, flipY }] = useState(() => ({\n flipX: motionValue(false),\n flipY: motionValue(false),\n rotate: motionValue(0),\n scale: motionValue(1),\n x: motionValue(0),\n y: motionValue(0),\n }));\n\n const naturalRef = useRef(natural);\n const viewportRef = useRef(viewport);\n const maxScaleRef = useRef(maxScale ?? DEFAULT_MAX_SCALE);\n maxScaleRef.current = maxScale ?? DEFAULT_MAX_SCALE;\n const fillViewportRef = useRef(fillViewport ?? false);\n fillViewportRef.current = fillViewport ?? false;\n\n const onCloseRequestRef = useRef(onCloseRequest);\n onCloseRequestRef.current = onCloseRequest;\n\n const isClosingRef = useRef(isClosing);\n isClosingRef.current = isClosing;\n\n const closeAccumRef = useRef(0);\n const disarmedRef = useRef(false);\n const idleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const resetCloseTracking = useCallback(() => {\n if (idleTimerRef.current !== null) {\n clearTimeout(idleTimerRef.current);\n idleTimerRef.current = null;\n }\n closeAccumRef.current = 0;\n disarmedRef.current = false;\n }, []);\n\n // The close FLIP spring animates these same scale/x/y values. Any of\n // these entry points still firing during the ~300ms close window would\n // either fight that spring visually or, for wheel/reset specifically,\n // race escIntent()/isCleanState() into cancelling the close outright.\n const closing = useCallback(() => isClosingRef.current?.() ?? false, []);\n\n const isCleanState = useCallback(\n () =>\n Math.abs(scale.get() - 1) < CLEAN_EPSILON &&\n Math.abs(rotate.get()) < CLEAN_EPSILON &&\n !flipX.get() &&\n !flipY.get(),\n [flipX, flipY, rotate, scale],\n );\n\n const computeDerived = useCallback((): DerivedState => {\n const currentScale = scale.get();\n return {\n canZoomIn: currentScale < maxScaleRef.current,\n canZoomOut: currentScale > 1,\n isClean: isCleanState(),\n isZoomed: currentScale > 1,\n rotation: normalizeRotation(rotate.get()),\n };\n }, [isCleanState, rotate, scale]);\n\n const [derived, setDerived] = useState<DerivedState>(computeDerived);\n\n const syncDerived = useCallback(() => {\n setDerived((prev) => {\n const next = computeDerived();\n if (\n prev.canZoomIn === next.canZoomIn &&\n prev.canZoomOut === next.canZoomOut &&\n prev.isClean === next.isClean &&\n prev.isZoomed === next.isZoomed &&\n prev.rotation === next.rotation\n ) {\n return prev;\n }\n return next;\n });\n }, [computeDerived]);\n\n useEffect(() => {\n const unsubscribers = [scale, rotate, flipX, flipY].map((value) =>\n value.on('change', syncDerived),\n );\n syncDerived();\n return () => {\n for (const unsubscribe of unsubscribers) unsubscribe();\n };\n }, [flipX, flipY, rotate, scale, syncDerived]);\n\n const getFitRect = useCallback(\n () =>\n computeFit(\n naturalRef.current,\n viewportRef.current,\n normalizeRotation(rotate.get()),\n fillViewportRef.current,\n ),\n [rotate],\n );\n\n const applyTransform = useCallback(\n (next: TransformState, fitRect: Rect) => {\n const clamped = clampPan(next, fitRect, viewportRef.current);\n // .jump(), not .set(): a surviving spring on these same values (e.g. a\n // dragEnd clamp-back or wheel snap-back still in flight) would otherwise\n // keep animating toward its own target and silently overwrite this\n // instant write on its next tick — motion's set() never stops an\n // active animation, only jump() does.\n scale.jump(next.scale);\n x.jump(clamped.x);\n y.jump(clamped.y);\n },\n [scale, x, y],\n );\n\n // Wheel/pinch stays on the instant applyTransform for 1:1 gesture tracking;\n // stepped inputs (toolbar/keyboard zoom, double-click) animate instead.\n const animateTransform = useCallback(\n (next: TransformState, fitRect: Rect) => {\n const clamped = clampPan(next, fitRect, viewportRef.current);\n animate(scale, next.scale, RESET_TRANSITION);\n animate(x, clamped.x, RESET_TRANSITION);\n animate(y, clamped.y, RESET_TRANSITION);\n },\n [scale, x, y],\n );\n\n const zoomBy = useCallback(\n (factor: number) => {\n if (closing()) return;\n const currentScale = scale.get();\n const targetScale = clampScale(currentScale * factor, maxScaleRef.current);\n const fitRect = getFitRect();\n const anchor: Point = { x: viewportRef.current.width / 2, y: viewportRef.current.height / 2 };\n const next = anchoredZoom(\n { scale: currentScale, x: x.get(), y: y.get() },\n targetScale,\n anchor,\n fitRect,\n );\n animateTransform(next, fitRect);\n },\n [animateTransform, closing, getFitRect, scale, x, y],\n );\n\n const zoomIn = useCallback(() => zoomBy(ZOOM_STEP), [zoomBy]);\n const zoomOut = useCallback(() => zoomBy(1 / ZOOM_STEP), [zoomBy]);\n\n const handleDoubleClick = useCallback(\n (point: Point) => {\n if (closing()) return;\n const currentScale = scale.get();\n const fitRect = getFitRect();\n const target = doubleClickTarget(\n currentScale,\n naturalRef.current,\n fitRect,\n normalizeRotation(rotate.get()),\n );\n const targetScale = clampScale(target, maxScaleRef.current);\n const next = anchoredZoom(\n { scale: currentScale, x: x.get(), y: y.get() },\n targetScale,\n point,\n fitRect,\n );\n animateTransform(next, fitRect);\n },\n [animateTransform, closing, getFitRect, rotate, scale, x, y],\n );\n\n const handleWheel = useCallback(\n (event: WheelLikeEvent) => {\n event.preventDefault?.();\n if (closing()) return;\n\n if (idleTimerRef.current !== null) clearTimeout(idleTimerRef.current);\n idleTimerRef.current = setTimeout(() => {\n idleTimerRef.current = null;\n closeAccumRef.current = 0;\n disarmedRef.current = false;\n }, WHEEL_IDLE_MS);\n\n const currentScale = scale.get();\n const isPinch = !!(event.ctrlKey || event.metaKey);\n const zoomed = currentScale > 1;\n\n if (isPinch || zoomed) {\n disarmedRef.current = true;\n closeAccumRef.current = 0;\n\n const rawTarget = currentScale * wheelZoomFactor(event.deltaY);\n\n if (rawTarget <= 1) {\n animate(scale, 1, RESET_TRANSITION);\n animate(x, 0, RESET_TRANSITION);\n animate(y, 0, RESET_TRANSITION);\n return;\n }\n\n const targetScale = clampScale(rawTarget, maxScaleRef.current);\n const fitRect = getFitRect();\n const anchor: Point = { x: event.clientX, y: event.clientY };\n const next = anchoredZoom(\n { scale: currentScale, x: x.get(), y: y.get() },\n targetScale,\n anchor,\n fitRect,\n );\n applyTransform(next, fitRect);\n return;\n }\n\n if (disarmedRef.current || !isCleanState()) return;\n\n closeAccumRef.current += Math.abs(event.deltaY);\n if (closeAccumRef.current >= WHEEL_CLOSE_THRESHOLD) {\n closeAccumRef.current = 0;\n onCloseRequestRef.current?.();\n }\n },\n [applyTransform, closing, getFitRect, isCleanState, scale, x, y],\n );\n\n const rotateBy = useCallback(\n (delta: 90 | -90) => {\n if (closing()) return;\n rotate.jump(normalizeRotation(rotate.get() + delta));\n scale.jump(1);\n x.jump(0);\n y.jump(0);\n },\n [closing, rotate, scale, x, y],\n );\n\n const rotateLeft = useCallback(() => rotateBy(-90), [rotateBy]);\n const rotateRight = useCallback(() => rotateBy(90), [rotateBy]);\n\n const flipHorizontal = useCallback(() => {\n if (closing()) return;\n flipX.set(!flipX.get());\n }, [closing, flipX]);\n\n const flipVertical = useCallback(() => {\n if (closing()) return;\n flipY.set(!flipY.get());\n }, [closing, flipY]);\n\n const reset = useCallback(() => {\n if (closing()) return;\n animate(scale, 1, RESET_TRANSITION);\n animate(x, 0, RESET_TRANSITION);\n animate(y, 0, RESET_TRANSITION);\n animate(rotate, 0, RESET_TRANSITION);\n flipX.set(false);\n flipY.set(false);\n }, [closing, flipX, flipY, rotate, scale, x, y]);\n\n const dragBy = useCallback(\n (delta: Point) => {\n // A pointer can still be down when close starts (e.g. pinch to just\n // over 1x — inside isClean's epsilon, so Esc/wheel reads 'close' —\n // while the same gesture is still panning). Gated for consistency\n // with the other entry points even though .set() here can't cancel\n // the close spring outright, only cause a self-correcting flicker.\n if (closing()) return;\n const fitRect = getFitRect();\n const bounds = panBounds({ scale: scale.get(), x: 0, y: 0 }, fitRect, viewportRef.current);\n x.set(rubberBand(x.get() + delta.x, bounds.x.min, bounds.x.max));\n y.set(rubberBand(y.get() + delta.y, bounds.y.min, bounds.y.max));\n },\n [closing, getFitRect, scale, x, y],\n );\n\n const dragEnd = useCallback(() => {\n if (closing()) return;\n const fitRect = getFitRect();\n const clamped = clampPan(\n { scale: scale.get(), x: x.get(), y: y.get() },\n fitRect,\n viewportRef.current,\n );\n animate(x, clamped.x, RESET_TRANSITION);\n animate(y, clamped.y, RESET_TRANSITION);\n }, [closing, getFitRect, scale, x, y]);\n\n const escIntent = useCallback(\n (): 'reset' | 'close' => (isCleanState() ? 'close' : 'reset'),\n [isCleanState],\n );\n\n const setViewport = useCallback(\n (next: Size) => {\n viewportRef.current = next;\n const fitRect = computeFit(\n naturalRef.current,\n next,\n normalizeRotation(rotate.get()),\n fillViewportRef.current,\n );\n const clamped = clampPan({ scale: scale.get(), x: x.get(), y: y.get() }, fitRect, next);\n x.set(clamped.x);\n y.set(clamped.y);\n },\n [rotate, scale, x, y],\n );\n\n const setNatural = useCallback(\n (next: Size) => {\n naturalRef.current = next;\n const fitRect = computeFit(\n next,\n viewportRef.current,\n normalizeRotation(rotate.get()),\n fillViewportRef.current,\n );\n const clamped = clampPan(\n { scale: scale.get(), x: x.get(), y: y.get() },\n fitRect,\n viewportRef.current,\n );\n x.set(clamped.x);\n y.set(clamped.y);\n },\n [rotate, scale, x, y],\n );\n\n return {\n canZoomIn: derived.canZoomIn,\n canZoomOut: derived.canZoomOut,\n dragBy,\n dragEnd,\n escIntent,\n flipHorizontal,\n flipVertical,\n flipX,\n flipY,\n handleDoubleClick,\n handleWheel,\n isClean: derived.isClean,\n isZoomed: derived.isZoomed,\n reset,\n resetCloseTracking,\n rotate,\n rotateLeft,\n rotateRight,\n rotation: derived.rotation,\n scale,\n setNatural,\n setViewport,\n x,\n y,\n zoomIn,\n zoomOut,\n };\n};\n\nexport type { Point, Rotation, Size } from './geometry';\n"],"mappings":";;;;AAkBA,MAAM,wBAAwB;AAC9B,MAAM,gBAAgB;AACtB,MAAM,YAAY;AAClB,MAAM,mBAAmB;CAAE,SAAS;CAAI,WAAW;CAAK,MAAM;AAAkB;AAChF,MAAM,gBAAgB;AAyDtB,MAAa,cAAc,EACzB,SACA,UACA,UACA,gBACA,WACA,mBACyC;CACzC,MAAM,CAAC,EAAE,OAAO,GAAG,GAAG,QAAQ,OAAO,WAAW,gBAAgB;EAC9D,OAAO,YAAY,KAAK;EACxB,OAAO,YAAY,KAAK;EACxB,QAAQ,YAAY,CAAC;EACrB,OAAO,YAAY,CAAC;EACpB,GAAG,YAAY,CAAC;EAChB,GAAG,YAAY,CAAC;CAClB,EAAE;CAEF,MAAM,aAAa,OAAO,OAAO;CACjC,MAAM,cAAc,OAAO,QAAQ;CACnC,MAAM,cAAc,OAAO,YAAA,CAA6B;CACxD,YAAY,UAAU,YAAA;CACtB,MAAM,kBAAkB,OAAO,gBAAgB,KAAK;CACpD,gBAAgB,UAAU,gBAAgB;CAE1C,MAAM,oBAAoB,OAAO,cAAc;CAC/C,kBAAkB,UAAU;CAE5B,MAAM,eAAe,OAAO,SAAS;CACrC,aAAa,UAAU;CAEvB,MAAM,gBAAgB,OAAO,CAAC;CAC9B,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,eAAe,OAA6C,IAAI;CAEtE,MAAM,qBAAqB,kBAAkB;EAC3C,IAAI,aAAa,YAAY,MAAM;GACjC,aAAa,aAAa,OAAO;GACjC,aAAa,UAAU;EACzB;EACA,cAAc,UAAU;EACxB,YAAY,UAAU;CACxB,GAAG,CAAC,CAAC;CAML,MAAM,UAAU,kBAAkB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AO;EAAG;CAAC,CACtB;CAEA,OAAO;EACL,WAAW,QAAQ;EACnB,YAAY,QAAQ;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,QAAQ;EACjB,UAAU,QAAQ;EAClB;EACA;EACA;EACA;EACA;EACA,UAAU,QAAQ;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useZoomPan.mjs","names":[],"sources":["../../../src/Image/viewer/useZoomPan.ts"],"sourcesContent":["import type { MotionValue } from 'motion/react';\nimport { animate, motionValue } from 'motion/react';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { Point, Rect, Rotation, Size, TransformState, ZoomPolicy } from './geometry';\nimport {\n anchoredZoom,\n clampPan,\n clampScale,\n computeFit,\n DEFAULT_AUTO_ZOOM_THRESHOLD,\n DEFAULT_MAX_SCALE,\n doubleClickTarget,\n MIN_SCALE,\n naturalScale,\n normalizeRotation,\n normalizeWheelDelta,\n panBounds,\n resolveInitialScale,\n rubberBand,\n wheelZoomFactor,\n} from './geometry';\n\nconst WHEEL_CLOSE_THRESHOLD = 100;\nconst WHEEL_IDLE_MS = 300;\nconst ZOOM_STEP = 1.5;\nconst RESET_TRANSITION = { damping: 30, stiffness: 300, type: 'spring' as const };\nconst CLEAN_EPSILON = 0.01;\n\nexport interface WheelLikeEvent {\n clientX: number;\n clientY: number;\n ctrlKey?: boolean;\n deltaMode?: number;\n deltaY: number;\n metaKey?: boolean;\n preventDefault?: () => void;\n}\n\nexport interface UseZoomPanOptions {\n autoZoomThreshold?: number;\n defaultZoom?: ZoomPolicy;\n fillViewport?: boolean;\n isClosing?: () => boolean;\n isTransitioning?: () => boolean;\n maxScale?: number;\n natural: Size;\n onCloseRequest?: () => void;\n viewport: Size;\n}\n\nexport interface UseZoomPanResult {\n canZoomIn: boolean;\n canZoomOut: boolean;\n dragBy: (delta: Point) => void;\n dragEnd: () => void;\n escIntent: () => 'reset' | 'close';\n flipHorizontal: () => void;\n flipVertical: () => void;\n flipX: MotionValue<boolean>;\n flipY: MotionValue<boolean>;\n getInitialScale: () => number;\n handleDoubleClick: (point: Point) => void;\n handleWheel: (event: WheelLikeEvent) => void;\n isClean: boolean;\n isZoomed: boolean;\n reset: () => void;\n resetCloseTracking: () => void;\n rotate: MotionValue<number>;\n rotateLeft: () => void;\n rotateRight: () => void;\n rotation: Rotation;\n scale: MotionValue<number>;\n setNatural: (natural: Size) => void;\n setViewport: (viewport: Size) => void;\n toggleActualSize: () => void;\n x: MotionValue<number>;\n y: MotionValue<number>;\n zoomIn: () => void;\n zoomOut: () => void;\n}\n\ninterface DerivedState {\n canZoomIn: boolean;\n canZoomOut: boolean;\n isClean: boolean;\n isZoomed: boolean;\n rotation: Rotation;\n}\n\nexport const useZoomPan = ({\n natural,\n viewport,\n maxScale,\n onCloseRequest,\n isClosing,\n isTransitioning,\n fillViewport,\n defaultZoom,\n autoZoomThreshold,\n}: UseZoomPanOptions): UseZoomPanResult => {\n const naturalRef = useRef(natural);\n const viewportRef = useRef(viewport);\n const maxScaleRef = useRef(maxScale ?? DEFAULT_MAX_SCALE);\n maxScaleRef.current = maxScale ?? DEFAULT_MAX_SCALE;\n const fillViewportRef = useRef(fillViewport ?? false);\n fillViewportRef.current = fillViewport ?? false;\n const policyRef = useRef(defaultZoom ?? 'auto');\n policyRef.current = defaultZoom ?? 'auto';\n const thresholdRef = useRef(autoZoomThreshold ?? DEFAULT_AUTO_ZOOM_THRESHOLD);\n thresholdRef.current = autoZoomThreshold ?? DEFAULT_AUTO_ZOOM_THRESHOLD;\n\n const computeInitialScale = useCallback((rotation: Rotation = 0) => {\n const fitRect = computeFit(\n naturalRef.current,\n viewportRef.current,\n rotation,\n fillViewportRef.current,\n );\n return resolveInitialScale(\n policyRef.current,\n naturalRef.current,\n fitRect,\n rotation,\n thresholdRef.current,\n );\n }, []);\n\n const [initialScaleSeed] = useState(computeInitialScale);\n const initialScaleRef = useRef(initialScaleSeed);\n const getInitialScale = useCallback(() => initialScaleRef.current, []);\n\n const [{ scale, x, y, rotate, flipX, flipY }] = useState(() => ({\n flipX: motionValue(false),\n flipY: motionValue(false),\n rotate: motionValue(0),\n scale: motionValue(initialScaleRef.current),\n x: motionValue(0),\n y: motionValue(0),\n }));\n\n // The ceiling has to clear the opening scale, otherwise a very large image\n // (naturalScale > maxScale) is clamped below the 100% it was asked to open at.\n const effectiveMaxScale = useCallback(\n () => Math.max(maxScaleRef.current, initialScaleRef.current),\n [],\n );\n\n const onCloseRequestRef = useRef(onCloseRequest);\n onCloseRequestRef.current = onCloseRequest;\n\n const isClosingRef = useRef(isClosing);\n isClosingRef.current = isClosing;\n\n const isTransitioningRef = useRef(isTransitioning);\n isTransitioningRef.current = isTransitioning;\n\n const closeAccumRef = useRef(0);\n const disarmedRef = useRef(false);\n const idleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const resetCloseTracking = useCallback(() => {\n if (idleTimerRef.current !== null) {\n clearTimeout(idleTimerRef.current);\n idleTimerRef.current = null;\n }\n closeAccumRef.current = 0;\n disarmedRef.current = false;\n }, []);\n\n // The close FLIP spring animates these same scale/x/y values. Any of\n // these entry points still firing during the ~300ms close window would\n // either fight that spring visually or, for wheel/reset specifically,\n // race escIntent()/isCleanState() into cancelling the close outright.\n const closing = useCallback(() => isClosingRef.current?.() ?? false, []);\n\n // Three questions that used to share one answer, and stop sharing it the\n // moment the viewer can open at something other than fit:\n // isAtFitFloor — no zoom-out left, so a further scroll down has\n // nowhere to go and becomes the dismiss gesture.\n // isOrientationClean — no rotation/flip to lose, so dismissing is safe.\n // Guards the wheel the same way layered Esc does:\n // state the user built is never thrown away by a\n // gesture that merely ran out of room.\n // isCleanState — both of the above *and* untouched zoom, i.e. \"the\n // user hasn't changed anything at all\", which is what\n // lets Esc/click close outright and lets the close\n // animation FLIP back to the thumbnail instead of fade.\n // All three coincide only while initialScale === MIN_SCALE.\n const isAtFitFloor = useCallback(() => scale.get() <= MIN_SCALE + CLEAN_EPSILON, [scale]);\n\n const isOrientationClean = useCallback(\n () => Math.abs(rotate.get()) < CLEAN_EPSILON && !flipX.get() && !flipY.get(),\n [flipX, flipY, rotate],\n );\n\n const isCleanState = useCallback(\n () => Math.abs(scale.get() - initialScaleRef.current) < CLEAN_EPSILON && isOrientationClean(),\n [isOrientationClean, scale],\n );\n\n const computeDerived = useCallback((): DerivedState => {\n const currentScale = scale.get();\n return {\n canZoomIn: currentScale < effectiveMaxScale(),\n canZoomOut: currentScale > MIN_SCALE,\n isClean: isCleanState(),\n isZoomed: currentScale > MIN_SCALE,\n rotation: normalizeRotation(rotate.get()),\n };\n }, [effectiveMaxScale, isCleanState, rotate, scale]);\n\n const [derived, setDerived] = useState<DerivedState>(computeDerived);\n\n const syncDerived = useCallback(() => {\n setDerived((prev) => {\n const next = computeDerived();\n if (\n prev.canZoomIn === next.canZoomIn &&\n prev.canZoomOut === next.canZoomOut &&\n prev.isClean === next.isClean &&\n prev.isZoomed === next.isZoomed &&\n prev.rotation === next.rotation\n ) {\n return prev;\n }\n return next;\n });\n }, [computeDerived]);\n\n useEffect(() => {\n const unsubscribers = [scale, rotate, flipX, flipY].map((value) =>\n value.on('change', syncDerived),\n );\n syncDerived();\n return () => {\n for (const unsubscribe of unsubscribers) unsubscribe();\n };\n }, [flipX, flipY, rotate, scale, syncDerived]);\n\n const getFitRect = useCallback(\n () =>\n computeFit(\n naturalRef.current,\n viewportRef.current,\n normalizeRotation(rotate.get()),\n fillViewportRef.current,\n ),\n [rotate],\n );\n\n const applyTransform = useCallback(\n (next: TransformState, fitRect: Rect) => {\n const clamped = clampPan(next, fitRect, viewportRef.current);\n // .jump(), not .set(): a surviving spring on these same values (e.g. a\n // dragEnd clamp-back or wheel snap-back still in flight) would otherwise\n // keep animating toward its own target and silently overwrite this\n // instant write on its next tick — motion's set() never stops an\n // active animation, only jump() does.\n scale.jump(next.scale);\n x.jump(clamped.x);\n y.jump(clamped.y);\n },\n [scale, x, y],\n );\n\n // Wheel/pinch stays on the instant applyTransform for 1:1 gesture tracking;\n // stepped inputs (toolbar/keyboard zoom, double-click) animate instead.\n const animateTransform = useCallback(\n (next: TransformState, fitRect: Rect) => {\n const clamped = clampPan(next, fitRect, viewportRef.current);\n animate(scale, next.scale, RESET_TRANSITION);\n animate(x, clamped.x, RESET_TRANSITION);\n animate(y, clamped.y, RESET_TRANSITION);\n },\n [scale, x, y],\n );\n\n const zoomBy = useCallback(\n (factor: number) => {\n if (closing()) return;\n const currentScale = scale.get();\n const targetScale = clampScale(currentScale * factor, effectiveMaxScale());\n const fitRect = getFitRect();\n const anchor: Point = { x: viewportRef.current.width / 2, y: viewportRef.current.height / 2 };\n const next = anchoredZoom(\n { scale: currentScale, x: x.get(), y: y.get() },\n targetScale,\n anchor,\n fitRect,\n );\n animateTransform(next, fitRect);\n },\n [animateTransform, closing, effectiveMaxScale, getFitRect, scale, x, y],\n );\n\n const zoomIn = useCallback(() => zoomBy(ZOOM_STEP), [zoomBy]);\n const zoomOut = useCallback(() => zoomBy(1 / ZOOM_STEP), [zoomBy]);\n\n const handleDoubleClick = useCallback(\n (point: Point) => {\n if (closing()) return;\n const currentScale = scale.get();\n const fitRect = getFitRect();\n const target = doubleClickTarget(\n currentScale,\n naturalRef.current,\n fitRect,\n normalizeRotation(rotate.get()),\n );\n const targetScale = clampScale(target, effectiveMaxScale());\n const next = anchoredZoom(\n { scale: currentScale, x: x.get(), y: y.get() },\n targetScale,\n point,\n fitRect,\n );\n animateTransform(next, fitRect);\n },\n [animateTransform, closing, effectiveMaxScale, getFitRect, rotate, scale, x, y],\n );\n\n const toggleActualSize = useCallback(() => {\n if (closing()) return;\n const currentScale = scale.get();\n const fitRect = getFitRect();\n const actual = naturalScale(naturalRef.current, fitRect, normalizeRotation(rotate.get()));\n const atActual = Math.abs(currentScale - actual) < CLEAN_EPSILON;\n const targetScale = clampScale(atActual ? MIN_SCALE : actual, effectiveMaxScale());\n const anchor: Point = { x: viewportRef.current.width / 2, y: viewportRef.current.height / 2 };\n const next = anchoredZoom(\n { scale: currentScale, x: x.get(), y: y.get() },\n targetScale,\n anchor,\n fitRect,\n );\n animateTransform(next, fitRect);\n }, [animateTransform, closing, effectiveMaxScale, getFitRect, rotate, scale, x, y]);\n\n const handleWheel = useCallback(\n (event: WheelLikeEvent) => {\n event.preventDefault?.();\n if (closing()) return;\n\n if (idleTimerRef.current !== null) clearTimeout(idleTimerRef.current);\n idleTimerRef.current = setTimeout(() => {\n idleTimerRef.current = null;\n closeAccumRef.current = 0;\n disarmedRef.current = false;\n }, WHEEL_IDLE_MS);\n\n const delta = normalizeWheelDelta(event.deltaY, event.deltaMode, viewportRef.current.height);\n\n const currentScale = scale.get();\n const isPinch = !!(event.ctrlKey || event.metaKey);\n // Zooming in is never gated on the current scale: gating it was what made\n // a plain wheel inert at the zoom floor, which reads as enormous damping.\n // Only scrolling *down* while already at the floor has nowhere left to go,\n // and that is precisely where the dismiss gesture takes over.\n const zoomingIn = delta < 0;\n\n if (isPinch || zoomingIn || !isAtFitFloor()) {\n disarmedRef.current = true;\n closeAccumRef.current = 0;\n\n const rawTarget = currentScale * wheelZoomFactor(delta);\n\n if (rawTarget <= MIN_SCALE) {\n animate(scale, MIN_SCALE, RESET_TRANSITION);\n animate(x, 0, RESET_TRANSITION);\n animate(y, 0, RESET_TRANSITION);\n return;\n }\n\n const targetScale = clampScale(rawTarget, effectiveMaxScale());\n const fitRect = getFitRect();\n const anchor: Point = { x: event.clientX, y: event.clientY };\n const next = anchoredZoom(\n { scale: currentScale, x: x.get(), y: y.get() },\n targetScale,\n anchor,\n fitRect,\n );\n applyTransform(next, fitRect);\n return;\n }\n\n // Deliberately not isCleanState(): an image that opened at 100% and was\n // scrolled back down to fit has \"changed\" by that measure, yet it is\n // exactly where the dismiss gesture belongs. Only orientation is worth\n // protecting here.\n if (disarmedRef.current || !isOrientationClean()) return;\n\n closeAccumRef.current += Math.abs(delta);\n if (closeAccumRef.current >= WHEEL_CLOSE_THRESHOLD) {\n closeAccumRef.current = 0;\n onCloseRequestRef.current?.();\n }\n },\n [\n applyTransform,\n closing,\n effectiveMaxScale,\n getFitRect,\n isAtFitFloor,\n isOrientationClean,\n scale,\n x,\n y,\n ],\n );\n\n const rotateBy = useCallback(\n (delta: 90 | -90) => {\n if (closing()) return;\n rotate.jump(normalizeRotation(rotate.get() + delta));\n scale.jump(1);\n x.jump(0);\n y.jump(0);\n },\n [closing, rotate, scale, x, y],\n );\n\n const rotateLeft = useCallback(() => rotateBy(-90), [rotateBy]);\n const rotateRight = useCallback(() => rotateBy(90), [rotateBy]);\n\n const flipHorizontal = useCallback(() => {\n if (closing()) return;\n flipX.set(!flipX.get());\n }, [closing, flipX]);\n\n const flipVertical = useCallback(() => {\n if (closing()) return;\n flipY.set(!flipY.get());\n }, [closing, flipY]);\n\n const reset = useCallback(() => {\n if (closing()) return;\n // Back to how the viewer opened, which is not necessarily fit.\n animate(scale, initialScaleRef.current, RESET_TRANSITION);\n animate(x, 0, RESET_TRANSITION);\n animate(y, 0, RESET_TRANSITION);\n animate(rotate, 0, RESET_TRANSITION);\n flipX.set(false);\n flipY.set(false);\n }, [closing, flipX, flipY, rotate, scale, x, y]);\n\n const dragBy = useCallback(\n (delta: Point) => {\n // A pointer can still be down when close starts (e.g. pinch to just\n // over 1x — inside isClean's epsilon, so Esc/wheel reads 'close' —\n // while the same gesture is still panning). Gated for consistency\n // with the other entry points even though .set() here can't cancel\n // the close spring outright, only cause a self-correcting flicker.\n if (closing()) return;\n const fitRect = getFitRect();\n const bounds = panBounds({ scale: scale.get(), x: 0, y: 0 }, fitRect, viewportRef.current);\n x.set(rubberBand(x.get() + delta.x, bounds.x.min, bounds.x.max));\n y.set(rubberBand(y.get() + delta.y, bounds.y.min, bounds.y.max));\n },\n [closing, getFitRect, scale, x, y],\n );\n\n const dragEnd = useCallback(() => {\n if (closing()) return;\n const fitRect = getFitRect();\n const clamped = clampPan(\n { scale: scale.get(), x: x.get(), y: y.get() },\n fitRect,\n viewportRef.current,\n );\n animate(x, clamped.x, RESET_TRANSITION);\n animate(y, clamped.y, RESET_TRANSITION);\n }, [closing, getFitRect, scale, x, y]);\n\n const escIntent = useCallback(\n (): 'reset' | 'close' => (isCleanState() ? 'close' : 'reset'),\n [isCleanState],\n );\n\n const setViewport = useCallback(\n (next: Size) => {\n viewportRef.current = next;\n const fitRect = computeFit(\n naturalRef.current,\n next,\n normalizeRotation(rotate.get()),\n fillViewportRef.current,\n );\n const clamped = clampPan({ scale: scale.get(), x: x.get(), y: y.get() }, fitRect, next);\n x.set(clamped.x);\n y.set(clamped.y);\n },\n [rotate, scale, x, y],\n );\n\n const setNatural = useCallback(\n (next: Size) => {\n const wasClean = isCleanState();\n naturalRef.current = next;\n const rotation = normalizeRotation(rotate.get());\n initialScaleRef.current = computeInitialScale(rotation);\n\n // A dual-source entry opens on the thumbnail's intrinsic size and only\n // learns the hi-res one here, which can move the opening scale (a 400px\n // stand-in is fit-sized; the 2000px original it becomes is not). Re-land\n // only if the user hasn't taken over — and never mid-transition, where\n // .jump() would kill the open FLIP's spring instead of joining it.\n if (wasClean && !closing() && !isTransitioningRef.current?.()) {\n scale.jump(initialScaleRef.current);\n }\n\n const fitRect = computeFit(next, viewportRef.current, rotation, fillViewportRef.current);\n const clamped = clampPan(\n { scale: scale.get(), x: x.get(), y: y.get() },\n fitRect,\n viewportRef.current,\n );\n x.set(clamped.x);\n y.set(clamped.y);\n },\n [closing, computeInitialScale, isCleanState, rotate, scale, x, y],\n );\n\n return {\n canZoomIn: derived.canZoomIn,\n canZoomOut: derived.canZoomOut,\n dragBy,\n dragEnd,\n escIntent,\n flipHorizontal,\n flipVertical,\n flipX,\n flipY,\n getInitialScale,\n handleDoubleClick,\n handleWheel,\n isClean: derived.isClean,\n isZoomed: derived.isZoomed,\n reset,\n resetCloseTracking,\n rotate,\n rotateLeft,\n rotateRight,\n rotation: derived.rotation,\n scale,\n setNatural,\n setViewport,\n toggleActualSize,\n x,\n y,\n zoomIn,\n zoomOut,\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M,UAAU,WAAW,MAAM,YAAY,SAAS,UAAU,gBAAgB,OAAO;EACvF,MAAM,UAAU,SACd;GAAE,OAAO,MAAM,IAAI;GAAG,GAAG,EAAE,IAAI;GAAG,GAAG,EAAE,IAAI;EAAE,GAC7C,SACA,YAAY,OACd;EACA,EAAE,IAAI,QAAQ,CAAC;EACf,EAAE,IAAI,QAAQ,CAAC;CACjB,GACA;EAAC;EAAS;EAAqB;EAAc;EAAQ;EAAO;EAAG;CAAC,CAClE;CAEA,OAAO;EACL,WAAW,QAAQ;EACnB,YAAY,QAAQ;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,QAAQ;EACjB,UAAU,QAAQ;EAClB;EACA;EACA;EACA;EACA;EACA,UAAU,QAAQ;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { visit } from "../../node_modules/.
|
|
2
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { defaultUrlTransform } from "react-markdown";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
//#region src/Markdown/plugins/rehypeCustomFootnotes.ts
|
|
3
3
|
const rehypeCustomFootnotes = () => (tree, file) => {
|
|
4
4
|
const linksData = file.data.footnoteLinks || {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node } from "../../node_modules/.
|
|
1
|
+
import { Node } from "../../node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.mjs";
|
|
2
2
|
//#region src/Markdown/plugins/rehypeKatexDir.d.ts
|
|
3
3
|
declare const rehypeKatexDir: () => (tree: Node) => void;
|
|
4
4
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
//#region src/Markdown/plugins/rehypeKatexDir.ts
|
|
3
3
|
const rehypeKatexDir = () => (tree) => {
|
|
4
4
|
visit(tree, "element", (node) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Root } from "../../node_modules/.
|
|
1
|
+
import { Root } from "../../node_modules/.pnpm/@types_hast@3.0.5/node_modules/@types/hast/index.mjs";
|
|
2
2
|
//#region src/Markdown/plugins/rehypeStreamAnimated.d.ts
|
|
3
3
|
interface StreamAnimatedRuntime {
|
|
4
4
|
births: number[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
import { getNow } from "../../utils/getNow.mjs";
|
|
3
3
|
//#region src/Markdown/plugins/rehypeStreamAnimated.ts
|
|
4
4
|
const WORD_SEGMENT_RE = /\s+|\S+/g;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
//#region src/Markdown/plugins/remarkBr.ts
|
|
3
3
|
/**
|
|
4
4
|
* Remark plugin to handle <br> and <br/> tags in markdown text
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
//#region src/Markdown/plugins/remarkColor.ts
|
|
3
3
|
/**
|
|
4
4
|
* Remark plugin to handle color syntax in markdown code spans
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SKIP } from "../../node_modules/.
|
|
2
|
-
import { visit } from "../../node_modules/.
|
|
1
|
+
import { SKIP } from "../../node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.mjs";
|
|
2
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
3
3
|
//#region src/Markdown/plugins/remarkCustomFootnotes.ts
|
|
4
4
|
const remarkCustomFootnotes = () => (tree, file) => {
|
|
5
5
|
const footnoteLinks = /* @__PURE__ */ new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
//#region src/Markdown/plugins/remarkGfmPlus.ts
|
|
3
3
|
const DEFAULT_ALLOW_HTML_TAGS = [
|
|
4
4
|
"sub",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
//#region src/Markdown/plugins/remarkVideo.ts
|
|
3
3
|
/**
|
|
4
4
|
* Remark plugin to handle <video> tags in markdown text
|
|
@@ -34,17 +34,19 @@ const toastManagers = {
|
|
|
34
34
|
"top-left": Toast.createToastManager(),
|
|
35
35
|
"top-right": Toast.createToastManager()
|
|
36
36
|
};
|
|
37
|
-
const
|
|
38
|
-
"bottom": /* @__PURE__ */ new
|
|
39
|
-
"bottom-left": /* @__PURE__ */ new
|
|
40
|
-
"bottom-right": /* @__PURE__ */ new
|
|
41
|
-
"top": /* @__PURE__ */ new
|
|
42
|
-
"top-left": /* @__PURE__ */ new
|
|
43
|
-
"top-right": /* @__PURE__ */ new
|
|
37
|
+
const activeToasts = {
|
|
38
|
+
"bottom": /* @__PURE__ */ new Map(),
|
|
39
|
+
"bottom-left": /* @__PURE__ */ new Map(),
|
|
40
|
+
"bottom-right": /* @__PURE__ */ new Map(),
|
|
41
|
+
"top": /* @__PURE__ */ new Map(),
|
|
42
|
+
"top-left": /* @__PURE__ */ new Map(),
|
|
43
|
+
"top-right": /* @__PURE__ */ new Map()
|
|
44
44
|
};
|
|
45
45
|
const getManager = (position) => toastManagers[position];
|
|
46
46
|
let toastIdCounter = 0;
|
|
47
47
|
const generateToastId = () => `toast-${Date.now().toString(36)}-${(toastIdCounter++).toString(36)}`;
|
|
48
|
+
const findActivePosition = (id) => ALL_POSITIONS.find((pos) => activeToasts[pos].has(id));
|
|
49
|
+
const isFrontMost = (position, id) => Array.from(activeToasts[position].keys()).at(-1) === id;
|
|
48
50
|
const normalizeOptions = (optionsOrMessage, type) => {
|
|
49
51
|
if (typeof optionsOrMessage === "string") return {
|
|
50
52
|
description: optionsOrMessage,
|
|
@@ -69,17 +71,30 @@ const createToastInstance = (id, position) => ({
|
|
|
69
71
|
const addToast = (options) => {
|
|
70
72
|
const position = options.placement ?? globalState.position;
|
|
71
73
|
const manager = getManager(position);
|
|
72
|
-
const onRemove = options
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
const { id: dedupeId, onClose, onRemove } = options;
|
|
75
|
+
if (dedupeId) {
|
|
76
|
+
const prevPosition = findActivePosition(dedupeId);
|
|
77
|
+
if (prevPosition && !(prevPosition === position && isFrontMost(position, dedupeId))) {
|
|
78
|
+
activeToasts[prevPosition].get(dedupeId).superseded = true;
|
|
79
|
+
activeToasts[prevPosition].delete(dedupeId);
|
|
80
|
+
runWhenToastHostReady(() => getManager(prevPosition).close(dedupeId));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const id = dedupeId ?? generateToastId();
|
|
84
|
+
const active = { superseded: false };
|
|
85
|
+
activeToasts[position].set(id, active);
|
|
75
86
|
runWhenToastHostReady(() => {
|
|
76
87
|
manager.add({
|
|
77
88
|
id,
|
|
78
89
|
data: options,
|
|
79
90
|
description: options.description,
|
|
80
|
-
onClose:
|
|
91
|
+
onClose: () => {
|
|
92
|
+
if (active.superseded) return;
|
|
93
|
+
onClose?.();
|
|
94
|
+
},
|
|
81
95
|
onRemove: () => {
|
|
82
|
-
|
|
96
|
+
if (active.superseded) return;
|
|
97
|
+
activeToasts[position].delete(id);
|
|
83
98
|
onRemove?.();
|
|
84
99
|
},
|
|
85
100
|
timeout: options.duration ?? globalState.duration,
|
|
@@ -90,12 +105,12 @@ const addToast = (options) => {
|
|
|
90
105
|
};
|
|
91
106
|
const dismissToast = (id) => {
|
|
92
107
|
if (id) for (const [position, manager] of Object.entries(toastManagers)) {
|
|
93
|
-
|
|
108
|
+
activeToasts[position].delete(id);
|
|
94
109
|
runWhenToastHostReady(() => manager.close(id));
|
|
95
110
|
}
|
|
96
111
|
else for (const [position, manager] of Object.entries(toastManagers)) {
|
|
97
|
-
const ids = Array.from(
|
|
98
|
-
|
|
112
|
+
const ids = Array.from(activeToasts[position].keys());
|
|
113
|
+
activeToasts[position].clear();
|
|
99
114
|
runWhenToastHostReady(() => {
|
|
100
115
|
for (const toastId of ids) manager.close(toastId);
|
|
101
116
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imperative.mjs","names":["BaseToast"],"sources":["../../../src/base-ui/Toast/imperative.tsx"],"sourcesContent":["'use client';\n\nimport { Toast as BaseToast } from '@base-ui/react/toast';\nimport { cx } from 'antd-style';\nimport { memo, useEffect, useId, useState, useSyncExternalStore } from 'react';\n\nimport { useIsClient } from '@/hooks/useIsClient';\nimport { useAppElement } from '@/ThemeProvider';\n\nimport { acquireLayerZIndex } from '../zIndex';\nimport { ToastContext } from './context';\nimport { isActiveToastHost, registerToastHost, subscribeToastHost } from './hostGuard';\nimport {\n __resetPendingToastQueueForTests,\n markToastHostNotReady,\n markToastHostReady,\n runWhenToastHostReady,\n} from './pendingQueue';\nimport { viewportVariants } from './style';\nimport ToastItem from './Toast';\nimport {\n type ToastAPI,\n type ToastInstance,\n type ToastOptions,\n type ToastPosition,\n type ToastPromiseOptions,\n type ToastType,\n} from './type';\n\n// All possible positions\nconst ALL_POSITIONS: ToastPosition[] = [\n 'top',\n 'top-left',\n 'top-right',\n 'bottom',\n 'bottom-left',\n 'bottom-right',\n];\n\n// Global state management\ninterface ToastState {\n duration: number;\n limit: number;\n position: ToastPosition;\n swipeDirection: ('left' | 'right' | 'up' | 'down') | ('left' | 'right' | 'up' | 'down')[];\n}\n\nlet globalState: ToastState = {\n duration: 5000,\n limit: 5,\n position: 'bottom-right',\n swipeDirection: ['down', 'right'],\n};\n\n// Toast managers for each position\nconst toastManagers: Record<ToastPosition, ReturnType<typeof BaseToast.createToastManager>> = {\n 'bottom': BaseToast.createToastManager(),\n 'bottom-left': BaseToast.createToastManager(),\n 'bottom-right': BaseToast.createToastManager(),\n 'top': BaseToast.createToastManager(),\n 'top-left': BaseToast.createToastManager(),\n 'top-right': BaseToast.createToastManager(),\n};\n\nconst activeToastIds: Record<ToastPosition, Set<string>> = {\n 'bottom': new Set(),\n 'bottom-left': new Set(),\n 'bottom-right': new Set(),\n 'top': new Set(),\n 'top-left': new Set(),\n 'top-right': new Set(),\n};\n\nconst getManager = (position: ToastPosition) => toastManagers[position];\n\nlet toastIdCounter = 0;\nconst generateToastId = (): string =>\n `toast-${Date.now().toString(36)}-${(toastIdCounter++).toString(36)}`;\n\nconst normalizeOptions = (\n optionsOrMessage: Omit<ToastOptions, 'type'> | string,\n type: ToastType,\n): ToastOptions => {\n if (typeof optionsOrMessage === 'string') {\n return {\n description: optionsOrMessage,\n type,\n };\n }\n return {\n ...optionsOrMessage,\n type,\n };\n};\n\nconst createToastInstance = (id: string, position: ToastPosition): ToastInstance => ({\n close: () => runWhenToastHostReady(() => getManager(position).close(id)),\n id,\n update: (options) => {\n runWhenToastHostReady(() =>\n getManager(position).update(id, {\n data: options,\n description: options.description,\n title: options.title,\n }),\n );\n },\n});\n\n// createToastManager() is a stateless emitter (see @base-ui/react/toast/createToastManager):\n// add/close/update just broadcast to whatever is currently subscribed, and the\n// ToastProvider that owns the real toast state only subscribes from a passive\n// useEffect. Calls made while no host is ready (e.g. mid-handoff between the\n// previously-active ToastHost unmounting and its successor's Provider\n// subscribing) would otherwise be silently dropped, so every manager call is\n// routed through runWhenToastHostReady to queue until a host is listening.\nconst addToast = (options: ToastOptions): ToastInstance => {\n const position = options.placement ?? globalState.position;\n const manager = getManager(position);\n const onRemove = options.onRemove;\n const id = generateToastId();\n activeToastIds[position].add(id);\n runWhenToastHostReady(() => {\n manager.add({\n id,\n data: options,\n description: options.description,\n onClose: options.onClose,\n onRemove: () => {\n activeToastIds[position].delete(id);\n onRemove?.();\n },\n timeout: options.duration ?? globalState.duration,\n title: options.title,\n });\n });\n return createToastInstance(id, position);\n};\n\nconst dismissToast = (id?: string) => {\n if (id) {\n // Try to close from all managers since we don't know which position the toast is in\n for (const [position, manager] of Object.entries(toastManagers)) {\n activeToastIds[position as ToastPosition].delete(id);\n runWhenToastHostReady(() => manager.close(id));\n }\n } else {\n // Clear all toasts\n for (const [position, manager] of Object.entries(toastManagers)) {\n const ids = Array.from(activeToastIds[position as ToastPosition]);\n activeToastIds[position as ToastPosition].clear();\n runWhenToastHostReady(() => {\n for (const toastId of ids) {\n manager.close(toastId);\n }\n });\n }\n }\n};\n\nconst createSuccessToast = (\n optionsOrMessage: Omit<ToastOptions, 'type'> | string,\n): ToastInstance => {\n return addToast(normalizeOptions(optionsOrMessage, 'success'));\n};\n\nconst createErrorToast = (optionsOrMessage: Omit<ToastOptions, 'type'> | string): ToastInstance => {\n return addToast(normalizeOptions(optionsOrMessage, 'error'));\n};\n\nconst createInfoToast = (optionsOrMessage: Omit<ToastOptions, 'type'> | string): ToastInstance => {\n return addToast(normalizeOptions(optionsOrMessage, 'info'));\n};\n\nconst createWarningToast = (\n optionsOrMessage: Omit<ToastOptions, 'type'> | string,\n): ToastInstance => {\n return addToast(normalizeOptions(optionsOrMessage, 'warning'));\n};\n\nconst createLoadingToast = (\n optionsOrMessage: Omit<ToastOptions, 'type'> | string,\n): ToastInstance => {\n const options = normalizeOptions(optionsOrMessage, 'loading');\n // Loading toasts don't auto-dismiss by default\n return addToast({ duration: 0, ...options });\n};\n\nasync function promiseToast<T>(promise: Promise<T>, options: ToastPromiseOptions<T>): Promise<T> {\n const loadingOptions =\n typeof options.loading === 'string'\n ? { description: options.loading }\n : (options.loading as ToastOptions);\n\n const loadingToast = addToast({\n closable: false,\n duration: 0,\n type: 'loading',\n ...loadingOptions,\n });\n\n try {\n const result = await promise;\n\n loadingToast.close();\n\n const successOptions = (() => {\n if (typeof options.success === 'string') {\n return { description: options.success };\n }\n if (typeof options.success === 'function') {\n return { description: options.success(result) };\n }\n return options.success as ToastOptions;\n })();\n\n addToast({ type: 'success', ...successOptions });\n\n return result;\n } catch (error) {\n loadingToast.close();\n\n const errorOptions = (() => {\n if (typeof options.error === 'string') {\n return { description: options.error };\n }\n if (typeof options.error === 'function') {\n return { description: options.error(error as Error) };\n }\n return options.error as ToastOptions;\n })();\n\n addToast({ type: 'error', ...errorOptions });\n\n throw error;\n }\n}\n\n// Base toast function\nconst baseToast = (options: ToastOptions): ToastInstance => {\n return addToast({ type: 'default', ...options });\n};\n\n// Toast API\nexport const toast: ToastAPI = Object.assign(baseToast, {\n dismiss: dismissToast,\n error: createErrorToast,\n info: createInfoToast,\n loading: createLoadingToast,\n promise: promiseToast,\n success: createSuccessToast,\n warning: createWarningToast,\n});\n\n// Toast List Component\nconst ToastList = memo(() => {\n const { toasts } = BaseToast.useToastManager();\n return toasts.map((t) => <ToastItem key={t.id} toast={t} />);\n});\n\nToastList.displayName = 'ToastList';\n\nexport interface ToastHostProps {\n className?: string;\n /**\n * Default duration for toasts\n * @default 5000\n */\n duration?: number;\n /**\n * Maximum number of toasts\n * @default 5\n */\n limit?: number;\n /**\n * Toast position\n * @default 'bottom-right'\n */\n position?: ToastPosition;\n /**\n * Root element for portal\n */\n root?: HTMLElement | ShadowRoot | null;\n /**\n * Swipe direction to dismiss\n * @default ['down', 'right']\n */\n swipeDirection?: ('left' | 'right' | 'up' | 'down') | ('left' | 'right' | 'up' | 'down')[];\n}\n\nexport const ToastHost = memo(\n ({\n root,\n className,\n duration = 5000,\n limit = 5,\n position = 'bottom-right',\n swipeDirection = ['down', 'right'],\n }: ToastHostProps) => {\n const isClient = useIsClient();\n const appElement = useAppElement();\n const [viewportZIndex, setViewportZIndex] = useState<number | undefined>(undefined);\n const hostId = useId();\n\n useEffect(() => registerToastHost(hostId), [hostId]);\n\n const isActive = useSyncExternalStore(\n subscribeToastHost,\n () => isActiveToastHost(hostId),\n () => false,\n );\n\n useEffect(() => {\n if (!isActive) return;\n globalState = {\n duration,\n limit,\n position,\n swipeDirection,\n };\n }, [duration, limit, position, swipeDirection, isActive]);\n\n useEffect(() => {\n if (!isActive) return;\n setViewportZIndex(acquireLayerZIndex('toast'));\n }, [isActive]);\n\n useEffect(() => {\n if (!isActive || !isClient) return undefined;\n // Runs after the six BaseToast.Provider children below have committed\n // and subscribed (child effects run before the parent's), so the\n // managers are guaranteed to have a live listener once this fires.\n markToastHostReady();\n return () => {\n markToastHostNotReady();\n };\n }, [isActive, isClient]);\n\n if (!isClient || !isActive) return null;\n\n const container = root ?? appElement ?? document.body;\n\n return ALL_POSITIONS.map((pos) => (\n <ToastContext key={pos} value={{ position: pos, swipeDirection }}>\n <BaseToast.Provider limit={limit} timeout={duration} toastManager={getManager(pos)}>\n <BaseToast.Portal container={container}>\n <BaseToast.Viewport\n className={cx(viewportVariants({ position: pos }), className)}\n style={{ zIndex: viewportZIndex }}\n >\n <ToastList />\n </BaseToast.Viewport>\n </BaseToast.Portal>\n </BaseToast.Provider>\n </ToastContext>\n ));\n },\n);\n\nToastHost.displayName = 'ToastHost';\n\n// Hook to use toast manager\nexport const useToast = () => toast;\n\nexport const __resetToastStateForTests = (): void => {\n globalState = {\n duration: 5000,\n limit: 5,\n position: 'bottom-right',\n swipeDirection: ['down', 'right'],\n };\n for (const position of ALL_POSITIONS) {\n toastManagers[position] = BaseToast.createToastManager();\n activeToastIds[position].clear();\n }\n __resetPendingToastQueueForTests();\n};\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,gBAAiC;CACrC;CACA;CACA;CACA;CACA;CACA;AACF;AAUA,IAAI,cAA0B;CAC5B,UAAU;CACV,OAAO;CACP,UAAU;CACV,gBAAgB,CAAC,QAAQ,OAAO;AAClC;AAGA,MAAM,gBAAwF;CAC5F,UAAUA,MAAU,mBAAmB;CACvC,eAAeA,MAAU,mBAAmB;CAC5C,gBAAgBA,MAAU,mBAAmB;CAC7C,OAAOA,MAAU,mBAAmB;CACpC,YAAYA,MAAU,mBAAmB;CACzC,aAAaA,MAAU,mBAAmB;AAC5C;AAEA,MAAM,iBAAqD;CACzD,0BAAU,IAAI,IAAI;CAClB,+BAAe,IAAI,IAAI;CACvB,gCAAgB,IAAI,IAAI;CACxB,uBAAO,IAAI,IAAI;CACf,4BAAY,IAAI,IAAI;CACpB,6BAAa,IAAI,IAAI;AACvB;AAEA,MAAM,cAAc,aAA4B,cAAc;AAE9D,IAAI,iBAAiB;AACrB,MAAM,wBACJ,SAAS,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,IAAI,iBAAA,CAAkB,SAAS,EAAE;AAEpE,MAAM,oBACJ,kBACA,SACiB;CACjB,IAAI,OAAO,qBAAqB,UAC9B,OAAO;EACL,aAAa;EACb;CACF;CAEF,OAAO;EACL,GAAG;EACH;CACF;AACF;AAEA,MAAM,uBAAuB,IAAY,cAA4C;CACnF,aAAa,4BAA4B,WAAW,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;CACvE;CACA,SAAS,YAAY;EACnB,4BACE,WAAW,QAAQ,CAAC,CAAC,OAAO,IAAI;GAC9B,MAAM;GACN,aAAa,QAAQ;GACrB,OAA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AC5D,OAAO,EAAE,QAAQ,eAAe;KAEhC,UAAA,oBAAC,WAAD,CAAY,CAAA;IACM,CAAA;GACJ,CAAA;EACA,CAAA;CACR,GAXK,GAWL,CACf;AACH,CACF;AAEA,UAAU,cAAc;AAGxB,MAAa,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"imperative.mjs","names":["BaseToast"],"sources":["../../../src/base-ui/Toast/imperative.tsx"],"sourcesContent":["'use client';\n\nimport { Toast as BaseToast } from '@base-ui/react/toast';\nimport { cx } from 'antd-style';\nimport { memo, useEffect, useId, useState, useSyncExternalStore } from 'react';\n\nimport { useIsClient } from '@/hooks/useIsClient';\nimport { useAppElement } from '@/ThemeProvider';\n\nimport { acquireLayerZIndex } from '../zIndex';\nimport { ToastContext } from './context';\nimport { isActiveToastHost, registerToastHost, subscribeToastHost } from './hostGuard';\nimport {\n __resetPendingToastQueueForTests,\n markToastHostNotReady,\n markToastHostReady,\n runWhenToastHostReady,\n} from './pendingQueue';\nimport { viewportVariants } from './style';\nimport ToastItem from './Toast';\nimport {\n type ToastAPI,\n type ToastInstance,\n type ToastOptions,\n type ToastPosition,\n type ToastPromiseOptions,\n type ToastType,\n} from './type';\n\n// All possible positions\nconst ALL_POSITIONS: ToastPosition[] = [\n 'top',\n 'top-left',\n 'top-right',\n 'bottom',\n 'bottom-left',\n 'bottom-right',\n];\n\n// Global state management\ninterface ToastState {\n duration: number;\n limit: number;\n position: ToastPosition;\n swipeDirection: ('left' | 'right' | 'up' | 'down') | ('left' | 'right' | 'up' | 'down')[];\n}\n\nlet globalState: ToastState = {\n duration: 5000,\n limit: 5,\n position: 'bottom-right',\n swipeDirection: ['down', 'right'],\n};\n\n// Toast managers for each position\nconst toastManagers: Record<ToastPosition, ReturnType<typeof BaseToast.createToastManager>> = {\n 'bottom': BaseToast.createToastManager(),\n 'bottom-left': BaseToast.createToastManager(),\n 'bottom-right': BaseToast.createToastManager(),\n 'top': BaseToast.createToastManager(),\n 'top-left': BaseToast.createToastManager(),\n 'top-right': BaseToast.createToastManager(),\n};\n\ninterface ActiveToast {\n superseded: boolean;\n}\n\nconst activeToasts: Record<ToastPosition, Map<string, ActiveToast>> = {\n 'bottom': new Map(),\n 'bottom-left': new Map(),\n 'bottom-right': new Map(),\n 'top': new Map(),\n 'top-left': new Map(),\n 'top-right': new Map(),\n};\n\nconst getManager = (position: ToastPosition) => toastManagers[position];\n\nlet toastIdCounter = 0;\nconst generateToastId = (): string =>\n `toast-${Date.now().toString(36)}-${(toastIdCounter++).toString(36)}`;\n\nconst findActivePosition = (id: string) => ALL_POSITIONS.find((pos) => activeToasts[pos].has(id));\n\n// Base UI prepends every new toast, so the last entry we registered is the one\n// currently rendered at the front of the stack.\nconst isFrontMost = (position: ToastPosition, id: string) =>\n Array.from(activeToasts[position].keys()).at(-1) === id;\n\nconst normalizeOptions = (\n optionsOrMessage: Omit<ToastOptions, 'type'> | string,\n type: ToastType,\n): ToastOptions => {\n if (typeof optionsOrMessage === 'string') {\n return {\n description: optionsOrMessage,\n type,\n };\n }\n return {\n ...optionsOrMessage,\n type,\n };\n};\n\nconst createToastInstance = (id: string, position: ToastPosition): ToastInstance => ({\n close: () => runWhenToastHostReady(() => getManager(position).close(id)),\n id,\n update: (options) => {\n runWhenToastHostReady(() =>\n getManager(position).update(id, {\n data: options,\n description: options.description,\n title: options.title,\n }),\n );\n },\n});\n\n// createToastManager() is a stateless emitter (see @base-ui/react/toast/createToastManager):\n// add/close/update just broadcast to whatever is currently subscribed, and the\n// ToastProvider that owns the real toast state only subscribes from a passive\n// useEffect. Calls made while no host is ready (e.g. mid-handoff between the\n// previously-active ToastHost unmounting and its successor's Provider\n// subscribing) would otherwise be silently dropped, so every manager call is\n// routed through runWhenToastHostReady to queue until a host is listening.\nconst addToast = (options: ToastOptions): ToastInstance => {\n const position = options.placement ?? globalState.position;\n const manager = getManager(position);\n const { id: dedupeId, onClose, onRemove } = options;\n\n if (dedupeId) {\n const prevPosition = findActivePosition(dedupeId);\n // Already the front-most toast: let Base UI upsert it in place so it only\n // refreshes its content and timer, without replaying the slide-in animation.\n const shouldPromote =\n prevPosition && !(prevPosition === position && isFrontMost(position, dedupeId));\n\n if (shouldPromote) {\n // Closing marks the toast as `ending`, which makes the following `add`\n // drop it and prepend a fresh one — Base UI's own upsert keeps the\n // original slot instead.\n activeToasts[prevPosition].get(dedupeId)!.superseded = true;\n activeToasts[prevPosition].delete(dedupeId);\n runWhenToastHostReady(() => getManager(prevPosition).close(dedupeId));\n }\n }\n\n const id = dedupeId ?? generateToastId();\n const active: ActiveToast = { superseded: false };\n activeToasts[position].set(id, active);\n runWhenToastHostReady(() => {\n manager.add({\n id,\n data: options,\n description: options.description,\n onClose: () => {\n if (active.superseded) return;\n onClose?.();\n },\n onRemove: () => {\n if (active.superseded) return;\n activeToasts[position].delete(id);\n onRemove?.();\n },\n timeout: options.duration ?? globalState.duration,\n title: options.title,\n });\n });\n return createToastInstance(id, position);\n};\n\nconst dismissToast = (id?: string) => {\n if (id) {\n // Try to close from all managers since we don't know which position the toast is in\n for (const [position, manager] of Object.entries(toastManagers)) {\n activeToasts[position as ToastPosition].delete(id);\n runWhenToastHostReady(() => manager.close(id));\n }\n } else {\n // Clear all toasts\n for (const [position, manager] of Object.entries(toastManagers)) {\n const ids = Array.from(activeToasts[position as ToastPosition].keys());\n activeToasts[position as ToastPosition].clear();\n runWhenToastHostReady(() => {\n for (const toastId of ids) {\n manager.close(toastId);\n }\n });\n }\n }\n};\n\nconst createSuccessToast = (\n optionsOrMessage: Omit<ToastOptions, 'type'> | string,\n): ToastInstance => {\n return addToast(normalizeOptions(optionsOrMessage, 'success'));\n};\n\nconst createErrorToast = (optionsOrMessage: Omit<ToastOptions, 'type'> | string): ToastInstance => {\n return addToast(normalizeOptions(optionsOrMessage, 'error'));\n};\n\nconst createInfoToast = (optionsOrMessage: Omit<ToastOptions, 'type'> | string): ToastInstance => {\n return addToast(normalizeOptions(optionsOrMessage, 'info'));\n};\n\nconst createWarningToast = (\n optionsOrMessage: Omit<ToastOptions, 'type'> | string,\n): ToastInstance => {\n return addToast(normalizeOptions(optionsOrMessage, 'warning'));\n};\n\nconst createLoadingToast = (\n optionsOrMessage: Omit<ToastOptions, 'type'> | string,\n): ToastInstance => {\n const options = normalizeOptions(optionsOrMessage, 'loading');\n // Loading toasts don't auto-dismiss by default\n return addToast({ duration: 0, ...options });\n};\n\nasync function promiseToast<T>(promise: Promise<T>, options: ToastPromiseOptions<T>): Promise<T> {\n const loadingOptions =\n typeof options.loading === 'string'\n ? { description: options.loading }\n : (options.loading as ToastOptions);\n\n const loadingToast = addToast({\n closable: false,\n duration: 0,\n type: 'loading',\n ...loadingOptions,\n });\n\n try {\n const result = await promise;\n\n loadingToast.close();\n\n const successOptions = (() => {\n if (typeof options.success === 'string') {\n return { description: options.success };\n }\n if (typeof options.success === 'function') {\n return { description: options.success(result) };\n }\n return options.success as ToastOptions;\n })();\n\n addToast({ type: 'success', ...successOptions });\n\n return result;\n } catch (error) {\n loadingToast.close();\n\n const errorOptions = (() => {\n if (typeof options.error === 'string') {\n return { description: options.error };\n }\n if (typeof options.error === 'function') {\n return { description: options.error(error as Error) };\n }\n return options.error as ToastOptions;\n })();\n\n addToast({ type: 'error', ...errorOptions });\n\n throw error;\n }\n}\n\n// Base toast function\nconst baseToast = (options: ToastOptions): ToastInstance => {\n return addToast({ type: 'default', ...options });\n};\n\n// Toast API\nexport const toast: ToastAPI = Object.assign(baseToast, {\n dismiss: dismissToast,\n error: createErrorToast,\n info: createInfoToast,\n loading: createLoadingToast,\n promise: promiseToast,\n success: createSuccessToast,\n warning: createWarningToast,\n});\n\n// Toast List Component\nconst ToastList = memo(() => {\n const { toasts } = BaseToast.useToastManager();\n return toasts.map((t) => <ToastItem key={t.id} toast={t} />);\n});\n\nToastList.displayName = 'ToastList';\n\nexport interface ToastHostProps {\n className?: string;\n /**\n * Default duration for toasts\n * @default 5000\n */\n duration?: number;\n /**\n * Maximum number of toasts\n * @default 5\n */\n limit?: number;\n /**\n * Toast position\n * @default 'bottom-right'\n */\n position?: ToastPosition;\n /**\n * Root element for portal\n */\n root?: HTMLElement | ShadowRoot | null;\n /**\n * Swipe direction to dismiss\n * @default ['down', 'right']\n */\n swipeDirection?: ('left' | 'right' | 'up' | 'down') | ('left' | 'right' | 'up' | 'down')[];\n}\n\nexport const ToastHost = memo(\n ({\n root,\n className,\n duration = 5000,\n limit = 5,\n position = 'bottom-right',\n swipeDirection = ['down', 'right'],\n }: ToastHostProps) => {\n const isClient = useIsClient();\n const appElement = useAppElement();\n const [viewportZIndex, setViewportZIndex] = useState<number | undefined>(undefined);\n const hostId = useId();\n\n useEffect(() => registerToastHost(hostId), [hostId]);\n\n const isActive = useSyncExternalStore(\n subscribeToastHost,\n () => isActiveToastHost(hostId),\n () => false,\n );\n\n useEffect(() => {\n if (!isActive) return;\n globalState = {\n duration,\n limit,\n position,\n swipeDirection,\n };\n }, [duration, limit, position, swipeDirection, isActive]);\n\n useEffect(() => {\n if (!isActive) return;\n setViewportZIndex(acquireLayerZIndex('toast'));\n }, [isActive]);\n\n useEffect(() => {\n if (!isActive || !isClient) return undefined;\n // Runs after the six BaseToast.Provider children below have committed\n // and subscribed (child effects run before the parent's), so the\n // managers are guaranteed to have a live listener once this fires.\n markToastHostReady();\n return () => {\n markToastHostNotReady();\n };\n }, [isActive, isClient]);\n\n if (!isClient || !isActive) return null;\n\n const container = root ?? appElement ?? document.body;\n\n return ALL_POSITIONS.map((pos) => (\n <ToastContext key={pos} value={{ position: pos, swipeDirection }}>\n <BaseToast.Provider limit={limit} timeout={duration} toastManager={getManager(pos)}>\n <BaseToast.Portal container={container}>\n <BaseToast.Viewport\n className={cx(viewportVariants({ position: pos }), className)}\n style={{ zIndex: viewportZIndex }}\n >\n <ToastList />\n </BaseToast.Viewport>\n </BaseToast.Portal>\n </BaseToast.Provider>\n </ToastContext>\n ));\n },\n);\n\nToastHost.displayName = 'ToastHost';\n\n// Hook to use toast manager\nexport const useToast = () => toast;\n\nexport const __resetToastStateForTests = (): void => {\n globalState = {\n duration: 5000,\n limit: 5,\n position: 'bottom-right',\n swipeDirection: ['down', 'right'],\n };\n for (const position of ALL_POSITIONS) {\n toastManagers[position] = BaseToast.createToastManager();\n activeToasts[position].clear();\n }\n __resetPendingToastQueueForTests();\n};\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,gBAAiC;CACrC;CACA;CACA;CACA;CACA;CACA;AACF;AAUA,IAAI,cAA0B;CAC5B,UAAU;CACV,OAAO;CACP,UAAU;CACV,gBAAgB,CAAC,QAAQ,OAAO;AAClC;AAGA,MAAM,gBAAwF;CAC5F,UAAUA,MAAU,mBAAmB;CACvC,eAAeA,MAAU,mBAAmB;CAC5C,gBAAgBA,MAAU,mBAAmB;CAC7C,OAAOA,MAAU,mBAAmB;CACpC,YAAYA,MAAU,mBAAmB;CACzC,aAAaA,MAAU,mBAAmB;AAC5C;AAMA,MAAM,eAAgE;CACpE,0BAAU,IAAI,IAAI;CAClB,+BAAe,IAAI,IAAI;CACvB,gCAAgB,IAAI,IAAI;CACxB,uBAAO,IAAI,IAAI;CACf,4BAAY,IAAI,IAAI;CACpB,6BAAa,IAAI,IAAI;AACvB;AAEA,MAAM,cAAc,aAA4B,cAAc;AAE9D,IAAI,iBAAiB;AACrB,MAAM,wBACJ,SAAS,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,IAAI,iBAAA,CAAkB,SAAS,EAAE;AAEpE,MAAM,sBAAsB,OAAe,cAAc,MAAM,QAAQ,aAAa,IAAI,CAAC,IAAI,EAAE,CAAC;AAIhG,MAAM,eAAe,UAAyB,OAC5C,MAAM,KAAK,aAAa,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM;AAEvD,MAAM,oBACJ,kBACA,SACiB;CACjB,IAAI,OAAO,qBAAqB,UAC9B,OAAO;EACL,aAAa;EACb;CACF;CAEF,OAAO;EACL,GAAG;EACH;CACF;AACF;AAEA,MAAM,uBAAuB,IAAY,cAA4C;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IAAI,CAAC,UAAU;EACf,kBAAkB,mBAAmB,OAAO,CAAC;CAC/C,GAAG,CAAC,QAAQ,CAAC;CAEb,gBAAgB;EACd,IAAI,CAAC,YAAY,CAAC,UAAU,OAAO,KAAA;EAInC,mBAAmB;EACnB,aAAa;GACX,sBAAsB;EACxB;CACF,GAAG,CAAC,UAAU,QAAQ,CAAC;CAEvB,IAAI,CAAC,YAAY,CAAC,UAAU,OAAO;CAEnC,MAAM,YAAY,QAAQ,cAAc,SAAS;CAEjD,OAAO,cAAc,KAAK,QACxB,oBAAC,cAAD;EAAwB,OAAO;GAAE,UAAU;GAAK;EAAe;EAC7D,UAAA,oBAACA,MAAU,UAAX;GAA2B;GAAO,SAAS;GAAU,cAAc,WAAW,GAAG;GAC/E,UAAA,oBAACA,MAAU,QAAX;IAA6B;IAC3B,UAAA,oBAACA,MAAU,UAAX;KACE,WAAW,GAAG,iBAAiB,EAAE,UAAU,IAAI,CAAC,GAAG,SAAS;KAC5D,OAAO,EAAE,QAAQ,eAAe;KAEhC,UAAA,oBAAC,WAAD,CAAY,CAAA;IACM,CAAA;GACJ,CAAA;EACA,CAAA;CACR,GAXK,GAWL,CACf;AACH,CACF;AAEA,UAAU,cAAc;AAGxB,MAAa,iBAAiB"}
|
|
@@ -66,6 +66,13 @@ interface ToastOptions {
|
|
|
66
66
|
* Custom icon
|
|
67
67
|
*/
|
|
68
68
|
icon?: IconProps['icon'];
|
|
69
|
+
/**
|
|
70
|
+
* Stable identifier used to deduplicate toasts. Showing a toast with an id
|
|
71
|
+
* that is already visible refreshes it in place and resets its timer instead
|
|
72
|
+
* of stacking a second copy; if it is no longer the newest toast it is also
|
|
73
|
+
* moved back to the front of the stack.
|
|
74
|
+
*/
|
|
75
|
+
id?: string;
|
|
69
76
|
/**
|
|
70
77
|
* Callback when toast is closed
|
|
71
78
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/i18n/resources/en/image.d.ts
|
|
2
2
|
declare const _default: {
|
|
3
|
+
readonly 'image.actualSize': "Actual Size";
|
|
3
4
|
readonly 'image.close': "Close";
|
|
4
5
|
readonly 'image.copy': "Copy";
|
|
5
6
|
readonly 'image.copyFailed': "Copy Failed";
|
|
@@ -7,6 +8,7 @@ declare const _default: {
|
|
|
7
8
|
readonly 'image.download': "Download";
|
|
8
9
|
readonly 'image.downloadFailed': "Download Failed";
|
|
9
10
|
readonly 'image.downloadSuccess': "Download Success";
|
|
11
|
+
readonly 'image.fitToScreen': "Fit to Screen";
|
|
10
12
|
readonly 'image.flipHorizontal': "Flip Horizontal";
|
|
11
13
|
readonly 'image.flipVertical': "Flip Vertical";
|
|
12
14
|
readonly 'image.more': "More";
|
|
@@ -16,7 +18,6 @@ declare const _default: {
|
|
|
16
18
|
readonly 'image.rotateRight': "Rotate Right";
|
|
17
19
|
readonly 'image.zoomIn': "Zoom In";
|
|
18
20
|
readonly 'image.zoomOut': "Zoom Out";
|
|
19
|
-
readonly 'image.zoomReset': "Reset Zoom";
|
|
20
21
|
};
|
|
21
22
|
//#endregion
|
|
22
23
|
export { _default as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/i18n/resources/en/image.ts
|
|
2
2
|
var image_default = {
|
|
3
|
+
"image.actualSize": "Actual Size",
|
|
3
4
|
"image.close": "Close",
|
|
4
5
|
"image.copy": "Copy",
|
|
5
6
|
"image.copyFailed": "Copy Failed",
|
|
@@ -7,6 +8,7 @@ var image_default = {
|
|
|
7
8
|
"image.download": "Download",
|
|
8
9
|
"image.downloadFailed": "Download Failed",
|
|
9
10
|
"image.downloadSuccess": "Download Success",
|
|
11
|
+
"image.fitToScreen": "Fit to Screen",
|
|
10
12
|
"image.flipHorizontal": "Flip Horizontal",
|
|
11
13
|
"image.flipVertical": "Flip Vertical",
|
|
12
14
|
"image.more": "More",
|
|
@@ -15,8 +17,7 @@ var image_default = {
|
|
|
15
17
|
"image.rotateLeft": "Rotate Left",
|
|
16
18
|
"image.rotateRight": "Rotate Right",
|
|
17
19
|
"image.zoomIn": "Zoom In",
|
|
18
|
-
"image.zoomOut": "Zoom Out"
|
|
19
|
-
"image.zoomReset": "Reset Zoom"
|
|
20
|
+
"image.zoomOut": "Zoom Out"
|
|
20
21
|
};
|
|
21
22
|
//#endregion
|
|
22
23
|
export { image_default as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.mjs","names":[],"sources":["../../../../src/i18n/resources/en/image.ts"],"sourcesContent":["export default {\n 'image.close': 'Close',\n 'image.copy': 'Copy',\n 'image.copyFailed': 'Copy Failed',\n 'image.copySuccess': 'Copy Success',\n 'image.download': 'Download',\n 'image.downloadFailed': 'Download Failed',\n 'image.downloadSuccess': 'Download Success',\n 'image.flipHorizontal': 'Flip Horizontal',\n 'image.flipVertical': 'Flip Vertical',\n 'image.more': 'More',\n 'image.next': 'Next',\n 'image.prev': 'Previous',\n 'image.rotateLeft': 'Rotate Left',\n 'image.rotateRight': 'Rotate Right',\n 'image.zoomIn': 'Zoom In',\n 'image.zoomOut': 'Zoom Out',\n
|
|
1
|
+
{"version":3,"file":"image.mjs","names":[],"sources":["../../../../src/i18n/resources/en/image.ts"],"sourcesContent":["export default {\n 'image.actualSize': 'Actual Size',\n 'image.close': 'Close',\n 'image.copy': 'Copy',\n 'image.copyFailed': 'Copy Failed',\n 'image.copySuccess': 'Copy Success',\n 'image.download': 'Download',\n 'image.downloadFailed': 'Download Failed',\n 'image.downloadSuccess': 'Download Success',\n 'image.fitToScreen': 'Fit to Screen',\n 'image.flipHorizontal': 'Flip Horizontal',\n 'image.flipVertical': 'Flip Vertical',\n 'image.more': 'More',\n 'image.next': 'Next',\n 'image.prev': 'Previous',\n 'image.rotateLeft': 'Rotate Left',\n 'image.rotateRight': 'Rotate Right',\n 'image.zoomIn': 'Zoom In',\n 'image.zoomOut': 'Zoom Out',\n} as const;\n"],"mappings":";AAAA,IAAA,gBAAe;CACb,oBAAoB;CACpB,eAAe;CACf,cAAc;CACd,oBAAoB;CACpB,qBAAqB;CACrB,kBAAkB;CAClB,wBAAwB;CACxB,yBAAyB;CACzB,qBAAqB;CACrB,wBAAwB;CACxB,sBAAsB;CACtB,cAAc;CACd,cAAc;CACd,cAAc;CACd,oBAAoB;CACpB,qBAAqB;CACrB,gBAAgB;CAChB,iBAAiB;AACnB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/i18n/resources/zhCn/image.d.ts
|
|
2
2
|
declare const _default: {
|
|
3
|
+
readonly 'image.actualSize': "实际尺寸";
|
|
3
4
|
readonly 'image.close': "关闭";
|
|
4
5
|
readonly 'image.copy': "复制";
|
|
5
6
|
readonly 'image.copyFailed': "复制失败";
|
|
@@ -7,6 +8,7 @@ declare const _default: {
|
|
|
7
8
|
readonly 'image.download': "下载";
|
|
8
9
|
readonly 'image.downloadFailed': "下载失败";
|
|
9
10
|
readonly 'image.downloadSuccess': "下载成功";
|
|
11
|
+
readonly 'image.fitToScreen': "适应屏幕";
|
|
10
12
|
readonly 'image.flipHorizontal': "水平翻转";
|
|
11
13
|
readonly 'image.flipVertical': "垂直翻转";
|
|
12
14
|
readonly 'image.more': "更多";
|
|
@@ -16,7 +18,6 @@ declare const _default: {
|
|
|
16
18
|
readonly 'image.rotateRight': "向右旋转";
|
|
17
19
|
readonly 'image.zoomIn': "放大";
|
|
18
20
|
readonly 'image.zoomOut': "缩小";
|
|
19
|
-
readonly 'image.zoomReset': "重置缩放";
|
|
20
21
|
};
|
|
21
22
|
//#endregion
|
|
22
23
|
export { _default as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/i18n/resources/zhCn/image.ts
|
|
2
2
|
var image_default = {
|
|
3
|
+
"image.actualSize": "实际尺寸",
|
|
3
4
|
"image.close": "关闭",
|
|
4
5
|
"image.copy": "复制",
|
|
5
6
|
"image.copyFailed": "复制失败",
|
|
@@ -7,6 +8,7 @@ var image_default = {
|
|
|
7
8
|
"image.download": "下载",
|
|
8
9
|
"image.downloadFailed": "下载失败",
|
|
9
10
|
"image.downloadSuccess": "下载成功",
|
|
11
|
+
"image.fitToScreen": "适应屏幕",
|
|
10
12
|
"image.flipHorizontal": "水平翻转",
|
|
11
13
|
"image.flipVertical": "垂直翻转",
|
|
12
14
|
"image.more": "更多",
|
|
@@ -15,8 +17,7 @@ var image_default = {
|
|
|
15
17
|
"image.rotateLeft": "向左旋转",
|
|
16
18
|
"image.rotateRight": "向右旋转",
|
|
17
19
|
"image.zoomIn": "放大",
|
|
18
|
-
"image.zoomOut": "缩小"
|
|
19
|
-
"image.zoomReset": "重置缩放"
|
|
20
|
+
"image.zoomOut": "缩小"
|
|
20
21
|
};
|
|
21
22
|
//#endregion
|
|
22
23
|
export { image_default as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.mjs","names":[],"sources":["../../../../src/i18n/resources/zhCn/image.ts"],"sourcesContent":["export default {\n 'image.close': '关闭',\n 'image.copy': '复制',\n 'image.copyFailed': '复制失败',\n 'image.copySuccess': '复制成功',\n 'image.download': '下载',\n 'image.downloadFailed': '下载失败',\n 'image.downloadSuccess': '下载成功',\n 'image.flipHorizontal': '水平翻转',\n 'image.flipVertical': '垂直翻转',\n 'image.more': '更多',\n 'image.next': '下一张',\n 'image.prev': '上一张',\n 'image.rotateLeft': '向左旋转',\n 'image.rotateRight': '向右旋转',\n 'image.zoomIn': '放大',\n 'image.zoomOut': '缩小',\n
|
|
1
|
+
{"version":3,"file":"image.mjs","names":[],"sources":["../../../../src/i18n/resources/zhCn/image.ts"],"sourcesContent":["export default {\n 'image.actualSize': '实际尺寸',\n 'image.close': '关闭',\n 'image.copy': '复制',\n 'image.copyFailed': '复制失败',\n 'image.copySuccess': '复制成功',\n 'image.download': '下载',\n 'image.downloadFailed': '下载失败',\n 'image.downloadSuccess': '下载成功',\n 'image.fitToScreen': '适应屏幕',\n 'image.flipHorizontal': '水平翻转',\n 'image.flipVertical': '垂直翻转',\n 'image.more': '更多',\n 'image.next': '下一张',\n 'image.prev': '上一张',\n 'image.rotateLeft': '向左旋转',\n 'image.rotateRight': '向右旋转',\n 'image.zoomIn': '放大',\n 'image.zoomOut': '缩小',\n} as const;\n"],"mappings":";AAAA,IAAA,gBAAe;CACb,oBAAoB;CACpB,eAAe;CACf,cAAc;CACd,oBAAoB;CACpB,qBAAqB;CACrB,kBAAkB;CAClB,wBAAwB;CACxB,yBAAyB;CACzB,qBAAqB;CACrB,wBAAwB;CACxB,sBAAsB;CACtB,cAAc;CACd,cAAc;CACd,cAAc;CACd,oBAAoB;CACpB,qBAAqB;CACrB,gBAAgB;CAChB,iBAAiB;AACnB"}
|
package/es/index.d.mts
CHANGED
|
@@ -186,7 +186,7 @@ import HtmlPreview from "./HtmlPreview/HtmlPreview.mjs";
|
|
|
186
186
|
import { HtmlPreviewIframe } from "./HtmlPreview/Iframe.mjs";
|
|
187
187
|
import { AUTO_HEIGHT_MESSAGE_TYPE } from "./HtmlPreview/injectAutoHeightScript.mjs";
|
|
188
188
|
import "./HtmlPreview/index.mjs";
|
|
189
|
-
import { ImageProps, PreviewGroupProps } from "./Image/type.mjs";
|
|
189
|
+
import { ImagePreviewOptions, ImageProps, PreviewGroupProps } from "./Image/type.mjs";
|
|
190
190
|
import PreviewGroup from "./Image/PreviewGroup.mjs";
|
|
191
191
|
import Image from "./Image/index.mjs";
|
|
192
192
|
import A from "./A/index.mjs";
|
|
@@ -309,4 +309,4 @@ import { LayoutSidebarInner } from "./Layout/components/LayoutSidebarInner.mjs";
|
|
|
309
309
|
import { LayoutToc } from "./Layout/components/LayoutToc.mjs";
|
|
310
310
|
import Layout from "./Layout/index.mjs";
|
|
311
311
|
import { ErrorBoundary, ErrorBoundaryProps } from "react-error-boundary";
|
|
312
|
-
export { A, type AProps, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, ActionIcon, ActionIconGroup, type ActionIconGroupEvent, type MenuItemType as ActionIconGroupItemType, type ActionIconGroupProps, type ActionIconProps, type ActionIconSize, Alert, type AlertProps, AutoComplete, type AutoCompleteProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type BaseMenuItemType, Block, type BlockProps, Burger, type BurgerProps, Button, type ButtonProps, type CDN, CLASSNAMES, Center, type CenterProps, Checkbox, CheckboxGroup, type CheckboxGroupOption, type CheckboxGroupProps, type CheckboxProps, CodeDiff, type CodeDiffProps, CodeEditor, type CodeEditorProps, Collapse, type CollapseItemType, type CollapseProps, type ColorPalettes, type ColorPalettesAlpha, ColorSwatches, type ColorSwatchesProps, type ColorToken, type Config, ConfigProvider, type ContextMenuCheckboxItem, ContextMenuHost, type ContextMenuInterceptor, type ContextMenuItem, ContextMenuTrigger, CopyButton, type CopyButtonProps, DatePicker, type DatePickerProps, type DiffViewMode, type DivProps, DownloadButton, type DownloadButtonProps, DraggablePanel, DraggablePanelBody, type DraggablePanelBodyProps, DraggablePanelContainer, type DraggablePanelContainerProps, DraggablePanelFooter, type DraggablePanelFooterProps, DraggablePanelHeader, type DraggablePanelHeaderProps, type DraggablePanelProps, DraggableSideNav, type DraggableSideNavProps, Drawer, type DrawerProps, Dropdown, type DropdownItem, DropdownMenu, type DropdownMenuCheckboxItem, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuFooter, type DropdownMenuFooterProps, DropdownMenuGroup, DropdownMenuGroupLabel, type DropdownMenuGroupLabelProps, DropdownMenuHeader, type DropdownMenuHeaderProps, DropdownMenuItem, DropdownMenuItemContent, type DropdownMenuItemContentProps, DropdownMenuItemExtra, type DropdownMenuItemExtraProps, DropdownMenuItemIcon, type DropdownMenuItemIconProps, DropdownMenuItemLabel, type DropdownMenuItemLabelProps, type DropdownMenuItemProps, type MenuItemType as DropdownMenuItemType, type DropdownMenuPlacement, DropdownMenuPopup, type DropdownMenuPopupProps, DropdownMenuPortal, type DropdownMenuPortalProps, DropdownMenuPositioner, type DropdownMenuPositionerProps, type DropdownMenuProps, DropdownMenuRoot, DropdownMenuScrollViewport, type DropdownMenuScrollViewportProps, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, type DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, type DropdownMenuSubmenuTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps, type DropdownProps, EditableText, type EditableTextProps, EditorSlashMenu, type EditorSlashMenuGroup, type EditorSlashMenuItems, type EditorSlashMenuOption, EmojiPicker, type EmojiPickerProps, Empty, type EmptyProps, ErrorBoundary, type ErrorBoundaryProps, FileTypeIcon, type FileTypeIconProps, _default as FlexBasic, type FlexBasicProps, _default as Flexbox, type FlexboxProps, FluentEmoji, type FluentEmojiProps, FontLoader, type FontLoaderProps, Footer, type FooterProps, Form, FormGroup, type FormGroupItemType, type FormGroupProps, type FormInstance, FormItem, type FormItemProps, FormModal, type FormModalProps, type FormProps, FormSubmitFooter, type FormSubmitFooterProps, FormTitle, type FormTitleProps, Freeze, type FreezeProps, type GenericItemType, Grid, type GridProps, GroupAvatar, type GroupAvatarProps, GuideCard, type GuideCardProps, DEFAULT_HEIGHT as HTML_PREVIEW_DEFAULT_HEIGHT, DEFAULT_SANDBOX as HTML_PREVIEW_DEFAULT_SANDBOX, AUTO_HEIGHT_MESSAGE_TYPE as HTML_PREVIEW_RESIZE_MESSAGE, Header, type HeaderProps, Highlighter, type HighlighterProps, Hotkey, HotkeyInput, type HotkeyInputProps, type HotkeyProps, HtmlPreview, HtmlPreviewIframe, type HtmlPreviewIframeProps, type HtmlPreviewMode, type HtmlPreviewProps, type HtmlPreviewStreamingMode, I18nProvider, type I18nProviderProps, Icon, type IconProps, IconProvider, type IconSize, Image, type ImageProps, ImageSelect, type ImageSelectItem, type ImageSelectProps, type ImgProps, type ImperativeModalProps, Input, InputNumber, type InputNumberProps, InputOPT, type InputOPTProps, InputPassword, type InputPasswordProps, type InputProps, type ItemType, KeyMapEnum, LOBE_THEME_APP_ID, Layout, LayoutFooter, type LayoutFooterProps, LayoutHeader, type LayoutHeaderProps, LayoutMain, type LayoutMainProps, type LayoutProps, LayoutSidebar, LayoutSidebarInner, type LayoutSidebarInnerProps, type LayoutSidebarProps, LayoutToc, type LayoutTocProps, List, ListItem, type ListItemProps, type ListProps, type LobeCustomStylish, type LobeCustomToken, I18nProvider as LobeUIProvider, Markdown, type MarkdownProps, MaskShadow, type MaskShadowProps, MaterialFileTypeIcon, type MaterialFileTypeIconProps, Menu, type MenuCheckboxItemType, type MenuInfo, type MenuItemType, type MenuProps, Mermaid, type MermaidProps, Meta, type MetaProps, Modal, ModalHost, type ModalHostProps, type ModalInstance, type ModalProps, ModalProvider, MotionComponent, type MotionComponentType, MotionProvider, NeuralNetworkLoading, type NeuralNetworkLoadingProps, NeutralColors, NeutralColorsObj, PatchDiff, type PatchDiffProps, type Placement, type PlacementConfig, Popover, PopoverArrow, type PopoverArrowAtomProps, PopoverArrowIcon, PopoverBackdrop, type PopoverContextValue, PopoverGroup, type PopoverPlacement, PopoverPopup, type PopoverPopupAtomProps, PopoverPortal, type PopoverPortalAtomProps, PopoverPositioner, type PopoverPositionerAtomProps, type PopoverProps, PopoverProvider, PopoverRoot, type PopoverTrigger, PopoverTriggerElement, type PopoverTriggerElementProps, PopoverViewport, type PopoverViewportAtomProps, type PresetColorKey, type PresetColorType, type PresetSystemColorKey, type PresetSystemColorType, PreviewGroup, type PreviewGroupProps, PrimaryColors, PrimaryColorsObj, type RawModalComponent, type RawModalComponentProps, type RawModalInstance, type RawModalKeyOptions, type RawModalOptions, ScrollArea, ScrollAreaContent, type ScrollAreaContentProps, ScrollAreaCorner, type ScrollAreaCornerProps, type ScrollAreaProps, ScrollAreaRoot, type ScrollAreaRootProps, ScrollAreaScrollbar, type ScrollAreaScrollbarProps, ScrollAreaThumb, type ScrollAreaThumbProps, ScrollAreaViewport, type ScrollAreaViewportProps, ScrollShadow, type ScrollShadowProps, SearchBar, type SearchBarProps, SearchResultCards, type SearchResultCardsProps, Segmented, type SegmentedProps, Select, type SelectProps, _default$1 as ShikiLobeTheme, SideNav, type SideNavProps, Skeleton, SkeletonAvatar, type SkeletonAvatarProps, SkeletonBlock, type SkeletonBlockProps, SkeletonButton, type SkeletonButtonProps, SkeletonParagraph, type SkeletonParagraphProps, type SkeletonProps, SkeletonTags, type SkeletonTagsProps, SkeletonTitle, type SkeletonTitleProps, SliderWithInput, type SliderWithInputProps, Snippet, type SnippetProps, SortableList, type SortableListProps, type SpanProps, type SvgProps, SyntaxHighlighter, type SyntaxHighlighterProps, SyntaxMermaid, type SyntaxMermaidProps, type SystemColorToken, Tabs, type TabsProps, Tag, type TagProps, Text, TextArea, type TextAreaProps, type TextProps, ThemeProvider, type ThemeProviderProps, ThemeSwitch, type ThemeSwitchProps, type ToastAPI, ToastHost, type ToastHostProps, type ToastInstance, type ToastOptions, type ToastPosition, type ToastPromiseOptions, type ToastProps, type ToastType, Toc, type TocProps, Tooltip, TooltipGroup, type TooltipProps, type Trigger, Typography, type TypographyProps, Video, type VideoProps, closeContextMenu, combineKeys, copyToClipboard, createModal, createRawModal, findCustomThemeName, genCdnUrl, generateColorNeutralPalette, generateColorPalette, highlighterThemes, containsScript as htmlPreviewContainsScript, isFullHtmlDocument, isHtmlContentClosed, generateCustomStylish as lobeCustomStylish, generateCustomToken as lobeCustomToken, staticStylish as lobeStaticStylish, styles as menuSharedStyles, mermaidThemes, neutralColors, neutralColorsSwatches, placementMap, preprocessMarkdownContent, preventDefault, preventDefaultAndStopPropagation, primaryColors, primaryColorsSwatches, rehypeCustomFootnotes, rehypeKatexDir, rehypeStreamAnimated, remarkBr, remarkColor, remarkCustomFootnotes, remarkGfmPlus, remarkVideo, renderDropdownMenuItems, setContextMenuInterceptor, showContextMenu, stopPropagation, toFloatingUIPlacement, toast, updateContextMenuItems, useAppElement, useCdnFn, useModalContext, useMotionComponent, usePopoverContext, usePopoverPortalContainer, useToast, useTranslation };
|
|
312
|
+
export { A, type AProps, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, ActionIcon, ActionIconGroup, type ActionIconGroupEvent, type MenuItemType as ActionIconGroupItemType, type ActionIconGroupProps, type ActionIconProps, type ActionIconSize, Alert, type AlertProps, AutoComplete, type AutoCompleteProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type BaseMenuItemType, Block, type BlockProps, Burger, type BurgerProps, Button, type ButtonProps, type CDN, CLASSNAMES, Center, type CenterProps, Checkbox, CheckboxGroup, type CheckboxGroupOption, type CheckboxGroupProps, type CheckboxProps, CodeDiff, type CodeDiffProps, CodeEditor, type CodeEditorProps, Collapse, type CollapseItemType, type CollapseProps, type ColorPalettes, type ColorPalettesAlpha, ColorSwatches, type ColorSwatchesProps, type ColorToken, type Config, ConfigProvider, type ContextMenuCheckboxItem, ContextMenuHost, type ContextMenuInterceptor, type ContextMenuItem, ContextMenuTrigger, CopyButton, type CopyButtonProps, DatePicker, type DatePickerProps, type DiffViewMode, type DivProps, DownloadButton, type DownloadButtonProps, DraggablePanel, DraggablePanelBody, type DraggablePanelBodyProps, DraggablePanelContainer, type DraggablePanelContainerProps, DraggablePanelFooter, type DraggablePanelFooterProps, DraggablePanelHeader, type DraggablePanelHeaderProps, type DraggablePanelProps, DraggableSideNav, type DraggableSideNavProps, Drawer, type DrawerProps, Dropdown, type DropdownItem, DropdownMenu, type DropdownMenuCheckboxItem, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuFooter, type DropdownMenuFooterProps, DropdownMenuGroup, DropdownMenuGroupLabel, type DropdownMenuGroupLabelProps, DropdownMenuHeader, type DropdownMenuHeaderProps, DropdownMenuItem, DropdownMenuItemContent, type DropdownMenuItemContentProps, DropdownMenuItemExtra, type DropdownMenuItemExtraProps, DropdownMenuItemIcon, type DropdownMenuItemIconProps, DropdownMenuItemLabel, type DropdownMenuItemLabelProps, type DropdownMenuItemProps, type MenuItemType as DropdownMenuItemType, type DropdownMenuPlacement, DropdownMenuPopup, type DropdownMenuPopupProps, DropdownMenuPortal, type DropdownMenuPortalProps, DropdownMenuPositioner, type DropdownMenuPositionerProps, type DropdownMenuProps, DropdownMenuRoot, DropdownMenuScrollViewport, type DropdownMenuScrollViewportProps, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, type DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, type DropdownMenuSubmenuTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps, type DropdownProps, EditableText, type EditableTextProps, EditorSlashMenu, type EditorSlashMenuGroup, type EditorSlashMenuItems, type EditorSlashMenuOption, EmojiPicker, type EmojiPickerProps, Empty, type EmptyProps, ErrorBoundary, type ErrorBoundaryProps, FileTypeIcon, type FileTypeIconProps, _default as FlexBasic, type FlexBasicProps, _default as Flexbox, type FlexboxProps, FluentEmoji, type FluentEmojiProps, FontLoader, type FontLoaderProps, Footer, type FooterProps, Form, FormGroup, type FormGroupItemType, type FormGroupProps, type FormInstance, FormItem, type FormItemProps, FormModal, type FormModalProps, type FormProps, FormSubmitFooter, type FormSubmitFooterProps, FormTitle, type FormTitleProps, Freeze, type FreezeProps, type GenericItemType, Grid, type GridProps, GroupAvatar, type GroupAvatarProps, GuideCard, type GuideCardProps, DEFAULT_HEIGHT as HTML_PREVIEW_DEFAULT_HEIGHT, DEFAULT_SANDBOX as HTML_PREVIEW_DEFAULT_SANDBOX, AUTO_HEIGHT_MESSAGE_TYPE as HTML_PREVIEW_RESIZE_MESSAGE, Header, type HeaderProps, Highlighter, type HighlighterProps, Hotkey, HotkeyInput, type HotkeyInputProps, type HotkeyProps, HtmlPreview, HtmlPreviewIframe, type HtmlPreviewIframeProps, type HtmlPreviewMode, type HtmlPreviewProps, type HtmlPreviewStreamingMode, I18nProvider, type I18nProviderProps, Icon, type IconProps, IconProvider, type IconSize, Image, type ImagePreviewOptions, type ImageProps, ImageSelect, type ImageSelectItem, type ImageSelectProps, type ImgProps, type ImperativeModalProps, Input, InputNumber, type InputNumberProps, InputOPT, type InputOPTProps, InputPassword, type InputPasswordProps, type InputProps, type ItemType, KeyMapEnum, LOBE_THEME_APP_ID, Layout, LayoutFooter, type LayoutFooterProps, LayoutHeader, type LayoutHeaderProps, LayoutMain, type LayoutMainProps, type LayoutProps, LayoutSidebar, LayoutSidebarInner, type LayoutSidebarInnerProps, type LayoutSidebarProps, LayoutToc, type LayoutTocProps, List, ListItem, type ListItemProps, type ListProps, type LobeCustomStylish, type LobeCustomToken, I18nProvider as LobeUIProvider, Markdown, type MarkdownProps, MaskShadow, type MaskShadowProps, MaterialFileTypeIcon, type MaterialFileTypeIconProps, Menu, type MenuCheckboxItemType, type MenuInfo, type MenuItemType, type MenuProps, Mermaid, type MermaidProps, Meta, type MetaProps, Modal, ModalHost, type ModalHostProps, type ModalInstance, type ModalProps, ModalProvider, MotionComponent, type MotionComponentType, MotionProvider, NeuralNetworkLoading, type NeuralNetworkLoadingProps, NeutralColors, NeutralColorsObj, PatchDiff, type PatchDiffProps, type Placement, type PlacementConfig, Popover, PopoverArrow, type PopoverArrowAtomProps, PopoverArrowIcon, PopoverBackdrop, type PopoverContextValue, PopoverGroup, type PopoverPlacement, PopoverPopup, type PopoverPopupAtomProps, PopoverPortal, type PopoverPortalAtomProps, PopoverPositioner, type PopoverPositionerAtomProps, type PopoverProps, PopoverProvider, PopoverRoot, type PopoverTrigger, PopoverTriggerElement, type PopoverTriggerElementProps, PopoverViewport, type PopoverViewportAtomProps, type PresetColorKey, type PresetColorType, type PresetSystemColorKey, type PresetSystemColorType, PreviewGroup, type PreviewGroupProps, PrimaryColors, PrimaryColorsObj, type RawModalComponent, type RawModalComponentProps, type RawModalInstance, type RawModalKeyOptions, type RawModalOptions, ScrollArea, ScrollAreaContent, type ScrollAreaContentProps, ScrollAreaCorner, type ScrollAreaCornerProps, type ScrollAreaProps, ScrollAreaRoot, type ScrollAreaRootProps, ScrollAreaScrollbar, type ScrollAreaScrollbarProps, ScrollAreaThumb, type ScrollAreaThumbProps, ScrollAreaViewport, type ScrollAreaViewportProps, ScrollShadow, type ScrollShadowProps, SearchBar, type SearchBarProps, SearchResultCards, type SearchResultCardsProps, Segmented, type SegmentedProps, Select, type SelectProps, _default$1 as ShikiLobeTheme, SideNav, type SideNavProps, Skeleton, SkeletonAvatar, type SkeletonAvatarProps, SkeletonBlock, type SkeletonBlockProps, SkeletonButton, type SkeletonButtonProps, SkeletonParagraph, type SkeletonParagraphProps, type SkeletonProps, SkeletonTags, type SkeletonTagsProps, SkeletonTitle, type SkeletonTitleProps, SliderWithInput, type SliderWithInputProps, Snippet, type SnippetProps, SortableList, type SortableListProps, type SpanProps, type SvgProps, SyntaxHighlighter, type SyntaxHighlighterProps, SyntaxMermaid, type SyntaxMermaidProps, type SystemColorToken, Tabs, type TabsProps, Tag, type TagProps, Text, TextArea, type TextAreaProps, type TextProps, ThemeProvider, type ThemeProviderProps, ThemeSwitch, type ThemeSwitchProps, type ToastAPI, ToastHost, type ToastHostProps, type ToastInstance, type ToastOptions, type ToastPosition, type ToastPromiseOptions, type ToastProps, type ToastType, Toc, type TocProps, Tooltip, TooltipGroup, type TooltipProps, type Trigger, Typography, type TypographyProps, Video, type VideoProps, closeContextMenu, combineKeys, copyToClipboard, createModal, createRawModal, findCustomThemeName, genCdnUrl, generateColorNeutralPalette, generateColorPalette, highlighterThemes, containsScript as htmlPreviewContainsScript, isFullHtmlDocument, isHtmlContentClosed, generateCustomStylish as lobeCustomStylish, generateCustomToken as lobeCustomToken, staticStylish as lobeStaticStylish, styles as menuSharedStyles, mermaidThemes, neutralColors, neutralColorsSwatches, placementMap, preprocessMarkdownContent, preventDefault, preventDefaultAndStopPropagation, primaryColors, primaryColorsSwatches, rehypeCustomFootnotes, rehypeKatexDir, rehypeStreamAnimated, remarkBr, remarkColor, remarkCustomFootnotes, remarkGfmPlus, remarkVideo, renderDropdownMenuItems, setContextMenuInterceptor, showContextMenu, stopPropagation, toFloatingUIPlacement, toast, updateContextMenuItems, useAppElement, useCdnFn, useModalContext, useMotionComponent, usePopoverContext, usePopoverPortalContainer, useToast, useTranslation };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MDXComponents } from "../../node_modules/.
|
|
1
|
+
import { MDXComponents } from "../../node_modules/.pnpm/@types_mdx@2.0.14/node_modules/@types/mdx/types.mjs";
|
|
2
2
|
//#region src/mdx/mdxComponents/index.d.ts
|
|
3
3
|
declare const mdxComponents: MDXComponents;
|
|
4
4
|
//#endregion
|
package/es/node_modules/{.bun → .pnpm}/@types_hast@3.0.5/node_modules/@types/hast/index.d.mts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Data as Data$1, Node as Node$1 } from "../../../../@types_unist@3.0.3/node_modules/@types/unist/index.mjs";
|
|
2
|
-
//#region node_modules/.
|
|
2
|
+
//#region node_modules/.pnpm/@types+hast@3.0.5/node_modules/@types/hast/index.d.ts
|
|
3
3
|
// ## Interfaces
|
|
4
4
|
/**
|
|
5
5
|
* Info associated with hast nodes by the ecosystem.
|