@optifye/dashboard-core 6.12.32 → 6.12.33

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/dist/index.d.mts CHANGED
@@ -4397,7 +4397,7 @@ declare const useWorkspaceUptimeTimeline: (options: UseWorkspaceUptimeTimelineOp
4397
4397
  * console.log(formatTime(myDate, 'HH:mm:ss zzz')); // Formats using date-fns string in configured timezone
4398
4398
  * console.log(`Current timezone: ${timezone}`);
4399
4399
  */
4400
- declare function useDateFormatter(): {
4400
+ declare function useDateFormatter(timezoneOverride?: string): {
4401
4401
  formatDate: (date: Date | string, formatString?: string) => string;
4402
4402
  formatTime: (date: Date | string, formatString?: string) => string;
4403
4403
  formatDateTime: (date: Date | string, formatString?: string) => string;
package/dist/index.d.ts CHANGED
@@ -4397,7 +4397,7 @@ declare const useWorkspaceUptimeTimeline: (options: UseWorkspaceUptimeTimelineOp
4397
4397
  * console.log(formatTime(myDate, 'HH:mm:ss zzz')); // Formats using date-fns string in configured timezone
4398
4398
  * console.log(`Current timezone: ${timezone}`);
4399
4399
  */
4400
- declare function useDateFormatter(): {
4400
+ declare function useDateFormatter(timezoneOverride?: string): {
4401
4401
  formatDate: (date: Date | string, formatString?: string) => string;
4402
4402
  formatTime: (date: Date | string, formatString?: string) => string;
4403
4403
  formatDateTime: (date: Date | string, formatString?: string) => string;
package/dist/index.js CHANGED
@@ -20487,46 +20487,56 @@ var useWorkspaceUptimeTimeline = (options) => {
20487
20487
  refetch: fetchTimeline
20488
20488
  };
20489
20489
  };
20490
- function useDateFormatter() {
20490
+ function useDateFormatter(timezoneOverride) {
20491
20491
  const { defaultTimezone, defaultLocale, dateFormatOptions, timeFormatOptions, dateTimeFormatOptions } = useDateTimeConfig();
20492
+ const resolvedTimezone = timezoneOverride || defaultTimezone || "UTC";
20492
20493
  const formatDate2 = React144.useCallback(
20493
20494
  (date, formatString) => {
20494
20495
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
20495
20496
  if (!dateFns.isValid(dateObj)) return "Invalid Date";
20496
- const tz = defaultTimezone || "UTC";
20497
+ const tz = resolvedTimezone;
20497
20498
  if (formatString) {
20498
20499
  return dateFnsTz.formatInTimeZone(dateObj, tz, formatString);
20499
20500
  }
20500
20501
  const effectiveOptions = dateFormatOptions || { year: "numeric", month: "short", day: "numeric" };
20501
- return new Intl.DateTimeFormat(defaultLocale || "en-US", effectiveOptions).format(dateObj);
20502
+ return new Intl.DateTimeFormat(defaultLocale || "en-US", {
20503
+ ...effectiveOptions,
20504
+ timeZone: tz
20505
+ }).format(dateObj);
20502
20506
  },
20503
- [defaultTimezone, defaultLocale, dateFormatOptions]
20507
+ [resolvedTimezone, defaultLocale, dateFormatOptions]
20504
20508
  );
20505
20509
  const formatTime5 = React144.useCallback(
20506
20510
  (date, formatString) => {
20507
20511
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
20508
20512
  if (!dateFns.isValid(dateObj)) return "Invalid Time";
20509
- const tz = defaultTimezone || "UTC";
20513
+ const tz = resolvedTimezone;
20510
20514
  if (formatString) {
20511
20515
  return dateFnsTz.formatInTimeZone(dateObj, tz, formatString);
20512
20516
  }
20513
20517
  const effectiveOptions = timeFormatOptions || { hour: "numeric", minute: "numeric" };
20514
- return new Intl.DateTimeFormat(defaultLocale || "en-US", effectiveOptions).format(dateObj);
20518
+ return new Intl.DateTimeFormat(defaultLocale || "en-US", {
20519
+ ...effectiveOptions,
20520
+ timeZone: tz
20521
+ }).format(dateObj);
20515
20522
  },
20516
- [defaultTimezone, defaultLocale, timeFormatOptions]
20523
+ [resolvedTimezone, defaultLocale, timeFormatOptions]
20517
20524
  );
20518
20525
  const formatDateTime = React144.useCallback(
20519
20526
  (date, formatString) => {
20520
20527
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
20521
20528
  if (!dateFns.isValid(dateObj)) return "Invalid Date/Time";
20522
- const tz = defaultTimezone || "UTC";
20529
+ const tz = resolvedTimezone;
20523
20530
  if (formatString) {
20524
20531
  return dateFnsTz.formatInTimeZone(dateObj, tz, formatString);
20525
20532
  }
20526
20533
  const effectiveOptions = dateTimeFormatOptions || { year: "numeric", month: "short", day: "numeric", hour: "numeric", minute: "numeric" };
20527
- return new Intl.DateTimeFormat(defaultLocale || "en-US", effectiveOptions).format(dateObj);
20534
+ return new Intl.DateTimeFormat(defaultLocale || "en-US", {
20535
+ ...effectiveOptions,
20536
+ timeZone: tz
20537
+ }).format(dateObj);
20528
20538
  },
20529
- [defaultTimezone, defaultLocale, dateTimeFormatOptions]
20539
+ [resolvedTimezone, defaultLocale, dateTimeFormatOptions]
20530
20540
  );
20531
20541
  const getNow = React144.useCallback(() => {
20532
20542
  return /* @__PURE__ */ new Date();
@@ -20536,7 +20546,7 @@ function useDateFormatter() {
20536
20546
  formatTime: formatTime5,
20537
20547
  formatDateTime,
20538
20548
  getNow,
20539
- timezone: defaultTimezone || "UTC",
20549
+ timezone: resolvedTimezone,
20540
20550
  locale: defaultLocale || "en-US"
20541
20551
  };
20542
20552
  }
@@ -40265,14 +40275,16 @@ var DateTimeDisplay = ({
40265
40275
  const {
40266
40276
  defaultTimezone
40267
40277
  } = useDateTimeConfig();
40268
- const { formatDate: formatDate2, formatTime: formatTime5 } = useDateFormatter();
40269
- const [now4, setNow] = React144.useState(() => getCurrentTimeInZone(defaultTimezone || "UTC"));
40278
+ const appTimezone = useAppTimezone();
40279
+ const timezone = appTimezone || defaultTimezone || "UTC";
40280
+ const { formatDate: formatDate2, formatTime: formatTime5 } = useDateFormatter(timezone);
40281
+ const [now4, setNow] = React144.useState(() => /* @__PURE__ */ new Date());
40270
40282
  React144.useEffect(() => {
40271
40283
  const timerId = setInterval(() => {
40272
- setNow(getCurrentTimeInZone(defaultTimezone || "UTC"));
40284
+ setNow(/* @__PURE__ */ new Date());
40273
40285
  }, 1e3);
40274
40286
  return () => clearInterval(timerId);
40275
- }, [defaultTimezone]);
40287
+ }, []);
40276
40288
  if (!showDate && !showTime) {
40277
40289
  return null;
40278
40290
  }
@@ -42794,9 +42806,9 @@ var TimeDisplay = ({ className, variant = "default" }) => {
42794
42806
  minute: "2-digit",
42795
42807
  second: "2-digit",
42796
42808
  hour12: true,
42797
- timeZone: timezoneToDisplay,
42798
- ...dateTimeConfig?.timeFormatOptions || {}
42809
+ ...dateTimeConfig?.timeFormatOptions || {},
42799
42810
  // Allow override from config
42811
+ timeZone: timezoneToDisplay
42800
42812
  };
42801
42813
  try {
42802
42814
  setTime(new Intl.DateTimeFormat(localeToUse, effectiveFormatOptions).format(now4));
@@ -42839,7 +42851,8 @@ var TimeDisplay_default = TimeDisplay;
42839
42851
  var DateDisplay = ({ className, variant = "default" }) => {
42840
42852
  const { dateTimeConfig } = useDashboardConfig();
42841
42853
  const [date, setDate] = React144.useState("");
42842
- const timezoneToDisplay = dateTimeConfig?.defaultTimezone || "UTC";
42854
+ const dbTimezone = useAppTimezone();
42855
+ const timezoneToDisplay = dbTimezone || dateTimeConfig?.defaultTimezone || "UTC";
42843
42856
  const localeToUse = dateTimeConfig?.defaultLocale || "en-US";
42844
42857
  React144.useEffect(() => {
42845
42858
  const getCurrentFormattedDate = () => {
@@ -42848,9 +42861,9 @@ var DateDisplay = ({ className, variant = "default" }) => {
42848
42861
  weekday: "short",
42849
42862
  day: "numeric",
42850
42863
  month: "short",
42851
- timeZone: timezoneToDisplay,
42852
- ...dateTimeConfig?.dateFormatOptions || {}
42864
+ ...dateTimeConfig?.dateFormatOptions || {},
42853
42865
  // Allow override from config
42866
+ timeZone: timezoneToDisplay
42854
42867
  };
42855
42868
  try {
42856
42869
  return new Intl.DateTimeFormat(localeToUse, effectiveFormatOptions).format(now4);
package/dist/index.mjs CHANGED
@@ -20458,46 +20458,56 @@ var useWorkspaceUptimeTimeline = (options) => {
20458
20458
  refetch: fetchTimeline
20459
20459
  };
20460
20460
  };
20461
- function useDateFormatter() {
20461
+ function useDateFormatter(timezoneOverride) {
20462
20462
  const { defaultTimezone, defaultLocale, dateFormatOptions, timeFormatOptions, dateTimeFormatOptions } = useDateTimeConfig();
20463
+ const resolvedTimezone = timezoneOverride || defaultTimezone || "UTC";
20463
20464
  const formatDate2 = useCallback(
20464
20465
  (date, formatString) => {
20465
20466
  const dateObj = typeof date === "string" ? parseISO(date) : date;
20466
20467
  if (!isValid(dateObj)) return "Invalid Date";
20467
- const tz = defaultTimezone || "UTC";
20468
+ const tz = resolvedTimezone;
20468
20469
  if (formatString) {
20469
20470
  return formatInTimeZone(dateObj, tz, formatString);
20470
20471
  }
20471
20472
  const effectiveOptions = dateFormatOptions || { year: "numeric", month: "short", day: "numeric" };
20472
- return new Intl.DateTimeFormat(defaultLocale || "en-US", effectiveOptions).format(dateObj);
20473
+ return new Intl.DateTimeFormat(defaultLocale || "en-US", {
20474
+ ...effectiveOptions,
20475
+ timeZone: tz
20476
+ }).format(dateObj);
20473
20477
  },
20474
- [defaultTimezone, defaultLocale, dateFormatOptions]
20478
+ [resolvedTimezone, defaultLocale, dateFormatOptions]
20475
20479
  );
20476
20480
  const formatTime5 = useCallback(
20477
20481
  (date, formatString) => {
20478
20482
  const dateObj = typeof date === "string" ? parseISO(date) : date;
20479
20483
  if (!isValid(dateObj)) return "Invalid Time";
20480
- const tz = defaultTimezone || "UTC";
20484
+ const tz = resolvedTimezone;
20481
20485
  if (formatString) {
20482
20486
  return formatInTimeZone(dateObj, tz, formatString);
20483
20487
  }
20484
20488
  const effectiveOptions = timeFormatOptions || { hour: "numeric", minute: "numeric" };
20485
- return new Intl.DateTimeFormat(defaultLocale || "en-US", effectiveOptions).format(dateObj);
20489
+ return new Intl.DateTimeFormat(defaultLocale || "en-US", {
20490
+ ...effectiveOptions,
20491
+ timeZone: tz
20492
+ }).format(dateObj);
20486
20493
  },
20487
- [defaultTimezone, defaultLocale, timeFormatOptions]
20494
+ [resolvedTimezone, defaultLocale, timeFormatOptions]
20488
20495
  );
20489
20496
  const formatDateTime = useCallback(
20490
20497
  (date, formatString) => {
20491
20498
  const dateObj = typeof date === "string" ? parseISO(date) : date;
20492
20499
  if (!isValid(dateObj)) return "Invalid Date/Time";
20493
- const tz = defaultTimezone || "UTC";
20500
+ const tz = resolvedTimezone;
20494
20501
  if (formatString) {
20495
20502
  return formatInTimeZone(dateObj, tz, formatString);
20496
20503
  }
20497
20504
  const effectiveOptions = dateTimeFormatOptions || { year: "numeric", month: "short", day: "numeric", hour: "numeric", minute: "numeric" };
20498
- return new Intl.DateTimeFormat(defaultLocale || "en-US", effectiveOptions).format(dateObj);
20505
+ return new Intl.DateTimeFormat(defaultLocale || "en-US", {
20506
+ ...effectiveOptions,
20507
+ timeZone: tz
20508
+ }).format(dateObj);
20499
20509
  },
20500
- [defaultTimezone, defaultLocale, dateTimeFormatOptions]
20510
+ [resolvedTimezone, defaultLocale, dateTimeFormatOptions]
20501
20511
  );
20502
20512
  const getNow = useCallback(() => {
20503
20513
  return /* @__PURE__ */ new Date();
@@ -20507,7 +20517,7 @@ function useDateFormatter() {
20507
20517
  formatTime: formatTime5,
20508
20518
  formatDateTime,
20509
20519
  getNow,
20510
- timezone: defaultTimezone || "UTC",
20520
+ timezone: resolvedTimezone,
20511
20521
  locale: defaultLocale || "en-US"
20512
20522
  };
20513
20523
  }
@@ -40236,14 +40246,16 @@ var DateTimeDisplay = ({
40236
40246
  const {
40237
40247
  defaultTimezone
40238
40248
  } = useDateTimeConfig();
40239
- const { formatDate: formatDate2, formatTime: formatTime5 } = useDateFormatter();
40240
- const [now4, setNow] = useState(() => getCurrentTimeInZone(defaultTimezone || "UTC"));
40249
+ const appTimezone = useAppTimezone();
40250
+ const timezone = appTimezone || defaultTimezone || "UTC";
40251
+ const { formatDate: formatDate2, formatTime: formatTime5 } = useDateFormatter(timezone);
40252
+ const [now4, setNow] = useState(() => /* @__PURE__ */ new Date());
40241
40253
  useEffect(() => {
40242
40254
  const timerId = setInterval(() => {
40243
- setNow(getCurrentTimeInZone(defaultTimezone || "UTC"));
40255
+ setNow(/* @__PURE__ */ new Date());
40244
40256
  }, 1e3);
40245
40257
  return () => clearInterval(timerId);
40246
- }, [defaultTimezone]);
40258
+ }, []);
40247
40259
  if (!showDate && !showTime) {
40248
40260
  return null;
40249
40261
  }
@@ -42765,9 +42777,9 @@ var TimeDisplay = ({ className, variant = "default" }) => {
42765
42777
  minute: "2-digit",
42766
42778
  second: "2-digit",
42767
42779
  hour12: true,
42768
- timeZone: timezoneToDisplay,
42769
- ...dateTimeConfig?.timeFormatOptions || {}
42780
+ ...dateTimeConfig?.timeFormatOptions || {},
42770
42781
  // Allow override from config
42782
+ timeZone: timezoneToDisplay
42771
42783
  };
42772
42784
  try {
42773
42785
  setTime(new Intl.DateTimeFormat(localeToUse, effectiveFormatOptions).format(now4));
@@ -42810,7 +42822,8 @@ var TimeDisplay_default = TimeDisplay;
42810
42822
  var DateDisplay = ({ className, variant = "default" }) => {
42811
42823
  const { dateTimeConfig } = useDashboardConfig();
42812
42824
  const [date, setDate] = useState("");
42813
- const timezoneToDisplay = dateTimeConfig?.defaultTimezone || "UTC";
42825
+ const dbTimezone = useAppTimezone();
42826
+ const timezoneToDisplay = dbTimezone || dateTimeConfig?.defaultTimezone || "UTC";
42814
42827
  const localeToUse = dateTimeConfig?.defaultLocale || "en-US";
42815
42828
  useEffect(() => {
42816
42829
  const getCurrentFormattedDate = () => {
@@ -42819,9 +42832,9 @@ var DateDisplay = ({ className, variant = "default" }) => {
42819
42832
  weekday: "short",
42820
42833
  day: "numeric",
42821
42834
  month: "short",
42822
- timeZone: timezoneToDisplay,
42823
- ...dateTimeConfig?.dateFormatOptions || {}
42835
+ ...dateTimeConfig?.dateFormatOptions || {},
42824
42836
  // Allow override from config
42837
+ timeZone: timezoneToDisplay
42825
42838
  };
42826
42839
  try {
42827
42840
  return new Intl.DateTimeFormat(localeToUse, effectiveFormatOptions).format(now4);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.12.32",
3
+ "version": "6.12.33",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",