@refinitiv-ui/elements 6.15.5 → 6.16.1
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 +12 -0
- package/lib/datetime-picker/index.d.ts +5 -0
- package/lib/datetime-picker/index.js +23 -3
- package/lib/heatmap/custom-elements.json +15 -2
- package/lib/heatmap/custom-elements.md +14 -13
- package/lib/heatmap/helpers/text.d.ts +3 -3
- package/lib/heatmap/helpers/text.js +5 -5
- package/lib/heatmap/index.d.ts +8 -4
- package/lib/heatmap/index.js +19 -10
- package/lib/version.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.16.1](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@6.16.0...@refinitiv-ui/elements@6.16.1) (2024-03-12)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **datetime-picker:** validate values for weekendsonly and weekdaysonly ([#1118](https://github.com/Refinitiv/refinitiv-ui/issues/1118)) ([fec6814](https://github.com/Refinitiv/refinitiv-ui/commit/fec6814e77d703da9f4021052da9d4e2d678db46))
|
|
11
|
+
|
|
12
|
+
# [6.16.0](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@6.15.5...@refinitiv-ui/elements@6.16.0) (2024-02-27)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **heatmap:** add new config in Heatmap to customise maximum font size in the cells ([bb0b767](https://github.com/Refinitiv/refinitiv-ui/commit/bb0b7674f479b62c5699b2027086df9704eafcd9))
|
|
17
|
+
|
|
6
18
|
## [6.15.5](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@6.15.4...@refinitiv-ui/elements@6.15.5) (2024-02-19)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @refinitiv-ui/elements
|
|
@@ -427,6 +427,11 @@ export declare class DatetimePicker extends FormFieldElement implements MultiVal
|
|
|
427
427
|
* @returns true if `from` is before or the same as `to`
|
|
428
428
|
*/
|
|
429
429
|
private isFromBeforeTo;
|
|
430
|
+
/**
|
|
431
|
+
* Check if `values` correspond to dates that are allowed within the conditions of weekdays or weekends
|
|
432
|
+
* @returns false if `values` don't correspond to dates that are allowed within the conditions of weekdays or weekends.
|
|
433
|
+
*/
|
|
434
|
+
private isValidDay;
|
|
430
435
|
/**
|
|
431
436
|
* Check if datetime picker has an error
|
|
432
437
|
* @returns true if error
|
|
@@ -8,7 +8,7 @@ import { property } from '@refinitiv-ui/core/decorators/property.js';
|
|
|
8
8
|
import { query } from '@refinitiv-ui/core/decorators/query.js';
|
|
9
9
|
import '@refinitiv-ui/phrasebook/locale/en/datetime-picker.js';
|
|
10
10
|
import { TranslatePropertyKey, getLocale, translate } from '@refinitiv-ui/translate';
|
|
11
|
-
import { DateFormat, DateTimeFormat, addMonths, format, isAfter, isBefore, isValidDate, isValidDateTime, parse, subMonths } from '@refinitiv-ui/utils/date.js';
|
|
11
|
+
import { DateFormat, DateTimeFormat, addMonths, format, isAfter, isBefore, isValidDate, isValidDateTime, isWeekend, parse, subMonths } from '@refinitiv-ui/utils/date.js';
|
|
12
12
|
import '../calendar/index.js';
|
|
13
13
|
import '../icon/index.js';
|
|
14
14
|
import { preload } from '../icon/index.js';
|
|
@@ -443,7 +443,9 @@ let DatetimePicker = class DatetimePicker extends FormFieldElement {
|
|
|
443
443
|
if ((changedProperties.has('_values') && changedProperties.get('_values') !== undefined) ||
|
|
444
444
|
(changedProperties.has('min') && changedProperties.get('min') !== undefined) ||
|
|
445
445
|
(changedProperties.has('max') && changedProperties.get('max') !== undefined) ||
|
|
446
|
-
(changedProperties.has('showSeconds') && changedProperties.get('showSeconds') !== undefined)
|
|
446
|
+
(changedProperties.has('showSeconds') && changedProperties.get('showSeconds') !== undefined) ||
|
|
447
|
+
(changedProperties.has('weekdaysOnly') && changedProperties.get('weekdaysOnly') !== undefined) ||
|
|
448
|
+
(changedProperties.has('weekendsOnly') && changedProperties.get('weekendsOnly') !== undefined)) {
|
|
447
449
|
return true;
|
|
448
450
|
}
|
|
449
451
|
return false;
|
|
@@ -898,12 +900,30 @@ let DatetimePicker = class DatetimePicker extends FormFieldElement {
|
|
|
898
900
|
}
|
|
899
901
|
return true;
|
|
900
902
|
}
|
|
903
|
+
/**
|
|
904
|
+
* Check if `values` correspond to dates that are allowed within the conditions of weekdays or weekends
|
|
905
|
+
* @returns false if `values` don't correspond to dates that are allowed within the conditions of weekdays or weekends.
|
|
906
|
+
*/
|
|
907
|
+
isValidDay() {
|
|
908
|
+
for (const value of this.values) {
|
|
909
|
+
if (this.weekdaysOnly && isWeekend(value)) {
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
if (this.weekendsOnly && !isWeekend(value)) {
|
|
913
|
+
return false;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return true;
|
|
917
|
+
}
|
|
901
918
|
/**
|
|
902
919
|
* Check if datetime picker has an error
|
|
903
920
|
* @returns true if error
|
|
904
921
|
*/
|
|
905
922
|
hasError() {
|
|
906
|
-
return !(this.isValidFormat() &&
|
|
923
|
+
return !(this.isValidFormat() &&
|
|
924
|
+
this.isValueWithinMinMax() &&
|
|
925
|
+
this.isFromBeforeTo() &&
|
|
926
|
+
this.isValidDay());
|
|
907
927
|
}
|
|
908
928
|
/**
|
|
909
929
|
* Toggles the opened state of the list
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"name": "label-width",
|
|
15
|
-
"description": "
|
|
15
|
+
"description": "Set minimum text length to be shown on cells. Unit in pixel.\ne.g. label-width = 30; cell's label is hidden when text length is less than 30px.",
|
|
16
16
|
"type": "number",
|
|
17
17
|
"default": "0"
|
|
18
18
|
},
|
|
@@ -57,6 +57,12 @@
|
|
|
57
57
|
"description": "Cell minimum color saturation, value can be from 0 - 1",
|
|
58
58
|
"type": "number",
|
|
59
59
|
"default": "0.4"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "label-max-font-size",
|
|
63
|
+
"description": "Maximum font size of label in cells, value in pixel unit e.g. 18",
|
|
64
|
+
"type": "number",
|
|
65
|
+
"default": "16"
|
|
60
66
|
}
|
|
61
67
|
],
|
|
62
68
|
"properties": [
|
|
@@ -69,7 +75,7 @@
|
|
|
69
75
|
{
|
|
70
76
|
"name": "labelWidth",
|
|
71
77
|
"attribute": "label-width",
|
|
72
|
-
"description": "
|
|
78
|
+
"description": "Set minimum text length to be shown on cells. Unit in pixel.\ne.g. label-width = 30; cell's label is hidden when text length is less than 30px.",
|
|
73
79
|
"type": "number",
|
|
74
80
|
"default": "0"
|
|
75
81
|
},
|
|
@@ -122,6 +128,13 @@
|
|
|
122
128
|
"type": "number",
|
|
123
129
|
"default": "0.4"
|
|
124
130
|
},
|
|
131
|
+
{
|
|
132
|
+
"name": "labelMaxFontSize",
|
|
133
|
+
"attribute": "label-max-font-size",
|
|
134
|
+
"description": "Maximum font size of label in cells, value in pixel unit e.g. 18",
|
|
135
|
+
"type": "number",
|
|
136
|
+
"default": "16"
|
|
137
|
+
},
|
|
125
138
|
{
|
|
126
139
|
"name": "tooltipCallback",
|
|
127
140
|
"description": "A callback function that allows tooltip rendering on cell hover",
|
|
@@ -5,19 +5,20 @@ values contained in a matrix are represented as colors
|
|
|
5
5
|
|
|
6
6
|
## Properties
|
|
7
7
|
|
|
8
|
-
| Property
|
|
9
|
-
|
|
10
|
-
| `axisHidden`
|
|
11
|
-
| `blend`
|
|
12
|
-
| `config`
|
|
13
|
-
| `labelHidden`
|
|
14
|
-
| `
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
8
|
+
| Property | Attribute | Type | Default | Description |
|
|
9
|
+
|--------------------|-----------------------|--------------------------|---------|--------------------------------------------------|
|
|
10
|
+
| `axisHidden` | `axis-hidden` | `boolean` | false | Hide all axes |
|
|
11
|
+
| `blend` | `blend` | `boolean` | false | Enable cell color blending |
|
|
12
|
+
| `config` | `config` | `HeatmapConfig` | null | Heatmap configuration options. |
|
|
13
|
+
| `labelHidden` | `label-hidden` | `boolean` | false | Hide all labels in the cells |
|
|
14
|
+
| `labelMaxFontSize` | `label-max-font-size` | `number` | 16 | Maximum font size of label in cells, value in pixel unit e.g. 18 |
|
|
15
|
+
| `labelWidth` | `label-width` | `number` | 0 | Set minimum text length to be shown on cells. Unit in pixel.<br />e.g. label-width = 30; cell's label is hidden when text length is less than 30px. |
|
|
16
|
+
| `maxPoint` | `max-point` | `number` | 1 | Maximum point of the cell coloring |
|
|
17
|
+
| `midPoint` | `mid-point` | `number` | 0 | Middle point of the cell coloring |
|
|
18
|
+
| `minPoint` | `min-point` | `number` | -1 | Minimum point of the cell coloring |
|
|
19
|
+
| `renderCallback` | | `HeatmapRenderCallback` | | Render callback function use for custom cell properties.<br />Accepts custom label, foreground and background color |
|
|
20
|
+
| `saturation` | `saturation` | `number` | 0.4 | Cell minimum color saturation, value can be from 0 - 1 |
|
|
21
|
+
| `tooltipCallback` | | `HeatmapTooltipCallback` | | A callback function that allows tooltip rendering on cell hover |
|
|
21
22
|
|
|
22
23
|
## Methods
|
|
23
24
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { HeatmapCell } from './types';
|
|
2
2
|
declare const MIN_FONT_SIZE = 12;
|
|
3
|
-
declare const MAX_FONT_SIZE = 16;
|
|
4
3
|
/**
|
|
5
4
|
* Calculate responsive font size according to the screen width
|
|
6
5
|
* @param ratio font ratio
|
|
7
6
|
* @param cellHeight cell's height
|
|
8
7
|
* @param cellWidth cell's width
|
|
8
|
+
* @param cellMaxFontSize cell's max font size
|
|
9
9
|
* @returns font size
|
|
10
10
|
*/
|
|
11
|
-
declare const getResponsiveFontSize: (ratio: number, cellHeight: number, cellWidth: number) => number;
|
|
11
|
+
declare const getResponsiveFontSize: (ratio: number, cellHeight: number, cellWidth: number, cellMaxFontSize: number) => number;
|
|
12
12
|
/**
|
|
13
13
|
* Get maximum text width out of all the cell by sampling
|
|
14
14
|
* @param ctx canvas context
|
|
@@ -17,4 +17,4 @@ declare const getResponsiveFontSize: (ratio: number, cellHeight: number, cellWid
|
|
|
17
17
|
* @returns label width measured in canvas
|
|
18
18
|
*/
|
|
19
19
|
declare const getMaximumTextWidth: (ctx: CanvasRenderingContext2D, cells: HeatmapCell[], hasCellHeader: boolean) => number;
|
|
20
|
-
export { getResponsiveFontSize, getMaximumTextWidth, MIN_FONT_SIZE
|
|
20
|
+
export { getResponsiveFontSize, getMaximumTextWidth, MIN_FONT_SIZE };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const MIN_FONT_SIZE = 12;
|
|
2
|
-
const MAX_FONT_SIZE = 16;
|
|
3
2
|
/**
|
|
4
3
|
* Calculate responsive font size according to the screen width
|
|
5
4
|
* @param ratio font ratio
|
|
6
5
|
* @param cellHeight cell's height
|
|
7
6
|
* @param cellWidth cell's width
|
|
7
|
+
* @param cellMaxFontSize cell's max font size
|
|
8
8
|
* @returns font size
|
|
9
9
|
*/
|
|
10
|
-
const getResponsiveFontSize = (ratio, cellHeight, cellWidth) => {
|
|
10
|
+
const getResponsiveFontSize = (ratio, cellHeight, cellWidth, cellMaxFontSize) => {
|
|
11
11
|
let fontSize = Math.round(Math.min(cellHeight, cellWidth) * ratio);
|
|
12
12
|
if (fontSize < MIN_FONT_SIZE) {
|
|
13
13
|
fontSize = MIN_FONT_SIZE;
|
|
14
14
|
}
|
|
15
|
-
else if (fontSize >
|
|
16
|
-
fontSize =
|
|
15
|
+
else if (fontSize > cellMaxFontSize) {
|
|
16
|
+
fontSize = cellMaxFontSize;
|
|
17
17
|
}
|
|
18
18
|
return fontSize;
|
|
19
19
|
};
|
|
@@ -71,4 +71,4 @@ const getMaximumTextWidth = (ctx, cells, hasCellHeader) => {
|
|
|
71
71
|
}
|
|
72
72
|
return maxTextWidth;
|
|
73
73
|
};
|
|
74
|
-
export { getResponsiveFontSize, getMaximumTextWidth, MIN_FONT_SIZE
|
|
74
|
+
export { getResponsiveFontSize, getMaximumTextWidth, MIN_FONT_SIZE };
|
package/lib/heatmap/index.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export declare class Heatmap extends ResponsiveElement {
|
|
|
27
27
|
*/
|
|
28
28
|
config: HeatmapConfig | null;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* e.g. label-width
|
|
30
|
+
* Set minimum text length to be shown on cells. Unit in pixel.
|
|
31
|
+
* e.g. label-width = 30; cell's label is hidden when text length is less than 30px.
|
|
32
32
|
*/
|
|
33
33
|
labelWidth: number;
|
|
34
34
|
/**
|
|
@@ -65,6 +65,10 @@ export declare class Heatmap extends ResponsiveElement {
|
|
|
65
65
|
* Cell minimum color saturation, value can be from 0 - 1
|
|
66
66
|
*/
|
|
67
67
|
saturation: number;
|
|
68
|
+
/**
|
|
69
|
+
* Maximum font size of label in cells, value in pixel unit e.g. 18
|
|
70
|
+
*/
|
|
71
|
+
labelMaxFontSize: number;
|
|
68
72
|
/**
|
|
69
73
|
* Returns data of interactive cell
|
|
70
74
|
* @param {MouseEvent} event A MouseEvent that occurs when Heatmap is being interacted
|
|
@@ -330,9 +334,9 @@ export declare class Heatmap extends ResponsiveElement {
|
|
|
330
334
|
*/
|
|
331
335
|
private paintAllLabel;
|
|
332
336
|
/**
|
|
333
|
-
* Calculates space between header and label
|
|
334
|
-
* Maximum 10 pixels
|
|
337
|
+
* Calculates space between header and label
|
|
335
338
|
* @param cellHeight in pixels
|
|
339
|
+
* @param cellWidth in pixels
|
|
336
340
|
* @returns in pixels
|
|
337
341
|
*/
|
|
338
342
|
private calculateHeaderMargin;
|
package/lib/heatmap/index.js
CHANGED
|
@@ -149,8 +149,8 @@ let Heatmap = class Heatmap extends ResponsiveElement {
|
|
|
149
149
|
*/
|
|
150
150
|
this.config = null;
|
|
151
151
|
/**
|
|
152
|
-
*
|
|
153
|
-
* e.g. label-width
|
|
152
|
+
* Set minimum text length to be shown on cells. Unit in pixel.
|
|
153
|
+
* e.g. label-width = 30; cell's label is hidden when text length is less than 30px.
|
|
154
154
|
*/
|
|
155
155
|
this.labelWidth = 0;
|
|
156
156
|
/**
|
|
@@ -181,6 +181,10 @@ let Heatmap = class Heatmap extends ResponsiveElement {
|
|
|
181
181
|
* Cell minimum color saturation, value can be from 0 - 1
|
|
182
182
|
*/
|
|
183
183
|
this.saturation = 0.4;
|
|
184
|
+
/**
|
|
185
|
+
* Maximum font size of label in cells, value in pixel unit e.g. 18
|
|
186
|
+
*/
|
|
187
|
+
this.labelMaxFontSize = 16;
|
|
184
188
|
/**
|
|
185
189
|
* Current active cell
|
|
186
190
|
*/
|
|
@@ -630,14 +634,16 @@ let Heatmap = class Heatmap extends ResponsiveElement {
|
|
|
630
634
|
}
|
|
631
635
|
}
|
|
632
636
|
/**
|
|
633
|
-
* Calculates space between header and label
|
|
634
|
-
* Maximum 10 pixels
|
|
637
|
+
* Calculates space between header and label
|
|
635
638
|
* @param cellHeight in pixels
|
|
639
|
+
* @param cellWidth in pixels
|
|
636
640
|
* @returns in pixels
|
|
637
641
|
*/
|
|
638
|
-
calculateHeaderMargin(cellHeight) {
|
|
639
|
-
const margin =
|
|
640
|
-
|
|
642
|
+
calculateHeaderMargin(cellHeight, cellWidth) {
|
|
643
|
+
const margin = 18; // maximum margin
|
|
644
|
+
const maxValue = Math.max(cellHeight, cellWidth);
|
|
645
|
+
const minValue = Math.min(cellHeight, cellWidth);
|
|
646
|
+
return margin / (maxValue / minValue);
|
|
641
647
|
}
|
|
642
648
|
/**
|
|
643
649
|
* Paints label to a single cell
|
|
@@ -653,7 +659,7 @@ let Heatmap = class Heatmap extends ResponsiveElement {
|
|
|
653
659
|
cell.foregroundColor === undefined) {
|
|
654
660
|
return;
|
|
655
661
|
}
|
|
656
|
-
const margin = cell.header ? this.calculateHeaderMargin(cell.height) : 0;
|
|
662
|
+
const margin = cell.header ? this.calculateHeaderMargin(cell.height, cell.width) : 0;
|
|
657
663
|
const label = typeof cell.customLabel === 'string' ? cell.customLabel : cell.label;
|
|
658
664
|
this.canvasContext.fillStyle = cell.customForegroundColor || cell.foregroundColor;
|
|
659
665
|
this.canvasContext.fillText(label || '', cell.x + cell.width / 2, cell.y + 1 + cell.height / 2 + margin);
|
|
@@ -676,7 +682,7 @@ let Heatmap = class Heatmap extends ResponsiveElement {
|
|
|
676
682
|
this.contentWithinCellBoundary = false;
|
|
677
683
|
return this.contentWithinCellBoundary;
|
|
678
684
|
}
|
|
679
|
-
let fontSize = getResponsiveFontSize(fontRatio, contentHeight, contentWidth);
|
|
685
|
+
let fontSize = getResponsiveFontSize(fontRatio, contentHeight, contentWidth, this.labelMaxFontSize);
|
|
680
686
|
canvas.textAlign = 'center';
|
|
681
687
|
canvas.textBaseline = 'middle';
|
|
682
688
|
canvas.font = `${fontSize}px ${fontFamily}`;
|
|
@@ -812,7 +818,7 @@ let Heatmap = class Heatmap extends ResponsiveElement {
|
|
|
812
818
|
return;
|
|
813
819
|
}
|
|
814
820
|
const labelFontStyle = this.canvasContext.font;
|
|
815
|
-
const margin = this.labelHidden ? 0 : this.calculateHeaderMargin(cell.height);
|
|
821
|
+
const margin = this.labelHidden ? 0 : this.calculateHeaderMargin(cell.height, cell.width);
|
|
816
822
|
this.canvasContext.font = 'bold ' + labelFontStyle;
|
|
817
823
|
this.canvasContext.fillStyle = cell.customForegroundColor || cell.foregroundColor;
|
|
818
824
|
this.canvasContext.fillText(cell.header || '', cell.x + cell.width / 2, cell.y + 1 + cell.height / 2 - margin);
|
|
@@ -1098,6 +1104,9 @@ __decorate([
|
|
|
1098
1104
|
__decorate([
|
|
1099
1105
|
property({ type: Number })
|
|
1100
1106
|
], Heatmap.prototype, "saturation", void 0);
|
|
1107
|
+
__decorate([
|
|
1108
|
+
property({ type: Number, attribute: 'label-max-font-size' })
|
|
1109
|
+
], Heatmap.prototype, "labelMaxFontSize", void 0);
|
|
1101
1110
|
__decorate([
|
|
1102
1111
|
property({ attribute: false })
|
|
1103
1112
|
], Heatmap.prototype, "tooltipCallback", void 0);
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '6.
|
|
1
|
+
export const VERSION = '6.16.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refinitiv-ui/elements",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.16.1",
|
|
4
4
|
"description": "Element Framework Elements",
|
|
5
5
|
"author": "LSEG",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -370,5 +370,5 @@
|
|
|
370
370
|
"publishConfig": {
|
|
371
371
|
"access": "public"
|
|
372
372
|
},
|
|
373
|
-
"gitHead": "
|
|
373
|
+
"gitHead": "c3bf39341ad3fe6264c27e083e914717744f3a49"
|
|
374
374
|
}
|