@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,11 +1,13 @@
1
1
  import { CaretDownIcon } from '@phosphor-icons/react/dist/csr/CaretDown';
2
- import { MenuTrigger, MenuSection, SubmenuTrigger, Link, Button as Button$1, Popover, Menu, MenuItem, Separator } from 'react-aria-components';
3
- import { createContext, isValidElement, useCallback, useState, useRef, useLayoutEffect } from 'react';
2
+ import { MenuTrigger, MenuSection, SubmenuTrigger, Link, Button as Button$1, OverlayTriggerStateContext, Popover, Menu, MenuItem, Separator } from 'react-aria-components';
3
+ import { createContext, isValidElement, useMemo, useContext, useEffect, useCallback, useState, useLayoutEffect, useRef } from 'react';
4
4
  import { extendTailwindMerge } from 'tailwind-merge';
5
5
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
+ import { createPortal } from 'react-dom';
6
7
  import { CheckIcon } from '@phosphor-icons/react/dist/csr/Check';
7
8
  import { CaretRightIcon } from '@phosphor-icons/react/dist/csr/CaretRight';
8
9
  import '@phosphor-icons/react/dist/csr/DotsThreeVertical';
10
+ import { XIcon } from '@phosphor-icons/react/dist/csr/X';
9
11
  import { UserIcon } from '@phosphor-icons/react/dist/csr/User';
10
12
  import '@phosphor-icons/react/dist/csr/Plus';
11
13
 
@@ -284,6 +286,81 @@ var Button = ({
284
286
  }
285
287
  return /* @__PURE__ */ jsx(Button$1, { ...commonProps, type: commonProps.type || "button", isPending: loading });
286
288
  };
