@avenue-ticketing/ui 0.12.0-beta.7 → 0.12.0-beta.8
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/dist/date-picker-mobile-overlay-K7k5Wj8h.d.ts +12 -0
- package/dist/react/button.d.ts +1 -1
- package/dist/react/calendar.d.ts +19 -0
- package/dist/react/calendar.js +611 -0
- package/dist/react/calendar.js.map +1 -0
- package/dist/react/date-picker.d.ts +17 -0
- package/dist/react/date-picker.js +879 -0
- package/dist/react/date-picker.js.map +1 -0
- package/dist/react/date-range-picker.d.ts +17 -0
- package/dist/react/date-range-picker.js +1836 -0
- package/dist/react/date-range-picker.js.map +1 -0
- package/dist/react/range-calendar.d.ts +33 -0
- package/dist/react/range-calendar.js +1560 -0
- package/dist/react/range-calendar.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
import { createContext, useMemo, useState, useEffect, isValidElement, useContext, Fragment as Fragment$1, useLayoutEffect } from 'react';
|
|
2
|
+
import { today, getLocalTimeZone, getDayOfWeek, isToday } from '@internationalized/date';
|
|
3
|
+
import { useControlledState } from '@react-stately/utils';
|
|
4
|
+
import { CalendarBlankIcon } from '@phosphor-icons/react/dist/csr/CalendarBlank';
|
|
5
|
+
import { useDateFormatter } from 'react-aria';
|
|
6
|
+
import { DatePicker as DatePicker$1, Group, Dialog, Link, Button as Button$1, OverlayTriggerStateContext, Popover, useSlottedContext, CalendarContext, Calendar as Calendar$1, Heading, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, DateInput, DateSegment, useLocale, RangeCalendarContext, CalendarCell as CalendarCell$1, TooltipTrigger as TooltipTrigger$1, Tooltip as Tooltip$1, OverlayArrow } from 'react-aria-components';
|
|
7
|
+
import { extendTailwindMerge } from 'tailwind-merge';
|
|
8
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import { CaretLeftIcon } from '@phosphor-icons/react/dist/csr/CaretLeft';
|
|
10
|
+
import { CaretRightIcon } from '@phosphor-icons/react/dist/csr/CaretRight';
|
|
11
|
+
import { QuestionIcon } from '@phosphor-icons/react/dist/csr/Question';
|
|
12
|
+
import { InfoIcon } from '@phosphor-icons/react/dist/csr/Info';
|
|
13
|
+
import '@phosphor-icons/react/dist/csr/Eye';
|
|
14
|
+
import '@phosphor-icons/react/dist/csr/EyeSlash';
|
|
15
|
+
import { XIcon } from '@phosphor-icons/react/dist/csr/X';
|
|
16
|
+
|
|
17
|
+
var twMerge = extendTailwindMerge({
|
|
18
|
+
extend: {
|
|
19
|
+
theme: {
|
|
20
|
+
text: ["display-xs", "display-sm", "display-md", "display-lg", "display-xl", "display-2xl"]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var cx = twMerge;
|
|
25
|
+
function sortCx(classes) {
|
|
26
|
+
return classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ../../utils/is-react-component.ts
|
|
30
|
+
var isFunctionComponent = (component) => {
|
|
31
|
+
return typeof component === "function";
|
|
32
|
+
};
|
|
33
|
+
var isClassComponent = (component) => {
|
|
34
|
+
return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
|
|
35
|
+
};
|
|
36
|
+
var isForwardRefComponent = (component) => {
|
|
37
|
+
return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
|
|
38
|
+
};
|
|
39
|
+
var isReactComponent = (component) => {
|
|
40
|
+
return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
|
|
41
|
+
};
|
|
42
|
+
var focusShadowPlain = "focus-visible:outline-none focus-visible:[box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
|
|
43
|
+
var focusShadowSkeuomorphic = "focus-visible:outline-none focus-visible:[box-shadow:var(--shadow-xs-skeuomorphic),0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
|
|
44
|
+
var skeuomorphicGradientBorderClass = [
|
|
45
|
+
"ring-1 ring-inset ring-transparent",
|
|
46
|
+
"before:pointer-events-none before:absolute before:inset-px before:rounded-[inherit] before:border before:border-[#ffffff1f] before:content-['']",
|
|
47
|
+
"before:[mask-image:linear-gradient(to_bottom,#000,transparent)]"
|
|
48
|
+
].join(" ");
|
|
49
|
+
var skeuomorphicShadowClass = ["shadow-xs-skeuomorphic", focusShadowSkeuomorphic, "overflow-hidden"].join(" ");
|
|
50
|
+
var focusShadowSecondary = "focus-visible:outline-none focus-visible:[box-shadow:0px_1px_2px_0px_rgba(0,0,0,0.05),0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
|
|
51
|
+
var secondaryInnerShadow = "after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:content-[''] after:[box-shadow:inset_0px_-1px_0px_0px_rgba(0,0,0,0.05)]";
|
|
52
|
+
var secondaryShadowClass = ["relative overflow-hidden shadow-xs", secondaryInnerShadow, focusShadowSecondary].join(" ");
|
|
53
|
+
var inputNumberButtonClass = [
|
|
54
|
+
"in-data-number-input:border-0 in-data-number-input:shadow-none in-data-number-input:!rounded-none in-data-number-input:!h-full in-data-number-input:!min-h-0 in-data-number-input:self-stretch in-data-number-input:overflow-hidden",
|
|
55
|
+
"in-data-number-input:before:hidden in-data-number-input:after:hidden",
|
|
56
|
+
"in-data-number-input:focus-visible:outline-none in-data-number-input:focus-visible:shadow-none in-data-number-input:focus-visible:ring-0 in-data-number-input:focus-visible:![box-shadow:none]"
|
|
57
|
+
].join(" ");
|
|
58
|
+
var inputAddonButtonClass = [
|
|
59
|
+
"in-data-input-wrapper:border-0 in-data-input-wrapper:shadow-none in-data-input-wrapper:!rounded-none in-data-input-wrapper:overflow-hidden",
|
|
60
|
+
"in-data-input-wrapper:in-data-trailing:border-l in-data-input-wrapper:in-data-trailing:border-solid in-data-input-wrapper:in-data-trailing:border-primary",
|
|
61
|
+
"in-data-input-wrapper:in-data-leading:border-r in-data-input-wrapper:in-data-leading:border-solid in-data-input-wrapper:in-data-leading:border-primary",
|
|
62
|
+
"in-data-input-wrapper:group-invalid:in-data-trailing:border-error_subtle in-data-input-wrapper:group-invalid:in-data-leading:border-error_subtle",
|
|
63
|
+
"in-data-input-wrapper:before:hidden in-data-input-wrapper:after:hidden",
|
|
64
|
+
"in-data-input-wrapper:focus-visible:outline-none in-data-input-wrapper:focus-visible:shadow-none in-data-input-wrapper:focus-visible:ring-0 in-data-input-wrapper:focus-visible:![box-shadow:none]"
|
|
65
|
+
].join(" ");
|
|
66
|
+
var styles = sortCx({
|
|
67
|
+
common: {
|
|
68
|
+
root: [
|
|
69
|
+
"group relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-full font-body outline-none before:absolute",
|
|
70
|
+
"font-semibold transition-[color,background-color,border-color,box-shadow,opacity,transform] duration-150 ease-out",
|
|
71
|
+
"pressed:scale-[0.985] pressed:duration-100 pressed:ease-linear motion-reduce:pressed:scale-100",
|
|
72
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed in-data-input-wrapper:disabled:opacity-100",
|
|
73
|
+
inputAddonButtonClass,
|
|
74
|
+
inputNumberButtonClass,
|
|
75
|
+
// Stretch to InputGroup row height; padding/typography follow `data-input-size` on the field (Figma 85:1269).
|
|
76
|
+
"in-data-input-wrapper:!h-full in-data-input-wrapper:!min-h-0 in-data-input-wrapper:self-stretch",
|
|
77
|
+
"in-data-input-wrapper:in-data-[input-size=sm]:gap-1 in-data-input-wrapper:in-data-[input-size=sm]:px-3 in-data-input-wrapper:in-data-[input-size=sm]:py-2 in-data-input-wrapper:in-data-[input-size=sm]:text-sm",
|
|
78
|
+
"in-data-input-wrapper:in-data-[input-size=md]:gap-1 in-data-input-wrapper:in-data-[input-size=md]:px-3.5 in-data-input-wrapper:in-data-[input-size=md]:py-2.5 in-data-input-wrapper:in-data-[input-size=md]:text-sm",
|
|
79
|
+
"in-data-input-wrapper:in-data-[input-size=lg]:gap-1.5 in-data-input-wrapper:in-data-[input-size=lg]:px-4 in-data-input-wrapper:in-data-[input-size=lg]:py-2.5 in-data-input-wrapper:in-data-[input-size=lg]:text-md",
|
|
80
|
+
"*:data-icon:pointer-events-none *:data-icon:shrink-0 *:data-icon:transition-inherit-all"
|
|
81
|
+
].join(" "),
|
|
82
|
+
icon: "pointer-events-none shrink-0 transition-inherit-all"
|
|
83
|
+
},
|
|
84
|
+
sizes: {
|
|
85
|
+
xs: {
|
|
86
|
+
root: [
|
|
87
|
+
"h-8 min-h-8 gap-1 px-[0.625rem] py-1.5 text-sm data-icon-only:size-8 data-icon-only:min-h-8 data-icon-only:min-w-8 data-icon-only:p-2",
|
|
88
|
+
"in-data-input-wrapper:data-icon-only:p-2.5",
|
|
89
|
+
"*:data-icon:size-4"
|
|
90
|
+
].join(" "),
|
|
91
|
+
linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-3"
|
|
92
|
+
},
|
|
93
|
+
sm: {
|
|
94
|
+
root: [
|
|
95
|
+
"h-9 min-h-9 gap-1 px-3 py-2 text-sm data-icon-only:size-9 data-icon-only:min-h-9 data-icon-only:min-w-9 data-icon-only:p-2",
|
|
96
|
+
"in-data-input-wrapper:data-icon-only:p-2.5",
|
|
97
|
+
"*:data-icon:size-5"
|
|
98
|
+
].join(" "),
|
|
99
|
+
linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-3"
|
|
100
|
+
},
|
|
101
|
+
md: {
|
|
102
|
+
root: [
|
|
103
|
+
"h-10 min-h-10 gap-1 px-3.5 py-2.5 text-sm data-icon-only:size-10 data-icon-only:min-h-10 data-icon-only:min-w-10 data-icon-only:p-2.5",
|
|
104
|
+
"in-data-input-wrapper:data-icon-only:p-3",
|
|
105
|
+
"*:data-icon:size-5"
|
|
106
|
+
].join(" "),
|
|
107
|
+
linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-4"
|
|
108
|
+
},
|
|
109
|
+
lg: {
|
|
110
|
+
root: "h-11 min-h-11 gap-1.5 px-4 py-2.5 text-md data-icon-only:size-11 data-icon-only:min-h-11 data-icon-only:min-w-11 data-icon-only:p-3 *:data-icon:size-5",
|
|
111
|
+
linkRoot: "h-auto min-h-0 gap-1.5 px-0! py-0! text-md *:data-text:underline-offset-4"
|
|
112
|
+
},
|
|
113
|
+
xl: {
|
|
114
|
+
root: "h-12 min-h-12 gap-1.5 px-[1.125rem] py-3 text-md data-icon-only:size-12 data-icon-only:min-h-12 data-icon-only:min-w-12 data-icon-only:p-3 data-icon-only:*:data-icon:size-6 *:data-icon:size-5",
|
|
115
|
+
linkRoot: "h-auto min-h-0 gap-1.5 px-0! py-0! text-md *:data-text:underline-offset-4"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
colors: {
|
|
119
|
+
/** Figma Hierarchy=Primary — dark neutral solid; hover lightens to fg-tertiary_hover (#404040). */
|
|
120
|
+
primary: {
|
|
121
|
+
root: [
|
|
122
|
+
"bg-primary-solid text-white",
|
|
123
|
+
skeuomorphicShadowClass,
|
|
124
|
+
skeuomorphicGradientBorderClass,
|
|
125
|
+
"hover:bg-fg-tertiary_hover dark:hover:bg-quaternary",
|
|
126
|
+
"disabled:opacity-30",
|
|
127
|
+
"data-loading:bg-fg-tertiary_hover dark:data-loading:bg-quaternary",
|
|
128
|
+
"*:data-icon:not([data-icon=loading]):text-white/70"
|
|
129
|
+
].join(" ")
|
|
130
|
+
},
|
|
131
|
+
/** Figma Hierarchy=Brand — purple solid; hover darkens to bg-brand-solid_hover (#6d28d9). */
|
|
132
|
+
brand: {
|
|
133
|
+
root: [
|
|
134
|
+
"bg-brand-solid text-primary_on-brand",
|
|
135
|
+
skeuomorphicShadowClass,
|
|
136
|
+
skeuomorphicGradientBorderClass,
|
|
137
|
+
"hover:bg-brand-solid_hover",
|
|
138
|
+
"disabled:opacity-50",
|
|
139
|
+
"data-loading:bg-brand-solid_hover",
|
|
140
|
+
"*:data-icon:not([data-icon=loading]):text-primary_on-brand"
|
|
141
|
+
].join(" ")
|
|
142
|
+
},
|
|
143
|
+
/** Figma Hierarchy=Secondary — border-primary + shadow-xs + skeuomorphic inner rim overlay. */
|
|
144
|
+
secondary: {
|
|
145
|
+
root: [
|
|
146
|
+
"border border-solid border-primary bg-primary text-secondary",
|
|
147
|
+
secondaryShadowClass,
|
|
148
|
+
"hover:bg-primary_hover hover:text-secondary_hover",
|
|
149
|
+
"disabled:opacity-50",
|
|
150
|
+
"data-loading:bg-primary_hover",
|
|
151
|
+
"*:data-icon:text-fg-secondary"
|
|
152
|
+
].join(" ")
|
|
153
|
+
},
|
|
154
|
+
/** Figma Hierarchy=Tertiary */
|
|
155
|
+
tertiary: {
|
|
156
|
+
root: [
|
|
157
|
+
"border border-transparent bg-transparent text-tertiary",
|
|
158
|
+
focusShadowPlain,
|
|
159
|
+
"hover:bg-primary_hover hover:text-tertiary_hover",
|
|
160
|
+
"disabled:opacity-50",
|
|
161
|
+
"*:data-icon:text-fg-tertiary"
|
|
162
|
+
].join(" ")
|
|
163
|
+
},
|
|
164
|
+
/** Figma Hierarchy=Link color — text + icons share brand-secondary; hover underlines with fg-brand-secondary. */
|
|
165
|
+
"link-color": {
|
|
166
|
+
root: [
|
|
167
|
+
"h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-brand-secondary shadow-none",
|
|
168
|
+
focusShadowPlain,
|
|
169
|
+
"hover:text-brand-secondary_hover",
|
|
170
|
+
"disabled:opacity-50",
|
|
171
|
+
"*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-fg-brand-secondary"
|
|
172
|
+
].join(" ")
|
|
173
|
+
},
|
|
174
|
+
/** Figma Hierarchy=Link gray — text + icons share tertiary; hover underlines with fg-quaternary. */
|
|
175
|
+
"link-gray": {
|
|
176
|
+
root: [
|
|
177
|
+
"h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-tertiary shadow-none",
|
|
178
|
+
focusShadowPlain,
|
|
179
|
+
"hover:text-tertiary_hover",
|
|
180
|
+
"disabled:opacity-50",
|
|
181
|
+
"*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-fg-quaternary"
|
|
182
|
+
].join(" ")
|
|
183
|
+
},
|
|
184
|
+
"primary-destructive": {
|
|
185
|
+
root: [
|
|
186
|
+
"bg-error-solid text-white",
|
|
187
|
+
skeuomorphicShadowClass,
|
|
188
|
+
skeuomorphicGradientBorderClass,
|
|
189
|
+
"hover:bg-error-solid_hover",
|
|
190
|
+
"disabled:opacity-50",
|
|
191
|
+
"data-loading:bg-error-solid_hover",
|
|
192
|
+
"*:data-icon:not([data-icon=loading]):text-white/70"
|
|
193
|
+
].join(" ")
|
|
194
|
+
},
|
|
195
|
+
"secondary-destructive": {
|
|
196
|
+
root: [
|
|
197
|
+
"border border-solid border-primary bg-primary text-error-primary",
|
|
198
|
+
secondaryShadowClass,
|
|
199
|
+
"hover:bg-error-primary hover:text-error-primary_hover",
|
|
200
|
+
"disabled:opacity-50",
|
|
201
|
+
"data-loading:bg-error-primary",
|
|
202
|
+
"*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
|
|
203
|
+
].join(" ")
|
|
204
|
+
},
|
|
205
|
+
"tertiary-destructive": {
|
|
206
|
+
root: [
|
|
207
|
+
"border border-transparent bg-transparent text-error-primary",
|
|
208
|
+
focusShadowPlain,
|
|
209
|
+
"hover:bg-error-primary hover:text-error-primary_hover",
|
|
210
|
+
"disabled:opacity-50",
|
|
211
|
+
"*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
|
|
212
|
+
].join(" ")
|
|
213
|
+
},
|
|
214
|
+
/** Figma Hierarchy=Link (destructive) — text + icons share error-primary; hover underlines. */
|
|
215
|
+
"link-destructive": {
|
|
216
|
+
root: [
|
|
217
|
+
"h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-error-primary shadow-none",
|
|
218
|
+
focusShadowPlain,
|
|
219
|
+
"hover:text-error-primary_hover",
|
|
220
|
+
"disabled:opacity-50",
|
|
221
|
+
"*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-current"
|
|
222
|
+
].join(" ")
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
var Button = ({
|
|
227
|
+
size = "md",
|
|
228
|
+
color = "primary",
|
|
229
|
+
children,
|
|
230
|
+
className,
|
|
231
|
+
noTextPadding,
|
|
232
|
+
iconLeading: IconLeading,
|
|
233
|
+
iconTrailing: IconTrailing,
|
|
234
|
+
isDisabled: disabled,
|
|
235
|
+
isLoading: loading,
|
|
236
|
+
showTextWhileLoading,
|
|
237
|
+
...props
|
|
238
|
+
}) => {
|
|
239
|
+
const href = "href" in props ? props.href : void 0;
|
|
240
|
+
const isIcon = (IconLeading || IconTrailing) && !children;
|
|
241
|
+
const isLinkType = ["link-gray", "link-color", "link-destructive"].includes(color);
|
|
242
|
+
noTextPadding = isLinkType || noTextPadding;
|
|
243
|
+
const commonChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
244
|
+
isValidElement(IconLeading) && IconLeading,
|
|
245
|
+
isReactComponent(IconLeading) && /* @__PURE__ */ jsx(IconLeading, { "data-icon": "leading", className: styles.common.icon }),
|
|
246
|
+
loading && /* @__PURE__ */ jsx(
|
|
247
|
+
"svg",
|
|
248
|
+
{
|
|
249
|
+
fill: "none",
|
|
250
|
+
"data-icon": "loading",
|
|
251
|
+
viewBox: "0 0 256 256",
|
|
252
|
+
"aria-hidden": true,
|
|
253
|
+
className: cx(
|
|
254
|
+
styles.common.icon,
|
|
255
|
+
"size-5 animate-spin",
|
|
256
|
+
!showTextWhileLoading && "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
|
|
257
|
+
),
|
|
258
|
+
children: /* @__PURE__ */ jsx(
|
|
259
|
+
"path",
|
|
260
|
+
{
|
|
261
|
+
fill: "currentColor",
|
|
262
|
+
d: "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"
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
children && /* @__PURE__ */ jsx("span", { "data-text": true, className: cx("transition-inherit-all", !noTextPadding && !isLinkType && "px-0.5"), children }),
|
|
268
|
+
isValidElement(IconTrailing) && IconTrailing,
|
|
269
|
+
isReactComponent(IconTrailing) && /* @__PURE__ */ jsx(IconTrailing, { "data-icon": "trailing", className: styles.common.icon })
|
|
270
|
+
] });
|
|
271
|
+
const commonProps = {
|
|
272
|
+
"data-icon-only": isIcon ? true : void 0,
|
|
273
|
+
"data-loading": loading ? true : void 0,
|
|
274
|
+
...props,
|
|
275
|
+
isDisabled: disabled || loading,
|
|
276
|
+
className: cx(
|
|
277
|
+
styles.common.root,
|
|
278
|
+
styles.sizes[size].root,
|
|
279
|
+
styles.colors[color].root,
|
|
280
|
+
isLinkType && styles.sizes[size].linkRoot,
|
|
281
|
+
(loading || href && (disabled || loading)) && "pointer-events-none",
|
|
282
|
+
loading && (showTextWhileLoading ? "[&>*:not([data-icon=loading]):not([data-text])]:hidden" : "[&>*:not([data-icon=loading])]:invisible"),
|
|
283
|
+
className
|
|
284
|
+
),
|
|
285
|
+
children: commonChildren
|
|
286
|
+
};
|
|
287
|
+
if ("href" in commonProps) {
|
|
288
|
+
return /* @__PURE__ */ jsx(Link, { ...commonProps, href: disabled || loading ? void 0 : href });
|
|
289
|
+
}
|
|
290
|
+
return /* @__PURE__ */ jsx(Button$1, { ...commonProps, type: commonProps.type || "button", isPending: loading });
|
|
291
|
+
};
|
|
292
|
+
var MOBILE_SHEET_MAX_PX = 1024;
|
|
293
|
+
function useIsMobile(breakpoint = MOBILE_SHEET_MAX_PX + 1) {
|
|
294
|
+
const [isMobile, setIsMobile] = useState(() => {
|
|
295
|
+
if (typeof window === "undefined") return false;
|
|
296
|
+
return window.matchMedia(`(max-width: ${breakpoint - 1}px)`).matches;
|
|
297
|
+
});
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
|
|
300
|
+
const handler = (e) => setIsMobile(e.matches);
|
|
301
|
+
mq.addEventListener("change", handler);
|
|
302
|
+
return () => mq.removeEventListener("change", handler);
|
|
303
|
+
}, [breakpoint]);
|
|
304
|
+
return isMobile;
|
|
305
|
+
}
|
|
306
|
+
var Tooltip = ({
|
|
307
|
+
title,
|
|
308
|
+
description,
|
|
309
|
+
children,
|
|
310
|
+
arrow = false,
|
|
311
|
+
delay = 100,
|
|
312
|
+
closeDelay = 0,
|
|
313
|
+
trigger,
|
|
314
|
+
isDisabled,
|
|
315
|
+
isOpen,
|
|
316
|
+
defaultOpen,
|
|
317
|
+
offset = 6,
|
|
318
|
+
crossOffset,
|
|
319
|
+
placement = "top",
|
|
320
|
+
onOpenChange,
|
|
321
|
+
...tooltipProps
|
|
322
|
+
}) => {
|
|
323
|
+
const isTopOrBottomLeft = ["top left", "top end", "bottom left", "bottom end"].includes(placement);
|
|
324
|
+
const isTopOrBottomRight = ["top right", "top start", "bottom right", "bottom start"].includes(placement);
|
|
325
|
+
const calculatedCrossOffset = isTopOrBottomLeft ? -12 : isTopOrBottomRight ? 12 : 0;
|
|
326
|
+
return /* @__PURE__ */ jsxs(TooltipTrigger$1, { ...{ trigger, delay, closeDelay, isDisabled, isOpen, defaultOpen, onOpenChange }, children: [
|
|
327
|
+
children,
|
|
328
|
+
/* @__PURE__ */ jsx(
|
|
329
|
+
Tooltip$1,
|
|
330
|
+
{
|
|
331
|
+
...tooltipProps,
|
|
332
|
+
offset,
|
|
333
|
+
placement,
|
|
334
|
+
crossOffset: crossOffset ?? calculatedCrossOffset,
|
|
335
|
+
className: ({ isEntering, isExiting }) => cx(isEntering && "ease-out animate-in", isExiting && "ease-in animate-out"),
|
|
336
|
+
children: ({ isEntering, isExiting }) => /* @__PURE__ */ jsxs(
|
|
337
|
+
"div",
|
|
338
|
+
{
|
|
339
|
+
className: cx(
|
|
340
|
+
"z-50 flex max-w-xs origin-(--trigger-anchor-point) flex-col items-start gap-1 rounded-lg bg-primary-solid px-3 shadow-lg will-change-transform",
|
|
341
|
+
description ? "py-3" : "py-2",
|
|
342
|
+
isEntering && "ease-out animate-in fade-in zoom-in-95 in-placement-left:slide-in-from-right-0.5 in-placement-right:slide-in-from-left-0.5 in-placement-top:slide-in-from-bottom-0.5 in-placement-bottom:slide-in-from-top-0.5",
|
|
343
|
+
isExiting && "ease-in animate-out fade-out zoom-out-95 in-placement-left:slide-out-to-right-0.5 in-placement-right:slide-out-to-left-0.5 in-placement-top:slide-out-to-bottom-0.5 in-placement-bottom:slide-out-to-top-0.5"
|
|
344
|
+
),
|
|
345
|
+
children: [
|
|
346
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-white", children: title }),
|
|
347
|
+
description && /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-tooltip-supporting-text", children: description }),
|
|
348
|
+
arrow && /* @__PURE__ */ jsx(OverlayArrow, { children: /* @__PURE__ */ jsx(
|
|
349
|
+
"svg",
|
|
350
|
+
{
|
|
351
|
+
viewBox: "0 0 100 100",
|
|
352
|
+
className: "size-2.5 fill-bg-primary-solid in-placement-left:-rotate-90 in-placement-right:rotate-90 in-placement-top:rotate-0 in-placement-bottom:rotate-180",
|
|
353
|
+
children: /* @__PURE__ */ jsx("path", { d: "M0,0 L35.858,35.858 Q50,50 64.142,35.858 L100,0 Z" })
|
|
354
|
+
}
|
|
355
|
+
) })
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
] });
|
|
362
|
+
};
|
|
363
|
+
var TooltipTrigger = ({ children, className, ...buttonProps }) => {
|
|
364
|
+
return /* @__PURE__ */ jsx(Button$1, { ...buttonProps, className: (values) => cx("h-max w-max outline-hidden", typeof className === "function" ? className(values) : className), children });
|
|
365
|
+
};
|
|
366
|
+
var inputFocusRingShadow = "border-brand ring-1 ring-inset ring-brand";
|
|
367
|
+
var inputErrorFocusRingShadow = "border-error ring-1 ring-inset ring-error";
|
|
368
|
+
createContext({});
|
|
369
|
+
var DateFieldContext = createContext({});
|
|
370
|
+
var InputDateBase = ({
|
|
371
|
+
tooltip,
|
|
372
|
+
shortcut,
|
|
373
|
+
groupRef,
|
|
374
|
+
size = "md",
|
|
375
|
+
isInvalid,
|
|
376
|
+
isDisabled,
|
|
377
|
+
icon: Icon,
|
|
378
|
+
wrapperClassName,
|
|
379
|
+
tooltipClassName,
|
|
380
|
+
iconClassName,
|
|
381
|
+
...inputProps
|
|
382
|
+
}) => {
|
|
383
|
+
const hasTrailingIcon = tooltip || isInvalid;
|
|
384
|
+
const hasLeadingIcon = Icon;
|
|
385
|
+
const context = useContext(DateFieldContext);
|
|
386
|
+
const inputSize = context?.size || size;
|
|
387
|
+
const sizes = sortCx({
|
|
388
|
+
sm: {
|
|
389
|
+
root: cx("px-3 py-2 text-sm", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-8.5"),
|
|
390
|
+
iconLeading: "left-3 size-4 stroke-[2.25px]",
|
|
391
|
+
iconTrailing: "right-3",
|
|
392
|
+
shortcut: "pr-2.5"
|
|
393
|
+
},
|
|
394
|
+
md: {
|
|
395
|
+
root: cx("px-3 py-2 text-md", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-10"),
|
|
396
|
+
iconLeading: "left-3 size-5",
|
|
397
|
+
iconTrailing: "right-3",
|
|
398
|
+
shortcut: "pr-2.5"
|
|
399
|
+
},
|
|
400
|
+
lg: {
|
|
401
|
+
root: cx("px-3.5 py-2.5 text-md", hasTrailingIcon && "pr-9.5", hasLeadingIcon && "pl-10.5"),
|
|
402
|
+
iconLeading: "left-3.5 size-5",
|
|
403
|
+
iconTrailing: "right-3.5",
|
|
404
|
+
shortcut: "pr-3"
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
return /* @__PURE__ */ jsxs(
|
|
408
|
+
Group,
|
|
409
|
+
{
|
|
410
|
+
...{ isDisabled, isInvalid },
|
|
411
|
+
ref: groupRef,
|
|
412
|
+
className: ({ isFocusWithin, isDisabled: isDisabled2, isInvalid: isInvalid2 }) => cx(
|
|
413
|
+
"group/input relative flex w-full flex-row place-content-center place-items-center rounded-lg border border-solid border-primary bg-primary shadow-xs transition-[border-color,box-shadow] duration-100 ease-linear",
|
|
414
|
+
isFocusWithin && !isDisabled2 && !isInvalid2 && inputFocusRingShadow,
|
|
415
|
+
// Disabled state styles
|
|
416
|
+
isDisabled2 && "cursor-not-allowed opacity-50 in-data-input-wrapper:opacity-100",
|
|
417
|
+
"group-disabled:cursor-not-allowed group-disabled:opacity-50 in-data-input-wrapper:group-disabled:opacity-100",
|
|
418
|
+
// Invalid state styles
|
|
419
|
+
isInvalid2 && !isFocusWithin && "border-error_subtle",
|
|
420
|
+
"group-invalid:border-error_subtle",
|
|
421
|
+
"group-invalid:focus-within:border-error group-invalid:focus-within:ring-1 group-invalid:focus-within:ring-inset group-invalid:focus-within:ring-error",
|
|
422
|
+
isInvalid2 && isFocusWithin && inputErrorFocusRingShadow,
|
|
423
|
+
context?.wrapperClassName,
|
|
424
|
+
wrapperClassName
|
|
425
|
+
),
|
|
426
|
+
children: [
|
|
427
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: cx("pointer-events-none absolute text-fg-quaternary", sizes[inputSize].iconLeading, context?.iconClassName, iconClassName) }),
|
|
428
|
+
/* @__PURE__ */ jsx(DateInput, { ...inputProps, className: cx("flex w-full", sizes[size].root, typeof inputProps.className === "string" && inputProps.className), children: (segment) => /* @__PURE__ */ jsx(
|
|
429
|
+
DateSegment,
|
|
430
|
+
{
|
|
431
|
+
segment,
|
|
432
|
+
className: cx(
|
|
433
|
+
"rounded px-0.5 text-primary tabular-nums caret-transparent focus:bg-brand-solid focus:font-medium focus:text-white focus:outline-hidden",
|
|
434
|
+
// The placeholder segment.
|
|
435
|
+
segment.isPlaceholder && "text-placeholder uppercase",
|
|
436
|
+
// The separator "/" segment.
|
|
437
|
+
segment.type === "literal" && "text-fg-quaternary"
|
|
438
|
+
)
|
|
439
|
+
}
|
|
440
|
+
) }),
|
|
441
|
+
tooltip && /* @__PURE__ */ jsx(Tooltip, { title: tooltip, placement: "top", children: /* @__PURE__ */ jsx(
|
|
442
|
+
TooltipTrigger,
|
|
443
|
+
{
|
|
444
|
+
className: cx(
|
|
445
|
+
"absolute cursor-pointer text-fg-quaternary transition duration-200 group-invalid/input:hidden hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
|
|
446
|
+
sizes[inputSize].iconTrailing,
|
|
447
|
+
context?.tooltipClassName,
|
|
448
|
+
tooltipClassName
|
|
449
|
+
),
|
|
450
|
+
children: /* @__PURE__ */ jsx(QuestionIcon, { className: "size-4 stroke-[2.25px]" })
|
|
451
|
+
}
|
|
452
|
+
) }),
|
|
453
|
+
/* @__PURE__ */ jsx(
|
|
454
|
+
InfoIcon,
|
|
455
|
+
{
|
|
456
|
+
className: cx(
|
|
457
|
+
"pointer-events-none absolute hidden size-4 stroke-[2.25px] text-fg-error-secondary group-invalid/input:block",
|
|
458
|
+
sizes[inputSize].iconTrailing,
|
|
459
|
+
context?.tooltipClassName,
|
|
460
|
+
tooltipClassName
|
|
461
|
+
)
|
|
462
|
+
}
|
|
463
|
+
),
|
|
464
|
+
shortcut && /* @__PURE__ */ jsx(
|
|
465
|
+
"div",
|
|
466
|
+
{
|
|
467
|
+
className: cx(
|
|
468
|
+
"pointer-events-none absolute inset-y-0.5 right-0.5 z-10 flex items-center rounded-r-[inherit] bg-linear-to-r from-transparent to-bg-primary to-40% pl-8",
|
|
469
|
+
sizes[inputSize].shortcut
|
|
470
|
+
),
|
|
471
|
+
children: /* @__PURE__ */ jsx(
|
|
472
|
+
"span",
|
|
473
|
+
{
|
|
474
|
+
"aria-hidden": "true",
|
|
475
|
+
className: "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
|
|
476
|
+
children: typeof shortcut === "string" ? shortcut : "\u2318K"
|
|
477
|
+
}
|
|
478
|
+
)
|
|
479
|
+
}
|
|
480
|
+
)
|
|
481
|
+
]
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
};
|
|
485
|
+
var CalendarCell = ({ date, isHighlighted, showOutOfRangeDates = false, fluid = false, ...props }) => {
|
|
486
|
+
const { locale } = useLocale();
|
|
487
|
+
const dayOfWeek = getDayOfWeek(date, locale);
|
|
488
|
+
const rangeCalendarContext = useSlottedContext(RangeCalendarContext);
|
|
489
|
+
const isRangeCalendar = !!rangeCalendarContext;
|
|
490
|
+
const start = rangeCalendarContext?.value?.start;
|
|
491
|
+
const end = rangeCalendarContext?.value?.end;
|
|
492
|
+
const isAfterStart = start ? date.compare(start) > 0 : true;
|
|
493
|
+
const isBeforeEnd = end ? date.compare(end) < 0 : true;
|
|
494
|
+
const isAfterOrOnStart = start && date.compare(start) >= 0;
|
|
495
|
+
const isBeforeOrOnEnd = end && date.compare(end) <= 0;
|
|
496
|
+
const isInRange = isAfterOrOnStart && isBeforeOrOnEnd;
|
|
497
|
+
const lastDayOfMonth = new Date(date.year, date.month, 0).getDate();
|
|
498
|
+
const isLastDayOfMonth = date.day === lastDayOfMonth;
|
|
499
|
+
const isFirstDayOfMonth = date.day === 1;
|
|
500
|
+
const isTodayDate = isToday(date, getLocalTimeZone());
|
|
501
|
+
return /* @__PURE__ */ jsx(
|
|
502
|
+
CalendarCell$1,
|
|
503
|
+
{
|
|
504
|
+
...props,
|
|
505
|
+
date,
|
|
506
|
+
className: ({ isDisabled, isFocusVisible, isSelectionStart, isSelectionEnd, isSelected, isOutsideMonth }) => {
|
|
507
|
+
const isRoundedLeft = isSelectionStart || dayOfWeek === 0;
|
|
508
|
+
const isRoundedRight = isSelectionEnd || dayOfWeek === 6;
|
|
509
|
+
return cx(
|
|
510
|
+
"relative focus:outline-hidden",
|
|
511
|
+
fluid ? "aspect-square w-full" : "size-10",
|
|
512
|
+
isRoundedLeft && "rounded-l-full",
|
|
513
|
+
isRoundedRight && "rounded-r-full",
|
|
514
|
+
isInRange && isDisabled && "bg-secondary",
|
|
515
|
+
isSelected && isRangeCalendar && "bg-secondary",
|
|
516
|
+
isDisabled ? "pointer-events-none" : "cursor-pointer",
|
|
517
|
+
isFocusVisible ? "z-10" : "z-0",
|
|
518
|
+
isOutsideMonth && "opacity-50",
|
|
519
|
+
isRangeCalendar && isOutsideMonth && !showOutOfRangeDates && "hidden",
|
|
520
|
+
// Show gradient on last day of month if it's within the selected range.
|
|
521
|
+
isLastDayOfMonth && isSelected && isBeforeEnd && 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",
|
|
522
|
+
// Show gradient on first day of month if it's within the selected range.
|
|
523
|
+
isFirstDayOfMonth && isSelected && isAfterStart && 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"
|
|
524
|
+
);
|
|
525
|
+
},
|
|
526
|
+
children: ({ isDisabled, isFocusVisible, isSelectionStart, isSelectionEnd, isSelected, formattedDate }) => {
|
|
527
|
+
const markedAsSelected = isSelectionStart || isSelectionEnd || isSelected && !isDisabled && !isRangeCalendar;
|
|
528
|
+
return /* @__PURE__ */ jsxs(
|
|
529
|
+
"div",
|
|
530
|
+
{
|
|
531
|
+
className: cx(
|
|
532
|
+
"relative flex size-full items-center justify-center rounded-full text-sm text-secondary hover:text-secondary_hover",
|
|
533
|
+
// Disabled state.
|
|
534
|
+
isDisabled && "text-secondary/50",
|
|
535
|
+
// Focus ring, visible while the cell has keyboard focus.
|
|
536
|
+
isFocusVisible ? "outline-2 outline-offset-2 outline-focus-ring" : "",
|
|
537
|
+
// Hover state for cells in the middle of the range.
|
|
538
|
+
isSelected && !isDisabled && isRangeCalendar ? "font-medium" : "",
|
|
539
|
+
markedAsSelected && "bg-brand-solid font-medium text-white hover:bg-brand-solid_hover hover:text-white",
|
|
540
|
+
// Hover state for non-selected cells.
|
|
541
|
+
!isSelected && !isDisabled ? "hover:bg-primary_hover hover:font-medium!" : "",
|
|
542
|
+
!isSelected && isTodayDate ? "bg-secondary font-medium hover:bg-secondary_hover" : ""
|
|
543
|
+
),
|
|
544
|
+
children: [
|
|
545
|
+
formattedDate,
|
|
546
|
+
(isHighlighted || isTodayDate) && /* @__PURE__ */ jsx(
|
|
547
|
+
"div",
|
|
548
|
+
{
|
|
549
|
+
className: cx(
|
|
550
|
+
"absolute bottom-1 left-1/2 size-1.25 -translate-x-1/2 rounded-full",
|
|
551
|
+
markedAsSelected ? "bg-fg-white" : "bg-fg-brand-primary",
|
|
552
|
+
isDisabled && "opacity-50"
|
|
553
|
+
)
|
|
554
|
+
}
|
|
555
|
+
)
|
|
556
|
+
]
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
};
|
|
563
|
+
var CalendarContextProvider = ({ children }) => {
|
|
564
|
+
const [value, setValue] = useState(null);
|
|
565
|
+
const [focusedValue, onFocusChange] = useState();
|
|
566
|
+
const onChange = (next) => {
|
|
567
|
+
if (Array.isArray(next)) return;
|
|
568
|
+
setValue(next);
|
|
569
|
+
};
|
|
570
|
+
return /* @__PURE__ */ jsx(CalendarContext.Provider, { value: { value, onChange, focusedValue, onFocusChange }, children });
|
|
571
|
+
};
|
|
572
|
+
var Calendar = ({ highlightedDates: highlightedDates2, fluid = false, className, children, ...props }) => {
|
|
573
|
+
const context = useSlottedContext(CalendarContext);
|
|
574
|
+
const ContextWrapper = context ? Fragment$1 : CalendarContextProvider;
|
|
575
|
+
return /* @__PURE__ */ jsx(ContextWrapper, { children: /* @__PURE__ */ jsx(
|
|
576
|
+
Calendar$1,
|
|
577
|
+
{
|
|
578
|
+
...props,
|
|
579
|
+
className: (state) => cx("flex flex-col gap-3", fluid && "w-full", typeof className === "function" ? className(state) : className),
|
|
580
|
+
children: ({ state }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
581
|
+
/* @__PURE__ */ jsxs("header", { className: "flex items-center justify-between", children: [
|
|
582
|
+
/* @__PURE__ */ jsx(Button, { slot: "previous", iconLeading: CaretLeftIcon, size: "sm", color: "tertiary", className: "size-8" }),
|
|
583
|
+
/* @__PURE__ */ jsx(Heading, { className: "text-sm font-semibold text-fg-secondary" }),
|
|
584
|
+
/* @__PURE__ */ jsx(Button, { slot: "next", iconLeading: CaretRightIcon, size: "sm", color: "tertiary", className: "size-8" })
|
|
585
|
+
] }),
|
|
586
|
+
children || /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
587
|
+
/* @__PURE__ */ jsx(InputDateBase, { "aria-label": "Date", size: "sm", className: "flex-1" }),
|
|
588
|
+
/* @__PURE__ */ jsx(
|
|
589
|
+
Button,
|
|
590
|
+
{
|
|
591
|
+
slot: null,
|
|
592
|
+
size: "sm",
|
|
593
|
+
color: "secondary",
|
|
594
|
+
onClick: () => {
|
|
595
|
+
state.setValue(today(getLocalTimeZone()));
|
|
596
|
+
state.setFocusedDate(today(getLocalTimeZone()));
|
|
597
|
+
},
|
|
598
|
+
children: "Today"
|
|
599
|
+
}
|
|
600
|
+
)
|
|
601
|
+
] }),
|
|
602
|
+
/* @__PURE__ */ jsxs(CalendarGrid, { weekdayStyle: "short", className: cx(fluid ? "w-full table-fixed" : "w-max"), children: [
|
|
603
|
+
/* @__PURE__ */ jsx(CalendarGridHeader, { className: "border-b-4 border-transparent", children: (day) => /* @__PURE__ */ jsx(CalendarHeaderCell, { className: "p-0", children: /* @__PURE__ */ jsx(
|
|
604
|
+
"div",
|
|
605
|
+
{
|
|
606
|
+
className: cx(
|
|
607
|
+
"flex items-center justify-center text-sm font-medium text-secondary",
|
|
608
|
+
fluid ? "h-10 w-full" : "size-10"
|
|
609
|
+
),
|
|
610
|
+
children: day.slice(0, 2)
|
|
611
|
+
}
|
|
612
|
+
) }) }),
|
|
613
|
+
/* @__PURE__ */ jsx(CalendarGridBody, { className: "[&_td]:p-0 [&_tr]:border-b-4 [&_tr]:border-transparent [&_tr:last-of-type]:border-none", children: (date) => /* @__PURE__ */ jsx(
|
|
614
|
+
CalendarCell,
|
|
615
|
+
{
|
|
616
|
+
date,
|
|
617
|
+
fluid,
|
|
618
|
+
isHighlighted: highlightedDates2?.some((highlightedDate) => date.compare(highlightedDate) === 0)
|
|
619
|
+
}
|
|
620
|
+
) })
|
|
621
|
+
] })
|
|
622
|
+
] })
|
|
623
|
+
}
|
|
624
|
+
) });
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
// ../../components/application/date-picker/date-picker-mobile-overlay.ts
|
|
628
|
+
function resolveDatePickerMobileOptions(mobileOptions) {
|
|
629
|
+
return {
|
|
630
|
+
fullScreen: mobileOptions?.fullScreen ?? true,
|
|
631
|
+
title: mobileOptions?.title,
|
|
632
|
+
panelClassName: mobileOptions?.className,
|
|
633
|
+
contentClassName: mobileOptions?.contentClassName
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
var MOBILE_SHEET_MOTION_MS = 175;
|
|
637
|
+
var MOBILE_SHEET_ENTRY_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
|
|
638
|
+
var MOBILE_SHEET_EXIT_EASING = "cubic-bezier(0.85, 0, 1, 0.15)";
|
|
639
|
+
var MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX = 120;
|
|
640
|
+
function useMobileSheetAnimation(open, enabled, slideEntrance = true, slideOffsetPx = MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX) {
|
|
641
|
+
const [shouldRender, setShouldRender] = useState(open);
|
|
642
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
643
|
+
useLayoutEffect(() => {
|
|
644
|
+
if (!enabled) {
|
|
645
|
+
setShouldRender(open);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
if (open) {
|
|
649
|
+
setShouldRender(true);
|
|
650
|
+
}
|
|
651
|
+
}, [open, enabled]);
|
|
652
|
+
useEffect(() => {
|
|
653
|
+
if (!enabled || open) return;
|
|
654
|
+
const timer = setTimeout(() => setShouldRender(false), MOBILE_SHEET_MOTION_MS);
|
|
655
|
+
return () => clearTimeout(timer);
|
|
656
|
+
}, [open, enabled]);
|
|
657
|
+
useLayoutEffect(() => {
|
|
658
|
+
if (!enabled || open || !shouldRender) return;
|
|
659
|
+
setIsAnimating(false);
|
|
660
|
+
}, [enabled, open, shouldRender]);
|
|
661
|
+
useEffect(() => {
|
|
662
|
+
if (!enabled || !shouldRender || !open) return;
|
|
663
|
+
let raf2 = 0;
|
|
664
|
+
const raf1 = requestAnimationFrame(() => {
|
|
665
|
+
raf2 = requestAnimationFrame(() => setIsAnimating(true));
|
|
666
|
+
});
|
|
667
|
+
return () => {
|
|
668
|
+
cancelAnimationFrame(raf1);
|
|
669
|
+
if (raf2) cancelAnimationFrame(raf2);
|
|
670
|
+
};
|
|
671
|
+
}, [shouldRender, open, enabled]);
|
|
672
|
+
const motionEasing = open ? MOBILE_SHEET_ENTRY_EASING : MOBILE_SHEET_EXIT_EASING;
|
|
673
|
+
const hiddenTransform = slideEntrance ? `translateY(${slideOffsetPx}px)` : "translateY(100%)";
|
|
674
|
+
const panelStyle = enabled ? {
|
|
675
|
+
transform: isAnimating ? "translateY(0)" : hiddenTransform,
|
|
676
|
+
opacity: isAnimating ? 1 : 0,
|
|
677
|
+
transitionProperty: "transform, opacity",
|
|
678
|
+
transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
|
|
679
|
+
transitionTimingFunction: motionEasing
|
|
680
|
+
} : void 0;
|
|
681
|
+
const backdropStyle = enabled ? {
|
|
682
|
+
opacity: isAnimating ? 1 : 0,
|
|
683
|
+
transitionProperty: "opacity",
|
|
684
|
+
transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
|
|
685
|
+
transitionTimingFunction: motionEasing
|
|
686
|
+
} : void 0;
|
|
687
|
+
return { shouldRender, isAnimating, panelStyle, backdropStyle };
|
|
688
|
+
}
|
|
689
|
+
function MobileFullScreenCloseButton({ onClose }) {
|
|
690
|
+
return /* @__PURE__ */ jsxs(
|
|
691
|
+
"button",
|
|
692
|
+
{
|
|
693
|
+
type: "button",
|
|
694
|
+
onClick: (e) => {
|
|
695
|
+
e.stopPropagation();
|
|
696
|
+
onClose();
|
|
697
|
+
},
|
|
698
|
+
className: "relative z-20 flex size-12 shrink-0 cursor-pointer items-center justify-center rounded-full bg-primary text-fg-primary transition duration-100 ease-linear hover:bg-primary_hover active:scale-[0.96] focus-visible:outline-none focus-visible:[box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]",
|
|
699
|
+
children: [
|
|
700
|
+
/* @__PURE__ */ jsx(XIcon, { className: "size-5", "aria-hidden": "true" }),
|
|
701
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
702
|
+
]
|
|
703
|
+
}
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
function MobileFullScreenChrome({
|
|
707
|
+
title,
|
|
708
|
+
contentClassName,
|
|
709
|
+
onClose,
|
|
710
|
+
children
|
|
711
|
+
}) {
|
|
712
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: [
|
|
713
|
+
/* @__PURE__ */ jsxs(
|
|
714
|
+
"div",
|
|
715
|
+
{
|
|
716
|
+
className: cx(
|
|
717
|
+
"flex w-full shrink-0 items-center py-2 pl-4 pr-2",
|
|
718
|
+
title ? "justify-between gap-3" : "justify-end"
|
|
719
|
+
),
|
|
720
|
+
children: [
|
|
721
|
+
title ? /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-base font-semibold text-primary", children: title }) : null,
|
|
722
|
+
/* @__PURE__ */ jsx(MobileFullScreenCloseButton, { onClose })
|
|
723
|
+
]
|
|
724
|
+
}
|
|
725
|
+
),
|
|
726
|
+
/* @__PURE__ */ jsx("div", { className: cx("flex min-h-0 w-full flex-1 flex-col overflow-x-hidden overflow-y-auto", contentClassName), children })
|
|
727
|
+
] });
|
|
728
|
+
}
|
|
729
|
+
var DatePickerOverlay = ({ mobileOptions, children, className, style, offset, ...props }) => {
|
|
730
|
+
const isMobile = useIsMobile();
|
|
731
|
+
const resolvedMobile = useMemo(() => resolveDatePickerMobileOptions(mobileOptions), [mobileOptions]);
|
|
732
|
+
const useMobileFullScreen = isMobile && resolvedMobile.fullScreen;
|
|
733
|
+
const overlayState = useContext(OverlayTriggerStateContext);
|
|
734
|
+
const open = overlayState?.isOpen ?? false;
|
|
735
|
+
const { shouldRender, panelStyle } = useMobileSheetAnimation(open, useMobileFullScreen);
|
|
736
|
+
useEffect(() => {
|
|
737
|
+
if (!useMobileFullScreen || !open) return;
|
|
738
|
+
const prev = document.body.style.overflow;
|
|
739
|
+
document.body.style.overflow = "hidden";
|
|
740
|
+
return () => {
|
|
741
|
+
document.body.style.overflow = prev;
|
|
742
|
+
};
|
|
743
|
+
}, [useMobileFullScreen, open]);
|
|
744
|
+
const close = () => overlayState?.close();
|
|
745
|
+
const showMobileFullScreen = useMobileFullScreen && shouldRender;
|
|
746
|
+
const isMobileFullScreenExiting = showMobileFullScreen && !open;
|
|
747
|
+
return /* @__PURE__ */ jsx(
|
|
748
|
+
Popover,
|
|
749
|
+
{
|
|
750
|
+
placement: "bottom",
|
|
751
|
+
containerPadding: 0,
|
|
752
|
+
isNonModal: useMobileFullScreen,
|
|
753
|
+
...props,
|
|
754
|
+
offset: useMobileFullScreen ? 0 : offset ?? 8,
|
|
755
|
+
isExiting: isMobileFullScreenExiting,
|
|
756
|
+
...useMobileFullScreen ? { "data-date-picker-mobile-overlay": true } : {},
|
|
757
|
+
style: useMobileFullScreen ? void 0 : style,
|
|
758
|
+
className: (state) => cx(
|
|
759
|
+
"outline-hidden",
|
|
760
|
+
useMobileFullScreen && "pointer-events-none fixed! inset-0! z-50 size-full! max-w-none! border-0 bg-transparent shadow-none",
|
|
761
|
+
!useMobileFullScreen && (typeof className === "function" ? className(state) : className)
|
|
762
|
+
),
|
|
763
|
+
children: (state) => {
|
|
764
|
+
const content = typeof children === "function" ? children(state) : children;
|
|
765
|
+
if (useMobileFullScreen) {
|
|
766
|
+
return /* @__PURE__ */ jsx(
|
|
767
|
+
"div",
|
|
768
|
+
{
|
|
769
|
+
style: panelStyle,
|
|
770
|
+
className: cx(
|
|
771
|
+
"pointer-events-auto fixed inset-0 z-50 flex h-dvh min-h-dvh w-full will-change-transform flex-col overflow-hidden rounded-none border-0 bg-primary shadow-none",
|
|
772
|
+
resolvedMobile.panelClassName
|
|
773
|
+
),
|
|
774
|
+
children: /* @__PURE__ */ jsx(
|
|
775
|
+
MobileFullScreenChrome,
|
|
776
|
+
{
|
|
777
|
+
title: resolvedMobile.title,
|
|
778
|
+
contentClassName: resolvedMobile.contentClassName,
|
|
779
|
+
onClose: close,
|
|
780
|
+
children: content
|
|
781
|
+
}
|
|
782
|
+
)
|
|
783
|
+
}
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
return content;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
);
|
|
790
|
+
};
|
|
791
|
+
var highlightedDates = [today(getLocalTimeZone())];
|
|
792
|
+
var DatePicker = ({
|
|
793
|
+
value: valueProp,
|
|
794
|
+
defaultValue,
|
|
795
|
+
onChange,
|
|
796
|
+
onApply,
|
|
797
|
+
onCancel,
|
|
798
|
+
size = "sm",
|
|
799
|
+
mobileOptions,
|
|
800
|
+
...props
|
|
801
|
+
}) => {
|
|
802
|
+
const isMobile = useIsMobile();
|
|
803
|
+
const resolvedMobile = useMemo(() => resolveDatePickerMobileOptions(mobileOptions), [mobileOptions]);
|
|
804
|
+
const useMobileFullScreen = isMobile && resolvedMobile.fullScreen;
|
|
805
|
+
const formatter = useDateFormatter({
|
|
806
|
+
month: "short",
|
|
807
|
+
day: "numeric",
|
|
808
|
+
year: "numeric"
|
|
809
|
+
});
|
|
810
|
+
const [value, setValue] = useControlledState(valueProp, defaultValue || null, onChange);
|
|
811
|
+
const formattedDate = value ? formatter.format(value.toDate(getLocalTimeZone())) : "Select date";
|
|
812
|
+
return /* @__PURE__ */ jsxs(DatePicker$1, { "aria-label": "Date picker", shouldCloseOnSelect: false, ...props, value, onChange: setValue, children: [
|
|
813
|
+
/* @__PURE__ */ jsx(Group, { children: /* @__PURE__ */ jsx(Button, { size, color: "secondary", iconLeading: CalendarBlankIcon, children: formattedDate }) }),
|
|
814
|
+
/* @__PURE__ */ jsx(
|
|
815
|
+
DatePickerOverlay,
|
|
816
|
+
{
|
|
817
|
+
placement: "bottom right",
|
|
818
|
+
offset: 8,
|
|
819
|
+
mobileOptions: { title: "Select date", ...mobileOptions },
|
|
820
|
+
className: ({ isEntering, isExiting }) => cx(
|
|
821
|
+
"origin-(--trigger-anchor-point) will-change-transform",
|
|
822
|
+
isEntering && "duration-150 ease-out animate-in fade-in placement-right:slide-in-from-left-0.5 placement-top:slide-in-from-bottom-0.5 placement-bottom:slide-in-from-top-0.5",
|
|
823
|
+
isExiting && "duration-100 ease-in animate-out fade-out placement-right:slide-out-to-left-0.5 placement-top:slide-out-to-bottom-0.5 placement-bottom:slide-out-to-top-0.5"
|
|
824
|
+
),
|
|
825
|
+
children: /* @__PURE__ */ jsx(
|
|
826
|
+
Dialog,
|
|
827
|
+
{
|
|
828
|
+
"aria-label": "Date picker",
|
|
829
|
+
className: cx(
|
|
830
|
+
useMobileFullScreen ? "flex min-h-0 flex-1 flex-col overflow-hidden bg-primary outline-hidden" : "rounded-2xl bg-primary shadow-xl ring ring-secondary_alt"
|
|
831
|
+
),
|
|
832
|
+
children: ({ close }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
833
|
+
/* @__PURE__ */ jsx("div", { className: cx("flex", useMobileFullScreen ? "min-h-0 w-full flex-1 flex-col overflow-x-hidden overflow-y-auto px-4 pt-1 pb-4" : "px-6 py-5"), children: /* @__PURE__ */ jsx(Calendar, { fluid: useMobileFullScreen, highlightedDates }) }),
|
|
834
|
+
/* @__PURE__ */ jsxs(
|
|
835
|
+
"div",
|
|
836
|
+
{
|
|
837
|
+
className: cx(
|
|
838
|
+
"grid grid-cols-2 gap-3 border-t border-secondary p-4",
|
|
839
|
+
useMobileFullScreen && "shrink-0 pb-[max(1rem,env(safe-area-inset-bottom))]"
|
|
840
|
+
),
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ jsx(
|
|
843
|
+
Button,
|
|
844
|
+
{
|
|
845
|
+
size: "md",
|
|
846
|
+
color: "secondary",
|
|
847
|
+
onClick: () => {
|
|
848
|
+
onCancel?.();
|
|
849
|
+
close();
|
|
850
|
+
},
|
|
851
|
+
children: "Cancel"
|
|
852
|
+
}
|
|
853
|
+
),
|
|
854
|
+
/* @__PURE__ */ jsx(
|
|
855
|
+
Button,
|
|
856
|
+
{
|
|
857
|
+
size: "md",
|
|
858
|
+
color: "primary",
|
|
859
|
+
onClick: () => {
|
|
860
|
+
onApply?.();
|
|
861
|
+
close();
|
|
862
|
+
},
|
|
863
|
+
children: "Apply"
|
|
864
|
+
}
|
|
865
|
+
)
|
|
866
|
+
]
|
|
867
|
+
}
|
|
868
|
+
)
|
|
869
|
+
] })
|
|
870
|
+
}
|
|
871
|
+
)
|
|
872
|
+
}
|
|
873
|
+
)
|
|
874
|
+
] });
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
export { DatePicker };
|
|
878
|
+
//# sourceMappingURL=date-picker.js.map
|
|
879
|
+
//# sourceMappingURL=date-picker.js.map
|