@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, isValidElement, useRef, useLayoutEffect } from 'react';
1
+ import { createContext, useState, useMemo, useContext, useEffect, useCallback, isValidElement, useLayoutEffect, useRef } from 'react';
2
2
  import { ShippingContainerIcon } from '@phosphor-icons/react/dist/csr/ShippingContainer';
3
3
  import { QuestionIcon } from '@phosphor-icons/react/dist/csr/Question';
4
4
  import { StackIcon } from '@phosphor-icons/react/dist/csr/Stack';
@@ -6,13 +6,15 @@ import { SignOutIcon } from '@phosphor-icons/react/dist/csr/SignOut';
6
6
  import { MoonIcon } from '@phosphor-icons/react/dist/csr/Moon';
7
7
  import { GearIcon } from '@phosphor-icons/react/dist/csr/Gear';
8
8
  import { UserIcon } from '@phosphor-icons/react/dist/csr/User';
9
- import { MenuTrigger, Button as Button$1, MenuSection, SubmenuTrigger, Popover, Menu, MenuItem, Separator, Link } from 'react-aria-components';
9
+ import { MenuTrigger, Button as Button$1, MenuSection, SubmenuTrigger, OverlayTriggerStateContext, Popover, Menu, MenuItem, Separator, Link } from 'react-aria-components';
10
10
  import { extendTailwindMerge } from 'tailwind-merge';
11
11
  import '@phosphor-icons/react/dist/csr/Plus';
12
12
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
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 '@phosphor-icons/react/dist/csr/DotsThreeVertical';
17
+ import { XIcon } from '@phosphor-icons/react/dist/csr/X';
16
18
 
