@rpg-engine/long-bow 0.8.218 → 0.8.220

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 (33) hide show
  1. package/dist/components/Store/MetadataCollector.d.ts +2 -2
  2. package/dist/components/Store/Store.d.ts +10 -21
  3. package/dist/components/Store/StoreHeader.d.ts +14 -0
  4. package/dist/components/Store/hooks/useStoreCart.d.ts +2 -0
  5. package/dist/components/Store/hooks/useStoreMetadata.d.ts +4 -11
  6. package/dist/components/Store/hooks/useStoreTabs.d.ts +20 -0
  7. package/dist/components/Store/internal/packToBlueprint.d.ts +2 -0
  8. package/dist/components/Store/sections/StoreItemsSection.d.ts +5 -3
  9. package/dist/hooks/useStoreFiltering.d.ts +7 -4
  10. package/dist/long-bow.cjs.development.js +346 -375
  11. package/dist/long-bow.cjs.development.js.map +1 -1
  12. package/dist/long-bow.cjs.production.min.js +1 -1
  13. package/dist/long-bow.cjs.production.min.js.map +1 -1
  14. package/dist/long-bow.esm.js +348 -377
  15. package/dist/long-bow.esm.js.map +1 -1
  16. package/package.json +1 -1
  17. package/src/components/Store/CartView.tsx +7 -2
  18. package/src/components/Store/MetadataCollector.tsx +60 -40
  19. package/src/components/Store/Store.tsx +75 -270
  20. package/src/components/Store/StoreHeader.tsx +74 -0
  21. package/src/components/Store/__test__/MetadataCollector.spec.tsx +94 -164
  22. package/src/components/Store/__test__/Store.spec.tsx +4 -0
  23. package/src/components/Store/__test__/useStoreMetadata.spec.tsx +58 -156
  24. package/src/components/Store/__test__/useStoreTabs.spec.tsx +69 -0
  25. package/src/components/Store/hooks/useStoreCart.ts +5 -2
  26. package/src/components/Store/hooks/useStoreMetadata.ts +30 -48
  27. package/src/components/Store/hooks/useStoreTabs.ts +104 -0
  28. package/src/components/Store/internal/packToBlueprint.ts +21 -0
  29. package/src/components/Store/sections/StoreItemsSection.tsx +19 -60
  30. package/src/components/Store/sections/StorePacksSection.tsx +0 -1
  31. package/src/components/shared/ScrollableContent/ScrollableContent.tsx +3 -6
  32. package/src/hooks/useStoreFiltering.spec.tsx +79 -0
  33. package/src/hooks/useStoreFiltering.ts +27 -9
