@texturehq/edges 1.3.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import React__default, { ReactNode } from 'react';
4
4
  import * as PhosphorIcons from '@phosphor-icons/react';
5
5
  import { IconProps as IconProps$1 } from '@phosphor-icons/react';
6
6
  import { DateValue, DateFieldProps as DateFieldProps$1, ValidationResult, MeterProps as MeterProps$1 } from 'react-aria-components';
7
- import { ViewState } from 'react-map-gl';
7
+ import { ViewState, MapRef } from 'react-map-gl';
8
8
  import * as d3_scale from 'd3-scale';
9
9
  import { ScaleTime, ScaleLinear } from 'd3-scale';
10
10
 
@@ -634,8 +634,45 @@ declare const Logo: ({ className, showWordmark, width, fill }: LogoProps) => rea
634
634
  * A clean, developer-friendly API for defining map layers that abstracts
635
635
  * away Mapbox jargon while supporting vector tiles, GeoJSON, and custom markers.
636
636
  */
637
+ /**
638
+ * Sequential palette color schemes (light → dark gradients)
639
+ * Use for numeric data that goes from low to high (population, temperature, elevation, etc.)
640
+ */
641
+ type SequentialScheme = "viridis" | "magma" | "rose" | "cerulean" | "forest";
642
+ /**
643
+ * Diverging palette color schemes (two-hue gradients with light center)
644
+ * Use for numeric data with a meaningful center point (anomalies, differences, profit/loss, etc.)
645
+ */
646
+ type DivergingScheme = "orangeYellowSeafoam" | "redYellowBlue" | "redBlue";
637
647
  /**
638
648
  * Color specification - supports design tokens, hex values, or property-based mapping
649
+ *
650
+ * @example
651
+ * // Design token
652
+ * { token: "brand-primary" }
653
+ *
654
+ * @example
655
+ * // Hex color
656
+ * { hex: "#ff0000" }
657
+ *
658
+ * @example
659
+ * // Property-based mapping (works with all layer types)
660
+ * { by: "voltage_level", mapping: { high: { hex: "#ff0000" }, low: { hex: "#00ff00" } } }
661
+ *
662
+ * @example
663
+ * // Categorical auto-assignment (automatically assigns colors from palette)
664
+ * // ⚠️ ONLY works with GeoJSON layers that provide data as an object (not URL)
665
+ * { by: "type", palette: "categorical" }
666
+ *
667
+ * @example
668
+ * // Sequential palette (numeric data, light to dark)
669
+ * // ⚠️ ONLY works with GeoJSON layers that provide data as an object (not URL)
670
+ * { by: "population_density", palette: "sequential", scheme: "viridis", scale: "auto" }
671
+ *
672
+ * @example
673
+ * // Diverging palette (numeric data with meaningful center)
674
+ * // ⚠️ ONLY works with GeoJSON layers that provide data as an object (not URL)
675
+ * { by: "temp_anomaly", palette: "diverging", scheme: "redYellowBlue", center: 0 }
639
676
  */
