northants-design-system 3.2.2 → 3.3.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 (29) hide show
  1. package/build/index.d.ts +1 -3
  2. package/build/index.js +240 -135
  3. package/build/index.js.map +1 -1
  4. package/build/index.mjs.js +242 -135
  5. package/build/index.mjs.js.map +1 -1
  6. package/build/library/components/MapInfoWindow/MapInfoWindow.d.ts +4 -0
  7. package/build/library/components/MapInfoWindow/MapInfoWindow.types.d.ts +6 -0
  8. package/build/library/components/MapMarker/MapMarker.d.ts +2 -4
  9. package/build/library/components/MapMarker/MapMarker.types.d.ts +46 -0
  10. package/build/library/components/StaticMap/StaticMap.d.ts +6 -0
  11. package/build/library/components/StaticMap/StaticMap.types.d.ts +7 -3
  12. package/build/library/directory/DirectoryService/DirectoryService.storydata.d.ts +4 -0
  13. package/build/library/directory/DirectoryServiceMapMarker/DirectoryServiceMapMarker.d.ts +4 -0
  14. package/build/library/directory/DirectoryServiceMapMarker/DirectoryServiceMapMarker.types.d.ts +45 -0
  15. package/build/library/directory/DirectoryServiceMapMarkerSet/DirectoryServiceMapMarkerSet.d.ts +4 -0
  16. package/build/library/directory/DirectoryServiceMapMarkerSet/DirectoryServiceMapMarkerSet.storydata.d.ts +5 -0
  17. package/build/library/directory/DirectoryServiceMapMarkerSet/DirectoryServiceMapMarkerSet.types.d.ts +53 -0
  18. package/build/library/directory/DirectoryServiceStaticMap/DirectoryServiceStaticMap.d.ts +4 -0
  19. package/build/library/directory/DirectoryServiceStaticMap/DirectoryServiceStaticMap.types.d.ts +11 -0
  20. package/package.json +4 -5
  21. package/build/library/slices/LinkBlock/LinkBlock.d.ts +0 -4
  22. package/build/library/slices/LinkBlock/LinkBlock.types.d.ts +0 -36
  23. package/build/library/structure/CludoNewsSearch/CludoNewsDateSearch.d.ts +0 -6
  24. package/build/library/structure/CludoNewsSearch/CludoNewsResultCount.d.ts +0 -3
  25. package/build/library/structure/CludoNewsSearch/CludoNewsSearch.d.ts +0 -4
  26. package/build/library/structure/CludoNewsSearch/CludoNewsSearch.test.d.ts +0 -1
  27. package/build/library/structure/CludoNewsSearch/CludoNewsSearch.types.d.ts +0 -18
  28. package/build/library/structure/CludoNewsSearch/CludoNewsSort.d.ts +0 -3
  29. /package/build/library/{slices/LinkBlock/LinkBlock.test.d.ts → components/MapInfoWindow/MapInfoWindow.test.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { cloneElement, Component, useState, useEffect, useId, useRef, useContext, useCallback, useEffectEvent, createContext } from 'react';
2
+ import React__default, { cloneElement, Component, useState, useEffect, useId, useRef, useContext, useCallback, useEffectEvent, isValidElement, useMemo, createContext } from 'react';
3
3
  import styled, { css, useTheme, ThemeContext, ThemeProvider, createGlobalStyle } from 'styled-components';
4
4
  import require$$1 from 'path';
5
5
  import require$$3 from 'url';
@@ -7,7 +7,7 @@ import require$$0$1 from 'fs';
7
7
  import axios from 'axios';
8
8
  import { useForm, Controller } from 'react-hook-form';
9
9
  import { useAutocomplete, SearchInput, SaytSuggestion, autocompleteHandleInputKeyDown, autocompleteHandleInputBlur, autocompleteHandleInputChange, CludoWrapper, ResultCount, DidYouMean, ResultsList, CustomResult, ResultImage, ResultTitle, ResultDescription, ResultBadge, ResultUrl, Pagination as Pagination$1, FacetGroup, StandardFacet } from '@cludosearch/cludo-search-components/ssr';
10
- import { Wrapper as Wrapper$5 } from '@googlemaps/react-wrapper';
10
+ import { useAdvancedMarkerRef, AdvancedMarker, Pin, InfoWindow, APIProvider, Map as Map$1 } from '@vis.gl/react-google-maps';
11
11
 
12
12
  /******************************************************************************
13
13
  Copyright (c) Microsoft Corporation.
@@ -3716,7 +3716,7 @@ var Autocomplete = function (_a) {
3716
3716
  })));
3717
3717
  };
3718
3718
 
3719
- const Container$1v = styled.div`
3719
+ const Container$1u = styled.div`
3720
3720
  display: block;
3721
3721
  `;
3722
3722
 
@@ -3802,7 +3802,7 @@ var BackToTop = function (_a) {
3802
3802
  useEffect(function () {
3803
3803
  window.addEventListener('scroll', toggleVisible);
3804
3804
  });
3805
- return (React__default.createElement(Container$1v, { "data-testid": "BackToTop" }, isActive && (React__default.createElement(BackToTopButton, { onClick: scrollToTop, "$visible": visible, "data-testid": "BackToTopButton", type: "button", "aria-label": "Go to the top of the page" },
3805
+ return (React__default.createElement(Container$1u, { "data-testid": "BackToTop" }, isActive && (React__default.createElement(BackToTopButton, { onClick: scrollToTop, "$visible": visible, "data-testid": "BackToTopButton", type: "button", "aria-label": "Go to the top of the page" },
3806
3806
  React__default.createElement(ChevronIcon, { colourFill: theme.theme_vars.colours.white, direction: "up" })))));
3807
3807
  };
3808
3808
 
@@ -3895,7 +3895,7 @@ var Button$5 = function (_a) {
3895
3895
  return (React__default.createElement(StyledButton$1, __assign({ className: ["button--".concat(size), mode].join(' ') }, href, { title: title ? title : text, "$colourOverride": colourOverride && colourOverride }, props), text ? text : children));
3896
3896
  };
3897
3897
 
3898
- const Container$1u = styled.div`
3898
+ const Container$1t = styled.div`
3899
3899
  display: block;
3900
3900
  background-color: ${(props) =>
3901
3901
  props.$isOpen ? props.theme.theme_vars.colours.positive : props.theme.theme_vars.colours.negative}16;
@@ -19593,7 +19593,7 @@ var ConsultationStatus = function (_a) {
19593
19593
  detail: new Date(closeDate).toLocaleDateString('en-GB'),
19594
19594
  },
19595
19595
  ];
19596
- return (React__default.createElement(Container$1u, { "data-testid": "ConsultationStatus", "$isOpen": isOpen },
19596
+ return (React__default.createElement(Container$1t, { "data-testid": "ConsultationStatus", "$isOpen": isOpen },
19597
19597
  React__default.createElement(SummaryList, { terms: terms, hasBorders: false, hasMargin: false, hasWrapOnMobile: false })));
19598
19598
  };
19599
19599
 
@@ -21806,7 +21806,7 @@ var DynamicIcon = function (_a) {
21806
21806
  React__default.createElement(DynamicComponent, { name: icon, isHover: true }))))));
21807
21807
  };
21808
21808
 
21809
- const Container$1t = styled.div`
21809
+ const Container$1s = styled.div`
21810
21810
  display: block;
21811
21811
  padding: ${(props) => props.theme.theme_vars.spacingSizes.small};
21812
21812
  border-bottom: ${(props) => (props.$hasBorder ? `1px solid ${props.theme.theme_vars.colours.grey}` : 'none')};
@@ -21978,94 +21978,13 @@ var formatDateRange = function (startDate, endDate) {
21978
21978
 
21979
21979
  var EventDetails = function (_a) {
21980
21980
  var startTime = _a.startTime, endTime = _a.endTime, location = _a.location, _b = _a.hasBorder, hasBorder = _b === void 0 ? true : _b, _c = _a.hasMargin, hasMargin = _c === void 0 ? true : _c;
21981
- return (React__default.createElement(Container$1t, { "data-testid": "EventDetails", "$hasBorder": hasBorder, "$hasMargin": hasMargin },
21981
+ return (React__default.createElement(Container$1s, { "data-testid": "EventDetails", "$hasBorder": hasBorder, "$hasMargin": hasMargin },
21982
21982
  React__default.createElement(EventRow, null,
21983
21983
  React__default.createElement(HeadingWithIcon, { icon: "events", level: 4, text: formatDateRange(startTime, endTime), hasHover: false })),
21984
21984
  React__default.createElement(EventRow, null,
21985
21985
  React__default.createElement(HeadingWithIcon, { icon: "address", level: 4, text: location, hasHover: false }))));
21986
21986
  };
21987
21987
 
21988
- const Container$1s = styled.div`
21989
- display: flex;
21990
- width: 100%;
21991
- min-height: 400px;
21992
- align-items: stretch;
21993
- align-content: stretch;
21994
-
21995
- & > div {
21996
- width: 100%;
21997
- }
21998
- `;
21999
-
22000
- /**
22001
- * An interactive Google Map which can accept MapMarkers as children
22002
- */
22003
- var Map$1 = function (_a) {
22004
- var center = _a.center, zoom = _a.zoom, children = _a.children;
22005
- var ref = React__default.useRef(null);
22006
- var _b = React__default.useState(), map = _b[0], setMap = _b[1];
22007
- React__default.useEffect(function () {
22008
- if (ref.current && !map) {
22009
- setMap(new window.google.maps.Map(ref.current, { center: center, zoom: zoom }));
22010
- }
22011
- }, [ref, map]);
22012
- return (React__default.createElement(Container$1s, { "data-testid": "Map" },
22013
- React__default.createElement("div", { ref: ref }),
22014
- React__default.Children.map(children, function (child) {
22015
- if (React__default.isValidElement(child)) {
22016
- // set the map prop on the child component
22017
- // @ts-ignore
22018
- return React__default.cloneElement(child, { map: map });
22019
- }
22020
- })));
22021
- };
22022
-
22023
- /**
22024
- * A Google Maps marker to be placed inside a Map component
22025
- */
22026
- var MapMarker = function (options) {
22027
- var _a = React__default.useState(), marker = _a[0], setMarker = _a[1];
22028
- var theme = useTheme();
22029
- var icon = {
22030
- path: 'M19.7,5.6c-0.1,0-0.5,0.1-0.9,0.1c-3.3,0.4-6.5,2-8.9,4.4c-2.6,2.6-4.2,5.9-4.6,9.6c-0.1,1,0,3.1,0.1,4.1c0.3,2.1,1.1,4.2,2.3,6.6c0.9,1.6,1.6,2.9,4.2,7c0.9,1.4,1.9,3.1,2.6,4.2c2.3,3.9,4.1,7.9,5.4,11.9c0.2,0.6,0.3,0.8,0.6,0.9c0.5,0.2,1.1,0.1,1.4-0.3c0.1-0.1,0.2-0.5,0.4-0.9c1.1-3.3,2.5-6.5,4.2-9.5c1.2-2.2,2-3.6,4.4-7.4c1.7-2.7,2.3-3.6,2.9-4.8c1.6-2.9,2.5-5.3,2.9-7.8c0.2-1,0.2-3.1,0.1-4.1c-0.2-1.5-0.5-3-1-4.2c-2.1-5.2-6.8-8.9-12.4-9.8C22.9,5.6,20.2,5.5,19.7,5.6z',
22031
- fillColor: "".concat(theme.theme_vars.colours.action_dark),
22032
- fillOpacity: 1,
22033
- anchor: new google.maps.Point(40, 60),
22034
- labelOrigin: new google.maps.Point(21, 25),
22035
- };
22036
- var mergedOptions = __assign(__assign({}, options), { anchorPoint: new google.maps.Point(-5, -40), icon: icon, label: {
22037
- text: typeof options.label === 'string' ? options.label : options.label.text,
22038
- color: 'white',
22039
- }, position: options.position, title: options.title });
22040
- React__default.useEffect(function () {
22041
- if (!marker) {
22042
- setMarker(new google.maps.Marker());
22043
- }
22044
- // remove marker from map on unmount
22045
- return function () {
22046
- if (marker) {
22047
- marker.setMap(null);
22048
- }
22049
- };
22050
- }, [marker]);
22051
- React__default.useEffect(function () {
22052
- if (marker) {
22053
- var infoWindow_1 = new google.maps.InfoWindow({
22054
- content: "<strong>".concat(options.title, "</strong>"),
22055
- ariaLabel: options.title,
22056
- });
22057
- marker.setOptions(mergedOptions);
22058
- marker.addListener('click', function () {
22059
- infoWindow_1.open({
22060
- anchor: marker,
22061
- map: options.map,
22062
- });
22063
- });
22064
- }
22065
- }, [marker, options]);
22066
- return null;
22067
- };
22068
-
22069
21988
  const Container$1r = styled.div`
22070
21989
  ${(props) => props.theme.fontStyles};
22071
21990
  display: block;
@@ -24023,6 +23942,51 @@ var CookieBanner = function (_a) {
24023
23942
  React__default.createElement(CookieHide, { onClick: hideCookiesConfirmationBanner, "aria-controls": "CookieBannerAccepted", "aria-hidden": "false" }, "Hide"))))));
24024
23943
  };
24025
23944
 
23945
+ /**
23946
+ * A function to validate whether a given latitude/longitude pair are valid
23947
+ * Ths function can be used to prevent untrusted backend/CMS values from
23948
+ * injecting extra query parameters into the Static Maps request.
23949
+ */
23950
+ var isValidLatLng = function (lat, lng) {
23951
+ var latNum = Number(lat);
23952
+ var lngNum = Number(lng);
23953
+ return (typeof lat !== 'undefined' &&
23954
+ typeof lng !== 'undefined' &&
23955
+ lat !== null &&
23956
+ lng !== null &&
23957
+ "".concat(lat).trim() !== '' &&
23958
+ "".concat(lng).trim() !== '' &&
23959
+ Number.isFinite(latNum) &&
23960
+ Number.isFinite(lngNum) &&
23961
+ latNum >= -90 &&
23962
+ latNum <= 90 &&
23963
+ lngNum >= -180 &&
23964
+ lngNum <= 180);
23965
+ };
23966
+ /**
23967
+ * Constrains a marker label to a single character in the API's allowed
23968
+ * set (A-Z, 0-9). Returns an empty string if nothing valid is supplied.
23969
+ */
23970
+ var sanitiseLabel = function (label) {
23971
+ if (!label) {
23972
+ return '';
23973
+ }
23974
+ var cleaned = label.replace(/[^A-Z0-9]/gi, '');
23975
+ return cleaned.length > 0 ? cleaned.charAt(0).toUpperCase() : '';
23976
+ };
23977
+ /**
23978
+ * Builds a single, fully URL-encoded `&markers=...` segment. Encoding the
23979
+ * whole value ensures colour/size/label (whose TypeScript unions only
23980
+ * apply at compile time) cannot break out of their parameter.
23981
+ */
23982
+ var buildMarkerSegment = function (size, colour, label, latitude, longitude) {
23983
+ var parts = ["size:".concat(size), "color:".concat(colour)];
23984
+ if (label) {
23985
+ parts.push("label:".concat(label));
23986
+ }
23987
+ parts.push("".concat(latitude, ",").concat(longitude));
23988
+ return "&markers=".concat(encodeURIComponent(parts.join('|')));
23989
+ };
24026
23990
  /**
24027
23991
  * A static Google map with optional markers
24028
23992
  */
@@ -24031,21 +23995,29 @@ var StaticMap = function (_a) {
24031
23995
  var centre = _a.centre, imageAltText = _a.imageAltText, _c = _a.mapMarkers, mapMarkers = _c === void 0 ? [] : _c, _d = _a.mapType, mapType = _d === void 0 ? 'roadmap' : _d, _e = _a.size, size = _e === void 0 ? '640x320' : _e, _f = _a.zoom, zoom = _f === void 0 ? 14 : _f;
24032
23996
  var apiKey = (_b = process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY) !== null && _b !== void 0 ? _b : '';
24033
23997
  var markerPath = mapMarkers
23998
+ .filter(function (mapMarker) { return isValidLatLng(mapMarker.lat, mapMarker.lng); })
24034
23999
  .map(function (mapMarker) {
24035
24000
  var _a, _b;
24036
- var size = (_a = mapMarker.size) !== null && _a !== void 0 ? _a : 'normal';
24037
- var colour = (_b = mapMarker.colour) !== null && _b !== void 0 ? _b : 'red';
24038
- var label = mapMarker.label ? "%7Clabel:".concat(mapMarker.label) : '';
24039
- return "&markers=size:".concat(size, "%7Ccolor:").concat(colour).concat(label, "%7C").concat(mapMarker.lat, ",").concat(mapMarker.lng);
24001
+ return buildMarkerSegment((_a = mapMarker.size) !== null && _a !== void 0 ? _a : 'normal', (_b = mapMarker.colour) !== null && _b !== void 0 ? _b : 'red', sanitiseLabel(mapMarker.label), String(mapMarker.lat), String(mapMarker.lng));
24040
24002
  })
24041
24003
  .join('');
24004
+ // Build the base parameters via URLSearchParams so that centre/size/zoom/
24005
+ // maptype are percent-encoded and cannot inject additional query params.
24006
+ var params = new URLSearchParams({
24007
+ center: centre,
24008
+ size: size,
24009
+ zoom: "".concat(zoom),
24010
+ maptype: mapType,
24011
+ key: apiKey,
24012
+ });
24013
+ var mapSrc = "https://maps.googleapis.com/maps/api/staticmap?".concat(params.toString()).concat(markerPath);
24042
24014
  return (React__default.createElement(Container$1i, { "data-testid": "StaticMap" },
24043
24015
  React__default.createElement(Message$1, null,
24044
24016
  React__default.createElement("span", null,
24045
24017
  "To interact with the map, you need to ",
24046
24018
  React__default.createElement(Cookies, { onClick: AcceptCookies }, "accept cookies"),
24047
24019
  ".")),
24048
- React__default.createElement(MapImage, { src: "https://maps.googleapis.com/maps/api/staticmap?center=".concat(centre, "&size=").concat(size, "&zoom=").concat(zoom, "&maptype=").concat(mapType).concat(markerPath, "&key=").concat(apiKey), alt: imageAltText })));
24020
+ React__default.createElement(MapImage, { src: mapSrc, alt: imageAltText })));
24049
24021
  };
24050
24022
 
24051
24023
  /**
@@ -35950,23 +35922,150 @@ var ServiceContact = function (_a) {
35950
35922
 
35951
35923
  const Container$4 = styled.div`
35952
35924
  display: block;
35925
+
35926
+ position: relative;
35927
+ padding-bottom: 56.25%; /* 16:9 */
35928
+ height: 0;
35953
35929
  `;
35954
35930
 
35931
+ var MapMarker = function (_a) {
35932
+ var _b, _c, _d, _e, _f;
35933
+ var advancedMarkerElementOptions = _a.advancedMarkerElementOptions, pinElementOptions = _a.pinElementOptions, infoWindowContent = _a.infoWindowContent, _g = _a.markerIndex, markerIndex = _g === void 0 ? 0 : _g, currentlyOpenInfoWindow = _a.currentlyOpenInfoWindow, setCurrentlyOpenInfowindow = _a.setCurrentlyOpenInfowindow, initiateResetOfAnotherMarker = _a.initiateResetOfAnotherMarker, _h = _a.resetSignal, resetSignal = _h === void 0 ? 0 : _h;
35934
+ // Get a Marker reference to be used to associated this 'AdvancedMarker' to its Infowindow
35935
+ var _j = useAdvancedMarkerRef(), markerRef = _j[0], marker = _j[1];
35936
+ var _k = useState(false), infowindowIsOpen = _k[0], setInfowindowIsOpen = _k[1];
35937
+ var themeContext = useContext(ThemeContext);
35938
+ // Monitor for a reset signal (i.e. a request for Infowindow closure) from the parent map...
35939
+ useEffect(function () {
35940
+ if (resetSignal == 0)
35941
+ return; // Ignore first initialisation of this component
35942
+ if (!infowindowIsOpen)
35943
+ return; // If the Infowindow is already closed, ignore requests to close it
35944
+ setInfowindowIsOpen(false); // Otherwise, close the Infowindow as instructed by the parent map
35945
+ }, [resetSignal]);
35946
+ // Establish the position in-which this AdvancedMarker is to be located..
35947
+ // using the coordinates of Northampton's Market Square as a default if none are provided
35948
+ var position;
35949
+ // If GPS coordinates have been specified via the 'AdvancedMarkerElementOptions' parameter
35950
+ if (((_b = advancedMarkerElementOptions === null || advancedMarkerElementOptions === void 0 ? void 0 : advancedMarkerElementOptions.position) === null || _b === void 0 ? void 0 : _b.lat) &&
35951
+ ((_c = advancedMarkerElementOptions === null || advancedMarkerElementOptions === void 0 ? void 0 : advancedMarkerElementOptions.position) === null || _c === void 0 ? void 0 : _c.lng)) {
35952
+ // then use those GPS coordinates...
35953
+ position = advancedMarkerElementOptions.position;
35954
+ }
35955
+ else {
35956
+ return React__default.createElement(React__default.Fragment, null);
35957
+ }
35958
+ // Function to handle the Marker being clicked...
35959
+ var handleMarkerClick = function (markerIndex) {
35960
+ // If this marker doesn't currently have its Infowindow open...
35961
+ if (!infowindowIsOpen) {
35962
+ // ... then open its InfoWindow...
35963
+ setInfowindowIsOpen(true);
35964
+ // Then, if another marker has its window open....
35965
+ if (currentlyOpenInfoWindow != -1 && currentlyOpenInfoWindow != markerIndex) {
35966
+ // ...notify the Parent map that that other marker
35967
+ // needs to close its Infowindow...
35968
+ initiateResetOfAnotherMarker(currentlyOpenInfoWindow);
35969
+ }
35970
+ // Finally, notify the parent that this Marker's Infowindow is open...
35971
+ setCurrentlyOpenInfowindow(markerIndex);
35972
+ }
35973
+ else {
35974
+ // Otherwise, if this Marker's InfoWindow IS Open...
35975
+ // ...then close this Marker's Infowindow
35976
+ setInfowindowIsOpen(false);
35977
+ // ... and notify the parent map it has been closed
35978
+ setCurrentlyOpenInfowindow(-1);
35979
+ }
35980
+ };
35981
+ // Function to handle the 'Infowindow' close button being clicked on...
35982
+ var handleInfoWindowCloseClick = function () {
35983
+ // Record the fact that the Infowindow has been closed...
35984
+ setInfowindowIsOpen(false);
35985
+ // and notify the Parent map that the Infowindow has been closed...
35986
+ setCurrentlyOpenInfowindow(-1);
35987
+ };
35988
+ if (!infoWindowContent && (advancedMarkerElementOptions === null || advancedMarkerElementOptions === void 0 ? void 0 : advancedMarkerElementOptions.title)) {
35989
+ infoWindowContent = React__default.createElement("span", null, advancedMarkerElementOptions.title);
35990
+ }
35991
+ // Return, to the Parent component, an appropriately customized Advanced Marker
35992
+ // with an appropriately customised and populated Infowindow
35993
+ return (React__default.createElement(React__default.Fragment, { key: markerIndex },
35994
+ React__default.createElement(AdvancedMarker, __assign({ ref: markerRef, position: position, clickable: true }, advancedMarkerElementOptions, { title: (advancedMarkerElementOptions === null || advancedMarkerElementOptions === void 0 ? void 0 : advancedMarkerElementOptions.title) || '', anchorLeft: (_d = advancedMarkerElementOptions === null || advancedMarkerElementOptions === void 0 ? void 0 : advancedMarkerElementOptions.anchorLeft) !== null && _d !== void 0 ? _d : undefined, anchorTop: (_e = advancedMarkerElementOptions === null || advancedMarkerElementOptions === void 0 ? void 0 : advancedMarkerElementOptions.anchorTop) !== null && _e !== void 0 ? _e : undefined, collisionBehavior: (_f = advancedMarkerElementOptions === null || advancedMarkerElementOptions === void 0 ? void 0 : advancedMarkerElementOptions.collisionBehavior) !== null && _f !== void 0 ? _f : undefined, onClick: function () { return handleMarkerClick(markerIndex); } }),
35995
+ React__default.createElement(Pin, __assign({}, __assign({ glyphColor: themeContext.theme_vars.colours.white, background: themeContext.theme_vars.colours.action_dark, borderColor: themeContext.theme_vars.colours.black }, pinElementOptions)))),
35996
+ isValidElement(infoWindowContent) && infowindowIsOpen && marker && (React__default.createElement(InfoWindow, { anchor: marker, onCloseClick: function () {
35997
+ handleInfoWindowCloseClick();
35998
+ } }, infoWindowContent))));
35999
+ };
36000
+
35955
36001
  var DirectoryMap = function (_a) {
35956
- var _b, _c;
36002
+ var _b, _c, _d, _e;
35957
36003
  var allowCookies = _a.allowCookies, mapProps = _a.mapProps;
36004
+ // Determine if Cookies have been accepted (so that, if not, a Static Map can be displayed)
35958
36005
  var cookiesAccepted = wereCookiesAccepted(allowCookies);
36006
+ // Obtain Our Google Maps API Key
35959
36007
  var apiKey = (_b = process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY) !== null && _b !== void 0 ? _b : '';
35960
- var latLong = mapProps.centre.split(',');
35961
- var center = {
35962
- lat: parseFloat(latLong[0]),
35963
- lng: parseFloat(latLong[1]),
36008
+ // Get a handle to the current theme context, so that we can style the Map Markers appropriately
36009
+ var themeContext = useContext(ThemeContext);
36010
+ // Prepare to record which Marker on the map currently has its Infowindow open (and change as necessary)
36011
+ var _f = useState(-1), currentlyOpenInfoWindow = _f[0], setCurrentlyOpenInfowindow = _f[1];
36012
+ // Establish an array of Reset 'Signals' so that only one Marker can have its Infowindow open at once
36013
+ var _g = useState(), signals = _g[0], setSignals = _g[1];
36014
+ // Determine which 'Map Markers' are "renderable", by filtering out values that don't have valid GPS coordinates
36015
+ var mapMarkersThatAreRenderable = useMemo(function () { var _a; return ((_a = mapProps === null || mapProps === void 0 ? void 0 : mapProps.mapMarkers) !== null && _a !== void 0 ? _a : []).filter(function (mapMarkers) { return isValidLatLng(mapMarkers.lat, mapMarkers.lng); }); }, [mapProps]);
36016
+ // Monitor for a reset signal (i.e. a request for Infowindow closure) from the parent map...
36017
+ useEffect(function () {
36018
+ // Create a new appropriately-sized copy of the 'reset signals' array and fill it with zeroes...
36019
+ setSignals(function () { return Array(mapMarkersThatAreRenderable.length).fill(0); });
36020
+ }, [mapProps, mapMarkersThatAreRenderable]);
36021
+ // Grab and parse the GPS Coordinates of the mapProps to deduce this Map's centre...
36022
+ // using the coordinates of Northampton's Market Square as a default if none are provided
36023
+ var center = { lat: 52.23555414368587, lng: -0.8957390701320571 };
36024
+ var latLong = ((_c = mapProps.centre) !== null && _c !== void 0 ? _c : '').split(',');
36025
+ if (isValidLatLng(latLong[0], latLong[1])) {
36026
+ center = { lat: parseFloat(latLong[0]), lng: parseFloat(latLong[1]) };
36027
+ }
36028
+ // Fit in all available space, and maintain a 16:9 aspect ratio.
36029
+ var style = { position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' };
36030
+ // Define a Function to allow Markers (or sets of Markers) to close other Marker's Infowindows on the same map...
36031
+ var initiateResetOfAnotherMarker = function (markerIndex) {
36032
+ if (markerIndex == -1)
36033
+ return; // Ignore nonsensical requests
36034
+ if (!signals || signals.length == 0)
36035
+ return; // Ignore first initialisation of the 'signals' array
36036
+ // Duplicate the 'signals' array...
36037
+ var duplicateArray = signals.slice();
36038
+ // Accumulate the counter for the specific Marker that needs to close its Infowindow
36039
+ duplicateArray[markerIndex]++;
36040
+ // Replace the signals array with the duplicate one just created...
36041
+ setSignals(duplicateArray);
35964
36042
  };
35965
- return (React__default.createElement(Container$4, { "data-testid": "DirectoryMap" }, cookiesAccepted ? (React__default.createElement(React__default.Fragment, null,
35966
- React__default.createElement(Wrapper$5, { apiKey: apiKey },
35967
- React__default.createElement(Map$1, { center: center, zoom: (_c = mapProps.zoom) !== null && _c !== void 0 ? _c : 14 }, mapProps.mapMarkers.map(function (marker, index) {
35968
- var _a;
35969
- return (React__default.createElement(MapMarker, { position: { lat: marker.lat, lng: marker.lng }, label: marker.label, title: (_a = marker.title) !== null && _a !== void 0 ? _a : '', key: index }));
36043
+ // Define a Function to manage what happens to InfoWindows when the Map is clicked on...
36044
+ var handleMapClick = function () {
36045
+ if (currentlyOpenInfoWindow == -1)
36046
+ return; // Nothing to do if no Infowindows are open..
36047
+ if (!signals || signals.length == 0)
36048
+ return; // Ignore first initialisation of this map's 'signals' array
36049
+ // Duplicate the 'signals' array...
36050
+ var duplicateArray = signals.slice();
36051
+ // Accumulate the counter for the Marker that needs to close its Infowindow
36052
+ duplicateArray[currentlyOpenInfoWindow]++;
36053
+ // Replace the signals array with the duplicated that was just created...
36054
+ setSignals(duplicateArray);
36055
+ // Reset the currently open in this Directory Map's infowindow tracker
36056
+ setCurrentlyOpenInfowindow(-1);
36057
+ };
36058
+ return (React__default.createElement(Container$4, { "data-testid": "DirectoryMap" }, cookiesAccepted ? (React__default.createElement(APIProvider, { apiKey: apiKey },
36059
+ React__default.createElement(Map$1, { defaultCenter: center, defaultZoom: (_d = mapProps.zoom) !== null && _d !== void 0 ? _d : 14, mapId: 'DEMO_MAP_ID', gestureHandling: "greedy", style: style, onClick: function () { return handleMapClick(); } }, ((_e = signals === null || signals === void 0 ? void 0 : signals.length) !== null && _e !== void 0 ? _e : 0) >= 1 &&
36060
+ (mapMarkersThatAreRenderable === null || mapMarkersThatAreRenderable === void 0 ? void 0 : mapMarkersThatAreRenderable.map(function (marker, markerIndex) {
36061
+ var _a, _b;
36062
+ return (React__default.createElement(MapMarker, { key: markerIndex, advancedMarkerElementOptions: {
36063
+ position: { lat: marker.lat, lng: marker.lng },
36064
+ title: (_a = marker.title) !== null && _a !== void 0 ? _a : '',
36065
+ }, pinElementOptions: {
36066
+ glyphText: marker.label,
36067
+ glyphColor: themeContext.theme_vars.colours.white,
36068
+ }, infoWindowContent: marker.infoWindowContent ? marker.infoWindowContent : undefined, markerIndex: markerIndex, currentlyOpenInfoWindow: currentlyOpenInfoWindow, setCurrentlyOpenInfowindow: setCurrentlyOpenInfowindow, resetSignal: (_b = signals === null || signals === void 0 ? void 0 : signals[markerIndex]) !== null && _b !== void 0 ? _b : 0, initiateResetOfAnotherMarker: initiateResetOfAnotherMarker }));
35970
36069
  }))))) : (React__default.createElement(StaticMap, __assign({}, mapProps)))));
35971
36070
  };
35972
36071
 
@@ -36133,15 +36232,20 @@ var getIcon = function (profile) {
36133
36232
  };
36134
36233
 
36135
36234
  var DirectoryService = function (_a) {
36136
- var _b, _c, _d, _e;
36137
- var id = _a.id, name = _a.name, accreditations = _a.accreditations, _f = _a.ageInMonths, ageInMonths = _f === void 0 ? false : _f, description = _a.description, descriptionElement = _a.descriptionElement, eligibilitys = _a.eligibilitys, email = _a.email, fees = _a.fees, languages = _a.languages, organization = _a.organization, regular_schedules = _a.regular_schedules, contacts = _a.contacts, service_areas = _a.service_areas, service_at_locations = _a.service_at_locations, service_social_profiles = _a.service_social_profiles, service_taxonomys = _a.service_taxonomys, taxonomiesToShow = _a.taxonomiesToShow, url = _a.url, uploads = _a.uploads, shortListPath = _a.shortListPath;
36138
- var labelLetters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'];
36139
- var _g = useState(false), notServer = _g[0], setNotServer = _g[1];
36235
+ var _b, _c;
36236
+ var id = _a.id, name = _a.name, accreditations = _a.accreditations, _d = _a.ageInMonths, ageInMonths = _d === void 0 ? false : _d, description = _a.description, descriptionElement = _a.descriptionElement, eligibilitys = _a.eligibilitys, email = _a.email, fees = _a.fees, languages = _a.languages, organization = _a.organization, regular_schedules = _a.regular_schedules, contacts = _a.contacts, service_areas = _a.service_areas, service_at_locations = _a.service_at_locations, service_social_profiles = _a.service_social_profiles, service_taxonomys = _a.service_taxonomys, taxonomiesToShow = _a.taxonomiesToShow, url = _a.url, uploads = _a.uploads, shortListPath = _a.shortListPath;
36237
+ var letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
36238
+ var labelLetters = letters.split('');
36239
+ var _e = useState(false), notServer = _e[0], setNotServer = _e[1];
36140
36240
  var themeContext = useContext(ThemeContext);
36141
36241
  var favourites = useDirectoryShortListContext().favourites.favourites;
36142
36242
  useEffect(function () {
36143
36243
  setNotServer(true);
36144
36244
  }, []);
36245
+ // The visitable, geocoded locations for this service. Each becomes its own
36246
+ // map pin, all sharing the same `directoryServiceProps`, so a multi-location
36247
+ // service shows every location without duplicating the service data.
36248
+ var mapLocations = (service_at_locations !== null && service_at_locations !== void 0 ? service_at_locations : []).filter(function (location) { return location.is_visitable != false && isValidLatLng(location.latitude, location.longitude); });
36145
36249
  return (React__default.createElement(Container$6, { "data-testid": "DirectoryService" },
36146
36250
  React__default.createElement(Row$1, null,
36147
36251
  React__default.createElement(Column, { small: "full", medium: "full", large: "full" },
@@ -36158,7 +36262,7 @@ var DirectoryService = function (_a) {
36158
36262
  " Shortlist (",
36159
36263
  favourites.length,
36160
36264
  ")")),
36161
- React__default.createElement(DirectoryAddToShortList, { id: id, name: name, snippet: transformSnippet(description, 350), email: email, website: url, phone: (_c = (_b = contacts === null || contacts === void 0 ? void 0 : contacts[0]) === null || _b === void 0 ? void 0 : _b.phones) === null || _c === void 0 ? void 0 : _c.flatMap(function (phone) { return phone.number; }).join(', '), addresses: service_at_locations.flatMap(function (location) {
36265
+ React__default.createElement(DirectoryAddToShortList, { id: id, name: name, snippet: transformSnippet(description, 350), email: email, website: url, phone: (_c = (_b = contacts === null || contacts === void 0 ? void 0 : contacts[0]) === null || _b === void 0 ? void 0 : _b.phones) === null || _c === void 0 ? void 0 : _c.flatMap(function (phone) { return phone.number; }).join(', '), addresses: service_at_locations === null || service_at_locations === void 0 ? void 0 : service_at_locations.flatMap(function (location) {
36162
36266
  return location.physical_addresses;
36163
36267
  }), fees: fees })))))),
36164
36268
  service_at_locations.filter(function (location) {
@@ -36179,21 +36283,15 @@ var DirectoryService = function (_a) {
36179
36283
  (location === null || location === void 0 ? void 0 : location.accessibility_for_disabilities.length) > 0 && (React__default.createElement(React__default.Fragment, null,
36180
36284
  React__default.createElement(Heading$1, { level: 3, text: "Other facilities on site" }),
36181
36285
  React__default.createElement("ul", null, location.accessibility_for_disabilities.map(function (accessibility) { return (React__default.createElement("li", { key: accessibility.id }, accessibility.accessibility)); })))))); })),
36182
- React__default.createElement(Column, { small: "full", medium: "full", large: "two-thirds" }, service_at_locations.filter(function (location) {
36183
- return location.is_visitable != false;
36184
- }).length > 0 &&
36185
- ((_d = service_at_locations[0]) === null || _d === void 0 ? void 0 : _d.latitude) &&
36186
- ((_e = service_at_locations[0]) === null || _e === void 0 ? void 0 : _e.longitude) && (React__default.createElement(React__default.Fragment, null,
36286
+ React__default.createElement(Column, { small: "full", medium: "full", large: "two-thirds" }, mapLocations.length > 0 && (React__default.createElement(React__default.Fragment, null,
36187
36287
  notServer && (React__default.createElement(DirectoryMap, { mapProps: {
36188
- centre: "".concat(service_at_locations[0].latitude, ",").concat(service_at_locations[0].longitude),
36189
- imageAltText: "".concat(service_at_locations[0].name, " shown on a map"),
36288
+ centre: "".concat(mapLocations[0].latitude, ",").concat(mapLocations[0].longitude),
36289
+ imageAltText: "".concat(mapLocations[0].name, " shown on a map"),
36190
36290
  zoom: 14,
36191
36291
  size: '640x320',
36192
36292
  mapMarkers: service_at_locations
36193
36293
  .filter(function (location) {
36194
- return (location.latitude != null &&
36195
- location.longitude != null &&
36196
- location.is_visitable != false);
36294
+ return (isValidLatLng(location.latitude, location.longitude) && location.is_visitable != false);
36197
36295
  })
36198
36296
  .map(function (location, locationIndex) {
36199
36297
  return {
@@ -36201,10 +36299,12 @@ var DirectoryService = function (_a) {
36201
36299
  lng: parseFloat(location.longitude),
36202
36300
  label: labelLetters[locationIndex],
36203
36301
  title: location.name,
36302
+ infoWindowContent: (React__default.createElement("span", null,
36303
+ React__default.createElement("strong", null, name !== null && name !== void 0 ? name : ''))),
36204
36304
  };
36205
36305
  }),
36206
36306
  } })),
36207
- React__default.createElement(MapLink, { href: "https://www.google.com/maps/search/?api=1&query=".concat(service_at_locations[0].latitude, "%2C").concat(service_at_locations[0].longitude) }, "View in Google Maps"))))))),
36307
+ React__default.createElement(MapLink, { href: "https://www.google.com/maps/search/?api=1&query=".concat(mapLocations[0].latitude, "%2C").concat(mapLocations[0].longitude) }, "View in Google Maps"))))))),
36208
36308
  (email || url || (contacts === null || contacts === void 0 ? void 0 : contacts.length) > 0) && (React__default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
36209
36309
  React__default.createElement(Heading$1, { level: 2, text: "How to contact this service" }),
36210
36310
  React__default.createElement(ServiceContact, { email: email, website: url, contacts: contacts }))),
@@ -36721,19 +36821,26 @@ var DirectoryServiceList = function (_a) {
36721
36821
  zoom: mapZoom,
36722
36822
  size: '640x320',
36723
36823
  imageAltText: 'Directory search results displayed on a map',
36724
- mapMarkers: services
36725
- .filter(function (service) {
36726
- var _a;
36727
- return ((_a = service.service_at_locations[0]) === null || _a === void 0 ? void 0 : _a.is_visitable) != false;
36728
- })
36729
- .map(function (service, index) {
36730
- var _a, _b;
36731
- return {
36732
- lat: parseFloat((_a = service.service_at_locations[0]) === null || _a === void 0 ? void 0 : _a.latitude),
36733
- lng: parseFloat((_b = service.service_at_locations[0]) === null || _b === void 0 ? void 0 : _b.longitude),
36734
- label: labelLetters[index],
36735
- title: "<a href=\"".concat(directoryPath, "/").concat(service.id, "\">").concat(service.name, "</a>"),
36736
- };
36824
+ mapMarkers: services.flatMap(function (service, index) {
36825
+ var _a, _b, _c;
36826
+ if (service.service_at_locations &&
36827
+ service.service_at_locations[0] &&
36828
+ service.service_at_locations[0].latitude &&
36829
+ service.service_at_locations[0].longitude &&
36830
+ ((_a = service.service_at_locations[0]) === null || _a === void 0 ? void 0 : _a.is_visitable) != false) {
36831
+ return [
36832
+ {
36833
+ lat: parseFloat((_b = service.service_at_locations[0]) === null || _b === void 0 ? void 0 : _b.latitude),
36834
+ lng: parseFloat((_c = service.service_at_locations[0]) === null || _c === void 0 ? void 0 : _c.longitude),
36835
+ label: labelLetters[index],
36836
+ title: service.name,
36837
+ infoWindowContent: (React__default.createElement("a", { href: "".concat(directoryPath, "/").concat(service.id) }, service.name)),
36838
+ },
36839
+ ];
36840
+ }
36841
+ else {
36842
+ return [];
36843
+ }
36737
36844
  }),
36738
36845
  };
36739
36846
  var handleAgeChange = function (e, field) {
@@ -36848,7 +36955,7 @@ var DirectoryServiceList = function (_a) {
36848
36955
  ")"))),
36849
36956
  React__default.createElement(Column, { small: "full", medium: "full", large: "full" },
36850
36957
  React__default.createElement(Pagination, { currentPage: pageNumber, totalResults: totalResults, resultsPerPage: perPage, postTo: directoryPath, buttonClickOverride: setPageNumber })),
36851
- React__default.createElement(Column, { small: "full", medium: "full", large: "full" }, notServer && React__default.createElement(React__default.Fragment, null, (services === null || services === void 0 ? void 0 : services.length) > 0 && showMap && React__default.createElement(DirectoryMap, { mapProps: mapProps }))),
36958
+ React__default.createElement(Column, { small: "full", medium: "full", large: "full" }, notServer && (services === null || services === void 0 ? void 0 : services.length) > 0 && showMap && (React__default.createElement(DirectoryMap, { mapProps: mapProps }))),
36852
36959
  services.map(function (service, index) {
36853
36960
  var _a, _b, _c, _d, _e, _f, _g;
36854
36961
  var snippet = transformSnippet(service.description, extractLength);
@@ -38816,5 +38923,5 @@ var DirectoryDocumentList = function (_a) {
38816
38923
  React__default.createElement(Column, { small: "full", medium: "full", large: "full" }, !isLoading && (React__default.createElement(Pagination, { currentPage: pageNumber, totalResults: totalResults, resultsPerPage: perPage, postTo: directoryPath, buttonClickOverride: setPageNumber }))))))));
38817
38924
  };
38818
38925
 
38819
- export { AccessibleLinks, Accordion$1 as Accordion, AlertBanner, AlertBannerService, Autocomplete, BackLink, BackToTop, BinFinder, BlockLinks, BlockQuote, Breadcrumbs, BudgetGame, Button$5 as Button, CallToAction, Cards, CheckboxListFilter, CludoSearch, ConsultationList, ConsultationStatus, Contents$1 as Contents, ContentsNavigation, CookieBanner, CouncilTaxAlphabeticalDirectory, DirectoryDocumentList, DirectoryDocuments, DirectoryService, DirectoryServiceList, DirectoryShortList, DirectoryShortListProvider, DisplayDate, Divider, DownloadableFiles, DropDownFilter, DynamicIcon, EventDetails, EventList, Footer, FullWidthContainer, GDS_theme, GlobalStyleReset, GoogleMap, Header, Heading$1 as Heading, HeadingWithIcon, HeroImage, HomeHero, Image, ImageAndText, InquestSchedule, Map$1 as Map, MapMarker, MaxWidthContainer, MemorialHero, NewsArticleDate, NewsArticleFeaturedBlock, NewsArticleFilterAccordion, NewsArticleImage, NewsArticleList, NewsArticleListHeader, NewsArticleOldBanner, PageMain, PageSidebar, PageTitle, PageWithSidebarContainer, PageWrapper, Pagination, PhaseBanner, PromoBanner, PromoBlock, PromoTabs, PromoTabsDisplay, PromotedLinks, PromotedServicesTabs, Promotions, QuickExit, Quiz, RateThisPage, RecyclingInformation, RelatedEvents, ResponsiveImage, RoadworksList, SearchBox, SearchResultsList, Searchbar, SectionLinks, SectionLinksMobileContents, SectionLinksSidebar, ServiceLinksBoxed, ServicesLinksList, SignpostLinks, SkipToMainContent, StaticMap, Summary, SummaryList, TextInput, ToggleButtons, Video, WarningText, WarningTextDisclaimer, WebChat, WebChatAssistant, lb_theme_north, lb_theme_west, north_theme, useDirectoryShortListContext, west_theme };
38926
+ export { AccessibleLinks, Accordion$1 as Accordion, AlertBanner, AlertBannerService, Autocomplete, BackLink, BackToTop, BinFinder, BlockLinks, BlockQuote, Breadcrumbs, BudgetGame, Button$5 as Button, CallToAction, Cards, CheckboxListFilter, CludoSearch, ConsultationList, ConsultationStatus, Contents$1 as Contents, ContentsNavigation, CookieBanner, CouncilTaxAlphabeticalDirectory, DirectoryDocumentList, DirectoryDocuments, DirectoryService, DirectoryServiceList, DirectoryShortList, DirectoryShortListProvider, DisplayDate, Divider, DownloadableFiles, DropDownFilter, DynamicIcon, EventDetails, EventList, Footer, FullWidthContainer, GDS_theme, GlobalStyleReset, GoogleMap, Header, Heading$1 as Heading, HeadingWithIcon, HeroImage, HomeHero, Image, ImageAndText, InquestSchedule, MaxWidthContainer, MemorialHero, NewsArticleDate, NewsArticleFeaturedBlock, NewsArticleFilterAccordion, NewsArticleImage, NewsArticleList, NewsArticleListHeader, NewsArticleOldBanner, PageMain, PageSidebar, PageTitle, PageWithSidebarContainer, PageWrapper, Pagination, PhaseBanner, PromoBanner, PromoBlock, PromoTabs, PromoTabsDisplay, PromotedLinks, PromotedServicesTabs, Promotions, QuickExit, Quiz, RateThisPage, RecyclingInformation, RelatedEvents, ResponsiveImage, RoadworksList, SearchBox, SearchResultsList, Searchbar, SectionLinks, SectionLinksMobileContents, SectionLinksSidebar, ServiceLinksBoxed, ServicesLinksList, SignpostLinks, SkipToMainContent, StaticMap, Summary, SummaryList, TextInput, ToggleButtons, Video, WarningText, WarningTextDisclaimer, WebChat, WebChatAssistant, lb_theme_north, lb_theme_west, north_theme, useDirectoryShortListContext, west_theme };
38820
38927
  //# sourceMappingURL=index.mjs.js.map