1 | import * as React from "react";
|
2 | import { AbstractPureComponent, Intent, IntentProps, Props } from "../../common";
|
3 | import { HandleProps } from "./handleProps";
|
4 | export interface SliderBaseProps extends Props, IntentProps {
|
5 | children?: React.ReactNode;
|
6 | /**
|
7 | * Whether the slider is non-interactive.
|
8 | *
|
9 | * @default false
|
10 | */
|
11 | disabled?: boolean;
|
12 | /**
|
13 | * Increment between successive labels. Must be greater than zero.
|
14 | *
|
15 | * @default inferred (if labelStepSize is undefined)
|
16 | */
|
17 | labelStepSize?: number;
|
18 | /**
|
19 | * Array of specific values for the label placement. This prop is mutually exclusive with
|
20 | * `labelStepSize`.
|
21 | */
|
22 | labelValues?: readonly number[];
|
23 | /**
|
24 | * Number of decimal places to use when rendering label value. Default value is the number of
|
25 | * decimals used in the `stepSize` prop. This prop has _no effect_ if you supply a custom
|
26 | * `labelRenderer` callback.
|
27 | *
|
28 | * @default inferred from stepSize
|
29 | */
|
30 | labelPrecision?: number;
|
31 | /**
|
32 | * Maximum value of the slider. Value must be a finite number.
|
33 | *
|
34 | * @default 10
|
35 | */
|
36 | max?: number;
|
37 | /**
|
38 | * Minimum value of the slider. Value must be a finite number.
|
39 | *
|
40 | * @default 0
|
41 | */
|
42 | min?: number;
|
43 | /**
|
44 | * Whether a solid bar should be rendered on the track between current and initial values,
|
45 | * or between handles for `RangeSlider`.
|
46 | *
|
47 | * @default true
|
48 | */
|
49 | showTrackFill?: boolean;
|
50 | /**
|
51 | * Increment between successive values; amount by which the handle moves. Must be greater than zero.
|
52 | *
|
53 | * @default 1
|
54 | */
|
55 | stepSize?: number;
|
56 | /**
|
57 | * Callback to render a single label. Useful for formatting numbers as currency or percentages.
|
58 | * If `true`, labels will use number value formatted to `labelPrecision` decimal places.
|
59 | * If `false`, labels will not be shown.
|
60 | *
|
61 | * The callback is provided a numeric value and optional rendering options, which include:
|
62 | * - isHandleTooltip: whether this label is being rendered within a handle tooltip
|
63 | *
|
64 | * @default true
|
65 | */
|
66 | labelRenderer?: boolean | ((value: number, opts?: {
|
67 | isHandleTooltip: boolean;
|
68 | }) => string | JSX.Element);
|
69 | /**
|
70 | * Whether to show the slider in a vertical orientation.
|
71 | *
|
72 | * @default false
|
73 | */
|
74 | vertical?: boolean;
|
75 | }
|
76 | export interface MultiSliderProps extends SliderBaseProps {
|
77 | /** Default intent of a track segment, used only if no handle specifies `intentBefore/After`. */
|
78 | defaultTrackIntent?: Intent;
|
79 | /** Callback invoked when a handle value changes. Receives handle values in sorted order. */
|
80 | onChange?(values: number[]): void;
|
81 | /** Callback invoked when a handle is released. Receives handle values in sorted order. */
|
82 | onRelease?(values: number[]): void;
|
83 | }
|
84 | export interface SliderState {
|
85 | labelPrecision: number;
|
86 | /** the client size, in pixels, of one tick */
|
87 | tickSize: number;
|
88 | /** the size of one tick as a ratio of the component's client size */
|
89 | tickSizeRatio: number;
|
90 | }
|
91 | /**
|
92 | * Multi slider component.
|
93 | *
|
94 | * @see https://blueprintjs.com/docs/#core/components/sliders.multi-slider
|
95 | */
|
96 | export declare class MultiSlider extends AbstractPureComponent<MultiSliderProps, SliderState> {
|
97 | static defaultSliderProps: SliderBaseProps;
|
98 | static defaultProps: MultiSliderProps;
|
99 | static displayName: string;
|
100 | static Handle: React.FC<HandleProps>;
|
101 | static getDerivedStateFromProps(props: MultiSliderProps): {
|
102 | labelPrecision: number;
|
103 | };
|
104 | private static getLabelPrecision;
|
105 | state: SliderState;
|
106 | private handleElements;
|
107 | private trackElement;
|
108 | getSnapshotBeforeUpdate(prevProps: MultiSliderProps): null;
|
109 | render(): JSX.Element;
|
110 | componentDidMount(): void;
|
111 | componentDidUpdate(prevProps: MultiSliderProps, prevState: SliderState): void;
|
112 | protected validateProps(props: React.PropsWithChildren<MultiSliderProps>): void;
|
113 | private formatLabel;
|
114 | private renderLabels;
|
115 | private renderTracks;
|
116 | private renderTrackFill;
|
117 | private renderHandles;
|
118 | private addHandleRef;
|
119 | private maybeHandleTrackClick;
|
120 | private maybeHandleTrackTouch;
|
121 | private canHandleTrackEvent;
|
122 | private nearestHandleForValue;
|
123 | private getHandlerForIndex;
|
124 | private getNewHandleValues;
|
125 | private findFirstLockedHandleIndex;
|
126 | private handleChange;
|
127 | private handleRelease;
|
128 | private getLabelValues;
|
129 | private getOffsetRatio;
|
130 | private getTrackIntent;
|
131 | private updateTickSize;
|
132 | }
|