Skip to content

Commit

Permalink
Improve Source types (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVelarde authored May 25, 2023
1 parent e196a60 commit 2d681d7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fix widget calculation with very large viewports/masks [#680](https://github.com/CartoDB/carto-react/pull/680)
- Storybook: show figma codes/theme code snippets for colors [#684](https://github.com/CartoDB/carto-react/pull/684)
- Bar & Histogram & Formula & ComparativeFormula Widgets: Add a skeleton for loading state [#674](https://github.com/CartoDB/carto-react/pull/674)
- Improve Source types [#687](https://github.com/CartoDB/carto-react/pull/687)

## 2.0

Expand Down
2 changes: 1 addition & 1 deletion packages/react-api/src/hooks/useCartoLayerProps.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SourceProps, LayerConfig, UseCartoLayerFilterProps } from '../types';

interface UseCartoLayerProps {
source: SourceProps & { id: string };
source: SourceProps;
layerConfig?: LayerConfig;
uniqueIdProperty?: string;
viewportFeatures?: boolean;
Expand Down
7 changes: 4 additions & 3 deletions packages/react-api/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ interface CredentialsCarto3 {
export type Credentials = CredentialsCarto2 | CredentialsCarto3;

export type SourceProps = {
id: string;
data: string;
type: MAP_TYPES.QUERY | MAP_TYPES.TABLE | MAP_TYPES.TILESET;
connection?: string;
credentials: Credentials;
queryParameters: QueryParameters;
connection: string;
credentials?: Credentials;
queryParameters?: QueryParameters;
};

export type LayerConfig = {
Expand Down
16 changes: 9 additions & 7 deletions packages/react-redux/src/slices/cartoSlice.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { AnyAction, Reducer } from 'redux';
import { Feature, Polygon, MultiPolygon } from 'geojson';

type Source = SourceProps & {
id: string
filters?: any
filtersLogicalOperator?: FiltersLogicalOperators
isDroppingFeatures?: boolean
filters?: any;
filtersLogicalOperator?: FiltersLogicalOperators;
isDroppingFeatures?: boolean;
};

type Layer = {
Expand All @@ -25,7 +24,7 @@ type FilterBasic = {
type: _FilterTypes;
values: string[] | number[] | number[][];
owner?: string;
params?: Record<string, unknown>
params?: Record<string, unknown>;
};

type FilterCommonProps = {
Expand Down Expand Up @@ -71,7 +70,7 @@ declare enum CartoActions {
SET_FEATURES_READY = 'carto/setFeaturesReady',
SET_CREDENTIALS = 'carto/setCredentials',
SET_FEATURE_SELECTION_MODE = 'carto/setFeatureSelectionMode',
SET_FEATURE_SELECTION_ENABLED = 'carto/setFeatureSelectionEnabled',
SET_FEATURE_SELECTION_ENABLED = 'carto/setFeatureSelectionEnabled'
}

export function createCartoSlice(
Expand Down Expand Up @@ -170,6 +169,9 @@ export function setFeatureSelectionEnabled(enabled: boolean): {

export function selectViewport(state: any): Viewport | null;

export function selectSpatialFilter(state: any, sourceId?: string): Feature<Polygon | MultiPolygon> | null;
export function selectSpatialFilter(
state: any,
sourceId?: string
): Feature<Polygon | MultiPolygon> | null;

export function selectFeatureSelectionMode(state: any): string | null;

0 comments on commit 2d681d7

Please sign in to comment.