@neo4j-ndl/react 5.1.1 → 5.1.3
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/button/stories/button-disabled.story.js +1 -1
- package/lib/cjs/button/stories/button-disabled.story.js.map +1 -1
- package/lib/cjs/button/stories/button-floating.story.js +1 -1
- package/lib/cjs/button/stories/button-floating.story.js.map +1 -1
- package/lib/cjs/button/stories/button-fluid.story.js +1 -1
- package/lib/cjs/button/stories/button-fluid.story.js.map +1 -1
- package/lib/cjs/button/stories/button-loading.story.js +1 -1
- package/lib/cjs/button/stories/button-loading.story.js.map +1 -1
- package/lib/cjs/button/stories/button-running-cancel.story.js +3 -4
- package/lib/cjs/button/stories/button-running-cancel.story.js.map +1 -1
- package/lib/cjs/checkbox/Checkbox.js +1 -0
- package/lib/cjs/checkbox/Checkbox.js.map +1 -1
- package/lib/cjs/clipboard-button/ClipboardButton.js +1 -1
- package/lib/cjs/clipboard-button/ClipboardButton.js.map +1 -1
- package/lib/cjs/dropzone/Dropzone.js +2 -6
- package/lib/cjs/dropzone/Dropzone.js.map +1 -1
- package/lib/cjs/switch/Switch.js +1 -0
- package/lib/cjs/switch/Switch.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/button/stories/button-disabled.story.js +3 -3
- package/lib/esm/button/stories/button-disabled.story.js.map +1 -1
- package/lib/esm/button/stories/button-floating.story.js +3 -3
- package/lib/esm/button/stories/button-floating.story.js.map +1 -1
- package/lib/esm/button/stories/button-fluid.story.js +3 -3
- package/lib/esm/button/stories/button-fluid.story.js.map +1 -1
- package/lib/esm/button/stories/button-loading.story.js +3 -3
- package/lib/esm/button/stories/button-loading.story.js.map +1 -1
- package/lib/esm/button/stories/button-running-cancel.story.js +3 -4
- package/lib/esm/button/stories/button-running-cancel.story.js.map +1 -1
- package/lib/esm/checkbox/Checkbox.js +1 -0
- package/lib/esm/checkbox/Checkbox.js.map +1 -1
- package/lib/esm/clipboard-button/ClipboardButton.js +1 -1
- package/lib/esm/clipboard-button/ClipboardButton.js.map +1 -1
- package/lib/esm/dropzone/Dropzone.js +2 -6
- package/lib/esm/dropzone/Dropzone.js.map +1 -1
- package/lib/esm/switch/Switch.js +1 -0
- package/lib/esm/switch/Switch.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/button/stories/button-disabled.story.d.ts.map +1 -1
- package/lib/types/button/stories/button-floating.story.d.ts.map +1 -1
- package/lib/types/button/stories/button-fluid.story.d.ts.map +1 -1
- package/lib/types/button/stories/button-loading.story.d.ts.map +1 -1
- package/lib/types/button/stories/button-running-cancel.story.d.ts.map +1 -1
- package/lib/types/checkbox/Checkbox.d.ts.map +1 -1
- package/lib/types/clipboard-button/ClipboardButton.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/lib/types/switch/Switch.d.ts.map +1 -1
- package/package.json +5 -5
- 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":"button-fluid.story.js","sourceRoot":"","sources":["../../../../src/button/stories/button-fluid.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"button-fluid.story.js","sourceRoot":"","sources":["../../../../src/button/stories/button-fluid.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE5E,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,eAAK,SAAS,EAAC,2BAA2B,aACxC,KAAC,YAAY,IAAC,OAAO,6BAAsB,EAC3C,KAAC,cAAc,IAAC,OAAO,+BAA0B,EACjD,KAAC,UAAU,IAAC,OAAO,2BAAkB,IACjC,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton, OutlinedButton, TextButton } from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <div className=\"flex flex-col gap-token-8\">\n <FilledButton isFluid>Filled</FilledButton>\n <OutlinedButton isFluid>Outlined</OutlinedButton>\n <TextButton isFluid>Text</TextButton>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/*!
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) "Neo4j"
|
|
@@ -20,9 +20,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
20
20
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
21
|
*/
|
|
22
22
|
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
|
-
import { FilledButton } from '@neo4j-ndl/react';
|
|
23
|
+
import { FilledButton, OutlinedButton, TextButton } from '@neo4j-ndl/react';
|
|
24
24
|
const Component = () => {
|
|
25
|
-
return (_jsx(FilledButton, { isLoading: true,
|
|
25
|
+
return (_jsxs("div", { className: "grid grid-cols-3 gap-token-8", children: [_jsx(FilledButton, { isLoading: true, variant: "primary", children: "Filled Primary" }), _jsx(FilledButton, { isLoading: true, variant: "danger", children: "Filled Danger" }), _jsx("div", {}), _jsx(OutlinedButton, { isLoading: true, variant: "primary", children: "Outlined Primary" }), _jsx(OutlinedButton, { isLoading: true, variant: "danger", children: "Outlined Danger" }), _jsx(OutlinedButton, { isLoading: true, variant: "neutral", children: "Outlined Neutral" }), _jsx(TextButton, { isLoading: true, variant: "primary", children: "Text Primary" }), _jsx(TextButton, { isLoading: true, variant: "danger", children: "Text Danger" }), _jsx(TextButton, { isLoading: true, variant: "neutral", children: "Text Neutral" })] }));
|
|
26
26
|
};
|
|
27
27
|
export default Component;
|
|
28
28
|
//# sourceMappingURL=button-loading.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-loading.story.js","sourceRoot":"","sources":["../../../../src/button/stories/button-loading.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"button-loading.story.js","sourceRoot":"","sources":["../../../../src/button/stories/button-loading.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE5E,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,eAAK,SAAS,EAAC,8BAA8B,aAC3C,KAAC,YAAY,IAAC,SAAS,QAAC,OAAO,EAAC,SAAS,+BAE1B,EACf,KAAC,YAAY,IAAC,SAAS,QAAC,OAAO,EAAC,QAAQ,8BAEzB,EACf,eAAO,EACP,KAAC,cAAc,IAAC,SAAS,QAAC,OAAO,EAAC,SAAS,iCAE1B,EACjB,KAAC,cAAc,IAAC,SAAS,QAAC,OAAO,EAAC,QAAQ,gCAEzB,EACjB,KAAC,cAAc,IAAC,SAAS,QAAC,OAAO,EAAC,SAAS,iCAE1B,EACjB,KAAC,UAAU,IAAC,SAAS,QAAC,OAAO,EAAC,SAAS,6BAE1B,EACb,KAAC,UAAU,IAAC,SAAS,QAAC,OAAO,EAAC,QAAQ,4BAEzB,EACb,KAAC,UAAU,IAAC,SAAS,QAAC,OAAO,EAAC,SAAS,6BAE1B,IACT,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton, OutlinedButton, TextButton } from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <div className=\"grid grid-cols-3 gap-token-8\">\n <FilledButton isLoading variant=\"primary\">\n Filled Primary\n </FilledButton>\n <FilledButton isLoading variant=\"danger\">\n Filled Danger\n </FilledButton>\n <div />\n <OutlinedButton isLoading variant=\"primary\">\n Outlined Primary\n </OutlinedButton>\n <OutlinedButton isLoading variant=\"danger\">\n Outlined Danger\n </OutlinedButton>\n <OutlinedButton isLoading variant=\"neutral\">\n Outlined Neutral\n </OutlinedButton>\n <TextButton isLoading variant=\"primary\">\n Text Primary\n </TextButton>\n <TextButton isLoading variant=\"danger\">\n Text Danger\n </TextButton>\n <TextButton isLoading variant=\"neutral\">\n Text Neutral\n </TextButton>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -68,10 +68,9 @@ const Component = () => {
|
|
|
68
68
|
display: 'flex',
|
|
69
69
|
flexDirection: 'column',
|
|
70
70
|
gap: '5px',
|
|
71
|
-
}, children: [_jsx("div", { children: "Click to start the mocked running process" }), _jsx(FilledButton, Object.assign({ style: { width: '100px' } }, buttonProps)), _jsxs("div", { style: { marginTop: '10px', position: 'relative' }, children: [_jsx("span", { children: "Status: " }), _jsx("span", {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}, children: isRunning ? `Running (${secondsLeft} seconds left)` : 'Not running' })] })] }));
|
|
71
|
+
}, children: [_jsx("div", { children: "Click to start the mocked running process" }), _jsx(FilledButton, Object.assign({ style: { width: '100px' } }, buttonProps)), _jsxs("div", { style: { marginTop: '10px', position: 'relative' }, children: [_jsx("span", { children: "Status: " }), _jsx("span", { className: isRunning
|
|
72
|
+
? 'text-success-text font-bold'
|
|
73
|
+
: 'text-danger-text font-bold', children: isRunning ? `Running (${secondsLeft} seconds left)` : 'Not running' })] })] }));
|
|
75
74
|
};
|
|
76
75
|
export default Component;
|
|
77
76
|
//# sourceMappingURL=button-running-cancel.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-running-cancel.story.js","sourceRoot":"","sources":["../../../../src/button/stories/button-running-cancel.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAExD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;QAC/B,OAAO,CAAC,SAAS;YACf,CAAC,CAAC;gBACE,QAA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ACX,aAED,sEAAoD,EACpD,KAAC,YAAY,kBAAC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAM,WAAW,EAAI,EAC5D,eAAK,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,aACrD,sCAAqB,EACrB,eACE,
|
|
1
|
+
{"version":3,"file":"button-running-cancel.story.js","sourceRoot":"","sources":["../../../../src/button/stories/button-running-cancel.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAExD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;QAC/B,OAAO,CAAC,SAAS;YACf,CAAC,CAAC;gBACE,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,GAAG,EAAE;oBACZ,cAAc,CAAC,CAAC,CAAC,CAAC;oBAClB,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE;wBACrC,cAAc,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;oBACrC,CAAC,EAAE,IAAI,CAAC,CAAC;oBACT,yEAAyE;oBACzE,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;wBACnC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,CAAC,CAAC,CAAC,aAAa,GAC/D,IACH,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton } from '@neo4j-ndl/react';\nimport { useMemo, useRef, useState } from 'react';\n\nconst Component = () => {\n const [secondsLeft, setSecondsLeft] = useState<number>(0);\n const [isRunning, setIsRunning] = useState(false);\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n const intervalRef = useRef<NodeJS.Timeout | null>(null);\n\n const buttonProps = useMemo(() => {\n return !isRunning\n ? {\n children: 'Run',\n onClick: () => {\n setSecondsLeft(5);\n intervalRef.current = setInterval(() => {\n setSecondsLeft((prev) => prev - 1);\n }, 1000);\n // Start the mocked running process. This would be your running function.\n timeoutRef.current = setTimeout(() => {\n setIsRunning(false);\n timeoutRef.current = null;\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n }\n }, 5000);\n setIsRunning(true);\n },\n }\n : {\n children: 'Cancel',\n onClick: () => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n }\n intervalRef.current = null;\n // Cancel the mocked running process. This would be your cancel the running function.\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n setIsRunning(false);\n },\n };\n }, [isRunning]);\n\n return (\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n flexDirection: 'column',\n gap: '5px',\n }}\n >\n <div>Click to start the mocked running process</div>\n <FilledButton style={{ width: '100px' }} {...buttonProps} />\n <div style={{ marginTop: '10px', position: 'relative' }}>\n <span>Status: </span>\n <span\n className={\n isRunning\n ? 'text-success-text font-bold'\n : 'text-danger-text font-bold'\n }\n >\n {isRunning ? `Running (${secondsLeft} seconds left)` : 'Not running'}\n </span>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/checkbox/Checkbox.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAuC9E,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAiBa,EAAE,EAAE;;QAjBjB,EACvB,SAAS,EACT,gBAAgB,EAChB,eAAe,GAAG,KAAK,EACvB,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,KAAK,EAClB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,OAEiC,EADjC,SAAS,cAhBW,qMAiBxB,CADa;IAEZ,MAAM,KAAK,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,KAIF,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,EAAE,EAJlB,EACJ,kBAAkB,EAAE,mBAAmB,EACvC,cAAc,EAAE,eAAe,OAET,EAD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,eAAe;QAC3B,OAAO;QACP,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,CACL,iBAAO,SAAS,EAAE,cAAc,aAC7B,eAAe,KAAK,IAAI,IAAI,YAAY,EACzC,8BACE,GAAG,EAAE,UAAU,EACf,IAAI,EAAC,UAAU,gBACH,SAAS,sBACH,mBAAmB,kBACvB,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,MAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,EAC/D,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,EACjB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,eAAe,IACtB,SAAS,EACT,mBAAmB,EACvB,EACD,OAAO,CAAC,eAAe,CAAC,KAAK,KAAK,IAAI,YAAY,IAC7C,CACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { useEffect, useRef } from 'react';\n\nimport {\n useFormFieldGroup,\n useInlineFieldLabel,\n} from '../_common/form-control';\nimport { type CommonProps, type HtmlAttributes } from '../_common/types';\nimport { useSemiControlledInput } from '../_common/use-semi-controlled-input';\n\ntype CheckboxProps = {\n /** Whether the checkbox is checked */\n isChecked?: boolean;\n /** Checks the input by default in uncontrolled mode */\n isDefaultChecked?: boolean; // isDefaultChecked sounds weird to me?\n /** Whether the checkbox is indeterminate */\n isIndeterminate?: boolean;\n /** Whether the checkbox is disabled */\n isDisabled?: boolean;\n /** Whether the checkbox & label should take the full available width of its container */\n isFluid?: boolean;\n /** The value of the checkbox */\n value?: HtmlAttributes<'input'>['value']; // should this be required?\n /** Whether the label should be displayed before the checkbox */\n hasLeadingLabel?: boolean;\n /** The callback function triggered when the checkbox value changes */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n /** The callback function triggered when the checkbox is clicked */\n onClick?: (event: React.MouseEvent<HTMLInputElement>) => void;\n} & (\n | {\n /** The aria label of the checkbox. Required if the label is not a string. */\n ariaLabel: string;\n // TODO v5: inconsistent naming. Naming the checkbox takes a union of\n // `label` and `ariaLabel`, so the accessible name comes from a different\n // prop depending on what the label renders. Combobox instead requires the\n // label and clips it with `hasVisuallyHiddenLabel`, and TextInput reaches\n // for htmlAttributes['aria-label'].\n /** The label of the checkbox. If not a string, supply an aria label for screen reader support. */\n label?: undefined;\n }\n | {\n ariaLabel?: string;\n label: React.ReactNode;\n }\n);\n\nexport const Checkbox = ({\n isChecked,\n isDefaultChecked,\n isIndeterminate = false,\n isFluid = false,\n isDisabled = false,\n hasLeadingLabel,\n ariaLabel,\n onChange,\n onClick,\n value,\n label,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'input', CheckboxProps>) => {\n const group = useFormFieldGroup('checkbox');\n const {\n 'aria-describedby': htmlAriaDescribedBy,\n 'aria-invalid': htmlAriaInvalid,\n ...inputHtmlAttributes\n } = htmlAttributes ?? {};\n const isDisabledState = isDisabled || group?.isDisabled === true;\n const internalRef = useRef<HTMLInputElement>(null);\n const mergedRefs = useMergeRefs([internalRef, ref]);\n\n const [isCheckedState, internalOnChange] = useSemiControlledInput({\n inputType: 'checkbox',\n isControlled: isChecked !== undefined,\n onChange,\n state: isChecked ?? isDefaultChecked ?? false,\n });\n\n const checkboxClasses = classNames('ndl-checkbox', className, {\n 'ndl-disabled': isDisabledState,\n 'ndl-indeterminate': isIndeterminate,\n });\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.indeterminate = isIndeterminate;\n }\n }, [isIndeterminate]);\n\n const { labelContent, fieldClassName } = useInlineFieldLabel({\n ariaLabel,\n componentName: 'Checkbox',\n isDisabled: isDisabledState,\n isFluid,\n label,\n });\n\n return (\n <label className={fieldClassName}>\n {hasLeadingLabel === true && labelContent}\n <input\n ref={mergedRefs}\n type=\"checkbox\"\n aria-label={ariaLabel}\n aria-describedby={htmlAriaDescribedBy}\n aria-invalid={group?.hasError === true ? true : htmlAriaInvalid}\n disabled={isDisabledState}\n checked={isCheckedState}\n name={group?.name}\n onClick={onClick}\n onChange={internalOnChange}\n value={value}\n style={style}\n className={checkboxClasses}\n {...restProps}\n {...inputHtmlAttributes}\n />\n {Boolean(hasLeadingLabel) === false && labelContent}\n </label>\n );\n};\n"]}
|
|
@@ -111,7 +111,7 @@ const ConfirmationButton = (_a) => {
|
|
|
111
111
|
onFocus: handleOpenTooltip,
|
|
112
112
|
onMouseEnter: handleOpenTooltip,
|
|
113
113
|
onMouseLeave: handleCloseTooltip,
|
|
114
|
-
}, children: _jsx(OutlinedButton, Object.assign({ variant: "neutral" }, restProps.
|
|
114
|
+
}, children: _jsx(OutlinedButton, Object.assign({ variant: "neutral" }, restProps.outlinedButtonProps, { onClick: (event) => {
|
|
115
115
|
if (onClick) {
|
|
116
116
|
onClick(event);
|
|
117
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClipboardButton.js","sourceRoot":"","sources":["../../../src/clipboard-button/ClipboardButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,OAAO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AACJ,CAAC,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport React from 'react';\n\nimport { type ButtonSizes } from '../button';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { useCopyToClipboard } from '../hooks';\nimport { IconButton } from '../icon-button';\nimport { Square2StackIconOutline } from '../icons/generated/heroIcons/Square2StackIconOutline';\nimport { Kbd } from '../kbd';\nimport { OutlinedButton } from '../outlined-button';\nimport { Tooltip } from '../tooltip';\n\ntype ConfirmationButtonProps = {\n description: string;\n descriptionKbdProps?: React.ComponentProps<typeof Kbd>;\n actionFeedbackText: string;\n tooltipProps?: Omit<React.ComponentProps<typeof Tooltip>, 'children'>;\n onClick?: React.ComponentPropsWithoutRef<'button'>['onClick'];\n children: React.ReactNode;\n className?: string;\n icon: React.ReactNode;\n htmlAttributes?: React.ComponentPropsWithoutRef<'button'>;\n} & (\n | {\n type: 'clean-icon-button';\n cleanIconButtonProps?: Omit<\n React.ComponentProps<typeof CleanIconButton>,\n 'children' | 'onClick' | 'tooltip'\n >;\n }\n | {\n type: 'icon-button';\n iconButtonProps?: Omit<\n React.ComponentProps<typeof IconButton>,\n 'children' | 'onClick' | 'tooltip'\n >;\n }\n | {\n type: 'outlined-button';\n outlinedButtonProps?: Omit<\n React.ComponentProps<typeof OutlinedButton>,\n 'children' | 'onClick' | 'tooltip'\n >;\n }\n);\n\nconst ConfirmationButton = ({\n descriptionKbdProps,\n description,\n actionFeedbackText,\n icon,\n children,\n onClick,\n htmlAttributes,\n tooltipProps,\n type = 'clean-icon-button',\n ...restProps\n}: ConfirmationButtonProps) => {\n const [timeoutId, setTimeoutId] = React.useState<number | null>(null);\n const [isOpen, setIsOpen] = React.useState(false);\n\n const handleClick = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n const newTimeoutId = window.setTimeout(() => {\n setTimeoutId(null);\n }, 2000);\n\n setTimeoutId(newTimeoutId);\n };\n\n const handleCloseTooltip = () => {\n setIsOpen(false);\n };\n\n const handleOpenTooltip = () => {\n setIsOpen(true);\n };\n\n const content = timeoutId === null ? description : actionFeedbackText;\n /* Controlling the tip to make it disappear in a timely manner */\n\n if (type === 'clean-icon-button') {\n return (\n <CleanIconButton\n {...(\n restProps as {\n cleanIconButtonProps: React.ComponentProps<typeof CleanIconButton>;\n }\n ).cleanIconButtonProps}\n description={content}\n descriptionKbdProps={descriptionKbdProps}\n tooltipProps={{\n root: {\n ...tooltipProps,\n isOpen: isOpen || timeoutId !== null,\n },\n trigger: {\n htmlAttributes: {\n onBlur: handleCloseTooltip,\n onFocus: handleOpenTooltip,\n onMouseEnter: handleOpenTooltip,\n onMouseLeave: handleCloseTooltip,\n },\n },\n }}\n onClick={(event) => {\n if (onClick) {\n onClick(event);\n }\n handleClick();\n }}\n className={restProps.className}\n htmlAttributes={htmlAttributes}\n >\n {icon}\n </CleanIconButton>\n );\n } else if (type === 'icon-button') {\n return (\n <IconButton\n {...(\n restProps as {\n iconButtonProps: React.ComponentProps<typeof IconButton>;\n }\n ).iconButtonProps}\n description={content}\n tooltipProps={{\n root: {\n ...tooltipProps,\n isOpen: isOpen || timeoutId !== null,\n },\n trigger: {\n htmlAttributes: {\n onBlur: handleCloseTooltip,\n onFocus: handleOpenTooltip,\n onMouseEnter: handleOpenTooltip,\n onMouseLeave: handleCloseTooltip,\n },\n },\n }}\n onClick={(event) => {\n if (onClick) {\n onClick(event);\n }\n handleClick();\n }}\n className={restProps.className}\n htmlAttributes={htmlAttributes}\n >\n {icon}\n </IconButton>\n );\n } else if (type === 'outlined-button') {\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isOpen || timeoutId !== null}\n {...tooltipProps}\n onOpenChange={(open) => {\n if (open) {\n handleOpenTooltip();\n } else {\n handleCloseTooltip();\n }\n tooltipProps?.onOpenChange?.(open);\n }}\n >\n <Tooltip.Trigger\n hasButtonWrapper\n htmlAttributes={{\n 'aria-label': content,\n onBlur: handleCloseTooltip,\n onFocus: handleOpenTooltip,\n onMouseEnter: handleOpenTooltip,\n onMouseLeave: handleCloseTooltip,\n }}\n >\n <OutlinedButton\n variant=\"neutral\"\n {...(\n restProps as {\n buttonProps: React.ComponentProps<typeof OutlinedButton>;\n }\n ).buttonProps}\n onClick={(event) => {\n if (onClick) {\n onClick(event);\n }\n handleClick();\n }}\n leadingVisual={icon}\n className={restProps.className}\n htmlAttributes={htmlAttributes}\n >\n {children}\n </OutlinedButton>\n </Tooltip.Trigger>\n <Tooltip.Content>\n {content}\n {descriptionKbdProps && <Kbd {...descriptionKbdProps} />}\n </Tooltip.Content>\n </Tooltip>\n );\n }\n};\n\n/**\n * @remarks\n * For more information of the `TooltipProps` type, see the Tooltip component documentation.\n */\ninterface ClipboardButtonProps {\n /** The text that should be set to users clipboard */\n textToCopy: string;\n descriptionKbdProps?: React.ComponentProps<typeof Kbd>;\n tooltipProps?: Omit<React.ComponentProps<typeof Tooltip>, 'children'>;\n isDisabled?: boolean;\n size?: ButtonSizes;\n htmlAttributes?: React.ComponentPropsWithoutRef<'button'>;\n type?: 'outlined-button' | 'clean-icon-button' | 'icon-button';\n}\n\nexport const ClipboardButton = ({\n textToCopy,\n descriptionKbdProps,\n isDisabled,\n size,\n tooltipProps,\n htmlAttributes,\n type,\n}: ClipboardButtonProps) => {\n const [, copyFunction] = useCopyToClipboard();\n\n const isOutlinedButton = type === 'outlined-button';\n const isIconButton = type === 'icon-button';\n\n const props = isOutlinedButton\n ? {\n outlinedButtonProps: {\n isDisabled,\n size,\n },\n type: 'outlined-button' as const,\n }\n : isIconButton\n ? {\n iconButtonProps: {\n description: 'Copy to clipboard',\n isDisabled,\n size,\n },\n type: 'icon-button' as const,\n }\n : {\n cleanIconButtonProps: {\n description: 'Copy to clipboard',\n isDisabled,\n size,\n },\n type: 'clean-icon-button' as const,\n };\n\n return (\n <ConfirmationButton\n onClick={() => copyFunction(textToCopy)}\n description=\"Copy to clipboard\"\n actionFeedbackText=\"Copied\"\n descriptionKbdProps={descriptionKbdProps}\n {...props}\n tooltipProps={tooltipProps}\n icon={<Square2StackIconOutline className=\"ndl-icon-svg\" />}\n htmlAttributes={{\n 'aria-live': 'polite',\n ...htmlAttributes,\n }}\n >\n {type === 'outlined-button' && 'Copy'}\n </ConfirmationButton>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ClipboardButton.js","sourceRoot":"","sources":["../../../src/clipboard-button/ClipboardButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAoCrC,MAAM,kBAAkB,GAAG,CAAC,EAWF,EAAE,EAAE;QAXF,EAC1B,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,cAAc,EACd,YAAY,EACZ,IAAI,GAAG,mBAAmB,OAEF,EADrB,SAAS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QACH,CAAC,CAAC,YAAY;YACZ,CAAC,CAAC;gBACE,eAAe,EAAE;oBACf,WAAW,EAAE,mBAAmB;oBAChC,UAAU;oBACV,IAAI;iBACL;gBACD,IAAI,EAAE,aAAsB;aAC7B;YACH,CAAC,CAAC;gBACE,oBAAoB,EAAE;oBACpB,WAAW,EAAE,mBAAmB;oBAChC,UAAU;oBACV,IAAI;iBACL;gBACD,IAAI,EAAE,mBAA4B;aACnC,CAAC;IAER,OAAO,CACL,KAAC,kBAAkB,kBACjB,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,EACvC,WAAW,EAAC,mBAAmB,EAC/B,kBAAkB,EAAC,QAAQ,EAC3B,mBAAmB,EAAE,mBAAmB,IACpC,KAAK,IACT,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,KAAC,uBAAuB,IAAC,SAAS,EAAC,cAAc,GAAG,EAC1D,cAAc,kBACZ,WAAW,EAAE,QAAQ,IAClB,cAAc,aAGlB,IAAI,KAAK,iBAAiB,IAAI,MAAM,IAClB,CACtB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport React from 'react';\n\nimport { type ButtonSizes } from '../button';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { useCopyToClipboard } from '../hooks';\nimport { IconButton } from '../icon-button';\nimport { Square2StackIconOutline } from '../icons/generated/heroIcons/Square2StackIconOutline';\nimport { Kbd } from '../kbd';\nimport { OutlinedButton } from '../outlined-button';\nimport { Tooltip } from '../tooltip';\n\ntype ConfirmationButtonProps = {\n description: string;\n descriptionKbdProps?: React.ComponentProps<typeof Kbd>;\n actionFeedbackText: string;\n tooltipProps?: Omit<React.ComponentProps<typeof Tooltip>, 'children'>;\n onClick?: React.ComponentPropsWithoutRef<'button'>['onClick'];\n children: React.ReactNode;\n className?: string;\n icon: React.ReactNode;\n htmlAttributes?: React.ComponentPropsWithoutRef<'button'>;\n} & (\n | {\n type: 'clean-icon-button';\n cleanIconButtonProps?: Omit<\n React.ComponentProps<typeof CleanIconButton>,\n 'children' | 'onClick' | 'tooltip'\n >;\n }\n | {\n type: 'icon-button';\n iconButtonProps?: Omit<\n React.ComponentProps<typeof IconButton>,\n 'children' | 'onClick' | 'tooltip'\n >;\n }\n | {\n type: 'outlined-button';\n outlinedButtonProps?: Omit<\n React.ComponentProps<typeof OutlinedButton>,\n 'children' | 'onClick' | 'tooltip'\n >;\n }\n);\n\nconst ConfirmationButton = ({\n descriptionKbdProps,\n description,\n actionFeedbackText,\n icon,\n children,\n onClick,\n htmlAttributes,\n tooltipProps,\n type = 'clean-icon-button',\n ...restProps\n}: ConfirmationButtonProps) => {\n const [timeoutId, setTimeoutId] = React.useState<number | null>(null);\n const [isOpen, setIsOpen] = React.useState(false);\n\n const handleClick = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n const newTimeoutId = window.setTimeout(() => {\n setTimeoutId(null);\n }, 2000);\n\n setTimeoutId(newTimeoutId);\n };\n\n const handleCloseTooltip = () => {\n setIsOpen(false);\n };\n\n const handleOpenTooltip = () => {\n setIsOpen(true);\n };\n\n const content = timeoutId === null ? description : actionFeedbackText;\n /* Controlling the tip to make it disappear in a timely manner */\n\n if (type === 'clean-icon-button') {\n return (\n <CleanIconButton\n {...(\n restProps as {\n cleanIconButtonProps: React.ComponentProps<typeof CleanIconButton>;\n }\n ).cleanIconButtonProps}\n description={content}\n descriptionKbdProps={descriptionKbdProps}\n tooltipProps={{\n root: {\n ...tooltipProps,\n isOpen: isOpen || timeoutId !== null,\n },\n trigger: {\n htmlAttributes: {\n onBlur: handleCloseTooltip,\n onFocus: handleOpenTooltip,\n onMouseEnter: handleOpenTooltip,\n onMouseLeave: handleCloseTooltip,\n },\n },\n }}\n onClick={(event) => {\n if (onClick) {\n onClick(event);\n }\n handleClick();\n }}\n className={restProps.className}\n htmlAttributes={htmlAttributes}\n >\n {icon}\n </CleanIconButton>\n );\n } else if (type === 'icon-button') {\n return (\n <IconButton\n {...(\n restProps as {\n iconButtonProps: React.ComponentProps<typeof IconButton>;\n }\n ).iconButtonProps}\n description={content}\n tooltipProps={{\n root: {\n ...tooltipProps,\n isOpen: isOpen || timeoutId !== null,\n },\n trigger: {\n htmlAttributes: {\n onBlur: handleCloseTooltip,\n onFocus: handleOpenTooltip,\n onMouseEnter: handleOpenTooltip,\n onMouseLeave: handleCloseTooltip,\n },\n },\n }}\n onClick={(event) => {\n if (onClick) {\n onClick(event);\n }\n handleClick();\n }}\n className={restProps.className}\n htmlAttributes={htmlAttributes}\n >\n {icon}\n </IconButton>\n );\n } else if (type === 'outlined-button') {\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isOpen || timeoutId !== null}\n {...tooltipProps}\n onOpenChange={(open) => {\n if (open) {\n handleOpenTooltip();\n } else {\n handleCloseTooltip();\n }\n tooltipProps?.onOpenChange?.(open);\n }}\n >\n <Tooltip.Trigger\n hasButtonWrapper\n htmlAttributes={{\n 'aria-label': content,\n onBlur: handleCloseTooltip,\n onFocus: handleOpenTooltip,\n onMouseEnter: handleOpenTooltip,\n onMouseLeave: handleCloseTooltip,\n }}\n >\n <OutlinedButton\n variant=\"neutral\"\n {...(\n restProps as {\n outlinedButtonProps: React.ComponentProps<\n typeof OutlinedButton\n >;\n }\n ).outlinedButtonProps}\n onClick={(event) => {\n if (onClick) {\n onClick(event);\n }\n handleClick();\n }}\n leadingVisual={icon}\n className={restProps.className}\n htmlAttributes={htmlAttributes}\n >\n {children}\n </OutlinedButton>\n </Tooltip.Trigger>\n <Tooltip.Content>\n {content}\n {descriptionKbdProps && <Kbd {...descriptionKbdProps} />}\n </Tooltip.Content>\n </Tooltip>\n );\n }\n};\n\n/**\n * @remarks\n * For more information of the `TooltipProps` type, see the Tooltip component documentation.\n */\ninterface ClipboardButtonProps {\n /** The text that should be set to users clipboard */\n textToCopy: string;\n descriptionKbdProps?: React.ComponentProps<typeof Kbd>;\n tooltipProps?: Omit<React.ComponentProps<typeof Tooltip>, 'children'>;\n isDisabled?: boolean;\n size?: ButtonSizes;\n htmlAttributes?: React.ComponentPropsWithoutRef<'button'>;\n type?: 'outlined-button' | 'clean-icon-button' | 'icon-button';\n}\n\nexport const ClipboardButton = ({\n textToCopy,\n descriptionKbdProps,\n isDisabled,\n size,\n tooltipProps,\n htmlAttributes,\n type,\n}: ClipboardButtonProps) => {\n const [, copyFunction] = useCopyToClipboard();\n\n const isOutlinedButton = type === 'outlined-button';\n const isIconButton = type === 'icon-button';\n\n const props = isOutlinedButton\n ? {\n outlinedButtonProps: {\n isDisabled,\n size,\n },\n type: 'outlined-button' as const,\n }\n : isIconButton\n ? {\n iconButtonProps: {\n description: 'Copy to clipboard',\n isDisabled,\n size,\n },\n type: 'icon-button' as const,\n }\n : {\n cleanIconButtonProps: {\n description: 'Copy to clipboard',\n isDisabled,\n size,\n },\n type: 'clean-icon-button' as const,\n };\n\n return (\n <ConfirmationButton\n onClick={() => copyFunction(textToCopy)}\n description=\"Copy to clipboard\"\n actionFeedbackText=\"Copied\"\n descriptionKbdProps={descriptionKbdProps}\n {...props}\n tooltipProps={tooltipProps}\n icon={<Square2StackIconOutline className=\"ndl-icon-svg\" />}\n htmlAttributes={{\n 'aria-live': 'polite',\n ...htmlAttributes,\n }}\n >\n {type === 'outlined-button' && 'Copy'}\n </ConfirmationButton>\n );\n};\n"]}
|
|
@@ -64,11 +64,7 @@ const DropzoneComponent = (_a) => {
|
|
|
64
64
|
var _a;
|
|
65
65
|
if (acceptedFileExtensions && acceptedFileExtensions.length > 0) {
|
|
66
66
|
for (const file of acceptedFiles) {
|
|
67
|
-
const isAccepted = acceptedFileExtensions.some((extension) =>
|
|
68
|
-
if (file.name.endsWith(extension)) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
67
|
+
const isAccepted = acceptedFileExtensions.some((extension) => file.name.endsWith(extension));
|
|
72
68
|
if (!isAccepted) {
|
|
73
69
|
setIsRejected(true);
|
|
74
70
|
return;
|
|
@@ -103,7 +99,7 @@ const DropzoneComponent = (_a) => {
|
|
|
103
99
|
setIsRejected(false);
|
|
104
100
|
}
|
|
105
101
|
}, [isDragActive, isRejected]);
|
|
106
|
-
return (_jsxs(_Fragment, { children: [isRejected && (_jsxs(Banner, { className: "ndl-dropzone-error-alert", variant: "danger", children: [_jsx(Banner.Header, { children: "Error" }), _jsx(Banner.Description, { children:
|
|
102
|
+
return (_jsxs(_Fragment, { children: [isRejected && (_jsxs(Banner, { className: "ndl-dropzone-error-alert", variant: "danger", children: [_jsx(Banner.Header, { children: "Error" }), _jsx(Banner.Description, { children: rejectedText !== null && rejectedText !== void 0 ? rejectedText : 'File extension not supported.' })] })), _jsx("div", Object.assign({ ref: mergedRef, className: wrapperClasses, style: style }, restProps, htmlAttributes, { children: _jsxs("div", Object.assign({ className: "ndl-dropzone-inner-wrapper" }, getRootProps(), { children: [_jsx("input", Object.assign({ "aria-label": "Drag and drop area" }, getInputProps())), _jsxs("div", { className: "ndl-dropzone-inner", children: [width !== undefined && width > 230 && (_jsx(_Fragment, { children: isDragActive && !isSafari ? (computedFileImage) : (_jsx(DocumentArrowUpIconOutline, { className: "ndl-dropzone-upload-icon" })) })), !isUploading && (_jsxs("div", { className: "ndl-dnd-title-container", children: [_jsx(Typography, { variant: "subheading-medium", children: titleText ||
|
|
107
103
|
(heading !== null && heading !== void 0 ? heading : (_jsxs(_Fragment, { children: ["Drag ", _jsx("span", { className: "ndl-dnd-title-ampersand", children: "&" }), ' ', "Drop"] }))) }), !isDragReject && (_jsxs("div", { className: "ndl-dnd-subtitle", children: [_jsx(Typography, { variant: "body-medium", children: "or" }), ' ', _jsx("button", { className: "ndl-dnd-browse-link", onClick: () => open(), disabled: isDisabled, type: "button", children: "Browse" })] }))] })), _jsxs("div", { className: "ndl-dropzone-footer", children: [isUploading && _jsx(_Fragment, { children: loadingElement }), !isUploading && (_jsx("div", { className: "ndl-file-support-text", children: supportedFilesDescription }))] })] })] })) }))] }));
|
|
108
104
|
};
|
|
109
105
|
const DropzoneLoadingProgressBarComponent = (_a) => {
|
|
@@ -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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AAC,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 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,+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* 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/switch/Switch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/switch/Switch.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAuC9E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAiBa,EAAE,EAAE;;QAjBjB,E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AE,cAAc,EACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,IACpB,SAAS,EACT,cAAc,EAClB,EACD,OAAO,CAAC,eAAe,CAAC,KAAK,KAAK,IAAI,YAAY,IAC7C,CACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { useEffect, useRef } from 'react';\n\nimport { useInlineFieldLabel } from '../_common/form-control';\nimport { type CommonProps, type HtmlAttributes } from '../_common/types';\nimport { useSemiControlledInput } from '../_common/use-semi-controlled-input';\n\ntype SwitchProps = {\n /** Whether the switch is checked */\n isChecked?: boolean;\n /** Checks the input by default in uncontrolled mode */\n isDefaultChecked?: boolean; // isDefaultChecked sounds weird to me?\n /** Whether the switch is indeterminate */\n isIndeterminate?: boolean;\n /** Whether the switch is disabled */\n isDisabled?: boolean;\n /** Whether the switch & label should take the full available width of its container */\n isFluid?: boolean;\n /** The value of the switch */\n value?: HtmlAttributes<'input'>['value']; // should this be required?\n /** Whether the label should be displayed before the switch */\n hasLeadingLabel?: boolean;\n /** The callback function triggered when the switch value changes */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n /** The callback function triggered when the switch is clicked */\n onClick?: (event: React.MouseEvent<HTMLInputElement>) => void;\n} & (\n | {\n /** The aria label of the switch. Required if the label is not a string. */\n ariaLabel: string;\n // TODO v5: inconsistent naming. Naming the switch takes a union of\n // `label` and `ariaLabel`, so the accessible name comes from a different\n // prop depending on what the label renders. Combobox instead requires the\n // label and clips it with `hasVisuallyHiddenLabel`, and TextInput reaches\n // for htmlAttributes['aria-label'].\n /** The label of the switch. If not a string, supply an aria label for screen reader support. */\n label?: undefined;\n }\n | {\n ariaLabel?: string;\n label: React.ReactNode;\n }\n);\n\nexport const Switch = ({\n isChecked,\n isDefaultChecked,\n isIndeterminate = false,\n isFluid = false,\n isDisabled = false,\n hasLeadingLabel,\n ariaLabel,\n onChange,\n onClick,\n value,\n label,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'input', SwitchProps>) => {\n const internalRef = useRef<HTMLInputElement>(null);\n const mergedRefs = useMergeRefs([internalRef, ref]);\n\n const [isCheckedState, internalOnChange] = useSemiControlledInput({\n inputType: 'switch',\n isControlled: isChecked !== undefined,\n onChange,\n state: isChecked ?? isDefaultChecked ?? false,\n });\n\n const switchClasses = classNames('ndl-switch', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-indeterminate': isIndeterminate,\n });\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.indeterminate = isIndeterminate;\n }\n }, [isIndeterminate]);\n\n const { labelContent, fieldClassName } = useInlineFieldLabel({\n ariaLabel,\n componentName: 'Switch',\n isDisabled,\n isFluid,\n label,\n });\n\n return (\n <label className={fieldClassName}>\n {hasLeadingLabel === true && labelContent}\n <input\n ref={mergedRefs}\n type=\"checkbox\"\n role=\"switch\"\n aria-label={ariaLabel}\n disabled={isDisabled}\n checked={isCheckedState}\n onClick={onClick}\n onChange={internalOnChange}\n value={value}\n style={style}\n className={switchClasses}\n {...restProps}\n {...htmlAttributes}\n />\n {Boolean(hasLeadingLabel) === false && labelContent}\n </label>\n );\n};\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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B [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,0BA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,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":"button-disabled.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-disabled.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+
|
|
1
|
+
{"version":3,"file":"button-disabled.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-disabled.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+CAQd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-floating.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-floating.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+
|
|
1
|
+
{"version":3,"file":"button-floating.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-floating.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+CAOd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-fluid.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-fluid.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+
|
|
1
|
+
{"version":3,"file":"button-fluid.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-fluid.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+CAQd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-loading.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-loading.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+
|
|
1
|
+
{"version":3,"file":"button-loading.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-loading.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+CA8Bd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-running-cancel.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-running-cancel.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAKjD,QAAA,MAAM,SAAS,+
|
|
1
|
+
{"version":3,"file":"button-running-cancel.story.d.ts","sourceRoot":"","sources":["../../../../src/button/stories/button-running-cancel.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAKjD,QAAA,MAAM,SAAS,+CAoEd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|