@carto/kepler.gl 0.0.40-alpha.4 → 0.0.40-alpha.aggregation-selector-3

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/dist/components/common/field-selector.js +62 -17
  2. package/dist/components/common/field-token.js +4 -12
  3. package/dist/components/common/icons/chevron-right.js +69 -0
  4. package/dist/components/common/icons/index.js +9 -1
  5. package/dist/components/common/item-selector/dropdown-list.js +133 -20
  6. package/dist/components/common/item-selector/item-selector-submenu.js +133 -0
  7. package/dist/components/common/item-selector/item-selector.js +7 -4
  8. package/dist/components/common/item-selector/typeahead.js +16 -16
  9. package/dist/components/side-panel/layer-panel/layer-configurator.js +11 -4
  10. package/dist/components/side-panel/layer-panel/vis-config-by-field-selector.js +7 -3
  11. package/dist/constants/default-settings.js +33 -3
  12. package/dist/constants/index.js +7 -1
  13. package/dist/styles/base.js +3 -3
  14. package/package.json +1 -1
  15. package/src/components/common/field-selector.js +62 -21
  16. package/src/components/common/field-token.js +13 -14
  17. package/src/components/common/icons/chevron-right.js +47 -0
  18. package/src/components/common/icons/index.js +1 -0
  19. package/src/components/common/item-selector/dropdown-list.js +131 -44
  20. package/src/components/common/item-selector/item-selector-submenu.js +88 -0
  21. package/src/components/common/item-selector/item-selector.d.ts +2 -1
  22. package/src/components/common/item-selector/item-selector.js +5 -2
  23. package/src/components/common/item-selector/typeahead.js +27 -21
  24. package/src/components/side-panel/layer-panel/layer-configurator.js +17 -1
  25. package/src/components/side-panel/layer-panel/vis-config-by-field-selector.js +5 -1
  26. package/src/constants/default-settings.js +51 -0
  27. package/src/constants/index.js +2 -1
  28. package/src/styles/base.js +1 -0
  29. package/umd/keplergl.min.js +31 -31
  30. package/CHANGELOG.md +0 -711
@@ -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()}
@@ -1108,6 +1108,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1108
1108
  onChange,
1109
1109
  onChangeVisConfig,
1110
1110
  fields,
1111
+ fieldsAggregated,
1111
1112
  description,
1112
1113
  isLoading
1113
1114
  }) => {
@@ -1115,6 +1116,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1115
1116
  channelScaleType,
1116
1117
  domain,
1117
1118
  field,
1119
+ aggregation,
1118
1120
  key,
1119
1121
  property,
1120
1122
  range,
@@ -1138,6 +1140,7 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1138
1140
  scaleOptions.length > 1;
1139
1141
  const defaultDescription = 'layerConfiguration.defaultDescription';
1140
1142
  const visRange = layer.config.visConfig[range];
1143
+ const aggregator = layer.config.visConfig[aggregation];
1141
1144
 
1142
1145
  return (
1143
1146
  <VisConfigByFieldSelector
@@ -1145,6 +1148,8 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1145
1148
  description={description || defaultDescription}
1146
1149
  domain={layer.config[domain]}
1147
1150
  fields={supportedFields}
1151
+ aggregator={aggregator}
1152
+ fieldsAggregated={fieldsAggregated}
1148
1153
  id={layer.id}
1149
1154
  key={`${key}-channel-selector`}
1150
1155
  property={property}
@@ -1159,7 +1164,18 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1159
1164
  if (visRange?.colorMap) {
1160
1165
  onChangeVisConfig({[range]: {...visRange, colorMap: undefined}});
1161
1166
  }
1162
- onChange({[field]: val}, key);
1167
+ onChange(
1168
+ {
1169
+ [field]: val,
1170
+ ...(fieldsAggregated && {
1171
+ visConfig: {
1172
+ ...layer.config.visConfig,
1173
+ [aggregation]: val?.selectedAggregator
1174
+ }
1175
+ })
1176
+ },
1177
+ key
1178
+ );
1163
1179
  }}
1164
1180
  updateScale={val => onChange({[scale]: val}, key)}
1165
1181
  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';
@@ -896,6 +896,7 @@ const dropdownList = css`
896
896
 
897
897
  .list__item {
898
898
  ${props => props.theme.dropdownListItem};
899
+ ${dropdownListItem};
899
900
  }
900
901
 
901
902
  .list__item__anchor {