@rpg-engine/long-bow 0.7.19 → 0.7.22

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.
@@ -20,5 +20,6 @@ export interface IChatProps {
20
20
  opacity?: number;
21
21
  sendMessage: boolean;
22
22
  styles?: IStyles;
23
+ isExpanded: boolean;
23
24
  }
24
25
  export declare const Chat: React.FC<IChatProps>;
@@ -29,5 +29,7 @@ export interface IChatRevampProps {
29
29
  searchCharacterUI: boolean;
30
30
  hideSearchCharacterUI: () => void;
31
31
  showSearchCharacterUI: () => void;
32
+ minimizedByDefault?: boolean;
33
+ autoCloseOnSend?: boolean;
32
34
  }
33
35
  export declare const ChatRevamp: React.FC<IChatRevampProps>;
@@ -14,6 +14,7 @@ var shared = require('@rpg-engine/shared');
14
14
  var dayjs = _interopDefault(require('dayjs'));
15
15
  var reactErrorBoundary = require('react-error-boundary');
16
16
  var fa = require('react-icons/fa');
17
+ var io = require('react-icons/io');
17
18
  var rx = require('react-icons/rx');
18
19
  var Draggable = _interopDefault(require('react-draggable'));
19
20
  var ReactDOM = _interopDefault(require('react-dom'));
@@ -26117,17 +26118,19 @@ var Chat = function Chat(_ref) {
26117
26118
  buttonBackgroundColor: '#333',
26118
26119
  width: '100%',
26119
26120
  height: '100%'
26120
- } : _ref$styles;
26121
+ } : _ref$styles,
26122
+ isExpanded = _ref.isExpanded;
26121
26123
  var _useState = React.useState(''),
26122
26124
  message = _useState[0],
26123
26125
  setMessage = _useState[1];
26124
26126
  var inputRef = React.useRef(null);
26125
26127
  React.useEffect(function () {
26126
26128
  var _inputRef$current;
26127
- scrollChatToBottom();
26128
- // Focus the input element when the component mounts
26129
+ if (isExpanded) {
26130
+ scrollChatToBottom();
26131
+ }
26129
26132
  (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
26130
- }, [chatMessages]);
26133
+ }, [chatMessages, isExpanded]);
26131
26134
  var scrollChatToBottom = function scrollChatToBottom() {
26132
26135
  var scrollingElement = document.querySelector('.chat-body');
26133
26136
  if (scrollingElement) {
@@ -26153,20 +26156,22 @@ var Chat = function Chat(_ref) {
26153
26156
  };
26154
26157
  return React__default.createElement(ChatContainer, {
26155
26158
  width: styles.width || 'auto',
26156
- height: styles.height || 'auto'
26159
+ height: styles.height || 'auto',
26160
+ isExpanded: isExpanded
26161
+ }, isExpanded && React__default.createElement(reactErrorBoundary.ErrorBoundary, {
26162
+ fallback: React__default.createElement("p", null, "Oops! Your chat has crashed.")
26157
26163
  }, React__default.createElement(CloseButton, {
26158
26164
  onClick: onCloseButton
26159
- }, React__default.createElement(fa.FaTimes, null)), React__default.createElement(reactErrorBoundary.ErrorBoundary, {
26160
- fallback: React__default.createElement("p", null, "Oops! Your chat has crashed.")
26161
- }, React__default.createElement(MessagesContainer, {
26165
+ }, React__default.createElement(fa.FaTimes, null)), React__default.createElement(MessagesContainer, {
26162
26166
  className: "chat-body"
26163
26167
  }, chatMessages.map(function (chatMessage, index) {
26164
26168
  return React__default.createElement(Message, {
26165
26169
  color: styles.textColor || uiColors.yellow,
26166
26170
  key: chatMessage._id + "_" + index
26167
26171
  }, formatMessage(chatMessage));
26168
- })), React__default.createElement(Form, {
26169
- onSubmit: handleSubmit
26172
+ }))), React__default.createElement(Form, {
26173
+ onSubmit: handleSubmit,
26174
+ isExpanded: isExpanded
26170
26175
  }, React__default.createElement(TextField, {
26171
26176
  ref: inputRef,
26172
26177
  value: message,
@@ -26182,7 +26187,7 @@ var Chat = function Chat(_ref) {
26182
26187
  }), React__default.createElement(SendButton, {
26183
26188
  type: "submit",
26184
26189
  disabled: !message.trim()
26185
- }, "\u25B6"))));
26190
+ }, "\u25B6")));
26186
26191
  };
