jaci-ui 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +85 -0
- package/dist/components/calendar/calendar.cjs +377 -0
- package/dist/components/calendar/calendar.cjs.map +1 -0
- package/dist/components/calendar/calendar.d.cts +56 -0
- package/dist/components/calendar/calendar.d.ts +56 -0
- package/dist/components/calendar/calendar.js +368 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/calendar/index.d.cts +2 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/combobox/combobox.cjs +13 -1
- package/dist/components/combobox/combobox.cjs.map +1 -1
- package/dist/components/combobox/combobox.d.cts +7 -2
- package/dist/components/combobox/combobox.d.ts +7 -2
- package/dist/components/combobox/combobox.js +13 -2
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/combobox/index.d.cts +2 -2
- package/dist/components/combobox/index.d.ts +2 -2
- package/dist/components/command/command.cjs +55 -34
- package/dist/components/command/command.cjs.map +1 -1
- package/dist/components/command/command.d.cts +1 -0
- package/dist/components/command/command.d.ts +1 -0
- package/dist/components/command/command.js +55 -34
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/controls/input.cjs +26 -5
- package/dist/components/controls/input.cjs.map +1 -1
- package/dist/components/controls/input.d.cts +5 -2
- package/dist/components/controls/input.d.ts +5 -2
- package/dist/components/controls/input.js +28 -7
- package/dist/components/controls/input.js.map +1 -1
- package/dist/components/controls/textarea.cjs +26 -5
- package/dist/components/controls/textarea.cjs.map +1 -1
- package/dist/components/controls/textarea.d.cts +5 -2
- package/dist/components/controls/textarea.d.ts +5 -2
- package/dist/components/controls/textarea.js +28 -7
- package/dist/components/controls/textarea.js.map +1 -1
- package/dist/components/data-toolbar/data-toolbar.cjs +141 -0
- package/dist/components/data-toolbar/data-toolbar.cjs.map +1 -0
- package/dist/components/data-toolbar/data-toolbar.d.cts +50 -0
- package/dist/components/data-toolbar/data-toolbar.d.ts +50 -0
- package/dist/components/data-toolbar/data-toolbar.js +132 -0
- package/dist/components/data-toolbar/data-toolbar.js.map +1 -0
- package/dist/components/data-toolbar/index.d.cts +2 -0
- package/dist/components/data-toolbar/index.d.ts +2 -0
- package/dist/components/data-view/data-view.cjs +33 -1
- package/dist/components/data-view/data-view.cjs.map +1 -1
- package/dist/components/data-view/data-view.d.cts +12 -1
- package/dist/components/data-view/data-view.d.ts +12 -1
- package/dist/components/data-view/data-view.js +31 -2
- package/dist/components/data-view/data-view.js.map +1 -1
- package/dist/components/data-view/index.d.cts +2 -2
- package/dist/components/data-view/index.d.ts +2 -2
- package/dist/components/date-picker/date-picker.cjs +9 -9
- package/dist/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.d.cts +3 -1
- package/dist/components/date-picker/date-picker.d.ts +3 -1
- package/dist/components/date-picker/date-picker.js +9 -9
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.cjs +589 -0
- package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -0
- package/dist/components/date-range-picker/date-range-picker.d.cts +134 -0
- package/dist/components/date-range-picker/date-range-picker.d.ts +134 -0
- package/dist/components/date-range-picker/date-range-picker.js +568 -0
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -0
- package/dist/components/date-range-picker/index.d.cts +2 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/field/field.cjs +106 -11
- package/dist/components/field/field.cjs.map +1 -1
- package/dist/components/field/field.d.cts +22 -4
- package/dist/components/field/field.d.ts +22 -4
- package/dist/components/field/field.js +107 -13
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/field/index.d.cts +2 -2
- package/dist/components/field/index.d.ts +2 -2
- package/dist/components/list/list.cjs +3 -1
- package/dist/components/list/list.cjs.map +1 -1
- package/dist/components/list/list.d.cts +3 -1
- package/dist/components/list/list.d.ts +3 -1
- package/dist/components/list/list.js +3 -1
- package/dist/components/list/list.js.map +1 -1
- package/dist/components/pagination/index.d.cts +2 -2
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/pagination.cjs +122 -21
- package/dist/components/pagination/pagination.cjs.map +1 -1
- package/dist/components/pagination/pagination.d.cts +25 -13
- package/dist/components/pagination/pagination.d.ts +25 -13
- package/dist/components/pagination/pagination.js +122 -23
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/pin-input/index.d.cts +2 -0
- package/dist/components/pin-input/index.d.ts +2 -0
- package/dist/components/pin-input/pin-input.cjs +266 -0
- package/dist/components/pin-input/pin-input.cjs.map +1 -0
- package/dist/components/pin-input/pin-input.d.cts +46 -0
- package/dist/components/pin-input/pin-input.d.ts +46 -0
- package/dist/components/pin-input/pin-input.js +258 -0
- package/dist/components/pin-input/pin-input.js.map +1 -0
- package/dist/components/select/index.d.cts +2 -2
- package/dist/components/select/index.d.ts +2 -2
- package/dist/components/select/select.cjs +80 -3
- package/dist/components/select/select.cjs.map +1 -1
- package/dist/components/select/select.d.cts +18 -3
- package/dist/components/select/select.d.ts +18 -3
- package/dist/components/select/select.js +78 -5
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/table/index.d.cts +2 -2
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/table.cjs +265 -46
- package/dist/components/table/table.cjs.map +1 -1
- package/dist/components/table/table.d.cts +41 -8
- package/dist/components/table/table.d.ts +41 -8
- package/dist/components/table/table.js +264 -48
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tags-input/tags-input.cjs +83 -5
- package/dist/components/tags-input/tags-input.cjs.map +1 -1
- package/dist/components/tags-input/tags-input.d.cts +3 -0
- package/dist/components/tags-input/tags-input.d.ts +3 -0
- package/dist/components/tags-input/tags-input.js +83 -5
- package/dist/components/tags-input/tags-input.js.map +1 -1
- package/dist/components/tree-view/index.d.cts +2 -2
- package/dist/components/tree-view/index.d.ts +2 -2
- package/dist/components/tree-view/tree-view.cjs +60 -3
- package/dist/components/tree-view/tree-view.cjs.map +1 -1
- package/dist/components/tree-view/tree-view.d.cts +12 -1
- package/dist/components/tree-view/tree-view.d.ts +12 -1
- package/dist/components/tree-view/tree-view.js +58 -4
- package/dist/components/tree-view/tree-view.js.map +1 -1
- package/dist/components/upload/index.d.cts +2 -2
- package/dist/components/upload/index.d.ts +2 -2
- package/dist/components/upload/upload.cjs +90 -10
- package/dist/components/upload/upload.cjs.map +1 -1
- package/dist/components/upload/upload.d.cts +25 -2
- package/dist/components/upload/upload.d.ts +25 -2
- package/dist/components/upload/upload.js +89 -11
- package/dist/components/upload/upload.js.map +1 -1
- package/dist/index.cjs +74 -1
- package/dist/index.d.cts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +14 -10
- package/dist/styled-system/recipes/calendar.cjs +43 -0
- package/dist/styled-system/recipes/calendar.cjs.map +1 -0
- package/dist/styled-system/recipes/calendar.js +43 -0
- package/dist/styled-system/recipes/calendar.js.map +1 -0
- package/dist/styled-system/recipes/combobox.cjs +1 -0
- package/dist/styled-system/recipes/combobox.cjs.map +1 -1
- package/dist/styled-system/recipes/combobox.js +1 -0
- package/dist/styled-system/recipes/combobox.js.map +1 -1
- package/dist/styled-system/recipes/data-toolbar.cjs +40 -0
- package/dist/styled-system/recipes/data-toolbar.cjs.map +1 -0
- package/dist/styled-system/recipes/data-toolbar.js +40 -0
- package/dist/styled-system/recipes/data-toolbar.js.map +1 -0
- package/dist/styled-system/recipes/data-view.cjs +3 -0
- package/dist/styled-system/recipes/data-view.cjs.map +1 -1
- package/dist/styled-system/recipes/data-view.js +3 -0
- package/dist/styled-system/recipes/data-view.js.map +1 -1
- package/dist/styled-system/recipes/date-range-picker.cjs +52 -0
- package/dist/styled-system/recipes/date-range-picker.cjs.map +1 -0
- package/dist/styled-system/recipes/date-range-picker.js +52 -0
- package/dist/styled-system/recipes/date-range-picker.js.map +1 -0
- package/dist/styled-system/recipes/list.cjs +7 -1
- package/dist/styled-system/recipes/list.cjs.map +1 -1
- package/dist/styled-system/recipes/list.js +7 -1
- package/dist/styled-system/recipes/list.js.map +1 -1
- package/dist/styled-system/recipes/pagination.cjs +9 -1
- package/dist/styled-system/recipes/pagination.cjs.map +1 -1
- package/dist/styled-system/recipes/pagination.js +9 -1
- package/dist/styled-system/recipes/pagination.js.map +1 -1
- package/dist/styled-system/recipes/pin-input.cjs +39 -0
- package/dist/styled-system/recipes/pin-input.cjs.map +1 -0
- package/dist/styled-system/recipes/pin-input.js +39 -0
- package/dist/styled-system/recipes/pin-input.js.map +1 -0
- package/dist/styled-system/recipes/select.cjs +5 -1
- package/dist/styled-system/recipes/select.cjs.map +1 -1
- package/dist/styled-system/recipes/select.js +5 -1
- package/dist/styled-system/recipes/select.js.map +1 -1
- package/dist/styled-system/recipes/table.cjs +15 -2
- package/dist/styled-system/recipes/table.cjs.map +1 -1
- package/dist/styled-system/recipes/table.js +15 -2
- package/dist/styled-system/recipes/table.js.map +1 -1
- package/dist/styled-system/recipes/tree-view.cjs +4 -1
- package/dist/styled-system/recipes/tree-view.cjs.map +1 -1
- package/dist/styled-system/recipes/tree-view.js +4 -1
- package/dist/styled-system/recipes/tree-view.js.map +1 -1
- package/dist/styled-system/recipes/upload.cjs +2 -0
- package/dist/styled-system/recipes/upload.cjs.map +1 -1
- package/dist/styled-system/recipes/upload.js +2 -0
- package/dist/styled-system/recipes/upload.js.map +1 -1
- package/dist/styles.css +995 -95
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-view.cjs","names":["treeView","cx","Children"],"sources":["../../../src/components/tree-view/tree-view.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Children, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { treeView } from \"../../styled-system/recipes\";\n\nexport type TreeViewSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TreeViewSelection = string | readonly string[] | null;\n\ninterface TreeNodeRecord {\n id: string;\n parentId: string | undefined;\n disabled: boolean;\n selectable: boolean;\n order: number;\n element: HTMLDivElement | null;\n}\n\ninterface TreeViewContextValue {\n disabled: boolean;\n loopFocus: boolean;\n selectionMode: TreeViewSelectionMode;\n expanded: ReadonlySet<string>;\n selected: ReadonlySet<string>;\n nodes: readonly TreeNodeRecord[];\n registerNode: (node: TreeNodeRecord) => () => void;\n setNodeElement: (id: string, element: HTMLDivElement | null) => void;\n isVisible: (id: string) => boolean;\n hasChildren: (id: string) => boolean;\n getDepth: (id: string) => number;\n getSiblings: (id: string) => readonly TreeNodeRecord[];\n toggleExpanded: (id: string) => void;\n selectNode: (id: string) => void;\n focusNode: (id: string) => void;\n handleKeyDown: (id: string, event: KeyboardEvent<HTMLDivElement>) => void;\n activeId: string | null;\n setActiveId: (id: string) => void;\n}\n\nconst TreeViewContext = createContext<TreeViewContextValue | null>(null);\nconst TreeParentContext = createContext<string | undefined>(undefined);\nconst TreeItemContext = createContext<string | null>(null);\n\nfunction useTreeViewContext() {\n const context = useContext(TreeViewContext);\n if (!context) throw new Error(\"TreeView parts must be rendered inside TreeView.Root.\");\n return context;\n}\n\nfunction asSet(value: string | readonly string[] | null | undefined, mode: TreeViewSelectionMode) {\n if (mode === \"multiple\") return new Set(Array.isArray(value) ? value : value ? [value] : []);\n return new Set(typeof value === \"string\" ? [value] : []);\n}\n\nexport interface TreeViewRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n expanded?: readonly string[];\n defaultExpanded?: readonly string[];\n onExpandedChange?: (expanded: string[]) => void;\n selected?: TreeViewSelection;\n defaultSelected?: TreeViewSelection;\n onSelectedChange?: (selected: TreeViewSelection) => void;\n selectionMode?: TreeViewSelectionMode;\n loopFocus?: boolean;\n disabled?: boolean;\n children?: ReactNode;\n}\n\nexport const TreeViewRoot = forwardRef<HTMLDivElement, TreeViewRootProps>(function TreeViewRoot(\n {\n children,\n className,\n defaultExpanded = [],\n defaultSelected = null,\n disabled = false,\n expanded: controlledExpanded,\n loopFocus = true,\n onExpandedChange,\n onSelectedChange,\n selected: controlledSelected,\n selectionMode = \"single\",\n ...props\n },\n ref,\n) {\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpanded));\n const [uncontrolledSelected, setUncontrolledSelected] = useState(() =>\n asSet(defaultSelected, selectionMode),\n );\n const [activeId, setActiveId] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const nodesRef = useRef(new Map<string, TreeNodeRecord>());\n const orderRef = useRef(0);\n const styles = treeView();\n const expanded = useMemo(\n () => new Set(controlledExpanded ?? uncontrolledExpanded),\n [controlledExpanded, uncontrolledExpanded],\n );\n const selected = useMemo(\n () =>\n controlledSelected === undefined\n ? uncontrolledSelected\n : asSet(controlledSelected, selectionMode),\n [controlledSelected, selectionMode, uncontrolledSelected],\n );\n const nodes = Array.from(nodesRef.current.values()).sort((a, b) => a.order - b.order);\n\n const registerNode = useCallback((node: TreeNodeRecord) => {\n const registeredNode = { ...node, order: orderRef.current++ };\n nodesRef.current.set(node.id, registeredNode);\n setVersion((current) => current + 1);\n return () => {\n if (nodesRef.current.get(node.id) === registeredNode) nodesRef.current.delete(node.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setNodeElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const node = nodesRef.current.get(id);\n if (node) node.element = element;\n }, []);\n\n const hasChildren = useCallback(\n (id: string) => nodes.some((node) => node.parentId === id),\n [nodes],\n );\n const isVisible = useCallback(\n (id: string) => {\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n if (!expanded.has(current.parentId)) return false;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return true;\n },\n [expanded, nodes],\n );\n const getDepth = useCallback(\n (id: string) => {\n let depth = 1;\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n depth += 1;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return depth;\n },\n [nodes],\n );\n const getSiblings = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n return nodes.filter((candidate) => candidate.parentId === node?.parentId);\n },\n [nodes],\n );\n\n const toggleExpanded = useCallback(\n (id: string) => {\n if (disabled || !hasChildren(id)) return;\n const next = new Set(expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledExpanded === undefined) setUncontrolledExpanded(next);\n onExpandedChange?.(Array.from(next));\n },\n [controlledExpanded, disabled, expanded, hasChildren, onExpandedChange],\n );\n\n const selectNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (disabled || !node || node.disabled || !node.selectable || selectionMode === \"none\")\n return;\n const next = new Set(selected);\n if (selectionMode === \"single\") {\n next.clear();\n next.add(id);\n } else if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledSelected === undefined) setUncontrolledSelected(next);\n onSelectedChange?.(\n selectionMode === \"multiple\" ? Array.from(next) : (next.values().next().value ?? null),\n );\n },\n [controlledSelected, disabled, nodes, onSelectedChange, selected, selectionMode],\n );\n\n const visibleNodes = nodes.filter((node) => isVisible(node.id));\n const focusNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node || node.disabled || !isVisible(id)) return;\n setActiveId(id);\n node.element?.focus();\n },\n [isVisible, nodes],\n );\n\n const handleKeyDown = useCallback(\n (id: string, event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const index = visibleNodes.findIndex((node) => node.id === id);\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = index + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleNodes.length) % visibleNodes.length;\n const nextNode = visibleNodes[nextIndex];\n if (nextIndex >= 0 && nextIndex < visibleNodes.length && nextNode) focusNode(nextNode.id);\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusNode((event.key === \"Home\" ? visibleNodes[0] : visibleNodes.at(-1))?.id ?? id);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (hasChildren(id) && !expanded.has(id)) toggleExpanded(id);\n else if (hasChildren(id))\n focusNode(nodes.find((candidate) => candidate.parentId === id)?.id ?? id);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (hasChildren(id) && expanded.has(id)) toggleExpanded(id);\n else if (node.parentId) focusNode(node.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectNode(id);\n }\n },\n [\n disabled,\n expanded,\n focusNode,\n hasChildren,\n loopFocus,\n nodes,\n selectNode,\n toggleExpanded,\n visibleNodes,\n ],\n );\n\n const context = useMemo<TreeViewContextValue>(\n () => ({\n disabled,\n loopFocus,\n selectionMode,\n expanded,\n selected,\n nodes,\n registerNode,\n setNodeElement,\n isVisible,\n hasChildren,\n getDepth,\n getSiblings,\n toggleExpanded,\n selectNode,\n focusNode,\n handleKeyDown,\n activeId,\n setActiveId,\n }),\n [\n activeId,\n disabled,\n expanded,\n focusNode,\n getDepth,\n getSiblings,\n handleKeyDown,\n hasChildren,\n isVisible,\n loopFocus,\n nodes,\n registerNode,\n selectNode,\n selected,\n selectionMode,\n setNodeElement,\n toggleExpanded,\n ],\n );\n\n return (\n <TreeViewContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n aria-multiselectable={selectionMode === \"multiple\" || undefined}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"tree-view\"\n data-slot=\"tree-view\"\n role=\"tree\"\n >\n {children}\n </div>\n </TreeViewContext.Provider>\n );\n});\n\nexport interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"id\"> {\n id: string;\n disabled?: boolean;\n selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = false,\n onClick,\n onFocus,\n onKeyDown,\n style,\n selectable = true,\n id,\n ...props\n },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n useEffect(\n () => context.registerNode({ id, parentId, disabled, selectable, order: 0, element: null }),\n [context.registerNode, disabled, id, parentId, selectable],\n );\n const siblings = context.getSiblings(id);\n const registeredNode = context.nodes.find((candidate) => candidate.id === id);\n const selected = context.selected.has(id);\n const visible = context.isVisible(id);\n const siblingIndex = siblings.findIndex((candidate) => candidate.id === id);\n const tabIndex =\n context.activeId === id || (context.activeId === null && context.nodes[0]?.id === id) ? 0 : -1;\n const childNodes = Children.toArray(children);\n const groupNodes = childNodes.filter(\n (child) => isValidElement(child) && child.type === TreeViewGroup,\n );\n const rowNodes = childNodes.filter(\n (child) => !(isValidElement(child) && child.type === TreeViewGroup),\n );\n\n return (\n <TreeParentContext.Provider value={id}>\n <TreeItemContext.Provider value={id}>\n <div\n {...props}\n ref={(element) => {\n context.setNodeElement(id, element);\n if (typeof ref === \"function\") ref(element);\n else if (ref) ref.current = element;\n }}\n aria-disabled={disabled || undefined}\n aria-expanded={context.hasChildren(id) ? context.expanded.has(id) : undefined}\n aria-level={registeredNode ? context.getDepth(id) : parentId ? 2 : 1}\n aria-posinset={siblingIndex >= 0 ? siblingIndex + 1 : 1}\n aria-setsize={siblings.length || 1}\n aria-selected={context.selectionMode === \"none\" ? undefined : selected}\n className={styles.itemWrapper}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-jaci-component=\"tree-view\"\n data-selected={selected || undefined}\n data-slot=\"tree-view-item\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented) context.selectNode(id);\n }}\n onFocus={(event) => {\n context.setActiveId(id);\n onFocus?.(event);\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n context.handleKeyDown(id, event);\n onKeyDown?.(event);\n }}\n role=\"treeitem\"\n tabIndex={visible ? tabIndex : -1}\n >\n <div\n className={cx(styles.item, className)}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-selected={selected || undefined}\n data-slot=\"tree-view-item-row\"\n style={style}\n >\n {rowNodes}\n </div>\n {groupNodes}\n </div>\n </TreeItemContext.Provider>\n </TreeParentContext.Provider>\n );\n});\n\nexport type TreeViewGroupProps = ComponentPropsWithoutRef<\"div\">;\nexport const TreeViewGroup = forwardRef<HTMLDivElement, TreeViewGroupProps>(function TreeViewGroup(\n { children, className, style, ...props },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n const visible = parentId ? context.expanded.has(parentId) : true;\n return (\n // biome-ignore lint/a11y/useSemanticElements: WAI-ARIA tree groups require role=\"group\".\n <div\n {...props}\n ref={ref}\n aria-hidden={!visible || undefined}\n className={cx(styles.group, className)}\n data-jaci-component=\"tree-view\"\n data-expanded={visible || undefined}\n data-slot=\"tree-view-group\"\n hidden={!visible}\n role=\"group\"\n style={{ ...style, display: visible ? style?.display : \"none\" }}\n >\n {children}\n </div>\n );\n});\n\nexport type TreeViewToggleProps = ComponentPropsWithoutRef<\"button\">;\nexport const TreeViewToggle = forwardRef<HTMLButtonElement, TreeViewToggleProps>(\n function TreeViewToggle({ children, className, onClick, ...props }, ref) {\n const context = useTreeViewContext();\n const itemId = useContext(TreeItemContext);\n const id = itemId;\n return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented && id) context.toggleExpanded(id);\n }}\n tabIndex={-1}\n type=\"button\"\n >\n {children ?? (id && context.expanded.has(id) ? \"▾\" : \"▸\")}\n </button>\n );\n },\n);\n\nexport type TreeViewLabelProps = ComponentPropsWithoutRef<\"span\">;\nexport const TreeViewLabel = forwardRef<HTMLSpanElement, TreeViewLabelProps>(function TreeViewLabel(\n { className, ...props },\n ref,\n) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(treeView().label, className)}\n data-slot=\"tree-view-label\"\n />\n );\n});\n\nexport const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem,\n Group: TreeViewGroup,\n Toggle: TreeViewToggle,\n Label: TreeViewLabel,\n};\n"],"mappings":";;;;;;AAmDA,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;AACvE,MAAM,qBAAA,GAAA,MAAA,cAAA,CAAsD,KAAA,CAAS;AACrE,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA+C,IAAI;AAEzD,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,MAAM,OAAsD,MAA6B;CAChG,IAAI,SAAS,YAAY,OAAO,IAAI,IAAI,MAAM,QAAQ,KAAK,IAAI,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC;CAC3F,OAAO,IAAI,IAAI,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI,CAAC,CAAC;AACzD;AAeA,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA6D,SAAS,aACjF,EACE,UACA,WACA,kBAAkB,CAAC,GACnB,kBAAkB,MAClB,WAAW,OACX,UAAU,oBACV,YAAY,MACZ,kBACA,kBACA,UAAU,oBACV,gBAAgB,UAChB,GAAG,SAEL,KACA;CACA,MAAM,CAAC,sBAAsB,4BAAA,GAAA,MAAA,SAAA,OAA0C,IAAI,IAAI,eAAe,CAAC;CAC/F,MAAM,CAAC,sBAAsB,4BAAA,GAAA,MAAA,SAAA,OAC3B,MAAM,iBAAiB,aAAa,CACtC;CACA,MAAM,CAAC,UAAU,gBAAA,GAAA,MAAA,SAAA,CAAuC,IAAI;CAC5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,QAAQ;CACR,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"tree-view.cjs","names":["treeView","cx","Children"],"sources":["../../../src/components/tree-view/tree-view.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Children, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { treeView } from \"../../styled-system/recipes\";\n\nexport type TreeViewSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TreeViewSelection = string | readonly string[] | null;\n\ninterface TreeNodeRecord {\n id: string;\n parentId: string | undefined;\n disabled: boolean;\n hasChildren: boolean;\n loading: boolean;\n selectable: boolean;\n order: number;\n element: HTMLDivElement | null;\n}\n\ninterface TreeViewContextValue {\n disabled: boolean;\n loopFocus: boolean;\n selectionMode: TreeViewSelectionMode;\n expanded: ReadonlySet<string>;\n selected: ReadonlySet<string>;\n nodes: readonly TreeNodeRecord[];\n registerNode: (node: TreeNodeRecord) => () => void;\n setNodeElement: (id: string, element: HTMLDivElement | null) => void;\n isVisible: (id: string) => boolean;\n hasChildren: (id: string) => boolean;\n getDepth: (id: string) => number;\n getSiblings: (id: string) => readonly TreeNodeRecord[];\n toggleExpanded: (id: string) => void;\n selectNode: (id: string) => void;\n focusNode: (id: string) => void;\n handleKeyDown: (id: string, event: KeyboardEvent<HTMLDivElement>) => void;\n activeId: string | null;\n setActiveId: (id: string) => void;\n}\n\nconst TreeViewContext = createContext<TreeViewContextValue | null>(null);\nconst TreeParentContext = createContext<string | undefined>(undefined);\nconst TreeItemContext = createContext<string | null>(null);\n\nfunction useTreeViewContext() {\n const context = useContext(TreeViewContext);\n if (!context) throw new Error(\"TreeView parts must be rendered inside TreeView.Root.\");\n return context;\n}\n\nfunction asSet(value: string | readonly string[] | null | undefined, mode: TreeViewSelectionMode) {\n if (mode === \"multiple\") return new Set(Array.isArray(value) ? value : value ? [value] : []);\n return new Set(typeof value === \"string\" ? [value] : []);\n}\n\nexport interface TreeViewRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n expanded?: readonly string[];\n defaultExpanded?: readonly string[];\n onExpandedChange?: (expanded: string[]) => void;\n selected?: TreeViewSelection;\n defaultSelected?: TreeViewSelection;\n onSelectedChange?: (selected: TreeViewSelection) => void;\n selectionMode?: TreeViewSelectionMode;\n loopFocus?: boolean;\n disabled?: boolean;\n children?: ReactNode;\n}\n\nexport const TreeViewRoot = forwardRef<HTMLDivElement, TreeViewRootProps>(function TreeViewRoot(\n {\n children,\n className,\n defaultExpanded = [],\n defaultSelected = null,\n disabled = false,\n expanded: controlledExpanded,\n loopFocus = true,\n onExpandedChange,\n onSelectedChange,\n selected: controlledSelected,\n selectionMode = \"single\",\n ...props\n },\n ref,\n) {\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpanded));\n const [uncontrolledSelected, setUncontrolledSelected] = useState(() =>\n asSet(defaultSelected, selectionMode),\n );\n const [activeId, setActiveId] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const nodesRef = useRef(new Map<string, TreeNodeRecord>());\n const orderRef = useRef(0);\n const styles = treeView();\n const expanded = useMemo(\n () => new Set(controlledExpanded ?? uncontrolledExpanded),\n [controlledExpanded, uncontrolledExpanded],\n );\n const selected = useMemo(\n () =>\n controlledSelected === undefined\n ? uncontrolledSelected\n : asSet(controlledSelected, selectionMode),\n [controlledSelected, selectionMode, uncontrolledSelected],\n );\n const nodes = Array.from(nodesRef.current.values()).sort((a, b) => a.order - b.order);\n\n const registerNode = useCallback((node: TreeNodeRecord) => {\n const registeredNode = { ...node, order: orderRef.current++ };\n nodesRef.current.set(node.id, registeredNode);\n setVersion((current) => current + 1);\n return () => {\n if (nodesRef.current.get(node.id) === registeredNode) nodesRef.current.delete(node.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setNodeElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const node = nodesRef.current.get(id);\n if (node) node.element = element;\n }, []);\n\n const hasChildren = useCallback(\n (id: string) =>\n nodes.some((node) => node.parentId === id) ||\n Boolean(nodes.find((node) => node.id === id)?.hasChildren),\n [nodes],\n );\n const isVisible = useCallback(\n (id: string) => {\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n if (!expanded.has(current.parentId)) return false;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return true;\n },\n [expanded, nodes],\n );\n const getDepth = useCallback(\n (id: string) => {\n let depth = 1;\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n depth += 1;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return depth;\n },\n [nodes],\n );\n const getSiblings = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n return nodes.filter((candidate) => candidate.parentId === node?.parentId);\n },\n [nodes],\n );\n\n const toggleExpanded = useCallback(\n (id: string) => {\n if (disabled || !hasChildren(id)) return;\n const next = new Set(expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledExpanded === undefined) setUncontrolledExpanded(next);\n onExpandedChange?.(Array.from(next));\n },\n [controlledExpanded, disabled, expanded, hasChildren, onExpandedChange],\n );\n\n const selectNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (disabled || !node || node.disabled || !node.selectable || selectionMode === \"none\")\n return;\n const next = new Set(selected);\n if (selectionMode === \"single\") {\n next.clear();\n next.add(id);\n } else if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledSelected === undefined) setUncontrolledSelected(next);\n onSelectedChange?.(\n selectionMode === \"multiple\" ? Array.from(next) : (next.values().next().value ?? null),\n );\n },\n [controlledSelected, disabled, nodes, onSelectedChange, selected, selectionMode],\n );\n\n const visibleNodes = nodes.filter((node) => isVisible(node.id));\n const focusNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node || node.disabled || !isVisible(id)) return;\n setActiveId(id);\n node.element?.focus();\n },\n [isVisible, nodes],\n );\n\n const handleKeyDown = useCallback(\n (id: string, event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const index = visibleNodes.findIndex((node) => node.id === id);\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = index + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleNodes.length) % visibleNodes.length;\n const nextNode = visibleNodes[nextIndex];\n if (nextIndex >= 0 && nextIndex < visibleNodes.length && nextNode) focusNode(nextNode.id);\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusNode((event.key === \"Home\" ? visibleNodes[0] : visibleNodes.at(-1))?.id ?? id);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (hasChildren(id) && !expanded.has(id)) toggleExpanded(id);\n else if (hasChildren(id))\n focusNode(nodes.find((candidate) => candidate.parentId === id)?.id ?? id);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (hasChildren(id) && expanded.has(id)) toggleExpanded(id);\n else if (node.parentId) focusNode(node.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectNode(id);\n }\n },\n [\n disabled,\n expanded,\n focusNode,\n hasChildren,\n loopFocus,\n nodes,\n selectNode,\n toggleExpanded,\n visibleNodes,\n ],\n );\n\n const context = useMemo<TreeViewContextValue>(\n () => ({\n disabled,\n loopFocus,\n selectionMode,\n expanded,\n selected,\n nodes,\n registerNode,\n setNodeElement,\n isVisible,\n hasChildren,\n getDepth,\n getSiblings,\n toggleExpanded,\n selectNode,\n focusNode,\n handleKeyDown,\n activeId,\n setActiveId,\n }),\n [\n activeId,\n disabled,\n expanded,\n focusNode,\n getDepth,\n getSiblings,\n handleKeyDown,\n hasChildren,\n isVisible,\n loopFocus,\n nodes,\n registerNode,\n selectNode,\n selected,\n selectionMode,\n setNodeElement,\n toggleExpanded,\n ],\n );\n\n return (\n <TreeViewContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n aria-multiselectable={selectionMode === \"multiple\" || undefined}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"tree-view\"\n data-slot=\"tree-view\"\n role=\"tree\"\n >\n {children}\n </div>\n </TreeViewContext.Provider>\n );\n});\n\nexport interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"id\"> {\n id: string;\n disabled?: boolean;\n hasChildren?: boolean;\n loading?: boolean;\n selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = false,\n hasChildren: hasChildrenProp = false,\n loading = false,\n onClick,\n onFocus,\n onKeyDown,\n style,\n selectable = true,\n id,\n ...props\n },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n useEffect(\n () =>\n context.registerNode({\n id,\n parentId,\n disabled,\n hasChildren: hasChildrenProp,\n loading,\n selectable,\n order: 0,\n element: null,\n }),\n [context.registerNode, disabled, hasChildrenProp, id, loading, parentId, selectable],\n );\n const siblings = context.getSiblings(id);\n const registeredNode = context.nodes.find((candidate) => candidate.id === id);\n const selected = context.selected.has(id);\n const visible = context.isVisible(id);\n const siblingIndex = siblings.findIndex((candidate) => candidate.id === id);\n const tabIndex =\n context.activeId === id || (context.activeId === null && context.nodes[0]?.id === id) ? 0 : -1;\n const childNodes = Children.toArray(children);\n const groupNodes = childNodes.filter(\n (child) => isValidElement(child) && child.type === TreeViewGroup,\n );\n const rowNodes = childNodes.filter(\n (child) => !(isValidElement(child) && child.type === TreeViewGroup),\n );\n\n return (\n <TreeParentContext.Provider value={id}>\n <TreeItemContext.Provider value={id}>\n <div\n {...props}\n ref={(element) => {\n context.setNodeElement(id, element);\n if (typeof ref === \"function\") ref(element);\n else if (ref) ref.current = element;\n }}\n aria-disabled={disabled || undefined}\n aria-expanded={context.hasChildren(id) ? context.expanded.has(id) : undefined}\n aria-busy={loading || undefined}\n aria-level={registeredNode ? context.getDepth(id) : parentId ? 2 : 1}\n aria-posinset={siblingIndex >= 0 ? siblingIndex + 1 : 1}\n aria-setsize={siblings.length || 1}\n aria-selected={context.selectionMode === \"none\" ? undefined : selected}\n className={styles.itemWrapper}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-jaci-component=\"tree-view\"\n data-selected={selected || undefined}\n data-loading={loading || undefined}\n data-slot=\"tree-view-item\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented) context.selectNode(id);\n }}\n onFocus={(event) => {\n context.setActiveId(id);\n onFocus?.(event);\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n context.handleKeyDown(id, event);\n onKeyDown?.(event);\n }}\n role=\"treeitem\"\n tabIndex={visible ? tabIndex : -1}\n >\n <div\n className={cx(styles.item, className)}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-selected={selected || undefined}\n data-slot=\"tree-view-item-row\"\n style={style}\n >\n {rowNodes}\n </div>\n {groupNodes}\n </div>\n </TreeItemContext.Provider>\n </TreeParentContext.Provider>\n );\n});\n\nexport type TreeViewGroupProps = ComponentPropsWithoutRef<\"div\">;\nexport const TreeViewGroup = forwardRef<HTMLDivElement, TreeViewGroupProps>(function TreeViewGroup(\n { children, className, style, ...props },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n const visible = parentId ? context.expanded.has(parentId) : true;\n return (\n // biome-ignore lint/a11y/useSemanticElements: WAI-ARIA tree groups require role=\"group\".\n <div\n {...props}\n ref={ref}\n aria-hidden={!visible || undefined}\n className={cx(styles.group, className)}\n data-jaci-component=\"tree-view\"\n data-expanded={visible || undefined}\n data-slot=\"tree-view-group\"\n hidden={!visible}\n role=\"group\"\n style={{ ...style, display: visible ? style?.display : \"none\" }}\n >\n {children}\n </div>\n );\n});\n\nexport type TreeViewToggleProps = ComponentPropsWithoutRef<\"button\">;\nexport const TreeViewToggle = forwardRef<HTMLButtonElement, TreeViewToggleProps>(\n function TreeViewToggle({ children, className, onClick, ...props }, ref) {\n const context = useTreeViewContext();\n const itemId = useContext(TreeItemContext);\n const id = itemId;\n const item = id ? context.nodes.find((candidate) => candidate.id === id) : undefined;\n const disabled = context.disabled || Boolean(item?.disabled);\n return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n aria-disabled={disabled || undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\n disabled={disabled || props.disabled}\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented && id) context.toggleExpanded(id);\n }}\n tabIndex={-1}\n type=\"button\"\n >\n {children ?? (id && context.expanded.has(id) ? \"▾\" : \"▸\")}\n </button>\n );\n },\n);\n\nexport type TreeViewLabelProps = ComponentPropsWithoutRef<\"span\">;\nexport const TreeViewLabel = forwardRef<HTMLSpanElement, TreeViewLabelProps>(function TreeViewLabel(\n { className, ...props },\n ref,\n) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(treeView().label, className)}\n data-slot=\"tree-view-label\"\n />\n );\n});\n\nexport interface TreeViewStateProps extends ComponentPropsWithoutRef<\"div\"> {\n children?: ReactNode;\n}\n\nexport const TreeViewLoading = forwardRef<HTMLDivElement, TreeViewStateProps>(\n function TreeViewLoading({ children = \"Loading…\", className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"polite\"\n aria-level={1}\n className={cx(treeView().loading, className)}\n data-slot=\"tree-view-loading\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n },\n);\n\nexport const TreeViewEmpty = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewEmpty(\n { children = \"No items found.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-level={1}\n className={cx(treeView().empty, className)}\n data-slot=\"tree-view-empty\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeViewError = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewError(\n { children = \"Something went wrong.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"assertive\"\n aria-level={1}\n className={cx(treeView().error, className)}\n data-slot=\"tree-view-error\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem,\n Group: TreeViewGroup,\n Toggle: TreeViewToggle,\n Label: TreeViewLabel,\n Loading: TreeViewLoading,\n Empty: TreeViewEmpty,\n Error: TreeViewError,\n};\n"],"mappings":";;;;;;AAqDA,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;AACvE,MAAM,qBAAA,GAAA,MAAA,cAAA,CAAsD,KAAA,CAAS;AACrE,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA+C,IAAI;AAEzD,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,MAAM,OAAsD,MAA6B;CAChG,IAAI,SAAS,YAAY,OAAO,IAAI,IAAI,MAAM,QAAQ,KAAK,IAAI,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC;CAC3F,OAAO,IAAI,IAAI,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI,CAAC,CAAC;AACzD;AAeA,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA6D,SAAS,aACjF,EACE,UACA,WACA,kBAAkB,CAAC,GACnB,kBAAkB,MAClB,WAAW,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;CACE,CAAA;AAET,CAAC;AAED,MAAa,iBAAA,GAAA,MAAA,WAAA,CAA+D,SAAS,cACnF,EAAE,WAAW,yBAAyB,WAAW,GAAG,SACpD,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,iBAAc;EACd,aAAU;EACV,cAAY;EACZ,WAAWC,WAAAA,GAAGD,kBAAAA,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,SAAS;CACT,OAAO;CACP,OAAO;AACT"}
|
|
@@ -18,6 +18,8 @@ declare const TreeViewRoot: import("react").ForwardRefExoticComponent<TreeViewRo
|
|
|
18
18
|
interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<"div">, "id"> {
|
|
19
19
|
id: string;
|
|
20
20
|
disabled?: boolean;
|
|
21
|
+
hasChildren?: boolean;
|
|
22
|
+
loading?: boolean;
|
|
21
23
|
selectable?: boolean;
|
|
22
24
|
}
|
|
23
25
|
declare const TreeViewItem: import("react").ForwardRefExoticComponent<TreeViewItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -27,13 +29,22 @@ type TreeViewToggleProps = ComponentPropsWithoutRef<"button">;
|
|
|
27
29
|
declare const TreeViewToggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
28
30
|
type TreeViewLabelProps = ComponentPropsWithoutRef<"span">;
|
|
29
31
|
declare const TreeViewLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
32
|
+
interface TreeViewStateProps extends ComponentPropsWithoutRef<"div"> {
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
declare const TreeViewLoading: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
|
+
declare const TreeViewEmpty: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
37
|
+
declare const TreeViewError: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
38
|
declare const TreeView: {
|
|
31
39
|
Root: import("react").ForwardRefExoticComponent<TreeViewRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
40
|
Item: import("react").ForwardRefExoticComponent<TreeViewItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
33
41
|
Group: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
42
|
Toggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
35
43
|
Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
44
|
+
Loading: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
45
|
+
Empty: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
46
|
+
Error: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
47
|
};
|
|
37
48
|
//#endregion
|
|
38
|
-
export { TreeView, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewToggle, TreeViewToggleProps };
|
|
49
|
+
export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewLoading, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewStateProps, TreeViewToggle, TreeViewToggleProps };
|
|
39
50
|
//# sourceMappingURL=tree-view.d.cts.map
|
|
@@ -18,6 +18,8 @@ declare const TreeViewRoot: import("react").ForwardRefExoticComponent<TreeViewRo
|
|
|
18
18
|
interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<"div">, "id"> {
|
|
19
19
|
id: string;
|
|
20
20
|
disabled?: boolean;
|
|
21
|
+
hasChildren?: boolean;
|
|
22
|
+
loading?: boolean;
|
|
21
23
|
selectable?: boolean;
|
|
22
24
|
}
|
|
23
25
|
declare const TreeViewItem: import("react").ForwardRefExoticComponent<TreeViewItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -27,13 +29,22 @@ type TreeViewToggleProps = ComponentPropsWithoutRef<"button">;
|
|
|
27
29
|
declare const TreeViewToggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
28
30
|
type TreeViewLabelProps = ComponentPropsWithoutRef<"span">;
|
|
29
31
|
declare const TreeViewLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
32
|
+
interface TreeViewStateProps extends ComponentPropsWithoutRef<"div"> {
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
declare const TreeViewLoading: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
|
+
declare const TreeViewEmpty: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
37
|
+
declare const TreeViewError: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
38
|
declare const TreeView: {
|
|
31
39
|
Root: import("react").ForwardRefExoticComponent<TreeViewRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
40
|
Item: import("react").ForwardRefExoticComponent<TreeViewItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
33
41
|
Group: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
42
|
Toggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
35
43
|
Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
44
|
+
Loading: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
45
|
+
Empty: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
46
|
+
Error: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
47
|
};
|
|
37
48
|
//#endregion
|
|
38
|
-
export { TreeView, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewToggle, TreeViewToggleProps };
|
|
49
|
+
export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewLoading, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewStateProps, TreeViewToggle, TreeViewToggleProps };
|
|
39
50
|
//# sourceMappingURL=tree-view.d.ts.map
|
|
@@ -47,7 +47,7 @@ const TreeViewRoot = forwardRef(function TreeViewRoot({ children, className, def
|
|
|
47
47
|
const node = nodesRef.current.get(id);
|
|
48
48
|
if (node) node.element = element;
|
|
49
49
|
}, []);
|
|
50
|
-
const hasChildren = useCallback((id) => nodes.some((node) => node.parentId === id), [nodes]);
|
|
50
|
+
const hasChildren = useCallback((id) => nodes.some((node) => node.parentId === id) || Boolean(nodes.find((node) => node.id === id)?.hasChildren), [nodes]);
|
|
51
51
|
const isVisible = useCallback((id) => {
|
|
52
52
|
let current = nodes.find((node) => node.id === id);
|
|
53
53
|
while (current?.parentId) {
|
|
@@ -199,7 +199,7 @@ const TreeViewRoot = forwardRef(function TreeViewRoot({ children, className, def
|
|
|
199
199
|
})
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
|
-
const TreeViewItem = forwardRef(function TreeViewItem({ children, className, disabled = false, onClick, onFocus, onKeyDown, style, selectable = true, id, ...props }, ref) {
|
|
202
|
+
const TreeViewItem = forwardRef(function TreeViewItem({ children, className, disabled = false, hasChildren: hasChildrenProp = false, loading = false, onClick, onFocus, onKeyDown, style, selectable = true, id, ...props }, ref) {
|
|
203
203
|
const context = useTreeViewContext();
|
|
204
204
|
const parentId = useContext(TreeParentContext);
|
|
205
205
|
const styles = treeView();
|
|
@@ -207,13 +207,17 @@ const TreeViewItem = forwardRef(function TreeViewItem({ children, className, dis
|
|
|
207
207
|
id,
|
|
208
208
|
parentId,
|
|
209
209
|
disabled,
|
|
210
|
+
hasChildren: hasChildrenProp,
|
|
211
|
+
loading,
|
|
210
212
|
selectable,
|
|
211
213
|
order: 0,
|
|
212
214
|
element: null
|
|
213
215
|
}), [
|
|
214
216
|
context.registerNode,
|
|
215
217
|
disabled,
|
|
218
|
+
hasChildrenProp,
|
|
216
219
|
id,
|
|
220
|
+
loading,
|
|
217
221
|
parentId,
|
|
218
222
|
selectable
|
|
219
223
|
]);
|
|
@@ -239,6 +243,7 @@ const TreeViewItem = forwardRef(function TreeViewItem({ children, className, dis
|
|
|
239
243
|
},
|
|
240
244
|
"aria-disabled": disabled || void 0,
|
|
241
245
|
"aria-expanded": context.hasChildren(id) ? context.expanded.has(id) : void 0,
|
|
246
|
+
"aria-busy": loading || void 0,
|
|
242
247
|
"aria-level": registeredNode ? context.getDepth(id) : parentId ? 2 : 1,
|
|
243
248
|
"aria-posinset": siblingIndex >= 0 ? siblingIndex + 1 : 1,
|
|
244
249
|
"aria-setsize": siblings.length || 1,
|
|
@@ -248,6 +253,7 @@ const TreeViewItem = forwardRef(function TreeViewItem({ children, className, dis
|
|
|
248
253
|
"data-expanded": context.expanded.has(id) || void 0,
|
|
249
254
|
"data-jaci-component": "tree-view",
|
|
250
255
|
"data-selected": selected || void 0,
|
|
256
|
+
"data-loading": loading || void 0,
|
|
251
257
|
"data-slot": "tree-view-item",
|
|
252
258
|
onClick: (event) => {
|
|
253
259
|
event.stopPropagation();
|
|
@@ -303,12 +309,16 @@ const TreeViewGroup = forwardRef(function TreeViewGroup({ children, className, s
|
|
|
303
309
|
const TreeViewToggle = forwardRef(function TreeViewToggle({ children, className, onClick, ...props }, ref) {
|
|
304
310
|
const context = useTreeViewContext();
|
|
305
311
|
const id = useContext(TreeItemContext);
|
|
312
|
+
const item = id ? context.nodes.find((candidate) => candidate.id === id) : void 0;
|
|
313
|
+
const disabled = context.disabled || Boolean(item?.disabled);
|
|
306
314
|
return /* @__PURE__ */ jsx("button", {
|
|
307
315
|
...props,
|
|
308
316
|
ref,
|
|
309
317
|
"aria-expanded": id ? context.expanded.has(id) : void 0,
|
|
318
|
+
"aria-disabled": disabled || void 0,
|
|
310
319
|
className: cx(treeView().toggle, className),
|
|
311
320
|
"data-slot": "tree-view-toggle",
|
|
321
|
+
disabled: disabled || props.disabled,
|
|
312
322
|
onClick: (event) => {
|
|
313
323
|
event.stopPropagation();
|
|
314
324
|
onClick?.(event);
|
|
@@ -327,14 +337,58 @@ const TreeViewLabel = forwardRef(function TreeViewLabel({ className, ...props },
|
|
|
327
337
|
"data-slot": "tree-view-label"
|
|
328
338
|
});
|
|
329
339
|
});
|
|
340
|
+
const TreeViewLoading = forwardRef(function TreeViewLoading({ children = "Loading…", className, ...props }, ref) {
|
|
341
|
+
return /* @__PURE__ */ jsx("div", {
|
|
342
|
+
...props,
|
|
343
|
+
ref,
|
|
344
|
+
"aria-disabled": "true",
|
|
345
|
+
"aria-live": "polite",
|
|
346
|
+
"aria-level": 1,
|
|
347
|
+
className: cx(treeView().loading, className),
|
|
348
|
+
"data-slot": "tree-view-loading",
|
|
349
|
+
role: "treeitem",
|
|
350
|
+
tabIndex: -1,
|
|
351
|
+
children
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
const TreeViewEmpty = forwardRef(function TreeViewEmpty({ children = "No items found.", className, ...props }, ref) {
|
|
355
|
+
return /* @__PURE__ */ jsx("div", {
|
|
356
|
+
...props,
|
|
357
|
+
ref,
|
|
358
|
+
"aria-disabled": "true",
|
|
359
|
+
"aria-level": 1,
|
|
360
|
+
className: cx(treeView().empty, className),
|
|
361
|
+
"data-slot": "tree-view-empty",
|
|
362
|
+
role: "treeitem",
|
|
363
|
+
tabIndex: -1,
|
|
364
|
+
children
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
const TreeViewError = forwardRef(function TreeViewError({ children = "Something went wrong.", className, ...props }, ref) {
|
|
368
|
+
return /* @__PURE__ */ jsx("div", {
|
|
369
|
+
...props,
|
|
370
|
+
ref,
|
|
371
|
+
"aria-disabled": "true",
|
|
372
|
+
"aria-live": "assertive",
|
|
373
|
+
"aria-level": 1,
|
|
374
|
+
className: cx(treeView().error, className),
|
|
375
|
+
"data-slot": "tree-view-error",
|
|
376
|
+
role: "treeitem",
|
|
377
|
+
tabIndex: -1,
|
|
378
|
+
children
|
|
379
|
+
});
|
|
380
|
+
});
|
|
330
381
|
const TreeView = {
|
|
331
382
|
Root: TreeViewRoot,
|
|
332
383
|
Item: TreeViewItem,
|
|
333
384
|
Group: TreeViewGroup,
|
|
334
385
|
Toggle: TreeViewToggle,
|
|
335
|
-
Label: TreeViewLabel
|
|
386
|
+
Label: TreeViewLabel,
|
|
387
|
+
Loading: TreeViewLoading,
|
|
388
|
+
Empty: TreeViewEmpty,
|
|
389
|
+
Error: TreeViewError
|
|
336
390
|
};
|
|
337
391
|
//#endregion
|
|
338
|
-
export { TreeView, TreeViewGroup, TreeViewItem, TreeViewLabel, TreeViewRoot, TreeViewToggle };
|
|
392
|
+
export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewItem, TreeViewLabel, TreeViewLoading, TreeViewRoot, TreeViewToggle };
|
|
339
393
|
|
|
340
394
|
//# sourceMappingURL=tree-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-view.js","names":[],"sources":["../../../src/components/tree-view/tree-view.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Children, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { treeView } from \"../../styled-system/recipes\";\n\nexport type TreeViewSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TreeViewSelection = string | readonly string[] | null;\n\ninterface TreeNodeRecord {\n id: string;\n parentId: string | undefined;\n disabled: boolean;\n selectable: boolean;\n order: number;\n element: HTMLDivElement | null;\n}\n\ninterface TreeViewContextValue {\n disabled: boolean;\n loopFocus: boolean;\n selectionMode: TreeViewSelectionMode;\n expanded: ReadonlySet<string>;\n selected: ReadonlySet<string>;\n nodes: readonly TreeNodeRecord[];\n registerNode: (node: TreeNodeRecord) => () => void;\n setNodeElement: (id: string, element: HTMLDivElement | null) => void;\n isVisible: (id: string) => boolean;\n hasChildren: (id: string) => boolean;\n getDepth: (id: string) => number;\n getSiblings: (id: string) => readonly TreeNodeRecord[];\n toggleExpanded: (id: string) => void;\n selectNode: (id: string) => void;\n focusNode: (id: string) => void;\n handleKeyDown: (id: string, event: KeyboardEvent<HTMLDivElement>) => void;\n activeId: string | null;\n setActiveId: (id: string) => void;\n}\n\nconst TreeViewContext = createContext<TreeViewContextValue | null>(null);\nconst TreeParentContext = createContext<string | undefined>(undefined);\nconst TreeItemContext = createContext<string | null>(null);\n\nfunction useTreeViewContext() {\n const context = useContext(TreeViewContext);\n if (!context) throw new Error(\"TreeView parts must be rendered inside TreeView.Root.\");\n return context;\n}\n\nfunction asSet(value: string | readonly string[] | null | undefined, mode: TreeViewSelectionMode) {\n if (mode === \"multiple\") return new Set(Array.isArray(value) ? value : value ? [value] : []);\n return new Set(typeof value === \"string\" ? [value] : []);\n}\n\nexport interface TreeViewRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n expanded?: readonly string[];\n defaultExpanded?: readonly string[];\n onExpandedChange?: (expanded: string[]) => void;\n selected?: TreeViewSelection;\n defaultSelected?: TreeViewSelection;\n onSelectedChange?: (selected: TreeViewSelection) => void;\n selectionMode?: TreeViewSelectionMode;\n loopFocus?: boolean;\n disabled?: boolean;\n children?: ReactNode;\n}\n\nexport const TreeViewRoot = forwardRef<HTMLDivElement, TreeViewRootProps>(function TreeViewRoot(\n {\n children,\n className,\n defaultExpanded = [],\n defaultSelected = null,\n disabled = false,\n expanded: controlledExpanded,\n loopFocus = true,\n onExpandedChange,\n onSelectedChange,\n selected: controlledSelected,\n selectionMode = \"single\",\n ...props\n },\n ref,\n) {\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpanded));\n const [uncontrolledSelected, setUncontrolledSelected] = useState(() =>\n asSet(defaultSelected, selectionMode),\n );\n const [activeId, setActiveId] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const nodesRef = useRef(new Map<string, TreeNodeRecord>());\n const orderRef = useRef(0);\n const styles = treeView();\n const expanded = useMemo(\n () => new Set(controlledExpanded ?? uncontrolledExpanded),\n [controlledExpanded, uncontrolledExpanded],\n );\n const selected = useMemo(\n () =>\n controlledSelected === undefined\n ? uncontrolledSelected\n : asSet(controlledSelected, selectionMode),\n [controlledSelected, selectionMode, uncontrolledSelected],\n );\n const nodes = Array.from(nodesRef.current.values()).sort((a, b) => a.order - b.order);\n\n const registerNode = useCallback((node: TreeNodeRecord) => {\n const registeredNode = { ...node, order: orderRef.current++ };\n nodesRef.current.set(node.id, registeredNode);\n setVersion((current) => current + 1);\n return () => {\n if (nodesRef.current.get(node.id) === registeredNode) nodesRef.current.delete(node.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setNodeElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const node = nodesRef.current.get(id);\n if (node) node.element = element;\n }, []);\n\n const hasChildren = useCallback(\n (id: string) => nodes.some((node) => node.parentId === id),\n [nodes],\n );\n const isVisible = useCallback(\n (id: string) => {\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n if (!expanded.has(current.parentId)) return false;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return true;\n },\n [expanded, nodes],\n );\n const getDepth = useCallback(\n (id: string) => {\n let depth = 1;\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n depth += 1;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return depth;\n },\n [nodes],\n );\n const getSiblings = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n return nodes.filter((candidate) => candidate.parentId === node?.parentId);\n },\n [nodes],\n );\n\n const toggleExpanded = useCallback(\n (id: string) => {\n if (disabled || !hasChildren(id)) return;\n const next = new Set(expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledExpanded === undefined) setUncontrolledExpanded(next);\n onExpandedChange?.(Array.from(next));\n },\n [controlledExpanded, disabled, expanded, hasChildren, onExpandedChange],\n );\n\n const selectNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (disabled || !node || node.disabled || !node.selectable || selectionMode === \"none\")\n return;\n const next = new Set(selected);\n if (selectionMode === \"single\") {\n next.clear();\n next.add(id);\n } else if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledSelected === undefined) setUncontrolledSelected(next);\n onSelectedChange?.(\n selectionMode === \"multiple\" ? Array.from(next) : (next.values().next().value ?? null),\n );\n },\n [controlledSelected, disabled, nodes, onSelectedChange, selected, selectionMode],\n );\n\n const visibleNodes = nodes.filter((node) => isVisible(node.id));\n const focusNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node || node.disabled || !isVisible(id)) return;\n setActiveId(id);\n node.element?.focus();\n },\n [isVisible, nodes],\n );\n\n const handleKeyDown = useCallback(\n (id: string, event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const index = visibleNodes.findIndex((node) => node.id === id);\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = index + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleNodes.length) % visibleNodes.length;\n const nextNode = visibleNodes[nextIndex];\n if (nextIndex >= 0 && nextIndex < visibleNodes.length && nextNode) focusNode(nextNode.id);\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusNode((event.key === \"Home\" ? visibleNodes[0] : visibleNodes.at(-1))?.id ?? id);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (hasChildren(id) && !expanded.has(id)) toggleExpanded(id);\n else if (hasChildren(id))\n focusNode(nodes.find((candidate) => candidate.parentId === id)?.id ?? id);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (hasChildren(id) && expanded.has(id)) toggleExpanded(id);\n else if (node.parentId) focusNode(node.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectNode(id);\n }\n },\n [\n disabled,\n expanded,\n focusNode,\n hasChildren,\n loopFocus,\n nodes,\n selectNode,\n toggleExpanded,\n visibleNodes,\n ],\n );\n\n const context = useMemo<TreeViewContextValue>(\n () => ({\n disabled,\n loopFocus,\n selectionMode,\n expanded,\n selected,\n nodes,\n registerNode,\n setNodeElement,\n isVisible,\n hasChildren,\n getDepth,\n getSiblings,\n toggleExpanded,\n selectNode,\n focusNode,\n handleKeyDown,\n activeId,\n setActiveId,\n }),\n [\n activeId,\n disabled,\n expanded,\n focusNode,\n getDepth,\n getSiblings,\n handleKeyDown,\n hasChildren,\n isVisible,\n loopFocus,\n nodes,\n registerNode,\n selectNode,\n selected,\n selectionMode,\n setNodeElement,\n toggleExpanded,\n ],\n );\n\n return (\n <TreeViewContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n aria-multiselectable={selectionMode === \"multiple\" || undefined}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"tree-view\"\n data-slot=\"tree-view\"\n role=\"tree\"\n >\n {children}\n </div>\n </TreeViewContext.Provider>\n );\n});\n\nexport interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"id\"> {\n id: string;\n disabled?: boolean;\n selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = false,\n onClick,\n onFocus,\n onKeyDown,\n style,\n selectable = true,\n id,\n ...props\n },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n useEffect(\n () => context.registerNode({ id, parentId, disabled, selectable, order: 0, element: null }),\n [context.registerNode, disabled, id, parentId, selectable],\n );\n const siblings = context.getSiblings(id);\n const registeredNode = context.nodes.find((candidate) => candidate.id === id);\n const selected = context.selected.has(id);\n const visible = context.isVisible(id);\n const siblingIndex = siblings.findIndex((candidate) => candidate.id === id);\n const tabIndex =\n context.activeId === id || (context.activeId === null && context.nodes[0]?.id === id) ? 0 : -1;\n const childNodes = Children.toArray(children);\n const groupNodes = childNodes.filter(\n (child) => isValidElement(child) && child.type === TreeViewGroup,\n );\n const rowNodes = childNodes.filter(\n (child) => !(isValidElement(child) && child.type === TreeViewGroup),\n );\n\n return (\n <TreeParentContext.Provider value={id}>\n <TreeItemContext.Provider value={id}>\n <div\n {...props}\n ref={(element) => {\n context.setNodeElement(id, element);\n if (typeof ref === \"function\") ref(element);\n else if (ref) ref.current = element;\n }}\n aria-disabled={disabled || undefined}\n aria-expanded={context.hasChildren(id) ? context.expanded.has(id) : undefined}\n aria-level={registeredNode ? context.getDepth(id) : parentId ? 2 : 1}\n aria-posinset={siblingIndex >= 0 ? siblingIndex + 1 : 1}\n aria-setsize={siblings.length || 1}\n aria-selected={context.selectionMode === \"none\" ? undefined : selected}\n className={styles.itemWrapper}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-jaci-component=\"tree-view\"\n data-selected={selected || undefined}\n data-slot=\"tree-view-item\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented) context.selectNode(id);\n }}\n onFocus={(event) => {\n context.setActiveId(id);\n onFocus?.(event);\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n context.handleKeyDown(id, event);\n onKeyDown?.(event);\n }}\n role=\"treeitem\"\n tabIndex={visible ? tabIndex : -1}\n >\n <div\n className={cx(styles.item, className)}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-selected={selected || undefined}\n data-slot=\"tree-view-item-row\"\n style={style}\n >\n {rowNodes}\n </div>\n {groupNodes}\n </div>\n </TreeItemContext.Provider>\n </TreeParentContext.Provider>\n );\n});\n\nexport type TreeViewGroupProps = ComponentPropsWithoutRef<\"div\">;\nexport const TreeViewGroup = forwardRef<HTMLDivElement, TreeViewGroupProps>(function TreeViewGroup(\n { children, className, style, ...props },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n const visible = parentId ? context.expanded.has(parentId) : true;\n return (\n // biome-ignore lint/a11y/useSemanticElements: WAI-ARIA tree groups require role=\"group\".\n <div\n {...props}\n ref={ref}\n aria-hidden={!visible || undefined}\n className={cx(styles.group, className)}\n data-jaci-component=\"tree-view\"\n data-expanded={visible || undefined}\n data-slot=\"tree-view-group\"\n hidden={!visible}\n role=\"group\"\n style={{ ...style, display: visible ? style?.display : \"none\" }}\n >\n {children}\n </div>\n );\n});\n\nexport type TreeViewToggleProps = ComponentPropsWithoutRef<\"button\">;\nexport const TreeViewToggle = forwardRef<HTMLButtonElement, TreeViewToggleProps>(\n function TreeViewToggle({ children, className, onClick, ...props }, ref) {\n const context = useTreeViewContext();\n const itemId = useContext(TreeItemContext);\n const id = itemId;\n return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented && id) context.toggleExpanded(id);\n }}\n tabIndex={-1}\n type=\"button\"\n >\n {children ?? (id && context.expanded.has(id) ? \"▾\" : \"▸\")}\n </button>\n );\n },\n);\n\nexport type TreeViewLabelProps = ComponentPropsWithoutRef<\"span\">;\nexport const TreeViewLabel = forwardRef<HTMLSpanElement, TreeViewLabelProps>(function TreeViewLabel(\n { className, ...props },\n ref,\n) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(treeView().label, className)}\n data-slot=\"tree-view-label\"\n />\n );\n});\n\nexport const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem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;EACzC,aAAU;CACX,CAAA;AAEL,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"tree-view.js","names":[],"sources":["../../../src/components/tree-view/tree-view.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Children, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { treeView } from \"../../styled-system/recipes\";\n\nexport type TreeViewSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TreeViewSelection = string | readonly string[] | null;\n\ninterface TreeNodeRecord {\n id: string;\n parentId: string | undefined;\n disabled: boolean;\n hasChildren: boolean;\n loading: boolean;\n selectable: boolean;\n order: number;\n element: HTMLDivElement | null;\n}\n\ninterface TreeViewContextValue {\n disabled: boolean;\n loopFocus: boolean;\n selectionMode: TreeViewSelectionMode;\n expanded: ReadonlySet<string>;\n selected: ReadonlySet<string>;\n nodes: readonly TreeNodeRecord[];\n registerNode: (node: TreeNodeRecord) => () => void;\n setNodeElement: (id: string, element: HTMLDivElement | null) => void;\n isVisible: (id: string) => boolean;\n hasChildren: (id: string) => boolean;\n getDepth: (id: string) => number;\n getSiblings: (id: string) => readonly TreeNodeRecord[];\n toggleExpanded: (id: string) => void;\n selectNode: (id: string) => void;\n focusNode: (id: string) => void;\n handleKeyDown: (id: string, event: KeyboardEvent<HTMLDivElement>) => void;\n activeId: string | null;\n setActiveId: (id: string) => void;\n}\n\nconst TreeViewContext = createContext<TreeViewContextValue | null>(null);\nconst TreeParentContext = createContext<string | undefined>(undefined);\nconst TreeItemContext = createContext<string | null>(null);\n\nfunction useTreeViewContext() {\n const context = useContext(TreeViewContext);\n if (!context) throw new Error(\"TreeView parts must be rendered inside TreeView.Root.\");\n return context;\n}\n\nfunction asSet(value: string | readonly string[] | null | undefined, mode: TreeViewSelectionMode) {\n if (mode === \"multiple\") return new Set(Array.isArray(value) ? value : value ? [value] : []);\n return new Set(typeof value === \"string\" ? [value] : []);\n}\n\nexport interface TreeViewRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n expanded?: readonly string[];\n defaultExpanded?: readonly string[];\n onExpandedChange?: (expanded: string[]) => void;\n selected?: TreeViewSelection;\n defaultSelected?: TreeViewSelection;\n onSelectedChange?: (selected: TreeViewSelection) => void;\n selectionMode?: TreeViewSelectionMode;\n loopFocus?: boolean;\n disabled?: boolean;\n children?: ReactNode;\n}\n\nexport const TreeViewRoot = forwardRef<HTMLDivElement, TreeViewRootProps>(function TreeViewRoot(\n {\n children,\n className,\n defaultExpanded = [],\n defaultSelected = null,\n disabled = false,\n expanded: controlledExpanded,\n loopFocus = true,\n onExpandedChange,\n onSelectedChange,\n selected: controlledSelected,\n selectionMode = \"single\",\n ...props\n },\n ref,\n) {\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpanded));\n const [uncontrolledSelected, setUncontrolledSelected] = useState(() =>\n asSet(defaultSelected, selectionMode),\n );\n const [activeId, setActiveId] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const nodesRef = useRef(new Map<string, TreeNodeRecord>());\n const orderRef = useRef(0);\n const styles = treeView();\n const expanded = useMemo(\n () => new Set(controlledExpanded ?? uncontrolledExpanded),\n [controlledExpanded, uncontrolledExpanded],\n );\n const selected = useMemo(\n () =>\n controlledSelected === undefined\n ? uncontrolledSelected\n : asSet(controlledSelected, selectionMode),\n [controlledSelected, selectionMode, uncontrolledSelected],\n );\n const nodes = Array.from(nodesRef.current.values()).sort((a, b) => a.order - b.order);\n\n const registerNode = useCallback((node: TreeNodeRecord) => {\n const registeredNode = { ...node, order: orderRef.current++ };\n nodesRef.current.set(node.id, registeredNode);\n setVersion((current) => current + 1);\n return () => {\n if (nodesRef.current.get(node.id) === registeredNode) nodesRef.current.delete(node.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setNodeElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const node = nodesRef.current.get(id);\n if (node) node.element = element;\n }, []);\n\n const hasChildren = useCallback(\n (id: string) =>\n nodes.some((node) => node.parentId === id) ||\n Boolean(nodes.find((node) => node.id === id)?.hasChildren),\n [nodes],\n );\n const isVisible = useCallback(\n (id: string) => {\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n if (!expanded.has(current.parentId)) return false;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return true;\n },\n [expanded, nodes],\n );\n const getDepth = useCallback(\n (id: string) => {\n let depth = 1;\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n depth += 1;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return depth;\n },\n [nodes],\n );\n const getSiblings = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n return nodes.filter((candidate) => candidate.parentId === node?.parentId);\n },\n [nodes],\n );\n\n const toggleExpanded = useCallback(\n (id: string) => {\n if (disabled || !hasChildren(id)) return;\n const next = new Set(expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledExpanded === undefined) setUncontrolledExpanded(next);\n onExpandedChange?.(Array.from(next));\n },\n [controlledExpanded, disabled, expanded, hasChildren, onExpandedChange],\n );\n\n const selectNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (disabled || !node || node.disabled || !node.selectable || selectionMode === \"none\")\n return;\n const next = new Set(selected);\n if (selectionMode === \"single\") {\n next.clear();\n next.add(id);\n } else if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledSelected === undefined) setUncontrolledSelected(next);\n onSelectedChange?.(\n selectionMode === \"multiple\" ? Array.from(next) : (next.values().next().value ?? null),\n );\n },\n [controlledSelected, disabled, nodes, onSelectedChange, selected, selectionMode],\n );\n\n const visibleNodes = nodes.filter((node) => isVisible(node.id));\n const focusNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node || node.disabled || !isVisible(id)) return;\n setActiveId(id);\n node.element?.focus();\n },\n [isVisible, nodes],\n );\n\n const handleKeyDown = useCallback(\n (id: string, event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const index = visibleNodes.findIndex((node) => node.id === id);\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = index + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleNodes.length) % visibleNodes.length;\n const nextNode = visibleNodes[nextIndex];\n if (nextIndex >= 0 && nextIndex < visibleNodes.length && nextNode) focusNode(nextNode.id);\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusNode((event.key === \"Home\" ? visibleNodes[0] : visibleNodes.at(-1))?.id ?? id);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (hasChildren(id) && !expanded.has(id)) toggleExpanded(id);\n else if (hasChildren(id))\n focusNode(nodes.find((candidate) => candidate.parentId === id)?.id ?? id);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (hasChildren(id) && expanded.has(id)) toggleExpanded(id);\n else if (node.parentId) focusNode(node.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectNode(id);\n }\n },\n [\n disabled,\n expanded,\n focusNode,\n hasChildren,\n loopFocus,\n nodes,\n selectNode,\n toggleExpanded,\n visibleNodes,\n ],\n );\n\n const context = useMemo<TreeViewContextValue>(\n () => ({\n disabled,\n loopFocus,\n selectionMode,\n expanded,\n selected,\n nodes,\n registerNode,\n setNodeElement,\n isVisible,\n hasChildren,\n getDepth,\n getSiblings,\n toggleExpanded,\n selectNode,\n focusNode,\n handleKeyDown,\n activeId,\n setActiveId,\n }),\n [\n activeId,\n disabled,\n expanded,\n focusNode,\n getDepth,\n getSiblings,\n handleKeyDown,\n hasChildren,\n isVisible,\n loopFocus,\n nodes,\n registerNode,\n selectNode,\n selected,\n selectionMode,\n setNodeElement,\n toggleExpanded,\n ],\n );\n\n return (\n <TreeViewContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n aria-multiselectable={selectionMode === \"multiple\" || undefined}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"tree-view\"\n data-slot=\"tree-view\"\n role=\"tree\"\n >\n {children}\n </div>\n </TreeViewContext.Provider>\n );\n});\n\nexport interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"id\"> {\n id: string;\n disabled?: boolean;\n hasChildren?: boolean;\n loading?: boolean;\n selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = false,\n hasChildren: hasChildrenProp = false,\n loading = false,\n onClick,\n onFocus,\n onKeyDown,\n style,\n selectable = true,\n id,\n ...props\n },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n useEffect(\n () =>\n context.registerNode({\n id,\n parentId,\n disabled,\n hasChildren: hasChildrenProp,\n loading,\n selectable,\n order: 0,\n element: null,\n }),\n [context.registerNode, disabled, hasChildrenProp, id, loading, parentId, selectable],\n );\n const siblings = context.getSiblings(id);\n const registeredNode = context.nodes.find((candidate) => candidate.id === id);\n const selected = context.selected.has(id);\n const visible = context.isVisible(id);\n const siblingIndex = siblings.findIndex((candidate) => candidate.id === id);\n const tabIndex =\n context.activeId === id || (context.activeId === null && context.nodes[0]?.id === id) ? 0 : -1;\n const childNodes = Children.toArray(children);\n const groupNodes = childNodes.filter(\n (child) => isValidElement(child) && child.type === TreeViewGroup,\n );\n const rowNodes = childNodes.filter(\n (child) => !(isValidElement(child) && child.type === TreeViewGroup),\n );\n\n return (\n <TreeParentContext.Provider value={id}>\n <TreeItemContext.Provider value={id}>\n <div\n {...props}\n ref={(element) => {\n context.setNodeElement(id, element);\n if (typeof ref === \"function\") ref(element);\n else if (ref) ref.current = element;\n }}\n aria-disabled={disabled || undefined}\n aria-expanded={context.hasChildren(id) ? context.expanded.has(id) : undefined}\n aria-busy={loading || undefined}\n aria-level={registeredNode ? context.getDepth(id) : parentId ? 2 : 1}\n aria-posinset={siblingIndex >= 0 ? siblingIndex + 1 : 1}\n aria-setsize={siblings.length || 1}\n aria-selected={context.selectionMode === \"none\" ? undefined : selected}\n className={styles.itemWrapper}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-jaci-component=\"tree-view\"\n data-selected={selected || undefined}\n data-loading={loading || undefined}\n data-slot=\"tree-view-item\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented) context.selectNode(id);\n }}\n onFocus={(event) => {\n context.setActiveId(id);\n onFocus?.(event);\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n context.handleKeyDown(id, event);\n onKeyDown?.(event);\n }}\n role=\"treeitem\"\n tabIndex={visible ? tabIndex : -1}\n >\n <div\n className={cx(styles.item, className)}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-selected={selected || undefined}\n data-slot=\"tree-view-item-row\"\n style={style}\n >\n {rowNodes}\n </div>\n {groupNodes}\n </div>\n </TreeItemContext.Provider>\n </TreeParentContext.Provider>\n );\n});\n\nexport type TreeViewGroupProps = ComponentPropsWithoutRef<\"div\">;\nexport const TreeViewGroup = forwardRef<HTMLDivElement, TreeViewGroupProps>(function TreeViewGroup(\n { children, className, style, ...props },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n const visible = parentId ? context.expanded.has(parentId) : true;\n return (\n // biome-ignore lint/a11y/useSemanticElements: WAI-ARIA tree groups require role=\"group\".\n <div\n {...props}\n ref={ref}\n aria-hidden={!visible || undefined}\n className={cx(styles.group, className)}\n data-jaci-component=\"tree-view\"\n data-expanded={visible || undefined}\n data-slot=\"tree-view-group\"\n hidden={!visible}\n role=\"group\"\n style={{ ...style, display: visible ? style?.display : \"none\" }}\n >\n {children}\n </div>\n );\n});\n\nexport type TreeViewToggleProps = ComponentPropsWithoutRef<\"button\">;\nexport const TreeViewToggle = forwardRef<HTMLButtonElement, TreeViewToggleProps>(\n function TreeViewToggle({ children, className, onClick, ...props }, ref) {\n const context = useTreeViewContext();\n const itemId = useContext(TreeItemContext);\n const id = itemId;\n const item = id ? context.nodes.find((candidate) => candidate.id === id) : undefined;\n const disabled = context.disabled || Boolean(item?.disabled);\n return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n aria-disabled={disabled || undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\n disabled={disabled || props.disabled}\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented && id) context.toggleExpanded(id);\n }}\n tabIndex={-1}\n type=\"button\"\n >\n {children ?? (id && context.expanded.has(id) ? \"▾\" : \"▸\")}\n </button>\n );\n },\n);\n\nexport type TreeViewLabelProps = ComponentPropsWithoutRef<\"span\">;\nexport const TreeViewLabel = forwardRef<HTMLSpanElement, TreeViewLabelProps>(function TreeViewLabel(\n { className, ...props },\n ref,\n) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(treeView().label, className)}\n data-slot=\"tree-view-label\"\n />\n );\n});\n\nexport interface TreeViewStateProps extends ComponentPropsWithoutRef<\"div\"> {\n children?: ReactNode;\n}\n\nexport const TreeViewLoading = forwardRef<HTMLDivElement, TreeViewStateProps>(\n function TreeViewLoading({ children = \"Loading…\", className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"polite\"\n aria-level={1}\n className={cx(treeView().loading, className)}\n data-slot=\"tree-view-loading\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n },\n);\n\nexport const TreeViewEmpty = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewEmpty(\n { children = \"No items found.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-level={1}\n className={cx(treeView().empty, className)}\n data-slot=\"tree-view-empty\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeViewError = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewError(\n { children = \"Something went wrong.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"assertive\"\n aria-level={1}\n className={cx(treeView().error, className)}\n data-slot=\"tree-view-error\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem,\n Group: TreeViewGroup,\n Toggle: TreeViewToggle,\n Label: TreeViewLabel,\n Loading: TreeViewLoading,\n Empty: TreeViewEmpty,\n Error: TreeViewError,\n};\n"],"mappings":";;;;;;AAqDA,MAAM,kBAAkB,cAA2C,IAAI;AACvE,MAAM,oBAAoB,cAAkC,KAAA,CAAS;AACrE,MAAM,kBAAkB,cAA6B,IAAI;AAEzD,SAAS,qBAAqB;CAC5B,MAAM,UAAU,WAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,MAAM,OAAsD,MAA6B;CAChG,IAAI,SAAS,YAAY,OAAO,IAAI,IAAI,MAAM,QAAQ,KAAK,IAAI,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC;CAC3F,OAAO,IAAI,IAAI,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI,CAAC,CAAC;AACzD;AAeA,MAAa,eAAe,WAA8C,SAAS,aACjF,EACE,UACA,WACA,kBAAkB,CAAC,GACnB,kBAAkB,MAClB,WAAW,OACX,UAAU,oB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ACE,CAAA;AAET,CACF;AAEA,MAAa,gBAAgB,WAA+C,SAAS,cACnF,EAAE,WAAW,mBAAmB,WAAW,GAAG,SAC9C,KACA;CACA,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,iBAAc;EACd,cAAY;EACZ,WAAW,GAAG,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,gBAAgB,WAA+C,SAAS,cACnF,EAAE,WAAW,yBAAyB,WAAW,GAAG,SACpD,KACA;CACA,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,iBAAc;EACd,aAAU;EACV,cAAY;EACZ,WAAW,GAAG,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,SAAS;CACT,OAAO;CACP,OAAO;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Upload, UploadDropzone, UploadDropzoneProps, UploadError, UploadErrorProps, UploadHint, UploadHintProps, UploadIcon, UploadIconProps, UploadInput, UploadInputProps, UploadItem, UploadItemProps, UploadList, UploadListProps, UploadPreview, UploadPreviewProps, UploadProgress, UploadProgressProps, UploadRejection, UploadRejectionReason, UploadRemove, UploadRemoveProps, UploadRoot, UploadRootProps, UploadText, UploadTextProps, UploadTrigger, UploadTriggerProps } from "./upload.cjs";
|
|
2
|
-
export { Upload, UploadDropzone, type UploadDropzoneProps, UploadError, type UploadErrorProps, UploadHint, type UploadHintProps, UploadIcon, type UploadIconProps, UploadInput, type UploadInputProps, UploadItem, type UploadItemProps, UploadList, type UploadListProps, UploadPreview, type UploadPreviewProps, UploadProgress, type UploadProgressProps, type UploadRejection, type UploadRejectionReason, UploadRemove, type UploadRemoveProps, UploadRoot, type UploadRootProps, UploadText, type UploadTextProps, UploadTrigger, type UploadTriggerProps };
|
|
1
|
+
import { Upload, UploadCancel, UploadCancelProps, UploadDropzone, UploadDropzoneProps, UploadError, UploadErrorProps, UploadFileState, UploadFileStatus, UploadHint, UploadHintProps, UploadIcon, UploadIconProps, UploadInput, UploadInputProps, UploadItem, UploadItemProps, UploadList, UploadListProps, UploadPreview, UploadPreviewProps, UploadProgress, UploadProgressProps, UploadRejection, UploadRejectionReason, UploadRemove, UploadRemoveProps, UploadRoot, UploadRootProps, UploadStatus, UploadStatusProps, UploadText, UploadTextProps, UploadTrigger, UploadTriggerProps } from "./upload.cjs";
|
|
2
|
+
export { Upload, UploadCancel, type UploadCancelProps, UploadDropzone, type UploadDropzoneProps, UploadError, type UploadErrorProps, type UploadFileState, type UploadFileStatus, UploadHint, type UploadHintProps, UploadIcon, type UploadIconProps, UploadInput, type UploadInputProps, UploadItem, type UploadItemProps, UploadList, type UploadListProps, UploadPreview, type UploadPreviewProps, UploadProgress, type UploadProgressProps, type UploadRejection, type UploadRejectionReason, UploadRemove, type UploadRemoveProps, UploadRoot, type UploadRootProps, UploadStatus, type UploadStatusProps, UploadText, type UploadTextProps, UploadTrigger, type UploadTriggerProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Upload, UploadDropzone, UploadDropzoneProps, UploadError, UploadErrorProps, UploadHint, UploadHintProps, UploadIcon, UploadIconProps, UploadInput, UploadInputProps, UploadItem, UploadItemProps, UploadList, UploadListProps, UploadPreview, UploadPreviewProps, UploadProgress, UploadProgressProps, UploadRejection, UploadRejectionReason, UploadRemove, UploadRemoveProps, UploadRoot, UploadRootProps, UploadText, UploadTextProps, UploadTrigger, UploadTriggerProps } from "./upload.js";
|
|
2
|
-
export { Upload, UploadDropzone, type UploadDropzoneProps, UploadError, type UploadErrorProps, UploadHint, type UploadHintProps, UploadIcon, type UploadIconProps, UploadInput, type UploadInputProps, UploadItem, type UploadItemProps, UploadList, type UploadListProps, UploadPreview, type UploadPreviewProps, UploadProgress, type UploadProgressProps, type UploadRejection, type UploadRejectionReason, UploadRemove, type UploadRemoveProps, UploadRoot, type UploadRootProps, UploadText, type UploadTextProps, UploadTrigger, type UploadTriggerProps };
|
|
1
|
+
import { Upload, UploadCancel, UploadCancelProps, UploadDropzone, UploadDropzoneProps, UploadError, UploadErrorProps, UploadFileState, UploadFileStatus, UploadHint, UploadHintProps, UploadIcon, UploadIconProps, UploadInput, UploadInputProps, UploadItem, UploadItemProps, UploadList, UploadListProps, UploadPreview, UploadPreviewProps, UploadProgress, UploadProgressProps, UploadRejection, UploadRejectionReason, UploadRemove, UploadRemoveProps, UploadRoot, UploadRootProps, UploadStatus, UploadStatusProps, UploadText, UploadTextProps, UploadTrigger, UploadTriggerProps } from "./upload.js";
|
|
2
|
+
export { Upload, UploadCancel, type UploadCancelProps, UploadDropzone, type UploadDropzoneProps, UploadError, type UploadErrorProps, type UploadFileState, type UploadFileStatus, UploadHint, type UploadHintProps, UploadIcon, type UploadIconProps, UploadInput, type UploadInputProps, UploadItem, type UploadItemProps, UploadList, type UploadListProps, UploadPreview, type UploadPreviewProps, UploadProgress, type UploadProgressProps, type UploadRejection, type UploadRejectionReason, UploadRemove, type UploadRemoveProps, UploadRoot, type UploadRootProps, UploadStatus, type UploadStatusProps, UploadText, type UploadTextProps, UploadTrigger, type UploadTriggerProps };
|