@jotul/jotul-widgets 1.0.2 → 1.0.4
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.
- package/README.md +13 -0
- package/dist/JotulWidget.css +1 -1
- package/dist/JotulWidget.d.ts +2 -2
- package/dist/JotulWidget.js +53 -17
- package/dist/components/ProductPageWidget.d.ts +4 -1
- package/dist/components/ProductPageWidget.js +169 -4
- package/dist/components/product-page/DealerList.d.ts +9 -1
- package/dist/components/product-page/DealerList.js +27 -3
- package/dist/components/product-page/InquiryForm.d.ts +2 -1
- package/dist/components/product-page/InquiryForm.js +4 -2
- package/dist/components/product-page/LocationSearch.d.ts +2 -1
- package/dist/components/product-page/LocationSearch.js +18 -3
- package/dist/i18n/locales/cz.json +41 -0
- package/dist/i18n/locales/de.json +41 -0
- package/dist/i18n/locales/en.json +41 -0
- package/dist/i18n/locales/fi.json +41 -0
- package/dist/i18n/locales/fr.json +41 -0
- package/dist/i18n/locales/nl.json +41 -0
- package/dist/i18n/locales/no.json +41 -0
- package/dist/i18n/locales/pl.json +41 -0
- package/dist/i18n/locales/se.json +41 -0
- package/dist/i18n/widgetStrings.d.ts +7 -5
- package/dist/i18n/widgetStrings.js +54 -148
- package/dist/images/dealer-pin-exclusive.svg +24 -0
- package/dist/images/dealer-pin.svg +11 -0
- package/dist/images/jotul-exclusive-dealer.png +0 -0
- package/dist/types.d.ts +14 -0
- package/dist/utils.js +11 -1
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -35,6 +35,19 @@ Custom route:
|
|
|
35
35
|
/>
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
Custom trigger button:
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
<JotulWidget
|
|
42
|
+
type="productPage"
|
|
43
|
+
productPageTrigger={({ onOpen, label, className, style }) => (
|
|
44
|
+
<button type="button" onClick={onOpen} className={className} style={style}>
|
|
45
|
+
{label}
|
|
46
|
+
</button>
|
|
47
|
+
)}
|
|
48
|
+
/>
|
|
49
|
+
```
|
|
50
|
+
|
|
38
51
|
Current behavior:
|
|
39
52
|
|
|
40
53
|
- invalid API key -> `Invalid API key`
|
package/dist/JotulWidget.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.jwi-pointer-events-none{pointer-events:none}.jwi-absolute{position:absolute}.jwi-relative{position:relative}.jwi-bottom-0{bottom:0}.jwi-left-0{left:0}.jwi-right-0{right:0}.jwi-z-20{z-index:20}.jwi-m-0{margin:0}.jwi--mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.jwi-mb-3{margin-bottom:.75rem}.jwi-mr-\[-12px\]{margin-right:-12px}.jwi-mt-1{margin-top:.25rem}.jwi-mt-2{margin-top:.5rem}.jwi-mt-3{margin-top:.75rem}.jwi-mt-4{margin-top:1rem}.jwi-box-border{box-sizing:border-box}.jwi-flex{display:flex}.jwi-inline-flex{display:inline-flex}.jwi-h-10{height:2.5rem}.jwi-h-12{height:3rem}.jwi-h-3\.5{height:.875rem}.jwi-h-4{height:1rem}.jwi-h-5{height:1.25rem}.jwi-h-6{height:1.5rem}.jwi-h-\[14px\]{height:14px}.jwi-h-\[18px\]{height:18px}.jwi-h-\[22px\]{height:22px}.jwi-h-\[60px\]{height:60px}.jwi-max-h-\[min\(60vh\,480px\)\]{max-height:min(60vh,480px)}.jwi-min-h-\[48px\]{min-height:48px}.jwi-min-h-\[56px\]{min-height:56px}.jwi-w-14{width:3.5rem}.jwi-w-2\/3{width:66.666667%}.jwi-w-24{width:6rem}.jwi-w-28{width:7rem}.jwi-w-3\.5{width:.875rem}.jwi-w-4{width:1rem}.jwi-w-48{width:12rem}.jwi-w-5{width:1.25rem}.jwi-w-\[14px\]{width:14px}.jwi-w-\[18px\]{width:18px}.jwi-w-\[22px\]{width:22px}.jwi-w-\[540px\]{width:540px}.jwi-w-auto{width:auto}.jwi-w-fit{width:-moz-fit-content;width:fit-content}.jwi-w-full{width:100%}.jwi-min-w-0{min-width:0}.jwi-max-w-\[220px\]{max-width:220px}.jwi-max-w-\[70\%\]{max-width:70%}.jwi-max-w-\[calc\(100\%-5rem\)\]{max-width:calc(100% - 5rem)}.jwi-max-w-full{max-width:100%}.jwi-flex-1{flex:1 1 0%}.jwi-flex-shrink-0,.jwi-shrink-0{flex-shrink:0}@keyframes jwi-pulse{50%{opacity:.5}}.jwi-animate-pulse{animation:jwi-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes jwi-spin{to{transform:rotate(1turn)}}.jwi-animate-spin{animation:jwi-spin 1s linear infinite}.jwi-cursor-pointer{cursor:pointer}.jwi-resize-y{resize:vertical}.jwi-flex-row{flex-direction:row}.jwi-flex-col{flex-direction:column}.jwi-items-start{align-items:flex-start}.jwi-items-center{align-items:center}.jwi-items-stretch{align-items:stretch}.jwi-justify-center{justify-content:center}.jwi-justify-between{justify-content:space-between}.jwi-gap-0\.5{gap:.125rem}.jwi-gap-1\.5{gap:.375rem}.jwi-gap-2{gap:.5rem}.jwi-gap-3{gap:.75rem}.jwi-gap-4{gap:1rem}.jwi-space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.jwi-self-stretch{align-self:stretch}.jwi-overflow-hidden{overflow:hidden}.jwi-overflow-y-auto{overflow-y:auto}.jwi-whitespace-nowrap{white-space:nowrap}.jwi-break-all{word-break:break-all}.jwi-rounded-\[10px\]{border-radius:10px}.jwi-rounded-full{border-radius:9999px}.jwi-border{border-width:1px}.jwi-border-0{border-width:0}.jwi-border-b{border-bottom-width:1px}.jwi-border-\[\#b7e5c2\]{--tw-border-opacity:1;border-color:rgb(183 229 194/var(--tw-border-opacity,1))}.jwi-border-\[\#d8d2c7\]{--tw-border-opacity:1;border-color:rgb(216 210 199/var(--tw-border-opacity,1))}.jwi-border-\[\#e6e1d7\]{--tw-border-opacity:1;border-color:rgb(230 225 215/var(--tw-border-opacity,1))}.jwi-border-\[\#f0c7c2\]{--tw-border-opacity:1;border-color:rgb(240 199 194/var(--tw-border-opacity,1))}.jwi-bg-\[\#FCFCFC\]{--tw-bg-opacity:1;background-color:rgb(252 252 252/var(--tw-bg-opacity,1))}.jwi-bg-\[\#ece8df\]{--tw-bg-opacity:1;background-color:rgb(236 232 223/var(--tw-bg-opacity,1))}.jwi-bg-\[\#eefbf2\]{--tw-bg-opacity:1;background-color:rgb(238 251 242/var(--tw-bg-opacity,1))}.jwi-bg-\[\#ef2b18\]{--tw-bg-opacity:1;background-color:rgb(239 43 24/var(--tw-bg-opacity,1))}.jwi-bg-\[\#f7f5ef\]{--tw-bg-opacity:1;background-color:rgb(247 245 239/var(--tw-bg-opacity,1))}.jwi-bg-\[\#fbf3db\]{--tw-bg-opacity:1;background-color:rgb(251 243 219/var(--tw-bg-opacity,1))}.jwi-bg-\[\#fff3f1\]{--tw-bg-opacity:1;background-color:rgb(255 243 241/var(--tw-bg-opacity,1))}.jwi-bg-transparent{background-color:transparent}.jwi-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.jwi-bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.jwi-from-white{--tw-gradient-from:#fff var(--tw-gradient-from-position);--tw-gradient-to:hsla(0,0%,100%,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.jwi-to-transparent{--tw-gradient-to:transparent var(--tw-gradient-to-position)}.jwi-p-0{padding:0}.jwi-p-4{padding:1rem}.jwi-p-6{padding:1.5rem}.jwi-px-2\.5{padding-left:.625rem;padding-right:.625rem}.jwi-px-4{padding-left:1rem;padding-right:1rem}.jwi-px-5{padding-left:1.25rem;padding-right:1.25rem}.jwi-px-6{padding-left:1.5rem;padding-right:1.5rem}.jwi-px-7{padding-left:1.75rem;padding-right:1.75rem}.jwi-py-1{padding-top:.25rem;padding-bottom:.25rem}.jwi-py-3{padding-top:.75rem;padding-bottom:.75rem}.jwi-py-4{padding-top:1rem;padding-bottom:1rem}.jwi-py-8{padding-top:2rem;padding-bottom:2rem}.jwi-pb-3{padding-bottom:.75rem}.jwi-pl-5{padding-left:1.25rem}.jwi-pr-1{padding-right:.25rem}.jwi-pr-3{padding-right:.75rem}.jwi-pr-\[12px\]{padding-right:12px}.jwi-text-left{text-align:left}.jwi-font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.jwi-text-\[14px\]{font-size:14px}.jwi-text-base{font-size:1rem;line-height:1.5rem}.jwi-text-sm{font-size:.875rem;line-height:1.25rem}.jwi-text-xs{font-size:.75rem;line-height:1rem}.jwi-font-medium{font-weight:500}.jwi-font-normal{font-weight:400}.jwi-font-semibold{font-weight:600}.jwi-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.jwi-leading-\[1\.35\]{line-height:1.35}.jwi-leading-\[1\.4\]{line-height:1.4}.jwi-leading-none{line-height:1}.jwi-leading-snug{line-height:1.375}.jwi-text-\[\#111111\]{--tw-text-opacity:1;color:rgb(17 17 17/var(--tw-text-opacity,1))}.jwi-text-\[\#1b5e20\]{--tw-text-opacity:1;color:rgb(27 94 32/var(--tw-text-opacity,1))}.jwi-text-\[\#767676\]{--tw-text-opacity:1;color:rgb(118 118 118/var(--tw-text-opacity,1))}.jwi-text-\[\#8f2d21\]{--tw-text-opacity:1;color:rgb(143 45 33/var(--tw-text-opacity,1))}.jwi-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.jwi-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.jwi-opacity-25{opacity:.25}.jwi-opacity-75{opacity:.75}.jwi-opacity-95{opacity:.95}.jwi-shadow-\[0_1px_2px_rgba\(17\,17\,17\,0\.03\)\]{--tw-shadow:0 1px 2px hsla(0,0%,7%,.03);--tw-shadow-colored:0 1px 2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.jwi-shadow-\[0_8px_24px_rgba\(17\,17\,17\,0\.08\)\]{--tw-shadow:0 8px 24px hsla(0,0%,7%,.08);--tw-shadow-colored:0 8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.jwi-outline-none{outline:2px solid transparent;outline-offset:2px}.placeholder\:jwi-text-\[\#767676\]::-moz-placeholder{--tw-text-opacity:1;color:rgb(118 118 118/var(--tw-text-opacity,1))}.placeholder\:jwi-text-\[\#767676\]::placeholder{--tw-text-opacity:1;color:rgb(118 118 118/var(--tw-text-opacity,1))}.hover\:jwi-bg-\[\#d92817\]:hover{--tw-bg-opacity:1;background-color:rgb(217 40 23/var(--tw-bg-opacity,1))}.hover\:jwi-bg-\[\#f7f5f0\]:hover{--tw-bg-opacity:1;background-color:rgb(247 245 240/var(--tw-bg-opacity,1))}.hover\:jwi-text-\[\#444444\]:hover{--tw-text-opacity:1;color:rgb(68 68 68/var(--tw-text-opacity,1))}.hover\:jwi-underline:hover{text-decoration-line:underline}.focus\:jwi-border-\[\#111111\]:focus{--tw-border-opacity:1;border-color:rgb(17 17 17/var(--tw-border-opacity,1))}.disabled\:jwi-cursor-wait:disabled{cursor:wait}.disabled\:hover\:jwi-bg-\[\#ef2b18\]:hover:disabled{--tw-bg-opacity:1;background-color:rgb(239 43 24/var(--tw-bg-opacity,1))}@media (min-width:768px){.md\:jwi-max-w-\[220px\]{max-width:220px}.md\:jwi-flex-row{flex-direction:row}.md\:jwi-items-center{align-items:center}.md\:jwi-justify-between{justify-content:space-between}}
|
|
1
|
+
.jwi-pointer-events-none{pointer-events:none}.jwi-fixed{position:fixed}.jwi-absolute{position:absolute}.jwi-relative{position:relative}.jwi-inset-0{inset:0}.jwi-inset-x-0{left:0;right:0}.jwi-bottom-0{bottom:0}.jwi-left-0{left:0}.jwi-right-0{right:0}.jwi-right-3{right:.75rem}.jwi-top-3{top:.75rem}.jwi-z-20{z-index:20}.jwi-z-30{z-index:30}.jwi-z-\[1200\]{z-index:1200}.jwi-z-\[9999\]{z-index:9999}.jwi-m-0{margin:0}.jwi--mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.-jwi-mt-px{margin-top:-1px}.jwi-mb-3{margin-bottom:.75rem}.jwi-mr-\[-12px\]{margin-right:-12px}.jwi-mt-2{margin-top:.5rem}.jwi-mt-3{margin-top:.75rem}.jwi-mt-4{margin-top:1rem}.jwi-box-border{box-sizing:border-box}.jwi-flex{display:flex}.jwi-inline-flex{display:inline-flex}.jwi-h-10{height:2.5rem}.jwi-h-12{height:3rem}.jwi-h-14{height:3.5rem}.jwi-h-3\.5{height:.875rem}.jwi-h-4{height:1rem}.jwi-h-5{height:1.25rem}.jwi-h-6{height:1.5rem}.jwi-h-9{height:2.25rem}.jwi-h-\[14px\]{height:14px}.jwi-h-\[18px\]{height:18px}.jwi-h-\[22px\]{height:22px}.jwi-h-\[45\%\]{height:45%}.jwi-h-\[60px\]{height:60px}.jwi-h-\[78vh\]{height:78vh}.jwi-h-\[calc\(78vh-48px\)\]{height:calc(78vh - 48px)}.jwi-h-\[min\(85vh\,860px\)\]{height:min(85vh,860px)}.jwi-h-auto{height:auto}.jwi-h-full{height:100%}.jwi-max-h-\[min\(60vh\,480px\)\]{max-height:min(60vh,480px)}.jwi-max-h-none{max-height:none}.jwi-min-h-0{min-height:0}.jwi-min-h-\[48px\]{min-height:48px}.jwi-min-h-\[56px\]{min-height:56px}.jwi-w-14{width:3.5rem}.jwi-w-2\/3{width:66.666667%}.jwi-w-24{width:6rem}.jwi-w-28{width:7rem}.jwi-w-3\.5{width:.875rem}.jwi-w-4{width:1rem}.jwi-w-48{width:12rem}.jwi-w-5{width:1.25rem}.jwi-w-9{width:2.25rem}.jwi-w-\[14px\]{width:14px}.jwi-w-\[18px\]{width:18px}.jwi-w-\[22px\]{width:22px}.jwi-w-\[40px\]{width:40px}.jwi-w-\[540px\]{width:540px}.jwi-w-\[min\(96vw\,1200px\)\]{width:min(96vw,1200px)}.jwi-w-auto{width:auto}.jwi-w-fit{width:-moz-fit-content;width:fit-content}.jwi-w-full{width:100%}.jwi-min-w-0{min-width:0}.jwi-max-w-\[220px\]{max-width:220px}.jwi-max-w-\[70\%\]{max-width:70%}.jwi-max-w-\[calc\(100\%-5rem\)\]{max-width:calc(100% - 5rem)}.jwi-max-w-full{max-width:100%}.jwi-flex-1{flex:1 1 0%}.jwi-flex-shrink-0,.jwi-shrink-0{flex-shrink:0}.jwi-scale-100{--tw-scale-x:1;--tw-scale-y:1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes jwi-pulse{50%{opacity:.5}}.jwi-animate-pulse{animation:jwi-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes jwi-spin{to{transform:rotate(1turn)}}.jwi-animate-spin{animation:jwi-spin 1s linear infinite}.jwi-cursor-pointer{cursor:pointer}.jwi-resize-y{resize:vertical}.jwi-flex-row{flex-direction:row}.jwi-flex-col{flex-direction:column}.jwi-items-start{align-items:flex-start}.jwi-items-center{align-items:center}.jwi-items-stretch{align-items:stretch}.jwi-justify-end{justify-content:flex-end}.jwi-justify-center{justify-content:center}.jwi-justify-between{justify-content:space-between}.jwi-gap-0\.5{gap:.125rem}.jwi-gap-1{gap:.25rem}.jwi-gap-1\.5{gap:.375rem}.jwi-gap-2{gap:.5rem}.jwi-gap-3{gap:.75rem}.jwi-gap-4{gap:1rem}.jwi-space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.jwi-self-stretch{align-self:stretch}.jwi-overflow-hidden{overflow:hidden}.jwi-overflow-y-auto{overflow-y:auto}.jwi-overscroll-y-contain{overscroll-behavior-y:contain}.jwi-whitespace-nowrap{white-space:nowrap}.jwi-break-all{word-break:break-all}.jwi-rounded-\[10px\]{border-radius:10px}.jwi-rounded-full{border-radius:9999px}.jwi-rounded-b-\[10px\]{border-bottom-right-radius:10px;border-bottom-left-radius:10px}.jwi-rounded-t-\[10px\]{border-top-left-radius:10px;border-top-right-radius:10px}.jwi-rounded-t-\[16px\]{border-top-left-radius:16px;border-top-right-radius:16px}.jwi-border{border-width:1px}.jwi-border-0{border-width:0}.jwi-border-b{border-bottom-width:1px}.jwi-border-t{border-top-width:1px}.jwi-border-t-0{border-top-width:0}.jwi-border-\[\#b7e5c2\]{--tw-border-opacity:1;border-color:rgb(183 229 194/var(--tw-border-opacity,1))}.jwi-border-\[\#d8d2c7\]{--tw-border-opacity:1;border-color:rgb(216 210 199/var(--tw-border-opacity,1))}.jwi-border-\[\#e6e1d7\]{--tw-border-opacity:1;border-color:rgb(230 225 215/var(--tw-border-opacity,1))}.jwi-border-\[\#ef2b18\]{--tw-border-opacity:1;border-color:rgb(239 43 24/var(--tw-border-opacity,1))}.jwi-border-\[\#f0c7c2\]{--tw-border-opacity:1;border-color:rgb(240 199 194/var(--tw-border-opacity,1))}.jwi-bg-\[\#FCFCFC\]{--tw-bg-opacity:1;background-color:rgb(252 252 252/var(--tw-bg-opacity,1))}.jwi-bg-\[\#ece8df\]{--tw-bg-opacity:1;background-color:rgb(236 232 223/var(--tw-bg-opacity,1))}.jwi-bg-\[\#eefbf2\]{--tw-bg-opacity:1;background-color:rgb(238 251 242/var(--tw-bg-opacity,1))}.jwi-bg-\[\#ef2b18\]{--tw-bg-opacity:1;background-color:rgb(239 43 24/var(--tw-bg-opacity,1))}.jwi-bg-\[\#f0f0f0\]{--tw-bg-opacity:1;background-color:rgb(240 240 240/var(--tw-bg-opacity,1))}.jwi-bg-\[\#f7f5ef\]{--tw-bg-opacity:1;background-color:rgb(247 245 239/var(--tw-bg-opacity,1))}.jwi-bg-\[\#fbf3db\]{--tw-bg-opacity:1;background-color:rgb(251 243 219/var(--tw-bg-opacity,1))}.jwi-bg-\[\#fff3f1\]{--tw-bg-opacity:1;background-color:rgb(255 243 241/var(--tw-bg-opacity,1))}.jwi-bg-black\/45{background-color:rgba(0,0,0,.45)}.jwi-bg-transparent{background-color:transparent}.jwi-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.jwi-bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.jwi-from-white{--tw-gradient-from:#fff var(--tw-gradient-from-position);--tw-gradient-to:hsla(0,0%,100%,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.jwi-to-transparent{--tw-gradient-to:transparent var(--tw-gradient-to-position)}.jwi-p-0{padding:0}.jwi-p-1{padding:.25rem}.jwi-p-4{padding:1rem}.jwi-p-6{padding:1.5rem}.jwi-px-2\.5{padding-left:.625rem;padding-right:.625rem}.jwi-px-4{padding-left:1rem;padding-right:1rem}.jwi-px-5{padding-left:1.25rem;padding-right:1.25rem}.jwi-px-6{padding-left:1.5rem;padding-right:1.5rem}.jwi-px-7{padding-left:1.75rem;padding-right:1.75rem}.jwi-py-1{padding-top:.25rem;padding-bottom:.25rem}.jwi-py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.jwi-py-3{padding-top:.75rem;padding-bottom:.75rem}.jwi-py-4{padding-top:1rem;padding-bottom:1rem}.jwi-py-8{padding-top:2rem;padding-bottom:2rem}.jwi-pb-24{padding-bottom:6rem}.jwi-pb-3{padding-bottom:.75rem}.jwi-pl-5{padding-left:1.25rem}.jwi-pr-1{padding-right:.25rem}.jwi-pr-3{padding-right:.75rem}.jwi-pr-\[12px\]{padding-right:12px}.jwi-pt-3{padding-top:.75rem}.jwi-text-left{text-align:left}.jwi-font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.jwi-text-\[13px\]{font-size:13px}.jwi-text-base{font-size:1rem;line-height:1.5rem}.jwi-text-sm{font-size:.875rem;line-height:1.25rem}.jwi-text-xl{font-size:1.25rem;line-height:1.75rem}.jwi-text-xs{font-size:.75rem;line-height:1rem}.jwi-font-medium{font-weight:500}.jwi-font-normal{font-weight:400}.jwi-font-semibold{font-weight:600}.jwi-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.jwi-leading-\[1\.35\]{line-height:1.35}.jwi-leading-\[1\.4\]{line-height:1.4}.jwi-leading-none{line-height:1}.jwi-leading-snug{line-height:1.375}.jwi-text-\[\#000000\]{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.jwi-text-\[\#111111\]{--tw-text-opacity:1;color:rgb(17 17 17/var(--tw-text-opacity,1))}.jwi-text-\[\#1b5e20\]{--tw-text-opacity:1;color:rgb(27 94 32/var(--tw-text-opacity,1))}.jwi-text-\[\#555555\]{--tw-text-opacity:1;color:rgb(85 85 85/var(--tw-text-opacity,1))}.jwi-text-\[\#767676\]{--tw-text-opacity:1;color:rgb(118 118 118/var(--tw-text-opacity,1))}.jwi-text-\[\#8f2d21\]{--tw-text-opacity:1;color:rgb(143 45 33/var(--tw-text-opacity,1))}.jwi-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.jwi-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.jwi-opacity-25{opacity:.25}.jwi-opacity-75{opacity:.75}.jwi-opacity-95{opacity:.95}.jwi-shadow-\[0_-12px_36px_rgba\(0\,0\,0\,0\.22\)\]{--tw-shadow:0 -12px 36px rgba(0,0,0,.22);--tw-shadow-colored:0 -12px 36px var(--tw-shadow-color)}.jwi-shadow-\[0_-12px_36px_rgba\(0\,0\,0\,0\.22\)\],.jwi-shadow-\[0_-6px_20px_rgba\(0\,0\,0\,0\.12\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.jwi-shadow-\[0_-6px_20px_rgba\(0\,0\,0\,0\.12\)\]{--tw-shadow:0 -6px 20px rgba(0,0,0,.12);--tw-shadow-colored:0 -6px 20px var(--tw-shadow-color)}.jwi-shadow-\[0_1px_2px_rgba\(17\,17\,17\,0\.03\)\]{--tw-shadow:0 1px 2px hsla(0,0%,7%,.03);--tw-shadow-colored:0 1px 2px var(--tw-shadow-color)}.jwi-shadow-\[0_1px_2px_rgba\(17\,17\,17\,0\.03\)\],.jwi-shadow-\[0_20px_60px_rgba\(0\,0\,0\,0\.25\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.jwi-shadow-\[0_20px_60px_rgba\(0\,0\,0\,0\.25\)\]{--tw-shadow:0 20px 60px rgba(0,0,0,.25);--tw-shadow-colored:0 20px 60px var(--tw-shadow-color)}.jwi-shadow-\[0_2px_8px_rgba\(0\,0\,0\,0\.12\)\]{--tw-shadow:0 2px 8px rgba(0,0,0,.12);--tw-shadow-colored:0 2px 8px var(--tw-shadow-color)}.jwi-shadow-\[0_2px_8px_rgba\(0\,0\,0\,0\.12\)\],.jwi-shadow-\[0_8px_24px_rgba\(17\,17\,17\,0\.08\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.jwi-shadow-\[0_8px_24px_rgba\(17\,17\,17\,0\.08\)\]{--tw-shadow:0 8px 24px hsla(0,0%,7%,.08);--tw-shadow-colored:0 8px 24px var(--tw-shadow-color)}.jwi-outline-none{outline:2px solid transparent;outline-offset:2px}.jwi-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.placeholder\:jwi-text-\[13px\]::-moz-placeholder{font-size:13px}.placeholder\:jwi-text-\[13px\]::placeholder{font-size:13px}.placeholder\:jwi-text-\[\#767676\]::-moz-placeholder{--tw-text-opacity:1;color:rgb(118 118 118/var(--tw-text-opacity,1))}.placeholder\:jwi-text-\[\#767676\]::placeholder{--tw-text-opacity:1;color:rgb(118 118 118/var(--tw-text-opacity,1))}.hover\:jwi-bg-\[\#d92817\]:hover{--tw-bg-opacity:1;background-color:rgb(217 40 23/var(--tw-bg-opacity,1))}.hover\:jwi-bg-\[\#f7f5f0\]:hover{--tw-bg-opacity:1;background-color:rgb(247 245 240/var(--tw-bg-opacity,1))}.hover\:jwi-text-\[\#444444\]:hover{--tw-text-opacity:1;color:rgb(68 68 68/var(--tw-text-opacity,1))}.hover\:jwi-underline:hover{text-decoration-line:underline}.focus\:jwi-border-\[\#111111\]:focus{--tw-border-opacity:1;border-color:rgb(17 17 17/var(--tw-border-opacity,1))}.disabled\:jwi-cursor-wait:disabled{cursor:wait}.disabled\:hover\:jwi-bg-\[\#ef2b18\]:hover:disabled{--tw-bg-opacity:1;background-color:rgb(239 43 24/var(--tw-bg-opacity,1))}@media (min-width:768px){.md\:jwi-h-full{height:100%}.md\:jwi-w-\[48\%\]{width:48%}.md\:jwi-w-\[52\%\]{width:52%}.md\:jwi-max-w-\[220px\]{max-width:220px}.md\:jwi-flex-row{flex-direction:row}.md\:jwi-items-center{align-items:center}.md\:jwi-justify-between{justify-content:space-between}.md\:jwi-border-r{border-right-width:1px}.md\:jwi-border-\[\#ece8df\]{--tw-border-opacity:1;border-color:rgb(236 232 223/var(--tw-border-opacity,1))}.md\:jwi-text-\[14px\]{font-size:14px}.md\:jwi-text-base{font-size:1rem;line-height:1.5rem}.md\:placeholder\:jwi-text-\[14px\]::-moz-placeholder{font-size:14px}.md\:placeholder\:jwi-text-\[14px\]::placeholder{font-size:14px}}
|
package/dist/JotulWidget.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ import type { JotulWidgetProps } from './types';
|
|
|
4
4
|
export { DEFAULT_WIDGET_LOCALE_TAG, normalizeWidgetLocale, resolveWidgetUiLocale, } from './i18n/widgetStrings';
|
|
5
5
|
export type { JotulWidgetLocale } from './i18n/widgetStrings';
|
|
6
6
|
export { checkWidgetAuthorization, searchLocationSuggestions, searchDealersByCoordinates, searchDealersByPostalCode, };
|
|
7
|
-
export type { CheckWidgetAuthorizationOptions, DealerSearchResponse, JotulWidgetButtonStyling, JotulWidgetProps, JotulWidgetStyling, JotulWidgetType, WidgetAuthClientResponse, } from './types';
|
|
8
|
-
export declare function JotulWidget({ type, endpoint, className, productName, locale: localeProp, market: marketProp, brands, styling, }: JotulWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export type { CheckWidgetAuthorizationOptions, DealerSearchResponse, JotulWidgetButtonStyling, JotulWidgetProps, ProductPageTriggerRenderProps, JotulWidgetStyling, JotulWidgetType, WidgetAuthClientResponse, } from './types';
|
|
8
|
+
export declare function JotulWidget({ type, endpoint, className, productName, locale: localeProp, market: marketProp, brands, styling, productPageTrigger, }: JotulWidgetProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/JotulWidget.js
CHANGED
|
@@ -19,8 +19,8 @@ const GEOLOCATION_OPTIONS = {
|
|
|
19
19
|
timeout: 15000,
|
|
20
20
|
maximumAge: 300000,
|
|
21
21
|
};
|
|
22
|
-
export function JotulWidget({ type, endpoint = '/api/jotul/widget', className, productName, locale: localeProp, market: marketProp, brands, styling, }) {
|
|
23
|
-
const resolvedUiLocale = useMemo(() => resolveWidgetUiLocale(localeProp), [localeProp]);
|
|
22
|
+
export function JotulWidget({ type, endpoint = '/api/jotul/widget', className, productName, locale: localeProp, market: marketProp, brands, styling, productPageTrigger, }) {
|
|
23
|
+
const resolvedUiLocale = useMemo(() => resolveWidgetUiLocale(localeProp, marketProp), [localeProp, marketProp]);
|
|
24
24
|
const t = WIDGET_STRINGS[resolvedUiLocale];
|
|
25
25
|
const apiLocaleTag = useMemo(() => (localeProp?.trim() ? localeProp.trim() : DEFAULT_WIDGET_LOCALE_TAG), [localeProp]);
|
|
26
26
|
const apiMarket = useMemo(() => {
|
|
@@ -58,7 +58,6 @@ export function JotulWidget({ type, endpoint = '/api/jotul/widget', className, p
|
|
|
58
58
|
}), [apiLocaleTag, apiMarket, brands, endpoint]);
|
|
59
59
|
const runDealerSearchByCoordinates = useCallback(async (latitude, longitude) => {
|
|
60
60
|
setLocationError(null);
|
|
61
|
-
setSearchResult(null);
|
|
62
61
|
setIsSearching(true);
|
|
63
62
|
try {
|
|
64
63
|
const result = await searchDealersByCoordinates(latitude, longitude, dealerSearchOptions);
|
|
@@ -172,27 +171,42 @@ export function JotulWidget({ type, endpoint = '/api/jotul/widget', className, p
|
|
|
172
171
|
return 'typeReady';
|
|
173
172
|
}, [type]);
|
|
174
173
|
const widgetType = isWidgetType(type) ? type : undefined;
|
|
174
|
+
const openProductPageWidget = useCallback(() => {
|
|
175
|
+
setLocationError(null);
|
|
176
|
+
setSearchResult(null);
|
|
177
|
+
setLocationQuery('');
|
|
178
|
+
setLocationSuggestions([]);
|
|
179
|
+
setIsSuggestionListOpen(false);
|
|
180
|
+
setIsOpen(true);
|
|
181
|
+
if (auth?.ok && auth.authorized === true && !isLoading) {
|
|
182
|
+
setShouldAutoLocateAfterAuth(false);
|
|
183
|
+
runLocationSearch();
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
setShouldAutoLocateAfterAuth(true);
|
|
187
|
+
}
|
|
188
|
+
}, [auth, isLoading, runLocationSearch]);
|
|
175
189
|
const shellClass = 'jwi-box-border jwi-flex jwi-w-[540px] jwi-max-w-full jwi-flex-col jwi-font-sans jwi-text-[#111111]';
|
|
176
190
|
const rootClass = className != null && className !== '' ? `${shellClass} ${className}` : shellClass;
|
|
177
191
|
if (typeState !== 'typeReady') {
|
|
178
192
|
return _jsx("div", { className: rootClass, children: t.invalidWidgetTypeError });
|
|
179
193
|
}
|
|
180
194
|
if (widgetType === 'productPage' && !isOpen) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
const trigger = typeof productPageTrigger === 'function'
|
|
196
|
+
? productPageTrigger({
|
|
197
|
+
onOpen: openProductPageWidget,
|
|
198
|
+
isLoading,
|
|
199
|
+
label: t.findDealer,
|
|
200
|
+
className: heroPrimaryButton.className,
|
|
201
|
+
style: heroPrimaryButton.style,
|
|
202
|
+
})
|
|
203
|
+
: productPageTrigger;
|
|
204
|
+
return (_jsx("div", { className: rootClass, children: _jsx("div", { className: "jwi-flex jwi-py-8 jwi-items-center jwi-justify-center", children: trigger != null ? (_jsx("div", { role: "button", tabIndex: 0, onClick: openProductPageWidget, onKeyDown: (event) => {
|
|
205
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
openProductPageWidget();
|
|
194
208
|
}
|
|
195
|
-
}, className: heroPrimaryButton.className, style: heroPrimaryButton.style, children: t.findDealer }) }) }));
|
|
209
|
+
}, children: trigger })) : (_jsx("button", { type: "button", onClick: openProductPageWidget, className: heroPrimaryButton.className, style: heroPrimaryButton.style, children: t.findDealer })) }) }));
|
|
196
210
|
}
|
|
197
211
|
const productPageAuthPending = widgetType === 'productPage' && isOpen && (auth === null || isLoading);
|
|
198
212
|
if (productPageAuthPending) {
|
|
@@ -215,6 +229,23 @@ export function JotulWidget({ type, endpoint = '/api/jotul/widget', className, p
|
|
|
215
229
|
if (trimmed.length < 3) {
|
|
216
230
|
setLocationSuggestions([]);
|
|
217
231
|
}
|
|
232
|
+
}, onQuerySubmit: async (value) => {
|
|
233
|
+
const query = value.trim();
|
|
234
|
+
if (query.length < 3)
|
|
235
|
+
return;
|
|
236
|
+
setIsSearchingSuggestions(true);
|
|
237
|
+
const result = await searchLocationSuggestions(query, dealerSearchOptions);
|
|
238
|
+
const resolvedSuggestions = result.ok && Array.isArray(result.suggestions) ? result.suggestions : [];
|
|
239
|
+
setLocationSuggestions(resolvedSuggestions);
|
|
240
|
+
setIsSearchingSuggestions(false);
|
|
241
|
+
const suggestion = resolvedSuggestions[0];
|
|
242
|
+
if (!suggestion)
|
|
243
|
+
return;
|
|
244
|
+
setLocationQuery(suggestion.label);
|
|
245
|
+
setLocationSuggestions([]);
|
|
246
|
+
setIsSearchingSuggestions(false);
|
|
247
|
+
setIsSuggestionListOpen(false);
|
|
248
|
+
await runDealerSearchByCoordinates(suggestion.latitude, suggestion.longitude);
|
|
218
249
|
}, onSuggestionSelect: (suggestion) => {
|
|
219
250
|
setLocationQuery(suggestion.label);
|
|
220
251
|
setLocationSuggestions([]);
|
|
@@ -252,6 +283,11 @@ export function JotulWidget({ type, endpoint = '/api/jotul/widget', className, p
|
|
|
252
283
|
setInquiryValues(createInquiryFormValues(productName, dealerName));
|
|
253
284
|
setInquiryError(null);
|
|
254
285
|
setIsInquirySubmitted(false);
|
|
286
|
+
}, onClosePopup: () => {
|
|
287
|
+
setIsOpen(false);
|
|
288
|
+
setLocationSuggestions([]);
|
|
289
|
+
setIsSuggestionListOpen(false);
|
|
290
|
+
setIsSearchingSuggestions(false);
|
|
255
291
|
} }) }));
|
|
256
292
|
}
|
|
257
293
|
return _jsx("div", { className: rootClass, children: renderReadyState(widgetType, t) });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'leaflet/dist/leaflet.css';
|
|
1
2
|
import type { WidgetStrings } from '../i18n/widgetStrings';
|
|
2
3
|
import type { DealerSearchResponse, InquiryFormValues, JotulWidgetButtonStyling, LocationSuggestion } from '../types';
|
|
3
4
|
type ProductPageWidgetProps = {
|
|
@@ -16,12 +17,14 @@ type ProductPageWidgetProps = {
|
|
|
16
17
|
suggestionsOpen: boolean;
|
|
17
18
|
isSuggestionsLoading: boolean;
|
|
18
19
|
onQueryChange: (value: string) => void;
|
|
20
|
+
onQuerySubmit: (value: string) => void | Promise<void>;
|
|
19
21
|
onSuggestionSelect: (suggestion: LocationSuggestion) => void;
|
|
20
22
|
onDismissSuggestions: () => void;
|
|
21
23
|
onInquiryClose: () => void;
|
|
22
24
|
onInquirySubmit: () => void;
|
|
23
25
|
onInquiryFieldChange: (key: keyof InquiryFormValues, value: string) => void;
|
|
24
26
|
onStartInquiry: (dealerName: string) => void;
|
|
27
|
+
onClosePopup?: () => void;
|
|
25
28
|
};
|
|
26
|
-
export declare function ProductPageWidget({ t, buttonStyling, isSearching, locationError, searchResult, inquiryValues, inquiryError, isInquirySubmitted, selectedDealerName, isManualSearchEnabled, query, suggestions, suggestionsOpen, isSuggestionsLoading, onQueryChange, onSuggestionSelect, onDismissSuggestions, onInquiryClose, onInquirySubmit, onInquiryFieldChange, onStartInquiry, }: ProductPageWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare function ProductPageWidget({ t, buttonStyling, isSearching, locationError, searchResult, inquiryValues, inquiryError, isInquirySubmitted, selectedDealerName, isManualSearchEnabled, query, suggestions, suggestionsOpen, isSuggestionsLoading, onQueryChange, onQuerySubmit, onSuggestionSelect, onDismissSuggestions, onInquiryClose, onInquirySubmit, onInquiryFieldChange, onStartInquiry, onClosePopup, }: ProductPageWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
27
30
|
export {};
|
|
@@ -1,16 +1,181 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import 'leaflet/dist/leaflet.css';
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { icon } from 'leaflet';
|
|
5
|
+
import { MapContainer, Marker, TileLayer, Tooltip, useMap } from 'react-leaflet';
|
|
2
6
|
import { DealerCardSkeleton } from './DealerCardSkeleton';
|
|
3
7
|
import { DealerList } from './product-page/DealerList';
|
|
4
8
|
import { InquiryForm } from './product-page/InquiryForm';
|
|
5
9
|
import { LocationSearch } from './product-page/LocationSearch';
|
|
6
10
|
import { StatusBanner } from './product-page/StatusBanner';
|
|
11
|
+
import { ArrowRightIcon } from '../icons/ArrowRightIcon';
|
|
12
|
+
import dealerPin from '../images/dealer-pin.svg';
|
|
13
|
+
import dealerPinExclusive from '../images/dealer-pin-exclusive.svg';
|
|
7
14
|
import { R10 } from '../constants';
|
|
8
|
-
|
|
15
|
+
const MAPTILER_BASIC_TILE_URL = 'https://api.maptiler.com/maps/basic-v2/256/{z}/{x}/{y}.png';
|
|
16
|
+
const MAPTILER_FALLBACK_KEY = 'get_your_own_D6rA4zTHduk6KOKTXzGB';
|
|
17
|
+
function getMapTilerKey() {
|
|
18
|
+
if (typeof window === 'undefined')
|
|
19
|
+
return MAPTILER_FALLBACK_KEY;
|
|
20
|
+
const w = window;
|
|
21
|
+
if (typeof w.JOTUL_WIDGET_MAPTILER_KEY === 'string') {
|
|
22
|
+
const key = w.JOTUL_WIDGET_MAPTILER_KEY.trim();
|
|
23
|
+
if (key.length > 0)
|
|
24
|
+
return key;
|
|
25
|
+
}
|
|
26
|
+
return MAPTILER_FALLBACK_KEY;
|
|
27
|
+
}
|
|
28
|
+
function readNumber(value) {
|
|
29
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
30
|
+
return value;
|
|
31
|
+
if (typeof value === 'string') {
|
|
32
|
+
const parsed = Number(value);
|
|
33
|
+
if (Number.isFinite(parsed))
|
|
34
|
+
return parsed;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
function getDealerName(dealer) {
|
|
39
|
+
const raw = dealer.name;
|
|
40
|
+
return typeof raw === 'string' && raw.trim() ? raw.trim() : 'Unknown dealer';
|
|
41
|
+
}
|
|
42
|
+
function getDealerMapPoint(dealer) {
|
|
43
|
+
const latitude = readNumber(dealer.latitude);
|
|
44
|
+
const longitude = readNumber(dealer.longitude);
|
|
45
|
+
if (latitude == null || longitude == null)
|
|
46
|
+
return null;
|
|
47
|
+
const rawExclusive = dealer.exclusive;
|
|
48
|
+
const isExclusive = rawExclusive === true ||
|
|
49
|
+
rawExclusive === 1 ||
|
|
50
|
+
rawExclusive === '1' ||
|
|
51
|
+
rawExclusive === 'true' ||
|
|
52
|
+
rawExclusive === 'TRUE' ||
|
|
53
|
+
rawExclusive === 'yes' ||
|
|
54
|
+
rawExclusive === 'YES' ||
|
|
55
|
+
rawExclusive === 'y' ||
|
|
56
|
+
rawExclusive === 'Y';
|
|
57
|
+
return {
|
|
58
|
+
dealer,
|
|
59
|
+
dealerName: getDealerName(dealer),
|
|
60
|
+
latitude,
|
|
61
|
+
longitude,
|
|
62
|
+
isExclusive,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function toAssetSrc(value) {
|
|
66
|
+
return typeof value === 'string' ? value : value.src;
|
|
67
|
+
}
|
|
68
|
+
function createDealerPinIcon(isExclusive, active) {
|
|
69
|
+
const size = active ? 48 : 42;
|
|
70
|
+
const width = Math.round((16 / 20) * size);
|
|
71
|
+
const pinUrl = isExclusive ? toAssetSrc(dealerPinExclusive) : toAssetSrc(dealerPin);
|
|
72
|
+
return icon({
|
|
73
|
+
iconUrl: pinUrl,
|
|
74
|
+
iconRetinaUrl: pinUrl,
|
|
75
|
+
iconSize: [width, size],
|
|
76
|
+
iconAnchor: [Math.round(width / 2), size],
|
|
77
|
+
tooltipAnchor: [0, -Math.round(size * 0.85)],
|
|
78
|
+
className: 'jwi-map-pin',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function FitMapBounds({ points, defaultCenter, }) {
|
|
82
|
+
const map = useMap();
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const all = points.map((p) => [p.latitude, p.longitude]);
|
|
85
|
+
if (defaultCenter != null)
|
|
86
|
+
all.push(defaultCenter);
|
|
87
|
+
if (all.length === 0)
|
|
88
|
+
return;
|
|
89
|
+
if (all.length === 1) {
|
|
90
|
+
map.setView(all[0], 12, { animate: true });
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
map.fitBounds(all, { padding: [30, 30], animate: true, maxZoom: 14 });
|
|
94
|
+
}, [defaultCenter, map, points]);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function FocusActiveDealer({ point }) {
|
|
98
|
+
const map = useMap();
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (point == null)
|
|
101
|
+
return;
|
|
102
|
+
map.setView([point.latitude, point.longitude], Math.max(map.getZoom(), 13), {
|
|
103
|
+
animate: true,
|
|
104
|
+
});
|
|
105
|
+
}, [map, point]);
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
export function ProductPageWidget({ t, buttonStyling, isSearching, locationError, searchResult, inquiryValues, inquiryError, isInquirySubmitted, selectedDealerName, isManualSearchEnabled, query, suggestions, suggestionsOpen, isSuggestionsLoading, onQueryChange, onQuerySubmit, onSuggestionSelect, onDismissSuggestions, onInquiryClose, onInquirySubmit, onInquiryFieldChange, onStartInquiry, onClosePopup, }) {
|
|
9
109
|
const dealers = (searchResult?.dealers ?? []);
|
|
10
110
|
const total = searchResult?.total ?? dealers.length;
|
|
11
111
|
const inquiryFormOpen = inquiryValues != null;
|
|
12
|
-
|
|
112
|
+
const [viewMode, setViewMode] = useState('list');
|
|
113
|
+
const [activeDealerName, setActiveDealerName] = useState(null);
|
|
114
|
+
const [mobileMapExpanded, setMobileMapExpanded] = useState(false);
|
|
115
|
+
const [isMobileViewport, setIsMobileViewport] = useState(false);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (viewMode !== 'map') {
|
|
118
|
+
setMobileMapExpanded(false);
|
|
119
|
+
}
|
|
120
|
+
}, [viewMode]);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (viewMode !== 'map')
|
|
123
|
+
return;
|
|
124
|
+
const previous = document.body.style.overflow;
|
|
125
|
+
document.body.style.overflow = 'hidden';
|
|
126
|
+
return () => {
|
|
127
|
+
document.body.style.overflow = previous;
|
|
128
|
+
};
|
|
129
|
+
}, [viewMode]);
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (typeof window === 'undefined')
|
|
132
|
+
return;
|
|
133
|
+
const media = window.matchMedia('(max-width: 767px)');
|
|
134
|
+
const update = () => setIsMobileViewport(media.matches);
|
|
135
|
+
update();
|
|
136
|
+
media.addEventListener('change', update);
|
|
137
|
+
return () => media.removeEventListener('change', update);
|
|
138
|
+
}, []);
|
|
139
|
+
const mapPoints = useMemo(() => dealers.map((dealer) => getDealerMapPoint(dealer)).filter((v) => v != null), [dealers]);
|
|
140
|
+
const defaultCenter = useMemo(() => {
|
|
141
|
+
const first = mapPoints[0];
|
|
142
|
+
if (first != null)
|
|
143
|
+
return [first.latitude, first.longitude];
|
|
144
|
+
const latitude = readNumber(searchResult?.origin?.latitude);
|
|
145
|
+
const longitude = readNumber(searchResult?.origin?.longitude);
|
|
146
|
+
if (latitude == null || longitude == null)
|
|
147
|
+
return null;
|
|
148
|
+
return [latitude, longitude];
|
|
149
|
+
}, [mapPoints, searchResult?.origin?.latitude, searchResult?.origin?.longitude]);
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
setActiveDealerName(dealers.length > 0 ? getDealerName(dealers[0]) : null);
|
|
152
|
+
}, [dealers]);
|
|
153
|
+
const activeMapPoint = useMemo(() => mapPoints.find((p) => p.dealerName === activeDealerName) ?? null, [activeDealerName, mapPoints]);
|
|
154
|
+
const mapTilerTileUrl = useMemo(() => `${MAPTILER_BASIC_TILE_URL}?key=${encodeURIComponent(getMapTilerKey())}`, []);
|
|
155
|
+
const listMapPills = (_jsxs("div", { className: "jwi-inline-flex jwi-items-center jwi-gap-1 jwi-rounded-full jwi-p-1", children: [_jsx("button", { type: "button", onClick: () => setViewMode('list'), className: `jwi-cursor-pointer jwi-rounded-full jwi-px-4 jwi-py-1.5 jwi-text-sm jwi-font-medium ${viewMode === 'list'
|
|
156
|
+
? 'jwi-bg-[#f0f0f0] jwi-text-[#000000]'
|
|
157
|
+
: 'jwi-bg-transparent jwi-text-[#555555]'}`, children: t.listView }), _jsx("button", { type: "button", onClick: () => setViewMode('map'), className: `jwi-cursor-pointer jwi-rounded-full jwi-px-4 jwi-py-1.5 jwi-text-sm jwi-font-medium ${viewMode === 'map'
|
|
158
|
+
? 'jwi-bg-[#f0f0f0] jwi-text-[#000000]'
|
|
159
|
+
: 'jwi-bg-transparent jwi-text-[#555555]'}`, children: t.mapView })] }));
|
|
160
|
+
const mapCanvas = (_jsxs(MapContainer, { center: defaultCenter ?? [59.9139, 10.7522], zoom: 10, className: "jwi-h-full jwi-w-full", zoomControl: true, children: [_jsx(TileLayer, { attribution: '\u00A9 <a href="https://www.maptiler.com/copyright/" target="_blank" rel="noreferrer">MapTiler</a> \u00A9 <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">OpenStreetMap</a> contributors', url: mapTilerTileUrl }), _jsx(FitMapBounds, { points: mapPoints, defaultCenter: defaultCenter }), _jsx(FocusActiveDealer, { point: activeMapPoint }), mapPoints.map((point) => {
|
|
161
|
+
const isActive = activeDealerName === point.dealerName;
|
|
162
|
+
return (_jsx(Marker, { position: [point.latitude, point.longitude], icon: createDealerPinIcon(point.isExclusive, isActive), eventHandlers: {
|
|
163
|
+
click: () => setActiveDealerName(point.dealerName),
|
|
164
|
+
}, children: _jsx(Tooltip, { children: point.dealerName }) }, `${point.dealerName}-${point.latitude}-${point.longitude}`));
|
|
165
|
+
})] }));
|
|
166
|
+
const showInquiryInMapPopup = inquiryFormOpen && searchResult?.ok && viewMode === 'map';
|
|
167
|
+
const handleDealerFocus = (dealerName) => {
|
|
168
|
+
setActiveDealerName(dealerName);
|
|
169
|
+
};
|
|
170
|
+
const closeMapPopup = () => {
|
|
171
|
+
if (onClosePopup != null) {
|
|
172
|
+
onClosePopup();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
setViewMode('list');
|
|
176
|
+
};
|
|
177
|
+
if (inquiryFormOpen && searchResult?.ok && viewMode !== 'map') {
|
|
13
178
|
return (_jsx("div", { className: "jwi-flex jwi-w-full jwi-flex-col jwi-gap-3", children: _jsx(InquiryForm, { t: t, buttonStyling: buttonStyling, inquiryValues: inquiryValues, inquiryError: inquiryError, onInquiryClose: onInquiryClose, onInquirySubmit: onInquirySubmit, onInquiryFieldChange: onInquiryFieldChange }) }));
|
|
14
179
|
}
|
|
15
|
-
return (_jsxs("div", { className: `jwi-flex jwi-w-full jwi-flex-col jwi-gap-3 ${R10} jwi-border jwi-border-[#e6e1d7] jwi-bg-white jwi-p-6`, children: [_jsx(LocationSearch, { t: t, isManualSearchEnabled: isManualSearchEnabled, query: query, suggestions: suggestions, suggestionsOpen: suggestionsOpen, isSuggestionsLoading: isSuggestionsLoading, onQueryChange: onQueryChange, onSuggestionSelect: onSuggestionSelect, onDismissSuggestions: onDismissSuggestions }), locationError != null && !isManualSearchEnabled && (_jsx(StatusBanner, { tone: "error", children: locationError })), searchResult?.ok === false && (_jsx(StatusBanner, { tone: "error", children: searchResult.error ?? '' })), isInquirySubmitted && _jsx(StatusBanner, { tone: "success", children: t.inquirySentSuccess }), isSearching && (_jsxs("div", { className: "jwi-flex jwi-flex-col", children: [_jsx("div", { className: "jwi-w-full jwi-flex-shrink-0 jwi-border-b jwi-border-[#e6e1d7] jwi-pb-3", children: _jsx("div", { className: "jwi-h-5 jwi-w-48 jwi-animate-pulse jwi-rounded-full jwi-bg-[#ece8df]" }) }), _jsxs("div", { className: "jwi-mt-3 jwi-mr-[-12px] jwi-flex jwi-max-h-[min(60vh,480px)] jwi-flex-col jwi-gap-4 jwi-overflow-y-auto jwi-pr-[12px]", children: [_jsx(DealerCardSkeleton, {}), _jsx(DealerCardSkeleton, {}), _jsx(DealerCardSkeleton, {})] })] })), searchResult?.ok && !isSearching && (_jsx(DealerList, { dealers: dealers, total: total, selectedDealerName: selectedDealerName, t: t, buttonStyling: buttonStyling, onStartInquiry: onStartInquiry }))] }));
|
|
180
|
+
return (_jsxs(_Fragment, { children: [viewMode === 'list' && (_jsxs("div", { className: `jwi-flex jwi-w-full jwi-flex-col jwi-gap-3 ${R10} jwi-border jwi-border-[#e6e1d7] jwi-bg-white jwi-p-6`, children: [_jsx(LocationSearch, { t: t, isManualSearchEnabled: isManualSearchEnabled, query: query, suggestions: suggestions, suggestionsOpen: suggestionsOpen, isSuggestionsLoading: isSuggestionsLoading, onQueryChange: onQueryChange, onQuerySubmit: onQuerySubmit, onSuggestionSelect: onSuggestionSelect, onDismissSuggestions: onDismissSuggestions }), locationError != null && !isManualSearchEnabled && (_jsx(StatusBanner, { tone: "error", children: locationError })), searchResult?.ok === false && (_jsx(StatusBanner, { tone: "error", children: searchResult.error ?? '' })), isInquirySubmitted && _jsx(StatusBanner, { tone: "success", children: t.inquirySentSuccess }), isSearching && (_jsxs("div", { className: "jwi-flex jwi-flex-col", children: [_jsx("div", { className: "jwi-w-full jwi-flex-shrink-0 jwi-border-b jwi-border-[#e6e1d7] jwi-pb-3", children: _jsx("div", { className: "jwi-h-5 jwi-w-48 jwi-animate-pulse jwi-rounded-full jwi-bg-[#ece8df]" }) }), _jsxs("div", { className: "jwi-mt-3 jwi-mr-[-12px] jwi-flex jwi-max-h-[min(60vh,480px)] jwi-flex-col jwi-gap-4 jwi-overflow-y-auto jwi-pr-[12px]", children: [_jsx(DealerCardSkeleton, {}), _jsx(DealerCardSkeleton, {}), _jsx(DealerCardSkeleton, {})] })] })), searchResult?.ok && !isSearching && viewMode === 'list' && (_jsx(DealerList, { dealers: dealers, total: total, selectedDealerName: selectedDealerName, headerRight: listMapPills, t: t, buttonStyling: buttonStyling, onStartInquiry: onStartInquiry }))] })), searchResult?.ok && viewMode === 'map' && (_jsxs(_Fragment, { children: [!isMobileViewport && (_jsx("div", { className: "jwi-fixed jwi-inset-0 jwi-z-[9999] jwi-flex jwi-items-center jwi-justify-center jwi-bg-black/45 jwi-p-4", onClick: () => setViewMode('list'), children: _jsxs("div", { className: `jwi-relative jwi-flex jwi-h-[min(85vh,860px)] jwi-w-[min(96vw,1200px)] jwi-scale-100 jwi-flex-col jwi-overflow-hidden ${R10} jwi-bg-white jwi-shadow-[0_20px_60px_rgba(0,0,0,0.25)] jwi-transition-all md:jwi-flex-row`, onClick: (event) => event.stopPropagation(), children: [_jsx("button", { type: "button", onClick: closeMapPopup, className: "jwi-absolute jwi-right-3 jwi-top-3 jwi-z-[1200] jwi-inline-flex jwi-h-9 jwi-w-9 jwi-cursor-pointer jwi-items-center jwi-justify-center jwi-rounded-full jwi-border jwi-border-[#d8d2c7] jwi-bg-white jwi-text-xl jwi-leading-none jwi-text-[#111111] jwi-shadow-[0_2px_8px_rgba(0,0,0,0.12)]", "aria-label": t.closeMap, children: "\u00D7" }), _jsx("div", { className: "jwi-flex jwi-h-full jwi-min-h-0 jwi-w-full jwi-flex-col jwi-overflow-hidden md:jwi-w-[48%] md:jwi-border-r md:jwi-border-[#ece8df]", children: _jsx("div", { className: "jwi-flex jwi-h-full jwi-min-h-0 jwi-w-full jwi-flex-col jwi-gap-3 jwi-overflow-hidden jwi-bg-white jwi-p-6", children: showInquiryInMapPopup ? (_jsx(InquiryForm, { t: t, buttonStyling: buttonStyling, inquiryValues: inquiryValues, inquiryError: inquiryError, embedded: true, onInquiryClose: onInquiryClose, onInquirySubmit: onInquirySubmit, onInquiryFieldChange: onInquiryFieldChange })) : (_jsxs(_Fragment, { children: [_jsx(LocationSearch, { t: t, isManualSearchEnabled: isManualSearchEnabled, query: query, suggestions: suggestions, suggestionsOpen: suggestionsOpen, isSuggestionsLoading: isSuggestionsLoading, onQueryChange: onQueryChange, onQuerySubmit: onQuerySubmit, onSuggestionSelect: onSuggestionSelect, onDismissSuggestions: onDismissSuggestions }), locationError != null && !isManualSearchEnabled && (_jsx(StatusBanner, { tone: "error", children: locationError })), isInquirySubmitted && (_jsx(StatusBanner, { tone: "success", children: t.inquirySentSuccess })), _jsx(DealerList, { dealers: dealers, total: total, selectedDealerName: selectedDealerName, activeDealerName: activeDealerName, fitAvailableHeight: true, autoScrollToActive: true, maxHeightClassName: "jwi-max-h-none", headerRight: listMapPills, t: t, buttonStyling: buttonStyling, onStartInquiry: onStartInquiry, onSelectDealer: handleDealerFocus })] })) }) }), _jsx("div", { className: "jwi-relative jwi-h-[45%] jwi-w-full md:jwi-h-full md:jwi-w-[52%]", children: mapCanvas })] }) })), isMobileViewport && (_jsx("div", { className: "jwi-fixed jwi-inset-0 jwi-z-[9999] jwi-bg-white", children: _jsxs("div", { className: "jwi-relative jwi-flex jwi-h-full jwi-flex-col", children: [_jsx("div", { className: "jwi-flex jwi-justify-end jwi-bg-white jwi-px-4 jwi-pt-3", children: _jsx("button", { type: "button", onClick: closeMapPopup, className: "jwi-inline-flex jwi-h-9 jwi-w-9 jwi-cursor-pointer jwi-items-center jwi-justify-center jwi-rounded-full jwi-border jwi-border-[#d8d2c7] jwi-bg-white jwi-text-xl jwi-leading-none jwi-text-[#111111]", "aria-label": t.closeMap, children: "\u00D7" }) }), _jsx("div", { className: "jwi-min-h-0 jwi-flex-1 jwi-overflow-y-auto jwi-bg-white jwi-p-4 jwi-pb-24", children: showInquiryInMapPopup ? (_jsx(InquiryForm, { t: t, buttonStyling: buttonStyling, inquiryValues: inquiryValues, inquiryError: inquiryError, embedded: true, onInquiryClose: onInquiryClose, onInquirySubmit: onInquirySubmit, onInquiryFieldChange: onInquiryFieldChange })) : (_jsxs(_Fragment, { children: [_jsx(LocationSearch, { t: t, isManualSearchEnabled: isManualSearchEnabled, query: query, suggestions: suggestions, suggestionsOpen: suggestionsOpen, isSuggestionsLoading: isSuggestionsLoading, onQueryChange: onQueryChange, onQuerySubmit: onQuerySubmit, onSuggestionSelect: onSuggestionSelect, onDismissSuggestions: onDismissSuggestions }), locationError != null && !isManualSearchEnabled && (_jsx(StatusBanner, { tone: "error", children: locationError })), isInquirySubmitted && (_jsx(StatusBanner, { tone: "success", children: t.inquirySentSuccess })), _jsx(DealerList, { dealers: dealers, total: total, selectedDealerName: selectedDealerName, activeDealerName: activeDealerName, maxHeightClassName: "jwi-max-h-none", autoScrollToActive: true, enableInternalScroll: false, headerRight: listMapPills, t: t, buttonStyling: buttonStyling, onStartInquiry: onStartInquiry, onSelectDealer: handleDealerFocus })] })) }), !showInquiryInMapPopup && !mobileMapExpanded && (_jsxs("button", { type: "button", onClick: () => setMobileMapExpanded((open) => !open), className: "jwi-absolute jwi-inset-x-0 jwi-bottom-0 jwi-z-20 jwi-flex jwi-h-14 jwi-items-center jwi-justify-center jwi-gap-2 jwi-rounded-t-[16px] jwi-border-t jwi-border-[#e6e1d7] jwi-bg-white jwi-text-sm jwi-font-semibold jwi-text-[#111111] jwi-shadow-[0_-6px_20px_rgba(0,0,0,0.12)]", children: [t.openMap, _jsx("span", { className: "jwi-inline-flex", style: { transform: 'rotate(-90deg)' }, children: _jsx(ArrowRightIcon, { className: "jwi-h-4 jwi-w-4 jwi-shrink-0" }) })] })), mobileMapExpanded && !showInquiryInMapPopup && (_jsxs("div", { className: "jwi-absolute jwi-inset-x-0 jwi-bottom-0 jwi-z-30 jwi-h-[78vh] jwi-overflow-hidden jwi-rounded-t-[16px] jwi-bg-white jwi-shadow-[0_-12px_36px_rgba(0,0,0,0.22)]", children: [_jsxs("button", { type: "button", onClick: () => setMobileMapExpanded(false), className: "jwi-flex jwi-h-12 jwi-w-full jwi-items-center jwi-justify-center jwi-gap-2 jwi-border-b jwi-border-[#e6e1d7] jwi-bg-white jwi-text-sm jwi-font-semibold jwi-text-[#111111]", children: [t.closeMapMobile, _jsx("span", { className: "jwi-inline-flex", style: { transform: 'rotate(90deg)' }, children: _jsx(ArrowRightIcon, { className: "jwi-h-4 jwi-w-4 jwi-shrink-0" }) })] }), _jsx("div", { className: "jwi-h-[calc(78vh-48px)] jwi-w-full", children: mapCanvas })] }))] }) }))] }))] }));
|
|
16
181
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import type { WidgetStrings } from '../../i18n/widgetStrings';
|
|
2
3
|
import type { DealerRecord, JotulWidgetButtonStyling } from '../../types';
|
|
3
4
|
type DealerListProps = {
|
|
4
5
|
dealers: DealerRecord[];
|
|
5
6
|
total: number;
|
|
6
7
|
selectedDealerName: string | null;
|
|
8
|
+
activeDealerName?: string | null;
|
|
9
|
+
maxHeightClassName?: string;
|
|
10
|
+
fitAvailableHeight?: boolean;
|
|
11
|
+
autoScrollToActive?: boolean;
|
|
12
|
+
enableInternalScroll?: boolean;
|
|
13
|
+
headerRight?: ReactNode;
|
|
7
14
|
t: WidgetStrings;
|
|
8
15
|
buttonStyling?: JotulWidgetButtonStyling;
|
|
9
16
|
onStartInquiry: (dealerName: string) => void;
|
|
17
|
+
onSelectDealer?: (dealerName: string) => void;
|
|
10
18
|
};
|
|
11
|
-
export declare function DealerList({ dealers, total, selectedDealerName, t, buttonStyling, onStartInquiry, }: DealerListProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function DealerList({ dealers, total, selectedDealerName, activeDealerName, maxHeightClassName, fitAvailableHeight, autoScrollToActive, enableInternalScroll, headerRight, t, buttonStyling, onStartInquiry, onSelectDealer, }: DealerListProps): import("react/jsx-runtime").JSX.Element;
|
|
12
20
|
export {};
|
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { R10 } from '../../constants';
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
3
4
|
import { ArrowRightIcon } from '../../icons/ArrowRightIcon';
|
|
4
5
|
import { TelephoneIcon } from '../../icons/TelephoneIcon';
|
|
5
6
|
import { getWidgetPrimaryButtonPresentation } from '../../utils/widgetPrimaryButtonPresentation';
|
|
7
|
+
import exclusiveDealerBadge from '../../images/jotul-exclusive-dealer.png';
|
|
6
8
|
import { asText, formatDistance, getDealerAddressLines, getDealerKey, getDealerName, } from '../../utils';
|
|
7
|
-
export function DealerList({ dealers, total, selectedDealerName, t, buttonStyling, onStartInquiry, }) {
|
|
9
|
+
export function DealerList({ dealers, total, selectedDealerName, activeDealerName = null, maxHeightClassName = 'jwi-max-h-[min(60vh,480px)]', fitAvailableHeight = false, autoScrollToActive = false, enableInternalScroll = true, headerRight, t, buttonStyling, onStartInquiry, onSelectDealer, }) {
|
|
10
|
+
const cardRefs = useRef({});
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!autoScrollToActive || !activeDealerName)
|
|
13
|
+
return;
|
|
14
|
+
const card = cardRefs.current[activeDealerName];
|
|
15
|
+
if (card == null)
|
|
16
|
+
return;
|
|
17
|
+
card.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18
|
+
}, [activeDealerName, autoScrollToActive]);
|
|
8
19
|
const inquiryCta = getWidgetPrimaryButtonPresentation(buttonStyling, 'panel', {
|
|
9
20
|
extraClassName: 'jwi-w-full jwi-max-w-full jwi-shrink-0 jwi-justify-between jwi-gap-2 md:jwi-max-w-[220px]',
|
|
10
21
|
});
|
|
11
|
-
return (_jsxs("div", { className:
|
|
22
|
+
return (_jsxs("div", { className: `jwi-mt-2 jwi-flex jwi-flex-col ${fitAvailableHeight ? 'jwi-flex-1 jwi-min-h-0' : ''}`, children: [_jsx("div", { className: "jwi--mx-6 jwi-w-auto jwi-flex-shrink-0 jwi-border-b jwi-border-[#e6e1d7] jwi-pb-3 jwi-px-6", children: _jsxs("div", { className: "jwi-flex jwi-items-center jwi-justify-between jwi-gap-3", children: [_jsx("div", { className: "jwi-whitespace-nowrap jwi-text-sm jwi-font-medium jwi-text-[#111111]", children: t.dealersNearYou.replace('{count}', String(total)) }), headerRight] }) }), _jsxs("div", { className: `jwi-relative jwi-mt-4 ${fitAvailableHeight ? 'jwi-flex-1 jwi-min-h-0' : ''}`, children: [_jsx("div", { className: `jwi-flex ${maxHeightClassName} ${fitAvailableHeight ? 'jwi-h-full' : ''} jwi-flex-col jwi-gap-4 ${enableInternalScroll
|
|
23
|
+
? 'jwi-mr-[-12px] jwi-overflow-y-auto jwi-overscroll-y-contain jwi-pr-[12px]'
|
|
24
|
+
: ''}`, children: dealers.map((dealer, index) => {
|
|
12
25
|
const addressLines = getDealerAddressLines(dealer);
|
|
13
26
|
const phone = asText(dealer.phone);
|
|
14
27
|
const distance = formatDistance(dealer);
|
|
15
28
|
const dealerName = getDealerName(dealer, t.unknownDealer);
|
|
16
29
|
const isSelectedDealer = selectedDealerName === dealerName;
|
|
17
|
-
|
|
30
|
+
const isActiveDealer = activeDealerName === dealerName;
|
|
31
|
+
const isExclusive = dealer.exclusive === true ||
|
|
32
|
+
dealer.exclusive === 1 ||
|
|
33
|
+
dealer.exclusive === '1';
|
|
34
|
+
return (_jsxs("div", { ref: (element) => {
|
|
35
|
+
cardRefs.current[dealerName] = element;
|
|
36
|
+
}, className: `jwi-w-full jwi-cursor-pointer ${R10} jwi-border jwi-bg-white jwi-p-4 jwi-shadow-[0_1px_2px_rgba(17,17,17,0.03)] ${isActiveDealer ? 'jwi-border-[#ef2b18]' : 'jwi-border-[#e6e1d7]'}`, onClick: () => onSelectDealer?.(dealerName), children: [_jsxs("div", { className: "jwi-flex jwi-items-start jwi-justify-between jwi-gap-3", children: [_jsx("div", { className: "jwi-min-w-0 jwi-max-w-[calc(100%-5rem)] jwi-pr-1", children: _jsxs("div", { className: "jwi-flex jwi-items-center jwi-gap-2", children: [isExclusive && (_jsx("img", { src: typeof exclusiveDealerBadge === 'string'
|
|
37
|
+
? exclusiveDealerBadge
|
|
38
|
+
: exclusiveDealerBadge.src, alt: "Jotul exclusive dealer", className: "jwi-h-auto jwi-w-[40px] jwi-shrink-0 jwi-rounded-full jwi-m-0" })), _jsx("h3", { className: "jwi-m-0 jwi-text-sm md:jwi-text-base jwi-font-semibold jwi-leading-snug jwi-text-[#111111]", children: dealerName })] }) }), distance && (_jsx("div", { className: `jwi-shrink-0 jwi-whitespace-nowrap ${R10} jwi-bg-[#fbf3db] jwi-px-2.5 jwi-py-1 jwi-text-xs jwi-font-medium jwi-leading-none jwi-text-[#111111]`, children: distance }))] }), addressLines.length > 0 && (_jsx("div", { className: "jwi-mt-3 jwi-flex jwi-flex-col jwi-gap-0.5 jwi-text-sm jwi-leading-snug jwi-text-[#111111]", children: addressLines.map((line) => (_jsx("div", { children: line }, line))) })), _jsxs("div", { className: "jwi-mt-4 jwi-flex jwi-flex-col jwi-gap-3 md:jwi-flex-row md:jwi-items-center md:jwi-justify-between", children: [_jsxs("button", { type: "button", onClick: (event) => {
|
|
39
|
+
event.stopPropagation();
|
|
40
|
+
onStartInquiry(dealerName);
|
|
41
|
+
}, className: inquiryCta.className, style: inquiryCta.style, children: [_jsx("span", { children: isSelectedDealer ? t.sendInquiryEditing : t.sendInquiryCta }), _jsx(ArrowRightIcon, { className: "jwi-h-[18px] jwi-w-[18px] jwi-shrink-0" })] }), phone && (_jsxs("a", { href: `tel:${phone.replace(/\s+/g, '')}`, onClick: (event) => event.stopPropagation(), className: "jwi-inline-flex jwi-min-w-0 jwi-items-center jwi-gap-2 jwi-text-sm jwi-font-normal jwi-tabular-nums jwi-text-[#111111] hover:jwi-underline", children: [_jsx(TelephoneIcon, {}), _jsx("span", { className: "jwi-break-all", children: phone })] }))] })] }, getDealerKey(dealer, index)));
|
|
18
42
|
}) }), _jsx("div", { "aria-hidden": true, className: "jwi-pointer-events-none jwi-absolute jwi-bottom-0 jwi-left-0 jwi-right-0 jwi-h-10 jwi-bg-gradient-to-t jwi-from-white jwi-to-transparent" })] })] }));
|
|
19
43
|
}
|
|
@@ -5,9 +5,10 @@ type InquiryFormProps = {
|
|
|
5
5
|
buttonStyling?: JotulWidgetButtonStyling;
|
|
6
6
|
inquiryValues: InquiryFormValues;
|
|
7
7
|
inquiryError: string | null;
|
|
8
|
+
embedded?: boolean;
|
|
8
9
|
onInquiryClose: () => void;
|
|
9
10
|
onInquirySubmit: () => void;
|
|
10
11
|
onInquiryFieldChange: (key: keyof InquiryFormValues, value: string) => void;
|
|
11
12
|
};
|
|
12
|
-
export declare function InquiryForm({ t, buttonStyling, inquiryValues, inquiryError, onInquiryClose, onInquirySubmit, onInquiryFieldChange, }: InquiryFormProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function InquiryForm({ t, buttonStyling, inquiryValues, inquiryError, embedded, onInquiryClose, onInquirySubmit, onInquiryFieldChange, }: InquiryFormProps): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -3,7 +3,7 @@ import { InquiryField } from '../InquiryField';
|
|
|
3
3
|
import { R10 } from '../../constants';
|
|
4
4
|
import { ArrowRightIcon } from '../../icons/ArrowRightIcon';
|
|
5
5
|
import { getWidgetPrimaryButtonPresentation } from '../../utils/widgetPrimaryButtonPresentation';
|
|
6
|
-
export function InquiryForm({ t, buttonStyling, inquiryValues, inquiryError, onInquiryClose, onInquirySubmit, onInquiryFieldChange, }) {
|
|
6
|
+
export function InquiryForm({ t, buttonStyling, inquiryValues, inquiryError, embedded = false, onInquiryClose, onInquirySubmit, onInquiryFieldChange, }) {
|
|
7
7
|
const submitButton = getWidgetPrimaryButtonPresentation(buttonStyling, 'panel', {
|
|
8
8
|
extraClassName: 'jwi-mt-4 jwi-w-full',
|
|
9
9
|
});
|
|
@@ -14,5 +14,7 @@ export function InquiryForm({ t, buttonStyling, inquiryValues, inquiryError, onI
|
|
|
14
14
|
return (_jsxs("form", { onSubmit: (event) => {
|
|
15
15
|
event.preventDefault();
|
|
16
16
|
onInquirySubmit();
|
|
17
|
-
}, className: `jwi-w-full ${R10} jwi-
|
|
17
|
+
}, className: `jwi-w-full ${R10} jwi-bg-white jwi-p-4 ${embedded
|
|
18
|
+
? ''
|
|
19
|
+
: 'jwi-border jwi-border-[#e6e1d7] jwi-shadow-[0_1px_2px_rgba(17,17,17,0.03)]'}`, children: [_jsxs("button", { type: "button", onClick: onInquiryClose, className: "jwi-mb-3 jwi-inline-flex jwi-w-fit jwi-cursor-pointer jwi-items-center jwi-gap-1.5 jwi-border-0 jwi-bg-transparent jwi-p-0 jwi-text-left jwi-text-sm jwi-font-medium jwi-text-[#767676] hover:jwi-text-[#444444]", children: [_jsx("span", { className: "jwi-inline-flex jwi-shrink-0", style: { transform: 'scaleX(-1)' }, "aria-hidden": true, children: _jsx(ArrowRightIcon, { className: "jwi-h-[14px] jwi-w-[14px]" }) }), t.goBack] }), _jsx("input", { type: "hidden", name: "product", value: inquiryValues.productName }), _jsx("input", { type: "hidden", name: "dealer", value: inquiryValues.dealerName }), _jsxs("div", { className: "jwi-min-w-0", children: [_jsx("h3", { className: "jwi-m-0 jwi-text-base jwi-font-semibold jwi-leading-snug jwi-text-[#111111]", children: title }), _jsx("p", { className: "jwi-m-0 jwi-mt-2 jwi-text-sm jwi-leading-[1.4] jwi-text-[#767676]", children: t.dealerWillContact.replace('{dealer}', inquiryValues.dealerName) })] }), _jsxs("div", { className: "jwi-mt-4 jwi-flex jwi-flex-col jwi-gap-3", children: [_jsx(InquiryField, { label: t.fieldName, value: inquiryValues.name, onChange: (value) => onInquiryFieldChange('name', value) }), _jsx(InquiryField, { label: t.fieldEmail, type: "email", value: inquiryValues.email, onChange: (value) => onInquiryFieldChange('email', value) }), _jsx(InquiryField, { label: t.fieldPhone, type: "tel", value: inquiryValues.phone, onChange: (value) => onInquiryFieldChange('phone', value) }), _jsx(InquiryField, { label: t.fieldComment, multiline: true, value: inquiryValues.comment, onChange: (value) => onInquiryFieldChange('comment', value) })] }), inquiryError && (_jsx("div", { className: `jwi-mt-4 ${R10} jwi-border jwi-border-[#f0c7c2] jwi-bg-[#fff3f1] jwi-px-4 jwi-py-3 jwi-text-sm jwi-leading-[1.4] jwi-text-[#8f2d21]`, children: inquiryError })), _jsx("button", { type: "submit", className: submitButton.className, style: submitButton.style, children: t.sendInquiryCta })] }));
|
|
18
20
|
}
|
|
@@ -8,8 +8,9 @@ type LocationSearchProps = {
|
|
|
8
8
|
suggestionsOpen: boolean;
|
|
9
9
|
isSuggestionsLoading: boolean;
|
|
10
10
|
onQueryChange: (value: string) => void;
|
|
11
|
+
onQuerySubmit: (value: string) => void;
|
|
11
12
|
onSuggestionSelect: (suggestion: LocationSuggestion) => void;
|
|
12
13
|
onDismissSuggestions: () => void;
|
|
13
14
|
};
|
|
14
|
-
export declare function LocationSearch({ t, isManualSearchEnabled, query, suggestions, suggestionsOpen, isSuggestionsLoading, onQueryChange, onSuggestionSelect, onDismissSuggestions, }: LocationSearchProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function LocationSearch({ t, isManualSearchEnabled, query, suggestions, suggestionsOpen, isSuggestionsLoading, onQueryChange, onQuerySubmit, onSuggestionSelect, onDismissSuggestions, }: LocationSearchProps): import("react/jsx-runtime").JSX.Element;
|
|
15
16
|
export {};
|
|
@@ -2,16 +2,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { R10 } from '../../constants';
|
|
4
4
|
import { PinIcon } from '../../icons/PinIcon';
|
|
5
|
-
export function LocationSearch({ t, isManualSearchEnabled, query, suggestions, suggestionsOpen, isSuggestionsLoading, onQueryChange, onSuggestionSelect, onDismissSuggestions, }) {
|
|
5
|
+
export function LocationSearch({ t, isManualSearchEnabled, query, suggestions, suggestionsOpen, isSuggestionsLoading, onQueryChange, onQuerySubmit, onSuggestionSelect, onDismissSuggestions, }) {
|
|
6
6
|
const hasQuery = query.trim().length > 0;
|
|
7
7
|
const showSuggestions = isManualSearchEnabled && hasQuery && suggestionsOpen;
|
|
8
8
|
const queryLength = query.trim().length;
|
|
9
9
|
const rootRef = useRef(null);
|
|
10
10
|
const inputRef = useRef(null);
|
|
11
11
|
useEffect(() => {
|
|
12
|
+
if (!showSuggestions)
|
|
13
|
+
return;
|
|
12
14
|
function handleOutsideClick(event) {
|
|
13
15
|
if (!showSuggestions)
|
|
14
16
|
return;
|
|
17
|
+
if (!rootRef.current || rootRef.current.offsetParent === null)
|
|
18
|
+
return;
|
|
15
19
|
if (!rootRef.current?.contains(event.target)) {
|
|
16
20
|
onDismissSuggestions();
|
|
17
21
|
}
|
|
@@ -21,11 +25,22 @@ export function LocationSearch({ t, isManualSearchEnabled, query, suggestions, s
|
|
|
21
25
|
document.removeEventListener('mousedown', handleOutsideClick);
|
|
22
26
|
};
|
|
23
27
|
}, [onDismissSuggestions, showSuggestions]);
|
|
24
|
-
return (_jsxs("div", { ref: rootRef, className: "jwi-relative jwi-w-full jwi-flex-shrink-0", children: [_jsx("div", { className: `jwi-w-full jwi-overflow-hidden
|
|
28
|
+
return (_jsxs("div", { ref: rootRef, className: "jwi-relative jwi-w-full jwi-flex-shrink-0", children: [_jsx("div", { className: `jwi-w-full jwi-overflow-hidden jwi-border jwi-border-[#d8d2c7] jwi-bg-white ${showSuggestions ? 'jwi-rounded-t-[10px]' : R10}`, children: _jsx("div", { className: "jwi-flex jwi-w-full jwi-min-w-0 jwi-flex-row jwi-items-stretch", children: _jsxs("div", { className: "jwi-flex jwi-min-w-0 jwi-flex-1 jwi-items-center jwi-gap-3 jwi-bg-[#FCFCFC] jwi-px-5", children: [_jsx("span", { className: "jwi-inline-flex jwi-shrink-0 jwi-text-black", children: _jsx(PinIcon, {}) }), _jsx("input", { ref: inputRef, type: "text", value: query, readOnly: !isManualSearchEnabled, placeholder: isManualSearchEnabled ? t.locationManualHint : t.useLocationHint, "aria-label": t.useLocationHint, onChange: (event) => onQueryChange(event.target.value), onKeyDown: (event) => {
|
|
25
29
|
if (event.key === 'Escape') {
|
|
26
30
|
onDismissSuggestions();
|
|
27
31
|
inputRef.current?.blur();
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
if (event.key === 'Enter' &&
|
|
34
|
+
isManualSearchEnabled &&
|
|
35
|
+
suggestions.length > 0) {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
onSuggestionSelect(suggestions[0]);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (event.key === 'Enter' && isManualSearchEnabled) {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
onQuerySubmit(query);
|
|
43
|
+
}
|
|
44
|
+
}, className: "jwi-min-w-0 jwi-h-[60px] jwi-w-full jwi-flex-1 jwi-border-0 jwi-bg-transparent jwi-text-[13px] md:jwi-text-[14px] jwi-leading-[1.4] jwi-text-[#111111] jwi-outline-none placeholder:jwi-text-[13px] md:placeholder:jwi-text-[14px] placeholder:jwi-text-[#767676]" })] }) }) }), showSuggestions && (_jsxs("div", { className: "-jwi-mt-px jwi-absolute jwi-z-20 jwi-w-full jwi-overflow-hidden jwi-rounded-b-[10px] jwi-border jwi-border-t-0 jwi-border-[#d8d2c7] jwi-bg-white jwi-shadow-[0_8px_24px_rgba(17,17,17,0.08)]", children: [isSuggestionsLoading && (_jsx("div", { className: "jwi-px-4 jwi-py-3 jwi-text-sm jwi-text-[#767676]", children: t.finding })), !isSuggestionsLoading && queryLength < 3 && (_jsx("div", { className: "jwi-px-4 jwi-py-3 jwi-text-sm jwi-text-[#767676]", children: t.locationTypeMore })), !isSuggestionsLoading && queryLength >= 3 && suggestions.length === 0 && (_jsx("div", { className: "jwi-px-4 jwi-py-3 jwi-text-sm jwi-text-[#767676]", children: t.locationNoResults })), !isSuggestionsLoading &&
|
|
30
45
|
suggestions.map((suggestion, index) => (_jsx("button", { type: "button", onClick: () => onSuggestionSelect(suggestion), className: "jwi-flex jwi-w-full jwi-cursor-pointer jwi-items-start jwi-border-0 jwi-bg-white jwi-px-4 jwi-py-3 jwi-text-left jwi-text-sm jwi-leading-[1.35] jwi-text-[#111111] hover:jwi-bg-[#f7f5f0]", children: suggestion.label }, `${suggestion.latitude}-${suggestion.longitude}-${index}`)))] }))] }));
|
|
31
46
|
}
|