@carto/kepler.gl 0.0.40-alpha.1 → 0.0.40-alpha.aggregation-selector
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.
- package/dist/components/common/field-selector.js +62 -17
- package/dist/components/common/field-token.js +4 -12
- package/dist/components/common/icons/chevron-right.js +69 -0
- package/dist/components/common/icons/index.js +9 -1
- package/dist/components/common/item-selector/dropdown-list.js +118 -20
- package/dist/components/common/item-selector/item-selector-submenu.js +133 -0
- package/dist/components/common/item-selector/item-selector.js +7 -4
- package/dist/components/common/item-selector/typeahead.js +16 -16
- package/dist/components/side-panel/layer-panel/layer-configurator.js +11 -4
- package/dist/components/side-panel/layer-panel/vis-config-by-field-selector.js +7 -3
- package/dist/constants/default-settings.js +33 -3
- package/dist/constants/index.js +7 -1
- package/dist/styles/base.js +3 -3
- package/package.json +1 -1
- package/src/components/common/field-selector.js +62 -21
- package/src/components/common/field-token.js +13 -14
- package/src/components/common/icons/chevron-right.js +47 -0
- package/src/components/common/icons/index.js +1 -0
- package/src/components/common/item-selector/dropdown-list.js +124 -43
- package/src/components/common/item-selector/item-selector-submenu.js +88 -0
- package/src/components/common/item-selector/item-selector.d.ts +2 -1
- package/src/components/common/item-selector/item-selector.js +5 -2
- package/src/components/common/item-selector/typeahead.js +27 -21
- package/src/components/side-panel/layer-panel/layer-configurator.js +17 -1
- package/src/components/side-panel/layer-panel/vis-config-by-field-selector.js +5 -1
- package/src/constants/default-settings.js +51 -0
- package/src/constants/index.js +2 -1
- package/src/styles/base.js +1 -0
- package/umd/keplergl.min.js +25 -25
|
@@ -43,7 +43,7 @@ const TypeaheadWrapper = styled.div`
|
|
|
43
43
|
display: flex;
|
|
44
44
|
flex-direction: column;
|
|
45
45
|
background-color: ${props =>
|
|
46
|
-
props.light ? props.theme.dropdownListBgdLT : props.theme.
|
|
46
|
+
props.light ? props.theme.dropdownListBgdLT : props.theme.inputBgd};
|
|
47
47
|
box-shadow: ${props => props.theme.dropdownListShadow};
|
|
48
48
|
|
|
49
49
|
:focus {
|
|
@@ -51,27 +51,29 @@ const TypeaheadWrapper = styled.div`
|
|
|
51
51
|
}
|
|
52
52
|
`;
|
|
53
53
|
|
|
54
|
-
const InputBox = styled.div
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`;
|
|
54
|
+
const InputBox = styled.div`
|
|
55
|
+
position: relative;
|
|
56
|
+
margin: 8px;
|
|
57
|
+
`
|
|
59
58
|
|
|
60
59
|
const TypeaheadInput = styled.input`
|
|
61
|
-
${props => (props.light ? props.theme.inputLT : props.theme.secondaryInput)}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
${props => (props.light ? props.theme.inputLT : props.theme.secondaryInput)};
|
|
61
|
+
width: 100%;
|
|
62
|
+
padding-left: 35px;
|
|
63
|
+
background-color: ${props => props.light ? props.theme.inputBgd : '#eee'};
|
|
64
|
+
border: none;
|
|
66
65
|
`;
|
|
67
66
|
|
|
68
|
-
const InputIcon = styled.div
|
|
69
|
-
className: 'typeahead__input_icon'
|
|
70
|
-
})`
|
|
67
|
+
const InputIcon = styled.div`
|
|
71
68
|
position: absolute;
|
|
72
|
-
|
|
73
|
-
top:
|
|
69
|
+
left: 10px;
|
|
70
|
+
top: 50%;
|
|
71
|
+
z-index: 2;
|
|
72
|
+
transform: translateY(-50%);
|
|
74
73
|
color: ${props => props.theme.inputPlaceholderColor};
|
|
74
|
+
svg {
|
|
75
|
+
display: block;
|
|
76
|
+
}
|
|
75
77
|
`;
|
|
76
78
|
|
|
77
79
|
function generateSearchFunction(props) {
|
|
@@ -151,7 +153,8 @@ class Typeahead extends Component {
|
|
|
151
153
|
customListItemComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
152
154
|
customListHeaderComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
153
155
|
showOptionsWhenEmpty: PropTypes.bool,
|
|
154
|
-
searchable: PropTypes.bool
|
|
156
|
+
searchable: PropTypes.bool,
|
|
157
|
+
withSubOptions: PropTypes.bool
|
|
155
158
|
};
|
|
156
159
|
|
|
157
160
|
static defaultProps = {
|
|
@@ -181,7 +184,8 @@ class Typeahead extends Component {
|
|
|
181
184
|
customListHeaderComponent: null,
|
|
182
185
|
showOptionsWhenEmpty: true,
|
|
183
186
|
searchable: true,
|
|
184
|
-
resultsTruncatedMessage: null
|
|
187
|
+
resultsTruncatedMessage: null,
|
|
188
|
+
withSubOptions: false
|
|
185
189
|
};
|
|
186
190
|
|
|
187
191
|
static getDerivedStateFromProps(props, state) {
|
|
@@ -247,6 +251,7 @@ class Typeahead extends Component {
|
|
|
247
251
|
return (
|
|
248
252
|
<this.props.customListComponent
|
|
249
253
|
fixedOptions={this.props.fixedOptions}
|
|
254
|
+
searchEntryValue={this.state.entryValue}
|
|
250
255
|
options={
|
|
251
256
|
this.props.maxVisible
|
|
252
257
|
? this.state.searchResults.slice(0, this.props.maxVisible)
|
|
@@ -267,6 +272,7 @@ class Typeahead extends Component {
|
|
|
267
272
|
displayOption={this.props.displayOption}
|
|
268
273
|
selectedItems={this.props.selectedItems}
|
|
269
274
|
light={this.props.light}
|
|
275
|
+
withSubOptions={this.props.withSubOptions}
|
|
270
276
|
/>
|
|
271
277
|
);
|
|
272
278
|
}
|
|
@@ -473,6 +479,9 @@ class Typeahead extends Component {
|
|
|
473
479
|
{this._renderHiddenInput()}
|
|
474
480
|
{this.props.searchable ? (
|
|
475
481
|
<InputBox>
|
|
482
|
+
<InputIcon>
|
|
483
|
+
<this.props.inputIcon height="18px" />
|
|
484
|
+
</InputIcon>
|
|
476
485
|
<TypeaheadInput
|
|
477
486
|
ref={this.entry}
|
|
478
487
|
type="text"
|
|
@@ -485,9 +494,6 @@ class Typeahead extends Component {
|
|
|
485
494
|
onBlur={this._onBlur}
|
|
486
495
|
light={this.props.light}
|
|
487
496
|
/>
|
|
488
|
-
<InputIcon>
|
|
489
|
-
<this.props.inputIcon height="18px" />
|
|
490
|
-
</InputIcon>
|
|
491
497
|
</InputBox>
|
|
492
498
|
) : null}
|
|
493
499
|
{this._renderIncrementalSearchResults()}
|
|
@@ -1104,6 +1104,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
|
|
|
1104
1104
|
onChange,
|
|
1105
1105
|
onChangeVisConfig,
|
|
1106
1106
|
fields,
|
|
1107
|
+
fieldsAggregated,
|
|
1107
1108
|
description,
|
|
1108
1109
|
isLoading
|
|
1109
1110
|
}) => {
|
|
@@ -1111,6 +1112,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
|
|
|
1111
1112
|
channelScaleType,
|
|
1112
1113
|
domain,
|
|
1113
1114
|
field,
|
|
1115
|
+
aggregation,
|
|
1114
1116
|
key,
|
|
1115
1117
|
property,
|
|
1116
1118
|
range,
|
|
@@ -1134,6 +1136,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
|
|
|
1134
1136
|
scaleOptions.length > 1;
|
|
1135
1137
|
const defaultDescription = 'layerConfiguration.defaultDescription';
|
|
1136
1138
|
const visRange = layer.config.visConfig[range];
|
|
1139
|
+
const aggregator = layer.config.visConfig[aggregation];
|
|
1137
1140
|
|
|
1138
1141
|
return (
|
|
1139
1142
|
<VisConfigByFieldSelector
|
|
@@ -1141,6 +1144,8 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
|
|
|
1141
1144
|
description={description || defaultDescription}
|
|
1142
1145
|
domain={layer.config[domain]}
|
|
1143
1146
|
fields={supportedFields}
|
|
1147
|
+
aggregator={aggregator}
|
|
1148
|
+
fieldsAggregated={fieldsAggregated}
|
|
1144
1149
|
id={layer.id}
|
|
1145
1150
|
key={`${key}-channel-selector`}
|
|
1146
1151
|
property={property}
|
|
@@ -1155,7 +1160,18 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
|
|
|
1155
1160
|
if (visRange?.colorMap) {
|
|
1156
1161
|
onChangeVisConfig({[range]: {...visRange, colorMap: undefined}});
|
|
1157
1162
|
}
|
|
1158
|
-
onChange(
|
|
1163
|
+
onChange(
|
|
1164
|
+
{
|
|
1165
|
+
[field]: val,
|
|
1166
|
+
...(fieldsAggregated && {
|
|
1167
|
+
visConfig: {
|
|
1168
|
+
...layer.config.visConfig,
|
|
1169
|
+
[aggregation]: val?.selectedAggregator
|
|
1170
|
+
}
|
|
1171
|
+
})
|
|
1172
|
+
},
|
|
1173
|
+
key
|
|
1174
|
+
);
|
|
1159
1175
|
}}
|
|
1160
1176
|
updateScale={val => onChange({[scale]: val}, key)}
|
|
1161
1177
|
updateCustomPalette={colorMap => onChangeVisConfig({[range]: {...visRange, colorMap}})}
|
|
@@ -53,7 +53,9 @@ function VisConfigByFieldSelectorFactory(InfoHelper, FieldSelector, ColorDimensi
|
|
|
53
53
|
description: PropTypes.string,
|
|
54
54
|
label: PropTypes.string,
|
|
55
55
|
placeholder: PropTypes.string,
|
|
56
|
-
isLoading: PropTypes.bool
|
|
56
|
+
isLoading: PropTypes.bool,
|
|
57
|
+
fieldsAggregated: PropTypes.bool,
|
|
58
|
+
aggregator: PropTypes.string
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
_updateVisByField = val => {
|
|
@@ -106,6 +108,8 @@ function VisConfigByFieldSelectorFactory(InfoHelper, FieldSelector, ColorDimensi
|
|
|
106
108
|
onSelect={this._updateVisByField}
|
|
107
109
|
erasable
|
|
108
110
|
isLoading={this.props.isLoading}
|
|
111
|
+
withAggregator={this.props.fieldsAggregated}
|
|
112
|
+
aggregator={this.props.fieldsAggregated && this.props.aggregator}
|
|
109
113
|
/>
|
|
110
114
|
</SidePanelSection>
|
|
111
115
|
<div>
|
|
@@ -451,6 +451,57 @@ export const AGGREGATION_TYPES = {
|
|
|
451
451
|
countUnique: 'count unique'
|
|
452
452
|
};
|
|
453
453
|
|
|
454
|
+
export const FIELD_TYPES_AGGREGATORS = {
|
|
455
|
+
date: null,
|
|
456
|
+
geojson: null,
|
|
457
|
+
integer: [
|
|
458
|
+
AGGREGATION_TYPES.average,
|
|
459
|
+
AGGREGATION_TYPES.maximum,
|
|
460
|
+
AGGREGATION_TYPES.minimum,
|
|
461
|
+
AGGREGATION_TYPES.stdev,
|
|
462
|
+
AGGREGATION_TYPES.sum,
|
|
463
|
+
AGGREGATION_TYPES.variance
|
|
464
|
+
],
|
|
465
|
+
real: [
|
|
466
|
+
AGGREGATION_TYPES.average,
|
|
467
|
+
AGGREGATION_TYPES.maximum,
|
|
468
|
+
AGGREGATION_TYPES.minimum,
|
|
469
|
+
AGGREGATION_TYPES.stdev,
|
|
470
|
+
AGGREGATION_TYPES.sum,
|
|
471
|
+
AGGREGATION_TYPES.variance
|
|
472
|
+
],
|
|
473
|
+
string: null,
|
|
474
|
+
timestamp: null,
|
|
475
|
+
point: null
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
export const FIELD_AGGREGATORS = [
|
|
479
|
+
{
|
|
480
|
+
id: AGGREGATION_TYPES.average,
|
|
481
|
+
displayName: 'AVG'
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
id: AGGREGATION_TYPES.maximum,
|
|
485
|
+
displayName: 'MAX'
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
id: AGGREGATION_TYPES.minimum,
|
|
489
|
+
displayName: 'MIN'
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
id: AGGREGATION_TYPES.stdev,
|
|
493
|
+
displayName: 'STDEV'
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
id: AGGREGATION_TYPES.sum,
|
|
497
|
+
displayName: 'SUM'
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
id: AGGREGATION_TYPES.variance,
|
|
501
|
+
displayName: 'VARIANCE'
|
|
502
|
+
}
|
|
503
|
+
];
|
|
504
|
+
|
|
454
505
|
export const linearFieldScaleFunctions = {
|
|
455
506
|
[CHANNEL_SCALES.color]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile, SCALE_TYPES.custom],
|
|
456
507
|
[CHANNEL_SCALES.radius]: [SCALE_TYPES.sqrt],
|
package/src/constants/index.js
CHANGED