@flipova/foundation 2.3.0 → 2.4.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 (98) hide show
  1. package/README.md +157 -156
  2. package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +16 -7
  3. package/components/ui/accordion/AccordionAnimatedHeight.tsx +3 -15
  4. package/components/ui/accordion/AccordionAnimatedIcon.tsx +2 -9
  5. package/components/ui/accordion/AnimatedHeight.tsx +3 -15
  6. package/components/ui/accordion/AnimatedIcon.tsx +2 -9
  7. package/components/ui/accordion/MIGRATION_SUMMARY.md +22 -11
  8. package/components/ui/accordion/USAGE_EXAMPLE.tsx +10 -25
  9. package/components/ui/accordion/index.tsx +71 -139
  10. package/components/ui/actionsheet/index.tsx +63 -105
  11. package/components/ui/alert/index.tsx +20 -50
  12. package/components/ui/alert-dialog/index.tsx +23 -48
  13. package/components/ui/avatar/index.tsx +32 -68
  14. package/components/ui/badge/index.tsx +18 -49
  15. package/components/ui/bottomsheet/index.tsx +20 -52
  16. package/components/ui/box/index.tsx +4 -9
  17. package/components/ui/box/index.web.tsx +3 -9
  18. package/components/ui/button/index.tsx +73 -109
  19. package/components/ui/calendar/creator.tsx +69 -30
  20. package/components/ui/calendar/index.tsx +81 -159
  21. package/components/ui/calendar/styles.tsx +10 -10
  22. package/components/ui/card/index.tsx +8 -9
  23. package/components/ui/card/index.web.tsx +4 -10
  24. package/components/ui/center/index.tsx +6 -11
  25. package/components/ui/center/index.web.tsx +3 -9
  26. package/components/ui/checkbox/index.tsx +46 -107
  27. package/components/ui/date-time-picker/creator.tsx +14 -1
  28. package/components/ui/date-time-picker/index.tsx +107 -156
  29. package/components/ui/date-time-picker/index.web.tsx +11 -33
  30. package/components/ui/date-time-picker/styles.tsx +5 -5
  31. package/components/ui/divider/index.tsx +5 -6
  32. package/components/ui/drawer/index.tsx +108 -128
  33. package/components/ui/fab/index.tsx +25 -68
  34. package/components/ui/flat-list/index.tsx +11 -8
  35. package/components/ui/form-control/index.tsx +49 -90
  36. package/components/ui/gluestack-ui-provider/index.tsx +4 -18
  37. package/components/ui/gluestack-ui-provider/index.web.tsx +10 -11
  38. package/components/ui/gluestack-ui-provider/script.ts +1 -3
  39. package/components/ui/gluestack-ui-provider/theme-context.ts +2 -2
  40. package/components/ui/gluestack-ui-provider/useGluestackColors.ts +2 -6
  41. package/components/ui/grid/index.tsx +128 -165
  42. package/components/ui/grid/index.web.tsx +17 -19
  43. package/components/ui/grid/styles.tsx +1 -3
  44. package/components/ui/heading/index.tsx +146 -169
  45. package/components/ui/heading/index.web.tsx +7 -28
  46. package/components/ui/heading/styles.tsx +5 -5
  47. package/components/ui/hstack/index.tsx +16 -15
  48. package/components/ui/hstack/index.web.tsx +17 -17
  49. package/components/ui/hstack/styles.tsx +5 -5
  50. package/components/ui/icon/index.tsx +95 -486
  51. package/components/ui/icon/index.web.tsx +79 -439
  52. package/components/ui/image/index.tsx +13 -18
  53. package/components/ui/image-viewer/index.tsx +149 -221
  54. package/components/ui/image-viewer/index.web.tsx +88 -113
  55. package/components/ui/input/index.tsx +20 -33
  56. package/components/ui/link/index.tsx +16 -22
  57. package/components/ui/liquid-glass/index.tsx +19 -25
  58. package/components/ui/menu/index.tsx +44 -66
  59. package/components/ui/modal/index.tsx +70 -91
  60. package/components/ui/popover/index.tsx +102 -121
  61. package/components/ui/portal/index.tsx +5 -6
  62. package/components/ui/pressable/index.tsx +5 -9
  63. package/components/ui/progress/index.tsx +4 -11
  64. package/components/ui/radio/index.tsx +47 -83
  65. package/components/ui/select/index.tsx +38 -59
  66. package/components/ui/select/select-actionsheet.tsx +61 -108
  67. package/components/ui/skeleton/index.tsx +22 -43
  68. package/components/ui/skeleton/index.web.tsx +63 -75
  69. package/components/ui/slider/index.tsx +36 -56
  70. package/components/ui/spinner/index.tsx +1 -10
  71. package/components/ui/switch/index.tsx +6 -13
  72. package/components/ui/table/index.tsx +39 -102
  73. package/components/ui/table/index.web.tsx +41 -79
  74. package/components/ui/tabs/TabsAnimatedIndicator.tsx +10 -38
  75. package/components/ui/tabs/creator.tsx +32 -24
  76. package/components/ui/tabs/index.tsx +253 -309
  77. package/components/ui/text/index.tsx +23 -37
  78. package/components/ui/text/index.web.tsx +33 -35
  79. package/components/ui/text/styles.tsx +5 -5
  80. package/components/ui/textarea/index.tsx +24 -38
  81. package/components/ui/toast/index.tsx +47 -52
  82. package/components/ui/tooltip/index.tsx +12 -28
  83. package/components/ui/vstack/index.tsx +17 -17
  84. package/components/ui/vstack/index.web.tsx +17 -17
  85. package/components/ui/vstack/styles.tsx +5 -5
  86. package/design/tools/design.js +15 -12
  87. package/design/tools/npm.js +4 -3
  88. package/dist/{chunk-B277QSR5.mjs → chunk-2R66P5X5.mjs} +1816 -3124
  89. package/dist/chunk-2R66P5X5.mjs.map +1 -0
  90. package/dist/{chunk-GD37RFBR.js → chunk-LCTFQJZM.js} +1816 -3124
  91. package/dist/chunk-LCTFQJZM.js.map +1 -0
  92. package/dist/index.js +294 -294
  93. package/dist/index.mjs +1 -1
  94. package/dist/ui/index.js +294 -294
  95. package/dist/ui/index.mjs +1 -1
  96. package/package.json +12 -7
  97. package/dist/chunk-B277QSR5.mjs.map +0 -1
  98. package/dist/chunk-GD37RFBR.js.map +0 -1
