@digitransit-component/digitransit-component-autosuggest-panel 8.4.2 → 9.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/LICENSE-AGPL.txt +661 -0
- package/LICENSE-EUPL.txt +291 -0
- package/README.md +4 -16
- package/index.cjs +7 -0
- package/lib/index.cjs +2 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.development.cjs +840 -0
- package/lib/index.js +830 -1
- package/lib/index.js.map +1 -1
- package/package.json +24 -9
- package/index.js +0 -7
- package/lib/index.development.js +0 -2
package/lib/index.js
CHANGED
|
@@ -1,2 +1,831 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("classnames"),require("prop-types"),require("react"),require("react-i18next"),require("react-sortablejs"),require("@digitransit-component/digitransit-component-autosuggest"),require("@digitransit-component/digitransit-component-icon"),require("lodash/isEmpty"),require("downshift"),require("i18next")):"function"==typeof define&&define.amd?define(["exports","classnames","prop-types","react","react-i18next","react-sortablejs","@digitransit-component/digitransit-component-autosuggest","@digitransit-component/digitransit-component-icon","lodash/isEmpty","downshift","i18next"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@digitransit-component/digitransit-component-autosuggest-panel"]={},e.cx,e.PropTypes,e.React,e.reactI18next,e.reactSortablejs,e.DTAutosuggest,e.Icon,e.isEmpty,e.downshift,e.i18next)}(this,function(e,t,n,i,a,o,s,l,r,d,c){"use strict";function p(e){return e&&e.__esModule?e:{default:e}}var u=p(t),_=p(n),h=p(i),g=p(s),v=p(l),f=p(r);function m(e){return m="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},m(e)}function y(e){var t=function(e,t){if("object"!=m(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=m(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==m(t)?t:t+""}function b(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&i.firstChild?i.insertBefore(a,i.firstChild):i.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}var S="select_combobox-container__SvQ84",k="select_left-column__jbjXM",w="select_combobox-label__-CrdK",P="select_container__-r8y8",E="select_suggestion__JyaUk",O="select_suggestionHighlighted__nWx3k",N="select_suggestionsContainerOpen__JVYuR",C="select_input__YVoSg";x(".select_combobox-container__SvQ84 {\n background-color: #fff;\n border: solid #888 1px;\n display: flex;\n align-items: center;\n border-radius: 5px;\n height: 50px;\n justify-content: space-between;\n flex-grow: 1;\n}\n.select_combobox-container__SvQ84:focus-within {\n border-color: #007ac9;\n}\n.select_combobox-container__SvQ84 .select_left-column__jbjXM {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n\n.select_combobox-label__-CrdK {\n font-size: 12px;\n line-height: 20px;\n color: #666;\n letter-spacing: -0.48px;\n margin-left: 12px;\n margin-top: 4px;\n}\n\n.select_container__-r8y8 {\n position: relative;\n width: 100%;\n height: 100%;\n}\n.select_container__-r8y8 > div {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n height: 100%;\n cursor: pointer;\n}\n.select_container__-r8y8 .select_suggestion__JyaUk {\n font-size: 15px;\n line-height: 49px;\n height: 50px;\n padding: 0 0 0 12px;\n letter-spacing: -0.6px;\n color: #333;\n font-weight: 500;\n}\n.select_container__-r8y8 .select_suggestionHighlighted__nWx3k {\n font-size: 15px;\n font-weight: 500;\n background: #f2f5f7;\n}\n.select_container__-r8y8 .select_suggestionsContainerOpen__JVYuR {\n position: absolute;\n background-color: #fff;\n z-index: 20;\n max-height: 250px;\n overflow-x: hidden;\n overflow-y: scroll;\n border-radius: 5px;\n box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.06);\n border: 1px rgba(0, 0, 0, 0.1) solid;\n top: calc(100% + 4px);\n left: 0;\n width: 100%;\n list-style-type: none;\n padding: 0;\n margin: 0;\n}\n.select_container__-r8y8 .select_suggestionsContainerOpen__JVYuR ul {\n padding: 0;\n margin: 0;\n}\n.select_container__-r8y8 .select_suggestionsContainerOpen__JVYuR li:not(:last-child) {\n border-bottom: 1px solid #ddd;\n}\n.select_container__-r8y8 .select_input__YVoSg {\n appearance: none;\n margin: -4px 0 0 0;\n padding-left: 12px;\n border: none;\n height: 26px;\n}\n.select_container__-r8y8 .select_input__YVoSg:focus {\n outline: none;\n border: none;\n box-shadow: none;\n background: #fff;\n}\n.select_container__-r8y8 .select_input__YVoSg:read-only {\n cursor: pointer;\n background: #fff;\n}\n.select_container__-r8y8 .select_input__YVoSg {\n background: #fff;\n font-weight: 500;\n box-shadow: none;\n font-size: 15px;\n font-stretch: normal;\n font-style: normal;\n line-height: 1.33;\n letter-spacing: -0.6px;\n color: #333;\n}");const V=({value:e,options:t,onSlackTimeSelected:n,viaPointIndex:i,id:a,label:o,icon:s})=>{const l=`${a}-label`,r=t.find(t=>t.value===e),{isOpen:c,getToggleButtonProps:p,getMenuProps:_,getItemProps:g,getLabelProps:v,highlightedIndex:f}=d.useSelect({selectedItem:r,items:t,labelId:l,id:a,itemToString:e=>e.displayName,onSelectedItemChange:({selectedItem:e})=>{n(e.value,i)}});return h.default.createElement("div",{className:S},h.default.createElement("div",{className:P},h.default.createElement("div",p(),h.default.createElement("span",{className:k},h.default.createElement("label",Object.assign({},v(),{className:w}),o),h.default.createElement("div",{className:C},h.default.createElement("span",null,r.displayName))),s),h.default.createElement("ul",Object.assign({className:u.default(N,!c&&"hidden")},_()),c&&t.map((e,t)=>h.default.createElement("li",Object.assign({key:e.value,className:u.default(E,t===f&&O)},g({index:t})),h.default.createElement("span",null,e.displayName))))))};"production"!==process.env.NODE_ENV&&(V.propTypes={value:_.default.number.isRequired,onSlackTimeSelected:_.default.func.isRequired,options:_.default.arrayOf(_.default.shape({displayName:_.default.string.isRequired,value:_.default.number.isRequired}).isRequired).isRequired,id:_.default.string.isRequired,label:_.default.node.isRequired,icon:_.default.node.isRequired,viaPointIndex:_.default.number.isRequired});const A=c.createInstance({fallbackLng:"fi",resources:{de:{translation:{"add-via-button-label":"Füge Zwischenziel hinzu","add-via-duration-button-label":"Setze Umsteigezeit für Zwischenziel {{index}}","add-via-duration-button-label-close":"Schließe Umsteigezeit-Auswahl für Zwischenziel {{index}}","add-via-duration-button-label-open":"Öffne Umsteigezeit-Auswahl für Zwischenziel {{index}}","minute-short":"min","remove-via-button-label":"Entferne Zwischenziel {{index}}","swap-order-button-label":"Tausche Start mit Ziel","via-point":"Zwischenziel","via-point-index":"Zwischenziel {{index}}","viapoint-slack-amount":"Umsteigezeit"}},en:{translation:{"add-via-button-label":"Add via point","add-via-duration-button-label":"Set stop duration at via point {{index}}","add-via-duration-button-label-close":"Close stop duration selector at via point {{index}}","add-via-duration-button-label-open":"Open stop duration selector at via point {{index}}","minute-short":"min","remove-via-button-label":"Remove via point {{index}}","swap-order-button-label":"Reverse origin and destination","via-point":"Via point","via-point-index":"Via point {{index}}","viapoint-slack-amount":"Stop duration"}},fi:{translation:{"add-via-button-label":"Lisää välipiste","add-via-duration-button-label":"Aseta välipisteelle {{index}} pysähdyksen kesto","add-via-duration-button-label-close":"Avaa välipisteen {{index}} pysähdyksen kesto valitsin","add-via-duration-button-label-open":"Sulje välipisteen {{index}} pysähdyksen kesto valitsin","minute-short":"min","remove-via-button-label":"Poista välipiste {{index}}","swap-order-button-label":"Käännä reitin suunta vastakkaiseksi","via-point":"Välipiste","via-point-index":"Välipiste {{index}}","viapoint-slack-amount":"Pysähdyksen kesto"}},pl:{translation:{"add-via-button-label":"Dodaj punkt pośredni","add-via-duration-button-label":"Wybierz czas postoju dla punktu {{index}}","add-via-duration-button-label-close":"Zamknij wybornik czasu postoju w punkcie {{index}}","add-via-duration-button-label-open":"Otwórz wybornik czasu postoju w punkcie {{index}}","minute-short":"min.","remove-via-button-label":"Usuń punkt pośredni {{index}}","swap-order-button-label":"Odwróć początek i cel","via-point":"Punkt pośredni","via-point-index":"Punkt pośredni {{index}}","viapoint-slack-amount":"Czas postoju"}},sv:{translation:{"add-via-button-label":"Lägg till viapunkt","add-via-duration-button-label":"Ställ in varaktighet för viapunkten {{index}}","add-via-duration-button-label-close":"Stäng väljaren för varaktighet vid via-punkten {{index}}","add-via-duration-button-label-open":"Öppna väljaren för varaktighet vid via-punkten {{index}}","minute-short":"min","remove-via-button-label":"Ta bort viapunkt {{index}}","swap-order-button-label":"Sväng ruttens riktning till den motsatta","via-point":"Via punkt","via-point-index":"Via punkt {{index}}","viapoint-slack-amount":"Stoppets varaktighet"}}},defaultNS:"translation",react:{useSuspense:!0}});A.init();var R={"autosuggest-panel":"styles_autosuggest-panel__OaGWx","autosuggest-searchpanel-text":"styles_autosuggest-searchpanel-text__K2Sud","origin-input-container":"styles_origin-input-container__J-Iva","destination-input-container":"styles_destination-input-container__Q-nKR",row:"styles_row__AJFl2","viapoints-container":"styles_viapoints-container__S9HPW","viapoint-container":"styles_viapoint-container__Ev7XS","light-gray-background":"styles_light-gray-background__DO6vl","viapoint-before":"styles_viapoint-before__O0but","viapoint-input-container":"styles_viapoint-input-container__m84pk","viapoint-1":"styles_viapoint-1__-L3YV",viapoint:"styles_viapoint__l7OQr","viapoint-2":"styles_viapoint-2__nbTQE","viapoint-3":"styles_viapoint-3__euAwt","viapoint-4":"styles_viapoint-4__zT4lg","viapoint-5":"styles_viapoint-5__Nv3uU","viapoint-slack-time":"styles_viapoint-slack-time__RF3rg","select-wrapper":"styles_select-wrapper__ZbWuX","via-point-button-container":"styles_via-point-button-container__Oxyk8","input-viapoint-slack-container":"styles_input-viapoint-slack-container__4T7LG","itinerary-search-control":"styles_itinerary-search-control__9A4Y-",opposite:"styles_opposite__aI-Yn","add-via-point":"styles_add-via-point__q5tPF","add-via-point-slack":"styles_add-via-point-slack__aYNIN","remove-via-point":"styles_remove-via-point__1ys9T","combobox-icon":"styles_combobox-icon__s8Fqp","time-input-icon":"styles_time-input-icon__4xP1Q","rectangle-container":"styles_rectangle-container__kXQDW",rectangle:"styles_rectangle__1ryOy","search-panel-whitespace":"styles_search-panel-whitespace__YsiJN"};x(".styles_autosuggest-panel__OaGWx {\n width: 100%;\n}\n\n.styles_autosuggest-searchpanel-text__K2Sud {\n font-size: 24px;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.8px;\n color: #333;\n line-height: 1;\n margin-bottom: 17px;\n margin-top: unset;\n}\n@media screen and (min-width: 768px) {\n .styles_autosuggest-searchpanel-text__K2Sud {\n letter-spacing: -0.8px;\n line-height: 27px;\n margin-bottom: 21px;\n }\n}\n\n.styles_origin-input-container__J-Iva,\n.styles_destination-input-container__Q-nKR {\n display: flex;\n flex: 1 0 100%;\n}\n.styles_origin-input-container__J-Iva input[type=text],\n.styles_destination-input-container__Q-nKR input[type=text] {\n margin: 0;\n}\n\n.styles_row__AJFl2 {\n display: flex;\n flex-direction: row;\n}\n\n.styles_viapoints-container__S9HPW {\n display: flex;\n flex-direction: column;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS {\n display: flex;\n flex: 1 0 100%;\n min-height: 50px;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS:first-child {\n margin-top: 6px;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS:not(:first-child) {\n margin-top: 3px;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS:last-child {\n margin-bottom: 6px;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl {\n display: flex;\n padding: 3px 0;\n flex-direction: column;\n background: #f2f5f7;\n border-radius: 5px;\n width: 100%;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-before__O0but {\n display: flex;\n min-width: 27px;\n justify-content: center;\n align-items: center;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-before__O0but svg {\n fill: #888;\n height: 20px;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-input-container__m84pk {\n display: flex;\n align-items: center;\n width: 100%;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-input-container__m84pk input[type=text] {\n margin: 0;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-input-container__m84pk.styles_viapoint-1__-L3YV > div.styles_viapoint__l7OQr {\n z-index: 15;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-input-container__m84pk.styles_viapoint-2__nbTQE > div.styles_viapoint__l7OQr {\n z-index: 14;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-input-container__m84pk.styles_viapoint-3__euAwt > div.styles_viapoint__l7OQr {\n z-index: 13;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-input-container__m84pk.styles_viapoint-4__zT4lg > div.styles_viapoint__l7OQr {\n z-index: 12;\n}\n.styles_viapoints-container__S9HPW .styles_viapoint-container__Ev7XS .styles_light-gray-background__DO6vl .styles_viapoint-input-container__m84pk.styles_viapoint-5__Nv3uU > div.styles_viapoint__l7OQr {\n z-index: 11;\n}\n\n.styles_viapoint-slack-time__RF3rg {\n font-size: 13px;\n font-weight: normal;\n letter-spacing: -0.36px;\n color: #333;\n padding-left: 27px;\n padding-top: 12px;\n padding-bottom: 10px;\n}\n\n.styles_select-wrapper__ZbWuX {\n display: flex;\n height: 50px;\n margin-top: 9px;\n padding-left: 27px;\n padding-right: 47px;\n}\n\n.styles_via-point-button-container__Oxyk8 {\n display: flex;\n}\n.styles_via-point-button-container__Oxyk8 > div:nth-child(1) {\n order: 1;\n border-left: none;\n}\n.styles_via-point-button-container__Oxyk8 > div:nth-child(2) {\n order: 2;\n border-left: 1px solid rgba(151, 151, 151, 0.2);\n}\n\n.styles_input-viapoint-slack-container__4T7LG {\n display: flex;\n flex-direction: column;\n}\n\n.styles_itinerary-search-control__9A4Y- {\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n max-height: 50px;\n min-width: var(--width);\n}\n.styles_itinerary-search-control__9A4Y- + .styles_itinerary-search-control__9A4Y- {\n border-left: 1px solid rgba(151, 151, 151, 0.2);\n}\n.styles_itinerary-search-control__9A4Y- .styles_opposite__aI-Yn {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n min-width: 40px;\n cursor: pointer;\n}\n.styles_itinerary-search-control__9A4Y- .styles_opposite__aI-Yn svg {\n width: 19px;\n height: 17px;\n}\n.styles_itinerary-search-control__9A4Y- .styles_add-via-point__q5tPF {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n min-width: 40px;\n cursor: pointer;\n}\n.styles_itinerary-search-control__9A4Y- .styles_add-via-point__q5tPF svg {\n width: 20px;\n height: 22px;\n}\n.styles_itinerary-search-control__9A4Y- .styles_add-via-point-slack__aYNIN {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n min-width: 47px;\n cursor: pointer;\n}\n.styles_itinerary-search-control__9A4Y- .styles_add-via-point-slack__aYNIN svg {\n width: 18px;\n height: 19px;\n}\n.styles_itinerary-search-control__9A4Y- .styles_remove-via-point__1ys9T {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n max-height: 44px;\n min-width: 40px;\n cursor: pointer;\n}\n.styles_itinerary-search-control__9A4Y- .styles_remove-via-point__1ys9T svg {\n width: 14px;\n height: 14px;\n}\n\n.styles_combobox-icon__s8Fqp {\n color: var(--color);\n border-left: solid #888 1px;\n height: 35px;\n}\n.styles_combobox-icon__s8Fqp.styles_time-input-icon__4xP1Q {\n padding: 9px 13px 0 13px;\n}\n.styles_combobox-icon__s8Fqp.styles_time-input-icon__4xP1Q svg {\n width: 18px;\n height: 19px;\n}\n\n.styles_rectangle-container__kXQDW {\n display: block;\n position: relative;\n height: 9px;\n z-index: 19;\n}\n.styles_rectangle-container__kXQDW .styles_rectangle__1ryOy {\n position: absolute;\n width: 4px;\n height: 25px;\n border-radius: 2px;\n background-color: #ddd;\n margin-left: 25px;\n margin-top: -9px;\n}\n\n.styles_search-panel-whitespace__YsiJN {\n min-width: 40px;\n}");const I=["children","className","enabled","onClick","onKeyPress","wide"],j=()=>({}),q=e=>{if(void 0===e||f.default(e))return!0;const t=Object.keys(e);return 1===t.length||2===t.length&&t.includes("locationSlack")},T=e=>{let{children:t,className:n,enabled:i,onClick:a,onKeyPress:o,wide:s}=e,l=function(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;n[i]=e[i]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,I);return h.default.createElement("div",{className:R["itinerary-search-control"],style:{"--width":s?"47px":"40px"}},a&&i&&h.default.createElement("div",Object.assign({},l,{className:n,onClick:a,onKeyPress:o,role:"button",tabIndex:"0"}),t))},z=(e,t,n=!1)=>{const i=e.indexOf(t);return i>-1&&e.splice(i,1),n?e.map(e=>e>t?e-1:e):e},W=e=>{const t=e&&(e.key||e.which||e.keyCode)||"";return!(!t||![13," ","Spacebar"].concat([32,"Enter"]).includes(t))&&(e.preventDefault(),!0)},Y=e=>e&&e.address||e&&e.gps&&e.ready&&"Nykyinen sijainti"||"",H=e=>e&&!0===e.gps?"position":"location";"production"!==process.env.NODE_ENV&&(T.propTypes={children:_.default.node,className:_.default.string.isRequired,enabled:_.default.bool.isRequired,onClick:_.default.func.isRequired,onKeyPress:_.default.func.isRequired,wide:_.default.bool}),T.defaultProps={children:void 0,wide:!1};const L="production"!==process.env.NODE_ENV?_.default.shape({address:_.default.string,lat:_.default.number,lon:_.default.number,locationSlack:_.default.number}):{};class M extends h.default.Component{constructor(e){super(e),b(this,"storeReference",e=>{this.setState(t=>({refs:[...t.refs,e]}))}),b(this,"handleFocusChange",()=>{const{destination:e}=this.props;e&&e.lat||this.state.refs[1].focus()}),b(this,"updateViaPoints",e=>{0!==e.length?this.props.updateViaPoints(e.filter(e=>!q(e))):this.props.updateViaPoints([])}),b(this,"handleToggleViaPointSlackClick",e=>{const{activeSlackInputs:t}=this.state;this.setState({activeSlackInputs:t.includes(e)?z(t,e):t.concat([e])})}),b(this,"handleViaPointSlackTimeSelected",(e,t)=>{this.props.addAnalyticsEvent&&this.props.addAnalyticsEvent({action:"EditViaPointStopDuration",category:"ItinerarySettings",name:e/60});const{viaPoints:n}=this.props;n[t].locationSlack=Number.parseInt(e,10),this.updateViaPoints(n)}),b(this,"handleViaPointLocationSelected",(e,t)=>{this.props.handleViaPointLocationSelected(e,t)}),b(this,"handleRemoveViaPointClick",e=>{this.props.addAnalyticsEvent&&this.props.addAnalyticsEvent({action:"RemoveJourneyViaPoint",category:"ItinerarySettings",name:null});const{activeSlackInputs:t}=this.state,{viaPoints:n}=this.props;n.splice(e,1),this.setState({activeSlackInputs:z(t,e,!0)},()=>this.updateViaPoints(n))}),b(this,"handleAddViaPointClick",()=>{this.props.addAnalyticsEvent&&this.props.addAnalyticsEvent({action:"AddJourneyViaPoint",category:"ItinerarySettings",name:"QuickSettingsButton"});const{viaPoints:e}=this.props;e.push({}),this.setState(this.state)}),b(this,"handleSwapOrderClick",()=>{this.props.addAnalyticsEvent&&this.props.addAnalyticsEvent({action:"SwitchJourneyStartAndEndPointOrder",category:"ItinerarySettings",name:null});const{viaPoints:e}=this.props;e.reverse(),this.props.swapOrder()}),b(this,"getSlackDisplay",e=>`${e/60} ${this.props.t("minute-short",{lng:this.props.lang})}`),this.state={activeSlackInputs:[],refs:[]}}render(){const{origin:e,searchPanelText:t,searchContext:n,disableAutoFocus:i,viaPoints:a,originMobileLabel:s,destinationMobileLabel:l,fontWeights:r,onFocusChange:d,showSwapControl:c,showViapointControl:p,t:_,lang:f}=this.props,{primary:m}=this.props.colors,{activeSlackInputs:y}=this.state,b=(e=>{const t=[];for(let n=0;n<=9;n++){const i=10*n;t.push({displayName:`${i} ${e("minute-short")}`,value:60*i})}return t})(_),x=(e,t=0)=>e&&e.locationSlack||t,S=e=>y.includes(e);return h.default.createElement("div",{className:u.default(R["autosuggest-panel"],this.props.isMobile&&"small"),style:{"--color":m,"--font-weight-medium":r.medium}}," ",t?h.default.createElement("div",null,h.default.createElement("h1",{className:R["autosuggest-searchpanel-text"]}," ",t)):null,h.default.createElement("div",{className:R["origin-input-container"]},h.default.createElement(g.default,{appElement:this.props.appElement,icon:"originEllipse",id:"origin",autoFocus:!0!==i&&(!this.props.isMobile&&!e.lat),storeRef:this.storeReference,refPoint:this.props.refPoint,className:H(e),placeholder:this.props.originPlaceHolder,value:Y(e),searchContext:n,getAutoSuggestIcons:this.props.getAutoSuggestIcons,onSelect:this.props.onSelect,onClear:this.props.onClear,focusChange:d||this.handleFocusChange,lang:this.props.lang,sources:this.props.sources,targets:this.props.targets,filterResults:this.props.filterResults,isMobile:this.props.isMobile,colors:this.props.colors,mobileLabel:s,fontWeights:this.props.fontWeights,modeSet:this.props.modeSet,showScroll:this.props.showScroll,isEmbedded:this.props.isEmbedded}),(c||p)&&h.default.createElement(T,{className:R.opposite,enabled:c,onClick:()=>this.handleSwapOrderClick(),onKeyPress:e=>W(e)&&this.handleSwapOrderClick(),"aria-label":_("swap-order-button-label",{lng:f})},h.default.createElement(v.default,{img:"opposite",color:m}))),0===a.length&&h.default.createElement("div",{className:R["rectangle-container"]},h.default.createElement("div",{className:R.rectangle})),h.default.createElement(o.ReactSortable,{className:R["viapoints-container"],list:a,handle:`.${R["viapoint-before"]}`,animation:200,disabled:a.length<=1,setList:e=>{const t=e.filter(e=>!q(e));t.length>0&&this.props.updateViaPoints(t)}},a.map((e,t)=>h.default.createElement("div",{className:u.default(R["viapoint-container"]),key:`viapoint-${t}`},h.default.createElement("div",{className:R["light-gray-background"]},h.default.createElement("div",{className:R.row},h.default.createElement("div",{className:R["viapoint-before"],style:a.length>1?{cursor:"move"}:{}},a.length>1&&h.default.createElement(v.default,{img:"ellipsis",rotate:90,color:m})),h.default.createElement("div",{className:`${R["viapoint-input-container"]} ${R[`viapoint-${t+1}`]}`},h.default.createElement(g.default,{appElement:this.props.appElement,icon:"mapMarker",id:"via-point",ariaLabel:_("via-point-index",{index:t+1,lng:f}),autoFocus:!0!==i&&!this.props.isMobile,placeholder:"via-point",className:"viapoint",searchContext:n,refPoint:this.props.refPoint,value:e&&e.address||"",onSelect:this.props.onSelect,onClear:this.props.onClear,handleViaPoints:e=>this.handleViaPointLocationSelected(e,t),lang:this.props.lang,sources:this.props.sources,targets:this.props.targets,filterResults:this.props.filterResults,getAutoSuggestIcons:this.props.getAutoSuggestIcons,isMobile:this.props.isMobile,fontWeights:this.props.fontWeights,modeSet:this.props.modeSet,colors:this.props.colors,showScroll:this.props.showScroll})),this.props.showSlackControl&&h.default.createElement(T,{className:R["add-via-point-slack"],enabled:this.props.showViapointControl,onClick:()=>this.handleToggleViaPointSlackClick(t),onKeyPress:e=>W(e)&&this.handleToggleViaPointSlackClick(t),"aria-label":_(S(t)?"add-via-duration-button-label-open":"add-via-duration-button-label-close",{index:t+1,lng:f}),wide:!0},h.default.createElement(v.default,{img:"time",color:m}))),!S(t)&&a[t]&&a[t].locationSlack>0&&h.default.createElement("span",{className:R["viapoint-slack-time"]},`${_("viapoint-slack-amount",{lng:f})}: ${this.getSlackDisplay(a[t].locationSlack)}`),h.default.createElement("div",{className:u.default(R["input-viapoint-slack-container"],!S(t)&&"collapsed")},h.default.createElement("div",{className:R["select-wrapper"]},h.default.createElement(V,{id:`viapoint-slack-${t}`,label:_("viapoint-slack-amount",{lng:f}),options:b,value:x(a[t]),viaPointIndex:t,icon:h.default.createElement("span",{className:`${R["combobox-icon"]} ${R["time-input-icon"]}`},h.default.createElement(v.default,{img:"time",color:m})),onSlackTimeSelected:this.handleViaPointSlackTimeSelected})))),h.default.createElement(T,{className:R["remove-via-point"],enabled:this.props.showViapointControl,onClick:()=>this.handleRemoveViaPointClick(t),onKeyPress:e=>W(e)&&this.handleRemoveViaPointClick(t),"aria-label":_("remove-via-button-label",{index:t+1,lng:f})},h.default.createElement(v.default,{img:"trash",color:m}))))),h.default.createElement("div",{className:R["destination-input-container"]},h.default.createElement(g.default,{appElement:this.props.appElement,icon:"mapMarker",id:"destination",autoFocus:!0!==i&&(!this.props.isMobile&&!Number.isNaN(e.lat)),storeRef:this.storeReference,placeholder:this.props.destinationPlaceHolder,className:H(this.props.destination),getAutoSuggestIcons:this.props.getAutoSuggestIcons,searchContext:n,onSelect:this.props.onSelect,onClear:this.props.onClear,refPoint:this.props.refPoint,value:Y(this.props.destination),lang:this.props.lang,sources:this.props.sources,targets:this.props.targets,filterResults:this.props.filterResults,isMobile:this.props.isMobile,mobileLabel:l,fontWeights:this.props.fontWeights,modeSet:this.props.modeSet,colors:this.props.colors,showScroll:this.props.showScroll,isEmbedded:this.props.isEmbedded}),(c||p)&&h.default.createElement(T,{className:u.default(R["add-via-point"],R.more,a.length>4&&"collapsed"),enabled:p&&0===a.length,onClick:()=>this.handleAddViaPointClick(),onKeyPress:e=>W(e)&&this.handleAddViaPointClick(),"aria-label":_("add-via-button-label",{lng:f})},h.default.createElement(v.default,{img:"viapoint",width:1.25,height:1.375,color:m}))))}}b(M,"defaultProps",{origin:void 0,destination:void 0,viaPoints:[],originPlaceHolder:"give-origin",destinationPlaceHolder:"give-destination",swapOrder:void 0,updateViaPoints:()=>{},searchPanelText:void 0,sources:[],targets:[],filterResults:void 0,onClear:void 0,getAutoSuggestIcons:void 0,refPoint:void 0,addAnalyticsEvent:void 0,disableAutoFocus:!1,isMobile:!1,handleViaPointLocationSelected:void 0,originMobileLabel:null,destinationMobileLabel:null,modeSet:void 0,colors:l.defaultColors,fontWeights:{medium:500},showScroll:!1,onFocusChange:void 0,isEmbedded:!1,showSwapControl:!1,showViapointControl:!1,showSlackControl:!1}),"production"!==process.env.NODE_ENV&&(M.propTypes={appElement:_.default.string.isRequired,origin:L,destination:L,originPlaceHolder:_.default.string,destinationPlaceHolder:_.default.string,viaPoints:_.default.arrayOf(L),updateViaPoints:_.default.func,handleViaPointLocationSelected:_.default.func,swapOrder:_.default.func,searchPanelText:_.default.string,searchContext:_.default.shape({URL_PELIAS:_.default.string}).isRequired,onSelect:_.default.func.isRequired,onClear:_.default.func,addAnalyticsEvent:_.default.func,lang:_.default.string.isRequired,disableAutoFocus:_.default.bool,sources:_.default.arrayOf(_.default.string),targets:_.default.arrayOf(_.default.string),filterResults:_.default.func,isMobile:_.default.bool,originMobileLabel:_.default.string,destinationMobileLabel:_.default.string,refPoint:L,modeSet:_.default.string,colors:_.default.objectOf(_.default.string),getAutoSuggestIcons:_.default.objectOf(_.default.func),fontWeights:_.default.shape({medium:_.default.number}),showScroll:_.default.bool,onFocusChange:_.default.func,isEmbedded:_.default.bool,showSwapControl:_.default.bool,showViapointControl:_.default.bool,showSlackControl:_.default.bool,t:_.default.func.isRequired});const D=a.withTranslation()(M);e.default=e=>h.default.createElement(a.I18nextProvider,{i18n:A},h.default.createElement(D,e)),e.getEmptyViaPointPlaceHolder=j,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { withTranslation, I18nextProvider } from 'react-i18next';
|
|
5
|
+
import { ReactSortable } from 'react-sortablejs';
|
|
6
|
+
import DTAutoSuggest from '@digitransit-component/digitransit-component-autosuggest';
|
|
7
|
+
import Icon, { defaultColors } from '@digitransit-component/digitransit-component-icon';
|
|
8
|
+
import isEmpty from 'lodash/isEmpty.js';
|
|
9
|
+
import { useSelect } from 'downshift';
|
|
10
|
+
import { createInstance } from 'i18next';
|
|
11
|
+
|
|
12
|
+
function _typeof(o) {
|
|
13
|
+
"@babel/helpers - typeof";
|
|
14
|
+
|
|
15
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
16
|
+
return typeof o;
|
|
17
|
+
} : function (o) {
|
|
18
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
19
|
+
}, _typeof(o);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function toPrimitive(t, r) {
|
|
23
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
24
|
+
var e = t[Symbol.toPrimitive];
|
|
25
|
+
if (void 0 !== e) {
|
|
26
|
+
var i = e.call(t, r);
|
|
27
|
+
if ("object" != _typeof(i)) return i;
|
|
28
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
29
|
+
}
|
|
30
|
+
return ("string" === r ? String : Number)(t);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function toPropertyKey(t) {
|
|
34
|
+
var i = toPrimitive(t, "string");
|
|
35
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _defineProperty(e, r, t) {
|
|
39
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
40
|
+
value: t,
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true
|
|
44
|
+
}) : e[r] = t, e;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
48
|
+
if (null == r) return {};
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
51
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
52
|
+
t[n] = r[n];
|
|
53
|
+
}
|
|
54
|
+
return t;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _objectWithoutProperties(e, t) {
|
|
58
|
+
if (null == e) return {};
|
|
59
|
+
var o,
|
|
60
|
+
r,
|
|
61
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
62
|
+
if (Object.getOwnPropertySymbols) {
|
|
63
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
64
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
65
|
+
}
|
|
66
|
+
return i;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function styleInject(css, ref) {
|
|
70
|
+
if ( ref === void 0 ) ref = {};
|
|
71
|
+
var insertAt = ref.insertAt;
|
|
72
|
+
|
|
73
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
74
|
+
|
|
75
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
76
|
+
var style = document.createElement('style');
|
|
77
|
+
style.type = 'text/css';
|
|
78
|
+
|
|
79
|
+
if (insertAt === 'top') {
|
|
80
|
+
if (head.firstChild) {
|
|
81
|
+
head.insertBefore(style, head.firstChild);
|
|
82
|
+
} else {
|
|
83
|
+
head.appendChild(style);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
head.appendChild(style);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (style.styleSheet) {
|
|
90
|
+
style.styleSheet.cssText = css;
|
|
91
|
+
} else {
|
|
92
|
+
style.appendChild(document.createTextNode(css));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var css_248z$1 = ".select_combobox-container__l-gXK {\n background-color: #fff;\n border: solid #888 1px;\n display: flex;\n align-items: center;\n border-radius: 5px;\n height: 50px;\n justify-content: space-between;\n flex-grow: 1;\n}\n.select_combobox-container__l-gXK:focus-within {\n border-color: #007ac9;\n}\n.select_combobox-container__l-gXK .select_left-column__NCDpJ {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n\n.select_combobox-label__QYe0V {\n font-size: 12px;\n line-height: 20px;\n color: #666;\n letter-spacing: -0.48px;\n margin-left: 12px;\n margin-top: 4px;\n}\n\n.select_container__U5yMR {\n position: relative;\n width: 100%;\n height: 100%;\n}\n.select_container__U5yMR > div {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n height: 100%;\n cursor: pointer;\n}\n.select_container__U5yMR .select_suggestion__7in7q {\n font-size: 15px;\n line-height: 49px;\n height: 50px;\n padding: 0 0 0 12px;\n letter-spacing: -0.6px;\n color: #333;\n font-weight: 500;\n}\n.select_container__U5yMR .select_suggestionHighlighted__HV-5T {\n font-size: 15px;\n font-weight: 500;\n background: #f2f5f7;\n}\n.select_container__U5yMR .select_suggestionsContainerOpen__SzPE6 {\n position: absolute;\n background-color: #fff;\n z-index: 20;\n max-height: 250px;\n overflow-x: hidden;\n overflow-y: scroll;\n border-radius: 5px;\n box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.06);\n border: 1px rgba(0, 0, 0, 0.1) solid;\n top: calc(100% + 4px);\n left: 0;\n width: 100%;\n list-style-type: none;\n padding: 0;\n margin: 0;\n}\n.select_container__U5yMR .select_suggestionsContainerOpen__SzPE6 ul {\n padding: 0;\n margin: 0;\n}\n.select_container__U5yMR .select_suggestionsContainerOpen__SzPE6 li:not(:last-child) {\n border-bottom: 1px solid #ddd;\n}\n.select_container__U5yMR .select_input__tiwn5 {\n appearance: none;\n margin: -4px 0 0 0;\n padding-left: 12px;\n border: none;\n height: 26px;\n}\n.select_container__U5yMR .select_input__tiwn5:focus {\n outline: none;\n border: none;\n box-shadow: none;\n background: #fff;\n}\n.select_container__U5yMR .select_input__tiwn5:read-only {\n cursor: pointer;\n background: #fff;\n}\n.select_container__U5yMR .select_input__tiwn5 {\n background: #fff;\n font-weight: 500;\n box-shadow: none;\n font-size: 15px;\n font-stretch: normal;\n font-style: normal;\n line-height: 1.33;\n letter-spacing: -0.6px;\n color: #333;\n}";
|
|
97
|
+
var styles$1 = {"combobox-container":"select_combobox-container__l-gXK","left-column":"select_left-column__NCDpJ","combobox-label":"select_combobox-label__QYe0V","container":"select_container__U5yMR","suggestion":"select_suggestion__7in7q","suggestionHighlighted":"select_suggestionHighlighted__HV-5T","suggestionsContainerOpen":"select_suggestionsContainerOpen__SzPE6","input":"select_input__tiwn5"};
|
|
98
|
+
styleInject(css_248z$1);
|
|
99
|
+
|
|
100
|
+
const Select = ({
|
|
101
|
+
value,
|
|
102
|
+
options,
|
|
103
|
+
onSlackTimeSelected,
|
|
104
|
+
viaPointIndex,
|
|
105
|
+
id,
|
|
106
|
+
label,
|
|
107
|
+
icon
|
|
108
|
+
}) => {
|
|
109
|
+
const labelId = `${id}-label`;
|
|
110
|
+
const selectedItem = options.find(option => option.value === value);
|
|
111
|
+
const {
|
|
112
|
+
isOpen,
|
|
113
|
+
getToggleButtonProps,
|
|
114
|
+
getMenuProps,
|
|
115
|
+
getItemProps,
|
|
116
|
+
getLabelProps,
|
|
117
|
+
highlightedIndex
|
|
118
|
+
} = useSelect({
|
|
119
|
+
selectedItem,
|
|
120
|
+
items: options,
|
|
121
|
+
labelId,
|
|
122
|
+
id,
|
|
123
|
+
itemToString: item => item.displayName,
|
|
124
|
+
onSelectedItemChange: ({
|
|
125
|
+
selectedItem: newItem
|
|
126
|
+
}) => {
|
|
127
|
+
onSlackTimeSelected(newItem.value, viaPointIndex);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: styles$1['combobox-container']
|
|
132
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
className: styles$1.container
|
|
134
|
+
}, /*#__PURE__*/React.createElement("div", getToggleButtonProps(), /*#__PURE__*/React.createElement("span", {
|
|
135
|
+
className: styles$1['left-column']
|
|
136
|
+
}, /*#__PURE__*/React.createElement("label", Object.assign({}, getLabelProps(), {
|
|
137
|
+
className: styles$1['combobox-label']
|
|
138
|
+
}), label), /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
className: styles$1.input
|
|
140
|
+
}, /*#__PURE__*/React.createElement("span", null, selectedItem.displayName))), icon), /*#__PURE__*/React.createElement("ul", Object.assign({
|
|
141
|
+
className: cx(styles$1.suggestionsContainerOpen, !isOpen && 'hidden')
|
|
142
|
+
}, getMenuProps()), isOpen && options.map((option, index) => /*#__PURE__*/React.createElement("li", Object.assign({
|
|
143
|
+
key: option.value,
|
|
144
|
+
className: cx(styles$1.suggestion, index === highlightedIndex && styles$1.suggestionHighlighted)
|
|
145
|
+
}, getItemProps({
|
|
146
|
+
index
|
|
147
|
+
})), /*#__PURE__*/React.createElement("span", null, option.displayName))))));
|
|
148
|
+
};
|
|
149
|
+
process.env.NODE_ENV !== "production" ? Select.propTypes = {
|
|
150
|
+
value: PropTypes.number.isRequired,
|
|
151
|
+
onSlackTimeSelected: PropTypes.func.isRequired,
|
|
152
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
153
|
+
displayName: PropTypes.string.isRequired,
|
|
154
|
+
value: PropTypes.number.isRequired
|
|
155
|
+
}).isRequired).isRequired,
|
|
156
|
+
id: PropTypes.string.isRequired,
|
|
157
|
+
label: PropTypes.node.isRequired,
|
|
158
|
+
icon: PropTypes.node.isRequired,
|
|
159
|
+
viaPointIndex: PropTypes.number.isRequired
|
|
160
|
+
} : void 0;
|
|
161
|
+
|
|
162
|
+
const translations = {
|
|
163
|
+
de: {
|
|
164
|
+
translation: {
|
|
165
|
+
'add-via-button-label': 'Füge Zwischenziel hinzu',
|
|
166
|
+
'add-via-duration-button-label': 'Setze Umsteigezeit für Zwischenziel {{index}}',
|
|
167
|
+
'add-via-duration-button-label-close': 'Schließe Umsteigezeit-Auswahl für Zwischenziel {{index}}',
|
|
168
|
+
'add-via-duration-button-label-open': 'Öffne Umsteigezeit-Auswahl für Zwischenziel {{index}}',
|
|
169
|
+
'minute-short': 'min',
|
|
170
|
+
'remove-via-button-label': 'Entferne Zwischenziel {{index}}',
|
|
171
|
+
'swap-order-button-label': 'Tausche Start mit Ziel',
|
|
172
|
+
'via-point': 'Zwischenziel',
|
|
173
|
+
'via-point-index': 'Zwischenziel {{index}}',
|
|
174
|
+
'viapoint-slack-amount': 'Umsteigezeit'
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
en: {
|
|
178
|
+
translation: {
|
|
179
|
+
'add-via-button-label': 'Add via point',
|
|
180
|
+
'add-via-duration-button-label': 'Set stop duration at via point {{index}}',
|
|
181
|
+
'add-via-duration-button-label-close': 'Close stop duration selector at via point {{index}}',
|
|
182
|
+
'add-via-duration-button-label-open': 'Open stop duration selector at via point {{index}}',
|
|
183
|
+
'minute-short': 'min',
|
|
184
|
+
'remove-via-button-label': 'Remove via point {{index}}',
|
|
185
|
+
'swap-order-button-label': 'Reverse origin and destination',
|
|
186
|
+
'via-point': 'Via point',
|
|
187
|
+
'via-point-index': 'Via point {{index}}',
|
|
188
|
+
'viapoint-slack-amount': 'Stop duration'
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
fi: {
|
|
192
|
+
translation: {
|
|
193
|
+
'add-via-button-label': 'Lisää välipiste',
|
|
194
|
+
'add-via-duration-button-label': 'Aseta välipisteelle {{index}} pysähdyksen kesto',
|
|
195
|
+
'add-via-duration-button-label-close': 'Avaa välipisteen {{index}} pysähdyksen kesto valitsin',
|
|
196
|
+
'add-via-duration-button-label-open': 'Sulje välipisteen {{index}} pysähdyksen kesto valitsin',
|
|
197
|
+
'minute-short': 'min',
|
|
198
|
+
'remove-via-button-label': 'Poista välipiste {{index}}',
|
|
199
|
+
'swap-order-button-label': 'Käännä reitin suunta vastakkaiseksi',
|
|
200
|
+
'via-point': 'Välipiste',
|
|
201
|
+
'via-point-index': 'Välipiste {{index}}',
|
|
202
|
+
'viapoint-slack-amount': 'Pysähdyksen kesto'
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
pl: {
|
|
206
|
+
translation: {
|
|
207
|
+
'add-via-button-label': 'Dodaj punkt pośredni',
|
|
208
|
+
'add-via-duration-button-label': 'Wybierz czas postoju dla punktu {{index}}',
|
|
209
|
+
'add-via-duration-button-label-close': 'Zamknij wybornik czasu postoju w punkcie {{index}}',
|
|
210
|
+
'add-via-duration-button-label-open': 'Otwórz wybornik czasu postoju w punkcie {{index}}',
|
|
211
|
+
'minute-short': 'min.',
|
|
212
|
+
'remove-via-button-label': 'Usuń punkt pośredni {{index}}',
|
|
213
|
+
'swap-order-button-label': 'Odwróć początek i cel',
|
|
214
|
+
'via-point': 'Punkt pośredni',
|
|
215
|
+
'via-point-index': 'Punkt pośredni {{index}}',
|
|
216
|
+
'viapoint-slack-amount': 'Czas postoju'
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
sv: {
|
|
220
|
+
translation: {
|
|
221
|
+
'add-via-button-label': 'Lägg till viapunkt',
|
|
222
|
+
'add-via-duration-button-label': 'Ställ in varaktighet för viapunkten {{index}}',
|
|
223
|
+
'add-via-duration-button-label-close': 'Stäng väljaren för varaktighet vid via-punkten {{index}}',
|
|
224
|
+
'add-via-duration-button-label-open': 'Öppna väljaren för varaktighet vid via-punkten {{index}}',
|
|
225
|
+
'minute-short': 'min',
|
|
226
|
+
'remove-via-button-label': 'Ta bort viapunkt {{index}}',
|
|
227
|
+
'swap-order-button-label': 'Sväng ruttens riktning till den motsatta',
|
|
228
|
+
'via-point': 'Via punkt',
|
|
229
|
+
'via-point-index': 'Via punkt {{index}}',
|
|
230
|
+
'viapoint-slack-amount': 'Stoppets varaktighet'
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const i18n = createInstance({
|
|
236
|
+
fallbackLng: 'fi',
|
|
237
|
+
// debug: true,
|
|
238
|
+
resources: translations,
|
|
239
|
+
defaultNS: 'translation',
|
|
240
|
+
react: {
|
|
241
|
+
useSuspense: true
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
i18n.init();
|
|
245
|
+
|
|
246
|
+
var css_248z = ".styles_autosuggest-panel__GEaoJ {\n width: 100%;\n}\n\n.styles_autosuggest-searchpanel-text__7O850 {\n font-size: 24px;\n font-weight: var(--font-weight-medium);\n letter-spacing: -0.8px;\n color: #333;\n line-height: 1;\n margin-bottom: 17px;\n margin-top: unset;\n}\n@media screen and (min-width: 768px) {\n .styles_autosuggest-searchpanel-text__7O850 {\n letter-spacing: -0.8px;\n line-height: 27px;\n margin-bottom: 21px;\n }\n}\n\n.styles_origin-input-container__yfozN,\n.styles_destination-input-container__kJPky {\n display: flex;\n flex: 1 0 100%;\n}\n.styles_origin-input-container__yfozN input[type=text],\n.styles_destination-input-container__kJPky input[type=text] {\n margin: 0;\n}\n\n.styles_row__MvzsR {\n display: flex;\n flex-direction: row;\n}\n\n.styles_viapoints-container__fukkW {\n display: flex;\n flex-direction: column;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE {\n display: flex;\n flex: 1 0 100%;\n min-height: 50px;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE:first-child {\n margin-top: 6px;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE:not(:first-child) {\n margin-top: 3px;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE:last-child {\n margin-bottom: 6px;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM {\n display: flex;\n padding: 3px 0;\n flex-direction: column;\n background: #f2f5f7;\n border-radius: 5px;\n width: 100%;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-before__J1O3f {\n display: flex;\n min-width: 27px;\n justify-content: center;\n align-items: center;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-before__J1O3f svg {\n fill: #888;\n height: 20px;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-input-container__fEQi9 {\n display: flex;\n align-items: center;\n width: 100%;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-input-container__fEQi9 input[type=text] {\n margin: 0;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-input-container__fEQi9.styles_viapoint-1__s2wSB > div.styles_viapoint__UnOwm {\n z-index: 15;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-input-container__fEQi9.styles_viapoint-2__JNsq8 > div.styles_viapoint__UnOwm {\n z-index: 14;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-input-container__fEQi9.styles_viapoint-3__tv7Qy > div.styles_viapoint__UnOwm {\n z-index: 13;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-input-container__fEQi9.styles_viapoint-4__v0tfs > div.styles_viapoint__UnOwm {\n z-index: 12;\n}\n.styles_viapoints-container__fukkW .styles_viapoint-container__O-xAE .styles_light-gray-background__0vkzM .styles_viapoint-input-container__fEQi9.styles_viapoint-5__luT-- > div.styles_viapoint__UnOwm {\n z-index: 11;\n}\n\n.styles_viapoint-slack-time__dV527 {\n font-size: 13px;\n font-weight: normal;\n letter-spacing: -0.36px;\n color: #333;\n padding-left: 27px;\n padding-top: 12px;\n padding-bottom: 10px;\n}\n\n.styles_select-wrapper__zaWty {\n display: flex;\n height: 50px;\n margin-top: 9px;\n padding-left: 27px;\n padding-right: 47px;\n}\n\n.styles_via-point-button-container__kUBm7 {\n display: flex;\n}\n.styles_via-point-button-container__kUBm7 > div:nth-child(1) {\n order: 1;\n border-left: none;\n}\n.styles_via-point-button-container__kUBm7 > div:nth-child(2) {\n order: 2;\n border-left: 1px solid rgba(151, 151, 151, 0.2);\n}\n\n.styles_input-viapoint-slack-container__-LDqu {\n display: flex;\n flex-direction: column;\n}\n\n.styles_itinerary-search-control__1KyCb {\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n max-height: 50px;\n min-width: var(--width);\n}\n.styles_itinerary-search-control__1KyCb + .styles_itinerary-search-control__1KyCb {\n border-left: 1px solid rgba(151, 151, 151, 0.2);\n}\n.styles_itinerary-search-control__1KyCb .styles_opposite__BE7K1 {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n min-width: 40px;\n cursor: pointer;\n}\n.styles_itinerary-search-control__1KyCb .styles_opposite__BE7K1 svg {\n width: 19px;\n height: 17px;\n}\n.styles_itinerary-search-control__1KyCb .styles_add-via-point__7E6zU {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n min-width: 40px;\n cursor: pointer;\n}\n.styles_itinerary-search-control__1KyCb .styles_add-via-point__7E6zU svg {\n width: 20px;\n height: 22px;\n}\n.styles_itinerary-search-control__1KyCb .styles_add-via-point-slack__kddhr {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n min-width: 47px;\n cursor: pointer;\n}\n.styles_itinerary-search-control__1KyCb .styles_add-via-point-slack__kddhr svg {\n width: 18px;\n height: 19px;\n}\n.styles_itinerary-search-control__1KyCb .styles_remove-via-point__1oWx- {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n max-height: 44px;\n min-width: 40px;\n cursor: pointer;\n}\n.styles_itinerary-search-control__1KyCb .styles_remove-via-point__1oWx- svg {\n width: 14px;\n height: 14px;\n}\n\n.styles_combobox-icon__fhYvA {\n color: var(--color);\n border-left: solid #888 1px;\n height: 35px;\n}\n.styles_combobox-icon__fhYvA.styles_time-input-icon__L2TcV {\n padding: 9px 13px 0 13px;\n}\n.styles_combobox-icon__fhYvA.styles_time-input-icon__L2TcV svg {\n width: 18px;\n height: 19px;\n}\n\n.styles_rectangle-container__4Vtuo {\n display: block;\n position: relative;\n height: 9px;\n z-index: 19;\n}\n.styles_rectangle-container__4Vtuo .styles_rectangle__s-y7y {\n position: absolute;\n width: 4px;\n height: 25px;\n border-radius: 2px;\n background-color: #ddd;\n margin-left: 25px;\n margin-top: -9px;\n}\n\n.styles_search-panel-whitespace__RefGL {\n min-width: 40px;\n}";
|
|
247
|
+
var styles = {"autosuggest-panel":"styles_autosuggest-panel__GEaoJ","autosuggest-searchpanel-text":"styles_autosuggest-searchpanel-text__7O850","origin-input-container":"styles_origin-input-container__yfozN","destination-input-container":"styles_destination-input-container__kJPky","row":"styles_row__MvzsR","viapoints-container":"styles_viapoints-container__fukkW","viapoint-container":"styles_viapoint-container__O-xAE","light-gray-background":"styles_light-gray-background__0vkzM","viapoint-before":"styles_viapoint-before__J1O3f","viapoint-input-container":"styles_viapoint-input-container__fEQi9","viapoint-1":"styles_viapoint-1__s2wSB","viapoint":"styles_viapoint__UnOwm","viapoint-2":"styles_viapoint-2__JNsq8","viapoint-3":"styles_viapoint-3__tv7Qy","viapoint-4":"styles_viapoint-4__v0tfs","viapoint-5":"styles_viapoint-5__luT--","viapoint-slack-time":"styles_viapoint-slack-time__dV527","select-wrapper":"styles_select-wrapper__zaWty","via-point-button-container":"styles_via-point-button-container__kUBm7","input-viapoint-slack-container":"styles_input-viapoint-slack-container__-LDqu","itinerary-search-control":"styles_itinerary-search-control__1KyCb","opposite":"styles_opposite__BE7K1","add-via-point":"styles_add-via-point__7E6zU","add-via-point-slack":"styles_add-via-point-slack__kddhr","remove-via-point":"styles_remove-via-point__1oWx-","combobox-icon":"styles_combobox-icon__fhYvA","time-input-icon":"styles_time-input-icon__L2TcV","rectangle-container":"styles_rectangle-container__4Vtuo","rectangle":"styles_rectangle__s-y7y","search-panel-whitespace":"styles_search-panel-whitespace__RefGL"};
|
|
248
|
+
styleInject(css_248z);
|
|
249
|
+
|
|
250
|
+
const _excluded = ["children", "className", "enabled", "onClick", "onKeyPress", "wide"];
|
|
251
|
+
const getEmptyViaPointPlaceHolder = () => ({});
|
|
252
|
+
const isViaPointEmpty = viaPoint => {
|
|
253
|
+
if (viaPoint === undefined || isEmpty(viaPoint)) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
const keys = Object.keys(viaPoint);
|
|
257
|
+
return keys.length === 1 || keys.length === 2 && keys.includes('locationSlack');
|
|
258
|
+
};
|
|
259
|
+
const ItinerarySearchControl = _ref => {
|
|
260
|
+
let {
|
|
261
|
+
children,
|
|
262
|
+
className,
|
|
263
|
+
enabled,
|
|
264
|
+
onClick,
|
|
265
|
+
onKeyPress,
|
|
266
|
+
wide
|
|
267
|
+
} = _ref,
|
|
268
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
269
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
270
|
+
className: styles['itinerary-search-control'],
|
|
271
|
+
style: {
|
|
272
|
+
'--width': wide ? '47px' : '40px'
|
|
273
|
+
}
|
|
274
|
+
}, onClick && enabled && /*#__PURE__*/React.createElement("div", Object.assign({}, rest, {
|
|
275
|
+
className: className,
|
|
276
|
+
onClick: onClick,
|
|
277
|
+
onKeyPress: onKeyPress,
|
|
278
|
+
role: "button",
|
|
279
|
+
tabIndex: "0"
|
|
280
|
+
}), children));
|
|
281
|
+
};
|
|
282
|
+
const updateViaPointSlack = (activeViaPointSlacks, updatedViaPointIndex, viaPointRemoved = false) => {
|
|
283
|
+
const foundAtIndex = activeViaPointSlacks.indexOf(updatedViaPointIndex);
|
|
284
|
+
if (foundAtIndex > -1) {
|
|
285
|
+
activeViaPointSlacks.splice(foundAtIndex, 1);
|
|
286
|
+
}
|
|
287
|
+
return viaPointRemoved ? activeViaPointSlacks.map(value => value > updatedViaPointIndex ? value - 1 : value) : activeViaPointSlacks;
|
|
288
|
+
};
|
|
289
|
+
const isKeyboardSelectionEvent = event => {
|
|
290
|
+
const space = [13, ' ', 'Spacebar'];
|
|
291
|
+
const enter = [32, 'Enter'];
|
|
292
|
+
const key = event && (event.key || event.which || event.keyCode) || '';
|
|
293
|
+
if (!key || !space.concat(enter).includes(key)) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
event.preventDefault();
|
|
297
|
+
return true;
|
|
298
|
+
};
|
|
299
|
+
const value = location => location && location.address || location && location.gps && location.ready && 'Nykyinen sijainti' || '';
|
|
300
|
+
const getLocationType = location => location && location.gps === true ? 'position' : 'location';
|
|
301
|
+
const getSlackTimeOptions = t => {
|
|
302
|
+
const timeOptions = [];
|
|
303
|
+
for (let i = 0; i <= 9; i++) {
|
|
304
|
+
const valueInMinutes = i * 10;
|
|
305
|
+
timeOptions.push({
|
|
306
|
+
displayName: `${valueInMinutes} ${t('minute-short')}`,
|
|
307
|
+
value: valueInMinutes * 60
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return timeOptions;
|
|
311
|
+
};
|
|
312
|
+
process.env.NODE_ENV !== "production" ? ItinerarySearchControl.propTypes = {
|
|
313
|
+
children: PropTypes.node,
|
|
314
|
+
className: PropTypes.string.isRequired,
|
|
315
|
+
enabled: PropTypes.bool.isRequired,
|
|
316
|
+
onClick: PropTypes.func.isRequired,
|
|
317
|
+
onKeyPress: PropTypes.func.isRequired,
|
|
318
|
+
wide: PropTypes.bool
|
|
319
|
+
} : void 0;
|
|
320
|
+
ItinerarySearchControl.defaultProps = {
|
|
321
|
+
children: undefined,
|
|
322
|
+
wide: false
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Panel that renders two DTAutosuggest search fields, including viapoint handling
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* const searchContext = {
|
|
330
|
+
* isPeliasLocationAware: false // true / false does Let Pelias suggest based on current user location
|
|
331
|
+
* minimalRegexp: undefined // used for testing min. regexp. For example: new RegExp('.{2,}'),
|
|
332
|
+
* lineRegexp: undefined // identify searches for route numbers/labels: bus | train | metro. For example: new RegExp(
|
|
333
|
+
* // '(^[0-9]+[a-z]?$|^[yuleapinkrtdz]$|(^m[12]?b?$))',
|
|
334
|
+
* // 'i',
|
|
335
|
+
* // ),
|
|
336
|
+
* URL_PELIAS: '' // url for pelias searches
|
|
337
|
+
* feedIDs: ['HSL', 'HSLLautta'] // FeedId's like [HSL, HSLLautta]
|
|
338
|
+
* geocodingSources: ['oa','osm','nlsfi'] // sources for geocoding
|
|
339
|
+
* geocodingSearchParams; {} // Searchparmas fro geocoding
|
|
340
|
+
* getFavouriteLocations: () => ({}), // Function that returns array of favourite locations.
|
|
341
|
+
* getFavouriteStops: () => ({}), // Function that returns array of favourite stops.
|
|
342
|
+
* getLanguage: () => ({}), // Function that returns current language.
|
|
343
|
+
* getFavouriteRoutes: () => ({}), // Function that returns array of favourite routes.
|
|
344
|
+
* getPositions: () => ({}), // Function that returns user's geolocation.
|
|
345
|
+
* getRoutesQuery: () => ({}), // Function that returns query for fetching routes.
|
|
346
|
+
* getStopAndStationsQuery: () => ({}), // Function that fetches favourite stops and stations from graphql API.
|
|
347
|
+
* getFavouriteRoutesQuery: () => ({}), // Function that returns query for fetching favourite routes.
|
|
348
|
+
* getFavouriteVehicleRentalStations: () => ({}), // Function that returns favourite bike rental station.
|
|
349
|
+
* getFavouriteVehicleRentalStationsQuery: () => ({}), // Function that returns query for fetching favourite bike rental stations.
|
|
350
|
+
* startLocationWatch: () => ({}), // Function that locates users geolocation.
|
|
351
|
+
* saveSearch: () => ({}), // Function that saves search to old searches store.
|
|
352
|
+
* clearOldSearches: () => ({}), // Function that clears old searches store.
|
|
353
|
+
* getFutureRoutes: () => ({}), // Function that return future routes
|
|
354
|
+
* saveFutureRoute: () => ({}), // Function that saves a future route
|
|
355
|
+
* clearFutureRoutes: () => ({}), // Function that clears future routes
|
|
356
|
+
* };
|
|
357
|
+
*
|
|
358
|
+
* const origin = {
|
|
359
|
+
* lat: 60.169196,
|
|
360
|
+
* lon: 24.957674,
|
|
361
|
+
* address: 'Aleksanterinkatu, Helsinki',
|
|
362
|
+
* set: true,
|
|
363
|
+
* ready: true,
|
|
364
|
+
* }
|
|
365
|
+
*
|
|
366
|
+
* const destination = {
|
|
367
|
+
* lat: 60.199093,
|
|
368
|
+
* lon: 24.940536,
|
|
369
|
+
* address: 'Opastinsilta 6, Helsinki',
|
|
370
|
+
* set: true,
|
|
371
|
+
* ready: true,
|
|
372
|
+
* }
|
|
373
|
+
* onSelect(item, id) {
|
|
374
|
+
* return null; // Define what to do when a suggestion is being selected. None by default.
|
|
375
|
+
* }
|
|
376
|
+
* onClear(id) {
|
|
377
|
+
* return null; // Define what to do when a suggestion is being selected. None by default.
|
|
378
|
+
* }
|
|
379
|
+
* const getAutoSuggestIcons: {
|
|
380
|
+
* // Called for every city bike station rendered as a search suggestion. Should return the icon and
|
|
381
|
+
* // color used for that station. Two icons are available, 'citybike-stop-digitransit' anditybike-stop-digitransit-secondary'.
|
|
382
|
+
* citybikes: station => {
|
|
383
|
+
* return ['citybike-stop-digitransit', '#f2b62d'];
|
|
384
|
+
* }
|
|
385
|
+
* }
|
|
386
|
+
* const targets = ['Locations', 'Stops', 'Routes']; // Defines what you are searching. all available options are Locations, Stops, Routes, VehicleRentalStations, FutureRoutes, MapPosition and CurrentPosition. Leave empty to search all targets.
|
|
387
|
+
* const sources = ['Favourite', 'History', 'Datasource'] // Defines where you are searching. all available are: Favourite, History (previously searched searches), and Datasource. Leave empty to use all sources.
|
|
388
|
+
* <DTAutosuggestPanel
|
|
389
|
+
* appElement={appElement} // Required. Root element's id. Needed for react-modal component.
|
|
390
|
+
* origin={origin} // Selected origin point
|
|
391
|
+
* destination={destination} // Selected destination point
|
|
392
|
+
* originPlaceHolder={'Give origin'} // Optional Give string shown initially inside origin search field
|
|
393
|
+
* destinationPlaceHolder={'Give destination'} // Optional Give string shown initally inside destination search field
|
|
394
|
+
* initialViaPoints={[]} // Optional. If showViapointControl is set to true, pass initial via points to the panel. Currently no default implementation is given.
|
|
395
|
+
* updateViaPoints={() => return []} // Optional. If showViapointControl is set to true, define how to update your via point list with this function. Currenlty no default implementation is given.
|
|
396
|
+
* swapOrder={() => return null} // Optional. If showSwapControl is set to true, define how to swap order of your points (origin, destination, viapoints). Currently no default implementation is given.
|
|
397
|
+
* searchContext={searchContext}
|
|
398
|
+
* getAutoSuggestIcons={getAutoSuggestIcons}
|
|
399
|
+
* onSelect={this.onSelect}
|
|
400
|
+
* onClear={this.onClear}
|
|
401
|
+
* lang="fi" // Define language fi sv or en.
|
|
402
|
+
* addAnalyticsEvent={null} // Optional. you can record an analytics event if you wish. if passed, component will pass an category, action, name parameters to addAnalyticsEvent
|
|
403
|
+
* disableAutoFocus={false} // Optional. use this to disable autofocus completely from DTAutosuggestPanel
|
|
404
|
+
* sources={sources}
|
|
405
|
+
* targets={targets}
|
|
406
|
+
* isMobile // Optional. Defaults to false. Whether to use mobile search.
|
|
407
|
+
* originMobileLabel="Origin label" // Optional. Custom label text for origin field on mobile.
|
|
408
|
+
* destinationMobileLabel="Destination label" // Optional. Custom label text for destination field on mobile.
|
|
409
|
+
* handleFocusChange={() => {}} // Optional. If defined overrides default onFocusChange behaviour
|
|
410
|
+
* showSwapControl={false} // Optional.
|
|
411
|
+
* showViapointControl={false} // Optional.
|
|
412
|
+
*/
|
|
413
|
+
|
|
414
|
+
const locationShape = process.env.NODE_ENV !== "production" ? PropTypes.shape({
|
|
415
|
+
address: PropTypes.string,
|
|
416
|
+
lat: PropTypes.number,
|
|
417
|
+
lon: PropTypes.number,
|
|
418
|
+
locationSlack: PropTypes.number
|
|
419
|
+
}) : {};
|
|
420
|
+
class DTAutosuggestPanel extends React.Component {
|
|
421
|
+
constructor(props) {
|
|
422
|
+
super(props);
|
|
423
|
+
_defineProperty(this, "storeReference", ref => {
|
|
424
|
+
this.setState(prevState => ({
|
|
425
|
+
refs: [...prevState.refs, ref]
|
|
426
|
+
}));
|
|
427
|
+
});
|
|
428
|
+
_defineProperty(this, "handleFocusChange", () => {
|
|
429
|
+
const {
|
|
430
|
+
destination
|
|
431
|
+
} = this.props;
|
|
432
|
+
if (!destination || !destination.lat) {
|
|
433
|
+
this.state.refs[1].focus();
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
_defineProperty(this, "updateViaPoints", viaPoints => {
|
|
437
|
+
if (viaPoints.length === 0) {
|
|
438
|
+
this.props.updateViaPoints([]);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
this.props.updateViaPoints(viaPoints.filter(vp => !isViaPointEmpty(vp)));
|
|
442
|
+
});
|
|
443
|
+
_defineProperty(this, "handleToggleViaPointSlackClick", viaPointIndex => {
|
|
444
|
+
const {
|
|
445
|
+
activeSlackInputs
|
|
446
|
+
} = this.state;
|
|
447
|
+
this.setState({
|
|
448
|
+
activeSlackInputs: activeSlackInputs.includes(viaPointIndex) ? updateViaPointSlack(activeSlackInputs, viaPointIndex) : activeSlackInputs.concat([viaPointIndex])
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
_defineProperty(this, "handleViaPointSlackTimeSelected", (slackTimeInSeconds, i) => {
|
|
452
|
+
if (this.props.addAnalyticsEvent) {
|
|
453
|
+
this.props.addAnalyticsEvent({
|
|
454
|
+
action: 'EditViaPointStopDuration',
|
|
455
|
+
category: 'ItinerarySettings',
|
|
456
|
+
name: slackTimeInSeconds / 60
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
const {
|
|
460
|
+
viaPoints
|
|
461
|
+
} = this.props;
|
|
462
|
+
viaPoints[i].locationSlack = Number.parseInt(slackTimeInSeconds, 10);
|
|
463
|
+
this.updateViaPoints(viaPoints);
|
|
464
|
+
});
|
|
465
|
+
_defineProperty(this, "handleViaPointLocationSelected", (viaPointLocation, i) => {
|
|
466
|
+
this.props.handleViaPointLocationSelected(viaPointLocation, i);
|
|
467
|
+
});
|
|
468
|
+
_defineProperty(this, "handleRemoveViaPointClick", viaPointIndex => {
|
|
469
|
+
if (this.props.addAnalyticsEvent) {
|
|
470
|
+
this.props.addAnalyticsEvent({
|
|
471
|
+
action: 'RemoveJourneyViaPoint',
|
|
472
|
+
category: 'ItinerarySettings',
|
|
473
|
+
name: null
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
const {
|
|
477
|
+
activeSlackInputs
|
|
478
|
+
} = this.state;
|
|
479
|
+
const {
|
|
480
|
+
viaPoints
|
|
481
|
+
} = this.props;
|
|
482
|
+
viaPoints.splice(viaPointIndex, 1);
|
|
483
|
+
this.setState({
|
|
484
|
+
activeSlackInputs: updateViaPointSlack(activeSlackInputs, viaPointIndex, true)
|
|
485
|
+
}, () => this.updateViaPoints(viaPoints));
|
|
486
|
+
});
|
|
487
|
+
_defineProperty(this, "handleAddViaPointClick", () => {
|
|
488
|
+
if (this.props.addAnalyticsEvent) {
|
|
489
|
+
this.props.addAnalyticsEvent({
|
|
490
|
+
action: 'AddJourneyViaPoint',
|
|
491
|
+
category: 'ItinerarySettings',
|
|
492
|
+
name: 'QuickSettingsButton'
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
const {
|
|
496
|
+
viaPoints
|
|
497
|
+
} = this.props;
|
|
498
|
+
viaPoints.push(getEmptyViaPointPlaceHolder());
|
|
499
|
+
// We need to update the state so that placeHolder will show up in panel.
|
|
500
|
+
// eslint-disable-next-line react/no-access-state-in-setstate
|
|
501
|
+
this.setState(this.state);
|
|
502
|
+
});
|
|
503
|
+
_defineProperty(this, "handleSwapOrderClick", () => {
|
|
504
|
+
if (this.props.addAnalyticsEvent) {
|
|
505
|
+
this.props.addAnalyticsEvent({
|
|
506
|
+
action: 'SwitchJourneyStartAndEndPointOrder',
|
|
507
|
+
category: 'ItinerarySettings',
|
|
508
|
+
name: null
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
const {
|
|
512
|
+
viaPoints
|
|
513
|
+
} = this.props;
|
|
514
|
+
viaPoints.reverse();
|
|
515
|
+
this.props.swapOrder();
|
|
516
|
+
});
|
|
517
|
+
_defineProperty(this, "getSlackDisplay", slackInSeconds => `${slackInSeconds / 60} ${this.props.t('minute-short', {
|
|
518
|
+
lng: this.props.lang
|
|
519
|
+
})}`);
|
|
520
|
+
this.state = {
|
|
521
|
+
activeSlackInputs: [],
|
|
522
|
+
refs: []
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
render() {
|
|
526
|
+
const {
|
|
527
|
+
origin,
|
|
528
|
+
searchPanelText,
|
|
529
|
+
searchContext,
|
|
530
|
+
disableAutoFocus,
|
|
531
|
+
viaPoints,
|
|
532
|
+
originMobileLabel,
|
|
533
|
+
destinationMobileLabel,
|
|
534
|
+
fontWeights,
|
|
535
|
+
onFocusChange,
|
|
536
|
+
showSwapControl,
|
|
537
|
+
showViapointControl,
|
|
538
|
+
t,
|
|
539
|
+
lang: lng
|
|
540
|
+
} = this.props;
|
|
541
|
+
const {
|
|
542
|
+
primary
|
|
543
|
+
} = this.props.colors;
|
|
544
|
+
const {
|
|
545
|
+
activeSlackInputs
|
|
546
|
+
} = this.state;
|
|
547
|
+
const slackTime = getSlackTimeOptions(t);
|
|
548
|
+
const defaultSlackTimeValue = 0;
|
|
549
|
+
const getViaPointSlackTimeOrDefault = (viaPoint, defaultValue = defaultSlackTimeValue) => viaPoint && viaPoint.locationSlack || defaultValue;
|
|
550
|
+
const isViaPointSlackTimeInputActive = index => activeSlackInputs.includes(index);
|
|
551
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
552
|
+
className: cx(styles['autosuggest-panel'], this.props.isMobile && "small"),
|
|
553
|
+
style: {
|
|
554
|
+
'--color': primary,
|
|
555
|
+
'--font-weight-medium': fontWeights.medium
|
|
556
|
+
}
|
|
557
|
+
}, ' ', searchPanelText ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", {
|
|
558
|
+
className: styles['autosuggest-searchpanel-text']
|
|
559
|
+
}, ' ', searchPanelText)) : null, /*#__PURE__*/React.createElement("div", {
|
|
560
|
+
className: styles['origin-input-container']
|
|
561
|
+
}, /*#__PURE__*/React.createElement(DTAutoSuggest, {
|
|
562
|
+
appElement: this.props.appElement,
|
|
563
|
+
icon: "originEllipse",
|
|
564
|
+
id: "origin",
|
|
565
|
+
autoFocus: disableAutoFocus === true ? false : !this.props.isMobile && !origin?.lat,
|
|
566
|
+
storeRef: this.storeReference,
|
|
567
|
+
refPoint: this.props.refPoint,
|
|
568
|
+
className: getLocationType(origin),
|
|
569
|
+
placeholder: this.props.originPlaceHolder,
|
|
570
|
+
value: value(origin),
|
|
571
|
+
searchContext: searchContext,
|
|
572
|
+
getAutoSuggestIcons: this.props.getAutoSuggestIcons,
|
|
573
|
+
onSelect: this.props.onSelect,
|
|
574
|
+
onClear: this.props.onClear,
|
|
575
|
+
focusChange: onFocusChange || this.handleFocusChange,
|
|
576
|
+
lang: this.props.lang,
|
|
577
|
+
sources: this.props.sources,
|
|
578
|
+
targets: this.props.targets,
|
|
579
|
+
filterResults: this.props.filterResults,
|
|
580
|
+
isMobile: this.props.isMobile,
|
|
581
|
+
colors: this.props.colors,
|
|
582
|
+
mobileLabel: originMobileLabel,
|
|
583
|
+
fontWeights: this.props.fontWeights,
|
|
584
|
+
modeSet: this.props.modeSet,
|
|
585
|
+
showScroll: this.props.showScroll,
|
|
586
|
+
isEmbedded: this.props.isEmbedded
|
|
587
|
+
}), (showSwapControl || showViapointControl) && /*#__PURE__*/React.createElement(ItinerarySearchControl, {
|
|
588
|
+
className: styles.opposite,
|
|
589
|
+
enabled: showSwapControl,
|
|
590
|
+
onClick: () => this.handleSwapOrderClick(),
|
|
591
|
+
onKeyPress: e => isKeyboardSelectionEvent(e) && this.handleSwapOrderClick(),
|
|
592
|
+
"aria-label": t('swap-order-button-label', {
|
|
593
|
+
lng
|
|
594
|
+
})
|
|
595
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
596
|
+
img: "opposite",
|
|
597
|
+
color: primary
|
|
598
|
+
}))), viaPoints.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
599
|
+
className: styles['rectangle-container']
|
|
600
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
601
|
+
className: styles.rectangle
|
|
602
|
+
})), /*#__PURE__*/React.createElement(ReactSortable, {
|
|
603
|
+
className: styles['viapoints-container'],
|
|
604
|
+
list: viaPoints,
|
|
605
|
+
handle: `.${styles['viapoint-before']}`,
|
|
606
|
+
animation: 200,
|
|
607
|
+
disabled: viaPoints.length <= 1,
|
|
608
|
+
setList: items => {
|
|
609
|
+
const newViaPoints = items.filter(vp => !isViaPointEmpty(vp));
|
|
610
|
+
if (newViaPoints.length > 0) {
|
|
611
|
+
this.props.updateViaPoints(newViaPoints);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}, viaPoints.map((o, i) => /*#__PURE__*/React.createElement("div", {
|
|
615
|
+
className: cx(styles['viapoint-container']),
|
|
616
|
+
key: `viapoint-${i}` // eslint-disable-line
|
|
617
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
618
|
+
className: styles['light-gray-background']
|
|
619
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
620
|
+
className: styles.row
|
|
621
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
622
|
+
className: styles['viapoint-before'],
|
|
623
|
+
style: viaPoints.length > 1 ? {
|
|
624
|
+
cursor: 'move'
|
|
625
|
+
} : {}
|
|
626
|
+
}, viaPoints.length > 1 && /*#__PURE__*/React.createElement(Icon, {
|
|
627
|
+
img: "ellipsis",
|
|
628
|
+
rotate: 90,
|
|
629
|
+
color: primary
|
|
630
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
631
|
+
className: `${styles['viapoint-input-container']} ${styles[`viapoint-${i + 1}`]}`
|
|
632
|
+
}, /*#__PURE__*/React.createElement(DTAutoSuggest, {
|
|
633
|
+
appElement: this.props.appElement,
|
|
634
|
+
icon: "mapMarker",
|
|
635
|
+
id: "via-point",
|
|
636
|
+
ariaLabel: t('via-point-index', {
|
|
637
|
+
index: i + 1,
|
|
638
|
+
lng
|
|
639
|
+
}),
|
|
640
|
+
autoFocus: disableAutoFocus === true ? false : !this.props.isMobile,
|
|
641
|
+
placeholder: "via-point",
|
|
642
|
+
className: "viapoint",
|
|
643
|
+
searchContext: searchContext,
|
|
644
|
+
refPoint: this.props.refPoint,
|
|
645
|
+
value: o && o.address || '',
|
|
646
|
+
onSelect: this.props.onSelect,
|
|
647
|
+
onClear: this.props.onClear,
|
|
648
|
+
handleViaPoints: item => this.handleViaPointLocationSelected(item, i),
|
|
649
|
+
lang: this.props.lang,
|
|
650
|
+
sources: this.props.sources,
|
|
651
|
+
targets: this.props.targets,
|
|
652
|
+
filterResults: this.props.filterResults,
|
|
653
|
+
getAutoSuggestIcons: this.props.getAutoSuggestIcons,
|
|
654
|
+
isMobile: this.props.isMobile,
|
|
655
|
+
fontWeights: this.props.fontWeights,
|
|
656
|
+
modeSet: this.props.modeSet,
|
|
657
|
+
colors: this.props.colors,
|
|
658
|
+
showScroll: this.props.showScroll
|
|
659
|
+
})), this.props.showSlackControl && /*#__PURE__*/React.createElement(ItinerarySearchControl, {
|
|
660
|
+
className: styles['add-via-point-slack'],
|
|
661
|
+
enabled: this.props.showViapointControl,
|
|
662
|
+
onClick: () => this.handleToggleViaPointSlackClick(i),
|
|
663
|
+
onKeyPress: e => isKeyboardSelectionEvent(e) && this.handleToggleViaPointSlackClick(i),
|
|
664
|
+
"aria-label": t(isViaPointSlackTimeInputActive(i) ? 'add-via-duration-button-label-open' : 'add-via-duration-button-label-close', {
|
|
665
|
+
index: i + 1,
|
|
666
|
+
lng
|
|
667
|
+
}),
|
|
668
|
+
wide: true
|
|
669
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
670
|
+
img: "time",
|
|
671
|
+
color: primary
|
|
672
|
+
}))), !isViaPointSlackTimeInputActive(i) && viaPoints[i] && viaPoints[i].locationSlack > 0 && /*#__PURE__*/React.createElement("span", {
|
|
673
|
+
className: styles['viapoint-slack-time']
|
|
674
|
+
}, `${t('viapoint-slack-amount', {
|
|
675
|
+
lng
|
|
676
|
+
})}: ${this.getSlackDisplay(viaPoints[i].locationSlack)}`), /*#__PURE__*/React.createElement("div", {
|
|
677
|
+
className: cx(styles['input-viapoint-slack-container'], !isViaPointSlackTimeInputActive(i) && "collapsed")
|
|
678
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
679
|
+
className: styles['select-wrapper']
|
|
680
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
681
|
+
id: `viapoint-slack-${i}`,
|
|
682
|
+
label: t('viapoint-slack-amount', {
|
|
683
|
+
lng
|
|
684
|
+
}),
|
|
685
|
+
options: slackTime,
|
|
686
|
+
value: getViaPointSlackTimeOrDefault(viaPoints[i]),
|
|
687
|
+
viaPointIndex: i,
|
|
688
|
+
icon: /*#__PURE__*/React.createElement("span", {
|
|
689
|
+
className: `${styles['combobox-icon']} ${styles['time-input-icon']}`
|
|
690
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
691
|
+
img: "time",
|
|
692
|
+
color: primary
|
|
693
|
+
})),
|
|
694
|
+
onSlackTimeSelected: this.handleViaPointSlackTimeSelected
|
|
695
|
+
})))), /*#__PURE__*/React.createElement(ItinerarySearchControl, {
|
|
696
|
+
className: styles['remove-via-point'],
|
|
697
|
+
enabled: this.props.showViapointControl,
|
|
698
|
+
onClick: () => this.handleRemoveViaPointClick(i),
|
|
699
|
+
onKeyPress: e => isKeyboardSelectionEvent(e) && this.handleRemoveViaPointClick(i),
|
|
700
|
+
"aria-label": t('remove-via-button-label', {
|
|
701
|
+
index: i + 1,
|
|
702
|
+
lng
|
|
703
|
+
})
|
|
704
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
705
|
+
img: "trash",
|
|
706
|
+
color: primary
|
|
707
|
+
}))))), /*#__PURE__*/React.createElement("div", {
|
|
708
|
+
className: styles['destination-input-container']
|
|
709
|
+
}, /*#__PURE__*/React.createElement(DTAutoSuggest, {
|
|
710
|
+
appElement: this.props.appElement,
|
|
711
|
+
icon: "mapMarker",
|
|
712
|
+
id: "destination",
|
|
713
|
+
autoFocus: disableAutoFocus === true ? false : !this.props.isMobile && !Number.isNaN(origin?.lat),
|
|
714
|
+
storeRef: this.storeReference,
|
|
715
|
+
placeholder: this.props.destinationPlaceHolder,
|
|
716
|
+
className: getLocationType(this.props.destination),
|
|
717
|
+
getAutoSuggestIcons: this.props.getAutoSuggestIcons,
|
|
718
|
+
searchContext: searchContext,
|
|
719
|
+
onSelect: this.props.onSelect,
|
|
720
|
+
onClear: this.props.onClear,
|
|
721
|
+
refPoint: this.props.refPoint,
|
|
722
|
+
value: value(this.props.destination),
|
|
723
|
+
lang: this.props.lang,
|
|
724
|
+
sources: this.props.sources,
|
|
725
|
+
targets: this.props.targets,
|
|
726
|
+
filterResults: this.props.filterResults,
|
|
727
|
+
isMobile: this.props.isMobile,
|
|
728
|
+
mobileLabel: destinationMobileLabel,
|
|
729
|
+
fontWeights: this.props.fontWeights,
|
|
730
|
+
modeSet: this.props.modeSet,
|
|
731
|
+
colors: this.props.colors,
|
|
732
|
+
showScroll: this.props.showScroll,
|
|
733
|
+
isEmbedded: this.props.isEmbedded
|
|
734
|
+
}), (showSwapControl || showViapointControl) && /*#__PURE__*/React.createElement(ItinerarySearchControl, {
|
|
735
|
+
className: cx(styles['add-via-point'], styles.more, viaPoints.length > 4 && "collapsed"),
|
|
736
|
+
enabled: showViapointControl && viaPoints.length === 0,
|
|
737
|
+
onClick: () => this.handleAddViaPointClick(),
|
|
738
|
+
onKeyPress: e => isKeyboardSelectionEvent(e) && this.handleAddViaPointClick(),
|
|
739
|
+
"aria-label": t('add-via-button-label', {
|
|
740
|
+
lng
|
|
741
|
+
})
|
|
742
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
743
|
+
img: "viapoint",
|
|
744
|
+
width: 1.25,
|
|
745
|
+
height: 1.375,
|
|
746
|
+
color: primary
|
|
747
|
+
}))));
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
_defineProperty(DTAutosuggestPanel, "defaultProps", {
|
|
751
|
+
origin: undefined,
|
|
752
|
+
destination: undefined,
|
|
753
|
+
viaPoints: [],
|
|
754
|
+
originPlaceHolder: 'give-origin',
|
|
755
|
+
destinationPlaceHolder: 'give-destination',
|
|
756
|
+
swapOrder: undefined,
|
|
757
|
+
updateViaPoints: () => {},
|
|
758
|
+
searchPanelText: undefined,
|
|
759
|
+
sources: [],
|
|
760
|
+
targets: [],
|
|
761
|
+
filterResults: undefined,
|
|
762
|
+
onClear: undefined,
|
|
763
|
+
getAutoSuggestIcons: undefined,
|
|
764
|
+
refPoint: undefined,
|
|
765
|
+
addAnalyticsEvent: undefined,
|
|
766
|
+
disableAutoFocus: false,
|
|
767
|
+
isMobile: false,
|
|
768
|
+
handleViaPointLocationSelected: undefined,
|
|
769
|
+
originMobileLabel: null,
|
|
770
|
+
destinationMobileLabel: null,
|
|
771
|
+
modeSet: undefined,
|
|
772
|
+
colors: defaultColors,
|
|
773
|
+
fontWeights: {
|
|
774
|
+
medium: 500
|
|
775
|
+
},
|
|
776
|
+
showScroll: false,
|
|
777
|
+
onFocusChange: undefined,
|
|
778
|
+
isEmbedded: false,
|
|
779
|
+
showSwapControl: false,
|
|
780
|
+
showViapointControl: false,
|
|
781
|
+
showSlackControl: false
|
|
782
|
+
});
|
|
783
|
+
process.env.NODE_ENV !== "production" ? DTAutosuggestPanel.propTypes = {
|
|
784
|
+
appElement: PropTypes.string.isRequired,
|
|
785
|
+
origin: locationShape,
|
|
786
|
+
destination: locationShape,
|
|
787
|
+
originPlaceHolder: PropTypes.string,
|
|
788
|
+
destinationPlaceHolder: PropTypes.string,
|
|
789
|
+
viaPoints: PropTypes.arrayOf(locationShape),
|
|
790
|
+
updateViaPoints: PropTypes.func,
|
|
791
|
+
handleViaPointLocationSelected: PropTypes.func,
|
|
792
|
+
swapOrder: PropTypes.func,
|
|
793
|
+
searchPanelText: PropTypes.string,
|
|
794
|
+
searchContext: PropTypes.shape({
|
|
795
|
+
URL_PELIAS: PropTypes.string
|
|
796
|
+
}).isRequired,
|
|
797
|
+
onSelect: PropTypes.func.isRequired,
|
|
798
|
+
onClear: PropTypes.func,
|
|
799
|
+
addAnalyticsEvent: PropTypes.func,
|
|
800
|
+
lang: PropTypes.string.isRequired,
|
|
801
|
+
disableAutoFocus: PropTypes.bool,
|
|
802
|
+
sources: PropTypes.arrayOf(PropTypes.string),
|
|
803
|
+
targets: PropTypes.arrayOf(PropTypes.string),
|
|
804
|
+
filterResults: PropTypes.func,
|
|
805
|
+
isMobile: PropTypes.bool,
|
|
806
|
+
originMobileLabel: PropTypes.string,
|
|
807
|
+
destinationMobileLabel: PropTypes.string,
|
|
808
|
+
refPoint: locationShape,
|
|
809
|
+
modeSet: PropTypes.string,
|
|
810
|
+
colors: PropTypes.objectOf(PropTypes.string),
|
|
811
|
+
getAutoSuggestIcons: PropTypes.objectOf(PropTypes.func),
|
|
812
|
+
fontWeights: PropTypes.shape({
|
|
813
|
+
medium: PropTypes.number
|
|
814
|
+
}),
|
|
815
|
+
showScroll: PropTypes.bool,
|
|
816
|
+
onFocusChange: PropTypes.func,
|
|
817
|
+
isEmbedded: PropTypes.bool,
|
|
818
|
+
showSwapControl: PropTypes.bool,
|
|
819
|
+
showViapointControl: PropTypes.bool,
|
|
820
|
+
showSlackControl: PropTypes.bool,
|
|
821
|
+
t: PropTypes.func.isRequired
|
|
822
|
+
} : void 0;
|
|
823
|
+
const DTAutosuggestPanelWithTranslation = withTranslation()(DTAutosuggestPanel);
|
|
824
|
+
var index = props => {
|
|
825
|
+
return /*#__PURE__*/React.createElement(I18nextProvider, {
|
|
826
|
+
i18n: i18n
|
|
827
|
+
}, /*#__PURE__*/React.createElement(DTAutosuggestPanelWithTranslation, props));
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
export { index as default, getEmptyViaPointPlaceHolder };
|
|
2
831
|
//# sourceMappingURL=index.js.map
|