@longline/aqua-ui 1.0.338 → 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 +25 -0
- package/formatters/PhoneFormatter/PhoneFormatter.js +34 -0
- package/formatters/PhoneFormatter/index.d.ts +1 -0
- package/formatters/PhoneFormatter/index.js +1 -0
- 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/helper/phoneNumber.d.ts +31 -0
- package/helper/phoneNumber.js +142 -0
- 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 +97 -0
- package/inputs/PhoneInput/PhoneInput.js +113 -0
- package/inputs/PhoneInput/index.d.ts +2 -0
- package/inputs/PhoneInput/index.js +1 -0
- 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
|
@@ -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 };
|
|
@@ -24,13 +24,15 @@ import * as React from 'react';
|
|
|
24
24
|
import { Source, useMap } from 'react-map-gl/mapbox';
|
|
25
25
|
import { HtmlMarkerLayer } from '../HtmlMarkerLayer/HtmlMarkerLayer';
|
|
26
26
|
import { ClusterMarker } from '../../markers/ClusterMarker';
|
|
27
|
+
// Default cluster radius in pixels (see IClusterLayerProps.radius).
|
|
28
|
+
var DEFAULT_RADIUS = 24;
|
|
27
29
|
function uuidv4() {
|
|
28
30
|
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, function (c) {
|
|
29
31
|
return (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16);
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
var ClusterLayerBase = function (_a) {
|
|
33
|
-
var _b = _a.relativeSize, relativeSize = _b === void 0 ? 0 : _b, _c = _a.radius, radius = _c === void 0 ?
|
|
35
|
+
var _b = _a.relativeSize, relativeSize = _b === void 0 ? 0 : _b, _c = _a.radius, radius = _c === void 0 ? DEFAULT_RADIUS : _c, _d = _a.clusterRadius, clusterRadius = _d === void 0 ? 80 : _d, _e = _a.clusterMaxZoom, clusterMaxZoom = _e === void 0 ? 18 : _e, _f = _a.ringFields, ringFields = _f === void 0 ? [] : _f, _g = _a.clickZoom, clickZoom = _g === void 0 ? false : _g, props = __rest(_a, ["relativeSize", "radius", "clusterRadius", "clusterMaxZoom", "ringFields", "clickZoom"]);
|
|
34
36
|
var map = useMap().current;
|
|
35
37
|
// Generate a random, unique source ID:
|
|
36
38
|
var sourceId = React.useRef(uuidv4()).current;
|
|
@@ -68,6 +70,8 @@ var ClusterLayerBase = function (_a) {
|
|
|
68
70
|
return obj;
|
|
69
71
|
}, [props.aggregation, ringFields]);
|
|
70
72
|
var handleClick = function (longitude, latitude, cluster_id) {
|
|
73
|
+
if (!map)
|
|
74
|
+
return;
|
|
71
75
|
map.getSource(sourceId).getClusterExpansionZoom(cluster_id, function (err, zoom) {
|
|
72
76
|
if (err)
|
|
73
77
|
return;
|
|
@@ -79,7 +83,7 @@ var ClusterLayerBase = function (_a) {
|
|
|
79
83
|
};
|
|
80
84
|
return (React.createElement(Source, { id: sourceId, type: 'geojson', data: itemsToFeatures, cluster: true, clusterRadius: clusterRadius, clusterMaxZoom: clusterMaxZoom, clusterProperties: __assign({}, clusterProperties) },
|
|
81
85
|
React.createElement(HtmlMarkerLayer, { sourceId: sourceId, idField: "cluster_id", minZoom: props.minZoom, maxZoom: props.maxZoom }, function (markerProps) {
|
|
82
|
-
return React.createElement(ClusterMarker, __assign({ relativeSize: relativeSize, radius: radius, value: props.aggregation ? markerProps['sum'] : markerProps['point_count'], ringValues: ringFields.map(function (f) { return markerProps[f]; }), onClick: clickZoom ? function () { return handleClick(markerProps.longitude, markerProps.latitude, markerProps.cluster_id); } : null }, markerProps));
|
|
86
|
+
return React.createElement(ClusterMarker, __assign({ relativeSize: relativeSize, radius: radius, value: props.aggregation ? markerProps['sum'] : markerProps['point_count'], decimals: props.decimals, ringValues: ringFields.map(function (f) { return markerProps[f]; }), onClick: clickZoom ? function () { return handleClick(markerProps.longitude, markerProps.latitude, markerProps.cluster_id); } : null }, markerProps));
|
|
83
87
|
})));
|
|
84
88
|
};
|
|
85
89
|
/**
|
|
@@ -106,7 +110,7 @@ var ClusterLayerBase = function (_a) {
|
|
|
106
110
|
* ```
|
|
107
111
|
*/
|
|
108
112
|
var ClusterLayer = function (_a) {
|
|
109
|
-
var _b = _a.relativeSize, relativeSize = _b === void 0 ? 0 : _b, _c = _a.radius, radius = _c === void 0 ?
|
|
113
|
+
var _b = _a.relativeSize, relativeSize = _b === void 0 ? 0 : _b, _c = _a.radius, radius = _c === void 0 ? DEFAULT_RADIUS : _c, _d = _a.clusterRadius, clusterRadius = _d === void 0 ? 80 : _d, _e = _a.clusterMaxZoom, clusterMaxZoom = _e === void 0 ? 18 : _e, _f = _a.minZoom, minZoom = _f === void 0 ? 0 : _f, _g = _a.maxZoom, maxZoom = _g === void 0 ? 99 : _g, _h = _a.decimals, decimals = _h === void 0 ? 0 : _h, ringFields = _a.ringFields, _j = _a.clickZoom, clickZoom = _j === void 0 ? false : _j, props = __rest(_a, ["relativeSize", "radius", "clusterRadius", "clusterMaxZoom", "minZoom", "maxZoom", "decimals", "ringFields", "clickZoom"]);
|
|
110
114
|
var _k = React.useState(0), key = _k[0], setKey = _k[1];
|
|
111
115
|
// When aggregation changes, we mount a whole new component. Mapbox does not
|
|
112
116
|
// appear to deal with changes to clusterProperties well.
|
|
@@ -65,6 +65,8 @@ var HtmlMarkerLayerBase = function (_a) {
|
|
|
65
65
|
var childrenFn = React.useRef(children);
|
|
66
66
|
var ensureMarker = React.useCallback(function (feature) {
|
|
67
67
|
var _a, _b, _c, _d, _e;
|
|
68
|
+
if (!map)
|
|
69
|
+
return undefined;
|
|
68
70
|
var id = feature.properties[idField];
|
|
69
71
|
if (!id)
|
|
70
72
|
return undefined;
|
|
@@ -87,7 +89,9 @@ var HtmlMarkerLayerBase = function (_a) {
|
|
|
87
89
|
return marker;
|
|
88
90
|
}, [idField, map]);
|
|
89
91
|
var updateMarkers = React.useCallback(function () {
|
|
90
|
-
var _a, _b;
|
|
92
|
+
var _a, _b, _c;
|
|
93
|
+
if (!map)
|
|
94
|
+
return;
|
|
91
95
|
if (!map.getSource(sourceId))
|
|
92
96
|
return;
|
|
93
97
|
if (!map.isSourceLoaded(sourceId))
|
|
@@ -116,7 +120,7 @@ var HtmlMarkerLayerBase = function (_a) {
|
|
|
116
120
|
var newVisible = {};
|
|
117
121
|
for (var _i = 0, features_1 = features; _i < features_1.length; _i++) {
|
|
118
122
|
var feature = features_1[_i];
|
|
119
|
-
var id = feature.properties[idField];
|
|
123
|
+
var id = (_b = feature.properties) === null || _b === void 0 ? void 0 : _b[idField];
|
|
120
124
|
var marker = ensureMarker(feature);
|
|
121
125
|
if (marker)
|
|
122
126
|
newVisible[id] = marker;
|
|
@@ -124,7 +128,7 @@ var HtmlMarkerLayerBase = function (_a) {
|
|
|
124
128
|
for (var id in visibleRef.current) {
|
|
125
129
|
if (!newVisible[id]) {
|
|
126
130
|
visibleRef.current[id].remove();
|
|
127
|
-
(
|
|
131
|
+
(_c = rootsRef.current[id]) === null || _c === void 0 ? void 0 : _c.unmount();
|
|
128
132
|
delete markersRef.current[id];
|
|
129
133
|
delete rootsRef.current[id];
|
|
130
134
|
}
|
|
@@ -147,7 +151,7 @@ var HtmlMarkerLayerBase = function (_a) {
|
|
|
147
151
|
return function () {
|
|
148
152
|
map.off('sourcedata', onSourceData);
|
|
149
153
|
map.off('render', onRender);
|
|
150
|
-
//
|
|
154
|
+
// Defer cleanup until after React has finished unmounting.
|
|
151
155
|
requestAnimationFrame(function () {
|
|
152
156
|
var _a;
|
|
153
157
|
for (var id in markersRef.current) {
|
|
@@ -27,6 +27,10 @@ import { VertexShader } from './VertexShader';
|
|
|
27
27
|
import { FragmentShader } from './FragmentShader';
|
|
28
28
|
import { RgbColor } from '../../../helper/RgbColor';
|
|
29
29
|
import { PresetGradients } from '../../../controls/Gradient';
|
|
30
|
+
// Default prop values, referenced both by the IdwBlendLayerBase fallbacks and
|
|
31
|
+
// the IdwBlendLayer wrapper below.
|
|
32
|
+
var DEFAULT_MIN_ZOOM = 0;
|
|
33
|
+
var DEFAULT_MAX_ZOOM = 99;
|
|
30
34
|
var IdwBlendLayerBase = function (props) {
|
|
31
35
|
var map = useMap();
|
|
32
36
|
var discProgram = React.useRef(null);
|
|
@@ -92,11 +96,12 @@ var IdwBlendLayerBase = function (props) {
|
|
|
92
96
|
discBuffer.current = createPointsBuffer(gl, props.data);
|
|
93
97
|
};
|
|
94
98
|
var onRender = function (gl, matrix, zoom, width, height) {
|
|
99
|
+
var _a, _b;
|
|
95
100
|
// Render is called many times while the map is panned/zoomed.
|
|
96
101
|
// You cannot have access to the map though.
|
|
97
|
-
if (zoom < props.minZoom)
|
|
102
|
+
if (zoom < ((_a = props.minZoom) !== null && _a !== void 0 ? _a : DEFAULT_MIN_ZOOM))
|
|
98
103
|
return;
|
|
99
|
-
if (zoom > props.maxZoom)
|
|
104
|
+
if (zoom > ((_b = props.maxZoom) !== null && _b !== void 0 ? _b : DEFAULT_MAX_ZOOM))
|
|
100
105
|
return;
|
|
101
106
|
// Render is called many times while the map is panned/zoomed.
|
|
102
107
|
// You cannot have access to the map though.
|
|
@@ -115,14 +120,14 @@ var IdwBlendLayerBase = function (props) {
|
|
|
115
120
|
//gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
116
121
|
gl.drawArrays(gl.TRIANGLE_STRIP, 0, props.data.length * 4);
|
|
117
122
|
};
|
|
118
|
-
return (React.createElement(Layer, { id:
|
|
123
|
+
return (React.createElement(Layer, { id: "", type: "custom", beforeId: "overlay", key: time, onAdd: onAddLayer, render: function (gl, matrix) { return onRender(gl, matrix, map.current.getZoom(), map.current.getContainer().clientWidth, map.current.getContainer().clientHeight); } }));
|
|
119
124
|
};
|
|
120
125
|
/**
|
|
121
126
|
* An `IdwLayer` takes a data array of the form `{ latitude, longitude, value }`,
|
|
122
127
|
* and renders a colored surface using inverse distance weighting.
|
|
123
128
|
*/
|
|
124
129
|
var IdwBlendLayer = function (_a) {
|
|
125
|
-
var _b = _a.gradientStops, gradientStops = _b === void 0 ? PresetGradients.Blue : _b, _c = _a.minZoom, minZoom = _c === void 0 ?
|
|
130
|
+
var _b = _a.gradientStops, gradientStops = _b === void 0 ? PresetGradients.Blue : _b, _c = _a.minZoom, minZoom = _c === void 0 ? DEFAULT_MIN_ZOOM : _c, _d = _a.maxZoom, maxZoom = _d === void 0 ? DEFAULT_MAX_ZOOM : _d, _e = _a.maxDistance, maxDistance = _e === void 0 ? 0.0002 : _e, _f = _a.fadeFraction, fadeFraction = _f === void 0 ? 0.15 : _f, props = __rest(_a, ["gradientStops", "minZoom", "maxZoom", "maxDistance", "fadeFraction"]);
|
|
126
131
|
return React.createElement(IdwBlendLayerBase, __assign({ gradientStops: gradientStops, minZoom: minZoom, maxZoom: maxZoom, maxDistance: maxDistance, fadeFraction: fadeFraction }, props));
|
|
127
132
|
};
|
|
128
133
|
IdwBlendLayer.displayName = 'IdwBlendLayer';
|
|
@@ -31,7 +31,8 @@ interface IIdwLayerProps {
|
|
|
31
31
|
*/
|
|
32
32
|
maxDistance?: number;
|
|
33
33
|
/**
|
|
34
|
-
* Thickness of fading edge of blob
|
|
34
|
+
* Thickness of fading edge of blob, as a fraction of `maxDistance`,
|
|
35
|
+
* clamped to the range 0..1.
|
|
35
36
|
* @default 0.15
|
|
36
37
|
*/
|
|
37
38
|
fadeFraction?: number;
|