@juspay/blend-design-system 0.0.18 → 0.0.19
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/dist/components/DateRangePicker/CalendarGrid.d.ts +3 -1
- package/dist/components/DateRangePicker/QuickRangeSelector.d.ts +3 -1
- package/dist/components/DateRangePicker/dateRangePicker.tokens.d.ts +6 -0
- package/dist/components/DateRangePicker/types.d.ts +112 -0
- package/dist/components/DateRangePicker/utils.d.ts +97 -3
- package/dist/main.js +12601 -12452
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateRange } from './types';
|
|
1
|
+
import { DateRange, CustomRangeConfig } from './types';
|
|
2
2
|
type CalendarGridProps = {
|
|
3
3
|
selectedRange: DateRange;
|
|
4
4
|
onDateSelect: (range: DateRange) => void;
|
|
@@ -8,6 +8,8 @@ type CalendarGridProps = {
|
|
|
8
8
|
disablePastDates?: boolean;
|
|
9
9
|
hideFutureDates?: boolean;
|
|
10
10
|
hidePastDates?: boolean;
|
|
11
|
+
customDisableDates?: (date: Date) => boolean;
|
|
12
|
+
customRangeConfig?: CustomRangeConfig;
|
|
11
13
|
showDateTimePicker?: boolean;
|
|
12
14
|
};
|
|
13
15
|
declare const CalendarGrid: import('react').ForwardRefExoticComponent<CalendarGridProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { DateRangePreset, DateRangePickerSize } from './types';
|
|
1
|
+
import { DateRangePreset, DateRangePickerSize, CustomPresetConfig } from './types';
|
|
2
2
|
type QuickRangeSelectorProps = {
|
|
3
3
|
isOpen: boolean;
|
|
4
4
|
onToggle: () => void;
|
|
5
5
|
activePreset: DateRangePreset;
|
|
6
6
|
onPresetSelect: (preset: DateRangePreset) => void;
|
|
7
7
|
excludeCustom?: boolean;
|
|
8
|
+
customPresets?: CustomPresetConfig[];
|
|
8
9
|
className?: string;
|
|
9
10
|
disableFutureDates?: boolean;
|
|
10
11
|
disablePastDates?: boolean;
|
|
11
12
|
isDisabled?: boolean;
|
|
12
13
|
size?: DateRangePickerSize;
|
|
13
14
|
maxMenuHeight?: number;
|
|
15
|
+
isStandalone?: boolean;
|
|
14
16
|
};
|
|
15
17
|
declare const QuickRangeSelector: import('react').ForwardRefExoticComponent<QuickRangeSelectorProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
16
18
|
export default QuickRangeSelector;
|
|
@@ -28,6 +28,11 @@ export type CalendarTokenType = {
|
|
|
28
28
|
md: CSSObject['fontSize'];
|
|
29
29
|
lg: CSSObject['fontSize'];
|
|
30
30
|
};
|
|
31
|
+
disabled: {
|
|
32
|
+
borderLeft: CSSObject['borderLeft'];
|
|
33
|
+
borderTop: CSSObject['borderTop'];
|
|
34
|
+
borderBottom: CSSObject['borderBottom'];
|
|
35
|
+
};
|
|
31
36
|
};
|
|
32
37
|
content: {
|
|
33
38
|
padding: CSSObject['padding'];
|
|
@@ -164,6 +169,7 @@ export type CalendarTokenType = {
|
|
|
164
169
|
disabled: {
|
|
165
170
|
opacity: CSSObject['opacity'];
|
|
166
171
|
cursor: CSSObject['cursor'];
|
|
172
|
+
border: CSSObject['border'];
|
|
167
173
|
};
|
|
168
174
|
borderRadiusWithPresets: CSSObject['borderRadius'];
|
|
169
175
|
borderRadiusWithoutPresets: CSSObject['borderRadius'];
|
|
@@ -4,10 +4,14 @@ export declare enum DateRangePreset {
|
|
|
4
4
|
TODAY = "today",
|
|
5
5
|
YESTERDAY = "yesterday",
|
|
6
6
|
TOMORROW = "tomorrow",
|
|
7
|
+
LAST_30_MINUTES = "last30Minutes",
|
|
7
8
|
LAST_1_HOUR = "last1Hour",
|
|
8
9
|
LAST_6_HOURS = "last6Hours",
|
|
10
|
+
LAST_24_HOURS = "last24Hours",
|
|
9
11
|
LAST_7_DAYS = "last7Days",
|
|
10
12
|
LAST_30_DAYS = "last30Days",
|
|
13
|
+
THIS_MONTH = "thisMonth",
|
|
14
|
+
LAST_MONTH = "lastMonth",
|
|
11
15
|
LAST_3_MONTHS = "last3Months",
|
|
12
16
|
LAST_12_MONTHS = "last12Months",
|
|
13
17
|
NEXT_7_DAYS = "next7Days",
|
|
@@ -137,11 +141,116 @@ export type PickerColumnData = {
|
|
|
137
141
|
items: (string | number)[];
|
|
138
142
|
selectedIndex: number;
|
|
139
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* Custom preset configuration for predefined presets
|
|
146
|
+
*/
|
|
147
|
+
export type CustomPresetConfig = {
|
|
148
|
+
preset: DateRangePreset;
|
|
149
|
+
label?: string;
|
|
150
|
+
visible?: boolean;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Custom preset definition for truly custom presets
|
|
154
|
+
*/
|
|
155
|
+
export type CustomPresetDefinition = {
|
|
156
|
+
id: string;
|
|
157
|
+
label: string;
|
|
158
|
+
getDateRange: () => DateRange;
|
|
159
|
+
visible?: boolean;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Presets configuration - can be predefined presets, custom configs, or custom definitions
|
|
163
|
+
*/
|
|
164
|
+
export type PresetsConfig = DateRangePreset[] | CustomPresetConfig[] | CustomPresetDefinition[] | (DateRangePreset | CustomPresetConfig | CustomPresetDefinition)[];
|
|
165
|
+
/**
|
|
166
|
+
* Function type for custom date disabling logic
|
|
167
|
+
* @param date The date to check
|
|
168
|
+
* @returns true if the date should be disabled, false otherwise
|
|
169
|
+
*/
|
|
170
|
+
export type CustomDateDisableFunction = (date: Date) => boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Function type for custom range calculation
|
|
173
|
+
* @param selectedDate The date that was selected
|
|
174
|
+
* @param currentRange The current date range
|
|
175
|
+
* @param isStartDate Whether the selected date is for start or end
|
|
176
|
+
* @returns The new date range or null to use default behavior
|
|
177
|
+
*/
|
|
178
|
+
export type CustomRangeCalculationFunction = (selectedDate: Date, currentRange: DateRange, isStartDate: boolean) => DateRange | null;
|
|
179
|
+
/**
|
|
180
|
+
* Configuration for automatic range calculation
|
|
181
|
+
*/
|
|
182
|
+
export type AutoRangeConfig = {
|
|
183
|
+
/** Number of days to add to start date for end date */
|
|
184
|
+
rangeDays?: number;
|
|
185
|
+
/** Number of hours to add to start date for end date */
|
|
186
|
+
rangeHours?: number;
|
|
187
|
+
/** Number of minutes to add to start date for end date */
|
|
188
|
+
rangeMinutes?: number;
|
|
189
|
+
/** Whether to include the start date in the range (true) or exclude it (false) */
|
|
190
|
+
includeStartDate?: boolean;
|
|
191
|
+
/** Custom function to calculate the range */
|
|
192
|
+
customCalculation?: CustomRangeCalculationFunction;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Function type for custom range calculation
|
|
196
|
+
* @param startDate The selected start date
|
|
197
|
+
* @param currentRange The current selected range (if any)
|
|
198
|
+
* @returns The calculated end date, or null to use default behavior
|
|
199
|
+
*/
|
|
200
|
+
export type CustomRangeCalculatorFunction = (startDate: Date, currentRange?: DateRange) => Date | null;
|
|
201
|
+
/**
|
|
202
|
+
* Configuration for custom range behavior
|
|
203
|
+
*/
|
|
204
|
+
export type CustomRangeConfig = {
|
|
205
|
+
/**
|
|
206
|
+
* Function to calculate end date based on start date
|
|
207
|
+
*/
|
|
208
|
+
calculateEndDate?: CustomRangeCalculatorFunction;
|
|
209
|
+
/**
|
|
210
|
+
* Fixed number of days for the range (alternative to calculateEndDate)
|
|
211
|
+
*/
|
|
212
|
+
fixedDayRange?: number;
|
|
213
|
+
/**
|
|
214
|
+
* Reference date range to use for comparison/duration calculation
|
|
215
|
+
* When provided, the component will calculate a range with the same duration
|
|
216
|
+
*/
|
|
217
|
+
referenceRange?: DateRange;
|
|
218
|
+
/**
|
|
219
|
+
* Number of days to go backward for backward ranges (e.g., last 5 days)
|
|
220
|
+
* Used when calculateEndDate returns the same date as clicked date
|
|
221
|
+
* @default 6
|
|
222
|
+
*/
|
|
223
|
+
backwardDays?: number;
|
|
224
|
+
/**
|
|
225
|
+
* Whether to allow manual end date selection when using custom range logic
|
|
226
|
+
* @default false
|
|
227
|
+
*/
|
|
228
|
+
allowManualEndDateSelection?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Whether to apply custom range logic to preset selections
|
|
231
|
+
* @default false
|
|
232
|
+
*/
|
|
233
|
+
applyToPresets?: boolean;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Preset selection callback data
|
|
237
|
+
*/
|
|
238
|
+
export type PresetSelectionData = {
|
|
239
|
+
preset: DateRangePreset;
|
|
240
|
+
label: string;
|
|
241
|
+
dateRange: DateRange;
|
|
242
|
+
formattedStartDate: string;
|
|
243
|
+
formattedEndDate: string;
|
|
244
|
+
formattedStartTime: string;
|
|
245
|
+
formattedEndTime: string;
|
|
246
|
+
};
|
|
140
247
|
export type DateRangePickerProps = {
|
|
141
248
|
value?: DateRange;
|
|
142
249
|
onChange?: (range: DateRange) => void;
|
|
250
|
+
onPresetSelection?: (data: PresetSelectionData) => void;
|
|
143
251
|
showDateTimePicker?: boolean;
|
|
144
252
|
showPresets?: boolean;
|
|
253
|
+
customPresets?: PresetsConfig;
|
|
145
254
|
placeholder?: string;
|
|
146
255
|
isDisabled?: boolean;
|
|
147
256
|
icon?: ReactNode;
|
|
@@ -153,6 +262,8 @@ export type DateRangePickerProps = {
|
|
|
153
262
|
disablePastDates?: boolean;
|
|
154
263
|
hideFutureDates?: boolean;
|
|
155
264
|
hidePastDates?: boolean;
|
|
265
|
+
customDisableDates?: CustomDateDisableFunction;
|
|
266
|
+
customRangeConfig?: CustomRangeConfig;
|
|
156
267
|
triggerElement?: ReactNode;
|
|
157
268
|
useDrawerOnMobile?: boolean;
|
|
158
269
|
skipQuickFiltersOnMobile?: boolean;
|
|
@@ -160,6 +271,7 @@ export type DateRangePickerProps = {
|
|
|
160
271
|
formatConfig?: DateFormatConfig;
|
|
161
272
|
triggerConfig?: TriggerConfig;
|
|
162
273
|
maxMenuHeight?: number;
|
|
274
|
+
showPreset?: boolean;
|
|
163
275
|
};
|
|
164
276
|
export type PresetItemProps = {
|
|
165
277
|
preset: DateRangePreset;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateRange, DateRangePreset, DateFormatConfig, CustomFormatFunction, HapticFeedbackType } from './types';
|
|
1
|
+
import { DateRange, DateRangePreset, DateFormatConfig, CustomFormatFunction, HapticFeedbackType, CustomPresetConfig, CustomPresetDefinition, PresetsConfig, CustomRangeConfig } from './types';
|
|
2
2
|
import { CalendarTokenType } from './dateRangePicker.tokens';
|
|
3
3
|
/**
|
|
4
4
|
* Formats a date according to the specified format
|
|
@@ -277,9 +277,10 @@ export declare const getScrollToMonth: (monthIndex: number, monthHeight: number)
|
|
|
277
277
|
* @param today Today's date
|
|
278
278
|
* @param disableFutureDates Whether future dates are disabled
|
|
279
279
|
* @param disablePastDates Whether past dates are disabled
|
|
280
|
+
* @param customDisableDates Custom function to disable specific dates
|
|
280
281
|
* @returns Object with all date states
|
|
281
282
|
*/
|
|
282
|
-
export declare const getDateCellStates: (date: Date, selectedRange: DateRange, today: Date, disableFutureDates?: boolean, disablePastDates?: boolean) => {
|
|
283
|
+
export declare const getDateCellStates: (date: Date, selectedRange: DateRange, today: Date, disableFutureDates?: boolean, disablePastDates?: boolean, customDisableDates?: (date: Date) => boolean) => {
|
|
283
284
|
isStart: boolean;
|
|
284
285
|
isEnd: boolean;
|
|
285
286
|
isRangeDay: boolean;
|
|
@@ -473,9 +474,10 @@ export declare const createCalendarMonthData: (year: number, month: number, mont
|
|
|
473
474
|
* @param disableFutureDates Whether future dates are disabled
|
|
474
475
|
* @param disablePastDates Whether past dates are disabled
|
|
475
476
|
* @param calendarToken Calendar token for styling
|
|
477
|
+
* @param customDisableDates Custom function to disable specific dates
|
|
476
478
|
* @returns Day cell props
|
|
477
479
|
*/
|
|
478
|
-
export declare const calculateDayCellProps: (date: Date, selectedRange: DateRange, today: Date, disableFutureDates: boolean, disablePastDates: boolean, calendarToken: CalendarTokenType) => {
|
|
480
|
+
export declare const calculateDayCellProps: (date: Date, selectedRange: DateRange, today: Date, disableFutureDates: boolean, disablePastDates: boolean, calendarToken: CalendarTokenType, customDisableDates?: (date: Date) => boolean) => {
|
|
479
481
|
dateStates: ReturnType<typeof getDateCellStates>;
|
|
480
482
|
styles: Record<string, unknown>;
|
|
481
483
|
textColor: string | unknown;
|
|
@@ -703,6 +705,28 @@ export declare const shouldHideDateFromCalendar: (date: Date, today: Date, hideF
|
|
|
703
705
|
* @returns New date range or null if click should be ignored
|
|
704
706
|
*/
|
|
705
707
|
export declare const handleEnhancedCalendarDateClick: (clickedDate: Date, selectedRange: DateRange, allowSingleDateSelection: boolean | undefined, today: Date, disableFutureDates?: boolean, disablePastDates?: boolean, isDoubleClick?: boolean) => DateRange | null;
|
|
708
|
+
/**
|
|
709
|
+
* Validates custom range configuration
|
|
710
|
+
* @param config The custom range configuration to validate
|
|
711
|
+
* @returns Validation result
|
|
712
|
+
*/
|
|
713
|
+
export declare const validateCustomRangeConfig: (config: CustomRangeConfig) => {
|
|
714
|
+
isValid: boolean;
|
|
715
|
+
error?: string;
|
|
716
|
+
};
|
|
717
|
+
/**
|
|
718
|
+
* Handles calendar date click with custom range configuration support
|
|
719
|
+
* @param clickedDate The date that was clicked
|
|
720
|
+
* @param selectedRange Current selected range
|
|
721
|
+
* @param allowSingleDateSelection Whether single date selection is allowed
|
|
722
|
+
* @param today Today's date for validation
|
|
723
|
+
* @param disableFutureDates Whether future dates are disabled
|
|
724
|
+
* @param disablePastDates Whether past dates are disabled
|
|
725
|
+
* @param customRangeConfig Custom range configuration
|
|
726
|
+
* @param isDoubleClick Whether this is a double-click event
|
|
727
|
+
* @returns New date range or null if click should be ignored
|
|
728
|
+
*/
|
|
729
|
+
export declare const handleCustomRangeCalendarDateClick: (clickedDate: Date, selectedRange: DateRange, allowSingleDateSelection: boolean | undefined, today: Date, disableFutureDates?: boolean, disablePastDates?: boolean, customRangeConfig?: CustomRangeConfig, isDoubleClick?: boolean) => DateRange | null;
|
|
706
730
|
/**
|
|
707
731
|
* Checks if two dates represent the same calendar day (ignoring time and timezone)
|
|
708
732
|
*/
|
|
@@ -727,3 +751,73 @@ export declare const matchesTomorrowPreset: (range: DateRange) => boolean;
|
|
|
727
751
|
* Robust preset detection that works with both UTC and local timezone dates
|
|
728
752
|
*/
|
|
729
753
|
export declare const detectPresetFromRange: (range: DateRange) => DateRangePreset;
|
|
754
|
+
/**
|
|
755
|
+
* Default preset configuration for the DateRangePicker
|
|
756
|
+
*/
|
|
757
|
+
export declare const DEFAULT_PRESET_CONFIG: DateRangePreset[];
|
|
758
|
+
/**
|
|
759
|
+
* Get custom preset definition by ID
|
|
760
|
+
*/
|
|
761
|
+
export declare const getCustomPresetDefinition: (id: string) => CustomPresetDefinition | undefined;
|
|
762
|
+
/**
|
|
763
|
+
* Processes custom presets configuration and returns normalized preset configs
|
|
764
|
+
* @param customPresets User-provided presets configuration
|
|
765
|
+
* @returns Array of normalized CustomPresetConfig objects
|
|
766
|
+
*/
|
|
767
|
+
export declare const processCustomPresets: (customPresets?: PresetsConfig) => CustomPresetConfig[];
|
|
768
|
+
/**
|
|
769
|
+
* Filters presets based on visibility and other criteria
|
|
770
|
+
* @param presetConfigs Array of preset configurations
|
|
771
|
+
* @param disableFutureDates Whether future date presets should be excluded
|
|
772
|
+
* @param disablePastDates Whether past date presets should be excluded
|
|
773
|
+
* @returns Array of visible and enabled presets
|
|
774
|
+
*/
|
|
775
|
+
export declare const getFilteredPresets: (presetConfigs: CustomPresetConfig[], disableFutureDates?: boolean, disablePastDates?: boolean) => DateRangePreset[];
|
|
776
|
+
/**
|
|
777
|
+
* Gets the label for a preset, using custom label if provided
|
|
778
|
+
* @param preset The preset to get label for
|
|
779
|
+
* @param presetConfigs Array of preset configurations with potential custom labels
|
|
780
|
+
* @returns The label for the preset
|
|
781
|
+
*/
|
|
782
|
+
export declare const getPresetLabelWithCustom: (preset: DateRangePreset, presetConfigs?: CustomPresetConfig[]) => string;
|
|
783
|
+
/**
|
|
784
|
+
* Creates a preset configuration with custom label and visibility
|
|
785
|
+
* @param preset The preset enum value
|
|
786
|
+
* @param label Optional custom label
|
|
787
|
+
* @param visible Whether the preset should be visible (default: true)
|
|
788
|
+
* @returns CustomPresetConfig object
|
|
789
|
+
*/
|
|
790
|
+
export declare const createPresetConfig: (preset: DateRangePreset, label?: string, visible?: boolean) => CustomPresetConfig;
|
|
791
|
+
/**
|
|
792
|
+
* Helper function to create common preset configurations
|
|
793
|
+
*/
|
|
794
|
+
export declare const PRESET_HELPERS: {
|
|
795
|
+
/**
|
|
796
|
+
* Creates a configuration for time-based presets only
|
|
797
|
+
*/
|
|
798
|
+
timeBasedOnly: () => CustomPresetConfig[];
|
|
799
|
+
/**
|
|
800
|
+
* Creates a configuration for day-based presets only
|
|
801
|
+
*/
|
|
802
|
+
dayBasedOnly: () => CustomPresetConfig[];
|
|
803
|
+
/**
|
|
804
|
+
* Creates a configuration for month-based presets only
|
|
805
|
+
*/
|
|
806
|
+
monthBasedOnly: () => CustomPresetConfig[];
|
|
807
|
+
/**
|
|
808
|
+
* Creates a minimal preset configuration
|
|
809
|
+
*/
|
|
810
|
+
minimal: () => CustomPresetConfig[];
|
|
811
|
+
/**
|
|
812
|
+
* Creates a comprehensive preset configuration
|
|
813
|
+
*/
|
|
814
|
+
comprehensive: () => CustomPresetConfig[];
|
|
815
|
+
/**
|
|
816
|
+
* Creates a configuration with custom labels
|
|
817
|
+
*/
|
|
818
|
+
withCustomLabels: () => CustomPresetConfig[];
|
|
819
|
+
/**
|
|
820
|
+
* Creates a configuration with some presets hidden
|
|
821
|
+
*/
|
|
822
|
+
selectiveVisibility: () => CustomPresetConfig[];
|
|
823
|
+
};
|