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.
main
Buddy 3 months ago
parent 301f223938
commit d6f7304313

@ -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']);

@ -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',

Loading…
Cancel
Save