@deck.gl-community/react 9.0.1
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/README.md +3 -0
- package/dist/components/icon.d.ts +3 -0
- package/dist/components/icon.js +6 -0
- package/dist/components/long-press-button.d.ts +13 -0
- package/dist/components/long-press-button.js +31 -0
- package/dist/components/modal.d.ts +8 -0
- package/dist/components/modal.js +70 -0
- package/dist/components/positioned-view-control.d.ts +9 -0
- package/dist/components/positioned-view-control.js +5 -0
- package/dist/components/view-control.d.ts +38 -0
- package/dist/components/view-control.js +128 -0
- package/dist/index.cjs +521 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +13 -0
- package/dist/overlays/html-cluster-overlay.d.ts +13 -0
- package/dist/overlays/html-cluster-overlay.js +53 -0
- package/dist/overlays/html-overlay-item.d.ts +12 -0
- package/dist/overlays/html-overlay-item.js +13 -0
- package/dist/overlays/html-overlay.d.ts +19 -0
- package/dist/overlays/html-overlay.js +65 -0
- package/dist/overlays/html-tooltip-overlay.d.ts +16 -0
- package/dist/overlays/html-tooltip-overlay.js +53 -0
- package/package.json +50 -0
- package/src/components/icon.tsx +7 -0
- package/src/components/long-press-button.tsx +43 -0
- package/src/components/modal.tsx +92 -0
- package/src/components/positioned-view-control.tsx +16 -0
- package/src/components/view-control.tsx +163 -0
- package/src/index.ts +19 -0
- package/src/overlays/html-cluster-overlay.ts +80 -0
- package/src/overlays/html-overlay-item.tsx +30 -0
- package/src/overlays/html-overlay.tsx +91 -0
- package/src/overlays/html-tooltip-overlay.tsx +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
export declare class LongPressButton extends PureComponent {
|
|
4
|
+
static propTypes: {
|
|
5
|
+
onClick: PropTypes.Validator<(...args: any[]) => any>;
|
|
6
|
+
children: PropTypes.Validator<any>;
|
|
7
|
+
};
|
|
8
|
+
buttonPressTimer: ReturnType<typeof setTimeout> | null;
|
|
9
|
+
_repeat: () => void;
|
|
10
|
+
_handleButtonPress: () => void;
|
|
11
|
+
_handleButtonRelease: () => void;
|
|
12
|
+
render(): React.JSX.Element;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
export class LongPressButton extends PureComponent {
|
|
4
|
+
static propTypes = {
|
|
5
|
+
onClick: PropTypes.func.isRequired,
|
|
6
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
7
|
+
children: PropTypes.any.isRequired
|
|
8
|
+
};
|
|
9
|
+
buttonPressTimer = null;
|
|
10
|
+
_repeat = () => {
|
|
11
|
+
if (this.buttonPressTimer) {
|
|
12
|
+
this.props.onClick();
|
|
13
|
+
this.buttonPressTimer = setTimeout(this._repeat, 100);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
_handleButtonPress = () => {
|
|
17
|
+
this.buttonPressTimer = setTimeout(this._repeat, 100);
|
|
18
|
+
};
|
|
19
|
+
_handleButtonRelease = () => {
|
|
20
|
+
if (this.buttonPressTimer) {
|
|
21
|
+
clearTimeout(this.buttonPressTimer);
|
|
22
|
+
}
|
|
23
|
+
this.buttonPressTimer = null;
|
|
24
|
+
};
|
|
25
|
+
render() {
|
|
26
|
+
return (React.createElement("div", { onMouseDown: (event) => {
|
|
27
|
+
this._handleButtonPress();
|
|
28
|
+
document.addEventListener('mouseup', this._handleButtonRelease, { once: true });
|
|
29
|
+
} }, this.props.children));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const Button: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
3
|
+
export type ModalProps = {
|
|
4
|
+
title: any;
|
|
5
|
+
content: any;
|
|
6
|
+
onClose: () => unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare function EditorModal(props: ModalProps): React.JSX.Element;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Modal, { ModalProvider } from 'styled-react-modal';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
export const Button = styled.button `
|
|
6
|
+
display: inline-block;
|
|
7
|
+
color: #fff;
|
|
8
|
+
background-color: rgb(90, 98, 94);
|
|
9
|
+
font-size: 1em;
|
|
10
|
+
margin: 0.25em;
|
|
11
|
+
padding: 0.375em 0.75em;
|
|
12
|
+
border: 1px solid transparent;
|
|
13
|
+
border-radius: 0.25em;
|
|
14
|
+
display: block;
|
|
15
|
+
`;
|
|
16
|
+
const StyledModal = Modal.styled `
|
|
17
|
+
position: relative;
|
|
18
|
+
display: block;
|
|
19
|
+
width: 50rem;
|
|
20
|
+
height: auto;
|
|
21
|
+
max-width: 500px;
|
|
22
|
+
margin: 1.75rem auto;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
25
|
+
font-size: 1rem;
|
|
26
|
+
font-weight: 400;
|
|
27
|
+
color: rgb(21, 25, 29);
|
|
28
|
+
line-height: 1.5;
|
|
29
|
+
text-align: left;
|
|
30
|
+
`;
|
|
31
|
+
const Content = styled.div `
|
|
32
|
+
position: relative;
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
width: 100%;
|
|
36
|
+
pointer-events: auto;
|
|
37
|
+
background-color: #fff;
|
|
38
|
+
background-clip: padding-box;
|
|
39
|
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
40
|
+
border-radius: 0.3rem;
|
|
41
|
+
outline: 0;
|
|
42
|
+
`;
|
|
43
|
+
const HeaderRow = styled.div `
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: flex-start;
|
|
46
|
+
justify-content: space-between;
|
|
47
|
+
padding: 0.75rem 0.75rem;
|
|
48
|
+
border-bottom: 1px solid rgb(222, 226, 230);
|
|
49
|
+
`;
|
|
50
|
+
const Header = styled.h5 `
|
|
51
|
+
font-size: 1.25rem;
|
|
52
|
+
font-weight: 500;
|
|
53
|
+
margin: 0;
|
|
54
|
+
`;
|
|
55
|
+
export function EditorModal(props) {
|
|
56
|
+
const [isOpen, setIsOpen] = React.useState(true);
|
|
57
|
+
function toggleModal() {
|
|
58
|
+
if (isOpen) {
|
|
59
|
+
props.onClose();
|
|
60
|
+
}
|
|
61
|
+
setIsOpen(!isOpen);
|
|
62
|
+
}
|
|
63
|
+
return (React.createElement(React.Fragment, null,
|
|
64
|
+
React.createElement(ModalProvider, null,
|
|
65
|
+
React.createElement(StyledModal, { isOpen: isOpen, onBackgroundClick: toggleModal, onEscapeKeydown: toggleModal },
|
|
66
|
+
React.createElement(Content, null,
|
|
67
|
+
React.createElement(HeaderRow, null,
|
|
68
|
+
React.createElement(Header, null, props.title)),
|
|
69
|
+
props.content)))));
|
|
70
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ViewControl } from './view-control';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// A wrapper for positioning the ViewControl component
|
|
4
|
+
export const PositionedViewControl = ({ fitBounds, panBy, zoomBy, zoomLevel, maxZoom, minZoom }) => (React.createElement("div", { style: { position: 'relative', top: '20px', left: '20px' } },
|
|
5
|
+
React.createElement(ViewControl, { fitBounds: fitBounds, panBy: panBy, zoomBy: zoomBy, zoomLevel: zoomLevel, maxZoom: maxZoom, minZoom: minZoom })));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
export declare const ViewControlWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const NavigationButtonContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const NavigationButton: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const ZoomControlWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const VerticalSlider: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const ZoomControlButton: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare class ViewControl extends PureComponent {
|
|
10
|
+
static displayName: string;
|
|
11
|
+
static propTypes: {
|
|
12
|
+
fitBounds: PropTypes.Requireable<(...args: any[]) => any>;
|
|
13
|
+
panBy: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
+
zoomBy: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
+
zoomLevel: PropTypes.Requireable<number>;
|
|
16
|
+
minZoom: PropTypes.Requireable<number>;
|
|
17
|
+
maxZoom: PropTypes.Requireable<number>;
|
|
18
|
+
deltaPan: PropTypes.Requireable<number>;
|
|
19
|
+
deltaZoom: PropTypes.Requireable<number>;
|
|
20
|
+
};
|
|
21
|
+
static defaultProps: {
|
|
22
|
+
fitBounds: () => void;
|
|
23
|
+
panBy: () => void;
|
|
24
|
+
zoomBy: () => void;
|
|
25
|
+
deltaPan: number;
|
|
26
|
+
deltaZoom: number;
|
|
27
|
+
minZoom: number;
|
|
28
|
+
maxZoom: number;
|
|
29
|
+
};
|
|
30
|
+
panUp: () => any;
|
|
31
|
+
panDown: () => any;
|
|
32
|
+
panLeft: () => any;
|
|
33
|
+
panRight: () => any;
|
|
34
|
+
zoomIn: () => any;
|
|
35
|
+
zoomOut: () => any;
|
|
36
|
+
onChangeZoomLevel: (evt: any) => void;
|
|
37
|
+
render(): React.JSX.Element;
|
|
38
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// @ts-nocheck TODO
|
|
2
|
+
import React, { PureComponent } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { LongPressButton } from './long-press-button';
|
|
6
|
+
export const ViewControlWrapper = styled.div `
|
|
7
|
+
align-items: center;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
position: absolute;
|
|
11
|
+
z-index: 99;
|
|
12
|
+
user-select: none;
|
|
13
|
+
`;
|
|
14
|
+
export const NavigationButtonContainer = styled.div `
|
|
15
|
+
background: #f7f7f7;
|
|
16
|
+
border-radius: 23px;
|
|
17
|
+
border: 0.5px solid #eaeaea;
|
|
18
|
+
box-shadow: inset 11px 11px 5px -7px rgba(230, 230, 230, 0.49);
|
|
19
|
+
height: 46px;
|
|
20
|
+
width: 46px;
|
|
21
|
+
`;
|
|
22
|
+
export const NavigationButton = styled.div `
|
|
23
|
+
color: #848484;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
left: ${(props) => props.left};
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: ${(props) => props.top};
|
|
28
|
+
transform: rotate(${(props) => props.rotate || 0}deg);
|
|
29
|
+
|
|
30
|
+
&:hover,
|
|
31
|
+
&:active {
|
|
32
|
+
color: #00ade6;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
export const ZoomControlWrapper = styled.div `
|
|
36
|
+
align-items: center;
|
|
37
|
+
background: #f7f7f7;
|
|
38
|
+
border: 0.5px solid #eaeaea;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
margin-top: 6px;
|
|
42
|
+
padding: 2px 0;
|
|
43
|
+
width: 18px;
|
|
44
|
+
`;
|
|
45
|
+
export const VerticalSlider = styled.div `
|
|
46
|
+
display: inline-block;
|
|
47
|
+
height: 100px;
|
|
48
|
+
padding: 0;
|
|
49
|
+
width: 10px;
|
|
50
|
+
|
|
51
|
+
> input[type='range'][orient='vertical'] {
|
|
52
|
+
-webkit-appearance: slider-vertical;
|
|
53
|
+
height: 100px;
|
|
54
|
+
padding: 0;
|
|
55
|
+
margin: 0;
|
|
56
|
+
width: 10px;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
export const ZoomControlButton = styled.div `
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
font-size: 14px;
|
|
62
|
+
font-weight: 500;
|
|
63
|
+
margin: -4px;
|
|
64
|
+
|
|
65
|
+
&:hover,
|
|
66
|
+
&:active {
|
|
67
|
+
color: #00ade6;
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
export class ViewControl extends PureComponent {
|
|
71
|
+
static displayName = 'ViewControl';
|
|
72
|
+
static propTypes = {
|
|
73
|
+
// functions
|
|
74
|
+
fitBounds: PropTypes.func,
|
|
75
|
+
panBy: PropTypes.func,
|
|
76
|
+
zoomBy: PropTypes.func,
|
|
77
|
+
// current zoom level
|
|
78
|
+
zoomLevel: PropTypes.number,
|
|
79
|
+
// configuration
|
|
80
|
+
minZoom: PropTypes.number,
|
|
81
|
+
maxZoom: PropTypes.number,
|
|
82
|
+
deltaPan: PropTypes.number,
|
|
83
|
+
deltaZoom: PropTypes.number
|
|
84
|
+
};
|
|
85
|
+
static defaultProps = {
|
|
86
|
+
fitBounds: () => { },
|
|
87
|
+
panBy: () => { },
|
|
88
|
+
zoomBy: () => { },
|
|
89
|
+
deltaPan: 10,
|
|
90
|
+
deltaZoom: 0.1,
|
|
91
|
+
minZoom: 0.1,
|
|
92
|
+
maxZoom: 1
|
|
93
|
+
};
|
|
94
|
+
// pan actions
|
|
95
|
+
panUp = () => this.props.panBy(0, this.props.deltaPan);
|
|
96
|
+
panDown = () => this.props.panBy(0, -1 * this.props.deltaPan);
|
|
97
|
+
panLeft = () => this.props.panBy(this.props.deltaPan, 0);
|
|
98
|
+
panRight = () => this.props.panBy(-1 * this.props.deltaPan, 0);
|
|
99
|
+
// zoom actions
|
|
100
|
+
zoomIn = () => this.props.zoomBy(this.props.deltaZoom);
|
|
101
|
+
zoomOut = () => this.props.zoomBy(-1 * this.props.deltaZoom);
|
|
102
|
+
onChangeZoomLevel = (evt) => {
|
|
103
|
+
const delta = evt.target.value - this.props.zoomLevel;
|
|
104
|
+
this.props.zoomBy(delta);
|
|
105
|
+
};
|
|
106
|
+
render() {
|
|
107
|
+
const buttons = [
|
|
108
|
+
{ top: -2, left: 14, rotate: 0, onClick: this.panUp, content: '▲', key: 'up' },
|
|
109
|
+
{ top: 12, left: 0, rotate: -90, onClick: this.panLeft, content: '◀', key: 'left' },
|
|
110
|
+
{ top: 12, left: 28, rotate: 90, onClick: this.panRight, content: '▶', key: 'right' },
|
|
111
|
+
{ top: 25, left: 14, rotate: 180, onClick: this.panDown, content: '▼', key: 'down' }
|
|
112
|
+
];
|
|
113
|
+
return (React.createElement(ViewControlWrapper, null,
|
|
114
|
+
React.createElement(NavigationButtonContainer, null,
|
|
115
|
+
buttons.map((b) => (React.createElement(NavigationButton, { key: b.key, top: `${b.top}px`, left: `${b.left}px`, rotate: b.rotate },
|
|
116
|
+
React.createElement(LongPressButton, { onClick: b.onClick }, b.content)))),
|
|
117
|
+
React.createElement(NavigationButton, { top: '12px', left: '16px', onClick: this.props.fitBounds }, '¤')),
|
|
118
|
+
React.createElement(ZoomControlWrapper, null,
|
|
119
|
+
React.createElement(ZoomControlButton, null,
|
|
120
|
+
React.createElement(LongPressButton, { onClick: this.zoomIn }, '+')),
|
|
121
|
+
React.createElement(VerticalSlider, null,
|
|
122
|
+
React.createElement("input", { type: "range", value: this.props.zoomLevel, min: this.props.minZoom, max: this.props.maxZoom, step: this.props.deltaZoom, onChange: this.onChangeZoomLevel,
|
|
123
|
+
/* @ts-expect-error */
|
|
124
|
+
orient: "vertical" })),
|
|
125
|
+
React.createElement(ZoomControlButton, null,
|
|
126
|
+
React.createElement(LongPressButton, { onClick: this.zoomOut }, '-')))));
|
|
127
|
+
}
|
|
128
|
+
}
|