From 011afc8f5deb26240129635819b4c636ec39c9aa Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Fri, 20 Dec 2024 07:55:27 +0100 Subject: [PATCH] Remove unused components --- .../src/components/expandable-text-field.tsx | 80 ----------------- .../mui-extras/tooltipped-button.tsx | 87 ------------------- 2 files changed, 167 deletions(-) delete mode 100644 packages/jupyter-ai/src/components/expandable-text-field.tsx delete mode 100644 packages/jupyter-ai/src/components/mui-extras/tooltipped-button.tsx diff --git a/packages/jupyter-ai/src/components/expandable-text-field.tsx b/packages/jupyter-ai/src/components/expandable-text-field.tsx deleted file mode 100644 index 5e05511ef..000000000 --- a/packages/jupyter-ai/src/components/expandable-text-field.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import React, { useEffect, useRef, useState } from 'react'; - -export interface IExpandableTextFieldProps { - label: string; - collapsedTextMaxLength?: number; - id?: string; - text?: string; - style?: React.CSSProperties; - InputProps?: { - startAdornment: JSX.Element; - }; - helperText?: string; - name?: string; -} - -export function ExpandableTextField( - props: IExpandableTextFieldProps -): JSX.Element { - const [expanded, setExpanded] = useState(false); - const [overflowing, setOverflowing] = useState(false); - const { label, style, helperText, InputProps } = props; - const textContainerRef = useRef(null); - - useEffect(() => { - setExpanded(false); - const el = textContainerRef.current; - if (el?.offsetWidth && el?.scrollWidth) { - setOverflowing(el.offsetWidth < el.scrollWidth); - } - }, [props.text]); - - return ( -
- {label} -
-
- {InputProps?.startAdornment} - - {props.text ? props.text : !InputProps?.startAdornment && '\u2014'} - -
- {overflowing && ( -
setExpanded(!expanded)} - className="jp-ai-ExpandableTextField-value" - > - {expanded ? 'Show Less' : 'Show More'} -
- )} - - {helperText} - -
-
- ); -} diff --git a/packages/jupyter-ai/src/components/mui-extras/tooltipped-button.tsx b/packages/jupyter-ai/src/components/mui-extras/tooltipped-button.tsx deleted file mode 100644 index 363a4e832..000000000 --- a/packages/jupyter-ai/src/components/mui-extras/tooltipped-button.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import React from 'react'; -import { Button, ButtonProps, SxProps, TooltipProps } from '@mui/material'; - -import { ContrastingTooltip } from './contrasting-tooltip'; - -export type TooltippedButtonProps = { - onClick: React.MouseEventHandler; - tooltip: string; - children: JSX.Element; - disabled?: boolean; - placement?: TooltipProps['placement']; - /** - * The offset of the tooltip popup. - * - * The expected syntax is defined by the Popper library: - * https://popper.js.org/docs/v2/modifiers/offset/ - */ - offset?: [number, number]; - 'aria-label'?: string; - /** - * Props passed directly to the MUI `Button` component. - */ - buttonProps?: ButtonProps; - /** - * Styles applied to the MUI `Button` component. - */ - sx?: SxProps; -}; - -/** - * A component that renders an MUI `Button` with a high-contrast tooltip - * provided by `ContrastingTooltip`. This component differs from the MUI - * defaults in the following ways: - * - * - Shows the tooltip on hover even if disabled. - * - Renders the tooltip above the button by default. - * - Renders the tooltip closer to the button by default. - * - Lowers the opacity of the Button when disabled. - * - Renders the Button with `line-height: 0` to avoid showing extra - * vertical space in SVG icons. - * - * NOTE TO DEVS: Please keep this component's features synchronized with - * features available to `TooltippedIconButton`. - */ -export function TooltippedButton(props: TooltippedButtonProps): JSX.Element { - return ( - - {/* - By default, tooltips never appear when the Button is disabled. The - official way to support this feature in MUI is to wrap the child Button - element in a `span` element. - - See: https://mui.com/material-ui/react-tooltip/#disabled-elements - */} - - - - - ); -}