@rpg-engine/long-bow 0.8.140 → 0.8.145

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.
Files changed (68) hide show
  1. package/dist/components/Marketplace/BlueprintSearchModal.d.ts +17 -0
  2. package/dist/components/Marketplace/BuyOrderDetailsModal.d.ts +17 -0
  3. package/dist/components/Marketplace/BuyOrderPanel.d.ts +24 -0
  4. package/dist/components/Marketplace/BuyOrderRows.d.ts +13 -0
  5. package/dist/components/Marketplace/BuyPanel.d.ts +9 -1
  6. package/dist/components/Marketplace/HistoryPanel.d.ts +18 -0
  7. package/dist/components/Marketplace/ManagmentPanel.d.ts +4 -3
  8. package/dist/components/Marketplace/Marketplace.d.ts +38 -2
  9. package/dist/components/Marketplace/MarketplaceRows.d.ts +13 -1
  10. package/dist/components/Marketplace/MarketplaceSettingsPanel.d.ts +8 -0
  11. package/dist/components/Store/PaymentMethodModal.d.ts +1 -0
  12. package/dist/components/shared/LabelPill/LabelPill.d.ts +9 -0
  13. package/dist/components/shared/LabelPill/index.d.ts +1 -0
  14. package/dist/components/shared/SegmentedToggle/SegmentedToggle.d.ts +12 -0
  15. package/dist/components/shared/SegmentedToggle/index.d.ts +1 -0
  16. package/dist/components/shared/Tabs/Tabs.d.ts +13 -0
  17. package/dist/components/shared/Tabs/index.d.ts +1 -0
  18. package/dist/index.d.ts +5 -0
  19. package/dist/long-bow.cjs.development.js +12074 -1449
  20. package/dist/long-bow.cjs.development.js.map +1 -1
  21. package/dist/long-bow.cjs.production.min.js +1 -1
  22. package/dist/long-bow.cjs.production.min.js.map +1 -1
  23. package/dist/long-bow.esm.js +12060 -1450
  24. package/dist/long-bow.esm.js.map +1 -1
  25. package/dist/stories/Features/marketplace/BlueprintSearchModal.stories.d.ts +1 -0
  26. package/dist/stories/Features/marketplace/BuyOrderPanel.stories.d.ts +1 -0
  27. package/dist/stories/Features/marketplace/BuyOrderRows.stories.d.ts +1 -0
  28. package/dist/stories/Features/marketplace/HistoryPanel.stories.d.ts +1 -0
  29. package/dist/stories/Features/trading/MarketplaceRows.stories.d.ts +2 -1
  30. package/dist/stories/UI/buttonsAndInputs/SegmentedToggle.stories.d.ts +6 -0
  31. package/dist/stories/UI/text/LabelPill.stories.d.ts +7 -0
  32. package/dist/utils/atlasUtils.d.ts +2 -0
  33. package/package.json +3 -2
  34. package/src/components/ConfirmModal.tsx +50 -27
  35. package/src/components/Marketplace/BlueprintSearchModal.tsx +418 -0
  36. package/src/components/Marketplace/BuyOrderDetailsModal.tsx +307 -0
  37. package/src/components/Marketplace/BuyOrderPanel.tsx +266 -0
  38. package/src/components/Marketplace/BuyOrderRows.tsx +287 -0
  39. package/src/components/Marketplace/BuyPanel.tsx +486 -170
  40. package/src/components/Marketplace/HistoryPanel.tsx +422 -0
  41. package/src/components/Marketplace/ManagmentPanel.tsx +176 -98
  42. package/src/components/Marketplace/Marketplace.tsx +227 -40
  43. package/src/components/Marketplace/MarketplaceBuyModal.tsx +1 -0
  44. package/src/components/Marketplace/MarketplaceRows.tsx +274 -80
  45. package/src/components/Marketplace/MarketplaceSettingsPanel.tsx +128 -0
  46. package/src/components/Store/CartView.tsx +11 -0
  47. package/src/components/Store/PaymentMethodModal.tsx +26 -9
  48. package/src/components/shared/LabelPill/LabelPill.tsx +45 -0
  49. package/src/components/shared/LabelPill/index.ts +1 -0
  50. package/src/components/shared/SegmentedToggle/SegmentedToggle.tsx +61 -0
  51. package/src/components/shared/SegmentedToggle/index.ts +1 -0
  52. package/src/components/shared/SpriteFromAtlas.tsx +7 -2
  53. package/src/components/shared/Tabs/Tabs.tsx +60 -0
  54. package/src/components/shared/Tabs/index.ts +1 -0
  55. package/src/index.tsx +5 -0
  56. package/src/mocks/atlas/items/items.json +33998 -25238
  57. package/src/mocks/atlas/items/items.png +0 -0
  58. package/src/mocks/itemContainer.mocks.ts +31 -0
  59. package/src/stories/Features/marketplace/BlueprintSearchModal.stories.tsx +145 -0
  60. package/src/stories/Features/marketplace/BuyOrderPanel.stories.tsx +207 -0
  61. package/src/stories/Features/marketplace/BuyOrderRows.stories.tsx +116 -0
  62. package/src/stories/Features/marketplace/HistoryPanel.stories.tsx +157 -0
  63. package/src/stories/Features/trading/Marketplace.stories.tsx +109 -0
  64. package/src/stories/Features/trading/MarketplaceRows.stories.tsx +11 -0
  65. package/src/stories/UI/buttonsAndInputs/SegmentedToggle.stories.tsx +54 -0
  66. package/src/stories/UI/text/LabelPill.stories.tsx +43 -0
  67. package/src/utils/__test__/atlasUtils.spec.ts +26 -0
  68. package/src/utils/atlasUtils.ts +80 -0
