@r2digisolutions/components 0.24.7 → 0.24.9

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.
@@ -79,12 +79,17 @@
79
79
  const showImage = $derived(!!src && !imgError);
80
80
  </script>
81
81
 
82
- <span class={['relative inline-flex aspect-square shrink-0', className]}>
82
+ <span
83
+ class={[
84
+ 'relative inline-flex aspect-square shrink-0 overflow-hidden rounded-full',
85
+ sizeClasses[size],
86
+ className
87
+ ]}
88
+ >
83
89
  <span
84
90
  class={[
85
- 'inline-flex aspect-square items-center justify-center overflow-hidden rounded-full',
91
+ 'inline-flex h-full w-full items-center justify-center rounded-full',
86
92
  ringed && 'ring-2 ring-surface-elevated',
87
- sizeClasses[size],
88
93
  !showImage && [bgColor, 'text-white font-semibold']
89
94
  ]}
90
95
  role={alt ? 'img' : undefined}
@@ -0,0 +1,175 @@
1
+ <script lang="ts">
2
+ import type { Map as LeafletMap, Marker } from 'leaflet';
3
+ import { untrack } from 'svelte';
4
+
5
+ let {
6
+ lat,
7
+ lng,
8
+ label = '',
9
+ zoom = 14,
10
+ href,
11
+ linkLabel = 'OpenStreetMap',
12
+ class: className = '',
13
+ heightClass = 'h-56 sm:h-64'
14
+ }: {
15
+ lat: number;
16
+ lng: number;
17
+ label?: string;
18
+ zoom?: number;
19
+ href?: string;
20
+ linkLabel?: string;
21
+ class?: string;
22
+ heightClass?: string;
23
+ } = $props();
24
+
25
+ let mapEl: HTMLDivElement | undefined = $state();
26
+ let mapReady = $state(false);
27
+ let dark = $state(false);
28
+
29
+ /** Leaflet handles are non-reactive; sync via mapReady + props. */
30
+ let map: LeafletMap | null = null;
31
+ let marker: Marker | null = null;
32
+ let leaflet: typeof import('leaflet') | null = null;
33
+
34
+ const OSM_TILES = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
35
+ const invertTiles = $derived(dark);
36
+
37
+ $effect(() => {
38
+ if (typeof document === 'undefined') return;
39
+ const root = document.documentElement;
40
+ const sync = () => {
41
+ dark = root.classList.contains('dark');
42
+ };
43
+ sync();
44
+ const observer = new MutationObserver(sync);
45
+ observer.observe(root, { attributes: true, attributeFilter: ['class'] });
46
+ return () => observer.disconnect();
47
+ });
48
+
49
+ function syncView(m: LeafletMap, nextLat: number, nextLng: number, nextZoom: number) {
50
+ const latLng: [number, number] = [nextLat, nextLng];
51
+ marker?.setLatLng(latLng);
52
+ m.setView(latLng, nextZoom);
53
+ requestAnimationFrame(() => m.invalidateSize());
54
+ }
55
+
56
+ $effect(() => {
57
+ const el = mapEl;
58
+ if (!el) return;
59
+
60
+ let cancelled = false;
61
+ let instance: LeafletMap | null = null;
62
+ let resizeObserver: ResizeObserver | null = null;
63
+
64
+ (async () => {
65
+ const mod = await import('leaflet');
66
+ const L = ((mod as { default?: typeof import('leaflet') }).default ??
67
+ mod) as typeof import('leaflet');
68
+ await import('leaflet/dist/leaflet.css');
69
+ if (cancelled) return;
70
+
71
+ // Vite does not resolve Leaflet's default icon URLs from CSS; import assets.
72
+ const [iconRetina, icon, shadow] = await Promise.all([
73
+ import('leaflet/dist/images/marker-icon-2x.png'),
74
+ import('leaflet/dist/images/marker-icon.png'),
75
+ import('leaflet/dist/images/marker-shadow.png')
76
+ ]);
77
+ delete (L.Icon.Default.prototype as unknown as { _getIconUrl?: unknown })._getIconUrl;
78
+ L.Icon.Default.mergeOptions({
79
+ iconRetinaUrl: iconRetina.default,
80
+ iconUrl: icon.default,
81
+ shadowUrl: shadow.default
82
+ });
83
+
84
+ const initial = untrack(() => ({ lat, lng, zoom }));
85
+ instance = L.map(el, { scrollWheelZoom: false }).setView(
86
+ [initial.lat, initial.lng],
87
+ initial.zoom
88
+ );
89
+ L.tileLayer(OSM_TILES, {
90
+ maxZoom: 19,
91
+ attribution: '&copy; OpenStreetMap contributors'
92
+ }).addTo(instance);
93
+
94
+ marker = L.marker([initial.lat, initial.lng]).addTo(instance);
95
+ leaflet = L;
96
+ map = instance;
97
+ mapReady = true;
98
+
99
+ resizeObserver = new ResizeObserver(() => {
100
+ instance?.invalidateSize({ animate: false });
101
+ });
102
+ resizeObserver.observe(el);
103
+ requestAnimationFrame(() => instance?.invalidateSize({ animate: false }));
104
+ })();
105
+
106
+ return () => {
107
+ cancelled = true;
108
+ resizeObserver?.disconnect();
109
+ mapReady = false;
110
+ instance?.remove();
111
+ map = null;
112
+ marker = null;
113
+ leaflet = null;
114
+ };
115
+ });
116
+
117
+ $effect(() => {
118
+ const L = leaflet;
119
+ const m = map;
120
+ if (!mapReady || !L || !m) return;
121
+ syncView(m, lat, lng, zoom);
122
+ });
123
+ </script>
124
+
125
+ <div
126
+ class="r2-location-map border-border overflow-hidden rounded-2xl border bg-surface {className}"
127
+ data-dark={dark ? 'true' : 'false'}
128
+ data-tile-invert={invertTiles ? 'true' : 'false'}
129
+ >
130
+ <div class="relative w-full {heightClass}">
131
+ <div
132
+ bind:this={mapEl}
133
+ class="r2-location-map-canvas absolute inset-0 h-full w-full"
134
+ aria-label={label || 'Map'}
135
+ ></div>
136
+ </div>
137
+ {#if label}
138
+ <p class="text-muted px-3 py-2 text-xs">{label}</p>
139
+ {/if}
140
+ {#if href}
141
+ <p class="border-border border-t px-3 py-2">
142
+ <a
143
+ {href}
144
+ target="_blank"
145
+ rel="noopener noreferrer"
146
+ class="text-muted hover:text-primary text-xs underline-offset-2 hover:underline"
147
+ >
148
+ {linkLabel}
149
+ </a>
150
+ </p>
151
+ {/if}
152
+ </div>
153
+
154
+ <style>
155
+ :global(.r2-location-map-canvas.leaflet-container) {
156
+ height: 100%;
157
+ width: 100%;
158
+ z-index: 0;
159
+ font: inherit;
160
+ background: transparent;
161
+ }
162
+
163
+ :global(.r2-location-map[data-tile-invert='true'] .leaflet-container) {
164
+ background: #0a0a0a;
165
+ }
166
+
167
+ :global(.r2-location-map[data-tile-invert='true'] .leaflet-tile-pane) {
168
+ filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.95);
169
+ }
170
+
171
+ :global(.r2-location-map[data-dark='true'] .leaflet-control-attribution) {
172
+ background: rgb(24 24 27 / 0.8);
173
+ color: #a3a3a3;
174
+ }
175
+ </style>
@@ -0,0 +1,13 @@
1
+ type $$ComponentProps = {
2
+ lat: number;
3
+ lng: number;
4
+ label?: string;
5
+ zoom?: number;
6
+ href?: string;
7
+ linkLabel?: string;
8
+ class?: string;
9
+ heightClass?: string;
10
+ };
11
+ declare const LocationMap: import("svelte").Component<$$ComponentProps, {}, "">;
12
+ type LocationMap = ReturnType<typeof LocationMap>;
13
+ export default LocationMap;
@@ -89,7 +89,7 @@
89
89
  class={[
90
90
  'relative px-3 py-2 text-sm font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
91
91
  fullWidth && 'flex-1 text-center',
92
- item.disabled && 'opacity-40 cursor-not-allowed',
92
+ item.disabled ? 'cursor-not-allowed opacity-40' : 'cursor-pointer',
93
93
  variant === 'underline' &&
94
94
  (activeId === item.id
95
95
  ? 'text-brand-700 dark:text-brand-300'
@@ -142,9 +142,11 @@
142
142
  <div
143
143
  class={[
144
144
  'bg-surface flex w-full flex-col overflow-hidden',
145
- // h-dvh (not height:100%): % collapses when html/body have no explicit height
145
+ // Prefer h-full so embedded browsers (IDE Simple Browser) don't exceed the
146
+ // iframe: h-dvh tracks the OS window and causes a second outer scrollbar.
147
+ // min-h-dvh keeps a viewport floor when html/body have no explicit height.
146
148
  fillParent && 'min-h-0 h-full',
147
- !fillParent && fullHeight && 'h-dvh min-h-dvh',
149
+ !fillParent && fullHeight && 'h-full min-h-dvh',
148
150
  !fillParent && !fullHeight && 'min-h-[32rem]',
149
151
  className
150
152
  ]}
@@ -179,14 +181,16 @@
179
181
  </div>
180
182
  {/if}
181
183
 
182
- <!-- Form column: true center in remaining space -->
183
- <div
184
- class="min-h-0 px-5 py-8 sm:px-8 sm:py-10 flex h-full flex-1 flex-col items-center justify-center overflow-y-auto"
185
- >
186
- <div class="max-w-md mx-auto w-full shrink-0">
187
- {#if children}
188
- {@render children()}
189
- {/if}
184
+ <!-- Scroll outer, center inner (min-h-full): one scrollbar when tall -->
185
+ <div class="min-h-0 flex h-full flex-1 flex-col overflow-y-auto">
186
+ <div
187
+ class="px-5 py-8 sm:px-8 sm:py-10 flex min-h-full flex-1 flex-col items-center justify-center"
188
+ >
189
+ <div class="max-w-md mx-auto w-full shrink-0">
190
+ {#if children}
191
+ {@render children()}
192
+ {/if}
193
+ </div>
190
194
  </div>
191
195
  </div>
192
196
 
@@ -174,10 +174,10 @@
174
174
  aria-label="{copy.trigger}{unreadCount > 0 ? withCount(copy.unreadSuffix, unreadCount) : ''}"
175
175
  aria-expanded={open}
176
176
  aria-controls={popoverId}
177
- class="relative flex h-9 w-9 items-center justify-center rounded-lg text-secondary outline-none transition-colors hover:bg-surface-overlay hover:text-primary focus-visible:ring-2 focus-visible:ring-brand-500/30"
177
+ class="relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-xl border border-border bg-surface-elevated text-primary shadow-sm transition-all duration-200 hover:border-border-strong hover:bg-surface-overlay focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2"
178
178
  >
179
179
  <svg
180
- class="h-5 w-5"
180
+ class="h-4 w-4"
181
181
  viewBox="0 0 24 24"
182
182
  fill="none"
183
183
  stroke="currentColor"
@@ -192,7 +192,7 @@
192
192
  </svg>
193
193
  {#if unreadCount > 0}
194
194
  <span
195
- class="absolute -right-0.5 -top-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-brand-500 text-[10px] font-bold leading-none text-white"
195
+ class="pointer-events-none absolute -top-1 -right-1 flex min-w-5 items-center justify-center rounded-full bg-brand-500 px-1 py-0.5 text-[10px] font-bold leading-none text-white shadow-sm"
196
196
  >
197
197
  {unreadCount > 9 ? '9+' : unreadCount}
198
198
  </span>
package/dist/index.d.ts CHANGED
@@ -817,6 +817,7 @@ export { default as AssetPickerPage } from './components/organisms/AssetPickerPa
817
817
  export type { AssetPickerView, PickerAsset } from './components/organisms/AssetPickerPage/AssetPickerPage.svelte';
818
818
  export { default as ExploreFeedPage } from './components/organisms/ExploreFeedPage/ExploreFeedPage.svelte';
819
819
  export type { ExploreFeedItem, ExploreFeedGroup, ExploreSuggestion, ExploreFeaturedItem } from './components/organisms/ExploreFeedPage/ExploreFeedPage.svelte';
820
+ export { default as LocationMap } from './components/molecules/LocationMap/LocationMap.svelte';
820
821
  export { default as MapExplorer } from './components/organisms/MapExplorer/MapExplorer.svelte';
821
822
  export type { MapExplorerBounds, MapExplorerCluster, MapExplorerFilter, MapExplorerCardContext, MapExplorerItem, MapExplorerListView, MapExplorerPanel } from './components/organisms/MapExplorer/MapExplorer.svelte';
822
823
  export { default as MultiWorkspaceDashboard } from './components/organisms/MultiWorkspaceDashboard/MultiWorkspaceDashboard.svelte';
package/dist/index.js CHANGED
@@ -555,6 +555,7 @@ export { default as MobileAccountPage } from './components/organisms/MobileAccou
555
555
  export { default as BacklogPage } from './components/organisms/BacklogPage/BacklogPage.svelte';
556
556
  export { default as AssetPickerPage } from './components/organisms/AssetPickerPage/AssetPickerPage.svelte';
557
557
  export { default as ExploreFeedPage } from './components/organisms/ExploreFeedPage/ExploreFeedPage.svelte';
558
+ export { default as LocationMap } from './components/molecules/LocationMap/LocationMap.svelte';
558
559
  export { default as MapExplorer } from './components/organisms/MapExplorer/MapExplorer.svelte';
559
560
  export { default as MultiWorkspaceDashboard } from './components/organisms/MultiWorkspaceDashboard/MultiWorkspaceDashboard.svelte';
560
561
  export { default as LeadDetailPage } from './components/organisms/LeadDetailPage/LeadDetailPage.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.24.7",
3
+ "version": "0.24.9",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",