@cloud-app-dev/vidc 3.2.11 → 3.2.14
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/.dumirc.ts +71 -0
- package/.editorconfig +0 -3
- package/.eslintrc.js +3 -0
- package/.fatherrc.ts +19 -0
- package/.husky/commit-msg +5 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc.js +16 -0
- package/README.md +14 -26
- package/es/Api/index.js +100 -30
- package/es/AppContext/Sync.js +19 -3
- package/es/AppContext/index.js +86 -42
- package/es/AppContext/static.js +7 -0
- package/es/Auth/index.js +11 -4
- package/es/AutoExit/index.js +11 -3
- package/es/Box/BetweenBox/index.js +19 -10
- package/es/Box/BetweenBox/{index.css → index.less} +0 -0
- package/es/Box/InfoBox/index.js +24 -18
- package/es/Box/InfoBox/index.less +22 -0
- package/es/Box/TwoColumnBox/index.js +42 -25
- package/es/Box/TwoColumnBox/index.less +70 -0
- package/es/Box/deps/grid-factory.d.ts +2 -2
- package/es/Box/deps/grid-factory.js +12 -0
- package/es/Box/index.js +29 -16
- package/es/Box/{index.css → index.less} +5 -4
- package/es/CheckGroupFixed/demo.d.ts +3 -0
- package/es/CheckGroupFixed/demo.js +28 -0
- package/es/CheckGroupFixed/index.js +117 -82
- package/es/CheckGroupFixed/index.less +50 -0
- package/es/Config/index.js +5 -1
- package/es/Config/utils.js +18 -3
- package/es/ConfigContext/index.js +8 -4
- package/es/CustomRenderSelect/index.js +71 -36
- package/es/CustomRenderSelect/index.less +25 -0
- package/es/DisableMark/index.js +14 -11
- package/es/DisableMark/{index.css → index.less} +0 -0
- package/es/DomMove/demo.js +14 -10
- package/es/DomMove/index.js +52 -30
- package/es/DomMove/utils.js +8 -3
- package/es/Drag/DragAndDropItem.js +44 -20
- package/es/Drag/DropItem.js +22 -6
- package/es/Drag/index.js +2 -2
- package/es/Drag/{index.css → index.less} +0 -0
- package/es/Drawer/Footer.js +22 -15
- package/es/Drawer/{Demo.d.ts → demo.d.ts} +0 -0
- package/es/Drawer/demo.js +109 -0
- package/es/Drawer/index.js +98 -60
- package/es/Drawer/index.less +42 -0
- package/es/ErrorFallback/index.js +23 -14
- package/es/FrontendPlayer/index.js +1 -1
- package/es/FullScreen/index.js +30 -17
- package/es/FullScreen/index.less +16 -0
- package/es/HightLevel/index.js +11 -4
- package/es/HightLevel/{index.css → index.less} +0 -0
- package/es/IconFont/index.js +39 -18
- package/es/ImageView/index.js +37 -13
- package/es/ImageView/index.less +10 -0
- package/es/Input/demo.d.ts +3 -0
- package/es/Input/demo.js +16 -0
- package/es/Input/index.js +46 -22
- package/es/Input/index.less +12 -0
- package/es/InstanceHistory/index.js +2 -0
- package/es/LabelValue/index.js +25 -18
- package/es/LabelValue/index.less +20 -0
- package/es/List/DynamicGridList/Demo.d.ts +1 -0
- package/es/List/DynamicGridList/Demo.js +52 -32
- package/es/List/DynamicGridList/index.d.ts +3 -3
- package/es/List/DynamicGridList/index.js +41 -26
- package/es/List/DynamicList/index.js +76 -56
- package/es/List/DynamicList/index.less +15 -0
- package/es/List/GridList/Demo.d.ts +1 -0
- package/es/List/GridList/Demo.js +60 -38
- package/es/List/GridList/hook.d.ts +1 -1
- package/es/List/GridList/hook.js +66 -35
- package/es/List/GridList/index.js +33 -29
- package/es/List/GridList/{index.css → index.less} +0 -0
- package/es/List/GridList/utils.d.ts +2 -2
- package/es/List/GridList/utils.js +1 -0
- package/es/List/VList/index.d.ts +1 -1
- package/es/List/VList/index.js +32 -19
- package/es/List/VList/{index.css → index.less} +0 -0
- package/es/List/VList/utils.d.ts +2 -2
- package/es/List/VList/utils.js +8 -6
- package/es/List/demo.d.ts +3 -0
- package/es/List/demo.js +26 -0
- package/es/List/index.d.ts +1 -1
- package/es/List/index.js +31 -23
- package/es/List/{index.css → index.less} +5 -4
- package/es/ListWithSizeAnimate/demo.d.ts +2 -0
- package/es/ListWithSizeAnimate/demo.js +19 -0
- package/es/ListWithSizeAnimate/index.d.ts +9 -0
- package/es/ListWithSizeAnimate/index.js +71 -0
- package/es/ListWithSizeAnimate/index.less +13 -0
- package/es/LoaderApp/index.js +59 -25
- package/es/LoaderApp/{index.css → index.less} +0 -0
- package/es/LoaderApp/loader.js +40 -23
- package/es/LoaderApp/sandbox.back.js +101 -24
- package/es/LoaderApp/sandbox.js +26 -9
- package/es/LoaderApp/utils.d.ts +1 -1
- package/es/LoaderApp/utils.js +68 -25
- package/es/LoaderScript/index.js +25 -10
- package/es/LoaderScript/utils.js +151 -87
- package/es/Map/BasicMap/AMapInstance.d.ts +1 -1
- package/es/Map/BasicMap/AMapInstance.js +25 -3
- package/es/Map/BasicMap/LeafletInstance.js +28 -11
- package/es/Map/BasicMap/index.js +67 -27
- package/es/Map/BasicMap/index.less +24 -0
- package/es/Map/ClusterLayer/hook.d.ts +2 -2
- package/es/Map/ClusterLayer/hook.js +51 -23
- package/es/Map/ClusterLayer/index.d.ts +1 -1
- package/es/Map/ClusterLayer/index.js +14 -6
- package/es/Map/ClusterLayer/index.less +27 -0
- package/es/Map/Config/index.js +44 -16
- package/es/Map/Config/utils.js +17 -3
- package/es/Map/Context/index.js +43 -9
- package/es/Map/FindPio/index.js +5 -2
- package/es/Map/FindPio/{index.css → index.less} +0 -0
- package/es/Map/InfoWindow/MakerLikeWindow.d.ts +1 -1
- package/es/Map/InfoWindow/MakerLikeWindow.js +41 -18
- package/es/Map/InfoWindow/demo.d.ts +1 -0
- package/es/Map/InfoWindow/demo.js +51 -29
- package/es/Map/InfoWindow/index.d.ts +1 -1
- package/es/Map/InfoWindow/index.js +39 -18
- package/es/Map/LevelCenter/DragMarker/index.js +16 -10
- package/es/Map/LevelCenter/demo.d.ts +1 -0
- package/es/Map/LevelCenter/demo.js +41 -22
- package/es/Map/LevelCenter/index.js +41 -29
- package/es/Map/LevelCenter/index.less +2 -0
- package/es/Map/LoaderMap/index.js +38 -22
- package/es/Map/MapDrawSelect/demo.d.ts +1 -0
- package/es/Map/MapDrawSelect/demo.js +65 -46
- package/es/Map/MapDrawSelect/index.js +43 -31
- package/es/Map/MapDrawSelect/index.less +2 -0
- package/es/Map/MouseTool/index.js +32 -18
- package/es/Map/MouseTool/useMouseTools.js +37 -8
- package/es/Map/ResetTools/index.js +58 -44
- package/es/Map/ResetTools/index.less +35 -0
- package/es/Map/SinglePoint/index.js +39 -27
- package/es/Map/SinglePoint/index.less +41 -0
- package/es/Map/hook/useMapEvent.js +8 -4
- package/es/Map/hook/useMapType.js +3 -2
- package/es/Map/index.d.ts +1 -0
- package/es/Map/index.js +11 -11
- package/es/Map/useMarker/index.d.ts +1 -1
- package/es/Map/useMarker/index.js +33 -13
- package/es/Map/{LevelCenter/index.css → useMarker/index.less} +0 -0
- package/es/Map/withMap/index.d.ts +1 -0
- package/es/Map/withMap/index.js +14 -4
- package/es/Modal/demo.d.ts +3 -0
- package/es/Modal/demo.js +106 -0
- package/es/Modal/index.js +94 -57
- package/es/Modal/index.less +45 -0
- package/es/Picture/component/DefaultRects/RectInfo.js +59 -37
- package/es/Picture/component/DefaultRects/index.js +46 -32
- package/es/Picture/component/DefaultRects/index.less +188 -0
- package/es/Picture/component/DrawRect/index.js +37 -24
- package/es/Picture/component/DrawRect/{index.css → index.less} +0 -0
- package/es/Picture/component/RectMenu/index.js +35 -26
- package/es/Picture/component/RectMenu/index.less +31 -0
- package/es/Picture/component/RectMenu/utils.js +6 -3
- package/es/Picture/component/Tools/index.js +91 -69
- package/es/Picture/component/Tools/index.less +43 -0
- package/es/Picture/component/WheelScale/index.js +9 -4
- package/es/Picture/demo.js +14 -11
- package/es/Picture/dragBound.d.ts +1 -1
- package/es/Picture/dragBound.js +17 -4
- package/es/Picture/index.d.ts +2 -2
- package/es/Picture/index.js +201 -137
- package/es/Picture/index.less +14 -0
- package/es/Picture/interface.d.ts +0 -6
- package/es/Picture/loadCaptureRectImage.d.ts +1 -1
- package/es/Picture/loadCaptureRectImage.js +39 -14
- package/es/Picture/useDraw.js +40 -20
- package/es/Picture/utils.d.ts +9 -9
- package/es/Picture/utils.js +18 -3
- package/es/Player/api/index.d.ts +3 -3
- package/es/Player/api/index.js +117 -82
- package/es/Player/context.js +21 -7
- package/es/Player/contraller_bar/bar.d.ts +1 -1
- package/es/Player/contraller_bar/bar.js +28 -10
- package/es/Player/contraller_bar/contraller_event.js +34 -12
- package/es/Player/contraller_bar/index.js +30 -22
- package/es/Player/contraller_bar/left_bar.js +62 -39
- package/es/Player/contraller_bar/right_bar.js +34 -18
- package/es/Player/contraller_bar/time.js +19 -8
- package/es/Player/contraller_bar/useBarStatus.js +29 -11
- package/es/Player/contraller_bar/volume.d.ts +1 -1
- package/es/Player/contraller_bar/volume.js +43 -21
- package/es/Player/demo.d.ts +1 -0
- package/es/Player/demo.js +258 -215
- package/es/Player/event/errorEvent.js +41 -16
- package/es/Player/event/eventName.js +12 -1
- package/es/Player/event/index.js +66 -24
- package/es/Player/fps_play.js +33 -15
- package/es/Player/frontend_player.js +42 -20
- package/es/Player/frontend_timeline.js +95 -55
- package/es/Player/iconfont.js +23 -8
- package/es/Player/index.js +1 -1
- package/es/Player/live_heart.js +15 -3
- package/es/Player/message.js +68 -37
- package/es/Player/segment_player.js +113 -62
- package/es/Player/segment_timeline.js +145 -97
- package/es/Player/single_player.js +153 -111
- package/es/Player/style/bar.less +39 -0
- package/es/Player/style/iconfont.js +17 -10
- package/es/Player/style/index.less +30 -0
- package/es/Player/style/message.less +50 -0
- package/es/Player/style/slider.less +103 -0
- package/es/Player/style/timeline.less +106 -0
- package/es/Player/style/volume.less +21 -0
- package/es/Player/timeline.d.ts +1 -1
- package/es/Player/timeline.js +59 -32
- package/es/Player/util.js +46 -7
- package/es/PlayerExt/demo.d.ts +1 -0
- package/es/PlayerExt/demo.js +145 -112
- package/es/PlayerExt/index.d.ts +2 -2
- package/es/PlayerExt/index.js +139 -87
- package/es/PlayerExt/{index.css → index.less} +0 -0
- package/es/Progress/index.js +18 -5
- package/es/Progress/index.less +20 -0
- package/es/ROI/demo.d.ts +1 -0
- package/es/ROI/demo.js +12 -8
- package/es/ROI/index.js +45 -35
- package/es/ROI/index.less +29 -0
- package/es/ScreenPlayer/Live.d.ts +2 -2
- package/es/ScreenPlayer/Live.js +172 -109
- package/es/ScreenPlayer/LiveTools.d.ts +2 -2
- package/es/ScreenPlayer/LiveTools.js +156 -116
- package/es/ScreenPlayer/PlayerWithExt.d.ts +2 -2
- package/es/ScreenPlayer/PlayerWithExt.js +172 -115
- package/es/ScreenPlayer/RatePick.js +35 -22
- package/es/ScreenPlayer/Record.d.ts +1 -1
- package/es/ScreenPlayer/Record.js +307 -192
- package/es/ScreenPlayer/RecordTools.d.ts +2 -2
- package/es/ScreenPlayer/RecordTools.js +201 -149
- package/es/ScreenPlayer/ScreenSelect.js +37 -28
- package/es/ScreenPlayer/SegmentTimeLine.d.ts +1 -1
- package/es/ScreenPlayer/SegmentTimeLine.js +24 -17
- package/es/ScreenPlayer/TimeMode.js +22 -16
- package/es/ScreenPlayer/TimeSelect.js +86 -65
- package/es/ScreenPlayer/demo.js +16 -18
- package/es/ScreenPlayer/demo2.js +193 -178
- package/es/ScreenPlayer/index.d.ts +1 -0
- package/es/ScreenPlayer/index.js +3 -3
- package/es/ScreenPlayer/index.less +178 -0
- package/es/ScreenPlayer/interface.d.ts +2 -2
- package/es/ScreenPlayer/useTimeSlider.d.ts +8 -8
- package/es/ScreenPlayer/useTimeSlider.js +167 -60
- package/es/ScreenPlayer/useVideoFit.d.ts +1 -1
- package/es/ScreenPlayer/useVideoFit.js +18 -5
- package/es/ScreenPlayer/utils.d.ts +1 -1
- package/es/ScreenPlayer/utils.js +10 -1
- package/es/SegmentPlayer/index.js +1 -1
- package/es/Service/fetch-adapter.d.ts +1 -1
- package/es/Service/fetch-adapter.js +48 -5
- package/es/Service/http.js +46 -16
- package/es/Service/index.js +2 -2
- package/es/TableLayout/index.js +18 -12
- package/es/TableLayout/{index.css → index.less} +0 -0
- package/es/ThemeAntd/demo.d.ts +1 -0
- package/es/ThemeAntd/demo.js +126 -76
- package/es/ThemeAntd/{demo.css → demo.less} +4 -3
- package/es/ThemeAntd/index.js +6 -2
- package/es/ThemeAntd/index.less +16 -0
- package/es/ThemeAntd/style/button.less +67 -0
- package/es/ThemeAntd/style/checkbox.less +72 -0
- package/es/ThemeAntd/style/form.less +12 -0
- package/es/ThemeAntd/style/input.less +83 -0
- package/es/ThemeAntd/style/pagination.less +95 -0
- package/es/ThemeAntd/style/picker.less +106 -0
- package/es/ThemeAntd/style/popover.less +5 -0
- package/es/ThemeAntd/style/radio.less +87 -0
- package/es/ThemeAntd/style/{scrollbar.css → scrollbar.less} +4 -2
- package/es/ThemeAntd/style/select.less +81 -0
- package/es/ThemeAntd/style/table.less +57 -0
- package/es/ThemeAntd/style/tree.less +18 -0
- package/es/Timeout/index.js +36 -12
- package/es/Tree/demo.js +26 -21
- package/es/Tree/index.js +51 -30
- package/es/Tree/index.less +59 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +48 -47
- package/es/useDrawROI/index.js +130 -65
- package/es/useEventEmitterHandle/index.js +6 -2
- package/es/useFullscreen/demo.js +44 -27
- package/es/useFullscreen/index.js +30 -8
- package/es/useHistory/index.js +3 -1
- package/es/useInfiniteScroll/index.js +50 -19
- package/es/useRafInterval/index.js +28 -4
- package/es/useSimpleState/index.js +23 -6
- package/es/useVirtualList/index.js +58 -20
- package/es/utils.d.ts +1 -1
- package/es/utils.js +53 -14
- package/package.json +37 -32
- package/tsconfig.json +8 -32
- package/.eslintrc +0 -4
- package/.fatherrc.js +0 -25
- package/.prettierrc +0 -11
- package/.umirc.ts +0 -55
- package/clear-cache.sh +0 -4
- package/es/Box/InfoBox/index.css +0 -22
- package/es/Box/TwoColumnBox/index.css +0 -70
- package/es/CheckGroupFixed/index.css +0 -49
- package/es/CustomRenderSelect/index.css +0 -20
- package/es/Drawer/Demo.js +0 -59
- package/es/Drawer/index.css +0 -40
- package/es/FullScreen/index.css +0 -16
- package/es/ImageView/index.css +0 -10
- package/es/Input/index.css +0 -8
- package/es/LabelValue/index.css +0 -18
- package/es/List/DynamicList/index.css +0 -15
- package/es/Map/BasicMap/index.css +0 -24
- package/es/Map/ClusterLayer/index.css +0 -26
- package/es/Map/MapDrawSelect/index.css +0 -0
- package/es/Map/ResetTools/index.css +0 -32
- package/es/Map/SinglePoint/icon/Place_icon_OnLine_Hover.svg +0 -15
- package/es/Map/SinglePoint/icon/Place_icon_OnLine_Normal.svg +0 -15
- package/es/Map/SinglePoint/icon/Place_icon_OutLine_Hover.svg +0 -15
- package/es/Map/SinglePoint/icon/Place_icon_OutLine_Normal.svg +0 -15
- package/es/Map/SinglePoint/index.css +0 -29
- package/es/Map/useMarker/index.css +0 -0
- package/es/Modal/index.css +0 -43
- package/es/Picture/component/DefaultRects/index.css +0 -247
- package/es/Picture/component/RectMenu/index.css +0 -31
- package/es/Picture/component/Tools/index.css +0 -42
- package/es/Picture/index.css +0 -12
- package/es/Player/style/bar.css +0 -38
- package/es/Player/style/index.css +0 -30
- package/es/Player/style/message.css +0 -49
- package/es/Player/style/slider.css +0 -96
- package/es/Player/style/timeline.css +0 -99
- package/es/Player/style/volume.css +0 -19
- package/es/Progress/index.css +0 -20
- package/es/ROI/index.css +0 -29
- package/es/ScreenPlayer/index.css +0 -166
- package/es/ThemeAntd/index.css +0 -620
- package/es/ThemeAntd/style/button.css +0 -55
- package/es/ThemeAntd/style/checkbox.css +0 -64
- package/es/ThemeAntd/style/form.css +0 -10
- package/es/ThemeAntd/style/input.css +0 -68
- package/es/ThemeAntd/style/pagination.css +0 -82
- package/es/ThemeAntd/style/picker.css +0 -98
- package/es/ThemeAntd/style/popover.css +0 -3
- package/es/ThemeAntd/style/radio.css +0 -80
- package/es/ThemeAntd/style/select.css +0 -76
- package/es/ThemeAntd/style/table.css +0 -46
- package/es/ThemeAntd/style/tree.css +0 -16
- package/es/Tree/index.css +0 -64
package/es/useDrawROI/index.js
CHANGED
|
@@ -3,55 +3,82 @@ import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
|
3
3
|
import _usePrevious from "ahooks/es/usePrevious";
|
|
4
4
|
import _useSize from "ahooks/es/useSize";
|
|
5
5
|
import _useLatest from "ahooks/es/useLatest";
|
|
6
|
+
|
|
6
7
|
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
8
|
+
|
|
7
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
|
+
|
|
8
11
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
|
|
9
13
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
+
|
|
10
15
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
+
|
|
21
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
+
|
|
11
23
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
24
|
+
|
|
12
25
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
26
|
+
|
|
13
27
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
28
|
+
|
|
14
29
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
30
|
+
|
|
15
31
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
32
|
+
|
|
16
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
|
+
|
|
17
35
|
import { getTargetElement } from 'ahooks/lib/utils/domTarget';
|
|
18
36
|
import { useEffect, useMemo } from 'react';
|
|
19
37
|
import { lineString } from '@turf/helpers';
|
|
20
38
|
import lineToPolygon from '@turf/line-to-polygon';
|
|
21
39
|
import booleanDisjoint from '@turf/boolean-disjoint';
|
|
22
40
|
import { useHotkeys } from 'react-hotkeys-hook';
|
|
23
|
-
import useSimpleState from
|
|
41
|
+
import useSimpleState from "../useSimpleState";
|
|
42
|
+
|
|
24
43
|
function useDrawROI(target, _ref) {
|
|
25
44
|
var row = _ref.row,
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
rowItems = _ref.rowItems,
|
|
46
|
+
defaultAreas = _ref.defaultAreas;
|
|
47
|
+
|
|
28
48
|
var _useSimpleState = useSimpleState({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
pos: [],
|
|
50
|
+
tempPos: [],
|
|
51
|
+
saveArea: defaultAreas !== null && defaultAreas !== void 0 ? defaultAreas : [],
|
|
52
|
+
isOpen: false
|
|
53
|
+
}),
|
|
54
|
+
_useSimpleState2 = _slicedToArray(_useSimpleState, 3),
|
|
55
|
+
state = _useSimpleState2[0],
|
|
56
|
+
updateState = _useSimpleState2[1],
|
|
57
|
+
setState = _useSimpleState2[2];
|
|
58
|
+
|
|
38
59
|
var isOpenRef = _useLatest(state.isOpen);
|
|
60
|
+
|
|
39
61
|
var size = _useSize(target);
|
|
62
|
+
|
|
40
63
|
var oldSize = _usePrevious(size);
|
|
64
|
+
|
|
41
65
|
useEffect(function () {
|
|
42
|
-
if (!(size
|
|
66
|
+
if (!(size !== null && size !== void 0 && size.width)) {
|
|
43
67
|
return;
|
|
44
68
|
}
|
|
69
|
+
|
|
45
70
|
var canvas = getTargetElement(target);
|
|
46
71
|
canvas.width = size === null || size === void 0 ? void 0 : size.width;
|
|
47
72
|
canvas.height = size === null || size === void 0 ? void 0 : size.height;
|
|
48
73
|
console.warn('canvas,size变化!');
|
|
49
|
-
|
|
74
|
+
|
|
75
|
+
if (!(oldSize !== null && oldSize !== void 0 && oldSize.width)) {
|
|
50
76
|
return;
|
|
51
77
|
}
|
|
78
|
+
|
|
52
79
|
var scale = size.width / oldSize.width;
|
|
53
80
|
setState(function (old) {
|
|
54
|
-
return
|
|
81
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
55
82
|
pos: [],
|
|
56
83
|
tempPos: [],
|
|
57
84
|
saveArea: old.saveArea.map(function (area) {
|
|
@@ -60,9 +87,9 @@ function useDrawROI(target, _ref) {
|
|
|
60
87
|
});
|
|
61
88
|
})
|
|
62
89
|
});
|
|
63
|
-
});
|
|
64
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
91
|
}, [size === null || size === void 0 ? void 0 : size.height, size === null || size === void 0 ? void 0 : size.width]);
|
|
92
|
+
|
|
66
93
|
_useUpdateEffect(function () {
|
|
67
94
|
if (state.saveArea.length === 0 && defaultAreas.length > 0) {
|
|
68
95
|
updateState({
|
|
@@ -70,30 +97,35 @@ function useDrawROI(target, _ref) {
|
|
|
70
97
|
});
|
|
71
98
|
}
|
|
72
99
|
}, [defaultAreas, state.saveArea]);
|
|
100
|
+
|
|
73
101
|
_useEventListener('click', function (event) {
|
|
74
102
|
if (!isOpenRef.current) {
|
|
75
103
|
return;
|
|
76
104
|
}
|
|
105
|
+
|
|
77
106
|
var p_x = event.offsetX;
|
|
78
107
|
var p_y = event.offsetY;
|
|
79
108
|
setState(function (old) {
|
|
80
|
-
var pos = old.pos;
|
|
81
|
-
|
|
109
|
+
var pos = old.pos; // 去掉重复点位,dbclick导致重复触发
|
|
110
|
+
|
|
82
111
|
if (!pos.find(function (_ref2) {
|
|
83
112
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
84
|
-
|
|
85
|
-
|
|
113
|
+
x = _ref3[0],
|
|
114
|
+
y = _ref3[1];
|
|
115
|
+
|
|
86
116
|
return x === p_x && y === p_y;
|
|
87
117
|
})) {
|
|
88
118
|
pos = [].concat(_toConsumableArray(pos), [[p_x, p_y]]);
|
|
89
119
|
}
|
|
90
|
-
|
|
120
|
+
|
|
121
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
91
122
|
pos: pos
|
|
92
123
|
});
|
|
93
124
|
});
|
|
94
125
|
}, {
|
|
95
126
|
target: target
|
|
96
127
|
});
|
|
128
|
+
|
|
97
129
|
_useEventListener('dblclick', function (event) {
|
|
98
130
|
var p_x = event.offsetX;
|
|
99
131
|
var p_y = event.offsetY;
|
|
@@ -101,21 +133,25 @@ function useDrawROI(target, _ref) {
|
|
|
101
133
|
var saveArea = old.saveArea;
|
|
102
134
|
var pos = old.pos;
|
|
103
135
|
var tempPos = old.tempPos;
|
|
136
|
+
|
|
104
137
|
if (pos.length > 2) {
|
|
105
138
|
// 去掉重复点位
|
|
106
139
|
if (!pos.find(function (_ref4) {
|
|
107
140
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
108
|
-
|
|
109
|
-
|
|
141
|
+
x = _ref5[0],
|
|
142
|
+
y = _ref5[1];
|
|
143
|
+
|
|
110
144
|
return x === p_x && y === p_y;
|
|
111
145
|
})) {
|
|
112
146
|
pos = [].concat(_toConsumableArray(pos), [[p_x, p_y]]);
|
|
113
147
|
}
|
|
148
|
+
|
|
114
149
|
saveArea = [].concat(_toConsumableArray(saveArea), [pos]);
|
|
115
150
|
pos = [];
|
|
116
151
|
tempPos = [];
|
|
117
152
|
}
|
|
118
|
-
|
|
153
|
+
|
|
154
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
119
155
|
pos: pos,
|
|
120
156
|
saveArea: saveArea,
|
|
121
157
|
tempPos: tempPos
|
|
@@ -124,41 +160,47 @@ function useDrawROI(target, _ref) {
|
|
|
124
160
|
}, {
|
|
125
161
|
target: target
|
|
126
162
|
});
|
|
163
|
+
|
|
127
164
|
_useEventListener('mousemove', function (event) {
|
|
128
165
|
if (!isOpenRef.current || state.pos.length === 0) {
|
|
129
166
|
return;
|
|
130
167
|
}
|
|
168
|
+
|
|
131
169
|
var p_x = event.offsetX;
|
|
132
170
|
var p_y = event.offsetY;
|
|
133
171
|
setState(function (old) {
|
|
134
|
-
return
|
|
172
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
135
173
|
tempPos: [p_x, p_y]
|
|
136
174
|
});
|
|
137
175
|
});
|
|
138
176
|
}, {
|
|
139
177
|
target: target
|
|
140
178
|
});
|
|
179
|
+
|
|
141
180
|
var clearCanvas = function clearCanvas() {
|
|
142
181
|
var canvas = getTargetElement(target);
|
|
143
|
-
var ctx = canvas.getContext('2d');
|
|
144
|
-
|
|
182
|
+
var ctx = canvas.getContext('2d'); // 重置画布
|
|
183
|
+
|
|
145
184
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
146
185
|
};
|
|
186
|
+
|
|
147
187
|
var drawSavaArea = function drawSavaArea(area) {
|
|
148
188
|
var canvas = getTargetElement(target);
|
|
149
|
-
var ctx = canvas.getContext('2d');
|
|
150
|
-
|
|
189
|
+
var ctx = canvas.getContext('2d'); // 绘制已完成的图形
|
|
190
|
+
|
|
151
191
|
area.forEach(function (item) {
|
|
152
192
|
// 绘制坐标线
|
|
153
193
|
var _item = _toArray(item),
|
|
154
|
-
|
|
155
|
-
|
|
194
|
+
startPos = _item[0],
|
|
195
|
+
pos = _item.slice(1);
|
|
196
|
+
|
|
156
197
|
ctx.beginPath();
|
|
157
198
|
ctx.moveTo.apply(ctx, _toConsumableArray(startPos));
|
|
158
199
|
pos.forEach(function (_ref6) {
|
|
159
200
|
var _ref7 = _slicedToArray(_ref6, 2),
|
|
160
|
-
|
|
161
|
-
|
|
201
|
+
x = _ref7[0],
|
|
202
|
+
y = _ref7[1];
|
|
203
|
+
|
|
162
204
|
return ctx.lineTo(x, y);
|
|
163
205
|
});
|
|
164
206
|
ctx.lineTo.apply(ctx, _toConsumableArray(startPos));
|
|
@@ -169,84 +211,96 @@ function useDrawROI(target, _ref) {
|
|
|
169
211
|
ctx.stroke();
|
|
170
212
|
});
|
|
171
213
|
};
|
|
214
|
+
|
|
172
215
|
var canvasRendering = function canvasRendering(points, tempPos) {
|
|
173
216
|
if (points.length === 0) {
|
|
174
217
|
return;
|
|
175
218
|
}
|
|
219
|
+
|
|
176
220
|
var canvas = getTargetElement(target);
|
|
177
|
-
var ctx = canvas.getContext('2d');
|
|
178
|
-
|
|
221
|
+
var ctx = canvas.getContext('2d'); // 绘制坐标点
|
|
222
|
+
|
|
179
223
|
points.forEach(function (_ref8) {
|
|
180
224
|
var _ref9 = _slicedToArray(_ref8, 2),
|
|
181
|
-
|
|
182
|
-
|
|
225
|
+
x = _ref9[0],
|
|
226
|
+
y = _ref9[1];
|
|
227
|
+
|
|
183
228
|
ctx.beginPath();
|
|
184
229
|
ctx.arc(x, y, 4, 0, 2 * Math.PI);
|
|
185
230
|
ctx.fillStyle = 'red';
|
|
186
231
|
ctx.fill();
|
|
187
|
-
});
|
|
188
|
-
|
|
232
|
+
}); // 绘制坐标线
|
|
233
|
+
|
|
189
234
|
var _points = _toArray(points),
|
|
190
|
-
|
|
191
|
-
|
|
235
|
+
startPos = _points[0],
|
|
236
|
+
pos = _points.slice(1);
|
|
237
|
+
|
|
192
238
|
ctx.beginPath();
|
|
193
239
|
ctx.moveTo.apply(ctx, _toConsumableArray(startPos));
|
|
194
240
|
pos.forEach(function (_ref10) {
|
|
195
241
|
var _ref11 = _slicedToArray(_ref10, 2),
|
|
196
|
-
|
|
197
|
-
|
|
242
|
+
x = _ref11[0],
|
|
243
|
+
y = _ref11[1];
|
|
244
|
+
|
|
198
245
|
return ctx.lineTo(x, y);
|
|
199
246
|
});
|
|
247
|
+
|
|
200
248
|
var _tempPos = _slicedToArray(tempPos, 2),
|
|
201
|
-
|
|
202
|
-
|
|
249
|
+
x = _tempPos[0],
|
|
250
|
+
y = _tempPos[1];
|
|
251
|
+
|
|
203
252
|
if (typeof x === 'number' && typeof y === 'number') {
|
|
204
253
|
ctx.lineTo(x, y);
|
|
205
254
|
}
|
|
255
|
+
|
|
206
256
|
ctx.lineTo.apply(ctx, _toConsumableArray(startPos));
|
|
207
257
|
ctx.strokeStyle = '#f32d37';
|
|
208
258
|
ctx.lineWidth = 2;
|
|
209
259
|
ctx.fillStyle = 'rgba(243,45,55,0.5)';
|
|
210
260
|
ctx.fill();
|
|
211
261
|
ctx.stroke();
|
|
212
|
-
};
|
|
213
|
-
|
|
262
|
+
}; //绘制hook
|
|
263
|
+
|
|
264
|
+
|
|
214
265
|
useEffect(function () {
|
|
215
266
|
clearCanvas();
|
|
216
267
|
drawSavaArea(state.saveArea);
|
|
217
|
-
canvasRendering(state.pos, state.tempPos);
|
|
218
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
268
|
+
canvasRendering(state.pos, state.tempPos); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
219
269
|
}, [state.pos, state.saveArea, state.tempPos]);
|
|
220
270
|
var status = useMemo(function () {
|
|
221
271
|
return state.isOpen ? 'open' : 'close';
|
|
222
272
|
}, [state.isOpen]);
|
|
273
|
+
|
|
223
274
|
var open = function open() {
|
|
224
275
|
return setState(function (old) {
|
|
225
|
-
return
|
|
276
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
226
277
|
isOpen: true
|
|
227
278
|
});
|
|
228
279
|
});
|
|
229
280
|
};
|
|
281
|
+
|
|
230
282
|
var close = function close() {
|
|
231
283
|
return setState(function (old) {
|
|
232
|
-
return
|
|
284
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
233
285
|
isOpen: false
|
|
234
286
|
});
|
|
235
287
|
});
|
|
236
288
|
};
|
|
289
|
+
|
|
237
290
|
var clear = function clear() {
|
|
238
291
|
return setState(function (old) {
|
|
239
|
-
return
|
|
292
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
240
293
|
pos: [],
|
|
241
294
|
saveArea: [],
|
|
242
295
|
tempPos: []
|
|
243
296
|
});
|
|
244
297
|
});
|
|
245
|
-
};
|
|
246
|
-
|
|
298
|
+
}; //快捷键处理
|
|
299
|
+
|
|
300
|
+
|
|
247
301
|
useHotkeys('esc', function () {
|
|
248
302
|
return setState(function (old) {
|
|
249
|
-
return
|
|
303
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
250
304
|
pos: [],
|
|
251
305
|
tempPos: []
|
|
252
306
|
});
|
|
@@ -255,49 +309,59 @@ function useDrawROI(target, _ref) {
|
|
|
255
309
|
var rio = useMemo(function () {
|
|
256
310
|
var rioArr = [];
|
|
257
311
|
var canvas = getTargetElement(target);
|
|
312
|
+
|
|
258
313
|
if (!canvas) {
|
|
259
314
|
rioArr = new Array(row).fill(new Array(rowItems).fill(0));
|
|
260
315
|
return rioArr;
|
|
261
316
|
}
|
|
317
|
+
|
|
262
318
|
var _canvas$getBoundingCl = canvas.getBoundingClientRect(),
|
|
263
|
-
|
|
264
|
-
|
|
319
|
+
width = _canvas$getBoundingCl.width,
|
|
320
|
+
height = _canvas$getBoundingCl.height;
|
|
321
|
+
|
|
265
322
|
var itemWidth = width / rowItems;
|
|
266
|
-
var itemHeight = height / row;
|
|
267
|
-
|
|
323
|
+
var itemHeight = height / row; // 转换当前绘制完成的区域为多边形
|
|
324
|
+
|
|
268
325
|
var areas = state.saveArea.map(function (item) {
|
|
269
326
|
return lineToPolygon(lineString(item));
|
|
270
327
|
});
|
|
328
|
+
|
|
271
329
|
for (var i = 0; i < row; i++) {
|
|
272
330
|
var arr = [];
|
|
331
|
+
|
|
273
332
|
var _loop = function _loop(k) {
|
|
274
333
|
// x表示当地的纬度,y表示当地的经度
|
|
275
|
-
var lines = lineString([[k * itemWidth, i * itemHeight], [(k + 1) * itemWidth, i * itemHeight], [(k + 1) * itemWidth, (i + 1) * itemHeight], [k * itemWidth, (i + 1) * itemHeight], [k * itemWidth, i * itemHeight]]);
|
|
276
|
-
|
|
277
|
-
var rect = lineToPolygon(lines);
|
|
278
|
-
|
|
334
|
+
var lines = lineString([[k * itemWidth, i * itemHeight], [(k + 1) * itemWidth, i * itemHeight], [(k + 1) * itemWidth, (i + 1) * itemHeight], [k * itemWidth, (i + 1) * itemHeight], [k * itemWidth, i * itemHeight]]); // 转换每格为多边形
|
|
335
|
+
|
|
336
|
+
var rect = lineToPolygon(lines); //标记当前rect 是否与绘制的图形相交
|
|
337
|
+
|
|
279
338
|
var flag = areas.findIndex(function (area) {
|
|
280
339
|
return !booleanDisjoint(rect, area);
|
|
281
340
|
}) > -1;
|
|
282
341
|
arr.push(flag ? 1 : 0);
|
|
283
342
|
};
|
|
343
|
+
|
|
284
344
|
for (var k = 0; k < rowItems; k++) {
|
|
285
345
|
_loop(k);
|
|
286
346
|
}
|
|
347
|
+
|
|
287
348
|
rioArr.push(arr);
|
|
288
349
|
}
|
|
350
|
+
|
|
289
351
|
return rioArr;
|
|
290
352
|
}, [row, rowItems, state.saveArea, target]);
|
|
353
|
+
|
|
291
354
|
var deleteArea = function deleteArea(area) {
|
|
292
355
|
setState(function (old) {
|
|
293
356
|
var newArea = old.saveArea.filter(function (v) {
|
|
294
357
|
return v.join('-') !== area.join('-');
|
|
295
358
|
});
|
|
296
|
-
return
|
|
359
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
297
360
|
saveArea: _toConsumableArray(newArea)
|
|
298
361
|
});
|
|
299
362
|
});
|
|
300
363
|
};
|
|
364
|
+
|
|
301
365
|
return {
|
|
302
366
|
open: open,
|
|
303
367
|
close: close,
|
|
@@ -308,4 +372,5 @@ function useDrawROI(target, _ref) {
|
|
|
308
372
|
deleteArea: deleteArea
|
|
309
373
|
};
|
|
310
374
|
}
|
|
375
|
+
|
|
311
376
|
export default useDrawROI;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import _SocketEmitter from "@cloud-app-dev/utils/es/SocketEmitter";
|
|
2
2
|
import _useLatest from "ahooks/es/useLatest";
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
|
+
|
|
4
5
|
function useEventEmitterHandle(eventName, handle) {
|
|
5
6
|
var handlerRef = _useLatest(handle);
|
|
7
|
+
|
|
6
8
|
useEffect(function () {
|
|
7
9
|
var eventListener = function eventListener(event) {
|
|
8
10
|
return handlerRef.current(event);
|
|
9
11
|
};
|
|
12
|
+
|
|
10
13
|
_SocketEmitter.on(eventName, eventListener);
|
|
14
|
+
|
|
11
15
|
return function () {
|
|
12
16
|
return _SocketEmitter.off(eventName, eventListener);
|
|
13
|
-
};
|
|
14
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
18
|
}, [eventName]);
|
|
16
19
|
}
|
|
20
|
+
|
|
17
21
|
export default useEventEmitterHandle;
|
package/es/useFullscreen/demo.js
CHANGED
|
@@ -1,41 +1,58 @@
|
|
|
1
1
|
import _useFullscreen3 from "ahooks/es/useFullscreen";
|
|
2
|
+
|
|
2
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
|
|
3
5
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
|
|
4
7
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
|
|
5
9
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
+
|
|
6
11
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
+
|
|
7
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
|
|
8
15
|
import React, { useRef } from 'react';
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
18
|
export default function App() {
|
|
10
19
|
var ref1 = useRef();
|
|
11
20
|
var ref2 = useRef();
|
|
21
|
+
|
|
12
22
|
var _useFullscreen = _useFullscreen3(ref1),
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
24
|
+
fullscreen1 = _useFullscreen2[0],
|
|
25
|
+
options1 = _useFullscreen2[1];
|
|
26
|
+
|
|
16
27
|
var _useFullscreen4 = _useFullscreen3(ref2),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
_useFullscreen5 = _slicedToArray(_useFullscreen4, 2),
|
|
29
|
+
fullscreen2 = _useFullscreen5[0],
|
|
30
|
+
options2 = _useFullscreen5[1];
|
|
31
|
+
|
|
32
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
33
|
+
className: "App",
|
|
34
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
35
|
+
style: {
|
|
36
|
+
width: 400,
|
|
37
|
+
height: 400,
|
|
38
|
+
background: 'blue'
|
|
39
|
+
},
|
|
40
|
+
ref: ref1,
|
|
41
|
+
children: [/*#__PURE__*/_jsxs("button", {
|
|
42
|
+
onClick: options1.toggleFullscreen,
|
|
43
|
+
children: ["\u7236\u5143\u7D20", fullscreen1 ? '退出全屏' : '全屏']
|
|
44
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
45
|
+
style: {
|
|
46
|
+
width: 200,
|
|
47
|
+
height: 200,
|
|
48
|
+
background: 'red'
|
|
49
|
+
},
|
|
50
|
+
ref: ref2,
|
|
51
|
+
children: /*#__PURE__*/_jsxs("button", {
|
|
52
|
+
onClick: options2.toggleFullscreen,
|
|
53
|
+
children: ["\u5B50\u5143\u7D20", fullscreen2 ? '退出全屏' : '全屏']
|
|
54
|
+
})
|
|
55
|
+
})]
|
|
56
|
+
}), /*#__PURE__*/_jsx("div", {})]
|
|
57
|
+
});
|
|
41
58
|
}
|
|
@@ -1,44 +1,62 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
2
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
3
5
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
4
7
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
+
|
|
5
9
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
6
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
7
13
|
import { useState } from 'react';
|
|
8
14
|
import useLatest from 'ahooks/es/useLatest';
|
|
9
15
|
import useMemoizedFn from 'ahooks/es/useMemoizedFn';
|
|
10
16
|
import useUnmount from 'ahooks/es/useUnmount';
|
|
11
17
|
import { getTargetElement } from 'ahooks/es/utils/domTarget';
|
|
12
18
|
import screenfull from 'screenfull';
|
|
19
|
+
|
|
13
20
|
var useFullscreen = function useFullscreen(target, options) {
|
|
14
21
|
var _ref = options || {},
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
onExit = _ref.onExit,
|
|
23
|
+
onEnter = _ref.onEnter;
|
|
24
|
+
|
|
17
25
|
var onExitRef = useLatest(onExit);
|
|
18
26
|
var onEnterRef = useLatest(onEnter);
|
|
27
|
+
|
|
19
28
|
var _useState = useState(false),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
state = _useState2[0],
|
|
31
|
+
setState = _useState2[1];
|
|
32
|
+
|
|
23
33
|
var onChange = function onChange() {
|
|
24
|
-
var _a, _b;
|
|
25
34
|
if (screenfull.isEnabled) {
|
|
26
35
|
var el = getTargetElement(target);
|
|
27
36
|
var isFullscreen = document.fullscreenElement === el;
|
|
37
|
+
|
|
28
38
|
if (isFullscreen) {
|
|
29
|
-
|
|
39
|
+
var _onEnterRef$current;
|
|
40
|
+
|
|
41
|
+
(_onEnterRef$current = onEnterRef.current) === null || _onEnterRef$current === void 0 ? void 0 : _onEnterRef$current.call(onEnterRef);
|
|
30
42
|
} else {
|
|
43
|
+
var _onExitRef$current;
|
|
44
|
+
|
|
31
45
|
screenfull.off('change', onChange);
|
|
32
|
-
(
|
|
46
|
+
(_onExitRef$current = onExitRef.current) === null || _onExitRef$current === void 0 ? void 0 : _onExitRef$current.call(onExitRef);
|
|
33
47
|
}
|
|
48
|
+
|
|
34
49
|
setState(isFullscreen);
|
|
35
50
|
}
|
|
36
51
|
};
|
|
52
|
+
|
|
37
53
|
var enterFullscreen = function enterFullscreen() {
|
|
38
54
|
var el = getTargetElement(target);
|
|
55
|
+
|
|
39
56
|
if (!el) {
|
|
40
57
|
return;
|
|
41
58
|
}
|
|
59
|
+
|
|
42
60
|
if (screenfull.isEnabled) {
|
|
43
61
|
try {
|
|
44
62
|
screenfull.request(el);
|
|
@@ -48,11 +66,13 @@ var useFullscreen = function useFullscreen(target, options) {
|
|
|
48
66
|
}
|
|
49
67
|
}
|
|
50
68
|
};
|
|
69
|
+
|
|
51
70
|
var exitFullscreen = function exitFullscreen() {
|
|
52
71
|
if (screenfull.isEnabled) {
|
|
53
72
|
screenfull.exit();
|
|
54
73
|
}
|
|
55
74
|
};
|
|
75
|
+
|
|
56
76
|
var toggleFullscreen = function toggleFullscreen() {
|
|
57
77
|
if (state) {
|
|
58
78
|
exitFullscreen();
|
|
@@ -60,6 +80,7 @@ var useFullscreen = function useFullscreen(target, options) {
|
|
|
60
80
|
enterFullscreen();
|
|
61
81
|
}
|
|
62
82
|
};
|
|
83
|
+
|
|
63
84
|
useUnmount(function () {
|
|
64
85
|
if (screenfull.isEnabled) {
|
|
65
86
|
screenfull.off('change', onChange);
|
|
@@ -72,4 +93,5 @@ var useFullscreen = function useFullscreen(target, options) {
|
|
|
72
93
|
isEnabled: screenfull.isEnabled
|
|
73
94
|
}];
|
|
74
95
|
};
|
|
96
|
+
|
|
75
97
|
export default useFullscreen;
|
package/es/useHistory/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import InstanceHistory from
|
|
2
|
+
import InstanceHistory from "../InstanceHistory";
|
|
3
|
+
|
|
3
4
|
function useHistory() {
|
|
4
5
|
var history = useMemo(function () {
|
|
5
6
|
return InstanceHistory;
|
|
6
7
|
}, []);
|
|
7
8
|
return history;
|
|
8
9
|
}
|
|
10
|
+
|
|
9
11
|
export default useHistory;
|