@@ -1,13 +1,30 @@
1
- import { IEquipmentSet, IItem, IMarketplaceItem } from '@rpg-engine/shared';
1
+ import {
2
+ IEquipmentSet,
3
+ IItem,
4
+ IMarketplaceBlueprintSearchRequest,
5
+ IMarketplaceBlueprintSummary,
6
+ IMarketplaceBuyOrderItem,
7
+ IMarketplaceItem,
8
+ IMarketplaceTransaction,
9
+ } from '@rpg-engine/shared';
10
+ import { Clock } from 'pixelarticons/react/Clock';
11
+ import { Settings2 } from 'pixelarticons/react/Settings2';
12
+ import { ShoppingBag } from 'pixelarticons/react/ShoppingBag';
13
+ import { ShoppingCart } from 'pixelarticons/react/ShoppingCart';
14
+ import { Store } from 'pixelarticons/react/Store';
2
15
  import React, { useState } from 'react';
3
16
  import styled from 'styled-components';
4
- import { Button, ButtonTypes } from '../Button';
5
17
  import { DraggableContainer } from '../DraggableContainer';
6
18
  import { Pager } from '../Pager';
7
19
  import { RPGUIContainerTypes } from '../RPGUI/RPGUIContainer';
8
- import { MarketplacePaymentMethod } from './MarketplaceBuyModal';
20
+ import { Tabs } from '../shared/Tabs';
21
+ import { BlueprintSearchModal } from './BlueprintSearchModal';
22
+ import { BuyOrderPanel } from './BuyOrderPanel';
9
23
  import { BuyPanel } from './BuyPanel';
24
+ import { HistoryPanel } from './HistoryPanel';
10
25
  import { ManagmentPanel } from './ManagmentPanel';
26
+ import { MarketplacePaymentMethod } from './MarketplaceBuyModal';
27
+ import { MarketplaceAcceptedCurrency, MarketplaceSettingsPanel } from './MarketplaceSettingsPanel';
11
28
 
