@expressms/smartapp-ui 1.1.5 → 1.1.6

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 (37) hide show
  1. package/build/main/assets/icons/check-mark.svg +2 -2
  2. package/build/main/assets/icons/notification-error.svg +3 -0
  3. package/build/main/assets/icons/notification-info.svg +5 -0
  4. package/build/main/assets/icons/notification-success.svg +4 -0
  5. package/build/main/assets/icons/notification-warning.svg +5 -0
  6. package/build/main/constants/constants.d.ts +3 -2
  7. package/build/main/constants/constants.js +3 -2
  8. package/build/main/helpers/index.d.ts +1 -1
  9. package/build/main/helpers/index.js +1 -1
  10. package/build/main/styles/stories.module.scss +178 -54
  11. package/build/main/styles/styles.min.css +1 -1
  12. package/build/main//321/201omponents/Checkbox/Checkbox.d.ts +1 -1
  13. package/build/main//321/201omponents/Checkbox/Checkbox.js +7 -3
  14. package/build/main//321/201omponents/Checkbox/types.d.ts +4 -3
  15. package/build/main//321/201omponents/DragAndDrop/DragAndDrop.js +1 -1
  16. package/build/main//321/201omponents/Header/Header.d.ts +1 -1
  17. package/build/main//321/201omponents/Header/Header.js +2 -2
  18. package/build/main//321/201omponents/Header/types.d.ts +2 -0
  19. package/build/main//321/201omponents/Notification/Notification.d.ts +4 -0
  20. package/build/main//321/201omponents/Notification/Notification.js +40 -0
  21. package/build/main//321/201omponents/Notification/index.d.ts +1 -0
  22. package/build/main//321/201omponents/Notification/index.js +1 -0
  23. package/build/main//321/201omponents/Notification/types.d.ts +14 -0
  24. package/build/main//321/201omponents/Notification/types.js +1 -0
  25. package/build/main//321/201omponents/RadioButton/RadioButton.d.ts +4 -0
  26. package/build/main//321/201omponents/RadioButton/RadioButton.js +25 -0
  27. package/build/main//321/201omponents/RadioButton/index.d.ts +1 -0
  28. package/build/main//321/201omponents/RadioButton/index.js +1 -0
  29. package/build/main//321/201omponents/RadioButton/types.d.ts +8 -0
  30. package/build/main//321/201omponents/RadioButton/types.js +1 -0
  31. package/build/main//321/201omponents/Stories/Stories.js +22 -18
  32. package/build/main//321/201omponents/Toggle/Toggle.d.ts +1 -1
  33. package/build/main//321/201omponents/Toggle/Toggle.js +11 -2
  34. package/build/main//321/201omponents/Toggle/types.d.ts +4 -1
  35. package/build/main//321/201omponents/index.d.ts +2 -0
  36. package/build/main//321/201omponents/index.js +2 -0
  37. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  import { ICheckBoxProps } from './types';
2
2
  import '../../styles/stories.module.scss';
3
- declare const CheckBox: ({ id, disabled, checked, iconColor, onChange }: ICheckBoxProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const CheckBox: ({ id, isDisabled, isChecked, checkedColor, checkedHoverColor, onChange }: ICheckBoxProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default CheckBox;
@@ -10,12 +10,16 @@ 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 } from 'react';
13
14
  import { ReactComponent as CheckIcon } from '../../assets/icons/check-mark.svg';
14
15
  import { getColor } from '../../helpers';
15
- import { DEFAULT_BLUE_ICON_COLOR } from '../../constants';
16
+ import { DEFAULT_BLUE_ICON_COLOR, DEFAULT_BLUE_ICON_HOVER_COLOR } from '../../constants';
16
17
  import '../../styles/stories.module.scss';
17
18
  var CheckBox = function (_a) {
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: getColor(iconColor, DEFAULT_BLUE_ICON_COLOR) } }) : _jsx("span", { className: "checkmark" })] })) })));
19
+ var id = _a.id, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, _c = _a.isChecked, isChecked = _c === void 0 ? false : _c, checkedColor = _a.checkedColor, checkedHoverColor = _a.checkedHoverColor, _d = _a.onChange, onChange = _d === void 0 ? function () { return undefined; } : _d;
20
+ useEffect(function () {
21
+ document.documentElement.style.setProperty('--checkbox-hover-color', getColor(checkedHoverColor, DEFAULT_BLUE_ICON_HOVER_COLOR));
22
+ }, [checkedHoverColor]);
23
+ 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: isDisabled, checked: isChecked, onChange: onChange }), isChecked ? _jsx(CheckIcon, { style: { color: getColor(checkedColor, DEFAULT_BLUE_ICON_COLOR) } }) : _jsx("span", { className: "checkmark" })] })) })));
20
24
  };
