@ne1410s/address 0.0.204 → 0.0.206

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 CHANGED
@@ -1,21 +1,9 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 ne1410s
3
+ Copyright (c) 2026 ne1410s
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
6
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
8
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,66 +1,66 @@
1
- # @ne1410s/address
2
-
3
- ## An address lookup utility.
4
-
5
- ```html
6
- <ne14-address reveal="Hey!">
7
- <p>Hello world</p>
8
- </ne14-address>
9
- ```
10
-
11
- - **Use:** `<script src="PATH_TO_UMD_SCRIPT"></script>`
12
- - **Extend:** _npm i -S @ne1410s/address_
13
-
14
- ### Attributes
15
-
16
- ```html
17
- <ne14-address corner="3" reveal="Definition here">YO' STUFF</ne14-address>
18
- ```
19
-
20
- - **corner**: If specified, the reveal text is positioned in a corner of the screen:
21
- - 1: Top-left, 2: Top-right, 3: Bottom-right, 4: Bottom-left
22
- - **reveal**: The definition text that gets shown on hover
23
-
24
- ### Events
25
-
26
- ```javascript
27
- const address = document.querySelector('ne14-address');
28
-
29
- address.addEventListener('...', () => {
30
- console.log('Event fired!');
31
- });
32
- ```
33
-
34
- - _There are no bespoke events raised in the internal workings of this element_
35
-
36
- ### Methods
37
-
38
- - _There are no bespoke methods exposed in this element_
39
-
40
- ### Properties
41
-
42
- - `set` **corner** (number): Sets the attribute with the corresponding value
43
- - `set` **reveal** (string): Sets the attribute with the corresponding value
44
-
45
- ### CSS Variables
46
-
47
- Some degree of custom styling can be provided, by way of css variables:
48
-
49
- ```css
50
- ne14-address {
51
- --src-border: 1px solid green;
52
- --reveal-trg-bg: rebeccapurple;
53
- }
54
- ```
55
-
56
- - **`--src-border-radius`** _Source item border radius. Defaults to: `3px`_
57
- - **`--src-border`** _Source item border. Defaults to: `1px solid black`_
58
- - **`--src-bg`** _Source item background. Defaults to: `inherit`_
59
- - **`--src-fg`** _Source item foreground. Defaults to: `inherit`_
60
- - **`--trg-border-radius`** _Target item border radius. Defaults to: `3px`_
61
- - **`--reveal-src-border`** _Source item border (in reveal mode). Defaults to: `--src-border`_
62
- - **`--reveal-src-bg`** _Source item background (in reveal mode). Defaults to: `inherit`_
63
- - **`--reveal-src-fg`** _Source item foreground (in reveal mode). Defaults to: `inherit`_
64
- - **`--reveal-trg-border`** _Target item border (in reveal mode). Defaults to: `1px solid black`_
65
- - **`--reveal-trg-bg`** _Target item background (in reveal mode). Defaults to: `white`_
66
- - **`--reveal-trg-fg`** _Target item foreground (in reveal mode). Defaults to: `inherit`_
1
+ # @ne1410s/address
2
+
3
+ ## An address lookup utility.
4
+
5
+ ```html
6
+ <ne14-address reveal="Hey!">
7
+ <p>Hello world</p>
8
+ </ne14-address>
9
+ ```
10
+
11
+ - **Use:** `<script src="PATH_TO_UMD_SCRIPT"></script>`
12
+ - **Extend:** _npm i -S @ne1410s/address_
13
+
14
+ ### Attributes
15
+
16
+ ```html
17
+ <ne14-address corner="3" reveal="Definition here">YO' STUFF</ne14-address>
18
+ ```
19
+
20
+ - **corner**: If specified, the reveal text is positioned in a corner of the screen:
21
+ - 1: Top-left, 2: Top-right, 3: Bottom-right, 4: Bottom-left
22
+ - **reveal**: The definition text that gets shown on hover
23
+
24
+ ### Events
25
+
26
+ ```javascript
27
+ const address = document.querySelector('ne14-address');
28
+
29
+ address.addEventListener('...', () => {
30
+ console.log('Event fired!');
31
+ });
32
+ ```
33
+
34
+ - _There are no bespoke events raised in the internal workings of this element_
35
+
36
+ ### Methods
37
+
38
+ - _There are no bespoke methods exposed in this element_
39
+
40
+ ### Properties
41
+
42
+ - `set` **corner** (number): Sets the attribute with the corresponding value
43
+ - `set` **reveal** (string): Sets the attribute with the corresponding value
44
+
45
+ ### CSS Variables
46
+
47
+ Some degree of custom styling can be provided, by way of css variables:
48
+
49
+ ```css
50
+ ne14-address {
51
+ --src-border: 1px solid green;
52
+ --reveal-trg-bg: rebeccapurple;
53
+ }
54
+ ```
55
+
56
+ - **`--src-border-radius`** _Source item border radius. Defaults to: `3px`_
57
+ - **`--src-border`** _Source item border. Defaults to: `1px solid black`_
58
+ - **`--src-bg`** _Source item background. Defaults to: `inherit`_
59
+ - **`--src-fg`** _Source item foreground. Defaults to: `inherit`_
60
+ - **`--trg-border-radius`** _Target item border radius. Defaults to: `3px`_
61
+ - **`--reveal-src-border`** _Source item border (in reveal mode). Defaults to: `--src-border`_
62
+ - **`--reveal-src-bg`** _Source item background (in reveal mode). Defaults to: `inherit`_
63
+ - **`--reveal-src-fg`** _Source item foreground (in reveal mode). Defaults to: `inherit`_
64
+ - **`--reveal-trg-border`** _Target item border (in reveal mode). Defaults to: `1px solid black`_
65
+ - **`--reveal-trg-bg`** _Target item background (in reveal mode). Defaults to: `white`_
66
+ - **`--reveal-trg-fg`** _Target item foreground (in reveal mode). Defaults to: `inherit`_
@@ -1,10 +1,9 @@
1
- import { CustomElementBase } from '@ne1410s/cust-elems';
2
- export declare class AddressLookup extends CustomElementBase {
3
- private static readonly Css;
4
- private static readonly Html;
1
+ export declare class AddressLookup extends HTMLElement {
2
+ private readonly root;
5
3
  private addressCompleter;
6
4
  constructor();
7
5
  initialise(): void;
8
6
  private onPlaceChanged;
9
7
  private getMatchingFieldId;
10
8
  }
9
+ //# sourceMappingURL=address-lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-lookup.d.ts","sourceRoot":"","sources":["../../src/address-lookup/address-lookup.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,gBAAgB,CAA0C;IAElE,cAOC;IAEM,UAAU,SAShB;IAED,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,kBAAkB;CAoB3B"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { AddressLookup } from './address-lookup/address-lookup';
2
2
  export { AddressLookup };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAwBhE,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ "use strict";var ne_address=(()=>{var n=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var m=(s,t)=>{for(var e in t)n(s,e,{get:t[e],enumerable:!0})},f=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of p(t))!u.call(s,a)&&a!==e&&n(s,a,{get:()=>t[a],enumerable:!(o=d(t,a))||o.enumerable});return s};var b=s=>f(n({},"__esModule",{value:!0}),s);var y={};m(y,{AddressLookup:()=>l});var r="html{font-family:Calibri}";var i='<span class="root"><form action="" method="get" autocomplete="off"><label class="super-slim-field-left"><span class="form-label">No.*</span> <input id="house-number" name="house-number" required></label> <label class="field-right"><span class="form-label">Street*</span> <input id="street" name="street" required autocomplete="off" placeholder="Type your address..."></label> <label class="full-field"><span class="form-label">Address Line 2</span> <input id="address2" name="address2"></label> <label class="full-field"><span class="form-label">Town / City*</span> <input id="town" name="town" required></label> <label class="slim-field-left"><span class="form-label">County*</span> <input id="county" name="county" required></label> <label class="field-right"><span class="form-label">Postcode*</span> <input id="postcode" name="postcode" required></label> <label class="full-field"><span class="form-label">Country*</span> <input id="country" name="country" required></label> <button type="button" class="my-button">Save address</button> <input type="reset" value="Clear form"></form></span>';var l=class extends HTMLElement{constructor(){super();this.addressCompleter=null;this.root=this.attachShadow({mode:"open"});let e=new CSSStyleSheet;e.replaceSync(r),this.shadowRoot.adoptedStyleSheets=[e],this.shadowRoot.innerHTML=i}initialise(){let e=this.root.querySelector("#street");this.addressCompleter=new google.maps.places.Autocomplete(e,{componentRestrictions:{country:["uk"]},fields:["address_components"],types:["address"]}),this.addressCompleter.addListener("place_changed",this.onPlaceChanged)}onPlaceChanged(){let e=this.addressCompleter.getPlace();for(let o of e.address_components){let a=this.getMatchingFieldId(o.types[0]);if(a){let c=document.querySelector(a);c.value=o.long_name}}}getMatchingFieldId(e){switch(e){case"street_number":return"#house-number";case"route":return"#street";case"postal_code":return"#postcode";case"locality":return"#town";case"postal_town":return"#town";case"administrative_area_level_2":return"#county";case"country":return"#country";default:return""}}};if("customElements"in window&&!window.customElements.get("ne14-address")){window.customElements.define("ne14-address",l);let s="AIzaSyDcwGyRxRbcNGWOFQVT87A1mkxEOfm8t0w",t="apiCallback",e=`https://maps.googleapis.com/maps/api/js?key=${s}&callback=${t}&libraries=places&v=weekly`,o=document.createElement("script");o.setAttribute("async",""),o.setAttribute("src",e),window[t]=()=>{Array.from(document.querySelectorAll("ne14-address")).forEach(a=>{a.initialise()})},window.addEventListener("load",()=>document.body.appendChild(o))}return b(y);})();
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var n="html{font-family:Calibri}";var r='<span class="root"><form action="" method="get" autocomplete="off"><label class="super-slim-field-left"><span class="form-label">No.*</span> <input id="house-number" name="house-number" required></label> <label class="field-right"><span class="form-label">Street*</span> <input id="street" name="street" required autocomplete="off" placeholder="Type your address..."></label> <label class="full-field"><span class="form-label">Address Line 2</span> <input id="address2" name="address2"></label> <label class="full-field"><span class="form-label">Town / City*</span> <input id="town" name="town" required></label> <label class="slim-field-left"><span class="form-label">County*</span> <input id="county" name="county" required></label> <label class="field-right"><span class="form-label">Postcode*</span> <input id="postcode" name="postcode" required></label> <label class="full-field"><span class="form-label">Country*</span> <input id="country" name="country" required></label> <button type="button" class="my-button">Save address</button> <input type="reset" value="Clear form"></form></span>';var a=class extends HTMLElement{constructor(){super();this.addressCompleter=null;this.root=this.attachShadow({mode:"open"});let e=new CSSStyleSheet;e.replaceSync(n),this.shadowRoot.adoptedStyleSheets=[e],this.shadowRoot.innerHTML=r}initialise(){let e=this.root.querySelector("#street");this.addressCompleter=new google.maps.places.Autocomplete(e,{componentRestrictions:{country:["uk"]},fields:["address_components"],types:["address"]}),this.addressCompleter.addListener("place_changed",this.onPlaceChanged)}onPlaceChanged(){let e=this.addressCompleter.getPlace();for(let t of e.address_components){let s=this.getMatchingFieldId(t.types[0]);if(s){let i=document.querySelector(s);i.value=t.long_name}}}getMatchingFieldId(e){switch(e){case"street_number":return"#house-number";case"route":return"#street";case"postal_code":return"#postcode";case"locality":return"#town";case"postal_town":return"#town";case"administrative_area_level_2":return"#county";case"country":return"#country";default:return""}}};if("customElements"in window&&!window.customElements.get("ne14-address")){window.customElements.define("ne14-address",a);let l="AIzaSyDcwGyRxRbcNGWOFQVT87A1mkxEOfm8t0w",o="apiCallback",e=`https://maps.googleapis.com/maps/api/js?key=${l}&callback=${o}&libraries=places&v=weekly`,t=document.createElement("script");t.setAttribute("async",""),t.setAttribute("src",e),window[o]=()=>{Array.from(document.querySelectorAll("ne14-address")).forEach(s=>{s.initialise()})},window.addEventListener("load",()=>document.body.appendChild(t))}export{a as AddressLookup};
package/package.json CHANGED
@@ -1,55 +1,71 @@
1
- {
2
- "name": "@ne1410s/address",
3
- "version": "0.0.204",
4
- "description": "An address lookup tool.",
5
- "main": "dist/ne14_address.cjs.min.js",
6
- "module": "dist/ne14_address.esm.min.js",
7
- "browser": "dist/ne14_address.umd.min.js",
8
- "displayName": "ne_address",
9
- "types": "dist/index.d.ts",
10
- "files": [
11
- "dist"
12
- ],
13
- "scripts": {
14
- "dev": "npx rollup -c rollup.browser.config.js -m -w",
15
- "clean": "npx rimraf dist",
16
- "is-pretty": "npx prettier -l .",
17
- "prettify": "npx prettier -w .",
18
- "build": "npm run clean && npx rollup -c",
19
- "test": "npm run is-pretty",
20
- "publish-local": "npm run test && npm run build && npm pack",
21
- "publish-patch": "npm run test && npm run build && npm version patch && npm publish --access public",
22
- "publish-minor": "npm run test && npm run build && npm version minor && npm publish --access public",
23
- "publish-major": "npm run test && npm run build && npm version major && npm publish --access public"
24
- },
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/ne14-fed/elem.address.git"
28
- },
29
- "keywords": [
30
- "ES",
31
- "address",
32
- "lookup"
33
- ],
34
- "author": "ne1410s <pgj646@gmail.com> (http://ne1410s.co.uk)",
35
- "license": "MIT",
36
- "bugs": {
37
- "url": "https://github.com/ne14-fed/elem.address/issues"
38
- },
39
- "homepage": "https://github.com/ne14-fed/elem.address#readme",
40
- "devDependencies": {
41
- "@rollup/plugin-commonjs": "^25.0.8",
42
- "@rollup/plugin-json": "^6.1.0",
43
- "@rollup/plugin-node-resolve": "^15.3.1",
44
- "@rollup/plugin-url": "^8.0.2",
45
- "@types/google.maps": "^3.58.1",
46
- "prettier": "^3.7.4",
47
- "rimraf": "^5.0.10",
48
- "rollup": "^4.53.5",
49
- "rollup-plugin-typescript2": "^0.36.0",
50
- "typescript": "^5.9.3"
51
- },
52
- "dependencies": {
53
- "@ne1410s/cust-elems": "^0.3.167"
54
- }
55
- }
1
+ {
2
+ "name": "@ne1410s/address",
3
+ "version": "0.0.206",
4
+ "displayName": "ne_address",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./iife": "./dist/index.iife.js"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "description": "A popup html element",
20
+ "author": "ne1410s <pgj646@gmail.com> (http://ne1410s.co.uk)",
21
+ "keywords": [
22
+ "popup",
23
+ "element"
24
+ ],
25
+ "homepage": "https://github.com/ne14-fed/elem.popup#readme",
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/ne14-fed/elem.popup.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/ne14-fed/elem.popup/issues"
33
+ },
34
+ "engines": {
35
+ "node": ">=20"
36
+ },
37
+ "scripts": {
38
+ "dev": "npm link && concurrently \"npm run build:watch\" \"npm run demo:iife\" \"npm run demo:vite\"",
39
+ "clean": "del-cli dist",
40
+ "is-pretty": "prettier -l .",
41
+ "prettify": "prettier -w .",
42
+ "build": "npm run clean && tsc && node esbuild.mjs",
43
+ "build:watch": "concurrently \"tsc --watch\" \"node esbuild.mjs --watch\"",
44
+ "demo:vite": "cd demo/vite && npm i && npm link @ne1410s/address && npx vite",
45
+ "demo:iife": "npx live-server demo/iife --mount=/package:dist --no-css-inject",
46
+ "test": "npm run typecheck && npm run is-pretty",
47
+ "typecheck": "tsc --noEmit",
48
+ "publish-local": "npm run build && npm pack",
49
+ "publish-patch": "npm run build && npm version patch && npm publish --access public",
50
+ "publish-minor": "npm run build && npm version minor && npm publish --access public",
51
+ "publish-major": "npm run build && npm version major && npm publish --access public"
52
+ },
53
+ "devDependencies": {
54
+ "@types/google.maps": "^3.65.5",
55
+ "clean-css": "^5.3.3",
56
+ "concurrently": "^10.0.4",
57
+ "del-cli": "^7.0.0",
58
+ "esbuild": "^0.28.2",
59
+ "esbuild-sass-plugin": "^3.7.0",
60
+ "html-minifier-terser": "^7.2.0",
61
+ "prettier": "^3.9.6",
62
+ "typescript": "^7.0.2"
63
+ },
64
+ "dependencies": {
65
+ "@ne1410s/cust-elems": "^0.3.168"
66
+ },
67
+ "allowScripts": {
68
+ "esbuild@0.28.2": true,
69
+ "@parcel/watcher@2.6.0": true
70
+ }
71
+ }
@@ -1,76 +0,0 @@
1
- 'use strict';
2
-
3
- var custElems = require('@ne1410s/cust-elems');
4
-
5
- var markupUrl = "data:text/html;base64,PHNwYW4gY2xhc3M9InJvb3QiPg0KICA8Zm9ybSBhY3Rpb249IiIgbWV0aG9kPSJnZXQiIGF1dG9jb21wbGV0ZT0ib2ZmIj4NCiAgICA8bGFiZWwgY2xhc3M9InN1cGVyLXNsaW0tZmllbGQtbGVmdCI+DQogICAgICA8c3BhbiBjbGFzcz0iZm9ybS1sYWJlbCI+Tm8uKjwvc3Bhbj4NCiAgICAgIDx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hc3M9ImZvcm0tbGFiZWwiPlBvc3Rjb2RlKjwvc3Bhbj4NCiAgICAgIDxpbnB1dCBpZD0icG9zdGNvZGUiIG5hbWU9InBvc3Rjb2RlIiByZXF1aXJlZCAvPg0KICAgIDwvbGFiZWw+DQogICAgPGxhYmVsIGNsYXNzPSJmdWxsLWZpZWxkIj4NCiAgICAgIDxzcGFuIGNsYXNzPSJmb3JtLWxhYmVsIj5Db3VudHJ5Kjwvc3Bhbj4NCiAgICAgIDxpbnB1dCBpZD0iY291bnRyeSIgbmFtZT0iY291bnRyeSIgcmVxdWlyZWQgLz4NCiAgICA8L2xhYmVsPg0KICAgIDxidXR0b24gdHlwZT0iYnV0dG9uIiBjbGFzcz0ibXktYnV0dG9uIj5TYXZlIGFkZHJlc3M8L2J1dHRvbj4NCiAgICA8aW5wdXQgdHlwZT0icmVzZXQiIHZhbHVlPSJDbGVhciBmb3JtIiAvPg0KICA8L2Zvcm0+DQo8L3NwYW4+DQo=";
6
-
7
- var stylesUrl = "data:text/css;base64,";
8
-
9
- class AddressLookup extends custElems.CustomElementBase {
10
- constructor() {
11
- super(AddressLookup.Css, AddressLookup.Html);
12
- }
13
- initialise() {
14
- const searchBox = this.root.querySelector('#street');
15
- this.addressCompleter = new google.maps.places.Autocomplete(searchBox, {
16
- componentRestrictions: { country: ['uk'] },
17
- fields: ['address_components'],
18
- types: ['address'],
19
- });
20
- this.addressCompleter.addListener('place_changed', this.onPlaceChanged);
21
- }
22
- onPlaceChanged() {
23
- const place = this.addressCompleter.getPlace();
24
- for (const component of place.address_components) {
25
- const inputFieldId = this.getMatchingFieldId(component.types[0]);
26
- if (inputFieldId) {
27
- const input = document.querySelector(inputFieldId);
28
- input.value = component.long_name;
29
- }
30
- }
31
- }
32
- getMatchingFieldId(componentType) {
33
- switch (componentType) {
34
- case 'street_number':
35
- return '#house-number';
36
- case 'route':
37
- return '#street';
38
- case 'postal_code':
39
- return '#postcode';
40
- case 'locality':
41
- return '#town';
42
- case 'postal_town':
43
- return '#town';
44
- case 'administrative_area_level_2':
45
- return '#county';
46
- case 'country':
47
- return '#country';
48
- default:
49
- return '';
50
- }
51
- }
52
- }
53
- AddressLookup.Css = custElems.reduceCss(custElems.decode(stylesUrl));
54
- AddressLookup.Html = custElems.reduceHtml(custElems.decode(markupUrl));
55
-
56
- // If custom elements is supported
57
- if ('customElements' in window) {
58
- // If not already defined
59
- if (!window.customElements.get('ne14-address')) {
60
- window.customElements.define('ne14-address', AddressLookup);
61
- const apiKey = 'AIzaSyDcwGyRxRbcNGWOFQVT87A1mkxEOfm8t0w';
62
- const callback = 'apiCallback'; // `ne_address.${AddressLookup.name}.${AddressLookup.Cb.name}`;
63
- const mapsScriptUrl = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=${callback}&libraries=places&v=weekly`;
64
- const mapsScript = document.createElement('script');
65
- mapsScript.setAttribute('async', '');
66
- mapsScript.setAttribute('src', mapsScriptUrl);
67
- window[callback] = () => {
68
- Array.from(document.querySelectorAll('ne14-address')).forEach((el) => {
69
- el.initialise();
70
- });
71
- };
72
- window.addEventListener('load', () => document.body.appendChild(mapsScript));
73
- }
74
- }
75
-
76
- exports.AddressLookup = AddressLookup;
@@ -1,74 +0,0 @@
1
- import { reduceCss, decode, reduceHtml, CustomElementBase } from '@ne1410s/cust-elems';
2
-
3
- var markupUrl = "data:text/html;base64,PHNwYW4gY2xhc3M9InJvb3QiPg0KICA8Zm9ybSBhY3Rpb249IiIgbWV0aG9kPSJnZXQiIGF1dG9jb21wbGV0ZT0ib2ZmIj4NCiAgICA8bGFiZWwgY2xhc3M9InN1cGVyLXNsaW0tZmllbGQtbGVmdCI+DQogICAgICA8c3BhbiBjbGFzcz0iZm9ybS1sYWJlbCI+Tm8uKjwvc3Bhbj4NCiAgICAgIDxpbnB1dCBpZD0iaG91c2UtbnVtYmVyIiBuYW1lPSJob3VzZS1udW1iZXIiIHJlcXVpcmVkIC8+DQogICAgPC9sYWJlbD4NCiAgICA8bGFiZWwgY2xh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1aXJlZCAvPg0KICAgIDwvbGFiZWw+DQogICAgPGxhYmVsIGNsYXNzPSJmdWxsLWZpZWxkIj4NCiAgICAgIDxzcGFuIGNsYXNzPSJmb3JtLWxhYmVsIj5Db3VudHJ5Kjwvc3Bhbj4NCiAgICAgIDxpbnB1dCBpZD0iY291bnRyeSIgbmFtZT0iY291bnRyeSIgcmVxdWlyZWQgLz4NCiAgICA8L2xhYmVsPg0KICAgIDxidXR0b24gdHlwZT0iYnV0dG9uIiBjbGFzcz0ibXktYnV0dG9uIj5TYXZlIGFkZHJlc3M8L2J1dHRvbj4NCiAgICA8aW5wdXQgdHlwZT0icmVzZXQiIHZhbHVlPSJDbGVhciBmb3JtIiAvPg0KICA8L2Zvcm0+DQo8L3NwYW4+DQo=";
4
-
5
- var stylesUrl = "data:text/css;base64,";
6
-
7
- class AddressLookup extends CustomElementBase {
8
- constructor() {
9
- super(AddressLookup.Css, AddressLookup.Html);
10
- }
11
- initialise() {
12
- const searchBox = this.root.querySelector('#street');
13
- this.addressCompleter = new google.maps.places.Autocomplete(searchBox, {
14
- componentRestrictions: { country: ['uk'] },
15
- fields: ['address_components'],
16
- types: ['address'],
17
- });
18
- this.addressCompleter.addListener('place_changed', this.onPlaceChanged);
19
- }
20
- onPlaceChanged() {
21
- const place = this.addressCompleter.getPlace();
22
- for (const component of place.address_components) {
23
- const inputFieldId = this.getMatchingFieldId(component.types[0]);
24
- if (inputFieldId) {
25
- const input = document.querySelector(inputFieldId);
26
- input.value = component.long_name;
27
- }
28
- }
29
- }
30
- getMatchingFieldId(componentType) {
31
- switch (componentType) {
32
- case 'street_number':
33
- return '#house-number';
34
- case 'route':
35
- return '#street';
36
- case 'postal_code':
37
- return '#postcode';
38
- case 'locality':
39
- return '#town';
40
- case 'postal_town':
41
- return '#town';
42
- case 'administrative_area_level_2':
43
- return '#county';
44
- case 'country':
45
- return '#country';
46
- default:
47
- return '';
48
- }
49
- }
50
- }
51
- AddressLookup.Css = reduceCss(decode(stylesUrl));
52
- AddressLookup.Html = reduceHtml(decode(markupUrl));
53
-
54
- // If custom elements is supported
55
- if ('customElements' in window) {
56
- // If not already defined
57
- if (!window.customElements.get('ne14-address')) {
58
- window.customElements.define('ne14-address', AddressLookup);
59
- const apiKey = 'AIzaSyDcwGyRxRbcNGWOFQVT87A1mkxEOfm8t0w';
60
- const callback = 'apiCallback'; // `ne_address.${AddressLookup.name}.${AddressLookup.Cb.name}`;
61
- const mapsScriptUrl = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=${callback}&libraries=places&v=weekly`;
62
- const mapsScript = document.createElement('script');
63
- mapsScript.setAttribute('async', '');
64
- mapsScript.setAttribute('src', mapsScriptUrl);
65
- window[callback] = () => {
66
- Array.from(document.querySelectorAll('ne14-address')).forEach((el) => {
67
- el.initialise();
68
- });
69
- };
70
- window.addEventListener('load', () => document.body.appendChild(mapsScript));
71
- }
72
- }
73
-
74
- export { AddressLookup };
@@ -1,105 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ne_address = {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- class CustomElementBase extends HTMLElement {
8
- constructor(css, html, mode = 'closed') {
9
- super();
10
- this.root = this.attachShadow({ mode });
11
- this.root.innerHTML = html;
12
- const style = document.createElement('style');
13
- style.textContent = css;
14
- this.root.appendChild(style);
15
- }
16
- }
17
-
18
- function decode(b64) {
19
- const bIndex = (b64 + '').indexOf('base64,');
20
- return bIndex === -1 ? b64 : window.atob(b64.substring(bIndex + 7));
21
- }
22
- function reduceCss(cssIn) {
23
- return cssIn
24
- .replace(/\s+/g, ' ')
25
- .replace(/([,{}:;])\s/g, '$1')
26
- .replace(/\s([{])/g, '$1');
27
- }
28
- function reduceHtml(htmlIn) {
29
- return htmlIn.replace(/\s+/g, ' ').replace(/(^|>)\s+(<|$)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sPg0KICAgIDxsYWJlbCBjbGFzcz0ic2xpbS1maWVsZC1sZWZ0Ij4NCiAgICAgIDxzcGFuIGNsYXNzPSJmb3JtLWxhYmVsIj5Db3VudHkqPC9zcGFuPg0KICAgICAgPGlucHV0IGlkPSJjb3VudHkiIG5hbWU9ImNvdW50eSIgcmVxdWlyZWQgLz4NCiAgICA8L2xhYmVsPg0KICAgIDxsYWJlbCBjbGFzcz0iZmllbGQtcmlnaHQiPg0KICAgICAgPHNwYW4gY2xhc3M9ImZvcm0tbGFiZWwiPlBvc3Rjb2RlKjwvc3Bhbj4NCiAgICAgIDxpbnB1dCBpZD0icG9zdGNvZGUiIG5hbWU9InBvc3Rjb2RlIiByZXF1aXJlZCAvPg0KICAgIDwvbGFiZWw+DQogICAgPGxhYmVsIGNsYXNzPSJmdWxsLWZpZWxkIj4NCiAgICAgIDxzcGFuIGNsYXNzPSJmb3JtLWxhYmVsIj5Db3VudHJ5Kjwvc3Bhbj4NCiAgICAgIDxpbnB1dCBpZD0iY291bnRyeSIgbmFtZT0iY291bnRyeSIgcmVxdWlyZWQgLz4NCiAgICA8L2xhYmVsPg0KICAgIDxidXR0b24gdHlwZT0iYnV0dG9uIiBjbGFzcz0ibXktYnV0dG9uIj5TYXZlIGFkZHJlc3M8L2J1dHRvbj4NCiAgICA8aW5wdXQgdHlwZT0icmVzZXQiIHZhbHVlPSJDbGVhciBmb3JtIiAvPg0KICA8L2Zvcm0+DQo8L3NwYW4+DQo=";
33
-
34
- var stylesUrl = "data:text/css;base64,";
35
-
36
- class AddressLookup extends CustomElementBase {
37
- constructor() {
38
- super(AddressLookup.Css, AddressLookup.Html);
39
- }
40
- initialise() {
41
- const searchBox = this.root.querySelector('#street');
42
- this.addressCompleter = new google.maps.places.Autocomplete(searchBox, {
43
- componentRestrictions: { country: ['uk'] },
44
- fields: ['address_components'],
45
- types: ['address'],
46
- });
47
- this.addressCompleter.addListener('place_changed', this.onPlaceChanged);
48
- }
49
- onPlaceChanged() {
50
- const place = this.addressCompleter.getPlace();
51
- for (const component of place.address_components) {
52
- const inputFieldId = this.getMatchingFieldId(component.types[0]);
53
- if (inputFieldId) {
54
- const input = document.querySelector(inputFieldId);
55
- input.value = component.long_name;
56
- }
57
- }
58
- }
59
- getMatchingFieldId(componentType) {
60
- switch (componentType) {
61
- case 'street_number':
62
- return '#house-number';
63
- case 'route':
64
- return '#street';
65
- case 'postal_code':
66
- return '#postcode';
67
- case 'locality':
68
- return '#town';
69
- case 'postal_town':
70
- return '#town';
71
- case 'administrative_area_level_2':
72
- return '#county';
73
- case 'country':
74
- return '#country';
75
- default:
76
- return '';
77
- }
78
- }
79
- }
80
- AddressLookup.Css = reduceCss(decode(stylesUrl));
81
- AddressLookup.Html = reduceHtml(decode(markupUrl));
82
-
83
- // If custom elements is supported
84
- if ('customElements' in window) {
85
- // If not already defined
86
- if (!window.customElements.get('ne14-address')) {
87
- window.customElements.define('ne14-address', AddressLookup);
88
- const apiKey = 'AIzaSyDcwGyRxRbcNGWOFQVT87A1mkxEOfm8t0w';
89
- const callback = 'apiCallback'; // `ne_address.${AddressLookup.name}.${AddressLookup.Cb.name}`;
90
- const mapsScriptUrl = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=${callback}&libraries=places&v=weekly`;
91
- const mapsScript = document.createElement('script');
92
- mapsScript.setAttribute('async', '');
93
- mapsScript.setAttribute('src', mapsScriptUrl);
94
- window[callback] = () => {
95
- Array.from(document.querySelectorAll('ne14-address')).forEach((el) => {
96
- el.initialise();
97
- });
98
- };
99
- window.addEventListener('load', () => document.body.appendChild(mapsScript));
100
- }
101
- }
102
-
103
- exports.AddressLookup = AddressLookup;
104
-
105
- }));