@idealyst/datepicker 1.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.
Files changed (50) hide show
  1. package/README.md +88 -0
  2. package/package.json +77 -0
  3. package/src/DatePicker/Calendar.native.tsx +159 -0
  4. package/src/DatePicker/Calendar.styles.tsx +224 -0
  5. package/src/DatePicker/Calendar.tsx +154 -0
  6. package/src/DatePicker/DatePicker.native.tsx +33 -0
  7. package/src/DatePicker/DatePicker.styles.tsx +69 -0
  8. package/src/DatePicker/DatePicker.web.tsx +31 -0
  9. package/src/DatePicker/index.native.ts +3 -0
  10. package/src/DatePicker/index.ts +3 -0
  11. package/src/DatePicker/types.ts +78 -0
  12. package/src/DateRangePicker/DateRangePicker.native.tsx +39 -0
  13. package/src/DateRangePicker/DateRangePicker.styles.tsx +83 -0
  14. package/src/DateRangePicker/DateRangePicker.web.tsx +40 -0
  15. package/src/DateRangePicker/RangeCalendar.native.tsx +267 -0
  16. package/src/DateRangePicker/RangeCalendar.styles.tsx +170 -0
  17. package/src/DateRangePicker/RangeCalendar.web.tsx +275 -0
  18. package/src/DateRangePicker/index.native.ts +3 -0
  19. package/src/DateRangePicker/index.ts +3 -0
  20. package/src/DateRangePicker/types.ts +98 -0
  21. package/src/DateTimePicker/DateTimePicker.native.tsx +82 -0
  22. package/src/DateTimePicker/DateTimePicker.styles.tsx +77 -0
  23. package/src/DateTimePicker/DateTimePicker.tsx +79 -0
  24. package/src/DateTimePicker/TimePicker.native.tsx +204 -0
  25. package/src/DateTimePicker/TimePicker.styles.tsx +116 -0
  26. package/src/DateTimePicker/TimePicker.tsx +406 -0
  27. package/src/DateTimePicker/index.native.ts +3 -0
  28. package/src/DateTimePicker/index.ts +3 -0
  29. package/src/DateTimePicker/types.ts +84 -0
  30. package/src/DateTimeRangePicker/DateTimeRangePicker.native.tsx +213 -0
  31. package/src/DateTimeRangePicker/DateTimeRangePicker.styles.tsx +95 -0
  32. package/src/DateTimeRangePicker/DateTimeRangePicker.web.tsx +141 -0
  33. package/src/DateTimeRangePicker/index.native.ts +2 -0
  34. package/src/DateTimeRangePicker/index.ts +2 -0
  35. package/src/DateTimeRangePicker/types.ts +72 -0
  36. package/src/examples/DatePickerExamples.tsx +274 -0
  37. package/src/examples/index.ts +1 -0
  38. package/src/index.native.ts +16 -0
  39. package/src/index.ts +16 -0
  40. package/src/primitives/CalendarGrid/CalendarGrid.styles.tsx +62 -0
  41. package/src/primitives/CalendarGrid/CalendarGrid.tsx +138 -0
  42. package/src/primitives/CalendarGrid/index.ts +1 -0
  43. package/src/primitives/CalendarHeader/CalendarHeader.styles.tsx +25 -0
  44. package/src/primitives/CalendarHeader/CalendarHeader.tsx +69 -0
  45. package/src/primitives/CalendarHeader/index.ts +1 -0
  46. package/src/primitives/CalendarOverlay/CalendarOverlay.styles.tsx +81 -0
  47. package/src/primitives/CalendarOverlay/CalendarOverlay.tsx +130 -0
  48. package/src/primitives/CalendarOverlay/index.ts +1 -0
  49. package/src/primitives/Wrapper/Wrapper.web.tsx +33 -0
  50. package/src/primitives/Wrapper/index.ts +1 -0
