@krizaka/ui 3.76.0 → 3.77.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.
- package/dist/blocks.css +14 -0
- package/dist/chunk-NM2DEHFZ.js +25 -0
- package/dist/chunk-NM2DEHFZ.js.map +1 -0
- package/dist/document-viewer.d.ts +23 -6
- package/dist/document-viewer.js +21 -5
- package/dist/document-viewer.js.map +1 -1
- package/dist/map/cards.d.ts +145 -0
- package/dist/map/cards.js +74 -0
- package/dist/map/cards.js.map +1 -0
- package/dist/map/pin.d.ts +57 -0
- package/dist/map/pin.js +53 -0
- package/dist/map/pin.js.map +1 -0
- package/dist/map/sheet.d.ts +80 -0
- package/dist/map/sheet.js +61 -0
- package/dist/map/sheet.js.map +1 -0
- package/dist/map.d.ts +41 -14
- package/dist/map.js +85 -112
- package/dist/map.js.map +1 -1
- package/dist/native/map.d.ts +29 -10
- package/dist/native/map.js +81 -107
- package/dist/native/map.js.map +1 -1
- package/dist/shop/services.js +1 -1
- package/dist/shop/services.js.map +1 -1
- package/dist/shop-composer.js +1 -1
- package/dist/shop-composer.js.map +1 -1
- package/dist/shop-gallery.js +2 -2
- package/dist/shop-gallery.js.map +1 -1
- package/dist/wall.d.ts +10 -5
- package/dist/wall.js +10 -4
- package/dist/wall.js.map +1 -1
- package/package.json +53 -8
- package/registry/app-frame.json +1 -1
- package/registry/document-viewer.json +9 -8
- package/registry/examples/document-viewer/highlights.js +2 -1
- package/registry/examples/document-viewer/highlights.tsx +3 -0
- package/registry/examples/map/pins.d.ts +4 -0
- package/registry/examples/map/pins.js +20 -0
- package/registry/examples/map/pins.tsx +27 -0
- package/registry/examples/map/place-sheet.d.ts +4 -0
- package/registry/examples/map/place-sheet.js +34 -0
- package/registry/examples/map/place-sheet.tsx +35 -0
- package/registry/examples/wall/tidy.d.ts +4 -0
- package/registry/examples/wall/tidy.js +27 -0
- package/registry/examples/wall/tidy.tsx +19 -0
- package/registry/index.json +9 -9
- package/registry/map.json +81 -13
- package/registry/nav-bar.json +1 -1
- package/registry/rail-nav.json +1 -1
- package/registry/shop-gallery.json +1 -1
- package/registry/shop.json +2 -2
- package/registry/site-footer.json +1 -1
- package/registry/wall.json +24 -2
package/dist/map/pin.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
tv
|
|
4
|
+
} from "../chunk-NM2DEHFZ.js";
|
|
5
|
+
|
|
6
|
+
// src/map/pin/map-pin.tsx
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var mapPin = tv({
|
|
9
|
+
slots: {
|
|
10
|
+
root: "relative inline-flex items-center justify-center text-on-accent transition-transform motion-reduce:transition-none",
|
|
11
|
+
shape: "block h-full w-full overflow-visible drop-shadow-md",
|
|
12
|
+
glyph: "absolute inset-0 flex items-center justify-center text-[0.55em] font-semibold leading-none [&>svg]:h-[55%] [&>svg]:w-[55%]"
|
|
13
|
+
},
|
|
14
|
+
variants: {
|
|
15
|
+
selected: {
|
|
16
|
+
true: { root: "scale-125" }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
var PATHS = {
|
|
21
|
+
drop: { d: "M12 1C6.2 1 1.5 5.6 1.5 11.3 1.5 18.6 12 31 12 31s10.5-12.4 10.5-19.7C22.5 5.6 17.8 1 12 1Z", viewBox: "0 0 24 32", height: 32 / 24, head: [12, 11.5] },
|
|
22
|
+
disc: { d: "M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z", viewBox: "0 0 24 24", height: 1, head: [12, 12] },
|
|
23
|
+
tag: { d: "M5 2h14a2 2 0 0 1 2 2v12l-9 7.5L3 16V4a2 2 0 0 1 2-2Z", viewBox: "0 0 24 26", height: 26 / 24, head: [12, 10] }
|
|
24
|
+
};
|
|
25
|
+
function pinColours(shape, state, tone) {
|
|
26
|
+
const tag = shape === "tag";
|
|
27
|
+
const base = tag ? "var(--kz-paper-tag)" : `var(--kz-${tone === "margin" ? "paper-rule-margin" : "accent"})`;
|
|
28
|
+
const edge = tag ? "var(--kz-paper-tag-edge)" : "var(--kz-on-accent)";
|
|
29
|
+
const muted = "var(--kz-text-muted)";
|
|
30
|
+
if (state === "closed") return { edge, fill: "var(--kz-surface-3)", stroke: muted, glyph: muted, headFill: "none" };
|
|
31
|
+
if (state === "visited") return { edge, fill: "var(--kz-surface-1)", stroke: base, glyph: base, headFill: base };
|
|
32
|
+
return { edge, fill: base, stroke: edge, glyph: tag ? "var(--kz-paper-tag-ink)" : edge, headFill: "var(--kz-surface-0)" };
|
|
33
|
+
}
|
|
34
|
+
var GLYPH_TOP = { drop: "-8%", tag: "6%", disc: 0 };
|
|
35
|
+
function MapPin({ shape = "drop", state = "default", tone = "accent", size = 28, children, className }) {
|
|
36
|
+
const s = mapPin({ selected: state === "selected" });
|
|
37
|
+
const p = PATHS[shape];
|
|
38
|
+
const c = pinColours(shape, state, tone);
|
|
39
|
+
const closed = state === "closed";
|
|
40
|
+
return /* @__PURE__ */ jsxs("span", { className: s.root({ className }), style: { width: size, height: size * p.height }, "data-shape": shape, "data-state": state, "aria-hidden": "true", children: [
|
|
41
|
+
/* @__PURE__ */ jsxs("svg", { className: s.shape(), viewBox: p.viewBox, focusable: "false", children: [
|
|
42
|
+
/* @__PURE__ */ jsx("path", { d: p.d, fill: c.fill, stroke: c.stroke, strokeWidth: state === "selected" ? 2.5 : 1.75, strokeDasharray: closed ? "3 2" : void 0 }),
|
|
43
|
+
shape === "tag" ? /* @__PURE__ */ jsx("circle", { cx: 12, cy: 5.5, r: 1.6, fill: "var(--kz-surface-0)", stroke: c.edge, strokeWidth: 1 }) : null,
|
|
44
|
+
children ? null : /* @__PURE__ */ jsx("circle", { cx: p.head[0], cy: p.head[1], r: shape === "disc" ? 3 : 3.2, fill: c.headFill, opacity: closed ? 0 : 1 })
|
|
45
|
+
] }),
|
|
46
|
+
children ? /* @__PURE__ */ jsx("span", { className: s.glyph(), style: { color: c.glyph, top: GLYPH_TOP[shape] }, children }) : null
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
MapPin,
|
|
51
|
+
mapPin
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=pin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/map/pin/map-pin.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { tv } from \"../../tv\";\n\nexport const mapPin = tv({\n slots: {\n root: \"relative inline-flex items-center justify-center text-on-accent transition-transform motion-reduce:transition-none\",\n shape: \"block h-full w-full overflow-visible drop-shadow-md\",\n glyph: \"absolute inset-0 flex items-center justify-center text-[0.55em] font-semibold leading-none [&>svg]:h-[55%] [&>svg]:w-[55%]\",\n },\n variants: {\n selected: {\n true: { root: \"scale-125\" },\n },\n },\n});\n\nexport type MapPinShape = \"drop\" | \"disc\" | \"tag\";\nexport type MapPinState = \"default\" | \"selected\" | \"visited\" | \"closed\";\n\nexport type MapPinProps = {\n /** `drop` (a pin, its tip on the place), `disc` (a dot with a ring) or `tag` (the Cahier's manila tag with its eyelet). Default `drop`. */\n shape?: MapPinShape;\n /** `default`; `selected` (larger, the ring doubled); `visited` (hollow: seen already); `closed` (greyed: not available now). */\n state?: MapPinState;\n /** `accent` (the product's colour) or `margin` (the notebook's red). Default `accent`. */\n tone?: \"accent\" | \"margin\";\n /** Its size in pixels (the width). Default 28. */\n size?: number;\n /** A short mark or an icon in the head of the pin (\"3\", an icon). */\n children?: React.ReactNode;\n className?: string;\n};\n\nconst PATHS: Record<MapPinShape, { d: string; viewBox: string; height: number; head: [number, number] }> = {\n drop: { d: \"M12 1C6.2 1 1.5 5.6 1.5 11.3 1.5 18.6 12 31 12 31s10.5-12.4 10.5-19.7C22.5 5.6 17.8 1 12 1Z\", viewBox: \"0 0 24 32\", height: 32 / 24, head: [12, 11.5] },\n disc: { d: \"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z\", viewBox: \"0 0 24 24\", height: 1, head: [12, 12] },\n tag: { d: \"M5 2h14a2 2 0 0 1 2 2v12l-9 7.5L3 16V4a2 2 0 0 1 2-2Z\", viewBox: \"0 0 24 26\", height: 26 / 24, head: [12, 10] },\n};\n\ntype PinColours = { edge: string; fill: string; stroke: string; glyph: string; headFill: string };\n\n/** The colours a pin wears for its shape, state and tone: the state is also said by shape (hollow, struck), never by colour alone. */\nfunction pinColours(shape: MapPinShape, state: MapPinState, tone: \"accent\" | \"margin\"): PinColours {\n const tag = shape === \"tag\";\n const base = tag ? \"var(--kz-paper-tag)\" : `var(--kz-${tone === \"margin\" ? \"paper-rule-margin\" : \"accent\"})`;\n const edge = tag ? \"var(--kz-paper-tag-edge)\" : \"var(--kz-on-accent)\";\n const muted = \"var(--kz-text-muted)\";\n if (state === \"closed\") return { edge, fill: \"var(--kz-surface-3)\", stroke: muted, glyph: muted, headFill: \"none\" };\n if (state === \"visited\") return { edge, fill: \"var(--kz-surface-1)\", stroke: base, glyph: base, headFill: base };\n return { edge, fill: base, stroke: edge, glyph: tag ? \"var(--kz-paper-tag-ink)\" : edge, headFill: \"var(--kz-surface-0)\" };\n}\n\nconst GLYPH_TOP: Record<MapPinShape, string | number> = { drop: \"-8%\", tag: \"6%\", disc: 0 };\n\n/**\n * A pin for a `Marker`'s children: three shapes, four states, drawn from the tokens (both themes). Decorative by itself —\n * the `Marker` carries the label — and the state is also said by shape (hollow, struck), never by colour alone.\n */\nexport function MapPin({ shape = \"drop\", state = \"default\", tone = \"accent\", size = 28, children, className }: Readonly<MapPinProps>) {\n const s = mapPin({ selected: state === \"selected\" });\n const p = PATHS[shape];\n const c = pinColours(shape, state, tone);\n const closed = state === \"closed\";\n return (\n <span className={s.root({ className })} style={{ width: size, height: size * p.height }} data-shape={shape} data-state={state} aria-hidden=\"true\">\n <svg className={s.shape()} viewBox={p.viewBox} focusable=\"false\">\n <path d={p.d} fill={c.fill} stroke={c.stroke} strokeWidth={state === \"selected\" ? 2.5 : 1.75} strokeDasharray={closed ? \"3 2\" : undefined} />\n {shape === \"tag\" ? <circle cx={12} cy={5.5} r={1.6} fill=\"var(--kz-surface-0)\" stroke={c.edge} strokeWidth={1} /> : null}\n {children ? null : <circle cx={p.head[0]} cy={p.head[1]} r={shape === \"disc\" ? 3 : 3.2} fill={c.headFill} opacity={closed ? 0 : 1} />}\n </svg>\n {children ? (\n <span className={s.glyph()} style={{ color: c.glyph, top: GLYPH_TOP[shape] }}>\n {children}\n </span>\n ) : null}\n </span>\n );\n}\n"],"mappings":";;;;;;AAoEM,SACE,KADF;AA9DC,IAAM,SAAS,GAAG;AAAA,EACvB,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA,UAAU;AAAA,IACR,UAAU;AAAA,MACR,MAAM,EAAE,MAAM,YAAY;AAAA,IAC5B;AAAA,EACF;AACF,CAAC;AAmBD,IAAM,QAAqG;AAAA,EACzG,MAAM,EAAE,GAAG,+FAA+F,SAAS,aAAa,QAAQ,KAAK,IAAI,MAAM,CAAC,IAAI,IAAI,EAAE;AAAA,EAClK,MAAM,EAAE,GAAG,4CAA4C,SAAS,aAAa,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE;AAAA,EACvG,KAAK,EAAE,GAAG,yDAAyD,SAAS,aAAa,QAAQ,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE;AAC3H;AAKA,SAAS,WAAW,OAAoB,OAAoB,MAAuC;AACjG,QAAM,MAAM,UAAU;AACtB,QAAM,OAAO,MAAM,wBAAwB,YAAY,SAAS,WAAW,sBAAsB,QAAQ;AACzG,QAAM,OAAO,MAAM,6BAA6B;AAChD,QAAM,QAAQ;AACd,MAAI,UAAU,SAAU,QAAO,EAAE,MAAM,MAAM,uBAAuB,QAAQ,OAAO,OAAO,OAAO,UAAU,OAAO;AAClH,MAAI,UAAU,UAAW,QAAO,EAAE,MAAM,MAAM,uBAAuB,QAAQ,MAAM,OAAO,MAAM,UAAU,KAAK;AAC/G,SAAO,EAAE,MAAM,MAAM,MAAM,QAAQ,MAAM,OAAO,MAAM,4BAA4B,MAAM,UAAU,sBAAsB;AAC1H;AAEA,IAAM,YAAkD,EAAE,MAAM,OAAO,KAAK,MAAM,MAAM,EAAE;AAMnF,SAAS,OAAO,EAAE,QAAQ,QAAQ,QAAQ,WAAW,OAAO,UAAU,OAAO,IAAI,UAAU,UAAU,GAA0B;AACpI,QAAM,IAAI,OAAO,EAAE,UAAU,UAAU,WAAW,CAAC;AACnD,QAAM,IAAI,MAAM,KAAK;AACrB,QAAM,IAAI,WAAW,OAAO,OAAO,IAAI;AACvC,QAAM,SAAS,UAAU;AACzB,SACE,qBAAC,UAAK,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,OAAO,EAAE,OAAO,MAAM,QAAQ,OAAO,EAAE,OAAO,GAAG,cAAY,OAAO,cAAY,OAAO,eAAY,QACzI;AAAA,yBAAC,SAAI,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,WAAU,SACvD;AAAA,0BAAC,UAAK,GAAG,EAAE,GAAG,MAAM,EAAE,MAAM,QAAQ,EAAE,QAAQ,aAAa,UAAU,aAAa,MAAM,MAAM,iBAAiB,SAAS,QAAQ,QAAW;AAAA,MAC1I,UAAU,QAAQ,oBAAC,YAAO,IAAI,IAAI,IAAI,KAAK,GAAG,KAAK,MAAK,uBAAsB,QAAQ,EAAE,MAAM,aAAa,GAAG,IAAK;AAAA,MACnH,WAAW,OAAO,oBAAC,YAAO,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,GAAG,UAAU,SAAS,IAAI,KAAK,MAAM,EAAE,UAAU,SAAS,SAAS,IAAI,GAAG;AAAA,OACrI;AAAA,IACC,WACC,oBAAC,UAAK,WAAW,EAAE,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,UAAU,KAAK,EAAE,GACxE,UACH,IACE;AAAA,KACN;AAEJ;","names":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
declare const mapSheet: tailwind_variants.TVReturnType<{
|
|
5
|
+
snap: {
|
|
6
|
+
peek: {
|
|
7
|
+
root: string;
|
|
8
|
+
};
|
|
9
|
+
half: {
|
|
10
|
+
root: string;
|
|
11
|
+
};
|
|
12
|
+
full: {
|
|
13
|
+
root: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}, {
|
|
17
|
+
root: string;
|
|
18
|
+
handle: string;
|
|
19
|
+
grip: string;
|
|
20
|
+
body: string;
|
|
21
|
+
}, undefined, {
|
|
22
|
+
snap: {
|
|
23
|
+
peek: {
|
|
24
|
+
root: string;
|
|
25
|
+
};
|
|
26
|
+
half: {
|
|
27
|
+
root: string;
|
|
28
|
+
};
|
|
29
|
+
full: {
|
|
30
|
+
root: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
root: string;
|
|
35
|
+
handle: string;
|
|
36
|
+
grip: string;
|
|
37
|
+
body: string;
|
|
38
|
+
}, tailwind_variants.TVReturnTypeLike<{
|
|
39
|
+
snap: {
|
|
40
|
+
peek: {
|
|
41
|
+
root: string;
|
|
42
|
+
};
|
|
43
|
+
half: {
|
|
44
|
+
root: string;
|
|
45
|
+
};
|
|
46
|
+
full: {
|
|
47
|
+
root: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}, {
|
|
51
|
+
root: string;
|
|
52
|
+
handle: string;
|
|
53
|
+
grip: string;
|
|
54
|
+
body: string;
|
|
55
|
+
}>>;
|
|
56
|
+
type MapSheetSnap = "peek" | "half" | "full";
|
|
57
|
+
declare const MAP_SHEET_SNAPS: readonly MapSheetSnap[];
|
|
58
|
+
type MapSheetProps = Omit<React.ComponentProps<"section">, "children"> & {
|
|
59
|
+
/** What the sheet is, passed translated: its accessible name ("Place details"). */
|
|
60
|
+
label: string;
|
|
61
|
+
/** The content: an info card, a route card, a list. */
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
/** The snap point, when controlled. */
|
|
64
|
+
snap?: MapSheetSnap;
|
|
65
|
+
/** The snap point at the start, when not controlled. Default "peek". */
|
|
66
|
+
defaultSnap?: MapSheetSnap;
|
|
67
|
+
/** Called with the new snap point (the handle: a press cycles, ArrowUp / ArrowDown step, Home / End jump). */
|
|
68
|
+
onSnapChange?: (snap: MapSheetSnap) => void;
|
|
69
|
+
/** The handle's name, translated ("Resize the panel"). */
|
|
70
|
+
handleLabel: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* A NON-modal sheet over a map: the map stays alive and reachable behind it (no scrim, no focus trap, nothing made
|
|
74
|
+
* inert). On a phone it rises from the bottom with three snap points; from the `md` breakpoint it is a card at the
|
|
75
|
+
* side and the handle disappears. Place it in the map's positioned container.
|
|
76
|
+
*/
|
|
77
|
+
declare function MapSheet({ label, children, snap, defaultSnap, onSnapChange, handleLabel, className, ...props }: MapSheetProps): React.JSX.Element;
|
|
78
|
+
|
|
79
|
+
export { MAP_SHEET_SNAPS, MapSheet, mapSheet };
|
|
80
|
+
export type { MapSheetProps, MapSheetSnap };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
tv
|
|
4
|
+
} from "../chunk-NM2DEHFZ.js";
|
|
5
|
+
|
|
6
|
+
// src/map/sheet/map-sheet.tsx
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var mapSheet = tv({
|
|
10
|
+
slots: {
|
|
11
|
+
root: "absolute inset-x-0 bottom-0 z-10 flex max-h-full flex-col rounded-t-2xl border border-border-subtle bg-surface-1 text-fg shadow-lg transition-[height] duration-200 motion-reduce:transition-none md:inset-y-3 md:left-3 md:right-auto md:max-h-none md:w-[22rem] md:rounded-2xl",
|
|
12
|
+
handle: "flex h-6 w-full shrink-0 items-center justify-center md:hidden focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-border-focus",
|
|
13
|
+
grip: "h-1 w-10 rounded-full bg-border-default",
|
|
14
|
+
body: "min-h-0 flex-1 overflow-y-auto px-4 pb-4 md:pt-4"
|
|
15
|
+
},
|
|
16
|
+
variants: {
|
|
17
|
+
snap: {
|
|
18
|
+
peek: { root: "h-24 md:h-auto" },
|
|
19
|
+
half: { root: "h-1/2 md:h-auto" },
|
|
20
|
+
full: { root: "h-[92%] md:h-auto" }
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: { snap: "peek" }
|
|
24
|
+
});
|
|
25
|
+
var MAP_SHEET_SNAPS = ["peek", "half", "full"];
|
|
26
|
+
function MapSheet({ label, children, snap, defaultSnap = "peek", onSnapChange, handleLabel, className, ...props }) {
|
|
27
|
+
const [inner, setInner] = React.useState(defaultSnap);
|
|
28
|
+
const current = snap ?? inner;
|
|
29
|
+
const set = (next) => {
|
|
30
|
+
if (snap === void 0) setInner(next);
|
|
31
|
+
onSnapChange?.(next);
|
|
32
|
+
};
|
|
33
|
+
const step = (by) => set(MAP_SHEET_SNAPS[Math.min(MAP_SHEET_SNAPS.length - 1, Math.max(0, MAP_SHEET_SNAPS.indexOf(current) + by))]);
|
|
34
|
+
const s = mapSheet({ snap: current });
|
|
35
|
+
return /* @__PURE__ */ jsxs("section", { ...props, "aria-label": label, "data-snap": current, className: s.root({ className }), children: [
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
"button",
|
|
38
|
+
{
|
|
39
|
+
type: "button",
|
|
40
|
+
className: s.handle(),
|
|
41
|
+
"aria-label": handleLabel,
|
|
42
|
+
"aria-expanded": current !== "peek",
|
|
43
|
+
onClick: () => set(MAP_SHEET_SNAPS[(MAP_SHEET_SNAPS.indexOf(current) + 1) % MAP_SHEET_SNAPS.length]),
|
|
44
|
+
onKeyDown: (e) => {
|
|
45
|
+
const move = { ArrowUp: () => step(1), ArrowDown: () => step(-1), Home: () => set("peek"), End: () => set("full") }[e.key];
|
|
46
|
+
if (!move) return;
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
move();
|
|
49
|
+
},
|
|
50
|
+
children: /* @__PURE__ */ jsx("span", { className: s.grip(), "aria-hidden": true })
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ jsx("div", { className: s.body(), children })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
MAP_SHEET_SNAPS,
|
|
58
|
+
MapSheet,
|
|
59
|
+
mapSheet
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=sheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/map/sheet/map-sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { tv } from \"../../tv\";\n\nexport const mapSheet = tv({\n slots: {\n root: \"absolute inset-x-0 bottom-0 z-10 flex max-h-full flex-col rounded-t-2xl border border-border-subtle bg-surface-1 text-fg shadow-lg transition-[height] duration-200 motion-reduce:transition-none md:inset-y-3 md:left-3 md:right-auto md:max-h-none md:w-[22rem] md:rounded-2xl\",\n handle: \"flex h-6 w-full shrink-0 items-center justify-center md:hidden focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-border-focus\",\n grip: \"h-1 w-10 rounded-full bg-border-default\",\n body: \"min-h-0 flex-1 overflow-y-auto px-4 pb-4 md:pt-4\",\n },\n variants: {\n snap: {\n peek: { root: \"h-24 md:h-auto\" },\n half: { root: \"h-1/2 md:h-auto\" },\n full: { root: \"h-[92%] md:h-auto\" },\n },\n },\n defaultVariants: { snap: \"peek\" },\n});\n\nexport type MapSheetSnap = \"peek\" | \"half\" | \"full\";\nexport const MAP_SHEET_SNAPS: readonly MapSheetSnap[] = [\"peek\", \"half\", \"full\"];\n\nexport type MapSheetProps = Omit<React.ComponentProps<\"section\">, \"children\"> & {\n /** What the sheet is, passed translated: its accessible name (\"Place details\"). */\n label: string;\n /** The content: an info card, a route card, a list. */\n children: React.ReactNode;\n /** The snap point, when controlled. */\n snap?: MapSheetSnap;\n /** The snap point at the start, when not controlled. Default \"peek\". */\n defaultSnap?: MapSheetSnap;\n /** Called with the new snap point (the handle: a press cycles, ArrowUp / ArrowDown step, Home / End jump). */\n onSnapChange?: (snap: MapSheetSnap) => void;\n /** The handle's name, translated (\"Resize the panel\"). */\n handleLabel: string;\n};\n\n/**\n * A NON-modal sheet over a map: the map stays alive and reachable behind it (no scrim, no focus trap, nothing made\n * inert). On a phone it rises from the bottom with three snap points; from the `md` breakpoint it is a card at the\n * side and the handle disappears. Place it in the map's positioned container.\n */\nexport function MapSheet({ label, children, snap, defaultSnap = \"peek\", onSnapChange, handleLabel, className, ...props }: MapSheetProps) {\n const [inner, setInner] = React.useState<MapSheetSnap>(defaultSnap);\n const current = snap ?? inner;\n const set = (next: MapSheetSnap) => {\n if (snap === undefined) setInner(next);\n onSnapChange?.(next);\n };\n const step = (by: number) => set(MAP_SHEET_SNAPS[Math.min(MAP_SHEET_SNAPS.length - 1, Math.max(0, MAP_SHEET_SNAPS.indexOf(current) + by))]!);\n const s = mapSheet({ snap: current });\n return (\n <section {...props} aria-label={label} data-snap={current} className={s.root({ className })}>\n <button\n type=\"button\"\n className={s.handle()}\n aria-label={handleLabel}\n aria-expanded={current !== \"peek\"}\n onClick={() => set(MAP_SHEET_SNAPS[(MAP_SHEET_SNAPS.indexOf(current) + 1) % MAP_SHEET_SNAPS.length]!)}\n onKeyDown={(e) => {\n const move = { ArrowUp: () => step(1), ArrowDown: () => step(-1), Home: () => set(\"peek\"), End: () => set(\"full\") }[e.key];\n if (!move) return;\n e.preventDefault();\n move();\n }}\n >\n <span className={s.grip()} aria-hidden />\n </button>\n <div className={s.body()}>{children}</div>\n </section>\n );\n}\n"],"mappings":";;;;;;AAEA,YAAY,WAAW;AAsDnB,SAcI,KAdJ;AAlDG,IAAM,WAAW,GAAG;AAAA,EACzB,OAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,MAAM,EAAE,MAAM,iBAAiB;AAAA,MAC/B,MAAM,EAAE,MAAM,kBAAkB;AAAA,MAChC,MAAM,EAAE,MAAM,oBAAoB;AAAA,IACpC;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,OAAO;AAClC,CAAC;AAGM,IAAM,kBAA2C,CAAC,QAAQ,QAAQ,MAAM;AAsBxE,SAAS,SAAS,EAAE,OAAO,UAAU,MAAM,cAAc,QAAQ,cAAc,aAAa,WAAW,GAAG,MAAM,GAAkB;AACvI,QAAM,CAAC,OAAO,QAAQ,IAAU,eAAuB,WAAW;AAClE,QAAM,UAAU,QAAQ;AACxB,QAAM,MAAM,CAAC,SAAuB;AAClC,QAAI,SAAS,OAAW,UAAS,IAAI;AACrC,mBAAe,IAAI;AAAA,EACrB;AACA,QAAM,OAAO,CAAC,OAAe,IAAI,gBAAgB,KAAK,IAAI,gBAAgB,SAAS,GAAG,KAAK,IAAI,GAAG,gBAAgB,QAAQ,OAAO,IAAI,EAAE,CAAC,CAAC,CAAE;AAC3I,QAAM,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AACpC,SACE,qBAAC,aAAS,GAAG,OAAO,cAAY,OAAO,aAAW,SAAS,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,GACxF;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,WAAW,EAAE,OAAO;AAAA,QACpB,cAAY;AAAA,QACZ,iBAAe,YAAY;AAAA,QAC3B,SAAS,MAAM,IAAI,iBAAiB,gBAAgB,QAAQ,OAAO,IAAI,KAAK,gBAAgB,MAAM,CAAE;AAAA,QACpG,WAAW,CAAC,MAAM;AAChB,gBAAM,OAAO,EAAE,SAAS,MAAM,KAAK,CAAC,GAAG,WAAW,MAAM,KAAK,EAAE,GAAG,MAAM,MAAM,IAAI,MAAM,GAAG,KAAK,MAAM,IAAI,MAAM,EAAE,EAAE,EAAE,GAAG;AACzH,cAAI,CAAC,KAAM;AACX,YAAE,eAAe;AACjB,eAAK;AAAA,QACP;AAAA,QAEA,8BAAC,UAAK,WAAW,EAAE,KAAK,GAAG,eAAW,MAAC;AAAA;AAAA,IACzC;AAAA,IACA,oBAAC,SAAI,WAAW,EAAE,KAAK,GAAI,UAAS;AAAA,KACtC;AAEJ;","names":[]}
|
package/dist/map.d.ts
CHANGED
|
@@ -56,8 +56,15 @@ declare function sliceLine(path: readonly LngLat[], fraction: number): GeoJSON.F
|
|
|
56
56
|
type MapBrand = keyof typeof brands;
|
|
57
57
|
/** A colour mixed into another (`#rrggbb` only): `t` = 0 gives `a`, 1 gives `b`. */
|
|
58
58
|
declare function mix(a: string, b: string, t: number): string;
|
|
59
|
-
/**
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The look of the map: `plain` (the product register) or `notebook` (the Cahier: ink lines on the paper in light, chalk on
|
|
61
|
+
* the slate in dark, the margin's red for the main roads).
|
|
62
|
+
*/
|
|
63
|
+
type MapVariant = "plain" | "notebook";
|
|
64
|
+
/** The scheme a map is asked for: `auto` follows the page (web) or the app (native). */
|
|
65
|
+
type MapScheme = "dark" | "light" | "auto";
|
|
66
|
+
/** The colours of the map in a scheme (and a brand, a variant): what the style, the markers, the clusters and the static map share. */
|
|
67
|
+
declare function mapPalette(scheme: "dark" | "light", brand?: MapBrand, variant?: MapVariant): {
|
|
61
68
|
land: string;
|
|
62
69
|
background: string;
|
|
63
70
|
water: string;
|
|
@@ -72,9 +79,18 @@ declare function mapPalette(scheme: "dark" | "light", brand?: MapBrand): {
|
|
|
72
79
|
halo: string;
|
|
73
80
|
accent: string;
|
|
74
81
|
onAccent: string;
|
|
82
|
+
cluster: {
|
|
83
|
+
fill: string;
|
|
84
|
+
stroke: string;
|
|
85
|
+
text: string;
|
|
86
|
+
};
|
|
87
|
+
point: {
|
|
88
|
+
fill: string;
|
|
89
|
+
stroke: string;
|
|
90
|
+
};
|
|
75
91
|
};
|
|
76
92
|
/** The basemap flavour of a palette: every role of Protomaps' layers filled from the tokens. */
|
|
77
|
-
declare function mapFlavor(scheme: "dark" | "light", brand?: MapBrand): Flavor;
|
|
93
|
+
declare function mapFlavor(scheme: "dark" | "light", brand?: MapBrand, variant?: MapVariant): Flavor;
|
|
78
94
|
/** A region of the basemap: its PMTiles file and the zoom up to which it has tiles. */
|
|
79
95
|
type MapRegion = {
|
|
80
96
|
url: string;
|
|
@@ -85,6 +101,8 @@ type MapStyleOptions = {
|
|
|
85
101
|
scheme: "dark" | "light";
|
|
86
102
|
/** The product whose accent the map carries (its markers, its water's tint). Default `krizaka`. */
|
|
87
103
|
brand?: MapBrand;
|
|
104
|
+
/** The look: `plain` (default), or `notebook` (the Cahier's paper and ink). */
|
|
105
|
+
variant?: MapVariant;
|
|
88
106
|
/** The language of the labels (`fr`, `en`): the place names in it where OpenStreetMap has them. Default `en`. */
|
|
89
107
|
lang?: string;
|
|
90
108
|
/** The low zooms of the whole world. Default: our world extract (zoom 0–6). */
|
|
@@ -96,21 +114,22 @@ type MapStyleOptions = {
|
|
|
96
114
|
};
|
|
97
115
|
/** The zoom where the detailed region takes over from the world. */
|
|
98
116
|
declare const REGION_FROM_ZOOM = 6.5;
|
|
117
|
+
type StyleLayer = {
|
|
118
|
+
id: string;
|
|
119
|
+
minzoom?: number;
|
|
120
|
+
maxzoom?: number;
|
|
121
|
+
[k: string]: unknown;
|
|
122
|
+
};
|
|
99
123
|
/**
|
|
100
124
|
* The MapLibre style of a Krizaka map (a `StyleSpecification`): the world's low zooms, then the detailed region,
|
|
101
125
|
* painted from the tokens. The `pmtiles://` sources need the PMTiles protocol (the web `Map` registers it; MapLibre
|
|
102
126
|
* Native reads it as it is).
|
|
103
127
|
*/
|
|
104
|
-
declare function mapStyle({ scheme, brand, lang, world, region, glyphs }: MapStyleOptions): {
|
|
128
|
+
declare function mapStyle({ scheme, brand, variant, lang, world, region, glyphs }: MapStyleOptions): {
|
|
105
129
|
version: 8;
|
|
106
130
|
glyphs: string;
|
|
107
131
|
sources: Record<string, unknown>;
|
|
108
|
-
layers:
|
|
109
|
-
[k: string]: unknown;
|
|
110
|
-
id: string;
|
|
111
|
-
minzoom?: number;
|
|
112
|
-
maxzoom?: number;
|
|
113
|
-
}[];
|
|
132
|
+
layers: StyleLayer[];
|
|
114
133
|
};
|
|
115
134
|
|
|
116
135
|
type MapLibre = typeof maplibre_gl;
|
|
@@ -192,12 +211,18 @@ type Registry = {
|
|
|
192
211
|
add: (id: string, text: string) => void;
|
|
193
212
|
remove: (id: string) => void;
|
|
194
213
|
};
|
|
214
|
+
type Look = {
|
|
215
|
+
scheme: "dark" | "light";
|
|
216
|
+
brand?: MapBrand;
|
|
217
|
+
variant?: MapVariant;
|
|
218
|
+
};
|
|
195
219
|
type Ctx = {
|
|
196
220
|
map: MapInstance | null;
|
|
197
221
|
lib: MapLibre | null;
|
|
198
222
|
ready: boolean;
|
|
199
223
|
reduce: boolean;
|
|
200
224
|
places: Registry;
|
|
225
|
+
look: Look;
|
|
201
226
|
};
|
|
202
227
|
/** The map a child is drawn on (`Marker`, `RadiusCircle`, `Cluster`…): the MapLibre instance once it is ready. */
|
|
203
228
|
declare function useMap(): Ctx;
|
|
@@ -230,8 +255,10 @@ type MapProps = {
|
|
|
230
255
|
zoom?: number;
|
|
231
256
|
/** The camera follows `center` and `zoom` when they change (flies, or jumps under reduced motion). */
|
|
232
257
|
controlled?: boolean;
|
|
233
|
-
/** The scheme
|
|
234
|
-
scheme?:
|
|
258
|
+
/** The scheme: `auto` (default) follows the page (`html.light`) as it changes; `dark` or `light` pins it. */
|
|
259
|
+
scheme?: MapScheme;
|
|
260
|
+
/** The look: `plain` (default), `notebook` (the Cahier: paper and ink, manila tags for clusters). */
|
|
261
|
+
variant?: MapVariant;
|
|
235
262
|
/** The product whose accent the map carries. Default `krizaka`. */
|
|
236
263
|
brand?: MapBrand;
|
|
237
264
|
/** The language of the labels (`fr`, `en`). Default `en`. */
|
|
@@ -261,7 +288,7 @@ type MapProps = {
|
|
|
261
288
|
className?: string;
|
|
262
289
|
};
|
|
263
290
|
/** A map: MapLibre over our Protomaps tiles, styled from the tokens, with its places as a list for screen readers. */
|
|
264
|
-
declare function MapRoot({ label, center, zoom, controlled, scheme: schemeProp, brand, lang, region, world, controls, interactive, fallback, onMoveEnd, onPress, children, labels: given, className, }: MapProps): React.JSX.Element;
|
|
291
|
+
declare function MapRoot({ label, center, zoom, controlled, scheme: schemeProp, variant, brand, lang, region, world, controls, interactive, fallback, onMoveEnd, onPress, children, labels: given, className, }: MapProps): React.JSX.Element;
|
|
265
292
|
type MarkerProps = {
|
|
266
293
|
/** Where it stands. */
|
|
267
294
|
position: LngLat;
|
|
@@ -510,4 +537,4 @@ type StaticMapProps = {
|
|
|
510
537
|
declare function StaticMap({ label, center, zoom, places, image, className }: StaticMapProps): React.JSX.Element;
|
|
511
538
|
|
|
512
539
|
export { Cluster, LocationPicker, MAP_ATTRIBUTION, MAP_GLYPHS, MAP_TILES, MapRoot as Map, Marker, Pulse, REGION_FROM_ZOOM, RadiusCircle, Route, StaticMap, UserPosition, circlePolygon, configureMaps, distanceMeters, formatDistance, locationPicker, locationPickerLabels, map, mapAssets, mapFlavor, mapLabels, mapPalette, mapStyle, mix, pathLength, pointAlong, project, setMapAssetsBase, sliceLine, staticMap, useMap };
|
|
513
|
-
export type { ClusterPoint, ClusterProps, LngLat, LocationPickerLabels, LocationPickerProps, MapBrand, MapLabels, MapProps, MapRegion, MapStyleOptions, MarkerProps, PulseProps, RadiusCircleProps, RouteProps, StaticMapPlace, StaticMapProps, UserPositionProps };
|
|
540
|
+
export type { ClusterPoint, ClusterProps, LngLat, LocationPickerLabels, LocationPickerProps, MapBrand, MapLabels, MapProps, MapRegion, MapScheme, MapStyleOptions, MapVariant, MarkerProps, PulseProps, RadiusCircleProps, RouteProps, StaticMapPlace, StaticMapProps, UserPositionProps };
|
package/dist/map.js
CHANGED
|
@@ -403,104 +403,77 @@ function mix(a, b, t) {
|
|
|
403
403
|
const [x, y] = [p(a), p(b)];
|
|
404
404
|
return `#${x.map((v, i) => Math.round(v + (y[i] - v) * t).toString(16).padStart(2, "0")).join("")}`;
|
|
405
405
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const dark = scheme === "dark";
|
|
406
|
+
var tint = (base2, dark) => (colour, d, l) => mix(base2, colour, dark ? d : l);
|
|
407
|
+
function plainPalette(t, dark) {
|
|
409
408
|
const land = dark ? t.surface1 : t.surface0;
|
|
409
|
+
const on = tint(land, dark);
|
|
410
|
+
const text = t.textPrimary;
|
|
410
411
|
return {
|
|
411
412
|
land,
|
|
412
413
|
background: dark ? t.surface0 : t.surface2,
|
|
413
|
-
water:
|
|
414
|
-
park:
|
|
415
|
-
road: dark ?
|
|
416
|
-
roadMajor:
|
|
417
|
-
casing:
|
|
418
|
-
building:
|
|
419
|
-
boundary:
|
|
414
|
+
water: on(t.accent, 0.18, 0.14),
|
|
415
|
+
park: on(t.success, 0.1, 0.12),
|
|
416
|
+
road: dark ? on(text, 0.12, 0) : "#ffffff",
|
|
417
|
+
roadMajor: on(text, 0.2, 0.06),
|
|
418
|
+
casing: on(text, 0.05, 0.12),
|
|
419
|
+
building: on(text, 0.06, 0.07),
|
|
420
|
+
boundary: on(text, 0.3, 0.3),
|
|
420
421
|
label: t.textSecondary,
|
|
421
|
-
labelStrong:
|
|
422
|
+
labelStrong: text,
|
|
422
423
|
halo: land,
|
|
423
424
|
accent: t.accent,
|
|
424
|
-
onAccent: t.onAccent
|
|
425
|
+
onAccent: t.onAccent,
|
|
426
|
+
// The clusters and the pins' ring: a disc of the accent in the product register.
|
|
427
|
+
cluster: { fill: t.accent, stroke: land, text: t.onAccent },
|
|
428
|
+
point: { fill: t.accent, stroke: land }
|
|
425
429
|
};
|
|
426
430
|
}
|
|
427
|
-
function
|
|
428
|
-
const
|
|
431
|
+
function notebookPalette(plain, t, dark) {
|
|
432
|
+
const paper = t.surface0;
|
|
433
|
+
const margin = t.paperRuleMargin;
|
|
434
|
+
const on = tint(paper, dark);
|
|
435
|
+
const ink = t.textPrimary;
|
|
436
|
+
return {
|
|
437
|
+
...plain,
|
|
438
|
+
land: paper,
|
|
439
|
+
background: paper,
|
|
440
|
+
water: on(t.accent, 0.26, 0.2),
|
|
441
|
+
park: on(t.paperTag, 0.7, 0.55),
|
|
442
|
+
road: on(ink, 0.32, 0.28),
|
|
443
|
+
roadMajor: on(margin, 0.75, 0.7),
|
|
444
|
+
casing: paper,
|
|
445
|
+
halo: paper,
|
|
446
|
+
// A cluster is a manila tag with its eyelet edge; a single point is the margin's red.
|
|
447
|
+
cluster: { fill: t.paperTag, stroke: t.paperTagEdge, text: t.paperTagInk },
|
|
448
|
+
point: { fill: margin, stroke: paper }
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function mapPalette(scheme, brand = "krizaka", variant = "plain") {
|
|
452
|
+
const t = { ...themes[scheme], ...brands[brand]?.[scheme] };
|
|
453
|
+
const dark = scheme === "dark";
|
|
454
|
+
const plain = plainPalette(t, dark);
|
|
455
|
+
if (variant === "notebook") return notebookPalette(plain, t, dark);
|
|
456
|
+
return plain;
|
|
457
|
+
}
|
|
458
|
+
var FLAVOR_ROLES = [
|
|
459
|
+
[/halo/, "halo"],
|
|
460
|
+
[/city_label/, "labelStrong"],
|
|
461
|
+
[/label/, "label"],
|
|
462
|
+
[/casing|railway/, "casing"],
|
|
463
|
+
[/major|highway/, "roadMajor"],
|
|
464
|
+
[/^(other|minor|link|bridges|tunnel)/, "road"],
|
|
465
|
+
[/park|wood|scrub|zoo/, "park"],
|
|
466
|
+
[/runway|buildings|pier/, "building"],
|
|
467
|
+
[/water/, "water"],
|
|
468
|
+
[/boundaries/, "boundary"],
|
|
469
|
+
[/background/, "background"]
|
|
470
|
+
];
|
|
471
|
+
function mapFlavor(scheme, brand, variant) {
|
|
472
|
+
const c = mapPalette(scheme, brand, variant);
|
|
429
473
|
const base2 = namedFlavor(scheme);
|
|
430
474
|
return {
|
|
431
475
|
...base2,
|
|
432
|
-
|
|
433
|
-
earth: c.land,
|
|
434
|
-
park_a: c.park,
|
|
435
|
-
park_b: c.park,
|
|
436
|
-
wood_a: c.park,
|
|
437
|
-
wood_b: c.park,
|
|
438
|
-
scrub_a: c.park,
|
|
439
|
-
scrub_b: c.park,
|
|
440
|
-
glacier: c.land,
|
|
441
|
-
sand: c.land,
|
|
442
|
-
beach: c.land,
|
|
443
|
-
zoo: c.park,
|
|
444
|
-
hospital: c.land,
|
|
445
|
-
industrial: c.land,
|
|
446
|
-
school: c.land,
|
|
447
|
-
military: c.land,
|
|
448
|
-
aerodrome: c.land,
|
|
449
|
-
pedestrian: c.land,
|
|
450
|
-
runway: c.building,
|
|
451
|
-
water: c.water,
|
|
452
|
-
buildings: c.building,
|
|
453
|
-
pier: c.building,
|
|
454
|
-
boundaries: c.boundary,
|
|
455
|
-
railway: c.casing,
|
|
456
|
-
other: c.road,
|
|
457
|
-
minor_service: c.road,
|
|
458
|
-
minor_a: c.road,
|
|
459
|
-
minor_b: c.road,
|
|
460
|
-
link: c.road,
|
|
461
|
-
major: c.roadMajor,
|
|
462
|
-
highway: c.roadMajor,
|
|
463
|
-
bridges_other: c.road,
|
|
464
|
-
bridges_minor: c.road,
|
|
465
|
-
bridges_link: c.road,
|
|
466
|
-
bridges_major: c.roadMajor,
|
|
467
|
-
bridges_highway: c.roadMajor,
|
|
468
|
-
tunnel_other: c.road,
|
|
469
|
-
tunnel_minor: c.road,
|
|
470
|
-
tunnel_link: c.road,
|
|
471
|
-
tunnel_major: c.roadMajor,
|
|
472
|
-
tunnel_highway: c.roadMajor,
|
|
473
|
-
minor_service_casing: c.casing,
|
|
474
|
-
minor_casing: c.casing,
|
|
475
|
-
link_casing: c.casing,
|
|
476
|
-
major_casing_late: c.casing,
|
|
477
|
-
major_casing_early: c.casing,
|
|
478
|
-
highway_casing_late: c.casing,
|
|
479
|
-
highway_casing_early: c.casing,
|
|
480
|
-
bridges_other_casing: c.casing,
|
|
481
|
-
bridges_minor_casing: c.casing,
|
|
482
|
-
bridges_link_casing: c.casing,
|
|
483
|
-
bridges_major_casing: c.casing,
|
|
484
|
-
bridges_highway_casing: c.casing,
|
|
485
|
-
tunnel_other_casing: c.casing,
|
|
486
|
-
tunnel_minor_casing: c.casing,
|
|
487
|
-
tunnel_link_casing: c.casing,
|
|
488
|
-
tunnel_major_casing: c.casing,
|
|
489
|
-
tunnel_highway_casing: c.casing,
|
|
490
|
-
roads_label_minor: c.label,
|
|
491
|
-
roads_label_minor_halo: c.halo,
|
|
492
|
-
roads_label_major: c.label,
|
|
493
|
-
roads_label_major_halo: c.halo,
|
|
494
|
-
ocean_label: c.label,
|
|
495
|
-
subplace_label: c.label,
|
|
496
|
-
subplace_label_halo: c.halo,
|
|
497
|
-
city_label: c.labelStrong,
|
|
498
|
-
city_label_halo: c.halo,
|
|
499
|
-
state_label: c.label,
|
|
500
|
-
state_label_halo: c.halo,
|
|
501
|
-
country_label: c.label,
|
|
502
|
-
address_label: c.label,
|
|
503
|
-
address_label_halo: c.halo,
|
|
476
|
+
...Object.fromEntries(Object.keys(base2).map((role) => [role, c[FLAVOR_ROLES.find(([re]) => re.test(role))?.[1] ?? "land"]])),
|
|
504
477
|
regular: "Noto Sans Regular",
|
|
505
478
|
bold: "Noto Sans Medium",
|
|
506
479
|
italic: "Noto Sans Italic",
|
|
@@ -510,32 +483,32 @@ function mapFlavor(scheme, brand) {
|
|
|
510
483
|
};
|
|
511
484
|
}
|
|
512
485
|
var REGION_FROM_ZOOM = 6.5;
|
|
513
|
-
function
|
|
514
|
-
|
|
486
|
+
function worldLayers(layerList, hasRegion) {
|
|
487
|
+
return layerList.map((l) => {
|
|
488
|
+
if (l.id === "background") return l;
|
|
489
|
+
const maxzoom = hasRegion ? Math.min(l.maxzoom ?? 24, REGION_FROM_ZOOM) : l.maxzoom;
|
|
490
|
+
return { ...l, id: `world-${l.id}`, ...maxzoom === void 0 ? {} : { maxzoom } };
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
function regionLayers(layerList, hasWorld) {
|
|
494
|
+
return layerList.filter((l) => l.id !== "background" || !hasWorld).map((l) => l.id === "background" ? l : { ...l, id: `region-${l.id}`, minzoom: hasWorld ? Math.max(l.minzoom ?? 0, REGION_FROM_ZOOM) : l.minzoom });
|
|
495
|
+
}
|
|
496
|
+
function mapStyle({ scheme, brand, variant, lang = "en", world = { url: mapAssets().tiles.world, maxzoom: 6 }, region = { url: mapAssets().tiles.quebec, maxzoom: 14 }, glyphs = mapAssets().glyphs }) {
|
|
497
|
+
const flavor = mapFlavor(scheme, brand, variant);
|
|
515
498
|
const attribution = `<a href="${MAP_ATTRIBUTION.protomapsUrl}">${MAP_ATTRIBUTION.protomaps}</a> \xB7 <a href="${MAP_ATTRIBUTION.osmUrl}">${MAP_ATTRIBUTION.osm}</a>`;
|
|
516
499
|
const sources = {};
|
|
517
500
|
const all = [];
|
|
518
501
|
if (world) {
|
|
519
502
|
sources.world = { type: "vector", url: `pmtiles://${world.url}`, attribution };
|
|
520
|
-
|
|
521
|
-
if (l.id === "background") all.push(l);
|
|
522
|
-
else all.push({ ...l, id: `world-${l.id}`, maxzoom: region ? Math.min(l.maxzoom ?? 24, REGION_FROM_ZOOM) : l.maxzoom });
|
|
523
|
-
}
|
|
503
|
+
all.push(...worldLayers(layers("world", flavor, { lang }), Boolean(region)));
|
|
524
504
|
}
|
|
525
505
|
if (region) {
|
|
526
506
|
sources.region = { type: "vector", url: `pmtiles://${region.url}`, attribution };
|
|
527
|
-
|
|
528
|
-
if (l.id === "background") {
|
|
529
|
-
if (!world) all.push(l);
|
|
530
|
-
continue;
|
|
531
|
-
}
|
|
532
|
-
all.push({ ...l, id: `region-${l.id}`, minzoom: world ? Math.max(l.minzoom ?? 0, REGION_FROM_ZOOM) : l.minzoom });
|
|
533
|
-
}
|
|
507
|
+
all.push(...regionLayers(layers("region", flavor, { lang }), Boolean(world)));
|
|
534
508
|
}
|
|
535
509
|
const drawn = all.filter((l) => !l.layout?.["icon-image"]);
|
|
536
|
-
return { version: 8, glyphs, sources, layers: drawn
|
|
510
|
+
return { version: 8, glyphs, sources, layers: drawn };
|
|
537
511
|
}
|
|
538
|
-
var withoutKey = (o, key) => Object.fromEntries(Object.entries(o).filter(([k]) => k !== key));
|
|
539
512
|
|
|
540
513
|
// src/map/map.tsx
|
|
541
514
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -599,7 +572,8 @@ function MapRoot({
|
|
|
599
572
|
center,
|
|
600
573
|
zoom = 12,
|
|
601
574
|
controlled,
|
|
602
|
-
scheme: schemeProp,
|
|
575
|
+
scheme: schemeProp = "auto",
|
|
576
|
+
variant,
|
|
603
577
|
brand,
|
|
604
578
|
lang,
|
|
605
579
|
region,
|
|
@@ -616,7 +590,7 @@ function MapRoot({
|
|
|
616
590
|
const labels = { ...mapLabels, ...given };
|
|
617
591
|
const s = map();
|
|
618
592
|
const pageScheme = usePageScheme();
|
|
619
|
-
const scheme = schemeProp
|
|
593
|
+
const scheme = schemeProp === "auto" ? pageScheme : schemeProp;
|
|
620
594
|
const reduce = usePrefersReducedMotion();
|
|
621
595
|
const host = React2.useRef(null);
|
|
622
596
|
const [instance, setInstance] = React2.useState(null);
|
|
@@ -638,7 +612,7 @@ function MapRoot({
|
|
|
638
612
|
React2.useEffect(() => {
|
|
639
613
|
latest.current = { onMoveEnd, onPress };
|
|
640
614
|
});
|
|
641
|
-
const styleOf = React2.useCallback((sc) => mapStyle({ scheme: sc, brand, lang, ...region !== void 0 ? { region } : {}, ...world !== void 0 ? { world } : {} }), [brand, lang, region, world]);
|
|
615
|
+
const styleOf = React2.useCallback((sc) => mapStyle({ scheme: sc, brand, variant, lang, ...region !== void 0 ? { region } : {}, ...world !== void 0 ? { world } : {} }), [brand, variant, lang, region, world]);
|
|
642
616
|
const wanted = React2.useRef({ scheme, styleOf });
|
|
643
617
|
React2.useEffect(() => {
|
|
644
618
|
wanted.current = { scheme, styleOf };
|
|
@@ -697,7 +671,7 @@ function MapRoot({
|
|
|
697
671
|
else instance.flyTo({ ...view, speed: 1.4 });
|
|
698
672
|
}, [instance, controlled, center[0], center[1], zoom, reduce]);
|
|
699
673
|
const zoomBy = (by) => instance && (reduce ? instance.setZoom(instance.getZoom() + by) : instance.zoomTo(instance.getZoom() + by, { duration: 250 }));
|
|
700
|
-
const ctx = React2.useMemo(() => ({ map: instance, lib, ready, reduce, places: registry }), [instance, lib, ready, reduce, registry]);
|
|
674
|
+
const ctx = React2.useMemo(() => ({ map: instance, lib, ready, reduce, places: registry, look: { scheme, brand, variant } }), [instance, lib, ready, reduce, registry, scheme, brand, variant]);
|
|
701
675
|
const listed = Object.entries(places);
|
|
702
676
|
return /* @__PURE__ */ jsx(MapContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
|
|
703
677
|
"section",
|
|
@@ -893,7 +867,7 @@ function Route({ path, label, draw = true, duration = 1400, courier, tripDuratio
|
|
|
893
867
|
return null;
|
|
894
868
|
}
|
|
895
869
|
function useGeoLayer(id, data, layers2, source = {}) {
|
|
896
|
-
const { map: m, ready } = useMap();
|
|
870
|
+
const { map: m, ready, look: { scheme, brand, variant } } = useMap();
|
|
897
871
|
const dataRef = React2.useRef(data);
|
|
898
872
|
React2.useEffect(() => {
|
|
899
873
|
dataRef.current = data;
|
|
@@ -904,9 +878,8 @@ function useGeoLayer(id, data, layers2, source = {}) {
|
|
|
904
878
|
if (!m || !ready) return;
|
|
905
879
|
const add = () => {
|
|
906
880
|
if (m.getSource(id)) return;
|
|
907
|
-
const scheme = document.documentElement.classList.contains("light") ? "light" : "dark";
|
|
908
881
|
m.addSource(id, { type: "geojson", data: dataRef.current, ...source });
|
|
909
|
-
for (const layer of layers2(mapPalette(scheme))) m.addLayer(layer);
|
|
882
|
+
for (const layer of layers2(mapPalette(scheme, brand, variant))) m.addLayer(layer);
|
|
910
883
|
};
|
|
911
884
|
add();
|
|
912
885
|
m.on("styledata", add);
|
|
@@ -916,7 +889,7 @@ function useGeoLayer(id, data, layers2, source = {}) {
|
|
|
916
889
|
for (const layer of m.getStyle().layers.filter((l) => "source" in l && l.source === id)) m.removeLayer(layer.id);
|
|
917
890
|
if (m.getSource(id)) m.removeSource(id);
|
|
918
891
|
};
|
|
919
|
-
}, [m, ready, id]);
|
|
892
|
+
}, [m, ready, id, scheme, brand, variant]);
|
|
920
893
|
}
|
|
921
894
|
function RadiusCircle({ center, radius, tone = "accent" }) {
|
|
922
895
|
const id = `kz-circle-${React2.useId().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
@@ -942,9 +915,9 @@ function Cluster({ points, onPointPress, radius = 48 }) {
|
|
|
942
915
|
id,
|
|
943
916
|
data,
|
|
944
917
|
(c) => [
|
|
945
|
-
{ id: `${id}-groups`, type: "circle", source: id, filter: ["has", "point_count"], paint: { "circle-color": c.
|
|
946
|
-
{ id: `${id}-count`, type: "symbol", source: id, filter: ["has", "point_count"], layout: { "text-field": ["get", "point_count_abbreviated"], "text-font": ["Noto Sans Medium"], "text-size": 13 }, paint: { "text-color": c.
|
|
947
|
-
{ id: `${id}-points`, type: "circle", source: id, filter: ["!", ["has", "point_count"]], paint: { "circle-color": c.
|
|
918
|
+
{ id: `${id}-groups`, type: "circle", source: id, filter: ["has", "point_count"], paint: { "circle-color": c.cluster.fill, "circle-opacity": 0.95, "circle-radius": ["step", ["get", "point_count"], 16, 10, 20, 50, 26], "circle-stroke-width": 3, "circle-stroke-color": c.cluster.stroke } },
|
|
919
|
+
{ id: `${id}-count`, type: "symbol", source: id, filter: ["has", "point_count"], layout: { "text-field": ["get", "point_count_abbreviated"], "text-font": ["Noto Sans Medium"], "text-size": 13 }, paint: { "text-color": c.cluster.text } },
|
|
920
|
+
{ id: `${id}-points`, type: "circle", source: id, filter: ["!", ["has", "point_count"]], paint: { "circle-color": c.point.fill, "circle-radius": 7, "circle-stroke-width": 2.5, "circle-stroke-color": c.point.stroke } }
|
|
948
921
|
],
|
|
949
922
|
{ cluster: true, clusterRadius: radius, clusterMaxZoom: 15 }
|
|
950
923
|
);
|