From d6f73043138284a0360837a0688499d114e6317f Mon Sep 17 00:00:00 2001 From: Buddy Date: Wed, 10 Jun 2026 22:11:00 -0700 Subject: [PATCH] refactor: use defineProps with str() in icon components Switch leaflet-icon and leaflet-div-icon from bare { attr: '...' } objects to defineProps(...) with str() factories, consistent with all other components. --- src/components/leaflet-div-icon.ts | 19 ++++++++++--------- src/components/leaflet-icon.ts | 27 ++++++++++++++------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/components/leaflet-div-icon.ts b/src/components/leaflet-div-icon.ts index 64b91a9..0570579 100644 --- a/src/components/leaflet-div-icon.ts +++ b/src/components/leaflet-div-icon.ts @@ -1,15 +1,16 @@ import { DivIcon, DivIconOptions, Icon } from 'leaflet'; +import { defineProps, str } from '../core/props.ts'; import { emitIconChanged } from '../core/register.ts'; -const PROPS = { - iconSize: { attr: 'icon-size' }, - iconAnchor: { attr: 'icon-anchor' }, - popupAnchor: { attr: 'popup-anchor' }, - tooltipAnchor: { attr: 'tooltip-anchor' }, - className: { attr: 'class-name' }, - html: { attr: 'html' }, - bgPos: { attr: 'bg-pos' }, -} as const; +const PROPS = defineProps({ + iconSize: str(), + iconAnchor: str(), + popupAnchor: str(), + tooltipAnchor: str(), + className: str(), + html: str(), + bgPos: str(), +}); const JSON_KEYS = new Set(['iconSize', 'iconAnchor', 'popupAnchor', 'tooltipAnchor', 'bgPos']); diff --git a/src/components/leaflet-icon.ts b/src/components/leaflet-icon.ts index 56d8383..bcbc1d0 100644 --- a/src/components/leaflet-icon.ts +++ b/src/components/leaflet-icon.ts @@ -1,19 +1,20 @@ import { Icon, IconOptions } from 'leaflet'; +import { defineProps, str } from '../core/props.ts'; import { emitIconChanged } from '../core/register.ts'; -const PROPS = { - iconUrl: { attr: 'icon-url' }, - iconRetinaUrl: { attr: 'icon-retina-url' }, - iconSize: { attr: 'icon-size' }, - iconAnchor: { attr: 'icon-anchor' }, - popupAnchor: { attr: 'popup-anchor' }, - tooltipAnchor: { attr: 'tooltip-anchor' }, - shadowUrl: { attr: 'shadow-url' }, - shadowRetinaUrl: { attr: 'shadow-retina-url' }, - shadowSize: { attr: 'shadow-size' }, - shadowAnchor: { attr: 'shadow-anchor' }, - className: { attr: 'class-name' }, -} as const; +const PROPS = defineProps({ + iconUrl: str(), + iconRetinaUrl: str(), + iconSize: str(), + iconAnchor: str(), + popupAnchor: str(), + tooltipAnchor: str(), + shadowUrl: str(), + shadowRetinaUrl: str(), + shadowSize: str(), + shadowAnchor: str(), + className: str(), +}); const JSON_KEYS = new Set([ 'iconSize',