@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.
- 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/index.tsx +4 -18
- package/components/ui/gluestack-ui-provider/index.web.tsx +10 -11
- package/components/ui/gluestack-ui-provider/script.ts +1 -3
- package/components/ui/gluestack-ui-provider/theme-context.ts +2 -2
- package/components/ui/gluestack-ui-provider/useGluestackColors.ts +2 -6
- 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/tools/design.js +15 -12
- package/design/tools/npm.js +4 -3
- package/dist/{chunk-B277QSR5.mjs → chunk-2R66P5X5.mjs} +1816 -3124
- package/dist/chunk-2R66P5X5.mjs.map +1 -0
- package/dist/{chunk-GD37RFBR.js → chunk-LCTFQJZM.js} +1816 -3124
- package/dist/chunk-LCTFQJZM.js.map +1 -0
- package/dist/index.js +294 -294
- package/dist/index.mjs +1 -1
- package/dist/ui/index.js +294 -294
- package/dist/ui/index.mjs +1 -1
- package/package.json +12 -7
- package/dist/chunk-B277QSR5.mjs.map +0 -1
- package/dist/chunk-GD37RFBR.js.map +0 -1
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { createButton } from '@gluestack-ui/core/button/creator';
|
|
4
|
-
import {
|
|
5
|
-
tva,
|
|
6
|
-
withStyleContext,
|
|
7
|
-
useStyleContext,
|
|
8
|
-
type VariantProps,
|
|
9
|
-
} from '@gluestack-ui/utils/nativewind-utils';
|
|
4
|
+
import { tva, withStyleContext, useStyleContext, type VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
10
5
|
import { cssInterop } from 'nativewind';
|
|
11
6
|
import { ActivityIndicator, Pressable, Text, View } from 'react-native';
|
|
12
7
|
import { UIIcon } from '@gluestack-ui/core/icon/creator';
|
|
@@ -35,15 +30,15 @@ const buttonStyle = tva({
|
|
|
35
30
|
base: 'rounded-md flex-row items-center justify-center data-[focus-visible=true]:web:outline-none data-[focus-visible=true]:web:ring-2 data-[disabled=true]:opacity-40 gap-2 h-fit',
|
|
36
31
|
variants: {
|
|
37
32
|
variant: {
|
|
38
|
-
default:
|
|
39
|
-
'bg-primary data-[hover=true]:bg-primary/90 data-[active=true]:bg-primary/90',
|
|
33
|
+
default: 'bg-primary data-[hover=true]:bg-primary/90 data-[active=true]:bg-primary/90',
|
|
40
34
|
destructive:
|
|
41
35
|
'bg-destructive data-[hover=true]:bg-destructive/90 data-[active=true]:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
42
36
|
outline:
|
|
43
37
|
'border border-border bg-background shadow-xs data-[hover=true]:bg-accent data-[active=true]:bg-accent dark:bg-input/[0.045] dark:border-border/90 dark:data-[hover=true]:bg-input/[0.075] dark:data-[active=true]:bg-input/[0.075]',
|
|
44
38
|
secondary:
|
|
45
39
|
'bg-secondary text-secondary-foreground data-[hover=true]:bg-secondary/80 data-[active=true]:bg-secondary/80',
|
|
46
|
-
ghost:
|
|
40
|
+
ghost:
|
|
41
|
+
'data-[hover=true]:bg-accent data-[active=true]:bg-accent dark:data-[hover=true]:bg-accent/50 dark:data-[active=true]:bg-accent/50',
|
|
47
42
|
link: 'text-primary underline-offset-4 data-[hover=true]:underline data-[active=true]:underline',
|
|
48
43
|
},
|
|
49
44
|
size: {
|
|
@@ -92,11 +87,9 @@ const buttonIconStyle = tva({
|
|
|
92
87
|
variant: {
|
|
93
88
|
default: 'text-primary-foreground',
|
|
94
89
|
destructive: 'text-white',
|
|
95
|
-
outline:
|
|
96
|
-
'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
90
|
+
outline: 'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
97
91
|
secondary: 'text-secondary-foreground',
|
|
98
|
-
ghost:
|
|
99
|
-
'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
92
|
+
ghost: 'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
100
93
|
link: 'text-primary',
|
|
101
94
|
},
|
|
102
95
|
size: {
|
|
@@ -111,11 +104,11 @@ const buttonGroupStyle = tva({
|
|
|
111
104
|
base: '',
|
|
112
105
|
variants: {
|
|
113
106
|
space: {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
xs: 'gap-1',
|
|
108
|
+
sm: 'gap-2',
|
|
109
|
+
md: 'gap-3',
|
|
110
|
+
lg: 'gap-4',
|
|
111
|
+
xl: 'gap-5',
|
|
119
112
|
'2xl': 'gap-6',
|
|
120
113
|
'3xl': 'gap-7',
|
|
121
114
|
'4xl': 'gap-8',
|
|
@@ -124,60 +117,61 @@ const buttonGroupStyle = tva({
|
|
|
124
117
|
true: 'gap-0',
|
|
125
118
|
},
|
|
126
119
|
flexDirection: {
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
row: 'flex-row',
|
|
121
|
+
column: 'flex-col',
|
|
129
122
|
'row-reverse': 'flex-row-reverse',
|
|
130
123
|
'column-reverse': 'flex-col-reverse',
|
|
131
124
|
},
|
|
132
125
|
},
|
|
133
126
|
});
|
|
134
|
-
type IButtonProps = Omit<
|
|
135
|
-
React.ComponentPropsWithoutRef<typeof UIButton>,
|
|
136
|
-
'context'
|
|
137
|
-
> &
|
|
127
|
+
type IButtonProps = Omit<React.ComponentPropsWithoutRef<typeof UIButton>, 'context'> &
|
|
138
128
|
VariantProps<typeof buttonStyle> & { className?: string };
|
|
139
|
-
const Button = React.forwardRef<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
129
|
+
const Button = React.forwardRef<React.ElementRef<typeof UIButton>, IButtonProps>(
|
|
130
|
+
({ className, variant = 'default', size = 'default', ...props }, ref) => {
|
|
131
|
+
return (
|
|
132
|
+
<UIButton
|
|
133
|
+
ref={ref}
|
|
134
|
+
{...props}
|
|
135
|
+
className={buttonStyle({ variant, size, class: className })}
|
|
136
|
+
context={{ variant, size }}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
);
|
|
152
141
|
type IButtonTextProps = React.ComponentPropsWithoutRef<typeof UIButton.Text> &
|
|
153
142
|
VariantProps<typeof buttonTextStyle> & { className?: string };
|
|
154
|
-
const ButtonText = React.forwardRef<
|
|
155
|
-
|
|
156
|
-
|
|
143
|
+
const ButtonText = React.forwardRef<React.ElementRef<typeof UIButton.Text>, IButtonTextProps>(
|
|
144
|
+
({ className, size, ...props }, ref) => {
|
|
145
|
+
const { size: parentSize, variant: parentVariant } = useStyleContext(SCOPE);
|
|
146
|
+
return (
|
|
147
|
+
<UIButton.Text
|
|
148
|
+
ref={ref}
|
|
149
|
+
{...props}
|
|
150
|
+
className={buttonTextStyle({
|
|
151
|
+
parentVariants: {
|
|
152
|
+
size: parentSize,
|
|
153
|
+
variant: parentVariant,
|
|
154
|
+
},
|
|
155
|
+
size,
|
|
156
|
+
class: className,
|
|
157
|
+
})}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
const ButtonSpinner = React.forwardRef<
|
|
163
|
+
React.ElementRef<typeof UIButton.Spinner>,
|
|
164
|
+
React.ComponentPropsWithoutRef<typeof UIButton.Spinner>
|
|
157
165
|
>(({ className, size, ...props }, ref) => {
|
|
158
|
-
const { size: parentSize
|
|
166
|
+
const { size: parentSize } = useStyleContext(SCOPE);
|
|
159
167
|
return (
|
|
160
|
-
<UIButton.
|
|
168
|
+
<UIButton.Spinner
|
|
161
169
|
ref={ref}
|
|
162
170
|
{...props}
|
|
163
|
-
className={
|
|
164
|
-
parentVariants: {
|
|
165
|
-
size: parentSize,
|
|
166
|
-
variant: parentVariant,
|
|
167
|
-
},
|
|
168
|
-
size,
|
|
169
|
-
class: className,
|
|
170
|
-
})}
|
|
171
|
+
className={buttonSpinnerStyle({ parentVariants: { size: parentSize }, class: className, size: size as any })}
|
|
171
172
|
/>
|
|
172
173
|
);
|
|
173
174
|
});
|
|
174
|
-
const ButtonSpinner = React.forwardRef<
|
|
175
|
-
React.ElementRef<typeof UIButton.Spinner>,
|
|
176
|
-
React.ComponentPropsWithoutRef<typeof UIButton.Spinner>
|
|
177
|
-
>(({ className, size, ...props }, ref) => {
|
|
178
|
-
const { size: parentSize } = useStyleContext(SCOPE);
|
|
179
|
-
return <UIButton.Spinner ref={ref} {...props} className={buttonSpinnerStyle({ parentVariants: { size: parentSize }, class: className, size: size as any })} />;
|
|
180
|
-
});
|
|
181
175
|
type IButtonIcon = React.ComponentPropsWithoutRef<typeof UIButton.Icon> &
|
|
182
176
|
VariantProps<typeof buttonIconStyle> & {
|
|
183
177
|
className?: string | undefined;
|
|
@@ -185,63 +179,33 @@ type IButtonIcon = React.ComponentPropsWithoutRef<typeof UIButton.Icon> &
|
|
|
185
179
|
height?: number;
|
|
186
180
|
width?: number;
|
|
187
181
|
};
|
|
188
|
-
const ButtonIcon = React.forwardRef<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
182
|
+
const ButtonIcon = React.forwardRef<React.ElementRef<typeof UIButton.Icon>, IButtonIcon>(
|
|
183
|
+
({ className, size, ...props }, ref) => {
|
|
184
|
+
const { size: parentSize, variant: parentVariant } = useStyleContext(SCOPE);
|
|
185
|
+
if (typeof size === 'number') {
|
|
186
|
+
return <UIButton.Icon ref={ref} {...props} className={buttonIconStyle({ class: className })} size={size} />;
|
|
187
|
+
} else if ((props.height !== undefined || props.width !== undefined) && size === undefined) {
|
|
188
|
+
return <UIButton.Icon ref={ref} {...props} className={buttonIconStyle({ class: className })} />;
|
|
189
|
+
}
|
|
194
190
|
return (
|
|
195
191
|
<UIButton.Icon
|
|
196
|
-
ref={ref}
|
|
197
192
|
{...props}
|
|
198
|
-
className={buttonIconStyle({
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<UIButton.Icon
|
|
193
|
+
className={buttonIconStyle({
|
|
194
|
+
parentVariants: {
|
|
195
|
+
size: parentSize,
|
|
196
|
+
variant: parentVariant,
|
|
197
|
+
},
|
|
198
|
+
size,
|
|
199
|
+
class: className,
|
|
200
|
+
})}
|
|
208
201
|
ref={ref}
|
|
209
|
-
{...props}
|
|
210
|
-
className={buttonIconStyle({ class: className })}
|
|
211
202
|
/>
|
|
212
203
|
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
parentVariants: {
|
|
219
|
-
size: parentSize,
|
|
220
|
-
variant: parentVariant,
|
|
221
|
-
},
|
|
222
|
-
size,
|
|
223
|
-
class: className,
|
|
224
|
-
})}
|
|
225
|
-
ref={ref}
|
|
226
|
-
/>
|
|
227
|
-
);
|
|
228
|
-
});
|
|
229
|
-
type IButtonGroupProps = React.ComponentPropsWithoutRef<typeof UIButton.Group> &
|
|
230
|
-
VariantProps<typeof buttonGroupStyle>;
|
|
231
|
-
const ButtonGroup = React.forwardRef<
|
|
232
|
-
React.ElementRef<typeof UIButton.Group>,
|
|
233
|
-
IButtonGroupProps
|
|
234
|
-
>(
|
|
235
|
-
(
|
|
236
|
-
{
|
|
237
|
-
className,
|
|
238
|
-
space = 'md',
|
|
239
|
-
isAttached = false,
|
|
240
|
-
flexDirection = 'column',
|
|
241
|
-
...props
|
|
242
|
-
},
|
|
243
|
-
ref
|
|
244
|
-
) => {
|
|
204
|
+
},
|
|
205
|
+
);
|
|
206
|
+
type IButtonGroupProps = React.ComponentPropsWithoutRef<typeof UIButton.Group> & VariantProps<typeof buttonGroupStyle>;
|
|
207
|
+
const ButtonGroup = React.forwardRef<React.ElementRef<typeof UIButton.Group>, IButtonGroupProps>(
|
|
208
|
+
({ className, space = 'md', isAttached = false, flexDirection = 'column', ...props }, ref) => {
|
|
245
209
|
return (
|
|
246
210
|
<UIButton.Group
|
|
247
211
|
className={buttonGroupStyle({
|
|
@@ -254,7 +218,7 @@ const ButtonGroup = React.forwardRef<
|
|
|
254
218
|
ref={ref}
|
|
255
219
|
/>
|
|
256
220
|
);
|
|
257
|
-
}
|
|
221
|
+
},
|
|
258
222
|
);
|
|
259
223
|
Button.displayName = 'Button';
|
|
260
224
|
ButtonText.displayName = 'ButtonText';
|
|
@@ -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
|