@homefile/components-v2 2.49.5 → 2.49.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.
@@ -1,4 +1,4 @@
1
1
  import { MessageChatPanelI } from '../../../interfaces';
2
2
  import 'react-quill-new/dist/quill.snow.css';
3
3
  import '../../../styles';
4
- export declare const MessageChatPanel: ({ message, onBack, onClose, onReply, }: MessageChatPanelI) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const MessageChatPanel: ({ actionLabel, address, city, email, firstName, icon, lastName, message, onBack, onAction, onClose, onReply, phone, showAvatar, showHeader, state, title, zip, }: MessageChatPanelI) => import("react/jsx-runtime").JSX.Element;
@@ -12,13 +12,27 @@ import { useState } from 'react';
12
12
  import { t } from 'i18next';
13
13
  import { Box, DrawerBody, DrawerContent, DrawerFooter, DrawerHeader, Stack, Text, } from '@chakra-ui/react';
14
14
  import QuillEditor from 'react-quill-new';
15
- import { Document2 } from '../../../assets/images';
16
- import { BackCircleButton, FooterButtons, MessageCard, PanelHeader, up, WrapperWithShadow, } from '../../../components';
15
+ import { Inbox } from '../../../assets/images';
16
+ import { BackCircleButton, FooterButtons, MessageCard, MessageSenderCard, PanelHeader, up, WrapperWithShadow, } from '../../../components';
17
17
  import 'react-quill-new/dist/quill.snow.css';
18
18
  import '../../../styles';
19
- export const MessageChatPanel = ({ message, onBack, onClose, onReply, }) => {
19
+ export const MessageChatPanel = ({ actionLabel, address, city, email, firstName, icon = Inbox, lastName, message, onBack, onAction, onClose, onReply, phone, showAvatar, showHeader, state, title, zip, }) => {
20
20
  var _a, _b;
21
21
  const [value, setValue] = useState('');
22
+ const senderCardData = {
23
+ actionLabel,
24
+ address,
25
+ city,
26
+ email,
27
+ firstName,
28
+ lastName,
29
+ onAction,
30
+ phone,
31
+ showAvatar,
32
+ showHeader,
33
+ state,
34
+ zip,
35
+ };
22
36
  const onChange = (content) => {
23
37
  setValue(content);
24
38
  };
@@ -30,7 +44,7 @@ export const MessageChatPanel = ({ message, onBack, onClose, onReply, }) => {
30
44
  });
31
45
  setValue('');
32
46
  });
