@expressms/smartapp-ui 1.0.7 → 1.1.1

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.
Files changed (38) hide show
  1. package/build/main/assets/icons/loader.svg +3 -0
  2. package/build/main/assets/icons/refresh.svg +3 -0
  3. package/build/main/constants/constants.d.ts +20 -0
  4. package/build/main/constants/constants.js +23 -0
  5. package/build/main/helpers/index.d.ts +4 -1
  6. package/build/main/helpers/index.js +6 -2
  7. package/build/main/styles/stories.module.scss +184 -21
  8. package/build/main/styles/styles.min.css +1 -1
  9. package/build/main//321/201omponents/ActionModal/ActionModal.js +2 -2
  10. package/build/main//321/201omponents/AttachedFile/AttachedFile.js +3 -3
  11. package/build/main//321/201omponents/Avatar/Avatar.d.ts +1 -1
  12. package/build/main//321/201omponents/Avatar/Avatar.js +16 -16
  13. package/build/main//321/201omponents/Avatar/types.d.ts +4 -2
  14. package/build/main//321/201omponents/Avatar/types.js +1 -0
  15. package/build/main//321/201omponents/Checkbox/Checkbox.js +2 -2
  16. package/build/main//321/201omponents/Chips/Chips.js +2 -2
  17. package/build/main//321/201omponents/CustomSelectProfiles/CustomSelectProfiles.js +3 -3
  18. package/build/main//321/201omponents/DragAndDrop/DragAndDrop.js +2 -2
  19. package/build/main//321/201omponents/Error/Error.js +2 -2
  20. package/build/main//321/201omponents/Header/Header.d.ts +1 -1
  21. package/build/main//321/201omponents/Header/Header.js +18 -4
  22. package/build/main//321/201omponents/Header/types.d.ts +10 -0
  23. package/build/main//321/201omponents/Loader/Loader.d.ts +1 -1
  24. package/build/main//321/201omponents/Loader/Loader.js +17 -2
  25. package/build/main//321/201omponents/Loader/types.d.ts +6 -0
  26. package/build/main//321/201omponents/Profile/Profile.js +4 -4
  27. package/build/main//321/201omponents/Stories/Stories.js +91 -38
  28. package/build/main//321/201omponents/Stories/types.d.ts +23 -7
  29. package/build/main//321/201omponents/Stories/types.js +5 -0
  30. package/build/main//321/201omponents/SyncLoader/SyncLoader.d.ts +4 -0
  31. package/build/main//321/201omponents/SyncLoader/SyncLoader.js +66 -0
  32. package/build/main//321/201omponents/SyncLoader/index.d.ts +1 -0
  33. package/build/main//321/201omponents/SyncLoader/index.js +1 -0
  34. package/build/main//321/201omponents/SyncLoader/types.d.ts +6 -0
  35. package/build/main//321/201omponents/SyncLoader/types.js +1 -0
  36. package/build/main//321/201omponents/index.d.ts +1 -0
  37. package/build/main//321/201omponents/index.js +1 -0
  38. package/package.json +4 -1
@@ -16,7 +16,7 @@ import { ReactComponent as CancelIcon } from '../../assets/icons/cancel-cross.sv
16
16
  import Button from '../Button';
17
17
  import Input from '../Input';
18
18
  import { TButtonColor, TButtonType } from '../Button/types';
19
- import { getIconColor } from '../../helpers';
19
+ 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) {
@@ -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: getIconColor(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.low, color: TButtonColor.blue, onClickFunction: function () { return confirmButtonFunction(value); } }) }))] })) })) })));
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.low, color: TButtonColor.blue, onClickFunction: function () { return confirmButtonFunction(value); } }) }))] })) })) })));
41
41
  };
42
42
  export default ActionModal;
@@ -14,14 +14,14 @@ import classNames from 'classnames';
14
14
  import { ReactComponent as FileIcon } from '../../assets/icons/file.svg';
15
15
  import { ReactComponent as RemoveIcon } from '../../assets/icons/close.svg';
16
16
  import { ReactComponent as DownloadIcon } from '../../assets/icons/download.svg';
17
- import { getIconColor } from '../../helpers';
17
+ import { getColor } from '../../helpers';
18
18
  import { DEFAULT_BLUE_ICON_COLOR, DEFAULT_GRAY_ICON_COLOR } from '../../constants';
19
19
  import '../../styles/stories.module.scss';
20
20
  var AttachedFile = function (_a) {
21
21
  var fileName = _a.fileName, weight = _a.weight, weightType = _a.weightType, _b = _a.isSpaceBetween, isSpaceBetween = _b === void 0 ? false : _b, _c = _a.onClickDownloadFile, onClickDownloadFile = _c === void 0 ? undefined : _c, _d = _a.onClickRemoveFile, onClickRemoveFile = _d === void 0 ? undefined : _d, _e = _a.isRemoveFile, isRemoveFile = _e === void 0 ? false : _e, _f = _a.isDownloadFile, isDownloadFile = _f === void 0 ? false : _f, _g = _a.width, width = _g === void 0 ? 100 : _g, fileColor = _a.fileColor, downloadColor = _a.downloadColor, removeColor = _a.removeColor;
22
- return (_jsxs("div", __assign({ style: { width: "".concat(width, "%") }, className: "smartapp-attached-file" }, { children: [_jsx("div", __assign({ className: "smartapp-attached-file--icon" }, { children: _jsx(FileIcon, { style: { color: getIconColor(fileColor, DEFAULT_GRAY_ICON_COLOR) } }) })), _jsxs("div", __assign({ className: classNames({
22
+ return (_jsxs("div", __assign({ style: { width: "".concat(width, "%") }, className: "smartapp-attached-file" }, { children: [_jsx("div", __assign({ className: "smartapp-attached-file--icon" }, { children: _jsx(FileIcon, { style: { color: getColor(fileColor, DEFAULT_GRAY_ICON_COLOR) } }) })), _jsxs("div", __assign({ className: classNames({
23
23
  'smartapp-attached-file__value': true,
24
24
  'justify-space-between': isSpaceBetween,
25
- }) }, { children: [_jsxs("div", __assign({ className: "smartapp-attached-file__value--info" }, { children: [_jsx("p", __assign({ className: "smartapp-attached-file__value--info__name" }, { children: fileName })), _jsx("p", __assign({ className: "smartapp-attached-file__value--info__weight" }, { children: "".concat(weight, " ").concat(weightType) }))] })), _jsxs("div", __assign({ className: "smartapp-attached-file__value--icons" }, { children: [onClickRemoveFile && isRemoveFile && (_jsx("div", __assign({ onClick: function () { return onClickRemoveFile(fileName); }, className: "smartapp-attached-file__value--icons__close" }, { children: _jsx(RemoveIcon, { style: { color: getIconColor(removeColor, DEFAULT_BLUE_ICON_COLOR) } }) }))), onClickDownloadFile && isDownloadFile && (_jsx("div", __assign({ onClick: function () { return onClickDownloadFile(fileName); }, className: "smartapp-attached-file__value--icons__download" }, { children: _jsx(DownloadIcon, { style: { color: getIconColor(downloadColor, DEFAULT_BLUE_ICON_COLOR) } }) })))] }))] }))] }), weight));
25
+ }) }, { children: [_jsxs("div", __assign({ className: "smartapp-attached-file__value--info" }, { children: [_jsx("p", __assign({ className: "smartapp-attached-file__value--info__name" }, { children: fileName })), _jsx("p", __assign({ className: "smartapp-attached-file__value--info__weight" }, { children: "".concat(weight, " ").concat(weightType) }))] })), _jsxs("div", __assign({ className: "smartapp-attached-file__value--icons" }, { children: [onClickRemoveFile && isRemoveFile && (_jsx("div", __assign({ onClick: function () { return onClickRemoveFile(fileName); }, className: "smartapp-attached-file__value--icons__close" }, { children: _jsx(RemoveIcon, { style: { color: getColor(removeColor, DEFAULT_BLUE_ICON_COLOR) } }) }))), onClickDownloadFile && isDownloadFile && (_jsx("div", __assign({ onClick: function () { return onClickDownloadFile(fileName); }, className: "smartapp-attached-file__value--icons__download" }, { children: _jsx(DownloadIcon, { style: { color: getColor(downloadColor, DEFAULT_BLUE_ICON_COLOR) } }) })))] }))] }))] }), weight));
26
26
  };
