@neo4j-ndl/react 4.12.5 → 4.13.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/lib/cjs/icons/generated/custom/Appearance.js +30 -0
- package/lib/cjs/icons/generated/custom/Appearance.js.map +1 -0
- package/lib/cjs/icons/generated/custom/index.js +5 -3
- package/lib/cjs/icons/generated/custom/index.js.map +1 -1
- package/lib/cjs/next/index.js +16 -0
- package/lib/cjs/next/index.js.map +1 -1
- package/lib/cjs/next/tree-view/TreeView.js +460 -0
- package/lib/cjs/next/tree-view/TreeView.js.map +1 -0
- package/lib/cjs/next/tree-view/index.js +26 -0
- package/lib/cjs/next/tree-view/index.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/index.js +60 -0
- package/lib/cjs/next/tree-view/stories/index.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-actions.story.js +36 -0
- package/lib/cjs/next/tree-view/stories/tree-view-actions.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-lazy.story.js +149 -0
- package/lib/cjs/next/tree-view/stories/tree-view-lazy.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-multi.story.js +73 -0
- package/lib/cjs/next/tree-view/stories/tree-view-multi.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-non-selectable-folders.story.js +35 -0
- package/lib/cjs/next/tree-view/stories/tree-view-non-selectable-folders.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-single.story.js +35 -0
- package/lib/cjs/next/tree-view/stories/tree-view-single.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-tooltip.story.js +34 -0
- package/lib/cjs/next/tree-view/stories/tree-view-tooltip.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-trailing.story.js +34 -0
- package/lib/cjs/next/tree-view/stories/tree-view-trailing.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-uncontrolled.story.js +33 -0
- package/lib/cjs/next/tree-view/stories/tree-view-uncontrolled.story.js.map +1 -0
- package/lib/esm/icons/generated/custom/Appearance.js +28 -0
- package/lib/esm/icons/generated/custom/Appearance.js.map +1 -0
- package/lib/esm/icons/generated/custom/index.js +1 -0
- package/lib/esm/icons/generated/custom/index.js.map +1 -1
- package/lib/esm/next/index.js +1 -1
- package/lib/esm/next/index.js.map +1 -1
- package/lib/esm/next/tree-view/TreeView.js +454 -0
- package/lib/esm/next/tree-view/TreeView.js.map +1 -0
- package/lib/esm/next/tree-view/index.js +22 -0
- package/lib/esm/next/tree-view/index.js.map +1 -0
- package/lib/esm/next/tree-view/stories/index.js +46 -0
- package/lib/esm/next/tree-view/stories/index.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-actions.story.js +34 -0
- package/lib/esm/next/tree-view/stories/tree-view-actions.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-lazy.story.js +147 -0
- package/lib/esm/next/tree-view/stories/tree-view-lazy.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-multi.story.js +71 -0
- package/lib/esm/next/tree-view/stories/tree-view-multi.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-non-selectable-folders.story.js +33 -0
- package/lib/esm/next/tree-view/stories/tree-view-non-selectable-folders.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-single.story.js +33 -0
- package/lib/esm/next/tree-view/stories/tree-view-single.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-tooltip.story.js +32 -0
- package/lib/esm/next/tree-view/stories/tree-view-tooltip.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-trailing.story.js +32 -0
- package/lib/esm/next/tree-view/stories/tree-view-trailing.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-uncontrolled.story.js +31 -0
- package/lib/esm/next/tree-view/stories/tree-view-uncontrolled.story.js.map +1 -0
- package/lib/types/icons/generated/custom/Appearance.d.ts +29 -0
- package/lib/types/icons/generated/custom/Appearance.d.ts.map +1 -0
- package/lib/types/icons/generated/custom/index.d.ts +1 -0
- package/lib/types/icons/generated/custom/index.d.ts.map +1 -1
- package/lib/types/next/index.d.ts +1 -0
- package/lib/types/next/index.d.ts.map +1 -1
- package/lib/types/next/tree-view/TreeView.d.ts +79 -0
- package/lib/types/next/tree-view/TreeView.d.ts.map +1 -0
- package/lib/types/next/tree-view/index.d.ts +22 -0
- package/lib/types/next/tree-view/index.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/index.d.ts +37 -0
- package/lib/types/next/tree-view/stories/index.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-actions.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-actions.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-lazy.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-lazy.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-multi.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-multi.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-non-selectable-folders.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-non-selectable-folders.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-single.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-single.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-tooltip.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-tooltip.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-trailing.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-trailing.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-uncontrolled.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-uncontrolled.story.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeView.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,EAAC,eAAe,CAAC,CAAC;IAC9C,OAAO,CACL,8CACE,GAAG,EAAE,GAAG,iBACI,MAAM,EAClB,SAAS,EAAE,IAAA,oBAAU,EAAC,4BAA4B,EAAE,SAAS,CAAC,EAC9D,KAAK,EAAE,gBAAE,cAAc,EAAE,KAAK,GAAG,CAAC,IAAK,KAAK,CAAyB,IACjE,cAAc,EACd,SAAS,cAEZ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACtC,uBAAC,mBAAQ,IAAS,MAAM,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,IAA7B,CAAC,CAA+B,CAChD,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACpD,4BAAQ","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { type CommonProps, type TooltipObjectProps } from '../../_common/types';\nimport { useSemicontrolledState } from '../../_common/use-semi-controlled-state';\nimport { Checkbox } from '../../checkbox';\nimport { CleanIconButton } from '../../clean-icon-button';\nimport { ConditionalWrap } from '../../conditional-wrap';\nimport {\n ChevronRightIconOutline,\n EllipsisHorizontalIconOutline,\n} from '../../icons';\nimport { Menu } from '../../menu';\nimport { Skeleton } from '../../skeleton';\nimport { Tooltip } from '../../tooltip';\n\ntype SelectionMode = 'single' | 'multiple';\n\ntype TreeViewContextValue = {\n focusedId: string | null;\n level: number;\n selectionMode: SelectionMode;\n setFocusedId: (id: string | null) => void;\n};\n\nconst noop = () => undefined;\n\nconst TREE_EVENTS = {\n action: 'treeitem-action',\n collapse: 'treeitem-collapse',\n expand: 'treeitem-expand',\n select: 'treeitem-select',\n} as const;\n\nconst TreeViewContext = createContext<TreeViewContextValue>({\n focusedId: null,\n level: 1,\n selectionMode: 'single',\n setFocusedId: noop,\n});\n\nfunction getVisibleTreeItems(root: HTMLElement): HTMLElement[] {\n return Array.from(\n root.querySelectorAll<HTMLElement>(\n '[role=\"treeitem\"]:not([role=\"group\"][hidden] [role=\"treeitem\"])',\n ),\n ).filter((el) => {\n let parent = el.parentElement;\n while (parent && parent !== root) {\n if (parent.getAttribute('role') === 'group' && parent.hidden) {\n return false;\n }\n parent = parent.parentElement;\n }\n return true;\n });\n}\n\nfunction annotateTreeItems(children: React.ReactNode): React.ReactNode {\n const items = Children.toArray(children);\n const treeItemCount = items.filter(\n (child): child is React.ReactElement =>\n isValidElement(child) && child.type === Item,\n ).length;\n\n let posInSet = 0;\n return Children.map(children, (child) => {\n if (isValidElement(child) && child.type === Item) {\n posInSet++;\n return cloneElement(\n child as React.ReactElement<React.HTMLAttributes<HTMLElement>>,\n {\n 'aria-posinset': posInSet,\n 'aria-setsize': treeItemCount,\n },\n );\n }\n return child;\n });\n}\n\ntype RootProps = {\n /** The aria-label for the tree. Required for accessibility, unless using ariaLabelledby. Pass null to omit. */\n ariaLabel: string | null;\n /** The aria-labelledby for the tree. Pass a string of space-separated IDs of elements that label the tree. */\n ariaLabelledby?: string;\n /** The children of the tree. Should be TreeView.Item components or TreeView.SkeletonItem components only. */\n children?: React.ReactNode;\n /** Selection mode for the tree. Defaults to \"single\". */\n selectionMode?: SelectionMode;\n};\n\n/**\n * Root container for a tree view. Renders a `role=\"tree\"` element with full\n * keyboard navigation (arrow keys, Home/End, Enter/Space) following the\n * WAI-ARIA TreeView pattern.\n *\n * Direct children should be `TreeView.Item` or `TreeView.SkeletonItem`.\n *\n * @example\n * ```tsx\n * <TreeView ariaLabel=\"Files\">\n * <TreeView.Item title=\"README.md\" onSelectedChange={setSelected} isSelected={selected} />\n * </TreeView>\n * ```\n *\n * @alpha - this component is still in development and may change in the future. It might not have feature parity with the old tree view yet.\n */\nconst Root = ({\n children,\n selectionMode = 'single',\n ariaLabel,\n ariaLabelledby,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', RootProps>) => {\n const treeRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([treeRef, ref]);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n const items = getVisibleTreeItems(root);\n if (items.length === 0) {\n return;\n }\n\n const currentIndex = items.findIndex((el) => el.id === focusedId);\n let isHandled = true;\n\n switch (e.key) {\n case 'ArrowDown': {\n const nextIndex =\n currentIndex < items.length - 1 ? currentIndex + 1 : currentIndex;\n const nextItem = items[nextIndex];\n if (nextItem) {\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n break;\n }\n case 'ArrowUp': {\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n const prevItem = items[prevIndex];\n if (prevItem) {\n setFocusedId(prevItem.id);\n prevItem.focus();\n }\n break;\n }\n case 'ArrowRight': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'false') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.expand));\n } else if (isExpanded === 'true') {\n const nextIndex = currentIndex + 1;\n if (nextIndex < items.length) {\n const nextItem = items[nextIndex];\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n }\n break;\n }\n case 'ArrowLeft': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'true') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.collapse));\n } else {\n const parentGroup = current.closest('[role=\"group\"]');\n if (parentGroup?.id) {\n const parentItem = root.querySelector<HTMLElement>(\n `[aria-owns=\"${parentGroup.id}\"]`,\n );\n if (parentItem) {\n setFocusedId(parentItem.id);\n parentItem.focus();\n }\n }\n }\n break;\n }\n case 'Home': {\n const first = items[0];\n if (first) {\n setFocusedId(first.id);\n first.focus();\n }\n break;\n }\n case 'End': {\n const last = items[items.length - 1];\n if (last) {\n setFocusedId(last.id);\n last.focus();\n }\n break;\n }\n case 'Enter':\n case ' ': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.select));\n }\n break;\n }\n case 'F10': {\n if (e.shiftKey) {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.action));\n }\n } else {\n isHandled = false;\n }\n break;\n }\n default:\n isHandled = false;\n }\n\n if (isHandled) {\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [focusedId],\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n if (e.target === root) {\n const items = getVisibleTreeItems(root);\n const alreadyFocused = focusedId\n ? items.find((el) => el.id === focusedId)\n : null;\n const target = alreadyFocused ?? items[0];\n if (target) {\n setFocusedId(target.id);\n target.focus();\n }\n }\n },\n [focusedId],\n );\n\n const classes = classNames(className, 'ndl-tree-view-new');\n\n return (\n <TreeViewContext.Provider\n value={{ focusedId, level: 1, selectionMode, setFocusedId }}\n >\n <div\n ref={mergedRef}\n role=\"tree\"\n aria-multiselectable={selectionMode === 'multiple' || undefined}\n tabIndex={0}\n className={classes}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n aria-label={ariaLabel ?? undefined}\n aria-labelledby={ariaLabelledby}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n );\n};\n\ntype ItemProps = {\n /** Nested TreeView.Item or TreeView.SkeletonItem elements rendered as sub-items in a collapsible group. */\n children?: React.ReactNode;\n /** The label content displayed in the item row. */\n title?: React.ReactNode;\n /** Default expansion for uncontrolled items */\n defaultExpanded?: boolean;\n /** Whether the item has children. Decides if the item should render a chevron for expansion. Needed for lazy loading. */\n hasChildren?: boolean;\n /** Whether the item is disabled */\n isDisabled?: boolean;\n /** Whether the item is expanded. Makes the item controlled. */\n isExpanded?: boolean;\n /** Whether the item is in an indeterminate state. Only meaningful in multi-select mode for parent nodes. */\n isIndeterminate?: boolean;\n /** Whether the item is loading. Applies aria-busy=\"true\" to the item. */\n isLoading?: boolean;\n /** Whether the item is selected */\n isSelected?: boolean;\n /** Leading visual for the item. */\n leadingVisual?: React.ReactNode;\n /** Trailing content for the item. Shown after the children but before the action menu. */\n trailingContent?: React.ReactNode;\n /** ReactNode containing Menu.Item elements to render in an action menu. When provided, an action button is rendered. */\n actionMenuItems?: React.ReactNode;\n /** Props forwarded to the Menu sub-components (anchorRef, onClose). */\n actionMenuProps?: React.ComponentProps<typeof Menu>;\n /** Content rendered inside the tooltip. When provided, the item is wrapped in a Tooltip. */\n tooltipContent?: React.ReactNode;\n /** Props forwarded to the Tooltip sub-components (root, trigger, content). */\n tooltipProps?: TooltipObjectProps;\n /** Callback called when the item is expanded/collapsed. */\n onExpandedChange?: (isExpanded: boolean) => void;\n /** Callback called when the item is selected/deselected. */\n onSelectedChange?: (isSelected: boolean) => void;\n};\n\n/**\n * A single item within a `TreeView`. Renders a `role=\"treeitem\"` element that\n * supports selection, expansion, leading/trailing visuals, and an action menu.\n *\n * The `title` prop provides the item's label content. Nesting `TreeView.Item`\n * elements as `children` creates a hierarchical tree structure.\n *\n * Supports both controlled (`isExpanded`) and uncontrolled (`defaultExpanded`)\n * expansion, as well as lazy loading via `hasChildren` + `isLoading`.\n *\n * @example\n * ```tsx\n * <TreeView.Item\n * title=\"src\"\n * leadingVisual={<FolderIcon />}\n * isSelected={selected}\n * onSelectedChange={setSelected}\n * >\n * <TreeView.Item title=\"index.ts\" />\n * </TreeView.Item>\n * ```\n */\nconst Item = ({\n actionMenuItems,\n children,\n defaultExpanded = false,\n hasChildren: hasChildrenProp,\n isDisabled,\n isExpanded: isExpandedProp,\n isIndeterminate,\n isLoading,\n isSelected,\n leadingVisual,\n title,\n tooltipContent,\n tooltipProps,\n trailingContent,\n onExpandedChange,\n onSelectedChange,\n actionMenuProps,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ItemProps>) => {\n const generatedId = useId();\n const itemId = `ndl-treeitem-${generatedId}`;\n const titleId = `ndl-treeitem-title-${generatedId}`;\n const groupId = `ndl-treegroup-${generatedId}`;\n const itemRef = useRef<HTMLDivElement>(null);\n const actionButtonRef = useRef<HTMLButtonElement>(null);\n const didOpenViaKeyboard = useRef(false);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n const { focusedId, level, selectionMode, setFocusedId } =\n useContext(TreeViewContext);\n\n const isControlledExpansion = isExpandedProp !== undefined;\n const [isExpanded, setIsExpanded] = useSemicontrolledState({\n isControlled: isControlledExpansion,\n onChange: onExpandedChange,\n state: isExpandedProp ?? defaultExpanded,\n });\n\n const hasChildren = hasChildrenProp ?? Children.count(children) > 0;\n const isSelectable = onSelectedChange !== undefined;\n const isMultiple = selectionMode === 'multiple';\n\n const toggleExpanded = useCallback(() => {\n if (isDisabled) {\n return;\n }\n if (hasChildren) {\n setIsExpanded(!isExpanded);\n }\n }, [isDisabled, hasChildren, setIsExpanded, isExpanded]);\n\n const handleSelect = useCallback(() => {\n if (isDisabled) {\n return;\n }\n onSelectedChange?.(!isSelected);\n }, [isDisabled, isSelected, onSelectedChange]);\n\n const handleClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n }, [\n isDisabled,\n setFocusedId,\n itemId,\n isSelectable,\n handleSelect,\n toggleExpanded,\n ]);\n\n const handleChevronClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n toggleExpanded();\n },\n [isDisabled, setFocusedId, itemId, toggleExpanded],\n );\n\n const handleMenuClose = useCallback(() => {\n setIsMenuOpen(false);\n if (didOpenViaKeyboard.current) {\n itemRef.current?.focus();\n didOpenViaKeyboard.current = false;\n }\n }, []);\n\n const handleCustomEvents = useCallback(\n (e: Event) => {\n if (e.type === TREE_EVENTS.expand) {\n e.stopPropagation();\n if (hasChildren && !isExpanded && !isDisabled) {\n setIsExpanded(true);\n }\n } else if (e.type === TREE_EVENTS.collapse) {\n e.stopPropagation();\n if (hasChildren && isExpanded && !isDisabled) {\n setIsExpanded(false);\n }\n } else if (e.type === TREE_EVENTS.select) {\n e.stopPropagation();\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n } else if (e.type === TREE_EVENTS.action) {\n e.stopPropagation();\n if (actionMenuItems && !isDisabled) {\n didOpenViaKeyboard.current = true;\n setIsMenuOpen(true);\n }\n }\n },\n [\n actionMenuItems,\n hasChildren,\n isExpanded,\n isDisabled,\n isSelectable,\n setIsExpanded,\n handleSelect,\n toggleExpanded,\n ],\n );\n\n const callbackRef = useCallback(\n (node: HTMLDivElement | null) => {\n const prev = itemRef.current;\n if (prev) {\n prev.removeEventListener(TREE_EVENTS.expand, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.select, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n (itemRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n if (node) {\n node.addEventListener(TREE_EVENTS.expand, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.select, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n },\n [handleCustomEvents],\n );\n\n const mergedRef = useMergeRefs([callbackRef, ref]);\n\n const isFocused = focusedId === itemId;\n\n const selectionAriaProps = (() => {\n if (!isSelectable) {\n return {};\n }\n if (isMultiple) {\n return {\n 'aria-checked': isIndeterminate\n ? ('mixed' as const)\n : (isSelected ?? false),\n };\n }\n return { 'aria-selected': isSelected ?? false };\n })();\n\n const itemElement = (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard handled on tree root; aria-selected/aria-checked applied via spread\n <div\n ref={mergedRef}\n id={itemId}\n // eslint-disable-next-line jsx-a11y/role-has-required-aria-props -- aria-selected/aria-checked applied conditionally via spread\n role=\"treeitem\"\n {...selectionAriaProps}\n aria-expanded={hasChildren ? isExpanded : undefined}\n aria-owns={hasChildren ? groupId : undefined}\n aria-disabled={isDisabled || undefined}\n aria-busy={isLoading || undefined}\n aria-keyshortcuts={actionMenuItems ? 'Shift+F10' : undefined}\n aria-labelledby={titleId}\n aria-level={level}\n tabIndex={isFocused ? 0 : -1}\n className={classNames('ndl-tree-view-new-item', className, {\n 'ndl-tree-view-new-item--disabled': isDisabled,\n 'ndl-tree-view-new-item--parent': hasChildren,\n 'ndl-tree-view-new-item--selected': isSelected && isSelectable,\n })}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n onClick={(e) => {\n e.stopPropagation();\n handleClick();\n }}\n {...htmlAttributes}\n {...restProps}\n >\n <div\n className={classNames('ndl-tree-view-new-item-content', {\n 'ndl-tree-view-new-item-content--parent': hasChildren,\n })}\n >\n {hasChildren && (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard handled on tree root\n <span\n className=\"ndl-tree-view-new-chevron\"\n aria-disabled={isDisabled}\n onClick={handleChevronClick}\n >\n <ChevronRightIconOutline\n className={classNames('ndl-tree-view-new-chevron-icon', {\n 'ndl-tree-view-new-chevron-icon--open': isExpanded,\n })}\n />\n </span>\n )}\n {leadingVisual && (\n <div className=\"ndl-tree-view-new-item-content-leading-visual\">\n {leadingVisual}\n </div>\n )}\n {isMultiple && isSelectable && (\n <div className=\"ndl-tree-view-new-checkbox\" inert>\n <Checkbox\n style={{ borderWidth: '1.5px' }}\n ariaLabel=\"Select\"\n isChecked={isSelected}\n isIndeterminate={isIndeterminate}\n isDisabled={isDisabled}\n onChange={noop}\n />\n </div>\n )}\n <div id={titleId} className=\"ndl-tree-view-new-item-content-title\">\n {title}\n </div>\n {trailingContent && (\n <div className=\"ndl-tree-view-new-item-content-trailing-content\">\n {trailingContent}\n </div>\n )}\n {actionMenuItems && (\n <div\n className={classNames('ndl-tree-view-new-action', {\n 'ndl-tree-view-new-action--visible': isMenuOpen,\n })}\n >\n <CleanIconButton\n ref={actionButtonRef}\n size=\"small\"\n description={null}\n isDisabled={isDisabled}\n style={{ height: '24px', width: '24px' }}\n htmlAttributes={{\n 'aria-expanded': isMenuOpen || undefined,\n 'aria-haspopup': 'menu',\n 'aria-label': 'Actions',\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n didOpenViaKeyboard.current = false;\n setIsMenuOpen((prev) => !prev);\n },\n tabIndex: -1,\n }}\n >\n <EllipsisHorizontalIconOutline />\n </CleanIconButton>\n <Menu\n isOpen={isMenuOpen}\n anchorRef={actionButtonRef}\n onClose={handleMenuClose}\n {...actionMenuProps}\n >\n {actionMenuItems}\n </Menu>\n </div>\n )}\n </div>\n </div>\n );\n\n return (\n <>\n <ConditionalWrap\n shouldWrap={tooltipContent !== undefined && tooltipContent !== null}\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n hoverDelay={{ close: 0, open: 500 }}\n isDisabled={isMenuOpen}\n followCursor={true}\n {...tooltipProps?.root}\n >\n <Tooltip.Trigger hasButtonWrapper {...tooltipProps?.trigger}>\n {children}\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {tooltipContent}\n </Tooltip.Content>\n </Tooltip>\n )}\n >\n {itemElement}\n </ConditionalWrap>\n {hasChildren && (\n <TreeViewContext.Provider\n value={{ focusedId, level: level + 1, selectionMode, setFocusedId }}\n >\n <div\n role=\"group\"\n id={groupId}\n hidden={!isExpanded}\n style={{ '--tree-level': level - 1 } as React.CSSProperties}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n )}\n </>\n );\n};\n\ntype SkeletonItemProps = {\n /** The number of rows to render. */\n rows?: number;\n};\n\n/**\n * A skeleton placeholder for tree items that are being loaded. Renders one or\n * more `Skeleton` rows at the current nesting depth. The element is\n * `aria-hidden` since it is purely a visual indicator and not interactive.\n *\n * Typically used inside a `TreeView.Item` that has `isLoading` set, to give\n * the user a visual hint that child items are being fetched.\n *\n * @example\n * ```tsx\n * <TreeView.Item title=\"Lazy folder\" hasChildren isLoading={isLoading} isExpanded>\n * {isLoading && <TreeView.SkeletonItem rows={3} />}\n * </TreeView.Item>\n * ```\n */\nconst SkeletonItem = ({\n rows = 1,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', SkeletonItemProps>) => {\n const { level } = useContext(TreeViewContext);\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={classNames('ndl-tree-view-new-skeleton', className)}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n {...htmlAttributes}\n {...restProps}\n >\n {Array.from({ length: rows }, (_, i) => (\n <Skeleton key={i} height=\"18px\" width=\"100%\" />\n ))}\n </div>\n );\n};\n\nconst TreeView = Object.assign(Root, { Item, SkeletonItem });\nexport { TreeView };\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.TreeView = void 0;
|
|
24
|
+
var TreeView_1 = require("./TreeView");
|
|
25
|
+
Object.defineProperty(exports, "TreeView", { enumerable: true, get: function () { return TreeView_1.TreeView; } });
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/next/tree-view/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { TreeView } from './TreeView';\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.TreeViewUncontrolledExpansionSrc = exports.TreeViewTooltipSrc = exports.TreeViewTrailingContentSrc = exports.TreeViewSingleSelectSrc = exports.TreeViewNonSelectableFoldersSrc = exports.TreeViewMultiSelectSrc = exports.TreeViewLazyLoadingSrc = exports.TreeViewActionsSrc = exports.TreeViewWithTooltip = exports.TreeViewWithTrailingContent = exports.TreeViewUncontrolledExpansion = exports.TreeViewWithActions = exports.TreeViewSingleSelect = exports.TreeViewNonSelectableFolders = exports.TreeViewMultiSelect = exports.TreeViewLazyLoading = void 0;
|
|
27
|
+
var tree_view_lazy_story_1 = require("./tree-view-lazy.story");
|
|
28
|
+
Object.defineProperty(exports, "TreeViewLazyLoading", { enumerable: true, get: function () { return __importDefault(tree_view_lazy_story_1).default; } });
|
|
29
|
+
var tree_view_multi_story_1 = require("./tree-view-multi.story");
|
|
30
|
+
Object.defineProperty(exports, "TreeViewMultiSelect", { enumerable: true, get: function () { return __importDefault(tree_view_multi_story_1).default; } });
|
|
31
|
+
var tree_view_non_selectable_folders_story_1 = require("./tree-view-non-selectable-folders.story");
|
|
32
|
+
Object.defineProperty(exports, "TreeViewNonSelectableFolders", { enumerable: true, get: function () { return __importDefault(tree_view_non_selectable_folders_story_1).default; } });
|
|
33
|
+
var tree_view_single_story_1 = require("./tree-view-single.story");
|
|
34
|
+
Object.defineProperty(exports, "TreeViewSingleSelect", { enumerable: true, get: function () { return __importDefault(tree_view_single_story_1).default; } });
|
|
35
|
+
var tree_view_actions_story_1 = require("./tree-view-actions.story");
|
|
36
|
+
Object.defineProperty(exports, "TreeViewWithActions", { enumerable: true, get: function () { return __importDefault(tree_view_actions_story_1).default; } });
|
|
37
|
+
var tree_view_uncontrolled_story_1 = require("./tree-view-uncontrolled.story");
|
|
38
|
+
Object.defineProperty(exports, "TreeViewUncontrolledExpansion", { enumerable: true, get: function () { return __importDefault(tree_view_uncontrolled_story_1).default; } });
|
|
39
|
+
var tree_view_trailing_story_1 = require("./tree-view-trailing.story");
|
|
40
|
+
Object.defineProperty(exports, "TreeViewWithTrailingContent", { enumerable: true, get: function () { return __importDefault(tree_view_trailing_story_1).default; } });
|
|
41
|
+
var tree_view_tooltip_story_1 = require("./tree-view-tooltip.story");
|
|
42
|
+
Object.defineProperty(exports, "TreeViewWithTooltip", { enumerable: true, get: function () { return __importDefault(tree_view_tooltip_story_1).default; } });
|
|
43
|
+
const export_stories_utils_1 = require("../../../_common/export-stories-utils");
|
|
44
|
+
const tree_view_actions_story_raw_1 = __importDefault(require("./tree-view-actions.story?raw"));
|
|
45
|
+
const tree_view_lazy_story_raw_1 = __importDefault(require("./tree-view-lazy.story?raw"));
|
|
46
|
+
const tree_view_multi_story_raw_1 = __importDefault(require("./tree-view-multi.story?raw"));
|
|
47
|
+
const tree_view_non_selectable_folders_story_raw_1 = __importDefault(require("./tree-view-non-selectable-folders.story?raw"));
|
|
48
|
+
const tree_view_single_story_raw_1 = __importDefault(require("./tree-view-single.story?raw"));
|
|
49
|
+
const tree_view_tooltip_story_raw_1 = __importDefault(require("./tree-view-tooltip.story?raw"));
|
|
50
|
+
const tree_view_trailing_story_raw_1 = __importDefault(require("./tree-view-trailing.story?raw"));
|
|
51
|
+
const tree_view_uncontrolled_story_raw_1 = __importDefault(require("./tree-view-uncontrolled.story?raw"));
|
|
52
|
+
exports.TreeViewActionsSrc = (0, export_stories_utils_1.removeLicenseHeader)(tree_view_actions_story_raw_1.default);
|
|
53
|
+
exports.TreeViewLazyLoadingSrc = (0, export_stories_utils_1.removeLicenseHeader)(tree_view_lazy_story_raw_1.default);
|
|
54
|
+
exports.TreeViewMultiSelectSrc = (0, export_stories_utils_1.removeLicenseHeader)(tree_view_multi_story_raw_1.default);
|
|
55
|
+
exports.TreeViewNonSelectableFoldersSrc = (0, export_stories_utils_1.removeLicenseHeader)(tree_view_non_selectable_folders_story_raw_1.default);
|
|
56
|
+
exports.TreeViewSingleSelectSrc = (0, export_stories_utils_1.removeLicenseHeader)(tree_view_single_story_raw_1.default);
|
|
57
|
+
exports.TreeViewTrailingContentSrc = (0, export_stories_utils_1.removeLicenseHeader)(tree_view_trailing_story_raw_1.default);
|
|
58
|
+
exports.TreeViewTooltipSrc = (0, export_stories_utils_1.removeLicenseHeader)(tree_view_tooltip_story_raw_1.default);
|
|
59
|
+
exports.TreeViewUncontrolledExpansionSrc = (0, export_stories_utils_1.removeLicenseHeader)(tree_view_uncontrolled_story_raw_1.default);
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/next/tree-view/stories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,+DAAwE;AAA/D,4IAAA,OAAO,OAAuB;AACvC,iEAAyE;AAAhE,6IAAA,OAAO,OAAuB;AACvC,mGAAmG;AAA1F,uKAAA,OAAO,OAAgC;AAChD,mEAA2E;AAAlE,+IAAA,OAAO,OAAwB;AACxC,qEAA2E;AAAlE,+IAAA,OAAO,OAAuB;AACvC,+EAA0F;AAAjF,8JAAA,OAAO,OAAiC;AACjD,uEAAoF;AAA3E,wJAAA,OAAO,OAA+B;AAC/C,qEAA2E;AAAlE,+IAAA,OAAO,OAAuB;AAEvC,gFAA4E;AAC5E,gGAAkE;AAClE,0FAAmE;AACnE,4FAAoE;AACpE,8HAA8F;AAC9F,8FAAsE;AACtE,gGAAkE;AAClE,kGAA2E;AAC3E,0GAAqF;AAExE,QAAA,kBAAkB,GAAG,IAAA,0CAAmB,EAAC,qCAAqB,CAAC,CAAC;AAChE,QAAA,sBAAsB,GAAG,IAAA,0CAAmB,EACvD,kCAAyB,CAC1B,CAAC;AACW,QAAA,sBAAsB,GAAG,IAAA,0CAAmB,EACvD,mCAAyB,CAC1B,CAAC;AACW,QAAA,+BAA+B,GAAG,IAAA,0CAAmB,EAChE,oDAAkC,CACnC,CAAC;AACW,QAAA,uBAAuB,GAAG,IAAA,0CAAmB,EACxD,oCAA0B,CAC3B,CAAC;AACW,QAAA,0BAA0B,GAAG,IAAA,0CAAmB,EAC3D,sCAA6B,CAC9B,CAAC;AACW,QAAA,kBAAkB,GAAG,IAAA,0CAAmB,EAAC,qCAAqB,CAAC,CAAC;AAChE,QAAA,gCAAgC,GAAG,IAAA,0CAAmB,EACjE,0CAAmC,CACpC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as TreeViewLazyLoading } from './tree-view-lazy.story';\nexport { default as TreeViewMultiSelect } from './tree-view-multi.story';\nexport { default as TreeViewNonSelectableFolders } from './tree-view-non-selectable-folders.story';\nexport { default as TreeViewSingleSelect } from './tree-view-single.story';\nexport { default as TreeViewWithActions } from './tree-view-actions.story';\nexport { default as TreeViewUncontrolledExpansion } from './tree-view-uncontrolled.story';\nexport { default as TreeViewWithTrailingContent } from './tree-view-trailing.story';\nexport { default as TreeViewWithTooltip } from './tree-view-tooltip.story';\n\nimport { removeLicenseHeader } from '../../../_common/export-stories-utils';\nimport TreeViewActionsSrcRaw from './tree-view-actions.story?raw';\nimport TreeViewLazyLoadingSrcRaw from './tree-view-lazy.story?raw';\nimport TreeViewMultiSelectSrcRaw from './tree-view-multi.story?raw';\nimport TreeViewNonSelectableFoldersSrcRaw from './tree-view-non-selectable-folders.story?raw';\nimport TreeViewSingleSelectSrcRaw from './tree-view-single.story?raw';\nimport TreeViewTooltipSrcRaw from './tree-view-tooltip.story?raw';\nimport TreeViewTrailingContentSrcRaw from './tree-view-trailing.story?raw';\nimport TreeViewUncontrolledExpansionSrcRaw from './tree-view-uncontrolled.story?raw';\n\nexport const TreeViewActionsSrc = removeLicenseHeader(TreeViewActionsSrcRaw);\nexport const TreeViewLazyLoadingSrc = removeLicenseHeader(\n TreeViewLazyLoadingSrcRaw,\n);\nexport const TreeViewMultiSelectSrc = removeLicenseHeader(\n TreeViewMultiSelectSrcRaw,\n);\nexport const TreeViewNonSelectableFoldersSrc = removeLicenseHeader(\n TreeViewNonSelectableFoldersSrcRaw,\n);\nexport const TreeViewSingleSelectSrc = removeLicenseHeader(\n TreeViewSingleSelectSrcRaw,\n);\nexport const TreeViewTrailingContentSrc = removeLicenseHeader(\n TreeViewTrailingContentSrcRaw,\n);\nexport const TreeViewTooltipSrc = removeLicenseHeader(TreeViewTooltipSrcRaw);\nexport const TreeViewUncontrolledExpansionSrc = removeLicenseHeader(\n TreeViewUncontrolledExpansionSrcRaw,\n);\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const icons_1 = require("@neo4j-ndl/react/icons");
|
|
27
|
+
const next_1 = require("@neo4j-ndl/react/next");
|
|
28
|
+
const react_2 = require("react");
|
|
29
|
+
const Component = () => {
|
|
30
|
+
const [expanded, setExpanded] = (0, react_2.useState)({});
|
|
31
|
+
const [selected, setSelected] = (0, react_2.useState)(null);
|
|
32
|
+
const toggle = (key) => setExpanded((prev) => (Object.assign(Object.assign({}, prev), { [key]: !prev[key] })));
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)(next_1.TreeView, { ariaLabel: "Project files", children: [(0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: "src", hasChildren: true, isExpanded: expanded['src'], onExpandedChange: () => toggle('src'), isSelected: selected === 'src', onSelectedChange: () => setSelected('src'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {}), actionMenuItems: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "New File", onClick: () => alert('New file in src') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Rename", onClick: () => alert('Rename src') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Delete", onClick: () => alert('Delete src') })] }), children: [(0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "index.ts", isSelected: selected === 'index', onSelectedChange: () => setSelected('index'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}), actionMenuItems: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Open", onClick: () => alert('Open index.ts') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Rename", onClick: () => alert('Rename index.ts') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Delete", onClick: () => alert('Delete index.ts') })] }) }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "utils.ts", isSelected: selected === 'utils', onSelectedChange: () => setSelected('utils'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}), actionMenuItems: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Open", onClick: () => alert('Open utils.ts') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Rename", onClick: () => alert('Rename utils.ts') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Delete", onClick: () => alert('Delete utils.ts') })] }) })] }), (0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: "tests", hasChildren: true, isExpanded: expanded['tests'], onExpandedChange: () => toggle('tests'), isSelected: selected === 'tests', onSelectedChange: () => setSelected('tests'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {}), actionMenuItems: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Run Tests", onClick: () => alert('Run all tests') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "New Test", onClick: () => alert('New test in tests') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Delete", onClick: () => alert('Delete tests') })] }), children: [(0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "index.test.ts", isSelected: selected === 'index-test', onSelectedChange: () => setSelected('index-test'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}), actionMenuItems: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Run", onClick: () => alert('Run index.test.ts') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Rename", onClick: () => alert('Rename index.test.ts') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Delete", onClick: () => alert('Delete index.test.ts') })] }) }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "utils.test.ts", isSelected: selected === 'utils-test', onSelectedChange: () => setSelected('utils-test'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}), actionMenuItems: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Run", onClick: () => alert('Run utils.test.ts') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Rename", onClick: () => alert('Rename utils.test.ts') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Delete", onClick: () => alert('Delete utils.test.ts') })] }) })] }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "README.md", isSelected: selected === 'readme', onSelectedChange: () => setSelected('readme'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}), actionMenuItems: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Open", onClick: () => alert('Open README.md') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Rename", onClick: () => alert('Rename README.md') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Delete", onClick: () => alert('Delete README.md') })] }) })] }));
|
|
34
|
+
};
|
|
35
|
+
exports.default = Component;
|
|
36
|
+
//# sourceMappingURL=tree-view-actions.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view-actions.story.js","sourceRoot":"","sources":["../../../../../src/next/tree-view/stories/tree-view-actions.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAwC;AACxC,kDAA8E;AAC9E,gDAAiD;AACjD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAA0B,EAAE,CAAC,CAAC;IACtE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAgB,IAAI,CAAC,CAAC;IAE9D,MAAM,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GAAG,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,GACzC,EACF,uBAAC,YAAI,CAAC,IAAI,IACR,KAAK,EAAC,QAAQ,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,sBAAsB,CAAC,GAC5C,EACF,uBAAC,YAAI,CAAC,IAAI,IACR,KAAK,EAAC,QAAQ,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,sBAAsB,CAAC,GAC5C,IACD,GAEL,IACY,EAChB,uBAAC,eAAQ,CAAC,IAAI,IACZ,KAAK,EAAC,WAAW,EACjB,UAAU,EAAE,QAAQ,KAAK,QAAQ,EACjC,gBAAgB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAC7C,aAAa,EAAE,uBAAC,2BAAmB,KAAG,EACtC,eAAe,EACb,6DACE,uBAAC,YAAI,CAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAI,EAClE,uBAAC,YAAI,CAAC,IAAI,IACR,KAAK,EAAC,QAAQ,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,GACxC,EACF,uBAAC,YAAI,CAAC,IAAI,IACR,KAAK,EAAC,QAAQ,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,GACxC,IACD,GAEL,IACO,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Menu } from '@neo4j-ndl/react';\nimport { DocumentIconOutline, FolderIconSolid } from '@neo4j-ndl/react/icons';\nimport { TreeView } from '@neo4j-ndl/react/next';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [expanded, setExpanded] = useState<Record<string, boolean>>({});\n const [selected, setSelected] = useState<string | null>(null);\n\n const toggle = (key: string) =>\n setExpanded((prev) => ({ ...prev, [key]: !prev[key] }));\n\n return (\n <TreeView ariaLabel=\"Project files\">\n <TreeView.Item\n title=\"src\"\n hasChildren\n isExpanded={expanded['src']}\n onExpandedChange={() => toggle('src')}\n isSelected={selected === 'src'}\n onSelectedChange={() => setSelected('src')}\n leadingVisual={<FolderIconSolid />}\n actionMenuItems={\n <>\n <Menu.Item\n title=\"New File\"\n onClick={() => alert('New file in src')}\n />\n <Menu.Item title=\"Rename\" onClick={() => alert('Rename src')} />\n <Menu.Item title=\"Delete\" onClick={() => alert('Delete src')} />\n </>\n }\n >\n <TreeView.Item\n title=\"index.ts\"\n isSelected={selected === 'index'}\n onSelectedChange={() => setSelected('index')}\n leadingVisual={<DocumentIconOutline />}\n actionMenuItems={\n <>\n <Menu.Item title=\"Open\" onClick={() => alert('Open index.ts')} />\n <Menu.Item\n title=\"Rename\"\n onClick={() => alert('Rename index.ts')}\n />\n <Menu.Item\n title=\"Delete\"\n onClick={() => alert('Delete index.ts')}\n />\n </>\n }\n />\n <TreeView.Item\n title=\"utils.ts\"\n isSelected={selected === 'utils'}\n onSelectedChange={() => setSelected('utils')}\n leadingVisual={<DocumentIconOutline />}\n actionMenuItems={\n <>\n <Menu.Item title=\"Open\" onClick={() => alert('Open utils.ts')} />\n <Menu.Item\n title=\"Rename\"\n onClick={() => alert('Rename utils.ts')}\n />\n <Menu.Item\n title=\"Delete\"\n onClick={() => alert('Delete utils.ts')}\n />\n </>\n }\n />\n </TreeView.Item>\n <TreeView.Item\n title=\"tests\"\n hasChildren\n isExpanded={expanded['tests']}\n onExpandedChange={() => toggle('tests')}\n isSelected={selected === 'tests'}\n onSelectedChange={() => setSelected('tests')}\n leadingVisual={<FolderIconSolid />}\n actionMenuItems={\n <>\n <Menu.Item\n title=\"Run Tests\"\n onClick={() => alert('Run all tests')}\n />\n <Menu.Item\n title=\"New Test\"\n onClick={() => alert('New test in tests')}\n />\n <Menu.Item title=\"Delete\" onClick={() => alert('Delete tests')} />\n </>\n }\n >\n <TreeView.Item\n title=\"index.test.ts\"\n isSelected={selected === 'index-test'}\n onSelectedChange={() => setSelected('index-test')}\n leadingVisual={<DocumentIconOutline />}\n actionMenuItems={\n <>\n <Menu.Item\n title=\"Run\"\n onClick={() => alert('Run index.test.ts')}\n />\n <Menu.Item\n title=\"Rename\"\n onClick={() => alert('Rename index.test.ts')}\n />\n <Menu.Item\n title=\"Delete\"\n onClick={() => alert('Delete index.test.ts')}\n />\n </>\n }\n />\n <TreeView.Item\n title=\"utils.test.ts\"\n isSelected={selected === 'utils-test'}\n onSelectedChange={() => setSelected('utils-test')}\n leadingVisual={<DocumentIconOutline />}\n actionMenuItems={\n <>\n <Menu.Item\n title=\"Run\"\n onClick={() => alert('Run utils.test.ts')}\n />\n <Menu.Item\n title=\"Rename\"\n onClick={() => alert('Rename utils.test.ts')}\n />\n <Menu.Item\n title=\"Delete\"\n onClick={() => alert('Delete utils.test.ts')}\n />\n </>\n }\n />\n </TreeView.Item>\n <TreeView.Item\n title=\"README.md\"\n isSelected={selected === 'readme'}\n onSelectedChange={() => setSelected('readme')}\n leadingVisual={<DocumentIconOutline />}\n actionMenuItems={\n <>\n <Menu.Item title=\"Open\" onClick={() => alert('Open README.md')} />\n <Menu.Item\n title=\"Rename\"\n onClick={() => alert('Rename README.md')}\n />\n <Menu.Item\n title=\"Delete\"\n onClick={() => alert('Delete README.md')}\n />\n </>\n }\n />\n </TreeView>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const icons_1 = require("@neo4j-ndl/react/icons");
|
|
26
|
+
const next_1 = require("@neo4j-ndl/react/next");
|
|
27
|
+
const react_1 = require("react");
|
|
28
|
+
const TREE_DATA = [
|
|
29
|
+
{
|
|
30
|
+
children: [
|
|
31
|
+
{
|
|
32
|
+
children: [
|
|
33
|
+
{ id: 'app-tsx', label: 'App.tsx' },
|
|
34
|
+
{ id: 'index-tsx', label: 'index.tsx' },
|
|
35
|
+
{ id: 'styles-css', label: 'styles.css' },
|
|
36
|
+
],
|
|
37
|
+
id: 'frontend',
|
|
38
|
+
label: 'Frontend',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
children: [
|
|
42
|
+
{ id: 'server-ts', label: 'server.ts' },
|
|
43
|
+
{ id: 'routes-ts', label: 'routes.ts' },
|
|
44
|
+
],
|
|
45
|
+
id: 'backend',
|
|
46
|
+
label: 'Backend',
|
|
47
|
+
},
|
|
48
|
+
{ id: 'readme-md', label: 'README.md' },
|
|
49
|
+
],
|
|
50
|
+
id: 'projects',
|
|
51
|
+
label: 'Projects',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
children: [
|
|
57
|
+
{ id: 'beach-jpg', label: 'beach.jpg' },
|
|
58
|
+
{ id: 'sunset-jpg', label: 'sunset.jpg' },
|
|
59
|
+
],
|
|
60
|
+
id: 'vacation',
|
|
61
|
+
label: 'Vacation',
|
|
62
|
+
},
|
|
63
|
+
{ id: 'profile-png', label: 'profile.png' },
|
|
64
|
+
],
|
|
65
|
+
id: 'photos',
|
|
66
|
+
label: 'Photos',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
children: [
|
|
70
|
+
{ id: 'resume-pdf', label: 'resume.pdf' },
|
|
71
|
+
{ id: 'cover-letter-pdf', label: 'cover-letter.pdf' },
|
|
72
|
+
{ id: 'notes-txt', label: 'notes.txt' },
|
|
73
|
+
],
|
|
74
|
+
id: 'documents',
|
|
75
|
+
label: 'Documents',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
children: [
|
|
79
|
+
{
|
|
80
|
+
children: [
|
|
81
|
+
{ id: 'chill-m3u', label: 'chill.m3u' },
|
|
82
|
+
{ id: 'workout-m3u', label: 'workout.m3u' },
|
|
83
|
+
],
|
|
84
|
+
id: 'playlists',
|
|
85
|
+
label: 'Playlists',
|
|
86
|
+
},
|
|
87
|
+
{ id: 'favorites-m3u', label: 'favorites.m3u' },
|
|
88
|
+
],
|
|
89
|
+
id: 'music',
|
|
90
|
+
label: 'Music',
|
|
91
|
+
},
|
|
92
|
+
{ id: 'todo-txt', label: 'TODO.txt' },
|
|
93
|
+
];
|
|
94
|
+
const LOAD_DELAY_MS = 600;
|
|
95
|
+
function iconForNode(node) {
|
|
96
|
+
if (node.children) {
|
|
97
|
+
return (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {});
|
|
98
|
+
}
|
|
99
|
+
if (/\.(jpg|jpeg|png|gif|svg)$/i.test(node.label)) {
|
|
100
|
+
return (0, jsx_runtime_1.jsx)(icons_1.PhotoIconOutline, {});
|
|
101
|
+
}
|
|
102
|
+
return (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {});
|
|
103
|
+
}
|
|
104
|
+
const INITIAL_NODE_STATE = {
|
|
105
|
+
hasLoaded: false,
|
|
106
|
+
isExpanded: false,
|
|
107
|
+
isLoading: false,
|
|
108
|
+
};
|
|
109
|
+
function useTreeState() {
|
|
110
|
+
const [nodeStates, setNodeStates] = (0, react_1.useState)({});
|
|
111
|
+
const [selectedId, setSelectedId] = (0, react_1.useState)(null);
|
|
112
|
+
const timers = (0, react_1.useRef)({});
|
|
113
|
+
const getNodeState = (0, react_1.useCallback)((id) => { var _a; return (_a = nodeStates[id]) !== null && _a !== void 0 ? _a : INITIAL_NODE_STATE; }, [nodeStates]);
|
|
114
|
+
const handleExpand = (0, react_1.useCallback)((id, expanded) => {
|
|
115
|
+
setNodeStates((prev) => {
|
|
116
|
+
var _a;
|
|
117
|
+
const current = (_a = prev[id]) !== null && _a !== void 0 ? _a : INITIAL_NODE_STATE;
|
|
118
|
+
if (expanded && !current.hasLoaded) {
|
|
119
|
+
if (timers.current[id]) {
|
|
120
|
+
clearTimeout(timers.current[id]);
|
|
121
|
+
}
|
|
122
|
+
timers.current[id] = setTimeout(() => {
|
|
123
|
+
setNodeStates((p) => (Object.assign(Object.assign({}, p), { [id]: { hasLoaded: true, isExpanded: true, isLoading: false } })));
|
|
124
|
+
delete timers.current[id];
|
|
125
|
+
}, LOAD_DELAY_MS);
|
|
126
|
+
return Object.assign(Object.assign({}, prev), { [id]: { hasLoaded: false, isExpanded: true, isLoading: true } });
|
|
127
|
+
}
|
|
128
|
+
return Object.assign(Object.assign({}, prev), { [id]: Object.assign(Object.assign({}, current), { isExpanded: expanded }) });
|
|
129
|
+
});
|
|
130
|
+
}, []);
|
|
131
|
+
const handleSelect = (0, react_1.useCallback)((id) => setSelectedId((prev) => (prev === id ? null : id)), []);
|
|
132
|
+
return { getNodeState, handleExpand, handleSelect, selectedId };
|
|
133
|
+
}
|
|
134
|
+
function renderNode(node, ctx) {
|
|
135
|
+
const hasChildren = node.children !== undefined &&
|
|
136
|
+
node.children !== null &&
|
|
137
|
+
node.children.length > 0;
|
|
138
|
+
const state = ctx.getNodeState(node.id);
|
|
139
|
+
return ((0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: node.label, hasChildren: hasChildren, isExpanded: state.isExpanded, isLoading: state.isLoading, isSelected: ctx.selectedId === node.id, leadingVisual: iconForNode(node), onExpandedChange: (expanded) => ctx.handleExpand(node.id, expanded), onSelectedChange: () => ctx.handleSelect(node.id), children: [hasChildren && state.isLoading && !state.hasLoaded && ((0, jsx_runtime_1.jsx)(next_1.TreeView.SkeletonItem, { rows: 2 })), hasChildren &&
|
|
140
|
+
state.hasLoaded &&
|
|
141
|
+
node.children.map((child) => renderNode(child, ctx))] }, node.id));
|
|
142
|
+
}
|
|
143
|
+
const Component = () => {
|
|
144
|
+
const { getNodeState, selectedId, handleExpand, handleSelect } = useTreeState();
|
|
145
|
+
const ctx = (0, react_1.useMemo)(() => ({ getNodeState, handleExpand, handleSelect, selectedId }), [getNodeState, selectedId, handleExpand, handleSelect]);
|
|
146
|
+
return ((0, jsx_runtime_1.jsx)(next_1.TreeView, { ariaLabel: "Lazy-loaded file explorer", children: TREE_DATA.map((node) => renderNode(node, ctx)) }));
|
|
147
|
+
};
|
|
148
|
+
exports.default = Component;
|
|
149
|
+
//# sourceMappingURL=tree-view-lazy.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view-l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AC,eAAQ,CAAC,YAAY,IAAC,IAAI,EAAE,CAAC,GAAI,CACnC,EACA,WAAW;gBACV,KAAK,CAAC,SAAS;gBACf,IAAI,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,KAjBlD,IAAI,CAAC,EAAE,CAkBE,CACjB,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,GAC5D,YAAY,EAAE,CAAC;IAEjB,MAAM,GAAG,GAAG,IAAA,eAAO,EACjB,GAAG,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,EAChE,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,CAAC,CACvD,CAAC;IAEF,OAAO,CACL,uBAAC,eAAQ,IAAC,SAAS,EAAC,2BAA2B,YAC5C,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,GACtC,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport {\n DocumentIconOutline,\n FolderIconSolid,\n PhotoIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport { TreeView } from '@neo4j-ndl/react/next';\nimport { useCallback, useMemo, useRef, useState } from 'react';\n\ntype TreeNode = {\n id: string;\n label: string;\n children?: TreeNode[];\n};\n\nconst TREE_DATA: TreeNode[] = [\n {\n children: [\n {\n children: [\n { id: 'app-tsx', label: 'App.tsx' },\n { id: 'index-tsx', label: 'index.tsx' },\n { id: 'styles-css', label: 'styles.css' },\n ],\n id: 'frontend',\n label: 'Frontend',\n },\n {\n children: [\n { id: 'server-ts', label: 'server.ts' },\n { id: 'routes-ts', label: 'routes.ts' },\n ],\n id: 'backend',\n label: 'Backend',\n },\n { id: 'readme-md', label: 'README.md' },\n ],\n id: 'projects',\n label: 'Projects',\n },\n {\n children: [\n {\n children: [\n { id: 'beach-jpg', label: 'beach.jpg' },\n { id: 'sunset-jpg', label: 'sunset.jpg' },\n ],\n id: 'vacation',\n label: 'Vacation',\n },\n { id: 'profile-png', label: 'profile.png' },\n ],\n id: 'photos',\n label: 'Photos',\n },\n {\n children: [\n { id: 'resume-pdf', label: 'resume.pdf' },\n { id: 'cover-letter-pdf', label: 'cover-letter.pdf' },\n { id: 'notes-txt', label: 'notes.txt' },\n ],\n id: 'documents',\n label: 'Documents',\n },\n {\n children: [\n {\n children: [\n { id: 'chill-m3u', label: 'chill.m3u' },\n { id: 'workout-m3u', label: 'workout.m3u' },\n ],\n id: 'playlists',\n label: 'Playlists',\n },\n { id: 'favorites-m3u', label: 'favorites.m3u' },\n ],\n id: 'music',\n label: 'Music',\n },\n { id: 'todo-txt', label: 'TODO.txt' },\n];\n\nconst LOAD_DELAY_MS = 600;\n\nfunction iconForNode(node: TreeNode) {\n if (node.children) {\n return <FolderIconSolid />;\n }\n if (/\\.(jpg|jpeg|png|gif|svg)$/i.test(node.label)) {\n return <PhotoIconOutline />;\n }\n return <DocumentIconOutline />;\n}\n\ntype NodeState = {\n isExpanded: boolean;\n isLoading: boolean;\n hasLoaded: boolean;\n};\n\nconst INITIAL_NODE_STATE: NodeState = {\n hasLoaded: false,\n isExpanded: false,\n isLoading: false,\n};\n\nfunction useTreeState() {\n const [nodeStates, setNodeStates] = useState<Record<string, NodeState>>({});\n const [selectedId, setSelectedId] = useState<string | null>(null);\n const timers = useRef<Record<string, ReturnType<typeof setTimeout>>>({});\n\n const getNodeState = useCallback(\n (id: string): NodeState => nodeStates[id] ?? INITIAL_NODE_STATE,\n [nodeStates],\n );\n\n const handleExpand = useCallback((id: string, expanded: boolean) => {\n setNodeStates((prev) => {\n const current = prev[id] ?? INITIAL_NODE_STATE;\n if (expanded && !current.hasLoaded) {\n if (timers.current[id]) {\n clearTimeout(timers.current[id]);\n }\n timers.current[id] = setTimeout(() => {\n setNodeStates((p) => ({\n ...p,\n [id]: { hasLoaded: true, isExpanded: true, isLoading: false },\n }));\n delete timers.current[id];\n }, LOAD_DELAY_MS);\n return {\n ...prev,\n [id]: { hasLoaded: false, isExpanded: true, isLoading: true },\n };\n }\n return { ...prev, [id]: { ...current, isExpanded: expanded } };\n });\n }, []);\n\n const handleSelect = useCallback(\n (id: string) => setSelectedId((prev) => (prev === id ? null : id)),\n [],\n );\n\n return { getNodeState, handleExpand, handleSelect, selectedId };\n}\n\ntype RenderContext = {\n getNodeState: (id: string) => NodeState;\n selectedId: string | null;\n handleExpand: (id: string, expanded: boolean) => void;\n handleSelect: (id: string) => void;\n};\n\nfunction renderNode(node: TreeNode, ctx: RenderContext) {\n const hasChildren =\n node.children !== undefined &&\n node.children !== null &&\n node.children.length > 0;\n const state = ctx.getNodeState(node.id);\n\n return (\n <TreeView.Item\n key={node.id}\n title={node.label}\n hasChildren={hasChildren}\n isExpanded={state.isExpanded}\n isLoading={state.isLoading}\n isSelected={ctx.selectedId === node.id}\n leadingVisual={iconForNode(node)}\n onExpandedChange={(expanded: boolean) =>\n ctx.handleExpand(node.id, expanded)\n }\n onSelectedChange={() => ctx.handleSelect(node.id)}\n >\n {hasChildren && state.isLoading && !state.hasLoaded && (\n <TreeView.SkeletonItem rows={2} />\n )}\n {hasChildren &&\n state.hasLoaded &&\n node.children!.map((child) => renderNode(child, ctx))}\n </TreeView.Item>\n );\n}\n\nconst Component = () => {\n const { getNodeState, selectedId, handleExpand, handleSelect } =\n useTreeState();\n\n const ctx = useMemo<RenderContext>(\n () => ({ getNodeState, handleExpand, handleSelect, selectedId }),\n [getNodeState, selectedId, handleExpand, handleSelect],\n );\n\n return (\n <TreeView ariaLabel=\"Lazy-loaded file explorer\">\n {TREE_DATA.map((node) => renderNode(node, ctx))}\n </TreeView>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const icons_1 = require("@neo4j-ndl/react/icons");
|
|
26
|
+
const next_1 = require("@neo4j-ndl/react/next");
|
|
27
|
+
const react_1 = require("react");
|
|
28
|
+
const WORK_CHILDREN = ['report', 'presentation'];
|
|
29
|
+
const DOC_CHILDREN = ['work', 'resume'];
|
|
30
|
+
const IMAGE_CHILDREN = ['photo', 'screenshot'];
|
|
31
|
+
const DISABLED_KEYS = new Set(['presentation']);
|
|
32
|
+
function getParentChecked(checked, childKeys) {
|
|
33
|
+
const enabledKeys = childKeys.filter((k) => !DISABLED_KEYS.has(k));
|
|
34
|
+
if (enabledKeys.length === 0) {
|
|
35
|
+
return { isChecked: false, isIndeterminate: false };
|
|
36
|
+
}
|
|
37
|
+
const checkedCount = enabledKeys.filter((k) => checked[k]).length;
|
|
38
|
+
if (checkedCount === 0) {
|
|
39
|
+
return { isChecked: false, isIndeterminate: false };
|
|
40
|
+
}
|
|
41
|
+
if (checkedCount === enabledKeys.length) {
|
|
42
|
+
return { isChecked: true, isIndeterminate: false };
|
|
43
|
+
}
|
|
44
|
+
return { isChecked: false, isIndeterminate: true };
|
|
45
|
+
}
|
|
46
|
+
const Component = () => {
|
|
47
|
+
const [expanded, setExpanded] = (0, react_1.useState)({});
|
|
48
|
+
const [checked, setChecked] = (0, react_1.useState)({});
|
|
49
|
+
const toggle = (key) => setExpanded((prev) => (Object.assign(Object.assign({}, prev), { [key]: !prev[key] })));
|
|
50
|
+
const toggleCheck = (0, react_1.useCallback)((key) => {
|
|
51
|
+
setChecked((prev) => (Object.assign(Object.assign({}, prev), { [key]: !prev[key] })));
|
|
52
|
+
}, []);
|
|
53
|
+
const toggleParent = (0, react_1.useCallback)((childKeys) => {
|
|
54
|
+
const enabledKeys = childKeys.filter((k) => !DISABLED_KEYS.has(k));
|
|
55
|
+
const isAllChecked = enabledKeys.every((k) => checked[k]);
|
|
56
|
+
setChecked((prev) => {
|
|
57
|
+
const next = Object.assign({}, prev);
|
|
58
|
+
for (const k of enabledKeys) {
|
|
59
|
+
next[k] = !isAllChecked;
|
|
60
|
+
}
|
|
61
|
+
return next;
|
|
62
|
+
});
|
|
63
|
+
}, [checked]);
|
|
64
|
+
const docState = getParentChecked(checked, [
|
|
65
|
+
...DOC_CHILDREN,
|
|
66
|
+
...WORK_CHILDREN,
|
|
67
|
+
]);
|
|
68
|
+
const workState = getParentChecked(checked, WORK_CHILDREN);
|
|
69
|
+
const imageState = getParentChecked(checked, IMAGE_CHILDREN);
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)(next_1.TreeView, { ariaLabel: "File explorer", selectionMode: "multiple", children: [(0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: "Documents", hasChildren: true, isExpanded: expanded['documents'], onExpandedChange: () => toggle('documents'), isSelected: docState.isChecked, isIndeterminate: docState.isIndeterminate, onSelectedChange: () => toggleParent([...DOC_CHILDREN, ...WORK_CHILDREN]), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {}), children: [(0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: "Work", hasChildren: true, isExpanded: expanded['work'], onExpandedChange: () => toggle('work'), isSelected: workState.isChecked, isIndeterminate: workState.isIndeterminate, onSelectedChange: () => toggleParent(WORK_CHILDREN), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {}), children: [(0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Report.pdf", isSelected: !!checked['report'], onSelectedChange: () => toggleCheck('report'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}) }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Presentation.pptx", isDisabled: true, onSelectedChange: () => null, leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}) })] }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Resume.pdf", isSelected: !!checked['resume'], onSelectedChange: () => toggleCheck('resume'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}) })] }), (0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: "Images", hasChildren: true, isExpanded: expanded['images'], onExpandedChange: () => toggle('images'), isSelected: imageState.isChecked, isIndeterminate: imageState.isIndeterminate, onSelectedChange: () => toggleParent(IMAGE_CHILDREN), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {}), children: [(0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Photo.jpg", isSelected: !!checked['photo'], onSelectedChange: () => toggleCheck('photo'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PhotoIconOutline, {}) }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Screenshot.png", isSelected: !!checked['screenshot'], onSelectedChange: () => toggleCheck('screenshot'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PhotoIconOutline, {}) })] })] }));
|
|
71
|
+
};
|
|
72
|
+
exports.default = Component;
|
|
73
|
+
//# sourceMappingURL=tree-view-multi.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view-multi.story.js","sourceRoot":"","sources":["../../../../../src/next/tree-view/stories/tree-view-multi.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,kDAIgC;AAChC,gDAAiD;AACjD,iCAA8C;AAI9C,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAU,CAAC;AAC1D,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AACjD,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,YAAY,CAAU,CAAC;AACxD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;AAEhD,SAAS,gBAAgB,CACvB,OAAqB,EACrB,SAA4B;IAE5B,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAA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E,CAAC,MAAM,CAAC,QAAQ,CAAC,EACxC,UAAU,EAAE,UAAU,CAAC,SAAS,EAChC,eAAe,EAAE,UAAU,CAAC,eAAe,EAC3C,gBAAgB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,EACpD,aAAa,EAAE,uBAAC,uBAAe,KAAG,aAElC,uBAAC,eAAQ,CAAC,IAAI,IACZ,KAAK,EAAC,WAAW,EACjB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAC9B,gBAAgB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,EAC5C,aAAa,EAAE,uBAAC,wBAAgB,KAAG,GACnC,EACF,uBAAC,eAAQ,CAAC,IAAI,IACZ,KAAK,EAAC,gBAAgB,EACtB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EACnC,gBAAgB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,EACjD,aAAa,EAAE,uBAAC,wBAAgB,KAAG,GACnC,IACY,IACP,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport {\n DocumentIconOutline,\n FolderIconSolid,\n PhotoIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport { TreeView } from '@neo4j-ndl/react/next';\nimport { useCallback, useState } from 'react';\n\ntype CheckedState = Record<string, boolean>;\n\nconst WORK_CHILDREN = ['report', 'presentation'] as const;\nconst DOC_CHILDREN = ['work', 'resume'] as const;\nconst IMAGE_CHILDREN = ['photo', 'screenshot'] as const;\nconst DISABLED_KEYS = new Set(['presentation']);\n\nfunction getParentChecked(\n checked: CheckedState,\n childKeys: readonly string[],\n): { isChecked: boolean; isIndeterminate: boolean } {\n const enabledKeys = childKeys.filter((k) => !DISABLED_KEYS.has(k));\n if (enabledKeys.length === 0) {\n return { isChecked: false, isIndeterminate: false };\n }\n const checkedCount = enabledKeys.filter((k) => checked[k]).length;\n if (checkedCount === 0) {\n return { isChecked: false, isIndeterminate: false };\n }\n if (checkedCount === enabledKeys.length) {\n return { isChecked: true, isIndeterminate: false };\n }\n return { isChecked: false, isIndeterminate: true };\n}\n\nconst Component = () => {\n const [expanded, setExpanded] = useState<Record<string, boolean>>({});\n const [checked, setChecked] = useState<CheckedState>({});\n\n const toggle = (key: string) =>\n setExpanded((prev) => ({ ...prev, [key]: !prev[key] }));\n\n const toggleCheck = useCallback((key: string) => {\n setChecked((prev) => ({ ...prev, [key]: !prev[key] }));\n }, []);\n\n const toggleParent = useCallback(\n (childKeys: readonly string[]) => {\n const enabledKeys = childKeys.filter((k) => !DISABLED_KEYS.has(k));\n const isAllChecked = enabledKeys.every((k) => checked[k]);\n setChecked((prev) => {\n const next = { ...prev };\n for (const k of enabledKeys) {\n next[k] = !isAllChecked;\n }\n return next;\n });\n },\n [checked],\n );\n\n const docState = getParentChecked(checked, [\n ...DOC_CHILDREN,\n ...WORK_CHILDREN,\n ]);\n const workState = getParentChecked(checked, WORK_CHILDREN);\n const imageState = getParentChecked(checked, IMAGE_CHILDREN);\n\n return (\n <TreeView ariaLabel=\"File explorer\" selectionMode=\"multiple\">\n <TreeView.Item\n title=\"Documents\"\n hasChildren\n isExpanded={expanded['documents']}\n onExpandedChange={() => toggle('documents')}\n isSelected={docState.isChecked}\n isIndeterminate={docState.isIndeterminate}\n onSelectedChange={() =>\n toggleParent([...DOC_CHILDREN, ...WORK_CHILDREN])\n }\n leadingVisual={<FolderIconSolid />}\n >\n <TreeView.Item\n title=\"Work\"\n hasChildren\n isExpanded={expanded['work']}\n onExpandedChange={() => toggle('work')}\n isSelected={workState.isChecked}\n isIndeterminate={workState.isIndeterminate}\n onSelectedChange={() => toggleParent(WORK_CHILDREN)}\n leadingVisual={<FolderIconSolid />}\n >\n <TreeView.Item\n title=\"Report.pdf\"\n isSelected={!!checked['report']}\n onSelectedChange={() => toggleCheck('report')}\n leadingVisual={<DocumentIconOutline />}\n />\n <TreeView.Item\n title=\"Presentation.pptx\"\n isDisabled\n onSelectedChange={() => null}\n leadingVisual={<DocumentIconOutline />}\n />\n </TreeView.Item>\n <TreeView.Item\n title=\"Resume.pdf\"\n isSelected={!!checked['resume']}\n onSelectedChange={() => toggleCheck('resume')}\n leadingVisual={<DocumentIconOutline />}\n />\n </TreeView.Item>\n <TreeView.Item\n title=\"Images\"\n hasChildren\n isExpanded={expanded['images']}\n onExpandedChange={() => toggle('images')}\n isSelected={imageState.isChecked}\n isIndeterminate={imageState.isIndeterminate}\n onSelectedChange={() => toggleParent(IMAGE_CHILDREN)}\n leadingVisual={<FolderIconSolid />}\n >\n <TreeView.Item\n title=\"Photo.jpg\"\n isSelected={!!checked['photo']}\n onSelectedChange={() => toggleCheck('photo')}\n leadingVisual={<PhotoIconOutline />}\n />\n <TreeView.Item\n title=\"Screenshot.png\"\n isSelected={!!checked['screenshot']}\n onSelectedChange={() => toggleCheck('screenshot')}\n leadingVisual={<PhotoIconOutline />}\n />\n </TreeView.Item>\n </TreeView>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const icons_1 = require("@neo4j-ndl/react/icons");
|
|
26
|
+
const next_1 = require("@neo4j-ndl/react/next");
|
|
27
|
+
const react_1 = require("react");
|
|
28
|
+
const Component = () => {
|
|
29
|
+
const [expanded, setExpanded] = (0, react_1.useState)({});
|
|
30
|
+
const [selected, setSelected] = (0, react_1.useState)(null);
|
|
31
|
+
const toggle = (key) => setExpanded((prev) => (Object.assign(Object.assign({}, prev), { [key]: !prev[key] })));
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(next_1.TreeView, { ariaLabel: "File explorer", children: [(0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: "Documents", hasChildren: true, isExpanded: expanded['documents'], onExpandedChange: () => toggle('documents'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {}), children: [(0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: "Work", hasChildren: true, isExpanded: expanded['work'], onExpandedChange: () => toggle('work'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {}), children: [(0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Report.pdf", isSelected: selected === 'report', onSelectedChange: () => setSelected('report'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}) }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Presentation.pptx", isSelected: selected === 'presentation', onSelectedChange: () => setSelected('presentation'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}) })] }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Resume.pdf", isSelected: selected === 'resume', onSelectedChange: () => setSelected('resume'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}) })] }), (0, jsx_runtime_1.jsxs)(next_1.TreeView.Item, { title: "Images", hasChildren: true, isExpanded: expanded['images'], onExpandedChange: () => toggle('images'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.FolderIconSolid, {}), children: [(0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Photo.jpg", isSelected: selected === 'photo', onSelectedChange: () => setSelected('photo'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}) }), (0, jsx_runtime_1.jsx)(next_1.TreeView.Item, { title: "Screenshot.png", isSelected: selected === 'screenshot', onSelectedChange: () => setSelected('screenshot'), leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.DocumentIconOutline, {}) })] })] }));
|
|
33
|
+
};
|
|
34
|
+
exports.default = Component;
|
|
35
|
+
//# sourceMappingURL=tree-view-non-selectable-folders.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view-non-selectable-folders.story.js","sourceRoot":"","sources":["../../../../../src/next/tree-view/stories/tree-view-non-selectable-folders.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,kDAA8E;AAC9E,gDAAiD;AACjD,iCAAiC;AAEjC,MAAM,SA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AC,EACnD,aAAa,EAAE,uBAAC,2BAAmB,KAAG,GACtC,IACY,EAChB,uBAAC,eAAQ,CAAC,IAAI,IACZ,KAAK,EAAC,YAAY,EAClB,UAAU,EAAE,QAAQ,KAAK,QAAQ,EACjC,gBAAgB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAC7C,aAAa,EAAE,uBAAC,2BAAmB,KAAG,GACtC,IACY,EAChB,wBAAC,eAAQ,CAAC,IAAI,IACZ,KAAK,EAAC,QAAQ,EACd,WAAW,QACX,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC9B,gBAAgB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EACxC,aAAa,EAAE,uBAAC,uBAAe,KAAG,aAElC,uBAAC,eAAQ,CAAC,IAAI,IACZ,KAAK,EAAC,WAAW,EACjB,UAAU,EAAE,QAAQ,KAAK,OAAO,EAChC,gBAAgB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,EAC5C,aAAa,EAAE,uBAAC,2BAAmB,KAAG,GACtC,EACF,uBAAC,eAAQ,CAAC,IAAI,IACZ,KAAK,EAAC,gBAAgB,EACtB,UAAU,EAAE,QAAQ,KAAK,YAAY,EACrC,gBAAgB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,EACjD,aAAa,EAAE,uBAAC,2BAAmB,KAAG,GACtC,IACY,IACP,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { DocumentIconOutline, FolderIconSolid } from '@neo4j-ndl/react/icons';\nimport { TreeView } from '@neo4j-ndl/react/next';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [expanded, setExpanded] = useState<Record<string, boolean>>({});\n const [selected, setSelected] = useState<string | null>(null);\n\n const toggle = (key: string) =>\n setExpanded((prev) => ({ ...prev, [key]: !prev[key] }));\n\n return (\n <TreeView ariaLabel=\"File explorer\">\n <TreeView.Item\n title=\"Documents\"\n hasChildren\n isExpanded={expanded['documents']}\n onExpandedChange={() => toggle('documents')}\n leadingVisual={<FolderIconSolid />}\n >\n <TreeView.Item\n title=\"Work\"\n hasChildren\n isExpanded={expanded['work']}\n onExpandedChange={() => toggle('work')}\n leadingVisual={<FolderIconSolid />}\n >\n <TreeView.Item\n title=\"Report.pdf\"\n isSelected={selected === 'report'}\n onSelectedChange={() => setSelected('report')}\n leadingVisual={<DocumentIconOutline />}\n />\n <TreeView.Item\n title=\"Presentation.pptx\"\n isSelected={selected === 'presentation'}\n onSelectedChange={() => setSelected('presentation')}\n leadingVisual={<DocumentIconOutline />}\n />\n </TreeView.Item>\n <TreeView.Item\n title=\"Resume.pdf\"\n isSelected={selected === 'resume'}\n onSelectedChange={() => setSelected('resume')}\n leadingVisual={<DocumentIconOutline />}\n />\n </TreeView.Item>\n <TreeView.Item\n title=\"Images\"\n hasChildren\n isExpanded={expanded['images']}\n onExpandedChange={() => toggle('images')}\n leadingVisual={<FolderIconSolid />}\n >\n <TreeView.Item\n title=\"Photo.jpg\"\n isSelected={selected === 'photo'}\n onSelectedChange={() => setSelected('photo')}\n leadingVisual={<DocumentIconOutline />}\n />\n <TreeView.Item\n title=\"Screenshot.png\"\n isSelected={selected === 'screenshot'}\n onSelectedChange={() => setSelected('screenshot')}\n leadingVisual={<DocumentIconOutline />}\n />\n </TreeView.Item>\n </TreeView>\n );\n};\n\nexport default Component;\n"]}
|