@neo4j-ndl/react 4.8.3 → 4.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/lib/cjs/accordion/Accordion.js +1 -1
  2. package/lib/cjs/accordion/Accordion.js.map +1 -1
  3. package/lib/cjs/ai/prompt/Prompt.js +1 -1
  4. package/lib/cjs/ai/prompt/Prompt.js.map +1 -1
  5. package/lib/cjs/ai/suggestion/Suggestion.js +1 -1
  6. package/lib/cjs/ai/suggestion/Suggestion.js.map +1 -1
  7. package/lib/cjs/breadcrumbs/Breadcrumbs.js +1 -1
  8. package/lib/cjs/breadcrumbs/Breadcrumbs.js.map +1 -1
  9. package/lib/cjs/breadcrumbs/stories/breadcrumbs-header.story.js +1 -1
  10. package/lib/cjs/breadcrumbs/stories/breadcrumbs-header.story.js.map +1 -1
  11. package/lib/cjs/color-picker/ColorPicker.js +1 -1
  12. package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
  13. package/lib/cjs/date-picker/DatePicker.js +2 -2
  14. package/lib/cjs/date-picker/DatePicker.js.map +1 -1
  15. package/lib/cjs/graph-label/GraphLabel.js +5 -1
  16. package/lib/cjs/graph-label/GraphLabel.js.map +1 -1
  17. package/lib/cjs/inline-edit/InlineEdit.js +1 -1
  18. package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
  19. package/lib/cjs/select-icon-button/SelectIconButton.js +1 -1
  20. package/lib/cjs/select-icon-button/SelectIconButton.js.map +1 -1
  21. package/lib/cjs/side-navigation/SideNavigation.js +1 -1
  22. package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
  23. package/lib/cjs/tabs/Tabs.js +1 -1
  24. package/lib/cjs/tabs/Tabs.js.map +1 -1
  25. package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js +2 -2
  26. package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -1
  27. package/lib/cjs/tooltip/Tooltip.js +1 -1
  28. package/lib/cjs/tooltip/Tooltip.js.map +1 -1
  29. package/lib/cjs/tree-view/TreeItemWrapper.js +1 -1
  30. package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
  31. package/lib/cjs/tree-view/TreeViewTextItem.js +2 -2
  32. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  33. package/lib/cjs/tree-view/stories/treeview-custom.story.js +1 -1
  34. package/lib/cjs/tree-view/stories/treeview-custom.story.js.map +1 -1
  35. package/lib/esm/accordion/Accordion.js +1 -1
  36. package/lib/esm/accordion/Accordion.js.map +1 -1
  37. package/lib/esm/ai/prompt/Prompt.js +1 -1
  38. package/lib/esm/ai/prompt/Prompt.js.map +1 -1
  39. package/lib/esm/ai/suggestion/Suggestion.js +1 -1
  40. package/lib/esm/ai/suggestion/Suggestion.js.map +1 -1
  41. package/lib/esm/breadcrumbs/Breadcrumbs.js +1 -1
  42. package/lib/esm/breadcrumbs/Breadcrumbs.js.map +1 -1
  43. package/lib/esm/breadcrumbs/stories/breadcrumbs-header.story.js +1 -1
  44. package/lib/esm/breadcrumbs/stories/breadcrumbs-header.story.js.map +1 -1
  45. package/lib/esm/color-picker/ColorPicker.js +1 -1
  46. package/lib/esm/color-picker/ColorPicker.js.map +1 -1
  47. package/lib/esm/date-picker/DatePicker.js +2 -2
  48. package/lib/esm/date-picker/DatePicker.js.map +1 -1
  49. package/lib/esm/graph-label/GraphLabel.js +5 -1
  50. package/lib/esm/graph-label/GraphLabel.js.map +1 -1
  51. package/lib/esm/inline-edit/InlineEdit.js +1 -1
  52. package/lib/esm/inline-edit/InlineEdit.js.map +1 -1
  53. package/lib/esm/select-icon-button/SelectIconButton.js +1 -1
  54. package/lib/esm/select-icon-button/SelectIconButton.js.map +1 -1
  55. package/lib/esm/side-navigation/SideNavigation.js +1 -1
  56. package/lib/esm/side-navigation/SideNavigation.js.map +1 -1
  57. package/lib/esm/tabs/Tabs.js +1 -1
  58. package/lib/esm/tabs/Tabs.js.map +1 -1
  59. package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js +2 -2
  60. package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -1
  61. package/lib/esm/tooltip/Tooltip.js +1 -1
  62. package/lib/esm/tooltip/Tooltip.js.map +1 -1
  63. package/lib/esm/tree-view/TreeItemWrapper.js +1 -1
  64. package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
  65. package/lib/esm/tree-view/TreeViewTextItem.js +2 -2
  66. package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
  67. package/lib/esm/tree-view/stories/treeview-custom.story.js +1 -1
  68. package/lib/esm/tree-view/stories/treeview-custom.story.js.map +1 -1
  69. package/lib/types/accordion/Accordion.d.ts.map +1 -1
  70. package/lib/types/ai/prompt/Prompt.d.ts.map +1 -1
  71. package/lib/types/ai/suggestion/Suggestion.d.ts.map +1 -1
  72. package/lib/types/breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  73. package/lib/types/breadcrumbs/stories/breadcrumbs-header.story.d.ts.map +1 -1
  74. package/lib/types/date-picker/DatePicker.d.ts.map +1 -1
  75. package/lib/types/graph-label/GraphLabel.d.ts.map +1 -1
  76. package/lib/types/inline-edit/InlineEdit.d.ts.map +1 -1
  77. package/lib/types/select-icon-button/SelectIconButton.d.ts.map +1 -1
  78. package/lib/types/side-navigation/SideNavigation.d.ts.map +1 -1
  79. package/lib/types/tabs/Tabs.d.ts.map +1 -1
  80. package/lib/types/timezone-picker/stories/timezone-picker-dst-aware.story.d.ts.map +1 -1
  81. package/lib/types/tooltip/Tooltip.d.ts.map +1 -1
  82. package/lib/types/tree-view/TreeItemWrapper.d.ts.map +1 -1
  83. package/lib/types/tree-view/TreeViewTextItem.d.ts.map +1 -1
  84. package/lib/types/tree-view/stories/treeview-custom.story.d.ts.map +1 -1
  85. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.t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AC,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;AA5MW,QAAA,gBAAgB,oBA4M3B","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 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 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,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,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jC,uBAAC,kCAAe,IACd,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,EAC/C,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAClB,mCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,IAAI,CAAC,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"]}
@@ -83,7 +83,7 @@ const Component = () => {
83
83
  background: !restProps.item.canHaveSubItems
84
84
  ? 'linear-gradient(in hsl longer hue 45deg, red 0 0)'
85
85
  : '',
86
- }, children: [restProps.item.canHaveSubItems && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(icons_1.FolderIconOutline, { className: "n-h-5 w-h-5" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => restProps.onCollapse && restProps.onCollapse(), children: restProps.item.isCollapsed ? ((0, jsx_runtime_1.jsx)(icons_1.ChevronUpIconSolid, { className: "n-h-5 w-h-5" })) : ((0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconSolid, { className: "n-h-5 w-h-5" })) })] })), 'custom' in restProps.item.data &&
86
+ }, children: [restProps.item.canHaveSubItems && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(icons_1.FolderIconOutline, { className: "n-h-5 w-h-5" }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => restProps.onCollapse && restProps.onCollapse(), children: restProps.item.isCollapsed ? ((0, jsx_runtime_1.jsx)(icons_1.ChevronUpIconSolid, { className: "n-h-5 w-h-5" })) : ((0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconSolid, { className: "n-h-5 w-h-5" })) })] })), 'custom' in restProps.item.data &&
87
87
  typeof restProps.item.data.custom === 'string' &&
88
88
  restProps.item.data.custom] }) })));
89
89
  } }));
@@ -1 +1 @@
1
- {"version":3,"file":"treeview-custom.story.js","sourceRoot":"","sources":["../../../../src/tree-view/stories/treeview-custom.story.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAA4C;AAC5C,kDAIgC;AAEhC,iCAAiC;AAEjC,MAAM,UAAU,GAAmD;IACjE;QACE,eAAe,EAAE,IAAI;QACrB,IAAI,EAAE;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I,CAAC,eAAe,IAAI,CACjC,6DACE,uBAAC,yBAAiB,IAAC,SAAS,EAAC,aAAa,GAAG,EAC7C,mCACE,OAAO,EAAE,GAAG,EAAE,CACZ,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU,EAAE,YAG/C,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAC5B,uBAAC,0BAAkB,IAAC,SAAS,EAAC,aAAa,GAAG,CAC/C,CAAC,CAAC,CAAC,CACF,uBAAC,4BAAoB,IAAC,SAAS,EAAC,aAAa,GAAG,CACjD,GACM,IACR,CACJ,EACA,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI;4BAC9B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,QAAQ;4BAC9C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IACxB,IACmB,CAC5B,CAAC;QACJ,CAAC,GACD,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 {\n ChevronDownIconSolid,\n ChevronUpIconSolid,\n FolderIconOutline,\n} 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 custom: 'Custom Root',\n },\n id: 'Root',\n isCollapsed: false,\n isSelected: false,\n subItems: [\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 1',\n },\n id: 'Child 1',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 2',\n },\n id: 'Child 2',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 3',\n },\n id: 'Child 3',\n isSelected: false,\n },\n ],\n },\n];\n\nconst Component = () => {\n const [items, setItems] = useState(TREE_ITEMS);\n\n return (\n <TreeView\n items={items}\n onItemsChanged={(newItems) => {\n setItems(newItems);\n }}\n TreeItemComponent={function CustomTreeItem({\n ref,\n onItemsChanged,\n ...restProps\n }: React.ComponentProps<typeof TreeView.TreeItemWrapper>) {\n return (\n <TreeView.TreeItemWrapper\n {...restProps}\n onItemsChanged={onItemsChanged}\n ref={ref}\n >\n <div\n className=\"n-items-center n-flex n-flex-row\"\n style={{\n background: !restProps.item.canHaveSubItems\n ? 'linear-gradient(in hsl longer hue 45deg, red 0 0)'\n : '',\n }}\n >\n {restProps.item.canHaveSubItems && (\n <>\n <FolderIconOutline className=\"n-h-5 w-h-5\" />\n <button\n onClick={() =>\n restProps.onCollapse && restProps.onCollapse()\n }\n >\n {restProps.item.isCollapsed ? (\n <ChevronUpIconSolid className=\"n-h-5 w-h-5\" />\n ) : (\n <ChevronDownIconSolid className=\"n-h-5 w-h-5\" />\n )}\n </button>\n </>\n )}\n {'custom' in restProps.item.data &&\n typeof restProps.item.data.custom === 'string' &&\n restProps.item.data.custom}\n </div>\n </TreeView.TreeItemWrapper>\n );\n }}\n />\n );\n};\n\nexport default Component;\n"]}
1
+ {"version":3,"file":"treeview-custom.story.js","sourceRoot":"","sources":["../../../../src/tree-view/stories/treeview-custom.story.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD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AAE,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe;4BACzC,CAAC,CAAC,mDAAmD;4BACrD,CAAC,CAAC,EAAE;qBACP,aAEA,SAAS,CAAC,IAAI,CAAC,eAAe,IAAI,CACjC,6DACE,uBAAC,yBAAiB,IAAC,SAAS,EAAC,aAAa,GAAG,EAC7C,mCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CACZ,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU,EAAE,YAG/C,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAC5B,uBAAC,0BAAkB,IAAC,SAAS,EAAC,aAAa,GAAG,CAC/C,CAAC,CAAC,CAAC,CACF,uBAAC,4BAAoB,IAAC,SAAS,EAAC,aAAa,GAAG,CACjD,GACM,IACR,CACJ,EACA,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI;4BAC9B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,QAAQ;4BAC9C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IACxB,IACmB,CAC5B,CAAC;QACJ,CAAC,GACD,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 {\n ChevronDownIconSolid,\n ChevronUpIconSolid,\n FolderIconOutline,\n} 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 custom: 'Custom Root',\n },\n id: 'Root',\n isCollapsed: false,\n isSelected: false,\n subItems: [\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 1',\n },\n id: 'Child 1',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 2',\n },\n id: 'Child 2',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 3',\n },\n id: 'Child 3',\n isSelected: false,\n },\n ],\n },\n];\n\nconst Component = () => {\n const [items, setItems] = useState(TREE_ITEMS);\n\n return (\n <TreeView\n items={items}\n onItemsChanged={(newItems) => {\n setItems(newItems);\n }}\n TreeItemComponent={function CustomTreeItem({\n ref,\n onItemsChanged,\n ...restProps\n }: React.ComponentProps<typeof TreeView.TreeItemWrapper>) {\n return (\n <TreeView.TreeItemWrapper\n {...restProps}\n onItemsChanged={onItemsChanged}\n ref={ref}\n >\n <div\n className=\"n-items-center n-flex n-flex-row\"\n style={{\n background: !restProps.item.canHaveSubItems\n ? 'linear-gradient(in hsl longer hue 45deg, red 0 0)'\n : '',\n }}\n >\n {restProps.item.canHaveSubItems && (\n <>\n <FolderIconOutline className=\"n-h-5 w-h-5\" />\n <button\n type=\"button\"\n onClick={() =>\n restProps.onCollapse && restProps.onCollapse()\n }\n >\n {restProps.item.isCollapsed ? (\n <ChevronUpIconSolid className=\"n-h-5 w-h-5\" />\n ) : (\n <ChevronDownIconSolid className=\"n-h-5 w-h-5\" />\n )}\n </button>\n </>\n )}\n {'custom' in restProps.item.data &&\n typeof restProps.item.data.custom === 'string' &&\n restProps.item.data.custom}\n </div>\n </TreeView.TreeItemWrapper>\n );\n }}\n />\n );\n};\n\nexport default Component;\n"]}
@@ -184,7 +184,7 @@ const BaseAccordionItem = ({ itemId, children, title, className = '', arrowPosit
184
184
  'ndl-accordion-item-content-expanded': isExpanded,
185
185
  'ndl-accordion-item-content-leading': arrowPosition === 'leading',
186
186
  });
