@j3m-quantum/ui 1.8.0 → 1.9.1

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.
package/README.md CHANGED
@@ -8,6 +8,13 @@ J3M Quantum UI - A React component library with J3M design tokens.
8
8
  - **Tailwind CSS v4** (required - not compatible with v3)
9
9
  - **tw-animate-css** >= 1.0.0
10
10
 
11
+ ### Optional Peer Dependencies
12
+
13
+ | Package | Version | Required For |
14
+ |---------|---------|--------------|
15
+ | `leaflet` | ^1.9.4 | Map components |
16
+ | `react-leaflet` | ^5.0.0 | Map components |
17
+
11
18
  ## Features
12
19
 
13
20
  - **J3M Design Tokens** - Orange primary, neutral grays, pill-shaped buttons
@@ -272,6 +279,9 @@ Dialog, Drawer, Sheet, Popover, HoverCard
272
279
  ### Layout
273
280
  ScrollArea, Collapsible, Resizable, Sidebar, SidebarProvider, SidebarInset, Section
274
281
 
282
+ ### Map
283
+ Map, MapTileLayer, MapMarker, MapPopup, MapTooltip, MapZoomControl
284
+
275
285
  ### Utilities
276
286
  ThemeSwitch, ToolbarCanvas, PlayerCanvas
277
287
 
