@avenue-ticketing/ui 0.12.0-beta.1 → 0.12.0-beta.2

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.
Files changed (65) hide show
  1. package/dist/react/checkbox.js +10 -7
  2. package/dist/react/checkbox.js.map +1 -1
  3. package/dist/react/combobox.d.ts +3 -2
  4. package/dist/react/combobox.js +284 -32
  5. package/dist/react/combobox.js.map +1 -1
  6. package/dist/react/dropdown-account-breadcrumb.js +176 -14
  7. package/dist/react/dropdown-account-breadcrumb.js.map +1 -1
  8. package/dist/react/dropdown-account-button.js +186 -21
  9. package/dist/react/dropdown-account-button.js.map +1 -1
  10. package/dist/react/dropdown-account-card-md.js +187 -22
  11. package/dist/react/dropdown-account-card-md.js.map +1 -1
  12. package/dist/react/dropdown-account-card-sm.js +187 -22
  13. package/dist/react/dropdown-account-card-sm.js.map +1 -1
  14. package/dist/react/dropdown-account-card-xs.js +187 -22
  15. package/dist/react/dropdown-account-card-xs.js.map +1 -1
  16. package/dist/react/dropdown-avatar.js +186 -21
  17. package/dist/react/dropdown-avatar.js.map +1 -1
  18. package/dist/react/dropdown-button-advanced.js +186 -21
  19. package/dist/react/dropdown-button-advanced.js.map +1 -1
  20. package/dist/react/dropdown-button-link.js +187 -22
  21. package/dist/react/dropdown-button-link.js.map +1 -1
  22. package/dist/react/dropdown-button-simple.js +186 -21
  23. package/dist/react/dropdown-button-simple.js.map +1 -1
  24. package/dist/react/dropdown-icon-advanced.js +187 -22
  25. package/dist/react/dropdown-icon-advanced.js.map +1 -1
  26. package/dist/react/dropdown-icon-simple.js +187 -22
  27. package/dist/react/dropdown-icon-simple.js.map +1 -1
  28. package/dist/react/dropdown-integration.js +186 -21
  29. package/dist/react/dropdown-integration.js.map +1 -1
  30. package/dist/react/dropdown-search-advanced.js +186 -21
  31. package/dist/react/dropdown-search-advanced.js.map +1 -1
  32. package/dist/react/dropdown-search-simple.js +186 -21
  33. package/dist/react/dropdown-search-simple.js.map +1 -1
  34. package/dist/react/dropdown.d.ts +4 -1
  35. package/dist/react/dropdown.js +187 -22
  36. package/dist/react/dropdown.js.map +1 -1
  37. package/dist/react/input-tags-outer.js +8 -8
  38. package/dist/react/input-tags-outer.js.map +1 -1
  39. package/dist/react/input-tags.js +8 -8
  40. package/dist/react/input-tags.js.map +1 -1
  41. package/dist/react/multi-select.d.ts +3 -2
  42. package/dist/react/multi-select.js +228 -27
  43. package/dist/react/multi-select.js.map +1 -1
  44. package/dist/react/popover.d.ts +10 -1
  45. package/dist/react/popover.js +195 -18
  46. package/dist/react/popover.js.map +1 -1
  47. package/dist/react/radio-buttons.js +2 -1
  48. package/dist/react/radio-buttons.js.map +1 -1
  49. package/dist/react/select-item.d.ts +2 -1
  50. package/dist/react/select-item.js +11 -7
  51. package/dist/react/select-item.js.map +1 -1
  52. package/dist/react/select.d.ts +4 -3
  53. package/dist/react/select.js +298 -42
  54. package/dist/react/select.js.map +1 -1
  55. package/dist/react/switch.js +1 -1
  56. package/dist/react/switch.js.map +1 -1
  57. package/dist/react/tag-select.d.ts +5 -2
  58. package/dist/react/tag-select.js +215 -25
  59. package/dist/react/tag-select.js.map +1 -1
  60. package/dist/react/tags.js +8 -8
  61. package/dist/react/tags.js.map +1 -1
  62. package/dist/select-mobile-sheet-CB2ptDTJ.d.ts +12 -0
  63. package/dist/{select-shared-B3Y5SMXU.d.ts → select-shared-oJEeJxeB.d.ts} +6 -0
  64. package/package.json +1 -1
  65. package/theme.css +1 -1
