This repository was archived by the owner on Aug 29, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathSlider.react.js
More file actions
237 lines (206 loc) · 6.54 KB
/
Slider.react.js
File metadata and controls
237 lines (206 loc) · 6.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
import React, {Component, lazy, Suspense} from 'react';
import PropTypes from 'prop-types';
import slider from '../utils/LazyLoader/slider';
const RealSlider = lazy(slider);
/**
* A slider component with a single handle.
*/
export default class Slider extends Component {
render() {
return (
<Suspense fallback={null}>
<RealSlider {...this.props} />
</Suspense>
);
}
}
Slider.propTypes = {
/**
* The ID of this component, used to identify dash components
* in callbacks. The ID needs to be unique across all of the
* components in an app.
*/
id: PropTypes.string,
/**
* Marks on the slider.
* The key determines the position (a number),
* and the value determines what will show.
* If you want to set the style of a specific mark point,
* the value should be an object which
* contains style and label properties.
*/
marks: PropTypes.objectOf(
PropTypes.oneOfType([
PropTypes.string,
PropTypes.exact({
label: PropTypes.string,
style: PropTypes.object,
}),
])
),
/**
* The value of the input
*/
value: PropTypes.number,
/**
* The value of the input during a drag
*/
drag_value: PropTypes.number,
/**
* Additional CSS class for the root DOM node
*/
className: PropTypes.string,
/**
* If true, the handles can't be moved.
*/
disabled: PropTypes.bool,
/**
* When the step value is greater than 1,
* you can set the dots to true if you want to
* render the slider with dots.
*/
dots: PropTypes.bool,
/**
* If the value is true, it means a continuous
* value is included. Otherwise, it is an independent value.
*/
included: PropTypes.bool,
/**
* Minimum allowed value of the slider
*/
min: PropTypes.number,
/**
* Maximum allowed value of the slider
*/
max: PropTypes.number,
/**
* Configuration for tooltips describing the current slider value
*/
tooltip: PropTypes.exact({
/**
* Determines whether tooltips should always be visible
* (as opposed to the default, visible on hover)
*/
always_visible: PropTypes.bool,
/**
* Determines the placement of tooltips
* See https://github.com/react-component/tooltip#api
* top/bottom{*} sets the _origin_ of the tooltip, so e.g. `topLeft`
* will in reality appear to be on the top right of the handle
*/
placement: PropTypes.oneOf([
'left',
'right',
'top',
'bottom',
'topLeft',
'topRight',
'bottomLeft',
'bottomRight',
]),
}),
/**
* Value by which increments or decrements are made.
*/
step: PropTypes.number,
/**
* If true, display an Input component whose value is synced with the Slider's value.
*/
synced_input: PropTypes.bool,
/**
* The classname to be given to the synced Input component.
*/
synced_input_class_name: PropTypes.string,
/**
* The CSS to be applied to the class of the input (div).
*/
synced_input_style: PropTypes.object,
/**
* The id to be applied to the input (div). Default is "syncedInput".
*/
synced_input_id: PropTypes.string,
/**
* The CSS to be applied to the class of the slider (div).
*/
style: PropTypes.object,
/**
* The amount of time the synced Input should wait before passing along state changes without a change of focus or the user pressing Enter. In milliseconds.
*/
synced_input_debounce_time: PropTypes.number,
/**
* If true, the slider will be vertical
*/
vertical: PropTypes.bool,
/**
* The height, in px, of the slider if it is vertical.
*/
verticalHeight: PropTypes.number,
/**
* Determines when the component should update its `value`
* property. If `mouseup` (the default) then the slider
* will only trigger its value when the user has finished
* dragging the slider. If `drag`, then the slider will
* update its value continuously as it is being dragged.
* If you want different actions during and after drag,
* leave `updatemode` as `mouseup` and use `drag_value`
* for the continuously updating value.
*/
updatemode: PropTypes.oneOf(['mouseup', 'drag']),
/**
* Dash-assigned callback that gets fired when the value or drag_value changes.
*/
setProps: PropTypes.func,
/**
* Object that holds the loading state object coming from dash-renderer
*/
loading_state: PropTypes.shape({
/**
* Determines if the component is loading or not
*/
is_loading: PropTypes.bool,
/**
* Holds which property is loading
*/
prop_name: PropTypes.string,
/**
* Holds the name of the component that is loading
*/
component_name: PropTypes.string,
}),
/**
* Used to allow user interactions in this component to be persisted when
* the component - or the page - is refreshed. If `persisted` is truthy and
* hasn't changed from its previous value, a `value` that the user has
* changed while using the app will keep that change, as long as
* the new `value` also matches what was given originally.
* Used in conjunction with `persistence_type`.
*/
persistence: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string,
PropTypes.number,
]),
/**
* Properties whose user interactions will persist after refreshing the
* component or the page. Since only `value` is allowed this prop can
* normally be ignored.
*/
persisted_props: PropTypes.arrayOf(PropTypes.oneOf(['value'])),
/**
* Where persisted user changes will be stored:
* memory: only kept in memory, reset on page refresh.
* local: window.localStorage, data is kept after the browser quit.
* session: window.sessionStorage, data is cleared once the browser quit.
*/
persistence_type: PropTypes.oneOf(['local', 'session', 'memory']),
};
Slider.defaultProps = {
updatemode: 'mouseup',
persisted_props: ['value'],
persistence_type: 'local',
verticalHeight: 400,
synced_input_debounce_time: 450,
synced_input_id: 'syncedInput',
};
export const propTypes = Slider.propTypes;
export const defaultProps = Slider.defaultProps;