@avenue-ticketing/native 0.1.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 +9 -0
- package/dist/avatar.d.ts +75 -0
- package/dist/avatar.js +300 -0
- package/dist/avatar.js.map +1 -0
- package/dist/badge.d.ts +149 -0
- package/dist/badge.js +388 -0
- package/dist/badge.js.map +1 -0
- package/dist/button-group.d.ts +36 -0
- package/dist/button-group.js +186 -0
- package/dist/button-group.js.map +1 -0
- package/dist/button.d.ts +45 -0
- package/dist/button.js +357 -0
- package/dist/button.js.map +1 -0
- package/dist/checkbox.d.ts +31 -0
- package/dist/checkbox.js +212 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/date-picker.d.ts +50 -0
- package/dist/date-picker.js +755 -0
- package/dist/date-picker.js.map +1 -0
- package/dist/dialog.d.ts +62 -0
- package/dist/dialog.js +325 -0
- package/dist/dialog.js.map +1 -0
- package/dist/dropdown.d.ts +85 -0
- package/dist/dropdown.js +977 -0
- package/dist/dropdown.js.map +1 -0
- package/dist/input-group-addon-context.d.ts +10 -0
- package/dist/input-group-addon-context.js +9 -0
- package/dist/input-group-addon-context.js.map +1 -0
- package/dist/input.d.ts +325 -0
- package/dist/input.js +7890 -0
- package/dist/input.js.map +1 -0
- package/dist/radio.d.ts +34 -0
- package/dist/radio.js +177 -0
- package/dist/radio.js.map +1 -0
- package/dist/sheet.d.ts +67 -0
- package/dist/sheet.js +277 -0
- package/dist/sheet.js.map +1 -0
- package/dist/slider.d.ts +22 -0
- package/dist/slider.js +197 -0
- package/dist/slider.js.map +1 -0
- package/dist/tabs.d.ts +69 -0
- package/dist/tabs.js +379 -0
- package/dist/tabs.js.map +1 -0
- package/dist/textarea.d.ts +23 -0
- package/dist/textarea.js +176 -0
- package/dist/textarea.js.map +1 -0
- package/dist/toast.d.ts +32 -0
- package/dist/toast.js +140 -0
- package/dist/toast.js.map +1 -0
- package/dist/toggle.d.ts +31 -0
- package/dist/toggle.js +205 -0
- package/dist/toggle.js.map +1 -0
- package/dist/tooltip.d.ts +44 -0
- package/dist/tooltip.js +293 -0
- package/dist/tooltip.js.map +1 -0
- package/package.json +93 -0
- package/theme-dark.css +362 -0
- package/theme.css +161 -0
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
import { createContext, useMemo, useState, useRef, useCallback, isValidElement, useEffect, useContext } from 'react';
|
|
2
|
+
import { View, Pressable, Text } from 'react-native-css/components';
|
|
3
|
+
import { CaretLeftIcon } from 'phosphor-react-native/src/icons/CaretLeft';
|
|
4
|
+
import { CaretRightIcon } from 'phosphor-react-native/src/icons/CaretRight';
|
|
5
|
+
import { CalendarBlankIcon } from 'phosphor-react-native/src/icons/CalendarBlank';
|
|
6
|
+
import { useNativeVariable } from 'react-native-css';
|
|
7
|
+
import { extendTailwindMerge } from 'tailwind-merge';
|
|
8
|
+
import { Linking, useWindowDimensions, PanResponder, Modal } from 'react-native';
|
|
9
|
+
import { useInputGroupAddon } from '@avenue-ticketing/native/input-group-addon-context';
|
|
10
|
+
import Animated2, { Easing, useSharedValue, withRepeat, withTiming, useAnimatedStyle, runOnJS } from 'react-native-reanimated';
|
|
11
|
+
import Svg, { Path } from 'react-native-svg';
|
|
12
|
+
import { styled } from 'nativewind';
|
|
13
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
14
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
15
|
+
import 'phosphor-react-native/src/icons/ArrowLeft';
|
|
16
|
+
import { XIcon } from 'phosphor-react-native/src/icons/X';
|
|
17
|
+
|
|
18
|
+
// ../../native/components/application/date-picker/date-picker.tsx
|
|
19
|
+
var twMerge = extendTailwindMerge({
|
|
20
|
+
extend: {
|
|
21
|
+
theme: {
|
|
22
|
+
text: ["display-xs", "display-sm", "display-md", "display-lg", "display-xl", "display-2xl"]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var cx = twMerge;
|
|
27
|
+
function sortCx(classes) {
|
|
28
|
+
return classes;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ../core/src/date-picker.ts
|
|
32
|
+
function calendarCellClass(state) {
|
|
33
|
+
return cx(
|
|
34
|
+
"relative focus:outline-hidden",
|
|
35
|
+
state.fill ? "h-12 flex-1 items-center justify-center" : state.fluid ? "aspect-square w-full" : "size-10",
|
|
36
|
+
state.isRoundedLeft && "rounded-l-full",
|
|
37
|
+
state.isRoundedRight && "rounded-r-full",
|
|
38
|
+
state.isInRange && state.isDisabled && "bg-secondary",
|
|
39
|
+
state.isSelected && state.isRangeCalendar && "bg-secondary",
|
|
40
|
+
state.isDisabled ? "pointer-events-none" : "cursor-pointer",
|
|
41
|
+
state.isFocusVisible ? "z-10" : "z-0",
|
|
42
|
+
state.isOutsideMonth && "opacity-50",
|
|
43
|
+
state.isRangeCalendar && state.isOutsideMonth && !state.showOutOfRangeDates && "hidden",
|
|
44
|
+
state.isLastDayOfMonth && state.isSelected && state.isBeforeEnd && state.isRangeCalendar && "after:absolute after:inset-0 after:translate-x-full after:bg-gradient-to-l after:from-transparent after:to-bg-secondary in-[[role=gridcell]:last-child]:after:hidden",
|
|
45
|
+
state.isFirstDayOfMonth && state.isSelected && state.isAfterStart && state.isRangeCalendar && "after:absolute after:inset-0 after:-translate-x-full after:bg-gradient-to-r after:from-transparent after:to-bg-secondary in-[[role=gridcell]:first-child]:after:hidden"
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function calendarCellLabelClass(state) {
|
|
49
|
+
return cx(
|
|
50
|
+
"relative size-12 items-center justify-center rounded-full" ,
|
|
51
|
+
"text-sm text-secondary",
|
|
52
|
+
state.isDisabled && "text-secondary/50",
|
|
53
|
+
state.isFocusVisible ? "outline-2 outline-offset-2 outline-focus-ring" : "",
|
|
54
|
+
state.isSelected && !state.isDisabled && state.isRangeCalendar ? "font-medium" : "",
|
|
55
|
+
state.markedAsSelected && "bg-brand-solid font-medium text-white hover:bg-brand-solid_hover hover:text-white",
|
|
56
|
+
!state.isSelected && !state.isDisabled ? "hover:bg-primary_hover hover:font-medium!" : "",
|
|
57
|
+
!state.isSelected && state.isTodayDate ? "bg-secondary font-medium hover:bg-secondary_hover" : ""
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function calendarCellDotClass(markedAsSelected, isDisabled) {
|
|
61
|
+
return cx(
|
|
62
|
+
"absolute bottom-1 left-1/2 size-1.25 -translate-x-1/2 rounded-full",
|
|
63
|
+
markedAsSelected ? "bg-fg-white" : "bg-fg-brand-primary",
|
|
64
|
+
isDisabled
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
var calendarStyles = {
|
|
68
|
+
root: "flex-col gap-3",
|
|
69
|
+
header: "flex-row items-center justify-between",
|
|
70
|
+
heading: "text-sm font-semibold text-fg-secondary",
|
|
71
|
+
card: "rounded-2xl bg-primary",
|
|
72
|
+
cardBody: "px-6 py-5",
|
|
73
|
+
footer: "flex-row gap-3 border-t border-secondary p-4"
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// ../core/src/button.ts
|
|
77
|
+
function isLinkButtonColor(color) {
|
|
78
|
+
return color === "link-gray" || color === "link-color" || color === "link-destructive";
|
|
79
|
+
}
|
|
80
|
+
function isSolidSkeuomorphic(color) {
|
|
81
|
+
return color === "primary" || color === "brand" || color === "primary-destructive";
|
|
82
|
+
}
|
|
83
|
+
function isSecondarySkeuomorphic(color) {
|
|
84
|
+
return color === "secondary" || color === "secondary-destructive";
|
|
85
|
+
}
|
|
86
|
+
var BUTTON_ICON_SIZE_PX = {
|
|
87
|
+
xs: 16,
|
|
88
|
+
sm: 20,
|
|
89
|
+
md: 20,
|
|
90
|
+
lg: 20,
|
|
91
|
+
xl: 20
|
|
92
|
+
};
|
|
93
|
+
function resolveButtonIconSizePx(size, isIconOnly = false) {
|
|
94
|
+
if (size === "xl" && isIconOnly) return 24;
|
|
95
|
+
return BUTTON_ICON_SIZE_PX[size];
|
|
96
|
+
}
|
|
97
|
+
function resolveButtonIconSizeClass(size, isIconOnly = false) {
|
|
98
|
+
if (size === "xl" && isIconOnly) return "size-6";
|
|
99
|
+
if (size === "xs") return "size-4";
|
|
100
|
+
return "size-5";
|
|
101
|
+
}
|
|
102
|
+
var BUTTON_LOADING_SPINNER_PATH = "M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60,61.46,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20-66.54-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z";
|
|
103
|
+
var buttonStyles = sortCx({
|
|
104
|
+
common: {
|
|
105
|
+
// Avoid bare `flex` — NativeWind maps it like web (row) and can break parents.
|
|
106
|
+
root: "relative flex-row items-center justify-center overflow-visible rounded-full shrink-0",
|
|
107
|
+
icon: "shrink-0",
|
|
108
|
+
label: "shrink-0 font-semibold"
|
|
109
|
+
},
|
|
110
|
+
sizes: {
|
|
111
|
+
// Padding / height / gap match `buttonWebStyles.sizes` (web root).
|
|
112
|
+
xs: {
|
|
113
|
+
root: "h-8 min-h-8 gap-1 px-[0.625rem] py-1.5",
|
|
114
|
+
label: "text-sm",
|
|
115
|
+
iconOnly: "size-8 min-h-8 min-w-8 p-2"
|
|
116
|
+
},
|
|
117
|
+
sm: {
|
|
118
|
+
root: "h-9 min-h-9 gap-1 px-3 py-2",
|
|
119
|
+
label: "text-sm",
|
|
120
|
+
iconOnly: "size-9 min-h-9 min-w-9 p-2"
|
|
121
|
+
},
|
|
122
|
+
md: {
|
|
123
|
+
root: "h-10 min-h-10 gap-1 px-3.5 py-2.5",
|
|
124
|
+
label: "text-sm",
|
|
125
|
+
iconOnly: "size-10 min-h-10 min-w-10 p-2.5"
|
|
126
|
+
},
|
|
127
|
+
lg: {
|
|
128
|
+
root: "h-11 min-h-11 gap-1.5 px-4 py-2.5",
|
|
129
|
+
label: "text-md",
|
|
130
|
+
iconOnly: "size-11 min-h-11 min-w-11 p-3"
|
|
131
|
+
},
|
|
132
|
+
xl: {
|
|
133
|
+
root: "h-12 min-h-12 gap-1.5 px-[1.125rem] py-3",
|
|
134
|
+
label: "text-md",
|
|
135
|
+
iconOnly: "size-12 min-h-12 min-w-12 p-3"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
/** Web `disabled:opacity-30` (primary) / `disabled:opacity-50` (others). */
|
|
139
|
+
disabledOpacity: {
|
|
140
|
+
primary: "opacity-30",
|
|
141
|
+
brand: "opacity-50",
|
|
142
|
+
secondary: "opacity-50",
|
|
143
|
+
tertiary: "opacity-50",
|
|
144
|
+
"link-color": "opacity-50",
|
|
145
|
+
"link-gray": "opacity-50",
|
|
146
|
+
"primary-destructive": "opacity-50",
|
|
147
|
+
"secondary-destructive": "opacity-50",
|
|
148
|
+
"tertiary-destructive": "opacity-50",
|
|
149
|
+
"link-destructive": "opacity-50"
|
|
150
|
+
},
|
|
151
|
+
/** Native InputGroup addon — shell owns border/height; button is a flush inner segment. */
|
|
152
|
+
inputGroup: {
|
|
153
|
+
root: "h-auto min-h-0 self-stretch rounded-none border-0 bg-primary shadow-none overflow-hidden",
|
|
154
|
+
sm: "gap-1 px-3 py-2",
|
|
155
|
+
md: "gap-1 px-3.5 py-2.5",
|
|
156
|
+
lg: "gap-1.5 px-4 py-2.5",
|
|
157
|
+
xs: "gap-1 px-3 py-2",
|
|
158
|
+
xl: "gap-1.5 px-4 py-2.5"
|
|
159
|
+
},
|
|
160
|
+
colors: {
|
|
161
|
+
primary: {
|
|
162
|
+
root: "bg-primary-solid",
|
|
163
|
+
label: "text-white",
|
|
164
|
+
/** Web `*:data-icon:not([data-icon=loading]):text-white/70` */
|
|
165
|
+
icon: "text-white/70",
|
|
166
|
+
/** Loading icon inherits root `text-white`. */
|
|
167
|
+
spinner: "text-white"
|
|
168
|
+
},
|
|
169
|
+
brand: {
|
|
170
|
+
root: "bg-brand-solid",
|
|
171
|
+
label: "text-primary_on-brand",
|
|
172
|
+
icon: "text-primary_on-brand",
|
|
173
|
+
spinner: "text-primary_on-brand"
|
|
174
|
+
},
|
|
175
|
+
secondary: {
|
|
176
|
+
root: "border border-solid border-primary bg-primary",
|
|
177
|
+
label: "text-secondary",
|
|
178
|
+
icon: "text-fg-secondary",
|
|
179
|
+
spinner: "text-fg-secondary"
|
|
180
|
+
},
|
|
181
|
+
tertiary: {
|
|
182
|
+
root: "border border-transparent bg-transparent",
|
|
183
|
+
label: "text-tertiary",
|
|
184
|
+
icon: "text-fg-tertiary",
|
|
185
|
+
spinner: "text-fg-tertiary"
|
|
186
|
+
},
|
|
187
|
+
"link-color": {
|
|
188
|
+
// Web: underline decoration transparent until hover — native uses press underline.
|
|
189
|
+
root: "h-auto min-h-0 bg-transparent px-0 py-0",
|
|
190
|
+
label: "text-brand-secondary",
|
|
191
|
+
icon: "text-brand-secondary",
|
|
192
|
+
spinner: "text-brand-secondary"
|
|
193
|
+
},
|
|
194
|
+
"link-gray": {
|
|
195
|
+
root: "h-auto min-h-0 bg-transparent px-0 py-0",
|
|
196
|
+
label: "text-tertiary",
|
|
197
|
+
icon: "text-fg-tertiary",
|
|
198
|
+
spinner: "text-fg-tertiary"
|
|
199
|
+
},
|
|
200
|
+
"primary-destructive": {
|
|
201
|
+
root: "bg-error-solid",
|
|
202
|
+
label: "text-white",
|
|
203
|
+
icon: "text-white/70",
|
|
204
|
+
spinner: "text-white"
|
|
205
|
+
},
|
|
206
|
+
"secondary-destructive": {
|
|
207
|
+
root: "border border-solid border-primary bg-primary",
|
|
208
|
+
label: "text-error-primary",
|
|
209
|
+
icon: "text-fg-error-secondary",
|
|
210
|
+
spinner: "text-fg-error-secondary"
|
|
211
|
+
},
|
|
212
|
+
"tertiary-destructive": {
|
|
213
|
+
root: "border border-transparent bg-transparent",
|
|
214
|
+
label: "text-error-primary",
|
|
215
|
+
icon: "text-fg-error-secondary",
|
|
216
|
+
spinner: "text-fg-error-secondary"
|
|
217
|
+
},
|
|
218
|
+
"link-destructive": {
|
|
219
|
+
root: "h-auto min-h-0 bg-transparent px-0 py-0",
|
|
220
|
+
label: "text-error-primary",
|
|
221
|
+
icon: "text-error-primary",
|
|
222
|
+
spinner: "text-error-primary"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// ../core/src/is-react-component.ts
|
|
228
|
+
var isFunctionComponent = (component) => {
|
|
229
|
+
return typeof component === "function";
|
|
230
|
+
};
|
|
231
|
+
var isClassComponent = (component) => {
|
|
232
|
+
return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
|
|
233
|
+
};
|
|
234
|
+
var isForwardRefComponent = (component) => {
|
|
235
|
+
return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
|
|
236
|
+
};
|
|
237
|
+
var isReactComponent = (component) => {
|
|
238
|
+
return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// ../../native/components/base/buttons/button.styles.ts
|
|
242
|
+
var nativeButtonInteraction = sortCx({
|
|
243
|
+
root: "active:scale-[0.985]",
|
|
244
|
+
drop: "shadow-xs",
|
|
245
|
+
clip: "absolute inset-0 overflow-hidden rounded-full",
|
|
246
|
+
insetRing: "absolute inset-0 rounded-full border border-solid border-[rgba(0,0,0,0.18)]",
|
|
247
|
+
bottomWeight: "absolute inset-x-0 bottom-0 h-0.5 bg-[rgba(0,0,0,0.05)]",
|
|
248
|
+
topHighlight: "absolute left-px right-px top-px h-px bg-[rgba(255,255,255,0.12)]",
|
|
249
|
+
secondaryBottom: "absolute inset-x-0 bottom-0 h-px bg-[rgba(0,0,0,0.05)]",
|
|
250
|
+
colors: {
|
|
251
|
+
primary: "active:bg-fg-tertiary_hover",
|
|
252
|
+
brand: "active:bg-brand-solid_hover",
|
|
253
|
+
secondary: "active:bg-primary_hover",
|
|
254
|
+
tertiary: "active:bg-primary_hover",
|
|
255
|
+
// Web link hover: underline + color shift. RN uses press = hover.
|
|
256
|
+
"link-color": "active:opacity-80",
|
|
257
|
+
"link-gray": "active:opacity-80",
|
|
258
|
+
"primary-destructive": "active:bg-error-solid_hover",
|
|
259
|
+
"secondary-destructive": "active:bg-error-primary",
|
|
260
|
+
"tertiary-destructive": "active:bg-error-primary",
|
|
261
|
+
"link-destructive": "active:opacity-80"
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
function hasPressScale(color) {
|
|
265
|
+
return !isLinkButtonColor(color);
|
|
266
|
+
}
|
|
267
|
+
var StyledSvg = styled(Svg);
|
|
268
|
+
var ButtonSpinner = ({ className, size, showTextWhileLoading }) => {
|
|
269
|
+
const rotation = useSharedValue(0);
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
rotation.value = withRepeat(
|
|
272
|
+
withTiming(360, { duration: 1e3, easing: Easing.linear }),
|
|
273
|
+
-1,
|
|
274
|
+
false
|
|
275
|
+
);
|
|
276
|
+
}, [rotation]);
|
|
277
|
+
const spinStyle = useAnimatedStyle(() => ({
|
|
278
|
+
transform: [{ rotate: `${rotation.value}deg` }]
|
|
279
|
+
}));
|
|
280
|
+
return /* @__PURE__ */ jsx(
|
|
281
|
+
View,
|
|
282
|
+
{
|
|
283
|
+
pointerEvents: "none",
|
|
284
|
+
className: cx(
|
|
285
|
+
!showTextWhileLoading && "absolute inset-0 items-center justify-center"
|
|
286
|
+
),
|
|
287
|
+
children: /* @__PURE__ */ jsx(Animated2.View, { style: spinStyle, children: /* @__PURE__ */ jsx(
|
|
288
|
+
StyledSvg,
|
|
289
|
+
{
|
|
290
|
+
width: size,
|
|
291
|
+
height: size,
|
|
292
|
+
viewBox: "0 0 256 256",
|
|
293
|
+
accessibilityElementsHidden: true,
|
|
294
|
+
className,
|
|
295
|
+
children: /* @__PURE__ */ jsx(Path, { fill: "currentColor", d: BUTTON_LOADING_SPINNER_PATH })
|
|
296
|
+
}
|
|
297
|
+
) })
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
};
|
|
301
|
+
var Button = ({
|
|
302
|
+
size = "md",
|
|
303
|
+
color = "primary",
|
|
304
|
+
title,
|
|
305
|
+
children,
|
|
306
|
+
className,
|
|
307
|
+
noTextPadding,
|
|
308
|
+
iconLeading: IconLeading,
|
|
309
|
+
iconTrailing: IconTrailing,
|
|
310
|
+
isDisabled: disabled = false,
|
|
311
|
+
isLoading: loading = false,
|
|
312
|
+
showTextWhileLoading,
|
|
313
|
+
href,
|
|
314
|
+
onPress,
|
|
315
|
+
inInputGroup = false,
|
|
316
|
+
...props
|
|
317
|
+
}) => {
|
|
318
|
+
const inAddon = useInputGroupAddon();
|
|
319
|
+
const flattenInGroup = inInputGroup || inAddon;
|
|
320
|
+
const titleFromChildren = typeof children === "string" || typeof children === "number" ? String(children) : null;
|
|
321
|
+
const titleText = title ?? titleFromChildren;
|
|
322
|
+
const customChildren = titleText == null ? children : null;
|
|
323
|
+
const isIcon = Boolean((IconLeading || IconTrailing) && !titleText && !customChildren);
|
|
324
|
+
const isLinkType = isLinkButtonColor(color);
|
|
325
|
+
const padText = !(isLinkType || noTextPadding);
|
|
326
|
+
const isInactive = disabled || loading;
|
|
327
|
+
const showTitle = Boolean(titleText) && (!loading || showTextWhileLoading);
|
|
328
|
+
const iconSizePx = resolveButtonIconSizePx(size, isIcon);
|
|
329
|
+
const iconClassName = cx(
|
|
330
|
+
buttonStyles.common.icon,
|
|
331
|
+
resolveButtonIconSizeClass(size, isIcon),
|
|
332
|
+
buttonStyles.colors[color].icon
|
|
333
|
+
);
|
|
334
|
+
const LeadingIcon = isReactComponent(IconLeading) ? IconLeading : null;
|
|
335
|
+
const TrailingIcon = isReactComponent(IconTrailing) ? IconTrailing : null;
|
|
336
|
+
const handlePress = (event) => {
|
|
337
|
+
if (isInactive) return;
|
|
338
|
+
if (href) {
|
|
339
|
+
void Linking.openURL(href);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
onPress?.(event);
|
|
343
|
+
};
|
|
344
|
+
return /* @__PURE__ */ jsx(
|
|
345
|
+
Pressable,
|
|
346
|
+
{
|
|
347
|
+
accessibilityRole: "button",
|
|
348
|
+
accessibilityLabel: titleText ?? void 0,
|
|
349
|
+
accessibilityState: { disabled: isInactive, busy: loading },
|
|
350
|
+
disabled: isInactive,
|
|
351
|
+
onPress: handlePress,
|
|
352
|
+
className: cx(
|
|
353
|
+
buttonStyles.common.root,
|
|
354
|
+
flattenInGroup ? cx(buttonStyles.inputGroup.root, buttonStyles.inputGroup[size]) : cx(buttonStyles.sizes[size].root, isIcon && buttonStyles.sizes[size].iconOnly),
|
|
355
|
+
flattenInGroup ? "bg-primary" : buttonStyles.colors[color].root,
|
|
356
|
+
!flattenInGroup && hasPressScale(color) && nativeButtonInteraction.root,
|
|
357
|
+
!flattenInGroup && (isSolidSkeuomorphic(color) || isSecondarySkeuomorphic(color)) && nativeButtonInteraction.drop,
|
|
358
|
+
nativeButtonInteraction.colors[color],
|
|
359
|
+
isLinkType && "h-auto min-h-0 px-0 py-0",
|
|
360
|
+
// Web applies disabled opacity only when disabled — not while loading.
|
|
361
|
+
disabled && buttonStyles.disabledOpacity[color],
|
|
362
|
+
className
|
|
363
|
+
),
|
|
364
|
+
...props,
|
|
365
|
+
children: ({ pressed }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
366
|
+
!flattenInGroup && isSolidSkeuomorphic(color) && /* @__PURE__ */ jsxs(View, { pointerEvents: "none", className: nativeButtonInteraction.clip, children: [
|
|
367
|
+
/* @__PURE__ */ jsx(View, { className: nativeButtonInteraction.insetRing }),
|
|
368
|
+
/* @__PURE__ */ jsx(View, { className: nativeButtonInteraction.bottomWeight }),
|
|
369
|
+
/* @__PURE__ */ jsx(View, { className: nativeButtonInteraction.topHighlight })
|
|
370
|
+
] }),
|
|
371
|
+
!flattenInGroup && isSecondarySkeuomorphic(color) && /* @__PURE__ */ jsx(View, { pointerEvents: "none", className: nativeButtonInteraction.clip, children: /* @__PURE__ */ jsx(View, { className: nativeButtonInteraction.secondaryBottom }) }),
|
|
372
|
+
isValidElement(IconLeading) && !loading && IconLeading,
|
|
373
|
+
LeadingIcon && !loading && /* @__PURE__ */ jsx(LeadingIcon, { className: iconClassName, size: iconSizePx }),
|
|
374
|
+
loading && /* @__PURE__ */ jsx(
|
|
375
|
+
ButtonSpinner,
|
|
376
|
+
{
|
|
377
|
+
className: buttonStyles.colors[color].spinner,
|
|
378
|
+
size: iconSizePx,
|
|
379
|
+
showTextWhileLoading
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
showTitle && /* @__PURE__ */ jsx(
|
|
383
|
+
Text,
|
|
384
|
+
{
|
|
385
|
+
numberOfLines: 1,
|
|
386
|
+
className: cx(
|
|
387
|
+
buttonStyles.common.label,
|
|
388
|
+
buttonStyles.sizes[size].label,
|
|
389
|
+
buttonStyles.colors[color].label,
|
|
390
|
+
// Web link: transparent underline until hover — press ≈ hover on RN.
|
|
391
|
+
isLinkType && pressed && "underline",
|
|
392
|
+
padText && !isLinkType && "px-0.5",
|
|
393
|
+
loading && !showTextWhileLoading && "opacity-0"
|
|
394
|
+
),
|
|
395
|
+
children: titleText
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
!loading && customChildren,
|
|
399
|
+
isValidElement(IconTrailing) && !loading && IconTrailing,
|
|
400
|
+
TrailingIcon && !loading && /* @__PURE__ */ jsx(TrailingIcon, { className: iconClassName, size: iconSizePx })
|
|
401
|
+
] })
|
|
402
|
+
}
|
|
403
|
+
);
|
|
404
|
+
};
|
|
405
|
+
Button.displayName = "Button";
|
|
406
|
+
|
|
407
|
+
// ../core/src/sheet.ts
|
|
408
|
+
var SHEET_VELOCITY_THRESHOLD = 1;
|
|
409
|
+
var SHEET_PANEL_OPEN_MS = 280;
|
|
410
|
+
var SHEET_PANEL_CLOSE_MS_MOBILE = 220;
|
|
411
|
+
var SHEET_HANDOFF_AFTER_CLOSE_DELAY_MS = 80;
|
|
412
|
+
var SHEET_PANEL_OPEN_EASING_BEZIER = [0, 0.55, 0.45, 1];
|
|
413
|
+
var SHEET_PANEL_CLOSE_EASING_BEZIER = [0.55, 0, 1, 0.45];
|
|
414
|
+
var sheetStyles = sortCx({
|
|
415
|
+
boundary: "relative min-h-0 min-w-0",
|
|
416
|
+
close: "size-12 items-center justify-center rounded-full bg-primary active:scale-[0.96] active:bg-primary_hover",
|
|
417
|
+
panel: "bg-primary p-6",
|
|
418
|
+
header: "flex-col",
|
|
419
|
+
headerFixed: "border-b border-secondary bg-primary p-4",
|
|
420
|
+
footer: "flex-row",
|
|
421
|
+
footerFixed: "border-t border-secondary bg-primary p-4",
|
|
422
|
+
title: "text-lg font-semibold text-primary",
|
|
423
|
+
description: "text-sm text-tertiary",
|
|
424
|
+
nestedClose: "size-12 shrink-0 items-center justify-center rounded-full bg-primary active:scale-[0.96] active:bg-primary_hover"
|
|
425
|
+
});
|
|
426
|
+
var SheetContext = createContext(void 0);
|
|
427
|
+
function useSheetContext() {
|
|
428
|
+
const ctx = useContext(SheetContext);
|
|
429
|
+
if (!ctx) throw new Error("Sheet components must be used within a <Sheet />");
|
|
430
|
+
return ctx;
|
|
431
|
+
}
|
|
432
|
+
var OPEN_EASING = Easing.bezier(...SHEET_PANEL_OPEN_EASING_BEZIER);
|
|
433
|
+
var CLOSE_EASING = Easing.bezier(...SHEET_PANEL_CLOSE_EASING_BEZIER);
|
|
434
|
+
var Sheet = ({ children, open: controlledOpen, onOpenChange, showBackdrop = false }) => {
|
|
435
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
436
|
+
const isControlled = controlledOpen !== void 0;
|
|
437
|
+
const open = isControlled ? controlledOpen : internalOpen;
|
|
438
|
+
const afterCloseRef = useRef(null);
|
|
439
|
+
const setOpen = useCallback(
|
|
440
|
+
(value2, options) => {
|
|
441
|
+
if (!value2 && options?.afterClose) afterCloseRef.current = options.afterClose;
|
|
442
|
+
if (value2) afterCloseRef.current = null;
|
|
443
|
+
if (!isControlled) setInternalOpen(value2);
|
|
444
|
+
onOpenChange?.(value2);
|
|
445
|
+
if (!value2 && options?.afterClose) {
|
|
446
|
+
const cb = options.afterClose;
|
|
447
|
+
setTimeout(() => {
|
|
448
|
+
cb();
|
|
449
|
+
afterCloseRef.current = null;
|
|
450
|
+
}, SHEET_HANDOFF_AFTER_CLOSE_DELAY_MS);
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
[isControlled, onOpenChange]
|
|
454
|
+
);
|
|
455
|
+
const value = useMemo(() => ({ open, setOpen, showBackdrop }), [open, setOpen, showBackdrop]);
|
|
456
|
+
return /* @__PURE__ */ jsx(SheetContext.Provider, { value, children });
|
|
457
|
+
};
|
|
458
|
+
var SheetCloseButton = ({ className, onPress }) => {
|
|
459
|
+
const { setOpen } = useSheetContext();
|
|
460
|
+
const fgPrimary = useNativeVariable("--color-fg-primary") ?? "#181d27";
|
|
461
|
+
return /* @__PURE__ */ jsx(
|
|
462
|
+
Pressable,
|
|
463
|
+
{
|
|
464
|
+
accessibilityRole: "button",
|
|
465
|
+
accessibilityLabel: "Close",
|
|
466
|
+
onPress: onPress ?? (() => setOpen(false)),
|
|
467
|
+
className: cx(sheetStyles.close, className),
|
|
468
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: 22, weight: "regular", color: fgPrimary })
|
|
469
|
+
}
|
|
470
|
+
);
|
|
471
|
+
};
|
|
472
|
+
var SheetPanel = ({ side, size, className, duration, swipeEnabled, showClose, elevated, children }) => {
|
|
473
|
+
const { open, setOpen, showBackdrop } = useSheetContext();
|
|
474
|
+
const { width: windowWidth, height: windowHeight } = useWindowDimensions();
|
|
475
|
+
const insets = useSafeAreaInsets();
|
|
476
|
+
const bgPrimary = useNativeVariable("--color-bg-primary") ?? "#ffffff";
|
|
477
|
+
const borderSecondary = useNativeVariable("--color-border-secondary") ?? "#e9eaeb";
|
|
478
|
+
const overlayColor = useNativeVariable("--color-bg-overlay") ?? "#0a0d12";
|
|
479
|
+
const [mounted, setMounted] = useState(open);
|
|
480
|
+
const horizontal = side === "left" || side === "right";
|
|
481
|
+
const full = size === "full";
|
|
482
|
+
const customWidth = /(?:^|\s)(?:w-|max-w-)/.test(className ?? "");
|
|
483
|
+
const customHeight = /(?:^|\s)(?:h-|max-h-)/.test(className ?? "");
|
|
484
|
+
const travel = horizontal ? windowWidth : windowHeight;
|
|
485
|
+
const offset = useSharedValue(open ? 0 : travel);
|
|
486
|
+
const swipeClosing = useRef(false);
|
|
487
|
+
const finishSwipeClose = useCallback(() => {
|
|
488
|
+
swipeClosing.current = false;
|
|
489
|
+
setMounted(false);
|
|
490
|
+
setOpen(false);
|
|
491
|
+
}, [setOpen]);
|
|
492
|
+
useEffect(() => {
|
|
493
|
+
if (open) {
|
|
494
|
+
swipeClosing.current = false;
|
|
495
|
+
setMounted(true);
|
|
496
|
+
offset.value = withTiming(0, { duration, easing: OPEN_EASING });
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (swipeClosing.current) return;
|
|
500
|
+
offset.value = withTiming(travel, { duration: SHEET_PANEL_CLOSE_MS_MOBILE, easing: CLOSE_EASING }, (finished) => {
|
|
501
|
+
if (finished) runOnJS(setMounted)(false);
|
|
502
|
+
});
|
|
503
|
+
}, [open, duration, offset, travel]);
|
|
504
|
+
const edgePan = useMemo(
|
|
505
|
+
() => PanResponder.create({
|
|
506
|
+
onStartShouldSetPanResponder: () => swipeEnabled && horizontal,
|
|
507
|
+
onMoveShouldSetPanResponder: () => swipeEnabled && horizontal,
|
|
508
|
+
onPanResponderMove: (_evt, gesture) => {
|
|
509
|
+
const raw = side === "right" ? gesture.dx : -gesture.dx;
|
|
510
|
+
offset.value = Math.min(Math.max(raw, 0), travel);
|
|
511
|
+
},
|
|
512
|
+
onPanResponderRelease: (_evt, gesture) => {
|
|
513
|
+
const raw = side === "right" ? gesture.dx : -gesture.dx;
|
|
514
|
+
const velocity = side === "right" ? gesture.vx : -gesture.vx;
|
|
515
|
+
const shouldClose = raw > travel * 0.35 || raw > 40 && velocity > SHEET_VELOCITY_THRESHOLD;
|
|
516
|
+
if (shouldClose) {
|
|
517
|
+
swipeClosing.current = true;
|
|
518
|
+
offset.value = withTiming(travel, { duration: SHEET_PANEL_CLOSE_MS_MOBILE, easing: CLOSE_EASING }, (finished) => {
|
|
519
|
+
if (finished) runOnJS(finishSwipeClose)();
|
|
520
|
+
});
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
offset.value = withTiming(0, { duration, easing: OPEN_EASING });
|
|
524
|
+
},
|
|
525
|
+
onPanResponderTerminate: () => {
|
|
526
|
+
offset.value = withTiming(0, { duration, easing: OPEN_EASING });
|
|
527
|
+
}
|
|
528
|
+
}),
|
|
529
|
+
[swipeEnabled, horizontal, side, offset, travel, duration, finishSwipeClose]
|
|
530
|
+
);
|
|
531
|
+
const panelStyle = useAnimatedStyle(() => {
|
|
532
|
+
const translateX = side === "right" ? offset.value : side === "left" ? -offset.value : 0;
|
|
533
|
+
const translateY = side === "bottom" ? offset.value : side === "top" ? -offset.value : 0;
|
|
534
|
+
return { transform: [{ translateX }, { translateY }] };
|
|
535
|
+
});
|
|
536
|
+
const backdropStyle = useAnimatedStyle(() => ({
|
|
537
|
+
opacity: travel > 0 ? 0.4 * (1 - offset.value / travel) : 0
|
|
538
|
+
}));
|
|
539
|
+
if (!mounted) return null;
|
|
540
|
+
const edge = side === "right" ? { right: 0, top: 0, bottom: 0, borderLeftWidth: customWidth ? 1 : 0 } : side === "left" ? { left: 0, top: 0, bottom: 0, borderRightWidth: customWidth ? 1 : 0 } : side === "bottom" ? { left: 0, right: 0, bottom: 0, borderTopWidth: customHeight ? 1 : 0 } : { left: 0, right: 0, top: 0, borderBottomWidth: customHeight ? 1 : 0 };
|
|
541
|
+
return /* @__PURE__ */ jsx(Modal, { visible: true, transparent: true, animationType: "none", presentationStyle: "overFullScreen", statusBarTranslucent: true, onRequestClose: () => setOpen(false), children: /* @__PURE__ */ jsxs(View, { className: "h-full w-full flex-1", children: [
|
|
542
|
+
showBackdrop && !full && /* @__PURE__ */ jsx(Animated2.View, { style: [{ position: "absolute", top: 0, right: 0, bottom: 0, left: 0, backgroundColor: overlayColor }, backdropStyle], children: /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss", onPress: () => setOpen(false), className: "flex-1" }) }),
|
|
543
|
+
/* @__PURE__ */ jsx(
|
|
544
|
+
Animated2.View,
|
|
545
|
+
{
|
|
546
|
+
style: [
|
|
547
|
+
panelStyle,
|
|
548
|
+
{
|
|
549
|
+
position: "absolute",
|
|
550
|
+
width: customWidth ? void 0 : windowWidth,
|
|
551
|
+
height: customHeight ? void 0 : windowHeight,
|
|
552
|
+
backgroundColor: bgPrimary,
|
|
553
|
+
borderColor: borderSecondary,
|
|
554
|
+
zIndex: 10,
|
|
555
|
+
...elevated ? {
|
|
556
|
+
shadowColor: "#000000",
|
|
557
|
+
shadowOffset: {
|
|
558
|
+
width: side === "right" ? -12 : side === "left" ? 12 : 0,
|
|
559
|
+
height: side === "bottom" ? -12 : side === "top" ? 12 : 0
|
|
560
|
+
},
|
|
561
|
+
shadowOpacity: 0.16,
|
|
562
|
+
shadowRadius: 24,
|
|
563
|
+
elevation: 16
|
|
564
|
+
} : { elevation: 0 },
|
|
565
|
+
paddingTop: insets.top,
|
|
566
|
+
paddingBottom: insets.bottom,
|
|
567
|
+
...edge
|
|
568
|
+
}
|
|
569
|
+
],
|
|
570
|
+
children: /* @__PURE__ */ jsxs(View, { className: cx(sheetStyles.panel, "flex-1", className), children: [
|
|
571
|
+
children,
|
|
572
|
+
showClose && /* @__PURE__ */ jsx(View, { className: "absolute top-4 right-4 z-20", children: /* @__PURE__ */ jsx(SheetCloseButton, {}) })
|
|
573
|
+
] })
|
|
574
|
+
}
|
|
575
|
+
),
|
|
576
|
+
swipeEnabled && horizontal && /* @__PURE__ */ jsx(
|
|
577
|
+
View,
|
|
578
|
+
{
|
|
579
|
+
...edgePan.panHandlers,
|
|
580
|
+
style: {
|
|
581
|
+
position: "absolute",
|
|
582
|
+
top: 0,
|
|
583
|
+
bottom: 0,
|
|
584
|
+
width: 28,
|
|
585
|
+
zIndex: 40,
|
|
586
|
+
...side === "right" ? { left: 0 } : { right: 0 }
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
)
|
|
590
|
+
] }) });
|
|
591
|
+
};
|
|
592
|
+
var SheetContent = ({ children, side = "right", size = "md", className, swipeEnabled = true, showClose = true, elevated = true, duration = SHEET_PANEL_OPEN_MS }) => {
|
|
593
|
+
return /* @__PURE__ */ jsx(SheetPanel, { side, size, className, duration, swipeEnabled, showClose, elevated, children });
|
|
594
|
+
};
|
|
595
|
+
var WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
596
|
+
function keyOf(date) {
|
|
597
|
+
return `${date.year}-${date.month}-${date.day}`;
|
|
598
|
+
}
|
|
599
|
+
function todayDate() {
|
|
600
|
+
const now = /* @__PURE__ */ new Date();
|
|
601
|
+
return { year: now.getFullYear(), month: now.getMonth(), day: now.getDate() };
|
|
602
|
+
}
|
|
603
|
+
function formatDate(date) {
|
|
604
|
+
if (!date) return "Select date";
|
|
605
|
+
return new Date(date.year, date.month, date.day).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
|
|
606
|
+
}
|
|
607
|
+
function monthCells(year, month) {
|
|
608
|
+
const first = new Date(year, month, 1).getDay();
|
|
609
|
+
const count = new Date(year, month + 1, 0).getDate();
|
|
610
|
+
const cells = [];
|
|
611
|
+
const prevCount = new Date(year, month, 0).getDate();
|
|
612
|
+
for (let i = 0; i < first; i++) {
|
|
613
|
+
const day = prevCount - first + 1 + i;
|
|
614
|
+
const prev = new Date(year, month - 1, day);
|
|
615
|
+
cells.push({ date: { year: prev.getFullYear(), month: prev.getMonth(), day: prev.getDate() }, outside: true });
|
|
616
|
+
}
|
|
617
|
+
for (let day = 1; day <= count; day++) cells.push({ date: { year, month, day }, outside: false });
|
|
618
|
+
while (cells.length % 7 !== 0) {
|
|
619
|
+
const next = new Date(year, month + 1, cells.length - (first + count) + 1);
|
|
620
|
+
cells.push({ date: { year: next.getFullYear(), month: next.getMonth(), day: next.getDate() }, outside: true });
|
|
621
|
+
}
|
|
622
|
+
return cells;
|
|
623
|
+
}
|
|
624
|
+
function compare(a, b) {
|
|
625
|
+
if (a.year !== b.year) return a.year - b.year;
|
|
626
|
+
if (a.month !== b.month) return a.month - b.month;
|
|
627
|
+
return a.day - b.day;
|
|
628
|
+
}
|
|
629
|
+
var Calendar = ({ value, onChange, range, onRangeChange }) => {
|
|
630
|
+
const today = useMemo(todayDate, []);
|
|
631
|
+
const [cursor, setCursor] = useState({ year: (value ?? range?.start ?? today).year, month: (value ?? range?.start ?? today).month });
|
|
632
|
+
const [selected, setSelected] = useState(value ?? null);
|
|
633
|
+
const [selectedRange, setSelectedRange] = useState(range ?? { start: null, end: null });
|
|
634
|
+
const fg = useNativeVariable("--color-fg-secondary") ?? "#414651";
|
|
635
|
+
const cells = monthCells(cursor.year, cursor.month);
|
|
636
|
+
const title = new Date(cursor.year, cursor.month, 1).toLocaleDateString(void 0, { month: "long", year: "numeric" });
|
|
637
|
+
const active = onChange ? value ?? selected : selected;
|
|
638
|
+
const activeRange = onRangeChange && range ? range : selectedRange;
|
|
639
|
+
const select = (date) => {
|
|
640
|
+
if (onRangeChange || range) {
|
|
641
|
+
const current = activeRange ?? { start: null, end: null };
|
|
642
|
+
const next = !current.start || current.start && current.end ? { start: date, end: null } : compare(date, current.start) < 0 ? { start: date, end: current.start } : { start: current.start, end: date };
|
|
643
|
+
setSelectedRange(next);
|
|
644
|
+
onRangeChange?.(next);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
setSelected(date);
|
|
648
|
+
onChange?.(date);
|
|
649
|
+
};
|
|
650
|
+
return /* @__PURE__ */ jsxs(View, { className: calendarStyles.root, children: [
|
|
651
|
+
/* @__PURE__ */ jsxs(View, { className: calendarStyles.header, children: [
|
|
652
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Previous month", onPress: () => setCursor((current) => ({ year: current.month === 0 ? current.year - 1 : current.year, month: current.month === 0 ? 11 : current.month - 1 })), className: "size-8 items-center justify-center", children: /* @__PURE__ */ jsx(CaretLeftIcon, { size: 16, color: fg }) }),
|
|
653
|
+
/* @__PURE__ */ jsx(Text, { className: calendarStyles.heading, children: title }),
|
|
654
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Next month", onPress: () => setCursor((current) => ({ year: current.month === 11 ? current.year + 1 : current.year, month: current.month === 11 ? 0 : current.month + 1 })), className: "size-8 items-center justify-center", children: /* @__PURE__ */ jsx(CaretRightIcon, { size: 16, color: fg }) })
|
|
655
|
+
] }),
|
|
656
|
+
/* @__PURE__ */ jsx(View, { className: "w-full flex-row", children: WEEKDAYS.map((day) => /* @__PURE__ */ jsx(View, { className: "h-12 flex-1 items-center justify-center", children: /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-secondary", children: day }) }, day)) }),
|
|
657
|
+
Array.from({ length: cells.length / 7 }, (_, row) => cells.slice(row * 7, row * 7 + 7)).map((week) => /* @__PURE__ */ jsx(View, { className: "w-full flex-row", children: week.map(({ date, outside }) => {
|
|
658
|
+
const selectedDay = active != null && keyOf(active) === keyOf(date);
|
|
659
|
+
const start = activeRange?.start != null && keyOf(activeRange.start) === keyOf(date);
|
|
660
|
+
const end = activeRange?.end != null && keyOf(activeRange.end) === keyOf(date);
|
|
661
|
+
const inRange = Boolean(activeRange?.start && activeRange.end && compare(date, activeRange.start) > 0 && compare(date, activeRange.end) < 0);
|
|
662
|
+
const isTodayDate = keyOf(date) === keyOf(today);
|
|
663
|
+
const marked = selectedDay || start || end;
|
|
664
|
+
const weekday = new Date(date.year, date.month, date.day).getDay();
|
|
665
|
+
const isRangeCalendar = Boolean(onRangeChange || range);
|
|
666
|
+
return /* @__PURE__ */ jsx(
|
|
667
|
+
Pressable,
|
|
668
|
+
{
|
|
669
|
+
accessibilityRole: "button",
|
|
670
|
+
onPress: () => select(date),
|
|
671
|
+
className: calendarCellClass({
|
|
672
|
+
fill: true,
|
|
673
|
+
isRoundedLeft: start || weekday === 0,
|
|
674
|
+
isRoundedRight: end || weekday === 6,
|
|
675
|
+
isInRange: inRange,
|
|
676
|
+
isSelected: inRange || start || end || selectedDay,
|
|
677
|
+
isRangeCalendar,
|
|
678
|
+
isOutsideMonth: outside,
|
|
679
|
+
showOutOfRangeDates: true
|
|
680
|
+
}),
|
|
681
|
+
children: /* @__PURE__ */ jsxs(View, { className: calendarCellLabelClass({ markedAsSelected: marked, isTodayDate, isSelected: inRange || start || end || selectedDay, isRangeCalendar }), children: [
|
|
682
|
+
/* @__PURE__ */ jsx(Text, { className: cx("text-sm", marked ? "font-medium text-white" : "text-secondary", isTodayDate && !marked && "font-medium"), children: date.day }),
|
|
683
|
+
isTodayDate && /* @__PURE__ */ jsx(View, { className: calendarCellDotClass(marked) })
|
|
684
|
+
] })
|
|
685
|
+
},
|
|
686
|
+
keyOf(date) + String(outside)
|
|
687
|
+
);
|
|
688
|
+
}) }, keyOf(week[0].date)))
|
|
689
|
+
] });
|
|
690
|
+
};
|
|
691
|
+
var PickerChrome = ({ title }) => {
|
|
692
|
+
return /* @__PURE__ */ jsxs(View, { className: "w-full flex-row items-center justify-between gap-3 py-2 pr-2 pl-4", children: [
|
|
693
|
+
/* @__PURE__ */ jsx(Text, { className: "min-w-0 flex-1 text-base font-semibold text-primary", numberOfLines: 1, children: title }),
|
|
694
|
+
/* @__PURE__ */ jsx(SheetCloseButton, {})
|
|
695
|
+
] });
|
|
696
|
+
};
|
|
697
|
+
var DatePicker = ({ value: valueProp, defaultValue = null, onChange }) => {
|
|
698
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
699
|
+
const [open, setOpen] = useState(false);
|
|
700
|
+
const [draft, setDraft] = useState(valueProp ?? internal);
|
|
701
|
+
const value = valueProp !== void 0 ? valueProp : internal;
|
|
702
|
+
return /* @__PURE__ */ jsxs(Sheet, { open, onOpenChange: setOpen, children: [
|
|
703
|
+
/* @__PURE__ */ jsx(Button, { color: "secondary", iconLeading: CalendarBlankIcon, onPress: () => {
|
|
704
|
+
setDraft(value);
|
|
705
|
+
setOpen(true);
|
|
706
|
+
}, children: formatDate(value) }),
|
|
707
|
+
/* @__PURE__ */ jsxs(SheetContent, { side: "bottom", size: "full", elevated: false, swipeEnabled: false, showClose: false, className: "flex-1 flex-col justify-between p-0", children: [
|
|
708
|
+
/* @__PURE__ */ jsx(PickerChrome, { title: "Select date" }),
|
|
709
|
+
/* @__PURE__ */ jsx(View, { className: "min-h-0 w-full flex-1 px-4 pt-1 pb-4", children: /* @__PURE__ */ jsx(Calendar, { value: draft, onChange: setDraft }) }),
|
|
710
|
+
/* @__PURE__ */ jsxs(View, { className: "w-full flex-row gap-3 border-t border-secondary p-4", children: [
|
|
711
|
+
/* @__PURE__ */ jsx(Button, { color: "secondary", className: "flex-1", onPress: () => setOpen(false), children: "Cancel" }),
|
|
712
|
+
/* @__PURE__ */ jsx(Button, { className: "flex-1", onPress: () => {
|
|
713
|
+
if (valueProp === void 0) setInternal(draft);
|
|
714
|
+
onChange?.(draft);
|
|
715
|
+
setOpen(false);
|
|
716
|
+
}, children: "Apply" })
|
|
717
|
+
] })
|
|
718
|
+
] })
|
|
719
|
+
] });
|
|
720
|
+
};
|
|
721
|
+
var DateRangePicker = ({ value, onChange }) => {
|
|
722
|
+
const [open, setOpen] = useState(false);
|
|
723
|
+
const [draft, setDraft] = useState(value ?? { start: null, end: null });
|
|
724
|
+
const label = value?.start ? `${formatDate(value.start)} \u2013 ${formatDate(value.end)}` : "Select dates";
|
|
725
|
+
return /* @__PURE__ */ jsxs(Sheet, { open, onOpenChange: setOpen, children: [
|
|
726
|
+
/* @__PURE__ */ jsx(Button, { color: "secondary", iconLeading: CalendarBlankIcon, onPress: () => {
|
|
727
|
+
setDraft(value ?? { start: null, end: null });
|
|
728
|
+
setOpen(true);
|
|
729
|
+
}, children: label }),
|
|
730
|
+
/* @__PURE__ */ jsxs(SheetContent, { side: "bottom", size: "full", elevated: false, swipeEnabled: false, showClose: false, className: "flex-1 flex-col justify-between p-0", children: [
|
|
731
|
+
/* @__PURE__ */ jsx(PickerChrome, { title: "Select dates" }),
|
|
732
|
+
/* @__PURE__ */ jsx(View, { className: "min-h-0 w-full flex-1 px-4 pt-1 pb-4", children: /* @__PURE__ */ jsx(Calendar, { range: draft, onRangeChange: setDraft }) }),
|
|
733
|
+
/* @__PURE__ */ jsxs(View, { className: "w-full flex-row gap-3 border-t border-secondary p-4", children: [
|
|
734
|
+
/* @__PURE__ */ jsx(Button, { color: "secondary", className: "flex-1", onPress: () => setOpen(false), children: "Cancel" }),
|
|
735
|
+
/* @__PURE__ */ jsx(Button, { className: "flex-1", onPress: () => {
|
|
736
|
+
onChange?.(draft);
|
|
737
|
+
setOpen(false);
|
|
738
|
+
}, children: "Apply" })
|
|
739
|
+
] })
|
|
740
|
+
] })
|
|
741
|
+
] });
|
|
742
|
+
};
|
|
743
|
+
var CalendarCard = ({ value, onChange, range, onRangeChange, onApply, onCancel }) => {
|
|
744
|
+
return /* @__PURE__ */ jsxs(View, { className: calendarStyles.card, children: [
|
|
745
|
+
/* @__PURE__ */ jsx(View, { className: calendarStyles.cardBody, children: /* @__PURE__ */ jsx(Calendar, { value, onChange, range, onRangeChange }) }),
|
|
746
|
+
/* @__PURE__ */ jsxs(View, { className: calendarStyles.footer, children: [
|
|
747
|
+
/* @__PURE__ */ jsx(Button, { color: "secondary", className: "flex-1", onPress: onCancel, children: "Cancel" }),
|
|
748
|
+
/* @__PURE__ */ jsx(Button, { className: "flex-1", onPress: onApply, children: "Apply" })
|
|
749
|
+
] })
|
|
750
|
+
] });
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
export { Calendar, CalendarCard, DatePicker, DateRangePicker };
|
|
754
|
+
//# sourceMappingURL=date-picker.js.map
|
|
755
|
+
//# sourceMappingURL=date-picker.js.map
|