@neo4j-ndl/react 5.6.4 → 6.0.0-alpha.0.d77a467

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 (118) hide show
  1. package/lib/cjs/accordion/Accordion.js +2 -2
  2. package/lib/cjs/accordion/Accordion.js.map +1 -1
  3. package/lib/cjs/ai/preview/Preview.js +1 -1
  4. package/lib/cjs/ai/preview/Preview.js.map +1 -1
  5. package/lib/cjs/ai/reasoning/Reasoning.js +2 -2
  6. package/lib/cjs/ai/reasoning/Reasoning.js.map +1 -1
  7. package/lib/cjs/ai/thinking/Thinking.js +2 -2
  8. package/lib/cjs/ai/thinking/Thinking.js.map +1 -1
  9. package/lib/cjs/avatar/Avatar.js +1 -1
  10. package/lib/cjs/avatar/Avatar.js.map +1 -1
  11. package/lib/cjs/banner/Banner.js +1 -1
  12. package/lib/cjs/banner/Banner.js.map +1 -1
  13. package/lib/cjs/data-grid/Components.js +1 -1
  14. package/lib/cjs/data-grid/Components.js.map +1 -1
  15. package/lib/cjs/date-picker/DatePicker.js +2 -2
  16. package/lib/cjs/date-picker/DatePicker.js.map +1 -1
  17. package/lib/cjs/dialog/Dialog.js +1 -1
  18. package/lib/cjs/dialog/Dialog.js.map +1 -1
  19. package/lib/cjs/drawer/Drawer.js +1 -1
  20. package/lib/cjs/drawer/Drawer.js.map +1 -1
  21. package/lib/cjs/dropzone/Dropzone.js +2 -2
  22. package/lib/cjs/dropzone/Dropzone.js.map +1 -1
  23. package/lib/cjs/icons/index.js +1 -1
  24. package/lib/cjs/index.js +4 -2
  25. package/lib/cjs/index.js.map +1 -1
  26. package/lib/cjs/inline-edit/InlineEdit.js +1 -1
  27. package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
  28. package/lib/cjs/inline-edit/utils.js +2 -4
  29. package/lib/cjs/inline-edit/utils.js.map +1 -1
  30. package/lib/cjs/search-field/SearchField.js +94 -0
  31. package/lib/cjs/search-field/SearchField.js.map +1 -0
  32. package/lib/cjs/search-field/index.js +30 -0
  33. package/lib/cjs/search-field/index.js.map +1 -0
  34. package/lib/cjs/side-navigation/SideNavigation.js +2 -2
  35. package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
  36. package/lib/cjs/spotlight/Spotlight.js +1 -1
  37. package/lib/cjs/spotlight/Spotlight.js.map +1 -1
  38. package/lib/cjs/tabs/Tabs.js +1 -1
  39. package/lib/cjs/tabs/Tabs.js.map +1 -1
  40. package/lib/cjs/text-input/TextInput.js +1 -1
  41. package/lib/cjs/text-input/TextInput.js.map +1 -1
  42. package/lib/cjs/tooltip/Tooltip.js +1 -1
  43. package/lib/cjs/tooltip/Tooltip.js.map +1 -1
  44. package/lib/cjs/tree-view/TreeViewTextItem.js +1 -1
  45. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  46. package/lib/esm/accordion/Accordion.mjs +2 -2
  47. package/lib/esm/accordion/Accordion.mjs.map +1 -1
  48. package/lib/esm/ai/preview/Preview.mjs +1 -1
  49. package/lib/esm/ai/preview/Preview.mjs.map +1 -1
  50. package/lib/esm/ai/reasoning/Reasoning.mjs +2 -2
  51. package/lib/esm/ai/reasoning/Reasoning.mjs.map +1 -1
  52. package/lib/esm/ai/thinking/Thinking.mjs +2 -2
  53. package/lib/esm/ai/thinking/Thinking.mjs.map +1 -1
  54. package/lib/esm/avatar/Avatar.mjs +1 -1
  55. package/lib/esm/avatar/Avatar.mjs.map +1 -1
  56. package/lib/esm/banner/Banner.mjs +1 -1
  57. package/lib/esm/banner/Banner.mjs.map +1 -1
  58. package/lib/esm/data-grid/Components.mjs +1 -1
  59. package/lib/esm/data-grid/Components.mjs.map +1 -1
  60. package/lib/esm/date-picker/DatePicker.mjs +2 -2
  61. package/lib/esm/date-picker/DatePicker.mjs.map +1 -1
  62. package/lib/esm/dialog/Dialog.mjs +1 -1
  63. package/lib/esm/dialog/Dialog.mjs.map +1 -1
  64. package/lib/esm/drawer/Drawer.mjs +1 -1
  65. package/lib/esm/drawer/Drawer.mjs.map +1 -1
  66. package/lib/esm/dropzone/Dropzone.mjs +2 -2
  67. package/lib/esm/dropzone/Dropzone.mjs.map +1 -1
  68. package/lib/esm/icons/index.mjs +1 -1
  69. package/lib/esm/index.mjs +4 -3
  70. package/lib/esm/index.mjs.map +1 -1
  71. package/lib/esm/inline-edit/InlineEdit.mjs +1 -1
  72. package/lib/esm/inline-edit/InlineEdit.mjs.map +1 -1
  73. package/lib/esm/inline-edit/utils.mjs +2 -4
  74. package/lib/esm/inline-edit/utils.mjs.map +1 -1
  75. package/lib/esm/search-field/SearchField.mjs +89 -0
  76. package/lib/esm/search-field/SearchField.mjs.map +1 -0
  77. package/lib/esm/search-field/index.mjs +24 -0
  78. package/lib/esm/search-field/index.mjs.map +1 -0
  79. package/lib/esm/side-navigation/SideNavigation.mjs +2 -2
  80. package/lib/esm/side-navigation/SideNavigation.mjs.map +1 -1
  81. package/lib/esm/spotlight/Spotlight.mjs +1 -1
  82. package/lib/esm/spotlight/Spotlight.mjs.map +1 -1
  83. package/lib/esm/tabs/Tabs.mjs +1 -1
  84. package/lib/esm/tabs/Tabs.mjs.map +1 -1
  85. package/lib/esm/text-input/TextInput.mjs +1 -1
  86. package/lib/esm/text-input/TextInput.mjs.map +1 -1
  87. package/lib/esm/tooltip/Tooltip.mjs +1 -1
  88. package/lib/esm/tooltip/Tooltip.mjs.map +1 -1
  89. package/lib/esm/tree-view/TreeViewTextItem.mjs +1 -1
  90. package/lib/esm/tree-view/TreeViewTextItem.mjs.map +1 -1
  91. package/lib/types/ai/thinking/Thinking.d.ts.map +1 -1
  92. package/lib/types/index.d.ts +1 -0
  93. package/lib/types/index.d.ts.map +1 -1
  94. package/lib/types/inline-edit/InlineEdit.d.ts +1 -1
  95. package/lib/types/inline-edit/utils.d.ts.map +1 -1
  96. package/lib/types/search-field/SearchField.d.ts +52 -0
  97. package/lib/types/search-field/SearchField.d.ts.map +1 -0
  98. package/lib/types/search-field/index.d.ts +22 -0
  99. package/lib/types/search-field/index.d.ts.map +1 -0
  100. package/package.json +9 -3
  101. package/skills/ndl-react/SKILL.md +3 -2
  102. package/skills/ndl-react/components/accordion.md +3 -3
  103. package/skills/ndl-react/components/clean-icon-button.md +5 -5
  104. package/skills/ndl-react/components/date-picker.md +2 -2
  105. package/skills/ndl-react/components/dropzone.md +2 -2
  106. package/skills/ndl-react/components/icon-button.md +5 -5
  107. package/skills/ndl-react/components/inline-edit.md +1 -1
  108. package/skills/ndl-react/components/radio.md +1 -1
  109. package/skills/ndl-react/components/search-field.md +254 -0
  110. package/skills/ndl-react/components/select-icon-button.md +6 -6
  111. package/skills/ndl-react/components/side-navigation.md +4 -4
  112. package/skills/ndl-react/components/skeleton.md +3 -3
  113. package/skills/ndl-react/components/status-indicator.md +5 -5
  114. package/skills/ndl-react/components/tabs.md +4 -4
  115. package/skills/ndl-react/components/timezone-picker.md +1 -1
  116. package/skills/ndl-react/components/tooltip.md +1 -1
  117. package/skills/ndl-react/components/typography.md +2 -2
  118. package/skills/ndl-react/references/styling.md +1 -1
@@ -107,7 +107,7 @@ const AccordionComponent = function AccordionComponent(_ref) {
107
107
  }) }));
108
108
  };
109
109
  const createItemId = (type, id) => `ndl-accordionitem${type}id-${id}`;
