@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
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
- function mapPalette(scheme, brand = "krizaka") {
407
- const t = { ...themes[scheme], ...brands[brand]?.[scheme] };
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: mix(land, t.accent, dark ? 0.18 : 0.14),
414
- park: mix(land, t.success, dark ? 0.1 : 0.12),
415
- road: dark ? mix(land, t.textPrimary, 0.12) : "#ffffff",
416
- roadMajor: dark ? mix(land, t.textPrimary, 0.2) : mix(land, t.textPrimary, 0.06),
417
- casing: mix(land, t.textPrimary, dark ? 0.05 : 0.12),
418
- building: mix(land, t.textPrimary, dark ? 0.06 : 0.07),
419
- boundary: mix(land, t.textPrimary, 0.3),
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: t.textPrimary,
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 mapFlavor(scheme, brand) {
428
- const c = mapPalette(scheme, brand);
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
- background: c.background,
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 mapStyle({ scheme, brand, lang = "en", world = { url: mapAssets().tiles.world, maxzoom: 6 }, region = { url: mapAssets().tiles.quebec, maxzoom: 14 }, glyphs = mapAssets().glyphs }) {
514
- const flavor = mapFlavor(scheme, brand);
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
- for (const l of layers("world", flavor, { lang })) {
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
- for (const l of layers("region", flavor, { lang })) {
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.map((l) => l.maxzoom === void 0 ? withoutKey(l, "maxzoom") : l) };
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 ?? pageScheme;
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.accent, "circle-opacity": 0.92, "circle-radius": ["step", ["get", "point_count"], 16, 10, 20, 50, 26], "circle-stroke-width": 3, "circle-stroke-color": c.halo } },
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.onAccent } },
947
- { id: `${id}-points`, type: "circle", source: id, filter: ["!", ["has", "point_count"]], paint: { "circle-color": c.accent, "circle-radius": 7, "circle-stroke-width": 2.5, "circle-stroke-color": c.halo } }
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
  );