@capillarytech/blaze-ui 5.1.19 → 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.
@@ -83,6 +83,10 @@ export interface CapDateTimePickerProps extends Omit<DatePickerProps<Dayjs>, 'va
83
83
  * @deprecated This prop is discouraged. Consider using custom panel components instead.
84
84
  */
85
85
  renderExtraFooter?: () => React.ReactNode;
86
+ /**
87
+ * Callback when OK button is clicked
88
+ */
89
+ onOk?: (value: Dayjs | Moment | null | Dayjs[] | Moment[]) => void;
86
90
  }
87
91
  /** Internal-only: adds react-intl's injected `intl` prop to the public props */
88
92
  export type InternalProps = CapDateTimePickerProps & WrappedComponentProps;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../components/CapDateTimePicker/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,sBACf,SAAQ,IAAI,CACV,eAAe,CAAC,KAAK,CAAC,EACpB,OAAO,GACP,UAAU,GACV,YAAY,GACZ,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,WAAW,GACX,mBAAmB,CACtB;IACD;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAEvC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtE;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC,KAAK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IAEpC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,WAAW,CAAC;IAEjE;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;IAE1C;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,EAAE,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;CACpE;AAED,gFAAgF;AAChF,MAAM,MAAM,aAAa,GAAG,sBAAsB,GAAG,qBAAqB,CAAC"}
@@ -3834,6 +3834,7 @@ exports.isDayjsObject = isDayjsObject;
3834
3834
  exports.isMomentObject = isMomentObject;
3835
3835
  exports.momentToDayjs = momentToDayjs;
3836
3836
  exports.normalizeDateValue = normalizeDateValue;
3837
+ exports.toDayjsInTimezone = toDayjsInTimezone;
3837
3838
  var _dayjs = _interopRequireDefault(__webpack_require__(87695));
3838
3839
  var _advancedFormat = _interopRequireDefault(__webpack_require__(96833));
3839
3840
  var _customParseFormat = _interopRequireDefault(__webpack_require__(2825));
@@ -3945,7 +3946,23 @@ if (!tzIsCallable) {
3945
3946
  if (_dayjs.default.isDayjs(date)) {
3946
3947
  return date.tz(tzName);
3947
3948
  }
3948
- return (0, _dayjs.default)(date).tz(tzName);
3949
+ // For strings/Dates: interpret the date/time values as being IN the target timezone
3950
+ // (matching moment.tz(string, tz) semantics). dayjs(date).tz(tz) is wrong because
3951
+ // dayjs(date) anchors to the system local timezone, so .tz() converts FROM local TO tz.
3952
+ // Instead: parse as UTC to get raw date/time values, compute the target timezone's offset,
3953
+ // then adjust the UTC timestamp so .tz() produces the intended local time.
3954
+ try {
3955
+ // Validate timezone is a real IANA timezone before applying the offset correction
3956
+ Intl.DateTimeFormat(undefined, {
3957
+ timeZone: tzName
3958
+ });
3959
+ } catch (_unused) {
3960
+ // Invalid timezone — fall back to local time
3961
+ return (0, _dayjs.default)(date);
3962
+ }
3963
+ const asUtc = _dayjs.default.utc(date);
3964
+ const tzOffset = asUtc.tz(tzName).utcOffset(); // target tz offset in minutes
3965
+ return _dayjs.default.utc(asUtc.valueOf() - tzOffset * 60000).tz(tzName);
3949
3966
  } catch (error) {
3950
3967
  // If timezone is invalid, log error and fall back to local time
3951
3968
  logDevError("dayjs.tz: Invalid timezone \"" + tzName + "\"", error);
@@ -4171,6 +4188,35 @@ function momentToDayjs(value) {
4171
4188
  return null;
4172
4189
  }
4173
4190
 
4191
+ /**
4192
+ * Converts any supported date value (Moment, Day.js, string, Date) to a Day.js object
4193
+ * in the specified timezone. This is the recommended single entry point for timezone-safe
4194
+ * date conversion — it handles moment-to-dayjs conversion and timezone application in one step,
4195
+ * avoiding the double-offset bug in dayjs-timezone-iana-plugin.
4196
+ *
4197
+ * @param value - Moment, Day.js, string, Date, or null/undefined
4198
+ * @param timezone - Target IANA timezone (e.g., 'Asia/Kolkata', 'America/New_York')
4199
+ * @returns Day.js object in the target timezone, or null if invalid
4200
+ *
4201
+ * @example
4202
+ * toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'Asia/Kolkata'), 'Asia/Kolkata');
4203
+ * // Returns dayjs representing 2025-04-21 00:00 IST
4204
+ *
4205
+ * @example
4206
+ * toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'UTC'), 'Asia/Kolkata');
4207
+ * // Returns dayjs representing 2025-04-21 05:30 IST
4208
+ */
4209
+ function toDayjsInTimezone(value, timezone) {
4210
+ const dayjsValue = momentToDayjs(value);
4211
+ if (!dayjsValue) return null;
4212
+
4213
+ // Convert via UTC to avoid the double-offset bug in dayjs-timezone-iana-plugin:
4214
+ // calling .tz() on a dayjs that already has a non-zero utcOffset corrupts the value.
4215
+ // Going through .toDate() → dayjs.utc() gives us a clean UTC-mode dayjs that .tz()
4216
+ // correctly converts to the target timezone.
4217
+ return _dayjs.default.utc(dayjsValue.toDate()).tz(timezone);
4218
+ }
4219
+
4174
4220
  /**
4175
4221
  * Converts a Day.js object to Moment.js, preserving timezone and locale information.
4176
4222
  *