UNPKG

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