110
- const BaseAccordionItem = ({ itemId, children, title, className = "", arrowPosition = "leading", isDisabled = false, onExpandedChange, htmlAttributes, style, as, titleTypographyVariant = "subheading-medium", hasDivider = true, trailingContent, headingLevel = 2 }) => {
110
+ const BaseAccordionItem = ({ itemId, children, title, className = "", arrowPosition = "leading", isDisabled = false, onExpandedChange, htmlAttributes, style, as, titleTypographyVariant = "subheading-large", hasDivider = true, trailingContent, headingLevel = 2 }) => {
111
111
  const contentRef = (0, react.useRef)(null);
112
112
  const innerContentRef = (0, react.useRef)(null);
113
113
  const itemElementId = createItemId("item", itemId);
@@ -220,7 +220,7 @@ const BaseAccordionItem = ({ itemId, children, title, className = "", arrowPosit
220
220
  * @remarks
221
221
  * Where `T` is of the type `string | number | undefined`.
222
222
  *
223
- * `TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code' | 'label'`.
223
+ * `TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code'`.
224
224
  */
225
225
  const AccordionItem = (_ref3) => {
226
226
  let { className } = _ref3, restProps = require_objectWithoutProperties.default(_ref3, _excluded3);
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.js","names":["findUntil","useRef","classNames","AccordionContext","useAccordionContext","useCallback","Typography","ChevronDownIconOutline","Divider"],"sources":["../../../src/accordion/Accordion.tsx"],"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/generated/heroIcons/ChevronDownIconOutline';\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 headingLevel = 2,\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 <Typography\n as={`h${headingLevel}`}\n variant={titleTypographyVariant}\n className=\"ndl-accordion-item-heading\"\n >\n <button\n type=\"button\"\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <span className={titleClasses}>{title}</span>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n 'ndl-expanded': isExpanded,\n })}\n />\n </span>\n </button>\n </Typography>\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=\"ndl-accordion-item-content-text\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\n/**\n * @remarks\n * Where `T` is of the type `string | number | undefined`.\n *\n * `TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code' | 'label'`.\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\n/**\n * @remarks\n * Where `T` is of the type `string | number | undefined`.\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AA+DQ,MAAA,aAAA,CAAA,mBAAiB,gBAAA;AA+NzB,MAAA,aAAA,CAAA,WAAA;AAsBA,MAAA,aAAA,CAAA,WAAA;AA5UF,MAAM,oBACJ,kBACA,UACA,YAA6B,WACV;CACnB,MAAM,aAAa,iBAAiB,QAAA,qBAA8B;CAClE,IAAI,CAAC,YACH,OAAO;CAGT,OAAOA,sBAAAA,UAAU,WAAW,YAAY,QAAQ;AAClD;AAEA,MAAM,qBAAqB,SAAS,mBAGlC,MAU+C;CAV/C,IAAA,EACA,UACA,IACA,YACA,UACA,WACA,OACA,gBACA,QAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,gBAAA,GAAeC,MAAAA,OAAAA,CAAU,IAAI;CAEnC,CAAA,GAAA,MAAA,oBAAA,CAAoB,WAAW,aAAa,OAAQ;CAEpD,MAAM,YAA+B,MAAM;CAI3C,MAAM,iBAAiB,UAA+C;EAEpE,IAAI,CADqB,aAAa,SAEpC;EAEF,MAAM,gBAAgB,SAAS;EAC/B,IAAI,MAAM,QAAQ,aAAa;GAC7B,MAAM,eAAe;GACrB,MAAM,gBAAgB;GACtB,MAAM,oBAAoB,iBACxB,eAAA,yDAEA,MACF;GACA,MAAM,YAAA,sBAAA,QAAA,sBAAA,KAAA,IAAA,KAAA,IAAY,kBAAmB;GAErC,IAAI,aAAa,qBAAqB,aACpC,mBAAmB,SAAwB;EAE/C,OAAO,IAAI,MAAM,QAAQ,WAAW;GAClC,MAAM,eAAe;GACrB,MAAM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ef","classNames","AccordionContext","useAccordionContext","useCallback","Typography","ChevronDownIconOutline","Divider"],"sources":["../../../src/accordion/Accordion.tsx"],"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/generated/heroIcons/ChevronDownIconOutline';\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-large',\n hasDivider = true,\n trailingContent,\n headingLevel = 2,\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 <Typography\n as={`h${headingLevel}`}\n variant={titleTypographyVariant}\n className=\"ndl-accordion-item-heading\"\n >\n <button\n type=\"button\"\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <span className={titleClasses}>{title}</span>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n 'ndl-expanded': isExpanded,\n })}\n />\n </span>\n </button>\n </Typography>\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=\"ndl-accordion-item-content-text\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\n/**\n * @remarks\n * Where `T` is of the type `string | number | undefined`.\n *\n * `TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code'`.\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\n/**\n * @remarks\n * Where `T` is of the type `string | number | undefined`.\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AA+DQ,MAAA,aAAA,CAAA,mBAAiB,gBAAA;AA+NzB,MAAA,aAAA,CAAA,WAAA;AAsBA,MAAA,aAAA,CAAA,WAAA;AA5UF,MAAM,oBACJ,kB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SAAD,CAAU,CAAA;CAChB,EAAA,CAAA,CAAA;AAEf;;;;;;;AAQA,MAAM,iBAGJ,UAGoD;CAHpD,IAAA,EACA,cAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,MAAM,WAAA,GAAUN,WAAAA,QAAAA,CAAW,8BAA8B,SAAS;CAElE,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAA,sBAAA,QAAA,sBAAA,QAAA,CAAA,GAAsB,SAAA,GAAA,CAAA,GAAA,EAAW,WAAW,QAAA,CAAU,CAAA;AAChE;AACA,cAAc,cAAc;AAW5B,MAAM,aAGJ,UAGkD;CAHlD,IAAA,EACA,cAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,MAAM,WAAA,GAAUA,WAAAA,QAAAA,CAAW,4BAA4B,SAAS;CAEhE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAA,sBAAA,QAAA,sBAAA,QAAA,CAAA,GAAsB,SAAA,GAAA,CAAA,GAAA;EAAW,WAAW;EAAS,YAAY;CAAQ,CAAA,CAAA;AAE9E;AAEA,UAAU,cAAc;AAExB,MAAM,YAAY,OAAO,OAAO,oBAAoB;CACvC;CACX,MAAM;AACR,CAAC"}
@@ -124,7 +124,7 @@ const PreviewConfirmation = (_ref3) => {
124
124
  style
125
125
  }, restProps), htmlAttributes), {}, { children: [!(isFooter && status !== "pending") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_neo4j_ndl_react.Typography, {
126
126
  as: "div",
127
- variant: isFooter ? "subheading-small" : "body-medium",
127
+ variant: isFooter ? "subheading-medium" : "body-medium",
128
128
  className: "ndl-ai-preview-confirmation-content",
129
129
  children
130
130
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_neo4j_ndl_react.Typography, {
@@ -1 +1 @@
1
- {"version":3,"file":"Preview.js","names":["classNames","Typography","TruncatedTextWithTooltip","CheckIconOutline","XMarkIconOutline","useState","useNeedleTheme","Languages","ndlCodeDark","ndlCodeLight","style","LoadingSpinner","ClipboardButton","StatusLabel","SyntaxHighlighter"],"sources":["../../../../src/ai/preview/Preview.tsx"],"sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n ClipboardButton,\n type CodeBlock,\n LoadingSpinner,\n StatusLabel,\n Typography,\n useNeedleTheme,\n} from '@neo4j-ndl/react';\nimport classNames from 'classnames';\nimport { useEffect, useState } from 'react';\nimport { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';\n\nimport { TruncatedTextWithTooltip } from '../../_common/TruncatedTextWithTooltip';\nimport { type CommonProps } from '../../_common/types';\nimport {\n type LanguageProp,\n Languages,\n loadLanguage,\n} from '../../code-block/code-languages';\nimport ndlCodeDark from '../../code-block/themes/ndl-code-dark';\nimport ndlCodeLight from '../../code-block/themes/ndl-code-light';\nimport { CheckIconOutline } from '../../icons/generated/heroIcons/CheckIconOutline';\nimport { XMarkIconOutline } from '../../icons/generated/heroIcons/XMarkIconOutline';\n\ntype PreviewProps = {\n children: React.ReactNode;\n};\n\n/**\n * Component to use for previewing certain content in AI chat applications.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PreviewComponent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\ntype PreviewHeaderProps = {\n /** The content to display in the header. When a plain string is passed, it truncates with an ellipsis and shows a tooltip with the full text when space is limited. */\n children?: React.ReactNode;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n actions?: React.ReactNode;\n};\n\nconst PreviewHeader = ({\n children,\n actions,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewHeaderProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-header', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Typography\n variant=\"code\"\n as=\"div\"\n className=\"ndl-ai-preview-header-leading-content\"\n >\n {typeof children === 'string' ? (\n <TruncatedTextWithTooltip text={children} />\n ) : (\n children\n )}\n </Typography>\n\n {actions && (\n <div className=\"ndl-ai-preview-header-actions\">{actions}</div>\n )}\n </div>\n );\n};\n\ntype PreviewConfirmationProps = {\n /** The content to display in the confirmation */\n children?: React.ReactNode;\n /** The actions to display in the confirmation, usually two buttons; one for confirming and one for rejecting. */\n actions: React.ReactNode;\n /** Whether the confirmation is used as a footer */\n isFooter?: boolean;\n /** The status of the confirmation */\n status?: 'pending' | 'confirmed' | 'rejected';\n /** The text to display for the confirmed status */\n confirmedActionText?: string;\n /** The text to display for the rejected status */\n rejectedActionText?: string;\n};\n\nconst PreviewConfirmation = ({\n children,\n actions,\n isFooter = false,\n status = 'pending',\n confirmedActionText = 'Action confirmed',\n rejectedActionText = 'Action rejected',\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewConfirmationProps>) => {\n const classes = classNames('ndl-ai-preview-confirmation', className, {\n 'ndl-ai-preview-confirmation-footer': isFooter,\n });\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {!(isFooter && status !== 'pending') && (\n <Typography\n as=\"div\"\n variant={isFooter ? 'subheading-small' : 'body-medium'}\n className=\"ndl-ai-preview-confirmation-content\"\n >\n {children}\n </Typography>\n )}\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-ai-preview-confirmation-actions\"\n >\n {status === 'pending' && actions}\n {status === 'confirmed' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <CheckIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {confirmedActionText}\n </div>\n )}\n {status === 'rejected' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <XMarkIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {rejectedActionText}\n </div>\n )}\n </Typography>\n </div>\n );\n};\n\ntype PreviewCodeProps = {\n /** The code content to display */\n code: string;\n /** The language of the code (e.g., 'cypher', 'python', 'javascript') */\n language: React.ComponentProps<typeof CodeBlock>['language'];\n /** The current state of the code block\n * @deprecated - The query should be described in the heading property instead.\n */\n label?: 'read' | 'write';\n /** Whether the code block is loading */\n isLoading?: boolean;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n headerActions?: React.ReactNode;\n /** The theme of the code block */\n theme?: 'ndl-code-dark' | 'ndl-code-light';\n /** The heading to display in the header. If not provided, the language will be displayed. Truncates with an ellipsis and shows a tooltip with the full text when space is limited. */\n heading?: string;\n};\n\nconst PreviewCode = ({\n code,\n language,\n label,\n isLoading = false,\n headerActions,\n theme,\n heading,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewCodeProps>) => {\n const [loadedLanguage, setLoadedLanguage] = useState<\n PreviewCodeProps['language'] | null\n >(null);\n const { theme: ndlTheme } = useNeedleTheme();\n\n useEffect(() => {\n if (!language || !(Languages as readonly string[]).includes(language)) {\n setLoadedLanguage('text');\n return;\n }\n\n loadLanguage(language as LanguageProp)\n .then((module) => {\n SyntaxHighlighter.registerLanguage(language, module.default);\n setLoadedLanguage(language);\n })\n .catch((err) => console.error(err));\n }, [language]);\n\n const getTheme = () => {\n switch (theme) {\n case 'ndl-code-dark':\n return ndlCodeDark;\n case 'ndl-code-light':\n return ndlCodeLight;\n default:\n return ndlTheme === 'light' ? ndlCodeLight : ndlCodeDark;\n }\n };\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-code', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {isLoading && (\n <div className=\"ndl-ai-preview-code-loading\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"code\">\n WRITING {language.toUpperCase()}\n </Typography>\n </div>\n )}\n {!isLoading && (\n <>\n <PreviewHeader\n className=\"ndl-ai-preview-code-header\"\n actions={\n <>\n <ClipboardButton\n textToCopy={code}\n type=\"clean-icon-button\"\n size=\"small\"\n />\n {headerActions}\n </>\n }\n >\n <TruncatedTextWithTooltip\n className=\"ndl-ai-preview-code-header-heading\"\n text={\n heading ??\n `${language}${language.toLowerCase() === 'cypher' ? ' QUERY' : ''}`\n }\n />\n {label && (\n <StatusLabel\n variant={label === 'write' ? 'warning' : 'info'}\n size=\"small\"\n fill=\"semi-filled\"\n >\n {label.toUpperCase()}\n </StatusLabel>\n )}\n </PreviewHeader>\n <div className=\"ndl-ai-preview-code-content\">\n <SyntaxHighlighter\n language={loadedLanguage ?? 'text'}\n style={{\n ...getTheme(),\n 'pre[class*=\"language-\"]': {\n border: 0,\n color: 'var(--theme-color-neutral-text-default)',\n lineHeight: '1',\n overflowX: 'auto',\n padding: 'var(--space-12)',\n width: 'fit-content',\n },\n }}\n // Turn on 'shouldShowLineNumbers' & 'wrapLongLines' at the same time, the display is wrong\n // https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/402\n // wrapLongLines\n showLineNumbers={false}\n // Any value on codeTagProps replaces the library default, which would inline the theme's code styles\n codeTagProps={{}}\n >\n {code}\n </SyntaxHighlighter>\n </div>\n </>\n )}\n </div>\n );\n};\n\ntype PreviewContentProps = {\n children?: React.ReactNode;\n};\n\nconst PreviewContent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewContentProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-content', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nexport const Preview = Object.assign(PreviewComponent, {\n Code: PreviewCode,\n Confirmation: PreviewConfirmation,\n Content: PreviewContent,\n Header: PreviewHeader,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDE;CACA;CACA;CACA;CACA;;;CAwBA;CACA;CACA;CACA;CACA;CACA;;;CA8CA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAmEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAoHA;CACA;CACA;CACA;CACA;;;;;;;AA9RF,MAAM,oBAAoB,SAOc;CAPd,IAAA,EACxB,UACA,KACA,OACA,WACA,mBAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACM;EACE;EACP,YAAA,GAAWA,WAAAA,QAAAA,CAAW,kBAAkB,SAAS;CAC7C,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACE,CAAA;AAET;AASA,MAAM,iBAAiB,UAQuB;CARvB,IAAA,EACrB,UACA,SACA,KACA,OACA,WACA,mBAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACM;EACE;EACP,YAAA,GAAWA,WAAAA,QAAAA,CAAW,yBAAyB,SAAS;CACpD,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAAA,UALN,CAOE,iBAAA,GAAA,kBAAA,IAAA,CAACC,iBAAAA,YAAD;EACE,SAAQ;EACR,IAAG;EACH,WAAU;EAET,UAAA,OAAO,aAAa,WACnB,iBAAA,GAAA,kBA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AkB,UAOuB;CAPvB,IAAA,EACtB,UACA,KACA,OACA,WACA,mBAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACM;EACE;EACP,YAAA,GAAWd,WAAAA,QAAAA,CAAW,0BAA0B,SAAS;CACrD,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACE,CAAA;AAET;AAEA,MAAa,UAAU,OAAO,OAAO,kBAAkB;CACrD,MAAM;CACN,cAAc;CACd,SAAS;CACT,QAAQ;AACV,CAAC"}
1
+ {"version":3,"file":"Preview.js","names":["classNames","Typography","TruncatedTextWithTooltip","CheckIconOutline","XMarkIconOutline","useState","useNeedleTheme","Languages","ndlCodeDark","ndlCodeLight","style","LoadingSpinner","ClipboardButton","StatusLabel","SyntaxHighlighter"],"sources":["../../../../src/ai/preview/Preview.tsx"],"sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n ClipboardButton,\n type CodeBlock,\n LoadingSpinner,\n StatusLabel,\n Typography,\n useNeedleTheme,\n} from '@neo4j-ndl/react';\nimport classNames from 'classnames';\nimport { useEffect, useState } from 'react';\nimport { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';\n\nimport { TruncatedTextWithTooltip } from '../../_common/TruncatedTextWithTooltip';\nimport { type CommonProps } from '../../_common/types';\nimport {\n type LanguageProp,\n Languages,\n loadLanguage,\n} from '../../code-block/code-languages';\nimport ndlCodeDark from '../../code-block/themes/ndl-code-dark';\nimport ndlCodeLight from '../../code-block/themes/ndl-code-light';\nimport { CheckIconOutline } from '../../icons/generated/heroIcons/CheckIconOutline';\nimport { XMarkIconOutline } from '../../icons/generated/heroIcons/XMarkIconOutline';\n\ntype PreviewProps = {\n children: React.ReactNode;\n};\n\n/**\n * Component to use for previewing certain content in AI chat applications.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PreviewComponent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\ntype PreviewHeaderProps = {\n /** The content to display in the header. When a plain string is passed, it truncates with an ellipsis and shows a tooltip with the full text when space is limited. */\n children?: React.ReactNode;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n actions?: React.ReactNode;\n};\n\nconst PreviewHeader = ({\n children,\n actions,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewHeaderProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-header', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Typography\n variant=\"code\"\n as=\"div\"\n className=\"ndl-ai-preview-header-leading-content\"\n >\n {typeof children === 'string' ? (\n <TruncatedTextWithTooltip text={children} />\n ) : (\n children\n )}\n </Typography>\n\n {actions && (\n <div className=\"ndl-ai-preview-header-actions\">{actions}</div>\n )}\n </div>\n );\n};\n\ntype PreviewConfirmationProps = {\n /** The content to display in the confirmation */\n children?: React.ReactNode;\n /** The actions to display in the confirmation, usually two buttons; one for confirming and one for rejecting. */\n actions: React.ReactNode;\n /** Whether the confirmation is used as a footer */\n isFooter?: boolean;\n /** The status of the confirmation */\n status?: 'pending' | 'confirmed' | 'rejected';\n /** The text to display for the confirmed status */\n confirmedActionText?: string;\n /** The text to display for the rejected status */\n rejectedActionText?: string;\n};\n\nconst PreviewConfirmation = ({\n children,\n actions,\n isFooter = false,\n status = 'pending',\n confirmedActionText = 'Action confirmed',\n rejectedActionText = 'Action rejected',\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewConfirmationProps>) => {\n const classes = classNames('ndl-ai-preview-confirmation', className, {\n 'ndl-ai-preview-confirmation-footer': isFooter,\n });\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {!(isFooter && status !== 'pending') && (\n <Typography\n as=\"div\"\n variant={isFooter ? 'subheading-medium' : 'body-medium'}\n className=\"ndl-ai-preview-confirmation-content\"\n >\n {children}\n </Typography>\n )}\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-ai-preview-confirmation-actions\"\n >\n {status === 'pending' && actions}\n {status === 'confirmed' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <CheckIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {confirmedActionText}\n </div>\n )}\n {status === 'rejected' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <XMarkIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {rejectedActionText}\n </div>\n )}\n </Typography>\n </div>\n );\n};\n\ntype PreviewCodeProps = {\n /** The code content to display */\n code: string;\n /** The language of the code (e.g., 'cypher', 'python', 'javascript') */\n language: React.ComponentProps<typeof CodeBlock>['language'];\n /** The current state of the code block\n * @deprecated - The query should be described in the heading property instead.\n */\n label?: 'read' | 'write';\n /** Whether the code block is loading */\n isLoading?: boolean;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n headerActions?: React.ReactNode;\n /** The theme of the code block */\n theme?: 'ndl-code-dark' | 'ndl-code-light';\n /** The heading to display in the header. If not provided, the language will be displayed. Truncates with an ellipsis and shows a tooltip with the full text when space is limited. */\n heading?: string;\n};\n\nconst PreviewCode = ({\n code,\n language,\n label,\n isLoading = false,\n headerActions,\n theme,\n heading,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewCodeProps>) => {\n const [loadedLanguage, setLoadedLanguage] = useState<\n PreviewCodeProps['language'] | null\n >(null);\n const { theme: ndlTheme } = useNeedleTheme();\n\n useEffect(() => {\n if (!language || !(Languages as readonly string[]).includes(language)) {\n setLoadedLanguage('text');\n return;\n }\n\n loadLanguage(language as LanguageProp)\n .then((module) => {\n SyntaxHighlighter.registerLanguage(language, module.default);\n setLoadedLanguage(language);\n })\n .catch((err) => console.error(err));\n }, [language]);\n\n const getTheme = () => {\n switch (theme) {\n case 'ndl-code-dark':\n return ndlCodeDark;\n case 'ndl-code-light':\n return ndlCodeLight;\n default:\n return ndlTheme === 'light' ? ndlCodeLight : ndlCodeDark;\n }\n };\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-code', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {isLoading && (\n <div className=\"ndl-ai-preview-code-loading\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"code\">\n WRITING {language.toUpperCase()}\n </Typography>\n </div>\n )}\n {!isLoading && (\n <>\n <PreviewHeader\n className=\"ndl-ai-preview-code-header\"\n actions={\n <>\n <ClipboardButton\n textToCopy={code}\n type=\"clean-icon-button\"\n size=\"small\"\n />\n {headerActions}\n </>\n }\n >\n <TruncatedTextWithTooltip\n className=\"ndl-ai-preview-code-header-heading\"\n text={\n heading ??\n `${language}${language.toLowerCase() === 'cypher' ? ' QUERY' : ''}`\n }\n />\n {label && (\n <StatusLabel\n variant={label === 'write' ? 'warning' : 'info'}\n size=\"small\"\n fill=\"semi-filled\"\n >\n {label.toUpperCase()}\n </StatusLabel>\n )}\n </PreviewHeader>\n <div className=\"ndl-ai-preview-code-content\">\n <SyntaxHighlighter\n language={loadedLanguage ?? 'text'}\n style={{\n ...getTheme(),\n 'pre[class*=\"language-\"]': {\n border: 0,\n color: 'var(--theme-color-neutral-text-default)',\n lineHeight: '1',\n overflowX: 'auto',\n padding: 'var(--space-12)',\n width: 'fit-content',\n },\n }}\n // Turn on 'shouldShowLineNumbers' & 'wrapLongLines' at the same time, the display is wrong\n // https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/402\n // wrapLongLines\n showLineNumbers={false}\n // Any value on codeTagProps replaces the library default, which would inline the theme's code styles\n codeTagProps={{}}\n >\n {code}\n </SyntaxHighlighter>\n </div>\n </>\n )}\n </div>\n );\n};\n\ntype PreviewContentProps = {\n children?: React.ReactNode;\n};\n\nconst PreviewContent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewContentProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-content', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nexport const Preview = Object.assign(PreviewComponent, {\n Code: PreviewCode,\n Confirmation: PreviewConfirmation,\n Content: PreviewContent,\n Header: PreviewHeader,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDE;CACA;CACA;CACA;CACA;;;CAwBA;CACA;CACA;CACA;CACA;CACA;;;CA8CA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAmEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAoHA;CACA;CACA;CACA;CACA;;;;;;;AA9RF,MAAM,oBAAoB,SAOc;CAPd,IAAA,EACxB,UACA,KACA,OACA,WACA,mBAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACM;EACE;EACP,YAAA,GAAWA,WAAAA,QAAAA,CAAW,kBAAkB,SAAS;CAC7C,G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,UAAA,MAAM,YAAY;EACR,CAAA,CAEF;CACf,CAAA,GAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EACb,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,YAAD;GACE,UAAU,mBAAA,QAAA,mBAAA,KAAA,IAAA,iBAAkB;GAC5B,OAAA,sBAAA,QAAA,sBAAA,QAAA,CAAA,GACK,SAAS,CAAA,GAAA,CAAA,GAAA,EACZ,6BAA2B;IACzB,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,WAAW;IACX,SAAS;IACT,OAAO;GACT,EAAA,CACF;GAIA,iBAAiB;GAEjB,cAAc,CAAC;GAEd,UAAA;EACgB,CAAA;CAChB,CAAA,CACL,EAAA,CAAA,CAED,EAAA,CAAA,CAAA;AAET;AAMA,MAAM,kBAAkB,UAOuB;CAPvB,IAAA,EACtB,UACA,KACA,OACA,WACA,mBAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACM;EACE;EACP,YAAA,GAAWd,WAAAA,QAAAA,CAAW,0BAA0B,SAAS;CACrD,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACE,CAAA;AAET;AAEA,MAAa,UAAU,OAAO,OAAO,kBAAkB;CACrD,MAAM;CACN,cAAc;CACd,SAAS;CACT,QAAQ;AACV,CAAC"}
@@ -80,7 +80,7 @@ const ReasoningComponent = (_ref) => {
80
80
  className: classes,
81
81
  style
82
82
  }, restProps), htmlAttributes), {}, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_neo4j_ndl_react.Typography, require_objectSpread2.default(require_objectSpread2.default({
83
- variant: "label",
83
+ variant: "title-4",
84
84
  className: (0, classnames.default)("ndl-ai-reasoning-header", { "ndl-expanded": isExpanded })
85
85
  }, !isThinking ? {
86
86
  as: "button",
@@ -134,7 +134,7 @@ const Section = (_ref2) => {
134
134
  className: "ndl-ai-reasoning-section-leading",
135
135
  children: leadingVisual
136
136
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_neo4j_ndl_react.Typography, {
137
- variant: "subheading-small",
137
+ variant: "subheading-medium",
138
138
  children: heading
139
139
  })]
140
140
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1 +1 @@
1
- {"version":3,"file":"Reasoning.js","names":["classNames","useState","useId","formatThinkingDuration","Typography","Presence","ChevronDownIconOutline"],"sources":["../../../../src/ai/reasoning/Reasoning.tsx"],"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 { Typography } from '@neo4j-ndl/react';\nimport classNames from 'classnames';\nimport { useId, useState } from 'react';\n\nimport { type CommonProps } from '../../_common/types';\nimport { ChevronDownIconOutline } from '../../icons/generated/heroIcons/ChevronDownIconOutline';\nimport { Presence } from '../presence';\nimport { formatThinkingDuration } from '../thinking/thinking-duration-formatter';\n\ntype ReasoningProps = {\n /** What should be displayed inside the reasoning component. */\n children?: React.ReactNode;\n /** Whether the AI is thinking */\n isThinking?: boolean;\n /** The duration of the thinking in milliseconds */\n thinkingMs?: number;\n /** The current action the AI is performing */\n currentAction?: string;\n};\n\n/**\n * The component is used to display the reasoning state of an LLM.\n * It has an accordion like behavior to show the reasoning steps.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst ReasoningComponent = ({\n isThinking = true,\n thinkingMs = 1000,\n currentAction = 'Thinking',\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ReasoningProps>) => {\n const classes = classNames('ndl-ai-reasoning', className);\n const [isExpanded, setIsExpanded] = useState(false);\n const shouldShowChildren = isExpanded && isThinking === false;\n const buttonId = useId();\n const panelId = useId();\n\n const { value: thinkingDuration, unit } = formatThinkingDuration(thinkingMs);\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <Typography\n variant=\"label\"\n className={classNames('ndl-ai-reasoning-header', {\n 'ndl-expanded': isExpanded,\n })}\n {...(!isThinking\n ? {\n as: 'button',\n htmlAttributes: {\n 'aria-controls': panelId,\n 'aria-expanded': isExpanded,\n id: buttonId,\n onClick: () => setIsExpanded(!isExpanded),\n type: 'button',\n },\n }\n : { as: 'div', htmlAttributes: { id: buttonId } })}\n >\n {isThinking === true ? (\n <>\n <Presence\n isThinking={isThinking}\n className=\"ndl-ai-reasoning-presence\"\n />\n <span className=\"ndl-ai-reasoning-header-text\">\n {currentAction}...\n </span>\n </>\n ) : (\n <>\n <span>\n Thought for {thinkingDuration} {unit}\n </span>\n <ChevronDownIconOutline\n className={classNames('ndl-ai-reasoning-chevron', {\n 'ndl-expanded': isExpanded,\n })}\n />\n </>\n )}\n </Typography>\n <div\n className={classNames('ndl-ai-reasoning-content', {\n 'ndl-expanded': shouldShowChildren,\n })}\n inert={!shouldShowChildren}\n aria-hidden={!shouldShowChildren}\n aria-labelledby={buttonId}\n role=\"region\"\n id={panelId}\n >\n <div className=\"ndl-ai-reasoning-content-inner\">\n <div className=\"ndl-ai-reasoning-content-inner-2\">{children}</div>\n </div>\n </div>\n </div>\n );\n};\n\ntype SectionProps = {\n /** The heading of the section */\n heading?: React.ReactNode;\n /** The children of the section */\n children?: React.ReactNode;\n /** The visual leading the section */\n leadingVisual?: React.ReactNode;\n};\n\nconst Section = ({\n heading,\n leadingVisual,\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', SectionProps>) => {\n const classes = classNames('ndl-ai-reasoning-section', className);\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-reasoning-section-header\">\n <div className=\"ndl-ai-reasoning-section-leading\">{leadingVisual}</div>\n <Typography variant=\"subheading-small\">{heading}</Typography>\n </div>\n <div className=\"ndl-ai-reasoning-section-content\">\n <div className=\"ndl-ai-reasoning-section-content-line-container\">\n <div className=\"ndl-ai-reasoning-section-content-line\" />\n </div>\n <div className=\"ndl-ai-reasoning-section-content-children\">\n {children}\n </div>\n </div>\n </div>\n );\n};\n\nconst Footer = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', { children: React.ReactNode }>) => {\n const classes = classNames('ndl-ai-reasoning-footer', className);\n return (\n <Typography\n as=\"div\"\n variant=\"body-small\"\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n};\n\nconst Reasoning = Object.assign(ReasoningComponent, {\n Footer,\n Section,\n});\n\nexport { Reasoning };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAwFA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA8BA;CACA;CACA;CACA;CACA;;;;;;;;AAxIF,MAAM,sBAAsB,SAUc;CAVd,IAAA,EAC1B,aAAa,MACb,aAAa,KACb,gBAAgB,YAChB,UACA,WACA,OACA,gBACA,QAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,WAAA,GAAUA,WAAAA,QAAAA,CAAW,oBAAoB,SAAS;CACxD,MAAM,CAAC,YAAY,kBAAA,GAAiBC,MAAAA,SAAAA,CAAS,KAAK;CAClD,MAAM,qBAAqB,cAAc,eAAe;CAC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AA,CAAC,OAAD,EAAK,WAAU,wCAAyC,CAAA;EACrD,CAAA,GACL,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GACZ;EACE,CAAA,CACF;CACF,CAAA,CAAA,EAAA,CAAA,CAAA;AAET;AAEA,MAAM,UAAU,UAOyC;CAPzC,IAAA,EACd,UACA,WACA,OACA,gBACA,QAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,MAAM,WAAA,GAAUJ,WAAAA,QAAAA,CAAW,2BAA2B,SAAS;CAC/D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACI,iBAAAA,YAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;EACC,IAAG;EACH,SAAQ;EACR,WAAW;EACJ;EACF;CACD,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACS,CAAA;AAEhB;AAEA,MAAM,YAAY,OAAO,OAAO,oBAAoB;CAClD;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"Reasoning.js","names":["classNames","useState","useId","formatThinkingDuration","Typography","Presence","ChevronDownIconOutline"],"sources":["../../../../src/ai/reasoning/Reasoning.tsx"],"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 { Typography } from '@neo4j-ndl/react';\nimport classNames from 'classnames';\nimport { useId, useState } from 'react';\n\nimport { type CommonProps } from '../../_common/types';\nimport { ChevronDownIconOutline } from '../../icons/generated/heroIcons/ChevronDownIconOutline';\nimport { Presence } from '../presence';\nimport { formatThinkingDuration } from '../thinking/thinking-duration-formatter';\n\ntype ReasoningProps = {\n /** What should be displayed inside the reasoning component. */\n children?: React.ReactNode;\n /** Whether the AI is thinking */\n isThinking?: boolean;\n /** The duration of the thinking in milliseconds */\n thinkingMs?: number;\n /** The current action the AI is performing */\n currentAction?: string;\n};\n\n/**\n * The component is used to display the reasoning state of an LLM.\n * It has an accordion like behavior to show the reasoning steps.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst ReasoningComponent = ({\n isThinking = true,\n thinkingMs = 1000,\n currentAction = 'Thinking',\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ReasoningProps>) => {\n const classes = classNames('ndl-ai-reasoning', className);\n const [isExpanded, setIsExpanded] = useState(false);\n const shouldShowChildren = isExpanded && isThinking === false;\n const buttonId = useId();\n const panelId = useId();\n\n const { value: thinkingDuration, unit } = formatThinkingDuration(thinkingMs);\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <Typography\n variant=\"title-4\"\n className={classNames('ndl-ai-reasoning-header', {\n 'ndl-expanded': isExpanded,\n })}\n {...(!isThinking\n ? {\n as: 'button',\n htmlAttributes: {\n 'aria-controls': panelId,\n 'aria-expanded': isExpanded,\n id: buttonId,\n onClick: () => setIsExpanded(!isExpanded),\n type: 'button',\n },\n }\n : { as: 'div', htmlAttributes: { id: buttonId } })}\n >\n {isThinking === true ? (\n <>\n <Presence\n isThinking={isThinking}\n className=\"ndl-ai-reasoning-presence\"\n />\n <span className=\"ndl-ai-reasoning-header-text\">\n {currentAction}...\n </span>\n </>\n ) : (\n <>\n <span>\n Thought for {thinkingDuration} {unit}\n </span>\n <ChevronDownIconOutline\n className={classNames('ndl-ai-reasoning-chevron', {\n 'ndl-expanded': isExpanded,\n })}\n />\n </>\n )}\n </Typography>\n <div\n className={classNames('ndl-ai-reasoning-content', {\n 'ndl-expanded': shouldShowChildren,\n })}\n inert={!shouldShowChildren}\n aria-hidden={!shouldShowChildren}\n aria-labelledby={buttonId}\n role=\"region\"\n id={panelId}\n >\n <div className=\"ndl-ai-reasoning-content-inner\">\n <div className=\"ndl-ai-reasoning-content-inner-2\">{children}</div>\n </div>\n </div>\n </div>\n );\n};\n\ntype SectionProps = {\n /** The heading of the section */\n heading?: React.ReactNode;\n /** The children of the section */\n children?: React.ReactNode;\n /** The visual leading the section */\n leadingVisual?: React.ReactNode;\n};\n\nconst Section = ({\n heading,\n leadingVisual,\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', SectionProps>) => {\n const classes = classNames('ndl-ai-reasoning-section', className);\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-reasoning-section-header\">\n <div className=\"ndl-ai-reasoning-section-leading\">{leadingVisual}</div>\n <Typography variant=\"subheading-medium\">{heading}</Typography>\n </div>\n <div className=\"ndl-ai-reasoning-section-content\">\n <div className=\"ndl-ai-reasoning-section-content-line-container\">\n <div className=\"ndl-ai-reasoning-section-content-line\" />\n </div>\n <div className=\"ndl-ai-reasoning-section-content-children\">\n {children}\n </div>\n </div>\n </div>\n );\n};\n\nconst Footer = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', { children: React.ReactNode }>) => {\n const classes = classNames('ndl-ai-reasoning-footer', className);\n return (\n <Typography\n as=\"div\"\n variant=\"body-small\"\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n};\n\nconst Reasoning = Object.assign(ReasoningComponent, {\n Footer,\n Section,\n});\n\nexport { Reasoning };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAwFA;CACA;CACA;C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;EAAf,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GAAoC,UAAA;EAAmB,CAAA,GACtE,iBAAA,GAAA,kBAAA,IAAA,CAACI,iBAAAA,YAAD;GAAY,SAAQ;GAAqB,UAAA;EAAoB,CAAA,CAC1D;CACL,CAAA,GAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GACb,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAK,WAAU,wCAAyC,CAAA;EACrD,CAAA,GACL,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GACZ;EACE,CAAA,CACF;CACF,CAAA,CAAA,EAAA,CAAA,CAAA;AAET;AAEA,MAAM,UAAU,UAOyC;CAPzC,IAAA,EACd,UACA,WACA,OACA,gBACA,QAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,MAAM,WAAA,GAAUJ,WAAAA,QAAAA,CAAW,2BAA2B,SAAS;CAC/D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACI,iBAAAA,YAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;EACC,IAAG;EACH,SAAQ;EACR,WAAW;EACJ;EACF;CACD,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACS,CAAA;AAEhB;AAEA,MAAM,YAAY,OAAO,OAAO,oBAAoB;CAClD;CACA;AACF,CAAC"}
@@ -60,11 +60,11 @@ const Thinking = (_ref) => {
60
60
  isThinking,
61
61
  className: "ndl-ai-thinking-presence"
62
62
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_typography_Typography.Typography, {
63
- variant: "subheading-small",
63
+ variant: "subheading-medium",
64
64
  className: "ndl-ai-thinking-label",
65
65
  children: "Thinking"
66
66
  })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_typography_Typography.Typography, {
67
- variant: "subheading-small",
67
+ variant: "subheading-medium",
68
68
  className: "ndl-ai-thinking-done",
69
69
  children: [
70
70
  "Thought",
@@ -1 +1 @@
1
- {"version":3,"file":"Thinking.js","names":["classNames","formatThinkingDuration","Presence","Typography"],"sources":["../../../../src/ai/thinking/Thinking.tsx"],"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';\nimport { Typography } from '../../typography';\nimport { Presence } from '../presence';\nimport { formatThinkingDuration } from './thinking-duration-formatter';\n\ntype ThinkingProps = {\n /** Whether the AI is thinking.\n * If true, will render a thinking presence icon and the text \"Thinking\".\n * If false, will render the duration of the thinking.\n */\n isThinking?: boolean;\n /** The duration of the thinking in milliseconds */\n thinkingMs?: number;\n};\n\n/**\n * The component is used to display the thinking state of an LLM.\n * If the `isThinking` prop is true, it will render a thinking presence icon and the text \"Thinking\".\n * If the `isThinking` prop is false, it will render the duration of the thinking.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst Thinking = ({\n className,\n isThinking = true,\n style,\n htmlAttributes,\n ref,\n thinkingMs = 1000,\n ...restProps\n}: CommonProps<'div', ThinkingProps>) => {\n const classes = classNames('ndl-ai-thinking', className);\n\n const { value: thinkingDuration, unit } = formatThinkingDuration(thinkingMs);\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {isThinking === true ? (\n <>\n <Presence\n isThinking={isThinking}\n className=\"ndl-ai-thinking-presence\"\n />\n <Typography\n variant=\"subheading-small\"\n className=\"ndl-ai-thinking-label\"\n >\n Thinking\n </Typography>\n </>\n ) : (\n <Typography variant=\"subheading-small\" className=\"ndl-ai-thinking-done\">\n Thought{' '}\n <span className=\"ndl-ai-thinking-duration\">\n for {thinkingDuration} {unit}\n </span>\n </Typography>\n )}\n </div>\n );\n};\n\nexport { Thinking };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CE;CACA;CACA;CACA;CACA;CACA;;;;;;;;;AANF,MAAM,YAAY,SAQuB;CARvB,IAAA,EAChB,WACA,aAAa,MACb,OACA,gBACA,KACA,aAAa,QAAA,MACV,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,WAAA,GAAUA,WAAAA,QAAAA,CAAW,mBAAmB,SAAS;CAEvD,MAAM,EAAE,OAAO,kBAAkB,SAASC,gDAAAA,uBAAuB,UAAU;CAE3E,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACM;EACL,WAAW;EACJ;CACH,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAAA,UAEH,eAAe,OACd,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,UAAD;EACc;EACZ,WAAU;CACX,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,YAAD;EACE,SAAQ;EACR,WAAU;EACX,UAAA;CAEW,CAAA,CACZ,EAAA,CAAA,IAEF,iBAAA,GAAA,kBAAA,KAAA,CAACA,8BAAAA,YAAD;EAAY,SAAQ;EAAmB,WAAU;EAAjD,UAAA;GAAwE;GAC9D;GACR,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;IAAM,WAAU;IAAhB,UAAA;KAA2C;KACpC;KAAiB;KAAE;IACpB;;EACI;CAEX,CAAA,EAAA,CAAA,CAAA;AAET"}
1
+ {"version":3,"file":"Thinking.js","names":["classNames","formatThinkingDuration","Presence","Typography"],"sources":["../../../../src/ai/thinking/Thinking.tsx"],"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';\nimport { Typography } from '../../typography';\nimport { Presence } from '../presence';\nimport { formatThinkingDuration } from './thinking-duration-formatter';\n\ntype ThinkingProps = {\n /** Whether the AI is thinking.\n * If true, will render a thinking presence icon and the text \"Thinking\".\n * If false, will render the duration of the thinking.\n */\n isThinking?: boolean;\n /** The duration of the thinking in milliseconds */\n thinkingMs?: number;\n};\n\n/**\n * The component is used to display the thinking state of an LLM.\n * If the `isThinking` prop is true, it will render a thinking presence icon and the text \"Thinking\".\n * If the `isThinking` prop is false, it will render the duration of the thinking.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst Thinking = ({\n className,\n isThinking = true,\n style,\n htmlAttributes,\n ref,\n thinkingMs = 1000,\n ...restProps\n}: CommonProps<'div', ThinkingProps>) => {\n const classes = classNames('ndl-ai-thinking', className);\n\n const { value: thinkingDuration, unit } = formatThinkingDuration(thinkingMs);\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {isThinking === true ? (\n <>\n <Presence\n isThinking={isThinking}\n className=\"ndl-ai-thinking-presence\"\n />\n <Typography\n variant=\"subheading-medium\"\n className=\"ndl-ai-thinking-label\"\n >\n Thinking\n </Typography>\n </>\n ) : (\n <Typography\n variant=\"subheading-medium\"\n className=\"ndl-ai-thinking-done\"\n >\n Thought{' '}\n <span className=\"ndl-ai-thinking-duration\">\n for {thinkingDuration} {unit}\n </span>\n </Typography>\n )}\n </div>\n );\n};\n\nexport { Thinking };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CE;CACA;CACA;CACA;CACA;CACA;;;;;;;;;AANF,MAAM,YAAY,SAQuB;CARvB,IAAA,EAChB,WACA,aAAa,MACb,OACA,gBACA,KACA,aAAa,QAAA,MACV,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,WAAA,GAAUA,WAAAA,QAAAA,CAAW,mBAAmB,SAAS;CAEvD,MAAM,EAAE,OAAO,kBAAkB,SAASC,gDAAAA,uBAAuB,UAAU;CAE3E,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACM;EACL,WAAW;EACJ;CACH,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAAA,UAEH,eAAe,OACd,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,UAAD;EACc;EACZ,WAAU;CACX,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,YAAD;EACE,SAAQ;EACR,WAAU;EACX,UAAA;CAEW,CAAA,CACZ,EAAA,CAAA,IAEF,iBAAA,GAAA,kBAAA,KAAA,CAACA,8BAAAA,YAAD;EACE,SAAQ;EACR,WAAU;EAFZ,UAAA;GAGC;GACS;GACR,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;IAAM,WAAU;IAAhB,UAAA;KAA2C;KACpC;KAAiB;KAAE;IACpB;;EACI;CAEX,CAAA,EAAA,CAAA,CAAA;AAET"}
@@ -117,7 +117,7 @@ const Avatar = (_ref) => {
117
117
  const renderIconType = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: icon !== null && icon !== void 0 ? icon : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons_generated_heroIcons_UserIconOutline.UserIconOutline, {}) });
118
118
  const renderLettersType = () => {
119
119
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_typography_Typography.Typography, {
120
- variant: "subheading-small",
120
+ variant: "subheading-medium",
121
121
  className: "ndl-avatar-typography",
122
122
  children: getLettersDisplay(name !== null && name !== void 0 ? name : "")
123
123
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","names":["classNames","UserIconOutline","Typography"],"sources":["../../../src/avatar/Avatar.tsx"],"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';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { UserIconOutline } from '../icons/generated/heroIcons/UserIconOutline';\nimport { Typography } from '../typography';\n\ntype SizeType = AvatarProps['size'];\ntype StatusType = NonNullable<AvatarProps['status']>;\n\ninterface CircleProperties {\n /** Center coordinates of the circles */\n cxAndCy: number;\n /** Diameter of the circles */\n diameter: number;\n /** Radius of the inner circle */\n rInner: number;\n /** Radius of the outer circle */\n rOuter: number;\n}\n\nfunction circleSizeFactory(size: SizeType): CircleProperties {\n switch (size) {\n case 'x-small':\n case 'small':\n case 'medium':\n return {\n cxAndCy: 4.5,\n diameter: 9,\n rInner: 3,\n rOuter: 4.5,\n };\n case 'large':\n case 'x-large':\n default:\n return {\n cxAndCy: 6,\n diameter: 12,\n rInner: 4,\n rOuter: 6,\n };\n }\n}\n\nfunction StatusIndicator({\n size,\n status,\n}: {\n size: SizeType;\n status: StatusType;\n}) {\n const { cxAndCy, diameter, rInner, rOuter } = circleSizeFactory(size);\n const statusClasses = `ndl-avatar-status ndl-avatar-status-${status}`;\n\n return (\n <div\n className={statusClasses}\n title={status.charAt(0).toUpperCase() + status.slice(1)}\n role=\"presentation\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height={diameter}\n width={diameter}\n viewBox={`0 0 ${diameter} ${diameter}`}\n fill=\"none\"\n >\n <circle\n cx={cxAndCy}\n cy={cxAndCy}\n r={rOuter}\n className=\"ndl-avatar-status-circle-outer\"\n />\n <circle\n cx={cxAndCy}\n cy={cxAndCy}\n r={status === 'unknown' ? rInner - 1 : rInner}\n className=\"ndl-avatar-status-circle-inner\"\n />\n </svg>\n </div>\n );\n}\n\ntype AvatarProps = {\n /** Whether to display a status indicator */\n hasStatus?: boolean;\n /** Whether the avatar is disabled. When disabled, status indicators are hidden and `onClick` handlers are disabled when cast as a button */\n isDisabled?: boolean;\n /** The name associated with the avatar. Used for alt text and aria-label. For letters type, this text is displayed */\n name?: string;\n /** The shape of the avatar */\n shape?: 'circle' | 'square';\n /** The size of the avatar */\n size?: 'x-small' | 'small' | 'medium' | 'large' | 'x-large';\n /** Source URI for the image. When provided with `type=\"image`\", displays the image */\n source?: string;\n /** The status to display. Only shown when `hasStatus` is `true` and component is not disabled */\n status?: 'offline' | 'online' | 'unknown';\n /** The type of avatar content. If `type=\"image\"` and no source is provided, automatically falls back to `icon` */\n type?: 'icon' | 'image' | 'letters';\n /** Custom icon to display when `type` is `\"icon\"`. Defaults to `UserIconOutline` */\n icon?: React.ReactNode;\n} & (\n | {\n as: 'button';\n onClick: () => void;\n }\n | {\n as?: React.ElementType;\n }\n);\n\nconst getLettersDisplay = (displayName: string) => {\n const words = displayName.trim().split(/\\s+/).filter(Boolean);\n if (words.length <= 1) {\n return displayName.trim();\n }\n return words\n .map((word) => word.charAt(0))\n .join('')\n .toUpperCase();\n};\n\nexport const Avatar = <T extends React.ElementType = 'div'>({\n as,\n hasStatus = false,\n icon,\n isDisabled = false,\n name,\n shape = 'circle',\n size = 'medium',\n source,\n status,\n type: initialType = 'image',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, AvatarProps>) => {\n // If source is not provided, fallback to icon\n const type =\n initialType === 'image' && (source === undefined || source === '')\n ? 'icon'\n : initialType;\n\n const Component: React.ElementType = as ?? 'div';\n const isButton = Component === 'button';\n const classes = classNames(\n `ndl-avatar ndl-avatar-${shape} ndl-avatar-${size}`,\n className,\n );\n const shapeClasses = classNames(\n `ndl-avatar-shape ndl-avatar-${shape} ndl-avatar-${shape}-${size}`,\n {\n 'ndl-avatar-disabled': isDisabled,\n },\n );\n\n const typeClass = `ndl-avatar-${type}`;\n\n const renderImageType = () => (\n <>\n <img data-testid=\"ndl-avatar-image\" src={source} alt={name} />\n <div\n data-testid=\"ndl-avatar-image-overlay\"\n className={`${shapeClasses} ndl-avatar-image-overlay`}\n />\n </>\n );\n\n const renderIconType = () => <>{icon ?? <UserIconOutline />}</>;\n\n const renderLettersType = () => {\n return (\n <Typography variant=\"subheading-small\" className=\"ndl-avatar-typography\">\n {getLettersDisplay(name ?? '')}\n </Typography>\n );\n };\n\n const TypeComponent =\n type === 'image'\n ? renderImageType()\n : type === 'icon'\n ? renderIconType()\n : type === 'letters' && Boolean(name)\n ? renderLettersType()\n : null;\n\n const isStatusIndicatorVisible =\n hasStatus && !isDisabled && status !== undefined;\n\n return (\n <Component\n ref={ref}\n className={classes}\n style={style}\n aria-hidden={!isButton}\n {...(isButton && {\n disabled: isDisabled,\n })}\n aria-label={name ? `Avatar ${name}` : 'Avatar'}\n {...restProps}\n {...htmlAttributes}\n >\n <div className={classNames(shapeClasses, typeClass)}>{TypeComponent}</div>\n {isStatusIndicatorVisible && (\n <StatusIndicator size={size} status={status} />\n )}\n </Component>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiJE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AArHF,SAAS,kBAAkB,MAAkC;CAC3D,QAAQ,MAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO;GACL,SAAS;GACT,UAAU;GACV,QAAQ;GACR,QAAQ;EACV;EAGF,SACE,OAAO;GACL,SAAS;GACT,UAAU;GACV,QAAQ;GACR,QAAQ;EACV;CACJ;AACF;AAEA,SAAS,gBAAgB,EACvB,MACA,UAIC;CACD,MAAM,EAAE,SAAS,UAAU,QAAQ,WAAW,kBAAkB,IAAI;CACpE,MAAM,gBAAgB,uCAAuC;CAE7D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,WAAW;EACX,OAAO,OAAO,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,OAAO,MAAM,CAAC;EACtD,MAAK;EAEL,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;GACE,OAAM;GACN,QAAQ;GACR,OAAO;GACP,SAAS,OAAO,SAAS,GAAG;GAC5B,MAAK;GALP,UAAA,CAOE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;IACE,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,WAAU;GACX,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;IACE,IAAI;IACJ,IAAI;IACJ,GAAG,WAAW,YAAY,SAAS,IAAI;IACvC,WAAU;GACX,CAAA,CACE;;CACF,C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GAAA,kBAAA,IAAA,CAACC,kDAAAA,iBAAD,CAAkB,CAAA,EAAI,CAAA;CAE9D,MAAM,0BAA0B;EAC9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,YAAD;GAAY,SAAQ;GAAmB,WAAU;GAC9C,UAAA,kBAAkB,SAAA,QAAA,SAAA,KAAA,IAAA,OAAQ,EAAE;EACnB,CAAA;CAEhB;CAEA,MAAM,gBACJ,SAAS,UACL,gBAAgB,IAChB,SAAS,SACP,eAAe,IACf,SAAS,aAAa,QAAQ,IAAI,IAChC,kBAAkB,IAClB;CAEV,MAAM,2BACJ,aAAa,CAAC,cAAc,WAAW,KAAA;CAEzC,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,WAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACM;EACL,WAAW;EACJ;EACP,eAAa,CAAC;CACT,GAAA,YAAY,EACf,UAAU,WACZ,CAAA,GAAA,CAAA,GAAA,EACA,cAAY,OAAO,UAAU,SAAS,SAAA,GAClC,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAAA,UAVN,CAYE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,YAAA,GAAWF,WAAAA,QAAAA,CAAW,cAAc,SAAS;EAAI,UAAA;CAAmB,CAAA,GACxE,4BACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAD;EAAuB;EAAc;CAAS,CAAA,CAEvC,EAAA,CAAA,CAAA;AAEf"}
1
+ {"version":3,"file":"Avatar.js","names":["classNames","UserIconOutline","Typography"],"sources":["../../../src/avatar/Avatar.tsx"],"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';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { UserIconOutline } from '../icons/generated/heroIcons/UserIconOutline';\nimport { Typography } from '../typography';\n\ntype SizeType = AvatarProps['size'];\ntype StatusType = NonNullable<AvatarProps['status']>;\n\ninterface CircleProperties {\n /** Center coordinates of the circles */\n cxAndCy: number;\n /** Diameter of the circles */\n diameter: number;\n /** Radius of the inner circle */\n rInner: number;\n /** Radius of the outer circle */\n rOuter: number;\n}\n\nfunction circleSizeFactory(size: SizeType): CircleProperties {\n switch (size) {\n case 'x-small':\n case 'small':\n case 'medium':\n return {\n cxAndCy: 4.5,\n diameter: 9,\n rInner: 3,\n rOuter: 4.5,\n };\n case 'large':\n case 'x-large':\n default:\n return {\n cxAndCy: 6,\n diameter: 12,\n rInner: 4,\n rOuter: 6,\n };\n }\n}\n\nfunction StatusIndicator({\n size,\n status,\n}: {\n size: SizeType;\n status: StatusType;\n}) {\n const { cxAndCy, diameter, rInner, rOuter } = circleSizeFactory(size);\n const statusClasses = `ndl-avatar-status ndl-avatar-status-${status}`;\n\n return (\n <div\n className={statusClasses}\n title={status.charAt(0).toUpperCase() + status.slice(1)}\n role=\"presentation\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height={diameter}\n width={diameter}\n viewBox={`0 0 ${diameter} ${diameter}`}\n fill=\"none\"\n >\n <circle\n cx={cxAndCy}\n cy={cxAndCy}\n r={rOuter}\n className=\"ndl-avatar-status-circle-outer\"\n />\n <circle\n cx={cxAndCy}\n cy={cxAndCy}\n r={status === 'unknown' ? rInner - 1 : rInner}\n className=\"ndl-avatar-status-circle-inner\"\n />\n </svg>\n </div>\n );\n}\n\ntype AvatarProps = {\n /** Whether to display a status indicator */\n hasStatus?: boolean;\n /** Whether the avatar is disabled. When disabled, status indicators are hidden and `onClick` handlers are disabled when cast as a button */\n isDisabled?: boolean;\n /** The name associated with the avatar. Used for alt text and aria-label. For letters type, this text is displayed */\n name?: string;\n /** The shape of the avatar */\n shape?: 'circle' | 'square';\n /** The size of the avatar */\n size?: 'x-small' | 'small' | 'medium' | 'large' | 'x-large';\n /** Source URI for the image. When provided with `type=\"image`\", displays the image */\n source?: string;\n /** The status to display. Only shown when `hasStatus` is `true` and component is not disabled */\n status?: 'offline' | 'online' | 'unknown';\n /** The type of avatar content. If `type=\"image\"` and no source is provided, automatically falls back to `icon` */\n type?: 'icon' | 'image' | 'letters';\n /** Custom icon to display when `type` is `\"icon\"`. Defaults to `UserIconOutline` */\n icon?: React.ReactNode;\n} & (\n | {\n as: 'button';\n onClick: () => void;\n }\n | {\n as?: React.ElementType;\n }\n);\n\nconst getLettersDisplay = (displayName: string) => {\n const words = displayName.trim().split(/\\s+/).filter(Boolean);\n if (words.length <= 1) {\n return displayName.trim();\n }\n return words\n .map((word) => word.charAt(0))\n .join('')\n .toUpperCase();\n};\n\nexport const Avatar = <T extends React.ElementType = 'div'>({\n as,\n hasStatus = false,\n icon,\n isDisabled = false,\n name,\n shape = 'circle',\n size = 'medium',\n source,\n status,\n type: initialType = 'image',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, AvatarProps>) => {\n // If source is not provided, fallback to icon\n const type =\n initialType === 'image' && (source === undefined || source === '')\n ? 'icon'\n : initialType;\n\n const Component: React.ElementType = as ?? 'div';\n const isButton = Component === 'button';\n const classes = classNames(\n `ndl-avatar ndl-avatar-${shape} ndl-avatar-${size}`,\n className,\n );\n const shapeClasses = classNames(\n `ndl-avatar-shape ndl-avatar-${shape} ndl-avatar-${shape}-${size}`,\n {\n 'ndl-avatar-disabled': isDisabled,\n },\n );\n\n const typeClass = `ndl-avatar-${type}`;\n\n const renderImageType = () => (\n <>\n <img data-testid=\"ndl-avatar-image\" src={source} alt={name} />\n <div\n data-testid=\"ndl-avatar-image-overlay\"\n className={`${shapeClasses} ndl-avatar-image-overlay`}\n />\n </>\n );\n\n const renderIconType = () => <>{icon ?? <UserIconOutline />}</>;\n\n const renderLettersType = () => {\n return (\n <Typography variant=\"subheading-medium\" className=\"ndl-avatar-typography\">\n {getLettersDisplay(name ?? '')}\n </Typography>\n );\n };\n\n const TypeComponent =\n type === 'image'\n ? renderImageType()\n : type === 'icon'\n ? renderIconType()\n : type === 'letters' && Boolean(name)\n ? renderLettersType()\n : null;\n\n const isStatusIndicatorVisible =\n hasStatus && !isDisabled && status !== undefined;\n\n return (\n <Component\n ref={ref}\n className={classes}\n style={style}\n aria-hidden={!isButton}\n {...(isButton && {\n disabled: isDisabled,\n })}\n aria-label={name ? `Avatar ${name}` : 'Avatar'}\n {...restProps}\n {...htmlAttributes}\n >\n <div className={classNames(shapeClasses, typeClass)}>{TypeComponent}</div>\n {isStatusIndicatorVisible && (\n <StatusIndicator size={size} status={status} />\n )}\n </Component>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiJE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AArHF,SAAS,kBAAkB,MAAkC;CAC3D,QAAQ,MAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO;GACL,SAAS;GACT,UAAU;GACV,QAAQ;GACR,QAAQ;EACV;EAGF,SACE,OAAO;GACL,SAAS;GACT,UAAU;GACV,QAAQ;GACR,QAAQ;EACV;CACJ;AACF;AAEA,SAAS,gBAAgB,EACvB,MACA,UAIC;CACD,MAAM,EAAE,SAAS,UAAU,QAAQ,WAAW,kBAAkB,IAAI;CACpE,MAAM,gBAAgB,uCAAuC;CAE7D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,WAAW;EACX,OAAO,OAAO,OAAO,CAAC,CAAC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,UAAA;CAAmB,CAAA,GACxE,4BACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAD;EAAuB;EAAc;CAAS,CAAA,CAEvC,EAAA,CAAA,CAAA;AAEf"}
@@ -92,7 +92,7 @@ const BannerHeader = (_ref) => {
92
92
  const classes = (0, classnames.default)("ndl-banner-header", className);
93
93
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_typography_Typography.Typography, require_objectSpread2.default(require_objectSpread2.default({
94
94
  as: "span",
95
- variant: "title-4",
95
+ variant: "title-3",
96
96
  className: classes,
97
97
  style,
98
98
  ref,
@@ -1 +1 @@
1
- {"version":3,"file":"Banner.js","names":["CheckCircleIconSolid","ExclamationTriangleIconSolid","ExclamationCircleIconSolid","InformationCircleIconSolid","BoltIconOutline","classNames","Typography","CleanIconButton","XMarkIconOutline"],"sources":["../../../src/banner/Banner.tsx"],"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';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { BoltIconOutline } from '../icons/generated/heroIcons/BoltIconOutline';\nimport { CheckCircleIconSolid } from '../icons/generated/heroIcons/CheckCircleIconSolid';\nimport { ExclamationCircleIconSolid } from '../icons/generated/heroIcons/ExclamationCircleIconSolid';\nimport { ExclamationTriangleIconSolid } from '../icons/generated/heroIcons/ExclamationTriangleIconSolid';\nimport { InformationCircleIconSolid } from '../icons/generated/heroIcons/InformationCircleIconSolid';\nimport { XMarkIconOutline } from '../icons/generated/heroIcons/XMarkIconOutline';\nimport { Typography } from '../typography';\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype BannerCommonProps = {\n /** Shows a status icon. The icon is based on the value of the `variant` prop */\n hasIcon?: boolean;\n\n /** Content to be shown in the banner. */\n children?: React.ReactNode;\n\n /** Sets the role to alert */\n isAlert?: boolean;\n\n /** How the banner is used. */\n usage?: 'inline' | 'global';\n\n /** The variant of the banner */\n variant?: BannerVariant;\n};\n\ntype CloseableBannerProps = {\n /** If the banner is closeable. Renders an icon button in the top right corner */\n isCloseable: true;\n\n /** Event handler for when the close icon is clicked */\n onClose: (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n};\n\ntype NonCloseableBannerProps = {\n isCloseable?: false;\n onClose?: never;\n};\n\ntype BannerCloseProps = CloseableBannerProps | NonCloseableBannerProps;\n\ntype BannerProps = BannerCommonProps & BannerCloseProps;\ntype BannerVariant = 'info' | 'success' | 'warning' | 'danger' | 'neutral';\n\nconst StatusIcon = ({ variant }: { variant: BannerVariant }) => {\n const iconComponent = (() => {\n switch (variant) {\n case 'success':\n return <CheckCircleIconSolid />;\n case 'warning':\n return <ExclamationTriangleIconSolid />;\n case 'danger':\n return <ExclamationCircleIconSolid />;\n case 'info':\n return <InformationCircleIconSolid />;\n case 'neutral':\n return <BoltIconOutline />;\n default:\n return null;\n }\n })();\n\n return <div className=\"ndl-banner-status-icon\">{iconComponent}</div>;\n};\n\nconst BannerHeader = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', { children: React.ReactNode }>) => {\n const classes = classNames('ndl-banner-header', className);\n return (\n <Typography\n as=\"span\"\n variant=\"title-4\"\n className={classes}\n style={style}\n ref={ref}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nconst BannerDescription = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', { children: React.ReactNode }>) => {\n const classes = classNames('ndl-banner-description', className);\n return (\n <Typography\n as=\"div\"\n variant=\"body-medium\"\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n};\n\nconst BannerActions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', { children: React.ReactNode }>) => {\n const classes = classNames('ndl-banner-actions', className);\n return (\n <div\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nconst BannerComponent = <T extends React.ElementType = 'section'>({\n as,\n variant = 'info',\n hasIcon = false,\n onClose,\n className,\n children,\n isCloseable = false,\n usage = 'inline',\n htmlAttributes,\n isAlert = false,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, BannerProps>) => {\n const Element: React.ElementType = as ?? 'section';\n\n const classes = classNames('ndl-banner', className, {\n 'ndl-danger': variant === 'danger',\n 'ndl-global': usage === 'global',\n 'ndl-info': variant === 'info',\n 'ndl-inline': usage === 'inline',\n 'ndl-neutral': variant === 'neutral',\n 'ndl-success': variant === 'success',\n 'ndl-warning': variant === 'warning',\n });\n\n const handleClose = (\n event:\n | React.MouseEvent<HTMLElement, MouseEvent>\n | React.KeyboardEvent<HTMLElement>,\n ) => {\n if (onClose && typeof onClose === 'function') {\n onClose(event);\n }\n };\n\n return (\n <Element\n className={classes}\n role={isAlert ? 'alert' : undefined}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-banner-content-wrapper\">\n {hasIcon && <StatusIcon variant={variant} />}\n <div className=\"ndl-banner-content\">{children}</div>\n </div>\n {isCloseable && (\n <CleanIconButton\n size=\"small\"\n onClick={handleClose}\n description={null}\n htmlAttributes={{ 'aria-label': 'Close' }}\n >\n <XMarkIconOutline />\n </CleanIconButton>\n )}\n </Element>\n );\n};\n\nconst Banner = Object.assign(BannerComponent, {\n Actions: BannerActions,\n Description: BannerDescription,\n Header: BannerHeader,\n});\n\nexport { Banner };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsGE;CACA;CACA;CACA;CACA;;;CAoBA;CACA;CACA;CACA;CACA;;;CAoBA;CACA;CACA;CACA;CACA;;;CAkBA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAtGF,MAAM,cAAc,EAAE,cAA0C;CAkB9D,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EAjBO,iBAAA;GAC3B,QAAQ,SAAR;IACE,KAAK,WACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,uDAAAA,sBAAD,CAAuB,CAAA;IAChC,KAAK,WACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,+DAAAA,8BAAD,CAA+B,CAAA;IACxC,KAAK,UACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,6DAAAA,4BAAD,CAA6B,CAAA;IACtC,KAAK,QACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,6DAAAA,4BAAD,CAA6B,CAAA;IACtC,KAAK,WACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,kDAAAA,iBAAD,CAAkB,CAAA;IAC3B,SACE,OAAO;GACX;EACF,EAAA,CAE4D;CAAO,CAAA;AACrE;AAEA,MAAM,gBAAgB,SAOoC;CAPpC,IAAA,EACpB,UACA,WACA,OACA,gBACA,QAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,WAAA,GAAUC,WAAAA,QAAAA,CAAW,qBAAqB,SAAS;CACzD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,YAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;EACC,IAAG;EACH,SAAQ;EACR,WAAW;EACJ;EACF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AY;CAC7B,CAAC;CAED,MAAM,eACJ,UAGG;EACH,IAAI,WAAW,OAAO,YAAY,YAChC,QAAQ,KAAK;CAEjB;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,SAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACC,WAAW;EACX,MAAM,UAAU,UAAU,KAAA;EACrB;CACD,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAAA,UALN,CAOE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,WAAW,iBAAA,GAAA,kBAAA,IAAA,CAAC,YAAD,EAAqB,QAAU,CAAA,GAC3C,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GAAsB;EAAc,CAAA,CAChD;CACJ,CAAA,GAAA,eACC,iBAAA,GAAA,kBAAA,IAAA,CAACE,0CAAAA,iBAAD;EACE,MAAK;EACL,SAAS;EACT,aAAa;EACb,gBAAgB,EAAE,cAAc,QAAQ;EAExC,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,mDAAAA,kBAAD,CAAmB,CAAA;CACJ,CAAA,CAEZ,EAAA,CAAA,CAAA;AAEb;AAEA,MAAM,SAAS,OAAO,OAAO,iBAAiB;CAC5C,SAAS;CACT,aAAa;CACb,QAAQ;AACV,CAAC"}
1
+ {"version":3,"file":"Banner.js","names":["CheckCircleIconSolid","ExclamationTriangleIconSolid","ExclamationCircleIconSolid","InformationCircleIconSolid","BoltIconOutline","classNames","Typography","CleanIconButton","XMarkIconOutline"],"sources":["../../../src/banner/Banner.tsx"],"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';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { BoltIconOutline } from '../icons/generated/heroIcons/BoltIconOutline';\nimport { CheckCircleIconSolid } from '../icons/generated/heroIcons/CheckCircleIconSolid';\nimport { ExclamationCircleIconSolid } from '../icons/generated/heroIcons/ExclamationCircleIconSolid';\nimport { ExclamationTriangleIconSolid } from '../icons/generated/heroIcons/ExclamationTriangleIconSolid';\nimport { InformationCircleIconSolid } from '../icons/generated/heroIcons/InformationCircleIconSolid';\nimport { XMarkIconOutline } from '../icons/generated/heroIcons/XMarkIconOutline';\nimport { Typography } from '../typography';\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype BannerCommonProps = {\n /** Shows a status icon. The icon is based on the value of the `variant` prop */\n hasIcon?: boolean;\n\n /** Content to be shown in the banner. */\n children?: React.ReactNode;\n\n /** Sets the role to alert */\n isAlert?: boolean;\n\n /** How the banner is used. */\n usage?: 'inline' | 'global';\n\n /** The variant of the banner */\n variant?: BannerVariant;\n};\n\ntype CloseableBannerProps = {\n /** If the banner is closeable. Renders an icon button in the top right corner */\n isCloseable: true;\n\n /** Event handler for when the close icon is clicked */\n onClose: (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n};\n\ntype NonCloseableBannerProps = {\n isCloseable?: false;\n onClose?: never;\n};\n\ntype BannerCloseProps = CloseableBannerProps | NonCloseableBannerProps;\n\ntype BannerProps = BannerCommonProps & BannerCloseProps;\ntype BannerVariant = 'info' | 'success' | 'warning' | 'danger' | 'neutral';\n\nconst StatusIcon = ({ variant }: { variant: BannerVariant }) => {\n const iconComponent = (() => {\n switch (variant) {\n case 'success':\n return <CheckCircleIconSolid />;\n case 'warning':\n return <ExclamationTriangleIconSolid />;\n case 'danger':\n return <ExclamationCircleIconSolid />;\n case 'info':\n return <InformationCircleIconSolid />;\n case 'neutral':\n return <BoltIconOutline />;\n default:\n return null;\n }\n })();\n\n return <div className=\"ndl-banner-status-icon\">{iconComponent}</div>;\n};\n\nconst BannerHeader = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', { children: React.ReactNode }>) => {\n const classes = classNames('ndl-banner-header', className);\n return (\n <Typography\n as=\"span\"\n variant=\"title-3\"\n className={classes}\n style={style}\n ref={ref}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nconst BannerDescription = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', { children: React.ReactNode }>) => {\n const classes = classNames('ndl-banner-description', className);\n return (\n <Typography\n as=\"div\"\n variant=\"body-medium\"\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n};\n\nconst BannerActions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', { children: React.ReactNode }>) => {\n const classes = classNames('ndl-banner-actions', className);\n return (\n <div\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nconst BannerComponent = <T extends React.ElementType = 'section'>({\n as,\n variant = 'info',\n hasIcon = false,\n onClose,\n className,\n children,\n isCloseable = false,\n usage = 'inline',\n htmlAttributes,\n isAlert = false,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, BannerProps>) => {\n const Element: React.ElementType = as ?? 'section';\n\n const classes = classNames('ndl-banner', className, {\n 'ndl-danger': variant === 'danger',\n 'ndl-global': usage === 'global',\n 'ndl-info': variant === 'info',\n 'ndl-inline': usage === 'inline',\n 'ndl-neutral': variant === 'neutral',\n 'ndl-success': variant === 'success',\n 'ndl-warning': variant === 'warning',\n });\n\n const handleClose = (\n event:\n | React.MouseEvent<HTMLElement, MouseEvent>\n | React.KeyboardEvent<HTMLElement>,\n ) => {\n if (onClose && typeof onClose === 'function') {\n onClose(event);\n }\n };\n\n return (\n <Element\n className={classes}\n role={isAlert ? 'alert' : undefined}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-banner-content-wrapper\">\n {hasIcon && <StatusIcon variant={variant} />}\n <div className=\"ndl-banner-content\">{children}</div>\n </div>\n {isCloseable && (\n <CleanIconButton\n size=\"small\"\n onClick={handleClose}\n description={null}\n htmlAttributes={{ 'aria-label': 'Close' }}\n >\n <XMarkIconOutline />\n </CleanIconButton>\n )}\n </Element>\n );\n};\n\nconst Banner = Object.assign(BannerComponent, {\n Actions: BannerActions,\n Description: BannerDescription,\n Header: BannerHeader,\n});\n\nexport { Banner };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsGE;CACA;CACA;CACA;CACA;;;CAoBA;CACA;CACA;CACA;CACA;;;CAoBA;CACA;CACA;CACA;CACA;;;CAkBA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAtGF,MAAM,cAAc,EAAE,cAA0C;CAkB9D,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EAjBO,iBAAA;GAC3B,QAAQ,SAAR;IACE,KAAK,WACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,uDAAAA,sBAAD,CAAuB,CAAA;IAChC,KAAK,WACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,+DAAAA,8BAAD,CAA+B,CAAA;IACxC,KAAK,UACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,6DAAAA,4BAAD,CAA6B,CAAA;IACtC,KAAK,QACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,6DAAAA,4B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AM,SAAS,OAAO,OAAO,iBAAiB;CAC5C,SAAS;CACT,aAAa;CACb,QAAQ;AACV,CAAC"}
@@ -735,7 +735,7 @@ const NoDataPlaceholder = (_ref18) => {
735
735
  className: (0, classnames.default)("nld-table-placeholder-wrapper", className),
736
736
  role: "row"
737
737
  }, restProps), htmlAttributes), {}, { children: children || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(NoDataPlaceholderContentWrapper, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(NoDataIcon, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_typography_Typography.Typography, {
738
- variant: "subheading-small",
738
+ variant: "subheading-medium",
739
739
  children: "No data available"
740
740
  })] }) }));
741
741
  };