@neo4j-ndl/react 4.9.32 → 4.9.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/_common/CodeBlockWrapper.js +2 -2
- package/lib/cjs/_common/CodeBlockWrapper.js.map +1 -1
- package/lib/cjs/code-block/CodeBlock.js +1 -1
- package/lib/cjs/code-block/CodeBlock.js.map +1 -1
- package/lib/cjs/popover/Popover.js.map +1 -1
- package/lib/cjs/popover/use-popover.js +8 -7
- package/lib/cjs/popover/use-popover.js.map +1 -1
- package/lib/cjs/tree-view/TreeItemWrapper.js +3 -3
- package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
- package/lib/cjs/tree-view/TreeView.js +34 -6
- package/lib/cjs/tree-view/TreeView.js.map +1 -1
- package/lib/cjs/tree-view/TreeViewItem.js +2 -2
- package/lib/cjs/tree-view/TreeViewItem.js.map +1 -1
- package/lib/cjs/tree-view/TreeViewTextItem.js +1 -1
- package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
- package/lib/cjs/tree-view/stories/treeview-default.story.js +9 -9
- package/lib/cjs/tree-view/stories/treeview-default.story.js.map +1 -1
- package/lib/cjs/tree-view/tree-view-types.js.map +1 -1
- package/lib/esm/_common/CodeBlockWrapper.js +2 -2
- package/lib/esm/_common/CodeBlockWrapper.js.map +1 -1
- package/lib/esm/code-block/CodeBlock.js +1 -1
- package/lib/esm/code-block/CodeBlock.js.map +1 -1
- package/lib/esm/popover/Popover.js.map +1 -1
- package/lib/esm/popover/use-popover.js +8 -7
- package/lib/esm/popover/use-popover.js.map +1 -1
- package/lib/esm/tree-view/TreeItemWrapper.js +3 -3
- package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
- package/lib/esm/tree-view/TreeView.js +34 -6
- package/lib/esm/tree-view/TreeView.js.map +1 -1
- package/lib/esm/tree-view/TreeViewItem.js +2 -2
- package/lib/esm/tree-view/TreeViewItem.js.map +1 -1
- package/lib/esm/tree-view/TreeViewTextItem.js +1 -1
- package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
- package/lib/esm/tree-view/stories/treeview-default.story.js +9 -9
- package/lib/esm/tree-view/stories/treeview-default.story.js.map +1 -1
- package/lib/esm/tree-view/tree-view-types.js.map +1 -1
- package/lib/types/_common/CodeBlockWrapper.d.ts.map +1 -1
- package/lib/types/popover/Popover.d.ts +3 -1
- package/lib/types/popover/Popover.d.ts.map +1 -1
- package/lib/types/tree-view/TreeItemWrapper.d.ts +1 -1
- package/lib/types/tree-view/TreeItemWrapper.d.ts.map +1 -1
- package/lib/types/tree-view/TreeView.d.ts +6 -3
- package/lib/types/tree-view/TreeView.d.ts.map +1 -1
- package/lib/types/tree-view/TreeViewItem.d.ts +4 -1
- package/lib/types/tree-view/TreeViewItem.d.ts.map +1 -1
- package/lib/types/tree-view/TreeViewTextItem.d.ts.map +1 -1
- package/lib/types/tree-view/tree-view-types.d.ts +3 -0
- package/lib/types/tree-view/tree-view-types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -77,11 +77,11 @@ const CodeBlockWrapper = (_a) => {
|
|
|
77
77
|
'ndl-disabled': isDisabled,
|
|
78
78
|
}), style: {
|
|
79
79
|
maxWidth: `calc(100% - ${((_b = actions === null || actions === void 0 ? void 0 : actions.length) !== null && _b !== void 0 ? _b : 0) * 36 + 20}px)`,
|
|
80
|
-
}, "data-testid": "ndl-code-block-title", children: heading })), (0, jsx_runtime_1.
|
|
80
|
+
}, "data-testid": "ndl-code-block-title", children: heading })), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ndl-code-content-container', {
|
|
81
81
|
'ndl-disabled': isDisabled,
|
|
82
82
|
}), style: {
|
|
83
83
|
height: Boolean(heading) === true ? 'calc(100% - 24px - 12px)' : '100%',
|
|
84
|
-
}, children:
|
|
84
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { ref: syntaxHighlighterWrapperRef, className: "ndl-highlight-wrapper", children: children }) })] }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ndl-code-block-actions', {
|
|
85
85
|
'ndl-disabled': isDisabled,
|
|
86
86
|
}), children: actions === null || actions === void 0 ? void 0 : actions.map((iconButtonProps, i) => {
|
|
87
87
|
const { htmlAttributes, description } = iconButtonProps, restCleanIconButtonProps = __rest(iconButtonProps, ["htmlAttributes", "description"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockWrapper.js","sourceRoot":"","sources":["../../../src/_common/CodeBlockWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAEpC,iCAAqE;AAErE,4DAAuD;AACvD,oCAAwE;AAgBxE,MAAM,cAAc,GAAG,KAAK,CAAC;AAEtB,MAAM,gBAAgB,GAAG,CAE9B,EAeiD,EAAE,EAAE;;QAfrD,EACA,EAAE,EACF,SAAS,EACT,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,EACP,sBAAsB,EACtB,yBAAyB,EACzB,SAAS,EACT,KAAK,EACL,GAAG,EACH,cAAc,OAEmC,EAD9C,SAAS,cAdZ,iLAeD,CADa;IAEZ,MAAM,SAAS,GAAsB,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,cAAc,CAAC;IAE1D,MAAM,2BAA2B,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAEjE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,SAAS,IAAI,CAAC,CAAC;IACzE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IAEtE,IAAA,iBAAS,EAAC,GAAG,EAAE;;QACb,IACE,CAAC,MAAA,MAAA,2BAA2B,CAAC,OAAO,0CAAE,YAAY,mCAAI,CAAC,CAAC;YACxD,CAAC,MAAA,MA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,CAAC,CAAC;4BAClC,aAAa,CAAC,IAAI,CAAC,CAAC;wBACtB,CAAC;oBACH,CAAC,YAEA,UAAU,CAAC,CAAC,CAAC,uBAAC,4BAAoB,KAAG,CAAC,CAAC,CAAC,uBAAC,8BAAsB,KAAG,GACnD,GACd,CACP,KACS,CACb,CAAC;AACJ,CAAC,CAAC;AA3IW,QAAA,gBAAgB,oBA2I3B","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 { useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ChevronDownIconOutline, ChevronUpIconOutline } from '../icons';\nimport { type PolymorphicCommonProps } from './types';\n\nexport interface CodeBlockWrapperProps {\n maxHeight?: number;\n code: string;\n heading?: string | React.ReactNode;\n children: React.ReactNode;\n isDisabled?: boolean;\n actions?: React.ComponentPropsWithoutRef<typeof CleanIconButton<'button'>>[];\n shouldShowExpandButton: boolean;\n setShouldShowExpandButton: React.Dispatch<React.SetStateAction<boolean>>;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst defaultElement = 'div';\n\nexport const CodeBlockWrapper = <\n T extends React.ElementType = typeof defaultElement,\n>({\n as,\n maxHeight,\n code,\n heading,\n children,\n isDisabled,\n actions,\n shouldShowExpandButton,\n setShouldShowExpandButton,\n className,\n style,\n ref,\n htmlAttributes,\n ...restProps\n}: PolymorphicCommonProps<T, CodeBlockWrapperProps>) => {\n const Component: React.ElementType = as ?? defaultElement;\n\n const syntaxHighlighterWrapperRef = useRef<HTMLDivElement>(null);\n\n const [containerHeight, setContainerHeight] = useState(`${maxHeight}px`);\n const [isExpanded, setIsExpanded] = useState(maxHeight === undefined);\n\n useEffect(() => {\n if (\n (syntaxHighlighterWrapperRef.current?.scrollHeight ?? 0) <=\n (syntaxHighlighterWrapperRef.current?.clientHeight ?? 0)\n ) {\n setIsExpanded(true);\n } else {\n setIsExpanded(false);\n }\n }, []);\n\n useLayoutEffect(() => {\n if (maxHeight === undefined) {\n return;\n }\n\n if (\n (syntaxHighlighterWrapperRef.current?.clientHeight ?? 0) >=\n (syntaxHighlighterWrapperRef.current?.scrollHeight ?? 0)\n ) {\n setContainerHeight(`fit-content`);\n setShouldShowExpandButton(false);\n } else {\n setContainerHeight(`${maxHeight}px`);\n setShouldShowExpandButton(true);\n }\n }, [maxHeight, code, setShouldShowExpandButton]);\n\n return (\n <Component\n ref={ref}\n className={classNames('ndl-code-block-container', className)}\n style={{ height: containerHeight, ...style }}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"n-flex n-flex-col n-h-full\">\n {Boolean(heading) === true && (\n <div\n className={classNames('ndl-code-block-title', {\n 'ndl-disabled': isDisabled,\n })}\n style={{\n maxWidth: `calc(100% - ${(actions?.length ?? 0) * 36 + 20}px)`,\n }}\n data-testid=\"ndl-code-block-title\"\n >\n {heading}\n </div>\n )}\n <div\n className={classNames('ndl-code-content-container', {\n 'ndl-disabled': isDisabled,\n })}\n style={{\n height:\n Boolean(heading) === true ? 'calc(100% - 24px - 12px)' : '100%',\n }}\n >\n <div\n ref={syntaxHighlighterWrapperRef}\n className=\"ndl-highlight-wrapper\"\n >\n {children}\n </div>\n </div>\n </div>\n <div\n className={classNames('ndl-code-block-actions', {\n 'ndl-disabled': isDisabled,\n })}\n >\n {actions?.map((iconButtonProps, i) => {\n const { htmlAttributes, description, ...restCleanIconButtonProps } =\n iconButtonProps;\n return (\n <CleanIconButton\n key={i}\n description={`${description ?? 'CodeBlock Action'}`}\n isDisabled={isDisabled}\n htmlAttributes={{\n 'data-testid': `ndl-action-button-${i}`,\n ...htmlAttributes,\n }}\n {...restCleanIconButtonProps}\n />\n );\n })}\n </div>\n {shouldShowExpandButton && (\n <div className=\"ndl-code-block-expand-button\">\n <CleanIconButton\n description={isExpanded ? 'Collapse' : 'Expand'}\n tooltipProps={{\n root: {\n shouldCloseOnReferenceClick: true,\n },\n }}\n onClick={() => {\n if (isExpanded) {\n setContainerHeight(`${maxHeight}px`);\n setIsExpanded(false);\n } else {\n setContainerHeight(`fit-content`);\n setIsExpanded(true);\n }\n }}\n >\n {isExpanded ? <ChevronUpIconOutline /> : <ChevronDownIconOutline />}\n </CleanIconButton>\n </div>\n )}\n </Component>\n );\n};\n"]}
|
|
@@ -99,7 +99,7 @@ const CodeBlock = (_a) => {
|
|
|
99
99
|
border: 0,
|
|
100
100
|
color: 'var(--theme-color-neutral-text-default)',
|
|
101
101
|
lineHeight: '1',
|
|
102
|
-
padding: `0 ${calculateRightPadding !== null && calculateRightPadding !== void 0 ? calculateRightPadding : 0}px 0.75em
|
|
102
|
+
padding: `0 ${calculateRightPadding !== null && calculateRightPadding !== void 0 ? calculateRightPadding : 0}px 0.75em 0.75em`,
|
|
103
103
|
width: 'fit-content',
|
|
104
104
|
} }),
|
|
105
105
|
// Turn on 'shouldShowLineNumbers' & 'wrapLongLines' at the same time, the display is wrong
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","sourceRoot":"","sources":["../../../src/code-block/CodeBlock.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,iCAA4C;AAC5C,uEAA2E;AAC3E,0EAQwD;AAExD,kEAA+D;AAG/D,oCAA0C;AAC1C,qDAAmE;AACnE,2EAAiD;AACjD,6EAAmD;AAsB5C,MAAM,SAAS,GAAG,CAAyC,EAetB,EAAE,EAAE;QAfkB,EAChE,EA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,uBAAC,mCAAgB,kBACf,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,sBAAsB,EAAE,sBAAsB,EAC9C,yBAAyB,EAAE,yBAAyB,IAChD,SAAS,EACT,cAAc,cAElB,uBAAC,qCAAiB,IAChB,QAAQ,EAAE,cAAc,IAAI,MAAM,EAClC,KAAK,kCACA,QAAQ,EAAE,KACb,yBAAyB,EAAE;oBACzB,MAAM,EAAE,CAAC;oBACT,KAAK,EAAE,yCAAyC;oBAChD,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE,KAAK,qBAAqB,aAArB,qBAAqB,cAArB,qBAAqB,GAAI,CAAC,kBAAkB;oBAC1D,KAAK,EAAE,aAAa;iBACrB;YAEH,2FAA2F;YAC3F,kFAAkF;YAClF,gBAAgB;YAChB,YAAY,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EACrC,eAAe,EAAE,qBAAqB,YAErC,IAAI,GACa,IACH,CACpB,CAAC;AACJ,CAAC,CAAC;AA9GW,QAAA,SAAS,aA8GpB","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type React from 'react';\nimport { useEffect, useState } from 'react';\nimport { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport {\n base16AteliersulphurpoolLight,\n coy,\n duotoneLight,\n ghcolors,\n prism,\n solarizedlight,\n vs,\n} from 'react-syntax-highlighter/dist/cjs/styles/prism';\n\nimport { CodeBlockWrapper } from '../_common/CodeBlockWrapper';\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { type IconButton } from '../icon-button';\nimport { useNeedleTheme } from '../theme';\nimport { type LanguageProp, loadLanguage } from './code-languages';\nimport ndlCodeDark from './themes/ndl-code-dark';\nimport ndlCodeLight from './themes/ndl-code-light';\n\ninterface CodeBlockProps {\n code: string;\n isDisabled?: boolean;\n maxHeight?: number;\n language: LanguageProp | 'text';\n shouldShowLineNumbers?: boolean;\n theme?:\n | 'vs'\n | 'base16-ateliersulphurpool.light'\n | 'coy'\n | 'duotone-light'\n | 'ghcolors'\n | 'prism'\n | 'solarizedlight'\n | 'ndl-code-dark'\n | 'ndl-code-light';\n heading?: React.ReactNode;\n actions?: React.ComponentProps<typeof IconButton<'button'>>[];\n}\n\nexport const CodeBlock = <T extends React.ElementType = 'button'>({\n as,\n maxHeight,\n code,\n language,\n shouldShowLineNumbers,\n theme,\n heading,\n actions,\n isDisabled,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, CodeBlockProps>) => {\n const [shouldShowExpandButton, setShouldShowExpandButton] = useState(\n maxHeight !== undefined,\n );\n\n const { theme: ndlTheme } = useNeedleTheme();\n const [loadedLanguage, setLoadedLanguage] = useState<\n LanguageProp | 'text' | null\n >(null);\n\n useEffect(() => {\n if (language === undefined || language === 'text') {\n setLoadedLanguage('text');\n return;\n }\n\n loadLanguage(language)\n .then((module) => {\n SyntaxHighlighter.registerLanguage(language, module.default);\n setLoadedLanguage(language);\n })\n // TODO: add visual feedback for the user\n .catch((err) => console.error(err));\n }, [language]);\n\n const getTheme = () => {\n switch (theme) {\n case 'ndl-code-dark':\n return ndlCodeDark;\n case 'ndl-code-light':\n return ndlCodeLight;\n case 'vs':\n return vs;\n case 'base16-ateliersulphurpool.light':\n return base16AteliersulphurpoolLight;\n case 'coy':\n return coy;\n case 'duotone-light':\n return duotoneLight;\n case 'ghcolors':\n return ghcolors;\n case 'prism':\n return prism;\n case 'solarizedlight':\n return solarizedlight;\n default:\n return ndlTheme === 'light' ? ndlCodeLight : ndlCodeDark;\n }\n };\n const calculateRightPadding = (() => {\n if (Boolean(heading) === false) {\n const expandButtonCount = shouldShowExpandButton ? 1 : 0;\n const actionCount = actions?.length ?? 0;\n return Math.max(actionCount * 36, expandButtonCount * 36) + 8;\n }\n })();\n\n return (\n <CodeBlockWrapper\n as={as}\n className={className}\n style={style}\n ref={ref}\n maxHeight={maxHeight}\n code={code}\n heading={heading}\n isDisabled={isDisabled}\n actions={actions}\n shouldShowExpandButton={shouldShowExpandButton}\n setShouldShowExpandButton={setShouldShowExpandButton}\n {...restProps}\n {...htmlAttributes}\n >\n <SyntaxHighlighter\n language={loadedLanguage || 'text'}\n style={{\n ...getTheme(),\n 'pre[class*=\"language-\"]': {\n border: 0,\n color: 'var(--theme-color-neutral-text-default)',\n lineHeight: '1',\n padding: `0 ${calculateRightPadding ?? 0}px 0.75em 0.75em`,\n width: 'fit-content',\n },\n }}\n // Turn on 'shouldShowLineNumbers' & 'wrapLongLines' at the same time, the display is wrong\n // https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/402\n // wrapLongLines\n codeTagProps={{ className: 'n-code' }}\n showLineNumbers={shouldShowLineNumbers}\n >\n {code}\n </SyntaxHighlighter>\n </CodeBlockWrapper>\n );\n};\n"]}
|
|
@@ -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,0D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O,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,"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;AAkDF,MAAM,cAAc,GAAG,eAAK,CAAC,aAAa,C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4j 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({
|
|
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
|
-
|
|
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,YA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AO;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,E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AAC,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 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,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B,GAAI,KAAK,EACjC,UAAU,EACV,UAAU,EACV,IAAI,CACL,YAGH,iCACE,IAAI,EAAC,cAAc,EACnB,SAAS,EAAC,iCAAiC,EAC3C,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,iBAAiB,CACf,KAAK,EACL,wBAAwB,aAAxB,wBAAwB,cAAxB,wBAAwB,GAAI,KAAK,EACjC,UAAU,CACX,aAGF,CAAC,oBAAoB,IAAI,CACxB,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(
|
|
58
|
-
var
|
|
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 : (
|
|
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,
|
|
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,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,EACA,KAAK,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,GACM;;IACpB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vB,gBAAgB,EAAE,IAAI,CAAC,EAAE,KAAK,qBAAqB,EACnD,iBAAiB,EACf,iBAAiB,KAAK,SAAS;gCAC7B,CAAC,CAAE,mCAA4C;gCAC/C,CAAC,CAAC,iBAAiB,EAEvB,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,EAC/C,cAAc,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,EAAE,CAC9C,cAAc,CAAC,IAAA,2BAAS,EAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,EAExD,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC7C,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EACvC,oBAAoB,EAAE,IAAI,CAAC,UAAU,KAAK,KAAK,IAvB1C,IAAI,CAAC,EAAE,CAwBZ,CACH,CAAA;qBAAA,CAAC,IACC,EAEJ,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;I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,CAAC,EAAE,CAqCZ,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 ...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"]}
|