@trackunit/react-date-and-time-components 1.9.47 → 1.9.49

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/index.cjs.js CHANGED
@@ -507,13 +507,30 @@ const formatCustomDateRangeLabel = (dateRange) => {
507
507
  dateAndTimeUtils.formatDateUtil(dateRange.end ?? new Date(), { dateFormat: "medium", selectFormat: "dateOnly" }));
508
508
  };
509
509
 
510
+ const TEMPORAL_UNITS = ["day", "days"];
511
+ const TEMPORAL_DIRECTIONS = ["last", "next"];
510
512
  /**
511
513
  * Check if a value is a temporal period.
512
514
  *
513
515
  * @param value - The value to check.
514
516
  * @returns {boolean} - Whether the value is a temporal period.
515
517
  */
516
- const isTemporalPeriod = (value) => !!value && typeof value === "object" && "direction" in value && "count" in value && "unit" in value;
518
+ const isTemporalPeriod = (value) => !!value &&
519
+ typeof value === "object" &&
520
+ "direction" in value &&
521
+ "count" in value &&
522
+ "unit" in value &&
523
+ sharedUtils.nonNullable(value.unit) &&
524
+ sharedUtils.nonNullable(value.direction) &&
525
+ typeof value.count === "number" &&
526
+ isTemporalUnit(value.unit) &&
527
+ isTemporalDirection(value.direction);
528
+ const isTemporalUnit = (unit) => {
529
+ return typeof unit === "string" && TEMPORAL_UNITS.includes(unit);
530
+ };
531
+ const isTemporalDirection = (direction) => {
532
+ return typeof direction === "string" && TEMPORAL_DIRECTIONS.includes(direction);
533
+ };
517
534
 
518
535
  /**
519
536
  * Day range select component.
package/index.esm.js CHANGED
@@ -505,13 +505,30 @@ const formatCustomDateRangeLabel = (dateRange) => {
505
505
  formatDateUtil(dateRange.end ?? new Date(), { dateFormat: "medium", selectFormat: "dateOnly" }));
506
506
  };
507
507
 
508
+ const TEMPORAL_UNITS = ["day", "days"];
509
+ const TEMPORAL_DIRECTIONS = ["last", "next"];
508
510
  /**
509
511
  * Check if a value is a temporal period.
510
512
  *
511
513
  * @param value - The value to check.
512
514
  * @returns {boolean} - Whether the value is a temporal period.
513
515
  */
514
- const isTemporalPeriod = (value) => !!value && typeof value === "object" && "direction" in value && "count" in value && "unit" in value;
516
+ const isTemporalPeriod = (value) => !!value &&
517
+ typeof value === "object" &&
518
+ "direction" in value &&
519
+ "count" in value &&
520
+ "unit" in value &&
521
+ nonNullable(value.unit) &&
522
+ nonNullable(value.direction) &&
523
+ typeof value.count === "number" &&
524
+ isTemporalUnit(value.unit) &&
525
+ isTemporalDirection(value.direction);
526
+ const isTemporalUnit = (unit) => {
527
+ return typeof unit === "string" && TEMPORAL_UNITS.includes(unit);
528
+ };
529
+ const isTemporalDirection = (direction) => {
530
+ return typeof direction === "string" && TEMPORAL_DIRECTIONS.includes(direction);
531
+ };
515
532
 
516
533
  /**
517
534
  * Day range select component.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-date-and-time-components",
3
- "version": "1.9.47",
3
+ "version": "1.9.49",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,15 +8,15 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "react": "19.0.0",
11
- "@trackunit/react-components": "1.8.0",
11
+ "@trackunit/react-components": "1.8.1",
12
12
  "@trackunit/date-and-time-utils": "1.6.33",
13
- "@trackunit/react-date-and-time-hooks": "1.6.36",
13
+ "@trackunit/react-date-and-time-hooks": "1.6.37",
14
14
  "@trackunit/css-class-variance-utilities": "1.6.33",
15
15
  "@trackunit/ui-icons": "1.6.32",
16
16
  "@trackunit/shared-utils": "1.8.33",
17
- "@trackunit/i18n-library-translation": "1.6.36",
17
+ "@trackunit/i18n-library-translation": "1.6.37",
18
18
  "@trackunit/react-test-setup": "1.3.33",
19
- "@trackunit/react-form-components": "1.7.13",
19
+ "@trackunit/react-form-components": "1.7.14",
20
20
  "string-ts": "^2.0.0",
21
21
  "tailwind-merge": "^2.0.0",
22
22
  "react-calendar": "^6.0.0"
@@ -1,4 +1,3 @@
1
- import { DateRange } from "@trackunit/date-and-time-utils";
2
1
  import { TemporalPeriod } from "../../types";
3
2
  /**
4
3
  * Check if a value is a temporal period.
@@ -6,4 +5,4 @@ import { TemporalPeriod } from "../../types";
6
5
  * @param value - The value to check.
7
6
  * @returns {boolean} - Whether the value is a temporal period.
8
7
  */
9
- export declare const isTemporalPeriod: (value: DateRange | TemporalPeriod | undefined) => value is TemporalPeriod;
8
+ export declare const isTemporalPeriod: (value: unknown) => value is TemporalPeriod;