@sdxc/ui 2026.11.18 → 2026.11.22

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 (233) hide show
  1. package/README.md +133 -1
  2. package/dist/app/index.d.ts +1 -0
  3. package/dist/app/index.js +1 -0
  4. package/dist/app/mixins/command-palette.js +10 -2
  5. package/dist/app/mixins/log-viewer.js +17 -14
  6. package/dist/app/mixins/route-dialog.d.ts +17 -0
  7. package/dist/app/mixins/route-dialog.js +53 -0
  8. package/dist/app/optimistic-toggle.js +6 -0
  9. package/dist/app/route-dialog.d.ts +38 -0
  10. package/dist/app/route-dialog.js +49 -0
  11. package/dist/audio/equalizer.d.ts +24 -0
  12. package/dist/audio/equalizer.js +57 -0
  13. package/dist/audio/index.d.ts +16 -0
  14. package/dist/audio/index.js +16 -0
  15. package/dist/audio/media-tile.d.ts +38 -0
  16. package/dist/audio/media-tile.js +98 -0
  17. package/dist/audio/player-bar.d.ts +108 -0
  18. package/dist/audio/player-bar.js +338 -0
  19. package/dist/audio/queue-list.d.ts +56 -0
  20. package/dist/audio/queue-list.js +102 -0
  21. package/dist/audio/track-list.d.ts +91 -0
  22. package/dist/audio/track-list.js +226 -0
  23. package/dist/audio/utils/media-session.d.ts +44 -0
  24. package/dist/audio/utils/media-session.js +87 -0
  25. package/dist/audio/utils/play-queue.d.ts +98 -0
  26. package/dist/audio/utils/play-queue.js +149 -0
  27. package/dist/audio/utils/track-time.d.ts +28 -0
  28. package/dist/audio/utils/track-time.js +36 -0
  29. package/dist/chat/composer-format.d.ts +35 -0
  30. package/dist/chat/composer-format.js +84 -0
  31. package/dist/chat/index.d.ts +6 -0
  32. package/dist/chat/index.js +6 -0
  33. package/dist/chat/mention-menu.d.ts +43 -0
  34. package/dist/chat/mention-menu.js +70 -0
  35. package/dist/chat/message-group.d.ts +92 -0
  36. package/dist/chat/message-group.js +222 -0
  37. package/dist/chat/mixins/composer-format.d.ts +28 -0
  38. package/dist/chat/mixins/composer-format.js +80 -0
  39. package/dist/chat/mixins/composer-send.d.ts +2 -2
  40. package/dist/chat/mixins/composer-send.js +4 -2
  41. package/dist/chat/mixins/mention-menu.d.ts +41 -0
  42. package/dist/chat/mixins/mention-menu.js +213 -0
  43. package/dist/chat/mixins/reaction-sync.d.ts +47 -0
  44. package/dist/chat/mixins/reaction-sync.js +172 -0
  45. package/dist/chat/reaction-bar.d.ts +70 -0
  46. package/dist/chat/reaction-bar.js +108 -0
  47. package/dist/chat/typing-indicator.d.ts +42 -0
  48. package/dist/chat/typing-indicator.js +68 -0
  49. package/dist/chat/utils/composer-text.d.ts +38 -0
  50. package/dist/chat/utils/composer-text.js +86 -0
  51. package/dist/chat/utils/markdown-format.d.ts +30 -0
  52. package/dist/chat/utils/markdown-format.js +158 -0
  53. package/dist/chat/utils/mention-query.d.ts +55 -0
  54. package/dist/chat/utils/mention-query.js +60 -0
  55. package/dist/commerce/cart-drawer.d.ts +69 -0
  56. package/dist/commerce/cart-drawer.js +163 -0
  57. package/dist/commerce/cart-line.d.ts +32 -0
  58. package/dist/commerce/cart-line.js +43 -0
  59. package/dist/commerce/checkout-layout.d.ts +32 -0
  60. package/dist/commerce/checkout-layout.js +51 -0
  61. package/dist/commerce/facet-filters.d.ts +121 -0
  62. package/dist/commerce/facet-filters.js +318 -0
  63. package/dist/commerce/fulfilment-note.d.ts +28 -0
  64. package/dist/commerce/fulfilment-note.js +26 -0
  65. package/dist/commerce/index.d.ts +27 -0
  66. package/dist/commerce/index.js +27 -0
  67. package/dist/commerce/item-options-dialog.d.ts +67 -0
  68. package/dist/commerce/item-options-dialog.js +150 -0
  69. package/dist/commerce/menu-item-card.d.ts +37 -0
  70. package/dist/commerce/menu-item-card.js +96 -0
  71. package/dist/commerce/option-group.d.ts +62 -0
  72. package/dist/commerce/option-group.js +121 -0
  73. package/dist/commerce/order-summary.d.ts +42 -0
  74. package/dist/commerce/order-summary.js +76 -0
  75. package/dist/commerce/order-tracker.d.ts +80 -0
  76. package/dist/commerce/order-tracker.js +178 -0
  77. package/dist/commerce/price.d.ts +52 -0
  78. package/dist/commerce/price.js +108 -0
  79. package/dist/commerce/product-card.d.ts +53 -0
  80. package/dist/commerce/product-card.js +127 -0
  81. package/dist/commerce/product-gallery.d.ts +70 -0
  82. package/dist/commerce/product-gallery.js +186 -0
  83. package/dist/commerce/promo-code.d.ts +56 -0
  84. package/dist/commerce/promo-code.js +101 -0
  85. package/dist/commerce/quantity-stepper.d.ts +42 -0
  86. package/dist/commerce/quantity-stepper.js +53 -0
  87. package/dist/commerce/question-list.d.ts +53 -0
  88. package/dist/commerce/question-list.js +92 -0
  89. package/dist/commerce/shipping-estimate.d.ts +53 -0
  90. package/dist/commerce/shipping-estimate.js +39 -0
  91. package/dist/commerce/sort-select.d.ts +38 -0
  92. package/dist/commerce/sort-select.js +38 -0
  93. package/dist/commerce/variant-picker.d.ts +75 -0
  94. package/dist/commerce/variant-picker.js +135 -0
  95. package/dist/components/amount.d.ts +46 -0
  96. package/dist/components/amount.js +34 -0
  97. package/dist/components/autocomplete.d.ts +82 -0
  98. package/dist/components/autocomplete.js +114 -0
  99. package/dist/components/carousel.d.ts +31 -1
  100. package/dist/components/carousel.js +66 -3
  101. package/dist/components/index.d.ts +11 -0
  102. package/dist/components/index.js +11 -0
  103. package/dist/components/letterbox.d.ts +47 -0
  104. package/dist/components/letterbox.js +56 -0
  105. package/dist/components/lightbox.d.ts +88 -0
  106. package/dist/components/lightbox.js +224 -0
  107. package/dist/components/media-grid.d.ts +53 -0
  108. package/dist/components/media-grid.js +89 -0
  109. package/dist/components/range-months.d.ts +100 -0
  110. package/dist/components/range-months.js +274 -0
  111. package/dist/components/rating-input.d.ts +33 -0
  112. package/dist/components/rating-input.js +63 -0
  113. package/dist/components/rating.d.ts +38 -0
  114. package/dist/components/rating.js +66 -0
  115. package/dist/components/review-card.d.ts +39 -0
  116. package/dist/components/review-card.js +59 -0
  117. package/dist/components/section-bar.d.ts +57 -0
  118. package/dist/components/section-bar.js +140 -0
  119. package/dist/components/step-indicator.d.ts +46 -0
  120. package/dist/components/step-indicator.js +96 -0
  121. package/dist/finance/index.d.ts +10 -0
  122. package/dist/finance/index.js +10 -0
  123. package/dist/finance/ledger.d.ts +60 -0
  124. package/dist/finance/ledger.js +93 -0
  125. package/dist/finance/payment-card.d.ts +49 -0
  126. package/dist/finance/payment-card.js +115 -0
  127. package/dist/map/engine.d.ts +49 -0
  128. package/dist/map/engine.js +591 -0
  129. package/dist/map/index.d.ts +12 -0
  130. package/dist/map/index.js +12 -0
  131. package/dist/map/map-canvas.d.ts +101 -0
  132. package/dist/map/map-canvas.js +275 -0
  133. package/dist/map/map.d.ts +217 -0
  134. package/dist/map/map.js +598 -0
  135. package/dist/map/mixins/map-link.d.ts +30 -0
  136. package/dist/map/mixins/map-link.js +116 -0
  137. package/dist/map/utils/basemap.d.ts +88 -0
  138. package/dist/map/utils/basemap.js +84 -0
  139. package/dist/map/utils/cluster.d.ts +43 -0
  140. package/dist/map/utils/cluster.js +80 -0
  141. package/dist/map/utils/mercator.d.ts +66 -0
  142. package/dist/map/utils/mercator.js +92 -0
  143. package/dist/map/utils/stage.d.ts +24 -0
  144. package/dist/map/utils/stage.js +49 -0
  145. package/dist/mixins/autocomplete.d.ts +28 -0
  146. package/dist/mixins/autocomplete.js +283 -0
  147. package/dist/mixins/carousel-controls.d.ts +14 -3
  148. package/dist/mixins/carousel-controls.js +89 -30
  149. package/dist/mixins/index.d.ts +2 -0
  150. package/dist/mixins/index.js +2 -0
  151. package/dist/mixins/lightbox-controls.d.ts +34 -0
  152. package/dist/mixins/lightbox-controls.js +176 -0
  153. package/dist/schedule/agenda.d.ts +63 -0
  154. package/dist/schedule/agenda.js +221 -0
  155. package/dist/schedule/day-strip.d.ts +50 -0
  156. package/dist/schedule/day-strip.js +136 -0
  157. package/dist/schedule/free-busy.d.ts +96 -0
  158. package/dist/schedule/free-busy.js +285 -0
  159. package/dist/schedule/index.d.ts +15 -0
  160. package/dist/schedule/index.js +15 -0
  161. package/dist/schedule/mixins/day-strip-scroll.d.ts +16 -0
  162. package/dist/schedule/mixins/day-strip-scroll.js +40 -0
  163. package/dist/schedule/mixins/time-grid-drag.d.ts +24 -0
  164. package/dist/schedule/mixins/time-grid-drag.js +532 -0
  165. package/dist/schedule/month-view.d.ts +68 -0
  166. package/dist/schedule/month-view.js +301 -0
  167. package/dist/schedule/time-grid.d.ts +168 -0
  168. package/dist/schedule/time-grid.js +417 -0
  169. package/dist/schedule/utils/time-grid-layout.d.ts +50 -0
  170. package/dist/schedule/utils/time-grid-layout.js +93 -0
  171. package/dist/schedule/year-view.d.ts +46 -0
  172. package/dist/schedule/year-view.js +142 -0
  173. package/dist/styles/index.d.ts +1 -0
  174. package/dist/styles/index.js +1 -0
  175. package/dist/styles/typewriter-text.d.ts +20 -0
  176. package/dist/styles/typewriter-text.js +23 -0
  177. package/dist/test/map.d.ts +18 -0
  178. package/dist/test/map.js +96 -0
  179. package/dist/test/reels.d.ts +30 -0
  180. package/dist/test/reels.js +41 -0
  181. package/dist/test/stories.d.ts +31 -0
  182. package/dist/test/stories.js +66 -0
  183. package/dist/travel/boarding-pass.d.ts +107 -0
  184. package/dist/travel/boarding-pass.js +293 -0
  185. package/dist/travel/car-offer.d.ts +70 -0
  186. package/dist/travel/car-offer.js +127 -0
  187. package/dist/travel/fare-calendar.d.ts +85 -0
  188. package/dist/travel/fare-calendar.js +233 -0
  189. package/dist/travel/fare-options.d.ts +84 -0
  190. package/dist/travel/fare-options.js +142 -0
  191. package/dist/travel/flight-itinerary.d.ts +84 -0
  192. package/dist/travel/flight-itinerary.js +112 -0
  193. package/dist/travel/flight-option.d.ts +58 -0
  194. package/dist/travel/flight-option.js +111 -0
  195. package/dist/travel/flight-segment.d.ts +105 -0
  196. package/dist/travel/flight-segment.js +174 -0
  197. package/dist/travel/index.d.ts +20 -0
  198. package/dist/travel/index.js +20 -0
  199. package/dist/travel/package-savings.d.ts +74 -0
  200. package/dist/travel/package-savings.js +128 -0
  201. package/dist/travel/price-breakdown.d.ts +66 -0
  202. package/dist/travel/price-breakdown.js +102 -0
  203. package/dist/travel/rating-breakdown.d.ts +81 -0
  204. package/dist/travel/rating-breakdown.js +132 -0
  205. package/dist/travel/seat-map.d.ts +108 -0
  206. package/dist/travel/seat-map.js +371 -0
  207. package/dist/travel/trip-timeline.d.ts +84 -0
  208. package/dist/travel/trip-timeline.js +212 -0
  209. package/dist/utils/gamepad-presses.d.ts +21 -0
  210. package/dist/utils/gamepad-presses.js +28 -0
  211. package/dist/utils/index.d.ts +5 -0
  212. package/dist/utils/index.js +5 -0
  213. package/dist/utils/move-focus.d.ts +20 -0
  214. package/dist/utils/move-focus.js +28 -0
  215. package/dist/utils/range-months.d.ts +54 -0
  216. package/dist/utils/range-months.js +98 -0
  217. package/dist/utils/swipe-direction.d.ts +23 -0
  218. package/dist/utils/swipe-direction.js +27 -0
  219. package/dist/utils/typewriter.d.ts +49 -0
  220. package/dist/utils/typewriter.js +171 -0
  221. package/dist/video/index.d.ts +6 -2
  222. package/dist/video/index.js +6 -2
  223. package/dist/video/mixins/reel-feed-sync.d.ts +41 -0
  224. package/dist/video/mixins/reel-feed-sync.js +430 -0
  225. package/dist/video/mixins/story-viewer-sync.d.ts +31 -0
  226. package/dist/video/mixins/story-viewer-sync.js +391 -0
  227. package/dist/video/reel-feed.d.ts +95 -0
  228. package/dist/video/reel-feed.js +124 -0
  229. package/dist/video/story-ring.d.ts +32 -0
  230. package/dist/video/story-ring.js +42 -0
  231. package/dist/video/story-viewer.d.ts +85 -0
  232. package/dist/video/story-viewer.js +250 -0
  233. package/package.json +21 -2