289
+ var MOBILE_SHEET_MOTION_MS = 175;
290
+ var MOBILE_SHEET_ENTRY_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
291
+ var MOBILE_SHEET_EXIT_EASING = "cubic-bezier(0.85, 0, 1, 0.15)";
292
+ var MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX = 120;
293
+ function resolveSelectMobileOptions(mobileOptions) {
294
+ return {
295
+ sheet: mobileOptions?.sheet ?? true,
296
+ title: mobileOptions?.title,
297
+ sheetClassName: mobileOptions?.className,
298
+ contentClassName: mobileOptions?.contentClassName
299
+ };
300
+ }
301
+ function useMobileSheetAnimation(open, enabled, slideEntrance = true, slideOffsetPx = MOBILE_SHEET_SLIDE_ENTRANCE_OFFSET_PX) {
302
+ const [shouldRender, setShouldRender] = useState(open);
303
+ const [isAnimating, setIsAnimating] = useState(false);
304
+ useLayoutEffect(() => {
305
+ if (!enabled) {
306
+ setShouldRender(open);
307
+ return;
308
+ }
309
+ if (open) {
310
+ setShouldRender(true);
311
+ }
312
+ }, [open, enabled]);
313
+ useEffect(() => {
314
+ if (!enabled || open) return;
315
+ const timer = setTimeout(() => setShouldRender(false), MOBILE_SHEET_MOTION_MS);
316
+ return () => clearTimeout(timer);
317
+ }, [open, enabled]);
318
+ useLayoutEffect(() => {
319
+ if (!enabled || open || !shouldRender) return;
320
+ setIsAnimating(false);
321
+ }, [enabled, open, shouldRender]);
322
+ useEffect(() => {
323
+ if (!enabled || !shouldRender || !open) return;
324
+ let raf2 = 0;
325
+ const raf1 = requestAnimationFrame(() => {
326
+ raf2 = requestAnimationFrame(() => setIsAnimating(true));
327
+ });
328
+ return () => {
329
+ cancelAnimationFrame(raf1);
330
+ if (raf2) cancelAnimationFrame(raf2);
331
+ };
332
+ }, [shouldRender, open, enabled]);
333
+ const motionEasing = open ? MOBILE_SHEET_ENTRY_EASING : MOBILE_SHEET_EXIT_EASING;
334
+ const hiddenTransform = slideEntrance ? `translateY(${slideOffsetPx}px)` : "translateY(100%)";
335
+ const panelStyle = enabled ? {
336
+ transform: isAnimating ? "translateY(0)" : hiddenTransform,
337
+ opacity: isAnimating ? 1 : 0,
338
+ transitionProperty: "transform, opacity",
339
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
340
+ transitionTimingFunction: motionEasing
341
+ } : void 0;
342
+ const backdropStyle = enabled ? {
343
+ opacity: isAnimating ? 1 : 0,
344
+ transitionProperty: "opacity",
345
+ transitionDuration: `${MOBILE_SHEET_MOTION_MS}ms`,
346
+ transitionTimingFunction: motionEasing
347
+ } : void 0;
348
+ return { shouldRender, isAnimating, panelStyle, backdropStyle };
349
+ }
350
+ var MOBILE_SHEET_MAX_PX = 1024;
351
+ function useIsMobile(breakpoint = MOBILE_SHEET_MAX_PX + 1) {
352
+ const [isMobile, setIsMobile] = useState(() => {
353
+ if (typeof window === "undefined") return false;
354
+ return window.matchMedia(`(max-width: ${breakpoint - 1}px)`).matches;
355
+ });
356
+ useEffect(() => {
357
+ const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
358
+ const handler = (e) => setIsMobile(e.matches);
359
+ mq.addEventListener("change", handler);
360
+ return () => mq.removeEventListener("change", handler);
361
+ }, [breakpoint]);
362
+ return isMobile;
363
+ }
287
364
  var sizes = {
288
365
  xs: "size-1.5",
289
366
  sm: "size-2",
@@ -436,7 +513,7 @@ var Avatar = ({
436
513
  };
437
514
  var CHECKBOX_TICK_DELAY_MS = 60;
438
515
  var CHECKBOX_TICK_DRAW_MS = 100;
439
- function CheckboxAnimatedCheckMark({ className }) {
516
+ function CheckboxAnimatedCheckMark({ pixelSize, className }) {
440
517
  const pathRef = useRef(null);
441
518
  useLayoutEffect(() => {
442
519
  const path = pathRef.current;
@@ -457,7 +534,7 @@ function CheckboxAnimatedCheckMark({ className }) {
457
534
  });
458
535
  return () => anim.cancel();
459
536
  }, []);
460
- return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", viewBox: "0 0 14 14", fill: "none", className: cx("block shrink-0", className), children: /* @__PURE__ */ jsx(
537
+ 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(
461
538
  "path",
462
539
  {
463
540
  ref: pathRef,
@@ -472,14 +549,15 @@ function CheckboxAnimatedCheckMark({ className }) {
472
549
  var focusRingShadow = "outline-none [box-shadow:0px_0px_0px_2px_var(--color-bg-primary),0px_0px_0px_4px_var(--color-focus-ring)]";
473
550
  var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = "sm", isFocusVisible = false }) => {
474
551
  const isChecked = isSelected || isIndeterminate;
475
- const iconClassName = size === "sm" ? "size-2.5" : "size-3.5";
552
+ const iconPixelSize = size === "sm" ? 10 : 14;
476
553
  return /* @__PURE__ */ jsxs(
477
554
  "div",
478
555
  {
479
556
  className: cx(
480
- "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center border border-solid border-primary",
557
+ "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip border border-solid border-primary",
481
558
  size === "sm" ? "size-4 rounded-xs" : "size-5 rounded-sm",
482
559
  isChecked ? "border-transparent bg-brand-solid" : "bg-primary",
560
+ !isChecked && !isDisabled && "group-hover:bg-primary_hover",
483
561
  isDisabled && "cursor-not-allowed opacity-50",
484
562
  isDisabled && !isChecked && "bg-tertiary",
485
563
  isFocusVisible && !isDisabled && focusRingShadow,
@@ -490,13 +568,15 @@ var CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size =
490
568
  "svg",
491
569
  {
492
570
  "aria-hidden": "true",
571
+ width: iconPixelSize,
572
+ height: iconPixelSize,
493
573
  viewBox: "0 0 14 14",
494
574
  fill: "none",
495
- className: cx("pointer-events-none block shrink-0 text-fg-white", iconClassName),
575
+ className: "pointer-events-none block text-fg-white",
496
576
  children: /* @__PURE__ */ jsx("path", { d: "M2.91675 7H11.0834", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
497
577
  }
498
578
  ),
499
- isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { className: cx("pointer-events-none text-fg-white", iconClassName) })
579
+ isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: "pointer-events-none text-fg-white" })
500
580
  ]
501
581
  }
502
582
  );
@@ -541,6 +621,7 @@ var RadioButtonBase = ({ className, isFocusVisible, isSelected, isDisabled, size
541
621
  "relative flex shrink-0 cursor-pointer appearance-none items-center justify-center overflow-clip rounded-full border border-solid border-primary bg-primary",
542
622
  size === "sm" ? "size-4" : "size-5",
543
623
  isSelected && "border-transparent bg-brand-solid",
624
+ !isSelected && !isDisabled && "group-hover:bg-primary_hover",
544
625
  isDisabled && "cursor-not-allowed opacity-50",
545
626
  isDisabled && !isSelected && "bg-tertiary",
546
627
  isFocusVisible && !isDisabled && focusRingShadow2,
@@ -582,7 +663,7 @@ var ToggleBase = ({ className, isHovered, isDisabled, isFocusVisible, isSelected
582
663
  const classes = slim ? styles3.slim[size] : styles3.default[size];
583
664
  const offTrackBackground = (() => {
584
665
  if (isDisabled) return "bg-tertiary";
585
- if (isHovered) return slim ? "bg-tertiary" : "bg-brand-primary";
666
+ if (isHovered) return "bg-secondary_hover";
586
667
  return "bg-quaternary";
587
668
  })();
588
669
  return /* @__PURE__ */ jsx(
@@ -697,21 +778,105 @@ var DropdownMenu = (props) => {
697
778
  }
698
779
  );
699
780
  };
700
- var DropdownPopover = (props) => {
701
- return /* @__PURE__ */ jsx(
702
- Popover,
781
+ var DropdownSheetDepthContext = createContext(0);
782
+ function DropdownSheetCloseButton({ onClose }) {
783
+ return /* @__PURE__ */ jsxs(
784
+ "button",
703
785
  {
704
- placement: "bottom right",
705
- ...props,
706
- className: (state) => cx(
707
- "w-62 origin-(--trigger-anchor-point) overflow-auto rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
708
- 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",
709
- 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",
710
- typeof props.className === "function" ? props.className(state) : props.className
711
- ),
712
- children: props.children
786
+ type: "button",
787
+ onClick: (e) => {
788
+ e.stopPropagation();
789
+ onClose();
790
+ },
791
+ 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)]",
792
+ children: [
793
+ /* @__PURE__ */ jsx(XIcon, { className: "size-5", "aria-hidden": "true" }),
794
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
795
+ ]
713
796
  }
714
797
  );
798
+ }
799
+ function DropdownSheetChrome({ title, onClose, children }) {
800
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
801
+ /* @__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: [
802
+ title ? /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-base font-semibold text-primary", children: title }) : null,
803
+ /* @__PURE__ */ jsx(DropdownSheetCloseButton, { onClose })
804
+ ] }),
805
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto pb-[max(2.5rem,calc(env(safe-area-inset-bottom)+2rem))]", children })
806
+ ] });
807
+ }
808
+ var DropdownPopover = ({ mobileOptions, children, className, style, ...props }) => {
809
+ const isMobile = useIsMobile();
810
+ const resolvedMobile = useMemo(() => resolveSelectMobileOptions(mobileOptions), [mobileOptions]);
811
+ const useMobileSheet = isMobile && resolvedMobile.sheet;
812
+ const overlayState = useContext(OverlayTriggerStateContext);
813
+ const open = overlayState?.isOpen ?? false;
814
+ const parentDepth = useContext(DropdownSheetDepthContext);
815
+ const depth = parentDepth + 1;
816
+ const { shouldRender, panelStyle, backdropStyle } = useMobileSheetAnimation(open, useMobileSheet);
817
+ useEffect(() => {
818
+ if (!useMobileSheet || !open) return;
819
+ const prev = document.body.style.overflow;
820
+ document.body.style.overflow = "hidden";
821
+ return () => {
822
+ document.body.style.overflow = prev;
823
+ };
824
+ }, [useMobileSheet, open]);
825
+ if (!useMobileSheet) {
826
+ return /* @__PURE__ */ jsx(
827
+ Popover,
828
+ {
829
+ placement: "bottom right",
830
+ ...props,
831
+ style,
832
+ className: (state) => cx(
833
+ "w-62 origin-(--trigger-anchor-point) overflow-auto rounded-lg bg-primary shadow-lg ring-1 ring-secondary_alt will-change-transform",
834
+ 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",
835
+ 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",
836
+ typeof className === "function" ? className(state) : className
837
+ ),
838
+ children
839
+ }
840
+ );
841
+ }
842
+ const close = () => overlayState?.close();
843
+ const showMobileSheet = shouldRender;
844
+ const isMobileSheetExiting = showMobileSheet && !open;
845
+ const scrimZIndex = 50 + (depth - 1) * 10;
846
+ const sheetZIndex = scrimZIndex + 1;
847
+ const mobileScrim = shouldRender && typeof document !== "undefined" ? createPortal(
848
+ /* @__PURE__ */ jsx(
849
+ "div",
850
+ {
851
+ className: "fixed inset-0 bg-overlay/70",
852
+ style: { ...backdropStyle, zIndex: scrimZIndex },
853
+ onClick: close,
854
+ "aria-hidden": "true"
855
+ }
856
+ ),
857
+ document.body
858
+ ) : null;
859
+ return /* @__PURE__ */ jsxs(DropdownSheetDepthContext.Provider, { value: depth, children: [
860
+ mobileScrim,
861
+ /* @__PURE__ */ jsx(
862
+ Popover,
863
+ {
864
+ placement: "bottom",
865
+ containerPadding: 0,
866
+ offset: 0,
867
+ ...props,
868
+ isExiting: isMobileSheetExiting,
869
+ "data-dropdown-mobile-sheet": true,
870
+ style: { ...panelStyle, zIndex: sheetZIndex, ...style },
871
+ className: (state) => cx(
872
+ "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",
873
+ resolvedMobile.sheetClassName,
874
+ typeof className === "function" ? className(state) : className
875
+ ),
876
+ children: /* @__PURE__ */ jsx(DropdownSheetChrome, { title: resolvedMobile.title, onClose: close, children: typeof children === "function" ? null : children })
877
+ }
878
+ )
879
+ ] });
715
880
  };
716
881
  var DropdownSeparator = (props) => {
717
882
  return /* @__PURE__ */ jsx(Separator, { ...props, className: cx("my-1 h-px w-full bg-border-secondary", props.className) });