@opensystemslab/map 0.5.0 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6522,14 +6522,18 @@ x:-moz-any-link {
6522
6522
  :host .govuk-label {
6523
6523
  font-family: var(--autocomplete__font-family, "GDS Transport", arial, sans-serif);
6524
6524
  }
6525
+ :host .govuk-label--static {
6526
+ font-size: var(--autocomplete__label__font-size, 19px);
6527
+ }
6525
6528
  :host .autocomplete__input {
6526
6529
  font-family: var(--autocomplete__font-family, "GDS Transport", arial, sans-serif);
6527
6530
  font-size: var(--autocomplete__input__font-size, 19px);
6528
6531
  height: var(--autocomplete__input__height, 35px);
6529
6532
  padding: var(--autocomplete__input__padding, 5px 34px 5px 5px);
6533
+ z-index: calc(var(--autocomplete__dropdown-arrow-down__z-index, 1) + 1);
6530
6534
  }
6531
6535
  :host .autocomplete__dropdown-arrow-down {
6532
- z-index: var(--autocomplete__dropdown-arrow-down__z-index, -1);
6536
+ z-index: var(--autocomplete__dropdown-arrow-down__z-index, 1);
6533
6537
  top: calc((var(--autocomplete__input__height, 35px) - 17px) / 2);
6534
6538
  }
6535
6539
  :host .autocomplete__option {
@@ -6538,13 +6542,14 @@ x:-moz-any-link {
6538
6542
  padding: var(--autocomplete__option__padding, 5px);
6539
6543
  border-bottom: var(--autocomplete__option__border-bottom, solid 1px #b1b4b6);
6540
6544
  }
6541
- :host .autocomplete__option:hover, :host .autocomplete__option:focus {
6545
+ :host .autocomplete__option--focused,
6546
+ :host .autocomplete__option:hover, .autocomplete__option--focused :host .autocomplete__option:hover {
6542
6547
  border-color: var(--autocomplete__option__hover-border-color, #1d70b8);
6543
6548
  background-color: var(--autocomplete__option__hover-background-color, #1d70b8);
6544
6549
  }
6545
6550
  :host .autocomplete__menu {
6546
6551
  max-height: var(--autocomplete__menu__max-height, 342px);
6547
- }`,by=Object.freeze,xy=Object.defineProperty,ky=Object.getOwnPropertyDescriptor,wy=(t,e,i,o)=>{for(var n,r=o>1?void 0:o?ky(e,i):e,a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o?n(e,i,r):n(r))||r);return o&&r&&xy(e,i,r),r},Sy=(t,e)=>by(xy(t,"raw",{value:by(e||t.slice())}));let Cy=class extends ht{constructor(){super(...arguments),this.id="autocomplete",this.postcode="SE5 0HU",this.label="Select an address",this.initialAddress="",this.osPlacesApiKey="",this._totalAddresses=void 0,this._addressesInPostcode=[],this._options=[],this._selectedAddress=null,this._osError=void 0,this.dispatch=(t,e)=>this.dispatchEvent(new CustomEvent(t,{detail:e}))}connectedCallback(){super.connectedCallback(),this._fetchData()}disconnectedCallback(){super.disconnectedCallback()}firstUpdated(){yy({element:this.renderRoot.querySelector(`#${this.id}-container`),id:this.id,required:!0,source:this._options,defaultValue:this.initialAddress,showAllValues:!0,displayMenu:"overlay",tNoResults:()=>"No addresses found",onConfirm:t=>{this._selectedAddress=this._addressesInPostcode.filter((e=>e.LPI.ADDRESS.split(`, ${e.LPI.ADMINISTRATIVE_AREA}`)[0]===t))[0],this._selectedAddress&&this.dispatch("addressSelection",{address:this._selectedAddress})}})}async _fetchData(t=0,e=[]){const i={postcode:this.postcode,dataset:"LPI",maxResults:"100",output_srs:"EPSG:4326",lr:"EN",key:this.osPlacesApiKey},o=`https://api.os.uk/search/places/v1/postcode?${new URLSearchParams(i)}`;await fetch(o+`&offset=${t}`).then((t=>t.json())).then((t=>{var i,o,n;(t.error||t.fault)&&(this._osError=(null==(i=t.error)?void 0:i.message)||(null==(o=t.fault)?void 0:o.faultstring)||"Something went wrong"),this._totalAddresses=null==(n=t.header)?void 0:n.totalresults;const r=e.concat(t.results||[]);if(this._addressesInPostcode=r,this.dispatch("ready",{postcode:this.postcode,status:`fetched ${this._addressesInPostcode.length}/${this._totalAddresses} addresses`}),t.results){t.results.filter((t=>"APPROVED"===t.LPI.LPI_LOGICAL_STATUS_CODE_DESCRIPTION)).map((t=>{this._options.push(t.LPI.ADDRESS.split(`, ${t.LPI.ADMINISTRATIVE_AREA}`)[0])}));const e=new Intl.Collator([],{numeric:!0});this._options.sort(((t,i)=>e.compare(t,i)))}this._totalAddresses&&this._totalAddresses>this._addressesInPostcode.length&&this._fetchData(this._addressesInPostcode.length,this._addressesInPostcode)})).catch((t=>console.log(t)))}render(){let t;return this.osPlacesApiKey?this._osError?t=this._osError:0===this._totalAddresses&&(t=`No addresses found in postcode ${this.postcode}`):t="Missing OS Places API key",t?U(my||(my=Sy(['<script src="https://cdn.polyfill.io/v2/polyfill.min.js"><\/script>\n <div class="govuk-warning-text" role="status">\n <span class="govuk-warning-text__icon" aria-hidden="true">!</span>\n <strong class="govuk-warning-text__text">\n <span class="govuk-warning-text__assistive">Warning</span>\n ',"\n </strong>\n </div>"])),t):U(vy||(vy=Sy(['<script src="https://cdn.polyfill.io/v2/polyfill.min.js"><\/script>\n <link\n rel="stylesheet"\n href="https://cdn.jsdelivr.net/npm/accessible-autocomplete@2.0.4/dist/accessible-autocomplete.min.css"\n />\n <label class="govuk-label" htmlFor=',">",'</label>\n <div\n id="','-container"\n role="status"\n spellcheck="false"\n ></div>'])),this.id,this.label,this.id)}};Cy.styles=f(_y),wy([gt({type:String})],Cy.prototype,"id",2),wy([gt({type:String})],Cy.prototype,"postcode",2),wy([gt({type:String})],Cy.prototype,"label",2),wy([gt({type:String})],Cy.prototype,"initialAddress",2),wy([gt({type:String})],Cy.prototype,"osPlacesApiKey",2),wy([mt()],Cy.prototype,"_totalAddresses",2),wy([mt()],Cy.prototype,"_addressesInPostcode",2),wy([mt()],Cy.prototype,"_options",2),wy([mt()],Cy.prototype,"_selectedAddress",2),wy([mt()],Cy.prototype,"_osError",2),Cy=wy([ct("address-autocomplete")],Cy);var zy,Ty=function(){return(Ty=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},Ey=/^([a-z]{1,2}\d)([a-z])$/i,Oy=/[a-z]{2}$/i,Py=/\d[a-z]{2}$/i,jy=/^[a-z]{1,2}\d[a-z\d]?\s*\d[a-z]{2}$/i,Ry=/^[a-z]{1,2}/i,Iy={valid:!1,postcode:null,incode:null,outcode:null,area:null,district:null,subDistrict:null,sector:null,unit:null},Fy=function(t){return null===t?null:t[0]},My=/\s+/gi,Ay=function(t){return t.replace(My,"").toUpperCase()},Dy=function(t,e){return Ay(t).match(e)},Ly=function(t){return null!==t.match(jy)},Gy=function(t){var e=Ny(t);if(null===e)return null;var i=By(t);return null===i?null:e+" "+i},Ny=function(t){return Ly(t)?Ay(t).replace(Py,""):null},By=function(t){if(!Ly(t))return null;var e=Dy(t,Py);return Fy(e)},qy=function(t){if(!Ly(t))return null;var e=Dy(t,Ry);return Fy(e)},Wy=function(t){var e=Ny(t);if(null===e)return null;var i=By(t);return null===i?null:e+" "+i[0]},Vy=function(t){if(!Ly(t))return null;var e=Dy(t,Oy);return Fy(e)},Uy=function(t){var e=Ny(t);if(null===e)return null;var i=e.match(Ey);return null===i?e:i[1]},Xy=function(t){var e=Ny(t);return null===e||null===e.match(Ey)?null:e},Ky=g`@charset "UTF-8";
6552
+ }`,by=Object.freeze,xy=Object.defineProperty,ky=Object.getOwnPropertyDescriptor,wy=(t,e,i,o)=>{for(var n,r=o>1?void 0:o?ky(e,i):e,a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o?n(e,i,r):n(r))||r);return o&&r&&xy(e,i,r),r},Sy=(t,e)=>by(xy(t,"raw",{value:by(e||t.slice())}));let Cy=class extends ht{constructor(){super(...arguments),this.id="autocomplete",this.postcode="SE5 0HU",this.label="Select an address",this.initialAddress="",this.osPlacesApiKey="",this.arrowStyle="default",this.labelStyle="responsive",this._totalAddresses=void 0,this._addressesInPostcode=[],this._options=[],this._selectedAddress=null,this._osError=void 0,this.dispatch=(t,e)=>this.dispatchEvent(new CustomEvent(t,{detail:e}))}connectedCallback(){super.connectedCallback(),this._fetchData()}disconnectedCallback(){super.disconnectedCallback()}getLightDropdownArrow(){return'<svg class="autocomplete__dropdown-arrow-down" style="height: 17px;" viewBox="0 0 512 512" ><path d="M256,298.3L256,298.3L256,298.3l174.2-167.2c4.3-4.2,11.4-4.1,15.8,0.2l30.6,29.9c4.4,4.3,4.5,11.3,0.2,15.5L264.1,380.9 c-2.2,2.2-5.2,3.2-8.1,3c-3,0.1-5.9-0.9-8.1-3L35.2,176.7c-4.3-4.2-4.2-11.2,0.2-15.5L66,131.3c4.4-4.3,11.5-4.4,15.8-0.2L256,298.3 z"/></svg>'}firstUpdated(){yy({element:this.renderRoot.querySelector(`#${this.id}-container`),id:this.id,required:!0,source:this._options,defaultValue:this.initialAddress,showAllValues:!0,displayMenu:"overlay",dropdownArrow:"light"===this.arrowStyle?this.getLightDropdownArrow:void 0,tNoResults:()=>"No addresses found",onConfirm:t=>{this._selectedAddress=this._addressesInPostcode.filter((e=>e.LPI.ADDRESS.split(`, ${e.LPI.ADMINISTRATIVE_AREA}`)[0]===t))[0],this._selectedAddress&&this.dispatch("addressSelection",{address:this._selectedAddress})}})}async _fetchData(t=0,e=[]){const i={postcode:this.postcode,dataset:"LPI",maxResults:"100",output_srs:"EPSG:4326",lr:"EN",key:this.osPlacesApiKey},o=`https://api.os.uk/search/places/v1/postcode?${new URLSearchParams(i)}`;await fetch(o+`&offset=${t}`).then((t=>t.json())).then((t=>{var i,o,n;(t.error||t.fault)&&(this._osError=(null==(i=t.error)?void 0:i.message)||(null==(o=t.fault)?void 0:o.faultstring)||"Something went wrong"),this._totalAddresses=null==(n=t.header)?void 0:n.totalresults;const r=e.concat(t.results||[]);if(this._addressesInPostcode=r,this.dispatch("ready",{postcode:this.postcode,status:`fetched ${this._addressesInPostcode.length}/${this._totalAddresses} addresses`}),t.results){t.results.filter((t=>"APPROVED"===t.LPI.LPI_LOGICAL_STATUS_CODE_DESCRIPTION)).map((t=>{this._options.push(t.LPI.ADDRESS.split(`, ${t.LPI.ADMINISTRATIVE_AREA}`)[0])}));const e=new Intl.Collator([],{numeric:!0});this._options.sort(((t,i)=>e.compare(t,i)))}this._totalAddresses&&this._totalAddresses>this._addressesInPostcode.length&&this._fetchData(this._addressesInPostcode.length,this._addressesInPostcode)})).catch((t=>console.log(t)))}_getLabelClasses(){let t="govuk-label";return"static"===this.labelStyle&&(t+=" govuk-label--static"),t}render(){let t;return this.osPlacesApiKey?this._osError?t=this._osError:0===this._totalAddresses&&(t=`No addresses found in postcode ${this.postcode}`):t="Missing OS Places API key",t?U(my||(my=Sy(['<script src="https://cdn.polyfill.io/v2/polyfill.min.js"><\/script>\n <div class="govuk-warning-text" role="status">\n <span class="govuk-warning-text__icon" aria-hidden="true">!</span>\n <strong class="govuk-warning-text__text">\n <span class="govuk-warning-text__assistive">Warning</span>\n ',"\n </strong>\n </div>"])),t):U(vy||(vy=Sy(['<script src="https://cdn.polyfill.io/v2/polyfill.min.js"><\/script>\n <link\n rel="stylesheet"\n href="https://cdn.jsdelivr.net/npm/accessible-autocomplete@2.0.4/dist/accessible-autocomplete.min.css"\n />\n <label class='," for=","\n >",'</label\n >\n <div id="','-container" spellcheck="false"></div>'])),this._getLabelClasses(),this.id,this.label,this.id)}};Cy.styles=f(_y),wy([gt({type:String})],Cy.prototype,"id",2),wy([gt({type:String})],Cy.prototype,"postcode",2),wy([gt({type:String})],Cy.prototype,"label",2),wy([gt({type:String})],Cy.prototype,"initialAddress",2),wy([gt({type:String})],Cy.prototype,"osPlacesApiKey",2),wy([gt({type:String})],Cy.prototype,"arrowStyle",2),wy([gt({type:String})],Cy.prototype,"labelStyle",2),wy([mt()],Cy.prototype,"_totalAddresses",2),wy([mt()],Cy.prototype,"_addressesInPostcode",2),wy([mt()],Cy.prototype,"_options",2),wy([mt()],Cy.prototype,"_selectedAddress",2),wy([mt()],Cy.prototype,"_osError",2),Cy=wy([ct("address-autocomplete")],Cy);var zy,Ty=function(){return(Ty=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},Ey=/^([a-z]{1,2}\d)([a-z])$/i,Oy=/[a-z]{2}$/i,Py=/\d[a-z]{2}$/i,jy=/^[a-z]{1,2}\d[a-z\d]?\s*\d[a-z]{2}$/i,Ry=/^[a-z]{1,2}/i,Iy={valid:!1,postcode:null,incode:null,outcode:null,area:null,district:null,subDistrict:null,sector:null,unit:null},Fy=function(t){return null===t?null:t[0]},My=/\s+/gi,Ay=function(t){return t.replace(My,"").toUpperCase()},Dy=function(t,e){return Ay(t).match(e)},Ly=function(t){return null!==t.match(jy)},Gy=function(t){var e=Ny(t);if(null===e)return null;var i=By(t);return null===i?null:e+" "+i},Ny=function(t){return Ly(t)?Ay(t).replace(Py,""):null},By=function(t){if(!Ly(t))return null;var e=Dy(t,Py);return Fy(e)},qy=function(t){if(!Ly(t))return null;var e=Dy(t,Ry);return Fy(e)},Wy=function(t){var e=Ny(t);if(null===e)return null;var i=By(t);return null===i?null:e+" "+i[0]},Vy=function(t){if(!Ly(t))return null;var e=Dy(t,Oy);return Fy(e)},Uy=function(t){var e=Ny(t);if(null===e)return null;var i=e.match(Ey);return null===i?e:i[1]},Xy=function(t){var e=Ny(t);return null===e||null===e.match(Ey)?null:e},Ky=g`@charset "UTF-8";
6548
6553
  .govuk-link {
6549
6554
  font-family: "GDS Transport", arial, sans-serif;
6550
6555
  -webkit-font-smoothing: antialiased;
@@ -6522,14 +6522,18 @@ x:-moz-any-link {
6522
6522
  :host .govuk-label {
6523
6523
  font-family: var(--autocomplete__font-family, "GDS Transport", arial, sans-serif);
6524
6524
  }
6525
+ :host .govuk-label--static {
6526
+ font-size: var(--autocomplete__label__font-size, 19px);
6527
+ }
6525
6528
  :host .autocomplete__input {
6526
6529
  font-family: var(--autocomplete__font-family, "GDS Transport", arial, sans-serif);
6527
6530
  font-size: var(--autocomplete__input__font-size, 19px);
6528
6531
  height: var(--autocomplete__input__height, 35px);
6529
6532
  padding: var(--autocomplete__input__padding, 5px 34px 5px 5px);
6533
+ z-index: calc(var(--autocomplete__dropdown-arrow-down__z-index, 1) + 1);
6530
6534
  }
6531
6535
  :host .autocomplete__dropdown-arrow-down {
6532
- z-index: var(--autocomplete__dropdown-arrow-down__z-index, -1);
6536
+ z-index: var(--autocomplete__dropdown-arrow-down__z-index, 1);
6533
6537
  top: calc((var(--autocomplete__input__height, 35px) - 17px) / 2);
6534
6538
  }
6535
6539
  :host .autocomplete__option {
@@ -6538,13 +6542,14 @@ x:-moz-any-link {
6538
6542
  padding: var(--autocomplete__option__padding, 5px);
6539
6543
  border-bottom: var(--autocomplete__option__border-bottom, solid 1px #b1b4b6);
6540
6544
  }
6541
- :host .autocomplete__option:hover, :host .autocomplete__option:focus {
6545
+ :host .autocomplete__option--focused,
6546
+ :host .autocomplete__option:hover, .autocomplete__option--focused :host .autocomplete__option:hover {
6542
6547
  border-color: var(--autocomplete__option__hover-border-color, #1d70b8);
6543
6548
  background-color: var(--autocomplete__option__hover-background-color, #1d70b8);
6544
6549
  }
6545
6550
  :host .autocomplete__menu {
6546
6551
  max-height: var(--autocomplete__menu__max-height, 342px);
6547
- }`,My=Object.freeze,Ay=Object.defineProperty,Dy=Object.getOwnPropertyDescriptor,Ly=(t,e,i,o)=>{for(var n,r=o>1?void 0:o?Dy(e,i):e,a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o?n(e,i,r):n(r))||r);return o&&r&&Ay(e,i,r),r},Gy=(t,e)=>My(Ay(t,"raw",{value:My(e||t.slice())}));t.AddressAutocomplete=class extends nt{constructor(){super(...arguments),this.id="autocomplete",this.postcode="SE5 0HU",this.label="Select an address",this.initialAddress="",this.osPlacesApiKey="",this._totalAddresses=void 0,this._addressesInPostcode=[],this._options=[],this._selectedAddress=null,this._osError=void 0,this.dispatch=(t,e)=>this.dispatchEvent(new CustomEvent(t,{detail:e}))}connectedCallback(){super.connectedCallback(),this._fetchData()}disconnectedCallback(){super.disconnectedCallback()}firstUpdated(){Iy({element:this.renderRoot.querySelector(`#${this.id}-container`),id:this.id,required:!0,source:this._options,defaultValue:this.initialAddress,showAllValues:!0,displayMenu:"overlay",tNoResults:()=>"No addresses found",onConfirm:t=>{this._selectedAddress=this._addressesInPostcode.filter((e=>e.LPI.ADDRESS.split(`, ${e.LPI.ADMINISTRATIVE_AREA}`)[0]===t))[0],this._selectedAddress&&this.dispatch("addressSelection",{address:this._selectedAddress})}})}async _fetchData(t=0,e=[]){const i={postcode:this.postcode,dataset:"LPI",maxResults:"100",output_srs:"EPSG:4326",lr:"EN",key:this.osPlacesApiKey},o=`https://api.os.uk/search/places/v1/postcode?${new URLSearchParams(i)}`;await fetch(o+`&offset=${t}`).then((t=>t.json())).then((t=>{var i,o,n;(t.error||t.fault)&&(this._osError=(null==(i=t.error)?void 0:i.message)||(null==(o=t.fault)?void 0:o.faultstring)||"Something went wrong"),this._totalAddresses=null==(n=t.header)?void 0:n.totalresults;const r=e.concat(t.results||[]);if(this._addressesInPostcode=r,this.dispatch("ready",{postcode:this.postcode,status:`fetched ${this._addressesInPostcode.length}/${this._totalAddresses} addresses`}),t.results){t.results.filter((t=>"APPROVED"===t.LPI.LPI_LOGICAL_STATUS_CODE_DESCRIPTION)).map((t=>{this._options.push(t.LPI.ADDRESS.split(`, ${t.LPI.ADMINISTRATIVE_AREA}`)[0])}));const e=new Intl.Collator([],{numeric:!0});this._options.sort(((t,i)=>e.compare(t,i)))}this._totalAddresses&&this._totalAddresses>this._addressesInPostcode.length&&this._fetchData(this._addressesInPostcode.length,this._addressesInPostcode)})).catch((t=>console.log(t)))}render(){let t;return this.osPlacesApiKey?this._osError?t=this._osError:0===this._totalAddresses&&(t=`No addresses found in postcode ${this.postcode}`):t="Missing OS Places API key",t?D(jy||(jy=Gy(['<script src="https://cdn.polyfill.io/v2/polyfill.min.js"><\/script>\n <div class="govuk-warning-text" role="status">\n <span class="govuk-warning-text__icon" aria-hidden="true">!</span>\n <strong class="govuk-warning-text__text">\n <span class="govuk-warning-text__assistive">Warning</span>\n ',"\n </strong>\n </div>"])),t):D(Ry||(Ry=Gy(['<script src="https://cdn.polyfill.io/v2/polyfill.min.js"><\/script>\n <link\n rel="stylesheet"\n href="https://cdn.jsdelivr.net/npm/accessible-autocomplete@2.0.4/dist/accessible-autocomplete.min.css"\n />\n <label class="govuk-label" htmlFor=',">",'</label>\n <div\n id="','-container"\n role="status"\n spellcheck="false"\n ></div>'])),this.id,this.label,this.id)}},t.AddressAutocomplete.styles=a(Fy),Ly([st({type:String})],t.AddressAutocomplete.prototype,"id",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"postcode",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"label",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"initialAddress",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"osPlacesApiKey",2),Ly([lt()],t.AddressAutocomplete.prototype,"_totalAddresses",2),Ly([lt()],t.AddressAutocomplete.prototype,"_addressesInPostcode",2),Ly([lt()],t.AddressAutocomplete.prototype,"_options",2),Ly([lt()],t.AddressAutocomplete.prototype,"_selectedAddress",2),Ly([lt()],t.AddressAutocomplete.prototype,"_osError",2),t.AddressAutocomplete=Ly([rt("address-autocomplete")],t.AddressAutocomplete);var Ny,By=function(){return(By=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},qy=/^([a-z]{1,2}\d)([a-z])$/i,Wy=/[a-z]{2}$/i,Vy=/\d[a-z]{2}$/i,Uy=/^[a-z]{1,2}\d[a-z\d]?\s*\d[a-z]{2}$/i,Xy=/^[a-z]{1,2}/i,Ky={valid:!1,postcode:null,incode:null,outcode:null,area:null,district:null,subDistrict:null,sector:null,unit:null},Yy=function(t){return null===t?null:t[0]},Zy=/\s+/gi,$y=function(t){return t.replace(Zy,"").toUpperCase()},Hy=function(t,e){return $y(t).match(e)},Jy=function(t){return null!==t.match(Uy)},Qy=function(t){var e=t_(t);if(null===e)return null;var i=e_(t);return null===i?null:e+" "+i},t_=function(t){return Jy(t)?$y(t).replace(Vy,""):null},e_=function(t){if(!Jy(t))return null;var e=Hy(t,Vy);return Yy(e)},i_=function(t){if(!Jy(t))return null;var e=Hy(t,Xy);return Yy(e)},o_=function(t){var e=t_(t);if(null===e)return null;var i=e_(t);return null===i?null:e+" "+i[0]},n_=function(t){if(!Jy(t))return null;var e=Hy(t,Wy);return Yy(e)},r_=function(t){var e=t_(t);if(null===e)return null;var i=e.match(qy);return null===i?e:i[1]},a_=function(t){var e=t_(t);return null===e||null===e.match(qy)?null:e},s_=s`@charset "UTF-8";
6552
+ }`,My=Object.freeze,Ay=Object.defineProperty,Dy=Object.getOwnPropertyDescriptor,Ly=(t,e,i,o)=>{for(var n,r=o>1?void 0:o?Dy(e,i):e,a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o?n(e,i,r):n(r))||r);return o&&r&&Ay(e,i,r),r},Gy=(t,e)=>My(Ay(t,"raw",{value:My(e||t.slice())}));t.AddressAutocomplete=class extends nt{constructor(){super(...arguments),this.id="autocomplete",this.postcode="SE5 0HU",this.label="Select an address",this.initialAddress="",this.osPlacesApiKey="",this.arrowStyle="default",this.labelStyle="responsive",this._totalAddresses=void 0,this._addressesInPostcode=[],this._options=[],this._selectedAddress=null,this._osError=void 0,this.dispatch=(t,e)=>this.dispatchEvent(new CustomEvent(t,{detail:e}))}connectedCallback(){super.connectedCallback(),this._fetchData()}disconnectedCallback(){super.disconnectedCallback()}getLightDropdownArrow(){return'<svg class="autocomplete__dropdown-arrow-down" style="height: 17px;" viewBox="0 0 512 512" ><path d="M256,298.3L256,298.3L256,298.3l174.2-167.2c4.3-4.2,11.4-4.1,15.8,0.2l30.6,29.9c4.4,4.3,4.5,11.3,0.2,15.5L264.1,380.9 c-2.2,2.2-5.2,3.2-8.1,3c-3,0.1-5.9-0.9-8.1-3L35.2,176.7c-4.3-4.2-4.2-11.2,0.2-15.5L66,131.3c4.4-4.3,11.5-4.4,15.8-0.2L256,298.3 z"/></svg>'}firstUpdated(){Iy({element:this.renderRoot.querySelector(`#${this.id}-container`),id:this.id,required:!0,source:this._options,defaultValue:this.initialAddress,showAllValues:!0,displayMenu:"overlay",dropdownArrow:"light"===this.arrowStyle?this.getLightDropdownArrow:void 0,tNoResults:()=>"No addresses found",onConfirm:t=>{this._selectedAddress=this._addressesInPostcode.filter((e=>e.LPI.ADDRESS.split(`, ${e.LPI.ADMINISTRATIVE_AREA}`)[0]===t))[0],this._selectedAddress&&this.dispatch("addressSelection",{address:this._selectedAddress})}})}async _fetchData(t=0,e=[]){const i={postcode:this.postcode,dataset:"LPI",maxResults:"100",output_srs:"EPSG:4326",lr:"EN",key:this.osPlacesApiKey},o=`https://api.os.uk/search/places/v1/postcode?${new URLSearchParams(i)}`;await fetch(o+`&offset=${t}`).then((t=>t.json())).then((t=>{var i,o,n;(t.error||t.fault)&&(this._osError=(null==(i=t.error)?void 0:i.message)||(null==(o=t.fault)?void 0:o.faultstring)||"Something went wrong"),this._totalAddresses=null==(n=t.header)?void 0:n.totalresults;const r=e.concat(t.results||[]);if(this._addressesInPostcode=r,this.dispatch("ready",{postcode:this.postcode,status:`fetched ${this._addressesInPostcode.length}/${this._totalAddresses} addresses`}),t.results){t.results.filter((t=>"APPROVED"===t.LPI.LPI_LOGICAL_STATUS_CODE_DESCRIPTION)).map((t=>{this._options.push(t.LPI.ADDRESS.split(`, ${t.LPI.ADMINISTRATIVE_AREA}`)[0])}));const e=new Intl.Collator([],{numeric:!0});this._options.sort(((t,i)=>e.compare(t,i)))}this._totalAddresses&&this._totalAddresses>this._addressesInPostcode.length&&this._fetchData(this._addressesInPostcode.length,this._addressesInPostcode)})).catch((t=>console.log(t)))}_getLabelClasses(){let t="govuk-label";return"static"===this.labelStyle&&(t+=" govuk-label--static"),t}render(){let t;return this.osPlacesApiKey?this._osError?t=this._osError:0===this._totalAddresses&&(t=`No addresses found in postcode ${this.postcode}`):t="Missing OS Places API key",t?D(jy||(jy=Gy(['<script src="https://cdn.polyfill.io/v2/polyfill.min.js"><\/script>\n <div class="govuk-warning-text" role="status">\n <span class="govuk-warning-text__icon" aria-hidden="true">!</span>\n <strong class="govuk-warning-text__text">\n <span class="govuk-warning-text__assistive">Warning</span>\n ',"\n </strong>\n </div>"])),t):D(Ry||(Ry=Gy(['<script src="https://cdn.polyfill.io/v2/polyfill.min.js"><\/script>\n <link\n rel="stylesheet"\n href="https://cdn.jsdelivr.net/npm/accessible-autocomplete@2.0.4/dist/accessible-autocomplete.min.css"\n />\n <label class='," for=","\n >",'</label\n >\n <div id="','-container" spellcheck="false"></div>'])),this._getLabelClasses(),this.id,this.label,this.id)}},t.AddressAutocomplete.styles=a(Fy),Ly([st({type:String})],t.AddressAutocomplete.prototype,"id",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"postcode",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"label",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"initialAddress",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"osPlacesApiKey",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"arrowStyle",2),Ly([st({type:String})],t.AddressAutocomplete.prototype,"labelStyle",2),Ly([lt()],t.AddressAutocomplete.prototype,"_totalAddresses",2),Ly([lt()],t.AddressAutocomplete.prototype,"_addressesInPostcode",2),Ly([lt()],t.AddressAutocomplete.prototype,"_options",2),Ly([lt()],t.AddressAutocomplete.prototype,"_selectedAddress",2),Ly([lt()],t.AddressAutocomplete.prototype,"_osError",2),t.AddressAutocomplete=Ly([rt("address-autocomplete")],t.AddressAutocomplete);var Ny,By=function(){return(By=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},qy=/^([a-z]{1,2}\d)([a-z])$/i,Wy=/[a-z]{2}$/i,Vy=/\d[a-z]{2}$/i,Uy=/^[a-z]{1,2}\d[a-z\d]?\s*\d[a-z]{2}$/i,Xy=/^[a-z]{1,2}/i,Ky={valid:!1,postcode:null,incode:null,outcode:null,area:null,district:null,subDistrict:null,sector:null,unit:null},Yy=function(t){return null===t?null:t[0]},Zy=/\s+/gi,$y=function(t){return t.replace(Zy,"").toUpperCase()},Hy=function(t,e){return $y(t).match(e)},Jy=function(t){return null!==t.match(Uy)},Qy=function(t){var e=t_(t);if(null===e)return null;var i=e_(t);return null===i?null:e+" "+i},t_=function(t){return Jy(t)?$y(t).replace(Vy,""):null},e_=function(t){if(!Jy(t))return null;var e=Hy(t,Vy);return Yy(e)},i_=function(t){if(!Jy(t))return null;var e=Hy(t,Xy);return Yy(e)},o_=function(t){var e=t_(t);if(null===e)return null;var i=e_(t);return null===i?null:e+" "+i[0]},n_=function(t){if(!Jy(t))return null;var e=Hy(t,Wy);return Yy(e)},r_=function(t){var e=t_(t);if(null===e)return null;var i=e.match(qy);return null===i?e:i[1]},a_=function(t){var e=t_(t);return null===e||null===e.match(qy)?null:e},s_=s`@charset "UTF-8";
6548
6553
  .govuk-link {
6549
6554
  font-family: "GDS Transport", arial, sans-serif;
6550
6555
  -webkit-font-smoothing: antialiased;
package/dist/index.html CHANGED
@@ -15,7 +15,8 @@
15
15
  <!-- Examples of available style options for address-autocomplete -->
16
16
  <!-- <style>
17
17
  address-autocomplete {
18
- --autocomplete__input__padding: 6px 12px 7px 12px;
18
+ --autocomplete__label__font-size: 25px;
19
+ --autocomplete__input__padding: 6px 40px 7px 12px;
19
20
  --autocomplete__input__font-size: 15px;
20
21
  --autocomplete__input__height: 50px;
21
22
  --autocomplete__dropdown-arrow-down__top: 16px;
@@ -39,7 +40,7 @@
39
40
  <div style="margin-bottom:1em">
40
41
  <postcode-search hintText="Optional hint text shows up here" id="example-postcode" />
41
42
  </div>
42
- <div style="margin-bottom:1em;">
43
+ <div style="margin-bottom:1em; background-color: white;">
43
44
  <!--
44
45
  Examples (as of March 2022):
45
46
  SE5 OHU (Southwark): default/"standard" postcode example, fetches 65 LPI addresses
@@ -50,7 +51,7 @@
50
51
  Example with default value (used for planx "change" & "back" button behavior):
51
52
  <address-autocomplete postcode="SE5 0HU" id="example-autocomplete" initialAddress="75, COBOURG ROAD, LONDON" />
52
53
  -->
53
- <address-autocomplete postcode="SE5 0HU" id="example-autocomplete" />
54
+ <address-autocomplete postcode="SE5 0HU" id="example-autocomplete" arrowStyle="light" labelStyle="static"/>
54
55
  </div>
55
56
  </div>
56
57
  <script>