@carto/kepler.gl 0.0.42 → 0.0.43

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +711 -0
  2. package/dist/components/common/field-selector.js +62 -17
  3. package/dist/components/common/field-token.js +4 -12
  4. package/dist/components/common/icons/chevron-right.js +69 -0
  5. package/dist/components/common/icons/index.js +9 -1
  6. package/dist/components/common/item-selector/dropdown-list.js +137 -21
  7. package/dist/components/common/item-selector/item-selector-submenu.js +133 -0
  8. package/dist/components/common/item-selector/item-selector.js +7 -4
  9. package/dist/components/common/item-selector/typeahead.js +16 -16
  10. package/dist/components/side-panel/layer-panel/layer-configurator.js +11 -4
  11. package/dist/components/side-panel/layer-panel/vis-config-by-field-selector.js +7 -3
  12. package/dist/constants/default-settings.js +33 -3
  13. package/dist/constants/index.js +7 -1
  14. package/dist/styles/base.js +4 -4
  15. package/package.json +1 -1
  16. package/src/components/common/field-selector.js +62 -21
  17. package/src/components/common/field-token.js +13 -14
  18. package/src/components/common/icons/chevron-right.js +47 -0
  19. package/src/components/common/icons/index.js +1 -0
  20. package/src/components/common/item-selector/dropdown-list.js +135 -36
  21. package/src/components/common/item-selector/item-selector-submenu.js +88 -0
  22. package/src/components/common/item-selector/item-selector.d.ts +2 -1
  23. package/src/components/common/item-selector/item-selector.js +5 -2
  24. package/src/components/common/item-selector/typeahead.js +27 -21
  25. package/src/components/side-panel/layer-panel/layer-configurator.js +17 -1
  26. package/src/components/side-panel/layer-panel/vis-config-by-field-selector.js +5 -1
  27. package/src/constants/default-settings.js +51 -0
  28. package/src/constants/index.js +2 -1
  29. package/src/styles/base.js +4 -0
  30. 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.dropdownListBgd};
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.attrs({
55
- className: 'typeahead__input_box'
56
- })`
57
- padding: 8px;
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)} :hover {
62
- cursor: pointer;
63
- background-color: ${props =>
64
- props.light ? props.theme.selectBackgroundLT : props.theme.secondaryInputBgd};
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.attrs({
69
- className: 'typeahead__input_icon'
70
- })`
67
+ const InputIcon = styled.div`
71
68
  position: absolute;
72
- right: 15px;
73
- top: 14px;
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()}
@@ -1129,6 +1129,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1129
1129
  onChange,
1130
1130
  onChangeVisConfig,
1131
1131
  fields,
1132
+ fieldsAggregated,
1132
1133
  description,
1133
1134
  isLoading
1134
1135
  }) => {
@@ -1136,6 +1137,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1136
1137
  channelScaleType,
1137
1138
  domain,
1138
1139
  field,
1140
+ aggregation,
1139
1141
  key,
1140
1142
  property,
1141
1143
  range,
@@ -1159,6 +1161,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1159
1161
  scaleOptions.length > 1;
1160
1162
  const defaultDescription = 'layerConfiguration.defaultDescription';
1161
1163
  const visRange = layer.config.visConfig[range];
1164
+ const aggregator = layer.config.visConfig[aggregation];
1162
1165
 
1163
1166
  return (
1164
1167
  <VisConfigByFieldSelector
@@ -1166,6 +1169,8 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1166
1169
  description={description || defaultDescription}
1167
1170
  domain={layer.config[domain]}
1168
1171
  fields={supportedFields}
1172
+ aggregator={aggregator}
1173
+ fieldsAggregated={fieldsAggregated}
1169
1174
  id={layer.id}
1170
1175
  key={`${key}-channel-selector`}
1171
1176
  property={property}
@@ -1180,7 +1185,18 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1180
1185
  if (visRange?.colorMap) {
1181
1186
  onChangeVisConfig({[range]: {...visRange, colorMap: undefined}});
1182
1187
  }
1183
- onChange({[field]: val}, key);
1188
+ onChange(
1189
+ {
1190
+ [field]: val,
1191
+ ...(fieldsAggregated && {
1192
+ visConfig: {
1193
+ ...layer.config.visConfig,
1194
+ [aggregation]: val?.selectedAggregator
1195
+ }
1196
+ })
1197
+ },
1198
+ key
1199
+ );
1184
1200
  }}
1185
1201
  updateScale={val => onChange({[scale]: val}, key)}
1186
1202
  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],
@@ -67,7 +67,8 @@ export {
67
67
  RESOLUTIONS,
68
68
  SORT_ORDER,
69
69
  MAP_CONTROLS,
70
- UNKNOWN_COLOR
70
+ UNKNOWN_COLOR,
71
+ FIELD_AGGREGATORS
71
72
  } from './default-settings';
72
73
 
73
74
  export {BUG_REPORT_LINK, USER_GUIDE_DOC} from './user-guides';
@@ -835,10 +835,13 @@ const dropdownListAnchorLT = css`
835
835
  `;
836
836
 
837
837
  const dropdownListSize = css`
838
+ display: flex;
839
+ align-items: center;
838
840
  font-size: 11px;
839
841
  padding: 3px 9px;
840
842
  font-weight: 500;
841
843
  white-space: nowrap;
844
+ height: 32px;
842
845
  `;
843
846
 
844
847
  const dropdownListItem = css`
@@ -896,6 +899,7 @@ const dropdownList = css`
896
899
 
897
900
  .list__item {
898
901
  ${props => props.theme.dropdownListItem};
902
+ ${dropdownListItem};
899
903
  }
900
904
 
901
905
  .list__item__anchor {