@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,12 @@
1
+ interface DatePickerMobileOptions {
2
+ /** When `false`, keep the floating popover on narrow viewports. Default `true`. */
3
+ fullScreen?: boolean;
4
+ /** Optional header title on mobile (shown beside the close control). */
5
+ title?: string;
6
+ /** Extra classes on the full-screen panel. */
7
+ className?: string;
8
+ /** Extra classes on the scrollable body region. */
9
+ contentClassName?: string;
10
+ }
11
+
12
+ export type { DatePickerMobileOptions as D };
@@ -1,5 +1,5 @@
1
1
  import { FC, ReactNode, ReactElement } from 'react';
2
- import { LinkProps as LinkProps$1, ButtonProps as ButtonProps$1 } from 'react-aria-components';
2
+ import { ButtonProps as ButtonProps$1, LinkProps as LinkProps$1 } from 'react-aria-components';
3
3
 
4
4
  declare const styles: {
5
5
  common: {
@@ -0,0 +1,19 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, PropsWithChildren } from 'react';
3
+ import { CalendarProps as CalendarProps$1, DateValue } from 'react-aria-components';
4
+
5
+ declare const CalendarContextProvider: ({ children }: PropsWithChildren) => react.JSX.Element;
6
+ interface CalendarProps extends CalendarProps$1<DateValue> {
7
+ /** The dates to highlight. */
8
+ highlightedDates?: DateValue[];
9
+ /** Stretch the grid to fill available width (mobile full-screen). */
10
+ fluid?: boolean;
11
+ /**
12
+ * The content to render between the header and the calendar grid.
13
+ * If not provided, a default layout will be rendered with a date input and a today button.
14
+ */
15
+ children?: ReactNode;
16
+ }
17
+ declare const Calendar: ({ highlightedDates, fluid, className, children, ...props }: CalendarProps) => react.JSX.Element;
18
+
19
+ export { Calendar, CalendarContextProvider };
@@ -0,0 +1,611 @@
1
+ import { createContext, useState, Fragment, isValidElement, useContext } from 'react';
2
+ import { today, getLocalTimeZone, getDayOfWeek, isToday } from '@internationalized/date';
3
+ import { CaretLeftIcon } from '@phosphor-icons/react/dist/csr/CaretLeft';
4
+ import { CaretRightIcon } from '@phosphor-icons/react/dist/csr/CaretRight';
5
+ import { CalendarContext, useSlottedContext, Calendar as Calendar$1, Heading, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, Link, Button as Button$1, Group, DateInput, DateSegment, useLocale, RangeCalendarContext, CalendarCell as CalendarCell$1, TooltipTrigger as TooltipTrigger$1, Tooltip as Tooltip$1, OverlayArrow } 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
+
13
+ var twMerge = extendTailwindMerge({
14
+ extend: {
15
+ theme: {
16
+ text: ["display-xs", "display-sm", "display-md", "display-lg", "display-xl", "display-2xl"]
17
+ }
18
+ }
19
+ });
20
+ var cx = twMerge;
21
+ function sortCx(classes) {
22
+ return classes;
23
+ }
24
+
25
+ // ../../utils/is-react-component.ts
26
+ var isFunctionComponent = (component) => {
27
+ return typeof component === "function";
28
+ };
29
+ var isClassComponent = (component) => {
30
+ return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
31
+ };
32
+ var isForwardRefComponent = (component) => {
33
+ return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
34
+ };
35
+ var isReactComponent = (component) => {
36
+ return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
37
+ };
38
+ 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)]";
39
+ 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)]";
40
+ var skeuomorphicGradientBorderClass = [
41
+ "ring-1 ring-inset ring-transparent",
42
+ "before:pointer-events-none before:absolute before:inset-px before:rounded-[inherit] before:border before:border-[#ffffff1f] before:content-['']",
43
+ "before:[mask-image:linear-gradient(to_bottom,#000,transparent)]"
44
+ ].join(" ");
45
+ var skeuomorphicShadowClass = ["shadow-xs-skeuomorphic", focusShadowSkeuomorphic, "overflow-hidden"].join(" ");
46
+ 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)]";
47
+ 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)]";
48
+ var secondaryShadowClass = ["relative overflow-hidden shadow-xs", secondaryInnerShadow, focusShadowSecondary].join(" ");
49
+ var inputNumberButtonClass = [
50
+ "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",
51
+ "in-data-number-input:before:hidden in-data-number-input:after:hidden",
52
+ "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]"
53
+ ].join(" ");
54
+ var inputAddonButtonClass = [
55
+ "in-data-input-wrapper:border-0 in-data-input-wrapper:shadow-none in-data-input-wrapper:!rounded-none in-data-input-wrapper:overflow-hidden",
56
+ "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",
57
+ "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",
58
+ "in-data-input-wrapper:group-invalid:in-data-trailing:border-error_subtle in-data-input-wrapper:group-invalid:in-data-leading:border-error_subtle",
59
+ "in-data-input-wrapper:before:hidden in-data-input-wrapper:after:hidden",
60
+ "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]"
61
+ ].join(" ");
62
+ var styles = sortCx({
63
+ common: {
64
+ root: [
65
+ "group relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-full font-body outline-none before:absolute",
66
+ "font-semibold transition-[color,background-color,border-color,box-shadow,opacity,transform] duration-150 ease-out",
67
+ "pressed:scale-[0.985] pressed:duration-100 pressed:ease-linear motion-reduce:pressed:scale-100",
68
+ "disabled:pointer-events-none disabled:cursor-not-allowed in-data-input-wrapper:disabled:opacity-100",
69
+ inputAddonButtonClass,
70
+ inputNumberButtonClass,
71
+ // Stretch to InputGroup row height; padding/typography follow `data-input-size` on the field (Figma 85:1269).
72
+ "in-data-input-wrapper:!h-full in-data-input-wrapper:!min-h-0 in-data-input-wrapper:self-stretch",
73
+ "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",
74
+ "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",
75
+ "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",
76
+ "*:data-icon:pointer-events-none *:data-icon:shrink-0 *:data-icon:transition-inherit-all"
77
+ ].join(" "),
78
+ icon: "pointer-events-none shrink-0 transition-inherit-all"
79
+ },
80
+ sizes: {
81
+ xs: {
82
+ root: [
83
+ "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",
84
+ "in-data-input-wrapper:data-icon-only:p-2.5",
85
+ "*:data-icon:size-4"
86
+ ].join(" "),
87
+ linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-3"
88
+ },
89
+ sm: {
90
+ root: [
91
+ "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",
92
+ "in-data-input-wrapper:data-icon-only:p-2.5",
93
+ "*:data-icon:size-5"
94
+ ].join(" "),
95
+ linkRoot: "h-auto min-h-0 gap-1 px-0! py-0! text-sm *:data-text:underline-offset-3"
96
+ },
97
+ md: {
98
+ root: [
99
+ "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",
100
+ "in-data-input-wrapper:data-icon-only:p-3",
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-4"
104
+ },
105
+ lg: {
106
+ 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",
107
+ linkRoot: "h-auto min-h-0 gap-1.5 px-0! py-0! text-md *:data-text:underline-offset-4"
108
+ },
109
+ xl: {
110
+ 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",
111
+ linkRoot: "h-auto min-h-0 gap-1.5 px-0! py-0! text-md *:data-text:underline-offset-4"
112
+ }
113
+ },
114
+ colors: {
115
+ /** Figma Hierarchy=Primary — dark neutral solid; hover lightens to fg-tertiary_hover (#404040). */
116
+ primary: {
117
+ root: [
118
+ "bg-primary-solid text-white",
119
+ skeuomorphicShadowClass,
120
+ skeuomorphicGradientBorderClass,
121
+ "hover:bg-fg-tertiary_hover dark:hover:bg-quaternary",
122
+ "disabled:opacity-30",
123
+ "data-loading:bg-fg-tertiary_hover dark:data-loading:bg-quaternary",
124
+ "*:data-icon:not([data-icon=loading]):text-white/70"
125
+ ].join(" ")
126
+ },
127
+ /** Figma Hierarchy=Brand — purple solid; hover darkens to bg-brand-solid_hover (#6d28d9). */
128
+ brand: {
129
+ root: [
130
+ "bg-brand-solid text-primary_on-brand",
131
+ skeuomorphicShadowClass,
132
+ skeuomorphicGradientBorderClass,
133
+ "hover:bg-brand-solid_hover",
134
+ "disabled:opacity-50",
135
+ "data-loading:bg-brand-solid_hover",
136
+ "*:data-icon:not([data-icon=loading]):text-primary_on-brand"
137
+ ].join(" ")
138
+ },
139
+ /** Figma Hierarchy=Secondary — border-primary + shadow-xs + skeuomorphic inner rim overlay. */
140
+ secondary: {
141
+ root: [
142
+ "border border-solid border-primary bg-primary text-secondary",
143
+ secondaryShadowClass,
144
+ "hover:bg-primary_hover hover:text-secondary_hover",
145
+ "disabled:opacity-50",
146
+ "data-loading:bg-primary_hover",
147
+ "*:data-icon:text-fg-secondary"
148
+ ].join(" ")
149
+ },
150
+ /** Figma Hierarchy=Tertiary */
151
+ tertiary: {
152
+ root: [
153
+ "border border-transparent bg-transparent text-tertiary",
154
+ focusShadowPlain,
155
+ "hover:bg-primary_hover hover:text-tertiary_hover",
156
+ "disabled:opacity-50",
157
+ "*:data-icon:text-fg-tertiary"
158
+ ].join(" ")
159
+ },
160
+ /** Figma Hierarchy=Link color — text + icons share brand-secondary; hover underlines with fg-brand-secondary. */
161
+ "link-color": {
162
+ root: [
163
+ "h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-brand-secondary shadow-none",
164
+ focusShadowPlain,
165
+ "hover:text-brand-secondary_hover",
166
+ "disabled:opacity-50",
167
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-fg-brand-secondary"
168
+ ].join(" ")
169
+ },
170
+ /** Figma Hierarchy=Link gray — text + icons share tertiary; hover underlines with fg-quaternary. */
171
+ "link-gray": {
172
+ root: [
173
+ "h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-tertiary shadow-none",
174
+ focusShadowPlain,
175
+ "hover:text-tertiary_hover",
176
+ "disabled:opacity-50",
177
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-fg-quaternary"
178
+ ].join(" ")
179
+ },
180
+ "primary-destructive": {
181
+ root: [
182
+ "bg-error-solid text-white",
183
+ skeuomorphicShadowClass,
184
+ skeuomorphicGradientBorderClass,
185
+ "hover:bg-error-solid_hover",
186
+ "disabled:opacity-50",
187
+ "data-loading:bg-error-solid_hover",
188
+ "*:data-icon:not([data-icon=loading]):text-white/70"
189
+ ].join(" ")
190
+ },
191
+ "secondary-destructive": {
192
+ root: [
193
+ "border border-solid border-primary bg-primary text-error-primary",
194
+ secondaryShadowClass,
195
+ "hover:bg-error-primary hover:text-error-primary_hover",
196
+ "disabled:opacity-50",
197
+ "data-loading:bg-error-primary",
198
+ "*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
199
+ ].join(" ")
200
+ },
201
+ "tertiary-destructive": {
202
+ root: [
203
+ "border border-transparent bg-transparent text-error-primary",
204
+ focusShadowPlain,
205
+ "hover:bg-error-primary hover:text-error-primary_hover",
206
+ "disabled:opacity-50",
207
+ "*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
208
+ ].join(" ")
209
+ },
210
+ /** Figma Hierarchy=Link (destructive) — text + icons share error-primary; hover underlines. */
211
+ "link-destructive": {
212
+ root: [
213
+ "h-auto min-h-0 border-0 bg-transparent px-0! py-0! text-error-primary shadow-none",
214
+ focusShadowPlain,
215
+ "hover:text-error-primary_hover",
216
+ "disabled:opacity-50",
217
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:decoration-solid hover:*:data-text:decoration-current"
218
+ ].join(" ")
219
+ }
220
+ }
221
+ });
222
+ var Button = ({
223
+ size = "md",
224
+ color = "primary",
225
+ children,
226
+ className,
227
+ noTextPadding,
228
+ iconLeading: IconLeading,
229
+ iconTrailing: IconTrailing,
230
+ isDisabled: disabled,
231
+ isLoading: loading,
232
+ showTextWhileLoading,
233
+ ...props
234
+ }) => {
235
+ const href = "href" in props ? props.href : void 0;
236
+ const isIcon = (IconLeading || IconTrailing) && !children;
237
+ const isLinkType = ["link-gray", "link-color", "link-destructive"].includes(color);
238
+ noTextPadding = isLinkType || noTextPadding;
239
+ const commonChildren = /* @__PURE__ */ jsxs(Fragment$1, { children: [
240
+ isValidElement(IconLeading) && IconLeading,
241
+ isReactComponent(IconLeading) && /* @__PURE__ */ jsx(IconLeading, { "data-icon": "leading", className: styles.common.icon }),
242
+ loading && /* @__PURE__ */ jsx(
243
+ "svg",
244
+ {
245
+ fill: "none",
246
+ "data-icon": "loading",
247
+ viewBox: "0 0 256 256",
248
+ "aria-hidden": true,
249
+ className: cx(
250
+ styles.common.icon,
251
+ "size-5 animate-spin",
252
+ !showTextWhileLoading && "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
253
+ ),
254
+ children: /* @__PURE__ */ jsx(
255
+ "path",
256
+ {
257
+ fill: "currentColor",
258
+ 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"
259
+ }
260
+ )
261
+ }
262
+ ),
263
+ children && /* @__PURE__ */ jsx("span", { "data-text": true, className: cx("transition-inherit-all", !noTextPadding && !isLinkType && "px-0.5"), children }),
264
+ isValidElement(IconTrailing) && IconTrailing,
265
+ isReactComponent(IconTrailing) && /* @__PURE__ */ jsx(IconTrailing, { "data-icon": "trailing", className: styles.common.icon })
266
+ ] });
267
+ const commonProps = {
268
+ "data-icon-only": isIcon ? true : void 0,
269
+ "data-loading": loading ? true : void 0,
270
+ ...props,
271
+ isDisabled: disabled || loading,
272
+ className: cx(
273
+ styles.common.root,
274
+ styles.sizes[size].root,
275
+ styles.colors[color].root,
276
+ isLinkType && styles.sizes[size].linkRoot,
277
+ (loading || href && (disabled || loading)) && "pointer-events-none",
278
+ loading && (showTextWhileLoading ? "[&>*:not([data-icon=loading]):not([data-text])]:hidden" : "[&>*:not([data-icon=loading])]:invisible"),
279
+ className
280
+ ),
281
+ children: commonChildren
282
+ };
283
+ if ("href" in commonProps) {
284
+ return /* @__PURE__ */ jsx(Link, { ...commonProps, href: disabled || loading ? void 0 : href });
285
+ }
286
+ return /* @__PURE__ */ jsx(Button$1, { ...commonProps, type: commonProps.type || "button", isPending: loading });
287
+ };
288
+ var Tooltip = ({
289
+ title,
290
+ description,
291
+ children,
292
+ arrow = false,
293
+ delay = 100,
294
+ closeDelay = 0,
295
+ trigger,
296
+ isDisabled,
297
+ isOpen,
298
+ defaultOpen,
299
+ offset = 6,
300
+ crossOffset,
301
+ placement = "top",
302
+ onOpenChange,
303
+ ...tooltipProps
304
+ }) => {
305
+ const isTopOrBottomLeft = ["top left", "top end", "bottom left", "bottom end"].includes(placement);
306
+ const isTopOrBottomRight = ["top right", "top start", "bottom right", "bottom start"].includes(placement);
307
+ const calculatedCrossOffset = isTopOrBottomLeft ? -12 : isTopOrBottomRight ? 12 : 0;
308
+ return /* @__PURE__ */ jsxs(TooltipTrigger$1, { ...{ trigger, delay, closeDelay, isDisabled, isOpen, defaultOpen, onOpenChange }, children: [
309
+ children,
310
+ /* @__PURE__ */ jsx(
311
+ Tooltip$1,
312
+ {
313
+ ...tooltipProps,
314
+ offset,
315
+ placement,
316
+ crossOffset: crossOffset ?? calculatedCrossOffset,
317
+ className: ({ isEntering, isExiting }) => cx(isEntering && "ease-out animate-in", isExiting && "ease-in animate-out"),
318
+ children: ({ isEntering, isExiting }) => /* @__PURE__ */ jsxs(
319
+ "div",
320
+ {
321
+ className: cx(
322
+ "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",
323
+ description ? "py-3" : "py-2",
324
+ 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",
325
+ 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"
326
+ ),
327
+ children: [
328
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-white", children: title }),
329
+ description && /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-tooltip-supporting-text", children: description }),
330
+ arrow && /* @__PURE__ */ jsx(OverlayArrow, { children: /* @__PURE__ */ jsx(
331
+ "svg",
332
+ {
333
+ viewBox: "0 0 100 100",
334
+ 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",
335
+ children: /* @__PURE__ */ jsx("path", { d: "M0,0 L35.858,35.858 Q50,50 64.142,35.858 L100,0 Z" })
336
+ }
337
+ ) })
338
+ ]
339
+ }
340
+ )
341
+ }
342
+ )
343
+ ] });
344
+ };
345
+ var TooltipTrigger = ({ children, className, ...buttonProps }) => {
346
+ return /* @__PURE__ */ jsx(Button$1, { ...buttonProps, className: (values) => cx("h-max w-max outline-hidden", typeof className === "function" ? className(values) : className), children });
347
+ };
348
+ var inputFocusRingShadow = "border-brand ring-1 ring-inset ring-brand";
349
+ var inputErrorFocusRingShadow = "border-error ring-1 ring-inset ring-error";
350
+ createContext({});
351
+ var DateFieldContext = createContext({});
352
+ var InputDateBase = ({
353
+ tooltip,
354
+ shortcut,
355
+ groupRef,
356
+ size = "md",
357
+ isInvalid,
358
+ isDisabled,
359
+ icon: Icon,
360
+ wrapperClassName,
361
+ tooltipClassName,
362
+ iconClassName,
363
+ ...inputProps
364
+ }) => {
365
+ const hasTrailingIcon = tooltip || isInvalid;
366
+ const hasLeadingIcon = Icon;
367
+ const context = useContext(DateFieldContext);
368
+ const inputSize = context?.size || size;
369
+ const sizes = sortCx({
370
+ sm: {
371
+ root: cx("px-3 py-2 text-sm", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-8.5"),
372
+ iconLeading: "left-3 size-4 stroke-[2.25px]",
373
+ iconTrailing: "right-3",
374
+ shortcut: "pr-2.5"
375
+ },
376
+ md: {
377
+ root: cx("px-3 py-2 text-md", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-10"),
378
+ iconLeading: "left-3 size-5",
379
+ iconTrailing: "right-3",
380
+ shortcut: "pr-2.5"
381
+ },
382
+ lg: {
383
+ root: cx("px-3.5 py-2.5 text-md", hasTrailingIcon && "pr-9.5", hasLeadingIcon && "pl-10.5"),
384
+ iconLeading: "left-3.5 size-5",
385
+ iconTrailing: "right-3.5",
386
+ shortcut: "pr-3"
387
+ }
388
+ });
389
+ return /* @__PURE__ */ jsxs(
390
+ Group,
391
+ {
392
+ ...{ isDisabled, isInvalid },
393
+ ref: groupRef,
394
+ className: ({ isFocusWithin, isDisabled: isDisabled2, isInvalid: isInvalid2 }) => cx(
395
+ "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",
396
+ isFocusWithin && !isDisabled2 && !isInvalid2 && inputFocusRingShadow,
397
+ // Disabled state styles
398
+ isDisabled2 && "cursor-not-allowed opacity-50 in-data-input-wrapper:opacity-100",
399
+ "group-disabled:cursor-not-allowed group-disabled:opacity-50 in-data-input-wrapper:group-disabled:opacity-100",
400
+ // Invalid state styles
401
+ isInvalid2 && !isFocusWithin && "border-error_subtle",
402
+ "group-invalid:border-error_subtle",
403
+ "group-invalid:focus-within:border-error group-invalid:focus-within:ring-1 group-invalid:focus-within:ring-inset group-invalid:focus-within:ring-error",
404
+ isInvalid2 && isFocusWithin && inputErrorFocusRingShadow,
405
+ context?.wrapperClassName,
406
+ wrapperClassName
407
+ ),
408
+ children: [
409
+ Icon && /* @__PURE__ */ jsx(Icon, { className: cx("pointer-events-none absolute text-fg-quaternary", sizes[inputSize].iconLeading, context?.iconClassName, iconClassName) }),
410
+ /* @__PURE__ */ jsx(DateInput, { ...inputProps, className: cx("flex w-full", sizes[size].root, typeof inputProps.className === "string" && inputProps.className), children: (segment) => /* @__PURE__ */ jsx(
411
+ DateSegment,
412
+ {
413
+ segment,
414
+ className: cx(
415
+ "rounded px-0.5 text-primary tabular-nums caret-transparent focus:bg-brand-solid focus:font-medium focus:text-white focus:outline-hidden",
416
+ // The placeholder segment.
417
+ segment.isPlaceholder && "text-placeholder uppercase",
418
+ // The separator "/" segment.
419
+ segment.type === "literal" && "text-fg-quaternary"
420
+ )
421
+ }
422
+ ) }),
423
+ tooltip && /* @__PURE__ */ jsx(Tooltip, { title: tooltip, placement: "top", children: /* @__PURE__ */ jsx(
424
+ TooltipTrigger,
425
+ {
426
+ className: cx(
427
+ "absolute cursor-pointer text-fg-quaternary transition duration-200 group-invalid/input:hidden hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
428
+ sizes[inputSize].iconTrailing,
429
+ context?.tooltipClassName,
430
+ tooltipClassName
431
+ ),
432
+ children: /* @__PURE__ */ jsx(QuestionIcon, { className: "size-4 stroke-[2.25px]" })
433
+ }
434
+ ) }),
435
+ /* @__PURE__ */ jsx(
436
+ InfoIcon,
437
+ {
438
+ className: cx(
439
+ "pointer-events-none absolute hidden size-4 stroke-[2.25px] text-fg-error-secondary group-invalid/input:block",
440
+ sizes[inputSize].iconTrailing,
441
+ context?.tooltipClassName,
442
+ tooltipClassName
443
+ )
444
+ }
445
+ ),
446
+ shortcut && /* @__PURE__ */ jsx(
447
+ "div",
448
+ {
449
+ className: cx(
450
+ "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",
451
+ sizes[inputSize].shortcut
452
+ ),
453
+ children: /* @__PURE__ */ jsx(
454
+ "span",
455
+ {
456
+ "aria-hidden": "true",
457
+ className: "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
458
+ children: typeof shortcut === "string" ? shortcut : "\u2318K"
459
+ }
460
+ )
461
+ }
462
+ )
463
+ ]
464
+ }
465
+ );
466
+ };
467
+ var CalendarCell = ({ date, isHighlighted, showOutOfRangeDates = false, fluid = false, ...props }) => {
468
+ const { locale } = useLocale();
469
+ const dayOfWeek = getDayOfWeek(date, locale);
470
+ const rangeCalendarContext = useSlottedContext(RangeCalendarContext);
471
+ const isRangeCalendar = !!rangeCalendarContext;
472
+ const start = rangeCalendarContext?.value?.start;
473
+ const end = rangeCalendarContext?.value?.end;
474
+ const isAfterStart = start ? date.compare(start) > 0 : true;
475
+ const isBeforeEnd = end ? date.compare(end) < 0 : true;
476
+ const isAfterOrOnStart = start && date.compare(start) >= 0;
477
+ const isBeforeOrOnEnd = end && date.compare(end) <= 0;
478
+ const isInRange = isAfterOrOnStart && isBeforeOrOnEnd;
479
+ const lastDayOfMonth = new Date(date.year, date.month, 0).getDate();
480
+ const isLastDayOfMonth = date.day === lastDayOfMonth;
481
+ const isFirstDayOfMonth = date.day === 1;
482
+ const isTodayDate = isToday(date, getLocalTimeZone());
483
+ return /* @__PURE__ */ jsx(
484
+ CalendarCell$1,
485
+ {
486
+ ...props,
487
+ date,
488
+ className: ({ isDisabled, isFocusVisible, isSelectionStart, isSelectionEnd, isSelected, isOutsideMonth }) => {
489
+ const isRoundedLeft = isSelectionStart || dayOfWeek === 0;
490
+ const isRoundedRight = isSelectionEnd || dayOfWeek === 6;
491
+ return cx(
492
+ "relative focus:outline-hidden",
493
+ fluid ? "aspect-square w-full" : "size-10",
494
+ isRoundedLeft && "rounded-l-full",
495
+ isRoundedRight && "rounded-r-full",
496
+ isInRange && isDisabled && "bg-secondary",
497
+ isSelected && isRangeCalendar && "bg-secondary",
498
+ isDisabled ? "pointer-events-none" : "cursor-pointer",
499
+ isFocusVisible ? "z-10" : "z-0",
500
+ isOutsideMonth && "opacity-50",
501
+ isRangeCalendar && isOutsideMonth && !showOutOfRangeDates && "hidden",
502
+ // Show gradient on last day of month if it's within the selected range.
503
+ 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",
504
+ // Show gradient on first day of month if it's within the selected range.
505
+ 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"
506
+ );
507
+ },
508
+ children: ({ isDisabled, isFocusVisible, isSelectionStart, isSelectionEnd, isSelected, formattedDate }) => {
509
+ const markedAsSelected = isSelectionStart || isSelectionEnd || isSelected && !isDisabled && !isRangeCalendar;
510
+ return /* @__PURE__ */ jsxs(
511
+ "div",
512
+ {
513
+ className: cx(
514
+ "relative flex size-full items-center justify-center rounded-full text-sm text-secondary hover:text-secondary_hover",
515
+ // Disabled state.
516
+ isDisabled && "text-secondary/50",
517
+ // Focus ring, visible while the cell has keyboard focus.
518
+ isFocusVisible ? "outline-2 outline-offset-2 outline-focus-ring" : "",
519
+ // Hover state for cells in the middle of the range.
520
+ isSelected && !isDisabled && isRangeCalendar ? "font-medium" : "",
521
+ markedAsSelected && "bg-brand-solid font-medium text-white hover:bg-brand-solid_hover hover:text-white",
522
+ // Hover state for non-selected cells.
523
+ !isSelected && !isDisabled ? "hover:bg-primary_hover hover:font-medium!" : "",
524
+ !isSelected && isTodayDate ? "bg-secondary font-medium hover:bg-secondary_hover" : ""
525
+ ),
526
+ children: [
527
+ formattedDate,
528
+ (isHighlighted || isTodayDate) && /* @__PURE__ */ jsx(
529
+ "div",
530
+ {
531
+ className: cx(
532
+ "absolute bottom-1 left-1/2 size-1.25 -translate-x-1/2 rounded-full",
533
+ markedAsSelected ? "bg-fg-white" : "bg-fg-brand-primary",
534
+ isDisabled && "opacity-50"
535
+ )
536
+ }
537
+ )
538
+ ]
539
+ }
540
+ );
541
+ }
542
+ }
543
+ );
544
+ };
545
+ var CalendarContextProvider = ({ children }) => {
546
+ const [value, setValue] = useState(null);
547
+ const [focusedValue, onFocusChange] = useState();
548
+ const onChange = (next) => {
549
+ if (Array.isArray(next)) return;
550
+ setValue(next);
551
+ };
552
+ return /* @__PURE__ */ jsx(CalendarContext.Provider, { value: { value, onChange, focusedValue, onFocusChange }, children });
553
+ };
554
+ var Calendar = ({ highlightedDates, fluid = false, className, children, ...props }) => {
555
+ const context = useSlottedContext(CalendarContext);
556
+ const ContextWrapper = context ? Fragment : CalendarContextProvider;
557
+ return /* @__PURE__ */ jsx(ContextWrapper, { children: /* @__PURE__ */ jsx(
558
+ Calendar$1,
559
+ {
560
+ ...props,
561
+ className: (state) => cx("flex flex-col gap-3", fluid && "w-full", typeof className === "function" ? className(state) : className),
562
+ children: ({ state }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
563
+ /* @__PURE__ */ jsxs("header", { className: "flex items-center justify-between", children: [
564
+ /* @__PURE__ */ jsx(Button, { slot: "previous", iconLeading: CaretLeftIcon, size: "sm", color: "tertiary", className: "size-8" }),
565
+ /* @__PURE__ */ jsx(Heading, { className: "text-sm font-semibold text-fg-secondary" }),
566
+ /* @__PURE__ */ jsx(Button, { slot: "next", iconLeading: CaretRightIcon, size: "sm", color: "tertiary", className: "size-8" })
567
+ ] }),
568
+ children || /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
569
+ /* @__PURE__ */ jsx(InputDateBase, { "aria-label": "Date", size: "sm", className: "flex-1" }),
570
+ /* @__PURE__ */ jsx(
571
+ Button,
572
+ {
573
+ slot: null,
574
+ size: "sm",
575
+ color: "secondary",
576
+ onClick: () => {
577
+ state.setValue(today(getLocalTimeZone()));
578
+ state.setFocusedDate(today(getLocalTimeZone()));
579
+ },
580
+ children: "Today"
581
+ }
582
+ )
583
+ ] }),
584
+ /* @__PURE__ */ jsxs(CalendarGrid, { weekdayStyle: "short", className: cx(fluid ? "w-full table-fixed" : "w-max"), children: [
585
+ /* @__PURE__ */ jsx(CalendarGridHeader, { className: "border-b-4 border-transparent", children: (day) => /* @__PURE__ */ jsx(CalendarHeaderCell, { className: "p-0", children: /* @__PURE__ */ jsx(
586
+ "div",
587
+ {
588
+ className: cx(
589
+ "flex items-center justify-center text-sm font-medium text-secondary",
590
+ fluid ? "h-10 w-full" : "size-10"
591
+ ),
592
+ children: day.slice(0, 2)
593
+ }
594
+ ) }) }),
595
+ /* @__PURE__ */ jsx(CalendarGridBody, { className: "[&_td]:p-0 [&_tr]:border-b-4 [&_tr]:border-transparent [&_tr:last-of-type]:border-none", children: (date) => /* @__PURE__ */ jsx(
596
+ CalendarCell,
597
+ {
598
+ date,
599
+ fluid,
600
+ isHighlighted: highlightedDates?.some((highlightedDate) => date.compare(highlightedDate) === 0)
601
+ }
602
+ ) })
603
+ ] })
604
+ ] })
605
+ }
606
+ ) });
607
+ };
608
+
609
+ export { Calendar, CalendarContextProvider };
610
+ //# sourceMappingURL=calendar.js.map
611
+ //# sourceMappingURL=calendar.js.map