@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.
@@ -6,6 +6,7 @@ import { GRID_WIDTH, GRID_HEIGHT, ShortcutType, getItemTextureKeyPath, ItemRarit
6
6
  import dayjs from 'dayjs';
7
7
  import { ErrorBoundary as ErrorBoundary$1 } from 'react-error-boundary';
8
8
  import { FaTimes } from 'react-icons/fa';
9
+ import { IoMdContract, IoMdExpand } from 'react-icons/io';
9
10
  import { RxMagnifyingGlass, RxCross2 } from 'react-icons/rx';
10
11
  import Draggable from 'react-draggable';
11
12
  import ReactDOM from 'react-dom';
@@ -26110,17 +26111,19 @@ var Chat = function Chat(_ref) {
26110
26111
  buttonBackgroundColor: '#333',
26111
26112
  width: '100%',
26112
26113
  height: '100%'
26113
- } : _ref$styles;
26114
+ } : _ref$styles,
26115
+ isExpanded = _ref.isExpanded;
26114
26116
  var _useState = useState(''),
26115
26117
  message = _useState[0],
26116
26118
  setMessage = _useState[1];
26117
26119
  var inputRef = useRef(null);
26118
26120
  useEffect(function () {
26119
26121
  var _inputRef$current;
26120
- scrollChatToBottom();
26121
- // Focus the input element when the component mounts
26122
+ if (isExpanded) {
26123
+ scrollChatToBottom();
26124
+ }
26122
26125
  (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
26123
- }, [chatMessages]);
26126
+ }, [chatMessages, isExpanded]);
26124
26127
  var scrollChatToBottom = function scrollChatToBottom() {
26125
26128
  var scrollingElement = document.querySelector('.chat-body');
26126
26129
  if (scrollingElement) {
@@ -26146,20 +26149,22 @@ var Chat = function Chat(_ref) {
26146
26149
  };
26147
26150
  return React.createElement(ChatContainer, {
26148
26151
  width: styles.width || 'auto',
26149
- height: styles.height || 'auto'
26152
+ height: styles.height || 'auto',
26153
+ isExpanded: isExpanded
26154
+ }, isExpanded && React.createElement(ErrorBoundary$1, {
26155
+ fallback: React.createElement("p", null, "Oops! Your chat has crashed.")
26150
26156
  }, React.createElement(CloseButton, {
26151
26157
  onClick: onCloseButton
26152
- }, React.createElement(FaTimes, null)), React.createElement(ErrorBoundary$1, {
26153
- fallback: React.createElement("p", null, "Oops! Your chat has crashed.")
26154
- }, React.createElement(MessagesContainer, {
26158
+ }, React.createElement(FaTimes, null)), React.createElement(MessagesContainer, {
26155
26159
  className: "chat-body"
26156
26160
  }, chatMessages.map(function (chatMessage, index) {
26157
26161
  return React.createElement(Message, {
26158
26162
  color: styles.textColor || uiColors.yellow,
26159
26163
  key: chatMessage._id + "_" + index
26160
26164
  }, formatMessage(chatMessage));
26161
- })), React.createElement(Form, {
26162
- onSubmit: handleSubmit
26165
+ }))), React.createElement(Form, {
26166
+ onSubmit: handleSubmit,
26167
+ isExpanded: isExpanded
26163
26168
  }, React.createElement(TextField, {
26164
26169
  ref: inputRef,
26165
26170
  value: message,
@@ -26175,7 +26180,7 @@ var Chat = function Chat(_ref) {
26175
26180
  }), React.createElement(SendButton, {
26176
26181
  type: "submit",
26177
26182
  disabled: !message.trim()
26178
- }, "\u25B6"))));
26183
+ }, "\u25B6")));
26179
26184
  };
