@krizaka/ui 3.76.1 → 3.78.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.
Files changed (47) hide show
  1. package/dist/blocks.css +14 -0
  2. package/dist/chunk-NM2DEHFZ.js +25 -0
  3. package/dist/chunk-NM2DEHFZ.js.map +1 -0
  4. package/dist/document-viewer.d.ts +23 -6
  5. package/dist/document-viewer.js +21 -5
  6. package/dist/document-viewer.js.map +1 -1
  7. package/dist/filter-bar.d.ts +3 -3
  8. package/dist/map/cards.d.ts +145 -0
  9. package/dist/map/cards.js +74 -0
  10. package/dist/map/cards.js.map +1 -0
  11. package/dist/map/pin.d.ts +57 -0
  12. package/dist/map/pin.js +53 -0
  13. package/dist/map/pin.js.map +1 -0
  14. package/dist/map/sheet.d.ts +80 -0
  15. package/dist/map/sheet.js +61 -0
  16. package/dist/map/sheet.js.map +1 -0
  17. package/dist/map.d.ts +41 -14
  18. package/dist/map.js +85 -112
  19. package/dist/map.js.map +1 -1
  20. package/dist/native/map.d.ts +29 -10
  21. package/dist/native/map.js +81 -107
  22. package/dist/native/map.js.map +1 -1
  23. package/dist/virtual.d.ts +3 -3
  24. package/dist/wall.d.ts +10 -5
  25. package/dist/wall.js +10 -4
  26. package/dist/wall.js.map +1 -1
  27. package/package.json +51 -6
  28. package/registry/app-frame.json +1 -1
  29. package/registry/document-viewer.json +9 -8
  30. package/registry/examples/document-viewer/highlights.js +2 -1
  31. package/registry/examples/document-viewer/highlights.tsx +3 -0
  32. package/registry/examples/map/pins.d.ts +4 -0
  33. package/registry/examples/map/pins.js +20 -0
  34. package/registry/examples/map/pins.tsx +27 -0
  35. package/registry/examples/map/place-sheet.d.ts +4 -0
  36. package/registry/examples/map/place-sheet.js +34 -0
  37. package/registry/examples/map/place-sheet.tsx +35 -0
  38. package/registry/examples/wall/tidy.d.ts +4 -0
  39. package/registry/examples/wall/tidy.js +27 -0
  40. package/registry/examples/wall/tidy.tsx +19 -0
  41. package/registry/index.json +9 -9
  42. package/registry/map.json +81 -13
  43. package/registry/nav-bar.json +1 -1
  44. package/registry/rail-nav.json +1 -1
  45. package/registry/shop.json +1 -1
  46. package/registry/site-footer.json +1 -1
  47. package/registry/wall.json +24 -2
@@ -14,8 +14,13 @@ declare function formatDistance(meters: number, locale: string): string;
14
14
 
15
15
  /** A product of the family: its accent paints the map. */
16
16
  type MapBrand = keyof typeof brands;