@@ -9,34 +9,30 @@ import { withStyleContext } from '@gluestack-ui/utils/nativewind-utils';
9
9
  import { cssInterop } from 'nativewind';
10
10
  import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
11
11
 
12
- const IndicatorWrapper = React.forwardRef<
13
- React.ComponentRef<typeof View>,
14
- ViewProps
15
- >(function IndicatorWrapper({ ...props }, ref) {
12
+ const IndicatorWrapper = React.forwardRef<React.ComponentRef<typeof View>, ViewProps>(function IndicatorWrapper(
13
+ { ...props },
14
+ ref,
15
+ ) {
16
16
  return <View {...props} ref={ref} />;
17
17
  });
18
18
 
19
- const LabelWrapper = React.forwardRef<
20
- React.ComponentRef<typeof Text>,
21
- TextProps
22
- >(function LabelWrapper({ ...props }, ref) {
19
+ const LabelWrapper = React.forwardRef<React.ComponentRef<typeof Text>, TextProps>(function LabelWrapper(
20
+ { ...props },
21
+ ref,
22
+ ) {
23
23
  return <Text {...props} ref={ref} />;
24
24
  });
25
25
 
26
- const IconWrapper = React.forwardRef<
27
- React.ComponentRef<typeof UIIcon>,
28
- React.ComponentPropsWithoutRef<typeof UIIcon>
29
- >(function IconWrapper({ ...props }, ref) {
30
- return <UIIcon {...props} ref={ref as any} />;
31
- });
26
+ const IconWrapper = React.forwardRef<React.ComponentRef<typeof UIIcon>, React.ComponentPropsWithoutRef<typeof UIIcon>>(
27
+ function IconWrapper({ ...props }, ref) {
28
+ return <UIIcon {...props} ref={ref as any} />;
29
+ },
30
+ );
32
31
 
33
32
  const SCOPE = 'CHECKBOX';
34
33
  const UICheckbox = createCheckbox({
35
34
  // @ts-expect-error : internal implementation for r-19/react-native-web
36
- Root:
37
- Platform.OS === 'web'
38
- ? withStyleContext(View, SCOPE)
39
- : withStyleContext(Pressable, SCOPE),
35
+ Root: Platform.OS === 'web' ? withStyleContext(View, SCOPE) : withStyleContext(Pressable, SCOPE),
40
36
  Group: View,
41
37
  Icon: IconWrapper,
42
38
  Label: LabelWrapper,
@@ -74,111 +70,54 @@ const checkboxIconStyle = tva({
74
70
 
75
71
  const CheckboxGroup = UICheckbox.Group;
76
72
 
77
- type ICheckboxProps = React.ComponentPropsWithoutRef<typeof UICheckbox> &
78
- VariantProps<typeof checkboxStyle>;
79
-
80
- const Checkbox = React.forwardRef<
81
- React.ComponentRef<typeof UICheckbox>,
82
- ICheckboxProps
83
- >(function Checkbox({ className, ...props }, ref) {
84
- return (
85
- <UICheckbox
86
- className={checkboxStyle({ class: className })}
87
- {...props}
88
- context={{}}
89
- ref={ref}
90
- />
91
- );
73
+ type ICheckboxProps = React.ComponentPropsWithoutRef<typeof UICheckbox> & VariantProps<typeof checkboxStyle>;
74
+
75
+ const Checkbox = React.forwardRef<React.ComponentRef<typeof UICheckbox>, ICheckboxProps>(function Checkbox(
76
+ { className, ...props },
77
+ ref,
78
+ ) {
79
+ return <UICheckbox className={checkboxStyle({ class: className })} {...props} context={{}} ref={ref} />;
92
80
  });
93
81
 
94
- type ICheckboxIndicatorProps = React.ComponentPropsWithoutRef<
95
- typeof UICheckbox.Indicator
96
- > &
82
+ type ICheckboxIndicatorProps = React.ComponentPropsWithoutRef<typeof UICheckbox.Indicator> &
97
83
  VariantProps<typeof checkboxIndicatorStyle>;
98
84
 
99
- const CheckboxIndicator = React.forwardRef<
100
- React.ComponentRef<typeof UICheckbox.Indicator>,
101
- ICheckboxIndicatorProps
102
- >(function CheckboxIndicator({ className, ...props }, ref) {
103
- return (
104
- <UICheckbox.Indicator
105
- className={checkboxIndicatorStyle({ class: className })}
106
- {...props}
107
- ref={ref}
108
- />
109
- );
110
- });
85
+ const CheckboxIndicator = React.forwardRef<React.ComponentRef<typeof UICheckbox.Indicator>, ICheckboxIndicatorProps>(
86
+ function CheckboxIndicator({ className, ...props }, ref) {
87
+ return <UICheckbox.Indicator className={checkboxIndicatorStyle({ class: className })} {...props} ref={ref} />;
88
+ },
89
+ );
111
90
 
112
- type ICheckboxLabelProps = React.ComponentPropsWithoutRef<
113
- typeof UICheckbox.Label
114
- > &
91
+ type ICheckboxLabelProps = React.ComponentPropsWithoutRef<typeof UICheckbox.Label> &
115
92
  VariantProps<typeof checkboxLabelStyle>;
116
- const CheckboxLabel = React.forwardRef<
117
- React.ComponentRef<typeof UICheckbox.Label>,
118
- ICheckboxLabelProps
119
- >(function CheckboxLabel({ className, ...props }, ref) {
120
- return (
121
- <UICheckbox.Label
122
- className={checkboxLabelStyle({ class: className })}
123
- {...props}
124
- ref={ref}
125
- />
126
- );
127
- });
93
+ const CheckboxLabel = React.forwardRef<React.ComponentRef<typeof UICheckbox.Label>, ICheckboxLabelProps>(
94
+ function CheckboxLabel({ className, ...props }, ref) {
95
+ return <UICheckbox.Label className={checkboxLabelStyle({ class: className })} {...props} ref={ref} />;
96
+ },
97
+ );
128
98
 
129
- type ICheckboxIconProps = React.ComponentPropsWithoutRef<
130
- typeof UICheckbox.Icon
131
- > &
99
+ type ICheckboxIconProps = React.ComponentPropsWithoutRef<typeof UICheckbox.Icon> &
132
100
  VariantProps<typeof checkboxIconStyle> & {
133
101
  size?: number;
134
102
  height?: number;
135
103
  width?: number;
136
104
  };
137
105
 
138
- const CheckboxIcon = React.forwardRef<
139
- React.ComponentRef<typeof UICheckbox.Icon>,
140
- ICheckboxIconProps
141
- >(function CheckboxIcon({ className, size, ...props }, ref) {
142
- if (typeof size === 'number') {
143
- return (
144
- <UICheckbox.Icon
145
- ref={ref}
146
- {...props}
147
- className={checkboxIconStyle({ class: className })}
148
- size={size}
149
- />
150
- );
151
- } else if (
152
- (props.height !== undefined || props.width !== undefined) &&
153
- size === undefined
154
- ) {
155
- return (
156
- <UICheckbox.Icon
157
- ref={ref}
158
- {...props}
159
- className={checkboxIconStyle({ class: className })}
160
- />
161
- );
162
- }
163
-
164
- return (
165
- <UICheckbox.Icon
166
- className={checkboxIconStyle({ class: className })}
167
- {...props}
168
- ref={ref}
169
- />
170
- );
171
- });
106
+ const CheckboxIcon = React.forwardRef<React.ComponentRef<typeof UICheckbox.Icon>, ICheckboxIconProps>(
107
+ function CheckboxIcon({ className, size, ...props }, ref) {
108
+ if (typeof size === 'number') {
109
+ return <UICheckbox.Icon ref={ref} {...props} className={checkboxIconStyle({ class: className })} size={size} />;
110
+ } else if ((props.height !== undefined || props.width !== undefined) && size === undefined) {
111
+ return <UICheckbox.Icon ref={ref} {...props} className={checkboxIconStyle({ class: className })} />;
112
+ }
113
+
114
+ return <UICheckbox.Icon className={checkboxIconStyle({ class: className })} {...props} ref={ref} />;
115
+ },
116
+ );
172
117
 
173
118
  Checkbox.displayName = 'Checkbox';
174
119
  CheckboxIndicator.displayName = 'CheckboxIndicator';
175
120
  CheckboxLabel.displayName = 'CheckboxLabel';
176
121
  CheckboxIcon.displayName = 'CheckboxIcon';
177
122
 
178
- export {
179
- Checkbox,
180
- CheckboxIndicator,
181
- CheckboxLabel,
182
- CheckboxIcon,
183
- CheckboxGroup,
184
- };
123
+ export { Checkbox, CheckboxIndicator, CheckboxLabel, CheckboxIcon, CheckboxGroup };
@@ -70,7 +70,20 @@ export function DateTimePickerProvider({
70
70
  isOpen,
71
71
  setIsOpen,
72
72
  }),
73
- [value, onChange, mode, minimumDate, maximumDate, locale, timeZoneOffsetInMinutes, is24Hour, disabled, placeholder, format, isOpen]
73
+ [
74
+ value,
75
+ onChange,
76
+ mode,
77
+ minimumDate,
78
+ maximumDate,
79
+ locale,
80
+ timeZoneOffsetInMinutes,
81
+ is24Hour,
82
+ disabled,
83
+ placeholder,
84
+ format,
85
+ isOpen,
86
+ ],
74
87
  );
75
88
 
76
89
  return <DateTimePickerContext.Provider value={contextValue}>{children}</DateTimePickerContext.Provider>;
@@ -1,26 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  import React, { useCallback, useMemo } from 'react';
4
- import {
5
- View,
6
- Pressable,
7
- TextInput,
8
- Text,
9
- Platform,
10
- Modal,
11
- } from 'react-native';
4
+ import { View, Pressable, TextInput, Text, Platform, Modal } from 'react-native';
12
5
  import DateTimePickerNative from '@react-native-community/datetimepicker';
13
6
  import { tva } from '@gluestack-ui/utils/nativewind-utils';
14
- import {
15
- withStyleContext,
16
- useStyleContext,
17
- } from '@gluestack-ui/utils/nativewind-utils';
7
+ import { withStyleContext, useStyleContext } from '@gluestack-ui/utils/nativewind-utils';
18
8
  import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
19
- import {
20
- createDateTimePicker,
21
- DateTimePickerProvider,
22
- useDateTimePicker,
23
- } from './creator';
9
+ import { createDateTimePicker, DateTimePickerProvider, useDateTimePicker } from './creator';
24
10
  import { cssInterop } from 'nativewind';
25
11
  import { PrimitiveIcon, UIIcon } from '@gluestack-ui/core/icon/creator';
26
12
  import {
@@ -83,44 +69,73 @@ cssInterop(PrimitiveIcon, {
83
69
  },
84
70
  });
85
71
 
86
- type IDateTimePickerProps = VariantProps<typeof dateTimePickerStyle> &
87
- DateTimePickerProps & { className?: string };
88
-
89
- const DateTimePicker = React.forwardRef<
90
- React.ComponentRef<typeof UIDateTimePicker>,
91
- IDateTimePickerProps
92
- >(function DateTimePicker(
93
- {
94
- className,
95
- value,
96
- onChange,
97
- mode = 'datetime',
98
- minimumDate,
99
- maximumDate,
100
- locale,
101
- timeZoneOffsetInMinutes,
102
- is24Hour,
103
- disabled,
104
- placeholder,
105
- format,
106
- display = 'modal', // Default to modal for iOS
107
- children,
108
- ...props
109
- },
110
- ref
111
- ) {
112
- const handleNativeChange = useCallback(
113
- (event: any, selectedDate?: Date) => {
114
- // The native picker handles its own close
115
- if (selectedDate) {
116
- onChange?.(selectedDate);
117
- }
72
+ type IDateTimePickerProps = VariantProps<typeof dateTimePickerStyle> & DateTimePickerProps & { className?: string };
73
+
74
+ const DateTimePicker = React.forwardRef<React.ComponentRef<typeof UIDateTimePicker>, IDateTimePickerProps>(
75
+ function DateTimePicker(
76
+ {
77
+ className,
78
+ value,
79
+ onChange,
80
+ mode = 'datetime',
81
+ minimumDate,
82
+ maximumDate,
83
+ locale,
84
+ timeZoneOffsetInMinutes,
85
+ is24Hour,
86
+ disabled,
87
+ placeholder,
88
+ format,
89
+ display = 'modal', // Default to modal for iOS
90
+ children,
91
+ ...props
118
92
  },
119
- [onChange]
120
- );
93
+ ref,
94
+ ) {
95
+ const handleNativeChange = useCallback(
96
+ (event: any, selectedDate?: Date) => {
97
+ // The native picker handles its own close
98
+ if (selectedDate) {
99
+ onChange?.(selectedDate);
100
+ }
101
+ },
102
+ [onChange],
103
+ );
104
+
105
+ // On iOS, use custom trigger + spinner in modal or inline
106
+ if (Platform.OS === 'ios') {
107
+ return (
108
+ <DateTimePickerProvider
109
+ value={value}
110
+ onChange={onChange}
111
+ mode={mode}
112
+ minimumDate={minimumDate}
113
+ maximumDate={maximumDate}
114
+ locale={locale}
115
+ timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
116
+ is24Hour={is24Hour}
117
+ disabled={disabled}
118
+ placeholder={placeholder}
119
+ format={format}
120
+ >
121
+ <UIDateTimePicker className={dateTimePickerStyle({ class: className })} ref={ref} {...props}>
122
+ {children}
123
+ </UIDateTimePicker>
124
+ {/* iOS spinner picker shown in modal or inline based on display prop */}
125
+ <IOSDateTimePicker
126
+ value={value}
127
+ mode={mode}
128
+ minimumDate={minimumDate}
129
+ maximumDate={maximumDate}
130
+ timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
131
+ is24Hour={is24Hour}
132
+ display={display}
133
+ onChange={handleNativeChange}
134
+ />
135
+ </DateTimePickerProvider>
136
+ );
137
+ }
121
138
 
122
- // On iOS, use custom trigger + spinner in modal or inline
123
- if (Platform.OS === 'ios') {
124
139
  return (
125
140
  <DateTimePickerProvider
126
141
  value={value}
@@ -135,62 +150,23 @@ const DateTimePicker = React.forwardRef<
135
150
  placeholder={placeholder}
136
151
  format={format}
137
152
  >
138
- <UIDateTimePicker
139
- className={dateTimePickerStyle({ class: className })}
140
- ref={ref}
141
- {...props}
142
- >
153
+ <UIDateTimePicker className={dateTimePickerStyle({ class: className })} ref={ref} {...props}>
143
154
  {children}
144
155
  </UIDateTimePicker>
145
- {/* iOS spinner picker shown in modal or inline based on display prop */}
146
- <IOSDateTimePicker
156
+ {/* Native picker is rendered directly on Android */}
157
+ <DateTimePickerNativeWrapper
147
158
  value={value}
148
159
  mode={mode}
149
160
  minimumDate={minimumDate}
150
161
  maximumDate={maximumDate}
151
162
  timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
152
163
  is24Hour={is24Hour}
153
- display={display}
154
164
  onChange={handleNativeChange}
155
165
  />
156
166
  </DateTimePickerProvider>
157
167
  );
158
- }
159
-
160
- return (
161
- <DateTimePickerProvider
162
- value={value}
163
- onChange={onChange}
164
- mode={mode}
165
- minimumDate={minimumDate}
166
- maximumDate={maximumDate}
167
- locale={locale}
168
- timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
169
- is24Hour={is24Hour}
170
- disabled={disabled}
171
- placeholder={placeholder}
172
- format={format}
173
- >
174
- <UIDateTimePicker
175
- className={dateTimePickerStyle({ class: className })}
176
- ref={ref}
177
- {...props}
178
- >
179
- {children}
180
- </UIDateTimePicker>
181
- {/* Native picker is rendered directly on Android */}
182
- <DateTimePickerNativeWrapper
183
- value={value}
184
- mode={mode}
185
- minimumDate={minimumDate}
186
- maximumDate={maximumDate}
187
- timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
188
- is24Hour={is24Hour}
189
- onChange={handleNativeChange}
190
- />
191
- </DateTimePickerProvider>
192
- );
193
- });
168
+ },
169
+ );
194
170
 
195
171
  // Separate component to handle the native picker display (Android only)
196
172
  function DateTimePickerNativeWrapper({
@@ -217,7 +193,7 @@ function DateTimePickerNativeWrapper({
217
193
  setIsOpen(false);
218
194
  onChange(event, selectedDate);
219
195
  },
220
- [onChange, setIsOpen]
196
+ [onChange, setIsOpen],
221
197
  );
222
198
 
223
199
  // Android doesn't support 'datetime' mode - use two-step picker
@@ -292,7 +268,7 @@ function AndroidDateTimePicker({
292
268
  setIsOpen(false);
293
269
  }
294
270
  },
295
- [setIsOpen]
271
+ [setIsOpen],
296
272
  );
297
273
 
298
274
  const handleTimeChange = React.useCallback(
@@ -309,7 +285,7 @@ function AndroidDateTimePicker({
309
285
  onChange(event, selectedTime);
310
286
  }
311
287
  },
312
- [tempDate, onChange, setIsOpen]
288
+ [tempDate, onChange, setIsOpen],
313
289
  );
314
290
 
315
291
  if (!isOpen || !step) return null;
@@ -378,7 +354,7 @@ function IOSDateTimePicker({
378
354
  onChange(event, selectedDate);
379
355
  }
380
356
  },
381
- [onChange]
357
+ [onChange],
382
358
  );
383
359
 
384
360
  const handleDone = React.useCallback(() => {
@@ -415,32 +391,18 @@ function IOSDateTimePicker({
415
391
 
416
392
  // Modal mode: show picker in modal with backdrop
417
393
  return (
418
- <Modal
419
- visible={isOpen}
420
- transparent={true}
421
- animationType="slide"
422
- onRequestClose={handleCancel}
423
- >
394
+ <Modal visible={isOpen} transparent={true} animationType="slide" onRequestClose={handleCancel}>
424
395
  <View className="flex-1 justify-end">
425
396
  {/* Backdrop - separate touchable area */}
426
- <Pressable
427
- className="absolute inset-0 bg-black/50"
428
- onPress={handleCancel}
429
- />
397
+ <Pressable className="absolute inset-0 bg-black/50" onPress={handleCancel} />
430
398
  {/* Picker container */}
431
399
  <View className="bg-background rounded-t-lg p-4 relative">
432
400
  <View className="flex-row justify-between items-center mb-4 border-b border-border pb-2">
433
401
  <Pressable onPress={handleCancel}>
434
- <Text className="text-primary font-semibold text-base">
435
- Cancel
436
- </Text>
402
+ <Text className="text-primary font-semibold text-base">Cancel</Text>
437
403
  </Pressable>
438
404
  <Text className="text-foreground font-semibold text-base">
439
- {mode === 'date'
440
- ? 'Select Date'
441
- : mode === 'time'
442
- ? 'Select Time'
443
- : 'Select Date & Time'}
405
+ {mode === 'date' ? 'Select Date' : mode === 'time' ? 'Select Time' : 'Select Date & Time'}
444
406
  </Text>
445
407
  <Pressable onPress={handleDone}>
446
408
  <Text className="text-primary font-semibold text-base">Done</Text>
@@ -462,9 +424,7 @@ function IOSDateTimePicker({
462
424
  );
463
425
  }
464
426
 
465
- type IDateTimePickerTriggerProps = VariantProps<
466
- typeof dateTimePickerTriggerStyle
467
- > &
427
+ type IDateTimePickerTriggerProps = VariantProps<typeof dateTimePickerTriggerStyle> &
468
428
  React.ComponentProps<typeof UIDateTimePicker.Trigger> & {
469
429
  className?: string;
470
430
  };
@@ -472,10 +432,7 @@ type IDateTimePickerTriggerProps = VariantProps<
472
432
  const DateTimePickerTrigger = React.forwardRef<
473
433
  React.ComponentRef<typeof UIDateTimePicker.Trigger>,
474
434
  IDateTimePickerTriggerProps
475
- >(function DateTimePickerTrigger(
476
- { className, size = 'md', variant = 'outline', ...props },
477
- ref
478
- ) {
435
+ >(function DateTimePickerTrigger({ className, size = 'md', variant = 'outline', ...props }, ref) {
479
436
  const { disabled, setIsOpen } = useDateTimePicker();
480
437
 
481
438
  return (
@@ -534,37 +491,36 @@ const DateTimePickerInput = React.forwardRef<
534
491
  type IDateTimePickerIconProps = VariantProps<typeof dateTimePickerIconStyle> &
535
492
  React.ComponentProps<typeof UIDateTimePicker.Icon> & { className?: string };
536
493
 
537
- const DateTimePickerIcon = React.forwardRef<
538
- React.ComponentRef<typeof UIDateTimePicker.Icon>,
539
- IDateTimePickerIconProps
540
- >(function DateTimePickerIcon({ className, size, ...props }, ref) {
541
- const { size: parentSize } = useStyleContext(SCOPE);
494
+ const DateTimePickerIcon = React.forwardRef<React.ComponentRef<typeof UIDateTimePicker.Icon>, IDateTimePickerIconProps>(
495
+ function DateTimePickerIcon({ className, size, ...props }, ref) {
496
+ const { size: parentSize } = useStyleContext(SCOPE);
497
+
498
+ if (typeof size === 'number') {
499
+ return (
500
+ <UIDateTimePicker.Icon
501
+ ref={ref}
502
+ {...props}
503
+ className={dateTimePickerIconStyle({ class: className })}
504
+ size={size}
505
+ />
506
+ );
507
+ }
542
508
 
543
- if (typeof size === 'number') {
544
509
  return (
545
510
  <UIDateTimePicker.Icon
511
+ className={dateTimePickerIconStyle({
512
+ class: className,
513
+ size,
514
+ parentVariants: {
515
+ size: parentSize,
516
+ },
517
+ })}
546
518
  ref={ref}
547
519
  {...props}
548
- className={dateTimePickerIconStyle({ class: className })}
549
- size={size}
550
520
  />
551
521
  );
552
- }
553
-
554
- return (
555
- <UIDateTimePicker.Icon
556
- className={dateTimePickerIconStyle({
557
- class: className,
558
- size,
559
- parentVariants: {
560
- size: parentSize,
561
- },
562
- })}
563
- ref={ref}
564
- {...props}
565
- />
566
- );
567
- });
522
+ },
523
+ );
568
524
 
569
525
  function formatDate(date: Date, format: string): string {
570
526
  const pad = (n: number) => n.toString().padStart(2, '0');
@@ -577,9 +533,4 @@ function formatDate(date: Date, format: string): string {
577
533
  .replace('ss', pad(date.getSeconds()));
578
534
  }
579
535
 
580
- export {
581
- DateTimePicker,
582
- DateTimePickerTrigger,
583
- DateTimePickerInput,
584
- DateTimePickerIcon,
585
- };
536
+ export { DateTimePicker, DateTimePickerTrigger, DateTimePickerInput, DateTimePickerIcon };
@@ -27,10 +27,7 @@ interface DateTimePickerProps {
27
27
  style?: any;
28
28
  }
29
29
 
30
- const DateTimePicker = React.forwardRef<
31
- React.ComponentRef<typeof View>,
32
- DateTimePickerProps
33
- >(function DateTimePicker(
30
+ const DateTimePicker = React.forwardRef<React.ComponentRef<typeof View>, DateTimePickerProps>(function DateTimePicker(
34
31
  {
35
32
  value,
36
33
  onChange,
@@ -42,13 +39,11 @@ const DateTimePicker = React.forwardRef<
42
39
  className,
43
40
  style,
44
41
  },
45
- ref
42
+ ref,
46
43
  ) {
47
44
  const [isOpen, setIsOpen] = useState(false);
48
45
  const [tempDate, setTempDate] = useState<Date | undefined>(value);
49
- const [tempTime, setTempTime] = useState(
50
- value ? formatTimeForInput(value) : ''
51
- );
46
+ const [tempTime, setTempTime] = useState(value ? formatTimeForInput(value) : '');
52
47
 
53
48
  const handleDateSelect = useCallback(
54
49
  (date: Date) => {
@@ -58,15 +53,12 @@ const DateTimePicker = React.forwardRef<
58
53
  setIsOpen(false);
59
54
  }
60
55
  },
61
- [mode, onChange]
56
+ [mode, onChange],
62
57
  );
63
58
 
64
- const handleTimeChange = useCallback(
65
- (e: React.ChangeEvent<HTMLInputElement>) => {
66
- setTempTime(e.target.value);
67
- },
68
- []
69
- );
59
+ const handleTimeChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
60
+ setTempTime(e.target.value);
61
+ }, []);
70
62
 
71
63
  const handleConfirm = useCallback(() => {
72
64
  if (mode === 'time' && tempTime) {
@@ -103,10 +95,7 @@ const DateTimePicker = React.forwardRef<
103
95
  return (
104
96
  <View ref={ref} className={`relative ${className || ''}`} style={style}>
105
97
  {/* Trigger Input */}
106
- <Pressable
107
- onPress={() => !disabled && setIsOpen(true)}
108
- className="w-full"
109
- >
98
+ <Pressable onPress={() => !disabled && setIsOpen(true)} className="w-full">
110
99
  <View className="flex-row items-center border border-border rounded-md px-3 py-2 bg-background">
111
100
  <TextInput
112
101
  value={displayValue || placeholder}
@@ -148,16 +137,10 @@ const DateTimePicker = React.forwardRef<
148
137
 
149
138
  {/* Actions */}
150
139
  <View className="flex-row justify-end gap-2">
151
- <Pressable
152
- onPress={handleCancel}
153
- className="px-4 py-2 rounded bg-muted"
154
- >
140
+ <Pressable onPress={handleCancel} className="px-4 py-2 rounded bg-muted">
155
141
  <span className="text-muted-foreground text-sm">Cancel</span>
156
142
  </Pressable>
157
- <Pressable
158
- onPress={handleConfirm}
159
- className="px-4 py-2 rounded bg-primary"
160
- >
143
+ <Pressable onPress={handleConfirm} className="px-4 py-2 rounded bg-primary">
161
144
  <span className="text-primary-foreground text-sm">Confirm</span>
162
145
  </Pressable>
163
146
  </View>
@@ -208,10 +191,5 @@ const DateTimePickerIcon = React.forwardRef<
208
191
  return <PrimitiveIcon ref={ref} {...props} />;
209
192
  });
210
193
 
211
- export {
212
- DateTimePicker,
213
- DateTimePickerTrigger,
214
- DateTimePickerInput,
215
- DateTimePickerIcon,
216
- };
194
+ export { DateTimePicker, DateTimePickerTrigger, DateTimePickerInput, DateTimePickerIcon };
217
195
  export type { DateTimePickerProps, DateTimePickerMode };