@@ -0,0 +1,101 @@
1
+ /**
2
+ * A drawn map: a stage holding one SVG coordinate space, where caller-drawn art, routes, moving
3
+ * markers and price pins all place by viewBox units. Pins are HTML links or buttons laid over
4
+ * the art, so they stay crisp, focusable and at reading size at any stage width.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { EntryComponent, Handle, Props as TagProps, RemixNode } from "remix/component";
10
+ /** Prop types for {@link MapCanvas} and its parts. */
11
+ export declare namespace MapCanvas {
12
+ /** Every native `<figure>` attribute, plus the coordinate space and the art drawn in it. */
13
+ interface Props extends Omit<TagProps<"figure">, "children"> {
14
+ /**
15
+ * The SVG viewBox every part places by; a non-zero origin crops into one area of the art.
16
+ * The stage keeps its aspect ratio.
17
+ * @default "0 0 400 300"
18
+ */
19
+ viewBox?: string;
20
+ /** SVG children drawn under everything else: land, water, parks, roads. */
21
+ art?: RemixNode;
22
+ /** The map's accessible name, such as "Stays in Lisbon". */
23
+ label: string;
24
+ /** {@link MapCanvas.Route}, {@link MapCanvas.Marker} and {@link MapCanvas.Pin} elements. */
25
+ children?: RemixNode;
26
+ }
27
+ /** The parsed viewBox the stage hands its parts. */
28
+ interface Context {
29
+ minX: number;
30
+ minY: number;
31
+ width: number;
32
+ height: number;
33
+ viewBox: string;
34
+ }
35
+ /** Every native `<button>` attribute but `children`, plus where the pin sits and what it says. */
36
+ interface PinProps extends Omit<TagProps<"button">, "children" | "mix"> {
37
+ /** Mixins for the pin, which renders as either a link or a button. */
38
+ mix?: TagProps<"span">["mix"];
39
+ /** Horizontal position in viewBox units. */
40
+ x: number;
41
+ /** Vertical position in viewBox units. */
42
+ y: number;
43
+ /** The pill's content, such as a price or an icon; with text it names the pin. */
44
+ label: RemixNode;
45
+ /** Renders the pin as a link to this address instead of a button. */
46
+ href?: string;
47
+ /** Lights the pin as if pointed at, such as while its listing is hovered. */
48
+ highlighted?: boolean;
49
+ /** Marks the selected pin: inverted colors, drawn above the rest, `aria-current`. */
50
+ current?: boolean;
51
+ /**
52
+ * Colors of the pill at rest.
53
+ * @default "neutral"
54
+ */
55
+ tone?: "brand" | "neutral";
56
+ /** Record key shared with a listing row, linked through `mapLink`. */
57
+ mapKey?: string;
58
+ }
59
+ /** Every native `<svg>` attribute but its geometry, plus the path the route follows. */
60
+ interface RouteProps extends Omit<TagProps<"svg">, "children" | "viewBox"> {
61
+ /** Path data in viewBox units. */
62
+ d: string;
63
+ /**
64
+ * Share of the route already travelled, from 0 to 1, drawn solid; the rest is dashed.
65
+ * @default 0
66
+ */
67
+ done?: number;
68
+ }
69
+ /** Every native `<svg>` attribute but its geometry, plus where along a path the marker is. */
70
+ interface MarkerProps extends Omit<TagProps<"svg">, "children" | "viewBox"> {
71
+ /** Path data in viewBox units the marker travels. */
72
+ route: string;
73
+ /** Share of `route` travelled, from 0 to 1. */
74
+ progress: number;
75
+ /** SVG glyph centred on the origin; a dot with a halo when omitted. */
76
+ children?: RemixNode;
77
+ }
78
+ }
79
+ /**
80
+ * Renders the stage at the full width of its parent and at the viewBox's aspect ratio, the
81
+ * art in an `aria-hidden` SVG and its parts over it. Anything drawn past the viewBox is
82
+ * clipped, so the stage never widens the page.
83
+ *
84
+ * @example
85
+ * <MapCanvas label="Stays in Lisbon" art={<rect width="400" height="300" fill="#e8efe3" />}>
86
+ * <MapCanvas.Pin x={120} y={80} label="$182" href="/stays/1" mapKey="1" />
87
+ * </MapCanvas>
88
+ */
89
+ export declare function MapCanvas(handle: Handle<MapCanvas.Props, MapCanvas.Context>): () => import("remix/component").RemixElement;
90
+ export declare namespace MapCanvas {
91
+ var Route: (handle: Handle<MapCanvas.RouteProps>) => () => import("remix/component").RemixElement;
92
+ var Marker: (handle: Handle<MapCanvas.MarkerProps>) => () => import("remix/component").RemixElement;
93
+ var Pin: (handle: Handle<MapCanvas.PinProps>) => () => import("remix/component").RemixElement | null;
94
+ }
95
+ /**
96
+ * Links every row and pin carrying a `mapKey` on the page in one island, so a server-rendered
97
+ * list and its map light each other on hover and focus. Mount it once beside the map.
98
+ *
99
+ * @example <MapCanvasSync />
100
+ */
101
+ export declare const MapCanvasSync: EntryComponent<Record<never, never>>;
@@ -0,0 +1,275 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
2
+ import { mergeMix, raw } from "@sdxc/u/general";
3
+ import { motionReduce, motionSafe } from "@sdxc/u/responsive";
4
+ import { when } from "@sdxc/u/state";
5
+ import { clientEntry } from "remix/component";
6
+ import { mapLink, mapLinks } from "./mixins/map-link.js";
7
+ /** Coordinate space a stage draws in when the caller names none. */
8
+ const DEFAULT_VIEW_BOX = "0 0 400 300";
9
+ /** Tone a pin paints with when the caller names none. */
10
+ const DEFAULT_TONE = "neutral";
11
+ /** Share of a route drawn as travelled when the caller names none. */
12
+ const DEFAULT_DONE = 0;
13
+ /** Height, in pixels, of the tail under a pin, whose tip sits on the pin's point. */
14
+ const PIN_TAIL = 6;
15
+ /**
16
+ * Parses a viewBox into its four numbers, falling back to the default space when the string
17
+ * is malformed or has no area.
18
+ */
19
+ function parseViewBox(viewBox) {
20
+ let parts = viewBox
21
+ .trim()
22
+ .split(/[\s,]+/)
23
+ .map(Number);
24
+ let [minX = 0, minY = 0, width = 0, height = 0] = parts;
25
+ if (parts.length !== 4 || parts.some((part) => !Number.isFinite(part))) {
26
+ return parseViewBox(DEFAULT_VIEW_BOX);
27
+ }
28
+ if (width <= 0 || height <= 0)
29
+ return parseViewBox(DEFAULT_VIEW_BOX);
30
+ return { minX, minY, width, height, viewBox: `${minX} ${minY} ${width} ${height}` };
31
+ }
32
+ /** Clamps a share to the 0–1 range, reading anything that is not a number as 0. */
33
+ function clampShare(value) {
34
+ if (!Number.isFinite(value))
35
+ return 0;
36
+ return Math.min(1, Math.max(0, value));
37
+ }
38
+ /** Reads the stage's coordinate space, or the default one outside a stage. */
39
+ function spaceOf(handle) {
40
+ let context = handle.context.get(MapCanvas);
41
+ return context ?? parseViewBox(DEFAULT_VIEW_BOX);
42
+ }
43
+ /**
44
+ * Renders the stage at the full width of its parent and at the viewBox's aspect ratio, the
45
+ * art in an `aria-hidden` SVG and its parts over it. Anything drawn past the viewBox is
46
+ * clipped, so the stage never widens the page.
47
+ *
48
+ * @example
49
+ * <MapCanvas label="Stays in Lisbon" art={<rect width="400" height="300" fill="#e8efe3" />}>
50
+ * <MapCanvas.Pin x={120} y={80} label="$182" href="/stays/1" mapKey="1" />
51
+ * </MapCanvas>
52
+ */
53
+ export function MapCanvas(handle) {
54
+ return () => {
55
+ let { art, children, label, mix, viewBox, ...rest } = handle.props;
56
+ let space = parseViewBox(viewBox ?? DEFAULT_VIEW_BOX);
57
+ handle.context.set(space);
58
+ return (_jsxs("figure", { "aria-label": label, ...rest, "data-slot": "map-canvas", mix: mergeMix([
59
+ raw({
60
+ position: "relative",
61
+ isolation: "isolate",
62
+ inlineSize: "100%",
63
+ minInlineSize: "0",
64
+ aspectRatio: `${space.width} / ${space.height}`,
65
+ margin: "0",
66
+ overflow: "clip",
67
+ borderRadius: "var(--ui-map-radius, 0.75rem)",
68
+ background: "var(--ui-map-ground, var(--ui-neutral-bg-tint))",
69
+ }),
70
+ ], mix), children: [_jsx("svg", { viewBox: space.viewBox, preserveAspectRatio: "none", "aria-hidden": "true", focusable: "false", "data-slot": "map-canvas-art", mix: [
71
+ raw({
72
+ position: "absolute",
73
+ inset: "0",
74
+ inlineSize: "100%",
75
+ blockSize: "100%",
76
+ display: "block",
77
+ }),
78
+ ], children: art }), children] }));
79
+ };
80
+ }
81
+ /**
82
+ * Draws a route over the art: the travelled share as a solid line, the rest dashed, both over a
83
+ * light casing that keeps the line legible on any art.
84
+ *
85
+ * @example <MapCanvas.Route d="M40 250 C120 200 220 220 330 70" done={0.6} />
86
+ */
87
+ MapCanvas.Route = function MapCanvasRoute(handle) {
88
+ return () => {
89
+ let { d, done, mix, ...rest } = handle.props;
90
+ let space = spaceOf(handle);
91
+ let travelled = clampShare(done ?? DEFAULT_DONE);
92
+ return (_jsxs("svg", { ...rest, viewBox: space.viewBox, preserveAspectRatio: "none", "aria-hidden": "true", focusable: "false", "data-slot": "map-canvas-route", mix: mergeMix([
93
+ raw({
94
+ position: "absolute",
95
+ inset: "0",
96
+ inlineSize: "100%",
97
+ blockSize: "100%",
98
+ display: "block",
99
+ overflow: "visible",
100
+ pointerEvents: "none",
101
+ }),
102
+ ], mix), children: [_jsx("path", { d: d, "data-route-part": "casing", mix: [
103
+ raw({
104
+ fill: "none",
105
+ stroke: "var(--ui-map-route-casing, var(--ui-surface-raised, white))",
106
+ strokeWidth: "var(--ui-map-route-casing-width, 7)",
107
+ strokeLinecap: "round",
108
+ strokeLinejoin: "round",
109
+ }),
110
+ ] }), _jsx("path", { d: d, "data-route-part": "ahead", mix: [
111
+ raw({
112
+ fill: "none",
113
+ stroke: "var(--ui-map-route-color, var(--ui-brand-bg-solid))",
114
+ strokeOpacity: "0.55",
115
+ strokeWidth: "var(--ui-map-route-width, 3)",
116
+ strokeLinecap: "round",
117
+ strokeLinejoin: "round",
118
+ strokeDasharray: "var(--ui-map-route-dash, 2 7)",
119
+ }),
120
+ ] }), travelled > 0 ? (_jsx("path", { d: d, pathLength: "1", "data-route-part": "done", "stroke-dasharray": `${travelled} 2`, mix: [
121
+ raw({
122
+ fill: "none",
123
+ stroke: "var(--ui-map-route-color, var(--ui-brand-bg-solid))",
124
+ strokeWidth: "var(--ui-map-route-width, 3)",
125
+ strokeLinecap: "round",
126
+ strokeLinejoin: "round",
127
+ }),
128
+ ] })) : null] }));
129
+ };
130
+ };
131
+ /**
132
+ * Places a marker along a path with CSS motion paths, so a new `progress` glides it along the
133
+ * route instead of jumping; under reduced motion it moves straight to the new spot. The glyph
134
+ * group carries `data-map-marker` for scripts that update it live.
135
+ *
136
+ * @example <MapCanvas.Marker route="M40 250 C120 200 220 220 330 70" progress={0.6} />
137
+ */
138
+ MapCanvas.Marker = function MapCanvasMarker(handle) {
139
+ return () => {
140
+ let { children, mix, progress, route, ...rest } = handle.props;
141
+ let space = spaceOf(handle);
142
+ return (_jsx("svg", { ...rest, viewBox: space.viewBox, preserveAspectRatio: "none", "aria-hidden": "true", focusable: "false", "data-slot": "map-canvas-marker", mix: mergeMix([
143
+ raw({
144
+ position: "absolute",
145
+ inset: "0",
146
+ inlineSize: "100%",
147
+ blockSize: "100%",
148
+ display: "block",
149
+ overflow: "visible",
150
+ pointerEvents: "none",
151
+ }),
152
+ ], mix), children: _jsx("g", { "data-map-marker": "", style: {
153
+ "--ui-map-progress": String(clampShare(progress)),
154
+ offsetPath: `path(${JSON.stringify(route)})`,
155
+ }, mix: [
156
+ raw({
157
+ offsetDistance: "calc(var(--ui-map-progress) * 100%)",
158
+ offsetRotate: "0deg",
159
+ offsetAnchor: "0 0",
160
+ }),
161
+ motionSafe(raw({ transition: "offset-distance 400ms ease-out" })),
162
+ motionReduce(raw({ transition: "none" })),
163
+ ], children: children ?? (_jsxs(_Fragment, { children: [_jsx("circle", { r: "11", mix: [raw({ fill: "var(--ui-map-marker-color, var(--ui-brand-bg-solid))" })], "fill-opacity": "0.22" }), _jsx("circle", { r: "5.5", mix: [
164
+ raw({
165
+ fill: "var(--ui-map-marker-color, var(--ui-brand-bg-solid))",
166
+ stroke: "var(--ui-surface-raised, white)",
167
+ strokeWidth: "2",
168
+ }),
169
+ ] })] })) }) }));
170
+ };
171
+ };
172
+ /**
173
+ * One pin: a pill whose tail tips onto its point, as a link with `href` or a button otherwise
174
+ * (pass `popovertarget` or `commandfor` to open a card). Pointing, focus and `data-highlighted`
175
+ * lift it above its neighbours; a point outside the viewBox renders nothing.
176
+ *
177
+ * @example <MapCanvas.Pin x={210} y={140} label="$182" href="/stays/7" mapKey="7" current />
178
+ * @example <MapCanvas.Pin x={90} y={60} label="Casa Rosa" popovertarget="stay-3-card" />
179
+ */
180
+ MapCanvas.Pin = function MapCanvasPin(handle) {
181
+ return () => {
182
+ let { current = false, highlighted = false, href, label, mapKey, mix, tone, x, y, ...rest } = handle.props;
183
+ let space = spaceOf(handle);
184
+ let left = ((x - space.minX) / space.width) * 100;
185
+ let top = ((y - space.minY) / space.height) * 100;
186
+ if (!(left >= 0 && left <= 100 && top >= 0 && top <= 100))
187
+ return null;
188
+ let shared = {
189
+ "aria-current": current ? "true" : undefined,
190
+ "data-slot": "map-canvas-pin",
191
+ "data-tone": tone ?? DEFAULT_TONE,
192
+ "data-highlighted": highlighted ? "" : undefined,
193
+ style: { left: `${left}%`, top: `${top}%` },
194
+ mix: mergeMix([
195
+ raw({
196
+ position: "absolute",
197
+ zIndex: "1",
198
+ display: "inline-flex",
199
+ alignItems: "center",
200
+ gap: "0.25rem",
201
+ minBlockSize: "1.75rem",
202
+ paddingInline: "0.625rem",
203
+ border: "0",
204
+ borderRadius: "9999px",
205
+ font: "inherit",
206
+ fontSize: "0.8125rem",
207
+ fontWeight: "600",
208
+ lineHeight: "1",
209
+ whiteSpace: "nowrap",
210
+ fontVariantNumeric: "tabular-nums",
211
+ textDecoration: "none",
212
+ cursor: "pointer",
213
+ translate: `-50% calc(-100% - ${PIN_TAIL}px)`,
214
+ transformOrigin: `50% calc(100% + ${PIN_TAIL}px)`,
215
+ background: "var(--ui-surface-raised, white)",
216
+ color: "var(--ui-neutral-fg-emphasis)",
217
+ boxShadow: "var(--ui-shadow-ring)",
218
+ "&::after": {
219
+ content: '""',
220
+ position: "absolute",
221
+ insetBlockStart: "100%",
222
+ insetInlineStart: "50%",
223
+ inlineSize: `${PIN_TAIL * 2}px`,
224
+ blockSize: `${PIN_TAIL}px`,
225
+ translate: "-50% -0.5px",
226
+ clipPath: "polygon(0 0, 100% 0, 50% 100%)",
227
+ background: "inherit",
228
+ },
229
+ '&[data-tone="brand"]': {
230
+ background: "var(--ui-brand-bg-solid)",
231
+ color: "var(--ui-brand-fg-on-solid)",
232
+ },
233
+ "&[aria-current]": {
234
+ zIndex: "2",
235
+ background: "var(--ui-neutral-bg-solid)",
236
+ color: "var(--ui-neutral-fg-on-solid)",
237
+ },
238
+ '&[data-tone="brand"][aria-current]': {
239
+ background: "var(--ui-surface-raised, white)",
240
+ color: "var(--ui-brand-fg-emphasis)",
241
+ boxShadow: "0 0 0 2px var(--ui-brand-bg-solid)",
242
+ },
243
+ "&:hover, &:focus-visible, &[data-highlighted]": {
244
+ zIndex: "3",
245
+ boxShadow: "var(--ui-shadow-ring-hover), 0 4px 12px -4px rgb(0 0 0 / 0.3)",
246
+ },
247
+ "&[data-highlighted]:not([aria-current])": {
248
+ background: "var(--ui-neutral-bg-solid)",
249
+ color: "var(--ui-neutral-fg-on-solid)",
250
+ },
251
+ "@media (forced-colors: active)": { border: "1px solid CanvasText" },
252
+ }),
253
+ when("&:focus-visible", raw({ outline: "2px solid var(--ui-brand-ring)" })),
254
+ motionSafe(raw({
255
+ transition: "scale 140ms ease-out",
256
+ "&:hover, &:focus-visible, &[data-highlighted]": { scale: "1.08" },
257
+ })),
258
+ ...(mapKey === undefined ? [] : [mapLink(mapKey)]),
259
+ ], mix),
260
+ };
261
+ if (href !== undefined) {
262
+ return (_jsx("a", { ...rest, ...shared, href: href, children: label }));
263
+ }
264
+ return (_jsx("button", { type: "button", ...rest, ...shared, children: label }));
265
+ };
266
+ };
267
+ /**
268
+ * Links every row and pin carrying a `mapKey` on the page in one island, so a server-rendered
269
+ * list and its map light each other on hover and focus. Mount it once beside the map.
270
+ *
271
+ * @example <MapCanvasSync />
272
+ */
273
+ export const MapCanvasSync = clientEntry("@sdxc/ui/map/map-canvas#MapCanvasSync", function MapCanvasSync() {
274
+ return () => _jsx("span", { hidden: true, mix: [mapLinks()] });
275
+ });
@@ -0,0 +1,217 @@
1
+ /**
2
+ * A geographic map that renders on the server: real longitude and latitude projected with Web
3
+ * Mercator onto a stage, a vector basemap as SVG, markers as links or buttons that cluster when
4
+ * close, popups, routes and zoom links that work without script; an island makes it draggable.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { EntryComponent, Handle, Props as TagProps, RemixElement, RemixNode } from "remix/component";
10
+ import type { EngineProps } from "./engine.js";
11
+ import type { MapFeatureCollection } from "./utils/basemap.js";
12
+ import type { LngLat, Pixel, View } from "./utils/mercator.js";
13
+ export type { Bounds, LngLat, View } from "./utils/mercator.js";
14
+ export type { FeatureKind, MapFeature, MapFeatureCollection } from "./utils/basemap.js";
15
+ /**
16
+ * OpenFreeMap's free vector styles, a quiet light one and its dark twin, which need no key.
17
+ * Their style, tiles, glyphs and sprites all load from `tiles.openfreemap.org`, the one host a
18
+ * page's CSP must allow in `connect-src` and `img-src` (with `blob:`) to draw them.
19
+ */
20
+ export declare const OPEN_FREE_MAP: GeoMap.StyleBasemap;
21
+ /** Prop types for {@link GeoMap} and its parts. */
22
+ export declare namespace GeoMap {
23
+ /** A control the map can show in its top corner. */
24
+ type Control = "zoom" | "reset" | "locate" | "fullscreen";
25
+ /** Caller-drawn vector land, water, parks, roads and place names from GeoJSON. */
26
+ interface GeoJSONBasemap {
27
+ kind: "geojson";
28
+ /** Features sorted by `properties.kind`; see `MapFeatureProperties`. */
29
+ data: MapFeatureCollection;
30
+ /**
31
+ * What the stage shows where no feature is drawn: `water` for an island or a coast
32
+ * drawn as land polygons in a sea.
33
+ * @default "land"
34
+ */
35
+ ground?: "land" | "water";
36
+ }
37
+ /** Tiles from a MapLibre style, such as OpenFreeMap's, drawn once the island loads. */
38
+ interface StyleBasemap {
39
+ kind: "style";
40
+ /** Style URL for the light theme. */
41
+ light: string;
42
+ /** Style URL for the dark theme; the light style serves both when omitted. */
43
+ dark?: string;
44
+ /** Drawn on the server and without script, under the markers, such as a static image. */
45
+ fallback?: RemixNode;
46
+ }
47
+ /** What the map draws under its markers. */
48
+ type Basemap = GeoJSONBasemap | StyleBasemap;
49
+ /** Builds a page URL for a view, which turns zoom controls and clusters into links. */
50
+ interface Navigation {
51
+ href(view: View): string;
52
+ }
53
+ /** Every string the map speaks; the library ships no copy. */
54
+ interface Labels {
55
+ zoomIn: string;
56
+ zoomOut: string;
57
+ /** The control that returns to the starting view. */
58
+ reset: string;
59
+ /** The control that centres the map on the visitor's location. */
60
+ locate: string;
61
+ fullscreen: string;
62
+ /** A cluster bubble's accessible name, with `{count}` for its markers, such as "{count} stays". */
63
+ cluster: string;
64
+ /** Shown on touch screens when one finger tries to pan, such as "Use two fingers to move the map". */
65
+ gestureHint: string;
66
+ }
67
+ /** Every native `<div>` attribute, plus the view, the basemap and the strings. */
68
+ interface Props extends Omit<TagProps<"div">, "children" | "id"> {
69
+ /** The stage's id, which the island finds it by. */
70
+ id: string;
71
+ /** The map's accessible name, such as "Stays in Lisbon". */
72
+ label: string;
73
+ /** The point at the middle of the stage. */
74
+ center: LngLat;
75
+ zoom: number;
76
+ /** @default 0 */
77
+ minZoom?: number;
78
+ /** @default 20 */
79
+ maxZoom?: number;
80
+ /**
81
+ * What the map is drawn on: a MapLibre style pair, or your own GeoJSON.
82
+ * @default OPEN_FREE_MAP
83
+ */
84
+ basemap?: Basemap;
85
+ /** @default ["zoom"] */
86
+ controls?: Control[];
87
+ /** Turns zoom controls and clusters into links that work without script. */
88
+ navigation?: Navigation;
89
+ labels: Labels;
90
+ /**
91
+ * Distance in pixels under which markers gather into one bubble.
92
+ * @default 44
93
+ */
94
+ clusterRadius?: number;
95
+ /**
96
+ * Stage size in pixels assumed on the server for the bounds a search area submits.
97
+ * @default [1024, 768]
98
+ */
99
+ viewport?: Pixel;
100
+ /** Where the island loads MapLibre's worker from, such as a bundler's `?url` import. */
101
+ workerUrl?: string;
102
+ /** {@link GeoMap.Marker}, {@link GeoMap.Route} and {@link GeoMap.Area} elements. */
103
+ children?: RemixNode;
104
+ }
105
+ /** What the stage hands its parts. */
106
+ interface Context {
107
+ id: string;
108
+ view: View;
109
+ minZoom: number;
110
+ maxZoom: number;
111
+ viewport: Pixel;
112
+ /** Keys of markers drawn inside a cluster bubble instead of on their own. */
113
+ clustered: Set<string>;
114
+ }
115
+ /** Every native `<button>` attribute but `children`, plus where the marker sits and what it says. */
116
+ interface MarkerProps extends Omit<TagProps<"button">, "children" | "mix"> {
117
+ /** Mixins for the marker, which renders as either a link or a button. */
118
+ mix?: TagProps<"span">["mix"];
119
+ at: LngLat;
120
+ /** The pill's content, such as a price; with text it names the marker. */
121
+ label: RemixNode;
122
+ /** Renders the marker as a link; a popup then opens on hover and focus. */
123
+ href?: string;
124
+ /** Lights the marker as if pointed at, such as while its listing is hovered. */
125
+ highlighted?: boolean;
126
+ /** Marks the selected marker: inverted colors, drawn above the rest, never clustered. */
127
+ current?: boolean;
128
+ /** @default "neutral" */
129
+ tone?: "brand" | "neutral";
130
+ /** Record key shared with a listing row, linked through `mapLink`. */
131
+ mapKey?: string;
132
+ /** A {@link GeoMap.Popup}. */
133
+ children?: RemixNode;
134
+ }
135
+ /** What a marker hands its popup. */
136
+ interface MarkerContext {
137
+ popupId: string;
138
+ anchor: string;
139
+ }
140
+ /** Every native `<div>` attribute; the popup's content is its children. */
141
+ interface PopupProps extends Omit<TagProps<"div">, "id" | "popover" | "style"> {
142
+ children?: RemixNode;
143
+ }
144
+ /** Every native `<svg>` attribute but its geometry, plus the line the route follows. */
145
+ interface RouteProps extends Omit<TagProps<"svg">, "children" | "viewBox"> {
146
+ path: LngLat[];
147
+ /**
148
+ * Share of the route travelled, from 0 to 1, drawn solid; the rest is dashed.
149
+ * @default 0
150
+ */
151
+ progress?: number;
152
+ /** {@link GeoMap.RouteMarker} elements. */
153
+ children?: RemixNode;
154
+ }
155
+ /** What a route hands its markers. */
156
+ interface RouteContext {
157
+ d: string;
158
+ progress: number;
159
+ }
160
+ /** Every native `<g>` attribute, plus where along the route the glyph sits. */
161
+ interface RouteMarkerProps extends Omit<TagProps<"g">, "children" | "style"> {
162
+ /**
163
+ * `progress` follows the route's progress and the live `--ui-map-progress` property; a
164
+ * number is a fixed share.
165
+ * @default "progress"
166
+ */
167
+ at?: "progress" | "start" | "end" | number;
168
+ /** SVG glyph centred on the origin; a dot with a halo when omitted. */
169
+ children?: RemixNode;
170
+ }
171
+ /** The form fields a "Search this area" button fills, and its content. */
172
+ interface AreaProps extends Omit<TagProps<"button">, "children" | "form" | "type"> {
173
+ /** The id of the form the fields and the button belong to. */
174
+ form: string;
175
+ /** The button's content, such as "Search this area". */
176
+ label: RemixNode;
177
+ /**
178
+ * Field receiving `west,south,east,north`.
179
+ * @default "bounds"
180
+ */
181
+ name?: string;
182
+ /**
183
+ * Field receiving `longitude,latitude` of the middle.
184
+ * @default "center"
185
+ */
186
+ centerName?: string;
187
+ /**
188
+ * Field receiving the zoom.
189
+ * @default "zoom"
190
+ */
191
+ zoomName?: string;
192
+ }
193
+ }
194
+ /**
195
+ * The map stage: a region at the full size of its parent (20rem tall at least) that draws the
196
+ * basemap as SVG, writes place names, clusters close markers into bubbles and shows the
197
+ * controls, then hands the stage to the island, which mounts MapLibre in it when WebGL works.
198
+ *
199
+ * @example
200
+ * <GeoMap id="stays-map" label="Stays in Lisbon" center={[-9.14, 38.72]} zoom={12} labels={labels} navigation={{ href: (view) => `?zoom=${view.zoom}&center=${view.center}` }}>
201
+ * <GeoMap.Marker at={[-9.15, 38.71]} label="$182" href="/stays/1" mapKey="1" />
202
+ * </GeoMap>
203
+ */
204
+ export declare function GeoMap(handle: Handle<GeoMap.Props, GeoMap.Context>): () => RemixElement;
205
+ export declare namespace GeoMap {
206
+ var Marker: (handle: Handle<GeoMap.MarkerProps, GeoMap.MarkerContext>) => () => RemixElement;
207
+ var Popup: (handle: Handle<GeoMap.PopupProps>) => () => RemixElement;
208
+ var Route: (handle: Handle<GeoMap.RouteProps, GeoMap.RouteContext>) => () => RemixElement;
209
+ var RouteMarker: (handle: Handle<GeoMap.RouteMarkerProps>) => () => RemixElement;
210
+ var Area: (handle: Handle<GeoMap.AreaProps>) => () => RemixElement;
211
+ }
212
+ /**
213
+ * The island every map stage renders: it finds the stage by id and hands it to the browser
214
+ * engine, then passes on new props after a re-render such as a frame swap, so the camera
215
+ * follows a server-chosen view. It draws nothing itself.
216
+ */
217
+ export declare const GeoMapEngine: EntryComponent<EngineProps>;