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