@oneblink/apps-react 13.4.0-beta.4 → 13.4.0-beta.5

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.
@@ -0,0 +1,3 @@
1
+ export default function GoogleMapsLogo({ className }: {
2
+ className?: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Official Google Maps attribution logo. Google requires it to be unmodified,
3
+ // 16-19px tall and labelled "Google Maps" for accessibility.
4
+ // https://developers.google.com/maps/documentation/places/web-service/policies#logo
5
+ export default function GoogleMapsLogo({ className }) {
6
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", role: "img", "aria-label": "Google Maps", width: "88", height: "16", viewBox: "0 0 98 18", className: className, children: _jsxs("g", { fill: "#5E5E5E", children: [_jsx("path", { d: "M7.08,13.96c-1.93,0-3.59-0.68-4.99-2.05C0.7,10.54,0,8.9,0,6.98c0-1.92,0.7-3.56,2.09-4.93C3.49,0.68,5.15,0,7.08,0c1.85,0,3.45,0.64,4.79,1.92l-1.35,1.35C9.56,2.36,8.41,1.91,7.08,1.91c-1.4,0-2.58,0.49-3.55,1.48C2.56,4.38,2.08,5.57,2.08,6.98c0,1.41,0.49,2.61,1.46,3.59c0.97,0.99,2.15,1.48,3.55,1.48c1.42,0,2.59-0.47,3.53-1.4c0.56-0.56,0.9-1.36,1.04-2.4H7.08V6.35h6.42c0.07,0.34,0.1,0.74,0.1,1.19c0,1.87-0.55,3.36-1.65,4.46C10.71,13.31,9.08,13.96,7.08,13.96zM22,12.68c-0.87,0.86-1.94,1.29-3.2,1.29c-1.26,0-2.33-0.43-3.2-1.29c-0.87-0.86-1.31-1.93-1.31-3.21c0-1.28,0.44-2.35,1.31-3.21c0.87-0.86,1.94-1.29,3.2-1.29c1.26,0,2.33,0.43,3.2,1.29c0.87,0.86,1.31,1.93,1.31,3.21C23.31,10.75,22.88,11.82,22,12.68zM17.01,11.42c0.5,0.52,1.1,0.77,1.79,0.77c0.69,0,1.29-0.26,1.79-0.77c0.5-0.52,0.75-1.17,0.75-1.95c0-0.79-0.25-1.45-0.74-1.96C20.1,7,19.5,6.74,18.8,6.74c-0.7,0-1.3,0.26-1.8,0.77c-0.49,0.51-0.74,1.16-0.74,1.96C16.26,10.25,16.51,10.9,17.01,11.42zM31.85,12.68c-0.87,0.86-1.94,1.29-3.2,1.29s-2.33-0.43-3.2-1.29c-0.87-0.86-1.31-1.93-1.31-3.21c0-1.28,0.44-2.35,1.31-3.21c0.87-0.86,1.94-1.29,3.2-1.29s2.33,0.43,3.2,1.29c0.87,0.86,1.31,1.93,1.31,3.21C33.16,10.75,32.72,11.82,31.85,12.68zM26.86,11.42c0.5,0.52,1.1,0.77,1.79,0.77c0.69,0,1.29-0.26,1.79-0.77c0.5-0.52,0.75-1.17,0.75-1.95c0-0.79-0.25-1.45-0.74-1.96s-1.09-0.77-1.8-0.77c-0.7,0-1.3,0.26-1.8,0.77c-0.49,0.51-0.74,1.16-0.74,1.96C26.11,10.25,26.36,10.9,26.86,11.42zM38.32,18c-1,0-1.84-0.27-2.52-0.8c-0.68-0.53-1.17-1.15-1.46-1.86l1.72-0.72c0.18,0.43,0.47,0.81,0.85,1.12c0.39,0.32,0.86,0.48,1.41,0.48c0.75,0,1.34-0.23,1.76-0.68c0.43-0.45,0.64-1.11,0.64-1.96v-0.65h-0.07c-0.56,0.68-1.35,1.02-2.37,1.02c-1.15,0-2.15-0.44-3.01-1.31c-0.86-0.87-1.29-1.93-1.29-3.17c0-1.25,0.43-2.31,1.29-3.19c0.86-0.88,1.87-1.32,3.01-1.32c0.51,0,0.97,0.1,1.39,0.29c0.41,0.19,0.74,0.43,0.98,0.72h0.07V5.25h1.87v8.07c0,1.57-0.4,2.74-1.2,3.52C40.59,17.61,39.57,18,38.32,18zM38.45,12.19c0.68,0,1.25-0.26,1.71-0.77c0.46-0.52,0.69-1.16,0.69-1.93c0-0.78-0.23-1.44-0.69-1.96C39.7,7,39.13,6.74,38.45,6.74c-0.69,0-1.28,0.26-1.77,0.78c-0.49,0.52-0.73,1.18-0.73,1.96c0,0.77,0.24,1.42,0.73,1.93C37.17,11.93,37.76,12.19,38.45,12.19zM45.93,0.48v13.21h-1.98V0.48H45.93zM51.34,13.96c-1.27,0-2.33-0.43-3.18-1.29c-0.85-0.86-1.28-1.93-1.28-3.2c0-1.32,0.41-2.4,1.23-3.24c0.82-0.84,1.82-1.26,3.01-1.26c0.55,0,1.05,0.1,1.52,0.3c0.47,0.2,0.85,0.45,1.16,0.77c0.31,0.31,0.55,0.62,0.73,0.91c0.18,0.3,0.33,0.59,0.44,0.89l0.2,0.51l-6.01,2.49c0.47,0.91,1.19,1.36,2.18,1.36c0.91,0,1.65-0.41,2.21-1.24l1.53,1.02c-0.34,0.51-0.82,0.97-1.45,1.38C53.02,13.76,52.25,13.96,51.34,13.96zM48.84,9.33l4.02-1.67c-0.11-0.28-0.32-0.51-0.63-0.69c-0.31-0.18-0.65-0.26-1.04-0.26c-0.58,0-1.12,0.24-1.63,0.72C49.06,7.9,48.82,8.54,48.84,9.33z" }), _jsx("path", { d: "M60.05,13.69V1.5h1.57l4.24,7.42h0.07l4.24-7.42h1.57v12.19h-1.57V6.45l0.07-2.04h-0.07l-3.81,6.69h-0.92l-3.81-6.69h-0.07l0.07,2.04v7.24H60.05zM76.36,13.96c-0.89,0-1.63-0.26-2.22-0.77c-0.6-0.51-0.89-1.19-0.89-2.03c0-0.91,0.35-1.62,1.06-2.14c0.7-0.52,1.57-0.77,2.61-0.77c0.92,0,1.67,0.17,2.26,0.51V8.53c0-0.61-0.21-1.1-0.63-1.47c-0.42-0.37-0.94-0.55-1.55-0.55c-0.45,0-0.87,0.11-1.23,0.32C75.39,7.04,75.13,7.34,75,7.71L73.57,7.1c0.19-0.5,0.57-0.96,1.14-1.39c0.57-0.43,1.32-0.64,2.25-0.64c1.07,0,1.95,0.31,2.66,0.94c0.7,0.62,1.06,1.5,1.06,2.64v5.04h-1.5v-1.16H79.1C78.48,13.49,77.56,13.96,76.36,13.96zM76.61,12.53c0.65,0,1.23-0.24,1.76-0.72c0.53-0.48,0.79-1.05,0.79-1.71c-0.44-0.36-1.11-0.54-1.99-0.54c-0.76,0-1.33,0.16-1.72,0.49c-0.39,0.33-0.58,0.72-0.58,1.16c0,0.41,0.18,0.73,0.53,0.97C75.76,12.41,76.16,12.53,76.61,12.53zM86.58,13.96c-0.64,0-1.21-0.14-1.71-0.41c-0.51-0.27-0.88-0.61-1.13-1.02h-0.07l0.07,1.16v3.68h-1.57V5.35h1.5v1.16h0.07c0.25-0.41,0.63-0.75,1.13-1.02c0.51-0.27,1.08-0.41,1.71-0.41c1.08,0,2.01,0.43,2.79,1.28c0.78,0.85,1.18,1.91,1.18,3.17c0,1.26-0.39,2.32-1.18,3.17C88.59,13.54,87.66,13.96,86.58,13.96zM86.32,12.53c0.73,0,1.35-0.28,1.87-0.83c0.52-0.55,0.78-1.28,0.78-2.19c0-0.91-0.26-1.64-0.78-2.19c-0.52-0.55-1.15-0.83-1.87-0.83c-0.74,0-1.37,0.27-1.88,0.82c-0.52,0.54-0.77,1.28-0.77,2.2s0.26,1.65,0.77,2.2C84.96,12.26,85.58,12.53,86.32,12.53zM94.71,13.96c-0.93,0-1.7-0.23-2.31-0.68c-0.61-0.45-1.05-1.02-1.34-1.7l1.4-0.58c0.44,1.04,1.2,1.57,2.26,1.57c0.49,0,0.89-0.11,1.2-0.32c0.31-0.22,0.47-0.5,0.47-0.85c0-0.54-0.38-0.91-1.14-1.11l-1.69-0.41c-0.53-0.14-1.04-0.39-1.52-0.77c-0.48-0.38-0.72-0.89-0.72-1.54c0-0.74,0.33-1.34,0.98-1.8c0.65-0.46,1.43-0.69,2.32-0.69c0.74,0,1.4,0.17,1.98,0.5c0.58,0.34,0.99,0.81,1.24,1.44L96.5,7.58c-0.31-0.74-0.94-1.11-1.91-1.11c-0.47,0-0.86,0.1-1.18,0.29c-0.32,0.19-0.48,0.45-0.48,0.78c0,0.48,0.37,0.8,1.11,0.97l1.65,0.39c0.78,0.18,1.36,0.49,1.74,0.94c0.37,0.44,0.56,0.94,0.56,1.5c0,0.75-0.31,1.37-0.92,1.87C96.47,13.71,95.68,13.96,94.71,13.96z" })] }) }));
7
+ }
8
+ //# sourceMappingURL=GoogleMapsLogo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMapsLogo.js","sourceRoot":"","sources":["../../src/components/GoogleMapsLogo.tsx"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,6DAA6D;AAC7D,oFAAoF;AACpF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,SAAS,EAA0B;IAC1E,OAAO,CACL,cACE,KAAK,EAAC,4BAA4B,EAClC,IAAI,EAAC,KAAK,gBACC,aAAa,EACxB,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,SAAS,EAAE,SAAS,YAEpB,aAAG,IAAI,EAAC,SAAS,aACf,eAAM,CAAC,EAAC,ypFAAypF,GAAG,EACpqF,eAAM,CAAC,EAAC,s8DAAs8D,GAAG,IAC/8D,GACA,CACP,CAAA;AACH,CAAC","sourcesContent":["// Official Google Maps attribution logo. Google requires it to be unmodified,\n// 16-19px tall and labelled \"Google Maps\" for accessibility.\n// https://developers.google.com/maps/documentation/places/web-service/policies#logo\nexport default function GoogleMapsLogo({ className }: { className?: string }) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n role=\"img\"\n aria-label=\"Google Maps\"\n width=\"88\"\n height=\"16\"\n viewBox=\"0 0 98 18\"\n className={className}\n >\n <g fill=\"#5E5E5E\">\n <path d=\"M7.08,13.96c-1.93,0-3.59-0.68-4.99-2.05C0.7,10.54,0,8.9,0,6.98c0-1.92,0.7-3.56,2.09-4.93C3.49,0.68,5.15,0,7.08,0c1.85,0,3.45,0.64,4.79,1.92l-1.35,1.35C9.56,2.36,8.41,1.91,7.08,1.91c-1.4,0-2.58,0.49-3.55,1.48C2.56,4.38,2.08,5.57,2.08,6.98c0,1.41,0.49,2.61,1.46,3.59c0.97,0.99,2.15,1.48,3.55,1.48c1.42,0,2.59-0.47,3.53-1.4c0.56-0.56,0.9-1.36,1.04-2.4H7.08V6.35h6.42c0.07,0.34,0.1,0.74,0.1,1.19c0,1.87-0.55,3.36-1.65,4.46C10.71,13.31,9.08,13.96,7.08,13.96zM22,12.68c-0.87,0.86-1.94,1.29-3.2,1.29c-1.26,0-2.33-0.43-3.2-1.29c-0.87-0.86-1.31-1.93-1.31-3.21c0-1.28,0.44-2.35,1.31-3.21c0.87-0.86,1.94-1.29,3.2-1.29c1.26,0,2.33,0.43,3.2,1.29c0.87,0.86,1.31,1.93,1.31,3.21C23.31,10.75,22.88,11.82,22,12.68zM17.01,11.42c0.5,0.52,1.1,0.77,1.79,0.77c0.69,0,1.29-0.26,1.79-0.77c0.5-0.52,0.75-1.17,0.75-1.95c0-0.79-0.25-1.45-0.74-1.96C20.1,7,19.5,6.74,18.8,6.74c-0.7,0-1.3,0.26-1.8,0.77c-0.49,0.51-0.74,1.16-0.74,1.96C16.26,10.25,16.51,10.9,17.01,11.42zM31.85,12.68c-0.87,0.86-1.94,1.29-3.2,1.29s-2.33-0.43-3.2-1.29c-0.87-0.86-1.31-1.93-1.31-3.21c0-1.28,0.44-2.35,1.31-3.21c0.87-0.86,1.94-1.29,3.2-1.29s2.33,0.43,3.2,1.29c0.87,0.86,1.31,1.93,1.31,3.21C33.16,10.75,32.72,11.82,31.85,12.68zM26.86,11.42c0.5,0.52,1.1,0.77,1.79,0.77c0.69,0,1.29-0.26,1.79-0.77c0.5-0.52,0.75-1.17,0.75-1.95c0-0.79-0.25-1.45-0.74-1.96s-1.09-0.77-1.8-0.77c-0.7,0-1.3,0.26-1.8,0.77c-0.49,0.51-0.74,1.16-0.74,1.96C26.11,10.25,26.36,10.9,26.86,11.42zM38.32,18c-1,0-1.84-0.27-2.52-0.8c-0.68-0.53-1.17-1.15-1.46-1.86l1.72-0.72c0.18,0.43,0.47,0.81,0.85,1.12c0.39,0.32,0.86,0.48,1.41,0.48c0.75,0,1.34-0.23,1.76-0.68c0.43-0.45,0.64-1.11,0.64-1.96v-0.65h-0.07c-0.56,0.68-1.35,1.02-2.37,1.02c-1.15,0-2.15-0.44-3.01-1.31c-0.86-0.87-1.29-1.93-1.29-3.17c0-1.25,0.43-2.31,1.29-3.19c0.86-0.88,1.87-1.32,3.01-1.32c0.51,0,0.97,0.1,1.39,0.29c0.41,0.19,0.74,0.43,0.98,0.72h0.07V5.25h1.87v8.07c0,1.57-0.4,2.74-1.2,3.52C40.59,17.61,39.57,18,38.32,18zM38.45,12.19c0.68,0,1.25-0.26,1.71-0.77c0.46-0.52,0.69-1.16,0.69-1.93c0-0.78-0.23-1.44-0.69-1.96C39.7,7,39.13,6.74,38.45,6.74c-0.69,0-1.28,0.26-1.77,0.78c-0.49,0.52-0.73,1.18-0.73,1.96c0,0.77,0.24,1.42,0.73,1.93C37.17,11.93,37.76,12.19,38.45,12.19zM45.93,0.48v13.21h-1.98V0.48H45.93zM51.34,13.96c-1.27,0-2.33-0.43-3.18-1.29c-0.85-0.86-1.28-1.93-1.28-3.2c0-1.32,0.41-2.4,1.23-3.24c0.82-0.84,1.82-1.26,3.01-1.26c0.55,0,1.05,0.1,1.52,0.3c0.47,0.2,0.85,0.45,1.16,0.77c0.31,0.31,0.55,0.62,0.73,0.91c0.18,0.3,0.33,0.59,0.44,0.89l0.2,0.51l-6.01,2.49c0.47,0.91,1.19,1.36,2.18,1.36c0.91,0,1.65-0.41,2.21-1.24l1.53,1.02c-0.34,0.51-0.82,0.97-1.45,1.38C53.02,13.76,52.25,13.96,51.34,13.96zM48.84,9.33l4.02-1.67c-0.11-0.28-0.32-0.51-0.63-0.69c-0.31-0.18-0.65-0.26-1.04-0.26c-0.58,0-1.12,0.24-1.63,0.72C49.06,7.9,48.82,8.54,48.84,9.33z\" />\n <path d=\"M60.05,13.69V1.5h1.57l4.24,7.42h0.07l4.24-7.42h1.57v12.19h-1.57V6.45l0.07-2.04h-0.07l-3.81,6.69h-0.92l-3.81-6.69h-0.07l0.07,2.04v7.24H60.05zM76.36,13.96c-0.89,0-1.63-0.26-2.22-0.77c-0.6-0.51-0.89-1.19-0.89-2.03c0-0.91,0.35-1.62,1.06-2.14c0.7-0.52,1.57-0.77,2.61-0.77c0.92,0,1.67,0.17,2.26,0.51V8.53c0-0.61-0.21-1.1-0.63-1.47c-0.42-0.37-0.94-0.55-1.55-0.55c-0.45,0-0.87,0.11-1.23,0.32C75.39,7.04,75.13,7.34,75,7.71L73.57,7.1c0.19-0.5,0.57-0.96,1.14-1.39c0.57-0.43,1.32-0.64,2.25-0.64c1.07,0,1.95,0.31,2.66,0.94c0.7,0.62,1.06,1.5,1.06,2.64v5.04h-1.5v-1.16H79.1C78.48,13.49,77.56,13.96,76.36,13.96zM76.61,12.53c0.65,0,1.23-0.24,1.76-0.72c0.53-0.48,0.79-1.05,0.79-1.71c-0.44-0.36-1.11-0.54-1.99-0.54c-0.76,0-1.33,0.16-1.72,0.49c-0.39,0.33-0.58,0.72-0.58,1.16c0,0.41,0.18,0.73,0.53,0.97C75.76,12.41,76.16,12.53,76.61,12.53zM86.58,13.96c-0.64,0-1.21-0.14-1.71-0.41c-0.51-0.27-0.88-0.61-1.13-1.02h-0.07l0.07,1.16v3.68h-1.57V5.35h1.5v1.16h0.07c0.25-0.41,0.63-0.75,1.13-1.02c0.51-0.27,1.08-0.41,1.71-0.41c1.08,0,2.01,0.43,2.79,1.28c0.78,0.85,1.18,1.91,1.18,3.17c0,1.26-0.39,2.32-1.18,3.17C88.59,13.54,87.66,13.96,86.58,13.96zM86.32,12.53c0.73,0,1.35-0.28,1.87-0.83c0.52-0.55,0.78-1.28,0.78-2.19c0-0.91-0.26-1.64-0.78-2.19c-0.52-0.55-1.15-0.83-1.87-0.83c-0.74,0-1.37,0.27-1.88,0.82c-0.52,0.54-0.77,1.28-0.77,2.2s0.26,1.65,0.77,2.2C84.96,12.26,85.58,12.53,86.32,12.53zM94.71,13.96c-0.93,0-1.7-0.23-2.31-0.68c-0.61-0.45-1.05-1.02-1.34-1.7l1.4-0.58c0.44,1.04,1.2,1.57,2.26,1.57c0.49,0,0.89-0.11,1.2-0.32c0.31-0.22,0.47-0.5,0.47-0.85c0-0.54-0.38-0.91-1.14-1.11l-1.69-0.41c-0.53-0.14-1.04-0.39-1.52-0.77c-0.48-0.38-0.72-0.89-0.72-1.54c0-0.74,0.33-1.34,0.98-1.8c0.65-0.46,1.43-0.69,2.32-0.69c0.74,0,1.4,0.17,1.98,0.5c0.58,0.34,0.99,0.81,1.24,1.44L96.5,7.58c-0.31-0.74-0.94-1.11-1.91-1.11c-0.47,0-0.86,0.1-1.18,0.29c-0.32,0.19-0.48,0.45-0.48,0.78c0,0.48,0.37,0.8,1.11,0.97l1.65,0.39c0.78,0.18,1.36,0.49,1.74,0.94c0.37,0.44,0.56,0.94,0.56,1.5c0,0.75-0.31,1.37-0.92,1.87C96.47,13.71,95.68,13.96,94.71,13.96z\" />\n </g>\n </svg>\n )\n}\n"]}
@@ -7,6 +7,7 @@ import useGoogle from '../hooks/useGoogle';
7
7
  import useIsMounted from '../hooks/useIsMounted';
8
8
  import useElementAriaDescribedby from '../hooks/useElementAriaDescribedby';
9
9
  import FormElementValidationMessage from '../components/renderer/FormElementValidationMessage';
10
+ import GoogleMapsLogo from '../components/GoogleMapsLogo';
10
11
  function FormElementGoogleAddress({ id, element, readOnly, value, displayValidationMessage, validationMessage, onChange, isDirty, setIsDirty, autocompleteAttributes, }) {
11
12
  const ariaDescribedby = useElementAriaDescribedby(id, element);
12
13
  const isMounted = useIsMounted();
@@ -135,7 +136,7 @@ function FormElementGoogleAddress({ id, element, readOnly, value, displayValidat
135
136
  setLabel(newLabel !== null && newLabel !== void 0 ? newLabel : '');
136
137
  }
137
138
  }, [value]);
138
- return (_jsxs("div", { className: "cypress-google-address-element", children: [_jsx(FormElementLabelContainer, { className: "ob-google-address ob-autocomplete", element: element, id: id, required: element.required, children: _jsx(AutocompleteDropdown, { id: id, label: label, disabled: readOnly || isLoadingAddressDetails, placeholder: element.placeholderValue, required: element.required, value: value, validationMessage: validationMessage, displayValidationMessage: displayValidationMessage, onChangeValue: handleChange, isLoading: isLoadingAddressDetails, hasError: !!error, onChangeLabel: setLabel, searchDebounceMs: 750, searchMinCharacters: 4, onSearch: handleSearch, isDirty: isDirty, setIsDirty: setIsDirty, "aria-describedby": ariaDescribedby, branding: _jsxs("a", { className: "dropdown-item cypress-powered-by-google ob-autocomplete__drop-down-item-powered-by-google", children: ["powered by", ' ', _jsx("img", { src: "https://developers.google.com/static/maps/documentation/images/google_on_white.png" })] }), autoComplete: autocompleteAttributes }) }), error && (_jsx(FormElementValidationMessage, { message: error.toString(), className: "cypress-google-address-details-error-message" }))] }));
139
+ return (_jsxs("div", { className: "cypress-google-address-element", children: [_jsx(FormElementLabelContainer, { className: "ob-google-address ob-autocomplete", element: element, id: id, required: element.required, children: _jsx(AutocompleteDropdown, { id: id, label: label, disabled: readOnly || isLoadingAddressDetails, placeholder: element.placeholderValue, required: element.required, value: value, validationMessage: validationMessage, displayValidationMessage: displayValidationMessage, onChangeValue: handleChange, isLoading: isLoadingAddressDetails, hasError: !!error, onChangeLabel: setLabel, searchDebounceMs: 750, searchMinCharacters: 4, onSearch: handleSearch, isDirty: isDirty, setIsDirty: setIsDirty, "aria-describedby": ariaDescribedby, branding: _jsx("a", { className: "dropdown-item cypress-powered-by-google ob-autocomplete__drop-down-item-powered-by-google", children: _jsx(GoogleMapsLogo, {}) }), autoComplete: autocompleteAttributes }) }), error && (_jsx(FormElementValidationMessage, { message: error.toString(), className: "cypress-google-address-details-error-message" }))] }));
139
140
  }
140
141
  export default React.memo(FormElementGoogleAddress);
141
142
  //# sourceMappingURL=FormElementGoogleAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormElementGoogleAddress.js","sourceRoot":"","sources":["../../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AE,CAAC,CAAC,KAAK,EACjB,aAAa,EAAE,QAAQ,EACvB,gBAAgB,EAAE,GAAG,EACrB,mBAAmB,EAAE,CAAC,EACtB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,sBACJ,eAAe,EACjC,QAAQ,EACN,aAAG,SAAS,EAAC,2FAA2F,2BAC3F,GAAG,EACd,cAAK,GAAG,EAAC,oFAAoF,GAAG,IAC9F,EAEN,YAAY,EAAE,sBAAsB,GACpC,GACwB,EAE3B,KAAK,IAAI,CACR,KAAC,4BAA4B,IAC3B,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,EACzB,SAAS,EAAC,8CAA8C,GACxD,CACH,IACG,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { FormTypes, GoogleTypes } from '@oneblink/types'\nimport { OneBlinkAppsError, Sentry } from '../apps'\n\nimport AutocompleteDropdown from '../components/renderer/AutocompleteDropdown'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport useGoogle from '../hooks/useGoogle'\nimport useIsMounted from '../hooks/useIsMounted'\nimport useElementAriaDescribedby from '../hooks/useElementAriaDescribedby'\nimport { FormElementValueChangeHandler, IsDirtyProps } from '../types/form'\nimport FormElementValidationMessage from '../components/renderer/FormElementValidationMessage'\n\ntype Props = {\n formId: number\n id: string\n element: FormTypes.GoogleAddressElement\n readOnly: boolean\n value: GoogleTypes.GoogleMapsAddress | undefined\n displayValidationMessage: boolean\n validationMessage: string | undefined\n onChange: FormElementValueChangeHandler<GoogleTypes.GoogleMapsAddress>\n autocompleteAttributes?: string\n} & IsDirtyProps\n\nfunction FormElementGoogleAddress({\n id,\n element,\n readOnly,\n value,\n displayValidationMessage,\n validationMessage,\n onChange,\n isDirty,\n setIsDirty,\n autocompleteAttributes,\n}: Props) {\n const ariaDescribedby = useElementAriaDescribedby(id, element)\n const isMounted = useIsMounted()\n const [label, setLabel] = React.useState('')\n const [error, setError] = React.useState<Error | undefined>()\n const [isLoadingAddressDetails, setIsLoadingAddressDetails] =\n React.useState(false)\n\n const { isLoaded } = useGoogle()\n\n const autocompleteService = React.useMemo(() => {\n if (isLoaded) {\n return new google.maps.places.AutocompleteService()\n }\n }, [isLoaded])\n\n const dummyMap = React.useMemo(() => {\n if (isLoaded) {\n return new google.maps.Map(document.createElement('div'))\n }\n }, [isLoaded])\n\n const handleSearch = React.useCallback(\n async (input: string, abortSignal: AbortSignal) => {\n setError(undefined)\n if (autocompleteService) {\n const predictions = await new Promise<\n google.maps.places.QueryAutocompletePrediction[]\n >((resolve, reject) => {\n autocompleteService.getQueryPredictions(\n {\n input,\n },\n (predictions, status) => {\n switch (status) {\n case google.maps.places.PlacesServiceStatus.OK:\n case google.maps.places.PlacesServiceStatus.ZERO_RESULTS: {\n resolve(predictions ?? [])\n break\n }\n case google.maps.places.PlacesServiceStatus.OVER_QUERY_LIMIT: {\n reject(\n new OneBlinkAppsError(\n 'This application has gone over its Google Address querying quota. Please contact an administrator to rectify the issue or try again later.',\n ),\n )\n break\n }\n case google.maps.places.PlacesServiceStatus.INVALID_REQUEST: {\n reject(\n new OneBlinkAppsError(\n 'Google Maps API key may not have been configured correctly, the request to retrieve address suggestions is invalid. Please contact an administrator to rectify the issue.',\n ),\n )\n break\n }\n case google.maps.places.PlacesServiceStatus.REQUEST_DENIED: {\n reject(\n new OneBlinkAppsError(\n 'Google Maps API key has not been configured correctly. Please contact an administrator to rectify the issue.',\n ),\n )\n break\n }\n default: {\n reject(\n new OneBlinkAppsError(\n 'An unknown error has occurred. Please try again and contact support if the problem persists.',\n ),\n )\n }\n }\n },\n )\n }).catch((e) => {\n if (!abortSignal.aborted) {\n Sentry.captureException(e)\n }\n throw e\n })\n\n if (!abortSignal.aborted) {\n return predictions.reduce<Array<{ value: string; label: string }>>(\n (results, prediction) => {\n if (prediction.place_id) {\n results.push({\n value: prediction.place_id,\n label: prediction.description,\n })\n }\n return results\n },\n [],\n )\n }\n }\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n )\n },\n [autocompleteService],\n )\n\n const handleChange = React.useCallback(\n async (placeId: string | undefined) => {\n if (!placeId) {\n onChange(element, { value: undefined })\n return\n }\n\n setIsLoadingAddressDetails(true)\n try {\n //this should not happen, we can't get a place Id without google being present\n if (!isLoaded || !dummyMap) {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: new Error(\n 'Google Places library has not be initialised',\n ),\n },\n )\n }\n\n const placeService = new google.maps.places.PlacesService(dummyMap)\n const place = await new Promise<google.maps.places.PlaceResult>(\n (resolve, reject) => {\n placeService.getDetails(\n {\n placeId,\n fields: [\n 'place_id',\n 'formatted_address',\n 'geometry',\n 'address_components',\n ],\n },\n (place, status) => {\n if (\n status !== google.maps.places.PlacesServiceStatus.OK ||\n !place\n ) {\n reject(\n new OneBlinkAppsError(\n `Could not find address details for place with id: ${placeId}`,\n ),\n )\n return\n }\n resolve(place)\n },\n )\n },\n )\n onChange(element, {\n value: {\n place_id: place.place_id,\n formatted_address: place.formatted_address,\n address_components: place.address_components,\n geometry: {\n location: place.geometry?.location?.toJSON(),\n viewport: place.geometry?.viewport?.toJSON(),\n },\n },\n })\n } catch (newError) {\n if (isMounted.current) {\n setError(newError as Error)\n }\n }\n if (isMounted.current) {\n setIsLoadingAddressDetails(false)\n }\n },\n [isMounted, onChange, element, isLoaded, dummyMap],\n )\n\n // Ensure the label is set if the value is set outside of this component\n React.useEffect(() => {\n if (value) {\n const newLabel = value.formatted_address || value.place_id\n setLabel(newLabel ?? '')\n }\n }, [value])\n\n return (\n <div className=\"cypress-google-address-element\">\n <FormElementLabelContainer\n className=\"ob-google-address ob-autocomplete\"\n element={element}\n id={id}\n required={element.required}\n >\n <AutocompleteDropdown\n id={id}\n label={label}\n disabled={readOnly || isLoadingAddressDetails}\n placeholder={element.placeholderValue}\n required={element.required}\n value={value}\n validationMessage={validationMessage}\n displayValidationMessage={displayValidationMessage}\n onChangeValue={handleChange}\n isLoading={isLoadingAddressDetails}\n hasError={!!error}\n onChangeLabel={setLabel}\n searchDebounceMs={750}\n searchMinCharacters={4}\n onSearch={handleSearch}\n isDirty={isDirty}\n setIsDirty={setIsDirty}\n aria-describedby={ariaDescribedby}\n branding={\n <a className=\"dropdown-item cypress-powered-by-google ob-autocomplete__drop-down-item-powered-by-google\">\n powered by{' '}\n <img src=\"https://developers.google.com/static/maps/documentation/images/google_on_white.png\" />\n </a>\n }\n autoComplete={autocompleteAttributes}\n />\n </FormElementLabelContainer>\n\n {error && (\n <FormElementValidationMessage\n message={error.toString()}\n className=\"cypress-google-address-details-error-message\"\n />\n )}\n </div>\n )\n}\n\nexport default React.memo(FormElementGoogleAddress)\n"]}
1
+ {"version":3,"file":"FormElementGoogleAddress.js","sourceRoot":"","sources":["../../src/form-elements/FormElementGoogleAddress.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,oBAAoB,MAAM,6CAA6C,CAAA;AAC9E,OAAO,yBAAyB,MAAM,kDAAkD,CAAA;AACxF,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAC1C,OAAO,YAAY,MAAM,uBAAuB,CAAA;AAChD,OAAO,yBAAyB,MAAM,oCAAoC,CAAA;AAE1E,OAAO,4BAA4B,MAAM,qDAAqD,CAAA;AAC9F,OAAO,cAAc,MAAM,8BAA8B,CAAA;AAczD,SAAS,wBAAwB,CAAC,EAChC,EAAE,EACF,OAAO,EACP,QAAQ,EACR,KAAK,EACL,wBAAwB,EACxB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,UAAU,EACV,sBAAsB,GAChB;IACN,MAAM,eAAe,GAAG,yBAAyB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;I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,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,OAAO,CACL,eAAK,SAAS,EAAC,gCAAgC,aAC7C,KAAC,yBAAyB,IACxB,SAAS,EAAC,mCAAmC,EAC7C,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,OAAO,CAAC,QAAQ,YAE1B,KAAC,oBAAoB,IACnB,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,IAAI,uBAAuB,EAC7C,WAAW,EAAE,OAAO,CAAC,gBAAgB,EACrC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,KAAK,EAAE,KAAK,EACZ,iBAAiB,EAAE,iBAAiB,EACpC,wBAAwB,EAAE,wBAAwB,EAClD,aAAa,EAAE,YAAY,EAC3B,SAAS,EAAE,uBAAuB,EAClC,QAAQ,EAAE,CAAC,CAAC,KAAK,EACjB,aAAa,EAAE,QAAQ,EACvB,gBAAgB,EAAE,GAAG,EACrB,mBAAmB,EAAE,CAAC,EACtB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,sBACJ,eAAe,EACjC,QAAQ,EACN,YAAG,SAAS,EAAC,2FAA2F,YACtG,KAAC,cAAc,KAAG,GAChB,EAEN,YAAY,EAAE,sBAAsB,GACpC,GACwB,EAE3B,KAAK,IAAI,CACR,KAAC,4BAA4B,IAC3B,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,EACzB,SAAS,EAAC,8CAA8C,GACxD,CACH,IACG,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { FormTypes, GoogleTypes } from '@oneblink/types'\nimport { OneBlinkAppsError, Sentry } from '../apps'\n\nimport AutocompleteDropdown from '../components/renderer/AutocompleteDropdown'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport useGoogle from '../hooks/useGoogle'\nimport useIsMounted from '../hooks/useIsMounted'\nimport useElementAriaDescribedby from '../hooks/useElementAriaDescribedby'\nimport { FormElementValueChangeHandler, IsDirtyProps } from '../types/form'\nimport FormElementValidationMessage from '../components/renderer/FormElementValidationMessage'\nimport GoogleMapsLogo from '../components/GoogleMapsLogo'\n\ntype Props = {\n formId: number\n id: string\n element: FormTypes.GoogleAddressElement\n readOnly: boolean\n value: GoogleTypes.GoogleMapsAddress | undefined\n displayValidationMessage: boolean\n validationMessage: string | undefined\n onChange: FormElementValueChangeHandler<GoogleTypes.GoogleMapsAddress>\n autocompleteAttributes?: string\n} & IsDirtyProps\n\nfunction FormElementGoogleAddress({\n id,\n element,\n readOnly,\n value,\n displayValidationMessage,\n validationMessage,\n onChange,\n isDirty,\n setIsDirty,\n autocompleteAttributes,\n}: Props) {\n const ariaDescribedby = useElementAriaDescribedby(id, element)\n const isMounted = useIsMounted()\n const [label, setLabel] = React.useState('')\n const [error, setError] = React.useState<Error | undefined>()\n const [isLoadingAddressDetails, setIsLoadingAddressDetails] =\n React.useState(false)\n\n const { isLoaded } = useGoogle()\n\n const autocompleteService = React.useMemo(() => {\n if (isLoaded) {\n return new google.maps.places.AutocompleteService()\n }\n }, [isLoaded])\n\n const dummyMap = React.useMemo(() => {\n if (isLoaded) {\n return new google.maps.Map(document.createElement('div'))\n }\n }, [isLoaded])\n\n const handleSearch = React.useCallback(\n async (input: string, abortSignal: AbortSignal) => {\n setError(undefined)\n if (autocompleteService) {\n const predictions = await new Promise<\n google.maps.places.QueryAutocompletePrediction[]\n >((resolve, reject) => {\n autocompleteService.getQueryPredictions(\n {\n input,\n },\n (predictions, status) => {\n switch (status) {\n case google.maps.places.PlacesServiceStatus.OK:\n case google.maps.places.PlacesServiceStatus.ZERO_RESULTS: {\n resolve(predictions ?? [])\n break\n }\n case google.maps.places.PlacesServiceStatus.OVER_QUERY_LIMIT: {\n reject(\n new OneBlinkAppsError(\n 'This application has gone over its Google Address querying quota. Please contact an administrator to rectify the issue or try again later.',\n ),\n )\n break\n }\n case google.maps.places.PlacesServiceStatus.INVALID_REQUEST: {\n reject(\n new OneBlinkAppsError(\n 'Google Maps API key may not have been configured correctly, the request to retrieve address suggestions is invalid. Please contact an administrator to rectify the issue.',\n ),\n )\n break\n }\n case google.maps.places.PlacesServiceStatus.REQUEST_DENIED: {\n reject(\n new OneBlinkAppsError(\n 'Google Maps API key has not been configured correctly. Please contact an administrator to rectify the issue.',\n ),\n )\n break\n }\n default: {\n reject(\n new OneBlinkAppsError(\n 'An unknown error has occurred. Please try again and contact support if the problem persists.',\n ),\n )\n }\n }\n },\n )\n }).catch((e) => {\n if (!abortSignal.aborted) {\n Sentry.captureException(e)\n }\n throw e\n })\n\n if (!abortSignal.aborted) {\n return predictions.reduce<Array<{ value: string; label: string }>>(\n (results, prediction) => {\n if (prediction.place_id) {\n results.push({\n value: prediction.place_id,\n label: prediction.description,\n })\n }\n return results\n },\n [],\n )\n }\n }\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n )\n },\n [autocompleteService],\n )\n\n const handleChange = React.useCallback(\n async (placeId: string | undefined) => {\n if (!placeId) {\n onChange(element, { value: undefined })\n return\n }\n\n setIsLoadingAddressDetails(true)\n try {\n //this should not happen, we can't get a place Id without google being present\n if (!isLoaded || !dummyMap) {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: new Error(\n 'Google Places library has not be initialised',\n ),\n },\n )\n }\n\n const placeService = new google.maps.places.PlacesService(dummyMap)\n const place = await new Promise<google.maps.places.PlaceResult>(\n (resolve, reject) => {\n placeService.getDetails(\n {\n placeId,\n fields: [\n 'place_id',\n 'formatted_address',\n 'geometry',\n 'address_components',\n ],\n },\n (place, status) => {\n if (\n status !== google.maps.places.PlacesServiceStatus.OK ||\n !place\n ) {\n reject(\n new OneBlinkAppsError(\n `Could not find address details for place with id: ${placeId}`,\n ),\n )\n return\n }\n resolve(place)\n },\n )\n },\n )\n onChange(element, {\n value: {\n place_id: place.place_id,\n formatted_address: place.formatted_address,\n address_components: place.address_components,\n geometry: {\n location: place.geometry?.location?.toJSON(),\n viewport: place.geometry?.viewport?.toJSON(),\n },\n },\n })\n } catch (newError) {\n if (isMounted.current) {\n setError(newError as Error)\n }\n }\n if (isMounted.current) {\n setIsLoadingAddressDetails(false)\n }\n },\n [isMounted, onChange, element, isLoaded, dummyMap],\n )\n\n // Ensure the label is set if the value is set outside of this component\n React.useEffect(() => {\n if (value) {\n const newLabel = value.formatted_address || value.place_id\n setLabel(newLabel ?? '')\n }\n }, [value])\n\n return (\n <div className=\"cypress-google-address-element\">\n <FormElementLabelContainer\n className=\"ob-google-address ob-autocomplete\"\n element={element}\n id={id}\n required={element.required}\n >\n <AutocompleteDropdown\n id={id}\n label={label}\n disabled={readOnly || isLoadingAddressDetails}\n placeholder={element.placeholderValue}\n required={element.required}\n value={value}\n validationMessage={validationMessage}\n displayValidationMessage={displayValidationMessage}\n onChangeValue={handleChange}\n isLoading={isLoadingAddressDetails}\n hasError={!!error}\n onChangeLabel={setLabel}\n searchDebounceMs={750}\n searchMinCharacters={4}\n onSearch={handleSearch}\n isDirty={isDirty}\n setIsDirty={setIsDirty}\n aria-describedby={ariaDescribedby}\n branding={\n <a className=\"dropdown-item cypress-powered-by-google ob-autocomplete__drop-down-item-powered-by-google\">\n <GoogleMapsLogo />\n </a>\n }\n autoComplete={autocompleteAttributes}\n />\n </FormElementLabelContainer>\n\n {error && (\n <FormElementValidationMessage\n message={error.toString()}\n className=\"cypress-google-address-details-error-message\"\n />\n )}\n </div>\n )\n}\n\nexport default React.memo(FormElementGoogleAddress)\n"]}
@@ -22,7 +22,7 @@
22
22
  padding-right: 16px;
23
23
  color: #5f6368;
24
24
 
25
- img {
25
+ svg {
26
26
  vertical-align: middle;
27
27
  }
28
28
  }
package/dist/styles.css CHANGED
@@ -9077,7 +9077,7 @@ input[type=range]:focus-visible::-moz-range-thumb {
9077
9077
  padding-right: 16px;
9078
9078
  color: #5f6368;
9079
9079
  }
9080
- .ob-autocomplete .ob-autocomplete__drop-down-item-powered-by-google img {
9080
+ .ob-autocomplete .ob-autocomplete__drop-down-item-powered-by-google svg {
9081
9081
  vertical-align: middle;
9082
9082
  }
9083
9083
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oneblink/apps-react",
3
3
  "description": "Helper functions for OneBlink apps in ReactJS.",
4
- "version": "13.4.0-beta.4",
4
+ "version": "13.4.0-beta.5",
5
5
  "author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/oneblink/apps-react/issues"