@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260326055821 → 0.8.1-dev.20260326063413

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.
Files changed (3) hide show
  1. package/dist/index.js +184 -36
  2. package/dist/index.mjs +308 -160
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -396,47 +396,192 @@ var NumberView_default = NumberView;
396
396
 
397
397
  // src/components/controls/view/DateView.tsx
398
398
  var import_react2 = __toESM(require("react"));
399
- var import_moment_timezone = __toESM(require("moment-timezone"));
399
+
400
+ // src/components/controls/view/TimeZoneAbbrevations.tsx
401
+ var timeZoneAbbreviations = {
402
+ "Asia/Calcutta": "IST",
403
+ "Asia/Kolkata": "IST",
404
+ "America/New_York": "EST",
405
+ "America/Los_Angeles": "PST",
406
+ "Europe/London": "GMT",
407
+ "Europe/Paris": "CET",
408
+ "Asia/Tokyo": "JST",
409
+ "America/Chicago": "CST",
410
+ "America/Denver": "MST",
411
+ "Asia/Shanghai": "CST",
412
+ "Asia/Hong_Kong": "HKT",
413
+ "Australia/Sydney": "AEST",
414
+ "Australia/Melbourne": "AEST",
415
+ "Australia/Perth": "AWST",
416
+ "Pacific/Auckland": "NZST",
417
+ "Europe/Berlin": "CET",
418
+ "Europe/Madrid": "CET",
419
+ "Europe/Rome": "CET",
420
+ "Europe/Athens": "EET",
421
+ "Europe/Istanbul": "TRT",
422
+ "Africa/Cairo": "EET",
423
+ "Africa/Johannesburg": "SAST",
424
+ "Asia/Dubai": "GST",
425
+ "Asia/Singapore": "SGT",
426
+ "Asia/Seoul": "KST",
427
+ "America/Toronto": "EST",
428
+ "America/Vancouver": "PST",
429
+ "America/Sao_Paulo": "BRT",
430
+ "America/Mexico_City": "CST",
431
+ "Asia/Manila": "PHT",
432
+ "Asia/Jakarta": "WIB",
433
+ "Asia/Bangkok": "ICT",
434
+ "Asia/Karachi": "PKT",
435
+ "Asia/Tehran": "IRST",
436
+ "Asia/Baghdad": "AST",
437
+ "Europe/Moscow": "MSK",
438
+ "Europe/Amsterdam": "CET",
439
+ "Europe/Brussels": "CET",
440
+ "Europe/Zurich": "CET",
441
+ "America/Anchorage": "AKST",
442
+ "Pacific/Honolulu": "HST",
443
+ "Antarctica/McMurdo": "NZST",
444
+ "Atlantic/Reykjavik": "GMT",
445
+ "Asia/Riyadh": "AST",
446
+ "America/Argentina/Buenos_Aires": "ART",
447
+ "America/Bogota": "COT",
448
+ "Africa/Nairobi": "EAT",
449
+ "Asia/Kuala_Lumpur": "MYT",
450
+ "Asia/Ho_Chi_Minh": "ICT",
451
+ "Europe/Warsaw": "CET",
452
+ "Europe/Prague": "CET",
453
+ "America/Phoenix": "MST",
454
+ "America/Indianapolis": "EST",
455
+ "Pacific/Fiji": "FJT",
456
+ "Asia/Colombo": "IST",
457
+ "Africa/Lagos": "WAT",
458
+ "America/Caracas": "VET",
459
+ "America/Halifax": "AST",
460
+ "Pacific/Tahiti": "TAHT",
461
+ "America/St_Johns": "NST",
462
+ "Europe/Bucharest": "EET",
463
+ "Europe/Helsinki": "EET",
464
+ "Europe/Kiev": "EET",
465
+ "Europe/Oslo": "CET",
466
+ "Europe/Stockholm": "CET",
467
+ "Europe/Lisbon": "WET",
468
+ "Asia/Beirut": "EET",
469
+ "Asia/Damascus": "EET",
470
+ "Asia/Jerusalem": "IST",
471
+ "Asia/Amman": "EET",
472
+ "America/Santiago": "CLT",
473
+ "America/Lima": "PET",
474
+ "America/Montevideo": "UYT",
475
+ "Asia/Tashkent": "UZT",
476
+ "Asia/Yerevan": "AMT",
477
+ "Asia/Baku": "AZT",
478
+ "Europe/Vilnius": "EET",
479
+ "Europe/Riga": "EET",
480
+ "Europe/Tallinn": "EET",
481
+ "Europe/Sofia": "EET",
482
+ "Africa/Casablanca": "WET",
483
+ "America/Guatemala": "CST",
484
+ "America/Panama": "EST",
485
+ "America/Costa_Rica": "CST",
486
+ "Pacific/Port_Moresby": "PGT",
487
+ "Asia/Makassar": "WITA",
488
+ "Asia/Vladivostok": "VLAT",
489
+ "Asia/Krasnoyarsk": "KRAT",
490
+ "Asia/Novosibirsk": "NOVT",
491
+ "Asia/Yakutsk": "YAKT",
492
+ "Asia/Sakhalin": "SAKT",
493
+ "Asia/Ulaanbaatar": "ULAT",
494
+ "Asia/Choibalsan": "CHOT",
495
+ "Asia/Omsk": "OMST",
496
+ "Asia/Kamchatka": "PETT",
497
+ "Pacific/Pago_Pago": "SST",
498
+ "Pacific/Guam": "ChST",
499
+ "Pacific/Saipan": "ChST",
500
+ "Pacific/Palau": "PWT",
501
+ "Pacific/Efate": "VUT",
502
+ "Pacific/Kosrae": "KOST",
503
+ "Pacific/Nauru": "NRT",
504
+ "Pacific/Tarawa": "GILT",
505
+ "Pacific/Enderbury": "PHOT",
506
+ "Pacific/Fakaofo": "TKT",
507
+ "Pacific/Chatham": "CHAST",
508
+ "Pacific/Tongatapu": "TOT",
509
+ "Pacific/Funafuti": "TVT",
510
+ "Pacific/Majuro": "MHT",
511
+ "Pacific/Kwajalein": "MHT",
512
+ "Pacific/Wake": "WAKT",
513
+ "Pacific/Wallis": "WFT"
514
+ };
515
+
516
+ // src/components/controls/view/DateView.tsx
400
517
  var import_jsx_runtime2 = require("react/jsx-runtime");
