@longline/aqua-ui 1.0.61 → 1.0.63
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
|
@@ -31,8 +31,8 @@ var SliderBase = function (props) {
|
|
|
31
31
|
// while the knob is being dragged. Upon release, this value is called back
|
|
32
32
|
// with onChange. Or continuously, if `immediate` is set.
|
|
33
33
|
var value = React.useRef(props.value);
|
|
34
|
-
// Reference:
|
|
35
|
-
var
|
|
34
|
+
// Reference: track body
|
|
35
|
+
var trackRef = React.useRef(null);
|
|
36
36
|
// Reference: track fill.
|
|
37
37
|
var trackFillRef = React.useRef(null);
|
|
38
38
|
// Reference: knob
|
|
@@ -98,9 +98,9 @@ var SliderBase = function (props) {
|
|
|
98
98
|
};
|
|
99
99
|
});
|
|
100
100
|
var handleMouseEvent = function (clientX) {
|
|
101
|
-
var rect =
|
|
101
|
+
var rect = trackRef.current.getBoundingClientRect();
|
|
102
102
|
// Calculate x-position in range 0..1:
|
|
103
|
-
var x = clamp((clientX - rect.left) /
|
|
103
|
+
var x = clamp((clientX - rect.left) / trackRef.current.offsetWidth, 0, 1);
|
|
104
104
|
// Derive value from x-position:
|
|
105
105
|
var v = Math.round((props.max - props.min) * x + props.min);
|
|
106
106
|
// Set new value. If props.immediate, then call onChange immediately.
|
|
@@ -154,8 +154,8 @@ var SliderBase = function (props) {
|
|
|
154
154
|
// Create a number of ticks and return them.
|
|
155
155
|
return Array(props.ticks).fill(0).map(function (t, idx) { return React.createElement(Tick, { key: idx }); });
|
|
156
156
|
};
|
|
157
|
-
return (React.createElement("div", { className: props.className,
|
|
158
|
-
React.createElement(Track,
|
|
157
|
+
return (React.createElement("div", { className: props.className, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, tabIndex: 0 },
|
|
158
|
+
React.createElement(Track, { ref: trackRef },
|
|
159
159
|
React.createElement(TrackFill, { "$disabled": props.disabled, "$error": props.error, ref: trackFillRef }),
|
|
160
160
|
props.ticks && renderTicks(),
|
|
161
161
|
React.createElement(KnobPosition, { ref: knobRef },
|
|
@@ -183,7 +183,7 @@ var SliderStyled = styled(SliderBase)(templateObject_21 || (templateObject_21 =
|
|
|
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
|
|
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
|
|
@@ -145,7 +145,7 @@ var GeocoderBase = function (props) {
|
|
|
145
145
|
return (React.createElement(MapControl, { x: props.x, y: props.y },
|
|
146
146
|
React.createElement("div", { className: props.className, onKeyDown: function (e) { return handleKeyDown(e); }, ref: wrapperRef },
|
|
147
147
|
React.createElement(GeocoderSelector, { placeholder: props.placeholder, searchIcon: props.searchIcon, value: q, onChange: handleChange }),
|
|
148
|
-
React.createElement(GeocoderList, null, features.map(function (f, idx) {
|
|
148
|
+
features.length > 0 && React.createElement(GeocoderList, null, features.map(function (f, idx) {
|
|
149
149
|
return React.createElement(GeocoderEntry, { key: idx, feature: f, selected: idx == selectedIndex, onClick: function () { return handleClick(f); } });
|
|
150
150
|
})))));
|
|
151
151
|
};
|