@refinitiv-ui/elements 7.9.0 → 7.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,508 @@
1
+ import { JSXInterface } from '../../jsx';
2
+ import { CSSResultGroup, FormFieldElement, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
3
+ import '@refinitiv-ui/phrasebook/locale/en/slider.js';
4
+ import { TranslatePromise } from '@refinitiv-ui/translate';
5
+ import '../../number-field/index.js';
6
+ /**
7
+ * Allows users to make selections from a range of values
8
+ *
9
+ * @attr {string} value - Value of slider. Not applicable in range mode.
10
+ * @prop {string} [value="0"] - Value of slider. Not applicable in range mode.
11
+ *
12
+ * @attr {boolean} readonly - Set readonly state
13
+ * @prop {boolean} [readonly=false] - Set readonly state
14
+ *
15
+ * @attr {boolean} disabled - Set disabled state
16
+ * @prop {boolean} [disabled=false] - Set disabled state
17
+ *
18
+ * @fires value-changed - Fired when the user commits a value change. The event is not triggered if `value` property is changed programmatically.
19
+ * @fires from-changed - Fired when the user changes from's value. The event is not triggered if `from` property is changed programmatically.
20
+ * @fires to-changed - Fired when the user changes to's value. The event is not triggered if `to` property is changed programmatically.
21
+ * @fires input - Fired with the value of the input in `e.detail.value` like another custom events when the user inputs a value by interacting with the slider or updating its input field.
22
+ * @fires from-input - Fired when the user inputs from's value by interacting with the slider or updating its input field.
23
+ * @fires to-input - Fired when the user inputs to's value by interacting with the slider or updating its input field.
24
+ */
25
+ export declare class Slider extends FormFieldElement {
26
+ /**
27
+ * Element version number
28
+ * @returns version number
29
+ */
30
+ static get version(): string;
31
+ /**
32
+ * Define styles in a tagged template literal, using the css tag function.
33
+ * @returns CSS template
34
+ */
35
+ static get styles(): CSSResultGroup;
36
+ /**
37
+ * Whether if the thumb is being drag
38
+ */
39
+ private dragging;
40
+ private valuePrevious;
41
+ private fromPrevious;
42
+ private toPrevious;
43
+ private valuePreviousInput;
44
+ private fromPreviousInput;
45
+ private toPreviousInput;
46
+ /** Aria label for 'to' and 'from' value thumb, resolved based on locale. */
47
+ private toAriaLabel;
48
+ private fromAriaLabel;
49
+ /**
50
+ * Specified size of increment or decrement jump between value.
51
+ */
52
+ step: string;
53
+ /**
54
+ * Set minimum value of slider.
55
+ */
56
+ min: string;
57
+ /**
58
+ * Set maximum value of slider.
59
+ */
60
+ max: string;
61
+ /**
62
+ * Uses with `range`. Low value of slider in range mode.
63
+ */
64
+ from: string;
65
+ /**
66
+ * Uses with `range`. High value of slider in range mode
67
+ */
68
+ to: string;
69
+ /**
70
+ * Set slider appearances to show pin mode.
71
+ * @ignore
72
+ * NOTE: Pin isn't applicable in Halo. Hide this from document
73
+ */
74
+ pin: boolean;
75
+ /**
76
+ * Set slider to range mode. Instead of a single value, slider will provide `from` and `to`.
77
+ */
78
+ range: boolean;
79
+ /**
80
+ * Show steps marker on slider.
81
+ */
82
+ showSteps: boolean;
83
+ /**
84
+ * Show input number field.
85
+ */
86
+ showInputField: 'readonly' | '' | null;
87
+ /**
88
+ * Uses with `range`. Set minimum allowance value (distance) between `from` and `to`.
89
+ */
90
+ minRange: string;
91
+ /**
92
+ * Slider internal translation strings
93
+ */
94
+ protected labelTPromise: TranslatePromise;
95
+ /**
96
+ * Converts value from string to number for calculations
97
+ * @returns value of input as a number
98
+ */
99
+ private get valueNumber();
100
+ /**
101
+ * Converts min value from string to number for calculations
102
+ * @returns minimum value of slider as a number
103
+ */
104
+ private get minNumber();
105
+ /**
106
+ * Converts max value from string to number for calculations
107
+ * @returns maximum value of slider as a number
108
+ */
109
+ private get maxNumber();
110
+ /**
111
+ * Converts step value from string to number for calculations
112
+ * @returns step value of slider as a number
113
+ */
114
+ private get stepNumber();
115
+ /**
116
+ * Compute and normalise step value for calculations
117
+ * @returns step value that should be inside the min / max boundary
118
+ */
119
+ private get stepRange();
120
+ /**
121
+ * Converts from value from string to number for calculations
122
+ * @returns from value of slider as a number
123
+ */
124
+ private get fromNumber();
125
+ /**
126
+ * Converts to value from string to number for calculations
127
+ * @returns to value of slider as a number
128
+ */
129
+ private get toNumber();
130
+ /**
131
+ * Converts min-range from string to number for calculations
132
+ * @returns min-range of input as a number
133
+ */
134
+ private get minRangeNumber();
135
+ /**
136
+ * Number of decimal places used for displaying value
137
+ * Based on step or min decimal places
138
+ */
139
+ private get decimalPlace();
140
+ /**
141
+ * Return hide/show input field state
142
+ * @returns true if showInputField value is exist
143
+ */
144
+ private get isShowInputField();
145
+ /**
146
+ * Slider element reference
147
+ */
148
+ private sliderRef;
149
+ /**
150
+ * Slider's track reference
151
+ */
152
+ private trackRef;
153
+ /**
154
+ * From value thumb reference, rendered only in range mode
155
+ */
156
+ private fromThumbRef;
157
+ /**
158
+ * To value thumb reference, rendered only in range mode
159
+ */
160
+ private toThumbRef;
161
+ /**
162
+ * Value thumb reference
163
+ */
164
+ private valueThumbRef;
165
+ /**
166
+ * Number field for slider value
167
+ */
168
+ private valueInput;
169
+ /**
170
+ * Number field for from value in range mode
171
+ */
172
+ private fromInput;
173
+ /**
174
+ * Number field for to value in range mode
175
+ */
176
+ private toInput;
177
+ /**
178
+ * Current focused thumb
179
+ */
180
+ private activeThumb;
181
+ /**
182
+ * Thumb that may involves data changes
183
+ */
184
+ private changedThumb;
185
+ constructor();
186
+ /**
187
+ * On first updated lifecycle
188
+ * @param changedProperties changed properties
189
+ * @returns {void}
190
+ */
191
+ protected firstUpdated(changedProperties: PropertyValues): void;
192
+ /**
193
+ * Perform asynchronous update
194
+ * @returns promise
195
+ */
196
+ protected performUpdate(): Promise<void>;
197
+ /**
198
+ * Gets Slider Marker elements from the slot.
199
+ * @returns Array of Slider Marker elements.
200
+ */
201
+ private getMarkerElements;
202
+ /**
203
+ * Gets the active marker based on the provided marker value.
204
+ * @param value - The marker value.
205
+ * @returns The active marker element.
206
+ */
207
+ private getActiveMarker;
208
+ /**
209
+ * Finds the closest ancestor ef-slider-marker in the DOM tree.
210
+ * @param startingElement The HTML element to start searching from.
211
+ * @returns The found marker, or null if not found.
212
+ */
213
+ private findClosestMarker;
214
+ /**
215
+ * Handles the slot change event by updating the position of markers.
216
+ * @returns {void}
217
+ */
218
+ private onSlotChange;
219
+ /**
220
+ * @ignore
221
+ * On willUpdate lifecycle
222
+ * @param changedProperties changed properties
223
+ * @returns {void}
224
+ */
225
+ willUpdate(changedProperties: PropertyValues): void;
226
+ /**
227
+ * On updated lifecycle
228
+ * @param changedProperties changed properties
229
+ * @returns {void}
230
+ */
231
+ protected updated(changedProperties: PropertyValues): void;
232
+ /**
233
+ * Update the ARIA value text for a given thumb.
234
+ *
235
+ * @param thumbRef - The reference to the thumb element.
236
+ * @param markerValue - The value associated with the marker.
237
+ * @returns {void}
238
+ */
239
+ private updateAriaValueText;
240
+ /**
241
+ * Show Warning a warning message invalid property
242
+ * @param propName value for checking
243
+ * @returns {void}
244
+ */
245
+ private showWarningInvalidProperty;
246
+ /**
247
+ * Initialises slider value properties
248
+ * @returns {void}
249
+ */
250
+ private prepareValues;
251
+ /**
252
+ * Add event listeners to thumbs depending on mode
253
+ * @returns {void}
254
+ */
255
+ private prepareThumbs;
256
+ /**
257
+ * Add or remove event listener on slider track depending on slider disabled and readonly state
258
+ * @returns {void}
259
+ */
260
+ private prepareSliderTrack;
261
+ /**
262
+ * Get slider data name from keyboard event target
263
+ * @param target target element
264
+ * @returns Slider data name
265
+ */
266
+ private getThumbName;
267
+ /**
268
+ * Handles key down event on thumbs
269
+ * @param event Keyboard event
270
+ * @returns {void}
271
+ */
272
+ private onKeyDown;
273
+ /**
274
+ * Set thumb to minimum value possible
275
+ * @param data type of data to change
276
+ * @returns {void}
277
+ */
278
+ private onApplyMin;
279
+ /**
280
+ * Set thumb to maximum value possible
281
+ * @param data type of data to change
282
+ * @returns {void}
283
+ */
284
+ private onApplyMax;
285
+ /**
286
+ * Increase or decrease value depending on direction
287
+ * Then fires value change event
288
+ * @param direction Up or Down
289
+ * @param data type of data to change
290
+ * @returns {void}
291
+ */
292
+ private onApplyStep;
293
+ /**
294
+ * Calculate thumb position based on value and multiplier
295
+ * @param value decimal fraction value
296
+ * @param multiplier defaults to 100
297
+ * @returns thumb position as a fraction of 100
298
+ */
299
+ private calculatePosition;
300
+ /**
301
+ * Adds active attribute used in styling
302
+ * @param event focus event
303
+ * @returns {void}
304
+ */
305
+ private onThumbFocus;
306
+ /**
307
+ * Removes active attribute used in styling
308
+ * @param event focus event
309
+ * @returns {void}
310
+ */
311
+ private onThumbBlur;
312
+ /**
313
+ * On number-field blur
314
+ * @param event focus event
315
+ * @returns {void}
316
+ */
317
+ private onNumberFieldBlur;
318
+ /**
319
+ * On number-field input
320
+ * @param event input event
321
+ * @returns {void}
322
+ */
323
+ private onNumberFieldInput;
324
+ /**
325
+ * On number-field keydown
326
+ * @param event keyboard event
327
+ * @returns {void}
328
+ */
329
+ private onNumberFieldKeyDown;
330
+ /**
331
+ * Update notify property by input name attribute
332
+ * @param name name input attribute
333
+ * @param value input value
334
+ * @returns {void}
335
+ */
336
+ private updateNotifyProperty;
337
+ /**
338
+ * Dispatch data {value, from, to} changed event
339
+ * @returns {void}
340
+ */
341
+ private dispatchDataChangedEvent;
342
+ /**
343
+ * Dispatch data {input, from-input, to-input} changing event
344
+ * @returns {void}
345
+ */
346
+ private dispatchDataInputEvent;
347
+ /**
348
+ * Start dragging event on slider
349
+ * @param event event dragstart
350
+ * @returns {void}
351
+ */
352
+ private onDragStart;
353
+ /**
354
+ * Get mouse position in percentage value
355
+ * @param event event mousemove and touchmove
356
+ * @returns mouse position by percentage
357
+ */
358
+ private getMousePosition;
359
+ /**
360
+ * Dragging after on dragging start event
361
+ * @param event event mousemove and touchmove
362
+ * @returns {void}
363
+ */
364
+ private onDrag;
365
+ /**
366
+ * Saves changed data into correct field
367
+ * @param value value of changed data
368
+ * @returns {void}
369
+ */
370
+ private persistChangedData;
371
+ /**
372
+ * Validate and return FROM value within available range
373
+ * @param value from value
374
+ * @returns validated from value
375
+ */
376
+ private validateFrom;
377
+ /**
378
+ * Validate and return TO value within available range
379
+ * @param value to value
380
+ * @returns validated to value.
381
+ */
382
+ private validateTo;
383
+ /**
384
+ * Validate number field from changed thumb
385
+ * @returns {void}
386
+ */
387
+ private validateNumberField;
388
+ /**
389
+ * Calculate the nearest possible step value depending on step interval
390
+ * @param thumbPosition current thumb position in fraction
391
+ * @returns nearest available slider step in fraction
392
+ */
393
+ private getNearestPossibleValue;
394
+ /**
395
+ * Get slider value from thumb position
396
+ * @param position thumb position
397
+ * @returns calculated value
398
+ */
399
+ private getValueFromPosition;
400
+ /**
401
+ * Format value to display in both integer and fraction cases
402
+ * @param value value before use display
403
+ * @returns formatted value
404
+ */
405
+ private format;
406
+ /**
407
+ * End dragging event and remove dragging event
408
+ * @param event event mouseup and touchmove
409
+ * @returns {void}
410
+ */
411
+ private onDragEnd;
412
+ /**
413
+ * Value observer
414
+ * @returns {void}
415
+ */
416
+ private onValueChange;
417
+ /**
418
+ * From value observer
419
+ * @returns {void}
420
+ */
421
+ private onFromValueChange;
422
+ /**
423
+ * Check if value is inside min / max boundary
424
+ * @param value value is checking
425
+ * @param valueFor notation variable binding if range === true
426
+ * @returns true if value and step inside a boundary
427
+ */
428
+ private isValueInBoundary;
429
+ /**
430
+ * To value observer
431
+ * @returns {void}
432
+ */
433
+ private onToValueChange;
434
+ /**
435
+ * Step observer
436
+ * @returns {void}
437
+ */
438
+ private onStepChange;
439
+ /**
440
+ * Min range observer
441
+ * @returns {void}
442
+ */
443
+ private onMinRangeChange;
444
+ /**
445
+ * Min observer
446
+ * @param oldValue old value of min property
447
+ * @returns {void}
448
+ */
449
+ private onMinChange;
450
+ /**
451
+ * Max observer
452
+ * @param oldValue old value of max property
453
+ * @returns {void}
454
+ */
455
+ private onMaxChange;
456
+ /**
457
+ * Implement `render` Track template.
458
+ * @param range show range slider
459
+ * @returns Track template
460
+ */
461
+ private renderTrack;
462
+ /**
463
+ * Implement `render` Thumb template.
464
+ * @param value thumb value in track
465
+ * @param thumbPosition thumb position in track
466
+ * @param name name of thumb to render
467
+ * @returns Thumb template
468
+ */
469
+ private thumbTemplate;
470
+ /**
471
+ * Renders thumb template depending on parameter
472
+ * @param from thumb value start in track
473
+ * @param to thumb value end in track (optional)
474
+ * @returns Thumbs template
475
+ */
476
+ private renderThumb;
477
+ /**
478
+ * Implement `render` number field has template.
479
+ * @param value value in the slider for binding in the input value
480
+ * @param name name input value
481
+ * @returns {TemplateResult} number field template
482
+ */
483
+ private renderNumberField;
484
+ /**
485
+ * Implement `render` slider template.
486
+ * @returns Slider template
487
+ */
488
+ protected render(): TemplateResult;
489
+ }
490
+ declare global {
491
+ interface HTMLElementTagNameMap {
492
+ 'ef-slider': Slider;
493
+ }
494
+ }
495
+
496
+ declare global {
497
+ interface HTMLElementTagNameMap {
498
+ 'ef-slider': Slider;
499
+ }
500
+
501
+ namespace JSX {
502
+ interface IntrinsicElements {
503
+ 'ef-slider': Partial<Slider> | JSXInterface.HTMLAttributes<Slider>;
504
+ }
505
+ }
506
+ }
507
+
508
+ export {};