@capillarytech/blaze-ui 5.2.2 → 5.2.4

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 (47) hide show
  1. package/.npmrc +2 -0
  2. package/CapCollapsibleNavbar/index.js +55 -3
  3. package/CapCollapsibleNavbar/index.js.map +1 -1
  4. package/CapCondition/index.js +55 -3
  5. package/CapCondition/index.js.map +1 -1
  6. package/CapDatePicker/index.js +55 -3
  7. package/CapDatePicker/index.js.map +1 -1
  8. package/CapDateTimePicker/README.md +136 -0
  9. package/CapDateTimePicker/index.d.ts +13 -0
  10. package/CapDateTimePicker/index.d.ts.map +1 -0
  11. package/CapDateTimePicker/index.js +166 -106
  12. package/CapDateTimePicker/index.js.map +1 -1
  13. package/CapDateTimePicker/messages.d.ts +17 -0
  14. package/CapDateTimePicker/messages.d.ts.map +1 -0
  15. package/CapDateTimePicker/types.d.ts +93 -0
  16. package/CapDateTimePicker/types.d.ts.map +1 -0
  17. package/CapDateTimeRangePicker/index.js +55 -3
  18. package/CapDateTimeRangePicker/index.js.map +1 -1
  19. package/CapEventCalendar/index.js +55 -3
  20. package/CapEventCalendar/index.js.map +1 -1
  21. package/CapLanguageProvider/index.js +55 -3
  22. package/CapLanguageProvider/index.js.map +1 -1
  23. package/CapLevelGraphRenderer/CapLevelGraphRenderer-test-cases.md +50 -0
  24. package/CapLevelGraphRenderer/MIGRATION_ANALYSIS.md +138 -0
  25. package/CapLevelGraphRenderer/README.md +123 -0
  26. package/CapLevelGraphRenderer/STORYBOOK_ANALYSIS.md +96 -0
  27. package/CapLevelGraphRenderer/Tooltip.d.ts +31 -0
  28. package/CapLevelGraphRenderer/Tooltip.d.ts.map +1 -0
  29. package/CapLevelGraphRenderer/Tooltip_MIGRATION_ANALYSIS.md +120 -0
  30. package/CapLevelGraphRenderer/index.d.ts +16 -0
  31. package/CapLevelGraphRenderer/index.d.ts.map +1 -0
  32. package/CapLevelGraphRenderer/index.js +159 -135
  33. package/CapLevelGraphRenderer/index.js.map +1 -1
  34. package/CapLevelGraphRenderer/tests/TEST_COVERAGE.md +119 -0
  35. package/CapLevelGraphRenderer/types.d.ts +139 -0
  36. package/CapLevelGraphRenderer/types.d.ts.map +1 -0
  37. package/CapNotificationDropdown/index.js +55 -3
  38. package/CapNotificationDropdown/index.js.map +1 -1
  39. package/CapTimePicker/index.js +55 -3
  40. package/CapTimePicker/index.js.map +1 -1
  41. package/index.d.ts +4 -0
  42. package/index.d.ts.map +1 -1
  43. package/index.js +1053 -4
  44. package/index.js.map +1 -1
  45. package/package.json +4 -2
  46. package/utils/dayjs.d.ts +21 -0
  47. package/utils/dayjs.d.ts.map +1 -1
@@ -477,7 +477,7 @@ module.exports = isObject;
477
477
 
478
478
 
479
479
  exports.__esModule = true;
480
- exports.TIME_UNITS = exports.FORMAT_TOKENS = void 0;
480
+ exports.TIME_UNITS = exports.FORMAT_TOKENS = exports.DEFAULT_TIMEZONE = void 0;
481
481
  exports.dayjsToMoment = dayjsToMoment;
482
482
  exports["default"] = void 0;
483
483
  exports.hasMomentTimezoneSupport = hasMomentTimezoneSupport;
@@ -485,6 +485,7 @@ exports.isDayjsObject = isDayjsObject;
485
485
  exports.isMomentObject = isMomentObject;
486
486
  exports.momentToDayjs = momentToDayjs;
487
487
  exports.normalizeDateValue = normalizeDateValue;
488
+ exports.toDayjsInTimezone = toDayjsInTimezone;
488
489
  var _dayjs = _interopRequireDefault(__webpack_require__(87695));
489
490
  var _advancedFormat = _interopRequireDefault(__webpack_require__(96833));
490
491
  var _customParseFormat = _interopRequireDefault(__webpack_require__(2825));