12
29
  export interface IMarketPlaceProps {
13
30
  items: IMarketplaceItem[];
@@ -28,12 +45,13 @@ export interface IMarketPlaceProps {
28
45
  scale?: number;
29
46
  equipmentSet?: IEquipmentSet | null;
30
47
  onMarketPlaceItemBuy?: (marketPlaceItemId: string, paymentMethod?: MarketplacePaymentMethod) => void;
48
+ onFulfillBuyOrder?: (buyOrderId: string) => void;
31
49
  onMarketPlaceItemRemove?: (marketPlaceItemId: string) => void;
32
50
  availableGold: number;
33
51
  selectedItemToSell: IItem | null;
34
52
  onSelectedItemToSellRemove: (item: IItem) => void;
35
53
  onYourPanelToggle: (yourPanel: boolean) => void;
36
- onAddItemToMarketplace: (item: IItem, price: number) => void;
54
+ onAddItemToMarketplace: (item: IItem, price: number, acceptedCurrency?: MarketplaceAcceptedCurrency) => void;
37
55
  characterId: string;
38
56
  enableHotkeys?: () => void;
39
57
  disableHotkeys?: () => void;
@@ -44,12 +62,112 @@ export interface IMarketPlaceProps {
44
62
  onPageChange: (page: number) => void;
45
63
  dcBalance?: number;
46
64
  dcToGoldSwapRate?: number;
65
+ acceptedCurrency?: MarketplaceAcceptedCurrency;
66
+ onAcceptedCurrencyChange?: (value: MarketplaceAcceptedCurrency) => void;
67
+ onActiveTabChange?: (tab: string) => void;
68
+
69
+ // Buy Order props
70
+ buyOrderSelectedBlueprint?: IMarketplaceBlueprintSummary;
71
+ buyOrderQuantity?: number;
72
+ buyOrderMaxPrice?: number;
73
+ buyOrderSelectedRarity?: string;
74
+ onBuyOrderQuantityChange?: (quantity: number) => void;
75
+ onBuyOrderMaxPriceChange?: (price: number) => void;
76
+ onBuyOrderRarityChange?: (rarity: string) => void;
77
+ onPlaceBuyOrder?: () => void;
78
+ onClearBuyOrderBlueprint?: () => void;
79
+ yourBuyOrders?: IMarketplaceBuyOrderItem[];
80
+ yourBuyOrdersTotal?: number;
81
+ yourBuyOrdersPage?: number;
82
+ onYourBuyOrdersPageChange?: (page: number) => void;
83
+ onCancelBuyOrder?: (buyOrderId: string) => void;
84
+ openBuyOrders?: IMarketplaceBuyOrderItem[];
85
+ openBuyOrdersTotal?: number;
86
+ openBuyOrdersPage?: number;
87
+ onOpenBuyOrdersPageChange?: (page: number) => void;
88
+
89
+ // Blueprint Search props
90
+ onBlueprintSearch?: (request: IMarketplaceBlueprintSearchRequest) => void;
91
+ onBlueprintSelect?: (blueprint: IMarketplaceBlueprintSummary) => void;
92
+ blueprintSearchResults?: IMarketplaceBlueprintSummary[];
93
+ blueprintSearchTotalCount?: number;
94
+ blueprintSearchCurrentPage?: number;
95
+ blueprintSearchIsLoading?: boolean;
96
+
97
+ // History props
98
+ historyTransactions?: IMarketplaceTransaction[];
99
+ historyTotalCount?: number;
100
+ historyCurrentPage?: number;
101
+ historyItemsPerPage?: number;
102
+ historySelectedType?: string;
103
+ onHistoryTypeChange?: (type: string) => void;
104
+ onHistoryPageChange?: (page: number) => void;
47
105
  }
48
106
 
107
+ type ActiveTab = 'marketplace' | 'sell' | 'buy-orders' | 'history' | 'settings';
108
+
49
109
  export const Marketplace: React.FC<IMarketPlaceProps> = props => {
50
- const { onClose, scale, onYourPanelToggle } = props;
110
+ const {
111
+ onClose,
112
+ scale,
113
+ onYourPanelToggle,
114
+ onActiveTabChange,
115
+ acceptedCurrency: acceptedCurrencyProp,
116
+ onAcceptedCurrencyChange,
117
+ // Buy Order
118
+ buyOrderSelectedBlueprint,
119
+ buyOrderQuantity = 0,
120
+ buyOrderMaxPrice = 0,
121
+ buyOrderSelectedRarity = '',
122
+ onBuyOrderQuantityChange,
123
+ onBuyOrderMaxPriceChange,
124
+ onBuyOrderRarityChange,
125
+ onPlaceBuyOrder,
126
+ onClearBuyOrderBlueprint,
127
+ yourBuyOrders = [],
128
+ yourBuyOrdersTotal = 0,
129
+ yourBuyOrdersPage = 1,
130
+ onYourBuyOrdersPageChange,
131
+ onCancelBuyOrder,
132
+ // Blueprint Search
133
+ onBlueprintSearch,
134
+ onBlueprintSelect,
135
+ blueprintSearchResults = [],
136
+ blueprintSearchTotalCount = 0,
137
+ blueprintSearchCurrentPage = 1,
138
+ blueprintSearchIsLoading = false,
139
+ // History
140
+ historyTransactions = [],
141
+ historyTotalCount = 0,
142
+ historyCurrentPage = 1,
143
+ historyItemsPerPage = 10,
144
+ historySelectedType = 'All',
145
+ onHistoryTypeChange,
146
+ onHistoryPageChange,
147
+ } = props;
51
148
 
52
- const [isYourPanel, setIsYourPanel] = useState(false);
149
+ const [activeTab, setActiveTab] = useState<ActiveTab>('marketplace');
150
+ const [acceptedCurrency, setAcceptedCurrency] = useState<MarketplaceAcceptedCurrency>(acceptedCurrencyProp ?? MarketplaceAcceptedCurrency.GoldOrDc);
151
+ const [isBlueprintSearchOpen, setIsBlueprintSearchOpen] = useState(false);
152
+
153
+ const handleCurrencyChange = (value: MarketplaceAcceptedCurrency) => {
154
+ setAcceptedCurrency(value);
155
+ onAcceptedCurrencyChange?.(value);
156
+ };
157
+
158
+ const handleTabChange = (tabId: string) => {
159
+ const tab = tabId as ActiveTab;
160
+ setActiveTab(tab);
161
+ onYourPanelToggle(tab === 'sell');
162
+ onActiveTabChange?.(tab);
163
+ };
164
+
165
+ const handleBlueprintSelect = (blueprint: IMarketplaceBlueprintSummary) => {
166
+ setIsBlueprintSearchOpen(false);
167
+ onBlueprintSelect?.(blueprint);
168
+ };
169
+
170
+ const showSharedPager = activeTab === 'sell';
53
171
 
54
172
  return (
55
173
  <DraggableContainer
@@ -61,49 +179,118 @@ export const Marketplace: React.FC<IMarketPlaceProps> = props => {
61
179
  cancelDrag="#MarketContainer, .rpgui-dropdown-imp, input, .empty-slot, button"
62
180
  scale={scale}
63
181
  >
64
- {isYourPanel && (
65
- <>
66
- <ManagmentPanel {...props} />
67
-
68
- <PagerContainer>
69
- <Button
70
- buttonType={ButtonTypes.RPGUIButton}
71
- onPointerDown={() => {
72
- onYourPanelToggle(false);
73
- setIsYourPanel(false);
74
- }}
75
- >
76
- Go to marketplace
77
- </Button>
78
- <Pager {...props} />
79
- </PagerContainer>
80
- </>
182
+ <Tabs
183
+ options={[
184
+ {
185
+ id: 'marketplace',
186
+ label: 'Marketplace',
187
+ icon: <Store width={18} height={18} />,
188
+ },
189
+ {
190
+ id: 'sell',
191
+ label: 'Sell',
192
+ icon: <ShoppingBag width={18} height={18} />,
193
+ },
194
+ {
195
+ id: 'buy-orders',
196
+ label: 'Buy',
197
+ icon: <ShoppingCart width={18} height={18} />,
198
+ },
199
+ {
200
+ id: 'history',
201
+ label: 'History',
202
+ icon: <Clock width={18} height={18} />,
203
+ },
204
+ {
205
+ id: 'settings',
206
+ label: 'Settings',
207
+ icon: <Settings2 width={18} height={18} />,
208
+ },
209
+ ]}
210
+ activeTabId={activeTab}
211
+ onTabChange={handleTabChange}
212
+ />
213
+
214
+ {activeTab === 'marketplace' && (
215
+ <BuyPanel {...props} />
216
+ )}
217
+
218
+ {activeTab === 'sell' && (
219
+ <ManagmentPanel {...props} acceptedCurrency={acceptedCurrency} />
81
220
  )}
82
- {!isYourPanel && (
221
+
222
+ {activeTab === 'buy-orders' && (
83
223
  <>
84
- <BuyPanel {...props} />
85
-
86
- <PagerContainer>
87
- <Button
88
- buttonType={ButtonTypes.RPGUIButton}
89
- onPointerDown={() => {
90
- onYourPanelToggle(true);
91
- setIsYourPanel(true);
92
- }}
93
- >
94
- Go to your panel
95
- </Button>
96
- <Pager {...props} />
97
- </PagerContainer>
224
+ <BuyOrderPanel
225
+ atlasJSON={props.atlasJSON}
226
+ atlasIMG={props.atlasIMG}
227
+ selectedBlueprint={buyOrderSelectedBlueprint}
228
+ onOpenBlueprintSearch={() => setIsBlueprintSearchOpen(true)}
229
+ onCloseDetails={onClearBuyOrderBlueprint}
230
+ onQuantityChange={onBuyOrderQuantityChange ?? (() => {})}
231
+ onMaxPriceChange={onBuyOrderMaxPriceChange ?? (() => {})}
232
+ onRarityChange={onBuyOrderRarityChange ?? (() => {})}
233
+ onPlaceBuyOrder={onPlaceBuyOrder ?? (() => {})}
234
+ currentQuantity={buyOrderQuantity}
235
+ currentMaxPrice={buyOrderMaxPrice}
236
+ selectedRarity={buyOrderSelectedRarity}
237
+ yourBuyOrders={yourBuyOrders}
238
+ yourBuyOrdersTotal={yourBuyOrdersTotal}
239
+ yourBuyOrdersPage={yourBuyOrdersPage}
240
+ onYourBuyOrdersPageChange={onYourBuyOrdersPageChange ?? (() => {})}
241
+ onCancelBuyOrder={onCancelBuyOrder ?? (() => {})}
242
+ />
243
+ <BlueprintSearchModal
244
+ isOpen={isBlueprintSearchOpen}
245
+ onClose={() => setIsBlueprintSearchOpen(false)}
246
+ onSelect={handleBlueprintSelect}
247
+ onSearch={onBlueprintSearch ?? (() => {})}
248
+ blueprints={blueprintSearchResults}
249
+ totalCount={blueprintSearchTotalCount}
250
+ currentPage={blueprintSearchCurrentPage}
251
+ isLoading={blueprintSearchIsLoading}
252
+ atlasJSON={props.atlasJSON}
253
+ atlasIMG={props.atlasIMG}
254
+ />
98
255
  </>
99
256
  )}
257
+
258
+ {activeTab === 'history' && (
259
+ <HistoryPanel
260
+ transactions={historyTransactions}
261
+ totalCount={historyTotalCount}
262
+ currentPage={historyCurrentPage}
263
+ itemsPerPage={historyItemsPerPage}
264
+ selectedType={historySelectedType}
265
+ onTypeChange={onHistoryTypeChange ?? (() => {})}
266
+ onPageChange={onHistoryPageChange ?? (() => {})}
267
+ atlasJSON={props.atlasJSON}
268
+ atlasIMG={props.atlasIMG}
269
+ dcToGoldSwapRate={props.dcToGoldSwapRate}
270
+ />
271
+ )}
272
+
273
+ {activeTab === 'settings' && (
274
+ <MarketplaceSettingsPanel
275
+ acceptedCurrency={acceptedCurrency}
276
+ onAcceptedCurrencyChange={handleCurrencyChange}
277
+ />
278
+ )}
279
+
280
+ {showSharedPager && (
281
+ <PagerContainer>
282
+ <Pager {...props} />
283
+ </PagerContainer>
284
+ )}
100
285
  </DraggableContainer>
101
286
  );
102
287
  };
103
288
 
104
289
  const PagerContainer = styled.div`
105
290
  display: flex;
106
- justify-content: space-between;
291
+ justify-content: center;
107
292
  align-items: center;
108
- width: calc(100% - 30px);
293
+ width: 95%;
294
+ margin: 6px auto 0 auto;
295
+ padding: 4px 10px;
109
296
  `;
@@ -152,6 +152,7 @@ const CloseButton = styled.button`
152
152
  padding: 4px;
153
153
  display: flex;
154
154
  align-items: center;
155
+ pointer-events: auto;
155
156
 
156
157
  &:hover {
157
158
  color: #ffffff;