@refinitiv-ui/elements 6.8.7 → 6.8.9
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.
- package/CHANGELOG.md +180 -433
- package/LICENSE +1 -1
- package/README.md +13 -11
- package/lib/accordion/index.d.ts +1 -1
- package/lib/accordion/index.js +4 -7
- package/lib/appstate-bar/index.d.ts +2 -2
- package/lib/appstate-bar/index.js +10 -4
- package/lib/autosuggest/index.d.ts +7 -7
- package/lib/autosuggest/index.js +85 -80
- package/lib/autosuggest/themes/solar/charcoal/index.js +1 -1
- package/lib/autosuggest/themes/solar/pearl/index.js +1 -1
- package/lib/button/index.js +7 -10
- package/lib/button-bar/index.d.ts +1 -1
- package/lib/button-bar/index.js +12 -12
- package/lib/calendar/index.d.ts +39 -39
- package/lib/calendar/index.js +160 -125
- package/lib/calendar/utils.js +2 -2
- package/lib/canvas/index.d.ts +1 -1
- package/lib/canvas/index.js +2 -4
- package/lib/card/helpers/types.d.ts +2 -2
- package/lib/card/index.d.ts +5 -5
- package/lib/card/index.js +34 -28
- package/lib/chart/helpers/legend.js +10 -8
- package/lib/chart/index.d.ts +3 -3
- package/lib/chart/index.js +17 -17
- package/lib/chart/plugins/doughnut-center-label.js +6 -5
- package/lib/checkbox/index.d.ts +1 -1
- package/lib/checkbox/index.js +12 -13
- package/lib/clock/index.d.ts +55 -55
- package/lib/clock/index.js +84 -95
- package/lib/clock/themes/halo/dark/index.js +1 -1
- package/lib/clock/themes/halo/light/index.js +1 -1
- package/lib/clock/themes/solar/charcoal/index.js +1 -1
- package/lib/clock/themes/solar/pearl/index.js +1 -1
- package/lib/collapse/index.d.ts +1 -1
- package/lib/collapse/index.js +28 -19
- package/lib/collapse/themes/halo/dark/index.js +1 -1
- package/lib/collapse/themes/halo/light/index.js +1 -1
- package/lib/color-dialog/elements/color-palettes.d.ts +1 -1
- package/lib/color-dialog/elements/color-palettes.js +5 -6
- package/lib/color-dialog/elements/grayscale-palettes.d.ts +1 -1
- package/lib/color-dialog/elements/grayscale-palettes.js +9 -9
- package/lib/color-dialog/elements/palettes.js +5 -4
- package/lib/color-dialog/helpers/value-model.js +7 -9
- package/lib/color-dialog/index.d.ts +6 -6
- package/lib/color-dialog/index.js +53 -37
- package/lib/color-picker/index.d.ts +2 -2
- package/lib/color-picker/index.js +40 -34
- package/lib/combo-box/helpers/filter.d.ts +2 -2
- package/lib/combo-box/helpers/types.d.ts +1 -1
- package/lib/combo-box/index.d.ts +9 -9
- package/lib/combo-box/index.js +61 -55
- package/lib/configuration/elements/configuration.d.ts +1 -1
- package/lib/configuration/elements/configuration.js +2 -2
- package/lib/counter/index.d.ts +4 -4
- package/lib/counter/index.js +9 -7
- package/lib/datetime-field/index.d.ts +4 -5
- package/lib/datetime-field/index.js +32 -23
- package/lib/datetime-field/utils.js +11 -1
- package/lib/datetime-picker/index.d.ts +75 -75
- package/lib/datetime-picker/index.js +151 -132
- package/lib/datetime-picker/locales.js +5 -5
- package/lib/datetime-picker/utils.js +9 -9
- package/lib/dialog/draggable-element.js +1 -2
- package/lib/dialog/index.d.ts +6 -6
- package/lib/dialog/index.js +48 -38
- package/lib/email-field/index.d.ts +1 -1
- package/lib/email-field/index.js +6 -6
- package/lib/events.d.ts +1 -1
- package/lib/flag/index.d.ts +1 -1
- package/lib/flag/index.js +6 -5
- package/lib/flag/utils/FlagLoader.js +1 -1
- package/lib/header/index.d.ts +1 -1
- package/lib/header/index.js +2 -2
- package/lib/header/themes/halo/dark/index.js +1 -1
- package/lib/header/themes/halo/light/index.js +1 -1
- package/lib/header/themes/solar/charcoal/index.js +1 -1
- package/lib/header/themes/solar/pearl/index.js +1 -1
- package/lib/heatmap/helpers/color.d.ts +1 -1
- package/lib/heatmap/helpers/color.js +11 -5
- package/lib/heatmap/helpers/track.js +3 -3
- package/lib/heatmap/index.d.ts +9 -9
- package/lib/heatmap/index.js +51 -42
- package/lib/icon/index.d.ts +2 -2
- package/lib/icon/index.js +6 -8
- package/lib/icon/utils/IconLoader.d.ts +1 -0
- package/lib/icon/utils/IconLoader.js +9 -1
- package/lib/interactive-chart/helpers/types.d.ts +3 -3
- package/lib/interactive-chart/index.d.ts +34 -34
- package/lib/interactive-chart/index.js +72 -57
- package/lib/item/helpers/types.d.ts +1 -1
- package/lib/item/index.d.ts +3 -3
- package/lib/item/index.js +24 -20
- package/lib/jsx.d.ts +6 -4
- package/lib/label/index.d.ts +1 -1
- package/lib/label/index.js +11 -8
- package/lib/layout/index.d.ts +7 -7
- package/lib/layout/index.js +7 -7
- package/lib/led-gauge/index.d.ts +1 -1
- package/lib/led-gauge/index.js +10 -10
- package/lib/list/elements/list.d.ts +3 -3
- package/lib/list/elements/list.js +10 -12
- package/lib/list/helpers/renderer.js +2 -2
- package/lib/list/helpers/types.d.ts +1 -1
- package/lib/list/index.d.ts +1 -1
- package/lib/list/renderer.d.ts +7 -7
- package/lib/loader/index.js +7 -8
- package/lib/multi-input/index.d.ts +6 -6
- package/lib/multi-input/index.js +39 -45
- package/lib/notification/elements/notification-tray.d.ts +2 -2
- package/lib/notification/elements/notification-tray.js +3 -3
- package/lib/notification/elements/notification.d.ts +2 -2
- package/lib/notification/elements/notification.js +22 -14
- package/lib/notification/helpers/status.js +1 -1
- package/lib/number-field/index.d.ts +5 -6
- package/lib/number-field/index.js +37 -47
- package/lib/overlay/elements/overlay-viewport.d.ts +1 -1
- package/lib/overlay/elements/overlay.d.ts +2 -2
- package/lib/overlay/elements/overlay.js +154 -98
- package/lib/overlay/helpers/types.d.ts +1 -1
- package/lib/overlay/managers/backdrop-manager.d.ts +1 -1
- package/lib/overlay/managers/backdrop-manager.js +2 -2
- package/lib/overlay/managers/close-manager.js +2 -1
- package/lib/overlay/managers/focus-manager.js +23 -13
- package/lib/overlay/managers/interaction-lock-manager.d.ts +4 -4
- package/lib/overlay/managers/interaction-lock-manager.js +33 -25
- package/lib/overlay/managers/viewport-manager.d.ts +2 -2
- package/lib/overlay/managers/viewport-manager.js +3 -2
- package/lib/overlay/managers/zindex-manager.js +4 -2
- package/lib/overlay-menu/helpers/types.d.ts +2 -2
- package/lib/overlay-menu/index.d.ts +1 -1
- package/lib/overlay-menu/index.js +44 -33
- package/lib/overlay-menu/managers/menu-manager.d.ts +10 -10
- package/lib/overlay-menu/managers/menu-manager.js +15 -13
- package/lib/pagination/index.d.ts +4 -4
- package/lib/pagination/index.js +39 -14
- package/lib/panel/index.js +1 -1
- package/lib/password-field/index.d.ts +2 -2
- package/lib/password-field/index.js +4 -4
- package/lib/pill/index.d.ts +1 -1
- package/lib/pill/index.js +22 -19
- package/lib/progress-bar/index.d.ts +1 -1
- package/lib/progress-bar/index.js +38 -37
- package/lib/radio-button/index.d.ts +2 -2
- package/lib/radio-button/index.js +17 -12
- package/lib/radio-button/radio-button-registry.js +8 -5
- package/lib/rating/index.d.ts +1 -1
- package/lib/rating/index.js +2 -5
- package/lib/rating/utils.d.ts +6 -6
- package/lib/rating/utils.js +6 -6
- package/lib/search-field/index.d.ts +2 -2
- package/lib/search-field/index.js +4 -4
- package/lib/select/index.d.ts +34 -34
- package/lib/select/index.js +70 -83
- package/lib/sidebar-layout/index.d.ts +2 -2
- package/lib/sidebar-layout/index.js +7 -9
- package/lib/slider/index.d.ts +2 -2
- package/lib/slider/index.js +57 -45
- package/lib/slider/utils.d.ts +10 -10
- package/lib/slider/utils.js +10 -10
- package/lib/sparkline/index.d.ts +1 -1
- package/lib/sparkline/index.js +7 -8
- package/lib/swing-gauge/helpers.js +2 -2
- package/lib/swing-gauge/index.d.ts +19 -19
- package/lib/swing-gauge/index.js +91 -81
- package/lib/tab/index.d.ts +1 -1
- package/lib/tab/index.js +16 -27
- package/lib/tab/themes/halo/dark/index.js +1 -1
- package/lib/tab/themes/halo/light/index.js +1 -1
- package/lib/tab/themes/solar/charcoal/index.js +1 -1
- package/lib/tab/themes/solar/pearl/index.js +1 -1
- package/lib/tab-bar/helpers/animate.js +1 -1
- package/lib/tab-bar/index.d.ts +1 -1
- package/lib/tab-bar/index.js +34 -18
- package/lib/tab-bar/themes/halo/dark/index.js +1 -1
- package/lib/tab-bar/themes/halo/light/index.js +1 -1
- package/lib/text-field/index.d.ts +1 -1
- package/lib/text-field/index.js +36 -33
- package/lib/time-picker/index.d.ts +6 -6
- package/lib/time-picker/index.js +104 -90
- package/lib/toggle/index.d.ts +1 -1
- package/lib/toggle/index.js +4 -3
- package/lib/tooltip/elements/title-tooltip.js +2 -2
- package/lib/tooltip/index.d.ts +27 -27
- package/lib/tooltip/index.js +42 -38
- package/lib/tooltip/managers/tooltip-manager.d.ts +1 -1
- package/lib/tornado-chart/elements/tornado-chart.d.ts +1 -1
- package/lib/tornado-chart/elements/tornado-chart.js +1 -1
- package/lib/tornado-chart/elements/tornado-item.d.ts +2 -2
- package/lib/tornado-chart/elements/tornado-item.js +12 -10
- package/lib/tree/elements/tree-item.d.ts +3 -3
- package/lib/tree/elements/tree-item.js +21 -19
- package/lib/tree/elements/tree.d.ts +1 -1
- package/lib/tree/elements/tree.js +12 -11
- package/lib/tree/helpers/renderer.js +4 -3
- package/lib/tree/index.d.ts +1 -1
- package/lib/tree/managers/tree-manager.d.ts +1 -1
- package/lib/tree/managers/tree-manager.js +17 -18
- package/lib/tree/themes/solar/charcoal/index.js +1 -1
- package/lib/tree/themes/solar/pearl/index.js +1 -1
- package/lib/tree-select/index.d.ts +9 -9
- package/lib/tree-select/index.js +91 -82
- package/lib/tree-select/themes/halo/dark/index.js +1 -1
- package/lib/tree-select/themes/halo/light/index.js +1 -1
- package/lib/tree-select/themes/solar/charcoal/index.js +1 -1
- package/lib/tree-select/themes/solar/pearl/index.js +1 -1
- package/lib/version.js +1 -1
- package/package.json +16 -16
- package/tsconfig.tsbuildinfo +1 -1
package/lib/slider/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { ControlElement, WarningNotice, css, html, nothing } from '@refinitiv-ui/core';
|
|
3
3
|
import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
|
|
4
4
|
import { property } from '@refinitiv-ui/core/decorators/property.js';
|
|
5
5
|
import { query } from '@refinitiv-ui/core/decorators/query.js';
|
|
6
6
|
import { state } from '@refinitiv-ui/core/decorators/state.js';
|
|
7
7
|
import { createRef, ref } from '@refinitiv-ui/core/directives/ref.js';
|
|
8
8
|
import { styleMap } from '@refinitiv-ui/core/directives/style-map.js';
|
|
9
|
-
import { translate } from '@refinitiv-ui/translate';
|
|
10
9
|
import '@refinitiv-ui/phrasebook/locale/en/slider.js';
|
|
11
|
-
import {
|
|
10
|
+
import { translate } from '@refinitiv-ui/translate';
|
|
12
11
|
import '../number-field/index.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { VERSION } from '../version.js';
|
|
13
|
+
import { Direction, SliderDataName } from './constants.js';
|
|
14
|
+
import { clamp, countDecimalPlace, isDecimalNumber, preventDefault } from './utils.js';
|
|
15
15
|
/**
|
|
16
16
|
* Allows users to make selections from a range of values
|
|
17
17
|
*
|
|
@@ -45,67 +45,67 @@ let Slider = class Slider extends ControlElement {
|
|
|
45
45
|
:host {
|
|
46
46
|
display: flex;
|
|
47
47
|
}
|
|
48
|
-
[part=slider-wrapper] {
|
|
48
|
+
[part='slider-wrapper'] {
|
|
49
49
|
position: relative;
|
|
50
50
|
width: 100%;
|
|
51
51
|
}
|
|
52
|
-
[part=slider] {
|
|
52
|
+
[part='slider'] {
|
|
53
53
|
width: 100%;
|
|
54
54
|
height: 100%;
|
|
55
55
|
display: inline-block;
|
|
56
56
|
}
|
|
57
|
-
:host(:not([disabled]):focus){
|
|
58
|
-
outline:none;
|
|
57
|
+
:host(:not([disabled]):focus) {
|
|
58
|
+
outline: none;
|
|
59
59
|
}
|
|
60
|
-
:host([show-steps]) [part=track-wrapper]::after {
|
|
61
|
-
display:block;
|
|
60
|
+
:host([show-steps]) [part='track-wrapper']::after {
|
|
61
|
+
display: block;
|
|
62
62
|
position: absolute;
|
|
63
|
-
content:
|
|
63
|
+
content: '';
|
|
64
64
|
right: 0;
|
|
65
65
|
}
|
|
66
|
-
[part=track-wrapper]{
|
|
67
|
-
content:
|
|
66
|
+
[part='track-wrapper'] {
|
|
67
|
+
content: '';
|
|
68
68
|
position: absolute;
|
|
69
69
|
width: 100%;
|
|
70
70
|
top: 50%;
|
|
71
71
|
left: 0;
|
|
72
72
|
pointer-events: none;
|
|
73
73
|
}
|
|
74
|
-
[part=thumb-container]{
|
|
74
|
+
[part='thumb-container'] {
|
|
75
75
|
outline: none;
|
|
76
76
|
position: absolute;
|
|
77
77
|
top: 0;
|
|
78
78
|
width: 100%;
|
|
79
79
|
z-index: 3;
|
|
80
80
|
}
|
|
81
|
-
[part=thumb]{
|
|
81
|
+
[part='thumb'] {
|
|
82
82
|
position: absolute;
|
|
83
83
|
margin: 0 auto;
|
|
84
84
|
}
|
|
85
|
-
[part=pin]{
|
|
85
|
+
[part='pin'] {
|
|
86
86
|
display: flex;
|
|
87
87
|
position: absolute;
|
|
88
88
|
align-items: center;
|
|
89
89
|
justify-content: center;
|
|
90
90
|
z-index: 1;
|
|
91
91
|
}
|
|
92
|
-
:host([show-steps]) [part=step-container]{
|
|
92
|
+
:host([show-steps]) [part='step-container'] {
|
|
93
93
|
position: absolute;
|
|
94
94
|
left: 0;
|
|
95
95
|
width: 100%;
|
|
96
96
|
}
|
|
97
|
-
:host([show-steps]) [part=step]{
|
|
97
|
+
:host([show-steps]) [part='step'] {
|
|
98
98
|
width: 100%;
|
|
99
99
|
position: absolute;
|
|
100
100
|
left: 0;
|
|
101
101
|
}
|
|
102
|
-
[part=track-fill]{
|
|
102
|
+
[part='track-fill'] {
|
|
103
103
|
z-index: 2;
|
|
104
|
-
content:
|
|
104
|
+
content: '';
|
|
105
105
|
position: absolute;
|
|
106
106
|
left: 0;
|
|
107
107
|
}
|
|
108
|
-
:host([show-steps][step=
|
|
108
|
+
:host([show-steps][step='0']) [part='track-wrapper']::after {
|
|
109
109
|
width: 0;
|
|
110
110
|
}
|
|
111
111
|
`;
|
|
@@ -299,19 +299,19 @@ let Slider = class Slider extends ControlElement {
|
|
|
299
299
|
this.changedThumb = null;
|
|
300
300
|
/**
|
|
301
301
|
* @ignore
|
|
302
|
-
|
|
302
|
+
*/
|
|
303
303
|
this.onDrag = this.onDrag.bind(this);
|
|
304
304
|
/**
|
|
305
305
|
* @ignore
|
|
306
|
-
|
|
306
|
+
*/
|
|
307
307
|
this.onDragStart = this.onDragStart.bind(this);
|
|
308
308
|
/**
|
|
309
309
|
* @ignore
|
|
310
|
-
|
|
310
|
+
*/
|
|
311
311
|
this.onDragEnd = this.onDragEnd.bind(this);
|
|
312
312
|
/**
|
|
313
313
|
* @ignore
|
|
314
|
-
|
|
314
|
+
*/
|
|
315
315
|
this.onKeyDown = this.onKeyDown.bind(this);
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
@@ -332,8 +332,8 @@ let Slider = class Slider extends ControlElement {
|
|
|
332
332
|
*/
|
|
333
333
|
willUpdate(changedProperties) {
|
|
334
334
|
super.willUpdate(changedProperties);
|
|
335
|
-
if ((changedProperties.has('disabled') && changedProperties.get('disabled') !== undefined)
|
|
336
|
-
|
|
335
|
+
if ((changedProperties.has('disabled') && changedProperties.get('disabled') !== undefined) ||
|
|
336
|
+
(changedProperties.has('readonly') && changedProperties.get('readonly') !== undefined)) {
|
|
337
337
|
this.prepareSliderTrack();
|
|
338
338
|
}
|
|
339
339
|
changedProperties.forEach((_, changedProperty) => {
|
|
@@ -398,21 +398,21 @@ let Slider = class Slider extends ControlElement {
|
|
|
398
398
|
message = 'value should be more than min.';
|
|
399
399
|
}
|
|
400
400
|
else if (propName === 'from' && this.range) {
|
|
401
|
-
isValid =
|
|
401
|
+
isValid = this.fromNumber >= this.minNumber && this.fromNumber <= this.toNumber;
|
|
402
402
|
message = 'value should be more than min and less than to.';
|
|
403
403
|
}
|
|
404
404
|
else if (propName === 'to' && this.range) {
|
|
405
|
-
isValid =
|
|
405
|
+
isValid = this.toNumber <= this.maxNumber && this.toNumber >= this.fromNumber;
|
|
406
406
|
message = 'value should be less than max and more than from.';
|
|
407
407
|
}
|
|
408
408
|
else if (propName === 'step') {
|
|
409
|
-
isValid =
|
|
409
|
+
isValid = this.maxNumber - this.minNumber >= this.stepNumber;
|
|
410
410
|
message = 'value should be between min and max.';
|
|
411
411
|
}
|
|
412
412
|
else if (propName === 'minRange' && this.minRangeNumber > 0) {
|
|
413
413
|
const distanceFromTo = Math.abs(this.toNumber - this.fromNumber);
|
|
414
414
|
const distanceMinMax = Math.abs(this.maxNumber - this.minNumber);
|
|
415
|
-
isValid =
|
|
415
|
+
isValid = distanceMinMax >= this.minRangeNumber && distanceFromTo >= this.minRangeNumber;
|
|
416
416
|
message = 'value should be less than distance from and to, min and max.';
|
|
417
417
|
}
|
|
418
418
|
if (!isValid) {
|
|
@@ -439,8 +439,8 @@ let Slider = class Slider extends ControlElement {
|
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
else {
|
|
442
|
-
this.from = clamp(
|
|
443
|
-
this.to = clamp(
|
|
442
|
+
this.from = clamp(this.fromNumber || this.minNumber, this.minNumber, this.toNumber);
|
|
443
|
+
this.to = clamp(this.toNumber || this.maxNumber, this.fromNumber, this.maxNumber);
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
else {
|
|
@@ -681,7 +681,7 @@ let Slider = class Slider extends ControlElement {
|
|
|
681
681
|
shouldUpdate = this.isValueInBoundary(Number(value), '');
|
|
682
682
|
}
|
|
683
683
|
if (shouldUpdate) {
|
|
684
|
-
|
|
684
|
+
this[name] = value;
|
|
685
685
|
this.notifyPropertyChange(name, value);
|
|
686
686
|
}
|
|
687
687
|
else {
|
|
@@ -713,7 +713,7 @@ let Slider = class Slider extends ControlElement {
|
|
|
713
713
|
this.classList.add('grabbable');
|
|
714
714
|
if (this.range) {
|
|
715
715
|
const mousePosition = this.getMousePosition(event);
|
|
716
|
-
const relativeMousePosition = (
|
|
716
|
+
const relativeMousePosition = (this.maxNumber - this.minNumber) * mousePosition + this.minNumber;
|
|
717
717
|
const distanceFrom = Math.abs(relativeMousePosition - this.fromNumber);
|
|
718
718
|
const distanceTo = Math.abs(relativeMousePosition - this.toNumber);
|
|
719
719
|
if (distanceFrom < distanceTo) {
|
|
@@ -748,7 +748,9 @@ let Slider = class Slider extends ControlElement {
|
|
|
748
748
|
return 1;
|
|
749
749
|
}
|
|
750
750
|
// check drag desktop or mobile
|
|
751
|
-
const pageX = event.changedTouches
|
|
751
|
+
const pageX = event.changedTouches
|
|
752
|
+
? event.changedTouches[0].pageX
|
|
753
|
+
: event.pageX;
|
|
752
754
|
const positionSize = pageX - sliderRect.left;
|
|
753
755
|
if (positionSize <= sliderRect.width) {
|
|
754
756
|
return Math.min(Math.max((pageX - sliderRect.left) / sliderRect.width, 0), 1);
|
|
@@ -826,7 +828,7 @@ let Slider = class Slider extends ControlElement {
|
|
|
826
828
|
getNearestPossibleValue(thumbPosition) {
|
|
827
829
|
const stepSize = this.calculatePosition(this.minNumber + this.stepRange, 1);
|
|
828
830
|
const nearestValue = Math.round(thumbPosition / stepSize) * stepSize;
|
|
829
|
-
if (thumbPosition <= nearestValue +
|
|
831
|
+
if (thumbPosition <= nearestValue + stepSize / 2) {
|
|
830
832
|
if (nearestValue <= 1) {
|
|
831
833
|
return nearestValue;
|
|
832
834
|
}
|
|
@@ -954,11 +956,11 @@ let Slider = class Slider extends ControlElement {
|
|
|
954
956
|
// Check if value is in range
|
|
955
957
|
if (this.range) {
|
|
956
958
|
if (valueFor === SliderDataName.to) {
|
|
957
|
-
if (value <
|
|
959
|
+
if (value < this.fromNumber + this.minRangeNumber || value > this.maxNumber) {
|
|
958
960
|
return false;
|
|
959
961
|
}
|
|
960
962
|
}
|
|
961
|
-
else if (value < this.minNumber || value >
|
|
963
|
+
else if (value < this.minNumber || value > this.toNumber - this.minRangeNumber) {
|
|
962
964
|
return false;
|
|
963
965
|
}
|
|
964
966
|
}
|
|
@@ -1083,11 +1085,17 @@ let Slider = class Slider extends ControlElement {
|
|
|
1083
1085
|
*/
|
|
1084
1086
|
renderTrack(range) {
|
|
1085
1087
|
const stepContainerSize = this.calculatePosition(this.minNumber + this.stepNumber);
|
|
1086
|
-
const translateX =
|
|
1087
|
-
const stepsStyle = {
|
|
1088
|
+
const translateX = stepContainerSize / 2;
|
|
1089
|
+
const stepsStyle = {
|
|
1090
|
+
transform: `translateX(${translateX}%)`,
|
|
1091
|
+
backgroundSize: `${stepContainerSize}% 100%`
|
|
1092
|
+
};
|
|
1088
1093
|
const stepContainerStyle = { transform: `translateX(-${translateX}%)` };
|
|
1089
1094
|
const trackFillStyle = range
|
|
1090
|
-
? {
|
|
1095
|
+
? {
|
|
1096
|
+
width: `${this.calculatePosition(this.toNumber) - this.calculatePosition(this.fromNumber)}%`,
|
|
1097
|
+
left: `${this.calculatePosition(this.fromNumber)}%`
|
|
1098
|
+
}
|
|
1091
1099
|
: { width: `${this.calculatePosition(Number(this.value))}%` };
|
|
1092
1100
|
return html `
|
|
1093
1101
|
<div part="track-wrapper" ${ref(this.trackRef)}>
|
|
@@ -1197,11 +1205,15 @@ let Slider = class Slider extends ControlElement {
|
|
|
1197
1205
|
<div part="slider-wrapper">
|
|
1198
1206
|
<div part="slider" ${ref(this.sliderRef)}>
|
|
1199
1207
|
${this.renderTrack(this.range)}
|
|
1200
|
-
${this.range
|
|
1208
|
+
${this.range
|
|
1209
|
+
? this.renderThumb(this.fromNumber, this.toNumber)
|
|
1210
|
+
: this.renderThumb(this.valueNumber)}
|
|
1201
1211
|
</div>
|
|
1202
1212
|
</div>
|
|
1203
1213
|
${this.range && this.isShowInputField ? this.renderNumberField(this.to, SliderDataName.to) : null}
|
|
1204
|
-
${!this.range && this.isShowInputField
|
|
1214
|
+
${!this.range && this.isShowInputField
|
|
1215
|
+
? this.renderNumberField(this.value, SliderDataName.value)
|
|
1216
|
+
: null}
|
|
1205
1217
|
`;
|
|
1206
1218
|
}
|
|
1207
1219
|
};
|
package/lib/slider/utils.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
* Set prevent default action and stop bubbles event
|
|
3
|
+
* @param event event mouse or touch
|
|
4
|
+
* @returns {void}
|
|
5
|
+
*/
|
|
6
6
|
declare const preventDefault: (event: Event) => Event;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
* Return value that never exceed the maximum boundary
|
|
9
|
+
* @param value value for check clamp
|
|
10
|
+
* @param min max value
|
|
11
|
+
* @param max min value
|
|
12
|
+
* @returns number between two numbers
|
|
13
|
+
*/
|
|
14
14
|
declare const clamp: (value: number, min: number, max: number) => string;
|
|
15
15
|
/**
|
|
16
16
|
* Check if number is a decimal number
|
package/lib/slider/utils.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
* Set prevent default action and stop bubbles event
|
|
3
|
+
* @param event event mouse or touch
|
|
4
|
+
* @returns {void}
|
|
5
|
+
*/
|
|
6
6
|
const preventDefault = (event) => {
|
|
7
7
|
event.preventDefault();
|
|
8
8
|
event.stopPropagation();
|
|
9
9
|
return event;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
* Return value that never exceed the maximum boundary
|
|
13
|
+
* @param value value for check clamp
|
|
14
|
+
* @param min max value
|
|
15
|
+
* @param max min value
|
|
16
|
+
* @returns number between two numbers
|
|
17
|
+
*/
|
|
18
18
|
const clamp = function (value, min, max) {
|
|
19
19
|
return Math.max(min, Math.min(value, max)).toString();
|
|
20
20
|
};
|
package/lib/sparkline/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSXInterface } from '../jsx';
|
|
2
|
-
import { CSSResultGroup, PropertyValues, ResponsiveElement, TemplateResult
|
|
2
|
+
import { CSSResultGroup, ElementSize, PropertyValues, ResponsiveElement, TemplateResult } from '@refinitiv-ui/core';
|
|
3
3
|
import '@refinitiv-ui/browser-sparkline';
|
|
4
4
|
import type { BrowserSparklineChart } from '@refinitiv-ui/browser-sparkline';
|
|
5
5
|
import type { ThemeConfig } from '@refinitiv-ui/browser-sparkline/lib/browserSparklineCanvas';
|
package/lib/sparkline/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { ResponsiveElement, css, html } from '@refinitiv-ui/core';
|
|
3
3
|
import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
|
|
4
4
|
import { property } from '@refinitiv-ui/core/decorators/property.js';
|
|
5
5
|
import { query } from '@refinitiv-ui/core/decorators/query.js';
|
|
6
|
-
import { VERSION } from '../version.js';
|
|
7
|
-
import { color } from '@refinitiv-ui/utils/color.js';
|
|
8
6
|
import '@refinitiv-ui/browser-sparkline';
|
|
7
|
+
import { color } from '@refinitiv-ui/utils/color.js';
|
|
8
|
+
import { VERSION } from '../version.js';
|
|
9
9
|
let Sparkline = class Sparkline extends ResponsiveElement {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
@@ -145,13 +145,14 @@ let Sparkline = class Sparkline extends ResponsiveElement {
|
|
|
145
145
|
display: block;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
browser-sparkline-chart,
|
|
148
|
+
browser-sparkline-chart,
|
|
149
|
+
browser-sparkline-canvas {
|
|
149
150
|
width: 100%;
|
|
150
151
|
height: 100%;
|
|
151
152
|
display: block;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
[part=chart] {
|
|
155
|
+
[part='chart'] {
|
|
155
156
|
height: 100%;
|
|
156
157
|
}
|
|
157
158
|
`;
|
|
@@ -162,9 +163,7 @@ let Sparkline = class Sparkline extends ResponsiveElement {
|
|
|
162
163
|
* @return Render template
|
|
163
164
|
*/
|
|
164
165
|
render() {
|
|
165
|
-
return html `
|
|
166
|
-
<browser-sparkline-chart part="chart" id="sparkline"></browser-sparkline-chart>
|
|
167
|
-
`;
|
|
166
|
+
return html ` <browser-sparkline-chart part="chart" id="sparkline"></browser-sparkline-chart> `;
|
|
168
167
|
}
|
|
169
168
|
};
|
|
170
169
|
__decorate([
|
|
@@ -75,7 +75,7 @@ const draw = (drawData, drawCtx, drawParams) => {
|
|
|
75
75
|
ctx.setLineDash([5, 3]);
|
|
76
76
|
}
|
|
77
77
|
ctx.moveTo(data.width / 2, data.height - data.size * data.gaugeLowerBound);
|
|
78
|
-
ctx.lineTo(data.width / 2, data.height -
|
|
78
|
+
ctx.lineTo(data.width / 2, data.height - data.size * data.gaugeUpperBound + style.strokeWidth);
|
|
79
79
|
ctx.strokeStyle = style.centerlineColor;
|
|
80
80
|
ctx.stroke();
|
|
81
81
|
ctx.restore();
|
|
@@ -89,7 +89,7 @@ const elasticOut = ((amplitude, period) => {
|
|
|
89
89
|
return time;
|
|
90
90
|
}
|
|
91
91
|
const s = (period / pi2) * Math.asin(1 / amplitude);
|
|
92
|
-
return
|
|
92
|
+
return amplitude * Math.pow(2, -10 * time) * Math.sin(((time - s) * pi2) / period) + 1;
|
|
93
93
|
};
|
|
94
94
|
})(1.2, 0.5);
|
|
95
95
|
const textWidth = (drawCtx, text, fontSize, fontFamily) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSXInterface } from '../jsx';
|
|
2
|
-
import {
|
|
2
|
+
import { CSSResultGroup, PropertyValues, ResponsiveElement, TemplateResult } from '@refinitiv-ui/core';
|
|
3
3
|
import '../canvas/index.js';
|
|
4
4
|
import '../label/index.js';
|
|
5
5
|
import type { SwingGaugeCanvasSize, SwingGaugeValueFormatter } from './types';
|
|
@@ -47,12 +47,12 @@ export declare class SwingGauge extends ResponsiveElement {
|
|
|
47
47
|
*/
|
|
48
48
|
duration: number;
|
|
49
49
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
* Primary value legend
|
|
51
|
+
*/
|
|
52
52
|
primaryLegend: string;
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
* Secondary value legend
|
|
55
|
+
*/
|
|
56
56
|
secondaryLegend: string;
|
|
57
57
|
/**
|
|
58
58
|
* Custom value formatter
|
|
@@ -74,36 +74,36 @@ export declare class SwingGauge extends ResponsiveElement {
|
|
|
74
74
|
private primaryLineRadian;
|
|
75
75
|
private secondaryLineRadian;
|
|
76
76
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
* Data requires to draw swing gauge
|
|
78
|
+
*/
|
|
79
79
|
private data;
|
|
80
80
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
* Internal sizes and scales
|
|
82
|
+
*/
|
|
83
83
|
private width;
|
|
84
84
|
private height;
|
|
85
85
|
private size;
|
|
86
86
|
private lineLength;
|
|
87
87
|
private scale;
|
|
88
88
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
* Current fill percentage
|
|
90
|
+
*/
|
|
91
91
|
private fillPercentage;
|
|
92
92
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
* Keeps previous percentage calculation to avoid re-rendering the same value
|
|
94
|
+
*/
|
|
95
95
|
private previousFillPercentage;
|
|
96
96
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
* This for keep line number of label for calculate new radius
|
|
98
|
+
*/
|
|
99
99
|
private labelLineNumber;
|
|
100
100
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
* Get primary percentage
|
|
102
|
+
*/
|
|
103
103
|
private get primaryPercentage();
|
|
104
104
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
* Get secondary percentage
|
|
106
|
+
*/
|
|
107
107
|
private get secondaryPercentage();
|
|
108
108
|
/**
|
|
109
109
|
* Check width and height are valid
|