@expressms/smartapp-ui 1.1.1 → 1.1.2
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/build/main/styles/stories.module.scss +32 -14
- package/build/main/styles/styles.min.css +1 -1
- package/build/main//321/201omponents/ActionModal/ActionModal.d.ts +1 -1
- package/build/main//321/201omponents/ActionModal/ActionModal.js +3 -3
- package/build/main//321/201omponents/ActionModal/types.d.ts +2 -0
- package/build/main//321/201omponents/ConfirmationModal/ConfirmationModal.js +1 -1
- package/build/main//321/201omponents/Stories/Stories.js +27 -13
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IActionModalProps } from './types';
|
|
2
2
|
import '../../styles/stories.module.scss';
|
|
3
|
-
declare const ActionModal: ({ isModalOpen, title, buttonName, confirmButtonFunction, cancelButtonFunction, placeholder, defaultValue, iconColor, }: IActionModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare const ActionModal: ({ isModalOpen, title, buttonName, confirmButtonFunction, cancelButtonFunction, placeholder, defaultValue, iconColor, buttonWidth, }: IActionModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default ActionModal;
|
|
@@ -20,8 +20,8 @@ import { getColor } from '../../helpers';
|
|
|
20
20
|
import { DEFAULT_GRAY_ICON_COLOR } from '../../constants';
|
|
21
21
|
import '../../styles/stories.module.scss';
|
|
22
22
|
var ActionModal = function (_a) {
|
|
23
|
-
var isModalOpen = _a.isModalOpen, title = _a.title, buttonName = _a.buttonName, confirmButtonFunction = _a.confirmButtonFunction, cancelButtonFunction = _a.cancelButtonFunction, placeholder = _a.placeholder, _b = _a.defaultValue, defaultValue = _b === void 0 ? '' : _b, iconColor = _a.iconColor;
|
|
24
|
-
var
|
|
23
|
+
var isModalOpen = _a.isModalOpen, title = _a.title, buttonName = _a.buttonName, confirmButtonFunction = _a.confirmButtonFunction, cancelButtonFunction = _a.cancelButtonFunction, placeholder = _a.placeholder, _b = _a.defaultValue, defaultValue = _b === void 0 ? '' : _b, iconColor = _a.iconColor, _c = _a.buttonWidth, buttonWidth = _c === void 0 ? 100 : _c;
|
|
24
|
+
var _d = useState(defaultValue), value = _d[0], setValue = _d[1];
|
|
25
25
|
var ref = useRef();
|
|
26
26
|
useEffect(function () {
|
|
27
27
|
var checkIfClickedOutside = function (e) {
|
|
@@ -37,6 +37,6 @@ var ActionModal = function (_a) {
|
|
|
37
37
|
var onChange = function (value) {
|
|
38
38
|
setValue(value);
|
|
39
39
|
};
|
|
40
|
-
return (_jsx(Popup, __assign({ closeOnDocumentClick: true, modal: true, open: isModalOpen }, { children: _jsx("div", __assign({ ref: ref, className: "smartapp-action-modal" }, { children: _jsxs("div", __assign({ className: "smartapp-action-modal__content" }, { children: [_jsx("p", __assign({ className: "smartapp-action-modal__content--title" }, { children: title })), _jsx("div", __assign({ onClick: cancelButtonFunction, className: "smartapp-action-modal__content__cancel-cross" }, { children: _jsx(CancelIcon, { style: { color: getColor(iconColor, DEFAULT_GRAY_ICON_COLOR) } }) })), _jsx("div", __assign({ className: "smartapp-action-modal__content--input" }, { children: _jsx(Input, { defaultValue: value, placeholder: placeholder, onChange: onChange }) })), _jsx("div", __assign({ className: "smartapp-action-modal__content--buttons" }, { children: _jsx(Button, { title: buttonName, typeButton: TButtonType.
|
|
40
|
+
return (_jsx(Popup, __assign({ closeOnDocumentClick: true, modal: true, open: isModalOpen }, { children: _jsx("div", __assign({ ref: ref, className: "smartapp-action-modal" }, { children: _jsxs("div", __assign({ className: "smartapp-action-modal__content" }, { children: [_jsx("p", __assign({ className: "smartapp-action-modal__content--title" }, { children: title })), _jsx("div", __assign({ onClick: cancelButtonFunction, className: "smartapp-action-modal__content__cancel-cross" }, { children: _jsx(CancelIcon, { style: { color: getColor(iconColor, DEFAULT_GRAY_ICON_COLOR) } }) })), _jsx("div", __assign({ className: "smartapp-action-modal__content--input" }, { children: _jsx(Input, { defaultValue: value, placeholder: placeholder, onChange: onChange }) })), _jsx("div", __assign({ className: "smartapp-action-modal__content--buttons" }, { children: _jsx(Button, { width: buttonWidth, title: buttonName, typeButton: TButtonType.standard, color: TButtonColor.blue, onClickFunction: function () { return confirmButtonFunction(value); } }) }))] })) })) })));
|
|
41
41
|
};
|
|
42
42
|
export default ActionModal;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IntRange } from '../types';
|
|
1
2
|
export interface IActionModalProps {
|
|
2
3
|
isModalOpen: boolean;
|
|
3
4
|
title: string;
|
|
@@ -7,4 +8,5 @@ export interface IActionModalProps {
|
|
|
7
8
|
placeholder?: string;
|
|
8
9
|
defaultValue?: string;
|
|
9
10
|
iconColor?: string;
|
|
11
|
+
buttonWidth?: IntRange<1, 101>;
|
|
10
12
|
}
|
|
@@ -29,6 +29,6 @@ var ConfirmationModal = function (_a) {
|
|
|
29
29
|
document === null || document === void 0 ? void 0 : document.removeEventListener('click', checkIfClickedOutside, true);
|
|
30
30
|
};
|
|
31
31
|
}, [isModalOpen, cancelButtonFunction]);
|
|
32
|
-
return (_jsx(Popup, __assign({ closeOnDocumentClick: true, modal: true, open: isModalOpen }, { children: _jsx("div", __assign({ ref: ref, className: "smartapp-confirmation-modal" }, { children: _jsxs("div", __assign({ className: "smartapp-confirmation-modal__content" }, { children: [_jsx("p", __assign({ className: "smartapp-confirmation-modal__content--title" }, { children: title })), _jsx("p", __assign({ className: "smartapp-confirmation-modal__content--text" }, { children: text })), _jsxs("div", __assign({ className: "smartapp-confirmation-modal__content--buttons" }, { children: [_jsx(Button, { width: 50, title: cancelButtonName, typeButton: TButtonType.
|
|
32
|
+
return (_jsx(Popup, __assign({ closeOnDocumentClick: true, modal: true, open: isModalOpen }, { children: _jsx("div", __assign({ ref: ref, className: "smartapp-confirmation-modal" }, { children: _jsxs("div", __assign({ className: "smartapp-confirmation-modal__content" }, { children: [_jsx("p", __assign({ className: "smartapp-confirmation-modal__content--title" }, { children: title })), _jsx("p", __assign({ className: "smartapp-confirmation-modal__content--text" }, { children: text })), _jsxs("div", __assign({ className: "smartapp-confirmation-modal__content--buttons" }, { children: [_jsx(Button, { width: 50, title: cancelButtonName, typeButton: TButtonType.standard, onClickFunction: cancelButtonFunction, color: TButtonColor.white }), _jsx(Button, { width: 50, title: confirmButtonName, typeButton: TButtonType.standard, onClickFunction: confirmButtonFunction, color: TButtonColor.blue })] }))] })) })) })));
|
|
33
33
|
};
|
|
34
34
|
export default ConfirmationModal;
|
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useEffect, useState } from 'react';
|
|
13
|
+
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
14
14
|
import classNames from 'classnames';
|
|
15
15
|
import { isNull, sortBy } from 'lodash';
|
|
16
16
|
import Stories from 'react-insta-stories';
|
|
@@ -98,7 +98,6 @@ var StoriesComponent = function (_a) {
|
|
|
98
98
|
handleCloseGroupStories();
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
var onPrevious = function () { return activeStoryId === stories[0].id && handlePrevious(); };
|
|
102
101
|
var onStoryStart = function (storyIndex) {
|
|
103
102
|
var isVideoStory = stories[storyIndex].type === STORY_TYPE.video;
|
|
104
103
|
isVideoStory && setActiveStoryId(stories[storyIndex].id);
|
|
@@ -114,12 +113,23 @@ var StoriesComponent = function (_a) {
|
|
|
114
113
|
changeGroupStoriesToViewed(activeGroupStories);
|
|
115
114
|
}
|
|
116
115
|
};
|
|
116
|
+
var getCurrentStoryIndex = function () { return stories.findIndex(function (_a) {
|
|
117
|
+
var id = _a.id;
|
|
118
|
+
return id === activeStoryId;
|
|
119
|
+
}); };
|
|
120
|
+
var onPrevious = function () {
|
|
121
|
+
activeStoryId === stories[0].id ? handlePrevious() : onStoryStart(getCurrentStoryIndex() - 1);
|
|
122
|
+
};
|
|
123
|
+
var onNext = function () {
|
|
124
|
+
var currentStoryIndex = getCurrentStoryIndex();
|
|
125
|
+
currentStoryIndex !== stories.length - 1 && onStoryStart(currentStoryIndex + 1);
|
|
126
|
+
};
|
|
117
127
|
var getImageContent = function (_a) {
|
|
118
128
|
var id = _a.id, title = _a.title, body = _a.body, backgroundSource = _a.backgroundSource, button = _a.button, image = _a.image;
|
|
119
129
|
return ({
|
|
120
130
|
content: function () {
|
|
121
131
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
122
|
-
|
|
132
|
+
useLayoutEffect(function () {
|
|
123
133
|
setActiveStoryId(id);
|
|
124
134
|
var storyWrapper = document.querySelector('.smartapp-stories');
|
|
125
135
|
var storyWrapperHeight = (storyWrapper === null || storyWrapper === void 0 ? void 0 : storyWrapper.getBoundingClientRect().height) || 0;
|
|
@@ -151,6 +161,16 @@ var StoriesComponent = function (_a) {
|
|
|
151
161
|
onSwipedLeft: function () { return handleNext(); },
|
|
152
162
|
onSwipedRight: function () { return handlePrevious(); },
|
|
153
163
|
});
|
|
164
|
+
var createBackgroundVideo = function (id, url) {
|
|
165
|
+
var video = document.createElement('video');
|
|
166
|
+
video.id = "background_video_".concat(id);
|
|
167
|
+
video.src = url;
|
|
168
|
+
video.muted = true;
|
|
169
|
+
video.playsInline = true;
|
|
170
|
+
video.autoplay = true;
|
|
171
|
+
video.classList.add('smartapp-stories-content__background-video');
|
|
172
|
+
return video;
|
|
173
|
+
};
|
|
154
174
|
useEffect(function () {
|
|
155
175
|
var sortedStories = sortStoriesByOrder((groupStories === null || groupStories === void 0 ? void 0 : groupStories.stories) || []);
|
|
156
176
|
setActiveGroupStories(groupStories);
|
|
@@ -185,20 +205,14 @@ var StoriesComponent = function (_a) {
|
|
|
185
205
|
isWebPlatform(platform) && (popupElement === null || popupElement === void 0 ? void 0 : popupElement.style.setProperty('--background', background));
|
|
186
206
|
}
|
|
187
207
|
else {
|
|
208
|
+
var id = activeStory.id, url = activeStory.url;
|
|
188
209
|
var prevBackgroundVideos = document.querySelectorAll(".smartapp-stories-content__background-video");
|
|
189
210
|
!isEmpty(prevBackgroundVideos) && prevBackgroundVideos.forEach(function (video) { return video.remove(); });
|
|
190
|
-
var video = document.createElement('video');
|
|
191
|
-
video.id = "background_video_".concat(activeStory.id);
|
|
192
|
-
video.src = activeStory.url;
|
|
193
|
-
video.playsInline = true;
|
|
194
|
-
video.autoplay = true;
|
|
195
|
-
video.muted = true;
|
|
196
|
-
video.classList.add('smartapp-stories-content__background-video');
|
|
197
211
|
if (isWebPlatform(platform)) {
|
|
198
212
|
popupElement === null || popupElement === void 0 ? void 0 : popupElement.style.removeProperty('--background');
|
|
199
|
-
popupElement === null || popupElement === void 0 ? void 0 : popupElement.appendChild(
|
|
213
|
+
popupElement === null || popupElement === void 0 ? void 0 : popupElement.appendChild(createBackgroundVideo(id, url));
|
|
200
214
|
}
|
|
201
|
-
videoWrapper === null || videoWrapper === void 0 ? void 0 : videoWrapper.appendChild(
|
|
215
|
+
videoWrapper === null || videoWrapper === void 0 ? void 0 : videoWrapper.appendChild(createBackgroundVideo(id, url));
|
|
202
216
|
}
|
|
203
217
|
}
|
|
204
218
|
}, [platform, activeStory]);
|
|
@@ -212,7 +226,7 @@ var StoriesComponent = function (_a) {
|
|
|
212
226
|
_b['smartapp-stories__video'] = (activeStory === null || activeStory === void 0 ? void 0 : activeStory.type) === STORY_TYPE.video,
|
|
213
227
|
_b['smartapp-stories__animate-right'] = isAnimateToRight,
|
|
214
228
|
_b['smartapp-stories__animate-left'] = isAnimateToLeft,
|
|
215
|
-
_b)) }, swipeableHandlers, { children: _jsx(Stories, { defaultInterval: 6000, width: "100%", height: "100%", stories: getStories(), onStoryStart: onStoryStart, onPrevious: onPrevious, onAllStoriesEnd: handleNext, progressContainerStyles: progressContainerStyles(platform), progressWrapperStyles: progressWrapperStyles, progressStyles: progressStyles }, activeGroupStories.id) })), _jsx(CloseStoriesIcon, { className: classNames((_c = {
|
|
229
|
+
_b)) }, swipeableHandlers, { children: _jsx(Stories, { defaultInterval: 6000, width: "100%", height: "100%", stories: getStories(), onStoryStart: onStoryStart, onPrevious: onPrevious, onNext: onNext, onAllStoriesEnd: handleNext, progressContainerStyles: progressContainerStyles(platform), progressWrapperStyles: progressWrapperStyles, progressStyles: progressStyles }, activeGroupStories.id) })), _jsx(CloseStoriesIcon, { className: classNames((_c = {
|
|
216
230
|
'smartapp-stories__icon': true
|
|
217
231
|
},
|
|
218
232
|
_c["smartapp-stories__icon--".concat(platform)] = true,
|