UNPKG

2.66 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 { AbstractPureComponent, DISPLAYNAME_PREFIX, Intent } from "../../common";
19import * as Errors from "../../common/errors";
20import { MultiSlider } from "./multiSlider";
21var RangeIndex;
22(function (RangeIndex) {
23 RangeIndex[RangeIndex["START"] = 0] = "START";
24 RangeIndex[RangeIndex["END"] = 1] = "END";
25})(RangeIndex || (RangeIndex = {}));
26/**
27 * Range slider component.
28 *
29 * @see https://blueprintjs.com/docs/#core/components/sliders.range-slider
30 */
31var RangeSlider = /** @class */ (function (_super) {
32 __extends(RangeSlider, _super);
33 function RangeSlider() {
34 return _super !== null && _super.apply(this, arguments) || this;
35 }
36 RangeSlider.prototype.render = function () {
37 var _a = this.props, value = _a.value, handleHtmlProps = _a.handleHtmlProps, props = __rest(_a, ["value", "handleHtmlProps"]);
38 return (React.createElement(MultiSlider, __assign({}, props),
39 React.createElement(MultiSlider.Handle, { value: value[RangeIndex.START], type: "start", intentAfter: props.intent, htmlProps: handleHtmlProps === null || handleHtmlProps === void 0 ? void 0 : handleHtmlProps.start }),
40 React.createElement(MultiSlider.Handle, { value: value[RangeIndex.END], type: "end", htmlProps: handleHtmlProps === null || handleHtmlProps === void 0 ? void 0 : handleHtmlProps.end })));
41 };
42 RangeSlider.prototype.validateProps = function (props) {
43 var value = props.value;
44 if (value == null || value[RangeIndex.START] == null || value[RangeIndex.END] == null) {
45 throw new Error(Errors.RANGESLIDER_NULL_VALUE);
46 }
47 };
48 RangeSlider.defaultProps = __assign(__assign({}, MultiSlider.defaultSliderProps), { intent: Intent.PRIMARY, value: [0, 10] });
49 RangeSlider.displayName = "".concat(DISPLAYNAME_PREFIX, ".RangeSlider");
50 return RangeSlider;
51}(AbstractPureComponent));
52export { RangeSlider };
53//# sourceMappingURL=rangeSlider.js.map
\No newline at end of file