33
- return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, title: (_a = message === null || message === void 0 ? void 0 : message.from) !== null && _a !== void 0 ? _a : '', icon: Document2 }) }), _jsxs(DrawerBody, { p: "0", children: [onBack && (_jsx(Box, { bg: "lightBlue.2", py: "2", px: "base", children: _jsx(BackCircleButton, { onClick: onBack }) })), _jsx(Stack, { spacing: "base", p: "base", pb: "4", children: (_b = message === null || message === void 0 ? void 0 : message.chatReplies) === null || _b === void 0 ? void 0 : _b.map((reply) => (_jsx(MessageCard, { message: Object.assign(Object.assign({}, reply), { currentUser: message.currentUser }), variant: "chat" }, reply._id))) })] }), _jsx(DrawerFooter, { p: "0", maxH: "400px", children: _jsx(WrapperWithShadow, { animation: up, fadeDelay: 0.2, children: _jsxs(Stack, { spacing: "base", children: [_jsx(Text, { children: t('inbox.createReply') }), _jsx(QuillEditor, { theme: "snow", value: value, modules: { toolbar }, onChange: onChange, placeholder: t('inbox.enterContent') }), _jsx(FooterButtons, { px: "0", button1: {
47
+ return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, title: (_a = title !== null && title !== void 0 ? title : message === null || message === void 0 ? void 0 : message.from) !== null && _a !== void 0 ? _a : '', icon: icon }) }), _jsx(DrawerBody, { p: "0", children: _jsxs(Stack, { spacing: "base", children: [onBack && (_jsx(Box, { bg: "lightBlue.2", py: "2", px: "base", children: _jsx(BackCircleButton, { onClick: onBack }) })), _jsx(MessageSenderCard, Object.assign({}, senderCardData)), _jsx(Stack, { spacing: "base", p: "base", pb: "4", children: (_b = message === null || message === void 0 ? void 0 : message.chatReplies) === null || _b === void 0 ? void 0 : _b.map((reply) => (_jsx(MessageCard, { message: Object.assign(Object.assign({}, reply), { currentUser: message.currentUser }), variant: "chat" }, reply._id))) })] }) }), _jsx(DrawerFooter, { p: "0", maxH: "400px", children: _jsx(WrapperWithShadow, { animation: up, fadeDelay: 0.2, children: _jsxs(Stack, { spacing: "base", children: [_jsx(Text, { children: t('inbox.createReply') }), _jsx(QuillEditor, { theme: "snow", value: value, modules: { toolbar }, onChange: onChange, placeholder: t('inbox.enterContent') }), _jsx(FooterButtons, { px: "0", button1: {
34
48
  buttonStyle: 'secondaryFooter',
35
49
  label: t('buttons.send'),
36
50
  isDisabled: Number(value.length) === 0,
@@ -1,2 +1,2 @@
1
1
  import { MessagePanelI } from '../../../interfaces';
2
- export declare const MessagePanel: ({ icon, messages, onClick, onClose, title, email, firstName, lastName, phone, address, city, state, zip, showAvatar, showHeader, onAction, actionLabel, }: MessagePanelI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MessagePanel: ({ icon, messages, onClick, onClose, title, ...senderCardData }: MessagePanelI) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import { t } from 'i18next';
3
14
  import { Box, DrawerBody, DrawerContent, DrawerHeader, Stack, } from '@chakra-ui/react';
@@ -5,22 +16,9 @@ import { Inbox } from '../../../assets/images';
5
16
  import { BaseCounter, MessageCard, MessageSenderCard, PanelHeader, SelectInput, } from '../../../components';
6
17
  import { useMessagePanel } from '../../../hooks';
7
18
  import { pluralize } from '../../../utils';
8
- export const MessagePanel = ({ icon = Inbox, messages, onClick, onClose, title = t('inbox.message'), email, firstName, lastName, phone, address, city, state, zip, showAvatar, showHeader, onAction, actionLabel, }) => {
19
+ export const MessagePanel = (_a) => {
20
+ var { icon = Inbox, messages, onClick, onClose, title = t('inbox.message') } = _a, senderCardData = __rest(_a, ["icon", "messages", "onClick", "onClose", "title"]);
9
21
  const { currentSort, sortedMessages, handleSelectItem, items } = useMessagePanel(messages);
10
22
  const baseCounterText = `${t('counter.showing')} ${sortedMessages.length} ${t('counter.of')} ${messages.length} ${pluralize(sortedMessages.length, t('inbox.message').toLowerCase())} `;
11
- const senderCardData = {
12
- email,
13
- firstName,
14
- lastName,
15
- phone,
16
- address,
17
- city,
18
- state,
19
- zip,
20
- showAvatar,
21
- showHeader,
22
- onAction,
23
- actionLabel,
24
- };
25
23
  return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, title: title, icon: icon }) }), _jsx(DrawerBody, { p: "0", children: _jsxs(Stack, { spacing: "base", children: [_jsxs(Box, { children: [_jsx(MessageSenderCard, Object.assign({}, senderCardData)), _jsx(Box, { p: "base", bg: "lightBlue.2", children: _jsx(SelectInput, { handleClick: handleSelectItem, initialValue: currentSort, items: items }) })] }), _jsx(Box, { px: "base", children: _jsx(BaseCounter, { text: baseCounterText }) }), _jsx(Stack, { spacing: "1", pl: "26px", pr: "base", children: sortedMessages.map((message) => (_jsx(MessageCard, { message: message, onClick: onClick }, message._id))) })] }) })] }));
26
24
  };
@@ -1,12 +1,14 @@
1
- import { InboxMessageI } from '../../interfaces';
1
+ import { InboxMessageI, MessageSenderCardI } from '../../interfaces';
2
2
  interface InboxMessageReplyI {
3
3
  id: string;
4
4
  message: string;
5
5
  }
6
- export interface MessageChatPanelI {
6
+ export interface MessageChatPanelI extends Partial<MessageSenderCardI> {
7
+ icon?: string;
7
8
  message?: InboxMessageI;
8
- onReply: (props: InboxMessageReplyI) => void | Promise<void>;
9
- onClose: () => void;
10
9
  onBack?: () => void;
10
+ onClose: () => void;
11
+ onReply: (props: InboxMessageReplyI) => void | Promise<void>;
12
+ title?: string;
11
13
  }
12
14
  export {};
@@ -32,18 +32,31 @@ export default {
32
32
  showHeader: true,
33
33
  },
34
34
  decorators: [
35
- (Story) => (_jsx(RightPanel, { isOpen: true, onClose: action('onClose'), children: _jsx(Story, {}) })),
35
+ (Story) => (_jsx(RightPanel, { isOpen: true, onClose: action('onClose'), blockScrollOnMount: false, children: _jsx(Story, {}) })),
36
36
  ],
37
37
  };
38
38
  export const MessagePanelComponent = (args) => {
39
39
  const [showMessageChat, setShowMessageChat] = useState(false);
40
40
  const [selectedMessage, setSelectedMessage] = useState(undefined);
41
41
  const onReply = action('onReply');
42
+ const senderCardData = {
43
+ actionLabel: args.actionLabel,
44
+ address: args.address,
45
+ city: args.city,
46
+ email: args.email,
47
+ firstName: args.firstName,
48
+ lastName: args.lastName,
49
+ phone: args.phone,
50
+ showAvatar: args.showAvatar,
51
+ showHeader: args.showHeader,
52
+ state: args.state,
53
+ zip: args.zip,
54
+ };
42
55
  const handleMessageChatToggle = () => setShowMessageChat(!showMessageChat);
43
56
  return (_jsxs(Fragment, { children: [_jsx(MessagePanel, Object.assign({}, args, { onClick: (message) => {
44
57
  setSelectedMessage(message);
45
58
  handleMessageChatToggle();
46
- }, onAction: action('onAction'), actionLabel: "NOTE" })), _jsx(RightPanel, { isOpen: showMessageChat, onClose: handleMessageChatToggle, children: _jsx(MessageChatPanel, { message: selectedMessage, onReply: (reply) => __awaiter(void 0, void 0, void 0, function* () {
59
+ }, onAction: action('onAction'), actionLabel: "NOTE" })), _jsx(RightPanel, { isOpen: showMessageChat, onClose: handleMessageChatToggle, blockScrollOnMount: false, children: _jsx(MessageChatPanel, Object.assign({}, senderCardData, { actionLabel: "NOTE", icon: args.icon, message: selectedMessage, onAction: action('onActionChat'), onReply: (reply) => __awaiter(void 0, void 0, void 0, function* () {
47
60
  onReply(reply);
48
- }), onClose: action('onCloseChatPanel'), onBack: handleMessageChatToggle }) })] }));
61
+ }), onClose: action('onCloseChatPanel'), onBack: handleMessageChatToggle, title: args.title })) })] }));
49
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.49.5",
3
+ "version": "2.49.6",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",