@refinitiv-ui/elements 7.0.0 → 7.0.2
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 +195 -449
- package/LICENSE +2 -2
- package/README.md +12 -10
- package/cli.mjs +5 -3
- 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 +80 -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 +156 -123
- package/lib/calendar/utils.js +1 -1
- 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/elements/chart.d.ts +4 -4
- package/lib/chart/elements/chart.js +39 -33
- package/lib/chart/plugins/doughnut-center-label.d.ts +3 -3
- package/lib/chart/plugins/doughnut-center-label.js +13 -9
- 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 +27 -18
- 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.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 +150 -131
- 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 +5 -5
- package/lib/dialog/index.js +51 -47
- 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 +8 -10
- package/lib/interactive-chart/helpers/types.d.ts +3 -3
- package/lib/interactive-chart/index.d.ts +29 -29
- package/lib/interactive-chart/index.js +69 -55
- 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 +10 -7
- 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 +14 -13
- package/lib/notification/helpers/status.js +1 -1
- package/lib/notification/themes/halo/dark/index.js +1 -1
- package/lib/notification/themes/halo/light/index.js +1 -1
- package/lib/notification/themes/solar/charcoal/index.js +1 -1
- package/lib/notification/themes/solar/pearl/index.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 +152 -96
- 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 +14 -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 +3 -3
- 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 +68 -81
- 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 +34 -31
- package/lib/time-picker/index.d.ts +6 -6
- package/lib/time-picker/index.js +103 -89
- package/lib/toggle/index.d.ts +1 -1
- package/lib/toggle/index.js +4 -3
- package/lib/toggle/themes/halo/dark/index.js +1 -1
- package/lib/toggle/themes/halo/light/index.js +1 -1
- package/lib/toggle/themes/solar/charcoal/index.js +1 -1
- package/lib/toggle/themes/solar/pearl/index.js +1 -1
- 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 +2 -2
- 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 +17 -17
- package/tsconfig.tsbuildinfo +1 -1
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
|
package/lib/swing-gauge/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { ResponsiveElement, css, html
|
|
2
|
+
import { ResponsiveElement, WarningNotice, 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
6
|
import { state } from '@refinitiv-ui/core/decorators/state.js';
|
|
7
7
|
import { styleMap } from '@refinitiv-ui/core/directives/style-map.js';
|
|
8
|
-
import { VERSION } from '../version.js';
|
|
9
8
|
import '../canvas/index.js';
|
|
10
9
|
import '../label/index.js';
|
|
11
|
-
import {
|
|
10
|
+
import { VERSION } from '../version.js';
|
|
12
11
|
import { DefaultStyle, Segment, TextType } from './const.js';
|
|
12
|
+
import { helpers as canvasHelper } from './helpers.js';
|
|
13
13
|
/**
|
|
14
14
|
* Constants from swing-gauge default specs
|
|
15
15
|
*/
|
|
@@ -53,12 +53,12 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
53
53
|
*/
|
|
54
54
|
this.duration = 1000;
|
|
55
55
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
* Primary value legend
|
|
57
|
+
*/
|
|
58
58
|
this.primaryLegend = '';
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
* Secondary value legend
|
|
61
|
+
*/
|
|
62
62
|
this.secondaryLegend = '';
|
|
63
63
|
/**
|
|
64
64
|
* Custom value formatter
|
|
@@ -80,28 +80,28 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
80
80
|
this.primaryLineRadian = PRIMARY_RADIAN;
|
|
81
81
|
this.secondaryLineRadian = SECONDARY_RADIAN;
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
* Data requires to draw swing gauge
|
|
84
|
+
*/
|
|
85
85
|
this.data = null;
|
|
86
86
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
* Internal sizes and scales
|
|
88
|
+
*/
|
|
89
89
|
this.width = 0;
|
|
90
90
|
this.height = 0;
|
|
91
91
|
this.size = 0;
|
|
92
92
|
this.lineLength = 60;
|
|
93
93
|
this.scale = 1;
|
|
94
94
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
* Current fill percentage
|
|
96
|
+
*/
|
|
97
97
|
this.fillPercentage = 0;
|
|
98
98
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
* Keeps previous percentage calculation to avoid re-rendering the same value
|
|
100
|
+
*/
|
|
101
101
|
this.previousFillPercentage = 0;
|
|
102
102
|
/**
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
* This for keep line number of label for calculate new radius
|
|
104
|
+
*/
|
|
105
105
|
this.labelLineNumber = 1;
|
|
106
106
|
/**
|
|
107
107
|
* Style for primary container
|
|
@@ -139,46 +139,50 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
139
139
|
display: block;
|
|
140
140
|
height: 200px;
|
|
141
141
|
}
|
|
142
|
-
:host [part=container] {
|
|
142
|
+
:host [part='container'] {
|
|
143
143
|
display: flex;
|
|
144
144
|
flex-direction: column;
|
|
145
145
|
height: 100%;
|
|
146
146
|
}
|
|
147
|
-
:host [part=canvas-container] {
|
|
147
|
+
:host [part='canvas-container'] {
|
|
148
148
|
position: relative;
|
|
149
149
|
flex: 1;
|
|
150
150
|
}
|
|
151
|
-
:host [part=canvas] {
|
|
151
|
+
:host [part='canvas'] {
|
|
152
152
|
height: 100%;
|
|
153
153
|
}
|
|
154
|
-
:host [part=primary-legend],
|
|
154
|
+
:host [part='primary-legend'],
|
|
155
|
+
[part='secondary-legend'] {
|
|
155
156
|
text-align: left;
|
|
156
157
|
display: flex;
|
|
157
158
|
}
|
|
158
|
-
:host [part=primary-label],
|
|
159
|
+
:host [part='primary-label'],
|
|
160
|
+
[part='primary-value'] {
|
|
159
161
|
text-align: left;
|
|
160
162
|
}
|
|
161
|
-
:host [part=secondary-label],
|
|
163
|
+
:host [part='secondary-label'],
|
|
164
|
+
[part='secondary-value'] {
|
|
162
165
|
text-align: right;
|
|
163
166
|
}
|
|
164
|
-
:host [part=legend-container-outer] {
|
|
167
|
+
:host [part='legend-container-outer'] {
|
|
165
168
|
width: 60%;
|
|
166
169
|
margin: 0 auto;
|
|
167
170
|
text-align: center;
|
|
168
171
|
}
|
|
169
|
-
:host [part=legend-container-inner] {
|
|
172
|
+
:host [part='legend-container-inner'] {
|
|
170
173
|
max-width: 100%;
|
|
171
174
|
display: inline-block;
|
|
172
175
|
}
|
|
173
|
-
:host [part=primary-legend-symbol],
|
|
176
|
+
:host [part='primary-legend-symbol'],
|
|
177
|
+
[part='secondary-legend-symbol'] {
|
|
174
178
|
display: inline-block;
|
|
175
179
|
flex-shrink: 0;
|
|
176
180
|
}
|
|
177
|
-
:host [part=primary-container] {
|
|
181
|
+
:host [part='primary-container'] {
|
|
178
182
|
position: absolute;
|
|
179
183
|
text-align: left;
|
|
180
184
|
}
|
|
181
|
-
:host [part=secondary-container] {
|
|
185
|
+
:host [part='secondary-container'] {
|
|
182
186
|
position: absolute;
|
|
183
187
|
text-align: right;
|
|
184
188
|
}
|
|
@@ -215,14 +219,14 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
215
219
|
return this._secondaryValue;
|
|
216
220
|
}
|
|
217
221
|
/**
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
* Get primary percentage
|
|
223
|
+
*/
|
|
220
224
|
get primaryPercentage() {
|
|
221
225
|
return this.getPercentage(this.primaryValue);
|
|
222
226
|
}
|
|
223
227
|
/**
|
|
224
|
-
|
|
225
|
-
|
|
228
|
+
* Get secondary percentage
|
|
229
|
+
*/
|
|
226
230
|
get secondaryPercentage() {
|
|
227
231
|
return this.getPercentage(this.secondaryValue);
|
|
228
232
|
}
|
|
@@ -273,8 +277,9 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
273
277
|
*/
|
|
274
278
|
update(changedProperties) {
|
|
275
279
|
super.update(changedProperties);
|
|
276
|
-
if (changedProperties.has('primaryValue') ||
|
|
277
|
-
|
|
280
|
+
if (changedProperties.has('primaryValue') ||
|
|
281
|
+
changedProperties.has('secondaryValue') ||
|
|
282
|
+
(this.primaryValue === 0 && this.secondaryValue === 0)) {
|
|
278
283
|
this.canvas.autoloop = true;
|
|
279
284
|
this.renderCanvas('frame');
|
|
280
285
|
this.animateCanvas();
|
|
@@ -285,9 +290,11 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
285
290
|
if (changedProperties.has('valueFormatter')) {
|
|
286
291
|
this.calculateValueFontSize();
|
|
287
292
|
}
|
|
288
|
-
if (changedProperties.has('primaryValue') ||
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
if (changedProperties.has('primaryValue') ||
|
|
294
|
+
changedProperties.has('secondaryValue') ||
|
|
295
|
+
changedProperties.has('primaryLabel') ||
|
|
296
|
+
changedProperties.has('secondaryLabel') ||
|
|
297
|
+
changedProperties.has('valueFormatter')) {
|
|
291
298
|
this.updateGaugePositions();
|
|
292
299
|
}
|
|
293
300
|
}
|
|
@@ -328,7 +335,8 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
328
335
|
*/
|
|
329
336
|
easeTo(to, from, time) {
|
|
330
337
|
const diff = (this.duration - (time - performance.now())) / this.duration;
|
|
331
|
-
this.fillPercentage =
|
|
338
|
+
this.fillPercentage =
|
|
339
|
+
from + (to - from) * canvasHelper.elasticOut(diff > 1 ? 1 : diff < 0 ? 0 : diff) || 0;
|
|
332
340
|
if (this.fillPercentage !== to) {
|
|
333
341
|
this.cancelFrame(this.requestedAnimationID);
|
|
334
342
|
this.requestedAnimationID = this.onFrame(() => this.easeTo(to, from, time));
|
|
@@ -408,7 +416,7 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
408
416
|
const reverseScale = 1 - this.scale;
|
|
409
417
|
// increase the offset by 25%, this for buffer to make label have some space from bottom
|
|
410
418
|
this.linePointerOffset = (containerHeight / gaugeHeight) * reverseScale * 1.25;
|
|
411
|
-
this.primaryLineRadian = PRIMARY_RADIAN + DEFAULT_OFFSET +
|
|
419
|
+
this.primaryLineRadian = PRIMARY_RADIAN + DEFAULT_OFFSET + OVERFLOW_OFFSET * reverseScale;
|
|
412
420
|
this.secondaryLineRadian = 3 - this.primaryLineRadian;
|
|
413
421
|
}
|
|
414
422
|
const primaryPosLine = this.getPositionStyle(Segment.PRIMARY, this.primaryLineRadian, this.linePointerOffset, 0);
|
|
@@ -528,7 +536,7 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
528
536
|
const offset = DEFAULT_OFFSET * reverseScale;
|
|
529
537
|
this.primaryLineRadian = PRIMARY_RADIAN + offset;
|
|
530
538
|
this.secondaryLineRadian = SECONDARY_RADIAN - offset;
|
|
531
|
-
this.linePointerOffset = LINE_POINTER_OFFSET +
|
|
539
|
+
this.linePointerOffset = LINE_POINTER_OFFSET + 0.4 * (1 - this.scale);
|
|
532
540
|
}
|
|
533
541
|
this.primaryLineRadian = this.primaryLineRadian > 1.3 ? 1.3 : this.primaryLineRadian;
|
|
534
542
|
this.secondaryLineRadian = this.primaryLineRadian > 1.7 ? 1.7 : this.secondaryLineRadian;
|
|
@@ -558,7 +566,8 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
558
566
|
minFontSize = MIN_LABEL_FONT_SIZE;
|
|
559
567
|
// buffer for word wrap
|
|
560
568
|
widthScale = 1.1;
|
|
561
|
-
longerLabel =
|
|
569
|
+
longerLabel =
|
|
570
|
+
this.primaryLabel.length > this.secondaryLabel.length ? this.primaryLabel : this.secondaryLabel;
|
|
562
571
|
fontSize = Math.ceil(this.scale * this.canvas.height * GAUGE_LABEL_FONT_SCALE);
|
|
563
572
|
}
|
|
564
573
|
else {
|
|
@@ -596,7 +605,10 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
596
605
|
if (!this.canvas.ctx) {
|
|
597
606
|
return;
|
|
598
607
|
}
|
|
599
|
-
this.labelStyle = {
|
|
608
|
+
this.labelStyle = {
|
|
609
|
+
maxWidth: `${this.lineLength}px`,
|
|
610
|
+
fontSize: `${this.calculateFontSize(this.canvas.ctx, TextType.LABEL)}px`
|
|
611
|
+
};
|
|
600
612
|
}
|
|
601
613
|
/**
|
|
602
614
|
* Update value font size
|
|
@@ -606,7 +618,10 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
606
618
|
if (!this.canvas.ctx) {
|
|
607
619
|
return;
|
|
608
620
|
}
|
|
609
|
-
this.valueStyle = {
|
|
621
|
+
this.valueStyle = {
|
|
622
|
+
maxWidth: `${this.lineLength}px`,
|
|
623
|
+
fontSize: `${this.calculateFontSize(this.canvas.ctx, TextType.VALUE)}px`
|
|
624
|
+
};
|
|
610
625
|
}
|
|
611
626
|
/**
|
|
612
627
|
* Compute percentage of value
|
|
@@ -617,7 +632,7 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
617
632
|
if (value === 0) {
|
|
618
633
|
return 0;
|
|
619
634
|
}
|
|
620
|
-
return 100 * value / (this.primaryValue + this.secondaryValue);
|
|
635
|
+
return (100 * value) / (this.primaryValue + this.secondaryValue);
|
|
621
636
|
}
|
|
622
637
|
/**
|
|
623
638
|
* Handles canvas resize
|
|
@@ -636,11 +651,10 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
636
651
|
get legendTemplate() {
|
|
637
652
|
return this.primaryLegend.length > 0 || this.secondaryLegend.length > 0
|
|
638
653
|
? html `<div part="legend-container-outer">
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
</div>`
|
|
654
|
+
<div part="legend-container-inner">
|
|
655
|
+
${this.primaryLegendTemplate} ${this.secondaryLegendTemplate}
|
|
656
|
+
</div>
|
|
657
|
+
</div>`
|
|
644
658
|
: null;
|
|
645
659
|
}
|
|
646
660
|
/**
|
|
@@ -650,9 +664,11 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
650
664
|
get primaryLegendTemplate() {
|
|
651
665
|
return this.primaryLegend
|
|
652
666
|
? html `<div part="primary-legend">
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
</
|
|
667
|
+
<span part="primary-legend-symbol"></span>
|
|
668
|
+
<ef-label max-line="${MAX_LEGEND_LINE}" line-clamp="${MAX_LEGEND_LINE}"
|
|
669
|
+
>${this.primaryLegend}</ef-label
|
|
670
|
+
>
|
|
671
|
+
</div>`
|
|
656
672
|
: null;
|
|
657
673
|
}
|
|
658
674
|
/**
|
|
@@ -662,9 +678,11 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
662
678
|
get secondaryLegendTemplate() {
|
|
663
679
|
return this.secondaryLegend
|
|
664
680
|
? html `<div part="secondary-legend">
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
</
|
|
681
|
+
<span part="secondary-legend-symbol"></span>
|
|
682
|
+
<ef-label max-line="${MAX_LEGEND_LINE}" line-clamp="${MAX_LEGEND_LINE}"
|
|
683
|
+
>${this.secondaryLegend}</ef-label
|
|
684
|
+
>
|
|
685
|
+
</div>`
|
|
668
686
|
: null;
|
|
669
687
|
}
|
|
670
688
|
render() {
|
|
@@ -674,38 +692,30 @@ let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
|
674
692
|
<div part="canvas-container">
|
|
675
693
|
<ef-canvas part="canvas" @resize=${this.onCanvasResize}></ef-canvas>
|
|
676
694
|
<div part="primary-container" style=${styleMap(this.primaryContainerStyle)}>
|
|
677
|
-
${this.primaryLabel
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
695
|
+
${this.primaryLabel
|
|
696
|
+
? html ` <ef-label
|
|
697
|
+
part="primary-label"
|
|
698
|
+
max-line="${MAX_LABEL_LINE}"
|
|
699
|
+
line-clamp="${MAX_LABEL_LINE}"
|
|
700
|
+
style=${styleMap(this.labelStyle)}
|
|
701
|
+
>${this.primaryLabel} </ef-label
|
|
702
|
+
><br />`
|
|
685
703
|
: null}
|
|
686
|
-
<ef-label
|
|
687
|
-
part="primary-value"
|
|
688
|
-
truncate=""
|
|
689
|
-
line-clamp="1"
|
|
690
|
-
style=${styleMap(this.valueStyle)}
|
|
704
|
+
<ef-label part="primary-value" truncate="" line-clamp="1" style=${styleMap(this.valueStyle)}
|
|
691
705
|
>${this.valueFormatter(this.primaryPercentage, this.primaryValue)}</ef-label
|
|
692
706
|
>
|
|
693
707
|
</div>
|
|
694
708
|
<div part="secondary-container" style=${styleMap(this.secondaryContainerStyle)}>
|
|
695
|
-
${this.secondaryLabel
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
709
|
+
${this.secondaryLabel
|
|
710
|
+
? html ` <ef-label
|
|
711
|
+
part="secondary-label"
|
|
712
|
+
max-line="${MAX_LABEL_LINE}"
|
|
713
|
+
line-clamp="${MAX_LABEL_LINE}"
|
|
714
|
+
style=${styleMap(this.labelStyle)}
|
|
715
|
+
>${this.secondaryLabel} </ef-label
|
|
716
|
+
><br />`
|
|
703
717
|
: null}
|
|
704
|
-
<ef-label
|
|
705
|
-
part="secondary-value"
|
|
706
|
-
truncate=""
|
|
707
|
-
line-clamp="1"
|
|
708
|
-
style=${styleMap(this.valueStyle)}
|
|
718
|
+
<ef-label part="secondary-value" truncate="" line-clamp="1" style=${styleMap(this.valueStyle)}
|
|
709
719
|
>${this.valueFormatter(this.secondaryPercentage, this.secondaryValue)}</ef-label
|
|
710
720
|
>
|
|
711
721
|
</div>
|
package/lib/tab/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSXInterface } from '../jsx';
|
|
2
|
-
import {
|
|
2
|
+
import { CSSResultGroup, ControlElement, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
|
|
3
3
|
import '../icon/index.js';
|
|
4
4
|
import '../label/index.js';
|
|
5
5
|
/**
|
package/lib/tab/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { ControlElement, css, html } from '@refinitiv-ui/core';
|
|
3
|
+
import { triggerResize } from '@refinitiv-ui/core';
|
|
3
4
|
import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
|
|
4
5
|
import { property } from '@refinitiv-ui/core/decorators/property.js';
|
|
5
6
|
import { state } from '@refinitiv-ui/core/decorators/state.js';
|
|
6
7
|
import { isSlotEmpty } from '@refinitiv-ui/utils/is-slot-empty.js';
|
|
7
|
-
import { triggerResize } from '@refinitiv-ui/core';
|
|
8
|
-
import { VERSION } from '../version.js';
|
|
9
8
|
import '../icon/index.js';
|
|
10
9
|
import '../label/index.js';
|
|
10
|
+
import { VERSION } from '../version.js';
|
|
11
11
|
/**
|
|
12
12
|
* A building block for individual tab
|
|
13
13
|
* @attr {boolean} disabled - Set disabled state
|
|
@@ -153,11 +153,13 @@ let Tab = class Tab extends ControlElement {
|
|
|
153
153
|
* @returns close button template
|
|
154
154
|
*/
|
|
155
155
|
get CloseTemplate() {
|
|
156
|
-
return this.clears || this.clearsOnHover
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
return this.clears || this.clearsOnHover
|
|
157
|
+
? html `
|
|
158
|
+
<div part="close-container">
|
|
159
|
+
<ef-icon part="close" icon="cross" @tap="${this.handleClickClear}"></ef-icon>
|
|
160
|
+
</div>
|
|
161
|
+
`
|
|
162
|
+
: null;
|
|
161
163
|
}
|
|
162
164
|
/**
|
|
163
165
|
* Create ef-label template when label is true
|
|
@@ -167,13 +169,7 @@ let Tab = class Tab extends ControlElement {
|
|
|
167
169
|
if (!this.label || this.isSlotHasContent) {
|
|
168
170
|
return null;
|
|
169
171
|
}
|
|
170
|
-
return html `
|
|
171
|
-
<ef-label
|
|
172
|
-
part="label"
|
|
173
|
-
.lineClamp=${this.getLineClamp()}>
|
|
174
|
-
${this.label}
|
|
175
|
-
</ef-label>
|
|
176
|
-
`;
|
|
172
|
+
return html ` <ef-label part="label" .lineClamp=${this.getLineClamp()}> ${this.label} </ef-label> `;
|
|
177
173
|
}
|
|
178
174
|
/**
|
|
179
175
|
* Create ef-label template when subLabel is true
|
|
@@ -183,13 +179,7 @@ let Tab = class Tab extends ControlElement {
|
|
|
183
179
|
if (!this.subLabel || this.isSlotHasContent) {
|
|
184
180
|
return null;
|
|
185
181
|
}
|
|
186
|
-
return html `
|
|
187
|
-
<ef-label
|
|
188
|
-
part="sub-label"
|
|
189
|
-
.lineClamp=${this.getLineClamp()}>
|
|
190
|
-
${this.subLabel}
|
|
191
|
-
</ef-label>
|
|
192
|
-
`;
|
|
182
|
+
return html ` <ef-label part="sub-label" .lineClamp=${this.getLineClamp()}> ${this.subLabel} </ef-label> `;
|
|
193
183
|
}
|
|
194
184
|
/**
|
|
195
185
|
* A `TemplateResult` that will be used
|
|
@@ -199,11 +189,10 @@ let Tab = class Tab extends ControlElement {
|
|
|
199
189
|
render() {
|
|
200
190
|
return html `
|
|
201
191
|
${this.icon ? html `<ef-icon icon=${this.icon} part="icon"></ef-icon>` : null}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
</div>
|
|
192
|
+
<div part="label-container">
|
|
193
|
+
${this.LabelTemplate} ${this.SubLabelTemplate}
|
|
194
|
+
<slot @slotchange="${this.onSlotChange}"></slot>
|
|
195
|
+
</div>
|
|
207
196
|
${this.CloseTemplate}
|
|
208
197
|
`;
|
|
209
198
|
}
|