21
25
  export default CheckBox;
@@ -1,7 +1,8 @@
1
1
  export interface ICheckBoxProps {
2
2
  id: string;
3
- disabled?: boolean;
4
- checked?: boolean;
5
- iconColor?: string;
3
+ isDisabled?: boolean;
4
+ isChecked?: boolean;
5
+ checkedColor?: string;
6
+ checkedHoverColor?: string;
6
7
  onChange?: () => void;
7
8
  }
@@ -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: 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)); }) }))); } })) })) })));
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, isChecked: instanceOption.isCompleted, checkedColor: 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;
@@ -1,4 +1,4 @@
1
1
  import { IHeaderProps } from './types';
2
2
  import '../../styles/stories.module.scss';
3
- declare const Header: ({ title, isBack, isRemove, refreshIcon, onClickBack, onClickRemove, arrowColor, trashColor, platform, headerHeight, textSize, textColor, backgroundColor, }: IHeaderProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const Header: ({ title, isBack, isRemove, refreshIcon, customIcon, onClickBack, onClickRemove, arrowColor, trashColor, platform, headerHeight, textSize, textColor, backgroundColor, }: IHeaderProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default Header;
@@ -19,7 +19,7 @@ import { DEFAULT_BLACK_ICON_COLOR, DEFAULT_HEADER_BACKGROUND_COLOR, DEFAULT_HEAD
19
19
  import '../../styles/stories.module.scss';
20
20
  var Header = function (_a) {
21
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;
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, customIcon = _a.customIcon, _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
23
  var getHeaderStyles = function () { return ({
24
24
  height: headerHeight && "".concat(headerHeight - 29, "px"),
25
25
  fontSize: FONT_SIZE[textSize],
@@ -31,6 +31,6 @@ var Header = function (_a) {
31
31
  var isEnabled = _a.isEnabled, onClick = _a.onClick;
32
32
  return (_jsx(RefreshIcon, { className: classNames({ 'smartapp-header__icons--refresh': isEnabled }), onClick: !isEnabled ? onClick : function () { } }));
33
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)] }))] })));
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), customIcon] }))] })));
35
35
  };
36
36
  export default Header;
