UNPKG

2.7 kBJavaScriptView Raw
1/*
2 * Copyright 2016 Palantir Technologies, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { __assign, __extends, __rest } from "tslib";
17import * as React from "react";
18import { AbstractPureComponent2, Intent } from "../../common";
19import * as Errors from "../../common/errors";
20import { DISPLAYNAME_PREFIX } from "../../common/props";
21import { MultiSlider } from "./multiSlider";
22var RangeIndex;
23(function (RangeIndex) {
24 RangeIndex[RangeIndex["START"] = 0] = "START";
25 RangeIndex[RangeIndex["END"] = 1] = "END";
26})(RangeIndex || (RangeIndex = {}));
27/**
28 * Range slider component.
29 *
30 * @see https://blueprintjs.com/docs/#core/components/sliders.range-slider
31 */
32var RangeSlider = /** @class */ (function (_super) {
33 __extends(RangeSlider, _super);
34 function RangeSlider() {
35 return _super !== null && _super.apply(this, arguments) || this;
36 }
37 RangeSlider.prototype.render = function () {
38 var _a = this.props, value = _a.value, handleHtmlProps = _a.handleHtmlProps, props = __rest(_a, ["value", "handleHtmlProps"]);
39 return (React.createElement(MultiSlider, __assign({}, props),
40 React.createElement(MultiSlider.Handle, { value: value[RangeIndex.START], type: "start", intentAfter: props.intent, htmlProps: handleHtmlProps === null || handleHtmlProps === void 0 ? void 0 : handleHtmlProps.start }),
41 React.createElement(MultiSlider.Handle, { value: value[RangeIndex.END], type: "end", htmlProps: handleHtmlProps === null || handleHtmlProps === void 0 ? void 0 : handleHtmlProps.end })));
42 };
43 RangeSlider.prototype.validateProps = function (props) {
44 var value = props.value;
45 if (value == null || value[RangeIndex.START] == null || value[RangeIndex.END] == null) {
46 throw new Error(Errors.RANGESLIDER_NULL_VALUE);
47 }
48 };
49 RangeSlider.defaultProps = __assign(__assign({}, MultiSlider.defaultSliderProps), { intent: Intent.PRIMARY, value: [0, 10] });
50 RangeSlider.displayName = "".concat(DISPLAYNAME_PREFIX, ".RangeSlider");
51 return RangeSlider;
52}(AbstractPureComponent2));
53export { RangeSlider };
54//# sourceMappingURL=rangeSlider.js.map
\No newline at end of file