@trackunit/react-date-and-time-hooks 2.4.8-alpha-d0f54ff2967.0 → 2.4.10

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
@@ -394,24 +394,27 @@ const useDateAndTime = () => {
394
394
  * @param {TemporalDate} from
395
395
  * @param {TemporalDate} to
396
396
  * @param {TemporalSinceType} type
397
+ * @param {TuRelativeTimeStyle} [style] - Optional width override. Pass `"narrow-compact"` for the
398
+ * shortest locale-native form with the past-tense affix stripped (e.g. `"2d"` in English).
399
+ * Omit to get the default long form (`"2 days ago"` in English).
397
400
  * @returns {string}
398
401
  */
399
- const since = react.useCallback((from, to, type) => {
402
+ const since = react.useCallback((from, to, type, style) => {
400
403
  switch (type) {
401
404
  case "auto":
402
- return dateAndTimeUtils.timeSinceAuto(from, to, currentTimeZone, currentLocale);
405
+ return dateAndTimeUtils.timeSinceAuto(from, to, currentTimeZone, currentLocale, style);
403
406
  case "seconds":
404
- return dateAndTimeUtils.timeSinceInSeconds(from, to, currentTimeZone, currentLocale);
407
+ return dateAndTimeUtils.timeSinceInSeconds(from, to, currentTimeZone, currentLocale, style);
405
408
  case "minutes":
406
- return dateAndTimeUtils.timeSinceInMinutes(from, to, currentTimeZone, currentLocale);
409
+ return dateAndTimeUtils.timeSinceInMinutes(from, to, currentTimeZone, currentLocale, style);
407
410
  case "hours":
408
- return dateAndTimeUtils.timeSinceInHours(from, to, currentTimeZone, currentLocale);
411
+ return dateAndTimeUtils.timeSinceInHours(from, to, currentTimeZone, currentLocale, style);
409
412
  case "days":
410
- return dateAndTimeUtils.timeSinceInDays(from, to, currentTimeZone, currentLocale);
413
+ return dateAndTimeUtils.timeSinceInDays(from, to, currentTimeZone, currentLocale, style);
411
414
  case "months":
412
- return dateAndTimeUtils.timeSinceInMonths(from, to, currentTimeZone, currentLocale);
415
+ return dateAndTimeUtils.timeSinceInMonths(from, to, currentTimeZone, currentLocale, style);
413
416
  case "years":
414
- return dateAndTimeUtils.timeSinceInYears(from, to, currentTimeZone, currentLocale);
417
+ return dateAndTimeUtils.timeSinceInYears(from, to, currentTimeZone, currentLocale, style);
415
418
  default:
416
419
  return sharedUtils.exhaustiveCheck(type);
417
420
  }
package/index.esm.js CHANGED
@@ -392,24 +392,27 @@ const useDateAndTime = () => {
392
392
  * @param {TemporalDate} from
393
393
  * @param {TemporalDate} to
394
394
  * @param {TemporalSinceType} type
395
+ * @param {TuRelativeTimeStyle} [style] - Optional width override. Pass `"narrow-compact"` for the
396
+ * shortest locale-native form with the past-tense affix stripped (e.g. `"2d"` in English).
397
+ * Omit to get the default long form (`"2 days ago"` in English).
395
398
  * @returns {string}
396
399
  */
397
- const since = useCallback((from, to, type) => {
400
+ const since = useCallback((from, to, type, style) => {
398
401
  switch (type) {
399
402
  case "auto":
400
- return timeSinceAuto(from, to, currentTimeZone, currentLocale);
403
+ return timeSinceAuto(from, to, currentTimeZone, currentLocale, style);
401
404
  case "seconds":
402
- return timeSinceInSeconds(from, to, currentTimeZone, currentLocale);
405
+ return timeSinceInSeconds(from, to, currentTimeZone, currentLocale, style);
403
406
  case "minutes":
404
- return timeSinceInMinutes(from, to, currentTimeZone, currentLocale);
407
+ return timeSinceInMinutes(from, to, currentTimeZone, currentLocale, style);
405
408
  case "hours":
406
- return timeSinceInHours(from, to, currentTimeZone, currentLocale);
409
+ return timeSinceInHours(from, to, currentTimeZone, currentLocale, style);
407
410
  case "days":
408
- return timeSinceInDays(from, to, currentTimeZone, currentLocale);
411
+ return timeSinceInDays(from, to, currentTimeZone, currentLocale, style);
409
412
  case "months":
410
- return timeSinceInMonths(from, to, currentTimeZone, currentLocale);
413
+ return timeSinceInMonths(from, to, currentTimeZone, currentLocale, style);
411
414
  case "years":
412
- return timeSinceInYears(from, to, currentTimeZone, currentLocale);
415
+ return timeSinceInYears(from, to, currentTimeZone, currentLocale, style);
413
416
  default:
414
417
  return exhaustiveCheck(type);
415
418
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/date-and-time-hooks/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@trackunit/react-date-and-time-hooks",
3
- "version": "2.4.8-alpha-d0f54ff2967.0",
3
+ "version": "2.4.10",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
7
  "node": ">=24.x"
8
8
  },
9
9
  "dependencies": {
10
- "@trackunit/date-and-time-utils": "1.14.4-alpha-d0f54ff2967.0",
11
- "@trackunit/iris-app-runtime-core-api": "1.17.4-alpha-d0f54ff2967.0",
12
- "@trackunit/shared-utils": "1.16.4-alpha-d0f54ff2967.0",
13
- "@trackunit/react-core-hooks": "1.20.5-alpha-d0f54ff2967.0"
10
+ "@trackunit/date-and-time-utils": "1.14.5",
11
+ "@trackunit/iris-app-runtime-core-api": "1.17.4",
12
+ "@trackunit/shared-utils": "1.16.4",
13
+ "@trackunit/react-core-hooks": "1.20.6"
14
14
  },
15
15
  "devDependencies": {
16
- "@trackunit/react-core-contexts-test": "1.18.4-alpha-d0f54ff2967.0"
16
+ "@trackunit/react-core-contexts-test": "1.18.4"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": "^19.0.0"
@@ -1,4 +1,5 @@
1
- import { DateRange, TemporalDate, TemporalFormat, TemporalFormatStyle } from "@trackunit/date-and-time-utils";
1
+ import { DateRange, TemporalDate, TemporalFormat, TemporalFormatStyle, TuRelativeTimeStyle } from "@trackunit/date-and-time-utils";
2
+ export type { TuRelativeTimeStyle };
2
3
  type TemporalTypes = "second" | "seconds" | "minute" | "minutes" | "hour" | "hours" | "day" | "days" | "week" | "weeks" | "month" | "months" | "year" | "years";
3
4
  export type TemporalArithmeticType = Extract<TemporalTypes, "hours" | "minutes" | "days" | "weeks" | "months" | "years">;
4
5
  export type TemporalEdgeOfType = Extract<TemporalTypes, "hour" | "minute" | "day" | "week" | "month">;
@@ -25,7 +26,7 @@ interface UseDateAndTimeReturn {
25
26
  difference: (from: TemporalDate, to: TemporalDate, type: TemporalDifferenceType) => number;
26
27
  dateIs: (date: TemporalDate, type: TemporalIsType, betweenDates?: DateRange) => boolean;
27
28
  same: (date: TemporalDate, type: TemporalSameType) => boolean;
28
- since: (from: TemporalDate, to: TemporalDate, type: TemporalSinceType) => string;
29
+ since: (from: TemporalDate, to: TemporalDate, type: TemporalSinceType, style?: TuRelativeTimeStyle) => string;
29
30
  duration: (from: number | Intl.Duration, type: TemporalDurationType, format?: TemporalFormat["dayFormat"], roundAt?: TemporalTimeRounding) => string;
30
31
  convert: (amount: number, unit: "hour" | "minute" | "second" | "millisecond", conversionType: "hour" | "minute" | "second" | "millisecond") => number;
31
32
  dayName: (date: TemporalDate, format: TemporalFormatStyle) => string;
@@ -50,4 +51,3 @@ interface UseDateAndTimeReturn {
50
51
  * and timezone internally.
51
52
  */
52
53
  export declare const useDateAndTime: () => UseDateAndTimeReturn;
53
- export {};