@neo4j-ndl/react 4.9.32 → 4.9.33

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.
Files changed (40) hide show
  1. package/lib/cjs/popover/Popover.js.map +1 -1
  2. package/lib/cjs/popover/use-popover.js +8 -7
  3. package/lib/cjs/popover/use-popover.js.map +1 -1
  4. package/lib/cjs/tree-view/TreeItemWrapper.js +3 -3
  5. package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
  6. package/lib/cjs/tree-view/TreeView.js +34 -6
  7. package/lib/cjs/tree-view/TreeView.js.map +1 -1
  8. package/lib/cjs/tree-view/TreeViewItem.js +2 -2
  9. package/lib/cjs/tree-view/TreeViewItem.js.map +1 -1
  10. package/lib/cjs/tree-view/TreeViewTextItem.js +1 -1
  11. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  12. package/lib/cjs/tree-view/stories/treeview-default.story.js +9 -9
  13. package/lib/cjs/tree-view/stories/treeview-default.story.js.map +1 -1
  14. package/lib/cjs/tree-view/tree-view-types.js.map +1 -1
  15. package/lib/esm/popover/Popover.js.map +1 -1
  16. package/lib/esm/popover/use-popover.js +8 -7
  17. package/lib/esm/popover/use-popover.js.map +1 -1
  18. package/lib/esm/tree-view/TreeItemWrapper.js +3 -3
  19. package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
  20. package/lib/esm/tree-view/TreeView.js +34 -6
  21. package/lib/esm/tree-view/TreeView.js.map +1 -1
  22. package/lib/esm/tree-view/TreeViewItem.js +2 -2
  23. package/lib/esm/tree-view/TreeViewItem.js.map +1 -1
  24. package/lib/esm/tree-view/TreeViewTextItem.js +1 -1
  25. package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
  26. package/lib/esm/tree-view/stories/treeview-default.story.js +9 -9
  27. package/lib/esm/tree-view/stories/treeview-default.story.js.map +1 -1
  28. package/lib/esm/tree-view/tree-view-types.js.map +1 -1
  29. package/lib/types/popover/Popover.d.ts +3 -1
  30. package/lib/types/popover/Popover.d.ts.map +1 -1
  31. package/lib/types/tree-view/TreeItemWrapper.d.ts +1 -1
  32. package/lib/types/tree-view/TreeItemWrapper.d.ts.map +1 -1
  33. package/lib/types/tree-view/TreeView.d.ts +6 -3
  34. package/lib/types/tree-view/TreeView.d.ts.map +1 -1
  35. package/lib/types/tree-view/TreeViewItem.d.ts +4 -1
  36. package/lib/types/tree-view/TreeViewItem.d.ts.map +1 -1
  37. package/lib/types/tree-view/TreeViewTextItem.d.ts.map +1 -1
  38. package/lib/types/tree-view/tree-view-types.d.ts +3 -0
  39. package/lib/types/tree-view/tree-view-types.d.ts.map +1 -1
  40. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/popover/Popover.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAM4B;AAC5B,4DAAoC;AACpC,kDAA0B;AAM1B,0DAAsD;AACtD,6DAA6D;AAC7D,0DAAwD;AACxD,+CAA2C;AAC3C,+EAA4E;AAgB/D,QAAA,oBAAoB,GAAwC;IACvE,yBAAyB,EAAE,WAAW;IACtC,oBAAoB,EAAE,YAAY;IAClC,0BAA0B,EAAE,QAAQ;IACpC,yBAAyB,EAAE,UAAU;IACrC,wBAAwB,EAAE,cAAc;IACxC,yBAAyB,EAAE,OAAO;IAClC,yBAAyB,EAAE,MAAM;IACjC,oBAAoB,EAAE,SAAS;IAC/B,mBAAmB,EAAE,aAAa;IAClC,0BAA0B,EAAE,KAAK;IACjC,wBAAwB,EAAE,WAAW;IACrC,mBAAmB,EAAE,YAAY;CAClC,CAAC;AA+CF,MAAM,cAAc,GAAG,eAAK,CAAC,aAAa,CAAc,IAAI,CAAC,CAAC;AAEvD,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAEjD,IAA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D;IACzD,IAAA,yDAA2B,GAAE,CAAC;IAE9B,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,uBAAC,kCAAe,IACd,UAAU,EAAE,OAAO,CAAC,UAAU,EAC9B,IAAI,EAAE,CAAC,YAAY,EAAE,EAAE;;YAAC,OAAA,CACtB,uBAAC,sBAAc,IACb,IAAI,EACF,CAAC,MAAA,OAAO,CAAC,2BAA2B,mCAAI,KAAK,CAAC;oBAC5C,CAAC,CAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAA8B;oBACxD,CAAC,CAAC,SAAS,YAGd,YAAY,GACE,CAClB,CAAA;SAAA,YAED,uBAAC,4BAAoB,IACnB,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,OAAO,CAAC,kBAAkB,EACjC,YAAY,EAAE,OAAO,CAAC,YAAY,YAElC,uBAAC,SAAS,kBACR,SAAS,EAAE,OAAO,qBACD,OAAO,CAAC,OAAO,sBACd,OAAO,CAAC,aAAa,EACvC,KAAK,gDACA,OAAO,CAAC,cAAc,GACtB,OAAO,CAAC,gBAAgB,GACxB,KAAK,GAEV,GAAG,EAAE,IAAI,IACL,OAAO,CAAC,gBAAgB,mBAAM,cAAc,EAAG,EAC/C,SAAS,cAEZ,QAAQ,IACC,GACS,GACP,CACnB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEM,0BAAO","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 FloatingFocusManager,\n FloatingPortal,\n type OffsetOptions,\n type Placement,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React from 'react';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme/ThemeProvider';\nimport { usePopover } from './use-popover';\nimport { usePatchFloatingFocusGuards } from './usePatchFloatingFocusGuards';\n\ntype PlacementOptions =\n | 'bottom-end-top-end'\n | 'bottom-start-top-start'\n | 'bottom-middle-top-middle'\n | 'top-end-bottom-end'\n | 'top-start-bottom-start'\n | 'top-middle-bottom-middle'\n | 'bottom-start-bottom-end'\n | 'top-start-top-end'\n | 'middle-start-middle-end'\n | 'bottom-end-bottom-start'\n | 'top-end-top-start'\n | 'middle-end-middle-start';\n\nexport const placementTranslation: Record<PlacementOptions, Placement> = {\n 'bottom-end-bottom-start': 'right-end',\n 'bottom-end-top-end': 'bottom-end',\n 'bottom-middle-top-middle': 'bottom',\n 'bottom-start-bottom-end': 'left-end',\n 'bottom-start-top-start': 'bottom-start',\n 'middle-end-middle-start': 'right',\n 'middle-start-middle-end': 'left',\n 'top-end-bottom-end': 'top-end',\n 'top-end-top-start': 'right-start',\n 'top-middle-bottom-middle': 'top',\n 'top-start-bottom-start': 'top-start',\n 'top-start-top-end': 'left-start',\n};\ntype PopoverProps = {\n /** if the popover is open */\n isOpen?: boolean;\n /** The content of the popover */\n children?: React.ReactNode;\n /**\n * Can be used if the anchor should be separated from the trigger.\n * Note: to visually separate the anchor from the trigger, use the Popover.Anchor component instead.\n */\n anchorElement?: Element | null;\n /** If the anchorPosition is provided the anchorElement will be ignored */\n anchorPosition?: {\n x: number;\n y: number;\n };\n /** The placement of the floating element is determined by two sets of words. The first set of words specifies the point on the anchor element where the floating element will be attached. The second set of coordinates specifies the point on the floating element that will attach to the anchor element.*/\n placement?: PlacementOptions;\n /** can take either a number, an object or a function. Full documentation here: https://floating-ui.com/docs/offset */\n offset?: OffsetOptions;\n /** Called when an internal state change is triggered, when the floating element either opens or closes. It is not called when `isOpen` is updated by the consumer. */\n onOpenChange?: (isOpen: boolean, event?: Event) => void;\n /** Use anchorEl for portal's container. Should be used if the popover is portaled and is inside a Dialog for example. */\n hasAnchorPortal?: boolean;\n /** If the popover should constrain the focus inside the popover while open */\n shouldCaptureFocus?: boolean;\n /** Which element to initially focus. **/\n initialFocus?: number | React.RefObject<HTMLElement | null>;\n /** The role of the popover */\n role?:\n | 'tooltip'\n | 'dialog'\n | 'alertdialog'\n | 'menu'\n | 'listbox'\n | 'grid'\n | 'tree';\n /** If the popover should close when the user clicks outside of it */\n closeOnClickOutside?: boolean;\n /** The strategy of the popover. Fixed should be used when the popover is inside a Dialog. */\n strategy?: 'fixed' | 'absolute';\n /** Whether the content is rendered in a portal */\n isPortaled?: boolean;\n};\n\ntype ContextType = ReturnType<typeof usePopover> | null;\n\nconst PopoverContext = React.createContext<ContextType>(null);\n\nexport const usePopoverContext = () => {\n const context = React.useContext(PopoverContext);\n\n if (context === null) {\n throw new Error('Popover components must be wrapped in <Popover />');\n }\n\n return context;\n};\n\nconst PopoverComponent = ({\n children,\n anchorElement,\n placement,\n isOpen,\n offset,\n anchorPosition,\n hasAnchorPortal: hasAnchorPortalProp,\n shouldCaptureFocus = false,\n initialFocus,\n onOpenChange,\n role,\n closeOnClickOutside = true,\n isPortaled: isPortaledProp,\n strategy: strategyProp,\n}: PopoverProps) => {\n const isInsideDialog = useIsInsideDialog();\n\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const hasAnchorPortal = isInsideDialog;\n const isPortaled = !isInsideDialog;\n\n const popover = usePopover({\n anchorElement: anchorElement,\n anchorElementAsPortalAnchor: hasAnchorPortalProp ?? hasAnchorPortal,\n anchorPosition,\n closeOnClickOutside,\n initialFocus,\n isOpen: isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n offsetOption: offset,\n onOpenChange: onOpenChange,\n placement: placement ? placementTranslation[placement] : undefined,\n role,\n shouldCaptureFocus: shouldCaptureFocus,\n strategy: strategyProp ?? strategy,\n });\n\n return (\n <PopoverContext.Provider value={popover}>\n {children}\n </PopoverContext.Provider>\n );\n};\n\ntype PopoverTriggerProps = {\n /** The content of the trigger */\n children: React.ReactNode;\n /** Whether the trigger should render a button element, or pass its props to the child element */\n hasButtonWrapper?: boolean;\n};\n\nconst PopoverTrigger = ({\n children,\n hasButtonWrapper = false,\n ref,\n ...props\n}: CommonProps<'button', PopoverTriggerProps>) => {\n const context = usePopoverContext();\n // Example from floating UI\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n // `hasButtonWrapper` allows the user to pass any element as the anchor\n if (hasButtonWrapper && React.isValidElement(children)) {\n return React.cloneElement(\n children,\n context.getReferenceProps({\n ...props,\n ...childrenProps,\n 'data-state': context.isOpen ? 'open' : 'closed',\n ref: mergedRefs,\n }),\n );\n }\n return (\n <button\n ref={context.refs.setReference}\n type=\"button\"\n data-state={context.isOpen ? 'open' : 'closed'}\n {...context.getReferenceProps(props)}\n >\n {children}\n </button>\n );\n};\n\ntype PopoverAnchorProps = {\n children?: React.ReactNode;\n};\n\n/**\n * Use this to separate the anchor visually from the trigger.\n */\nconst PopoverAnchor = ({\n children,\n ref,\n ...props\n}: CommonProps<'div', PopoverAnchorProps>) => {\n const context = usePopoverContext();\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any)?.props;\n const mergedRefs = useMergeRefs([\n context.refs.setPositionReference,\n ref,\n childrenProps?.ref,\n ]);\n\n if (React.isValidElement(children)) {\n return React.cloneElement(children, {\n ...props,\n ...childrenProps,\n ref: mergedRefs,\n });\n }\n\n return (\n <div ref={mergedRefs} {...props}>\n {children}\n </div>\n );\n};\n\ntype PopoverContentProps = {\n children: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n};\n\nconst PopoverContent = <T extends React.ElementType = 'div'>({\n as,\n className,\n style,\n children,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, PopoverContentProps>) => {\n const { context: floatingContext, ...context } = usePopoverContext();\n\n const refs = useMergeRefs([context.refs.setFloating, ref]);\n\n const { themeClassName } = useNeedleTheme();\n\n const classes = classNames('ndl-popover', themeClassName, className);\n const Component: React.ElementType = as ?? 'div';\n\n // Patch to not get axe errors for the focus guards\n // To be noted is that axe gives us a false positive error here since the focus guards directly pass focus to other elements\n // https://github.com/floating-ui/floating-ui/issues/2462\n usePatchFloatingFocusGuards();\n\n if (!floatingContext.open) {\n return null;\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => (\n <FloatingPortal\n root={\n (context.anchorElementAsPortalAnchor ?? false)\n ? (context.refs.reference.current as HTMLElement | null)\n : undefined\n }\n >\n {wrapChildren}\n </FloatingPortal>\n )}\n >\n <FloatingFocusManager\n context={floatingContext}\n modal={context.shouldCaptureFocus}\n initialFocus={context.initialFocus}\n >\n <Component\n className={classes}\n aria-labelledby={context.labelId}\n aria-describedby={context.descriptionId}\n style={{\n ...context.floatingStyles,\n ...context.transitionStyles,\n ...style,\n }}\n ref={refs}\n {...context.getFloatingProps({ ...htmlAttributes })}\n {...restProps}\n >\n {children}\n </Component>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\nconst Popover = Object.assign(PopoverComponent, {\n Anchor: PopoverAnchor,\n Content: PopoverContent,\n Trigger: PopoverTrigger,\n});\n\nexport { Popover };\n"]}
1
+ {"version":3,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AA,YAED,uBAAC,4BAAoB,IACnB,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,OAAO,CAAC,kBAAkB,EACjC,YAAY,EAAE,OAAO,CAAC,YAAY,YAElC,uBAAC,SAAS,kBACR,SAAS,EAAE,OAAO,qBACD,OAAO,CAAC,OAAO,sBACd,OAAO,CAAC,aAAa,EACvC,KAAK,gDACA,OAAO,CAAC,cAAc,GACtB,OAAO,CAAC,gBAAgB,GACxB,KAAK,GAEV,GAAG,EAAE,IAAI,IACL,OAAO,CAAC,gBAAgB,mBAAM,cAAc,EAAG,EAC/C,SAAS,cAEZ,QAAQ,IACC,GACS,GACP,CACnB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEM,0BAAO","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 FloatingFocusManager,\n FloatingPortal,\n type OffsetOptions,\n type Placement,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React from 'react';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme/ThemeProvider';\nimport { usePopover } from './use-popover';\nimport { usePatchFloatingFocusGuards } from './usePatchFloatingFocusGuards';\n\ntype PlacementOptions =\n | 'bottom-end-top-end'\n | 'bottom-start-top-start'\n | 'bottom-middle-top-middle'\n | 'top-end-bottom-end'\n | 'top-start-bottom-start'\n | 'top-middle-bottom-middle'\n | 'bottom-start-bottom-end'\n | 'top-start-top-end'\n | 'middle-start-middle-end'\n | 'bottom-end-bottom-start'\n | 'top-end-top-start'\n | 'middle-end-middle-start';\n\nexport const placementTranslation: Record<PlacementOptions, Placement> = {\n 'bottom-end-bottom-start': 'right-end',\n 'bottom-end-top-end': 'bottom-end',\n 'bottom-middle-top-middle': 'bottom',\n 'bottom-start-bottom-end': 'left-end',\n 'bottom-start-top-start': 'bottom-start',\n 'middle-end-middle-start': 'right',\n 'middle-start-middle-end': 'left',\n 'top-end-bottom-end': 'top-end',\n 'top-end-top-start': 'right-start',\n 'top-middle-bottom-middle': 'top',\n 'top-start-bottom-start': 'top-start',\n 'top-start-top-end': 'left-start',\n};\ntype PopoverProps = {\n /** if the popover is open */\n isOpen?: boolean;\n /** The content of the popover */\n children?: React.ReactNode;\n /**\n * Can be used if the anchor should be separated from the trigger.\n * Note: to visually separate the anchor from the trigger, use the Popover.Anchor component instead.\n */\n anchorElement?: Element | null;\n /** If the anchorPosition is provided the anchorElement will be ignored */\n anchorPosition?: {\n x: number;\n y: number;\n };\n /** The placement of the floating element is determined by two sets of words. The first set of words specifies the point on the anchor element where the floating element will be attached. The second set of coordinates specifies the point on the floating element that will attach to the anchor element.*/\n placement?: PlacementOptions;\n /** can take either a number, an object or a function. Full documentation here: https://floating-ui.com/docs/offset */\n offset?: OffsetOptions;\n /** Called when an internal state change is triggered, when the floating element either opens or closes. It is not called when `isOpen` is updated by the consumer. */\n onOpenChange?: (isOpen: boolean, event?: Event) => void;\n /** Use anchorEl for portal's container. Should be used if the popover is portaled and is inside a Dialog for example. */\n hasAnchorPortal?: boolean;\n /** If the popover should constrain the focus inside the popover while open */\n shouldCaptureFocus?: boolean;\n /** Which element to initially focus. **/\n initialFocus?: number | React.RefObject<HTMLElement | null>;\n // TODO v5: remove this prop\n /** The role of the popover.\n * @deprecated - This prop will be removed in v5.\n */\n role?:\n | 'tooltip'\n | 'dialog'\n | 'alertdialog'\n | 'menu'\n | 'listbox'\n | 'grid'\n | 'tree';\n /** If the popover should close when the user clicks outside of it */\n closeOnClickOutside?: boolean;\n /** The strategy of the popover. Fixed should be used when the popover is inside a Dialog. */\n strategy?: 'fixed' | 'absolute';\n /** Whether the content is rendered in a portal */\n isPortaled?: boolean;\n};\n\ntype ContextType = ReturnType<typeof usePopover> | null;\n\nconst PopoverContext = React.createContext<ContextType>(null);\n\nexport const usePopoverContext = () => {\n const context = React.useContext(PopoverContext);\n\n if (context === null) {\n throw new Error('Popover components must be wrapped in <Popover />');\n }\n\n return context;\n};\n\nconst PopoverComponent = ({\n children,\n anchorElement,\n placement,\n isOpen,\n offset,\n anchorPosition,\n hasAnchorPortal: hasAnchorPortalProp,\n shouldCaptureFocus = false,\n initialFocus,\n onOpenChange,\n role,\n closeOnClickOutside = true,\n isPortaled: isPortaledProp,\n strategy: strategyProp,\n}: PopoverProps) => {\n const isInsideDialog = useIsInsideDialog();\n\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const hasAnchorPortal = isInsideDialog;\n const isPortaled = !isInsideDialog;\n\n const popover = usePopover({\n anchorElement: anchorElement,\n anchorElementAsPortalAnchor: hasAnchorPortalProp ?? hasAnchorPortal,\n anchorPosition,\n closeOnClickOutside,\n initialFocus,\n isOpen: isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n offsetOption: offset,\n onOpenChange: onOpenChange,\n placement: placement ? placementTranslation[placement] : undefined,\n role,\n shouldCaptureFocus: shouldCaptureFocus,\n strategy: strategyProp ?? strategy,\n });\n\n return (\n <PopoverContext.Provider value={popover}>\n {children}\n </PopoverContext.Provider>\n );\n};\n\ntype PopoverTriggerProps = {\n /** The content of the trigger */\n children: React.ReactNode;\n /** Whether the trigger should render a button element, or pass its props to the child element */\n hasButtonWrapper?: boolean;\n};\n\nconst PopoverTrigger = ({\n children,\n hasButtonWrapper = false,\n ref,\n ...props\n}: CommonProps<'button', PopoverTriggerProps>) => {\n const context = usePopoverContext();\n // Example from floating UI\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n // `hasButtonWrapper` allows the user to pass any element as the anchor\n if (hasButtonWrapper && React.isValidElement(children)) {\n return React.cloneElement(\n children,\n context.getReferenceProps({\n ...props,\n ...childrenProps,\n 'data-state': context.isOpen ? 'open' : 'closed',\n ref: mergedRefs,\n }),\n );\n }\n return (\n <button\n ref={context.refs.setReference}\n type=\"button\"\n data-state={context.isOpen ? 'open' : 'closed'}\n {...context.getReferenceProps(props)}\n >\n {children}\n </button>\n );\n};\n\ntype PopoverAnchorProps = {\n children?: React.ReactNode;\n};\n\n/**\n * Use this to separate the anchor visually from the trigger.\n */\nconst PopoverAnchor = ({\n children,\n ref,\n ...props\n}: CommonProps<'div', PopoverAnchorProps>) => {\n const context = usePopoverContext();\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any)?.props;\n const mergedRefs = useMergeRefs([\n context.refs.setPositionReference,\n ref,\n childrenProps?.ref,\n ]);\n\n if (React.isValidElement(children)) {\n return React.cloneElement(children, {\n ...props,\n ...childrenProps,\n ref: mergedRefs,\n });\n }\n\n return (\n <div ref={mergedRefs} {...props}>\n {children}\n </div>\n );\n};\n\ntype PopoverContentProps = {\n children: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n};\n\nconst PopoverContent = <T extends React.ElementType = 'div'>({\n as,\n className,\n style,\n children,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, PopoverContentProps>) => {\n const { context: floatingContext, ...context } = usePopoverContext();\n\n const refs = useMergeRefs([context.refs.setFloating, ref]);\n\n const { themeClassName } = useNeedleTheme();\n\n const classes = classNames('ndl-popover', themeClassName, className);\n const Component: React.ElementType = as ?? 'div';\n\n // Patch to not get axe errors for the focus guards\n // To be noted is that axe gives us a false positive error here since the focus guards directly pass focus to other elements\n // https://github.com/floating-ui/floating-ui/issues/2462\n usePatchFloatingFocusGuards();\n\n if (!floatingContext.open) {\n return null;\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => (\n <FloatingPortal\n root={\n (context.anchorElementAsPortalAnchor ?? false)\n ? (context.refs.reference.current as HTMLElement | null)\n : undefined\n }\n >\n {wrapChildren}\n </FloatingPortal>\n )}\n >\n <FloatingFocusManager\n context={floatingContext}\n modal={context.shouldCaptureFocus}\n initialFocus={context.initialFocus}\n >\n <Component\n className={classes}\n aria-labelledby={context.labelId}\n aria-describedby={context.descriptionId}\n style={{\n ...context.floatingStyles,\n ...context.transitionStyles,\n ...style,\n }}\n ref={refs}\n {...context.getFloatingProps({ ...htmlAttributes })}\n {...restProps}\n >\n {children}\n </Component>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\nconst Popover = Object.assign(PopoverComponent, {\n Anchor: PopoverAnchor,\n Content: PopoverContent,\n Trigger: PopoverTrigger,\n});\n\nexport { Popover };\n"]}
@@ -80,16 +80,17 @@ function usePopover({ isInitialOpen = false, placement = 'bottom', isOpen: contr
80
80
  const { styles: transitionStyles } = (0, react_1.useTransitionStyles)(context, {
81
81
  duration: (_a = Number.parseInt(base_1.tokens.motion.duration.quick)) !== null && _a !== void 0 ? _a : 0,
82
82
  });
83
- return (0, react_2.useMemo)(() => (Object.assign(Object.assign(Object.assign({ isOpen }, interactions), data), { transitionStyles,
84
- labelId,
83
+ return (0, react_2.useMemo)(() => (Object.assign(Object.assign(Object.assign({}, data), interactions), { anchorElementAsPortalAnchor,
85
84
  descriptionId,
86
- setLabelId,
87
- setDescriptionId,
88
- anchorElementAsPortalAnchor,
89
- shouldCaptureFocus,
90
85
  initialFocus,
86
+ isOpen,
91
87
  isPortaled,
92
- returnFocus })), [
88
+ labelId,
89
+ returnFocus,
90
+ setDescriptionId,
91
+ setLabelId,
92
+ shouldCaptureFocus,
93
+ transitionStyles })), [
93
94
  isOpen,
94
95
  interactions,
95
96
  data,
@@ -1 +1 @@
1
- {"version":3,"file":"use-popover.js","sourceRoot":"","sources":["../../../src/popover/use-popover.tsx"],"names":[],"mappings":";;AAoFA,gCA8GC;AAlMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAgB4B;AAC5B,0CAAyC;AACzC,iCAA0C;AA8C1C,SAAgB,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,EACb,cAAc,EACd,2BAA2B,EAC3B,kBAAkB,EAClB,YAAY,EACZ,IAAI,EAAE,QAAQ,EACd,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,QAAQ,GAAG,UAAU,EACrB,UAAU,GAAG,IAAI,MACC,EAAE;;IACpB,oEAAoE;IACpE,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,IAAA,gBAAQ,EAAC,aAAa,CAAC,CAAC;IAC5E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,GAAsB,CAAC;IAC7D,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,GAAsB,CAAC;IAEzE,0EAA0E;IAC1E,oDAAoD;IACpD,MAAM,MAAM,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,kBAAkB,CAAC;IAEpD,MAAM,IAAI,GAAG,IAAA,mBAAW,EAAC;QACvB,QAAQ,EAAE;YACR,SAAS,EAAE,aAAa;SACzB;QACD,UAAU,EAAE;YACV,IAAA,cAAM,EAAC,YAAY,CAAC;YAC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AAE,WAAW,CAAC,CAAC,CAAC;IAE1E,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,2BAAmB,EAAC,OAAO,EAAE;QAChE,QAAQ,EAAE,MAAA,MAAM,CAAC,QAAQ,CAAC,aAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,mCAAI,CAAC;KAC7D,CAAC,CAAC;IAEH,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CAAC,6CACJ,MAAM,IACH,YAAY,GACZ,IAAI,KACP,gBAAgB;QAChB,OAAO;QACP,aAAa;QACb,UAAU;QACV,gBAAgB;QAChB,2BAA2B;QAC3B,kBAAkB;QAClB,YAAY;QACZ,UAAU;QACV,WAAW,IACX,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 isOpen,\n ...interactions,\n ...data,\n transitionStyles,\n labelId,\n descriptionId,\n setLabelId,\n setDescriptionId,\n anchorElementAsPortalAnchor,\n shouldCaptureFocus,\n initialFocus,\n isPortaled,\n returnFocus,\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"]}
1
+ {"version":3,"file":"use-popover.js","sourceRoot":"","sources":["../../../src/popover/use-popover.tsx"],"names":[],"mappings":";;AAoFA,gCA8GC;AAlMD;;;;;;;;;;;;;;;;;;;GAm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2B;QAC3B,aAAa;QACb,YAAY;QACZ,MAAM;QACN,UAAU;QACV,OAAO;QACP,WAAW;QACX,gBAAgB;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"]}
@@ -156,10 +156,10 @@ const onInnerDivKeyDown = (event, shouldDisableInteraction, wrapperRef) => {
156
156
  * Is also used internally to create the TreeViewTextItem component
157
157
  */
158
158
  function TreeItemWrapperInner(_a) {
159
- var { depth, shouldDisableInteraction, shouldDisableSorting, isGhost, isIndicator, onCollapse, item, setNodeRef, setActivatorNodeRef, dragHandleProps, style, className, trails, children, indentationWidth, tabIndex, onFocus, ref } = _a,
159
+ var { depth, shouldDisableInteraction, shouldDisableSorting, isGhost, isIndicator, onCollapse, item, setNodeRef, setActivatorNodeRef, dragHandleProps, style, className, trails, children, indentationWidth, ariaLevel, ariaPosInSet, ariaSetSize, tabIndex, onFocus, ref } = _a,
160
160
  // Need to destruct to avoid passing it to the component
161
161
  // oxlint-disable-next-line no-unused-vars
162
- restProps = __rest(_a, ["depth", "shouldDisableInteraction", "shouldDisableSorting", "isGhost", "isIndicator", "onCollapse", "item", "setNodeRef", "setActivatorNodeRef", "dragHandleProps", "style", "className", "trails", "children", "indentationWidth", "tabIndex", "onFocus", "ref"]);
162
+ restProps = __rest(_a, ["depth", "shouldDisableInteraction", "shouldDisableSorting", "isGhost", "isIndicator", "onCollapse", "item", "setNodeRef", "setActivatorNodeRef", "dragHandleProps", "style", "className", "trails", "children", "indentationWidth", "ariaLevel", "ariaPosInSet", "ariaSetSize", "tabIndex", "onFocus", "ref"]);
163
163
  const wrapperRef = (0, react_1.useRef)(null);
164
164
  return ((0, jsx_runtime_1.jsx)("li", { ref: (el) => {
165
165
  wrapperRef.current = el;
@@ -173,7 +173,7 @@ function TreeItemWrapperInner(_a) {
173
173
  'ndl-tree-view-list-item': true,
174
174
  'ndl-tree-view-list-item-disable-interaction': shouldDisableInteraction,
175
175
  'ndl-tree-view-list-item-placeholder': isGhost,
176
- }), 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: (0, jsx_runtime_1.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 && ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: "ndl-tree-view-drag-handle", ref: setActivatorNodeRef, "aria-label": "Pick up" }, dragHandleProps, { tabIndex: tabIndex, children: (0, jsx_runtime_1.jsx)(icons_1.DragIcon, {}) }))), trails.map((trail, index) => {
176
+ }), 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: (0, jsx_runtime_1.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 && ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: "ndl-tree-view-drag-handle", ref: setActivatorNodeRef, "aria-label": "Pick up" }, dragHandleProps, { tabIndex: tabIndex, children: (0, jsx_runtime_1.jsx)(icons_1.DragIcon, {}) }))), trails.map((trail, index) => {
177
177
  return (0, jsx_runtime_1.jsx)(TreeViewTrail_1.Trail, { variant: trail }, index);
178
178
  }), children] }) }));
