@carto/ps-react-maps 3.5.0-canary.2 → 3.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.
@@ -29,7 +29,7 @@ export type { ModelProps } from './models/types';
29
29
  export { CategoriesModel, useCategories } from './models/categories';
30
30
  export { FeaturesModel, useFeatures } from './models/features';
31
31
  export { FormulaModel, useFormula } from './models/formula';
32
- export { HistogramModel, useHistogram } from './models/histogram.';
32
+ export { HistogramModel, useHistogram } from './models/histogram';
33
33
  export { RangeModel, useRange } from './models/range';
34
34
  export { ScatterModel, useScatter } from './models/scatter';
35
35
  export { TableModel, useTable } from './models/table';
@@ -43,7 +43,7 @@ export { MapProvider, useMapStore } from './providers/map/provider';
43
43
  export { createMapStore } from './providers/map/store';
44
44
  export type { QuerySource, Source, SourceStore, TableSource, TilesetSource, } from './providers/sources/types';
45
45
  export { clientID } from './providers/sources/const';
46
- export { useSourceStore } from './providers/sources/store';
46
+ export { useSourceStore, useSource, useFilters, useSourceWithFilters, getFilterValues, } from './providers/sources/store';
47
47
  export { MapsProvider } from './provider';
48
48
  export { useEventManager } from './use-event-manager';
49
49
  export { useLayers } from './use-layers';
@@ -2,6 +2,6 @@ import { UseQueryOptions } from '@tanstack/react-query';
2
2
  export interface ModelProps<T, R> {
3
3
  accessToken: string;
4
4
  sourceId: string;
5
- widgetProps: T;
5
+ widgetProps: Omit<T, 'filters'>;
6
6
  useQueryProps?: Omit<UseQueryOptions<unknown, Error, R>, 'queryKey' | 'queryFn'>;
7
7
  }
@@ -1,3 +1,60 @@
1
1
  import { Source, SourceStore } from './types';
2
- export declare const useSourceStore: import('zustand').UseBoundStore<import('zustand').StoreApi<SourceStore>>;
2
+ import { Filters, FilterType } from '@carto/api-client';
3
+ export declare const useSourceStore: import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<SourceStore>, "setState"> & {
4
+ setState(partial: SourceStore | Partial<SourceStore> | ((state: SourceStore) => SourceStore | Partial<SourceStore>), replace?: false | undefined, action?: (string | {
5
+ [x: string]: unknown;
6
+ [x: number]: unknown;
7
+ [x: symbol]: unknown;
8
+ type: string;
9
+ }) | undefined): void;
10
+ setState(state: SourceStore | ((state: SourceStore) => SourceStore), replace: true, action?: (string | {
11
+ [x: string]: unknown;
12
+ [x: number]: unknown;
13
+ [x: symbol]: unknown;
14
+ type: string;
15
+ }) | undefined): void;
16
+ }>;
17
+ /**
18
+ * Shortcut to grabbing the source from the sources store object
19
+ * @param id - the id of the source you want to grab
20
+ * @returns source object without filters
21
+ */
3
22
  export declare function useSource(id: string): Source | undefined;
23
+ /**
24
+ * Shortcut to grabbing the filters from the filters store object
25
+ * @param id - the id of the source the filters are applied to
26
+ * @returns filters object as used in the `@carto/api-client` methods calls
27
+ */
28
+ export declare function useFilters(id: string): Filters | undefined;
29
+ /**
30
+ * Returns a source together with its filters, pulling from the separate `sources` and `filters` state objects
31
+ * @param id - the id of the source
32
+ * @returns source object as used in `@carto/api-client`
33
+ */
34
+ export declare function useSourceWithFilters(id: string): {
35
+ filters: Filters;
36
+ widgets?: (import('@carto/api-client').WidgetSource<import('@carto/api-client').WidgetSourceProps> | null) | undefined;
37
+ type: "table" | "query" | "query+h3" | "query+quadbin" | "query+boundary" | "tileset" | "tileset+h3" | "tileset+quadbin" | "table+h3" | "table+quadbin" | "table+boundary" | "raster";
38
+ data: string;
39
+ apiBaseUrl?: string | undefined;
40
+ headers?: Record<string, string> | undefined;
41
+ cache?: {
42
+ value?: number;
43
+ } | undefined;
44
+ clientId?: string | undefined;
45
+ format?: import('@carto/api-client').Format | undefined;
46
+ maxLengthURL?: number | undefined;
47
+ spatialDataColumn?: string | undefined;
48
+ spatialDataType?: ("h3" | "geo" | "quadbin") | undefined;
49
+ tileResolution?: import('@carto/api-client').TileResolution | undefined;
50
+ localCache?: {
51
+ cache?: Map<string, Promise<unknown>>;
52
+ cacheControl?: ("no-cache" | "no-store")[];
53
+ } | undefined;
54
+ connectionName: string;
55
+ apiVersion?: import('@carto/api-client').ApiVersion | undefined;
56
+ } | undefined;
57
+ export declare function getFilterValues(filters: Filters | undefined, { column, type }: {
58
+ column: string;
59
+ type: FilterType;
60
+ }): string[] | number[] | number[][];
@@ -47,22 +47,15 @@ export type RasterQuadbinTilesetSource = {
47
47
  rasterMetadata?: RasterMetadata;
48
48
  } & OmitTable<RasterSourceOptions>;
49
49
  export type AllRasterSource = RasterQuadbinTilesetSource;
50
- export type Source = (AllQuerySource | AllTilesetSource | AllTableSource | AllRasterSource) & {
50
+ export type Source = Omit<(AllQuerySource | AllTilesetSource | AllTableSource | AllRasterSource) & {
51
51
  data: string;
52
52
  widgets?: WidgetSource<WidgetSourceProps> | null;
53
- filters?: Filters;
54
53
  apiVersion?: ApiVersion;
55
- };
56
- export interface SourceFilters {
57
- filters?: Record<string, Record<string, {
58
- values: string[] | number[];
59
- owner?: string;
60
- }>>;
61
- }
54
+ }, 'filters'>;
62
55
  export interface SourceStore {
63
56
  sources: Record<string, Source>;
64
57
  filters: Record<string, Filters>;
65
- setSource: (id: string, source?: Partial<Omit<Source, 'filters'>>) => void;
58
+ setSource: (id: string, source?: Partial<Source>) => void;
66
59
  removeSource: (id: string) => void;
67
60
  setFilters: (id: string, filters: (AddFilterOptions | RemoveFilterOptions)[]) => void;
68
61
  removeFilters: (id: string, column?: RemoveFilterOptions['column'], owner?: RemoveFilterOptions['owner']) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carto/ps-react-maps",
3
- "version": "3.5.0-canary.2",
3
+ "version": "3.5.0",
4
4
  "description": "CARTO's Professional Service React DeckGL library",
5
5
  "type": "module",
6
6
  "dependencies": {},
@@ -27,8 +27,8 @@
27
27
  "mjolnir.js": "2.7.3",
28
28
  "react-map-gl": "8.0.1",
29
29
  "zustand": "5.0.3",
30
- "@carto/ps-utils": "2.0.0",
31
- "@carto/ps-services": "2.4.0-canary.0"
30
+ "@carto/ps-services": "2.4.0",
31
+ "@carto/ps-utils": "2.0.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@tanstack/react-query": "^5.0.0",