@refinitiv-ui/elements 6.16.0 → 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 CHANGED
@@ -3,6 +3,12 @@
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
+
6
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)
7
13
 
8
14
  ### Features
@@ -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() && this.isValueWithinMinMax() && this.isFromBeforeTo());
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
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '6.16.0';
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.16.0",
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": "296f3d3f500bb1d65efa1f7dc689324a50b44201"
373
+ "gitHead": "c3bf39341ad3fe6264c27e083e914717744f3a49"
374
374
  }