@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.
- package/CapCollapsibleNavbar/index.js +47 -1
- package/CapCollapsibleNavbar/index.js.map +1 -1
- package/CapCondition/index.js +47 -1
- package/CapCondition/index.js.map +1 -1
- package/CapDatePicker/index.js +47 -1
- package/CapDatePicker/index.js.map +1 -1
- package/CapDateTimePicker/index.d.ts.map +1 -1
- package/CapDateTimePicker/index.js +56 -9
- package/CapDateTimePicker/index.js.map +1 -1
- package/CapDateTimePicker/types.d.ts +4 -0
- package/CapDateTimePicker/types.d.ts.map +1 -1
- package/CapDateTimeRangePicker/index.js +47 -1
- package/CapDateTimeRangePicker/index.js.map +1 -1
- package/CapEventCalendar/index.js +47 -1
- package/CapEventCalendar/index.js.map +1 -1
- package/CapLanguageProvider/index.js +47 -1
- package/CapLanguageProvider/index.js.map +1 -1
- package/CapNotificationDropdown/index.js +47 -1
- package/CapNotificationDropdown/index.js.map +1 -1
- package/CapTimePicker/index.js +47 -1
- package/CapTimePicker/index.js.map +1 -1
- package/index.js +56 -9
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/utils/dayjs.d.ts +19 -0
- package/utils/dayjs.d.ts.map +1 -1
|
@@ -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;;;;
|
|
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
|
-
|
|
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);
|
|
@@ -4119,6 +4136,35 @@ function momentToDayjs(value) {
|
|
|
4119
4136
|
return null;
|
|
4120
4137
|
}
|
|
4121
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
|
+
|
|
4122
4168
|
/**
|
|
4123
4169
|
* Converts a Day.js object to Moment.js, preserving timezone and locale information.
|
|
4124
4170
|
*
|
|
@@ -16742,7 +16788,7 @@ var _logDeprecationWarning = _interopRequireDefault(__webpack_require__(19224));
|
|
|
16742
16788
|
var _messages = _interopRequireDefault(__webpack_require__(32528));
|
|
16743
16789
|
var _styles = _interopRequireDefault(__webpack_require__(2580));
|
|
16744
16790
|
var _jsxRuntime = __webpack_require__(74848);
|
|
16745
|
-
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"];
|
|
16746
16792
|
/**
|
|
16747
16793
|
*
|
|
16748
16794
|
* CapDateTimePicker
|
|
@@ -16761,6 +16807,7 @@ const CapDateTimePicker = _ref => {
|
|
|
16761
16807
|
},
|
|
16762
16808
|
className = '',
|
|
16763
16809
|
value = null,
|
|
16810
|
+
defaultValue = null,
|
|
16764
16811
|
onChange = () => {},
|
|
16765
16812
|
cellRender,
|
|
16766
16813
|
dateRender,
|
|
@@ -16799,16 +16846,14 @@ const CapDateTimePicker = _ref => {
|
|
|
16799
16846
|
const skipNextCloseRef = (0, _react.useRef)(false);
|
|
16800
16847
|
|
|
16801
16848
|
// Detect if consumer is using moment
|
|
16802
|
-
const isConsumerUsingMoment = (0, _dayjs.isMomentObject)(value);
|
|
16849
|
+
const isConsumerUsingMoment = (0, _dayjs.isMomentObject)(value) || (0, _dayjs.isMomentObject)(defaultValue);
|
|
16803
16850
|
|
|
16804
16851
|
// Parse date in timezone
|
|
16805
16852
|
const parseDateTime = dateTime => {
|
|
16806
16853
|
if (!dateTime) return null;
|
|
16807
|
-
|
|
16808
|
-
|
|
16809
|
-
|
|
16810
|
-
if (!dayjsDateTime) return null;
|
|
16811
|
-
return dayjsDateTime.clone().tz(timezone);
|
|
16854
|
+
const dayjsDateTimeToTimezone = (0, _dayjs.toDayjsInTimezone)(dateTime, timezone);
|
|
16855
|
+
if (!dayjsDateTimeToTimezone) return null;
|
|
16856
|
+
return dayjsDateTimeToTimezone;
|
|
16812
16857
|
};
|
|
16813
16858
|
|
|
16814
16859
|
// Today's date in target timezone
|
|
@@ -16845,7 +16890,9 @@ const CapDateTimePicker = _ref => {
|
|
|
16845
16890
|
const handleOk = date => {
|
|
16846
16891
|
skipNextCloseRef.current = false;
|
|
16847
16892
|
setIsPickerOpen(false);
|
|
16848
|
-
|
|
16893
|
+
const parsedValue = parseDateTime(date);
|
|
16894
|
+
const result = (0, _dayjs.normalizeDateValue)(isConsumerUsingMoment, parsedValue);
|
|
16895
|
+
onOk == null || onOk(result != null ? result : null);
|
|
16849
16896
|
};
|
|
16850
16897
|
|
|
16851
16898
|
// Get the current value in the correct timezone
|