@juspay/blend-design-system 0.0.19-beta → 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.
|
@@ -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;
|
|
@@ -4,12 +4,14 @@ export declare enum DateRangePreset {
|
|
|
4
4
|
TODAY = "today",
|
|
5
5
|
YESTERDAY = "yesterday",
|
|
6
6
|
TOMORROW = "tomorrow",
|
|
7
|
-
|
|
7
|
+
LAST_30_MINUTES = "last30Minutes",
|
|
8
8
|
LAST_1_HOUR = "last1Hour",
|
|
9
9
|
LAST_6_HOURS = "last6Hours",
|
|
10
10
|
LAST_24_HOURS = "last24Hours",
|
|
11
11
|
LAST_7_DAYS = "last7Days",
|
|
12
12
|
LAST_30_DAYS = "last30Days",
|
|
13
|
+
THIS_MONTH = "thisMonth",
|
|
14
|
+
LAST_MONTH = "lastMonth",
|
|
13
15
|
LAST_3_MONTHS = "last3Months",
|
|
14
16
|
LAST_12_MONTHS = "last12Months",
|
|
15
17
|
NEXT_7_DAYS = "next7Days",
|
|
@@ -139,6 +141,27 @@ export type PickerColumnData = {
|
|
|
139
141
|
items: (string | number)[];
|
|
140
142
|
selectedIndex: number;
|
|
141
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)[];
|
|
142
165
|
/**
|
|
143
166
|
* Function type for custom date disabling logic
|
|
144
167
|
* @param date The date to check
|
|
@@ -209,11 +232,25 @@ export type CustomRangeConfig = {
|
|
|
209
232
|
*/
|
|
210
233
|
applyToPresets?: boolean;
|
|
211
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
|
+
};
|
|
212
247
|
export type DateRangePickerProps = {
|
|
213
248
|
value?: DateRange;
|
|
214
249
|
onChange?: (range: DateRange) => void;
|
|
250
|
+
onPresetSelection?: (data: PresetSelectionData) => void;
|
|
215
251
|
showDateTimePicker?: boolean;
|
|
216
252
|
showPresets?: boolean;
|
|
253
|
+
customPresets?: PresetsConfig;
|
|
217
254
|
placeholder?: string;
|
|
218
255
|
isDisabled?: boolean;
|
|
219
256
|
icon?: ReactNode;
|
|
@@ -234,6 +271,7 @@ export type DateRangePickerProps = {
|
|
|
234
271
|
formatConfig?: DateFormatConfig;
|
|
235
272
|
triggerConfig?: TriggerConfig;
|
|
236
273
|
maxMenuHeight?: number;
|
|
274
|
+
showPreset?: boolean;
|
|
237
275
|
};
|
|
238
276
|
export type PresetItemProps = {
|
|
239
277
|
preset: DateRangePreset;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateRange, DateRangePreset, DateFormatConfig, CustomFormatFunction, HapticFeedbackType,
|
|
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
|
|
@@ -705,6 +705,28 @@ export declare const shouldHideDateFromCalendar: (date: Date, today: Date, hideF
|
|
|
705
705
|
* @returns New date range or null if click should be ignored
|
|
706
706
|
*/
|
|
707
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;
|
|
708
730
|
/**
|
|
709
731
|
* Checks if two dates represent the same calendar day (ignoring time and timezone)
|
|
710
732
|
*/
|
|
@@ -730,99 +752,72 @@ export declare const matchesTomorrowPreset: (range: DateRange) => boolean;
|
|
|
730
752
|
*/
|
|
731
753
|
export declare const detectPresetFromRange: (range: DateRange) => DateRangePreset;
|
|
732
754
|
/**
|
|
733
|
-
*
|
|
734
|
-
* @param startDate The selected start date
|
|
735
|
-
* @param customRangeConfig Custom range configuration
|
|
736
|
-
* @param currentRange Current selected range (optional)
|
|
737
|
-
* @returns Calculated range or null to use default behavior
|
|
755
|
+
* Default preset configuration for the DateRangePicker
|
|
738
756
|
*/
|
|
739
|
-
export declare const
|
|
757
|
+
export declare const DEFAULT_PRESET_CONFIG: DateRangePreset[];
|
|
740
758
|
/**
|
|
741
|
-
*
|
|
742
|
-
* @param clickedDate The date that was clicked
|
|
743
|
-
* @param selectedRange Current selected range
|
|
744
|
-
* @param allowSingleDateSelection Whether single date selection is allowed
|
|
745
|
-
* @param today Today's date for validation
|
|
746
|
-
* @param disableFutureDates Whether future dates are disabled
|
|
747
|
-
* @param disablePastDates Whether past dates are disabled
|
|
748
|
-
* @param customRangeConfig Custom range configuration
|
|
749
|
-
* @param isDoubleClick Whether this is a double-click event
|
|
750
|
-
* @returns New date range or null if click should be ignored
|
|
759
|
+
* Get custom preset definition by ID
|
|
751
760
|
*/
|
|
752
|
-
export declare const
|
|
761
|
+
export declare const getCustomPresetDefinition: (id: string) => CustomPresetDefinition | undefined;
|
|
753
762
|
/**
|
|
754
|
-
*
|
|
755
|
-
* @param
|
|
756
|
-
* @returns
|
|
763
|
+
* Processes custom presets configuration and returns normalized preset configs
|
|
764
|
+
* @param customPresets User-provided presets configuration
|
|
765
|
+
* @returns Array of normalized CustomPresetConfig objects
|
|
757
766
|
*/
|
|
758
|
-
export declare const
|
|
759
|
-
isValid: boolean;
|
|
760
|
-
error?: string;
|
|
761
|
-
};
|
|
767
|
+
export declare const processCustomPresets: (customPresets?: PresetsConfig) => CustomPresetConfig[];
|
|
762
768
|
/**
|
|
763
|
-
*
|
|
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
|
|
764
774
|
*/
|
|
765
|
-
export declare const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
* Creates a calculator for business days (excluding weekends)
|
|
774
|
-
* @param businessDays Number of business days
|
|
775
|
-
* @returns Custom range calculator function
|
|
776
|
-
*/
|
|
777
|
-
businessDays: (businessDays: number) => CustomRangeCalculatorFunction;
|
|
778
|
-
/**
|
|
779
|
-
* Creates a calculator for end of week (Sunday)
|
|
780
|
-
* @returns Custom range calculator function
|
|
781
|
-
*/
|
|
782
|
-
endOfWeek: () => CustomRangeCalculatorFunction;
|
|
783
|
-
/**
|
|
784
|
-
* Creates a calculator for end of month
|
|
785
|
-
* @returns Custom range calculator function
|
|
786
|
-
*/
|
|
787
|
-
endOfMonth: () => CustomRangeCalculatorFunction;
|
|
788
|
-
/**
|
|
789
|
-
* Creates a calculator for quarter end
|
|
790
|
-
* @returns Custom range calculator function
|
|
791
|
-
*/
|
|
792
|
-
endOfQuarter: () => CustomRangeCalculatorFunction;
|
|
793
|
-
/**
|
|
794
|
-
* Creates a calculator that compares with another date range
|
|
795
|
-
* @param compareRange The range to compare with
|
|
796
|
-
* @returns Custom range calculator function
|
|
797
|
-
*/
|
|
798
|
-
compareWithRange: (compareRange: DateRange) => CustomRangeCalculatorFunction;
|
|
799
|
-
};
|
|
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;
|
|
800
783
|
/**
|
|
801
|
-
*
|
|
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
|
|
802
789
|
*/
|
|
803
|
-
export declare const
|
|
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[];
|
|
804
799
|
/**
|
|
805
|
-
*
|
|
800
|
+
* Creates a configuration for day-based presets only
|
|
806
801
|
*/
|
|
807
|
-
|
|
802
|
+
dayBasedOnly: () => CustomPresetConfig[];
|
|
808
803
|
/**
|
|
809
|
-
*
|
|
804
|
+
* Creates a configuration for month-based presets only
|
|
810
805
|
*/
|
|
811
|
-
|
|
806
|
+
monthBasedOnly: () => CustomPresetConfig[];
|
|
812
807
|
/**
|
|
813
|
-
*
|
|
808
|
+
* Creates a minimal preset configuration
|
|
814
809
|
*/
|
|
815
|
-
|
|
810
|
+
minimal: () => CustomPresetConfig[];
|
|
816
811
|
/**
|
|
817
|
-
*
|
|
812
|
+
* Creates a comprehensive preset configuration
|
|
818
813
|
*/
|
|
819
|
-
|
|
814
|
+
comprehensive: () => CustomPresetConfig[];
|
|
820
815
|
/**
|
|
821
|
-
*
|
|
816
|
+
* Creates a configuration with custom labels
|
|
822
817
|
*/
|
|
823
|
-
|
|
818
|
+
withCustomLabels: () => CustomPresetConfig[];
|
|
824
819
|
/**
|
|
825
|
-
*
|
|
820
|
+
* Creates a configuration with some presets hidden
|
|
826
821
|
*/
|
|
827
|
-
|
|
822
|
+
selectiveVisibility: () => CustomPresetConfig[];
|
|
828
823
|
};
|