@vllnt/ui 0.2.0 → 0.2.1-canary.06f0e84

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 (202) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/README.md +27 -12
  3. package/dist/components/activity-log/activity-log.js +1 -0
  4. package/dist/components/agent-activity/agent-activity.js +311 -0
  5. package/dist/components/agent-activity/index.js +18 -0
  6. package/dist/components/ai-artifact/ai-artifact.js +422 -0
  7. package/dist/components/ai-artifact/index.js +24 -0
  8. package/dist/components/ai-sidebar/ai-sidebar.js +254 -0
  9. package/dist/components/ai-sidebar/index.js +22 -0
  10. package/dist/components/alert-pulse/alert-pulse.js +93 -0
  11. package/dist/components/alert-pulse/index.js +6 -0
  12. package/dist/components/anchor-port/anchor-port.js +51 -0
  13. package/dist/components/anchor-port/index.js +4 -0
  14. package/dist/components/animated-text/animated-text.js +1 -0
  15. package/dist/components/auto-reload/auto-reload.js +367 -0
  16. package/dist/components/auto-reload/index.js +6 -0
  17. package/dist/components/banner/banner.js +155 -0
  18. package/dist/components/banner/index.js +10 -0
  19. package/dist/components/bottom-activity-strip/bottom-activity-strip.js +91 -0
  20. package/dist/components/bottom-activity-strip/index.js +6 -0
  21. package/dist/components/bottom-bar/bottom-bar.js +25 -0
  22. package/dist/components/bottom-bar/index.js +4 -0
  23. package/dist/components/canvas-shell/canvas-foundation-demo.js +183 -0
  24. package/dist/components/canvas-shell/canvas-shell-route-config.js +0 -0
  25. package/dist/components/canvas-shell/canvas-shell.js +261 -0
  26. package/dist/components/canvas-shell/index.js +4 -0
  27. package/dist/components/canvas-view/canvas-view.js +461 -0
  28. package/dist/components/canvas-view/index.js +6 -0
  29. package/dist/components/chart/area-chart.js +1 -0
  30. package/dist/components/chart/line-chart.js +1 -0
  31. package/dist/components/chat-dock-section/chat-dock-section.js +56 -0
  32. package/dist/components/chat-dock-section/index.js +6 -0
  33. package/dist/components/checklist/checklist.js +7 -0
  34. package/dist/components/checklist/index.js +3 -1
  35. package/dist/components/choropleth-map/choropleth-map.js +373 -0
  36. package/dist/components/choropleth-map/index.js +10 -0
  37. package/dist/components/chronological-timeline/chronological-timeline.js +337 -0
  38. package/dist/components/chronological-timeline/index.js +8 -0
  39. package/dist/components/civilization-card/civilization-card.js +258 -0
  40. package/dist/components/civilization-card/index.js +8 -0
  41. package/dist/components/combobox/combobox.js +44 -20
  42. package/dist/components/comment-pin/comment-pin.js +104 -0
  43. package/dist/components/comment-pin/index.js +6 -0
  44. package/dist/components/connector-edge/connector-edge.js +66 -0
  45. package/dist/components/connector-edge/index.js +6 -0
  46. package/dist/components/context-lens/context-lens.js +98 -0
  47. package/dist/components/context-lens/index.js +6 -0
  48. package/dist/components/conversation-thread/conversation-thread.js +348 -0
  49. package/dist/components/conversation-thread/index.js +20 -0
  50. package/dist/components/copy-button/copy-button.js +189 -0
  51. package/dist/components/copy-button/index.js +8 -0
  52. package/dist/components/curriculum/curriculum.js +349 -0
  53. package/dist/components/curriculum/index.js +10 -0
  54. package/dist/components/data-list/data-list.js +1 -0
  55. package/dist/components/document-sibling-nav/document-sibling-nav.js +111 -0
  56. package/dist/components/document-sibling-nav/index.js +8 -0
  57. package/dist/components/edge-label/edge-label.js +26 -0
  58. package/dist/components/edge-label/index.js +4 -0
  59. package/dist/components/empty-state/empty-state.js +93 -0
  60. package/dist/components/empty-state/index.js +8 -0
  61. package/dist/components/era-comparison/era-comparison.js +198 -0
  62. package/dist/components/era-comparison/index.js +16 -0
  63. package/dist/components/floating-toolbar/floating-toolbar.js +66 -0
  64. package/dist/components/floating-toolbar/index.js +6 -0
  65. package/dist/components/follow-mode/follow-mode.js +89 -0
  66. package/dist/components/follow-mode/index.js +6 -0
  67. package/dist/components/form/form.js +432 -0
  68. package/dist/components/form/index.js +20 -0
  69. package/dist/components/gantt-chart/gantt-chart.js +331 -0
  70. package/dist/components/gantt-chart/index.js +6 -0
  71. package/dist/components/geography-quiz-map/geography-quiz-map.js +343 -0
  72. package/dist/components/geography-quiz-map/index.js +12 -0
  73. package/dist/components/glass-panel/glass-panel.js +21 -0
  74. package/dist/components/glass-panel/index.js +4 -0
  75. package/dist/components/globe-3d/globe-3d.js +417 -0
  76. package/dist/components/globe-3d/index.js +10 -0
  77. package/dist/components/group-hull/group-hull.js +29 -0
  78. package/dist/components/group-hull/index.js +4 -0
  79. package/dist/components/handoff-beacon/handoff-beacon.js +78 -0
  80. package/dist/components/handoff-beacon/index.js +6 -0
  81. package/dist/components/heat-map-overlay/heat-map-overlay.js +215 -0
  82. package/dist/components/heat-map-overlay/index.js +6 -0
  83. package/dist/components/heat-overlay/heat-overlay.js +92 -0
  84. package/dist/components/heat-overlay/index.js +6 -0
  85. package/dist/components/historic-timeline/historic-timeline.js +342 -0
  86. package/dist/components/historic-timeline/index.js +6 -0
  87. package/dist/components/historical-figure-card/historical-figure-card.js +273 -0
  88. package/dist/components/historical-figure-card/index.js +6 -0
  89. package/dist/components/index.js +568 -1
  90. package/dist/components/infinite-plane/index.js +6 -0
  91. package/dist/components/infinite-plane/infinite-plane.js +75 -0
  92. package/dist/components/interactive-timeline/index.js +16 -0
  93. package/dist/components/interactive-timeline/interactive-timeline.js +708 -0
  94. package/dist/components/jarvis-dock/index.js +6 -0
  95. package/dist/components/jarvis-dock/jarvis-dock.js +98 -0
  96. package/dist/components/kbd/index.js +5 -0
  97. package/dist/components/kbd/kbd.js +117 -0
  98. package/dist/components/knowledge-check/index.js +6 -0
  99. package/dist/components/knowledge-check/knowledge-check.js +448 -0
  100. package/dist/components/left-rail/index.js +4 -0
  101. package/dist/components/left-rail/left-rail.js +25 -0
  102. package/dist/components/live-cursor/index.js +6 -0
  103. package/dist/components/live-cursor/live-cursor.js +62 -0
  104. package/dist/components/map-2d/index.js +20 -0
  105. package/dist/components/map-2d/map-2d.js +455 -0
  106. package/dist/components/map-timeline/index.js +16 -0
  107. package/dist/components/map-timeline/map-timeline.js +506 -0
  108. package/dist/components/metric-cluster/index.js +6 -0
  109. package/dist/components/metric-cluster/metric-cluster.js +96 -0
  110. package/dist/components/mini-map-panel/index.js +6 -0
  111. package/dist/components/mini-map-panel/mini-map-panel.js +74 -0
  112. package/dist/components/model-comparison/index.js +12 -0
  113. package/dist/components/model-comparison/model-comparison.js +211 -0
  114. package/dist/components/multi-select/index.js +6 -0
  115. package/dist/components/multi-select/multi-select.js +258 -0
  116. package/dist/components/multi-select-lasso/index.js +6 -0
  117. package/dist/components/multi-select-lasso/multi-select-lasso.js +76 -0
  118. package/dist/components/newsletter-signup/index.js +8 -0
  119. package/dist/components/newsletter-signup/newsletter-signup.js +269 -0
  120. package/dist/components/object-card/index.js +6 -0
  121. package/dist/components/object-card/object-card.js +126 -0
  122. package/dist/components/object-handle/index.js +4 -0
  123. package/dist/components/object-handle/object-handle.js +38 -0
  124. package/dist/components/object-inspector/index.js +6 -0
  125. package/dist/components/object-inspector/object-inspector.js +136 -0
  126. package/dist/components/overview-board/index.js +8 -0
  127. package/dist/components/overview-board/overview-board.js +127 -0
  128. package/dist/components/parallel-timeline/index.js +6 -0
  129. package/dist/components/parallel-timeline/parallel-timeline.js +251 -0
  130. package/dist/components/playback-ghost/index.js +6 -0
  131. package/dist/components/playback-ghost/playback-ghost.js +83 -0
  132. package/dist/components/policy-delivery-panel/index.js +6 -0
  133. package/dist/components/policy-delivery-panel/policy-delivery-panel.js +99 -0
  134. package/dist/components/presence-stack/index.js +6 -0
  135. package/dist/components/presence-stack/presence-stack.js +108 -0
  136. package/dist/components/presence-sync-indicator/index.js +6 -0
  137. package/dist/components/presence-sync-indicator/presence-sync-indicator.js +73 -0
  138. package/dist/components/pricing-table/index.js +8 -0
  139. package/dist/components/pricing-table/pricing-table.js +247 -0
  140. package/dist/components/primary-source-viewer/index.js +26 -0
  141. package/dist/components/primary-source-viewer/primary-source-viewer.js +439 -0
  142. package/dist/components/progress-tracker/index.js +20 -0
  143. package/dist/components/progress-tracker/progress-tracker.js +527 -0
  144. package/dist/components/prompt-templates/index.js +6 -0
  145. package/dist/components/prompt-templates/prompt-templates.js +403 -0
  146. package/dist/components/property-section/index.js +6 -0
  147. package/dist/components/property-section/property-section.js +101 -0
  148. package/dist/components/relationship-inspector/index.js +6 -0
  149. package/dist/components/relationship-inspector/relationship-inspector.js +102 -0
  150. package/dist/components/right-dock/index.js +4 -0
  151. package/dist/components/right-dock/right-dock.js +28 -0
  152. package/dist/components/route-map/index.js +6 -0
  153. package/dist/components/route-map/route-map.js +339 -0
  154. package/dist/components/routing-assignment-panel/index.js +6 -0
  155. package/dist/components/routing-assignment-panel/routing-assignment-panel.js +122 -0
  156. package/dist/components/run-timeline/index.js +6 -0
  157. package/dist/components/run-timeline/run-timeline.js +221 -0
  158. package/dist/components/runtime-overview-panel/index.js +6 -0
  159. package/dist/components/runtime-overview-panel/runtime-overview-panel.js +89 -0
  160. package/dist/components/segmented-control/index.js +12 -0
  161. package/dist/components/segmented-control/segmented-control.js +61 -0
  162. package/dist/components/selection-halo/index.js +6 -0
  163. package/dist/components/selection-halo/selection-halo.js +72 -0
  164. package/dist/components/selection-presence/index.js +6 -0
  165. package/dist/components/selection-presence/selection-presence.js +50 -0
  166. package/dist/components/snap-guides/index.js +6 -0
  167. package/dist/components/snap-guides/snap-guides.js +45 -0
  168. package/dist/components/spinner/unicode-spinner.js +1 -0
  169. package/dist/components/state-badge-overlay/index.js +6 -0
  170. package/dist/components/state-badge-overlay/state-badge-overlay.js +90 -0
  171. package/dist/components/sticky-metric/index.js +6 -0
  172. package/dist/components/sticky-metric/sticky-metric.js +83 -0
  173. package/dist/components/story-map/index.js +8 -0
  174. package/dist/components/story-map/story-map.js +414 -0
  175. package/dist/components/tags-input/index.js +4 -0
  176. package/dist/components/tags-input/tags-input.js +178 -0
  177. package/dist/components/thread-bubble/index.js +6 -0
  178. package/dist/components/thread-bubble/thread-bubble.js +85 -0
  179. package/dist/components/threshold-ring/index.js +6 -0
  180. package/dist/components/threshold-ring/threshold-ring.js +160 -0
  181. package/dist/components/timeline/index.js +12 -0
  182. package/dist/components/timeline/timeline.js +239 -0
  183. package/dist/components/timeline-scrubber/index.js +6 -0
  184. package/dist/components/timeline-scrubber/timeline-scrubber.js +179 -0
  185. package/dist/components/top-bar/index.js +4 -0
  186. package/dist/components/top-bar/top-bar.js +31 -0
  187. package/dist/components/transaction-list/index.js +14 -0
  188. package/dist/components/transaction-list/transaction-list.js +226 -0
  189. package/dist/components/tree-view/index.js +6 -0
  190. package/dist/components/tree-view/tree-view.js +298 -0
  191. package/dist/components/usage-breakdown/usage-breakdown.js +1 -0
  192. package/dist/components/viewport-bookmarks/index.js +6 -0
  193. package/dist/components/viewport-bookmarks/viewport-bookmarks.js +116 -0
  194. package/dist/components/workspace-switcher/index.js +6 -0
  195. package/dist/components/workspace-switcher/workspace-switcher.js +61 -0
  196. package/dist/components/world-breadcrumbs/index.js +6 -0
  197. package/dist/components/world-breadcrumbs/world-breadcrumbs.js +114 -0
  198. package/dist/components/zoom-hud/index.js +4 -0
  199. package/dist/components/zoom-hud/zoom-hud.js +61 -0
  200. package/dist/index.d.ts +7906 -225
  201. package/dist/index.js +3 -1
  202. package/package.json +9 -5
