@rpg-engine/long-bow 0.7.18 → 0.7.21

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,6 @@ export interface IChatRevampProps {
29
29
  searchCharacterUI: boolean;
30
30
  hideSearchCharacterUI: () => void;
31
31
  showSearchCharacterUI: () => void;
32
+ minimizedByDefault?: boolean;
32
33
  }
33
34
  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,13 +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];
26126
+ var inputRef = React.useRef(null);
26124
26127
  React.useEffect(function () {
26125
- scrollChatToBottom();
26126
- }, [chatMessages]);
26128
+ var _inputRef$current;
26129
+ if (isExpanded) {
26130
+ scrollChatToBottom();
26131
+ }
26132
+ (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
26133
+ }, [chatMessages, isExpanded]);
26127
26134
  var scrollChatToBottom = function scrollChatToBottom() {
26128
26135
  var scrollingElement = document.querySelector('.chat-body');
26129
26136
  if (scrollingElement) {
@@ -26149,21 +26156,24 @@ var Chat = function Chat(_ref) {
26149
26156
  };
26150
26157
  return React__default.createElement(ChatContainer, {
26151
26158
  width: styles.width || 'auto',
26152
- 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.")
26153
26163
  }, React__default.createElement(CloseButton, {
26154
26164
  onClick: onCloseButton
26155
- }, React__default.createElement(fa.FaTimes, null)), React__default.createElement(reactErrorBoundary.ErrorBoundary, {
26156
- fallback: React__default.createElement("p", null, "Oops! Your chat has crashed.")
26157
- }, React__default.createElement(MessagesContainer, {
26165
+ }, React__default.createElement(fa.FaTimes, null)), React__default.createElement(MessagesContainer, {
26158
26166
  className: "chat-body"
26159
26167
  }, chatMessages.map(function (chatMessage, index) {
26160
26168
  return React__default.createElement(Message, {
26161
26169
  color: styles.textColor || uiColors.yellow,
26162
26170
  key: chatMessage._id + "_" + index
26163
26171
  }, formatMessage(chatMessage));
26164
- })), React__default.createElement(Form, {
26165
- onSubmit: handleSubmit
26172
+ }))), React__default.createElement(Form, {
26173
+ onSubmit: handleSubmit,
26174
+ isExpanded: isExpanded
26166
26175
  }, React__default.createElement(TextField, {
26176
+ ref: inputRef,
26167
26177
  value: message,
26168
26178
  onChange: function onChange(e) {
26169
26179
  return setMessage(e.target.value);
@@ -26173,12 +26183,11 @@ var Chat = function Chat(_ref) {
26173
26183
  onFocus: onFocus,
26174
26184
  onBlur: onBlur,
26175
26185
  onPointerDown: onFocus,
26176
- autoFocus: true,
26177
26186
  placeholder: "Type your message..."
26178
26187
  }), React__default.createElement(SendButton, {
26179
26188
  type: "submit",
26180
26189
  disabled: !message.trim()
26181
- }, "\u25B6"))));
26190
+ }, "\u25B6")));
26182
26191
  };
