@ioca/react 1.3.74 → 1.3.75
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/lib/cjs/components/affix/totop.js +2 -1
- package/lib/cjs/components/affix/totop.js.map +1 -1
- package/lib/cjs/components/button/button.js +0 -4
- package/lib/cjs/components/button/button.js.map +1 -1
- package/lib/cjs/components/button/index.js +1 -0
- package/lib/cjs/components/button/index.js.map +1 -1
- package/lib/cjs/components/button/merged.js +13 -0
- package/lib/cjs/components/button/merged.js.map +1 -0
- package/lib/cjs/components/editor/controls.js +2 -1
- package/lib/cjs/components/editor/controls.js.map +1 -1
- package/lib/cjs/components/image/image.js +2 -2
- package/lib/cjs/components/image/image.js.map +1 -1
- package/lib/cjs/components/list/item.js +2 -1
- package/lib/cjs/components/list/item.js.map +1 -1
- package/lib/cjs/components/list/list.js +3 -2
- package/lib/cjs/components/list/list.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +2 -1
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/picker/colors/footer.js +2 -1
- package/lib/cjs/components/picker/colors/footer.js.map +1 -1
- package/lib/cjs/components/popconfirm/popconfirm.js +2 -1
- package/lib/cjs/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/cjs/components/popup/popup.js +2 -2
- package/lib/cjs/components/popup/popup.js.map +1 -1
- package/lib/cjs/components/tabs/tabs.js +4 -3
- package/lib/cjs/components/tabs/tabs.js.map +1 -1
- package/lib/cjs/components/upload/upload.js +2 -1
- package/lib/cjs/components/upload/upload.js.map +1 -1
- package/lib/cjs/components/video/video.js +2 -1
- package/lib/cjs/components/video/video.js.map +1 -1
- package/lib/cjs/index.js +3 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/js/hooks.js +3 -3
- package/lib/cjs/js/hooks.js.map +1 -1
- package/lib/cjs/js/usePreview/content.js +2 -1
- package/lib/cjs/js/usePreview/content.js.map +1 -1
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/affix/totop.js +2 -1
- package/lib/es/components/affix/totop.js.map +1 -1
- package/lib/es/components/button/button.js +0 -4
- package/lib/es/components/button/button.js.map +1 -1
- package/lib/es/components/button/index.js +1 -0
- package/lib/es/components/button/index.js.map +1 -1
- package/lib/es/components/button/merged.js +9 -0
- package/lib/es/components/button/merged.js.map +1 -0
- package/lib/es/components/editor/controls.js +2 -1
- package/lib/es/components/editor/controls.js.map +1 -1
- package/lib/es/components/image/image.js +2 -2
- package/lib/es/components/image/image.js.map +1 -1
- package/lib/es/components/list/item.js +2 -1
- package/lib/es/components/list/item.js.map +1 -1
- package/lib/es/components/list/list.js +3 -2
- package/lib/es/components/list/list.js.map +1 -1
- package/lib/es/components/modal/modal.js +2 -1
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/picker/colors/footer.js +2 -1
- package/lib/es/components/picker/colors/footer.js.map +1 -1
- package/lib/es/components/popconfirm/popconfirm.js +2 -1
- package/lib/es/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/es/components/popup/popup.js +2 -2
- package/lib/es/components/popup/popup.js.map +1 -1
- package/lib/es/components/tabs/tabs.js +4 -3
- package/lib/es/components/tabs/tabs.js.map +1 -1
- package/lib/es/components/upload/upload.js +2 -1
- package/lib/es/components/upload/upload.js.map +1 -1
- package/lib/es/components/video/video.js +2 -1
- package/lib/es/components/video/video.js.map +1 -1
- package/lib/es/index.js +2 -1
- package/lib/es/index.js.map +1 -1
- package/lib/es/js/hooks.js +3 -3
- package/lib/es/js/hooks.js.map +1 -1
- package/lib/es/js/usePreview/content.js +2 -1
- package/lib/es/js/usePreview/content.js.map +1 -1
- package/lib/index.js +66 -63
- package/lib/types/components/button/merged.d.ts +5 -0
- package/lib/types/components/list/type.d.ts +2 -1
- package/package.json +2 -2
|
@@ -5,10 +5,11 @@ import classNames from 'classnames';
|
|
|
5
5
|
import { throttle } from 'radash';
|
|
6
6
|
import { useRef, useImperativeHandle, useEffect } from 'react';
|
|
7
7
|
import { exitFullScreen, fullScreen } from '../../js/utils.js';
|
|
8
|
-
import
|
|
8
|
+
import '../button/merged.js';
|
|
9
9
|
import Icon from '../icon/icon.js';
|
|
10
10
|
import Progress from '../progress/progress.js';
|
|
11
11
|
import Text from '../text/text.js';
|
|
12
|
+
import Button from '../button/button.js';
|
|
12
13
|
|
|
13
14
|
const Video = (props) => {
|
|
14
15
|
const { ref, style, hideControls, autoplay, muted, volume = 50, height, width, useOriginControls, timeProgressProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.js","sources":["../../../../packages/components/video/video.tsx"],"sourcesContent":["import {\n\tFullscreenExitRound,\n\tFullscreenRound,\n\tPauseRound,\n\tPlayArrowRound,\n\tStopRound,\n\tVolumeDownRound,\n\tVolumeOffRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { throttle } from \"radash\";\nimport { useEffect, useImperativeHandle, useRef } from \"react\";\nimport { exitFullScreen, fullScreen } from \"../../js/utils\";\nimport Button from \"../button\";\nimport Icon from \"../icon\";\nimport Progress from \"../progress\";\nimport Text from \"../text\";\nimport \"./index.css\";\nimport { IVideo } from \"./type\";\n\nconst Video = (props: IVideo) => {\n\tconst {\n\t\tref,\n\t\tstyle,\n\t\thideControls,\n\t\tautoplay,\n\t\tmuted,\n\t\tvolume = 50,\n\t\theight,\n\t\twidth,\n\t\tuseOriginControls,\n\t\ttimeProgressProps = {\n\t\t\tbarClass: \"bg-blue\",\n\t\t},\n\t\tvolumeProgressProps = {\n\t\t\tbarClass: \"bg-blue\",\n\t\t},\n\t\tclassName,\n\t\tonFullScreenChange,\n\t\t...restProps\n\t} = props;\n\tconst state = useReactive({\n\t\tplaying: autoplay,\n\t\tvolume: muted ? 0 : volume,\n\t\tvolumeCache: 0,\n\t\tmuted,\n\t\tcurrent: 0,\n\t\tduration: 0,\n\t\tisFullscreen: false,\n\t\tcontrolHidden: true,\n\t\tdraggingProgress: false,\n\t});\n\tconst videoRef = useRef<HTMLVideoElement>(null);\n\tconst hiddenTO = useRef<any>(null);\n\n\tconst timeUpdateListener = (e) => {\n\t\tconst tar = e.target;\n\t\tif (tar.paused || state.draggingProgress) return;\n\n\t\tObject.assign(state, {\n\t\t\tcurrent: tar.currentTime,\n\t\t});\n\t};\n\n\tconst playChangeListener = (e) => {\n\t\tstate.playing = !e.target.paused;\n\t};\n\n\tconst fsChangeListener = () => {\n\t\tif (typeof document === \"undefined\") return;\n\t\tconst tar = videoRef.current?.parentElement;\n\t\tif (!tar) return;\n\n\t\tstate.isFullscreen = document.fullscreenElement === tar;\n\t};\n\n\tconst volumeChangeListener = (e) => {\n\t\tconst tar = e.target;\n\t\tObject.assign(state, {\n\t\t\tvolume: tar.volume * 100,\n\t\t\tmuted: tar.volume === 0,\n\t\t});\n\t};\n\n\tconst handlePlay = () => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.paused ? v.play() : v.pause();\n\t};\n\n\tconst handleReady = (e) => {\n\t\tconst tar = e.target;\n\t\tObject.assign(state, {\n\t\t\tduration: tar.duration,\n\t\t\tcurrent: tar.currentTime,\n\t\t});\n\t\ttar.volume = state.volume / 100;\n\t};\n\n\tconst handleMuted = () => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tif (v.volume > 0) {\n\t\t\tstate.volumeCache = v.volume;\n\t\t\tv.volume = 0;\n\t\t\treturn;\n\t\t}\n\t\tv.volume = state.volumeCache === 0 ? 0.5 : state.volumeCache;\n\t};\n\n\tconst handleStop = () => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.currentTime = 0;\n\t\tv.pause();\n\t};\n\n\tconst handleFullscreen = () => {\n\t\tconst tar = videoRef.current?.parentElement;\n\t\tif (!tar) return;\n\n\t\tstate.isFullscreen ? exitFullScreen() : fullScreen(tar);\n\t\tonFullScreenChange?.(!state.isFullscreen);\n\t};\n\n\tconst handleUpdateTime = (t) => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.currentTime = (state.duration * t) / 100;\n\t};\n\n\tconst handleUpdateVolume = (t) => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.volume = t / 100;\n\t};\n\n\tconst showControls = !hideControls && !useOriginControls;\n\n\tconst clearHiddenTO = () => {\n\t\tif (!hiddenTO.current) return;\n\t\tclearTimeout(hiddenTO.current);\n\t\thiddenTO.current = null;\n\t};\n\n\tconst setHiddenFalse = () => {\n\t\tif (!showControls || !state.controlHidden) return;\n\t\tstate.controlHidden = false;\n\n\t\tclearHiddenTO();\n\t\thiddenTO.current = setTimeout(() => {\n\t\t\tstate.controlHidden = true;\n\t\t}, 1000);\n\t};\n\n\tconst handleDraggingProgress = (dragging) => {\n\t\tstate.draggingProgress = dragging;\n\t};\n\n\tconst handleMouseMove = throttle({ interval: 900 }, setHiddenFalse);\n\n\tuseImperativeHandle(ref, () => ({\n\t\tplay: () => {\n\t\t\tconst v = videoRef.current;\n\t\t\tif (!v) return;\n\n\t\t\tv.play();\n\t\t},\n\t\tpause: () => {\n\t\t\tconst v = videoRef.current;\n\t\t\tif (!v) return;\n\n\t\t\tv.pause();\n\t\t},\n\t\tstop: handleStop,\n\t\tfullscreen: handleFullscreen,\n\t\tgetVideo: () => videoRef.current,\n\t}));\n\n\tuseEffect(() => {\n\t\tif (typeof document === \"undefined\") return;\n\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.addEventListener(\"timeupdate\", timeUpdateListener);\n\t\tv.addEventListener(\"play\", playChangeListener);\n\t\tv.addEventListener(\"pause\", playChangeListener);\n\t\tv.addEventListener(\"volumechange\", volumeChangeListener);\n\t\tdocument.addEventListener(\"fullscreenchange\", fsChangeListener);\n\n\t\treturn () => {\n\t\t\tclearHiddenTO();\n\t\t\tv.removeEventListener(\"timeupdate\", timeUpdateListener);\n\t\t\tv.removeEventListener(\"play\", playChangeListener);\n\t\t\tv.removeEventListener(\"pause\", playChangeListener);\n\t\t\tv.removeEventListener(\"volumechange\", volumeChangeListener);\n\t\t\tdocument.removeEventListener(\"fullscreenchange\", fsChangeListener);\n\t\t};\n\t}, []);\n\n\tconst currentValue = (state.current / state.duration) * 100;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\"i-video\", className)}\n\t\t\tstyle={{ height, width, ...style }}\n\t\t\tonClick={handlePlay}\n\t\t\tonDoubleClick={() => handleFullscreen()}\n\t\t\tonMouseMove={handleMouseMove}\n\t\t>\n\t\t\t<video\n\t\t\t\tref={videoRef}\n\t\t\t\tonCanPlay={handleReady}\n\t\t\t\t{...restProps}\n\t\t\t\tcontrols={useOriginControls}\n\t\t\t/>\n\n\t\t\t{showControls && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames(\"i-video-controls\", {\n\t\t\t\t\t\t\"i-video-controls-hidden\": state.controlHidden,\n\t\t\t\t\t})}\n\t\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t\t>\n\t\t\t\t\t<Button.Toggle\n\t\t\t\t\t\tclassName='i-video-btn'\n\t\t\t\t\t\tflat\n\t\t\t\t\t\tsquare\n\t\t\t\t\t\tafter={<Icon icon={<PauseRound />} />}\n\t\t\t\t\t\tactive={state.playing}\n\t\t\t\t\t\tonClick={handlePlay}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={<PlayArrowRound />} />\n\t\t\t\t\t</Button.Toggle>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName='i-video-btn'\n\t\t\t\t\t\tflat\n\t\t\t\t\t\tsquare\n\t\t\t\t\t\tonClick={handleStop}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={<StopRound />} />\n\t\t\t\t\t</Button>\n\t\t\t\t\t<span className='i-video-times font-sm'>\n\t\t\t\t\t\t<Text.Time seconds={state.current} /> /\n\t\t\t\t\t\t<Text.Time seconds={state.duration} />\n\t\t\t\t\t</span>\n\t\t\t\t\t<Progress\n\t\t\t\t\t\t{...timeProgressProps}\n\t\t\t\t\t\tvalue={currentValue}\n\t\t\t\t\t\tonChange={handleUpdateTime}\n\t\t\t\t\t\tonDraggingChange={handleDraggingProgress}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<div className='i-video-control-volume'>\n\t\t\t\t\t\t<Button.Toggle\n\t\t\t\t\t\t\tclassName='i-video-btn'\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tactive={state.volume <= 0}\n\t\t\t\t\t\t\tafter={\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\ticon={<VolumeOffRound />}\n\t\t\t\t\t\t\t\t\tstyle={{ padding: \".125em\" }}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={handleMuted}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<VolumeDownRound />} />\n\t\t\t\t\t\t</Button.Toggle>\n\n\t\t\t\t\t\t<div className='i-video-volume'>\n\t\t\t\t\t\t\t<Progress\n\t\t\t\t\t\t\t\tstyle={{ height: 100 }}\n\t\t\t\t\t\t\t\tvertical\n\t\t\t\t\t\t\t\t{...volumeProgressProps}\n\t\t\t\t\t\t\t\tvalue={state.volume}\n\t\t\t\t\t\t\t\tonChange={handleUpdateVolume}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<Button.Toggle\n\t\t\t\t\t\tclassName='i-video-btn'\n\t\t\t\t\t\tflat\n\t\t\t\t\t\tsquare\n\t\t\t\t\t\tafter={<Icon icon={<FullscreenExitRound />} />}\n\t\t\t\t\t\tactive={state.isFullscreen}\n\t\t\t\t\t\tonClick={() => handleFullscreen()}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={<FullscreenRound />} />\n\t\t\t\t\t</Button.Toggle>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\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A,GAAC,CAAA,eAAe,EAAG,EAAA,CAAA,EAAA,CAAI,EACpB,CAAA,CAAA,EAAA,CACX,CACN,CAAA,EAAA,CACI;AAER;;;;"}
|
|
1
|
+
{"version":3,"file":"video.js","sources":["../../../../packages/components/video/video.tsx"],"sourcesContent":["import {\n\tFullscreenExitRound,\n\tFullscreenRound,\n\tPauseRound,\n\tPlayArrowRound,\n\tStopRound,\n\tVolumeDownRound,\n\tVolumeOffRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { throttle } from \"radash\";\nimport { useEffect, useImperativeHandle, useRef } from \"react\";\nimport { exitFullScreen, fullScreen } from \"../../js/utils\";\nimport Button from \"../button\";\nimport Icon from \"../icon\";\nimport Progress from \"../progress\";\nimport Text from \"../text\";\nimport \"./index.css\";\nimport { IVideo } from \"./type\";\n\nconst Video = (props: IVideo) => {\n\tconst {\n\t\tref,\n\t\tstyle,\n\t\thideControls,\n\t\tautoplay,\n\t\tmuted,\n\t\tvolume = 50,\n\t\theight,\n\t\twidth,\n\t\tuseOriginControls,\n\t\ttimeProgressProps = {\n\t\t\tbarClass: \"bg-blue\",\n\t\t},\n\t\tvolumeProgressProps = {\n\t\t\tbarClass: \"bg-blue\",\n\t\t},\n\t\tclassName,\n\t\tonFullScreenChange,\n\t\t...restProps\n\t} = props;\n\tconst state = useReactive({\n\t\tplaying: autoplay,\n\t\tvolume: muted ? 0 : volume,\n\t\tvolumeCache: 0,\n\t\tmuted,\n\t\tcurrent: 0,\n\t\tduration: 0,\n\t\tisFullscreen: false,\n\t\tcontrolHidden: true,\n\t\tdraggingProgress: false,\n\t});\n\tconst videoRef = useRef<HTMLVideoElement>(null);\n\tconst hiddenTO = useRef<any>(null);\n\n\tconst timeUpdateListener = (e) => {\n\t\tconst tar = e.target;\n\t\tif (tar.paused || state.draggingProgress) return;\n\n\t\tObject.assign(state, {\n\t\t\tcurrent: tar.currentTime,\n\t\t});\n\t};\n\n\tconst playChangeListener = (e) => {\n\t\tstate.playing = !e.target.paused;\n\t};\n\n\tconst fsChangeListener = () => {\n\t\tif (typeof document === \"undefined\") return;\n\t\tconst tar = videoRef.current?.parentElement;\n\t\tif (!tar) return;\n\n\t\tstate.isFullscreen = document.fullscreenElement === tar;\n\t};\n\n\tconst volumeChangeListener = (e) => {\n\t\tconst tar = e.target;\n\t\tObject.assign(state, {\n\t\t\tvolume: tar.volume * 100,\n\t\t\tmuted: tar.volume === 0,\n\t\t});\n\t};\n\n\tconst handlePlay = () => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.paused ? v.play() : v.pause();\n\t};\n\n\tconst handleReady = (e) => {\n\t\tconst tar = e.target;\n\t\tObject.assign(state, {\n\t\t\tduration: tar.duration,\n\t\t\tcurrent: tar.currentTime,\n\t\t});\n\t\ttar.volume = state.volume / 100;\n\t};\n\n\tconst handleMuted = () => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tif (v.volume > 0) {\n\t\t\tstate.volumeCache = v.volume;\n\t\t\tv.volume = 0;\n\t\t\treturn;\n\t\t}\n\t\tv.volume = state.volumeCache === 0 ? 0.5 : state.volumeCache;\n\t};\n\n\tconst handleStop = () => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.currentTime = 0;\n\t\tv.pause();\n\t};\n\n\tconst handleFullscreen = () => {\n\t\tconst tar = videoRef.current?.parentElement;\n\t\tif (!tar) return;\n\n\t\tstate.isFullscreen ? exitFullScreen() : fullScreen(tar);\n\t\tonFullScreenChange?.(!state.isFullscreen);\n\t};\n\n\tconst handleUpdateTime = (t) => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.currentTime = (state.duration * t) / 100;\n\t};\n\n\tconst handleUpdateVolume = (t) => {\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.volume = t / 100;\n\t};\n\n\tconst showControls = !hideControls && !useOriginControls;\n\n\tconst clearHiddenTO = () => {\n\t\tif (!hiddenTO.current) return;\n\t\tclearTimeout(hiddenTO.current);\n\t\thiddenTO.current = null;\n\t};\n\n\tconst setHiddenFalse = () => {\n\t\tif (!showControls || !state.controlHidden) return;\n\t\tstate.controlHidden = false;\n\n\t\tclearHiddenTO();\n\t\thiddenTO.current = setTimeout(() => {\n\t\t\tstate.controlHidden = true;\n\t\t}, 1000);\n\t};\n\n\tconst handleDraggingProgress = (dragging) => {\n\t\tstate.draggingProgress = dragging;\n\t};\n\n\tconst handleMouseMove = throttle({ interval: 900 }, setHiddenFalse);\n\n\tuseImperativeHandle(ref, () => ({\n\t\tplay: () => {\n\t\t\tconst v = videoRef.current;\n\t\t\tif (!v) return;\n\n\t\t\tv.play();\n\t\t},\n\t\tpause: () => {\n\t\t\tconst v = videoRef.current;\n\t\t\tif (!v) return;\n\n\t\t\tv.pause();\n\t\t},\n\t\tstop: handleStop,\n\t\tfullscreen: handleFullscreen,\n\t\tgetVideo: () => videoRef.current,\n\t}));\n\n\tuseEffect(() => {\n\t\tif (typeof document === \"undefined\") return;\n\n\t\tconst v = videoRef.current;\n\t\tif (!v) return;\n\n\t\tv.addEventListener(\"timeupdate\", timeUpdateListener);\n\t\tv.addEventListener(\"play\", playChangeListener);\n\t\tv.addEventListener(\"pause\", playChangeListener);\n\t\tv.addEventListener(\"volumechange\", volumeChangeListener);\n\t\tdocument.addEventListener(\"fullscreenchange\", fsChangeListener);\n\n\t\treturn () => {\n\t\t\tclearHiddenTO();\n\t\t\tv.removeEventListener(\"timeupdate\", timeUpdateListener);\n\t\t\tv.removeEventListener(\"play\", playChangeListener);\n\t\t\tv.removeEventListener(\"pause\", playChangeListener);\n\t\t\tv.removeEventListener(\"volumechange\", volumeChangeListener);\n\t\t\tdocument.removeEventListener(\"fullscreenchange\", fsChangeListener);\n\t\t};\n\t}, []);\n\n\tconst currentValue = (state.current / state.duration) * 100;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\"i-video\", className)}\n\t\t\tstyle={{ height, width, ...style }}\n\t\t\tonClick={handlePlay}\n\t\t\tonDoubleClick={() => handleFullscreen()}\n\t\t\tonMouseMove={handleMouseMove}\n\t\t>\n\t\t\t<video\n\t\t\t\tref={videoRef}\n\t\t\t\tonCanPlay={handleReady}\n\t\t\t\t{...restProps}\n\t\t\t\tcontrols={useOriginControls}\n\t\t\t/>\n\n\t\t\t{showControls && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames(\"i-video-controls\", {\n\t\t\t\t\t\t\"i-video-controls-hidden\": state.controlHidden,\n\t\t\t\t\t})}\n\t\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t\t>\n\t\t\t\t\t<Button.Toggle\n\t\t\t\t\t\tclassName='i-video-btn'\n\t\t\t\t\t\tflat\n\t\t\t\t\t\tsquare\n\t\t\t\t\t\tafter={<Icon icon={<PauseRound />} />}\n\t\t\t\t\t\tactive={state.playing}\n\t\t\t\t\t\tonClick={handlePlay}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={<PlayArrowRound />} />\n\t\t\t\t\t</Button.Toggle>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName='i-video-btn'\n\t\t\t\t\t\tflat\n\t\t\t\t\t\tsquare\n\t\t\t\t\t\tonClick={handleStop}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={<StopRound />} />\n\t\t\t\t\t</Button>\n\t\t\t\t\t<span className='i-video-times font-sm'>\n\t\t\t\t\t\t<Text.Time seconds={state.current} /> /\n\t\t\t\t\t\t<Text.Time seconds={state.duration} />\n\t\t\t\t\t</span>\n\t\t\t\t\t<Progress\n\t\t\t\t\t\t{...timeProgressProps}\n\t\t\t\t\t\tvalue={currentValue}\n\t\t\t\t\t\tonChange={handleUpdateTime}\n\t\t\t\t\t\tonDraggingChange={handleDraggingProgress}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<div className='i-video-control-volume'>\n\t\t\t\t\t\t<Button.Toggle\n\t\t\t\t\t\t\tclassName='i-video-btn'\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tactive={state.volume <= 0}\n\t\t\t\t\t\t\tafter={\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\ticon={<VolumeOffRound />}\n\t\t\t\t\t\t\t\t\tstyle={{ padding: \".125em\" }}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={handleMuted}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<VolumeDownRound />} />\n\t\t\t\t\t\t</Button.Toggle>\n\n\t\t\t\t\t\t<div className='i-video-volume'>\n\t\t\t\t\t\t\t<Progress\n\t\t\t\t\t\t\t\tstyle={{ height: 100 }}\n\t\t\t\t\t\t\t\tvertical\n\t\t\t\t\t\t\t\t{...volumeProgressProps}\n\t\t\t\t\t\t\t\tvalue={state.volume}\n\t\t\t\t\t\t\t\tonChange={handleUpdateVolume}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<Button.Toggle\n\t\t\t\t\t\tclassName='i-video-btn'\n\t\t\t\t\t\tflat\n\t\t\t\t\t\tsquare\n\t\t\t\t\t\tafter={<Icon icon={<FullscreenExitRound />} />}\n\t\t\t\t\t\tactive={state.isFullscreen}\n\t\t\t\t\t\tonClick={() => handleFullscreen()}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={<FullscreenRound />} />\n\t\t\t\t\t</Button.Toggle>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Video;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;AAqBA,MAAM,KAAK,GAAG,CAAC,KAAa,KAAI;IAC/B,MAAM,EACL,GAAG,EACH,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,MAAM,GAAG,EAAE,EACX,MAAM,EACN,KAAK,EACL,iBAAiB,EAC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AA,MAAM,EACN,IAAA,EAAA,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,EACzB,KAAK,EACJA,GAAC,CAAA,IAAI,IACJ,IAAI,EAAEA,GAAC,CAAA,cAAc,EAAG,EAAA,CAAA,EACxB,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAC3B,CAAA,EAEH,OAAO,EAAE,WAAW,EAEpB,QAAA,EAAAA,GAAA,CAAC,IAAI,EAAA,EAAC,IAAI,EAAEA,GAAC,CAAA,eAAe,KAAG,EAAI,CAAA,EAAA,CACpB,EAEhBA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,gBAAgB,EAAA,QAAA,EAC9BA,IAAC,QAAQ,EAAA,EACR,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,EACtB,QAAQ,EACJ,IAAA,EAAA,GAAA,mBAAmB,EACvB,KAAK,EAAE,KAAK,CAAC,MAAM,EACnB,QAAQ,EAAE,kBAAkB,EAC3B,CAAA,EAAA,CACG,IACD,EAENA,GAAA,CAAC,MAAM,CAAC,MAAM,EAAA,EACb,SAAS,EAAC,aAAa,EACvB,IAAI,EACJ,IAAA,EAAA,MAAM,EACN,IAAA,EAAA,KAAK,EAAEA,GAAA,CAAC,IAAI,EAAC,EAAA,IAAI,EAAEA,GAAA,CAAC,mBAAmB,EAAA,EAAA,CAAG,EAAI,CAAA,EAC9C,MAAM,EAAE,KAAK,CAAC,YAAY,EAC1B,OAAO,EAAE,MAAM,gBAAgB,EAAE,EAAA,QAAA,EAEjCA,GAAC,CAAA,IAAI,EAAC,EAAA,IAAI,EAAEA,GAAC,CAAA,eAAe,EAAG,EAAA,CAAA,EAAA,CAAI,EACpB,CAAA,CAAA,EAAA,CACX,CACN,CAAA,EAAA,CACI;AAER;;;;"}
|
package/lib/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as Affix } from './components/affix/affix.js';
|
|
2
2
|
export { default as Badge } from './components/badge/badge.js';
|
|
3
|
-
|
|
3
|
+
import './components/button/merged.js';
|
|
4
4
|
export { default as Card } from './components/card/card.js';
|
|
5
5
|
export { default as Checkbox } from './components/checkbox/checkbox.js';
|
|
6
6
|
export { default as Collapse } from './components/collapse/collapse.js';
|
|
@@ -37,4 +37,5 @@ export { default as Tree } from './components/tree/tree.js';
|
|
|
37
37
|
export { default as Upload } from './components/upload/upload.js';
|
|
38
38
|
export { default as Video } from './components/video/video.js';
|
|
39
39
|
export { default as usePreview } from './js/usePreview/index.js';
|
|
40
|
+
export { default as Button } from './components/button/button.js';
|
|
40
41
|
//# sourceMappingURL=index.js.map
|
package/lib/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/es/js/hooks.js
CHANGED
|
@@ -63,9 +63,9 @@ function useKeydown(listener, options) {
|
|
|
63
63
|
}, [listener]);
|
|
64
64
|
}
|
|
65
65
|
const defaultObserver = {
|
|
66
|
-
observe:
|
|
67
|
-
unobserve:
|
|
68
|
-
disconnect:
|
|
66
|
+
observe: undefined,
|
|
67
|
+
unobserve: undefined,
|
|
68
|
+
disconnect: undefined,
|
|
69
69
|
};
|
|
70
70
|
function useIntersectionObserver(configs) {
|
|
71
71
|
if (typeof window === "undefined") {
|
package/lib/es/js/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../../../packages/js/hooks.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\ntype TMouseEvent = (e: MouseEvent) => void;\ntype TKeyboardEvent = (e: KeyboardEvent) => void;\ntype TEventOption = {\n\tdisabled?: boolean;\n};\n\nconst MouseMoveEvents = new Set<TMouseEvent>();\nconst MouseUpEvents = new Set<TMouseEvent>();\nconst KeydownEvents = new Set<TKeyboardEvent>();\n\nlet initialized = false;\n\nconst initEvents = () => {\n\tif (!document || initialized) return;\n\tinitialized = true;\n\n\tconst touchable = \"ontouchend\" in document;\n\tconst EVENTS: Record<string, any> = {\n\t\tMOVE: touchable ? \"touchmove\" : \"mousemove\",\n\t\tUP: touchable ? \"touchend\" : \"mouseup\",\n\t\tKEYDOWN: \"keydown\",\n\t};\n\n\tdocument.addEventListener(\n\t\tEVENTS.MOVE,\n\t\t(e) => {\n\t\t\tfor (const listener of MouseMoveEvents.values()) {\n\t\t\t\tlistener(e);\n\t\t\t}\n\t\t},\n\t\t{ passive: false }\n\t);\n\n\tdocument.addEventListener(EVENTS.UP, (e) => {\n\t\tfor (const listener of MouseUpEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n\n\tdocument.addEventListener(EVENTS.KEYDOWN, (e) => {\n\t\tfor (const listener of KeydownEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n};\n\nfunction useInitEvents() {\n\tuseEffect(initEvents, []);\n}\n\nexport function useMouseMove(listener: TMouseEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseMoveEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseMoveEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useMouseUp(listener: TMouseEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseUpEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseUpEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useKeydown(listener: TKeyboardEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tKeydownEvents.add(listener);\n\t\treturn () => {\n\t\t\tKeydownEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nconst defaultObserver = {\n\tobserve:
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../packages/js/hooks.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\ntype TMouseEvent = (e: MouseEvent) => void;\ntype TKeyboardEvent = (e: KeyboardEvent) => void;\ntype TEventOption = {\n\tdisabled?: boolean;\n};\n\nconst MouseMoveEvents = new Set<TMouseEvent>();\nconst MouseUpEvents = new Set<TMouseEvent>();\nconst KeydownEvents = new Set<TKeyboardEvent>();\n\nlet initialized = false;\n\nconst initEvents = () => {\n\tif (!document || initialized) return;\n\tinitialized = true;\n\n\tconst touchable = \"ontouchend\" in document;\n\tconst EVENTS: Record<string, any> = {\n\t\tMOVE: touchable ? \"touchmove\" : \"mousemove\",\n\t\tUP: touchable ? \"touchend\" : \"mouseup\",\n\t\tKEYDOWN: \"keydown\",\n\t};\n\n\tdocument.addEventListener(\n\t\tEVENTS.MOVE,\n\t\t(e) => {\n\t\t\tfor (const listener of MouseMoveEvents.values()) {\n\t\t\t\tlistener(e);\n\t\t\t}\n\t\t},\n\t\t{ passive: false }\n\t);\n\n\tdocument.addEventListener(EVENTS.UP, (e) => {\n\t\tfor (const listener of MouseUpEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n\n\tdocument.addEventListener(EVENTS.KEYDOWN, (e) => {\n\t\tfor (const listener of KeydownEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n};\n\nfunction useInitEvents() {\n\tuseEffect(initEvents, []);\n}\n\nexport function useMouseMove(listener: TMouseEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseMoveEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseMoveEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useMouseUp(listener: TMouseEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseUpEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseUpEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useKeydown(listener: TKeyboardEvent, options?: TEventOption) {\n\tuseInitEvents();\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tKeydownEvents.add(listener);\n\t\treturn () => {\n\t\t\tKeydownEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nconst defaultObserver = {\n\tobserve: undefined,\n\tunobserve: undefined,\n\tdisconnect: undefined,\n};\n\nexport function useIntersectionObserver(configs?: IntersectionObserverInit) {\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\tconst WM = new WeakMap();\n\tconst IO = new IntersectionObserver((entries) => {\n\t\tentries.map((entry) => {\n\t\t\tconst callback = WM.get(entry.target);\n\t\t\tcallback?.(entry.target, entry.isIntersecting);\n\t\t});\n\t}, configs);\n\n\tfunction observe(target: HTMLElement, callback: Function) {\n\t\tif (WM.get(target)) return;\n\t\tWM.set(target, callback);\n\t\ttarget && IO.observe(target);\n\t}\n\n\tfunction unobserve(target: HTMLElement) {\n\t\ttarget && IO.unobserve(target);\n\t\tWM.delete(target);\n\t}\n\n\tfunction disconnect() {\n\t\tIO.disconnect();\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n\nexport function useResizeObserver() {\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\tconst WM = new WeakMap();\n\tconst IO = new ResizeObserver((entries) => {\n\t\tentries.map((entry) => {\n\t\t\tconst callback = WM.get(entry.target);\n\t\t\tcallback?.(entry.target);\n\t\t});\n\t});\n\n\tfunction observe(target: HTMLElement, callback: Function) {\n\t\tif (WM.get(target)) return;\n\t\ttarget && IO.observe(target);\n\t\tWM.set(target, callback);\n\t}\n\n\tfunction unobserve(target: HTMLElement) {\n\t\ttarget && IO.unobserve(target);\n\t\tWM.delete(target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H,KAAC,CAAC;AAEF,IAAA,SAAS,OAAO,CAAC,MAAmB,EAAE,QAAkB,EAAA;AACvD,QAAA,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE;AACpB,QAAA,MAAM,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;AAC5B,QAAA,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;;IAGzB,SAAS,SAAS,CAAC,MAAmB,EAAA;AACrC,QAAA,MAAM,IAAI,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC;AAC9B,QAAA,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;;AAGlB,IAAA,SAAS,UAAU,GAAA;QAClB,EAAE,CAAC,UAAU,EAAE;;IAGhB,OAAO;QACN,OAAO;QACP,SAAS;QACT,UAAU;KACV;AACF;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import '../../components/button/merged.js';
|
|
3
3
|
import Icon from '../../components/icon/icon.js';
|
|
4
4
|
import { CloseRound, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound } from '@ricons/material';
|
|
5
5
|
import { useReactive } from 'ahooks';
|
|
@@ -10,6 +10,7 @@ import { useMouseMove, useMouseUp } from '../hooks.js';
|
|
|
10
10
|
import { getSuffixByUrl, getFileType } from '../utils.js';
|
|
11
11
|
import renderFile from './renderFile.js';
|
|
12
12
|
import { TFileType } from './type.js';
|
|
13
|
+
import Button from '../../components/button/button.js';
|
|
13
14
|
|
|
14
15
|
function Content(props) {
|
|
15
16
|
const { items = [], initial = 0, renderFile: renderFile$1 = renderFile, onRotate, onChange, onClose, onZoom, } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sources":["../../../../packages/js/usePreview/content.tsx"],"sourcesContent":["import Button from \"@p/components/button\";\nimport Icon from \"@p/components/icon\";\nimport {\n\tAspectRatioRound,\n\tCloseRound,\n\tFileDownloadOutlined,\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tOpenInNewRound,\n\tRotateLeftRound,\n\tRotateRightRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { throttle } from \"radash\";\nimport { useMemo, useRef } from \"react\";\nimport { useMouseMove, useMouseUp } from \"../hooks\";\nimport { getFileType, getSuffixByUrl } from \"../utils\";\nimport DefaultRenderFile from \"./renderFile\";\nimport { IPreview, TFileType, TPreviewItem } from \"./type\";\n\nexport default function Content(props: IPreview) {\n\tconst {\n\t\titems = [],\n\t\tinitial = 0,\n\t\trenderFile = DefaultRenderFile,\n\t\tonRotate,\n\t\tonChange,\n\t\tonClose,\n\t\tonZoom,\n\t} = props;\n\tconst state = useReactive({\n\t\tcurrent: initial,\n\t\trotate: 0,\n\t\tscale: 1,\n\t\ttranslate: [0, 0],\n\t\tstart: [0, 0],\n\t\tdragging: false,\n\t\tcontrolHidden: true,\n\t});\n\tconst box = useRef<HTMLDivElement>(null);\n\tconst translate = useRef<number[]>([0, 0]);\n\tconst hiddenTO = useRef<any>(null);\n\n\tconst files = useMemo(() => {\n\t\treturn items.map((item) => {\n\t\t\tconst o: TPreviewItem = {\n\t\t\t\tsrc: \"\",\n\t\t\t};\n\t\t\tif (typeof item === \"string\") {\n\t\t\t\to.src = item;\n\t\t\t} else {\n\t\t\t\tObject.assign(o, item);\n\t\t\t}\n\n\t\t\to.suffix = getSuffixByUrl(o.src) || \"\";\n\t\t\to.type = getFileType(o.suffix, item[\"type\"]);\n\n\t\t\treturn o;\n\t\t});\n\t}, [items]);\n\n\tconst { file, content } = useMemo(() => {\n\t\tconst file = files[state.current];\n\t\tconst content = renderFile(file);\n\n\t\treturn {\n\t\t\tfile,\n\t\t\tcontent,\n\t\t};\n\t}, [state.current, items]);\n\n\tconst isImage = file.type === TFileType.IMAGE;\n\n\tconst handleSwitch = (next: number) => {\n\t\tconst l = files.length;\n\t\tconst { current: before } = state;\n\t\tif (next >= l) {\n\t\t\tstate.current = 0;\n\t\t} else if (next < 0) {\n\t\t\tstate.current = l - 1;\n\t\t} else {\n\t\t\tstate.current = next;\n\t\t}\n\t\tonChange?.(state.current, before);\n\n\t\tstate.rotate = files[state.current].rotate || 0;\n\n\t\tif (state.scale !== 1) {\n\t\t\tstate.scale = 1;\n\t\t\tonZoom?.(1);\n\t\t}\n\t\tonRotate?.(state.rotate);\n\t\tstate.translate = translate.current = [0, 0];\n\t};\n\n\tconst handleRotate = (deg: number) => {\n\t\tstate.rotate += deg;\n\n\t\tonRotate?.(state.rotate);\n\t};\n\n\tconst handleMouseWheel = throttle({ interval: 60 }, (e) => {\n\t\tif (!isImage) return;\n\t\tlet after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);\n\t\tif (after > 2) after = 2;\n\t\tif (after < 0.25) after = 0.25;\n\n\t\tonZoom?.(after);\n\t\tstate.scale = after;\n\t});\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!isImage) return;\n\t\te.preventDefault();\n\t\tstate.dragging = true;\n\t\tstate.start = [e.pageX, e.pageY];\n\t};\n\n\tconst clearHiddenTO = () => {\n\t\tif (!hiddenTO.current || state.controlHidden) return;\n\t\tclearTimeout(hiddenTO.current);\n\t\thiddenTO.current = null;\n\t};\n\n\tconst setHiddenFalse = () => {\n\t\tif (!state.controlHidden) return;\n\t\tstate.controlHidden = false;\n\n\t\tclearHiddenTO();\n\t\thiddenTO.current = setTimeout(() => {\n\t\t\tstate.controlHidden = true;\n\t\t}, 1000);\n\t};\n\n\tconst throttleMouseMove = throttle({ interval: 300 }, setHiddenFalse);\n\n\tconst handleMouseMove = (e) => {\n\t\tthrottleMouseMove();\n\t\tif (!state.dragging) return;\n\t\te.preventDefault();\n\n\t\tconst [x, y] = translate.current;\n\t\tconst [ox, oy] = state.start;\n\t\tconst offsetX = e.pageX - ox;\n\t\tconst offsetY = e.pageY - oy;\n\n\t\tstate.translate = [x + offsetX, y + offsetY];\n\t};\n\n\tconst handleMouseUp = () => {\n\t\tif (!state.dragging) return;\n\t\tstate.dragging = false;\n\t\ttranslate.current = state.translate;\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={box}\n\t\t\t\tclassName={classNames(\"i-preview-content\", {\n\t\t\t\t\t\"no-transition\": state.dragging,\n\t\t\t\t})}\n\t\t\t\tstyle={{\n\t\t\t\t\ttransform: `translate(${state.translate\n\t\t\t\t\t\t.map((n) => `${n}px`)\n\t\t\t\t\t\t.join(\",\")}) rotate(${state.rotate}deg) scale(${\n\t\t\t\t\t\tstate.scale\n\t\t\t\t\t})`,\n\t\t\t\t}}\n\t\t\t\tonWheel={handleMouseWheel}\n\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-preview-controls\", {\n\t\t\t\t\t\"i-preview-controls-hidden\": state.controlHidden,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<Button square flat onClick={onClose}>\n\t\t\t\t\t<Icon icon={<CloseRound />} />\n\t\t\t\t</Button>\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<span className='px-8'>\n\t\t\t\t\t\t{state.current + 1} / {files.length}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{state.scale !== 1 && (\n\t\t\t\t\t<Button flat onClick={() => (state.scale = 1)}>\n\t\t\t\t\t\t<Icon icon={<AspectRatioRound />} />\n\t\t\t\t\t\t<span className='mt-2'>\n\t\t\t\t\t\t\t{(state.scale * 100).toFixed(0)}%\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Button>\n\t\t\t\t)}\n\t\t\t\t<Button square flat href={file.src} target='_blank'>\n\t\t\t\t\t<Icon icon={<OpenInNewRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat href={file.src} download target='_blank'>\n\t\t\t\t\t<Icon icon={<FileDownloadOutlined />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(90)}>\n\t\t\t\t\t<Icon icon={<RotateRightRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(-90)}>\n\t\t\t\t\t<Icon icon={<RotateLeftRound />} />\n\t\t\t\t</Button>\n\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current - 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowLeftRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current + 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowRightRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"names":["renderFile","DefaultRenderFile","_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;AAqBwB,SAAA,OAAO,CAAC,KAAe,EAAA;IAC9C,MAAM,EACL,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,CAAC,cACXA,YAAU,GAAGC,UAAiB,EAC9B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,GACN,GAAG,KAAK;IACT,MAAM,KAAK,GAAG,WAAW,CAAC;AACzB,QAAA,OAAO,EAAE,OAAO;AAChB,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACR,QAAA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AAI,EAClC,CAAA,EACTA,GAAC,CAAA,MAAM,EACN,EAAA,MAAM,EACN,IAAA,EAAA,IAAI,QACJ,OAAO,EAAE,MAAM,YAAY,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,EAAA,QAAA,EAE9CA,GAAC,CAAA,IAAI,EAAC,EAAA,IAAI,EAAEA,GAAC,CAAA,uBAAuB,EAAG,EAAA,CAAA,EAAA,CAAI,GACnC,CACP,EAAA,CAAA,CACH,CACI,EAAA,CAAA,CAAA,EAAA,CACJ;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"content.js","sources":["../../../../packages/js/usePreview/content.tsx"],"sourcesContent":["import Button from \"@p/components/button\";\nimport Icon from \"@p/components/icon\";\nimport {\n\tAspectRatioRound,\n\tCloseRound,\n\tFileDownloadOutlined,\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tOpenInNewRound,\n\tRotateLeftRound,\n\tRotateRightRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { throttle } from \"radash\";\nimport { useMemo, useRef } from \"react\";\nimport { useMouseMove, useMouseUp } from \"../hooks\";\nimport { getFileType, getSuffixByUrl } from \"../utils\";\nimport DefaultRenderFile from \"./renderFile\";\nimport { IPreview, TFileType, TPreviewItem } from \"./type\";\n\nexport default function Content(props: IPreview) {\n\tconst {\n\t\titems = [],\n\t\tinitial = 0,\n\t\trenderFile = DefaultRenderFile,\n\t\tonRotate,\n\t\tonChange,\n\t\tonClose,\n\t\tonZoom,\n\t} = props;\n\tconst state = useReactive({\n\t\tcurrent: initial,\n\t\trotate: 0,\n\t\tscale: 1,\n\t\ttranslate: [0, 0],\n\t\tstart: [0, 0],\n\t\tdragging: false,\n\t\tcontrolHidden: true,\n\t});\n\tconst box = useRef<HTMLDivElement>(null);\n\tconst translate = useRef<number[]>([0, 0]);\n\tconst hiddenTO = useRef<any>(null);\n\n\tconst files = useMemo(() => {\n\t\treturn items.map((item) => {\n\t\t\tconst o: TPreviewItem = {\n\t\t\t\tsrc: \"\",\n\t\t\t};\n\t\t\tif (typeof item === \"string\") {\n\t\t\t\to.src = item;\n\t\t\t} else {\n\t\t\t\tObject.assign(o, item);\n\t\t\t}\n\n\t\t\to.suffix = getSuffixByUrl(o.src) || \"\";\n\t\t\to.type = getFileType(o.suffix, item[\"type\"]);\n\n\t\t\treturn o;\n\t\t});\n\t}, [items]);\n\n\tconst { file, content } = useMemo(() => {\n\t\tconst file = files[state.current];\n\t\tconst content = renderFile(file);\n\n\t\treturn {\n\t\t\tfile,\n\t\t\tcontent,\n\t\t};\n\t}, [state.current, items]);\n\n\tconst isImage = file.type === TFileType.IMAGE;\n\n\tconst handleSwitch = (next: number) => {\n\t\tconst l = files.length;\n\t\tconst { current: before } = state;\n\t\tif (next >= l) {\n\t\t\tstate.current = 0;\n\t\t} else if (next < 0) {\n\t\t\tstate.current = l - 1;\n\t\t} else {\n\t\t\tstate.current = next;\n\t\t}\n\t\tonChange?.(state.current, before);\n\n\t\tstate.rotate = files[state.current].rotate || 0;\n\n\t\tif (state.scale !== 1) {\n\t\t\tstate.scale = 1;\n\t\t\tonZoom?.(1);\n\t\t}\n\t\tonRotate?.(state.rotate);\n\t\tstate.translate = translate.current = [0, 0];\n\t};\n\n\tconst handleRotate = (deg: number) => {\n\t\tstate.rotate += deg;\n\n\t\tonRotate?.(state.rotate);\n\t};\n\n\tconst handleMouseWheel = throttle({ interval: 60 }, (e) => {\n\t\tif (!isImage) return;\n\t\tlet after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);\n\t\tif (after > 2) after = 2;\n\t\tif (after < 0.25) after = 0.25;\n\n\t\tonZoom?.(after);\n\t\tstate.scale = after;\n\t});\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!isImage) return;\n\t\te.preventDefault();\n\t\tstate.dragging = true;\n\t\tstate.start = [e.pageX, e.pageY];\n\t};\n\n\tconst clearHiddenTO = () => {\n\t\tif (!hiddenTO.current || state.controlHidden) return;\n\t\tclearTimeout(hiddenTO.current);\n\t\thiddenTO.current = null;\n\t};\n\n\tconst setHiddenFalse = () => {\n\t\tif (!state.controlHidden) return;\n\t\tstate.controlHidden = false;\n\n\t\tclearHiddenTO();\n\t\thiddenTO.current = setTimeout(() => {\n\t\t\tstate.controlHidden = true;\n\t\t}, 1000);\n\t};\n\n\tconst throttleMouseMove = throttle({ interval: 300 }, setHiddenFalse);\n\n\tconst handleMouseMove = (e) => {\n\t\tthrottleMouseMove();\n\t\tif (!state.dragging) return;\n\t\te.preventDefault();\n\n\t\tconst [x, y] = translate.current;\n\t\tconst [ox, oy] = state.start;\n\t\tconst offsetX = e.pageX - ox;\n\t\tconst offsetY = e.pageY - oy;\n\n\t\tstate.translate = [x + offsetX, y + offsetY];\n\t};\n\n\tconst handleMouseUp = () => {\n\t\tif (!state.dragging) return;\n\t\tstate.dragging = false;\n\t\ttranslate.current = state.translate;\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={box}\n\t\t\t\tclassName={classNames(\"i-preview-content\", {\n\t\t\t\t\t\"no-transition\": state.dragging,\n\t\t\t\t})}\n\t\t\t\tstyle={{\n\t\t\t\t\ttransform: `translate(${state.translate\n\t\t\t\t\t\t.map((n) => `${n}px`)\n\t\t\t\t\t\t.join(\",\")}) rotate(${state.rotate}deg) scale(${\n\t\t\t\t\t\tstate.scale\n\t\t\t\t\t})`,\n\t\t\t\t}}\n\t\t\t\tonWheel={handleMouseWheel}\n\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-preview-controls\", {\n\t\t\t\t\t\"i-preview-controls-hidden\": state.controlHidden,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<Button square flat onClick={onClose}>\n\t\t\t\t\t<Icon icon={<CloseRound />} />\n\t\t\t\t</Button>\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<span className='px-8'>\n\t\t\t\t\t\t{state.current + 1} / {files.length}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{state.scale !== 1 && (\n\t\t\t\t\t<Button flat onClick={() => (state.scale = 1)}>\n\t\t\t\t\t\t<Icon icon={<AspectRatioRound />} />\n\t\t\t\t\t\t<span className='mt-2'>\n\t\t\t\t\t\t\t{(state.scale * 100).toFixed(0)}%\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Button>\n\t\t\t\t)}\n\t\t\t\t<Button square flat href={file.src} target='_blank'>\n\t\t\t\t\t<Icon icon={<OpenInNewRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat href={file.src} download target='_blank'>\n\t\t\t\t\t<Icon icon={<FileDownloadOutlined />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(90)}>\n\t\t\t\t\t<Icon icon={<RotateRightRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(-90)}>\n\t\t\t\t\t<Icon icon={<RotateLeftRound />} />\n\t\t\t\t</Button>\n\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current - 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowLeftRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current + 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowRightRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\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,EAAA,IAAI,EAAEA,GAAA,CAAC,eAAe,EAAG,EAAA,CAAA,EAAA,CAAI,EAC3B,CAAA,EAER,KAAK,CAAC,MAAM,GAAG,CAAC,KAChBF,IACC,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CAAAC,GAAA,CAAC,MAAM,EACN,EAAA,MAAM,EACN,IAAA,EAAA,IAAI,EACJ,IAAA,EAAA,OAAO,EAAE,MAAM,YAAY,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,EAE9C,QAAA,EAAAA,GAAA,CAAC,IAAI,EAAA,EAAC,IAAI,EAAEA,GAAA,CAAC,sBAAsB,EAAA,EAAA,CAAG,GAAI,EAClC,CAAA,EACTA,GAAC,CAAA,MAAM,EACN,EAAA,MAAM,EACN,IAAA,EAAA,IAAI,QACJ,OAAO,EAAE,MAAM,YAAY,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,EAAA,QAAA,EAE9CA,GAAC,CAAA,IAAI,EAAC,EAAA,IAAI,EAAEA,GAAC,CAAA,uBAAuB,EAAG,EAAA,CAAA,EAAA,CAAI,GACnC,CACP,EAAA,CAAA,CACH,CACI,EAAA,CAAA,CAAA,EAAA,CACJ;AAEL;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { debounce, uid, throttle, pick, title } from 'radash';
|
|
4
|
-
import {
|
|
4
|
+
import { createElement, useEffect, useMemo, Children, cloneElement, isValidElement, useState, useRef, Fragment as Fragment$1, useLayoutEffect, useImperativeHandle, createContext, useContext } from 'react';
|
|
5
5
|
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, RedoRound, UndoRound, ClearAllRound, PauseRound, PlayArrowRound, StopRound, VolumeOffRound, VolumeDownRound, FullscreenExitRound, FullscreenRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, HideImageTwotone, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, ListAltRound, PlusSharp } from '@ricons/material';
|
|
6
6
|
import { useReactive, useCreation, useSize } from 'ahooks';
|
|
7
7
|
import { createRoot } from 'react-dom/client';
|
|
@@ -71,6 +71,56 @@ const Loading = (props) => {
|
|
|
71
71
|
}, children: jsx("circle", { cx: '12', cy: '12', r: '9.5', fill: 'none', strokeWidth: '3', strokeLinecap: 'round', strokeDasharray: 40, strokeDashoffset: 0 }) })), text] }));
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
const formatClass = ({ outline, flat, loading, disabled, size = "normal", block, round, square, secondary, className, }) => classNames("i-btn", className, {
|
|
75
|
+
"i-btn-outline": outline,
|
|
76
|
+
"i-btn-flat": flat,
|
|
77
|
+
"i-btn-block": block,
|
|
78
|
+
"i-btn-loading": loading,
|
|
79
|
+
"i-btn-square": square,
|
|
80
|
+
"i-btn-secondary": secondary,
|
|
81
|
+
[`i-btn-${size}`]: size !== "normal",
|
|
82
|
+
round,
|
|
83
|
+
disabled,
|
|
84
|
+
});
|
|
85
|
+
const Button = (props) => {
|
|
86
|
+
const { as: As = "a", ref, children, className, loading, flat, outline, square, secondary, size, round, href, ripple = true, onClick, ...restProps } = props;
|
|
87
|
+
const handleClick = (e) => {
|
|
88
|
+
if (loading || restProps.disabled) {
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
onClick?.(e);
|
|
94
|
+
};
|
|
95
|
+
if (!children)
|
|
96
|
+
return jsx(Fragment, {});
|
|
97
|
+
const childNodes = [
|
|
98
|
+
loading && jsx(Loading, {}, 'loading'),
|
|
99
|
+
createElement("span", { key: "content", className: "i-btn-content" }, children),
|
|
100
|
+
];
|
|
101
|
+
const attrs = {
|
|
102
|
+
className: formatClass(props),
|
|
103
|
+
["data-ripple"]: ripple && !loading && !restProps.disabled ? "" : undefined,
|
|
104
|
+
onClick: handleClick,
|
|
105
|
+
};
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
ripple && useRipple();
|
|
108
|
+
}, [ripple]);
|
|
109
|
+
if (typeof As === "string") {
|
|
110
|
+
return createElement(As, {
|
|
111
|
+
ref,
|
|
112
|
+
href,
|
|
113
|
+
...attrs,
|
|
114
|
+
...restProps,
|
|
115
|
+
}, childNodes);
|
|
116
|
+
}
|
|
117
|
+
return createElement(As, {
|
|
118
|
+
to: href || "",
|
|
119
|
+
...attrs,
|
|
120
|
+
...restProps,
|
|
121
|
+
}, childNodes);
|
|
122
|
+
};
|
|
123
|
+
|
|
74
124
|
function Group(props) {
|
|
75
125
|
const { children, vertical, buttonProps, className, style } = props;
|
|
76
126
|
const nodes = useMemo(() => {
|
|
@@ -123,57 +173,8 @@ function Toggle(props) {
|
|
|
123
173
|
}), children: state.active ? after ?? children : children }) }));
|
|
124
174
|
}
|
|
125
175
|
|
|
126
|
-
const formatClass = ({ outline, flat, loading, disabled, size = "normal", block, round, square, secondary, className, }) => classNames("i-btn", className, {
|
|
127
|
-
"i-btn-outline": outline,
|
|
128
|
-
"i-btn-flat": flat,
|
|
129
|
-
"i-btn-block": block,
|
|
130
|
-
"i-btn-loading": loading,
|
|
131
|
-
"i-btn-square": square,
|
|
132
|
-
"i-btn-secondary": secondary,
|
|
133
|
-
[`i-btn-${size}`]: size !== "normal",
|
|
134
|
-
round,
|
|
135
|
-
disabled,
|
|
136
|
-
});
|
|
137
|
-
const Button = (props) => {
|
|
138
|
-
const { as: As = "a", ref, children, className, loading, flat, outline, square, secondary, size, round, href, ripple = true, onClick, ...restProps } = props;
|
|
139
|
-
const handleClick = (e) => {
|
|
140
|
-
if (loading || restProps.disabled) {
|
|
141
|
-
e.stopPropagation();
|
|
142
|
-
e.preventDefault();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
onClick?.(e);
|
|
146
|
-
};
|
|
147
|
-
if (!children)
|
|
148
|
-
return jsx(Fragment, {});
|
|
149
|
-
const childNodes = [
|
|
150
|
-
loading && jsx(Loading, {}, 'loading'),
|
|
151
|
-
createElement("span", { key: "content", className: "i-btn-content" }, children),
|
|
152
|
-
];
|
|
153
|
-
const attrs = {
|
|
154
|
-
className: formatClass(props),
|
|
155
|
-
["data-ripple"]: ripple && !loading && !restProps.disabled ? "" : undefined,
|
|
156
|
-
onClick: handleClick,
|
|
157
|
-
};
|
|
158
|
-
useEffect(() => {
|
|
159
|
-
ripple && useRipple();
|
|
160
|
-
}, [ripple]);
|
|
161
|
-
if (typeof As === "string") {
|
|
162
|
-
return createElement(As, {
|
|
163
|
-
ref,
|
|
164
|
-
href,
|
|
165
|
-
...attrs,
|
|
166
|
-
...restProps,
|
|
167
|
-
}, childNodes);
|
|
168
|
-
}
|
|
169
|
-
return createElement(As, {
|
|
170
|
-
to: href || "",
|
|
171
|
-
...attrs,
|
|
172
|
-
...restProps,
|
|
173
|
-
}, childNodes);
|
|
174
|
-
};
|
|
175
|
-
Button.Toggle = Toggle;
|
|
176
176
|
Button.Group = Group;
|
|
177
|
+
Button.Toggle = Toggle;
|
|
177
178
|
|
|
178
179
|
const Icon = (props) => {
|
|
179
180
|
const { ref, icon, size = "1.425em", rotate, style, className, ...restProps } = props;
|
|
@@ -762,9 +763,9 @@ function useKeydown(listener, options) {
|
|
|
762
763
|
}, [listener]);
|
|
763
764
|
}
|
|
764
765
|
const defaultObserver = {
|
|
765
|
-
observe:
|
|
766
|
-
unobserve:
|
|
767
|
-
disconnect:
|
|
766
|
+
observe: undefined,
|
|
767
|
+
unobserve: undefined,
|
|
768
|
+
disconnect: undefined,
|
|
768
769
|
};
|
|
769
770
|
function useIntersectionObserver(configs) {
|
|
770
771
|
if (typeof window === "undefined") {
|
|
@@ -1075,16 +1076,17 @@ function Drawer(props) {
|
|
|
1075
1076
|
}
|
|
1076
1077
|
|
|
1077
1078
|
const Item$4 = (props) => {
|
|
1078
|
-
const { ref, active, type, align, disabled, label, style, className, children, ...restProps } = props;
|
|
1079
|
+
const { ref, active, type, align, disabled, label, style, border, className, children, ...restProps } = props;
|
|
1079
1080
|
return (jsxs("li", { ref: ref, className: classNames("i-list-item", className, {
|
|
1080
1081
|
"i-list-item-active": active,
|
|
1081
1082
|
"i-list-option": type === "option",
|
|
1083
|
+
"i-list-item-bordered": border,
|
|
1082
1084
|
disabled,
|
|
1083
1085
|
}), style: { alignItems: align, ...style }, ...restProps, children: [label !== undefined && (jsx("span", { className: 'i-list-item-label', children: label })), children] }));
|
|
1084
1086
|
};
|
|
1085
1087
|
|
|
1086
1088
|
const List$1 = (props) => {
|
|
1087
|
-
const { label, type, className, children, ...restProps } = props;
|
|
1089
|
+
const { label, type, border, className, children, ...restProps } = props;
|
|
1088
1090
|
return (jsx("ul", { className: classNames("i-list", className), ...restProps, children: Children.map(children, (node, i) => {
|
|
1089
1091
|
const renderLabel = typeof label === "function" ? label(i) : label;
|
|
1090
1092
|
const { type, props: nodeProps } = node;
|
|
@@ -1092,7 +1094,8 @@ const List$1 = (props) => {
|
|
|
1092
1094
|
return cloneElement(node, {
|
|
1093
1095
|
label: renderLabel,
|
|
1094
1096
|
...nodeProps,
|
|
1095
|
-
type,
|
|
1097
|
+
type: props.type,
|
|
1098
|
+
border,
|
|
1096
1099
|
});
|
|
1097
1100
|
}
|
|
1098
1101
|
return node;
|
|
@@ -1299,10 +1302,10 @@ function Popup(props) {
|
|
|
1299
1302
|
arrowProps: { left: arrowX, top: arrowY, pos: arrowPos },
|
|
1300
1303
|
});
|
|
1301
1304
|
};
|
|
1305
|
+
const { observe, unobserve, disconnect } = useResizeObserver();
|
|
1302
1306
|
useEffect(() => {
|
|
1303
|
-
if (trigger === "contextmenu")
|
|
1307
|
+
if (trigger === "contextmenu" || !observe)
|
|
1304
1308
|
return;
|
|
1305
|
-
const { observe, unobserve, disconnect } = useResizeObserver();
|
|
1306
1309
|
triggerRef.current && observe(triggerRef.current, computePosition);
|
|
1307
1310
|
if (!watchResize || !contentRef.current)
|
|
1308
1311
|
return;
|
|
@@ -2473,7 +2476,7 @@ const Image = (props) => {
|
|
|
2473
2476
|
if (!ref.current?.complete) {
|
|
2474
2477
|
state.status = "loading";
|
|
2475
2478
|
}
|
|
2476
|
-
if (!lazyload || !ref.current)
|
|
2479
|
+
if (!lazyload || !ref.current || !observe)
|
|
2477
2480
|
return;
|
|
2478
2481
|
observe(ref.current, (tar, visible) => {
|
|
2479
2482
|
if (!visible)
|
|
@@ -2484,7 +2487,7 @@ const Image = (props) => {
|
|
|
2484
2487
|
return () => {
|
|
2485
2488
|
ref.current && unobserve(ref.current);
|
|
2486
2489
|
};
|
|
2487
|
-
}, [src]);
|
|
2490
|
+
}, [src, observe]);
|
|
2488
2491
|
restProps[lazyload ? "data-src" : "src"] = src;
|
|
2489
2492
|
const iSize = state.status === "loading" ? initSize : undefined;
|
|
2490
2493
|
return (jsx("div", { style: {
|
|
@@ -3921,7 +3924,7 @@ const Tabs = ((props) => {
|
|
|
3921
3924
|
state.active = key;
|
|
3922
3925
|
};
|
|
3923
3926
|
useEffect(() => {
|
|
3924
|
-
if (!size || hideMore)
|
|
3927
|
+
if (!size || hideMore || !observe)
|
|
3925
3928
|
return;
|
|
3926
3929
|
const { scrollHeight, scrollWidth } = navsRef.current;
|
|
3927
3930
|
const { width, height } = size;
|
|
@@ -3967,7 +3970,7 @@ const Tabs = ((props) => {
|
|
|
3967
3970
|
open(active);
|
|
3968
3971
|
}, [active]);
|
|
3969
3972
|
useEffect(() => {
|
|
3970
|
-
if (hideMore)
|
|
3973
|
+
if (hideMore || !unobserve)
|
|
3971
3974
|
return;
|
|
3972
3975
|
return () => {
|
|
3973
3976
|
navRefs.current?.map(unobserve);
|
|
@@ -3,8 +3,9 @@ import { HTMLAttributes, ReactNode, RefObject } from 'react';
|
|
|
3
3
|
interface IList extends HTMLAttributes<HTMLUListElement> {
|
|
4
4
|
label?: ReactNode | ((i: number) => ReactNode);
|
|
5
5
|
type?: "option" | "default";
|
|
6
|
+
border?: boolean;
|
|
6
7
|
}
|
|
7
|
-
interface IListItem extends HTMLAttributes<HTMLLIElement>, Pick<IList, "type"> {
|
|
8
|
+
interface IListItem extends HTMLAttributes<HTMLLIElement>, Pick<IList, "type" | "border"> {
|
|
8
9
|
ref?: RefObject<HTMLLIElement | null>;
|
|
9
10
|
active?: boolean;
|
|
10
11
|
align?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ioca/react",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.75",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"rollup-plugin-dts": "^6.1.1",
|
|
45
45
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
46
46
|
"rollup-plugin-scss": "^4.0.0",
|
|
47
|
-
"sass": "^1.
|
|
47
|
+
"sass": "^1.86.0",
|
|
48
48
|
"typescript": "^5.7.2",
|
|
49
49
|
"vite": "^6.0.2",
|
|
50
50
|
"vite-plugin-dynamic-import": "^1.6.0"
|