401
518
  var DateView = (props) => {
519
+ const getTimeZoneAbbreviation = (timeZone) => {
520
+ return timeZoneAbbreviations[timeZone] || timeZone;
521
+ };
522
+ const getRelativeTime = (dateString) => {
523
+ const now = /* @__PURE__ */ new Date();
524
+ const date = /* @__PURE__ */ new Date(dateString + "Z");
525
+ const diffMs = now.getTime() - date.getTime();
526
+ const diffSec = Math.floor(diffMs / 1e3);
527
+ const diffMin = Math.floor(diffSec / 60);
528
+ const diffHr = Math.floor(diffMin / 60);
529
+ const diffDay = Math.floor(diffHr / 24);
530
+ if (diffSec < 60) return "Just now";
531
+ if (diffMin < 60) return `${diffMin} minute${diffMin > 1 ? "s" : ""} ago`;
532
+ if (diffHr < 24) return `${diffHr} hour${diffHr > 1 ? "s" : ""} ago`;
533
+ if (diffDay < 7) return `${diffDay} day${diffDay > 1 ? "s" : ""} ago`;
534
+ return new Intl.DateTimeFormat("en", {
535
+ day: "2-digit",
536
+ month: "short",
537
+ year: "numeric"
538
+ }).format(date);
539
+ };
540
+ console.log("DateView props:", props);
541
+ const parseAndFormatDate = (dateString, format) => {
542
+ const parsedDate = /* @__PURE__ */ new Date(dateString + "Z");
543
+ if (format === "relative") {
544
+ return getRelativeTime(dateString);
545
+ }
546
+ switch (props.controlType) {
547
+ case "date":
548
+ return new Intl.DateTimeFormat("en", {
549
+ day: "2-digit",
550
+ month: "short",
551
+ year: "numeric"
552
+ }).format(parsedDate);
553
+ case "time":
554
+ return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(Intl.DateTimeFormat().resolvedOptions().timeZone)} (${getTimePeriod(parsedDate)})`;
555
+ default:
556
+ return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", { day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" }).format(parsedDate) : new Intl.DateTimeFormat("en", { day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit", second: "2-digit" }).format(parsedDate);
557
+ }
558
+ };
559
+ const formatTime = (date) => {
560
+ return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", { hour: "2-digit", minute: "2-digit" }).format(date) : new Intl.DateTimeFormat("en", { hour: "2-digit", minute: "2-digit", second: "2-digit" }).format(date);
561
+ };
562
+ const getTimePeriod = (date) => {
563
+ const hours = date.getHours();
564
+ if (hours >= 5 && hours < 8) return "Early Morning";
565
+ if (hours >= 8 && hours < 12) return "Morning";
566
+ if (hours >= 12 && hours < 14) return "Noon";
567
+ if (hours >= 14 && hours < 17) return "Afternoon";
568
+ if (hours >= 17 && hours < 20) return "Evening";
569
+ if (hours >= 20 && hours < 22) return "Late Evening";
570
+ if (hours >= 22 || hours < 5) return "Night";
571
+ return "Late Night";
572
+ };
402
573
  let localDateTime = "";
403
- let timezone;
574
+ let timeZoneAbbreviation = "";
404
575
  try {
405
- const val = props.value && props.value.toString().includes("Z") ? props.value : props.value + "Z";
406
- const parsedDate = new Date(val);
407
- const timezoneOffset = parsedDate.getTimezoneOffset();
408
- timezone = import_moment_timezone.default.tz.zone(import_moment_timezone.default.tz.guess())?.abbr(timezoneOffset);
409
- if (props.format && props.format == "timeago") {
410
- localDateTime = formatTimeAgo(parsedDate);
411
- } else {
412
- localDateTime = parsedDate.toLocaleString() + " " + timezone;
413
- }
576
+ localDateTime = parseAndFormatDate(props.value, props.format);
577
+ timeZoneAbbreviation = getTimeZoneAbbreviation(Intl.DateTimeFormat().resolvedOptions().timeZone);
414
578
  } catch (error) {
415
- console.error("Error parsing date:", props.value);
416
- }
417
- function formatTimeAgo(inputDate) {
418
- const currentDate = /* @__PURE__ */ new Date();
419
- const timeDifference = Math.floor((currentDate.getTime() - inputDate.getTime()) / 1e3);
420
- if (timeDifference < 10) {
421
- return "few secs ago";
422
- } else if (timeDifference < 60) {
423
- return `${timeDifference} secs ago`;
424
- } else if (timeDifference < 3600) {
425
- const minutes = Math.floor(timeDifference / 60);
426
- return `${minutes} min${minutes > 1 ? "s" : ""} ago`;
427
- } else if (timeDifference < 86400) {
428
- const hours = Math.floor(timeDifference / 3600);
429
- const remainingMinutes = Math.floor(timeDifference % 3600 / 60);
430
- return `${hours} hour${hours > 1 ? "s" : ""}, ${remainingMinutes} min${remainingMinutes > 1 ? "s" : ""} ago`;
431
- } else if (timeDifference < 14 * 3600) {
432
- const daysAgo = Math.floor(timeDifference / 86400);
433
- return `${daysAgo} day${daysAgo > 1 ? "s" : ""} ago`;
434
- } else {
435
- const formattedDate = inputDate.toLocaleString();
436
- return formattedDate;
437
- }
579
+ console.error("Error parsing date:", props.value, error);
438
580
  }
439
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "inline-flex gap-1", children: localDateTime == "Invalid Date undefined" ? "-" : localDateTime }) });
581
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "inline-flex flex-wrap gap-1", children: [
582
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: localDateTime }),
583
+ !props.format && props.controlType != "date" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbreviation })
584
+ ] }) });
440
585
  };
441
586
  var DateView_default = DateView;
442
587
 
@@ -531,7 +676,10 @@ var ViewControl = import_react9.default.forwardRef(
531
676
  // [ViewControlTypes.aiGeneratedSummary]: AiGeneratedSummary,
532
677
  };
533
678
  const SelectedControlComponent = props.controlType ? ControlComponents[props.controlType] : void 0;
534
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react9.default.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectedControlComponent, { ...props }) : "Control not found:" + props.controlType });
679
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react9.default.Fragment, { children: [
680
+ props.controlType,
681
+ SelectedControlComponent ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectedControlComponent, { ...props }) : "Control not found:" + props.controlType
682
+ ] });
535
683
  }
536
684
  );
537
685
  ViewControl.displayName = "ViewControl";