@wherabouts/react-ui 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@wherabouts/react-ui` are documented here. This project adheres
4
+ to [Semantic Versioning](https://semver.org/) and the
5
+ [Keep a Changelog](https://keepachangelog.com/) format.
6
+
7
+ ## [0.1.0] - 2026-06-18
8
+
9
+ First publishable release.
10
+
11
+ ### Added
12
+
13
+ - **`AddressAutocomplete`** — debounced, WAI-ARIA combobox address search with keyboard
14
+ navigation, proximity bias (`enableGeolocation` / `userLat` / `userLng`), session
15
+ tokens, i18n strings, and fully customizable `render*` slots.
16
+ - **`AddressFormField`** — `AddressAutocomplete` with a label and error styling for forms.
17
+ - **`ForwardGeocodeInput`** — resolves free-text addresses to coordinates.
18
+ - **`ReverseGeocodeInput`** — resolves coordinates to the nearest address.
19
+ - **`AddressFieldGroup`** — controlled street/suburb/state/postcode field group.
20
+ - Utilities `toAddressWithParsed` and `cn`, plus exported component prop and value types.
21
+ - Prebuilt `styles.css` and dual ESM + CJS builds with bundled type declarations.
22
+
23
+ ### Notes
24
+
25
+ - International address coverage (US/EU and more) is in **beta** and rolling out;
26
+ availability may vary by deployment. Australian (G-NAF) coverage is authoritative.
27
+ </content>
package/README.md ADDED
@@ -0,0 +1,176 @@
1
+ # @wherabouts/react-ui
2
+
3
+ Production-ready, accessible React components for the [Wherabouts](https://wherabouts.com)
4
+ location API — address autocomplete, forward/reverse geocoding inputs, and structured
5
+ address form fields. Built on [`@wherabouts/sdk`](https://www.npmjs.com/package/@wherabouts/sdk),
6
+ styled with Tailwind, and shipped with a prebuilt stylesheet so you can drop them in
7
+ without any build setup.
8
+
9
+ > **Coverage:** Authoritative Australian addresses (G-NAF). International coverage
10
+ > (US, parts of the EU, and more) is in **beta** and rolling out — availability may
11
+ > vary by deployment.
12
+
13
+ ## Requirements
14
+
15
+ - React **19+** and React DOM 19+ (peer dependencies)
16
+ - A Wherabouts API key (`wh_...`)
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ # npm
22
+ npm install @wherabouts/react-ui @wherabouts/sdk @wherabouts/react
23
+
24
+ # pnpm
25
+ pnpm add @wherabouts/react-ui @wherabouts/sdk @wherabouts/react
26
+
27
+ # yarn
28
+ yarn add @wherabouts/react-ui @wherabouts/sdk @wherabouts/react
29
+ ```
30
+
31
+ Peer dependencies: `react` & `react-dom` (>=19), `@wherabouts/sdk` (>=0.4.2), and
32
+ `@wherabouts/react` (>=0.2.0).
33
+
34
+ Import the stylesheet once, near your app root:
35
+
36
+ ```ts
37
+ import "@wherabouts/react-ui/styles.css";
38
+ ```
39
+
40
+ ## Quick start
41
+
42
+ Every component takes a `client` created with the SDK. Create it once and share it.
43
+
44
+ ```tsx
45
+ import { createWheraboutsClient } from "@wherabouts/sdk";
46
+ import { AddressAutocomplete } from "@wherabouts/react-ui";
47
+ import "@wherabouts/react-ui/styles.css";
48
+
49
+ const client = createWheraboutsClient({ apiKey: import.meta.env.VITE_WHERABOUTS_KEY });
50
+
51
+ export function Checkout() {
52
+ return (
53
+ <AddressAutocomplete
54
+ client={client}
55
+ placeholder="Start typing an address…"
56
+ onSelect={(address) => console.log(address.formattedAddress, address.latitude, address.longitude)}
57
+ />
58
+ );
59
+ }
60
+ ```
61
+
62
+ > **Note:** Use a **publishable** key scoped to your origin for browser use. Never ship a
63
+ > secret server key to the client.
64
+
65
+ ## Components
66
+
67
+ ### `AddressAutocomplete`
68
+
69
+ Debounced address search with a fully accessible (WAI-ARIA combobox) suggestion list,
70
+ keyboard navigation, and customizable rendering.
71
+
72
+ ```tsx
73
+ <AddressAutocomplete
74
+ client={client}
75
+ onSelect={(address) => setAddress(address)}
76
+ minCharsToSearch={3}
77
+ debounceMs={200}
78
+ maxSuggestions={8}
79
+ enableGeolocation
80
+ />
81
+ ```
82
+
83
+ | Prop | Type | Default | Description |
84
+ |---|---|---|---|
85
+ | `client` | `WheraboutsClient` | — | **Required.** SDK client. |
86
+ | `onSelect` | `(address: AddressWithParsed) => void` | — | Called when a suggestion is chosen. |
87
+ | `onQueryChange` | `(query: string) => void` | — | Called as the input text changes. |
88
+ | `placeholder` | `string` | — | Input placeholder. |
89
+ | `debounceMs` | `number` | `200` | Debounce before querying the API. |
90
+ | `minCharsToSearch` | `number` | `3` | Minimum characters before searching. |
91
+ | `maxSuggestions` | `number` | `10` | Max suggestions to show. |
92
+ | `enableGeolocation` | `boolean` | `false` | Use the browser's location to bias results (proximity). |
93
+ | `userLat` / `userLng` | `number` | — | Explicit proximity bias instead of geolocation. |
94
+ | `sessionToken` | `string` | — | Group a run of keystrokes into one billable search (see `newSessionToken()` in the SDK). |
95
+ | `disabled` / `required` | `boolean` | `false` | Standard input states. |
96
+ | `error` | `string` | — | External error message to display. |
97
+ | `id` / `className` | `string` | — | Pass-through for the input. |
98
+ | `i18nStrings` | `Partial<AddressI18nStrings>` | — | Override built-in labels/strings. |
99
+ | `renderSuggestion` | `(address, isActive) => ReactNode` | — | Custom suggestion row. |
100
+ | `renderEmpty` / `renderLoading` / `renderError` | `() => ReactNode` | — | Custom empty/loading/error states. |
101
+
102
+ ### `AddressFormField`
103
+
104
+ `AddressAutocomplete` wrapped with a `<label>` and error styling — drop-in for forms.
105
+ Accepts every `AddressAutocomplete` prop plus:
106
+
107
+ | Prop | Type | Description |
108
+ |---|---|---|
109
+ | `label` | `string` | **Required.** Field label. |
110
+ | `labelClassName` | `string` | Class for the label element. |
111
+ | `errorClassName` | `string` | Class for the error text. |
112
+
113
+ ```tsx
114
+ <AddressFormField client={client} label="Delivery address" required onSelect={setAddress} />
115
+ ```
116
+
117
+ ### `ForwardGeocodeInput`
118
+
119
+ Resolves a free-text address to coordinates as `query` changes (forward geocoding).
120
+
121
+ | Prop | Type | Description |
122
+ |---|---|---|
123
+ | `client` | `WheraboutsClient` | **Required.** SDK client. |
124
+ | `query` | `string \| null` | Address text to geocode. |
125
+ | `onResult` | `(r: { latitude, longitude, formattedAddress }) => void` | Geocode result callback. |
126
+ | `placeholder` / `id` / `className` | `string` | Pass-through. |
127
+ | `disabled` | `boolean` | Disabled state. |
128
+
129
+ ### `ReverseGeocodeInput`
130
+
131
+ Resolves `latitude`/`longitude` to the nearest address (reverse geocoding).
132
+
133
+ | Prop | Type | Description |
134
+ |---|---|---|
135
+ | `client` | `WheraboutsClient` | **Required.** SDK client. |
136
+ | `latitude` / `longitude` | `number \| null` | Coordinates to reverse-geocode. |
137
+ | `onResult` | `(r: { address, distance }) => void` | Result callback. |
138
+ | `placeholder` / `id` / `className` | `string` | Pass-through. |
139
+ | `disabled` | `boolean` | Disabled state. |
140
+
141
+ ### `AddressFieldGroup`
142
+
143
+ A controlled group of structured inputs (street, suburb, state, postcode) for editing a
144
+ full address.
145
+
146
+ | Prop | Type | Description |
147
+ |---|---|---|
148
+ | `client` | `WheraboutsClient` | **Required.** SDK client. |
149
+ | `value` | `AddressFieldGroupValue` | **Required.** Controlled value. |
150
+ | `onChange` | `(value: AddressFieldGroupValue) => void` | **Required.** Change handler. |
151
+ | `streetLabel` / `suburbLabel` / `stateLabel` / `postcodeLabel` | `string` | Override field labels. |
152
+ | `disabled` / `className` | — | Standard states. |
153
+
154
+ ## Utilities & types
155
+
156
+ - `toAddressWithParsed(suggestion)` — map a raw SDK `AddressSuggestion` to the
157
+ `AddressWithParsed` shape used by these components.
158
+ - `cn(...classes)` — the `clsx` + `tailwind-merge` class combiner used internally.
159
+ - Exported types: `AddressWithParsed`, `AddressI18nStrings`, `AddressValidateFn`,
160
+ `AddressSuggestionInput`, and each component's `*Props`.
161
+
162
+ ## Styling
163
+
164
+ The package ships a prebuilt `styles.css` (import it once, as shown above). Components use
165
+ neutral design tokens and accept `className` for overrides; you can also fully replace
166
+ suggestion/empty/loading/error rendering via the `render*` props on `AddressAutocomplete`.
167
+
168
+ ## TypeScript
169
+
170
+ Ships dual ESM + CJS builds with bundled type declarations. All props and callback
171
+ payloads are fully typed.
172
+
173
+ ## License
174
+
175
+ UNLICENSED — © Wherabouts. See the repository for usage terms.
176
+ </content>