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.
This commit is contained in:
parent
85f0fbe216
commit
96037f22b6
@ -18,7 +18,7 @@ const PROPS = {
|
|||||||
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletCircleMarker extends withProps(HTMLElement, PROPS) {
|
export default class LeafletCircleMarker extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: CircleMarker;
|
#obj?: CircleMarker;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -18,7 +18,7 @@ const PROPS = {
|
|||||||
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletCircle extends withProps(HTMLElement, PROPS) {
|
export default class LeafletCircle extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Circle;
|
#obj?: Circle;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const PROPS = {
|
|||||||
prefix: { kind: 'str', attr: 'prefix', default: '' },
|
prefix: { kind: 'str', attr: 'prefix', default: '' },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletControlAttribution extends withProps(HTMLElement, PROPS) {
|
export default class LeafletControlAttribution extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Control.Attribution;
|
#obj?: Control.Attribution;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const PROPS = {
|
|||||||
updateWhenIdle: { kind: 'bool-on', attr: 'update-when-idle' },
|
updateWhenIdle: { kind: 'bool-on', attr: 'update-when-idle' },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletControlScale extends withProps(HTMLElement, PROPS) {
|
export default class LeafletControlScale extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Control.Scale;
|
#obj?: Control.Scale;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const PROPS = {
|
|||||||
zoomOutTitle: { kind: 'str', attr: 'zoom-out-title', default: 'Zoom out' },
|
zoomOutTitle: { kind: 'str', attr: 'zoom-out-title', default: 'Zoom out' },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletControlZoom extends withProps(HTMLElement, PROPS) {
|
export default class LeafletControlZoom extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Control.Zoom;
|
#obj?: Control.Zoom;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { FeatureGroup, Layer } from 'leaflet';
|
|||||||
import { buildOptions } from '../core/utils.ts';
|
import { buildOptions } from '../core/utils.ts';
|
||||||
import { registerChildren, unregisterChildren, getChildren } from '../core/register.ts';
|
import { registerChildren, unregisterChildren, getChildren } from '../core/register.ts';
|
||||||
|
|
||||||
export class LeafletFeatureGroup extends HTMLElement {
|
export default class LeafletFeatureGroup extends HTMLElement {
|
||||||
#obj?: FeatureGroup;
|
#obj?: FeatureGroup;
|
||||||
|
|
||||||
static get observedAttributes() {
|
static get observedAttributes() {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ const PROP_BY_ATTR = new Map<string, string>(
|
|||||||
Object.entries(PROPS).map(([name, spec]) => [spec.attr, name]),
|
Object.entries(PROPS).map(([name, spec]) => [spec.attr, name]),
|
||||||
);
|
);
|
||||||
|
|
||||||
export class LeafletGeoJSON extends withProps(HTMLElement, PROPS) {
|
export default class LeafletGeoJSON extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: GeoJSON;
|
#obj?: GeoJSON;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ const PROPS = {
|
|||||||
|
|
||||||
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
||||||
|
|
||||||
export class LeafletImageOverlay extends withProps(HTMLElement, PROPS) {
|
export default class LeafletImageOverlay extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: ImageOverlay;
|
#obj?: ImageOverlay;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { LayerGroup, Layer } from 'leaflet';
|
|||||||
import { buildOptions } from '../core/utils.ts';
|
import { buildOptions } from '../core/utils.ts';
|
||||||
import { registerChildren, unregisterChildren, getChildren } from '../core/register.ts';
|
import { registerChildren, unregisterChildren, getChildren } from '../core/register.ts';
|
||||||
|
|
||||||
export class LeafletLayerGroup extends HTMLElement {
|
export default class LeafletLayerGroup extends HTMLElement {
|
||||||
#obj?: LayerGroup;
|
#obj?: LayerGroup;
|
||||||
|
|
||||||
static get observedAttributes() {
|
static get observedAttributes() {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
export class LeafletLine extends HTMLElement {
|
export default class LeafletLine extends HTMLElement {
|
||||||
static get observedAttributes() {
|
static get observedAttributes() {
|
||||||
return ['lat', 'lng'];
|
return ['lat', 'lng'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -185,7 +185,7 @@ type PropTypes = {
|
|||||||
// runtime still extends HTMLElement, and no interface merge is required.
|
// runtime still extends HTMLElement, and no interface merge is required.
|
||||||
const TypedBase = HTMLElement as unknown as new () => HTMLElement & PropTypes;
|
const TypedBase = HTMLElement as unknown as new () => HTMLElement & PropTypes;
|
||||||
|
|
||||||
export class LeafletMap extends TypedBase {
|
export default class LeafletMap extends TypedBase {
|
||||||
#map?: LMap;
|
#map?: LMap;
|
||||||
#container!: HTMLDivElement;
|
#container!: HTMLDivElement;
|
||||||
#cssLink?: HTMLLinkElement;
|
#cssLink?: HTMLLinkElement;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ const PROPS = {
|
|||||||
|
|
||||||
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
||||||
|
|
||||||
export class LeafletMarker extends withProps(HTMLElement, PROPS) {
|
export default class LeafletMarker extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Marker;
|
#obj?: Marker;
|
||||||
#syncing = false;
|
#syncing = false;
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { withProps } from '../core/with-props.ts';
|
|||||||
import { registerChildren, unregisterChildren } from '../core/register.ts';
|
import { registerChildren, unregisterChildren } from '../core/register.ts';
|
||||||
import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts';
|
import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts';
|
||||||
import type { PropDef } from '../core/props.ts';
|
import type { PropDef } from '../core/props.ts';
|
||||||
import type { LeafletLine } from './leaflet-line.ts';
|
import type LeafletLine from './leaflet-line.ts';
|
||||||
|
|
||||||
const PROPS = {
|
const PROPS = {
|
||||||
color: { kind: 'str', attr: 'color', default: '#3388ff' },
|
color: { kind: 'str', attr: 'color', default: '#3388ff' },
|
||||||
@ -16,7 +16,7 @@ const PROPS = {
|
|||||||
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletPolygon extends withProps(HTMLElement, PROPS) {
|
export default class LeafletPolygon extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Polygon;
|
#obj?: Polygon;
|
||||||
#observer?: MutationObserver;
|
#observer?: MutationObserver;
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { withProps } from '../core/with-props.ts';
|
|||||||
import { registerChildren, unregisterChildren } from '../core/register.ts';
|
import { registerChildren, unregisterChildren } from '../core/register.ts';
|
||||||
import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts';
|
import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts';
|
||||||
import type { PropDef } from '../core/props.ts';
|
import type { PropDef } from '../core/props.ts';
|
||||||
import type { LeafletLine } from './leaflet-line.ts';
|
import type LeafletLine from './leaflet-line.ts';
|
||||||
|
|
||||||
const PROPS = {
|
const PROPS = {
|
||||||
color: { kind: 'str', attr: 'color', default: '#3388ff' },
|
color: { kind: 'str', attr: 'color', default: '#3388ff' },
|
||||||
@ -16,7 +16,7 @@ const PROPS = {
|
|||||||
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletPolyline extends withProps(HTMLElement, PROPS) {
|
export default class LeafletPolyline extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Polyline;
|
#obj?: Polyline;
|
||||||
#observer?: MutationObserver;
|
#observer?: MutationObserver;
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ const PROPS = {
|
|||||||
autoClose: { kind: 'bool-on', attr: 'auto-close' },
|
autoClose: { kind: 'bool-on', attr: 'auto-close' },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletPopup extends withProps(HTMLElement, PROPS) {
|
export default class LeafletPopup extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Popup;
|
#obj?: Popup;
|
||||||
#observer?: MutationObserver;
|
#observer?: MutationObserver;
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const PROPS = {
|
|||||||
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
fillOpacity: { kind: 'num', attr: 'fill-opacity', default: 0.2 },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletRectangle extends withProps(HTMLElement, PROPS) {
|
export default class LeafletRectangle extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Rectangle;
|
#obj?: Rectangle;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ const PROPS = {
|
|||||||
|
|
||||||
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
||||||
|
|
||||||
export class LeafletSVGOverlay extends withProps(HTMLElement, PROPS) {
|
export default class LeafletSVGOverlay extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: SVGOverlay;
|
#obj?: SVGOverlay;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ const PROPS = {
|
|||||||
|
|
||||||
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
||||||
|
|
||||||
export class LeafletTileLayerWMS extends withProps(HTMLElement, PROPS) {
|
export default class LeafletTileLayerWMS extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: TileLayer.WMS;
|
#obj?: TileLayer.WMS;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const PROPS = {
|
|||||||
|
|
||||||
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
||||||
|
|
||||||
export class LeafletTileLayer extends withProps(HTMLElement, PROPS) {
|
export default class LeafletTileLayer extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: TileLayer;
|
#obj?: TileLayer;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const PROPS = {
|
|||||||
opacity: { kind: 'num', attr: 'opacity', default: 1.0 },
|
opacity: { kind: 'num', attr: 'opacity', default: 1.0 },
|
||||||
} satisfies Record<string, PropDef>;
|
} satisfies Record<string, PropDef>;
|
||||||
|
|
||||||
export class LeafletTooltip extends withProps(HTMLElement, PROPS) {
|
export default class LeafletTooltip extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: Tooltip;
|
#obj?: Tooltip;
|
||||||
#observer?: MutationObserver;
|
#observer?: MutationObserver;
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ const PROPS = {
|
|||||||
|
|
||||||
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
const PROP_BY_ATTR = buildAttrMap(PROPS);
|
||||||
|
|
||||||
export class LeafletVideoOverlay extends withProps(HTMLElement, PROPS) {
|
export default class LeafletVideoOverlay extends withProps(HTMLElement, PROPS) {
|
||||||
#obj?: VideoOverlay;
|
#obj?: VideoOverlay;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
|||||||
42
src/index.ts
42
src/index.ts
@ -3,24 +3,24 @@ export * from './core/with-props.ts';
|
|||||||
export * from './core/path-style.ts';
|
export * from './core/path-style.ts';
|
||||||
export * from './core/register.ts';
|
export * from './core/register.ts';
|
||||||
export * from './core/props.ts';
|
export * from './core/props.ts';
|
||||||
export * from './components/leaflet-map.ts';
|
export { default as LeafletMap } from './components/leaflet-map.ts';
|
||||||
export * from './components/leaflet-marker.ts';
|
export { default as LeafletMarker } from './components/leaflet-marker.ts';
|
||||||
export * from './components/leaflet-circle.ts';
|
export { default as LeafletCircle } from './components/leaflet-circle.ts';
|
||||||
export * from './components/leaflet-circle-marker.ts';
|
export { default as LeafletCircleMarker } from './components/leaflet-circle-marker.ts';
|
||||||
export * from './components/leaflet-line.ts';
|
export { default as LeafletLine } from './components/leaflet-line.ts';
|
||||||
export * from './components/leaflet-polygon.ts';
|
export { default as LeafletPolygon } from './components/leaflet-polygon.ts';
|
||||||
export * from './components/leaflet-polyline.ts';
|
export { default as LeafletPolyline } from './components/leaflet-polyline.ts';
|
||||||
export * from './components/leaflet-rectangle.ts';
|
export { default as LeafletRectangle } from './components/leaflet-rectangle.ts';
|
||||||
export * from './components/leaflet-tile-layer.ts';
|
export { default as LeafletTileLayer } from './components/leaflet-tile-layer.ts';
|
||||||
export * from './components/leaflet-tile-layer-wms.ts';
|
export { default as LeafletTileLayerWMS } from './components/leaflet-tile-layer-wms.ts';
|
||||||
export * from './components/leaflet-image-overlay.ts';
|
export { default as LeafletImageOverlay } from './components/leaflet-image-overlay.ts';
|
||||||
export * from './components/leaflet-video-overlay.ts';
|
export { default as LeafletVideoOverlay } from './components/leaflet-video-overlay.ts';
|
||||||
export * from './components/leaflet-svg-overlay.ts';
|
export { default as LeafletSVGOverlay } from './components/leaflet-svg-overlay.ts';
|
||||||
export * from './components/leaflet-layer-group.ts';
|
export { default as LeafletLayerGroup } from './components/leaflet-layer-group.ts';
|
||||||
export * from './components/leaflet-feature-group.ts';
|
export { default as LeafletFeatureGroup } from './components/leaflet-feature-group.ts';
|
||||||
export * from './components/leaflet-geojson.ts';
|
export { default as LeafletGeoJSON } from './components/leaflet-geojson.ts';
|
||||||
export * from './components/leaflet-control-zoom.ts';
|
export { default as LeafletControlZoom } from './components/leaflet-control-zoom.ts';
|
||||||
export * from './components/leaflet-control-attribution.ts';
|
export { default as LeafletControlAttribution } from './components/leaflet-control-attribution.ts';
|
||||||
export * from './components/leaflet-control-scale.ts';
|
export { default as LeafletControlScale } from './components/leaflet-control-scale.ts';
|
||||||
export * from './components/leaflet-popup.ts';
|
export { default as LeafletPopup } from './components/leaflet-popup.ts';
|
||||||
export * from './components/leaflet-tooltip.ts';
|
export { default as LeafletTooltip } from './components/leaflet-tooltip.ts';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user