@neo4j-ndl/react 5.1.2 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ai/response/Response.js +127 -3
- package/lib/cjs/ai/response/Response.js.map +1 -1
- package/lib/cjs/ai/response/safe-href.js +108 -0
- package/lib/cjs/ai/response/safe-href.js.map +1 -0
- package/lib/cjs/ai/response/stories/response-all-components.story.js +10 -3
- package/lib/cjs/ai/response/stories/response-all-components.story.js.map +1 -1
- package/lib/cjs/ai/response/stories/response-lists.story.js +6 -1
- package/lib/cjs/ai/response/stories/response-lists.story.js.map +1 -1
- package/lib/cjs/date-picker/DatePicker.js +6 -3
- package/lib/cjs/date-picker/DatePicker.js.map +1 -1
- package/lib/cjs/dropzone/Dropzone.js +2 -6
- package/lib/cjs/dropzone/Dropzone.js.map +1 -1
- package/lib/cjs/toast/Toast.js +4 -4
- package/lib/cjs/toast/Toast.js.map +1 -1
- package/lib/esm/ai/response/Response.js +127 -3
- package/lib/esm/ai/response/Response.js.map +1 -1
- package/lib/esm/ai/response/safe-href.js +104 -0
- package/lib/esm/ai/response/safe-href.js.map +1 -0
- package/lib/esm/ai/response/stories/response-all-components.story.js +10 -3
- package/lib/esm/ai/response/stories/response-all-components.story.js.map +1 -1
- package/lib/esm/ai/response/stories/response-lists.story.js +6 -1
- package/lib/esm/ai/response/stories/response-lists.story.js.map +1 -1
- package/lib/esm/date-picker/DatePicker.js +6 -3
- package/lib/esm/date-picker/DatePicker.js.map +1 -1
- package/lib/esm/dropzone/Dropzone.js +2 -6
- package/lib/esm/dropzone/Dropzone.js.map +1 -1
- package/lib/esm/toast/Toast.js +4 -4
- package/lib/esm/toast/Toast.js.map +1 -1
- package/lib/types/ai/response/Response.d.ts +15 -1
- package/lib/types/ai/response/Response.d.ts.map +1 -1
- package/lib/types/ai/response/safe-href.d.ts +26 -0
- package/lib/types/ai/response/safe-href.d.ts.map +1 -0
- package/lib/types/ai/response/stories/response-all-components.story.d.ts.map +1 -1
- package/lib/types/ai/response/stories/response-lists.story.d.ts.map +1 -1
- package/lib/types/date-picker/DatePicker.d.ts.map +1 -1
- package/lib/types/dropzone/Dropzone.d.ts +1 -1
- package/lib/types/dropzone/Dropzone.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/ndl-react/SKILL.md +2 -2
- package/skills/ndl-react/components/ai/response.md +36 -5
- package/skills/ndl-react/components/dropzone.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropzone.js","sourceRoot":"","sources":["../../../src/dropzone/Dropzone.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAkB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAIL,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;AACrG,OAAO,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAyC3C;;;;;;GAMG;AAEH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAEzB,MAAM,QAAQ,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,QAAQ,CAAC;AAE5C,MAAM,iBA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J,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mCAAmC,GAAG,CAAC,EAQS,EAAE,EAAE;QARb,EAC3C,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,KAAK,EACL,GAAG,OAEiD,EADjD,SAAS,cAP+B,6FAQ5C,CADa;IAEZ,OAAO,CACL,eAAK,SAAS,EAAC,2CAA2C,aACxD,eAAK,SAAS,EAAC,8CAA8C,aAC3D,KAAC,UAAU,IACT,SAAS,EAAC,8CAA8C,EACxD,OAAO,EAAC,kBAAkB,YAEzB,GAAG,qBAAqB,GAAG,GACjB,EACZ,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAC7B,KAAC,UAAU,IACT,SAAS,EAAC,0CAA0C,EACpD,OAAO,EAAC,aAAa,YACrB,IAAI,iBAAiB,gBAAgB,GAAc,CACtD,IACG,EACN,KAAC,WAAW,kBACV,SAAS,EAAE,UAAU,CAAC,mCAAmC,EAAE,SAAS,CAAC,EACrE,KAAK,EAAE,qBAAqB,EAC5B,IAAI,EAAC,OAAO,EACZ,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,IACR,SAAS,EACb,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE;IAChD,kBAAkB,EAAE,mCAAmC;CACxD,CAAC,CAAC;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { detect } from 'detect-browser';\nimport { type RefObject, useMemo, useRef, useState } from 'react';\nimport {\n type DropEvent,\n type DropzoneOptions,\n type FileRejection,\n useDropzone,\n} from 'react-dropzone';\nimport { useResizeObserver } from 'usehooks-ts';\n\nimport { type CommonProps } from '../_common/types';\nimport { Banner } from '../banner';\nimport { DocumentArrowUpIconOutline } from '../icons/generated/heroIcons/DocumentArrowUpIconOutline';\nimport { DocumentArrowUpIconSolid } from '../icons/generated/heroIcons/DocumentArrowUpIconSolid';\nimport { XCircleIconSolid } from '../icons/generated/heroIcons/XCircleIconSolid';\nimport { ProgressBar } from '../progress-bar';\nimport { Typography } from '../typography';\n\n/**\n *\n *\n * Types\n *\n *\n */\n/**\n * @remarks\n * Where `DropzoneOptions` is the props for the `react-dropzone` library. For more information, see the [react-dropzone documentation](https://react-dropzone.js.org/#src).\n */\ntype DropzoneProps = {\n /** Props for the underlying `react-dropzone` component. Don't use `accept`. If using custom file extensions as this option is broken. Instead use the `acceptedFileExtensions` property. */\n dropZoneOptions: DropzoneOptions;\n\n /** Informational text that highlights the supported file types, will be displayed in the footer. */\n supportedFilesDescription?: React.ReactNode;\n\n /** Element to display when uploading the file. */\n loadingElement?: React.ReactNode;\n\n /** Use when wanting a custom heading. */\n heading?: React.ReactNode;\n\n /** Message to be shown when file is rejected. */\n rejectedText?: React.ReactNode;\n\n /** The accepted file extensions for the Drag-and-Drop. */\n acceptedFileExtensions?: string[];\n};\n\ntype DropzoneLoadingProgressBarProps = {\n /** The percentage of the progress bar. */\n progressBarPrecentage: number;\n\n /** The time in minute left to upload the file. */\n progressBarMinute?: number;\n};\n\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst browser = detect();\n\nconst isSafari = browser?.name === 'safari';\n\nconst DropzoneComponent = ({\n dropZoneOptions,\n supportedFilesDescription,\n loadingElement,\n heading,\n rejectedText,\n acceptedFileExtensions,\n htmlAttributes,\n style,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', DropzoneProps>) => {\n /**\n * We intercept the onDrop function in order to enforce\n * custom file extensions. Before calling the onDrop props we check\n * if the custom file extensions is acceptable. If the extension\n * conforms to acceptedFileExtensions, we call onDrop. Otherwise, we\n * present an error message.\n */\n function onDropInterceptor<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ) {\n if (acceptedFileExtensions && acceptedFileExtensions.length > 0) {\n for (const file of acceptedFiles) {\n const isAccepted = acceptedFileExtensions.some((extension) => {\n if (file.name.endsWith(extension)) {\n return true;\n }\n });\n if (!isAccepted) {\n setIsRejected(true);\n return;\n }\n }\n }\n setIsRejected(false);\n dropZoneOptions.onDrop?.(acceptedFiles, fileRejections, event);\n }\n\n const [isRejected, setIsRejected] = useState(false);\n const dropZoneRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([dropZoneRef, ref]);\n const isDisabled = dropZoneOptions?.disabled || Boolean(loadingElement);\n\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n isDragAccept,\n isDragReject,\n open,\n } = useDropzone({\n ...dropZoneOptions,\n disabled: isDisabled,\n noClick: true,\n onDrop: onDropInterceptor,\n });\n\n const { width } = useResizeObserver({\n ref: dropZoneRef as RefObject<HTMLElement>,\n });\n\n const isUploading = Boolean(loadingElement);\n\n const titleText =\n isDragActive && isDragReject\n ? 'Format not supported'\n : isDragActive && !isDragReject\n ? 'Drop file'\n : null;\n\n const computedFileImage =\n (isDragActive && isDragAccept) || isUploading ? (\n <DocumentArrowUpIconSolid className=\"ndl-dropzone-drag-icon ndl-accepted\" />\n ) : (\n <XCircleIconSolid className=\"ndl-dropzone-drag-icon ndl-rejected\" />\n );\n\n const wrapperClasses = classNames('ndl-dropzone', className, {\n 'ndl-drag-active': isDragActive,\n 'ndl-drag-disabled': dropZoneOptions?.disabled,\n 'ndl-file-invalid': isDragActive && isDragReject,\n });\n\n useMemo(() => {\n if (isDragActive && isRejected) {\n setIsRejected(false);\n }\n }, [isDragActive, isRejected]);\n\n return (\n <>\n {isRejected && (\n <Banner className=\"ndl-dropzone-error-alert\" variant=\"danger\">\n <Banner.Header>Error</Banner.Header>\n <Banner.Description>\n {Boolean(rejectedText) || 'File extension not supported.'}\n </Banner.Description>\n </Banner>\n )}\n <div\n ref={mergedRef}\n className={wrapperClasses}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-dropzone-inner-wrapper\" {...getRootProps()}>\n <input aria-label=\"Drag and drop area\" {...getInputProps()} />\n <div className=\"ndl-dropzone-inner\">\n {/* Illustration should be visible only after arbitrary width */}\n {width !== undefined && width > 230 && (\n <>\n {isDragActive && !isSafari ? (\n computedFileImage\n ) : (\n <DocumentArrowUpIconOutline className=\"ndl-dropzone-upload-icon\" />\n )}\n </>\n )}\n {!isUploading && (\n <div className=\"ndl-dnd-title-container\">\n <Typography variant=\"subheading-medium\">\n {titleText ||\n (heading ?? (\n <>\n Drag <span className=\"ndl-dnd-title-ampersand\">&</span>{' '}\n Drop\n </>\n ))}\n </Typography>\n {!isDragReject && (\n <div className=\"ndl-dnd-subtitle\">\n <Typography variant=\"body-medium\">or</Typography>{' '}\n <button\n className=\"ndl-dnd-browse-link\"\n onClick={() => open()}\n disabled={isDisabled}\n type=\"button\"\n >\n Browse\n </button>\n </div>\n )}\n </div>\n )}\n <div className=\"ndl-dropzone-footer\">\n {isUploading && <>{loadingElement}</>}\n {!isUploading && (\n <div className=\"ndl-file-support-text\">\n {supportedFilesDescription}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n </>\n );\n};\n\nconst DropzoneLoadingProgressBarComponent = ({\n progressBarPrecentage,\n progressBarMinute,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'div', DropzoneLoadingProgressBarProps>) => {\n return (\n <div className=\"ndl-dropzone-loading-progress-bar-wrapper\">\n <div className=\"ndl-dropzone-loading-progress-bar-indicators\">\n <Typography\n className=\"ndl-dropzone-loading-progress-bar-precentage\"\n variant=\"subheading-small\"\n >\n {`${progressBarPrecentage}%`}\n </Typography>\n {Boolean(progressBarMinute) && (\n <Typography\n className=\"ndl-dropzone-loading-progress-bar-minute\"\n variant=\"body-medium\"\n >{`(${progressBarMinute} minutes left)`}</Typography>\n )}\n </div>\n <ProgressBar\n className={classNames('ndl-dropzone-loading-progress-bar', className)}\n value={progressBarPrecentage}\n size=\"large\"\n htmlAttributes={htmlAttributes}\n ref={ref}\n style={style}\n {...restProps}\n />\n </div>\n );\n};\n\nconst Dropzone = Object.assign(DropzoneComponent, {\n LoadingProgressBar: DropzoneLoadingProgressBarComponent,\n});\n\nexport { Dropzone };\n"]}
|
|
1
|
+
{"version":3,"file":"Dropzone.js","sourceRoot":"","sources":["../../../src/dropzone/Dropzone.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAkB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAIL,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;AACrG,OAAO,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM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AI,4BAAG,cAAc,GAAI,EACpC,CAAC,WAAW,IAAI,CACf,cAAK,SAAS,EAAC,uBAAuB,YACnC,yBAAyB,GACtB,CACP,IACG,IACF,KACF,IACF,IACL,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mCAAmC,GAAG,CAAC,EAQS,EAAE,EAAE;QARb,EAC3C,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,KAAK,EACL,GAAG,OAEiD,EADjD,SAAS,cAP+B,6FAQ5C,CADa;IAEZ,OAAO,CACL,eAAK,SAAS,EAAC,2CAA2C,aACxD,eAAK,SAAS,EAAC,8CAA8C,aAC3D,KAAC,UAAU,IACT,SAAS,EAAC,8CAA8C,EACxD,OAAO,EAAC,kBAAkB,YAEzB,GAAG,qBAAqB,GAAG,GACjB,EACZ,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAC7B,KAAC,UAAU,IACT,SAAS,EAAC,0CAA0C,EACpD,OAAO,EAAC,aAAa,YACrB,IAAI,iBAAiB,gBAAgB,GAAc,CACtD,IACG,EACN,KAAC,WAAW,kBACV,SAAS,EAAE,UAAU,CAAC,mCAAmC,EAAE,SAAS,CAAC,EACrE,KAAK,EAAE,qBAAqB,EAC5B,IAAI,EAAC,OAAO,EACZ,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,IACR,SAAS,EACb,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE;IAChD,kBAAkB,EAAE,mCAAmC;CACxD,CAAC,CAAC;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { detect } from 'detect-browser';\nimport { type RefObject, useMemo, useRef, useState } from 'react';\nimport {\n type DropEvent,\n type DropzoneOptions,\n type FileRejection,\n useDropzone,\n} from 'react-dropzone';\nimport { useResizeObserver } from 'usehooks-ts';\n\nimport { type CommonProps } from '../_common/types';\nimport { Banner } from '../banner';\nimport { DocumentArrowUpIconOutline } from '../icons/generated/heroIcons/DocumentArrowUpIconOutline';\nimport { DocumentArrowUpIconSolid } from '../icons/generated/heroIcons/DocumentArrowUpIconSolid';\nimport { XCircleIconSolid } from '../icons/generated/heroIcons/XCircleIconSolid';\nimport { ProgressBar } from '../progress-bar';\nimport { Typography } from '../typography';\n\n/**\n *\n *\n * Types\n *\n *\n */\n/**\n * @remarks\n * Where `DropzoneOptions` is the props for the `react-dropzone` library. For more information, see the [react-dropzone documentation](https://react-dropzone.js.org/#src).\n */\ntype DropzoneProps = {\n /** Props for the underlying `react-dropzone` component. Don't use `accept`. If using custom file extensions as this option is broken. Instead use the `acceptedFileExtensions` property. */\n dropZoneOptions: DropzoneOptions;\n\n /** Informational text that highlights the supported file types, will be displayed in the footer. */\n supportedFilesDescription?: React.ReactNode;\n\n /** Element to display when uploading the file. */\n loadingElement?: React.ReactNode;\n\n /** Use when wanting a custom heading. */\n heading?: React.ReactNode;\n\n /** Message shown when a file is rejected. Defaults to \"File extension not supported.\" when omitted. */\n rejectedText?: React.ReactNode;\n\n /** The accepted file extensions for the Drag-and-Drop. */\n acceptedFileExtensions?: string[];\n};\n\ntype DropzoneLoadingProgressBarProps = {\n /** The percentage of the progress bar. */\n progressBarPrecentage: number;\n\n /** The time in minute left to upload the file. */\n progressBarMinute?: number;\n};\n\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst browser = detect();\n\nconst isSafari = browser?.name === 'safari';\n\nconst DropzoneComponent = ({\n dropZoneOptions,\n supportedFilesDescription,\n loadingElement,\n heading,\n rejectedText,\n acceptedFileExtensions,\n htmlAttributes,\n style,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', DropzoneProps>) => {\n /**\n * We intercept the onDrop function in order to enforce\n * custom file extensions. Before calling the onDrop props we check\n * if the custom file extensions is acceptable. If the extension\n * conforms to acceptedFileExtensions, we call onDrop. Otherwise, we\n * present an error message.\n */\n function onDropInterceptor<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ) {\n if (acceptedFileExtensions && acceptedFileExtensions.length > 0) {\n for (const file of acceptedFiles) {\n const isAccepted = acceptedFileExtensions.some((extension) =>\n file.name.endsWith(extension),\n );\n if (!isAccepted) {\n setIsRejected(true);\n return;\n }\n }\n }\n setIsRejected(false);\n dropZoneOptions.onDrop?.(acceptedFiles, fileRejections, event);\n }\n\n const [isRejected, setIsRejected] = useState(false);\n const dropZoneRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([dropZoneRef, ref]);\n const isDisabled = dropZoneOptions?.disabled || Boolean(loadingElement);\n\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n isDragAccept,\n isDragReject,\n open,\n } = useDropzone({\n ...dropZoneOptions,\n disabled: isDisabled,\n noClick: true,\n onDrop: onDropInterceptor,\n });\n\n const { width } = useResizeObserver({\n ref: dropZoneRef as RefObject<HTMLElement>,\n });\n\n const isUploading = Boolean(loadingElement);\n\n const titleText =\n isDragActive && isDragReject\n ? 'Format not supported'\n : isDragActive && !isDragReject\n ? 'Drop file'\n : null;\n\n const computedFileImage =\n (isDragActive && isDragAccept) || isUploading ? (\n <DocumentArrowUpIconSolid className=\"ndl-dropzone-drag-icon ndl-accepted\" />\n ) : (\n <XCircleIconSolid className=\"ndl-dropzone-drag-icon ndl-rejected\" />\n );\n\n const wrapperClasses = classNames('ndl-dropzone', className, {\n 'ndl-drag-active': isDragActive,\n 'ndl-drag-disabled': dropZoneOptions?.disabled,\n 'ndl-file-invalid': isDragActive && isDragReject,\n });\n\n useMemo(() => {\n if (isDragActive && isRejected) {\n setIsRejected(false);\n }\n }, [isDragActive, isRejected]);\n\n return (\n <>\n {isRejected && (\n <Banner className=\"ndl-dropzone-error-alert\" variant=\"danger\">\n <Banner.Header>Error</Banner.Header>\n <Banner.Description>\n {rejectedText ?? 'File extension not supported.'}\n </Banner.Description>\n </Banner>\n )}\n <div\n ref={mergedRef}\n className={wrapperClasses}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-dropzone-inner-wrapper\" {...getRootProps()}>\n <input aria-label=\"Drag and drop area\" {...getInputProps()} />\n <div className=\"ndl-dropzone-inner\">\n {/* Illustration should be visible only after arbitrary width */}\n {width !== undefined && width > 230 && (\n <>\n {isDragActive && !isSafari ? (\n computedFileImage\n ) : (\n <DocumentArrowUpIconOutline className=\"ndl-dropzone-upload-icon\" />\n )}\n </>\n )}\n {!isUploading && (\n <div className=\"ndl-dnd-title-container\">\n <Typography variant=\"subheading-medium\">\n {titleText ||\n (heading ?? (\n <>\n Drag <span className=\"ndl-dnd-title-ampersand\">&</span>{' '}\n Drop\n </>\n ))}\n </Typography>\n {!isDragReject && (\n <div className=\"ndl-dnd-subtitle\">\n <Typography variant=\"body-medium\">or</Typography>{' '}\n <button\n className=\"ndl-dnd-browse-link\"\n onClick={() => open()}\n disabled={isDisabled}\n type=\"button\"\n >\n Browse\n </button>\n </div>\n )}\n </div>\n )}\n <div className=\"ndl-dropzone-footer\">\n {isUploading && <>{loadingElement}</>}\n {!isUploading && (\n <div className=\"ndl-file-support-text\">\n {supportedFilesDescription}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n </>\n );\n};\n\nconst DropzoneLoadingProgressBarComponent = ({\n progressBarPrecentage,\n progressBarMinute,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'div', DropzoneLoadingProgressBarProps>) => {\n return (\n <div className=\"ndl-dropzone-loading-progress-bar-wrapper\">\n <div className=\"ndl-dropzone-loading-progress-bar-indicators\">\n <Typography\n className=\"ndl-dropzone-loading-progress-bar-precentage\"\n variant=\"subheading-small\"\n >\n {`${progressBarPrecentage}%`}\n </Typography>\n {Boolean(progressBarMinute) && (\n <Typography\n className=\"ndl-dropzone-loading-progress-bar-minute\"\n variant=\"body-medium\"\n >{`(${progressBarMinute} minutes left)`}</Typography>\n )}\n </div>\n <ProgressBar\n className={classNames('ndl-dropzone-loading-progress-bar', className)}\n value={progressBarPrecentage}\n size=\"large\"\n htmlAttributes={htmlAttributes}\n ref={ref}\n style={style}\n {...restProps}\n />\n </div>\n );\n};\n\nconst Dropzone = Object.assign(DropzoneComponent, {\n LoadingProgressBar: DropzoneLoadingProgressBarComponent,\n});\n\nexport { Dropzone };\n"]}
|
package/lib/esm/toast/Toast.js
CHANGED
|
@@ -77,13 +77,13 @@ const Toast = (_a) => {
|
|
|
77
77
|
function getProps(onClose, shouldAutoClose, onAutoClose, onAction, sonnerToastProps, variant) {
|
|
78
78
|
const isProgressBar = variant === 'progress-bar';
|
|
79
79
|
// https://sonner.emilkowal.ski/toast#api-reference
|
|
80
|
-
return Object.assign({ duration: !isProgressBar && shouldAutoClose ? (!onAction ? 5000 : 8000) : Infinity,
|
|
81
|
-
onCloseCallback(onClose, toast.id);
|
|
82
|
-
}, onAutoClose: (toast) => {
|
|
80
|
+
return Object.assign({ duration: !isProgressBar && shouldAutoClose ? (!onAction ? 5000 : 8000) : Infinity, onAutoClose: (toast) => {
|
|
83
81
|
if (onAutoClose) {
|
|
84
82
|
return onAutoClose(toast.id);
|
|
85
83
|
}
|
|
86
|
-
}
|
|
84
|
+
}, onDismiss: (toast) => {
|
|
85
|
+
onCloseCallback(onClose, toast.id);
|
|
86
|
+
}, unstyled: true }, sonnerToastProps);
|
|
87
87
|
}
|
|
88
88
|
function createToast(text, props, variant, icon) {
|
|
89
89
|
const { ref, sonnerToastProps = {}, onClose, shouldAutoClose, onAutoClose, onAction } = props, restProps = __rest(props, ["ref", "sonnerToastProps", "onClose", "shouldAutoClose", "onAutoClose", "onAction"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../../src/toast/Toast.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAEL,KAAK,IAAI,WAAW,EACpB,OAAO,IAAI,aAAa,GAGzB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA6D9C,MAAM,OAAO,GAAG,CAAC,KAAmB,EAAE,EAAE;IACtC,MAAM,EACJ,QAAQ,GAAG,aAAa,EACxB,aAAa,GAAG,CAAC,EACjB,SAAS,EACT,kBAAkB,GACnB,GAAG,KAAK,CAAC;IAEV,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAE7D,OAAO,CACL,KAAC,aAAa,kBACZ,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,IACxB,kBAAkB,EACtB,CACH,CAAC;AACJ,CAAC,CAAC;AAOF,SAAS,eAAe,CACtB,QAA6C,EAC7C,EAAW;IAEX,IAAI,QAAQ,EAA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AAG,KAAK,GAAG,CAAC;QAC/B,MAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAmB,CAAC;QAE3E,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,2BAA2B,GAAG,YAAY,CAAC,aAAa,CAC5D,6BAA6B,CACZ,CAAC;QACpB,2BAA2B,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC,aAAa,CAClE,mBAAmB,CACF,CAAC;QAEpB,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC,EAAE,gDAAgD;CACpD,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport { type ReactNode } from 'react';\nimport {\n type ExternalToast as SonnerExternalToast,\n toast as sonnerToast,\n Toaster as SonnerToaster,\n type ToasterProps as SonnerToasterProps,\n type ToastT as SonnerToastT,\n} from 'sonner';\n\nimport { type CommonProps } from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { CheckCircleIconSolid } from '../icons/generated/heroIcons/CheckCircleIconSolid';\nimport { ExclamationCircleIconSolid } from '../icons/generated/heroIcons/ExclamationCircleIconSolid';\nimport { XMarkIconOutline } from '../icons/generated/heroIcons/XMarkIconOutline';\nimport { OutlinedButton } from '../outlined-button';\nimport { ProgressBar } from '../progress-bar';\n\ntype ToastVariants = 'neutral' | 'success' | 'danger' | 'progress-bar';\n\ntype ToastCommandVariants = 'neutral' | 'success' | 'danger' | 'progressBar';\n\ntype ToastId = string | number;\n\ntype BaseToastProps = CommonProps<\n 'div',\n {\n /** If `true` a close button will be displayed in the toast. */\n isCloseable?: boolean;\n /** If `true` the toast will close when the action button is triggered. */\n shouldCloseOnAction?: boolean;\n /** Function that will be called when the toast is closed. */\n onClose?: (id: ToastId) => void;\n /** If true the toast will close automatically after a certain time. */\n shouldAutoClose?: boolean;\n /** Function that will be called when the toast is automatically closed. */\n onAutoClose?: (id: ToastId) => void;\n /** If set an action button will be displayed. The value here will be displayed\n * in the action button. If this is set the toast property `shouldAutoClose` will\n * automatically be set to `false` unless overridden. */\n actionLabel?: string;\n /** Function that will be called when the action button is clicked. */\n onAction?: (id: ToastId) => void;\n /** If a dev wishes to set the underlying framework props (Sonner Toast).\n * https://sonner.emilkowal.ski/toast#api-reference */\n sonnerToastProps?: SonnerExternalToast;\n /** If true the toast is controlled by the parent. */\n isControlled?: boolean;\n }\n>;\n\ninterface ToastNeutralProps extends BaseToastProps {\n icon?: ReactNode;\n}\n// oxlint-disable-next-line @typescript-eslint/no-empty-object-type\ninterface ToastSuccessProps extends BaseToastProps {}\n// oxlint-disable-next-line @typescript-eslint/no-empty-object-type\ninterface ToastDangerProps extends BaseToastProps {}\n\ninterface ToastProgressBarProps extends BaseToastProps {\n icon?: ReactNode;\n initialProgressBarValue?: number;\n}\n\ntype ToastVariantsProps =\n | ToastNeutralProps\n | ToastSuccessProps\n | ToastDangerProps\n | ToastProgressBarProps;\n\ninterface ToasterProps extends Pick<\n SonnerToasterProps,\n 'position' | 'visibleToasts' | 'className'\n> {\n sonnerToasterProps?: SonnerToasterProps;\n}\n\nconst Toaster = (props: ToasterProps) => {\n const {\n position = 'bottom-left',\n visibleToasts = 1,\n className,\n sonnerToasterProps,\n } = props;\n\n const classes = classNames('ndl-toast-container', className);\n\n return (\n <SonnerToaster\n className={classes}\n position={position}\n visibleToasts={visibleToasts}\n {...sonnerToasterProps}\n />\n );\n};\n\ntype SonnerToast = typeof sonnerToast;\ninterface CustomSonnerToast extends SonnerToast {\n needle: Record<string, { onClose?: (id: ToastId) => void }>;\n}\n\nfunction onCloseCallback(\n callback: ((id: ToastId) => void) | undefined,\n id: ToastId,\n) {\n if (callback) {\n callback(id);\n // Cleanup\n delete (sonnerToast as CustomSonnerToast).needle[id];\n }\n}\n\ntype ToastElement = ToastVariantsProps & {\n icon: ReactNode;\n id: ToastId;\n variant: ToastVariants;\n text: ReactNode;\n initialProgressBarValue?: number;\n isControlled?: boolean;\n};\n\nconst Toast = ({\n icon,\n id,\n text,\n variant,\n isCloseable,\n onClose,\n actionLabel,\n onAction,\n shouldCloseOnAction,\n initialProgressBarValue,\n isControlled,\n htmlAttributes,\n ref,\n ...restProps\n}: ToastElement) => {\n const isProgressBar = variant === 'progress-bar';\n\n const handleOnClose = () => {\n if (isControlled === true) {\n onCloseCallback(onClose, id);\n return;\n }\n sonnerToast.dismiss(id);\n onCloseCallback(onClose, id);\n };\n\n const handleOnAction = () => {\n if (onAction) {\n onAction(id);\n }\n if (shouldCloseOnAction === true) {\n sonnerToast.dismiss(id);\n onCloseCallback(onClose, id);\n }\n };\n\n return (\n <div\n id={String(id)}\n className=\"ndl-toast\"\n tabIndex={-1}\n ref={ref}\n data-variant={variant}\n data-testid=\"ndl-toast\"\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-toast-content\" tabIndex={-1}>\n {icon && (\n <div className={`ndl-toast-icon ndl-toast-${variant}`}>{icon}</div>\n )}\n <div className=\"ndl-toast-text\">{text}</div>\n {actionLabel && (\n <OutlinedButton\n className=\"ndl-toast-action\"\n size=\"small\"\n onClick={handleOnAction}\n >\n {actionLabel}\n </OutlinedButton>\n )}\n {(isCloseable || actionLabel || isProgressBar) && (\n <CleanIconButton\n className=\"ndl-toast-close-button\"\n onClick={handleOnClose}\n description={null}\n size=\"small\"\n htmlAttributes={{\n 'aria-label': 'Close',\n }}\n >\n <XMarkIconOutline />\n </CleanIconButton>\n )}\n </div>\n {isProgressBar && (\n <ProgressBar size=\"small\" value={initialProgressBarValue ?? 0} />\n )}\n </div>\n );\n};\n\nfunction getProps(\n onClose: ((id: ToastId) => void) | undefined,\n shouldAutoClose: boolean | undefined,\n onAutoClose: ((id: ToastId) => void) | undefined,\n onAction: ((id: ToastId) => void) | undefined,\n sonnerToastProps: SonnerExternalToast | undefined,\n variant: ToastVariants,\n) {\n const isProgressBar = variant === 'progress-bar';\n // https://sonner.emilkowal.ski/toast#api-reference\n return {\n duration:\n !isProgressBar && shouldAutoClose ? (!onAction ? 5000 : 8000) : Infinity,\n unstyled: true,\n onDismiss: (toast: SonnerToastT) => {\n onCloseCallback(onClose, toast.id);\n },\n onAutoClose: (toast: SonnerToastT) => {\n if (onAutoClose) {\n return onAutoClose(toast.id);\n }\n },\n ...sonnerToastProps,\n };\n}\n\nfunction createToast(\n text: ReactNode,\n props: ToastVariantsProps,\n variant: ToastVariants,\n icon: ReactNode,\n) {\n const {\n ref,\n sonnerToastProps = {},\n onClose,\n shouldAutoClose,\n onAutoClose,\n onAction,\n ...restProps\n } = props;\n\n const { id: sonnerToastPropsId } = sonnerToastProps;\n sonnerToastProps.id = sonnerToastPropsId ?? `ndl-toast-${Date.now()}`;\n\n // Unfortunately calling sonnerToast.dismiss does not trigger the onDismiss\n // callback (weird). So we need to save the onClose callback and call it manually\n // when calling dismiss manually as we want an onClose callback.\n // https://sonner.emilkowal.ski/toast#on-close-callback\n // https://github.com/emilkowalski/sonner/blob/main/src/index.tsx#L320\n // https://github.com/emilkowalski/sonner/blob/main/src/index.tsx#L359\n (sonnerToast as CustomSonnerToast).needle = {\n [String(sonnerToastProps.id)]: {\n onClose,\n },\n };\n\n return sonnerToast.custom(\n (id: ToastId) => (\n <Toast\n {...restProps}\n ref={ref}\n id={id}\n text={text}\n variant={variant}\n icon={icon}\n onClose={onClose}\n onAction={onAction}\n />\n ),\n {\n ...getProps(\n onClose,\n shouldAutoClose,\n onAutoClose,\n onAction,\n sonnerToastProps,\n variant,\n ),\n },\n );\n}\n\n// eslint-disable-next-line no-redeclare\ninterface Toast {\n neutral: (text: ReactNode, props?: ToastNeutralProps) => ToastId;\n success: (text: ReactNode, props?: ToastSuccessProps) => ToastId;\n danger: (text: ReactNode, props?: ToastDangerProps) => ToastId;\n progressBar: (text: ReactNode, props?: ToastProgressBarProps) => ToastId;\n updateProgressBarValue: (id: ToastId, value: number) => void;\n close: (id: ToastId) => void;\n sonnerToast: typeof sonnerToast;\n}\n\nconst toast: Toast = {\n close: (id) => {\n sonnerToast.dismiss(id);\n onCloseCallback((sonnerToast as CustomSonnerToast).needle[id]?.onClose, id);\n },\n danger: (text: ReactNode, props = {}) =>\n createToast(text, props, 'danger', <ExclamationCircleIconSolid />),\n neutral: (text, props = {}) => {\n const { icon, ...restProps } = props;\n return createToast(text, restProps, 'neutral', icon);\n },\n progressBar: (text: ReactNode, props = {}) => {\n const { icon, ...restProps } = props;\n return createToast(text, restProps, 'progress-bar', icon);\n },\n sonnerToast,\n success: (text: ReactNode, props = {}) => {\n const icon = <CheckCircleIconSolid />;\n return createToast(text, props, 'success', icon);\n },\n updateProgressBarValue: (id, givenValue) => {\n const value = givenValue > 100 ? 100 : givenValue < 0 ? 0 : givenValue;\n\n // Unable to use the sonner toast.update on custom toasts.\n const widthValue = `${value}%`;\n const toastElement = document.getElementById(String(id)) as HTMLDivElement;\n\n if (!toastElement) {\n return;\n }\n\n const progressBarContainerElement = toastElement.querySelector(\n '.ndl-progress-bar-container',\n ) as HTMLDivElement;\n progressBarContainerElement.ariaValueNow = String(value);\n const progressBarElement = progressBarContainerElement.querySelector(\n '.ndl-progress-bar',\n ) as HTMLDivElement;\n\n if (!progressBarContainerElement) {\n return;\n }\n\n progressBarElement.style.setProperty('width', widthValue);\n }, // If devs wish to directly access sonner toast.\n};\n\nexport { Toaster, toast };\nexport type {\n ToasterProps,\n ToastVariants,\n ToastCommandVariants,\n ToastNeutralProps,\n ToastSuccessProps,\n ToastDangerProps,\n ToastProgressBarProps,\n ToastVariantsProps,\n ToastElement,\n ToastId,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../../src/toast/Toast.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAEL,KAAK,IAAI,WAAW,EACpB,OAAO,IAAI,aAAa,GAGzB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA6D9C,MAAM,OAAO,GAAG,CAAC,KAAmB,EAAE,EAAE;IACtC,MAAM,EACJ,QAAQ,GAAG,aAAa,EACxB,aAAa,GAAG,CAAC,EACjB,SAAS,EACT,kBAAkB,GACnB,GAAG,KAAK,CAAC;IAEV,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAE7D,OAAO,CACL,KAAC,aAAa,kBACZ,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,IACxB,kBAAkB,EACtB,CACH,CAAC;AACJ,CAAC,CAAC;AAOF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C,CAAC,UAAU,CAAC;QAEvE,0DAA0D;QAC1D,MAAM,UAAU,GAAG,GAAG,KAAK,GAAG,CAAC;QAC/B,MAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAmB,CAAC;QAE3E,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,2BAA2B,GAAG,YAAY,CAAC,aAAa,CAC5D,6BAA6B,CACZ,CAAC;QACpB,2BAA2B,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC,aAAa,CAClE,mBAAmB,CACF,CAAC;QAEpB,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC,EAAE,gDAAgD;CACpD,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport { type ReactNode } from 'react';\nimport {\n type ExternalToast as SonnerExternalToast,\n toast as sonnerToast,\n Toaster as SonnerToaster,\n type ToasterProps as SonnerToasterProps,\n type ToastT as SonnerToastT,\n} from 'sonner';\n\nimport { type CommonProps } from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { CheckCircleIconSolid } from '../icons/generated/heroIcons/CheckCircleIconSolid';\nimport { ExclamationCircleIconSolid } from '../icons/generated/heroIcons/ExclamationCircleIconSolid';\nimport { XMarkIconOutline } from '../icons/generated/heroIcons/XMarkIconOutline';\nimport { OutlinedButton } from '../outlined-button';\nimport { ProgressBar } from '../progress-bar';\n\ntype ToastVariants = 'neutral' | 'success' | 'danger' | 'progress-bar';\n\ntype ToastCommandVariants = 'neutral' | 'success' | 'danger' | 'progressBar';\n\ntype ToastId = string | number;\n\ntype BaseToastProps = CommonProps<\n 'div',\n {\n /** If `true` a close button will be displayed in the toast. */\n isCloseable?: boolean;\n /** If `true` the toast will close when the action button is triggered. */\n shouldCloseOnAction?: boolean;\n /** Function that will be called when the toast is closed. */\n onClose?: (id: ToastId) => void;\n /** If true the toast will close automatically after a certain time. */\n shouldAutoClose?: boolean;\n /** Function that will be called when the toast is automatically closed. */\n onAutoClose?: (id: ToastId) => void;\n /** If set an action button will be displayed. The value here will be displayed\n * in the action button. If this is set the toast property `shouldAutoClose` will\n * automatically be set to `false` unless overridden. */\n actionLabel?: string;\n /** Function that will be called when the action button is clicked. */\n onAction?: (id: ToastId) => void;\n /** If a dev wishes to set the underlying framework props (Sonner Toast).\n * https://sonner.emilkowal.ski/toast#api-reference */\n sonnerToastProps?: SonnerExternalToast;\n /** If true the toast is controlled by the parent. */\n isControlled?: boolean;\n }\n>;\n\ninterface ToastNeutralProps extends BaseToastProps {\n icon?: ReactNode;\n}\n// oxlint-disable-next-line @typescript-eslint/no-empty-object-type\ninterface ToastSuccessProps extends BaseToastProps {}\n// oxlint-disable-next-line @typescript-eslint/no-empty-object-type\ninterface ToastDangerProps extends BaseToastProps {}\n\ninterface ToastProgressBarProps extends BaseToastProps {\n icon?: ReactNode;\n initialProgressBarValue?: number;\n}\n\ntype ToastVariantsProps =\n | ToastNeutralProps\n | ToastSuccessProps\n | ToastDangerProps\n | ToastProgressBarProps;\n\ninterface ToasterProps extends Pick<\n SonnerToasterProps,\n 'position' | 'visibleToasts' | 'className'\n> {\n sonnerToasterProps?: SonnerToasterProps;\n}\n\nconst Toaster = (props: ToasterProps) => {\n const {\n position = 'bottom-left',\n visibleToasts = 1,\n className,\n sonnerToasterProps,\n } = props;\n\n const classes = classNames('ndl-toast-container', className);\n\n return (\n <SonnerToaster\n className={classes}\n position={position}\n visibleToasts={visibleToasts}\n {...sonnerToasterProps}\n />\n );\n};\n\ntype SonnerToast = typeof sonnerToast;\ninterface CustomSonnerToast extends SonnerToast {\n needle: Record<string, { onClose?: (id: ToastId) => void }>;\n}\n\nfunction onCloseCallback(\n callback: ((id: ToastId) => void) | undefined,\n id: ToastId,\n) {\n if (callback) {\n callback(id);\n // Cleanup\n delete (sonnerToast as CustomSonnerToast).needle[id];\n }\n}\n\ntype ToastElement = ToastVariantsProps & {\n icon: ReactNode;\n id: ToastId;\n variant: ToastVariants;\n text: ReactNode;\n initialProgressBarValue?: number;\n isControlled?: boolean;\n};\n\nconst Toast = ({\n icon,\n id,\n text,\n variant,\n isCloseable,\n onClose,\n actionLabel,\n onAction,\n shouldCloseOnAction,\n initialProgressBarValue,\n isControlled,\n htmlAttributes,\n ref,\n ...restProps\n}: ToastElement) => {\n const isProgressBar = variant === 'progress-bar';\n\n const handleOnClose = () => {\n if (isControlled === true) {\n onCloseCallback(onClose, id);\n return;\n }\n sonnerToast.dismiss(id);\n onCloseCallback(onClose, id);\n };\n\n const handleOnAction = () => {\n if (onAction) {\n onAction(id);\n }\n if (shouldCloseOnAction === true) {\n sonnerToast.dismiss(id);\n onCloseCallback(onClose, id);\n }\n };\n\n return (\n <div\n id={String(id)}\n className=\"ndl-toast\"\n tabIndex={-1}\n ref={ref}\n data-variant={variant}\n data-testid=\"ndl-toast\"\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-toast-content\" tabIndex={-1}>\n {icon && (\n <div className={`ndl-toast-icon ndl-toast-${variant}`}>{icon}</div>\n )}\n <div className=\"ndl-toast-text\">{text}</div>\n {actionLabel && (\n <OutlinedButton\n className=\"ndl-toast-action\"\n size=\"small\"\n onClick={handleOnAction}\n >\n {actionLabel}\n </OutlinedButton>\n )}\n {(isCloseable || actionLabel || isProgressBar) && (\n <CleanIconButton\n className=\"ndl-toast-close-button\"\n onClick={handleOnClose}\n description={null}\n size=\"small\"\n htmlAttributes={{\n 'aria-label': 'Close',\n }}\n >\n <XMarkIconOutline />\n </CleanIconButton>\n )}\n </div>\n {isProgressBar && (\n <ProgressBar size=\"small\" value={initialProgressBarValue ?? 0} />\n )}\n </div>\n );\n};\n\nfunction getProps(\n onClose: ((id: ToastId) => void) | undefined,\n shouldAutoClose: boolean | undefined,\n onAutoClose: ((id: ToastId) => void) | undefined,\n onAction: ((id: ToastId) => void) | undefined,\n sonnerToastProps: SonnerExternalToast | undefined,\n variant: ToastVariants,\n) {\n const isProgressBar = variant === 'progress-bar';\n // https://sonner.emilkowal.ski/toast#api-reference\n return {\n duration:\n !isProgressBar && shouldAutoClose ? (!onAction ? 5000 : 8000) : Infinity,\n onAutoClose: (toast: SonnerToastT) => {\n if (onAutoClose) {\n return onAutoClose(toast.id);\n }\n },\n onDismiss: (toast: SonnerToastT) => {\n onCloseCallback(onClose, toast.id);\n },\n unstyled: true,\n ...sonnerToastProps,\n };\n}\n\nfunction createToast(\n text: ReactNode,\n props: ToastVariantsProps,\n variant: ToastVariants,\n icon: ReactNode,\n) {\n const {\n ref,\n sonnerToastProps = {},\n onClose,\n shouldAutoClose,\n onAutoClose,\n onAction,\n ...restProps\n } = props;\n\n const { id: sonnerToastPropsId } = sonnerToastProps;\n sonnerToastProps.id = sonnerToastPropsId ?? `ndl-toast-${Date.now()}`;\n\n // Unfortunately calling sonnerToast.dismiss does not trigger the onDismiss\n // callback (weird). So we need to save the onClose callback and call it manually\n // when calling dismiss manually as we want an onClose callback.\n // https://sonner.emilkowal.ski/toast#on-close-callback\n // https://github.com/emilkowalski/sonner/blob/main/src/index.tsx#L320\n // https://github.com/emilkowalski/sonner/blob/main/src/index.tsx#L359\n (sonnerToast as CustomSonnerToast).needle = {\n [String(sonnerToastProps.id)]: {\n onClose,\n },\n };\n\n return sonnerToast.custom(\n (id: ToastId) => (\n <Toast\n {...restProps}\n ref={ref}\n id={id}\n text={text}\n variant={variant}\n icon={icon}\n onClose={onClose}\n onAction={onAction}\n />\n ),\n {\n ...getProps(\n onClose,\n shouldAutoClose,\n onAutoClose,\n onAction,\n sonnerToastProps,\n variant,\n ),\n },\n );\n}\n\n// eslint-disable-next-line no-redeclare\ninterface Toast {\n neutral: (text: ReactNode, props?: ToastNeutralProps) => ToastId;\n success: (text: ReactNode, props?: ToastSuccessProps) => ToastId;\n danger: (text: ReactNode, props?: ToastDangerProps) => ToastId;\n progressBar: (text: ReactNode, props?: ToastProgressBarProps) => ToastId;\n updateProgressBarValue: (id: ToastId, value: number) => void;\n close: (id: ToastId) => void;\n sonnerToast: typeof sonnerToast;\n}\n\nconst toast: Toast = {\n close: (id) => {\n sonnerToast.dismiss(id);\n onCloseCallback((sonnerToast as CustomSonnerToast).needle[id]?.onClose, id);\n },\n danger: (text: ReactNode, props = {}) =>\n createToast(text, props, 'danger', <ExclamationCircleIconSolid />),\n neutral: (text, props = {}) => {\n const { icon, ...restProps } = props;\n return createToast(text, restProps, 'neutral', icon);\n },\n progressBar: (text: ReactNode, props = {}) => {\n const { icon, ...restProps } = props;\n return createToast(text, restProps, 'progress-bar', icon);\n },\n sonnerToast,\n success: (text: ReactNode, props = {}) => {\n const icon = <CheckCircleIconSolid />;\n return createToast(text, props, 'success', icon);\n },\n updateProgressBarValue: (id, givenValue) => {\n const value = givenValue > 100 ? 100 : givenValue < 0 ? 0 : givenValue;\n\n // Unable to use the sonner toast.update on custom toasts.\n const widthValue = `${value}%`;\n const toastElement = document.getElementById(String(id)) as HTMLDivElement;\n\n if (!toastElement) {\n return;\n }\n\n const progressBarContainerElement = toastElement.querySelector(\n '.ndl-progress-bar-container',\n ) as HTMLDivElement;\n progressBarContainerElement.ariaValueNow = String(value);\n const progressBarElement = progressBarContainerElement.querySelector(\n '.ndl-progress-bar',\n ) as HTMLDivElement;\n\n if (!progressBarContainerElement) {\n return;\n }\n\n progressBarElement.style.setProperty('width', widthValue);\n }, // If devs wish to directly access sonner toast.\n};\n\nexport { Toaster, toast };\nexport type {\n ToasterProps,\n ToastVariants,\n ToastCommandVariants,\n ToastNeutralProps,\n ToastSuccessProps,\n ToastDangerProps,\n ToastProgressBarProps,\n ToastVariantsProps,\n ToastElement,\n ToastId,\n};\n"]}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import { Streamdown } from 'streamdown';
|
|
22
22
|
import { type CommonProps } from '../../_common/types';
|
|
23
23
|
type ResponseProps = {
|
|
24
|
-
/**
|
|
24
|
+
/** Markdown content from the AI. URLs and attributes are sanitized before render. */
|
|
25
25
|
children: string;
|
|
26
26
|
/** Whether the response is animating */
|
|
27
27
|
isAnimating?: React.ComponentProps<typeof Streamdown>['isAnimating'];
|
|
@@ -30,6 +30,20 @@ type ResponseProps = {
|
|
|
30
30
|
* The component is used to display the response from an LLM.
|
|
31
31
|
* It handles markdown rendering and streaming.
|
|
32
32
|
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Treat `children` as untrusted. Link and image URLs are limited to `http:`,
|
|
35
|
+
* `https:`, `mailto:`, and same-origin relative or fragment paths. Unsafe
|
|
36
|
+
* schemes (for example `javascript:`) and network-path URLs (for example
|
|
37
|
+
* `//evil.example`) render as plain text for links and are omitted for images.
|
|
38
|
+
* Markdown attributes are allow-listed so event handlers cannot reach the DOM.
|
|
39
|
+
* Allowed links open in a new tab with a fixed `rel="noopener noreferrer"`
|
|
40
|
+
* (`target` and `rel` from markdown are ignored). Absolute `http:` and
|
|
41
|
+
* `https:` links use `TextLink` `type="external"` when their origin differs
|
|
42
|
+
* from the page, and `type="internal"` when it matches. Relative, fragment,
|
|
43
|
+
* and `mailto:` links use `type="internal"`.
|
|
44
|
+
* Ids and related attributes from model output are prefixed with
|
|
45
|
+
* `user-content-` to avoid colliding with the host document.
|
|
46
|
+
*
|
|
33
47
|
* @alpha - Changes to this component may be breaking.
|
|
34
48
|
*/
|
|
35
49
|
declare const Response: import("react").MemoExoticComponent<({ className, children, isAnimating, ref, style, htmlAttributes, ...restProps }: CommonProps<"div", ResponseProps>) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAwB,UAAU,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAwB,UAAU,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,qBAAqB,CAAC;AAqJ5E,KAAK,aAAa,GAAG;IACnB,qFAAqF;IACrF,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC;CACtE,CAAC;AA8BF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,QAAQ,uHAST,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC,6CA0TrC,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Returns a URL safe to use as an anchor `href` or image `src`, or `undefined`
|
|
23
|
+
* when the value must not be rendered as a navigable/fetchable URL.
|
|
24
|
+
*/
|
|
25
|
+
export declare const safeHref: (href?: string) => string | undefined;
|
|
26
|
+
//# sourceMappingURL=safe-href.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-href.d.ts","sourceRoot":"","sources":["../../../../src/ai/response/safe-href.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAuCH;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,SAqDjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-all-components.story.d.ts","sourceRoot":"","sources":["../../../../../src/ai/response/stories/response-all-components.story.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"response-all-components.story.d.ts","sourceRoot":"","sources":["../../../../../src/ai/response/stories/response-all-components.story.tsx"],"names":[],"mappings":"AAmOA,eAAO,MAAM,SAAS,+CAYrB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-lists.story.d.ts","sourceRoot":"","sources":["../../../../../src/ai/response/stories/response-lists.story.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"response-lists.story.d.ts","sourceRoot":"","sources":["../../../../../src/ai/response/stories/response-lists.story.tsx"],"names":[],"mappings":"AAoKA,eAAO,MAAM,SAAS,+CAYrB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":"AAwBA,OAAO,eAEN,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAyEpD;;;;;;GAMG;AACH,UAAU,eAAe;IACvB,oDAAoD;IAGpD,cAAc,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC;IACxD,2CAA2C;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qDAAqD;IACrD,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,CAAC;IAClE,kEAAkE;IAClE,oBAAoB,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,CAAC;IACnE;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,UAAU,GAAI,8JAYxB,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":"AAwBA,OAAO,eAEN,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAyEpD;;;;;;GAMG;AACH,UAAU,eAAe;IACvB,oDAAoD;IAGpD,cAAc,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC;IACxD,2CAA2C;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qDAAqD;IACrD,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,CAAC;IAClE,kEAAkE;IAClE,oBAAoB,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,CAAC;IACnE;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,UAAU,GAAI,8JAYxB,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,4CAwZrC,CAAC"}
|
|
@@ -41,7 +41,7 @@ type DropzoneProps = {
|
|
|
41
41
|
loadingElement?: React.ReactNode;
|
|
42
42
|
/** Use when wanting a custom heading. */
|
|
43
43
|
heading?: React.ReactNode;
|
|
44
|
-
/** Message
|
|
44
|
+
/** Message shown when a file is rejected. Defaults to "File extension not supported." when omitted. */
|
|
45
45
|
rejectedText?: React.ReactNode;
|
|
46
46
|
/** The accepted file extensions for the Drag-and-Drop. */
|
|
47
47
|
acceptedFileExtensions?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropzone.d.ts","sourceRoot":"","sources":["../../../src/dropzone/Dropzone.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpD;;;;;;GAMG;AACH;;;GAGG;AACH,KAAK,aAAa,GAAG;IACnB,4LAA4L;IAC5L,eAAe,EAAE,eAAe,CAAC;IAEjC,oGAAoG;IACpG,yBAAyB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE5C,kDAAkD;IAClD,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEjC,yCAAyC;IACzC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,
|
|
1
|
+
{"version":3,"file":"Dropzone.d.ts","sourceRoot":"","sources":["../../../src/dropzone/Dropzone.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpD;;;;;;GAMG;AACH;;;GAGG;AACH,KAAK,aAAa,GAAG;IACnB,4LAA4L;IAC5L,eAAe,EAAE,eAAe,CAAC;IAEjC,oGAAoG;IACpG,yBAAyB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE5C,kDAAkD;IAClD,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEjC,yCAAyC;IACzC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,uGAAuG;IACvG,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE/B,0DAA0D;IAC1D,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,KAAK,+BAA+B,GAAG;IACrC,2CAA2C;IAC3C,qBAAqB,EAAE,MAAM,CAAC;IAE9B,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAsNF,QAAA,MAAM,QAAQ,wKA5LX,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC;4HA8JjC,WAAW,CAAC,KAAK,EAAE,+BAA+B,CAAC;CAgCpD,CAAC;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: ndl-react
|
|
3
3
|
metadata:
|
|
4
4
|
package: '@neo4j-ndl/react'
|
|
5
|
-
version: '5.1.
|
|
5
|
+
version: '5.1.4'
|
|
6
6
|
description: >-
|
|
7
7
|
Build and edit UI with the Neo4j Needle React design system
|
|
8
8
|
(@neo4j-ndl/react). Use when adding, composing, or modifying Needle components
|
|
@@ -15,7 +15,7 @@ description: >-
|
|
|
15
15
|
|
|
16
16
|
# Neo4j Needle (@neo4j-ndl/react)
|
|
17
17
|
|
|
18
|
-
> 📌 Shipped with `@neo4j-ndl/react` v5.1.
|
|
18
|
+
> 📌 Shipped with `@neo4j-ndl/react` v5.1.4. Once installed into your repo (e.g. via
|
|
19
19
|
> `npx skills add`) this folder is detached from the package — the installed
|
|
20
20
|
> package (TypeScript types in `node_modules/@neo4j-ndl/react`) is the source of
|
|
21
21
|
> truth.
|
|
@@ -10,10 +10,23 @@ Import: `import { Response } from '@neo4j-ndl/react/ai'`
|
|
|
10
10
|
|
|
11
11
|
| Prop | Type | Required | Default | Description |
|
|
12
12
|
|------|------|----------|---------|-------------|
|
|
13
|
-
| `children` | `string` | ✅ | |
|
|
13
|
+
| `children` | `string` | ✅ | | Markdown content from the AI. URLs and attributes are sanitized before render. |
|
|
14
14
|
| `isAnimating` | `boolean` | | | Whether the response is animating |
|
|
15
15
|
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
16
16
|
|
|
17
|
+
Treat `children` as untrusted. Link and image URLs are limited to `http:`,
|
|
18
|
+
`https:`, `mailto:`, and same-origin relative or fragment paths. Unsafe
|
|
19
|
+
schemes (for example `javascript:`) and network-path URLs (for example
|
|
20
|
+
`//evil.example`) render as plain text for links and are omitted for images.
|
|
21
|
+
Markdown attributes are allow-listed so event handlers cannot reach the DOM.
|
|
22
|
+
Allowed links open in a new tab with a fixed `rel="noopener noreferrer"`
|
|
23
|
+
(`target` and `rel` from markdown are ignored). Absolute `http:` and
|
|
24
|
+
`https:` links use `TextLink` `type="external"` when their origin differs
|
|
25
|
+
from the page, and `type="internal"` when it matches. Relative, fragment,
|
|
26
|
+
and `mailto:` links use `type="internal"`.
|
|
27
|
+
Ids and related attributes from model output are prefixed with
|
|
28
|
+
`user-content-` to avoid colliding with the host document.
|
|
29
|
+
|
|
17
30
|
## Examples
|
|
18
31
|
|
|
19
32
|
### Default
|
|
@@ -155,9 +168,13 @@ without syntax highlighting
|
|
|
155
168
|
|
|
156
169
|
## Links
|
|
157
170
|
|
|
158
|
-
Visit [
|
|
171
|
+
Visit [Needle AI Response All Components](/?path=/story/components-ai-response--all-components) to see a full demo of the story. — This link has the href \`/?path=/story/components-ai-response--all-components\`, which is relative to the current origin.
|
|
172
|
+
|
|
173
|
+
Visit [Needle on this origin](https://needle.neo4j.design/?path=/story/components-ai-response--all-components) — This link has the href \`https://needle.neo4j.design/?path=/story/components-ai-response--all-components\`, which is an absolute URL. It is internal when the page origin is \`https://needle.neo4j.design\`.
|
|
174
|
+
|
|
175
|
+
Visit [Neo4j](https://neo4j.com) for more information. — This link has the href \`https://neo4j.com\`, which is an absolute URL on a different origin.
|
|
159
176
|
|
|
160
|
-
Multiple links: [Documentation](https://neo4j.com/docs) and [Community](https://community.neo4j.com)
|
|
177
|
+
Multiple links: [Documentation](https://neo4j.com/docs) and [Community](https://community.neo4j.com). — These links have the hrefs \`https://neo4j.com/docs\` and \`https://community.neo4j.com\`, which are absolute URLs.
|
|
161
178
|
|
|
162
179
|
## Blockquotes
|
|
163
180
|
|
|
@@ -255,9 +272,15 @@ Use code blocks for preformatted text with preserved spacing:
|
|
|
255
272
|
`;
|
|
256
273
|
|
|
257
274
|
export const Component = () => {
|
|
275
|
+
// Keep the live example on the current origin so it renders as internal
|
|
276
|
+
// both locally and on the published Storybook.
|
|
277
|
+
const markdown = comprehensiveMarkdown.replaceAll(
|
|
278
|
+
'https://needle.neo4j.design',
|
|
279
|
+
window.location.origin,
|
|
280
|
+
);
|
|
258
281
|
return (
|
|
259
282
|
<div className="max-w-4xl">
|
|
260
|
-
<Response>{
|
|
283
|
+
<Response>{markdown}</Response>
|
|
261
284
|
</div>
|
|
262
285
|
);
|
|
263
286
|
};
|
|
@@ -1039,6 +1062,8 @@ const listsMarkdown = `
|
|
|
1039
1062
|
- Neo4j Desktop
|
|
1040
1063
|
- Neo4j Browser
|
|
1041
1064
|
- Neo4j Bloom
|
|
1065
|
+
4. Needle
|
|
1066
|
+
- [Needle](https://needle.neo4j.design)
|
|
1042
1067
|
|
|
1043
1068
|
## Lists with Inline Formatting
|
|
1044
1069
|
|
|
@@ -1050,9 +1075,15 @@ const listsMarkdown = `
|
|
|
1050
1075
|
`;
|
|
1051
1076
|
|
|
1052
1077
|
export const Component = () => {
|
|
1078
|
+
// Keep the live example on the current origin so it renders as internal
|
|
1079
|
+
// both locally and on the published Storybook.
|
|
1080
|
+
const markdown = listsMarkdown.replaceAll(
|
|
1081
|
+
'https://needle.neo4j.design',
|
|
1082
|
+
window.location.origin,
|
|
1083
|
+
);
|
|
1053
1084
|
return (
|
|
1054
1085
|
<div className="max-w-4xl">
|
|
1055
|
-
<Response>{
|
|
1086
|
+
<Response>{markdown}</Response>
|
|
1056
1087
|
</div>
|
|
1057
1088
|
);
|
|
1058
1089
|
};
|
|
@@ -15,7 +15,7 @@ Import: `import { Dropzone } from '@neo4j-ndl/react'`
|
|
|
15
15
|
| `heading` | `ReactNode` | | | Use when wanting a custom heading. |
|
|
16
16
|
| `loadingElement` | `ReactNode` | | | Element to display when uploading the file. |
|
|
17
17
|
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
18
|
-
| `rejectedText` | `ReactNode` | | | Message
|
|
18
|
+
| `rejectedText` | `ReactNode` | | | Message shown when a file is rejected. Defaults to "File extension not supported." when omitted. |
|
|
19
19
|
| `supportedFilesDescription` | `ReactNode` | | | Informational text that highlights the supported file types, will be displayed in the footer. |
|
|
20
20
|
|
|
21
21
|
Where `DropzoneOptions` is the props for the `react-dropzone` library. For more information, see the [react-dropzone documentation](https://react-dropzone.js.org/#src).
|