@@ -0,0 +1,130 @@
1
+ import React, { useState } from 'react';
2
+ import { Button, View, Text } from '@idealyst/components';
3
+ import { calendarOverlayStyles } from './CalendarOverlay.styles';
4
+
5
+ type OverlayMode = 'month' | 'year';
6
+
7
+ interface CalendarOverlayProps {
8
+ mode: OverlayMode;
9
+ currentMonth: number;
10
+ currentYear: number;
11
+ onMonthSelect: (month: number) => void;
12
+ onYearSelect: (year: number) => void;
13
+ onClose: () => void;
14
+ disabled?: boolean;
15
+ }
16
+
17
+ const months = [
18
+ 'January', 'February', 'March', 'April', 'May', 'June',
19
+ 'July', 'August', 'September', 'October', 'November', 'December'
20
+ ];
21
+
22
+
23
+ export const CalendarOverlay: React.FC<CalendarOverlayProps> = ({
24
+ mode,
25
+ currentMonth,
26
+ currentYear,
27
+ onMonthSelect,
28
+ onYearSelect,
29
+ onClose,
30
+ disabled = false,
31
+ }) => {
32
+ const [yearRangeStart, setYearRangeStart] = useState(currentYear - 10);
33
+ const years = Array.from({ length: 20 }, (_, i) => yearRangeStart + i);
34
+
35
+
36
+ const handleMonthSelect = (monthIndex: number) => {
37
+ onMonthSelect(monthIndex);
38
+ onClose();
39
+ };
40
+
41
+ const handleYearSelect = (year: number) => {
42
+ onYearSelect(year);
43
+ onClose();
44
+ };
45
+
46
+ const goToPreviousYearRange = () => {
47
+ setYearRangeStart(yearRangeStart - 20);
48
+ };
49
+
50
+ const goToNextYearRange = () => {
51
+ setYearRangeStart(yearRangeStart + 20);
52
+ };
53
+
54
+ return (
55
+ <View style={calendarOverlayStyles.container}>
56
+ <View style={calendarOverlayStyles.header}>
57
+ <Text style={calendarOverlayStyles.title}>
58
+ Select {mode === 'month' ? 'Month' : 'Year'}
59
+ </Text>
60
+ <Button
61
+ variant="text"
62
+ size="small"
63
+ onPress={onClose}
64
+ style={calendarOverlayStyles.closeButton}
65
+ >
66
+
67
+ </Button>
68
+ </View>
69
+
70
+ {mode === 'month' ? (
71
+ <View style={calendarOverlayStyles.monthGrid}>
72
+ {months.map((month, index) => (
73
+ <Button
74
+ key={month}
75
+ variant={index === currentMonth ? 'contained' : 'outlined'}
76
+ intent={index === currentMonth ? 'primary' : 'neutral'}
77
+ size="small"
78
+ onPress={() => handleMonthSelect(index)}
79
+ disabled={disabled}
80
+ style={calendarOverlayStyles.gridButton}
81
+ >
82
+ {month.slice(0, 3)}
83
+ </Button>
84
+ ))}
85
+ </View>
86
+ ) : (
87
+ <View style={calendarOverlayStyles.yearContainer}>
88
+ <View style={calendarOverlayStyles.yearNavigation}>
89
+ <Button
90
+ variant="text"
91
+ size="small"
92
+ onPress={goToPreviousYearRange}
93
+ disabled={disabled}
94
+ style={calendarOverlayStyles.yearNavButton}
95
+ >
96
+
97
+ </Button>
98
+ <Text style={calendarOverlayStyles.yearRangeText}>
99
+ {yearRangeStart} - {yearRangeStart + 19}
100
+ </Text>
101
+ <Button
102
+ variant="text"
103
+ size="small"
104
+ onPress={goToNextYearRange}
105
+ disabled={disabled}
106
+ style={calendarOverlayStyles.yearNavButton}
107
+ >
108
+
109
+ </Button>
110
+ </View>
111
+ <View style={calendarOverlayStyles.yearGrid}>
112
+ {years.map((year) => (
113
+ <Button
114
+ key={year}
115
+ variant={year === currentYear ? 'contained' : 'outlined'}
116
+ intent={year === currentYear ? 'primary' : 'neutral'}
117
+ size="small"
118
+ onPress={() => handleYearSelect(year)}
119
+ disabled={disabled}
120
+ style={calendarOverlayStyles.gridButton}
121
+ >
122
+ {year}
123
+ </Button>
124
+ ))}
125
+ </View>
126
+ </View>
127
+ )}
128
+ </View>
129
+ );
130
+ };
@@ -0,0 +1 @@
1
+ export { CalendarOverlay } from './CalendarOverlay';
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { getWebProps } from 'react-native-unistyles/web';
3
+
4
+ interface WrapperProps {
5
+ style?: any;
6
+ children?: React.ReactNode;
7
+ onClick?: () => void;
8
+ 'data-testid'?: string;
9
+ ref?: React.Ref<HTMLDivElement>;
10
+ }
11
+
12
+ export const Wrapper = React.forwardRef<HTMLDivElement, WrapperProps>(({
13
+ style,
14
+ children,
15
+ onClick,
16
+ 'data-testid': testID,
17
+ ...props
18
+ }, ref) => {
19
+ return (
20
+ <div
21
+ ref={ref}
22
+ style={style}
23
+ onClick={onClick}
24
+ data-testid={testID}
25
+ {...getWebProps(style)}
26
+ {...props}
27
+ >
28
+ {children}
29
+ </div>
30
+ );
31
+ });
32
+
33
+ Wrapper.displayName = 'Wrapper';
@@ -0,0 +1 @@
1
+ export { Wrapper } from './Wrapper.web';