@refinitiv-ui/elements 7.10.5 → 7.10.7

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 CHANGED
@@ -3,6 +3,16 @@
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
+ ## [7.10.7](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@7.10.6...@refinitiv-ui/elements@7.10.7) (2024-03-12)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **datetime-picker:** validate values for weekendsonly and weekdaysonly ([#1117](https://github.com/Refinitiv/refinitiv-ui/issues/1117)) ([0898814](https://github.com/Refinitiv/refinitiv-ui/commit/089881482effc70cf9e2b47f3148b44140ce37a2))
11
+
12
+ ## [7.10.6](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@7.10.5...@refinitiv-ui/elements@7.10.6) (2024-02-27)
13
+
14
+ **Note:** Version bump only for package @refinitiv-ui/elements
15
+
6
16
  ## [7.10.5](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@7.10.4...@refinitiv-ui/elements@7.10.5) (2024-02-19)
7
17
 
8
18
  **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 '../overlay/index.js';
@@ -442,7 +442,9 @@ let DatetimePicker = class DatetimePicker extends FormFieldElement {
442
442
  if ((changedProperties.has('_values') && changedProperties.get('_values') !== undefined) ||
443
443
  (changedProperties.has('min') && changedProperties.get('min') !== undefined) ||
444
444
  (changedProperties.has('max') && changedProperties.get('max') !== undefined) ||
445
- (changedProperties.has('showSeconds') && changedProperties.get('showSeconds') !== undefined)) {
445
+ (changedProperties.has('showSeconds') && changedProperties.get('showSeconds') !== undefined) ||
446
+ (changedProperties.has('weekdaysOnly') && changedProperties.get('weekdaysOnly') !== undefined) ||
447
+ (changedProperties.has('weekendsOnly') && changedProperties.get('weekendsOnly') !== undefined)) {
446
448
  return true;
447
449
  }
448
450
  return false;
@@ -893,12 +895,30 @@ let DatetimePicker = class DatetimePicker extends FormFieldElement {
893
895
  }
894
896
  return true;
895
897
  }
898
+ /**
899
+ * Check if `values` correspond to dates that are allowed within the conditions of weekdays or weekends
900
+ * @returns false if `values` don't correspond to dates that are allowed within the conditions of weekdays or weekends.
901
+ */
902
+ isValidDay() {
903
+ for (const value of this.values) {
904
+ if (this.weekdaysOnly && isWeekend(value)) {
905
+ return false;
906
+ }
907
+ if (this.weekendsOnly && !isWeekend(value)) {
908
+ return false;
909
+ }
910
+ }
911
+ return true;
912
+ }
896
913
  /**
897
914
  * Check if datetime picker has an error
898
915
  * @returns true if error
899
916
  */
900
917
  hasError() {
901
- return !(this.isValidFormat() && this.isValueWithinMinMax() && this.isFromBeforeTo());
918
+ return !(this.isValidFormat() &&
919
+ this.isValueWithinMinMax() &&
920
+ this.isFromBeforeTo() &&
921
+ this.isValidDay());
902
922
  }
903
923
  /**
904
924
  * Toggles the opened state of the list
@@ -12,7 +12,7 @@
12
12
  },
13
13
  {
14
14
  "name": "label-width",
15
- "description": "Number of maximum label width that cell can paint in pixel.\ne.g. label-width: 30px; cell label hides when text length reaches 30px.",
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": "Number of maximum label width that cell can paint in pixel.\ne.g. label-width: 30px; cell label hides when text length reaches 30px.",
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 | 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
- | `labelWidth` | `label-width` | `number` | 0 | Number of maximum label width that cell can paint in pixel.<br />e.g. label-width: 30px; cell label hides when text length reaches 30px. |
15
- | `maxPoint` | `max-point` | `number` | 1 | Maximum point of the cell coloring |
16
- | `midPoint` | `mid-point` | `number` | 0 | Middle point of the cell coloring |
17
- | `minPoint` | `min-point` | `number` | -1 | Minimum point of the cell coloring |
18
- | `renderCallback` | | `HeatmapRenderCallback` | | Render callback function use for custom cell properties.<br />Accepts custom label, foreground and background color |
19
- | `saturation` | `saturation` | `number` | 0.4 | Cell minimum color saturation, value can be from 0 - 1 |
20
- | `tooltipCallback` | | `HeatmapTooltipCallback` | | A callback function that allows tooltip rendering on cell hover |
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, MAX_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 > MAX_FONT_SIZE) {
16
- fontSize = MAX_FONT_SIZE;
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, MAX_FONT_SIZE };
74
+ export { getResponsiveFontSize, getMaximumTextWidth, MIN_FONT_SIZE };
@@ -27,8 +27,8 @@ export declare class Heatmap extends ResponsiveElement {
27
27
  */
28
28
  config: HeatmapConfig | null;
29
29
  /**
30
- * Number of maximum label width that cell can paint in pixel.
31
- * e.g. label-width: 30px; cell label hides when text length reaches 30px.
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 using cell's height
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;
@@ -148,8 +148,8 @@ let Heatmap = class Heatmap extends ResponsiveElement {
148
148
  */
149
149
  this.config = null;