179
179
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TreeItemWrapper.js","sourceRoot":"","sources":["../../../src/tree-view/TreeItemWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAEpC,iCAA+B;AAE/B,4CAA+E;AAC/E,oCAAoC;AACpC,6EAKsC;AAEtC,mDAAwC;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,IAA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ACN,CAAC;AACJ,CAAC;AAEY,QAAA,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,4DAAoC;AAEpC,iCAA+B;AAE/B,4CAA+E;AAC/E,oCAAoC;AACpC,6EAKsC;AAEtC,mDAAwC;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,IAAA,6BAAqB,EAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC5D,MAAM,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;YACjC,IAAI,YAAY,YAAY,WAAW,EAAE,CAAC;gBACxC,YAAY,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC;QACH,CAAC;QAED,KAAK,CAAC,cAAc,EAAE,CAAC;IACzB,CAAC;SAAM,IAAI,KAAK,CAAC,GAAG,KAAK,WAAW,EAAE,CAAC;QACrC,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,CAA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C3C,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,iDACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,2BAA2B,EACrC,GAAG,EAAE,mBAAmB,gBACb,SAAS,IAChB,eAAe,IACnB,QAAQ,EAAE,QAAQ,YAElB,uBAAC,gBAAQ,KAAG,IACL,CACV,EACA,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;oBAC3B,OAAO,uBAAC,qBAAK,IAAa,OAAO,EAAE,KAAK,IAArB,KAAK,CAAoB,CAAC;gBAC/C,CAAC,CAAC,EAED,QAAQ,IACL,GACH,CACN,CAAC;AACJ,CAAC;AAEY,QAAA,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,4 +1,15 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.TreeView = void 0;
4
15
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -54,8 +65,9 @@ const dropAnimationConfig = {
54
65
  });
