@longline/aqua-ui 1.0.339 → 1.0.340
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/containers/Anchor/Anchor.d.ts +5 -0
- package/containers/Anchor/Anchor.js +20 -8
- package/containers/Dock/Dock.d.ts +5 -0
- package/containers/Dock/Dock.js +1 -1
- package/containers/Dock/Dockable.d.ts +5 -0
- package/containers/Dock/Dockable.js +20 -12
- package/containers/DragBar/DragBar.d.ts +5 -0
- package/containers/DragBar/DragBar.js +16 -5
- package/containers/Form/Field.d.ts +0 -3
- package/containers/Form/Field.js +3 -6
- package/containers/Form/Form.js +5 -36
- package/containers/Form/Validation.d.ts +1 -1
- package/containers/Form/Validation.js +6 -6
- package/containers/Form/context/FormContext.d.ts +1 -2
- package/containers/Form/context/useForm.d.ts +1 -1
- package/containers/Form/elements/BoxWrapper.js +2 -0
- package/containers/GlassPane/GlassPane.d.ts +7 -2
- package/containers/GlassPane/GlassPane.js +3 -3
- package/containers/InfoBox/InfoBox.d.ts +5 -0
- package/containers/InfoBox/InfoBox.js +1 -1
- package/containers/List/List.d.ts +5 -0
- package/containers/List/List.js +1 -1
- package/containers/List/ListCell.d.ts +5 -0
- package/containers/List/ListCell.js +1 -1
- package/containers/List/ListRow.d.ts +7 -2
- package/containers/List/ListRow.js +1 -1
- package/containers/Message/Error.d.ts +2 -0
- package/containers/Message/Error.js +1 -1
- package/containers/Message/Message.d.ts +5 -0
- package/containers/Message/Message.js +1 -1
- package/containers/Message/NoData.d.ts +2 -0
- package/containers/Message/NoData.js +1 -1
- package/containers/Message/NoFilteredData.d.ts +2 -0
- package/containers/Message/NoFilteredData.js +1 -1
- package/containers/Openable/Openable.d.ts +5 -0
- package/containers/Openable/Openable.js +8 -8
- package/containers/PublicRoute/PublicRoute.d.ts +9 -1
- package/containers/PublicRoute/PublicRoute.js +3 -7
- package/containers/Tabs/Pane.d.ts +5 -0
- package/containers/Tabs/Pane.js +3 -3
- package/containers/Tabs/Tabs.d.ts +5 -0
- package/containers/Tabs/Tabs.js +3 -3
- package/controls/Chip/Chip.d.ts +15 -3
- package/controls/Chip/Chip.js +7 -6
- package/controls/CircularProgress/CircularProgress.d.ts +11 -0
- package/controls/CircularProgress/CircularProgress.js +19 -11
- package/controls/Dropzone/Dropzone.d.ts +11 -1
- package/controls/Dropzone/Dropzone.js +18 -7
- package/controls/Fab/Fab.d.ts +14 -6
- package/controls/Fab/Fab.js +7 -20
- package/controls/Ghost/Ghost.js +3 -3
- package/controls/Gradient/Gradient.d.ts +5 -0
- package/controls/Gradient/Gradient.js +7 -4
- package/controls/Histogram/Histogram.d.ts +8 -2
- package/controls/Histogram/Histogram.js +9 -9
- package/controls/Histogram/HistogramBar.d.ts +2 -2
- package/controls/Icon/Icon.d.ts +10 -4
- package/controls/Icon/Icon.js +23 -6
- package/controls/Key/Key.d.ts +5 -0
- package/controls/Key/Key.js +2 -5
- package/controls/LinearChart/LinearChart.d.ts +9 -0
- package/controls/LinearChart/LinearChart.js +11 -6
- package/controls/ListButton/ListButton.d.ts +46 -3
- package/controls/ListButton/ListButton.js +70 -9
- package/controls/ListView/ColumnsManager/ColumnDraggable.js +11 -5
- package/controls/ListView/ColumnsManager/SourceColumns.js +1 -1
- package/controls/ListView/IListViewProps.d.ts +9 -2
- package/controls/ListView/ListView.js +13 -12
- package/controls/ListView/defaults.d.ts +3 -0
- package/controls/ListView/defaults.js +6 -0
- package/controls/ListView/elements/Body.d.ts +1 -1
- package/controls/ListView/elements/Body.js +23 -12
- package/controls/ListView/elements/Ghost.js +3 -2
- package/controls/ListView/elements/Header.js +3 -2
- package/controls/ListView/elements/HeaderCell.js +3 -3
- package/controls/ListView/elements/Table.js +16 -10
- package/controls/Mouse/Mouse.d.ts +6 -4
- package/controls/Mouse/Mouse.js +15 -8
- package/controls/PrimaryButton/PrimaryButton.d.ts +9 -3
- package/controls/PrimaryButton/PrimaryButton.js +5 -5
- package/controls/Progress/Progress.d.ts +9 -0
- package/controls/Progress/Progress.js +12 -8
- package/controls/SecondaryButton/SecondaryButton.d.ts +8 -3
- package/controls/SecondaryButton/SecondaryButton.js +1 -1
- package/controls/SpeechRecognizer/EditorRegistry.js +1 -2
- package/controls/SpeechRecognizer/SpeechRecognizer.d.ts +9 -1
- package/controls/SpeechRecognizer/SpeechRecognizer.js +16 -9
- package/controls/TabBar/TabBar.d.ts +5 -0
- package/controls/TabBar/TabBar.js +14 -6
- package/controls/TabBar/Underliner.js +1 -1
- package/controls/TertiaryButton/TertiaryButton.d.ts +9 -3
- package/controls/TertiaryButton/TertiaryButton.js +5 -3
- package/controls/ToggleButton/ToggleButton.d.ts +8 -2
- package/controls/ToggleButton/ToggleButton.js +1 -1
- package/controls/View/View.d.ts +5 -0
- package/controls/View/View.js +1 -1
- package/formatters/CountryFormatter/CountryFormatter.d.ts +3 -2
- package/formatters/CountryFormatter/CountryUtil.d.ts +3 -3
- package/formatters/DateTimeFormatter/DateTimeFormatter.d.ts +11 -10
- package/formatters/DateTimeFormatter/elements/Custom.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/DistanceDate.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/LongDate.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/LongDateTime.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/LongTime.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/Month.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/ShortDate.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/ShortDateTime.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/ShortTime.d.ts +1 -1
- package/formatters/DivisionFormatter/DivisionFormatter.d.ts +2 -2
- package/formatters/DivisionFormatter/DivisionFormatter.js +1 -1
- package/formatters/DivisionFormatter/DivisionUtil.d.ts +1 -1
- package/formatters/DivisionFormatter/DivisionUtil.js +5 -3
- package/formatters/FilesizeFormatter/FilesizeFormatter.d.ts +3 -3
- package/formatters/GIS/CoordinateFormatter.d.ts +2 -2
- package/formatters/GIS/LatitudeFormatter.d.ts +2 -2
- package/formatters/GIS/LongitudeFormatter.d.ts +2 -2
- package/formatters/HumanFormatter/HumanFormatter.d.ts +3 -3
- package/formatters/NumberFormatter/NumberFormatter.d.ts +3 -3
- package/formatters/PhoneFormatter/PhoneFormatter.d.ts +3 -3
- package/formatters/StringFormatter/StringFormatter.d.ts +3 -3
- package/formatters/StringFormatter/StringFormatter.js +1 -4
- package/helper/DMS.d.ts +1 -1
- package/helper/DMS.js +2 -2
- package/hooks/useOutsideClose/useOutsideClose.js +20 -11
- package/hooks/useSpeechAIRecorder/useSpeechAIRecorder.js +10 -7
- package/index.js +1 -0
- package/inputs/DateInput/Body.d.ts +2 -2
- package/inputs/DateInput/Body.js +11 -7
- package/inputs/DateInput/Calendar.d.ts +1 -1
- package/inputs/DateInput/Calendar.js +3 -5
- package/inputs/DateInput/DateInput.d.ts +11 -3
- package/inputs/DateInput/DateInput.js +11 -3
- package/inputs/DateInput/Day.d.ts +1 -1
- package/inputs/DateInput/InfiniteList.js +6 -3
- package/inputs/DateInput/Navbar.js +3 -2
- package/inputs/DateInput/NumericInput.js +3 -0
- package/inputs/DateInput/Selector.d.ts +1 -1
- package/inputs/DateInput/Selector.js +9 -6
- package/inputs/Dropdown/Body.d.ts +2 -2
- package/inputs/Dropdown/Column.d.ts +1 -1
- package/inputs/Dropdown/Dropdown.d.ts +5 -0
- package/inputs/Dropdown/Dropdown.js +36 -63
- package/inputs/Dropdown/Pill.js +1 -1
- package/inputs/Dropdown/Selection.js +1 -1
- package/inputs/Editor/Editor.d.ts +5 -0
- package/inputs/Editor/Editor.js +16 -6
- package/inputs/Editor/buttons/SpeechAIButton.js +2 -0
- package/inputs/Editor/buttons/TextAIButton.d.ts +0 -13
- package/inputs/Editor/buttons/TextAIButton.js +30 -14
- package/inputs/Editor/buttons/TextAIMenu.js +1 -1
- package/inputs/Editor/menu/MenuBar.d.ts +1 -1
- package/inputs/Editor/menu/MenuBar.js +1 -1
- package/inputs/Editor/menu/MenuButton.js +1 -1
- package/inputs/Input/Clear.js +1 -1
- package/inputs/Input/Input.d.ts +5 -0
- package/inputs/Input/Input.js +8 -6
- package/inputs/Input/InputWrapper.d.ts +2 -0
- package/inputs/Input/InputWrapper.js +1 -1
- package/inputs/Input/Reveal.js +1 -1
- package/inputs/MonthRange/Body.d.ts +1 -1
- package/inputs/MonthRange/Calendar.d.ts +2 -2
- package/inputs/MonthRange/Calendar.js +6 -9
- package/inputs/MonthRange/MonthRange.d.ts +7 -1
- package/inputs/MonthRange/MonthRange.js +14 -6
- package/inputs/MonthRange/Selector.d.ts +1 -1
- package/inputs/MonthRange/Selector.js +12 -11
- package/inputs/PhoneInput/PhoneInput.d.ts +5 -0
- package/inputs/PhoneInput/PhoneInput.js +2 -2
- package/inputs/Selector/Selector.d.ts +5 -0
- package/inputs/Selector/Selector.js +4 -1
- package/inputs/Slider/Slider.d.ts +75 -22
- package/inputs/Slider/Slider.js +104 -22
- package/inputs/Textarea/Textarea.d.ts +5 -5
- package/inputs/Textarea/Textarea.js +3 -2
- package/map/Map/Map.d.ts +2 -2
- package/map/Map/Map.js +20 -14
- package/map/PositionsManager/PositionBox.js +7 -3
- package/map/PositionsManager/PositionsManager.js +33 -13
- package/map/controls/CompassButton/CompassButton.js +1 -1
- package/map/controls/FullscreenButton/FullscreenButton.js +1 -1
- package/map/controls/Geocoder/Geocoder.js +28 -14
- package/map/controls/Geocoder/GeocoderApi.js +2 -0
- package/map/controls/Geocoder/GeocoderSelector.js +1 -1
- package/map/controls/Graticule/Graticule.js +1 -5
- package/map/controls/MapLoader/MapLoader.js +1 -1
- package/map/controls/ScaleControl/ScaleControl.js +1 -1
- package/map/controls/ZoomInButton/ZoomInButton.js +1 -1
- package/map/controls/ZoomOutButton/ZoomOutButton.d.ts +1 -1
- package/map/controls/ZoomOutButton/ZoomOutButton.js +2 -2
- package/map/controls/base/MapButton/MapButton.d.ts +8 -2
- package/map/controls/base/MapButton/MapButton.js +11 -2
- package/map/controls/base/MapControl/MapControl.d.ts +5 -0
- package/map/controls/base/MapControl/MapControl.js +10 -7
- package/map/layers/ClusterLayer/ClusterLayer.d.ts +1 -1
- package/map/layers/ClusterLayer/ClusterLayer.js +7 -3
- package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer.js +8 -4
- package/map/layers/IdwBlendLayer/IdwBlendLayer.js +9 -4
- package/map/layers/IdwLayer/IdwLayer.d.ts +2 -1
- package/map/layers/IdwLayer/IdwLayer.js +271 -215
- package/map/layers/InterpolationLayer/ContoursFragmentShader.d.ts +1 -1
- package/map/layers/InterpolationLayer/ContoursFragmentShader.js +1 -1
- package/map/layers/InterpolationLayer/InterpolationLayer.d.ts +4 -3
- package/map/layers/InterpolationLayer/InterpolationLayer.js +362 -275
- package/map/layers/ParticlesLayer/ParticlesLayer.d.ts +8 -7
- package/map/layers/ParticlesLayer/ParticlesLayer.js +528 -404
- package/map/markers/ClusterMarker/ClusterMarker.d.ts +6 -1
- package/map/markers/ClusterMarker/ClusterMarker.js +15 -6
- package/map/markers/RiskMarker/RiskMarker.d.ts +5 -1
- package/map/markers/RiskMarker/RiskMarker.js +4 -4
- package/modules/CountryDropdown/CountryDropdown.js +10 -1
- package/modules/Filter/Filter.d.ts +5 -0
- package/modules/Filter/Filter.js +10 -6
- package/modules/Globe/Globe.d.ts +5 -0
- package/modules/Globe/Globe.js +4 -4
- package/modules/MainMenu/Item.d.ts +9 -2
- package/modules/MainMenu/Item.js +8 -5
- package/modules/MainMenu/MainMenu.d.ts +5 -0
- package/modules/MainMenu/MainMenu.js +1 -1
- package/modules/ParticleGlobe/GL.d.ts +1 -1
- package/modules/ParticleGlobe/ParticleGlobe.d.ts +5 -0
- package/modules/ParticleGlobe/ParticleGlobe.js +69 -40
- package/modules/Public/Public.d.ts +5 -0
- package/modules/Public/Public.js +3 -3
- package/package.json +1 -1
- package/services/Auth/Auth.js +13 -7
- package/services/Auth/AuthContext.js +9 -1
- package/services/Dialog/Dialog.d.ts +7 -2
- package/services/Dialog/Dialog.js +7 -6
- package/services/Dialog/DialogWindow.d.ts +3 -1
- package/services/Dialog/DialogWindow.js +1 -1
- package/services/Dialog/XhrDialog.d.ts +1 -1
- package/services/Toast/Toast.js +5 -3
- package/services/Toast/ToastContainer.js +3 -1
- package/services/Toast/ToastContext.d.ts +1 -1
- package/services/Toast/ToastProvider.js +2 -0
- package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer copy.d.ts +0 -35
- package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer copy.js +0 -176
- package/modules/Root/Content.d.ts +0 -16
- package/modules/Root/Content.js +0 -25
- package/modules/Root/Overlay.d.ts +0 -23
- package/modules/Root/Overlay.js +0 -33
- package/modules/Root/Root.d.ts +0 -10
- package/modules/Root/Root.js +0 -46
- package/modules/Root/Shader.d.ts +0 -15
- package/modules/Root/Shader.js +0 -24
- package/modules/Root/Sidebar.d.ts +0 -13
- package/modules/Root/Sidebar.js +0 -24
- package/modules/Root/index.d.ts +0 -1
- package/modules/Root/index.js +0 -1
- package/modules/Root/stories/SampleContent.d.ts +0 -7
- package/modules/Root/stories/SampleContent.js +0 -44
|
@@ -34,14 +34,15 @@ var TextareaBase = function (props) {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
var toggleFullscreen = function () {
|
|
37
|
+
var _a;
|
|
37
38
|
if (document.fullscreenElement) {
|
|
38
39
|
document.exitFullscreen();
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
|
-
textareaRef.current.requestFullscreen();
|
|
42
|
+
(_a = textareaRef.current) === null || _a === void 0 ? void 0 : _a.requestFullscreen();
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
return (React.createElement(InputWrapper, { fluid: props.fluid, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, flex: props.flex },
|
|
45
|
+
return (React.createElement(InputWrapper, { fluid: props.fluid, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, flex: props.flex, style: props.style },
|
|
45
46
|
React.createElement("textarea", { "data-testid": props['data-testid'] || "Textarea", className: props.className, ref: textareaRef, name: props.name, value: value == null ? '' : value, placeholder: props.placeholder, disabled: props.disabled, tabIndex: 0, onChange: handleChange }),
|
|
46
47
|
props.fullscreen &&
|
|
47
48
|
React.createElement(FullscreenToggle, { onClick: toggleFullscreen },
|
package/map/Map/Map.d.ts
CHANGED
|
@@ -128,8 +128,8 @@ interface IMapProps extends ITestable {
|
|
|
128
128
|
*/
|
|
129
129
|
onMouseLeave?: (e: MapMouseEvent) => void;
|
|
130
130
|
}
|
|
131
|
-
declare const ViewStateContext: React.Context<ViewState>;
|
|
132
|
-
declare const useViewState: () => ViewState;
|
|
131
|
+
declare const ViewStateContext: React.Context<ViewState | null>;
|
|
132
|
+
declare const useViewState: () => ViewState | null;
|
|
133
133
|
declare const Map: {
|
|
134
134
|
({ longitude, latitude, zoom, pitch, bearing, logoPosition, interactiveLayerIds, noRotate, preserveDrawingBuffer, minZoom, maxZoom, fadeDuration, doubleClickZoom, ...props }: IMapProps): React.JSX.Element;
|
|
135
135
|
displayName: string;
|
package/map/Map/Map.js
CHANGED
|
@@ -74,21 +74,24 @@ var useViewState = function () {
|
|
|
74
74
|
* The map's current ViewState is tracked in local state, and fed into a context provider.
|
|
75
75
|
* The ViewState can be retrieved by child components using `useViewState()`.
|
|
76
76
|
*/
|
|
77
|
+
// Default view-state prop values, referenced both by the MapBase fallbacks and
|
|
78
|
+
// the Map wrapper below.
|
|
79
|
+
var DEFAULT_LONGITUDE = -64.6;
|
|
80
|
+
var DEFAULT_LATITUDE = 44.02;
|
|
81
|
+
var DEFAULT_ZOOM = 11;
|
|
82
|
+
var DEFAULT_PITCH = 0;
|
|
83
|
+
var DEFAULT_BEARING = 0;
|
|
77
84
|
var MapBase = function (props) {
|
|
85
|
+
var _a, _b, _c, _d, _e;
|
|
78
86
|
var theme = useTheme();
|
|
79
|
-
var
|
|
80
|
-
longitude: props.longitude,
|
|
81
|
-
latitude: props.latitude,
|
|
82
|
-
zoom: props.zoom,
|
|
83
|
-
pitch: props.pitch,
|
|
84
|
-
bearing: props.bearing,
|
|
87
|
+
var _f = React.useState({
|
|
88
|
+
longitude: (_a = props.longitude) !== null && _a !== void 0 ? _a : DEFAULT_LONGITUDE,
|
|
89
|
+
latitude: (_b = props.latitude) !== null && _b !== void 0 ? _b : DEFAULT_LATITUDE,
|
|
90
|
+
zoom: (_c = props.zoom) !== null && _c !== void 0 ? _c : DEFAULT_ZOOM,
|
|
91
|
+
pitch: (_d = props.pitch) !== null && _d !== void 0 ? _d : DEFAULT_PITCH,
|
|
92
|
+
bearing: (_e = props.bearing) !== null && _e !== void 0 ? _e : DEFAULT_BEARING,
|
|
85
93
|
padding: props.padding || { top: 0, bottom: 0, left: 0, right: 0 }
|
|
86
|
-
}), viewState =
|
|
87
|
-
// TODO: REMOVE THIS!
|
|
88
|
-
// React.useEffect(() => {
|
|
89
|
-
// // Clears entire Mapbox tile cache for testing of clipping strategy.
|
|
90
|
-
// MapboxGL.clearStorage();
|
|
91
|
-
// }, []);
|
|
94
|
+
}), viewState = _f[0], setViewState = _f[1];
|
|
92
95
|
var loadImage = function (url) {
|
|
93
96
|
return new Promise(function (res, rej) {
|
|
94
97
|
var img = new Image();
|
|
@@ -169,7 +172,7 @@ var MapBase = function (props) {
|
|
|
169
172
|
};
|
|
170
173
|
React.useEffect(function () {
|
|
171
174
|
if (!props.clipped)
|
|
172
|
-
return;
|
|
175
|
+
return undefined;
|
|
173
176
|
var originalFetch = window.fetch;
|
|
174
177
|
window.fetch = function () {
|
|
175
178
|
var args = [];
|
|
@@ -201,6 +204,9 @@ var MapBase = function (props) {
|
|
|
201
204
|
});
|
|
202
205
|
});
|
|
203
206
|
};
|
|
207
|
+
// Restore the original fetch when the clipped map unmounts, so the global
|
|
208
|
+
// override doesn't leak into the rest of the app.
|
|
209
|
+
return function () { window.fetch = originalFetch; };
|
|
204
210
|
}, []);
|
|
205
211
|
var handleLoad = function (e) {
|
|
206
212
|
var map = e.target;
|
|
@@ -229,7 +235,7 @@ var MapBase = function (props) {
|
|
|
229
235
|
};
|
|
230
236
|
var Controls = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n & > * {\n pointer-events: all;\n }\n\n ", ";\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n & > * {\n pointer-events: all;\n }\n\n ", ";\n"])), function (p) { return p.theme.font.bodyMedium; });
|
|
231
237
|
var Map = function (_a) {
|
|
232
|
-
var _b = _a.longitude, longitude = _b === void 0 ?
|
|
238
|
+
var _b = _a.longitude, longitude = _b === void 0 ? DEFAULT_LONGITUDE : _b, _c = _a.latitude, latitude = _c === void 0 ? DEFAULT_LATITUDE : _c, _d = _a.zoom, zoom = _d === void 0 ? DEFAULT_ZOOM : _d, _e = _a.pitch, pitch = _e === void 0 ? DEFAULT_PITCH : _e, _f = _a.bearing, bearing = _f === void 0 ? DEFAULT_BEARING : _f, _g = _a.logoPosition, logoPosition = _g === void 0 ? 'top-right' : _g, _h = _a.interactiveLayerIds, interactiveLayerIds = _h === void 0 ? [] : _h, _j = _a.noRotate, noRotate = _j === void 0 ? false : _j, _k = _a.preserveDrawingBuffer, preserveDrawingBuffer = _k === void 0 ? false : _k, _l = _a.minZoom, minZoom = _l === void 0 ? 1 : _l, _m = _a.maxZoom, maxZoom = _m === void 0 ? 20 : _m, _o = _a.fadeDuration, fadeDuration = _o === void 0 ? 300 : _o, _p = _a.doubleClickZoom, doubleClickZoom = _p === void 0 ? true : _p, props = __rest(_a, ["longitude", "latitude", "zoom", "pitch", "bearing", "logoPosition", "interactiveLayerIds", "noRotate", "preserveDrawingBuffer", "minZoom", "maxZoom", "fadeDuration", "doubleClickZoom"]);
|
|
233
239
|
return React.createElement(MapBase, __assign({ longitude: longitude, latitude: latitude, zoom: zoom, pitch: pitch, bearing: bearing, logoPosition: logoPosition, interactiveLayerIds: interactiveLayerIds, noRotate: noRotate, preserveDrawingBuffer: preserveDrawingBuffer, minZoom: minZoom, maxZoom: maxZoom, fadeDuration: fadeDuration, doubleClickZoom: doubleClickZoom }, props));
|
|
234
240
|
};
|
|
235
241
|
Map.displayName = 'Map';
|
|
@@ -24,15 +24,19 @@ var PositionBox = function (props) {
|
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
26
|
var handleMouseMove = function (ev) {
|
|
27
|
-
if (dragging)
|
|
27
|
+
if (dragging && dragOffset.current)
|
|
28
28
|
props.onMove(ev.clientX - dragOffset.current[0], ev.clientY - dragOffset.current[1]);
|
|
29
29
|
};
|
|
30
30
|
var handleMouseUp = function () {
|
|
31
31
|
setDragging(false);
|
|
32
32
|
};
|
|
33
33
|
var handleStartDrag = function (ev) {
|
|
34
|
-
var
|
|
35
|
-
var
|
|
34
|
+
var _a;
|
|
35
|
+
var parent = (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
36
|
+
if (!parent)
|
|
37
|
+
return;
|
|
38
|
+
var x = parent.offsetLeft;
|
|
39
|
+
var y = parent.offsetTop;
|
|
36
40
|
dragOffset.current = [ev.clientX - x - 9, ev.clientY - y - 38];
|
|
37
41
|
setDragging(true);
|
|
38
42
|
};
|
|
@@ -40,10 +40,16 @@ var PositionsManager = function (_a) {
|
|
|
40
40
|
var store = storage == 'session' ? sessionStorage : localStorage;
|
|
41
41
|
// Retrieve positions from storage. Returns [] if no data in store.
|
|
42
42
|
var loadPositionsFromStorage = function () {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
try {
|
|
44
|
+
var json = store.getItem(STORAGE_KEY);
|
|
45
|
+
if (json == null)
|
|
46
|
+
return [];
|
|
47
|
+
return JSON.parse(json);
|
|
48
|
+
}
|
|
49
|
+
catch (_a) {
|
|
50
|
+
// Ignore corrupt/unavailable storage.
|
|
45
51
|
return [];
|
|
46
|
-
|
|
52
|
+
}
|
|
47
53
|
};
|
|
48
54
|
// Save positions to store.
|
|
49
55
|
var savePositionsToStorage = function (positions) {
|
|
@@ -55,13 +61,16 @@ var PositionsManager = function (_a) {
|
|
|
55
61
|
// Ctrl key must be held down.
|
|
56
62
|
if (!ev.originalEvent.ctrlKey)
|
|
57
63
|
return;
|
|
64
|
+
var m = map.current;
|
|
65
|
+
if (!m)
|
|
66
|
+
return;
|
|
58
67
|
// Add click coordinates to positions list.
|
|
59
68
|
setPositions(function (positions) {
|
|
60
69
|
// Allow no more than 3 saved positions.
|
|
61
70
|
if (positions.length >= maxPositions)
|
|
62
71
|
return positions;
|
|
63
72
|
// Add new position to positions list.
|
|
64
|
-
var position = { lng: ev.lngLat.lng, lat: ev.lngLat.lat, zoom:
|
|
73
|
+
var position = { lng: ev.lngLat.lng, lat: ev.lngLat.lat, zoom: m.getZoom() };
|
|
65
74
|
var newPositions = __spreadArray([position], positions, true);
|
|
66
75
|
// Store new positions list in store.
|
|
67
76
|
savePositionsToStorage(newPositions);
|
|
@@ -71,31 +80,42 @@ var PositionsManager = function (_a) {
|
|
|
71
80
|
// Add a CTRL+click handler to the map, and removes
|
|
72
81
|
// it on unmount.
|
|
73
82
|
React.useEffect(function () {
|
|
74
|
-
map.current
|
|
75
|
-
|
|
83
|
+
var m = map.current;
|
|
84
|
+
if (!m)
|
|
85
|
+
return undefined;
|
|
86
|
+
m.on('click', handleRegisterCoordinate);
|
|
87
|
+
return function () { m.off('click', handleRegisterCoordinate); };
|
|
76
88
|
}, []);
|
|
77
89
|
var handleMovePosition = function (idx, x, y) {
|
|
78
|
-
var
|
|
79
|
-
|
|
90
|
+
var m = map.current;
|
|
91
|
+
if (!m)
|
|
92
|
+
return;
|
|
93
|
+
var _a = m.unproject([x, y]), lng = _a.lng, lat = _a.lat;
|
|
94
|
+
var position = { lng: lng, lat: lat, zoom: m.getZoom() };
|
|
80
95
|
var head = positions.slice(0, idx);
|
|
81
96
|
var tail = positions.slice(idx + 1);
|
|
82
97
|
var newPositions = __spreadArray(__spreadArray(__spreadArray([], head, true), [position], false), tail, true);
|
|
83
98
|
setPositions(newPositions);
|
|
84
|
-
savePositionsToStorage(
|
|
99
|
+
savePositionsToStorage(newPositions);
|
|
85
100
|
};
|
|
86
101
|
var handleDeletePosition = function (idx) {
|
|
87
|
-
positions.
|
|
88
|
-
setPositions(
|
|
89
|
-
savePositionsToStorage(
|
|
102
|
+
var newPositions = positions.filter(function (_, i) { return i !== idx; });
|
|
103
|
+
setPositions(newPositions);
|
|
104
|
+
savePositionsToStorage(newPositions);
|
|
90
105
|
};
|
|
91
106
|
var handleFocus = function (idx) {
|
|
92
107
|
var position = positions[idx];
|
|
108
|
+
if (!map.current)
|
|
109
|
+
return;
|
|
93
110
|
map.current.easeTo({
|
|
94
111
|
center: [position.lng, position.lat],
|
|
95
112
|
zoom: position.zoom
|
|
96
113
|
});
|
|
97
114
|
};
|
|
98
|
-
return (React.createElement(React.Fragment, null, positions.reverse().map(function (position,
|
|
115
|
+
return (React.createElement(React.Fragment, null, positions.slice().reverse().map(function (position, revIdx) {
|
|
116
|
+
// Map the display (reversed) index back to the canonical index so the
|
|
117
|
+
// move/delete/focus handlers target the correct entry.
|
|
118
|
+
var idx = positions.length - 1 - revIdx;
|
|
99
119
|
return React.createElement(PositionBox, { key: idx, coord: position, onMove: function (x, y) { return handleMovePosition(idx, x, y); }, onDelete: function () { return handleDeletePosition(idx); }, onFocus: function () { return handleFocus(idx); } });
|
|
100
120
|
})));
|
|
101
121
|
};
|
|
@@ -34,7 +34,7 @@ import { Key } from '../../../controls/Key';
|
|
|
34
34
|
var CompassButtonBase = function (props) {
|
|
35
35
|
var viewState = useViewState();
|
|
36
36
|
var map = useMap().current;
|
|
37
|
-
return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "CompassButton", onClick: function () { map.rotateTo(0); map.resetNorthPitch(); } }, props),
|
|
37
|
+
return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "CompassButton", ariaLabel: "Reset bearing and pitch", onClick: function () { map.rotateTo(0); map.resetNorthPitch(); } }, props),
|
|
38
38
|
React.createElement("div", { style: { transform: "rotateX(".concat(props.visualizePitch ? viewState.pitch : 0, "deg)") } },
|
|
39
39
|
React.createElement("svg", { style: { transform: "rotateZ(".concat(-viewState.bearing, "deg)") }, xmlns: "http://www.w3.org/2000/svg", x: "0px", y: "0px", viewBox: "0 0 1000 1000" },
|
|
40
40
|
React.createElement("polygon", { className: "tip", points: "100,1000 500,0 900,1000 500,700 " }),
|
|
@@ -59,7 +59,7 @@ var FullscreenButton = function (_a) {
|
|
|
59
59
|
window.document.exitFullscreen();
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "FullscreenButton", disabled: !checkFullscreenSupport(), onClick: toggle, hint: hint }, props),
|
|
62
|
+
return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "FullscreenButton", ariaLabel: "Toggle fullscreen", disabled: !checkFullscreenSupport(), onClick: toggle, hint: hint }, props),
|
|
63
63
|
React.createElement("svg", { width: "100", height: "100", viewBox: "0 0 448 512", xmlns: "http://www.w3.org/2000/svg" },
|
|
64
64
|
React.createElement("path", { d: "M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z" }))));
|
|
65
65
|
};
|
|
@@ -33,27 +33,34 @@ import { GeocoderList } from './GeocoderList';
|
|
|
33
33
|
import { GeocoderSelector } from './GeocoderSelector';
|
|
34
34
|
import { MapControl } from '../base/MapControl';
|
|
35
35
|
import { useOutsideClose } from '../../../hooks/useOutsideClose';
|
|
36
|
+
// Default prop values, referenced both by the GeocoderBase fallbacks and the
|
|
37
|
+
// Geocoder wrapper below.
|
|
38
|
+
var DEFAULT_SEARCH_ICON = false;
|
|
39
|
+
var DEFAULT_PLACEHOLDER = "Type to search places";
|
|
40
|
+
var DEFAULT_UPWARDS = false;
|
|
36
41
|
var GeocoderBase = function (props) {
|
|
42
|
+
var _a, _b, _c;
|
|
37
43
|
var wrapperRef = React.useRef(null);
|
|
38
44
|
var map = useMap().current;
|
|
39
45
|
// Timer is used for debouncing requests:
|
|
40
|
-
var
|
|
46
|
+
var _d = React.useState(null), timer = _d[0], setTimer = _d[1];
|
|
41
47
|
// Current query:
|
|
42
|
-
var
|
|
48
|
+
var _e = React.useState(""), q = _e[0], setQ = _e[1];
|
|
43
49
|
// Currently retrieved features:
|
|
44
|
-
var
|
|
50
|
+
var _f = React.useState([]), features = _f[0], setFeatures = _f[1];
|
|
45
51
|
// Offset of currently-selected feature (0-based):
|
|
46
|
-
var
|
|
52
|
+
var _g = React.useState(-1), selectedIndex = _g[0], setSelectedIndex = _g[1];
|
|
47
53
|
//
|
|
48
54
|
// Clear the control, removing any items.
|
|
49
55
|
// Focus on input.
|
|
50
56
|
//
|
|
51
57
|
var clear = function () {
|
|
58
|
+
var _a;
|
|
52
59
|
setQ("");
|
|
53
60
|
setFeatures([]);
|
|
54
61
|
setSelectedIndex(-1);
|
|
55
|
-
if (wrapperRef)
|
|
56
|
-
wrapperRef.current.querySelector('input').focus();
|
|
62
|
+
if (wrapperRef.current)
|
|
63
|
+
(_a = wrapperRef.current.querySelector('input')) === null || _a === void 0 ? void 0 : _a.focus();
|
|
57
64
|
};
|
|
58
65
|
useOutsideClose({
|
|
59
66
|
open: features.length > 0,
|
|
@@ -66,7 +73,7 @@ var GeocoderBase = function (props) {
|
|
|
66
73
|
// Call mapbox geocoder API, and store results in state.
|
|
67
74
|
//
|
|
68
75
|
var lookup = function (q) {
|
|
69
|
-
if (q
|
|
76
|
+
if (q === "") {
|
|
70
77
|
clear();
|
|
71
78
|
return;
|
|
72
79
|
}
|
|
@@ -78,13 +85,17 @@ var GeocoderBase = function (props) {
|
|
|
78
85
|
setFeatures(res);
|
|
79
86
|
if (res.length > 0)
|
|
80
87
|
setSelectedIndex(0);
|
|
88
|
+
})
|
|
89
|
+
.catch(function () {
|
|
90
|
+
setFeatures([]);
|
|
91
|
+
setSelectedIndex(-1);
|
|
81
92
|
});
|
|
82
93
|
};
|
|
83
94
|
//
|
|
84
95
|
// Debounce calls to lookup by 350ms.
|
|
85
96
|
//
|
|
86
97
|
var lookupDebounced = function (q) {
|
|
87
|
-
if (timer
|
|
98
|
+
if (timer !== null) {
|
|
88
99
|
window.clearTimeout(timer);
|
|
89
100
|
setTimer(null);
|
|
90
101
|
}
|
|
@@ -95,6 +106,8 @@ var GeocoderBase = function (props) {
|
|
|
95
106
|
lookupDebounced(newq);
|
|
96
107
|
};
|
|
97
108
|
var handleClick = function (feature) {
|
|
109
|
+
if (!map)
|
|
110
|
+
return;
|
|
98
111
|
if (feature.properties.bbox) {
|
|
99
112
|
map.fitBounds(feature.properties.bbox);
|
|
100
113
|
}
|
|
@@ -121,7 +134,8 @@ var GeocoderBase = function (props) {
|
|
|
121
134
|
case 'Enter':
|
|
122
135
|
case 'NumpadEnter':
|
|
123
136
|
e.preventDefault();
|
|
124
|
-
|
|
137
|
+
if (selectedIndex >= 0 && features[selectedIndex])
|
|
138
|
+
handleClick(features[selectedIndex]);
|
|
125
139
|
break;
|
|
126
140
|
case 'Escape':
|
|
127
141
|
e.preventDefault();
|
|
@@ -129,11 +143,11 @@ var GeocoderBase = function (props) {
|
|
|
129
143
|
break;
|
|
130
144
|
}
|
|
131
145
|
};
|
|
132
|
-
return (React.createElement(MapControl, { "data-testid": props['data-testid'] || "Geocoder", x: props.x, y: props.y },
|
|
146
|
+
return (React.createElement(MapControl, { "data-testid": props['data-testid'] || "Geocoder", x: props.x, y: props.y, respectPadding: props.respectPadding, style: props.style },
|
|
133
147
|
React.createElement("div", { className: props.className, onKeyDown: function (e) { return handleKeyDown(e); }, ref: wrapperRef },
|
|
134
|
-
React.createElement(GeocoderSelector, { placeholder: props.placeholder, searchIcon: props.searchIcon, value: q, onChange: handleChange }),
|
|
135
|
-
features.length > 0 && React.createElement(GeocoderList, { upwards: props.upwards }, features.map(function (f, idx) {
|
|
136
|
-
return React.createElement(GeocoderEntry, { key: idx, feature: f, selected: idx
|
|
148
|
+
React.createElement(GeocoderSelector, { placeholder: (_a = props.placeholder) !== null && _a !== void 0 ? _a : DEFAULT_PLACEHOLDER, searchIcon: (_b = props.searchIcon) !== null && _b !== void 0 ? _b : DEFAULT_SEARCH_ICON, value: q, onChange: handleChange }),
|
|
149
|
+
features.length > 0 && React.createElement(GeocoderList, { upwards: (_c = props.upwards) !== null && _c !== void 0 ? _c : DEFAULT_UPWARDS }, features.map(function (f, idx) {
|
|
150
|
+
return React.createElement(GeocoderEntry, { key: idx, feature: f, selected: idx === selectedIndex, onClick: function () { return handleClick(f); } });
|
|
137
151
|
})))));
|
|
138
152
|
};
|
|
139
153
|
var GeocoderStyled = styled(GeocoderBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: ", "px;\n pointer-events: all !important;\n"], ["\n width: ", "px;\n pointer-events: all !important;\n"
|
|
@@ -159,7 +173,7 @@ var GeocoderStyled = styled(GeocoderBase)(templateObject_1 || (templateObject_1
|
|
|
159
173
|
* Mapbox geocoding playground: https://docs.mapbox.com/playground/geocoding/
|
|
160
174
|
*/
|
|
161
175
|
var Geocoder = function (_a) {
|
|
162
|
-
var _b = _a.width, width = _b === void 0 ? 300 : _b, _c = _a.searchIcon, searchIcon = _c === void 0 ?
|
|
176
|
+
var _b = _a.width, width = _b === void 0 ? 300 : _b, _c = _a.searchIcon, searchIcon = _c === void 0 ? DEFAULT_SEARCH_ICON : _c, _d = _a.placeholder, placeholder = _d === void 0 ? DEFAULT_PLACEHOLDER : _d, _e = _a.pointZoom, pointZoom = _e === void 0 ? 15 : _e, _f = _a.proximityIP, proximityIP = _f === void 0 ? true : _f, _g = _a.upwards, upwards = _g === void 0 ? DEFAULT_UPWARDS : _g, props = __rest(_a, ["width", "searchIcon", "placeholder", "pointZoom", "proximityIP", "upwards"]);
|
|
163
177
|
return React.createElement(GeocoderStyled, __assign({ width: width, searchIcon: searchIcon, placeholder: placeholder, pointZoom: pointZoom, proximityIP: proximityIP, upwards: upwards }, props));
|
|
164
178
|
};
|
|
165
179
|
Geocoder.displayName = "Geocoder";
|
|
@@ -55,6 +55,8 @@ var GeocoderApi = /** @class */ (function () {
|
|
|
55
55
|
})];
|
|
56
56
|
case 1:
|
|
57
57
|
res = _a.sent();
|
|
58
|
+
if (!res.ok)
|
|
59
|
+
throw new Error("Geocoder lookup failed: ".concat(res.status, " ").concat(res.statusText));
|
|
58
60
|
return [4 /*yield*/, res.json()];
|
|
59
61
|
case 2:
|
|
60
62
|
json = _a.sent();
|
|
@@ -20,6 +20,6 @@ var GeocoderSelectorBase = function (props) {
|
|
|
20
20
|
React.createElement(Icon, { url: SVG.Icons.Search, color: theme.colors.neutral[50] }),
|
|
21
21
|
React.createElement("input", { placeholder: props.placeholder, value: props.value, onChange: handleChange })));
|
|
22
22
|
};
|
|
23
|
-
var GeocoderSelector = styled(GeocoderSelectorBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n height: 34px;\n padding-left: 8px;\n padding-right: 8px;\n\n // Content: \n display: flex;\n align-items: center;\n gap: 4px;\n\n // Appearance:\n background-color: ", ";\n box-sizing: border-box;\n border-radius: ", "px;\n border: none;\n\n // Hover:\n &:hover {\n outline: solid 2px ", ";\n }\n\n // Focus:\n :focus-within > & {\n outline: solid 2px ", ";\n &::placeholder {\n color: rgb(from ", " r g b / 30%);\n }\n }\n \n input {\n width: 100%;\n box-sizing: border-box;\n z-index: 0;\n text-align: left;\n border: none;\n outline: none;\n background-color: transparent;\n color: ", ";\n \n // Define colors for placeholder text.\n &::placeholder {\n color: rgb(from ", " r g b / 50%);\n opacity: 1 !important; /* Firefox applies opacity */\n }\n\n // Define colors for selected text.\n &::selection {\n background-color: ", ";\n color: ", ";\n }\n\n /*
|
|
23
|
+
var GeocoderSelector = styled(GeocoderSelectorBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n height: 34px;\n padding-left: 8px;\n padding-right: 8px;\n\n // Content: \n display: flex;\n align-items: center;\n gap: 4px;\n\n // Appearance:\n background-color: ", ";\n box-sizing: border-box;\n border-radius: ", "px;\n border: none;\n\n // Hover:\n &:hover {\n outline: solid 2px ", ";\n }\n\n // Focus:\n :focus-within > & {\n outline: solid 2px ", ";\n &::placeholder {\n color: rgb(from ", " r g b / 30%);\n }\n }\n \n input {\n width: 100%;\n box-sizing: border-box;\n z-index: 0;\n text-align: left;\n border: none;\n outline: none;\n background-color: transparent;\n color: ", ";\n \n // Define colors for placeholder text.\n &::placeholder {\n color: rgb(from ", " r g b / 50%);\n opacity: 1 !important; /* Firefox applies opacity */\n }\n\n // Define colors for selected text.\n &::selection {\n background-color: ", ";\n color: ", ";\n }\n\n /* Make sure HTML5 validation does not show up. */\n &:valid {\n box-shadow: none;\n }\n &:invalid {\n box-shadow: none;\n }\n\n /* Turn off number spinners. */\n &[type=number]::-webkit-inner-spin-button, \n &[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none; /* Webkit (Chrome) */\n margin: 0; \n } \n &[type=number] {\n -moz-appearance: textfield; /* Firefox */\n appearance: textfield;\n }\n }\n"], ["\n position: relative;\n height: 34px;\n padding-left: 8px;\n padding-right: 8px;\n\n // Content: \n display: flex;\n align-items: center;\n gap: 4px;\n\n // Appearance:\n background-color: ", ";\n box-sizing: border-box;\n border-radius: ", "px;\n border: none;\n\n // Hover:\n &:hover {\n outline: solid 2px ", ";\n }\n\n // Focus:\n :focus-within > & {\n outline: solid 2px ", ";\n &::placeholder {\n color: rgb(from ", " r g b / 30%);\n }\n }\n \n input {\n width: 100%;\n box-sizing: border-box;\n z-index: 0;\n text-align: left;\n border: none;\n outline: none;\n background-color: transparent;\n color: ", ";\n \n // Define colors for placeholder text.\n &::placeholder {\n color: rgb(from ", " r g b / 50%);\n opacity: 1 !important; /* Firefox applies opacity */\n }\n\n // Define colors for selected text.\n &::selection {\n background-color: ", ";\n color: ", ";\n }\n\n /* Make sure HTML5 validation does not show up. */\n &:valid {\n box-shadow: none;\n }\n &:invalid {\n box-shadow: none;\n }\n\n /* Turn off number spinners. */\n &[type=number]::-webkit-inner-spin-button, \n &[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none; /* Webkit (Chrome) */\n margin: 0; \n } \n &[type=number] {\n -moz-appearance: textfield; /* Firefox */\n appearance: textfield;\n }\n }\n"])), function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.theme.radius.normal; }, function (p) { return p.theme.colors.primary[2]; }, function (p) { return p.theme.colors.primary[1]; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.theme.colors.primary[2]; }, function (p) { return p.theme.colors.neutral[100]; });
|
|
24
24
|
export { GeocoderSelector };
|
|
25
25
|
var templateObject_1;
|
|
@@ -75,7 +75,6 @@ var Graticule = function (props) {
|
|
|
75
75
|
var step = props.adaptive ? props.degrees / Math.pow(2, Math.ceil(viewState.zoom - 1)) : props.degrees;
|
|
76
76
|
var bounds = getBounds();
|
|
77
77
|
var features = [];
|
|
78
|
-
var count = 0;
|
|
79
78
|
for (var lng = -180; lng <= 180; lng += step) {
|
|
80
79
|
if (!(lng > bounds.west && lng < bounds.east))
|
|
81
80
|
continue;
|
|
@@ -84,7 +83,6 @@ var Graticule = function (props) {
|
|
|
84
83
|
geometry: { type: 'LineString', coordinates: [[lng, -90], [lng, 90]] },
|
|
85
84
|
properties: {}
|
|
86
85
|
});
|
|
87
|
-
count++;
|
|
88
86
|
}
|
|
89
87
|
for (var lat = -90; lat <= 90; lat += step) {
|
|
90
88
|
if (!(lat < bounds.north && lat > bounds.south))
|
|
@@ -94,7 +92,6 @@ var Graticule = function (props) {
|
|
|
94
92
|
geometry: { type: 'LineString', coordinates: [[-180, lat], [180, lat]] },
|
|
95
93
|
properties: {}
|
|
96
94
|
});
|
|
97
|
-
count++;
|
|
98
95
|
}
|
|
99
96
|
for (var lng = -180 + step; lng <= 180; lng += step) {
|
|
100
97
|
if (!(lng > bounds.west && lng < bounds.east))
|
|
@@ -112,7 +109,6 @@ var Graticule = function (props) {
|
|
|
112
109
|
geometry: { type: 'Point', coordinates: [lng, lat + step / 2] },
|
|
113
110
|
properties: { x: props.decimal ? formatNumber(lng, 3) : formatLongitude(lng) }
|
|
114
111
|
});
|
|
115
|
-
count += 2;
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
114
|
return { type: 'FeatureCollection', features: features };
|
|
@@ -120,7 +116,7 @@ var Graticule = function (props) {
|
|
|
120
116
|
var _b = React.useState({ type: 'FeatureCollection', features: [] }), featureCollection = _b[0], setFeatureCollection = _b[1];
|
|
121
117
|
React.useEffect(function () {
|
|
122
118
|
setFeatureCollection(buildGrid());
|
|
123
|
-
}, [viewState.zoom, viewState.latitude, viewState.longitude]);
|
|
119
|
+
}, [viewState.zoom, viewState.latitude, viewState.longitude, props.degrees, props.adaptive, props.decimal]);
|
|
124
120
|
return (React.createElement(React.Fragment, null,
|
|
125
121
|
React.createElement(Source, { type: "geojson", data: featureCollection },
|
|
126
122
|
React.createElement(Layer, { type: "line", filter: ['==', ["geometry-type"], 'LineString'], paint: {
|
|
@@ -30,7 +30,7 @@ import { MapControl } from '../base/MapControl';
|
|
|
30
30
|
var DEFAULT_SIZE = 40; // Default control size (px)
|
|
31
31
|
var DEFAULT_COLOR = "white"; // Default control color
|
|
32
32
|
var MapLoaderBase = function (props) {
|
|
33
|
-
return (React.createElement(MapControl, { "data-testid": props['data-testid'] || "MapLoader", x: props.x, y: props.y },
|
|
33
|
+
return (React.createElement(MapControl, { "data-testid": props['data-testid'] || "MapLoader", x: props.x, y: props.y, respectPadding: props.respectPadding, style: props.style },
|
|
34
34
|
React.createElement("div", { className: props.className },
|
|
35
35
|
React.createElement(Svg, { width: "1792", height: "1792", viewBox: "0 0 1792 1792", xmlns: "http://www.w3.org/2000/svg" },
|
|
36
36
|
React.createElement("path", { d: "M1760 896q0 176-68.5 336t-184 275.5-275.5 184-336 68.5-336-68.5-275.5-184-184-275.5-68.5-336q0-213 97-398.5t265-305.5 374-151v228q-221 45-366.5 221t-145.5 406q0 130 51 248.5t136.5 204 204 136.5 248.5 51 248.5-51 204-136.5 136.5-204 51-248.5q0-230-145.5-406t-366.5-221v-228q206 31 374 151t265 305.5 97 398.5z" })))));
|
|
@@ -100,7 +100,7 @@ var ScaleControlStyled = styled(ScaleControlBase)(templateObject_1 || (templateO
|
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
102
|
var ScaleControl = function (_a) {
|
|
103
|
-
var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, _d = _a.width, width = _d === void 0 ?
|
|
103
|
+
var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, _d = _a.width, width = _d === void 0 ? DEFAULT_WIDTH : _d, props = __rest(_a, ["x", "y", "width"]);
|
|
104
104
|
return React.createElement(ScaleControlStyled, __assign({ x: x, y: y, width: width }, props));
|
|
105
105
|
};
|
|
106
106
|
ScaleControl.displayName = 'ScaleControl';
|
|
@@ -49,7 +49,7 @@ var ZoomInButton = function (_a) {
|
|
|
49
49
|
" Zoom in") : _b, props = __rest(_a, ["hint"]);
|
|
50
50
|
var viewState = useViewState();
|
|
51
51
|
var map = useMap().current;
|
|
52
|
-
return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "ZoomInButton", disabled: viewState.zoom >= map.getMaxZoom(), onClick: function () { return map.zoomIn(); }, hint: hint }, props),
|
|
52
|
+
return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "ZoomInButton", ariaLabel: "Zoom in", disabled: viewState.zoom >= map.getMaxZoom(), onClick: function () { return map.zoomIn(); }, hint: hint }, props),
|
|
53
53
|
React.createElement("svg", { width: "100", height: "100", viewBox: "0 0 100 100", xmlns: "http://www.w3.org/2000/svg" },
|
|
54
54
|
React.createElement("path", { d: "M100,43.2v13.6c0,1.9-0.7,3.5-2,4.8c-1.3,1.3-2.9,2-4.8,2H63.6v29.5c0,1.9-0.7,3.5-2,4.8c-1.3,1.3-2.9,2-4.8,2H43.2c-1.9,0-3.5-0.7-4.8-2c-1.3-1.3-2-2.9-2-4.8V63.6H6.8c-1.9,0-3.5-0.7-4.8-2c-1.3-1.3-2-2.9-2-4.8V43.2c0-1.9,0.7-3.5,2-4.8c1.3-1.3,2.9-2,4.8-2h29.5V6.8c0-1.9,0.7-3.5,2-4.8c1.3-1.3,2.9-2,4.8-2h13.6c1.9,0,3.5,0.7,4.8,2c1.3,1.3,2,2.9,2,4.8v29.5h29.5c1.9,0,3.5,0.7,4.8,2C99.3,39.7,100,41.3,100,43.2z" }))));
|
|
55
55
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { IMapButtonProps } from '../base/MapButton';
|
|
3
3
|
/**
|
|
4
|
-
* The `
|
|
4
|
+
* The `ZoomOutButton` zooms the map out when clicked. It respects the min and
|
|
5
5
|
* max zoom levels of the map.
|
|
6
6
|
*
|
|
7
7
|
* The current map ViewState must be passed to this control, which is done
|
|
@@ -27,7 +27,7 @@ import { useViewState } from '../../Map';
|
|
|
27
27
|
import { Mouse } from '../../../controls/Mouse';
|
|
28
28
|
import { Key } from '../../../controls/Key';
|
|
29
29
|
/**
|
|
30
|
-
* The `
|
|
30
|
+
* The `ZoomOutButton` zooms the map out when clicked. It respects the min and
|
|
31
31
|
* max zoom levels of the map.
|
|
32
32
|
*
|
|
33
33
|
* The current map ViewState must be passed to this control, which is done
|
|
@@ -49,7 +49,7 @@ var ZoomOutButton = function (_a) {
|
|
|
49
49
|
" Zoom out") : _b, props = __rest(_a, ["hint"]);
|
|
50
50
|
var viewState = useViewState();
|
|
51
51
|
var map = useMap().current;
|
|
52
|
-
return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "ZoomOutButton", disabled: viewState.zoom <= map.getMinZoom(), onClick: function () { return map.zoomOut(); }, hint: hint }, props),
|
|
52
|
+
return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "ZoomOutButton", ariaLabel: "Zoom out", disabled: viewState.zoom <= map.getMinZoom(), onClick: function () { return map.zoomOut(); }, hint: hint }, props),
|
|
53
53
|
React.createElement("svg", { width: "100", height: "100", viewBox: "0 0 100 100", xmlns: "http://www.w3.org/2000/svg" },
|
|
54
54
|
React.createElement("path", { d: "M93.2,36.4c1.9,0,3.5,0.7,4.8,2c1.3,1.3,2,2.9,2,4.8v13.6c0,1.9-0.7,3.5-2,4.8c-1.3,1.3-2.9,2-4.8,2H63.6H6.8c-1.9,0-3.5-0.7-4.8-2c-1.3-1.3-2-2.9-2-4.8V43.2c0-1.9,0.7-3.5,2-4.8c1.3-1.3,2.9-2,4.8-2" }))));
|
|
55
55
|
};
|
|
@@ -15,6 +15,11 @@ interface IMapButtonProps extends IMapControlProps {
|
|
|
15
15
|
* Optional hint to show on hover. This can be JSX. No hint is shown if this value is `null`.
|
|
16
16
|
*/
|
|
17
17
|
hint?: React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Accessible label for the button, read by screen readers. Provide this when
|
|
20
|
+
* the `hint` is JSX (a string hint is used as the label automatically).
|
|
21
|
+
*/
|
|
22
|
+
ariaLabel?: string;
|
|
18
23
|
/**
|
|
19
24
|
* Button size in pixels.
|
|
20
25
|
* @defaultValue 32
|
|
@@ -31,9 +36,10 @@ interface IProps {
|
|
|
31
36
|
/** @ignore */
|
|
32
37
|
children?: React.ReactNode;
|
|
33
38
|
/**
|
|
34
|
-
* Fired when the map button is clicked.
|
|
39
|
+
* Fired when the map button is clicked, or activated with Enter/Space.
|
|
40
|
+
* Receives the originating mouse or keyboard event.
|
|
35
41
|
*/
|
|
36
|
-
onClick: (e
|
|
42
|
+
onClick: (e: React.MouseEvent | React.KeyboardEvent) => void;
|
|
37
43
|
}
|
|
38
44
|
/**
|
|
39
45
|
* A `MapButton` is a square button to be used on a Mapbox map. It must
|
|
@@ -39,6 +39,14 @@ var MapButtonBase = function (props) {
|
|
|
39
39
|
if (props.onClick)
|
|
40
40
|
props.onClick(e);
|
|
41
41
|
};
|
|
42
|
+
var handleKeyDown = function (e) {
|
|
43
|
+
if (props.disabled)
|
|
44
|
+
return;
|
|
45
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
props.onClick(e);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
42
50
|
var handleMouseEnter = function () {
|
|
43
51
|
if (hintRef)
|
|
44
52
|
hintRef.style.opacity = "1";
|
|
@@ -60,7 +68,8 @@ var MapButtonBase = function (props) {
|
|
|
60
68
|
]
|
|
61
69
|
}), styles = _c.styles, attributes = _c.attributes, update = _c.update;
|
|
62
70
|
var renderButton = function () {
|
|
63
|
-
|
|
71
|
+
var _a;
|
|
72
|
+
return React.createElement("div", { ref: setWrapperRef, className: props.className, "data-testid": props['data-testid'] || "MapButton", tabIndex: props.disabled ? -1 : 0, role: "button", "aria-label": (_a = props.ariaLabel) !== null && _a !== void 0 ? _a : (typeof props.hint === 'string' ? props.hint : undefined), "aria-disabled": props.disabled, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
|
|
64
73
|
React.createElement(Button, { "data-testid": "MapButton.Button", "$grouped": props.grouped, "$size": props.size, "$disabled": props.disabled, "$active": props.active }, props.children),
|
|
65
74
|
props.hint &&
|
|
66
75
|
createPortal(React.createElement(Hint, { "data-testid": "MapButton.Hint", ref: setHintRef, styles: styles.popper, attributes: __assign({}, attributes.popper) }, props.hint), document.body));
|
|
@@ -69,7 +78,7 @@ var MapButtonBase = function (props) {
|
|
|
69
78
|
return renderButton();
|
|
70
79
|
return React.createElement(MapControl, { x: props.x, y: props.y }, renderButton());
|
|
71
80
|
};
|
|
72
|
-
var Button = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["
|
|
81
|
+
var Button = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n cursor: pointer;\n background-color: ", ";\n\n // Border:\n border-radius: 4px;\n\n ", "\n\n svg {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding: 8px;\n fill: ", ";\n transition: fill ease-in-out ", "ms;\n }\n\n // Hover:\n div:hover > & {\n background-color: ", ";\n }\n\n ", "\n\n // Disabled:\n ", "\n"], ["\n width: 100%;\n height: 100%;\n cursor: pointer;\n background-color: ", ";\n\n // Border:\n border-radius: 4px;\n\n ", "\n\n svg {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding: 8px;\n fill: ", ";\n transition: fill ease-in-out ", "ms;\n }\n\n // Hover:\n div:hover > & {\n background-color: ", ";\n }\n\n ", "\n\n // Disabled:\n ", "\n"])), function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.$grouped && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n div:first-child > & {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n }\n div:not(:last-child):not(:first-child) > & {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n }\n div:last-child > & {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n "], ["\n div:first-child > & {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n }\n div:not(:last-child):not(:first-child) > & {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n }\n div:last-child > & {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n "]))); }, function (p) { return p.theme.colors.neutral[10]; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.colors.neutral[95]; }, function (p) { return p.$active && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", " !important;\n svg {\n fill: ", ";\n }\n "], ["\n background-color: ", " !important;\n svg {\n fill: ", ";\n }\n "])), function (p) { return p.theme.colors.accent; }, function (p) { return p.theme.colors.neutral[100]; }); }, function (p) { return p.$disabled && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n cursor: default;\n background-color: ", ";\n svg { fill: ", "; } \n "], ["\n cursor: default;\n background-color: ", ";\n svg { fill: ", "; } \n "])), function (p) { return p.theme.colors.neutral[50]; }, function (p) { return p.theme.colors.primary[3]; }); });
|
|
73
82
|
var MapButtonStyled = styled(MapButtonBase)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: relative;\n pointer-events: all;\n\n // Size control:\n width: ", "px;\n height: ", "px;\n\n outline: 0;\n user-select: none;\n\n // Grouped button has a separator border (though not the last button in the group):\n ", "\n\n // Disabled mode:\n ", " \n"], ["\n position: relative;\n pointer-events: all;\n\n // Size control:\n width: ", "px;\n height: ", "px;\n\n outline: 0;\n user-select: none;\n\n // Grouped button has a separator border (though not the last button in the group):\n ", "\n\n // Disabled mode:\n ", " \n"
|
|
74
83
|
/**
|
|
75
84
|
* A `MapButton` is a square button to be used on a Mapbox map. It must
|
|
@@ -20,6 +20,11 @@ interface IMapControlProps extends ITestable {
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
respectPadding?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Optional inline styles applied to the outer element, merged after (and so
|
|
25
|
+
* overriding) the computed positioning styles.
|
|
26
|
+
*/
|
|
27
|
+
style?: React.CSSProperties;
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
30
|
* `MapControl` positions a control of top of a map, taking Mapbox `padding`
|
|
@@ -27,15 +27,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
27
27
|
import * as React from 'react';
|
|
28
28
|
import styled from 'styled-components';
|
|
29
29
|
import { useViewState } from '../../../Map';
|
|
30
|
+
// Default prop values, referenced both by the MapControlBase fallbacks and the
|
|
31
|
+
// MapControl wrapper below.
|
|
32
|
+
var DEFAULT_X = 0;
|
|
33
|
+
var DEFAULT_Y = 0;
|
|
30
34
|
var MapControlBase = function (props) {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
31
36
|
var viewState = useViewState();
|
|
32
|
-
|
|
37
|
+
var x = (_a = props.x) !== null && _a !== void 0 ? _a : DEFAULT_X;
|
|
38
|
+
var y = (_b = props.y) !== null && _b !== void 0 ? _b : DEFAULT_Y;
|
|
39
|
+
return (React.createElement("div", { "data-testid": props['data-testid'] || "MapControl", className: props.className, style: __assign({
|
|
33
40
|
// Must calculate this style dynamically, because it needs local state.
|
|
34
|
-
left: props.x
|
|
35
|
-
right: props.x < 0 ? "".concat((props.respectPadding ? viewState.padding.right : 0) - props.x, "px") : 'auto',
|
|
36
|
-
top: props.y >= 0 ? "".concat(props.y + (props.respectPadding ? viewState.padding.top : 0), "px") : 'auto',
|
|
37
|
-
bottom: props.y < 0 ? "".concat(-props.y - -(props.respectPadding ? viewState.padding.bottom : 0), "px") : 'auto'
|
|
38
|
-
} }, props.children));
|
|
41
|
+
left: x >= 0 ? "".concat(x + (props.respectPadding ? ((_d = (_c = viewState === null || viewState === void 0 ? void 0 : viewState.padding) === null || _c === void 0 ? void 0 : _c.left) !== null && _d !== void 0 ? _d : 0) : 0), "px") : 'auto', right: x < 0 ? "".concat((props.respectPadding ? ((_f = (_e = viewState === null || viewState === void 0 ? void 0 : viewState.padding) === null || _e === void 0 ? void 0 : _e.right) !== null && _f !== void 0 ? _f : 0) : 0) - x, "px") : 'auto', top: y >= 0 ? "".concat(y + (props.respectPadding ? ((_h = (_g = viewState === null || viewState === void 0 ? void 0 : viewState.padding) === null || _g === void 0 ? void 0 : _g.top) !== null && _h !== void 0 ? _h : 0) : 0), "px") : 'auto', bottom: y < 0 ? "".concat(-y - -(props.respectPadding ? ((_k = (_j = viewState === null || viewState === void 0 ? void 0 : viewState.padding) === null || _j === void 0 ? void 0 : _j.bottom) !== null && _k !== void 0 ? _k : 0) : 0), "px") : 'auto' }, props.style) }, props.children));
|
|
39
42
|
};
|
|
40
43
|
var MapControlStyled = styled(MapControlBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n z-index: 100;\n box-sizing: border-box;\n pointer-events: none;\n"], ["\n position: absolute;\n z-index: 100;\n box-sizing: border-box;\n pointer-events: none;\n"
|
|
41
44
|
/**
|
|
@@ -70,7 +73,7 @@ var MapControlStyled = styled(MapControlBase)(templateObject_1 || (templateObjec
|
|
|
70
73
|
* and `ScaleControl`.
|
|
71
74
|
*/
|
|
72
75
|
var MapControl = function (_a) {
|
|
73
|
-
var _b = _a.x, x = _b === void 0 ?
|
|
76
|
+
var _b = _a.x, x = _b === void 0 ? DEFAULT_X : _b, _c = _a.y, y = _c === void 0 ? DEFAULT_Y : _c, _d = _a.respectPadding, respectPadding = _d === void 0 ? false : _d, props = __rest(_a, ["x", "y", "respectPadding"]);
|
|
74
77
|
return React.createElement(MapControlStyled, __assign({ x: x, y: y, respectPadding: respectPadding }, props));
|
|
75
78
|
};
|
|
76
79
|
export { MapControl };
|