@impulse-ui-native/datetime 2.0.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/dist/index.d.mts +116 -0
- package/dist/index.js +1742 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { FlyoutProps } from '@impulse-ui-native/flyout';
|
|
3
|
+
import { ControlComponentProps, ControlComponentCommonProps, PressableCoreProps } from '@impulse-ui-native/primitives';
|
|
4
|
+
|
|
5
|
+
interface TimePickerValue {
|
|
6
|
+
hours: number;
|
|
7
|
+
minutes: number;
|
|
8
|
+
seconds: number;
|
|
9
|
+
}
|
|
10
|
+
type RangeSide = "start" | "end";
|
|
11
|
+
type TimeFormat = "12h" | "24h";
|
|
12
|
+
type PickerColumnType = "hour" | "minute" | "second";
|
|
13
|
+
interface TimeRange {
|
|
14
|
+
start?: Date;
|
|
15
|
+
end?: Date;
|
|
16
|
+
}
|
|
17
|
+
interface InfiniteRangeItem {
|
|
18
|
+
key: string;
|
|
19
|
+
value: number;
|
|
20
|
+
index: number;
|
|
21
|
+
}
|
|
22
|
+
interface QuickDateOption<Value> {
|
|
23
|
+
label: string;
|
|
24
|
+
value: Value;
|
|
25
|
+
}
|
|
26
|
+
interface PickerFlyoutActions {
|
|
27
|
+
clearable?: boolean;
|
|
28
|
+
onPressApply?: PressableCoreProps["onPress"];
|
|
29
|
+
onPressCancel?: PressableCoreProps["onPress"];
|
|
30
|
+
onPressClear?: PressableCoreProps["onPress"];
|
|
31
|
+
}
|
|
32
|
+
interface DatetimePickerCommonProps extends Partial<ControlComponentProps>, ControlComponentCommonProps {
|
|
33
|
+
clearable?: boolean;
|
|
34
|
+
}
|
|
35
|
+
interface DatetimePickerFlyoutCommonProps extends FlyoutProps, PickerFlyoutActions {
|
|
36
|
+
visible: Date;
|
|
37
|
+
quickDateOptions?: QuickDateOption<Date | TimeRange>[];
|
|
38
|
+
onPressQuickDateOption?: (value: Date | TimeRange) => void;
|
|
39
|
+
onChangeVisible: (date: Date) => void;
|
|
40
|
+
onPressCalendarDay: (date: Date) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface DatetimePickerProps extends DatetimePickerCommonProps {
|
|
44
|
+
value?: Date | null;
|
|
45
|
+
defaultValue?: Date | null;
|
|
46
|
+
onChange?: (value: Date | null) => void;
|
|
47
|
+
quickDateOptions?: QuickDateOption<Date>[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface DatetimeRangePickerProps extends DatetimePickerCommonProps {
|
|
51
|
+
value?: TimeRange | null;
|
|
52
|
+
defaultValue?: TimeRange | null;
|
|
53
|
+
onChange?: (value: TimeRange | null) => void;
|
|
54
|
+
quickDateOptions?: QuickDateOption<TimeRange>[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare const DatePicker: react.NamedExoticComponent<DatetimePickerProps>;
|
|
58
|
+
|
|
59
|
+
declare const DateRangePicker: react.NamedExoticComponent<DatetimeRangePickerProps>;
|
|
60
|
+
|
|
61
|
+
declare const DatetimePicker: react.NamedExoticComponent<DatetimePickerProps>;
|
|
62
|
+
|
|
63
|
+
declare const DatetimeRangePicker: react.NamedExoticComponent<DatetimeRangePickerProps>;
|
|
64
|
+
|
|
65
|
+
interface TimePickerProps extends DatetimePickerCommonProps {
|
|
66
|
+
value?: TimePickerValue | null;
|
|
67
|
+
defaultValue?: TimePickerValue | null;
|
|
68
|
+
onChange?: (value: TimePickerValue | null) => void;
|
|
69
|
+
}
|
|
70
|
+
declare const TimePicker: react.NamedExoticComponent<TimePickerProps>;
|
|
71
|
+
|
|
72
|
+
declare function getMonthNames(locale?: string, format?: "long" | "short" | "narrow"): string[];
|
|
73
|
+
declare function getDayNames(locale?: string, format?: "long" | "short" | "narrow"): string[];
|
|
74
|
+
declare function getYears(): number[];
|
|
75
|
+
declare function getMonthCalendarMatrix(year: number, month: number): Date[][];
|
|
76
|
+
declare function createInfiniteRange(max: number, repeats: number): any[];
|
|
77
|
+
declare function getInfiniteRangeInitialIndex(max: number, targetValue: number, repeats: number): number;
|
|
78
|
+
declare function getClosestIndexByValue(data: number[], value: number, currentIndex: number): number;
|
|
79
|
+
declare function formatTimepickerValue(value: TimePickerValue): string;
|
|
80
|
+
declare function applyTime(date: Date, time: TimePickerValue | null): Date;
|
|
81
|
+
declare function getInitialVisibleDate(value?: TimeRange | null, defaultValue?: TimeRange | null): Date;
|
|
82
|
+
declare function normalizeRange(range: TimeRange | null): TimeRange | null;
|
|
83
|
+
declare function endOfDay(date: Date): Date;
|
|
84
|
+
declare function addDays(date: Date, days: number): Date;
|
|
85
|
+
declare function startOfWeek(date: Date): Date;
|
|
86
|
+
declare function endOfWeek(date: Date): Date;
|
|
87
|
+
declare function startOfDay(date: Date): Date;
|
|
88
|
+
|
|
89
|
+
interface CalendarDayState {
|
|
90
|
+
isSelected: boolean;
|
|
91
|
+
isRangeStart: boolean;
|
|
92
|
+
isInRange: boolean;
|
|
93
|
+
isRangeEnd: boolean;
|
|
94
|
+
isCurrentMonth: boolean;
|
|
95
|
+
}
|
|
96
|
+
interface GetCalendarDayStateOptions {
|
|
97
|
+
date: Date;
|
|
98
|
+
visible: Date;
|
|
99
|
+
value?: Date | TimeRange | null;
|
|
100
|
+
}
|
|
101
|
+
declare function isTimeRange(value: unknown): value is TimeRange;
|
|
102
|
+
declare function isSameDay(left: Date, right: Date): boolean;
|
|
103
|
+
declare function isDateInMonth(date: Date, monthDate: Date): boolean;
|
|
104
|
+
declare function isBeforeDay(left: Date, right: Date): boolean;
|
|
105
|
+
declare function isAfterDay(left: Date, right: Date): boolean;
|
|
106
|
+
declare function isRangeStart(date: Date, rangeStart?: Date | null): boolean;
|
|
107
|
+
declare function isRangeEnd(date: Date, rangeEnd?: Date | null): boolean;
|
|
108
|
+
declare function isInRange(date: Date, rangeStart?: Date | null, rangeEnd?: Date | null): boolean;
|
|
109
|
+
declare function isSelected(date: Date, selected?: Date | null, rangeStart?: Date | null, rangeEnd?: Date | null): boolean;
|
|
110
|
+
declare function getCalendarDayState({ date, visible, value, }: GetCalendarDayStateOptions): CalendarDayState;
|
|
111
|
+
declare function createCalendarRange(date: Date, previousRange?: TimeRange): TimeRange | undefined;
|
|
112
|
+
declare function getQuickOptionKey(value: Date | TimeRange): string | undefined;
|
|
113
|
+
declare function isDateRange(value: unknown): value is TimeRange;
|
|
114
|
+
declare function getDateKey(date: Date): string;
|
|
115
|
+
|
|
116
|
+
export { type CalendarDayState, DatePicker, DateRangePicker, DatetimePicker, type DatetimePickerCommonProps, type DatetimePickerFlyoutCommonProps, type DatetimePickerProps, DatetimeRangePicker, type DatetimeRangePickerProps, type GetCalendarDayStateOptions, type InfiniteRangeItem, type PickerColumnType, type PickerFlyoutActions, type QuickDateOption, type RangeSide, type TimeFormat, TimePicker, type TimePickerValue, type TimeRange, addDays, applyTime, createCalendarRange, createInfiniteRange, endOfDay, endOfWeek, formatTimepickerValue, getCalendarDayState, getClosestIndexByValue, getDateKey, getDayNames, getInfiniteRangeInitialIndex, getInitialVisibleDate, getMonthCalendarMatrix, getMonthNames, getQuickOptionKey, getYears, isAfterDay, isBeforeDay, isDateInMonth, isDateRange, isInRange, isRangeEnd, isRangeStart, isSameDay, isSelected, isTimeRange, normalizeRange, startOfDay, startOfWeek };
|