@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,13 +1,15 @@
1
- import { createContext, useState, isValidElement, useContext, useCallback, useRef, useLayoutEffect } from 'react';
1
+ import { createContext, useState, isValidElement, useMemo, useContext, useEffect, useCallback, useLayoutEffect, useRef } from 'react';
2
2
  import { CaretDownIcon } from '@phosphor-icons/react/dist/csr/CaretDown';
3
3
  import { PlusIcon } from '@phosphor-icons/react/dist/csr/Plus';
4
4
  import { MagnifyingGlassIcon } from '@phosphor-icons/react/dist/csr/MagnifyingGlass';
5
- import { useFilter, MenuTrigger, Autocomplete, SearchField, SubmenuTrigger, Link, Button as Button$1, Popover, Group, Input, Menu, MenuItem, TooltipTrigger as TooltipTrigger$1, Tooltip as Tooltip$1, OverlayArrow } from 'react-aria-components';
5
+ import { useFilter, MenuTrigger, Autocomplete, SearchField, SubmenuTrigger, Link, Button as Button$1, OverlayTriggerStateContext, Popover, Group, Input, Menu, MenuItem, TooltipTrigger as TooltipTrigger$1, Tooltip as Tooltip$1, OverlayArrow } from 'react-aria-components';
6
6
  import { extendTailwindMerge } from 'tailwind-merge';
7
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
+ import { createPortal } from 'react-dom';
8
9
  import { CheckIcon } from '@phosphor-icons/react/dist/csr/Check';
9
10
  import { CaretRightIcon } from '@phosphor-icons/react/dist/csr/CaretRight';
10
11
  import '@phosphor-icons/react/dist/csr/DotsThreeVertical';
12
+ import { XIcon } from '@phosphor-icons/react/dist/csr/X';
11
13
  import { UserIcon } from '@phosphor-icons/react/dist/csr/User';
12
14
  import { EyeIcon } from '@phosphor-icons/react/dist/csr/Eye';
13
15
  import { EyeSlashIcon } from '@phosphor-icons/react/dist/csr/EyeSlash';
@@ -289,6 +291,81 @@ var Button = ({
289
291
  }
290
292
  return /* @__PURE__ */ jsx(Button$1, { ...commonProps, type: commonProps.type || "button", isPending: loading });
291
293
  };
