@flipova/foundation 2.2.1 → 2.4.0-beta.1
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/CHANGELOG.md +6 -0
- package/README.md +157 -156
- package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +16 -7
- package/components/ui/accordion/AccordionAnimatedHeight.tsx +3 -15
- package/components/ui/accordion/AccordionAnimatedIcon.tsx +2 -9
- package/components/ui/accordion/AnimatedHeight.tsx +3 -15
- package/components/ui/accordion/AnimatedIcon.tsx +2 -9
- package/components/ui/accordion/MIGRATION_SUMMARY.md +22 -11
- package/components/ui/accordion/USAGE_EXAMPLE.tsx +10 -25
- package/components/ui/accordion/index.tsx +71 -139
- package/components/ui/actionsheet/index.tsx +63 -105
- package/components/ui/alert/index.tsx +20 -50
- package/components/ui/alert-dialog/index.tsx +23 -48
- package/components/ui/avatar/index.tsx +32 -68
- package/components/ui/badge/index.tsx +18 -49
- package/components/ui/bottomsheet/index.tsx +20 -52
- package/components/ui/box/index.tsx +4 -9
- package/components/ui/box/index.web.tsx +3 -9
- package/components/ui/button/index.tsx +73 -109
- package/components/ui/calendar/creator.tsx +69 -30
- package/components/ui/calendar/index.tsx +81 -159
- package/components/ui/calendar/styles.tsx +10 -10
- package/components/ui/card/index.tsx +8 -9
- package/components/ui/card/index.web.tsx +4 -10
- package/components/ui/center/index.tsx +6 -11
- package/components/ui/center/index.web.tsx +3 -9
- package/components/ui/checkbox/index.tsx +46 -107
- package/components/ui/date-time-picker/creator.tsx +14 -1
- package/components/ui/date-time-picker/index.tsx +107 -156
- package/components/ui/date-time-picker/index.web.tsx +11 -33
- package/components/ui/date-time-picker/styles.tsx +5 -5
- package/components/ui/divider/index.tsx +5 -6
- package/components/ui/drawer/index.tsx +108 -128
- package/components/ui/fab/index.tsx +25 -68
- package/components/ui/flat-list/index.tsx +11 -8
- package/components/ui/form-control/index.tsx +49 -90
- package/components/ui/gluestack-ui-provider/config.ts +69 -2
- package/components/ui/gluestack-ui-provider/index.tsx +32 -12
- package/components/ui/gluestack-ui-provider/index.web.tsx +43 -16
- package/components/ui/gluestack-ui-provider/script.ts +13 -8
- package/components/ui/gluestack-ui-provider/theme-context.ts +36 -1
- package/components/ui/gluestack-ui-provider/useGluestackColors.ts +11 -4
- package/components/ui/grid/index.tsx +128 -165
- package/components/ui/grid/index.web.tsx +17 -19
- package/components/ui/grid/styles.tsx +1 -3
- package/components/ui/heading/index.tsx +146 -169
- package/components/ui/heading/index.web.tsx +7 -28
- package/components/ui/heading/styles.tsx +5 -5
- package/components/ui/hstack/index.tsx +16 -15
- package/components/ui/hstack/index.web.tsx +17 -17
- package/components/ui/hstack/styles.tsx +5 -5
- package/components/ui/icon/index.tsx +95 -486
- package/components/ui/icon/index.web.tsx +79 -439
- package/components/ui/image/index.tsx +13 -18
- package/components/ui/image-viewer/index.tsx +149 -221
- package/components/ui/image-viewer/index.web.tsx +88 -113
- package/components/ui/input/index.tsx +20 -33
- package/components/ui/link/index.tsx +16 -22
- package/components/ui/liquid-glass/index.tsx +19 -25
- package/components/ui/menu/index.tsx +44 -66
- package/components/ui/modal/index.tsx +70 -91
- package/components/ui/popover/index.tsx +102 -121
- package/components/ui/portal/index.tsx +5 -6
- package/components/ui/pressable/index.tsx +5 -9
- package/components/ui/progress/index.tsx +4 -11
- package/components/ui/radio/index.tsx +47 -83
- package/components/ui/select/index.tsx +38 -59
- package/components/ui/select/select-actionsheet.tsx +61 -108
- package/components/ui/skeleton/index.tsx +22 -43
- package/components/ui/skeleton/index.web.tsx +63 -75
- package/components/ui/slider/index.tsx +36 -56
- package/components/ui/spinner/index.tsx +1 -10
- package/components/ui/switch/index.tsx +6 -13
- package/components/ui/table/index.tsx +39 -102
- package/components/ui/table/index.web.tsx +41 -79
- package/components/ui/tabs/TabsAnimatedIndicator.tsx +10 -38
- package/components/ui/tabs/creator.tsx +32 -24
- package/components/ui/tabs/index.tsx +253 -309
- package/components/ui/text/index.tsx +23 -37
- package/components/ui/text/index.web.tsx +33 -35
- package/components/ui/text/styles.tsx +5 -5
- package/components/ui/textarea/index.tsx +24 -38
- package/components/ui/toast/index.tsx +47 -52
- package/components/ui/tooltip/index.tsx +12 -28
- package/components/ui/vstack/index.tsx +17 -17
- package/components/ui/vstack/index.web.tsx +17 -17
- package/components/ui/vstack/styles.tsx +5 -5
- package/design/canonical.index.txt +15 -1
- package/design/manifest.xml +2 -0
- package/design/schema.xsd +11 -0
- package/design/themes.xml +175 -2
- package/design/tools/design.js +15 -12
- package/design/tools/npm.js +4 -3
- package/design/tools/sources/.generate/config.py +60 -2
- package/dist/{chunk-RPLDFHEZ.mjs → chunk-2R66P5X5.mjs} +1907 -3130
- package/dist/chunk-2R66P5X5.mjs.map +1 -0
- package/dist/{chunk-JVHJUIXV.js → chunk-LCTFQJZM.js} +1909 -3129
- package/dist/chunk-LCTFQJZM.js.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +303 -291
- package/dist/index.mjs +1 -1
- package/dist/ui/index.d.mts +44 -3
- package/dist/ui/index.d.ts +44 -3
- package/dist/ui/index.js +303 -291
- package/dist/ui/index.mjs +1 -1
- package/package.json +12 -7
- package/dist/chunk-JVHJUIXV.js.map +0 -1
- package/dist/chunk-RPLDFHEZ.mjs.map +0 -1
|
@@ -48,15 +48,27 @@ export interface ICalendarProps {
|
|
|
48
48
|
const DAY_MS = 86400000;
|
|
49
49
|
const WEEKDAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
50
50
|
const MONTH_LABELS = [
|
|
51
|
-
'January',
|
|
52
|
-
'
|
|
51
|
+
'January',
|
|
52
|
+
'February',
|
|
53
|
+
'March',
|
|
54
|
+
'April',
|
|
55
|
+
'May',
|
|
56
|
+
'June',
|
|
57
|
+
'July',
|
|
58
|
+
'August',
|
|
59
|
+
'September',
|
|
60
|
+
'October',
|
|
61
|
+
'November',
|
|
62
|
+
'December',
|
|
53
63
|
];
|
|
54
64
|
|
|
55
65
|
function stripTime(d: Date) {
|
|
56
66
|
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
57
67
|
}
|
|
58
68
|
function isSameDay(a?: Date, b?: Date) {
|
|
59
|
-
return
|
|
69
|
+
return (
|
|
70
|
+
!!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate()
|
|
71
|
+
);
|
|
60
72
|
}
|
|
61
73
|
function startOfMonthDate(d: Date) {
|
|
62
74
|
return new Date(d.getFullYear(), d.getMonth(), 1);
|
|
@@ -96,7 +108,10 @@ function getWeekNumber(date: Date) {
|
|
|
96
108
|
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
97
109
|
return Math.ceil(((d.getTime() - yearStart.getTime()) / DAY_MS + 1) / 7);
|
|
98
110
|
}
|
|
99
|
-
function isDateDisabled(
|
|
111
|
+
function isDateDisabled(
|
|
112
|
+
date: Date,
|
|
113
|
+
props: Pick<ICalendarProps, 'minimumDate' | 'maximumDate' | 'disabledDates' | 'disabled'>,
|
|
114
|
+
) {
|
|
100
115
|
if (props.disabled) return true;
|
|
101
116
|
if (props.minimumDate && stripTime(date) < stripTime(props.minimumDate)) return true;
|
|
102
117
|
if (props.maximumDate && stripTime(date) > stripTime(props.maximumDate)) return true;
|
|
@@ -129,8 +144,22 @@ export interface CreateCalendarConfig {
|
|
|
129
144
|
|
|
130
145
|
export function createCalendar(slots: CreateCalendarConfig) {
|
|
131
146
|
const {
|
|
132
|
-
Root,
|
|
133
|
-
|
|
147
|
+
Root,
|
|
148
|
+
Header,
|
|
149
|
+
HeaderPrevButton,
|
|
150
|
+
HeaderNextButton,
|
|
151
|
+
HeaderMonthSelect,
|
|
152
|
+
HeaderYearSelect,
|
|
153
|
+
WeekDaysHeader,
|
|
154
|
+
WeekDay,
|
|
155
|
+
Body,
|
|
156
|
+
Grid,
|
|
157
|
+
Week,
|
|
158
|
+
Day,
|
|
159
|
+
DayText,
|
|
160
|
+
DayIndicator,
|
|
161
|
+
WeekNumber,
|
|
162
|
+
Footer,
|
|
134
163
|
} = slots;
|
|
135
164
|
|
|
136
165
|
const Calendar = React.forwardRef<any, ICalendarProps & { className?: string }>(function Calendar(props, ref) {
|
|
@@ -162,7 +191,8 @@ export function createCalendar(slots: CreateCalendarConfig) {
|
|
|
162
191
|
if (defaultMonth) return startOfMonthDate(defaultMonth);
|
|
163
192
|
if (mode === 'single' && currentValue instanceof Date) return startOfMonthDate(currentValue);
|
|
164
193
|
if (mode === 'range' && currentValue?.from) return startOfMonthDate(currentValue.from);
|
|
165
|
-
if (mode === 'multiple' && Array.isArray(currentValue) && currentValue[0])
|
|
194
|
+
if (mode === 'multiple' && Array.isArray(currentValue) && currentValue[0])
|
|
195
|
+
return startOfMonthDate(currentValue[0]);
|
|
166
196
|
return startOfMonthDate(new Date());
|
|
167
197
|
});
|
|
168
198
|
const displayedMonth = controlledMonth ? startOfMonthDate(controlledMonth) : uncontrolledMonth;
|
|
@@ -172,7 +202,7 @@ export function createCalendar(slots: CreateCalendarConfig) {
|
|
|
172
202
|
if (!controlledMonth) setUncontrolledMonth(next);
|
|
173
203
|
onMonthChange?.(next);
|
|
174
204
|
},
|
|
175
|
-
[controlledMonth, onMonthChange]
|
|
205
|
+
[controlledMonth, onMonthChange],
|
|
176
206
|
);
|
|
177
207
|
|
|
178
208
|
const setValue = React.useCallback(
|
|
@@ -180,7 +210,7 @@ export function createCalendar(slots: CreateCalendarConfig) {
|
|
|
180
210
|
if (value === undefined) setUncontrolledValue(next);
|
|
181
211
|
onValueChange?.(next);
|
|
182
212
|
},
|
|
183
|
-
[value, onValueChange]
|
|
213
|
+
[value, onValueChange],
|
|
184
214
|
);
|
|
185
215
|
|
|
186
216
|
const handleDayPress = React.useCallback(
|
|
@@ -204,13 +234,13 @@ export function createCalendar(slots: CreateCalendarConfig) {
|
|
|
204
234
|
setValue(date);
|
|
205
235
|
}
|
|
206
236
|
},
|
|
207
|
-
[mode, currentValue, setValue, minimumDate, maximumDate, disabledDates, disabled]
|
|
237
|
+
[mode, currentValue, setValue, minimumDate, maximumDate, disabledDates, disabled],
|
|
208
238
|
);
|
|
209
239
|
|
|
210
240
|
const weeks = React.useMemo(() => buildMonthGrid(displayedMonth, weekStartsOn), [displayedMonth, weekStartsOn]);
|
|
211
241
|
const weekDayLabels = React.useMemo(
|
|
212
242
|
() => Array.from({ length: 7 }, (_, i) => WEEKDAY_LABELS[(weekStartsOn + i) % 7]),
|
|
213
|
-
[weekStartsOn]
|
|
243
|
+
[weekStartsOn],
|
|
214
244
|
);
|
|
215
245
|
const today = React.useMemo(() => new Date(), []);
|
|
216
246
|
|
|
@@ -241,11 +271,19 @@ export function createCalendar(slots: CreateCalendarConfig) {
|
|
|
241
271
|
const isRangeStart = !!range?.from && isSameDay(date, range.from);
|
|
242
272
|
const isRangeEnd = !!range?.to && isSameDay(date, range.to);
|
|
243
273
|
const isInRange = !!range?.from && !!range?.to && date > stripTime(range.from) && date < stripTime(range.to);
|
|
244
|
-
return {
|
|
274
|
+
return {
|
|
275
|
+
isSelected: isRangeStart || isRangeEnd,
|
|
276
|
+
isToday,
|
|
277
|
+
isDisabled,
|
|
278
|
+
isOutsideMonth,
|
|
279
|
+
isInRange,
|
|
280
|
+
isRangeStart,
|
|
281
|
+
isRangeEnd,
|
|
282
|
+
};
|
|
245
283
|
}
|
|
246
284
|
return { isSelected: isSameDay(currentValue as Date | undefined, date), isToday, isDisabled, isOutsideMonth };
|
|
247
285
|
},
|
|
248
|
-
[mode, currentValue, displayedMonth, today, minimumDate, maximumDate, disabledDates, disabled]
|
|
286
|
+
[mode, currentValue, displayedMonth, today, minimumDate, maximumDate, disabledDates, disabled],
|
|
249
287
|
);
|
|
250
288
|
|
|
251
289
|
return (
|
|
@@ -289,23 +327,24 @@ export function createCalendar(slots: CreateCalendarConfig) {
|
|
|
289
327
|
{week.map((date) => {
|
|
290
328
|
const state = resolveDayState(date);
|
|
291
329
|
const dayMarkers = markers?.filter((m: CalendarMarker) => isSameDay(m.date, date)) ?? [];
|
|
292
|
-
const dataState =
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
330
|
+
const dataState =
|
|
331
|
+
state.isRangeStart && state.isRangeEnd
|
|
332
|
+
? 'selected'
|
|
333
|
+
: state.isRangeStart
|
|
334
|
+
? 'range-start'
|
|
335
|
+
: state.isRangeEnd
|
|
336
|
+
? 'range-end'
|
|
337
|
+
: state.isInRange
|
|
338
|
+
? 'range-middle'
|
|
339
|
+
: state.isSelected
|
|
340
|
+
? 'selected'
|
|
341
|
+
: state.isToday
|
|
342
|
+
? 'today'
|
|
343
|
+
: state.isDisabled
|
|
344
|
+
? 'disabled'
|
|
345
|
+
: state.isOutsideMonth
|
|
346
|
+
? 'outside-month'
|
|
347
|
+
: 'default';
|
|
309
348
|
|
|
310
349
|
return (
|
|
311
350
|
<Day
|
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { View, Text, Pressable } from 'react-native';
|
|
5
|
-
import {
|
|
6
|
-
createCalendar,
|
|
7
|
-
type ICalendarProps,
|
|
8
|
-
type CalendarMode,
|
|
9
|
-
type CalendarMarkers,
|
|
10
|
-
} from './creator';
|
|
5
|
+
import { createCalendar, type ICalendarProps, type CalendarMode, type CalendarMarkers } from './creator';
|
|
11
6
|
import { cssInterop } from 'nativewind';
|
|
12
7
|
import {
|
|
13
8
|
calendarStyle,
|
|
@@ -40,13 +35,7 @@ const CalendarRoot = React.forwardRef<
|
|
|
40
35
|
React.ElementRef<typeof View>,
|
|
41
36
|
ICalendarProps & React.ComponentProps<typeof View> & { className?: string }
|
|
42
37
|
>(({ className, ...props }, ref) => {
|
|
43
|
-
return (
|
|
44
|
-
<View
|
|
45
|
-
ref={ref}
|
|
46
|
-
className={calendarStyle({ class: className })}
|
|
47
|
-
{...props}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
38
|
+
return <View ref={ref} className={calendarStyle({ class: className })} {...props} />;
|
|
50
39
|
});
|
|
51
40
|
|
|
52
41
|
// Styled Header
|
|
@@ -54,13 +43,7 @@ const CalendarHeaderRoot = React.forwardRef<
|
|
|
54
43
|
React.ElementRef<typeof View>,
|
|
55
44
|
React.ComponentProps<typeof View> & { className?: string }
|
|
56
45
|
>(({ className, ...props }, ref) => {
|
|
57
|
-
return (
|
|
58
|
-
<View
|
|
59
|
-
ref={ref}
|
|
60
|
-
className={calendarHeaderStyle({ class: className })}
|
|
61
|
-
{...props}
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
46
|
+
return <View ref={ref} className={calendarHeaderStyle({ class: className })} {...props} />;
|
|
64
47
|
});
|
|
65
48
|
|
|
66
49
|
const CalendarHeaderPrevButtonRoot = React.forwardRef<
|
|
@@ -101,18 +84,22 @@ const CalendarHeaderTitleRoot = React.forwardRef<
|
|
|
101
84
|
React.ElementRef<typeof Text>,
|
|
102
85
|
React.ComponentProps<typeof Text> & { className?: string }
|
|
103
86
|
>(({ className, ...props }, ref) => {
|
|
104
|
-
return (
|
|
105
|
-
<Text
|
|
106
|
-
ref={ref}
|
|
107
|
-
className={calendarHeaderTitleStyle({ class: className })}
|
|
108
|
-
{...props}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
87
|
+
return <Text ref={ref} className={calendarHeaderTitleStyle({ class: className })} {...props} />;
|
|
111
88
|
});
|
|
112
89
|
|
|
113
90
|
const MONTH_NAMES = [
|
|
114
|
-
'January',
|
|
115
|
-
'
|
|
91
|
+
'January',
|
|
92
|
+
'February',
|
|
93
|
+
'March',
|
|
94
|
+
'April',
|
|
95
|
+
'May',
|
|
96
|
+
'June',
|
|
97
|
+
'July',
|
|
98
|
+
'August',
|
|
99
|
+
'September',
|
|
100
|
+
'October',
|
|
101
|
+
'November',
|
|
102
|
+
'December',
|
|
116
103
|
];
|
|
117
104
|
|
|
118
105
|
type SelectRootProps = React.ComponentProps<typeof View> & {
|
|
@@ -122,86 +109,66 @@ type SelectRootProps = React.ComponentProps<typeof View> & {
|
|
|
122
109
|
onValueChange?: (value: number) => void;
|
|
123
110
|
};
|
|
124
111
|
|
|
125
|
-
const CalendarHeaderMonthSelectRoot = React.forwardRef<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
</MenuItemLabel>
|
|
152
|
-
</MenuItem>
|
|
153
|
-
))}
|
|
154
|
-
</Menu>
|
|
155
|
-
</View>
|
|
156
|
-
);
|
|
157
|
-
});
|
|
112
|
+
const CalendarHeaderMonthSelectRoot = React.forwardRef<React.ElementRef<typeof View>, SelectRootProps>(
|
|
113
|
+
({ className, items = [], selectedValue, onValueChange, ...props }, ref) => {
|
|
114
|
+
const label = selectedValue !== undefined ? MONTH_NAMES[selectedValue] : 'Month';
|
|
115
|
+
return (
|
|
116
|
+
<View ref={ref} className={calendarHeaderSelectStyle({ class: className })} {...props}>
|
|
117
|
+
<Menu
|
|
118
|
+
placement="bottom"
|
|
119
|
+
offset={4}
|
|
120
|
+
trigger={({ ...triggerProps }) => (
|
|
121
|
+
<Pressable {...triggerProps} className="px-2 py-1 rounded-md flex-row items-center">
|
|
122
|
+
<Text className="text-sm font-medium text-foreground">{label}</Text>
|
|
123
|
+
</Pressable>
|
|
124
|
+
)}
|
|
125
|
+
>
|
|
126
|
+
{items.map((item) => (
|
|
127
|
+
<MenuItem key={item.value} textValue={item.label} onPress={() => onValueChange?.(item.value)}>
|
|
128
|
+
<MenuItemLabel className={item.value === selectedValue ? 'text-primary font-semibold' : ''}>
|
|
129
|
+
{item.label}
|
|
130
|
+
</MenuItemLabel>
|
|
131
|
+
</MenuItem>
|
|
132
|
+
))}
|
|
133
|
+
</Menu>
|
|
134
|
+
</View>
|
|
135
|
+
);
|
|
136
|
+
},
|
|
137
|
+
);
|
|
158
138
|
|
|
159
|
-
const CalendarHeaderYearSelectRoot = React.forwardRef<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
</MenuItemLabel>
|
|
186
|
-
</MenuItem>
|
|
187
|
-
))}
|
|
188
|
-
</Menu>
|
|
189
|
-
</View>
|
|
190
|
-
);
|
|
191
|
-
});
|
|
139
|
+
const CalendarHeaderYearSelectRoot = React.forwardRef<React.ElementRef<typeof View>, SelectRootProps>(
|
|
140
|
+
({ className, items = [], selectedValue, onValueChange, ...props }, ref) => {
|
|
141
|
+
const label = selectedValue !== undefined ? String(selectedValue) : 'Year';
|
|
142
|
+
return (
|
|
143
|
+
<View ref={ref} className={calendarHeaderSelectStyle({ class: className })} {...props}>
|
|
144
|
+
<Menu
|
|
145
|
+
placement="bottom"
|
|
146
|
+
offset={4}
|
|
147
|
+
trigger={({ ...triggerProps }) => (
|
|
148
|
+
<Pressable {...triggerProps} className="px-2 py-1 rounded-md flex-row items-center">
|
|
149
|
+
<Text className="text-sm font-medium text-foreground">{label}</Text>
|
|
150
|
+
</Pressable>
|
|
151
|
+
)}
|
|
152
|
+
>
|
|
153
|
+
{items.map((item) => (
|
|
154
|
+
<MenuItem key={item.value} textValue={item.label} onPress={() => onValueChange?.(item.value)}>
|
|
155
|
+
<MenuItemLabel className={item.value === selectedValue ? 'text-primary font-semibold' : ''}>
|
|
156
|
+
{item.label}
|
|
157
|
+
</MenuItemLabel>
|
|
158
|
+
</MenuItem>
|
|
159
|
+
))}
|
|
160
|
+
</Menu>
|
|
161
|
+
</View>
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
);
|
|
192
165
|
|
|
193
166
|
// Styled Week Days Header
|
|
194
167
|
const CalendarWeekDaysHeaderRoot = React.forwardRef<
|
|
195
168
|
React.ElementRef<typeof View>,
|
|
196
169
|
React.ComponentProps<typeof View> & { className?: string }
|
|
197
170
|
>(({ className, ...props }, ref) => {
|
|
198
|
-
return (
|
|
199
|
-
<View
|
|
200
|
-
ref={ref}
|
|
201
|
-
className={calendarWeekDaysHeaderStyle({ class: className })}
|
|
202
|
-
{...props}
|
|
203
|
-
/>
|
|
204
|
-
);
|
|
171
|
+
return <View ref={ref} className={calendarWeekDaysHeaderStyle({ class: className })} {...props} />;
|
|
205
172
|
});
|
|
206
173
|
|
|
207
174
|
const CalendarWeekDayRoot = React.forwardRef<
|
|
@@ -209,15 +176,9 @@ const CalendarWeekDayRoot = React.forwardRef<
|
|
|
209
176
|
React.ComponentProps<typeof View> & { className?: string }
|
|
210
177
|
>(({ className, children, ...props }, ref) => {
|
|
211
178
|
return (
|
|
212
|
-
<View
|
|
213
|
-
ref={ref}
|
|
214
|
-
className={calendarWeekDayStyle({ class: className })}
|
|
215
|
-
{...props}
|
|
216
|
-
>
|
|
179
|
+
<View ref={ref} className={calendarWeekDayStyle({ class: className })} {...props}>
|
|
217
180
|
{typeof children === 'string' ? (
|
|
218
|
-
<Text className={calendarWeekDayTextStyle({ class: '' })}>
|
|
219
|
-
{children}
|
|
220
|
-
</Text>
|
|
181
|
+
<Text className={calendarWeekDayTextStyle({ class: '' })}>{children}</Text>
|
|
221
182
|
) : (
|
|
222
183
|
children
|
|
223
184
|
)}
|
|
@@ -230,46 +191,28 @@ const CalendarBodyRoot = React.forwardRef<
|
|
|
230
191
|
React.ElementRef<typeof View>,
|
|
231
192
|
React.ComponentProps<typeof View> & { className?: string }
|
|
232
193
|
>(({ className, ...props }, ref) => {
|
|
233
|
-
return (
|
|
234
|
-
<View
|
|
235
|
-
ref={ref}
|
|
236
|
-
className={calendarBodyStyle({ class: className })}
|
|
237
|
-
{...props}
|
|
238
|
-
/>
|
|
239
|
-
);
|
|
194
|
+
return <View ref={ref} className={calendarBodyStyle({ class: className })} {...props} />;
|
|
240
195
|
});
|
|
241
196
|
|
|
242
197
|
const CalendarGridRoot = React.forwardRef<
|
|
243
198
|
React.ElementRef<typeof View>,
|
|
244
199
|
React.ComponentProps<typeof View> & { className?: string }
|
|
245
200
|
>(({ className, ...props }, ref) => {
|
|
246
|
-
return (
|
|
247
|
-
<View
|
|
248
|
-
ref={ref}
|
|
249
|
-
className={calendarGridStyle({ class: className })}
|
|
250
|
-
{...props}
|
|
251
|
-
/>
|
|
252
|
-
);
|
|
201
|
+
return <View ref={ref} className={calendarGridStyle({ class: className })} {...props} />;
|
|
253
202
|
});
|
|
254
203
|
|
|
255
204
|
const CalendarWeekRoot = React.forwardRef<
|
|
256
205
|
React.ElementRef<typeof View>,
|
|
257
206
|
React.ComponentProps<typeof View> & { className?: string }
|
|
258
207
|
>(({ className, ...props }, ref) => {
|
|
259
|
-
return (
|
|
260
|
-
<View
|
|
261
|
-
ref={ref}
|
|
262
|
-
className={calendarWeekStyle({ class: className })}
|
|
263
|
-
{...props}
|
|
264
|
-
/>
|
|
265
|
-
);
|
|
208
|
+
return <View ref={ref} className={calendarWeekStyle({ class: className })} {...props} />;
|
|
266
209
|
});
|
|
267
210
|
|
|
268
211
|
// Styled Day
|
|
269
212
|
const CalendarDayRoot = React.forwardRef<
|
|
270
213
|
React.ElementRef<typeof Pressable>,
|
|
271
214
|
React.ComponentProps<typeof Pressable> & {
|
|
272
|
-
|
|
215
|
+
className?: string;
|
|
273
216
|
'data-state'?: string;
|
|
274
217
|
}
|
|
275
218
|
>(({ className, 'data-state': dataState, ...props }, ref) => {
|
|
@@ -319,7 +262,7 @@ const CalendarDayTextRoot = React.forwardRef<
|
|
|
319
262
|
const CalendarDayIndicatorRoot = React.forwardRef<
|
|
320
263
|
React.ElementRef<typeof View>,
|
|
321
264
|
React.ComponentProps<typeof View> & {
|
|
322
|
-
|
|
265
|
+
className?: string;
|
|
323
266
|
'data-type'?: string;
|
|
324
267
|
}
|
|
325
268
|
>(({ className, 'data-type': dataType, ...props }, ref) => {
|
|
@@ -341,15 +284,9 @@ const CalendarWeekNumberRoot = React.forwardRef<
|
|
|
341
284
|
React.ComponentProps<typeof View> & { className?: string }
|
|
342
285
|
>(({ className, children, ...props }, ref) => {
|
|
343
286
|
return (
|
|
344
|
-
<View
|
|
345
|
-
ref={ref}
|
|
346
|
-
className={calendarWeekNumberStyle({ class: className })}
|
|
347
|
-
{...props}
|
|
348
|
-
>
|
|
287
|
+
<View ref={ref} className={calendarWeekNumberStyle({ class: className })} {...props}>
|
|
349
288
|
{typeof children === 'string' || typeof children === 'number' ? (
|
|
350
|
-
<Text className={calendarWeekNumberTextStyle({ class: '' })}>
|
|
351
|
-
{children}
|
|
352
|
-
</Text>
|
|
289
|
+
<Text className={calendarWeekNumberTextStyle({ class: '' })}>{children}</Text>
|
|
353
290
|
) : (
|
|
354
291
|
children
|
|
355
292
|
)}
|
|
@@ -362,13 +299,7 @@ const CalendarFooterRoot = React.forwardRef<
|
|
|
362
299
|
React.ElementRef<typeof View>,
|
|
363
300
|
React.ComponentProps<typeof View> & { className?: string }
|
|
364
301
|
>(({ className, ...props }, ref) => {
|
|
365
|
-
return (
|
|
366
|
-
<View
|
|
367
|
-
ref={ref}
|
|
368
|
-
className={calendarFooterStyle({ class: className })}
|
|
369
|
-
{...props}
|
|
370
|
-
/>
|
|
371
|
-
);
|
|
302
|
+
return <View ref={ref} className={calendarFooterStyle({ class: className })} {...props} />;
|
|
372
303
|
});
|
|
373
304
|
|
|
374
305
|
// Create Calendar using the factory
|
|
@@ -423,10 +354,7 @@ type CalendarProps = (SingleModeProps | MultipleModeProps | RangeModeProps) &
|
|
|
423
354
|
className?: string;
|
|
424
355
|
};
|
|
425
356
|
|
|
426
|
-
const CalendarComponent = React.forwardRef<
|
|
427
|
-
React.ElementRef<typeof View>,
|
|
428
|
-
CalendarProps
|
|
429
|
-
>((props, ref) => {
|
|
357
|
+
const CalendarComponent = React.forwardRef<React.ElementRef<typeof View>, CalendarProps>((props, ref) => {
|
|
430
358
|
return <UICalendar ref={ref} {...(props as any)} />;
|
|
431
359
|
});
|
|
432
360
|
CalendarComponent.displayName = 'Calendar';
|
|
@@ -451,12 +379,6 @@ export const CalendarWeekNumber = UICalendar.WeekNumber;
|
|
|
451
379
|
export const CalendarFooter = UICalendar.Footer;
|
|
452
380
|
|
|
453
381
|
// Re-export types
|
|
454
|
-
export type {
|
|
455
|
-
ICalendarProps,
|
|
456
|
-
CalendarMode,
|
|
457
|
-
CalendarMarker,
|
|
458
|
-
CalendarMarkers,
|
|
459
|
-
DayState,
|
|
460
|
-
} from './creator';
|
|
382
|
+
export type { ICalendarProps, CalendarMode, CalendarMarker, CalendarMarkers, DayState } from './creator';
|
|
461
383
|
|
|
462
384
|
export type { CalendarProps };
|
|
@@ -70,10 +70,10 @@ export const calendarDayStyle = tva({
|
|
|
70
70
|
base: 'flex-1 aspect-square items-center justify-center rounded-md web:max-w-[2.25rem] relative transition-colors',
|
|
71
71
|
variants: {
|
|
72
72
|
state: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
default: 'hover:bg-accent active:bg-accent/80',
|
|
74
|
+
selected: 'bg-primary hover:bg-primary/90 active:bg-primary/80',
|
|
75
|
+
today: 'bg-accent',
|
|
76
|
+
disabled: 'opacity-40 cursor-not-allowed',
|
|
77
77
|
'outside-month': 'opacity-30',
|
|
78
78
|
'range-start': 'bg-primary rounded-r-md',
|
|
79
79
|
'range-end': 'bg-primary rounded-l-md',
|
|
@@ -86,10 +86,10 @@ export const calendarDayTextStyle = tva({
|
|
|
86
86
|
base: 'text-foreground text-sm font-normal z-10',
|
|
87
87
|
variants: {
|
|
88
88
|
state: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
default: 'text-foreground',
|
|
90
|
+
selected: 'text-primary-foreground ',
|
|
91
|
+
today: 'text-accent-foreground',
|
|
92
|
+
disabled: 'text-muted-foreground',
|
|
93
93
|
'outside-month': 'text-muted-foreground',
|
|
94
94
|
'range-start': 'text-primary-foreground font-semibold',
|
|
95
95
|
'range-end': 'text-primary-foreground font-semibold',
|
|
@@ -103,9 +103,9 @@ export const calendarDayIndicatorStyle = tva({
|
|
|
103
103
|
base: 'absolute bottom-1 flex-row gap-0.5 z-0',
|
|
104
104
|
variants: {
|
|
105
105
|
type: {
|
|
106
|
-
|
|
106
|
+
dot: 'flex-row gap-0.5',
|
|
107
107
|
'multi-dot': 'flex-row gap-0.5',
|
|
108
|
-
|
|
108
|
+
period: 'absolute inset-0 rounded-md opacity-20',
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
111
|
});
|
|
@@ -4,19 +4,18 @@ import { View } from 'react-native';
|
|
|
4
4
|
import { cardStyle } from './styles';
|
|
5
5
|
import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
6
6
|
|
|
7
|
-
type ICardProps = React.ComponentPropsWithoutRef<typeof View> &
|
|
8
|
-
VariantProps<typeof cardStyle> & {
|
|
7
|
+
type ICardProps = React.ComponentPropsWithoutRef<typeof View> &
|
|
8
|
+
VariantProps<typeof cardStyle> & {
|
|
9
9
|
className?: string;
|
|
10
10
|
size?: 'default' | 'sm';
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const Card = React.forwardRef<React.ComponentRef<typeof View>, ICardProps>(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
13
|
+
const Card = React.forwardRef<React.ComponentRef<typeof View>, ICardProps>(function Card(
|
|
14
|
+
{ className, size = 'default', ...props },
|
|
15
|
+
ref,
|
|
16
|
+
) {
|
|
17
|
+
return <View className={cardStyle({ size, class: className })} {...props} ref={ref} />;
|
|
18
|
+
});
|
|
20
19
|
|
|
21
20
|
Card.displayName = 'Card';
|
|
22
21
|
|
|
@@ -2,23 +2,17 @@ import React from 'react';
|
|
|
2
2
|
import { cardStyle } from './styles';
|
|
3
3
|
import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
4
4
|
|
|
5
|
-
type ICardProps = React.ComponentPropsWithoutRef<'div'> &
|
|
6
|
-
VariantProps<typeof cardStyle> & {
|
|
5
|
+
type ICardProps = React.ComponentPropsWithoutRef<'div'> &
|
|
6
|
+
VariantProps<typeof cardStyle> & {
|
|
7
7
|
className?: string;
|
|
8
8
|
size?: 'default' | 'sm';
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const Card = React.forwardRef<HTMLDivElement, ICardProps>(function Card(
|
|
12
12
|
{ className, size = 'default', ...props },
|
|
13
|
-
ref
|
|
13
|
+
ref,
|
|
14
14
|
) {
|
|
15
|
-
return (
|
|
16
|
-
<div
|
|
17
|
-
className={cardStyle({ size, class: className })}
|
|
18
|
-
{...props}
|
|
19
|
-
ref={ref}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
15
|
+
return <div className={cardStyle({ size, class: className })} {...props} ref={ref} />;
|
|
22
16
|
});
|
|
23
17
|
|
|
24
18
|
Card.displayName = 'Card';
|
|
@@ -5,17 +5,12 @@ import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
|
5
5
|
|
|
6
6
|
type ICenterProps = ViewProps & VariantProps<typeof centerStyle>;
|
|
7
7
|
|
|
8
|
-
const Center = React.forwardRef<React.ComponentRef<typeof View>, ICenterProps>(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ref={ref}
|
|
15
|
-
/>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
);
|
|
8
|
+
const Center = React.forwardRef<React.ComponentRef<typeof View>, ICenterProps>(function Center(
|
|
9
|
+
{ className, ...props },
|
|
10
|
+
ref,
|
|
11
|
+
) {
|
|
12
|
+
return <View className={centerStyle({ class: className })} {...props} ref={ref} />;
|
|
13
|
+
});
|
|
19
14
|
|
|
20
15
|
Center.displayName = 'Center';
|
|
21
16
|
|
|
@@ -3,16 +3,10 @@ import { centerStyle } from './styles';
|
|
|
3
3
|
|
|
4
4
|
import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
5
5
|
|
|
6
|
-
type ICenterProps = React.ComponentPropsWithoutRef<'div'> &
|
|
7
|
-
VariantProps<typeof centerStyle>;
|
|
6
|
+
type ICenterProps = React.ComponentPropsWithoutRef<'div'> & VariantProps<typeof centerStyle>;
|
|
8
7
|
|
|
9
|
-
const Center = React.forwardRef<HTMLDivElement, ICenterProps>(function Center(
|
|
10
|
-
{ className
|
|
11
|
-
ref
|
|
12
|
-
) {
|
|
13
|
-
return (
|
|
14
|
-
<div className={centerStyle({ class: className })} {...props} ref={ref} />
|
|
15
|
-
);
|
|
8
|
+
const Center = React.forwardRef<HTMLDivElement, ICenterProps>(function Center({ className, ...props }, ref) {
|
|
9
|
+
return <div className={centerStyle({ class: className })} {...props} ref={ref} />;
|
|
16
10
|
});
|
|
17
11
|
|
|
18
12
|
Center.displayName = 'Center';
|