@@ -1,3 +1,4 @@
1
+ import { ReactElement } from 'react';
1
2
  export type TRefreshIcon = {
2
3
  isEnabled: boolean;
3
4
  onClick: () => void;
@@ -7,6 +8,7 @@ export interface IHeaderProps {
7
8
  isBack?: boolean;
8
9
  isRemove?: boolean;
9
10
  refreshIcon?: TRefreshIcon;
11
+ customIcon?: ReactElement;
10
12
  onClickBack?: () => void;
11
13
  onClickRemove?: () => void;
12
14
  arrowColor?: string;
@@ -0,0 +1,4 @@
1
+ import { INotificationProps } from './types';
2
+ import '../../styles/stories.module.scss';
3
+ declare const Notification: ({ isShown, type, isAutoHidden, hideDuration, platform, message, action, hideNotification, }: INotificationProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default Notification;
@@ -0,0 +1,40 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useEffect } from 'react';
14
+ import Popup from 'reactjs-popup';
15
+ import { ReactComponent as NotificationSuccessIcon } from '../../assets/icons/notification-success.svg';
16
+ import { ReactComponent as NotificationInfoIcon } from '../../assets/icons/notification-info.svg';
17
+ import { ReactComponent as NotificationWarningIcon } from '../../assets/icons/notification-warning.svg';
18
+ import { ReactComponent as NotificationErrorIcon } from '../../assets/icons/notification-error.svg';
19
+ import { CANCEL_ACTION_TEXT, PLATFORM } from '../../constants';
20
+ import { getClassNames } from '../../helpers';
21
+ import '../../styles/stories.module.scss';
22
+ var NOTIFICATION_ICONS = {
23
+ success: _jsx(NotificationSuccessIcon, {}),
24
+ info: _jsx(NotificationInfoIcon, {}),
25
+ warning: _jsx(NotificationWarningIcon, {}),
26
+ error: _jsx(NotificationErrorIcon, {}),
27
+ };
28
+ var Notification = function (_a) {
29
+ var isShown = _a.isShown, _b = _a.type, type = _b === void 0 ? 'success' : _b, _c = _a.isAutoHidden, isAutoHidden = _c === void 0 ? true : _c, _d = _a.hideDuration, hideDuration = _d === void 0 ? 3000 : _d, _e = _a.platform, platform = _e === void 0 ? PLATFORM.web : _e, message = _a.message, action = _a.action, hideNotification = _a.hideNotification;
30
+ useEffect(function () {
31
+ if (isShown && isAutoHidden) {
32
+ var timeout_1 = setTimeout(function () {
33
+ hideNotification();
34
+ }, hideDuration);
35
+ return function () { return clearTimeout(timeout_1); };
36
+ }
37
+ }, [isShown, isAutoHidden, hideDuration, hideNotification]);
38
+ return (_jsx(Popup, __assign({ className: getClassNames('notification', '-', platform), open: isShown, closeOnDocumentClick: false, closeOnEscape: false }, { children: _jsxs("div", __assign({ className: getClassNames('smartapp-notification', '__', type) }, { children: [NOTIFICATION_ICONS[type], _jsxs("div", __assign({ className: "smartapp-notification__content" }, { children: [_jsx("div", { children: message }), action && (_jsx("div", __assign({ className: "smartapp-notification__content--action", onClick: action.onClick }, { children: action.text || CANCEL_ACTION_TEXT })))] }))] })) })));
39
+ };
40
+ export default Notification;
@@ -0,0 +1 @@
1
+ export { default } from './Notification';
@@ -0,0 +1 @@
1
+ export { default } from './Notification';
@@ -0,0 +1,14 @@
1
+ import { ReactElement } from 'react';
2
+ export interface INotificationProps {
3
+ isShown: boolean;
4
+ type?: 'success' | 'info' | 'warning' | 'error';
5
+ isAutoHidden?: boolean;
6
+ hideDuration?: number;
7
+ platform?: 'web' | 'ios' | 'android';
8
+ message: string | ReactElement;
9
+ action?: {
10
+ text?: string;
11
+ onClick: () => void;
12
+ };
13
+ hideNotification: () => void;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { IRadioButtonProps } from './types';
2
+ import '../../styles/stories.module.scss';
3
+ declare const RadioButton: ({ id, isDisabled, isChecked, checkedColor, checkedHoverColor, onChange, }: IRadioButtonProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default RadioButton;
@@ -0,0 +1,25 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { useEffect } from 'react';
14
+ import { DEFAULT_BLUE_ICON_COLOR, DEFAULT_BLUE_ICON_HOVER_COLOR } from '../../constants';
15
+ import { getColor } from '../../helpers';
16
+ import '../../styles/stories.module.scss';
17
+ var RadioButton = function (_a) {
18
+ var id = _a.id, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, _c = _a.isChecked, isChecked = _c === void 0 ? false : _c, checkedColor = _a.checkedColor, checkedHoverColor = _a.checkedHoverColor, onChange = _a.onChange;
19
+ useEffect(function () {
20
+ document.documentElement.style.setProperty('--radio-button-color', getColor(checkedColor, DEFAULT_BLUE_ICON_COLOR));
21
+ document.documentElement.style.setProperty('--radio-button-hover-color', getColor(checkedHoverColor, DEFAULT_BLUE_ICON_HOVER_COLOR));
22
+ }, [checkedColor, checkedHoverColor]);
23
+ return (_jsx("div", __assign({ className: "smartapp-radio-button" }, { children: _jsx("label", __assign({ htmlFor: "smartapp-radio-button-".concat(id), onClick: onChange }, { children: _jsx("input", { type: "radio", id: "smartapp-radio-button-".concat(id), checked: isChecked, disabled: isDisabled }) })) })));
24
+ };
25
+ export default RadioButton;
@@ -0,0 +1 @@
1
+ export { default } from './RadioButton';
@@ -0,0 +1 @@
1
+ export { default } from './RadioButton';
@@ -0,0 +1,8 @@
1
+ export interface IRadioButtonProps {
2
+ id: string;
3
+ isDisabled?: boolean;
4
+ isChecked?: boolean;
5
+ checkedColor?: string;
6
+ checkedHoverColor?: string;
7
+ onChange: () => void;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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, useLayoutEffect, useState } from 'react';
13
+ import { useCallback, 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';
@@ -19,17 +19,16 @@ import { useSwipeable } from 'react-swipeable';
19
19
  import { isEmpty } from 'lodash';
20
20
  import { ReactComponent as CloseStoriesIcon } from '../../assets/icons/close-stories.svg';
21
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
+ import { DEFAULT_BACKGROUND_BUTTON_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_TEXT_BUTTON_COLOR, NUMBER_OF_STORIES_FOR_ROUND_INDICATORS, PLATFORM, } from '../../constants';
23
+ import { getColor, isIosPlatform, isWebPlatform } from '../../helpers';
24
24
  import '../../styles/stories.module.scss';
25
25
  var storyItemBaseStyles = {
26
26
  height: '100%',
27
27
  width: '100%',
28
28
  };
29
- var progressContainerStyles = function (platform) { return ({
30
- gap: '12px',
29
+ var progressContainerStyles = function (platform, storiesCount) { return ({
30
+ gap: storiesCount >= NUMBER_OF_STORIES_FOR_ROUND_INDICATORS ? '8px' : '12px',
31
31
  width: '100%',
32
- maxWidth: isIosPlatform(platform) || isAndroidPlatform(platform) ? '139px' : '198px',
33
32
  filter: 'none',
34
33
  paddingTop: isWebPlatform(platform) ? '22px' : isIosPlatform(platform) ? '21px' : '26px',
35
34
  paddingLeft: '0',
@@ -41,6 +40,7 @@ var progressWrapperStyles = {
41
40
  borderRadius: '51px',
42
41
  background: 'rgba(255, 255, 255, 0.4)',
43
42
  margin: 0,
43
+ overflow: 'hidden',
44
44
  };
45
45
  var progressStyles = {
46
46
  height: '4px',
@@ -113,10 +113,10 @@ var StoriesComponent = function (_a) {
113
113
  changeGroupStoriesToViewed(activeGroupStories);
114
114
  }
115
115
  };
116
- var getCurrentStoryIndex = function () { return stories.findIndex(function (_a) {
116
+ var getCurrentStoryIndex = useCallback(function () { return (stories.findIndex(function (_a) {
117
117
  var id = _a.id;
118
118
  return id === activeStoryId;
119
- }); };
119
+ })); }, [stories, activeStoryId]);
120
120
  var onPrevious = function () {
121
121
  activeStoryId === stories[0].id ? handlePrevious() : onStoryStart(getCurrentStoryIndex() - 1);
122
122
  };
@@ -131,15 +131,6 @@ var StoriesComponent = function (_a) {
131
131
  // eslint-disable-next-line react-hooks/rules-of-hooks
132
132
  useLayoutEffect(function () {
133
133
  setActiveStoryId(id);
134
- var storyWrapper = document.querySelector('.smartapp-stories');
135
- var storyWrapperHeight = (storyWrapper === null || storyWrapper === void 0 ? void 0 : storyWrapper.getBoundingClientRect().height) || 0;
136
- var storyContent = document.querySelector('.smartapp-stories__story');
137
- var storyContentHeight = (storyContent === null || storyContent === void 0 ? void 0 : storyContent.getBoundingClientRect().height) || 0;
138
- var buttonElement = document.querySelector('.smartapp-stories__story--button');
139
- var buttonElementHeight = buttonElement ? (buttonElement.getBoundingClientRect().height + BUTTON_PADDING) : 0;
140
- var padding = (storyWrapperHeight - storyContentHeight - buttonElementHeight) / 2;
141
- var paddingTop = (padding > MAX_PADDING_FOR_IMAGE && image) ? "".concat(MAX_PADDING_FOR_IMAGE, "px") : "".concat(padding, "px");
142
- storyContent === null || storyContent === void 0 ? void 0 : storyContent.style.setProperty('--padding', paddingTop);
143
134
  }, []);
144
135
  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: {
145
136
  color: getColor(button.textColor, DEFAULT_TEXT_BUTTON_COLOR),
@@ -193,6 +184,19 @@ var StoriesComponent = function (_a) {
193
184
  video === null || video === void 0 ? void 0 : video.removeEventListener("pause", pauseVideosOnBackground);
194
185
  };
195
186
  }, [activeStoryId]);
187
+ useEffect(function () {
188
+ var currentStoryIndex = getCurrentStoryIndex();
189
+ var indicatorsContainer = document.querySelector('.smartapp-stories > div:first-of-type > div:first-of-type');
190
+ var indicators = Array.from((indicatorsContainer === null || indicatorsContainer === void 0 ? void 0 : indicatorsContainer.children) || []);
191
+ indicators.forEach(function (indicator, index) {
192
+ if (indicators.length >= NUMBER_OF_STORIES_FOR_ROUND_INDICATORS) {
193
+ indicator.style.width = index !== currentStoryIndex ? '4px' : '48px';
194
+ }
195
+ else {
196
+ indicator.style.width = '38px';
197
+ }
198
+ });
199
+ }, [getCurrentStoryIndex]);
196
200
  useEffect(function () {
197
201
  var popupElement = document.querySelector('.smartapp-stories-content');
198
202
  var videoWrapper = document.querySelector('.smartapp-stories-content > div > div > div:nth-child(2) > div');
@@ -226,7 +230,7 @@ var StoriesComponent = function (_a) {
226
230
  _b['smartapp-stories__video'] = (activeStory === null || activeStory === void 0 ? void 0 : activeStory.type) === STORY_TYPE.video,
227
231
  _b['smartapp-stories__animate-right'] = isAnimateToRight,
228
232
  _b['smartapp-stories__animate-left'] = isAnimateToLeft,
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 = {
233
+ _b)) }, swipeableHandlers, { children: _jsx(Stories, { defaultInterval: 6000, width: "100%", height: "100%", stories: getStories(), onStoryStart: onStoryStart, onPrevious: onPrevious, onNext: onNext, onAllStoriesEnd: handleNext, progressContainerStyles: progressContainerStyles(platform, stories.length), progressWrapperStyles: progressWrapperStyles, progressStyles: progressStyles }, activeGroupStories.id) })), _jsx(CloseStoriesIcon, { className: classNames((_c = {
230
234
  'smartapp-stories__icon': true
231
235
  },
232
236
  _c["smartapp-stories__icon--".concat(platform)] = true,
@@ -1,4 +1,4 @@
1
1
  import { IToggleProps } from './types';
2
2
  import '../../styles/stories.module.scss';
3
- declare const Toggle: ({ id, checked, onClick }: IToggleProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const Toggle: ({ id, isDisabled, isChecked, checkedColor, checkedHoverColor, onClick, }: IToggleProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default Toggle;
@@ -10,9 +10,18 @@ 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 } from 'react';
14
+ import classNames from 'classnames';
15
+ import { DEFAULT_BLUE_ICON_COLOR, DEFAULT_BLUE_ICON_HOVER_COLOR } from '../../constants';
16
+ import { getColor } from '../../helpers';
13
17
  import '../../styles/stories.module.scss';
14
18
  var Toggle = function (_a) {
15
- var _b = _a.id, id = _b === void 0 ? 'toggle' : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, _d = _a.onClick, onClick = _d === void 0 ? function () { return undefined; } : _d;
16
- return (_jsx("div", __assign({ className: "smartapp-toggle-wrapper" }, { children: _jsxs("label", __assign({ className: "smartapp-toggle", htmlFor: "smartapp-toggle-".concat(id), onClick: function () { return onClick(); } }, { children: [_jsx("input", { type: "checkbox", id: "smartapp-toggle-".concat(id), checked: checked, disabled: true }), _jsx("span", { className: "smartapp-slider round" })] })) })));
19
+ var _b = _a.id, id = _b === void 0 ? 'toggle' : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isChecked, isChecked = _d === void 0 ? false : _d, checkedColor = _a.checkedColor, checkedHoverColor = _a.checkedHoverColor, _e = _a.onClick, onClick = _e === void 0 ? function () { return undefined; } : _e;
20
+ var handleClick = function () { return !isDisabled && onClick(); };
21
+ useEffect(function () {
22
+ document.documentElement.style.setProperty('--toggle-color', getColor(checkedColor, DEFAULT_BLUE_ICON_COLOR));
23
+ document.documentElement.style.setProperty('--toggle-hover-color', getColor(checkedHoverColor, DEFAULT_BLUE_ICON_HOVER_COLOR));
24
+ }, [checkedColor, checkedHoverColor]);
25
+ return (_jsx("div", __assign({ className: "smartapp-toggle-wrapper" }, { children: _jsxs("label", __assign({ htmlFor: "smartapp-toggle-".concat(id), className: "smartapp-toggle", onClick: handleClick }, { children: [_jsx("input", { type: "checkbox", id: "smartapp-toggle-".concat(id), checked: isChecked, disabled: true }), _jsx("span", { className: classNames('smartapp-slider', { 'smartapp-slider__disabled': isDisabled }) })] })) })));
17
26
  };
18
27
  export default Toggle;
@@ -1,5 +1,8 @@
1
1
  export interface IToggleProps {
2
2
  id?: string;
3
- checked?: boolean;
3
+ isDisabled?: boolean;
4
+ isChecked?: boolean;
5
+ checkedColor?: string;
6
+ checkedHoverColor?: string;
4
7
  onClick?: () => void;
5
8
  }
@@ -20,3 +20,5 @@ export { default as Toggle } from './Toggle';
20
20
  export { default as Stories } from './Stories';
21
21
  export { default as SyncLoader } from './SyncLoader';
22
22
  export { default as Modal } from './Modal';
23
+ export { default as Notification } from './Notification';
24
+ export { default as RadioButton } from './RadioButton';
@@ -20,3 +20,5 @@ export { default as Toggle } from './Toggle';
20
20
  export { default as Stories } from './Stories';
21
21
  export { default as SyncLoader } from './SyncLoader';
22
22
  export { default as Modal } from './Modal';
23
+ export { default as Notification } from './Notification';
24
+ export { default as RadioButton } from './RadioButton';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressms/smartapp-ui",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "SmartApp UI library",
5
5
  "license": "MIT",
6
6
  "main": "build/main/index.js",