640
677
  type ColorSpec = {
641
678
  token: string;
@@ -644,6 +681,27 @@ type ColorSpec = {
644
681
  } | {
645
682
  by: string;
646
683
  mapping: Record<string, ColorSpec>;
684
+ } | {
685
+ by: string;
686
+ palette: "categorical";
687
+ scale?: "auto";
688
+ } | {
689
+ by: string;
690
+ palette: "sequential";
691
+ scheme?: SequentialScheme;
692
+ scale?: {
693
+ min: number;
694
+ max: number;
695
+ } | "auto";
696
+ } | {
697
+ by: string;
698
+ palette: "diverging";
699
+ scheme?: DivergingScheme;
700
+ center: number | "median" | "mean";
701
+ scale?: {
702
+ min: number;
703
+ max: number;
704
+ } | "auto";
647
705
  };
648
706
  /**
649
707
  * Zoom-based interpolation for numeric values
@@ -994,6 +1052,25 @@ interface CustomControl extends BaseControl {
994
1052
  */
995
1053
  type MapControl = NavigationControl | LayersControl | SearchControl | ListControl | CustomControl;
996
1054
 
1055
+ /**
1056
+ * Ref handle for programmatic map control
1057
+ */
1058
+ interface InteractiveMapHandle {
1059
+ /**
1060
+ * Show a tooltip for a specific feature
1061
+ * @param featureId - The feature ID to show tooltip for
1062
+ * @param layerId - Optional layer ID to narrow the search
1063
+ */
1064
+ showTooltip: (featureId: string | number, layerId?: string) => void;
1065
+ /**
1066
+ * Hide the currently active tooltip
1067
+ */
1068
+ hideTooltip: () => void;
1069
+ /**
1070
+ * Get the underlying Mapbox map instance
1071
+ */
1072
+ getMap: () => MapRef | null;
1073
+ }
997
1074
  interface InteractiveMapProps {
998
1075
  /**
999
1076
  * Initial camera position
@@ -1077,10 +1154,19 @@ interface InteractiveMapProps {
1077
1154
  headers?: Record<string, string>;
1078
1155
  };
1079
1156
  /**
1080
- * Show loading state overlay
1157
+ * Show loading state overlay (for external data loading)
1158
+ * The map automatically shows a loading state while Mapbox initializes.
1159
+ * Use this prop if you need to show loading while fetching additional data.
1081
1160
  * @default false
1082
1161
  */
1083
1162
  isLoading?: boolean;
1163
+ /**
1164
+ * Callback fired when the map finishes loading
1165
+ * Called after Mapbox is fully initialized and initial tiles are loaded.
1166
+ * The map handles its own loading state internally, but you can use this
1167
+ * callback for analytics, initializing overlays, or other side effects.
1168
+ */
1169
+ onLoad?: () => void;
1084
1170
  /**
1085
1171
  * Map controls configuration
1086
1172
  *
@@ -1109,7 +1195,7 @@ interface InteractiveMapProps {
1109
1195
  */
1110
1196
  controls?: MapControl[] | "default" | false;
1111
1197
  }
1112
- declare function InteractiveMap({ initialViewState, viewState, onViewStateChange, scrollEnabled, className, previewMode, previewModeCta, onPreviewModePress, mapType, layers, mapboxAccessToken, transformRequest, isLoading, controls, }: InteractiveMapProps): react_jsx_runtime.JSX.Element;
1198
+ declare const InteractiveMap: React__default.ForwardRefExoticComponent<InteractiveMapProps & React__default.RefAttributes<InteractiveMapHandle>>;
1113
1199
 
1114
1200
  interface StaticMapProps {
1115
1201
  /**
@@ -1174,6 +1260,11 @@ interface StaticMapProps {
1174
1260
  * @default true
1175
1261
  */
1176
1262
  showMarker?: boolean;
1263
+ /**
1264
+ * Callback fired when the map finishes loading
1265
+ * Useful for knowing when Mapbox is fully initialized and tiles are loaded
1266
+ */
1267
+ onLoad?: () => void;
1177
1268
  /**
1178
1269
  * Additional CSS classes
1179
1270
  */
@@ -1187,7 +1278,7 @@ interface StaticMapProps {
1187
1278
  *
1188
1279
  * Automatically adapts to light/dark mode using the global ColorModeProvider.
1189
1280
  */
1190
- declare function StaticMap({ width, height, initialViewState, isLoading, mapType, layers, mapboxAccessToken, showMarker, className, }: StaticMapProps): react_jsx_runtime.JSX.Element;
1281
+ declare function StaticMap({ width, height, initialViewState, isLoading, mapType, layers, mapboxAccessToken, showMarker, onLoad, className, }: StaticMapProps): react_jsx_runtime.JSX.Element;
1191
1282
 
1192
1283
  /**
1193
1284
  * Represents a geographic point with coordinates
@@ -4,7 +4,7 @@ import React__default, { ReactNode } from 'react';
4
4
  import * as PhosphorIcons from '@phosphor-icons/react';
5
5
  import { IconProps as IconProps$1 } from '@phosphor-icons/react';
6
6
  import { DateValue, DateFieldProps as DateFieldProps$1, ValidationResult, MeterProps as MeterProps$1 } from 'react-aria-components';
7
- import { ViewState } from 'react-map-gl';
7
+ import { ViewState, MapRef } from 'react-map-gl';
8
8
  import * as d3_scale from 'd3-scale';
9
9
  import { ScaleTime, ScaleLinear } from 'd3-scale';
10
10
 
@@ -634,8 +634,45 @@ declare const Logo: ({ className, showWordmark, width, fill }: LogoProps) => rea
634
634
  * A clean, developer-friendly API for defining map layers that abstracts
635
635
  * away Mapbox jargon while supporting vector tiles, GeoJSON, and custom markers.
636
636
  */
637
+ /**
638
+ * Sequential palette color schemes (light → dark gradients)
639
+ * Use for numeric data that goes from low to high (population, temperature, elevation, etc.)
640
+ */
641
+ type SequentialScheme = "viridis" | "magma" | "rose" | "cerulean" | "forest";
642
+ /**
643
+ * Diverging palette color schemes (two-hue gradients with light center)
644
+ * Use for numeric data with a meaningful center point (anomalies, differences, profit/loss, etc.)
645
+ */
646
+ type DivergingScheme = "orangeYellowSeafoam" | "redYellowBlue" | "redBlue";
637
647
  /**
638
648
  * Color specification - supports design tokens, hex values, or property-based mapping
649
+ *
650
+ * @example
651
+ * // Design token
652
+ * { token: "brand-primary" }
653
+ *
654
+ * @example
655
+ * // Hex color
656
+ * { hex: "#ff0000" }
657
+ *
658
+ * @example
659
+ * // Property-based mapping (works with all layer types)
660
+ * { by: "voltage_level", mapping: { high: { hex: "#ff0000" }, low: { hex: "#00ff00" } } }
661
+ *
662
+ * @example
663
+ * // Categorical auto-assignment (automatically assigns colors from palette)
664
+ * // ⚠️ ONLY works with GeoJSON layers that provide data as an object (not URL)
665
+ * { by: "type", palette: "categorical" }
666
+ *
667
+ * @example
668
+ * // Sequential palette (numeric data, light to dark)
669
+ * // ⚠️ ONLY works with GeoJSON layers that provide data as an object (not URL)
670
+ * { by: "population_density", palette: "sequential", scheme: "viridis", scale: "auto" }
671
+ *
672
+ * @example
673
+ * // Diverging palette (numeric data with meaningful center)
674
+ * // ⚠️ ONLY works with GeoJSON layers that provide data as an object (not URL)
675
+ * { by: "temp_anomaly", palette: "diverging", scheme: "redYellowBlue", center: 0 }
639
676
  */
640
677
  type ColorSpec = {
641
678
  token: string;
@@ -644,6 +681,27 @@ type ColorSpec = {
644
681
  } | {
645
682
  by: string;
646
683
  mapping: Record<string, ColorSpec>;
684
+ } | {
685
+ by: string;
686
+ palette: "categorical";
687
+ scale?: "auto";
688
+ } | {
689
+ by: string;
690
+ palette: "sequential";
691
+ scheme?: SequentialScheme;
692
+ scale?: {
693
+ min: number;
694
+ max: number;
695
+ } | "auto";
696
+ } | {
697
+ by: string;
698
+ palette: "diverging";
699
+ scheme?: DivergingScheme;
700
+ center: number | "median" | "mean";
701
+ scale?: {
702
+ min: number;
703
+ max: number;
704
+ } | "auto";
647
705
  };
648
706
  /**
649
707
  * Zoom-based interpolation for numeric values
@@ -994,6 +1052,25 @@ interface CustomControl extends BaseControl {
994
1052
  */
995
1053
  type MapControl = NavigationControl | LayersControl | SearchControl | ListControl | CustomControl;
996
1054
 
1055
+ /**
1056
+ * Ref handle for programmatic map control
1057
+ */
1058
+ interface InteractiveMapHandle {
1059
+ /**
1060
+ * Show a tooltip for a specific feature
1061
+ * @param featureId - The feature ID to show tooltip for
1062
+ * @param layerId - Optional layer ID to narrow the search
1063
+ */
1064
+ showTooltip: (featureId: string | number, layerId?: string) => void;
1065
+ /**
1066
+ * Hide the currently active tooltip
1067
+ */
1068
+ hideTooltip: () => void;
1069
+ /**
1070
+ * Get the underlying Mapbox map instance
1071
+ */
1072
+ getMap: () => MapRef | null;
1073
+ }
997
1074
  interface InteractiveMapProps {
998
1075
  /**
999
1076
  * Initial camera position
@@ -1077,10 +1154,19 @@ interface InteractiveMapProps {
1077
1154
  headers?: Record<string, string>;
1078
1155
  };
1079
1156
  /**
1080
- * Show loading state overlay
1157
+ * Show loading state overlay (for external data loading)
1158
+ * The map automatically shows a loading state while Mapbox initializes.
1159
+ * Use this prop if you need to show loading while fetching additional data.
1081
1160
  * @default false
1082
1161
  */
1083
1162
  isLoading?: boolean;
1163
+ /**
1164
+ * Callback fired when the map finishes loading
1165
+ * Called after Mapbox is fully initialized and initial tiles are loaded.
1166
+ * The map handles its own loading state internally, but you can use this
1167
+ * callback for analytics, initializing overlays, or other side effects.
1168
+ */
1169
+ onLoad?: () => void;
1084
1170
  /**
1085
1171
  * Map controls configuration
1086
1172
  *
@@ -1109,7 +1195,7 @@ interface InteractiveMapProps {
1109
1195
  */
1110
1196
  controls?: MapControl[] | "default" | false;
1111
1197
  }
1112
- declare function InteractiveMap({ initialViewState, viewState, onViewStateChange, scrollEnabled, className, previewMode, previewModeCta, onPreviewModePress, mapType, layers, mapboxAccessToken, transformRequest, isLoading, controls, }: InteractiveMapProps): react_jsx_runtime.JSX.Element;
1198
+ declare const InteractiveMap: React__default.ForwardRefExoticComponent<InteractiveMapProps & React__default.RefAttributes<InteractiveMapHandle>>;
1113
1199
 
1114
1200
  interface StaticMapProps {
1115
1201
  /**
@@ -1174,6 +1260,11 @@ interface StaticMapProps {
1174
1260
  * @default true
1175
1261
  */
1176
1262
  showMarker?: boolean;
1263
+ /**
1264
+ * Callback fired when the map finishes loading
1265
+ * Useful for knowing when Mapbox is fully initialized and tiles are loaded
1266
+ */
1267
+ onLoad?: () => void;
1177
1268
  /**
1178
1269
  * Additional CSS classes
1179
1270
  */
@@ -1187,7 +1278,7 @@ interface StaticMapProps {
1187
1278
  *
1188
1279
  * Automatically adapts to light/dark mode using the global ColorModeProvider.
1189
1280
  */
1190
- declare function StaticMap({ width, height, initialViewState, isLoading, mapType, layers, mapboxAccessToken, showMarker, className, }: StaticMapProps): react_jsx_runtime.JSX.Element;
1281
+ declare function StaticMap({ width, height, initialViewState, isLoading, mapType, layers, mapboxAccessToken, showMarker, onLoad, className, }: StaticMapProps): react_jsx_runtime.JSX.Element;
1191
1282
 
1192
1283
  /**
1193
1284
  * Represents a geographic point with coordinates