@@ -1,4 +1,4 @@
1
- import { createContext, useState, useCallback, useRef, useLayoutEffect } from 'react';
1
+ import { createContext, useState, useMemo, useContext, useEffect, useCallback, useLayoutEffect, useRef } from 'react';
2
2
  import { ArrowLeftIcon } from '@phosphor-icons/react/dist/csr/ArrowLeft';
3
3
  import { ArrowRightIcon } from '@phosphor-icons/react/dist/csr/ArrowRight';
4
4
  import { CodeIcon } from '@phosphor-icons/react/dist/csr/Code';
@@ -9,15 +9,92 @@ import { PencilLineIcon } from '@phosphor-icons/react/dist/csr/PencilLine';
9
9
  import { ArrowCounterClockwiseIcon } from '@phosphor-icons/react/dist/csr/ArrowCounterClockwise';
10
10
  import { ScissorsIcon } from '@phosphor-icons/react/dist/csr/Scissors';
11
11
  import { StarIcon } from '@phosphor-icons/react/dist/csr/Star';
12
- import { MenuTrigger, MenuSection, SubmenuTrigger, Button, Popover, Menu, MenuItem, Separator } from 'react-aria-components';
12
+ import { MenuTrigger, MenuSection, SubmenuTrigger, Button, OverlayTriggerStateContext, Popover, Menu, MenuItem, Separator } from 'react-aria-components';
13
+ import { createPortal } from 'react-dom';
13
14
  import { CheckIcon } from '@phosphor-icons/react/dist/csr/Check';
14
15
  import { CaretRightIcon } from '@phosphor-icons/react/dist/csr/CaretRight';
15
16
  import { DotsThreeVerticalIcon } from '@phosphor-icons/react/dist/csr/DotsThreeVertical';
17
+ import { XIcon } from '@phosphor-icons/react/dist/csr/X';
16
18
  import { extendTailwindMerge } from 'tailwind-merge';
17
19
  import { UserIcon } from '@phosphor-icons/react/dist/csr/User';
18
20
  import '@phosphor-icons/react/dist/csr/Plus';
19
- import { jsxs, jsx } from 'react/jsx-runtime';
21
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
20
22
 