@@ -0,0 +1,6 @@
1
+ import {
2
+ LiveCursor
3
+ } from "./live-cursor";
4
+ export {
5
+ LiveCursor
6
+ };
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ forwardRef
5
+ } from "react";
6
+ import { cn } from "../../lib/utils";
7
+ const DEFAULT_LABELS = {
8
+ region: "Live cursor"
9
+ };
10
+ const LiveCursor = forwardRef(
11
+ (props, ref) => {
12
+ const { className, color, labels, name, status, x, y, ...rest } = props;
13
+ const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
14
+ const resolvedColor = color ?? "var(--foreground)";
15
+ return /* @__PURE__ */ jsxs(
16
+ "div",
17
+ {
18
+ "aria-label": typeof name === "string" ? `${resolvedLabels.region}: ${name}` : resolvedLabels.region,
19
+ className: cn(
20
+ "pointer-events-none absolute z-30 flex items-start gap-1",
21
+ className
22
+ ),
23
+ "data-live-cursor": true,
24
+ ref,
25
+ role: "img",
26
+ style: { left: x, top: y },
27
+ ...rest,
28
+ children: [
29
+ /* @__PURE__ */ jsx(
30
+ "svg",
31
+ {
32
+ "aria-hidden": "true",
33
+ className: "-ml-1 -mt-1 drop-shadow-sm",
34
+ "data-live-cursor-pointer": true,
35
+ fill: resolvedColor,
36
+ height: 18,
37
+ viewBox: "0 0 16 18",
38
+ width: 16,
39
+ children: /* @__PURE__ */ jsx("path", { d: "M0 0 L0 14 L4 11 L7 17 L10 16 L7 10 L13 10 Z" })
40
+ }
41
+ ),
42
+ name === null || name === void 0 ? null : /* @__PURE__ */ jsxs(
43
+ "span",
44
+ {
45
+ className: "ml-2 mt-2 inline-flex flex-col rounded-md px-1.5 py-0.5 text-[10px] font-medium text-white shadow-sm",
46
+ "data-live-cursor-chip": true,
47
+ style: { backgroundColor: resolvedColor },
48
+ children: [
49
+ /* @__PURE__ */ jsx("span", { children: name }),
50
+ status ? /* @__PURE__ */ jsx("span", { className: "text-[9px] opacity-80", "data-live-cursor-status": true, children: status }) : null
51
+ ]
52
+ }
53
+ )
54
+ ]
55
+ }
56
+ );
57
+ }
58
+ );
59
+ LiveCursor.displayName = "LiveCursor";
60
+ export {
61
+ LiveCursor
62
+ };
@@ -0,0 +1,20 @@
1
+ import {
2
+ Map2D,
3
+ MapControls,
4
+ MapLayer,
5
+ MapMarker,
6
+ MapMarkerIcon,
7
+ MapPopup,
8
+ MapZoomIn,
9
+ MapZoomOut
10
+ } from "./map-2d";
11
+ export {
12
+ Map2D,
13
+ MapControls,
14
+ MapLayer,
15
+ MapMarker,
16
+ MapMarkerIcon,
17
+ MapPopup,
18
+ MapZoomIn,
19
+ MapZoomOut
20
+ };
@@ -0,0 +1,455 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ createContext,
5
+ forwardRef,
6
+ useCallback,
7
+ useContext,
8
+ useId,
9
+ useMemo,
10
+ useRef,
11
+ useState
12
+ } from "react";
13
+ import { cn } from "../../lib/utils";
14
+ const MIN_ZOOM = 1;
15
+ const MAX_ZOOM = 32;
16
+ const ZOOM_STEP = 1.5;
17
+ const VIEWBOX_WIDTH = 1e3;
18
+ const VIEWBOX_HEIGHT = 500;
19
+ const DEFAULT_LABELS = {
20
+ region: "Map",
21
+ zoomIn: "Zoom in",
22
+ zoomOut: "Zoom out"
23
+ };
24
+ const MapContext = createContext(null);
25
+ function useMapContext() {
26
+ const ctx = useContext(MapContext);
27
+ if (!ctx) {
28
+ throw new Error("Map2D subcomponent used outside its root.");
29
+ }
30
+ return ctx;
31
+ }
32
+ function clamp(value, min, max) {
33
+ return Math.min(Math.max(value, min), max);
34
+ }
35
+ function projectEquirectangular(position, width, height) {
36
+ const [lng, lat] = position;
37
+ const x = (lng + 180) / 360 * width;
38
+ const y = (90 - lat) / 180 * height;
39
+ return { x, y };
40
+ }
41
+ function useMapState(arguments_) {
42
+ const { center, initialZoom, resolvedLabels } = arguments_;
43
+ const initialPan = useMemo(() => {
44
+ const target = projectEquirectangular(
45
+ center,
46
+ VIEWBOX_WIDTH,
47
+ VIEWBOX_HEIGHT
48
+ );
49
+ return {
50
+ x: VIEWBOX_WIDTH / 2 - target.x,
51
+ y: VIEWBOX_HEIGHT / 2 - target.y
52
+ };
53
+ }, [center]);
54
+ const [pan, setPan] = useState(initialPan);
55
+ const [zoom, setZoom] = useState(
56
+ clamp(initialZoom, MIN_ZOOM, MAX_ZOOM)
57
+ );
58
+ const zoomIn = useCallback(() => {
59
+ setZoom((current) => clamp(current * ZOOM_STEP, MIN_ZOOM, MAX_ZOOM));
60
+ }, []);
61
+ const zoomOut = useCallback(() => {
62
+ setZoom((current) => clamp(current / ZOOM_STEP, MIN_ZOOM, MAX_ZOOM));
63
+ }, []);
64
+ const project = useCallback(
65
+ (position) => projectEquirectangular(position, VIEWBOX_WIDTH, VIEWBOX_HEIGHT),
66
+ []
67
+ );
68
+ return useMemo(
69
+ () => ({
70
+ height: VIEWBOX_HEIGHT,
71
+ labels: resolvedLabels,
72
+ pan,
73
+ project,
74
+ setPan,
75
+ width: VIEWBOX_WIDTH,
76
+ zoom,
77
+ zoomIn,
78
+ zoomOut
79
+ }),
80
+ [pan, project, resolvedLabels, zoom, zoomIn, zoomOut]
81
+ );
82
+ }
83
+ const MapControls = forwardRef(({ children, className, ...rest }, ref) => /* @__PURE__ */ jsx(
84
+ "div",
85
+ {
86
+ "aria-label": "Map controls",
87
+ className: cn(
88
+ "absolute right-3 top-3 z-20 flex flex-col gap-1 rounded-md border border-border bg-background/95 p-1 shadow-sm backdrop-blur",
89
+ className
90
+ ),
91
+ ref,
92
+ ...rest,
93
+ children
94
+ }
95
+ ));
96
+ MapControls.displayName = "MapControls";
97
+ const ControlButton = forwardRef(
98
+ ({ ariaLabel, className, glyph, onActivate, ...rest }, ref) => /* @__PURE__ */ jsx(
99
+ "button",
100
+ {
101
+ "aria-label": ariaLabel,
102
+ className: cn(
103
+ "inline-flex h-7 w-7 items-center justify-center rounded text-sm font-semibold hover:bg-accent focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
104
+ className
105
+ ),
106
+ onClick: onActivate,
107
+ ref,
108
+ type: "button",
109
+ ...rest,
110
+ children: glyph
111
+ }
112
+ )
113
+ );
114
+ ControlButton.displayName = "ControlButton";
115
+ const MapZoomIn = forwardRef(({ ...rest }, ref) => {
116
+ const { labels, zoomIn } = useMapContext();
117
+ return /* @__PURE__ */ jsx(
118
+ ControlButton,
119
+ {
120
+ ariaLabel: labels.zoomIn,
121
+ glyph: "+",
122
+ onActivate: zoomIn,
123
+ ref,
124
+ ...rest
125
+ }
126
+ );
127
+ });
128
+ MapZoomIn.displayName = "MapZoomIn";
129
+ const MapZoomOut = forwardRef(({ ...rest }, ref) => {
130
+ const { labels, zoomOut } = useMapContext();
131
+ return /* @__PURE__ */ jsx(
132
+ ControlButton,
133
+ {
134
+ ariaLabel: labels.zoomOut,
135
+ glyph: "\u2212",
136
+ onActivate: zoomOut,
137
+ ref,
138
+ ...rest
139
+ }
140
+ );
141
+ });
142
+ MapZoomOut.displayName = "MapZoomOut";
143
+ const MapMarkerIcon = forwardRef(({ children, className, ...rest }, ref) => /* @__PURE__ */ jsx("g", { className: cn("text-primary", className), ref, ...rest, children }));
144
+ MapMarkerIcon.displayName = "MapMarkerIcon";
145
+ function MarkerVisual({ children }) {
146
+ if (children) return children;
147
+ return /* @__PURE__ */ jsxs("g", { children: [
148
+ /* @__PURE__ */ jsx(
149
+ "circle",
150
+ {
151
+ className: "fill-primary stroke-background",
152
+ cx: "0",
153
+ cy: "0",
154
+ r: "7",
155
+ strokeWidth: "2"
156
+ }
157
+ ),
158
+ /* @__PURE__ */ jsx("circle", { className: "fill-background", cx: "0", cy: "0", r: "2" })
159
+ ] });
160
+ }
161
+ const MapMarker = forwardRef(
162
+ (props, ref) => {
163
+ const { children, className, onSelect, popup, position, title, ...rest } = props;
164
+ const { project } = useMapContext();
165
+ const point = project(position);
166
+ const markerId = useId();
167
+ const popupId = `${markerId}-popup`;
168
+ const labelText = title ?? (typeof popup === "string" ? popup : `Marker at ${position.join(", ")}`);
169
+ return /* @__PURE__ */ jsx("foreignObject", { height: "48", width: "48", x: point.x - 24, y: point.y - 24, children: /* @__PURE__ */ jsxs(
170
+ "button",
171
+ {
172
+ "aria-describedby": popup ? popupId : void 0,
173
+ "aria-label": labelText,
174
+ className: cn(
175
+ "group relative inline-flex h-full w-full cursor-pointer items-center justify-center bg-transparent p-0 outline-none focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
176
+ className
177
+ ),
178
+ "data-marker-id": markerId,
179
+ onClick: onSelect,
180
+ ref,
181
+ type: "button",
182
+ ...rest,
183
+ children: [
184
+ /* @__PURE__ */ jsx(
185
+ "svg",
186
+ {
187
+ className: "pointer-events-none h-6 w-6 overflow-visible",
188
+ viewBox: "-10 -10 20 20",
189
+ children: /* @__PURE__ */ jsx(MarkerVisual, { children })
190
+ }
191
+ ),
192
+ popup ? /* @__PURE__ */ jsx(
193
+ "span",
194
+ {
195
+ className: "pointer-events-none absolute bottom-full left-1/2 z-10 mb-1 hidden min-w-32 max-w-xs -translate-x-1/2 rounded-md border bg-popover px-2 py-1 text-center text-xs text-popover-foreground shadow-md group-hover:block group-focus-visible:block",
196
+ id: popupId,
197
+ role: "tooltip",
198
+ children: popup
199
+ }
200
+ ) : null
201
+ ]
202
+ }
203
+ ) });
204
+ }
205
+ );
206
+ MapMarker.displayName = "MapMarker";
207
+ const MapPopup = forwardRef(
208
+ (props, ref) => {
209
+ const { children, className, position, ...rest } = props;
210
+ const { project } = useMapContext();
211
+ const point = project(position);
212
+ return /* @__PURE__ */ jsx(
213
+ "foreignObject",
214
+ {
215
+ height: "200",
216
+ width: "320",
217
+ x: point.x - 160,
218
+ y: point.y - 220,
219
+ children: /* @__PURE__ */ jsx(
220
+ "div",
221
+ {
222
+ className: cn(
223
+ "pointer-events-auto inline-block max-w-xs -translate-y-2 rounded-md border bg-popover px-3 py-2 text-sm text-popover-foreground shadow-md",
224
+ className
225
+ ),
226
+ ref,
227
+ ...rest,
228
+ children
229
+ }
230
+ )
231
+ }
232
+ );
233
+ }
234
+ );
235
+ MapPopup.displayName = "MapPopup";
236
+ const MapLayer = forwardRef((props, ref) => {
237
+ const {
238
+ className,
239
+ data,
240
+ fill = "rgba(59, 130, 246, 0.15)",
241
+ stroke = "currentColor",
242
+ strokeWidth = 2,
243
+ ...rest
244
+ } = props;
245
+ const { project } = useMapContext();
246
+ return /* @__PURE__ */ jsx(
247
+ "g",
248
+ {
249
+ className: cn("text-blue-500/70", className),
250
+ "data-layer": "polygon",
251
+ ref,
252
+ ...rest,
253
+ children: data.map((shape) => {
254
+ const points = shape.coordinates.map((coord) => {
255
+ const projected = project(coord);
256
+ return `${projected.x.toString()},${projected.y.toString()}`;
257
+ }).join(" ");
258
+ return /* @__PURE__ */ jsx(
259
+ "polygon",
260
+ {
261
+ "data-shape-id": shape.id,
262
+ fill,
263
+ points,
264
+ stroke,
265
+ strokeWidth
266
+ },
267
+ shape.id
268
+ );
269
+ })
270
+ }
271
+ );
272
+ });
273
+ MapLayer.displayName = "MapLayer";
274
+ function usePanHandlers() {
275
+ const { height, pan, setPan, width, zoom } = useMapContext();
276
+ const dragRef = useRef(null);
277
+ const onPointerDown = useCallback(
278
+ (event) => {
279
+ dragRef.current = {
280
+ originPan: pan,
281
+ originX: event.clientX,
282
+ originY: event.clientY
283
+ };
284
+ event.currentTarget.setPointerCapture(event.pointerId);
285
+ },
286
+ [pan]
287
+ );
288
+ const onPointerMove = useCallback(
289
+ (event) => {
290
+ const drag = dragRef.current;
291
+ if (!drag) return;
292
+ const target = event.currentTarget;
293
+ const rect = target.getBoundingClientRect();
294
+ if (rect.width <= 0 || rect.height <= 0) return;
295
+ const scaleX = width / rect.width;
296
+ const scaleY = height / rect.height;
297
+ const dx = (event.clientX - drag.originX) * scaleX;
298
+ const dy = (event.clientY - drag.originY) * scaleY;
299
+ setPan({
300
+ x: drag.originPan.x + dx / zoom,
301
+ y: drag.originPan.y + dy / zoom
302
+ });
303
+ },
304
+ [height, setPan, width, zoom]
305
+ );
306
+ const onPointerEnd = useCallback(
307
+ (event) => {
308
+ const target = event.currentTarget;
309
+ if (target.hasPointerCapture(event.pointerId)) {
310
+ target.releasePointerCapture(event.pointerId);
311
+ }
312
+ dragRef.current = null;
313
+ },
314
+ []
315
+ );
316
+ return {
317
+ onPointerCancel: onPointerEnd,
318
+ onPointerDown,
319
+ onPointerMove,
320
+ onPointerUp: onPointerEnd
321
+ };
322
+ }
323
+ function Stage({ backdrop, backdropAlt, children }) {
324
+ const { height, pan, width, zoom } = useMapContext();
325
+ const handlers = usePanHandlers();
326
+ const innerWidth = width / zoom;
327
+ const innerHeight = height / zoom;
328
+ const viewX = (width - innerWidth) / 2 - pan.x;
329
+ const viewY = (height - innerHeight) / 2 - pan.y;
330
+ return /* @__PURE__ */ jsxs(
331
+ "svg",
332
+ {
333
+ className: "block h-full w-full cursor-grab touch-none active:cursor-grabbing",
334
+ "data-pan-x": pan.x,
335
+ "data-pan-y": pan.y,
336
+ "data-zoom": zoom,
337
+ preserveAspectRatio: "xMidYMid slice",
338
+ role: "presentation",
339
+ viewBox: `${viewX.toString()} ${viewY.toString()} ${innerWidth.toString()} ${innerHeight.toString()}`,
340
+ ...handlers,
341
+ children: [
342
+ /* @__PURE__ */ jsx("rect", { className: "fill-muted", height, width, x: "0", y: "0" }),
343
+ backdrop ? /* @__PURE__ */ jsx(
344
+ "image",
345
+ {
346
+ "aria-label": backdropAlt,
347
+ height,
348
+ href: backdrop,
349
+ preserveAspectRatio: "xMidYMid slice",
350
+ width,
351
+ x: "0",
352
+ y: "0"
353
+ }
354
+ ) : null,
355
+ children
356
+ ]
357
+ }
358
+ );
359
+ }
360
+ const SLOT_DISPLAY_NAMES = {
361
+ controls: MapControls.displayName,
362
+ layer: MapLayer.displayName,
363
+ marker: MapMarker.displayName,
364
+ popup: MapPopup.displayName
365
+ };
366
+ function displayName(child) {
367
+ if (typeof child !== "object" || child === null) return void 0;
368
+ if (!("type" in child)) return void 0;
369
+ const type = child.type;
370
+ if (typeof type !== "object" && typeof type !== "function") return void 0;
371
+ const name = type.displayName;
372
+ return typeof name === "string" ? name : void 0;
373
+ }
374
+ const SLOT_KEY_BY_NAME = {
375
+ [SLOT_DISPLAY_NAMES.controls]: "controls",
376
+ [SLOT_DISPLAY_NAMES.layer]: "layer",
377
+ [SLOT_DISPLAY_NAMES.marker]: "marker",
378
+ [SLOT_DISPLAY_NAMES.popup]: "popup"
379
+ };
380
+ function bucketChildren(children) {
381
+ const list = Array.isArray(children) ? children : [children];
382
+ return list.reduce(
383
+ (accumulator, child) => {
384
+ const name = displayName(child);
385
+ if (!name) return accumulator;
386
+ const key = SLOT_KEY_BY_NAME[name];
387
+ if (!key) return accumulator;
388
+ switch (key) {
389
+ case "controls":
390
+ accumulator.controls = child;
391
+ break;
392
+ case "marker":
393
+ accumulator.markers.push(child);
394
+ break;
395
+ case "layer":
396
+ accumulator.layers.push(child);
397
+ break;
398
+ case "popup":
399
+ accumulator.popups.push(child);
400
+ break;
401
+ }
402
+ return accumulator;
403
+ },
404
+ { controls: null, layers: [], markers: [], popups: [] }
405
+ );
406
+ }
407
+ const Map2D = forwardRef((props, ref) => {
408
+ const {
409
+ backdrop,
410
+ backdropAlt,
411
+ center = [0, 20],
412
+ children,
413
+ className,
414
+ labels,
415
+ zoom: initialZoom = 1,
416
+ ...rest
417
+ } = props;
418
+ const resolvedLabels = useMemo(
419
+ () => ({ ...DEFAULT_LABELS, ...labels }),
420
+ [labels]
421
+ );
422
+ const ctx = useMapState({ center, initialZoom, resolvedLabels });
423
+ const buckets = useMemo(() => bucketChildren(children), [children]);
424
+ return /* @__PURE__ */ jsx(MapContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
425
+ "section",
426
+ {
427
+ "aria-label": resolvedLabels.region,
428
+ className: cn(
429
+ "relative aspect-[2/1] w-full overflow-hidden rounded-2xl border bg-background text-foreground",
430
+ className
431
+ ),
432
+ ref,
433
+ ...rest,
434
+ children: [
435
+ /* @__PURE__ */ jsxs(Stage, { backdrop, backdropAlt, children: [
436
+ buckets.layers,
437
+ buckets.markers,
438
+ buckets.popups
439
+ ] }),
440
+ buckets.controls
441
+ ]
442
+ }
443
+ ) });
444
+ });
445
+ Map2D.displayName = "Map2D";
446
+ export {
447
+ Map2D,
448
+ MapControls,
449
+ MapLayer,
450
+ MapMarker,
451
+ MapMarkerIcon,
452
+ MapPopup,
453
+ MapZoomIn,
454
+ MapZoomOut
455
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ MapTimeline,
3
+ MapTimelineControls,
4
+ MapTimelineEvent,
5
+ MapTimelineLayer,
6
+ MapTimelinePlayButton,
7
+ MapTimelineSlider
8
+ } from "./map-timeline";
9
+ export {
10
+ MapTimeline,
11
+ MapTimelineControls,
12
+ MapTimelineEvent,
13
+ MapTimelineLayer,
14
+ MapTimelinePlayButton,
15
+ MapTimelineSlider
16
+ };