@longline/aqua-ui 1.0.50 → 1.0.52
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/inputs/Slider/Slider.js
CHANGED
|
@@ -177,13 +177,13 @@ var Knob = styled.div(templateObject_12 || (templateObject_12 = __makeTemplateOb
|
|
|
177
177
|
var KnobPosition = styled.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n position: absolute;\n left: 0;\n top: 0px;\n z-index: 0; // Required z-offset for Knob::before\n"], ["\n position: absolute;\n left: 0;\n top: 0px;\n z-index: 0; // Required z-offset for Knob::before\n"])));
|
|
178
178
|
var TrackFill = styled.div(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 50%;\n background-color: ", ";\n ", "\n ", " \n border-radius: 2px;\n"], ["\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 50%;\n background-color: ", ";\n ", "\n ", " \n border-radius: 2px;\n"])), function (p) { return p.theme.colors.primary[1]; }, function (p) { return p.$error && css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["background-color: ", ";"], ["background-color: ", ";"])), p.theme.colors.negative); }, function (p) { return p.$disabled && css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["background-color: ", ";"], ["background-color: ", ";"])), p.theme.colors.neutral[30]); });
|
|
179
179
|
var Track = styled.div(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n position: relative;\n height: 4px;\n border-radius: 2px;\n box-sizing: border-box;\n background-color: ", ";\n\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n padding-top: 1px;\n padding-left: 2px;\n padding-right: 2px;\n"], ["\n position: relative;\n height: 4px;\n border-radius: 2px;\n box-sizing: border-box;\n background-color: ", ";\n\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n padding-top: 1px;\n padding-left: 2px;\n padding-right: 2px;\n"])), function (p) { return p.theme.colors.primary[5]; });
|
|
180
|
-
var SliderStyled = styled(SliderBase)(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n position: relative;\n min-width: ", ";\n box-sizing: border-box;\n // Padding above and below to capture mouse-down\n padding-top:
|
|
180
|
+
var SliderStyled = styled(SliderBase)(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n position: relative;\n min-width: ", ";\n box-sizing: border-box;\n // Padding above and below to capture mouse-down\n padding-top: 52px;\n padding-bottom: 14px;\n ", "\n cursor: ", ";\n user-select: none;\n outline: none;\n ", "\n\n ", "\n"], ["\n position: relative;\n min-width: ", ";\n box-sizing: border-box;\n // Padding above and below to capture mouse-down\n padding-top: 52px;\n padding-bottom: 14px;\n ", "\n cursor: ", ";\n user-select: none;\n outline: none;\n ", "\n\n ", "\n"
|
|
181
181
|
/**
|
|
182
182
|
* Sliders allow users to view and select a value (or range) along a track.
|
|
183
183
|
* They're ideal for adjusting settings such as volume and brightness, or for
|
|
184
184
|
* applying image filters.
|
|
185
185
|
*/
|
|
186
|
-
])), function (p) { return p.fluid == true ? '100%' : '200px'; }, function (p) { return p.padded && css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n padding-left:
|
|
186
|
+
])), function (p) { return p.fluid == true ? '100%' : '200px'; }, function (p) { return p.padded && css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n padding-left: 20px;\n padding-right: 20px;\n "], ["\n padding-left: 20px;\n padding-right: 20px;\n "]))); }, function (p) { return p.disabled ? 'auto' : 'pointer'; }, function (p) { return p.disabled && css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n pointer-events: none;\n "], ["\n pointer-events: none;\n "]))); }, function (p) { return !p.disabled && css(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n // Focus ring:\n &:focus ", ":before {\n animation: ", " 2s linear infinite;\n }\n\n &:hover ", ":before {\n animation: none;\n opacity: 0.7;\n } \n\n // Active focus ring:\n &:active ", ":before {\n animation: none;\n opacity: 1;\n }\n "], ["\n // Focus ring:\n &:focus ", ":before {\n animation: ", " 2s linear infinite;\n }\n\n &:hover ", ":before {\n animation: none;\n opacity: 0.7;\n } \n\n // Active focus ring:\n &:active ", ":before {\n animation: none;\n opacity: 1;\n }\n "])), Knob, Pulse, Knob, Knob); });
|
|
187
187
|
/**
|
|
188
188
|
* Sliders allow users to view and select a value (or range) along a track.
|
|
189
189
|
* They're ideal for adjusting settings such as volume and brightness, or for
|
|
@@ -17,35 +17,16 @@ interface IProps {
|
|
|
17
17
|
* correctly.
|
|
18
18
|
*/
|
|
19
19
|
idField: string;
|
|
20
|
+
/**
|
|
21
|
+
* Minimum zoom level at which to show markers.
|
|
22
|
+
* @default 0
|
|
23
|
+
*/
|
|
24
|
+
minZoom?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum zoom level at which to show markers.
|
|
27
|
+
* @default 99
|
|
28
|
+
*/
|
|
29
|
+
maxZoom?: number;
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
* The `HtmlMarkerLayer` manages HTML markers on a map. HTML markers are far slower
|
|
23
|
-
* than OpenGL layers, but much more flexible: with SVG, any shape of marker can
|
|
24
|
-
* be designed, and the markers can easily be made responsive to hover.
|
|
25
|
-
*
|
|
26
|
-
* The `HtmlMarkerLayer` keeps an internal cache, creating and rendering markers only
|
|
27
|
-
* when they are visible in the map viewport. This is a suitable solution for clusters
|
|
28
|
-
* (where by definition there are never very many icons in the viewport), or when
|
|
29
|
-
* there are simply not _that_ many markers: up to a few hundred in the viewport is the
|
|
30
|
-
* upper limit.
|
|
31
|
-
*
|
|
32
|
-
* The `HtmlMarkerLayer` must be placed inside a GeoJSON `Source`. In that source,
|
|
33
|
-
* each feature must have a unique ID (passed to this layer as the `idField`), which
|
|
34
|
-
* is used to tell features apart. When features are refreshed, it is imported that
|
|
35
|
-
* they all get new IDs so that old markers get removed correctly.
|
|
36
|
-
*
|
|
37
|
-
* The `HtmlMarkerLayer` component takes a _function child_. This function accepts
|
|
38
|
-
* a `props` object, which will be the properties from each GeoJSON feature for which
|
|
39
|
-
* a marker is rendered.
|
|
40
|
-
*
|
|
41
|
-
* ```tsx
|
|
42
|
-
* // featureCollection has a property "id" with unique values
|
|
43
|
-
* <Source id="mysource" type="geojson" data={featureCollection}>
|
|
44
|
-
* <HtmlMarkerLayer sourceId="mysource" idField="id">
|
|
45
|
-
* {(markerProps) => <MyMarkerComponent color="gold" radius={45} {...markerProps}/>
|
|
46
|
-
* </HtmlMarkerLayer>
|
|
47
|
-
* </Source>
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
declare const HtmlMarkerLayer: (props: IProps) => React.JSX.Element;
|
|
31
|
+
declare const HtmlMarkerLayer: ({ minZoom, maxZoom, ...props }: IProps) => React.JSX.Element;
|
|
51
32
|
export { HtmlMarkerLayer };
|
|
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
12
23
|
import * as React from 'react';
|
|
13
24
|
import * as ReactDOM from 'react-dom/client';
|
|
14
25
|
import { Layer, useMap } from 'react-map-gl';
|
|
@@ -42,13 +53,15 @@ import { Marker } from 'mapbox-gl';
|
|
|
42
53
|
* </Source>
|
|
43
54
|
* ```
|
|
44
55
|
*/
|
|
45
|
-
var
|
|
56
|
+
var HtmlMarkerLayerBase = function (props) {
|
|
46
57
|
var map = useMap().current;
|
|
47
58
|
// Can't call props.children directly from map render event handler.
|
|
48
59
|
// Make a ref copy:
|
|
49
60
|
var children = React.useRef(props.children);
|
|
50
61
|
var markers = React.useRef({});
|
|
51
62
|
var markersOnScreen = React.useRef({});
|
|
63
|
+
var minZoom = React.useRef(props.minZoom);
|
|
64
|
+
var maxZoom = React.useRef(props.maxZoom);
|
|
52
65
|
// Add render event to map, and remove it when this component
|
|
53
66
|
// is unmounted. Whenever the map renders, we must refresh
|
|
54
67
|
// all markers.
|
|
@@ -60,6 +73,8 @@ var HtmlMarkerLayer = function (props) {
|
|
|
60
73
|
// Also clear map and repaint it, because child component props may
|
|
61
74
|
// have changed.
|
|
62
75
|
React.useEffect(function () {
|
|
76
|
+
minZoom.current = props.minZoom;
|
|
77
|
+
maxZoom.current = props.maxZoom;
|
|
63
78
|
children.current = props.children;
|
|
64
79
|
for (var id in markersOnScreen.current) {
|
|
65
80
|
markersOnScreen.current[id].remove();
|
|
@@ -67,7 +82,7 @@ var HtmlMarkerLayer = function (props) {
|
|
|
67
82
|
markers.current = {};
|
|
68
83
|
markersOnScreen.current = {};
|
|
69
84
|
map.triggerRepaint();
|
|
70
|
-
}, [props.children]);
|
|
85
|
+
}, [props.children, props.minZoom, props.maxZoom]);
|
|
71
86
|
// When component is unmounted, remove all its markers from the map.
|
|
72
87
|
React.useEffect(function () {
|
|
73
88
|
return function () {
|
|
@@ -105,11 +120,11 @@ var HtmlMarkerLayer = function (props) {
|
|
|
105
120
|
// Retrieve all features that are currently rendered on a visible map tile,
|
|
106
121
|
// thus excluding everything that's off-screen, for speed. The use of
|
|
107
122
|
// querySourceFeatures requires that at least one Layer exists, which is
|
|
108
|
-
// why we have layer that renders only invisible circles.
|
|
123
|
+
// why we have a layer that renders only invisible circles.
|
|
109
124
|
// querySourceFeatures often results duplicates due to buffering.
|
|
110
125
|
// Remove these duplicates by looking at each feature's unique ID.
|
|
111
126
|
var seen = {};
|
|
112
|
-
var features = map.querySourceFeatures(props.sourceId).filter(function (f) {
|
|
127
|
+
var features = (map.getZoom() < minZoom.current || map.getZoom() > maxZoom.current) ? [] : map.querySourceFeatures(props.sourceId).filter(function (f) {
|
|
113
128
|
var id = f.properties[props.idField];
|
|
114
129
|
return seen.hasOwnProperty(id) ? false : (seen[id] = true);
|
|
115
130
|
});
|
|
@@ -148,4 +163,8 @@ var HtmlMarkerLayer = function (props) {
|
|
|
148
163
|
// though it's empty.
|
|
149
164
|
return (React.createElement(Layer, { source: props.sourceId, type: "circle", paint: { "circle-radius": 0 } }));
|
|
150
165
|
};
|
|
166
|
+
var HtmlMarkerLayer = function (_a) {
|
|
167
|
+
var _b = _a.minZoom, minZoom = _b === void 0 ? 0 : _b, _c = _a.maxZoom, maxZoom = _c === void 0 ? 99 : _c, props = __rest(_a, ["minZoom", "maxZoom"]);
|
|
168
|
+
return React.createElement(HtmlMarkerLayerBase, __assign({ minZoom: minZoom, maxZoom: maxZoom }, props));
|
|
169
|
+
};
|
|
151
170
|
export { HtmlMarkerLayer };
|