@avenue-ticketing/ui 0.12.0-beta.6 → 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.
@@ -0,0 +1,1560 @@
1
+ import { createContext, useState, Fragment, useEffect, isValidElement, useContext, useMemo, useLayoutEffect, useRef, useCallback } from 'react';
2
+ import { CaretLeftIcon } from '@phosphor-icons/react/dist/csr/CaretLeft';
3
+ import { CaretRightIcon } from '@phosphor-icons/react/dist/csr/CaretRight';
4
+ import { useDateFormatter } from 'react-aria';
5
+ import { RangeCalendarContext, useSlottedContext, RangeCalendar as RangeCalendar$1, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, Link, Button as Button$1, RangeCalendarStateContext, Group, DateInput, DateSegment, useLocale, 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, OverlayTriggerStateContext, Popover as Popover$1, Text, ComboBox as ComboBox$1, ListBoxItem, ComboBoxStateContext, Input } from 'react-aria-components';
6
+ import { extendTailwindMerge } from 'tailwind-merge';
7
+ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
8
+ import { QuestionIcon } from '@phosphor-icons/react/dist/csr/Question';
9
+ import { InfoIcon } from '@phosphor-icons/react/dist/csr/Info';
10
+ import '@phosphor-icons/react/dist/csr/Eye';
11
+ import '@phosphor-icons/react/dist/csr/EyeSlash';
12
+ import { CaretDownIcon } from '@phosphor-icons/react/dist/csr/CaretDown';
13
+ import { UserIcon } from '@phosphor-icons/react/dist/csr/User';
14
+ import '@phosphor-icons/react/dist/csr/Plus';
15
+ import { MagnifyingGlassIcon } from '@phosphor-icons/react/dist/csr/MagnifyingGlass';
16
+ import { createPortal } from 'react-dom';
17
+ import { XIcon } from '@phosphor-icons/react/dist/csr/X';
18
+ import { CheckIcon } from '@phosphor-icons/react/dist/csr/Check';
19
+ import { getDayOfWeek, isToday, getLocalTimeZone } from '@internationalized/date';
20
+
21
+ var twMerge = extendTailwindMerge({
22
+ extend: {
23
+ theme: {
24
+ text: ["display-xs", "display-sm", "display-md", "display-lg", "display-xl", "display-2xl"]
25
+ }
26
+ }
27
+ });
28
+ var cx = twMerge;
29
+ function sortCx(classes) {
30
+ return classes;
31
+ }
32
+
33
+ // ../../utils/is-react-component.ts
34
+ var isFunctionComponent = (component) => {
35
+ return typeof component === "function";
36
+ };
37
+ var isClassComponent = (component) => {
38
+ return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
39
+ };
40
+ var isForwardRefComponent = (component) => {
41
+ return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
42
+ };
43
+ var isReactComponent = (component) => {
44
+ return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
45
+ };
46
+ 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)]";
47
+ 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)]";
48
+ var skeuomorphicGradientBorderClass = [
49
+ "ring-1 ring-inset ring-transparent",
50
+ "before:pointer-events-none before:absolute before:inset-px before:rounded-[inherit] before:border before:border-[#ffffff1f] before:content-['']",
51
+ "before:[mask-image:linear-gradient(to_bottom,#000,transparent)]"
52
+ ].join(" ");
53
+ var skeuomorphicShadowClass = ["shadow-xs-skeuomorphic", focusShadowSkeuomorphic, "overflow-hidden"].join(" ");
54
+ 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)]";
55
+ 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)]";
56
+ var secondaryShadowClass = ["relative overflow-hidden shadow-xs", secondaryInnerShadow, focusShadowSecondary].join(" ");
57
+ var inputNumberButtonClass = [
58
+ "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",
59
+ "in-data-number-input:before:hidden in-data-number-input:after:hidden",
60
+ "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]"
61
+ ].join(" ");
62
+ var inputAddonButtonClass = [
63
+ "in-data-input-wrapper:border-0 in-data-input-wrapper:shadow-none in-data-input-wrapper:!rounded-none in-data-input-wrapper:overflow-hidden",
64
+ "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",
65
+ "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",
66
+ "in-data-input-wrapper:group-invalid:in-data-trailing:border-error_subtle in-data-input-wrapper:group-invalid:in-data-leading:border-error_subtle",
67
+ "in-data-input-wrapper:before:hidden in-data-input-wrapper:after:hidden",
68
+ "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]"
69
+ ].join(" ");
70
+ var styles = sortCx({
71
+ common: {
72
+ root: [
73
+ "group relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-full font-body outline-none before:absolute",
74
+ "font-semibold transition-[color,background-color,border-color,box-shadow,opacity,transform] duration-150 ease-out",
75
+ "pressed:scale-[0.985] pressed:duration-100 pressed:ease-linear motion-reduce:pressed:scale-100",
76
+ "disabled:pointer-events-none disabled:cursor-not-allowed in-data-input-wrapper:disabled:opacity-100",
77
+ inputAddonButtonClass,
78
+ inputNumberButtonClass,
79
+ // Stretch to InputGroup row height; padding/typography follow `data-input-size` on the field (Figma 85:1269).
80
+ "in-data-input-wrapper:!h-full in-data-input-wrapper:!min-h-0 in-data-input-wrapper:self-stretch",
81
+ "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",
82
+ "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",
83
+ "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",
84
+ "*:data-icon:pointer-events-none *:data-icon:shrink-0 *:data-icon:transition-inherit-all"
85
+ ].join(" "),
86
+ icon: "pointer-events-none shrink-0 transition-inherit-all"
87
+ },
88
+ sizes: {
89
+ xs: {
90
+ root: [
91
+ "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",
92
+ "in-data-input-wrapper:data-icon-only:p-2.5",
93
+ "*:data-icon:size-4"
94
+ ].join(" "),
95
+ linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-3"
96
+ },
97
+ sm: {
98
+ root: [
99
+ "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",
100
+ "in-data-input-wrapper:data-icon-only:p-2.5",
101
+ "*:data-icon:size-5"
102
+ ].join(" "),
103
+ linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-3"
104
+ },
105
+ md: {
106
+ root: [
107
+ "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",
108
+ "in-data-input-wrapper:data-icon-only:p-3",
109
+ "*:data-icon:size-5"
110
+ ].join(" "),
111
+ linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-4"
112
+ },
113
+ lg: {
114
+ 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",
115
+ linkRoot: "h-auto min-h-0 gap-1.5 px-0! py-0! text-md *:data-text:underline-offset-4"
116
+ },
117
+ xl: {
118
+ 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",
119
+ linkRoot: "h-auto min-h-0 gap-1.5 px-0! py-0! text-md *:data-text:underline-offset-4"
120
+ }
121
+ },
122
+ colors: {
123
+ /** Figma Hierarchy=Primary — dark neutral solid; hover lightens to fg-tertiary_hover (#404040). */
124
+ primary: {
125
+ root: [
126
+ "bg-primary-solid text-white",
127
+ skeuomorphicShadowClass,
128
+ skeuomorphicGradientBorderClass,
129
+ "hover:bg-fg-tertiary_hover dark:hover:bg-quaternary",
130
+ "disabled:opacity-30",
131
+ "data-loading:bg-fg-tertiary_hover dark:data-loading:bg-quaternary",
132
+ "*:data-icon:not([data-icon=loading]):text-white/70"
133
+ ].join(" ")
134
+ },
135
+ /** Figma Hierarchy=Brand — purple solid; hover darkens to bg-brand-solid_hover (#6d28d9). */
136
+ brand: {
137
+ root: [
138
+ "bg-brand-solid text-primary_on-brand",
139
+ skeuomorphicShadowClass,
140
+ skeuomorphicGradientBorderClass,
141
+ "hover:bg-brand-solid_hover",
142
+ "disabled:opacity-50",
143
+ "data-loading:bg-brand-solid_hover",
144
+ "*:data-icon:not([data-icon=loading]):text-primary_on-brand"
145
+ ].join(" ")
146
+ },
147
+ /** Figma Hierarchy=Secondary — border-primary + shadow-xs + skeuomorphic inner rim overlay. */
148
+ secondary: {
149
+ root: [
150
+ "border border-solid border-primary bg-primary text-secondary",
151
+ secondaryShadowClass,
152
+ "hover:bg-primary_hover hover:text-secondary_hover",
153
+ "disabled:opacity-50",
154
+ "data-loading:bg-primary_hover",
155
+ "*:data-icon:text-fg-secondary"
156
+ ].join(" ")
157
+ },
158
+ /** Figma Hierarchy=Tertiary */
159
+ tertiary: {
160
+ root: [
161
+ "border border-transparent bg-transparent text-tertiary",
162
+ focusShadowPlain,
163
+ "hover:bg-primary_hover hover:text-tertiary_hover",
164
+ "disabled:opacity-50",
165
+ "*:data-icon:text-fg-tertiary"
166
+ ].join(" ")
167
+ },
168
+ /** Figma Hierarchy=Link color — text + icons share brand-secondary; hover underlines with fg-brand-secondary. */
169
+ "link-color": {
170
+ root: [
171
+ "h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-brand-secondary shadow-none",
172
+ focusShadowPlain,
173
+ "hover:text-brand-secondary_hover",
174
+ "disabled:opacity-50",
175
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-fg-brand-secondary"
176
+ ].join(" ")
177
+ },
178
+ /** Figma Hierarchy=Link gray — text + icons share tertiary; hover underlines with fg-quaternary. */
179
+ "link-gray": {
180
+ root: [
181
+ "h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-tertiary shadow-none",
182
+ focusShadowPlain,
183
+ "hover:text-tertiary_hover",
184
+ "disabled:opacity-50",
185
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-fg-quaternary"
186
+ ].join(" ")
187
+ },
188
+ "primary-destructive": {
189
+ root: [
190
+ "bg-error-solid text-white",
191
+ skeuomorphicShadowClass,
192
+ skeuomorphicGradientBorderClass,
193
+ "hover:bg-error-solid_hover",
194
+ "disabled:opacity-50",
195
+ "data-loading:bg-error-solid_hover",
196
+ "*:data-icon:not([data-icon=loading]):text-white/70"
197
+ ].join(" ")
198
+ },
199
+ "secondary-destructive": {
200
+ root: [
201
+ "border border-solid border-primary bg-primary text-error-primary",
202
+ secondaryShadowClass,
203
+ "hover:bg-error-primary hover:text-error-primary_hover",
204
+ "disabled:opacity-50",
205
+ "data-loading:bg-error-primary",
206
+ "*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
207
+ ].join(" ")
208
+ },
209
+ "tertiary-destructive": {
210
+ root: [
211
+ "border border-transparent bg-transparent text-error-primary",
212
+ focusShadowPlain,
213
+ "hover:bg-error-primary hover:text-error-primary_hover",
214
+ "disabled:opacity-50",
215
+ "*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
216
+ ].join(" ")
217
+ },
218
+ /** Figma Hierarchy=Link (destructive) — text + icons share error-primary; hover underlines. */
219
+ "link-destructive": {
220
+ root: [
221
+ "h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-error-primary shadow-none",
222
+ focusShadowPlain,
223
+ "hover:text-error-primary_hover",
224
+ "disabled:opacity-50",
225
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-current"
226
+ ].join(" ")
227
+ }
228
+ }
229
+ });
230
+ var Button = ({
231
+ size = "md",
232
+ color = "primary",
233
+ children,
234
+ className,
235
+ noTextPadding,
236
+ iconLeading: IconLeading,
237
+ iconTrailing: IconTrailing,
238
+ isDisabled: disabled,
239
+ isLoading: loading,
240
+ showTextWhileLoading,
241
+ ...props
242
+ }) => {
243
+ const href = "href" in props ? props.href : void 0;
244
+ const isIcon = (IconLeading || IconTrailing) && !children;
245
+ const isLinkType = ["link-gray", "link-color", "link-destructive"].includes(color);
246
+ noTextPadding = isLinkType || noTextPadding;
247
+ const commonChildren = /* @__PURE__ */ jsxs(Fragment$1, { children: [
248
+ isValidElement(IconLeading) && IconLeading,
249
+ isReactComponent(IconLeading) && /* @__PURE__ */ jsx(IconLeading, { "data-icon": "leading", className: styles.common.icon }),
250
+ loading && /* @__PURE__ */ jsx(
251
+ "svg",
252
+ {
253
+ fill: "none",
254
+ "data-icon": "loading",
255
+ viewBox: "0 0 256 256",
256
+ "aria-hidden": true,
257
+ className: cx(
258
+ styles.common.icon,
259
+ "size-5 animate-spin",
260
+ !showTextWhileLoading && "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
261
+ ),
262
+ children: /* @__PURE__ */ jsx(
263
+ "path",
264
+ {
265
+ fill: "currentColor",
266
+ 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"
267
+ }
268
+ )
269
+ }
270
+ ),
271
+ children && /* @__PURE__ */ jsx("span", { "data-text": true, className: cx("transition-inherit-all", !noTextPadding && !isLinkType && "px-0.5"), children }),
272
+ isValidElement(IconTrailing) && IconTrailing,
273
+ isReactComponent(IconTrailing) && /* @__PURE__ */ jsx(IconTrailing, { "data-icon": "trailing", className: styles.common.icon })
274
+ ] });
275
+ const commonProps = {
276
+ "data-icon-only": isIcon ? true : void 0,
277
+ "data-loading": loading ? true : void 0,
278
+ ...props,
279
+ isDisabled: disabled || loading,
280
+ className: cx(
281
+ styles.common.root,
282
+ styles.sizes[size].root,
283
+ styles.colors[color].root,
284
+ isLinkType && styles.sizes[size].linkRoot,
285
+ (loading || href && (disabled || loading)) && "pointer-events-none",
286
+ loading && (showTextWhileLoading ? "[&>*:not([data-icon=loading]):not([data-text])]:hidden" : "[&>*:not([data-icon=loading])]:invisible"),
287
+ className
288
+ ),
289
+ children: commonChildren
290
+ };
291
+ if ("href" in commonProps) {
292
+ return /* @__PURE__ */ jsx(Link, { ...commonProps, href: disabled || loading ? void 0 : href });
293
+ }
294
+ return /* @__PURE__ */ jsx(Button$1, { ...commonProps, type: commonProps.type || "button", isPending: loading });
295
+ };
296
+ var HintText = ({ isInvalid, className, size = "md", ...props }) => {
297
+ return /* @__PURE__ */ jsx(
298
+ Text,
299
+ {
300
+ ...props,
301
+ slot: isInvalid ? "errorMessage" : "description",
302
+ className: cx(
303
+ "text-sm text-tertiary",
304
+ // Size
305
+ size === "sm" && "text-xs",
306
+ "in-data-[input-size=sm]:text-xs",
307
+ // Invalid state
308
+ isInvalid && "text-error-primary",
309
+ "group-invalid:text-error-primary",
310
+ className
311
+ )
312
+ }
313
+ );
314
+ };
315
+ HintText.displayName = "HintText";
316
+ var Tooltip = ({
317
+ title,
318
+ description,
319
+ children,
320
+ arrow = false,
321
+ delay = 100,
322
+ closeDelay = 0,
323
+ trigger,
324
+ isDisabled,
325
+ isOpen,
326
+ defaultOpen,
327
+ offset = 6,
328
+ crossOffset,
329
+ placement = "top",
330
+ onOpenChange,
331
+ ...tooltipProps
332
+ }) => {
333
+ const isTopOrBottomLeft = ["top left", "top end", "bottom left", "bottom end"].includes(placement);
334
+ const isTopOrBottomRight = ["top right", "top start", "bottom right", "bottom start"].includes(placement);
335
+ const calculatedCrossOffset = isTopOrBottomLeft ? -12 : isTopOrBottomRight ? 12 : 0;
336
+ return /* @__PURE__ */ jsxs(TooltipTrigger$1, { ...{ trigger, delay, closeDelay, isDisabled, isOpen, defaultOpen, onOpenChange }, children: [
337
+ children,
338
+ /* @__PURE__ */ jsx(
339
+ Tooltip$1,
340
+ {
341
+ ...tooltipProps,
342
+ offset,
343
+ placement,
344
+ crossOffset: crossOffset ?? calculatedCrossOffset,
345
+ className: ({ isEntering, isExiting }) => cx(isEntering && "ease-out animate-in", isExiting && "ease-in animate-out"),
346
+ children: ({ isEntering, isExiting }) => /* @__PURE__ */ jsxs(
347
+ "div",
348
+ {
349
+ className: cx(
350
+ "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",
351
+ description ? "py-3" : "py-2",
352
+ 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",
353
+ 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"
354
+ ),
355
+ children: [
356
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-white", children: title }),
357
+ description && /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-tooltip-supporting-text", children: description }),
358
+ arrow && /* @__PURE__ */ jsx(OverlayArrow, { children: /* @__PURE__ */ jsx(
359
+ "svg",
360
+ {
361
+ viewBox: "0 0 100 100",
362
+ 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",
363
+ children: /* @__PURE__ */ jsx("path", { d: "M0,0 L35.858,35.858 Q50,50 64.142,35.858 L100,0 Z" })
364
+ }
365
+ ) })
366
+ ]
367
+ }
368
+ )
369
+ }
370
+ )
371
+ ] });
372
+ };
373
+ var TooltipTrigger = ({ children, className, ...buttonProps }) => {
374
+ return /* @__PURE__ */ jsx(Button$1, { ...buttonProps, className: (values) => cx("h-max w-max outline-hidden", typeof className === "function" ? className(values) : className), children });
375
+ };
376
+ var Label = ({ isInvalid, isRequired, tooltip, tooltipDescription, className, ...props }) => {
377
+ return /* @__PURE__ */ jsxs(
378
+ Label$1,
379
+ {
380
+ "data-label": "true",
381
+ ...props,
382
+ className: cx("flex cursor-default items-center gap-0.5 text-sm font-medium text-secondary", className),
383
+ children: [
384
+ props.children,
385
+ /* @__PURE__ */ jsx(
386
+ "span",
387
+ {
388
+ className: cx(
389
+ "hidden text-brand-tertiary",
390
+ isRequired && "block",
391
+ typeof isRequired === "undefined" && "group-required:block",
392
+ isInvalid && "text-error-primary",
393
+ typeof isInvalid === "undefined" && "group-invalid:text-error-primary"
394
+ ),
395
+ children: "*"
396
+ }
397
+ ),
398
+ tooltip && /* @__PURE__ */ jsx(Tooltip, { title: tooltip, description: tooltipDescription, placement: "top", children: /* @__PURE__ */ jsx(
399
+ TooltipTrigger,
400
+ {
401
+ isDisabled: false,
402
+ className: "cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
403
+ children: /* @__PURE__ */ jsx(QuestionIcon, { className: "size-4" })
404
+ }
405
+ ) })
406
+ ]
407
+ }
408
+ );
409
+ };
410
+ Label.displayName = "Label";
411
+ var inputFocusRingShadow = "border-brand ring-1 ring-inset ring-brand";
412
+ var inputErrorFocusRingShadow = "border-error ring-1 ring-inset ring-error";
413
+ createContext({});
414
+ var DateFieldContext = createContext({});
415
+ var InputDateBase = ({
416
+ tooltip,
417
+ shortcut,
418
+ groupRef,
419
+ size = "md",
420
+ isInvalid,
421
+ isDisabled,
422
+ icon: Icon,
423
+ wrapperClassName,
424
+ tooltipClassName,
425
+ iconClassName,
426
+ ...inputProps
427
+ }) => {
428
+ const hasTrailingIcon = tooltip || isInvalid;
429
+ const hasLeadingIcon = Icon;
430
+ const context = useContext(DateFieldContext);
431
+ const inputSize = context?.size || size;
432
+ const sizes5 = sortCx({
433
+ sm: {
434
+ root: cx("px-3 py-2 text-sm", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-8.5"),
435
+ iconLeading: "left-3 size-4 stroke-[2.25px]",
436
+ iconTrailing: "right-3",
437
+ shortcut: "pr-2.5"
438
+ },
439
+ md: {
440
+ root: cx("px-3 py-2 text-md", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-10"),
441
+ iconLeading: "left-3 size-5",
442
+ iconTrailing: "right-3",
443
+ shortcut: "pr-2.5"
444
+ },
445
+ lg: {
446
+ root: cx("px-3.5 py-2.5 text-md", hasTrailingIcon && "pr-9.5", hasLeadingIcon && "pl-10.5"),
447
+ iconLeading: "left-3.5 size-5",
448
+ iconTrailing: "right-3.5",
449
+ shortcut: "pr-3"
450
+ }
451
+ });
452
+ return /* @__PURE__ */ jsxs(
453
+ Group,
454
+ {
455
+ ...{ isDisabled, isInvalid },
456
+ ref: groupRef,
457
+ className: ({ isFocusWithin, isDisabled: isDisabled2, isInvalid: isInvalid2 }) => cx(
458
+ "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",
459
+ isFocusWithin && !isDisabled2 && !isInvalid2 && inputFocusRingShadow,
460
+ // Disabled state styles
461
+ isDisabled2 && "cursor-not-allowed opacity-50 in-data-input-wrapper:opacity-100",
462
+ "group-disabled:cursor-not-allowed group-disabled:opacity-50 in-data-input-wrapper:group-disabled:opacity-100",
463
+ // Invalid state styles
464
+ isInvalid2 && !isFocusWithin && "border-error_subtle",
465
+ "group-invalid:border-error_subtle",
466
+ "group-invalid:focus-within:border-error group-invalid:focus-within:ring-1 group-invalid:focus-within:ring-inset group-invalid:focus-within:ring-error",
467
+ isInvalid2 && isFocusWithin && inputErrorFocusRingShadow,
468
+ context?.wrapperClassName,
469
+ wrapperClassName
470
+ ),
471
+ children: [
472
+ Icon && /* @__PURE__ */ jsx(Icon, { className: cx("pointer-events-none absolute text-fg-quaternary", sizes5[inputSize].iconLeading, context?.iconClassName, iconClassName) }),
473
+ /* @__PURE__ */ jsx(DateInput, { ...inputProps, className: cx("flex w-full", sizes5[size].root, typeof inputProps.className === "string" && inputProps.className), children: (segment) => /* @__PURE__ */ jsx(
474
+ DateSegment,
475
+ {
476
+ segment,
477
+ className: cx(
478
+ "rounded px-0.5 text-primary tabular-nums caret-transparent focus:bg-brand-solid focus:font-medium focus:text-white focus:outline-hidden",
479
+ // The placeholder segment.
480
+ segment.isPlaceholder && "text-placeholder uppercase",
481
+ // The separator "/" segment.
482
+ segment.type === "literal" && "text-fg-quaternary"
483
+ )
484
+ }
485
+ ) }),
486
+ tooltip && /* @__PURE__ */ jsx(Tooltip, { title: tooltip, placement: "top", children: /* @__PURE__ */ jsx(
487
+ TooltipTrigger,
488
+ {
489
+ className: cx(
490
+ "absolute cursor-pointer text-fg-quaternary transition duration-200 group-invalid/input:hidden hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
491
+ sizes5[inputSize].iconTrailing,
492
+ context?.tooltipClassName,
493
+ tooltipClassName
494
+ ),
495
+ children: /* @__PURE__ */ jsx(QuestionIcon, { className: "size-4 stroke-[2.25px]" })
496
+ }
497
+ ) }),
498
+ /* @__PURE__ */ jsx(
499
+ InfoIcon,
500
+ {
501
+ className: cx(
502
+ "pointer-events-none absolute hidden size-4 stroke-[2.25px] text-fg-error-secondary group-invalid/input:block",
503
+ sizes5[inputSize].iconTrailing,
504
+ context?.tooltipClassName,
505
+ tooltipClassName
506
+ )
507
+ }
508
+ ),
509
+ shortcut && /* @__PURE__ */ jsx(
510
+ "div",
511
+ {
512
+ className: cx(
513
+ "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",
514
+ sizes5[inputSize].shortcut
515
+ ),
516
+ children: /* @__PURE__ */ jsx(
517
+ "span",
518
+ {
519
+ "aria-hidden": "true",
520
+ className: "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
521
+ children: typeof shortcut === "string" ? shortcut : "\u2318K"
522
+ }
523
+ )
524
+ }
525
+ )
526
+ ]
527
+ }
528
+ );
529
+ };
530
+ var sizes = {
531
+ xs: "size-1.5",
532
+ sm: "size-2",
533
+ md: "size-2.5",
534
+ lg: "size-3",
535
+ xl: "size-3.5",
536
+ "2xl": "size-4",
537
+ "3xl": "size-4.5",
538
+ "4xl": "size-5"
539
+ };
540
+ var AvatarOnlineIndicator = ({ size, status, className }) => /* @__PURE__ */ jsx(
541
+ "span",
542
+ {
543
+ className: cx(
544
+ "absolute right-0 bottom-0 flex justify-center rounded-full ring-[1.5px] ring-bg-primary",
545
+ status === "online" ? "bg-fg-success-secondary" : "bg-utility-neutral-300",
546
+ sizes[size],
547
+ className
548
+ ),
549
+ style: {
550
+ 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%)"
551
+ },
552
+ children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 7.2 2.85", fill: "none", className: "mt-[10%] h-[20%] w-[60%]", children: [
553
+ /* @__PURE__ */ jsx(
554
+ "path",
555
+ {
556
+ 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",
557
+ fill: "url(#reflection-gradient)",
558
+ fillOpacity: "0.4"
559
+ }
560
+ ),
561
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: "reflection-gradient", x1: "3.6", y1: "0", x2: "3.6", y2: "2.4", gradientUnits: "userSpaceOnUse", children: [
562
+ /* @__PURE__ */ jsx("stop", { stopColor: "white" }),
563
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0.1" })
564
+ ] }) })
565
+ ] })
566
+ }
567
+ );
568
+ var sizes2 = {
569
+ xs: "size-2.5",
570
+ sm: "size-3",
571
+ md: "size-3.5",
572
+ lg: "size-4",
573
+ xl: "size-4.5",
574
+ "2xl": "size-5",
575
+ "3xl": "size-6",
576
+ "4xl": "size-8"
577
+ };
578
+ 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: [
579
+ /* @__PURE__ */ jsx(
580
+ "path",
581
+ {
582
+ 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",
583
+ className: "fill-current"
584
+ }
585
+ ),
586
+ /* @__PURE__ */ jsx(
587
+ "path",
588
+ {
589
+ fillRule: "evenodd",
590
+ clipRule: "evenodd",
591
+ 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",
592
+ fill: "white"
593
+ }
594
+ )
595
+ ] });
596
+ 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 }) });
597
+ var styles2 = {
598
+ xs: { root: "size-6", rootWithBorder: "p-px", initials: "text-xs font-semibold", icon: "size-4" },
599
+ sm: { root: "size-8", rootWithBorder: "p-px", initials: "text-sm font-semibold", icon: "size-5" },
600
+ md: { root: "size-10", rootWithBorder: "p-px", initials: "text-md font-semibold", icon: "size-6" },
601
+ lg: { root: "size-12", rootWithBorder: "p-[1.5px]", initials: "text-lg font-semibold", icon: "size-7" },
602
+ xl: { root: "size-14", rootWithBorder: "p-0.5", initials: "text-xl font-semibold", icon: "size-8" },
603
+ "2xl": { root: "size-16", rootWithBorder: "p-0.5", initials: "text-display-xs font-semibold", icon: "size-8" }
604
+ };
605
+ var Avatar = ({
606
+ size = "md",
607
+ src,
608
+ alt,
609
+ initials,
610
+ placeholder,
611
+ placeholderIcon: PlaceholderIcon,
612
+ border,
613
+ badge,
614
+ status,
615
+ verified,
616
+ count,
617
+ focusable = false,
618
+ rounded = true,
619
+ className,
620
+ contentClassName
621
+ }) => {
622
+ const [isFailed, setIsFailed] = useState(false);
623
+ const canShowImage = src && !isFailed;
624
+ const renderMainContent = () => {
625
+ if (canShowImage) {
626
+ return /* @__PURE__ */ jsx("img", { "data-avatar-img": true, className: "size-full object-cover", src, alt, onError: () => setIsFailed(true) });
627
+ }
628
+ if (initials) {
629
+ return /* @__PURE__ */ jsx("span", { className: cx("text-quaternary", styles2[size].initials), children: initials });
630
+ }
631
+ if (PlaceholderIcon) {
632
+ return /* @__PURE__ */ jsx(PlaceholderIcon, { className: cx("text-fg-quaternary", styles2[size].icon) });
633
+ }
634
+ return placeholder || /* @__PURE__ */ jsx(UserIcon, { className: cx("text-fg-quaternary", styles2[size].icon) });
635
+ };
636
+ const renderBadgeContent = () => {
637
+ if (status) {
638
+ return /* @__PURE__ */ jsx(AvatarOnlineIndicator, { status, size });
639
+ }
640
+ if (verified) {
641
+ return /* @__PURE__ */ jsx(VerifiedTick, { size, className: cx("absolute right-0 bottom-0", size === "xs" && "-right-px -bottom-px") });
642
+ }
643
+ if (count) {
644
+ return /* @__PURE__ */ jsx(AvatarCount, { count });
645
+ }
646
+ return badge;
647
+ };
648
+ return /* @__PURE__ */ jsxs(
649
+ "div",
650
+ {
651
+ "data-avatar": true,
652
+ className: cx(
653
+ "relative inline-flex shrink-0 rounded-[7px]",
654
+ rounded && "rounded-full",
655
+ // Focus styles
656
+ focusable && "outline-none group-focus-visible:[box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]",
657
+ border && "ring-1 ring-secondary_alt",
658
+ border && styles2[size].rootWithBorder,
659
+ styles2[size].root,
660
+ className
661
+ ),
662
+ children: [
663
+ /* @__PURE__ */ jsx(
664
+ "div",
665
+ {
666
+ className: cx(
667
+ "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]",
668
+ rounded && "rounded-full",
669
+ 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%)]",
670
+ contentClassName
671
+ ),
672
+ children: renderMainContent()
673
+ }
674
+ ),
675
+ renderBadgeContent()
676
+ ]
677
+ }
678
+ );
679
+ };
680
+ var MOBILE_SHEET_MAX_PX = 1024;
681
+ function useIsMobile(breakpoint = MOBILE_SHEET_MAX_PX + 1) {
682
+ const [isMobile, setIsMobile] = useState(() => {
683
+ if (typeof window === "undefined") return false;
684
+ return window.matchMedia(`(max-width: ${breakpoint - 1}px)`).matches;
685
+ });
686
+ useEffect(() => {
687
+ const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
688
+ const handler = (e) => setIsMobile(e.matches);
689
+ mq.addEventListener("change", handler);
690
+ return () => mq.removeEventListener("change", handler);
691
+ }, [breakpoint]);
692
+ return isMobile;
693
+ }
694
+ var MOBILE_SHEET_MOTION_MS = 175;
695
+ var MOBILE_SHEET_ENTRY_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
696
+ var MOBILE_SHEET_EXIT_EASING = "cubic-bezier(0.85, 0, 1, 0.15)";
697
+ var MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX = 120;
698
+ function resolveSelectMobileOptions(mobileOptions) {
699
+ return {
700
+ sheet: mobileOptions?.sheet ?? true,
701
+ title: mobileOptions?.title,
702
+ sheetClassName: mobileOptions?.className,
703
+ contentClassName: mobileOptions?.contentClassName
704
+ };
705
+ }
706
+ function useMobileSheetAnimation(open, enabled, slideEntrance = true, slideOffsetPx = MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX) {
707
+ const [shouldRender, setShouldRender] = useState(open);
708
+ const [isAnimating, setIsAnimating] = useState(false);
709
+ useLayoutEffect(() => {
710
+ if (!enabled) {
711
+ setShouldRender(open);
712
+ return;
713
+ }
714
+ if (open) {
715
+ setShouldRender(true);
716
+ }
717
+ }, [open, enabled]);
718
+ useEffect(() => {
719
+ if (!enabled || open) return;
720
+ const timer = setTimeout(() => setShouldRender(false), MOBILE_SHEET_MOTION_MS);
721
+ return () => clearTimeout(timer);
722
+ }, [open, enabled]);
723
+ useLayoutEffect(() => {
724
+ if (!enabled || open || !shouldRender) return;
725
+ setIsAnimating(false);
726
+ }, [enabled, open, shouldRender]);
727
+ useEffect(() => {
728
+ if (!enabled || !shouldRender || !open) return;
729
+ let raf2 = 0;
730
+ const raf1 = requestAnimationFrame(() => {
731
+ raf2 = requestAnimationFrame(() => setIsAnimating(true));
732
+ });
733
+ return () => {
734
+ cancelAnimationFrame(raf1);
735
+ if (raf2) cancelAnimationFrame(raf2);
736
+ };
737
+ }, [shouldRender, open, enabled]);
738
+ const motionEasing = open ? MOBILE_SHEET_ENTRY_EASING : MOBILE_SHEET_EXIT_EASING;
739
+ const hiddenTransform = slideEntrance ? `translateY(${slideOffsetPx}px)` : "translateY(100%)";
740
+ const panelStyle = enabled ? {
741
+ transform: isAnimating ? "translateY(0)" : hiddenTransform,
742
+ opacity: isAnimating ? 1 : 0,
743
+ transitionProperty: "transform, opacity",
744
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
745
+ transitionTimingFunction: motionEasing
746
+ } : void 0;
747
+ const backdropStyle = enabled ? {
748
+ opacity: isAnimating ? 1 : 0,
749
+ transitionProperty: "opacity",
750
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
751
+ transitionTimingFunction: motionEasing
752
+ } : void 0;
753
+ return { shouldRender, isAnimating, panelStyle, backdropStyle };
754
+ }
755
+ function MobileSheetCloseButton({ onClose }) {
756
+ return /* @__PURE__ */ jsxs(
757
+ "button",
758
+ {
759
+ type: "button",
760
+ onClick: (e) => {
761
+ e.stopPropagation();
762
+ onClose();
763
+ },
764
+ 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)]",
765
+ children: [
766
+ /* @__PURE__ */ jsx(XIcon, { className: "size-5", "aria-hidden": "true" }),
767
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
768
+ ]
769
+ }
770
+ );
771
+ }
772
+ function MobileSheetChrome({
773
+ title,
774
+ contentClassName,
775
+ onClose,
776
+ children
777
+ }) {
778
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
779
+ /* @__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: [
780
+ title ? /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-base font-semibold text-primary", children: title }) : null,
781
+ /* @__PURE__ */ jsx(MobileSheetCloseButton, { onClose })
782
+ ] }),
783
+ /* @__PURE__ */ jsx(
784
+ "div",
785
+ {
786
+ className: cx(
787
+ "min-h-0 flex-1 overflow-y-auto pb-[calc(5rem+env(safe-area-inset-bottom,0px))]",
788
+ contentClassName
789
+ ),
790
+ children
791
+ }
792
+ )
793
+ ] });
794
+ }
795
+ var Popover = ({ mobileOptions, children, size, className, style, compoundContent = false, ...props }) => {
796
+ const isMobile = useIsMobile();
797
+ const resolvedMobile = useMemo(() => resolveSelectMobileOptions(mobileOptions), [mobileOptions]);
798
+ const useMobileSheet = isMobile && resolvedMobile.sheet;
799
+ const overlayState = useContext(OverlayTriggerStateContext);
800
+ const open = overlayState?.isOpen ?? false;
801
+ const { shouldRender, panelStyle, backdropStyle } = useMobileSheetAnimation(open, useMobileSheet);
802
+ useEffect(() => {
803
+ if (!useMobileSheet || !open) return;
804
+ const prev = document.body.style.overflow;
805
+ document.body.style.overflow = "hidden";
806
+ return () => {
807
+ document.body.style.overflow = prev;
808
+ };
809
+ }, [useMobileSheet, open]);
810
+ const close = () => overlayState?.close();
811
+ const showMobileSheet = useMobileSheet && shouldRender;
812
+ const isMobileSheetExiting = showMobileSheet && !open;
813
+ const mobileScrim = useMobileSheet && shouldRender && typeof document !== "undefined" ? createPortal(
814
+ /* @__PURE__ */ jsx(
815
+ "div",
816
+ {
817
+ className: "fixed inset-0 z-50 bg-overlay/70",
818
+ style: backdropStyle,
819
+ onClick: close,
820
+ "aria-hidden": "true"
821
+ }
822
+ ),
823
+ document.body
824
+ ) : null;
825
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
826
+ mobileScrim,
827
+ /* @__PURE__ */ jsx(
828
+ Popover$1,
829
+ {
830
+ placement: "bottom",
831
+ containerPadding: 0,
832
+ offset: 4,
833
+ ...props,
834
+ isExiting: isMobileSheetExiting,
835
+ ...useMobileSheet ? { "data-select-mobile-sheet": true } : {},
836
+ style: useMobileSheet ? { ...panelStyle, ...style } : style,
837
+ className: (state) => cx(
838
+ "outline-hidden",
839
+ !useMobileSheet && [
840
+ "w-(--trigger-width) origin-(--trigger-anchor-point) rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
841
+ compoundContent ? "overflow-hidden outline-hidden" : "overflow-x-hidden overflow-y-auto py-1 outline-hidden",
842
+ 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",
843
+ 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",
844
+ !compoundContent && size === "sm" && "max-h-56!",
845
+ !compoundContent && size === "md" && "max-h-64!",
846
+ !compoundContent && size === "lg" && "max-h-80!"
847
+ ],
848
+ useMobileSheet && [
849
+ "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",
850
+ "max-h-[min(90dvh,calc(100dvh-env(safe-area-inset-bottom,0px)))]",
851
+ resolvedMobile.sheetClassName
852
+ ],
853
+ typeof className === "function" ? className(state) : className
854
+ ),
855
+ children: (state) => {
856
+ const content = typeof children === "function" ? children(state) : children;
857
+ if (useMobileSheet) {
858
+ return /* @__PURE__ */ jsx(
859
+ MobileSheetChrome,
860
+ {
861
+ title: resolvedMobile.title,
862
+ contentClassName: resolvedMobile.contentClassName,
863
+ onClose: close,
864
+ children: content
865
+ }
866
+ );
867
+ }
868
+ return content;
869
+ }
870
+ }
871
+ )
872
+ ] });
873
+ };
874
+ var sizes3 = {
875
+ sm: {
876
+ root: "py-2 pl-3 pr-2.5 gap-2 *:data-icon:size-4 *:data-icon:stroke-[2.25px]",
877
+ withIcon: "",
878
+ text: "text-sm",
879
+ textContainer: "gap-x-1.5",
880
+ shortcut: "pr-2.5"
881
+ },
882
+ 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" },
883
+ 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" }
884
+ };
885
+ var searchSizes = {
886
+ sm: { wrapper: "py-1", root: "px-3 py-2 gap-2 *:data-icon:size-4 *:data-icon:stroke-[2.25px]", text: "text-sm" },
887
+ md: { wrapper: "py-0.5", root: "px-3 py-2 gap-2 *:data-icon:size-5", text: "text-md" },
888
+ lg: { wrapper: "py-0.5", root: "px-3.5 py-2.5 gap-2 *:data-icon:size-5", text: "text-md" }
889
+ };
890
+ var SelectContext = createContext({ size: "md" });
891
+ function hasResizeObserver() {
892
+ return typeof window.ResizeObserver !== "undefined";
893
+ }
894
+ function useResizeObserver(options) {
895
+ const { ref, box, onResize } = options;
896
+ useEffect(() => {
897
+ const element = ref?.current;
898
+ if (!element) {
899
+ return;
900
+ }
901
+ if (!hasResizeObserver()) {
902
+ window.addEventListener("resize", onResize, false);
903
+ return () => {
904
+ window.removeEventListener("resize", onResize, false);
905
+ };
906
+ } else {
907
+ const resizeObserverInstance = new window.ResizeObserver((entries) => {
908
+ if (!entries.length) {
909
+ return;
910
+ }
911
+ onResize();
912
+ });
913
+ resizeObserverInstance.observe(element, { box });
914
+ return () => {
915
+ if (element) {
916
+ resizeObserverInstance.unobserve(element);
917
+ }
918
+ };
919
+ }
920
+ }, [onResize, ref, box]);
921
+ }
922
+ var ComboBoxMobileTrigger = ({ size, placeholder, icon: IconProp, isInvalid, onPointerEnter, ref }) => {
923
+ const state = useContext(ComboBoxStateContext);
924
+ const selectedItem = state?.selectedItem?.value ?? null;
925
+ return /* @__PURE__ */ jsxs(
926
+ Button$1,
927
+ {
928
+ ref,
929
+ onPress: () => state?.open(),
930
+ onPointerEnter,
931
+ className: ({ isFocusVisible, isDisabled }) => cx(
932
+ "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",
933
+ isDisabled && "cursor-not-allowed opacity-50",
934
+ !isInvalid && (isFocusVisible || state?.isOpen) && inputFocusRingShadow,
935
+ isInvalid && !(isFocusVisible || state?.isOpen) && "border-error_subtle",
936
+ isInvalid && (isFocusVisible || state?.isOpen) && inputErrorFocusRingShadow,
937
+ "*:data-icon:shrink-0 *:data-icon:text-fg-quaternary",
938
+ sizes3[size].root
939
+ ),
940
+ children: [
941
+ 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" }),
942
+ selectedItem ? /* @__PURE__ */ jsxs("section", { className: cx("flex w-full truncate", sizes3[size].textContainer), children: [
943
+ /* @__PURE__ */ jsx("p", { className: cx("truncate font-medium text-primary", sizes3[size].text), children: selectedItem.label }),
944
+ selectedItem.supportingText && /* @__PURE__ */ jsx("p", { className: cx("text-tertiary", sizes3[size].text), children: selectedItem.supportingText })
945
+ ] }) : /* @__PURE__ */ jsx("p", { className: cx("truncate text-placeholder", sizes3[size].text), children: placeholder })
946
+ ]
947
+ }
948
+ );
949
+ };
950
+ 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: [
951
+ 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" }),
952
+ /* @__PURE__ */ jsx(
953
+ Input,
954
+ {
955
+ placeholder,
956
+ className: cx(
957
+ "w-full appearance-none bg-transparent text-primary caret-alpha-black/90 outline-hidden placeholder:text-placeholder",
958
+ searchSizes[size].text
959
+ )
960
+ }
961
+ )
962
+ ] }) });
963
+ var ComboBoxValue = ({ size, shortcut, placeholder, shortcutClassName, icon: IconProp, isInvalid, ref, ...otherProps }) => {
964
+ const state = useContext(ComboBoxStateContext);
965
+ const value = state?.selectedItem?.value || null;
966
+ const inputValue = state?.inputValue || null;
967
+ const first = inputValue?.split(value?.supportingText)?.[0] || "";
968
+ const last = inputValue?.split(first)[1];
969
+ return /* @__PURE__ */ jsxs(
970
+ Group,
971
+ {
972
+ ref,
973
+ ...otherProps,
974
+ isInvalid,
975
+ className: ({ isDisabled, isInvalid: isGroupInvalid }) => cx(
976
+ "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",
977
+ isDisabled && "cursor-not-allowed opacity-50",
978
+ !isGroupInvalid && state?.isOpen && inputFocusRingShadow,
979
+ !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",
980
+ isGroupInvalid && !state?.isOpen && "border-error_subtle",
981
+ isGroupInvalid && state?.isOpen && inputErrorFocusRingShadow,
982
+ 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",
983
+ // Icon styles
984
+ "*:data-icon:shrink-0 *:data-icon:text-fg-quaternary",
985
+ sizes3[size].root
986
+ ),
987
+ children: [
988
+ 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" }),
989
+ /* @__PURE__ */ jsxs("div", { className: "relative flex w-full items-center", children: [
990
+ 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: [
991
+ /* @__PURE__ */ jsx("p", { className: cx("font-medium text-primary", sizes3[size].text), children: first }),
992
+ last && /* @__PURE__ */ jsx("p", { className: cx("-ml-0.75 text-tertiary", sizes3[size].text), children: last })
993
+ ] }),
994
+ /* @__PURE__ */ jsx(
995
+ Input,
996
+ {
997
+ placeholder,
998
+ className: cx(
999
+ "z-10 w-full appearance-none bg-transparent text-transparent caret-alpha-black/90 placeholder:text-placeholder focus:outline-hidden disabled:cursor-not-allowed",
1000
+ sizes3[size].text
1001
+ )
1002
+ }
1003
+ )
1004
+ ] }),
1005
+ shortcut && /* @__PURE__ */ jsx(
1006
+ "div",
1007
+ {
1008
+ className: cx(
1009
+ "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",
1010
+ sizes3[size].shortcut,
1011
+ shortcutClassName
1012
+ ),
1013
+ children: /* @__PURE__ */ jsx(
1014
+ "span",
1015
+ {
1016
+ className: "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
1017
+ "aria-hidden": "true",
1018
+ children: "\u2318K"
1019
+ }
1020
+ )
1021
+ }
1022
+ )
1023
+ ]
1024
+ }
1025
+ );
1026
+ };
1027
+ var ComboBox = ({
1028
+ placeholder = "Search",
1029
+ shortcut = true,
1030
+ size = "md",
1031
+ children,
1032
+ items,
1033
+ shortcutClassName,
1034
+ icon,
1035
+ hideRequiredIndicator,
1036
+ mobileOptions,
1037
+ ...otherProps
1038
+ }) => {
1039
+ const isMobile = useIsMobile();
1040
+ const resolvedMobile = useMemo(() => resolveSelectMobileOptions(mobileOptions), [mobileOptions]);
1041
+ const useMobileSheet = isMobile && resolvedMobile.sheet;
1042
+ const triggerRef = useRef(null);
1043
+ const [popoverWidth, setPopoverWidth] = useState("");
1044
+ const onResize = useCallback(() => {
1045
+ if (!triggerRef.current) return;
1046
+ const divRect = triggerRef.current.getBoundingClientRect();
1047
+ setPopoverWidth(divRect.width + "px");
1048
+ }, []);
1049
+ useResizeObserver({
1050
+ ref: triggerRef,
1051
+ box: "border-box",
1052
+ onResize
1053
+ });
1054
+ 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: [
1055
+ otherProps.label && /* @__PURE__ */ jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: otherProps.tooltip, children: otherProps.label }),
1056
+ useMobileSheet ? /* @__PURE__ */ jsx(
1057
+ ComboBoxMobileTrigger,
1058
+ {
1059
+ ref: triggerRef,
1060
+ placeholder,
1061
+ icon,
1062
+ size,
1063
+ isInvalid: state.isInvalid,
1064
+ onPointerEnter: onResize
1065
+ }
1066
+ ) : /* @__PURE__ */ jsx(
1067
+ ComboBoxValue,
1068
+ {
1069
+ ref: triggerRef,
1070
+ placeholder,
1071
+ shortcut,
1072
+ shortcutClassName,
1073
+ icon,
1074
+ size,
1075
+ isInvalid: state.isInvalid,
1076
+ onFocus: onResize,
1077
+ onPointerEnter: onResize
1078
+ }
1079
+ ),
1080
+ /* @__PURE__ */ jsx(
1081
+ Popover,
1082
+ {
1083
+ size,
1084
+ triggerRef,
1085
+ compoundContent: useMobileSheet,
1086
+ style: useMobileSheet ? void 0 : { width: popoverWidth },
1087
+ className: otherProps.popoverClassName,
1088
+ mobileOptions: { title: otherProps.label, ...mobileOptions },
1089
+ children: useMobileSheet ? /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-col overflow-hidden outline-hidden", children: [
1090
+ /* @__PURE__ */ jsx(ComboBoxSheetSearch, { size, placeholder, icon }),
1091
+ /* @__PURE__ */ jsx(ListBox, { items, className: "min-h-0 flex-1 overflow-y-auto py-1 outline-hidden", children })
1092
+ ] }) : /* @__PURE__ */ jsx(ListBox, { items, className: "size-full outline-hidden", children })
1093
+ }
1094
+ ),
1095
+ otherProps.hint && /* @__PURE__ */ jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === "sm" && "text-xs"), children: otherProps.hint })
1096
+ ] }) }) });
1097
+ };
1098
+ var CHECKBOX_TICK_DELAY_MS = 60;
1099
+ var CHECKBOX_TICK_DRAW_MS = 100;
1100
+ function CheckboxAnimatedCheckMark({ pixelSize, className }) {
1101
+ const pathRef = useRef(null);
1102
+ useLayoutEffect(() => {
1103
+ const path = pathRef.current;
1104
+ if (!path || typeof path.getTotalLength !== "function") return;
1105
+ const len = path.getTotalLength();
1106
+ if (len <= 0) return;
1107
+ path.style.strokeDasharray = `${len}`;
1108
+ path.style.strokeDashoffset = `${len}`;
1109
+ if (typeof path.animate !== "function") {
1110
+ path.style.strokeDashoffset = "0";
1111
+ return;
1112
+ }
1113
+ const anim = path.animate([{ strokeDashoffset: len }, { strokeDashoffset: 0 }], {
1114
+ duration: CHECKBOX_TICK_DRAW_MS,
1115
+ delay: CHECKBOX_TICK_DELAY_MS,
1116
+ easing: "cubic-bezier(0.45, 0, 0.2, 1)",
1117
+ fill: "forwards"
1118
+ });
1119
+ return () => anim.cancel();
1120
+ }, []);
1121
+ 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(
1122
+ "path",
1123
+ {
1124
+ ref: pathRef,
1125
+ d: "M2.33325 7L5.24992 9.91667L11.6666 3.5",
1126
+ stroke: "currentColor",
1127
+ strokeWidth: "2",
1128
+ strokeLinecap: "round",
1129
+ strokeLinejoin: "round"
1130
+ }
1131
+ ) });
1132
+ }
1133
+ var focusRingShadow = "outline-none [box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
1134
+ var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = "sm", isFocusVisible = false }) => {
1135
+ const isChecked = isSelected || isIndeterminate;
1136
+ const iconPixelSize = size === "sm" ? 10 : 14;
1137
+ return /* @__PURE__ */ jsxs(
1138
+ "div",
1139
+ {
1140
+ className: cx(
1141
+ "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip border border-solid border-primary",
1142
+ size === "sm" ? "size-4 rounded-xs" : "size-5 rounded-sm",
1143
+ isChecked ? "border-transparent bg-brand-solid" : "bg-primary",
1144
+ !isChecked && !isDisabled && "group-hover:bg-primary_hover",
1145
+ isDisabled && "cursor-not-allowed opacity-50",
1146
+ isDisabled && !isChecked && "bg-tertiary",
1147
+ isFocusVisible && !isDisabled && focusRingShadow,
1148
+ className
1149
+ ),
1150
+ children: [
1151
+ isIndeterminate && /* @__PURE__ */ jsx(
1152
+ "svg",
1153
+ {
1154
+ "aria-hidden": "true",
1155
+ width: iconPixelSize,
1156
+ height: iconPixelSize,
1157
+ viewBox: "0 0 14 14",
1158
+ fill: "none",
1159
+ className: "pointer-events-none block text-fg-white",
1160
+ children: /* @__PURE__ */ jsx("path", { d: "M2.91675 7H11.0834", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
1161
+ }
1162
+ ),
1163
+ isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: "pointer-events-none text-fg-white" })
1164
+ ]
1165
+ }
1166
+ );
1167
+ };
1168
+ CheckboxBase.displayName = "CheckboxBase";
1169
+ var sizes4 = {
1170
+ sm: {
1171
+ root: "p-2 pr-2.5 gap-2 *:data-icon:size-4 *:data-icon:stroke-[2.25px]",
1172
+ text: "text-sm",
1173
+ textContainer: "gap-x-1.5",
1174
+ check: "size-4 stroke-[2.25px]",
1175
+ checkbox: "sm"
1176
+ },
1177
+ md: {
1178
+ root: "p-2 pr-2.5 gap-2 *:data-icon:size-5",
1179
+ text: "text-md",
1180
+ textContainer: "gap-x-2",
1181
+ check: "size-5",
1182
+ checkbox: "sm"
1183
+ },
1184
+ lg: {
1185
+ root: "p-2.5 pl-2 gap-2 *:data-icon:size-5",
1186
+ text: "text-md",
1187
+ textContainer: "gap-x-2",
1188
+ check: "size-5",
1189
+ checkbox: "md"
1190
+ }
1191
+ };
1192
+ var SelectItem = ({
1193
+ label,
1194
+ id,
1195
+ value,
1196
+ avatarUrl,
1197
+ supportingText,
1198
+ isDisabled,
1199
+ icon: Icon,
1200
+ className,
1201
+ children,
1202
+ selectionIndicator = "checkmark",
1203
+ selectionIndicatorAlign = "right",
1204
+ ...props
1205
+ }) => {
1206
+ const { size } = useContext(SelectContext);
1207
+ const labelOrChildren = label || (typeof children === "string" ? children : "");
1208
+ const textValue = supportingText ? labelOrChildren + " " + supportingText : labelOrChildren;
1209
+ const isLeft = selectionIndicatorAlign === "left";
1210
+ return /* @__PURE__ */ jsx(
1211
+ ListBoxItem,
1212
+ {
1213
+ id,
1214
+ value: value ?? {
1215
+ id,
1216
+ label: labelOrChildren,
1217
+ avatarUrl,
1218
+ supportingText,
1219
+ isDisabled,
1220
+ icon: Icon
1221
+ },
1222
+ textValue,
1223
+ isDisabled,
1224
+ ...props,
1225
+ className: (state) => cx("w-full py-px outline-hidden", size === "sm" ? "px-1" : "px-1.5", typeof className === "function" ? className(state) : className),
1226
+ children: (state) => /* @__PURE__ */ jsxs(
1227
+ "div",
1228
+ {
1229
+ className: cx(
1230
+ "flex cursor-pointer items-center rounded-md outline-hidden select-none",
1231
+ (state.isFocused || state.isHovered) && !(state.isSelected && selectionIndicator !== "checkbox") && "bg-primary_hover",
1232
+ state.isSelected && selectionIndicator !== "checkbox" && "bg-brand-primary_alt",
1233
+ state.isDisabled && "cursor-not-allowed opacity-50",
1234
+ // Icon styles
1235
+ "*:data-icon:shrink-0 *:data-icon:text-fg-quaternary",
1236
+ sizes4[size].root
1237
+ ),
1238
+ children: [
1239
+ isLeft && selectionIndicator === "checkbox" && /* @__PURE__ */ jsx(CheckboxBase, { size: sizes4[size].checkbox, isSelected: state.isSelected, isDisabled: state.isDisabled }),
1240
+ 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,
1241
+ /* @__PURE__ */ jsxs("div", { className: cx("flex w-full min-w-0 flex-1 flex-wrap", sizes4[size].textContainer), children: [
1242
+ /* @__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) }),
1243
+ supportingText && /* @__PURE__ */ jsx(Text, { slot: "description", className: cx("whitespace-nowrap text-tertiary", sizes4[size].text), children: supportingText })
1244
+ ] }),
1245
+ state.isSelected && selectionIndicator === "checkmark" && /* @__PURE__ */ jsx(CheckIcon, { "aria-hidden": "true", className: cx("ml-auto text-fg-brand-primary", sizes4[size].check) }),
1246
+ !isLeft && selectionIndicator === "checkbox" && /* @__PURE__ */ jsx(CheckboxBase, { size: sizes4[size].checkbox, isSelected: state.isSelected, isDisabled: state.isDisabled, className: "ml-auto" })
1247
+ ]
1248
+ }
1249
+ )
1250
+ }
1251
+ );
1252
+ };
1253
+ var SelectValue = ({ isOpen, isFocusVisible, isDisabled, isInvalid, size, placeholder, icon, ref }) => {
1254
+ const isActive = isOpen || isFocusVisible;
1255
+ return /* @__PURE__ */ jsx(
1256
+ Button$1,
1257
+ {
1258
+ ref,
1259
+ className: cx(
1260
+ "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",
1261
+ !isInvalid && isActive && inputFocusRingShadow,
1262
+ isInvalid && !isActive && "border-error_subtle",
1263
+ isInvalid && isActive && inputErrorFocusRingShadow,
1264
+ isDisabled && "cursor-not-allowed opacity-50"
1265
+ ),
1266
+ children: /* @__PURE__ */ jsx(
1267
+ SelectValue$1,
1268
+ {
1269
+ className: (state) => cx(
1270
+ "flex h-max w-full items-center justify-start truncate text-left align-middle",
1271
+ sizes3[size].root,
1272
+ // With icon
1273
+ (state.selectedItems[0]?.icon || icon) && sizes3[size].withIcon,
1274
+ // Icon styles
1275
+ "*:data-icon:shrink-0 *:data-icon:text-fg-quaternary"
1276
+ ),
1277
+ children: (state) => {
1278
+ const selectedItem = state.selectedItems[0];
1279
+ const Icon = selectedItem?.icon || icon;
1280
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1281
+ 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,
1282
+ selectedItem ? /* @__PURE__ */ jsxs("section", { className: cx("flex w-full truncate", sizes3[size].textContainer), children: [
1283
+ /* @__PURE__ */ jsx("p", { className: cx("truncate font-medium text-primary", sizes3[size].text), children: selectedItem?.label }),
1284
+ selectedItem?.supportingText && /* @__PURE__ */ jsx("p", { className: cx("text-tertiary", sizes3[size].text), children: selectedItem?.supportingText })
1285
+ ] }) : /* @__PURE__ */ jsx("p", { className: cx("text-placeholder", sizes3[size].text), children: placeholder }),
1286
+ /* @__PURE__ */ jsx(
1287
+ CaretDownIcon,
1288
+ {
1289
+ "aria-hidden": "true",
1290
+ className: cx("ml-auto shrink-0 text-fg-quaternary", size === "lg" ? "size-5" : "size-4 stroke-[2.25px]")
1291
+ }
1292
+ )
1293
+ ] });
1294
+ }
1295
+ }
1296
+ )
1297
+ }
1298
+ );
1299
+ };
1300
+ var Select = ({ placeholder = "Select", icon, size = "md", children, items, label, hint, tooltip, hideRequiredIndicator, mobileOptions, className, ...rest }) => {
1301
+ 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$1, { children: [
1302
+ label && /* @__PURE__ */ jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip, children: label }),
1303
+ /* @__PURE__ */ jsx(SelectValue, { ...state, ...{ size, placeholder }, icon }),
1304
+ /* @__PURE__ */ jsx(Popover, { size, className: rest.popoverClassName, mobileOptions: { title: label, ...mobileOptions }, children: /* @__PURE__ */ jsx(ListBox, { items, className: "size-full outline-hidden", children }) }),
1305
+ hint && /* @__PURE__ */ jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === "sm" && "text-xs"), children: hint })
1306
+ ] }) }) });
1307
+ };
1308
+ var _Select = Select;
1309
+ _Select.ComboBox = ComboBox;
1310
+ _Select.Item = SelectItem;
1311
+ var screens = {
1312
+ sm: "640px",
1313
+ md: "768px",
1314
+ lg: "1024px",
1315
+ xl: "1280px",
1316
+ "2xl": "1536px"
1317
+ };
1318
+ var useBreakpoint = (size) => {
1319
+ const [matches, setMatches] = useState(typeof window !== "undefined" ? window.matchMedia(`(min-width: ${screens[size]})`).matches : true);
1320
+ useEffect(() => {
1321
+ const breakpoint = window.matchMedia(`(min-width: ${screens[size]})`);
1322
+ setMatches(breakpoint.matches);
1323
+ const handleChange = (value) => setMatches(value.matches);
1324
+ breakpoint.addEventListener("change", handleChange);
1325
+ return () => breakpoint.removeEventListener("change", handleChange);
1326
+ }, [size]);
1327
+ return matches;
1328
+ };
1329
+ var CalendarCell = ({ date, isHighlighted, showOutOfRangeDates = false, fluid = false, ...props }) => {
1330
+ const { locale } = useLocale();
1331
+ const dayOfWeek = getDayOfWeek(date, locale);
1332
+ const rangeCalendarContext = useSlottedContext(RangeCalendarContext);
1333
+ const isRangeCalendar = !!rangeCalendarContext;
1334
+ const start = rangeCalendarContext?.value?.start;
1335
+ const end = rangeCalendarContext?.value?.end;
1336
+ const isAfterStart = start ? date.compare(start) > 0 : true;
1337
+ const isBeforeEnd = end ? date.compare(end) < 0 : true;
1338
+ const isAfterOrOnStart = start && date.compare(start) >= 0;
1339
+ const isBeforeOrOnEnd = end && date.compare(end) <= 0;
1340
+ const isInRange = isAfterOrOnStart && isBeforeOrOnEnd;
1341
+ const lastDayOfMonth = new Date(date.year, date.month, 0).getDate();
1342
+ const isLastDayOfMonth = date.day === lastDayOfMonth;
1343
+ const isFirstDayOfMonth = date.day === 1;
1344
+ const isTodayDate = isToday(date, getLocalTimeZone());
1345
+ return /* @__PURE__ */ jsx(
1346
+ CalendarCell$1,
1347
+ {
1348
+ ...props,
1349
+ date,
1350
+ className: ({ isDisabled, isFocusVisible, isSelectionStart, isSelectionEnd, isSelected, isOutsideMonth }) => {
1351
+ const isRoundedLeft = isSelectionStart || dayOfWeek === 0;
1352
+ const isRoundedRight = isSelectionEnd || dayOfWeek === 6;
1353
+ return cx(
1354
+ "relative focus:outline-hidden",
1355
+ fluid ? "aspect-square w-full" : "size-10",
1356
+ isRoundedLeft && "rounded-l-full",
1357
+ isRoundedRight && "rounded-r-full",
1358
+ isInRange && isDisabled && "bg-secondary",
1359
+ isSelected && isRangeCalendar && "bg-secondary",
1360
+ isDisabled ? "pointer-events-none" : "cursor-pointer",
1361
+ isFocusVisible ? "z-10" : "z-0",
1362
+ isOutsideMonth && "opacity-50",
1363
+ isRangeCalendar && isOutsideMonth && !showOutOfRangeDates && "hidden",
1364
+ // Show gradient on last day of month if it's within the selected range.
1365
+ 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",
1366
+ // Show gradient on first day of month if it's within the selected range.
1367
+ 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"
1368
+ );
1369
+ },
1370
+ children: ({ isDisabled, isFocusVisible, isSelectionStart, isSelectionEnd, isSelected, formattedDate }) => {
1371
+ const markedAsSelected = isSelectionStart || isSelectionEnd || isSelected && !isDisabled && !isRangeCalendar;
1372
+ return /* @__PURE__ */ jsxs(
1373
+ "div",
1374
+ {
1375
+ className: cx(
1376
+ "relative flex size-full items-center justify-center rounded-full text-sm text-secondary hover:text-secondary_hover",
1377
+ // Disabled state.
1378
+ isDisabled && "text-secondary/50",
1379
+ // Focus ring, visible while the cell has keyboard focus.
1380
+ isFocusVisible ? "outline-2 outline-offset-2 outline-focus-ring" : "",
1381
+ // Hover state for cells in the middle of the range.
1382
+ isSelected && !isDisabled && isRangeCalendar ? "font-medium" : "",
1383
+ markedAsSelected && "bg-brand-solid font-medium text-white hover:bg-brand-solid_hover hover:text-white",
1384
+ // Hover state for non-selected cells.
1385
+ !isSelected && !isDisabled ? "hover:bg-primary_hover hover:font-medium!" : "",
1386
+ !isSelected && isTodayDate ? "bg-secondary font-medium hover:bg-secondary_hover" : ""
1387
+ ),
1388
+ children: [
1389
+ formattedDate,
1390
+ (isHighlighted || isTodayDate) && /* @__PURE__ */ jsx(
1391
+ "div",
1392
+ {
1393
+ className: cx(
1394
+ "absolute bottom-1 left-1/2 size-1.25 -translate-x-1/2 rounded-full",
1395
+ markedAsSelected ? "bg-fg-white" : "bg-fg-brand-primary",
1396
+ isDisabled && "opacity-50"
1397
+ )
1398
+ }
1399
+ )
1400
+ ]
1401
+ }
1402
+ );
1403
+ }
1404
+ }
1405
+ );
1406
+ };
1407
+ var RangeCalendarContextProvider = ({ children }) => {
1408
+ const [value, onChange] = useState(null);
1409
+ const [focusedValue, onFocusChange] = useState();
1410
+ return /* @__PURE__ */ jsx(RangeCalendarContext.Provider, { value: { value, onChange, focusedValue, onFocusChange }, children });
1411
+ };
1412
+ var RangeCalendarTitle = ({ part }) => {
1413
+ const context = useContext(RangeCalendarStateContext);
1414
+ if (!context) {
1415
+ throw new Error("<RangeCalendarTitle /> must be used within a <RangeCalendar /> component.");
1416
+ }
1417
+ const formatter = useDateFormatter({
1418
+ month: "long",
1419
+ year: "numeric",
1420
+ calendar: context.visibleRange.start.calendar.identifier,
1421
+ timeZone: context.timeZone
1422
+ });
1423
+ return part === "start" ? formatter.format(context.visibleRange.start.toDate(context.timeZone)) : formatter.format(context.visibleRange.end.toDate(context.timeZone));
1424
+ };
1425
+ var RangePresetButton = ({ value, className, children, ...props }) => {
1426
+ const context = useSlottedContext(RangeCalendarContext);
1427
+ const isSelected = context?.value?.start?.compare(value.start) === 0 && context?.value?.end?.compare(value.end) === 0;
1428
+ return /* @__PURE__ */ jsx(
1429
+ "button",
1430
+ {
1431
+ ...props,
1432
+ className: cx(
1433
+ "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",
1434
+ isSelected ? "bg-secondary text-secondary_hover hover:bg-secondary_hover" : "text-secondary hover:bg-primary_hover hover:text-secondary_hover",
1435
+ className
1436
+ ),
1437
+ children
1438
+ }
1439
+ );
1440
+ };
1441
+ var MobilePresetButton = ({ value, children, ...props }) => {
1442
+ const context = useContext(RangeCalendarStateContext);
1443
+ return /* @__PURE__ */ jsx(
1444
+ Button,
1445
+ {
1446
+ ...props,
1447
+ slot: null,
1448
+ size: "sm",
1449
+ color: "link-color",
1450
+ onClick: () => {
1451
+ context?.setValue(value);
1452
+ context?.setFocusedDate(value.start);
1453
+ },
1454
+ children
1455
+ }
1456
+ );
1457
+ };
1458
+ var MobilePresetSelect = ({ presets }) => {
1459
+ const context = useContext(RangeCalendarStateContext);
1460
+ const entries = Object.entries(presets);
1461
+ const items = entries.map(([id, preset]) => ({ id, label: preset.label }));
1462
+ const current = context?.value;
1463
+ 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;
1464
+ return /* @__PURE__ */ jsx(
1465
+ _Select,
1466
+ {
1467
+ "aria-label": "Date range presets",
1468
+ size: "sm",
1469
+ placeholder: "Select a range",
1470
+ items,
1471
+ selectedKey,
1472
+ mobileOptions: { title: "Select a range", className: "h-dvh! max-h-dvh! rounded-none", contentClassName: "px-2" },
1473
+ onSelectionChange: (key) => {
1474
+ const preset = key != null ? presets[String(key)] : void 0;
1475
+ if (!preset) return;
1476
+ context?.setValue(preset.value);
1477
+ context?.setFocusedDate(preset.value.start);
1478
+ },
1479
+ children: (item) => /* @__PURE__ */ jsx(_Select.Item, { id: item.id, children: item.label })
1480
+ }
1481
+ );
1482
+ };
1483
+ var RangeCalendar = ({
1484
+ presets,
1485
+ visibleDuration,
1486
+ showOutOfRangeDates = false,
1487
+ showPresetsOnDesktop = false,
1488
+ fluid = false,
1489
+ ...props
1490
+ }) => {
1491
+ const isDesktop = useBreakpoint("md") && !fluid;
1492
+ const context = useSlottedContext(RangeCalendarContext);
1493
+ const ContextWrapper = context ? Fragment : RangeCalendarContextProvider;
1494
+ const visibleDurationMonths = fluid ? 1 : visibleDuration?.months || (isDesktop ? 2 : 1);
1495
+ return /* @__PURE__ */ jsx(ContextWrapper, { children: /* @__PURE__ */ jsxs(
1496
+ RangeCalendar$1,
1497
+ {
1498
+ ...props,
1499
+ className: (state) => cx(
1500
+ fluid ? "flex w-full flex-col items-stretch" : "flex items-start",
1501
+ typeof props.className === "function" ? props.className(state) : props.className
1502
+ ),
1503
+ visibleDuration: {
1504
+ months: visibleDurationMonths
1505
+ },
1506
+ children: [
1507
+ /* @__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: [
1508
+ /* @__PURE__ */ jsxs("header", { className: cx("relative flex items-center", visibleDurationMonths > 1 ? "justify-start" : "justify-between"), children: [
1509
+ /* @__PURE__ */ jsx(Button, { slot: "previous", iconLeading: CaretLeftIcon, size: "sm", color: "tertiary", className: "size-8" }),
1510
+ /* @__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" }) }),
1511
+ visibleDurationMonths === 1 && /* @__PURE__ */ jsx(Button, { slot: "next", iconLeading: CaretRightIcon, size: "sm", color: "tertiary", className: "size-8" })
1512
+ ] }),
1513
+ !isDesktop && /* @__PURE__ */ jsxs(
1514
+ "div",
1515
+ {
1516
+ className: cx(
1517
+ "flex w-full gap-2",
1518
+ fluid ? "flex-col items-stretch" : "items-center",
1519
+ !fluid && "md:hidden"
1520
+ ),
1521
+ children: [
1522
+ /* @__PURE__ */ jsx(InputDateBase, { slot: "start", size: "sm", wrapperClassName: "min-w-0 flex-1" }),
1523
+ !fluid && /* @__PURE__ */ jsx("div", { className: "text-md text-quaternary", children: "\u2013" }),
1524
+ /* @__PURE__ */ jsx(InputDateBase, { slot: "end", size: "sm", wrapperClassName: "min-w-0 flex-1" })
1525
+ ]
1526
+ }
1527
+ ),
1528
+ 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,
1529
+ /* @__PURE__ */ jsxs(CalendarGrid, { weekdayStyle: "short", className: cx(fluid ? "w-full table-fixed" : "w-max"), children: [
1530
+ /* @__PURE__ */ jsx(CalendarGridHeader, { children: (day) => /* @__PURE__ */ jsx(CalendarHeaderCell, { className: "border-b-4 border-transparent p-0", children: /* @__PURE__ */ jsx(
1531
+ "div",
1532
+ {
1533
+ className: cx(
1534
+ "flex items-center justify-center text-sm font-medium text-secondary",
1535
+ fluid ? "h-10 w-full" : "size-10"
1536
+ ),
1537
+ children: day.slice(0, 2)
1538
+ }
1539
+ ) }) }),
1540
+ /* @__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 }) })
1541
+ ] })
1542
+ ] }),
1543
+ visibleDurationMonths > 1 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 border-l border-secondary px-6 py-5", children: [
1544
+ /* @__PURE__ */ jsxs("header", { className: "relative flex items-center justify-end", children: [
1545
+ /* @__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" }) }),
1546
+ /* @__PURE__ */ jsx(Button, { slot: "next", iconLeading: CaretRightIcon, size: "sm", color: "tertiary", className: "size-8" })
1547
+ ] }),
1548
+ /* @__PURE__ */ jsxs(CalendarGrid, { weekdayStyle: "short", offset: { months: 1 }, className: "w-max", children: [
1549
+ /* @__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) }) }) }),
1550
+ /* @__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 }) })
1551
+ ] })
1552
+ ] })
1553
+ ]
1554
+ }
1555
+ ) });
1556
+ };
1557
+
1558
+ export { RangeCalendar, RangeCalendarContextProvider, RangePresetButton };
1559
+ //# sourceMappingURL=range-calendar.js.map
1560
+ //# sourceMappingURL=range-calendar.js.map