@@ -596,7 +597,23 @@ if (!tzIsCallable) {
596
597
  if (_dayjs.default.isDayjs(date)) {
597
598
  return date.tz(tzName);
598
599
  }
599
- return (0, _dayjs.default)(date).tz(tzName);
600
+ // For strings/Dates: interpret the date/time values as being IN the target timezone
601
+ // (matching moment.tz(string, tz) semantics). dayjs(date).tz(tz) is wrong because
602
+ // dayjs(date) anchors to the system local timezone, so .tz() converts FROM local TO tz.
603
+ // Instead: parse as UTC to get raw date/time values, compute the target timezone's offset,
604
+ // then adjust the UTC timestamp so .tz() produces the intended local time.
605
+ try {
606
+ // Validate timezone is a real IANA timezone before applying the offset correction
607
+ Intl.DateTimeFormat(undefined, {
608
+ timeZone: tzName
609
+ });
610
+ } catch (_unused) {
611
+ // Invalid timezone — fall back to local time
612
+ return (0, _dayjs.default)(date);
613
+ }
614
+ const asUtc = _dayjs.default.utc(date);
615
+ const tzOffset = asUtc.tz(tzName).utcOffset(); // target tz offset in minutes
616
+ return _dayjs.default.utc(asUtc.valueOf() - tzOffset * 60000).tz(tzName);
600
617
  } catch (error) {
601
618
  // If timezone is invalid, log error and fall back to local time
602
619
  logDevError("dayjs.tz: Invalid timezone \"" + tzName + "\"", error);
@@ -673,6 +690,8 @@ const FORMAT_TOKENS = exports.FORMAT_TOKENS = {
673
690
  MONTH_FULL: 'MMMM',
674
691
  YEAR: 'YYYY',
675
692
  YEAR_SHORT: 'YY',
693
+ // Cap UI datetime picker format (DD-MM-YYYY | HH:mm)
694
+ DATE_TIME: 'DD-MM-YYYY | HH:mm',
676
695
  // Localized formats
677
696
  DATE_LOCALIZED_SHORT: 'l',
678
697
  DATETIME_LOCALIZED_SHORT: 'll',
@@ -683,6 +702,7 @@ const FORMAT_TOKENS = exports.FORMAT_TOKENS = {
683
702
  DATETIME_LOCALIZED_LONG_TIME: 'LLL',
684
703
  DATETIME_LOCALIZED_LONG_TIME_WEEKDAY: 'LLLL'
685
704
  };
705
+ const DEFAULT_TIMEZONE = exports.DEFAULT_TIMEZONE = 'Asia/Kolkata';
686
706
  function logDevError(message, error) {
687
707
  if (false) // removed by dead control flow
688
708
  {}
@@ -763,7 +783,10 @@ function momentToDayjs(value) {
763
783
  const tz = value.tz();
764
784
  if (tz) {
765
785
  // Has a named timezone - preserve it
766
- dayjsObj = (0, _dayjs.default)(date).tz(tz);
786
+ // dayjs.utc(date) is required here: dayjs(date) anchors to the system local timezone,
787
+ // causing .tz() to only re-label without converting hours. dayjs.utc(date) creates a
788
+ // UTC-mode dayjs, which .tz() correctly converts to the target timezone for display.
789
+ dayjsObj = _dayjs.default.utc(date).tz(tz);
767
790
 
768
791
  // WORKAROUND: dayjs-timezone-iana-plugin doesn't persist timezone name in standard way
769
792
  // Store it manually in $x for round-trip conversion fidelity
@@ -816,6 +839,35 @@ function momentToDayjs(value) {
816
839
  return null;
817
840
  }
818
841
 
842
+ /**
843
+ * Converts any supported date value (Moment, Day.js, string, Date) to a Day.js object
844
+ * in the specified timezone. This is the recommended single entry point for timezone-safe
845
+ * date conversion — it handles moment-to-dayjs conversion and timezone application in one step,
846
+ * avoiding the double-offset bug in dayjs-timezone-iana-plugin.
847
+ *
848
+ * @param value - Moment, Day.js, string, Date, or null/undefined
849
+ * @param timezone - Target IANA timezone (e.g., 'Asia/Kolkata', 'America/New_York')
850
+ * @returns Day.js object in the target timezone, or null if invalid
851
+ *
852
+ * @example
853
+ * toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'Asia/Kolkata'), 'Asia/Kolkata');
854
+ * // Returns dayjs representing 2025-04-21 00:00 IST
855
+ *
856
+ * @example
857
+ * toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'UTC'), 'Asia/Kolkata');
858
+ * // Returns dayjs representing 2025-04-21 05:30 IST
859
+ */
860
+ function toDayjsInTimezone(value, timezone) {
861
+ const dayjsValue = momentToDayjs(value);
862
+ if (!dayjsValue) return null;
863
+
864
+ // Convert via UTC to avoid the double-offset bug in dayjs-timezone-iana-plugin:
865
+ // calling .tz() on a dayjs that already has a non-zero utcOffset corrupts the value.
866
+ // Going through .toDate() → dayjs.utc() gives us a clean UTC-mode dayjs that .tz()
867
+ // correctly converts to the target timezone.
868
+ return _dayjs.default.utc(dayjsValue.toDate()).tz(timezone);
869
+ }
870
+
819
871
  /**
820
872
  * Converts a Day.js object to Moment.js, preserving timezone and locale information.
821
873
  *