@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,1836 @@
|
|
|
1
|
+
import { createContext, useMemo, useState, useEffect, isValidElement, useContext, Fragment as Fragment$1, useLayoutEffect, useRef, useCallback } from 'react';
|
|
2
|
+
import { today, getLocalTimeZone, endOfMonth, startOfMonth, endOfWeek, startOfWeek, 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 { useLocale, DateRangePicker as DateRangePicker$1, Group, Dialog, Link, Button as Button$1, OverlayTriggerStateContext, Popover as Popover$1, useSlottedContext, RangeCalendarContext, RangeCalendar as RangeCalendar$1, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, DateInput, DateSegment, RangeCalendarStateContext, CalendarCell as CalendarCell$1, TooltipTrigger as TooltipTrigger$1, Tooltip as Tooltip$1, OverlayArrow, Select as Select$1, ListBox, Label as Label$1, SelectValue as SelectValue$1, Text, ComboBox as ComboBox$1, ListBoxItem, ComboBoxStateContext, Input } from 'react-aria-components';
|
|
7
|
+
import { extendTailwindMerge } from 'tailwind-merge';
|
|
8
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import { QuestionIcon } from '@phosphor-icons/react/dist/csr/Question';
|
|
10
|
+
import { InfoIcon } from '@phosphor-icons/react/dist/csr/Info';
|
|
11
|
+
import '@phosphor-icons/react/dist/csr/Eye';
|
|
12
|
+
import '@phosphor-icons/react/dist/csr/EyeSlash';
|
|
13
|
+
import { XIcon } from '@phosphor-icons/react/dist/csr/X';
|
|
14
|
+
import { CaretLeftIcon } from '@phosphor-icons/react/dist/csr/CaretLeft';
|
|
15
|
+
import { CaretRightIcon } from '@phosphor-icons/react/dist/csr/CaretRight';
|
|
16
|
+
import { CaretDownIcon } from '@phosphor-icons/react/dist/csr/CaretDown';
|
|
17
|
+
import { UserIcon } from '@phosphor-icons/react/dist/csr/User';
|
|
18
|
+
import '@phosphor-icons/react/dist/csr/Plus';
|
|
19
|
+
import { MagnifyingGlassIcon } from '@phosphor-icons/react/dist/csr/MagnifyingGlass';
|
|
20
|
+
import { createPortal } from 'react-dom';
|
|
21
|
+
import { CheckIcon } from '@phosphor-icons/react/dist/csr/Check';
|
|
22
|
+
|
|
23
|
+
var twMerge = extendTailwindMerge({
|
|
24
|
+
extend: {
|
|
25
|
+
theme: {
|
|
26
|
+
text: ["display-xs", "display-sm", "display-md", "display-lg", "display-xl", "display-2xl"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var cx = twMerge;
|
|
31
|
+
function sortCx(classes) {
|
|
32
|
+
return classes;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ../../utils/is-react-component.ts
|
|
36
|
+
var isFunctionComponent = (component) => {
|
|
37
|
+
return typeof component === "function";
|
|
38
|
+
};
|
|
39
|
+
var isClassComponent = (component) => {
|
|
40
|
+
return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
|
|
41
|
+
};
|
|
42
|
+
var isForwardRefComponent = (component) => {
|
|
43
|
+
return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
|
|
44
|
+
};
|
|
45
|
+
var isReactComponent = (component) => {
|
|
46
|
+
return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
|
|
47
|
+
};
|
|
48
|
+
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)]";
|
|
49
|
+
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)]";
|
|
50
|
+
var skeuomorphicGradientBorderClass = [
|
|
51
|
+
"ring-1 ring-inset ring-transparent",
|
|
52
|
+
"before:pointer-events-none before:absolute before:inset-px before:rounded-[inherit] before:border before:border-[#ffffff1f] before:content-['']",
|
|
53
|
+
"before:[mask-image:linear-gradient(to_bottom,#000,transparent)]"
|
|
54
|
+
].join(" ");
|
|
55
|
+
var skeuomorphicShadowClass = ["shadow-xs-skeuomorphic", focusShadowSkeuomorphic, "overflow-hidden"].join(" ");
|
|
56
|
+
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)]";
|
|
57
|
+
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)]";
|
|
58
|
+
var secondaryShadowClass = ["relative overflow-hidden shadow-xs", secondaryInnerShadow, focusShadowSecondary].join(" ");
|
|
59
|
+
var inputNumberButtonClass = [
|
|
60
|
+
"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",
|
|
61
|
+
"in-data-number-input:before:hidden in-data-number-input:after:hidden",
|
|
62
|
+
"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]"
|
|
63
|
+
].join(" ");
|
|
64
|
+
var inputAddonButtonClass = [
|
|
65
|
+
"in-data-input-wrapper:border-0 in-data-input-wrapper:shadow-none in-data-input-wrapper:!rounded-none in-data-input-wrapper:overflow-hidden",
|
|
66
|
+
"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",
|
|
67
|
+
"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",
|
|
68
|
+
"in-data-input-wrapper:group-invalid:in-data-trailing:border-error_subtle in-data-input-wrapper:group-invalid:in-data-leading:border-error_subtle",
|
|
69
|
+
"in-data-input-wrapper:before:hidden in-data-input-wrapper:after:hidden",
|
|
70
|
+
"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]"
|
|
71
|
+
].join(" ");
|
|
72
|
+
var styles = sortCx({
|
|
73
|
+
common: {
|
|
74
|
+
root: [
|
|
75
|
+
"group relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-full font-body outline-none before:absolute",
|
|
76
|
+
"font-semibold transition-[color,background-color,border-color,box-shadow,opacity,transform] duration-150 ease-out",
|
|
77
|
+
"pressed:scale-[0.985] pressed:duration-100 pressed:ease-linear motion-reduce:pressed:scale-100",
|
|
78
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed in-data-input-wrapper:disabled:opacity-100",
|
|
79
|
+
inputAddonButtonClass,
|
|
80
|
+
inputNumberButtonClass,
|
|
81
|
+
// Stretch to InputGroup row height; padding/typography follow `data-input-size` on the field (Figma 85:1269).
|
|
82
|
+
"in-data-input-wrapper:!h-full in-data-input-wrapper:!min-h-0 in-data-input-wrapper:self-stretch",
|
|
83
|
+
"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",
|
|
84
|
+
"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",
|
|
85
|
+
"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",
|
|
86
|
+
"*:data-icon:pointer-events-none *:data-icon:shrink-0 *:data-icon:transition-inherit-all"
|
|
87
|
+
].join(" "),
|
|
88
|
+
icon: "pointer-events-none shrink-0 transition-inherit-all"
|
|
89
|
+
},
|
|
90
|
+
sizes: {
|
|
91
|
+
xs: {
|
|
92
|
+
root: [
|
|
93
|
+
"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",
|
|
94
|
+
"in-data-input-wrapper:data-icon-only:p-2.5",
|
|
95
|
+
"*:data-icon:size-4"
|
|
96
|
+
].join(" "),
|
|
97
|
+
linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-3"
|
|
98
|
+
},
|
|
99
|
+
sm: {
|
|
100
|
+
root: [
|
|
101
|
+
"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",
|
|
102
|
+
"in-data-input-wrapper:data-icon-only:p-2.5",
|
|
103
|
+
"*:data-icon:size-5"
|
|
104
|
+
].join(" "),
|
|
105
|
+
linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-3"
|
|
106
|
+
},
|
|
107
|
+
md: {
|
|
108
|
+
root: [
|
|
109
|
+
"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",
|
|
110
|
+
"in-data-input-wrapper:data-icon-only:p-3",
|
|
111
|
+
"*:data-icon:size-5"
|
|
112
|
+
].join(" "),
|
|
113
|
+
linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-4"
|
|
114
|
+
},
|
|
115
|
+
lg: {
|
|
116
|
+
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",
|
|
117
|
+
linkRoot: "h-auto min-h-0 gap-1.5 px-0! py-0! text-md *:data-text:underline-offset-4"
|
|
118
|
+
},
|
|
119
|
+
xl: {
|
|
120
|
+
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",
|
|
121
|
+
linkRoot: "h-auto min-h-0 gap-1.5 px-0! py-0! text-md *:data-text:underline-offset-4"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
colors: {
|
|
125
|
+
/** Figma Hierarchy=Primary — dark neutral solid; hover lightens to fg-tertiary_hover (#404040). */
|
|
126
|
+
primary: {
|
|
127
|
+
root: [
|
|
128
|
+
"bg-primary-solid text-white",
|
|
129
|
+
skeuomorphicShadowClass,
|
|
130
|
+
skeuomorphicGradientBorderClass,
|
|
131
|
+
"hover:bg-fg-tertiary_hover dark:hover:bg-quaternary",
|
|
132
|
+
"disabled:opacity-30",
|
|
133
|
+
"data-loading:bg-fg-tertiary_hover dark:data-loading:bg-quaternary",
|
|
134
|
+
"*:data-icon:not([data-icon=loading]):text-white/70"
|
|
135
|
+
].join(" ")
|
|
136
|
+
},
|
|
137
|
+
/** Figma Hierarchy=Brand — purple solid; hover darkens to bg-brand-solid_hover (#6d28d9). */
|
|
138
|
+
brand: {
|
|
139
|
+
root: [
|
|
140
|
+
"bg-brand-solid text-primary_on-brand",
|
|
141
|
+
skeuomorphicShadowClass,
|
|
142
|
+
skeuomorphicGradientBorderClass,
|
|
143
|
+
"hover:bg-brand-solid_hover",
|
|
144
|
+
"disabled:opacity-50",
|
|
145
|
+
"data-loading:bg-brand-solid_hover",
|
|
146
|
+
"*:data-icon:not([data-icon=loading]):text-primary_on-brand"
|
|
147
|
+
].join(" ")
|
|
148
|
+
},
|
|
149
|
+
/** Figma Hierarchy=Secondary — border-primary + shadow-xs + skeuomorphic inner rim overlay. */
|
|
150
|
+
secondary: {
|
|
151
|
+
root: [
|
|
152
|
+
"border border-solid border-primary bg-primary text-secondary",
|
|
153
|
+
secondaryShadowClass,
|
|
154
|
+
"hover:bg-primary_hover hover:text-secondary_hover",
|
|
155
|
+
"disabled:opacity-50",
|
|
156
|
+
"data-loading:bg-primary_hover",
|
|
157
|
+
"*:data-icon:text-fg-secondary"
|
|
158
|
+
].join(" ")
|
|
159
|
+
},
|
|
160
|
+
/** Figma Hierarchy=Tertiary */
|
|
161
|
+
tertiary: {
|
|
162
|
+
root: [
|
|
163
|
+
"border border-transparent bg-transparent text-tertiary",
|
|
164
|
+
focusShadowPlain,
|
|
165
|
+
"hover:bg-primary_hover hover:text-tertiary_hover",
|
|
166
|
+
"disabled:opacity-50",
|
|
167
|
+
"*:data-icon:text-fg-tertiary"
|
|
168
|
+
].join(" ")
|
|
169
|
+
},
|
|
170
|
+
/** Figma Hierarchy=Link color — text + icons share brand-secondary; hover underlines with fg-brand-secondary. */
|
|
171
|
+
"link-color": {
|
|
172
|
+
root: [
|
|
173
|
+
"h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-brand-secondary shadow-none",
|
|
174
|
+
focusShadowPlain,
|
|
175
|
+
"hover:text-brand-secondary_hover",
|
|
176
|
+
"disabled:opacity-50",
|
|
177
|
+
"*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-fg-brand-secondary"
|
|
178
|
+
].join(" ")
|
|
179
|
+
},
|
|
180
|
+
/** Figma Hierarchy=Link gray — text + icons share tertiary; hover underlines with fg-quaternary. */
|
|
181
|
+
"link-gray": {
|
|
182
|
+
root: [
|
|
183
|
+
"h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-tertiary shadow-none",
|
|
184
|
+
focusShadowPlain,
|
|
185
|
+
"hover:text-tertiary_hover",
|
|
186
|
+
"disabled:opacity-50",
|
|
187
|
+
"*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-fg-quaternary"
|
|
188
|
+
].join(" ")
|
|
189
|
+
},
|
|
190
|
+
"primary-destructive": {
|
|
191
|
+
root: [
|
|
192
|
+
"bg-error-solid text-white",
|
|
193
|
+
skeuomorphicShadowClass,
|
|
194
|
+
skeuomorphicGradientBorderClass,
|
|
195
|
+
"hover:bg-error-solid_hover",
|
|
196
|
+
"disabled:opacity-50",
|
|
197
|
+
"data-loading:bg-error-solid_hover",
|
|
198
|
+
"*:data-icon:not([data-icon=loading]):text-white/70"
|
|
199
|
+
].join(" ")
|
|
200
|
+
},
|
|
201
|
+
"secondary-destructive": {
|
|
202
|
+
root: [
|
|
203
|
+
"border border-solid border-primary bg-primary text-error-primary",
|
|
204
|
+
secondaryShadowClass,
|
|
205
|
+
"hover:bg-error-primary hover:text-error-primary_hover",
|
|
206
|
+
"disabled:opacity-50",
|
|
207
|
+
"data-loading:bg-error-primary",
|
|
208
|
+
"*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
|
|
209
|
+
].join(" ")
|
|
210
|
+
},
|
|
211
|
+
"tertiary-destructive": {
|
|
212
|
+
root: [
|
|
213
|
+
"border border-transparent bg-transparent text-error-primary",
|
|
214
|
+
focusShadowPlain,
|
|
215
|
+
"hover:bg-error-primary hover:text-error-primary_hover",
|
|
216
|
+
"disabled:opacity-50",
|
|
217
|
+
"*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
|
|
218
|
+
].join(" ")
|
|
219
|
+
},
|
|
220
|
+
/** Figma Hierarchy=Link (destructive) — text + icons share error-primary; hover underlines. */
|
|
221
|
+
"link-destructive": {
|
|
222
|
+
root: [
|
|
223
|
+
"h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-error-primary shadow-none",
|
|
224
|
+
focusShadowPlain,
|
|
225
|
+
"hover:text-error-primary_hover",
|
|
226
|
+
"disabled:opacity-50",
|
|
227
|
+
"*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-current"
|
|
228
|
+
].join(" ")
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
var Button = ({
|
|
233
|
+
size = "md",
|
|
234
|
+
color = "primary",
|
|
235
|
+
children,
|
|
236
|
+
className,
|
|
237
|
+
noTextPadding,
|
|
238
|
+
iconLeading: IconLeading,
|
|
239
|
+
iconTrailing: IconTrailing,
|
|
240
|
+
isDisabled: disabled,
|
|
241
|
+
isLoading: loading,
|
|
242
|
+
showTextWhileLoading,
|
|
243
|
+
...props
|
|
244
|
+
}) => {
|
|
245
|
+
const href = "href" in props ? props.href : void 0;
|
|
246
|
+
const isIcon = (IconLeading || IconTrailing) && !children;
|
|
247
|
+
const isLinkType = ["link-gray", "link-color", "link-destructive"].includes(color);
|
|
248
|
+
noTextPadding = isLinkType || noTextPadding;
|
|
249
|
+
const commonChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
250
|
+
isValidElement(IconLeading) && IconLeading,
|
|
251
|
+
isReactComponent(IconLeading) && /* @__PURE__ */ jsx(IconLeading, { "data-icon": "leading", className: styles.common.icon }),
|
|
252
|
+
loading && /* @__PURE__ */ jsx(
|
|
253
|
+
"svg",
|
|
254
|
+
{
|
|
255
|
+
fill: "none",
|
|
256
|
+
"data-icon": "loading",
|
|
257
|
+
viewBox: "0 0 256 256",
|
|
258
|
+
"aria-hidden": true,
|
|
259
|
+
className: cx(
|
|
260
|
+
styles.common.icon,
|
|
261
|
+
"size-5 animate-spin",
|
|
262
|
+
!showTextWhileLoading && "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
|
|
263
|
+
),
|
|
264
|
+
children: /* @__PURE__ */ jsx(
|
|
265
|
+
"path",
|
|
266
|
+
{
|
|
267
|
+
fill: "currentColor",
|
|
268
|
+
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"
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
),
|
|
273
|
+
children && /* @__PURE__ */ jsx("span", { "data-text": true, className: cx("transition-inherit-all", !noTextPadding && !isLinkType && "px-0.5"), children }),
|
|
274
|
+
isValidElement(IconTrailing) && IconTrailing,
|
|
275
|
+
isReactComponent(IconTrailing) && /* @__PURE__ */ jsx(IconTrailing, { "data-icon": "trailing", className: styles.common.icon })
|
|
276
|
+
] });
|
|
277
|
+
const commonProps = {
|
|
278
|
+
"data-icon-only": isIcon ? true : void 0,
|
|
279
|
+
"data-loading": loading ? true : void 0,
|
|
280
|
+
...props,
|
|
281
|
+
isDisabled: disabled || loading,
|
|
282
|
+
className: cx(
|
|
283
|
+
styles.common.root,
|
|
284
|
+
styles.sizes[size].root,
|
|
285
|
+
styles.colors[color].root,
|
|
286
|
+
isLinkType && styles.sizes[size].linkRoot,
|
|
287
|
+
(loading || href && (disabled || loading)) && "pointer-events-none",
|
|
288
|
+
loading && (showTextWhileLoading ? "[&>*:not([data-icon=loading]):not([data-text])]:hidden" : "[&>*:not([data-icon=loading])]:invisible"),
|
|
289
|
+
className
|
|
290
|
+
),
|
|
291
|
+
children: commonChildren
|
|
292
|
+
};
|
|
293
|
+
if ("href" in commonProps) {
|
|
294
|
+
return /* @__PURE__ */ jsx(Link, { ...commonProps, href: disabled || loading ? void 0 : href });
|
|
295
|
+
}
|
|
296
|
+
return /* @__PURE__ */ jsx(Button$1, { ...commonProps, type: commonProps.type || "button", isPending: loading });
|
|
297
|
+
};
|
|
298
|
+
var HintText = ({ isInvalid, className, size = "md", ...props }) => {
|
|
299
|
+
return /* @__PURE__ */ jsx(
|
|
300
|
+
Text,
|
|
301
|
+
{
|
|
302
|
+
...props,
|
|
303
|
+
slot: isInvalid ? "errorMessage" : "description",
|
|
304
|
+
className: cx(
|
|
305
|
+
"text-sm text-tertiary",
|
|
306
|
+
// Size
|
|
307
|
+
size === "sm" && "text-xs",
|
|
308
|
+
"in-data-[input-size=sm]:text-xs",
|
|
309
|
+
// Invalid state
|
|
310
|
+
isInvalid && "text-error-primary",
|
|
311
|
+
"group-invalid:text-error-primary",
|
|
312
|
+
className
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
};
|
|
317
|
+
HintText.displayName = "HintText";
|
|
318
|
+
var Tooltip = ({
|
|
319
|
+
title,
|
|
320
|
+
description,
|
|
321
|
+
children,
|
|
322
|
+
arrow = false,
|
|
323
|
+
delay = 100,
|
|
324
|
+
closeDelay = 0,
|
|
325
|
+
trigger,
|
|
326
|
+
isDisabled,
|
|
327
|
+
isOpen,
|
|
328
|
+
defaultOpen,
|
|
329
|
+
offset = 6,
|
|
330
|
+
crossOffset,
|
|
331
|
+
placement = "top",
|
|
332
|
+
onOpenChange,
|
|
333
|
+
...tooltipProps
|
|
334
|
+
}) => {
|
|
335
|
+
const isTopOrBottomLeft = ["top left", "top end", "bottom left", "bottom end"].includes(placement);
|
|
336
|
+
const isTopOrBottomRight = ["top right", "top start", "bottom right", "bottom start"].includes(placement);
|
|
337
|
+
const calculatedCrossOffset = isTopOrBottomLeft ? -12 : isTopOrBottomRight ? 12 : 0;
|
|
338
|
+
return /* @__PURE__ */ jsxs(TooltipTrigger$1, { ...{ trigger, delay, closeDelay, isDisabled, isOpen, defaultOpen, onOpenChange }, children: [
|
|
339
|
+
children,
|
|
340
|
+
/* @__PURE__ */ jsx(
|
|
341
|
+
Tooltip$1,
|
|
342
|
+
{
|
|
343
|
+
...tooltipProps,
|
|
344
|
+
offset,
|
|
345
|
+
placement,
|
|
346
|
+
crossOffset: crossOffset ?? calculatedCrossOffset,
|
|
347
|
+
className: ({ isEntering, isExiting }) => cx(isEntering && "ease-out animate-in", isExiting && "ease-in animate-out"),
|
|
348
|
+
children: ({ isEntering, isExiting }) => /* @__PURE__ */ jsxs(
|
|
349
|
+
"div",
|
|
350
|
+
{
|
|
351
|
+
className: cx(
|
|
352
|
+
"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",
|
|
353
|
+
description ? "py-3" : "py-2",
|
|
354
|
+
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",
|
|
355
|
+
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"
|
|
356
|
+
),
|
|
357
|
+
children: [
|
|
358
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-white", children: title }),
|
|
359
|
+
description && /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-tooltip-supporting-text", children: description }),
|
|
360
|
+
arrow && /* @__PURE__ */ jsx(OverlayArrow, { children: /* @__PURE__ */ jsx(
|
|
361
|
+
"svg",
|
|
362
|
+
{
|
|
363
|
+
viewBox: "0 0 100 100",
|
|
364
|
+
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",
|
|
365
|
+
children: /* @__PURE__ */ jsx("path", { d: "M0,0 L35.858,35.858 Q50,50 64.142,35.858 L100,0 Z" })
|
|
366
|
+
}
|
|
367
|
+
) })
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
] });
|
|
374
|
+
};
|
|
375
|
+
var TooltipTrigger = ({ children, className, ...buttonProps }) => {
|
|
376
|
+
return /* @__PURE__ */ jsx(Button$1, { ...buttonProps, className: (values) => cx("h-max w-max outline-hidden", typeof className === "function" ? className(values) : className), children });
|
|
377
|
+
};
|
|
378
|
+
var Label = ({ isInvalid, isRequired, tooltip, tooltipDescription, className, ...props }) => {
|
|
379
|
+
return /* @__PURE__ */ jsxs(
|
|
380
|
+
Label$1,
|
|
381
|
+
{
|
|
382
|
+
"data-label": "true",
|
|
383
|
+
...props,
|
|
384
|
+
className: cx("flex cursor-default items-center gap-0.5 text-sm font-medium text-secondary", className),
|
|
385
|
+
children: [
|
|
386
|
+
props.children,
|
|
387
|
+
/* @__PURE__ */ jsx(
|
|
388
|
+
"span",
|
|
389
|
+
{
|
|
390
|
+
className: cx(
|
|
391
|
+
"hidden text-brand-tertiary",
|
|
392
|
+
isRequired && "block",
|
|
393
|
+
typeof isRequired === "undefined" && "group-required:block",
|
|
394
|
+
isInvalid && "text-error-primary",
|
|
395
|
+
typeof isInvalid === "undefined" && "group-invalid:text-error-primary"
|
|
396
|
+
),
|
|
397
|
+
children: "*"
|
|
398
|
+
}
|
|
399
|
+
),
|
|
400
|
+
tooltip && /* @__PURE__ */ jsx(Tooltip, { title: tooltip, description: tooltipDescription, placement: "top", children: /* @__PURE__ */ jsx(
|
|
401
|
+
TooltipTrigger,
|
|
402
|
+
{
|
|
403
|
+
isDisabled: false,
|
|
404
|
+
className: "cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
|
|
405
|
+
children: /* @__PURE__ */ jsx(QuestionIcon, { className: "size-4" })
|
|
406
|
+
}
|
|
407
|
+
) })
|
|
408
|
+
]
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
};
|
|
412
|
+
Label.displayName = "Label";
|
|
413
|
+
var inputFocusRingShadow = "border-brand ring-1 ring-inset ring-brand";
|
|
414
|
+
var inputErrorFocusRingShadow = "border-error ring-1 ring-inset ring-error";
|
|
415
|
+
createContext({});
|
|
416
|
+
var DateFieldContext = createContext({});
|
|
417
|
+
var InputDateBase = ({
|
|
418
|
+
tooltip,
|
|
419
|
+
shortcut,
|
|
420
|
+
groupRef,
|
|
421
|
+
size = "md",
|
|
422
|
+
isInvalid,
|
|
423
|
+
isDisabled,
|
|
424
|
+
icon: Icon,
|
|
425
|
+
wrapperClassName,
|
|
426
|
+
tooltipClassName,
|
|
427
|
+
iconClassName,
|
|
428
|
+
...inputProps
|
|
429
|
+
}) => {
|
|
430
|
+
const hasTrailingIcon = tooltip || isInvalid;
|
|
431
|
+
const hasLeadingIcon = Icon;
|
|
432
|
+
const context = useContext(DateFieldContext);
|
|
433
|
+
const inputSize = context?.size || size;
|
|
434
|
+
const sizes5 = sortCx({
|
|
435
|
+
sm: {
|
|
436
|
+
root: cx("px-3 py-2 text-sm", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-8.5"),
|
|
437
|
+
iconLeading: "left-3 size-4 stroke-[2.25px]",
|
|
438
|
+
iconTrailing: "right-3",
|
|
439
|
+
shortcut: "pr-2.5"
|
|
440
|
+
},
|
|
441
|
+
md: {
|
|
442
|
+
root: cx("px-3 py-2 text-md", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-10"),
|
|
443
|
+
iconLeading: "left-3 size-5",
|
|
444
|
+
iconTrailing: "right-3",
|
|
445
|
+
shortcut: "pr-2.5"
|
|
446
|
+
},
|
|
447
|
+
lg: {
|
|
448
|
+
root: cx("px-3.5 py-2.5 text-md", hasTrailingIcon && "pr-9.5", hasLeadingIcon && "pl-10.5"),
|
|
449
|
+
iconLeading: "left-3.5 size-5",
|
|
450
|
+
iconTrailing: "right-3.5",
|
|
451
|
+
shortcut: "pr-3"
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
return /* @__PURE__ */ jsxs(
|
|
455
|
+
Group,
|
|
456
|
+
{
|
|
457
|
+
...{ isDisabled, isInvalid },
|
|
458
|
+
ref: groupRef,
|
|
459
|
+
className: ({ isFocusWithin, isDisabled: isDisabled2, isInvalid: isInvalid2 }) => cx(
|
|
460
|
+
"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",
|
|
461
|
+
isFocusWithin && !isDisabled2 && !isInvalid2 && inputFocusRingShadow,
|
|
462
|
+
// Disabled state styles
|
|
463
|
+
isDisabled2 && "cursor-not-allowed opacity-50 in-data-input-wrapper:opacity-100",
|
|
464
|
+
"group-disabled:cursor-not-allowed group-disabled:opacity-50 in-data-input-wrapper:group-disabled:opacity-100",
|
|
465
|
+
// Invalid state styles
|
|
466
|
+
isInvalid2 && !isFocusWithin && "border-error_subtle",
|
|
467
|
+
"group-invalid:border-error_subtle",
|
|
468
|
+
"group-invalid:focus-within:border-error group-invalid:focus-within:ring-1 group-invalid:focus-within:ring-inset group-invalid:focus-within:ring-error",
|
|
469
|
+
isInvalid2 && isFocusWithin && inputErrorFocusRingShadow,
|
|
470
|
+
context?.wrapperClassName,
|
|
471
|
+
wrapperClassName
|
|
472
|
+
),
|
|
473
|
+
children: [
|
|
474
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: cx("pointer-events-none absolute text-fg-quaternary", sizes5[inputSize].iconLeading, context?.iconClassName, iconClassName) }),
|
|
475
|
+
/* @__PURE__ */ jsx(DateInput, { ...inputProps, className: cx("flex w-full", sizes5[size].root, typeof inputProps.className === "string" && inputProps.className), children: (segment) => /* @__PURE__ */ jsx(
|
|
476
|
+
DateSegment,
|
|
477
|
+
{
|
|
478
|
+
segment,
|
|
479
|
+
className: cx(
|
|
480
|
+
"rounded px-0.5 text-primary tabular-nums caret-transparent focus:bg-brand-solid focus:font-medium focus:text-white focus:outline-hidden",
|
|
481
|
+
// The placeholder segment.
|
|
482
|
+
segment.isPlaceholder && "text-placeholder uppercase",
|
|
483
|
+
// The separator "/" segment.
|
|
484
|
+
segment.type === "literal" && "text-fg-quaternary"
|
|
485
|
+
)
|
|
486
|
+
}
|
|
487
|
+
) }),
|
|
488
|
+
tooltip && /* @__PURE__ */ jsx(Tooltip, { title: tooltip, placement: "top", children: /* @__PURE__ */ jsx(
|
|
489
|
+
TooltipTrigger,
|
|
490
|
+
{
|
|
491
|
+
className: cx(
|
|
492
|
+
"absolute cursor-pointer text-fg-quaternary transition duration-200 group-invalid/input:hidden hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
|
|
493
|
+
sizes5[inputSize].iconTrailing,
|
|
494
|
+
context?.tooltipClassName,
|
|
495
|
+
tooltipClassName
|
|
496
|
+
),
|
|
497
|
+
children: /* @__PURE__ */ jsx(QuestionIcon, { className: "size-4 stroke-[2.25px]" })
|
|
498
|
+
}
|
|
499
|
+
) }),
|
|
500
|
+
/* @__PURE__ */ jsx(
|
|
501
|
+
InfoIcon,
|
|
502
|
+
{
|
|
503
|
+
className: cx(
|
|
504
|
+
"pointer-events-none absolute hidden size-4 stroke-[2.25px] text-fg-error-secondary group-invalid/input:block",
|
|
505
|
+
sizes5[inputSize].iconTrailing,
|
|
506
|
+
context?.tooltipClassName,
|
|
507
|
+
tooltipClassName
|
|
508
|
+
)
|
|
509
|
+
}
|
|
510
|
+
),
|
|
511
|
+
shortcut && /* @__PURE__ */ jsx(
|
|
512
|
+
"div",
|
|
513
|
+
{
|
|
514
|
+
className: cx(
|
|
515
|
+
"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",
|
|
516
|
+
sizes5[inputSize].shortcut
|
|
517
|
+
),
|
|
518
|
+
children: /* @__PURE__ */ jsx(
|
|
519
|
+
"span",
|
|
520
|
+
{
|
|
521
|
+
"aria-hidden": "true",
|
|
522
|
+
className: "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
|
|
523
|
+
children: typeof shortcut === "string" ? shortcut : "\u2318K"
|
|
524
|
+
}
|
|
525
|
+
)
|
|
526
|
+
}
|
|
527
|
+
)
|
|
528
|
+
]
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
};
|
|
532
|
+
var MOBILE_SHEET_MAX_PX = 1024;
|
|
533
|
+
function useIsMobile(breakpoint = MOBILE_SHEET_MAX_PX + 1) {
|
|
534
|
+
const [isMobile, setIsMobile] = useState(() => {
|
|
535
|
+
if (typeof window === "undefined") return false;
|
|
536
|
+
return window.matchMedia(`(max-width: ${breakpoint - 1}px)`).matches;
|
|
537
|
+
});
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
|
|
540
|
+
const handler = (e) => setIsMobile(e.matches);
|
|
541
|
+
mq.addEventListener("change", handler);
|
|
542
|
+
return () => mq.removeEventListener("change", handler);
|
|
543
|
+
}, [breakpoint]);
|
|
544
|
+
return isMobile;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// ../../components/application/date-picker/date-picker-mobile-overlay.ts
|
|
548
|
+
function resolveDatePickerMobileOptions(mobileOptions) {
|
|
549
|
+
return {
|
|
550
|
+
fullScreen: mobileOptions?.fullScreen ?? true,
|
|
551
|
+
title: mobileOptions?.title,
|
|
552
|
+
panelClassName: mobileOptions?.className,
|
|
553
|
+
contentClassName: mobileOptions?.contentClassName
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
var MOBILE_SHEET_MOTION_MS = 175;
|
|
557
|
+
var MOBILE_SHEET_ENTRY_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
|
|
558
|
+
var MOBILE_SHEET_EXIT_EASING = "cubic-bezier(0.85, 0, 1, 0.15)";
|
|
559
|
+
var MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX = 120;
|
|
560
|
+
function resolveSelectMobileOptions(mobileOptions) {
|
|
561
|
+
return {
|
|
562
|
+
sheet: mobileOptions?.sheet ?? true,
|
|
563
|
+
title: mobileOptions?.title,
|
|
564
|
+
sheetClassName: mobileOptions?.className,
|
|
565
|
+
contentClassName: mobileOptions?.contentClassName
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function useMobileSheetAnimation(open, enabled, slideEntrance = true, slideOffsetPx = MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX) {
|
|
569
|
+
const [shouldRender, setShouldRender] = useState(open);
|
|
570
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
571
|
+
useLayoutEffect(() => {
|
|
572
|
+
if (!enabled) {
|
|
573
|
+
setShouldRender(open);
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (open) {
|
|
577
|
+
setShouldRender(true);
|
|
578
|
+
}
|
|
579
|
+
}, [open, enabled]);
|
|
580
|
+
useEffect(() => {
|
|
581
|
+
if (!enabled || open) return;
|
|
582
|
+
const timer = setTimeout(() => setShouldRender(false), MOBILE_SHEET_MOTION_MS);
|
|
583
|
+
return () => clearTimeout(timer);
|
|
584
|
+
}, [open, enabled]);
|
|
585
|
+
useLayoutEffect(() => {
|
|
586
|
+
if (!enabled || open || !shouldRender) return;
|
|
587
|
+
setIsAnimating(false);
|
|
588
|
+
}, [enabled, open, shouldRender]);
|
|
589
|
+
useEffect(() => {
|
|
590
|
+
if (!enabled || !shouldRender || !open) return;
|
|
591
|
+
let raf2 = 0;
|
|
592
|
+
const raf1 = requestAnimationFrame(() => {
|
|
593
|
+
raf2 = requestAnimationFrame(() => setIsAnimating(true));
|
|
594
|
+
});
|
|
595
|
+
return () => {
|
|
596
|
+
cancelAnimationFrame(raf1);
|
|
597
|
+
if (raf2) cancelAnimationFrame(raf2);
|
|
598
|
+
};
|
|
599
|
+
}, [shouldRender, open, enabled]);
|
|
600
|
+
const motionEasing = open ? MOBILE_SHEET_ENTRY_EASING : MOBILE_SHEET_EXIT_EASING;
|
|
601
|
+
const hiddenTransform = slideEntrance ? `translateY(${slideOffsetPx}px)` : "translateY(100%)";
|
|
602
|
+
const panelStyle = enabled ? {
|
|
603
|
+
transform: isAnimating ? "translateY(0)" : hiddenTransform,
|
|
604
|
+
opacity: isAnimating ? 1 : 0,
|
|
605
|
+
transitionProperty: "transform, opacity",
|
|
606
|
+
transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
|
|
607
|
+
transitionTimingFunction: motionEasing
|
|
608
|
+
} : void 0;
|
|
609
|
+
const backdropStyle = enabled ? {
|
|
610
|
+
opacity: isAnimating ? 1 : 0,
|
|
611
|
+
transitionProperty: "opacity",
|
|
612
|
+
transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
|
|
613
|
+
transitionTimingFunction: motionEasing
|
|
614
|
+
} : void 0;
|
|
615
|
+
return { shouldRender, isAnimating, panelStyle, backdropStyle };
|
|
616
|
+
}
|
|
617
|
+
function MobileFullScreenCloseButton({ onClose }) {
|
|
618
|
+
return /* @__PURE__ */ jsxs(
|
|
619
|
+
"button",
|
|
620
|
+
{
|
|
621
|
+
type: "button",
|
|
622
|
+
onClick: (e) => {
|
|
623
|
+
e.stopPropagation();
|
|
624
|
+
onClose();
|
|
625
|
+
},
|
|
626
|
+
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)]",
|
|
627
|
+
children: [
|
|
628
|
+
/* @__PURE__ */ jsx(XIcon, { className: "size-5", "aria-hidden": "true" }),
|
|
629
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
630
|
+
]
|
|
631
|
+
}
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
function MobileFullScreenChrome({
|
|
635
|
+
title,
|
|
636
|
+
contentClassName,
|
|
637
|
+
onClose,
|
|
638
|
+
children
|
|
639
|
+
}) {
|
|
640
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: [
|
|
641
|
+
/* @__PURE__ */ jsxs(
|
|
642
|
+
"div",
|
|
643
|
+
{
|
|
644
|
+
className: cx(
|
|
645
|
+
"flex w-full shrink-0 items-center py-2 pl-4 pr-2",
|
|
646
|
+
title ? "justify-between gap-3" : "justify-end"
|
|
647
|
+
),
|
|
648
|
+
children: [
|
|
649
|
+
title ? /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-base font-semibold text-primary", children: title }) : null,
|
|
650
|
+
/* @__PURE__ */ jsx(MobileFullScreenCloseButton, { onClose })
|
|
651
|
+
]
|
|
652
|
+
}
|
|
653
|
+
),
|
|
654
|
+
/* @__PURE__ */ jsx("div", { className: cx("flex min-h-0 w-full flex-1 flex-col overflow-x-hidden overflow-y-auto", contentClassName), children })
|
|
655
|
+
] });
|
|
656
|
+
}
|
|
657
|
+
var DatePickerOverlay = ({ mobileOptions, children, className, style, offset, ...props }) => {
|
|
658
|
+
const isMobile = useIsMobile();
|
|
659
|
+
const resolvedMobile = useMemo(() => resolveDatePickerMobileOptions(mobileOptions), [mobileOptions]);
|
|
660
|
+
const useMobileFullScreen = isMobile && resolvedMobile.fullScreen;
|
|
661
|
+
const overlayState = useContext(OverlayTriggerStateContext);
|
|
662
|
+
const open = overlayState?.isOpen ?? false;
|
|
663
|
+
const { shouldRender, panelStyle } = useMobileSheetAnimation(open, useMobileFullScreen);
|
|
664
|
+
useEffect(() => {
|
|
665
|
+
if (!useMobileFullScreen || !open) return;
|
|
666
|
+
const prev = document.body.style.overflow;
|
|
667
|
+
document.body.style.overflow = "hidden";
|
|
668
|
+
return () => {
|
|
669
|
+
document.body.style.overflow = prev;
|
|
670
|
+
};
|
|
671
|
+
}, [useMobileFullScreen, open]);
|
|
672
|
+
const close = () => overlayState?.close();
|
|
673
|
+
const showMobileFullScreen = useMobileFullScreen && shouldRender;
|
|
674
|
+
const isMobileFullScreenExiting = showMobileFullScreen && !open;
|
|
675
|
+
return /* @__PURE__ */ jsx(
|
|
676
|
+
Popover$1,
|
|
677
|
+
{
|
|
678
|
+
placement: "bottom",
|
|
679
|
+
containerPadding: 0,
|
|
680
|
+
isNonModal: useMobileFullScreen,
|
|
681
|
+
...props,
|
|
682
|
+
offset: useMobileFullScreen ? 0 : offset ?? 8,
|
|
683
|
+
isExiting: isMobileFullScreenExiting,
|
|
684
|
+
...useMobileFullScreen ? { "data-date-picker-mobile-overlay": true } : {},
|
|
685
|
+
style: useMobileFullScreen ? void 0 : style,
|
|
686
|
+
className: (state) => cx(
|
|
687
|
+
"outline-hidden",
|
|
688
|
+
useMobileFullScreen && "pointer-events-none fixed! inset-0! z-50 size-full! max-w-none! border-0 bg-transparent shadow-none",
|
|
689
|
+
!useMobileFullScreen && (typeof className === "function" ? className(state) : className)
|
|
690
|
+
),
|
|
691
|
+
children: (state) => {
|
|
692
|
+
const content = typeof children === "function" ? children(state) : children;
|
|
693
|
+
if (useMobileFullScreen) {
|
|
694
|
+
return /* @__PURE__ */ jsx(
|
|
695
|
+
"div",
|
|
696
|
+
{
|
|
697
|
+
style: panelStyle,
|
|
698
|
+
className: cx(
|
|
699
|
+
"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",
|
|
700
|
+
resolvedMobile.panelClassName
|
|
701
|
+
),
|
|
702
|
+
children: /* @__PURE__ */ jsx(
|
|
703
|
+
MobileFullScreenChrome,
|
|
704
|
+
{
|
|
705
|
+
title: resolvedMobile.title,
|
|
706
|
+
contentClassName: resolvedMobile.contentClassName,
|
|
707
|
+
onClose: close,
|
|
708
|
+
children: content
|
|
709
|
+
}
|
|
710
|
+
)
|
|
711
|
+
}
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
return content;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
};
|
|
719
|
+
var sizes = {
|
|
720
|
+
xs: "size-1.5",
|
|
721
|
+
sm: "size-2",
|
|
722
|
+
md: "size-2.5",
|
|
723
|
+
lg: "size-3",
|
|
724
|
+
xl: "size-3.5",
|
|
725
|
+
"2xl": "size-4",
|
|
726
|
+
"3xl": "size-4.5",
|
|
727
|
+
"4xl": "size-5"
|
|
728
|
+
};
|
|
729
|
+
var AvatarOnlineIndicator = ({ size, status, className }) => /* @__PURE__ */ jsx(
|
|
730
|
+
"span",
|
|
731
|
+
{
|
|
732
|
+
className: cx(
|
|
733
|
+
"absolute right-0 bottom-0 flex justify-center rounded-full ring-[1.5px] ring-bg-primary",
|
|
734
|
+
status === "online" ? "bg-fg-success-secondary" : "bg-utility-neutral-300",
|
|
735
|
+
sizes[size],
|
|
736
|
+
className
|
|
737
|
+
),
|
|
738
|
+
style: {
|
|
739
|
+
backgroundImage: "radial-gradient(43.75% 43.75% at 50% 28.75%, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.00) 100%), radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.00) 74.66%, rgba(255, 255, 255, 0.18) 100%), radial-gradient(75% 75% at 50% 0%, rgba(255, 255, 255, 0.00) 0%, rgba(255, 255, 255, 0.00) 50%, rgba(255, 255, 255, 0.08) 99%, rgba(255, 255, 255, 0.00) 100%)"
|
|
740
|
+
},
|
|
741
|
+
children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 7.2 2.85", fill: "none", className: "mt-[10%] h-[20%] w-[60%]", children: [
|
|
742
|
+
/* @__PURE__ */ jsx(
|
|
743
|
+
"path",
|
|
744
|
+
{
|
|
745
|
+
d: "M7.2 1.83107C7.2 2.84235 5.58823 2.19729 3.6 2.19729C1.61177 2.19729 0 2.84235 0 1.83107C0 0.8198 1.61177 0 3.6 0C5.58823 0 7.2 0.8198 7.2 1.83107Z",
|
|
746
|
+
fill: "url(#reflection-gradient)",
|
|
747
|
+
fillOpacity: "0.4"
|
|
748
|
+
}
|
|
749
|
+
),
|
|
750
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: "reflection-gradient", x1: "3.6", y1: "0", x2: "3.6", y2: "2.4", gradientUnits: "userSpaceOnUse", children: [
|
|
751
|
+
/* @__PURE__ */ jsx("stop", { stopColor: "white" }),
|
|
752
|
+
/* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0.1" })
|
|
753
|
+
] }) })
|
|
754
|
+
] })
|
|
755
|
+
}
|
|
756
|
+
);
|
|
757
|
+
var sizes2 = {
|
|
758
|
+
xs: "size-2.5",
|
|
759
|
+
sm: "size-3",
|
|
760
|
+
md: "size-3.5",
|
|
761
|
+
lg: "size-4",
|
|
762
|
+
xl: "size-4.5",
|
|
763
|
+
"2xl": "size-5",
|
|
764
|
+
"3xl": "size-6",
|
|
765
|
+
"4xl": "size-8"
|
|
766
|
+
};
|
|
767
|
+
var VerifiedTick = ({ size, className }) => /* @__PURE__ */ jsxs("svg", { className: cx("z-10 text-utility-blue-500", sizes2[size], className), viewBox: "0 0 10 10", fill: "none", children: [
|
|
768
|
+
/* @__PURE__ */ jsx(
|
|
769
|
+
"path",
|
|
770
|
+
{
|
|
771
|
+
d: "M7.72237 1.77098C7.81734 2.00068 7.99965 2.18326 8.2292 2.27858L9.03413 2.61199C9.26384 2.70714 9.44635 2.88965 9.5415 3.11936C9.63665 3.34908 9.63665 3.60718 9.5415 3.83689L9.20833 4.64125C9.11313 4.87106 9.113 5.12943 9.20863 5.35913L9.54122 6.16325C9.58839 6.27702 9.61268 6.39897 9.6127 6.52214C9.61272 6.6453 9.58847 6.76726 9.54134 6.88105C9.4942 6.99484 9.42511 7.09823 9.33801 7.18531C9.2509 7.27238 9.14749 7.34144 9.03369 7.38854L8.22934 7.72171C7.99964 7.81669 7.81706 7.99899 7.72174 8.22855L7.38833 9.03348C7.29318 9.26319 7.11067 9.4457 6.88096 9.54085C6.65124 9.636 6.39314 9.636 6.16343 9.54085L5.35907 9.20767C5.12935 9.11276 4.87134 9.11295 4.64177 9.20821L3.83684 9.54115C3.60725 9.63608 3.34937 9.636 3.11984 9.54092C2.89032 9.44585 2.70791 9.26356 2.6127 9.03409L2.27918 8.22892C2.18421 7.99923 2.0019 7.81665 1.77235 7.72133L0.967421 7.38792C0.737807 7.29281 0.555355 7.11041 0.460169 6.88083C0.364983 6.65125 0.364854 6.39327 0.45981 6.16359L0.792984 5.35924C0.8879 5.12952 0.887707 4.87151 0.792445 4.64193L0.459749 3.83642C0.41258 3.72265 0.388291 3.60069 0.388272 3.47753C0.388252 3.35436 0.412501 3.2324 0.459634 3.11861C0.506767 3.00482 0.57586 2.90144 0.662965 2.81436C0.75007 2.72728 0.853479 2.65822 0.967283 2.61113L1.77164 2.27795C2.00113 2.18306 2.1836 2.00099 2.27899 1.7717L2.6124 0.966768C2.70755 0.737054 2.89006 0.554547 3.11978 0.459397C3.34949 0.364246 3.60759 0.364246 3.83731 0.459397L4.64166 0.792571C4.87138 0.887487 5.12939 0.887293 5.35897 0.792031L6.16424 0.459913C6.39392 0.364816 6.65197 0.364836 6.88164 0.459968C7.11131 0.555099 7.29379 0.737554 7.38895 0.967208L7.72247 1.77238L7.72237 1.77098Z",
|
|
772
|
+
className: "fill-current"
|
|
773
|
+
}
|
|
774
|
+
),
|
|
775
|
+
/* @__PURE__ */ jsx(
|
|
776
|
+
"path",
|
|
777
|
+
{
|
|
778
|
+
fillRule: "evenodd",
|
|
779
|
+
clipRule: "evenodd",
|
|
780
|
+
d: "M6.95829 3.68932C7.02509 3.58439 7.04747 3.45723 7.02051 3.3358C6.99356 3.21437 6.91946 3.10862 6.81454 3.04182C6.70961 2.97502 6.58245 2.95264 6.46102 2.97959C6.33959 3.00655 6.23384 3.08064 6.16704 3.18557L4.33141 6.06995L3.49141 5.01995C3.41375 4.92281 3.30069 4.8605 3.17709 4.84673C3.05349 4.83296 2.92949 4.86885 2.83235 4.94651C2.73522 5.02417 2.67291 5.13723 2.65914 5.26083C2.64536 5.38443 2.68125 5.50843 2.75891 5.60557L4.00891 7.16807C4.0555 7.22638 4.11533 7.27271 4.18344 7.30323C4.25154 7.33375 4.32595 7.34757 4.40047 7.34353C4.47499 7.3395 4.54747 7.31773 4.61188 7.28004C4.67629 7.24234 4.73077 7.18981 4.77079 7.12682L6.95829 3.68932Z",
|
|
781
|
+
fill: "white"
|
|
782
|
+
}
|
|
783
|
+
)
|
|
784
|
+
] });
|
|
785
|
+
var AvatarCount = ({ count, className }) => /* @__PURE__ */ jsx("div", { className: cx("absolute right-0 bottom-0 p-px", className), children: /* @__PURE__ */ jsx("div", { className: "flex size-3.5 items-center justify-center rounded-full bg-fg-error-primary text-center text-[10px] leading-[13px] font-bold text-white", children: count }) });
|
|
786
|
+
var styles2 = {
|
|
787
|
+
xs: { root: "size-6", rootWithBorder: "p-px", initials: "text-xs font-semibold", icon: "size-4" },
|
|
788
|
+
sm: { root: "size-8", rootWithBorder: "p-px", initials: "text-sm font-semibold", icon: "size-5" },
|
|
789
|
+
md: { root: "size-10", rootWithBorder: "p-px", initials: "text-md font-semibold", icon: "size-6" },
|
|
790
|
+
lg: { root: "size-12", rootWithBorder: "p-[1.5px]", initials: "text-lg font-semibold", icon: "size-7" },
|
|
791
|
+
xl: { root: "size-14", rootWithBorder: "p-0.5", initials: "text-xl font-semibold", icon: "size-8" },
|
|
792
|
+
"2xl": { root: "size-16", rootWithBorder: "p-0.5", initials: "text-display-xs font-semibold", icon: "size-8" }
|
|
793
|
+
};
|
|
794
|
+
var Avatar = ({
|
|
795
|
+
size = "md",
|
|
796
|
+
src,
|
|
797
|
+
alt,
|
|
798
|
+
initials,
|
|
799
|
+
placeholder,
|
|
800
|
+
placeholderIcon: PlaceholderIcon,
|
|
801
|
+
border,
|
|
802
|
+
badge,
|
|
803
|
+
status,
|
|
804
|
+
verified,
|
|
805
|
+
count,
|
|
806
|
+
focusable = false,
|
|
807
|
+
rounded = true,
|
|
808
|
+
className,
|
|
809
|
+
contentClassName
|
|
810
|
+
}) => {
|
|
811
|
+
const [isFailed, setIsFailed] = useState(false);
|
|
812
|
+
const canShowImage = src && !isFailed;
|
|
813
|
+
const renderMainContent = () => {
|
|
814
|
+
if (canShowImage) {
|
|
815
|
+
return /* @__PURE__ */ jsx("img", { "data-avatar-img": true, className: "size-full object-cover", src, alt, onError: () => setIsFailed(true) });
|
|
816
|
+
}
|
|
817
|
+
if (initials) {
|
|
818
|
+
return /* @__PURE__ */ jsx("span", { className: cx("text-quaternary", styles2[size].initials), children: initials });
|
|
819
|
+
}
|
|
820
|
+
if (PlaceholderIcon) {
|
|
821
|
+
return /* @__PURE__ */ jsx(PlaceholderIcon, { className: cx("text-fg-quaternary", styles2[size].icon) });
|
|
822
|
+
}
|
|
823
|
+
return placeholder || /* @__PURE__ */ jsx(UserIcon, { className: cx("text-fg-quaternary", styles2[size].icon) });
|
|
824
|
+
};
|
|
825
|
+
const renderBadgeContent = () => {
|
|
826
|
+
if (status) {
|
|
827
|
+
return /* @__PURE__ */ jsx(AvatarOnlineIndicator, { status, size });
|
|
828
|
+
}
|
|
829
|
+
if (verified) {
|
|
830
|
+
return /* @__PURE__ */ jsx(VerifiedTick, { size, className: cx("absolute right-0 bottom-0", size === "xs" && "-right-px -bottom-px") });
|
|
831
|
+
}
|
|
832
|
+
if (count) {
|
|
833
|
+
return /* @__PURE__ */ jsx(AvatarCount, { count });
|
|
834
|
+
}
|
|
835
|
+
return badge;
|
|
836
|
+
};
|
|
837
|
+
return /* @__PURE__ */ jsxs(
|
|
838
|
+
"div",
|
|
839
|
+
{
|
|
840
|
+
"data-avatar": true,
|
|
841
|
+
className: cx(
|
|
842
|
+
"relative inline-flex shrink-0 rounded-[7px]",
|
|
843
|
+
rounded && "rounded-full",
|
|
844
|
+
// Focus styles
|
|
845
|
+
focusable && "outline-none group-focus-visible:[box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]",
|
|
846
|
+
border && "ring-1 ring-secondary_alt",
|
|
847
|
+
border && styles2[size].rootWithBorder,
|
|
848
|
+
styles2[size].root,
|
|
849
|
+
className
|
|
850
|
+
),
|
|
851
|
+
children: [
|
|
852
|
+
/* @__PURE__ */ jsx(
|
|
853
|
+
"div",
|
|
854
|
+
{
|
|
855
|
+
className: cx(
|
|
856
|
+
"relative inline-flex size-full shrink-0 items-center justify-center overflow-hidden rounded-md bg-tertiary outline-[0.5px] -outline-offset-[0.5px] outline-black/16 before:inset-[0.5px]",
|
|
857
|
+
rounded && "rounded-full",
|
|
858
|
+
canShowImage && size !== "xs" && "before:absolute before:inset-0 before:rounded-[inherit] before:border before:border-white/32 before:mask-[linear-gradient(to_bottom,black_0%,transparent_25%,transparent_75%,black_100%)]",
|
|
859
|
+
contentClassName
|
|
860
|
+
),
|
|
861
|
+
children: renderMainContent()
|
|
862
|
+
}
|
|
863
|
+
),
|
|
864
|
+
renderBadgeContent()
|
|
865
|
+
]
|
|
866
|
+
}
|
|
867
|
+
);
|
|
868
|
+
};
|
|
869
|
+
function MobileSheetCloseButton({ onClose }) {
|
|
870
|
+
return /* @__PURE__ */ jsxs(
|
|
871
|
+
"button",
|
|
872
|
+
{
|
|
873
|
+
type: "button",
|
|
874
|
+
onClick: (e) => {
|
|
875
|
+
e.stopPropagation();
|
|
876
|
+
onClose();
|
|
877
|
+
},
|
|
878
|
+
className: "flex size-12 shrink-0 cursor-pointer items-center justify-center rounded-full 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)]",
|
|
879
|
+
children: [
|
|
880
|
+
/* @__PURE__ */ jsx(XIcon, { className: "size-5", "aria-hidden": "true" }),
|
|
881
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
882
|
+
]
|
|
883
|
+
}
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
function MobileSheetChrome({
|
|
887
|
+
title,
|
|
888
|
+
contentClassName,
|
|
889
|
+
onClose,
|
|
890
|
+
children
|
|
891
|
+
}) {
|
|
892
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
893
|
+
/* @__PURE__ */ jsxs("div", { className: cx("flex w-full shrink-0 items-center py-2 pl-4 pr-2", title ? "justify-between gap-3" : "justify-end"), children: [
|
|
894
|
+
title ? /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-base font-semibold text-primary", children: title }) : null,
|
|
895
|
+
/* @__PURE__ */ jsx(MobileSheetCloseButton, { onClose })
|
|
896
|
+
] }),
|
|
897
|
+
/* @__PURE__ */ jsx(
|
|
898
|
+
"div",
|
|
899
|
+
{
|
|
900
|
+
className: cx(
|
|
901
|
+
"min-h-0 flex-1 overflow-y-auto pb-[calc(5rem+env(safe-area-inset-bottom,0px))]",
|
|
902
|
+
contentClassName
|
|
903
|
+
),
|
|
904
|
+
children
|
|
905
|
+
}
|
|
906
|
+
)
|
|
907
|
+
] });
|
|
908
|
+
}
|
|
909
|
+
var Popover = ({ mobileOptions, children, size, className, style, compoundContent = false, ...props }) => {
|
|
910
|
+
const isMobile = useIsMobile();
|
|
911
|
+
const resolvedMobile = useMemo(() => resolveSelectMobileOptions(mobileOptions), [mobileOptions]);
|
|
912
|
+
const useMobileSheet = isMobile && resolvedMobile.sheet;
|
|
913
|
+
const overlayState = useContext(OverlayTriggerStateContext);
|
|
914
|
+
const open = overlayState?.isOpen ?? false;
|
|
915
|
+
const { shouldRender, panelStyle, backdropStyle } = useMobileSheetAnimation(open, useMobileSheet);
|
|
916
|
+
useEffect(() => {
|
|
917
|
+
if (!useMobileSheet || !open) return;
|
|
918
|
+
const prev = document.body.style.overflow;
|
|
919
|
+
document.body.style.overflow = "hidden";
|
|
920
|
+
return () => {
|
|
921
|
+
document.body.style.overflow = prev;
|
|
922
|
+
};
|
|
923
|
+
}, [useMobileSheet, open]);
|
|
924
|
+
const close = () => overlayState?.close();
|
|
925
|
+
const showMobileSheet = useMobileSheet && shouldRender;
|
|
926
|
+
const isMobileSheetExiting = showMobileSheet && !open;
|
|
927
|
+
const mobileScrim = useMobileSheet && shouldRender && typeof document !== "undefined" ? createPortal(
|
|
928
|
+
/* @__PURE__ */ jsx(
|
|
929
|
+
"div",
|
|
930
|
+
{
|
|
931
|
+
className: "fixed inset-0 z-50 bg-overlay/70",
|
|
932
|
+
style: backdropStyle,
|
|
933
|
+
onClick: close,
|
|
934
|
+
"aria-hidden": "true"
|
|
935
|
+
}
|
|
936
|
+
),
|
|
937
|
+
document.body
|
|
938
|
+
) : null;
|
|
939
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
940
|
+
mobileScrim,
|
|
941
|
+
/* @__PURE__ */ jsx(
|
|
942
|
+
Popover$1,
|
|
943
|
+
{
|
|
944
|
+
placement: "bottom",
|
|
945
|
+
containerPadding: 0,
|
|
946
|
+
offset: 4,
|
|
947
|
+
...props,
|
|
948
|
+
isExiting: isMobileSheetExiting,
|
|
949
|
+
...useMobileSheet ? { "data-select-mobile-sheet": true } : {},
|
|
950
|
+
style: useMobileSheet ? { ...panelStyle, ...style } : style,
|
|
951
|
+
className: (state) => cx(
|
|
952
|
+
"outline-hidden",
|
|
953
|
+
!useMobileSheet && [
|
|
954
|
+
"w-(--trigger-width) origin-(--trigger-anchor-point) rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
|
|
955
|
+
compoundContent ? "overflow-hidden outline-hidden" : "overflow-x-hidden overflow-y-auto py-1 outline-hidden",
|
|
956
|
+
state.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",
|
|
957
|
+
state.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",
|
|
958
|
+
!compoundContent && size === "sm" && "max-h-56!",
|
|
959
|
+
!compoundContent && size === "md" && "max-h-64!",
|
|
960
|
+
!compoundContent && size === "lg" && "max-h-80!"
|
|
961
|
+
],
|
|
962
|
+
useMobileSheet && [
|
|
963
|
+
"fixed! inset-x-0! bottom-0! top-auto! left-0! right-0! z-[51] flex w-full! max-w-none! flex-col overflow-hidden rounded-t-2xl rounded-b-none border-x-0 border-t border-secondary bg-primary shadow-xl",
|
|
964
|
+
"max-h-[min(90dvh,calc(100dvh-env(safe-area-inset-bottom,0px)))]",
|
|
965
|
+
resolvedMobile.sheetClassName
|
|
966
|
+
],
|
|
967
|
+
typeof className === "function" ? className(state) : className
|
|
968
|
+
),
|
|
969
|
+
children: (state) => {
|
|
970
|
+
const content = typeof children === "function" ? children(state) : children;
|
|
971
|
+
if (useMobileSheet) {
|
|
972
|
+
return /* @__PURE__ */ jsx(
|
|
973
|
+
MobileSheetChrome,
|
|
974
|
+
{
|
|
975
|
+
title: resolvedMobile.title,
|
|
976
|
+
contentClassName: resolvedMobile.contentClassName,
|
|
977
|
+
onClose: close,
|
|
978
|
+
children: content
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
return content;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
)
|
|
986
|
+
] });
|
|
987
|
+
};
|
|
988
|
+
var sizes3 = {
|
|
989
|
+
sm: {
|
|
990
|
+
root: "py-2 pl-3 pr-2.5 gap-2 *:data-icon:size-4 *:data-icon:stroke-[2.25px]",
|
|
991
|
+
withIcon: "",
|
|
992
|
+
text: "text-sm",
|
|
993
|
+
textContainer: "gap-x-1.5",
|
|
994
|
+
shortcut: "pr-2.5"
|
|
995
|
+
},
|
|
996
|
+
md: { root: "py-2 px-3 gap-2 *:data-icon:size-5", withIcon: "", text: "text-md", textContainer: "gap-x-1.5", shortcut: "pr-2.5" },
|
|
997
|
+
lg: { root: "py-2.5 px-3.5 gap-2 *:data-icon:size-5", withIcon: "", text: "text-md", textContainer: "gap-x-1.5", shortcut: "pr-3" }
|
|
998
|
+
};
|
|
999
|
+
var searchSizes = {
|
|
1000
|
+
sm: { wrapper: "py-1", root: "px-3 py-2 gap-2 *:data-icon:size-4 *:data-icon:stroke-[2.25px]", text: "text-sm" },
|
|
1001
|
+
md: { wrapper: "py-0.5", root: "px-3 py-2 gap-2 *:data-icon:size-5", text: "text-md" },
|
|
1002
|
+
lg: { wrapper: "py-0.5", root: "px-3.5 py-2.5 gap-2 *:data-icon:size-5", text: "text-md" }
|
|
1003
|
+
};
|
|
1004
|
+
var SelectContext = createContext({ size: "md" });
|
|
1005
|
+
function hasResizeObserver() {
|
|
1006
|
+
return typeof window.ResizeObserver !== "undefined";
|
|
1007
|
+
}
|
|
1008
|
+
function useResizeObserver(options) {
|
|
1009
|
+
const { ref, box, onResize } = options;
|
|
1010
|
+
useEffect(() => {
|
|
1011
|
+
const element = ref?.current;
|
|
1012
|
+
if (!element) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
if (!hasResizeObserver()) {
|
|
1016
|
+
window.addEventListener("resize", onResize, false);
|
|
1017
|
+
return () => {
|
|
1018
|
+
window.removeEventListener("resize", onResize, false);
|
|
1019
|
+
};
|
|
1020
|
+
} else {
|
|
1021
|
+
const resizeObserverInstance = new window.ResizeObserver((entries) => {
|
|
1022
|
+
if (!entries.length) {
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
onResize();
|
|
1026
|
+
});
|
|
1027
|
+
resizeObserverInstance.observe(element, { box });
|
|
1028
|
+
return () => {
|
|
1029
|
+
if (element) {
|
|
1030
|
+
resizeObserverInstance.unobserve(element);
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
}, [onResize, ref, box]);
|
|
1035
|
+
}
|
|
1036
|
+
var ComboBoxMobileTrigger = ({ size, placeholder, icon: IconProp, isInvalid, onPointerEnter, ref }) => {
|
|
1037
|
+
const state = useContext(ComboBoxStateContext);
|
|
1038
|
+
const selectedItem = state?.selectedItem?.value ?? null;
|
|
1039
|
+
return /* @__PURE__ */ jsxs(
|
|
1040
|
+
Button$1,
|
|
1041
|
+
{
|
|
1042
|
+
ref,
|
|
1043
|
+
onPress: () => state?.open(),
|
|
1044
|
+
onPointerEnter,
|
|
1045
|
+
className: ({ isFocusVisible, isDisabled }) => cx(
|
|
1046
|
+
"relative flex w-full cursor-pointer items-center gap-2 rounded-lg border border-solid border-primary bg-primary text-left shadow-xs outline-hidden transition-[border-color,box-shadow] duration-100 ease-linear",
|
|
1047
|
+
isDisabled && "cursor-not-allowed opacity-50",
|
|
1048
|
+
!isInvalid && (isFocusVisible || state?.isOpen) && inputFocusRingShadow,
|
|
1049
|
+
isInvalid && !(isFocusVisible || state?.isOpen) && "border-error_subtle",
|
|
1050
|
+
isInvalid && (isFocusVisible || state?.isOpen) && inputErrorFocusRingShadow,
|
|
1051
|
+
"*:data-icon:shrink-0 *:data-icon:text-fg-quaternary",
|
|
1052
|
+
sizes3[size].root
|
|
1053
|
+
),
|
|
1054
|
+
children: [
|
|
1055
|
+
isReactComponent(IconProp) ? /* @__PURE__ */ jsx(IconProp, { "data-icon": true, className: "pointer-events-none", "aria-hidden": "true" }) : isValidElement(IconProp) ? IconProp : /* @__PURE__ */ jsx(MagnifyingGlassIcon, { "data-icon": true, className: "pointer-events-none", "aria-hidden": "true" }),
|
|
1056
|
+
selectedItem ? /* @__PURE__ */ jsxs("section", { className: cx("flex w-full truncate", sizes3[size].textContainer), children: [
|
|
1057
|
+
/* @__PURE__ */ jsx("p", { className: cx("truncate font-medium text-primary", sizes3[size].text), children: selectedItem.label }),
|
|
1058
|
+
selectedItem.supportingText && /* @__PURE__ */ jsx("p", { className: cx("text-tertiary", sizes3[size].text), children: selectedItem.supportingText })
|
|
1059
|
+
] }) : /* @__PURE__ */ jsx("p", { className: cx("truncate text-placeholder", sizes3[size].text), children: placeholder })
|
|
1060
|
+
]
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
};
|
|
1064
|
+
var ComboBoxSheetSearch = ({ size, placeholder, icon: IconProp }) => /* @__PURE__ */ jsx("div", { className: cx("shrink-0 border-b border-secondary", searchSizes[size].wrapper), children: /* @__PURE__ */ jsxs("div", { className: cx("flex items-center", searchSizes[size].root), children: [
|
|
1065
|
+
isReactComponent(IconProp) ? /* @__PURE__ */ jsx(IconProp, { "data-icon": true, "aria-hidden": "true", className: "shrink-0 text-fg-quaternary" }) : isValidElement(IconProp) ? IconProp : /* @__PURE__ */ jsx(MagnifyingGlassIcon, { "data-icon": true, "aria-hidden": "true", className: "shrink-0 text-fg-quaternary" }),
|
|
1066
|
+
/* @__PURE__ */ jsx(
|
|
1067
|
+
Input,
|
|
1068
|
+
{
|
|
1069
|
+
placeholder,
|
|
1070
|
+
className: cx(
|
|
1071
|
+
"w-full appearance-none bg-transparent text-primary caret-alpha-black/90 outline-hidden placeholder:text-placeholder",
|
|
1072
|
+
searchSizes[size].text
|
|
1073
|
+
)
|
|
1074
|
+
}
|
|
1075
|
+
)
|
|
1076
|
+
] }) });
|
|
1077
|
+
var ComboBoxValue = ({ size, shortcut, placeholder, shortcutClassName, icon: IconProp, isInvalid, ref, ...otherProps }) => {
|
|
1078
|
+
const state = useContext(ComboBoxStateContext);
|
|
1079
|
+
const value = state?.selectedItem?.value || null;
|
|
1080
|
+
const inputValue = state?.inputValue || null;
|
|
1081
|
+
const first = inputValue?.split(value?.supportingText)?.[0] || "";
|
|
1082
|
+
const last = inputValue?.split(first)[1];
|
|
1083
|
+
return /* @__PURE__ */ jsxs(
|
|
1084
|
+
Group,
|
|
1085
|
+
{
|
|
1086
|
+
ref,
|
|
1087
|
+
...otherProps,
|
|
1088
|
+
isInvalid,
|
|
1089
|
+
className: ({ isDisabled, isInvalid: isGroupInvalid }) => cx(
|
|
1090
|
+
"relative flex w-full items-center gap-2 rounded-lg border border-solid border-primary bg-primary shadow-xs outline-hidden transition-[border-color,box-shadow] duration-100 ease-linear",
|
|
1091
|
+
isDisabled && "cursor-not-allowed opacity-50",
|
|
1092
|
+
!isGroupInvalid && state?.isOpen && inputFocusRingShadow,
|
|
1093
|
+
!isGroupInvalid && "has-[input:focus-visible]:border-brand has-[input:focus-visible]:ring-1 has-[input:focus-visible]:ring-inset has-[input:focus-visible]:ring-brand",
|
|
1094
|
+
isGroupInvalid && !state?.isOpen && "border-error_subtle",
|
|
1095
|
+
isGroupInvalid && state?.isOpen && inputErrorFocusRingShadow,
|
|
1096
|
+
isGroupInvalid && "has-[input:focus-visible]:border-error has-[input:focus-visible]:ring-1 has-[input:focus-visible]:ring-inset has-[input:focus-visible]:ring-error",
|
|
1097
|
+
// Icon styles
|
|
1098
|
+
"*:data-icon:shrink-0 *:data-icon:text-fg-quaternary",
|
|
1099
|
+
sizes3[size].root
|
|
1100
|
+
),
|
|
1101
|
+
children: [
|
|
1102
|
+
isReactComponent(IconProp) ? /* @__PURE__ */ jsx(IconProp, { "data-icon": true, className: "pointer-events-none", "aria-hidden": "true" }) : isValidElement(IconProp) ? IconProp : /* @__PURE__ */ jsx(MagnifyingGlassIcon, { "data-icon": true, className: "pointer-events-none", "aria-hidden": "true" }),
|
|
1103
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex w-full items-center", children: [
|
|
1104
|
+
inputValue && /* @__PURE__ */ jsxs("span", { className: cx("absolute top-1/2 z-0 inline-flex w-full -translate-y-1/2 truncate", sizes3[size].textContainer), "aria-hidden": "true", children: [
|
|
1105
|
+
/* @__PURE__ */ jsx("p", { className: cx("font-medium text-primary", sizes3[size].text), children: first }),
|
|
1106
|
+
last && /* @__PURE__ */ jsx("p", { className: cx("-ml-0.75 text-tertiary", sizes3[size].text), children: last })
|
|
1107
|
+
] }),
|
|
1108
|
+
/* @__PURE__ */ jsx(
|
|
1109
|
+
Input,
|
|
1110
|
+
{
|
|
1111
|
+
placeholder,
|
|
1112
|
+
className: cx(
|
|
1113
|
+
"z-10 w-full appearance-none bg-transparent text-transparent caret-alpha-black/90 placeholder:text-placeholder focus:outline-hidden disabled:cursor-not-allowed",
|
|
1114
|
+
sizes3[size].text
|
|
1115
|
+
)
|
|
1116
|
+
}
|
|
1117
|
+
)
|
|
1118
|
+
] }),
|
|
1119
|
+
shortcut && /* @__PURE__ */ jsx(
|
|
1120
|
+
"div",
|
|
1121
|
+
{
|
|
1122
|
+
className: cx(
|
|
1123
|
+
"absolute inset-y-0.5 right-0.5 z-10 hidden items-center rounded-r-[inherit] bg-linear-to-r from-transparent to-bg-primary to-40% pl-8 md:flex",
|
|
1124
|
+
sizes3[size].shortcut,
|
|
1125
|
+
shortcutClassName
|
|
1126
|
+
),
|
|
1127
|
+
children: /* @__PURE__ */ jsx(
|
|
1128
|
+
"span",
|
|
1129
|
+
{
|
|
1130
|
+
className: "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
|
|
1131
|
+
"aria-hidden": "true",
|
|
1132
|
+
children: "\u2318K"
|
|
1133
|
+
}
|
|
1134
|
+
)
|
|
1135
|
+
}
|
|
1136
|
+
)
|
|
1137
|
+
]
|
|
1138
|
+
}
|
|
1139
|
+
);
|
|
1140
|
+
};
|
|
1141
|
+
var ComboBox = ({
|
|
1142
|
+
placeholder = "Search",
|
|
1143
|
+
shortcut = true,
|
|
1144
|
+
size = "md",
|
|
1145
|
+
children,
|
|
1146
|
+
items,
|
|
1147
|
+
shortcutClassName,
|
|
1148
|
+
icon,
|
|
1149
|
+
hideRequiredIndicator,
|
|
1150
|
+
mobileOptions,
|
|
1151
|
+
...otherProps
|
|
1152
|
+
}) => {
|
|
1153
|
+
const isMobile = useIsMobile();
|
|
1154
|
+
const resolvedMobile = useMemo(() => resolveSelectMobileOptions(mobileOptions), [mobileOptions]);
|
|
1155
|
+
const useMobileSheet = isMobile && resolvedMobile.sheet;
|
|
1156
|
+
const triggerRef = useRef(null);
|
|
1157
|
+
const [popoverWidth, setPopoverWidth] = useState("");
|
|
1158
|
+
const onResize = useCallback(() => {
|
|
1159
|
+
if (!triggerRef.current) return;
|
|
1160
|
+
const divRect = triggerRef.current.getBoundingClientRect();
|
|
1161
|
+
setPopoverWidth(divRect.width + "px");
|
|
1162
|
+
}, []);
|
|
1163
|
+
useResizeObserver({
|
|
1164
|
+
ref: triggerRef,
|
|
1165
|
+
box: "border-box",
|
|
1166
|
+
onResize
|
|
1167
|
+
});
|
|
1168
|
+
return /* @__PURE__ */ jsx(SelectContext.Provider, { value: { size }, children: /* @__PURE__ */ jsx(ComboBox$1, { menuTrigger: useMobileSheet ? "manual" : "focus", ...otherProps, children: (state) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
1169
|
+
otherProps.label && /* @__PURE__ */ jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: otherProps.tooltip, children: otherProps.label }),
|
|
1170
|
+
useMobileSheet ? /* @__PURE__ */ jsx(
|
|
1171
|
+
ComboBoxMobileTrigger,
|
|
1172
|
+
{
|
|
1173
|
+
ref: triggerRef,
|
|
1174
|
+
placeholder,
|
|
1175
|
+
icon,
|
|
1176
|
+
size,
|
|
1177
|
+
isInvalid: state.isInvalid,
|
|
1178
|
+
onPointerEnter: onResize
|
|
1179
|
+
}
|
|
1180
|
+
) : /* @__PURE__ */ jsx(
|
|
1181
|
+
ComboBoxValue,
|
|
1182
|
+
{
|
|
1183
|
+
ref: triggerRef,
|
|
1184
|
+
placeholder,
|
|
1185
|
+
shortcut,
|
|
1186
|
+
shortcutClassName,
|
|
1187
|
+
icon,
|
|
1188
|
+
size,
|
|
1189
|
+
isInvalid: state.isInvalid,
|
|
1190
|
+
onFocus: onResize,
|
|
1191
|
+
onPointerEnter: onResize
|
|
1192
|
+
}
|
|
1193
|
+
),
|
|
1194
|
+
/* @__PURE__ */ jsx(
|
|
1195
|
+
Popover,
|
|
1196
|
+
{
|
|
1197
|
+
size,
|
|
1198
|
+
triggerRef,
|
|
1199
|
+
compoundContent: useMobileSheet,
|
|
1200
|
+
style: useMobileSheet ? void 0 : { width: popoverWidth },
|
|
1201
|
+
className: otherProps.popoverClassName,
|
|
1202
|
+
mobileOptions: { title: otherProps.label, ...mobileOptions },
|
|
1203
|
+
children: useMobileSheet ? /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-col overflow-hidden outline-hidden", children: [
|
|
1204
|
+
/* @__PURE__ */ jsx(ComboBoxSheetSearch, { size, placeholder, icon }),
|
|
1205
|
+
/* @__PURE__ */ jsx(ListBox, { items, className: "min-h-0 flex-1 overflow-y-auto py-1 outline-hidden", children })
|
|
1206
|
+
] }) : /* @__PURE__ */ jsx(ListBox, { items, className: "size-full outline-hidden", children })
|
|
1207
|
+
}
|
|
1208
|
+
),
|
|
1209
|
+
otherProps.hint && /* @__PURE__ */ jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === "sm" && "text-xs"), children: otherProps.hint })
|
|
1210
|
+
] }) }) });
|
|
1211
|
+
};
|
|
1212
|
+
var CHECKBOX_TICK_DELAY_MS = 60;
|
|
1213
|
+
var CHECKBOX_TICK_DRAW_MS = 100;
|
|
1214
|
+
function CheckboxAnimatedCheckMark({ pixelSize, className }) {
|
|
1215
|
+
const pathRef = useRef(null);
|
|
1216
|
+
useLayoutEffect(() => {
|
|
1217
|
+
const path = pathRef.current;
|
|
1218
|
+
if (!path || typeof path.getTotalLength !== "function") return;
|
|
1219
|
+
const len = path.getTotalLength();
|
|
1220
|
+
if (len <= 0) return;
|
|
1221
|
+
path.style.strokeDasharray = `${len}`;
|
|
1222
|
+
path.style.strokeDashoffset = `${len}`;
|
|
1223
|
+
if (typeof path.animate !== "function") {
|
|
1224
|
+
path.style.strokeDashoffset = "0";
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
const anim = path.animate([{ strokeDashoffset: len }, { strokeDashoffset: 0 }], {
|
|
1228
|
+
duration: CHECKBOX_TICK_DRAW_MS,
|
|
1229
|
+
delay: CHECKBOX_TICK_DELAY_MS,
|
|
1230
|
+
easing: "cubic-bezier(0.45, 0, 0.2, 1)",
|
|
1231
|
+
fill: "forwards"
|
|
1232
|
+
});
|
|
1233
|
+
return () => anim.cancel();
|
|
1234
|
+
}, []);
|
|
1235
|
+
return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", width: pixelSize, height: pixelSize, viewBox: "0 0 14 14", fill: "none", className: cx("block", className), children: /* @__PURE__ */ jsx(
|
|
1236
|
+
"path",
|
|
1237
|
+
{
|
|
1238
|
+
ref: pathRef,
|
|
1239
|
+
d: "M2.33325 7L5.24992 9.91667L11.6666 3.5",
|
|
1240
|
+
stroke: "currentColor",
|
|
1241
|
+
strokeWidth: "2",
|
|
1242
|
+
strokeLinecap: "round",
|
|
1243
|
+
strokeLinejoin: "round"
|
|
1244
|
+
}
|
|
1245
|
+
) });
|
|
1246
|
+
}
|
|
1247
|
+
var focusRingShadow = "outline-none [box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
|
|
1248
|
+
var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = "sm", isFocusVisible = false }) => {
|
|
1249
|
+
const isChecked = isSelected || isIndeterminate;
|
|
1250
|
+
const iconPixelSize = size === "sm" ? 10 : 14;
|
|
1251
|
+
return /* @__PURE__ */ jsxs(
|
|
1252
|
+
"div",
|
|
1253
|
+
{
|
|
1254
|
+
className: cx(
|
|
1255
|
+
"relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip border border-solid border-primary",
|
|
1256
|
+
size === "sm" ? "size-4 rounded-xs" : "size-5 rounded-sm",
|
|
1257
|
+
isChecked ? "border-transparent bg-brand-solid" : "bg-primary",
|
|
1258
|
+
!isChecked && !isDisabled && "group-hover:bg-primary_hover",
|
|
1259
|
+
isDisabled && "cursor-not-allowed opacity-50",
|
|
1260
|
+
isDisabled && !isChecked && "bg-tertiary",
|
|
1261
|
+
isFocusVisible && !isDisabled && focusRingShadow,
|
|
1262
|
+
className
|
|
1263
|
+
),
|
|
1264
|
+
children: [
|
|
1265
|
+
isIndeterminate && /* @__PURE__ */ jsx(
|
|
1266
|
+
"svg",
|
|
1267
|
+
{
|
|
1268
|
+
"aria-hidden": "true",
|
|
1269
|
+
width: iconPixelSize,
|
|
1270
|
+
height: iconPixelSize,
|
|
1271
|
+
viewBox: "0 0 14 14",
|
|
1272
|
+
fill: "none",
|
|
1273
|
+
className: "pointer-events-none block text-fg-white",
|
|
1274
|
+
children: /* @__PURE__ */ jsx("path", { d: "M2.91675 7H11.0834", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
1275
|
+
}
|
|
1276
|
+
),
|
|
1277
|
+
isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: "pointer-events-none text-fg-white" })
|
|
1278
|
+
]
|
|
1279
|
+
}
|
|
1280
|
+
);
|
|
1281
|
+
};
|
|
1282
|
+
CheckboxBase.displayName = "CheckboxBase";
|
|
1283
|
+
var sizes4 = {
|
|
1284
|
+
sm: {
|
|
1285
|
+
root: "p-2 pr-2.5 gap-2 *:data-icon:size-4 *:data-icon:stroke-[2.25px]",
|
|
1286
|
+
text: "text-sm",
|
|
1287
|
+
textContainer: "gap-x-1.5",
|
|
1288
|
+
check: "size-4 stroke-[2.25px]",
|
|
1289
|
+
checkbox: "sm"
|
|
1290
|
+
},
|
|
1291
|
+
md: {
|
|
1292
|
+
root: "p-2 pr-2.5 gap-2 *:data-icon:size-5",
|
|
1293
|
+
text: "text-md",
|
|
1294
|
+
textContainer: "gap-x-2",
|
|
1295
|
+
check: "size-5",
|
|
1296
|
+
checkbox: "sm"
|
|
1297
|
+
},
|
|
1298
|
+
lg: {
|
|
1299
|
+
root: "p-2.5 pl-2 gap-2 *:data-icon:size-5",
|
|
1300
|
+
text: "text-md",
|
|
1301
|
+
textContainer: "gap-x-2",
|
|
1302
|
+
check: "size-5",
|
|
1303
|
+
checkbox: "md"
|
|
1304
|
+
}
|
|
1305
|
+
};
|
|
1306
|
+
var SelectItem = ({
|
|
1307
|
+
label,
|
|
1308
|
+
id,
|
|
1309
|
+
value,
|
|
1310
|
+
avatarUrl,
|
|
1311
|
+
supportingText,
|
|
1312
|
+
isDisabled,
|
|
1313
|
+
icon: Icon,
|
|
1314
|
+
className,
|
|
1315
|
+
children,
|
|
1316
|
+
selectionIndicator = "checkmark",
|
|
1317
|
+
selectionIndicatorAlign = "right",
|
|
1318
|
+
...props
|
|
1319
|
+
}) => {
|
|
1320
|
+
const { size } = useContext(SelectContext);
|
|
1321
|
+
const labelOrChildren = label || (typeof children === "string" ? children : "");
|
|
1322
|
+
const textValue = supportingText ? labelOrChildren + " " + supportingText : labelOrChildren;
|
|
1323
|
+
const isLeft = selectionIndicatorAlign === "left";
|
|
1324
|
+
return /* @__PURE__ */ jsx(
|
|
1325
|
+
ListBoxItem,
|
|
1326
|
+
{
|
|
1327
|
+
id,
|
|
1328
|
+
value: value ?? {
|
|
1329
|
+
id,
|
|
1330
|
+
label: labelOrChildren,
|
|
1331
|
+
avatarUrl,
|
|
1332
|
+
supportingText,
|
|
1333
|
+
isDisabled,
|
|
1334
|
+
icon: Icon
|
|
1335
|
+
},
|
|
1336
|
+
textValue,
|
|
1337
|
+
isDisabled,
|
|
1338
|
+
...props,
|
|
1339
|
+
className: (state) => cx("w-full py-px outline-hidden", size === "sm" ? "px-1" : "px-1.5", typeof className === "function" ? className(state) : className),
|
|
1340
|
+
children: (state) => /* @__PURE__ */ jsxs(
|
|
1341
|
+
"div",
|
|
1342
|
+
{
|
|
1343
|
+
className: cx(
|
|
1344
|
+
"flex cursor-pointer items-center rounded-md outline-hidden select-none",
|
|
1345
|
+
(state.isFocused || state.isHovered) && !(state.isSelected && selectionIndicator !== "checkbox") && "bg-primary_hover",
|
|
1346
|
+
state.isSelected && selectionIndicator !== "checkbox" && "bg-brand-primary_alt",
|
|
1347
|
+
state.isDisabled && "cursor-not-allowed opacity-50",
|
|
1348
|
+
// Icon styles
|
|
1349
|
+
"*:data-icon:shrink-0 *:data-icon:text-fg-quaternary",
|
|
1350
|
+
sizes4[size].root
|
|
1351
|
+
),
|
|
1352
|
+
children: [
|
|
1353
|
+
isLeft && selectionIndicator === "checkbox" && /* @__PURE__ */ jsx(CheckboxBase, { size: sizes4[size].checkbox, isSelected: state.isSelected, isDisabled: state.isDisabled }),
|
|
1354
|
+
avatarUrl ? /* @__PURE__ */ jsx(Avatar, { "aria-hidden": "true", size: "xs", src: avatarUrl, alt: label, className: cx(size === "sm" && "size-5") }) : isReactComponent(Icon) ? /* @__PURE__ */ jsx(Icon, { "data-icon": true, "aria-hidden": "true" }) : isValidElement(Icon) ? Icon : null,
|
|
1355
|
+
/* @__PURE__ */ jsxs("div", { className: cx("flex w-full min-w-0 flex-1 flex-wrap", sizes4[size].textContainer), children: [
|
|
1356
|
+
/* @__PURE__ */ jsx(Text, { slot: "label", className: cx("truncate font-medium whitespace-nowrap text-primary", sizes4[size].text), children: label || (typeof children === "function" ? children(state) : children) }),
|
|
1357
|
+
supportingText && /* @__PURE__ */ jsx(Text, { slot: "description", className: cx("whitespace-nowrap text-tertiary", sizes4[size].text), children: supportingText })
|
|
1358
|
+
] }),
|
|
1359
|
+
state.isSelected && selectionIndicator === "checkmark" && /* @__PURE__ */ jsx(CheckIcon, { "aria-hidden": "true", className: cx("ml-auto text-fg-brand-primary", sizes4[size].check) }),
|
|
1360
|
+
!isLeft && selectionIndicator === "checkbox" && /* @__PURE__ */ jsx(CheckboxBase, { size: sizes4[size].checkbox, isSelected: state.isSelected, isDisabled: state.isDisabled, className: "ml-auto" })
|
|
1361
|
+
]
|
|
1362
|
+
}
|
|
1363
|
+
)
|
|
1364
|
+
}
|
|
1365
|
+
);
|
|
1366
|
+
};
|
|
1367
|
+
var SelectValue = ({ isOpen, isFocusVisible, isDisabled, isInvalid, size, placeholder, icon, ref }) => {
|
|
1368
|
+
const isActive = isOpen || isFocusVisible;
|
|
1369
|
+
return /* @__PURE__ */ jsx(
|
|
1370
|
+
Button$1,
|
|
1371
|
+
{
|
|
1372
|
+
ref,
|
|
1373
|
+
className: cx(
|
|
1374
|
+
"relative flex w-full cursor-pointer items-center rounded-lg border border-solid border-primary bg-primary shadow-xs outline-hidden transition-[border-color,box-shadow] duration-100 ease-linear",
|
|
1375
|
+
!isInvalid && isActive && inputFocusRingShadow,
|
|
1376
|
+
isInvalid && !isActive && "border-error_subtle",
|
|
1377
|
+
isInvalid && isActive && inputErrorFocusRingShadow,
|
|
1378
|
+
isDisabled && "cursor-not-allowed opacity-50"
|
|
1379
|
+
),
|
|
1380
|
+
children: /* @__PURE__ */ jsx(
|
|
1381
|
+
SelectValue$1,
|
|
1382
|
+
{
|
|
1383
|
+
className: (state) => cx(
|
|
1384
|
+
"flex h-max w-full items-center justify-start truncate text-left align-middle",
|
|
1385
|
+
sizes3[size].root,
|
|
1386
|
+
// With icon
|
|
1387
|
+
(state.selectedItems[0]?.icon || icon) && sizes3[size].withIcon,
|
|
1388
|
+
// Icon styles
|
|
1389
|
+
"*:data-icon:shrink-0 *:data-icon:text-fg-quaternary"
|
|
1390
|
+
),
|
|
1391
|
+
children: (state) => {
|
|
1392
|
+
const selectedItem = state.selectedItems[0];
|
|
1393
|
+
const Icon = selectedItem?.icon || icon;
|
|
1394
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1395
|
+
selectedItem?.avatarUrl ? /* @__PURE__ */ jsx(Avatar, { size: "xs", src: selectedItem.avatarUrl, alt: selectedItem.label, className: cx(size === "sm" && "size-5") }) : isReactComponent(Icon) ? /* @__PURE__ */ jsx(Icon, { "data-icon": true, "aria-hidden": "true" }) : isValidElement(Icon) ? Icon : null,
|
|
1396
|
+
selectedItem ? /* @__PURE__ */ jsxs("section", { className: cx("flex w-full truncate", sizes3[size].textContainer), children: [
|
|
1397
|
+
/* @__PURE__ */ jsx("p", { className: cx("truncate font-medium text-primary", sizes3[size].text), children: selectedItem?.label }),
|
|
1398
|
+
selectedItem?.supportingText && /* @__PURE__ */ jsx("p", { className: cx("text-tertiary", sizes3[size].text), children: selectedItem?.supportingText })
|
|
1399
|
+
] }) : /* @__PURE__ */ jsx("p", { className: cx("text-placeholder", sizes3[size].text), children: placeholder }),
|
|
1400
|
+
/* @__PURE__ */ jsx(
|
|
1401
|
+
CaretDownIcon,
|
|
1402
|
+
{
|
|
1403
|
+
"aria-hidden": "true",
|
|
1404
|
+
className: cx("ml-auto shrink-0 text-fg-quaternary", size === "lg" ? "size-5" : "size-4 stroke-[2.25px]")
|
|
1405
|
+
}
|
|
1406
|
+
)
|
|
1407
|
+
] });
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
)
|
|
1411
|
+
}
|
|
1412
|
+
);
|
|
1413
|
+
};
|
|
1414
|
+
var Select = ({ placeholder = "Select", icon, size = "md", children, items, label, hint, tooltip, hideRequiredIndicator, mobileOptions, className, ...rest }) => {
|
|
1415
|
+
return /* @__PURE__ */ jsx(SelectContext.Provider, { value: { size }, children: /* @__PURE__ */ jsx(Select$1, { ...rest, className: (state) => cx("flex flex-col gap-1.5", typeof className === "function" ? className(state) : className), children: (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1416
|
+
label && /* @__PURE__ */ jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip, children: label }),
|
|
1417
|
+
/* @__PURE__ */ jsx(SelectValue, { ...state, ...{ size, placeholder }, icon }),
|
|
1418
|
+
/* @__PURE__ */ jsx(Popover, { size, className: rest.popoverClassName, mobileOptions: { title: label, ...mobileOptions }, children: /* @__PURE__ */ jsx(ListBox, { items, className: "size-full outline-hidden", children }) }),
|
|
1419
|
+
hint && /* @__PURE__ */ jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === "sm" && "text-xs"), children: hint })
|
|
1420
|
+
] }) }) });
|
|
1421
|
+
};
|
|
1422
|
+
var _Select = Select;
|
|
1423
|
+
_Select.ComboBox = ComboBox;
|
|
1424
|
+
_Select.Item = SelectItem;
|
|
1425
|
+
var screens = {
|
|
1426
|
+
sm: "640px",
|
|
1427
|
+
md: "768px",
|
|
1428
|
+
lg: "1024px",
|
|
1429
|
+
xl: "1280px",
|
|
1430
|
+
"2xl": "1536px"
|
|
1431
|
+
};
|
|
1432
|
+
var useBreakpoint = (size) => {
|
|
1433
|
+
const [matches, setMatches] = useState(typeof window !== "undefined" ? window.matchMedia(`(min-width: ${screens[size]})`).matches : true);
|
|
1434
|
+
useEffect(() => {
|
|
1435
|
+
const breakpoint = window.matchMedia(`(min-width: ${screens[size]})`);
|
|
1436
|
+
setMatches(breakpoint.matches);
|
|
1437
|
+
const handleChange = (value) => setMatches(value.matches);
|
|
1438
|
+
breakpoint.addEventListener("change", handleChange);
|
|
1439
|
+
return () => breakpoint.removeEventListener("change", handleChange);
|
|
1440
|
+
}, [size]);
|
|
1441
|
+
return matches;
|
|
1442
|
+
};
|
|
1443
|
+
var CalendarCell = ({ date, isHighlighted, showOutOfRangeDates = false, fluid = false, ...props }) => {
|
|
1444
|
+
const { locale } = useLocale();
|
|
1445
|
+
const dayOfWeek = getDayOfWeek(date, locale);
|
|
1446
|
+
const rangeCalendarContext = useSlottedContext(RangeCalendarContext);
|
|
1447
|
+
const isRangeCalendar = !!rangeCalendarContext;
|
|
1448
|
+
const start = rangeCalendarContext?.value?.start;
|
|
1449
|
+
const end = rangeCalendarContext?.value?.end;
|
|
1450
|
+
const isAfterStart = start ? date.compare(start) > 0 : true;
|
|
1451
|
+
const isBeforeEnd = end ? date.compare(end) < 0 : true;
|
|
1452
|
+
const isAfterOrOnStart = start && date.compare(start) >= 0;
|
|
1453
|
+
const isBeforeOrOnEnd = end && date.compare(end) <= 0;
|
|
1454
|
+
const isInRange = isAfterOrOnStart && isBeforeOrOnEnd;
|
|
1455
|
+
const lastDayOfMonth = new Date(date.year, date.month, 0).getDate();
|
|
1456
|
+
const isLastDayOfMonth = date.day === lastDayOfMonth;
|
|
1457
|
+
const isFirstDayOfMonth = date.day === 1;
|
|
1458
|
+
const isTodayDate = isToday(date, getLocalTimeZone());
|
|
1459
|
+
return /* @__PURE__ */ jsx(
|
|
1460
|
+
CalendarCell$1,
|
|
1461
|
+
{
|
|
1462
|
+
...props,
|
|
1463
|
+
date,
|
|
1464
|
+
className: ({ isDisabled, isFocusVisible, isSelectionStart, isSelectionEnd, isSelected, isOutsideMonth }) => {
|
|
1465
|
+
const isRoundedLeft = isSelectionStart || dayOfWeek === 0;
|
|
1466
|
+
const isRoundedRight = isSelectionEnd || dayOfWeek === 6;
|
|
1467
|
+
return cx(
|
|
1468
|
+
"relative focus:outline-hidden",
|
|
1469
|
+
fluid ? "aspect-square w-full" : "size-10",
|
|
1470
|
+
isRoundedLeft && "rounded-l-full",
|
|
1471
|
+
isRoundedRight && "rounded-r-full",
|
|
1472
|
+
isInRange && isDisabled && "bg-secondary",
|
|
1473
|
+
isSelected && isRangeCalendar && "bg-secondary",
|
|
1474
|
+
isDisabled ? "pointer-events-none" : "cursor-pointer",
|
|
1475
|
+
isFocusVisible ? "z-10" : "z-0",
|
|
1476
|
+
isOutsideMonth && "opacity-50",
|
|
1477
|
+
isRangeCalendar && isOutsideMonth && !showOutOfRangeDates && "hidden",
|
|
1478
|
+
// Show gradient on last day of month if it's within the selected range.
|
|
1479
|
+
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",
|
|
1480
|
+
// Show gradient on first day of month if it's within the selected range.
|
|
1481
|
+
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"
|
|
1482
|
+
);
|
|
1483
|
+
},
|
|
1484
|
+
children: ({ isDisabled, isFocusVisible, isSelectionStart, isSelectionEnd, isSelected, formattedDate }) => {
|
|
1485
|
+
const markedAsSelected = isSelectionStart || isSelectionEnd || isSelected && !isDisabled && !isRangeCalendar;
|
|
1486
|
+
return /* @__PURE__ */ jsxs(
|
|
1487
|
+
"div",
|
|
1488
|
+
{
|
|
1489
|
+
className: cx(
|
|
1490
|
+
"relative flex size-full items-center justify-center rounded-full text-sm text-secondary hover:text-secondary_hover",
|
|
1491
|
+
// Disabled state.
|
|
1492
|
+
isDisabled && "text-secondary/50",
|
|
1493
|
+
// Focus ring, visible while the cell has keyboard focus.
|
|
1494
|
+
isFocusVisible ? "outline-2 outline-offset-2 outline-focus-ring" : "",
|
|
1495
|
+
// Hover state for cells in the middle of the range.
|
|
1496
|
+
isSelected && !isDisabled && isRangeCalendar ? "font-medium" : "",
|
|
1497
|
+
markedAsSelected && "bg-brand-solid font-medium text-white hover:bg-brand-solid_hover hover:text-white",
|
|
1498
|
+
// Hover state for non-selected cells.
|
|
1499
|
+
!isSelected && !isDisabled ? "hover:bg-primary_hover hover:font-medium!" : "",
|
|
1500
|
+
!isSelected && isTodayDate ? "bg-secondary font-medium hover:bg-secondary_hover" : ""
|
|
1501
|
+
),
|
|
1502
|
+
children: [
|
|
1503
|
+
formattedDate,
|
|
1504
|
+
(isHighlighted || isTodayDate) && /* @__PURE__ */ jsx(
|
|
1505
|
+
"div",
|
|
1506
|
+
{
|
|
1507
|
+
className: cx(
|
|
1508
|
+
"absolute bottom-1 left-1/2 size-1.25 -translate-x-1/2 rounded-full",
|
|
1509
|
+
markedAsSelected ? "bg-fg-white" : "bg-fg-brand-primary",
|
|
1510
|
+
isDisabled && "opacity-50"
|
|
1511
|
+
)
|
|
1512
|
+
}
|
|
1513
|
+
)
|
|
1514
|
+
]
|
|
1515
|
+
}
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
);
|
|
1520
|
+
};
|
|
1521
|
+
var RangeCalendarContextProvider = ({ children }) => {
|
|
1522
|
+
const [value, onChange] = useState(null);
|
|
1523
|
+
const [focusedValue, onFocusChange] = useState();
|
|
1524
|
+
return /* @__PURE__ */ jsx(RangeCalendarContext.Provider, { value: { value, onChange, focusedValue, onFocusChange }, children });
|
|
1525
|
+
};
|
|
1526
|
+
var RangeCalendarTitle = ({ part }) => {
|
|
1527
|
+
const context = useContext(RangeCalendarStateContext);
|
|
1528
|
+
if (!context) {
|
|
1529
|
+
throw new Error("<RangeCalendarTitle /> must be used within a <RangeCalendar /> component.");
|
|
1530
|
+
}
|
|
1531
|
+
const formatter = useDateFormatter({
|
|
1532
|
+
month: "long",
|
|
1533
|
+
year: "numeric",
|
|
1534
|
+
calendar: context.visibleRange.start.calendar.identifier,
|
|
1535
|
+
timeZone: context.timeZone
|
|
1536
|
+
});
|
|
1537
|
+
return part === "start" ? formatter.format(context.visibleRange.start.toDate(context.timeZone)) : formatter.format(context.visibleRange.end.toDate(context.timeZone));
|
|
1538
|
+
};
|
|
1539
|
+
var RangePresetButton = ({ value, className, children, ...props }) => {
|
|
1540
|
+
const context = useSlottedContext(RangeCalendarContext);
|
|
1541
|
+
const isSelected = context?.value?.start?.compare(value.start) === 0 && context?.value?.end?.compare(value.end) === 0;
|
|
1542
|
+
return /* @__PURE__ */ jsx(
|
|
1543
|
+
"button",
|
|
1544
|
+
{
|
|
1545
|
+
...props,
|
|
1546
|
+
className: cx(
|
|
1547
|
+
"cursor-pointer rounded-md px-3 py-2 text-left text-sm font-medium text-white outline-focus-ring transition duration-100 ease-linear focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
1548
|
+
isSelected ? "bg-secondary text-secondary_hover hover:bg-secondary_hover" : "text-secondary hover:bg-primary_hover hover:text-secondary_hover",
|
|
1549
|
+
className
|
|
1550
|
+
),
|
|
1551
|
+
children
|
|
1552
|
+
}
|
|
1553
|
+
);
|
|
1554
|
+
};
|
|
1555
|
+
var MobilePresetButton = ({ value, children, ...props }) => {
|
|
1556
|
+
const context = useContext(RangeCalendarStateContext);
|
|
1557
|
+
return /* @__PURE__ */ jsx(
|
|
1558
|
+
Button,
|
|
1559
|
+
{
|
|
1560
|
+
...props,
|
|
1561
|
+
slot: null,
|
|
1562
|
+
size: "sm",
|
|
1563
|
+
color: "link-color",
|
|
1564
|
+
onClick: () => {
|
|
1565
|
+
context?.setValue(value);
|
|
1566
|
+
context?.setFocusedDate(value.start);
|
|
1567
|
+
},
|
|
1568
|
+
children
|
|
1569
|
+
}
|
|
1570
|
+
);
|
|
1571
|
+
};
|
|
1572
|
+
var MobilePresetSelect = ({ presets }) => {
|
|
1573
|
+
const context = useContext(RangeCalendarStateContext);
|
|
1574
|
+
const entries = Object.entries(presets);
|
|
1575
|
+
const items = entries.map(([id, preset]) => ({ id, label: preset.label }));
|
|
1576
|
+
const current = context?.value;
|
|
1577
|
+
const selectedKey = current?.start && current?.end ? entries.find(([, preset]) => preset.value.start.compare(current.start) === 0 && preset.value.end.compare(current.end) === 0)?.[0] ?? null : null;
|
|
1578
|
+
return /* @__PURE__ */ jsx(
|
|
1579
|
+
_Select,
|
|
1580
|
+
{
|
|
1581
|
+
"aria-label": "Date range presets",
|
|
1582
|
+
size: "sm",
|
|
1583
|
+
placeholder: "Select a range",
|
|
1584
|
+
items,
|
|
1585
|
+
selectedKey,
|
|
1586
|
+
mobileOptions: { title: "Select a range", className: "h-dvh! max-h-dvh! rounded-none", contentClassName: "px-2" },
|
|
1587
|
+
onSelectionChange: (key) => {
|
|
1588
|
+
const preset = key != null ? presets[String(key)] : void 0;
|
|
1589
|
+
if (!preset) return;
|
|
1590
|
+
context?.setValue(preset.value);
|
|
1591
|
+
context?.setFocusedDate(preset.value.start);
|
|
1592
|
+
},
|
|
1593
|
+
children: (item) => /* @__PURE__ */ jsx(_Select.Item, { id: item.id, children: item.label })
|
|
1594
|
+
}
|
|
1595
|
+
);
|
|
1596
|
+
};
|
|
1597
|
+
var RangeCalendar = ({
|
|
1598
|
+
presets,
|
|
1599
|
+
visibleDuration,
|
|
1600
|
+
showOutOfRangeDates = false,
|
|
1601
|
+
showPresetsOnDesktop = false,
|
|
1602
|
+
fluid = false,
|
|
1603
|
+
...props
|
|
1604
|
+
}) => {
|
|
1605
|
+
const isDesktop = useBreakpoint("md") && !fluid;
|
|
1606
|
+
const context = useSlottedContext(RangeCalendarContext);
|
|
1607
|
+
const ContextWrapper = context ? Fragment$1 : RangeCalendarContextProvider;
|
|
1608
|
+
const visibleDurationMonths = fluid ? 1 : visibleDuration?.months || (isDesktop ? 2 : 1);
|
|
1609
|
+
return /* @__PURE__ */ jsx(ContextWrapper, { children: /* @__PURE__ */ jsxs(
|
|
1610
|
+
RangeCalendar$1,
|
|
1611
|
+
{
|
|
1612
|
+
...props,
|
|
1613
|
+
className: (state) => cx(
|
|
1614
|
+
fluid ? "flex w-full flex-col items-stretch" : "flex items-start",
|
|
1615
|
+
typeof props.className === "function" ? props.className(state) : props.className
|
|
1616
|
+
),
|
|
1617
|
+
visibleDuration: {
|
|
1618
|
+
months: visibleDurationMonths
|
|
1619
|
+
},
|
|
1620
|
+
children: [
|
|
1621
|
+
/* @__PURE__ */ jsxs("div", { className: cx("flex flex-col gap-3 md:gap-2", fluid ? "w-full px-4 pt-1 pb-4" : "px-6 py-5"), children: [
|
|
1622
|
+
/* @__PURE__ */ jsxs("header", { className: cx("relative flex items-center", visibleDurationMonths > 1 ? "justify-start" : "justify-between"), children: [
|
|
1623
|
+
/* @__PURE__ */ jsx(Button, { slot: "previous", iconLeading: CaretLeftIcon, size: "sm", color: "tertiary", className: "size-8" }),
|
|
1624
|
+
/* @__PURE__ */ jsx("h2", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-sm font-semibold text-fg-secondary", children: /* @__PURE__ */ jsx(RangeCalendarTitle, { part: "start" }) }),
|
|
1625
|
+
visibleDurationMonths === 1 && /* @__PURE__ */ jsx(Button, { slot: "next", iconLeading: CaretRightIcon, size: "sm", color: "tertiary", className: "size-8" })
|
|
1626
|
+
] }),
|
|
1627
|
+
!isDesktop && /* @__PURE__ */ jsxs(
|
|
1628
|
+
"div",
|
|
1629
|
+
{
|
|
1630
|
+
className: cx(
|
|
1631
|
+
"flex w-full gap-2",
|
|
1632
|
+
fluid ? "flex-col items-stretch" : "items-center",
|
|
1633
|
+
!fluid && "md:hidden"
|
|
1634
|
+
),
|
|
1635
|
+
children: [
|
|
1636
|
+
/* @__PURE__ */ jsx(InputDateBase, { slot: "start", size: "sm", wrapperClassName: "min-w-0 flex-1" }),
|
|
1637
|
+
!fluid && /* @__PURE__ */ jsx("div", { className: "text-md text-quaternary", children: "\u2013" }),
|
|
1638
|
+
/* @__PURE__ */ jsx(InputDateBase, { slot: "end", size: "sm", wrapperClassName: "min-w-0 flex-1" })
|
|
1639
|
+
]
|
|
1640
|
+
}
|
|
1641
|
+
),
|
|
1642
|
+
fluid && presets ? /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(MobilePresetSelect, { presets }) }) : (showPresetsOnDesktop || !isDesktop) && presets ? /* @__PURE__ */ jsx("div", { className: "mt-1 flex justify-between gap-3 px-2", children: Object.values(presets).map((preset) => /* @__PURE__ */ jsx(MobilePresetButton, { value: preset.value, children: preset.label }, preset.label)) }) : null,
|
|
1643
|
+
/* @__PURE__ */ jsxs(CalendarGrid, { weekdayStyle: "short", className: cx(fluid ? "w-full table-fixed" : "w-max"), children: [
|
|
1644
|
+
/* @__PURE__ */ jsx(CalendarGridHeader, { children: (day) => /* @__PURE__ */ jsx(CalendarHeaderCell, { className: "border-b-4 border-transparent p-0", children: /* @__PURE__ */ jsx(
|
|
1645
|
+
"div",
|
|
1646
|
+
{
|
|
1647
|
+
className: cx(
|
|
1648
|
+
"flex items-center justify-center text-sm font-medium text-secondary",
|
|
1649
|
+
fluid ? "h-10 w-full" : "size-10"
|
|
1650
|
+
),
|
|
1651
|
+
children: day.slice(0, 2)
|
|
1652
|
+
}
|
|
1653
|
+
) }) }),
|
|
1654
|
+
/* @__PURE__ */ jsx(CalendarGridBody, { className: "[&_td]:p-0 [&_tr]:border-b-4 [&_tr]:border-transparent [&_tr:last-of-type]:border-none", children: (date) => /* @__PURE__ */ jsx(CalendarCell, { date, fluid, showOutOfRangeDates }) })
|
|
1655
|
+
] })
|
|
1656
|
+
] }),
|
|
1657
|
+
visibleDurationMonths > 1 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 border-l border-secondary px-6 py-5", children: [
|
|
1658
|
+
/* @__PURE__ */ jsxs("header", { className: "relative flex items-center justify-end", children: [
|
|
1659
|
+
/* @__PURE__ */ jsx("h2", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-sm font-semibold text-fg-secondary", children: /* @__PURE__ */ jsx(RangeCalendarTitle, { part: "end" }) }),
|
|
1660
|
+
/* @__PURE__ */ jsx(Button, { slot: "next", iconLeading: CaretRightIcon, size: "sm", color: "tertiary", className: "size-8" })
|
|
1661
|
+
] }),
|
|
1662
|
+
/* @__PURE__ */ jsxs(CalendarGrid, { weekdayStyle: "short", offset: { months: 1 }, className: "w-max", children: [
|
|
1663
|
+
/* @__PURE__ */ jsx(CalendarGridHeader, { children: (day) => /* @__PURE__ */ jsx(CalendarHeaderCell, { className: "border-b-4 border-transparent p-0", children: /* @__PURE__ */ jsx("div", { className: "flex size-10 items-center justify-center text-sm font-medium text-secondary", children: day.slice(0, 2) }) }) }),
|
|
1664
|
+
/* @__PURE__ */ jsx(CalendarGridBody, { className: "[&_td]:p-0 [&_tr]:border-b-4 [&_tr]:border-transparent [&_tr:last-of-type]:border-none", children: (date) => /* @__PURE__ */ jsx(CalendarCell, { date }) })
|
|
1665
|
+
] })
|
|
1666
|
+
] })
|
|
1667
|
+
]
|
|
1668
|
+
}
|
|
1669
|
+
) });
|
|
1670
|
+
};
|
|
1671
|
+
var now = today(getLocalTimeZone());
|
|
1672
|
+
var highlightedDates = [today(getLocalTimeZone())];
|
|
1673
|
+
var DateRangePicker = ({
|
|
1674
|
+
value: valueProp,
|
|
1675
|
+
defaultValue,
|
|
1676
|
+
onChange,
|
|
1677
|
+
onApply,
|
|
1678
|
+
onCancel,
|
|
1679
|
+
size = "sm",
|
|
1680
|
+
mobileOptions,
|
|
1681
|
+
...props
|
|
1682
|
+
}) => {
|
|
1683
|
+
const isMobile = useIsMobile();
|
|
1684
|
+
const resolvedMobile = useMemo(() => resolveDatePickerMobileOptions(mobileOptions), [mobileOptions]);
|
|
1685
|
+
const useMobileFullScreen = isMobile && resolvedMobile.fullScreen;
|
|
1686
|
+
const { locale } = useLocale();
|
|
1687
|
+
const formatter = useDateFormatter({
|
|
1688
|
+
month: "short",
|
|
1689
|
+
day: "numeric",
|
|
1690
|
+
year: "numeric"
|
|
1691
|
+
});
|
|
1692
|
+
const [value, setValue] = useControlledState(valueProp, defaultValue || null, onChange);
|
|
1693
|
+
const [focusedValue, setFocusedValue] = useState(null);
|
|
1694
|
+
const formattedStartDate = value?.start ? formatter.format(value.start.toDate(getLocalTimeZone())) : "Select date";
|
|
1695
|
+
const formattedEndDate = value?.end ? formatter.format(value.end.toDate(getLocalTimeZone())) : "Select date";
|
|
1696
|
+
const presets = useMemo(
|
|
1697
|
+
() => ({
|
|
1698
|
+
today: { label: "Today", value: { start: now, end: now } },
|
|
1699
|
+
yesterday: { label: "Yesterday", value: { start: now.subtract({ days: 1 }), end: now.subtract({ days: 1 }) } },
|
|
1700
|
+
thisWeek: { label: "This week", value: { start: startOfWeek(now, locale), end: endOfWeek(now, locale) } },
|
|
1701
|
+
lastWeek: {
|
|
1702
|
+
label: "Last week",
|
|
1703
|
+
value: {
|
|
1704
|
+
start: startOfWeek(now, locale).subtract({ weeks: 1 }),
|
|
1705
|
+
end: endOfWeek(now, locale).subtract({ weeks: 1 })
|
|
1706
|
+
}
|
|
1707
|
+
},
|
|
1708
|
+
thisMonth: { label: "This month", value: { start: startOfMonth(now), end: endOfMonth(now) } },
|
|
1709
|
+
lastMonth: {
|
|
1710
|
+
label: "Last month",
|
|
1711
|
+
value: {
|
|
1712
|
+
start: startOfMonth(now).subtract({ months: 1 }),
|
|
1713
|
+
end: endOfMonth(now).subtract({ months: 1 })
|
|
1714
|
+
}
|
|
1715
|
+
},
|
|
1716
|
+
thisYear: { label: "This year", value: { start: startOfMonth(now.set({ month: 1 })), end: endOfMonth(now.set({ month: 12 })) } },
|
|
1717
|
+
lastYear: {
|
|
1718
|
+
label: "Last year",
|
|
1719
|
+
value: {
|
|
1720
|
+
start: startOfMonth(now.set({ month: 1 }).subtract({ years: 1 })),
|
|
1721
|
+
end: endOfMonth(now.set({ month: 12 }).subtract({ years: 1 }))
|
|
1722
|
+
}
|
|
1723
|
+
},
|
|
1724
|
+
allTime: {
|
|
1725
|
+
label: "All time",
|
|
1726
|
+
value: {
|
|
1727
|
+
start: now.set({ year: 2e3, month: 1, day: 1 }),
|
|
1728
|
+
end: now
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
}),
|
|
1732
|
+
[locale]
|
|
1733
|
+
);
|
|
1734
|
+
return /* @__PURE__ */ jsxs(DateRangePicker$1, { "aria-label": "Date range picker", shouldCloseOnSelect: false, ...props, value, onChange: setValue, children: [
|
|
1735
|
+
/* @__PURE__ */ jsx(Group, { children: /* @__PURE__ */ jsx(Button, { size, color: "secondary", iconLeading: CalendarBlankIcon, children: !value ? /* @__PURE__ */ jsx("span", { className: "text-placeholder", children: "Select dates" }) : `${formattedStartDate} \u2013 ${formattedEndDate}` }) }),
|
|
1736
|
+
/* @__PURE__ */ jsx(
|
|
1737
|
+
DatePickerOverlay,
|
|
1738
|
+
{
|
|
1739
|
+
placement: "bottom right",
|
|
1740
|
+
offset: 8,
|
|
1741
|
+
mobileOptions: { title: "Select dates", ...mobileOptions },
|
|
1742
|
+
className: ({ isEntering, isExiting }) => cx(
|
|
1743
|
+
"origin-(--trigger-anchor-point) will-change-transform",
|
|
1744
|
+
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",
|
|
1745
|
+
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"
|
|
1746
|
+
),
|
|
1747
|
+
children: /* @__PURE__ */ jsx(
|
|
1748
|
+
Dialog,
|
|
1749
|
+
{
|
|
1750
|
+
"aria-label": "Date range picker",
|
|
1751
|
+
className: cx(
|
|
1752
|
+
"flex outline-hidden",
|
|
1753
|
+
useMobileFullScreen ? "min-h-0 flex-1 flex-col overflow-hidden bg-primary" : "rounded-2xl bg-primary shadow-xl ring ring-secondary_alt focus:outline-hidden"
|
|
1754
|
+
),
|
|
1755
|
+
children: ({ close }) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: cx("flex min-h-0 flex-1", useMobileFullScreen ? "flex-col overflow-hidden" : "flex-row"), children: [
|
|
1756
|
+
/* @__PURE__ */ jsx("div", { className: "hidden w-38 flex-col gap-0.5 border-r border-solid border-secondary p-3 lg:flex", children: Object.values(presets).map((preset) => /* @__PURE__ */ jsx(
|
|
1757
|
+
RangePresetButton,
|
|
1758
|
+
{
|
|
1759
|
+
value: preset.value,
|
|
1760
|
+
onClick: () => {
|
|
1761
|
+
setValue(preset.value);
|
|
1762
|
+
setFocusedValue(preset.value.start);
|
|
1763
|
+
},
|
|
1764
|
+
children: preset.label
|
|
1765
|
+
},
|
|
1766
|
+
preset.label
|
|
1767
|
+
)) }),
|
|
1768
|
+
/* @__PURE__ */ jsxs("div", { className: cx("flex flex-col", useMobileFullScreen && "min-h-0 w-full flex-1 overflow-hidden"), children: [
|
|
1769
|
+
/* @__PURE__ */ jsx("div", { className: cx(useMobileFullScreen && "min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto"), children: /* @__PURE__ */ jsx(
|
|
1770
|
+
RangeCalendar,
|
|
1771
|
+
{
|
|
1772
|
+
fluid: useMobileFullScreen,
|
|
1773
|
+
focusedValue,
|
|
1774
|
+
onFocusChange: setFocusedValue,
|
|
1775
|
+
highlightedDates,
|
|
1776
|
+
presets: useMobileFullScreen ? presets : {
|
|
1777
|
+
lastWeek: presets.lastWeek,
|
|
1778
|
+
lastMonth: presets.lastMonth,
|
|
1779
|
+
lastYear: presets.lastYear
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
) }),
|
|
1783
|
+
/* @__PURE__ */ jsxs(
|
|
1784
|
+
"div",
|
|
1785
|
+
{
|
|
1786
|
+
className: cx(
|
|
1787
|
+
"flex justify-between gap-3 border-t border-secondary p-4",
|
|
1788
|
+
useMobileFullScreen && "shrink-0 pb-[max(1rem,env(safe-area-inset-bottom))]"
|
|
1789
|
+
),
|
|
1790
|
+
children: [
|
|
1791
|
+
/* @__PURE__ */ jsxs("div", { className: cx("hidden items-center gap-2", !useMobileFullScreen && "md:flex"), children: [
|
|
1792
|
+
/* @__PURE__ */ jsx(InputDateBase, { slot: "start", size: "sm" }),
|
|
1793
|
+
/* @__PURE__ */ jsx("div", { className: "text-md text-quaternary", children: "\u2013" }),
|
|
1794
|
+
/* @__PURE__ */ jsx(InputDateBase, { slot: "end", size: "sm" })
|
|
1795
|
+
] }),
|
|
1796
|
+
/* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-3 md:flex md:w-auto", children: [
|
|
1797
|
+
/* @__PURE__ */ jsx(
|
|
1798
|
+
Button,
|
|
1799
|
+
{
|
|
1800
|
+
size: "sm",
|
|
1801
|
+
color: "secondary",
|
|
1802
|
+
onClick: () => {
|
|
1803
|
+
onCancel?.();
|
|
1804
|
+
close();
|
|
1805
|
+
},
|
|
1806
|
+
children: "Cancel"
|
|
1807
|
+
}
|
|
1808
|
+
),
|
|
1809
|
+
/* @__PURE__ */ jsx(
|
|
1810
|
+
Button,
|
|
1811
|
+
{
|
|
1812
|
+
size: "sm",
|
|
1813
|
+
color: "primary",
|
|
1814
|
+
onClick: () => {
|
|
1815
|
+
onApply?.();
|
|
1816
|
+
close();
|
|
1817
|
+
},
|
|
1818
|
+
children: "Apply"
|
|
1819
|
+
}
|
|
1820
|
+
)
|
|
1821
|
+
] })
|
|
1822
|
+
]
|
|
1823
|
+
}
|
|
1824
|
+
)
|
|
1825
|
+
] })
|
|
1826
|
+
] }) })
|
|
1827
|
+
}
|
|
1828
|
+
)
|
|
1829
|
+
}
|
|
1830
|
+
)
|
|
1831
|
+
] });
|
|
1832
|
+
};
|
|
1833
|
+
|
|
1834
|
+
export { DateRangePicker };
|
|
1835
|
+
//# sourceMappingURL=date-range-picker.js.map
|
|
1836
|
+
//# sourceMappingURL=date-range-picker.js.map
|