@idealyst/datepicker 1.1.8 → 1.2.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.
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import { getWebProps } from 'react-native-unistyles/web';
3
- import { Text, Button, Icon } from '@idealyst/components';
4
- import { datePickerStyles } from './styles';
3
+ import { mdiChevronUp, mdiChevronDown } from '@mdi/js';
4
+ import { IconSvg } from './IconSvg.web';
5
+ import { timePickerStyles } from './TimePicker.styles';
5
6
  import type { TimePickerProps } from './types';
6
7
 
7
8
  export const TimePicker: React.FC<TimePickerProps> = ({
@@ -12,7 +13,7 @@ export const TimePicker: React.FC<TimePickerProps> = ({
12
13
  disabled = false,
13
14
  style,
14
15
  }) => {
15
- datePickerStyles.useVariants({ disabled });
16
+ const styles = timePickerStyles;
16
17
 
17
18
  const currentDate = value || new Date();
18
19
  const hours = currentDate.getHours();
@@ -54,57 +55,85 @@ export const TimePicker: React.FC<TimePickerProps> = ({
54
55
  updateTime(newHours, minutes);
55
56
  };
56
57
 
57
- // Get web props for styled elements
58
- const timePickerProps = getWebProps([datePickerStyles.timePicker, style as any]);
59
- const timeColumnsProps = getWebProps([datePickerStyles.timeColumns]);
60
- const timeColumnProps = getWebProps([datePickerStyles.timeColumn]);
61
- const timeSeparatorProps = getWebProps([datePickerStyles.timeSeparator]);
58
+ // Get dynamic styles
59
+ const timePickerStyle = (styles.timePicker as any)({ disabled });
60
+ const timeColumnsStyle = (styles.timeColumns as any)({});
61
+ const timeColumnStyle = (styles.timeColumn as any)({});
62
+ const timeSeparatorStyle = (styles.timeSeparator as any)({});
63
+ const separatorTextStyle = (styles.separatorText as any)({});
64
+ const timeValueStyle = (styles.timeValue as any)({});
65
+ const arrowButtonStyle = (styles.arrowButton as any)({ disabled });
66
+ const periodButtonStyle = (styles.periodButton as any)({ disabled });
67
+ const periodButtonTextStyle = (styles.periodButtonText as any)({});
68
+ const iconColorStyle = (styles.iconColor as any)({});
69
+
70
+ // Get web props
71
+ const timePickerProps = getWebProps([timePickerStyle, style as any]);
72
+ const timeColumnsProps = getWebProps([timeColumnsStyle]);
73
+ const timeColumnProps = getWebProps([timeColumnStyle]);
62
74
 
63
75
  return (
64
76
  <div {...timePickerProps}>
65
77
  <div {...timeColumnsProps}>
66
78
  {/* Hours column */}
67
79
  <div {...timeColumnProps}>
68
- <Button type="text" size="sm" onPress={incrementHours} disabled={disabled}>
69
- <Icon name="chevron-up" size={20} />
70
- </Button>
71
- <Text typography="h3" weight="semibold">
80
+ <button
81
+ style={arrowButtonStyle}
82
+ onClick={incrementHours}
83
+ disabled={disabled}
84
+ >
85
+ <IconSvg path={mdiChevronUp} size={20} color={iconColorStyle.color} />
86
+ </button>
87
+ <span style={timeValueStyle}>
72
88
  {String(displayHours).padStart(2, '0')}
73
- </Text>
74
- <Button type="text" size="sm" onPress={decrementHours} disabled={disabled}>
75
- <Icon name="chevron-down" size={20} />
76
- </Button>
89
+ </span>
90
+ <button
91
+ style={arrowButtonStyle}
92
+ onClick={decrementHours}
93
+ disabled={disabled}
94
+ >
95
+ <IconSvg path={mdiChevronDown} size={20} color={iconColorStyle.color} />
96
+ </button>
77
97
  </div>
78
98
 
79
99
  {/* Separator */}
80
- <div {...timeSeparatorProps}>
81
- <Text typography="h3" weight="semibold">:</Text>
100
+ <div style={timeSeparatorStyle}>
101
+ <span style={separatorTextStyle}>:</span>
82
102
  </div>
83
103
 
84
104
  {/* Minutes column */}
85
105
  <div {...timeColumnProps}>
86
- <Button type="text" size="sm" onPress={incrementMinutes} disabled={disabled}>
87
- <Icon name="chevron-up" size={20} />
88
- </Button>
89
- <Text typography="h3" weight="semibold">
106
+ <button
107
+ style={arrowButtonStyle}
108
+ onClick={incrementMinutes}
109
+ disabled={disabled}
110
+ >
111
+ <IconSvg path={mdiChevronUp} size={20} color={iconColorStyle.color} />
112
+ </button>
113
+ <span style={timeValueStyle}>
90
114
  {String(minutes).padStart(2, '0')}
91
- </Text>
92
- <Button type="text" size="sm" onPress={decrementMinutes} disabled={disabled}>
93
- <Icon name="chevron-down" size={20} />
94
- </Button>
115
+ </span>
116
+ <button
117
+ style={arrowButtonStyle}
118
+ onClick={decrementMinutes}
119
+ disabled={disabled}
120
+ >
121
+ <IconSvg path={mdiChevronDown} size={20} color={iconColorStyle.color} />
122
+ </button>
95
123
  </div>
96
124
 
97
125
  {/* AM/PM toggle for 12-hour mode */}
98
126
  {is12Hour && (
99
127
  <div {...timeColumnProps}>
100
- <Button
101
- type="outlined"
102
- size="sm"
103
- onPress={togglePeriod}
128
+ <button
129
+ style={periodButtonStyle}
130
+ onClick={togglePeriod}
104
131
  disabled={disabled}
105
132
  >
106
- {isPM ? 'PM' : 'AM'}
107
- </Button>
133
+ <span style={periodButtonTextStyle}>
134
+ {isPM ? 'PM' : 'AM'}
135
+ </span>
136
+ </button>
108
137
  </div>
109
138
  )}
110
139
  </div>
package/src/styles.ts DELETED
@@ -1,254 +0,0 @@
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 type InputContainerVariants = {
9
- disabled: boolean;
10
- error: boolean;
11
- };
12
-
13
- export const datePickerStyles = StyleSheet.create((theme: Theme) => {
14
- return {
15
- // Calendar container - compact
16
- calendar: {
17
- padding: 8,
18
- backgroundColor: theme.colors.surface.primary,
19
- borderRadius: 6,
20
- width: 220,
21
- variants: {
22
- disabled: {
23
- true: { opacity: 0.6 },
24
- false: { opacity: 1 },
25
- },
26
- },
27
- },
28
-
29
- // Calendar header with month/year and navigation
30
- calendarHeader: {
31
- flexDirection: 'row',
32
- alignItems: 'center',
33
- justifyContent: 'space-between',
34
- marginBottom: 4,
35
- paddingHorizontal: 2,
36
- _web: {
37
- display: 'flex',
38
- },
39
- },
40
-
41
- calendarTitle: {
42
- flexDirection: 'row',
43
- alignItems: 'center',
44
- gap: 2,
45
- _web: {
46
- display: 'flex',
47
- },
48
- },
49
-
50
- // Weekday header row
51
- weekdayRow: {
52
- flexDirection: 'row',
53
- marginBottom: 2,
54
- _web: {
55
- display: 'flex',
56
- },
57
- },
58
-
59
- weekdayCell: {
60
- width: 28,
61
- height: 20,
62
- alignItems: 'center',
63
- justifyContent: 'center',
64
- _web: {
65
- display: 'flex',
66
- },
67
- },
68
-
69
- // Calendar grid
70
- calendarGrid: {
71
- flexDirection: 'row',
72
- flexWrap: 'wrap',
73
- _web: {
74
- display: 'flex',
75
- },
76
- },
77
-
78
- // Month selector grid (3x4)
79
- monthGrid: {
80
- flexDirection: 'row',
81
- flexWrap: 'wrap',
82
- justifyContent: 'center',
83
- paddingVertical: 8,
84
- _web: {
85
- display: 'flex',
86
- },
87
- },
88
-
89
- // Year selector grid
90
- yearGrid: {
91
- flexDirection: 'row',
92
- flexWrap: 'wrap',
93
- justifyContent: 'center',
94
- paddingVertical: 8,
95
- _web: {
96
- display: 'flex',
97
- },
98
- },
99
-
100
- // Individual day cell - compact
101
- dayCell: {
102
- width: 28,
103
- height: 28,
104
- alignItems: 'center',
105
- justifyContent: 'center',
106
- _web: {
107
- display: 'flex',
108
- },
109
- },
110
-
111
- // Time picker container
112
- timePicker: {
113
- padding: 12,
114
- backgroundColor: theme.colors.surface.primary,
115
- borderRadius: 6,
116
- variants: {
117
- disabled: {
118
- true: { opacity: 0.6 },
119
- false: { opacity: 1 },
120
- },
121
- },
122
- },
123
-
124
- // Time columns container
125
- timeColumns: {
126
- flexDirection: 'row',
127
- gap: 8,
128
- alignItems: 'center',
129
- _web: {
130
- display: 'flex',
131
- },
132
- },
133
-
134
- // Individual time column (hours, minutes, period)
135
- timeColumn: {
136
- alignItems: 'center',
137
- gap: 2,
138
- _web: {
139
- display: 'flex',
140
- },
141
- },
142
-
143
- // Time separator (colon)
144
- timeSeparator: {
145
- paddingHorizontal: 2,
146
- },
147
-
148
- // Input row for datetime picker
149
- inputRow: {
150
- flexDirection: 'row',
151
- gap: 8,
152
- _web: {
153
- display: 'flex',
154
- },
155
- },
156
-
157
- // Popover content wrapper
158
- popoverContent: {
159
- backgroundColor: theme.colors.surface.primary,
160
- borderRadius: 6,
161
- ...theme.shadows.lg,
162
- overflow: 'hidden',
163
- },
164
-
165
- // Input container for DateInput/TimeInput
166
- inputContainer: {
167
- flexDirection: 'row',
168
- alignItems: 'center',
169
- borderWidth: 1,
170
- borderRadius: 6,
171
- overflow: 'hidden',
172
- borderColor: theme.colors.border.primary,
173
- backgroundColor: theme.colors.surface.primary,
174
- variants: {
175
- disabled: {
176
- true: {
177
- backgroundColor: theme.colors.surface.secondary,
178
- },
179
- false: {},
180
- },
181
- error: {
182
- true: {
183
- borderColor: theme.intents.error.primary,
184
- },
185
- false: {},
186
- },
187
- },
188
- _web: {
189
- display: 'flex',
190
- flexDirection: 'row',
191
- alignItems: 'center',
192
- border: `1px solid ${theme.colors.border.primary}`,
193
- },
194
- },
195
-
196
- // Text input inside the input container
197
- textInput: {
198
- flex: 1,
199
- padding: 8,
200
- paddingHorizontal: 12,
201
- fontSize: 14,
202
- backgroundColor: 'transparent',
203
- color: theme.colors.text.primary,
204
- variants: {
205
- disabled: {
206
- true: {
207
- color: theme.colors.text.tertiary,
208
- },
209
- false: {},
210
- },
211
- },
212
- _web: {
213
- outline: 'none',
214
- border: 'none',
215
- },
216
- },
217
-
218
- // Error text below input
219
- errorText: {
220
- marginTop: 4,
221
- color: theme.intents.error.primary,
222
- },
223
-
224
- // Label text above input
225
- labelText: {
226
- marginBottom: 4,
227
- },
228
-
229
- // Modal backdrop
230
- modalBackdrop: {
231
- flex: 1,
232
- justifyContent: 'center',
233
- alignItems: 'center',
234
- backgroundColor: 'rgba(0,0,0,0.5)',
235
- },
236
-
237
- // Selected day styling
238
- selectedDay: {
239
- backgroundColor: theme.intents.primary.primary,
240
- borderRadius: 14,
241
- },
242
-
243
- selectedDayText: {
244
- color: theme.intents.primary.contrast,
245
- },
246
-
247
- // Today styling
248
- todayDay: {
249
- borderWidth: 1,
250
- borderColor: theme.intents.primary.primary,
251
- borderRadius: 14,
252
- },
253
- } as const;
254
- });