294
+ var MOBILE_SHEET_MOTION_MS = 175;
295
+ var MOBILE_SHEET_ENTRY_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
296
+ var MOBILE_SHEET_EXIT_EASING = "cubic-bezier(0.85, 0, 1, 0.15)";
297
+ var MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX = 120;
298
+ function resolveSelectMobileOptions(mobileOptions) {
299
+ return {
300
+ sheet: mobileOptions?.sheet ?? true,
301
+ title: mobileOptions?.title,
302
+ sheetClassName: mobileOptions?.className,
303
+ contentClassName: mobileOptions?.contentClassName
304
+ };
305
+ }
306
+ function useMobileSheetAnimation(open, enabled, slideEntrance = true, slideOffsetPx = MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX) {
307
+ const [shouldRender, setShouldRender] = useState(open);
308
+ const [isAnimating, setIsAnimating] = useState(false);
309
+ useLayoutEffect(() => {
310
+ if (!enabled) {
311
+ setShouldRender(open);
312
+ return;
313
+ }
314
+ if (open) {
315
+ setShouldRender(true);
316
+ }
317
+ }, [open, enabled]);
318
+ useEffect(() => {
319
+ if (!enabled || open) return;
320
+ const timer = setTimeout(() => setShouldRender(false), MOBILE_SHEET_MOTION_MS);
321
+ return () => clearTimeout(timer);
322
+ }, [open, enabled]);
323
+ useLayoutEffect(() => {
324
+ if (!enabled || open || !shouldRender) return;
325
+ setIsAnimating(false);
326
+ }, [enabled, open, shouldRender]);
327
+ useEffect(() => {
328
+ if (!enabled || !shouldRender || !open) return;
329
+ let raf2 = 0;
330
+ const raf1 = requestAnimationFrame(() => {
331
+ raf2 = requestAnimationFrame(() => setIsAnimating(true));
332
+ });
333
+ return () => {
334
+ cancelAnimationFrame(raf1);
335
+ if (raf2) cancelAnimationFrame(raf2);
336
+ };
337
+ }, [shouldRender, open, enabled]);
338
+ const motionEasing = open ? MOBILE_SHEET_ENTRY_EASING : MOBILE_SHEET_EXIT_EASING;
339
+ const hiddenTransform = slideEntrance ? `translateY(${slideOffsetPx}px)` : "translateY(100%)";
340
+ const panelStyle = enabled ? {
341
+ transform: isAnimating ? "translateY(0)" : hiddenTransform,
342
+ opacity: isAnimating ? 1 : 0,
343
+ transitionProperty: "transform, opacity",
344
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
345
+ transitionTimingFunction: motionEasing
346
+ } : void 0;
347
+ const backdropStyle = enabled ? {
348
+ opacity: isAnimating ? 1 : 0,
349
+ transitionProperty: "opacity",
350
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
351
+ transitionTimingFunction: motionEasing
352
+ } : void 0;
353
+ return { shouldRender, isAnimating, panelStyle, backdropStyle };
354
+ }
355
+ var MOBILE_SHEET_MAX_PX = 1024;
356
+ function useIsMobile(breakpoint = MOBILE_SHEET_MAX_PX + 1) {
357
+ const [isMobile, setIsMobile] = useState(() => {
358
+ if (typeof window === "undefined") return false;
359
+ return window.matchMedia(`(max-width: ${breakpoint - 1}px)`).matches;
360
+ });
361
+ useEffect(() => {
362
+ const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
363
+ const handler = (e) => setIsMobile(e.matches);
364
+ mq.addEventListener("change", handler);
365
+ return () => mq.removeEventListener("change", handler);
366
+ }, [breakpoint]);
367
+ return isMobile;
368
+ }
292
369
  var Tooltip = ({
293
370
  title,
294
371
  description,
@@ -501,7 +578,7 @@ var Avatar = ({
501
578
  };
502
579
  var CHECKBOX_TICK_DELAY_MS = 60;
503
580
  var CHECKBOX_TICK_DRAW_MS = 100;
504
- function CheckboxAnimatedCheckMark({ className }) {
581
+ function CheckboxAnimatedCheckMark({ pixelSize, className }) {
505
582
  const pathRef = useRef(null);
506
583
  useLayoutEffect(() => {
507
584
  const path = pathRef.current;
@@ -522,7 +599,7 @@ function CheckboxAnimatedCheckMark({ className }) {
522
599
  });
523
600
  return () => anim.cancel();
524
601
  }, []);
525
- return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", viewBox: "0 0 14 14", fill: "none", className: cx("block shrink-0", className), children: /* @__PURE__ */ jsx(
602
+ 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(
526
603
  "path",
527
604
  {
528
605
  ref: pathRef,
@@ -537,14 +614,15 @@ function CheckboxAnimatedCheckMark({ className }) {
537
614
  var focusRingShadow = "outline-none [box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
538
615
  var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = "sm", isFocusVisible = false }) => {
539
616
  const isChecked = isSelected || isIndeterminate;
540
- const iconClassName = size === "sm" ? "size-2.5" : "size-3.5";
617
+ const iconPixelSize = size === "sm" ? 10 : 14;
541
618
  return /* @__PURE__ */ jsxs(
542
619
  "div",
543
620
  {
544
621
  className: cx(
545
- "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center border border-solid border-primary",
622
+ "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip border border-solid border-primary",
546
623
  size === "sm" ? "size-4 rounded-xs" : "size-5 rounded-sm",
547
624
  isChecked ? "border-transparent bg-brand-solid" : "bg-primary",
625
+ !isChecked && !isDisabled && "group-hover:bg-primary_hover",
548
626
  isDisabled && "cursor-not-allowed opacity-50",
549
627
  isDisabled && !isChecked && "bg-tertiary",
550
628
  isFocusVisible && !isDisabled && focusRingShadow,
@@ -555,13 +633,15 @@ var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size =
555
633
  "svg",
556
634
  {
557
635
  "aria-hidden": "true",
636
+ width: iconPixelSize,
637
+ height: iconPixelSize,
558
638
  viewBox: "0 0 14 14",
559
639
  fill: "none",
560
- className: cx("pointer-events-none block shrink-0 text-fg-white", iconClassName),
640
+ className: "pointer-events-none block text-fg-white",
561
641
  children: /* @__PURE__ */ jsx("path", { d: "M2.91675 7H11.0834", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
562
642
  }
563
643
  ),
564
- isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { className: cx("pointer-events-none text-fg-white", iconClassName) })
644
+ isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: "pointer-events-none text-fg-white" })
565
645
  ]
566
646
  }
567
647
  );
@@ -606,6 +686,7 @@ var RadioButtonBase = ({ className, isFocusVisible, isSelected, isDisabled, size
606
686
  "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip rounded-full border border-solid border-primary bg-primary",
607
687
  size === "sm" ? "size-4" : "size-5",
608
688
  isSelected && "border-transparent bg-brand-solid",
689
+ !isSelected && !isDisabled && "group-hover:bg-primary_hover",
609
690
  isDisabled && "cursor-not-allowed opacity-50",
610
691
  isDisabled && !isSelected && "bg-tertiary",
611
692
  isFocusVisible && !isDisabled && focusRingShadow2,
@@ -647,7 +728,7 @@ var ToggleBase = ({ className, isHovered, isDisabled, isFocusVisible, isSelected
647
728
  const classes = slim ? styles3.slim[size] : styles3.default[size];
648
729
  const offTrackBackground = (() => {
649
730
  if (isDisabled) return "bg-tertiary";
650
- if (isHovered) return slim ? "bg-tertiary" : "bg-brand-primary";
731
+ if (isHovered) return "bg-secondary_hover";
651
732
  return "bg-quaternary";
652
733
  })();
653
734
  return /* @__PURE__ */ jsx(
@@ -762,21 +843,105 @@ var DropdownMenu = (props) => {
762
843
  }
763
844
  );
764
845
  };
765
- var DropdownPopover = (props) => {
766
- return /* @__PURE__ */ jsx(
767
- Popover,
846
+ var DropdownSheetDepthContext = createContext(0);
847
+ function DropdownSheetCloseButton({ onClose }) {
848
+ return /* @__PURE__ */ jsxs(
849
+ "button",
768
850
  {
769
- placement: "bottom right",
770
- ...props,
771
- className: (state) => cx(
772
- "w-62 origin-(--trigger-anchor-point) overflow-auto rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
773
- 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",
774
- 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",
775
- typeof props.className === "function" ? props.className(state) : props.className
776
- ),
777
- children: props.children
851
+ type: "button",
852
+ onClick: (e) => {
853
+ e.stopPropagation();
854
+ onClose();
855
+ },
856
+ 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)]",
857
+ children: [
858
+ /* @__PURE__ */ jsx(XIcon, { className: "size-5", "aria-hidden": "true" }),
859
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
860
+ ]
778
861
  }
779
862
  );
863
+ }
864
+ function DropdownSheetChrome({ title, onClose, children }) {
865
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
866
+ /* @__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: [
867
+ title ? /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-base font-semibold text-primary", children: title }) : null,
868
+ /* @__PURE__ */ jsx(DropdownSheetCloseButton, { onClose })
869
+ ] }),
870
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto pb-[max(2.5rem,calc(env(safe-area-inset-bottom)+2rem))]", children })
871
+ ] });
872
+ }
873
+ var DropdownPopover = ({ mobileOptions, children, className, style, ...props }) => {
874
+ const isMobile = useIsMobile();
875
+ const resolvedMobile = useMemo(() => resolveSelectMobileOptions(mobileOptions), [mobileOptions]);
876
+ const useMobileSheet = isMobile && resolvedMobile.sheet;
877
+ const overlayState = useContext(OverlayTriggerStateContext);
878
+ const open = overlayState?.isOpen ?? false;
879
+ const parentDepth = useContext(DropdownSheetDepthContext);
880
+ const depth = parentDepth + 1;
881
+ const { shouldRender, panelStyle, backdropStyle } = useMobileSheetAnimation(open, useMobileSheet);
882
+ useEffect(() => {
883
+ if (!useMobileSheet || !open) return;
884
+ const prev = document.body.style.overflow;
885
+ document.body.style.overflow = "hidden";
886
+ return () => {
887
+ document.body.style.overflow = prev;
888
+ };
889
+ }, [useMobileSheet, open]);
890
+ if (!useMobileSheet) {
891
+ return /* @__PURE__ */ jsx(
892
+ Popover,
893
+ {
894
+ placement: "bottom right",
895
+ ...props,
896
+ style,
897
+ className: (state) => cx(
898
+ "w-62 origin-(--trigger-anchor-point) overflow-auto rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
899
+ 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",
900
+ 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",
901
+ typeof className === "function" ? className(state) : className
902
+ ),
903
+ children
904
+ }
905
+ );
906
+ }
907
+ const close = () => overlayState?.close();
908
+ const showMobileSheet = shouldRender;
909
+ const isMobileSheetExiting = showMobileSheet && !open;
910
+ const scrimZIndex = 50 + (depth - 1) * 10;
911
+ const sheetZIndex = scrimZIndex + 1;
912
+ const mobileScrim = shouldRender && typeof document !== "undefined" ? createPortal(
913
+ /* @__PURE__ */ jsx(
914
+ "div",
915
+ {
916
+ className: "fixed inset-0 bg-overlay/70",
917
+ style: { ...backdropStyle, zIndex: scrimZIndex },
918
+ onClick: close,
919
+ "aria-hidden": "true"
920
+ }
921
+ ),
922
+ document.body
923
+ ) : null;
924
+ return /* @__PURE__ */ jsxs(DropdownSheetDepthContext.Provider, { value: depth, children: [
925
+ mobileScrim,
926
+ /* @__PURE__ */ jsx(
927
+ Popover,
928
+ {
929
+ placement: "bottom",
930
+ containerPadding: 0,
931
+ offset: 0,
932
+ ...props,
933
+ isExiting: isMobileSheetExiting,
934
+ "data-dropdown-mobile-sheet": true,
935
+ style: { ...panelStyle, zIndex: sheetZIndex, ...style },
936
+ className: (state) => cx(
937
+ "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",
938
+ resolvedMobile.sheetClassName,
939
+ typeof className === "function" ? className(state) : className
940
+ ),
941
+ children: /* @__PURE__ */ jsx(DropdownSheetChrome, { title: resolvedMobile.title, onClose: close, children: typeof children === "function" ? null : children })
942
+ }
943
+ )
944
+ ] });
780
945
  };
781
946
  var Dropdown = {
782
947
  Root: MenuTrigger,