@spillway-cms/blocks 0.1.24 → 0.1.25

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 (55) hide show
  1. package/dist/collection.d.ts +32 -1
  2. package/dist/collection.js +40 -5
  3. package/dist/collection.js.map +1 -1
  4. package/dist/config.d.ts +15 -1
  5. package/dist/config.js +23 -3
  6. package/dist/config.js.map +1 -1
  7. package/dist/countdown.d.ts +34 -0
  8. package/dist/countdown.js +81 -0
  9. package/dist/countdown.js.map +1 -0
  10. package/dist/css.js +17 -0
  11. package/dist/css.js.map +1 -1
  12. package/dist/documents.d.ts +52 -0
  13. package/dist/documents.js +146 -0
  14. package/dist/documents.js.map +1 -0
  15. package/dist/examples.js +74 -0
  16. package/dist/examples.js.map +1 -1
  17. package/dist/form.d.ts +11 -3
  18. package/dist/form.js +27 -11
  19. package/dist/form.js.map +1 -1
  20. package/dist/glossary.d.ts +56 -0
  21. package/dist/glossary.js +117 -0
  22. package/dist/glossary.js.map +1 -0
  23. package/dist/hours.d.ts +44 -0
  24. package/dist/hours.js +163 -0
  25. package/dist/hours.js.map +1 -0
  26. package/dist/index.d.ts +16 -0
  27. package/dist/index.js +9 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/language-switcher.d.ts +38 -0
  30. package/dist/language-switcher.js +60 -0
  31. package/dist/language-switcher.js.map +1 -0
  32. package/dist/listing-script.d.ts +13 -0
  33. package/dist/listing-script.js +44 -0
  34. package/dist/listing-script.js.map +1 -0
  35. package/dist/location-map.d.ts +60 -0
  36. package/dist/location-map.js +215 -0
  37. package/dist/location-map.js.map +1 -0
  38. package/dist/meta.js +37 -2
  39. package/dist/meta.js.map +1 -1
  40. package/dist/motion.js +1 -1
  41. package/dist/progress.d.ts +46 -0
  42. package/dist/progress.js +106 -0
  43. package/dist/progress.js.map +1 -0
  44. package/dist/registry-package.js +1 -1
  45. package/dist/registry-package.js.map +1 -1
  46. package/dist/registry-types.d.ts +5 -0
  47. package/dist/registry-types.js.map +1 -1
  48. package/dist/styles.css +193 -1
  49. package/dist/utility-script.d.ts +20 -0
  50. package/dist/utility-script.js +90 -0
  51. package/dist/utility-script.js.map +1 -0
  52. package/dist/utility-shared.d.ts +18 -0
  53. package/dist/utility-shared.js +32 -0
  54. package/dist/utility-shared.js.map +1 -0
  55. package/package.json +2 -2
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The Collection block's listing script, carried once by a page with an interactive Collection block (filters, a pager, sorting
3
+ * or page sizes; `isInteractiveCollection`). It is progressive enhancement only: the server renders a plain GET form and links.
4
+ *
5
+ * With the script, the filter form, the A to Z letters, the pager and the sort links load the new view in place: it fetches the
6
+ * page at the new URL (the same server render, cached per query), swaps the block's content for the fetched block's (the n-th
7
+ * `[data-sw-listing]` of the page), writes the new result count into the existing live region so screen readers announce it, and
8
+ * pushes the URL, so the address stays shareable and the back button goes back to the previous view (popstate loads it again).
9
+ * The count and (after a submit) the form are never taken out of the page, so the live region keeps announcing and focus stays
10
+ * on the control that was used; a letter link focuses the new letter, the pager and sort links focus the results.
11
+ * The form is kept as the visitor left it after a submit; Back loads the earlier form too. Any failure falls back to a normal page load.
12
+ */
13
+ export const LISTING_SCRIPT = `(function(){var d=document,h=d.documentElement;if(h.hasAttribute('data-sw-listing-ready'))return;h.setAttribute('data-sw-listing-ready','');
14
+ if(!window.fetch||!window.DOMParser||!window.URLSearchParams||!window.FormData||!history.pushState)return;
15
+ var here=location.pathname+location.search;
16
+ function all(doc){return doc.querySelectorAll('[data-sw-listing]')}
17
+ function indexOf(el){var a=all(d);for(var i=0;i<a.length;i++)if(a[i]===el)return i;return -1}
18
+ function swap(el,next,keep){var cur=el.querySelector('.sw-container'),nw=next.querySelector('.sw-container');if(!cur||!nw)throw 0;
19
+ var count=cur.querySelector('[data-sw-listing-count]'),form=keep?cur.querySelector('form.sw-listing__form'):null,act=d.activeElement,kids=[],c,n;
20
+ for(c=nw.firstElementChild;c;c=c.nextElementSibling)kids.push(c);
21
+ for(c=cur.firstChild;c;c=n){n=c.nextSibling;if(c!==count&&c!==form)cur.removeChild(c)}
22
+ var ref=cur.firstChild;
23
+ for(var i=0;i<kids.length;i++){var k=kids[i];
24
+ if(count&&k.hasAttribute('data-sw-listing-count')){if(count.textContent!==k.textContent)count.textContent=k.textContent;ref=count.nextSibling;continue}
25
+ if(form&&k.matches('form.sw-listing__form')){ref=form.nextSibling;continue}
26
+ cur.insertBefore(d.importNode(k,true),ref)}
27
+ if(act&&act!==d.body&&d.contains(act)&&d.activeElement!==act)try{act.focus()}catch(e){}}
28
+ function load(el,url,opts){var i=indexOf(el);if(i<0){location.href=url;return}el.setAttribute('aria-busy','true');
29
+ fetch(url,{credentials:'same-origin',headers:{Accept:'text/html'}}).then(function(r){if(!r.ok)throw 0;return r.text()}).then(function(html){
30
+ var next=all(new DOMParser().parseFromString(html,'text/html'))[i];if(!next)throw 0;swap(el,next,opts.keep);el.removeAttribute('aria-busy');
31
+ if(opts.push){history.pushState({swListing:1},'',url);here=location.pathname+location.search}
32
+ if(opts.focus)opts.focus(el)}).catch(function(){location.href=url})}
33
+ function results(el){var r=el.querySelector('.sw-collection__results')||el.querySelector('[data-sw-listing-count]');if(r){if(!r.hasAttribute('tabindex'))r.setAttribute('tabindex','-1');try{r.focus()}catch(e){}}}
34
+ d.addEventListener('submit',function(e){var f=e.target;if(!f.matches||!f.matches('form.sw-listing__form'))return;var el=f.closest('[data-sw-listing]');if(!el)return;
35
+ e.preventDefault();var sp=new URLSearchParams();new FormData(f).forEach(function(v,k){if(typeof v==='string'&&v!=='')sp.append(k,v)});
36
+ var qs=sp.toString(),u=new URL(f.getAttribute('action')||location.pathname,location.href);load(el,u.pathname+(qs?'?'+qs:''),{push:true,keep:true})});
37
+ d.addEventListener('click',function(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;
38
+ var a=e.target.closest&&e.target.closest('a[href]');if(!a||!a.matches('.sw-listing__letter,.sw-listing__pager a,.sw-collection__sort,.sw-listing__reset'))return;
39
+ var el=a.closest('[data-sw-listing]');if(!el)return;var u=new URL(a.href,location.href);if(u.origin!==location.origin)return;e.preventDefault();
40
+ var letter=a.classList.contains('sw-listing__letter')?a.textContent:null;
41
+ load(el,u.pathname+u.search,{push:true,focus:function(b){if(letter!==null){var ls=b.querySelectorAll('.sw-listing__letter');for(var j=0;j<ls.length;j++)if(ls[j].textContent===letter&&ls[j].tagName==='A'){ls[j].focus();return}}results(b)}})});
42
+ window.addEventListener('popstate',function(){var now=location.pathname+location.search;if(now===here)return;here=now;var a=all(d);for(var i=0;i<a.length;i++)load(a[i],now,{push:false})});
43
+ })();`;
44
+ //# sourceMappingURL=listing-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listing-script.js","sourceRoot":"","sources":["../src/listing-script.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA8BxB,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The Location map block (docs/dev/location-map.md): the places of a collection as a list beside an interactive map, with the
3
+ * Collection block's filters (category, keyword search) and pager. Server-safe: the server resolves `items` (each with `geo`),
4
+ * `listing`, `fieldColumns` and `map` (the site's tiles) through the Collection resolver. Without JavaScript the block is the
5
+ * list alone, each place with its details and a link to it on OpenStreetMap; LOCMAP_SCRIPT, which the page carries only when the
6
+ * block is on it, draws the map (raster tiles, marker buttons, keyboard, the consent wait) and adds Show on map to each place.
7
+ */
8
+ import type { ComponentConfig } from '@puckeditor/core';
9
+ import { type CollectionField, type CollectionItem, type ExposedFilter, type LocationMapTiles } from '@spillway-cms/shared';
10
+ import { type ListingData } from './collection.js';
11
+ export type LocationMapHeight = 's' | 'm' | 'l';
12
+ export interface LocationMapProps {
13
+ collectionId: string;
14
+ /** An optional heading above the block (an h2), which also names the region. */
15
+ heading: string;
16
+ /** The number fields that hold each place's coordinates. */
17
+ latField: string;
18
+ lngField: string;
19
+ /** Lines under each place (an address, hours, a phone, a category). */
20
+ fields: CollectionField[];
21
+ /** Visitor filters: a taxonomy field as the category, a keyword search. */
22
+ filters: ExposedFilter[];
23
+ pageSize: number;
24
+ showPager: boolean;
25
+ showResultCount: boolean;
26
+ showSummary: boolean;
27
+ titleLevel: 'h2' | 'h3';
28
+ emptyText: string;
29
+ height: LocationMapHeight;
30
+ /** A "View on OpenStreetMap" link under each place, for visitors without the map. */
31
+ mapLinks: boolean;
32
+ /** Resolved by the server; never stored. */
33
+ items?: CollectionItem[];
34
+ listing?: ListingData;
35
+ fieldColumns?: {
36
+ field: string;
37
+ label: string;
38
+ }[];
39
+ map?: LocationMapTiles | null;
40
+ }
41
+ /** The blocks that need LOCMAP_SCRIPT on their page. */
42
+ export declare const LOCATION_MAP_BLOCKS: readonly ["LocationMap"];
43
+ export declare function osmPlaceUrl(lat: number, lng: number): string;
44
+ export declare function renderLocationMap(props: LocationMapProps & {
45
+ id?: string;
46
+ puck?: {
47
+ isEditing?: boolean;
48
+ };
49
+ }): import("react").JSX.Element;
50
+ export declare const locationMapComponent: ComponentConfig<LocationMapProps>;
51
+ export declare const locationMapCss = "/* ---------- Location map ---------- */\n.sw-locmap { padding: var(--sw-space-4, 2rem) 0; }\n.sw-locmap__heading { margin: 0 0 var(--sw-space-2, 1rem); }\n.sw-locmap__list { list-style: none; margin: var(--sw-space-2, 1rem) 0 0; padding: 0; display: grid; gap: var(--sw-space-2, 1rem); }\n.sw-locmap__item { padding: 0.9rem 1rem; border: 1px solid color-mix(in srgb, currentColor 14%, transparent); border-radius: var(--sw-radius, 8px); background: var(--sw-color-surface, transparent); }\n.sw-locmap__item[data-active] { border-color: var(--sw-color-primary); box-shadow: 0 0 0 1px var(--sw-color-primary); }\n.sw-locmap__title { margin: 0; font-size: 1.1rem; }\n.sw-locmap__summary { margin: 0.35rem 0 0; color: var(--sw-color-muted, #555); }\n.sw-locmap__fields { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--sw-space-2, 1rem); margin: 0.5rem 0 0; font-size: 0.9375rem; }\n.sw-locmap__field { display: contents; }\n.sw-locmap__field dt { font-weight: 600; }\n.sw-locmap__field dd { margin: 0; white-space: pre-line; }\n.sw-locmap__links { margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; font-size: 0.9375rem; }\n.sw-locmap__show { font: inherit; font-weight: 600; cursor: pointer; padding: 0.3rem 0.7rem; color: var(--sw-color-primary); background: transparent; border: 1px solid currentColor; border-radius: var(--sw-radius, 8px); }\n.sw-locmap__show:focus-visible, .sw-locmap__marker:focus-visible, .sw-locmap__map:focus-visible, .sw-locmap__zoom button:focus-visible, .sw-locmap__load:focus-visible { outline: 2px solid var(--sw-color-primary); outline-offset: 2px; }\n.sw-locmap__map { position: relative; overflow: hidden; height: 440px; border-radius: var(--sw-radius, 8px); background: color-mix(in srgb, currentColor 6%, var(--sw-color-bg, #fff)); touch-action: none; user-select: none; }\n.sw-locmap--h-s .sw-locmap__map { height: 320px; }\n.sw-locmap--h-l .sw-locmap__map { height: 600px; }\n.sw-locmap__map[hidden] { display: none; }\n.sw-locmap__tiles { position: absolute; inset: 0; cursor: grab; }\n.sw-locmap__tiles:active { cursor: grabbing; }\n.sw-locmap__tiles img { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; -webkit-user-drag: none; }\n.sw-locmap__marker { position: absolute; width: 28px; height: 28px; margin: -28px 0 0 -14px; padding: 0; border: 0; background: transparent; cursor: pointer; }\n.sw-locmap__marker::before { content: \"\"; position: absolute; inset: 0; background: var(--sw-color-primary, #1d4ed8); border: 2px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }\n.sw-locmap__marker[aria-pressed=\"true\"]::before { background: var(--sw-color-accent, #b45309); }\n.sw-locmap__popup { position: absolute; z-index: 3; width: max-content; max-width: 16rem; padding: 0.6rem 0.75rem; transform: translate(-50%, calc(-100% - 34px)); background: var(--sw-color-bg, #fff); color: var(--sw-color-text, #111); border-radius: var(--sw-radius, 8px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); font-size: 0.9375rem; }\n.sw-locmap__popup[hidden] { display: none; }\n.sw-locmap__popup p { margin: 0.25rem 0 0; }\n.sw-locmap__popup strong { display: block; }\n.sw-locmap__zoom { position: absolute; z-index: 4; top: 0.5rem; right: 0.5rem; display: flex; flex-direction: column; gap: 4px; }\n.sw-locmap__zoom button { width: 2.25rem; height: 2.25rem; font: inherit; font-size: 1.25rem; line-height: 1; cursor: pointer; color: var(--sw-color-text, #111); background: var(--sw-color-bg, #fff); border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: var(--sw-radius, 8px); }\n.sw-locmap__attribution { position: absolute; z-index: 4; right: 0; bottom: 0; padding: 2px 6px; font-size: 0.75rem; background: color-mix(in srgb, var(--sw-color-bg, #fff) 85%, transparent); color: var(--sw-color-text, #111); }\n.sw-locmap__attribution a { color: inherit; }\n.sw-locmap__consent { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; padding: 1.5rem; text-align: center; }\n.sw-locmap__load { font: inherit; font-weight: 600; cursor: pointer; padding: 0.5rem 1rem; color: var(--sw-color-primary-contrast, #fff); background: var(--sw-color-primary, #1d4ed8); border: 0; border-radius: var(--sw-radius, 8px); }\n@media (min-width: 900px) {\n .sw-locmap--live .sw-locmap__layout { display: grid; grid-template-columns: minmax(16rem, 2fr) 3fr; gap: var(--sw-space-3, 1.5rem); align-items: start; }\n .sw-locmap--live .sw-locmap__list { margin-top: 0; max-height: 440px; overflow: auto; padding-right: 4px; }\n .sw-locmap--live.sw-locmap--h-s .sw-locmap__list { max-height: 320px; }\n .sw-locmap--live.sw-locmap--h-l .sw-locmap__list { max-height: 600px; }\n .sw-locmap--live .sw-locmap__map { position: sticky; top: 1rem; order: 2; }\n}\n@media (max-width: 899px) {\n .sw-locmap--live .sw-locmap__layout { display: flex; flex-direction: column-reverse; gap: var(--sw-space-2, 1rem); }\n .sw-locmap--live .sw-locmap__map { height: min(60vh, 440px); }\n}\n";
52
+ /**
53
+ * The map, once per page (docs/dev/location-map.md). Reads each `[data-sw-locmap]` (the tiles, the credit, consent, the deepest
54
+ * zoom) and the places of its list (`data-lat`, `data-lng`), and draws a small slippy map: raster tiles as images, the view fitted
55
+ * to the places, drag to move, Ctrl and the wheel or double-click to zoom, the Zoom in and Zoom out buttons, and the arrow keys
56
+ * and + and - while the map has focus. Each place is a marker button named by the place; activating one, or the Show on map
57
+ * button it adds to the place in the list, opens a popup built with textContent. When tiles wait for consent (the provider sets
58
+ * cookies and the banner is on) and marketing is not granted, it shows a notice and a Show the map button instead.
59
+ */
60
+ export declare const LOCMAP_SCRIPT = "(function(){var d=document;if(d.documentElement.hasAttribute('data-sw-locmap-on'))return;d.documentElement.setAttribute('data-sw-locmap-on','');\nvar T=256,CK='sw_consent';\nfunction consented(){var m=d.cookie.match(new RegExp('(?:^|; )'+CK+'=([^;]*)'));if(!m||navigator.globalPrivacyControl===true)return false;return m[1]==='1'||/^a[01]m1$/.test(m[1])}\nfunction el(t,c,x){var e=d.createElement(t);if(c)e.className=c;if(x)e.textContent=x;return e}\nfunction world(lat,lng,z){var s=T*Math.pow(2,z),r=Math.sin(lat*Math.PI/180);r=Math.min(Math.max(r,-0.9999),0.9999);return[(lng+180)/360*s,(0.5-Math.log((1+r)/(1-r))/(4*Math.PI))*s]}\nfunction host(u){try{return new URL(u.replace(/\\{[a-z]\\}/g,'0')).hostname}catch(e){return u}}\nfunction setup(box){var cfg;try{cfg=JSON.parse(box.getAttribute('data-sw-locmap'))}catch(e){return}if(!cfg||!cfg.tileUrl)return;\nvar sec=box.closest('.sw-locmap'),list=sec&&sec.querySelector('.sw-locmap__list');if(!list)return;\nvar items=list.querySelectorAll('[data-sw-place]'),P=[];for(var i=0;i<items.length;i++){var it=items[i],la=parseFloat(it.getAttribute('data-lat')),ln=parseFloat(it.getAttribute('data-lng'));if(isFinite(la)&&isFinite(ln)&&Math.abs(la)<=90&&Math.abs(ln)<=180){var a=it.querySelector('.sw-locmap__title a'),t=it.querySelector('.sw-locmap__title'),dd=it.querySelector('.sw-locmap__field dd');P.push({lat:la,lng:ln,li:it,name:(t?t.textContent:'').trim(),href:a?a.getAttribute('href'):null,detail:dd?dd.textContent.trim():''})}}\nif(!P.length)return;box.hidden=false;sec.classList.add('sw-locmap--live');\nbox.setAttribute('role','region');box.setAttribute('aria-label','Map of the places listed');\nvar help=el('p','sw-visually-hidden','Drag or use the arrow keys to move the map, plus and minus to zoom. Each marker is a button that shows its place.');help.id=box.id+'-help';box.appendChild(help);box.setAttribute('aria-describedby',help.id);\nvar credit=el('div','sw-locmap__attribution');if(cfg.attributionUrl){var ca=el('a','',cfg.attribution);ca.href=cfg.attributionUrl;ca.rel='noopener';credit.appendChild(ca)}else credit.textContent=cfg.attribution;box.appendChild(credit);\nif(cfg.consent&&!consented()){var c=el('div','sw-locmap__consent');c.appendChild(el('p','','The map loads from '+host(cfg.tileUrl)+', which may set cookies.'));var b=el('button','sw-locmap__load','Show the map');b.type='button';c.appendChild(b);box.appendChild(c);\nvar go=function(){if(c.parentNode){c.parentNode.removeChild(c);draw(box,cfg,P)}};b.addEventListener('click',function(){go();box.focus()});d.addEventListener('click',function(e){if(e.target.closest&&e.target.closest('.sw-consent__btn'))setTimeout(function(){if(consented())go()},0)});return}\ndraw(box,cfg,P)}\nfunction draw(box,cfg,P){var max=Math.max(1,Math.min(22,cfg.maxZoom||19)),z=max,cx=0,cy=0,tiles={},retina=(window.devicePixelRatio||1)>1?'@2x':'';\nvar pane=el('div','sw-locmap__tiles'),layer=el('div','');pane.appendChild(layer);box.insertBefore(pane,box.firstChild);box.tabIndex=0;\nvar pop=el('div','sw-locmap__popup');pop.hidden=true;pop.setAttribute('aria-live','polite');box.appendChild(pop);\nvar zoom=el('div','sw-locmap__zoom');function zb(x,l,f){var b=el('button','',x);b.type='button';b.setAttribute('aria-label',l);b.addEventListener('click',f);zoom.appendChild(b)}\nzb('+','Zoom in',function(){setZoom(z+1)});zb('\\u2212','Zoom out',function(){setZoom(z-1)});box.appendChild(zoom);\nvar W=function(){return box.clientWidth||600},H=function(){return box.clientHeight||400},open=-1;\nP.forEach(function(p,i){var m=el('button','sw-locmap__marker');m.type='button';m.setAttribute('aria-label',p.name);m.setAttribute('aria-pressed','false');m.addEventListener('click',function(){show(i,false)});p.m=m;layer.appendChild(m);\nvar links=p.li.querySelector('.sw-locmap__links');if(!links){links=el('p','sw-locmap__links');p.li.appendChild(links)}var s=el('button','sw-locmap__show','Show on map');s.type='button';s.setAttribute('aria-controls',box.id);s.setAttribute('aria-label','Show on map: '+p.name);s.addEventListener('click',function(){show(i,true);p.m.focus()});links.insertBefore(s,links.firstChild)});\nfunction fit(){var w=W()-80,h=H()-80;for(z=max;z>1;z--){var a=bounds(z);if(a[2]-a[0]<=w&&a[3]-a[1]<=h)break}if(P.length===1)z=Math.min(max,16);var b=bounds(z);cx=(b[0]+b[2])/2;cy=(b[1]+b[3])/2}\nfunction bounds(zz){var x0=1/0,y0=1/0,x1=-1/0,y1=-1/0;P.forEach(function(p){var q=world(p.lat,p.lng,zz);x0=Math.min(x0,q[0]);y0=Math.min(y0,q[1]);x1=Math.max(x1,q[0]);y1=Math.max(y1,q[1])});return[x0,y0,x1,y1]}\nfunction render(){var w=W(),h=H(),n=Math.pow(2,z),ox=cx-w/2,oy=cy-h/2,want={};\nfor(var tx=Math.floor(ox/T);tx<=Math.floor((ox+w)/T);tx++)for(var ty=Math.floor(oy/T);ty<=Math.floor((oy+h)/T);ty++){if(ty<0||ty>=n)continue;var wx=((tx%n)+n)%n,k=z+'/'+tx+'/'+ty;want[k]=1;var img=tiles[k];\nif(!img){img=d.createElement('img');img.alt='';img.decoding='async';img.draggable=false;img.src=cfg.tileUrl.replace('{z}',z).replace('{x}',wx).replace('{y}',ty).replace('{r}',retina);tiles[k]=img;layer.insertBefore(img,layer.firstChild)}img.style.left=(tx*T-ox)+'px';img.style.top=(ty*T-oy)+'px'}\nfor(var key in tiles)if(!want[key]){layer.removeChild(tiles[key]);delete tiles[key]}\nP.forEach(function(p){var q=world(p.lat,p.lng,z);p.x=q[0]-ox;p.y=q[1]-oy;p.m.style.left=p.x+'px';p.m.style.top=p.y+'px';p.m.hidden=p.x<-20||p.y<-20||p.x>w+20||p.y>h+40});\nif(open>=0){var o=P[open];pop.style.left=o.x+'px';pop.style.top=o.y+'px'}}\nfunction setZoom(nz,ax,ay){nz=Math.max(1,Math.min(max,nz));if(nz===z)return;var w=W(),h=H();ax=ax==null?w/2:ax;ay=ay==null?h/2:ay;var f=Math.pow(2,nz-z),wx=cx-w/2+ax,wy=cy-h/2+ay;cx=wx*f-ax+w/2;cy=wy*f-ay+h/2;z=nz;render()}\nfunction show(i,center){if(open>=0){P[open].m.setAttribute('aria-pressed','false');P[open].li.removeAttribute('data-active')}open=i;var p=P[i];p.m.setAttribute('aria-pressed','true');p.li.setAttribute('data-active','');\nif(center){var q=world(p.lat,p.lng,z);cx=q[0];cy=q[1]-40}else if(p.li.scrollIntoView){try{p.li.scrollIntoView({block:'nearest'})}catch(e){}}\npop.textContent='';var n=el('strong','');if(p.href){var a=el('a','',p.name);a.href=p.href;n.appendChild(a)}else n.textContent=p.name;pop.appendChild(n);if(p.detail)pop.appendChild(el('p','',p.detail));pop.hidden=false;render()}\nvar drag=null;pane.addEventListener('pointerdown',function(e){if(e.button!==0)return;drag={x:e.clientX,y:e.clientY,cx:cx,cy:cy};try{pane.setPointerCapture(e.pointerId)}catch(x){}});\npane.addEventListener('pointermove',function(e){if(!drag)return;cx=drag.cx-(e.clientX-drag.x);cy=drag.cy-(e.clientY-drag.y);render()});\npane.addEventListener('pointerup',function(){drag=null});pane.addEventListener('pointercancel',function(){drag=null});\npane.addEventListener('dblclick',function(e){var r=box.getBoundingClientRect();setZoom(z+1,e.clientX-r.left,e.clientY-r.top)});\nbox.addEventListener('wheel',function(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();var r=box.getBoundingClientRect();setZoom(z+(e.deltaY<0?1:-1),e.clientX-r.left,e.clientY-r.top)},{passive:false});\nbox.addEventListener('keydown',function(e){if(e.target!==box)return;var s=64,k=e.key;if(k==='ArrowLeft')cx-=s;else if(k==='ArrowRight')cx+=s;else if(k==='ArrowUp')cy-=s;else if(k==='ArrowDown')cy+=s;else if(k==='+'||k==='=')return e.preventDefault(),setZoom(z+1);else if(k==='-'||k==='_')return e.preventDefault(),setZoom(z-1);else if(k==='Escape'&&open>=0){pop.hidden=true;P[open].m.setAttribute('aria-pressed','false');P[open].li.removeAttribute('data-active');open=-1;return}else return;e.preventDefault();render()});\nif(window.ResizeObserver)new ResizeObserver(function(){render()}).observe(box);else window.addEventListener('resize',render);\nfit();render()}\nfunction run(){var b=d.querySelectorAll('[data-sw-locmap]');for(var i=0;i<b.length;i++)setup(b[i])}\nif(d.readyState==='loading')d.addEventListener('DOMContentLoaded',run);else run()})();";
@@ -0,0 +1,215 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CONSENT_COOKIE } from '@spillway-cms/shared';
3
+ import { FilterForm, Pager } from './collection.js';
4
+ /** The blocks that need LOCMAP_SCRIPT on their page. */
5
+ export const LOCATION_MAP_BLOCKS = ['LocationMap'];
6
+ const yesNo = [
7
+ { label: 'Yes', value: true },
8
+ { label: 'No', value: false },
9
+ ];
10
+ const cleanId = (v) => String(v ?? 'x').replace(/[^a-zA-Z0-9_-]/g, '');
11
+ /** JSON for an HTML attribute: React escapes the quotes; `<` is escaped too so nothing can look like markup. */
12
+ const attrJson = (v) => JSON.stringify(v).replace(/</g, '\\u003c');
13
+ export function osmPlaceUrl(lat, lng) {
14
+ const la = lat.toFixed(6);
15
+ const ln = lng.toFixed(6);
16
+ return `https://www.openstreetmap.org/?mlat=${la}&mlon=${ln}#map=18/${la}/${ln}`;
17
+ }
18
+ function Place({ item, index, blockId, titleLevel, columns, showSummary, mapLinks }) {
19
+ const Title = titleLevel;
20
+ const lines = columns.filter((c) => c.field !== 'title' && item.cells?.[c.field]);
21
+ const geo = item.geo && Number.isFinite(item.geo.lat) && Number.isFinite(item.geo.lng) ? item.geo : null;
22
+ return (_jsxs("li", { className: "sw-locmap__item", id: `${blockId}-place-${index}`, "data-sw-place": geo ? String(index) : undefined, "data-lat": geo ? String(geo.lat) : undefined, "data-lng": geo ? String(geo.lng) : undefined, children: [_jsx(Title, { className: "sw-locmap__title", children: item.path ? _jsx("a", { href: item.path, children: item.title }) : item.title }), showSummary && item.summary ? _jsx("p", { className: "sw-locmap__summary", children: item.summary }) : null, lines.length ? (_jsx("dl", { className: "sw-locmap__fields", children: lines.map((c) => (_jsxs("div", { className: "sw-locmap__field", children: [_jsx("dt", { children: c.label }), _jsx("dd", { children: item.cells[c.field] })] }, c.field))) })) : null, geo && mapLinks ? (_jsx("p", { className: "sw-locmap__links", children: _jsxs("a", { className: "sw-locmap__osm", href: osmPlaceUrl(geo.lat, geo.lng), children: ["View ", _jsx("span", { className: "sw-visually-hidden", children: `${item.title} ` }), "on OpenStreetMap"] }) })) : null] }));
23
+ }
24
+ export function renderLocationMap(props) {
25
+ const { id, collectionId, heading, filters, showPager, showResultCount, showSummary, titleLevel, emptyText, height, mapLinks, items, listing, fieldColumns, map } = props;
26
+ const blockId = `sw-locmap-${cleanId(id ?? collectionId)}`;
27
+ const exposed = Array.isArray(filters) ? filters : [];
28
+ const shown = Array.isArray(fieldColumns) ? fieldColumns : [];
29
+ // Under the block's own heading the places are h3s; without one, the chosen level.
30
+ const level = heading?.trim() ? 'h3' : titleLevel === 'h2' ? 'h2' : 'h3';
31
+ const places = Array.isArray(items) ? items : null;
32
+ const located = (places ?? []).filter((i) => i.geo).length;
33
+ const h = height === 's' || height === 'l' ? height : 'm';
34
+ return (_jsx("section", { className: `sw-block sw-locmap sw-locmap--h-${h}`, "aria-labelledby": heading?.trim() ? `${blockId}-heading` : undefined, "aria-label": heading?.trim() ? undefined : 'Places', "data-collection": collectionId || undefined, children: _jsxs("div", { className: "sw-container", children: [heading?.trim() ? (_jsx("h2", { className: "sw-locmap__heading", id: `${blockId}-heading`, children: heading })) : null, listing && exposed.length > 0 ? _jsx(FilterForm, { id: blockId, filters: exposed, listing: listing, sortControl: false }) : null, listing && showResultCount !== false && places ? (_jsx("p", { className: "sw-listing__count", role: "status", children: (listing.total === 0 ? 'No places' : `${listing.total} place${listing.total === 1 ? '' : 's'}`) + (listing.pages > 1 ? ` · page ${listing.page} of ${listing.pages}` : '') })) : null, !places ? (_jsxs("div", { className: "sw-collection__placeholder", role: "note", children: ["Location map: the places of ", collectionId || '(no collection chosen)', " as a list beside a map, shown on the published page. Each place needs a latitude and a longitude."] })) : places.length === 0 ? (_jsx("p", { className: "sw-collection__empty", children: emptyText })) : (_jsxs("div", { className: "sw-locmap__layout", children: [_jsx("ol", { className: "sw-locmap__list", id: `${blockId}-list`, children: places.map((item, i) => (_jsx(Place, { item: item, index: i, blockId: blockId, titleLevel: level, columns: shown, showSummary: showSummary === true, mapLinks: mapLinks !== false }, item.id))) }), map && located > 0 ? _jsx("div", { className: "sw-locmap__map", id: `${blockId}-map`, "data-sw-locmap": attrJson(map), hidden: true }) : null] })), listing && showPager !== false ? _jsx(Pager, { listing: listing }) : null] }) }));
35
+ }
36
+ export const locationMapComponent = {
37
+ label: 'Location map',
38
+ fields: {
39
+ collectionId: { type: 'text', label: 'Collection id or key', placeholder: 'campus_locations' },
40
+ heading: { type: 'text', label: 'Heading (optional)' },
41
+ latField: { type: 'text', label: 'Latitude field', placeholder: 'latitude' },
42
+ lngField: { type: 'text', label: 'Longitude field', placeholder: 'longitude' },
43
+ fields: {
44
+ type: 'array',
45
+ label: 'Details under each place',
46
+ getItemSummary: (item) => item.label || item.field || 'Field',
47
+ arrayFields: {
48
+ field: { type: 'text', label: 'Field key', placeholder: 'address, hours, category' },
49
+ label: { type: 'text', label: 'Heading (optional)' },
50
+ },
51
+ defaultItemProps: { field: '', label: '' },
52
+ },
53
+ filters: {
54
+ type: 'array',
55
+ label: 'Visitor filters',
56
+ getItemSummary: (item) => item.label || item.field || 'Filter',
57
+ arrayFields: {
58
+ field: { type: 'text', label: 'Field key', placeholder: 'category' },
59
+ label: { type: 'text', label: 'Label' },
60
+ kind: {
61
+ type: 'select',
62
+ label: 'Kind',
63
+ options: [
64
+ { label: 'Keyword search', value: 'search' },
65
+ { label: 'Taxonomy term (a category)', value: 'taxonomy' },
66
+ { label: 'Select (one value)', value: 'select' },
67
+ ],
68
+ },
69
+ },
70
+ defaultItemProps: { field: '', label: '', kind: 'search' },
71
+ },
72
+ height: {
73
+ type: 'radio',
74
+ label: 'Map height',
75
+ options: [
76
+ { label: 'Short', value: 's' },
77
+ { label: 'Medium', value: 'm' },
78
+ { label: 'Tall', value: 'l' },
79
+ ],
80
+ },
81
+ pageSize: { type: 'number', label: 'Places per page', min: 1, max: 100 },
82
+ showPager: { type: 'radio', label: 'Show pager', options: yesNo },
83
+ showResultCount: { type: 'radio', label: 'Show the number of places', options: yesNo },
84
+ showSummary: { type: 'radio', label: 'Show summary', options: yesNo },
85
+ mapLinks: { type: 'radio', label: 'Link each place to OpenStreetMap', options: yesNo },
86
+ titleLevel: {
87
+ type: 'radio',
88
+ label: 'Place title level',
89
+ options: [
90
+ { label: 'H2', value: 'h2' },
91
+ { label: 'H3', value: 'h3' },
92
+ ],
93
+ },
94
+ emptyText: { type: 'text', label: 'Text when nothing matches' },
95
+ },
96
+ defaultProps: {
97
+ collectionId: '',
98
+ heading: '',
99
+ latField: 'latitude',
100
+ lngField: 'longitude',
101
+ fields: [],
102
+ filters: [],
103
+ pageSize: 100,
104
+ showPager: false,
105
+ showResultCount: true,
106
+ showSummary: false,
107
+ titleLevel: 'h3',
108
+ emptyText: 'No places match.',
109
+ height: 'm',
110
+ mapLinks: true,
111
+ },
112
+ render: (props) => renderLocationMap(props),
113
+ };
114
+ export const locationMapCss = `/* ---------- Location map ---------- */
115
+ .sw-locmap { padding: var(--sw-space-4, 2rem) 0; }
116
+ .sw-locmap__heading { margin: 0 0 var(--sw-space-2, 1rem); }
117
+ .sw-locmap__list { list-style: none; margin: var(--sw-space-2, 1rem) 0 0; padding: 0; display: grid; gap: var(--sw-space-2, 1rem); }
118
+ .sw-locmap__item { padding: 0.9rem 1rem; border: 1px solid color-mix(in srgb, currentColor 14%, transparent); border-radius: var(--sw-radius, 8px); background: var(--sw-color-surface, transparent); }
119
+ .sw-locmap__item[data-active] { border-color: var(--sw-color-primary); box-shadow: 0 0 0 1px var(--sw-color-primary); }
120
+ .sw-locmap__title { margin: 0; font-size: 1.1rem; }
121
+ .sw-locmap__summary { margin: 0.35rem 0 0; color: var(--sw-color-muted, #555); }
122
+ .sw-locmap__fields { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--sw-space-2, 1rem); margin: 0.5rem 0 0; font-size: 0.9375rem; }
123
+ .sw-locmap__field { display: contents; }
124
+ .sw-locmap__field dt { font-weight: 600; }
125
+ .sw-locmap__field dd { margin: 0; white-space: pre-line; }
126
+ .sw-locmap__links { margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; font-size: 0.9375rem; }
127
+ .sw-locmap__show { font: inherit; font-weight: 600; cursor: pointer; padding: 0.3rem 0.7rem; color: var(--sw-color-primary); background: transparent; border: 1px solid currentColor; border-radius: var(--sw-radius, 8px); }
128
+ .sw-locmap__show:focus-visible, .sw-locmap__marker:focus-visible, .sw-locmap__map:focus-visible, .sw-locmap__zoom button:focus-visible, .sw-locmap__load:focus-visible { outline: 2px solid var(--sw-color-primary); outline-offset: 2px; }
129
+ .sw-locmap__map { position: relative; overflow: hidden; height: 440px; border-radius: var(--sw-radius, 8px); background: color-mix(in srgb, currentColor 6%, var(--sw-color-bg, #fff)); touch-action: none; user-select: none; }
130
+ .sw-locmap--h-s .sw-locmap__map { height: 320px; }
131
+ .sw-locmap--h-l .sw-locmap__map { height: 600px; }
132
+ .sw-locmap__map[hidden] { display: none; }
133
+ .sw-locmap__tiles { position: absolute; inset: 0; cursor: grab; }
134
+ .sw-locmap__tiles:active { cursor: grabbing; }
135
+ .sw-locmap__tiles img { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; -webkit-user-drag: none; }
136
+ .sw-locmap__marker { position: absolute; width: 28px; height: 28px; margin: -28px 0 0 -14px; padding: 0; border: 0; background: transparent; cursor: pointer; }
137
+ .sw-locmap__marker::before { content: ""; position: absolute; inset: 0; background: var(--sw-color-primary, #1d4ed8); border: 2px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
138
+ .sw-locmap__marker[aria-pressed="true"]::before { background: var(--sw-color-accent, #b45309); }
139
+ .sw-locmap__popup { position: absolute; z-index: 3; width: max-content; max-width: 16rem; padding: 0.6rem 0.75rem; transform: translate(-50%, calc(-100% - 34px)); background: var(--sw-color-bg, #fff); color: var(--sw-color-text, #111); border-radius: var(--sw-radius, 8px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); font-size: 0.9375rem; }
140
+ .sw-locmap__popup[hidden] { display: none; }
141
+ .sw-locmap__popup p { margin: 0.25rem 0 0; }
142
+ .sw-locmap__popup strong { display: block; }
143
+ .sw-locmap__zoom { position: absolute; z-index: 4; top: 0.5rem; right: 0.5rem; display: flex; flex-direction: column; gap: 4px; }
144
+ .sw-locmap__zoom button { width: 2.25rem; height: 2.25rem; font: inherit; font-size: 1.25rem; line-height: 1; cursor: pointer; color: var(--sw-color-text, #111); background: var(--sw-color-bg, #fff); border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: var(--sw-radius, 8px); }
145
+ .sw-locmap__attribution { position: absolute; z-index: 4; right: 0; bottom: 0; padding: 2px 6px; font-size: 0.75rem; background: color-mix(in srgb, var(--sw-color-bg, #fff) 85%, transparent); color: var(--sw-color-text, #111); }
146
+ .sw-locmap__attribution a { color: inherit; }
147
+ .sw-locmap__consent { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; padding: 1.5rem; text-align: center; }
148
+ .sw-locmap__load { font: inherit; font-weight: 600; cursor: pointer; padding: 0.5rem 1rem; color: var(--sw-color-primary-contrast, #fff); background: var(--sw-color-primary, #1d4ed8); border: 0; border-radius: var(--sw-radius, 8px); }
149
+ @media (min-width: 900px) {
150
+ .sw-locmap--live .sw-locmap__layout { display: grid; grid-template-columns: minmax(16rem, 2fr) 3fr; gap: var(--sw-space-3, 1.5rem); align-items: start; }
151
+ .sw-locmap--live .sw-locmap__list { margin-top: 0; max-height: 440px; overflow: auto; padding-right: 4px; }
152
+ .sw-locmap--live.sw-locmap--h-s .sw-locmap__list { max-height: 320px; }
153
+ .sw-locmap--live.sw-locmap--h-l .sw-locmap__list { max-height: 600px; }
154
+ .sw-locmap--live .sw-locmap__map { position: sticky; top: 1rem; order: 2; }
155
+ }
156
+ @media (max-width: 899px) {
157
+ .sw-locmap--live .sw-locmap__layout { display: flex; flex-direction: column-reverse; gap: var(--sw-space-2, 1rem); }
158
+ .sw-locmap--live .sw-locmap__map { height: min(60vh, 440px); }
159
+ }
160
+ `;
161
+ /**
162
+ * The map, once per page (docs/dev/location-map.md). Reads each `[data-sw-locmap]` (the tiles, the credit, consent, the deepest
163
+ * zoom) and the places of its list (`data-lat`, `data-lng`), and draws a small slippy map: raster tiles as images, the view fitted
164
+ * to the places, drag to move, Ctrl and the wheel or double-click to zoom, the Zoom in and Zoom out buttons, and the arrow keys
165
+ * and + and - while the map has focus. Each place is a marker button named by the place; activating one, or the Show on map
166
+ * button it adds to the place in the list, opens a popup built with textContent. When tiles wait for consent (the provider sets
167
+ * cookies and the banner is on) and marketing is not granted, it shows a notice and a Show the map button instead.
168
+ */
169
+ export const LOCMAP_SCRIPT = `(function(){var d=document;if(d.documentElement.hasAttribute('data-sw-locmap-on'))return;d.documentElement.setAttribute('data-sw-locmap-on','');
170
+ var T=256,CK='${CONSENT_COOKIE}';
171
+ function consented(){var m=d.cookie.match(new RegExp('(?:^|; )'+CK+'=([^;]*)'));if(!m||navigator.globalPrivacyControl===true)return false;return m[1]==='1'||/^a[01]m1$/.test(m[1])}
172
+ function el(t,c,x){var e=d.createElement(t);if(c)e.className=c;if(x)e.textContent=x;return e}
173
+ function world(lat,lng,z){var s=T*Math.pow(2,z),r=Math.sin(lat*Math.PI/180);r=Math.min(Math.max(r,-0.9999),0.9999);return[(lng+180)/360*s,(0.5-Math.log((1+r)/(1-r))/(4*Math.PI))*s]}
174
+ function host(u){try{return new URL(u.replace(/\\{[a-z]\\}/g,'0')).hostname}catch(e){return u}}
175
+ function setup(box){var cfg;try{cfg=JSON.parse(box.getAttribute('data-sw-locmap'))}catch(e){return}if(!cfg||!cfg.tileUrl)return;
176
+ var sec=box.closest('.sw-locmap'),list=sec&&sec.querySelector('.sw-locmap__list');if(!list)return;
177
+ var items=list.querySelectorAll('[data-sw-place]'),P=[];for(var i=0;i<items.length;i++){var it=items[i],la=parseFloat(it.getAttribute('data-lat')),ln=parseFloat(it.getAttribute('data-lng'));if(isFinite(la)&&isFinite(ln)&&Math.abs(la)<=90&&Math.abs(ln)<=180){var a=it.querySelector('.sw-locmap__title a'),t=it.querySelector('.sw-locmap__title'),dd=it.querySelector('.sw-locmap__field dd');P.push({lat:la,lng:ln,li:it,name:(t?t.textContent:'').trim(),href:a?a.getAttribute('href'):null,detail:dd?dd.textContent.trim():''})}}
178
+ if(!P.length)return;box.hidden=false;sec.classList.add('sw-locmap--live');
179
+ box.setAttribute('role','region');box.setAttribute('aria-label','Map of the places listed');
180
+ var help=el('p','sw-visually-hidden','Drag or use the arrow keys to move the map, plus and minus to zoom. Each marker is a button that shows its place.');help.id=box.id+'-help';box.appendChild(help);box.setAttribute('aria-describedby',help.id);
181
+ var credit=el('div','sw-locmap__attribution');if(cfg.attributionUrl){var ca=el('a','',cfg.attribution);ca.href=cfg.attributionUrl;ca.rel='noopener';credit.appendChild(ca)}else credit.textContent=cfg.attribution;box.appendChild(credit);
182
+ if(cfg.consent&&!consented()){var c=el('div','sw-locmap__consent');c.appendChild(el('p','','The map loads from '+host(cfg.tileUrl)+', which may set cookies.'));var b=el('button','sw-locmap__load','Show the map');b.type='button';c.appendChild(b);box.appendChild(c);
183
+ var go=function(){if(c.parentNode){c.parentNode.removeChild(c);draw(box,cfg,P)}};b.addEventListener('click',function(){go();box.focus()});d.addEventListener('click',function(e){if(e.target.closest&&e.target.closest('.sw-consent__btn'))setTimeout(function(){if(consented())go()},0)});return}
184
+ draw(box,cfg,P)}
185
+ function draw(box,cfg,P){var max=Math.max(1,Math.min(22,cfg.maxZoom||19)),z=max,cx=0,cy=0,tiles={},retina=(window.devicePixelRatio||1)>1?'@2x':'';
186
+ var pane=el('div','sw-locmap__tiles'),layer=el('div','');pane.appendChild(layer);box.insertBefore(pane,box.firstChild);box.tabIndex=0;
187
+ var pop=el('div','sw-locmap__popup');pop.hidden=true;pop.setAttribute('aria-live','polite');box.appendChild(pop);
188
+ var zoom=el('div','sw-locmap__zoom');function zb(x,l,f){var b=el('button','',x);b.type='button';b.setAttribute('aria-label',l);b.addEventListener('click',f);zoom.appendChild(b)}
189
+ zb('+','Zoom in',function(){setZoom(z+1)});zb('\\u2212','Zoom out',function(){setZoom(z-1)});box.appendChild(zoom);
190
+ var W=function(){return box.clientWidth||600},H=function(){return box.clientHeight||400},open=-1;
191
+ P.forEach(function(p,i){var m=el('button','sw-locmap__marker');m.type='button';m.setAttribute('aria-label',p.name);m.setAttribute('aria-pressed','false');m.addEventListener('click',function(){show(i,false)});p.m=m;layer.appendChild(m);
192
+ var links=p.li.querySelector('.sw-locmap__links');if(!links){links=el('p','sw-locmap__links');p.li.appendChild(links)}var s=el('button','sw-locmap__show','Show on map');s.type='button';s.setAttribute('aria-controls',box.id);s.setAttribute('aria-label','Show on map: '+p.name);s.addEventListener('click',function(){show(i,true);p.m.focus()});links.insertBefore(s,links.firstChild)});
193
+ function fit(){var w=W()-80,h=H()-80;for(z=max;z>1;z--){var a=bounds(z);if(a[2]-a[0]<=w&&a[3]-a[1]<=h)break}if(P.length===1)z=Math.min(max,16);var b=bounds(z);cx=(b[0]+b[2])/2;cy=(b[1]+b[3])/2}
194
+ function bounds(zz){var x0=1/0,y0=1/0,x1=-1/0,y1=-1/0;P.forEach(function(p){var q=world(p.lat,p.lng,zz);x0=Math.min(x0,q[0]);y0=Math.min(y0,q[1]);x1=Math.max(x1,q[0]);y1=Math.max(y1,q[1])});return[x0,y0,x1,y1]}
195
+ function render(){var w=W(),h=H(),n=Math.pow(2,z),ox=cx-w/2,oy=cy-h/2,want={};
196
+ for(var tx=Math.floor(ox/T);tx<=Math.floor((ox+w)/T);tx++)for(var ty=Math.floor(oy/T);ty<=Math.floor((oy+h)/T);ty++){if(ty<0||ty>=n)continue;var wx=((tx%n)+n)%n,k=z+'/'+tx+'/'+ty;want[k]=1;var img=tiles[k];
197
+ if(!img){img=d.createElement('img');img.alt='';img.decoding='async';img.draggable=false;img.src=cfg.tileUrl.replace('{z}',z).replace('{x}',wx).replace('{y}',ty).replace('{r}',retina);tiles[k]=img;layer.insertBefore(img,layer.firstChild)}img.style.left=(tx*T-ox)+'px';img.style.top=(ty*T-oy)+'px'}
198
+ for(var key in tiles)if(!want[key]){layer.removeChild(tiles[key]);delete tiles[key]}
199
+ P.forEach(function(p){var q=world(p.lat,p.lng,z);p.x=q[0]-ox;p.y=q[1]-oy;p.m.style.left=p.x+'px';p.m.style.top=p.y+'px';p.m.hidden=p.x<-20||p.y<-20||p.x>w+20||p.y>h+40});
200
+ if(open>=0){var o=P[open];pop.style.left=o.x+'px';pop.style.top=o.y+'px'}}
201
+ function setZoom(nz,ax,ay){nz=Math.max(1,Math.min(max,nz));if(nz===z)return;var w=W(),h=H();ax=ax==null?w/2:ax;ay=ay==null?h/2:ay;var f=Math.pow(2,nz-z),wx=cx-w/2+ax,wy=cy-h/2+ay;cx=wx*f-ax+w/2;cy=wy*f-ay+h/2;z=nz;render()}
202
+ function show(i,center){if(open>=0){P[open].m.setAttribute('aria-pressed','false');P[open].li.removeAttribute('data-active')}open=i;var p=P[i];p.m.setAttribute('aria-pressed','true');p.li.setAttribute('data-active','');
203
+ if(center){var q=world(p.lat,p.lng,z);cx=q[0];cy=q[1]-40}else if(p.li.scrollIntoView){try{p.li.scrollIntoView({block:'nearest'})}catch(e){}}
204
+ pop.textContent='';var n=el('strong','');if(p.href){var a=el('a','',p.name);a.href=p.href;n.appendChild(a)}else n.textContent=p.name;pop.appendChild(n);if(p.detail)pop.appendChild(el('p','',p.detail));pop.hidden=false;render()}
205
+ var drag=null;pane.addEventListener('pointerdown',function(e){if(e.button!==0)return;drag={x:e.clientX,y:e.clientY,cx:cx,cy:cy};try{pane.setPointerCapture(e.pointerId)}catch(x){}});
206
+ pane.addEventListener('pointermove',function(e){if(!drag)return;cx=drag.cx-(e.clientX-drag.x);cy=drag.cy-(e.clientY-drag.y);render()});
207
+ pane.addEventListener('pointerup',function(){drag=null});pane.addEventListener('pointercancel',function(){drag=null});
208
+ pane.addEventListener('dblclick',function(e){var r=box.getBoundingClientRect();setZoom(z+1,e.clientX-r.left,e.clientY-r.top)});
209
+ box.addEventListener('wheel',function(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();var r=box.getBoundingClientRect();setZoom(z+(e.deltaY<0?1:-1),e.clientX-r.left,e.clientY-r.top)},{passive:false});
210
+ box.addEventListener('keydown',function(e){if(e.target!==box)return;var s=64,k=e.key;if(k==='ArrowLeft')cx-=s;else if(k==='ArrowRight')cx+=s;else if(k==='ArrowUp')cy-=s;else if(k==='ArrowDown')cy+=s;else if(k==='+'||k==='=')return e.preventDefault(),setZoom(z+1);else if(k==='-'||k==='_')return e.preventDefault(),setZoom(z-1);else if(k==='Escape'&&open>=0){pop.hidden=true;P[open].m.setAttribute('aria-pressed','false');P[open].li.removeAttribute('data-active');open=-1;return}else return;e.preventDefault();render()});
211
+ if(window.ResizeObserver)new ResizeObserver(function(){render()}).observe(box);else window.addEventListener('resize',render);
212
+ fit();render()}
213
+ function run(){var b=d.querySelectorAll('[data-sw-locmap]');for(var i=0;i<b.length;i++)setup(b[i])}
214
+ if(d.readyState==='loading')d.addEventListener('DOMContentLoaded',run);else run()})();`;
215
+ //# sourceMappingURL=location-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location-map.js","sourceRoot":"","sources":["../src/location-map.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,cAAc,EAAwF,MAAM,sBAAsB,CAAC;AAC5I,OAAO,EAAE,UAAU,EAAE,KAAK,EAAoB,MAAM,iBAAiB,CAAC;AA+BtE,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,aAAa,CAAU,CAAC;AAE5D,MAAM,KAAK,GAAG;IACZ,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;IAC7B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;CACrB,CAAC;AAEX,MAAM,OAAO,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAEhF,gHAAgH;AAChH,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAE5E,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,GAAW;IAClD,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,OAAO,uCAAuC,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;AACnF,CAAC;AAED,SAAS,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;uFA4CyD,CAAC"}
package/dist/meta.js CHANGED
@@ -129,6 +129,11 @@ export const blockMeta = {
129
129
  description: "The links from the home page to the page being viewed (Home, then each level above it, then the page), from the page's address (the titles of the pages at each level, as in the structured data) or from its place in the main menu. A navigation landmark named Breadcrumb with the page marked as current; nothing shows on the home page. Usually placed above the content of every page of a type with Structure → Placements, or with Site settings → Breadcrumbs.",
130
130
  aiHint: 'Use at the top of deep content pages (programs, departments, news, events), not on the home page or a landing page. Prefer a placement or the site setting over adding it to each page by hand. source "path" follows the address; "menu" follows the main menu.',
131
131
  },
