npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@annoyingmouse/wc-location-field

v1.2.0

Published

A web component for location selection with address search via Nominatim or Google Maps, an optional interactive map, browser geolocation, and What3Words support.

Readme

<wc-location-field>

Published on webcomponents.org

A self-contained web component for location selection. Provides address search via Nominatim (OpenStreetMap) or Google Maps, an optional interactive map, browser geolocation, and optional What3Words integration. No framework dependencies.

Demo

<custom-element-demo>
  <template>
    <script src="https://unpkg.com/@annoyingmouse/wc-location-field/wc-location-field.js" defer></script>
    <next-code-block></next-code-block>
  </template>
</custom-element-demo>
<wc-location-field
  label="Find a location"
  placeholder="e.g. Paddington Station"
></wc-location-field>

Installation

<script src="https://unpkg.com/@annoyingmouse/wc-location-field/wc-location-field.js" defer></script>

Styles and Leaflet (when show-map is used) are loaded automatically — no extra <link> tags needed.

Or as a module:

<script type="module" src="https://cdn.skypack.dev/@annoyingmouse/wc-location-field/wc-location-field.js"></script>

Usage

<wc-location-field label="From" placeholder="e.g. Paddington Station"></wc-location-field>

With map (Nominatim/Leaflet):

<wc-location-field
  label="Meeting point"
  show-map
  center-lat="51.505"
  center-lng="-0.09"
></wc-location-field>

With Google Maps (Places Autocomplete + Google Maps map):

<wc-location-field
  label="Meeting point"
  map-provider="google"
  google-maps-key="YOUR_API_KEY"
  show-map
></wc-location-field>

Display-only pinned map (no search UI, no click/drag):

<wc-location-field
  id="venue"
  label="Venue"
  show-map
  readonly
></wc-location-field>
document.querySelector('#venue').prefill({ address: 'Buckingham Palace', lat: 51.5014, lng: -0.1419 })

Attributes

| Attribute | Description | |---|---| | label | Field label text (reactive) | | placeholder | Input placeholder text (reactive) | | center-lat / center-lng | Map centre and search bias | | show-map | Renders an interactive map below the search box | | readonly | Hides search UI and disables map click/drag; use with show-map and prefill() to display a pinned location | | map-provider | "nominatim" (default) or "google" | | google-maps-key | Google Maps API key — required when map-provider="google" | | w3w-key | What3Words API key; enables ///word.word.word search | | radius-km | Draws a circle overlay on the map (requires show-map, center-lat, center-lng) |

Public API

const field = document.querySelector('wc-location-field')

// Programmatically set a location (does not fire location-change)
field.prefill({ address: 'Buckingham Palace', lat: 51.5014, lng: -0.1419 })

// Reset
field.clear()

// Read state
console.log(field.value, field.lat, field.lng, field.address)
// field.value returns What3Words address when resolved, else formatted address, else raw input

// label and placeholder can also be set as JS properties
field.label = 'Destination'
field.placeholder = 'Search for a place…'

// Set a GeoJSON boundary overlay on the map (polygon/feature drawn, map centred on its bounds)
field.geojson = { type: 'Polygon', coordinates: [[[0.1, 52.3], [0.2, 52.3], [0.2, 52.4], [0.1, 52.4], [0.1, 52.3]]] }

Events

field.addEventListener('location-change', e => {
  const { lat, lng, address, w3w } = e.detail
})

The location-change CustomEvent bubbles and fires whenever a location is resolved (from search, map click, marker drag, or geolocation).

Theming

The component is intentionally minimal — input and button styling inherit from your page. Two CSS custom properties are available:

wc-location-field {
  --lf-map-height: 300px;   /* default: 240px */
  --lf-w3w-color: #e11f26;  /* What3Words /// prefix colour */
}

Accessibility

  • ARIA combobox pattern (role="combobox", aria-expanded, aria-haspopup="listbox", aria-activedescendant)
  • Full keyboard navigation: ArrowDown/ArrowUp to move through suggestions, Enter to select, Escape to dismiss
  • Coordinates announced via aria-live="polite"
  • Geolocation status and errors announced via aria-live="assertive"
  • GPS button has an accessible label
  • In readonly mode the map container is labelled aria-label="Location map" for screen readers

Development

No build step required. Open index.html directly in a browser to develop and test.

npm run format   # format with Biome
npm run lint     # lint with Biome
npm test         # run tests with Web Test Runner

Releasing

Before releasing for the first time, authenticate with npm:

npm login

Then use one of the release scripts depending on the change:

npm run release:patch   # bug fixes (1.0.5 → 1.0.6)
npm run release:minor   # new features (1.0.5 → 1.1.0)
npm run release:major   # breaking changes (1.0.5 → 2.0.0)

Each script:

  1. Bumps the version in package.json and creates a git commit and tag
  2. Builds the minified dist (dist/wc-location-field.min.js) via Rollup
  3. Syncs the new version into bower.json
  4. Commits the build artifacts, pushes the commit and tags to GitHub
  5. Publishes the package to npm with public access

Licence

MIT