fan-standard-comp 3.2.1 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +2 -32
- package/dist/09cd8e9be7081f2166444cce393fe968.svg +54 -0
- package/dist/e3378c145b7db195ad068735e15fb28a.svg +165 -0
- package/dist/fan-standard-comp.umd.js +183 -439
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/lg.ttf +0 -0
- package/dist/fonts/lg.woff +0 -0
- package/dist/fonts/lg.woff2 +0 -0
- package/es/ButtonGroup/ButtonList.d.ts +2 -1
- package/es/ButtonGroup/ButtonMenu.d.ts +2 -1
- package/es/ButtonGroup/PopConfirmTitle.js +5 -5
- package/es/ButtonGroup/index.d.ts +3 -1
- package/es/ButtonGroup/index.js +146 -180
- package/es/ButtonGroup/style/index.less +4 -1
- package/es/CalendarCoordPicker/CalendarMonthPicker.d.ts +5 -0
- package/es/CalendarCoordPicker/CalendarMonthPicker.js +26 -0
- package/es/CalendarCoordPicker/index.d.ts +8 -0
- package/es/CalendarCoordPicker/index.js +296 -0
- package/es/CalendarCoordPicker/index.less +31 -0
- package/es/ConfigContext/index.d.ts +7 -0
- package/es/ConfigContext/index.js +12 -0
- package/es/DragContent/index.d.ts +1 -1
- package/es/DragContent/index.js +5 -5
- package/es/FormComp/ChunkUploader/api.js +14 -14
- package/es/FormComp/ChunkUploader/index.js +132 -139
- package/es/FormComp/ChunkUploader/lib.js +21 -21
- package/es/FormComp/ChunkUploader/upload-queue.class.js +64 -66
- package/es/FormComp/EditButton/index.d.ts +1 -1
- package/es/FormComp/EditButton/index.js +15 -17
- package/es/FormComp/FieldComponent/ReUpload.d.ts +1 -1
- package/es/FormComp/FieldComponent/ReUpload.js +37 -23
- package/es/FormComp/FieldComponent/RefactorTextarea.js +32 -0
- package/es/FormComp/FieldComponent/RefactorTreeSelect.js +72 -19
- package/es/FormComp/FieldComponent/TitleNode.d.ts +2 -1
- package/es/FormComp/FieldComponent/index.d.ts +1 -1
- package/es/FormComp/FieldComponent/index.js +37 -26
- package/es/FormComp/FieldComponent/setReadonlyValues.js +6 -6
- package/es/FormComp/RenderItemGroup/index.js +24 -8
- package/es/FormComp/Uploader/index.d.ts +9 -2
- package/es/FormComp/Uploader/index.js +325 -156
- package/es/FormComp/VarTemplate/index.js +57 -64
- package/es/ImageGallery/ImagePreview.d.ts +13 -0
- package/es/ImageGallery/ImagePreview.js +168 -0
- package/es/ImageGallery/PreviewStyles/ImagePreview.less +730 -0
- package/es/ImageGallery/PreviewStyles/fonts/lg.svg +54 -0
- package/es/ImageGallery/PreviewStyles/fonts/lg.ttf +0 -0
- package/es/ImageGallery/PreviewStyles/fonts/lg.woff +0 -0
- package/es/ImageGallery/PreviewStyles/fonts/lg.woff2 +0 -0
- package/es/ImageGallery/PreviewStyles/lg-thumbnail.css +108 -0
- package/es/ImageGallery/PreviewStyles/lg-video.css +144 -0
- package/es/ImageGallery/PreviewStyles/lg-zoom.css +116 -0
- package/es/ImageGallery/PreviewStyles/lightgallery.css +728 -0
- package/es/ImageGallery/SliderContent.d.ts +7 -0
- package/es/ImageGallery/SliderContent.js +699 -0
- package/es/ImageGallery/Thumbnail.d.ts +3 -0
- package/es/ImageGallery/Thumbnail.js +296 -0
- package/es/ImageGallery/hook/uniqueId.d.ts +1 -0
- package/es/ImageGallery/hook/uniqueId.js +10 -0
- package/es/ImageGallery/index.d.ts +4 -0
- package/es/ImageGallery/index.js +29 -0
- package/es/ImageGallery/style/index.less +5 -0
- package/es/ImageGallery/types.d.ts +5 -0
- package/es/ImageGallery/types.js +1 -0
- package/es/NavLeafScroll/index.js +94 -50
- package/es/RefactorTree/index.d.ts +1 -1
- package/es/RefactorTree/index.js +6 -6
- package/es/RefactorTree/indexTreeNode.d.ts +1 -1
- package/es/RefactorTree/indexTreeNode.js +19 -17
- package/es/RefactorTree/util.js +18 -18
- package/es/SpecIcon/fonts/demo_index.html +559 -5
- package/es/SpecIcon/fonts/iconfont.css +101 -3
- package/es/SpecIcon/fonts/iconfont.js +34 -27
- package/es/SpecIcon/fonts/iconfont.json +168 -0
- package/es/SpecIcon/fonts/iconfont.svg +163 -171
- package/es/SpecIcon/fonts/iconfont.ttf +0 -0
- package/es/SpecIcon/fonts/iconfont.woff +0 -0
- package/es/SpecIcon/fonts/iconfont.woff2 +0 -0
- package/es/SpecIcon/style/iconfont.less +106 -11
- package/es/SplitterLayout/Pane.d.ts +1 -1
- package/es/SplitterLayout/index.js +25 -26
- package/es/StandardContent/SplitterLayout/Pane.js +3 -3
- package/es/StandardContent/SplitterLayout/index.js +25 -26
- package/es/StandardContent/SubfieldContent.d.ts +1 -1
- package/es/StandardContent/WrapperContent.d.ts +1 -1
- package/es/StandardDragModal/index.d.ts +11 -3
- package/es/StandardDragModal/index.js +25 -3
- package/es/StandardFilter/index.d.ts +5 -16
- package/es/StandardFilter/index.js +212 -200
- package/es/StandardFilter/indexClass.d.ts +37 -0
- package/es/StandardFilter/indexClass.js +217 -0
- package/es/StandardFilter/style/index.less +82 -9
- package/es/StandardForm/StepForm.d.ts +1 -1
- package/es/StandardForm/StepForm.js +28 -22
- package/es/StandardForm/TabForm.d.ts +1 -1
- package/es/StandardForm/TabForm.js +41 -43
- package/es/StandardForm/index.d.ts +1 -1
- package/es/StandardForm/index.js +5 -5
- package/es/StandardModal/UpdateFormRef.js +0 -1
- package/es/StandardModal/index.d.ts +2 -1
- package/es/StandardModal/index.js +25 -39
- package/es/StandardPanel/index.d.ts +1 -1
- package/es/StandardPanel/index.js +7 -7
- package/es/StandardTable/index.d.ts +1 -0
- package/es/StandardTable/index.js +44 -26
- package/es/components/IconNode/index.d.ts +1 -1
- package/es/components/IconNode/index.js +0 -1
- package/es/data/general.config.js +31 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +6 -2
- package/es/utils/filterPermission.js +7 -10
- package/es/utils/getParentNodes.js +101 -26
- package/es/utils/index.js +2 -3
- package/es/utils/urlUtils.js +76 -0
- package/lib/ButtonGroup/ButtonList.d.ts +2 -1
- package/lib/ButtonGroup/ButtonList.js +2 -3
- package/lib/ButtonGroup/ButtonMenu.d.ts +2 -1
- package/lib/ButtonGroup/ButtonMenu.js +2 -3
- package/lib/ButtonGroup/PopConfirmTitle.js +7 -8
- package/lib/ButtonGroup/index.d.ts +3 -1
- package/lib/ButtonGroup/index.js +150 -185
- package/lib/ButtonGroup/style/index.less +4 -1
- package/lib/CalendarCoordPicker/CalendarMonthPicker.d.ts +5 -0
- package/lib/CalendarCoordPicker/CalendarMonthPicker.js +36 -0
- package/lib/CalendarCoordPicker/index.d.ts +8 -0
- package/lib/CalendarCoordPicker/index.js +305 -0
- package/lib/CalendarCoordPicker/index.less +31 -0
- package/lib/ConfigContext/index.d.ts +7 -0
- package/lib/ConfigContext/index.js +17 -0
- package/lib/DragContent/DragBar.js +2 -3
- package/lib/DragContent/index.d.ts +1 -1
- package/lib/DragContent/index.js +9 -10
- package/lib/FormComp/ChunkUploader/api.js +15 -15
- package/lib/FormComp/ChunkUploader/index.js +135 -142
- package/lib/FormComp/ChunkUploader/lib.js +22 -22
- package/lib/FormComp/ChunkUploader/upload-queue.class.js +66 -69
- package/lib/FormComp/ChunkUploader/worker.js +1 -1
- package/lib/FormComp/EditButton/index.d.ts +1 -1
- package/lib/FormComp/EditButton/index.js +19 -22
- package/lib/FormComp/FieldComponent/ReUpload.d.ts +1 -1
- package/lib/FormComp/FieldComponent/ReUpload.js +40 -28
- package/lib/FormComp/FieldComponent/RefactorTextarea.js +42 -0
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +75 -23
- package/lib/FormComp/FieldComponent/TitleNode.d.ts +2 -1
- package/lib/FormComp/FieldComponent/TitleNode.js +2 -3
- package/lib/FormComp/FieldComponent/index.d.ts +1 -1
- package/lib/FormComp/FieldComponent/index.js +41 -28
- package/lib/FormComp/FieldComponent/setReadonlyValues.js +15 -20
- package/lib/FormComp/RenderItemGroup/index.js +26 -11
- package/lib/FormComp/Uploader/index.d.ts +9 -2
- package/lib/FormComp/Uploader/index.js +325 -159
- package/lib/FormComp/VarTemplate/index.js +63 -71
- package/lib/FormComp/index.js +1 -1
- package/lib/ImageGallery/ImagePreview.d.ts +13 -0
- package/lib/ImageGallery/ImagePreview.js +178 -0
- package/lib/ImageGallery/PreviewStyles/ImagePreview.less +730 -0
- package/lib/ImageGallery/PreviewStyles/fonts/lg.svg +54 -0
- package/lib/ImageGallery/PreviewStyles/fonts/lg.ttf +0 -0
- package/lib/ImageGallery/PreviewStyles/fonts/lg.woff +0 -0
- package/lib/ImageGallery/PreviewStyles/fonts/lg.woff2 +0 -0
- package/lib/ImageGallery/PreviewStyles/lg-thumbnail.css +108 -0
- package/lib/ImageGallery/PreviewStyles/lg-video.css +144 -0
- package/lib/ImageGallery/PreviewStyles/lg-zoom.css +116 -0
- package/lib/ImageGallery/PreviewStyles/lightgallery.css +728 -0
- package/lib/ImageGallery/SliderContent.d.ts +7 -0
- package/lib/ImageGallery/SliderContent.js +708 -0
- package/lib/ImageGallery/Thumbnail.d.ts +3 -0
- package/lib/ImageGallery/Thumbnail.js +306 -0
- package/lib/ImageGallery/hook/uniqueId.d.ts +1 -0
- package/lib/ImageGallery/hook/uniqueId.js +17 -0
- package/lib/ImageGallery/index.d.ts +4 -0
- package/lib/ImageGallery/index.js +36 -0
- package/lib/ImageGallery/style/index.less +5 -0
- package/lib/ImageGallery/types.d.ts +5 -0
- package/lib/ImageGallery/types.js +5 -0
- package/lib/NavLeafScroll/index.js +98 -55
- package/lib/RefactorTree/index.d.ts +1 -1
- package/lib/RefactorTree/index.js +10 -11
- package/lib/RefactorTree/indexTreeNode.d.ts +1 -1
- package/lib/RefactorTree/indexTreeNode.js +23 -22
- package/lib/RefactorTree/util.js +18 -18
- package/lib/SpecIcon/fonts/demo_index.html +559 -5
- package/lib/SpecIcon/fonts/iconfont.css +101 -3
- package/lib/SpecIcon/fonts/iconfont.js +34 -27
- package/lib/SpecIcon/fonts/iconfont.json +168 -0
- package/lib/SpecIcon/fonts/iconfont.svg +163 -171
- package/lib/SpecIcon/fonts/iconfont.ttf +0 -0
- package/lib/SpecIcon/fonts/iconfont.woff +0 -0
- package/lib/SpecIcon/fonts/iconfont.woff2 +0 -0
- package/lib/SpecIcon/index.js +2 -3
- package/lib/SpecIcon/style/iconfont.less +106 -11
- package/lib/SplitterLayout/Pane.d.ts +1 -1
- package/lib/SplitterLayout/Pane.js +2 -3
- package/lib/SplitterLayout/index.js +27 -29
- package/lib/StandardContent/SplitterLayout/Pane.js +5 -6
- package/lib/StandardContent/SplitterLayout/index.js +27 -29
- package/lib/StandardContent/SubfieldContent.d.ts +1 -1
- package/lib/StandardContent/SubfieldContent.js +2 -3
- package/lib/StandardContent/WrapperContent.d.ts +1 -1
- package/lib/StandardContent/WrapperContent.js +2 -3
- package/lib/StandardDragModal/index.d.ts +11 -3
- package/lib/StandardDragModal/index.js +27 -33
- package/lib/StandardFilter/index.d.ts +5 -16
- package/lib/StandardFilter/index.js +215 -201
- package/lib/StandardFilter/indexClass.d.ts +37 -0
- package/lib/StandardFilter/indexClass.js +223 -0
- package/lib/StandardFilter/style/index.less +82 -9
- package/lib/StandardForm/ActionList.js +2 -3
- package/lib/StandardForm/StepForm.d.ts +1 -1
- package/lib/StandardForm/StepForm.js +32 -27
- package/lib/StandardForm/TabForm.d.ts +1 -1
- package/lib/StandardForm/TabForm.js +45 -48
- package/lib/StandardForm/index.d.ts +1 -1
- package/lib/StandardForm/index.js +9 -10
- package/lib/StandardModal/UpdateFormRef.js +3 -4
- package/lib/StandardModal/index.d.ts +2 -1
- package/lib/StandardModal/index.js +29 -43
- package/lib/StandardPanel/index.d.ts +1 -1
- package/lib/StandardPanel/index.js +11 -12
- package/lib/StandardTable/index.d.ts +1 -0
- package/lib/StandardTable/index.js +49 -29
- package/lib/components/IconNode/index.d.ts +1 -1
- package/lib/components/IconNode/index.js +2 -4
- package/lib/components/index.js +1 -1
- package/lib/data/func.code.js +2 -3
- package/lib/data/general.config.js +33 -3
- package/lib/data/index.js +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +30 -10
- package/lib/utils/ValueFormat.js +1 -2
- package/lib/utils/filterPermission.js +11 -18
- package/lib/utils/getParentNodes.js +103 -29
- package/lib/utils/index.js +5 -27
- package/lib/utils/urlUtils.js +82 -0
- package/package.json +15 -9
- package/dist/f26952c118ab6cdcd23dc0028ee98c11.svg +0 -173
- package/dist/fonts/iconfont.eot +0 -0
- package/es/StandardDragModal/ChangeStandardModal.d.ts +0 -44
- package/es/StandardDragModal/ChangeStandardModal.js +0 -493
- package/es/StandardDragModal/DraggableModal.d.ts +0 -7
- package/es/StandardDragModal/DraggableModal.js +0 -31
- package/es/StandardDragModal/DraggableModalContext.d.ts +0 -9
- package/es/StandardDragModal/DraggableModalContext.js +0 -5
- package/es/StandardDragModal/DraggableModalInner.d.ts +0 -16
- package/es/StandardDragModal/DraggableModalInner.js +0 -114
- package/es/StandardDragModal/DraggableModalProvider.d.ts +0 -4
- package/es/StandardDragModal/DraggableModalProvider.js +0 -40
- package/es/StandardDragModal/Modal.d.ts +0 -11
- package/es/StandardDragModal/Modal.js +0 -24
- package/es/StandardDragModal/ResizeHandle.d.ts +0 -2
- package/es/StandardDragModal/ResizeHandle.js +0 -8
- package/es/StandardDragModal/clamp.d.ts +0 -1
- package/es/StandardDragModal/clamp.js +0 -3
- package/es/StandardDragModal/draggableModalReducer.d.ts +0 -66
- package/es/StandardDragModal/draggableModalReducer.js +0 -157
- package/es/StandardDragModal/getWindowSize.d.ts +0 -4
- package/es/StandardDragModal/getWindowSize.js +0 -6
- package/es/StandardDragModal/index.less +0 -65
- package/es/StandardDragModal/useDrag.d.ts +0 -5
- package/es/StandardDragModal/useDrag.js +0 -66
- package/es/StandardDragModal/usePrevious.d.ts +0 -1
- package/es/StandardDragModal/usePrevious.js +0 -8
- package/es/StandardDragModal/useResize.d.ts +0 -7
- package/es/StandardDragModal/useResize.js +0 -74
- package/es/utils/dictSelectUtil.js +0 -153
- package/lib/StandardDragModal/ChangeStandardModal.d.ts +0 -44
- package/lib/StandardDragModal/ChangeStandardModal.js +0 -502
- package/lib/StandardDragModal/DraggableModal.d.ts +0 -7
- package/lib/StandardDragModal/DraggableModal.js +0 -40
- package/lib/StandardDragModal/DraggableModalContext.d.ts +0 -9
- package/lib/StandardDragModal/DraggableModalContext.js +0 -15
- package/lib/StandardDragModal/DraggableModalInner.d.ts +0 -16
- package/lib/StandardDragModal/DraggableModalInner.js +0 -124
- package/lib/StandardDragModal/DraggableModalProvider.d.ts +0 -4
- package/lib/StandardDragModal/DraggableModalProvider.js +0 -48
- package/lib/StandardDragModal/Modal.d.ts +0 -11
- package/lib/StandardDragModal/Modal.js +0 -32
- package/lib/StandardDragModal/ResizeHandle.d.ts +0 -2
- package/lib/StandardDragModal/ResizeHandle.js +0 -18
- package/lib/StandardDragModal/clamp.d.ts +0 -1
- package/lib/StandardDragModal/clamp.js +0 -10
- package/lib/StandardDragModal/draggableModalReducer.d.ts +0 -66
- package/lib/StandardDragModal/draggableModalReducer.js +0 -167
- package/lib/StandardDragModal/getWindowSize.d.ts +0 -4
- package/lib/StandardDragModal/getWindowSize.js +0 -13
- package/lib/StandardDragModal/index.less +0 -65
- package/lib/StandardDragModal/useDrag.d.ts +0 -5
- package/lib/StandardDragModal/useDrag.js +0 -73
- package/lib/StandardDragModal/usePrevious.d.ts +0 -1
- package/lib/StandardDragModal/usePrevious.js +0 -15
- package/lib/StandardDragModal/useResize.d.ts +0 -7
- package/lib/StandardDragModal/useResize.js +0 -81
- package/lib/utils/dictSelectUtil.js +0 -161
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { useRef, useEffect, useState } from 'react';
|
|
8
|
+
import classNames from "classnames";
|
|
9
|
+
var isDragging = false;
|
|
10
|
+
var translateX = 0;
|
|
11
|
+
var thumbDragUtils = {
|
|
12
|
+
cords: {
|
|
13
|
+
startX: 0,
|
|
14
|
+
endX: 0
|
|
15
|
+
},
|
|
16
|
+
isMoved: false,
|
|
17
|
+
newTranslateX: 0,
|
|
18
|
+
startTime: new Date(),
|
|
19
|
+
endTime: new Date(),
|
|
20
|
+
touchMoveTime: 0
|
|
21
|
+
};
|
|
22
|
+
var thumbClickable = true;
|
|
23
|
+
var thumbnailSwipeThreshold = 10;
|
|
24
|
+
var Thumbnail = function Thumbnail(props) {
|
|
25
|
+
var _props$thumbWidth = props.thumbWidth,
|
|
26
|
+
thumbWidth = _props$thumbWidth === void 0 ? 100 : _props$thumbWidth,
|
|
27
|
+
_props$thumbMargin = props.thumbMargin,
|
|
28
|
+
thumbMargin = _props$thumbMargin === void 0 ? 5 : _props$thumbMargin,
|
|
29
|
+
thumbCurrent = props.thumbCurrent,
|
|
30
|
+
children = props.children,
|
|
31
|
+
galleryCount = props.galleryCount,
|
|
32
|
+
onClickThumbItem = props.onClickThumbItem,
|
|
33
|
+
_props$currentPagerPo = props.currentPagerPosition,
|
|
34
|
+
currentPagerPosition = _props$currentPagerPo === void 0 ? 'middle' : _props$currentPagerPo;
|
|
35
|
+
var $thumbOuter = useRef();
|
|
36
|
+
var $thumbGroup = useRef();
|
|
37
|
+
var _useState = useState(0),
|
|
38
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
+
thumbOuterWidth = _useState2[0],
|
|
40
|
+
setThumbOuterWidth = _useState2[1];
|
|
41
|
+
var _useState3 = useState(0),
|
|
42
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
|
+
thumbTotalWidth = _useState4[0],
|
|
44
|
+
setThumbTotalWidth = _useState4[1];
|
|
45
|
+
var init = function init() {
|
|
46
|
+
var _a;
|
|
47
|
+
setThumbOuterWidth((_a = $thumbOuter === null || $thumbOuter === void 0 ? void 0 : $thumbOuter.current) === null || _a === void 0 ? void 0 : _a.clientWidth);
|
|
48
|
+
setThumbTotalWidth(galleryCount * (thumbWidth + thumbMargin));
|
|
49
|
+
// Thumbnail animation value
|
|
50
|
+
translateX = 0;
|
|
51
|
+
};
|
|
52
|
+
var destroy = function destroy() {
|
|
53
|
+
thumbDragUtils = {
|
|
54
|
+
cords: {
|
|
55
|
+
startX: 0,
|
|
56
|
+
endX: 0
|
|
57
|
+
},
|
|
58
|
+
isMoved: false,
|
|
59
|
+
newTranslateX: 0,
|
|
60
|
+
startTime: new Date(),
|
|
61
|
+
endTime: new Date(),
|
|
62
|
+
touchMoveTime: 0
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
var onThumbMouseDown = function onThumbMouseDown(e) {
|
|
66
|
+
if (thumbTotalWidth > thumbOuterWidth) {
|
|
67
|
+
// execute only on .lg-object
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
thumbDragUtils.cords.startX = e.pageX;
|
|
70
|
+
thumbDragUtils.startTime = new Date();
|
|
71
|
+
thumbClickable = false;
|
|
72
|
+
isDragging = true;
|
|
73
|
+
//
|
|
74
|
+
// // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
|
|
75
|
+
// this.core.outer.get().scrollLeft += 1;
|
|
76
|
+
// this.core.outer.get().scrollLeft -= 1;
|
|
77
|
+
//
|
|
78
|
+
if ($thumbOuter.current) {
|
|
79
|
+
$thumbOuter.current.classList.remove('spec-image-preview-grab');
|
|
80
|
+
$thumbOuter.current.classList.add('spec-image-preview-grabbing');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var onThumbMouseMove = function onThumbMouseMove(e) {
|
|
85
|
+
if (isDragging) {
|
|
86
|
+
thumbDragUtils.cords.endX = e.pageX;
|
|
87
|
+
thumbDragUtils = onThumbTouchMove(thumbDragUtils);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var onThumbMouseUp = function onThumbMouseUp(e) {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
if (thumbDragUtils.isMoved) {
|
|
93
|
+
thumbDragUtils = onThumbTouchEnd(thumbDragUtils);
|
|
94
|
+
} else {
|
|
95
|
+
thumbClickable = true;
|
|
96
|
+
}
|
|
97
|
+
if (isDragging) {
|
|
98
|
+
isDragging = false;
|
|
99
|
+
(_a = $thumbOuter === null || $thumbOuter === void 0 ? void 0 : $thumbOuter.current) === null || _a === void 0 ? void 0 : _a.classList.remove('spec-image-preview-grabbing');
|
|
100
|
+
(_b = $thumbOuter === null || $thumbOuter === void 0 ? void 0 : $thumbOuter.current) === null || _b === void 0 ? void 0 : _b.classList.add('spec-image-preview-grab');
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var onThumbTouchMove = function onThumbTouchMove(thumbDragUtils) {
|
|
104
|
+
thumbDragUtils.newTranslateX = translateX;
|
|
105
|
+
thumbDragUtils.isMoved = true;
|
|
106
|
+
thumbDragUtils.touchMoveTime = new Date().valueOf();
|
|
107
|
+
thumbDragUtils.newTranslateX -= thumbDragUtils.cords.endX - thumbDragUtils.cords.startX;
|
|
108
|
+
thumbDragUtils.newTranslateX = getPossibleTransformX(thumbDragUtils.newTranslateX);
|
|
109
|
+
// move current slide
|
|
110
|
+
setTranslate(thumbDragUtils.newTranslateX);
|
|
111
|
+
$thumbOuter.current.classList.add('spec-image-preview-dragging');
|
|
112
|
+
return thumbDragUtils;
|
|
113
|
+
};
|
|
114
|
+
var onTouchStart = function onTouchStart(e) {
|
|
115
|
+
if (thumbTotalWidth > thumbOuterWidth) {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
thumbDragUtils.cords.startX = e.targetTouches[0].pageX;
|
|
118
|
+
thumbClickable = false;
|
|
119
|
+
thumbDragUtils.startTime = new Date();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var onTouchMove = function onTouchMove(e) {
|
|
123
|
+
if (thumbTotalWidth > thumbOuterWidth) {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
thumbDragUtils.cords.endX = e.targetTouches[0].pageX;
|
|
126
|
+
thumbDragUtils = onThumbTouchMove(thumbDragUtils);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var onTouchEnd = function onTouchEnd() {
|
|
130
|
+
if (thumbDragUtils.isMoved) {
|
|
131
|
+
thumbDragUtils = onThumbTouchEnd(thumbDragUtils);
|
|
132
|
+
} else {
|
|
133
|
+
thumbClickable = true;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var onThumbTouchEnd = function onThumbTouchEnd(thumbDragUtils) {
|
|
137
|
+
thumbDragUtils.isMoved = false;
|
|
138
|
+
thumbDragUtils.endTime = new Date();
|
|
139
|
+
$thumbOuter.current.classList.remove('spec-image-preview-dragging');
|
|
140
|
+
var touchDuration = thumbDragUtils.endTime.valueOf() - thumbDragUtils.startTime.valueOf();
|
|
141
|
+
var distanceXnew = thumbDragUtils.cords.endX - thumbDragUtils.cords.startX;
|
|
142
|
+
var speedX = Math.abs(distanceXnew) / touchDuration;
|
|
143
|
+
// Some magical numbers
|
|
144
|
+
// Can be improved
|
|
145
|
+
if (speedX > 0.15 && thumbDragUtils.endTime.valueOf() - thumbDragUtils.touchMoveTime < 30) {
|
|
146
|
+
speedX += 1;
|
|
147
|
+
if (speedX > 2) {
|
|
148
|
+
speedX += 1;
|
|
149
|
+
}
|
|
150
|
+
speedX = speedX + speedX * (Math.abs(distanceXnew) / thumbOuterWidth);
|
|
151
|
+
$thumbGroup.current.style.transitionDuration = Math.min(speedX - 1, 2) + 'settings';
|
|
152
|
+
distanceXnew = distanceXnew * speedX;
|
|
153
|
+
translateX = getPossibleTransformX(translateX - distanceXnew);
|
|
154
|
+
setTranslate(translateX);
|
|
155
|
+
} else {
|
|
156
|
+
translateX = thumbDragUtils.newTranslateX;
|
|
157
|
+
}
|
|
158
|
+
if (Math.abs(thumbDragUtils.cords.endX - thumbDragUtils.cords.startX) < thumbnailSwipeThreshold) {
|
|
159
|
+
thumbClickable = true;
|
|
160
|
+
}
|
|
161
|
+
return thumbDragUtils;
|
|
162
|
+
};
|
|
163
|
+
var getPossibleTransformX = function getPossibleTransformX(left) {
|
|
164
|
+
if (left > thumbTotalWidth - thumbOuterWidth) {
|
|
165
|
+
left = thumbTotalWidth - thumbOuterWidth;
|
|
166
|
+
}
|
|
167
|
+
if (left < 0) {
|
|
168
|
+
left = 0;
|
|
169
|
+
}
|
|
170
|
+
return left;
|
|
171
|
+
};
|
|
172
|
+
var setTranslate = function setTranslate(value) {
|
|
173
|
+
// console.log('偏移量', -value)
|
|
174
|
+
$thumbGroup.current.style.transform = 'translate3d(-' + value + 'px, 0px, 0px)';
|
|
175
|
+
};
|
|
176
|
+
var animateThumb = function animateThumb(index) {
|
|
177
|
+
// $thumbGroup.current.style.transitionDuration = '400ms'
|
|
178
|
+
var position = 0;
|
|
179
|
+
switch (currentPagerPosition) {
|
|
180
|
+
case 'left':
|
|
181
|
+
position = 0;
|
|
182
|
+
break;
|
|
183
|
+
case 'middle':
|
|
184
|
+
position = thumbOuterWidth / 2 - thumbWidth / 2;
|
|
185
|
+
break;
|
|
186
|
+
case 'right':
|
|
187
|
+
position = thumbOuterWidth - thumbWidth;
|
|
188
|
+
}
|
|
189
|
+
translateX = (thumbWidth + thumbMargin) * index - 1 - position;
|
|
190
|
+
if (translateX > thumbTotalWidth - thumbOuterWidth) {
|
|
191
|
+
translateX = thumbTotalWidth - thumbOuterWidth;
|
|
192
|
+
}
|
|
193
|
+
if (translateX < 0) {
|
|
194
|
+
translateX = 0;
|
|
195
|
+
}
|
|
196
|
+
setTranslate(translateX);
|
|
197
|
+
};
|
|
198
|
+
useEffect(function () {
|
|
199
|
+
init();
|
|
200
|
+
return function () {
|
|
201
|
+
destroy();
|
|
202
|
+
};
|
|
203
|
+
}, [$thumbOuter === null || $thumbOuter === void 0 ? void 0 : $thumbOuter.current, $thumbGroup === null || $thumbGroup === void 0 ? void 0 : $thumbGroup.current, thumbWidth, thumbMargin, galleryCount]);
|
|
204
|
+
// 计算转到中间位置
|
|
205
|
+
// const slideThumbToMiddle = () => {
|
|
206
|
+
// const order = thumbCurrent + 1
|
|
207
|
+
// // 当前图片块距离
|
|
208
|
+
// const halfWidth = (thumbWidth + thumbMargin) / 2
|
|
209
|
+
// const curDistance = order * (thumbWidth + thumbMargin) - halfWidth
|
|
210
|
+
// const pageNum = Math.ceil((order * (thumbWidth + thumbMargin) / thumbOuterWidth))
|
|
211
|
+
// const totalPage = Math.ceil(thumbTotalWidth / thumbOuterWidth)
|
|
212
|
+
// const centerPosition = thumbOuterWidth / 2 // 中心点
|
|
213
|
+
// if (isNaN(pageNum)) {
|
|
214
|
+
// return
|
|
215
|
+
// }
|
|
216
|
+
// if (curDistance < centerPosition) {
|
|
217
|
+
// console.log('Rule1,位置小于中心点,不设偏移量')
|
|
218
|
+
// thumbDragUtils.newTranslateX = 0
|
|
219
|
+
// } else {
|
|
220
|
+
// console.log('thumbTotalWidth - curDistance', thumbTotalWidth - curDistance)
|
|
221
|
+
// if ((thumbTotalWidth - curDistance) < centerPosition) {
|
|
222
|
+
// console.log('Rule3,已经不足空间转到中间点了')
|
|
223
|
+
// thumbDragUtils.newTranslateX = thumbTotalWidth - thumbOuterWidth
|
|
224
|
+
// } else {
|
|
225
|
+
// console.log('Rule2,直接跳转到中间点')
|
|
226
|
+
// thumbDragUtils.newTranslateX = curDistance - centerPosition
|
|
227
|
+
// }
|
|
228
|
+
// }
|
|
229
|
+
// setTranslate(thumbDragUtils.newTranslateX)
|
|
230
|
+
// }
|
|
231
|
+
useEffect(function () {
|
|
232
|
+
// 判断是不是在中间
|
|
233
|
+
animateThumb(thumbCurrent);
|
|
234
|
+
}, [thumbCurrent, thumbTotalWidth, thumbOuterWidth, thumbMargin]);
|
|
235
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
236
|
+
className: 'spec-image-preview-thumb-outer spec-image-preview-thumb-align-middle spec-image-preview-grab spec-image-preview-animate-thumb',
|
|
237
|
+
ref: $thumbOuter
|
|
238
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
239
|
+
className: 'spec-image-preview-thumb spec-image-preview-thumb-group',
|
|
240
|
+
style: {
|
|
241
|
+
transitionDuration: '300ms',
|
|
242
|
+
width: galleryCount * (thumbWidth + thumbMargin) + 'px',
|
|
243
|
+
position: 'relative',
|
|
244
|
+
transform: 'translate3d(0px, 0px, 0px)'
|
|
245
|
+
},
|
|
246
|
+
ref: $thumbGroup,
|
|
247
|
+
onMouseDown: onThumbMouseDown,
|
|
248
|
+
onMouseUp: onThumbMouseUp,
|
|
249
|
+
onMouseMove: onThumbMouseMove,
|
|
250
|
+
onTouchStart: onTouchStart,
|
|
251
|
+
onTouchMove: onTouchMove,
|
|
252
|
+
onTouchEnd: onTouchEnd
|
|
253
|
+
}, React.Children.map(children, function (item, index) {
|
|
254
|
+
var imgNode; // = item.type !== 'img' ? item.props.children : item
|
|
255
|
+
if (item.type === 'img') {
|
|
256
|
+
imgNode = item;
|
|
257
|
+
} else if (item.props.children) {
|
|
258
|
+
if (Object.prototype.toString.call(item.props.children) === '[object Array]') {
|
|
259
|
+
// 多个子节点,只取img标签
|
|
260
|
+
imgNode = item.props.children.find(function (cItem) {
|
|
261
|
+
return cItem.type === 'img';
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
if (Object.prototype.toString.call(item.props.children) === '[object Object]') {
|
|
265
|
+
imgNode = item.props.children;
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
// 没有标签
|
|
269
|
+
imgNode = {};
|
|
270
|
+
}
|
|
271
|
+
// 单个子节点
|
|
272
|
+
// console.log('children=>item', item.props.children)
|
|
273
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
274
|
+
className: classNames('spec-image-preview-thumb-item', thumbCurrent === index ? 'active' : ''),
|
|
275
|
+
"data-item-id": index,
|
|
276
|
+
style: {
|
|
277
|
+
width: thumbWidth + 'px',
|
|
278
|
+
height: '80px',
|
|
279
|
+
marginRight: '5px'
|
|
280
|
+
},
|
|
281
|
+
onClick: function onClick(e) {
|
|
282
|
+
if (thumbClickable) {
|
|
283
|
+
onClickThumbItem === null || onClickThumbItem === void 0 ? void 0 : onClickThumbItem('number', index);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}, /*#__PURE__*/React.createElement("img", Object.assign({
|
|
287
|
+
src: item.props['data-src' || 'src']
|
|
288
|
+
}, imgNode.props, {
|
|
289
|
+
"data-item-id": index,
|
|
290
|
+
onMouseDown: function onMouseDown(evt) {
|
|
291
|
+
return evt.preventDefault();
|
|
292
|
+
}
|
|
293
|
+
})));
|
|
294
|
+
})));
|
|
295
|
+
};
|
|
296
|
+
export default Thumbnail;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useUniqueId: (prefix?: string) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var uniqueId = 0;
|
|
3
|
+
export var useUniqueId = function useUniqueId() {
|
|
4
|
+
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
5
|
+
var id = React.useRef("".concat(prefix, "-").concat(uniqueId++));
|
|
6
|
+
React.useEffect(function () {
|
|
7
|
+
uniqueId++;
|
|
8
|
+
}, []);
|
|
9
|
+
return id.current;
|
|
10
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ImagePreview from './ImagePreview';
|
|
3
|
+
import { useUniqueId } from "./hook/uniqueId";
|
|
4
|
+
import './style/index.less';
|
|
5
|
+
var ImageGallery = function ImageGallery(props) {
|
|
6
|
+
var children = props.children,
|
|
7
|
+
_props$hasThumbnail = props.hasThumbnail,
|
|
8
|
+
hasThumbnail = _props$hasThumbnail === void 0 ? true : _props$hasThumbnail,
|
|
9
|
+
items = props.items,
|
|
10
|
+
height = props.height;
|
|
11
|
+
var prefixCls = 'spec-image-gallery';
|
|
12
|
+
var coreId = useUniqueId(prefixCls);
|
|
13
|
+
// useEffect(() => {
|
|
14
|
+
// console.log(' document.getElementById(ImageGalleryId)', document.getElementById(ImageGalleryId))
|
|
15
|
+
// }, [])
|
|
16
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
17
|
+
className: prefixCls,
|
|
18
|
+
style: {
|
|
19
|
+
height: height
|
|
20
|
+
},
|
|
21
|
+
id: coreId
|
|
22
|
+
}, /*#__PURE__*/React.createElement(ImagePreview, {
|
|
23
|
+
hasThumbnail: hasThumbnail,
|
|
24
|
+
mode: 'inline',
|
|
25
|
+
showToolbar: false,
|
|
26
|
+
galleryItems: items
|
|
27
|
+
}, children));
|
|
28
|
+
};
|
|
29
|
+
export default ImageGallery;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|