@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.
- package/.npmrc +2 -0
- package/CapCollapsibleNavbar/index.js +55 -3
- package/CapCollapsibleNavbar/index.js.map +1 -1
- package/CapCondition/index.js +55 -3
- package/CapCondition/index.js.map +1 -1
- package/CapDatePicker/index.js +55 -3
- package/CapDatePicker/index.js.map +1 -1
- package/CapDateTimePicker/README.md +136 -0
- package/CapDateTimePicker/index.d.ts +13 -0
- package/CapDateTimePicker/index.d.ts.map +1 -0
- package/CapDateTimePicker/index.js +166 -106
- package/CapDateTimePicker/index.js.map +1 -1
- package/CapDateTimePicker/messages.d.ts +17 -0
- package/CapDateTimePicker/messages.d.ts.map +1 -0
- package/CapDateTimePicker/types.d.ts +93 -0
- package/CapDateTimePicker/types.d.ts.map +1 -0
- package/CapDateTimeRangePicker/index.js +55 -3
- package/CapDateTimeRangePicker/index.js.map +1 -1
- package/CapEventCalendar/index.js +55 -3
- package/CapEventCalendar/index.js.map +1 -1
- package/CapLanguageProvider/index.js +55 -3
- package/CapLanguageProvider/index.js.map +1 -1
- package/CapLevelGraphRenderer/CapLevelGraphRenderer-test-cases.md +50 -0
- package/CapLevelGraphRenderer/MIGRATION_ANALYSIS.md +138 -0
- package/CapLevelGraphRenderer/README.md +123 -0
- package/CapLevelGraphRenderer/STORYBOOK_ANALYSIS.md +96 -0
- package/CapLevelGraphRenderer/Tooltip.d.ts +31 -0
- package/CapLevelGraphRenderer/Tooltip.d.ts.map +1 -0
- package/CapLevelGraphRenderer/Tooltip_MIGRATION_ANALYSIS.md +120 -0
- package/CapLevelGraphRenderer/index.d.ts +16 -0
- package/CapLevelGraphRenderer/index.d.ts.map +1 -0
- package/CapLevelGraphRenderer/index.js +159 -135
- package/CapLevelGraphRenderer/index.js.map +1 -1
- package/CapLevelGraphRenderer/tests/TEST_COVERAGE.md +119 -0
- package/CapLevelGraphRenderer/types.d.ts +139 -0
- package/CapLevelGraphRenderer/types.d.ts.map +1 -0
- package/CapNotificationDropdown/index.js +55 -3
- package/CapNotificationDropdown/index.js.map +1 -1
- package/CapTimePicker/index.js +55 -3
- package/CapTimePicker/index.js.map +1 -1
- package/index.d.ts +4 -0
- package/index.d.ts.map +1 -1
- package/index.js +1053 -4
- package/index.js.map +1 -1
- package/package.json +4 -2
- package/utils/dayjs.d.ts +21 -0
- package/utils/dayjs.d.ts.map +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# CapDateTimePicker
|
|
2
|
+
|
|
3
|
+
A wrapper around Ant Design's DatePicker with `showTime` support, timezone-aware date parsing, and a consistent API for datetime selection in Capillary applications.
|
|
4
|
+
|
|
5
|
+
## Migration from Ant Design v3 to v6
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
#### 1. API Changes
|
|
10
|
+
|
|
11
|
+
| v3 API | v6 API | Status | Migration Guide |
|
|
12
|
+
|--------|--------|--------|-----------------|
|
|
13
|
+
| `dateRender` | `cellRender` | Deprecated | Replace `dateRender` with `cellRender`. Backward compatibility maintained. |
|
|
14
|
+
| `dropdownClassName` | `popupClassName` | Deprecated | Replace `dropdownClassName` with `popupClassName`. Backward compatibility maintained. |
|
|
15
|
+
| `dropdownStyle` | `popupStyle` | Deprecated | Replace `dropdownStyle` with `popupStyle`. Backward compatibility maintained. |
|
|
16
|
+
| `getCalendarContainer` | `getPopupContainer` | Deprecated | Replace `getCalendarContainer` with `getPopupContainer`. Backward compatibility maintained. |
|
|
17
|
+
| `open` | `popupOpen` | Deprecated | Replace `open` with `popupOpen`. Backward compatibility maintained. |
|
|
18
|
+
| `onOpenChange` | `onPopupOpenChange` | Deprecated | Replace `onOpenChange` with `onPopupOpenChange`. Backward compatibility maintained. |
|
|
19
|
+
| `showToday` | N/A | Deprecated | This prop is deprecated. Today button behavior is now handled internally by Ant Design. Backward compatibility maintained but discouraged. |
|
|
20
|
+
| `renderExtraFooter` | Custom Panel | Deprecated | This prop is discouraged. Consider using custom panel components instead. Backward compatibility maintained but discouraged. |
|
|
21
|
+
|
|
22
|
+
#### 2. Date Library Migration
|
|
23
|
+
|
|
24
|
+
The component continues to support both Moment.js and Day.js objects for backward compatibility:
|
|
25
|
+
|
|
26
|
+
- **Props accepting dates**: `value` now accepts `Dayjs | Moment | string | null`
|
|
27
|
+
- **Callbacks returning dates**: `onChange` returns the same type as the input (`Dayjs` if `Dayjs` was passed, `Moment` if `Moment` was passed)
|
|
28
|
+
|
|
29
|
+
**Migration Path for Consumers:**
|
|
30
|
+
```javascript
|
|
31
|
+
// Before (moment) - still works
|
|
32
|
+
import moment from 'moment-timezone';
|
|
33
|
+
<CapDateTimePicker
|
|
34
|
+
value={moment('2024-01-15 10:30')}
|
|
35
|
+
onChange={(momentObj) => console.log(momentObj.format())}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
// After (dayjs) - preferred
|
|
39
|
+
import dayjs from '@dayjs';
|
|
40
|
+
<CapDateTimePicker
|
|
41
|
+
value={dayjs('2024-01-15 10:30')}
|
|
42
|
+
onChange={(dayjsObj) => console.log(dayjsObj.format())}
|
|
43
|
+
/>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Backward Compatibility
|
|
47
|
+
|
|
48
|
+
All deprecated props still work but log a warning in development:
|
|
49
|
+
|
|
50
|
+
- **`dateRender`**: Still works but mapped to `cellRender` internally. Use `cellRender` instead.
|
|
51
|
+
- **`dropdownClassName`**: Still works. Use `popupClassName` instead.
|
|
52
|
+
- **`dropdownStyle`**: Still works. Use `popupStyle` instead.
|
|
53
|
+
- **`getCalendarContainer`**: Still works. Use `getPopupContainer` instead.
|
|
54
|
+
- **`open`**: Still works. Use `popupOpen` instead.
|
|
55
|
+
- **`onOpenChange`**: Still works. Use `onPopupOpenChange` instead.
|
|
56
|
+
- **`showToday`**: Still works but is deprecated.
|
|
57
|
+
- **`renderExtraFooter`**: Still works but is discouraged.
|
|
58
|
+
|
|
59
|
+
### Style Changes
|
|
60
|
+
|
|
61
|
+
The SCSS file (`styles.scss`) targets v3 class names (`.ant-calendar-*`) and is preserved as-is in this migration pass. Full SCSS migration to v6 class names (`.ant-picker-*`) will be done in a subsequent pass.
|
|
62
|
+
|
|
63
|
+
**Theme config**: `DatePicker.cellHoverBg` added to `getCapThemeConfig.ts` to control date cell hover background color.
|
|
64
|
+
|
|
65
|
+
### Code Improvements
|
|
66
|
+
|
|
67
|
+
1. **Removed PropTypes**: Replaced with TypeScript interfaces in `types.ts`
|
|
68
|
+
2. **Removed defaultProps**: Default values moved to function argument destructuring
|
|
69
|
+
3. **Using deprecation warning utility**: `logDeprecationWarning` for consistent warnings
|
|
70
|
+
4. **Type safety**: Full TypeScript support with proper Dayjs/Moment union types
|
|
71
|
+
5. **Backward compatibility**: All deprecated props mapped using nullish coalescing (`??`)
|
|
72
|
+
|
|
73
|
+
### What Stayed the Same
|
|
74
|
+
|
|
75
|
+
- `injectIntl` HOC pattern for i18n (no consumer-facing change)
|
|
76
|
+
- Timezone-aware date parsing logic
|
|
77
|
+
- Internal open/close state management for OK button behavior
|
|
78
|
+
- `showTime` config with timezone-aware `defaultValue`
|
|
79
|
+
- Calendar icon suffix
|
|
80
|
+
- `okText` from i18n messages
|
|
81
|
+
|
|
82
|
+
### What Changed
|
|
83
|
+
|
|
84
|
+
- **Updated**: Import from `antd-v5` (v6 compatible)
|
|
85
|
+
- **Removed**: `import 'antd/lib/date-picker/style/css'`
|
|
86
|
+
- **Removed**: PropTypes dependency
|
|
87
|
+
- **Removed**: `defaultProps` assignment
|
|
88
|
+
- **Updated**: Multiple deprecated props migrated to v6 API (with backward compatibility)
|
|
89
|
+
- **Added**: `cellRender` support (v6 replacement for `dateRender`)
|
|
90
|
+
- **Added**: `popupClassName`, `popupStyle`, `getPopupContainer`, `popupOpen`, `onPopupOpenChange`
|
|
91
|
+
|
|
92
|
+
## Usage
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import CapDateTimePicker from '@capillarytech/blaze-ui/components/CapDateTimePicker';
|
|
96
|
+
import dayjs from '@dayjs';
|
|
97
|
+
|
|
98
|
+
function MyComponent() {
|
|
99
|
+
const [date, setDate] = useState(null);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<CapDateTimePicker
|
|
103
|
+
value={date}
|
|
104
|
+
onChange={(newDate) => setDate(newDate)}
|
|
105
|
+
timezone="Asia/Kolkata"
|
|
106
|
+
showTime={{ format: 'HH:mm' }}
|
|
107
|
+
format="DD-MM-YYYY | HH:mm"
|
|
108
|
+
popupClassName="my-custom-popup"
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Props
|
|
115
|
+
|
|
116
|
+
See `types.ts` for complete prop definitions. Key props:
|
|
117
|
+
|
|
118
|
+
- `value`: `Dayjs | Moment | string | null`
|
|
119
|
+
- `onChange`: `(value: Dayjs | Moment | null, dateString: string) => void`
|
|
120
|
+
- `timezone`: Timezone string (default: `'Asia/Kolkata'`)
|
|
121
|
+
- `showTime`: `boolean | { format?: string }` (default: `{ format: 'HH:mm' }`)
|
|
122
|
+
- `format`: Date format string (default: `'DD-MM-YYYY | HH:mm'`)
|
|
123
|
+
- `cellRender`: Custom cell renderer (v6 API)
|
|
124
|
+
- `popupClassName`: Custom class for popup (v6 API)
|
|
125
|
+
- `popupStyle`: Custom style for popup (v6 API)
|
|
126
|
+
- `getPopupContainer`: Container for popup (v6 API)
|
|
127
|
+
- `popupOpen`: Whether popup is open (v6 API)
|
|
128
|
+
- `onPopupOpenChange`: Callback when popup open state changes (v6 API)
|
|
129
|
+
- `dateRender`: Deprecated — use `cellRender` instead
|
|
130
|
+
- `dropdownClassName`: Deprecated — use `popupClassName` instead
|
|
131
|
+
- `dropdownStyle`: Deprecated — use `popupStyle` instead
|
|
132
|
+
- `getCalendarContainer`: Deprecated — use `getPopupContainer` instead
|
|
133
|
+
- `open`: Deprecated — use `popupOpen` instead
|
|
134
|
+
- `onOpenChange`: Deprecated — use `onPopupOpenChange` instead
|
|
135
|
+
- `showToday`: Deprecated — handled internally by Ant Design
|
|
136
|
+
- `renderExtraFooter`: Deprecated — consider custom panel components
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* CapDateTimePicker
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import type { InternalProps } from './types';
|
|
8
|
+
declare const _default: React.FC<import("react-intl").WithIntlProps<InternalProps>> & {
|
|
9
|
+
WrappedComponent: React.ComponentType<InternalProps>;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
export type { CapDateTimePickerProps } from './types';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;;;;AAkL7C,wBAA6C;AAC7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -2973,6 +2973,24 @@ var _default = exports["default"] = SvgCircleDollar;
|
|
|
2973
2973
|
|
|
2974
2974
|
/***/ }),
|
|
2975
2975
|
|
|
2976
|
+
/***/ 19224:
|
|
2977
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2978
|
+
|
|
2979
|
+
"use strict";
|
|
2980
|
+
|
|
2981
|
+
|
|
2982
|
+
exports.__esModule = true;
|
|
2983
|
+
exports["default"] = logDeprecationWarning;
|
|
2984
|
+
var _isNil = _interopRequireDefault(__webpack_require__(69843));
|
|
2985
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
2986
|
+
function logDeprecationWarning(componentName, deprecatedPropName, deprecatedPropValue, replacementPropName) {
|
|
2987
|
+
// @ts-ignore - process.env is provided by webpack/build tools
|
|
2988
|
+
if (false) // removed by dead control flow
|
|
2989
|
+
{}
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
/***/ }),
|
|
2993
|
+
|
|
2976
2994
|
/***/ 19561:
|
|
2977
2995
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2978
2996
|
|
|
@@ -3756,7 +3774,7 @@ var _default = exports["default"] = SvgFile;
|
|
|
3756
3774
|
|
|
3757
3775
|
|
|
3758
3776
|
exports.__esModule = true;
|
|
3759
|
-
exports.TIME_UNITS = exports.FORMAT_TOKENS = void 0;
|
|
3777
|
+
exports.TIME_UNITS = exports.FORMAT_TOKENS = exports.DEFAULT_TIMEZONE = void 0;
|
|
3760
3778
|
exports.dayjsToMoment = dayjsToMoment;
|
|
3761
3779
|
exports["default"] = void 0;
|
|
3762
3780
|
exports.hasMomentTimezoneSupport = hasMomentTimezoneSupport;
|
|
@@ -3764,6 +3782,7 @@ exports.isDayjsObject = isDayjsObject;
|
|
|
3764
3782
|
exports.isMomentObject = isMomentObject;
|
|
3765
3783
|
exports.momentToDayjs = momentToDayjs;
|
|
3766
3784
|
exports.normalizeDateValue = normalizeDateValue;
|
|
3785
|
+
exports.toDayjsInTimezone = toDayjsInTimezone;
|
|
3767
3786
|
var _dayjs = _interopRequireDefault(__webpack_require__(87695));
|
|
3768
3787
|
var _advancedFormat = _interopRequireDefault(__webpack_require__(96833));
|
|
3769
3788
|
var _customParseFormat = _interopRequireDefault(__webpack_require__(2825));
|
|
@@ -3875,7 +3894,23 @@ if (!tzIsCallable) {
|
|
|
3875
3894
|
if (_dayjs.default.isDayjs(date)) {
|
|
3876
3895
|
return date.tz(tzName);
|
|
3877
3896
|
}
|
|
3878
|
-
|
|
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);
|
|
3879
3914
|
} catch (error) {
|
|
3880
3915
|
// If timezone is invalid, log error and fall back to local time
|
|
3881
3916
|
logDevError("dayjs.tz: Invalid timezone \"" + tzName + "\"", error);
|
|
@@ -3952,6 +3987,8 @@ const FORMAT_TOKENS = exports.FORMAT_TOKENS = {
|
|
|
3952
3987
|
MONTH_FULL: 'MMMM',
|
|
3953
3988
|
YEAR: 'YYYY',
|
|
3954
3989
|
YEAR_SHORT: 'YY',
|
|
3990
|
+
// Cap UI datetime picker format (DD-MM-YYYY | HH:mm)
|
|
3991
|
+
DATE_TIME: 'DD-MM-YYYY | HH:mm',
|
|
3955
3992
|
// Localized formats
|
|
3956
3993
|
DATE_LOCALIZED_SHORT: 'l',
|
|
3957
3994
|
DATETIME_LOCALIZED_SHORT: 'll',
|
|
@@ -3962,6 +3999,7 @@ const FORMAT_TOKENS = exports.FORMAT_TOKENS = {
|
|
|
3962
3999
|
DATETIME_LOCALIZED_LONG_TIME: 'LLL',
|
|
3963
4000
|
DATETIME_LOCALIZED_LONG_TIME_WEEKDAY: 'LLLL'
|
|
3964
4001
|
};
|
|
4002
|
+
const DEFAULT_TIMEZONE = exports.DEFAULT_TIMEZONE = 'Asia/Kolkata';
|
|
3965
4003
|
function logDevError(message, error) {
|
|
3966
4004
|
if (false) // removed by dead control flow
|
|
3967
4005
|
{}
|
|
@@ -4042,7 +4080,10 @@ function momentToDayjs(value) {
|
|
|
4042
4080
|
const tz = value.tz();
|
|
4043
4081
|
if (tz) {
|
|
4044
4082
|
// Has a named timezone - preserve it
|
|
4045
|
-
|
|
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);
|
|
4046
4087
|
|
|
4047
4088
|
// WORKAROUND: dayjs-timezone-iana-plugin doesn't persist timezone name in standard way
|
|
4048
4089
|
// Store it manually in $x for round-trip conversion fidelity
|
|
@@ -4095,6 +4136,35 @@ function momentToDayjs(value) {
|
|
|
4095
4136
|
return null;
|
|
4096
4137
|
}
|
|
4097
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
|
+
|
|
4098
4168
|
/**
|
|
4099
4169
|
* Converts a Day.js object to Moment.js, preserving timezone and locale information.
|
|
4100
4170
|
*
|
|
@@ -5342,17 +5412,17 @@ exports.scope = exports["default"] = void 0;
|
|
|
5342
5412
|
var _reactIntl = __webpack_require__(46407);
|
|
5343
5413
|
const scope = exports.scope = 'app.commonUtils.capUiLibrary.capDateTimePicker';
|
|
5344
5414
|
var _default = exports["default"] = (0, _reactIntl.defineMessages)({
|
|
5345
|
-
selectDateAndTime: {
|
|
5346
|
-
id: scope + ".selectDateAndTime",
|
|
5347
|
-
defaultMessage: 'Select date & time'
|
|
5348
|
-
},
|
|
5349
|
-
selectButton: {
|
|
5350
|
-
id: scope + ".selectButton",
|
|
5351
|
-
defaultMessage: 'Select'
|
|
5352
|
-
},
|
|
5353
5415
|
selectDateTimePlaceHolder: {
|
|
5354
5416
|
id: scope + ".selectDateTimePlaceHolder",
|
|
5355
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'
|
|
5356
5426
|
}
|
|
5357
5427
|
});
|
|
5358
5428
|
|
|
@@ -7800,24 +7870,11 @@ var ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ = __webpack_require__(31601);
|
|
|
7800
7870
|
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(76314);
|
|
7801
7871
|
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
|
|
7802
7872
|
// Module
|
|
7803
|
-
___CSS_LOADER_EXPORT___.push([module.id, `.cap-date-time-picker__calendar-icon{color:#091e42}.cap-date-time-
|
|
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}`, ""]);
|
|
7804
7874
|
// Exports
|
|
7805
7875
|
___CSS_LOADER_EXPORT___.locals = {
|
|
7806
7876
|
"cap-date-time-picker__calendar-icon": `cap-date-time-picker__calendar-icon`,
|
|
7807
|
-
"cap-date-time-
|
|
7808
|
-
"ant-calendar-picker-input": `ant-calendar-picker-input`,
|
|
7809
|
-
"calendar-popup": `calendar-popup`,
|
|
7810
|
-
"ant-calendar-ok-btn": `ant-calendar-ok-btn`,
|
|
7811
|
-
"ant-calendar-today-btn": `ant-calendar-today-btn`,
|
|
7812
|
-
"ant-calendar-time-picker-btn": `ant-calendar-time-picker-btn`,
|
|
7813
|
-
"ant-calendar-today": `ant-calendar-today`,
|
|
7814
|
-
"ant-calendar-date": `ant-calendar-date`,
|
|
7815
|
-
"ant-calendar-selected-day": `ant-calendar-selected-day`,
|
|
7816
|
-
"ant-calendar-footer": `ant-calendar-footer`,
|
|
7817
|
-
"ant-calendar-footer-btn": `ant-calendar-footer-btn`,
|
|
7818
|
-
"ant-calendar-ok-btn-disabled": `ant-calendar-ok-btn-disabled`,
|
|
7819
|
-
"ant-calendar-time-picker-btn-disabled": `ant-calendar-time-picker-btn-disabled`,
|
|
7820
|
-
"ant-calendar-time-picker-cell-selected": `ant-calendar-time-picker-cell-selected`
|
|
7877
|
+
"cap-date-time-picker__calendar-popup": `cap-date-time-picker__calendar-popup`
|
|
7821
7878
|
};
|
|
7822
7879
|
module.exports = ___CSS_LOADER_EXPORT___;
|
|
7823
7880
|
|
|
@@ -11252,14 +11309,6 @@ var _default = exports["default"] = SvgWechatOutline;
|
|
|
11252
11309
|
|
|
11253
11310
|
/***/ }),
|
|
11254
11311
|
|
|
11255
|
-
/***/ 61545:
|
|
11256
|
-
/***/ ((module) => {
|
|
11257
|
-
|
|
11258
|
-
"use strict";
|
|
11259
|
-
module.exports = require("antd/lib/date-picker/style/css");
|
|
11260
|
-
|
|
11261
|
-
/***/ }),
|
|
11262
|
-
|
|
11263
11312
|
/***/ 61779:
|
|
11264
11313
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
11265
11314
|
|
|
@@ -11585,6 +11634,14 @@ var _default = exports["default"] = SvgDisneyHotstar;
|
|
|
11585
11634
|
|
|
11586
11635
|
/***/ }),
|
|
11587
11636
|
|
|
11637
|
+
/***/ 64273:
|
|
11638
|
+
/***/ ((module) => {
|
|
11639
|
+
|
|
11640
|
+
"use strict";
|
|
11641
|
+
module.exports = require("antd-v5");
|
|
11642
|
+
|
|
11643
|
+
/***/ }),
|
|
11644
|
+
|
|
11588
11645
|
/***/ 64284:
|
|
11589
11646
|
/***/ ((module) => {
|
|
11590
11647
|
|
|
@@ -16476,14 +16533,6 @@ module.exports = require("dayjs/plugin/advancedFormat");
|
|
|
16476
16533
|
|
|
16477
16534
|
/***/ }),
|
|
16478
16535
|
|
|
16479
|
-
/***/ 97185:
|
|
16480
|
-
/***/ ((module) => {
|
|
16481
|
-
|
|
16482
|
-
"use strict";
|
|
16483
|
-
module.exports = require("antd");
|
|
16484
|
-
|
|
16485
|
-
/***/ }),
|
|
16486
|
-
|
|
16487
16536
|
/***/ 97849:
|
|
16488
16537
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
16489
16538
|
|
|
@@ -16729,57 +16778,82 @@ var exports = __webpack_exports__;
|
|
|
16729
16778
|
|
|
16730
16779
|
exports.__esModule = true;
|
|
16731
16780
|
exports["default"] = void 0;
|
|
16732
|
-
var
|
|
16733
|
-
__webpack_require__(61545);
|
|
16781
|
+
var _antdV = __webpack_require__(64273);
|
|
16734
16782
|
var _classnames = _interopRequireDefault(__webpack_require__(46942));
|
|
16735
|
-
var _propTypes = _interopRequireDefault(__webpack_require__(43363));
|
|
16736
16783
|
var _react = _interopRequireWildcard(__webpack_require__(9206));
|
|
16737
16784
|
var _reactIntl = __webpack_require__(46407);
|
|
16738
16785
|
var _dayjs = _interopRequireWildcard(__webpack_require__(25549));
|
|
16739
16786
|
var _CapIcon = _interopRequireDefault(__webpack_require__(65124));
|
|
16787
|
+
var _logDeprecationWarning = _interopRequireDefault(__webpack_require__(19224));
|
|
16740
16788
|
var _messages = _interopRequireDefault(__webpack_require__(32528));
|
|
16741
|
-
__webpack_require__(2580);
|
|
16789
|
+
var _styles = _interopRequireDefault(__webpack_require__(2580));
|
|
16742
16790
|
var _jsxRuntime = __webpack_require__(74848);
|
|
16743
|
-
const _excluded = ["intl", "className", "value", "onChange", "dateRender", "showTime", "format", "placeholder", "timezone", "disabledTime", "renderExtraFooter", "showToday", "onOk", "onPanelChange"];
|
|
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"];
|
|
16792
|
+
/**
|
|
16793
|
+
*
|
|
16794
|
+
* CapDateTimePicker
|
|
16795
|
+
*
|
|
16796
|
+
*/
|
|
16744
16797
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16745
16798
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16746
16799
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
16747
16800
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
16748
16801
|
const clsPrefix = 'cap-date-time-picker';
|
|
16749
16802
|
const CapDateTimePicker = _ref => {
|
|
16803
|
+
var _ref2;
|
|
16750
16804
|
let {
|
|
16751
16805
|
intl: {
|
|
16752
16806
|
formatMessage
|
|
16753
16807
|
},
|
|
16754
|
-
className,
|
|
16755
|
-
value,
|
|
16756
|
-
|
|
16808
|
+
className = '',
|
|
16809
|
+
value = null,
|
|
16810
|
+
defaultValue = null,
|
|
16811
|
+
onChange = () => {},
|
|
16812
|
+
cellRender,
|
|
16757
16813
|
dateRender,
|
|
16758
|
-
showTime
|
|
16759
|
-
|
|
16760
|
-
|
|
16761
|
-
|
|
16814
|
+
showTime = {
|
|
16815
|
+
format: _dayjs.FORMAT_TOKENS.TIME_24H
|
|
16816
|
+
},
|
|
16817
|
+
format = _dayjs.FORMAT_TOKENS.DATE_TIME,
|
|
16818
|
+
placeholder = '',
|
|
16819
|
+
timezone = _dayjs.DEFAULT_TIMEZONE,
|
|
16762
16820
|
disabledTime,
|
|
16763
16821
|
renderExtraFooter,
|
|
16764
16822
|
showToday,
|
|
16765
16823
|
onOk,
|
|
16766
|
-
onPanelChange
|
|
16824
|
+
onPanelChange,
|
|
16825
|
+
popupClassName,
|
|
16826
|
+
dropdownClassName,
|
|
16827
|
+
popupStyle,
|
|
16828
|
+
dropdownStyle,
|
|
16829
|
+
getPopupContainer,
|
|
16830
|
+
getCalendarContainer,
|
|
16831
|
+
popupOpen,
|
|
16832
|
+
open: openProp,
|
|
16833
|
+
onPopupOpenChange,
|
|
16834
|
+
onOpenChange
|
|
16767
16835
|
} = _ref,
|
|
16768
16836
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
16769
|
-
|
|
16837
|
+
(0, _logDeprecationWarning.default)('CapDateTimePicker', 'dateRender', dateRender, 'cellRender');
|
|
16838
|
+
(0, _logDeprecationWarning.default)('CapDateTimePicker', 'dropdownClassName', dropdownClassName, 'popupClassName');
|
|
16839
|
+
(0, _logDeprecationWarning.default)('CapDateTimePicker', 'dropdownStyle', dropdownStyle, 'popupStyle');
|
|
16840
|
+
(0, _logDeprecationWarning.default)('CapDateTimePicker', 'getCalendarContainer', getCalendarContainer, 'getPopupContainer');
|
|
16841
|
+
(0, _logDeprecationWarning.default)('CapDateTimePicker', 'open', openProp, 'popupOpen');
|
|
16842
|
+
(0, _logDeprecationWarning.default)('CapDateTimePicker', 'onOpenChange', onOpenChange, 'onPopupOpenChange');
|
|
16843
|
+
(0, _logDeprecationWarning.default)('CapDateTimePicker', 'showToday', showToday, 'N/A (handled internally)');
|
|
16844
|
+
(0, _logDeprecationWarning.default)('CapDateTimePicker', 'renderExtraFooter', renderExtraFooter, 'custom panel components');
|
|
16845
|
+
const [isPickerOpen, setIsPickerOpen] = (0, _react.useState)(false);
|
|
16770
16846
|
const skipNextCloseRef = (0, _react.useRef)(false);
|
|
16771
16847
|
|
|
16772
16848
|
// Detect if consumer is using moment
|
|
16773
|
-
const isConsumerUsingMoment = (0, _dayjs.isMomentObject)(value);
|
|
16849
|
+
const isConsumerUsingMoment = (0, _dayjs.isMomentObject)(value) || (0, _dayjs.isMomentObject)(defaultValue);
|
|
16774
16850
|
|
|
16775
16851
|
// Parse date in timezone
|
|
16776
16852
|
const parseDateTime = dateTime => {
|
|
16777
16853
|
if (!dateTime) return null;
|
|
16778
|
-
|
|
16779
|
-
|
|
16780
|
-
|
|
16781
|
-
if (!dayjsDateTime) return null;
|
|
16782
|
-
return dayjsDateTime.clone().tz(timezone);
|
|
16854
|
+
const dayjsDateTimeToTimezone = (0, _dayjs.toDayjsInTimezone)(dateTime, timezone);
|
|
16855
|
+
if (!dayjsDateTimeToTimezone) return null;
|
|
16856
|
+
return dayjsDateTimeToTimezone;
|
|
16783
16857
|
};
|
|
16784
16858
|
|
|
16785
16859
|
// Today's date in target timezone
|
|
@@ -16801,19 +16875,24 @@ const CapDateTimePicker = _ref => {
|
|
|
16801
16875
|
|
|
16802
16876
|
// Handle calendar change
|
|
16803
16877
|
const handleChange = (newValue, dateString) => {
|
|
16878
|
+
if (Array.isArray(newValue) || Array.isArray(dateString)) return;
|
|
16804
16879
|
const parsedValue = parseDateTime(newValue);
|
|
16805
16880
|
|
|
16806
16881
|
// Return the same type the consumer passed in
|
|
16807
16882
|
const result = (0, _dayjs.normalizeDateValue)(isConsumerUsingMoment, parsedValue);
|
|
16808
|
-
onChange(result, dateString);
|
|
16883
|
+
onChange(result != null ? result : null, dateString != null ? dateString : '');
|
|
16809
16884
|
};
|
|
16810
16885
|
const handleOpenChange = nextOpen => {
|
|
16811
|
-
|
|
16886
|
+
setIsPickerOpen(nextOpen);
|
|
16887
|
+
onPopupOpenChange == null || onPopupOpenChange(nextOpen);
|
|
16888
|
+
onOpenChange == null || onOpenChange(nextOpen);
|
|
16812
16889
|
};
|
|
16813
|
-
const handleOk =
|
|
16890
|
+
const handleOk = date => {
|
|
16814
16891
|
skipNextCloseRef.current = false;
|
|
16815
|
-
|
|
16816
|
-
|
|
16892
|
+
setIsPickerOpen(false);
|
|
16893
|
+
const parsedValue = parseDateTime(date);
|
|
16894
|
+
const result = (0, _dayjs.normalizeDateValue)(isConsumerUsingMoment, parsedValue);
|
|
16895
|
+
onOk == null || onOk(result != null ? result : null);
|
|
16817
16896
|
};
|
|
16818
16897
|
|
|
16819
16898
|
// Get the current value in the correct timezone
|
|
@@ -16821,17 +16900,31 @@ const CapDateTimePicker = _ref => {
|
|
|
16821
16900
|
if (!value) return null;
|
|
16822
16901
|
return parseDateTime(value);
|
|
16823
16902
|
}, [value, timezone]);
|
|
16824
|
-
|
|
16903
|
+
|
|
16904
|
+
// Backward compatibility: map deprecated props to new props
|
|
16905
|
+
const finalPopupClassName = (0, _classnames.default)(_styles.default[clsPrefix + "__calendar-popup"], popupClassName != null ? popupClassName : dropdownClassName);
|
|
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);
|
|
16911
|
+
const finalGetPopupContainer = getPopupContainer != null ? getPopupContainer : getCalendarContainer;
|
|
16912
|
+
const finalOpen = (_ref2 = popupOpen != null ? popupOpen : openProp) != null ? _ref2 : isPickerOpen;
|
|
16913
|
+
|
|
16914
|
+
// Backward compatibility: map deprecated dateRender to cellRender
|
|
16915
|
+
const finalCellRender = cellRender != null ? cellRender : dateRender ? current => dateRender(current, todayDate) : undefined;
|
|
16916
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antdV.DatePicker, _extends({
|
|
16825
16917
|
className: (0, _classnames.default)(clsPrefix, className),
|
|
16826
16918
|
showTime: showTimeConfig,
|
|
16827
16919
|
format: format,
|
|
16828
16920
|
placeholder: placeholder || formatMessage(_messages.default.selectDateTimePlaceHolder),
|
|
16829
16921
|
value: currentValue,
|
|
16830
16922
|
onChange: handleChange,
|
|
16831
|
-
|
|
16832
|
-
|
|
16833
|
-
|
|
16834
|
-
|
|
16923
|
+
cellRender: finalCellRender,
|
|
16924
|
+
popupClassName: finalPopupClassName,
|
|
16925
|
+
popupStyle: finalPopupStyle,
|
|
16926
|
+
getPopupContainer: finalGetPopupContainer,
|
|
16927
|
+
open: finalOpen,
|
|
16835
16928
|
onOk: handleOk,
|
|
16836
16929
|
onOpenChange: handleOpenChange,
|
|
16837
16930
|
onPanelChange: onPanelChange,
|
|
@@ -16842,43 +16935,10 @@ const CapDateTimePicker = _ref => {
|
|
|
16842
16935
|
suffixIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CapIcon.default, {
|
|
16843
16936
|
type: "calendar",
|
|
16844
16937
|
size: "m",
|
|
16845
|
-
className: clsPrefix + "__calendar-icon"
|
|
16938
|
+
className: _styles.default[clsPrefix + "__calendar-icon"]
|
|
16846
16939
|
})
|
|
16847
16940
|
}, rest));
|
|
16848
16941
|
};
|
|
16849
|
-
|
|
16850
|
-
/* ── prop types & defaults ────────────────────────────────── */
|
|
16851
|
-
CapDateTimePicker.propTypes = {
|
|
16852
|
-
intl: _reactIntl.intlShape.isRequired,
|
|
16853
|
-
className: _propTypes.default.string,
|
|
16854
|
-
value: _propTypes.default.oneOfType([_propTypes.default.object,
|
|
16855
|
-
// Moment or dayjs
|
|
16856
|
-
_propTypes.default.string // ISO date
|
|
16857
|
-
]),
|
|
16858
|
-
onChange: _propTypes.default.func,
|
|
16859
|
-
dateRender: _propTypes.default.func,
|
|
16860
|
-
showTime: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
|
|
16861
|
-
format: _propTypes.default.string,
|
|
16862
|
-
placeholder: _propTypes.default.string,
|
|
16863
|
-
timezone: _propTypes.default.string,
|
|
16864
|
-
disabledTime: _propTypes.default.func,
|
|
16865
|
-
renderExtraFooter: _propTypes.default.func,
|
|
16866
|
-
showToday: _propTypes.default.bool,
|
|
16867
|
-
onOk: _propTypes.default.func,
|
|
16868
|
-
onPanelChange: _propTypes.default.func
|
|
16869
|
-
};
|
|
16870
|
-
CapDateTimePicker.defaultProps = {
|
|
16871
|
-
className: '',
|
|
16872
|
-
value: null,
|
|
16873
|
-
onChange: () => {},
|
|
16874
|
-
showTime: {
|
|
16875
|
-
format: 'HH:mm'
|
|
16876
|
-
},
|
|
16877
|
-
format: 'DD-MM-YYYY | HH:mm',
|
|
16878
|
-
placeholder: '',
|
|
16879
|
-
timezone: 'Asia/Kolkata',
|
|
16880
|
-
showToday: true
|
|
16881
|
-
};
|
|
16882
16942
|
var _default = exports["default"] = (0, _reactIntl.injectIntl)(CapDateTimePicker);
|
|
16883
16943
|
})();
|
|
16884
16944
|
|