@betterinternship/components 3.2.13 → 3.3.3
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/dist/components/autocomplete.js +2 -2
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/context-menu.js +2 -2
- package/dist/components/context-menu.js.map +1 -1
- package/dist/components/dialog.js +3 -3
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dropdown-menu.js +5 -8
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/dropdown.js +2 -2
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/hover-card.js +1 -1
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/option-list.js +2 -2
- package/dist/components/option-list.js.map +1 -1
- package/dist/components/popover.js +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/select.js +2 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.js +2 -2
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/package.json +1 -1
- package/theme.css +33 -5
|
@@ -174,7 +174,7 @@ function AutocompleteBase({ required, options, value = [], setter, placeholder,
|
|
|
174
174
|
const sheetProps = useMobileSheet ? {
|
|
175
175
|
side: 'bottom',
|
|
176
176
|
showCloseButton: false,
|
|
177
|
-
overlayClassName: 'z-
|
|
177
|
+
overlayClassName: 'z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]',
|
|
178
178
|
'aria-describedby': undefined,
|
|
179
179
|
onOpenAutoFocus: (event) => { event.preventDefault(); sheetCloseRef.current?.focus(); },
|
|
180
180
|
onCloseAutoFocus: (event) => { event.preventDefault(); inputRef.current?.focus(); },
|
|
@@ -258,7 +258,7 @@ function AutocompleteBase({ required, options, value = [], setter, placeholder,
|
|
|
258
258
|
setQuery('');
|
|
259
259
|
setIsOpen(false);
|
|
260
260
|
} }, children: jsxs(OptionsSurface, { ...sheetProps, ref: useMobileSheet ? sheetRef : undefined, role: useMobileSheet ? "dialog" : undefined, "aria-modal": useMobileSheet ? true : undefined, "aria-label": useMobileSheet ? (typeof label === "string" ? label : "Choose options") : undefined, className: cn("bg-background text-sm shadow-card border border-border", useMobileSheet
|
|
261
|
-
? "fixed left-0 right-0 z-
|
|
261
|
+
? "fixed left-0 right-0 z-(--z-popover) flex flex-col gap-0 overflow-hidden rounded-t-control-lg border-b-0 p-0"
|
|
262
262
|
: "absolute left-0 right-0 z-50 mt-1 max-h-[400px] overflow-y-auto overscroll-contain rounded-control-lg"), style: useMobileSheet
|
|
263
263
|
? {
|
|
264
264
|
bottom: sheetViewport?.bottom ?? 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.js","sources":["../../src/components/autocomplete.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { Input } from \"./input\";\nimport { useDetectClickOutside } from '@/hooks/use-detect-click-outside';\nimport { cn } from \"@/utils\";\nimport { ChevronDown, PlusCircleIcon, Search, X } from \"lucide-react\";\nimport { Label } from \"./label\";\nimport { Button } from \"./button\";\nimport { CheckboxVisual } from \"./checkbox\";\nimport { Sheet, SheetContent, SheetTitle } from \"./sheet\";\nimport { useMobile } from \"@/hooks/use-mobile\";\nimport { useMobileSheetViewport } from \"@/hooks/use-mobile-sheet-viewport\";\nimport {\n FieldChromeContext,\n fieldFocusOutlineClassName,\n fieldInteractionClassName,\n useFieldFocus,\n} from \"@/hooks/use-field-focus\";\n\nexport interface IAutocompleteOption<ID extends number | string> {\n id: ID;\n name: string;\n keywords?: string[];\n /** Child options; in multiple mode the group can select all its children. */\n children?: IAutocompleteOption<ID>[];\n}\n\ntype MobileDropdownMode = \"sheet\" | \"inline\";\ntype InputIcons = boolean | \"search\" | \"dropdown\";\n\n/* -------------------------------------------------------\n * Base component (array-based). Single uses length 0..1.\n * -----------------------------------------------------*/\nfunction AutocompleteBase<ID extends number | string>({\n required,\n options,\n value = [],\n setter,\n placeholder,\n className,\n multiple = true,\n label,\n labelAddon,\n allowCustomValue = false,\n preserveOptionOrder = false,\n emptyText = \"No matching options\",\n mobileDropdownMode = \"sheet\",\n inputIcons = false,\n ...props\n}: {\n required?: boolean;\n options: IAutocompleteOption<ID>[];\n value?: ID[]; // single => 0..1 items, multi => any length\n setter: (next: ID[]) => void; // set the whole selection\n placeholder?: string;\n className?: string;\n multiple?: boolean;\n label?: React.ReactNode;\n labelAddon?: React.ReactNode;\n allowCustomValue?: boolean;\n preserveOptionOrder?: boolean;\n emptyText?: string;\n mobileDropdownMode?: MobileDropdownMode;\n inputIcons?: InputIcons;\n}) {\n const [query, setQuery] = useState(\"\");\n const [isOpen, setIsOpen] = useState(false);\n const [dropdownMaxHeight, setDropdownMaxHeight] = useState<number>();\n const isMobile = useMobile();\n const clickOutsideRef = useDetectClickOutside({\n onTriggered: () => {\n // Radix owns outside dismissal for the portalled modal sheet.\n if (isMobile && mobileDropdownMode === 'sheet') return;\n setIsOpen(false);\n },\n });\n const rootRef = useRef<HTMLDivElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const sheetInputRef = useRef<HTMLInputElement | null>(null);\n const sheetRef = useRef<HTMLDivElement | null>(null);\n const sheetCloseRef = useRef<HTMLButtonElement | null>(null);\n const lastSelectionRef = useRef(0);\n // Show the Button focus outline only for keyboard focus, not clicks.\n const { keyboardFocus, focusProps: fieldFocusProps } = useFieldFocus();\n\n const inputId = useId();\n const flatOptions = useMemo(\n () => options.flatMap((option) => option.children?.length ? option.children : [option]),\n [options],\n );\n\n const findExactOption = (value: string) => {\n const normalizedValue = value.trim().toLowerCase();\n return flatOptions.find(\n (o) =>\n o.name?.trim().toLowerCase() === normalizedValue ||\n o.keywords?.some((k) => k === normalizedValue),\n );\n };\n\n const resolveQuerySelection = (nextQuery: string, matchKeywords = true) => {\n const text = nextQuery.trim();\n if (!text) return false;\n\n const exact = matchKeywords\n ? findExactOption(text)\n : flatOptions.find(\n (o) => o.name?.trim().toLowerCase() === text.toLowerCase(),\n );\n if (exact) {\n setter([exact.id]);\n setQuery(\"\");\n return true;\n }\n\n if (allowCustomValue) {\n setter([text as unknown as ID]);\n setQuery(\"\");\n return true;\n }\n\n return false;\n };\n\n const selectedSet = useMemo(() => new Set(value ?? []), [value]);\n\n const filtered = useMemo(() => {\n const q = query.trim().toLowerCase();\n const base = q\n ? flatOptions.filter(\n (o) =>\n o.name?.toLowerCase().includes(q) ||\n options.some((group) => group.children?.some((child) => child.id === o.id) && group.name.toLowerCase().includes(q)) ||\n o.keywords?.some((k) => k.includes(q)),\n )\n : flatOptions;\n return preserveOptionOrder || options.some((option) => option.children?.length)\n ? base\n : base.slice().sort((a, b) => a.name.localeCompare(b.name));\n }, [query, flatOptions, options, preserveOptionOrder]);\n\n const toggle = (id: ID) => {\n lastSelectionRef.current = Date.now();\n if (!multiple) {\n setter([id]); // single-select\n setIsOpen(false);\n setQuery(\"\");\n return;\n }\n const set = new Set(value ?? []);\n if (set.has(id)) set.delete(id);\n else set.add(id);\n setter(Array.from(set));\n };\n\n const removeAt = (id: ID) => {\n const set = new Set(value ?? []);\n set.delete(id);\n setter(Array.from(set));\n };\n\n const selectedLabels = useMemo(\n () =>\n (value ?? [])\n .map((id) => {\n const label = flatOptions.find((o) => o.id === id)?.name;\n return label ?? (allowCustomValue ? String(id) : undefined);\n })\n .filter(Boolean) as string[],\n [value, flatOptions, allowCustomValue],\n );\n\n const singleDisplay = !multiple && (selectedLabels[0] ?? \"\");\n const useMobileSheet = isMobile && mobileDropdownMode === \"sheet\";\n const sheetViewport = useMobileSheetViewport(isOpen && useMobileSheet);\n const useInlineMobileDropdown = isMobile && mobileDropdownMode === \"inline\";\n\n\n useEffect(() => {\n if (!isOpen || !useInlineMobileDropdown) {\n setDropdownMaxHeight(undefined);\n return;\n }\n\n const updateDropdownMaxHeight = () => {\n const rootRect = rootRef.current?.getBoundingClientRect();\n if (!rootRect) return;\n\n const viewportHeight =\n window.visualViewport?.height ?? window.innerHeight;\n const gap = 8;\n const availableHeight = viewportHeight - rootRect.bottom - gap;\n setDropdownMaxHeight(Math.max(0, Math.min(400, availableHeight)));\n };\n\n updateDropdownMaxHeight();\n window.addEventListener(\"resize\", updateDropdownMaxHeight);\n window.visualViewport?.addEventListener(\"resize\", updateDropdownMaxHeight);\n window.visualViewport?.addEventListener(\"scroll\", updateDropdownMaxHeight);\n\n return () => {\n window.removeEventListener(\"resize\", updateDropdownMaxHeight);\n window.visualViewport?.removeEventListener(\n \"resize\",\n updateDropdownMaxHeight,\n );\n window.visualViewport?.removeEventListener(\n \"scroll\",\n updateDropdownMaxHeight,\n );\n };\n }, [isOpen, useInlineMobileDropdown]);\n\n const suppressMobileKeyboard =\n isMobile && (useMobileSheet || (mobileDropdownMode === \"inline\" && !allowCustomValue));\n\n // --- keyboard helpers for multi\n const onMultiKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (!multiple) return;\n if (allowCustomValue && e.key === \"Enter\" && query.trim().length > 0 && !findExactOption(query)) {\n const text = query.trim();\n const exact = findExactOption(text);\n const nextId = exact ? exact.id : (text as unknown as ID);\n const set = new Set(value ?? []);\n set.add(nextId);\n setter(Array.from(set));\n setQuery(\"\");\n setIsOpen(true);\n e.preventDefault();\n return;\n }\n if (\n e.key === \"Backspace\" &&\n query.length === 0 &&\n (value?.length ?? 0) > 0\n ) {\n const last = value[value.length - 1];\n removeAt(last);\n e.preventDefault();\n }\n if (e.key === \"Enter\") {\n const first = filtered[0];\n if (first) {\n toggle(first.id);\n setQuery(\"\");\n setIsOpen(true);\n e.preventDefault();\n }\n }\n if (e.key === \"ArrowDown\") setIsOpen(true);\n if (e.key === \"Escape\") setIsOpen(false);\n };\n\n // Same hover lift and press feedback as the Dropdown trigger.\n const fieldClassName = cn(\n fieldInteractionClassName,\n keyboardFocus && fieldFocusOutlineClassName,\n );\n\n const decorateSingleInput = (input: React.ReactNode) =>\n inputIcons ? (\n <div className={cn(\"relative min-w-0 flex-1\", fieldClassName)} {...fieldFocusProps}>\n {inputIcons !== \"search\" && inputIcons !== \"dropdown\" && (\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n )}\n <FieldChromeContext value={true}>{input}</FieldChromeContext>\n {inputIcons === \"search\" ? (\n <Search\n className=\"pointer-events-none absolute right-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n ) : (\n <ChevronDown\n className={cn(\n \"pointer-events-none absolute right-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none\",\n isOpen && \"rotate-180\",\n )}\n aria-hidden=\"true\"\n />\n )}\n </div>\n ) : (\n <div className={cn(\"relative min-w-0 flex-1\", fieldClassName)} {...fieldFocusProps}>\n <FieldChromeContext value={true}>{input}</FieldChromeContext>\n </div>\n );\n\n const OptionsSurface = useMobileSheet ? SheetContent : 'div';\n const sheetProps = useMobileSheet ? {\n side: 'bottom' as const,\n showCloseButton: false,\n overlayClassName: 'z-[1090] bg-black/25 backdrop-blur-[1px]',\n 'aria-describedby': undefined,\n onOpenAutoFocus: (event: Event) => { event.preventDefault(); sheetCloseRef.current?.focus(); },\n onCloseAutoFocus: (event: Event) => { event.preventDefault(); inputRef.current?.focus(); },\n } : {};\n return (\n <div\n className={cn(\"relative w-full overflow-visible\", className)}\n ref={(node) => {\n rootRef.current = node;\n (\n clickOutsideRef as React.MutableRefObject<HTMLDivElement | null>\n ).current = node;\n }}\n >\n {label ? (\n <Label\n label={label}\n required={required}\n labelAddon={labelAddon}\n />\n ) : null}\n\n {multiple ? (\n // ---------- MULTI: chips inline inside the box ----------\n <div\n className={cn(\n \"relative flex min-h-form-control w-full flex-wrap items-center gap-1 rounded-control-lg border border-input bg-background px-[0.75em] pr-10 hover:border-input-hover\",\n fieldClassName,\n )}\n {...fieldFocusProps}\n onClick={() => {\n setIsOpen(true);\n if (!suppressMobileKeyboard) {\n inputRef.current?.focus();\n }\n }}\n >\n {(value ?? []).map((id) => {\n const label = flatOptions.find((o) => o.id === id)?.name ?? String(id);\n return (\n <span\n key={String(id)}\n className=\"my-0.5 flex items-center gap-1 rounded-control-sm border border-input bg-muted px-2 text-xs\"\n >\n {label}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n className=\"ml-1 h-5 min-h-0 w-5 p-0 hover:bg-muted\"\n onClick={(event) => { event.stopPropagation(); removeAt(id); }}\n aria-label={`Remove ${label}`}\n >\n <X className=\"h-3.5 w-3.5\" />\n </Button>\n </span>\n );\n })}\n <input\n id={inputId}\n ref={inputRef}\n value={query}\n onChange={(e) => {\n setQuery(e.target.value);\n setIsOpen(true);\n }}\n onBlur={() => {\n if (useMobileSheet) return;\n // Delay slightly to let dropdown option clicks register first\n setTimeout(() => {\n if (Date.now() - lastSelectionRef.current < 250) {\n return;\n }\n if (allowCustomValue && query.trim().length > 0) {\n const text = query.trim();\n const exact = findExactOption(text);\n const nextId = exact ? exact.id : (text as unknown as ID);\n setter(Array.from(new Set([...(value ?? []), nextId])));\n setQuery(\"\");\n }\n }, 150);\n }}\n onKeyDown={onMultiKeyDown}\n onFocus={() => { if (!useMobileSheet) setIsOpen(true); }}\n readOnly={suppressMobileKeyboard}\n placeholder={(value?.length ?? 0) === 0 ? placeholder : \"\"}\n className={cn(\n \"h-[calc(var(--spacing-form-control)-2px)] min-w-[8ch] flex-1 border-none bg-transparent p-0 text-base outline-none focus:ring-0\",\n \"placeholder:text-muted-foreground/40\",\n )}\n {...props}\n />\n <ChevronDown\n className={cn(\n \"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none\",\n isOpen && \"rotate-180\",\n )}\n aria-hidden=\"true\"\n />\n </div>\n ) : (\n // ---------- SINGLE: regular input ----------\n decorateSingleInput(\n <Input\n id={inputId}\n value={singleDisplay || query}\n className={cn(\n \"border-input\",\n inputIcons === \"search\" || inputIcons === \"dropdown\" ? \"pr-10\" : inputIcons && \"px-10\",\n )}\n placeholder={placeholder}\n readOnly={suppressMobileKeyboard}\n onChange={(e) => {\n const nextQuery = e.target.value;\n\n if ((value?.length ?? 0) > 0) {\n setter([]);\n }\n\n const exact = findExactOption(nextQuery);\n // Only auto-fill on an exact NAME match; keyword/acronym matches\n // (e.g. \"dlsu\") require an explicit Enter, blur, or click.\n if (\n exact &&\n exact.name.trim().toLowerCase() ===\n nextQuery.trim().toLowerCase()\n ) {\n setter([exact.id]);\n setQuery(\"\");\n } else {\n setQuery(nextQuery);\n }\n\n setIsOpen(true);\n }}\n onFocus={() => { if (!useMobileSheet) setIsOpen(true); }}\n onClick={(e) => {\n setIsOpen(true);\n if (suppressMobileKeyboard) {\n e.currentTarget.blur();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && resolveQuerySelection(query, true)) {\n setIsOpen(false);\n e.preventDefault();\n }\n }}\n onBlur={() => {\n if (useMobileSheet) return;\n // slight delay to let dropdown option clicks register first\n setTimeout(() => {\n if (Date.now() - lastSelectionRef.current < 250) {\n return;\n }\n if (!resolveQuerySelection(query, false)) setQuery(\"\");\n }, 150);\n }}\n />,\n )\n )}\n\n {isOpen && (\n <Sheet open={useMobileSheet && isOpen} onOpenChange={next => { if (!next) { setQuery(''); setIsOpen(false); } }}>\n <OptionsSurface\n {...sheetProps}\n ref={useMobileSheet ? sheetRef : undefined}\n role={useMobileSheet ? \"dialog\" : undefined}\n aria-modal={useMobileSheet ? true : undefined}\n aria-label={useMobileSheet ? (typeof label === \"string\" ? label : \"Choose options\") : undefined}\n className={cn(\n \"bg-background text-sm shadow-card border border-border\",\n useMobileSheet\n ? \"fixed left-0 right-0 z-[1100] flex flex-col gap-0 overflow-hidden rounded-t-control-lg border-b-0 p-0\"\n : \"absolute left-0 right-0 z-50 mt-1 max-h-[400px] overflow-y-auto overscroll-contain rounded-control-lg\",\n )}\n style={\n useMobileSheet\n ? {\n bottom: sheetViewport?.bottom ?? 0,\n maxHeight: sheetViewport ? Math.min(sheetViewport.height, 640) : \"80dvh\",\n }\n : undefined\n }\n >\n {useMobileSheet && (\n <div className=\"shrink-0 px-4 pb-3 pt-4\">\n <div className=\"mb-3 flex items-center justify-between gap-4\">\n <SheetTitle className=\"text-base font-semibold text-foreground\">{label || \"Choose options\"}</SheetTitle>\n <button ref={sheetCloseRef} type=\"button\" aria-label=\"Close options\" className=\"-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\" onClick={() => { setQuery(\"\"); setIsOpen(false); }}>\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n <Input\n ref={sheetInputRef}\n aria-label={typeof label === \"string\" ? `Search ${label}` : \"Search options\"}\n value={query}\n placeholder={placeholder ?? \"Search\"}\n className=\"h-10 min-h-10 max-h-none text-base\"\n onChange={(e) => {\n setQuery(e.target.value);\n setIsOpen(true);\n if ((value?.length ?? 0) > 0 && !multiple) {\n setter([]);\n }\n }}\n onKeyDown={(e) => {\n if (multiple) {\n onMultiKeyDown(e);\n return;\n }\n\n if (e.key === \"Enter\" && resolveQuerySelection(query)) {\n setIsOpen(false);\n e.preventDefault();\n }\n\n if (e.key === \"Escape\") {\n setIsOpen(false);\n }\n }}\n />\n </div>\n )}\n <ul className={cn(\"flex flex-col gap-option-gap p-option-inset\", useMobileSheet && \"min-h-0 flex-1 overflow-y-auto overscroll-contain\")}>\n {allowCustomValue && (\n <li className=\"pointer-events-none px-option-x pb-1 pt-1.5 text-xs font-medium uppercase tracking-wide text-muted-foreground\">\n Suggestions\n </li>\n )}\n {filtered.length ? (\n filtered.map((option, index) => {\n const active = selectedSet.has(option.id);\n const group = options.find((item) => item.children?.some((child) => child.id === option.id));\n const firstInGroup = group && !filtered.slice(0, index).some((item) => group.children?.some((child) => child.id === item.id));\n return (\n <Fragment key={String(option.id)}>\n {firstInGroup && group && (\n <li>\n {multiple ? (\n <button type=\"button\" aria-pressed={group.children!.every((child) => selectedSet.has(child.id))} className=\"flex min-h-option-row w-full cursor-pointer items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm font-medium text-foreground transition-colors hover:bg-muted max-md:min-h-11\" onClick={() => {\n const ids = group.children!.map((child) => child.id);\n const next = new Set(value ?? []);\n const allSelected = ids.every((id) => next.has(id));\n ids.forEach((id) => allSelected ? next.delete(id) : next.add(id));\n setter(Array.from(next));\n }}>\n <CheckboxVisual checked={group.children!.every((child) => selectedSet.has(child.id)) ? true : group.children!.some((child) => selectedSet.has(child.id)) ? 'indeterminate' : false} />\n {group.name}\n </button>\n ) : <div className=\"px-option-x py-2 text-sm font-medium text-foreground\">{group.name}</div>}\n </li>\n )}\n <li>\n <button\n type=\"button\"\n aria-pressed={multiple ? active : undefined}\n onClick={() => {\n toggle(option.id);\n if (multiple) {\n // keep open for rapid multi-pick\n setQuery(\"\");\n if (!useMobileSheet) {\n inputRef.current?.focus();\n }\n } else {\n setQuery(\"\");\n setIsOpen(false);\n }\n }}\n className={cn(\n \"flex min-h-option-row w-full cursor-pointer items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-muted\",\n useMobileSheet && \"min-h-12\",\n group && \"pl-8\",\n active && \"bg-primary-tint\",\n )}\n >\n {multiple ? (\n <CheckboxVisual checked={active} />\n ) : null}\n {option.name}\n </button>\n </li>\n </Fragment>\n );\n })\n ) : (\n !allowCustomValue || !query.trim() ? (\n <li className=\"px-option-x py-2 text-sm text-muted-foreground\">\n {emptyText}\n </li>\n ) : null\n )}\n {allowCustomValue && query.trim() && !findExactOption(query) && (\n <li>\n <button\n type=\"button\"\n className=\"flex min-h-11 w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 text-left text-sm text-primary transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-primary\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n const text = query.trim();\n if (multiple) {\n setter(Array.from(new Set([...(value ?? []), text as unknown as ID])));\n setQuery(\"\");\n } else {\n resolveQuerySelection(text);\n setIsOpen(false);\n }\n }}\n >\n <PlusCircleIcon className=\"h-4 w-4\" aria-hidden=\"true\" />\n Add “{query.trim()}”\n </button>\n </li>\n )}\n </ul>\n {useMobileSheet && multiple && (\n <div className=\"shrink-0 border-t border-border bg-background px-4 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]\">\n <Button\n type=\"button\"\n variant=\"outline\"\n className=\"min-h-11 w-full\"\n onClick={() => {\n setQuery(\"\");\n setIsOpen(false);\n }}\n >\n Done\n </Button>\n </div>\n )}\n </OptionsSurface>\n </Sheet>\n )}\n </div>\n );\n}\n\ntype AutocompleteCommonProps<ID extends number | string> = {\n required?: boolean;\n options: IAutocompleteOption<ID>[];\n placeholder?: string;\n className?: string;\n label?: React.ReactNode;\n props?: any[];\n /** Allow a user to add their own text. Custom values are strings. */\n allowCustomValue?: boolean;\n preserveOptionOrder?: boolean;\n emptyText?: string;\n mobileDropdownMode?: MobileDropdownMode;\n inputIcons?: InputIcons;\n};\n\nexport type AutocompleteProps<ID extends number | string> = AutocompleteCommonProps<ID> & (\n | { multiple?: false; value?: ID | null; setter: (value?: ID | null) => void }\n | { multiple: true; value?: ID[]; setter: (value: ID[]) => void }\n);\n\nexport const Autocomplete = <ID extends number | string>(config: AutocompleteProps<ID>) => {\n const { required, options, placeholder, className, label, props, allowCustomValue = false,\n preserveOptionOrder = false, emptyText, mobileDropdownMode, inputIcons } = config;\n return (\n <AutocompleteBase<ID>\n required={required}\n options={options}\n multiple={config.multiple === true}\n value={config.multiple === true ? config.value ?? [] : config.value != null ? [config.value] : []}\n setter={(arr) => {\n if (config.multiple === true) config.setter(arr);\n else config.setter(arr[0] ?? null);\n }}\n placeholder={placeholder}\n className={className}\n label={label}\n allowCustomValue={allowCustomValue}\n preserveOptionOrder={preserveOptionOrder}\n emptyText={emptyText}\n mobileDropdownMode={mobileDropdownMode}\n inputIcons={inputIcons}\n {...props}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA+BA;;AAE0D;AAC1D;;;;AAmCE;;;;AAII;;;;AAGH;AACD;AACA;AACA;AACA;AACA;AACA;;;AAIA;AACA;AAKA;;AAEE;AAGI;AAEN;;AAGE;AACA;AAAW;;AAGT;;;AAKA;;AAEA;;;AAIA;;AAEA;;AAGF;AACF;AAEA;AAEA;;;;AAMY;AACA;;AAGV;AACE;;;AAIJ;AACE;;AAEE;;;;;;AAMF;AAAiB;;AACZ;;AAEP;AAEA;;AAEE;;AAEF;;AAKO;AACC;AACA;AACF;AACC;AAIP;AACA;;AAEA;;AAIE;;;;;;AAOE;;;;;AAMA;AACF;AAEA;AACA;;;AAIA;AACE;;;AASF;AACF;AAEA;;AAIA;AACE;;;AAEE;AACA;AACA;;AAEA;;;;;;;AAOF;;;;;;;AASA;AACE;;AAEE;;;;;;AAMJ;;AACA;;AACF;;;;;AAwCA;AACE;AACA;AACA;AACA;;;;AAIF;AAIM;AAEE;AAEJ;;AAYE;;;AASM;;AAEJ;;AAIE;;AAwBE;;AAEF;AAEE;;;;;;;;AAOI;AACA;AACA;;;;;AAKN;AAEsC;;;AA8BpC;;;;AAMA;;;AAGA;AAEE;AACE;AAEF;;;;;;;;AAQkC;;;AAIlC;;AAEJ;AAEE;;;;AAIF;AAEE;;;;;;;AAME;;;;;;AAQoG;AAUnG;AACA;AAID;AACI;AACA;AACD;;AAmBC;;AAEA;;;AAGF;;;;;;;;;AAYE;;;AAGF;;AAaF;AACA;;AAOU;;AAEA;AACA;;;AAcJ;;;;;AAKI;;;;;;;;AAsBZ;AAeM;;;;;;;;;;;;;AAoCpB;AAsBO;AACL;AAEA;AAOM;AAA8B;;;AAEhC;AAYN;;"}
|
|
1
|
+
{"version":3,"file":"autocomplete.js","sources":["../../src/components/autocomplete.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { Input } from \"./input\";\nimport { useDetectClickOutside } from '@/hooks/use-detect-click-outside';\nimport { cn } from \"@/utils\";\nimport { ChevronDown, PlusCircleIcon, Search, X } from \"lucide-react\";\nimport { Label } from \"./label\";\nimport { Button } from \"./button\";\nimport { CheckboxVisual } from \"./checkbox\";\nimport { Sheet, SheetContent, SheetTitle } from \"./sheet\";\nimport { useMobile } from \"@/hooks/use-mobile\";\nimport { useMobileSheetViewport } from \"@/hooks/use-mobile-sheet-viewport\";\nimport {\n FieldChromeContext,\n fieldFocusOutlineClassName,\n fieldInteractionClassName,\n useFieldFocus,\n} from \"@/hooks/use-field-focus\";\n\nexport interface IAutocompleteOption<ID extends number | string> {\n id: ID;\n name: string;\n keywords?: string[];\n /** Child options; in multiple mode the group can select all its children. */\n children?: IAutocompleteOption<ID>[];\n}\n\ntype MobileDropdownMode = \"sheet\" | \"inline\";\ntype InputIcons = boolean | \"search\" | \"dropdown\";\n\n/* -------------------------------------------------------\n * Base component (array-based). Single uses length 0..1.\n * -----------------------------------------------------*/\nfunction AutocompleteBase<ID extends number | string>({\n required,\n options,\n value = [],\n setter,\n placeholder,\n className,\n multiple = true,\n label,\n labelAddon,\n allowCustomValue = false,\n preserveOptionOrder = false,\n emptyText = \"No matching options\",\n mobileDropdownMode = \"sheet\",\n inputIcons = false,\n ...props\n}: {\n required?: boolean;\n options: IAutocompleteOption<ID>[];\n value?: ID[]; // single => 0..1 items, multi => any length\n setter: (next: ID[]) => void; // set the whole selection\n placeholder?: string;\n className?: string;\n multiple?: boolean;\n label?: React.ReactNode;\n labelAddon?: React.ReactNode;\n allowCustomValue?: boolean;\n preserveOptionOrder?: boolean;\n emptyText?: string;\n mobileDropdownMode?: MobileDropdownMode;\n inputIcons?: InputIcons;\n}) {\n const [query, setQuery] = useState(\"\");\n const [isOpen, setIsOpen] = useState(false);\n const [dropdownMaxHeight, setDropdownMaxHeight] = useState<number>();\n const isMobile = useMobile();\n const clickOutsideRef = useDetectClickOutside({\n onTriggered: () => {\n // Radix owns outside dismissal for the portalled modal sheet.\n if (isMobile && mobileDropdownMode === 'sheet') return;\n setIsOpen(false);\n },\n });\n const rootRef = useRef<HTMLDivElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const sheetInputRef = useRef<HTMLInputElement | null>(null);\n const sheetRef = useRef<HTMLDivElement | null>(null);\n const sheetCloseRef = useRef<HTMLButtonElement | null>(null);\n const lastSelectionRef = useRef(0);\n // Show the Button focus outline only for keyboard focus, not clicks.\n const { keyboardFocus, focusProps: fieldFocusProps } = useFieldFocus();\n\n const inputId = useId();\n const flatOptions = useMemo(\n () => options.flatMap((option) => option.children?.length ? option.children : [option]),\n [options],\n );\n\n const findExactOption = (value: string) => {\n const normalizedValue = value.trim().toLowerCase();\n return flatOptions.find(\n (o) =>\n o.name?.trim().toLowerCase() === normalizedValue ||\n o.keywords?.some((k) => k === normalizedValue),\n );\n };\n\n const resolveQuerySelection = (nextQuery: string, matchKeywords = true) => {\n const text = nextQuery.trim();\n if (!text) return false;\n\n const exact = matchKeywords\n ? findExactOption(text)\n : flatOptions.find(\n (o) => o.name?.trim().toLowerCase() === text.toLowerCase(),\n );\n if (exact) {\n setter([exact.id]);\n setQuery(\"\");\n return true;\n }\n\n if (allowCustomValue) {\n setter([text as unknown as ID]);\n setQuery(\"\");\n return true;\n }\n\n return false;\n };\n\n const selectedSet = useMemo(() => new Set(value ?? []), [value]);\n\n const filtered = useMemo(() => {\n const q = query.trim().toLowerCase();\n const base = q\n ? flatOptions.filter(\n (o) =>\n o.name?.toLowerCase().includes(q) ||\n options.some((group) => group.children?.some((child) => child.id === o.id) && group.name.toLowerCase().includes(q)) ||\n o.keywords?.some((k) => k.includes(q)),\n )\n : flatOptions;\n return preserveOptionOrder || options.some((option) => option.children?.length)\n ? base\n : base.slice().sort((a, b) => a.name.localeCompare(b.name));\n }, [query, flatOptions, options, preserveOptionOrder]);\n\n const toggle = (id: ID) => {\n lastSelectionRef.current = Date.now();\n if (!multiple) {\n setter([id]); // single-select\n setIsOpen(false);\n setQuery(\"\");\n return;\n }\n const set = new Set(value ?? []);\n if (set.has(id)) set.delete(id);\n else set.add(id);\n setter(Array.from(set));\n };\n\n const removeAt = (id: ID) => {\n const set = new Set(value ?? []);\n set.delete(id);\n setter(Array.from(set));\n };\n\n const selectedLabels = useMemo(\n () =>\n (value ?? [])\n .map((id) => {\n const label = flatOptions.find((o) => o.id === id)?.name;\n return label ?? (allowCustomValue ? String(id) : undefined);\n })\n .filter(Boolean) as string[],\n [value, flatOptions, allowCustomValue],\n );\n\n const singleDisplay = !multiple && (selectedLabels[0] ?? \"\");\n const useMobileSheet = isMobile && mobileDropdownMode === \"sheet\";\n const sheetViewport = useMobileSheetViewport(isOpen && useMobileSheet);\n const useInlineMobileDropdown = isMobile && mobileDropdownMode === \"inline\";\n\n\n useEffect(() => {\n if (!isOpen || !useInlineMobileDropdown) {\n setDropdownMaxHeight(undefined);\n return;\n }\n\n const updateDropdownMaxHeight = () => {\n const rootRect = rootRef.current?.getBoundingClientRect();\n if (!rootRect) return;\n\n const viewportHeight =\n window.visualViewport?.height ?? window.innerHeight;\n const gap = 8;\n const availableHeight = viewportHeight - rootRect.bottom - gap;\n setDropdownMaxHeight(Math.max(0, Math.min(400, availableHeight)));\n };\n\n updateDropdownMaxHeight();\n window.addEventListener(\"resize\", updateDropdownMaxHeight);\n window.visualViewport?.addEventListener(\"resize\", updateDropdownMaxHeight);\n window.visualViewport?.addEventListener(\"scroll\", updateDropdownMaxHeight);\n\n return () => {\n window.removeEventListener(\"resize\", updateDropdownMaxHeight);\n window.visualViewport?.removeEventListener(\n \"resize\",\n updateDropdownMaxHeight,\n );\n window.visualViewport?.removeEventListener(\n \"scroll\",\n updateDropdownMaxHeight,\n );\n };\n }, [isOpen, useInlineMobileDropdown]);\n\n const suppressMobileKeyboard =\n isMobile && (useMobileSheet || (mobileDropdownMode === \"inline\" && !allowCustomValue));\n\n // --- keyboard helpers for multi\n const onMultiKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (!multiple) return;\n if (allowCustomValue && e.key === \"Enter\" && query.trim().length > 0 && !findExactOption(query)) {\n const text = query.trim();\n const exact = findExactOption(text);\n const nextId = exact ? exact.id : (text as unknown as ID);\n const set = new Set(value ?? []);\n set.add(nextId);\n setter(Array.from(set));\n setQuery(\"\");\n setIsOpen(true);\n e.preventDefault();\n return;\n }\n if (\n e.key === \"Backspace\" &&\n query.length === 0 &&\n (value?.length ?? 0) > 0\n ) {\n const last = value[value.length - 1];\n removeAt(last);\n e.preventDefault();\n }\n if (e.key === \"Enter\") {\n const first = filtered[0];\n if (first) {\n toggle(first.id);\n setQuery(\"\");\n setIsOpen(true);\n e.preventDefault();\n }\n }\n if (e.key === \"ArrowDown\") setIsOpen(true);\n if (e.key === \"Escape\") setIsOpen(false);\n };\n\n // Same hover lift and press feedback as the Dropdown trigger.\n const fieldClassName = cn(\n fieldInteractionClassName,\n keyboardFocus && fieldFocusOutlineClassName,\n );\n\n const decorateSingleInput = (input: React.ReactNode) =>\n inputIcons ? (\n <div className={cn(\"relative min-w-0 flex-1\", fieldClassName)} {...fieldFocusProps}>\n {inputIcons !== \"search\" && inputIcons !== \"dropdown\" && (\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n )}\n <FieldChromeContext value={true}>{input}</FieldChromeContext>\n {inputIcons === \"search\" ? (\n <Search\n className=\"pointer-events-none absolute right-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n ) : (\n <ChevronDown\n className={cn(\n \"pointer-events-none absolute right-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none\",\n isOpen && \"rotate-180\",\n )}\n aria-hidden=\"true\"\n />\n )}\n </div>\n ) : (\n <div className={cn(\"relative min-w-0 flex-1\", fieldClassName)} {...fieldFocusProps}>\n <FieldChromeContext value={true}>{input}</FieldChromeContext>\n </div>\n );\n\n const OptionsSurface = useMobileSheet ? SheetContent : 'div';\n const sheetProps = useMobileSheet ? {\n side: 'bottom' as const,\n showCloseButton: false,\n overlayClassName: 'z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]',\n 'aria-describedby': undefined,\n onOpenAutoFocus: (event: Event) => { event.preventDefault(); sheetCloseRef.current?.focus(); },\n onCloseAutoFocus: (event: Event) => { event.preventDefault(); inputRef.current?.focus(); },\n } : {};\n return (\n <div\n className={cn(\"relative w-full overflow-visible\", className)}\n ref={(node) => {\n rootRef.current = node;\n (\n clickOutsideRef as React.MutableRefObject<HTMLDivElement | null>\n ).current = node;\n }}\n >\n {label ? (\n <Label\n label={label}\n required={required}\n labelAddon={labelAddon}\n />\n ) : null}\n\n {multiple ? (\n // ---------- MULTI: chips inline inside the box ----------\n <div\n className={cn(\n \"relative flex min-h-form-control w-full flex-wrap items-center gap-1 rounded-control-lg border border-input bg-background px-[0.75em] pr-10 hover:border-input-hover\",\n fieldClassName,\n )}\n {...fieldFocusProps}\n onClick={() => {\n setIsOpen(true);\n if (!suppressMobileKeyboard) {\n inputRef.current?.focus();\n }\n }}\n >\n {(value ?? []).map((id) => {\n const label = flatOptions.find((o) => o.id === id)?.name ?? String(id);\n return (\n <span\n key={String(id)}\n className=\"my-0.5 flex items-center gap-1 rounded-control-sm border border-input bg-muted px-2 text-xs\"\n >\n {label}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n className=\"ml-1 h-5 min-h-0 w-5 p-0 hover:bg-muted\"\n onClick={(event) => { event.stopPropagation(); removeAt(id); }}\n aria-label={`Remove ${label}`}\n >\n <X className=\"h-3.5 w-3.5\" />\n </Button>\n </span>\n );\n })}\n <input\n id={inputId}\n ref={inputRef}\n value={query}\n onChange={(e) => {\n setQuery(e.target.value);\n setIsOpen(true);\n }}\n onBlur={() => {\n if (useMobileSheet) return;\n // Delay slightly to let dropdown option clicks register first\n setTimeout(() => {\n if (Date.now() - lastSelectionRef.current < 250) {\n return;\n }\n if (allowCustomValue && query.trim().length > 0) {\n const text = query.trim();\n const exact = findExactOption(text);\n const nextId = exact ? exact.id : (text as unknown as ID);\n setter(Array.from(new Set([...(value ?? []), nextId])));\n setQuery(\"\");\n }\n }, 150);\n }}\n onKeyDown={onMultiKeyDown}\n onFocus={() => { if (!useMobileSheet) setIsOpen(true); }}\n readOnly={suppressMobileKeyboard}\n placeholder={(value?.length ?? 0) === 0 ? placeholder : \"\"}\n className={cn(\n \"h-[calc(var(--spacing-form-control)-2px)] min-w-[8ch] flex-1 border-none bg-transparent p-0 text-base outline-none focus:ring-0\",\n \"placeholder:text-muted-foreground/40\",\n )}\n {...props}\n />\n <ChevronDown\n className={cn(\n \"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none\",\n isOpen && \"rotate-180\",\n )}\n aria-hidden=\"true\"\n />\n </div>\n ) : (\n // ---------- SINGLE: regular input ----------\n decorateSingleInput(\n <Input\n id={inputId}\n value={singleDisplay || query}\n className={cn(\n \"border-input\",\n inputIcons === \"search\" || inputIcons === \"dropdown\" ? \"pr-10\" : inputIcons && \"px-10\",\n )}\n placeholder={placeholder}\n readOnly={suppressMobileKeyboard}\n onChange={(e) => {\n const nextQuery = e.target.value;\n\n if ((value?.length ?? 0) > 0) {\n setter([]);\n }\n\n const exact = findExactOption(nextQuery);\n // Only auto-fill on an exact NAME match; keyword/acronym matches\n // (e.g. \"dlsu\") require an explicit Enter, blur, or click.\n if (\n exact &&\n exact.name.trim().toLowerCase() ===\n nextQuery.trim().toLowerCase()\n ) {\n setter([exact.id]);\n setQuery(\"\");\n } else {\n setQuery(nextQuery);\n }\n\n setIsOpen(true);\n }}\n onFocus={() => { if (!useMobileSheet) setIsOpen(true); }}\n onClick={(e) => {\n setIsOpen(true);\n if (suppressMobileKeyboard) {\n e.currentTarget.blur();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && resolveQuerySelection(query, true)) {\n setIsOpen(false);\n e.preventDefault();\n }\n }}\n onBlur={() => {\n if (useMobileSheet) return;\n // slight delay to let dropdown option clicks register first\n setTimeout(() => {\n if (Date.now() - lastSelectionRef.current < 250) {\n return;\n }\n if (!resolveQuerySelection(query, false)) setQuery(\"\");\n }, 150);\n }}\n />,\n )\n )}\n\n {isOpen && (\n <Sheet open={useMobileSheet && isOpen} onOpenChange={next => { if (!next) { setQuery(''); setIsOpen(false); } }}>\n <OptionsSurface\n {...sheetProps}\n ref={useMobileSheet ? sheetRef : undefined}\n role={useMobileSheet ? \"dialog\" : undefined}\n aria-modal={useMobileSheet ? true : undefined}\n aria-label={useMobileSheet ? (typeof label === \"string\" ? label : \"Choose options\") : undefined}\n className={cn(\n \"bg-background text-sm shadow-card border border-border\",\n useMobileSheet\n ? \"fixed left-0 right-0 z-(--z-popover) flex flex-col gap-0 overflow-hidden rounded-t-control-lg border-b-0 p-0\"\n : \"absolute left-0 right-0 z-50 mt-1 max-h-[400px] overflow-y-auto overscroll-contain rounded-control-lg\",\n )}\n style={\n useMobileSheet\n ? {\n bottom: sheetViewport?.bottom ?? 0,\n maxHeight: sheetViewport ? Math.min(sheetViewport.height, 640) : \"80dvh\",\n }\n : undefined\n }\n >\n {useMobileSheet && (\n <div className=\"shrink-0 px-4 pb-3 pt-4\">\n <div className=\"mb-3 flex items-center justify-between gap-4\">\n <SheetTitle className=\"text-base font-semibold text-foreground\">{label || \"Choose options\"}</SheetTitle>\n <button ref={sheetCloseRef} type=\"button\" aria-label=\"Close options\" className=\"-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\" onClick={() => { setQuery(\"\"); setIsOpen(false); }}>\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n <Input\n ref={sheetInputRef}\n aria-label={typeof label === \"string\" ? `Search ${label}` : \"Search options\"}\n value={query}\n placeholder={placeholder ?? \"Search\"}\n className=\"h-10 min-h-10 max-h-none text-base\"\n onChange={(e) => {\n setQuery(e.target.value);\n setIsOpen(true);\n if ((value?.length ?? 0) > 0 && !multiple) {\n setter([]);\n }\n }}\n onKeyDown={(e) => {\n if (multiple) {\n onMultiKeyDown(e);\n return;\n }\n\n if (e.key === \"Enter\" && resolveQuerySelection(query)) {\n setIsOpen(false);\n e.preventDefault();\n }\n\n if (e.key === \"Escape\") {\n setIsOpen(false);\n }\n }}\n />\n </div>\n )}\n <ul className={cn(\"flex flex-col gap-option-gap p-option-inset\", useMobileSheet && \"min-h-0 flex-1 overflow-y-auto overscroll-contain\")}>\n {allowCustomValue && (\n <li className=\"pointer-events-none px-option-x pb-1 pt-1.5 text-xs font-medium uppercase tracking-wide text-muted-foreground\">\n Suggestions\n </li>\n )}\n {filtered.length ? (\n filtered.map((option, index) => {\n const active = selectedSet.has(option.id);\n const group = options.find((item) => item.children?.some((child) => child.id === option.id));\n const firstInGroup = group && !filtered.slice(0, index).some((item) => group.children?.some((child) => child.id === item.id));\n return (\n <Fragment key={String(option.id)}>\n {firstInGroup && group && (\n <li>\n {multiple ? (\n <button type=\"button\" aria-pressed={group.children!.every((child) => selectedSet.has(child.id))} className=\"flex min-h-option-row w-full cursor-pointer items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm font-medium text-foreground transition-colors hover:bg-muted max-md:min-h-11\" onClick={() => {\n const ids = group.children!.map((child) => child.id);\n const next = new Set(value ?? []);\n const allSelected = ids.every((id) => next.has(id));\n ids.forEach((id) => allSelected ? next.delete(id) : next.add(id));\n setter(Array.from(next));\n }}>\n <CheckboxVisual checked={group.children!.every((child) => selectedSet.has(child.id)) ? true : group.children!.some((child) => selectedSet.has(child.id)) ? 'indeterminate' : false} />\n {group.name}\n </button>\n ) : <div className=\"px-option-x py-2 text-sm font-medium text-foreground\">{group.name}</div>}\n </li>\n )}\n <li>\n <button\n type=\"button\"\n aria-pressed={multiple ? active : undefined}\n onClick={() => {\n toggle(option.id);\n if (multiple) {\n // keep open for rapid multi-pick\n setQuery(\"\");\n if (!useMobileSheet) {\n inputRef.current?.focus();\n }\n } else {\n setQuery(\"\");\n setIsOpen(false);\n }\n }}\n className={cn(\n \"flex min-h-option-row w-full cursor-pointer items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-muted\",\n useMobileSheet && \"min-h-12\",\n group && \"pl-8\",\n active && \"bg-primary-tint\",\n )}\n >\n {multiple ? (\n <CheckboxVisual checked={active} />\n ) : null}\n {option.name}\n </button>\n </li>\n </Fragment>\n );\n })\n ) : (\n !allowCustomValue || !query.trim() ? (\n <li className=\"px-option-x py-2 text-sm text-muted-foreground\">\n {emptyText}\n </li>\n ) : null\n )}\n {allowCustomValue && query.trim() && !findExactOption(query) && (\n <li>\n <button\n type=\"button\"\n className=\"flex min-h-11 w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 text-left text-sm text-primary transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-primary\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n const text = query.trim();\n if (multiple) {\n setter(Array.from(new Set([...(value ?? []), text as unknown as ID])));\n setQuery(\"\");\n } else {\n resolveQuerySelection(text);\n setIsOpen(false);\n }\n }}\n >\n <PlusCircleIcon className=\"h-4 w-4\" aria-hidden=\"true\" />\n Add “{query.trim()}”\n </button>\n </li>\n )}\n </ul>\n {useMobileSheet && multiple && (\n <div className=\"shrink-0 border-t border-border bg-background px-4 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]\">\n <Button\n type=\"button\"\n variant=\"outline\"\n className=\"min-h-11 w-full\"\n onClick={() => {\n setQuery(\"\");\n setIsOpen(false);\n }}\n >\n Done\n </Button>\n </div>\n )}\n </OptionsSurface>\n </Sheet>\n )}\n </div>\n );\n}\n\ntype AutocompleteCommonProps<ID extends number | string> = {\n required?: boolean;\n options: IAutocompleteOption<ID>[];\n placeholder?: string;\n className?: string;\n label?: React.ReactNode;\n props?: any[];\n /** Allow a user to add their own text. Custom values are strings. */\n allowCustomValue?: boolean;\n preserveOptionOrder?: boolean;\n emptyText?: string;\n mobileDropdownMode?: MobileDropdownMode;\n inputIcons?: InputIcons;\n};\n\nexport type AutocompleteProps<ID extends number | string> = AutocompleteCommonProps<ID> & (\n | { multiple?: false; value?: ID | null; setter: (value?: ID | null) => void }\n | { multiple: true; value?: ID[]; setter: (value: ID[]) => void }\n);\n\nexport const Autocomplete = <ID extends number | string>(config: AutocompleteProps<ID>) => {\n const { required, options, placeholder, className, label, props, allowCustomValue = false,\n preserveOptionOrder = false, emptyText, mobileDropdownMode, inputIcons } = config;\n return (\n <AutocompleteBase<ID>\n required={required}\n options={options}\n multiple={config.multiple === true}\n value={config.multiple === true ? config.value ?? [] : config.value != null ? [config.value] : []}\n setter={(arr) => {\n if (config.multiple === true) config.setter(arr);\n else config.setter(arr[0] ?? null);\n }}\n placeholder={placeholder}\n className={className}\n label={label}\n allowCustomValue={allowCustomValue}\n preserveOptionOrder={preserveOptionOrder}\n emptyText={emptyText}\n mobileDropdownMode={mobileDropdownMode}\n inputIcons={inputIcons}\n {...props}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA+BA;;AAE0D;AAC1D;;;;AAmCE;;;;AAII;;;;AAGH;AACD;AACA;AACA;AACA;AACA;AACA;;;AAIA;AACA;AAKA;;AAEE;AAGI;AAEN;;AAGE;AACA;AAAW;;AAGT;;;AAKA;;AAEA;;;AAIA;;AAEA;;AAGF;AACF;AAEA;AAEA;;;;AAMY;AACA;;AAGV;AACE;;;AAIJ;AACE;;AAEE;;;;;;AAMF;AAAiB;;AACZ;;AAEP;AAEA;;AAEE;;AAEF;;AAKO;AACC;AACA;AACF;AACC;AAIP;AACA;;AAEA;;AAIE;;;;;;AAOE;;;;;AAMA;AACF;AAEA;AACA;;;AAIA;AACE;;;AASF;AACF;AAEA;;AAIA;AACE;;;AAEE;AACA;AACA;;AAEA;;;;;;;AAOF;;;;;;;AASA;AACE;;AAEE;;;;;;AAMJ;;AACA;;AACF;;;;;AAwCA;AACE;AACA;AACA;AACA;;;;AAIF;AAIM;AAEE;AAEJ;;AAYE;;;AASM;;AAEJ;;AAIE;;AAwBE;;AAEF;AAEE;;;;;;;;AAOI;AACA;AACA;;;;;AAKN;AAEsC;;;AA8BpC;;;;AAMA;;;AAGA;AAEE;AACE;AAEF;;;;;;;;AAQkC;;;AAIlC;;AAEJ;AAEE;;;;AAIF;AAEE;;;;;;;AAME;;;;;;AAQoG;AAUnG;AACA;AAID;AACI;AACA;AACD;;AAmBC;;AAEA;;;AAGF;;;;;;;;;AAYE;;;AAGF;;AAaF;AACA;;AAOU;;AAEA;AACA;;;AAcJ;;;;;AAKI;;;;;;;;AAsBZ;AAeM;;;;;;;;;;;;;AAoCpB;AAsBO;AACL;AAEA;AAOM;AAA8B;;;AAEhC;AAYN;;"}
|
|
@@ -13,9 +13,9 @@ const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
|
13
13
|
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
14
14
|
const ContextMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => (jsxs(ContextMenuPrimitive.SubTrigger, { ref: ref, className: cn("flex cursor-pointer select-none items-center min-h-option-row pointer-coarse:min-h-11 rounded-control-sm px-option-x py-2 text-sm outline-none focus:bg-muted focus:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground", inset && "pl-9", className), ...props, children: [children, jsx(ChevronRight, { className: "ml-auto h-4 w-4" })] })));
|
|
15
15
|
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
|
16
|
-
const ContextMenuSubContent = React.forwardRef(({ className, ...props }, ref) => (jsx(ContextMenuPrimitive.SubContent, { ref: ref, className: cn("z-
|
|
16
|
+
const ContextMenuSubContent = React.forwardRef(({ className, ...props }, ref) => (jsx(ContextMenuPrimitive.SubContent, { ref: ref, className: cn("z-(--z-popover) min-w-[8rem] overflow-hidden rounded-control-lg border border-border bg-popover p-option-inset text-popover-foreground shadow-card 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", className), ...props })));
|
|
17
17
|
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
|
18
|
-
const ContextMenuContent = React.forwardRef(({ className, ...props }, ref) => (jsx(ContextMenuPrimitive.Portal, { children: jsx(ContextMenuPrimitive.Content, { ref: ref, className: cn("z-
|
|
18
|
+
const ContextMenuContent = React.forwardRef(({ className, ...props }, ref) => (jsx(ContextMenuPrimitive.Portal, { children: jsx(ContextMenuPrimitive.Content, { ref: ref, className: cn("z-(--z-popover) min-w-[8rem] overflow-hidden rounded-control-lg border border-border bg-popover p-option-inset text-popover-foreground shadow-card animate-in motion-reduce:animate-none fade-in-80 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", className), ...props }) })));
|
|
19
19
|
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
20
20
|
const ContextMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => (jsx(ContextMenuPrimitive.Item, { ref: ref, className: cn("relative flex cursor-pointer select-none items-center min-h-option-row pointer-coarse:min-h-11 rounded-control-sm px-option-x py-2 text-sm outline-none focus:bg-muted focus:text-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", inset && "pl-9", className), ...props })));
|
|
21
21
|
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.js","sources":["../../src/components/context-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as ContextMenuPrimitive from \"@radix-ui/react-context-menu\";\nimport { Check, ChevronRight, Circle } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\n\nconst ContextMenu = ContextMenuPrimitive.Root;\n\nconst ContextMenuTrigger = ContextMenuPrimitive.Trigger;\n\nconst ContextMenuGroup = ContextMenuPrimitive.Group;\n\nconst ContextMenuPortal = ContextMenuPrimitive.Portal;\n\nconst ContextMenuSub = ContextMenuPrimitive.Sub;\n\nconst ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;\n\nconst ContextMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(({ className, inset, children, ...props }, ref) => (\n <ContextMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n \"flex cursor-pointer select-none items-center min-h-option-row pointer-coarse:min-h-11 rounded-control-sm px-option-x py-2 text-sm outline-none focus:bg-muted focus:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground\",\n inset && \"pl-9\",\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"ml-auto h-4 w-4\" />\n </ContextMenuPrimitive.SubTrigger>\n));\nContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;\n\nconst ContextMenuSubContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>\n>(({ className, ...props }, ref) => (\n <ContextMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n \"z-
|
|
1
|
+
{"version":3,"file":"context-menu.js","sources":["../../src/components/context-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as ContextMenuPrimitive from \"@radix-ui/react-context-menu\";\nimport { Check, ChevronRight, Circle } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\n\nconst ContextMenu = ContextMenuPrimitive.Root;\n\nconst ContextMenuTrigger = ContextMenuPrimitive.Trigger;\n\nconst ContextMenuGroup = ContextMenuPrimitive.Group;\n\nconst ContextMenuPortal = ContextMenuPrimitive.Portal;\n\nconst ContextMenuSub = ContextMenuPrimitive.Sub;\n\nconst ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;\n\nconst ContextMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(({ className, inset, children, ...props }, ref) => (\n <ContextMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n \"flex cursor-pointer select-none items-center min-h-option-row pointer-coarse:min-h-11 rounded-control-sm px-option-x py-2 text-sm outline-none focus:bg-muted focus:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground\",\n inset && \"pl-9\",\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"ml-auto h-4 w-4\" />\n </ContextMenuPrimitive.SubTrigger>\n));\nContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;\n\nconst ContextMenuSubContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>\n>(({ className, ...props }, ref) => (\n <ContextMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n \"z-(--z-popover) min-w-[8rem] overflow-hidden rounded-control-lg border border-border bg-popover p-option-inset text-popover-foreground shadow-card 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));\nContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;\n\nconst ContextMenuContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(({ className, ...props }, ref) => (\n <ContextMenuPrimitive.Portal>\n <ContextMenuPrimitive.Content\n ref={ref}\n className={cn(\n \"z-(--z-popover) min-w-[8rem] overflow-hidden rounded-control-lg border border-border bg-popover p-option-inset text-popover-foreground shadow-card animate-in motion-reduce:animate-none fade-in-80 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 </ContextMenuPrimitive.Portal>\n));\nContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;\n\nconst ContextMenuItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean;\n }\n>(({ className, inset, ...props }, ref) => (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex cursor-pointer select-none items-center min-h-option-row pointer-coarse:min-h-11 rounded-control-sm px-option-x py-2 text-sm outline-none focus:bg-muted focus:text-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n inset && \"pl-9\",\n className,\n )}\n {...props}\n />\n));\nContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;\n\nconst ContextMenuCheckboxItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>\n>(({ className, children, checked, ...props }, ref) => (\n <ContextMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(\n \"relative flex cursor-pointer select-none items-center min-h-option-row pointer-coarse:min-h-11 rounded-control-sm py-2 pl-9 pr-option-x text-sm outline-none focus:bg-muted focus:text-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n className,\n )}\n checked={checked}\n {...props}\n >\n <span className=\"absolute left-option-x flex h-3.5 w-3.5 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n));\nContextMenuCheckboxItem.displayName =\n ContextMenuPrimitive.CheckboxItem.displayName;\n\nconst ContextMenuRadioItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>\n>(({ className, children, ...props }, ref) => (\n <ContextMenuPrimitive.RadioItem\n ref={ref}\n className={cn(\n \"relative flex cursor-pointer select-none items-center min-h-option-row pointer-coarse:min-h-11 rounded-control-sm py-2 pl-9 pr-option-x text-sm outline-none focus:bg-muted focus:text-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n <span className=\"absolute left-option-x flex h-3.5 w-3.5 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Circle className=\"h-2 w-2 fill-current\" />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n));\nContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;\n\nconst ContextMenuLabel = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(({ className, inset, ...props }, ref) => (\n <ContextMenuPrimitive.Label\n ref={ref}\n className={cn(\n \"px-2 py-1.5 text-sm font-semibold text-foreground\",\n inset && \"pl-9\",\n className,\n )}\n {...props}\n />\n));\nContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;\n\nconst ContextMenuSeparator = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-option-inset my-1 h-px bg-border\", className)}\n {...props}\n />\n));\nContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;\n\nconst ContextMenuShortcut = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\n \"ml-auto text-xs tracking-widest text-muted-foreground\",\n className,\n )}\n {...props}\n />\n );\n};\nContextMenuShortcut.displayName = \"ContextMenuShortcut\";\n\nexport {\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuContent,\n ContextMenuItem,\n ContextMenuCheckboxItem,\n ContextMenuRadioItem,\n ContextMenuLabel,\n ContextMenuSeparator,\n ContextMenuShortcut,\n ContextMenuGroup,\n ContextMenuPortal,\n ContextMenuSub,\n ContextMenuSubContent,\n ContextMenuSubTrigger,\n ContextMenuRadioGroup,\n};\n"],"names":[],"mappings":";;;;;;;AAQA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAmBA;AAEA;AAaA;AAEA;AAeA;AAEA;AAgBA;AAEA;AAqBA;AACE;AAEF;AAoBA;AAEA;AAgBA;AAEA;AAUA;AAEA;AAIE;AASF;AACA;;"}
|
|
@@ -18,10 +18,10 @@ function DialogClose({ ...props }) {
|
|
|
18
18
|
// Dialogs share the Sheet's layers (overlay 1100, content 1101), so either
|
|
19
19
|
// can open over the other and both sit above app chrome.
|
|
20
20
|
function DialogOverlay({ className, ...props }) {
|
|
21
|
-
return (jsx(SheetPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn('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 fixed inset-0 z-
|
|
21
|
+
return (jsx(SheetPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn('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 fixed inset-0 z-(--z-modal-overlay) bg-black/30', className), ...props }));
|
|
22
22
|
}
|
|
23
23
|
function DialogContent({ className, children, showCloseButton = true, overlayClassName, ...props }) {
|
|
24
|
-
return (jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [jsx(DialogOverlay, { className: overlayClassName }), jsxs(SheetPrimitive.Content, { "data-slot": "dialog-content", className: cn('bg-background 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 fixed top-[50%] left-[50%] z-
|
|
24
|
+
return (jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [jsx(DialogOverlay, { className: overlayClassName }), jsxs(SheetPrimitive.Content, { "data-slot": "dialog-content", className: cn('bg-background 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 fixed top-[50%] left-[50%] z-(--z-modal) grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-card border border-border p-6 shadow-card duration-interactive ease-out-strong sm:max-w-lg', className), ...props, children: [children, showCloseButton && (jsxs(SheetPrimitive.Close, { "data-slot": "dialog-close", className: "absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4", children: [jsx(XIcon, {}), jsx("span", { className: "sr-only", children: "Close" })] }))] })] }));
|
|
25
25
|
}
|
|
26
26
|
function DialogHeader({ className, divider = false, ...props }) {
|
|
27
27
|
return (jsx("div", { "data-slot": "dialog-header", className: cn('flex flex-col gap-2 pr-10 text-left', divider && 'border-b border-border pb-4', className), ...props }));
|
|
@@ -39,7 +39,7 @@ function DialogDescription({ className, ...props }) {
|
|
|
39
39
|
return (jsx(SheetPrimitive.Description, { "data-slot": "dialog-description", className: cn('text-muted-foreground text-sm', className), ...props }));
|
|
40
40
|
}
|
|
41
41
|
function DialogBottomSheet({ className, children, showCloseButton = true, overlayClassName, ...props }) {
|
|
42
|
-
return (jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [jsx(DialogOverlay, { className: overlayClassName }), jsxs(SheetPrimitive.Content, { "data-slot": "dialog-content", className: cn('bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom fixed bottom-0 left-0 right-0 z-
|
|
42
|
+
return (jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [jsx(DialogOverlay, { className: overlayClassName }), jsxs(SheetPrimitive.Content, { "data-slot": "dialog-content", className: cn('bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom fixed bottom-0 left-0 right-0 z-(--z-modal) w-full max-h-[90dvh] overflow-y-auto rounded-t-card border-t border-border p-6 pb-[max(1.5rem,env(safe-area-inset-bottom))] shadow-card duration-interactive ease-out-strong', className), ...props, children: [children, showCloseButton && (jsxs(SheetPrimitive.Close, { "data-slot": "dialog-close", className: "absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4", children: [jsx(XIcon, {}), jsx("span", { className: "sr-only", children: "Close" })] }))] })] }));
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export { Dialog, DialogBottomSheet, DialogClose, DialogContent, DialogDescription, DialogDivider, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sources":["../../src/components/dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { XIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\nfunction Dialog({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\n// Dialogs share the Sheet's layers (overlay 1100, content 1101), so either\n// can open over the other and both sit above app chrome.\nfunction DialogOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n className={cn(\n '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 fixed inset-0 z-
|
|
1
|
+
{"version":3,"file":"dialog.js","sources":["../../src/components/dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { XIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\nfunction Dialog({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\n// Dialogs share the Sheet's layers (overlay 1100, content 1101), so either\n// can open over the other and both sit above app chrome.\nfunction DialogOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n className={cn(\n '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 fixed inset-0 z-(--z-modal-overlay) bg-black/30',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogContent({\n className,\n children,\n showCloseButton = true,\n overlayClassName,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Content> & {\n showCloseButton?: boolean;\n /** Classes for the backdrop, e.g. a lighter tint. */\n overlayClassName?: string;\n}) {\n return (\n <DialogPortal data-slot=\"dialog-portal\">\n <DialogOverlay className={overlayClassName} />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n className={cn(\n 'bg-background 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 fixed top-[50%] left-[50%] z-(--z-modal) grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-card border border-border p-6 shadow-card duration-interactive ease-out-strong sm:max-w-lg',\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot=\"dialog-close\"\n className=\"absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4\"\n >\n <XIcon />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n}\n\nfunction DialogHeader({ className, divider = false, ...props }: React.ComponentProps<'div'> & { divider?: boolean }) {\n return (\n <div\n data-slot=\"dialog-header\"\n className={cn('flex flex-col gap-2 pr-10 text-left', divider && 'border-b border-border pb-4', className)}\n {...props}\n />\n );\n}\n\nfunction DialogFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(\n 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogDivider({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"dialog-divider\"\n role=\"separator\"\n className={cn('h-px w-full bg-border', className)}\n {...props}\n />\n );\n}\n\nfunction DialogTitle({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Title>) {\n return (\n <DialogPrimitive.Title\n data-slot=\"dialog-title\"\n className={cn('text-xl leading-snug font-semibold', className)}\n {...props}\n />\n );\n}\n\nfunction DialogDescription({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Description>) {\n return (\n <DialogPrimitive.Description\n data-slot=\"dialog-description\"\n className={cn('text-muted-foreground text-sm', className)}\n {...props}\n />\n );\n}\n\nfunction DialogBottomSheet({\n className,\n children,\n showCloseButton = true,\n overlayClassName,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Content> & {\n showCloseButton?: boolean;\n /** Classes for the backdrop, e.g. a lighter tint. */\n overlayClassName?: string;\n}) {\n return (\n <DialogPortal data-slot=\"dialog-portal\">\n <DialogOverlay className={overlayClassName} />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n className={cn(\n 'bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom fixed bottom-0 left-0 right-0 z-(--z-modal) w-full max-h-[90dvh] overflow-y-auto rounded-t-card border-t border-border p-6 pb-[max(1.5rem,env(safe-area-inset-bottom))] shadow-card duration-interactive ease-out-strong',\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot=\"dialog-close\"\n className=\"absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4\"\n >\n <XIcon />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n}\n\nexport {\n Dialog,\n DialogBottomSheet,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogDivider,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n"],"names":["_jsx","DialogPrimitive","_jsxs"],"mappings":";;;;;AAMA,SAAS,MAAM,CAAC,EACd,GAAG,KAAK,EAC0C,EAAA;IAClD,OAAOA,GAAA,CAACC,cAAe,CAAC,IAAI,iBAAW,QAAQ,EAAA,GAAK,KAAK,EAAA,CAAI;AAC/D;AAEA,SAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EAC6C,EAAA;IACrD,OAAOD,GAAA,CAACC,cAAe,CAAC,OAAO,iBAAW,gBAAgB,EAAA,GAAK,KAAK,EAAA,CAAI;AAC1E;AAEA,SAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EAC4C,EAAA;IACpD,OAAOD,GAAA,CAACC,cAAe,CAAC,MAAM,iBAAW,eAAe,EAAA,GAAK,KAAK,EAAA,CAAI;AACxE;AAEA,SAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EAC2C,EAAA;IACnD,OAAOD,GAAA,CAACC,cAAe,CAAC,KAAK,iBAAW,cAAc,EAAA,GAAK,KAAK,EAAA,CAAI;AACtE;AAEA;AACA;AACA,SAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EAC6C,EAAA;IACrD,QACED,IAACC,cAAe,CAAC,OAAO,EAAA,EAAA,WAAA,EACZ,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CACX,oMAAoM,EACpM,SAAS,CACV,KACG,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,aAAa,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,eAAe,GAAG,IAAI,EACtB,gBAAgB,EAChB,GAAG,KAAK,EAKT,EAAA;AACC,IAAA,QACEC,IAAA,CAAC,YAAY,EAAA,EAAA,WAAA,EAAW,eAAe,EAAA,QAAA,EAAA,CACrCF,GAAA,CAAC,aAAa,EAAA,EAAC,SAAS,EAAE,gBAAgB,EAAA,CAAI,EAC9CE,IAAA,CAACD,cAAe,CAAC,OAAO,EAAA,EAAA,WAAA,EACZ,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CACV,qeAAqe,EACte,SAAS,CACV,EAAA,GACG,KAAK,EAAA,QAAA,EAAA,CAER,QAAQ,EACR,eAAe,KACdC,IAAA,CAACD,cAAe,CAAC,KAAK,EAAA,EAAA,WAAA,EACV,cAAc,EACvB,SAAS,EAAC,6UAA6U,EAAA,QAAA,EAAA,CAExVD,GAAA,CAAC,KAAK,EAAA,EAAA,CAAG,EACTA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,SAAS,EAAA,QAAA,EAAA,OAAA,EAAA,CAAa,CAAA,EAAA,CAChB,CACzB,CAAA,EAAA,CACuB,CAAA,EAAA,CACb;AAEnB;AAEA,SAAS,YAAY,CAAC,EAAE,SAAS,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,KAAK,EAAuD,EAAA;IACjH,QACEA,0BACY,eAAe,EACzB,SAAS,EAAE,EAAE,CAAC,qCAAqC,EAAE,OAAO,IAAI,6BAA6B,EAAE,SAAS,CAAC,KACrG,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B,EAAA;AACxE,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAA,WAAA,EACY,eAAe,EACzB,SAAS,EAAE,EAAE,CACX,wDAAwD,EACxD,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,aAAa,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B,EAAA;IACzE,QACEA,0BACY,gBAAgB,EAC1B,IAAI,EAAC,WAAW,EAChB,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC,KAC7C,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EAC2C,EAAA;IACnD,QACEA,IAACC,cAAe,CAAC,KAAK,EAAA,EAAA,WAAA,EACV,cAAc,EACxB,SAAS,EAAE,EAAE,CAAC,oCAAoC,EAAE,SAAS,CAAC,KAC1D,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACiD,EAAA;IACzD,QACED,IAACC,cAAe,CAAC,WAAW,EAAA,EAAA,WAAA,EAChB,oBAAoB,EAC9B,SAAS,EAAE,EAAE,CAAC,+BAA+B,EAAE,SAAS,CAAC,KACrD,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,QAAQ,EACR,eAAe,GAAG,IAAI,EACtB,gBAAgB,EAChB,GAAG,KAAK,EAKT,EAAA;AACC,IAAA,QACEC,IAAA,CAAC,YAAY,EAAA,EAAA,WAAA,EAAW,eAAe,EAAA,QAAA,EAAA,CACrCF,GAAA,CAAC,aAAa,EAAA,EAAC,SAAS,EAAE,gBAAgB,EAAA,CAAI,EAC9CE,IAAA,CAACD,cAAe,CAAC,OAAO,EAAA,EAAA,WAAA,EACZ,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CACV,+YAA+Y,EAChZ,SAAS,CACV,EAAA,GACG,KAAK,EAAA,QAAA,EAAA,CAER,QAAQ,EACR,eAAe,KACdC,IAAA,CAACD,cAAe,CAAC,KAAK,EAAA,EAAA,WAAA,EACV,cAAc,EACvB,SAAS,EAAC,6UAA6U,EAAA,QAAA,EAAA,CAExVD,GAAA,CAAC,KAAK,EAAA,EAAA,CAAG,EACTA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,SAAS,EAAA,QAAA,EAAA,OAAA,EAAA,CAAa,CAAA,EAAA,CAChB,CACzB,CAAA,EAAA,CACuB,CAAA,EAAA,CACb;AAEnB;;;;"}
|
|
@@ -14,12 +14,9 @@ function DropdownMenuTrigger({ ...props }) {
|
|
|
14
14
|
}
|
|
15
15
|
function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
|
|
16
16
|
return (jsx(DropdownMenuPrimitive.Portal, { children: jsx(DropdownMenuPrimitive.Content, { "data-slot": "dropdown-menu-content", sideOffset: sideOffset, className: cn(
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
// to clear that to render above a modal. Matches the same fix
|
|
21
|
-
// already applied to SelectContent (components/select.tsx).
|
|
22
|
-
'bg-popover text-popover-foreground 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 z-[1100] max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-control-lg border border-border p-option-inset shadow-card', className), ...props }) }));
|
|
17
|
+
// The popover layer: it portals to document.body beside any
|
|
18
|
+
// Dialog, so it must sit above the modal layer to show over one.
|
|
19
|
+
'bg-popover text-popover-foreground 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 z-(--z-popover) max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-control-lg border border-border p-option-inset shadow-card', className), ...props }) }));
|
|
23
20
|
}
|
|
24
21
|
function DropdownMenuGroup({ ...props }) {
|
|
25
22
|
return (jsx(DropdownMenuPrimitive.Group, { "data-slot": "dropdown-menu-group", ...props }));
|
|
@@ -53,8 +50,8 @@ function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
|
|
|
53
50
|
}
|
|
54
51
|
function DropdownMenuSubContent({ className, ...props }) {
|
|
55
52
|
return (jsx(DropdownMenuPrimitive.SubContent, { "data-slot": "dropdown-menu-sub-content", className: cn(
|
|
56
|
-
//
|
|
57
|
-
'bg-popover text-popover-foreground 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 z-
|
|
53
|
+
// The popover layer, like DropdownMenuContent above.
|
|
54
|
+
'bg-popover text-popover-foreground 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 z-(--z-popover) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-control-lg border border-border p-option-inset shadow-card', className), ...props }));
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-menu.js","sources":["../../src/components/dropdown-menu.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\nfunction DropdownMenu({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {\n return <DropdownMenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />;\n}\n\nfunction DropdownMenuPortal({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {\n return (\n <DropdownMenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" {...props} />\n );\n}\n\nfunction DropdownMenuTrigger({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {\n return (\n <DropdownMenuPrimitive.Trigger\n data-slot=\"dropdown-menu-trigger\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuContent({\n className,\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n data-slot=\"dropdown-menu-content\"\n sideOffset={sideOffset}\n className={cn(\n // z-[1100] (not the default z-50) — the shared modal system's\n // backdrop is z-[1000] (app/providers/modal-provider.tsx), and\n // this portals to document.body as a sibling of it, so it needs\n // to clear that to render above a modal. Matches the same fix\n // already applied to SelectContent (components/select.tsx).\n 'bg-popover text-popover-foreground 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 z-[1100] max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-control-lg border border-border p-option-inset shadow-card',\n className,\n )}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n );\n}\n\nfunction DropdownMenuGroup({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {\n return (\n <DropdownMenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />\n );\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = 'default',\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n variant?: 'default' | 'destructive';\n}) {\n return (\n <DropdownMenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"focus:bg-muted focus:text-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex min-h-option-row w-full cursor-pointer select-none items-center gap-2 rounded-control-sm px-option-x py-2 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-9 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n className={cn(\n \"focus:bg-muted focus:text-foreground relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm py-2 pr-option-x pl-9 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n checked={checked}\n {...props}\n >\n <span className=\"pointer-events-none absolute left-option-x flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n}\n\nfunction DropdownMenuRadioGroup({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {\n return (\n <DropdownMenuPrimitive.RadioGroup\n data-slot=\"dropdown-menu-radio-group\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {\n return (\n <DropdownMenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n className={cn(\n \"focus:bg-muted focus:text-foreground relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm py-2 pr-option-x pl-9 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute left-option-x flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CircleIcon className=\"size-2 fill-current\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n}) {\n return (\n <DropdownMenuPrimitive.Label\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n className={cn(\n 'px-option-x py-2 text-sm font-semibold text-foreground data-[inset]:pl-9',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {\n return (\n <DropdownMenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn('bg-border -mx-option-inset my-1 h-px', className)}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuShortcut({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n 'text-muted-foreground ml-auto text-xs tracking-widest',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSub({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {\n return <DropdownMenuPrimitive.Sub data-slot=\"dropdown-menu-sub\" {...props} />;\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n}) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n data-inset={inset}\n className={cn(\n 'focus:bg-muted focus:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground flex min-h-option-row cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[inset]:pl-9',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"ml-auto size-4 text-muted-foreground\" />\n </DropdownMenuPrimitive.SubTrigger>\n );\n}\n\nfunction DropdownMenuSubContent({\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {\n return (\n <DropdownMenuPrimitive.SubContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n // z-[1100] — see the matching note on DropdownMenuContent above.\n 'bg-popover text-popover-foreground 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 z-[1100] min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-control-lg border border-border p-option-inset shadow-card',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n};\n"],"names":["_jsx","_jsxs"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"dropdown-menu.js","sources":["../../src/components/dropdown-menu.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\nfunction DropdownMenu({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {\n return <DropdownMenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />;\n}\n\nfunction DropdownMenuPortal({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {\n return (\n <DropdownMenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" {...props} />\n );\n}\n\nfunction DropdownMenuTrigger({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {\n return (\n <DropdownMenuPrimitive.Trigger\n data-slot=\"dropdown-menu-trigger\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuContent({\n className,\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n data-slot=\"dropdown-menu-content\"\n sideOffset={sideOffset}\n className={cn(\n // The popover layer: it portals to document.body beside any\n // Dialog, so it must sit above the modal layer to show over one.\n 'bg-popover text-popover-foreground 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 z-(--z-popover) max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-control-lg border border-border p-option-inset shadow-card',\n className,\n )}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n );\n}\n\nfunction DropdownMenuGroup({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {\n return (\n <DropdownMenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />\n );\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = 'default',\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n variant?: 'default' | 'destructive';\n}) {\n return (\n <DropdownMenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"focus:bg-muted focus:text-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex min-h-option-row w-full cursor-pointer select-none items-center gap-2 rounded-control-sm px-option-x py-2 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-9 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n className={cn(\n \"focus:bg-muted focus:text-foreground relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm py-2 pr-option-x pl-9 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n checked={checked}\n {...props}\n >\n <span className=\"pointer-events-none absolute left-option-x flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n}\n\nfunction DropdownMenuRadioGroup({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {\n return (\n <DropdownMenuPrimitive.RadioGroup\n data-slot=\"dropdown-menu-radio-group\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {\n return (\n <DropdownMenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n className={cn(\n \"focus:bg-muted focus:text-foreground relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm py-2 pr-option-x pl-9 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute left-option-x flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CircleIcon className=\"size-2 fill-current\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n}) {\n return (\n <DropdownMenuPrimitive.Label\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n className={cn(\n 'px-option-x py-2 text-sm font-semibold text-foreground data-[inset]:pl-9',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {\n return (\n <DropdownMenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn('bg-border -mx-option-inset my-1 h-px', className)}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuShortcut({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n 'text-muted-foreground ml-auto text-xs tracking-widest',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSub({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {\n return <DropdownMenuPrimitive.Sub data-slot=\"dropdown-menu-sub\" {...props} />;\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n}) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n data-inset={inset}\n className={cn(\n 'focus:bg-muted focus:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground flex min-h-option-row cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[inset]:pl-9',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"ml-auto size-4 text-muted-foreground\" />\n </DropdownMenuPrimitive.SubTrigger>\n );\n}\n\nfunction DropdownMenuSubContent({\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {\n return (\n <DropdownMenuPrimitive.SubContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n // The popover layer, like DropdownMenuContent above.\n 'bg-popover text-popover-foreground 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 z-(--z-popover) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-control-lg border border-border p-option-inset shadow-card',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n};\n"],"names":["_jsx","_jsxs"],"mappings":"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"}
|
|
@@ -135,7 +135,7 @@ const GroupableRadioDropdown = ({ name, options, onChange, disabled, defaultValu
|
|
|
135
135
|
setIsOpen(false);
|
|
136
136
|
}, [activeDropdown, name]);
|
|
137
137
|
const selected = value || value === 0 ? options.find((o) => o.id === value) : undefined;
|
|
138
|
-
return (jsxs("div", { className: cn("relative w-full max-w-svw min-w-0", className), ref: ref, children: [jsxs(Button, { ref: triggerRef, type: "button", variant: "outline", disabled: disabled, size: size, onClick: handleClick, onTouchEnd: (e) => e.stopPropagation(), "aria-haspopup": "listbox", "aria-expanded": isOpen, className: cn("w-full max-w-full min-w-0", "h-auto py-1", fieldTriggerClassName, "flex items-center justify-between gap-2"), children: [jsx("span", { className: "flex-1 min-w-0 text-left pr-2 leading-relaxed", children: selected ? (jsx("span", { className: "block whitespace-normal wrap-break-word", children: selected.name })) : (jsx("span", { className: "text-muted-foreground/40 font-normal", children: fallback })) }), jsx(ChevronDown, { className: cn("shrink-0 w-4 h-4 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none", isOpen ? "rotate-180" : "") })] }), isOpen && (jsxs(MobileSheetPortal, { enabled: isMobile, children: [isMobile && (jsx("button", { type: "button", "aria-label": "Close options", tabIndex: -1, className: "fixed inset-0 z-
|
|
138
|
+
return (jsxs("div", { className: cn("relative w-full max-w-svw min-w-0", className), ref: ref, children: [jsxs(Button, { ref: triggerRef, type: "button", variant: "outline", disabled: disabled, size: size, onClick: handleClick, onTouchEnd: (e) => e.stopPropagation(), "aria-haspopup": "listbox", "aria-expanded": isOpen, className: cn("w-full max-w-full min-w-0", "h-auto py-1", fieldTriggerClassName, "flex items-center justify-between gap-2"), children: [jsx("span", { className: "flex-1 min-w-0 text-left pr-2 leading-relaxed", children: selected ? (jsx("span", { className: "block whitespace-normal wrap-break-word", children: selected.name })) : (jsx("span", { className: "text-muted-foreground/40 font-normal", children: fallback })) }), jsx(ChevronDown, { className: cn("shrink-0 w-4 h-4 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none", isOpen ? "rotate-180" : "") })] }), isOpen && (jsxs(MobileSheetPortal, { enabled: isMobile, children: [isMobile && (jsx("button", { type: "button", "aria-label": "Close options", tabIndex: -1, className: "fixed inset-0 z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]", onClick: closeSheet })), jsxs("div", { ref: isMobile ? sheetRef : undefined, role: isMobile ? "dialog" : undefined, "aria-modal": isMobile ? true : undefined, "aria-label": isMobile ? fallback : undefined, onKeyDown: isMobile
|
|
139
139
|
? (event) => {
|
|
140
140
|
if (event.key === "Escape") {
|
|
141
141
|
event.preventDefault();
|
|
@@ -159,7 +159,7 @@ const GroupableRadioDropdown = ({ name, options, onChange, disabled, defaultValu
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
: undefined, className: cn("border border-border bg-background shadow-card", isMobile
|
|
162
|
-
? "fixed left-0 right-0 z-
|
|
162
|
+
? "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))]"
|
|
163
163
|
: "absolute left-0 right-0 top-full z-[9999] mt-1 max-w-full overflow-hidden rounded-control-lg"), style: isMobile
|
|
164
164
|
? {
|
|
165
165
|
bottom: sheetViewport?.bottom ?? 0,
|
|
@@ -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-[1090] 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-[1100] 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';\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;;"}
|
|
@@ -6,7 +6,7 @@ import { cn } from '../utils.js';
|
|
|
6
6
|
|
|
7
7
|
const HoverCard = HoverCardPrimitive.Root;
|
|
8
8
|
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
9
|
-
const HoverCardContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => (jsx(HoverCardPrimitive.Portal, { children: jsx(HoverCardPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, className: cn("z-
|
|
9
|
+
const HoverCardContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => (jsx(HoverCardPrimitive.Portal, { children: jsx(HoverCardPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, className: cn("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", className), ...props }) })));
|
|
10
10
|
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
11
11
|
|
|
12
12
|
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
@@ -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-
|
|
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;;"}
|
package/dist/components/label.js
CHANGED
|
@@ -10,7 +10,7 @@ FieldLabel.displayName = 'FieldLabel';
|
|
|
10
10
|
/** The label row shared by every form field: label, help tooltip, addon. */
|
|
11
11
|
function Label({ label, required, tooltip, labelAddon, labelProps, className, }) {
|
|
12
12
|
const hasTooltip = !!tooltip?.trim();
|
|
13
|
-
return (jsxs("div", { className: cn('mb-field-label-gap flex w-full justify-between gap-2 md:items-center', className), children: [jsxs("div", { className: "flex gap-2 md:items-center", children: [jsxs(FieldLabel, { ...labelProps, children: [label, " ", required && jsx("span", { className: "text-destructive", children: "*" })] }), hasTooltip ? (jsxs(Tooltip, { children: [jsx(TooltipTrigger, { asChild: true, children: jsx("button", { type: "button", "aria-label": "More information", className: "hover:cursor-help", children: jsx(MessageCircleQuestion, { className: "text-primary h-3.5 w-3.5" }) }) }), jsx(TooltipContent, { side: "bottom", className: "z-
|
|
13
|
+
return (jsxs("div", { className: cn('mb-field-label-gap flex w-full justify-between gap-2 md:items-center', className), children: [jsxs("div", { className: "flex gap-2 md:items-center", children: [jsxs(FieldLabel, { ...labelProps, children: [label, " ", required && jsx("span", { className: "text-destructive", children: "*" })] }), hasTooltip ? (jsxs(Tooltip, { children: [jsx(TooltipTrigger, { asChild: true, children: jsx("button", { type: "button", "aria-label": "More information", className: "hover:cursor-help", children: jsx(MessageCircleQuestion, { className: "text-primary h-3.5 w-3.5" }) }) }), jsx(TooltipContent, { side: "bottom", className: "z-(--z-tooltip) max-w-[80vw]", children: tooltip })] })) : (
|
|
14
14
|
// Reserves the icon's space so labels line up with or without help.
|
|
15
15
|
jsx("div", { "aria-hidden": "true", children: jsx(MessageCircleQuestion, { className: cn('invisible h-3.5 w-3.5') }) }))] }), labelAddon && jsx("div", { children: labelAddon })] }));
|
|
16
16
|
}
|
|
@@ -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-
|
|
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;;;;"}
|
|
@@ -69,10 +69,10 @@ function FilterMenu(props) {
|
|
|
69
69
|
const list = jsx(CheckboxList, { "aria-label": title, items: items });
|
|
70
70
|
// Phones: a bottom sheet, like Autocomplete and Select.
|
|
71
71
|
if (isMobile)
|
|
72
|
-
return (jsxs(Fragment, { children: [trigger, jsx(Sheet, { open: open, onOpenChange: setOpen, children: jsxs(SheetContent, { side: "bottom", showCloseButton: false, overlayClassName: "z-
|
|
72
|
+
return (jsxs(Fragment, { children: [trigger, jsx(Sheet, { open: open, onOpenChange: setOpen, children: jsxs(SheetContent, { side: "bottom", showCloseButton: false, overlayClassName: "z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]", "aria-describedby": undefined, onOpenAutoFocus: (event) => {
|
|
73
73
|
event.preventDefault();
|
|
74
74
|
closeRef.current?.focus();
|
|
75
|
-
}, className: "flex flex-col gap-0 p-0 pb-[max(0.75rem,env(safe-area-inset-bottom))]", children: [jsxs("div", { className: "flex shrink-0 items-center justify-between gap-4 px-4 pb-1 pt-4", children: [jsx(SheetTitle, { className: "text-base font-semibold text-foreground", children: title }), jsx("button", { ref: closeRef, type: "button", "aria-label": "Close", 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", onClick: () => setOpen(false), children: jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })] }), jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-2", children: list }), jsxs("div", { className: "flex shrink-0 gap-2 border-t border-border px-4 pt-3", children: [clearInSheet && (jsx(Button, { type: "button", variant: "ghost", scheme: "neutral", className: "flex-1", onClick: clearInSheet, children: clearLabel })), jsx(Button, { type: "button", variant: "outline", className: "flex-1", onClick: () => setOpen(false), children: "Done" })] })] }) })] }));
|
|
75
|
+
}, className: "z-(--z-popover) flex flex-col gap-0 p-0 pb-[max(0.75rem,env(safe-area-inset-bottom))]", children: [jsxs("div", { className: "flex shrink-0 items-center justify-between gap-4 px-4 pb-1 pt-4", children: [jsx(SheetTitle, { className: "text-base font-semibold text-foreground", children: title }), jsx("button", { ref: closeRef, type: "button", "aria-label": "Close", 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", onClick: () => setOpen(false), children: jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })] }), jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-2", children: list }), jsxs("div", { className: "flex shrink-0 gap-2 border-t border-border px-4 pt-3", children: [clearInSheet && (jsx(Button, { type: "button", variant: "ghost", scheme: "neutral", className: "flex-1", onClick: clearInSheet, children: clearLabel })), jsx(Button, { type: "button", variant: "outline", className: "flex-1", onClick: () => setOpen(false), children: "Done" })] })] }) })] }));
|
|
76
76
|
return (jsxs(Popover, { open: open, onOpenChange: setOpen, children: [jsx(PopoverTrigger, { asChild: true, children: trigger }), jsxs(PopoverContent, { align: align, className: cn("w-56 p-0", contentClassName), children: [list, onClear && (jsx("div", { className: "border-t border-border p-option-inset", children: clearVariant === "button" ? (jsxs(Button, { type: "button", variant: "ghost", scheme: "neutral", size: "sm", className: "w-full", onClick: onClear, children: [jsx(X, { size: 16, "aria-hidden": "true" }), clearLabel] })) : (jsx(Button, { type: "button", variant: "link", scheme: "primary", size: "xs", onClick: onClear, children: clearLabel })) }))] })] }));
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option-list.js","sources":["../../src/components/option-list.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { ChevronDown, X } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\nimport { useMobile } from \"@/hooks/use-mobile\";\nimport { Button } from \"./button\";\nimport { Checkbox } from \"./checkbox\";\nimport { FilterChip } from \"./filter-chip\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\nimport { Sheet, SheetContent, SheetTitle } from \"./sheet\";\n\n/*\n * The shared look for every list of options (menus, selects, dropdowns,\n * autocomplete, filter menus): the list is inset from its container's edge,\n * and each row is its own rounded box with a little space between rows, so\n * hover and selection read as distinct pills rather than full-bleed stripes.\n */\n\n/** Padding + row gap for a list of options inside a popover or sheet. */\nexport const optionListClassName = \"flex flex-col gap-option-gap p-option-inset\";\n\n/** One option row. Pair with a hover/focus or selected state as needed. */\nexport const optionRowClassName =\n \"relative flex min-h-option-row w-full cursor-pointer select-none items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm text-foreground outline-none transition-colors duration-state hover:bg-muted focus-visible:bg-muted motion-reduce:transition-none max-md:min-h-11\";\n\nexport type CheckboxListItem = {\n label: React.ReactNode;\n checked: boolean;\n onCheckedChange: (checked: boolean) => void;\n /** Indents the row under a group heading row. */\n indent?: boolean;\n /** Bolder label, e.g. a group's \"All …\" row. */\n strong?: boolean;\n disabled?: boolean;\n};\n\n/** A list of checkbox rows in the shared option style. */\nexport function CheckboxList({\n items,\n className,\n \"aria-label\": label,\n}: {\n items: CheckboxListItem[];\n className?: string;\n \"aria-label\"?: string;\n}) {\n return (\n <ul\n aria-label={label}\n className={cn(\"m-0 list-none\", optionListClassName, className)}\n >\n {items.map((item, index) => (\n <li key={index}>\n <label\n className={cn(\n optionRowClassName,\n item.indent && \"pl-8\",\n item.strong && \"font-medium\",\n item.disabled && \"pointer-events-none opacity-50\",\n )}\n >\n <Checkbox\n checked={item.checked}\n disabled={item.disabled}\n onCheckedChange={(checked) =>\n item.onCheckedChange(checked === true)\n }\n />\n <span className=\"min-w-0 flex-1\">{item.label}</span>\n </label>\n </li>\n ))}\n </ul>\n );\n}\n\nexport type FilterMenuOption = { label: React.ReactNode; value: string };\n\ntype FilterMenuCommon = {\n /** The chip's label (and the sheet title when it's text). */\n label?: React.ReactNode;\n /** Replaces the default chip, e.g. a labelled field button. */\n trigger?: React.ReactElement<React.HTMLAttributes<HTMLElement>>;\n /** Sheet title / list name when `label` isn't plain text. */\n title?: string;\n /** Shows a clear action (popover footer and sheet footer). */\n onClear?: () => void;\n clearLabel?: string;\n /**\n * How the popover's clear looks: a small link (default), or a quiet\n * full-width button with an ✕, e.g. to match a neighbouring picker.\n */\n clearVariant?: \"link\" | \"button\";\n size?: \"xs\" | \"sm\" | \"md\";\n align?: \"start\" | \"center\" | \"end\";\n className?: string;\n contentClassName?: string;\n};\n\n/** Simple filters: options in, selected values out. */\ntype FilterMenuOptionsProps = FilterMenuCommon & {\n options: FilterMenuOption[];\n /** The selected option values. */\n value: string[];\n onValueChange: (value: string[]) => void;\n items?: never;\n};\n\n/** Lists with their own rules (groups, indents): the rows themselves. */\ntype FilterMenuItemsProps = FilterMenuCommon & {\n items: CheckboxListItem[];\n options?: never;\n value?: never;\n onValueChange?: never;\n};\n\nexport type FilterMenuProps = FilterMenuOptionsProps | FilterMenuItemsProps;\n\n/**\n * A checklist behind a trigger: a dropdown on desktop and a bottom sheet\n * (with Clear and Done) on phones. Each tick applies immediately.\n *\n * Feed it either `options` + `value` + `onValueChange` (simple filters; the\n * default trigger is a FilterChip showing the count in the selected,\n * secondary style), or ready-made `items` with your own `trigger`.\n */\nexport function FilterMenu(props: FilterMenuProps) {\n const {\n label,\n trigger: customTrigger,\n title: titleProp,\n onClear,\n clearLabel = \"Clear\",\n clearVariant = \"link\",\n size = \"sm\",\n align = \"start\",\n className,\n contentClassName,\n } = props;\n const isMobile = useMobile();\n const [open, setOpen] = React.useState(false);\n const closeRef = React.useRef<HTMLButtonElement>(null);\n\n // Both ways in become the same rows.\n const items: CheckboxListItem[] =\n props.items ??\n props.options.map((option) => ({\n label: option.label,\n checked: props.value.includes(option.value),\n onCheckedChange: (on) =>\n props.onValueChange(\n on\n ? [...props.value, option.value]\n : props.value.filter((item) => item !== option.value),\n ),\n }));\n const count = props.items\n ? props.items.filter((item) => item.checked).length\n : props.value.length;\n const title = titleProp ?? (typeof label === \"string\" ? label : \"Filter\");\n // The sheet always offers Clear while something's on; the popover only\n // when the caller asks for it.\n const clearInSheet =\n onClear ??\n (!props.items && count > 0 ? () => props.onValueChange([]) : undefined);\n\n const triggerProps = {\n \"aria-haspopup\": \"dialog\" as const,\n \"aria-expanded\": open,\n onClick: isMobile ? () => setOpen(true) : undefined,\n };\n const trigger = customTrigger ? (\n React.cloneElement(customTrigger, {\n ...triggerProps,\n onClick: (event: React.MouseEvent<HTMLElement>) => {\n customTrigger.props.onClick?.(event);\n triggerProps.onClick?.();\n },\n })\n ) : (\n <FilterChip\n size={size}\n selected={count > 0}\n count={count || undefined}\n className={className}\n {...triggerProps}\n >\n {label}\n <ChevronDown size={14} aria-hidden=\"true\" className=\"-mr-1\" />\n </FilterChip>\n );\n\n const list = <CheckboxList aria-label={title} items={items} />;\n\n // Phones: a bottom sheet, like Autocomplete and Select.\n if (isMobile)\n return (\n <>\n {trigger}\n <Sheet open={open} onOpenChange={setOpen}>\n <SheetContent\n side=\"bottom\"\n showCloseButton={false}\n overlayClassName=\"z-[1090] bg-black/25 backdrop-blur-[1px]\"\n aria-describedby={undefined}\n onOpenAutoFocus={(event) => {\n event.preventDefault();\n closeRef.current?.focus();\n }}\n className=\"flex flex-col gap-0 p-0 pb-[max(0.75rem,env(safe-area-inset-bottom))]\"\n >\n <div className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-1 pt-4\">\n <SheetTitle className=\"text-base font-semibold text-foreground\">\n {title}\n </SheetTitle>\n <button\n ref={closeRef}\n type=\"button\"\n aria-label=\"Close\"\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={() => setOpen(false)}\n >\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto overscroll-contain px-2\">\n {list}\n </div>\n <div className=\"flex shrink-0 gap-2 border-t border-border px-4 pt-3\">\n {clearInSheet && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n scheme=\"neutral\"\n className=\"flex-1\"\n onClick={clearInSheet}\n >\n {clearLabel}\n </Button>\n )}\n {/* Outline, like Autocomplete's: ticks already applied, so\n Done only closes the sheet. */}\n <Button\n type=\"button\"\n variant=\"outline\"\n className=\"flex-1\"\n onClick={() => setOpen(false)}\n >\n Done\n </Button>\n </div>\n </SheetContent>\n </Sheet>\n </>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>{trigger}</PopoverTrigger>\n <PopoverContent\n align={align}\n className={cn(\"w-56 p-0\", contentClassName)}\n >\n {list}\n {onClear && (\n <div className=\"border-t border-border p-option-inset\">\n {clearVariant === \"button\" ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n scheme=\"neutral\"\n size=\"sm\"\n className=\"w-full\"\n onClick={onClear}\n >\n <X size={16} aria-hidden=\"true\" />\n {clearLabel}\n </Button>\n ) : (\n <Button\n type=\"button\"\n variant=\"link\"\n scheme=\"primary\"\n size=\"xs\"\n onClick={onClear}\n >\n {clearLabel}\n </Button>\n )}\n </div>\n )}\n </PopoverContent>\n </Popover>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAaA;;;;;AAKG;AAEH;AACO;AAEP;AACO;AAcP;AACM;;AAqCN;AA4CA;;;;;;;AAOG;AACG;AACJ;AAYA;AACA;;;AAIA;;;;;;AASU;AAEP;AACH;AACE;AACA;AACF;;;;;AAOA;AACE;AACA;AACA;;AAEF;AAEI;AACA;;AAEE;;;;;AAmBN;AACE;;AAWU;AACF;AAgDV;AAsCF;;"}
|
|
1
|
+
{"version":3,"file":"option-list.js","sources":["../../src/components/option-list.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { ChevronDown, X } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\nimport { useMobile } from \"@/hooks/use-mobile\";\nimport { Button } from \"./button\";\nimport { Checkbox } from \"./checkbox\";\nimport { FilterChip } from \"./filter-chip\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\nimport { Sheet, SheetContent, SheetTitle } from \"./sheet\";\n\n/*\n * The shared look for every list of options (menus, selects, dropdowns,\n * autocomplete, filter menus): the list is inset from its container's edge,\n * and each row is its own rounded box with a little space between rows, so\n * hover and selection read as distinct pills rather than full-bleed stripes.\n */\n\n/** Padding + row gap for a list of options inside a popover or sheet. */\nexport const optionListClassName = \"flex flex-col gap-option-gap p-option-inset\";\n\n/** One option row. Pair with a hover/focus or selected state as needed. */\nexport const optionRowClassName =\n \"relative flex min-h-option-row w-full cursor-pointer select-none items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm text-foreground outline-none transition-colors duration-state hover:bg-muted focus-visible:bg-muted motion-reduce:transition-none max-md:min-h-11\";\n\nexport type CheckboxListItem = {\n label: React.ReactNode;\n checked: boolean;\n onCheckedChange: (checked: boolean) => void;\n /** Indents the row under a group heading row. */\n indent?: boolean;\n /** Bolder label, e.g. a group's \"All …\" row. */\n strong?: boolean;\n disabled?: boolean;\n};\n\n/** A list of checkbox rows in the shared option style. */\nexport function CheckboxList({\n items,\n className,\n \"aria-label\": label,\n}: {\n items: CheckboxListItem[];\n className?: string;\n \"aria-label\"?: string;\n}) {\n return (\n <ul\n aria-label={label}\n className={cn(\"m-0 list-none\", optionListClassName, className)}\n >\n {items.map((item, index) => (\n <li key={index}>\n <label\n className={cn(\n optionRowClassName,\n item.indent && \"pl-8\",\n item.strong && \"font-medium\",\n item.disabled && \"pointer-events-none opacity-50\",\n )}\n >\n <Checkbox\n checked={item.checked}\n disabled={item.disabled}\n onCheckedChange={(checked) =>\n item.onCheckedChange(checked === true)\n }\n />\n <span className=\"min-w-0 flex-1\">{item.label}</span>\n </label>\n </li>\n ))}\n </ul>\n );\n}\n\nexport type FilterMenuOption = { label: React.ReactNode; value: string };\n\ntype FilterMenuCommon = {\n /** The chip's label (and the sheet title when it's text). */\n label?: React.ReactNode;\n /** Replaces the default chip, e.g. a labelled field button. */\n trigger?: React.ReactElement<React.HTMLAttributes<HTMLElement>>;\n /** Sheet title / list name when `label` isn't plain text. */\n title?: string;\n /** Shows a clear action (popover footer and sheet footer). */\n onClear?: () => void;\n clearLabel?: string;\n /**\n * How the popover's clear looks: a small link (default), or a quiet\n * full-width button with an ✕, e.g. to match a neighbouring picker.\n */\n clearVariant?: \"link\" | \"button\";\n size?: \"xs\" | \"sm\" | \"md\";\n align?: \"start\" | \"center\" | \"end\";\n className?: string;\n contentClassName?: string;\n};\n\n/** Simple filters: options in, selected values out. */\ntype FilterMenuOptionsProps = FilterMenuCommon & {\n options: FilterMenuOption[];\n /** The selected option values. */\n value: string[];\n onValueChange: (value: string[]) => void;\n items?: never;\n};\n\n/** Lists with their own rules (groups, indents): the rows themselves. */\ntype FilterMenuItemsProps = FilterMenuCommon & {\n items: CheckboxListItem[];\n options?: never;\n value?: never;\n onValueChange?: never;\n};\n\nexport type FilterMenuProps = FilterMenuOptionsProps | FilterMenuItemsProps;\n\n/**\n * A checklist behind a trigger: a dropdown on desktop and a bottom sheet\n * (with Clear and Done) on phones. Each tick applies immediately.\n *\n * Feed it either `options` + `value` + `onValueChange` (simple filters; the\n * default trigger is a FilterChip showing the count in the selected,\n * secondary style), or ready-made `items` with your own `trigger`.\n */\nexport function FilterMenu(props: FilterMenuProps) {\n const {\n label,\n trigger: customTrigger,\n title: titleProp,\n onClear,\n clearLabel = \"Clear\",\n clearVariant = \"link\",\n size = \"sm\",\n align = \"start\",\n className,\n contentClassName,\n } = props;\n const isMobile = useMobile();\n const [open, setOpen] = React.useState(false);\n const closeRef = React.useRef<HTMLButtonElement>(null);\n\n // Both ways in become the same rows.\n const items: CheckboxListItem[] =\n props.items ??\n props.options.map((option) => ({\n label: option.label,\n checked: props.value.includes(option.value),\n onCheckedChange: (on) =>\n props.onValueChange(\n on\n ? [...props.value, option.value]\n : props.value.filter((item) => item !== option.value),\n ),\n }));\n const count = props.items\n ? props.items.filter((item) => item.checked).length\n : props.value.length;\n const title = titleProp ?? (typeof label === \"string\" ? label : \"Filter\");\n // The sheet always offers Clear while something's on; the popover only\n // when the caller asks for it.\n const clearInSheet =\n onClear ??\n (!props.items && count > 0 ? () => props.onValueChange([]) : undefined);\n\n const triggerProps = {\n \"aria-haspopup\": \"dialog\" as const,\n \"aria-expanded\": open,\n onClick: isMobile ? () => setOpen(true) : undefined,\n };\n const trigger = customTrigger ? (\n React.cloneElement(customTrigger, {\n ...triggerProps,\n onClick: (event: React.MouseEvent<HTMLElement>) => {\n customTrigger.props.onClick?.(event);\n triggerProps.onClick?.();\n },\n })\n ) : (\n <FilterChip\n size={size}\n selected={count > 0}\n count={count || undefined}\n className={className}\n {...triggerProps}\n >\n {label}\n <ChevronDown size={14} aria-hidden=\"true\" className=\"-mr-1\" />\n </FilterChip>\n );\n\n const list = <CheckboxList aria-label={title} items={items} />;\n\n // Phones: a bottom sheet, like Autocomplete and Select.\n if (isMobile)\n return (\n <>\n {trigger}\n <Sheet open={open} onOpenChange={setOpen}>\n <SheetContent\n side=\"bottom\"\n showCloseButton={false}\n overlayClassName=\"z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]\"\n aria-describedby={undefined}\n onOpenAutoFocus={(event) => {\n event.preventDefault();\n closeRef.current?.focus();\n }}\n className=\"z-(--z-popover) flex flex-col gap-0 p-0 pb-[max(0.75rem,env(safe-area-inset-bottom))]\"\n >\n <div className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-1 pt-4\">\n <SheetTitle className=\"text-base font-semibold text-foreground\">\n {title}\n </SheetTitle>\n <button\n ref={closeRef}\n type=\"button\"\n aria-label=\"Close\"\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={() => setOpen(false)}\n >\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto overscroll-contain px-2\">\n {list}\n </div>\n <div className=\"flex shrink-0 gap-2 border-t border-border px-4 pt-3\">\n {clearInSheet && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n scheme=\"neutral\"\n className=\"flex-1\"\n onClick={clearInSheet}\n >\n {clearLabel}\n </Button>\n )}\n {/* Outline, like Autocomplete's: ticks already applied, so\n Done only closes the sheet. */}\n <Button\n type=\"button\"\n variant=\"outline\"\n className=\"flex-1\"\n onClick={() => setOpen(false)}\n >\n Done\n </Button>\n </div>\n </SheetContent>\n </Sheet>\n </>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>{trigger}</PopoverTrigger>\n <PopoverContent\n align={align}\n className={cn(\"w-56 p-0\", contentClassName)}\n >\n {list}\n {onClear && (\n <div className=\"border-t border-border p-option-inset\">\n {clearVariant === \"button\" ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n scheme=\"neutral\"\n size=\"sm\"\n className=\"w-full\"\n onClick={onClear}\n >\n <X size={16} aria-hidden=\"true\" />\n {clearLabel}\n </Button>\n ) : (\n <Button\n type=\"button\"\n variant=\"link\"\n scheme=\"primary\"\n size=\"xs\"\n onClick={onClear}\n >\n {clearLabel}\n </Button>\n )}\n </div>\n )}\n </PopoverContent>\n </Popover>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAaA;;;;;AAKG;AAEH;AACO;AAEP;AACO;AAcP;AACM;;AAqCN;AA4CA;;;;;;;AAOG;AACG;AACJ;AAYA;AACA;;;AAIA;;;;;;AASU;AAEP;AACH;AACE;AACA;AACF;;;;;AAOA;AACE;AACA;AACA;;AAEF;AAEI;AACA;;AAEE;;;;;AAmBN;AACE;;AAWU;AACF;AAgDV;AAsCF;;"}
|
|
@@ -8,7 +8,7 @@ function Popover({ ...props }) {
|
|
|
8
8
|
}
|
|
9
9
|
const PopoverTrigger = React.forwardRef(({ className, ...props }, ref) => (jsx(PopoverPrimitive.Trigger, { ref: ref, className: className, "data-slot": "popover-trigger", ...props })));
|
|
10
10
|
PopoverTrigger.displayName = PopoverPrimitive.Trigger.displayName;
|
|
11
|
-
const PopoverContent = React.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (jsx(PopoverPrimitive.Portal, { children: jsx(PopoverPrimitive.Content, { ref: ref, "data-slot": "popover-content", align: align, sideOffset: sideOffset, className: cn('bg-popover text-popover-foreground 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 z-
|
|
11
|
+
const PopoverContent = React.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (jsx(PopoverPrimitive.Portal, { children: jsx(PopoverPrimitive.Content, { ref: ref, "data-slot": "popover-content", align: align, sideOffset: sideOffset, className: cn('bg-popover text-popover-foreground 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 z-(--z-popover) w-72 origin-(--radix-popover-content-transform-origin) rounded-card border border-border p-4 shadow-card outline-hidden', className), ...props }) })));
|
|
12
12
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
13
13
|
const PopoverAnchor = React.forwardRef(({ className, ...props }, ref) => (jsx(PopoverPrimitive.Anchor, { ref: ref, "data-slot": "popover-anchor", className: className, ...props })));
|
|
14
14
|
PopoverAnchor.displayName = PopoverPrimitive.Anchor.displayName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../src/components/popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { cn } from '@/utils';\n\nfunction Popover({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\nconst PopoverTrigger = React.forwardRef<\n React.ElementRef<typeof PopoverPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Trigger>\n>(({ className, ...props }, ref) => (\n <PopoverPrimitive.Trigger\n ref={ref}\n className={className}\n data-slot=\"popover-trigger\"\n {...props}\n />\n));\nPopoverTrigger.displayName = PopoverPrimitive.Trigger.displayName;\n\nconst PopoverContent = React.forwardRef<\n React.ElementRef<typeof PopoverPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\n>(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n ref={ref}\n data-slot=\"popover-content\"\n align={align}\n sideOffset={sideOffset}\n className={cn(\n 'bg-popover text-popover-foreground 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 z-
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../src/components/popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { cn } from '@/utils';\n\nfunction Popover({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\nconst PopoverTrigger = React.forwardRef<\n React.ElementRef<typeof PopoverPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Trigger>\n>(({ className, ...props }, ref) => (\n <PopoverPrimitive.Trigger\n ref={ref}\n className={className}\n data-slot=\"popover-trigger\"\n {...props}\n />\n));\nPopoverTrigger.displayName = PopoverPrimitive.Trigger.displayName;\n\nconst PopoverContent = React.forwardRef<\n React.ElementRef<typeof PopoverPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\n>(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n ref={ref}\n data-slot=\"popover-content\"\n align={align}\n sideOffset={sideOffset}\n className={cn(\n 'bg-popover text-popover-foreground 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 z-(--z-popover) w-72 origin-(--radix-popover-content-transform-origin) rounded-card border border-border p-4 shadow-card outline-hidden',\n className,\n )}\n {...props}\n />\n </PopoverPrimitive.Portal>\n));\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\n\nconst PopoverAnchor = React.forwardRef<\n React.ElementRef<typeof PopoverPrimitive.Anchor>,\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Anchor>\n>(({ className, ...props }, ref) => (\n <PopoverPrimitive.Anchor\n ref={ref}\n data-slot=\"popover-anchor\"\n className={className}\n {...props}\n />\n));\nPopoverAnchor.displayName = PopoverPrimitive.Anchor.displayName;\n\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };\n"],"names":["_jsx"],"mappings":";;;;;AAKA,SAAS,OAAO,CAAC,EACf,GAAG,KAAK,EAC2C,EAAA;IACnD,OAAOA,GAAA,CAAC,gBAAgB,CAAC,IAAI,iBAAW,SAAS,EAAA,GAAK,KAAK,EAAA,CAAI;AACjE;AAEA,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAGrC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,MAC7BA,GAAA,CAAC,gBAAgB,CAAC,OAAO,EAAA,EACvB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,eACV,iBAAiB,EAAA,GACvB,KAAK,EAAA,CACT,CACH;AACD,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,WAAW;AAEjE,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAGrC,CAAC,EAAE,SAAS,EAAE,KAAK,GAAG,QAAQ,EAAE,UAAU,GAAG,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,MAC/DA,GAAA,CAAC,gBAAgB,CAAC,MAAM,EAAA,EAAA,QAAA,EACtBA,GAAA,CAAC,gBAAgB,CAAC,OAAO,EAAA,EACvB,GAAG,EAAE,GAAG,EAAA,WAAA,EACE,iBAAiB,EAC3B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,EAAE,CACX,whBAAwhB,EACxhB,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT,EAAA,CACsB,CAC3B;AACD,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,WAAW;AAEjE,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAGpC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,MAC7BA,GAAA,CAAC,gBAAgB,CAAC,MAAM,EAAA,EACtB,GAAG,EAAE,GAAG,EAAA,WAAA,EACE,gBAAgB,EAC1B,SAAS,EAAE,SAAS,EAAA,GAChB,KAAK,EAAA,CACT,CACH;AACD,aAAa,CAAC,WAAW,GAAG,gBAAgB,CAAC,MAAM,CAAC,WAAW;;;;"}
|
|
@@ -32,9 +32,9 @@ const SelectContent = React.forwardRef(({ className, children, position = 'poppe
|
|
|
32
32
|
const mobile = useMobile();
|
|
33
33
|
const { open, setOpen } = React.useContext(SelectContext);
|
|
34
34
|
const viewport = useMobileSheetViewport(open && mobile);
|
|
35
|
-
return (jsx(SelectPrimitive.Portal, { children: jsxs("div", { className: mobile ? '[&>[data-radix-popper-content-wrapper]]:!fixed [&>[data-radix-popper-content-wrapper]]:!inset-x-0 [&>[data-radix-popper-content-wrapper]]:!top-auto [&>[data-radix-popper-content-wrapper]]:!bottom-[var(--select-sheet-bottom)] [&>[data-radix-popper-content-wrapper]]:!transform-none [&>[data-radix-popper-content-wrapper]]:!z-
|
|
35
|
+
return (jsx(SelectPrimitive.Portal, { children: jsxs("div", { className: mobile ? '[&>[data-radix-popper-content-wrapper]]:!fixed [&>[data-radix-popper-content-wrapper]]:!inset-x-0 [&>[data-radix-popper-content-wrapper]]:!top-auto [&>[data-radix-popper-content-wrapper]]:!bottom-[var(--select-sheet-bottom)] [&>[data-radix-popper-content-wrapper]]:!transform-none [&>[data-radix-popper-content-wrapper]]:!z-(--z-popover) [&>[data-radix-popper-content-wrapper]]:!min-w-0' : undefined, style: { '--select-sheet-bottom': `${viewport?.bottom ?? 0}px` }, children: [mobile && open && (jsx("div", { "aria-hidden": "true", className: "fixed inset-0 z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]" })), jsxs(SelectPrimitive.Content, { ref: ref, className: cn('relative flex flex-col overflow-hidden border border-border bg-background text-sm text-foreground shadow-card duration-interactive ease-out-strong motion-reduce:animate-none', mobile
|
|
36
36
|
? 'w-full rounded-t-control-lg border-b-0 pb-[env(safe-area-inset-bottom)]'
|
|
37
|
-
: 'z-
|
|
37
|
+
: 'z-(--z-popover) max-h-[400px] min-w-[8rem] rounded-control-lg data-[state=open]:animate-in 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', className), position: mobile ? 'popper' : position, sideOffset: 4, style: {
|
|
38
38
|
...(mobile ? { maxHeight: viewport ? Math.min(viewport.height, 640) : '80dvh' } : {}),
|
|
39
39
|
...style,
|
|
40
40
|
}, ...props, children: [mobile && (jsxs("div", { role: "presentation", className: "flex shrink-0 items-center justify-between gap-4 px-4 pb-3 pt-4", children: [jsx("h2", { className: "text-base font-semibold text-foreground", children: title }), jsx("button", { type: "button", "aria-label": "Close options", className: "-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted", onPointerDown: (event) => event.stopPropagation(), onClick: () => setOpen(false), children: jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })] })), !mobile && jsx(SelectScrollUpButton, {}), jsx(SelectPrimitive.Viewport, { className: cn('flex min-h-0 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset', mobile ? 'w-full flex-1' : position === 'popper' && 'w-full min-w-[var(--radix-select-trigger-width)]'), children: children }), !mobile && jsx(SelectScrollDownButton, {})] })] }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sources":["../../src/components/select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { Check, ChevronDown, ChevronUp, X } from 'lucide-react';\n\nimport { cn } from '@/utils';\nimport { fieldInteractionClassName } from '@/hooks/use-field-focus';\nimport { useMobile } from '@/hooks/use-mobile';\nimport { useMobileSheetViewport } from '@/hooks/use-mobile-sheet-viewport';\n\nconst SelectContext = React.createContext({ open: false, setOpen: (_open: boolean) => {} });\n\nfunction Select({ open: controlledOpen, defaultOpen = false, onOpenChange, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n const open = controlledOpen ?? internalOpen;\n const setOpen = (next: boolean) => {\n if (controlledOpen === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n return (\n <SelectContext.Provider value={{ open, setOpen }}>\n <SelectPrimitive.Root {...props} open={open} onOpenChange={setOpen}>\n {children}\n </SelectPrimitive.Root>\n </SelectContext.Provider>\n );\n}\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n 'group bg-background text-foreground placeholder:text-muted-foreground/40 data-[placeholder]:text-muted-foreground/40 border-input enabled:hover:border-input-hover flex h-form-control min-h-form-control max-h-form-control w-full cursor-pointer items-center justify-between gap-2 rounded-control-lg border px-field-padding-x py-0 text-base font-normal outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',\n 'focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue',\n fieldInteractionClassName,\n className,\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-interactive ease-out-strong group-data-[state=open]:rotate-180 motion-reduce:transition-none\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n));\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronUp className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName =\n SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & { title?: string }\n>(({ className, children, position = 'popper', title = 'Choose an option', style, ...props }, ref) => {\n const mobile = useMobile();\n const { open, setOpen } = React.useContext(SelectContext);\n const viewport = useMobileSheetViewport(open && mobile);\n\n return (\n <SelectPrimitive.Portal>\n <div\n className={mobile ? '[&>[data-radix-popper-content-wrapper]]:!fixed [&>[data-radix-popper-content-wrapper]]:!inset-x-0 [&>[data-radix-popper-content-wrapper]]:!top-auto [&>[data-radix-popper-content-wrapper]]:!bottom-[var(--select-sheet-bottom)] [&>[data-radix-popper-content-wrapper]]:!transform-none [&>[data-radix-popper-content-wrapper]]:!z-
|
|
1
|
+
{"version":3,"file":"select.js","sources":["../../src/components/select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { Check, ChevronDown, ChevronUp, X } from 'lucide-react';\n\nimport { cn } from '@/utils';\nimport { fieldInteractionClassName } from '@/hooks/use-field-focus';\nimport { useMobile } from '@/hooks/use-mobile';\nimport { useMobileSheetViewport } from '@/hooks/use-mobile-sheet-viewport';\n\nconst SelectContext = React.createContext({ open: false, setOpen: (_open: boolean) => {} });\n\nfunction Select({ open: controlledOpen, defaultOpen = false, onOpenChange, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n const open = controlledOpen ?? internalOpen;\n const setOpen = (next: boolean) => {\n if (controlledOpen === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n return (\n <SelectContext.Provider value={{ open, setOpen }}>\n <SelectPrimitive.Root {...props} open={open} onOpenChange={setOpen}>\n {children}\n </SelectPrimitive.Root>\n </SelectContext.Provider>\n );\n}\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n 'group bg-background text-foreground placeholder:text-muted-foreground/40 data-[placeholder]:text-muted-foreground/40 border-input enabled:hover:border-input-hover flex h-form-control min-h-form-control max-h-form-control w-full cursor-pointer items-center justify-between gap-2 rounded-control-lg border px-field-padding-x py-0 text-base font-normal outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',\n 'focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue',\n fieldInteractionClassName,\n className,\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-interactive ease-out-strong group-data-[state=open]:rotate-180 motion-reduce:transition-none\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n));\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronUp className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName =\n SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & { title?: string }\n>(({ className, children, position = 'popper', title = 'Choose an option', style, ...props }, ref) => {\n const mobile = useMobile();\n const { open, setOpen } = React.useContext(SelectContext);\n const viewport = useMobileSheetViewport(open && mobile);\n\n return (\n <SelectPrimitive.Portal>\n <div\n className={mobile ? '[&>[data-radix-popper-content-wrapper]]:!fixed [&>[data-radix-popper-content-wrapper]]:!inset-x-0 [&>[data-radix-popper-content-wrapper]]:!top-auto [&>[data-radix-popper-content-wrapper]]:!bottom-[var(--select-sheet-bottom)] [&>[data-radix-popper-content-wrapper]]:!transform-none [&>[data-radix-popper-content-wrapper]]:!z-(--z-popover) [&>[data-radix-popper-content-wrapper]]:!min-w-0' : undefined}\n style={{ '--select-sheet-bottom': `${viewport?.bottom ?? 0}px` } as React.CSSProperties}\n >\n {mobile && open && (\n <div aria-hidden=\"true\" className=\"fixed inset-0 z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]\" />\n )}\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'relative flex flex-col overflow-hidden border border-border bg-background text-sm text-foreground shadow-card duration-interactive ease-out-strong motion-reduce:animate-none',\n mobile\n ? 'w-full rounded-t-control-lg border-b-0 pb-[env(safe-area-inset-bottom)]'\n : 'z-(--z-popover) max-h-[400px] min-w-[8rem] rounded-control-lg data-[state=open]:animate-in 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',\n className,\n )}\n position={mobile ? 'popper' : position}\n sideOffset={4}\n style={{\n ...(mobile ? { maxHeight: viewport ? Math.min(viewport.height, 640) : '80dvh' } : {}),\n ...style,\n }}\n {...props}\n >\n {mobile && (\n <div role=\"presentation\" className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-3 pt-4\">\n <h2 className=\"text-base font-semibold text-foreground\">{title}</h2>\n <button\n type=\"button\"\n aria-label=\"Close options\"\n className=\"-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\n onPointerDown={(event) => event.stopPropagation()}\n onClick={() => setOpen(false)}\n >\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n )}\n {!mobile && <SelectScrollUpButton />}\n <SelectPrimitive.Viewport\n className={cn(\n 'flex min-h-0 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset',\n mobile ? 'w-full flex-1' : position === 'popper' && 'w-full min-w-[var(--radix-select-trigger-width)]',\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n {!mobile && <SelectScrollDownButton />}\n </SelectPrimitive.Content>\n </div>\n </SelectPrimitive.Portal>\n );\n});\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('px-option-x py-2 text-sm font-semibold text-foreground', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 pr-9 text-sm text-muted-foreground outline-none select-none transition-colors duration-interactive ease-out-strong focus:bg-muted data-[state=checked]:bg-primary-tint data-[disabled]:pointer-events-none data-[disabled]:opacity-50 motion-reduce:transition-none max-md:min-h-12',\n className,\n )}\n {...props}\n >\n <span className=\"absolute right-option-x flex h-4 w-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('bg-border h-px', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n"],"names":[],"mappings":";;;;;;;;;;AAWA;AAEA;AACE;AACA;AACA;;;AAEE;AACF;AAEA;AAOF;AAEA;AAEA;AAEA;AAoBA;AAEA;AAeA;AAEA;AAeA;AACE;AAEF;AAIE;AACA;;AAGA;AAcQ;;AAOF;AACA;;AAgCR;AACA;AAEA;AAUA;AAEA;AAqBA;AAEA;AAUA;;"}
|
package/dist/components/sheet.js
CHANGED
|
@@ -10,9 +10,9 @@ const Sheet = SheetPrimitive.Root;
|
|
|
10
10
|
const SheetTrigger = SheetPrimitive.Trigger;
|
|
11
11
|
const SheetClose = SheetPrimitive.Close;
|
|
12
12
|
const SheetPortal = SheetPrimitive.Portal;
|
|
13
|
-
const SheetOverlay = React.forwardRef(({ className, ...props }, ref) => (jsx(SheetPrimitive.Overlay, { className: cn("fixed inset-0 z-
|
|
13
|
+
const SheetOverlay = React.forwardRef(({ className, ...props }, ref) => (jsx(SheetPrimitive.Overlay, { className: cn("fixed inset-0 z-(--z-modal-overlay) bg-black/30 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", className), ...props, ref: ref })));
|
|
14
14
|
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
|
15
|
-
const sheetVariants = cva("fixed z-
|
|
15
|
+
const sheetVariants = cva("fixed z-(--z-modal) gap-4 overflow-y-auto overscroll-contain border-border bg-background p-6 text-base text-foreground shadow-card transition ease-out-strong data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-200", {
|
|
16
16
|
variants: {
|
|
17
17
|
side: {
|
|
18
18
|
top: "inset-x-0 top-0 max-h-[90dvh] rounded-b-control-lg border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.js","sources":["../../src/components/sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as SheetPrimitive from \"@radix-ui/react-dialog\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\n\nconst Sheet = SheetPrimitive.Root;\n\nconst SheetTrigger = SheetPrimitive.Trigger;\n\nconst SheetClose = SheetPrimitive.Close;\n\nconst SheetPortal = SheetPrimitive.Portal;\n\nconst SheetOverlay = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Overlay\n className={cn(\n \"fixed inset-0 z-
|
|
1
|
+
{"version":3,"file":"sheet.js","sources":["../../src/components/sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as SheetPrimitive from \"@radix-ui/react-dialog\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\n\nconst Sheet = SheetPrimitive.Root;\n\nconst SheetTrigger = SheetPrimitive.Trigger;\n\nconst SheetClose = SheetPrimitive.Close;\n\nconst SheetPortal = SheetPrimitive.Portal;\n\nconst SheetOverlay = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Overlay\n className={cn(\n \"fixed inset-0 z-(--z-modal-overlay) bg-black/30 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\",\n className,\n )}\n {...props}\n ref={ref}\n />\n));\nSheetOverlay.displayName = SheetPrimitive.Overlay.displayName;\n\nconst sheetVariants = cva(\n \"fixed z-(--z-modal) gap-4 overflow-y-auto overscroll-contain border-border bg-background p-6 text-base text-foreground shadow-card transition ease-out-strong data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-200\",\n {\n variants: {\n side: {\n top: \"inset-x-0 top-0 max-h-[90dvh] rounded-b-control-lg border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n bottom:\n \"inset-x-0 bottom-0 max-h-[90dvh] rounded-t-control-lg border-t pb-[max(1.5rem,env(safe-area-inset-bottom))] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n left: \"inset-y-0 left-0 h-full w-3/4 rounded-r-control-lg border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm\",\n right:\n \"inset-y-0 right-0 h-full w-3/4 rounded-l-control-lg border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm\",\n },\n },\n defaultVariants: {\n side: \"right\",\n },\n },\n);\n\ninterface SheetContentProps\n extends\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,\n VariantProps<typeof sheetVariants> {\n showCloseButton?: boolean;\n overlayClassName?: string;\n}\n\nconst SheetContent = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Content>,\n SheetContentProps\n>(({ side = \"right\", className, children, showCloseButton = true, overlayClassName, ...props }, ref) => (\n <SheetPortal>\n <SheetOverlay className={overlayClassName} />\n <SheetPrimitive.Content\n ref={ref}\n className={cn(sheetVariants({ side }), className)}\n {...props}\n >\n {children}\n {showCloseButton && <SheetPrimitive.Close className=\"absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </SheetPrimitive.Close>}\n </SheetPrimitive.Content>\n </SheetPortal>\n));\nSheetContent.displayName = SheetPrimitive.Content.displayName;\n\nconst SheetHeader = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col space-y-2 pr-10 text-left\",\n className,\n )}\n {...props}\n />\n);\nSheetHeader.displayName = \"SheetHeader\";\n\nconst SheetFooter = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\",\n className,\n )}\n {...props}\n />\n);\nSheetFooter.displayName = \"SheetFooter\";\n\nconst SheetTitle = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Title\n ref={ref}\n className={cn(\"text-xl font-semibold text-foreground\", className)}\n {...props}\n />\n));\nSheetTitle.displayName = SheetPrimitive.Title.displayName;\n\nconst SheetDescription = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nSheetDescription.displayName = SheetPrimitive.Description.displayName;\n\nexport {\n Sheet,\n SheetPortal,\n SheetOverlay,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n};\n"],"names":[],"mappings":";;;;;;;;AASA;AAEA;AAEA;AAEA;AAEA;AAaA;AAEA;AAGI;AACE;AACE;AACA;AAEA;AACA;AAED;AACF;AACD;AACE;AACD;AACF;AAWH;AAmBA;AAEA;AAYA;AAEA;AAYA;AAEA;AAUA;AAEA;AAUA;;"}
|
|
@@ -12,7 +12,7 @@ function TooltipTrigger({ ...props }) {
|
|
|
12
12
|
return jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
13
13
|
}
|
|
14
14
|
function TooltipContent({ className, arrowClassName, sideOffset = 0, children, ...props }) {
|
|
15
|
-
return (jsx(TooltipPrimitive.Portal, { children: jsxs(TooltipPrimitive.Content, { "data-slot": "tooltip-content", sideOffset: sideOffset, className: cn('animate-in motion-reduce:animate-none fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-
|
|
15
|
+
return (jsx(TooltipPrimitive.Portal, { children: jsxs(TooltipPrimitive.Content, { "data-slot": "tooltip-content", sideOffset: sideOffset, className: cn('animate-in motion-reduce:animate-none fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-(--z-tooltip) w-fit origin-(--radix-tooltip-content-transform-origin) rounded-control-sm bg-foreground px-3 py-1.5 text-sm text-balance text-background', className), ...props, children: [children, jsx(TooltipPrimitive.Arrow, { width: 10, height: 5, className: cn('z-50 fill-foreground', arrowClassName) })] }) }));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sources":["../../src/components/tooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { cn } from '@/utils';\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n );\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return (\n <TooltipProvider>\n <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n </TooltipProvider>\n );\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />;\n}\n\nfunction TooltipContent({\n className,\n arrowClassName,\n sideOffset = 0,\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content> & {\n arrowClassName?: string;\n}) {\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n className={cn(\n 'animate-in motion-reduce:animate-none fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-
|
|
1
|
+
{"version":3,"file":"tooltip.js","sources":["../../src/components/tooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { cn } from '@/utils';\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n );\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return (\n <TooltipProvider>\n <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n </TooltipProvider>\n );\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />;\n}\n\nfunction TooltipContent({\n className,\n arrowClassName,\n sideOffset = 0,\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content> & {\n arrowClassName?: string;\n}) {\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n className={cn(\n 'animate-in motion-reduce:animate-none fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-(--z-tooltip) w-fit origin-(--radix-tooltip-content-transform-origin) rounded-control-sm bg-foreground px-3 py-1.5 text-sm text-balance text-background',\n className,\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow\n width={10}\n height={5}\n className={cn('z-50 fill-foreground', arrowClassName)}\n />\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n );\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;AAKA,SAAS,eAAe,CAAC,EACvB,aAAa,GAAG,CAAC,EACjB,GAAG,KAAK,EAC+C,EAAA;AACvD,IAAA,QACEA,GAAA,CAAC,gBAAgB,CAAC,QAAQ,EAAA,EAAA,WAAA,EACd,kBAAkB,EAC5B,aAAa,EAAE,aAAa,EAAA,GACxB,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,OAAO,CAAC,EACf,GAAG,KAAK,EAC2C,EAAA;AACnD,IAAA,QACEA,GAAA,CAAC,eAAe,EAAA,EAAA,QAAA,EACdA,IAAC,gBAAgB,CAAC,IAAI,EAAA,EAAA,WAAA,EAAW,SAAS,EAAA,GAAK,KAAK,EAAA,CAAI,EAAA,CACxC;AAEtB;AAEA,SAAS,cAAc,CAAC,EACtB,GAAG,KAAK,EAC8C,EAAA;IACtD,OAAOA,GAAA,CAAC,gBAAgB,CAAC,OAAO,iBAAW,iBAAiB,EAAA,GAAK,KAAK,EAAA,CAAI;AAC5E;AAEA,SAAS,cAAc,CAAC,EACtB,SAAS,EACT,cAAc,EACd,UAAU,GAAG,CAAC,EACd,QAAQ,EACR,GAAG,KAAK,EAGT,EAAA;IACC,QACEA,GAAA,CAAC,gBAAgB,CAAC,MAAM,cACtBC,IAAA,CAAC,gBAAgB,CAAC,OAAO,EAAA,EAAA,WAAA,EACb,iBAAiB,EAC3B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,EAAE,CACX,idAAid,EACjd,SAAS,CACV,EAAA,GACG,KAAK,aAER,QAAQ,EACTD,GAAA,CAAC,gBAAgB,CAAC,KAAK,EAAA,EACrB,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,EAAE,CAAC,sBAAsB,EAAE,cAAc,CAAC,EAAA,CACrD,CAAA,EAAA,CACuB,EAAA,CACH;AAE9B;;;;"}
|
package/package.json
CHANGED
package/theme.css
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
@custom-variant dark (&:is(.dark *));
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
|
+
/*
|
|
5
|
+
* Layering. Every overlay takes its z-index from this scale (z-(--z-name)),
|
|
6
|
+
* never a number of its own, so one that opens from another (a Select in a
|
|
7
|
+
* Dialog, a phone sheet over a Sheet) is always above it. Page chrome
|
|
8
|
+
* (sticky headers and the like) stays below 1100; toasts sit above all of
|
|
9
|
+
* these.
|
|
10
|
+
*/
|
|
11
|
+
--z-modal-overlay: 1100; /* Dialog / Sheet backdrop */
|
|
12
|
+
--z-modal: 1101; /* Dialog / Sheet content */
|
|
13
|
+
--z-popover-overlay: 1110; /* dimmer behind a phone option sheet */
|
|
14
|
+
--z-popover: 1111; /* Select, Popover, menus, hover cards, option sheets */
|
|
15
|
+
--z-tooltip: 1400;
|
|
4
16
|
/* Design tokens: the shared visual foundation for every component. */
|
|
5
17
|
--radius: 0.75rem;
|
|
6
18
|
--background: oklch(1 0 0);
|
|
@@ -37,7 +49,11 @@
|
|
|
37
49
|
--supportive-soft: color-mix(in oklab, var(--supportive) 10%, transparent);
|
|
38
50
|
--supportive-strong: color-mix(in oklab, var(--supportive), black 25%);
|
|
39
51
|
/* ...and a quiet edge for those tinted shapes (toasts, status markers). */
|
|
40
|
-
--supportive-border: color-mix(
|
|
52
|
+
--supportive-border: color-mix(
|
|
53
|
+
in oklab,
|
|
54
|
+
var(--supportive) 48%,
|
|
55
|
+
var(--border)
|
|
56
|
+
);
|
|
41
57
|
--muted: oklch(0.966 0.006 255);
|
|
42
58
|
--muted-foreground: oklch(0.542 0.07 265);
|
|
43
59
|
--warning: oklch(0.731 0.144 64);
|
|
@@ -52,7 +68,11 @@
|
|
|
52
68
|
/* Red is dark enough to read on its own tint, so -strong is the colour. */
|
|
53
69
|
--destructive-soft: color-mix(in oklab, var(--destructive) 10%, transparent);
|
|
54
70
|
--destructive-strong: var(--destructive);
|
|
55
|
-
--destructive-border: color-mix(
|
|
71
|
+
--destructive-border: color-mix(
|
|
72
|
+
in oklab,
|
|
73
|
+
var(--destructive) 48%,
|
|
74
|
+
var(--border)
|
|
75
|
+
);
|
|
56
76
|
--border: var(--color-border);
|
|
57
77
|
--border-hover: var(--color-border-hover);
|
|
58
78
|
--input: var(--color-border-control);
|
|
@@ -271,12 +291,20 @@
|
|
|
271
291
|
}
|
|
272
292
|
}
|
|
273
293
|
@keyframes error-bob {
|
|
274
|
-
0%,
|
|
275
|
-
|
|
294
|
+
0%,
|
|
295
|
+
100% {
|
|
296
|
+
transform: translateY(0);
|
|
297
|
+
}
|
|
298
|
+
50% {
|
|
299
|
+
transform: translateY(-6px);
|
|
300
|
+
}
|
|
276
301
|
}
|
|
277
302
|
/* Page title entrance: a short fade up when a page opens. */
|
|
278
303
|
@keyframes page-enter {
|
|
279
|
-
from {
|
|
304
|
+
from {
|
|
305
|
+
opacity: 0;
|
|
306
|
+
transform: translateY(6px);
|
|
307
|
+
}
|
|
280
308
|
}
|
|
281
309
|
}
|
|
282
310
|
|