From ac1b3047267c52b7d0d525579f58389a77f1f8e5 Mon Sep 17 00:00:00 2001 From: tnagorra Date: Fri, 17 Nov 2023 11:09:38 +0545 Subject: [PATCH] Make props non-mandatory for library components --- lib/src/Map.tsx | 6 +++--- lib/src/MapBounds.tsx | 4 ++-- lib/src/MapCenter.tsx | 2 +- lib/src/MapPopup.tsx | 6 +++--- lib/src/MapSource/MapState.tsx | 2 +- storybook/stories/points.geo.json | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/src/Map.tsx b/lib/src/Map.tsx index b6f1e04..d36e0b4 100644 --- a/lib/src/Map.tsx +++ b/lib/src/Map.tsx @@ -88,13 +88,13 @@ type Pos = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'; interface Props { mapStyle: MapOptions['style']; - mapOptions: Omit; + mapOptions?: Omit; - scaleControlShown: boolean; + scaleControlShown?: boolean; scaleControlPosition?: Pos; scaleControlOptions?: ConstructorParameters[0]; - navControlShown: boolean; + navControlShown?: boolean; navControlPosition?: Pos; navControlOptions?: ConstructorParameters[0]; diff --git a/lib/src/MapBounds.tsx b/lib/src/MapBounds.tsx index 2dfbb00..f6da45d 100644 --- a/lib/src/MapBounds.tsx +++ b/lib/src/MapBounds.tsx @@ -8,8 +8,8 @@ import { MapChildContext } from './context'; interface Props { bounds: LngLatBoundsLike | undefined; - padding: number | PaddingOptions; - duration: number; + padding?: number | PaddingOptions; + duration?: number; } function MapBounds(props: Props) { diff --git a/lib/src/MapCenter.tsx b/lib/src/MapCenter.tsx index 42cbf29..4062898 100644 --- a/lib/src/MapCenter.tsx +++ b/lib/src/MapCenter.tsx @@ -8,7 +8,7 @@ import { MapChildContext } from './context'; interface Props { center: LngLatLike | undefined; - centerOptions: Omit; + centerOptions?: Omit; } function MapCenter(props: Props) { diff --git a/lib/src/MapPopup.tsx b/lib/src/MapPopup.tsx index 6d21b5d..3355eb3 100644 --- a/lib/src/MapPopup.tsx +++ b/lib/src/MapPopup.tsx @@ -19,12 +19,12 @@ const noop = () => {}; // TODO: add mapStyle if necessary interface Props { - children: React.ReactElement; + children: React.ReactNode; coordinates: LngLatLike; - hidden: boolean; + hidden?: boolean; onHide?: () => void; popupOptions?: PopupOptions; - trackPointer: boolean; + trackPointer?: boolean; } function MapPopup(props: Props) { diff --git a/lib/src/MapSource/MapState.tsx b/lib/src/MapSource/MapState.tsx index 7a25376..44a369d 100644 --- a/lib/src/MapSource/MapState.tsx +++ b/lib/src/MapSource/MapState.tsx @@ -18,7 +18,7 @@ const noop = () => {}; interface Props { sourceLayer?: string; attributeKey: string; - attributes: { id: number; value: T }[]; + attributes: { id: number; value: T }[] | undefined; } const emptyAttributes: { id: number, value: unknown }[] = []; diff --git a/storybook/stories/points.geo.json b/storybook/stories/points.geo.json index 3b5b025..0751b8e 100644 --- a/storybook/stories/points.geo.json +++ b/storybook/stories/points.geo.json @@ -11,7 +11,7 @@ {"id": 9, "type":"Feature","properties":{"size":21},"geometry":{"coordinates":[87.29441830807923,26.80668471032783],"type":"Point"}}, {"id": 10, "type":"Feature","properties":{"size":46},"geometry":{"coordinates":[87.28003380525138,26.660334791546035],"type":"Point"}}, {"id": 11, "type":"Feature","properties":{"size":20},"geometry":{"coordinates":[87.70722604502095,26.663100830545687],"type":"Point"}}, -{"id": 12, "type":"Feature","properties":{"size":12},"geometry":{"coordinates":[87.98846811924068,26.64392958269093],"type":"Point"}}, +{"id": 12, "type":"Feature","properties":{"size":42},"geometry":{"coordinates":[87.98846811924068,26.64392958269093],"type":"Point"}}, {"id": 13, "type":"Feature","properties":{"size":34},"geometry":{"coordinates":[85.91531900080656,26.72792517109815],"type":"Point"}}, {"id": 14, "type":"Feature","properties":{"size":67},"geometry":{"coordinates":[85.03372409474434,27.423451458413965],"type":"Point"}}, {"id": 15, "type":"Feature","properties":{"size":88},"geometry":{"coordinates":[84.43390880617767,27.689846903500538],"type":"Point"}},