33 Commits (10027c9fe7b3bbf1e8f018aa5fad7e4e7cedad66)
 

Author SHA1 Message Date
Buddy 10027c9fe7 refactor: rename withProps to WithProps
Capitalize the mixin factory name since it's used in the extends
position (class Foo extends WithProps(...)). Update CLAUDE.md to
match.
3 months ago
Buddy f615dceea3 refactor: replace PROPS literal tables with factory helpers
Add num(), str(), on() factory functions and defineProps() wrapper
to core/props.ts. Each helper returns a PropDef fragment without
'attr'; defineProps fills it in via camelToKebab(key), with an
optional override for edge cases like playsInline->playsinline.

Input types are derived from their canonical counterparts via
OptionalAttr<T> = Omit<T, 'attr'> & { attr?: string }, keeping
definitions in sync automatically.

Net effect: ~3800 chars removed across 18 component files, no
behavior change, full type inference preserved.
3 months ago
Buddy 96037f22b6 refactor: switch component exports from named to default
All 21 component files export exactly one class. Change to
export default so consumers can import them without named braces.
Update src/index.ts re-exports from "export *" to
"export { default as LeafletXxx }". Fix the two type-only
imports of LeafletLine to use default import syntax.
3 months ago
Buddy 85f0fbe216 refactor: use .ts extension for relative imports in source
Change all import specifiers from ".js" to ".ts" in TypeScript source
files. Add allowImportingTsExtensions and rewriteRelativeImportExtensions
to tsconfig so tsc strips them to ".js" in the dist output — no build
pipeline changes needed. Update CLAUDE.md to reflect the new extension policy.
3 months ago
Buddy edecb44533 docs: update README and CLAUDE.md for current build and architecture
Remove stale JSR reference, add import-options section (formats, deep
imports, leaflet as external dep), fix build command (esbuild -> Rollup).
Rewrite CLAUDE.md architecture to reflect withProps mixin, register.ts
helpers, feature-group, and the full rollup output.
3 months ago
Buddy 5d0d15fba1 refactor: move props.ts from src/types/ to src/core/
The types/ directory now only had a single file. The PropDef and
PropTypesFromTable types are foundational to the module infrastructure
(used by utils.ts, with-props.ts, and every component), so core/ is a
better home. Deleted the empty types/ directory.
3 months ago
Buddy 565b79a89c chore: remove unused exports and dead css.d.ts
- camelCase removed entirely (never imported anywhere)
- PATH_STYLE_ATTRS, ChildEntry, createChildRegisterHandler made private
  (used only internally within their modules)
- src/types/css.d.ts deleted (leftover from an earlier
  approach — no .css imports exist in the source)
3 months ago
Buddy 3ec2d07115 feat: replace esbuild with Rollup, add CJS/UMD bundles and deep import support
Build pipeline now consists of two passes:
  1. tsc --outDir dist  — individual ESM modules for deep imports
  2. rollup -c           — bundled ESM, CJS, and UMD (minified + unminified)

