@capillarytech/blaze-ui 5.1.18 → 5.1.20

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapDateTimePicker/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAoC,MAAM,OAAO,CAAC;AAiBzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;;;;AAwK7C,wBAA6C;AAC7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapDateTimePicker/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAoC,MAAM,OAAO,CAAC;AAiBzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;;;;AAkL7C,wBAA6C;AAC7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC"}
@@ -3782,6 +3782,7 @@ exports.isDayjsObject = isDayjsObject;
3782
3782
  exports.isMomentObject = isMomentObject;
3783
3783
  exports.momentToDayjs = momentToDayjs;
3784
3784
  exports.normalizeDateValue = normalizeDateValue;
3785
+ exports.toDayjsInTimezone = toDayjsInTimezone;
3785
3786
  var _dayjs = _interopRequireDefault(__webpack_require__(87695));
3786
3787
  var _advancedFormat = _interopRequireDefault(__webpack_require__(96833));
3787
3788
  var _customParseFormat = _interopRequireDefault(__webpack_require__(2825));
@@ -3893,7 +3894,23 @@ if (!tzIsCallable) {
3893
3894
  if (_dayjs.default.isDayjs(date)) {
3894
3895
  return date.tz(tzName);
3895
3896
  }
3896
- return (0, _dayjs.default)(date).tz(tzName);
3897
+ // For strings/Dates: interpret the date/time values as being IN the target timezone
3898
+ // (matching moment.tz(string, tz) semantics). dayjs(date).tz(tz) is wrong because
3899
+ // dayjs(date) anchors to the system local timezone, so .tz() converts FROM local TO tz.
3900
+ // Instead: parse as UTC to get raw date/time values, compute the target timezone's offset,
3901
+ // then adjust the UTC timestamp so .tz() produces the intended local time.
3902
+ try {
3903
+ // Validate timezone is a real IANA timezone before applying the offset correction
3904
+ Intl.DateTimeFormat(undefined, {
3905
+ timeZone: tzName
3906
+ });
3907
+ } catch (_unused) {
3908
+ // Invalid timezone — fall back to local time
3909
+ return (0, _dayjs.default)(date);
3910
+ }
3911
+ const asUtc = _dayjs.default.utc(date);
3912
+ const tzOffset = asUtc.tz(tzName).utcOffset(); // target tz offset in minutes
3913
+ return _dayjs.default.utc(asUtc.valueOf() - tzOffset * 60000).tz(tzName);
3897
3914
  } catch (error) {
3898
3915
  // If timezone is invalid, log error and fall back to local time
3899
3916
  logDevError("dayjs.tz: Invalid timezone \"" + tzName + "\"", error);
@@ -4063,7 +4080,10 @@ function momentToDayjs(value) {
4063
4080
  const tz = value.tz();
4064
4081
  if (tz) {
4065
4082
  // Has a named timezone - preserve it
4066
- dayjsObj = (0, _dayjs.default)(date).tz(tz);
4083
+ // dayjs.utc(date) is required here: dayjs(date) anchors to the system local timezone,
4084
+ // causing .tz() to only re-label without converting hours. dayjs.utc(date) creates a
4085
+ // UTC-mode dayjs, which .tz() correctly converts to the target timezone for display.
4086
+ dayjsObj = _dayjs.default.utc(date).tz(tz);
4067
4087
 
4068
4088
  // WORKAROUND: dayjs-timezone-iana-plugin doesn't persist timezone name in standard way
4069
4089
  // Store it manually in $x for round-trip conversion fidelity
@@ -4116,6 +4136,35 @@ function momentToDayjs(value) {
4116
4136
  return null;
4117
4137
  }
4118
4138
 
4139
+ /**
4140
+ * Converts any supported date value (Moment, Day.js, string, Date) to a Day.js object
4141
+ * in the specified timezone. This is the recommended single entry point for timezone-safe
4142
+ * date conversion — it handles moment-to-dayjs conversion and timezone application in one step,
4143
+ * avoiding the double-offset bug in dayjs-timezone-iana-plugin.
4144
+ *
4145
+ * @param value - Moment, Day.js, string, Date, or null/undefined
4146
+ * @param timezone - Target IANA timezone (e.g., 'Asia/Kolkata', 'America/New_York')
4147
+ * @returns Day.js object in the target timezone, or null if invalid
4148
+ *
4149
+ * @example
4150
+ * toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'Asia/Kolkata'), 'Asia/Kolkata');
4151
+ * // Returns dayjs representing 2025-04-21 00:00 IST
4152
+ *
4153
+ * @example
4154
+ * toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'UTC'), 'Asia/Kolkata');
4155
+ * // Returns dayjs representing 2025-04-21 05:30 IST
4156
+ */
4157
+ function toDayjsInTimezone(value, timezone) {
4158
+ const dayjsValue = momentToDayjs(value);
4159
+ if (!dayjsValue) return null;
4160
+
4161
+ // Convert via UTC to avoid the double-offset bug in dayjs-timezone-iana-plugin:
4162
+ // calling .tz() on a dayjs that already has a non-zero utcOffset corrupts the value.
4163
+ // Going through .toDate() → dayjs.utc() gives us a clean UTC-mode dayjs that .tz()
4164
+ // correctly converts to the target timezone.
4165
+ return _dayjs.default.utc(dayjsValue.toDate()).tz(timezone);
4166
+ }
4167
+
4119
4168
  /**
4120
4169
  * Converts a Day.js object to Moment.js, preserving timezone and locale information.
4121
4170
  *
@@ -5366,6 +5415,14 @@ var _default = exports["default"] = (0, _reactIntl.defineMessages)({
5366
5415
  selectDateTimePlaceHolder: {
5367
5416
  id: scope + ".selectDateTimePlaceHolder",
5368
5417
  defaultMessage: 'Select date | time'
5418
+ },
5419
+ selectLabel: {
5420
+ id: scope + ".selectLabel",
5421
+ defaultMessage: 'Select'
5422
+ },
5423
+ todayLabel: {
5424
+ id: scope + ".todayLabel",
5425
+ defaultMessage: 'Today'
5369
5426
  }
5370
5427
  });
5371
5428
 
@@ -7813,7 +7870,7 @@ var ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ = __webpack_require__(31601);
7813
7870
  var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(76314);
7814
7871
  var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
7815
7872
  // Module
7816
- ___CSS_LOADER_EXPORT___.push([module.id, `.cap-date-time-picker__calendar-icon{color:#091e42}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges{width:100%;display:flex;align-items:center;justify-content:flex-start;gap:1.142rem;padding:.571rem 1.142rem .857rem 1.142rem}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok{order:0;margin-inline-start:0}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok>button{background:#47af46;border:none;border-radius:.285rem;padding:0 2rem;height:2.285rem;line-height:2.285rem;font-weight:500;color:#fff;box-shadow:none}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok>button>span{display:none}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok>button::after{content:"Select";font-size:1rem}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok>button:disabled{background:#a1d8a0;cursor:not-allowed}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-now{order:1}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-now>a{font-size:0;font-weight:500;color:#2466ea}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-now>a::after{content:"Today";font-size:1rem;vertical-align:sub}`, ""]);
7873
+ ___CSS_LOADER_EXPORT___.push([module.id, `.cap-date-time-picker__calendar-icon{color:#091e42}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges{width:100%;display:flex;align-items:center;justify-content:flex-start;gap:1.142rem;padding:.571rem 1.142rem .857rem 1.142rem}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok{order:0;margin-inline-start:0}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok>button{background:#47af46;border:none;border-radius:.285rem;padding:0 2rem;height:2.285rem;line-height:2.285rem;font-weight:500;color:#fff;box-shadow:none}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok>button>span{display:none}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok>button::after{content:var(--cap-datetime-select-label, "Select");font-size:1rem}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-ok>button:disabled{background:#a1d8a0;cursor:not-allowed}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-now{order:1}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-now>a{font-size:0;font-weight:500;color:#2466ea}.cap-date-time-picker__calendar-popup .ant-picker-footer .ant-picker-ranges .ant-picker-now>a::after{content:var(--cap-datetime-today-label, "Today");font-size:1rem;vertical-align:sub}`, ""]);
7817
7874
  // Exports
7818
7875
  ___CSS_LOADER_EXPORT___.locals = {
7819
7876
  "cap-date-time-picker__calendar-icon": `cap-date-time-picker__calendar-icon`,
@@ -16731,7 +16788,7 @@ var _logDeprecationWarning = _interopRequireDefault(__webpack_require__(19224));
16731
16788
  var _messages = _interopRequireDefault(__webpack_require__(32528));
16732
16789
  var _styles = _interopRequireDefault(__webpack_require__(2580));
16733
16790
  var _jsxRuntime = __webpack_require__(74848);
16734
- const _excluded = ["intl", "className", "value", "onChange", "cellRender", "dateRender", "showTime", "format", "placeholder", "timezone", "disabledTime", "renderExtraFooter", "showToday", "onOk", "onPanelChange", "popupClassName", "dropdownClassName", "popupStyle", "dropdownStyle", "getPopupContainer", "getCalendarContainer", "popupOpen", "open", "onPopupOpenChange", "onOpenChange"];
16791
+ const _excluded = ["intl", "className", "value", "defaultValue", "onChange", "cellRender", "dateRender", "showTime", "format", "placeholder", "timezone", "disabledTime", "renderExtraFooter", "showToday", "onOk", "onPanelChange", "popupClassName", "dropdownClassName", "popupStyle", "dropdownStyle", "getPopupContainer", "getCalendarContainer", "popupOpen", "open", "onPopupOpenChange", "onOpenChange"];
16735
16792
  /**
16736
16793
  *
16737
16794
  * CapDateTimePicker
@@ -16750,6 +16807,7 @@ const CapDateTimePicker = _ref => {
16750
16807
  },
16751
16808
  className = '',
16752
16809
  value = null,
16810
+ defaultValue = null,
16753
16811
  onChange = () => {},
16754
16812
  cellRender,
16755
16813
  dateRender,
@@ -16788,16 +16846,14 @@ const CapDateTimePicker = _ref => {
16788
16846
  const skipNextCloseRef = (0, _react.useRef)(false);
16789
16847
 
16790
16848
  // Detect if consumer is using moment
16791
- const isConsumerUsingMoment = (0, _dayjs.isMomentObject)(value);
16849
+ const isConsumerUsingMoment = (0, _dayjs.isMomentObject)(value) || (0, _dayjs.isMomentObject)(defaultValue);
16792
16850
 
16793
16851
  // Parse date in timezone
16794
16852
  const parseDateTime = dateTime => {
16795
16853
  if (!dateTime) return null;
16796
-
16797
- // Convert moment to dayjs
16798
- const dayjsDateTime = (0, _dayjs.momentToDayjs)(dateTime);
16799
- if (!dayjsDateTime) return null;
16800
- return dayjsDateTime.clone().tz(timezone);
16854
+ const dayjsDateTimeToTimezone = (0, _dayjs.toDayjsInTimezone)(dateTime, timezone);
16855
+ if (!dayjsDateTimeToTimezone) return null;
16856
+ return dayjsDateTimeToTimezone;
16801
16857
  };
16802
16858
 
16803
16859
  // Today's date in target timezone
@@ -16834,7 +16890,9 @@ const CapDateTimePicker = _ref => {
16834
16890
  const handleOk = date => {
16835
16891
  skipNextCloseRef.current = false;
16836
16892
  setIsPickerOpen(false);
16837
- onOk == null || onOk(date);
16893
+ const parsedValue = parseDateTime(date);
16894
+ const result = (0, _dayjs.normalizeDateValue)(isConsumerUsingMoment, parsedValue);
16895
+ onOk == null || onOk(result != null ? result : null);
16838
16896
  };
16839
16897
 
16840
16898
  // Get the current value in the correct timezone
@@ -16845,14 +16903,18 @@ const CapDateTimePicker = _ref => {
16845
16903
 
16846
16904
  // Backward compatibility: map deprecated props to new props
16847
16905
  const finalPopupClassName = (0, _classnames.default)(_styles.default[clsPrefix + "__calendar-popup"], popupClassName != null ? popupClassName : dropdownClassName);
16848
- const finalPopupStyle = popupStyle != null ? popupStyle : dropdownStyle;
16906
+ const labelVars = {
16907
+ '--cap-datetime-select-label': "'" + formatMessage(_messages.default.selectLabel) + "'",
16908
+ '--cap-datetime-today-label': "'" + formatMessage(_messages.default.todayLabel) + "'"
16909
+ };
16910
+ const finalPopupStyle = _extends({}, labelVars, popupStyle != null ? popupStyle : dropdownStyle);
16849
16911
  const finalGetPopupContainer = getPopupContainer != null ? getPopupContainer : getCalendarContainer;
16850
16912
  const finalOpen = (_ref2 = popupOpen != null ? popupOpen : openProp) != null ? _ref2 : isPickerOpen;
16851
16913
 
16852
16914
  // Backward compatibility: map deprecated dateRender to cellRender
16853
16915
  const finalCellRender = cellRender != null ? cellRender : dateRender ? current => dateRender(current, todayDate) : undefined;
16854
16916
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antdV.DatePicker, _extends({
16855
- className: (0, _classnames.default)(_styles.default[clsPrefix], className),
16917
+ className: (0, _classnames.default)(clsPrefix, className),
16856
16918
  showTime: showTimeConfig,
16857
16919
  format: format,
16858
16920
  placeholder: placeholder || formatMessage(_messages.default.selectDateTimePlaceHolder),