mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 16:51:20 +01:00
Merge remote-tracking branch 'upstream/master' into fix/web-driver-tests-v6-circleci-config
Conflicts: package-lock.json src/components/inputs/AutocompleteInput.jsx
This commit is contained in:
commit
4215b5808f
9 changed files with 91 additions and 103 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "maputnik",
|
"name": "maputnik",
|
||||||
"version": "1.1.0-beta",
|
"version": "1.1.0-beta3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -7945,9 +7945,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mapbox-gl-inspect": {
|
"mapbox-gl-inspect": {
|
||||||
"version": "1.2.4",
|
"version": "1.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/mapbox-gl-inspect/-/mapbox-gl-inspect-1.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/mapbox-gl-inspect/-/mapbox-gl-inspect-1.2.6.tgz",
|
||||||
"integrity": "sha1-7WD6SfXlS4JieOFKthJQqYYKYjU=",
|
"integrity": "sha512-4qOIuLa+I81Nj67NEtcxn+AdigysIMkY57j1cb1C0k1/yHTvq5viCZozjfTRavhLRBj1NDmoWJTi0A1mGpz2JQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"lodash.isequal": "4.5.0",
|
"lodash.isequal": "4.5.0",
|
||||||
"randomcolor": "0.4.4"
|
"randomcolor": "0.4.4"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "maputnik",
|
"name": "maputnik",
|
||||||
"version": "1.1.0-beta",
|
"version": "1.1.0-beta3",
|
||||||
"description": "A MapboxGL visual style editor",
|
"description": "A MapboxGL visual style editor",
|
||||||
"main": "''",
|
"main": "''",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
"lodash.isequal": "^4.5.0",
|
"lodash.isequal": "^4.5.0",
|
||||||
"lodash.throttle": "^4.1.1",
|
"lodash.throttle": "^4.1.1",
|
||||||
"mapbox-gl": "^0.43.0",
|
"mapbox-gl": "^0.43.0",
|
||||||
"mapbox-gl-inspect": "^1.2.4",
|
"mapbox-gl-inspect": "^1.2.6",
|
||||||
"maputnik-design": "github:maputnik/design",
|
"maputnik-design": "github:maputnik/design",
|
||||||
"mousetrap": "^1.6.1",
|
"mousetrap": "^1.6.1",
|
||||||
"ol-mapbox-style": "^1.0.1",
|
"ol-mapbox-style": "^1.0.1",
|
||||||
|
|
|
@ -266,7 +266,8 @@ export default class App extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
return <MapboxGlMap {...mapProps}
|
return <MapboxGlMap {...mapProps}
|
||||||
inspectModeEnabled={this.state.inspectModeEnabled}
|
inspectModeEnabled={this.state.inspectModeEnabled}
|
||||||
highlightedLayer={this.state.mapStyle.layers[this.state.selectedLayerIndex]} />
|
highlightedLayer={this.state.mapStyle.layers[this.state.selectedLayerIndex]}
|
||||||
|
onLayerSelect={this.onLayerSelect.bind(this)} />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,24 @@ import Autocomplete from 'react-autocomplete'
|
||||||
|
|
||||||
const MAX_HEIGHT = 140;
|
const MAX_HEIGHT = 140;
|
||||||
|
|
||||||
class AutocompleteMenu extends React.Component {
|
class AutocompleteInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
keepMenuWithinWindowBounds: PropTypes.bool,
|
value: PropTypes.string,
|
||||||
style: PropTypes.object,
|
options: PropTypes.array,
|
||||||
children: PropTypes.node
|
onChange: PropTypes.func,
|
||||||
|
keepMenuWithinWindowBounds: PropTypes.bool
|
||||||
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
onChange: () => {},
|
||||||
|
options: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
maxHeight: MAX_HEIGHT
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
calcMaxHeight() {
|
calcMaxHeight() {
|
||||||
|
@ -33,74 +46,32 @@ class AutocompleteMenu extends React.Component {
|
||||||
this.calcMaxHeight();
|
this.calcMaxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
maxHeight: MAX_HEIGHT
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
style: {}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const maxHeight = this.state.maxHeight - this.props.style.marginBottom || 0;
|
return <div
|
||||||
const style = {
|
|
||||||
maxHeight: maxHeight+"px"
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
ref={(el) => {
|
ref={(el) => {
|
||||||
this.autocompleteMenuEl = el;
|
this.autocompleteMenuEl = el;
|
||||||
}}
|
}}
|
||||||
className={"maputnik-autocomplete-menu"}
|
|
||||||
style={style}
|
|
||||||
>
|
>
|
||||||
{this.props.children}
|
<Autocomplete
|
||||||
</div>
|
menuStyle={{
|
||||||
)
|
position: "absolute",
|
||||||
}
|
overflow: "auto",
|
||||||
}
|
maxHeight: this.state.maxHeight
|
||||||
|
}}
|
||||||
class AutocompleteInput extends React.Component {
|
|
||||||
static propTypes = {
|
|
||||||
value: PropTypes.string,
|
|
||||||
options: PropTypes.array,
|
|
||||||
onChange: PropTypes.func,
|
|
||||||
keepMenuWithinWindowBounds: PropTypes.bool
|
|
||||||
}
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
onChange: () => {},
|
|
||||||
options: [],
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return <Autocomplete
|
|
||||||
wrapperProps={{
|
wrapperProps={{
|
||||||
className: "maputnik-autocomplete",
|
className: "maputnik-autocomplete",
|
||||||
style: null
|
style: null
|
||||||
}}
|
}}
|
||||||
renderMenu={(items) => {
|
|
||||||
return <AutocompleteMenu keepMenuWithinWindowBounds={this.props.keepMenuWithinWindowBounds} style={{marginBottom: 4}}>
|
|
||||||
{items}
|
|
||||||
</AutocompleteMenu>
|
|
||||||
}}
|
|
||||||
inputProps={{
|
inputProps={{
|
||||||
className: "maputnik-string"
|
className: "maputnik-string"
|
||||||
}}
|
}}
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
items={this.props.options}
|
items={this.props.options}
|
||||||
getItemValue={(item) => item[0]}
|
getItemValue={(item) => item[0]}
|
||||||
onSelect={v => {
|
onSelect={v => this.props.onChange(v)}
|
||||||
console.log("@@ onSelect", v)
|
onChange={(e, v) => this.props.onChange(v)}
|
||||||
this.props.onChange(v)
|
shouldItemRender={(item, value) => {
|
||||||
}}
|
return item[0].toLowerCase().indexOf(value.toLowerCase()) > -1
|
||||||
onChange={(e, v) => {
|
|
||||||
console.log("@@ onChange", v)
|
|
||||||
this.props.onChange(v)
|
|
||||||
}}
|
}}
|
||||||
renderItem={(item, isHighlighted) => (
|
renderItem={(item, isHighlighted) => (
|
||||||
<div
|
<div
|
||||||
|
@ -114,6 +85,7 @@ class AutocompleteInput extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ class LayerListContainer extends React.Component {
|
||||||
data-wd-key={[groupPrefix, idx].join('-')}
|
data-wd-key={[groupPrefix, idx].join('-')}
|
||||||
key={[groupPrefix, idx].join('-')}
|
key={[groupPrefix, idx].join('-')}
|
||||||
title={groupPrefix}
|
title={groupPrefix}
|
||||||
isActive={!this.isCollapsed(groupPrefix, idx)}
|
isActive={!this.isCollapsed(groupPrefix, idx) || idx === this.props.selectedLayerIndex}
|
||||||
onActiveToggle={this.toggleLayerGroup.bind(this, groupPrefix, idx)}
|
onActiveToggle={this.toggleLayerGroup.bind(this, groupPrefix, idx)}
|
||||||
/>
|
/>
|
||||||
listItems.push(grp)
|
listItems.push(grp)
|
||||||
|
@ -173,9 +173,10 @@ class LayerListContainer extends React.Component {
|
||||||
|
|
||||||
layers.forEach((layer, idxInGroup) => {
|
layers.forEach((layer, idxInGroup) => {
|
||||||
const groupIdx = findClosestCommonPrefix(this.props.layers, idx)
|
const groupIdx = findClosestCommonPrefix(this.props.layers, idx)
|
||||||
|
|
||||||
const listItem = <LayerListItem
|
const listItem = <LayerListItem
|
||||||
className={classnames({
|
className={classnames({
|
||||||
'maputnik-layer-list-item-collapsed': layers.length > 1 && this.isCollapsed(groupPrefix, groupIdx),
|
'maputnik-layer-list-item-collapsed': layers.length > 1 && this.isCollapsed(groupPrefix, groupIdx) && idx !== this.props.selectedLayerIndex,
|
||||||
'maputnik-layer-list-item-group-last': idxInGroup == layers.length - 1 && layers.length > 1
|
'maputnik-layer-list-item-group-last': idxInGroup == layers.length - 1 && layers.length > 1
|
||||||
})}
|
})}
|
||||||
index={idx}
|
index={idx}
|
||||||
|
|
|
@ -29,6 +29,7 @@ function groupFeaturesBySourceLayer(features) {
|
||||||
|
|
||||||
class FeatureLayerPopup extends React.Component {
|
class FeatureLayerPopup extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
onLayerSelect: PropTypes.func.isRequired,
|
||||||
features: PropTypes.array
|
features: PropTypes.array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +41,9 @@ class FeatureLayerPopup extends React.Component {
|
||||||
return <label
|
return <label
|
||||||
key={idx}
|
key={idx}
|
||||||
className="maputnik-popup-layer"
|
className="maputnik-popup-layer"
|
||||||
|
onClick={() => {
|
||||||
|
this.props.onLayerSelect(feature.layer.id)
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<LayerIcon type={feature.layer.type} style={{
|
<LayerIcon type={feature.layer.type} style={{
|
||||||
width: 14,
|
width: 14,
|
||||||
|
|
|
@ -15,12 +15,6 @@ import 'mapbox-gl/dist/mapbox-gl.css'
|
||||||
import '../../mapboxgl.css'
|
import '../../mapboxgl.css'
|
||||||
import '../../libs/mapbox-rtl'
|
import '../../libs/mapbox-rtl'
|
||||||
|
|
||||||
function renderLayerPopup(features) {
|
|
||||||
var mountNode = document.createElement('div');
|
|
||||||
ReactDOM.render(<FeatureLayerPopup features={features} />, mountNode)
|
|
||||||
return mountNode.innerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderPropertyPopup(features) {
|
function renderPropertyPopup(features) {
|
||||||
var mountNode = document.createElement('div');
|
var mountNode = document.createElement('div');
|
||||||
ReactDOM.render(<FeaturePropertyPopup features={features} />, mountNode)
|
ReactDOM.render(<FeaturePropertyPopup features={features} />, mountNode)
|
||||||
|
@ -60,6 +54,7 @@ function buildInspectStyle(originalMapStyle, coloredLayers, highlightedLayer) {
|
||||||
export default class MapboxGlMap extends React.Component {
|
export default class MapboxGlMap extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onDataChange: PropTypes.func,
|
onDataChange: PropTypes.func,
|
||||||
|
onLayerSelect: PropTypes.func.isRequired,
|
||||||
mapStyle: PropTypes.object.isRequired,
|
mapStyle: PropTypes.object.isRequired,
|
||||||
inspectModeEnabled: PropTypes.bool.isRequired,
|
inspectModeEnabled: PropTypes.bool.isRequired,
|
||||||
highlightedLayer: PropTypes.object,
|
highlightedLayer: PropTypes.object,
|
||||||
|
@ -68,6 +63,7 @@ export default class MapboxGlMap extends React.Component {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
onMapLoaded: () => {},
|
onMapLoaded: () => {},
|
||||||
onDataChange: () => {},
|
onDataChange: () => {},
|
||||||
|
onLayerSelect: () => {},
|
||||||
mapboxAccessToken: tokens.mapbox,
|
mapboxAccessToken: tokens.mapbox,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +129,9 @@ export default class MapboxGlMap extends React.Component {
|
||||||
if(this.props.inspectModeEnabled) {
|
if(this.props.inspectModeEnabled) {
|
||||||
return renderPropertyPopup(features)
|
return renderPropertyPopup(features)
|
||||||
} else {
|
} else {
|
||||||
return renderLayerPopup(features)
|
var mountNode = document.createElement('div');
|
||||||
|
ReactDOM.render(<FeatureLayerPopup features={features} onLayerSelect={this.props.onLayerSelect} />, mountNode)
|
||||||
|
return mountNode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -57,11 +57,22 @@ class AddModal extends React.Component {
|
||||||
|
|
||||||
componentWillUpdate(nextProps, nextState) {
|
componentWillUpdate(nextProps, nextState) {
|
||||||
// Check if source is valid for new type
|
// Check if source is valid for new type
|
||||||
const availableSources = this.getSources(nextState.type);
|
const oldType = this.state.type;
|
||||||
|
const newType = nextState.type;
|
||||||
|
|
||||||
|
const availableSourcesOld = this.getSources(oldType);
|
||||||
|
const availableSourcesNew = this.getSources(newType);
|
||||||
|
|
||||||
if(
|
if(
|
||||||
this.state.source !== ""
|
// Type has changed
|
||||||
&& availableSources.indexOf(this.state.source) < 0
|
oldType !== newType
|
||||||
|
&& this.state.source !== ""
|
||||||
|
// Was a valid source previously
|
||||||
|
&& availableSourcesOld.indexOf(this.state.source) > -1
|
||||||
|
// And is not a valid source now
|
||||||
|
&& availableSourcesNew.indexOf(nextState.source) < 0
|
||||||
) {
|
) {
|
||||||
|
// Clear the source
|
||||||
this.setState({
|
this.setState({
|
||||||
source: ""
|
source: ""
|
||||||
});
|
});
|
||||||
|
@ -90,7 +101,7 @@ class AddModal extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let [key, val] of Object.entries(this.props.sources)) {
|
for(let [key, val] of Object.entries(this.props.sources)) {
|
||||||
if(types[val.type].indexOf(type) > -1) {
|
if(types[val.type] && types[val.type].indexOf(type) > -1) {
|
||||||
sources.push(key);
|
sources.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
.maputnik-popup-layer {
|
.maputnik-popup-layer {
|
||||||
display: block;
|
display: block;
|
||||||
color: $color-lowgray;
|
color: $color-lowgray;
|
||||||
|
cursor: pointer;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
padding: $margin-2;
|
padding: $margin-2;
|
||||||
|
|
Loading…
Reference in a new issue