UNPKG

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