26180
26185
  var ChatContainer = /*#__PURE__*/styled.div.withConfig({
26181
26186
  displayName: "Chat__ChatContainer",
@@ -26183,7 +26188,7 @@ var ChatContainer = /*#__PURE__*/styled.div.withConfig({
26183
26188
  })(["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) {
26184
26189
  return props.width;
26185
26190
  }, function (props) {
26186
- return props.height;
26191
+ return props.isExpanded ? props.height : 'auto';
26187
26192
  });
26188
26193
  var CloseButton = /*#__PURE__*/styled.button.withConfig({
26189
26194
  displayName: "Chat__CloseButton",
@@ -26203,7 +26208,9 @@ var Message = /*#__PURE__*/styled.div.withConfig({
26203
26208
  var Form = /*#__PURE__*/styled.form.withConfig({
26204
26209
  displayName: "Chat__Form",
26205
26210
  componentId: "sc-1bk05n6-4"
26206
- })(["display:flex;padding:8px;background-color:rgba(42,42,42,0.4);"]);
26211
+ })(["display:flex;padding:8px;background-color:rgba(42,42,42,0.4);border-radius:", ";"], function (props) {
26212
+ return props.isExpanded ? '0' : '8px';
26213
+ });
26207
26214
  var TextField = /*#__PURE__*/styled.input.withConfig({
26208
26215
  displayName: "Chat__TextField",
26209
26216
  componentId: "sc-1bk05n6-5"
@@ -26518,17 +26525,40 @@ var ChatRevamp = function ChatRevamp(_ref) {
26518
26525
  onSendTradeMessage = _ref.onSendTradeMessage,
26519
26526
  searchCharacterUI = _ref.searchCharacterUI,
26520
26527
  hideSearchCharacterUI = _ref.hideSearchCharacterUI,
26521
- showSearchCharacterUI = _ref.showSearchCharacterUI;
26528
+ showSearchCharacterUI = _ref.showSearchCharacterUI,
26529
+ _ref$minimizedByDefau = _ref.minimizedByDefault,
26530
+ minimizedByDefault = _ref$minimizedByDefau === void 0 ? false : _ref$minimizedByDefau,
26531
+ _ref$autoCloseOnSend = _ref.autoCloseOnSend,
26532
+ autoCloseOnSend = _ref$autoCloseOnSend === void 0 ? false : _ref$autoCloseOnSend;
26522
26533
  var _useState = useState(false),
26523
26534
  showRecentChats = _useState[0],
26524
26535
  setShowRecentChats = _useState[1];
26536
+ var _useState2 = useState(!minimizedByDefault),
26537
+ isExpanded = _useState2[0],
26538
+ setIsExpanded = _useState2[1];
26525
26539
  var isPrivate = activeTab === 'private';
26526
26540
  var isTrade = activeTab === 'trade';
26541
+ useEffect(function () {
26542
+ if (isPrivate) {
26543
+ setIsExpanded(true);
26544
+ }
26545
+ }, [isPrivate]);
26546
+ var toggleExpand = function toggleExpand() {
26547
+ return setIsExpanded(function (prev) {
26548
+ return !prev;
26549
+ });
26550
+ };
26527
26551
  var toggleRecentChats = function toggleRecentChats() {
26528
26552
  return setShowRecentChats(function (prev) {
26529
26553
  return !prev;
26530
26554
  });
26531
26555
  };
26556
+ var handleTabChange = function handleTabChange(tabId) {
26557
+ if (tabId === 'private') {
26558
+ setIsExpanded(true);
26559
+ }
26560
+ onChangeTab(tabId);
26561
+ };
26532
26562
  var handlePreviousChatCharacterClick = function handlePreviousChatCharacterClick(character) {
26533
26563
  onPreviousChatCharacterClick == null ? void 0 : onPreviousChatCharacterClick(character);
26534
26564
  hideSearchCharacterUI();
@@ -26539,7 +26569,7 @@ var ChatRevamp = function ChatRevamp(_ref) {
26539
26569
  key: tab.label + "_" + index,
26540
26570
  active: tab.id === activeTab,
26541
26571
  onPointerDown: function onPointerDown() {
26542
- return onChangeTab(tab.id);
26572
+ return handleTabChange(tab.id);
26543
26573
  }
26544
26574
  }, tab.label);
26545
26575
  }));
@@ -26595,29 +26625,62 @@ var ChatRevamp = function ChatRevamp(_ref) {
26595
26625
  }
26596
26626
  return React.createElement(Chat, {
26597
26627
  chatMessages: chatMessages,
26598
- onSendChatMessage: isPrivate ? onSendPrivateChatMessage : isTrade ? onSendTradeMessage : onSendGlobalChatMessage,
26628
+ onSendChatMessage: function onSendChatMessage() {
26629
+ if (autoCloseOnSend) {
26630
+ onCloseButton();
26631
+ }
26632
+ if (isPrivate) {
26633
+ return onSendPrivateChatMessage;
26634
+ } else if (isTrade) {
26635
+ return onSendTradeMessage;
26636
+ } else {
26637
+ return onSendGlobalChatMessage;
26638
+ }
26639
+ },
26599
26640
  sendMessage: true,
26600
26641
  onCloseButton: onCloseButton,
26601
26642
  styles: styles,
26602
26643
  onFocus: onFocus,
26603
- onBlur: onBlur
26644
+ onBlur: onBlur,
26645
+ isExpanded: isExpanded
26604
26646
  });
26605
26647
  };
26606
- return React.createElement(React.Fragment, null, renderTabs(), React.createElement(PrivateChatContainer, {
26648
+ return React.createElement(ChatRevampContainer, null, React.createElement(TopBar, {
26649
+ isExpanded: isExpanded
26650
+ }, isExpanded && renderTabs(), React.createElement(ExpandButton, {
26651
+ onClick: toggleExpand,
26652
+ isExpanded: isExpanded
26653
+ }, isExpanded ? React.createElement(IoMdContract, {
26654
+ size: 20
26655
+ }) : React.createElement(IoMdExpand, {
26656
+ size: 20
26657
+ }))), React.createElement(PrivateChatContainer, {
26607
26658
  width: (styles == null ? void 0 : styles.width) || '80%',
26608
- height: (styles == null ? void 0 : styles.height) || 'auto'
26609
- }, React.createElement(RecentChatTabContainer, {
26659
+ height: (styles == null ? void 0 : styles.height) || 'auto',
26660
+ isExpanded: isExpanded
26661
+ }, isExpanded && React.createElement(RecentChatTabContainer, {
26610
26662
  isPrivate: isPrivate,
26611
26663
  isOpen: showRecentChats
26612
26664
  }, renderRecentChatTopBar(), renderRecentChatList()), React.createElement(ChatWrapper, null, renderChatContent())));
26613
26665
  };
26666
+ var ChatRevampContainer = /*#__PURE__*/styled.div.withConfig({
26667
+ displayName: "ChatRevamp__ChatRevampContainer",
26668
+ componentId: "sc-1sdiknw-0"
26669
+ })(["display:flex;flex-direction:column;width:100%;position:relative;"]);
26670
+ var TopBar = /*#__PURE__*/styled.div.withConfig({
26671
+ displayName: "ChatRevamp__TopBar",
26672
+ componentId: "sc-1sdiknw-1"
26673
+ })(["display:flex;align-items:center;justify-content:flex-start;", ""], function (_ref2) {
26674
+ var isExpanded = _ref2.isExpanded;
26675
+ return !isExpanded && css(["min-height:32px;"]);
26676
+ });
26614
26677
  var TabContainer = /*#__PURE__*/styled.div.withConfig({
26615
26678
  displayName: "ChatRevamp__TabContainer",
26616
- componentId: "sc-1sdiknw-0"
26617
- })(["width:100%;display:flex;gap:10px;"]);
26679
+ componentId: "sc-1sdiknw-2"
26680
+ })(["display:flex;gap:10px;align-items:center;flex-grow:1;"]);
26618
26681
  var Tab = /*#__PURE__*/styled.button.withConfig({
26619
26682
  displayName: "ChatRevamp__Tab",
26620
- componentId: "sc-1sdiknw-1"
26683
+ componentId: "sc-1sdiknw-3"
26621
26684
  })(["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) {
26622
26685
  return props.active ? 'rgba(198, 81, 2, 0.5)' : 'rgba(128, 128, 128, 0.5)';
26623
26686
  }, function (props) {
@@ -26625,19 +26688,27 @@ var Tab = /*#__PURE__*/styled.button.withConfig({
26625
26688
  }, function (props) {
26626
26689
  return props.active ? 'white' : uiColors.darkGray;
26627
26690
  });
26691
+ var ExpandButton = /*#__PURE__*/styled.button.withConfig({
26692
+ displayName: "ChatRevamp__ExpandButton",
26693
+ componentId: "sc-1sdiknw-4"
26694
+ })(["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) {
26695
+ var isExpanded = _ref3.isExpanded;
26696
+ return isExpanded ? 'right: 0' : 'left: 0';
26697
+ }, uiColors.orange, uiColors.orange);
26628
26698
  var PrivateChatContainer = /*#__PURE__*/styled.div.withConfig({
26629
26699
  displayName: "ChatRevamp__PrivateChatContainer",
26630
- componentId: "sc-1sdiknw-2"
26631
- })(["width:", ";height:", ";padding:10px;background-color:rgba(0,0,0,0.2);display:flex;gap:10px;"], function (_ref2) {
26632
- var width = _ref2.width;
26700
+ componentId: "sc-1sdiknw-5"
26701
+ })(["width:", ";height:", ";padding:10px;background-color:rgba(0,0,0,0.2);display:flex;gap:10px;flex-wrap:wrap;"], function (_ref4) {
26702
+ var width = _ref4.width;
26633
26703
  return width;
26634
- }, function (_ref3) {
26635
- var height = _ref3.height;
26636
- return height;
26704
+ }, function (_ref5) {
26705
+ var height = _ref5.height,
26706
+ isExpanded = _ref5.isExpanded;
26707
+ return isExpanded ? height : 'auto';
26637
26708
  });
26638
26709
  var RecentChatTabContainer = /*#__PURE__*/styled.div.withConfig({
26639
26710
  displayName: "ChatRevamp__RecentChatTabContainer",
26640
- componentId: "sc-1sdiknw-3"
26711
+ componentId: "sc-1sdiknw-6"
26641
26712
  })(["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) {
26642
26713
  return props.isPrivate ? 'flex' : 'none';
26643
26714
  }, uiColors.gray, function (props) {
@@ -26651,25 +26722,25 @@ var RecentChatTabContainer = /*#__PURE__*/styled.div.withConfig({
26651
26722
  });
26652
26723
  var RecentChatTopBar = /*#__PURE__*/styled.div.withConfig({
26653
26724
  displayName: "ChatRevamp__RecentChatTopBar",
26654
- componentId: "sc-1sdiknw-4"
26725
+ componentId: "sc-1sdiknw-7"
26655
26726
  })(["display:flex;align-items:center;justify-content:space-between;height:30px;flex-shrink:0;"]);
26656
26727
  var SearchButton$1 = /*#__PURE__*/styled.button.withConfig({
26657
26728
  displayName: "ChatRevamp__SearchButton",
26658
- componentId: "sc-1sdiknw-5"
26729
+ componentId: "sc-1sdiknw-8"
26659
26730
  })(["border:none;background-color:transparent;display:flex;flex-direction:column;align-items:flex-end;gap:2px;padding:4px;position:relative;"]);
26660
26731
  var BurgerIconContainer = /*#__PURE__*/styled.button.withConfig({
26661
26732
  displayName: "ChatRevamp__BurgerIconContainer",
26662
- componentId: "sc-1sdiknw-6"
26733
+ componentId: "sc-1sdiknw-9"
26663
26734
  })(["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) {
26664
26735
  return props.hasUnseenMessages ? 'block' : 'none';
26665
26736
  });
26666
26737
  var BurgerLineIcon = /*#__PURE__*/styled.span.withConfig({
26667
26738
  displayName: "ChatRevamp__BurgerLineIcon",
26668
- componentId: "sc-1sdiknw-7"
26739
+ componentId: "sc-1sdiknw-10"
26669
26740
  })(["width:1rem;height:2px;background-color:#ffffff;"]);
26670
26741
  var RecentChatLogContainer = /*#__PURE__*/styled.div.withConfig({
26671
26742
  displayName: "ChatRevamp__RecentChatLogContainer",
26672
- componentId: "sc-1sdiknw-8"
26743
+ componentId: "sc-1sdiknw-11"
26673
26744
  })(["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) {
26674
26745
  return props.isOpen ? 'flex' : 'none';
26675
26746
  }, function (props) {
@@ -26677,28 +26748,28 @@ var RecentChatLogContainer = /*#__PURE__*/styled.div.withConfig({
26677
26748
  });
26678
26749
  var ListElementContainer = /*#__PURE__*/styled.div.withConfig({
26679
26750
  displayName: "ChatRevamp__ListElementContainer",
26680
- componentId: "sc-1sdiknw-9"
26751
+ componentId: "sc-1sdiknw-12"
26681
26752
  })(["display:flex;justify-content:space-between;align-items:center;padding:2px 0;"]);
26682
26753
  var ListElement$1 = /*#__PURE__*/styled.button.withConfig({
26683
26754
  displayName: "ChatRevamp__ListElement",
26684
- componentId: "sc-1sdiknw-10"
26755
+ componentId: "sc-1sdiknw-13"
26685
26756
  })(["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) {
26686
26757
  return props.active ? uiColors.yellow : uiColors.white;
26687
26758
  });
26688
26759
  var StatusDot = /*#__PURE__*/styled.span.withConfig({
26689
26760
  displayName: "ChatRevamp__StatusDot",
26690
- componentId: "sc-1sdiknw-11"
26761
+ componentId: "sc-1sdiknw-14"
26691
26762
  })(["width:6px;height:6px;border-radius:50%;background-color:", ";display:inline-block;margin-right:6px;"], function (props) {
26692
26763
  return props.isUnseen ? uiColors.lightGreen : uiColors.gray;
26693
26764
  });
26694
26765
  var CloseButton$2 = /*#__PURE__*/styled.button.withConfig({
26695
26766
  displayName: "ChatRevamp__CloseButton",
26696
- componentId: "sc-1sdiknw-12"
26767
+ componentId: "sc-1sdiknw-15"
26697
26768
  })(["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);
26698
26769
  var ChatWrapper = /*#__PURE__*/styled.div.withConfig({
26699
26770
  displayName: "ChatRevamp__ChatWrapper",
26700
- componentId: "sc-1sdiknw-13"
26701
- })(["flex-grow:1;overflow:hidden;display:flex;flex-direction:column;"]);
26771
+ componentId: "sc-1sdiknw-16"
26772
+ })(["flex-grow:1;overflow:hidden;display:flex;flex-direction:column;position:relative;"]);
26702
26773
 
26703
26774
  var CheckButton = function CheckButton(_ref) {
26704
26775
  var items = _ref.items,