oolib 2.101.7 → 2.101.8
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/dist/components/ImageInput/comps/GallerySlider/comps/SliderShell/index.js +1 -12
- package/dist/components/ImageInput/comps/GallerySlider/index.js +11 -0
- package/dist/components/ImageInput/comps/ImageEditor/index.d.ts +2 -1
- package/dist/components/ImageInput/comps/ImageEditor/index.js +2 -2
- package/dist/components/ImageInput/comps/SingleImageInput/index.d.ts +2 -1
- package/dist/components/ImageInput/comps/SingleImageInput/index.js +4 -2
- package/package.json +1 -1
|
@@ -31,7 +31,6 @@ var calcAspectRatio_1 = require("../../../ImageEditor/utils/calcAspectRatio");
|
|
|
31
31
|
var themes_1 = require("../../../../../../themes");
|
|
32
32
|
var icons_1 = require("../../../../../../icons");
|
|
33
33
|
var Typo_1 = require("../../../../../Typo");
|
|
34
|
-
var useSwipe_1 = require("../../../../../../utils/customHooks/useSwipe");
|
|
35
34
|
var greyColor80 = themes_1.colors.greyColor80;
|
|
36
35
|
var CaretLeft = icons_1.icons.CaretLeft, CaretRight = icons_1.icons.CaretRight;
|
|
37
36
|
var SliderShell = function (_a) {
|
|
@@ -42,18 +41,8 @@ var SliderShell = function (_a) {
|
|
|
42
41
|
(0, react_1.useEffect)(function () {
|
|
43
42
|
setImageMinusCaptionHeight(wrapperRef.current.clientWidth / (0, calcAspectRatio_1.calcAspectRatio)(aspectRatio));
|
|
44
43
|
}, []);
|
|
45
|
-
var isTouchDevice = (0, react_1.useRef)('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
|
|
46
|
-
var handleDragStart = (0, useSwipe_1.useSwipe)({
|
|
47
|
-
isTouchDevice: isTouchDevice,
|
|
48
|
-
onSlide: function (direction) {
|
|
49
|
-
setActiveIdx(function (prevIdx) {
|
|
50
|
-
return direction === 'right' ? (prevIdx < value.length - 1 ? prevIdx + 1 : 0) : (prevIdx > 0 ? prevIdx - 1 : value.length - 1);
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
}).handleDragStart;
|
|
54
44
|
return (react_1.default.createElement(styled_1.StyledFlexWrapper, { ref: wrapperRef },
|
|
55
|
-
value.map(function (v, idx) { return (react_1.default.createElement(styled_1.StyledFlexItem, { key: (v === null || v === void 0 ? void 0 : v.publicUrl) || idx, marginLeft: idx === 0 && activeIdx * -100 + "%" },
|
|
56
|
-
react_1.default.createElement("div", { onTouchStart: handleDragStart, onMouseDown: handleDragStart }, render(v, idx) /* explicitly called, cuz we want an error to throw if render prop aint passed thru */))); }),
|
|
45
|
+
value.map(function (v, idx) { return (react_1.default.createElement(styled_1.StyledFlexItem, { key: (v === null || v === void 0 ? void 0 : v.publicUrl) || idx, marginLeft: idx === 0 && activeIdx * -100 + "%" }, render(v, idx) /* explicitly called, cuz we want an error to throw if render prop aint passed thru */)); }),
|
|
57
46
|
!isLoading && value.length > 1 && !imageUnderEdit && react_1.default.createElement(react_1.Fragment, null,
|
|
58
47
|
react_1.default.createElement(styled_1.StyledCaretLeft, { onClick: function () {
|
|
59
48
|
return setActiveIdx(activeIdx > 0 ? activeIdx - 1 : value.length - 1);
|
|
@@ -54,15 +54,26 @@ var makeArrayFromLength_1 = require("../../../../utils/makeArrayFromLength");
|
|
|
54
54
|
var SingleImageInput_1 = require("../SingleImageInput");
|
|
55
55
|
var GalleryThumbnails_1 = require("./comps/GalleryThumbnails");
|
|
56
56
|
var SliderShell_1 = require("./comps/SliderShell");
|
|
57
|
+
var useSwipe_1 = require("../../../../utils/customHooks/useSwipe");
|
|
57
58
|
var GallerySlider = function () {
|
|
58
59
|
var _a = (0, ImageInputContext_1.useImageInputContext)(), value = _a.value, noOfImagesUploading = _a.noOfImagesUploading, invert = _a.invert;
|
|
59
60
|
var _b = (0, react_1.useState)(0), activeIdx = _b[0], setActiveIdx = _b[1];
|
|
60
61
|
(0, react_1.useEffect)(function () { return setActiveIdx(0); }, [value === null || value === void 0 ? void 0 : value.length]); // reset the activeidx with uploading new images(focus on the newly added Images)
|
|
61
62
|
var uploadingPlaceholders = (0, makeArrayFromLength_1.makeArrayFromLength)(noOfImagesUploading).map(function (d) { return undefined; });
|
|
63
|
+
var isTouchDevice = (0, react_1.useRef)('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
|
|
64
|
+
var handleDragStart = (0, useSwipe_1.useSwipe)({
|
|
65
|
+
isTouchDevice: isTouchDevice,
|
|
66
|
+
onSlide: function (direction) {
|
|
67
|
+
setActiveIdx(function (prevIdx) {
|
|
68
|
+
return direction === 'right' ? (prevIdx < value.length - 1 ? prevIdx + 1 : 0) : (prevIdx > 0 ? prevIdx - 1 : value.length - 1);
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
}).handleDragStart;
|
|
62
72
|
return (react_1.default.createElement(styled_1.StyledGallery, { invert: invert },
|
|
63
73
|
react_1.default.createElement(GalleryThumbnails_1.GalleryThumbnails, { setActiveIdx: setActiveIdx, activeIdx: activeIdx }),
|
|
64
74
|
(value === null || value === void 0 ? void 0 : value.length) > 0 ? (react_1.default.createElement(SliderShell_1.SliderShell, { value: __spreadArray(__spreadArray([], uploadingPlaceholders, true), value, true), activeIdx: activeIdx, setActiveIdx: setActiveIdx, render: function (v) { return (react_1.default.createElement(SingleImageInput_1.SingleImageInput, __assign({}, {
|
|
65
75
|
value: v,
|
|
76
|
+
handleDragStart: handleDragStart,
|
|
66
77
|
// key: v?.publicUrl || idx, //cuz this is done inside the SliderShell
|
|
67
78
|
}))); } })) : (react_1.default.createElement(Placeholder_1.default, null))));
|
|
68
79
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* fiddle for dealing with rotation: https://jsfiddle.net/wunderbart/w1hw5kv1/
|
|
3
3
|
*/
|
|
4
|
-
export function ImageEditor({ id, readOnly, value: imageData, defaultImageSpread, handleSingleImageDataChange, handleDeleteSingleImage, handleReplaceSingleImage, aspectRatio, invert, handleUpload, setImageUnderEdit, disableImageBorder, stretchToFullHeight, containerShape, omitEditorTools, enableCaptions, underEditImageData: _underEditImageData, setUnderEditImageData: _setUnderEditImageData, isInPopUp, isInRTE }: {
|
|
4
|
+
export function ImageEditor({ id, readOnly, value: imageData, defaultImageSpread, handleSingleImageDataChange, handleDeleteSingleImage, handleReplaceSingleImage, aspectRatio, invert, handleUpload, setImageUnderEdit, disableImageBorder, stretchToFullHeight, containerShape, omitEditorTools, enableCaptions, underEditImageData: _underEditImageData, setUnderEditImageData: _setUnderEditImageData, isInPopUp, isInRTE, handleDragStart }: {
|
|
5
5
|
id: any;
|
|
6
6
|
readOnly: any;
|
|
7
7
|
value: any;
|
|
@@ -22,5 +22,6 @@ export function ImageEditor({ id, readOnly, value: imageData, defaultImageSpread
|
|
|
22
22
|
setUnderEditImageData: any;
|
|
23
23
|
isInPopUp: any;
|
|
24
24
|
isInRTE: any;
|
|
25
|
+
handleDragStart: any;
|
|
25
26
|
}, ...args: any[]): React.JSX.Element;
|
|
26
27
|
import React from "react";
|
|
@@ -64,7 +64,7 @@ function ImageEditor(_a) {
|
|
|
64
64
|
disableImageBorder = _a.disableImageBorder, stretchToFullHeight = _a.stretchToFullHeight, containerShape = _a.containerShape, omitEditorTools = _a.omitEditorTools, enableCaptions = _a.enableCaptions,
|
|
65
65
|
//sent by parent ImageEditor to child (modal) ImageEditor
|
|
66
66
|
_underEditImageData = _a.underEditImageData, //ImageEditor passes this to its recursive self when opening in popup
|
|
67
|
-
_setUnderEditImageData = _a.setUnderEditImageData, isInPopUp = _a.isInPopUp, isInRTE = _a.isInRTE;
|
|
67
|
+
_setUnderEditImageData = _a.setUnderEditImageData, isInPopUp = _a.isInPopUp, isInRTE = _a.isInRTE, handleDragStart = _a.handleDragStart;
|
|
68
68
|
var theme = (0, styled_components_1.useTheme)();
|
|
69
69
|
var _b = theme || {}, LexicalTextEditor = _b.LexicalTextEditor, _c = _b.lexicalTextEditorHasValue, lexicalTextEditorHasValue = _c === void 0 ? function () { return false; } : _c, //we are just defaulting to false for oolib preview. Meaning, when previewing in oolib, since this function doesnt exist (as it has to be provided by okf-fe), we will always return false from it.
|
|
70
70
|
//backwards compat
|
|
@@ -173,7 +173,7 @@ function ImageEditor(_a) {
|
|
|
173
173
|
imageSpread: imageSpread,
|
|
174
174
|
cropX: cropX,
|
|
175
175
|
cropY: cropY,
|
|
176
|
-
})),
|
|
176
|
+
}, { onTouchStart: handleDragStart && handleDragStart, onMouseDown: handleDragStart && handleDragStart })),
|
|
177
177
|
underEditImageData !== undefined &&
|
|
178
178
|
!omitEditorTools.includes("reposition") && (react_1.default.createElement(ImageReposManager_1.ImageReposManager, __assign({}, {
|
|
179
179
|
fullWidthOrFullHeightImg: fullWidthOrFullHeightImg,
|
|
@@ -29,7 +29,8 @@ var Placeholder_1 = __importDefault(require("../Placeholder"));
|
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
31
|
var SingleImageInput = function (_a) {
|
|
32
|
-
var value = _a.value
|
|
32
|
+
var value = _a.value, // this is a subset of ImageInput's value prop
|
|
33
|
+
handleDragStart = _a.handleDragStart;
|
|
33
34
|
var _b = (0, ImageInputContext_1.useImageInputContext)(), id = _b.id, aspectRatio = _b.aspectRatio, onChange = _b.onChange, handleUpload = _b.handleUpload, publicUrlBeingReplaced = _b.publicUrlBeingReplaced, readOnly = _b.readOnly, enableCaptions = _b.enableCaptions, invert = _b.invert, containerShape = _b.containerShape, defaultImageSpread = _b.defaultImageSpread, handleSingleImageDataChange = _b.handleSingleImageDataChange, handleDeleteSingleImage = _b.handleDeleteSingleImage, handleReplaceSingleImage = _b.handleReplaceSingleImage, setImageUnderEdit = _b.setImageUnderEdit, stretchToFullHeight = _b.stretchToFullHeight, disableImageBorder = _b.disableImageBorder, omitEditorTools = _b.omitEditorTools, isInRTE = _b.isInRTE;
|
|
34
35
|
//this helps for the ImageSlider, since ImageSlider uses SingleImageInput as child
|
|
35
36
|
var isBeingReplaced = publicUrlBeingReplaced && publicUrlBeingReplaced === (value === null || value === void 0 ? void 0 : value.publicUrl);
|
|
@@ -51,7 +52,8 @@ var SingleImageInput = function (_a) {
|
|
|
51
52
|
stretchToFullHeight: stretchToFullHeight,
|
|
52
53
|
disableImageBorder: disableImageBorder,
|
|
53
54
|
omitEditorTools: omitEditorTools,
|
|
54
|
-
isInRTE: isInRTE
|
|
55
|
+
isInRTE: isInRTE,
|
|
56
|
+
handleDragStart: handleDragStart
|
|
55
57
|
})));
|
|
56
58
|
};
|
|
57
59
|
exports.SingleImageInput = SingleImageInput;
|