23
+ var MOBILE_SHEET_MOTION_MS = 175;
24
+ var MOBILE_SHEET_ENTRY_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
25
+ var MOBILE_SHEET_EXIT_EASING = "cubic-bezier(0.85, 0, 1, 0.15)";
26
+ var MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX = 120;
27
+ function resolveSelectMobileOptions(mobileOptions) {
28
+ return {
29
+ sheet: mobileOptions?.sheet ?? true,
30
+ title: mobileOptions?.title,
31
+ sheetClassName: mobileOptions?.className,
32
+ contentClassName: mobileOptions?.contentClassName
33
+ };
34
+ }
35
+ function useMobileSheetAnimation(open, enabled, slideEntrance = true, slideOffsetPx = MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX) {
36
+ const [shouldRender, setShouldRender] = useState(open);
37
+ const [isAnimating, setIsAnimating] = useState(false);
38
+ useLayoutEffect(() => {
39
+ if (!enabled) {
40
+ setShouldRender(open);
41
+ return;
42
+ }
43
+ if (open) {
44
+ setShouldRender(true);
45
+ }
46
+ }, [open, enabled]);
47
+ useEffect(() => {
48
+ if (!enabled || open) return;
49
+ const timer = setTimeout(() => setShouldRender(false), MOBILE_SHEET_MOTION_MS);
50
+ return () => clearTimeout(timer);
51
+ }, [open, enabled]);
52
+ useLayoutEffect(() => {
53
+ if (!enabled || open || !shouldRender) return;
54
+ setIsAnimating(false);
55
+ }, [enabled, open, shouldRender]);
56
+ useEffect(() => {
57
+ if (!enabled || !shouldRender || !open) return;
58
+ let raf2 = 0;
59
+ const raf1 = requestAnimationFrame(() => {
60
+ raf2 = requestAnimationFrame(() => setIsAnimating(true));
61
+ });
62
+ return () => {
63
+ cancelAnimationFrame(raf1);
64
+ if (raf2) cancelAnimationFrame(raf2);
65
+ };
66
+ }, [shouldRender, open, enabled]);
67
+ const motionEasing = open ? MOBILE_SHEET_ENTRY_EASING : MOBILE_SHEET_EXIT_EASING;
68
+ const hiddenTransform = slideEntrance ? `translateY(${slideOffsetPx}px)` : "translateY(100%)";
69
+ const panelStyle = enabled ? {
70
+ transform: isAnimating ? "translateY(0)" : hiddenTransform,
71
+ opacity: isAnimating ? 1 : 0,
72
+ transitionProperty: "transform, opacity",
73
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
74
+ transitionTimingFunction: motionEasing
75
+ } : void 0;
76
+ const backdropStyle = enabled ? {
77
+ opacity: isAnimating ? 1 : 0,
78
+ transitionProperty: "opacity",
79
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
80
+ transitionTimingFunction: motionEasing
81
+ } : void 0;
82
+ return { shouldRender, isAnimating, panelStyle, backdropStyle };
83
+ }
84
+ var MOBILE_SHEET_MAX_PX = 1024;
85
+ function useIsMobile(breakpoint = MOBILE_SHEET_MAX_PX + 1) {
86
+ const [isMobile, setIsMobile] = useState(() => {
87
+ if (typeof window === "undefined") return false;
88
+ return window.matchMedia(`(max-width: ${breakpoint - 1}px)`).matches;
89
+ });
90
+ useEffect(() => {
91
+ const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
92
+ const handler = (e) => setIsMobile(e.matches);
93
+ mq.addEventListener("change", handler);
94
+ return () => mq.removeEventListener("change", handler);
95
+ }, [breakpoint]);
96
+ return isMobile;
97
+ }
21
98
  var twMerge = extendTailwindMerge({
22
99
  extend: {
23
100
  theme: {
@@ -178,7 +255,7 @@ var Avatar = ({
178
255
  };
179
256
  var CHECKBOX_TICK_DELAY_MS = 60;
180
257
  var CHECKBOX_TICK_DRAW_MS = 100;
181
- function CheckboxAnimatedCheckMark({ className }) {
258
+ function CheckboxAnimatedCheckMark({ pixelSize, className }) {
182
259
  const pathRef = useRef(null);
183
260
  useLayoutEffect(() => {
184
261
  const path = pathRef.current;
@@ -199,7 +276,7 @@ function CheckboxAnimatedCheckMark({ className }) {
199
276
  });
200
277
  return () => anim.cancel();
201
278
  }, []);
202
- return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", viewBox: "0 0 14 14", fill: "none", className: cx("block shrink-0", className), children: /* @__PURE__ */ jsx(
279
+ 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(
203
280
  "path",
204
281
  {
205
282
  ref: pathRef,
@@ -214,14 +291,15 @@ function CheckboxAnimatedCheckMark({ className }) {
214
291
  var focusRingShadow = "outline-none [box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
215
292
  var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = "sm", isFocusVisible = false }) => {
216
293
  const isChecked = isSelected || isIndeterminate;
217
- const iconClassName = size === "sm" ? "size-2.5" : "size-3.5";
294
+ const iconPixelSize = size === "sm" ? 10 : 14;
218
295
  return /* @__PURE__ */ jsxs(
219
296
  "div",
220
297
  {
221
298
  className: cx(
222
- "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center border border-solid border-primary",
299
+ "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip border border-solid border-primary",
223
300
  size === "sm" ? "size-4 rounded-xs" : "size-5 rounded-sm",
224
301
  isChecked ? "border-transparent bg-brand-solid" : "bg-primary",
302
+ !isChecked && !isDisabled && "group-hover:bg-primary_hover",
225
303
  isDisabled && "cursor-not-allowed opacity-50",
226
304
  isDisabled && !isChecked && "bg-tertiary",
227
305
  isFocusVisible && !isDisabled && focusRingShadow,
@@ -232,13 +310,15 @@ var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size =
232
310
  "svg",
233
311
  {
234
312
  "aria-hidden": "true",
313
+ width: iconPixelSize,
314
+ height: iconPixelSize,
235
315
  viewBox: "0 0 14 14",
236
316
  fill: "none",
237
- className: cx("pointer-events-none block shrink-0 text-fg-white", iconClassName),
317
+ className: "pointer-events-none block text-fg-white",
238
318
  children: /* @__PURE__ */ jsx("path", { d: "M2.91675 7H11.0834", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
239
319
  }
240
320
  ),
241
- isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { className: cx("pointer-events-none text-fg-white", iconClassName) })
321
+ isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: "pointer-events-none text-fg-white" })
242
322
  ]
243
323
  }
244
324
  );
@@ -283,6 +363,7 @@ var RadioButtonBase = ({ className, isFocusVisible, isSelected, isDisabled, size
283
363
  "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip rounded-full border border-solid border-primary bg-primary",
284
364
  size === "sm" ? "size-4" : "size-5",
285
365
  isSelected && "border-transparent bg-brand-solid",
366
+ !isSelected && !isDisabled && "group-hover:bg-primary_hover",
286
367
  isDisabled && "cursor-not-allowed opacity-50",
287
368
  isDisabled && !isSelected && "bg-tertiary",
288
369
  isFocusVisible && !isDisabled && focusRingShadow2,
@@ -324,7 +405,7 @@ var ToggleBase = ({ className, isHovered, isDisabled, isFocusVisible, isSelected
324
405
  const classes = slim ? styles2.slim[size] : styles2.default[size];
325
406
  const offTrackBackground = (() => {
326
407
  if (isDisabled) return "bg-tertiary";
327
- if (isHovered) return slim ? "bg-tertiary" : "bg-brand-primary";
408
+ if (isHovered) return "bg-secondary_hover";
328
409
  return "bg-quaternary";
329
410
  })();
330
411
  return /* @__PURE__ */ jsx(
@@ -440,21 +521,105 @@ var DropdownMenu = (props) => {
440
521
  }
441
522
  );
442
523
  };
443
- var DropdownPopover = (props) => {
444
- return /* @__PURE__ */ jsx(
445
- Popover,
524
+ var DropdownSheetDepthContext = createContext(0);
525
+ function DropdownSheetCloseButton({ onClose }) {
526
+ return /* @__PURE__ */ jsxs(
527
+ "button",
446
528
  {
447
- placement: "bottom right",
448
- ...props,
449
- className: (state) => cx(
450
- "w-62 origin-(--trigger-anchor-point) overflow-auto rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
451
- 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",
452
- 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",
453
- typeof props.className === "function" ? props.className(state) : props.className
454
- ),
455
- children: props.children
529
+ type: "button",
530
+ onClick: (e) => {
531
+ e.stopPropagation();
532
+ onClose();
533
+ },
534
+ 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)]",
535
+ children: [
536
+ /* @__PURE__ */ jsx(XIcon, { className: "size-5", "aria-hidden": "true" }),
537
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
538
+ ]
456
539
  }
457
540
  );
541
+ }
542
+ function DropdownSheetChrome({ title, onClose, children }) {
543
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
544
+ /* @__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: [
545
+ title ? /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-base font-semibold text-primary", children: title }) : null,
546
+ /* @__PURE__ */ jsx(DropdownSheetCloseButton, { onClose })
547
+ ] }),
548
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto pb-[max(2.5rem,calc(env(safe-area-inset-bottom)+2rem))]", children })
549
+ ] });
550
+ }
551
+ var DropdownPopover = ({ mobileOptions, children, className, style, ...props }) => {
552
+ const isMobile = useIsMobile();
553
+ const resolvedMobile = useMemo(() => resolveSelectMobileOptions(mobileOptions), [mobileOptions]);
554
+ const useMobileSheet = isMobile && resolvedMobile.sheet;
555
+ const overlayState = useContext(OverlayTriggerStateContext);
556
+ const open = overlayState?.isOpen ?? false;
557
+ const parentDepth = useContext(DropdownSheetDepthContext);
558
+ const depth = parentDepth + 1;
559
+ const { shouldRender, panelStyle, backdropStyle } = useMobileSheetAnimation(open, useMobileSheet);
560
+ useEffect(() => {
561
+ if (!useMobileSheet || !open) return;
562
+ const prev = document.body.style.overflow;
563
+ document.body.style.overflow = "hidden";
564
+ return () => {
565
+ document.body.style.overflow = prev;
566
+ };
567
+ }, [useMobileSheet, open]);
568
+ if (!useMobileSheet) {
569
+ return /* @__PURE__ */ jsx(
570
+ Popover,
571
+ {
572
+ placement: "bottom right",
573
+ ...props,
574
+ style,
575
+ className: (state) => cx(
576
+ "w-62 origin-(--trigger-anchor-point) overflow-auto rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
577
+ 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",
578
+ 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",
579
+ typeof className === "function" ? className(state) : className
580
+ ),
581
+ children
582
+ }
583
+ );
584
+ }
585
+ const close = () => overlayState?.close();
586
+ const showMobileSheet = shouldRender;
587
+ const isMobileSheetExiting = showMobileSheet && !open;
588
+ const scrimZIndex = 50 + (depth - 1) * 10;
589
+ const sheetZIndex = scrimZIndex + 1;
590
+ const mobileScrim = shouldRender && typeof document !== "undefined" ? createPortal(
591
+ /* @__PURE__ */ jsx(
592
+ "div",
593
+ {
594
+ className: "fixed inset-0 bg-overlay/70",
595
+ style: { ...backdropStyle, zIndex: scrimZIndex },
596
+ onClick: close,
597
+ "aria-hidden": "true"
598
+ }
599
+ ),
600
+ document.body
601
+ ) : null;
602
+ return /* @__PURE__ */ jsxs(DropdownSheetDepthContext.Provider, { value: depth, children: [
603
+ mobileScrim,
604
+ /* @__PURE__ */ jsx(
605
+ Popover,
606
+ {
607
+ placement: "bottom",
608
+ containerPadding: 0,
609
+ offset: 0,
610
+ ...props,
611
+ isExiting: isMobileSheetExiting,
612
+ "data-dropdown-mobile-sheet": true,
613
+ style: { ...panelStyle, zIndex: sheetZIndex, ...style },
614
+ className: (state) => cx(
615
+ "fixed! inset-x-0! bottom-0! top-auto! right-0! left-0! flex max-h-[min(90dvh,calc(100dvh-env(safe-area-inset-bottom,0px)))] 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 outline-hidden",
616
+ resolvedMobile.sheetClassName,
617
+ typeof className === "function" ? className(state) : className
618
+ ),
619
+ children: /* @__PURE__ */ jsx(DropdownSheetChrome, { title: resolvedMobile.title, onClose: close, children: typeof children === "function" ? null : children })
620
+ }
621
+ )
622
+ ] });
458
623
  };
459
624
  var DropdownSeparator = (props) => {
460
625
  return /* @__PURE__ */ jsx(Separator, { ...props, className: cx("my-1 h-px w-full bg-border-secondary", props.className) });