26183
26192
  var ChatContainer = /*#__PURE__*/styled__default.div.withConfig({
26184
26193
  displayName: "Chat__ChatContainer",
@@ -26186,7 +26195,7 @@ var ChatContainer = /*#__PURE__*/styled__default.div.withConfig({
26186
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) {
26187
26196
  return props.width;
26188
26197
  }, function (props) {
26189
- return props.height;
26198
+ return props.isExpanded ? props.height : 'auto';
26190
26199
  });
26191
26200
  var CloseButton = /*#__PURE__*/styled__default.button.withConfig({
26192
26201
  displayName: "Chat__CloseButton",
@@ -26206,7 +26215,9 @@ var Message = /*#__PURE__*/styled__default.div.withConfig({
26206
26215
  var Form = /*#__PURE__*/styled__default.form.withConfig({
26207
26216
  displayName: "Chat__Form",
26208
26217
  componentId: "sc-1bk05n6-4"
26209
- })(["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
+ });
26210
26221
  var TextField = /*#__PURE__*/styled__default.input.withConfig({
26211
26222
  displayName: "Chat__TextField",
26212
26223
  componentId: "sc-1bk05n6-5"
@@ -26520,17 +26531,38 @@ var ChatRevamp = function ChatRevamp(_ref) {
26520
26531
  onSendTradeMessage = _ref.onSendTradeMessage,
26521
26532
  searchCharacterUI = _ref.searchCharacterUI,
26522
26533
  hideSearchCharacterUI = _ref.hideSearchCharacterUI,
26523
- showSearchCharacterUI = _ref.showSearchCharacterUI;
26534
+ showSearchCharacterUI = _ref.showSearchCharacterUI,
26535
+ _ref$minimizedByDefau = _ref.minimizedByDefault,
26536
+ minimizedByDefault = _ref$minimizedByDefau === void 0 ? false : _ref$minimizedByDefau;
26524
26537
  var _useState = React.useState(false),
26525
26538
  showRecentChats = _useState[0],
26526
26539
  setShowRecentChats = _useState[1];
26540
+ var _useState2 = React.useState(!minimizedByDefault),
26541
+ isExpanded = _useState2[0],
26542
+ setIsExpanded = _useState2[1];
26527
26543
  var isPrivate = activeTab === 'private';
26528
26544
  var isTrade = activeTab === 'trade';
26545
+ React.useEffect(function () {
26546
+ if (isPrivate) {
26547
+ setIsExpanded(true);
26548
+ }
26549
+ }, [isPrivate]);
26550
+ var toggleExpand = function toggleExpand() {
26551
+ return setIsExpanded(function (prev) {
26552
+ return !prev;
26553
+ });
26554
+ };
26529
26555
  var toggleRecentChats = function toggleRecentChats() {
26530
26556
  return setShowRecentChats(function (prev) {
26531
26557
  return !prev;
26532
26558
  });
26533
26559
  };
26560
+ var handleTabChange = function handleTabChange(tabId) {
26561
+ if (tabId === 'private') {
26562
+ setIsExpanded(true);
26563
+ }
26564
+ onChangeTab(tabId);
26565
+ };
26534
26566
  var handlePreviousChatCharacterClick = function handlePreviousChatCharacterClick(character) {
26535
26567
  onPreviousChatCharacterClick == null ? void 0 : onPreviousChatCharacterClick(character);
26536
26568
  hideSearchCharacterUI();
@@ -26541,7 +26573,7 @@ var ChatRevamp = function ChatRevamp(_ref) {
26541
26573
  key: tab.label + "_" + index,
26542
26574
  active: tab.id === activeTab,
26543
26575
  onPointerDown: function onPointerDown() {
26544
- return onChangeTab(tab.id);
26576
+ return handleTabChange(tab.id);
26545
26577
  }
26546
26578
  }, tab.label);
26547
26579
  }));
@@ -26602,24 +26634,46 @@ var ChatRevamp = function ChatRevamp(_ref) {
26602
26634
  onCloseButton: onCloseButton,
26603
26635
  styles: styles,
26604
26636
  onFocus: onFocus,
26605
- onBlur: onBlur
26637
+ onBlur: onBlur,
26638
+ isExpanded: isExpanded
26606
26639
  });
26607
26640
  };
26608
- return React__default.createElement(React__default.Fragment, null, renderTabs(), React__default.createElement(PrivateChatContainer, {
26641
+ return React__default.createElement(ChatRevampContainer, null, React__default.createElement(TopBar, {
26642
+ isExpanded: isExpanded
26643
+ }, isExpanded && renderTabs(), React__default.createElement(ExpandButton, {
26644
+ onClick: toggleExpand,
26645
+ isExpanded: isExpanded
26646
+ }, isExpanded ? React__default.createElement(io.IoMdContract, {
26647
+ size: 20
26648
+ }) : React__default.createElement(io.IoMdExpand, {
26649
+ size: 20
26650
+ }))), React__default.createElement(PrivateChatContainer, {
26609
26651
  width: (styles == null ? void 0 : styles.width) || '80%',
26610
- height: (styles == null ? void 0 : styles.height) || 'auto'
26611
- }, React__default.createElement(RecentChatTabContainer, {
26652
+ height: (styles == null ? void 0 : styles.height) || 'auto',
26653
+ isExpanded: isExpanded
26654
+ }, isExpanded && React__default.createElement(RecentChatTabContainer, {
26612
26655
  isPrivate: isPrivate,
26613
26656
  isOpen: showRecentChats
26614
26657
  }, renderRecentChatTopBar(), renderRecentChatList()), React__default.createElement(ChatWrapper, null, renderChatContent())));
26615
26658
  };
26659
+ var ChatRevampContainer = /*#__PURE__*/styled__default.div.withConfig({
26660
+ displayName: "ChatRevamp__ChatRevampContainer",
26661
+ componentId: "sc-1sdiknw-0"
26662
+ })(["display:flex;flex-direction:column;width:100%;position:relative;"]);
26663
+ var TopBar = /*#__PURE__*/styled__default.div.withConfig({
26664
+ displayName: "ChatRevamp__TopBar",
26665
+ componentId: "sc-1sdiknw-1"
26666
+ })(["display:flex;align-items:center;justify-content:flex-start;", ""], function (_ref2) {
26667
+ var isExpanded = _ref2.isExpanded;
26668
+ return !isExpanded && styled.css(["min-height:32px;"]);
26669
+ });
26616
26670
  var TabContainer = /*#__PURE__*/styled__default.div.withConfig({
26617
26671
  displayName: "ChatRevamp__TabContainer",
26618
- componentId: "sc-1sdiknw-0"
26619
- })(["width:100%;display:flex;gap:10px;"]);
26672
+ componentId: "sc-1sdiknw-2"
26673
+ })(["display:flex;gap:10px;align-items:center;flex-grow:1;"]);
26620
26674
  var Tab = /*#__PURE__*/styled__default.button.withConfig({
26621
26675
  displayName: "ChatRevamp__Tab",
26622
- componentId: "sc-1sdiknw-1"
26676
+ componentId: "sc-1sdiknw-3"
26623
26677
  })(["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) {
26624
26678
  return props.active ? 'rgba(198, 81, 2, 0.5)' : 'rgba(128, 128, 128, 0.5)';
26625
26679
  }, function (props) {
@@ -26627,19 +26681,24 @@ var Tab = /*#__PURE__*/styled__default.button.withConfig({
26627
26681
  }, function (props) {
26628
26682
  return props.active ? 'white' : uiColors.darkGray;
26629
26683
  });
26684
+ var ExpandButton = /*#__PURE__*/styled__default.button.withConfig({
26685
+ displayName: "ChatRevamp__ExpandButton",
26686
+ componentId: "sc-1sdiknw-4"
26687
+ })(["position:absolute;top:0;right: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:", ";}"], uiColors.orange, uiColors.orange);
26630
26688
  var PrivateChatContainer = /*#__PURE__*/styled__default.div.withConfig({
26631
26689
  displayName: "ChatRevamp__PrivateChatContainer",
26632
- componentId: "sc-1sdiknw-2"
26633
- })(["width:", ";height:", ";padding:10px;background-color:rgba(0,0,0,0.2);display:flex;gap:10px;"], function (_ref2) {
26634
- var width = _ref2.width;
26690
+ componentId: "sc-1sdiknw-5"
26691
+ })(["width:", ";height:", ";padding:10px;background-color:rgba(0,0,0,0.2);display:flex;gap:10px;flex-direction:column;"], function (_ref3) {
26692
+ var width = _ref3.width;
26635
26693
  return width;
26636
- }, function (_ref3) {
26637
- var height = _ref3.height;
26638
- return height;
26694
+ }, function (_ref4) {
26695
+ var height = _ref4.height,
26696
+ isExpanded = _ref4.isExpanded;
26697
+ return isExpanded ? height : 'auto';
26639
26698
  });
26640
26699
  var RecentChatTabContainer = /*#__PURE__*/styled__default.div.withConfig({
26641
26700
  displayName: "ChatRevamp__RecentChatTabContainer",
26642
- componentId: "sc-1sdiknw-3"
26701
+ componentId: "sc-1sdiknw-6"
26643
26702
  })(["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) {
26644
26703
  return props.isPrivate ? 'flex' : 'none';
26645
26704
  }, uiColors.gray, function (props) {
@@ -26653,25 +26712,25 @@ var RecentChatTabContainer = /*#__PURE__*/styled__default.div.withConfig({
26653
26712
  });
26654
26713
  var RecentChatTopBar = /*#__PURE__*/styled__default.div.withConfig({
26655
26714
  displayName: "ChatRevamp__RecentChatTopBar",
26656
- componentId: "sc-1sdiknw-4"
26715
+ componentId: "sc-1sdiknw-7"
26657
26716
  })(["display:flex;align-items:center;justify-content:space-between;height:30px;flex-shrink:0;"]);
26658
26717
  var SearchButton$1 = /*#__PURE__*/styled__default.button.withConfig({
26659
26718
  displayName: "ChatRevamp__SearchButton",
26660
- componentId: "sc-1sdiknw-5"
26719
+ componentId: "sc-1sdiknw-8"
26661
26720
  })(["border:none;background-color:transparent;display:flex;flex-direction:column;align-items:flex-end;gap:2px;padding:4px;position:relative;"]);
26662
26721
  var BurgerIconContainer = /*#__PURE__*/styled__default.button.withConfig({
26663
26722
  displayName: "ChatRevamp__BurgerIconContainer",
26664
- componentId: "sc-1sdiknw-6"
26723
+ componentId: "sc-1sdiknw-9"
26665
26724
  })(["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) {
26666
26725
  return props.hasUnseenMessages ? 'block' : 'none';
26667
26726
  });
26668
26727
  var BurgerLineIcon = /*#__PURE__*/styled__default.span.withConfig({
26669
26728
  displayName: "ChatRevamp__BurgerLineIcon",
26670
- componentId: "sc-1sdiknw-7"
26729
+ componentId: "sc-1sdiknw-10"
26671
26730
  })(["width:1rem;height:2px;background-color:#ffffff;"]);
26672
26731
  var RecentChatLogContainer = /*#__PURE__*/styled__default.div.withConfig({
26673
26732
  displayName: "ChatRevamp__RecentChatLogContainer",
26674
- componentId: "sc-1sdiknw-8"
26733
+ componentId: "sc-1sdiknw-11"
26675
26734
  })(["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) {
26676
26735
  return props.isOpen ? 'flex' : 'none';
26677
26736
  }, function (props) {
@@ -26679,28 +26738,28 @@ var RecentChatLogContainer = /*#__PURE__*/styled__default.div.withConfig({
26679
26738
  });
26680
26739
  var ListElementContainer = /*#__PURE__*/styled__default.div.withConfig({
26681
26740
  displayName: "ChatRevamp__ListElementContainer",
26682
- componentId: "sc-1sdiknw-9"
26741
+ componentId: "sc-1sdiknw-12"
26683
26742
  })(["display:flex;justify-content:space-between;align-items:center;padding:2px 0;"]);
26684
26743
  var ListElement$1 = /*#__PURE__*/styled__default.button.withConfig({
26685
26744
  displayName: "ChatRevamp__ListElement",
26686
- componentId: "sc-1sdiknw-10"
26745
+ componentId: "sc-1sdiknw-13"
26687
26746
  })(["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) {
26688
26747
  return props.active ? uiColors.yellow : uiColors.white;
26689
26748
  });
26690
26749
  var StatusDot = /*#__PURE__*/styled__default.span.withConfig({
26691
26750
  displayName: "ChatRevamp__StatusDot",
26692
- componentId: "sc-1sdiknw-11"
26751
+ componentId: "sc-1sdiknw-14"
26693
26752
  })(["width:6px;height:6px;border-radius:50%;background-color:", ";display:inline-block;margin-right:6px;"], function (props) {
26694
26753
  return props.isUnseen ? uiColors.lightGreen : uiColors.gray;
26695
26754
  });
26696
26755
  var CloseButton$2 = /*#__PURE__*/styled__default.button.withConfig({
26697
26756
  displayName: "ChatRevamp__CloseButton",
26698
- componentId: "sc-1sdiknw-12"
26757
+ componentId: "sc-1sdiknw-15"
26699
26758
  })(["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);
26700
26759
  var ChatWrapper = /*#__PURE__*/styled__default.div.withConfig({
26701
26760
  displayName: "ChatRevamp__ChatWrapper",
26702
- componentId: "sc-1sdiknw-13"
26703
- })(["flex-grow:1;overflow:hidden;display:flex;flex-direction:column;"]);
26761
+ componentId: "sc-1sdiknw-16"
26762
+ })(["flex-grow:1;overflow:hidden;display:flex;flex-direction:column;position:relative;"]);
26704
26763
 
26705
26764
  var CheckButton = function CheckButton(_ref) {
26706
26765
  var items = _ref.items,