@mountainpass/addressr-svelte 0.3.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.
Files changed (3) hide show
  1. package/LICENSE +123 -0
  2. package/README.md +115 -0
  3. package/package.json +69 -0
package/LICENSE ADDED
@@ -0,0 +1,123 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including
45
+ the original version of the Work and any modifications or additions
46
+ to that Work or Derivative Works thereof, that is intentionally
47
+ submitted to the Licensor for inclusion in the Work by the copyright owner
48
+ or by an individual or Legal Entity authorized to submit on behalf of
49
+ the copyright owner.
50
+
51
+ "Contributor" shall mean Licensor and any individual or Legal Entity
52
+ on behalf of whom a Contribution has been received by the Licensor and
53
+ subsequently incorporated within the Work.
54
+
55
+ 2. Grant of Copyright License. Subject to the terms and conditions of
56
+ this License, each Contributor hereby grants to You a perpetual,
57
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
58
+ copyright license to reproduce, prepare Derivative Works of,
59
+ publicly display, publicly perform, sublicense, and distribute the
60
+ Work and such Derivative Works in Source or Object form.
61
+
62
+ 3. Grant of Patent License. Subject to the terms and conditions of
63
+ this License, each Contributor hereby grants to You a perpetual,
64
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
65
+ (except as stated in this section) patent license to make, have made,
66
+ use, offer to sell, sell, import, and otherwise transfer the Work,
67
+ where such license applies only to those patent claims licensable
68
+ by such Contributor that are necessarily infringed by their
69
+ Contribution(s) alone or by combination of their Contribution(s)
70
+ with the Work to which such Contribution(s) was submitted.
71
+
72
+ 4. Redistribution. You may reproduce and distribute copies of the
73
+ Work or Derivative Works thereof in any medium, with or without
74
+ modifications, and in Source or Object form, provided that You
75
+ meet the following conditions:
76
+
77
+ (a) You must give any other recipients of the Work or
78
+ Derivative Works a copy of this License; and
79
+
80
+ (b) You must cause any modified files to carry prominent notices
81
+ stating that You changed the files; and
82
+
83
+ (c) You must retain, in the Source form of any Derivative Works
84
+ that You distribute, all copyright, patent, trademark, and
85
+ attribution notices from the Source form of the Work,
86
+ excluding those notices that do not pertain to any part of
87
+ the Derivative Works; and
88
+
89
+ (d) If the Work includes a "NOTICE" text file as part of its
90
+ distribution, then any Derivative Works that You distribute must
91
+ include a readable copy of the attribution notices contained
92
+ within such NOTICE file, excluding any notices that do not
93
+ pertain to any part of the Derivative Works, in at least one
94
+ of the following places: within a NOTICE text file distributed
95
+ as part of the Derivative Works; within the Source form or
96
+ documentation, if provided along with the Derivative Works; or,
97
+ within a display generated by the Derivative Works, if and
98
+ wherever such third-party notices normally appear.
99
+
100
+ 5. Submission of Contributions.
101
+
102
+ 6. Trademarks. This License does not grant permission to use the trade
103
+ names, trademarks, service marks, or product names of the Licensor.
104
+
105
+ 7. Disclaimer of Warranty.
106
+
107
+ 8. Limitation of Liability.
108
+
109
+ 9. Accepting Warranty or Additional Liability.
110
+
111
+ Copyright 2026 Mountain Pass Pty. Limited
112
+
113
+ Licensed under the Apache License, Version 2.0 (the "License");
114
+ you may not use this file except in compliance with the License.
115
+ You may obtain a copy of the License at
116
+
117
+ http://www.apache.org/licenses/LICENSE-2.0
118
+
119
+ Unless required by applicable law or agreed to in writing, software
120
+ distributed under the License is distributed on an "AS IS" BASIS,
121
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122
+ See the License for the specific language governing permissions and
123
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # @mountainpass/addressr-svelte
2
+
3
+ Svelte address autocomplete component for Australian address search, powered by [Addressr](https://addressr.io).
4
+
5
+ Part of the [addressr-ui](https://github.com/mountain-pass/addressr-ui) monorepo.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @mountainpass/addressr-svelte
11
+ ```
12
+
13
+ Peer dependencies: `svelte` >= 4.
14
+
15
+ ## Drop-in component
16
+
17
+ ```svelte
18
+ <script>
19
+ import { AddressAutocomplete } from '@mountainpass/addressr-svelte';
20
+ import '@mountainpass/addressr-svelte/style.css';
21
+ </script>
22
+
23
+ <AddressAutocomplete
24
+ apiUrl="https://api.addressr.io/"
25
+ onSelect={(address) => {
26
+ console.log(address.sla); // "1 GEORGE ST, SYDNEY NSW 2000"
27
+ console.log(address.structured); // { street, locality, state, postcode, ... }
28
+ console.log(address.geocoding); // { latitude, longitude, ... }
29
+ }}
30
+ />
31
+ ```
32
+
33
+ ### Props
34
+
35
+ | Prop | Type | Default | Description |
36
+ |------|------|---------|-------------|
37
+ | `apiKey` | `string` | -- | RapidAPI key. Omit for direct API access. |
38
+ | `onSelect` | `(address: AddressDetail) => void` | -- | Called when an address is selected |
39
+ | `label` | `string` | `"Search Australian addresses"` | Accessible label text |
40
+ | `placeholder` | `string` | `"Start typing an address..."` | Input placeholder |
41
+ | `debounceMs` | `number` | `300` | Debounce delay in milliseconds |
42
+ | `apiUrl` | `string` | `"https://addressr.p.rapidapi.com/"` | API root URL |
43
+ | `apiHost` | `string` | `"addressr.p.rapidapi.com"` | RapidAPI host header |
44
+
45
+ ## Headless store
46
+
47
+ Build your own UI while keeping the search logic, debounce, pagination, and abort handling:
48
+
49
+ ```svelte
50
+ <script>
51
+ import { createAddressSearch } from '@mountainpass/addressr-svelte';
52
+
53
+ const search = createAddressSearch({ apiUrl: 'https://api.addressr.io/' });
54
+
55
+ function handleInput(e) {
56
+ search.setQuery(e.target.value);
57
+ }
58
+ </script>
59
+
60
+ <input value={$search.query} on:input={handleInput} />
61
+
62
+ {#if $search.isLoading}
63
+ <p>Searching...</p>
64
+ {/if}
65
+
66
+ <ul>
67
+ {#each $search.results as result}
68
+ <li on:click={() => search.selectAddress(result.pid)}>{result.sla}</li>
69
+ {/each}
70
+ {#if $search.hasMore}
71
+ <li on:click={() => search.loadMore()}>Load more...</li>
72
+ {/if}
73
+ </ul>
74
+ ```
75
+
76
+ ### Store state (`$search`)
77
+
78
+ | Property | Type | Description |
79
+ |----------|------|-------------|
80
+ | `query` | `string` | Current input value |
81
+ | `results` | `AddressSearchResult[]` | Search results (accumulated across pages) |
82
+ | `isLoading` | `boolean` | Initial search in progress |
83
+ | `isLoadingMore` | `boolean` | Pagination fetch in progress |
84
+ | `hasMore` | `boolean` | More pages available |
85
+ | `error` | `Error \| null` | Latest error |
86
+ | `selectedAddress` | `AddressDetail \| null` | Selected address detail |
87
+
88
+ ### Store methods
89
+
90
+ | Method | Description |
91
+ |--------|-------------|
92
+ | `setQuery(q)` | Update query (triggers debounced search) |
93
+ | `loadMore()` | Load next page of results |
94
+ | `selectAddress(pid)` | Fetch full address detail |
95
+ | `clear()` | Reset all state |
96
+ | `destroy()` | Clean up timers and abort controllers |
97
+
98
+ ## Accessibility
99
+
100
+ Implements the WAI-ARIA combobox pattern:
101
+
102
+ - Full keyboard navigation (Arrow keys, Enter, Escape)
103
+ - Screen reader announcements for results count and loading state
104
+ - Visible focus indicators (3:1 contrast)
105
+ - Touch targets >= 44px
106
+ - Accessible label always present
107
+ - Infinite scroll with loading indicator
108
+
109
+ ## Re-exports
110
+
111
+ This package re-exports everything from [`@mountainpass/addressr-core`](../core) for convenience -- `createAddressrClient`, `parseHighlight`, and all types.
112
+
113
+ ## License
114
+
115
+ Apache-2.0
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@mountainpass/addressr-svelte",
3
+ "version": "0.3.0",
4
+ "description": "Svelte address autocomplete component for Australian address search via Addressr",
5
+ "author": {
6
+ "name": "Mountain Pass",
7
+ "url": "https://mountain-pass.com.au"
8
+ },
9
+ "license": "Apache-2.0",
10
+ "type": "module",
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.mjs",
13
+ "types": "./dist/index.d.ts",
14
+ "svelte": "./dist/index.mjs",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "svelte": "./dist/index.mjs",
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.cjs"
21
+ },
22
+ "./style.css": "./dist/style.css"
23
+ },
24
+ "files": [
25
+ "dist/"
26
+ ],
27
+ "sideEffects": [
28
+ "*.css"
29
+ ],
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "peerDependencies": {
34
+ "svelte": ">=4"
35
+ },
36
+ "dependencies": {
37
+ "@windyroad/link-header": "^1.0.1",
38
+ "@mountainpass/addressr-core": "0.1.0"
39
+ },
40
+ "devDependencies": {
41
+ "@sveltejs/vite-plugin-svelte": "^5.0.3",
42
+ "@testing-library/svelte": "^5.2.7",
43
+ "@testing-library/jest-dom": "^6.6.3",
44
+ "@testing-library/user-event": "^14.6.1",
45
+ "jsdom": "^26.1.0",
46
+ "svelte": "^5.33.0",
47
+ "vite": "^6.3.5",
48
+ "vite-plugin-dts": "^4.5.4",
49
+ "vitest": "^3.2.3"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "keywords": [
55
+ "svelte",
56
+ "address",
57
+ "autocomplete",
58
+ "australia",
59
+ "addressr",
60
+ "gnaf",
61
+ "combobox",
62
+ "hateoas"
63
+ ],
64
+ "scripts": {
65
+ "build": "tsc --noEmit && vite build",
66
+ "test": "vitest run",
67
+ "lint": "eslint src/"
68
+ }
69
+ }