@rpg-engine/long-bow 0.5.14 → 0.5.16

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,6 +1,6 @@
1
- import { IChatMessage } from '@rpg-engine/shared';
1
+ import { IChatMessage, IPrivateChatMessage } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
- interface IStyles {
3
+ export interface IStyles {
4
4
  textColor?: string;
5
5
  buttonColor?: string;
6
6
  buttonBackgroundColor?: string;
@@ -8,7 +8,7 @@ interface IStyles {
8
8
  height?: string;
9
9
  }
10
10
  export interface IChatProps {
11
- chatMessages: IChatMessage[];
11
+ chatMessages: IChatMessage[] | IPrivateChatMessage[];
12
12
  onSendChatMessage: (message: string) => void;
13
13
  onCloseButton: () => void;
14
14
  onFocus?: () => void;
@@ -18,4 +18,3 @@ export interface IChatProps {
18
18
  styles?: IStyles;
19
19
  }
20
20
  export declare const Chat: React.FC<IChatProps>;
21
- export {};
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ import { ICharacter, IChatMessage, IPrivateChatMessage } from '@rpg-engine/shared';
3
+ import { IStyles } from '../Chat/Chat';
4
+ export interface ITabStyles {
5
+ width?: string;
6
+ height?: string;
7
+ }
8
+ export declare type PrivateChatCharacter = Pick<ICharacter, '_id' | 'name'>;
9
+ export interface IChatRevampProps {
10
+ chatMessages: IChatMessage[] | IPrivateChatMessage[];
11
+ onSendGlobalChatMessage: (message: string) => void;
12
+ onCloseButton: () => void;
13
+ onFocus?: () => void;
14
+ onBlur?: () => void;
15
+ opacity?: number;
16
+ styles?: IStyles;
17
+ tabs: {
18
+ label: string;
19
+ id: string;
20
+ }[];
21
+ activeTab: string;
22
+ onChangeTab: (tabId: string) => void;
23
+ privateChatCharacters?: PrivateChatCharacter[];
24
+ onChangeCharacterName: (characterName: string) => void;
25
+ onCharacterClick?: (character: PrivateChatCharacter) => void;
26
+ onSendPrivateChatMessage: (message: string) => void;
27
+ }
28
+ export declare const ChatRevamp: ({ chatMessages, onSendGlobalChatMessage, onChangeCharacterName, onFocus, onBlur, onCloseButton, styles, tabs, onChangeTab, activeTab, privateChatCharacters, onCharacterClick, onSendPrivateChatMessage, }: IChatRevampProps) => JSX.Element;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { IStyles } from '../Chat/Chat';
3
+ import type { PrivateChatCharacter } from './ChatRevamp';
4
+ interface ISearchCharacterProps {
5
+ onFocus?: () => void;
6
+ onBlur?: () => void;
7
+ onChangeCharacterName: (characterName: string) => void;
8
+ styles?: IStyles;
9
+ recentCharacters?: PrivateChatCharacter[];
10
+ setShowSearchCharacter: (show: boolean) => void;
11
+ onCharacterClick?: (character: PrivateChatCharacter) => void;
12
+ }
13
+ export declare const SearchCharacter: ({ onChangeCharacterName, onBlur, onFocus, recentCharacters, setShowSearchCharacter, onCharacterClick, styles, }: ISearchCharacterProps) => JSX.Element;
14
+ export {};
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
+ import { IStyles } from '../Chat/Chat';
2
3
  interface IProps {
3
4
  id: string;
4
5
  children: React.ReactNode;
6
+ styles?: IStyles;
5
7
  }
6
8
  export declare const TabBody: React.FC<IProps>;
7
9
  export {};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './components/Button';
2
2
  export * from './components/Character/CharacterSelection';
3
3
  export * from './components/Chat/Chat';
4
+ export * from './components/ChatRevamp/ChatRevamp';
4
5
  export * from './components/Chatdeprecated/ChatDeprecated';
5
6
  export * from './components/CheckButton';
6
7
  export * from './components/CircularController/CircularController';
@@ -12559,15 +12559,11 @@ var Chat = function Chat(_ref) {
12559
12559
  return dayjs(createdAt || new Date()).format('HH:mm') + " " + (emitter != null && emitter.name ? emitter.name + ": " : 'Unknown: ') + " " + message;
12560
12560
  };
12561
12561
  var onRenderChatMessages = function onRenderChatMessages(chatMessages) {
12562
- return chatMessages != null && chatMessages.length ? chatMessages == null ? void 0 : chatMessages.map(function (_ref2, index) {
12563
- var _id = _ref2._id,
12564
- createdAt = _ref2.createdAt,
12565
- emitter = _ref2.emitter,
12566
- message = _ref2.message;
12562
+ return chatMessages != null && chatMessages.length ? chatMessages == null ? void 0 : chatMessages.map(function (chatMessage, index) {
12567
12563
  return React__default.createElement(Message, {
12568
12564
  color: (styles == null ? void 0 : styles.textColor) || '#c65102',
12569
- key: _id + "_" + index
12570
- }, onRenderMessageLines(emitter, createdAt, message));
12565
+ key: chatMessage._id + "_" + index
12566
+ }, onRenderMessageLines(chatMessage.emitter, chatMessage.createdAt, chatMessage.message));
12571
12567
  }) : React__default.createElement(Message, {
12572
12568
  color: (styles == null ? void 0 : styles.textColor) || '#c65102'
12573
12569
  }, "No messages available.");
@@ -12614,8 +12610,8 @@ var ChatContainer = /*#__PURE__*/styled.div.withConfig({
12614
12610
  componentId: "sc-1bk05n6-0"
12615
12611
  })(["height:", ";width:", ";padding:10px;background-color:rgba(0,0,0,0.2);height:auto;"], function (props) {
12616
12612
  return props.height;
12617
- }, function (_ref3) {
12618
- var width = _ref3.width;
12613
+ }, function (_ref2) {
12614
+ var width = _ref2.width;
12619
12615
  return width;
12620
12616
  });
12621
12617
  var TextField = /*#__PURE__*/styled.input.withConfig({
@@ -12629,8 +12625,8 @@ var MessagesContainer = /*#__PURE__*/styled.div.withConfig({
12629
12625
  var Message = /*#__PURE__*/styled.div.withConfig({
12630
12626
  displayName: "Chat__Message",
12631
12627
  componentId: "sc-1bk05n6-3"
12632
- })(["margin-bottom:8px;color:", ";"], function (_ref4) {
12633
- var color = _ref4.color;
12628
+ })(["margin-bottom:8px;color:", ";"], function (_ref3) {
12629
+ var color = _ref3.color;
12634
12630
  return color;
12635
12631
  });
12636
12632
  var Form = /*#__PURE__*/styled.form.withConfig({
@@ -12640,11 +12636,11 @@ var Form = /*#__PURE__*/styled.form.withConfig({
12640
12636
  var Button$1 = /*#__PURE__*/styled.button.withConfig({
12641
12637
  displayName: "Chat__Button",
12642
12638
  componentId: "sc-1bk05n6-5"
12643
- })(["color:", ";background-color:", ";width:28px;height:28px;border:none !important;"], function (_ref5) {
12644
- var buttonColor = _ref5.buttonColor;
12639
+ })(["color:", ";background-color:", ";width:28px;height:28px;border:none !important;"], function (_ref4) {
12640
+ var buttonColor = _ref4.buttonColor;
12645
12641
  return buttonColor;
12646
- }, function (_ref6) {
12647
- var buttonBackgroundColor = _ref6.buttonBackgroundColor;
12642
+ }, function (_ref5) {
12643
+ var buttonBackgroundColor = _ref5.buttonBackgroundColor;
12648
12644
  return buttonBackgroundColor;
12649
12645
  });
12650
12646
 
@@ -12670,6 +12666,174 @@ var uiColors = {
12670
12666
  white: '#fff'
12671
12667
  };
12672
12668
 
12669
+ var SearchCharacter = function SearchCharacter(_ref) {
12670
+ var onChangeCharacterName = _ref.onChangeCharacterName,
12671
+ onBlur = _ref.onBlur,
12672
+ onFocus = _ref.onFocus,
12673
+ recentCharacters = _ref.recentCharacters,
12674
+ setShowSearchCharacter = _ref.setShowSearchCharacter,
12675
+ onCharacterClick = _ref.onCharacterClick,
12676
+ _ref$styles = _ref.styles,
12677
+ styles = _ref$styles === void 0 ? {
12678
+ textColor: '#c65102',
12679
+ buttonColor: '#005b96',
12680
+ buttonBackgroundColor: 'rgba(0,0,0,.2)',
12681
+ width: '80%',
12682
+ height: 'auto'
12683
+ } : _ref$styles;
12684
+ var _useState = React.useState(''),
12685
+ characterName = _useState[0],
12686
+ setCharacterName = _useState[1];
12687
+ var handleSubmit = function handleSubmit(event) {
12688
+ event.preventDefault();
12689
+ if (!characterName || characterName.trim() === '') return;
12690
+ onChangeCharacterName(characterName);
12691
+ };
12692
+ var handleCharacterClick = function handleCharacterClick(character) {
12693
+ if (!onCharacterClick) return;
12694
+ setCharacterName('');
12695
+ onCharacterClick(character);
12696
+ setShowSearchCharacter(false);
12697
+ };
12698
+ return React__default.createElement(SearchCharacterContainer, {
12699
+ width: (styles == null ? void 0 : styles.width) || '80%',
12700
+ height: (styles == null ? void 0 : styles.height) || 'auto'
12701
+ }, React__default.createElement(Form$1, {
12702
+ onSubmit: handleSubmit
12703
+ }, React__default.createElement(Column, {
12704
+ flex: 70
12705
+ }, React__default.createElement(TextField$1, {
12706
+ value: characterName,
12707
+ id: "inputCharacterName",
12708
+ onChange: function onChange(e) {
12709
+ setCharacterName(e.target.value);
12710
+ onChangeCharacterName(e.target.value);
12711
+ },
12712
+ height: 20,
12713
+ type: "text",
12714
+ autoComplete: "off",
12715
+ onFocus: onFocus,
12716
+ onBlur: onBlur,
12717
+ onPointerDown: onFocus,
12718
+ autoFocus: true
12719
+ })), React__default.createElement(Column, {
12720
+ justifyContent: "flex-end"
12721
+ }, React__default.createElement(SearchButton, {
12722
+ buttonColor: (styles == null ? void 0 : styles.buttonColor) || '#005b96',
12723
+ buttonBackgroundColor: (styles == null ? void 0 : styles.buttonBackgroundColor) || 'rgba(0,0,0,.5)',
12724
+ id: "chat-send-button",
12725
+ style: {
12726
+ borderRadius: '20%'
12727
+ }
12728
+ }, React__default.createElement(rx.RxMagnifyingGlass, {
12729
+ size: 15
12730
+ })))), recentCharacters && recentCharacters.length > 0 && React__default.createElement(ListContainer, null, recentCharacters.map(function (character) {
12731
+ return React__default.createElement(ListElement, {
12732
+ onPointerDown: function onPointerDown() {
12733
+ return handleCharacterClick(character);
12734
+ },
12735
+ key: character._id
12736
+ }, character.name);
12737
+ })));
12738
+ };
12739
+ var SearchCharacterContainer = /*#__PURE__*/styled.div.withConfig({
12740
+ displayName: "SearchCharacter__SearchCharacterContainer",
12741
+ componentId: "sc-172lyfr-0"
12742
+ })(["height:", ";width:", ";padding:10px;background-color:rgba(0,0,0,0.2);height:auto;"], function (props) {
12743
+ return props.height;
12744
+ }, function (_ref2) {
12745
+ var width = _ref2.width;
12746
+ return width;
12747
+ });
12748
+ var Form$1 = /*#__PURE__*/styled.form.withConfig({
12749
+ displayName: "SearchCharacter__Form",
12750
+ componentId: "sc-172lyfr-1"
12751
+ })(["display:flex;width:100%;justify-content:center;align-items:center;"]);
12752
+ var TextField$1 = /*#__PURE__*/styled.input.withConfig({
12753
+ displayName: "SearchCharacter__TextField",
12754
+ componentId: "sc-172lyfr-2"
12755
+ })(["width:100%;background-color:rgba(0,0,0,0.25) !important;border:none !important;max-height:28px !important;"]);
12756
+ var SearchButton = /*#__PURE__*/styled.button.withConfig({
12757
+ displayName: "SearchCharacter__SearchButton",
12758
+ componentId: "sc-172lyfr-3"
12759
+ })(["color:", ";background-color:", ";width:28px;height:28px;border:none !important;"], function (_ref3) {
12760
+ var buttonColor = _ref3.buttonColor;
12761
+ return buttonColor;
12762
+ }, function (_ref4) {
12763
+ var buttonBackgroundColor = _ref4.buttonBackgroundColor;
12764
+ return buttonBackgroundColor;
12765
+ });
12766
+ var ListContainer = /*#__PURE__*/styled.ul.withConfig({
12767
+ displayName: "SearchCharacter__ListContainer",
12768
+ componentId: "sc-172lyfr-4"
12769
+ })(["border:none;overflow-y:scroll;list-style:none;padding:0;"]);
12770
+ var ListElement = /*#__PURE__*/styled.li.withConfig({
12771
+ displayName: "SearchCharacter__ListElement",
12772
+ componentId: "sc-172lyfr-5"
12773
+ })(["margin:0.5rem 0 !important;font-size:", ";&:hover{color:#ff0;background-color:", ";}button{all:unset;}"], uiFonts.size.small, uiColors.darkGray);
12774
+
12775
+ var ChatRevamp = function ChatRevamp(_ref) {
12776
+ var chatMessages = _ref.chatMessages,
12777
+ onSendGlobalChatMessage = _ref.onSendGlobalChatMessage,
12778
+ onChangeCharacterName = _ref.onChangeCharacterName,
12779
+ onFocus = _ref.onFocus,
12780
+ onBlur = _ref.onBlur,
12781
+ onCloseButton = _ref.onCloseButton,
12782
+ styles = _ref.styles,
12783
+ tabs = _ref.tabs,
12784
+ onChangeTab = _ref.onChangeTab,
12785
+ activeTab = _ref.activeTab,
12786
+ privateChatCharacters = _ref.privateChatCharacters,
12787
+ onCharacterClick = _ref.onCharacterClick,
12788
+ onSendPrivateChatMessage = _ref.onSendPrivateChatMessage;
12789
+ var _useState = React.useState(true),
12790
+ showSearchCharacter = _useState[0],
12791
+ setShowSearchCharacter = _useState[1];
12792
+ React.useEffect(function () {
12793
+ setShowSearchCharacter(true);
12794
+ }, [activeTab]);
12795
+ var isPrivate = activeTab === 'private';
12796
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement(TabContainer, null, tabs.map(function (tab, index) {
12797
+ return React__default.createElement(Tab, {
12798
+ key: tab.label + "_" + index,
12799
+ active: tab.id === activeTab,
12800
+ onPointerDown: function onPointerDown() {
12801
+ return onChangeTab(tab.id);
12802
+ }
12803
+ }, tab.label);
12804
+ })), isPrivate && showSearchCharacter ? React__default.createElement(SearchCharacter, {
12805
+ onFocus: onFocus,
12806
+ onBlur: onBlur,
12807
+ onChangeCharacterName: onChangeCharacterName,
12808
+ styles: styles,
12809
+ recentCharacters: privateChatCharacters,
12810
+ setShowSearchCharacter: setShowSearchCharacter,
12811
+ onCharacterClick: onCharacterClick
12812
+ }) : React__default.createElement(Chat, {
12813
+ chatMessages: chatMessages,
12814
+ onSendChatMessage: isPrivate ? onSendPrivateChatMessage : onSendGlobalChatMessage,
12815
+ sendMessage: true,
12816
+ onCloseButton: onCloseButton,
12817
+ styles: styles,
12818
+ onFocus: onFocus,
12819
+ onBlur: onBlur
12820
+ }));
12821
+ };
12822
+ var TabContainer = /*#__PURE__*/styled.div.withConfig({
12823
+ displayName: "ChatRevamp__TabContainer",
12824
+ componentId: "sc-1sdiknw-0"
12825
+ })(["width:100%;display:flex;gap:10px;"]);
12826
+ var Tab = /*#__PURE__*/styled.button.withConfig({
12827
+ displayName: "ChatRevamp__Tab",
12828
+ componentId: "sc-1sdiknw-1"
12829
+ })(["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) {
12830
+ return props.active ? '#c65102' : uiColors.gray;
12831
+ }, function (props) {
12832
+ return props.active ? uiColors.orange : 'transparent';
12833
+ }, function (props) {
12834
+ return props.active ? 'white' : uiColors.raisinBlack;
12835
+ });
12836
+
12673
12837
  var _excluded$2 = ["innerRef"];
12674
12838
  var Input = function Input(_ref) {
12675
12839
  var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
@@ -12772,7 +12936,7 @@ var ChatDeprecated = function ChatDeprecated(_ref) {
12772
12936
  width: '100%',
12773
12937
  height: '80%',
12774
12938
  className: "chat-body dark-background"
12775
- }, onRenderChatMessages(chatMessages)), React__default.createElement(Form$1, {
12939
+ }, onRenderChatMessages(chatMessages)), React__default.createElement(Form$2, {
12776
12940
  onSubmit: handleSubmit
12777
12941
  }, React__default.createElement(Column, {
12778
12942
  flex: 70
@@ -12813,7 +12977,7 @@ var CustomContainer = /*#__PURE__*/styled(RPGUIContainer).withConfig({
12813
12977
  })(["display:block;opacity:", ";&:hover{opacity:1;}.dark-background{background-color:", " !important;}.chat-body{&.rpgui-container.framed-grey{background:unset;}max-height:170px;overflow-y:auto;}"], function (props) {
12814
12978
  return props.opacity;
12815
12979
  }, uiColors.darkGray);
12816
- var Form$1 = /*#__PURE__*/styled.form.withConfig({
12980
+ var Form$2 = /*#__PURE__*/styled.form.withConfig({
12817
12981
  displayName: "ChatDeprecated__Form",
12818
12982
  componentId: "sc-fuuod3-4"
12819
12983
  })(["display:flex;width:100%;justify-content:center;align-items:center;"]);
@@ -13257,7 +13421,7 @@ var RelativeListMenu = function RelativeListMenu(_ref) {
13257
13421
  overflow: 'hidden'
13258
13422
  }
13259
13423
  }, options.map(function (params, index) {
13260
- return React__default.createElement(ListElement, {
13424
+ return React__default.createElement(ListElement$1, {
13261
13425
  key: (params == null ? void 0 : params.id) || index,
13262
13426
  onPointerDown: function onPointerDown() {
13263
13427
  onSelected(params == null ? void 0 : params.id);
@@ -13275,7 +13439,7 @@ var Container$8 = /*#__PURE__*/styled.div.withConfig({
13275
13439
  }, function (props) {
13276
13440
  return props.fontSize;
13277
13441
  });
13278
- var ListElement = /*#__PURE__*/styled.li.withConfig({
13442
+ var ListElement$1 = /*#__PURE__*/styled.li.withConfig({
13279
13443
  displayName: "RelativeListMenu__ListElement",
13280
13444
  componentId: "sc-7hohf-1"
13281
13445
  })(["margin-right:0.5rem;"]);
@@ -15688,7 +15852,7 @@ var ItemContainer$1 = function ItemContainer(_ref) {
15688
15852
  var ItemsContainer = /*#__PURE__*/styled.div.withConfig({
15689
15853
  displayName: "ItemContainer__ItemsContainer",
15690
15854
  componentId: "sc-15y5p9l-0"
15691
- })(["display:flex;justify-content:center;flex-wrap:wrap;"]);
15855
+ })(["display:flex;justify-content:center;flex-wrap:wrap;max-height:270px;overflow-y:auto;"]);
15692
15856
  var QuantitySelectorContainer = /*#__PURE__*/styled.div.withConfig({
15693
15857
  displayName: "ItemContainer__QuantitySelectorContainer",
15694
15858
  componentId: "sc-15y5p9l-1"
@@ -15826,7 +15990,7 @@ var ListMenu = function ListMenu(_ref) {
15826
15990
  overflow: 'hidden'
15827
15991
  }
15828
15992
  }, options.map(function (params, index) {
15829
- return React__default.createElement(ListElement$1, {
15993
+ return React__default.createElement(ListElement$2, {
15830
15994
  key: (params == null ? void 0 : params.id) || index,
15831
15995
  onPointerDown: function onPointerDown() {
15832
15996
  onSelected(params == null ? void 0 : params.id);
@@ -15842,7 +16006,7 @@ var Container$j = /*#__PURE__*/styled.div.withConfig({
15842
16006
  }, function (props) {
15843
16007
  return props.x || 0;
15844
16008
  }, uiFonts.size.xsmall);
15845
- var ListElement$1 = /*#__PURE__*/styled.li.withConfig({
16009
+ var ListElement$2 = /*#__PURE__*/styled.li.withConfig({
15846
16010
  displayName: "ListMenu__ListElement",
15847
16011
  componentId: "sc-i9097t-1"
15848
16012
  })(["margin-right:0.5rem;"]);
@@ -18337,6 +18501,7 @@ exports.Button = Button;
18337
18501
  exports.CharacterSelection = CharacterSelection;
18338
18502
  exports.Chat = Chat;
18339
18503
  exports.ChatDeprecated = ChatDeprecated;
18504
+ exports.ChatRevamp = ChatRevamp;
18340
18505
  exports.CheckButton = CheckButton;
18341
18506
  exports.CircularController = CircularController;
18342
18507
  exports.CraftBook = CraftBook;