@digitransit-component/digitransit-component-favourite-modal 4.0.7 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,2 +1,739 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("classnames"),require("react-i18next"),require("lodash/isEmpty"),require("lodash/isNumber"),require("@hsl-fi/modal"),require("@digitransit-component/digitransit-component-icon"),require("i18next")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","classnames","react-i18next","lodash/isEmpty","lodash/isNumber","@hsl-fi/modal","@digitransit-component/digitransit-component-icon","i18next"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@digitransit-component/digitransit-component-favourite-modal"]={},e.React,e.PropTypes,e.cx,e.reactI18next,e.isEmpty,e.isNumber,e.Modal,e.Icon,e.i18next)}(this,function(e,t,o,a,n,i,l,r,s,d){"use strict";function u(e){return e&&e.__esModule?e:{default:e}}var c=u(t),f=u(o),m=u(a),p=u(i),_=u(l),v=u(r),b=u(s);function h(e){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(e)}function g(e){var t=function(e,t){if("object"!=h(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var a=o.call(e,t);if("object"!=h(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==h(t)?t:t+""}function k(e,t,o){return(t=g(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function y(e,t){void 0===t&&(t={});var o=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===o&&a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}var x={"generic-table":"styles_generic-table__V-wrC",row:"styles_row__AJFl2","generic-table__label-container":"styles_generic-table__label-container__PJa1r","favourite-icon-table-column":"styles_favourite-icon-table-column__7eEyw",place:"styles_place__ymmqu",work:"styles_work__fs304",home:"styles_home__pPJsU",school:"styles_school__Gq5Lo",sport:"styles_sport__fBWhN",shopping:"styles_shopping__EFuXp","selected-icon":"styles_selected-icon__4Cccg"};y(".styles_generic-table__V-wrC > .styles_row__AJFl2 {\n display: flex;\n}\n\n.styles_generic-table__label-container__PJa1r {\n font-size: 0.8rem;\n margin-top: 3px;\n color: #666;\n height: 16px;\n max-width: 62.5rem;\n margin-left: auto;\n margin-right: auto;\n}\n\n.styles_favourite-icon-table-column__7eEyw {\n cursor: pointer;\n flex: 1;\n align-items: center;\n padding: 0;\n background: #fff;\n float: left;\n height: 50px;\n margin: 0;\n line-height: 1;\n text-align: center;\n font-size: 17px;\n border-top: solid 1px #ddd;\n border-bottom: solid 1px #ddd;\n border-right: solid 1px #ddd;\n border-left: none;\n}\n.styles_favourite-icon-table-column__7eEyw.styles_place__ymmqu svg {\n width: 24px;\n height: 24px;\n}\n.styles_favourite-icon-table-column__7eEyw.styles_work__fs304 svg {\n width: 20px;\n height: 20px;\n}\n.styles_favourite-icon-table-column__7eEyw.styles_home__pPJsU svg, .styles_favourite-icon-table-column__7eEyw.styles_school__Gq5Lo svg, .styles_favourite-icon-table-column__7eEyw.styles_sport__fBWhN svg, .styles_favourite-icon-table-column__7eEyw.styles_shopping__EFuXp svg {\n width: 18px;\n height: 18px;\n}\n.styles_favourite-icon-table-column__7eEyw:active, .styles_favourite-icon-table-column__7eEyw:hover, .styles_favourite-icon-table-column__7eEyw:focus,\n.styles_favourite-icon-table-column__7eEyw .styles_selected-icon__4Cccg {\n background: #333;\n color: #fff;\n}\n\n.styles_favourite-icon-table-column__7eEyw:first-child {\n border-left: solid 1px #ddd;\n border-top-left-radius: 5px;\n border-bottom-left-radius: 5px;\n}\n\n.styles_favourite-icon-table-column__7eEyw:last-child {\n border-top-right-radius: 5px;\n border-bottom-right-radius: 5px;\n}\n\n.styles_favourite-icon-table-column__7eEyw.styles_selected-icon__4Cccg {\n background: #333;\n color: #fff;\n}");const w=d.createInstance({fallbackLng:"fi",resources:{de:{translation:{cancel:"Abbrechen","choose-icon":"Wählen Sie ein Symbol für diesen Ort","close-favourite-modal":"Favoriten-Dialog schließen","edit-place":"Ort bearbeiten","favourite-modal-on-add-new":"Neuen Favoriten hinzufügen","favourite-modal-on-edit":"Favorit bearbeiten: {{favourite.name}}","input-placeholder":"Einen Namen für Ort setzen (optional)",save:"Speichern","save-place":"Favorit speichern"}},en:{translation:{cancel:"Cancel","choose-icon":"Select the place's icon","close-favourite-modal":"Close the favourite modal","edit-place":"Edit place","favourite-modal-on-add-new":"Add a new favorite","favourite-modal-on-edit":"Editing favourite: {{favourite.name}}","input-placeholder":"Give the name a place (optional)",save:"Save","save-place":"Save place","cannot-save-place":"Cannot save a place without address or icon",place:"a place",home:"home",work:"work",sport:"sport",school:"school",shopping:"shopping","required-text":"required field"}},fi:{translation:{cancel:"Peruuta","choose-icon":"Valitse paikan kuvake","close-favourite-modal":"Sulje suosikkimodaali","edit-place":"Muokkaa paikkaa","favourite-modal-on-add-new":"Lisää uusi suosikki","favourite-modal-on-edit":"Muokkaa suosikkia {{favourite.name}}","input-placeholder":"Anna paikalle nimi (vapaaehtoinen)",save:"Tallenna","save-place":"Tallenna paikka","cannot-save-place":"Paikkaa ilman osoitetta tai ikonia ei voida tallentaa",place:"paikka",home:"koti",work:"työ",sport:"urheilu",school:"koulu",shopping:"ostokset","required-text":"pakollinen kenttä"}},pl:{translation:{cancel:"Anuluj","choose-icon":"Wybierz ikonę miejsca","close-favourite-modal":"Zamknij modal ulubionych","edit-place":"Edytuj miejsce","favourite-modal-on-add-new":"Dodaj ulubione miejsce","favourite-modal-on-edit":"Edycja ulubionego miejsca: {{favourite.name}}","input-placeholder":"Nadaj nazwę miejscu (opcjonalne)",save:"Zapisz","save-place":"Zapisz miejsce","cannot-save-place":"Nie można zapisać miejsca bez nazwy lub ikony",place:"miejsce",home:"dom",work:"praca",sport:"sport",school:"szkoła",shopping:"zakupy","required-text":"pole wymagane"}},sv:{translation:{cancel:"Avbryt","choose-icon":"Välj platsens ikon","close-favourite-modal":"Stäng favoritmodalen","edit-place":"Redigera plats","favourite-modal-on-add-new":"Lägg till ny favorit","favourite-modal-on-edit":"Redigera platsen: {{favourite.name}}","input-placeholder":"Ange platsens namn (frivilligt)",save:"Spara","save-place":"Spara plats","cannot-save-place":"Det går inte att spara en plats utan adress eller ikon",place:"en plats",home:"hem",work:"arbete",sport:"sport",school:"skola",shopping:"shoppa","required-field":"obligatoriskt fält"}}},defaultNS:"translation",react:{useSuspense:!0}});w.init();var E="desktop_favourite-modal-desktop-container__fwjzA",T="desktop_favourite-modal-desktop-top__qS5Mr",I="desktop_favourite-modal-desktop-header__EJRs9",q="desktop_favourite-modal-desktop-main__TB6B1",N="desktop_favourite-modal-desktop-location-search__BYeZe",j="desktop_favourite-modal-desktop-name__oiopT",S="desktop_favourite-modal-desktop-input__6NIl9",z="desktop_favourite-modal-desktop-text__0QTFh",C="desktop_favourite-modal-desktop-icons__wUczP",R="desktop_icons-container__oHCDb",O="desktop_favourite-modal-desktop-buttons__2e2KI",P="desktop_favourite-modal-desktop-button__MzlrD",A="desktop_save__I-9Vc",D="desktop_disabled__VS4DK",F="desktop_edit__hPeF7",M="desktop_sr-only__kvcEB";y(".desktop_favourite-modal-desktop-container__fwjzA {\n display: flex;\n flex-direction: column;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-top__qS5Mr {\n display: flex;\n flex-direction: row;\n width: 100%;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-top__qS5Mr .desktop_favourite-modal-desktop-header__EJRs9 {\n width: 100%;\n font-size: 18px;\n font-weight: var(--font-weight-medium);\n line-height: 1.33;\n letter-spacing: -0.6px;\n color: #333;\n margin-bottom: 25px;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-main__TB6B1 {\n text-align: left;\n margin-bottom: 27px;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-main__TB6B1 .desktop_favourite-modal-desktop-location-search__BYeZe {\n margin-bottom: 9px;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-main__TB6B1 .desktop_favourite-modal-desktop-name__oiopT .desktop_favourite-modal-desktop-input__6NIl9 {\n display: flex;\n position: relative;\n width: 100%;\n height: 44px;\n font-family: inherit;\n border-radius: 5px;\n border: solid 1px #888;\n background-color: #fff;\n padding-left: 20px;\n font-size: 15px;\n line-height: 1.2;\n letter-spacing: -0.5px;\n color: #333;\n box-sizing: border-box;\n appearance: none;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-main__TB6B1 .desktop_favourite-modal-desktop-name__oiopT .desktop_favourite-modal-desktop-input__6NIl9::placeholder {\n color: #666;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-main__TB6B1 .desktop_favourite-modal-desktop-name__oiopT .desktop_favourite-modal-desktop-input__6NIl9:focus {\n background: #fff;\n outline: none;\n border: 1px solid var(--color);\n box-shadow: 0 0 2px 1px var(--hover-color);\n appearance: none;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-text__0QTFh {\n font-size: 16px;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.53px;\n color: #333;\n margin: 0 0 11px 0;\n padding: 0;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-icons__wUczP {\n margin-bottom: 30px;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_icons-container__oHCDb {\n border: none;\n margin: 0;\n padding: 0;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI {\n display: flex;\n flex-direction: column;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD {\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n width: 100%;\n height: 50px;\n font-size: 18px;\n font-family: inherit;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.5px;\n background: var(--color);\n color: #fff;\n line-height: 0;\n text-align: center;\n padding: 0;\n margin: 0;\n border-width: 0;\n transition: background-color 300ms ease-out;\n border-radius: 25px;\n cursor: pointer;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD.desktop_save__I-9Vc:active, .desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD.desktop_save__I-9Vc:focus, .desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD.desktop_save__I-9Vc:hover {\n border-color: var(--hover-color);\n background: var(--hover-color);\n color: #fff;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD.desktop_save__I-9Vc.desktop_disabled__VS4DK {\n background: #bbb;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD.desktop_save__I-9Vc.desktop_disabled__VS4DK:active {\n background: #bbb;\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD.desktop_edit__hPeF7 {\n margin-top: 9px;\n background: #fff;\n border: solid 1px var(--color);\n color: var(--color);\n}\n.desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD.desktop_edit__hPeF7:active, .desktop_favourite-modal-desktop-container__fwjzA .desktop_favourite-modal-desktop-buttons__2e2KI .desktop_favourite-modal-desktop-button__MzlrD.desktop_edit__hPeF7:hover {\n border-color: var(--hover-color);\n background-color: #fff;\n color: var(--hover-color);\n}\n\n.desktop_sr-only__kvcEB:not(:focus, :active) {\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n}");const B=({headerText:e,autosuggestComponent:t,inputPlaceholder:o,specifyName:a,name:n,chooseIconText:i,favouriteIconTable:l,saveFavourite:r,saveText:s,canSave:d,isEdit:u,cancelText:f,cancelSelected:m,color:p,hoverColor:_,savePlaceText:v,cantSaveText:b,requiredText:h,fontWeights:g})=>c.default.createElement("div",{className:E,style:{"--color":`${p}`,"--hover-color":`${_}`,"--font-weight-medium":g.medium}},c.default.createElement("div",{className:T},c.default.createElement("div",{className:I},e)),c.default.createElement("div",{className:q},c.default.createElement("div",{className:N},t),c.default.createElement("div",{className:j},c.default.createElement("input",{"aria-label":o,className:S,value:n,placeholder:o,onChange:a}))),c.default.createElement("fieldset",{className:R},c.default.createElement("legend",{className:z},i,c.default.createElement("p",{className:M},h)),c.default.createElement("div",{className:C},l)),c.default.createElement("div",{className:O},c.default.createElement("button",{type:"button",className:`${P} ${A} ${d()?"":D}`,onClick:r,"aria-label":`${d()?v:b}`,"aria-disabled":!d()},s),u&&c.default.createElement("button",{type:"button",className:`${P} ${F} ${d()?"":D}`,onClick:m},f)));"production"!==process.env.NODE_ENV&&(B.propTypes={headerText:f.default.string.isRequired,autosuggestComponent:f.default.node.isRequired,inputPlaceholder:f.default.string.isRequired,specifyName:f.default.func.isRequired,name:f.default.string.isRequired,chooseIconText:f.default.string.isRequired,favouriteIconTable:f.default.node.isRequired,saveFavourite:f.default.func.isRequired,saveText:f.default.string.isRequired,canSave:f.default.func.isRequired,isEdit:f.default.bool,cancelText:f.default.string.isRequired,cancelSelected:f.default.func,color:f.default.string.isRequired,hoverColor:f.default.string.isRequired,savePlaceText:f.default.string.isRequired,cantSaveText:f.default.string.isRequired,requiredText:f.default.string.isRequired,fontWeights:f.default.shape({medium:f.default.number.isRequired}).isRequired}),B.defaultProps={isEdit:!1,cancelSelected:()=>({})};var J={"favourite-modal-mobile-container":"mobile_favourite-modal-mobile-container__dlntT","favourite-modal-mobile-top":"mobile_favourite-modal-mobile-top__9XrDU","favourite-modal-mobile-header":"mobile_favourite-modal-mobile-header__P3Dkl","favourite-modal-mobile-main":"mobile_favourite-modal-mobile-main__bFoYj","favourite-modal-mobile-location-search":"mobile_favourite-modal-mobile-location-search__mN0W2","favourite-modal-mobile-input":"mobile_favourite-modal-mobile-input__ExBwE","favourite-modal-mobile-text":"mobile_favourite-modal-mobile-text__S3Yia","favourite-modal-mobile-save":"mobile_favourite-modal-mobile-save__eJp-O","favourite-modal-mobile-button":"mobile_favourite-modal-mobile-button__mCTTC",disabled:"mobile_disabled__sHcru","sr-only":"mobile_sr-only__JN5YG"};y(".mobile_favourite-modal-mobile-container__dlntT {\n display: flex;\n flex-direction: column;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-top__9XrDU {\n display: flex;\n flex-direction: row;\n width: 100%;\n border-bottom: 1px solid #ddd;\n margin-bottom: 30px;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-top__9XrDU .mobile_favourite-modal-mobile-header__P3Dkl {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 100%;\n height: inherit;\n font-size: 18px;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.6px;\n text-align: center;\n color: #333;\n margin-bottom: 37px;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-main__bFoYj {\n text-align: left;\n margin-bottom: 28px;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-main__bFoYj .mobile_favourite-modal-mobile-location-search__mN0W2 {\n margin-bottom: 9px;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-main__bFoYj .mobile_favourite-modal-mobile-input__ExBwE {\n display: flex;\n position: relative;\n width: 100%;\n height: 44px;\n font-family: inherit;\n border-radius: 5px;\n border: solid 1px #888;\n background-color: #fff;\n padding-left: 20px;\n font-size: 16px;\n line-height: 1.2;\n letter-spacing: -0.5px;\n color: #333;\n box-sizing: border-box;\n appearance: none;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-main__bFoYj .mobile_favourite-modal-mobile-input__ExBwE:focus {\n background: #fff;\n outline: none;\n border: 1px solid var(--color);\n box-shadow: 0 0 2px 1px var(--hover-color);\n appearance: none;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-main__bFoYj .mobile_favourite-modal-mobile-input__ExBwE::placeholder {\n color: #666;\n font-size: 15px;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-text__S3Yia {\n font-size: 16px;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.53px;\n color: #333;\n margin-bottom: 18px;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-save__eJp-O {\n width: 100%;\n margin-top: 30px;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-save__eJp-O .mobile_favourite-modal-mobile-button__mCTTC {\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n width: 100%;\n height: 50px;\n font-size: 18px;\n font-family: inherit;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.5px;\n background: var(--color);\n line-height: 0;\n text-align: center;\n padding: 0;\n margin: 0;\n color: #fff;\n border-width: 0;\n transition: background-color 300ms ease-out;\n border-radius: 25px;\n cursor: pointer;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-save__eJp-O .mobile_favourite-modal-mobile-button__mCTTC:active, .mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-save__eJp-O .mobile_favourite-modal-mobile-button__mCTTC:focus, .mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-save__eJp-O .mobile_favourite-modal-mobile-button__mCTTC:hover {\n border-color: var(--hover-color);\n background: var(--hover-color);\n color: #fff;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-save__eJp-O .mobile_favourite-modal-mobile-button__mCTTC.mobile_disabled__sHcru {\n background: #bbb;\n}\n.mobile_favourite-modal-mobile-container__dlntT .mobile_favourite-modal-mobile-save__eJp-O .mobile_favourite-modal-mobile-button__mCTTC.mobile_disabled__sHcru:active {\n background: #bbb;\n}\n\n.mobile_sr-only__JN5YG:not(:focus, :active) {\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n}");const V=({headerText:e,autosuggestComponent:t,inputPlaceholder:o,specifyName:a,name:n,chooseIconText:i,favouriteIconTable:l,saveFavourite:r,saveText:s,canSave:d,color:u,hoverColor:f,savePlaceText:m,cantSaveText:p,requiredText:_,fontWeights:v})=>c.default.createElement("div",{className:J["favourite-modal-mobile-container"],style:{"--color":`${u}`,"--hover-color":`${f}`,"--font-weight-medium":v.medium}},c.default.createElement("div",{className:J["favourite-modal-mobile-top"]},c.default.createElement("div",{className:J["favourite-modal-mobile-header"]},e)),c.default.createElement("div",{className:J["favourite-modal-mobile-main"]},c.default.createElement("div",{className:J["favourite-modal-mobile-location-search"]},t),c.default.createElement("input",{className:J["favourite-modal-mobile-input"],value:n||"",placeholder:o,onChange:a})),c.default.createElement("div",{className:J["favourite-modal-mobile-text"]},i,c.default.createElement("p",{className:J["sr-only"]},_)),c.default.createElement("div",{className:J["favourite-modal-mobile-icons"]},l),c.default.createElement("div",{className:J["favourite-modal-mobile-save"]},c.default.createElement("button",{type:"button",className:`${J["favourite-modal-mobile-button"]} ${d()?"":J.disabled}`,onClick:r,"aria-label":`${d()?m:p}`},s)));"production"!==process.env.NODE_ENV&&(V.propTypes={headerText:f.default.string.isRequired,autosuggestComponent:f.default.node.isRequired,inputPlaceholder:f.default.string.isRequired,specifyName:f.default.func.isRequired,name:f.default.string.isRequired,chooseIconText:f.default.string.isRequired,favouriteIconTable:f.default.node.isRequired,saveFavourite:f.default.func.isRequired,saveText:f.default.string.isRequired,canSave:f.default.func.isRequired,color:f.default.string.isRequired,hoverColor:f.default.string.isRequired,savePlaceText:f.default.string.isRequired,cantSaveText:f.default.string.isRequired,requiredText:f.default.string.isRequired,fontWeights:f.default.shape({medium:f.default.number.isRequired}).isRequired});const $=["favouriteIconIds"];function W(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,a)}return o}function K(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?W(Object(o),!0).forEach(function(t){k(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):W(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}const Y={"icon-icon_place":"place","icon-icon_home":"home","icon-icon_work":"work","icon-icon_sport":"sport","icon-icon_school":"school","icon-icon_shopping":"shopping"},L=({value:e,selectedIconId:o,handleClick:a,color:i,lang:l})=>{const[r]=n.useTranslation(),[s,d]=t.useState(!1),[u,f]=t.useState(!1),p=e===Y[o]||s||u?"#ffffff":i;return c.default.createElement("button",{type:"button",className:m.default(x["favourite-icon-table-column"],x[e],e===Y[o]&&x["selected-icon"]),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocus:()=>f(!0),onBlur:()=>f(!1),onClick:()=>a(e),"aria-label":r(e,{lng:l})},c.default.createElement(b.default,{img:e,color:p}))};"production"!==process.env.NODE_ENV&&(L.propTypes={handleClick:f.default.func.isRequired,value:f.default.string.isRequired,selectedIconId:f.default.string,color:f.default.string.isRequired,lang:f.default.string.isRequired}),L.defaultProps={selectedIconId:""};const U=e=>{let{favouriteIconIds:t}=e,o=function(e,t){if(null==e)return{};var o,a,n=function(e,t){if(null==e)return{};var o={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(-1!==t.indexOf(a))continue;o[a]=e[a]}return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)o=i[a],-1===t.indexOf(o)&&{}.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(e,$);const a=t.map(e=>c.default.createElement(L,Object.assign({key:`favourite-icon-table-${e}`,value:e},o)));return c.default.createElement("div",{className:x["generic-table"]},c.default.createElement("div",{className:x.row},a))};"production"!==process.env.NODE_ENV&&(U.propTypes={favouriteIconIds:f.default.arrayOf(f.default.string).isRequired});class G extends c.default.Component{constructor(e){super(e),k(this,"specifyName",e=>{const t=e.target.value;this.setState(e=>({favourite:K(K({},e.favourite),{},{name:t})}))}),k(this,"selectIcon",e=>{this.setState(t=>({favourite:K(K({},t.favourite),{},{selectedIconId:`icon-icon_${e}`})}))}),k(this,"isEdit",()=>this.state.favourite&&void 0!==this.state.favourite.favouriteId),k(this,"canSave",()=>this.state.favourite&&!p.default(this.state.favourite.selectedIconId)&&_.default(this.state.favourite.lat)&&_.default(this.state.favourite.lon)),k(this,"closeModal",()=>{this.props.handleClose(),setTimeout(()=>{this.setState({favourite:null})},250)}),k(this,"cancelSelected",()=>{this.props.cancelSelected(),setTimeout(()=>{this.setState({favourite:null})},250)}),k(this,"save",()=>{if(this.canSave()){const e=p.default(this.state.favourite.name)?this.state.favourite.defaultName:this.state.favourite.name,t=K(K({},this.state.favourite),{},{name:e});delete t.defaultName,this.props.saveFavourite(K(K({},t),{},{type:"place"})),this.props.addAnalyticsEvent&&this.props.addAnalyticsEvent({category:"Favourite",action:"SaveFavourite",name:this.state.favourite.selectedIconId}),this.isEdit()&&this.props.cancelSelected?this.cancelSelected():this.closeModal()}}),this.state={favourite:null}}static getDerivedStateFromProps(e,t){const o=t.favourite,a=e.favourite;return p.default(a)?{favourite:null}:p.default(o)&&!p.default(a)?{favourite:K({},a)}:p.default(o)||p.default(a)||a.address===o.address&&a.lat===o.lat&&a.lon===o.lon?null:{favourite:K(K({},o),{},{address:a.address,lat:a.lat,lon:a.lon,gid:a.gid||null,name:o.name||a.name||"",defaultName:a.defaultName})}}componentWillUnmount(){this.setState({favourite:null})}render(){const{favourite:e}=this.state,{fontWeights:t,lang:o,t:a}=this.props,{primary:n,hover:i}=this.props.colors,l={headerText:this.isEdit()?a("edit-place",{lng:o}):a("save-place",{lng:o}),autosuggestComponent:K({},this.props.autosuggestComponent),inputPlaceholder:a("input-placeholder",{lng:o}),specifyName:this.specifyName,name:e&&e.name||"",chooseIconText:a("choose-icon",{lng:o}),favouriteIconTable:c.default.createElement(U,{selectedIconId:(()=>{if(e&&void 0!==e.selectedIconId)return e.selectedIconId})(),favouriteIconIds:G.favouriteIconIds,handleClick:this.selectIcon,color:n,lang:o}),saveFavourite:this.save,saveText:a("save",{lng:o}),canSave:this.canSave,isEdit:this.isEdit(),cancelText:a("cancel",{lng:o}),cancelSelected:()=>this.cancelSelected(),color:n,hoverColor:i,savePlaceText:a("save-place",{lng:o}),cantSaveText:a("cannot-save-place",{lng:o}),requiredText:a("required-text",{lng:o}),fontWeights:t};return c.default.createElement(v.default,{appElement:this.props.appElement,contentLabel:this.isEdit()?a("favourite-modal-on-edit",{lng:o,favourite:e}):a("favourite-modal-on-add-new",{lng:o}),closeButtonLabel:a("close-favourite-modal",{lng:o}),variant:this.props.isMobile?"large":"small",isOpen:this.props.isModalOpen,onCrossClick:()=>this.closeModal()},!this.props.isMobile&&c.default.createElement(B,l),this.props.isMobile&&c.default.createElement(V,l))}}k(G,"defaultProps",{cancelSelected:()=>({}),lang:"fi",isMobile:!1,favourite:null,autosuggestComponent:void 0,addAnalyticsEvent:void 0,colors:s.defaultColors,fontWeights:{medium:500}}),k(G,"favouriteIconIds",["place","home","work","sport","school","shopping"]),"production"!==process.env.NODE_ENV&&(G.propTypes={isModalOpen:f.default.bool.isRequired,handleClose:f.default.func.isRequired,saveFavourite:f.default.func.isRequired,cancelSelected:f.default.func,autosuggestComponent:f.default.node,favourite:f.default.shape({type:f.default.string,address:f.default.string,gtfsId:f.default.string,gid:f.default.string,lat:f.default.number,lon:f.default.number,name:f.default.string,selectedIconId:f.default.string,favouriteId:f.default.string,layer:f.default.string,defaultName:f.default.string}),addAnalyticsEvent:f.default.func,lang:f.default.string,t:f.default.func.isRequired,isMobile:f.default.bool,appElement:f.default.string.isRequired,colors:f.default.objectOf(f.default.string),fontWeights:f.default.shape({medium:f.default.number})});const H=n.withTranslation()(G);e.default=e=>c.default.createElement(n.I18nextProvider,{i18n:w},c.default.createElement(H,e)),Object.defineProperty(e,"__esModule",{value:!0})});
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cx from 'classnames';
4
+ import { withTranslation, useTranslation, I18nextProvider } from 'react-i18next';
5
+ import isEmpty from 'lodash/isEmpty.js';
6
+ import isNumber from 'lodash/isNumber.js';
7
+ import Modal from '@hsl-fi/modal';
8
+ import Icon, { defaultColors } from '@digitransit-component/digitransit-component-icon';
9
+ import { createInstance } from 'i18next';
10
+
11
+ function _typeof(o) {
12
+ "@babel/helpers - typeof";
13
+
14
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
15
+ return typeof o;
16
+ } : function (o) {
17
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
18
+ }, _typeof(o);
19
+ }
20
+
21
+ function toPrimitive(t, r) {
22
+ if ("object" != _typeof(t) || !t) return t;
23
+ var e = t[Symbol.toPrimitive];
24
+ if (void 0 !== e) {
25
+ var i = e.call(t, r);
26
+ if ("object" != _typeof(i)) return i;
27
+ throw new TypeError("@@toPrimitive must return a primitive value.");
28
+ }
29
+ return ("string" === r ? String : Number)(t);
30
+ }
31
+
32
+ function toPropertyKey(t) {
33
+ var i = toPrimitive(t, "string");
34
+ return "symbol" == _typeof(i) ? i : i + "";
35
+ }
36
+
37
+ function _defineProperty(e, r, t) {
38
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
39
+ value: t,
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true
43
+ }) : e[r] = t, e;
44
+ }
45
+
46
+ function _objectWithoutPropertiesLoose(r, e) {
47
+ if (null == r) return {};
48
+ var t = {};
49
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
50
+ if (-1 !== e.indexOf(n)) continue;
51
+ t[n] = r[n];
52
+ }
53
+ return t;
54
+ }
55
+
56
+ function _objectWithoutProperties(e, t) {
57
+ if (null == e) return {};
58
+ var o,
59
+ r,
60
+ i = _objectWithoutPropertiesLoose(e, t);
61
+ if (Object.getOwnPropertySymbols) {
62
+ var n = Object.getOwnPropertySymbols(e);
63
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
64
+ }
65
+ return i;
66
+ }
67
+
68
+ function styleInject(css, ref) {
69
+ if ( ref === void 0 ) ref = {};
70
+ var insertAt = ref.insertAt;
71
+
72
+ if (!css || typeof document === 'undefined') { return; }
73
+
74
+ var head = document.head || document.getElementsByTagName('head')[0];
75
+ var style = document.createElement('style');
76
+ style.type = 'text/css';
77
+
78
+ if (insertAt === 'top') {
79
+ if (head.firstChild) {
80
+ head.insertBefore(style, head.firstChild);
81
+ } else {
82
+ head.appendChild(style);
83
+ }
84
+ } else {
85
+ head.appendChild(style);
86
+ }
87
+
88
+ if (style.styleSheet) {
89
+ style.styleSheet.cssText = css;
90
+ } else {
91
+ style.appendChild(document.createTextNode(css));
92
+ }
93
+ }
94
+
95
+ var css_248z$2 = ".styles_generic-table__AmCUO > .styles_row__Iooox {\n display: flex;\n}\n\n.styles_generic-table__label-container__ItaRd {\n font-size: 0.8rem;\n margin-top: 3px;\n color: #666;\n height: 16px;\n max-width: 62.5rem;\n margin-left: auto;\n margin-right: auto;\n}\n\n.styles_favourite-icon-table-column__CzU8B {\n cursor: pointer;\n flex: 1;\n align-items: center;\n padding: 0;\n background: #fff;\n float: left;\n height: 50px;\n margin: 0;\n line-height: 1;\n text-align: center;\n font-size: 17px;\n border-top: solid 1px #ddd;\n border-bottom: solid 1px #ddd;\n border-right: solid 1px #ddd;\n border-left: none;\n}\n.styles_favourite-icon-table-column__CzU8B.styles_place__P6Ks- svg {\n width: 24px;\n height: 24px;\n}\n.styles_favourite-icon-table-column__CzU8B.styles_work__XL3SA svg {\n width: 20px;\n height: 20px;\n}\n.styles_favourite-icon-table-column__CzU8B.styles_home__xYJbW svg, .styles_favourite-icon-table-column__CzU8B.styles_school__K3-Yy svg, .styles_favourite-icon-table-column__CzU8B.styles_sport__i0xXI svg, .styles_favourite-icon-table-column__CzU8B.styles_shopping__eQ3br svg {\n width: 18px;\n height: 18px;\n}\n.styles_favourite-icon-table-column__CzU8B:active, .styles_favourite-icon-table-column__CzU8B:hover, .styles_favourite-icon-table-column__CzU8B:focus,\n.styles_favourite-icon-table-column__CzU8B .styles_selected-icon__PMTfC {\n background: #333;\n color: #fff;\n}\n\n.styles_favourite-icon-table-column__CzU8B:first-child {\n border-left: solid 1px #ddd;\n border-top-left-radius: 5px;\n border-bottom-left-radius: 5px;\n}\n\n.styles_favourite-icon-table-column__CzU8B:last-child {\n border-top-right-radius: 5px;\n border-bottom-right-radius: 5px;\n}\n\n.styles_favourite-icon-table-column__CzU8B.styles_selected-icon__PMTfC {\n background: #333;\n color: #fff;\n}";
96
+ var styles$2 = {"generic-table":"styles_generic-table__AmCUO","row":"styles_row__Iooox","generic-table__label-container":"styles_generic-table__label-container__ItaRd","favourite-icon-table-column":"styles_favourite-icon-table-column__CzU8B","place":"styles_place__P6Ks-","work":"styles_work__XL3SA","home":"styles_home__xYJbW","school":"styles_school__K3-Yy","sport":"styles_sport__i0xXI","shopping":"styles_shopping__eQ3br","selected-icon":"styles_selected-icon__PMTfC"};
97
+ styleInject(css_248z$2);
98
+
99
+ /* eslint sort-keys: "error" */
100
+ const translations = {
101
+ de: {
102
+ translation: {
103
+ cancel: 'Abbrechen',
104
+ 'choose-icon': 'Wählen Sie ein Symbol für diesen Ort',
105
+ 'close-favourite-modal': 'Favoriten-Dialog schließen',
106
+ 'edit-place': 'Ort bearbeiten',
107
+ 'favourite-modal-on-add-new': 'Neuen Favoriten hinzufügen',
108
+ 'favourite-modal-on-edit': 'Favorit bearbeiten: {{favourite.name}}',
109
+ 'input-placeholder': 'Einen Namen für Ort setzen (optional)',
110
+ save: 'Speichern',
111
+ 'save-place': 'Favorit speichern'
112
+ }
113
+ },
114
+ en: {
115
+ translation: {
116
+ cancel: 'Cancel',
117
+ 'cannot-save-place': 'Cannot save a place without address or icon',
118
+ 'choose-icon': "Select the place's icon",
119
+ 'close-favourite-modal': 'Close the favourite modal',
120
+ 'edit-place': 'Edit place',
121
+ 'favourite-modal-on-add-new': 'Add a new favorite',
122
+ 'favourite-modal-on-edit': 'Editing favourite: {{favourite.name}}',
123
+ home: 'home',
124
+ 'input-placeholder': 'Give the name a place (optional)',
125
+ place: 'a place',
126
+ 'required-text': 'required field',
127
+ save: 'Save',
128
+ 'save-place': 'Save place',
129
+ school: 'school',
130
+ shopping: 'shopping',
131
+ sport: 'sport',
132
+ work: 'work'
133
+ }
134
+ },
135
+ fi: {
136
+ translation: {
137
+ cancel: 'Peruuta',
138
+ 'cannot-save-place': 'Paikkaa ilman osoitetta tai ikonia ei voida tallentaa',
139
+ 'choose-icon': 'Valitse paikan kuvake',
140
+ 'close-favourite-modal': 'Sulje suosikkimodaali',
141
+ 'edit-place': 'Muokkaa paikkaa',
142
+ 'favourite-modal-on-add-new': 'Lisää uusi suosikki',
143
+ 'favourite-modal-on-edit': 'Muokkaa suosikkia {{favourite.name}}',
144
+ home: 'koti',
145
+ 'input-placeholder': 'Anna paikalle nimi (vapaaehtoinen)',
146
+ place: 'paikka',
147
+ 'required-text': 'pakollinen kenttä',
148
+ save: 'Tallenna',
149
+ 'save-place': 'Tallenna paikka',
150
+ school: 'koulu',
151
+ shopping: 'ostokset',
152
+ sport: 'urheilu',
153
+ work: 'työ'
154
+ }
155
+ },
156
+ pl: {
157
+ translation: {
158
+ cancel: 'Anuluj',
159
+ 'cannot-save-place': 'Nie można zapisać miejsca bez nazwy lub ikony',
160
+ 'choose-icon': 'Wybierz ikonę miejsca',
161
+ 'close-favourite-modal': 'Zamknij modal ulubionych',
162
+ 'edit-place': 'Edytuj miejsce',
163
+ 'favourite-modal-on-add-new': 'Dodaj ulubione miejsce',
164
+ 'favourite-modal-on-edit': 'Edycja ulubionego miejsca: {{favourite.name}}',
165
+ home: 'dom',
166
+ 'input-placeholder': 'Nadaj nazwę miejscu (opcjonalne)',
167
+ place: 'miejsce',
168
+ 'required-text': 'pole wymagane',
169
+ save: 'Zapisz',
170
+ 'save-place': 'Zapisz miejsce',
171
+ school: 'szkoła',
172
+ shopping: 'zakupy',
173
+ sport: 'sport',
174
+ work: 'praca'
175
+ }
176
+ },
177
+ sv: {
178
+ translation: {
179
+ cancel: 'Avbryt',
180
+ 'cannot-save-place': 'Det går inte att spara en plats utan adress eller ikon',
181
+ 'choose-icon': 'Välj platsens ikon',
182
+ 'close-favourite-modal': 'Stäng favoritmodalen',
183
+ 'edit-place': 'Redigera plats',
184
+ 'favourite-modal-on-add-new': 'Lägg till ny favorit',
185
+ 'favourite-modal-on-edit': 'Redigera platsen: {{favourite.name}}',
186
+ home: 'hem',
187
+ 'input-placeholder': 'Ange platsens namn (frivilligt)',
188
+ place: 'en plats',
189
+ 'required-text': 'obligatoriskt fält',
190
+ save: 'Spara',
191
+ 'save-place': 'Spara plats',
192
+ school: 'skola',
193
+ shopping: 'shoppa',
194
+ sport: 'sport',
195
+ work: 'arbete'
196
+ }
197
+ }
198
+ };
199
+
200
+ const i18n = createInstance({
201
+ fallbackLng: 'fi',
202
+ // debug: true,
203
+ resources: translations,
204
+ defaultNS: 'translation',
205
+ react: {
206
+ useSuspense: true
207
+ }
208
+ });
209
+ i18n.init();
210
+
211
+ var css_248z$1 = ".desktop_favourite-modal-desktop-container__PV5YQ {\n display: flex;\n flex-direction: column;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-top__Md0-E {\n display: flex;\n flex-direction: row;\n width: 100%;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-top__Md0-E .desktop_favourite-modal-desktop-header__ko87c {\n width: 100%;\n font-size: 18px;\n font-weight: var(--font-weight-medium);\n line-height: 1.33;\n letter-spacing: -0.6px;\n color: #333;\n margin-bottom: 25px;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-main__lkOF7 {\n text-align: left;\n margin-bottom: 27px;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-main__lkOF7 .desktop_favourite-modal-desktop-location-search__QO5vN {\n margin-bottom: 9px;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-main__lkOF7 .desktop_favourite-modal-desktop-name__qAHli .desktop_favourite-modal-desktop-input__GPKca {\n display: flex;\n position: relative;\n width: 100%;\n height: 44px;\n font-family: inherit;\n border-radius: 5px;\n border: solid 1px #888;\n background-color: #fff;\n padding-left: 20px;\n font-size: 15px;\n line-height: 1.2;\n letter-spacing: -0.5px;\n color: #333;\n box-sizing: border-box;\n appearance: none;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-main__lkOF7 .desktop_favourite-modal-desktop-name__qAHli .desktop_favourite-modal-desktop-input__GPKca::placeholder {\n color: #666;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-main__lkOF7 .desktop_favourite-modal-desktop-name__qAHli .desktop_favourite-modal-desktop-input__GPKca:focus {\n background: #fff;\n outline: none;\n border: 1px solid var(--color);\n box-shadow: 0 0 2px 1px var(--hover-color);\n appearance: none;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-text__QuGLs {\n font-size: 16px;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.53px;\n color: #333;\n margin: 0 0 11px 0;\n padding: 0;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-icons__lYHGt {\n margin-bottom: 30px;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_icons-container__qsM8T {\n border: none;\n margin: 0;\n padding: 0;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN {\n display: flex;\n flex-direction: column;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5 {\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n width: 100%;\n height: 50px;\n font-size: 18px;\n font-family: inherit;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.5px;\n background: var(--color);\n color: #fff;\n line-height: 0;\n text-align: center;\n padding: 0;\n margin: 0;\n border-width: 0;\n transition: background-color 300ms ease-out;\n border-radius: 25px;\n cursor: pointer;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5.desktop_save__3FjAd:active, .desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5.desktop_save__3FjAd:focus, .desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5.desktop_save__3FjAd:hover {\n border-color: var(--hover-color);\n background: var(--hover-color);\n color: #fff;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5.desktop_save__3FjAd.desktop_disabled__TxliP {\n background: #bbb;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5.desktop_save__3FjAd.desktop_disabled__TxliP:active {\n background: #bbb;\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5.desktop_edit__OWrRz {\n margin-top: 9px;\n background: #fff;\n border: solid 1px var(--color);\n color: var(--color);\n}\n.desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5.desktop_edit__OWrRz:active, .desktop_favourite-modal-desktop-container__PV5YQ .desktop_favourite-modal-desktop-buttons__CmnaN .desktop_favourite-modal-desktop-button__DS4p5.desktop_edit__OWrRz:hover {\n border-color: var(--hover-color);\n background-color: #fff;\n color: var(--hover-color);\n}\n\n.desktop_sr-only__Xy3rC:not(:focus, :active) {\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n}";
212
+ var styles$1 = {"favourite-modal-desktop-container":"desktop_favourite-modal-desktop-container__PV5YQ","favourite-modal-desktop-top":"desktop_favourite-modal-desktop-top__Md0-E","favourite-modal-desktop-header":"desktop_favourite-modal-desktop-header__ko87c","favourite-modal-desktop-main":"desktop_favourite-modal-desktop-main__lkOF7","favourite-modal-desktop-location-search":"desktop_favourite-modal-desktop-location-search__QO5vN","favourite-modal-desktop-name":"desktop_favourite-modal-desktop-name__qAHli","favourite-modal-desktop-input":"desktop_favourite-modal-desktop-input__GPKca","favourite-modal-desktop-text":"desktop_favourite-modal-desktop-text__QuGLs","favourite-modal-desktop-icons":"desktop_favourite-modal-desktop-icons__lYHGt","icons-container":"desktop_icons-container__qsM8T","favourite-modal-desktop-buttons":"desktop_favourite-modal-desktop-buttons__CmnaN","favourite-modal-desktop-button":"desktop_favourite-modal-desktop-button__DS4p5","save":"desktop_save__3FjAd","disabled":"desktop_disabled__TxliP","edit":"desktop_edit__OWrRz","sr-only":"desktop_sr-only__Xy3rC"};
213
+ styleInject(css_248z$1);
214
+
215
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
216
+ const DesktopModal = ({
217
+ headerText,
218
+ autosuggestComponent,
219
+ inputPlaceholder,
220
+ specifyName,
221
+ name,
222
+ chooseIconText,
223
+ favouriteIconTable,
224
+ saveFavourite,
225
+ saveText,
226
+ canSave,
227
+ isEdit,
228
+ cancelText,
229
+ cancelSelected,
230
+ color,
231
+ hoverColor,
232
+ savePlaceText,
233
+ cantSaveText,
234
+ requiredText,
235
+ fontWeights
236
+ }) => {
237
+ return /*#__PURE__*/React.createElement("div", {
238
+ className: styles$1['favourite-modal-desktop-container'],
239
+ style: {
240
+ '--color': `${color}`,
241
+ '--hover-color': `${hoverColor}`,
242
+ '--font-weight-medium': fontWeights.medium
243
+ }
244
+ }, /*#__PURE__*/React.createElement("div", {
245
+ className: styles$1['favourite-modal-desktop-top']
246
+ }, /*#__PURE__*/React.createElement("div", {
247
+ className: styles$1['favourite-modal-desktop-header']
248
+ }, headerText)), /*#__PURE__*/React.createElement("div", {
249
+ className: styles$1['favourite-modal-desktop-main']
250
+ }, /*#__PURE__*/React.createElement("div", {
251
+ className: styles$1['favourite-modal-desktop-location-search']
252
+ }, autosuggestComponent), /*#__PURE__*/React.createElement("div", {
253
+ className: styles$1['favourite-modal-desktop-name']
254
+ }, /*#__PURE__*/React.createElement("input", {
255
+ "aria-label": inputPlaceholder,
256
+ className: styles$1['favourite-modal-desktop-input'],
257
+ value: name,
258
+ placeholder: inputPlaceholder,
259
+ onChange: specifyName
260
+ }))), /*#__PURE__*/React.createElement("fieldset", {
261
+ className: styles$1['icons-container']
262
+ }, /*#__PURE__*/React.createElement("legend", {
263
+ className: styles$1['favourite-modal-desktop-text']
264
+ }, chooseIconText, /*#__PURE__*/React.createElement("p", {
265
+ className: styles$1['sr-only']
266
+ }, requiredText)), /*#__PURE__*/React.createElement("div", {
267
+ className: styles$1['favourite-modal-desktop-icons']
268
+ }, favouriteIconTable)), /*#__PURE__*/React.createElement("div", {
269
+ className: styles$1['favourite-modal-desktop-buttons']
270
+ }, /*#__PURE__*/React.createElement("button", {
271
+ type: "button",
272
+ className: `${styles$1['favourite-modal-desktop-button']} ${styles$1.save} ${canSave() ? '' : styles$1.disabled}`,
273
+ onClick: saveFavourite,
274
+ "aria-label": `${canSave() ? savePlaceText : cantSaveText}`,
275
+ "aria-disabled": !canSave()
276
+ }, saveText), isEdit && /*#__PURE__*/React.createElement("button", {
277
+ type: "button",
278
+ className: `${styles$1['favourite-modal-desktop-button']} ${styles$1.edit} ${canSave() ? '' : styles$1.disabled}`,
279
+ onClick: cancelSelected
280
+ }, cancelText)));
281
+ };
282
+ process.env.NODE_ENV !== "production" ? DesktopModal.propTypes = {
283
+ headerText: PropTypes.string.isRequired,
284
+ autosuggestComponent: PropTypes.node.isRequired,
285
+ inputPlaceholder: PropTypes.string.isRequired,
286
+ specifyName: PropTypes.func.isRequired,
287
+ name: PropTypes.string.isRequired,
288
+ chooseIconText: PropTypes.string.isRequired,
289
+ favouriteIconTable: PropTypes.node.isRequired,
290
+ saveFavourite: PropTypes.func.isRequired,
291
+ saveText: PropTypes.string.isRequired,
292
+ canSave: PropTypes.func.isRequired,
293
+ isEdit: PropTypes.bool,
294
+ cancelText: PropTypes.string.isRequired,
295
+ cancelSelected: PropTypes.func,
296
+ color: PropTypes.string.isRequired,
297
+ hoverColor: PropTypes.string.isRequired,
298
+ savePlaceText: PropTypes.string.isRequired,
299
+ cantSaveText: PropTypes.string.isRequired,
300
+ requiredText: PropTypes.string.isRequired,
301
+ fontWeights: PropTypes.shape({
302
+ medium: PropTypes.number.isRequired
303
+ }).isRequired
304
+ } : void 0;
305
+ DesktopModal.defaultProps = {
306
+ isEdit: false,
307
+ cancelSelected: () => ({})
308
+ };
309
+
310
+ var css_248z = ".mobile_favourite-modal-mobile-container__KaYun {\n display: flex;\n flex-direction: column;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-top__SkpP4 {\n display: flex;\n flex-direction: row;\n width: 100%;\n border-bottom: 1px solid #ddd;\n margin-bottom: 30px;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-top__SkpP4 .mobile_favourite-modal-mobile-header__dZlvY {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 100%;\n height: inherit;\n font-size: 18px;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.6px;\n text-align: center;\n color: #333;\n margin-bottom: 37px;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-main__VeUUV {\n text-align: left;\n margin-bottom: 28px;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-main__VeUUV .mobile_favourite-modal-mobile-location-search__fTM46 {\n margin-bottom: 9px;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-main__VeUUV .mobile_favourite-modal-mobile-input__yYUMl {\n display: flex;\n position: relative;\n width: 100%;\n height: 44px;\n font-family: inherit;\n border-radius: 5px;\n border: solid 1px #888;\n background-color: #fff;\n padding-left: 20px;\n font-size: 16px;\n line-height: 1.2;\n letter-spacing: -0.5px;\n color: #333;\n box-sizing: border-box;\n appearance: none;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-main__VeUUV .mobile_favourite-modal-mobile-input__yYUMl:focus {\n background: #fff;\n outline: none;\n border: 1px solid var(--color);\n box-shadow: 0 0 2px 1px var(--hover-color);\n appearance: none;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-main__VeUUV .mobile_favourite-modal-mobile-input__yYUMl::placeholder {\n color: #666;\n font-size: 15px;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-text__Dqo7y {\n font-size: 16px;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.53px;\n color: #333;\n margin-bottom: 18px;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-save__-CniA {\n width: 100%;\n margin-top: 30px;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-save__-CniA .mobile_favourite-modal-mobile-button__n7-mw {\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n width: 100%;\n height: 50px;\n font-size: 18px;\n font-family: inherit;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.5px;\n background: var(--color);\n line-height: 0;\n text-align: center;\n padding: 0;\n margin: 0;\n color: #fff;\n border-width: 0;\n transition: background-color 300ms ease-out;\n border-radius: 25px;\n cursor: pointer;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-save__-CniA .mobile_favourite-modal-mobile-button__n7-mw:active, .mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-save__-CniA .mobile_favourite-modal-mobile-button__n7-mw:focus, .mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-save__-CniA .mobile_favourite-modal-mobile-button__n7-mw:hover {\n border-color: var(--hover-color);\n background: var(--hover-color);\n color: #fff;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-save__-CniA .mobile_favourite-modal-mobile-button__n7-mw.mobile_disabled__X2KRm {\n background: #bbb;\n}\n.mobile_favourite-modal-mobile-container__KaYun .mobile_favourite-modal-mobile-save__-CniA .mobile_favourite-modal-mobile-button__n7-mw.mobile_disabled__X2KRm:active {\n background: #bbb;\n}\n\n.mobile_sr-only__kTOSh:not(:focus, :active) {\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n}";
311
+ var styles = {"favourite-modal-mobile-container":"mobile_favourite-modal-mobile-container__KaYun","favourite-modal-mobile-top":"mobile_favourite-modal-mobile-top__SkpP4","favourite-modal-mobile-header":"mobile_favourite-modal-mobile-header__dZlvY","favourite-modal-mobile-main":"mobile_favourite-modal-mobile-main__VeUUV","favourite-modal-mobile-location-search":"mobile_favourite-modal-mobile-location-search__fTM46","favourite-modal-mobile-input":"mobile_favourite-modal-mobile-input__yYUMl","favourite-modal-mobile-text":"mobile_favourite-modal-mobile-text__Dqo7y","favourite-modal-mobile-save":"mobile_favourite-modal-mobile-save__-CniA","favourite-modal-mobile-button":"mobile_favourite-modal-mobile-button__n7-mw","disabled":"mobile_disabled__X2KRm","sr-only":"mobile_sr-only__kTOSh"};
312
+ styleInject(css_248z);
313
+
314
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
315
+ const MobileModal = ({
316
+ headerText,
317
+ autosuggestComponent,
318
+ inputPlaceholder,
319
+ specifyName,
320
+ name,
321
+ chooseIconText,
322
+ favouriteIconTable,
323
+ saveFavourite,
324
+ saveText,
325
+ canSave,
326
+ color,
327
+ hoverColor,
328
+ savePlaceText,
329
+ cantSaveText,
330
+ requiredText,
331
+ fontWeights
332
+ }) => {
333
+ return /*#__PURE__*/React.createElement("div", {
334
+ className: styles['favourite-modal-mobile-container'],
335
+ style: {
336
+ '--color': `${color}`,
337
+ '--hover-color': `${hoverColor}`,
338
+ '--font-weight-medium': fontWeights.medium
339
+ }
340
+ }, /*#__PURE__*/React.createElement("div", {
341
+ className: styles['favourite-modal-mobile-top']
342
+ }, /*#__PURE__*/React.createElement("div", {
343
+ className: styles['favourite-modal-mobile-header']
344
+ }, headerText)), /*#__PURE__*/React.createElement("div", {
345
+ className: styles['favourite-modal-mobile-main']
346
+ }, /*#__PURE__*/React.createElement("div", {
347
+ className: styles['favourite-modal-mobile-location-search']
348
+ }, autosuggestComponent), /*#__PURE__*/React.createElement("input", {
349
+ className: styles['favourite-modal-mobile-input'],
350
+ value: name || '',
351
+ placeholder: inputPlaceholder,
352
+ onChange: specifyName
353
+ })), /*#__PURE__*/React.createElement("div", {
354
+ className: styles['favourite-modal-mobile-text']
355
+ }, chooseIconText, /*#__PURE__*/React.createElement("p", {
356
+ className: styles['sr-only']
357
+ }, requiredText)), /*#__PURE__*/React.createElement("div", {
358
+ className: styles['favourite-modal-mobile-icons']
359
+ }, favouriteIconTable), /*#__PURE__*/React.createElement("div", {
360
+ className: styles['favourite-modal-mobile-save']
361
+ }, /*#__PURE__*/React.createElement("button", {
362
+ type: "button",
363
+ className: `${styles['favourite-modal-mobile-button']} ${canSave() ? '' : styles.disabled}`,
364
+ onClick: saveFavourite,
365
+ "aria-label": `${canSave() ? savePlaceText : cantSaveText}`
366
+ }, saveText)));
367
+ };
368
+ process.env.NODE_ENV !== "production" ? MobileModal.propTypes = {
369
+ headerText: PropTypes.string.isRequired,
370
+ autosuggestComponent: PropTypes.node.isRequired,
371
+ inputPlaceholder: PropTypes.string.isRequired,
372
+ specifyName: PropTypes.func.isRequired,
373
+ name: PropTypes.string.isRequired,
374
+ chooseIconText: PropTypes.string.isRequired,
375
+ favouriteIconTable: PropTypes.node.isRequired,
376
+ saveFavourite: PropTypes.func.isRequired,
377
+ saveText: PropTypes.string.isRequired,
378
+ canSave: PropTypes.func.isRequired,
379
+ color: PropTypes.string.isRequired,
380
+ hoverColor: PropTypes.string.isRequired,
381
+ savePlaceText: PropTypes.string.isRequired,
382
+ cantSaveText: PropTypes.string.isRequired,
383
+ requiredText: PropTypes.string.isRequired,
384
+ fontWeights: PropTypes.shape({
385
+ medium: PropTypes.number.isRequired
386
+ }).isRequired
387
+ } : void 0;
388
+
389
+ const _excluded = ["favouriteIconIds"];
390
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
391
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
392
+ const FavouriteIconIdToNameMap = {
393
+ 'icon-icon_place': 'place',
394
+ 'icon-icon_home': 'home',
395
+ 'icon-icon_work': 'work',
396
+ 'icon-icon_sport': 'sport',
397
+ 'icon-icon_school': 'school',
398
+ 'icon-icon_shopping': 'shopping'
399
+ };
400
+ const FavouriteIconTableButton = ({
401
+ value,
402
+ selectedIconId,
403
+ handleClick,
404
+ color,
405
+ lang
406
+ }) => {
407
+ const [t] = useTranslation();
408
+ const [isHovered, setHover] = useState(false);
409
+ const [isFocused, setFocus] = useState(false);
410
+ const iconColor = value === FavouriteIconIdToNameMap[selectedIconId] || isHovered || isFocused ? '#ffffff' : color;
411
+ return /*#__PURE__*/React.createElement("button", {
412
+ type: "button",
413
+ className: cx(styles$2['favourite-icon-table-column'], styles$2[value], value === FavouriteIconIdToNameMap[selectedIconId] && styles$2['selected-icon']),
414
+ onMouseEnter: () => setHover(true),
415
+ onMouseLeave: () => setHover(false),
416
+ onFocus: () => setFocus(true),
417
+ onBlur: () => setFocus(false),
418
+ onClick: () => handleClick(value),
419
+ "aria-label": t(value, {
420
+ lng: lang
421
+ })
422
+ }, /*#__PURE__*/React.createElement(Icon, {
423
+ img: value,
424
+ color: iconColor
425
+ }));
426
+ };
427
+ process.env.NODE_ENV !== "production" ? FavouriteIconTableButton.propTypes = {
428
+ handleClick: PropTypes.func.isRequired,
429
+ value: PropTypes.string.isRequired,
430
+ selectedIconId: PropTypes.string,
431
+ color: PropTypes.string.isRequired,
432
+ lang: PropTypes.string.isRequired
433
+ } : void 0;
434
+ FavouriteIconTableButton.defaultProps = {
435
+ selectedIconId: ''
436
+ };
437
+ const FavouriteIconTable = _ref => {
438
+ let {
439
+ favouriteIconIds
440
+ } = _ref,
441
+ rest = _objectWithoutProperties(_ref, _excluded);
442
+ const columns = favouriteIconIds.map(value => /*#__PURE__*/React.createElement(FavouriteIconTableButton, Object.assign({
443
+ key: `favourite-icon-table-${value}`,
444
+ value: value
445
+ }, rest)));
446
+ return /*#__PURE__*/React.createElement("div", {
447
+ className: styles$2['generic-table']
448
+ }, /*#__PURE__*/React.createElement("div", {
449
+ className: styles$2.row
450
+ }, columns));
451
+ };
452
+ process.env.NODE_ENV !== "production" ? FavouriteIconTable.propTypes = {
453
+ favouriteIconIds: PropTypes.arrayOf(PropTypes.string).isRequired
454
+ } : void 0;
455
+
456
+ /**
457
+ * @example
458
+ * <FavouriteModal
459
+ * show={modalOpen}
460
+ * handleClose={handleClose}
461
+ * saveFavourite={onSaveFavourite}
462
+ * location={selectedLocation}
463
+ * favourite={favourite}
464
+ * lang={lang}
465
+ * autosuggestComponent={
466
+ * <AutoSuggest
467
+ * sources={['History', 'Datasource']}
468
+ * targets={['Locations', 'CurrentPosition']}
469
+ * id="favourite"
470
+ * autoFocus={false}
471
+ * placeholder="search-address-or-place"
472
+ * value={selectedLocation.address || ''}
473
+ * onFavouriteSelected={this.setLocationProperties}
474
+ * lang={lang}
475
+ * />
476
+ * }
477
+ * />
478
+ */
479
+ class FavouriteModal extends React.Component {
480
+ constructor(props) {
481
+ super(props);
482
+ _defineProperty(this, "specifyName", event => {
483
+ const name = event.target.value;
484
+ this.setState(prevState => ({
485
+ favourite: _objectSpread(_objectSpread({}, prevState.favourite), {}, {
486
+ name
487
+ })
488
+ }));
489
+ });
490
+ _defineProperty(this, "selectIcon", id => {
491
+ this.setState(prevState => ({
492
+ favourite: _objectSpread(_objectSpread({}, prevState.favourite), {}, {
493
+ selectedIconId: `icon-icon_${id}`
494
+ })
495
+ }));
496
+ });
497
+ _defineProperty(this, "isEdit", () => this.state.favourite && this.state.favourite.favouriteId !== undefined);
498
+ _defineProperty(this, "canSave", () => this.state.favourite && !isEmpty(this.state.favourite.selectedIconId) && isNumber(this.state.favourite.lat) && isNumber(this.state.favourite.lon));
499
+ _defineProperty(this, "closeModal", () => {
500
+ this.props.handleClose();
501
+ // hsl-fi/modal close animation lasts 250ms
502
+ setTimeout(() => {
503
+ this.setState({
504
+ favourite: null
505
+ });
506
+ }, 250);
507
+ });
508
+ _defineProperty(this, "cancelSelected", () => {
509
+ this.props.cancelSelected();
510
+ // hsl-fi/modal close animation lasts 250ms
511
+ setTimeout(() => {
512
+ this.setState({
513
+ favourite: null
514
+ });
515
+ }, 250);
516
+ });
517
+ _defineProperty(this, "save", () => {
518
+ if (this.canSave()) {
519
+ const name = isEmpty(this.state.favourite.name) ? this.state.favourite.defaultName : this.state.favourite.name;
520
+ const favourite = _objectSpread(_objectSpread({}, this.state.favourite), {}, {
521
+ name
522
+ });
523
+ delete favourite.defaultName;
524
+ this.props.saveFavourite(_objectSpread(_objectSpread({}, favourite), {}, {
525
+ type: 'place'
526
+ }));
527
+ if (this.props.addAnalyticsEvent) {
528
+ this.props.addAnalyticsEvent({
529
+ category: 'Favourite',
530
+ action: 'SaveFavourite',
531
+ name: this.state.favourite.selectedIconId
532
+ });
533
+ }
534
+ if (this.isEdit() && this.props.cancelSelected) {
535
+ this.cancelSelected();
536
+ } else {
537
+ this.closeModal();
538
+ }
539
+ }
540
+ });
541
+ this.state = {
542
+ favourite: null
543
+ };
544
+ }
545
+ static getDerivedStateFromProps(nextProps, prevState) {
546
+ const prevFav = prevState.favourite;
547
+ const nextFav = nextProps.favourite;
548
+ if (isEmpty(nextFav)) {
549
+ return {
550
+ favourite: null
551
+ };
552
+ }
553
+ if (isEmpty(prevFav) && !isEmpty(nextFav)) {
554
+ return {
555
+ favourite: _objectSpread({}, nextFav)
556
+ };
557
+ }
558
+ if (!isEmpty(prevFav) && !isEmpty(nextFav) && (nextFav.address !== prevFav.address || nextFav.lat !== prevFav.lat || nextFav.lon !== prevFav.lon)) {
559
+ return {
560
+ favourite: _objectSpread(_objectSpread({}, prevFav), {}, {
561
+ address: nextFav.address,
562
+ lat: nextFav.lat,
563
+ lon: nextFav.lon,
564
+ gid: nextFav.gid || null,
565
+ name: prevFav.name || nextFav.name || '',
566
+ defaultName: nextFav.defaultName
567
+ })
568
+ };
569
+ }
570
+ return null;
571
+ }
572
+ componentWillUnmount() {
573
+ this.setState({
574
+ favourite: null
575
+ });
576
+ }
577
+ render() {
578
+ const {
579
+ favourite
580
+ } = this.state;
581
+ const {
582
+ fontWeights,
583
+ lang,
584
+ t
585
+ } = this.props;
586
+ const {
587
+ primary,
588
+ hover
589
+ } = this.props.colors;
590
+ const headerText = this.isEdit() ? t('edit-place', {
591
+ lng: lang
592
+ }) : t('save-place', {
593
+ lng: lang
594
+ });
595
+ const modalProps = {
596
+ headerText,
597
+ autosuggestComponent: this.props.autosuggestComponent,
598
+ inputPlaceholder: t('input-placeholder', {
599
+ lng: lang
600
+ }),
601
+ specifyName: this.specifyName,
602
+ name: favourite && favourite.name || '',
603
+ chooseIconText: t('choose-icon', {
604
+ lng: lang
605
+ }),
606
+ favouriteIconTable: /*#__PURE__*/React.createElement(FavouriteIconTable, {
607
+ selectedIconId: (() => {
608
+ if (favourite && favourite.selectedIconId !== undefined || null) {
609
+ return favourite.selectedIconId;
610
+ }
611
+ return undefined;
612
+ })(),
613
+ favouriteIconIds: FavouriteModal.favouriteIconIds,
614
+ handleClick: this.selectIcon,
615
+ color: primary,
616
+ lang: lang
617
+ }),
618
+ saveFavourite: this.save,
619
+ saveText: t('save', {
620
+ lng: lang
621
+ }),
622
+ canSave: this.canSave,
623
+ isEdit: this.isEdit(),
624
+ cancelText: t('cancel', {
625
+ lng: lang
626
+ }),
627
+ cancelSelected: () => this.cancelSelected(),
628
+ color: primary,
629
+ hoverColor: hover,
630
+ savePlaceText: t('save-place', {
631
+ lng: lang
632
+ }),
633
+ cantSaveText: t('cannot-save-place', {
634
+ lng: lang
635
+ }),
636
+ requiredText: t('required-text', {
637
+ lng: lang
638
+ }),
639
+ fontWeights
640
+ };
641
+ return /*#__PURE__*/React.createElement(Modal, {
642
+ appElement: this.props.appElement,
643
+ contentLabel: this.isEdit() ? t('favourite-modal-on-edit', {
644
+ lng: lang,
645
+ favourite
646
+ }) : t('favourite-modal-on-add-new', {
647
+ lng: lang
648
+ }),
649
+ closeButtonLabel: t('close-favourite-modal', {
650
+ lng: lang
651
+ }),
652
+ variant: !this.props.isMobile ? 'small' : 'large',
653
+ isOpen: this.props.isModalOpen,
654
+ onCrossClick: () => this.closeModal()
655
+ }, !this.props.isMobile && /*#__PURE__*/React.createElement(DesktopModal, modalProps), this.props.isMobile && /*#__PURE__*/React.createElement(MobileModal, modalProps));
656
+ }
657
+ }
658
+ _defineProperty(FavouriteModal, "defaultProps", {
659
+ cancelSelected: () => ({}),
660
+ lang: 'fi',
661
+ isMobile: false,
662
+ favourite: null,
663
+ autosuggestComponent: undefined,
664
+ addAnalyticsEvent: undefined,
665
+ colors: defaultColors,
666
+ fontWeights: {
667
+ medium: 500
668
+ }
669
+ });
670
+ _defineProperty(FavouriteModal, "favouriteIconIds", ['place', 'home', 'work', 'sport', 'school', 'shopping']);
671
+ process.env.NODE_ENV !== "production" ? FavouriteModal.propTypes = {
672
+ isModalOpen: PropTypes.bool.isRequired,
673
+ /** Required.
674
+ * @type{function} */
675
+ handleClose: PropTypes.func.isRequired,
676
+ /** Required.
677
+ * @type{function} */
678
+ saveFavourite: PropTypes.func.isRequired,
679
+ /** Required. Only used when editing favourite.
680
+ * @type{function} */
681
+ cancelSelected: PropTypes.func,
682
+ /** Optional.
683
+ * Autosuggest component for searching new favourites.
684
+ * @type{node}
685
+ */
686
+ autosuggestComponent: PropTypes.node,
687
+ /** Optional.
688
+ * Object to prefill input field for name and/or selected icon.
689
+ * @type {object}
690
+ * @property {string} type
691
+ * @property {string} address
692
+ * @property {string} gtfsId
693
+ * @property {string} gid
694
+ * @property {number} lat
695
+ * @property {number} lon
696
+ * @property {string} name
697
+ * @property {string} selectedIconId
698
+ * @property {string} favouriteId
699
+ * @property {string} layer
700
+ * @property {string} defaultName
701
+ */
702
+ favourite: PropTypes.shape({
703
+ type: PropTypes.string,
704
+ address: PropTypes.string,
705
+ gtfsId: PropTypes.string,
706
+ gid: PropTypes.string,
707
+ lat: PropTypes.number,
708
+ lon: PropTypes.number,
709
+ name: PropTypes.string,
710
+ selectedIconId: PropTypes.string,
711
+ favouriteId: PropTypes.string,
712
+ layer: PropTypes.string,
713
+ defaultName: PropTypes.string
714
+ }),
715
+ /** Optional.
716
+ * @type {function} */
717
+ addAnalyticsEvent: PropTypes.func,
718
+ /** Optional. Language, fi, en or sv.
719
+ * @type {string} */
720
+ lang: PropTypes.string,
721
+ /** Translation function */
722
+ t: PropTypes.func.isRequired,
723
+ /** Optional. */
724
+ isMobile: PropTypes.bool,
725
+ appElement: PropTypes.string.isRequired,
726
+ colors: PropTypes.objectOf(PropTypes.string),
727
+ /** Optional. */
728
+ fontWeights: PropTypes.shape({
729
+ /** Default value is 500. */
730
+ medium: PropTypes.number
731
+ })
732
+ } : void 0;
733
+ const FavouriteModalWithTranslation = withTranslation()(FavouriteModal);
734
+ var index = props => /*#__PURE__*/React.createElement(I18nextProvider, {
735
+ i18n: i18n
736
+ }, /*#__PURE__*/React.createElement(FavouriteModalWithTranslation, props));
737
+
738
+ export { index as default };
2
739
  //# sourceMappingURL=index.js.map