@betterinternship/components 3.4.1 → 3.5.0
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.
- package/README.md +50 -38
- package/dist/brand-logos.d.ts +4 -0
- package/dist/brand-logos.js +13 -0
- package/dist/brand-logos.js.map +1 -0
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/animated-count.js.map +1 -1
- package/dist/components/animated-shiny-text.js.map +1 -1
- package/dist/components/app-header.js.map +1 -1
- package/dist/components/autocomplete.d.ts +1 -2
- package/dist/components/autocomplete.js +75 -64
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/banner.js.map +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/card.js.map +1 -1
- package/dist/components/carousel.js.map +1 -1
- package/dist/components/checkbox-field.d.ts +18 -0
- package/dist/components/checkbox-field.js +25 -0
- package/dist/components/checkbox-field.js.map +1 -0
- package/dist/components/checkbox-group.d.ts +33 -0
- package/dist/components/checkbox-group.js +43 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +6 -2
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/chip-select.d.ts +11 -2
- package/dist/components/chip-select.js +9 -4
- package/dist/components/chip-select.js.map +1 -1
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/context-menu.js.map +1 -1
- package/dist/components/{form-date-picker.d.ts → date-picker.d.ts} +11 -8
- package/dist/components/date-picker.js +57 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/divider.js.map +1 -1
- package/dist/components/dot-matrix.js.map +1 -1
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/dropdown.js +7 -2
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/error.js.map +1 -1
- package/dist/components/fab.js.map +1 -1
- package/dist/components/file-upload.js.map +1 -1
- package/dist/components/filter-chip.js.map +1 -1
- package/dist/components/form-field.d.ts +60 -5
- package/dist/components/form-field.js +55 -5
- package/dist/components/form-field.js.map +1 -1
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.js +3 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/loader.js.map +1 -1
- package/dist/components/magnetic-button.js.map +1 -1
- package/dist/components/messages.js.map +1 -1
- package/dist/components/mobile-sheet-portal.js.map +1 -1
- package/dist/components/{form-month-picker.d.ts → month-picker.d.ts} +6 -6
- package/dist/components/month-picker.js +57 -0
- package/dist/components/month-picker.js.map +1 -0
- package/dist/components/option-list.js.map +1 -1
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/paginator.js.map +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress.js.map +1 -1
- package/dist/components/radio-group.d.ts +11 -1
- package/dist/components/radio-group.js +17 -4
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/select.js +38 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.d.ts +1 -1
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/sonner-toast.js +133 -133
- package/dist/components/sonner-toast.js.map +1 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/switch.js +4 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.js +5 -5
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/textarea.js +3 -1
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/time-input.d.ts +9 -0
- package/dist/components/time-input.js +65 -0
- package/dist/components/time-input.js.map +1 -0
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/hooks/use-detect-click-outside.js.map +1 -1
- package/dist/hooks/use-field-focus.d.ts +1 -1
- package/dist/hooks/use-field-focus.js +1 -1
- package/dist/hooks/use-field-focus.js.map +1 -1
- package/dist/hooks/use-mobile-sheet-viewport.js.map +1 -1
- package/dist/hooks/use-mobile.js.map +1 -1
- package/dist/hooks/use-resource-table.js.map +1 -1
- package/dist/hooks/useMQJob.js.map +1 -1
- package/dist/index.d.ts +9 -12
- package/dist/index.js +8 -11
- package/dist/index.js.map +1 -1
- package/dist/lib/interaction-styles.js.map +1 -1
- package/dist/logos/base/betterinternship.svg.js +4 -0
- package/dist/logos/base/betterinternship.svg.js.map +1 -0
- package/dist/logos/black_fill/betterinternship_black.svg.js +4 -0
- package/dist/logos/black_fill/betterinternship_black.svg.js.map +1 -0
- package/dist/logos/circle/betterinternship_circle.svg.js +4 -0
- package/dist/logos/circle/betterinternship_circle.svg.js.map +1 -0
- package/dist/logos/white_fill/betterinternship_white.svg.js +4 -0
- package/dist/logos/white_fill/betterinternship_white.svg.js.map +1 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +54 -2
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
- package/dist/utils.js +11 -1
- package/dist/utils.js.map +1 -1
- package/package.json +317 -330
- package/theme.css +414 -414
- package/theme.legacy.css +84 -84
- package/dist/components/form-checkbox-group.d.ts +0 -31
- package/dist/components/form-checkbox-group.js +0 -30
- package/dist/components/form-checkbox-group.js.map +0 -1
- package/dist/components/form-checkbox.d.ts +0 -15
- package/dist/components/form-checkbox.js +0 -15
- package/dist/components/form-checkbox.js.map +0 -1
- package/dist/components/form-date-picker.js +0 -56
- package/dist/components/form-date-picker.js.map +0 -1
- package/dist/components/form-input.d.ts +0 -11
- package/dist/components/form-input.js +0 -13
- package/dist/components/form-input.js.map +0 -1
- package/dist/components/form-month-picker.js +0 -56
- package/dist/components/form-month-picker.js.map +0 -1
- package/dist/components/form-radio.d.ts +0 -15
- package/dist/components/form-radio.js +0 -20
- package/dist/components/form-radio.js.map +0 -1
- package/dist/components/form-textarea.d.ts +0 -11
- package/dist/components/form-textarea.js +0 -12
- package/dist/components/form-textarea.js.map +0 -1
- package/dist/components/form.d.ts +0 -24
- package/dist/components/form.js +0 -71
- package/dist/components/form.js.map +0 -1
- package/dist/components/time-input-native.d.ts +0 -14
- package/dist/components/time-input-native.js +0 -62
- package/dist/components/time-input-native.js.map +0 -1
- package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -706
- package/dist/node_modules/react-hook-form/dist/index.esm.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","sources":["../../src/components/dropdown.tsx"],"sourcesContent":["'use client';\n\n/**\n * @ Author: BetterInternship\n * @ Create Time: 2025-06-14 23:30:09\n * @ Modified time: 2025-10-31 18:13:16\n * @ Description:\n *\n * Stateful dropdown group component.\n */\n\nimport { Button } from \"./button\";\nimport { useMobile } from \"@/hooks/use-mobile\";\nimport { useMobileSheetViewport } from \"@/hooks/use-mobile-sheet-viewport\";\nimport { MobileSheetPortal } from \"./mobile-sheet-portal\";\nimport { cn } from \"@/utils\";\nimport { fieldTriggerClassName } from \"@/hooks/use-field-focus\";\nimport { ChevronDown, X } from \"lucide-react\";\nimport { useRouter } from \"next/navigation\";\nimport React, {\n Children,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useDetectClickOutside } from '@/hooks/use-detect-click-outside';\n\n/**\n * The group context interface.\n * What's available in the group context to other components.\n */\ninterface IDropdownGroupContext {\n activeDropdown: string;\n setActiveDropdown: (dropdown: string) => void;\n}\nconst DropdownGroupContext = createContext<IDropdownGroupContext>(\n {} as IDropdownGroupContext,\n);\n\n/**\n * A wrapper around the contents of a dropdown option.\n *\n * @component\n */\ntype IDropdownOptionProps = {\n children?: React.ReactNode;\n highlighted?: boolean;\n disabled?: boolean;\n href?: string;\n on_click?: () => void;\n};\nexport const DropdownOption = ({ children }: IDropdownOptionProps) => {\n return <>{children}</>;\n};\n\n/**\n * Creates a standard button dropdowns must use with mobile optimization.\n * Not meant to be used elsewhere.\n *\n * @component\n */\nconst DropdownOptionButton = ({\n children,\n set_is_open,\n size = \"xs\",\n}: {\n children: React.ReactElement<IDropdownOptionProps>;\n set_is_open: (is_open: boolean) => void;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\";\n}) => {\n const router = useRouter();\n const is_mobile = useMobile();\n const [scrolling, setScrolling] = useState(false);\n const dropdown_button_ref = useRef<HTMLInputElement>({} as HTMLInputElement);\n\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n set_is_open(false);\n children.props.on_click && children.props.on_click();\n children.props.href && router.push(children.props.href);\n },\n [children.props, router, set_is_open],\n );\n\n const onTouchStart = (e: any) => {\n e.stopPropagation();\n setScrolling(true);\n };\n\n const onTouchEnd = (e: any) => {\n e.stopPropagation();\n setScrolling(false);\n };\n\n useEffect(() => {\n const dropdown_button = dropdown_button_ref.current;\n if (!dropdown_button) return;\n\n // Attach passive touchstart handler\n dropdown_button.addEventListener(\"touchstart\", onTouchStart, {\n passive: true,\n });\n\n dropdown_button.addEventListener(\"touchend\", onTouchEnd, {\n passive: true,\n });\n\n // Cleanup on unmount\n return () => {\n dropdown_button.removeEventListener(\"touchstart\", onTouchStart);\n dropdown_button.removeEventListener(\"touchend\", onTouchEnd);\n };\n }, [onTouchStart]);\n\n return (\n <button\n // @ts-ignore\n ref={dropdown_button_ref}\n className={cn(\n \"flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 text-left text-muted-foreground transition-colors hover:bg-muted\",\n is_mobile ? \"min-h-12 py-3 active:bg-muted touch-manipulation\" : \"\",\n `text-${size}`,\n children.props.highlighted ? \"bg-primary-tint\" : \"\",\n )}\n onClick={(e) => !scrolling && handleClick(e)}\n >\n <div className=\"w-full\">{children}</div>\n </button>\n );\n};\n\n/**\n * This component creates a context provider for dropdowns inside it to use.\n * The dropdowns inside can modify the active dropdown when they're clicked.\n * This way, only one dropdown in the group is active at a time.\n *\n * @component\n */\nexport const DropdownGroup = ({ children }: { children: React.ReactNode }) => {\n const [activeDropdown, setActiveDropdown] = useState(\"\");\n const group_dropdown_context: IDropdownGroupContext = {\n activeDropdown,\n setActiveDropdown,\n };\n\n return (\n <DropdownGroupContext value={group_dropdown_context}>\n {children}\n </DropdownGroupContext>\n );\n};\n\ninterface IRadioDropdownOption<ID> {\n id: ID;\n name: string;\n}\n\n/**\n * This represents a single dropdown inside the group with mobile optimization.\n * Inherits the provided context (if there is none, that's fine).\n *\n * @component\n */\nexport const GroupableRadioDropdown = <ID extends number | string>({\n name,\n options,\n onChange,\n disabled,\n defaultValue = null,\n size = \"sm\",\n className = \"\",\n fallback = \"Select option\",\n}: {\n name: string;\n options: IRadioDropdownOption<ID>[];\n onChange: (option: ID) => void;\n defaultValue?: ID | ID[] | null;\n disabled?: boolean | undefined;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\";\n className?: string;\n fallback?: string;\n}) => {\n const isMobile = useMobile();\n const { activeDropdown, setActiveDropdown } =\n useContext(DropdownGroupContext);\n const [isOpen, setIsOpen] = useState(false);\n const sheetViewport = useMobileSheetViewport(isOpen && isMobile);\n const [value, setValue] = useState(defaultValue);\n const ref = useDetectClickOutside({ onTriggered: () => setIsOpen(false) });\n const triggerRef = useRef<HTMLButtonElement>(null);\n const sheetRef = useRef<HTMLDivElement>(null);\n const sheetCloseRef = useRef<HTMLButtonElement>(null);\n const useSheet = isOpen && isMobile;\n\n const closeSheet = useCallback(() => {\n setIsOpen(false);\n triggerRef.current?.focus();\n }, []);\n\n // While the mobile sheet is open: lock page scroll and move focus into it.\n useEffect(() => {\n if (!useSheet) return;\n const overflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n const frame = window.requestAnimationFrame(() =>\n sheetCloseRef.current?.focus(),\n );\n return () => {\n window.cancelAnimationFrame(frame);\n document.body.style.overflow = overflow;\n };\n }, [useSheet]);\n\n // Just so it's not stuck at the first default when the default changes\n useEffect(() => {\n setValue(defaultValue);\n }, [defaultValue]);\n\n /**\n * Activates dropdown\n */\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n setIsOpen(!isOpen);\n setActiveDropdown(name);\n },\n [isOpen, name, setActiveDropdown],\n );\n\n /**\n * Changes dropdown value\n */\n const handleChange = useCallback(\n (option: ID) => {\n setValue(option);\n onChange(option);\n setIsOpen(false);\n },\n [onChange],\n );\n\n // Check if it's still the active dropdown\n useEffect(() => {\n if (activeDropdown !== name) setIsOpen(false);\n }, [activeDropdown, name]);\n\n const selected =\n value || value === 0 ? options.find((o) => o.id === value) : undefined;\n\n return (\n <div\n className={cn(\"relative w-full max-w-svw min-w-0\", className)}\n ref={ref}\n >\n <Button\n ref={triggerRef}\n type=\"button\"\n variant=\"outline\"\n disabled={disabled}\n size={size}\n onClick={handleClick}\n onTouchEnd={(e) => e.stopPropagation()}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n className={cn(\n \"w-full max-w-full min-w-0\",\n \"h-auto py-1\",\n fieldTriggerClassName,\n \"flex items-center justify-between gap-2\",\n )}\n >\n {/* shrinkable text container */}\n <span className=\"flex-1 min-w-0 text-left pr-2 leading-relaxed\">\n {selected ? (\n <span className=\"block whitespace-normal wrap-break-word\">\n {selected.name}\n </span>\n ) : (\n <span className=\"text-muted-foreground/40 font-normal\">\n {fallback}\n </span>\n )}\n </span>\n\n <ChevronDown\n className={cn(\n \"shrink-0 w-4 h-4 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none\",\n isOpen ? \"rotate-180\" : \"\",\n )}\n />\n </Button>\n\n {isOpen && (\n <MobileSheetPortal enabled={isMobile}>\n {isMobile && (\n <button\n type=\"button\"\n aria-label=\"Close options\"\n tabIndex={-1}\n className=\"fixed inset-0 z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]\"\n onClick={closeSheet}\n />\n )}\n <div\n ref={isMobile ? sheetRef : undefined}\n role={isMobile ? \"dialog\" : undefined}\n aria-modal={isMobile ? true : undefined}\n aria-label={isMobile ? fallback : undefined}\n onKeyDown={\n isMobile\n ? (event) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeSheet();\n }\n if (event.key !== \"Tab\") return;\n const focusable =\n sheetRef.current?.querySelectorAll<HTMLElement>(\n \"button:not([disabled]):not([tabindex='-1'])\",\n );\n if (!focusable?.length) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (\n !event.shiftKey &&\n document.activeElement === last\n ) {\n event.preventDefault();\n first.focus();\n }\n }\n : undefined\n }\n className={cn(\n \"border border-border bg-background shadow-card\",\n isMobile\n ? \"fixed left-0 right-0 z-(--z-popover) flex flex-col overflow-hidden rounded-t-control-lg border-b-0 pb-[max(0.75rem,env(safe-area-inset-bottom))]\"\n : \"absolute left-0 right-0 top-full z-[9999] mt-1 max-w-full overflow-hidden rounded-control-lg\",\n )}\n style={\n isMobile\n ? {\n bottom: sheetViewport?.bottom ?? 0,\n maxHeight: sheetViewport\n ? Math.min(sheetViewport.height, 640)\n : \"80dvh\",\n }\n : undefined\n }\n >\n {isMobile && (\n <div className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-2 pt-4\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {fallback}\n </h2>\n <button\n ref={sheetCloseRef}\n type=\"button\"\n aria-label=\"Close options\"\n className=\"-mr-3 flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\n onClick={closeSheet}\n >\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n )}\n <div\n role=\"listbox\"\n className={cn(\n \"relative flex flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset touch-pan-y [-webkit-overflow-scrolling:touch] [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]\",\n isMobile ? \"min-h-0 flex-1\" : \"max-h-[400px]\",\n )}\n >\n {options.map((option, index) => (\n <DropdownOptionButton\n key={index}\n set_is_open={setIsOpen}\n size={size}\n >\n <DropdownOption\n highlighted={value === option.id}\n on_click={() => handleChange(option.id)}\n >\n <span className=\"block whitespace-normal wrap-break-word pr-2\">\n {option.name}\n </span>\n </DropdownOption>\n </DropdownOptionButton>\n ))}\n </div>\n </div>\n </MobileSheetPortal>\n )}\n </div>\n );\n};\n\n/**\n * This creates a dropdown menu for navigating with improved mobile support.\n *\n * @component\n */\nexport const GroupableNavDropdown = ({\n display,\n content,\n children,\n className = \"\",\n showArrow = true,\n}: {\n display?: React.ReactNode;\n content?: React.ReactNode;\n children?:\n | React.ReactElement<IDropdownOptionProps>\n | React.ReactElement<IDropdownOptionProps>[];\n className?: string;\n showArrow?: boolean;\n}) => {\n const is_mobile = useMobile();\n const [is_open, set_is_open] = useState(false);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const touchStartRef = useRef<{\n x: number;\n y: number;\n target: EventTarget | null;\n } | null>(null);\n\n // Close dropdown handler\n const closeDropdown = useCallback(() => {\n set_is_open(false);\n }, []);\n\n // Handle clicks outside dropdown\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n !is_mobile &&\n dropdownRef.current &&\n !dropdownRef.current.contains(event.target as Node) &&\n buttonRef.current &&\n !buttonRef.current.contains(event.target as Node)\n ) {\n closeDropdown();\n }\n };\n\n if (is_open && !is_mobile) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () =>\n document.removeEventListener(\"mousedown\", handleClickOutside);\n }\n }, [is_open, is_mobile, closeDropdown]);\n\n // Mobile touch handlers\n const handleTouchStart = useCallback(\n (e: TouchEvent) => {\n if (!is_mobile || !is_open) return;\n\n const touch = e.touches[0];\n touchStartRef.current = {\n x: touch.clientX,\n y: touch.clientY,\n target: e.target,\n };\n },\n [is_mobile, is_open],\n );\n\n const handleTouchEnd = useCallback(\n (e: TouchEvent) => {\n if (!is_mobile || !is_open || !touchStartRef.current) return;\n\n const touch = e.changedTouches[0];\n const startTouch = touchStartRef.current;\n\n // Calculate touch movement\n const deltaX = Math.abs(touch.clientX - startTouch.x);\n const deltaY = Math.abs(touch.clientY - startTouch.y);\n const isSwipe = deltaX > 10 || deltaY > 10;\n\n // Check if touch is outside dropdown area\n const target = e.target as Element;\n const isOutsideDropdown =\n dropdownRef.current &&\n !dropdownRef.current.contains(target) &&\n buttonRef.current &&\n !buttonRef.current.contains(target);\n\n // Close if touch ended outside and wasn't a swipe\n if (!isSwipe && isOutsideDropdown) {\n closeDropdown();\n }\n\n touchStartRef.current = null;\n },\n [is_mobile, is_open, closeDropdown],\n );\n\n // Set up mobile touch listeners\n useEffect(() => {\n if (is_mobile && is_open) {\n document.addEventListener(\"touchstart\", handleTouchStart);\n document.addEventListener(\"touchend\", handleTouchEnd);\n\n return () => {\n document.removeEventListener(\"touchstart\", handleTouchStart);\n document.removeEventListener(\"touchend\", handleTouchEnd);\n };\n }\n }, [is_mobile, is_open, handleTouchStart, handleTouchEnd]);\n\n // Prevent event propagation for dropdown content\n const handleDropdownInteraction = useCallback(\n (e: React.MouseEvent | React.TouchEvent) => {\n e.stopPropagation();\n },\n [],\n );\n\n // Toggle dropdown\n const handleButtonClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n set_is_open(!is_open);\n },\n [is_open],\n );\n\n return (\n <div className={cn(\"relative z-[100]\", className)} ref={dropdownRef}>\n <Button\n ref={buttonRef}\n type=\"button\"\n variant=\"ghost\"\n className=\"relative flex items-center gap-2 h-12 px-3 z-[1000]\"\n onClick={handleButtonClick}\n onTouchEnd={(e) => e.stopPropagation()}\n >\n {display}\n {showArrow && (\n <ChevronDown\n className={cn(\n \"w-4 h-4 text-muted-foreground transition-transform\",\n is_open ? \"rotate-180\" : \"\",\n )}\n />\n )}\n </Button>\n\n {is_open && (\n <div\n className={cn(\n \"absolute right-0 mt-2 bg-background border border-border rounded-control-lg overflow-hidden shadow-card z-[1000]\",\n is_mobile ? \"w-56\" : \"w-48\", // Slightly wider on mobile for better touch targets\n className,\n )}\n onClick={handleDropdownInteraction}\n onTouchStart={handleDropdownInteraction}\n onTouchEnd={handleDropdownInteraction}\n >\n <div\n className={cn(\n \"relative z-[1000] flex max-h-64 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]\",\n is_mobile ? \"max-h-80\" : \"max-h-64\",\n )}\n >\n {content}\n\n {Children.map(children, (child, index) => {\n return (\n <DropdownOptionButton key={index} set_is_open={set_is_open}>\n {child ? child : <></>}\n </DropdownOptionButton>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAsCA;;;AAkBA;AAEA;;;;;AAKG;AACH;AASE;AACA;;AAEA;AAEA;;;;AAKI;;AAKJ;;;AAGA;AAEA;;;AAGA;;AAGE;AACA;;;AAGA;AACE;AACD;AAED;AACE;AACD;;AAGD;AACE;AACA;AACF;AACF;AAEA;;AAGI;AAYN;AAEA;;;;;;AAMG;;;AAGD;;;;;AAUF;AAOA;;;;;AAKG;AACI;AAmBL;;;;;AAMA;AACA;AACA;AACA;AACA;AAEA;;AAEE;;;;AAKA;;;;AAGA;AAGA;AACE;;AAEF;AACF;;;;AAKA;AAEA;;AAEG;AACH;;AAGI;;;AAMJ;;AAEG;AACH;;;;AAKE;;;;;AAOF;AAEA;;AAgEc;AACI;;AAEE;;AAEF;;;;;AAMA;;;;;;;AAOE;;;;;;AAWN;AACA;AAIA;AACI;AACA;;AAEE;AACH;AACH;AAgDhB;AAEA;;;;AAIG;;AAgBD;;AAEA;AACA;AACA;;AAOA;;;;;AAME;AACE;AAEE;;AAEA;;AAGA;;AAEJ;AAEA;AACE;;;;;AAOJ;AAEI;;;;;;;;AAQF;AAIF;;;;AAKI;;AAGA;AACA;;;AAIA;AACA;AAEE;AACA;;;AAIF;AACE;;AAGF;;;;AAOF;AACE;AACA;AAEA;AACE;AACA;AACF;;;;AAKJ;;;;AAQA;;AAGI;AACF;;;;AAkDQ;AAMZ;;"}
|
|
1
|
+
{"version":3,"file":"dropdown.js","sources":["../../src/components/dropdown.tsx"],"sourcesContent":["'use client';\r\n\r\n/**\r\n * @ Author: BetterInternship\r\n * @ Create Time: 2025-06-14 23:30:09\r\n * @ Modified time: 2025-10-31 18:13:16\r\n * @ Description:\r\n *\r\n * Stateful dropdown group component.\r\n */\r\n\r\nimport { Button } from \"./button\";\r\nimport { useMobile } from \"@/hooks/use-mobile\";\r\nimport { useMobileSheetViewport } from \"@/hooks/use-mobile-sheet-viewport\";\r\nimport { MobileSheetPortal } from \"./mobile-sheet-portal\";\r\nimport { cn } from \"@/utils\";\r\nimport { fieldTriggerClassName } from \"@/hooks/use-field-focus\";\r\nimport { useFormField, useFormFieldControl } from \"./form-field\";\r\nimport { ChevronDown, X } from \"lucide-react\";\r\nimport { useRouter } from \"next/navigation\";\r\nimport React, {\r\n Children,\r\n createContext,\r\n useCallback,\r\n useContext,\r\n useEffect,\r\n useRef,\r\n useState,\r\n} from \"react\";\r\nimport { useDetectClickOutside } from '@/hooks/use-detect-click-outside';\r\n\r\n/**\r\n * The group context interface.\r\n * What's available in the group context to other components.\r\n */\r\ninterface IDropdownGroupContext {\r\n activeDropdown: string;\r\n setActiveDropdown: (dropdown: string) => void;\r\n}\r\nconst DropdownGroupContext = createContext<IDropdownGroupContext>(\r\n {} as IDropdownGroupContext,\r\n);\r\n\r\n/**\r\n * A wrapper around the contents of a dropdown option.\r\n *\r\n * @component\r\n */\r\ntype IDropdownOptionProps = {\r\n children?: React.ReactNode;\r\n highlighted?: boolean;\r\n disabled?: boolean;\r\n href?: string;\r\n on_click?: () => void;\r\n};\r\nexport const DropdownOption = ({ children }: IDropdownOptionProps) => {\r\n return <>{children}</>;\r\n};\r\n\r\n/**\r\n * Creates a standard button dropdowns must use with mobile optimization.\r\n * Not meant to be used elsewhere.\r\n *\r\n * @component\r\n */\r\nconst DropdownOptionButton = ({\r\n children,\r\n set_is_open,\r\n size = \"xs\",\r\n}: {\r\n children: React.ReactElement<IDropdownOptionProps>;\r\n set_is_open: (is_open: boolean) => void;\r\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\";\r\n}) => {\r\n const router = useRouter();\r\n const is_mobile = useMobile();\r\n const [scrolling, setScrolling] = useState(false);\r\n const dropdown_button_ref = useRef<HTMLInputElement>({} as HTMLInputElement);\r\n\r\n const handleClick = useCallback(\r\n (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n set_is_open(false);\r\n children.props.on_click && children.props.on_click();\r\n children.props.href && router.push(children.props.href);\r\n },\r\n [children.props, router, set_is_open],\r\n );\r\n\r\n const onTouchStart = (e: any) => {\r\n e.stopPropagation();\r\n setScrolling(true);\r\n };\r\n\r\n const onTouchEnd = (e: any) => {\r\n e.stopPropagation();\r\n setScrolling(false);\r\n };\r\n\r\n useEffect(() => {\r\n const dropdown_button = dropdown_button_ref.current;\r\n if (!dropdown_button) return;\r\n\r\n // Attach passive touchstart handler\r\n dropdown_button.addEventListener(\"touchstart\", onTouchStart, {\r\n passive: true,\r\n });\r\n\r\n dropdown_button.addEventListener(\"touchend\", onTouchEnd, {\r\n passive: true,\r\n });\r\n\r\n // Cleanup on unmount\r\n return () => {\r\n dropdown_button.removeEventListener(\"touchstart\", onTouchStart);\r\n dropdown_button.removeEventListener(\"touchend\", onTouchEnd);\r\n };\r\n }, [onTouchStart]);\r\n\r\n return (\r\n <button\r\n // @ts-ignore\r\n ref={dropdown_button_ref}\r\n className={cn(\r\n \"flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 text-left text-muted-foreground transition-colors hover:bg-muted\",\r\n is_mobile ? \"min-h-12 py-3 active:bg-muted touch-manipulation\" : \"\",\r\n `text-${size}`,\r\n children.props.highlighted ? \"bg-primary-tint\" : \"\",\r\n )}\r\n onClick={(e) => !scrolling && handleClick(e)}\r\n >\r\n <div className=\"w-full\">{children}</div>\r\n </button>\r\n );\r\n};\r\n\r\n/**\r\n * This component creates a context provider for dropdowns inside it to use.\r\n * The dropdowns inside can modify the active dropdown when they're clicked.\r\n * This way, only one dropdown in the group is active at a time.\r\n *\r\n * @component\r\n */\r\nexport const DropdownGroup = ({ children }: { children: React.ReactNode }) => {\r\n const [activeDropdown, setActiveDropdown] = useState(\"\");\r\n const group_dropdown_context: IDropdownGroupContext = {\r\n activeDropdown,\r\n setActiveDropdown,\r\n };\r\n\r\n return (\r\n <DropdownGroupContext value={group_dropdown_context}>\r\n {children}\r\n </DropdownGroupContext>\r\n );\r\n};\r\n\r\ninterface IRadioDropdownOption<ID> {\r\n id: ID;\r\n name: string;\r\n}\r\n\r\n/**\r\n * This represents a single dropdown inside the group with mobile optimization.\r\n * Inherits the provided context (if there is none, that's fine).\r\n *\r\n * @component\r\n */\r\nexport const GroupableRadioDropdown = <ID extends number | string>({\r\n name,\r\n options,\r\n onChange,\r\n disabled,\r\n defaultValue = null,\r\n size = \"sm\",\r\n className = \"\",\r\n fallback = \"Select option\",\r\n}: {\r\n name: string;\r\n options: IRadioDropdownOption<ID>[];\r\n onChange: (option: ID) => void;\r\n defaultValue?: ID | ID[] | null;\r\n disabled?: boolean | undefined;\r\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\";\r\n className?: string;\r\n fallback?: string;\r\n}) => {\r\n const isMobile = useMobile();\r\n const { activeDropdown, setActiveDropdown } =\r\n useContext(DropdownGroupContext);\r\n const [isOpen, setIsOpen] = useState(false);\r\n const sheetViewport = useMobileSheetViewport(isOpen && isMobile);\r\n const [value, setValue] = useState(defaultValue);\r\n const ref = useDetectClickOutside({ onTriggered: () => setIsOpen(false) });\r\n const triggerRef = useRef<HTMLButtonElement>(null);\r\n const sheetRef = useRef<HTMLDivElement>(null);\r\n const sheetCloseRef = useRef<HTMLButtonElement>(null);\r\n const useSheet = isOpen && isMobile;\r\n // The phone sheet's title: the field's label when inside a FormField.\r\n const sheetTitle = useFormField()?.labelText ?? fallback;\r\n // Inside a FormField the trigger takes the field's id, so the label opens it.\r\n const fieldProps = useFormFieldControl<{\r\n id?: string;\r\n \"aria-describedby\"?: string;\r\n \"aria-invalid\"?: React.AriaAttributes[\"aria-invalid\"];\r\n \"aria-required\"?: React.AriaAttributes[\"aria-required\"];\r\n }>({});\r\n\r\n const closeSheet = useCallback(() => {\r\n setIsOpen(false);\r\n triggerRef.current?.focus();\r\n }, []);\r\n\r\n // While the mobile sheet is open: lock page scroll and move focus into it.\r\n useEffect(() => {\r\n if (!useSheet) return;\r\n const overflow = document.body.style.overflow;\r\n document.body.style.overflow = \"hidden\";\r\n const frame = window.requestAnimationFrame(() =>\r\n sheetCloseRef.current?.focus(),\r\n );\r\n return () => {\r\n window.cancelAnimationFrame(frame);\r\n document.body.style.overflow = overflow;\r\n };\r\n }, [useSheet]);\r\n\r\n // Just so it's not stuck at the first default when the default changes\r\n useEffect(() => {\r\n setValue(defaultValue);\r\n }, [defaultValue]);\r\n\r\n /**\r\n * Activates dropdown\r\n */\r\n const handleClick = useCallback(\r\n (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n setIsOpen(!isOpen);\r\n setActiveDropdown(name);\r\n },\r\n [isOpen, name, setActiveDropdown],\r\n );\r\n\r\n /**\r\n * Changes dropdown value\r\n */\r\n const handleChange = useCallback(\r\n (option: ID) => {\r\n setValue(option);\r\n onChange(option);\r\n setIsOpen(false);\r\n },\r\n [onChange],\r\n );\r\n\r\n // Check if it's still the active dropdown\r\n useEffect(() => {\r\n if (activeDropdown !== name) setIsOpen(false);\r\n }, [activeDropdown, name]);\r\n\r\n const selected =\r\n value || value === 0 ? options.find((o) => o.id === value) : undefined;\r\n\r\n return (\r\n <div\r\n className={cn(\"relative w-full max-w-svw min-w-0\", className)}\r\n ref={ref}\r\n >\r\n <Button\r\n {...fieldProps}\r\n ref={triggerRef}\r\n type=\"button\"\r\n variant=\"outline\"\r\n disabled={disabled}\r\n size={size}\r\n onClick={handleClick}\r\n onTouchEnd={(e) => e.stopPropagation()}\r\n aria-haspopup=\"listbox\"\r\n aria-expanded={isOpen}\r\n className={cn(\r\n \"w-full max-w-full min-w-0\",\r\n \"h-auto py-1\",\r\n fieldTriggerClassName,\r\n \"flex items-center justify-between gap-2\",\r\n )}\r\n >\r\n {/* shrinkable text container */}\r\n <span className=\"flex-1 min-w-0 text-left pr-2 leading-relaxed\">\r\n {selected ? (\r\n <span className=\"block whitespace-normal wrap-break-word\">\r\n {selected.name}\r\n </span>\r\n ) : (\r\n <span className=\"text-muted-foreground/40 font-normal\">\r\n {fallback}\r\n </span>\r\n )}\r\n </span>\r\n\r\n <ChevronDown\r\n className={cn(\r\n \"shrink-0 w-4 h-4 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none\",\r\n isOpen ? \"rotate-180\" : \"\",\r\n )}\r\n />\r\n </Button>\r\n\r\n {isOpen && (\r\n <MobileSheetPortal enabled={isMobile}>\r\n {isMobile && (\r\n <button\r\n type=\"button\"\r\n aria-label=\"Close options\"\r\n tabIndex={-1}\r\n className=\"fixed inset-0 z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]\"\r\n onClick={closeSheet}\r\n />\r\n )}\r\n <div\r\n ref={isMobile ? sheetRef : undefined}\r\n role={isMobile ? \"dialog\" : undefined}\r\n aria-modal={isMobile ? true : undefined}\r\n aria-label={isMobile ? sheetTitle : undefined}\r\n onKeyDown={\r\n isMobile\r\n ? (event) => {\r\n if (event.key === \"Escape\") {\r\n event.preventDefault();\r\n closeSheet();\r\n }\r\n if (event.key !== \"Tab\") return;\r\n const focusable =\r\n sheetRef.current?.querySelectorAll<HTMLElement>(\r\n \"button:not([disabled]):not([tabindex='-1'])\",\r\n );\r\n if (!focusable?.length) return;\r\n const first = focusable[0];\r\n const last = focusable[focusable.length - 1];\r\n if (event.shiftKey && document.activeElement === first) {\r\n event.preventDefault();\r\n last.focus();\r\n } else if (\r\n !event.shiftKey &&\r\n document.activeElement === last\r\n ) {\r\n event.preventDefault();\r\n first.focus();\r\n }\r\n }\r\n : undefined\r\n }\r\n className={cn(\r\n \"border border-border bg-background shadow-card\",\r\n isMobile\r\n ? \"fixed left-0 right-0 z-(--z-popover) flex flex-col overflow-hidden rounded-t-control-lg border-b-0 pb-[max(0.75rem,env(safe-area-inset-bottom))]\"\r\n : \"absolute left-0 right-0 top-full z-[9999] mt-1 max-w-full overflow-hidden rounded-control-lg\",\r\n )}\r\n style={\r\n isMobile\r\n ? {\r\n bottom: sheetViewport?.bottom ?? 0,\r\n maxHeight: sheetViewport\r\n ? Math.min(sheetViewport.height, 640)\r\n : \"80dvh\",\r\n }\r\n : undefined\r\n }\r\n >\r\n {isMobile && (\r\n <div className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-2 pt-4\">\r\n <h2 className=\"text-base font-semibold text-foreground\">\r\n {sheetTitle}\r\n </h2>\r\n <button\r\n ref={sheetCloseRef}\r\n type=\"button\"\r\n aria-label=\"Close options\"\r\n className=\"-mr-3 flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\r\n onClick={closeSheet}\r\n >\r\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\r\n </button>\r\n </div>\r\n )}\r\n <div\r\n role=\"listbox\"\r\n className={cn(\r\n \"relative flex flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset touch-pan-y [-webkit-overflow-scrolling:touch] [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]\",\r\n isMobile ? \"min-h-0 flex-1\" : \"max-h-[400px]\",\r\n )}\r\n >\r\n {options.map((option, index) => (\r\n <DropdownOptionButton\r\n key={index}\r\n set_is_open={setIsOpen}\r\n size={size}\r\n >\r\n <DropdownOption\r\n highlighted={value === option.id}\r\n on_click={() => handleChange(option.id)}\r\n >\r\n <span className=\"block whitespace-normal wrap-break-word pr-2\">\r\n {option.name}\r\n </span>\r\n </DropdownOption>\r\n </DropdownOptionButton>\r\n ))}\r\n </div>\r\n </div>\r\n </MobileSheetPortal>\r\n )}\r\n </div>\r\n );\r\n};\r\n\r\n/**\r\n * This creates a dropdown menu for navigating with improved mobile support.\r\n *\r\n * @component\r\n */\r\nexport const GroupableNavDropdown = ({\r\n display,\r\n content,\r\n children,\r\n className = \"\",\r\n showArrow = true,\r\n}: {\r\n display?: React.ReactNode;\r\n content?: React.ReactNode;\r\n children?:\r\n | React.ReactElement<IDropdownOptionProps>\r\n | React.ReactElement<IDropdownOptionProps>[];\r\n className?: string;\r\n showArrow?: boolean;\r\n}) => {\r\n const is_mobile = useMobile();\r\n const [is_open, set_is_open] = useState(false);\r\n const dropdownRef = useRef<HTMLDivElement>(null);\r\n const buttonRef = useRef<HTMLButtonElement>(null);\r\n const touchStartRef = useRef<{\r\n x: number;\r\n y: number;\r\n target: EventTarget | null;\r\n } | null>(null);\r\n\r\n // Close dropdown handler\r\n const closeDropdown = useCallback(() => {\r\n set_is_open(false);\r\n }, []);\r\n\r\n // Handle clicks outside dropdown\r\n useEffect(() => {\r\n const handleClickOutside = (event: MouseEvent) => {\r\n if (\r\n !is_mobile &&\r\n dropdownRef.current &&\r\n !dropdownRef.current.contains(event.target as Node) &&\r\n buttonRef.current &&\r\n !buttonRef.current.contains(event.target as Node)\r\n ) {\r\n closeDropdown();\r\n }\r\n };\r\n\r\n if (is_open && !is_mobile) {\r\n document.addEventListener(\"mousedown\", handleClickOutside);\r\n return () =>\r\n document.removeEventListener(\"mousedown\", handleClickOutside);\r\n }\r\n }, [is_open, is_mobile, closeDropdown]);\r\n\r\n // Mobile touch handlers\r\n const handleTouchStart = useCallback(\r\n (e: TouchEvent) => {\r\n if (!is_mobile || !is_open) return;\r\n\r\n const touch = e.touches[0];\r\n touchStartRef.current = {\r\n x: touch.clientX,\r\n y: touch.clientY,\r\n target: e.target,\r\n };\r\n },\r\n [is_mobile, is_open],\r\n );\r\n\r\n const handleTouchEnd = useCallback(\r\n (e: TouchEvent) => {\r\n if (!is_mobile || !is_open || !touchStartRef.current) return;\r\n\r\n const touch = e.changedTouches[0];\r\n const startTouch = touchStartRef.current;\r\n\r\n // Calculate touch movement\r\n const deltaX = Math.abs(touch.clientX - startTouch.x);\r\n const deltaY = Math.abs(touch.clientY - startTouch.y);\r\n const isSwipe = deltaX > 10 || deltaY > 10;\r\n\r\n // Check if touch is outside dropdown area\r\n const target = e.target as Element;\r\n const isOutsideDropdown =\r\n dropdownRef.current &&\r\n !dropdownRef.current.contains(target) &&\r\n buttonRef.current &&\r\n !buttonRef.current.contains(target);\r\n\r\n // Close if touch ended outside and wasn't a swipe\r\n if (!isSwipe && isOutsideDropdown) {\r\n closeDropdown();\r\n }\r\n\r\n touchStartRef.current = null;\r\n },\r\n [is_mobile, is_open, closeDropdown],\r\n );\r\n\r\n // Set up mobile touch listeners\r\n useEffect(() => {\r\n if (is_mobile && is_open) {\r\n document.addEventListener(\"touchstart\", handleTouchStart);\r\n document.addEventListener(\"touchend\", handleTouchEnd);\r\n\r\n return () => {\r\n document.removeEventListener(\"touchstart\", handleTouchStart);\r\n document.removeEventListener(\"touchend\", handleTouchEnd);\r\n };\r\n }\r\n }, [is_mobile, is_open, handleTouchStart, handleTouchEnd]);\r\n\r\n // Prevent event propagation for dropdown content\r\n const handleDropdownInteraction = useCallback(\r\n (e: React.MouseEvent | React.TouchEvent) => {\r\n e.stopPropagation();\r\n },\r\n [],\r\n );\r\n\r\n // Toggle dropdown\r\n const handleButtonClick = useCallback(\r\n (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n set_is_open(!is_open);\r\n },\r\n [is_open],\r\n );\r\n\r\n return (\r\n <div className={cn(\"relative z-[100]\", className)} ref={dropdownRef}>\r\n <Button\r\n ref={buttonRef}\r\n type=\"button\"\r\n variant=\"ghost\"\r\n className=\"relative flex items-center gap-2 h-12 px-3 z-[1000]\"\r\n onClick={handleButtonClick}\r\n onTouchEnd={(e) => e.stopPropagation()}\r\n >\r\n {display}\r\n {showArrow && (\r\n <ChevronDown\r\n className={cn(\r\n \"w-4 h-4 text-muted-foreground transition-transform\",\r\n is_open ? \"rotate-180\" : \"\",\r\n )}\r\n />\r\n )}\r\n </Button>\r\n\r\n {is_open && (\r\n <div\r\n className={cn(\r\n \"absolute right-0 mt-2 bg-background border border-border rounded-control-lg overflow-hidden shadow-card z-[1000]\",\r\n is_mobile ? \"w-56\" : \"w-48\", // Slightly wider on mobile for better touch targets\r\n className,\r\n )}\r\n onClick={handleDropdownInteraction}\r\n onTouchStart={handleDropdownInteraction}\r\n onTouchEnd={handleDropdownInteraction}\r\n >\r\n <div\r\n className={cn(\r\n \"relative z-[1000] flex max-h-64 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]\",\r\n is_mobile ? \"max-h-80\" : \"max-h-64\",\r\n )}\r\n >\r\n {content}\r\n\r\n {Children.map(children, (child, index) => {\r\n return (\r\n <DropdownOptionButton key={index} set_is_open={set_is_open}>\r\n {child ? child : <></>}\r\n </DropdownOptionButton>\r\n );\r\n })}\r\n </div>\r\n </div>\r\n )}\r\n </div>\r\n );\r\n};\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAuCA;;;AAkBA;AAEA;;;;;AAKG;AACH;AASE;AACA;;AAEA;AAEA;;;;AAKI;;AAKJ;;;AAGA;AAEA;;;AAGA;;AAGE;AACA;;;AAGA;AACE;AACD;AAED;AACE;AACD;;AAGD;AACE;AACA;AACF;AACF;AAEA;;AAGI;AAYN;AAEA;;;;;;AAMG;;;AAGD;;;;;AAUF;AAOA;;;;;AAKG;AACI;AAmBL;;;;;AAMA;AACA;AACA;AACA;AACA;;;;AAIA;AAOA;;AAEE;;;;AAKA;;;;AAGA;AAGA;AACE;;AAEF;AACF;;;;AAKA;AAEA;;AAEG;AACH;;AAGI;;;AAMJ;;AAEG;AACH;;;;AAKE;;;;;AAOF;AAEA;;AAiEc;AACI;;AAEE;;AAEF;;;;;AAMA;;;;;;;AAOE;;;;;;AAWN;AACA;AAIA;AACI;AACA;;AAEE;AACH;AACH;AAgDhB;AAEA;;;;AAIG;;AAgBD;;AAEA;AACA;AACA;;AAOA;;;;;AAME;AACE;AAEE;;AAEA;;AAGA;;AAEJ;AAEA;AACE;;;;;AAOJ;AAEI;;;;;;;;AAQF;AAIF;;;;AAKI;;AAGA;AACA;;;AAIA;AACA;AAEE;AACA;;;AAIF;AACE;;AAGF;;;;AAOF;AACE;AACA;AAEA;AACE;AACA;AACF;;;;AAKJ;;;;AAQA;;AAGI;AACF;;;;AAkDQ;AAMZ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sources":["../../src/components/error.tsx"],"sourcesContent":["import { CircleAlert, RotateCw } from \"lucide-react\";\nimport { cn } from \"@/utils\";\nimport { Card } from \"./card\";\nimport { Button } from \"./button\";\n\nfunction ErrorGraphic() {\n return <img src=\"/error-exclamation-sprite.png\" alt=\"\" className=\"h-32 w-auto object-contain motion-safe:animate-error-bob motion-reduce:animate-none\" />;\n}\n\nexport const PageError = ({\n title,\n description,\n image = false,\n flush = false,\n topAlign = false,\n onRetry,\n}: {\n title: string;\n description: string;\n // Shows /error.png beneath the text.\n image?: boolean;\n // Card fills its container edge-to-edge instead of capping at max-w-md\n // with breathing room around it.\n flush?: boolean;\n // Aligns content to the top of the card instead of vertically centering\n // it (flush mode only).\n topAlign?: boolean;\n // Shows a \"Retry\" button that calls this when clicked.\n onRetry?: () => void;\n}) => {\n return (\n <div\n role=\"alert\"\n className={cn(\n \"animate-in fade-in-0 duration-interactive ease-out-strong motion-reduce:animate-none\",\n flush ? \"h-full\" : \"px-4 py-16\",\n )}\n >\n <Card\n className={cn(\n \"m-auto gap-0 px-6 py-8\",\n flush\n ? cn(\n \"h-full w-full items-start text-left\",\n topAlign ? \"justify-start\" : \"justify-center\",\n )\n : \"max-w-md items-center text-center\",\n )}\n >\n <span\n aria-hidden=\"true\"\n className={cn(\n \"mb-4 flex items-center justify-center text-destructive\",\n image\n ? \"h-40 w-32\"\n : \"size-12 rounded-full bg-destructive/10\",\n )}\n >\n {image ? <ErrorGraphic /> : <CircleAlert className=\"size-6\" />}\n </span>\n <h3 className=\"text-lg font-semibold text-foreground\">{title}</h3>\n <p className=\"mt-2 text-base leading-relaxed text-muted-foreground\">\n {description}\n </p>\n {onRetry && (\n <Button variant=\"outline\" className=\"mt-6\" onClick={onRetry}>\n <RotateCw className=\"size-4\" aria-hidden=\"true\" />\n Retry\n </Button>\n )}\n </Card>\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAKA,SAAS,YAAY,GAAA;AACnB,IAAA,OAAOA,GAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAC,+BAA+B,EAAC,GAAG,EAAC,EAAE,EAAC,SAAS,EAAC,qFAAqF,GAAG;AAC3J;AAEO,MAAM,SAAS,GAAG,CAAC,EACxB,KAAK,EACL,WAAW,EACX,KAAK,GAAG,KAAK,EACb,KAAK,GAAG,KAAK,EACb,QAAQ,GAAG,KAAK,EAChB,OAAO,GAcR,KAAI;AACH,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EACE,IAAI,EAAC,OAAO,EACZ,SAAS,EAAE,EAAE,CACX,sFAAsF,EACtF,KAAK,GAAG,QAAQ,GAAG,YAAY,CAChC,YAEDC,IAAA,CAAC,IAAI,EAAA,EACH,SAAS,EAAE,EAAE,CACX,wBAAwB,EACxB;AACE,kBAAE,EAAE,CACA,qCAAqC,EACrC,QAAQ,GAAG,eAAe,GAAG,gBAAgB;AAEjD,kBAAE,mCAAmC,CACxC,EAAA,QAAA,EAAA,CAEDD,GAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,SAAS,EAAE,EAAE,CACX,wDAAwD,EACxD;AACE,0BAAE;AACF,0BAAE,wCAAwC,CAC7C,EAAA,QAAA,EAEA,KAAK,GAAGA,GAAA,CAAC,YAAY,EAAA,EAAA,CAAG,GAAGA,GAAA,CAAC,WAAW,EAAA,EAAC,SAAS,EAAC,QAAQ,EAAA,CAAG,EAAA,CACzD,EACPA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,uCAAuC,YAAE,KAAK,EAAA,CAAM,EAClEA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,sDAAsD,EAAA,QAAA,EAChE,WAAW,EAAA,CACV,EACH,OAAO,KACNC,IAAA,CAAC,MAAM,EAAA,EAAC,OAAO,EAAC,SAAS,EAAC,SAAS,EAAC,MAAM,EAAC,OAAO,EAAE,OAAO,EAAA,QAAA,EAAA,CACzDD,GAAA,CAAC,QAAQ,EAAA,EAAC,SAAS,EAAC,QAAQ,EAAA,aAAA,EAAa,MAAM,GAAG,EAAA,OAAA,CAAA,EAAA,CAE3C,CACV,CAAA,EAAA,CACI,EAAA,CACH;AAEV;;;;"}
|
|
1
|
+
{"version":3,"file":"error.js","sources":["../../src/components/error.tsx"],"sourcesContent":["import { CircleAlert, RotateCw } from \"lucide-react\";\r\nimport { cn } from \"@/utils\";\r\nimport { Card } from \"./card\";\r\nimport { Button } from \"./button\";\r\n\r\nfunction ErrorGraphic() {\r\n return <img src=\"/error-exclamation-sprite.png\" alt=\"\" className=\"h-32 w-auto object-contain motion-safe:animate-error-bob motion-reduce:animate-none\" />;\r\n}\r\n\r\nexport const PageError = ({\r\n title,\r\n description,\r\n image = false,\r\n flush = false,\r\n topAlign = false,\r\n onRetry,\r\n}: {\r\n title: string;\r\n description: string;\r\n // Shows /error.png beneath the text.\r\n image?: boolean;\r\n // Card fills its container edge-to-edge instead of capping at max-w-md\r\n // with breathing room around it.\r\n flush?: boolean;\r\n // Aligns content to the top of the card instead of vertically centering\r\n // it (flush mode only).\r\n topAlign?: boolean;\r\n // Shows a \"Retry\" button that calls this when clicked.\r\n onRetry?: () => void;\r\n}) => {\r\n return (\r\n <div\r\n role=\"alert\"\r\n className={cn(\r\n \"animate-in fade-in-0 duration-interactive ease-out-strong motion-reduce:animate-none\",\r\n flush ? \"h-full\" : \"px-4 py-16\",\r\n )}\r\n >\r\n <Card\r\n className={cn(\r\n \"m-auto gap-0 px-6 py-8\",\r\n flush\r\n ? cn(\r\n \"h-full w-full items-start text-left\",\r\n topAlign ? \"justify-start\" : \"justify-center\",\r\n )\r\n : \"max-w-md items-center text-center\",\r\n )}\r\n >\r\n <span\r\n aria-hidden=\"true\"\r\n className={cn(\r\n \"mb-4 flex items-center justify-center text-destructive\",\r\n image\r\n ? \"h-40 w-32\"\r\n : \"size-12 rounded-full bg-destructive/10\",\r\n )}\r\n >\r\n {image ? <ErrorGraphic /> : <CircleAlert className=\"size-6\" />}\r\n </span>\r\n <h3 className=\"text-lg font-semibold text-foreground\">{title}</h3>\r\n <p className=\"mt-2 text-base leading-relaxed text-muted-foreground\">\r\n {description}\r\n </p>\r\n {onRetry && (\r\n <Button variant=\"outline\" className=\"mt-6\" onClick={onRetry}>\r\n <RotateCw className=\"size-4\" aria-hidden=\"true\" />\r\n Retry\r\n </Button>\r\n )}\r\n </Card>\r\n </div>\r\n );\r\n};\r\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAKA,SAAS,YAAY,GAAA;AACnB,IAAA,OAAOA,GAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAC,+BAA+B,EAAC,GAAG,EAAC,EAAE,EAAC,SAAS,EAAC,qFAAqF,GAAG;AAC3J;AAEO,MAAM,SAAS,GAAG,CAAC,EACxB,KAAK,EACL,WAAW,EACX,KAAK,GAAG,KAAK,EACb,KAAK,GAAG,KAAK,EACb,QAAQ,GAAG,KAAK,EAChB,OAAO,GAcR,KAAI;AACH,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EACE,IAAI,EAAC,OAAO,EACZ,SAAS,EAAE,EAAE,CACX,sFAAsF,EACtF,KAAK,GAAG,QAAQ,GAAG,YAAY,CAChC,YAEDC,IAAA,CAAC,IAAI,EAAA,EACH,SAAS,EAAE,EAAE,CACX,wBAAwB,EACxB;AACE,kBAAE,EAAE,CACA,qCAAqC,EACrC,QAAQ,GAAG,eAAe,GAAG,gBAAgB;AAEjD,kBAAE,mCAAmC,CACxC,EAAA,QAAA,EAAA,CAEDD,GAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,SAAS,EAAE,EAAE,CACX,wDAAwD,EACxD;AACE,0BAAE;AACF,0BAAE,wCAAwC,CAC7C,EAAA,QAAA,EAEA,KAAK,GAAGA,GAAA,CAAC,YAAY,EAAA,EAAA,CAAG,GAAGA,GAAA,CAAC,WAAW,EAAA,EAAC,SAAS,EAAC,QAAQ,EAAA,CAAG,EAAA,CACzD,EACPA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,uCAAuC,YAAE,KAAK,EAAA,CAAM,EAClEA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,sDAAsD,EAAA,QAAA,EAChE,WAAW,EAAA,CACV,EACH,OAAO,KACNC,IAAA,CAAC,MAAM,EAAA,EAAC,OAAO,EAAC,SAAS,EAAC,SAAS,EAAC,MAAM,EAAC,OAAO,EAAE,OAAO,EAAA,QAAA,EAAA,CACzDD,GAAA,CAAC,QAAQ,EAAA,EAAC,SAAS,EAAC,QAAQ,EAAA,aAAA,EAAa,MAAM,GAAG,EAAA,OAAA,CAAA,EAAA,CAE3C,CACV,CAAA,EAAA,CACI,EAAA,CACH;AAEV;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fab.js","sources":["../../src/components/fab.tsx"],"sourcesContent":["import { Button } from \"@/components/button\";\n\nconst FloatingActionButton = ({ onClick, children }: { onClick: () => void; children: React.ReactNode }) => {\n return (\n <Button\n onClick={onClick}\n className=\"fixed bottom-4 right-4 z-50 rounded-full bg-primary p-4 text-primary-foreground shadow-lg transition-[background-color,box-shadow,transform] duration-interactive ease-out-strong hover:bg-primary-hover hover:shadow-interactive motion-safe:pointer-fine:hover:-translate-y-0.5 motion-safe:active:translate-y-0 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary motion-reduce:transition-none\"\n >\n {children}\n </Button>\n );\n}\n\nexport { FloatingActionButton };\n"],"names":["_jsx"],"mappings":";;;AAEA,MAAM,oBAAoB,GAAG,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAsD,KAAI;AACzG,IAAA,QACEA,GAAA,CAAC,MAAM,EAAA,EACL,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,yZAAyZ,EAAA,QAAA,EAEla,QAAQ,EAAA,CACF;AAEb;;;;"}
|
|
1
|
+
{"version":3,"file":"fab.js","sources":["../../src/components/fab.tsx"],"sourcesContent":["import { Button } from \"@/components/button\";\r\n\r\nconst FloatingActionButton = ({ onClick, children }: { onClick: () => void; children: React.ReactNode }) => {\r\n return (\r\n <Button\r\n onClick={onClick}\r\n className=\"fixed bottom-4 right-4 z-50 rounded-full bg-primary p-4 text-primary-foreground shadow-lg transition-[background-color,box-shadow,transform] duration-interactive ease-out-strong hover:bg-primary-hover hover:shadow-interactive motion-safe:pointer-fine:hover:-translate-y-0.5 motion-safe:active:translate-y-0 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary motion-reduce:transition-none\"\r\n >\r\n {children}\r\n </Button>\r\n );\r\n}\r\n\r\nexport { FloatingActionButton };\r\n"],"names":["_jsx"],"mappings":";;;AAEA,MAAM,oBAAoB,GAAG,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAsD,KAAI;AACzG,IAAA,QACEA,GAAA,CAAC,MAAM,EAAA,EACL,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,yZAAyZ,EAAA,QAAA,EAEla,QAAQ,EAAA,CACF;AAEb;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload.js","sources":["../../src/components/file-upload.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Upload } from \"lucide-react\";\nimport { cn } from \"@/utils\";\nimport { FieldLabel } from \"./label\";\n\nexport type FileUploadVariant = \"compact\" | \"dropzone\";\nexport type FileRejectReason = \"type\" | \"size\";\nexport type FileUploadProps = {\n label: string;\n name: string;\n variant?: FileUploadVariant;\n /** Same format as the input's `accept`: extensions (\".pdf\") and/or MIME types (\"image/*\"). Also checked on drop. */\n accept?: string;\n /** Files larger than this are rejected through `onReject` instead of being selected. */\n maxSizeMB?: number;\n multiple?: boolean;\n required?: boolean;\n placeholder?: string;\n disabled?: boolean;\n className?: string;\n /**\n * The selected file, when the parent owns it. Pass `null` to clear the field.\n * Leave undefined to let the field remember the last pick itself.\n */\n value?: File | null;\n /** Shown under the field and marks it invalid. */\n error?: string | null;\n onFileSelect?: (file: File | null) => void;\n onFilesSelect?: (files: File[]) => void;\n /** Called with each file that fails `accept` or `maxSizeMB`. */\n onReject?: (file: File, reason: FileRejectReason) => void;\n};\n\n/** True when the file matches one of the `accept` entries (or there are none). */\nfunction matchesAccept(file: File, accept?: string) {\n if (!accept) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept\n .split(\",\")\n .map((entry) => entry.trim().toLowerCase())\n .filter(Boolean)\n .some((entry) =>\n entry.startsWith(\".\")\n ? name.endsWith(entry)\n : entry.endsWith(\"/*\")\n ? type.startsWith(entry.slice(0, -1))\n : type === entry,\n );\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(\n (\n {\n label,\n name,\n variant = \"compact\",\n accept,\n maxSizeMB,\n multiple,\n required,\n placeholder,\n disabled,\n className,\n value,\n error,\n onFileSelect,\n onFilesSelect,\n onReject,\n },\n ref,\n ) => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [pickedName, setPickedName] = React.useState<string | null>(null);\n const [dragging, setDragging] = React.useState(false);\n const errorId = `${name}-error`;\n const controlled = value !== undefined;\n const fileName = controlled ? (value?.name ?? null) : pickedName;\n\n const selectFiles = (files: File[]) => {\n const accepted = files.filter((file) => {\n if (!matchesAccept(file, accept)) {\n onReject?.(file, \"type\");\n return false;\n }\n if (maxSizeMB !== undefined && file.size > maxSizeMB * 1024 * 1024) {\n onReject?.(file, \"size\");\n return false;\n }\n return true;\n });\n // Every file was rejected: keep the current selection as it was.\n if (files.length > 0 && accepted.length === 0) return;\n\n const file = accepted[0] ?? null;\n setPickedName(\n accepted.length > 1\n ? `${accepted.length} files selected`\n : (file?.name ?? null),\n );\n onFileSelect?.(file);\n onFilesSelect?.(accepted);\n };\n const openPicker = () => {\n if (!disabled) inputRef.current?.click();\n };\n\n return (\n <div className={cn(\"grid gap-field-label-gap\", className)}>\n <FieldLabel htmlFor={name}>\n {label}\n {required && <span className=\"text-destructive\"> *</span>}\n </FieldLabel>\n <button\n type=\"button\"\n disabled={disabled}\n onClick={openPicker}\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? errorId : undefined}\n onDragEnter={(event) => {\n event.preventDefault();\n setDragging(true);\n }}\n onDragOver={(event) => {\n event.preventDefault();\n if (!disabled) setDragging(true);\n }}\n onDragLeave={() => setDragging(false)}\n onDrop={(event) => {\n event.preventDefault();\n setDragging(false);\n if (disabled) return;\n selectFiles(\n Array.from(event.dataTransfer.files).slice(\n 0,\n multiple ? undefined : 1,\n ),\n );\n }}\n className={cn(\n // min-w-0: as a grid item the button would otherwise refuse to\n // shrink below its text, overflowing narrow containers (phones).\n \"flex w-full min-w-0 cursor-pointer items-center gap-2 border border-input text-left text-sm text-muted-foreground transition-colors hover:border-input-hover hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none disabled:cursor-not-allowed disabled:opacity-60\",\n variant === \"dropzone\"\n ? \"min-h-36 flex-col justify-center rounded-card border-solid border-border px-6 py-6 text-center\"\n : \"min-h-11 rounded-control-lg px-4 py-2\",\n dragging && \"border-primary bg-primary-tint\",\n error && \"border-destructive\",\n )}\n >\n <Upload className=\"size-5 shrink-0 text-primary\" />\n <span\n className={cn(\n \"min-w-0\",\n // The dropzone has room to wrap; the compact field truncates.\n variant === \"dropzone\"\n ? \"max-w-full text-balance [overflow-wrap:anywhere]\"\n : \"truncate\",\n fileName && \"text-foreground\",\n )}\n >\n {fileName ?? placeholder ?? \"Drop a file here or click to upload\"}\n </span>\n </button>\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n id={name}\n type=\"file\"\n name={name}\n accept={accept}\n multiple={multiple}\n required={required}\n disabled={disabled}\n onChange={(event) => {\n selectFiles(Array.from(event.target.files ?? []));\n // Let the same file be picked again, e.g. after a rejection.\n event.target.value = \"\";\n }}\n className=\"sr-only\"\n />\n {error && (\n <p id={errorId} role=\"alert\" className=\"m-0 text-xs text-destructive\">\n {error}\n </p>\n )}\n </div>\n );\n },\n);\nFileUpload.displayName = \"FileUpload\";\n"],"names":[],"mappings":";;;;;;;AAmCA;AACA;AACE;AAAa;;;AAGb;;AAEG;;;AAIG;AACA;AACE;AACA;AAEV;;;AAwBI;AACA;AACA;AACA;AACA;AAEA;;;AAGM;AACA;;AAEF;AACE;AACA;;AAEF;AACF;;;;;AAKA;AAEI;;AAGJ;AACA;AACF;;AAEE;AAAe;AACjB;AAEA;;;AAeM;;AAGE;;AACF;;;AAKE;;;;;;;AAaE;;;AAWA;AACE;;AAUJ;;;AAEK;AAAS;AAChB;AASE;;AAEA;;AAWV;AAEF;;"}
|
|
1
|
+
{"version":3,"file":"file-upload.js","sources":["../../src/components/file-upload.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { Upload } from \"lucide-react\";\r\nimport { cn } from \"@/utils\";\r\nimport { FieldLabel } from \"./label\";\r\n\r\nexport type FileUploadVariant = \"compact\" | \"dropzone\";\r\nexport type FileRejectReason = \"type\" | \"size\";\r\nexport type FileUploadProps = {\r\n label: string;\r\n name: string;\r\n variant?: FileUploadVariant;\r\n /** Same format as the input's `accept`: extensions (\".pdf\") and/or MIME types (\"image/*\"). Also checked on drop. */\r\n accept?: string;\r\n /** Files larger than this are rejected through `onReject` instead of being selected. */\r\n maxSizeMB?: number;\r\n multiple?: boolean;\r\n required?: boolean;\r\n placeholder?: string;\r\n disabled?: boolean;\r\n className?: string;\r\n /**\r\n * The selected file, when the parent owns it. Pass `null` to clear the field.\r\n * Leave undefined to let the field remember the last pick itself.\r\n */\r\n value?: File | null;\r\n /** Shown under the field and marks it invalid. */\r\n error?: string | null;\r\n onFileSelect?: (file: File | null) => void;\r\n onFilesSelect?: (files: File[]) => void;\r\n /** Called with each file that fails `accept` or `maxSizeMB`. */\r\n onReject?: (file: File, reason: FileRejectReason) => void;\r\n};\r\n\r\n/** True when the file matches one of the `accept` entries (or there are none). */\r\nfunction matchesAccept(file: File, accept?: string) {\r\n if (!accept) return true;\r\n const name = file.name.toLowerCase();\r\n const type = file.type.toLowerCase();\r\n return accept\r\n .split(\",\")\r\n .map((entry) => entry.trim().toLowerCase())\r\n .filter(Boolean)\r\n .some((entry) =>\r\n entry.startsWith(\".\")\r\n ? name.endsWith(entry)\r\n : entry.endsWith(\"/*\")\r\n ? type.startsWith(entry.slice(0, -1))\r\n : type === entry,\r\n );\r\n}\r\n\r\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(\r\n (\r\n {\r\n label,\r\n name,\r\n variant = \"compact\",\r\n accept,\r\n maxSizeMB,\r\n multiple,\r\n required,\r\n placeholder,\r\n disabled,\r\n className,\r\n value,\r\n error,\r\n onFileSelect,\r\n onFilesSelect,\r\n onReject,\r\n },\r\n ref,\r\n ) => {\r\n const inputRef = React.useRef<HTMLInputElement>(null);\r\n const [pickedName, setPickedName] = React.useState<string | null>(null);\r\n const [dragging, setDragging] = React.useState(false);\r\n const errorId = `${name}-error`;\r\n const controlled = value !== undefined;\r\n const fileName = controlled ? (value?.name ?? null) : pickedName;\r\n\r\n const selectFiles = (files: File[]) => {\r\n const accepted = files.filter((file) => {\r\n if (!matchesAccept(file, accept)) {\r\n onReject?.(file, \"type\");\r\n return false;\r\n }\r\n if (maxSizeMB !== undefined && file.size > maxSizeMB * 1024 * 1024) {\r\n onReject?.(file, \"size\");\r\n return false;\r\n }\r\n return true;\r\n });\r\n // Every file was rejected: keep the current selection as it was.\r\n if (files.length > 0 && accepted.length === 0) return;\r\n\r\n const file = accepted[0] ?? null;\r\n setPickedName(\r\n accepted.length > 1\r\n ? `${accepted.length} files selected`\r\n : (file?.name ?? null),\r\n );\r\n onFileSelect?.(file);\r\n onFilesSelect?.(accepted);\r\n };\r\n const openPicker = () => {\r\n if (!disabled) inputRef.current?.click();\r\n };\r\n\r\n return (\r\n <div className={cn(\"grid gap-field-label-gap\", className)}>\r\n <FieldLabel htmlFor={name}>\r\n {label}\r\n {required && <span className=\"text-destructive\"> *</span>}\r\n </FieldLabel>\r\n <button\r\n type=\"button\"\r\n disabled={disabled}\r\n onClick={openPicker}\r\n aria-invalid={error ? true : undefined}\r\n aria-describedby={error ? errorId : undefined}\r\n onDragEnter={(event) => {\r\n event.preventDefault();\r\n setDragging(true);\r\n }}\r\n onDragOver={(event) => {\r\n event.preventDefault();\r\n if (!disabled) setDragging(true);\r\n }}\r\n onDragLeave={() => setDragging(false)}\r\n onDrop={(event) => {\r\n event.preventDefault();\r\n setDragging(false);\r\n if (disabled) return;\r\n selectFiles(\r\n Array.from(event.dataTransfer.files).slice(\r\n 0,\r\n multiple ? undefined : 1,\r\n ),\r\n );\r\n }}\r\n className={cn(\r\n // min-w-0: as a grid item the button would otherwise refuse to\r\n // shrink below its text, overflowing narrow containers (phones).\r\n \"flex w-full min-w-0 cursor-pointer items-center gap-2 border border-input text-left text-sm text-muted-foreground transition-colors hover:border-input-hover hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none disabled:cursor-not-allowed disabled:opacity-60\",\r\n variant === \"dropzone\"\r\n ? \"min-h-36 flex-col justify-center rounded-card border-solid border-border px-6 py-6 text-center\"\r\n : \"min-h-11 rounded-control-lg px-4 py-2\",\r\n dragging && \"border-primary bg-primary-tint\",\r\n error && \"border-destructive\",\r\n )}\r\n >\r\n <Upload className=\"size-5 shrink-0 text-primary\" />\r\n <span\r\n className={cn(\r\n \"min-w-0\",\r\n // The dropzone has room to wrap; the compact field truncates.\r\n variant === \"dropzone\"\r\n ? \"max-w-full text-balance [overflow-wrap:anywhere]\"\r\n : \"truncate\",\r\n fileName && \"text-foreground\",\r\n )}\r\n >\r\n {fileName ?? placeholder ?? \"Drop a file here or click to upload\"}\r\n </span>\r\n </button>\r\n <input\r\n ref={(node) => {\r\n inputRef.current = node;\r\n if (typeof ref === \"function\") ref(node);\r\n else if (ref) ref.current = node;\r\n }}\r\n id={name}\r\n type=\"file\"\r\n name={name}\r\n accept={accept}\r\n multiple={multiple}\r\n required={required}\r\n disabled={disabled}\r\n onChange={(event) => {\r\n selectFiles(Array.from(event.target.files ?? []));\r\n // Let the same file be picked again, e.g. after a rejection.\r\n event.target.value = \"\";\r\n }}\r\n className=\"sr-only\"\r\n />\r\n {error && (\r\n <p id={errorId} role=\"alert\" className=\"m-0 text-xs text-destructive\">\r\n {error}\r\n </p>\r\n )}\r\n </div>\r\n );\r\n },\r\n);\r\nFileUpload.displayName = \"FileUpload\";\r\n"],"names":[],"mappings":";;;;;;;AAmCA;AACA;AACE;AAAa;;;AAGb;;AAEG;;;AAIG;AACA;AACE;AACA;AAEV;;;AAwBI;AACA;AACA;AACA;AACA;AAEA;;;AAGM;AACA;;AAEF;AACE;AACA;;AAEF;AACF;;;;;AAKA;AAEI;;AAGJ;AACA;AACF;;AAEE;AAAe;AACjB;AAEA;;;AAeM;;AAGE;;AACF;;;AAKE;;;;;;;AAaE;;;AAWA;AACE;;AAUJ;;;AAEK;AAAS;AAChB;AASE;;AAEA;;AAWV;AAEF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-chip.js","sources":["../../src/components/filter-chip.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { cn } from '@/utils';\nimport { Button, type ButtonProps } from './button';\nimport type { ButtonScheme, ButtonSize } from './button';\n\nexport type FilterChipProps = Omit<\n ButtonProps,\n 'variant' | 'size' | 'scheme' | 'shape' | 'aria-pressed'\n> & {\n selected?: boolean;\n icon?: React.ReactNode;\n value?: string;\n size?: ButtonSize;\n scheme?: ButtonScheme;\n count?: number;\n};\n\nconst FilterChipGroupContext = React.createContext<{\n value: string | string[];\n multiple: boolean;\n onChange: (value: string) => void;\n} | null>(null);\n\n/** A toggleable pill for filtering; announces its state via aria-pressed. */\nconst FilterChip = React.forwardRef<HTMLButtonElement, FilterChipProps>(\n ({ selected, icon, children, className, value: chipValue, size = 'md', scheme, count, ...props }, ref) => {\n const group = React.useContext(FilterChipGroupContext);\n const isSelected = selected ?? (group && chipValue ? (group.multiple ? group.value.includes(chipValue) : group.value === chipValue) : false);\n return (\n <Button\n ref={ref}\n type=\"button\"\n variant=\"outline\"\n scheme={isSelected ? (scheme ?? 'secondary') : 'neutral'}\n size={size}\n shape=\"pill\"\n aria-pressed={isSelected}\n onClick={(event) => {\n props.onClick?.(event);\n if (!event.defaultPrevented && group && chipValue) group.onChange(chipValue);\n }}\n className={cn(\n 'group w-max max-w-full gap-2.5 font-[550] aria-pressed:font-semibold max-md:gap-2',\n !isSelected && '!border-border enabled:hover:!border-input',\n isSelected && scheme === 'neutral' && 'border-input-hover bg-accent text-accent-foreground hover:bg-accent',\n isSelected && scheme === 'primary' && 'border-primary bg-primary-selected text-primary hover:bg-primary-selected',\n className,\n )}\n {...props}\n >\n {icon}\n {children}\n {count !== undefined && <span className=\"inline-flex translate-y-px items-center text-[0.875em] leading-none tabular-nums opacity-75\">({count})</span>}\n </Button>\n );\n },\n);\nFilterChip.displayName = 'FilterChip';\n\nexport { FilterChip };\n\nexport function FilterChipGroup({ value, onChange, multiple = false, children, className }: {\n value: string | string[];\n onChange: (value: string | string[]) => void;\n multiple?: boolean;\n children: React.ReactNode;\n className?: string;\n}) {\n return <div className={cn('flex flex-wrap gap-2', className)}>\n <FilterChipGroupContext.Provider value={{ value, multiple, onChange: (next) => {\n if (!multiple) return onChange(next);\n const values = Array.isArray(value) ? value : [];\n onChange(values.includes(next) ? values.filter((item) => item !== next) : [...values, next]);\n } }}>{children}</FilterChipGroupContext.Provider>\n </div>;\n}\n"],"names":[],"mappings":";;;;;;AAoBA;AAMA;AACA;;AAGI;;AAWI;AACA;AAAmD;;AAgBzD;AAEF;AAIM;;AASA;AAAe;AACf;AACA;AACF;AAEJ;;"}
|
|
1
|
+
{"version":3,"file":"filter-chip.js","sources":["../../src/components/filter-chip.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { Button, type ButtonProps } from './button';\r\nimport type { ButtonScheme, ButtonSize } from './button';\r\n\r\nexport type FilterChipProps = Omit<\r\n ButtonProps,\r\n 'variant' | 'size' | 'scheme' | 'shape' | 'aria-pressed'\r\n> & {\r\n selected?: boolean;\r\n icon?: React.ReactNode;\r\n value?: string;\r\n size?: ButtonSize;\r\n scheme?: ButtonScheme;\r\n count?: number;\r\n};\r\n\r\nconst FilterChipGroupContext = React.createContext<{\r\n value: string | string[];\r\n multiple: boolean;\r\n onChange: (value: string) => void;\r\n} | null>(null);\r\n\r\n/** A toggleable pill for filtering; announces its state via aria-pressed. */\r\nconst FilterChip = React.forwardRef<HTMLButtonElement, FilterChipProps>(\r\n ({ selected, icon, children, className, value: chipValue, size = 'md', scheme, count, ...props }, ref) => {\r\n const group = React.useContext(FilterChipGroupContext);\r\n const isSelected = selected ?? (group && chipValue ? (group.multiple ? group.value.includes(chipValue) : group.value === chipValue) : false);\r\n return (\r\n <Button\r\n ref={ref}\r\n type=\"button\"\r\n variant=\"outline\"\r\n scheme={isSelected ? (scheme ?? 'secondary') : 'neutral'}\r\n size={size}\r\n shape=\"pill\"\r\n aria-pressed={isSelected}\r\n onClick={(event) => {\r\n props.onClick?.(event);\r\n if (!event.defaultPrevented && group && chipValue) group.onChange(chipValue);\r\n }}\r\n className={cn(\r\n 'group w-max max-w-full gap-2.5 font-[550] aria-pressed:font-semibold max-md:gap-2',\r\n !isSelected && '!border-border enabled:hover:!border-input',\r\n isSelected && scheme === 'neutral' && 'border-input-hover bg-accent text-accent-foreground hover:bg-accent',\r\n isSelected && scheme === 'primary' && 'border-primary bg-primary-selected text-primary hover:bg-primary-selected',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {icon}\r\n {children}\r\n {count !== undefined && <span className=\"inline-flex translate-y-px items-center text-[0.875em] leading-none tabular-nums opacity-75\">({count})</span>}\r\n </Button>\r\n );\r\n },\r\n);\r\nFilterChip.displayName = 'FilterChip';\r\n\r\nexport { FilterChip };\r\n\r\nexport function FilterChipGroup({ value, onChange, multiple = false, children, className }: {\r\n value: string | string[];\r\n onChange: (value: string | string[]) => void;\r\n multiple?: boolean;\r\n children: React.ReactNode;\r\n className?: string;\r\n}) {\r\n return <div className={cn('flex flex-wrap gap-2', className)}>\r\n <FilterChipGroupContext.Provider value={{ value, multiple, onChange: (next) => {\r\n if (!multiple) return onChange(next);\r\n const values = Array.isArray(value) ? value : [];\r\n onChange(values.includes(next) ? values.filter((item) => item !== next) : [...values, next]);\r\n } }}>{children}</FilterChipGroupContext.Provider>\r\n </div>;\r\n}\r\n"],"names":[],"mappings":";;;;;;AAoBA;AAMA;AACA;;AAGI;;AAWI;AACA;AAAmD;;AAgBzD;AAEF;AAIM;;AASA;AAAe;AACf;AACA;AACF;AAEJ;;"}
|
|
@@ -1,14 +1,69 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
/** What a `FormField` tells the control inside it. */
|
|
3
|
+
export interface FormFieldContextValue {
|
|
4
|
+
/** Id for the control; the label points at it. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Id of the label element, for controls labelled as a group. */
|
|
7
|
+
labelId: string;
|
|
8
|
+
/** Ids of the help text and error message, space-separated, when shown. */
|
|
9
|
+
describedBy?: string;
|
|
10
|
+
invalid: boolean;
|
|
11
|
+
required: boolean;
|
|
12
|
+
/** The label when it is plain text, for controls that need an accessible name elsewhere (e.g. a phone sheet). */
|
|
13
|
+
labelText?: string;
|
|
14
|
+
}
|
|
15
|
+
/** The surrounding field, or null outside a `FormField`. */
|
|
16
|
+
export declare function useFormField(): FormFieldContextValue | null;
|
|
17
|
+
type ControlAria = {
|
|
18
|
+
id?: string;
|
|
19
|
+
'aria-describedby'?: string;
|
|
20
|
+
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
21
|
+
'aria-required'?: React.AriaAttributes['aria-required'];
|
|
22
|
+
'aria-labelledby'?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Fills in the id and accessibility links from the surrounding `FormField`.
|
|
26
|
+
* Anything the caller passes explicitly wins. A `group` control (radio group,
|
|
27
|
+
* checkbox group) is named by the label instead of taking the id.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useFormFieldControl<P extends ControlAria>(props: P, kind?: 'control' | 'group'): P;
|
|
30
|
+
/**
|
|
31
|
+
* Hides the surrounding field from the controls inside it. For a component's
|
|
32
|
+
* own internal controls (a year picker inside a date popover, a search box in a
|
|
33
|
+
* phone sheet) so they don't take the field's id.
|
|
34
|
+
*/
|
|
35
|
+
export declare function FormFieldReset({ children }: {
|
|
36
|
+
children: React.ReactNode;
|
|
37
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
2
38
|
export interface FormFieldProps {
|
|
3
|
-
label?:
|
|
39
|
+
label?: React.ReactNode;
|
|
40
|
+
/** Shows the required mark and tells assistive tech. Defaults to false. */
|
|
4
41
|
required?: boolean;
|
|
42
|
+
/** Help shown from the question-mark icon beside the label. */
|
|
5
43
|
tooltip?: string;
|
|
6
|
-
/** Accepted for compatibility; not used by the Radix tooltip. */
|
|
7
|
-
tooltipId?: string;
|
|
8
44
|
/** Rendered to the right of the label, on the label's own row. */
|
|
9
45
|
labelAddon?: React.ReactNode;
|
|
46
|
+
/** Help text under the control. */
|
|
47
|
+
description?: React.ReactNode;
|
|
48
|
+
/** Error under the control; also marks the control invalid. */
|
|
49
|
+
error?: React.ReactNode;
|
|
50
|
+
/** Id for the control. Generated when omitted. */
|
|
51
|
+
id?: string;
|
|
52
|
+
/**
|
|
53
|
+
* The child is a group of controls (RadioGroup, CheckboxGroup): the label
|
|
54
|
+
* names the group instead of pointing at one control.
|
|
55
|
+
*/
|
|
56
|
+
group?: boolean;
|
|
10
57
|
className?: string;
|
|
11
58
|
children: React.ReactNode;
|
|
12
59
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The one labelled form field: label row (label, required mark, tooltip,
|
|
62
|
+
* addon), then the control, then help text and error. Put any plain control
|
|
63
|
+
* inside (Input, Textarea, SelectTrigger, Checkbox, Switch, Autocomplete,
|
|
64
|
+
* GroupableRadioDropdown, DatePicker, MonthPicker, TimeInput, or
|
|
65
|
+
* RadioGroup/CheckboxGroup/ChipSelect with `group`);
|
|
66
|
+
* it picks up the id and links automatically.
|
|
67
|
+
*/
|
|
68
|
+
export declare function FormField({ label, required, tooltip, labelAddon, description, error, id, group, className, children, }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
export {};
|
|
@@ -1,10 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
2
5
|
import { Label } from './label.js';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const FormFieldContext = React.createContext(null);
|
|
8
|
+
/** The surrounding field, or null outside a `FormField`. */
|
|
9
|
+
function useFormField() {
|
|
10
|
+
return React.useContext(FormFieldContext);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Fills in the id and accessibility links from the surrounding `FormField`.
|
|
14
|
+
* Anything the caller passes explicitly wins. A `group` control (radio group,
|
|
15
|
+
* checkbox group) is named by the label instead of taking the id.
|
|
16
|
+
*/
|
|
17
|
+
function useFormFieldControl(props, kind = 'control') {
|
|
18
|
+
const field = useFormField();
|
|
19
|
+
if (!field)
|
|
20
|
+
return props;
|
|
21
|
+
return {
|
|
22
|
+
...props,
|
|
23
|
+
...(kind === 'control'
|
|
24
|
+
? { id: props.id ?? field.id }
|
|
25
|
+
: { 'aria-labelledby': props['aria-labelledby'] ?? field.labelId }),
|
|
26
|
+
'aria-describedby': props['aria-describedby'] ?? field.describedBy,
|
|
27
|
+
'aria-invalid': props['aria-invalid'] ?? (field.invalid || undefined),
|
|
28
|
+
'aria-required': props['aria-required'] ?? (field.required || undefined),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hides the surrounding field from the controls inside it. For a component's
|
|
33
|
+
* own internal controls (a year picker inside a date popover, a search box in a
|
|
34
|
+
* phone sheet) so they don't take the field's id.
|
|
35
|
+
*/
|
|
36
|
+
function FormFieldReset({ children }) {
|
|
37
|
+
return jsx(FormFieldContext.Provider, { value: null, children: children });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The one labelled form field: label row (label, required mark, tooltip,
|
|
41
|
+
* addon), then the control, then help text and error. Put any plain control
|
|
42
|
+
* inside (Input, Textarea, SelectTrigger, Checkbox, Switch, Autocomplete,
|
|
43
|
+
* GroupableRadioDropdown, DatePicker, MonthPicker, TimeInput, or
|
|
44
|
+
* RadioGroup/CheckboxGroup/ChipSelect with `group`);
|
|
45
|
+
* it picks up the id and links automatically.
|
|
46
|
+
*/
|
|
47
|
+
function FormField({ label, required = false, tooltip, labelAddon, description, error, id, group = false, className, children, }) {
|
|
48
|
+
const generated = React.useId();
|
|
49
|
+
const controlId = id ?? generated;
|
|
50
|
+
const labelId = `${controlId}-label`;
|
|
51
|
+
const descriptionId = description ? `${controlId}-description` : undefined;
|
|
52
|
+
const errorId = error ? `${controlId}-error` : undefined;
|
|
53
|
+
const describedBy = [descriptionId, errorId].filter(Boolean).join(' ') || undefined;
|
|
54
|
+
const labelText = typeof label === 'string' ? label : undefined;
|
|
55
|
+
const value = React.useMemo(() => ({ id: controlId, labelId, describedBy, invalid: !!error, required, labelText }), [controlId, labelId, describedBy, error, required, labelText]);
|
|
56
|
+
return (jsxs("div", { className: cn('min-w-0', className), children: [label ? (jsx(Label, { label: label, required: required, tooltip: tooltip, labelAddon: labelAddon, labelProps: group ? { id: labelId } : { id: labelId, htmlFor: controlId } })) : null, jsx(FormFieldContext.Provider, { value: value, children: children }), description ? (jsx("p", { id: descriptionId, className: "mt-1.5 text-sm text-muted-foreground", children: description })) : null, error ? (jsx("p", { id: errorId, className: "mt-1.5 whitespace-pre-line text-sm text-destructive", children: error })) : null] }));
|
|
7
57
|
}
|
|
8
58
|
|
|
9
|
-
export { FormField };
|
|
59
|
+
export { FormField, FormFieldReset, useFormField, useFormFieldControl };
|
|
10
60
|
//# sourceMappingURL=form-field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-field.js","sources":["../../src/components/form-field.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"form-field.js","sources":["../../src/components/form-field.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { cn } from '@/utils';\nimport { Label } from './label';\n\n/** What a `FormField` tells the control inside it. */\nexport interface FormFieldContextValue {\n /** Id for the control; the label points at it. */\n id: string;\n /** Id of the label element, for controls labelled as a group. */\n labelId: string;\n /** Ids of the help text and error message, space-separated, when shown. */\n describedBy?: string;\n invalid: boolean;\n required: boolean;\n /** The label when it is plain text, for controls that need an accessible name elsewhere (e.g. a phone sheet). */\n labelText?: string;\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue | null>(null);\n\n/** The surrounding field, or null outside a `FormField`. */\nexport function useFormField() {\n return React.useContext(FormFieldContext);\n}\n\ntype ControlAria = {\n id?: string;\n 'aria-describedby'?: string;\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n 'aria-required'?: React.AriaAttributes['aria-required'];\n 'aria-labelledby'?: string;\n};\n\n/**\n * Fills in the id and accessibility links from the surrounding `FormField`.\n * Anything the caller passes explicitly wins. A `group` control (radio group,\n * checkbox group) is named by the label instead of taking the id.\n */\nexport function useFormFieldControl<P extends ControlAria>(props: P, kind: 'control' | 'group' = 'control'): P {\n const field = useFormField();\n if (!field) return props;\n return {\n ...props,\n ...(kind === 'control'\n ? { id: props.id ?? field.id }\n : { 'aria-labelledby': props['aria-labelledby'] ?? field.labelId }),\n 'aria-describedby': props['aria-describedby'] ?? field.describedBy,\n 'aria-invalid': props['aria-invalid'] ?? (field.invalid || undefined),\n 'aria-required': props['aria-required'] ?? (field.required || undefined),\n };\n}\n\n/**\n * Hides the surrounding field from the controls inside it. For a component's\n * own internal controls (a year picker inside a date popover, a search box in a\n * phone sheet) so they don't take the field's id.\n */\nexport function FormFieldReset({ children }: { children: React.ReactNode }) {\n return <FormFieldContext.Provider value={null}>{children}</FormFieldContext.Provider>;\n}\n\nexport interface FormFieldProps {\n label?: React.ReactNode;\n /** Shows the required mark and tells assistive tech. Defaults to false. */\n required?: boolean;\n /** Help shown from the question-mark icon beside the label. */\n tooltip?: string;\n /** Rendered to the right of the label, on the label's own row. */\n labelAddon?: React.ReactNode;\n /** Help text under the control. */\n description?: React.ReactNode;\n /** Error under the control; also marks the control invalid. */\n error?: React.ReactNode;\n /** Id for the control. Generated when omitted. */\n id?: string;\n /**\n * The child is a group of controls (RadioGroup, CheckboxGroup): the label\n * names the group instead of pointing at one control.\n */\n group?: boolean;\n className?: string;\n children: React.ReactNode;\n}\n\n/**\n * The one labelled form field: label row (label, required mark, tooltip,\n * addon), then the control, then help text and error. Put any plain control\n * inside (Input, Textarea, SelectTrigger, Checkbox, Switch, Autocomplete,\n * GroupableRadioDropdown, DatePicker, MonthPicker, TimeInput, or\n * RadioGroup/CheckboxGroup/ChipSelect with `group`);\n * it picks up the id and links automatically.\n */\nexport function FormField({\n label,\n required = false,\n tooltip,\n labelAddon,\n description,\n error,\n id,\n group = false,\n className,\n children,\n}: FormFieldProps) {\n const generated = React.useId();\n const controlId = id ?? generated;\n const labelId = `${controlId}-label`;\n const descriptionId = description ? `${controlId}-description` : undefined;\n const errorId = error ? `${controlId}-error` : undefined;\n const describedBy = [descriptionId, errorId].filter(Boolean).join(' ') || undefined;\n const labelText = typeof label === 'string' ? label : undefined;\n\n const value = React.useMemo<FormFieldContextValue>(\n () => ({ id: controlId, labelId, describedBy, invalid: !!error, required, labelText }),\n [controlId, labelId, describedBy, error, required, labelText],\n );\n\n return (\n <div className={cn('min-w-0', className)}>\n {label ? (\n <Label\n label={label}\n required={required}\n tooltip={tooltip}\n labelAddon={labelAddon}\n labelProps={group ? { id: labelId } : { id: labelId, htmlFor: controlId }}\n />\n ) : null}\n <FormFieldContext.Provider value={value}>{children}</FormFieldContext.Provider>\n {description ? (\n <p id={descriptionId} className=\"mt-1.5 text-sm text-muted-foreground\">\n {description}\n </p>\n ) : null}\n {error ? (\n <p id={errorId} className=\"mt-1.5 whitespace-pre-line text-sm text-destructive\">\n {error}\n </p>\n ) : null}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;AAqBA;AAEA;;AAEE;AACF;AAUA;;;;AAIG;;AAED;AACA;AAAY;;AAEV;;;AAGE;;AAEF;AACA;;AAEJ;AAEA;;;;AAIG;AACG;;AAEN;AAyBA;;;;;;;AAOG;AACG;AAYJ;AACA;AACA;AACA;AACA;AACA;AACA;;;AA+BF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hover-card.js","sources":["../../src/components/hover-card.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as HoverCardPrimitive from \"@radix-ui/react-hover-card\";\n\nimport { cn } from \"@/utils\";\n\nconst HoverCard = HoverCardPrimitive.Root;\n\nconst HoverCardTrigger = HoverCardPrimitive.Trigger;\n\nconst HoverCardContent = React.forwardRef<\n React.ElementRef<typeof HoverCardPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>\n>(({ className, align = \"center\", sideOffset = 4, ...props }, ref) => (\n <HoverCardPrimitive.Portal>\n <HoverCardPrimitive.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n className={cn(\n \"z-(--z-popover) w-64 max-w-[calc(100vw-2rem)] rounded-card border border-border bg-popover p-4 text-sm text-popover-foreground shadow-card outline-none data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\n className,\n )}\n {...props}\n />\n </HoverCardPrimitive.Portal>\n));\nHoverCardContent.displayName = HoverCardPrimitive.Content.displayName;\n\nexport { HoverCard, HoverCardTrigger, HoverCardContent };\n"],"names":[],"mappings":";;;;;;AAOA;AAEA;AAEA;AAiBA;;"}
|
|
1
|
+
{"version":3,"file":"hover-card.js","sources":["../../src/components/hover-card.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport * as HoverCardPrimitive from \"@radix-ui/react-hover-card\";\r\n\r\nimport { cn } from \"@/utils\";\r\n\r\nconst HoverCard = HoverCardPrimitive.Root;\r\n\r\nconst HoverCardTrigger = HoverCardPrimitive.Trigger;\r\n\r\nconst HoverCardContent = React.forwardRef<\r\n React.ElementRef<typeof HoverCardPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>\r\n>(({ className, align = \"center\", sideOffset = 4, ...props }, ref) => (\r\n <HoverCardPrimitive.Portal>\r\n <HoverCardPrimitive.Content\r\n ref={ref}\r\n align={align}\r\n sideOffset={sideOffset}\r\n className={cn(\r\n \"z-(--z-popover) w-64 max-w-[calc(100vw-2rem)] rounded-card border border-border bg-popover p-4 text-sm text-popover-foreground shadow-card outline-none data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n </HoverCardPrimitive.Portal>\r\n));\r\nHoverCardContent.displayName = HoverCardPrimitive.Content.displayName;\r\n\r\nexport { HoverCard, HoverCardTrigger, HoverCardContent };\r\n"],"names":[],"mappings":";;;;;;AAOA;AAEA;AAEA;AAiBA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-otp.js","sources":["../../src/components/input-otp.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { OTPInput, OTPInputContext } from \"input-otp\";\nimport { Dot } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\n\nexport type InputOTPSize = 'md' | 'lg' | 'xl';\n\nconst InputOTPSizeContext = React.createContext<InputOTPSize>('md');\n\nconst InputOTP = React.forwardRef<\n React.ElementRef<typeof OTPInput>,\n React.ComponentPropsWithoutRef<typeof OTPInput>\n>(({ className, containerClassName, ...props }, ref) => (\n <OTPInput\n ref={ref}\n containerClassName={cn(\n \"flex items-center gap-2 has-[:disabled]:opacity-50\",\n containerClassName,\n )}\n className={cn(\"disabled:cursor-not-allowed\", className)}\n {...props}\n />\n));\nInputOTP.displayName = \"InputOTP\";\n\nconst InputOTPGroup = React.forwardRef<\n React.ElementRef<\"div\">,\n React.ComponentPropsWithoutRef<\"div\"> & { size?: InputOTPSize }\n>(({ className, size = 'md', ...props }, ref) => (\n <InputOTPSizeContext.Provider value={size}>\n <div ref={ref} className={cn(\"flex items-center\", className)} {...props} />\n </InputOTPSizeContext.Provider>\n));\nInputOTPGroup.displayName = \"InputOTPGroup\";\n\nconst InputOTPSlot = React.forwardRef<\n React.ElementRef<\"div\">,\n React.ComponentPropsWithoutRef<\"div\"> & { index: number }\n>(({ index, className, ...props }, ref) => {\n const inputOTPContext = React.useContext(OTPInputContext);\n const size = React.useContext(InputOTPSizeContext);\n const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];\n\n return (\n <div\n ref={ref}\n className={cn(\n \"relative flex shrink-0 items-center justify-center border-y border-r border-input bg-background text-foreground transition-colors duration-interactive ease-out-strong motion-reduce:transition-none first:rounded-l-control-lg first:border-l last:rounded-r-control-lg\",\n isActive && \"z-10 bg-muted\",\n size === 'md' && 'h-form-control min-h-form-control max-h-form-control w-form-control text-base',\n size === 'lg' && 'h-16 min-h-16 max-h-16 w-16 text-2xl',\n size === 'xl' && 'h-20 min-h-20 max-h-20 w-20 text-3xl',\n className,\n )}\n {...props}\n >\n {char}\n {hasFakeCaret && (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center\">\n <div className=\"h-4 w-px animate-caret-blink bg-foreground duration-1000\" />\n </div>\n )}\n </div>\n );\n});\nInputOTPSlot.displayName = \"InputOTPSlot\";\n\nconst InputOTPSeparator = React.forwardRef<\n React.ElementRef<\"div\">,\n React.ComponentPropsWithoutRef<\"div\">\n>(({ ...props }, ref) => (\n <div ref={ref} role=\"separator\" {...props}>\n <Dot />\n </div>\n));\nInputOTPSeparator.displayName = \"InputOTPSeparator\";\n\nexport { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };\n"],"names":[],"mappings":";;;;;;;AAUA;AAEA;AAcA;AAEA;AAQA;AAEA;;;AAME;;AAuBF;AACA;AAEA;AAQA;;"}
|
|
1
|
+
{"version":3,"file":"input-otp.js","sources":["../../src/components/input-otp.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { OTPInput, OTPInputContext } from \"input-otp\";\r\nimport { Dot } from \"lucide-react\";\r\n\r\nimport { cn } from \"@/utils\";\r\n\r\nexport type InputOTPSize = 'md' | 'lg' | 'xl';\r\n\r\nconst InputOTPSizeContext = React.createContext<InputOTPSize>('md');\r\n\r\nconst InputOTP = React.forwardRef<\r\n React.ElementRef<typeof OTPInput>,\r\n React.ComponentPropsWithoutRef<typeof OTPInput>\r\n>(({ className, containerClassName, ...props }, ref) => (\r\n <OTPInput\r\n ref={ref}\r\n containerClassName={cn(\r\n \"flex items-center gap-2 has-[:disabled]:opacity-50\",\r\n containerClassName,\r\n )}\r\n className={cn(\"disabled:cursor-not-allowed\", className)}\r\n {...props}\r\n />\r\n));\r\nInputOTP.displayName = \"InputOTP\";\r\n\r\nconst InputOTPGroup = React.forwardRef<\r\n React.ElementRef<\"div\">,\r\n React.ComponentPropsWithoutRef<\"div\"> & { size?: InputOTPSize }\r\n>(({ className, size = 'md', ...props }, ref) => (\r\n <InputOTPSizeContext.Provider value={size}>\r\n <div ref={ref} className={cn(\"flex items-center\", className)} {...props} />\r\n </InputOTPSizeContext.Provider>\r\n));\r\nInputOTPGroup.displayName = \"InputOTPGroup\";\r\n\r\nconst InputOTPSlot = React.forwardRef<\r\n React.ElementRef<\"div\">,\r\n React.ComponentPropsWithoutRef<\"div\"> & { index: number }\r\n>(({ index, className, ...props }, ref) => {\r\n const inputOTPContext = React.useContext(OTPInputContext);\r\n const size = React.useContext(InputOTPSizeContext);\r\n const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];\r\n\r\n return (\r\n <div\r\n ref={ref}\r\n className={cn(\r\n \"relative flex shrink-0 items-center justify-center border-y border-r border-input bg-background text-foreground transition-colors duration-interactive ease-out-strong motion-reduce:transition-none first:rounded-l-control-lg first:border-l last:rounded-r-control-lg\",\r\n isActive && \"z-10 bg-muted\",\r\n size === 'md' && 'h-form-control min-h-form-control max-h-form-control w-form-control text-base',\r\n size === 'lg' && 'h-16 min-h-16 max-h-16 w-16 text-2xl',\r\n size === 'xl' && 'h-20 min-h-20 max-h-20 w-20 text-3xl',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {char}\r\n {hasFakeCaret && (\r\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center\">\r\n <div className=\"h-4 w-px animate-caret-blink bg-foreground duration-1000\" />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n});\r\nInputOTPSlot.displayName = \"InputOTPSlot\";\r\n\r\nconst InputOTPSeparator = React.forwardRef<\r\n React.ElementRef<\"div\">,\r\n React.ComponentPropsWithoutRef<\"div\">\r\n>(({ ...props }, ref) => (\r\n <div ref={ref} role=\"separator\" {...props}>\r\n <Dot />\r\n </div>\r\n));\r\nInputOTPSeparator.displayName = \"InputOTPSeparator\";\r\n\r\nexport { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };\r\n"],"names":[],"mappings":";;;;;;;AAUA;AAEA;AAcA;AAEA;AAQA;AAEA;;;AAME;;AAuBF;AACA;AAEA;AAQA;;"}
|
package/dist/components/input.js
CHANGED
|
@@ -4,10 +4,12 @@ import * as React from 'react';
|
|
|
4
4
|
import { EyeOff, Eye } from 'lucide-react';
|
|
5
5
|
import { cn } from '../utils.js';
|
|
6
6
|
import { useFieldChromeOwned, useFieldFocus, chain, fieldFocusOutlineClassName, fieldInteractionClassName } from '../hooks/use-field-focus.js';
|
|
7
|
+
import { useFormFieldControl } from './form-field.js';
|
|
7
8
|
|
|
8
9
|
const fieldClassName = 'bg-background pointer-events-auto relative z-10 box-border flex h-form-control min-h-form-control max-h-form-control w-full rounded-control-lg border border-input hover:border-input-hover px-[0.75em] py-0 text-base text-foreground ring-0';
|
|
9
10
|
const fieldDetailsClassName = 'file:text-foreground placeholder:text-muted-foreground/40 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50';
|
|
10
|
-
const Input = React.forwardRef(({ className, type, disabled, onPointerDown, onFocus, onBlur, ...
|
|
11
|
+
const Input = React.forwardRef(({ className, type, disabled, onPointerDown, onFocus, onBlur, ...ownProps }, ref) => {
|
|
12
|
+
const props = useFormFieldControl(ownProps);
|
|
11
13
|
const [passwordVisible, setPasswordVisible] = React.useState(false);
|
|
12
14
|
const chromeOwned = useFieldChromeOwned();
|
|
13
15
|
const { keyboardFocus, focusProps } = useFieldFocus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sources":["../../src/components/input.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Eye, EyeOff } from 'lucide-react';\n\nimport { cn } from '@/utils';\nimport {\n chain,\n fieldFocusOutlineClassName,\n fieldInteractionClassName,\n useFieldChromeOwned,\n useFieldFocus,\n} from '@/hooks/use-field-focus';\n\nconst fieldClassName =\n 'bg-background pointer-events-auto relative z-10 box-border flex h-form-control min-h-form-control max-h-form-control w-full rounded-control-lg border border-input hover:border-input-hover px-[0.75em] py-0 text-base text-foreground ring-0';\nconst fieldDetailsClassName =\n 'file:text-foreground placeholder:text-muted-foreground/40 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50';\n\nconst Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(\n ({ className, type, disabled, onPointerDown, onFocus, onBlur, ...
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../src/components/input.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\nimport { Eye, EyeOff } from 'lucide-react';\r\n\r\nimport { cn } from '@/utils';\r\nimport {\r\n chain,\r\n fieldFocusOutlineClassName,\r\n fieldInteractionClassName,\r\n useFieldChromeOwned,\r\n useFieldFocus,\r\n} from '@/hooks/use-field-focus';\r\nimport { useFormFieldControl } from './form-field';\r\n\r\nconst fieldClassName =\r\n 'bg-background pointer-events-auto relative z-10 box-border flex h-form-control min-h-form-control max-h-form-control w-full rounded-control-lg border border-input hover:border-input-hover px-[0.75em] py-0 text-base text-foreground ring-0';\r\nconst fieldDetailsClassName =\r\n 'file:text-foreground placeholder:text-muted-foreground/40 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50';\r\n\r\nconst Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(\r\n ({ className, type, disabled, onPointerDown, onFocus, onBlur, ...ownProps }, ref) => {\r\n const props = useFormFieldControl(ownProps);\r\n const [passwordVisible, setPasswordVisible] = React.useState(false);\r\n const chromeOwned = useFieldChromeOwned();\r\n const { keyboardFocus, focusProps } = useFieldFocus();\r\n const handlers = {\r\n onPointerDown: chain(onPointerDown, focusProps.onPointerDown),\r\n onFocus: chain(onFocus, focusProps.onFocus),\r\n onBlur: chain(onBlur, focusProps.onBlur),\r\n };\r\n const chrome = !chromeOwned && !disabled && cn(\r\n fieldInteractionClassName,\r\n keyboardFocus && fieldFocusOutlineClassName,\r\n );\r\n\r\n if (type === 'password') {\r\n const Icon = passwordVisible ? EyeOff : Eye;\r\n\r\n return (\r\n // The wrapper carries the lift and outline so the toggle moves with the field.\r\n <div className={cn('relative', chrome)}>\r\n <input\r\n type={passwordVisible ? 'text' : 'password'}\r\n className={cn(fieldClassName, 'pr-10', fieldDetailsClassName, className)}\r\n ref={ref}\r\n disabled={disabled}\r\n {...handlers}\r\n {...props}\r\n />\r\n <button\r\n type=\"button\"\r\n className=\"text-muted-foreground hover:text-foreground absolute inset-y-0 right-0 z-20 flex w-10 items-center justify-center disabled:cursor-not-allowed disabled:opacity-50\"\r\n onClick={() => setPasswordVisible((current) => !current)}\r\n disabled={disabled}\r\n aria-label={passwordVisible ? 'Hide password' : 'Show password'}\r\n aria-pressed={passwordVisible}\r\n >\r\n <Icon className=\"h-4 w-4\" aria-hidden=\"true\" />\r\n </button>\r\n </div>\r\n );\r\n }\r\n\r\n return (\r\n <input\r\n type={type}\r\n className={cn(fieldClassName, fieldDetailsClassName, chrome, className)}\r\n ref={ref}\r\n disabled={disabled}\r\n {...handlers}\r\n {...props}\r\n />\r\n );\r\n },\r\n);\r\nInput.displayName = 'Input';\r\n\r\nexport { Input };\r\n"],"names":[],"mappings":";;;;;;;;AAeA;AAEA;AAGA;AAEI;AACA;AACA;;AAEA;;;;;AAKA;AAKA;;;;;;AA4BA;AAUF;AAEF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sources":["../../src/components/label.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MessageCircleQuestion } from 'lucide-react';\n\nimport { cn } from '@/utils';\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from '@/components/tooltip';\n\nexport interface LabelProps {\n label: React.ReactNode;\n required?: boolean;\n tooltip?: string;\n /** Kept so existing callers still type-check; the Radix tooltip needs no id. */\n tooltipId?: string;\n labelAddon?: React.ReactNode;\n labelProps?: React.ComponentPropsWithRef<'label'>;\n className?: string;\n}\n\n/** Shared label typography with native label association and ref support. */\nexport const FieldLabel = React.forwardRef<HTMLLabelElement, React.ComponentPropsWithoutRef<'label'>>(\n ({ className, ...props }, ref) => (\n <label\n ref={ref}\n className={cn('text-field-label font-field-label text-[color:var(--color-field-label)]', className)}\n {...props}\n />\n ),\n);\nFieldLabel.displayName = 'FieldLabel';\n\n/** The label row shared by every form field: label, help tooltip, addon. */\nexport function Label({\n label,\n required,\n tooltip,\n labelAddon,\n labelProps,\n className,\n}: LabelProps) {\n const hasTooltip = !!tooltip?.trim();\n\n return (\n <div className={cn('mb-field-label-gap flex w-full justify-between gap-2 md:items-center', className)}>\n <div className=\"flex gap-2 md:items-center\">\n <FieldLabel {...labelProps}>\n {label} {required && <span className=\"text-destructive\">*</span>}\n </FieldLabel>\n {hasTooltip ? (\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n aria-label=\"More information\"\n className=\"hover:cursor-help\"\n >\n <MessageCircleQuestion className=\"text-primary h-3.5 w-3.5\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\" className=\"z-(--z-tooltip) max-w-[80vw]\">\n {tooltip}\n </TooltipContent>\n </Tooltip>\n ) : (\n // Reserves the icon's space so labels line up with or without help.\n <div aria-hidden=\"true\">\n <MessageCircleQuestion className={cn('invisible h-3.5 w-3.5')} />\n </div>\n )}\n </div>\n {labelAddon && <div>{labelAddon}</div>}\n </div>\n );\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAqBA;AACO,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACxC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,MAC3BA,eACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,yEAAyE,EAAE,SAAS,CAAC,EAAA,GAC/F,KAAK,EAAA,CACT,CACH;AAEH,UAAU,CAAC,WAAW,GAAG,YAAY;AAErC;AACM,SAAU,KAAK,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,GACE,EAAA;IACX,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE;AAEpC,IAAA,QACEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,EAAE,CAAC,sEAAsE,EAAE,SAAS,CAAC,aACnGA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,CACzCA,KAAC,UAAU,EAAA,EAAA,GAAK,UAAU,EAAA,QAAA,EAAA,CACvB,KAAK,EAAA,GAAA,EAAG,QAAQ,IAAID,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAA,GAAA,EAAA,CAAS,CAAA,EAAA,CACrD,EACZ,UAAU,IACTC,IAAA,CAAC,OAAO,EAAA,EAAA,QAAA,EAAA,CACND,GAAA,CAAC,cAAc,EAAA,EAAC,OAAO,EAAA,IAAA,EAAA,QAAA,EACrBA,GAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,gBACF,kBAAkB,EAC7B,SAAS,EAAC,mBAAmB,EAAA,QAAA,EAE7BA,GAAA,CAAC,qBAAqB,EAAA,EAAC,SAAS,EAAC,0BAA0B,EAAA,CAAG,EAAA,CACvD,EAAA,CACM,EACjBA,GAAA,CAAC,cAAc,IAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,8BAA8B,YACnE,OAAO,EAAA,CACO,IACT;;oBAGVA,GAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EAAiB,MAAM,YACrBA,GAAA,CAAC,qBAAqB,IAAC,SAAS,EAAE,EAAE,CAAC,uBAAuB,CAAC,GAAI,EAAA,CAC7D,CACP,CAAA,EAAA,CACG,EACL,UAAU,IAAIA,uBAAM,UAAU,EAAA,CAAO,CAAA,EAAA,CAClC;AAEV;;;;"}
|
|
1
|
+
{"version":3,"file":"label.js","sources":["../../src/components/label.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport { MessageCircleQuestion } from 'lucide-react';\r\n\r\nimport { cn } from '@/utils';\r\nimport {\r\n Tooltip,\r\n TooltipContent,\r\n TooltipTrigger,\r\n} from '@/components/tooltip';\r\n\r\nexport interface LabelProps {\r\n label: React.ReactNode;\r\n required?: boolean;\r\n tooltip?: string;\r\n /** Kept so existing callers still type-check; the Radix tooltip needs no id. */\r\n tooltipId?: string;\r\n labelAddon?: React.ReactNode;\r\n labelProps?: React.ComponentPropsWithRef<'label'>;\r\n className?: string;\r\n}\r\n\r\n/** Shared label typography with native label association and ref support. */\r\nexport const FieldLabel = React.forwardRef<HTMLLabelElement, React.ComponentPropsWithoutRef<'label'>>(\r\n ({ className, ...props }, ref) => (\r\n <label\r\n ref={ref}\r\n className={cn('text-field-label font-field-label text-[color:var(--color-field-label)]', className)}\r\n {...props}\r\n />\r\n ),\r\n);\r\nFieldLabel.displayName = 'FieldLabel';\r\n\r\n/** The label row shared by every form field: label, help tooltip, addon. */\r\nexport function Label({\r\n label,\r\n required,\r\n tooltip,\r\n labelAddon,\r\n labelProps,\r\n className,\r\n}: LabelProps) {\r\n const hasTooltip = !!tooltip?.trim();\r\n\r\n return (\r\n <div className={cn('mb-field-label-gap flex w-full justify-between gap-2 md:items-center', className)}>\r\n <div className=\"flex gap-2 md:items-center\">\r\n <FieldLabel {...labelProps}>\r\n {label} {required && <span className=\"text-destructive\">*</span>}\r\n </FieldLabel>\r\n {hasTooltip ? (\r\n <Tooltip>\r\n <TooltipTrigger asChild>\r\n <button\r\n type=\"button\"\r\n aria-label=\"More information\"\r\n className=\"hover:cursor-help\"\r\n >\r\n <MessageCircleQuestion className=\"text-primary h-3.5 w-3.5\" />\r\n </button>\r\n </TooltipTrigger>\r\n <TooltipContent side=\"bottom\" className=\"z-(--z-tooltip) max-w-[80vw]\">\r\n {tooltip}\r\n </TooltipContent>\r\n </Tooltip>\r\n ) : (\r\n // Reserves the icon's space so labels line up with or without help.\r\n <div aria-hidden=\"true\">\r\n <MessageCircleQuestion className={cn('invisible h-3.5 w-3.5')} />\r\n </div>\r\n )}\r\n </div>\r\n {labelAddon && <div>{labelAddon}</div>}\r\n </div>\r\n );\r\n}\r\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAqBA;AACO,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACxC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,MAC3BA,eACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,yEAAyE,EAAE,SAAS,CAAC,EAAA,GAC/F,KAAK,EAAA,CACT,CACH;AAEH,UAAU,CAAC,WAAW,GAAG,YAAY;AAErC;AACM,SAAU,KAAK,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,GACE,EAAA;IACX,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE;AAEpC,IAAA,QACEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,EAAE,CAAC,sEAAsE,EAAE,SAAS,CAAC,aACnGA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,CACzCA,KAAC,UAAU,EAAA,EAAA,GAAK,UAAU,EAAA,QAAA,EAAA,CACvB,KAAK,EAAA,GAAA,EAAG,QAAQ,IAAID,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAA,GAAA,EAAA,CAAS,CAAA,EAAA,CACrD,EACZ,UAAU,IACTC,IAAA,CAAC,OAAO,EAAA,EAAA,QAAA,EAAA,CACND,GAAA,CAAC,cAAc,EAAA,EAAC,OAAO,EAAA,IAAA,EAAA,QAAA,EACrBA,GAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,gBACF,kBAAkB,EAC7B,SAAS,EAAC,mBAAmB,EAAA,QAAA,EAE7BA,GAAA,CAAC,qBAAqB,EAAA,EAAC,SAAS,EAAC,0BAA0B,EAAA,CAAG,EAAA,CACvD,EAAA,CACM,EACjBA,GAAA,CAAC,cAAc,IAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,8BAA8B,YACnE,OAAO,EAAA,CACO,IACT;;oBAGVA,GAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EAAiB,MAAM,YACrBA,GAAA,CAAC,qBAAqB,IAAC,SAAS,EAAE,EAAE,CAAC,uBAAuB,CAAC,GAAI,EAAA,CAC7D,CACP,CAAA,EAAA,CACG,EACL,UAAU,IAAIA,uBAAM,UAAU,EAAA,CAAO,CAAA,EAAA,CAClC;AAEV;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sources":["../../src/components/loader.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from 'react';\nimport { cn } from '@/utils';\n\nconst sizes = { sm: 'size-4', md: 'size-6', lg: 'size-10' } as const;\n\nexport type SpinnerProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {\n size?: keyof typeof sizes;\n label?: string;\n decorative?: boolean;\n};\n\nexport function Spinner({ size = 'sm', label = 'Loading', decorative = false, className, ...props }: SpinnerProps) {\n return <span {...props} role={decorative ? undefined : 'status'} aria-hidden={decorative || undefined} className={cn('inline-flex shrink-0 items-center justify-center text-current', className)}>\n <span aria-hidden=\"true\" className={cn('block shrink-0 rounded-full border-2 border-current border-r-transparent motion-safe:animate-spin', sizes[size])} />\n {!decorative && <span className=\"sr-only\">{label}</span>}\n </span>;\n}\n\nexport type LoaderProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n children?: ReactNode;\n label?: string;\n size?: SpinnerProps['size'];\n};\n\n/** Centered loading content; the parent owns height and padding. */\nexport function Loader({ children, label = 'Loading', size = 'lg', className, ...props }: LoaderProps) {\n return <div {...props} role=\"status\" className={cn('flex w-full flex-col items-center justify-center gap-4 text-center text-primary', className)}>\n <Spinner size={size} decorative />\n {children ? <div className=\"text-sm text-muted-foreground\">{children}</div> : <span className=\"sr-only\">{label}</span>}\n </div>;\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAGA,MAAM,KAAK,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAW;AAQ9D,SAAU,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,GAAG,SAAS,EAAE,UAAU,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAgB,EAAA;IAC/G,OAAOA,IAAA,CAAA,MAAA,EAAA,EAAA,GAAU,KAAK,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,EAAA,aAAA,EAAe,UAAU,IAAI,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,+DAA+D,EAAE,SAAS,CAAC,aAC9LC,GAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAkB,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,mGAAmG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAI,EAC3J,CAAC,UAAU,IAAIA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,SAAS,EAAA,QAAA,EAAE,KAAK,EAAA,CAAQ,CAAA,EAAA,CACnD;AACT;AAQA;SACgB,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,GAAG,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,EAAe,EAAA;IACnG,OAAOD,IAAA,CAAA,KAAA,EAAA,EAAA,GAAS,KAAK,EAAE,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,EAAE,CAAC,iFAAiF,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAC9IC,GAAA,CAAC,OAAO,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,UAAU,SAAG,EACjC,QAAQ,GAAGA,aAAK,SAAS,EAAC,+BAA+B,EAAA,QAAA,EAAE,QAAQ,EAAA,CAAO,GAAGA,cAAM,SAAS,EAAC,SAAS,EAAA,QAAA,EAAE,KAAK,EAAA,CAAQ,CAAA,EAAA,CAClH;AACR;;;;"}
|
|
1
|
+
{"version":3,"file":"loader.js","sources":["../../src/components/loader.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from 'react';\r\nimport { cn } from '@/utils';\r\n\r\nconst sizes = { sm: 'size-4', md: 'size-6', lg: 'size-10' } as const;\r\n\r\nexport type SpinnerProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {\r\n size?: keyof typeof sizes;\r\n label?: string;\r\n decorative?: boolean;\r\n};\r\n\r\nexport function Spinner({ size = 'sm', label = 'Loading', decorative = false, className, ...props }: SpinnerProps) {\r\n return <span {...props} role={decorative ? undefined : 'status'} aria-hidden={decorative || undefined} className={cn('inline-flex shrink-0 items-center justify-center text-current', className)}>\r\n <span aria-hidden=\"true\" className={cn('block shrink-0 rounded-full border-2 border-current border-r-transparent motion-safe:animate-spin', sizes[size])} />\r\n {!decorative && <span className=\"sr-only\">{label}</span>}\r\n </span>;\r\n}\r\n\r\nexport type LoaderProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\r\n children?: ReactNode;\r\n label?: string;\r\n size?: SpinnerProps['size'];\r\n};\r\n\r\n/** Centered loading content; the parent owns height and padding. */\r\nexport function Loader({ children, label = 'Loading', size = 'lg', className, ...props }: LoaderProps) {\r\n return <div {...props} role=\"status\" className={cn('flex w-full flex-col items-center justify-center gap-4 text-center text-primary', className)}>\r\n <Spinner size={size} decorative />\r\n {children ? <div className=\"text-sm text-muted-foreground\">{children}</div> : <span className=\"sr-only\">{label}</span>}\r\n </div>;\r\n}\r\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAGA,MAAM,KAAK,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAW;AAQ9D,SAAU,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,GAAG,SAAS,EAAE,UAAU,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAgB,EAAA;IAC/G,OAAOA,IAAA,CAAA,MAAA,EAAA,EAAA,GAAU,KAAK,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,EAAA,aAAA,EAAe,UAAU,IAAI,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,+DAA+D,EAAE,SAAS,CAAC,aAC9LC,GAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAkB,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,mGAAmG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAI,EAC3J,CAAC,UAAU,IAAIA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,SAAS,EAAA,QAAA,EAAE,KAAK,EAAA,CAAQ,CAAA,EAAA,CACnD;AACT;AAQA;SACgB,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,GAAG,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,EAAe,EAAA;IACnG,OAAOD,IAAA,CAAA,KAAA,EAAA,EAAA,GAAS,KAAK,EAAE,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,EAAE,CAAC,iFAAiF,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAC9IC,GAAA,CAAC,OAAO,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,UAAU,SAAG,EACjC,QAAQ,GAAGA,aAAK,SAAS,EAAC,+BAA+B,EAAA,QAAA,EAAE,QAAQ,EAAA,CAAO,GAAGA,cAAM,SAAS,EAAC,SAAS,EAAA,QAAA,EAAE,KAAK,EAAA,CAAQ,CAAA,EAAA,CAClH;AACR;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magnetic-button.js","sources":["../../src/components/magnetic-button.tsx"],"sourcesContent":["'use client';\n\nimport { useReducedMotion, motion } from \"framer-motion\";\nimport { useRef, useState } from \"react\";\n\nexport default function MagneticButton({\n children,\n className = \"\",\n asChild = false,\n}: {\n children: React.ReactNode;\n className?: string;\n asChild?: boolean;\n}) {\n const prefersReduce = useReducedMotion();\n const ref = useRef<HTMLDivElement>(null);\n const [tx, setTx] = useState(0);\n const [ty, setTy] = useState(0);\n\n const max = 6; // px\n function onMove(e: React.MouseEvent) {\n if (prefersReduce) return;\n const el = ref.current;\n if (!el) return;\n const r = el.getBoundingClientRect();\n const x = (e.clientX - r.left) / r.width - 0.5;\n const y = (e.clientY - r.top) / r.height - 0.5;\n setTx(x * max * 2);\n setTy(y * max * 2);\n }\n function onLeave() {\n setTx(0);\n setTy(0);\n }\n\n return (\n <motion.div\n ref={ref}\n onMouseMove={onMove}\n onMouseLeave={onLeave}\n animate={{ x: tx, y: ty, rotate: tx * 0.3 }}\n transition={{ type: \"spring\", stiffness: 200, damping: 15, mass: 0.3 }}\n className={className}\n >\n {children}\n </motion.div>\n );\n}\n"],"names":[],"mappings":";;;;;AAKc;AASZ;AACA;;;AAIA;;AAEE;;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;;AAEF;;;;AAKA;AAYF;;"}
|
|
1
|
+
{"version":3,"file":"magnetic-button.js","sources":["../../src/components/magnetic-button.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useReducedMotion, motion } from \"framer-motion\";\r\nimport { useRef, useState } from \"react\";\r\n\r\nexport default function MagneticButton({\r\n children,\r\n className = \"\",\r\n asChild = false,\r\n}: {\r\n children: React.ReactNode;\r\n className?: string;\r\n asChild?: boolean;\r\n}) {\r\n const prefersReduce = useReducedMotion();\r\n const ref = useRef<HTMLDivElement>(null);\r\n const [tx, setTx] = useState(0);\r\n const [ty, setTy] = useState(0);\r\n\r\n const max = 6; // px\r\n function onMove(e: React.MouseEvent) {\r\n if (prefersReduce) return;\r\n const el = ref.current;\r\n if (!el) return;\r\n const r = el.getBoundingClientRect();\r\n const x = (e.clientX - r.left) / r.width - 0.5;\r\n const y = (e.clientY - r.top) / r.height - 0.5;\r\n setTx(x * max * 2);\r\n setTy(y * max * 2);\r\n }\r\n function onLeave() {\r\n setTx(0);\r\n setTy(0);\r\n }\r\n\r\n return (\r\n <motion.div\r\n ref={ref}\r\n onMouseMove={onMove}\r\n onMouseLeave={onLeave}\r\n animate={{ x: tx, y: ty, rotate: tx * 0.3 }}\r\n transition={{ type: \"spring\", stiffness: 200, damping: 15, mass: 0.3 }}\r\n className={className}\r\n >\r\n {children}\r\n </motion.div>\r\n );\r\n}\r\n"],"names":[],"mappings":";;;;;AAKc;AASZ;AACA;;;AAIA;;AAEE;;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;;AAEF;;;;AAKA;AAYF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sources":["../../src/components/messages.tsx"],"sourcesContent":["import { Card } from \"./card\";\n\nexport const Message = ({\n message,\n them,\n self,\n prevSelf,\n}: {\n message: string;\n them: string;\n self: boolean;\n prevSelf: boolean;\n}) => {\n return !self ? (\n <div className=\"flex flex-col max-w-[80%]\">\n {prevSelf && (\n <div className=\"text-xs pl-1 pb-1 text-muted-foreground\">{them}</div>\n )}\n <Card className=\"py-2 px-4 break-all text-sm w-fit\">\n {message}\n </Card>\n </div>\n ) : (\n <div className=\"flex flex-col items-end max-w-[80%] ml-auto\">\n {!prevSelf && (\n <div className=\"text-right text-xs pr-1 pb-1 text-muted-foreground\">You</div>\n )}\n <Card className=\"py-2 px-4 text-sm break-all bg-primary text-white text-wrap\">\n {message}\n </Card>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAEO,MAAM,OAAO,GAAG,CAAC,EACtB,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,QAAQ,GAMT,KAAI;AACH,IAAA,OAAO,CAAC,IAAI,IACVA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,2BAA2B,EAAA,QAAA,EAAA,CACvC,QAAQ,KACPC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,yCAAyC,EAAA,QAAA,EAAE,IAAI,EAAA,CAAO,CACtE,EACDA,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,mCAAmC,YAChD,OAAO,EAAA,CACH,CAAA,EAAA,CACH,KAEND,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,6CAA6C,EAAA,QAAA,EAAA,CACzD,CAAC,QAAQ,KACRC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,oDAAoD,EAAA,QAAA,EAAA,KAAA,EAAA,CAAU,CAC9E,EACDA,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,6DAA6D,EAAA,QAAA,EAC1E,OAAO,EAAA,CACH,CAAA,EAAA,CACH,CACP;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"messages.js","sources":["../../src/components/messages.tsx"],"sourcesContent":["import { Card } from \"./card\";\r\n\r\nexport const Message = ({\r\n message,\r\n them,\r\n self,\r\n prevSelf,\r\n}: {\r\n message: string;\r\n them: string;\r\n self: boolean;\r\n prevSelf: boolean;\r\n}) => {\r\n return !self ? (\r\n <div className=\"flex flex-col max-w-[80%]\">\r\n {prevSelf && (\r\n <div className=\"text-xs pl-1 pb-1 text-muted-foreground\">{them}</div>\r\n )}\r\n <Card className=\"py-2 px-4 break-all text-sm w-fit\">\r\n {message}\r\n </Card>\r\n </div>\r\n ) : (\r\n <div className=\"flex flex-col items-end max-w-[80%] ml-auto\">\r\n {!prevSelf && (\r\n <div className=\"text-right text-xs pr-1 pb-1 text-muted-foreground\">You</div>\r\n )}\r\n <Card className=\"py-2 px-4 text-sm break-all bg-primary text-white text-wrap\">\r\n {message}\r\n </Card>\r\n </div>\r\n );\r\n};\r\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAEO,MAAM,OAAO,GAAG,CAAC,EACtB,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,QAAQ,GAMT,KAAI;AACH,IAAA,OAAO,CAAC,IAAI,IACVA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,2BAA2B,EAAA,QAAA,EAAA,CACvC,QAAQ,KACPC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,yCAAyC,EAAA,QAAA,EAAE,IAAI,EAAA,CAAO,CACtE,EACDA,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,mCAAmC,YAChD,OAAO,EAAA,CACH,CAAA,EAAA,CACH,KAEND,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,6CAA6C,EAAA,QAAA,EAAA,CACzD,CAAC,QAAQ,KACRC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,oDAAoD,EAAA,QAAA,EAAA,KAAA,EAAA,CAAU,CAC9E,EACDA,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,6DAA6D,EAAA,QAAA,EAC1E,OAAO,EAAA,CACH,CAAA,EAAA,CACH,CACP;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile-sheet-portal.js","sources":["../../src/components/mobile-sheet-portal.tsx"],"sourcesContent":["\"use client\";\n\nimport { createPortal } from \"react-dom\";\n\n/**\n * Renders a mobile selection sheet at the end of the document so accordions\n * and animated panels can't clip it. Interactions inside are kept from reaching\n * the document's outside-click handlers, which would otherwise close it.\n */\nexport function MobileSheetPortal({\n enabled,\n children,\n}: {\n enabled: boolean;\n children: React.ReactNode;\n}) {\n if (!enabled) return <>{children}</>;\n\n return createPortal(\n <div\n onClick={(event) => event.stopPropagation()}\n onTouchStart={(event) => event.stopPropagation()}\n >\n {children}\n </div>,\n document.body,\n );\n}\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;;AAQD;;AAEA;AASF;;"}
|
|
1
|
+
{"version":3,"file":"mobile-sheet-portal.js","sources":["../../src/components/mobile-sheet-portal.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport { createPortal } from \"react-dom\";\r\n\r\n/**\r\n * Renders a mobile selection sheet at the end of the document so accordions\r\n * and animated panels can't clip it. Interactions inside are kept from reaching\r\n * the document's outside-click handlers, which would otherwise close it.\r\n */\r\nexport function MobileSheetPortal({\r\n enabled,\r\n children,\r\n}: {\r\n enabled: boolean;\r\n children: React.ReactNode;\r\n}) {\r\n if (!enabled) return <>{children}</>;\r\n\r\n return createPortal(\r\n <div\r\n onClick={(event) => event.stopPropagation()}\r\n onTouchStart={(event) => event.stopPropagation()}\r\n >\r\n {children}\r\n </div>,\r\n document.body,\r\n );\r\n}\r\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;;AAQD;;AAEA;AASF;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/** Props the trigger takes from the caller or the surrounding FormField. */
|
|
3
|
+
type TriggerProps = Pick<React.ButtonHTMLAttributes<HTMLButtonElement>, 'id' | 'aria-label' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-required' | 'disabled'>;
|
|
4
|
+
/** A month picker. Unlabelled: put it in a `FormField` for a label. */
|
|
5
|
+
export interface MonthPickerProps extends TriggerProps {
|
|
4
6
|
/** ms since epoch; will be normalized to the first day of the month */
|
|
5
7
|
date?: number;
|
|
6
8
|
/** setter receives ms since epoch (first day of month at local midnight) or undefined when cleared */
|
|
@@ -10,9 +12,6 @@ export interface FormMonthPickerProps extends React.InputHTMLAttributes<HTMLInpu
|
|
|
10
12
|
align?: 'start' | 'center' | 'end';
|
|
11
13
|
sideOffset?: number;
|
|
12
14
|
contentClassName?: string;
|
|
13
|
-
tooltip?: string;
|
|
14
|
-
tooltipId?: string;
|
|
15
|
-
required?: boolean;
|
|
16
15
|
/** Placeholder text when no month selected */
|
|
17
16
|
placeholder?: string;
|
|
18
17
|
/** Format the button text */
|
|
@@ -23,4 +22,5 @@ export interface FormMonthPickerProps extends React.InputHTMLAttributes<HTMLInpu
|
|
|
23
22
|
/** Close popover automatically on select (default true) */
|
|
24
23
|
autoClose?: boolean;
|
|
25
24
|
}
|
|
26
|
-
export declare const
|
|
25
|
+
export declare const MonthPicker: ({ date, setter, className, side, align, sideOffset, contentClassName, placeholder, format, fromYear, toYear, autoClose, ...ownTriggerProps }: MonthPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|