@wherabouts/vue-ui
v0.3.1
Published
Production-ready Vue 3 components for Wherabouts SDK — address autocomplete, geocoding, and form fields with accessibility and customization.
Downloads
460
Readme
@wherabouts/vue-ui
Vue 3 components and helpers for the Wherabouts location API —
address autocomplete, forward/reverse geocoding inputs, and structured address form fields.
Built on @wherabouts/sdk, styled with
Tailwind, and shipped with a prebuilt stylesheet so you can drop them in without any build
setup. This is the Vue counterpart to @wherabouts/react-ui.
Coverage: Authoritative Australian addresses (G-NAF). International coverage (US, parts of the EU, and more) is in beta and rolling out — availability may vary by deployment.
Status
Available (v0.3.0). All five Vue 3 SFC components —
AddressAutocomplete,AddressFormField,AddressFieldGroup,ForwardGeocodeInput,ReverseGeocodeInput— plus the backing composables (useAutocomplete,useForwardGeocode,useReverseGeocode,useAddressGeolocation,useCombobox) are implemented and exported. They mirror the@wherabouts/react-uiAPI, surfacing callbacks as Vue@-events.
Requirements
- Vue 3.0+ (peer dependency)
- A Wherabouts API key (
wh_...)
Installation
# npm
npm install @wherabouts/vue-ui @wherabouts/sdk
# pnpm
pnpm add @wherabouts/vue-ui @wherabouts/sdk
# yarn
yarn add @wherabouts/vue-ui @wherabouts/sdkPeer dependencies: vue (>=3.0.0) and @wherabouts/sdk (>=0.5.0).
Import the stylesheet once, near your app root:
import "@wherabouts/vue-ui/styles.css";Exports
Components, composables, shared utilities, and types are all exported from the package root:
import {
// Components
AddressAutocomplete,
AddressFormField,
AddressFieldGroup,
ForwardGeocodeInput,
ReverseGeocodeInput,
// Composables (headless logic, bring your own markup)
useAutocomplete,
useForwardGeocode,
useReverseGeocode,
useAddressGeolocation,
useCombobox,
// Utilities + types
toAddressWithParsed,
cn,
type AddressWithParsed,
type AddressFieldGroupValue,
type AddressI18nStrings,
type AddressSuggestionInput,
} from "@wherabouts/vue-ui";toAddressWithParsed(suggestion)— maps a raw SDKAddressSuggestioninto the flattenedAddressWithParsedshape the components use (formattedAddress,latitude,longitude, plus parsedstreetAddress/suburb/state/postcode/country).cn(...classes)— theclsx+tailwind-mergeclass combiner used internally for composing Tailwind classes without conflicts.
Types
| Type | Description |
|---|---|
| AddressWithParsed | Flattened address: id, formattedAddress, latitude, longitude, streetAddress, suburb, state, postcode, country. |
| AddressI18nStrings | Overridable UI strings: noResults, enterManually, errorRetry, geolocationError. |
| AddressSuggestionInput | Re-export of the SDK's AddressSuggestion (the input to toAddressWithParsed). |
Quick start
Each component takes a client created with the SDK. Create it once and share it.
<script setup lang="ts">
import { createWheraboutsClient } from "@wherabouts/sdk";
import { AddressAutocomplete } from "@wherabouts/vue-ui";
import "@wherabouts/vue-ui/styles.css";
const client = createWheraboutsClient({ apiKey: import.meta.env.VITE_WHERABOUTS_KEY });
function onSelect(address) {
console.log(address.formattedAddress, address.latitude, address.longitude);
}
</script>
<template>
<AddressAutocomplete
:client="client"
placeholder="Start typing an address…"
@select="onSelect"
/>
</template>Note: Use a publishable key scoped to your origin for browser use. Never ship a secret server key to the client.
Components
AddressAutocomplete— debounced address search with an accessible (WAI-ARIA combobox) suggestion list, keyboard navigation, optional geolocation proximity bias, and slot-based custom rendering. Emitsselect(anAddressWithParsed) andqueryChange.AddressFormField—AddressAutocompletewrapped with a label and error styling for drop-in form use. Emitsselect.ForwardGeocodeInput— resolves free-text address input to coordinates. Emitsresult({ latitude, longitude, formattedAddress }).ReverseGeocodeInput— resolveslatitude/longitudeto the nearest address. Emitsresult({ address, distance }).AddressFieldGroup— a controlled group of structured inputs (street, suburb, state, postcode) for editing a full address. Takes avalueand emitschange(AddressFieldGroupValue).
Props mirror the @wherabouts/react-ui components (props as Vue
props; React callbacks surfaced as @-events). Custom render-prop slots on
AddressAutocomplete are exposed as named slots: suggestion, loading, error,
empty.
Composables
When you want the logic without the markup, the components are built on headless composables you can use directly:
useAutocomplete(client, options)— owns thequeryref; debounces input, aborts stale requests, and exposes reactiveresults,status,error, andsetQuery.useForwardGeocode(client, query)— reactive forward geocoding from a query source.useReverseGeocode(client, coords)— reactive reverse geocoding from a coords source.useAddressGeolocation(enabled)— one-shot browser geolocation for proximity bias.useCombobox(options)— the headless WAI-ARIA combobox keyboard state machine.
Development
pnpm --filter @wherabouts/vue-ui build # vite build + prebuilt styles.css
pnpm --filter @wherabouts/vue-ui dev # build in watch mode
pnpm --filter @wherabouts/vue-ui test # vitestStyling
The package ships a prebuilt styles.css (import it once, as shown above). Components use
neutral design tokens and accept class for overrides.
TypeScript
Ships dual ESM + CJS builds with bundled type declarations. All exports are fully typed.
License
UNLICENSED — © Wherabouts. See the repository for usage terms.