26187
26192
  var ChatContainer = /*#__PURE__*/styled__default.div.withConfig({
26188
26193
  displayName: "Chat__ChatContainer",
@@ -26190,7 +26195,7 @@ var ChatContainer = /*#__PURE__*/styled__default.div.withConfig({
26190
26195
  })(["width:", ";height:", ";background-color:rgba(30,30,30,0.3);display:flex;flex-direction:column;position:relative;border-radius:8px;border:1px solid rgba(0,0,0,0.1);overflow:hidden;"], function (props) {
26191
26196
  return props.width;
26192
26197
  }, function (props) {
26193
- return props.height;
26198
+ return props.isExpanded ? props.height : 'auto';
26194
26199
  });
26195
26200
  var CloseButton = /*#__PURE__*/styled__default.button.withConfig({
26196
26201
  displayName: "Chat__CloseButton",
@@ -26210,7 +26215,9 @@ var Message = /*#__PURE__*/styled__default.div.withConfig({
26210
26215
  var Form = /*#__PURE__*/styled__default.form.withConfig({
26211
26216
  displayName: "Chat__Form",
26212
26217
  componentId: "sc-1bk05n6-4"
26213
- })(["display:flex;padding:8px;background-color:rgba(42,42,42,0.4);"]);
26218
+ })(["display:flex;padding:8px;background-color:rgba(42,42,42,0.4);border-radius:", ";"], function (props) {
26219
+ return props.isExpanded ? '0' : '8px';
26220
+ });
26214
26221
  var TextField = /*#__PURE__*/styled__default.input.withConfig({
26215
26222
  displayName: "Chat__TextField",
26216
26223
  componentId: "sc-1bk05n6-5"
@@ -26524,17 +26531,40 @@ var ChatRevamp = function ChatRevamp(_ref) {
26524
26531
  onSendTradeMessage = _ref.onSendTradeMessage,
26525
26532
  searchCharacterUI = _ref.searchCharacterUI,
26526
26533
  hideSearchCharacterUI = _ref.hideSearchCharacterUI,
26527
- showSearchCharacterUI = _ref.showSearchCharacterUI;
26534
+ showSearchCharacterUI = _ref.showSearchCharacterUI,
26535
+ _ref$minimizedByDefau = _ref.minimizedByDefault,
26536
+ minimizedByDefault = _ref$minimizedByDefau === void 0 ? false : _ref$minimizedByDefau,
26537
+ _ref$autoCloseOnSend = _ref.autoCloseOnSend,
26538
+ autoCloseOnSend = _ref$autoCloseOnSend === void 0 ? false : _ref$autoCloseOnSend;
26528
26539
  var _useState = React.useState(false),
26529
26540
  showRecentChats = _useState[0],
26530
26541
  setShowRecentChats = _useState[1];
26542
+ var _useState2 = React.useState(!minimizedByDefault),
26543
+ isExpanded = _useState2[0],
26544
+ setIsExpanded = _useState2[1];
26531
26545
  var isPrivate = activeTab === 'private';
26532
26546
  var isTrade = activeTab === 'trade';
26547
+ React.useEffect(function () {
26548
+ if (isPrivate) {
26549
+ setIsExpanded(true);
26550
+ }
26551
+ }, [isPrivate]);
26552
+ var toggleExpand = function toggleExpand() {
26553
+ return setIsExpanded(function (prev) {
26554
+ return !prev;
26555
+ });
26556
+ };
26533
26557
  var toggleRecentChats = function toggleRecentChats() {
26534
26558
  return setShowRecentChats(function (prev) {
26535
26559
  return !prev;
26536
26560
  });
26537
26561
  };
26562
+ var handleTabChange = function handleTabChange(tabId) {
26563
+ if (tabId === 'private') {
26564
+ setIsExpanded(true);
26565
+ }
26566
+ onChangeTab(tabId);
26567
+ };
26538
26568
  var handlePreviousChatCharacterClick = function handlePreviousChatCharacterClick(character) {
26539
26569
  onPreviousChatCharacterClick == null ? void 0 : onPreviousChatCharacterClick(character);
26540
26570
  hideSearchCharacterUI();
@@ -26545,7 +26575,7 @@ var ChatRevamp = function ChatRevamp(_ref) {
26545
26575
  key: tab.label + "_" + index,
26546
26576
  active: tab.id === activeTab,
26547
26577
  onPointerDown: function onPointerDown() {
26548
- return onChangeTab(tab.id);
26578
+ return handleTabChange(tab.id);
26549
26579
  }
26550
26580
  }, tab.label);
26551
26581
  }));
@@ -26601,29 +26631,62 @@ var ChatRevamp = function ChatRevamp(_ref) {
26601
26631
  }
26602
26632
  return React__default.createElement(Chat, {
26603
26633
  chatMessages: chatMessages,
26604
- onSendChatMessage: isPrivate ? onSendPrivateChatMessage : isTrade ? onSendTradeMessage : onSendGlobalChatMessage,
26634
+ onSendChatMessage: function onSendChatMessage() {
26635
+ if (autoCloseOnSend) {
26636
+ onCloseButton();
26637
+ }
26638
+ if (isPrivate) {
26639
+ return onSendPrivateChatMessage;
26640
+ } else if (isTrade) {
26641
+ return onSendTradeMessage;
26642
+ } else {
26643
+ return onSendGlobalChatMessage;
26644
+ }
26645
+ },
26605
26646
  sendMessage: true,
26606
26647
  onCloseButton: onCloseButton,
26607
26648
  styles: styles,
26608
26649
  onFocus: onFocus,
26609
- onBlur: onBlur
26650
+ onBlur: onBlur,
26651
+ isExpanded: isExpanded
26610
26652
  });
26611
26653
  };
26612
- return React__default.createElement(React__default.Fragment, null, renderTabs(), React__default.createElement(PrivateChatContainer, {
26654
+ return React__default.createElement(ChatRevampContainer, null, React__default.createElement(TopBar, {
26655
+ isExpanded: isExpanded
26656
+ }, isExpanded && renderTabs(), React__default.createElement(ExpandButton, {
26657
+ onClick: toggleExpand,
26658
+ isExpanded: isExpanded
26659
+ }, isExpanded ? React__default.createElement(io.IoMdContract, {
26660
+ size: 20
26661
+ }) : React__default.createElement(io.IoMdExpand, {
26662
+ size: 20
26663
+ }))), React__default.createElement(PrivateChatContainer, {
26613
26664
  width: (styles == null ? void 0 : styles.width) || '80%',
26614
- height: (styles == null ? void 0 : styles.height) || 'auto'
26615
- }, React__default.createElement(RecentChatTabContainer, {
26665
+ height: (styles == null ? void 0 : styles.height) || 'auto',
26666
+ isExpanded: isExpanded
26667
+ }, isExpanded && React__default.createElement(RecentChatTabContainer, {
26616
26668
  isPrivate: isPrivate,
26617
26669
  isOpen: showRecentChats
26618
26670
  }, renderRecentChatTopBar(), renderRecentChatList()), React__default.createElement(ChatWrapper, null, renderChatContent())));
26619
26671
  };
26672
+ var ChatRevampContainer = /*#__PURE__*/styled__default.div.withConfig({
26673
+ displayName: "ChatRevamp__ChatRevampContainer",
26674
+ componentId: "sc-1sdiknw-0"
26675
+ })(["display:flex;flex-direction:column;width:100%;position:relative;"]);
26676
+ var TopBar = /*#__PURE__*/styled__default.div.withConfig({
26677
+ displayName: "ChatRevamp__TopBar",
26678
+ componentId: "sc-1sdiknw-1"
26679
+ })(["display:flex;align-items:center;justify-content:flex-start;", ""], function (_ref2) {
26680
+ var isExpanded = _ref2.isExpanded;
26681
+ return !isExpanded && styled.css(["min-height:32px;"]);
26682
+ });
26620
26683
  var TabContainer = /*#__PURE__*/styled__default.div.withConfig({
26621
26684
  displayName: "ChatRevamp__TabContainer",
26622
- componentId: "sc-1sdiknw-0"
26623
- })(["width:100%;display:flex;gap:10px;"]);
26685
+ componentId: "sc-1sdiknw-2"
26686
+ })(["display:flex;gap:10px;align-items:center;flex-grow:1;"]);
26624
26687
  var Tab = /*#__PURE__*/styled__default.button.withConfig({
26625
26688
  displayName: "ChatRevamp__Tab",
26626
- componentId: "sc-1sdiknw-1"
26689
+ componentId: "sc-1sdiknw-3"
26627
26690
  })(["width:120px;color:white;font-size:0.8rem;all:unset;padding:0.6rem;font-size:0.8rem;border-radius:5px 5px 0 0;border-width:0.25rem 0.25rem 0 0.25rem;border-style:solid;border-color:", ";background-color:", ";color:", ";"], function (props) {
26628
26691
  return props.active ? 'rgba(198, 81, 2, 0.5)' : 'rgba(128, 128, 128, 0.5)';
26629
26692
  }, function (props) {
@@ -26631,19 +26694,27 @@ var Tab = /*#__PURE__*/styled__default.button.withConfig({
26631
26694
  }, function (props) {
26632
26695
  return props.active ? 'white' : uiColors.darkGray;
26633
26696
  });
26697
+ var ExpandButton = /*#__PURE__*/styled__default.button.withConfig({
26698
+ displayName: "ChatRevamp__ExpandButton",
26699
+ componentId: "sc-1sdiknw-4"
26700
+ })(["position:absolute;top:0;", ";width:30px;height:30px;background-color:", ";color:white;border:none;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer;transition:all 0.3s ease;z-index:10;&:hover{background-color:", ";}"], function (_ref3) {
26701
+ var isExpanded = _ref3.isExpanded;
26702
+ return isExpanded ? 'right: 0' : 'left: 0';
26703
+ }, uiColors.orange, uiColors.orange);
26634
26704
  var PrivateChatContainer = /*#__PURE__*/styled__default.div.withConfig({
26635
26705
  displayName: "ChatRevamp__PrivateChatContainer",
26636
- componentId: "sc-1sdiknw-2"
26637
- })(["width:", ";height:", ";padding:10px;background-color:rgba(0,0,0,0.2);display:flex;gap:10px;"], function (_ref2) {
26638
- var width = _ref2.width;
26706
+ componentId: "sc-1sdiknw-5"
26707
+ })(["width:", ";height:", ";padding:10px;background-color:rgba(0,0,0,0.2);display:flex;gap:10px;flex-wrap:wrap;"], function (_ref4) {
26708
+ var width = _ref4.width;
26639
26709
  return width;
26640
- }, function (_ref3) {
26641
- var height = _ref3.height;
26642
- return height;
26710
+ }, function (_ref5) {
26711
+ var height = _ref5.height,
26712
+ isExpanded = _ref5.isExpanded;
26713
+ return isExpanded ? height : 'auto';
26643
26714
  });
26644
26715
  var RecentChatTabContainer = /*#__PURE__*/styled__default.div.withConfig({
26645
26716
  displayName: "ChatRevamp__RecentChatTabContainer",
26646
- componentId: "sc-1sdiknw-3"
26717
+ componentId: "sc-1sdiknw-6"
26647
26718
  })(["display:", ";flex-direction:column;border-right:1px solid ", ";outline:none;width:", ";max-width:200px;min-width:", ";transition:all 0.3s ease-in-out;overflow:hidden;height:100%;@media (max-width:768px){width:", ";min-width:", ";}"], function (props) {
26648
26719
  return props.isPrivate ? 'flex' : 'none';
26649
26720
  }, uiColors.gray, function (props) {
@@ -26657,25 +26728,25 @@ var RecentChatTabContainer = /*#__PURE__*/styled__default.div.withConfig({
26657
26728
  });
26658
26729
  var RecentChatTopBar = /*#__PURE__*/styled__default.div.withConfig({
26659
26730
  displayName: "ChatRevamp__RecentChatTopBar",
26660
- componentId: "sc-1sdiknw-4"
26731
+ componentId: "sc-1sdiknw-7"
26661
26732
  })(["display:flex;align-items:center;justify-content:space-between;height:30px;flex-shrink:0;"]);
26662
26733
  var SearchButton$1 = /*#__PURE__*/styled__default.button.withConfig({
26663
26734
  displayName: "ChatRevamp__SearchButton",
26664
- componentId: "sc-1sdiknw-5"
26735
+ componentId: "sc-1sdiknw-8"
26665
26736
  })(["border:none;background-color:transparent;display:flex;flex-direction:column;align-items:flex-end;gap:2px;padding:4px;position:relative;"]);
26666
26737
  var BurgerIconContainer = /*#__PURE__*/styled__default.button.withConfig({
26667
26738
  displayName: "ChatRevamp__BurgerIconContainer",
26668
- componentId: "sc-1sdiknw-6"
26739
+ componentId: "sc-1sdiknw-9"
26669
26740
  })(["border:none;background-color:transparent;display:flex;flex-direction:column;align-items:flex-end;padding:4px;gap:2px;position:relative;&:after{content:'';width:6px;height:6px;position:absolute;top:0;right:2px;border-radius:50%;background-color:", ";display:", ";}"], uiColors.lightGreen, function (props) {
26670
26741
  return props.hasUnseenMessages ? 'block' : 'none';
26671
26742
  });
26672
26743
  var BurgerLineIcon = /*#__PURE__*/styled__default.span.withConfig({
26673
26744
  displayName: "ChatRevamp__BurgerLineIcon",
26674
- componentId: "sc-1sdiknw-7"
26745
+ componentId: "sc-1sdiknw-10"
26675
26746
  })(["width:1rem;height:2px;background-color:#ffffff;"]);
26676
26747
  var RecentChatLogContainer = /*#__PURE__*/styled__default.div.withConfig({
26677
26748
  displayName: "ChatRevamp__RecentChatLogContainer",
26678
- componentId: "sc-1sdiknw-8"
26749
+ componentId: "sc-1sdiknw-11"
26679
26750
  })(["display:", ";opacity:", ";flex-direction:column;gap:0.25rem;transition:opacity 0.3s ease-in-out;padding:0;margin:0;overflow-y:auto;flex-grow:1;height:0;scrollbar-width:thin;scrollbar-color:rgba(51,51,51,0.4) rgba(30,30,30,0.4);&::-webkit-scrollbar{width:8px;height:8px;}&::-webkit-scrollbar-track{background:rgba(30,30,30,0.2);border-radius:4px;}&::-webkit-scrollbar-thumb{background-color:rgba(255,102,0,0.5);border-radius:4px;border:2px solid rgba(30,30,30,0.2);}&::-webkit-scrollbar-thumb:hover{background-color:rgba(255,102,0,0.7);}"], function (props) {
26680
26751
  return props.isOpen ? 'flex' : 'none';
26681
26752
  }, function (props) {
@@ -26683,28 +26754,28 @@ var RecentChatLogContainer = /*#__PURE__*/styled__default.div.withConfig({
26683
26754
  });
26684
26755
  var ListElementContainer = /*#__PURE__*/styled__default.div.withConfig({
26685
26756
  displayName: "ChatRevamp__ListElementContainer",
26686
- componentId: "sc-1sdiknw-9"
26757
+ componentId: "sc-1sdiknw-12"
26687
26758
  })(["display:flex;justify-content:space-between;align-items:center;padding:2px 0;"]);
26688
26759
  var ListElement$1 = /*#__PURE__*/styled__default.button.withConfig({
26689
26760
  displayName: "ChatRevamp__ListElement",
26690
- componentId: "sc-1sdiknw-10"
26761
+ componentId: "sc-1sdiknw-13"
26691
26762
  })(["margin:0 !important;font-size:", " !important;padding:2px;all:unset;color:", ";width:100%;position:relative;display:flex;align-items:center;gap:4px;&:hover{color:#ff0;}max-width:calc(100% - 24px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"], uiFonts.size.small, function (props) {
26692
26763
  return props.active ? uiColors.yellow : uiColors.white;
26693
26764
  });
26694
26765
  var StatusDot = /*#__PURE__*/styled__default.span.withConfig({
26695
26766
  displayName: "ChatRevamp__StatusDot",
26696
- componentId: "sc-1sdiknw-11"
26767
+ componentId: "sc-1sdiknw-14"
26697
26768
  })(["width:6px;height:6px;border-radius:50%;background-color:", ";display:inline-block;margin-right:6px;"], function (props) {
26698
26769
  return props.isUnseen ? uiColors.lightGreen : uiColors.gray;
26699
26770
  });
26700
26771
  var CloseButton$2 = /*#__PURE__*/styled__default.button.withConfig({
26701
26772
  displayName: "ChatRevamp__CloseButton",
26702
- componentId: "sc-1sdiknw-12"
26773
+ componentId: "sc-1sdiknw-15"
26703
26774
  })(["all:unset;font-size:", ";margin:0 0.5rem;transition:all 0.2s ease-in-out;background-color:", ";color:", ";width:16px;height:16px;border-radius:50%;display:flex;justify-content:center;align-items:center;&:hover{background-color:", ";color:", ";}"], uiFonts.size.xxsmall, uiColors.red, uiColors.white, uiColors.white, uiColors.red);
26704
26775
  var ChatWrapper = /*#__PURE__*/styled__default.div.withConfig({
26705
26776
  displayName: "ChatRevamp__ChatWrapper",
26706
- componentId: "sc-1sdiknw-13"
26707
- })(["flex-grow:1;overflow:hidden;display:flex;flex-direction:column;"]);
26777
+ componentId: "sc-1sdiknw-16"
26778
+ })(["flex-grow:1;overflow:hidden;display:flex;flex-direction:column;position:relative;"]);
26708
26779
 
26709
26780
  var CheckButton = function CheckButton(_ref) {
26710
26781
  var items = _ref.items,