@react-text-game/ui 0.1.0

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 (219) hide show
  1. package/README.md +297 -0
  2. package/dist/components/DevModeDrawer/CopyButton.d.ts +4 -0
  3. package/dist/components/DevModeDrawer/CopyButton.d.ts.map +1 -0
  4. package/dist/components/DevModeDrawer/CopyButton.js +17 -0
  5. package/dist/components/DevModeDrawer/CopyButton.js.map +1 -0
  6. package/dist/components/DevModeDrawer/CurrentPassageData.d.ts +4 -0
  7. package/dist/components/DevModeDrawer/CurrentPassageData.d.ts.map +1 -0
  8. package/dist/components/DevModeDrawer/CurrentPassageData.js +23 -0
  9. package/dist/components/DevModeDrawer/CurrentPassageData.js.map +1 -0
  10. package/dist/components/DevModeDrawer/DevModeDrawer.d.ts +7 -0
  11. package/dist/components/DevModeDrawer/DevModeDrawer.d.ts.map +1 -0
  12. package/dist/components/DevModeDrawer/DevModeDrawer.js +29 -0
  13. package/dist/components/DevModeDrawer/DevModeDrawer.js.map +1 -0
  14. package/dist/components/DevModeDrawer/GameData.d.ts +4 -0
  15. package/dist/components/DevModeDrawer/GameData.d.ts.map +1 -0
  16. package/dist/components/DevModeDrawer/GameData.js +22 -0
  17. package/dist/components/DevModeDrawer/GameData.js.map +1 -0
  18. package/dist/components/DevModeDrawer/JumpToPassage.d.ts +2 -0
  19. package/dist/components/DevModeDrawer/JumpToPassage.d.ts.map +1 -0
  20. package/dist/components/DevModeDrawer/JumpToPassage.js +15 -0
  21. package/dist/components/DevModeDrawer/JumpToPassage.js.map +1 -0
  22. package/dist/components/DevModeDrawer/RefreshButton.d.ts +4 -0
  23. package/dist/components/DevModeDrawer/RefreshButton.d.ts.map +1 -0
  24. package/dist/components/DevModeDrawer/RefreshButton.js +5 -0
  25. package/dist/components/DevModeDrawer/RefreshButton.js.map +1 -0
  26. package/dist/components/DevModeDrawer/index.d.ts +2 -0
  27. package/dist/components/DevModeDrawer/index.d.ts.map +1 -0
  28. package/dist/components/DevModeDrawer/index.js +2 -0
  29. package/dist/components/DevModeDrawer/index.js.map +1 -0
  30. package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +22 -0
  31. package/dist/components/ErrorBoundary/ErrorBoundary.d.ts.map +1 -0
  32. package/dist/components/ErrorBoundary/ErrorBoundary.js +135 -0
  33. package/dist/components/ErrorBoundary/ErrorBoundary.js.map +1 -0
  34. package/dist/components/ErrorBoundary/index.d.ts +2 -0
  35. package/dist/components/ErrorBoundary/index.d.ts.map +1 -0
  36. package/dist/components/ErrorBoundary/index.js +2 -0
  37. package/dist/components/ErrorBoundary/index.js.map +1 -0
  38. package/dist/components/ErrorBoundary/types.d.ts +12 -0
  39. package/dist/components/ErrorBoundary/types.d.ts.map +1 -0
  40. package/dist/components/ErrorBoundary/types.js +2 -0
  41. package/dist/components/ErrorBoundary/types.js.map +1 -0
  42. package/dist/components/GameProvider/AppIconMenu.d.ts +8 -0
  43. package/dist/components/GameProvider/AppIconMenu.d.ts.map +1 -0
  44. package/dist/components/GameProvider/AppIconMenu.js +12 -0
  45. package/dist/components/GameProvider/AppIconMenu.js.map +1 -0
  46. package/dist/components/GameProvider/GameProvider.d.ts +12 -0
  47. package/dist/components/GameProvider/GameProvider.d.ts.map +1 -0
  48. package/dist/components/GameProvider/GameProvider.js +36 -0
  49. package/dist/components/GameProvider/GameProvider.js.map +1 -0
  50. package/dist/components/GameProvider/SaveLoadMenuContext.d.ts +11 -0
  51. package/dist/components/GameProvider/SaveLoadMenuContext.d.ts.map +1 -0
  52. package/dist/components/GameProvider/SaveLoadMenuContext.js +3 -0
  53. package/dist/components/GameProvider/SaveLoadMenuContext.js.map +1 -0
  54. package/dist/components/GameProvider/SaveLoadMenuProvider.d.ts +4 -0
  55. package/dist/components/GameProvider/SaveLoadMenuProvider.d.ts.map +1 -0
  56. package/dist/components/GameProvider/SaveLoadMenuProvider.js +32 -0
  57. package/dist/components/GameProvider/SaveLoadMenuProvider.js.map +1 -0
  58. package/dist/components/GameProvider/index.d.ts +2 -0
  59. package/dist/components/GameProvider/index.d.ts.map +1 -0
  60. package/dist/components/GameProvider/index.js +2 -0
  61. package/dist/components/GameProvider/index.js.map +1 -0
  62. package/dist/components/InteractiveMapComponent/Hotspot.d.ts +9 -0
  63. package/dist/components/InteractiveMapComponent/Hotspot.d.ts.map +1 -0
  64. package/dist/components/InteractiveMapComponent/Hotspot.js +30 -0
  65. package/dist/components/InteractiveMapComponent/Hotspot.js.map +1 -0
  66. package/dist/components/InteractiveMapComponent/HotspotMap.d.ts +8 -0
  67. package/dist/components/InteractiveMapComponent/HotspotMap.d.ts.map +1 -0
  68. package/dist/components/InteractiveMapComponent/HotspotMap.js +37 -0
  69. package/dist/components/InteractiveMapComponent/HotspotMap.js.map +1 -0
  70. package/dist/components/InteractiveMapComponent/HotspotMenu.d.ts +9 -0
  71. package/dist/components/InteractiveMapComponent/HotspotMenu.d.ts.map +1 -0
  72. package/dist/components/InteractiveMapComponent/HotspotMenu.js +37 -0
  73. package/dist/components/InteractiveMapComponent/HotspotMenu.js.map +1 -0
  74. package/dist/components/InteractiveMapComponent/ImageHotspot.d.ts +7 -0
  75. package/dist/components/InteractiveMapComponent/ImageHotspot.d.ts.map +1 -0
  76. package/dist/components/InteractiveMapComponent/ImageHotspot.js +23 -0
  77. package/dist/components/InteractiveMapComponent/ImageHotspot.js.map +1 -0
  78. package/dist/components/InteractiveMapComponent/InteractiveMapComponent.d.ts +7 -0
  79. package/dist/components/InteractiveMapComponent/InteractiveMapComponent.d.ts.map +1 -0
  80. package/dist/components/InteractiveMapComponent/InteractiveMapComponent.js +23 -0
  81. package/dist/components/InteractiveMapComponent/InteractiveMapComponent.js.map +1 -0
  82. package/dist/components/InteractiveMapComponent/LabelHotspot.d.ts +7 -0
  83. package/dist/components/InteractiveMapComponent/LabelHotspot.d.ts.map +1 -0
  84. package/dist/components/InteractiveMapComponent/LabelHotspot.js +10 -0
  85. package/dist/components/InteractiveMapComponent/LabelHotspot.js.map +1 -0
  86. package/dist/components/InteractiveMapComponent/SideHotspot.d.ts +7 -0
  87. package/dist/components/InteractiveMapComponent/SideHotspot.d.ts.map +1 -0
  88. package/dist/components/InteractiveMapComponent/SideHotspot.js +11 -0
  89. package/dist/components/InteractiveMapComponent/SideHotspot.js.map +1 -0
  90. package/dist/components/InteractiveMapComponent/helpers.d.ts +11 -0
  91. package/dist/components/InteractiveMapComponent/helpers.d.ts.map +1 -0
  92. package/dist/components/InteractiveMapComponent/helpers.js +34 -0
  93. package/dist/components/InteractiveMapComponent/helpers.js.map +1 -0
  94. package/dist/components/InteractiveMapComponent/index.d.ts +2 -0
  95. package/dist/components/InteractiveMapComponent/index.d.ts.map +1 -0
  96. package/dist/components/InteractiveMapComponent/index.js +2 -0
  97. package/dist/components/InteractiveMapComponent/index.js.map +1 -0
  98. package/dist/components/InteractiveMapComponent/types.d.ts +19 -0
  99. package/dist/components/InteractiveMapComponent/types.d.ts.map +1 -0
  100. package/dist/components/InteractiveMapComponent/types.js +2 -0
  101. package/dist/components/InteractiveMapComponent/types.js.map +1 -0
  102. package/dist/components/InteractiveMapComponent/useHotspotMapSize.d.ts +3 -0
  103. package/dist/components/InteractiveMapComponent/useHotspotMapSize.d.ts.map +1 -0
  104. package/dist/components/InteractiveMapComponent/useHotspotMapSize.js +74 -0
  105. package/dist/components/InteractiveMapComponent/useHotspotMapSize.js.map +1 -0
  106. package/dist/components/InteractiveMapComponent/useSortHotspots.d.ts +16 -0
  107. package/dist/components/InteractiveMapComponent/useSortHotspots.d.ts.map +1 -0
  108. package/dist/components/InteractiveMapComponent/useSortHotspots.js +13 -0
  109. package/dist/components/InteractiveMapComponent/useSortHotspots.js.map +1 -0
  110. package/dist/components/MainMenu.d.ts +2 -0
  111. package/dist/components/MainMenu.d.ts.map +1 -0
  112. package/dist/components/MainMenu.js +15 -0
  113. package/dist/components/MainMenu.js.map +1 -0
  114. package/dist/components/PassageController/PassageController.d.ts +2 -0
  115. package/dist/components/PassageController/PassageController.d.ts.map +1 -0
  116. package/dist/components/PassageController/PassageController.js +25 -0
  117. package/dist/components/PassageController/PassageController.js.map +1 -0
  118. package/dist/components/PassageController/index.d.ts +2 -0
  119. package/dist/components/PassageController/index.d.ts.map +1 -0
  120. package/dist/components/PassageController/index.js +2 -0
  121. package/dist/components/PassageController/index.js.map +1 -0
  122. package/dist/components/ReloadButton.d.ts +15 -0
  123. package/dist/components/ReloadButton.d.ts.map +1 -0
  124. package/dist/components/ReloadButton.js +10 -0
  125. package/dist/components/ReloadButton.js.map +1 -0
  126. package/dist/components/SaveButton.d.ts +21 -0
  127. package/dist/components/SaveButton.d.ts.map +1 -0
  128. package/dist/components/SaveButton.js +10 -0
  129. package/dist/components/SaveButton.js.map +1 -0
  130. package/dist/components/SaveLoadModal/SaveLoadModal.d.ts +9 -0
  131. package/dist/components/SaveLoadModal/SaveLoadModal.d.ts.map +1 -0
  132. package/dist/components/SaveLoadModal/SaveLoadModal.js +52 -0
  133. package/dist/components/SaveLoadModal/SaveLoadModal.js.map +1 -0
  134. package/dist/components/SaveLoadModal/index.d.ts +2 -0
  135. package/dist/components/SaveLoadModal/index.d.ts.map +1 -0
  136. package/dist/components/SaveLoadModal/index.js +2 -0
  137. package/dist/components/SaveLoadModal/index.js.map +1 -0
  138. package/dist/components/StoryComponent/StoryComponent.d.ts +7 -0
  139. package/dist/components/StoryComponent/StoryComponent.d.ts.map +1 -0
  140. package/dist/components/StoryComponent/StoryComponent.js +30 -0
  141. package/dist/components/StoryComponent/StoryComponent.js.map +1 -0
  142. package/dist/components/StoryComponent/components/Actions.d.ts +7 -0
  143. package/dist/components/StoryComponent/components/Actions.d.ts.map +1 -0
  144. package/dist/components/StoryComponent/components/Actions.js +6 -0
  145. package/dist/components/StoryComponent/components/Actions.js.map +1 -0
  146. package/dist/components/StoryComponent/components/Conversation.d.ts +7 -0
  147. package/dist/components/StoryComponent/components/Conversation.d.ts.map +1 -0
  148. package/dist/components/StoryComponent/components/Conversation.js +53 -0
  149. package/dist/components/StoryComponent/components/Conversation.js.map +1 -0
  150. package/dist/components/StoryComponent/components/Header.d.ts +7 -0
  151. package/dist/components/StoryComponent/components/Header.d.ts.map +1 -0
  152. package/dist/components/StoryComponent/components/Header.js +12 -0
  153. package/dist/components/StoryComponent/components/Header.js.map +1 -0
  154. package/dist/components/StoryComponent/components/Image.d.ts +5 -0
  155. package/dist/components/StoryComponent/components/Image.d.ts.map +1 -0
  156. package/dist/components/StoryComponent/components/Image.js +31 -0
  157. package/dist/components/StoryComponent/components/Image.js.map +1 -0
  158. package/dist/components/StoryComponent/components/Text.d.ts +7 -0
  159. package/dist/components/StoryComponent/components/Text.d.ts.map +1 -0
  160. package/dist/components/StoryComponent/components/Text.js +4 -0
  161. package/dist/components/StoryComponent/components/Text.js.map +1 -0
  162. package/dist/components/StoryComponent/components/Video.d.ts +7 -0
  163. package/dist/components/StoryComponent/components/Video.d.ts.map +1 -0
  164. package/dist/components/StoryComponent/components/Video.js +4 -0
  165. package/dist/components/StoryComponent/components/Video.js.map +1 -0
  166. package/dist/components/StoryComponent/components/index.d.ts +7 -0
  167. package/dist/components/StoryComponent/components/index.d.ts.map +1 -0
  168. package/dist/components/StoryComponent/components/index.js +7 -0
  169. package/dist/components/StoryComponent/components/index.js.map +1 -0
  170. package/dist/components/StoryComponent/index.d.ts +2 -0
  171. package/dist/components/StoryComponent/index.d.ts.map +1 -0
  172. package/dist/components/StoryComponent/index.js +2 -0
  173. package/dist/components/StoryComponent/index.js.map +1 -0
  174. package/dist/components/common/Button.d.ts +8 -0
  175. package/dist/components/common/Button.d.ts.map +1 -0
  176. package/dist/components/common/Button.js +64 -0
  177. package/dist/components/common/Button.js.map +1 -0
  178. package/dist/components/common/Spinner.d.ts +2 -0
  179. package/dist/components/common/Spinner.d.ts.map +1 -0
  180. package/dist/components/common/Spinner.js +3 -0
  181. package/dist/components/common/Spinner.js.map +1 -0
  182. package/dist/components/common/Tooltip.d.ts +12 -0
  183. package/dist/components/common/Tooltip.d.ts.map +1 -0
  184. package/dist/components/common/Tooltip.js +28 -0
  185. package/dist/components/common/Tooltip.js.map +1 -0
  186. package/dist/components/common/index.d.ts +4 -0
  187. package/dist/components/common/index.d.ts.map +1 -0
  188. package/dist/components/common/index.js +4 -0
  189. package/dist/components/common/index.js.map +1 -0
  190. package/dist/components/index.d.ts +6 -0
  191. package/dist/components/index.d.ts.map +1 -0
  192. package/dist/components/index.js +6 -0
  193. package/dist/components/index.js.map +1 -0
  194. package/dist/hooks/index.d.ts +3 -0
  195. package/dist/hooks/index.d.ts.map +1 -0
  196. package/dist/hooks/index.js +3 -0
  197. package/dist/hooks/index.js.map +1 -0
  198. package/dist/hooks/useLocalStorage.d.ts +2 -0
  199. package/dist/hooks/useLocalStorage.d.ts.map +1 -0
  200. package/dist/hooks/useLocalStorage.js +44 -0
  201. package/dist/hooks/useLocalStorage.js.map +1 -0
  202. package/dist/hooks/useSaveLoadMenu.d.ts +2 -0
  203. package/dist/hooks/useSaveLoadMenu.d.ts.map +1 -0
  204. package/dist/hooks/useSaveLoadMenu.js +11 -0
  205. package/dist/hooks/useSaveLoadMenu.js.map +1 -0
  206. package/dist/index.d.ts +3 -0
  207. package/dist/index.d.ts.map +1 -0
  208. package/dist/index.js +3 -0
  209. package/dist/index.js.map +1 -0
  210. package/dist/styles/index.css +1809 -0
  211. package/dist/tests/ErrorBoundary.test.d.ts +2 -0
  212. package/dist/tests/ErrorBoundary.test.d.ts.map +1 -0
  213. package/dist/tests/ErrorBoundary.test.js +317 -0
  214. package/dist/tests/ErrorBoundary.test.js.map +1 -0
  215. package/dist/tests/dexie.mock.d.ts +56 -0
  216. package/dist/tests/dexie.mock.d.ts.map +1 -0
  217. package/dist/tests/dexie.mock.js +113 -0
  218. package/dist/tests/dexie.mock.js.map +1 -0
  219. package/package.json +55 -0