17
19
  var twMerge = extendTailwindMerge({
18
20
  extend: {
@@ -439,9 +441,84 @@ var Button = ({
439
441
  }
440
442
  return /* @__PURE__ */ jsx(Button$1, { ...commonProps, type: commonProps.type || "button", isPending: loading });
441
443
  };
444
+ var MOBILE_SHEET_MOTION_MS = 175;
445
+ var MOBILE_SHEET_ENTRY_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
446
+ var MOBILE_SHEET_EXIT_EASING = "cubic-bezier(0.85, 0, 1, 0.15)";
447
+ var MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX = 120;
448
+ function resolveSelectMobileOptions(mobileOptions) {
449
+ return {
450
+ sheet: mobileOptions?.sheet ?? true,
451
+ title: mobileOptions?.title,
452
+ sheetClassName: mobileOptions?.className,
453
+ contentClassName: mobileOptions?.contentClassName
454
+ };
455
+ }
456
+ function useMobileSheetAnimation(open, enabled, slideEntrance = true, slideOffsetPx = MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX) {
457
+ const [shouldRender, setShouldRender] = useState(open);
458
+ const [isAnimating, setIsAnimating] = useState(false);
459
+ useLayoutEffect(() => {
460
+ if (!enabled) {
461
+ setShouldRender(open);
462
+ return;
463
+ }
464
+ if (open) {
465
+ setShouldRender(true);
466
+ }
467
+ }, [open, enabled]);
468
+ useEffect(() => {
469
+ if (!enabled || open) return;
470
+ const timer = setTimeout(() => setShouldRender(false), MOBILE_SHEET_MOTION_MS);
471
+ return () => clearTimeout(timer);
472
+ }, [open, enabled]);
473
+ useLayoutEffect(() => {
474
+ if (!enabled || open || !shouldRender) return;
475
+ setIsAnimating(false);
476
+ }, [enabled, open, shouldRender]);
477
+ useEffect(() => {
478
+ if (!enabled || !shouldRender || !open) return;
479
+ let raf2 = 0;
480
+ const raf1 = requestAnimationFrame(() => {
481
+ raf2 = requestAnimationFrame(() => setIsAnimating(true));
482
+ });
483
+ return () => {
484
+ cancelAnimationFrame(raf1);
485
+ if (raf2) cancelAnimationFrame(raf2);
486
+ };
487
+ }, [shouldRender, open, enabled]);
488
+ const motionEasing = open ? MOBILE_SHEET_ENTRY_EASING : MOBILE_SHEET_EXIT_EASING;
489
+ const hiddenTransform = slideEntrance ? `translateY(${slideOffsetPx}px)` : "translateY(100%)";
490
+ const panelStyle = enabled ? {
491
+ transform: isAnimating ? "translateY(0)" : hiddenTransform,
492
+ opacity: isAnimating ? 1 : 0,
493
+ transitionProperty: "transform, opacity",
494
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
495
+ transitionTimingFunction: motionEasing
496
+ } : void 0;
497
+ const backdropStyle = enabled ? {
498
+ opacity: isAnimating ? 1 : 0,
499
+ transitionProperty: "opacity",
500
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
501
+ transitionTimingFunction: motionEasing
502
+ } : void 0;
503
+ return { shouldRender, isAnimating, panelStyle, backdropStyle };
504
+ }
505
+ var MOBILE_SHEET_MAX_PX = 1024;
506
+ function useIsMobile(breakpoint = MOBILE_SHEET_MAX_PX + 1) {
507
+ const [isMobile, setIsMobile] = useState(() => {
508
+ if (typeof window === "undefined") return false;
509
+ return window.matchMedia(`(max-width: ${breakpoint - 1}px)`).matches;
510
+ });
511
+ useEffect(() => {
512
+ const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
513
+ const handler = (e) => setIsMobile(e.matches);
514
+ mq.addEventListener("change", handler);
515
+ return () => mq.removeEventListener("change", handler);
516
+ }, [breakpoint]);
517
+ return isMobile;
518
+ }
442
519
  var CHECKBOX_TICK_DELAY_MS = 60;
443
520
  var CHECKBOX_TICK_DRAW_MS = 100;
444
- function CheckboxAnimatedCheckMark({ className }) {
521
+ function CheckboxAnimatedCheckMark({ pixelSize, className }) {
445
522
  const pathRef = useRef(null);
446
523
  useLayoutEffect(() => {
447
524
  const path = pathRef.current;
@@ -462,7 +539,7 @@ function CheckboxAnimatedCheckMark({ className }) {
462
539
  });
463
540
  return () => anim.cancel();
464
541
  }, []);
465
- return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", viewBox: "0 0 14 14", fill: "none", className: cx("block shrink-0", className), children: /* @__PURE__ */ jsx(
542
+ 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(
466
543
  "path",
467
544
  {
468
545
  ref: pathRef,
@@ -477,14 +554,15 @@ function CheckboxAnimatedCheckMark({ className }) {
477
554
  var focusRingShadow = "outline-none [box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
478
555
  var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = "sm", isFocusVisible = false }) => {
479
556
  const isChecked = isSelected || isIndeterminate;
480
- const iconClassName = size === "sm" ? "size-2.5" : "size-3.5";
557
+ const iconPixelSize = size === "sm" ? 10 : 14;
481
558
  return /* @__PURE__ */ jsxs(
482
559
  "div",
483
560
  {
484
561
  className: cx(
485
- "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center border border-solid border-primary",
562
+ "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip border border-solid border-primary",
486
563
  size === "sm" ? "size-4 rounded-xs" : "size-5 rounded-sm",
487
564
  isChecked ? "border-transparent bg-brand-solid" : "bg-primary",
565
+ !isChecked && !isDisabled && "group-hover:bg-primary_hover",
488
566
  isDisabled && "cursor-not-allowed opacity-50",
489
567
  isDisabled && !isChecked && "bg-tertiary",
490
568
  isFocusVisible && !isDisabled && focusRingShadow,
@@ -495,13 +573,15 @@ var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size =
495
573
  "svg",
496
574
  {
497
575
  "aria-hidden": "true",
576
+ width: iconPixelSize,
577
+ height: iconPixelSize,
498
578
  viewBox: "0 0 14 14",
499
579
  fill: "none",
500
- className: cx("pointer-events-none block shrink-0 text-fg-white", iconClassName),
580
+ className: "pointer-events-none block text-fg-white",
501
581
  children: /* @__PURE__ */ jsx("path", { d: "M2.91675 7H11.0834", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
502
582
  }
503
583
  ),
504
- isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { className: cx("pointer-events-none text-fg-white", iconClassName) })
584
+ isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: "pointer-events-none text-fg-white" })
505
585
  ]
506
586
  }
507
587
  );
@@ -546,6 +626,7 @@ var RadioButtonBase = ({ className, isFocusVisible, isSelected, isDisabled, size
546
626
  "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip rounded-full border border-solid border-primary bg-primary",
547
627
  size === "sm" ? "size-4" : "size-5",
548
628
  isSelected && "border-transparent bg-brand-solid",
629
+ !isSelected && !isDisabled && "group-hover:bg-primary_hover",
549
630
  isDisabled && "cursor-not-allowed opacity-50",
550
631
  isDisabled && !isSelected && "bg-tertiary",
551
632
  isFocusVisible && !isDisabled && focusRingShadow2,
@@ -587,7 +668,7 @@ var ToggleBase = ({ className, isHovered, isDisabled, isFocusVisible, isSelected
587
668
  const classes = slim ? styles4.slim[size] : styles4.default[size];
588
669
  const offTrackBackground = (() => {
589
670
  if (isDisabled) return "bg-tertiary";
590
- if (isHovered) return slim ? "bg-tertiary" : "bg-brand-primary";
671
+ if (isHovered) return "bg-secondary_hover";
591
672
  return "bg-quaternary";
592
673
  })();
593
674
  return /* @__PURE__ */ jsx(
@@ -702,21 +783,105 @@ var DropdownMenu = (props) => {
702
783
  }
703
784
  );
704
785
  };
705
- var DropdownPopover = (props) => {
706
- return /* @__PURE__ */ jsx(
707
- Popover,
786
+ var DropdownSheetDepthContext = createContext(0);
787
+ function DropdownSheetCloseButton({ onClose }) {
788
+ return /* @__PURE__ */ jsxs(
789
+ "button",
708
790
  {
709
- placement: "bottom right",
710
- ...props,
711
- className: (state) => cx(
712
- "w-62 origin-(--trigger-anchor-point) overflow-auto rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
713
- 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",
714
- 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",
715
- typeof props.className === "function" ? props.className(state) : props.className
716
- ),
717
- children: props.children
791
+ type: "button",
792
+ onClick: (e) => {
793
+ e.stopPropagation();
794
+ onClose();
795
+ },
796
+ 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)]",
797
+ children: [
798
+ /* @__PURE__ */ jsx(XIcon, { className: "size-5", "aria-hidden": "true" }),
799
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
800
+ ]
718
801
  }
719
802
  );
803
+ }
804
+ function DropdownSheetChrome({ title, onClose, children }) {
805
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
806
+ /* @__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: [
807
+ title ? /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-base font-semibold text-primary", children: title }) : null,
808
+ /* @__PURE__ */ jsx(DropdownSheetCloseButton, { onClose })
809
+ ] }),
810
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto pb-[max(2.5rem,calc(env(safe-area-inset-bottom)+2rem))]", children })
811
+ ] });
812
+ }
813
+ var DropdownPopover = ({ mobileOptions, children, className, style, ...props }) => {
814
+ const isMobile = useIsMobile();
815
+ const resolvedMobile = useMemo(() => resolveSelectMobileOptions(mobileOptions), [mobileOptions]);
816
+ const useMobileSheet = isMobile && resolvedMobile.sheet;
817
+ const overlayState = useContext(OverlayTriggerStateContext);
818
+ const open = overlayState?.isOpen ?? false;
819
+ const parentDepth = useContext(DropdownSheetDepthContext);
820
+ const depth = parentDepth + 1;
821
+ const { shouldRender, panelStyle, backdropStyle } = useMobileSheetAnimation(open, useMobileSheet);
822
+ useEffect(() => {
823
+ if (!useMobileSheet || !open) return;
824
+ const prev = document.body.style.overflow;
825
+ document.body.style.overflow = "hidden";
826
+ return () => {
827
+ document.body.style.overflow = prev;
828
+ };
829
+ }, [useMobileSheet, open]);
830
+ if (!useMobileSheet) {
831
+ return /* @__PURE__ */ jsx(
832
+ Popover,
833
+ {
834
+ placement: "bottom right",
835
+ ...props,
836
+ style,
837
+ className: (state) => cx(
838
+ "w-62 origin-(--trigger-anchor-point) overflow-auto rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
839
+ 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",
840
+ 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",
841
+ typeof className === "function" ? className(state) : className
842
+ ),
843
+ children
844
+ }
845
+ );
846
+ }
847
+ const close = () => overlayState?.close();
848
+ const showMobileSheet = shouldRender;
849
+ const isMobileSheetExiting = showMobileSheet && !open;
850
+ const scrimZIndex = 50 + (depth - 1) * 10;
851
+ const sheetZIndex = scrimZIndex + 1;
852
+ const mobileScrim = shouldRender && typeof document !== "undefined" ? createPortal(
853
+ /* @__PURE__ */ jsx(
854
+ "div",
855
+ {
856
+ className: "fixed inset-0 bg-overlay/70",
857
+ style: { ...backdropStyle, zIndex: scrimZIndex },
858
+ onClick: close,
859
+ "aria-hidden": "true"
860
+ }
861
+ ),
862
+ document.body
863
+ ) : null;
864
+ return /* @__PURE__ */ jsxs(DropdownSheetDepthContext.Provider, { value: depth, children: [
865
+ mobileScrim,
866
+ /* @__PURE__ */ jsx(
867
+ Popover,
868
+ {
869
+ placement: "bottom",
870
+ containerPadding: 0,
871
+ offset: 0,
872
+ ...props,
873
+ isExiting: isMobileSheetExiting,
874
+ "data-dropdown-mobile-sheet": true,
875
+ style: { ...panelStyle, zIndex: sheetZIndex, ...style },
876
+ className: (state) => cx(
877
+ "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",
878
+ resolvedMobile.sheetClassName,
879
+ typeof className === "function" ? className(state) : className
880
+ ),
881
+ children: /* @__PURE__ */ jsx(DropdownSheetChrome, { title: resolvedMobile.title, onClose: close, children: typeof children === "function" ? null : children })
882
+ }
883
+ )
884
+ ] });
720
885
  };
721
886
  var DropdownSeparator = (props) => {
722
887
  return /* @__PURE__ */ jsx(Separator, { ...props, className: cx("my-1 h-px w-full bg-border-secondary", props.className) });