Package.json changes:
  - main/dist/index.cjs (CJS for require())
  - module/dist/index.js (ESM for bundlers)
  - types/dist/index.d.ts (bundled declarations via rollup-plugin-dts)
  - unpkg/dist/index.umd.js (CDN entry)
  - exports map with ./dist/* wildcard for deep imports
  - sideEffects: true since every component calls customElements.define
  - files: [dist, README.md]

tsconfig.json: adds declarationMap: true for Go-to-Definition to source.

Dependencies: removed esbuild, added rollup, @rollup/plugin-typescript,
@rollup/plugin-terser, rollup-plugin-dts, tslib.
3 months ago
Buddy 6906505a53 fix: move leaflet from devDependencies to dependencies
Consumers need leaflet at runtime since it is imported by the
bundled output.
3 months ago
Buddy 18db84e9a4 feat: derive buildOptions return type from PROPS table via Omit<PropTypesFromTable<TProps>, TExclude[number]>
Use a const type parameter on the exclude array so literal tuples narrow
correctly. The return type now reflects the actual properties and their
kinds (number/string/boolean) instead of Record<string, unknown>.

Four call sites needed local casts where PROPS declares str but Leaflet
expects a narrower type (crossOrigin, offset) — these are design-level
mismatches between HTML attribute types and Leaflet's option types.
3 months ago
Buddy 348e865dae docs: add why/how comments to all src/core modules
Explain design rationale for every exported utility, mixin, registration
helper, and path-style handler
3 months ago
Buddy 319b7bdb0c docs: remove vite mentions from README and CLAUDE.md 3 months ago
Buddy c69f9c8503 refactor: extract PROP_BY_ATTR + dynamic setter dispatch into helpers
Adds buildAttrMap(props) and setLayerAttr(obj, props, attrMap,
name, val) to utils.ts. The former replaces the PROP_BY_ATTR Map
construction (2 fewer lines per component), the latter replaces
the 6-line dynamic setter dispatch pattern used as the fallback
else block in 6 components.

For WMS, setLayerAttr returns false when no setter exists, so the
caller can fall back to setParams for non-method props.
3 months ago
Buddy 96b48a6ae2 refactor: extract #parsedBounds into parseBoundsAttr helper
Replaces the identical private #parsedBounds method in rectangle,
image-overlay, video-overlay, and svg-overlay with a call to
parseBoundsAttr(el) from utils.ts. Removes 4 x 5 = 20 lines
of method definitions.
3 months ago
Buddy e2752aa7e0 refactor: extract child-registration boilerplate into WeakMap helpers
Adds registerChildren / unregisterChildren / getChildren to
register.ts using module-scoped WeakMaps, removing the duplicated
#children / #childHandler fields + lifecycle wiring from 15
components.

registerChildren(el, layer) creates the children Map + handler,
stores both in WeakMaps, wires the event listener, and calls
registerWithParent — all in one call. unregisterChildren(el)
tears it down. getChildren(el) gives access to the map for
components that need custom child iteration in disconnectedCallback
(geojson, layer-group, feature-group).

Net: -101 lines, 15 components lose 2-4 fields + 4-8 lifecycle
lines each. Components with extra lifecycle work (marker -> dragend,
polygon/polyline -> observer + syncCoords) keep their custom
additions inline, just the register boilerplate is replaced.
3 months ago
Buddy c18829a0e3 refactor: extract duplicate #num helper into standalone numAttr()
Removes the identical private #num method from 5 components
(leaflet-circle, leaflet-circle-marker, leaflet-marker,
leaflet-popup, leaflet-tooltip). Replaces with numAttr(this, PROPS, name)
call to the new helper in utils.ts.
3 months ago
Buddy 566b8ea43c fix: handle runtime attribute changes for marker title/alt and media props
Marker title/alt now set via getElement() on the icon element.
VideoOverlay loop/autoplay/muted/playsInline set via getElement()
on the video element. ImageOverlay alt set via getElement() on
the img element. These props have no Leaflet set* method but
can be updated through the underlying DOM element.
3 months ago
Buddy 3846cad38e fix: use dragging.enable/disable instead of non-existent setDraggable
Leaflet Marker has no setDraggable method. Toggling dragging at
runtime requires marker.dragging.enable() / .disable(). Adds a
special case for the 'draggable' attribute in the
attributeChangedCallback before the generic setter lookup.
3 months ago
Buddy be84e61ad0 fix: bool-on props broken in generic setter dispatcher
parseAttributeValue('') returns '' (falsy) for boolean-present
attributes, making setDraggable(false), setInteractive(''), etc.
not work. Now looks up the prop spec from PROPS and passes
val !== null (true/false) when kind is 'bool-on'.

Fixes: leaflet-marker, leaflet-tile-layer-wms, leaflet-image-overlay,
leaflet-video-overlay, leaflet-svg-overlay, leaflet-geojson
3 months ago
Buddy 78c39f33a3 fix: sync lat/lng attributes on marker dragend
LeafletMarker now listens for Leaflet's 'dragend' event and writes
the final position back to the lat/lng attributes, using a #syncing
guard to prevent re-entrant setLatLng calls.
3 months ago
Buddy 80c87468b6 refactor: extract withProps mixin to eliminate TypedBase/observedAttributes boilerplate
18 components now use withProps(HTMLElement, PROPS) instead of
repeating TypedBase cast, static get observedAttributes(), and
static { definePropAccessors(...) } in each file.

Adds src/core/with-props.ts — a mixin factory that derives
PropTypesFromTable, defines property accessors, and sets up
observedAttributes from a PROPS table in a single expression.
3 months ago
Buddy 26e110d0b4 feat: group child tags by type in add-child wizard
When adding a child to leaflet-map, the tag select is now grouped
into categories: Tile Layers, Markers, Shapes, Data, Overlays,
Groups, and Controls, using <optgroup> elements.
3 months ago
Buddy 275c74f0c2 feat: two-pane dev controls panel with tree, editor, add-child, and pick-on-map
- Left pane: nested component tree with +/x buttons for add/remove
- Right pane: attribute editor with per-input MutationObserver sync
- Shared pick-on-map: single click picks both lat/lng from one map click
- Add-child wizard replaces editor pane, Cancel restores previous content
- Source HTML display for selected element
- Missing attributes added: min/max-zoom, zoom-snap/delta, path style attrs,
  popup/tooltip lat/lng, overlay interactive/loop/autoplay, and more
3 months ago
Buddy a8245c0114 chore: remove unused updateViaSetter helper 3 months ago
Buddy a7b0df2616 fix: register custom event in HTMLElementEventMap to eliminate casts
Augment HTMLElementEventMap with 'leaflet-register' so that
addEventListener('leaflet-register', handler) natively accepts
(e: LeafletRegisterEvent) => void, removing the need for
as EventListener casts in all 14 consumer components.
3 months ago
Buddy 4e1abdcc3d refactor: extract static PROP accessor blocks into definePropAccessors helper
All 17 TypedBase components now share a single definePropAccessors(proto, PROPS)
call in their static block instead of duplicating the getter/setter loop.

Also includes pre-existing cleanup:
- Refine LeafletRegisterEvent type (interface -> generic CustomEvent)
- Drop unused attrToPropName helper
- Fix createChildRegisterHandler return type in layer-group/feature-group
3 months ago
Buddy 4d27c8eaac core: rename prettier config and run prettier 3 months ago
Buddy fcfcdbfb7a docs: add full attribute tables for all components
Replace the brief 'Other components' section with complete per-component
attribute tables including defaults and descriptions. Add CSS/resize docs
for leaflet-map and a shared path-style reference table.
4 months ago
Buddy 2c2e83b7d0 feat: auto-invalidate map size on element resize via ResizeObserver
Replace the height-attribute approach with a ResizeObserver on the host
element so the map re-renders whenever its container size changes from
any source — CSS class, inline style, parent layout, etc.
4 months ago
Buddy 41acdc9bb7 feat: load Leaflet CSS via CDN <link> instead of bundling
Replace inline CSS import with a configurable CDN <link> to fix 404s on
marker icon PNG files (relative paths now resolve against the CDN URL).

- Remove leaflet/dist/leaflet.css import and --loader:.css=text from build
- Add css-url, css-integrity, css-crossorigin attributes on <leaflet-map>
- Derive Icon.Default.imagePath from CSS URL for JS-loaded marker icons
- Move shadow DOM setup into connectedCallback with reconnection guard
- Use CSS_ATTRS constant for observedAttributes and attributeChangedCallback

CSS attrs default to https://unpkg.com/leaflet@1.9.4/dist/leaflet.css with
SRI integrity and crossorigin='anonymous'. Custom CSS URLs drop the
default integrity; set css-integrity explicitly to re-enable SRI.
4 months ago
Buddy 1e7ea22342 fix: prevent tooltip crash from empty-string pane option
buildOptions was passing default values for absent attributes,
including empty-string defaults like pane:'', which caused Leaflet to
look up this._panes[''] and return undefined, crashing in appendChild.

- Skip empty-string defaults in buildOptions so Leaflet uses its own
- Broaden createChildRegisterHandler param from LayerGroup to Layer so
  non-container layers (marker, circle, etc.) can intercept popup/tooltip
  children and call bindPopup/bindTooltip instead of bubbling to the map
- Add child-registration handler to every layer component (all 12)
- Fix disconnectedCallback in container components to unbind popups and
  tooltips and remove child layers properly
4 months ago
Buddy 5f3fd5f61a refactor: replace inheritance hierarchy with composable PROPS-table pattern
Remove LeafletElement and LeafletControl base classes. Every component
now self-describes its attributes via a PROPS table, derives observed-
Attributes from it, and generates prototype getters/setters in static {}.

Registration lifecycle is extracted into standalone helpers
(registerWithParent, createChildRegisterHandler). Common update
patterns (path style) are shared via imported helpers instead of
duplicated across 5+ components.

Components manage their own #obj private field instead of a shared
protected leafletObject. Leaflet-map-style declarative patterns are
now consistent across all 20 components.
4 months ago
Buddy 6b448ba092 feat: Initial implementation of leaflet-components
Wraps Leaflet.js as native Web Components. Each element maps 1:1 to a
Leaflet object with reactive attribute binding and proper lifecycle cleanup.

Key design decisions:
- LeafletElement base class handles attribute→option mapping, the
  leaflet-register bubble event for parent/child wiring, and
  disconnectedCallback cleanup tracking parent bindings.
- LeafletControl base class for map controls (zoom, attribution, scale).
- leaflet-map uses a PROPS table to drive observedAttributes, getters/setters,
  attributeChangedCallback, and map event listeners from a single source of
  truth. Property types are derived via a mapped type over the table; the
  mixin-base pattern (TypedBase) makes them visible to TypeScript without an
  interface merge.
- Boolean map options that default to true use disable-* attributes.
- Leaflet and its CSS are bundled into dist/index.js via esbuild.
- JSR config included for @buddy/leaflet-components.
4 months ago