@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
|
@@ -75,7 +75,7 @@ const SortableTreeViewItemNotMemoized = function SortableTreeViewItem(_a) {
|
|
|
75
75
|
var { id, depth, isLast, TreeItemComponent, parent, shouldDisableSorting,
|
|
76
76
|
// need to destruct to avoid passing it to the component
|
|
77
77
|
// oxlint-disable-next-line no-unused-vars
|
|
78
|
-
sortableProps, keepGhostInPlace, item, onCollapse, trails, onItemsChanged, items, tabIndex, onFocus } = _a, restProps = __rest(_a, ["id", "depth", "isLast", "TreeItemComponent", "parent", "shouldDisableSorting", "sortableProps", "keepGhostInPlace", "item", "onCollapse", "trails", "onItemsChanged", "items", "tabIndex", "onFocus"]);
|
|
78
|
+
sortableProps, keepGhostInPlace, item, onCollapse, trails, onItemsChanged, items, ariaLevel, ariaPosInSet, ariaSetSize, tabIndex, onFocus } = _a, restProps = __rest(_a, ["id", "depth", "isLast", "TreeItemComponent", "parent", "shouldDisableSorting", "sortableProps", "keepGhostInPlace", "item", "onCollapse", "trails", "onItemsChanged", "items", "ariaLevel", "ariaPosInSet", "ariaSetSize", "tabIndex", "onFocus"]);
|
|
79
79
|
const { attributes, listeners, setNodeRef, transform, setActivatorNodeRef, transition, isDragging, isSorting, isOver, } = (0, sortable_1.useSortable)({
|
|
80
80
|
animateLayoutChanges,
|
|
81
81
|
id: id,
|
|
@@ -94,7 +94,7 @@ const SortableTreeViewItemNotMemoized = function SortableTreeViewItem(_a) {
|
|
|
94
94
|
}
|
|
95
95
|
return () => onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(item.id);
|
|
96
96
|
}, [item.id, onCollapse]);
|
|
97
|
-
return ((0, jsx_runtime_1.jsx)(TreeItemComponent, Object.assign({ item: item, isOverParent: false }, restProps, { setActivatorNodeRef: setActivatorNodeRef, setNodeRef: setNodeRef, style: style, depth: depth, isGhost: keepGhostInPlace, shouldDisableInteraction: isSorting, isLastInParent: isLast, parent: parent, dragHandleProps: Object.assign(Object.assign({}, attributes), listeners), isIndicator: isDragging, onCollapse: localCollapse, onItemsChanged: onItemsChanged, items: items, shouldDisableSorting: shouldDisableSorting, isOver: isOver, trails: trails, tabIndex: tabIndex, onFocus: onFocus })));
|
|
97
|
+
return ((0, jsx_runtime_1.jsx)(TreeItemComponent, Object.assign({ item: item, isOverParent: false }, restProps, { setActivatorNodeRef: setActivatorNodeRef, setNodeRef: setNodeRef, style: style, depth: depth, isGhost: keepGhostInPlace, shouldDisableInteraction: isSorting, isLastInParent: isLast, parent: parent, dragHandleProps: Object.assign(Object.assign({}, attributes), listeners), isIndicator: isDragging, onCollapse: localCollapse, onItemsChanged: onItemsChanged, items: items, ariaLevel: ariaLevel, ariaPosInSet: ariaPosInSet, ariaSetSize: ariaSetSize, shouldDisableSorting: shouldDisableSorting, isOver: isOver, trails: trails, tabIndex: tabIndex, onFocus: onFocus })));
|
|
98
98
|
};
|
|
99
99
|
exports.SortableTreeViewItem = react_1.default.memo(SortableTreeViewItemNotMemoized);
|
|
100
100
|
//# sourceMappingURL=TreeViewItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeViewItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,gDAI2B;AAC3B,+CAA2D;AAO3D,uDAAsD;AA+BtD,MAAM,oBAAoB,GAAyB,CAAC,EAClD,SAAS,EACT,UAAU,GACX,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeViewItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,gDAI2B;AAC3B,+CAA2D;AAO3D,uDAAsD;AA+BtD,MAAM,oBAAoB,GAAyB,CAAC,EAClD,SAAS,EACT,UAAU,GACX,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAgC/C,MAAM,+BAA+B,GAAG,SAAS,oBAAoB,CAGnE,EAsB4B;QAtB5B,EACA,EAAE,EACF,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,MAAM,EACN,oBAAoB;IACpB,wDAAwD;IACxD,0CAA0C;IAC1C,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,cAAc,EACd,KAAK,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,OAAO,OAEqB,EADzB,SAAS,cArBZ,mPAsBD,CADa;IAEZ,MAAM,EACJ,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,GACP,G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EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,IAChB,CACH,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,oBAAoB,GAAG,eAAK,CAAC,IAAI,CAC5C,+BAA+B,CACU,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { type UniqueIdentifier } from '@dnd-kit/core';\nimport {\n type AnimateLayoutChanges,\n useSortable,\n type UseSortableArguments,\n} from '@dnd-kit/sortable';\nimport React, { type CSSProperties, useMemo } from 'react';\n\nimport {\n type FlattenedTreeItem,\n type ItemChangedReason,\n type TreeItemComponent,\n} from './tree-view-types';\nimport { transformToString } from './tree-view-utils';\n\nexport interface TreeItemProps<T> {\n /** Number of child items */\n childCount?: number;\n /** Whether this is a clone item */\n clone?: boolean;\n /** Whether the item is collapsed */\n collapsed?: boolean;\n /** Depth of the item in the tree */\n depth: number;\n /** Whether interaction should be disabled */\n shouldDisableInteraction?: boolean;\n /** Whether this is an indicator item */\n indicator?: boolean;\n /** Width of the indentation */\n indentationWidth: number;\n /** The tree item data */\n item: FlattenedTreeItem<T>;\n /** Whether this is the last item in its parent */\n isLast: boolean;\n /** Parent item of this item */\n parent: FlattenedTreeItem<T> | null;\n /** Function to call when item is collapsed */\n onCollapse?(id: UniqueIdentifier): void;\n /** Function to call when item is removed */\n onRemove?(id: UniqueIdentifier): void;\n /** Function to set the wrapper ref */\n wrapperRef?(node: HTMLLIElement): void;\n}\n\nconst animateLayoutChanges: AnimateLayoutChanges = ({\n isSorting,\n isDragging,\n}) => (isSorting || isDragging ? false : true);\n\ntype SortableTreeItemProps<\n T extends Record<string, unknown>,\n E extends HTMLElement,\n> = TreeItemProps<T> & {\n id: UniqueIdentifier;\n /** The component to use for rendering the tree item */\n TreeItemComponent: TreeItemComponent<T, E>;\n /** Whether sorting should be disabled for this item */\n shouldDisableSorting?: boolean;\n /** Props for the sortable functionality */\n sortableProps?: Omit<UseSortableArguments, 'id'>;\n /** Whether to keep the ghost item in place while dragging */\n keepGhostInPlace?: boolean;\n /** A list of trails to render before the item */\n trails: ('none' | 'straight' | 'straight-curved' | 'curved')[];\n /** Function to call when the item has changed */\n onItemsChanged: (\n newItems: FlattenedTreeItem<T>[],\n itemChangedReason: ItemChangedReason<T>,\n ) => void;\n /** All items in the tree */\n items: FlattenedTreeItem<T>[];\n ariaLevel?: number;\n ariaPosInSet?: number;\n ariaSetSize?: number;\n tabIndex?: number;\n /** Function to call when the item receives focus */\n onFocus?: () => void;\n};\n\nconst SortableTreeViewItemNotMemoized = function SortableTreeViewItem<\n T extends Record<string, unknown>,\n E extends HTMLElement,\n>({\n id,\n depth,\n isLast,\n TreeItemComponent,\n parent,\n shouldDisableSorting,\n // need to destruct to avoid passing it to the component\n // oxlint-disable-next-line no-unused-vars\n sortableProps,\n keepGhostInPlace,\n item,\n onCollapse,\n trails,\n onItemsChanged,\n items,\n ariaLevel,\n ariaPosInSet,\n ariaSetSize,\n tabIndex,\n onFocus,\n ...restProps\n}: SortableTreeItemProps<T, E>) {\n const {\n attributes,\n listeners,\n setNodeRef,\n transform,\n setActivatorNodeRef,\n transition,\n isDragging,\n isSorting,\n isOver,\n } = useSortable({\n animateLayoutChanges,\n id: id,\n transition: {\n duration: 150, // milliseconds\n easing: 'cubic-bezier(0.25, 1, 0.5, 1)',\n },\n });\n\n const style: CSSProperties = {\n transform: transform ? transformToString(transform) : undefined,\n transition: transition ?? undefined,\n };\n const localCollapse = useMemo(() => {\n if (!onCollapse) {\n return undefined;\n }\n return () => onCollapse?.(item.id);\n }, [item.id, onCollapse]);\n\n return (\n <TreeItemComponent\n item={item}\n isOverParent={false}\n {...restProps}\n setActivatorNodeRef={setActivatorNodeRef}\n setNodeRef={setNodeRef}\n style={style}\n depth={depth}\n isGhost={keepGhostInPlace}\n shouldDisableInteraction={isSorting}\n isLastInParent={isLast}\n parent={parent}\n dragHandleProps={{\n ...attributes,\n ...listeners,\n }}\n isIndicator={isDragging}\n onCollapse={localCollapse}\n onItemsChanged={onItemsChanged}\n items={items}\n ariaLevel={ariaLevel}\n ariaPosInSet={ariaPosInSet}\n ariaSetSize={ariaSetSize}\n shouldDisableSorting={shouldDisableSorting}\n isOver={isOver}\n trails={trails}\n tabIndex={tabIndex}\n onFocus={onFocus}\n />\n );\n};\n\nexport const SortableTreeViewItem = React.memo(\n SortableTreeViewItemNotMemoized,\n) as typeof SortableTreeViewItemNotMemoized;\n"]}
|
|
@@ -81,7 +81,7 @@ const TreeViewTextItem = (_a) => {
|
|
|
81
81
|
: false;
|
|
82
82
|
return ((0, jsx_runtime_1.jsxs)(TreeItemWrapper_1.TreeItemWrapper, Object.assign({ depth: depth, shouldDisableInteraction: shouldDisableInteraction, shouldDisableSorting: shouldDisableSorting, isGhost: isGhost, indentationWidth: indentationWidth, isIndicator: isIndicator, isCollapsed: isCollapsed, onCollapse: onCollapse, item: item, parent: parent, isOver: isOver, isOverParent: isOverParent, setNodeRef: setNodeRef, setActivatorNodeRef: setActivatorNodeRef, dragHandleProps: dragHandleProps, style: style, trails: trails,
|
|
83
83
|
// oxlint-disable-next-line @typescript-eslint/no-empty-function
|
|
84
|
-
onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true',
|
|
84
|
+
onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true',
|
|
85
85
|
/**
|
|
86
86
|
* Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab
|
|
87
87
|
* since we use the arrow keys instead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsBA,0CAAuC;AACvC,4DAAuD;AACvD,0DAAsD;AACtD,oCAA2E;AAC3E,0CAAuC;AACvC,8CAA2C;AAM3C,uDAAoD;AAEpD;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CACjC,IAAqC,EACrC,KAAwC,EAC/B,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,0BAA0B,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CACjC,IAAqC,EACrC,KAAwC,EAC/B,EAAE;IACX,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7D,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,IAAI,CAAC,WAAW,EAC9B,SAAS,EAAC,8BAA8B,EACxC,QAAQ,EAAE,QAAQ,YAEjB,QAAQ,GACF,CACV,YAED,uBAAC,uBAAU,IACT,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,EAClE,cAAc,EAAE;4BACd,KAAK,EAAE;gCACL,QAAQ,EAAE,QAAQ;gCAClB,YAAY,EAAE,UAAU;gCACxB,UAAU,EAAE,QAAQ;6BACrB;yBACF,YAEA,IAAI,CAAC,IAAI,CAAC,IAAI,GACJ,GACG,IACT,EACX,gCAAK,SAAS,EAAC,uBAAuB,YACnC,IAAI,CAAC,IAAI,CAAC,OAAO;oBAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;wBACtC,OAAO,CACL,uBAAC,mCAAe,kBAEd,SAAS,EAAC,sBAAsB,EAChC,IAAI,EAAC,OAAO,IACR,MAAM,CAAC,WAAW,IACtB,cAAc,kBACZ,QAAQ,IACL,MAAM,CAAC,WAAW,CAAC,cAAc,aAGrC,MAAM,CAAC,IAAI,KATP,KAAK,CAUM,CACnB,CAAC;oBACJ,CAAC,CAAC,GACA,KACU,CACnB,CAAC;AACJ,CAAC,CAAC;AA9MW,QAAA,gBAAgB,oBA8M3B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type React from 'react';\n\nimport { Checkbox } from '../checkbox';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { ChevronDownIconOutline, ChevronRightIconOutline } from '../icons';\nimport { Skeleton } from '../skeleton';\nimport { Typography } from '../typography';\nimport {\n type FlattenedTreeItem,\n type TextItemData,\n type TreeItemComponentProps,\n} from './tree-view-types';\nimport { TreeItemWrapper } from './TreeItemWrapper';\n\n/**\n * checks if any parent is checked\n * @param item\n * @param items\n * @returns\n */\nconst parentIsCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const parent = items.find((i) => i.id === item.parentId);\n if (parent) {\n if (parent.isSelected) {\n return true;\n }\n return parentIsCheckedRecursively(parent, items);\n }\n return false;\n};\n\n/**\n * checks if any children are checked\n * @param item\n * @param items\n * @returns\n */\nconst childrenCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const children = items.filter((i) => i.parentId === item.id);\n if (children.length === 0) {\n return false;\n }\n return children.some(\n (i) => i.isSelected || childrenCheckedRecursively(i, items),\n );\n};\n\nexport const TreeViewTextItem = <T extends TextItemData>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n indentationWidth,\n isIndicator,\n isCollapsed,\n onCollapse,\n item,\n parent,\n isOver,\n isOverParent,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n trails,\n onItemsChanged,\n items,\n tabIndex,\n ref,\n ...restProps\n}: TreeItemComponentProps<T> & { ref?: React.Ref<HTMLElement> }) => {\n const isAnyParentChecked = parentIsCheckedRecursively(item, items);\n const isAnyChildChecked = childrenCheckedRecursively(item, items);\n\n const isIndeterminate =\n isAnyChildChecked === true &&\n isAnyParentChecked === false &&\n item.isSelected === false\n ? true\n : false;\n\n return (\n <TreeItemWrapper\n depth={depth}\n shouldDisableInteraction={shouldDisableInteraction}\n shouldDisableSorting={shouldDisableSorting}\n isGhost={isGhost}\n indentationWidth={indentationWidth}\n isIndicator={isIndicator}\n isCollapsed={isCollapsed}\n onCollapse={onCollapse}\n item={item}\n parent={parent}\n isOver={isOver}\n isOverParent={isOverParent}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n dragHandleProps={dragHandleProps}\n style={style}\n trails={trails}\n // oxlint-disable-next-line @typescript-eslint/no-empty-function\n onItemsChanged={() => {}}\n ref={ref}\n items={items}\n tabIndex={tabIndex}\n {...restProps}\n >\n {item.canHaveSubItems && onCollapse && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-collapse-button\"\n onClick={() => onCollapse()}\n aria-label={item.isCollapsed ? 'Expand' : 'Collapse'}\n aria-expanded={item.isCollapsed ? 'false' : 'true'}\n aria-pressed={!item.isCollapsed}\n /**\n * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab\n * since we use the arrow keys instead\n */\n tabIndex={tabIndex}\n >\n {item.isCollapsed && <ChevronRightIconOutline className=\"ndl-icon\" />}\n {!item.isCollapsed && <ChevronDownIconOutline className=\"ndl-icon\" />}\n </button>\n )}\n {item.isSelected !== undefined && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <Checkbox\n isIndeterminate={isIndeterminate}\n isChecked={item.isSelected}\n ariaLabel={item.data.text}\n htmlAttributes={{\n tabIndex,\n }}\n onChange={(event) => {\n const newItems = items.map((i) => {\n if (i.id === item.id) {\n return {\n ...i,\n isSelected: event.target.checked,\n };\n }\n return i;\n });\n\n // Uncheck parents if a child is unchecked\n if (!event.target.checked) {\n let parentId = item.parentId;\n while (parentId !== null) {\n const parent = newItems.find(\n (newItem) => newItem.id === parentId,\n );\n if (parent) {\n newItems.forEach((newItem) => {\n if (newItem.id === parent.id) {\n newItem.isSelected = false;\n }\n });\n parentId = parent.parentId;\n } else {\n parentId = null;\n }\n }\n }\n // Check children if a parent is checked\n if (item.canHaveSubItems) {\n const childIdsToUncheck = items\n .filter((i) => i.parentId === item.id)\n .map((i) => i.id);\n while (childIdsToUncheck.length > 0) {\n const childId = childIdsToUncheck.pop();\n const child = items.find((i) => i.id === childId);\n if (child) {\n newItems.forEach((newItem) => {\n if (newItem.id === child.id) {\n newItem.isSelected = event.target.checked;\n }\n });\n newItems\n .filter((i) => i.parentId === child.id)\n .forEach((i) => {\n childIdsToUncheck.push(i.id);\n });\n }\n }\n }\n onItemsChanged(newItems, { item, reason: 'selected' });\n }}\n aria-label={item.data.text}\n />\n </Skeleton>\n )}\n\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n height=\"20px\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <ConditionalWrap\n shouldWrap={item.data.onTextClick !== undefined}\n wrap={(children) => (\n <button\n type=\"button\"\n onClick={item.data.onTextClick}\n className=\"ndl-tree-view-text-clickable\"\n tabIndex={tabIndex}\n >\n {children}\n </button>\n )}\n >\n <Typography\n variant={item.canHaveSubItems ? 'subheading-small' : 'body-medium'}\n htmlAttributes={{\n style: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n }}\n >\n {item.data.text}\n </Typography>\n </ConditionalWrap>\n </Skeleton>\n <div className=\"ndl-tree-view-actions\">\n {item.data.actions &&\n item.data.actions.map((action, index) => {\n return (\n <CleanIconButton\n key={index}\n className=\"ndl-tree-view-action\"\n size=\"small\"\n {...action.buttonProps}\n htmlAttributes={{\n tabIndex,\n ...action.buttonProps.htmlAttributes,\n }}\n >\n {action.icon}\n </CleanIconButton>\n );\n })}\n </div>\n </TreeItemWrapper>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsBA,0CAAuC;AACvC,4DAAuD;AACvD,0DAAsD;AACtD,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uBAAC,mCAAe,kBAEd,SAAS,EAAC,sBAAsB,EAChC,IAAI,EAAC,OAAO,IACR,MAAM,CAAC,WAAW,IACtB,cAAc,kBACZ,QAAQ,IACL,MAAM,CAAC,WAAW,CAAC,cAAc,aAGrC,MAAM,CAAC,IAAI,KATP,KAAK,CAUM,CACnB,CAAC;oBACJ,CAAC,CAAC,GACA,KACU,CACnB,CAAC;AACJ,CAAC,CAAC;AA7MW,QAAA,gBAAgB,oBA6M3B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type React from 'react';\n\nimport { Checkbox } from '../checkbox';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { ChevronDownIconOutline, ChevronRightIconOutline } from '../icons';\nimport { Skeleton } from '../skeleton';\nimport { Typography } from '../typography';\nimport {\n type FlattenedTreeItem,\n type TextItemData,\n type TreeItemComponentProps,\n} from './tree-view-types';\nimport { TreeItemWrapper } from './TreeItemWrapper';\n\n/**\n * checks if any parent is checked\n * @param item\n * @param items\n * @returns\n */\nconst parentIsCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const parent = items.find((i) => i.id === item.parentId);\n if (parent) {\n if (parent.isSelected) {\n return true;\n }\n return parentIsCheckedRecursively(parent, items);\n }\n return false;\n};\n\n/**\n * checks if any children are checked\n * @param item\n * @param items\n * @returns\n */\nconst childrenCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const children = items.filter((i) => i.parentId === item.id);\n if (children.length === 0) {\n return false;\n }\n return children.some(\n (i) => i.isSelected || childrenCheckedRecursively(i, items),\n );\n};\n\nexport const TreeViewTextItem = <T extends TextItemData>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n indentationWidth,\n isIndicator,\n isCollapsed,\n onCollapse,\n item,\n parent,\n isOver,\n isOverParent,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n trails,\n onItemsChanged,\n items,\n tabIndex,\n ref,\n ...restProps\n}: TreeItemComponentProps<T> & { ref?: React.Ref<HTMLElement> }) => {\n const isAnyParentChecked = parentIsCheckedRecursively(item, items);\n const isAnyChildChecked = childrenCheckedRecursively(item, items);\n\n const isIndeterminate =\n isAnyChildChecked === true &&\n isAnyParentChecked === false &&\n item.isSelected === false\n ? true\n : false;\n\n return (\n <TreeItemWrapper\n depth={depth}\n shouldDisableInteraction={shouldDisableInteraction}\n shouldDisableSorting={shouldDisableSorting}\n isGhost={isGhost}\n indentationWidth={indentationWidth}\n isIndicator={isIndicator}\n isCollapsed={isCollapsed}\n onCollapse={onCollapse}\n item={item}\n parent={parent}\n isOver={isOver}\n isOverParent={isOverParent}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n dragHandleProps={dragHandleProps}\n style={style}\n trails={trails}\n // oxlint-disable-next-line @typescript-eslint/no-empty-function\n onItemsChanged={() => {}}\n ref={ref}\n items={items}\n tabIndex={tabIndex}\n {...restProps}\n >\n {item.canHaveSubItems && onCollapse && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-collapse-button\"\n onClick={() => onCollapse()}\n aria-label={item.isCollapsed ? 'Expand' : 'Collapse'}\n aria-expanded={item.isCollapsed ? 'false' : 'true'}\n /**\n * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab\n * since we use the arrow keys instead\n */\n tabIndex={tabIndex}\n >\n {item.isCollapsed && <ChevronRightIconOutline className=\"ndl-icon\" />}\n {!item.isCollapsed && <ChevronDownIconOutline className=\"ndl-icon\" />}\n </button>\n )}\n {item.isSelected !== undefined && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <Checkbox\n isIndeterminate={isIndeterminate}\n isChecked={item.isSelected}\n ariaLabel={item.data.text}\n htmlAttributes={{\n tabIndex,\n }}\n onChange={(event) => {\n const newItems = items.map((i) => {\n if (i.id === item.id) {\n return {\n ...i,\n isSelected: event.target.checked,\n };\n }\n return i;\n });\n\n // Uncheck parents if a child is unchecked\n if (!event.target.checked) {\n let parentId = item.parentId;\n while (parentId !== null) {\n const parent = newItems.find(\n (newItem) => newItem.id === parentId,\n );\n if (parent) {\n newItems.forEach((newItem) => {\n if (newItem.id === parent.id) {\n newItem.isSelected = false;\n }\n });\n parentId = parent.parentId;\n } else {\n parentId = null;\n }\n }\n }\n // Check children if a parent is checked\n if (item.canHaveSubItems) {\n const childIdsToUncheck = items\n .filter((i) => i.parentId === item.id)\n .map((i) => i.id);\n while (childIdsToUncheck.length > 0) {\n const childId = childIdsToUncheck.pop();\n const child = items.find((i) => i.id === childId);\n if (child) {\n newItems.forEach((newItem) => {\n if (newItem.id === child.id) {\n newItem.isSelected = event.target.checked;\n }\n });\n newItems\n .filter((i) => i.parentId === child.id)\n .forEach((i) => {\n childIdsToUncheck.push(i.id);\n });\n }\n }\n }\n onItemsChanged(newItems, { item, reason: 'selected' });\n }}\n aria-label={item.data.text}\n />\n </Skeleton>\n )}\n\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n height=\"20px\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <ConditionalWrap\n shouldWrap={item.data.onTextClick !== undefined}\n wrap={(children) => (\n <button\n type=\"button\"\n onClick={item.data.onTextClick}\n className=\"ndl-tree-view-text-clickable\"\n tabIndex={tabIndex}\n >\n {children}\n </button>\n )}\n >\n <Typography\n variant={item.canHaveSubItems ? 'subheading-small' : 'body-medium'}\n htmlAttributes={{\n style: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n }}\n >\n {item.data.text}\n </Typography>\n </ConditionalWrap>\n </Skeleton>\n <div className=\"ndl-tree-view-actions\">\n {item.data.actions &&\n item.data.actions.map((action, index) => {\n return (\n <CleanIconButton\n key={index}\n className=\"ndl-tree-view-action\"\n size=\"small\"\n {...action.buttonProps}\n htmlAttributes={{\n tabIndex,\n ...action.buttonProps.htmlAttributes,\n }}\n >\n {action.icon}\n </CleanIconButton>\n );\n })}\n </div>\n </TreeItemWrapper>\n );\n};\n"]}
|
|
@@ -32,10 +32,10 @@ const TREE_ITEMS = [
|
|
|
32
32
|
actions: [
|
|
33
33
|
{
|
|
34
34
|
buttonProps: {
|
|
35
|
+
description: 'Edit',
|
|
35
36
|
onClick: () => {
|
|
36
37
|
alert('Pencil was clicked');
|
|
37
38
|
},
|
|
38
|
-
tooltip: 'Edit',
|
|
39
39
|
},
|
|
40
40
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
41
41
|
},
|
|
@@ -56,10 +56,10 @@ const TREE_ITEMS = [
|
|
|
56
56
|
actions: [
|
|
57
57
|
{
|
|
58
58
|
buttonProps: {
|
|
59
|
+
description: 'Edit',
|
|
59
60
|
onClick: () => {
|
|
60
61
|
alert('Pencil was clicked');
|
|
61
62
|
},
|
|
62
|
-
tooltip: 'Edit',
|
|
63
63
|
},
|
|
64
64
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
65
65
|
},
|
|
@@ -79,10 +79,10 @@ const TREE_ITEMS = [
|
|
|
79
79
|
actions: [
|
|
80
80
|
{
|
|
81
81
|
buttonProps: {
|
|
82
|
+
description: 'Edit',
|
|
82
83
|
onClick: () => {
|
|
83
84
|
alert('Pencil was clicked');
|
|
84
85
|
},
|
|
85
|
-
tooltip: 'Edit',
|
|
86
86
|
},
|
|
87
87
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
88
88
|
},
|
|
@@ -102,10 +102,10 @@ const TREE_ITEMS = [
|
|
|
102
102
|
actions: [
|
|
103
103
|
{
|
|
104
104
|
buttonProps: {
|
|
105
|
+
description: 'Edit',
|
|
105
106
|
onClick: () => {
|
|
106
107
|
alert('Pencil was clicked');
|
|
107
108
|
},
|
|
108
|
-
tooltip: 'Edit',
|
|
109
109
|
},
|
|
110
110
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
111
111
|
},
|
|
@@ -125,10 +125,10 @@ const TREE_ITEMS = [
|
|
|
125
125
|
actions: [
|
|
126
126
|
{
|
|
127
127
|
buttonProps: {
|
|
128
|
+
description: 'Edit',
|
|
128
129
|
onClick: () => {
|
|
129
130
|
alert('Pencil was clicked');
|
|
130
131
|
},
|
|
131
|
-
tooltip: 'Edit',
|
|
132
132
|
},
|
|
133
133
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
134
134
|
},
|
|
@@ -149,10 +149,10 @@ const TREE_ITEMS = [
|
|
|
149
149
|
actions: [
|
|
150
150
|
{
|
|
151
151
|
buttonProps: {
|
|
152
|
+
description: 'Edit',
|
|
152
153
|
onClick: () => {
|
|
153
154
|
alert('Pencil was clicked');
|
|
154
155
|
},
|
|
155
|
-
tooltip: 'Edit',
|
|
156
156
|
},
|
|
157
157
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
158
158
|
},
|
|
@@ -171,10 +171,10 @@ const TREE_ITEMS = [
|
|
|
171
171
|
actions: [
|
|
172
172
|
{
|
|
173
173
|
buttonProps: {
|
|
174
|
+
description: 'Edit',
|
|
174
175
|
onClick: () => {
|
|
175
176
|
alert('Pencil was clicked');
|
|
176
177
|
},
|
|
177
|
-
tooltip: 'Edit',
|
|
178
178
|
},
|
|
179
179
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
180
180
|
},
|
|
@@ -193,10 +193,10 @@ const TREE_ITEMS = [
|
|
|
193
193
|
actions: [
|
|
194
194
|
{
|
|
195
195
|
buttonProps: {
|
|
196
|
+
description: 'Edit',
|
|
196
197
|
onClick: () => {
|
|
197
198
|
alert('Pencil was clicked');
|
|
198
199
|
},
|
|
199
|
-
tooltip: 'Edit',
|
|
200
200
|
},
|
|
201
201
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
202
202
|
},
|
|
@@ -219,10 +219,10 @@ const TREE_ITEMS = [
|
|
|
219
219
|
actions: [
|
|
220
220
|
{
|
|
221
221
|
buttonProps: {
|
|
222
|
+
description: 'Edit',
|
|
222
223
|
onClick: () => {
|
|
223
224
|
alert('Pencil was clicked');
|
|
224
225
|
},
|
|
225
|
-
tooltip: 'Edit',
|
|
226
226
|
},
|
|
227
227
|
icon: (0, jsx_runtime_1.jsx)(icons_1.PencilIconOutline, {}),
|
|
228
228
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeview-default.story.js","sourceRoot":"","sources":["../../../../src/tree-view/stories/treeview-default.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAA4C;AAC5C,kDAA2D;AAE3D,iCAAiC;AAEjC,MAAM,UAAU,GAAmD;IACjE;QACE,eAAe,EAAE,IAAI;QACrB,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP;oBACE,WAAW,EAAE;wBACX,OAAO,EAAE,GAAG,EAAE;4BACZ,KAAK,CAAC,oBAAoB,CAAC,CAAC;wBAC9B,CAAC;wBACD,OAAO,EAAE,MAAM;qBAChB;oBACD,IAAI,EAAE,uBAAC,yBAAiB,KAAG;iBAC5B;aACF;YACD,WAAW,EAAE,GAAG,EAAE;gBAChB,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YAC5B,CAAC;YACD,IAAI,EAAE,SAAS;SAChB;QACD,EAAE,EAAE,SAAS;QACb,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,IAAI;KACjB;CACF,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GACrB,IAAA,gBAAQ,EAAiD,UAAU,CAAC,CAAC;IAEvE,OAAO,CACL,uBAAC,gBAAQ,IACP,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,EAAE;YAC9C,gDAAgD;YAChD,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,iBAAiB,CAAC,CAAC;YACjE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC,EACD,iBAAiB,EAAE,SAAS,GAC5B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TreeView } from '@neo4j-ndl/react';\nimport { PencilIconOutline } from '@neo4j-ndl/react/icons';\nimport type React from 'react';\nimport { useState } from 'react';\n\nconst TREE_ITEMS: React.ComponentProps<typeof TreeView>['items'] = [\n {\n canHaveSubItems: true,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Folder 1',\n },\n id: 'Folder 1',\n isCollapsed: false,\n isSelected: false,\n isSortable: false,\n subItems: [\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 1',\n },\n id: 'Child 1',\n isSelected: false,\n isSortable: true,\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 2',\n },\n id: 'Child 2',\n isSelected: false,\n isSortable: true,\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 3',\n },\n id: 'Child 3',\n isSelected: false,\n isSortable: true,\n },\n {\n canHaveSubItems: true,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Folder 2',\n },\n id: 'Folder 2',\n isCollapsed: true,\n isSelected: false,\n isSortable: true,\n subItems: [\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 4',\n },\n\n id: 'Child 4',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 5',\n },\n id: 'Child 5',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 6',\n },\n id: 'Child 6',\n isSelected: false,\n },\n ],\n },\n ],\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n onClick: () => {\n alert('Pencil was clicked');\n },\n tooltip: 'Edit',\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 7',\n },\n id: 'Child 7',\n isSelected: false,\n isSortable: true,\n },\n];\n\nconst Component = () => {\n const [items, setItems] =\n useState<React.ComponentProps<typeof TreeView>['items']>(TREE_ITEMS);\n\n return (\n <TreeView\n items={items}\n onItemsChanged={(newItems, itemChangedReason) => {\n // eslint-disable-next-line no-restricted-syntax\n console.log('change with itemChangedReason:', itemChangedReason);\n setItems(newItems);\n }}\n TreeItemComponent={undefined}\n />\n );\n};\n\nexport default Component;\n"]}
|
|
1
|
+
{"version":3,"file":"treeview-default.story.js","sourceRoot":"","sources":["../../../../src/tree-view/stories/treeview-default.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAA4C;AAC5C,kDAA2D;AAE3D,iCAAiC;AAEjC,MAAM,UAAU,GAAmD;IACjE;QACE,eAAe,EAAE,IAAI;QACrB,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP;oBACE,WAAW,EAAE;wBACX,WAAW,EAAE,MAAM;wBACnB,OAAO,EAAE,GAAG,EAAE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C,CAAC;wBAC9B,CAAC;qBACF;oBACD,IAAI,EAAE,uBAAC,yBAAiB,KAAG;iBAC5B;aACF;YACD,WAAW,EAAE,GAAG,EAAE;gBAChB,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC5B,CAAC;YACD,IAAI,EAAE,SAAS;SAChB;QACD,EAAE,EAAE,SAAS;QACb,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,IAAI;KACjB;CACF,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GACrB,IAAA,gBAAQ,EAAiD,UAAU,CAAC,CAAC;IAEvE,OAAO,CACL,uBAAC,gBAAQ,IACP,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,EAAE;YAC9C,gDAAgD;YAChD,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,iBAAiB,CAAC,CAAC;YACjE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC,EACD,iBAAiB,EAAE,SAAS,GAC5B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TreeView } from '@neo4j-ndl/react';\nimport { PencilIconOutline } from '@neo4j-ndl/react/icons';\nimport type React from 'react';\nimport { useState } from 'react';\n\nconst TREE_ITEMS: React.ComponentProps<typeof TreeView>['items'] = [\n {\n canHaveSubItems: true,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Folder 1',\n },\n id: 'Folder 1',\n isCollapsed: false,\n isSelected: false,\n isSortable: false,\n subItems: [\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 1',\n },\n id: 'Child 1',\n isSelected: false,\n isSortable: true,\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 2',\n },\n id: 'Child 2',\n isSelected: false,\n isSortable: true,\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 3',\n },\n id: 'Child 3',\n isSelected: false,\n isSortable: true,\n },\n {\n canHaveSubItems: true,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Folder 2',\n },\n id: 'Folder 2',\n isCollapsed: true,\n isSelected: false,\n isSortable: true,\n subItems: [\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 4',\n },\n\n id: 'Child 4',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 5',\n },\n id: 'Child 5',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 6',\n },\n id: 'Child 6',\n isSelected: false,\n },\n ],\n },\n ],\n },\n {\n canHaveSubItems: false,\n data: {\n actions: [\n {\n buttonProps: {\n description: 'Edit',\n onClick: () => {\n alert('Pencil was clicked');\n },\n },\n icon: <PencilIconOutline />,\n },\n ],\n onTextClick: () => {\n alert('Text was clicked');\n },\n text: 'Child 7',\n },\n id: 'Child 7',\n isSelected: false,\n isSortable: true,\n },\n];\n\nconst Component = () => {\n const [items, setItems] =\n useState<React.ComponentProps<typeof TreeView>['items']>(TREE_ITEMS);\n\n return (\n <TreeView\n items={items}\n onItemsChanged={(newItems, itemChangedReason) => {\n // eslint-disable-next-line no-restricted-syntax\n console.log('change with itemChangedReason:', itemChangedReason);\n setItems(newItems);\n }}\n TreeItemComponent={undefined}\n />\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-view-types.js","sourceRoot":"","sources":["../../../src/tree-view/tree-view-types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { type UniqueIdentifier } from '@dnd-kit/core';\nimport { type RefAttributes } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { type IconButton } from '../icon-button';\nimport { type Skeleton } from '../skeleton';\n\nexport type TreeItem<T> =\n | {\n id: UniqueIdentifier;\n canHaveSubItems: false;\n isSortable?: boolean;\n data: T;\n isSelected?: boolean;\n isSkeletonLoading?: boolean;\n skeletonProps?: React.ComponentProps<typeof Skeleton>;\n }\n | {\n id: UniqueIdentifier;\n canHaveSubItems: true;\n isCollapsed: boolean;\n subItems: TreeItem<T>[];\n isSortable?: boolean;\n data: T;\n isSelected?: boolean;\n isSkeletonLoading?: boolean;\n skeletonProps?: React.ComponentProps<typeof Skeleton>;\n };\n\nexport type TextItemData = {\n text: string;\n onTextClick?: () => void;\n actions: {\n icon: React.ReactNode;\n buttonProps: Omit<\n React.ComponentPropsWithoutRef<typeof IconButton>,\n 'children' | 'as'\n >;\n }[];\n};\nexport type DefaultTreeItem = TreeItem<TextItemData>;\n\nexport type FlattenedTreeItem<T> = TreeItem<T> & {\n depth: number;\n parentId: UniqueIdentifier | null;\n};\n\nexport type TreeItemComponent<\n T extends Record<string, unknown>,\n TElement extends HTMLElement,\n> = React.FC<\n React.PropsWithChildren<TreeItemComponentProps<T> & RefAttributes<TElement>>\n>;\n\nexport type TreeItemComponentProps<T extends Record<string, unknown>> = Omit<\n CommonProps<\n 'div',\n {\n /** The tree item data */\n item: FlattenedTreeItem<T>;\n /** Parent item of this item */\n parent: FlattenedTreeItem<T> | null;\n\n /** If the item is should be rendered as a placeholder (for example, while dragging) */\n isGhost?: boolean;\n\n /** If the item is collapsed */\n isCollapsed?: boolean;\n\n /** Depth of the item in the tree */\n depth: number;\n\n /** While dragging it makes sense to disable some interaction for all other items. */\n shouldDisableInteraction?: boolean;\n\n /** True if sorting is disabled for this item. */\n shouldDisableSorting?: boolean;\n\n /** True if dragged item is over this Node. */\n isOver: boolean;\n\n /** True if dragged item is over the parent of this Node. */\n isOverParent: boolean;\n\n /** True if this item is the last in the parent list */\n isLastInParent: boolean;\n\n /** True if the item should be rendered as a indicator (for example, while dragging) */\n isIndicator?: boolean;\n\n /** Width of the indentation */\n indentationWidth: number;\n\n /** Function to call when the item is collapsed/expanded */\n onCollapse?(): void;\n\n /** Function to set the ref of the element that should activate sorting */\n setActivatorNodeRef: (node: HTMLElement | null) => void;\n\n /** Function to set the ref of the element that should be sorted (the wrapper element of the item) */\n setNodeRef: (node: HTMLLIElement) => void;\n\n /** Props for the drag handle */\n dragHandleProps?: Record<string, unknown>;\n\n /** A list of trails to render before the item */\n trails: ('none' | 'straight' | 'straight-curved' | 'curved')[];\n\n /** Function to call when the item has changed */\n onItemsChanged: (\n newItems: FlattenedTreeItem<T>[],\n reason: ItemChangedReason<T>,\n ) => void;\n\n /** All items in the tree */\n items: FlattenedTreeItem<T>[];\n tabIndex?: number;\n\n /** Function to call when the item receives focus */\n onFocus?: () => void;\n }\n >,\n 'htmlAttributes'\n>;\n\nexport type ItemChangedReason<T> = {\n /** The item that was changed */\n item: TreeItem<T>;\n /** The reason for the change */\n reason: 'collapsed' | 'expanded' | 'dropped' | 'selected' | 'other';\n};\n"]}
|
|
1
|
+
{"version":3,"file":"tree-view-types.js","sourceRoot":"","sources":["../../../src/tree-view/tree-view-types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { type UniqueIdentifier } from '@dnd-kit/core';\nimport { type RefAttributes } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { type IconButton } from '../icon-button';\nimport { type Skeleton } from '../skeleton';\n\nexport type TreeItem<T> =\n | {\n id: UniqueIdentifier;\n canHaveSubItems: false;\n isSortable?: boolean;\n data: T;\n isSelected?: boolean;\n isSkeletonLoading?: boolean;\n skeletonProps?: React.ComponentProps<typeof Skeleton>;\n }\n | {\n id: UniqueIdentifier;\n canHaveSubItems: true;\n isCollapsed: boolean;\n subItems: TreeItem<T>[];\n isSortable?: boolean;\n data: T;\n isSelected?: boolean;\n isSkeletonLoading?: boolean;\n skeletonProps?: React.ComponentProps<typeof Skeleton>;\n };\n\nexport type TextItemData = {\n text: string;\n onTextClick?: () => void;\n actions: {\n icon: React.ReactNode;\n buttonProps: Omit<\n React.ComponentPropsWithoutRef<typeof IconButton>,\n 'children' | 'as'\n >;\n }[];\n};\nexport type DefaultTreeItem = TreeItem<TextItemData>;\n\nexport type FlattenedTreeItem<T> = TreeItem<T> & {\n depth: number;\n parentId: UniqueIdentifier | null;\n};\n\nexport type TreeItemComponent<\n T extends Record<string, unknown>,\n TElement extends HTMLElement,\n> = React.FC<\n React.PropsWithChildren<TreeItemComponentProps<T> & RefAttributes<TElement>>\n>;\n\nexport type TreeItemComponentProps<T extends Record<string, unknown>> = Omit<\n CommonProps<\n 'div',\n {\n /** The tree item data */\n item: FlattenedTreeItem<T>;\n /** Parent item of this item */\n parent: FlattenedTreeItem<T> | null;\n\n /** If the item is should be rendered as a placeholder (for example, while dragging) */\n isGhost?: boolean;\n\n /** If the item is collapsed */\n isCollapsed?: boolean;\n\n /** Depth of the item in the tree */\n depth: number;\n\n /** While dragging it makes sense to disable some interaction for all other items. */\n shouldDisableInteraction?: boolean;\n\n /** True if sorting is disabled for this item. */\n shouldDisableSorting?: boolean;\n\n /** True if dragged item is over this Node. */\n isOver: boolean;\n\n /** True if dragged item is over the parent of this Node. */\n isOverParent: boolean;\n\n /** True if this item is the last in the parent list */\n isLastInParent: boolean;\n\n /** True if the item should be rendered as a indicator (for example, while dragging) */\n isIndicator?: boolean;\n\n /** Width of the indentation */\n indentationWidth: number;\n\n /** Function to call when the item is collapsed/expanded */\n onCollapse?(): void;\n\n /** Function to set the ref of the element that should activate sorting */\n setActivatorNodeRef: (node: HTMLElement | null) => void;\n\n /** Function to set the ref of the element that should be sorted (the wrapper element of the item) */\n setNodeRef: (node: HTMLLIElement) => void;\n\n /** Props for the drag handle */\n dragHandleProps?: Record<string, unknown>;\n\n /** A list of trails to render before the item */\n trails: ('none' | 'straight' | 'straight-curved' | 'curved')[];\n\n /** Function to call when the item has changed */\n onItemsChanged: (\n newItems: FlattenedTreeItem<T>[],\n reason: ItemChangedReason<T>,\n ) => void;\n\n /** All items in the tree */\n items: FlattenedTreeItem<T>[];\n tabIndex?: number;\n ariaLevel?: number;\n ariaPosInSet?: number;\n ariaSetSize?: number;\n\n /** Function to call when the item receives focus */\n onFocus?: () => void;\n }\n >,\n 'htmlAttributes'\n>;\n\nexport type ItemChangedReason<T> = {\n /** The item that was changed */\n item: TreeItem<T>;\n /** The reason for the change */\n reason: 'collapsed' | 'expanded' | 'dropped' | 'selected' | 'other';\n};\n"]}
|
|
@@ -71,11 +71,11 @@ export const CodeBlockWrapper = (_a) => {
|
|
|
71
71
|
'ndl-disabled': isDisabled,
|
|
72
72
|
}), style: {
|
|
73
73
|
maxWidth: `calc(100% - ${((_b = actions === null || actions === void 0 ? void 0 : actions.length) !== null && _b !== void 0 ? _b : 0) * 36 + 20}px)`,
|
|
74
|
-
}, "data-testid": "ndl-code-block-title", children: heading })),
|
|
74
|
+
}, "data-testid": "ndl-code-block-title", children: heading })), _jsx("div", { className: classNames('ndl-code-content-container', {
|
|
75
75
|
'ndl-disabled': isDisabled,
|
|
76
76
|
}), style: {
|
|
77
77
|
height: Boolean(heading) === true ? 'calc(100% - 24px - 12px)' : '100%',
|
|
78
|
-
}, children:
|
|
78
|
+
}, children: _jsx("div", { ref: syntaxHighlighterWrapperRef, className: "ndl-highlight-wrapper", children: children }) })] }), _jsx("div", { className: classNames('ndl-code-block-actions', {
|
|
79
79
|
'ndl-disabled': isDisabled,
|
|
80
80
|
}), children: actions === null || actions === void 0 ? void 0 : actions.map((iconButtonProps, i) => {
|
|
81
81
|
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,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAgBxE,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,CAAC,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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,KAEf,wBAAwB,GAPvB,CAAC,CAQN,CACH,CAAC;gBACJ,CAAC,CAAC,GACE,EACL,sBAAsB,IAAI,CACzB,cAAK,SAAS,EAAC,8BAA8B,YAC3C,KAAC,eAAe,IACd,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,EAC/C,YAAY,EAAE;wBACZ,IAAI,EAAE;4BACJ,2BAA2B,EAAE,IAAI;yBAClC;qBACF,EACD,OAAO,EAAE,GAAG,EAAE;wBACZ,IAAI,UAAU,EAAE,CAAC;4BACf,kBAAkB,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC;4BACrC,aAAa,CAAC,KAAK,CAAC,CAAC;wBACvB,CAAC;6BAAM,CAAC;4BACN,kBAAkB,CAAC,aAAa,CAAC,CAAC;4BAClC,aAAa,CAAC,IAAI,CAAC,CAAC;wBACtB,CAAC;oBACH,CAAC,YAEA,UAAU,CAAC,CAAC,CAAC,KAAC,oBAAoB,KAAG,CAAC,CAAC,CAAC,KAAC,sBAAsB,KAAG,GACnD,GACd,CACP,KACS,CACb,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport 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"]}
|
|
@@ -93,7 +93,7 @@ export const CodeBlock = (_a) => {
|
|
|
93
93
|
border: 0,
|
|
94
94
|
color: 'var(--theme-color-neutral-text-default)',
|
|
95
95
|
lineHeight: '1',
|
|
96
|
-
padding: `0 ${calculateRightPadding !== null && calculateRightPadding !== void 0 ? calculateRightPadding : 0}px 0.75em
|
|
96
|
+
padding: `0 ${calculateRightPadding !== null && calculateRightPadding !== void 0 ? calculateRightPadding : 0}px 0.75em 0.75em`,
|
|
97
97
|
width: 'fit-content',
|
|
98
98
|
} }),
|
|
99
99
|
// 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,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EACL,6BAA6B,EAC7B,GAAG,EACH,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,cAAc,EACd,EAAE,GACH,MAAM,gDAAgD,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAqB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,YAAY,MAAM,yBAAyB,CAAC;AAsBnD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAyC,EAetB,EAAE,EAAE;QAfkB,EAChE,EAAE,EACF,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,qBAAqB,EACrB,KAAK,EACL,OAAO,EACP,OAAO,EACP,UAAU,EACV,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,OAEuC,EADvC,SAAS,cAdoD,4JAejE,CADa;IAEZ,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAClE,SAAS,KAAK,SAAS,CACxB,CAAC;IAEF,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;IAC7C,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAElD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,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,KAAC,iBAAiB,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","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,OAAO,EACL,oBAAoB,EACpB,cAAc,EAGd,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;A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D,OAAO,CAAC,OAAO,sBACd,OAAO,CAAC,aAAa,EACvC,KAAK,gDACA,OAAO,CAAC,cAAc,GACtB,OAAO,CAAC,gBAAgB,GACxB,KAAK,GAEV,GAAG,EAAE,IAAI,IACL,OAAO,CAAC,gBAAgB,mBAAM,cAAc,EAAG,EAC/C,SAAS,cAEZ,QAAQ,IACC,GACS,GACP,CACnB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,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 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,OAAO,EACL,oBAAoB,EACpB,cAAc,EAGd,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAgB5E,MAAM,CAAC,MAAM,oBAAoB,GAAwC;IACvE,yBAAyB,EAAE,WAAW;IACtC,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P,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;AAEH,OAAO,EAAE,OAAO,EAAE,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 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"]}
|
|
@@ -77,16 +77,17 @@ export function usePopover({ isInitialOpen = false, placement = 'bottom', isOpen
|
|
|
77
77
|
const { styles: transitionStyles } = useTransitionStyles(context, {
|
|
78
78
|
duration: (_a = Number.parseInt(tokens.motion.duration.quick)) !== null && _a !== void 0 ? _a : 0,
|
|
79
79
|
});
|
|
80
|
-
return useMemo(() => (Object.assign(Object.assign(Object.assign({
|
|
81
|
-
labelId,
|
|
80
|
+
return useMemo(() => (Object.assign(Object.assign(Object.assign({}, data), interactions), { anchorElementAsPortalAnchor,
|
|
82
81
|
descriptionId,
|
|
83
|
-
setLabelId,
|
|
84
|
-
setDescriptionId,
|
|
85
|
-
anchorElementAsPortalAnchor,
|
|
86
|
-
shouldCaptureFocus,
|
|
87
82
|
initialFocus,
|
|
83
|
+
isOpen,
|
|
88
84
|
isPortaled,
|
|
89
|
-
|
|
85
|
+
labelId,
|
|
86
|
+
returnFocus,
|
|
87
|
+
setDescriptionId,
|
|
88
|
+
setLabelId,
|
|
89
|
+
shouldCaptureFocus,
|
|
90
|
+
transitionStyles })), [
|
|
90
91
|
isOpen,
|
|
91
92
|
interactions,
|
|
92
93
|
data,
|