@capillarytech/blaze-ui 5.2.1 → 5.3.0
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/.DS_Store +0 -0
- package/CapCondition/index.js +0 -1
- package/CapCondition/index.js.map +1 -1
- package/CapDatePicker/index.d.ts.map +1 -1
- package/CapDatePicker/index.js +0 -1
- package/CapDatePicker/index.js.map +1 -1
- package/CapDateRangePicker/README.md +159 -0
- package/CapDateRangePicker/index.d.ts +11 -0
- package/CapDateRangePicker/index.d.ts.map +1 -0
- package/CapDateRangePicker/index.js +768 -7300
- package/CapDateRangePicker/index.js.map +1 -1
- package/CapDateRangePicker/types.d.ts +142 -0
- package/CapDateRangePicker/types.d.ts.map +1 -0
- package/CapEmptyDivWithBorder/index.js +9 -647
- package/CapEmptyDivWithBorder/index.js.map +1 -1
- package/CapMobileDateRangePicker/index.js +847 -7131
- package/CapMobileDateRangePicker/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +281 -133
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/_variables.scss +8 -0
- package/CapEmptyDivWithBorder/index.d.ts +0 -12
- package/CapEmptyDivWithBorder/index.d.ts.map +0 -1
- package/CapEmptyDivWithBorder/types.d.ts +0 -26
- package/CapEmptyDivWithBorder/types.d.ts.map +0 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# CapDateRangePicker
|
|
2
|
+
|
|
3
|
+
A wrapper component around Ant Design's DatePicker.RangePicker that provides consistent styling, timezone support, and a simplified API for date range selection in Capillary applications.
|
|
4
|
+
|
|
5
|
+
## Migration from react-dates to Ant Design v6
|
|
6
|
+
|
|
7
|
+
This component has been **completely rewritten** — the underlying library changed from `react-dates` (Airbnb) to `antd-v5` (Ant Design v6) `DatePicker.RangePicker`.
|
|
8
|
+
|
|
9
|
+
### Breaking Changes
|
|
10
|
+
|
|
11
|
+
#### 1. Library Change
|
|
12
|
+
|
|
13
|
+
| Before | After |
|
|
14
|
+
|--------|-------|
|
|
15
|
+
| `react-dates` (Airbnb) | `antd-v5` DatePicker.RangePicker |
|
|
16
|
+
| Moment.js | Day.js |
|
|
17
|
+
| Class component with internal state | Functional component (stateless) |
|
|
18
|
+
| `react-dates/initialize` + CSS import | No separate initialization needed |
|
|
19
|
+
|
|
20
|
+
#### 2. API Changes
|
|
21
|
+
|
|
22
|
+
| Old API (react-dates) | New API (antd v6) | Status | Migration Guide |
|
|
23
|
+
|-----------------------|-------------------|--------|-----------------|
|
|
24
|
+
| `initialStartDate` / `initialEndDate` | `defaultValue: [Dayjs, Dayjs]` | Deprecated | Use `defaultValue` with Dayjs array |
|
|
25
|
+
| `onDatesChange({startDate, endDate})` | `onChange([start, end], [str1, str2])` | Changed | Callback shape changed |
|
|
26
|
+
| `focusedInput` / `onFocusChange` | `open` / `onOpenChange` | Deprecated | Antd manages focus internally |
|
|
27
|
+
| `showCalendarOnly` | N/A | Deprecated | Limited support via CSS |
|
|
28
|
+
| `allowYearNavigation` | N/A | Deprecated | Built-in in antd RangePicker |
|
|
29
|
+
| `hideCalendar` | `open={false}` | Deprecated | Use `open` prop directly |
|
|
30
|
+
| `isDayBlocked` | `disabledDate` | Deprecated | Use `disabledDate` |
|
|
31
|
+
| `customInputIcon` | `suffixIcon` | Deprecated | Use `suffixIcon` |
|
|
32
|
+
| `customArrowIcon` | `separator` | Deprecated | Use `separator` |
|
|
33
|
+
| `displayFormat` | `format` | Deprecated | Use `format` |
|
|
34
|
+
| `rootClass` | `getPopupContainer` | Deprecated | Use `getPopupContainer` |
|
|
35
|
+
| `dropdownClassName` | `popupClassName` | Deprecated | Use `popupClassName` |
|
|
36
|
+
| `dropdownStyle` | `popupStyle` | Deprecated | Use `popupStyle` |
|
|
37
|
+
| `getCalendarContainer` | `getPopupContainer` | Deprecated | Use `getPopupContainer` |
|
|
38
|
+
| `minimumNights` | `disabledDate` | Deprecated | Implement via `disabledDate` |
|
|
39
|
+
| `autoFocusEndDate` | `autoFocus` | Deprecated | Use `autoFocus` |
|
|
40
|
+
| `minDate` (string) | `minDate` (Dayjs) / `disabledDate` | Deprecated | Use `disabledDate` or `minDate` |
|
|
41
|
+
|
|
42
|
+
#### 3. Date Library Migration
|
|
43
|
+
|
|
44
|
+
The component now uses Day.js instead of Moment.js:
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
// Before (moment)
|
|
48
|
+
import moment from 'moment-timezone';
|
|
49
|
+
<CapDateRangePicker
|
|
50
|
+
initialStartDate={moment('2024-01-01')}
|
|
51
|
+
initialEndDate={moment('2024-01-31')}
|
|
52
|
+
onChange={(dates) => console.log(dates)} // dates = [momentStart, momentEnd]
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
// After (dayjs)
|
|
56
|
+
import dayjs from '@dayjs';
|
|
57
|
+
<CapDateRangePicker
|
|
58
|
+
defaultValue={[dayjs('2024-01-01'), dayjs('2024-01-31')]}
|
|
59
|
+
onChange={(dates, dateStrings) => console.log(dates, dateStrings)}
|
|
60
|
+
/>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Note:** The component maintains backward compatibility for Moment.js objects passed as props — they are automatically converted to Dayjs internally. However, callbacks will always return Dayjs objects.
|
|
64
|
+
|
|
65
|
+
### Backward Compatibility
|
|
66
|
+
|
|
67
|
+
All deprecated props still work with deprecation warnings in development:
|
|
68
|
+
|
|
69
|
+
- **`initialStartDate` / `initialEndDate`**: Mapped to `defaultValue` array
|
|
70
|
+
- **`onFocusChange`**: Mapped to `onOpenChange`
|
|
71
|
+
- **`isDayBlocked`**: Merged into `disabledDate`
|
|
72
|
+
- **`customInputIcon`**: Mapped to `suffixIcon`
|
|
73
|
+
- **`customArrowIcon`**: Mapped to `separator`
|
|
74
|
+
- **`displayFormat`**: Mapped to `format`
|
|
75
|
+
- **`dropdownClassName`**: Mapped to `popupClassName`
|
|
76
|
+
- **`dropdownStyle`**: Mapped to `popupStyle`
|
|
77
|
+
- **`getCalendarContainer`**: Mapped to `getPopupContainer`
|
|
78
|
+
- **`showCalendarOnly`**: Supported via CSS (hides input, keeps picker open)
|
|
79
|
+
- **`hideCalendar`**: Mapped to `open={false}`
|
|
80
|
+
- **`allowYearNavigation`**: No-op (built-in in antd)
|
|
81
|
+
- **`autoFocusEndDate`**: Mapped to `autoFocus`
|
|
82
|
+
|
|
83
|
+
### Style Changes
|
|
84
|
+
|
|
85
|
+
**Approach**: The component uses CSS Modules with design tokens:
|
|
86
|
+
- All react-dates CSS overrides removed (no longer relevant)
|
|
87
|
+
- CSS Modules classes for component-specific styles (timezone footer)
|
|
88
|
+
- Shared `datePickerCommon.scss` for common DatePicker styling patterns
|
|
89
|
+
- Design tokens via `$CAP_*` variables and `getCapThemeConfig` DatePicker section
|
|
90
|
+
|
|
91
|
+
### Timezone Footer
|
|
92
|
+
|
|
93
|
+
The timezone footer is preserved from the original implementation:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<CapDateRangePicker
|
|
97
|
+
showTimezone
|
|
98
|
+
timezone="Asia/Kolkata"
|
|
99
|
+
onChange={(dates) => console.log(dates)}
|
|
100
|
+
/>
|
|
101
|
+
// Footer shows: "Asia/Kolkata (UTC+05:30)"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### What Stayed the Same
|
|
105
|
+
|
|
106
|
+
- Timezone footer display
|
|
107
|
+
- Custom icon support (calendar suffix icon, separator)
|
|
108
|
+
- Size variants (small, default, large)
|
|
109
|
+
- ComponentWithLabelHOC integration
|
|
110
|
+
- Default date format (`DD MMM YYYY`)
|
|
111
|
+
|
|
112
|
+
### What Changed
|
|
113
|
+
|
|
114
|
+
- **Removed**: react-dates dependency, PropTypes, class component, internal state management
|
|
115
|
+
- **Added**: TypeScript types, CSS Modules, Day.js support, deprecation warnings
|
|
116
|
+
- **Updated**: Import from `antd-v5` DatePicker.RangePicker
|
|
117
|
+
- **Updated**: Moment.js → Day.js (with automatic backward conversion)
|
|
118
|
+
|
|
119
|
+
## Usage
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import CapDateRangePicker from '@capillarytech/blaze-ui/components/CapDateRangePicker';
|
|
123
|
+
import dayjs from '@dayjs';
|
|
124
|
+
|
|
125
|
+
function MyComponent() {
|
|
126
|
+
const [dates, setDates] = useState<[dayjs.Dayjs | null, dayjs.Dayjs | null] | null>(null);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<CapDateRangePicker
|
|
130
|
+
value={dates}
|
|
131
|
+
onChange={(newDates) => setDates(newDates)}
|
|
132
|
+
size="large"
|
|
133
|
+
timezone="America/New_York"
|
|
134
|
+
showTimezone
|
|
135
|
+
format="DD MMM YYYY"
|
|
136
|
+
popupClassName="my-custom-popup"
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Props
|
|
143
|
+
|
|
144
|
+
See `types.ts` for complete prop definitions. Key props:
|
|
145
|
+
|
|
146
|
+
- `value`: `[Dayjs | null, Dayjs | null] | null`
|
|
147
|
+
- `defaultValue`: `[Dayjs | null, Dayjs | null] | null`
|
|
148
|
+
- `onChange`: `(dates, dateStrings) => void`
|
|
149
|
+
- `size`: `'small' | 'default' | 'large'` (default: `'large'`)
|
|
150
|
+
- `timezone`: Timezone string (default: `'UTC'`)
|
|
151
|
+
- `showTimezone`: Whether to show timezone footer (default: `false`)
|
|
152
|
+
- `format`: Date format string (default: `'DD MMM YYYY'`)
|
|
153
|
+
- `popupClassName`: Custom class for popup
|
|
154
|
+
- `popupStyle`: Custom style for popup
|
|
155
|
+
- `getPopupContainer`: Container for popup
|
|
156
|
+
- `suffixIcon`: Custom suffix icon
|
|
157
|
+
- `separator`: Custom separator between date inputs
|
|
158
|
+
- `disabledDate`: Function to disable specific dates
|
|
159
|
+
- `renderExtraFooter`: Render extra footer in calendar panel
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* CapDateRangePicker
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import '../styles/datePickerCommon.scss';
|
|
8
|
+
declare const _default: React.ComponentType<import("../assets/HOCs/ComponentWithLabelHOC/types").ComponentWithLabelProps & Omit<import("../assets/HOCs/ComponentWithLabelHOC/types").WrappedComponentProps, keyof import("../assets/HOCs/ComponentWithLabelHOC/types").WrappedComponentProps>>;
|
|
9
|
+
export default _default;
|
|
10
|
+
export type { CapDateRangePickerProps, RangeValue } from './types';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapDateRangePicker/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,iCAAiC,CAAC;;AAkPzC,wBAAyD;AACzD,YAAY,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|