17
- /** The colours of the map in a scheme (and a brand): what the style, the markers and the static map share. */
18
- declare function mapPalette(scheme: "dark" | "light", brand?: MapBrand): {
17
+ /**
18
+ * The look of the map: `plain` (the product register) or `notebook` (the Cahier: ink lines on the paper in light, chalk on
19
+ * the slate in dark, the margin's red for the main roads).
20
+ */
21
+ type MapVariant = "plain" | "notebook";
22
+ /** 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. */
23
+ declare function mapPalette(scheme: "dark" | "light", brand?: MapBrand, variant?: MapVariant): {
19
24
  land: string;
20
25
  background: string;
21
26
  water: string;
@@ -30,6 +35,15 @@ declare function mapPalette(scheme: "dark" | "light", brand?: MapBrand): {
30
35
  halo: string;
31
36
  accent: string;
32
37
  onAccent: string;
38
+ cluster: {
39
+ fill: string;
40
+ stroke: string;
41
+ text: string;
42
+ };
43
+ point: {
44
+ fill: string;
45
+ stroke: string;
46
+ };
33
47
  };
34
48
  /** A region of the basemap: its PMTiles file and the zoom up to which it has tiles. */
35
49
  type MapRegion = {
@@ -41,6 +55,8 @@ type MapStyleOptions = {
41
55
  scheme: "dark" | "light";
42
56
  /** The product whose accent the map carries (its markers, its water's tint). Default `krizaka`. */
43
57
  brand?: MapBrand;
58
+ /** The look: `plain` (default), or `notebook` (the Cahier's paper and ink). */
59
+ variant?: MapVariant;
44
60
  /** The language of the labels (`fr`, `en`): the place names in it where OpenStreetMap has them. Default `en`. */
45
61
  lang?: string;
46
62
  /** The low zooms of the whole world. Default: our world extract (zoom 0–6). */
@@ -50,21 +66,22 @@ type MapStyleOptions = {
50
66
  /** The glyphs' URL template. Default: our Noto Sans on the CDN. */
51
67
  glyphs?: string;
52
68
  };
69
+ type StyleLayer = {
70
+ id: string;
71
+ minzoom?: number;
72
+ maxzoom?: number;
73
+ [k: string]: unknown;
74
+ };
53
75
  /**
54
76
  * The MapLibre style of a Krizaka map (a `StyleSpecification`): the world's low zooms, then the detailed region,
55
77
  * painted from the tokens. The `pmtiles://` sources need the PMTiles protocol (the web `Map` registers it; MapLibre
56
78
  * Native reads it as it is).
57
79
  */
58
- declare function mapStyle({ scheme, brand, lang, world, region, glyphs }: MapStyleOptions): {
80
+ declare function mapStyle({ scheme, brand, variant, lang, world, region, glyphs }: MapStyleOptions): {
59
81
  version: 8;
60
82
  glyphs: string;
61
83
  sources: Record<string, unknown>;
62
- layers: {
63
- [k: string]: unknown;
64
- id: string;
65
- minzoom?: number;
66
- maxzoom?: number;
67
- }[];
84
+ layers: StyleLayer[];
68
85
  };
69
86
 
70
87
  /** The basemap extracts: OpenStreetMap data built by Protomaps (ODbL). `world` up to zoom 6, `quebec` (Montréal–Québec) up to 14. */
@@ -89,6 +106,8 @@ type MapProps = {
89
106
  center: LngLat;
90
107
  /** The zoom (0 the world, 12 a city, 16 a street). Default 12. */
91
108
  zoom?: number;
109
+ /** The look: `plain` (default), or `notebook` (the Cahier). The scheme is the app's (`auto`). */
110
+ variant?: MapVariant;
92
111
  /** The product whose accent the map carries. Default `krizaka`. */
93
112
  brand?: BrandId;
94
113
  /** The language of the labels (`fr`, `en`). Default `en`. */
@@ -112,7 +131,7 @@ type MapProps = {
112
131
  style?: StyleProp<ViewStyle>;
113
132
  };
114
133
  /** A map: MapLibre Native over our Protomaps tiles, styled from the tokens in the app's scheme; its places in its name. */
115
- declare function NativeMap({ label, center, zoom, brand, lang, region, world, interactive, onMoveEnd, onPress, children, style }: MapProps): React.JSX.Element;
134
+ declare function NativeMap({ label, center, zoom, brand, variant, lang, region, world, interactive, onMoveEnd, onPress, children, style }: Readonly<MapProps>): React.JSX.Element;
116
135
  type MarkerProps = {
117
136
  /** Where it stands. */
118
137
  position: LngLat;
@@ -320,104 +320,77 @@ function mix(a, b, t) {
320
320
  const [x, y] = [p(a), p(b)];
321
321
  return `#${x.map((v, i) => Math.round(v + (y[i] - v) * t).toString(16).padStart(2, "0")).join("")}`;
322
322
  }
323
- function mapPalette(scheme, brand = "krizaka") {
324
- const t = { ...themes[scheme], ...brands[brand]?.[scheme] };
325
- const dark = scheme === "dark";
323
+ var tint = (base2, dark) => (colour, d, l) => mix(base2, colour, dark ? d : l);
324
+ function plainPalette(t, dark) {
326
325
  const land = dark ? t.surface1 : t.surface0;
326
+ const on = tint(land, dark);
327
+ const text = t.textPrimary;
327
328
  return {
328
329
  land,
329
330
  background: dark ? t.surface0 : t.surface2,
330
- water: mix(land, t.accent, dark ? 0.18 : 0.14),
331
- park: mix(land, t.success, dark ? 0.1 : 0.12),
332
- road: dark ? mix(land, t.textPrimary, 0.12) : "#ffffff",
333
- roadMajor: dark ? mix(land, t.textPrimary, 0.2) : mix(land, t.textPrimary, 0.06),
334
- casing: mix(land, t.textPrimary, dark ? 0.05 : 0.12),
335
- building: mix(land, t.textPrimary, dark ? 0.06 : 0.07),
336
- boundary: mix(land, t.textPrimary, 0.3),
331
+ water: on(t.accent, 0.18, 0.14),
332
+ park: on(t.success, 0.1, 0.12),
333
+ road: dark ? on(text, 0.12, 0) : "#ffffff",
334
+ roadMajor: on(text, 0.2, 0.06),
335
+ casing: on(text, 0.05, 0.12),
336
+ building: on(text, 0.06, 0.07),
337
+ boundary: on(text, 0.3, 0.3),
337
338
  label: t.textSecondary,
338
- labelStrong: t.textPrimary,
339
+ labelStrong: text,
339
340
  halo: land,
340
341
  accent: t.accent,
341
- onAccent: t.onAccent
342
+ onAccent: t.onAccent,
343
+ // The clusters and the pins' ring: a disc of the accent in the product register.
344
+ cluster: { fill: t.accent, stroke: land, text: t.onAccent },
345
+ point: { fill: t.accent, stroke: land }
342
346
  };
343
347
  }
344
- function mapFlavor(scheme, brand) {
345
- const c = mapPalette(scheme, brand);
348
+ function notebookPalette(plain, t, dark) {
349
+ const paper = t.surface0;
350
+ const margin = t.paperRuleMargin;
351
+ const on = tint(paper, dark);
352
+ const ink = t.textPrimary;
353
+ return {
354
+ ...plain,
355
+ land: paper,
356
+ background: paper,
357
+ water: on(t.accent, 0.26, 0.2),
358
+ park: on(t.paperTag, 0.7, 0.55),
359
+ road: on(ink, 0.32, 0.28),
360
+ roadMajor: on(margin, 0.75, 0.7),
361
+ casing: paper,
362
+ halo: paper,
363
+ // A cluster is a manila tag with its eyelet edge; a single point is the margin's red.
364
+ cluster: { fill: t.paperTag, stroke: t.paperTagEdge, text: t.paperTagInk },
365
+ point: { fill: margin, stroke: paper }
366
+ };
367
+ }
368
+ function mapPalette(scheme, brand = "krizaka", variant = "plain") {
369
+ const t = { ...themes[scheme], ...brands[brand]?.[scheme] };
370
+ const dark = scheme === "dark";
371
+ const plain = plainPalette(t, dark);
372
+ if (variant === "notebook") return notebookPalette(plain, t, dark);
373
+ return plain;
374
+ }
375
+ var FLAVOR_ROLES = [
376
+ [/halo/, "halo"],
377
+ [/city_label/, "labelStrong"],
378
+ [/label/, "label"],
379
+ [/casing|railway/, "casing"],
380
+ [/major|highway/, "roadMajor"],
381
+ [/^(other|minor|link|bridges|tunnel)/, "road"],
382
+ [/park|wood|scrub|zoo/, "park"],
383
+ [/runway|buildings|pier/, "building"],
384
+ [/water/, "water"],
385
+ [/boundaries/, "boundary"],
386
+ [/background/, "background"]
387
+ ];
388
+ function mapFlavor(scheme, brand, variant) {
389
+ const c = mapPalette(scheme, brand, variant);
346
390
  const base2 = namedFlavor(scheme);
347
391
  return {
348
392
  ...base2,
349
- background: c.background,
350
- earth: c.land,
351
- park_a: c.park,
352
- park_b: c.park,
353
- wood_a: c.park,
354
- wood_b: c.park,
355
- scrub_a: c.park,
356
- scrub_b: c.park,
357
- glacier: c.land,
358
- sand: c.land,
359
- beach: c.land,
360
- zoo: c.park,
361
- hospital: c.land,
362
- industrial: c.land,
363
- school: c.land,
364
- military: c.land,
365
- aerodrome: c.land,
366
- pedestrian: c.land,
367
- runway: c.building,
368
- water: c.water,
369
- buildings: c.building,
370
- pier: c.building,
371
- boundaries: c.boundary,
372
- railway: c.casing,
373
- other: c.road,
374
- minor_service: c.road,
375
- minor_a: c.road,
376
- minor_b: c.road,
377
- link: c.road,
378
- major: c.roadMajor,
379
- highway: c.roadMajor,
380
- bridges_other: c.road,
381
- bridges_minor: c.road,
382
- bridges_link: c.road,
383
- bridges_major: c.roadMajor,
384
- bridges_highway: c.roadMajor,
385
- tunnel_other: c.road,
386
- tunnel_minor: c.road,
387
- tunnel_link: c.road,
388
- tunnel_major: c.roadMajor,
389
- tunnel_highway: c.roadMajor,
390
- minor_service_casing: c.casing,
391
- minor_casing: c.casing,
392
- link_casing: c.casing,
393
- major_casing_late: c.casing,
394
- major_casing_early: c.casing,
395
- highway_casing_late: c.casing,
396
- highway_casing_early: c.casing,
397
- bridges_other_casing: c.casing,
398
- bridges_minor_casing: c.casing,
399
- bridges_link_casing: c.casing,
400
- bridges_major_casing: c.casing,
401
- bridges_highway_casing: c.casing,
402
- tunnel_other_casing: c.casing,
403
- tunnel_minor_casing: c.casing,
404
- tunnel_link_casing: c.casing,
405
- tunnel_major_casing: c.casing,
406
- tunnel_highway_casing: c.casing,
407
- roads_label_minor: c.label,
408
- roads_label_minor_halo: c.halo,
409
- roads_label_major: c.label,
410
- roads_label_major_halo: c.halo,
411
- ocean_label: c.label,
412
- subplace_label: c.label,
413
- subplace_label_halo: c.halo,
414
- city_label: c.labelStrong,
415
- city_label_halo: c.halo,
416
- state_label: c.label,
417
- state_label_halo: c.halo,
418
- country_label: c.label,
419
- address_label: c.label,
420
- address_label_halo: c.halo,
393
+ ...Object.fromEntries(Object.keys(base2).map((role) => [role, c[FLAVOR_ROLES.find(([re]) => re.test(role))?.[1] ?? "land"]])),
421
394
  regular: "Noto Sans Regular",
422
395
  bold: "Noto Sans Medium",
423
396
  italic: "Noto Sans Italic",
@@ -427,32 +400,32 @@ function mapFlavor(scheme, brand) {
427
400
  };
428
401
  }
429
402
  var REGION_FROM_ZOOM = 6.5;
430
- function mapStyle({ scheme, brand, lang = "en", world = { url: mapAssets().tiles.world, maxzoom: 6 }, region = { url: mapAssets().tiles.quebec, maxzoom: 14 }, glyphs = mapAssets().glyphs }) {
431
- const flavor = mapFlavor(scheme, brand);
403
+ function worldLayers(layerList, hasRegion) {
404
+ return layerList.map((l) => {
405
+ if (l.id === "background") return l;
406
+ const maxzoom = hasRegion ? Math.min(l.maxzoom ?? 24, REGION_FROM_ZOOM) : l.maxzoom;
407
+ return { ...l, id: `world-${l.id}`, ...maxzoom === void 0 ? {} : { maxzoom } };
408
+ });
409
+ }
410
+ function regionLayers(layerList, hasWorld) {
411
+ 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 });
412
+ }
413
+ function mapStyle({ scheme, brand, variant, lang = "en", world = { url: mapAssets().tiles.world, maxzoom: 6 }, region = { url: mapAssets().tiles.quebec, maxzoom: 14 }, glyphs = mapAssets().glyphs }) {
414
+ const flavor = mapFlavor(scheme, brand, variant);
432
415
  const attribution = `<a href="${MAP_ATTRIBUTION.protomapsUrl}">${MAP_ATTRIBUTION.protomaps}</a> \xB7 <a href="${MAP_ATTRIBUTION.osmUrl}">${MAP_ATTRIBUTION.osm}</a>`;
433
416
  const sources = {};
434
417
  const all = [];
435
418
  if (world) {
436
419
  sources.world = { type: "vector", url: `pmtiles://${world.url}`, attribution };
437
- for (const l of layers("world", flavor, { lang })) {
438
- if (l.id === "background") all.push(l);
439
- else all.push({ ...l, id: `world-${l.id}`, maxzoom: region ? Math.min(l.maxzoom ?? 24, REGION_FROM_ZOOM) : l.maxzoom });
440
- }
420
+ all.push(...worldLayers(layers("world", flavor, { lang }), Boolean(region)));
441
421
  }
442
422
  if (region) {
443
423
  sources.region = { type: "vector", url: `pmtiles://${region.url}`, attribution };
444
- for (const l of layers("region", flavor, { lang })) {
445
- if (l.id === "background") {
446
- if (!world) all.push(l);
447
- continue;
448
- }
449
- all.push({ ...l, id: `region-${l.id}`, minzoom: world ? Math.max(l.minzoom ?? 0, REGION_FROM_ZOOM) : l.minzoom });
450
- }
424
+ all.push(...regionLayers(layers("region", flavor, { lang }), Boolean(world)));
451
425
  }
452
426
  const drawn = all.filter((l) => !l.layout?.["icon-image"]);
453
- return { version: 8, glyphs, sources, layers: drawn.map((l) => l.maxzoom === void 0 ? withoutKey(l, "maxzoom") : l) };
427
+ return { version: 8, glyphs, sources, layers: drawn };
454
428
  }
455
- var withoutKey = (o, key) => Object.fromEntries(Object.entries(o).filter(([k]) => k !== key));
456
429
 
457
430
  // src/native/map.tsx
458
431
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -462,7 +435,7 @@ var useMapContext = () => {
462
435
  if (!ctx) throw new Error("inside a <Map> only");
463
436
  return ctx;
464
437
  };
465
- function NativeMap({ label, center, zoom = 12, brand, lang, region, world, interactive = true, onMoveEnd, onPress, children, style }) {
438
+ function NativeMap({ label, center, zoom = 12, brand, variant, lang, region, world, interactive = true, onMoveEnd, onPress, children, style }) {
466
439
  const { scheme, theme, radius, motion } = useTheme();
467
440
  const reduce = motion.duration.base === 0;
468
441
  const camera = React.useRef(null);
@@ -477,8 +450,8 @@ function NativeMap({ label, center, zoom = 12, brand, lang, region, world, inter
477
450
  }),
478
451
  []
479
452
  );
480
- const styleJson = React.useMemo(() => mapStyle({ scheme, brand, lang, ...region !== void 0 ? { region } : {}, ...world !== void 0 ? { world } : {} }), [scheme, brand, lang, region, world]);
481
- const palette = React.useMemo(() => mapPalette(scheme, brand), [scheme, brand]);
453
+ const styleJson = React.useMemo(() => mapStyle({ scheme, brand, variant, lang, ...region !== void 0 ? { region } : {}, ...world !== void 0 ? { world } : {} }), [scheme, brand, variant, lang, region, world]);
454
+ const palette = React.useMemo(() => mapPalette(scheme, brand, variant), [scheme, brand, variant]);
482
455
  const listed = Object.values(places);
483
456
  const ctx = React.useMemo(() => ({ palette, reduce, places: registry }), [palette, reduce, registry]);
484
457
  return /* @__PURE__ */ jsx(MapContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(View, { style: [styles.root, { borderRadius: radius.xl, borderColor: theme.borderDefault, backgroundColor: theme.surface2 }, style], children: [
@@ -584,6 +557,7 @@ function Cluster({ points, onPointPress, radius = 48 }) {
584
557
  () => ({ type: "FeatureCollection", features: points.map((p) => ({ type: "Feature", properties: { id: p.id, label: p.label }, geometry: { type: "Point", coordinates: [...p.position] } })) }),
585
558
  [points]
586
559
  );
560
+ const { cluster: group, point: dot } = palette;
587
561
  return /* @__PURE__ */ jsxs(
588
562
  GeoJSONSource,
589
563
  {
@@ -599,9 +573,9 @@ function Cluster({ points, onPointPress, radius = 48 }) {
599
573
  if (point) onPointPress?.(point);
600
574
  },
601
575
  children: [
602
- /* @__PURE__ */ jsx(Layer, { type: "circle", id: `${id}-groups`, filter: ["has", "point_count"], paint: { "circle-color": palette.accent, "circle-radius": ["step", ["get", "point_count"], 16, 10, 20, 50, 26], "circle-stroke-width": 3, "circle-stroke-color": palette.halo } }),
603
- /* @__PURE__ */ jsx(Layer, { type: "symbol", id: `${id}-count`, filter: ["has", "point_count"], layout: { "text-field": ["get", "point_count_abbreviated"], "text-font": ["Noto Sans Medium"], "text-size": 13 }, paint: { "text-color": palette.onAccent } }),
604
- /* @__PURE__ */ jsx(Layer, { type: "circle", id: `${id}-points`, filter: ["!", ["has", "point_count"]], paint: { "circle-color": palette.accent, "circle-radius": 7, "circle-stroke-width": 2.5, "circle-stroke-color": palette.halo } })
576
+ /* @__PURE__ */ jsx(Layer, { type: "circle", id: `${id}-groups`, filter: ["has", "point_count"], paint: { "circle-color": group.fill, "circle-radius": ["step", ["get", "point_count"], 16, 10, 20, 50, 26], "circle-stroke-width": 3, "circle-stroke-color": group.stroke } }),
577
+ /* @__PURE__ */ jsx(Layer, { type: "symbol", id: `${id}-count`, filter: ["has", "point_count"], layout: { "text-field": ["get", "point_count_abbreviated"], "text-font": ["Noto Sans Medium"], "text-size": 13 }, paint: { "text-color": group.text } }),
578
+ /* @__PURE__ */ jsx(Layer, { type: "circle", id: `${id}-points`, filter: ["!", ["has", "point_count"]], paint: { "circle-color": dot.fill, "circle-radius": 7, "circle-stroke-width": 2.5, "circle-stroke-color": dot.stroke } })
605
579
  ]
606
580
  }
607
581
  );