@idealyst/datepicker 1.1.3 → 1.1.5
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/package.json +6 -5
- package/src/DateInput.native.tsx +155 -0
- package/src/DateInput.tsx +2 -0
- package/src/DateInput.web.tsx +146 -0
- package/src/DatePicker.tsx +276 -0
- package/src/DateTimePicker.tsx +89 -0
- package/src/TimeInput.native.tsx +175 -0
- package/src/TimeInput.tsx +2 -0
- package/src/TimeInput.web.tsx +171 -0
- package/src/TimePicker.tsx +106 -0
- package/src/examples/DatePickerExamples.tsx +113 -149
- package/src/examples/index.ts +1 -1
- package/src/index.native.ts +15 -20
- package/src/index.ts +14 -19
- package/src/styles.ts +127 -0
- package/src/types.ts +56 -0
- package/src/DateInput/DateInput.native.tsx +0 -61
- package/src/DateInput/DateInput.styles.tsx +0 -26
- package/src/DateInput/DateInput.web.tsx +0 -61
- package/src/DateInput/DateInputBase.tsx +0 -228
- package/src/DateInput/index.native.ts +0 -2
- package/src/DateInput/index.ts +0 -2
- package/src/DateInput/types.ts +0 -60
- package/src/DatePicker/Calendar.native.tsx +0 -261
- package/src/DatePicker/Calendar.styles.tsx +0 -230
- package/src/DatePicker/Calendar.web.tsx +0 -159
- package/src/DatePicker/DatePicker.native.tsx +0 -51
- package/src/DatePicker/DatePicker.styles.tsx +0 -76
- package/src/DatePicker/DatePicker.web.tsx +0 -31
- package/src/DatePicker/index.native.ts +0 -3
- package/src/DatePicker/index.ts +0 -3
- package/src/DatePicker/types.ts +0 -78
- package/src/DateRangePicker/DateRangePicker.native.tsx +0 -39
- package/src/DateRangePicker/DateRangePicker.styles.tsx +0 -83
- package/src/DateRangePicker/DateRangePicker.web.tsx +0 -40
- package/src/DateRangePicker/RangeCalendar.native.tsx +0 -355
- package/src/DateRangePicker/RangeCalendar.styles.tsx +0 -200
- package/src/DateRangePicker/RangeCalendar.web.tsx +0 -384
- package/src/DateRangePicker/index.native.ts +0 -3
- package/src/DateRangePicker/index.ts +0 -3
- package/src/DateRangePicker/types.ts +0 -107
- package/src/DateTimePicker/DateTimePicker.native.tsx +0 -24
- package/src/DateTimePicker/DateTimePicker.styles.tsx +0 -104
- package/src/DateTimePicker/DateTimePicker.tsx +0 -21
- package/src/DateTimePicker/DateTimePickerBase.tsx +0 -185
- package/src/DateTimePicker/TimePicker.native.tsx +0 -17
- package/src/DateTimePicker/TimePicker.styles.tsx +0 -115
- package/src/DateTimePicker/TimePicker.tsx +0 -14
- package/src/DateTimePicker/TimePickerBase.tsx +0 -232
- package/src/DateTimePicker/index.native.ts +0 -3
- package/src/DateTimePicker/index.ts +0 -3
- package/src/DateTimePicker/primitives/ClockFace.native.tsx +0 -195
- package/src/DateTimePicker/primitives/ClockFace.web.tsx +0 -168
- package/src/DateTimePicker/primitives/TimeInput.native.tsx +0 -53
- package/src/DateTimePicker/primitives/TimeInput.web.tsx +0 -66
- package/src/DateTimePicker/primitives/index.native.ts +0 -2
- package/src/DateTimePicker/primitives/index.ts +0 -2
- package/src/DateTimePicker/primitives/index.web.ts +0 -2
- package/src/DateTimePicker/types.ts +0 -80
- package/src/DateTimePicker/utils/dimensions.native.ts +0 -9
- package/src/DateTimePicker/utils/dimensions.ts +0 -9
- package/src/DateTimePicker/utils/dimensions.web.ts +0 -33
- package/src/DateTimeRangePicker/DateTimeRangePicker.native.tsx +0 -24
- package/src/DateTimeRangePicker/DateTimeRangePicker.styles.tsx +0 -118
- package/src/DateTimeRangePicker/DateTimeRangePicker.web.tsx +0 -21
- package/src/DateTimeRangePicker/DateTimeRangePickerBase.tsx +0 -327
- package/src/DateTimeRangePicker/index.native.ts +0 -2
- package/src/DateTimeRangePicker/index.ts +0 -2
- package/src/DateTimeRangePicker/types.ts +0 -70
- package/src/primitives/CalendarGrid/CalendarGrid.styles.tsx +0 -51
- package/src/primitives/CalendarGrid/CalendarGrid.tsx +0 -146
- package/src/primitives/CalendarGrid/index.ts +0 -1
- package/src/primitives/CalendarHeader/CalendarHeader.styles.tsx +0 -25
- package/src/primitives/CalendarHeader/CalendarHeader.tsx +0 -69
- package/src/primitives/CalendarHeader/index.ts +0 -1
- package/src/primitives/CalendarOverlay/CalendarOverlay.styles.tsx +0 -86
- package/src/primitives/CalendarOverlay/CalendarOverlay.tsx +0 -136
- package/src/primitives/CalendarOverlay/index.ts +0 -1
- package/src/primitives/Wrapper/Wrapper.web.tsx +0 -33
- package/src/primitives/Wrapper/index.ts +0 -1
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { Screen, View, Text, Button } from '@idealyst/components';
|
|
3
|
-
import { DatePicker } from '../
|
|
4
|
-
import { DateTimePicker } from '../DateTimePicker';
|
|
5
|
-
import { DateTimeRangePicker, DateTimeRange } from '../DateTimeRangePicker';
|
|
3
|
+
import { DatePicker, TimePicker, DateInput, TimeInput, DateTimePicker } from '../index';
|
|
6
4
|
|
|
7
5
|
export const DatePickerExamples = () => {
|
|
8
|
-
const [
|
|
9
|
-
const [
|
|
10
|
-
const [disabledDate, setDisabledDate] = useState<Date | null>(new Date());
|
|
6
|
+
const [date, setDate] = useState<Date | null>(null);
|
|
7
|
+
const [time, setTime] = useState<Date | null>(null);
|
|
11
8
|
const [dateTime, setDateTime] = useState<Date | null>(null);
|
|
12
|
-
const [
|
|
13
|
-
const [
|
|
9
|
+
const [inlineDate, setInlineDate] = useState(new Date());
|
|
10
|
+
const [inlineTime, setInlineTime] = useState(new Date());
|
|
14
11
|
|
|
15
12
|
const tomorrow = new Date();
|
|
16
13
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
@@ -20,179 +17,146 @@ export const DatePickerExamples = () => {
|
|
|
20
17
|
|
|
21
18
|
return (
|
|
22
19
|
<Screen background="primary" padding="lg">
|
|
23
|
-
<View
|
|
24
|
-
<Text
|
|
25
|
-
DatePicker
|
|
20
|
+
<View gap="lg">
|
|
21
|
+
<Text typography="h2" weight="bold" align="center">
|
|
22
|
+
DatePicker Examples
|
|
26
23
|
</Text>
|
|
27
|
-
|
|
28
|
-
{/* DateTime Picker Examples */}
|
|
29
|
-
<View spacing="md">
|
|
30
|
-
<Text size="md" weight="semibold">DateTimePicker Examples</Text>
|
|
31
|
-
|
|
32
|
-
{/* Basic DateTime */}
|
|
33
|
-
<View spacing="sm">
|
|
34
|
-
<Text size="sm" weight="medium">Basic DateTimePicker (12-hour)</Text>
|
|
35
|
-
<DateTimePicker
|
|
36
|
-
value={dateTime}
|
|
37
|
-
onChange={setDateTime}
|
|
38
|
-
label="Select Date & Time"
|
|
39
|
-
placeholder="Choose date and time"
|
|
40
|
-
helperText="Responsive layout - side-by-side on large screens, step-by-step on mobile"
|
|
41
|
-
/>
|
|
42
|
-
{dateTime && (
|
|
43
|
-
<Text size="sm" color="secondary">
|
|
44
|
-
Selected: {dateTime.toLocaleString()}
|
|
45
|
-
</Text>
|
|
46
|
-
)}
|
|
47
|
-
</View>
|
|
48
24
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
</View>
|
|
25
|
+
{/* DateInput */}
|
|
26
|
+
<View gap="md">
|
|
27
|
+
<Text typography="h4" weight="semibold">DateInput</Text>
|
|
28
|
+
<Text typography="caption" color="secondary">
|
|
29
|
+
Type a date (MM/DD/YYYY) or click the calendar button
|
|
30
|
+
</Text>
|
|
31
|
+
<DateInput
|
|
32
|
+
value={date ?? undefined}
|
|
33
|
+
onChange={setDate}
|
|
34
|
+
label="Select Date"
|
|
35
|
+
placeholder="MM/DD/YYYY"
|
|
36
|
+
/>
|
|
37
|
+
{date && (
|
|
38
|
+
<Text typography="caption" color="secondary">
|
|
39
|
+
Selected: {date.toDateString()}
|
|
40
|
+
</Text>
|
|
41
|
+
)}
|
|
67
42
|
</View>
|
|
68
43
|
|
|
69
|
-
{/*
|
|
70
|
-
<View
|
|
71
|
-
<Text
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
44
|
+
{/* TimeInput */}
|
|
45
|
+
<View gap="md">
|
|
46
|
+
<Text typography="h4" weight="semibold">TimeInput</Text>
|
|
47
|
+
<Text typography="caption" color="secondary">
|
|
48
|
+
Type a time (e.g., 2:30 PM) or click the clock button
|
|
49
|
+
</Text>
|
|
50
|
+
<TimeInput
|
|
51
|
+
value={time ?? undefined}
|
|
52
|
+
onChange={setTime}
|
|
53
|
+
label="Select Time"
|
|
54
|
+
placeholder="12:00 PM"
|
|
78
55
|
/>
|
|
79
|
-
{
|
|
80
|
-
<Text
|
|
81
|
-
Selected: {
|
|
56
|
+
{time && (
|
|
57
|
+
<Text typography="caption" color="secondary">
|
|
58
|
+
Selected: {time.toLocaleTimeString()}
|
|
82
59
|
</Text>
|
|
83
60
|
)}
|
|
84
61
|
</View>
|
|
85
62
|
|
|
86
|
-
{/*
|
|
87
|
-
<View
|
|
88
|
-
<Text
|
|
89
|
-
<
|
|
90
|
-
value={
|
|
91
|
-
onChange={
|
|
63
|
+
{/* DateTimePicker */}
|
|
64
|
+
<View gap="md">
|
|
65
|
+
<Text typography="h4" weight="semibold">DateTimePicker</Text>
|
|
66
|
+
<DateTimePicker
|
|
67
|
+
value={dateTime ?? undefined}
|
|
68
|
+
onChange={setDateTime}
|
|
69
|
+
label="Select Date & Time"
|
|
70
|
+
/>
|
|
71
|
+
{dateTime && (
|
|
72
|
+
<Text typography="caption" color="secondary">
|
|
73
|
+
Selected: {dateTime.toLocaleString()}
|
|
74
|
+
</Text>
|
|
75
|
+
)}
|
|
76
|
+
</View>
|
|
77
|
+
|
|
78
|
+
{/* Date Range Restriction */}
|
|
79
|
+
<View gap="md">
|
|
80
|
+
<Text typography="h4" weight="semibold">With Min/Max Date</Text>
|
|
81
|
+
<DateInput
|
|
82
|
+
value={undefined}
|
|
83
|
+
onChange={() => {}}
|
|
92
84
|
label="Future Dates Only"
|
|
93
|
-
placeholder="
|
|
85
|
+
placeholder="MM/DD/YYYY"
|
|
94
86
|
minDate={tomorrow}
|
|
95
87
|
maxDate={nextMonth}
|
|
96
|
-
helperText="Only dates between tomorrow and next month"
|
|
97
88
|
/>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</Text>
|
|
102
|
-
)}
|
|
89
|
+
<Text typography="caption" color="secondary">
|
|
90
|
+
Only dates between tomorrow and next month
|
|
91
|
+
</Text>
|
|
103
92
|
</View>
|
|
104
93
|
|
|
105
|
-
{/*
|
|
106
|
-
<View
|
|
107
|
-
<Text
|
|
94
|
+
{/* Inline DatePicker */}
|
|
95
|
+
<View gap="md">
|
|
96
|
+
<Text typography="h4" weight="semibold">Inline DatePicker</Text>
|
|
108
97
|
<DatePicker
|
|
109
|
-
value={
|
|
110
|
-
onChange={
|
|
111
|
-
label="Disabled"
|
|
112
|
-
placeholder="Cannot select"
|
|
113
|
-
disabled
|
|
114
|
-
helperText="This picker is disabled"
|
|
98
|
+
value={inlineDate}
|
|
99
|
+
onChange={setInlineDate}
|
|
115
100
|
/>
|
|
101
|
+
<Text typography="caption" color="secondary">
|
|
102
|
+
Selected: {inlineDate.toDateString()}
|
|
103
|
+
</Text>
|
|
116
104
|
</View>
|
|
117
105
|
|
|
106
|
+
{/* Inline TimePicker */}
|
|
107
|
+
<View gap="md">
|
|
108
|
+
<Text typography="h4" weight="semibold">Inline TimePicker</Text>
|
|
109
|
+
<TimePicker
|
|
110
|
+
value={inlineTime}
|
|
111
|
+
onChange={setInlineTime}
|
|
112
|
+
mode="12h"
|
|
113
|
+
/>
|
|
114
|
+
<Text typography="caption" color="secondary">
|
|
115
|
+
Selected: {inlineTime.toLocaleTimeString()}
|
|
116
|
+
</Text>
|
|
117
|
+
</View>
|
|
118
|
+
|
|
119
|
+
{/* 24-hour Time */}
|
|
120
|
+
<View gap="md">
|
|
121
|
+
<Text typography="h4" weight="semibold">24-hour Format</Text>
|
|
122
|
+
<TimeInput
|
|
123
|
+
value={undefined}
|
|
124
|
+
onChange={() => {}}
|
|
125
|
+
label="24-hour Time"
|
|
126
|
+
placeholder="14:30"
|
|
127
|
+
mode="24h"
|
|
128
|
+
minuteStep={5}
|
|
129
|
+
/>
|
|
130
|
+
</View>
|
|
118
131
|
|
|
119
132
|
{/* Actions */}
|
|
120
|
-
<View
|
|
121
|
-
<Text
|
|
122
|
-
<View>
|
|
133
|
+
<View gap="md">
|
|
134
|
+
<Text typography="h4" weight="semibold">Actions</Text>
|
|
135
|
+
<View gap="sm">
|
|
123
136
|
<Button
|
|
124
|
-
type=
|
|
125
|
-
onPress={() =>
|
|
137
|
+
type="outlined"
|
|
138
|
+
onPress={() => {
|
|
139
|
+
const now = new Date();
|
|
140
|
+
setDate(now);
|
|
141
|
+
setTime(now);
|
|
142
|
+
setDateTime(now);
|
|
143
|
+
}}
|
|
126
144
|
>
|
|
127
|
-
Set
|
|
145
|
+
Set All to Now
|
|
128
146
|
</Button>
|
|
129
147
|
<Button
|
|
130
148
|
type="outlined"
|
|
131
149
|
onPress={() => {
|
|
132
|
-
|
|
133
|
-
|
|
150
|
+
setDate(null);
|
|
151
|
+
setTime(null);
|
|
152
|
+
setDateTime(null);
|
|
134
153
|
}}
|
|
135
154
|
>
|
|
136
155
|
Clear All
|
|
137
156
|
</Button>
|
|
138
157
|
</View>
|
|
139
158
|
</View>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
{/* Date Time Range Picker Examples */}
|
|
144
|
-
<View spacing="md">
|
|
145
|
-
<Text size="md" weight="semibold">DateTimeRangePicker Examples</Text>
|
|
146
|
-
|
|
147
|
-
{/* Basic DateTime Range */}
|
|
148
|
-
<View spacing="sm">
|
|
149
|
-
<Text size="sm" weight="medium">Date and time range selection</Text>
|
|
150
|
-
<DateTimeRangePicker
|
|
151
|
-
value={dateTimeRange}
|
|
152
|
-
onChange={setDateTimeRange}
|
|
153
|
-
label="Select Date & Time Range"
|
|
154
|
-
placeholder="Choose date/time range"
|
|
155
|
-
helperText="Select date range first, then adjust times"
|
|
156
|
-
/>
|
|
157
|
-
{dateTimeRange?.startDate && dateTimeRange?.endDate && (
|
|
158
|
-
<Text size="sm" color="secondary">
|
|
159
|
-
Range: {dateTimeRange.startDate.toLocaleString()} to {dateTimeRange.endDate.toLocaleString()}
|
|
160
|
-
</Text>
|
|
161
|
-
)}
|
|
162
|
-
</View>
|
|
163
|
-
</View>
|
|
164
|
-
|
|
165
|
-
{/* Features Description */}
|
|
166
|
-
<View spacing="md">
|
|
167
|
-
<Text size="md" weight="semibold">Features</Text>
|
|
168
|
-
<View spacing="sm">
|
|
169
|
-
<Text size="sm" color="secondary">
|
|
170
|
-
• Cross-platform calendar picker
|
|
171
|
-
</Text>
|
|
172
|
-
<Text size="sm" color="secondary">
|
|
173
|
-
• Date and time selection
|
|
174
|
-
</Text>
|
|
175
|
-
<Text size="sm" color="secondary">
|
|
176
|
-
• Date/time range selection
|
|
177
|
-
</Text>
|
|
178
|
-
<Text size="sm" color="secondary">
|
|
179
|
-
• 12/24 hour time formats
|
|
180
|
-
</Text>
|
|
181
|
-
<Text size="sm" color="secondary">
|
|
182
|
-
• Min/max date restrictions
|
|
183
|
-
</Text>
|
|
184
|
-
<Text size="sm" color="secondary">
|
|
185
|
-
• Accessible and keyboard navigable
|
|
186
|
-
</Text>
|
|
187
|
-
<Text size="sm" color="secondary">
|
|
188
|
-
• Theme-aware styling
|
|
189
|
-
</Text>
|
|
190
|
-
<Text size="sm" color="secondary">
|
|
191
|
-
• Customizable date/time formats
|
|
192
|
-
</Text>
|
|
193
|
-
</View>
|
|
194
|
-
</View>
|
|
195
159
|
</View>
|
|
196
160
|
</Screen>
|
|
197
161
|
);
|
|
198
|
-
};
|
|
162
|
+
};
|
package/src/examples/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DatePickerExamples } from './DatePickerExamples';
|
|
1
|
+
export { DatePickerExamples } from './DatePickerExamples';
|
package/src/index.native.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
//
|
|
2
|
-
export { DatePicker
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { DateTimePicker
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Date Input Component
|
|
18
|
-
export { DateInput } from './DateInput/index.native';
|
|
19
|
-
export type { DateInputProps } from './DateInput';
|
|
20
|
-
|
|
1
|
+
// Components - native platform
|
|
2
|
+
export { DatePicker } from './DatePicker';
|
|
3
|
+
export { TimePicker } from './TimePicker';
|
|
4
|
+
export { DateInput } from './DateInput.native';
|
|
5
|
+
export { TimeInput } from './TimeInput.native';
|
|
6
|
+
export { DateTimePicker } from './DateTimePicker';
|
|
7
|
+
|
|
8
|
+
// Types
|
|
9
|
+
export type {
|
|
10
|
+
DatePickerProps,
|
|
11
|
+
TimePickerProps,
|
|
12
|
+
DateInputProps,
|
|
13
|
+
TimeInputProps,
|
|
14
|
+
DateTimePickerProps,
|
|
15
|
+
} from './types';
|
package/src/index.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
//
|
|
2
|
-
export { DatePicker
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
// Date Time Picker Components
|
|
6
|
-
export { DateTimePicker, TimePicker } from './DateTimePicker';
|
|
7
|
-
export type { DateTimePickerProps, TimePickerProps } from './DateTimePicker';
|
|
8
|
-
|
|
9
|
-
// Date Range Picker Components
|
|
10
|
-
export { DateRangePicker, RangeCalendar } from './DateRangePicker';
|
|
11
|
-
export type { DateRangePickerProps, RangeCalendarProps, DateRange } from './DateRangePicker';
|
|
12
|
-
|
|
13
|
-
// Date Time Range Picker Components
|
|
14
|
-
export { DateTimeRangePicker } from './DateTimeRangePicker';
|
|
15
|
-
export type { DateTimeRangePickerProps, DateTimeRange } from './DateTimeRangePicker';
|
|
16
|
-
|
|
17
|
-
// Date Input Component
|
|
1
|
+
// Components
|
|
2
|
+
export { DatePicker } from './DatePicker';
|
|
3
|
+
export { TimePicker } from './TimePicker';
|
|
18
4
|
export { DateInput } from './DateInput';
|
|
19
|
-
export
|
|
20
|
-
|
|
5
|
+
export { TimeInput } from './TimeInput';
|
|
6
|
+
export { DateTimePicker } from './DateTimePicker';
|
|
7
|
+
|
|
8
|
+
// Types
|
|
9
|
+
export type {
|
|
10
|
+
DatePickerProps,
|
|
11
|
+
TimePickerProps,
|
|
12
|
+
DateInputProps,
|
|
13
|
+
TimeInputProps,
|
|
14
|
+
DateTimePickerProps,
|
|
15
|
+
} from './types';
|
package/src/styles.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import type { Theme } from '@idealyst/theme';
|
|
3
|
+
|
|
4
|
+
export type DatePickerVariants = {
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const datePickerStyles = StyleSheet.create((theme: Theme) => {
|
|
9
|
+
return {
|
|
10
|
+
// Calendar container - compact
|
|
11
|
+
calendar: {
|
|
12
|
+
padding: 8,
|
|
13
|
+
backgroundColor: theme.colors.surface.primary,
|
|
14
|
+
borderRadius: 6,
|
|
15
|
+
width: 220,
|
|
16
|
+
variants: {
|
|
17
|
+
disabled: {
|
|
18
|
+
true: { opacity: 0.6 },
|
|
19
|
+
false: { opacity: 1 },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
// Calendar header with month/year and navigation
|
|
25
|
+
calendarHeader: {
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'space-between',
|
|
29
|
+
marginBottom: 4,
|
|
30
|
+
paddingHorizontal: 2,
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
calendarTitle: {
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
gap: 2,
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
// Weekday header row
|
|
40
|
+
weekdayRow: {
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
marginBottom: 2,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
weekdayCell: {
|
|
46
|
+
width: 28,
|
|
47
|
+
height: 20,
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
// Calendar grid
|
|
53
|
+
calendarGrid: {
|
|
54
|
+
flexDirection: 'row',
|
|
55
|
+
flexWrap: 'wrap',
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// Month selector grid (3x4)
|
|
59
|
+
monthGrid: {
|
|
60
|
+
flexDirection: 'row',
|
|
61
|
+
flexWrap: 'wrap',
|
|
62
|
+
justifyContent: 'center',
|
|
63
|
+
paddingVertical: 8,
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
// Year selector grid
|
|
67
|
+
yearGrid: {
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
flexWrap: 'wrap',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
paddingVertical: 8,
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// Individual day cell - compact
|
|
75
|
+
dayCell: {
|
|
76
|
+
width: 28,
|
|
77
|
+
height: 28,
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
justifyContent: 'center',
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// Time picker container
|
|
83
|
+
timePicker: {
|
|
84
|
+
padding: 12,
|
|
85
|
+
backgroundColor: theme.colors.surface.primary,
|
|
86
|
+
borderRadius: 6,
|
|
87
|
+
variants: {
|
|
88
|
+
disabled: {
|
|
89
|
+
true: { opacity: 0.6 },
|
|
90
|
+
false: { opacity: 1 },
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// Time columns container
|
|
96
|
+
timeColumns: {
|
|
97
|
+
flexDirection: 'row',
|
|
98
|
+
gap: 8,
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// Individual time column (hours, minutes, period)
|
|
103
|
+
timeColumn: {
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
gap: 2,
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// Time separator (colon)
|
|
109
|
+
timeSeparator: {
|
|
110
|
+
paddingHorizontal: 2,
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
// Input row for datetime picker
|
|
114
|
+
inputRow: {
|
|
115
|
+
flexDirection: 'row',
|
|
116
|
+
gap: 8,
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
// Popover content wrapper
|
|
120
|
+
popoverContent: {
|
|
121
|
+
backgroundColor: theme.colors.surface.primary,
|
|
122
|
+
borderRadius: 6,
|
|
123
|
+
...theme.shadows.lg,
|
|
124
|
+
overflow: 'hidden',
|
|
125
|
+
},
|
|
126
|
+
} as const;
|
|
127
|
+
});
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface DatePickerProps {
|
|
4
|
+
value?: Date;
|
|
5
|
+
onChange: (date: Date) => void;
|
|
6
|
+
minDate?: Date;
|
|
7
|
+
maxDate?: Date;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
style?: ViewStyle;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TimePickerProps {
|
|
13
|
+
value?: Date;
|
|
14
|
+
onChange: (date: Date) => void;
|
|
15
|
+
mode?: '12h' | '24h';
|
|
16
|
+
minuteStep?: number;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
style?: ViewStyle;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DateInputProps {
|
|
22
|
+
value?: Date;
|
|
23
|
+
onChange: (date: Date | null) => void;
|
|
24
|
+
label?: string;
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
minDate?: Date;
|
|
27
|
+
maxDate?: Date;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
style?: ViewStyle;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TimeInputProps {
|
|
34
|
+
value?: Date;
|
|
35
|
+
onChange: (date: Date | null) => void;
|
|
36
|
+
label?: string;
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
mode?: '12h' | '24h';
|
|
39
|
+
minuteStep?: number;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
error?: string;
|
|
42
|
+
style?: ViewStyle;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface DateTimePickerProps {
|
|
46
|
+
value?: Date;
|
|
47
|
+
onChange: (date: Date | null) => void;
|
|
48
|
+
label?: string;
|
|
49
|
+
minDate?: Date;
|
|
50
|
+
maxDate?: Date;
|
|
51
|
+
timeMode?: '12h' | '24h';
|
|
52
|
+
minuteStep?: number;
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
error?: string;
|
|
55
|
+
style?: ViewStyle;
|
|
56
|
+
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, Input, Text } from '@idealyst/components';
|
|
3
|
-
import { DateInputBase } from './DateInputBase';
|
|
4
|
-
import { DateInputProps } from './types';
|
|
5
|
-
import { dateInputStyles } from './DateInput.styles';
|
|
6
|
-
|
|
7
|
-
export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
8
|
-
const {
|
|
9
|
-
label,
|
|
10
|
-
error,
|
|
11
|
-
helperText,
|
|
12
|
-
size = 'md',
|
|
13
|
-
variant = 'outlined',
|
|
14
|
-
disabled = false,
|
|
15
|
-
style,
|
|
16
|
-
inputStyle,
|
|
17
|
-
testID,
|
|
18
|
-
...baseProps
|
|
19
|
-
} = props;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<View style={style} testID={testID}>
|
|
24
|
-
{label && (
|
|
25
|
-
<Text style={dateInputStyles.label} testID={testID ? `${testID}-label` : undefined}>
|
|
26
|
-
{label}
|
|
27
|
-
</Text>
|
|
28
|
-
)}
|
|
29
|
-
|
|
30
|
-
<DateInputBase {...baseProps} disabled={disabled} testID={testID}>
|
|
31
|
-
{({ value, onChangeText, onFocus, onBlur, placeholder, disabled: inputDisabled, testID: inputTestID }) => (
|
|
32
|
-
<Input
|
|
33
|
-
value={value}
|
|
34
|
-
onChangeText={onChangeText}
|
|
35
|
-
onFocus={onFocus}
|
|
36
|
-
onBlur={onBlur}
|
|
37
|
-
placeholder={placeholder}
|
|
38
|
-
disabled={inputDisabled}
|
|
39
|
-
size={size}
|
|
40
|
-
variant={variant}
|
|
41
|
-
hasError={error ? true : false}
|
|
42
|
-
style={inputStyle}
|
|
43
|
-
testID={inputTestID}
|
|
44
|
-
/>
|
|
45
|
-
)}
|
|
46
|
-
</DateInputBase>
|
|
47
|
-
|
|
48
|
-
{error && (
|
|
49
|
-
<Text style={dateInputStyles.errorText} testID={testID ? `${testID}-error` : undefined}>
|
|
50
|
-
{error}
|
|
51
|
-
</Text>
|
|
52
|
-
)}
|
|
53
|
-
|
|
54
|
-
{!error && helperText && (
|
|
55
|
-
<Text style={dateInputStyles.helperText} testID={testID ? `${testID}-helper` : undefined}>
|
|
56
|
-
{helperText}
|
|
57
|
-
</Text>
|
|
58
|
-
)}
|
|
59
|
-
</View>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
|
|
3
|
-
export const dateInputStyles = StyleSheet.create((theme) => ({
|
|
4
|
-
container: {
|
|
5
|
-
width: '100%',
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
label: {
|
|
9
|
-
fontSize: theme.typography?.fontSize?.sm || 14,
|
|
10
|
-
color: theme.colors?.text?.primary || '#1f2937',
|
|
11
|
-
marginBottom: theme.spacing?.xs || 4,
|
|
12
|
-
fontWeight: '500',
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
helperText: {
|
|
16
|
-
fontSize: theme.typography?.fontSize?.sm || 12,
|
|
17
|
-
color: theme.colors?.text?.secondary || '#6b7280',
|
|
18
|
-
marginTop: theme.spacing?.xs || 4,
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
errorText: {
|
|
22
|
-
fontSize: theme.typography?.fontSize?.sm || 12,
|
|
23
|
-
color: theme.colors?.text?.error || '#dc2626',
|
|
24
|
-
marginTop: theme.spacing?.xs || 4,
|
|
25
|
-
},
|
|
26
|
-
}));
|