187
- return (_jsxs(Component, Object.assign({ className: classes, style: style, id: itemElementId }, htmlAttributes, { children: [_jsxs("div", { className: headerClasses, id: headerElementId, children: [_jsx("button", { id: buttonElementId, onClick: handleOnClick, className: buttonClasses, "aria-expanded": isExpanded, "aria-disabled": isDisabled, "aria-label": title, "aria-controls": panelElementId, disabled: isDisabled, children: _jsxs("span", { className: iconClasses, children: [_jsx(Typography, { variant: titleTypographyVariant, className: titleClasses, htmlAttributes: {
187
+ return (_jsxs(Component, Object.assign({ className: classes, style: style, id: itemElementId }, htmlAttributes, { children: [_jsxs("div", { className: headerClasses, id: headerElementId, children: [_jsx("button", { type: "button", id: buttonElementId, onClick: handleOnClick, className: buttonClasses, "aria-expanded": isExpanded, "aria-disabled": isDisabled, "aria-label": title, "aria-controls": panelElementId, disabled: isDisabled, children: _jsxs("span", { className: iconClasses, children: [_jsx(Typography, { variant: titleTypographyVariant, className: titleClasses, htmlAttributes: {
188
188
  'aria-level': 2,
189
189
  role: 'heading',
190
190
  }, children: title }), _jsx(ChevronDownIconOutline, { className: classNames('ndl-accordion-item-header-icon', {
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAA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AGpB,EAG+C,EAAE,EAAE;QAHnD,EACA,SAAS,OAEsC,EAD5C,SAAS,cAFZ,aAGD,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;IAEpE,OAAO,KAAC,iBAAiB,oBAAK,SAAS,IAAE,SAAS,EAAE,OAAO,IAAI,CAAC;AAClE,CAAC,CAAC;AACF,aAAa,CAAC,WAAW,GAAG,gBAAgB,CAAC;AAO7C,MAAM,SAAS,GAAG,CAGhB,EAG6C,EAAE,EAAE;QAHjD,EACA,SAAS,OAEoC,EAD1C,SAAS,cAFZ,aAGD,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAC;IAElE,OAAO,CACL,KAAC,iBAAiB,oBAAK,SAAS,IAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,CAC5E,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAE9C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAClD,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,SAAS,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 classNames from 'classnames';\nimport type React from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { findUntil } from '../_common/utils';\nimport { Divider } from '../divider';\nimport { ChevronDownIconOutline } from '../icons';\nimport { Typography } from '../typography';\nimport { AccordionContext, useAccordionContext } from './accordion-context';\nimport {\n type AccordionItemId,\n type AccordionItemProps,\n type AccordionProps,\n type ClassicItemProps,\n type IsMultiple,\n type IsNotMultiple,\n} from './accordion-types';\n\nenum AccordionSelector {\n Item = '.ndl-accordion-item',\n ItemNotDisabled = '.ndl-accordion-item:not(.ndl-accordion-item-disabled)',\n}\n\nconst getAccordionItem = (\n accordionElement: Element,\n selector: string,\n direction: 'next' | 'prev' = 'next',\n): Element | null => {\n const itemParent = accordionElement.closest(AccordionSelector.Item);\n if (!itemParent) {\n return null;\n }\n\n return findUntil(direction, itemParent, selector);\n};\n\nconst AccordionComponent = function AccordionComponent<\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n children,\n as,\n isMultiple,\n onChange,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, AccordionProps<T>>) {\n const accordionRef = useRef<U>(null);\n\n useImperativeHandle(ref, () => accordionRef.current!);\n\n const Component: React.ElementType = as || 'div';\n\n // The following function includes code needed to be\n // able to navigate with the arrow keys (not tab).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const accordionElement = accordionRef.current;\n if (!accordionElement) {\n return;\n }\n const activeElement = document.activeElement as HTMLElement;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'next',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'prev',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n activeElement.click();\n }\n };\n\n const focusAccordionItem = (accordionHtmlElement: HTMLElement) => {\n const accordionButton = accordionHtmlElement\n .getElementsByClassName('ndl-accordion-item-header-button')\n .item(0);\n\n if (accordionButton !== null && accordionButton instanceof HTMLElement) {\n accordionButton.focus();\n }\n };\n\n const classes = classNames('ndl-accordion', className);\n\n // Destructure and omit keys from DOM spread\n const { expandedItemIds, expandedItemId, ...restAccordionProps } =\n restProps as Record<string, unknown> as {\n expandedItemIds?: T[];\n expandedItemId?: T | null;\n [key: string]: unknown;\n };\n\n const contextValue = isMultiple\n ? ({\n expandedItemIds,\n isMultiple,\n onChange,\n } as IsMultiple<T>)\n : ({\n expandedItemId,\n isMultiple,\n onChange,\n } as IsNotMultiple<T>);\n\n return (\n <Component\n className={classes}\n style={style}\n ref={accordionRef}\n onKeyDown={handleKeyDown}\n role=\"presentation\"\n {...restAccordionProps}\n {...htmlAttributes}\n >\n <AccordionContext.Provider value={contextValue}>\n {children}\n </AccordionContext.Provider>\n </Component>\n );\n};\n\nconst createItemId = (type: string, id: AccordionItemId) =>\n `ndl-accordionitem${type}id-${id}`;\n\nconst BaseAccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n itemId,\n children,\n title,\n className = '',\n arrowPosition = 'leading',\n isDisabled = false,\n onExpandedChange,\n htmlAttributes,\n style,\n as,\n titleTypographyVariant = 'subheading-medium',\n hasDivider = true,\n trailingContent,\n}: PolymorphicCommonProps<U, AccordionItemProps<T>>) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const innerContentRef = useRef<HTMLDivElement>(null);\n const itemElementId = createItemId('item', itemId);\n const headerElementId = createItemId('header', itemId);\n const buttonElementId = createItemId('button', itemId);\n const panelElementId = createItemId('panel', itemId);\n const Component: React.ElementType = as || 'div';\n\n const context = useAccordionContext();\n const { isMultiple } = context;\n\n const isExpanded = isMultiple\n ? context.expandedItemIds.includes(itemId)\n : context.expandedItemId === itemId;\n\n const handleOnClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n // Custom callback to call.\n if (onExpandedChange !== undefined) {\n onExpandedChange(!isExpanded);\n }\n\n if (isMultiple) {\n const { expandedItemIds, onChange }: IsMultiple<T> = context;\n // Multiple expanded.\n if (isExpanded) {\n // Remove from list.\n const newArray: T[] = expandedItemIds.filter(\n (activeId) => activeId !== itemId,\n );\n onChange(newArray);\n } else if (!isExpanded) {\n // Add to list.\n const newArray = [...expandedItemIds];\n newArray.push(itemId);\n onChange(newArray);\n }\n } else {\n const { onChange }: IsNotMultiple<T> = context;\n // Single expanded.\n if (isExpanded) {\n // Set null.\n onChange(null);\n } else if (!isExpanded) {\n // Set to id.\n onChange(itemId);\n }\n }\n\n // The W3 WAI-ARIA states that focus can only happen on the header not the header button.\n document.activeElement?.parentElement?.focus();\n }, [isExpanded, isMultiple, isDisabled, itemId, onExpandedChange, context]);\n\n const classes = classNames('ndl-accordion-item', className, {\n 'ndl-accordion-item-disabled': isDisabled,\n 'ndl-accordion-item-expanded': isExpanded,\n });\n\n const headerClasses = classNames('ndl-accordion-item-header', {\n 'ndl-accordion-item-header-disabled': isDisabled,\n });\n\n const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {\n 'ndl-accordion-item-header-icon-wrapper-leading':\n arrowPosition === 'leading',\n });\n\n const buttonClasses = classNames('ndl-accordion-item-header-button', {\n 'ndl-accordion-item-header-button-disabled': isDisabled,\n });\n\n const titleClasses = classNames('ndl-accordion-item-header-button-title', {\n 'ndl-accordion-item-header-button-title': isDisabled,\n 'ndl-accordion-item-header-button-title-leading':\n arrowPosition === 'leading',\n });\n\n const contentClasses = classNames('ndl-accordion-item-content', {\n 'ndl-accordion-item-content-expanded': isExpanded,\n 'ndl-accordion-item-content-leading': arrowPosition === 'leading',\n });\n\n return (\n <Component\n className={classes}\n style={style}\n id={itemElementId}\n {...htmlAttributes}\n >\n <div className={headerClasses} id={headerElementId}>\n <button\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-label={title}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <Typography\n variant={titleTypographyVariant}\n className={titleClasses}\n htmlAttributes={{\n 'aria-level': 2,\n role: 'heading',\n }}\n >\n {title}\n </Typography>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n '-n-rotate-180': isExpanded,\n })}\n />\n </span>\n </button>\n {trailingContent && (\n <Typography as=\"div\" variant=\"body-medium\">\n {trailingContent}\n </Typography>\n )}\n </div>\n\n <div\n id={panelElementId}\n ref={contentRef}\n className={contentClasses}\n aria-hidden={!isExpanded}\n aria-labelledby={buttonElementId}\n role=\"region\"\n >\n {/* The <div> element has a child <button> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={innerContentRef}\n className=\"ndl-accordion-item-content-inner\"\n onKeyDown={(event) => event.stopPropagation()}\n >\n <Typography\n variant=\"body-medium\"\n className=\"n-text-neutral-text-weak\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\nconst AccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, ClassicItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-classic', className);\n\n return <BaseAccordionItem {...restProps} className={classes} />;\n};\nAccordionItem.displayName = 'Accordion.Item';\n\ntype CleanItemProps<T extends AccordionItemId> = Omit<\n AccordionItemProps<T>,\n 'hasDivider'\n>;\n\nconst CleanItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, CleanItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-clean', className);\n\n return (\n <BaseAccordionItem {...restProps} className={classes} hasDivider={false} />\n );\n};\n\nCleanItem.displayName = 'Accordion.CleanItem';\n\nconst Accordion = Object.assign(AccordionComponent, {\n CleanItem: CleanItem,\n Item: AccordionItem,\n});\n\nexport { Accordion };\n"]}
1
+ {"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAU5E,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IACpB,iDAA4B,CAAA;IAC5B,8FAAyE,CAAA;AAC3E,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAM,gBAAgB,GAAG,CACvB,gBAAyB,EACzB,QAAgB,EAChB,YAA6B,MAAM,EACnB,EAAE;IAClB,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,SAAS,k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CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAE9C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAClD,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,SAAS,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 classNames from 'classnames';\nimport type React from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { findUntil } from '../_common/utils';\nimport { Divider } from '../divider';\nimport { ChevronDownIconOutline } from '../icons';\nimport { Typography } from '../typography';\nimport { AccordionContext, useAccordionContext } from './accordion-context';\nimport {\n type AccordionItemId,\n type AccordionItemProps,\n type AccordionProps,\n type ClassicItemProps,\n type IsMultiple,\n type IsNotMultiple,\n} from './accordion-types';\n\nenum AccordionSelector {\n Item = '.ndl-accordion-item',\n ItemNotDisabled = '.ndl-accordion-item:not(.ndl-accordion-item-disabled)',\n}\n\nconst getAccordionItem = (\n accordionElement: Element,\n selector: string,\n direction: 'next' | 'prev' = 'next',\n): Element | null => {\n const itemParent = accordionElement.closest(AccordionSelector.Item);\n if (!itemParent) {\n return null;\n }\n\n return findUntil(direction, itemParent, selector);\n};\n\nconst AccordionComponent = function AccordionComponent<\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n children,\n as,\n isMultiple,\n onChange,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, AccordionProps<T>>) {\n const accordionRef = useRef<U>(null);\n\n useImperativeHandle(ref, () => accordionRef.current!);\n\n const Component: React.ElementType = as || 'div';\n\n // The following function includes code needed to be\n // able to navigate with the arrow keys (not tab).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const accordionElement = accordionRef.current;\n if (!accordionElement) {\n return;\n }\n const activeElement = document.activeElement as HTMLElement;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'next',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'prev',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n activeElement.click();\n }\n };\n\n const focusAccordionItem = (accordionHtmlElement: HTMLElement) => {\n const accordionButton = accordionHtmlElement\n .getElementsByClassName('ndl-accordion-item-header-button')\n .item(0);\n\n if (accordionButton !== null && accordionButton instanceof HTMLElement) {\n accordionButton.focus();\n }\n };\n\n const classes = classNames('ndl-accordion', className);\n\n // Destructure and omit keys from DOM spread\n const { expandedItemIds, expandedItemId, ...restAccordionProps } =\n restProps as Record<string, unknown> as {\n expandedItemIds?: T[];\n expandedItemId?: T | null;\n [key: string]: unknown;\n };\n\n const contextValue = isMultiple\n ? ({\n expandedItemIds,\n isMultiple,\n onChange,\n } as IsMultiple<T>)\n : ({\n expandedItemId,\n isMultiple,\n onChange,\n } as IsNotMultiple<T>);\n\n return (\n <Component\n className={classes}\n style={style}\n ref={accordionRef}\n onKeyDown={handleKeyDown}\n role=\"presentation\"\n {...restAccordionProps}\n {...htmlAttributes}\n >\n <AccordionContext.Provider value={contextValue}>\n {children}\n </AccordionContext.Provider>\n </Component>\n );\n};\n\nconst createItemId = (type: string, id: AccordionItemId) =>\n `ndl-accordionitem${type}id-${id}`;\n\nconst BaseAccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n itemId,\n children,\n title,\n className = '',\n arrowPosition = 'leading',\n isDisabled = false,\n onExpandedChange,\n htmlAttributes,\n style,\n as,\n titleTypographyVariant = 'subheading-medium',\n hasDivider = true,\n trailingContent,\n}: PolymorphicCommonProps<U, AccordionItemProps<T>>) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const innerContentRef = useRef<HTMLDivElement>(null);\n const itemElementId = createItemId('item', itemId);\n const headerElementId = createItemId('header', itemId);\n const buttonElementId = createItemId('button', itemId);\n const panelElementId = createItemId('panel', itemId);\n const Component: React.ElementType = as || 'div';\n\n const context = useAccordionContext();\n const { isMultiple } = context;\n\n const isExpanded = isMultiple\n ? context.expandedItemIds.includes(itemId)\n : context.expandedItemId === itemId;\n\n const handleOnClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n // Custom callback to call.\n if (onExpandedChange !== undefined) {\n onExpandedChange(!isExpanded);\n }\n\n if (isMultiple) {\n const { expandedItemIds, onChange }: IsMultiple<T> = context;\n // Multiple expanded.\n if (isExpanded) {\n // Remove from list.\n const newArray: T[] = expandedItemIds.filter(\n (activeId) => activeId !== itemId,\n );\n onChange(newArray);\n } else if (!isExpanded) {\n // Add to list.\n const newArray = [...expandedItemIds];\n newArray.push(itemId);\n onChange(newArray);\n }\n } else {\n const { onChange }: IsNotMultiple<T> = context;\n // Single expanded.\n if (isExpanded) {\n // Set null.\n onChange(null);\n } else if (!isExpanded) {\n // Set to id.\n onChange(itemId);\n }\n }\n\n // The W3 WAI-ARIA states that focus can only happen on the header not the header button.\n document.activeElement?.parentElement?.focus();\n }, [isExpanded, isMultiple, isDisabled, itemId, onExpandedChange, context]);\n\n const classes = classNames('ndl-accordion-item', className, {\n 'ndl-accordion-item-disabled': isDisabled,\n 'ndl-accordion-item-expanded': isExpanded,\n });\n\n const headerClasses = classNames('ndl-accordion-item-header', {\n 'ndl-accordion-item-header-disabled': isDisabled,\n });\n\n const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {\n 'ndl-accordion-item-header-icon-wrapper-leading':\n arrowPosition === 'leading',\n });\n\n const buttonClasses = classNames('ndl-accordion-item-header-button', {\n 'ndl-accordion-item-header-button-disabled': isDisabled,\n });\n\n const titleClasses = classNames('ndl-accordion-item-header-button-title', {\n 'ndl-accordion-item-header-button-title': isDisabled,\n 'ndl-accordion-item-header-button-title-leading':\n arrowPosition === 'leading',\n });\n\n const contentClasses = classNames('ndl-accordion-item-content', {\n 'ndl-accordion-item-content-expanded': isExpanded,\n 'ndl-accordion-item-content-leading': arrowPosition === 'leading',\n });\n\n return (\n <Component\n className={classes}\n style={style}\n id={itemElementId}\n {...htmlAttributes}\n >\n <div className={headerClasses} id={headerElementId}>\n <button\n type=\"button\"\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-label={title}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <Typography\n variant={titleTypographyVariant}\n className={titleClasses}\n htmlAttributes={{\n 'aria-level': 2,\n role: 'heading',\n }}\n >\n {title}\n </Typography>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n '-n-rotate-180': isExpanded,\n })}\n />\n </span>\n </button>\n {trailingContent && (\n <Typography as=\"div\" variant=\"body-medium\">\n {trailingContent}\n </Typography>\n )}\n </div>\n\n <div\n id={panelElementId}\n ref={contentRef}\n className={contentClasses}\n aria-hidden={!isExpanded}\n aria-labelledby={buttonElementId}\n role=\"region\"\n >\n {/* The <div> element has a child <button> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={innerContentRef}\n className=\"ndl-accordion-item-content-inner\"\n onKeyDown={(event) => event.stopPropagation()}\n >\n <Typography\n variant=\"body-medium\"\n className=\"n-text-neutral-text-weak\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\nconst AccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, ClassicItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-classic', className);\n\n return <BaseAccordionItem {...restProps} className={classes} />;\n};\nAccordionItem.displayName = 'Accordion.Item';\n\ntype CleanItemProps<T extends AccordionItemId> = Omit<\n AccordionItemProps<T>,\n 'hasDivider'\n>;\n\nconst CleanItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, CleanItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-clean', className);\n\n return (\n <BaseAccordionItem {...restProps} className={classes} hasDivider={false} />\n );\n};\n\nCleanItem.displayName = 'Accordion.CleanItem';\n\nconst Accordion = Object.assign(AccordionComponent, {\n CleanItem: CleanItem,\n Item: AccordionItem,\n});\n\nexport { Accordion };\n"]}
@@ -135,7 +135,7 @@ const PromptComponent = (_a) => {
135
135
  const SubmitPromptButton = ({ onSubmit, onCancel, isDisabled, isRunningPrompt, }) => {
136
136
  return (_jsx("div", { className: classNames('ndl-ai-prompt-button-container', {
137
137
  'ndl-in-loading': isRunningPrompt,
138
- }), children: _jsxs(Tooltip, { type: "simple", isDisabled: isDisabled || isRunningPrompt, hoverDelay: { close: 0, open: 500 }, shouldCloseOnReferenceClick: true, children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx("button", { style: {
138
+ }), children: _jsxs(Tooltip, { type: "simple", isDisabled: isDisabled || isRunningPrompt, hoverDelay: { close: 0, open: 500 }, shouldCloseOnReferenceClick: true, children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx("button", { type: "button", style: {
139
139
  borderRadius: isRunningPrompt
140
140
  ? 'var(--border-radius-sm)'
141
141
  : 'var(--border-radius-lg)',
@@ -1 +1 @@
1
- {"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../../src/ai/prompt/Prompt.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,IAAI,EACJ,cAAc,EACd,OAAO,EACP,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAiCjE;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,CAAC,EAiBS,EAAE,EAAE;QAjBb,EACvB,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,eAAe,GAAG,KAAK,EACvB,cAAc,EACd,cAAc,EACd,gBAAgB,GAAG,KAAK,EACxB,UAAU,EACV,aAAa,EACb,UAAU,GAAG,qCAAqC,EAClD,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,EACH,aAAa,OAEmB,EAD7B,SAAS,cAhBW,wNAiBxB,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IACtD,MAAM,gBAAgB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;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4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n CleanIconButton,\n DropdownButton,\n LoadingSpinner,\n Menu,\n OutlinedButton,\n Tooltip,\n Typography,\n} from '@neo4j-ndl/react';\nimport {\n ArrowSendIcon,\n ArrowSmallUpIconOutline,\n StopIconOutline,\n XMarkIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { CommonProps, HtmlAttributes } from '../../_common/types';\n\ntype PromptProps = {\n /** The prompt text */\n value?: React.ComponentPropsWithoutRef<'textarea'>['value'];\n /** Callback function called when the prompt text changes */\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n /** Whether the submit button is disabled */\n isSubmitDisabled?: boolean;\n /** Maximum number of rows the textarea can expand to */\n maxRows?: number;\n /** Whether the submit button is \"running\". Shows a stop icon when true. */\n isRunningPrompt?: boolean;\n /** Callback function called when the submit button is clicked */\n onSubmitPrompt?: (\n e:\n | React.KeyboardEvent<HTMLTextAreaElement>\n | React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => void;\n /** Callback function called when the cancel button is clicked */\n onCancelPrompt?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Content to display above the textarea */\n topContent?: React.ReactNode;\n /** Content to display below the textarea */\n bottomContent?: React.ReactNode;\n /** Disclaimer to display below the component */\n disclaimer?: React.ReactNode;\n /** Props for the textarea element */\n textareaProps?: HtmlAttributes<'textarea'>;\n};\n\n/**\n * The component is used to display the prompt input for an LLM.\n * It includes a textarea for the user to enter their prompt and a submit button.\n * It can also display content above and below the textarea, like uploaded files or a select for changing agents.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PromptComponent = ({\n value,\n onChange,\n maxRows = 5,\n isRunningPrompt = false,\n onSubmitPrompt,\n onCancelPrompt,\n isSubmitDisabled = false,\n topContent,\n bottomContent,\n disclaimer = 'All information should be verified.',\n className,\n style,\n htmlAttributes,\n ref,\n textareaProps,\n ...restProps\n}: CommonProps<'div', PromptProps>) => {\n const classes = classNames('ndl-ai-prompt', className);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const textareaAboveRef = useRef<HTMLDivElement>(null);\n const [lineHeight, setLineHeight] = useState(0);\n\n /** File overflow stuff */\n useEffect(() => {\n let rafId: number | null = null;\n\n const checkOverflow = () => {\n if (textareaAboveRef.current !== null) {\n const element = textareaAboveRef.current;\n const maxHeight = parseFloat(\n getComputedStyle(element).maxHeight.replace('px', ''),\n );\n const scrollHeight = element.scrollHeight;\n\n if (scrollHeight > maxHeight) {\n element.classList.add('ndl-can-scroll');\n } else {\n element.classList.remove('ndl-can-scroll');\n }\n }\n };\n\n const debouncedCheck = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(checkOverflow);\n };\n\n // Initial check\n checkOverflow();\n\n const resizeObserver = new ResizeObserver(debouncedCheck);\n const mutationObserver = new MutationObserver(debouncedCheck);\n\n if (textareaAboveRef.current !== null) {\n resizeObserver.observe(textareaAboveRef.current);\n mutationObserver.observe(textareaAboveRef.current, {\n childList: true,\n subtree: true,\n });\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, []);\n\n /** Textarea stuff */\n useEffect(() => {\n if (textareaRef.current !== null) {\n const computed = window.getComputedStyle(textareaRef.current);\n setLineHeight(parseInt(computed.lineHeight));\n }\n }, []);\n\n const adjustTextareaHeight = useCallback(() => {\n const ta = textareaRef.current;\n\n if (ta !== null && lineHeight > 0) {\n // Reset height so scrollHeight measures correctly\n ta.style.height = 'auto';\n\n const maxHeight = lineHeight * maxRows;\n\n if (ta.scrollHeight <= maxHeight) {\n ta.style.overflowY = 'hidden';\n ta.style.height = `${ta.scrollHeight}px`;\n } else {\n ta.style.overflowY = 'auto';\n ta.style.height = `${maxHeight}px`;\n }\n }\n }, [lineHeight, maxRows]);\n\n // Adjust height when prompt value changes (including when cleared)\n useEffect(() => {\n adjustTextareaHeight();\n }, [value, adjustTextareaHeight]);\n\n const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n adjustTextareaHeight();\n onChange?.(e);\n };\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-prompt-wrapper\">\n <div\n className={classNames('ndl-ai-prompt-loading-container', {\n 'ndl-expanded': isRunningPrompt,\n })}\n aria-hidden={!isRunningPrompt}\n inert={!isRunningPrompt}\n >\n <div className=\"ndl-ai-prompt-loading-shell\">\n <div className=\"ndl-ai-prompt-loading-content\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"body-medium\">\n Working\n <span className=\"ndl-ai-prompt-loading-dots\">\n <span>.</span>\n <span>.</span>\n <span>.</span>\n </span>\n </Typography>\n </div>\n </div>\n </div>\n <div className=\"ndl-ai-prompt-wrapper-inner\">\n {Boolean(topContent) && (\n <div\n className=\"ndl-ai-prompt-textarea-above\"\n ref={textareaAboveRef}\n >\n {topContent}\n </div>\n )}\n <textarea\n placeholder=\"Ask anything\"\n className=\"ndl-ai-prompt-textarea\"\n rows={1}\n onChange={handleInput}\n value={value}\n ref={textareaRef}\n onKeyDown={(e) => {\n if (\n e.key === 'Enter' &&\n !e.shiftKey &&\n isSubmitDisabled !== true\n ) {\n e.preventDefault();\n\n if (isRunningPrompt !== true) {\n onSubmitPrompt?.(e);\n }\n }\n }}\n {...textareaProps}\n />\n <div className=\"ndl-ai-prompt-textarea-below\">\n {Boolean(bottomContent) && (\n <div className=\"ndl-ai-prompt-textarea-below-leading\">\n {bottomContent}\n </div>\n )}\n </div>\n </div>\n <SubmitPromptButton\n isDisabled={isSubmitDisabled}\n isRunningPrompt={isRunningPrompt}\n onSubmit={onSubmitPrompt}\n onCancel={onCancelPrompt}\n />\n </div>\n {Boolean(disclaimer) && (\n <Typography variant=\"body-small\" className=\"ndl-ai-prompt-footer\">\n {disclaimer}\n </Typography>\n )}\n </div>\n );\n};\n\nconst SubmitPromptButton = ({\n onSubmit,\n onCancel,\n isDisabled,\n isRunningPrompt,\n}: {\n isDisabled?: boolean;\n isRunningPrompt?: boolean;\n onSubmit?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n onCancel?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}) => {\n return (\n <div\n className={classNames('ndl-ai-prompt-button-container', {\n 'ndl-in-loading': isRunningPrompt,\n })}\n >\n <Tooltip\n type=\"simple\"\n isDisabled={isDisabled || isRunningPrompt}\n hoverDelay={{ close: 0, open: 500 }}\n shouldCloseOnReferenceClick={true}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <button\n style={{\n borderRadius: isRunningPrompt\n ? 'var(--border-radius-sm)'\n : 'var(--border-radius-lg)',\n }}\n onClick={isRunningPrompt ? onCancel : onSubmit}\n disabled={isDisabled}\n aria-label={isRunningPrompt ? 'Stop' : 'Send'}\n >\n {isRunningPrompt === true ? (\n <OutlinedButton\n as=\"div\"\n variant=\"neutral\"\n className=\"ndl-ai-prompt-stop-button\"\n size=\"small\"\n isDisabled={isDisabled}\n leadingVisual={<StopIconOutline />}\n >\n Stop\n </OutlinedButton>\n ) : (\n <CleanIconButton\n description=\"Send\"\n as=\"div\"\n className=\"ndl-ai-prompt-submit-button\"\n size=\"medium\"\n isDisabled={isDisabled}\n htmlAttributes={{\n 'aria-pressed': undefined,\n }}\n >\n <ArrowSmallUpIconOutline />\n </CleanIconButton>\n )}\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content>Send</Tooltip.Content>\n </Tooltip>\n </div>\n );\n};\n\ntype AgentSelectProps = {\n value: { label: React.ReactNode; value: string };\n options: Array<{ label: React.ReactNode; value: string }>;\n onChange: (option: { label: React.ReactNode; value: string }) => void;\n};\n\nconst AgentSelect = ({ value, options = [], onChange }: AgentSelectProps) => {\n const anchorRef = useRef<HTMLButtonElement>(null);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n const displayLabel = value?.label ?? options[0]?.label ?? '';\n\n const handleItemClick = (option: {\n label: React.ReactNode;\n value: string;\n }) => {\n onChange?.(option);\n setIsMenuOpen(false);\n };\n\n return (\n <>\n <DropdownButton\n size=\"small\"\n className=\"ndl-ai-prompt-dropdown-button\"\n onClick={() => setIsMenuOpen((old) => !old)}\n isOpen={isMenuOpen}\n ref={anchorRef}\n >\n {displayLabel}\n </DropdownButton>\n <Menu\n isOpen={isMenuOpen}\n onClose={() => setIsMenuOpen(false)}\n anchorRef={anchorRef}\n placement=\"top-start-bottom-start\"\n >\n {options.map((option) => (\n <Menu.RadioItem\n key={option.value}\n title={option.label}\n isChecked={value?.value === option.value}\n onClick={() => handleItemClick(option)}\n />\n ))}\n </Menu>\n </>\n );\n};\n\ntype ContextTagProps = {\n children?: string;\n onClose: () => void;\n};\n\nconst ContextTag = ({ children, onClose }: ContextTagProps) => {\n const textRef = useRef<HTMLSpanElement>(null);\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isTooltipOpen}\n onOpenChange={(isOpen) => {\n if (isOpen) {\n const isTruncated =\n textRef.current?.scrollWidth &&\n textRef.current?.clientWidth &&\n textRef.current.scrollWidth > textRef.current.clientWidth;\n if (isTruncated) {\n setIsTooltipOpen(true);\n }\n } else {\n setIsTooltipOpen(false);\n }\n }}\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <div className=\"ndl-ai-prompt-context-tag\">\n <ArrowSendIcon className=\"ndl-ai-prompt-context-tag-icon\" />\n <Typography\n variant=\"body-medium\"\n className=\"ndl-ai-prompt-context-tag-text\"\n ref={textRef}\n >\n {children}\n </Typography>\n\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={`Remove context: ${children}`}\n className=\"ndl-ai-prompt-context-tag-close-button\"\n >\n <XMarkIconOutline className=\"ndl-ai-prompt-context-tag-icon\" />\n </button>\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>{children}</Tooltip.Content>\n </Tooltip>\n );\n};\n\nconst Prompt = Object.assign(PromptComponent, {\n ContextTag: ContextTag,\n Select: AgentSelect,\n});\n\nexport { Prompt };\n"]}
1
+ {"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../../src/ai/prompt/Prompt.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,IAAI,EACJ,cAAc,EACd,OAAO,EACP,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAiCjE;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,CAAC,EAiBS,EAAE,EAAE;QAjBb,EACvB,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,eAAe,GAAG,KAAK,EACvB,cAAc,EACd,cAAc,EACd,gBAAgB,GAAG,KAAK,EACxB,UAAU,EACV,aAAa,EACb,UAAU,GAAG,qCAAqC,EAClD,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,EACH,aAAa,OAEmB,EAD7B,SAAS,cAhBW,wNAiBxB,CADa;IAEZ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AAM,CAAC,MAAM,CAAC,eAAe,EAAE;IAC5C,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,WAAW;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,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 */\n\nimport {\n CleanIconButton,\n DropdownButton,\n LoadingSpinner,\n Menu,\n OutlinedButton,\n Tooltip,\n Typography,\n} from '@neo4j-ndl/react';\nimport {\n ArrowSendIcon,\n ArrowSmallUpIconOutline,\n StopIconOutline,\n XMarkIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { CommonProps, HtmlAttributes } from '../../_common/types';\n\ntype PromptProps = {\n /** The prompt text */\n value?: React.ComponentPropsWithoutRef<'textarea'>['value'];\n /** Callback function called when the prompt text changes */\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n /** Whether the submit button is disabled */\n isSubmitDisabled?: boolean;\n /** Maximum number of rows the textarea can expand to */\n maxRows?: number;\n /** Whether the submit button is \"running\". Shows a stop icon when true. */\n isRunningPrompt?: boolean;\n /** Callback function called when the submit button is clicked */\n onSubmitPrompt?: (\n e:\n | React.KeyboardEvent<HTMLTextAreaElement>\n | React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => void;\n /** Callback function called when the cancel button is clicked */\n onCancelPrompt?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Content to display above the textarea */\n topContent?: React.ReactNode;\n /** Content to display below the textarea */\n bottomContent?: React.ReactNode;\n /** Disclaimer to display below the component */\n disclaimer?: React.ReactNode;\n /** Props for the textarea element */\n textareaProps?: HtmlAttributes<'textarea'>;\n};\n\n/**\n * The component is used to display the prompt input for an LLM.\n * It includes a textarea for the user to enter their prompt and a submit button.\n * It can also display content above and below the textarea, like uploaded files or a select for changing agents.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PromptComponent = ({\n value,\n onChange,\n maxRows = 5,\n isRunningPrompt = false,\n onSubmitPrompt,\n onCancelPrompt,\n isSubmitDisabled = false,\n topContent,\n bottomContent,\n disclaimer = 'All information should be verified.',\n className,\n style,\n htmlAttributes,\n ref,\n textareaProps,\n ...restProps\n}: CommonProps<'div', PromptProps>) => {\n const classes = classNames('ndl-ai-prompt', className);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const textareaAboveRef = useRef<HTMLDivElement>(null);\n const [lineHeight, setLineHeight] = useState(0);\n\n /** File overflow stuff */\n useEffect(() => {\n let rafId: number | null = null;\n\n const checkOverflow = () => {\n if (textareaAboveRef.current !== null) {\n const element = textareaAboveRef.current;\n const maxHeight = parseFloat(\n getComputedStyle(element).maxHeight.replace('px', ''),\n );\n const scrollHeight = element.scrollHeight;\n\n if (scrollHeight > maxHeight) {\n element.classList.add('ndl-can-scroll');\n } else {\n element.classList.remove('ndl-can-scroll');\n }\n }\n };\n\n const debouncedCheck = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(checkOverflow);\n };\n\n // Initial check\n checkOverflow();\n\n const resizeObserver = new ResizeObserver(debouncedCheck);\n const mutationObserver = new MutationObserver(debouncedCheck);\n\n if (textareaAboveRef.current !== null) {\n resizeObserver.observe(textareaAboveRef.current);\n mutationObserver.observe(textareaAboveRef.current, {\n childList: true,\n subtree: true,\n });\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, []);\n\n /** Textarea stuff */\n useEffect(() => {\n if (textareaRef.current !== null) {\n const computed = window.getComputedStyle(textareaRef.current);\n setLineHeight(parseInt(computed.lineHeight));\n }\n }, []);\n\n const adjustTextareaHeight = useCallback(() => {\n const ta = textareaRef.current;\n\n if (ta !== null && lineHeight > 0) {\n // Reset height so scrollHeight measures correctly\n ta.style.height = 'auto';\n\n const maxHeight = lineHeight * maxRows;\n\n if (ta.scrollHeight <= maxHeight) {\n ta.style.overflowY = 'hidden';\n ta.style.height = `${ta.scrollHeight}px`;\n } else {\n ta.style.overflowY = 'auto';\n ta.style.height = `${maxHeight}px`;\n }\n }\n }, [lineHeight, maxRows]);\n\n // Adjust height when prompt value changes (including when cleared)\n useEffect(() => {\n adjustTextareaHeight();\n }, [value, adjustTextareaHeight]);\n\n const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n adjustTextareaHeight();\n onChange?.(e);\n };\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-prompt-wrapper\">\n <div\n className={classNames('ndl-ai-prompt-loading-container', {\n 'ndl-expanded': isRunningPrompt,\n })}\n aria-hidden={!isRunningPrompt}\n inert={!isRunningPrompt}\n >\n <div className=\"ndl-ai-prompt-loading-shell\">\n <div className=\"ndl-ai-prompt-loading-content\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"body-medium\">\n Working\n <span className=\"ndl-ai-prompt-loading-dots\">\n <span>.</span>\n <span>.</span>\n <span>.</span>\n </span>\n </Typography>\n </div>\n </div>\n </div>\n <div className=\"ndl-ai-prompt-wrapper-inner\">\n {Boolean(topContent) && (\n <div\n className=\"ndl-ai-prompt-textarea-above\"\n ref={textareaAboveRef}\n >\n {topContent}\n </div>\n )}\n <textarea\n placeholder=\"Ask anything\"\n className=\"ndl-ai-prompt-textarea\"\n rows={1}\n onChange={handleInput}\n value={value}\n ref={textareaRef}\n onKeyDown={(e) => {\n if (\n e.key === 'Enter' &&\n !e.shiftKey &&\n isSubmitDisabled !== true\n ) {\n e.preventDefault();\n\n if (isRunningPrompt !== true) {\n onSubmitPrompt?.(e);\n }\n }\n }}\n {...textareaProps}\n />\n <div className=\"ndl-ai-prompt-textarea-below\">\n {Boolean(bottomContent) && (\n <div className=\"ndl-ai-prompt-textarea-below-leading\">\n {bottomContent}\n </div>\n )}\n </div>\n </div>\n <SubmitPromptButton\n isDisabled={isSubmitDisabled}\n isRunningPrompt={isRunningPrompt}\n onSubmit={onSubmitPrompt}\n onCancel={onCancelPrompt}\n />\n </div>\n {Boolean(disclaimer) && (\n <Typography variant=\"body-small\" className=\"ndl-ai-prompt-footer\">\n {disclaimer}\n </Typography>\n )}\n </div>\n );\n};\n\nconst SubmitPromptButton = ({\n onSubmit,\n onCancel,\n isDisabled,\n isRunningPrompt,\n}: {\n isDisabled?: boolean;\n isRunningPrompt?: boolean;\n onSubmit?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n onCancel?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}) => {\n return (\n <div\n className={classNames('ndl-ai-prompt-button-container', {\n 'ndl-in-loading': isRunningPrompt,\n })}\n >\n <Tooltip\n type=\"simple\"\n isDisabled={isDisabled || isRunningPrompt}\n hoverDelay={{ close: 0, open: 500 }}\n shouldCloseOnReferenceClick={true}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <button\n type=\"button\"\n style={{\n borderRadius: isRunningPrompt\n ? 'var(--border-radius-sm)'\n : 'var(--border-radius-lg)',\n }}\n onClick={isRunningPrompt ? onCancel : onSubmit}\n disabled={isDisabled}\n aria-label={isRunningPrompt ? 'Stop' : 'Send'}\n >\n {isRunningPrompt === true ? (\n <OutlinedButton\n as=\"div\"\n variant=\"neutral\"\n className=\"ndl-ai-prompt-stop-button\"\n size=\"small\"\n isDisabled={isDisabled}\n leadingVisual={<StopIconOutline />}\n >\n Stop\n </OutlinedButton>\n ) : (\n <CleanIconButton\n description=\"Send\"\n as=\"div\"\n className=\"ndl-ai-prompt-submit-button\"\n size=\"medium\"\n isDisabled={isDisabled}\n htmlAttributes={{\n 'aria-pressed': undefined,\n }}\n >\n <ArrowSmallUpIconOutline />\n </CleanIconButton>\n )}\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content>Send</Tooltip.Content>\n </Tooltip>\n </div>\n );\n};\n\ntype AgentSelectProps = {\n value: { label: React.ReactNode; value: string };\n options: Array<{ label: React.ReactNode; value: string }>;\n onChange: (option: { label: React.ReactNode; value: string }) => void;\n};\n\nconst AgentSelect = ({ value, options = [], onChange }: AgentSelectProps) => {\n const anchorRef = useRef<HTMLButtonElement>(null);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n const displayLabel = value?.label ?? options[0]?.label ?? '';\n\n const handleItemClick = (option: {\n label: React.ReactNode;\n value: string;\n }) => {\n onChange?.(option);\n setIsMenuOpen(false);\n };\n\n return (\n <>\n <DropdownButton\n size=\"small\"\n className=\"ndl-ai-prompt-dropdown-button\"\n onClick={() => setIsMenuOpen((old) => !old)}\n isOpen={isMenuOpen}\n ref={anchorRef}\n >\n {displayLabel}\n </DropdownButton>\n <Menu\n isOpen={isMenuOpen}\n onClose={() => setIsMenuOpen(false)}\n anchorRef={anchorRef}\n placement=\"top-start-bottom-start\"\n >\n {options.map((option) => (\n <Menu.RadioItem\n key={option.value}\n title={option.label}\n isChecked={value?.value === option.value}\n onClick={() => handleItemClick(option)}\n />\n ))}\n </Menu>\n </>\n );\n};\n\ntype ContextTagProps = {\n children?: string;\n onClose: () => void;\n};\n\nconst ContextTag = ({ children, onClose }: ContextTagProps) => {\n const textRef = useRef<HTMLSpanElement>(null);\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isTooltipOpen}\n onOpenChange={(isOpen) => {\n if (isOpen) {\n const isTruncated =\n textRef.current?.scrollWidth &&\n textRef.current?.clientWidth &&\n textRef.current.scrollWidth > textRef.current.clientWidth;\n if (isTruncated) {\n setIsTooltipOpen(true);\n }\n } else {\n setIsTooltipOpen(false);\n }\n }}\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <div className=\"ndl-ai-prompt-context-tag\">\n <ArrowSendIcon className=\"ndl-ai-prompt-context-tag-icon\" />\n <Typography\n variant=\"body-medium\"\n className=\"ndl-ai-prompt-context-tag-text\"\n ref={textRef}\n >\n {children}\n </Typography>\n\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={`Remove context: ${children}`}\n className=\"ndl-ai-prompt-context-tag-close-button\"\n >\n <XMarkIconOutline className=\"ndl-ai-prompt-context-tag-icon\" />\n </button>\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>{children}</Tooltip.Content>\n </Tooltip>\n );\n};\n\nconst Prompt = Object.assign(PromptComponent, {\n ContextTag: ContextTag,\n Select: AgentSelect,\n});\n\nexport { Prompt };\n"]}
@@ -45,7 +45,7 @@ const Suggestion = (_a) => {
45
45
  'ndl-large': size === 'large',
46
46
  'ndl-small': size === 'small',
47
47
  });
48
- return (_jsx("button", Object.assign({ ref: ref, className: classes, style: style, onClick: onClick }, restProps, htmlAttributes, { children: _jsxs("div", { className: "ndl-ai-suggestion-inner", children: [Boolean(leadingVisual) && (_jsx("div", { className: "ndl-ai-suggestion-leading", children: leadingVisual })), children] }) })));
48
+ return (_jsx("button", Object.assign({ type: "button", ref: ref, className: classes, style: style, onClick: onClick }, restProps, htmlAttributes, { children: _jsxs("div", { className: "ndl-ai-suggestion-inner", children: [Boolean(leadingVisual) && (_jsx("div", { className: "ndl-ai-suggestion-leading", children: leadingVisual })), children] }) })));
49
49
  };
50
50
  export { Suggestion };
51
51
  //# sourceMappingURL=Suggestion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Suggestion.js","sourceRoot":"","sources":["../../../../src/ai/suggestion/Suggestion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AAiBpC;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,EAWqB,EAAE,EAAE;QAXzB,EAClB,QAAQ,EACR,aAAa,EACb,SAAS,EACT,OAAO,EACP,IAAI,GAAG,OAAO,EACd,GAAG,EACH,SAAS,EACT,KAAK,EACL,cAAc,OAEyB,EADpC,SAAS,cAVM,4GAWnB,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,mBAAmB,EAAE,SAAS,EAAE;QACzD,2BAA2B,EAAE,SAAS;QACtC,cAAc,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,QAAQ;QACxC,WAAW,EAAE,IAAI,KAAK,OAAO;QAC7B,WAAW,EAAE,IAAI,KAAK,OAAO;KAC9B,CAAC,CAAC;IAEH,OAAO,CACL,+BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,IACZ,SAAS,EACT,cAAc,cAElB,eAAK,SAAS,EAAC,yBAAyB,aACrC,OAAO,CAAC,aAAa,CAAC,IAAI,CACzB,cAAK,SAAS,EAAC,2BAA2B,YAAE,aAAa,GAAO,CACjE,EACA,QAAQ,IACL,IACC,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,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 */\n\nimport classNames from 'classnames';\n\nimport { type CommonProps } from '../../_common/types';\n\ntype SuggestionProps = {\n /** The content of the suggestion */\n children?: React.ReactNode;\n /** The visual to display before the content. Should be an icon. */\n leadingVisual?: React.ReactNode;\n /** Whether the suggestion is primary. Renders an animated border. */\n isPrimary?: boolean;\n /** Callback function triggered when the suggestion is clicked */\n onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** The size of the suggestion */\n size?: 'small' | 'large';\n};\n\n/**\n * The component is used to display a suggestion in a chat, or in a prompt.\n * It can be primary, which animates its border.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst Suggestion = ({\n children,\n leadingVisual,\n isPrimary,\n onClick,\n size = 'small',\n ref,\n className,\n style,\n htmlAttributes,\n ...restProps\n}: CommonProps<'button', SuggestionProps>) => {\n const classes = classNames('ndl-ai-suggestion', className, {\n 'ndl-ai-suggestion-special': isPrimary,\n 'ndl-disabled': htmlAttributes?.disabled,\n 'ndl-large': size === 'large',\n 'ndl-small': size === 'small',\n });\n\n return (\n <button\n ref={ref}\n className={classes}\n style={style}\n onClick={onClick}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-suggestion-inner\">\n {Boolean(leadingVisual) && (\n <div className=\"ndl-ai-suggestion-leading\">{leadingVisual}</div>\n )}\n {children}\n </div>\n </button>\n );\n};\n\nexport { Suggestion };\n"]}
1
+ {"version":3,"file":"Suggestion.js","sourceRoot":"","sources":["../../../../src/ai/suggestion/Suggestion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AAiBpC;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,EAWqB,EAAE,EAAE;QAXzB,EAClB,QAAQ,EACR,aAAa,EACb,SAAS,EACT,OAAO,EACP,IAAI,GAAG,OAAO,EACd,GAAG,EACH,SAAS,EACT,KAAK,EACL,cAAc,OAEyB,EADpC,SAAS,cAVM,4GAWnB,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,mBAAmB,EAAE,SAAS,EAAE;QACzD,2BAA2B,EAAE,SAAS;QACtC,cAAc,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,QAAQ;QACxC,WAAW,EAAE,IAAI,KAAK,OAAO;QAC7B,WAAW,EAAE,IAAI,KAAK,OAAO;KAC9B,CAAC,CAAC;IAEH,OAAO,CACL,+BACE,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,IACZ,SAAS,EACT,cAAc,cAElB,eAAK,SAAS,EAAC,yBAAyB,aACrC,OAAO,CAAC,aAAa,CAAC,IAAI,CACzB,cAAK,SAAS,EAAC,2BAA2B,YAAE,aAAa,GAAO,CACjE,EACA,QAAQ,IACL,IACC,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,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 */\n\nimport classNames from 'classnames';\n\nimport { type CommonProps } from '../../_common/types';\n\ntype SuggestionProps = {\n /** The content of the suggestion */\n children?: React.ReactNode;\n /** The visual to display before the content. Should be an icon. */\n leadingVisual?: React.ReactNode;\n /** Whether the suggestion is primary. Renders an animated border. */\n isPrimary?: boolean;\n /** Callback function triggered when the suggestion is clicked */\n onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** The size of the suggestion */\n size?: 'small' | 'large';\n};\n\n/**\n * The component is used to display a suggestion in a chat, or in a prompt.\n * It can be primary, which animates its border.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst Suggestion = ({\n children,\n leadingVisual,\n isPrimary,\n onClick,\n size = 'small',\n ref,\n className,\n style,\n htmlAttributes,\n ...restProps\n}: CommonProps<'button', SuggestionProps>) => {\n const classes = classNames('ndl-ai-suggestion', className, {\n 'ndl-ai-suggestion-special': isPrimary,\n 'ndl-disabled': htmlAttributes?.disabled,\n 'ndl-large': size === 'large',\n 'ndl-small': size === 'small',\n });\n\n return (\n <button\n type=\"button\"\n ref={ref}\n className={classes}\n style={style}\n onClick={onClick}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-suggestion-inner\">\n {Boolean(leadingVisual) && (\n <div className=\"ndl-ai-suggestion-leading\">{leadingVisual}</div>\n )}\n {children}\n </div>\n </button>\n );\n};\n\nexport { Suggestion };\n"]}
@@ -85,7 +85,7 @@ const BreadcrumbsSelectButton = (_a) => {
85
85
  const classes = classNames('ndl-breadcrumbs-button ndl-breadcrumbs-sibling-hover ndl-breadcrumbs-select', className, {
86
86
  'ndl-active': Boolean(isActive),
87
87
  });
88
- return (_jsxs("button", Object.assign({ ref: ref, className: classes, style: style, onClick: onClick, "aria-label": ariaLabel, "aria-pressed": isActive }, htmlAttributes, restProps, { children: [_jsx("div", { className: "ndl-breadcrumbs-button-leading-element", children: _jsx(ChevronDownIconOutline, {}) }), _jsx("div", { className: "ndl-breadcrumbs-button-content", children: children })] })));
88
+ return (_jsxs("button", Object.assign({ type: "button", ref: ref, className: classes, style: style, onClick: onClick, "aria-label": ariaLabel, "aria-pressed": isActive }, htmlAttributes, restProps, { children: [_jsx("div", { className: "ndl-breadcrumbs-button-leading-element", children: _jsx(ChevronDownIconOutline, {}) }), _jsx("div", { className: "ndl-breadcrumbs-button-content", children: children })] })));
89
89
  };
90
90
  const BreadcrumbsLink = (_a) => {
91
91
  var { children, as, className, style, htmlAttributes, ariaCurrent = false, ref } = _a, restProps = __rest(_a, ["children", "as", "className", "style", "htmlAttributes", "ariaCurrent", "ref"]);
@@ -1 +1 @@
1
- {"version":3,"file":"Breadcrumbs.js","sourceRoot":"","sources":["../../../src/breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAOpE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AASrC,MAAM,oBAAoB,GAAG,CAAC,EAQS,EAAE,EAAE;QARb,EAC5B,QAAQ,EACR,SAAS,EACT,cAAc,EACd,KAAK,EACL,GAAG,EACH,UAAU,GAAG,IAAI,OAEoB,EADlC,SAAS,cAPgB,yEAQ7B,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,UAAU,CAAC,sBAAsB,EAAE;QACrD,sBAAsB,EAAE,UAAU;KACnC,CAAC,CAAC;IACH,OAAO,CACL,0CACa,YAAY,EACvB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAElB,aAAI,SAAS,EAAE,WAAW,YAAG,QAAQ,GAAM,IACvC,CACP,CAAC;AACJ,CAAC,CAAC;AAMF,MAAM,sBAAsB,GAAG,aAAa,CAC1C,IAAI,CACL,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,GA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AAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE;IACtD,MAAM,EAAE,iBAAiB;IACzB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;IACrB,YAAY,EAAE,uBAAuB;CACtC,CAAC,CAAC;AAEH,OAAO,EAAE,WAAW,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 */\n\nimport { ChevronDownIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { createContext, useContext, useRef, useState } from 'react';\n\nimport {\n type CommonProps,\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { Tooltip } from '../tooltip';\n\ntype BreadcrumbsProps = {\n /** Content to be rendered. Should only be `Breadcrumbs.Item`. */\n children?: React.ReactNode;\n /** Additional classnames. */\n shouldWrap?: boolean;\n};\n\nconst BreadcrumbsComponent = ({\n children,\n className,\n htmlAttributes,\n style,\n ref,\n shouldWrap = true,\n ...restProps\n}: CommonProps<'nav', BreadcrumbsProps>) => {\n const classes = classNames('ndl-breadcrumbs', className);\n const listClasses = classNames('ndl-breadcrumbs-list', {\n 'ndl-breadcrumbs-wrap': shouldWrap,\n });\n return (\n <nav\n aria-label=\"Breadcrumb\"\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <ol className={listClasses}>{children}</ol>\n </nav>\n );\n};\n\ntype BreadcrumbsItemContextType = {\n isInBreadcrumbsItem: boolean;\n};\n\nconst BreadcrumbsItemContext = createContext<BreadcrumbsItemContextType | null>(\n null,\n);\n\nexport const useBreadcrumbsItemContext = (): BreadcrumbsItemContextType => {\n const context = useContext(BreadcrumbsItemContext);\n if (!context) {\n throw new Error('This component must be used within a <Breadcrumbs.Item>');\n }\n\n return context;\n};\n\ntype BreadcrumbsItemProps = {\n /** Content to be rendered. Should be either `Breadcrumbs.Link`, `Breadcrumbs.Button` or `Breadcrumbs.SelectButton`. */\n children?: React.ReactNode;\n};\n\nconst BreadcrumbsItem = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'li', BreadcrumbsItemProps>) => {\n const classes = classNames('ndl-breadcrumbs-item', className);\n\n return (\n <BreadcrumbsItemContext.Provider value={{ isInBreadcrumbsItem: true }}>\n <li\n ref={ref}\n className={classes}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n <div className=\"ndl-breadcrumbs-item-inner\">{children}</div>\n </li>\n </BreadcrumbsItemContext.Provider>\n );\n};\n\ntype InteractiveBreadcrumbProps = {\n /** Content to be rendered. */\n children?: React.ReactNode;\n} & (\n | {\n as: 'button';\n /**\n * Event handler for when the button is clicked. Only applicable if `as` is `'button'`.\n */\n onClick?: (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => void;\n }\n | {\n as: 'a';\n /**\n * The href of the link. Only applicable if `as` is `'a'`.\n */\n href: HtmlAttributes<'a'>['href'];\n /**\n * The target of the link. Only applicable if `as` is `'a'`.\n */\n target?: HtmlAttributes<'a'>['target'];\n }\n | {\n /**\n * What HTML element to render the root element as.\n */\n as?: React.ElementType;\n }\n);\n\ntype BreadcrumbsButtonProps = InteractiveBreadcrumbProps & {\n /** Leading element to be rendered. */\n leadingElement?: React.ReactNode;\n /** Trailing element to be rendered. */\n trailingElement?: React.ReactNode;\n};\n\nconst BreadcrumbsButton = <T extends React.ElementType = 'button'>({\n children,\n as,\n className,\n style,\n htmlAttributes,\n ref,\n leadingElement,\n trailingElement,\n ...restProps\n}: PolymorphicCommonProps<T, BreadcrumbsButtonProps>) => {\n useBreadcrumbsItemContext();\n\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n const contentRef = useRef<HTMLDivElement>(null);\n const Component: React.ElementType = as ?? 'button';\n\n const classes = classNames(\n 'ndl-breadcrumbs-button ndl-breadcrumbs-sibling-hover',\n className,\n );\n\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isTooltipOpen}\n onOpenChange={(isOpen) => {\n if (isOpen) {\n const isTruncated =\n contentRef.current?.scrollWidth &&\n contentRef.current?.clientWidth &&\n contentRef.current.scrollWidth > contentRef.current.clientWidth;\n const isVisible =\n contentRef.current?.offsetWidth &&\n contentRef.current?.offsetHeight &&\n contentRef.current.offsetWidth > 0 &&\n contentRef.current.offsetHeight > 0;\n setIsTooltipOpen(isTruncated || !isVisible);\n } else {\n setIsTooltipOpen(false);\n }\n }}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <Component\n ref={ref}\n className={classes}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n {Boolean(leadingElement) && (\n <div className=\"ndl-breadcrumbs-button-leading-element\">\n {leadingElement}\n </div>\n )}\n <div className=\"ndl-breadcrumbs-button-content\" ref={contentRef}>\n {children}\n </div>\n {Boolean(trailingElement) && (\n <div className=\"ndl-breadcrumbs-button-trailing-element\">\n {trailingElement}\n </div>\n )}\n </Component>\n </Tooltip.Trigger>\n <Tooltip.Content>{children}</Tooltip.Content>\n </Tooltip>\n );\n};\n\ntype BreadcrumbsSelectButtonProps = {\n /** Event handler for when the button is clicked. Should be used to open a `Menu`. */\n onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** Aria label needed for accessibility. */\n ariaLabel: string;\n /** Content to be rendered. */\n children?: React.ReactNode;\n /** Active - used when a connected menu is open */\n isActive?: boolean;\n};\n\nconst BreadcrumbsSelectButton = ({\n onClick,\n children,\n isActive,\n className,\n style,\n htmlAttributes,\n ariaLabel,\n ref,\n ...restProps\n}: CommonProps<'button', BreadcrumbsSelectButtonProps>) => {\n useBreadcrumbsItemContext();\n\n const classes = classNames(\n 'ndl-breadcrumbs-button ndl-breadcrumbs-sibling-hover ndl-breadcrumbs-select',\n className,\n {\n 'ndl-active': Boolean(isActive),\n },\n );\n\n return (\n <button\n ref={ref}\n className={classes}\n style={style}\n onClick={onClick}\n aria-label={ariaLabel}\n aria-pressed={isActive}\n {...htmlAttributes}\n {...restProps}\n >\n <div className=\"ndl-breadcrumbs-button-leading-element\">\n <ChevronDownIconOutline />\n </div>\n <div className=\"ndl-breadcrumbs-button-content\">{children}</div>\n </button>\n );\n};\n\ntype BreadcrumbsLinkProps = InteractiveBreadcrumbProps & {\n /**\n * Whether the link is the current item. Use `'page'` if it indicates the current page and `'step'` for steps (in a multi-step wizard for example).\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current\n */\n ariaCurrent?: React.AriaAttributes['aria-current'];\n};\n\nconst BreadcrumbsLink = <T extends React.ElementType = 'a'>({\n children,\n as,\n className,\n style,\n htmlAttributes,\n ariaCurrent = false,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, BreadcrumbsLinkProps>) => {\n useBreadcrumbsItemContext();\n\n const Component: React.ElementType = as ?? 'a';\n\n const classes = classNames(\n 'ndl-breadcrumbs-link',\n {\n 'ndl-breadcrumbs-link-current': Boolean(ariaCurrent),\n },\n className,\n );\n\n return (\n <Component\n ref={ref}\n className={classes}\n style={style}\n aria-current={ariaCurrent}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n );\n};\n\nconst Breadcrumbs = Object.assign(BreadcrumbsComponent, {\n Button: BreadcrumbsButton,\n Item: BreadcrumbsItem,\n Link: BreadcrumbsLink,\n SelectButton: BreadcrumbsSelectButton,\n});\n\nexport { Breadcrumbs };\n"]}
1
+ {"version":3,"file":"Breadcrumbs.js","sourceRoot":"","sources":["../../../src/breadcrumbs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sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { ChevronDownIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { createContext, useContext, useRef, useState } from 'react';\n\nimport {\n type CommonProps,\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { Tooltip } from '../tooltip';\n\ntype BreadcrumbsProps = {\n /** Content to be rendered. Should only be `Breadcrumbs.Item`. */\n children?: React.ReactNode;\n /** Additional classnames. */\n shouldWrap?: boolean;\n};\n\nconst BreadcrumbsComponent = ({\n children,\n className,\n htmlAttributes,\n style,\n ref,\n shouldWrap = true,\n ...restProps\n}: CommonProps<'nav', BreadcrumbsProps>) => {\n const classes = classNames('ndl-breadcrumbs', className);\n const listClasses = classNames('ndl-breadcrumbs-list', {\n 'ndl-breadcrumbs-wrap': shouldWrap,\n });\n return (\n <nav\n aria-label=\"Breadcrumb\"\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <ol className={listClasses}>{children}</ol>\n </nav>\n );\n};\n\ntype BreadcrumbsItemContextType = {\n isInBreadcrumbsItem: boolean;\n};\n\nconst BreadcrumbsItemContext = createContext<BreadcrumbsItemContextType | null>(\n null,\n);\n\nexport const useBreadcrumbsItemContext = (): BreadcrumbsItemContextType => {\n const context = useContext(BreadcrumbsItemContext);\n if (!context) {\n throw new Error('This component must be used within a <Breadcrumbs.Item>');\n }\n\n return context;\n};\n\ntype BreadcrumbsItemProps = {\n /** Content to be rendered. Should be either `Breadcrumbs.Link`, `Breadcrumbs.Button` or `Breadcrumbs.SelectButton`. */\n children?: React.ReactNode;\n};\n\nconst BreadcrumbsItem = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'li', BreadcrumbsItemProps>) => {\n const classes = classNames('ndl-breadcrumbs-item', className);\n\n return (\n <BreadcrumbsItemContext.Provider value={{ isInBreadcrumbsItem: true }}>\n <li\n ref={ref}\n className={classes}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n <div className=\"ndl-breadcrumbs-item-inner\">{children}</div>\n </li>\n </BreadcrumbsItemContext.Provider>\n );\n};\n\ntype InteractiveBreadcrumbProps = {\n /** Content to be rendered. */\n children?: React.ReactNode;\n} & (\n | {\n as: 'button';\n /**\n * Event handler for when the button is clicked. Only applicable if `as` is `'button'`.\n */\n onClick?: (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => void;\n }\n | {\n as: 'a';\n /**\n * The href of the link. Only applicable if `as` is `'a'`.\n */\n href: HtmlAttributes<'a'>['href'];\n /**\n * The target of the link. Only applicable if `as` is `'a'`.\n */\n target?: HtmlAttributes<'a'>['target'];\n }\n | {\n /**\n * What HTML element to render the root element as.\n */\n as?: React.ElementType;\n }\n);\n\ntype BreadcrumbsButtonProps = InteractiveBreadcrumbProps & {\n /** Leading element to be rendered. */\n leadingElement?: React.ReactNode;\n /** Trailing element to be rendered. */\n trailingElement?: React.ReactNode;\n};\n\nconst BreadcrumbsButton = <T extends React.ElementType = 'button'>({\n children,\n as,\n className,\n style,\n htmlAttributes,\n ref,\n leadingElement,\n trailingElement,\n ...restProps\n}: PolymorphicCommonProps<T, BreadcrumbsButtonProps>) => {\n useBreadcrumbsItemContext();\n\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n const contentRef = useRef<HTMLDivElement>(null);\n const Component: React.ElementType = as ?? 'button';\n\n const classes = classNames(\n 'ndl-breadcrumbs-button ndl-breadcrumbs-sibling-hover',\n className,\n );\n\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isTooltipOpen}\n onOpenChange={(isOpen) => {\n if (isOpen) {\n const isTruncated =\n contentRef.current?.scrollWidth &&\n contentRef.current?.clientWidth &&\n contentRef.current.scrollWidth > contentRef.current.clientWidth;\n const isVisible =\n contentRef.current?.offsetWidth &&\n contentRef.current?.offsetHeight &&\n contentRef.current.offsetWidth > 0 &&\n contentRef.current.offsetHeight > 0;\n setIsTooltipOpen(isTruncated || !isVisible);\n } else {\n setIsTooltipOpen(false);\n }\n }}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <Component\n ref={ref}\n className={classes}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n {Boolean(leadingElement) && (\n <div className=\"ndl-breadcrumbs-button-leading-element\">\n {leadingElement}\n </div>\n )}\n <div className=\"ndl-breadcrumbs-button-content\" ref={contentRef}>\n {children}\n </div>\n {Boolean(trailingElement) && (\n <div className=\"ndl-breadcrumbs-button-trailing-element\">\n {trailingElement}\n </div>\n )}\n </Component>\n </Tooltip.Trigger>\n <Tooltip.Content>{children}</Tooltip.Content>\n </Tooltip>\n );\n};\n\ntype BreadcrumbsSelectButtonProps = {\n /** Event handler for when the button is clicked. Should be used to open a `Menu`. */\n onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** Aria label needed for accessibility. */\n ariaLabel: string;\n /** Content to be rendered. */\n children?: React.ReactNode;\n /** Active - used when a connected menu is open */\n isActive?: boolean;\n};\n\nconst BreadcrumbsSelectButton = ({\n onClick,\n children,\n isActive,\n className,\n style,\n htmlAttributes,\n ariaLabel,\n ref,\n ...restProps\n}: CommonProps<'button', BreadcrumbsSelectButtonProps>) => {\n useBreadcrumbsItemContext();\n\n const classes = classNames(\n 'ndl-breadcrumbs-button ndl-breadcrumbs-sibling-hover ndl-breadcrumbs-select',\n className,\n {\n 'ndl-active': Boolean(isActive),\n },\n );\n\n return (\n <button\n type=\"button\"\n ref={ref}\n className={classes}\n style={style}\n onClick={onClick}\n aria-label={ariaLabel}\n aria-pressed={isActive}\n {...htmlAttributes}\n {...restProps}\n >\n <div className=\"ndl-breadcrumbs-button-leading-element\">\n <ChevronDownIconOutline />\n </div>\n <div className=\"ndl-breadcrumbs-button-content\">{children}</div>\n </button>\n );\n};\n\ntype BreadcrumbsLinkProps = InteractiveBreadcrumbProps & {\n /**\n * Whether the link is the current item. Use `'page'` if it indicates the current page and `'step'` for steps (in a multi-step wizard for example).\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current\n */\n ariaCurrent?: React.AriaAttributes['aria-current'];\n};\n\nconst BreadcrumbsLink = <T extends React.ElementType = 'a'>({\n children,\n as,\n className,\n style,\n htmlAttributes,\n ariaCurrent = false,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, BreadcrumbsLinkProps>) => {\n useBreadcrumbsItemContext();\n\n const Component: React.ElementType = as ?? 'a';\n\n const classes = classNames(\n 'ndl-breadcrumbs-link',\n {\n 'ndl-breadcrumbs-link-current': Boolean(ariaCurrent),\n },\n className,\n );\n\n return (\n <Component\n ref={ref}\n className={classes}\n style={style}\n aria-current={ariaCurrent}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n );\n};\n\nconst Breadcrumbs = Object.assign(BreadcrumbsComponent, {\n Button: BreadcrumbsButton,\n Item: BreadcrumbsItem,\n Link: BreadcrumbsLink,\n SelectButton: BreadcrumbsSelectButton,\n});\n\nexport { Breadcrumbs };\n"]}
@@ -26,7 +26,7 @@ import { useRef, useState } from 'react';
26
26
  const Component = () => {
27
27
  const [isOrganizationMenuOpen, setIsOrganizationMenuOpen] = useState(false);
28
28
  const organizationMenuRef = useRef(null);
29
- return (_jsxs(Breadcrumbs, { shouldWrap: false, children: [_jsx(Breadcrumbs.Item, { className: "n-mr-token-8", children: _jsx("button", { "aria-label": "Home", className: "n-rounded-sm focus-visible:n-outline-2 focus-visible:n-outline-offset-[3px] focus-visible:n-outline-primary-focus n-shrink-0", children: _jsx(Neo4JIconColorIcon, { className: "n-h-6 n-w-[26px]" }) }) }), _jsxs(Breadcrumbs.Item, { children: [_jsx(Breadcrumbs.Button, { leadingElement: _jsx(BuildingOffice2IconOutline, {}), children: "Organization 1" }), _jsx(Breadcrumbs.SelectButton, { ref: organizationMenuRef, ariaLabel: "Open organization menu", onClick: () => {
29
+ return (_jsxs(Breadcrumbs, { shouldWrap: false, children: [_jsx(Breadcrumbs.Item, { className: "n-mr-token-8", children: _jsx("button", { type: "button", "aria-label": "Home", className: "n-rounded-sm focus-visible:n-outline-2 focus-visible:n-outline-offset-[3px] focus-visible:n-outline-primary-focus n-shrink-0", children: _jsx(Neo4JIconColorIcon, { className: "n-h-6 n-w-[26px]" }) }) }), _jsxs(Breadcrumbs.Item, { children: [_jsx(Breadcrumbs.Button, { leadingElement: _jsx(BuildingOffice2IconOutline, {}), children: "Organization 1" }), _jsx(Breadcrumbs.SelectButton, { ref: organizationMenuRef, ariaLabel: "Open organization menu", onClick: () => {
30
30
  setIsOrganizationMenuOpen((prev) => !prev);
31
31
  }, isActive: isOrganizationMenuOpen, children: _jsxs(Menu, { anchorRef: organizationMenuRef, isOpen: isOrganizationMenuOpen, onClose: () => setIsOrganizationMenuOpen(false), children: [_jsxs(Menu.Group, { children: [_jsx(Menu.RadioItem, { title: "Organization 1", isChecked: true }), _jsx(Menu.RadioItem, { title: "Organization 2", isChecked: false })] }), _jsx(Menu.Divider, {}), _jsx(Menu.Group, { children: _jsx(Menu.Item, { title: "All Organizations" }) })] }) })] }), _jsxs(Breadcrumbs.Item, { children: [_jsx(Breadcrumbs.Button, { leadingElement: _jsx(FolderIconOutline, {}), children: "Project 1" }), _jsx(Breadcrumbs.SelectButton, { ariaLabel: "Open project menu" })] })] }));
32
32
  };
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumbs-header.story.js","sourceRoot":"","sources":["../../../../src/breadcrumbs/stories/breadcrumbs-header.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;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AAI,EAC1D,KAAC,IAAI,CAAC,SAAS,IAAC,KAAK,EAAC,gBAAgB,EAAC,SAAS,EAAE,KAAK,GAAI,IAChD,EACb,KAAC,IAAI,CAAC,OAAO,KAAG,EAChB,KAAC,IAAI,CAAC,KAAK,cACT,KAAC,IAAI,CAAC,IAAI,IAAC,KAAK,EAAC,mBAAmB,GAAG,GAC5B,IACR,GACkB,IACV,EACnB,MAAC,WAAW,CAAC,IAAI,eACf,KAAC,WAAW,CAAC,MAAM,IAAC,cAAc,EAAE,KAAC,iBAAiB,KAAG,0BAEpC,EACrB,KAAC,WAAW,CAAC,YAAY,IAAC,SAAS,EAAC,mBAAmB,GAA4B,IAClE,IACP,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Breadcrumbs, Menu } from '@neo4j-ndl/react';\nimport {\n BuildingOffice2IconOutline,\n FolderIconOutline,\n Neo4JIconColorIcon,\n} from '@neo4j-ndl/react/icons';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const [isOrganizationMenuOpen, setIsOrganizationMenuOpen] = useState(false);\n const organizationMenuRef = useRef<HTMLButtonElement>(null);\n\n return (\n <Breadcrumbs shouldWrap={false}>\n <Breadcrumbs.Item className=\"n-mr-token-8\">\n <button\n aria-label=\"Home\"\n className=\"n-rounded-sm focus-visible:n-outline-2 focus-visible:n-outline-offset-[3px] focus-visible:n-outline-primary-focus n-shrink-0\"\n >\n <Neo4JIconColorIcon className=\"n-h-6 n-w-[26px]\" />\n </button>\n </Breadcrumbs.Item>\n <Breadcrumbs.Item>\n <Breadcrumbs.Button leadingElement={<BuildingOffice2IconOutline />}>\n Organization 1\n </Breadcrumbs.Button>\n <Breadcrumbs.SelectButton\n ref={organizationMenuRef}\n ariaLabel=\"Open organization menu\"\n onClick={() => {\n setIsOrganizationMenuOpen((prev) => !prev);\n }}\n isActive={isOrganizationMenuOpen}\n >\n <Menu\n anchorRef={organizationMenuRef}\n isOpen={isOrganizationMenuOpen}\n onClose={() => setIsOrganizationMenuOpen(false)}\n >\n <Menu.Group>\n <Menu.RadioItem title=\"Organization 1\" isChecked={true} />\n <Menu.RadioItem title=\"Organization 2\" isChecked={false} />\n </Menu.Group>\n <Menu.Divider />\n <Menu.Group>\n <Menu.Item title=\"All Organizations\" />\n </Menu.Group>\n </Menu>\n </Breadcrumbs.SelectButton>\n </Breadcrumbs.Item>\n <Breadcrumbs.Item>\n <Breadcrumbs.Button leadingElement={<FolderIconOutline />}>\n Project 1\n </Breadcrumbs.Button>\n <Breadcrumbs.SelectButton ariaLabel=\"Open project menu\"></Breadcrumbs.SelectButton>\n </Breadcrumbs.Item>\n </Breadcrumbs>\n );\n};\n\nexport default Component;\n"]}
1
+ {"version":3,"file":"breadcrumbs-header.story.js","sourceRoot":"","sources":["../../../../src/breadcrumbs/stories/breadcrumbs-header.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,C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,GAAG,GAC5B,IACR,GACkB,IACV,EACnB,MAAC,WAAW,CAAC,IAAI,eACf,KAAC,WAAW,CAAC,MAAM,IAAC,cAAc,EAAE,KAAC,iBAAiB,KAAG,0BAEpC,EACrB,KAAC,WAAW,CAAC,YAAY,IAAC,SAAS,EAAC,mBAAmB,GAA4B,IAClE,IACP,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Breadcrumbs, Menu } from '@neo4j-ndl/react';\nimport {\n BuildingOffice2IconOutline,\n FolderIconOutline,\n Neo4JIconColorIcon,\n} from '@neo4j-ndl/react/icons';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const [isOrganizationMenuOpen, setIsOrganizationMenuOpen] = useState(false);\n const organizationMenuRef = useRef<HTMLButtonElement>(null);\n\n return (\n <Breadcrumbs shouldWrap={false}>\n <Breadcrumbs.Item className=\"n-mr-token-8\">\n <button\n type=\"button\"\n aria-label=\"Home\"\n className=\"n-rounded-sm focus-visible:n-outline-2 focus-visible:n-outline-offset-[3px] focus-visible:n-outline-primary-focus n-shrink-0\"\n >\n <Neo4JIconColorIcon className=\"n-h-6 n-w-[26px]\" />\n </button>\n </Breadcrumbs.Item>\n <Breadcrumbs.Item>\n <Breadcrumbs.Button leadingElement={<BuildingOffice2IconOutline />}>\n Organization 1\n </Breadcrumbs.Button>\n <Breadcrumbs.SelectButton\n ref={organizationMenuRef}\n ariaLabel=\"Open organization menu\"\n onClick={() => {\n setIsOrganizationMenuOpen((prev) => !prev);\n }}\n isActive={isOrganizationMenuOpen}\n >\n <Menu\n anchorRef={organizationMenuRef}\n isOpen={isOrganizationMenuOpen}\n onClose={() => setIsOrganizationMenuOpen(false)}\n >\n <Menu.Group>\n <Menu.RadioItem title=\"Organization 1\" isChecked={true} />\n <Menu.RadioItem title=\"Organization 2\" isChecked={false} />\n </Menu.Group>\n <Menu.Divider />\n <Menu.Group>\n <Menu.Item title=\"All Organizations\" />\n </Menu.Group>\n </Menu>\n </Breadcrumbs.SelectButton>\n </Breadcrumbs.Item>\n <Breadcrumbs.Item>\n <Breadcrumbs.Button leadingElement={<FolderIconOutline />}>\n Project 1\n </Breadcrumbs.Button>\n <Breadcrumbs.SelectButton ariaLabel=\"Open project menu\"></Breadcrumbs.SelectButton>\n </Breadcrumbs.Item>\n </Breadcrumbs>\n );\n};\n\nexport default Component;\n"]}
@@ -213,7 +213,7 @@ const Swatch = ({ colors, onChange, hsva, }) => {
213
213
  const isActive = hsva.h === hsvaColor.h &&
214
214
  hsva.s === hsvaColor.s &&
215
215
  hsva.v === hsvaColor.v;
216
- return (_jsx("button", { "aria-label": hexColor, className: classNames('ndl-color-picker-swatch-color', {
216
+ return (_jsx("button", { type: "button", "aria-label": hexColor, className: classNames('ndl-color-picker-swatch-color', {
217
217
  'ndl-color-picker-swatch-color-active': isActive,
218
218
  }), style: { backgroundColor: hsvaToHex(hsvaColor) }, onClick: () => onChange(hsvaColor) }, hexColor));
219
219
  }) }));