diff --git a/package-lock.json b/package-lock.json index 216dbcb54d..eb2634966f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,8 +8,11 @@ "name": "@cloudscape-design/components", "version": "3.0.0", "dependencies": { + "@cloudscape-design/chat-components": "^1.0.0", + "@cloudscape-design/code-view": "^3.0.0", "@cloudscape-design/collection-hooks": "^1.0.0", "@cloudscape-design/component-toolkit": "^1.0.0-beta", + "@cloudscape-design/design-tokens": "^3.0.0", "@cloudscape-design/test-utils-core": "^1.0.0", "@cloudscape-design/theming-runtime": "^1.0.0", "@dnd-kit/core": "^6.0.8", @@ -4622,6 +4625,15 @@ "version": "1.42.0", "license": "BSD-3-Clause" }, + "node_modules/ace-code": { + "version": "1.43.2", + "resolved": "https://amazon-149122183214.d.codeartifact.us-west-2.amazonaws.com/npm/shared/ace-code/-/ace-code-1.43.2.tgz", + "integrity": "sha512-GJnT2CjEJ45Hu4ydAmaRXDRtaujcZTAA0rWW6m2sSpcdGRquaIxLcZwQq/xJ35Mz9gD0+wZbj9jZB0wJPAZJDw==", + "license": "BSD-3-Clause", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/acorn": { "version": "8.15.0", "dev": true, diff --git a/package.json b/package.json index 2e75b7eebb..614cfc260a 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,9 @@ "@cloudscape-design/component-toolkit": "^1.0.0-beta", "@cloudscape-design/test-utils-core": "^1.0.0", "@cloudscape-design/theming-runtime": "^1.0.0", + "@cloudscape-design/chat-components": "^1.0.0", + "@cloudscape-design/code-view": "^3.0.0", + "@cloudscape-design/design-tokens": "^3.0.0", "@dnd-kit/core": "^6.0.8", "@dnd-kit/sortable": "^7.0.2", "@dnd-kit/utilities": "^3.2.1", @@ -167,7 +170,7 @@ { "path": "lib/components/internal/widget-exports.js", "brotli": false, - "limit": "800 kB", + "limit": "801 kB", "ignore": "react-dom" } ], diff --git a/pages/app-layout/chat/additional-info/dialog.tsx b/pages/app-layout/chat/additional-info/dialog.tsx new file mode 100644 index 0000000000..a827d2ca2b --- /dev/null +++ b/pages/app-layout/chat/additional-info/dialog.tsx @@ -0,0 +1,55 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import React from 'react'; + +import Button from '~components/button'; + +import '../dialog.scss'; + +const Dialog = React.forwardRef( + ( + { + children, + footer, + onDismiss, + ariaLabel, + }: { + children: React.ReactNode; + footer: React.ReactNode; + onDismiss: () => void; + ariaLabel: string; + }, + ref: React.Ref + ) => { + return ( +
+
+
+
+ +
{children}
+
+ +
{footer}
+
+ ); + } +); + +Dialog.displayName = 'Dialog'; + +export default Dialog; diff --git a/pages/app-layout/chat/additional-info/feedback-dialog.tsx b/pages/app-layout/chat/additional-info/feedback-dialog.tsx new file mode 100644 index 0000000000..e8beded947 --- /dev/null +++ b/pages/app-layout/chat/additional-info/feedback-dialog.tsx @@ -0,0 +1,125 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import React, { useEffect, useRef } from 'react'; + +import Box from '~components/box'; +import Button from '~components/button'; +import Checkbox from '~components/checkbox'; +import Form from '~components/form'; +import FormField from '~components/form-field'; +import SpaceBetween from '~components/space-between'; +import Textarea from '~components/textarea'; + +import Dialog from './dialog'; + +export default function FeedbackDialog({ onDismiss, onSubmit }: { onDismiss: () => void; onSubmit: () => void }) { + const [feedbackOptions, setFeedbackOptions] = React.useState({ + harmful: false, + incomplete: false, + inaccurate: false, + other: false, + }); + const [feedbackText, setFeedbackText] = React.useState(''); + const dialogRef = useRef(null); + const triggerRef = useRef(null); + + useEffect(() => { + // Store the element that had focus before dialog opened + triggerRef.current = document.activeElement as HTMLElement; + + // Focus the dialog container when it opens + dialogRef.current?.focus(); + + // Cleanup: Return focus to the trigger element when dialog closes + return () => { + triggerRef.current?.focus(); + }; + }, [dialogRef]); + + const selectOption = (option: string, checked: boolean) => + setFeedbackOptions({ ...feedbackOptions, [option]: checked }); + + const isFeedbackOptionSelected = Object.values(feedbackOptions).some(val => !!val); + const isSubmittable = isFeedbackOptionSelected || feedbackText.length > 0; + + const submitFeedback = () => { + if (!isSubmittable) { + return; + } + + onSubmit(); + }; + + return ( + + + + + + } + > +
+ Tell us more - optional + + } + > + + + + selectOption('harmful', detail.checked)} + > + Harmful + + selectOption('incomplete', detail.checked)} + > + Incomplete + + selectOption('inaccurate', detail.checked)} + > + Inaccurate + + selectOption('other', detail.checked)} + > + Other + + + + + +