150
150
  /**
151
- * Number of maximum label width that cell can paint in pixel.
152
- * e.g. label-width: 30px; cell label hides when text length reaches 30px.
151
+ * Set minimum text length to be shown on cells. Unit in pixel.
152
+ * e.g. label-width = 30; cell's label is hidden when text length is less than 30px.
153
153
  */
154
154
  this.labelWidth = 0;
155
155
  /**
@@ -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
  */
@@ -638,14 +642,16 @@ let Heatmap = class Heatmap extends ResponsiveElement {
638
642
  }
639
643
  }
640
644
  /**
641
- * Calculates space between header and label using cell's height
642
- * Maximum 10 pixels
645
+ * Calculates space between header and label
643
646
  * @param cellHeight in pixels
647
+ * @param cellWidth in pixels
644
648
  * @returns in pixels
645
649
  */
646
- calculateHeaderMargin(cellHeight) {
647
- const margin = (cellHeight / 10) * 2;
648
- return margin > 10 ? 10 : margin;
650
+ calculateHeaderMargin(cellHeight, cellWidth) {
651
+ const margin = 18; // maximum margin
652
+ const maxValue = Math.max(cellHeight, cellWidth);
653
+ const minValue = Math.min(cellHeight, cellWidth);
654
+ return margin / (maxValue / minValue);
649
655
  }
650
656
  /**
651
657
  * Paints label to a single cell
@@ -661,7 +667,7 @@ let Heatmap = class Heatmap extends ResponsiveElement {
661
667
  cell.foregroundColor === undefined) {
662
668
  return;
663
669
  }
664
- const margin = cell.header ? this.calculateHeaderMargin(cell.height) : 0;
670
+ const margin = cell.header ? this.calculateHeaderMargin(cell.height, cell.width) : 0;
665
671
  const label = typeof cell.customLabel === 'string' ? cell.customLabel : cell.label;
666
672
  this.canvasContext.fillStyle = cell.customForegroundColor || cell.foregroundColor;
667
673
  this.canvasContext.fillText(label || '', cell.x + cell.width / 2, cell.y + 1 + cell.height / 2 + margin);
@@ -684,7 +690,7 @@ let Heatmap = class Heatmap extends ResponsiveElement {
684
690
  this.contentWithinCellBoundary = false;
685
691
  return this.contentWithinCellBoundary;
686
692
  }
687
- let fontSize = getResponsiveFontSize(fontRatio, contentHeight, contentWidth);
693
+ let fontSize = getResponsiveFontSize(fontRatio, contentHeight, contentWidth, this.labelMaxFontSize);
688
694
  canvas.textAlign = 'center';
689
695
  canvas.textBaseline = 'middle';
690
696
  canvas.font = `${fontSize}px ${fontFamily}`;
@@ -823,7 +829,7 @@ let Heatmap = class Heatmap extends ResponsiveElement {
823
829
  return;
824
830
  }
825
831
  const labelFontStyle = this.canvasContext.font;
826
- const margin = this.labelHidden ? 0 : this.calculateHeaderMargin(cell.height);
832
+ const margin = this.labelHidden ? 0 : this.calculateHeaderMargin(cell.height, cell.width);
827
833
  this.canvasContext.font = 'bold ' + labelFontStyle;
828
834
  this.canvasContext.fillStyle = cell.customForegroundColor || cell.foregroundColor;
829
835
  this.canvasContext.fillText(cell.header || '', cell.x + cell.width / 2, cell.y + 1 + cell.height / 2 - margin);
@@ -1112,6 +1118,9 @@ __decorate([
1112
1118
  __decorate([
1113
1119
  property({ type: Number })
1114
1120
  ], Heatmap.prototype, "saturation", void 0);
1121
+ __decorate([
1122
+ property({ type: Number, attribute: 'label-max-font-size' })
1123
+ ], Heatmap.prototype, "labelMaxFontSize", void 0);
1115
1124
  __decorate([
1116
1125
  property({ attribute: false })
1117
1126
  ], Heatmap.prototype, "tooltipCallback", void 0);
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '7.10.5';
1
+ export const VERSION = '7.10.7';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@refinitiv-ui/elements",
3
- "version": "7.10.5",
3
+ "version": "7.10.7",
4
4
  "description": "Element Framework Elements",
5
5
  "author": "LSEG",
6
6
  "license": "Apache-2.0",
@@ -344,7 +344,7 @@
344
344
  "@lit-labs/context": "^0.3.1",
345
345
  "@refinitiv-ui/halo-theme": "^7.3.5",
346
346
  "@refinitiv-ui/solar-theme": "^7.2.6",
347
- "chart.js": "^4.3.0",
347
+ "chart.js": "^4.4.2",
348
348
  "chartjs-adapter-date-fns": "^3.0.0",
349
349
  "d3-interpolate": "^3.0.1",
350
350
  "date-fns": "^2.29.3",
@@ -373,5 +373,5 @@
373
373
  "publishConfig": {
374
374
  "access": "public"
375
375
  },
376
- "gitHead": "6820b961ecc0ad1517ef94807df775eceb4f91db"
376
+ "gitHead": "95774e711a8ad9898e4cb12aa97e050622d593ac"
377
377
  }