132
+ LanguageSwitcher: {
133
+ summary: 'This page in other languages.',
134
+ description: "Links to the page being viewed in each of the site's languages, each named in its own language (no flags). A language the page is not translated into links to that language's home page with a short note. A navigation landmark with the current language marked; Links shows them in a row, Menu behind a button. Works without JavaScript. Nothing shows on a site with one language. Site settings → Languages can show the same switcher in the header of every page.",
135
+ aiHint: 'Use only on multilingual sites, near the top of a page or in a sidebar; prefer the header switcher in Site settings → Languages over adding it to each page. Do not add flags or a second switcher.',
136
+ },
132
137
  Divider: {
133
138
  summary: 'A line between sections.',
134
139
  description: 'A horizontal rule.',
@@ -159,6 +164,31 @@ export const blockMeta = {
159
164
  description: 'A month grid, a week, a day or a date list of the event occurrences in a collection, with a link to its iCal feed and, optionally, links for visitors to switch views; filled in by the server at render time.',
160
165
  aiHint: 'Use on an events page. Set collectionId to the key of an existing collection of a type with a daterange field (ask or leave empty if unknown); view "month" for a grid, "week" for seven days, "day" for one day\'s agenda, "list" for upcoming dates. Set switcher to true on the main events page.',
161
166
  },
167
+ Countdown: {
168
+ summary: 'Time left to a date.',
169
+ description: 'Days, hours and minutes (optionally seconds, with a pause button) to a date and time in the site\'s time zone or the block\'s, with a label above the numbers. The server renders the time left, so it is right without JavaScript, and a small script ticks it. When the time is reached it shows a message or hides. Screen readers get the time left as a sentence; announcements are off, at the end, or at most once a minute.',
170
+ aiHint: 'Use for one deadline or start time people act on: applications closing, an event starting, early registration ending. Set date as YYYY-MM-DD and time as HH:MM on a 24-hour clock (ask if unknown; never invent one), label as what happens ("Applications close in"), endedMessage as what is true afterwards. Leave timeZone empty (the site\'s), showSeconds false and announce "none" unless asked. Never more than one per page.',
171
+ },
172
+ Hours: {
173
+ summary: 'Opening hours and holidays.',
174
+ description: 'Hours of operation for one or more locations: weekly hours (a day, or Monday to Friday, weekends or every day, with an opening and a closing time; split days and hours past midnight), dated exceptions and holidays (closed or special hours, for every location or one), an "Open now, closes at 5:00 PM" status computed in the site\'s time zone and refreshed every minute, today marked in the weekly table, holiday hours for the next 60 days, and OpeningHoursSpecification structured data per location.',
175
+ aiHint: 'Use on contact, visit and office pages. One location per office with its real name; hours rows use day MO, TU, WE, TH, FR, SA, SU, weekdays, weekend or daily, and opens/closes as HH:MM on a 24-hour clock. A day with no row is closed. Holidays go in exceptions with date YYYY-MM-DD (endDate for a range), a label and closed true, or closed false with opens and closes; set location only when it applies to one location. Never invent hours: ask, or leave the defaults for the editor. schemaType GovernmentOffice for a city or county office, Library for a library.',
176
+ },
177
+ DocumentLibrary: {
178
+ summary: 'Files from a folder or tag.',
179
+ description: 'A list of media library documents (PDF, Word, Excel, PowerPoint and the like) from a folder (with its subfolders) or with a tag: a type badge, the title as the download link, the size, the date added and an optional description; sorted by title or date, optionally grouped by folder, tag or type, with an optional search box and type filter. Members-only files show only to members who may see them.',
180
+ aiHint: 'Use for forms, policies, reports, agendas and minutes kept in the media library. Set folder to the name of an existing media folder or tag to an existing media tag (ask if unknown; never invent one). groupBy "folder" when the folder has subfolders by year or topic. search true when it lists more than about fifteen files.',
181
+ },
182
+ Glossary: {
183
+ summary: 'Terms and definitions, A to Z.',
184
+ description: 'Terms and definitions under letter headings, with an A to Z navigation that greys out letters without terms, a link to each letter and each term, an optional search box, and DefinedTermSet structured data. The terms are typed in the block, or come from a content type (a field for the term and one for the definition, each linked to its page) or a vocabulary (term labels and descriptions).',
185
+ aiHint: 'Use for a page of jargon explained: academic terms, legal or program vocabulary. Keep source "inline" and put each term in terms with a one or two sentence definition in plain language. Use source "type" with typeKey and definitionField, or "vocabulary" with vocabulary, only when that content already exists. search true for more than about thirty terms. Use one Glossary per page.',
186
+ },
187
+ CampaignProgress: {
188
+ summary: 'Raised so far against a goal.',
189
+ description: 'A fundraising or participation goal as a bar with the amount raised, the goal, the percentage and optionally the number of gifts: typed numbers, the paid gifts of a payment form, or a source a module registers. Money in a currency or plain numbers with a unit. The bar is a progress bar with its value as text for screen readers; the numbers can count up as it comes into view, following the motion settings.',
190
+ aiHint: 'Use near a donation form or on a campaign page. With typed numbers set raised and goal (numbers, no symbols) and currency (usd); never invent figures: ask, or leave the defaults for the editor. When the site takes donations through a form with a payment, use source "form" with formKey. Plain numbers ("meals", "volunteers"): format "number" with unit. Leave countUp false unless asked.',
191
+ },
162
192
  MiniCalendar: {
163
193
  summary: 'A small month of events.',
164
194
  description: 'One month of a collection\'s events as a compact grid for a sidebar or a home page: days with events link to that day on the events page, or to the event.',
@@ -184,10 +214,15 @@ export const blockMeta = {
184
214
  description: 'An A/B test: slots a (control), b and optional c; visitors of a running experiment (Experiments in the admin) are assigned a variant by weight and the results screen reports conversions per variant.',
185
215
  aiHint: 'Use only when the user names an existing experiment key. Put the current content in "a" and the challenger in "b"; leave "c" empty unless asked. Never invent experiment keys.',
186
216
  },
217
+ LocationMap: {
218
+ summary: 'Places on a map, with a list.',
219
+ description: "The places of a collection (buildings, offices, facilities) as a list beside an interactive map: each place's details, a marker per place with its coordinates, category and keyword filters and a pager from the collection. Without JavaScript it is the list alone, each place with a link to it on OpenStreetMap. Tiles come from Site settings → Integrations → Map tiles (OpenStreetMap by default) and wait for consent when the provider sets cookies.",
220
+ aiHint: 'Use for a page that shows many places (a campus map, facilities, offices). Set collectionId to a collection of a type with latitude and longitude number fields; add a taxonomy filter for the category and a search filter. For one place use the Maps module\'s Map block or an Embed.',
221
+ },
187
222
  Collection: {
188
223
  summary: 'A list that updates itself.',
189
- description: 'A saved query (collection) of entities rendered as cards, a list or a grid, optionally with visitor filters (keyword, taxonomy, select, date range) and a pager; items are filled in by the server at render time.',
190
- aiHint: 'Use for "latest posts", "case studies" or any list that should update itself. Set collectionId to the key of an existing collection (ask or leave empty if unknown); never invent items, the server supplies them.',
224
+ description: 'A saved query (collection) of entities rendered as cards, a list, a grid or a table, optionally with visitor filters (keyword, taxonomy, select, checkboxes for several values, an A to Z letter bar, date range), a Results per page choice (pageSizes) and a pager; items are filled in by the server at render time.',
225
+ aiHint: 'Use for "latest posts", "case studies", a directory or a finder: any list that should update itself. Set collectionId to the key of an existing collection (ask or leave empty if unknown); never invent items, the server supplies them. For a directory, add a { kind: "letter" } filter on the name field; for facets such as delivery mode, { kind: "checkboxes" }; pageSizes "12, 24, 48" lets visitors pick how many show.',
191
226
  },
192
227
  RegistryBrowse: {
193
228
  summary: 'Search the package registry.',
package/dist/meta.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,SAAS,GAA8B;IAClD,IAAI,EAAE;QACJ,OAAO,EAAE,+BAA+B;QACxC,WAAW,EAAE,iPAAiP;QAC9P,MAAM,EACJ,+kBAA+kB;KACllB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,oBAAoB;QAC7B,WAAW,EAAE,iDAAiD;QAC9D,MAAM,EACJ,8RAA8R;KACjS;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,0BAA0B;QACnC,WAAW,EAAE,6GAA6G;QAC1H,MAAM,EACJ,oMAAoM;KACvM;IACD,KAAK,EAAE;QACL,OAAO,EAAE,0BAA0B;QACnC,WAAW,EAAE,yFAAyF;QACtG,MAAM,EACJ,4JAA4J;KAC/J;IACD,OAAO,EAAE;QACP,OAAO,EAAE,6BAA6B;QACtC,WAAW,EAAE,kMAAkM;QAC/M,MAAM,EACJ,iOAAiO;KACpO;IACD,KAAK,EAAE;QACL,OAA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AAE,yRAAyR;QACtS,MAAM,EAAE,wKAAwK;KACjL;IACD,WAAW,EAAE;QACX,OAAO,EAAE,wBAAwB;QACjC,WAAW,EAAE,2LAA2L;QACxM,MAAM,EAAE,4IAA4I;KACrJ;CACF,CAAC"}
package/dist/motion.js CHANGED
@@ -159,7 +159,7 @@ blocks.forEach(function(b){if(b.hasAttribute('data-motion-stagger'))[].slice.cal
159
159
  setVideos();setPlays();setMarquees();setStories();setModels();watchModels();watchLotties();watchScenes();
160
160
  if(sync()||!h.hasAttribute('data-sw-motion')||!('IntersectionObserver' in window)){blocks.forEach(arrive);return}
161
161
  var counters=[].slice.call(d.querySelectorAll('[data-motion-count]'));
162
- var cio=new IntersectionObserver(function(es){es.forEach(function(en){if(en.isIntersecting){cio.unobserve(en.target);count(en.target)}})},{threshold:0.4});
162
+ var cio=new IntersectionObserver(function(es){es.forEach(function(en){if(en.isIntersecting){cio.unobserve(en.target);en.target.setAttribute('data-motion-counted','');count(en.target)}})},{threshold:0.4});
163
163
  counters.forEach(function(c){cio.observe(c)});
164
164
  var vh=window.innerHeight||d.documentElement.clientHeight;
165
165
  var io=new IntersectionObserver(function(es){es.forEach(function(en){if(en.isIntersecting){arrive(en.target);io.unobserve(en.target)}})},{rootMargin:'0px 0px -8% 0px'});
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Campaign progress (docs/dev/utility-blocks.md): the amount raised against a goal as a bar, from numbers typed in the block or,
3
+ * through the server's resolver (`resolved`), from a payment form's paid gifts or a module's progress source. The bar is a
4
+ * `role="progressbar"` with its value as text, and the same sentence is visible. The optional count-up is the motion script's
5
+ * (`data-motion-count`), so it follows the brand's motion level, reduced motion and the Reduce motion switch. Server-safe and pure.
6
+ */
7
+ import type { ComponentConfig } from '@puckeditor/core';
8
+ export interface CampaignProgressProps {
9
+ title: string;
10
+ text: string;
11
+ /** Where the numbers come from: typed here, a payment form's paid gifts, or a module's progress source. */
12
+ source: 'manual' | 'form' | 'module';
13
+ raised: number;
14
+ goal: number;
15
+ /** The number of gifts (typed numbers only; a source answers its own). */
16
+ count: number;
17
+ /** source form: the form's key. */
18
+ formKey: string;
19
+ /** source module: the key a module registered with registerProgressSource. */
20
+ sourceKey: string;
21
+ format: 'currency' | 'number';
22
+ /** ISO 4217 (usd); a source's own currency wins. */
23
+ currency: string;
24
+ /** For plain numbers: what is counted ("meals", "volunteers"). */
25
+ unit: string;
26
+ showCount: boolean;
27
+ /** What a gift is called in the count ("gifts", "donors"). */
28
+ countLabel: string;
29
+ /** Numbers count up and the bar fills as the block comes into view (motion rules apply). */
30
+ countUp: boolean;
31
+ /** Added by the server's resolver, never stored. */
32
+ resolved?: {
33
+ raised: number;
34
+ goal: number;
35
+ currency: string | null;
36
+ count: number | null;
37
+ source: string;
38
+ missing?: boolean;
39
+ };
40
+ }
41
+ /** 12500 usd → "$12,500"; 12.5 → "$12.50"; plain numbers with grouping; an unknown currency falls back to plain. */
42
+ export declare function formatAmount(n: number, currency: string | null | undefined): string;
43
+ /** The percentage of the goal reached, whole, floored (99.6 percent is not yet 100); 0 without a goal. */
44
+ export declare function percentOf(raised: number, goal: number): number;
45
+ export declare const campaignProgressComponent: ComponentConfig<CampaignProgressProps>;
46
+ export declare const PROGRESS_CSS = "\n/* ---------- Campaign progress ---------- */\n.sw-progress__title { margin: 0 0 var(--sw-space-1); }\n.sw-progress__text { margin: 0 0 var(--sw-space-2); color: var(--sw-color-muted); max-width: 70ch; }\n.sw-progress__figures { margin: 0 0 var(--sw-space-1); font-size: 1.125rem; }\n.sw-progress__raised { font-family: var(--sw-font-heading); font-size: clamp(1.75rem, 5vw, 2.5rem); font-weight: 700; color: var(--sw-color-primary); font-variant-numeric: tabular-nums; }\n.sw-progress__bar { position: relative; height: 1rem; overflow: hidden; border-radius: 999px; background: var(--sw-color-surface); border: 1px solid var(--sw-color-border); }\n.sw-progress__fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(var(--sw-progress, 0)); background: var(--sw-color-primary); border-radius: inherit; }\n[dir=\"rtl\"] .sw-progress__fill { transform-origin: right center; }\n.sw-progress__meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sw-space-1); margin: var(--sw-space-1) 0 0; color: var(--sw-color-muted); font-variant-numeric: tabular-nums; }\n.sw-progress__pct { font-weight: 700; color: var(--sw-color-text); }\n@media (prefers-reduced-motion: no-preference) {\n html.sw-motion-ready:not(.sw-reduce-motion) .sw-progress[data-motion-count] .sw-progress__fill { transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1); }\n html.sw-motion-ready:not(.sw-reduce-motion) .sw-progress[data-motion-count]:not([data-motion-counted]) .sw-progress__fill { transform: scaleX(0); }\n}\n";