27
27
  export default AttachedFile;
@@ -1,4 +1,4 @@
1
1
  import { IAvatarProps } from './types';
2
2
  import '../../styles/stories.module.scss';
3
- declare const Avatar: ({ username, onClick, widthHeight }: IAvatarProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const Avatar: ({ username, avatar, onClick, size }: IAvatarProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default Avatar;
@@ -14,26 +14,26 @@ import { AvatarFontSizes } from './types';
14
14
  import '../../styles/stories.module.scss';
15
15
  var Avatar = function (_a) {
16
16
  var _b, _c, _d;
17
- var username = _a.username, _e = _a.onClick, onClick = _e === void 0 ? function () { return undefined; } : _e, _f = _a.widthHeight, widthHeight = _f === void 0 ? 44 : _f;
18
- var initials = (username === null || username === void 0 ? void 0 : username.split(' ').length) <= 2
19
- ? (_d = (_c = (_b = username === null || username === void 0 ? void 0 : username.split(' ')) === null || _b === void 0 ? void 0 : _b.map(function (n) { return n[0]; })) === null || _c === void 0 ? void 0 : _c.join('.')) === null || _d === void 0 ? void 0 : _d.toUpperCase()
17
+ var username = _a.username, avatar = _a.avatar, _e = _a.onClick, onClick = _e === void 0 ? function () { return undefined; } : _e, _f = _a.size, size = _f === void 0 ? 44 : _f;
18
+ var initials = username.split(' ').length <= 2
19
+ ? (_d = (_c = (_b = username === null || username === void 0 ? void 0 : username.split(' ')) === null || _b === void 0 ? void 0 : _b.map(function (n) { return n[0]; })) === null || _c === void 0 ? void 0 : _c.join('')) === null || _d === void 0 ? void 0 : _d.toUpperCase()
20
20
  : username[0].toUpperCase();
21
21
  var getFontSizeAvatar = function () {
22
- if (typeof widthHeight === 'number') {
23
- switch (widthHeight) {
24
- case (widthHeight = 24): {
25
- return AvatarFontSizes.small;
26
- }
27
- case (widthHeight = 32): {
28
- return AvatarFontSizes.average;
29
- }
30
- case (widthHeight = 44): {
31
- return AvatarFontSizes.high;
32
- }
22
+ switch (size) {
23
+ case (size = 24): {
24
+ return AvatarFontSizes.small;
25
+ }
26
+ case (size = 32): {
27
+ return AvatarFontSizes.average;
28
+ }
29
+ case (size = 44): {
30
+ return AvatarFontSizes.high;
31
+ }
32
+ case (size = 100): {
33
+ return AvatarFontSizes.greatest;
33
34
  }
34
35
  }
35
- return AvatarFontSizes.high;
36
36
  };
37
- return (_jsx("div", __assign({ style: { width: "".concat(widthHeight, "px"), height: "".concat(widthHeight, "px"), fontSize: getFontSizeAvatar() }, onClick: onClick, className: "smartapp-avatar" }, { children: initials })));
37
+ return (_jsx("div", __assign({ style: { width: "".concat(size, "px"), height: "".concat(size, "px"), fontSize: getFontSizeAvatar() }, onClick: onClick, className: "smartapp-avatar" }, { children: avatar ? _jsx("img", { src: avatar, alt: "avatar" }) : initials })));
38
38
  };
39
39
  export default Avatar;
@@ -1,10 +1,12 @@
1
1
  export interface IAvatarProps {
2
2
  username: string;
3
+ avatar?: string;
3
4
  onClick?: () => void;
4
- widthHeight?: 24 | 32 | 44;
5
+ size?: 24 | 32 | 44 | 100;
5
6
  }
6
7
  export declare enum AvatarFontSizes {
7
8
  small = "12px",
8
9
  average = "14px",
9
- high = "18px"
10
+ high = "18px",
11
+ greatest = "42px"
10
12
  }
@@ -3,4 +3,5 @@ export var AvatarFontSizes;
3
3
  AvatarFontSizes["small"] = "12px";
4
4
  AvatarFontSizes["average"] = "14px";
5
5
  AvatarFontSizes["high"] = "18px";
6
+ AvatarFontSizes["greatest"] = "42px";
6
7
  })(AvatarFontSizes || (AvatarFontSizes = {}));
@@ -11,11 +11,11 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { ReactComponent as CheckIcon } from '../../assets/icons/check-mark.svg';
14
- import { getIconColor } from '../../helpers';
14
+ import { getColor } from '../../helpers';
15
15
  import { DEFAULT_BLUE_ICON_COLOR } from '../../constants';
16
16
  import '../../styles/stories.module.scss';
17
17
  var CheckBox = function (_a) {
18
18
  var id = _a.id, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, iconColor = _a.iconColor, _d = _a.onChange, onChange = _d === void 0 ? function () { return undefined; } : _d;
19
- return (_jsx("div", __assign({ className: "smartapp-check-box" }, { children: _jsxs("label", __assign({ htmlFor: "cb-".concat(id) }, { children: [_jsx("input", { id: "cb-".concat(id), type: "checkbox", className: "smartapp-check-box__custom-check-box", disabled: disabled, checked: checked, onChange: onChange }), checked ? _jsx(CheckIcon, { style: { color: getIconColor(iconColor, DEFAULT_BLUE_ICON_COLOR) } }) : _jsx("span", { className: "checkmark" })] })) })));
19
+ return (_jsx("div", __assign({ className: "smartapp-check-box" }, { children: _jsxs("label", __assign({ htmlFor: "cb-".concat(id) }, { children: [_jsx("input", { id: "cb-".concat(id), type: "checkbox", className: "smartapp-check-box__custom-check-box", disabled: disabled, checked: checked, onChange: onChange }), checked ? _jsx(CheckIcon, { style: { color: getColor(iconColor, DEFAULT_BLUE_ICON_COLOR) } }) : _jsx("span", { className: "checkmark" })] })) })));
20
20
  };
21
21
  export default CheckBox;
@@ -12,11 +12,11 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { ReactComponent as CancelIcon } from '../../assets/icons/cancel-cross.svg';
14
14
  import Avatar from '../Avatar';
15
- import { getIconColor } from '../../helpers';
15
+ import { getColor } from '../../helpers';
16
16
  import { DEFAULT_GRAY_ICON_COLOR } from '../../constants';
17
17
  import '../../styles/stories.module.scss';
18
18
  var Chips = function (_a) {
19
19
  var name = _a.name, iconColor = _a.iconColor, _b = _a.onCancelFunction, onCancelFunction = _b === void 0 ? function () { return undefined; } : _b;
20
- return (_jsxs("div", __assign({ className: "smartapp-chips" }, { children: [_jsxs("div", __assign({ className: "smartapp-chips__info" }, { children: [_jsx(Avatar, { username: name, widthHeight: 24 }), _jsx("p", __assign({ className: "smartapp-chips__info--name" }, { children: name }))] })), _jsx("div", __assign({ onClick: function () { return onCancelFunction(name); }, className: "smartapp-chips__cancel-icon" }, { children: _jsx(CancelIcon, { style: { color: getIconColor(iconColor, DEFAULT_GRAY_ICON_COLOR) } }) }))] })));
20
+ return (_jsxs("div", __assign({ className: "smartapp-chips" }, { children: [_jsxs("div", __assign({ className: "smartapp-chips__info" }, { children: [_jsx(Avatar, { username: name, size: 24 }), _jsx("p", __assign({ className: "smartapp-chips__info--name" }, { children: name }))] })), _jsx("div", __assign({ onClick: function () { return onCancelFunction(name); }, className: "smartapp-chips__cancel-icon" }, { children: _jsx(CancelIcon, { style: { color: getColor(iconColor, DEFAULT_GRAY_ICON_COLOR) } }) }))] })));
21
21
  };
22
22
  export default Chips;
@@ -27,14 +27,14 @@ import '../../styles/stories.module.scss';
27
27
  var Control = function (_a) {
28
28
  var _b, _c, _d;
29
29
  var children = _a.children, props = __rest(_a, ["children"]);
30
- return (_jsxs(components.Control, __assign({}, props, { children: [((_b = props.selectProps) === null || _b === void 0 ? void 0 : _b.value) && (_jsx("div", __assign({ className: "smartapp-custom-select__control" }, { children: _jsx("span", { children: _jsx(Avatar, { widthHeight: 32, username: (_d = (_c = props === null || props === void 0 ? void 0 : props.selectProps) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.username }) }) }))), children] })));
30
+ return (_jsxs(components.Control, __assign({}, props, { children: [((_b = props.selectProps) === null || _b === void 0 ? void 0 : _b.value) && (_jsx("div", __assign({ className: "smartapp-custom-select__control" }, { children: _jsx("span", { children: _jsx(Avatar, { size: 32, username: (_d = (_c = props === null || props === void 0 ? void 0 : props.selectProps) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.username }) }) }))), children] })));
31
31
  };
32
32
  var Option = function (_a) {
33
33
  var _b, _c, _d;
34
34
  var props = __rest(_a, []);
35
- return (_jsx(components.Option, __assign({}, props, { children: _jsxs("div", __assign({ className: "smartapp-custom-select__option" }, { children: [_jsx("div", __assign({ className: "smartapp-custom-select__option--avatar" }, { children: _jsx(Avatar, { widthHeight: 32, username: (_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.username }) })), _jsxs("div", __assign({ className: "smartapp-custom-select__option--info" }, { children: [_jsxs("p", __assign({ className: "smartapp-custom-select__option--info__title" }, { children: [(_c = props === null || props === void 0 ? void 0 : props.data) === null || _c === void 0 ? void 0 : _c.username, " "] })), _jsxs("p", __assign({ className: "smartapp-custom-select__option--info__email" }, { children: [(_d = props === null || props === void 0 ? void 0 : props.data) === null || _d === void 0 ? void 0 : _d.email, " "] }))] }))] })) })));
35
+ return (_jsx(components.Option, __assign({}, props, { children: _jsxs("div", __assign({ className: "smartapp-custom-select__option" }, { children: [_jsx("div", __assign({ className: "smartapp-custom-select__option--avatar" }, { children: _jsx(Avatar, { size: 32, username: (_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.username }) })), _jsxs("div", __assign({ className: "smartapp-custom-select__option--info" }, { children: [_jsxs("p", __assign({ className: "smartapp-custom-select__option--info__title" }, { children: [(_c = props === null || props === void 0 ? void 0 : props.data) === null || _c === void 0 ? void 0 : _c.username, " "] })), _jsxs("p", __assign({ className: "smartapp-custom-select__option--info__email" }, { children: [(_d = props === null || props === void 0 ? void 0 : props.data) === null || _d === void 0 ? void 0 : _d.email, " "] }))] }))] })) })));
36
36
  };
37
- var DropdownIndicator = function (props) { return (_jsx(components.DropdownIndicator, __assign({}, props))); };
37
+ var DropdownIndicator = function (props) { return _jsx(components.DropdownIndicator, __assign({}, props)); };
38
38
  var IndicatorSeparator = function () { return null; };
39
39
  var CustomSelectPriority = function (_a) {
40
40
  var options = _a.options, defaultValue = _a.defaultValue, placeholder = _a.placeholder, onChange = _a.onChange, _b = _a.width, width = _b === void 0 ? 100 : _b;
@@ -15,7 +15,7 @@ import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
15
15
  import { ReactComponent as OrderIcon } from '../../assets/icons/order.svg';
16
16
  import { ReactComponent as DeleteIcon } from '../../assets/icons/close.svg';
17
17
  import CheckBox from '../Checkbox';
18
- import { getIconColor } from '../../helpers';
18
+ import { getColor } from '../../helpers';
19
19
  import { DEFAULT_BLUE_ICON_COLOR, DEFAULT_GRAY_ICON_COLOR } from '../../constants';
20
20
  import '../../styles/stories.module.scss';
21
21
  var DragAndDrop = function (_a) {
@@ -50,6 +50,6 @@ var DragAndDrop = function (_a) {
50
50
  var newOptions = reorderOptions(options, result.source.index, result.destination.index);
51
51
  onDragEndFunction(newOptions);
52
52
  };
53
- return (_jsx("div", __assign({ style: { width: "".concat(width, "%") }, className: "smartapp-drag-drop" }, { children: _jsx(DragDropContext, __assign({ onDragStart: onDragStart, onDragEnd: onDragEnd }, { children: _jsx(Droppable, __assign({ droppableId: "droppable" }, { children: function (provided) { return (_jsx("div", __assign({}, provided.droppableProps, { ref: provided.innerRef, className: "smartapp-drag-drop__container" }, { children: options === null || options === void 0 ? void 0 : options.map(function (instanceOption, index) { return (_jsx(Draggable, __assign({ draggableId: instanceOption.id, index: index }, { children: function (provided) { return (_jsxs("div", __assign({ ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { className: "smartapp-drag-drop__container--instance" }, { children: [_jsxs("div", __assign({ className: "smartapp-drag-drop__container--instance__info" }, { children: [isCheckbox(instanceOption) && onChangeIsCompletedOption && (_jsx(CheckBox, { id: instanceOption.id, checked: instanceOption.isCompleted, iconColor: checkboxColor, onChange: function () { return onChangeIsCompletedOption(instanceOption); } })), onChangeOption ? (_jsx("input", { onChange: function (e) { return onChangeOption && onChangeOption(e, instanceOption); }, defaultValue: instanceOption.defaultValue, className: "smartapp-drag-drop__container--instance__info--name", type: "text", enterKeyHint: "enter", placeholder: placeholder }, instanceOption === null || instanceOption === void 0 ? void 0 : instanceOption.id)) : (_jsx("p", __assign({ className: "smartapp-drag-drop__container--instance__info--name" }, { children: instanceOption.defaultValue })))] })), _jsxs("div", __assign({ className: "smartapp-drag-drop__container--instance__icons" }, { children: [_jsx(OrderIcon, { style: { color: getIconColor(orderColor, DEFAULT_GRAY_ICON_COLOR) } }), onClickDeleteOption && _jsx(DeleteIcon, { className: "cp", style: { color: getIconColor(deleteColor, DEFAULT_BLUE_ICON_COLOR) }, onClick: function () { return onClickDeleteOption(instanceOption); } })] }))] }))); } }), instanceOption.id)); }) }))); } })) })) })));
53
+ return (_jsx("div", __assign({ style: { width: "".concat(width, "%") }, className: "smartapp-drag-drop" }, { children: _jsx(DragDropContext, __assign({ onDragStart: onDragStart, onDragEnd: onDragEnd }, { children: _jsx(Droppable, __assign({ droppableId: "droppable" }, { children: function (provided) { return (_jsx("div", __assign({}, provided.droppableProps, { ref: provided.innerRef, className: "smartapp-drag-drop__container" }, { children: options === null || options === void 0 ? void 0 : options.map(function (instanceOption, index) { return (_jsx(Draggable, __assign({ draggableId: instanceOption.id, index: index }, { children: function (provided) { return (_jsxs("div", __assign({ ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { className: "smartapp-drag-drop__container--instance" }, { children: [_jsxs("div", __assign({ className: "smartapp-drag-drop__container--instance__info" }, { children: [isCheckbox(instanceOption) && onChangeIsCompletedOption && (_jsx(CheckBox, { id: instanceOption.id, checked: instanceOption.isCompleted, iconColor: checkboxColor, onChange: function () { return onChangeIsCompletedOption(instanceOption); } })), onChangeOption ? (_jsx("input", { onChange: function (e) { return onChangeOption && onChangeOption(e, instanceOption); }, defaultValue: instanceOption.defaultValue, className: "smartapp-drag-drop__container--instance__info--name", type: "text", enterKeyHint: "enter", placeholder: placeholder }, instanceOption === null || instanceOption === void 0 ? void 0 : instanceOption.id)) : (_jsx("p", __assign({ className: "smartapp-drag-drop__container--instance__info--name" }, { children: instanceOption.defaultValue })))] })), _jsxs("div", __assign({ className: "smartapp-drag-drop__container--instance__icons" }, { children: [_jsx(OrderIcon, { style: { color: getColor(orderColor, DEFAULT_GRAY_ICON_COLOR) } }), onClickDeleteOption && _jsx(DeleteIcon, { className: "cp", style: { color: getColor(deleteColor, DEFAULT_BLUE_ICON_COLOR) }, onClick: function () { return onClickDeleteOption(instanceOption); } })] }))] }))); } }), instanceOption.id)); }) }))); } })) })) })));
54
54
  };
55
55
  export default DragAndDrop;
@@ -11,11 +11,11 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { ReactComponent as ErrorIcon } from '../../assets/icons/error.svg';
14
- import { getIconColor } from '../../helpers';
14
+ import { getColor } from '../../helpers';
15
15
  import { DEFAULT_GRAY_ICON_COLOR } from '../../constants';
16
16
  import '../../styles/stories.module.scss';
17
17
  var Error = function (_a) {
18
18
  var _b = _a.title, title = _b === void 0 ? 'Ошибка' : _b, _c = _a.text, text = _c === void 0 ? 'Попробуйте еще раз' : _c, _d = _a.width, width = _d === void 0 ? 100 : _d, iconColor = _a.iconColor;
19
- return (_jsxs("div", __assign({ className: "smartapp-error", style: { width: "".concat(width, "%") } }, { children: [_jsx("div", __assign({ className: "smartapp-error__icon" }, { children: _jsx(ErrorIcon, { style: { color: getIconColor(iconColor, DEFAULT_GRAY_ICON_COLOR) } }) })), _jsx("p", __assign({ className: "smartapp-error__title" }, { children: title })), _jsx("p", __assign({ className: "smartapp-error__text" }, { children: text }))] })));
19
+ return (_jsxs("div", __assign({ className: "smartapp-error", style: { width: "".concat(width, "%") } }, { children: [_jsx("div", __assign({ className: "smartapp-error__icon" }, { children: _jsx(ErrorIcon, { style: { color: getColor(iconColor, DEFAULT_GRAY_ICON_COLOR) } }) })), _jsx("p", __assign({ className: "smartapp-error__title" }, { children: title })), _jsx("p", __assign({ className: "smartapp-error__text" }, { children: text }))] })));
20
20
  };
21
21
  export default Error;
@@ -1,4 +1,4 @@
1
1
  import { IHeaderProps } from './types';
2
2
  import '../../styles/stories.module.scss';
3
- declare const Header: ({ title, isBack, isRemove, onClickBack, onClickRemove, arrowColor, trashColor, }: IHeaderProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const Header: ({ title, isBack, isRemove, refreshIcon, onClickBack, onClickRemove, arrowColor, trashColor, platform, headerHeight, textSize, textColor, backgroundColor, }: IHeaderProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default Header;
@@ -10,13 +10,27 @@ 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 classNames from 'classnames';
13
14
  import { ReactComponent as ArrowBackIcon } from '../../assets/icons/arrow-back.svg';
14
15
  import { ReactComponent as TrashIcon } from '../../assets/icons/trash.svg';
15
- import { getIconColor } from '../../helpers';
16
- import { DEFAULT_BLACK_ICON_COLOR, DEFAULT_RED_ICON_COLOR } from '../../constants';
16
+ import { ReactComponent as RefreshIcon } from '../../assets/icons/refresh.svg';
17
+ import { getColor } from '../../helpers';
18
+ import { DEFAULT_BLACK_ICON_COLOR, DEFAULT_HEADER_BACKGROUND_COLOR, DEFAULT_HEADER_TEXT_COLOR, DEFAULT_RED_ICON_COLOR, FONT_SIZE, LINE_HEIGHT, PLATFORM, } from '../../constants';
17
19
  import '../../styles/stories.module.scss';
18
20
  var Header = function (_a) {
19
- var _b = _a.title, title = _b === void 0 ? '' : _b, _c = _a.isBack, isBack = _c === void 0 ? false : _c, _d = _a.isRemove, isRemove = _d === void 0 ? false : _d, _e = _a.onClickBack, onClickBack = _e === void 0 ? function () { return undefined; } : _e, _f = _a.onClickRemove, onClickRemove = _f === void 0 ? function () { return undefined; } : _f, arrowColor = _a.arrowColor, trashColor = _a.trashColor;
20
- return (_jsxs("div", __assign({ className: "smartapp-header" }, { children: [_jsxs("div", __assign({ className: "smartapp-header__info" }, { children: [isBack && (_jsx(ArrowBackIcon, { style: { color: getIconColor(arrowColor, DEFAULT_BLACK_ICON_COLOR) }, onClick: onClickBack, className: "smartapp-header__info--arrow-back" })), title && _jsx("p", __assign({ className: "smartapp-header__info--title" }, { children: title }))] })), isRemove && (_jsx("div", __assign({ onClick: onClickRemove, className: "smartapp-header__trash" }, { children: _jsx(TrashIcon, { style: { color: getIconColor(trashColor, DEFAULT_RED_ICON_COLOR) } }) })))] })));
21
+ var _b;
22
+ var _c = _a.title, title = _c === void 0 ? '' : _c, _d = _a.isBack, isBack = _d === void 0 ? false : _d, _e = _a.isRemove, isRemove = _e === void 0 ? false : _e, refreshIcon = _a.refreshIcon, _f = _a.onClickBack, onClickBack = _f === void 0 ? function () { return undefined; } : _f, _g = _a.onClickRemove, onClickRemove = _g === void 0 ? function () { return undefined; } : _g, arrowColor = _a.arrowColor, trashColor = _a.trashColor, _h = _a.platform, platform = _h === void 0 ? PLATFORM.web : _h, headerHeight = _a.headerHeight, _j = _a.textSize, textSize = _j === void 0 ? 'default' : _j, textColor = _a.textColor, backgroundColor = _a.backgroundColor;
23
+ var getHeaderStyles = function () { return ({
24
+ height: headerHeight && "".concat(headerHeight - 29, "px"),
25
+ fontSize: FONT_SIZE[textSize],
26
+ lineHeight: LINE_HEIGHT[textSize],
27
+ color: getColor(textColor, DEFAULT_HEADER_TEXT_COLOR),
28
+ background: getColor(backgroundColor, DEFAULT_HEADER_BACKGROUND_COLOR),
29
+ }); };
30
+ var renderRefreshIcon = function (_a) {
31
+ var isEnabled = _a.isEnabled, onClick = _a.onClick;
32
+ return (_jsx(RefreshIcon, { className: classNames({ 'smartapp-header__icons--refresh': isEnabled }), onClick: !isEnabled ? onClick : function () { } }));
33
+ };
34
+ return (_jsxs("div", __assign({ className: classNames((_b = { 'smartapp-header': true }, _b["smartapp-header__".concat(platform)] = true, _b)), style: getHeaderStyles() }, { children: [_jsxs("div", __assign({ className: "smartapp-header__info" }, { children: [isBack && (_jsx(ArrowBackIcon, { style: { color: getColor(arrowColor, DEFAULT_BLACK_ICON_COLOR) }, onClick: onClickBack, className: "smartapp-header__info--arrow-back" })), title && _jsx("p", __assign({ className: "smartapp-header__info--title" }, { children: title }))] })), _jsxs("div", __assign({ className: "smartapp-header__icons" }, { children: [isRemove && (_jsx("div", __assign({ onClick: onClickRemove, className: "smartapp-header__icons--trash" }, { children: _jsx(TrashIcon, { style: { color: getColor(trashColor, DEFAULT_RED_ICON_COLOR) } }) }))), refreshIcon && renderRefreshIcon(refreshIcon)] }))] })));
21
35
  };
22
36
  export default Header;
@@ -1,9 +1,19 @@
1
+ export type TRefreshIcon = {
2
+ isEnabled: boolean;
3
+ onClick: () => void;
4
+ };
1
5
  export interface IHeaderProps {
2
6
  title?: string;
3
7
  isBack?: boolean;
4
8
  isRemove?: boolean;
9
+ refreshIcon?: TRefreshIcon;
5
10
  onClickBack?: () => void;
6
11
  onClickRemove?: () => void;
7
12
  arrowColor?: string;
8
13
  trashColor?: string;
14
+ platform?: 'web' | 'ios' | 'android';
15
+ headerHeight?: number;
16
+ textSize?: 'small' | 'default' | 'large';
17
+ textColor?: string;
18
+ backgroundColor?: string;
9
19
  }
@@ -1,4 +1,4 @@
1
1
  import { ILoaderProps } from './types';
2
2
  import '../../styles/stories.module.scss';
3
- declare const Loader: ({ isLoader, title }: ILoaderProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const Loader: ({ isLoader, isFullScreen, isTextItalic, title, textSize, width, iconSize, backgroundColor, }: ILoaderProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default Loader;
@@ -11,9 +11,24 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { ColorRing } from 'react-loader-spinner';
14
+ import classNames from 'classnames';
15
+ import { DEFAULT_GRAY_LOADER_BACKGROUND_COLOR, DEFAULT_WHITE_LOADER_BACKGROUND_COLOR, FONT_SIZE, LINE_HEIGHT, } from '../../constants';
16
+ import { getColor } from '../../helpers';
14
17
  import '../../styles/stories.module.scss';
15
18
  var Loader = function (_a) {
16
- var _b = _a.isLoader, isLoader = _b === void 0 ? false : _b, title = _a.title;
17
- return (_jsx("div", __assign({ className: "smartapp-loader-wrapper" }, { children: _jsxs("div", __assign({ className: "smartapp-loader" }, { children: [_jsx(ColorRing, { visible: isLoader, height: "32", width: "32", ariaLabel: "blocks-loading", wrapperStyle: {}, wrapperClass: "blocks-wrapper", colors: ['#4799E3', '#4799E3', '#4799E3', '#4799E3', '#4799E3'] }), title && _jsx("p", __assign({ className: "smartapp-loader__title" }, { children: title }))] })) })));
19
+ var _b = _a.isLoader, isLoader = _b === void 0 ? false : _b, _c = _a.isFullScreen, isFullScreen = _c === void 0 ? true : _c, _d = _a.isTextItalic, isTextItalic = _d === void 0 ? false : _d, title = _a.title, _e = _a.textSize, textSize = _e === void 0 ? 'small' : _e, _f = _a.width, width = _f === void 0 ? 150 : _f, _g = _a.iconSize, iconSize = _g === void 0 ? 32 : _g, backgroundColor = _a.backgroundColor;
20
+ var getTextStyles = function () { return ({
21
+ fontSize: FONT_SIZE[textSize],
22
+ fontStyle: isTextItalic ? 'italic' : 'normal',
23
+ lineHeight: LINE_HEIGHT[textSize],
24
+ }); };
25
+ var getBackgroundColor = function () {
26
+ var defaultColor = isFullScreen ? DEFAULT_GRAY_LOADER_BACKGROUND_COLOR : DEFAULT_WHITE_LOADER_BACKGROUND_COLOR;
27
+ return getColor(backgroundColor, defaultColor);
28
+ };
29
+ return (_jsx("div", __assign({ className: classNames({
30
+ 'smartapp-loader-wrapper': true,
31
+ 'smartapp-loader-wrapper__full-screen': isFullScreen,
32
+ }), style: { background: getBackgroundColor() } }, { children: _jsxs("div", __assign({ className: "smartapp-loader", style: { width: "".concat(width, "px") } }, { children: [_jsx(ColorRing, { visible: isLoader, height: iconSize, width: iconSize, ariaLabel: "blocks-loading", wrapperStyle: {}, wrapperClass: "blocks-wrapper", colors: ['#4799E3', '#4799E3', '#4799E3', '#4799E3', '#4799E3'] }), title && _jsx("p", __assign({ className: "smartapp-loader__title", style: getTextStyles() }, { children: title }))] })) })));
18
33
  };
19
34
  export default Loader;
@@ -1,4 +1,10 @@
1
1
  export interface ILoaderProps {
2
2
  isLoader: boolean;
3
+ isFullScreen?: boolean;
4
+ isTextItalic?: boolean;
3
5
  title?: string;
6
+ textSize?: 'small' | 'default' | 'large';
7
+ width?: number;
8
+ iconSize?: number;
9
+ backgroundColor?: string;
4
10
  }
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useEffect, useRef } from 'react';
14
14
  import { ReactComponent as LogoutIcon } from '../../assets/icons/logout.svg';
15
15
  import { ReactComponent as AddProfileIcon } from '../../assets/icons/plus.svg';
16
- import { getIconColor } from '../../helpers';
16
+ import { getColor } from '../../helpers';
17
17
  import { DEFAULT_BLUE_ICON_COLOR, DEFAULT_BLUE_LIGHT_ICON_COLOR } from '../../constants';
18
18
  import '../../styles/stories.module.scss';
19
19
  var Profile = function (_a) {
@@ -33,9 +33,9 @@ var Profile = function (_a) {
33
33
  document.removeEventListener('mousedown', checkIfClickedOutside);
34
34
  };
35
35
  }, [isShowProfile, onChange]);
36
- return (_jsxs("div", __assign({ ref: ref, className: "smartapp-profile__container" }, { children: [_jsx("div", __assign({ onClick: function () { return onChange(!isShowProfile); }, className: "smartapp-profile__avatar" }, { children: initials })), isShowProfile && (_jsxs("div", __assign({ style: { width: "".concat(width, "%") }, className: "smartapp-profile" }, { children: [_jsxs("div", __assign({ className: "smartapp-profile__current-profile" }, { children: [_jsxs("div", __assign({ className: "smartapp-profile__current-profile--info" }, { children: [_jsx("div", __assign({ className: "smartapp-profile__avatar" }, { children: initials })), _jsxs("div", __assign({ className: "smartapp-profile__current-profile--info__data" }, { children: [_jsx("p", __assign({ className: "smartapp-profile__current-profile--info__data--username" }, { children: username })), email && _jsx("p", __assign({ className: "smartapp-profile__current-profile--info__data--email" }, { children: email }))] }))] })), _jsx("div", __assign({ onClick: onClickLogout, className: "smartapp-profile__current-profile--logout" }, { children: _jsx(LogoutIcon, { style: { color: getIconColor(logoutColor, DEFAULT_BLUE_ICON_COLOR) } }) }))] })), isMultipleProfile && (_jsxs("div", __assign({ onClick: onClickAddProfile, className: "smartapp-profile__add-profile" }, { children: [_jsx("div", __assign({ className: "smartapp-profile__add-profile--icon" }, { children: _jsx(AddProfileIcon, { style: {
37
- stroke: getIconColor(addProfileColor, DEFAULT_BLUE_ICON_COLOR),
38
- color: getIconColor(addProfileBackgroundColor, DEFAULT_BLUE_LIGHT_ICON_COLOR)
36
+ return (_jsxs("div", __assign({ ref: ref, className: "smartapp-profile__container" }, { children: [_jsx("div", __assign({ onClick: function () { return onChange(!isShowProfile); }, className: "smartapp-profile__avatar" }, { children: initials })), isShowProfile && (_jsxs("div", __assign({ style: { width: "".concat(width, "%") }, className: "smartapp-profile" }, { children: [_jsxs("div", __assign({ className: "smartapp-profile__current-profile" }, { children: [_jsxs("div", __assign({ className: "smartapp-profile__current-profile--info" }, { children: [_jsx("div", __assign({ className: "smartapp-profile__avatar" }, { children: initials })), _jsxs("div", __assign({ className: "smartapp-profile__current-profile--info__data" }, { children: [_jsx("p", __assign({ className: "smartapp-profile__current-profile--info__data--username" }, { children: username })), email && _jsx("p", __assign({ className: "smartapp-profile__current-profile--info__data--email" }, { children: email }))] }))] })), _jsx("div", __assign({ onClick: onClickLogout, className: "smartapp-profile__current-profile--logout" }, { children: _jsx(LogoutIcon, { style: { color: getColor(logoutColor, DEFAULT_BLUE_ICON_COLOR) } }) }))] })), isMultipleProfile && (_jsxs("div", __assign({ onClick: onClickAddProfile, className: "smartapp-profile__add-profile" }, { children: [_jsx("div", __assign({ className: "smartapp-profile__add-profile--icon" }, { children: _jsx(AddProfileIcon, { style: {
37
+ stroke: getColor(addProfileColor, DEFAULT_BLUE_ICON_COLOR),
38
+ color: getColor(addProfileBackgroundColor, DEFAULT_BLUE_LIGHT_ICON_COLOR)
39
39
  } }) })), _jsx("p", __assign({ className: "smartapp-profile__add-profile--title" }, { children: "\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u0430\u043A\u043A\u0430\u0443\u043D\u0442" }))] })))] })))] })));
40
40
  };
41
41
  export default Profile;
@@ -16,9 +16,11 @@ import { isNull, sortBy } from 'lodash';
16
16
  import Stories from 'react-insta-stories';
17
17
  import Popup from 'reactjs-popup';
18
18
  import { useSwipeable } from 'react-swipeable';
19
+ import { isEmpty } from 'lodash';
19
20
  import { ReactComponent as CloseStoriesIcon } from '../../assets/icons/close-stories.svg';
20
- import { STORY_BACKGROUND_TYPES } from './types';
21
- import { BUTTON_PADDING, DEFAULT_FONT_FAMILY, MAX_PADDING_FOR_IMAGE, PLATFORM, } from '../../constants';
21
+ import { STORY_BACKGROUND_TYPES, STORY_TYPE, } from './types';
22
+ import { BUTTON_PADDING, DEFAULT_BACKGROUND_BUTTON_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_TEXT_BUTTON_COLOR, MAX_PADDING_FOR_IMAGE, PLATFORM, } from '../../constants';
23
+ import { getColor, isAndroidPlatform, isIosPlatform, isWebPlatform } from '../../helpers';
22
24
  import '../../styles/stories.module.scss';
23
25
  var storyItemBaseStyles = {
24
26
  height: '100%',
@@ -27,9 +29,9 @@ var storyItemBaseStyles = {
27
29
  var progressContainerStyles = function (platform) { return ({
28
30
  gap: '12px',
29
31
  width: '100%',
30
- maxWidth: platform === PLATFORM.ios || platform === PLATFORM.android ? '139px' : '198px',
32
+ maxWidth: isIosPlatform(platform) || isAndroidPlatform(platform) ? '139px' : '198px',
31
33
  filter: 'none',
32
- paddingTop: platform === PLATFORM.web ? '22px' : platform === PLATFORM.ios ? '21px' : '26px',
34
+ paddingTop: isWebPlatform(platform) ? '22px' : isIosPlatform(platform) ? '21px' : '26px',
33
35
  paddingLeft: '0',
34
36
  paddingRight: '0',
35
37
  paddingBottom: '0',
@@ -63,12 +65,10 @@ var StoriesComponent = function (_a) {
63
65
  var id = _a.id;
64
66
  return id === activeStoryId;
65
67
  });
66
- var getStoryStyles = function (story) {
67
- var _a, _b;
68
- if (((_a = story === null || story === void 0 ? void 0 : story.backgroundSource) === null || _a === void 0 ? void 0 : _a.type) === STORY_BACKGROUND_TYPES.color) {
69
- return __assign(__assign({}, storyItemBaseStyles), { background: story.backgroundSource.value });
70
- }
71
- return __assign(__assign({}, storyItemBaseStyles), { backgroundImage: "url(".concat((_b = story === null || story === void 0 ? void 0 : story.backgroundSource) === null || _b === void 0 ? void 0 : _b.value, ")"), backgroundSize: 'cover' });
68
+ var getStoryStyles = function (_a) {
69
+ var type = _a.type, value = _a.value;
70
+ return type === STORY_BACKGROUND_TYPES.color
71
+ ? __assign(__assign({}, storyItemBaseStyles), { background: value }) : __assign(__assign({}, storyItemBaseStyles), { backgroundImage: "url(".concat(value, ")"), backgroundSize: 'cover' });
72
72
  };
73
73
  var changeActiveGroupStories = function (groupStoriesItem) {
74
74
  setActiveGroupStories(groupStoriesItem);
@@ -99,10 +99,12 @@ var StoriesComponent = function (_a) {
99
99
  }
100
100
  };
101
101
  var onPrevious = function () { return activeStoryId === stories[0].id && handlePrevious(); };
102
- var onStoryStart = function () {
102
+ var onStoryStart = function (storyIndex) {
103
+ var isVideoStory = stories[storyIndex].type === STORY_TYPE.video;
104
+ isVideoStory && setActiveStoryId(stories[storyIndex].id);
103
105
  var story = stories.find(function (_a) {
104
106
  var id = _a.id;
105
- return id === activeStoryId;
107
+ return id === stories[storyIndex].id;
106
108
  });
107
109
  var isLastStory = stories.at(-1).id === story.id;
108
110
  if (!story.viewed && changeStoryToViewed) {
@@ -112,44 +114,94 @@ var StoriesComponent = function (_a) {
112
114
  changeGroupStoriesToViewed(activeGroupStories);
113
115
  }
114
116
  };
115
- var getStories = function () { return stories.map(function (story) { return ({
116
- content: function () {
117
- // eslint-disable-next-line react-hooks/rules-of-hooks
118
- useEffect(function () {
119
- setActiveStoryId(story.id);
120
- var storyWrapper = document.querySelector('.smartapp-stories');
121
- var storyWrapperHeight = (storyWrapper === null || storyWrapper === void 0 ? void 0 : storyWrapper.getBoundingClientRect().height) || 0;
122
- var storyContent = document.querySelector('.smartapp-stories__story');
123
- var storyContentHeight = (storyContent === null || storyContent === void 0 ? void 0 : storyContent.getBoundingClientRect().height) || 0;
124
- var buttonElement = document.querySelector('.smartapp-stories__story--button');
125
- var buttonElementHeight = buttonElement ? (buttonElement.getBoundingClientRect().height + BUTTON_PADDING) : 0;
126
- var padding = (storyWrapperHeight - storyContentHeight - buttonElementHeight) / 2;
127
- var paddingTop = (padding > MAX_PADDING_FOR_IMAGE && story.image) ? "".concat(MAX_PADDING_FOR_IMAGE, "px") : "".concat(padding, "px");
128
- storyContent === null || storyContent === void 0 ? void 0 : storyContent.style.setProperty('--padding', paddingTop);
129
- }, []);
130
- return (_jsx("div", __assign({ style: getStoryStyles(story) }, { children: _jsxs("div", __assign({ style: { fontFamily: "".concat(fontFamily, ", sans-serif") }, className: "smartapp-stories__story" }, { children: [story.image && _jsx("div", __assign({ className: "smartapp-stories__story--image" }, { children: _jsx("img", { src: story.image, alt: "" }) })), story.title && _jsx("div", __assign({ className: "smartapp-stories__story--title" }, { children: story.title })), story.body && _jsx("div", __assign({ className: "smartapp-stories__story--body" }, { children: story.body })), story.button && (_jsx("div", __assign({ className: classNames('smartapp-stories__story--button', "smartapp-stories__story--button__".concat(platform)), onClick: story.button.action }, { children: story.button.text })))] })) }), story.id));
131
- },
132
- }); }); };
117
+ var getImageContent = function (_a) {
118
+ var id = _a.id, title = _a.title, body = _a.body, backgroundSource = _a.backgroundSource, button = _a.button, image = _a.image;
119
+ return ({
120
+ content: function () {
121
+ // eslint-disable-next-line react-hooks/rules-of-hooks
122
+ useEffect(function () {
123
+ setActiveStoryId(id);
124
+ var storyWrapper = document.querySelector('.smartapp-stories');
125
+ var storyWrapperHeight = (storyWrapper === null || storyWrapper === void 0 ? void 0 : storyWrapper.getBoundingClientRect().height) || 0;
126
+ var storyContent = document.querySelector('.smartapp-stories__story');
127
+ var storyContentHeight = (storyContent === null || storyContent === void 0 ? void 0 : storyContent.getBoundingClientRect().height) || 0;
128
+ var buttonElement = document.querySelector('.smartapp-stories__story--button');
129
+ var buttonElementHeight = buttonElement ? (buttonElement.getBoundingClientRect().height + BUTTON_PADDING) : 0;
130
+ var padding = (storyWrapperHeight - storyContentHeight - buttonElementHeight) / 2;
131
+ var paddingTop = (padding > MAX_PADDING_FOR_IMAGE && image) ? "".concat(MAX_PADDING_FOR_IMAGE, "px") : "".concat(padding, "px");
132
+ storyContent === null || storyContent === void 0 ? void 0 : storyContent.style.setProperty('--padding', paddingTop);
133
+ }, []);
134
+ return (_jsx("div", __assign({ style: getStoryStyles(backgroundSource) }, { children: _jsxs("div", __assign({ style: { fontFamily: "".concat(fontFamily, ", sans-serif") }, className: "smartapp-stories__story" }, { children: [image && _jsx("div", __assign({ className: "smartapp-stories__story--image" }, { children: _jsx("img", { src: image, alt: "" }) })), title && _jsx("div", __assign({ className: "smartapp-stories__story--title" }, { children: title })), body && _jsx("div", __assign({ className: "smartapp-stories__story--body" }, { children: body })), button && (_jsx("div", __assign({ style: {
135
+ color: getColor(button.textColor, DEFAULT_TEXT_BUTTON_COLOR),
136
+ background: getColor(button.backgroundColor, DEFAULT_BACKGROUND_BUTTON_COLOR),
137
+ }, className: classNames('smartapp-stories__story--button', "smartapp-stories__story--button__".concat(platform)), onClick: button.action }, { children: button.text })))] })) }), id));
138
+ },
139
+ });
140
+ };
141
+ var getVideoContent = function (_a) {
142
+ var url = _a.url;
143
+ return ({
144
+ type: STORY_TYPE.video,
145
+ url: url,
146
+ });
147
+ };
148
+ var getStories = function () { return stories.map(function (story) { return story.type === STORY_TYPE.image ? getImageContent(story) : getVideoContent(story); }); };
133
149
  var swipeableHandlers = useSwipeable({
134
150
  trackMouse: true,
135
151
  onSwipedLeft: function () { return handleNext(); },
136
152
  onSwipedRight: function () { return handlePrevious(); },
137
153
  });
138
154
  useEffect(function () {
139
- var _a;
140
155
  var sortedStories = sortStoriesByOrder((groupStories === null || groupStories === void 0 ? void 0 : groupStories.stories) || []);
141
156
  setActiveGroupStories(groupStories);
142
157
  setStories(sortedStories);
143
- setActiveStoryId((groupStories === null || groupStories === void 0 ? void 0 : groupStories.stories) ? (_a = sortedStories[0]) === null || _a === void 0 ? void 0 : _a.id : null);
144
158
  }, [groupStories]);
145
159
  useEffect(function () {
146
- var _a, _b;
160
+ var video = document.querySelector('video');
161
+ var pauseVideosOnBackground = function () {
162
+ var backgroundVideos = document.querySelectorAll("#background_video_".concat(activeStoryId));
163
+ backgroundVideos.forEach(function (video) { return video.pause(); });
164
+ };
165
+ var playVideosOnBackground = function () {
166
+ var backgroundVideos = document.querySelectorAll("#background_video_".concat(activeStoryId));
167
+ backgroundVideos.forEach(function (video) { return video.play(); });
168
+ };
169
+ video === null || video === void 0 ? void 0 : video.addEventListener("play", playVideosOnBackground);
170
+ video === null || video === void 0 ? void 0 : video.addEventListener("pause", pauseVideosOnBackground);
171
+ return function () {
172
+ video === null || video === void 0 ? void 0 : video.removeEventListener("play", playVideosOnBackground);
173
+ video === null || video === void 0 ? void 0 : video.removeEventListener("pause", pauseVideosOnBackground);
174
+ };
175
+ }, [activeStoryId]);
176
+ useEffect(function () {
147
177
  var popupElement = document.querySelector('.smartapp-stories-content');
148
- var background = ((_a = activeStory === null || activeStory === void 0 ? void 0 : activeStory.backgroundSource) === null || _a === void 0 ? void 0 : _a.type) === STORY_BACKGROUND_TYPES.color
149
- ? activeStory.backgroundSource.value
150
- : "url(".concat((_b = activeStory === null || activeStory === void 0 ? void 0 : activeStory.backgroundSource) === null || _b === void 0 ? void 0 : _b.value, ")");
151
- popupElement === null || popupElement === void 0 ? void 0 : popupElement.style.setProperty('--background', background);
152
- }, [activeStory]);
178
+ var videoWrapper = document.querySelector('.smartapp-stories-content > div > div > div:nth-child(2) > div');
179
+ if (activeStory) {
180
+ if (activeStory.type === STORY_TYPE.image) {
181
+ var _a = activeStory.backgroundSource, type = _a.type, value = _a.value;
182
+ var prevBackgroundVideos = document.querySelectorAll(".smartapp-stories-content__background-video");
183
+ var background = type === STORY_BACKGROUND_TYPES.color ? value : "url(".concat(value, ")");
184
+ !isEmpty(prevBackgroundVideos) && prevBackgroundVideos.forEach(function (video) { return video.remove(); });
185
+ isWebPlatform(platform) && (popupElement === null || popupElement === void 0 ? void 0 : popupElement.style.setProperty('--background', background));
186
+ }
187
+ else {
188
+ var prevBackgroundVideos = document.querySelectorAll(".smartapp-stories-content__background-video");
189
+ !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
+ if (isWebPlatform(platform)) {
198
+ popupElement === null || popupElement === void 0 ? void 0 : popupElement.style.removeProperty('--background');
199
+ popupElement === null || popupElement === void 0 ? void 0 : popupElement.appendChild(video);
200
+ }
201
+ videoWrapper === null || videoWrapper === void 0 ? void 0 : videoWrapper.appendChild(video.cloneNode(true));
202
+ }
203
+ }
204
+ }, [platform, activeStory]);
153
205
  if (isNull(activeGroupStories)) {
154
206
  return null;
155
207
  }
@@ -157,6 +209,7 @@ var StoriesComponent = function (_a) {
157
209
  'smartapp-stories': true
158
210
  },
159
211
  _b["smartapp-stories__".concat(platform)] = true,
212
+ _b['smartapp-stories__video'] = (activeStory === null || activeStory === void 0 ? void 0 : activeStory.type) === STORY_TYPE.video,
160
213
  _b['smartapp-stories__animate-right'] = isAnimateToRight,
161
214
  _b['smartapp-stories__animate-left'] = isAnimateToLeft,
162
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 = {