jaci-ui 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +17 -0
- package/dist/components/alert-dialog/alert-dialog.cjs +4 -1
- package/dist/components/alert-dialog/alert-dialog.cjs.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.d.cts +2 -2
- package/dist/components/alert-dialog/alert-dialog.d.ts +2 -2
- package/dist/components/alert-dialog/alert-dialog.js +4 -1
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/color-picker/color-picker.cjs +4 -1
- package/dist/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/components/color-picker/color-picker.d.cts +2 -2
- package/dist/components/color-picker/color-picker.d.ts +2 -2
- package/dist/components/color-picker/color-picker.js +4 -1
- package/dist/components/color-picker/color-picker.js.map +1 -1
- package/dist/components/combobox/combobox.cjs +4 -1
- package/dist/components/combobox/combobox.cjs.map +1 -1
- package/dist/components/combobox/combobox.d.cts +2 -2
- package/dist/components/combobox/combobox.d.ts +2 -2
- package/dist/components/combobox/combobox.js +4 -1
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/command/command.cjs +73 -12
- package/dist/components/command/command.cjs.map +1 -1
- package/dist/components/command/command.d.cts +7 -1
- package/dist/components/command/command.d.ts +7 -1
- package/dist/components/command/command.js +73 -12
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/command/index.d.cts +2 -2
- package/dist/components/command/index.d.ts +2 -2
- package/dist/components/context-menu/context-menu.cjs +4 -1
- package/dist/components/context-menu/context-menu.cjs.map +1 -1
- package/dist/components/context-menu/context-menu.d.cts +2 -2
- package/dist/components/context-menu/context-menu.d.ts +2 -2
- package/dist/components/context-menu/context-menu.js +4 -1
- package/dist/components/context-menu/context-menu.js.map +1 -1
- package/dist/components/date-picker/date-picker.cjs +4 -1
- package/dist/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.d.cts +2 -2
- package/dist/components/date-picker/date-picker.d.ts +2 -2
- package/dist/components/date-picker/date-picker.js +4 -1
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.cjs +4 -1
- package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.d.cts +2 -2
- package/dist/components/date-range-picker/date-range-picker.d.ts +2 -2
- package/dist/components/date-range-picker/date-range-picker.js +4 -1
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/dialog/dialog.cjs +4 -1
- package/dist/components/dialog/dialog.cjs.map +1 -1
- package/dist/components/dialog/dialog.d.cts +2 -2
- package/dist/components/dialog/dialog.d.ts +2 -2
- package/dist/components/dialog/dialog.js +4 -1
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.cjs +4 -1
- package/dist/components/drawer/drawer.cjs.map +1 -1
- package/dist/components/drawer/drawer.d.cts +2 -2
- package/dist/components/drawer/drawer.d.ts +2 -2
- package/dist/components/drawer/drawer.js +4 -1
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/figure/figure.cjs +45 -36
- package/dist/components/figure/figure.cjs.map +1 -1
- package/dist/components/figure/figure.js +45 -36
- package/dist/components/figure/figure.js.map +1 -1
- package/dist/components/image/image.cjs +41 -32
- package/dist/components/image/image.cjs.map +1 -1
- package/dist/components/image/image.js +41 -32
- package/dist/components/image/image.js.map +1 -1
- package/dist/components/menu/menu.cjs +4 -1
- package/dist/components/menu/menu.cjs.map +1 -1
- package/dist/components/menu/menu.d.cts +2 -2
- package/dist/components/menu/menu.d.ts +2 -2
- package/dist/components/menu/menu.js +4 -1
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/menubar/menubar.cjs +4 -1
- package/dist/components/menubar/menubar.cjs.map +1 -1
- package/dist/components/menubar/menubar.d.cts +2 -2
- package/dist/components/menubar/menubar.d.ts +2 -2
- package/dist/components/menubar/menubar.js +4 -1
- package/dist/components/menubar/menubar.js.map +1 -1
- package/dist/components/navigation/navigation.cjs +3 -1
- package/dist/components/navigation/navigation.cjs.map +1 -1
- package/dist/components/navigation/navigation.js +3 -1
- package/dist/components/navigation/navigation.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.cjs +4 -1
- package/dist/components/navigation-menu/navigation-menu.cjs.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.d.cts +2 -2
- package/dist/components/navigation-menu/navigation-menu.d.ts +2 -2
- package/dist/components/navigation-menu/navigation-menu.js +4 -1
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/popover/popover.cjs +4 -1
- package/dist/components/popover/popover.cjs.map +1 -1
- package/dist/components/popover/popover.d.cts +2 -2
- package/dist/components/popover/popover.d.ts +2 -2
- package/dist/components/popover/popover.js +4 -1
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/select/select.cjs +4 -1
- package/dist/components/select/select.cjs.map +1 -1
- package/dist/components/select/select.d.cts +2 -2
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.js +4 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/sidebar/sidebar.cjs +24 -17
- package/dist/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/components/sidebar/sidebar.d.cts +4 -2
- package/dist/components/sidebar/sidebar.d.ts +4 -2
- package/dist/components/sidebar/sidebar.js +24 -17
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/toast/toast.cjs +4 -1
- package/dist/components/toast/toast.cjs.map +1 -1
- package/dist/components/toast/toast.d.cts +1 -1
- package/dist/components/toast/toast.d.ts +1 -1
- package/dist/components/toast/toast.js +4 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/tooltip/tooltip.cjs +4 -1
- package/dist/components/tooltip/tooltip.cjs.map +1 -1
- package/dist/components/tooltip/tooltip.d.cts +2 -2
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/tooltip.js +4 -1
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/styled-system/recipes/command.cjs +3 -3
- package/dist/styled-system/recipes/command.cjs.map +1 -1
- package/dist/styled-system/recipes/command.js +3 -3
- package/dist/styled-system/recipes/command.js.map +1 -1
- package/dist/styled-system/recipes/figure.cjs +1 -0
- package/dist/styled-system/recipes/figure.cjs.map +1 -1
- package/dist/styled-system/recipes/figure.js +1 -0
- package/dist/styled-system/recipes/figure.js.map +1 -1
- package/dist/styled-system/recipes/image.cjs +1 -0
- package/dist/styled-system/recipes/image.cjs.map +1 -1
- package/dist/styled-system/recipes/image.js +1 -0
- package/dist/styled-system/recipes/image.js.map +1 -1
- package/dist/styles.css +70 -50
- package/dist/theme/theme-provider.cjs +18 -8
- package/dist/theme/theme-provider.cjs.map +1 -1
- package/dist/theme/theme-provider.js +18 -8
- package/dist/theme/theme-provider.js.map +1 -1
- package/dist/theme/theme-scope.cjs +21 -0
- package/dist/theme/theme-scope.cjs.map +1 -0
- package/dist/theme/theme-scope.js +19 -0
- package/dist/theme/theme-scope.js.map +1 -0
- package/package.json +7 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.cjs","names":["command","cx"],"sources":["../../../src/components/command/command.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ChangeEvent, ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { command } from \"../../styled-system/recipes\";\nimport { cx } from \"../../styled-system/css\";\n\nexport type CommandFilter = (value: string, search: string, keywords: readonly string[]) => boolean;\n\ninterface CommandItemRecord {\n id: string;\n value: string;\n keywords: readonly string[];\n disabled: boolean;\n groupId: string | undefined;\n onSelect: ((value: string) => void) | undefined;\n element: HTMLDivElement | null;\n}\n\ninterface CommandContextValue {\n search: string;\n setSearch: (search: string) => void;\n loading: boolean;\n shouldFilter: boolean;\n items: readonly CommandItemRecord[];\n highlighted: string | null;\n listId: string;\n matches: (item: Pick<CommandItemRecord, \"value\" | \"keywords\">) => boolean;\n handleKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n registerItem: (item: CommandItemRecord) => () => void;\n setItemElement: (id: string, element: HTMLDivElement | null) => void;\n setHighlighted: (value: string | null) => void;\n selectItem: (id: string) => void;\n disabled: boolean;\n}\n\nconst CommandContext = createContext<CommandContextValue | null>(null);\nconst CommandGroupContext = createContext<string | undefined>(undefined);\nconst EMPTY_KEYWORDS: readonly string[] = [];\n\nfunction useCommandContext() {\n const context = useContext(CommandContext);\n if (!context) throw new Error(\"Command parts must be rendered inside Command.Root.\");\n return context;\n}\n\nfunction defaultFilter(value: string, search: string, keywords: readonly string[]) {\n const query = search.trim().toLocaleLowerCase();\n if (!query) return true;\n return [value, ...keywords].some((candidate) => candidate.toLocaleLowerCase().includes(query));\n}\n\nexport interface CommandRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n search?: string;\n defaultSearch?: string;\n onSearchChange?: (search: string) => void;\n filter?: CommandFilter;\n shouldFilter?: boolean;\n loopFocus?: boolean;\n disabled?: boolean;\n loading?: boolean;\n children?: ReactNode;\n}\n\nexport const CommandRoot = forwardRef<HTMLDivElement, CommandRootProps>(function CommandRoot(\n {\n children,\n className,\n defaultSearch = \"\",\n disabled = false,\n filter = defaultFilter,\n loading = false,\n onKeyDown,\n onSearchChange,\n search: controlledSearch,\n shouldFilter = true,\n loopFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledSearch, setUncontrolledSearch] = useState(defaultSearch);\n const [highlighted, setHighlighted] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const itemsRef = useRef(new Map<string, CommandItemRecord>());\n const listId = useId();\n const search = controlledSearch ?? uncontrolledSearch;\n const styles = command();\n\n const items = Array.from(itemsRef.current.values());\n const setSearch = useCallback(\n (next: string) => {\n if (controlledSearch === undefined) setUncontrolledSearch(next);\n onSearchChange?.(next);\n },\n [controlledSearch, onSearchChange],\n );\n const matches = useCallback(\n (item: Pick<CommandItemRecord, \"value\" | \"keywords\">) =>\n !shouldFilter || filter(item.value, search, item.keywords),\n [filter, search, shouldFilter],\n );\n const visibleItems = useMemo(\n () => items.filter((item) => !item.disabled && matches(item)),\n [items, matches],\n );\n\n const registerItem = useCallback((item: CommandItemRecord) => {\n itemsRef.current.set(item.id, item);\n setVersion((current) => current + 1);\n return () => {\n itemsRef.current.delete(item.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setItemElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const item = itemsRef.current.get(id);\n if (item) item.element = element;\n }, []);\n\n const selectItem = useCallback(\n (id: string) => {\n const item = itemsRef.current.get(id);\n if (item && !item.disabled && matches(item)) item.onSelect?.(item.value);\n },\n [matches],\n );\n\n useEffect(() => {\n if (!visibleItems.some((item) => item.id === highlighted)) {\n setHighlighted(visibleItems[0]?.id ?? null);\n }\n }, [highlighted, visibleItems]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event as KeyboardEvent<HTMLDivElement>);\n if (event.defaultPrevented) return;\n if (disabled) return;\n const currentIndex = visibleItems.findIndex((item) => item.id === highlighted);\n if ((event.key === \"ArrowDown\" || event.key === \"ArrowUp\") && visibleItems.length > 0) {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = currentIndex + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleItems.length) % visibleItems.length;\n if (nextIndex >= 0 && nextIndex < visibleItems.length) {\n setHighlighted(visibleItems[nextIndex]?.id ?? null);\n }\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n setHighlighted((event.key === \"Home\" ? visibleItems[0] : visibleItems.at(-1))?.id ?? null);\n } else if (event.key === \"Enter\" && highlighted) {\n event.preventDefault();\n selectItem(highlighted);\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n }\n },\n [disabled, highlighted, loopFocus, onKeyDown, selectItem, visibleItems],\n );\n\n const context = useMemo<CommandContextValue>(\n () => ({\n search,\n setSearch,\n disabled,\n handleKeyDown,\n loading,\n shouldFilter,\n items,\n highlighted,\n listId,\n matches,\n registerItem,\n setItemElement,\n setHighlighted,\n selectItem,\n }),\n [\n highlighted,\n disabled,\n handleKeyDown,\n items,\n listId,\n loading,\n matches,\n registerItem,\n search,\n selectItem,\n setItemElement,\n setSearch,\n shouldFilter,\n ],\n );\n\n return (\n <CommandContext.Provider value={context}>\n <div\n {...props}\n ref={(node) => {\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"command\"\n data-slot=\"command\"\n aria-disabled={disabled || undefined}\n >\n {children}\n </div>\n </CommandContext.Provider>\n );\n});\n\nexport type CommandInputProps = ComponentPropsWithoutRef<\"input\">;\nexport const CommandInput = forwardRef<HTMLInputElement, CommandInputProps>(function CommandInput(\n { className, onChange, onKeyDown, ...props },\n ref,\n) {\n const { disabled, handleKeyDown, highlighted, listId, search, setHighlighted, setSearch } =\n useCommandContext();\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n const next = event.target.value;\n setHighlighted(null);\n setSearch(next);\n };\n\n return (\n <input\n {...props}\n ref={ref}\n aria-activedescendant={highlighted ?? undefined}\n aria-controls={listId}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded=\"true\"\n className={cx(command().input, className)}\n data-slot=\"command-input\"\n disabled={disabled || props.disabled}\n onChange={(event) => {\n handleChange(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n handleKeyDown(event);\n }}\n value={search}\n />\n );\n});\n\nexport type CommandListProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandList = forwardRef<HTMLDivElement, CommandListProps>(function CommandList(\n { className, id, ...props },\n ref,\n) {\n const { listId } = useCommandContext();\n return (\n <div\n {...props}\n ref={ref}\n id={id ?? listId}\n className={cx(command().list, className)}\n data-slot=\"command-list\"\n role=\"listbox\"\n />\n );\n});\n\nexport interface CommandGroupProps extends ComponentPropsWithoutRef<\"div\"> {\n heading?: ReactNode;\n}\nexport const CommandGroup = forwardRef<HTMLDivElement, CommandGroupProps>(function CommandGroup(\n { children, className, heading, ...props },\n ref,\n) {\n const context = useCommandContext();\n const groupId = useId();\n const hasVisibleItems = context.items.some(\n (item) => item.groupId === groupId && !item.disabled && context.matches(item),\n );\n return (\n <CommandGroupContext.Provider value={groupId}>\n <div\n {...props}\n ref={ref}\n aria-hidden={!hasVisibleItems || undefined}\n className={cx(command().group, className)}\n data-slot=\"command-group\"\n hidden={!hasVisibleItems}\n >\n {heading ? (\n <div className={command().groupHeading} data-slot=\"command-group-heading\">\n {heading}\n </div>\n ) : null}\n {children}\n </div>\n </CommandGroupContext.Provider>\n );\n});\n\nexport interface CommandItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n value: string;\n keywords?: readonly string[];\n disabled?: boolean;\n onSelect?: (value: string) => void;\n}\nexport const CommandItem = forwardRef<HTMLDivElement, CommandItemProps>(function CommandItem(\n {\n children,\n className,\n disabled = false,\n keywords: itemKeywords,\n onClick,\n onMouseEnter,\n onSelect,\n value,\n ...props\n },\n ref,\n) {\n const context = useCommandContext();\n const groupId = useContext(CommandGroupContext);\n const id = `command-item-${useId().replace(/:/g, \"\")}`;\n const keywords = itemKeywords ?? EMPTY_KEYWORDS;\n const visible = context.matches({ value, keywords });\n\n useEffect(\n () =>\n context.registerItem({\n id,\n value,\n keywords,\n disabled,\n groupId,\n onSelect,\n element: null,\n }),\n [context.registerItem, disabled, groupId, id, keywords, onSelect, value],\n );\n\n if (!visible) {\n return <div aria-hidden=\"true\" hidden ref={ref} data-slot=\"command-item\" />;\n }\n\n return (\n <div\n {...props}\n ref={(node) => {\n context.setItemElement(id, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n aria-disabled={disabled || undefined}\n aria-selected={context.highlighted === id}\n className={cx(command().item, className)}\n data-disabled={disabled || undefined}\n data-highlighted={context.highlighted === id || undefined}\n data-slot=\"command-item\"\n id={id}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented && !disabled) context.selectItem(id);\n }}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (!disabled) context.setHighlighted(id);\n }}\n onKeyDown={(event) => {\n if ((event.key === \"Enter\" || event.key === \" \") && !disabled) {\n event.preventDefault();\n context.selectItem(id);\n }\n }}\n role=\"option\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport type CommandItemIndicatorProps = ComponentPropsWithoutRef<\"span\">;\nexport const CommandItemIndicator = forwardRef<HTMLSpanElement, CommandItemIndicatorProps>(\n function CommandItemIndicator({ children = \"✓\", className, ...props }, ref) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(command().itemIndicator, className)}\n data-slot=\"command-item-indicator\"\n >\n {children}\n </span>\n );\n },\n);\n\nexport type CommandEmptyProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandEmpty = forwardRef<HTMLDivElement, CommandEmptyProps>(function CommandEmpty(\n { className, ...props },\n ref,\n) {\n const context = useCommandContext();\n if (context.loading || context.items.some((item) => !item.disabled && context.matches(item)))\n return null;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(command().empty, className)}\n aria-live=\"polite\"\n aria-disabled=\"true\"\n data-slot=\"command-empty\"\n role=\"option\"\n tabIndex={-1}\n />\n );\n});\n\nexport type CommandLoadingProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandLoading = forwardRef<HTMLDivElement, CommandLoadingProps>(\n function CommandLoading({ className, ...props }, ref) {\n const context = useCommandContext();\n if (!context.loading) return null;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(command().loading, className)}\n aria-live=\"polite\"\n aria-disabled=\"true\"\n data-slot=\"command-loading\"\n role=\"option\"\n tabIndex={-1}\n />\n );\n },\n);\n\nexport type CommandSeparatorProps = ComponentPropsWithoutRef<\"hr\">;\nexport const CommandSeparator = forwardRef<HTMLHRElement, CommandSeparatorProps>(\n function CommandSeparator({ className, ...props }, ref) {\n return (\n <hr\n {...props}\n ref={ref}\n role=\"presentation\"\n className={cx(command().separator, className)}\n data-slot=\"command-separator\"\n />\n );\n },\n);\n\nexport const Command = {\n Root: CommandRoot,\n Input: CommandInput,\n List: CommandList,\n Group: CommandGroup,\n Item: CommandItem,\n ItemIndicator: CommandItemIndicator,\n Empty: CommandEmpty,\n Loading: CommandLoading,\n Separator: CommandSeparator,\n};\n"],"mappings":";;;;;;AA+CA,MAAM,kBAAA,GAAA,MAAA,cAAA,CAA2D,IAAI;AACrE,MAAM,uBAAA,GAAA,MAAA,cAAA,CAAwD,KAAA,CAAS;AACvE,MAAM,iBAAoC,CAAC;AAE3C,SAAS,oBAAoB;CAC3B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,cAAc;CACzC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,qDAAqD;CACnF,OAAO;AACT;AAEA,SAAS,cAAc,OAAe,QAAgB,UAA6B;CACjF,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,kBAAkB;CAC9C,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,MAAM,cAAc,UAAU,kBAAkB,CAAC,CAAC,SAAS,KAAK,CAAC;AAC/F;AAcA,MAAa,eAAA,GAAA,MAAA,WAAA,CAA2D,SAAS,YAC/E,EACE,UACA,WACA,gBAAgB,IAChB,WAAW,OACX,SAAS,eACT,UAAU,OACV,WACA,gBACA,QAAQ,kBACR,eAAe,MACf,YAAY,MACZ,GAAG,SAEL,KACA;CACA,MAAM,CAAC,oBAAoB,0BAAA,GAAA,MAAA,S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CACP,MAAM;CACN,eAAe;CACf,OAAO;CACP,SAAS;CACT,WAAW;AACb"}
|
|
1
|
+
{"version":3,"file":"command.cjs","names":["command","cx"],"sources":["../../../src/components/command/command.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ChangeEvent, ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { command } from \"../../styled-system/recipes\";\nimport { cx } from \"../../styled-system/css\";\n\nexport type CommandFilter = (value: string, search: string, keywords: readonly string[]) => boolean;\nexport type CommandMode = \"default\" | \"dropdown\";\n\ninterface CommandItemRecord {\n id: string;\n value: string;\n keywords: readonly string[];\n disabled: boolean;\n groupId: string | undefined;\n onSelect: ((value: string) => void) | undefined;\n element: HTMLDivElement | null;\n}\n\ninterface CommandContextValue {\n search: string;\n setSearch: (search: string) => void;\n loading: boolean;\n shouldFilter: boolean;\n items: readonly CommandItemRecord[];\n highlighted: string | null;\n listId: string;\n matches: (item: Pick<CommandItemRecord, \"value\" | \"keywords\">) => boolean;\n handleKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n registerItem: (item: CommandItemRecord) => () => void;\n setItemElement: (id: string, element: HTMLDivElement | null) => void;\n setHighlighted: (value: string | null) => void;\n selectItem: (id: string) => void;\n disabled: boolean;\n mode: CommandMode;\n open: boolean;\n setOpen: (open: boolean) => void;\n closeOnSelect: boolean;\n}\n\nconst CommandContext = createContext<CommandContextValue | null>(null);\nconst CommandGroupContext = createContext<string | undefined>(undefined);\nconst EMPTY_KEYWORDS: readonly string[] = [];\n\nfunction useCommandContext() {\n const context = useContext(CommandContext);\n if (!context) throw new Error(\"Command parts must be rendered inside Command.Root.\");\n return context;\n}\n\nfunction defaultFilter(value: string, search: string, keywords: readonly string[]) {\n const query = search.trim().toLocaleLowerCase();\n if (!query) return true;\n return [value, ...keywords].some((candidate) => candidate.toLocaleLowerCase().includes(query));\n}\n\nexport interface CommandRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n search?: string;\n defaultSearch?: string;\n onSearchChange?: (search: string) => void;\n filter?: CommandFilter;\n shouldFilter?: boolean;\n loopFocus?: boolean;\n disabled?: boolean;\n loading?: boolean;\n mode?: CommandMode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n closeOnSelect?: boolean;\n children?: ReactNode;\n}\n\nexport const CommandRoot = forwardRef<HTMLDivElement, CommandRootProps>(function CommandRoot(\n {\n children,\n className,\n defaultSearch = \"\",\n disabled = false,\n filter = defaultFilter,\n loading = false,\n mode = \"default\",\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n closeOnSelect = true,\n onKeyDown,\n onSearchChange,\n search: controlledSearch,\n shouldFilter = true,\n loopFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledSearch, setUncontrolledSearch] = useState(defaultSearch);\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const [highlighted, setHighlighted] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const itemsRef = useRef(new Map<string, CommandItemRecord>());\n const rootElementRef = useRef<HTMLDivElement | null>(null);\n const listId = useId();\n const search = controlledSearch ?? uncontrolledSearch;\n const open = mode === \"default\" ? true : (controlledOpen ?? uncontrolledOpen);\n const styles = command({ mode });\n\n const setOpen = useCallback(\n (nextOpen: boolean) => {\n if (mode !== \"dropdown\" || disabled) return;\n if (controlledOpen === undefined) setUncontrolledOpen(nextOpen);\n onOpenChange?.(nextOpen);\n },\n [controlledOpen, disabled, mode, onOpenChange],\n );\n const close = useCallback(() => setOpen(false), [setOpen]);\n\n const items = Array.from(itemsRef.current.values());\n const setSearch = useCallback(\n (next: string) => {\n if (controlledSearch === undefined) setUncontrolledSearch(next);\n onSearchChange?.(next);\n },\n [controlledSearch, onSearchChange],\n );\n const matches = useCallback(\n (item: Pick<CommandItemRecord, \"value\" | \"keywords\">) =>\n !shouldFilter || filter(item.value, search, item.keywords),\n [filter, search, shouldFilter],\n );\n const visibleItems = useMemo(\n () => items.filter((item) => !item.disabled && matches(item)),\n [items, matches],\n );\n\n const registerItem = useCallback((item: CommandItemRecord) => {\n itemsRef.current.set(item.id, item);\n setVersion((current) => current + 1);\n return () => {\n itemsRef.current.delete(item.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setItemElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const item = itemsRef.current.get(id);\n if (item) item.element = element;\n }, []);\n\n const selectItem = useCallback(\n (id: string) => {\n const item = itemsRef.current.get(id);\n if (item && !item.disabled && matches(item)) {\n item.onSelect?.(item.value);\n if (closeOnSelect) close();\n }\n },\n [close, closeOnSelect, matches],\n );\n\n useEffect(() => {\n if (mode !== \"dropdown\" || !open) return;\n\n const handleOutsidePress = (event: PointerEvent) => {\n const target = event.target;\n if (target instanceof Node && !rootElementRef.current?.contains(target)) close();\n };\n\n document.addEventListener(\"pointerdown\", handleOutsidePress);\n return () => document.removeEventListener(\"pointerdown\", handleOutsidePress);\n }, [close, mode, open]);\n\n useEffect(() => {\n if (!visibleItems.some((item) => item.id === highlighted)) {\n setHighlighted(visibleItems[0]?.id ?? null);\n }\n }, [highlighted, visibleItems]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event as KeyboardEvent<HTMLDivElement>);\n if (event.defaultPrevented) return;\n if (disabled) return;\n const currentIndex = visibleItems.findIndex((item) => item.id === highlighted);\n if ((event.key === \"ArrowDown\" || event.key === \"ArrowUp\") && visibleItems.length > 0) {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = currentIndex + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleItems.length) % visibleItems.length;\n if (nextIndex >= 0 && nextIndex < visibleItems.length) {\n setHighlighted(visibleItems[nextIndex]?.id ?? null);\n }\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n setHighlighted((event.key === \"Home\" ? visibleItems[0] : visibleItems.at(-1))?.id ?? null);\n } else if (event.key === \"Enter\" && highlighted) {\n event.preventDefault();\n selectItem(highlighted);\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n }\n },\n [close, disabled, highlighted, loopFocus, onKeyDown, selectItem, visibleItems],\n );\n\n const context = useMemo<CommandContextValue>(\n () => ({\n search,\n setSearch,\n disabled,\n handleKeyDown,\n loading,\n shouldFilter,\n items,\n highlighted,\n listId,\n matches,\n registerItem,\n setItemElement,\n setHighlighted,\n selectItem,\n mode,\n open,\n setOpen,\n closeOnSelect,\n }),\n [\n highlighted,\n disabled,\n handleKeyDown,\n items,\n listId,\n loading,\n matches,\n registerItem,\n search,\n selectItem,\n setItemElement,\n setSearch,\n shouldFilter,\n mode,\n open,\n setOpen,\n closeOnSelect,\n ],\n );\n\n return (\n <CommandContext.Provider value={context}>\n <div\n {...props}\n ref={(node) => {\n rootElementRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"command\"\n data-mode={mode}\n data-open={open || undefined}\n data-slot=\"command\"\n aria-disabled={disabled || undefined}\n >\n {children}\n </div>\n </CommandContext.Provider>\n );\n});\n\nexport type CommandInputProps = ComponentPropsWithoutRef<\"input\">;\nexport const CommandInput = forwardRef<HTMLInputElement, CommandInputProps>(function CommandInput(\n { className, onChange, onClick, onFocus, onKeyDown, ...props },\n ref,\n) {\n const {\n disabled,\n handleKeyDown,\n highlighted,\n listId,\n mode,\n open,\n search,\n setHighlighted,\n setOpen,\n setSearch,\n } = useCommandContext();\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n const next = event.target.value;\n setHighlighted(null);\n setSearch(next);\n };\n\n return (\n <input\n {...props}\n ref={ref}\n aria-activedescendant={highlighted ?? undefined}\n aria-controls={listId}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n className={cx(command().input, className)}\n data-slot=\"command-input\"\n disabled={disabled || props.disabled}\n onChange={(event) => {\n handleChange(event);\n }}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented && mode === \"dropdown\" && !disabled && !props.disabled)\n setOpen(true);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n if (!event.defaultPrevented && mode === \"dropdown\" && !disabled && !props.disabled)\n setOpen(true);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n handleKeyDown(event);\n }}\n value={search}\n />\n );\n});\n\nexport type CommandListProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandList = forwardRef<HTMLDivElement, CommandListProps>(function CommandList(\n { className, id, ...props },\n ref,\n) {\n const { listId, mode, open } = useCommandContext();\n const styles = command({ mode });\n return (\n <div\n {...props}\n ref={ref}\n id={id ?? listId}\n className={cx(styles.list, className)}\n aria-hidden={mode === \"dropdown\" && !open ? true : undefined}\n data-open={open || undefined}\n data-slot=\"command-list\"\n hidden={mode === \"dropdown\" && !open ? true : undefined}\n role=\"listbox\"\n />\n );\n});\n\nexport interface CommandGroupProps extends ComponentPropsWithoutRef<\"div\"> {\n heading?: ReactNode;\n}\nexport const CommandGroup = forwardRef<HTMLDivElement, CommandGroupProps>(function CommandGroup(\n { children, className, heading, ...props },\n ref,\n) {\n const context = useCommandContext();\n const groupId = useId();\n const hasVisibleItems = context.items.some(\n (item) => item.groupId === groupId && !item.disabled && context.matches(item),\n );\n return (\n <CommandGroupContext.Provider value={groupId}>\n <div\n {...props}\n ref={ref}\n aria-hidden={!hasVisibleItems || undefined}\n className={cx(command().group, className)}\n data-slot=\"command-group\"\n hidden={!hasVisibleItems}\n >\n {heading ? (\n <div className={command().groupHeading} data-slot=\"command-group-heading\">\n {heading}\n </div>\n ) : null}\n {children}\n </div>\n </CommandGroupContext.Provider>\n );\n});\n\nexport interface CommandItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n value: string;\n keywords?: readonly string[];\n disabled?: boolean;\n onSelect?: (value: string) => void;\n}\nexport const CommandItem = forwardRef<HTMLDivElement, CommandItemProps>(function CommandItem(\n {\n children,\n className,\n disabled = false,\n keywords: itemKeywords,\n onClick,\n onMouseEnter,\n onSelect,\n value,\n ...props\n },\n ref,\n) {\n const context = useCommandContext();\n const groupId = useContext(CommandGroupContext);\n const id = `command-item-${useId().replace(/:/g, \"\")}`;\n const keywords = itemKeywords ?? EMPTY_KEYWORDS;\n const visible = context.matches({ value, keywords });\n\n useEffect(\n () =>\n context.registerItem({\n id,\n value,\n keywords,\n disabled,\n groupId,\n onSelect,\n element: null,\n }),\n [context.registerItem, disabled, groupId, id, keywords, onSelect, value],\n );\n\n if (!visible) {\n return <div aria-hidden=\"true\" hidden ref={ref} data-slot=\"command-item\" />;\n }\n\n return (\n <div\n {...props}\n ref={(node) => {\n context.setItemElement(id, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n aria-disabled={disabled || undefined}\n aria-selected={context.highlighted === id}\n className={cx(command().item, className)}\n data-disabled={disabled || undefined}\n data-highlighted={context.highlighted === id || undefined}\n data-slot=\"command-item\"\n id={id}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented && !disabled) context.selectItem(id);\n }}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (!disabled) context.setHighlighted(id);\n }}\n onKeyDown={(event) => {\n if ((event.key === \"Enter\" || event.key === \" \") && !disabled) {\n event.preventDefault();\n context.selectItem(id);\n }\n }}\n role=\"option\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport type CommandItemIndicatorProps = ComponentPropsWithoutRef<\"span\">;\nexport const CommandItemIndicator = forwardRef<HTMLSpanElement, CommandItemIndicatorProps>(\n function CommandItemIndicator({ children = \"✓\", className, ...props }, ref) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(command().itemIndicator, className)}\n data-slot=\"command-item-indicator\"\n >\n {children}\n </span>\n );\n },\n);\n\nexport type CommandEmptyProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandEmpty = forwardRef<HTMLDivElement, CommandEmptyProps>(function CommandEmpty(\n { className, ...props },\n ref,\n) {\n const context = useCommandContext();\n if (context.loading || context.items.some((item) => !item.disabled && context.matches(item)))\n return null;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(command().empty, className)}\n aria-live=\"polite\"\n aria-disabled=\"true\"\n data-slot=\"command-empty\"\n role=\"option\"\n tabIndex={-1}\n />\n );\n});\n\nexport type CommandLoadingProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandLoading = forwardRef<HTMLDivElement, CommandLoadingProps>(\n function CommandLoading({ className, ...props }, ref) {\n const context = useCommandContext();\n if (!context.loading) return null;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(command().loading, className)}\n aria-live=\"polite\"\n aria-disabled=\"true\"\n data-slot=\"command-loading\"\n role=\"option\"\n tabIndex={-1}\n />\n );\n },\n);\n\nexport type CommandSeparatorProps = ComponentPropsWithoutRef<\"hr\">;\nexport const CommandSeparator = forwardRef<HTMLHRElement, CommandSeparatorProps>(\n function CommandSeparator({ className, ...props }, ref) {\n return (\n <hr\n {...props}\n ref={ref}\n role=\"presentation\"\n className={cx(command().separator, className)}\n data-slot=\"command-separator\"\n />\n );\n },\n);\n\nexport const Command = {\n Root: CommandRoot,\n Input: CommandInput,\n List: CommandList,\n Group: CommandGroup,\n Item: CommandItem,\n ItemIndicator: CommandItemIndicator,\n Empty: CommandEmpty,\n Loading: CommandLoading,\n Separator: CommandSeparator,\n};\n"],"mappings":";;;;;;AAoDA,MAAM,kBAAA,GAAA,MAAA,cAAA,CAA2D,IAAI;AACrE,MAAM,uBAAA,GAAA,MAAA,cAAA,CAAwD,KAAA,CAAS;AACvE,MAAM,iBAAoC,CAAC;AAE3C,SAAS,oBAAoB;CAC3B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,cAAc;CACzC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,qDAAqD;CACn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;AAEL,CAAC;AAGD,MAAa,kBAAA,GAAA,MAAA,WAAA,CACX,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CAEpD,IAAI,CADY,kBACL,CAAC,CAAC,SAAS,OAAO;CAC7B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GAAGD,gBAAAA,QAAQ,CAAC,CAAC,SAAS,SAAS;EAC1C,aAAU;EACV,iBAAc;EACd,aAAU;EACV,MAAK;EACL,UAAU;CACX,CAAA;AAEL,CACF;AAGA,MAAa,oBAAA,GAAA,MAAA,WAAA,CACX,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAS,KAAK;CACtD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;EACE,GAAI;EACC;EACL,MAAK;EACL,WAAWC,WAAAA,GAAGD,gBAAAA,QAAQ,CAAC,CAAC,WAAW,SAAS;EAC5C,aAAU;CACX,CAAA;AAEL,CACF;AAEA,MAAa,UAAU;CACrB,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;CACP,MAAM;CACN,eAAe;CACf,OAAO;CACP,SAAS;CACT,WAAW;AACb"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
2
|
//#region src/components/command/command.d.ts
|
|
3
3
|
type CommandFilter = (value: string, search: string, keywords: readonly string[]) => boolean;
|
|
4
|
+
type CommandMode = "default" | "dropdown";
|
|
4
5
|
interface CommandRootProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
5
6
|
search?: string;
|
|
6
7
|
defaultSearch?: string;
|
|
@@ -10,6 +11,11 @@ interface CommandRootProps extends Omit<ComponentPropsWithoutRef<"div">, "childr
|
|
|
10
11
|
loopFocus?: boolean;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
loading?: boolean;
|
|
14
|
+
mode?: CommandMode;
|
|
15
|
+
open?: boolean;
|
|
16
|
+
defaultOpen?: boolean;
|
|
17
|
+
onOpenChange?: (open: boolean) => void;
|
|
18
|
+
closeOnSelect?: boolean;
|
|
13
19
|
children?: ReactNode;
|
|
14
20
|
}
|
|
15
21
|
declare const CommandRoot: import("react").ForwardRefExoticComponent<CommandRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -47,5 +53,5 @@ declare const Command: {
|
|
|
47
53
|
Separator: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>, "ref"> & import("react").RefAttributes<HTMLHRElement>>;
|
|
48
54
|
};
|
|
49
55
|
//#endregion
|
|
50
|
-
export { Command, CommandEmpty, CommandEmptyProps, CommandFilter, CommandGroup, CommandGroupProps, CommandInput, CommandInputProps, CommandItem, CommandItemIndicator, CommandItemProps, CommandList, CommandListProps, CommandLoading, CommandLoadingProps, CommandRoot, CommandRootProps, CommandSeparator, CommandSeparatorProps };
|
|
56
|
+
export { Command, CommandEmpty, CommandEmptyProps, CommandFilter, CommandGroup, CommandGroupProps, CommandInput, CommandInputProps, CommandItem, CommandItemIndicator, CommandItemProps, CommandList, CommandListProps, CommandLoading, CommandLoadingProps, CommandMode, CommandRoot, CommandRootProps, CommandSeparator, CommandSeparatorProps };
|
|
51
57
|
//# sourceMappingURL=command.d.cts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
2
|
//#region src/components/command/command.d.ts
|
|
3
3
|
type CommandFilter = (value: string, search: string, keywords: readonly string[]) => boolean;
|
|
4
|
+
type CommandMode = "default" | "dropdown";
|
|
4
5
|
interface CommandRootProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
5
6
|
search?: string;
|
|
6
7
|
defaultSearch?: string;
|
|
@@ -10,6 +11,11 @@ interface CommandRootProps extends Omit<ComponentPropsWithoutRef<"div">, "childr
|
|
|
10
11
|
loopFocus?: boolean;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
loading?: boolean;
|
|
14
|
+
mode?: CommandMode;
|
|
15
|
+
open?: boolean;
|
|
16
|
+
defaultOpen?: boolean;
|
|
17
|
+
onOpenChange?: (open: boolean) => void;
|
|
18
|
+
closeOnSelect?: boolean;
|
|
13
19
|
children?: ReactNode;
|
|
14
20
|
}
|
|
15
21
|
declare const CommandRoot: import("react").ForwardRefExoticComponent<CommandRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -47,5 +53,5 @@ declare const Command: {
|
|
|
47
53
|
Separator: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>, "ref"> & import("react").RefAttributes<HTMLHRElement>>;
|
|
48
54
|
};
|
|
49
55
|
//#endregion
|
|
50
|
-
export { Command, CommandEmpty, CommandEmptyProps, CommandFilter, CommandGroup, CommandGroupProps, CommandInput, CommandInputProps, CommandItem, CommandItemIndicator, CommandItemProps, CommandList, CommandListProps, CommandLoading, CommandLoadingProps, CommandRoot, CommandRootProps, CommandSeparator, CommandSeparatorProps };
|
|
56
|
+
export { Command, CommandEmpty, CommandEmptyProps, CommandFilter, CommandGroup, CommandGroupProps, CommandInput, CommandInputProps, CommandItem, CommandItemIndicator, CommandItemProps, CommandList, CommandListProps, CommandLoading, CommandLoadingProps, CommandMode, CommandRoot, CommandRootProps, CommandSeparator, CommandSeparatorProps };
|
|
51
57
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -17,14 +17,28 @@ function defaultFilter(value, search, keywords) {
|
|
|
17
17
|
if (!query) return true;
|
|
18
18
|
return [value, ...keywords].some((candidate) => candidate.toLocaleLowerCase().includes(query));
|
|
19
19
|
}
|
|
20
|
-
const CommandRoot = forwardRef(function CommandRoot({ children, className, defaultSearch = "", disabled = false, filter = defaultFilter, loading = false, onKeyDown, onSearchChange, search: controlledSearch, shouldFilter = true, loopFocus = true, ...props }, ref) {
|
|
20
|
+
const CommandRoot = forwardRef(function CommandRoot({ children, className, defaultSearch = "", disabled = false, filter = defaultFilter, loading = false, mode = "default", open: controlledOpen, defaultOpen = false, onOpenChange, closeOnSelect = true, onKeyDown, onSearchChange, search: controlledSearch, shouldFilter = true, loopFocus = true, ...props }, ref) {
|
|
21
21
|
const [uncontrolledSearch, setUncontrolledSearch] = useState(defaultSearch);
|
|
22
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
22
23
|
const [highlighted, setHighlighted] = useState(null);
|
|
23
24
|
const [, setVersion] = useState(0);
|
|
24
25
|
const itemsRef = useRef(/* @__PURE__ */ new Map());
|
|
26
|
+
const rootElementRef = useRef(null);
|
|
25
27
|
const listId = useId();
|
|
26
28
|
const search = controlledSearch ?? uncontrolledSearch;
|
|
27
|
-
const
|
|
29
|
+
const open = mode === "default" ? true : controlledOpen ?? uncontrolledOpen;
|
|
30
|
+
const styles = command({ mode });
|
|
31
|
+
const setOpen = useCallback((nextOpen) => {
|
|
32
|
+
if (mode !== "dropdown" || disabled) return;
|
|
33
|
+
if (controlledOpen === void 0) setUncontrolledOpen(nextOpen);
|
|
34
|
+
onOpenChange?.(nextOpen);
|
|
35
|
+
}, [
|
|
36
|
+
controlledOpen,
|
|
37
|
+
disabled,
|
|
38
|
+
mode,
|
|
39
|
+
onOpenChange
|
|
40
|
+
]);
|
|
41
|
+
const close = useCallback(() => setOpen(false), [setOpen]);
|
|
28
42
|
const items = Array.from(itemsRef.current.values());
|
|
29
43
|
const setSearch = useCallback((next) => {
|
|
30
44
|
if (controlledSearch === void 0) setUncontrolledSearch(next);
|
|
@@ -50,8 +64,28 @@ const CommandRoot = forwardRef(function CommandRoot({ children, className, defau
|
|
|
50
64
|
}, []);
|
|
51
65
|
const selectItem = useCallback((id) => {
|
|
52
66
|
const item = itemsRef.current.get(id);
|
|
53
|
-
if (item && !item.disabled && matches(item))
|
|
54
|
-
|
|
67
|
+
if (item && !item.disabled && matches(item)) {
|
|
68
|
+
item.onSelect?.(item.value);
|
|
69
|
+
if (closeOnSelect) close();
|
|
70
|
+
}
|
|
71
|
+
}, [
|
|
72
|
+
close,
|
|
73
|
+
closeOnSelect,
|
|
74
|
+
matches
|
|
75
|
+
]);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (mode !== "dropdown" || !open) return;
|
|
78
|
+
const handleOutsidePress = (event) => {
|
|
79
|
+
const target = event.target;
|
|
80
|
+
if (target instanceof Node && !rootElementRef.current?.contains(target)) close();
|
|
81
|
+
};
|
|
82
|
+
document.addEventListener("pointerdown", handleOutsidePress);
|
|
83
|
+
return () => document.removeEventListener("pointerdown", handleOutsidePress);
|
|
84
|
+
}, [
|
|
85
|
+
close,
|
|
86
|
+
mode,
|
|
87
|
+
open
|
|
88
|
+
]);
|
|
55
89
|
useEffect(() => {
|
|
56
90
|
if (!visibleItems.some((item) => item.id === highlighted)) setHighlighted(visibleItems[0]?.id ?? null);
|
|
57
91
|
}, [highlighted, visibleItems]);
|
|
@@ -71,8 +105,12 @@ const CommandRoot = forwardRef(function CommandRoot({ children, className, defau
|
|
|
71
105
|
} else if (event.key === "Enter" && highlighted) {
|
|
72
106
|
event.preventDefault();
|
|
73
107
|
selectItem(highlighted);
|
|
74
|
-
} else if (event.key === "Escape")
|
|
108
|
+
} else if (event.key === "Escape") {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
close();
|
|
111
|
+
}
|
|
75
112
|
}, [
|
|
113
|
+
close,
|
|
76
114
|
disabled,
|
|
77
115
|
highlighted,
|
|
78
116
|
loopFocus,
|
|
@@ -94,7 +132,11 @@ const CommandRoot = forwardRef(function CommandRoot({ children, className, defau
|
|
|
94
132
|
registerItem,
|
|
95
133
|
setItemElement,
|
|
96
134
|
setHighlighted,
|
|
97
|
-
selectItem
|
|
135
|
+
selectItem,
|
|
136
|
+
mode,
|
|
137
|
+
open,
|
|
138
|
+
setOpen,
|
|
139
|
+
closeOnSelect
|
|
98
140
|
}), [
|
|
99
141
|
highlighted,
|
|
100
142
|
disabled,
|
|
@@ -108,27 +150,34 @@ const CommandRoot = forwardRef(function CommandRoot({ children, className, defau
|
|
|
108
150
|
selectItem,
|
|
109
151
|
setItemElement,
|
|
110
152
|
setSearch,
|
|
111
|
-
shouldFilter
|
|
153
|
+
shouldFilter,
|
|
154
|
+
mode,
|
|
155
|
+
open,
|
|
156
|
+
setOpen,
|
|
157
|
+
closeOnSelect
|
|
112
158
|
]);
|
|
113
159
|
return /* @__PURE__ */ jsx(CommandContext.Provider, {
|
|
114
160
|
value: context,
|
|
115
161
|
children: /* @__PURE__ */ jsx("div", {
|
|
116
162
|
...props,
|
|
117
163
|
ref: (node) => {
|
|
164
|
+
rootElementRef.current = node;
|
|
118
165
|
if (typeof ref === "function") ref(node);
|
|
119
166
|
else if (ref) ref.current = node;
|
|
120
167
|
},
|
|
121
168
|
className: cx(styles.root, className),
|
|
122
169
|
"data-disabled": disabled || void 0,
|
|
123
170
|
"data-jaci-component": "command",
|
|
171
|
+
"data-mode": mode,
|
|
172
|
+
"data-open": open || void 0,
|
|
124
173
|
"data-slot": "command",
|
|
125
174
|
"aria-disabled": disabled || void 0,
|
|
126
175
|
children
|
|
127
176
|
})
|
|
128
177
|
});
|
|
129
178
|
});
|
|
130
|
-
const CommandInput = forwardRef(function CommandInput({ className, onChange, onKeyDown, ...props }, ref) {
|
|
131
|
-
const { disabled, handleKeyDown, highlighted, listId, search, setHighlighted, setSearch } = useCommandContext();
|
|
179
|
+
const CommandInput = forwardRef(function CommandInput({ className, onChange, onClick, onFocus, onKeyDown, ...props }, ref) {
|
|
180
|
+
const { disabled, handleKeyDown, highlighted, listId, mode, open, search, setHighlighted, setOpen, setSearch } = useCommandContext();
|
|
132
181
|
const handleChange = (event) => {
|
|
133
182
|
onChange?.(event);
|
|
134
183
|
const next = event.target.value;
|
|
@@ -142,13 +191,21 @@ const CommandInput = forwardRef(function CommandInput({ className, onChange, onK
|
|
|
142
191
|
"aria-controls": listId,
|
|
143
192
|
role: "combobox",
|
|
144
193
|
"aria-haspopup": "listbox",
|
|
145
|
-
"aria-expanded":
|
|
194
|
+
"aria-expanded": open,
|
|
146
195
|
className: cx(command().input, className),
|
|
147
196
|
"data-slot": "command-input",
|
|
148
197
|
disabled: disabled || props.disabled,
|
|
149
198
|
onChange: (event) => {
|
|
150
199
|
handleChange(event);
|
|
151
200
|
},
|
|
201
|
+
onClick: (event) => {
|
|
202
|
+
onClick?.(event);
|
|
203
|
+
if (!event.defaultPrevented && mode === "dropdown" && !disabled && !props.disabled) setOpen(true);
|
|
204
|
+
},
|
|
205
|
+
onFocus: (event) => {
|
|
206
|
+
onFocus?.(event);
|
|
207
|
+
if (!event.defaultPrevented && mode === "dropdown" && !disabled && !props.disabled) setOpen(true);
|
|
208
|
+
},
|
|
152
209
|
onKeyDown: (event) => {
|
|
153
210
|
onKeyDown?.(event);
|
|
154
211
|
handleKeyDown(event);
|
|
@@ -157,13 +214,17 @@ const CommandInput = forwardRef(function CommandInput({ className, onChange, onK
|
|
|
157
214
|
});
|
|
158
215
|
});
|
|
159
216
|
const CommandList = forwardRef(function CommandList({ className, id, ...props }, ref) {
|
|
160
|
-
const { listId } = useCommandContext();
|
|
217
|
+
const { listId, mode, open } = useCommandContext();
|
|
218
|
+
const styles = command({ mode });
|
|
161
219
|
return /* @__PURE__ */ jsx("div", {
|
|
162
220
|
...props,
|
|
163
221
|
ref,
|
|
164
222
|
id: id ?? listId,
|
|
165
|
-
className: cx(
|
|
223
|
+
className: cx(styles.list, className),
|
|
224
|
+
"aria-hidden": mode === "dropdown" && !open ? true : void 0,
|
|
225
|
+
"data-open": open || void 0,
|
|
166
226
|
"data-slot": "command-list",
|
|
227
|
+
hidden: mode === "dropdown" && !open ? true : void 0,
|
|
167
228
|
role: "listbox"
|
|
168
229
|
});
|
|
169
230
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","names":[],"sources":["../../../src/components/command/command.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ChangeEvent, ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { command } from \"../../styled-system/recipes\";\nimport { cx } from \"../../styled-system/css\";\n\nexport type CommandFilter = (value: string, search: string, keywords: readonly string[]) => boolean;\n\ninterface CommandItemRecord {\n id: string;\n value: string;\n keywords: readonly string[];\n disabled: boolean;\n groupId: string | undefined;\n onSelect: ((value: string) => void) | undefined;\n element: HTMLDivElement | null;\n}\n\ninterface CommandContextValue {\n search: string;\n setSearch: (search: string) => void;\n loading: boolean;\n shouldFilter: boolean;\n items: readonly CommandItemRecord[];\n highlighted: string | null;\n listId: string;\n matches: (item: Pick<CommandItemRecord, \"value\" | \"keywords\">) => boolean;\n handleKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n registerItem: (item: CommandItemRecord) => () => void;\n setItemElement: (id: string, element: HTMLDivElement | null) => void;\n setHighlighted: (value: string | null) => void;\n selectItem: (id: string) => void;\n disabled: boolean;\n}\n\nconst CommandContext = createContext<CommandContextValue | null>(null);\nconst CommandGroupContext = createContext<string | undefined>(undefined);\nconst EMPTY_KEYWORDS: readonly string[] = [];\n\nfunction useCommandContext() {\n const context = useContext(CommandContext);\n if (!context) throw new Error(\"Command parts must be rendered inside Command.Root.\");\n return context;\n}\n\nfunction defaultFilter(value: string, search: string, keywords: readonly string[]) {\n const query = search.trim().toLocaleLowerCase();\n if (!query) return true;\n return [value, ...keywords].some((candidate) => candidate.toLocaleLowerCase().includes(query));\n}\n\nexport interface CommandRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n search?: string;\n defaultSearch?: string;\n onSearchChange?: (search: string) => void;\n filter?: CommandFilter;\n shouldFilter?: boolean;\n loopFocus?: boolean;\n disabled?: boolean;\n loading?: boolean;\n children?: ReactNode;\n}\n\nexport const CommandRoot = forwardRef<HTMLDivElement, CommandRootProps>(function CommandRoot(\n {\n children,\n className,\n defaultSearch = \"\",\n disabled = false,\n filter = defaultFilter,\n loading = false,\n onKeyDown,\n onSearchChange,\n search: controlledSearch,\n shouldFilter = true,\n loopFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledSearch, setUncontrolledSearch] = useState(defaultSearch);\n const [highlighted, setHighlighted] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const itemsRef = useRef(new Map<string, CommandItemRecord>());\n const listId = useId();\n const search = controlledSearch ?? uncontrolledSearch;\n const styles = command();\n\n const items = Array.from(itemsRef.current.values());\n const setSearch = useCallback(\n (next: string) => {\n if (controlledSearch === undefined) setUncontrolledSearch(next);\n onSearchChange?.(next);\n },\n [controlledSearch, onSearchChange],\n );\n const matches = useCallback(\n (item: Pick<CommandItemRecord, \"value\" | \"keywords\">) =>\n !shouldFilter || filter(item.value, search, item.keywords),\n [filter, search, shouldFilter],\n );\n const visibleItems = useMemo(\n () => items.filter((item) => !item.disabled && matches(item)),\n [items, matches],\n );\n\n const registerItem = useCallback((item: CommandItemRecord) => {\n itemsRef.current.set(item.id, item);\n setVersion((current) => current + 1);\n return () => {\n itemsRef.current.delete(item.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setItemElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const item = itemsRef.current.get(id);\n if (item) item.element = element;\n }, []);\n\n const selectItem = useCallback(\n (id: string) => {\n const item = itemsRef.current.get(id);\n if (item && !item.disabled && matches(item)) item.onSelect?.(item.value);\n },\n [matches],\n );\n\n useEffect(() => {\n if (!visibleItems.some((item) => item.id === highlighted)) {\n setHighlighted(visibleItems[0]?.id ?? null);\n }\n }, [highlighted, visibleItems]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event as KeyboardEvent<HTMLDivElement>);\n if (event.defaultPrevented) return;\n if (disabled) return;\n const currentIndex = visibleItems.findIndex((item) => item.id === highlighted);\n if ((event.key === \"ArrowDown\" || event.key === \"ArrowUp\") && visibleItems.length > 0) {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = currentIndex + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleItems.length) % visibleItems.length;\n if (nextIndex >= 0 && nextIndex < visibleItems.length) {\n setHighlighted(visibleItems[nextIndex]?.id ?? null);\n }\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n setHighlighted((event.key === \"Home\" ? visibleItems[0] : visibleItems.at(-1))?.id ?? null);\n } else if (event.key === \"Enter\" && highlighted) {\n event.preventDefault();\n selectItem(highlighted);\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n }\n },\n [disabled, highlighted, loopFocus, onKeyDown, selectItem, visibleItems],\n );\n\n const context = useMemo<CommandContextValue>(\n () => ({\n search,\n setSearch,\n disabled,\n handleKeyDown,\n loading,\n shouldFilter,\n items,\n highlighted,\n listId,\n matches,\n registerItem,\n setItemElement,\n setHighlighted,\n selectItem,\n }),\n [\n highlighted,\n disabled,\n handleKeyDown,\n items,\n listId,\n loading,\n matches,\n registerItem,\n search,\n selectItem,\n setItemElement,\n setSearch,\n shouldFilter,\n ],\n );\n\n return (\n <CommandContext.Provider value={context}>\n <div\n {...props}\n ref={(node) => {\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"command\"\n data-slot=\"command\"\n aria-disabled={disabled || undefined}\n >\n {children}\n </div>\n </CommandContext.Provider>\n );\n});\n\nexport type CommandInputProps = ComponentPropsWithoutRef<\"input\">;\nexport const CommandInput = forwardRef<HTMLInputElement, CommandInputProps>(function CommandInput(\n { className, onChange, onKeyDown, ...props },\n ref,\n) {\n const { disabled, handleKeyDown, highlighted, listId, search, setHighlighted, setSearch } =\n useCommandContext();\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n const next = event.target.value;\n setHighlighted(null);\n setSearch(next);\n };\n\n return (\n <input\n {...props}\n ref={ref}\n aria-activedescendant={highlighted ?? undefined}\n aria-controls={listId}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded=\"true\"\n className={cx(command().input, className)}\n data-slot=\"command-input\"\n disabled={disabled || props.disabled}\n onChange={(event) => {\n handleChange(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n handleKeyDown(event);\n }}\n value={search}\n />\n );\n});\n\nexport type CommandListProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandList = forwardRef<HTMLDivElement, CommandListProps>(function CommandList(\n { className, id, ...props },\n ref,\n) {\n const { listId } = useCommandContext();\n return (\n <div\n {...props}\n ref={ref}\n id={id ?? listId}\n className={cx(command().list, className)}\n data-slot=\"command-list\"\n role=\"listbox\"\n />\n );\n});\n\nexport interface CommandGroupProps extends ComponentPropsWithoutRef<\"div\"> {\n heading?: ReactNode;\n}\nexport const CommandGroup = forwardRef<HTMLDivElement, CommandGroupProps>(function CommandGroup(\n { children, className, heading, ...props },\n ref,\n) {\n const context = useCommandContext();\n const groupId = useId();\n const hasVisibleItems = context.items.some(\n (item) => item.groupId === groupId && !item.disabled && context.matches(item),\n );\n return (\n <CommandGroupContext.Provider value={groupId}>\n <div\n {...props}\n ref={ref}\n aria-hidden={!hasVisibleItems || undefined}\n className={cx(command().group, className)}\n data-slot=\"command-group\"\n hidden={!hasVisibleItems}\n >\n {heading ? (\n <div className={command().groupHeading} data-slot=\"command-group-heading\">\n {heading}\n </div>\n ) : null}\n {children}\n </div>\n </CommandGroupContext.Provider>\n );\n});\n\nexport interface CommandItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n value: string;\n keywords?: readonly string[];\n disabled?: boolean;\n onSelect?: (value: string) => void;\n}\nexport const CommandItem = forwardRef<HTMLDivElement, CommandItemProps>(function CommandItem(\n {\n children,\n className,\n disabled = false,\n keywords: itemKeywords,\n onClick,\n onMouseEnter,\n onSelect,\n value,\n ...props\n },\n ref,\n) {\n const context = useCommandContext();\n const groupId = useContext(CommandGroupContext);\n const id = `command-item-${useId().replace(/:/g, \"\")}`;\n const keywords = itemKeywords ?? EMPTY_KEYWORDS;\n const visible = context.matches({ value, keywords });\n\n useEffect(\n () =>\n context.registerItem({\n id,\n value,\n keywords,\n disabled,\n groupId,\n onSelect,\n element: null,\n }),\n [context.registerItem, disabled, groupId, id, keywords, onSelect, value],\n );\n\n if (!visible) {\n return <div aria-hidden=\"true\" hidden ref={ref} data-slot=\"command-item\" />;\n }\n\n return (\n <div\n {...props}\n ref={(node) => {\n context.setItemElement(id, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n aria-disabled={disabled || undefined}\n aria-selected={context.highlighted === id}\n className={cx(command().item, className)}\n data-disabled={disabled || undefined}\n data-highlighted={context.highlighted === id || undefined}\n data-slot=\"command-item\"\n id={id}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented && !disabled) context.selectItem(id);\n }}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (!disabled) context.setHighlighted(id);\n }}\n onKeyDown={(event) => {\n if ((event.key === \"Enter\" || event.key === \" \") && !disabled) {\n event.preventDefault();\n context.selectItem(id);\n }\n }}\n role=\"option\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport type CommandItemIndicatorProps = ComponentPropsWithoutRef<\"span\">;\nexport const CommandItemIndicator = forwardRef<HTMLSpanElement, CommandItemIndicatorProps>(\n function CommandItemIndicator({ children = \"✓\", className, ...props }, ref) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(command().itemIndicator, className)}\n data-slot=\"command-item-indicator\"\n >\n {children}\n </span>\n );\n },\n);\n\nexport type CommandEmptyProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandEmpty = forwardRef<HTMLDivElement, CommandEmptyProps>(function CommandEmpty(\n { className, ...props },\n ref,\n) {\n const context = useCommandContext();\n if (context.loading || context.items.some((item) => !item.disabled && context.matches(item)))\n return null;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(command().empty, className)}\n aria-live=\"polite\"\n aria-disabled=\"true\"\n data-slot=\"command-empty\"\n role=\"option\"\n tabIndex={-1}\n />\n );\n});\n\nexport type CommandLoadingProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandLoading = forwardRef<HTMLDivElement, CommandLoadingProps>(\n function CommandLoading({ className, ...props }, ref) {\n const context = useCommandContext();\n if (!context.loading) return null;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(command().loading, className)}\n aria-live=\"polite\"\n aria-disabled=\"true\"\n data-slot=\"command-loading\"\n role=\"option\"\n tabIndex={-1}\n />\n );\n },\n);\n\nexport type CommandSeparatorProps = ComponentPropsWithoutRef<\"hr\">;\nexport const CommandSeparator = forwardRef<HTMLHRElement, CommandSeparatorProps>(\n function CommandSeparator({ className, ...props }, ref) {\n return (\n <hr\n {...props}\n ref={ref}\n role=\"presentation\"\n className={cx(command().separator, className)}\n data-slot=\"command-separator\"\n />\n );\n },\n);\n\nexport const Command = {\n Root: CommandRoot,\n Input: CommandInput,\n List: CommandList,\n Group: CommandGroup,\n Item: CommandItem,\n ItemIndicator: CommandItemIndicator,\n Empty: CommandEmpty,\n Loading: CommandLoading,\n Separator: CommandSeparator,\n};\n"],"mappings":";;;;;;AA+CA,MAAM,iBAAiB,cAA0C,IAAI;AACrE,MAAM,sBAAsB,cAAkC,KAAA,CAAS;AACvE,MAAM,iBAAoC,CAAC;AAE3C,SAAS,oBAAoB;CAC3B,MAAM,UAAU,WAAW,cAAc;CACzC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,qDAAqD;CACnF,OAAO;AACT;AAEA,SAAS,cAAc,OAAe,QAAgB,UAA6B;CACjF,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,kBAAkB;CAC9C,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,MAAM,cAAc,UAAU,kBAAkB,CAAC,CAAC,SAAS,KAAK,CAAC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I,CADY,kBACL,CAAC,CAAC,SAAS,OAAO;CAC7B,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,QAAQ,CAAC,CAAC,SAAS,SAAS;EAC1C,aAAU;EACV,iBAAc;EACd,aAAU;EACV,MAAK;EACL,UAAU;CACX,CAAA;AAEL,CACF;AAGA,MAAa,mBAAmB,WAC9B,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAS,KAAK;CACtD,OACE,oBAAC,MAAD;EACE,GAAI;EACC;EACL,MAAK;EACL,WAAW,GAAG,QAAQ,CAAC,CAAC,WAAW,SAAS;EAC5C,aAAU;CACX,CAAA;AAEL,CACF;AAEA,MAAa,UAAU;CACrB,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;CACP,MAAM;CACN,eAAe;CACf,OAAO;CACP,SAAS;CACT,WAAW;AACb"}
|
|
1
|
+
{"version":3,"file":"command.js","names":[],"sources":["../../../src/components/command/command.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ChangeEvent, ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { command } from \"../../styled-system/recipes\";\nimport { cx } from \"../../styled-system/css\";\n\nexport type CommandFilter = (value: string, search: string, keywords: readonly string[]) => boolean;\nexport type CommandMode = \"default\" | \"dropdown\";\n\ninterface CommandItemRecord {\n id: string;\n value: string;\n keywords: readonly string[];\n disabled: boolean;\n groupId: string | undefined;\n onSelect: ((value: string) => void) | undefined;\n element: HTMLDivElement | null;\n}\n\ninterface CommandContextValue {\n search: string;\n setSearch: (search: string) => void;\n loading: boolean;\n shouldFilter: boolean;\n items: readonly CommandItemRecord[];\n highlighted: string | null;\n listId: string;\n matches: (item: Pick<CommandItemRecord, \"value\" | \"keywords\">) => boolean;\n handleKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n registerItem: (item: CommandItemRecord) => () => void;\n setItemElement: (id: string, element: HTMLDivElement | null) => void;\n setHighlighted: (value: string | null) => void;\n selectItem: (id: string) => void;\n disabled: boolean;\n mode: CommandMode;\n open: boolean;\n setOpen: (open: boolean) => void;\n closeOnSelect: boolean;\n}\n\nconst CommandContext = createContext<CommandContextValue | null>(null);\nconst CommandGroupContext = createContext<string | undefined>(undefined);\nconst EMPTY_KEYWORDS: readonly string[] = [];\n\nfunction useCommandContext() {\n const context = useContext(CommandContext);\n if (!context) throw new Error(\"Command parts must be rendered inside Command.Root.\");\n return context;\n}\n\nfunction defaultFilter(value: string, search: string, keywords: readonly string[]) {\n const query = search.trim().toLocaleLowerCase();\n if (!query) return true;\n return [value, ...keywords].some((candidate) => candidate.toLocaleLowerCase().includes(query));\n}\n\nexport interface CommandRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n search?: string;\n defaultSearch?: string;\n onSearchChange?: (search: string) => void;\n filter?: CommandFilter;\n shouldFilter?: boolean;\n loopFocus?: boolean;\n disabled?: boolean;\n loading?: boolean;\n mode?: CommandMode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n closeOnSelect?: boolean;\n children?: ReactNode;\n}\n\nexport const CommandRoot = forwardRef<HTMLDivElement, CommandRootProps>(function CommandRoot(\n {\n children,\n className,\n defaultSearch = \"\",\n disabled = false,\n filter = defaultFilter,\n loading = false,\n mode = \"default\",\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n closeOnSelect = true,\n onKeyDown,\n onSearchChange,\n search: controlledSearch,\n shouldFilter = true,\n loopFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledSearch, setUncontrolledSearch] = useState(defaultSearch);\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const [highlighted, setHighlighted] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const itemsRef = useRef(new Map<string, CommandItemRecord>());\n const rootElementRef = useRef<HTMLDivElement | null>(null);\n const listId = useId();\n const search = controlledSearch ?? uncontrolledSearch;\n const open = mode === \"default\" ? true : (controlledOpen ?? uncontrolledOpen);\n const styles = command({ mode });\n\n const setOpen = useCallback(\n (nextOpen: boolean) => {\n if (mode !== \"dropdown\" || disabled) return;\n if (controlledOpen === undefined) setUncontrolledOpen(nextOpen);\n onOpenChange?.(nextOpen);\n },\n [controlledOpen, disabled, mode, onOpenChange],\n );\n const close = useCallback(() => setOpen(false), [setOpen]);\n\n const items = Array.from(itemsRef.current.values());\n const setSearch = useCallback(\n (next: string) => {\n if (controlledSearch === undefined) setUncontrolledSearch(next);\n onSearchChange?.(next);\n },\n [controlledSearch, onSearchChange],\n );\n const matches = useCallback(\n (item: Pick<CommandItemRecord, \"value\" | \"keywords\">) =>\n !shouldFilter || filter(item.value, search, item.keywords),\n [filter, search, shouldFilter],\n );\n const visibleItems = useMemo(\n () => items.filter((item) => !item.disabled && matches(item)),\n [items, matches],\n );\n\n const registerItem = useCallback((item: CommandItemRecord) => {\n itemsRef.current.set(item.id, item);\n setVersion((current) => current + 1);\n return () => {\n itemsRef.current.delete(item.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setItemElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const item = itemsRef.current.get(id);\n if (item) item.element = element;\n }, []);\n\n const selectItem = useCallback(\n (id: string) => {\n const item = itemsRef.current.get(id);\n if (item && !item.disabled && matches(item)) {\n item.onSelect?.(item.value);\n if (closeOnSelect) close();\n }\n },\n [close, closeOnSelect, matches],\n );\n\n useEffect(() => {\n if (mode !== \"dropdown\" || !open) return;\n\n const handleOutsidePress = (event: PointerEvent) => {\n const target = event.target;\n if (target instanceof Node && !rootElementRef.current?.contains(target)) close();\n };\n\n document.addEventListener(\"pointerdown\", handleOutsidePress);\n return () => document.removeEventListener(\"pointerdown\", handleOutsidePress);\n }, [close, mode, open]);\n\n useEffect(() => {\n if (!visibleItems.some((item) => item.id === highlighted)) {\n setHighlighted(visibleItems[0]?.id ?? null);\n }\n }, [highlighted, visibleItems]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event as KeyboardEvent<HTMLDivElement>);\n if (event.defaultPrevented) return;\n if (disabled) return;\n const currentIndex = visibleItems.findIndex((item) => item.id === highlighted);\n if ((event.key === \"ArrowDown\" || event.key === \"ArrowUp\") && visibleItems.length > 0) {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = currentIndex + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleItems.length) % visibleItems.length;\n if (nextIndex >= 0 && nextIndex < visibleItems.length) {\n setHighlighted(visibleItems[nextIndex]?.id ?? null);\n }\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n setHighlighted((event.key === \"Home\" ? visibleItems[0] : visibleItems.at(-1))?.id ?? null);\n } else if (event.key === \"Enter\" && highlighted) {\n event.preventDefault();\n selectItem(highlighted);\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n }\n },\n [close, disabled, highlighted, loopFocus, onKeyDown, selectItem, visibleItems],\n );\n\n const context = useMemo<CommandContextValue>(\n () => ({\n search,\n setSearch,\n disabled,\n handleKeyDown,\n loading,\n shouldFilter,\n items,\n highlighted,\n listId,\n matches,\n registerItem,\n setItemElement,\n setHighlighted,\n selectItem,\n mode,\n open,\n setOpen,\n closeOnSelect,\n }),\n [\n highlighted,\n disabled,\n handleKeyDown,\n items,\n listId,\n loading,\n matches,\n registerItem,\n search,\n selectItem,\n setItemElement,\n setSearch,\n shouldFilter,\n mode,\n open,\n setOpen,\n closeOnSelect,\n ],\n );\n\n return (\n <CommandContext.Provider value={context}>\n <div\n {...props}\n ref={(node) => {\n rootElementRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"command\"\n data-mode={mode}\n data-open={open || undefined}\n data-slot=\"command\"\n aria-disabled={disabled || undefined}\n >\n {children}\n </div>\n </CommandContext.Provider>\n );\n});\n\nexport type CommandInputProps = ComponentPropsWithoutRef<\"input\">;\nexport const CommandInput = forwardRef<HTMLInputElement, CommandInputProps>(function CommandInput(\n { className, onChange, onClick, onFocus, onKeyDown, ...props },\n ref,\n) {\n const {\n disabled,\n handleKeyDown,\n highlighted,\n listId,\n mode,\n open,\n search,\n setHighlighted,\n setOpen,\n setSearch,\n } = useCommandContext();\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n const next = event.target.value;\n setHighlighted(null);\n setSearch(next);\n };\n\n return (\n <input\n {...props}\n ref={ref}\n aria-activedescendant={highlighted ?? undefined}\n aria-controls={listId}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n className={cx(command().input, className)}\n data-slot=\"command-input\"\n disabled={disabled || props.disabled}\n onChange={(event) => {\n handleChange(event);\n }}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented && mode === \"dropdown\" && !disabled && !props.disabled)\n setOpen(true);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n if (!event.defaultPrevented && mode === \"dropdown\" && !disabled && !props.disabled)\n setOpen(true);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n handleKeyDown(event);\n }}\n value={search}\n />\n );\n});\n\nexport type CommandListProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandList = forwardRef<HTMLDivElement, CommandListProps>(function CommandList(\n { className, id, ...props },\n ref,\n) {\n const { listId, mode, open } = useCommandContext();\n const styles = command({ mode });\n return (\n <div\n {...props}\n ref={ref}\n id={id ?? listId}\n className={cx(styles.list, className)}\n aria-hidden={mode === \"dropdown\" && !open ? true : undefined}\n data-open={open || undefined}\n data-slot=\"command-list\"\n hidden={mode === \"dropdown\" && !open ? true : undefined}\n role=\"listbox\"\n />\n );\n});\n\nexport interface CommandGroupProps extends ComponentPropsWithoutRef<\"div\"> {\n heading?: ReactNode;\n}\nexport const CommandGroup = forwardRef<HTMLDivElement, CommandGroupProps>(function CommandGroup(\n { children, className, heading, ...props },\n ref,\n) {\n const context = useCommandContext();\n const groupId = useId();\n const hasVisibleItems = context.items.some(\n (item) => item.groupId === groupId && !item.disabled && context.matches(item),\n );\n return (\n <CommandGroupContext.Provider value={groupId}>\n <div\n {...props}\n ref={ref}\n aria-hidden={!hasVisibleItems || undefined}\n className={cx(command().group, className)}\n data-slot=\"command-group\"\n hidden={!hasVisibleItems}\n >\n {heading ? (\n <div className={command().groupHeading} data-slot=\"command-group-heading\">\n {heading}\n </div>\n ) : null}\n {children}\n </div>\n </CommandGroupContext.Provider>\n );\n});\n\nexport interface CommandItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n value: string;\n keywords?: readonly string[];\n disabled?: boolean;\n onSelect?: (value: string) => void;\n}\nexport const CommandItem = forwardRef<HTMLDivElement, CommandItemProps>(function CommandItem(\n {\n children,\n className,\n disabled = false,\n keywords: itemKeywords,\n onClick,\n onMouseEnter,\n onSelect,\n value,\n ...props\n },\n ref,\n) {\n const context = useCommandContext();\n const groupId = useContext(CommandGroupContext);\n const id = `command-item-${useId().replace(/:/g, \"\")}`;\n const keywords = itemKeywords ?? EMPTY_KEYWORDS;\n const visible = context.matches({ value, keywords });\n\n useEffect(\n () =>\n context.registerItem({\n id,\n value,\n keywords,\n disabled,\n groupId,\n onSelect,\n element: null,\n }),\n [context.registerItem, disabled, groupId, id, keywords, onSelect, value],\n );\n\n if (!visible) {\n return <div aria-hidden=\"true\" hidden ref={ref} data-slot=\"command-item\" />;\n }\n\n return (\n <div\n {...props}\n ref={(node) => {\n context.setItemElement(id, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n aria-disabled={disabled || undefined}\n aria-selected={context.highlighted === id}\n className={cx(command().item, className)}\n data-disabled={disabled || undefined}\n data-highlighted={context.highlighted === id || undefined}\n data-slot=\"command-item\"\n id={id}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented && !disabled) context.selectItem(id);\n }}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (!disabled) context.setHighlighted(id);\n }}\n onKeyDown={(event) => {\n if ((event.key === \"Enter\" || event.key === \" \") && !disabled) {\n event.preventDefault();\n context.selectItem(id);\n }\n }}\n role=\"option\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport type CommandItemIndicatorProps = ComponentPropsWithoutRef<\"span\">;\nexport const CommandItemIndicator = forwardRef<HTMLSpanElement, CommandItemIndicatorProps>(\n function CommandItemIndicator({ children = \"✓\", className, ...props }, ref) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(command().itemIndicator, className)}\n data-slot=\"command-item-indicator\"\n >\n {children}\n </span>\n );\n },\n);\n\nexport type CommandEmptyProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandEmpty = forwardRef<HTMLDivElement, CommandEmptyProps>(function CommandEmpty(\n { className, ...props },\n ref,\n) {\n const context = useCommandContext();\n if (context.loading || context.items.some((item) => !item.disabled && context.matches(item)))\n return null;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(command().empty, className)}\n aria-live=\"polite\"\n aria-disabled=\"true\"\n data-slot=\"command-empty\"\n role=\"option\"\n tabIndex={-1}\n />\n );\n});\n\nexport type CommandLoadingProps = ComponentPropsWithoutRef<\"div\">;\nexport const CommandLoading = forwardRef<HTMLDivElement, CommandLoadingProps>(\n function CommandLoading({ className, ...props }, ref) {\n const context = useCommandContext();\n if (!context.loading) return null;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(command().loading, className)}\n aria-live=\"polite\"\n aria-disabled=\"true\"\n data-slot=\"command-loading\"\n role=\"option\"\n tabIndex={-1}\n />\n );\n },\n);\n\nexport type CommandSeparatorProps = ComponentPropsWithoutRef<\"hr\">;\nexport const CommandSeparator = forwardRef<HTMLHRElement, CommandSeparatorProps>(\n function CommandSeparator({ className, ...props }, ref) {\n return (\n <hr\n {...props}\n ref={ref}\n role=\"presentation\"\n className={cx(command().separator, className)}\n data-slot=\"command-separator\"\n />\n );\n },\n);\n\nexport const Command = {\n Root: CommandRoot,\n Input: CommandInput,\n List: CommandList,\n Group: CommandGroup,\n Item: CommandItem,\n ItemIndicator: CommandItemIndicator,\n Empty: CommandEmpty,\n Loading: CommandLoading,\n Separator: CommandSeparator,\n};\n"],"mappings":";;;;;;AAoDA,MAAM,iBAAiB,cAA0C,IAAI;AACrE,MAAM,sBAAsB,cAAkC,KAAA,CAAS;AACvE,MAAM,iBAAoC,CAAC;AAE3C,SAAS,oBAAoB;CAC3B,MAAM,UAAU,WAAW,cAAc;CACzC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,qDAAqD;CACnF,OAAO;AACT;AAEA,SAAS,cAAc,OAAe,QAAgB,UAA6B;CACjF,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,kBAAkB;CAC9C,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,MAAM,cAAc,UAAU,kBAAkB,CAAC,CAAC,SAAS,KAAK,CAAC;AAC/F;AAmBA,MAAa,cAAc,WAA6C,SAAS,YAC/E,EACE,UACA,WACA,gBAAgB,IAChB,WAAW,OACX,SAAS,eACT,UAAU,OACV,OAAO,WACP,MAAM,gBACN,cAAc,OACd,cACA,gBAAgB,MAChB,WACA,gBACA,QAAQ,kBACR,eAAe,MACf,YAAY,MACZ,GAAG,SAEL,KACA;CACA,MAAM,CAAC,oBAAoB,yBAAyB,SAAS,aAAa;CAC1E,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,WAAW;CACpE,MAAM,CAAC,aAAa,kBAAkB,SAAwB,IAAI;CAClE,MAAM,GAAG,cAAc,SAAS,CAAC;CACjC,MAAM,WAAW,uBAAO,IAAI,IAA+B,CAAC;CAC5D,MAAM,iBAAiB,OAA8B,IAAI;CACzD,MAAM,SAAS,MAAM;CACrB,MAAM,SAAS,oBAAoB;CACnC,MAAM,OAAO,SAAS,YAAY,OAAQ,kBAAkB;CA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;CACN,OAAO;CACP,MAAM;CACN,eAAe;CACf,OAAO;CACP,SAAS;CACT,WAAW;AACb"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Command, CommandEmpty, CommandEmptyProps, CommandFilter, CommandGroup, CommandGroupProps, CommandInput, CommandInputProps, CommandItem, CommandItemIndicator, CommandItemProps, CommandList, CommandListProps, CommandLoading, CommandLoadingProps, CommandRoot, CommandRootProps, CommandSeparator, CommandSeparatorProps } from "./command.cjs";
|
|
2
|
-
export { Command, CommandEmpty, type CommandEmptyProps, type CommandFilter, CommandGroup, type CommandGroupProps, CommandInput, type CommandInputProps, CommandItem, CommandItemIndicator, type CommandItemProps, CommandList, type CommandListProps, CommandLoading, type CommandLoadingProps, CommandRoot, type CommandRootProps, CommandSeparator, type CommandSeparatorProps };
|
|
1
|
+
import { Command, CommandEmpty, CommandEmptyProps, CommandFilter, CommandGroup, CommandGroupProps, CommandInput, CommandInputProps, CommandItem, CommandItemIndicator, CommandItemProps, CommandList, CommandListProps, CommandLoading, CommandLoadingProps, CommandMode, CommandRoot, CommandRootProps, CommandSeparator, CommandSeparatorProps } from "./command.cjs";
|
|
2
|
+
export { Command, CommandEmpty, type CommandEmptyProps, type CommandFilter, CommandGroup, type CommandGroupProps, CommandInput, type CommandInputProps, CommandItem, CommandItemIndicator, type CommandItemProps, CommandList, type CommandListProps, CommandLoading, type CommandLoadingProps, type CommandMode, CommandRoot, type CommandRootProps, CommandSeparator, type CommandSeparatorProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Command, CommandEmpty, CommandEmptyProps, CommandFilter, CommandGroup, CommandGroupProps, CommandInput, CommandInputProps, CommandItem, CommandItemIndicator, CommandItemProps, CommandList, CommandListProps, CommandLoading, CommandLoadingProps, CommandRoot, CommandRootProps, CommandSeparator, CommandSeparatorProps } from "./command.js";
|
|
2
|
-
export { Command, CommandEmpty, type CommandEmptyProps, type CommandFilter, CommandGroup, type CommandGroupProps, CommandInput, type CommandInputProps, CommandItem, CommandItemIndicator, type CommandItemProps, CommandList, type CommandListProps, CommandLoading, type CommandLoadingProps, CommandRoot, type CommandRootProps, CommandSeparator, type CommandSeparatorProps };
|
|
1
|
+
import { Command, CommandEmpty, CommandEmptyProps, CommandFilter, CommandGroup, CommandGroupProps, CommandInput, CommandInputProps, CommandItem, CommandItemIndicator, CommandItemProps, CommandList, CommandListProps, CommandLoading, CommandLoadingProps, CommandMode, CommandRoot, CommandRootProps, CommandSeparator, CommandSeparatorProps } from "./command.js";
|
|
2
|
+
export { Command, CommandEmpty, type CommandEmptyProps, type CommandFilter, CommandGroup, type CommandGroupProps, CommandInput, type CommandInputProps, CommandItem, CommandItemIndicator, type CommandItemProps, CommandList, type CommandListProps, CommandLoading, type CommandLoadingProps, type CommandMode, CommandRoot, type CommandRootProps, CommandSeparator, type CommandSeparatorProps };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_base_ui = require("../base-ui.cjs");
|
|
3
3
|
const require_menu = require("../../styled-system/recipes/menu.cjs");
|
|
4
|
+
const require_theme_scope = require("../../theme/theme-scope.cjs");
|
|
4
5
|
let react = require("react");
|
|
5
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
7
|
let _base_ui_react_context_menu = require("@base-ui/react/context-menu");
|
|
@@ -17,7 +18,9 @@ const ContextMenuTrigger = (0, react.forwardRef)(function ContextMenuTrigger({ c
|
|
|
17
18
|
"data-slot": "context-menu-trigger"
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
+
function ContextMenuPortal(props) {
|
|
22
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_context_menu.ContextMenu.Portal, { ...require_theme_scope.useThemePortalProps(props) });
|
|
23
|
+
}
|
|
21
24
|
const ContextMenuBackdrop = _base_ui_react_context_menu.ContextMenu.Backdrop;
|
|
22
25
|
const ContextMenuPositioner = (0, react.forwardRef)(function ContextMenuPositioner({ className, ...props }, ref) {
|
|
23
26
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_context_menu.ContextMenu.Positioner, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.cjs","names":["BaseContextMenu","withRecipeClassName","menu"],"sources":["../../../src/components/context-menu/context-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport { ContextMenu as BaseContextMenu } from \"@base-ui/react/context-menu\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { ContextMenuRoot as BaseContextMenuRoot } from \"@base-ui/react/context-menu\";\n\nimport { menu } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\n/**\n * A right-click and long-press menu with Base UI's keyboard navigation,\n * focus management, submenu support, and ARIA semantics.\n */\nexport type ContextMenuRootProps = BaseContextMenuRoot.Props;\n\nexport function ContextMenuRoot(props: ContextMenuRootProps) {\n return <BaseContextMenu.Root {...props} />;\n}\n\nexport type ContextMenuTriggerProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Trigger>;\n\nexport const ContextMenuTrigger = forwardRef<HTMLDivElement, ContextMenuTriggerProps>(\n function ContextMenuTrigger({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Trigger\n {...props}\n ref={ref}\n className={className}\n data-jaci-component=\"context-menu\"\n data-slot=\"context-menu-trigger\"\n />\n );\n },\n);\n\nexport type ContextMenuPortalProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Portal>;\nexport const ContextMenuPortal: typeof BaseContextMenu.Portal = BaseContextMenu.Portal;\n\nexport type ContextMenuBackdropProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Backdrop>;\nexport const ContextMenuBackdrop: typeof BaseContextMenu.Backdrop = BaseContextMenu.Backdrop;\n\nexport type ContextMenuPositionerProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.Positioner\n>;\n\nexport const ContextMenuPositioner = forwardRef<HTMLDivElement, ContextMenuPositionerProps>(\n function ContextMenuPositioner({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().positioner, className)}\n data-slot=\"context-menu-positioner\"\n />\n );\n },\n);\n\nexport type ContextMenuPopupProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Popup>;\n\nexport const ContextMenuPopup = forwardRef<HTMLDivElement, ContextMenuPopupProps>(\n function ContextMenuPopup({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().popup, className)}\n data-slot=\"context-menu-popup\"\n />\n );\n },\n);\n\nexport type ContextMenuArrowProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Arrow>;\n\nexport const ContextMenuArrow = forwardRef<HTMLDivElement, ContextMenuArrowProps>(\n function ContextMenuArrow({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Arrow\n {...props}\n ref={ref}\n className={className}\n data-slot=\"context-menu-arrow\"\n />\n );\n },\n);\n\nexport type ContextMenuItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Item>;\n\nexport const ContextMenuItem = forwardRef<HTMLElement, ContextMenuItemProps>(\n function ContextMenuItem({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Item\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-item\"\n />\n );\n },\n);\n\nexport type ContextMenuLinkItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.LinkItem>;\n\nexport const ContextMenuLinkItem = forwardRef<Element, ContextMenuLinkItemProps>(\n function ContextMenuLinkItem({ className, ...props }, ref) {\n return (\n <BaseContextMenu.LinkItem\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-link-item\"\n />\n );\n },\n);\n\nexport type ContextMenuCheckboxItemProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.CheckboxItem\n>;\n\nexport const ContextMenuCheckboxItem = forwardRef<HTMLElement, ContextMenuCheckboxItemProps>(\n function ContextMenuCheckboxItem({ className, ...props }, ref) {\n return (\n <BaseContextMenu.CheckboxItem\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-checkbox-item\"\n />\n );\n },\n);\n\nexport type ContextMenuCheckboxItemIndicatorProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.CheckboxItemIndicator\n>;\n\nexport const ContextMenuCheckboxItemIndicator = forwardRef<\n HTMLSpanElement,\n ContextMenuCheckboxItemIndicatorProps\n>(function ContextMenuCheckboxItemIndicator({ children = \"✓\", className, ...props }, ref) {\n return (\n <BaseContextMenu.CheckboxItemIndicator\n {...props}\n ref={ref}\n className={className}\n data-slot=\"context-menu-checkbox-indicator\"\n aria-hidden=\"true\"\n >\n {children}\n </BaseContextMenu.CheckboxItemIndicator>\n );\n});\n\nexport type ContextMenuRadioGroupProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.RadioGroup\n>;\nexport const ContextMenuRadioGroup: typeof BaseContextMenu.RadioGroup = BaseContextMenu.RadioGroup;\n\nexport type ContextMenuRadioItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.RadioItem>;\n\nexport const ContextMenuRadioItem = forwardRef<HTMLElement, ContextMenuRadioItemProps>(\n function ContextMenuRadioItem({ className, ...props }, ref) {\n return (\n <BaseContextMenu.RadioItem\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-radio-item\"\n />\n );\n },\n);\n\nexport type ContextMenuRadioItemIndicatorProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.RadioItemIndicator\n>;\n\nexport const ContextMenuRadioItemIndicator = forwardRef<\n HTMLSpanElement,\n ContextMenuRadioItemIndicatorProps\n>(function ContextMenuRadioItemIndicator({ children = \"•\", className, ...props }, ref) {\n return (\n <BaseContextMenu.RadioItemIndicator\n {...props}\n ref={ref}\n className={className}\n data-slot=\"context-menu-radio-indicator\"\n aria-hidden=\"true\"\n >\n {children}\n </BaseContextMenu.RadioItemIndicator>\n );\n});\n\nexport type ContextMenuSubmenuRootProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.SubmenuRoot\n>;\nexport const ContextMenuSubmenuRoot: typeof BaseContextMenu.SubmenuRoot =\n BaseContextMenu.SubmenuRoot;\n\nexport type ContextMenuSubmenuTriggerProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.SubmenuTrigger\n>;\n\nexport const ContextMenuSubmenuTrigger = forwardRef<HTMLElement, ContextMenuSubmenuTriggerProps>(\n function ContextMenuSubmenuTrigger({ className, ...props }, ref) {\n return (\n <BaseContextMenu.SubmenuTrigger\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-submenu-trigger\"\n />\n );\n },\n);\n\nexport type ContextMenuGroupProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Group>;\n\nexport const ContextMenuGroup = forwardRef<HTMLDivElement, ContextMenuGroupProps>(\n function ContextMenuGroup({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Group\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().group, className)}\n data-slot=\"context-menu-group\"\n />\n );\n },\n);\n\nexport type ContextMenuGroupLabelProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.GroupLabel\n>;\n\nexport const ContextMenuGroupLabel = forwardRef<HTMLDivElement, ContextMenuGroupLabelProps>(\n function ContextMenuGroupLabel({ className, ...props }, ref) {\n return (\n <BaseContextMenu.GroupLabel\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().groupLabel, className)}\n data-slot=\"context-menu-group-label\"\n />\n );\n },\n);\n\nexport type ContextMenuSeparatorProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Separator>;\n\nexport const ContextMenuSeparator = forwardRef<HTMLDivElement, ContextMenuSeparatorProps>(\n function ContextMenuSeparator({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Separator\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().separator, className)}\n data-slot=\"context-menu-separator\"\n />\n );\n },\n);\n\nexport const ContextMenu = {\n Root: ContextMenuRoot,\n Trigger: ContextMenuTrigger,\n Portal: ContextMenuPortal,\n Backdrop: ContextMenuBackdrop,\n Positioner: ContextMenuPositioner,\n Popup: ContextMenuPopup,\n Arrow: ContextMenuArrow,\n Item: ContextMenuItem,\n LinkItem: ContextMenuLinkItem,\n CheckboxItem: ContextMenuCheckboxItem,\n CheckboxItemIndicator: ContextMenuCheckboxItemIndicator,\n RadioGroup: ContextMenuRadioGroup,\n RadioItem: ContextMenuRadioItem,\n RadioItemIndicator: ContextMenuRadioItemIndicator,\n SubmenuRoot: ContextMenuSubmenuRoot,\n SubmenuTrigger: ContextMenuSubmenuTrigger,\n Group: ContextMenuGroup,\n GroupLabel: ContextMenuGroupLabel,\n Separator: ContextMenuSeparator,\n};\n"],"mappings":";;;;;;;AAgBA,SAAgB,gBAAgB,OAA6B;CAC3D,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,4BAAAA,YAAgB,MAAjB,EAAsB,GAAI,MAAQ,CAAA;AAC3C;AAIA,MAAa,sBAAA,GAAA,MAAA,WAAA,CACX,SAAS,mBAAmB,EAAE,WAAW,GAAG,SAAS,KAAK;CACxD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,4BAAAA,YAAgB,SAAjB;EACE,GAAI;EACC;EACM;EACX,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;AAGA,MAAa,oBAAmDA,4BAAAA,YAAgB;AAGhF,MAAa,sBAAuDA,4BAAAA,YAAgB;AAMpF,MAAa,yBAAA,GAAA,MAAA,WAAA,CACX,SAAS,sBAAsB,EAAE,WAAW,GAAG,SAAS,KAAK;CAC3D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,4BAAAA,YAAgB,YAAjB;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,aAAAA,KAAK,CAAC,CAAC,YAAY,SAAS;EAC3D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,oBAA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BAAA,GAAA,kBAAA,IAAA,CAACF,4BAAAA,YAAgB,OAAjB;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,aAAAA,KAAK,CAAC,CAAC,OAAO,SAAS;EACtD,aAAU;CACX,CAAA;AAEL,CACF;AAMA,MAAa,yBAAA,GAAA,MAAA,WAAA,CACX,SAAS,sBAAsB,EAAE,WAAW,GAAG,SAAS,KAAK;CAC3D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACF,4BAAAA,YAAgB,YAAjB;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,aAAAA,KAAK,CAAC,CAAC,YAAY,SAAS;EAC3D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,wBAAA,GAAA,MAAA,WAAA,CACX,SAAS,qBAAqB,EAAE,WAAW,GAAG,SAAS,KAAK;CAC1D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACF,4BAAAA,YAAgB,WAAjB;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,aAAAA,KAAK,CAAC,CAAC,WAAW,SAAS;EAC1D,aAAU;CACX,CAAA;AAEL,CACF;AAEA,MAAa,cAAc;CACzB,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,OAAO;CACP,OAAO;CACP,MAAM;CACN,UAAU;CACV,cAAc;CACd,uBAAuB;CACvB,YAAY;CACZ,WAAW;CACX,oBAAoB;CACpB,aAAa;CACb,gBAAgB;CAChB,OAAO;CACP,YAAY;CACZ,WAAW;AACb"}
|
|
1
|
+
{"version":3,"file":"context-menu.cjs","names":["BaseContextMenu","useThemePortalProps","withRecipeClassName","menu"],"sources":["../../../src/components/context-menu/context-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport { ContextMenu as BaseContextMenu } from \"@base-ui/react/context-menu\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { ContextMenuRoot as BaseContextMenuRoot } from \"@base-ui/react/context-menu\";\n\nimport { menu } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\n/**\n * A right-click and long-press menu with Base UI's keyboard navigation,\n * focus management, submenu support, and ARIA semantics.\n */\nexport type ContextMenuRootProps = BaseContextMenuRoot.Props;\n\nexport function ContextMenuRoot(props: ContextMenuRootProps) {\n return <BaseContextMenu.Root {...props} />;\n}\n\nexport type ContextMenuTriggerProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Trigger>;\n\nexport const ContextMenuTrigger = forwardRef<HTMLDivElement, ContextMenuTriggerProps>(\n function ContextMenuTrigger({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Trigger\n {...props}\n ref={ref}\n className={className}\n data-jaci-component=\"context-menu\"\n data-slot=\"context-menu-trigger\"\n />\n );\n },\n);\n\nexport type ContextMenuPortalProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Portal>;\nexport function ContextMenuPortal(props: ContextMenuPortalProps) {\n return <BaseContextMenu.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type ContextMenuBackdropProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Backdrop>;\nexport const ContextMenuBackdrop: typeof BaseContextMenu.Backdrop = BaseContextMenu.Backdrop;\n\nexport type ContextMenuPositionerProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.Positioner\n>;\n\nexport const ContextMenuPositioner = forwardRef<HTMLDivElement, ContextMenuPositionerProps>(\n function ContextMenuPositioner({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().positioner, className)}\n data-slot=\"context-menu-positioner\"\n />\n );\n },\n);\n\nexport type ContextMenuPopupProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Popup>;\n\nexport const ContextMenuPopup = forwardRef<HTMLDivElement, ContextMenuPopupProps>(\n function ContextMenuPopup({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().popup, className)}\n data-slot=\"context-menu-popup\"\n />\n );\n },\n);\n\nexport type ContextMenuArrowProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Arrow>;\n\nexport const ContextMenuArrow = forwardRef<HTMLDivElement, ContextMenuArrowProps>(\n function ContextMenuArrow({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Arrow\n {...props}\n ref={ref}\n className={className}\n data-slot=\"context-menu-arrow\"\n />\n );\n },\n);\n\nexport type ContextMenuItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Item>;\n\nexport const ContextMenuItem = forwardRef<HTMLElement, ContextMenuItemProps>(\n function ContextMenuItem({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Item\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-item\"\n />\n );\n },\n);\n\nexport type ContextMenuLinkItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.LinkItem>;\n\nexport const ContextMenuLinkItem = forwardRef<Element, ContextMenuLinkItemProps>(\n function ContextMenuLinkItem({ className, ...props }, ref) {\n return (\n <BaseContextMenu.LinkItem\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-link-item\"\n />\n );\n },\n);\n\nexport type ContextMenuCheckboxItemProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.CheckboxItem\n>;\n\nexport const ContextMenuCheckboxItem = forwardRef<HTMLElement, ContextMenuCheckboxItemProps>(\n function ContextMenuCheckboxItem({ className, ...props }, ref) {\n return (\n <BaseContextMenu.CheckboxItem\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-checkbox-item\"\n />\n );\n },\n);\n\nexport type ContextMenuCheckboxItemIndicatorProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.CheckboxItemIndicator\n>;\n\nexport const ContextMenuCheckboxItemIndicator = forwardRef<\n HTMLSpanElement,\n ContextMenuCheckboxItemIndicatorProps\n>(function ContextMenuCheckboxItemIndicator({ children = \"✓\", className, ...props }, ref) {\n return (\n <BaseContextMenu.CheckboxItemIndicator\n {...props}\n ref={ref}\n className={className}\n data-slot=\"context-menu-checkbox-indicator\"\n aria-hidden=\"true\"\n >\n {children}\n </BaseContextMenu.CheckboxItemIndicator>\n );\n});\n\nexport type ContextMenuRadioGroupProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.RadioGroup\n>;\nexport const ContextMenuRadioGroup: typeof BaseContextMenu.RadioGroup = BaseContextMenu.RadioGroup;\n\nexport type ContextMenuRadioItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.RadioItem>;\n\nexport const ContextMenuRadioItem = forwardRef<HTMLElement, ContextMenuRadioItemProps>(\n function ContextMenuRadioItem({ className, ...props }, ref) {\n return (\n <BaseContextMenu.RadioItem\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-radio-item\"\n />\n );\n },\n);\n\nexport type ContextMenuRadioItemIndicatorProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.RadioItemIndicator\n>;\n\nexport const ContextMenuRadioItemIndicator = forwardRef<\n HTMLSpanElement,\n ContextMenuRadioItemIndicatorProps\n>(function ContextMenuRadioItemIndicator({ children = \"•\", className, ...props }, ref) {\n return (\n <BaseContextMenu.RadioItemIndicator\n {...props}\n ref={ref}\n className={className}\n data-slot=\"context-menu-radio-indicator\"\n aria-hidden=\"true\"\n >\n {children}\n </BaseContextMenu.RadioItemIndicator>\n );\n});\n\nexport type ContextMenuSubmenuRootProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.SubmenuRoot\n>;\nexport const ContextMenuSubmenuRoot: typeof BaseContextMenu.SubmenuRoot =\n BaseContextMenu.SubmenuRoot;\n\nexport type ContextMenuSubmenuTriggerProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.SubmenuTrigger\n>;\n\nexport const ContextMenuSubmenuTrigger = forwardRef<HTMLElement, ContextMenuSubmenuTriggerProps>(\n function ContextMenuSubmenuTrigger({ className, ...props }, ref) {\n return (\n <BaseContextMenu.SubmenuTrigger\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().item, className)}\n data-slot=\"context-menu-submenu-trigger\"\n />\n );\n },\n);\n\nexport type ContextMenuGroupProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Group>;\n\nexport const ContextMenuGroup = forwardRef<HTMLDivElement, ContextMenuGroupProps>(\n function ContextMenuGroup({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Group\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().group, className)}\n data-slot=\"context-menu-group\"\n />\n );\n },\n);\n\nexport type ContextMenuGroupLabelProps = ComponentPropsWithoutRef<\n typeof BaseContextMenu.GroupLabel\n>;\n\nexport const ContextMenuGroupLabel = forwardRef<HTMLDivElement, ContextMenuGroupLabelProps>(\n function ContextMenuGroupLabel({ className, ...props }, ref) {\n return (\n <BaseContextMenu.GroupLabel\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().groupLabel, className)}\n data-slot=\"context-menu-group-label\"\n />\n );\n },\n);\n\nexport type ContextMenuSeparatorProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Separator>;\n\nexport const ContextMenuSeparator = forwardRef<HTMLDivElement, ContextMenuSeparatorProps>(\n function ContextMenuSeparator({ className, ...props }, ref) {\n return (\n <BaseContextMenu.Separator\n {...props}\n ref={ref}\n className={withRecipeClassName(menu().separator, className)}\n data-slot=\"context-menu-separator\"\n />\n );\n },\n);\n\nexport const ContextMenu = {\n Root: ContextMenuRoot,\n Trigger: ContextMenuTrigger,\n Portal: ContextMenuPortal,\n Backdrop: ContextMenuBackdrop,\n Positioner: ContextMenuPositioner,\n Popup: ContextMenuPopup,\n Arrow: ContextMenuArrow,\n Item: ContextMenuItem,\n LinkItem: ContextMenuLinkItem,\n CheckboxItem: ContextMenuCheckboxItem,\n CheckboxItemIndicator: ContextMenuCheckboxItemIndicator,\n RadioGroup: ContextMenuRadioGroup,\n RadioItem: ContextMenuRadioItem,\n RadioItemIndicator: ContextMenuRadioItemIndicator,\n SubmenuRoot: ContextMenuSubmenuRoot,\n SubmenuTrigger: ContextMenuSubmenuTrigger,\n Group: ContextMenuGroup,\n GroupLabel: ContextMenuGroupLabel,\n Separator: ContextMenuSeparator,\n};\n"],"mappings":";;;;;;;;AAiBA,SAAgB,gBAAgB,OAA6B;CAC3D,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,4BAAAA,YAAgB,MAAjB,EAAsB,GAAI,MAAQ,CAAA;AAC3C;AAIA,MAAa,sBAAA,GAAA,MAAA,WAAA,CACX,SAAS,mBAAmB,EAAE,WAAW,GAAG,SAAS,KAAK;CACxD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,4BAAAA,YAAgB,SAAjB;EACE,GAAI;EACC;EACM;EACX,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;AAGA,SAAgB,kBAAkB,OAA+B;CAC/D,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,4BAAAA,YAAgB,QAAjB,EAAwB,GAAIC,oBAAAA,oBAAoB,KAAK,EAAI,CAAA;AAClE;AAGA,MAAa,sBAAuDD,4BAAAA,YAAgB;AAMpF,MAAa,yBAAA,GAAA,MAAA,WAAA,CACX,SAAS,sBAAsB,EAAE,WAAW,GAAG,SAAS,KAAK;CAC3D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,4BAAAA,YAAgB,YAAjB;EACE,GAAI;EACC;EACL,WAAWE,gBAAAA,oBAAoBC,aAAAA,KAAK,CAAC,CAAC,YAAY,SAAS;EAC3D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,oBAAA,GAAA,MAAA,WAAA,CACX,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAS,KAAK;CACtD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACH,4BAAAA,YAAgB,OAAjB;EACE,GAAI;EACC;EACL,WAAWE,gBAAAA,oBAAoBC,aAAAA,KA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AAA,MAAA,WAAA,CACX,SAAS,sBAAsB,EAAE,WAAW,GAAG,SAAS,KAAK;CAC3D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACH,4BAAAA,YAAgB,YAAjB;EACE,GAAI;EACC;EACL,WAAWE,gBAAAA,oBAAoBC,aAAAA,KAAK,CAAC,CAAC,YAAY,SAAS;EAC3D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,wBAAA,GAAA,MAAA,WAAA,CACX,SAAS,qBAAqB,EAAE,WAAW,GAAG,SAAS,KAAK;CAC1D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACH,4BAAAA,YAAgB,WAAjB;EACE,GAAI;EACC;EACL,WAAWE,gBAAAA,oBAAoBC,aAAAA,KAAK,CAAC,CAAC,WAAW,SAAS;EAC1D,aAAU;CACX,CAAA;AAEL,CACF;AAEA,MAAa,cAAc;CACzB,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,OAAO;CACP,OAAO;CACP,MAAM;CACN,UAAU;CACV,cAAc;CACd,uBAAuB;CACvB,YAAY;CACZ,WAAW;CACX,oBAAoB;CACpB,aAAa;CACb,gBAAgB;CAChB,OAAO;CACP,YAAY;CACZ,WAAW;AACb"}
|
|
@@ -10,7 +10,7 @@ declare function ContextMenuRoot$1(props: ContextMenuRootProps): import("react")
|
|
|
10
10
|
type ContextMenuTriggerProps = ComponentPropsWithoutRef<typeof ContextMenu.Trigger>;
|
|
11
11
|
declare const ContextMenuTrigger: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
12
|
type ContextMenuPortalProps = ComponentPropsWithoutRef<typeof ContextMenu.Portal>;
|
|
13
|
-
declare
|
|
13
|
+
declare function ContextMenuPortal(props: ContextMenuPortalProps): import("react").JSX.Element;
|
|
14
14
|
type ContextMenuBackdropProps = ComponentPropsWithoutRef<typeof ContextMenu.Backdrop>;
|
|
15
15
|
declare const ContextMenuBackdrop: typeof ContextMenu.Backdrop;
|
|
16
16
|
type ContextMenuPositionerProps = ComponentPropsWithoutRef<typeof ContextMenu.Positioner>;
|
|
@@ -46,7 +46,7 @@ declare const ContextMenuSeparator: import("react").ForwardRefExoticComponent<Om
|
|
|
46
46
|
declare const ContextMenu$1: {
|
|
47
47
|
Root: typeof ContextMenuRoot$1;
|
|
48
48
|
Trigger: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
49
|
-
Portal:
|
|
49
|
+
Portal: typeof ContextMenuPortal;
|
|
50
50
|
Backdrop: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuBackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
51
51
|
Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
52
52
|
Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -10,7 +10,7 @@ declare function ContextMenuRoot$1(props: ContextMenuRootProps): import("react")
|
|
|
10
10
|
type ContextMenuTriggerProps = ComponentPropsWithoutRef<typeof ContextMenu.Trigger>;
|
|
11
11
|
declare const ContextMenuTrigger: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
12
|
type ContextMenuPortalProps = ComponentPropsWithoutRef<typeof ContextMenu.Portal>;
|
|
13
|
-
declare
|
|
13
|
+
declare function ContextMenuPortal(props: ContextMenuPortalProps): import("react").JSX.Element;
|
|
14
14
|
type ContextMenuBackdropProps = ComponentPropsWithoutRef<typeof ContextMenu.Backdrop>;
|
|
15
15
|
declare const ContextMenuBackdrop: typeof ContextMenu.Backdrop;
|
|
16
16
|
type ContextMenuPositionerProps = ComponentPropsWithoutRef<typeof ContextMenu.Positioner>;
|
|
@@ -46,7 +46,7 @@ declare const ContextMenuSeparator: import("react").ForwardRefExoticComponent<Om
|
|
|
46
46
|
declare const ContextMenu$1: {
|
|
47
47
|
Root: typeof ContextMenuRoot$1;
|
|
48
48
|
Trigger: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
49
|
-
Portal:
|
|
49
|
+
Portal: typeof ContextMenuPortal;
|
|
50
50
|
Backdrop: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuBackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
51
51
|
Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
52
52
|
Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { withRecipeClassName } from "../base-ui.js";
|
|
3
3
|
import { menu } from "../../styled-system/recipes/menu.js";
|
|
4
|
+
import { useThemePortalProps } from "../../theme/theme-scope.js";
|
|
4
5
|
import { forwardRef } from "react";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
import { ContextMenu } from "@base-ui/react/context-menu";
|
|
@@ -17,7 +18,9 @@ const ContextMenuTrigger = forwardRef(function ContextMenuTrigger({ className, .
|
|
|
17
18
|
"data-slot": "context-menu-trigger"
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
+
function ContextMenuPortal(props) {
|
|
22
|
+
return /* @__PURE__ */ jsx(ContextMenu.Portal, { ...useThemePortalProps(props) });
|
|
23
|
+
}
|
|
21
24
|
const ContextMenuBackdrop = ContextMenu.Backdrop;
|
|
22
25
|
const ContextMenuPositioner = forwardRef(function ContextMenuPositioner({ className, ...props }, ref) {
|
|
23
26
|
return /* @__PURE__ */ jsx(ContextMenu.Positioner, {
|