@@ -0,0 +1,135 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { Game } from "@react-text-game/core";
4
+ import { Component } from "react";
5
+ import { Button } from "../../components/common";
6
+ /**
7
+ * ErrorBoundary catches all JavaScript errors in the application:
8
+ * - Rendering errors
9
+ * - Event handler errors
10
+ * - Async errors (promises, setTimeout)
11
+ * - Global uncaught errors
12
+ */
13
+ export class ErrorBoundary extends Component {
14
+ constructor(props) {
15
+ super(props);
16
+ this.state = {
17
+ hasError: false,
18
+ error: null,
19
+ errorInfo: null,
20
+ copied: false,
21
+ };
22
+ }
23
+ static getDerivedStateFromError(error) {
24
+ return { hasError: true, error };
25
+ }
26
+ componentDidMount() {
27
+ // Catch global errors (event handlers, setTimeout, etc.)
28
+ window.addEventListener("error", this.handleGlobalError);
29
+ // Catch unhandled promise rejections
30
+ window.addEventListener("unhandledrejection", this.handlePromiseRejection);
31
+ }
32
+ componentWillUnmount() {
33
+ window.removeEventListener("error", this.handleGlobalError);
34
+ window.removeEventListener("unhandledrejection", this.handlePromiseRejection);
35
+ }
36
+ handleGlobalError = (event) => {
37
+ event.preventDefault();
38
+ // Handle different error types
39
+ let error;
40
+ if (event.error instanceof Error) {
41
+ error = event.error;
42
+ }
43
+ else if (event.message) {
44
+ error = new Error(event.message);
45
+ }
46
+ else {
47
+ // Fallback for events without error or message (e.g., resource load errors)
48
+ const target = event.target;
49
+ const targetInfo = target
50
+ ? `${target.tagName}${target.id ? `#${target.id}` : ""}${target.className ? `.${target.className.split(" ").join(".")}` : ""}`
51
+ : "unknown element";
52
+ error = new Error(`Resource error or unhandled error on ${targetInfo}`);
53
+ }
54
+ const errorInfo = {
55
+ componentStack: `\nGlobal error at ${event.filename || "unknown"}:${event.lineno || 0}:${event.colno || 0}`,
56
+ };
57
+ console.error("Global error caught:", error, event);
58
+ this.setState({
59
+ hasError: true,
60
+ error,
61
+ errorInfo,
62
+ });
63
+ this.props.onError?.(error, errorInfo);
64
+ };
65
+ handlePromiseRejection = (event) => {
66
+ event.preventDefault();
67
+ const error = event.reason instanceof Error
68
+ ? event.reason
69
+ : new Error(String(event.reason));
70
+ const errorInfo = {
71
+ componentStack: "\nUnhandled Promise Rejection",
72
+ };
73
+ console.error("Unhandled promise rejection:", error);
74
+ this.setState({
75
+ hasError: true,
76
+ error,
77
+ errorInfo,
78
+ });
79
+ this.props.onError?.(error, errorInfo);
80
+ };
81
+ componentDidCatch(error, errorInfo) {
82
+ console.error("ErrorBoundary caught an error:", error, errorInfo);
83
+ this.setState({
84
+ error,
85
+ errorInfo,
86
+ });
87
+ // Call optional error handler
88
+ this.props.onError?.(error, errorInfo);
89
+ }
90
+ reset = () => {
91
+ this.setState({
92
+ hasError: false,
93
+ error: null,
94
+ errorInfo: null,
95
+ });
96
+ };
97
+ copyErrorToClipboard = async () => {
98
+ if (!this.state.error || !this.state.errorInfo)
99
+ return;
100
+ const errorText = [
101
+ `Error: ${this.state.error.message}`,
102
+ "",
103
+ "Stack Trace:",
104
+ this.state.error.stack || "No stack trace available",
105
+ "",
106
+ "Component Stack:",
107
+ this.state.errorInfo.componentStack ||
108
+ "No component stack available",
109
+ ].join("\n");
110
+ try {
111
+ await navigator.clipboard.writeText(errorText);
112
+ this.setState({ copied: true });
113
+ setTimeout(() => {
114
+ this.setState({ copied: false });
115
+ }, 1000);
116
+ }
117
+ catch (err) {
118
+ console.error("Failed to copy error to clipboard:", err);
119
+ }
120
+ };
121
+ render() {
122
+ const errorOverlay = this.state.hasError && this.state.error && this.state.errorInfo ? (
123
+ // Use custom fallback if provided
124
+ this.props.fallback ? (this.props.fallback(this.state.error, this.state.errorInfo, this.reset)) : (
125
+ // Default fallback UI as overlay
126
+ _jsx("div", { className: "fixed inset-0 z-[9999] flex items-center justify-center bg-background bg-opacity-50 p-8", children: _jsxs("div", { className: "max-w-2xl w-full bg-card border-2 border-danger-500 rounded-lg p-6 shadow-lg relative max-h-screen", children: [_jsx("button", { onClick: this.reset, className: "cursor-pointer absolute top-4 right-4 text-danger-600 hover:text-danger-800 font-bold text-2xl leading-none transition-colors", "aria-label": "Close error", children: "\u00D7" }), _jsx("h1", { className: "text-2xl font-bold text-danger-900 mb-4", children: "Game Error" }), _jsx("p", { className: "text-danger-800 mb-4", children: "Something went wrong while running the game. This error has been logged." }), _jsxs("details", { className: "mb-4 max-h-100 overflow-auto", children: [_jsxs("summary", { className: "cursor-pointer text-danger-900 font-semibold mb-2 flex items-center justify-between", children: [_jsxs("div", { className: "flex gap-4 items-center", children: [_jsx("span", { children: "Error Details" }), _jsx("span", { children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", className: "w-6 h-6", children: _jsx("path", { fill: "#000", fillRule: "evenodd", d: "M12.7 14.7a1 1 0 0 1-1.4 0l-5-5a1 1 0 0 1 1.4-1.4l4.3 4.29 4.3-4.3a1 1 0 1 1 1.4 1.42l-5 5Z", clipRule: "evenodd" }) }) })] }), _jsxs("div", { className: "flex items-center gap-2", children: [this.state.copied && (_jsx("span", { className: "text-sm text-danger-700", children: "Copied to clipboard" })), _jsx("button", { onClick: (e) => {
127
+ e.preventDefault();
128
+ void this.copyErrorToClipboard();
129
+ }, className: "cursor-pointer text-danger-600 hover:text-danger-800 transition-colors", title: "Copy error to clipboard", "aria-label": "Copy error to clipboard", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), _jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })] }) })] })] }), _jsxs("div", { className: "bg-danger-100 p-4 rounded border border-danger-300 overflow-auto", children: [_jsxs("p", { className: "font-mono text-sm text-danger-900 mb-2", children: [_jsx("strong", { children: "Error:" }), " ", this.state.error.message] }), _jsx("p", { className: "font-mono text-xs text-danger-800 whitespace-pre-wrap", children: this.state.error.stack }), Game.options.isDevMode &&
130
+ this.state.errorInfo.componentStack && (_jsxs("p", { className: "font-mono text-xs text-danger-800 whitespace-pre-wrap mt-4", children: [_jsx("strong", { children: "Component Stack:" }), this.state.errorInfo
131
+ .componentStack] }))] })] }), _jsx(Button, { color: "warning", onClick: this.reset, children: "Try Again" })] }) }))) : null;
132
+ return (_jsxs(_Fragment, { children: [this.props.children, errorOverlay] }));
133
+ }
134
+ }
135
+ //# sourceMappingURL=ErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../src/components/ErrorBoundary/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,SAGlC;IACG,YAAY,KAAyB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SAChB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAY;QACxC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACrC,CAAC;IAED,iBAAiB;QACb,yDAAyD;QACzD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEzD,qCAAqC;QACrC,MAAM,CAAC,gBAAgB,CACnB,oBAAoB,EACpB,IAAI,CAAC,sBAAsB,CAC9B,CAAC;IACN,CAAC;IAED,oBAAoB;QAChB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC5D,MAAM,CAAC,mB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I,EACX,EAAE,EAAC,GAAG,EACN,EAAE,EAAC,GAAG,GACR,EACF,eAAM,CAAC,EAAC,yDAAyD,GAAG,IAClE,GACD,IACP,IACA,EACV,eAAK,SAAS,EAAC,kEAAkE,aAC7E,aAAG,SAAS,EAAC,wCAAwC,aACjD,sCAAuB,EAAC,GAAG,EAC1B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,IACzB,EACJ,YAAG,SAAS,EAAC,uDAAuD,YAC/D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GACvB,EACH,IAAI,CAAC,OAAO,CAAC,SAAS;wCACnB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,IAAI,CACnC,aAAG,SAAS,EAAC,4DAA4D,aACrE,gDAES,EAEL,IAAI,CAAC,KAAK,CAAC,SAAS;iDACf,cAAc,IAEvB,CACP,IACH,IACA,EACV,KAAC,MAAM,IACH,KAAK,EAAC,SAAS,EACf,OAAO,EAAE,IAAI,CAAC,KAAK,0BAGd,IACP,GACJ,CACT,CACJ,CAAC,CAAC,CAAC,IAAI,CAAC;QAEb,OAAO,CACH,8BACK,IAAI,CAAC,KAAK,CAAC,QAAQ,EACnB,YAAY,IACd,CACN,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export * from './ErrorBoundary';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBoundary/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './ErrorBoundary';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ErrorBoundary/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { ErrorInfo, PropsWithChildren, ReactNode } from "react";
2
+ export interface ErrorBoundaryState {
3
+ hasError: boolean;
4
+ error: Error | null;
5
+ errorInfo: ErrorInfo | null;
6
+ copied: boolean;
7
+ }
8
+ export interface ErrorBoundaryProps extends PropsWithChildren {
9
+ fallback?: (error: Error, errorInfo: ErrorInfo, reset: () => void) => ReactNode;
10
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
11
+ }
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBoundary/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhE,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,EAAE,CACP,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,IAAI,KAChB,SAAS,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CAC1D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/ErrorBoundary/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { NewOptions } from "@react-text-game/core";
2
+ type AppIconMenuProps = Readonly<{
3
+ options: NewOptions;
4
+ setOptions: (values: NewOptions) => void;
5
+ }>;
6
+ export declare const AppIconMenu: ({ options, setOptions }: AppIconMenuProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=AppIconMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppIconMenu.d.ts","sourceRoot":"","sources":["../../../src/components/GameProvider/AppIconMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,KAAK,gBAAgB,GAAG,QAAQ,CAAC;IAC7B,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CAC5C,CAAC,CAAC;AAEH,eAAO,MAAM,WAAW,GAAI,yBAAyB,gBAAgB,4CAgDpE,CAAC"}
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ export const AppIconMenu = ({ options, setOptions }) => {
5
+ const [isHovered, setIsHovered] = useState(false);
6
+ const { isDevMode } = options;
7
+ return (_jsxs("div", { className: "fixed bottom-3 left-2 z-10000000", children: [_jsx("button", { className: "cursor-pointer hover:opacity-50 active:scale-95 bg-primary-500 p-2 rounded-full", onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 20 20", className: "w-6 h-6", children: _jsx("path", { fill: "#000", fillRule: "evenodd", d: "M2.7 13.07 8.1 5.1a.5.5 0 0 1 .9.3v11.04a.5.5 0 0 1-.75.44l-5.4-3.07a.5.5 0 0 1-.15-.73Zm14.45.73-5.4 3.07a.5.5 0 0 1-.75-.44V5.38a.5.5 0 0 1 .9-.3l5.4 8a.5.5 0 0 1-.15.72ZM11 .53c-.48-.7-1.52-.7-2 0L.24 13.03c-.43.58-.26 1.4.36 1.77L9 19.63l.42.22c.36.2.8.2 1.16 0l.42-.22 8.4-4.83c.62-.36.8-1.19.36-1.77L11 .53Z" }) }) }), isHovered && (_jsx("div", { className: "absolute left-full bottom-0 bg-popover border border-border rounded-lg shadow-lg p-3 whitespace-nowrap", onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), children: _jsxs("label", { className: "flex items-center gap-2 cursor-pointer text-popover-foreground", children: [_jsx("input", { type: "checkbox", className: "cursor-pointer", checked: !!isDevMode, onChange: () => setOptions({
8
+ ...options,
9
+ isDevMode: !isDevMode,
10
+ }) }), _jsx("span", { children: "Is dev mode" })] }) }))] }));
11
+ };
12
+ //# sourceMappingURL=AppIconMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppIconMenu.js","sourceRoot":"","sources":["../../../src/components/GameProvider/AppIconMenu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAOjC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAoB,EAAE,EAAE;IACrE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE9B,OAAO,CACH,eAAK,SAAS,EAAC,kCAAkC,aAC7C,iBACI,SAAS,EAAC,iFAAiF,EAC3F,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACtC,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,YAEvC,cACI,KAAK,EAAC,4BAA4B,EAClC,IAAI,EAAC,cAAc,EACnB,OAAO,EAAC,WAAW,EACnB,SAAS,EAAC,SAAS,YAEnB,eACI,IAAI,EAAC,MAAM,EACX,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,2TAA2T,GAC/T,GACA,GACD,EACR,SAAS,IAAI,CACV,cACI,SAAS,EAAC,wGAAwG,EAClH,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACtC,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,YAEvC,iBAAO,SAAS,EAAC,gEAAgE,aAC7E,gBACI,IAAI,EAAC,UAAU,EACf,SAAS,EAAC,gBAAgB,EAC1B,OAAO,EAAE,CAAC,CAAC,SAAS,EACpB,QAAQ,EAAE,GAAG,EAAE,CACX,UAAU,CAAC;gCACP,GAAG,OAAO;gCACV,SAAS,EAAE,CAAC,SAAS;6BACxB,CAAC,GAER,EACF,yCAAwB,IACpB,GACN,CACT,IACC,CACT,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { NewOptions } from "@react-text-game/core";
2
+ import { PropsWithChildren, ReactNode } from "react";
3
+ type Components = Readonly<{
4
+ MainMenu?: (() => ReactNode) | undefined;
5
+ }>;
6
+ type GameProviderProps = PropsWithChildren<{
7
+ options: NewOptions;
8
+ components?: Components;
9
+ }>;
10
+ export declare const GameProvider: ({ children, options, components }: GameProviderProps) => import("react/jsx-runtime").JSX.Element | null;
11
+ export {};
12
+ //# sourceMappingURL=GameProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameProvider.d.ts","sourceRoot":"","sources":["../../../src/components/GameProvider/GameProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEH,UAAU,EAGb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAW1E,KAAK,UAAU,GAAG,QAAQ,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,MAAM,SAAS,CAAC,GAAG,SAAS,CAAC;CAC5C,CAAC,CAAC;AAEH,KAAK,iBAAiB,GAAG,iBAAiB,CAAC;IACvC,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;CAC3B,CAAC,CAAC;AAOH,eAAO,MAAM,YAAY,GAAI,mCAAmC,iBAAiB,mDAuChF,CAAC"}
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Game, newWidget, SYSTEM_PASSAGE_NAMES, } from "@react-text-game/core";
4
+ import { useEffect, useState } from "react";
5
+ import { ErrorBoundary } from "../../components/ErrorBoundary";
6
+ import { MainMenu } from "../../components/MainMenu";
7
+ import { SaveLoadModal } from "../../components/SaveLoadModal";
8
+ import { useSaveLoadMenu } from "../../hooks";
9
+ import { DevModeDrawer } from "../DevModeDrawer";
10
+ import { AppIconMenu } from "./AppIconMenu";
11
+ import { SaveLoadMenuProvider } from "./SaveLoadMenuProvider";
12
+ const SaveLoadModalWrapper = () => {
13
+ const { isOpen, mode, close } = useSaveLoadMenu();
14
+ return _jsx(SaveLoadModal, { isOpen: isOpen, onClose: close, mode: mode });
15
+ };
16
+ export const GameProvider = ({ children, options, components }) => {
17
+ const [internalOptions, setInternalOptions] = useState(options);
18
+ const [isInitialized, setIsInitialized] = useState(false);
19
+ useEffect(() => {
20
+ Game.init(options).then(() => {
21
+ newWidget(SYSTEM_PASSAGE_NAMES.START_MENU, components?.MainMenu?.() || _jsx(MainMenu, {}));
22
+ Game.setCurrent(SYSTEM_PASSAGE_NAMES.START_MENU);
23
+ setIsInitialized(true);
24
+ });
25
+ }, [options]);
26
+ useEffect(() => {
27
+ if (internalOptions && isInitialized && internalOptions !== options) {
28
+ Game.updateOptions(internalOptions);
29
+ }
30
+ }, [internalOptions, isInitialized, options]);
31
+ if (!isInitialized) {
32
+ return null;
33
+ }
34
+ return (_jsx(SaveLoadMenuProvider, { children: _jsxs(ErrorBoundary, { children: [children, options.isDevMode && (_jsxs(_Fragment, { children: [_jsx(AppIconMenu, { options: internalOptions, setOptions: setInternalOptions }), _jsx(DevModeDrawer, { options: internalOptions })] })), _jsx(SaveLoadModalWrapper, {})] }) }));
35
+ };
36
+ //# sourceMappingURL=GameProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameProvider.js","sourceRoot":"","sources":["../../../src/components/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,EAAE,IAAI,KAAC,QAAQ,KAAG,CAAC,CAAC;YACrF,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;YACjD,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,eAAe,IAAI,aAAa,IAAI,eAAe,KAAK,OAAO,EAAE,CAAC;YAClE,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACxC,CAAC;IACL,CAAC,EAAE,CAAC,eAAe,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAE9C,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CACH,KAAC,oBAAoB,cACjB,MAAC,aAAa,eACT,QAAQ,EACR,OAAO,CAAC,SAAS,IAAI,CAClB,8BACI,KAAC,WAAW,IACR,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,kBAAkB,GAChC,EACF,KAAC,aAAa,IAAC,OAAO,EAAE,eAAe,GAAI,IAC5C,CACN,EACD,KAAC,oBAAoB,KAAG,IACZ,GACG,CAC1B,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { SaveLoadMode } from "../../components/GameProvider/SaveLoadMenuProvider";
2
+ export interface SaveLoadMenuContextType {
3
+ isOpen: boolean;
4
+ mode: SaveLoadMode;
5
+ openSaveMenu: () => void;
6
+ openLoadMenu: () => void;
7
+ openSaveLoadMenu: () => void;
8
+ close: () => void;
9
+ }
10
+ export declare const SaveLoadMenuContext: import("react").Context<SaveLoadMenuContextType | undefined>;
11
+ //# sourceMappingURL=SaveLoadMenuContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SaveLoadMenuContext.d.ts","sourceRoot":"","sources":["../../../src/components/GameProvider/SaveLoadMenuContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,8DAEpB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { createContext } from "react";
2
+ export const SaveLoadMenuContext = createContext(undefined);
3
+ //# sourceMappingURL=SaveLoadMenuContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SaveLoadMenuContext.js","sourceRoot":"","sources":["../../../src/components/GameProvider/SaveLoadMenuContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAatC,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAE9C,SAAS,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { PropsWithChildren } from "react";
2
+ export type SaveLoadMode = "save" | "load" | "saveLoad";
3
+ export declare const SaveLoadMenuProvider: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=SaveLoadMenuProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SaveLoadMenuProvider.d.ts","sourceRoot":"","sources":["../../../src/components/GameProvider/SaveLoadMenuProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAIpD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAExD,eAAO,MAAM,oBAAoB,GAAI,cAAc,iBAAiB,4CAqCnE,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { SaveLoadMenuContext } from "./SaveLoadMenuContext";
5
+ export const SaveLoadMenuProvider = ({ children }) => {
6
+ const [isOpen, setIsOpen] = useState(false);
7
+ const [mode, setMode] = useState("saveLoad");
8
+ const openSaveMenu = () => {
9
+ setMode("save");
10
+ setIsOpen(true);
11
+ };
12
+ const openLoadMenu = () => {
13
+ setMode("load");
14
+ setIsOpen(true);
15
+ };
16
+ const openSaveLoadMenu = () => {
17
+ setMode("saveLoad");
18
+ setIsOpen(true);
19
+ };
20
+ const close = () => {
21
+ setIsOpen(false);
22
+ };
23
+ return (_jsx(SaveLoadMenuContext.Provider, { value: {
24
+ isOpen,
25
+ mode,
26
+ openSaveMenu,
27
+ openLoadMenu,
28
+ openSaveLoadMenu,
29
+ close,
30
+ }, children: children }));
31
+ };
32
+ //# sourceMappingURL=SaveLoadMenuProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SaveLoadMenuProvider.js","sourceRoot":"","sources":["../../../src/components/GameProvider/SaveLoadMenuProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAI5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,QAAQ,EAAqB,EAAE,EAAE;IACpE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAe,UAAU,CAAC,CAAC;IAE3D,MAAM,YAAY,GAAG,GAAG,EAAE;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;QAChB,SAAS,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;QAChB,SAAS,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,gBAAgB,GAAG,GAAG,EAAE;QAC1B,OAAO,CAAC,UAAU,CAAC,CAAC;QACpB,SAAS,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,GAAG,EAAE;QACf,SAAS,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,CACH,KAAC,mBAAmB,CAAC,QAAQ,IACzB,KAAK,EAAE;YACH,MAAM;YACN,IAAI;YACJ,YAAY;YACZ,YAAY;YACZ,gBAAgB;YAChB,KAAK;SACR,YAEA,QAAQ,GACkB,CAClC,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./GameProvider";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/GameProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./GameProvider";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/GameProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { MapImageHotspot, MapLabelHotspot } from "@react-text-game/core/passages";
2
+ import { ImagePositionInfo } from "./types";
3
+ type HotspotProps = {
4
+ hotspot: MapImageHotspot | MapLabelHotspot;
5
+ imagePositionInfo?: ImagePositionInfo;
6
+ };
7
+ export declare const Hotspot: ({ hotspot, imagePositionInfo }: HotspotProps) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=Hotspot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hotspot.d.ts","sourceRoot":"","sources":["../../../src/components/InteractiveMapComponent/Hotspot.tsx"],"names":[],"mappings":"AAEA,OAAO,EACH,eAAe,EACf,eAAe,EAClB,MAAM,gCAAgC,CAAC;AAQxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,YAAY,GAAG;IAChB,OAAO,EAAE,eAAe,GAAG,eAAe,CAAC;IAC3C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,gCAAgC,YAAY,4CA+CnE,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
4
+ import { Tooltip } from "../../components/common/Tooltip";
5
+ import { callIfFunction } from "./helpers";
6
+ import { ImageHotspot } from "./ImageHotspot";
7
+ import { LabelHotspot } from "./LabelHotspot";
8
+ export const Hotspot = ({ hotspot, imagePositionInfo }) => {
9
+ const hotspotRef = useRef(null);
10
+ const tooltipContent = callIfFunction(hotspot.tooltip?.content);
11
+ // Position the hotspot based on percentage coordinates and image position info
12
+ useEffect(() => {
13
+ if (hotspotRef.current && imagePositionInfo) {
14
+ const { x, y } = hotspot.position;
15
+ const { offsetLeft, offsetTop, scaledWidth, scaledHeight } = imagePositionInfo;
16
+ // Calculate position based on percentage of the scaled image
17
+ // x and y are percentages (0-100), so we convert to 0-1 by dividing by 100
18
+ const xPos = offsetLeft +
19
+ ((typeof x === "number" ? x : x()) / 100) * scaledWidth;
20
+ const yPos = offsetTop +
21
+ ((typeof y === "number" ? y : y()) / 100) * scaledHeight;
22
+ hotspotRef.current.style.left = `${xPos}px`;
23
+ hotspotRef.current.style.top = `${yPos}px`;
24
+ // Ensure transforms are applied
25
+ hotspotRef.current.style.transform = "translate(-50%, -50%)";
26
+ }
27
+ }, [hotspot.position, imagePositionInfo]);
28
+ return (_jsx("div", { ref: hotspotRef, className: "absolute z-10", children: _jsx(Tooltip, { content: tooltipContent, placement: hotspot.tooltip?.position || "top", disabled: !tooltipContent, children: _jsx("div", { children: hotspot.type === "image" ? (_jsx(ImageHotspot, { hotspot: hotspot })) : hotspot.type === "label" ? (_jsx(LabelHotspot, { hotspot: hotspot })) : (_jsx("div", { children: "Unknown Hotspot Type" })) }) }) }));
29
+ };
30
+ //# sourceMappingURL=Hotspot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hotspot.js","sourceRoot":"","sources":["../../../src/components/InteractiveMapComponent/Hotspot.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAMb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAgB,EAAE,EAAE;IACpE,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEhE,+EAA+E;IAC/E,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,UAAU,CAAC,OAAO,IAAI,iBAAiB,EAAE,CAAC;YAC1C,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;YAClC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,GACtD,iBAAiB,CAAC;YAEtB,6DAA6D;YAC7D,2EAA2E;YAC3E,MAAM,IAAI,GACN,UAAU;gBACV,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,WAAW,CAAC;YAC5D,MAAM,IAAI,GACN,SAAS;gBACT,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,YAAY,CAAC;YAE7D,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;YAC5C,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC;YAE3C,gCAAgC;YAChC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,uBAAuB,CAAC;QACjE,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE1C,OAAO,CACH,cAAK,GAAG,EAAE,UAAU,EAAE,SAAS,EAAC,eAAe,YAC3C,KAAC,OAAO,IACJ,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,IAAI,KAAK,EAC7C,QAAQ,EAAE,CAAC,cAAc,YAEzB,wBACK,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CACxB,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,GAAI,CACrC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAC3B,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,GAAI,CACrC,CAAC,CAAC,CAAC,CACA,iDAA+B,CAClC,GACC,GACA,GACR,CACT,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from "react";
2
+ type HotspotMapProps = {
3
+ imageUrl: string;
4
+ children?: ReactNode;
5
+ };
6
+ export declare const HotspotMap: ({ imageUrl, children }: HotspotMapProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=HotspotMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotspotMap.d.ts","sourceRoot":"","sources":["../../../src/components/InteractiveMapComponent/HotspotMap.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAA4B,MAAM,OAAO,CAAC;AAO5D,KAAK,eAAe,GAAG;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,wBAAwB,eAAe,4CA6DjE,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { Spinner } from "../../components/common/Spinner";
5
+ import { handleMapClick, renderChildren } from "./helpers";
6
+ import { useHotspotMapSize } from "./useHotspotMapSize";
7
+ export const HotspotMap = ({ imageUrl, children }) => {
8
+ const [isLoading, setIsLoading] = useState(true);
9
+ const [naturalDimensions, setNaturalDimensions] = useState({
10
+ width: 0,
11
+ height: 0,
12
+ });
13
+ const { containerRef, imageRef, positionInfo } = useHotspotMapSize({
14
+ isLoading,
15
+ naturalWidth: naturalDimensions.width,
16
+ naturalHeight: naturalDimensions.height,
17
+ });
18
+ const handleImageLoad = () => {
19
+ if (imageRef.current) {
20
+ setNaturalDimensions({
21
+ width: imageRef.current.naturalWidth,
22
+ height: imageRef.current.naturalHeight,
23
+ });
24
+ setIsLoading(false);
25
+ }
26
+ };
27
+ const handleImageError = (error) => {
28
+ console.error("Failed to load image:", error);
29
+ setIsLoading(false);
30
+ throw error;
31
+ };
32
+ return (_jsxs("div", { ref: containerRef, className: "relative w-full h-full overflow-hidden", children: [isLoading && (_jsx("div", { className: "absolute inset-0 flex items-center justify-center z-10", children: _jsx(Spinner, {}) })), _jsx("div", { className: "relative w-full h-full overflow-hidden", children: _jsx("img", { ref: imageRef, src: imageUrl, className: "absolute", style: {
33
+ opacity: isLoading ? 0 : 1,
34
+ transition: "opacity 0.3s ease",
35
+ }, onLoad: handleImageLoad, onError: handleImageError, alt: "Exploration map", onClick: (e) => handleMapClick(e, imageRef) }) }), !isLoading && (_jsx("div", { children: renderChildren({ positionInfo, children }) }))] }));
36
+ };
37
+ //# sourceMappingURL=HotspotMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotspotMap.js","sourceRoot":"","sources":["../../../src/components/InteractiveMapComponent/HotspotMap.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAA6B,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAmB,EAAE,EAAE;IAClE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAC;QACvD,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACZ,CAAC,CAAC;IAEH,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC;QAC/D,SAAS;QACT,YAAY,EAAE,iBAAiB,CAAC,KAAK;QACrC,aAAa,EAAE,iBAAiB,CAAC,MAAM;KAC1C,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,GAAG,EAAE;QACzB,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,oBAAoB,CAAC;gBACjB,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY;gBACpC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa;aACzC,CAAC,CAAC;YACH,YAAY,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,gBAAgB,GAAG,CACrB,KAA8C,EAChD,EAAE;QACA,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QAC9C,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,KAAK,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO,CACH,eACI,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,wCAAwC,aAEjD,SAAS,IAAI,CACV,cAAK,SAAS,EAAC,wDAAwD,YACnE,KAAC,OAAO,KAAG,GACT,CACT,EACD,cAAK,SAAS,EAAC,wCAAwC,YACnD,cACI,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,QAAQ,EACb,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE;wBACH,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC1B,UAAU,EAAE,mBAAmB;qBAClC,EACD,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,gBAAgB,EACzB,GAAG,EAAC,iBAAiB,EACrB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,QAAQ,CAAC,GAC7C,GACA,EACL,CAAC,SAAS,IAAI,CACX,wBAAM,cAAc,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,GAAO,CAC1D,IACC,CACT,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { MapMenu } from "@react-text-game/core/passages";
2
+ import { ImagePositionInfo } from "./types";
3
+ type Props = Readonly<{
4
+ menu: MapMenu;
5
+ imagePositionInfo?: ImagePositionInfo;
6
+ }>;
7
+ export declare const HotspotMenu: ({ menu, imagePositionInfo }: Props) => import("react/jsx-runtime").JSX.Element | null;
8
+ export {};
9
+ //# sourceMappingURL=HotspotMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotspotMenu.d.ts","sourceRoot":"","sources":["../../../src/components/InteractiveMapComponent/HotspotMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAOzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,KAAK,GAAG,QAAQ,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC,CAAC,CAAC;AAEH,eAAO,MAAM,WAAW,GAAI,6BAA6B,KAAK,mDAuE7D,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useRef } from "react";
4
+ import { twMerge } from "tailwind-merge";
5
+ import { Button, Tooltip } from "../../components/common";
6
+ import { callIfFunction } from "./helpers";
7
+ export const HotspotMenu = ({ menu, imagePositionInfo }) => {
8
+ const menuRef = useRef(null);
9
+ const items = useMemo(() => menu.items
10
+ .map((item) => callIfFunction(item))
11
+ .filter((item) => item !== undefined), [menu.items]);
12
+ // Position the menu based on percentage coordinates and image position info
13
+ useEffect(() => {
14
+ if (menuRef.current && imagePositionInfo && items.length) {
15
+ const { x, y } = menu.position;
16
+ const { offsetLeft, offsetTop, scaledWidth, scaledHeight } = imagePositionInfo;
17
+ // Calculate position based on percentage of the scaled image
18
+ const xPos = offsetLeft +
19
+ ((typeof x === "number" ? x : x()) / 100) * scaledWidth;
20
+ const yPos = offsetTop +
21
+ ((typeof y === "number" ? y : y()) / 100) * scaledHeight;
22
+ menuRef.current.style.left = `${xPos}px`;
23
+ menuRef.current.style.top = `${yPos}px`;
24
+ menuRef.current.style.transform = "translate(-50%, -50%)";
25
+ }
26
+ }, [menu.position, imagePositionInfo, items.length]);
27
+ if (items.length === 0) {
28
+ return null; // Don't render the menu if there are no items
29
+ }
30
+ return (_jsx("div", { ref: menuRef, className: twMerge("absolute z-10 flex gap-2 p-2 bg-popover/95 border border-border rounded-lg shadow-md", menu.direction === "horizontal" ? "flex-row" : "flex-col"), children: items.map((item, index) => {
31
+ const tooltipContent = callIfFunction(item.tooltip?.content);
32
+ const isDisabled = callIfFunction(item.isDisabled) || false;
33
+ const content = callIfFunction(item.content);
34
+ return (_jsx(Tooltip, { content: tooltipContent, placement: item.tooltip?.position || "top", disabled: !tooltipContent, children: _jsx("div", { children: _jsx(Button, { className: item?.props?.classNames?.button, variant: item?.props?.variant, color: item?.props?.color, disabled: isDisabled, onClick: item.action, children: content }) }) }, index));
35
+ }) }));
36
+ };
37
+ //# sourceMappingURL=HotspotMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotspotMenu.js","sourceRoot":"","sources":["../../../src/components/InteractiveMapComponent/HotspotMenu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAQ3C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAS,EAAE,EAAE;IAC9D,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,OAAO,CACjB,GAAG,EAAE,CACD,IAAI,CAAC,KAAK;SACL,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;SACnC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,EAC7C,CAAC,IAAI,CAAC,KAAK,CAAC,CACf,CAAC;IAEF,4EAA4E;I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C5D,YAEA,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACvB,MAAM,cAAc,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7D,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;YAC5D,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAE7C,OAAO,CACH,KAAC,OAAO,IAEJ,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,IAAI,KAAK,EAC1C,QAAQ,EAAE,CAAC,cAAc,YAEzB,wBACI,KAAC,MAAM,IACH,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAC1C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAC7B,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EACzB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,IAAI,CAAC,MAAM,YAEnB,OAAO,GACH,GACP,IAfD,KAAK,CAgBJ,CACb,CAAC;QACN,CAAC,CAAC,GACA,CACT,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ImageHotspot as ImageHotspotType, MapImageHotspot } from "@react-text-game/core/passages";
2
+ type ImageHotspotProps = {
3
+ hotspot: MapImageHotspot | ImageHotspotType;
4
+ };
5
+ export declare const ImageHotspot: ({ hotspot }: ImageHotspotProps) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=ImageHotspot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageHotspot.d.ts","sourceRoot":"","sources":["../../../src/components/InteractiveMapComponent/ImageHotspot.tsx"],"names":[],"mappings":"AAEA,OAAO,EACH,YAAY,IAAI,gBAAgB,EAChC,eAAe,EAClB,MAAM,gCAAgC,CAAC;AAMxC,KAAK,iBAAiB,GAAG;IACrB,OAAO,EAAE,eAAe,GAAG,gBAAgB,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,aAAa,iBAAiB,4CA4D1D,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useMemo, useState } from "react";
4
+ import { twMerge } from "tailwind-merge";
5
+ import { callIfFunction } from "./helpers";
6
+ export const ImageHotspot = ({ hotspot }) => {
7
+ const [isHovering, setIsHovering] = useState(false);
8
+ const [isActive, setIsActive] = useState(false);
9
+ const classNames = hotspot.props?.classNames || {};
10
+ const isDisabled = callIfFunction(hotspot.isDisabled);
11
+ const content = useMemo(() => ({
12
+ idle: callIfFunction(hotspot.content.idle),
13
+ hover: callIfFunction(hotspot.content.hover),
14
+ active: callIfFunction(hotspot.content.active),
15
+ disabled: callIfFunction(hotspot.content.disabled),
16
+ }), [hotspot.content]);
17
+ return (_jsx("button", { className: twMerge("cursor-pointer disabled:cursor-not-allowed relative", classNames.container), style: { zoom: hotspot.props?.zoom || "100%" }, disabled: isDisabled, onMouseEnter: () => setIsHovering(true), onMouseLeave: () => setIsHovering(false), onClick: () => {
18
+ setIsActive(true);
19
+ hotspot.action();
20
+ setTimeout(() => setIsActive(false), 100);
21
+ }, children: isActive && content.active ? (_jsx("img", { className: classNames.active, src: content.active, alt: "hotspot active" })) : isHovering && content.hover ? (_jsx("img", { className: classNames.hover, src: content.hover, alt: "hotspot hover" })) : isDisabled && content.disabled ? (_jsx("img", { className: classNames.disabled, src: content.disabled, alt: "hotspot disabled" })) : (_jsx("img", { className: classNames.idle, src: content.idle, alt: hotspot.id || "hotspot" })) }));
22
+ };
23
+ //# sourceMappingURL=ImageHotspot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageHotspot.js","sourceRoot":"","sources":["../../../src/components/InteractiveMapComponent/ImageHotspot.tsx"],"names":[],"mappings":"AAAA,YAAY,C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AC,KAAK,CAAC,EACxC,OAAO,EAAE,GAAG,EAAE;YACV,WAAW,CAAC,IAAI,CAAC,CAAC;YAClB,OAAO,CAAC,MAAM,EAAE,CAAC;YACjB,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC,YAEA,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAC1B,cACI,SAAS,EAAE,UAAU,CAAC,MAAM,EAC5B,GAAG,EAAE,OAAO,CAAC,MAAM,EACnB,GAAG,EAAC,gBAAgB,GACtB,CACL,CAAC,CAAC,CAAC,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAC9B,cACI,SAAS,EAAE,UAAU,CAAC,KAAK,EAC3B,GAAG,EAAE,OAAO,CAAC,KAAK,EAClB,GAAG,EAAC,eAAe,GACrB,CACL,CAAC,CAAC,CAAC,UAAU,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CACjC,cACI,SAAS,EAAE,UAAU,CAAC,QAAQ,EAC9B,GAAG,EAAE,OAAO,CAAC,QAAQ,EACrB,GAAG,EAAC,kBAAkB,GACxB,CACL,CAAC,CAAC,CAAC,CACA,cACI,SAAS,EAAE,UAAU,CAAC,IAAI,EAC1B,GAAG,EAAE,OAAO,CAAC,IAAI,EACjB,GAAG,EAAE,OAAO,CAAC,EAAE,IAAI,SAAS,GAC9B,CACL,GACI,CACZ,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { InteractiveMap } from "@react-text-game/core";
2
+ type InteractiveMapProps = {
3
+ interactiveMap: InteractiveMap;
4
+ };
5
+ export declare const InteractiveMapComponent: ({ interactiveMap, }: InteractiveMapProps) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=InteractiveMapComponent.d.ts.map