@neo4j-ndl/react 4.9.32 → 4.9.34
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/_common/CodeBlockWrapper.js +2 -2
- package/lib/cjs/_common/CodeBlockWrapper.js.map +1 -1
- package/lib/cjs/code-block/CodeBlock.js +1 -1
- package/lib/cjs/code-block/CodeBlock.js.map +1 -1
- package/lib/cjs/popover/Popover.js.map +1 -1
- package/lib/cjs/popover/use-popover.js +8 -7
- package/lib/cjs/popover/use-popover.js.map +1 -1
- package/lib/cjs/tree-view/TreeItemWrapper.js +3 -3
- package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
- package/lib/cjs/tree-view/TreeView.js +34 -6
- package/lib/cjs/tree-view/TreeView.js.map +1 -1
- package/lib/cjs/tree-view/TreeViewItem.js +2 -2
- package/lib/cjs/tree-view/TreeViewItem.js.map +1 -1
- package/lib/cjs/tree-view/TreeViewTextItem.js +1 -1
- package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
- package/lib/cjs/tree-view/stories/treeview-default.story.js +9 -9
- package/lib/cjs/tree-view/stories/treeview-default.story.js.map +1 -1
- package/lib/cjs/tree-view/tree-view-types.js.map +1 -1
- package/lib/esm/_common/CodeBlockWrapper.js +2 -2
- package/lib/esm/_common/CodeBlockWrapper.js.map +1 -1
- package/lib/esm/code-block/CodeBlock.js +1 -1
- package/lib/esm/code-block/CodeBlock.js.map +1 -1
- package/lib/esm/popover/Popover.js.map +1 -1
- package/lib/esm/popover/use-popover.js +8 -7
- package/lib/esm/popover/use-popover.js.map +1 -1
- package/lib/esm/tree-view/TreeItemWrapper.js +3 -3
- package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
- package/lib/esm/tree-view/TreeView.js +34 -6
- package/lib/esm/tree-view/TreeView.js.map +1 -1
- package/lib/esm/tree-view/TreeViewItem.js +2 -2
- package/lib/esm/tree-view/TreeViewItem.js.map +1 -1
- package/lib/esm/tree-view/TreeViewTextItem.js +1 -1
- package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
- package/lib/esm/tree-view/stories/treeview-default.story.js +9 -9
- package/lib/esm/tree-view/stories/treeview-default.story.js.map +1 -1
- package/lib/esm/tree-view/tree-view-types.js.map +1 -1
- package/lib/types/_common/CodeBlockWrapper.d.ts.map +1 -1
- package/lib/types/popover/Popover.d.ts +3 -1
- package/lib/types/popover/Popover.d.ts.map +1 -1
- package/lib/types/tree-view/TreeItemWrapper.d.ts +1 -1
- package/lib/types/tree-view/TreeItemWrapper.d.ts.map +1 -1
- package/lib/types/tree-view/TreeView.d.ts +6 -3
- package/lib/types/tree-view/TreeView.d.ts.map +1 -1
- package/lib/types/tree-view/TreeViewItem.d.ts +4 -1
- package/lib/types/tree-view/TreeViewItem.d.ts.map +1 -1
- package/lib/types/tree-view/TreeViewTextItem.d.ts.map +1 -1
- package/lib/types/tree-view/tree-view-types.d.ts +3 -0
- package/lib/types/tree-view/tree-view-types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-popover.js","sourceRoot":"","sources":["../../../src/popover/use-popover.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EACV,IAAI,EAEJ,MAAM,EAGN,KAAK,EACL,QAAQ,EACR,cAAc,EACd,UAAU,EACV,WAAW,EACX,eAAe,EAEf,OAAO,EACP,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA8C1C,MAAM,UAAU,UAAU,CAAC,EACzB,aAAa,GAAG,KAAK,EACrB,SAAS,GAAG,QAAQ,EACpB,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,iBAAiB,EAC/B,YAAY,GAAG,EAAE,EACjB,aAAa,EAC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QAChB,UAAU;QACV,kBAAkB;QAClB,gBAAgB,IAChB,EACF;QACE,MAAM;QACN,YAAY;QACZ,IAAI;QACJ,gBAAgB;QAChB,OAAO;QACP,aAAa;QACb,2BAA2B;QAC3B,kBAAkB;QAClB,YAAY;QACZ,UAAU;QACV,WAAW;KACZ,CACF,CAAC;AACJ,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 */\nimport {\n autoUpdate,\n flip,\n type FloatingFocusManagerProps,\n offset,\n type OffsetOptions,\n type Placement,\n shift,\n useClick,\n useClientPoint,\n useDismiss,\n useFloating,\n useInteractions,\n type UseInteractionsReturn,\n useRole,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { tokens } from '@neo4j-ndl/base';\nimport { useMemo, useState } from 'react';\n\nexport interface PopoverOptions {\n isInitialOpen?: boolean;\n placement?: Placement;\n isOpen?: boolean;\n onOpenChange?: (open: boolean, event?: Event) => void;\n offsetOption?: OffsetOptions;\n anchorElement?: Element | null;\n anchorPosition?: {\n x: number;\n y: number;\n };\n anchorElementAsPortalAnchor?: boolean;\n shouldCaptureFocus?: boolean;\n initialFocus?: number | React.RefObject<HTMLElement | null>;\n role?:\n | 'tooltip'\n | 'dialog'\n | 'alertdialog'\n | 'menu'\n | 'listbox'\n | 'grid'\n | 'tree';\n closeOnClickOutside?: boolean;\n closeOnReferencePress?: boolean;\n returnFocus?: FloatingFocusManagerProps['returnFocus'];\n strategy?: 'fixed' | 'absolute';\n isPortaled?: boolean;\n}\n\nexport interface UsePopoverReturn\n extends UseInteractionsReturn, ReturnType<typeof useFloating> {\n isOpen: boolean;\n labelId: string | undefined;\n descriptionId: string | undefined;\n transitionStyles: React.CSSProperties;\n setLabelId: (labelId: string | undefined) => void;\n setDescriptionId: (descriptionId: string | undefined) => void;\n anchorElementAsPortalAnchor: boolean | undefined;\n shouldCaptureFocus: boolean | undefined;\n initialFocus: number | React.RefObject<HTMLElement | null> | undefined;\n isPortaled: boolean;\n returnFocus: FloatingFocusManagerProps['returnFocus'];\n}\n\nexport function usePopover({\n isInitialOpen = false,\n placement = 'bottom',\n isOpen: controlledOpen,\n onOpenChange: setControlledOpen,\n offsetOption = 10,\n anchorElement,\n anchorPosition,\n anchorElementAsPortalAnchor,\n shouldCaptureFocus,\n initialFocus,\n role: roleProp,\n closeOnClickOutside,\n closeOnReferencePress,\n returnFocus,\n strategy = 'absolute',\n isPortaled = true,\n}: PopoverOptions = {}): UsePopoverReturn {\n // Internal state for uncontrolled mode (no `isOpen` prop provided).\n const [isOpenUncontrolled, setIsOpenUncontrolled] = useState(isInitialOpen);\n const [labelId, setLabelId] = useState<string | undefined>();\n const [descriptionId, setDescriptionId] = useState<string | undefined>();\n\n // Controlled/uncontrolled pattern: prefer the consumer-provided `isOpen`,\n // falling back to internal state when not provided.\n const isOpen = controlledOpen ?? isOpenUncontrolled;\n\n const data = useFloating({\n elements: {\n reference: anchorElement,\n },\n middleware: [\n offset(offsetOption),\n flip({\n crossAxis: placement.includes('-'),\n fallbackAxisSideDirection: 'end',\n padding: 5,\n }),\n shift(),\n ],\n // Floating UI calls this when interactions (useClick, useDismiss, etc.)\n // trigger an open/close. We always sync internal state so uncontrolled\n // mode works, and notify the consumer callback exactly once if provided.\n onOpenChange: (open, event) => {\n setIsOpenUncontrolled(open);\n setControlledOpen?.(open, event);\n },\n open: isOpen,\n placement: placement,\n strategy,\n whileElementsMounted: autoUpdate,\n });\n const context = data.context;\n\n // Only enable built-in click-to-toggle in uncontrolled mode. In controlled\n // mode the consumer owns the open state and wires up their own trigger.\n const click = useClick(context, {\n enabled: controlledOpen === undefined,\n });\n\n const dismiss = useDismiss(context, {\n outsidePress: closeOnClickOutside,\n referencePress: closeOnReferencePress,\n });\n const role = useRole(context, {\n role: roleProp,\n });\n\n const clientPoint = useClientPoint(context, {\n enabled: anchorPosition !== undefined,\n x: anchorPosition?.x,\n y: anchorPosition?.y,\n });\n\n const interactions = useInteractions([click, dismiss, role, clientPoint]);\n\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: Number.parseInt(tokens.motion.duration.quick) ?? 0,\n });\n\n return useMemo(\n () => ({\n ...data,\n ...interactions,\n anchorElementAsPortalAnchor,\n descriptionId,\n initialFocus,\n isOpen,\n isPortaled,\n labelId,\n returnFocus,\n setDescriptionId,\n setLabelId,\n shouldCaptureFocus,\n transitionStyles,\n }),\n [\n isOpen,\n interactions,\n data,\n transitionStyles,\n labelId,\n descriptionId,\n anchorElementAsPortalAnchor,\n shouldCaptureFocus,\n initialFocus,\n isPortaled,\n returnFocus,\n ],\n );\n}\n"]}
|
|
@@ -150,10 +150,10 @@ const onInnerDivKeyDown = (event, shouldDisableInteraction, wrapperRef) => {
|
|
|
150
150
|
* Is also used internally to create the TreeViewTextItem component
|
|
151
151
|
*/
|
|
152
152
|
function TreeItemWrapperInner(_a) {
|
|
153
|
-
var { depth, shouldDisableInteraction, shouldDisableSorting, isGhost, isIndicator, onCollapse, item, setNodeRef, setActivatorNodeRef, dragHandleProps, style, className, trails, children, indentationWidth, tabIndex, onFocus, ref } = _a,
|
|
153
|
+
var { depth, shouldDisableInteraction, shouldDisableSorting, isGhost, isIndicator, onCollapse, item, setNodeRef, setActivatorNodeRef, dragHandleProps, style, className, trails, children, indentationWidth, ariaLevel, ariaPosInSet, ariaSetSize, tabIndex, onFocus, ref } = _a,
|
|
154
154
|
// Need to destruct to avoid passing it to the component
|
|
155
155
|
// oxlint-disable-next-line no-unused-vars
|
|
156
|
-
restProps = __rest(_a, ["depth", "shouldDisableInteraction", "shouldDisableSorting", "isGhost", "isIndicator", "onCollapse", "item", "setNodeRef", "setActivatorNodeRef", "dragHandleProps", "style", "className", "trails", "children", "indentationWidth", "tabIndex", "onFocus", "ref"]);
|
|
156
|
+
restProps = __rest(_a, ["depth", "shouldDisableInteraction", "shouldDisableSorting", "isGhost", "isIndicator", "onCollapse", "item", "setNodeRef", "setActivatorNodeRef", "dragHandleProps", "style", "className", "trails", "children", "indentationWidth", "ariaLevel", "ariaPosInSet", "ariaSetSize", "tabIndex", "onFocus", "ref"]);
|
|
157
157
|
const wrapperRef = useRef(null);
|
|
158
158
|
return (_jsx("li", { ref: (el) => {
|
|
159
159
|
wrapperRef.current = el;
|
|
@@ -167,7 +167,7 @@ function TreeItemWrapperInner(_a) {
|
|
|
167
167
|
'ndl-tree-view-list-item': true,
|
|
168
168
|
'ndl-tree-view-list-item-disable-interaction': shouldDisableInteraction,
|
|
169
169
|
'ndl-tree-view-list-item-placeholder': isGhost,
|
|
170
|
-
}), style: Object.assign(Object.assign({}, style), { paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0 }), role: "treeitem", onFocus: onFocus, "aria-selected": item.isSelected && !item.isSkeletonLoading, "aria-expanded": item.canHaveSubItems ? !item.isCollapsed : undefined, onKeyDown: (event) => onWrapperKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef, onCollapse, item), children: _jsxs("div", { role: "presentation", className: "ndl-tree-view-list-item-content", ref: ref, onKeyDown: (event) => onInnerDivKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef), children: [!shouldDisableSorting && (_jsx("button", Object.assign({ type: "button", className: "ndl-tree-view-drag-handle", ref: setActivatorNodeRef, "aria-label": "Pick up" }, dragHandleProps, { tabIndex: tabIndex, children: _jsx(DragIcon, {}) }))), trails.map((trail, index) => {
|
|
170
|
+
}), style: Object.assign(Object.assign({}, style), { paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0 }), role: "treeitem", onFocus: onFocus, "aria-level": ariaLevel, "aria-posinset": ariaPosInSet, "aria-setsize": ariaSetSize, "aria-selected": undefined, "aria-checked": item.isSelected && !item.isSkeletonLoading, "aria-expanded": item.canHaveSubItems ? !item.isCollapsed : undefined, onKeyDown: (event) => onWrapperKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef, onCollapse, item), children: _jsxs("div", { role: "presentation", className: "ndl-tree-view-list-item-content", ref: ref, onKeyDown: (event) => onInnerDivKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef), children: [!shouldDisableSorting && (_jsx("button", Object.assign({ type: "button", className: "ndl-tree-view-drag-handle", ref: setActivatorNodeRef, "aria-label": "Pick up" }, dragHandleProps, { tabIndex: tabIndex, children: _jsx(DragIcon, {}) }))), trails.map((trail, index) => {
|
|
171
171
|
return _jsx(Trail, { variant: trail }, index);
|
|
172
172
|
}), children] }) }));
|
|
173
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeItemWrapper.js","sourceRoot":"","sources":["../../../src/tree-view/TreeItemWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC;;;;;;;;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AAO,EAAE,KAAK,IAArB,KAAK,CAAoB,CAAC;gBAC/C,CAAC,CAAC,EAED,QAAQ,IACL,GACH,CACN,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,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 */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useRef } from 'react';\n\nimport { findFocusableChildren, findFocusableSibling } from '../_common/utils';\nimport { DragIcon } from '../icons';\nimport {\n focusCellInNextRow,\n focusCellInPreviousRow,\n focusNextRow,\n focusPreviousRow,\n} from './tree-view-keyboard-helpers';\nimport { type TreeItem, type TreeItemComponentProps } from './tree-view-types';\nimport { Trail } from './TreeViewTrail';\n\n/**\n * Handles keydown events for when the item itself is focused (wrapperRef.current)\n * Moves the focus between the item and its children as well as toggles collapsing of the item\n * @param event\n * @param shouldDisableInteraction\n * @param wrapperRef\n * @param onCollapse\n * @param item\n * @returns\n */\n\nconst onWrapperKeyDown = (\n event: React.KeyboardEvent,\n shouldDisableInteraction: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n onCollapse: (() => void) | undefined,\n item: TreeItem<Record<string, unknown>>,\n) => {\n if (shouldDisableInteraction || wrapperRef.current === null) {\n return;\n }\n\n if (event.key === 'Enter' && onCollapse) {\n onCollapse();\n } else if (event.key === 'ArrowRight') {\n event.preventDefault();\n if (item.canHaveSubItems && item.isCollapsed && onCollapse) {\n onCollapse();\n } else {\n const focusable = findFocusableChildren(wrapperRef.current);\n const [firstElement] = focusable;\n if (firstElement instanceof HTMLElement) {\n firstElement.focus();\n }\n }\n\n event.preventDefault();\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n if (item.canHaveSubItems && !item.isCollapsed && onCollapse) {\n onCollapse();\n } else {\n focusPreviousRow(wrapperRef.current);\n }\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusNextRow(wrapperRef.current);\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusPreviousRow(wrapperRef.current);\n }\n};\n\n/**\n * Handles keydown events for when one of the items children is focused\n * Moves the focus between the children of the item and up to the parent if needed.\n * Stops the event from propagating to the parent since it has it own keydown handler\n * The parent is the wrapperRef.current and uses onWrapperKeyDown\n * @param event\n * @param shouldDisableInteraction\n * @param wrapperRef\n */\nconst onInnerDivKeyDown = (\n event: React.KeyboardEvent,\n shouldDisableInteraction: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n) => {\n if (shouldDisableInteraction) {\n return;\n }\n event.stopPropagation();\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n const nextElement = findFocusableSibling(wrapperRef, 'next');\n if (nextElement) {\n nextElement.focus();\n }\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n const previousElement = findFocusableSibling(wrapperRef, 'prev');\n if (previousElement) {\n previousElement.focus();\n } else {\n wrapperRef.current?.focus();\n }\n } else if (event.key === 'ArrowDown' && wrapperRef.current !== null) {\n event.preventDefault();\n focusCellInNextRow(wrapperRef.current);\n } else if (event.key === 'ArrowUp' && wrapperRef.current !== null) {\n event.preventDefault();\n focusCellInPreviousRow(wrapperRef.current);\n } else if (event.shiftKey && event.key === 'Tab') {\n const previousElement = findFocusableSibling(wrapperRef, 'prev');\n if (previousElement) {\n event.preventDefault();\n previousElement.focus();\n }\n } else if (event.key === 'Tab') {\n if (event.shiftKey) {\n return;\n }\n\n const nextElement = findFocusableSibling(wrapperRef, 'next');\n if (nextElement) {\n nextElement.focus();\n event.preventDefault();\n }\n }\n};\n\n/**\n * Used as a helper function to wrap the TreeItem component\n * This adds the drag handle and trail to the start of a tree item.\n * Useful if you want to add additional functionality to the tree item but still keep the drag handle and trail\n * Is also used internally to create the TreeViewTextItem component\n */\nfunction TreeItemWrapperInner<T extends Record<string, unknown>>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n isIndicator,\n onCollapse,\n item,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n className,\n trails,\n children,\n indentationWidth,\n tabIndex,\n onFocus,\n ref,\n // Need to destruct to avoid passing it to the component\n // oxlint-disable-next-line no-unused-vars\n ...restProps\n}: React.PropsWithChildren<TreeItemComponentProps<T>>) {\n const wrapperRef = useRef<HTMLElement | null>(null);\n\n return (\n <li\n ref={(el) => {\n wrapperRef.current = el;\n\n if (el === null) {\n return;\n }\n setNodeRef(el);\n }}\n className={classNames({\n className,\n indicator: isIndicator,\n 'ndl-tree-view-list-item': true,\n 'ndl-tree-view-list-item-disable-interaction': shouldDisableInteraction,\n 'ndl-tree-view-list-item-placeholder': isGhost,\n })}\n style={{\n ...style,\n paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0,\n }}\n role=\"treeitem\"\n onFocus={onFocus}\n aria-selected={item.isSelected && !item.isSkeletonLoading}\n aria-expanded={item.canHaveSubItems ? !item.isCollapsed : undefined}\n onKeyDown={(event) =>\n onWrapperKeyDown(\n event,\n shouldDisableInteraction ?? false,\n wrapperRef,\n onCollapse,\n item,\n )\n }\n >\n <div\n role=\"presentation\"\n className=\"ndl-tree-view-list-item-content\"\n ref={ref}\n onKeyDown={(event) =>\n onInnerDivKeyDown(\n event,\n shouldDisableInteraction ?? false,\n wrapperRef,\n )\n }\n >\n {!shouldDisableSorting && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-drag-handle\"\n ref={setActivatorNodeRef}\n aria-label=\"Pick up\"\n {...dragHandleProps}\n tabIndex={tabIndex}\n >\n <DragIcon />\n </button>\n )}\n {trails.map((trail, index) => {\n return <Trail key={index} variant={trail} />;\n })}\n\n {children}\n </div>\n </li>\n );\n}\n\nexport const TreeItemWrapper = TreeItemWrapperInner;\n"]}
|
|
1
|
+
{"version":3,"file":"TreeItemWrapper.js","sourceRoot":"","sources":["../../../src/tree-view/TreeItemWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC;;;;;;;;;GASG;AAEH,MAAM,gBAAgB,GAAG,CACvB,KAA0B,EAC1B,wBAAiC,EACjC,UAA+C,EAC/C,UAAoC,EACpC,IAAuC,EACvC,EAAE;IACF,IAAI,wBAAwB,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5D,OAAO;IACT,CAAC;IAED,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,UAAU,EAAE,CAAC;QACxC,UAAU,EAAE,CAAC;IACf,CAAC;SAAM,IAAI,KAAK,CAAC,GAAG,KAAK,YAAY,EAAE,CAAC;QACtC,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,WAAW,IAAI,UAAU,EAAE,CAAC;YAC3D,UAAU,EAAE,CAAC;QACf,CAAC;aAAM,CAAC;YACN,MAAM,SAAS,GAAG,qBAAqB,CAAC,UAAU,CAAC,OAAO,CAAC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C,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACnE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,gBAAgB,CACd,KAAK,EACL,wBAAwB,aAAxB,wBAAwB,cAAxB,wBAAwB,GAAI,KAAK,EACjC,UAAU,EACV,UAAU,EACV,IAAI,CACL,YAGH,eACE,IAAI,EAAC,cAAc,EACnB,SAAS,EAAC,iCAAiC,EAC3C,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,iBAAiB,CACf,KAAK,EACL,wBAAwB,aAAxB,wBAAwB,cAAxB,wBAAwB,GAAI,KAAK,EACjC,UAAU,CACX,aAGF,CAAC,oBAAoB,IAAI,CACxB,+BACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,2BAA2B,EACrC,GAAG,EAAE,mBAAmB,gBACb,SAAS,IAChB,eAAe,IACnB,QAAQ,EAAE,QAAQ,YAElB,KAAC,QAAQ,KAAG,IACL,CACV,EACA,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;oBAC3B,OAAO,KAAC,KAAK,IAAa,OAAO,EAAE,KAAK,IAArB,KAAK,CAAoB,CAAC;gBAC/C,CAAC,CAAC,EAED,QAAQ,IACL,GACH,CACN,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,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 */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useRef } from 'react';\n\nimport { findFocusableChildren, findFocusableSibling } from '../_common/utils';\nimport { DragIcon } from '../icons';\nimport {\n focusCellInNextRow,\n focusCellInPreviousRow,\n focusNextRow,\n focusPreviousRow,\n} from './tree-view-keyboard-helpers';\nimport { type TreeItem, type TreeItemComponentProps } from './tree-view-types';\nimport { Trail } from './TreeViewTrail';\n\n/**\n * Handles keydown events for when the item itself is focused (wrapperRef.current)\n * Moves the focus between the item and its children as well as toggles collapsing of the item\n * @param event\n * @param shouldDisableInteraction\n * @param wrapperRef\n * @param onCollapse\n * @param item\n * @returns\n */\n\nconst onWrapperKeyDown = (\n event: React.KeyboardEvent,\n shouldDisableInteraction: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n onCollapse: (() => void) | undefined,\n item: TreeItem<Record<string, unknown>>,\n) => {\n if (shouldDisableInteraction || wrapperRef.current === null) {\n return;\n }\n\n if (event.key === 'Enter' && onCollapse) {\n onCollapse();\n } else if (event.key === 'ArrowRight') {\n event.preventDefault();\n if (item.canHaveSubItems && item.isCollapsed && onCollapse) {\n onCollapse();\n } else {\n const focusable = findFocusableChildren(wrapperRef.current);\n const [firstElement] = focusable;\n if (firstElement instanceof HTMLElement) {\n firstElement.focus();\n }\n }\n\n event.preventDefault();\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n if (item.canHaveSubItems && !item.isCollapsed && onCollapse) {\n onCollapse();\n } else {\n focusPreviousRow(wrapperRef.current);\n }\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusNextRow(wrapperRef.current);\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusPreviousRow(wrapperRef.current);\n }\n};\n\n/**\n * Handles keydown events for when one of the items children is focused\n * Moves the focus between the children of the item and up to the parent if needed.\n * Stops the event from propagating to the parent since it has it own keydown handler\n * The parent is the wrapperRef.current and uses onWrapperKeyDown\n * @param event\n * @param shouldDisableInteraction\n * @param wrapperRef\n */\nconst onInnerDivKeyDown = (\n event: React.KeyboardEvent,\n shouldDisableInteraction: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n) => {\n if (shouldDisableInteraction) {\n return;\n }\n event.stopPropagation();\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n const nextElement = findFocusableSibling(wrapperRef, 'next');\n if (nextElement) {\n nextElement.focus();\n }\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n const previousElement = findFocusableSibling(wrapperRef, 'prev');\n if (previousElement) {\n previousElement.focus();\n } else {\n wrapperRef.current?.focus();\n }\n } else if (event.key === 'ArrowDown' && wrapperRef.current !== null) {\n event.preventDefault();\n focusCellInNextRow(wrapperRef.current);\n } else if (event.key === 'ArrowUp' && wrapperRef.current !== null) {\n event.preventDefault();\n focusCellInPreviousRow(wrapperRef.current);\n } else if (event.shiftKey && event.key === 'Tab') {\n const previousElement = findFocusableSibling(wrapperRef, 'prev');\n if (previousElement) {\n event.preventDefault();\n previousElement.focus();\n }\n } else if (event.key === 'Tab') {\n if (event.shiftKey) {\n return;\n }\n\n const nextElement = findFocusableSibling(wrapperRef, 'next');\n if (nextElement) {\n nextElement.focus();\n event.preventDefault();\n }\n }\n};\n\n/**\n * Used as a helper function to wrap the TreeItem component\n * This adds the drag handle and trail to the start of a tree item.\n * Useful if you want to add additional functionality to the tree item but still keep the drag handle and trail\n * Is also used internally to create the TreeViewTextItem component\n */\nfunction TreeItemWrapperInner<T extends Record<string, unknown>>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n isIndicator,\n onCollapse,\n item,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n className,\n trails,\n children,\n indentationWidth,\n ariaLevel,\n ariaPosInSet,\n ariaSetSize,\n tabIndex,\n onFocus,\n ref,\n // Need to destruct to avoid passing it to the component\n // oxlint-disable-next-line no-unused-vars\n ...restProps\n}: React.PropsWithChildren<TreeItemComponentProps<T>>) {\n const wrapperRef = useRef<HTMLElement | null>(null);\n\n return (\n <li\n ref={(el) => {\n wrapperRef.current = el;\n\n if (el === null) {\n return;\n }\n setNodeRef(el);\n }}\n className={classNames({\n className,\n indicator: isIndicator,\n 'ndl-tree-view-list-item': true,\n 'ndl-tree-view-list-item-disable-interaction': shouldDisableInteraction,\n 'ndl-tree-view-list-item-placeholder': isGhost,\n })}\n style={{\n ...style,\n paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0,\n }}\n role=\"treeitem\"\n onFocus={onFocus}\n aria-level={ariaLevel}\n aria-posinset={ariaPosInSet}\n aria-setsize={ariaSetSize}\n aria-selected={undefined}\n aria-checked={item.isSelected && !item.isSkeletonLoading}\n aria-expanded={item.canHaveSubItems ? !item.isCollapsed : undefined}\n onKeyDown={(event) =>\n onWrapperKeyDown(\n event,\n shouldDisableInteraction ?? false,\n wrapperRef,\n onCollapse,\n item,\n )\n }\n >\n <div\n role=\"presentation\"\n className=\"ndl-tree-view-list-item-content\"\n ref={ref}\n onKeyDown={(event) =>\n onInnerDivKeyDown(\n event,\n shouldDisableInteraction ?? false,\n wrapperRef,\n )\n }\n >\n {!shouldDisableSorting && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-drag-handle\"\n ref={setActivatorNodeRef}\n aria-label=\"Pick up\"\n {...dragHandleProps}\n tabIndex={tabIndex}\n >\n <DragIcon />\n </button>\n )}\n {trails.map((trail, index) => {\n return <Trail key={index} variant={trail} />;\n })}\n\n {children}\n </div>\n </li>\n );\n}\n\nexport const TreeItemWrapper = TreeItemWrapperInner;\n"]}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
13
|
/**
|
|
3
14
|
*
|
|
@@ -51,8 +62,9 @@ const dropAnimationConfig = {
|
|
|
51
62
|
});
|
|
52
63
|
},
|
|
53
64
|
};
|
|
54
|
-
const TreeViewComponent = function TreeView(
|
|
55
|
-
var
|
|
65
|
+
const TreeViewComponent = function TreeView(_a) {
|
|
66
|
+
var _b;
|
|
67
|
+
var { items, TreeItemComponent, onItemsChanged, htmlAttributes } = _a, restProps = __rest(_a, ["items", "TreeItemComponent", "onItemsChanged", "htmlAttributes"]);
|
|
56
68
|
const flattenItems = useMemo(() => flattenTree(items), [items]);
|
|
57
69
|
const [activeId, setActiveId] = useState(null);
|
|
58
70
|
const [overId, setOverId] = useState(null);
|
|
@@ -102,6 +114,18 @@ const TreeViewComponent = function TreeView({ items, TreeItemComponent, onItemsC
|
|
|
102
114
|
const projected = useMemo(() => activeId && overId
|
|
103
115
|
? getProjection(flattenedAndRemovedCollapsedItemsWithActive, activeId, overId, offsetLeft, indentationWidth)
|
|
104
116
|
: null, [activeId, overId, flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);
|
|
117
|
+
const hasSelectableItems = useMemo(() => flattenItems.some((item) => item.isSelected !== undefined), [flattenItems]);
|
|
118
|
+
const itemAriaData = useMemo(() => {
|
|
119
|
+
const visibleItems = flattenedAndRemovedCollapsedItemsWithActive.filter((item) => item.id !== ACTIVE_PLACEHOLDER_ID);
|
|
120
|
+
return visibleItems.reduce((acc, item) => {
|
|
121
|
+
const siblings = visibleItems.filter((sibling) => sibling.parentId === item.parentId);
|
|
122
|
+
acc[item.id] = {
|
|
123
|
+
posInSet: siblings.findIndex((sibling) => sibling.id === item.id) + 1,
|
|
124
|
+
setSize: siblings.length,
|
|
125
|
+
};
|
|
126
|
+
return acc;
|
|
127
|
+
}, {});
|
|
128
|
+
}, [flattenedAndRemovedCollapsedItemsWithActive]);
|
|
105
129
|
/* ------------------------------ Handlers ------------------------------ */
|
|
106
130
|
function handleDragStart({ active }) {
|
|
107
131
|
const activeId = active.id;
|
|
@@ -287,12 +311,16 @@ const TreeViewComponent = function TreeView({ items, TreeItemComponent, onItemsC
|
|
|
287
311
|
},
|
|
288
312
|
};
|
|
289
313
|
const trails = getTrailList();
|
|
290
|
-
const rowIdWithFocus = focusedRowId !== null && focusedRowId !== void 0 ? focusedRowId : (
|
|
291
|
-
return (_jsx(DndContext, { accessibility: { announcements }, sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, onDragStart: handleDragStart, onDragMove: handleDragMove, onDragOver: handleDragOver, onDragCancel: handleDragCancel, measuring: measuring, children: _jsxs(SortableContext, { items: flattenedAndRemovedCollapsedItemsWithActive.map((item) => item.id), strategy: verticalListSortingStrategy, children: [_jsx("ol", Object.assign({ className: "ndl-tree-view-list", role: "tree" }, htmlAttributes, { children: flattenedAndRemovedCollapsedItemsWithActive.map((item) => {
|
|
292
|
-
var _a;
|
|
314
|
+
const rowIdWithFocus = focusedRowId !== null && focusedRowId !== void 0 ? focusedRowId : (_b = flattenedAndRemovedCollapsedItemsWithActive[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
315
|
+
return (_jsx(DndContext, { accessibility: { announcements }, sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, onDragStart: handleDragStart, onDragMove: handleDragMove, onDragOver: handleDragOver, onDragCancel: handleDragCancel, measuring: measuring, children: _jsxs(SortableContext, { items: flattenedAndRemovedCollapsedItemsWithActive.map((item) => item.id), strategy: verticalListSortingStrategy, children: [_jsx("ol", Object.assign({ className: "ndl-tree-view-list", role: "tree", "aria-multiselectable": hasSelectableItems ? true : undefined }, restProps, htmlAttributes, { children: flattenedAndRemovedCollapsedItemsWithActive.map((item) => {
|
|
316
|
+
var _a, _b, _c;
|
|
293
317
|
return (_jsx(SortableTreeViewItem, { depth: item.id === activeId && projected ? projected.depth : item.depth, indentationWidth: indentationWidth, item: item, isLast: false, parent: (_a = flattenItems.find((i) => i.id === item.parentId)) !== null && _a !== void 0 ? _a : null, id: item.id, trails: trails[item.id], keepGhostInPlace: item.id === ACTIVE_PLACEHOLDER_ID, TreeItemComponent: TreeItemComponent === undefined
|
|
294
318
|
? TreeViewTextItem
|
|
295
|
-
: TreeItemComponent, onCollapse: () => handleToggleCollapse(item.id), onItemsChanged: (newItems, itemChangedReason) => onItemsChanged(buildTree(newItems), itemChangedReason), items: flattenItems,
|
|
319
|
+
: TreeItemComponent, onCollapse: () => handleToggleCollapse(item.id), onItemsChanged: (newItems, itemChangedReason) => onItemsChanged(buildTree(newItems), itemChangedReason), items: flattenItems, ariaLevel: item.id === ACTIVE_PLACEHOLDER_ID ? undefined : item.depth + 1, ariaPosInSet: item.id === ACTIVE_PLACEHOLDER_ID
|
|
320
|
+
? undefined
|
|
321
|
+
: (_b = itemAriaData[item.id]) === null || _b === void 0 ? void 0 : _b.posInSet, ariaSetSize: item.id === ACTIVE_PLACEHOLDER_ID
|
|
322
|
+
? undefined
|
|
323
|
+
: (_c = itemAriaData[item.id]) === null || _c === void 0 ? void 0 : _c.setSize, tabIndex: item.id === rowIdWithFocus ? 0 : -1, onFocus: () => setFocusedRowId(item.id), shouldDisableSorting: item.isSortable === false }, item.id));
|
|
296
324
|
}) })), createPortal(_jsx(DragOverlay, { dropAnimation: dropAnimationConfig }), document.body)] }) }));
|
|
297
325
|
};
|
|
298
326
|
const TreeViewComponents = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../src/tree-view/TreeView.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,aAAa,EACb,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AAC,QAAQ,CAAC,mCAAI,IAAI,EAChE,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EACvB,gBAAgB,EAAE,IAAI,CAAC,EAAE,KAAK,qBAAqB,EACnD,iBAAiB,EACf,iBAAiB,KAAK,SAAS;gCAC7B,CAAC,CAAE,gBAA4C;gCAC/C,CAAC,CAAC,iBAAiB,EAEvB,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,EAC/C,cAAc,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,EAAE,CAC9C,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,EAExD,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC7C,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EACvC,oBAAoB,EAAE,IAAI,CAAC,UAAU,KAAK,KAAK,IAvB1C,IAAI,CAAC,EAAE,CAwBZ,CACH,CAAA;qBAAA,CAAC,IACC,EAEJ,YAAY,CACX,KAAC,WAAW,IAAC,aAAa,EAAE,mBAAmB,GAAgB,EAC/D,QAAQ,CAAC,IAAI,CACd,IACe,GACP,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACzB,oBAAoB;IACpB,eAAe;IACf,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,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 */\nimport {\n type Announcements,\n closestCenter,\n defaultDropAnimation,\n DndContext,\n type DragEndEvent,\n type DragMoveEvent,\n type DragOverEvent,\n DragOverlay,\n type DragStartEvent,\n type DropAnimation,\n KeyboardSensor,\n MeasuringStrategy,\n PointerSensor,\n type UniqueIdentifier,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {\n arrayMove,\n SortableContext,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\nimport type React from 'react';\nimport { useCallback, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { type HtmlAttributes } from '../_common/types';\nimport { sortableTreeKeyboardCoordinates } from './tree-view-keyboard-coordinates';\nimport {\n type FlattenedTreeItem,\n type ItemChangedReason,\n type TreeItem,\n type TreeItemComponent,\n} from './tree-view-types';\nimport {\n buildTree,\n flattenTree,\n getProjection,\n removeChildrenOf,\n type SensorContext,\n transformToString,\n} from './tree-view-utils';\nimport { TreeItemWrapper } from './TreeItemWrapper';\nimport { SortableTreeViewItem } from './TreeViewItem';\nimport { TreeViewTextItem } from './TreeViewTextItem';\n\nconst indentationWidth = 20;\nconst ACTIVE_PLACEHOLDER_ID = 'ndl-active-tree-item';\n\nconst dropAnimationConfig: DropAnimation = {\n easing: 'ease-out',\n keyframes({ transform }) {\n return [\n {\n opacity: 1,\n transform: transformToString(transform.initial),\n },\n {\n opacity: 0,\n transform: transformToString({\n ...transform.final,\n y: transform.final.y + 5,\n x: transform.final.x + 5,\n }),\n },\n ];\n },\n sideEffects({ active }) {\n active.node.animate([{ opacity: 0 }, { opacity: 1 }], {\n duration: defaultDropAnimation.duration,\n easing: defaultDropAnimation.easing,\n });\n },\n};\n\nexport interface TreeViewProps<\n T extends Record<string, unknown>,\n E extends HTMLElement,\n> extends React.HTMLAttributes<HTMLOListElement> {\n /** The items to be displayed in the tree view */\n items: TreeItem<T>[];\n /** A function that is called when the items in the tree view change */\n onItemsChanged: (\n newItems: TreeItem<T>[],\n itemChangedReason: ItemChangedReason<T>,\n ) => void;\n /** The component to use for the tree items, if not provided the default component will be used */\n TreeItemComponent?: TreeItemComponent<T, E>;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'ol'>;\n}\n\nconst TreeViewComponent = function TreeView<\n T extends Record<string, unknown>,\n E extends HTMLElement,\n>({\n items,\n TreeItemComponent,\n onItemsChanged,\n htmlAttributes,\n}: TreeViewProps<T, E>) {\n const flattenItems = useMemo(() => flattenTree(items), [items]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const [overId, setOverId] = useState<UniqueIdentifier | null>(null);\n const [focusedRowId, setFocusedRowId] = useState<UniqueIdentifier | null>(\n null,\n );\n\n const [currentPosition, setCurrentPosition] = useState<{\n parentId: UniqueIdentifier | null;\n overId: UniqueIdentifier;\n } | null>(null);\n const [offsetLeft, setOffsetLeft] = useState(0);\n\n /* ------------------------------ Setup of Data ------------------------------ */\n\n const flattenedAndRemovedCollapsedItems = useMemo(() => {\n const collapsedItemsIds = flattenItems\n .filter((item) => item.canHaveSubItems && item.isCollapsed)\n .map((item) => item.id);\n\n return removeChildrenOf(\n [...flattenItems],\n activeId !== null ? [activeId, ...collapsedItemsIds] : collapsedItemsIds,\n );\n }, [activeId, flattenItems]);\n\n const activeItem = useMemo(\n () => (activeId ? flattenItems.find(({ id }) => id === activeId) : null),\n [activeId, flattenItems],\n );\n\n const flattenedAndRemovedCollapsedItemsWithActive = useMemo(() => {\n const collapsedItems = flattenItems.reduce<UniqueIdentifier[]>(\n (acc, item) => {\n if (item.canHaveSubItems && item.isCollapsed) {\n return [...acc, item.id];\n }\n return acc;\n },\n [],\n );\n\n const ItemsWithCollapsedRemoved = removeChildrenOf(\n flattenItems,\n activeId ? [activeId, ...collapsedItems] : collapsedItems,\n );\n const newArray: FlattenedTreeItem<T>[] = [];\n for (const item of ItemsWithCollapsedRemoved) {\n newArray.push(item);\n if (item.id === activeId) {\n newArray.push({\n ...item,\n id: ACTIVE_PLACEHOLDER_ID,\n });\n }\n }\n\n return newArray;\n }, [flattenItems, activeId]);\n\n if (activeItem?.canHaveSubItems && !activeItem?.isCollapsed) {\n flattenedAndRemovedCollapsedItems.push({\n ...activeItem,\n id: ACTIVE_PLACEHOLDER_ID,\n });\n }\n\n const sensorContext: SensorContext<T> = useRef({\n items: flattenedAndRemovedCollapsedItemsWithActive,\n offset: offsetLeft,\n });\n\n const coordinateGetter = useMemo(() => {\n sensorContext.current.items = flattenedAndRemovedCollapsedItemsWithActive;\n sensorContext.current.offset = offsetLeft;\n\n return sortableTreeKeyboardCoordinates<T>(\n sensorContext,\n true,\n indentationWidth,\n );\n }, [flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: coordinateGetter,\n }),\n );\n\n const projected = useMemo(\n () =>\n activeId && overId\n ? getProjection(\n flattenedAndRemovedCollapsedItemsWithActive,\n activeId,\n overId,\n offsetLeft,\n indentationWidth,\n )\n : null,\n [activeId, overId, flattenedAndRemovedCollapsedItemsWithActive, offsetLeft],\n );\n /* ------------------------------ Handlers ------------------------------ */\n function handleDragStart({ active }: DragStartEvent) {\n const activeId = active.id;\n setActiveId(activeId);\n setOverId(activeId);\n\n const activeItem = flattenItems.find(({ id }) => id === activeId);\n if (activeItem) {\n setCurrentPosition({\n overId: activeId,\n parentId: activeItem.parentId,\n });\n }\n\n document.body.style.setProperty('cursor', 'grabbing');\n }\n\n function handleDragMove({ delta }: DragMoveEvent) {\n setOffsetLeft(delta.x);\n }\n\n function handleDragOver({ over }: DragOverEvent) {\n setOverId(over?.id ?? null);\n }\n\n function resetState() {\n setOverId(null);\n setActiveId(null);\n setOffsetLeft(0);\n setCurrentPosition(null);\n\n document.body.style.setProperty('cursor', '');\n }\n\n const handleDragEnd = useCallback(\n (event: DragEndEvent) => {\n const { active, over } = event;\n resetState();\n let overIndex = flattenItems.findIndex((item) => item.id === over?.id);\n\n if (over?.id === ACTIVE_PLACEHOLDER_ID) {\n overIndex = flattenItems.findIndex((item) => item.id === active.id);\n }\n if (projected && over) {\n const { depth, parentId } = projected;\n const clonedItems: FlattenedTreeItem<T>[] = [...flattenItems];\n\n const parentIndex = clonedItems.findIndex(\n (item) => item.id === parentId,\n );\n const activeIndex = clonedItems.findIndex(({ id }) => id === active.id);\n const activeTreeItem = clonedItems[activeIndex];\n\n clonedItems[activeIndex] = { ...activeTreeItem, depth, parentId };\n const parentItem = clonedItems[parentIndex];\n if (parentItem && parentItem.canHaveSubItems) {\n clonedItems[parentIndex] = { ...parentItem, isCollapsed: false };\n }\n const newItems = buildTree(\n arrayMove(clonedItems, activeIndex, overIndex),\n );\n\n onItemsChanged(newItems, {\n item: activeTreeItem,\n reason: 'dropped',\n });\n }\n },\n [flattenItems, onItemsChanged, projected],\n );\n\n function handleToggleCollapse(id: UniqueIdentifier) {\n const item = flattenItems.find((item) => item.id === id);\n if (!item || item.canHaveSubItems !== true) {\n return;\n }\n\n onItemsChanged(\n buildTree(\n flattenItems.map((item) => {\n if (item.id === id && item.canHaveSubItems === true) {\n return { ...item, isCollapsed: !item.isCollapsed };\n }\n return item;\n }),\n ),\n {\n item,\n reason: item.isCollapsed ? 'expanded' : 'collapsed',\n },\n );\n }\n\n function handleDragCancel() {\n resetState();\n }\n\n /* ------------------------------ Keyboard functions ------------------------------ */\n const getMovementAnnouncement = (\n eventName: string,\n activeId: UniqueIdentifier,\n overId?: UniqueIdentifier,\n ) => {\n if (overId && projected) {\n if (eventName !== 'onDragEnd') {\n if (\n currentPosition &&\n projected.parentId === currentPosition.parentId &&\n overId === currentPosition.overId\n ) {\n return;\n } else {\n setCurrentPosition({\n overId,\n parentId: projected.parentId,\n });\n }\n }\n\n const clonedItems: FlattenedTreeItem<T>[] = [\n ...flattenedAndRemovedCollapsedItemsWithActive,\n ];\n const overIndex = clonedItems.findIndex(({ id }) => id === overId);\n const activeIndex = clonedItems.findIndex(({ id }) => id === activeId);\n const sortedItems = arrayMove(clonedItems, activeIndex, overIndex);\n\n const previousItem = sortedItems[overIndex - 1];\n\n let announcement;\n const movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';\n const nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';\n\n if (!previousItem) {\n const nextItem = sortedItems[overIndex + 1];\n announcement = `${activeId} was ${movedVerb} before ${nextItem.id}.`;\n } else {\n if (projected.depth > previousItem.depth) {\n announcement = `${activeId} was ${nestedVerb} under ${previousItem.id}.`;\n } else {\n let previousSibling: FlattenedTreeItem<T> | undefined = previousItem;\n while (previousSibling && projected.depth < previousSibling.depth) {\n const parentId: UniqueIdentifier | null = previousSibling.parentId;\n previousSibling = sortedItems.find(({ id }) => id === parentId);\n }\n\n if (previousSibling) {\n announcement = `${activeId} was ${movedVerb} after ${previousSibling.id}.`;\n }\n }\n }\n\n return announcement;\n }\n\n return;\n };\n\n const announcements: Announcements = {\n onDragCancel({ active }) {\n return `Moving was cancelled. ${active.id} was dropped in its original position.`;\n },\n onDragEnd({ active, over }) {\n return getMovementAnnouncement('onDragEnd', active.id, over?.id);\n },\n onDragMove({ active, over }) {\n return getMovementAnnouncement('onDragMove', active.id, over?.id);\n },\n onDragOver({ active, over }) {\n return getMovementAnnouncement('onDragOver', active.id, over?.id);\n },\n onDragStart({ active }) {\n return `Picked up ${active.id}.`;\n },\n };\n /* ------------------------------ Visual ------------------------------ */\n function getTrailList() {\n const trails: Record<\n UniqueIdentifier,\n ('none' | 'straight' | 'straight-curved' | 'curved')[]\n > = {};\n // Loop through the items in reverse\n [...flattenedAndRemovedCollapsedItemsWithActive]\n .reverse()\n .forEach((item, itemIndex, reversedList) => {\n const trailList: (\n | 'none'\n | 'straight'\n | 'straight-curved'\n | 'curved'\n )[] = [];\n const nextItem = reversedList[itemIndex - 1];\n // Loop through the depth of the item\n\n for (let trailDepth = 0; trailDepth < item.depth; trailDepth++) {\n // Not closest to the item so should be straight or none\n if (trailDepth < item.depth - 1) {\n if (nextItem === undefined) {\n trailList.push('none');\n continue;\n } else if (trails[nextItem?.id][trailDepth] === 'none') {\n trailList.push('none');\n continue;\n } else if (nextItem && nextItem.depth <= trailDepth) {\n trailList.push('none');\n continue;\n }\n trailList.push('straight');\n } else {\n if (\n (nextItem && trails[nextItem?.id][trailDepth] === 'none') ||\n nextItem === undefined ||\n nextItem.depth <= trailDepth\n ) {\n trailList.push('curved');\n } else {\n trailList.push('straight-curved');\n }\n }\n }\n trails[item.id] = trailList;\n });\n return trails;\n }\n\n const measuring = {\n droppable: {\n strategy: MeasuringStrategy.Always,\n },\n };\n\n const trails = getTrailList();\n const rowIdWithFocus =\n focusedRowId ?? flattenedAndRemovedCollapsedItemsWithActive[0]?.id;\n return (\n <DndContext\n accessibility={{ announcements }}\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={handleDragEnd}\n onDragStart={handleDragStart}\n onDragMove={handleDragMove}\n onDragOver={handleDragOver}\n onDragCancel={handleDragCancel}\n measuring={measuring}\n >\n <SortableContext\n items={flattenedAndRemovedCollapsedItemsWithActive.map(\n (item) => item.id,\n )}\n strategy={verticalListSortingStrategy}\n >\n <ol className=\"ndl-tree-view-list\" role=\"tree\" {...htmlAttributes}>\n {flattenedAndRemovedCollapsedItemsWithActive.map((item) => (\n <SortableTreeViewItem<T, E>\n key={item.id}\n depth={\n item.id === activeId && projected ? projected.depth : item.depth\n }\n indentationWidth={indentationWidth}\n item={item}\n isLast={false}\n parent={flattenItems.find((i) => i.id === item.parentId) ?? null}\n id={item.id}\n trails={trails[item.id]}\n keepGhostInPlace={item.id === ACTIVE_PLACEHOLDER_ID}\n TreeItemComponent={\n TreeItemComponent === undefined\n ? (TreeViewTextItem as TreeItemComponent<T, E>)\n : TreeItemComponent\n }\n onCollapse={() => handleToggleCollapse(item.id)}\n onItemsChanged={(newItems, itemChangedReason) =>\n onItemsChanged(buildTree(newItems), itemChangedReason)\n }\n items={flattenItems}\n tabIndex={item.id === rowIdWithFocus ? 0 : -1}\n onFocus={() => setFocusedRowId(item.id)}\n shouldDisableSorting={item.isSortable === false}\n />\n ))}\n </ol>\n {/* Portal is used to show the item the user drags */}\n {createPortal(\n <DragOverlay dropAnimation={dropAnimationConfig}></DragOverlay>,\n document.body,\n )}\n </SortableContext>\n </DndContext>\n );\n};\n\nconst TreeViewComponents = {\n SortableTreeViewItem,\n TreeItemWrapper,\n TreeViewTextItem,\n};\n\nexport const TreeView = Object.assign(TreeViewComponent, TreeViewComponents);\n"]}
|
|
1
|
+
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../src/tree-view/TreeView.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,aAAa,EACb,oBAAoB,EACpB,UAAU,EAIV,WAAW,EAGX,cAAc,EACd,iBAAiB,EACjB,aAAa,EAEb,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,eAAe,EACf,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AAOnF,OAAO,EACL,SAAS,EACT,WAAW,EACX,aAAa,EACb,gBAAgB,EAEhB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB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,EAErC,WAAW,EACT,IAAI,CAAC,EAAE,KAAK,qBAAqB;gCAC/B,CAAC,CAAC,SAAS;gCACX,CAAC,CAAC,MAAA,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,0CAAE,OAAO,EAEpC,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC7C,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EACvC,oBAAoB,EAAE,IAAI,CAAC,UAAU,KAAK,KAAK,IApC1C,IAAI,CAAC,EAAE,CAqCZ,CACH,CAAA;qBAAA,CAAC,IACC,EAEJ,YAAY,CACX,KAAC,WAAW,IAAC,aAAa,EAAE,mBAAmB,GAAgB,EAC/D,QAAQ,CAAC,IAAI,CACd,IACe,GACP,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACzB,oBAAoB;IACpB,eAAe;IACf,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,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 */\nimport {\n type Announcements,\n closestCenter,\n defaultDropAnimation,\n DndContext,\n type DragEndEvent,\n type DragMoveEvent,\n type DragOverEvent,\n DragOverlay,\n type DragStartEvent,\n type DropAnimation,\n KeyboardSensor,\n MeasuringStrategy,\n PointerSensor,\n type UniqueIdentifier,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {\n arrayMove,\n SortableContext,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\nimport type React from 'react';\nimport { useCallback, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { type HtmlAttributes } from '../_common/types';\nimport { sortableTreeKeyboardCoordinates } from './tree-view-keyboard-coordinates';\nimport {\n type FlattenedTreeItem,\n type ItemChangedReason,\n type TreeItem,\n type TreeItemComponent,\n} from './tree-view-types';\nimport {\n buildTree,\n flattenTree,\n getProjection,\n removeChildrenOf,\n type SensorContext,\n transformToString,\n} from './tree-view-utils';\nimport { TreeItemWrapper } from './TreeItemWrapper';\nimport { SortableTreeViewItem } from './TreeViewItem';\nimport { TreeViewTextItem } from './TreeViewTextItem';\n\nconst indentationWidth = 20;\nconst ACTIVE_PLACEHOLDER_ID = 'ndl-active-tree-item';\n\nconst dropAnimationConfig: DropAnimation = {\n easing: 'ease-out',\n keyframes({ transform }) {\n return [\n {\n opacity: 1,\n transform: transformToString(transform.initial),\n },\n {\n opacity: 0,\n transform: transformToString({\n ...transform.final,\n y: transform.final.y + 5,\n x: transform.final.x + 5,\n }),\n },\n ];\n },\n sideEffects({ active }) {\n active.node.animate([{ opacity: 0 }, { opacity: 1 }], {\n duration: defaultDropAnimation.duration,\n easing: defaultDropAnimation.easing,\n });\n },\n};\n\nexport interface TreeViewProps<\n T extends Record<string, unknown>,\n E extends HTMLElement,\n> extends React.HTMLAttributes<HTMLOListElement> {\n /** The items to be displayed in the tree view */\n items: TreeItem<T>[];\n /** A function that is called when the items in the tree view change */\n onItemsChanged: (\n newItems: TreeItem<T>[],\n itemChangedReason: ItemChangedReason<T>,\n ) => void;\n /** The component to use for the tree items, if not provided the default component will be used */\n TreeItemComponent?: TreeItemComponent<T, E>;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'ol'>;\n}\n\nconst TreeViewComponent = function TreeView<\n T extends Record<string, unknown>,\n E extends HTMLElement,\n>({\n items,\n TreeItemComponent,\n onItemsChanged,\n htmlAttributes,\n ...restProps\n}: TreeViewProps<T, E>) {\n const flattenItems = useMemo(() => flattenTree(items), [items]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const [overId, setOverId] = useState<UniqueIdentifier | null>(null);\n const [focusedRowId, setFocusedRowId] = useState<UniqueIdentifier | null>(\n null,\n );\n\n const [currentPosition, setCurrentPosition] = useState<{\n parentId: UniqueIdentifier | null;\n overId: UniqueIdentifier;\n } | null>(null);\n const [offsetLeft, setOffsetLeft] = useState(0);\n\n /* ------------------------------ Setup of Data ------------------------------ */\n\n const flattenedAndRemovedCollapsedItems = useMemo(() => {\n const collapsedItemsIds = flattenItems\n .filter((item) => item.canHaveSubItems && item.isCollapsed)\n .map((item) => item.id);\n\n return removeChildrenOf(\n [...flattenItems],\n activeId !== null ? [activeId, ...collapsedItemsIds] : collapsedItemsIds,\n );\n }, [activeId, flattenItems]);\n\n const activeItem = useMemo(\n () => (activeId ? flattenItems.find(({ id }) => id === activeId) : null),\n [activeId, flattenItems],\n );\n\n const flattenedAndRemovedCollapsedItemsWithActive = useMemo(() => {\n const collapsedItems = flattenItems.reduce<UniqueIdentifier[]>(\n (acc, item) => {\n if (item.canHaveSubItems && item.isCollapsed) {\n return [...acc, item.id];\n }\n return acc;\n },\n [],\n );\n\n const ItemsWithCollapsedRemoved = removeChildrenOf(\n flattenItems,\n activeId ? [activeId, ...collapsedItems] : collapsedItems,\n );\n const newArray: FlattenedTreeItem<T>[] = [];\n for (const item of ItemsWithCollapsedRemoved) {\n newArray.push(item);\n if (item.id === activeId) {\n newArray.push({\n ...item,\n id: ACTIVE_PLACEHOLDER_ID,\n });\n }\n }\n\n return newArray;\n }, [flattenItems, activeId]);\n\n if (activeItem?.canHaveSubItems && !activeItem?.isCollapsed) {\n flattenedAndRemovedCollapsedItems.push({\n ...activeItem,\n id: ACTIVE_PLACEHOLDER_ID,\n });\n }\n\n const sensorContext: SensorContext<T> = useRef({\n items: flattenedAndRemovedCollapsedItemsWithActive,\n offset: offsetLeft,\n });\n\n const coordinateGetter = useMemo(() => {\n sensorContext.current.items = flattenedAndRemovedCollapsedItemsWithActive;\n sensorContext.current.offset = offsetLeft;\n\n return sortableTreeKeyboardCoordinates<T>(\n sensorContext,\n true,\n indentationWidth,\n );\n }, [flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: coordinateGetter,\n }),\n );\n\n const projected = useMemo(\n () =>\n activeId && overId\n ? getProjection(\n flattenedAndRemovedCollapsedItemsWithActive,\n activeId,\n overId,\n offsetLeft,\n indentationWidth,\n )\n : null,\n [activeId, overId, flattenedAndRemovedCollapsedItemsWithActive, offsetLeft],\n );\n\n const hasSelectableItems = useMemo(\n () => flattenItems.some((item) => item.isSelected !== undefined),\n [flattenItems],\n );\n\n const itemAriaData = useMemo(() => {\n const visibleItems = flattenedAndRemovedCollapsedItemsWithActive.filter(\n (item) => item.id !== ACTIVE_PLACEHOLDER_ID,\n );\n\n return visibleItems.reduce<\n Record<UniqueIdentifier, { posInSet: number; setSize: number }>\n >((acc, item) => {\n const siblings = visibleItems.filter(\n (sibling) => sibling.parentId === item.parentId,\n );\n\n acc[item.id] = {\n posInSet: siblings.findIndex((sibling) => sibling.id === item.id) + 1,\n setSize: siblings.length,\n };\n\n return acc;\n }, {});\n }, [flattenedAndRemovedCollapsedItemsWithActive]);\n\n /* ------------------------------ Handlers ------------------------------ */\n function handleDragStart({ active }: DragStartEvent) {\n const activeId = active.id;\n setActiveId(activeId);\n setOverId(activeId);\n\n const activeItem = flattenItems.find(({ id }) => id === activeId);\n if (activeItem) {\n setCurrentPosition({\n overId: activeId,\n parentId: activeItem.parentId,\n });\n }\n\n document.body.style.setProperty('cursor', 'grabbing');\n }\n\n function handleDragMove({ delta }: DragMoveEvent) {\n setOffsetLeft(delta.x);\n }\n\n function handleDragOver({ over }: DragOverEvent) {\n setOverId(over?.id ?? null);\n }\n\n function resetState() {\n setOverId(null);\n setActiveId(null);\n setOffsetLeft(0);\n setCurrentPosition(null);\n\n document.body.style.setProperty('cursor', '');\n }\n\n const handleDragEnd = useCallback(\n (event: DragEndEvent) => {\n const { active, over } = event;\n resetState();\n let overIndex = flattenItems.findIndex((item) => item.id === over?.id);\n\n if (over?.id === ACTIVE_PLACEHOLDER_ID) {\n overIndex = flattenItems.findIndex((item) => item.id === active.id);\n }\n if (projected && over) {\n const { depth, parentId } = projected;\n const clonedItems: FlattenedTreeItem<T>[] = [...flattenItems];\n\n const parentIndex = clonedItems.findIndex(\n (item) => item.id === parentId,\n );\n const activeIndex = clonedItems.findIndex(({ id }) => id === active.id);\n const activeTreeItem = clonedItems[activeIndex];\n\n clonedItems[activeIndex] = { ...activeTreeItem, depth, parentId };\n const parentItem = clonedItems[parentIndex];\n if (parentItem && parentItem.canHaveSubItems) {\n clonedItems[parentIndex] = { ...parentItem, isCollapsed: false };\n }\n const newItems = buildTree(\n arrayMove(clonedItems, activeIndex, overIndex),\n );\n\n onItemsChanged(newItems, {\n item: activeTreeItem,\n reason: 'dropped',\n });\n }\n },\n [flattenItems, onItemsChanged, projected],\n );\n\n function handleToggleCollapse(id: UniqueIdentifier) {\n const item = flattenItems.find((item) => item.id === id);\n if (!item || item.canHaveSubItems !== true) {\n return;\n }\n\n onItemsChanged(\n buildTree(\n flattenItems.map((item) => {\n if (item.id === id && item.canHaveSubItems === true) {\n return { ...item, isCollapsed: !item.isCollapsed };\n }\n return item;\n }),\n ),\n {\n item,\n reason: item.isCollapsed ? 'expanded' : 'collapsed',\n },\n );\n }\n\n function handleDragCancel() {\n resetState();\n }\n\n /* ------------------------------ Keyboard functions ------------------------------ */\n const getMovementAnnouncement = (\n eventName: string,\n activeId: UniqueIdentifier,\n overId?: UniqueIdentifier,\n ) => {\n if (overId && projected) {\n if (eventName !== 'onDragEnd') {\n if (\n currentPosition &&\n projected.parentId === currentPosition.parentId &&\n overId === currentPosition.overId\n ) {\n return;\n } else {\n setCurrentPosition({\n overId,\n parentId: projected.parentId,\n });\n }\n }\n\n const clonedItems: FlattenedTreeItem<T>[] = [\n ...flattenedAndRemovedCollapsedItemsWithActive,\n ];\n const overIndex = clonedItems.findIndex(({ id }) => id === overId);\n const activeIndex = clonedItems.findIndex(({ id }) => id === activeId);\n const sortedItems = arrayMove(clonedItems, activeIndex, overIndex);\n\n const previousItem = sortedItems[overIndex - 1];\n\n let announcement;\n const movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';\n const nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';\n\n if (!previousItem) {\n const nextItem = sortedItems[overIndex + 1];\n announcement = `${activeId} was ${movedVerb} before ${nextItem.id}.`;\n } else {\n if (projected.depth > previousItem.depth) {\n announcement = `${activeId} was ${nestedVerb} under ${previousItem.id}.`;\n } else {\n let previousSibling: FlattenedTreeItem<T> | undefined = previousItem;\n while (previousSibling && projected.depth < previousSibling.depth) {\n const parentId: UniqueIdentifier | null = previousSibling.parentId;\n previousSibling = sortedItems.find(({ id }) => id === parentId);\n }\n\n if (previousSibling) {\n announcement = `${activeId} was ${movedVerb} after ${previousSibling.id}.`;\n }\n }\n }\n\n return announcement;\n }\n\n return;\n };\n\n const announcements: Announcements = {\n onDragCancel({ active }) {\n return `Moving was cancelled. ${active.id} was dropped in its original position.`;\n },\n onDragEnd({ active, over }) {\n return getMovementAnnouncement('onDragEnd', active.id, over?.id);\n },\n onDragMove({ active, over }) {\n return getMovementAnnouncement('onDragMove', active.id, over?.id);\n },\n onDragOver({ active, over }) {\n return getMovementAnnouncement('onDragOver', active.id, over?.id);\n },\n onDragStart({ active }) {\n return `Picked up ${active.id}.`;\n },\n };\n /* ------------------------------ Visual ------------------------------ */\n function getTrailList() {\n const trails: Record<\n UniqueIdentifier,\n ('none' | 'straight' | 'straight-curved' | 'curved')[]\n > = {};\n // Loop through the items in reverse\n [...flattenedAndRemovedCollapsedItemsWithActive]\n .reverse()\n .forEach((item, itemIndex, reversedList) => {\n const trailList: (\n | 'none'\n | 'straight'\n | 'straight-curved'\n | 'curved'\n )[] = [];\n const nextItem = reversedList[itemIndex - 1];\n // Loop through the depth of the item\n\n for (let trailDepth = 0; trailDepth < item.depth; trailDepth++) {\n // Not closest to the item so should be straight or none\n if (trailDepth < item.depth - 1) {\n if (nextItem === undefined) {\n trailList.push('none');\n continue;\n } else if (trails[nextItem?.id][trailDepth] === 'none') {\n trailList.push('none');\n continue;\n } else if (nextItem && nextItem.depth <= trailDepth) {\n trailList.push('none');\n continue;\n }\n trailList.push('straight');\n } else {\n if (\n (nextItem && trails[nextItem?.id][trailDepth] === 'none') ||\n nextItem === undefined ||\n nextItem.depth <= trailDepth\n ) {\n trailList.push('curved');\n } else {\n trailList.push('straight-curved');\n }\n }\n }\n trails[item.id] = trailList;\n });\n return trails;\n }\n\n const measuring = {\n droppable: {\n strategy: MeasuringStrategy.Always,\n },\n };\n\n const trails = getTrailList();\n const rowIdWithFocus =\n focusedRowId ?? flattenedAndRemovedCollapsedItemsWithActive[0]?.id;\n return (\n <DndContext\n accessibility={{ announcements }}\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={handleDragEnd}\n onDragStart={handleDragStart}\n onDragMove={handleDragMove}\n onDragOver={handleDragOver}\n onDragCancel={handleDragCancel}\n measuring={measuring}\n >\n <SortableContext\n items={flattenedAndRemovedCollapsedItemsWithActive.map(\n (item) => item.id,\n )}\n strategy={verticalListSortingStrategy}\n >\n <ol\n className=\"ndl-tree-view-list\"\n role=\"tree\"\n aria-multiselectable={hasSelectableItems ? true : undefined}\n {...restProps}\n {...htmlAttributes}\n >\n {flattenedAndRemovedCollapsedItemsWithActive.map((item) => (\n <SortableTreeViewItem<T, E>\n key={item.id}\n depth={\n item.id === activeId && projected ? projected.depth : item.depth\n }\n indentationWidth={indentationWidth}\n item={item}\n isLast={false}\n parent={flattenItems.find((i) => i.id === item.parentId) ?? null}\n id={item.id}\n trails={trails[item.id]}\n keepGhostInPlace={item.id === ACTIVE_PLACEHOLDER_ID}\n TreeItemComponent={\n TreeItemComponent === undefined\n ? (TreeViewTextItem as TreeItemComponent<T, E>)\n : TreeItemComponent\n }\n onCollapse={() => handleToggleCollapse(item.id)}\n onItemsChanged={(newItems, itemChangedReason) =>\n onItemsChanged(buildTree(newItems), itemChangedReason)\n }\n items={flattenItems}\n ariaLevel={\n item.id === ACTIVE_PLACEHOLDER_ID ? undefined : item.depth + 1\n }\n ariaPosInSet={\n item.id === ACTIVE_PLACEHOLDER_ID\n ? undefined\n : itemAriaData[item.id]?.posInSet\n }\n ariaSetSize={\n item.id === ACTIVE_PLACEHOLDER_ID\n ? undefined\n : itemAriaData[item.id]?.setSize\n }\n tabIndex={item.id === rowIdWithFocus ? 0 : -1}\n onFocus={() => setFocusedRowId(item.id)}\n shouldDisableSorting={item.isSortable === false}\n />\n ))}\n </ol>\n {/* Portal is used to show the item the user drags */}\n {createPortal(\n <DragOverlay dropAnimation={dropAnimationConfig}></DragOverlay>,\n document.body,\n )}\n </SortableContext>\n </DndContext>\n );\n};\n\nconst TreeViewComponents = {\n SortableTreeViewItem,\n TreeItemWrapper,\n TreeViewTextItem,\n};\n\nexport const TreeView = Object.assign(TreeViewComponent, TreeViewComponents);\n"]}
|
|
@@ -39,7 +39,7 @@ const SortableTreeViewItemNotMemoized = function SortableTreeViewItem(_a) {
|
|
|
39
39
|
var { id, depth, isLast, TreeItemComponent, parent, shouldDisableSorting,
|
|
40
40
|
// need to destruct to avoid passing it to the component
|
|
41
41
|
// oxlint-disable-next-line no-unused-vars
|
|
42
|
-
sortableProps, keepGhostInPlace, item, onCollapse, trails, onItemsChanged, items, tabIndex, onFocus } = _a, restProps = __rest(_a, ["id", "depth", "isLast", "TreeItemComponent", "parent", "shouldDisableSorting", "sortableProps", "keepGhostInPlace", "item", "onCollapse", "trails", "onItemsChanged", "items", "tabIndex", "onFocus"]);
|
|
42
|
+
sortableProps, keepGhostInPlace, item, onCollapse, trails, onItemsChanged, items, ariaLevel, ariaPosInSet, ariaSetSize, tabIndex, onFocus } = _a, restProps = __rest(_a, ["id", "depth", "isLast", "TreeItemComponent", "parent", "shouldDisableSorting", "sortableProps", "keepGhostInPlace", "item", "onCollapse", "trails", "onItemsChanged", "items", "ariaLevel", "ariaPosInSet", "ariaSetSize", "tabIndex", "onFocus"]);
|
|
43
43
|
const { attributes, listeners, setNodeRef, transform, setActivatorNodeRef, transition, isDragging, isSorting, isOver, } = useSortable({
|
|
44
44
|
animateLayoutChanges,
|
|
45
45
|
id: id,
|
|
@@ -58,7 +58,7 @@ const SortableTreeViewItemNotMemoized = function SortableTreeViewItem(_a) {
|
|
|
58
58
|
}
|
|
59
59
|
return () => onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(item.id);
|
|
60
60
|
}, [item.id, onCollapse]);
|
|
61
|
-
return (_jsx(TreeItemComponent, Object.assign({ item: item, isOverParent: false }, restProps, { setActivatorNodeRef: setActivatorNodeRef, setNodeRef: setNodeRef, style: style, depth: depth, isGhost: keepGhostInPlace, shouldDisableInteraction: isSorting, isLastInParent: isLast, parent: parent, dragHandleProps: Object.assign(Object.assign({}, attributes), listeners), isIndicator: isDragging, onCollapse: localCollapse, onItemsChanged: onItemsChanged, items: items, shouldDisableSorting: shouldDisableSorting, isOver: isOver, trails: trails, tabIndex: tabIndex, onFocus: onFocus })));
|
|
61
|
+
return (_jsx(TreeItemComponent, Object.assign({ item: item, isOverParent: false }, restProps, { setActivatorNodeRef: setActivatorNodeRef, setNodeRef: setNodeRef, style: style, depth: depth, isGhost: keepGhostInPlace, shouldDisableInteraction: isSorting, isLastInParent: isLast, parent: parent, dragHandleProps: Object.assign(Object.assign({}, attributes), listeners), isIndicator: isDragging, onCollapse: localCollapse, onItemsChanged: onItemsChanged, items: items, ariaLevel: ariaLevel, ariaPosInSet: ariaPosInSet, ariaSetSize: ariaSetSize, shouldDisableSorting: shouldDisableSorting, isOver: isOver, trails: trails, tabIndex: tabIndex, onFocus: onFocus })));
|
|
62
62
|
};
|
|
63
63
|
export const SortableTreeViewItem = React.memo(SortableTreeViewItemNotMemoized);
|
|
64
64
|
//# sourceMappingURL=TreeViewItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeViewItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAqBA,OAAO,EAEL,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,EAAsB,OAAO,EAAE,MAAM,OAAO,CAAC;AAO3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA+BtD,MAAM,oBAAoB,GAAyB,CAAC,EAClD,SAAS,EACT,UAAU,GACX,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeViewItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAqBA,OAAO,EAEL,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,EAAsB,OAAO,EAAE,MAAM,OAAO,CAAC;AAO3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA+BtD,MAAM,oBAAoB,GAAyB,CAAC,EAClD,SAAS,EACT,UAAU,GACX,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAgC/C,MAAM,+BAA+B,GAAG,SAAS,oBAAoB,CAGnE,EAsB4B;QAtB5B,EACA,EAAE,EACF,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,MAAM,EACN,o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AAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,eAAe,kCACV,UAAU,GACV,SAAS,GAEd,WAAW,EAAE,UAAU,EACvB,UAAU,EAAE,aAAa,EACzB,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,IAChB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAC5C,+BAA+B,CACU,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 */\nimport { type UniqueIdentifier } from '@dnd-kit/core';\nimport {\n type AnimateLayoutChanges,\n useSortable,\n type UseSortableArguments,\n} from '@dnd-kit/sortable';\nimport React, { type CSSProperties, useMemo } from 'react';\n\nimport {\n type FlattenedTreeItem,\n type ItemChangedReason,\n type TreeItemComponent,\n} from './tree-view-types';\nimport { transformToString } from './tree-view-utils';\n\nexport interface TreeItemProps<T> {\n /** Number of child items */\n childCount?: number;\n /** Whether this is a clone item */\n clone?: boolean;\n /** Whether the item is collapsed */\n collapsed?: boolean;\n /** Depth of the item in the tree */\n depth: number;\n /** Whether interaction should be disabled */\n shouldDisableInteraction?: boolean;\n /** Whether this is an indicator item */\n indicator?: boolean;\n /** Width of the indentation */\n indentationWidth: number;\n /** The tree item data */\n item: FlattenedTreeItem<T>;\n /** Whether this is the last item in its parent */\n isLast: boolean;\n /** Parent item of this item */\n parent: FlattenedTreeItem<T> | null;\n /** Function to call when item is collapsed */\n onCollapse?(id: UniqueIdentifier): void;\n /** Function to call when item is removed */\n onRemove?(id: UniqueIdentifier): void;\n /** Function to set the wrapper ref */\n wrapperRef?(node: HTMLLIElement): void;\n}\n\nconst animateLayoutChanges: AnimateLayoutChanges = ({\n isSorting,\n isDragging,\n}) => (isSorting || isDragging ? false : true);\n\ntype SortableTreeItemProps<\n T extends Record<string, unknown>,\n E extends HTMLElement,\n> = TreeItemProps<T> & {\n id: UniqueIdentifier;\n /** The component to use for rendering the tree item */\n TreeItemComponent: TreeItemComponent<T, E>;\n /** Whether sorting should be disabled for this item */\n shouldDisableSorting?: boolean;\n /** Props for the sortable functionality */\n sortableProps?: Omit<UseSortableArguments, 'id'>;\n /** Whether to keep the ghost item in place while dragging */\n keepGhostInPlace?: boolean;\n /** A list of trails to render before the item */\n trails: ('none' | 'straight' | 'straight-curved' | 'curved')[];\n /** Function to call when the item has changed */\n onItemsChanged: (\n newItems: FlattenedTreeItem<T>[],\n itemChangedReason: ItemChangedReason<T>,\n ) => void;\n /** All items in the tree */\n items: FlattenedTreeItem<T>[];\n ariaLevel?: number;\n ariaPosInSet?: number;\n ariaSetSize?: number;\n tabIndex?: number;\n /** Function to call when the item receives focus */\n onFocus?: () => void;\n};\n\nconst SortableTreeViewItemNotMemoized = function SortableTreeViewItem<\n T extends Record<string, unknown>,\n E extends HTMLElement,\n>({\n id,\n depth,\n isLast,\n TreeItemComponent,\n parent,\n shouldDisableSorting,\n // need to destruct to avoid passing it to the component\n // oxlint-disable-next-line no-unused-vars\n sortableProps,\n keepGhostInPlace,\n item,\n onCollapse,\n trails,\n onItemsChanged,\n items,\n ariaLevel,\n ariaPosInSet,\n ariaSetSize,\n tabIndex,\n onFocus,\n ...restProps\n}: SortableTreeItemProps<T, E>) {\n const {\n attributes,\n listeners,\n setNodeRef,\n transform,\n setActivatorNodeRef,\n transition,\n isDragging,\n isSorting,\n isOver,\n } = useSortable({\n animateLayoutChanges,\n id: id,\n transition: {\n duration: 150, // milliseconds\n easing: 'cubic-bezier(0.25, 1, 0.5, 1)',\n },\n });\n\n const style: CSSProperties = {\n transform: transform ? transformToString(transform) : undefined,\n transition: transition ?? undefined,\n };\n const localCollapse = useMemo(() => {\n if (!onCollapse) {\n return undefined;\n }\n return () => onCollapse?.(item.id);\n }, [item.id, onCollapse]);\n\n return (\n <TreeItemComponent\n item={item}\n isOverParent={false}\n {...restProps}\n setActivatorNodeRef={setActivatorNodeRef}\n setNodeRef={setNodeRef}\n style={style}\n depth={depth}\n isGhost={keepGhostInPlace}\n shouldDisableInteraction={isSorting}\n isLastInParent={isLast}\n parent={parent}\n dragHandleProps={{\n ...attributes,\n ...listeners,\n }}\n isIndicator={isDragging}\n onCollapse={localCollapse}\n onItemsChanged={onItemsChanged}\n items={items}\n ariaLevel={ariaLevel}\n ariaPosInSet={ariaPosInSet}\n ariaSetSize={ariaSetSize}\n shouldDisableSorting={shouldDisableSorting}\n isOver={isOver}\n trails={trails}\n tabIndex={tabIndex}\n onFocus={onFocus}\n />\n );\n};\n\nexport const SortableTreeViewItem = React.memo(\n SortableTreeViewItemNotMemoized,\n) as typeof SortableTreeViewItemNotMemoized;\n"]}
|
|
@@ -78,7 +78,7 @@ export const TreeViewTextItem = (_a) => {
|
|
|
78
78
|
: false;
|
|
79
79
|
return (_jsxs(TreeItemWrapper, Object.assign({ depth: depth, shouldDisableInteraction: shouldDisableInteraction, shouldDisableSorting: shouldDisableSorting, isGhost: isGhost, indentationWidth: indentationWidth, isIndicator: isIndicator, isCollapsed: isCollapsed, onCollapse: onCollapse, item: item, parent: parent, isOver: isOver, isOverParent: isOverParent, setNodeRef: setNodeRef, setActivatorNodeRef: setActivatorNodeRef, dragHandleProps: dragHandleProps, style: style, trails: trails,
|
|
80
80
|
// oxlint-disable-next-line @typescript-eslint/no-empty-function
|
|
81
|
-
onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && (_jsxs("button", { type: "button", className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true',
|
|
81
|
+
onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && (_jsxs("button", { type: "button", className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true',
|
|
82
82
|
/**
|
|
83
83
|
* Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab
|
|
84
84
|
* since we use the arrow keys instead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAsBA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CACjC,IAAqC,EACrC,KAAwC,EAC/B,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,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rC,MAAM,CAAC,IAAI,KATP,KAAK,CAUM,CACnB,CAAC;oBACJ,CAAC,CAAC,GACA,KACU,CACnB,CAAC;AACJ,CAAC,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 */\nimport type React from 'react';\n\nimport { Checkbox } from '../checkbox';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { ChevronDownIconOutline, ChevronRightIconOutline } from '../icons';\nimport { Skeleton } from '../skeleton';\nimport { Typography } from '../typography';\nimport {\n type FlattenedTreeItem,\n type TextItemData,\n type TreeItemComponentProps,\n} from './tree-view-types';\nimport { TreeItemWrapper } from './TreeItemWrapper';\n\n/**\n * checks if any parent is checked\n * @param item\n * @param items\n * @returns\n */\nconst parentIsCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const parent = items.find((i) => i.id === item.parentId);\n if (parent) {\n if (parent.isSelected) {\n return true;\n }\n return parentIsCheckedRecursively(parent, items);\n }\n return false;\n};\n\n/**\n * checks if any children are checked\n * @param item\n * @param items\n * @returns\n */\nconst childrenCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const children = items.filter((i) => i.parentId === item.id);\n if (children.length === 0) {\n return false;\n }\n return children.some(\n (i) => i.isSelected || childrenCheckedRecursively(i, items),\n );\n};\n\nexport const TreeViewTextItem = <T extends TextItemData>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n indentationWidth,\n isIndicator,\n isCollapsed,\n onCollapse,\n item,\n parent,\n isOver,\n isOverParent,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n trails,\n onItemsChanged,\n items,\n tabIndex,\n ref,\n ...restProps\n}: TreeItemComponentProps<T> & { ref?: React.Ref<HTMLElement> }) => {\n const isAnyParentChecked = parentIsCheckedRecursively(item, items);\n const isAnyChildChecked = childrenCheckedRecursively(item, items);\n\n const isIndeterminate =\n isAnyChildChecked === true &&\n isAnyParentChecked === false &&\n item.isSelected === false\n ? true\n : false;\n\n return (\n <TreeItemWrapper\n depth={depth}\n shouldDisableInteraction={shouldDisableInteraction}\n shouldDisableSorting={shouldDisableSorting}\n isGhost={isGhost}\n indentationWidth={indentationWidth}\n isIndicator={isIndicator}\n isCollapsed={isCollapsed}\n onCollapse={onCollapse}\n item={item}\n parent={parent}\n isOver={isOver}\n isOverParent={isOverParent}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n dragHandleProps={dragHandleProps}\n style={style}\n trails={trails}\n // oxlint-disable-next-line @typescript-eslint/no-empty-function\n onItemsChanged={() => {}}\n ref={ref}\n items={items}\n tabIndex={tabIndex}\n {...restProps}\n >\n {item.canHaveSubItems && onCollapse && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-collapse-button\"\n onClick={() => onCollapse()}\n aria-label={item.isCollapsed ? 'Expand' : 'Collapse'}\n aria-expanded={item.isCollapsed ? 'false' : 'true'}\n aria-pressed={!item.isCollapsed}\n /**\n * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab\n * since we use the arrow keys instead\n */\n tabIndex={tabIndex}\n >\n {item.isCollapsed && <ChevronRightIconOutline className=\"ndl-icon\" />}\n {!item.isCollapsed && <ChevronDownIconOutline className=\"ndl-icon\" />}\n </button>\n )}\n {item.isSelected !== undefined && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <Checkbox\n isIndeterminate={isIndeterminate}\n isChecked={item.isSelected}\n ariaLabel={item.data.text}\n htmlAttributes={{\n tabIndex,\n }}\n onChange={(event) => {\n const newItems = items.map((i) => {\n if (i.id === item.id) {\n return {\n ...i,\n isSelected: event.target.checked,\n };\n }\n return i;\n });\n\n // Uncheck parents if a child is unchecked\n if (!event.target.checked) {\n let parentId = item.parentId;\n while (parentId !== null) {\n const parent = newItems.find(\n (newItem) => newItem.id === parentId,\n );\n if (parent) {\n newItems.forEach((newItem) => {\n if (newItem.id === parent.id) {\n newItem.isSelected = false;\n }\n });\n parentId = parent.parentId;\n } else {\n parentId = null;\n }\n }\n }\n // Check children if a parent is checked\n if (item.canHaveSubItems) {\n const childIdsToUncheck = items\n .filter((i) => i.parentId === item.id)\n .map((i) => i.id);\n while (childIdsToUncheck.length > 0) {\n const childId = childIdsToUncheck.pop();\n const child = items.find((i) => i.id === childId);\n if (child) {\n newItems.forEach((newItem) => {\n if (newItem.id === child.id) {\n newItem.isSelected = event.target.checked;\n }\n });\n newItems\n .filter((i) => i.parentId === child.id)\n .forEach((i) => {\n childIdsToUncheck.push(i.id);\n });\n }\n }\n }\n onItemsChanged(newItems, { item, reason: 'selected' });\n }}\n aria-label={item.data.text}\n />\n </Skeleton>\n )}\n\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n height=\"20px\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <ConditionalWrap\n shouldWrap={item.data.onTextClick !== undefined}\n wrap={(children) => (\n <button\n type=\"button\"\n onClick={item.data.onTextClick}\n className=\"ndl-tree-view-text-clickable\"\n tabIndex={tabIndex}\n >\n {children}\n </button>\n )}\n >\n <Typography\n variant={item.canHaveSubItems ? 'subheading-small' : 'body-medium'}\n htmlAttributes={{\n style: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n }}\n >\n {item.data.text}\n </Typography>\n </ConditionalWrap>\n </Skeleton>\n <div className=\"ndl-tree-view-actions\">\n {item.data.actions &&\n item.data.actions.map((action, index) => {\n return (\n <CleanIconButton\n key={index}\n className=\"ndl-tree-view-action\"\n size=\"small\"\n {...action.buttonProps}\n htmlAttributes={{\n tabIndex,\n ...action.buttonProps.htmlAttributes,\n }}\n >\n {action.icon}\n </CleanIconButton>\n );\n })}\n </div>\n </TreeItemWrapper>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAsBA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CACjC,IAAqC,EACrC,KAAwC,EAC/B,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,0BAA0B,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAE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jC,KAAC,eAAe,IACd,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,EAC/C,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAClB,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAC9B,SAAS,EAAC,8BAA8B,EACxC,QAAQ,EAAE,QAAQ,YAEjB,QAAQ,GACF,CACV,YAED,KAAC,UAAU,IACT,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,EAClE,cAAc,EAAE;4BACd,KAAK,EAAE;gCACL,QAAQ,EAAE,QAAQ;gCAClB,YAAY,EAAE,UAAU;gCACxB,UAAU,EAAE,QAAQ;6BACrB;yBACF,YAEA,IAAI,CAAC,IAAI,CAAC,IAAI,GACJ,GACG,IACT,EACX,cAAK,SAAS,EAAC,uBAAuB,YACnC,IAAI,CAAC,IAAI,CAAC,OAAO;oBAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;wBACtC,OAAO,CACL,KAAC,eAAe,kBAEd,SAAS,EAAC,sBAAsB,EAChC,IAAI,EAAC,OAAO,IACR,MAAM,CAAC,WAAW,IACtB,cAAc,kBACZ,QAAQ,IACL,MAAM,CAAC,WAAW,CAAC,cAAc,aAGrC,MAAM,CAAC,IAAI,KATP,KAAK,CAUM,CACnB,CAAC;oBACJ,CAAC,CAAC,GACA,KACU,CACnB,CAAC;AACJ,CAAC,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 */\nimport type React from 'react';\n\nimport { Checkbox } from '../checkbox';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { ChevronDownIconOutline, ChevronRightIconOutline } from '../icons';\nimport { Skeleton } from '../skeleton';\nimport { Typography } from '../typography';\nimport {\n type FlattenedTreeItem,\n type TextItemData,\n type TreeItemComponentProps,\n} from './tree-view-types';\nimport { TreeItemWrapper } from './TreeItemWrapper';\n\n/**\n * checks if any parent is checked\n * @param item\n * @param items\n * @returns\n */\nconst parentIsCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const parent = items.find((i) => i.id === item.parentId);\n if (parent) {\n if (parent.isSelected) {\n return true;\n }\n return parentIsCheckedRecursively(parent, items);\n }\n return false;\n};\n\n/**\n * checks if any children are checked\n * @param item\n * @param items\n * @returns\n */\nconst childrenCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const children = items.filter((i) => i.parentId === item.id);\n if (children.length === 0) {\n return false;\n }\n return children.some(\n (i) => i.isSelected || childrenCheckedRecursively(i, items),\n );\n};\n\nexport const TreeViewTextItem = <T extends TextItemData>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n indentationWidth,\n isIndicator,\n isCollapsed,\n onCollapse,\n item,\n parent,\n isOver,\n isOverParent,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n trails,\n onItemsChanged,\n items,\n tabIndex,\n ref,\n ...restProps\n}: TreeItemComponentProps<T> & { ref?: React.Ref<HTMLElement> }) => {\n const isAnyParentChecked = parentIsCheckedRecursively(item, items);\n const isAnyChildChecked = childrenCheckedRecursively(item, items);\n\n const isIndeterminate =\n isAnyChildChecked === true &&\n isAnyParentChecked === false &&\n item.isSelected === false\n ? true\n : false;\n\n return (\n <TreeItemWrapper\n depth={depth}\n shouldDisableInteraction={shouldDisableInteraction}\n shouldDisableSorting={shouldDisableSorting}\n isGhost={isGhost}\n indentationWidth={indentationWidth}\n isIndicator={isIndicator}\n isCollapsed={isCollapsed}\n onCollapse={onCollapse}\n item={item}\n parent={parent}\n isOver={isOver}\n isOverParent={isOverParent}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n dragHandleProps={dragHandleProps}\n style={style}\n trails={trails}\n // oxlint-disable-next-line @typescript-eslint/no-empty-function\n onItemsChanged={() => {}}\n ref={ref}\n items={items}\n tabIndex={tabIndex}\n {...restProps}\n >\n {item.canHaveSubItems && onCollapse && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-collapse-button\"\n onClick={() => onCollapse()}\n aria-label={item.isCollapsed ? 'Expand' : 'Collapse'}\n aria-expanded={item.isCollapsed ? 'false' : 'true'}\n /**\n * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab\n * since we use the arrow keys instead\n */\n tabIndex={tabIndex}\n >\n {item.isCollapsed && <ChevronRightIconOutline className=\"ndl-icon\" />}\n {!item.isCollapsed && <ChevronDownIconOutline className=\"ndl-icon\" />}\n </button>\n )}\n {item.isSelected !== undefined && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <Checkbox\n isIndeterminate={isIndeterminate}\n isChecked={item.isSelected}\n ariaLabel={item.data.text}\n htmlAttributes={{\n tabIndex,\n }}\n onChange={(event) => {\n const newItems = items.map((i) => {\n if (i.id === item.id) {\n return {\n ...i,\n isSelected: event.target.checked,\n };\n }\n return i;\n });\n\n // Uncheck parents if a child is unchecked\n if (!event.target.checked) {\n let parentId = item.parentId;\n while (parentId !== null) {\n const parent = newItems.find(\n (newItem) => newItem.id === parentId,\n );\n if (parent) {\n newItems.forEach((newItem) => {\n if (newItem.id === parent.id) {\n newItem.isSelected = false;\n }\n });\n parentId = parent.parentId;\n } else {\n parentId = null;\n }\n }\n }\n // Check children if a parent is checked\n if (item.canHaveSubItems) {\n const childIdsToUncheck = items\n .filter((i) => i.parentId === item.id)\n .map((i) => i.id);\n while (childIdsToUncheck.length > 0) {\n const childId = childIdsToUncheck.pop();\n const child = items.find((i) => i.id === childId);\n if (child) {\n newItems.forEach((newItem) => {\n if (newItem.id === child.id) {\n newItem.isSelected = event.target.checked;\n }\n });\n newItems\n .filter((i) => i.parentId === child.id)\n .forEach((i) => {\n childIdsToUncheck.push(i.id);\n });\n }\n }\n }\n onItemsChanged(newItems, { item, reason: 'selected' });\n }}\n aria-label={item.data.text}\n />\n </Skeleton>\n )}\n\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n height=\"20px\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <ConditionalWrap\n shouldWrap={item.data.onTextClick !== undefined}\n wrap={(children) => (\n <button\n type=\"button\"\n onClick={item.data.onTextClick}\n className=\"ndl-tree-view-text-clickable\"\n tabIndex={tabIndex}\n >\n {children}\n </button>\n )}\n >\n <Typography\n variant={item.canHaveSubItems ? 'subheading-small' : 'body-medium'}\n htmlAttributes={{\n style: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n }}\n >\n {item.data.text}\n </Typography>\n </ConditionalWrap>\n </Skeleton>\n <div className=\"ndl-tree-view-actions\">\n {item.data.actions &&\n item.data.actions.map((action, index) => {\n return (\n <CleanIconButton\n key={index}\n className=\"ndl-tree-view-action\"\n size=\"small\"\n {...action.buttonProps}\n htmlAttributes={{\n tabIndex,\n ...action.buttonProps.htmlAttributes,\n }}\n >\n {action.icon}\n </CleanIconButton>\n );\n })}\n </div>\n </TreeItemWrapper>\n );\n};\n"]}
|