@carto/kepler.gl 0.0.13 → 0.0.16
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/CHANGELOG.md +711 -0
- package/dist/components/common/icons/index.js +9 -1
- package/dist/components/common/icons/swap-horizontal.js +68 -0
- package/dist/components/map-container.js +59 -53
- package/dist/components/side-panel/layer-panel/color-palette.js +12 -6
- package/dist/components/side-panel/layer-panel/color-range-selector.js +51 -17
- package/dist/components/side-panel/layer-panel/custom-palette.js +22 -8
- package/dist/components/side-panel/layer-panel/layer-config-group.js +19 -10
- package/dist/components/side-panel/layer-panel/layer-configurator.js +4 -4
- package/dist/components/side-panel/layer-panel/text-label-panel.js +18 -10
- package/dist/constants/default-settings.js +1 -1
- package/dist/localization/en.js +6 -1
- package/package.json +8 -8
- package/src/components/common/icons/index.js +1 -0
- package/src/components/common/icons/swap-horizontal.js +43 -0
- package/src/components/map-container.js +7 -4
- package/src/components/side-panel/layer-panel/color-palette.js +10 -3
- package/src/components/side-panel/layer-panel/color-range-selector.js +68 -28
- package/src/components/side-panel/layer-panel/custom-palette.js +23 -17
- package/src/components/side-panel/layer-panel/layer-config-group.js +16 -7
- package/src/components/side-panel/layer-panel/layer-configurator.js +20 -12
- package/src/components/side-panel/layer-panel/text-label-panel.js +15 -6
- package/src/localization/en.js +5 -0
- package/umd/keplergl.min.js +28 -28
|
@@ -25,7 +25,7 @@ import styled from 'styled-components';
|
|
|
25
25
|
import {createSelector} from 'reselect';
|
|
26
26
|
|
|
27
27
|
import ItemSelector from 'components/common/item-selector/item-selector';
|
|
28
|
-
import {PanelLabel} from 'components/common/styled-components';
|
|
28
|
+
import {PanelLabel, Button, Tooltip} from 'components/common/styled-components';
|
|
29
29
|
import Switch from 'components/common/switch';
|
|
30
30
|
import ColorPalette from './color-palette';
|
|
31
31
|
import CustomPalette from './custom-palette';
|
|
@@ -33,12 +33,13 @@ import {COLOR_RANGES} from 'constants/color-ranges';
|
|
|
33
33
|
import {numberSort} from 'utils/data-utils';
|
|
34
34
|
import {reverseColorRange} from 'utils/color-utils';
|
|
35
35
|
import {FormattedMessage} from 'localization';
|
|
36
|
+
import {SwapHorizontal} from 'components/common/icons';
|
|
36
37
|
|
|
37
|
-
export const ALL_TYPES = uniq(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
);
|
|
38
|
+
export const ALL_TYPES = uniq([
|
|
39
|
+
'all',
|
|
40
|
+
...COLOR_RANGES.map(c => c.type).filter(ctype => ctype),
|
|
41
|
+
'custom'
|
|
42
|
+
]);
|
|
42
43
|
|
|
43
44
|
export const ALL_STEPS = uniq(COLOR_RANGES.map(d => d.colors.length)).sort(numberSort);
|
|
44
45
|
|
|
@@ -66,8 +67,15 @@ const StyledPaletteConfig = styled.div`
|
|
|
66
67
|
.item-selector .item-selector__dropdown {
|
|
67
68
|
${props => props.theme.secondaryInput};
|
|
68
69
|
}
|
|
70
|
+
.color-palette__config__button {
|
|
71
|
+
svg {
|
|
72
|
+
margin: 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
69
75
|
`;
|
|
70
76
|
|
|
77
|
+
const CONFIG_SETTINGS_CUSTOM_REVERSED_BUTTON_TYPE = 'custom-reversed-button';
|
|
78
|
+
|
|
71
79
|
const CONFIG_SETTINGS = {
|
|
72
80
|
type: {
|
|
73
81
|
type: 'select',
|
|
@@ -78,12 +86,7 @@ const CONFIG_SETTINGS = {
|
|
|
78
86
|
options: ALL_STEPS
|
|
79
87
|
},
|
|
80
88
|
reversed: {
|
|
81
|
-
type:
|
|
82
|
-
options: [true, false]
|
|
83
|
-
},
|
|
84
|
-
custom: {
|
|
85
|
-
label: 'customPalette',
|
|
86
|
-
type: 'switch',
|
|
89
|
+
type: CONFIG_SETTINGS_CUSTOM_REVERSED_BUTTON_TYPE,
|
|
87
90
|
options: [true, false]
|
|
88
91
|
}
|
|
89
92
|
};
|
|
@@ -122,7 +125,10 @@ export default class ColorRangeSelect extends Component {
|
|
|
122
125
|
);
|
|
123
126
|
|
|
124
127
|
_updateConfig = ({key, value}) => {
|
|
125
|
-
this._setColorRangeConfig({
|
|
128
|
+
this._setColorRangeConfig({
|
|
129
|
+
[key]: value,
|
|
130
|
+
...(key === 'type' && {custom: value === 'custom'})
|
|
131
|
+
});
|
|
126
132
|
};
|
|
127
133
|
|
|
128
134
|
_onSetCustomPalette = config => {
|
|
@@ -157,16 +163,21 @@ export default class ColorRangeSelect extends Component {
|
|
|
157
163
|
|
|
158
164
|
return (
|
|
159
165
|
<StyledColorRangeSelector>
|
|
160
|
-
<StyledColorConfig>
|
|
161
|
-
{
|
|
162
|
-
|
|
163
|
-
key
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
<StyledColorConfig className="color-range-selector__config">
|
|
167
|
+
{Object.keys(colorRangeConfig)
|
|
168
|
+
.filter(
|
|
169
|
+
key =>
|
|
170
|
+
Boolean(CONFIG_SETTINGS[key]) && (colorRangeConfig.custom ? key === 'type' : true)
|
|
171
|
+
)
|
|
172
|
+
.map(key => (
|
|
173
|
+
<PaletteConfig
|
|
174
|
+
key={key}
|
|
175
|
+
label={CONFIG_SETTINGS[key].label || key}
|
|
176
|
+
config={CONFIG_SETTINGS[key]}
|
|
177
|
+
value={colorRangeConfig[key]}
|
|
178
|
+
onChange={value => this._updateConfig({key, value})}
|
|
179
|
+
/>
|
|
180
|
+
))}
|
|
170
181
|
</StyledColorConfig>
|
|
171
182
|
|
|
172
183
|
{colorRangeConfig.custom ? (
|
|
@@ -193,11 +204,16 @@ export default class ColorRangeSelect extends Component {
|
|
|
193
204
|
}
|
|
194
205
|
|
|
195
206
|
export const PaletteConfig = ({label, value, config: {type, options}, onChange}) => (
|
|
196
|
-
<StyledPaletteConfig
|
|
207
|
+
<StyledPaletteConfig
|
|
208
|
+
className={`color-palette__config color-palette__config--${label}`}
|
|
209
|
+
onClick={e => e.stopPropagation()}
|
|
210
|
+
>
|
|
197
211
|
<div className="color-palette__config__label">
|
|
198
|
-
|
|
199
|
-
<
|
|
200
|
-
|
|
212
|
+
{type !== CONFIG_SETTINGS_CUSTOM_REVERSED_BUTTON_TYPE && (
|
|
213
|
+
<PanelLabel>
|
|
214
|
+
<FormattedMessage id={`color.${label}`} />
|
|
215
|
+
</PanelLabel>
|
|
216
|
+
)}
|
|
201
217
|
</div>
|
|
202
218
|
{type === 'select' && (
|
|
203
219
|
<div className="color-palette__config__select">
|
|
@@ -213,6 +229,22 @@ export const PaletteConfig = ({label, value, config: {type, options}, onChange})
|
|
|
213
229
|
{type === 'switch' && (
|
|
214
230
|
<Switch checked={value} id={`${label}-toggle`} onChange={() => onChange(!value)} secondary />
|
|
215
231
|
)}
|
|
232
|
+
{type === CONFIG_SETTINGS_CUSTOM_REVERSED_BUTTON_TYPE && (
|
|
233
|
+
<Button
|
|
234
|
+
className={`color-palette__config__button ${
|
|
235
|
+
value ? 'color-palette__config__button--active' : ''
|
|
236
|
+
}`}
|
|
237
|
+
data-tip
|
|
238
|
+
data-for={`${label}-tooltip`}
|
|
239
|
+
{...(!value && {link: true})}
|
|
240
|
+
onClick={() => onChange(!value)}
|
|
241
|
+
>
|
|
242
|
+
<SwapHorizontal />
|
|
243
|
+
<Tooltip id={`${label}-tooltip`} effect="solid" place="top">
|
|
244
|
+
{label}
|
|
245
|
+
</Tooltip>
|
|
246
|
+
</Button>
|
|
247
|
+
)}
|
|
216
248
|
</StyledPaletteConfig>
|
|
217
249
|
);
|
|
218
250
|
|
|
@@ -237,7 +269,15 @@ export const ColorPaletteGroup = ({reversed, onSelect, selected, colorRanges}) =
|
|
|
237
269
|
colors={colorRange.colors}
|
|
238
270
|
isReversed={reversed}
|
|
239
271
|
isSelected={colorRange.name === selected.name && reversed === Boolean(selected.reversed)}
|
|
240
|
-
|
|
272
|
+
rootProps={{
|
|
273
|
+
'data-tip': true,
|
|
274
|
+
'data-for': `color-range-${i}-tooltip`
|
|
275
|
+
}}
|
|
276
|
+
>
|
|
277
|
+
<Tooltip id={`color-range-${i}-tooltip`} effect="solid" place="top">
|
|
278
|
+
{colorRange.name}
|
|
279
|
+
</Tooltip>
|
|
280
|
+
</ColorPalette>
|
|
241
281
|
</StyledColorRange>
|
|
242
282
|
))}
|
|
243
283
|
</div>
|
|
@@ -30,6 +30,7 @@ import {VertDots, Trash} from 'components/common/icons';
|
|
|
30
30
|
import ColorPalette from './color-palette';
|
|
31
31
|
import CustomPicker from './custom-picker';
|
|
32
32
|
import {arrayMove} from 'utils/data-utils';
|
|
33
|
+
import {FormattedMessage} from 'react-intl';
|
|
33
34
|
|
|
34
35
|
const dragHandleActive = css`
|
|
35
36
|
.layer__drag-handle {
|
|
@@ -115,7 +116,9 @@ const StyledButtonContainer = styled.div`
|
|
|
115
116
|
direction: rtl;
|
|
116
117
|
`;
|
|
117
118
|
|
|
118
|
-
const StyledInlineInput = styled.div
|
|
119
|
+
const StyledInlineInput = styled.div.attrs({
|
|
120
|
+
className: 'custom-palette__input'
|
|
121
|
+
})`
|
|
119
122
|
margin-left: 12px;
|
|
120
123
|
input {
|
|
121
124
|
color: ${props => props.theme.textColorHl};
|
|
@@ -198,7 +201,6 @@ class CustomPalette extends Component {
|
|
|
198
201
|
_onApply = event => {
|
|
199
202
|
event.stopPropagation();
|
|
200
203
|
event.preventDefault();
|
|
201
|
-
this.props.onCancel();
|
|
202
204
|
this.props.onApply(this.props.customPalette, event);
|
|
203
205
|
};
|
|
204
206
|
|
|
@@ -254,27 +256,31 @@ class CustomPalette extends Component {
|
|
|
254
256
|
id={`input-layer-label-${index}`}
|
|
255
257
|
/>
|
|
256
258
|
</StyledInlineInput>
|
|
257
|
-
<StyledTrash
|
|
259
|
+
<StyledTrash
|
|
260
|
+
className="custom-palette__trash"
|
|
261
|
+
onClick={() => this._onColorDelete(index)}
|
|
262
|
+
>
|
|
258
263
|
<Trash className="trashbin" />
|
|
259
264
|
</StyledTrash>
|
|
260
265
|
</SortableItem>
|
|
261
266
|
))}
|
|
262
267
|
</WrappedSortableContainer>
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
<StyledLine />
|
|
268
|
-
{/* Cancel or Confirm Buttons */}
|
|
269
|
-
<StyledButtonContainer>
|
|
270
|
-
<Button className="confirm-apply__button" link onClick={this._onApply}>
|
|
271
|
-
Confirm
|
|
272
|
-
</Button>
|
|
273
|
-
<Button link onClick={this.props.onCancel}>
|
|
274
|
-
Cancel
|
|
268
|
+
<div className="custom-palette-actions">
|
|
269
|
+
{/* Add Step Button */}
|
|
270
|
+
<Button className="add-step__button" link onClick={this._onColorAdd}>
|
|
271
|
+
<FormattedMessage id="customPalette.addStep" />
|
|
275
272
|
</Button>
|
|
276
|
-
|
|
277
|
-
|
|
273
|
+
<StyledLine className="custom-palette-actions__separator" />
|
|
274
|
+
{/* Cancel or Confirm Buttons */}
|
|
275
|
+
<StyledButtonContainer>
|
|
276
|
+
<Button className="confirm-apply__button" link onClick={this._onApply}>
|
|
277
|
+
<FormattedMessage id="customPalette.apply" />
|
|
278
|
+
</Button>
|
|
279
|
+
<Button className="cancel-apply__button" link onClick={this.props.onCancel}>
|
|
280
|
+
<FormattedMessage id="customPalette.cancel" />
|
|
281
|
+
</Button>
|
|
282
|
+
</StyledButtonContainer>
|
|
283
|
+
</div>
|
|
278
284
|
<Portaled isOpened={this.props.showSketcher !== false} left={280} top={-300}>
|
|
279
285
|
<CustomPicker
|
|
280
286
|
color={colors[this.props.showSketcher]}
|
|
@@ -144,7 +144,8 @@ function LayerConfigGroupFactory(LayerConfigGroupLabel) {
|
|
|
144
144
|
expanded: false,
|
|
145
145
|
onChange: () => {},
|
|
146
146
|
description: null,
|
|
147
|
-
disabled: false
|
|
147
|
+
disabled: false,
|
|
148
|
+
CollapseButton: VertThreeDots
|
|
148
149
|
};
|
|
149
150
|
|
|
150
151
|
static getDerivedStateFromProps(props, state) {
|
|
@@ -153,6 +154,10 @@ function LayerConfigGroupFactory(LayerConfigGroupLabel) {
|
|
|
153
154
|
return {collapsed: false};
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
if (props.layer && !props.layer.config.visConfig[props.property] && !state.collapsed) {
|
|
158
|
+
return {collapsed: true};
|
|
159
|
+
}
|
|
160
|
+
|
|
156
161
|
return null;
|
|
157
162
|
}
|
|
158
163
|
|
|
@@ -169,17 +174,15 @@ function LayerConfigGroupFactory(LayerConfigGroupLabel) {
|
|
|
169
174
|
onChange,
|
|
170
175
|
collapsible,
|
|
171
176
|
description,
|
|
172
|
-
disabled
|
|
177
|
+
disabled,
|
|
178
|
+
CollapseButton
|
|
173
179
|
} = this.props;
|
|
174
180
|
|
|
175
181
|
const {collapsed} = this.state;
|
|
176
182
|
|
|
177
183
|
return (
|
|
178
184
|
<StyledLayerConfigGroup className={classnames('layer-config-group', {collapsed, disabled})}>
|
|
179
|
-
<StyledConfigGroupHeader
|
|
180
|
-
className="layer-config-group__header"
|
|
181
|
-
onClick={() => this.setState({collapsed: !this.state.collapsed})}
|
|
182
|
-
>
|
|
185
|
+
<StyledConfigGroupHeader className="layer-config-group__header">
|
|
183
186
|
<LayerConfigGroupLabel label={label} description={description} />
|
|
184
187
|
<StyledLayerConfigGroupAction className="layer-config-group__action">
|
|
185
188
|
{property ? (
|
|
@@ -189,7 +192,13 @@ function LayerConfigGroupFactory(LayerConfigGroupLabel) {
|
|
|
189
192
|
onChange={() => onChange({[property]: !layer.config.visConfig[property]})}
|
|
190
193
|
/>
|
|
191
194
|
) : null}
|
|
192
|
-
{collapsible ?
|
|
195
|
+
{collapsible ? (
|
|
196
|
+
<CollapseButton
|
|
197
|
+
onClick={() => this.setState({collapsed: !this.state.collapsed})}
|
|
198
|
+
active={!this.state.collapsed}
|
|
199
|
+
height="18px"
|
|
200
|
+
/>
|
|
201
|
+
) : null}
|
|
193
202
|
</StyledLayerConfigGroupAction>
|
|
194
203
|
</StyledConfigGroupHeader>
|
|
195
204
|
<ConfigGroupContent
|
|
@@ -951,7 +951,11 @@ export default function LayerConfiguratorFactory(
|
|
|
951
951
|
{layer.layerInfoModal ? (
|
|
952
952
|
<HowToButton onClick={() => this.props.openModal(layer.layerInfoModal)} />
|
|
953
953
|
) : null}
|
|
954
|
-
<LayerConfigGroup
|
|
954
|
+
<LayerConfigGroup
|
|
955
|
+
label={'layer.basic'}
|
|
956
|
+
collapsible={Object.keys(layer.config.columns).length > 0}
|
|
957
|
+
expanded={!layer.hasAllColumns()}
|
|
958
|
+
>
|
|
955
959
|
<LayerTypeSelector
|
|
956
960
|
datasets={datasets}
|
|
957
961
|
layer={layer}
|
|
@@ -966,17 +970,21 @@ export default function LayerConfiguratorFactory(
|
|
|
966
970
|
onSelect={value => updateLayerConfig({dataId: value})}
|
|
967
971
|
/>
|
|
968
972
|
)}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
973
|
+
{Object.keys(layer.config.columns).length > 0 && (
|
|
974
|
+
<ConfigGroupCollapsibleContent>
|
|
975
|
+
<LayerColumnConfig
|
|
976
|
+
columnPairs={layer.columnPairs}
|
|
977
|
+
columns={layer.config.columns}
|
|
978
|
+
assignColumnPairs={layer.assignColumnPairs.bind(layer)}
|
|
979
|
+
assignColumn={layer.assignColumn.bind(layer)}
|
|
980
|
+
columnLabels={layer.columnLabels}
|
|
981
|
+
fields={fields}
|
|
982
|
+
fieldPairs={fieldPairs}
|
|
983
|
+
updateLayerConfig={updateLayerConfig}
|
|
984
|
+
updateLayerType={this.props.updateLayerType}
|
|
985
|
+
/>
|
|
986
|
+
</ConfigGroupCollapsibleContent>
|
|
987
|
+
)}
|
|
980
988
|
</LayerConfigGroup>
|
|
981
989
|
{this[renderTemplate] &&
|
|
982
990
|
this[renderTemplate]({
|
|
@@ -50,8 +50,17 @@ function TextLabelPanelFactory(RangeSlider, LayerConfigGroup, FieldSelector) {
|
|
|
50
50
|
updateLayerTextLabel: PropTypes.func.isRequired
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
static defaultProps = {
|
|
54
|
+
AddButton: props => (
|
|
55
|
+
<Button {...props} link>
|
|
56
|
+
<Add height="12px" />
|
|
57
|
+
<FormattedMessage id="panel.text.addMoreLabel" />
|
|
58
|
+
</Button>
|
|
59
|
+
)
|
|
60
|
+
};
|
|
61
|
+
|
|
53
62
|
render() {
|
|
54
|
-
const {updateLayerTextLabel, textLabel, fields} = this.props;
|
|
63
|
+
const {updateLayerTextLabel, textLabel, fields, AddButton} = this.props;
|
|
55
64
|
const currentFields = textLabel.map(tl => tl.field && tl.field.name).filter(d => d);
|
|
56
65
|
return (
|
|
57
66
|
<LayerConfigGroup label={'panel.text.label'} collapsible>
|
|
@@ -65,7 +74,10 @@ function TextLabelPanelFactory(RangeSlider, LayerConfigGroup, FieldSelector) {
|
|
|
65
74
|
</ConfigGroupCollapsibleHeader>
|
|
66
75
|
<ConfigGroupCollapsibleContent>
|
|
67
76
|
{textLabel.map((tl, idx) => (
|
|
68
|
-
<div
|
|
77
|
+
<div
|
|
78
|
+
key={tl.field ? tl.field.name : `null-${idx}`}
|
|
79
|
+
className="side-panel-section-group"
|
|
80
|
+
>
|
|
69
81
|
<PanelLabel>
|
|
70
82
|
<FormattedMessage id={'panel.text.labelWithId'} values={{labelId: idx + 1}} />
|
|
71
83
|
</PanelLabel>
|
|
@@ -129,10 +141,7 @@ function TextLabelPanelFactory(RangeSlider, LayerConfigGroup, FieldSelector) {
|
|
|
129
141
|
</div>
|
|
130
142
|
))}
|
|
131
143
|
<SidePanelSection>
|
|
132
|
-
<
|
|
133
|
-
<Add height="12px" />
|
|
134
|
-
<FormattedMessage id="panel.text.addMoreLabel" />
|
|
135
|
-
</Button>
|
|
144
|
+
<AddButton onClick={val => updateLayerTextLabel(textLabel.length)} />
|
|
136
145
|
</SidePanelSection>
|
|
137
146
|
</ConfigGroupCollapsibleContent>
|
|
138
147
|
</LayerConfigGroup>
|
package/src/localization/en.js
CHANGED