@@ -1,5 +1,5 @@
1
- import { MetadataType } from "@rpg-engine/shared";
2
- import React from "react";
1
+ import { MetadataType } from '@rpg-engine/shared';
2
+ import React from 'react';
3
3
  export interface IMetadataCollectorProps {
4
4
  metadataType: MetadataType;
5
5
  config: Record<string, any>;
@@ -1,7 +1,7 @@
1
1
  import { IItemPack, IPurchase, IProductBlueprint, UserAccountTypes } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
3
  import { IFeaturedItem } from './FeaturedBanner';
4
- declare type TabId = 'premium' | 'packs' | 'items' | 'characters' | 'wallet' | 'history' | 'redeem';
4
+ import { TabId } from './hooks/useStoreTabs';
5
5
  export interface IStoreProps {
6
6
  items: IProductBlueprint[];
7
7
  packs?: IItemPack[];
@@ -24,12 +24,7 @@ export interface IStoreProps {
24
24
  customCharactersContent?: React.ReactNode;
25
25
  customWalletContent?: React.ReactNode;
26
26
  customHistoryContent?: React.ReactNode;
27
- /** When true the store renders full-screen (useful on mobile). */
28
27
  fullScreen?: boolean;
29
- /** Override the DraggableContainer width (e.g. "90vw"). Defaults to "1000px". */
30
- containerWidth?: string;
31
- /** Override the DraggableContainer height (e.g. "80vh"). Defaults to "80vh" so the inner scroll area is bounded. */
32
- containerHeight?: string;
33
28
  packsBadge?: string;
34
29
  featuredItems?: IFeaturedItem[];
35
30
  onQuickBuy?: (item: IProductBlueprint, quantity?: number) => void;
@@ -47,48 +42,42 @@ export interface IStoreProps {
47
42
  saleEndsAt?: string;
48
43
  originalPrice?: number;
49
44
  }>;
50
- /** Fires when an item row becomes visible (on mount). Useful for store_item_viewed analytics. */
51
45
  onItemView?: (item: IProductBlueprint, position: number) => void;
52
- /** Fires when a pack row becomes visible (on mount). Useful for pack_viewed analytics. */
53
46
  onPackView?: (pack: IItemPack, position: number) => void;
54
- /** Fires when the active store tab changes (e.g. 'items', 'packs', 'premium'). */
55
47
  onTabChange?: (tab: string, itemsShown: number) => void;
56
- /** Fires when the category filter changes in the items tab. */
57
48
  onCategoryChange?: (category: string, itemsShown: number) => void;
58
- /** Fires when the cart is opened. */
59
49
  onCartOpen?: () => void;
60
- /** Fires when any item or pack is added to the cart. */
61
50
  onAddToCart?: (item: IProductBlueprint, quantity: number) => void;
62
- /** Fires when an item is removed from the cart. */
63
51
  onRemoveFromCart?: (itemKey: string) => void;
64
- /** Fires when the user taps "Pay" — before the purchase resolves. */
65
52
  onCheckoutStart?: (items: Array<{
66
53
  key: string;
67
54
  name: string;
68
55
  quantity: number;
69
56
  }>, total: number) => void;
70
- /** Fires after a successful purchase. */
71
57
  onPurchaseSuccess?: (items: Array<{
72
58
  key: string;
73
59
  name: string;
74
60
  quantity: number;
75
61
  }>, total: number) => void;
76
- /** Fires when a purchase fails. */
77
62
  onPurchaseError?: (error: string) => void;
78
- /** Called when the DC nudge in CartView is tapped — open the DC purchase flow. */
79
63
  onBuyDC?: () => void;
80
- /** Currency symbol to display (e.g. "$" for USD, "R$" for BRL). Defaults to "$". */
81
64
  currencySymbol?: string;
82
- /** Callback to redeem a voucher code. When provided, the Redeem tab is shown. */
83
65
  onRedeem?: (code: string) => Promise<{
84
66
  success: boolean;
85
67
  dcAmount?: number;
86
68
  error?: string;
87
69
  }>;
88
- /** Called when the voucher code input gains focus. */
89
70
  onRedeemInputFocus?: () => void;
90
- /** Called when the voucher code input loses focus. */
91
71
  onRedeemInputBlur?: () => void;
72
+ /** Override the modal width. Defaults to '1000px'. */
73
+ width?: string;
74
+ /** Override the modal height. Defaults to 'min(85vh, 900px)'. */
75
+ height?: string;
76
+ /** Override the item category filter pills. Auto-derived from item.itemType when omitted. */
77
+ itemCategoryOptions?: Array<{
78
+ value: string;
79
+ label: string;
80
+ }>;
92
81
  }
93
82
  export type { IFeaturedItem };
94
83
  export declare const Store: React.FC<IStoreProps>;
@@ -0,0 +1,14 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { TabId } from './hooks/useStoreTabs';
3
+ export interface IStoreHeaderProps {
4
+ tabs: Array<{
5
+ id: TabId;
6
+ label: ReactNode;
7
+ icon: ReactNode;
8
+ }>;
9
+ activeTabId: TabId;
10
+ onTabChange: (tabId: string) => void;
11
+ cartItemCount: number;
12
+ onOpenCart: () => void;
13
+ }
14
+ export declare const StoreHeader: React.FC<IStoreHeaderProps>;
@@ -15,6 +15,8 @@ interface IUseStoreCart {
15
15
  getTotalItems: () => number;
16
16
  getTotalPrice: () => number;
17
17
  isCollectingMetadata: boolean;
18
+ currentMetadataItem: IProductBlueprint | null;
19
+ resolveMetadata: (metadata: Record<string, any> | null) => void;
18
20
  }
19
21
  export declare const useStoreCart: () => IUseStoreCart;
20
22
  export {};
@@ -1,15 +1,8 @@
1
- import { IProductBlueprint } from "@rpg-engine/shared";
2
- interface IUseStoreMetadata {
1
+ import { IProductBlueprint } from '@rpg-engine/shared';
2
+ export interface IUseStoreMetadata {
3
3
  collectMetadata: (item: IProductBlueprint) => Promise<Record<string, any> | null>;
4
+ resolveMetadata: (metadata: Record<string, any> | null) => void;
4
5
  isCollectingMetadata: boolean;
6
+ currentMetadataItem: IProductBlueprint | null;
5
7
  }
6
8
  export declare const useStoreMetadata: () => IUseStoreMetadata;
7
- declare global {
8
- interface Window {
9
- __metadataResolvers?: {
10
- resolve: (metadata: Record<string, any> | null) => void;
11
- item: IProductBlueprint;
12
- };
13
- }
14
- }
15
- export {};
@@ -0,0 +1,20 @@
1
+ export declare type TabId = 'premium' | 'packs' | 'items' | 'characters' | 'wallet' | 'history' | 'redeem';
2
+ interface IUseStoreTabsParams {
3
+ tabOrder?: TabId[];
4
+ defaultActiveTab?: TabId;
5
+ hidePremiumTab?: boolean;
6
+ hasCharacters?: boolean;
7
+ hasRedeem?: boolean;
8
+ hasWallet?: boolean;
9
+ hasHistory?: boolean;
10
+ onTabChange?: (tab: TabId, itemsShown: number) => void;
11
+ getItemCount?: (tab: TabId) => number;
12
+ }
13
+ interface IUseStoreTabs {
14
+ availableTabIds: TabId[];
15
+ activeTab: TabId;
16
+ setActiveTab: (tab: TabId) => void;
17
+ handleTabChange: (tabId: string) => void;
18
+ }
19
+ export declare function useStoreTabs(params: IUseStoreTabsParams): IUseStoreTabs;
20
+ export {};
@@ -0,0 +1,2 @@
1
+ import { IItemPack, IProductBlueprint } from '@rpg-engine/shared';
2
+ export declare function packToBlueprint(pack: IItemPack): IProductBlueprint;
@@ -16,12 +16,14 @@ interface IStoreItemsSectionProps {
16
16
  saleEndsAt?: string;
17
17
  originalPrice?: number;
18
18
  }>;
19
- /** Fires when an item row becomes visible. Passes item and its 0-based position. */
20
19
  onItemView?: (item: IProductBlueprint, position: number) => void;
21
- /** Fires when the category filter changes. Passes new category and item count. */
22
20
  onCategoryChange?: (category: string, itemsShown: number) => void;
23
- /** Currency symbol to display (e.g. "$" for USD, "R$" for BRL). Defaults to "$". */
24
21
  currencySymbol?: string;
22
+ /** Override the auto-derived category filter pills. */
23
+ categoryOptions?: Array<{
24
+ value: string;
25
+ label: string;
26
+ }>;
25
27
  }
26
28
  export declare const StoreItemsSection: React.FC<IStoreItemsSectionProps>;
27
29
  export {};
@@ -1,11 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { IProductBlueprint, ItemType } from '@rpg-engine/shared';
2
+ import { IProductBlueprint } from '@rpg-engine/shared';
3
3
  import { IOptionsProps } from '../components/Dropdown';
4
- export declare const useStoreFiltering: (items: IProductBlueprint[]) => {
4
+ export declare const useStoreFiltering: (items: IProductBlueprint[], overrideCategoryOptions?: {
5
+ value: string;
6
+ label: string;
7
+ }[] | undefined) => {
5
8
  searchQuery: string;
6
9
  setSearchQuery: import("react").Dispatch<import("react").SetStateAction<string>>;
7
- selectedCategory: ItemType | "all";
8
- setSelectedCategory: import("react").Dispatch<import("react").SetStateAction<ItemType | "all">>;
10
+ selectedCategory: string;
11
+ setSelectedCategory: import("react").Dispatch<import("react").SetStateAction<string>>;
9
12
  categoryOptions: IOptionsProps[];
10
13
  filteredItems: IProductBlueprint[];
11
14
  };