55
66
  },
56
67
  };
57
- const TreeViewComponent = function TreeView({ items, TreeItemComponent, onItemsChanged, htmlAttributes, }) {
58
- var _a;
68
+ const TreeViewComponent = function TreeView(_a) {
69
+ var _b;
70
+ var { items, TreeItemComponent, onItemsChanged, htmlAttributes } = _a, restProps = __rest(_a, ["items", "TreeItemComponent", "onItemsChanged", "htmlAttributes"]);
59
71
  const flattenItems = (0, react_1.useMemo)(() => (0, tree_view_utils_1.flattenTree)(items), [items]);
60
72
  const [activeId, setActiveId] = (0, react_1.useState)(null);
61
73
  const [overId, setOverId] = (0, react_1.useState)(null);
@@ -105,6 +117,18 @@ const TreeViewComponent = function TreeView({ items, TreeItemComponent, onItemsC
105
117
  const projected = (0, react_1.useMemo)(() => activeId && overId
106
118
  ? (0, tree_view_utils_1.getProjection)(flattenedAndRemovedCollapsedItemsWithActive, activeId, overId, offsetLeft, indentationWidth)
107
119
  : null, [activeId, overId, flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);
120
+ const hasSelectableItems = (0, react_1.useMemo)(() => flattenItems.some((item) => item.isSelected !== undefined), [flattenItems]);
121
+ const itemAriaData = (0, react_1.useMemo)(() => {
122
+ const visibleItems = flattenedAndRemovedCollapsedItemsWithActive.filter((item) => item.id !== ACTIVE_PLACEHOLDER_ID);
123
+ return visibleItems.reduce((acc, item) => {
124
+ const siblings = visibleItems.filter((sibling) => sibling.parentId === item.parentId);
125
+ acc[item.id] = {
126
+ posInSet: siblings.findIndex((sibling) => sibling.id === item.id) + 1,
127
+ setSize: siblings.length,
128
+ };
129
+ return acc;
130
+ }, {});
131
+ }, [flattenedAndRemovedCollapsedItemsWithActive]);
108
132
  /* ------------------------------ Handlers ------------------------------ */
109
133
  function handleDragStart({ active }) {
110
134
  const activeId = active.id;
@@ -290,12 +314,16 @@ const TreeViewComponent = function TreeView({ items, TreeItemComponent, onItemsC
290
314
  },
291
315
  };
292
316
  const trails = getTrailList();
293
- const rowIdWithFocus = focusedRowId !== null && focusedRowId !== void 0 ? focusedRowId : (_a = flattenedAndRemovedCollapsedItemsWithActive[0]) === null || _a === void 0 ? void 0 : _a.id;
294
- return ((0, jsx_runtime_1.jsx)(core_1.DndContext, { accessibility: { announcements }, sensors: sensors, collisionDetection: core_1.closestCenter, onDragEnd: handleDragEnd, onDragStart: handleDragStart, onDragMove: handleDragMove, onDragOver: handleDragOver, onDragCancel: handleDragCancel, measuring: measuring, children: (0, jsx_runtime_1.jsxs)(sortable_1.SortableContext, { items: flattenedAndRemovedCollapsedItemsWithActive.map((item) => item.id), strategy: sortable_1.verticalListSortingStrategy, children: [(0, jsx_runtime_1.jsx)("ol", Object.assign({ className: "ndl-tree-view-list", role: "tree" }, htmlAttributes, { children: flattenedAndRemovedCollapsedItemsWithActive.map((item) => {
295
- var _a;
317
+ const rowIdWithFocus = focusedRowId !== null && focusedRowId !== void 0 ? focusedRowId : (_b = flattenedAndRemovedCollapsedItemsWithActive[0]) === null || _b === void 0 ? void 0 : _b.id;
318
+ return ((0, jsx_runtime_1.jsx)(core_1.DndContext, { accessibility: { announcements }, sensors: sensors, collisionDetection: core_1.closestCenter, onDragEnd: handleDragEnd, onDragStart: handleDragStart, onDragMove: handleDragMove, onDragOver: handleDragOver, onDragCancel: handleDragCancel, measuring: measuring, children: (0, jsx_runtime_1.jsxs)(sortable_1.SortableContext, { items: flattenedAndRemovedCollapsedItemsWithActive.map((item) => item.id), strategy: sortable_1.verticalListSortingStrategy, children: [(0, jsx_runtime_1.jsx)("ol", Object.assign({ className: "ndl-tree-view-list", role: "tree", "aria-multiselectable": hasSelectableItems ? true : undefined }, restProps, htmlAttributes, { children: flattenedAndRemovedCollapsedItemsWithActive.map((item) => {
319
+ var _a, _b, _c;
296
320
  return ((0, jsx_runtime_1.jsx)(TreeViewItem_1.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
297
321
  ? TreeViewTextItem_1.TreeViewTextItem
298
- : TreeItemComponent, onCollapse: () => handleToggleCollapse(item.id), onItemsChanged: (newItems, itemChangedReason) => onItemsChanged((0, tree_view_utils_1.buildTree)(newItems), itemChangedReason), items: flattenItems, tabIndex: item.id === rowIdWithFocus ? 0 : -1, onFocus: () => setFocusedRowId(item.id), shouldDisableSorting: item.isSortable === false }, item.id));
322
+ : TreeItemComponent, onCollapse: () => handleToggleCollapse(item.id), onItemsChanged: (newItems, itemChangedReason) => onItemsChanged((0, tree_view_utils_1.buildTree)(newItems), itemChangedReason), items: flattenItems, ariaLevel: item.id === ACTIVE_PLACEHOLDER_ID ? undefined : item.depth + 1, ariaPosInSet: item.id === ACTIVE_PLACEHOLDER_ID
323
+ ? undefined
324
+ : (_b = itemAriaData[item.id]) === null || _b === void 0 ? void 0 : _b.posInSet, ariaSetSize: item.id === ACTIVE_PLACEHOLDER_ID
325
+ ? undefined
326
+ : (_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));
299
327
  }) })), (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: dropAnimationConfig }), document.body)] }) }));
300
328
  };
301
329
  const TreeViewComponents = {
@@ -1 +1 @@
1
- {"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../src/tree-view/TreeView.tsx"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wCAiBuB;AACvB,gDAI2B;AAE3B,iCAA+D;AAC/D,yCAAyC;AAGzC,qFAAmF;AAOnF,uDAO2B;AAC3B,uDAAoD;AACpD,iDAAsD;AACtD,yDAAsD;AAEtD,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,qBAAqB,GAAG,sBAAsB,C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,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,IAAA,wBAAY,EACX,uBAAC,kBAAW,IAAC,aAAa,EAAE,mBAAmB,GAAgB,EAC/D,QAAQ,CAAC,IAAI,CACd,IACe,GACP,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACzB,oBAAoB,EAApB,mCAAoB;IACpB,eAAe,EAAf,iCAAe;IACf,gBAAgB,EAAhB,mCAAgB;CACjB,CAAC;AAEW,QAAA,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,wCAiBuB;AACvB,gDAI2B;AAE3B,iCAA+D;AAC/D,yCAAyC;AAGzC,qFAAmF;AAOnF,uDAO2B;AAC3B,uDAAoD;AACpD,iDAAsD;AACtD,yDAAsD;AAEtD,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAErD,MAAM,mBAAmB,GAAkB;IACzC,MAAM,EAAE,UAAU;IAClB,SAAS,CAAC,EAAE,SAAS,EAAE;QACrB,OAAO;YACL;gBACE,OAAO,EAAE,CAAC;gBACV,SAAS,EAAE,IAAA,mCAAiB,EAAC,SAAS,CAAC,OAAO,CAAC;aAChD;YACD;gBACE,OAAO,EAAE,CAAC;gBACV,SAAS,EAAE,IAAA,mCAAiB,kCACvB,SAAS,CAAC,KAAK,KAClB,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EACxB,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IACxB;aACH;SACF,CAAC;IACJ,CAAC;IACD,WAAW,CAAC,EAAE,MAAM,EAAE;QACpB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE;YACpD,QAAQ,EAAE,2BAAoB,CAAC,QAAQ;YACvC,MAAM,EAAE,2BAAoB,CAAC,MAAM;SACpC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAmBF,MAAM,iBAAiB,GAAG,SAAS,QAAQ,CAGzC,EAMoB;;QANpB,EACA,KAAK,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,OAEM,EADjB,SAAS,cALZ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**\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"]}
@@ -75,7 +75,7 @@ const SortableTreeViewItemNotMemoized = function SortableTreeViewItem(_a) {
75
75
  var { id, depth, isLast, TreeItemComponent, parent, shouldDisableSorting,
76
76
  // need to destruct to avoid passing it to the component
77
77
  // oxlint-disable-next-line no-unused-vars
78
- 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"]);
78
+ 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"]);
79
79
  const { attributes, listeners, setNodeRef, transform, setActivatorNodeRef, transition, isDragging, isSorting, isOver, } = (0, sortable_1.useSortable)({
80
80
  animateLayoutChanges,
81
81
  id: id,
@@ -94,7 +94,7 @@ const SortableTreeViewItemNotMemoized = function SortableTreeViewItem(_a) {
94
94
  }
95
95
  return () => onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(item.id);
96
96
  }, [item.id, onCollapse]);
97
- return ((0, jsx_runtime_1.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 })));
97
+ return ((0, jsx_runtime_1.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 })));
98
98
  };
99
99
  exports.SortableTreeViewItem = react_1.default.memo(SortableTreeViewItemNotMemoized);
100
100
  //# sourceMappingURL=TreeViewItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeViewItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,gDAI2B;AAC3B,+CAA2D;AAO3D,uDAAsD;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;AA6B/C,MAAM,+BAA+B,GAAG,SAAS,oBAAoB,CAGnE,EAmB4B;QAnB5B,EACA,EAAE,EACF,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,MAAM,EACN,oBAAoB;IACpB,wDAAwD;IACxD,0CAA0C;IAC1C,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,cAAc,EACd,KAAK,EACL,QAAQ,EACR,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KAAK,EAAE,KAAK,EACZ,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;AAEW,QAAA,oBAAoB,GAAG,eAAK,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 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 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 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"]}
1
+ {"version":3,"file":"TreeViewItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,gDAI2B;AAC3B,+CAA2D;AAO3D,uDAAsD;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,oBAAoB;IACpB,wDAAwD;IACxD,0CAA0C;IAC1C,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,cAAc,EACd,KAAK,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,OAAO,OAEqB,EADzB,SAAS,cArBZ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AE,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;AAEW,QAAA,oBAAoB,GAAG,eAAK,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"]}
@@ -81,7 +81,7 @@ const TreeViewTextItem = (_a) => {
81
81
  : false;
82
82
  return ((0, jsx_runtime_1.jsxs)(TreeItemWrapper_1.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,
83
83
  // oxlint-disable-next-line @typescript-eslint/no-empty-function
84
- onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true', "aria-pressed": !item.isCollapsed,
84
+ onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true',
85
85
  /**
86
86
  * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab
87
87
  * since we use the arrow keys instead