@@ -381,6 +391,96 @@ const navItems: NavItem[] = [
381
391
  <NavMain items={navItems} />
382
392
  ```
383
393
 
394
+ ## Map Components
395
+
396
+ Leaflet-based map components for displaying interactive maps. **Requires optional peer dependencies.**
397
+
398
+ ### Installation
399
+
400
+ ```bash
401
+ npm install leaflet react-leaflet
402
+ ```
403
+
404
+ ### Setup
405
+
406
+ Import Leaflet CSS in your app's entry CSS file:
407
+
408
+ ```css
409
+ /* src/index.css */
410
+ @import "tailwindcss";
411
+ @import "tw-animate-css";
412
+ @import "@j3m-quantum/ui/styles";
413
+ @import "leaflet/dist/leaflet.css";
414
+ ```
415
+
416
+ ### Basic Usage
417
+
418
+ ```tsx
419
+ import { Map, MapTileLayer, MapMarker, MapPopup } from '@j3m-quantum/ui'
420
+
421
+ function MyMap() {
422
+ return (
423
+ <Map center={[57.7089, 11.9746]} zoom={12} className="h-[400px]">
424
+ <MapTileLayer />
425
+ <MapMarker position={[57.7089, 11.9746]}>
426
+ <MapPopup>Hello from Gothenburg!</MapPopup>
427
+ </MapMarker>
428
+ </Map>
429
+ )
430
+ }
431
+ ```
432
+
433
+ ### Tile Layer Variants
434
+
435
+ ```tsx
436
+ // Default (OpenStreetMap)
437
+ <MapTileLayer variant="default" />
438
+
439
+ // Dark mode tiles
440
+ <MapTileLayer variant="dark" />
441
+
442
+ // Satellite imagery
443
+ <MapTileLayer variant="satellite" />
444
+ ```
445
+
446
+ ### Map Components Reference
447
+
448
+ | Component | Description |
449
+ |-----------|-------------|
450
+ | `Map` | Main map container. Requires explicit height via `className` or `style`. |
451
+ | `MapTileLayer` | Tile layer for map background. Supports `default`, `dark`, `satellite` variants. |
452
+ | `MapMarker` | Marker at a specific position. Can contain Popup and Tooltip children. |
453
+ | `MapPopup` | Popup that appears when a marker is clicked. |
454
+ | `MapTooltip` | Tooltip that appears on marker hover. |
455
+ | `MapZoomControl` | Custom zoom control positioning (MapContainer has built-in controls). |
456
+
457
+ ### Fixing Marker Icons
458
+
459
+ Bundlers may break Leaflet's default marker icon paths. Fix by configuring icons in your app:
460
+
461
+ ```tsx
462
+ import L from "leaflet"
463
+
464
+ delete (L.Icon.Default.prototype as any)._getIconUrl
465
+ L.Icon.Default.mergeOptions({
466
+ iconRetinaUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png",
467
+ iconUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png",
468
+ shadowUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png",
469
+ })
470
+ ```
471
+
472
+ ### React StrictMode
473
+
474
+ When using React StrictMode, use unique keys on Map components to prevent "already initialized" errors:
475
+
476
+ ```tsx
477
+ const [mapKey] = useState(() => `map-${Date.now()}`)
478
+
479
+ <Map key={mapKey} center={[57.7089, 11.9746]} zoom={12}>
480
+ ...
481
+ </Map>
482
+ ```
483
+
384
484
  ## Customization
385
485
 
386
486
  Override CSS variables after the import:
package/dist/index.cjs CHANGED
@@ -40,6 +40,7 @@ var PopoverPrimitive = require('@radix-ui/react-popover');
40
40
  var HoverCardPrimitive = require('@radix-ui/react-hover-card');
41
41
  var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
42
42
  var ResizablePrimitive = require('react-resizable-panels');
43
+ var reactLeaflet = require('react-leaflet');
43
44
  var reactTable = require('@tanstack/react-table');
44
45
  var dateFns = require('date-fns');
45
46
 
@@ -5888,6 +5889,89 @@ var SectionFooter = React27__namespace.forwardRef(
5888
5889
  )
5889
5890
  );
5890
5891
  SectionFooter.displayName = "SectionFooter";
5892
+ function Map2({
5893
+ center,
5894
+ zoom = 13,
5895
+ className,
5896
+ children,
5897
+ ...props
5898
+ }) {
5899
+ return /* @__PURE__ */ jsxRuntime.jsx(
5900
+ reactLeaflet.MapContainer,
5901
+ {
5902
+ center,
5903
+ zoom,
5904
+ className: cn(
5905
+ "w-full rounded-lg border border-border overflow-hidden",
5906
+ "[&_.leaflet-control-zoom]:border-border",
5907
+ "[&_.leaflet-control-zoom]:rounded-md",
5908
+ "[&_.leaflet-control-zoom]:shadow-sm",
5909
+ "[&_.leaflet-control-zoom-in]:rounded-t-md",
5910
+ "[&_.leaflet-control-zoom-in]:border-b",
5911
+ "[&_.leaflet-control-zoom-in]:border-border",
5912
+ "[&_.leaflet-control-zoom-out]:rounded-b-md",
5913
+ "[&_.leaflet-popup-content-wrapper]:rounded-lg",
5914
+ "[&_.leaflet-popup-content-wrapper]:shadow-lg",
5915
+ "[&_.leaflet-popup-content-wrapper]:border",
5916
+ "[&_.leaflet-popup-content-wrapper]:border-border",
5917
+ className
5918
+ ),
5919
+ scrollWheelZoom: true,
5920
+ ...props,
5921
+ children
5922
+ }
5923
+ );
5924
+ }
5925
+ var TILE_LAYERS = {
5926
+ default: {
5927
+ url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
5928
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
5929
+ },
5930
+ dark: {
5931
+ url: "https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",
5932
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>'
5933
+ },
5934
+ satellite: {
5935
+ url: "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
5936
+ attribution: "&copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"
5937
+ }
5938
+ };
5939
+ function MapTileLayer({
5940
+ variant = "default",
5941
+ ...props
5942
+ }) {
5943
+ const layer = TILE_LAYERS[variant];
5944
+ return /* @__PURE__ */ jsxRuntime.jsx(
5945
+ reactLeaflet.TileLayer,
5946
+ {
5947
+ url: layer.url,
5948
+ attribution: layer.attribution,
5949
+ ...props
5950
+ }
5951
+ );
5952
+ }
5953
+ function MapMarker({
5954
+ position,
5955
+ children,
5956
+ ...props
5957
+ }) {
5958
+ return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.Marker, { position, ...props, children });
5959
+ }
5960
+ function MapPopup({
5961
+ children,
5962
+ ...props
5963
+ }) {
5964
+ return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.Popup, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm", children }) });
5965
+ }
5966
+ function MapTooltip({
5967
+ children,
5968
+ ...props
5969
+ }) {
5970
+ return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.Tooltip, { ...props, children });
5971
+ }
5972
+ function MapZoomControl(props) {
5973
+ return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.ZoomControl, { ...props });
5974
+ }
5891
5975
  function DataTableColumnHeader({
5892
5976
  column,
5893
5977
  title,
@@ -13797,6 +13881,12 @@ exports.ItemTitle = ItemTitle;
13797
13881
  exports.Kbd = Kbd;
13798
13882
  exports.KbdGroup = KbdGroup;
13799
13883
  exports.Label = Label2;
13884
+ exports.Map = Map2;
13885
+ exports.MapMarker = MapMarker;
13886
+ exports.MapPopup = MapPopup;
13887
+ exports.MapTileLayer = MapTileLayer;
13888
+ exports.MapTooltip = MapTooltip;
13889
+ exports.MapZoomControl = MapZoomControl;
13800
13890
  exports.Menubar = Menubar;
13801
13891
  exports.MenubarCheckboxItem = MenubarCheckboxItem;
13802
13892
  exports.MenubarContent = MenubarContent;