diff --git a/packages/components/help-button/help-button.stories.tsx b/packages/components/help-button/help-button.stories.tsx deleted file mode 100644 index c84f89774e..0000000000 --- a/packages/components/help-button/help-button.stories.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import React from "react"; - -import Text from "../text"; -import Link from "../link"; -import HelpButton from "."; - -export default { - title: "Components/HelpButton", - component: HelpButton, - subcomponents: { Text, Link }, - argTypes: {}, - parameters: { - docs: { - description: { - component: "HelpButton is used for a action on a page", - }, - }, - }, -}; - -const Template = (args: any) => { - return ( -
- -
- ); -}; - -export const Default = Template.bind({}); -// @ts-expect-error TS(2339): Property 'args' does not exist on type '(args: any... Remove this comment to see the full error message -Default.args = { - offsetTop: 0, - offsetRight: 0, - offsetBottom: 0, - offsetLeft: 0, - // @ts-expect-error TS(2322): Type '{ children: string; fontSize: string; }' is ... Remove this comment to see the full error message - tooltipContent: Paste you tooltip content here, - place: "right", -}; - -const AutoTemplate = (args: any) => { - return ( -
- -

You can put every thing here

- - - } - {...args} - /> -
- ); -}; - -export const AutoPosition = AutoTemplate.bind({}); -// @ts-expect-error TS(2339): Property 'args' does not exist on type '(args: any... Remove this comment to see the full error message -AutoPosition.args = { - offsetTop: 0, - offsetRight: 0, - offsetBottom: 0, - offsetLeft: 0, -}; diff --git a/packages/components/help-button/help-button.test.tsx b/packages/components/help-button/help-button.test.tsx deleted file mode 100644 index 35ff99b471..0000000000 --- a/packages/components/help-button/help-button.test.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import React from "react"; -// @ts-expect-error TS(7016): Could not find a declaration file for module 'enzy... Remove this comment to see the full error message -import { mount, shallow } from "enzyme"; -import HelpButton from "."; - -const tooltipContent = "You tooltip content"; -// @ts-expect-error TS(2582): Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message -describe("", () => { - // @ts-expect-error TS(2582): Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message - it("HelpButton renders without error", () => { - // @ts-expect-error TS(2322): Type '{ tooltipContent: string; }' is not assignab... Remove this comment to see the full error message - const wrapper = mount(); - // @ts-expect-error TS(2304): Cannot find name 'expect'. - expect(wrapper).toExist(); - }); - - // @ts-expect-error TS(2582): Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message - it("HelpButton componentWillUnmount test", () => { - // @ts-expect-error TS(2322): Type '{ tooltipContent: string; }' is not assignab... Remove this comment to see the full error message - const wrapper = mount(); - // @ts-expect-error TS(2708): Cannot use namespace 'jest' as a value. - const componentWillUnmount = jest.spyOn( - wrapper.instance(), - "componentWillUnmount" - ); - wrapper.unmount(); - // @ts-expect-error TS(2304): Cannot find name 'expect'. - expect(componentWillUnmount).toHaveBeenCalled(); - }); - - // @ts-expect-error TS(2582): Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message - it("HelpButton test afterHide function", () => { - const wrapper = shallow( - // @ts-expect-error TS(2322): Type '{ tooltipContent: string; }' is not assignab... Remove this comment to see the full error message - - ).instance(); - wrapper.afterHide(); - // @ts-expect-error TS(2304): Cannot find name 'expect'. - expect(wrapper.state.hideTooltip).toEqual(false); - - wrapper.setState({ hideTooltip: false }); - wrapper.afterHide(); - // @ts-expect-error TS(2304): Cannot find name 'expect'. - expect(wrapper.state.hideTooltip).toEqual(false); - }); - - // @ts-expect-error TS(2582): Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message - it("accepts id", () => { - const wrapper = mount( - // @ts-expect-error TS(2322): Type '{ tooltipContent: string; id: string; }' is ... Remove this comment to see the full error message - - ); - - // @ts-expect-error TS(2304): Cannot find name 'expect'. - expect(wrapper.prop("id")).toEqual("testId"); - }); - - // @ts-expect-error TS(2582): Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message - it("accepts className", () => { - const wrapper = mount( - // @ts-expect-error TS(2322): Type '{ tooltipContent: string; className: string;... Remove this comment to see the full error message - - ); - - // @ts-expect-error TS(2304): Cannot find name 'expect'. - expect(wrapper.prop("className")).toEqual("test"); - }); - - // @ts-expect-error TS(2582): Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message - it("accepts style", () => { - const wrapper = mount( - // @ts-expect-error TS(2322): Type '{ tooltipContent: string; style: { color: st... Remove this comment to see the full error message - - ); - - // @ts-expect-error TS(2304): Cannot find name 'expect'. - expect(wrapper.getDOMNode().style).toHaveProperty("color", "red"); - }); -}); diff --git a/packages/components/help-button/index.tsx b/packages/components/help-button/index.tsx deleted file mode 100644 index dc08e13c24..0000000000 --- a/packages/components/help-button/index.tsx +++ /dev/null @@ -1,143 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import IconButton from "../icon-button"; -import Tooltip from "../tooltip"; -import uniqueId from "lodash/uniqueId"; -import { classNames } from "../utils/classNames"; - -// @ts-expect-error TS(2307): Cannot find module 'PUBLIC_DIR/images/info.react.s... Remove this comment to see the full error message -import InfoReactSvgUrl from "PUBLIC_DIR/images/info.react.svg?url"; - -class HelpButton extends React.Component { - id: any; - ref: any; - constructor(props: any) { - super(props); - - // @ts-expect-error TS(2339): Property 'id' does not exist on type 'Readonly<{}>... Remove this comment to see the full error message - this.id = this.props.id || uniqueId(); - } - - render() { - const { - // @ts-expect-error TS(2339): Property 'tooltipContent' does not exist on type '... Remove this comment to see the full error message - tooltipContent, - // @ts-expect-error TS(2339): Property 'place' does not exist on type 'Readonly<... Remove this comment to see the full error message - place, - // @ts-expect-error TS(2339): Property 'offset' does not exist on type 'Readonly... Remove this comment to see the full error message - offset, - // @ts-expect-error TS(2339): Property 'iconName' does not exist on type 'Readon... Remove this comment to see the full error message - iconName, - // @ts-expect-error TS(2339): Property 'color' does not exist on type 'Readonly<... Remove this comment to see the full error message - color, - // @ts-expect-error TS(2339): Property 'getContent' does not exist on type 'Read... Remove this comment to see the full error message - getContent, - // @ts-expect-error TS(2339): Property 'className' does not exist on type 'Reado... Remove this comment to see the full error message - className, - // @ts-expect-error TS(2339): Property 'dataTip' does not exist on type 'Readonl... Remove this comment to see the full error message - dataTip, - // @ts-expect-error TS(2339): Property 'tooltipMaxWidth' does not exist on type ... Remove this comment to see the full error message - tooltipMaxWidth, - // @ts-expect-error TS(2339): Property 'style' does not exist on type 'Readonly<... Remove this comment to see the full error message - style, - // @ts-expect-error TS(2339): Property 'size' does not exist on type 'Readonly<{... Remove this comment to see the full error message - size, - // @ts-expect-error TS(2339): Property 'afterShow' does not exist on type 'Reado... Remove this comment to see the full error message - afterShow, - // @ts-expect-error TS(2339): Property 'afterHide' does not exist on type 'Reado... Remove this comment to see the full error message - afterHide, - } = this.props; - - const anchorSelect = `div[id='${this.id}'] svg`; - - return ( -
- - - {getContent ? ( - - ) : ( - - {tooltipContent} - - )} -
- ); - } -} - -// @ts-expect-error TS(2339): Property 'propTypes' does not exist on type 'typeo... Remove this comment to see the full error message -HelpButton.propTypes = { - /** Displays the child elements */ - children: PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.node), - PropTypes.node, - ]), - /** Sets the tooltip content */ - tooltipContent: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), - /** Required to set additional properties of the tooltip */ - tooltipProps: PropTypes.object, - /** Sets the maximum width of the tooltip */ - tooltipMaxWidth: PropTypes.string, - /** Sets the tooltip id */ - tooltipId: PropTypes.string, - /** Global tooltip placement */ - place: PropTypes.string, - /** Specifies the icon name */ - iconName: PropTypes.string, - /** Icon color */ - color: PropTypes.string, - /** The data-* attribute is used to store custom data private to the page or application. Required to display a tip over the hovered element */ - dataTip: PropTypes.string, - /** Sets a callback function that generates the tip content dynamically */ - getContent: PropTypes.func, - /** Accepts class */ - className: PropTypes.string, - /** Accepts id */ - id: PropTypes.string, - /** Accepts css style */ - style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]), - /** Button height and width value */ - size: PropTypes.number, -}; - -// @ts-expect-error TS(2339): Property 'defaultProps' does not exist on type 'ty... Remove this comment to see the full error message -HelpButton.defaultProps = { - iconName: InfoReactSvgUrl, - place: "top", - className: "icon-button", - size: 12, -}; - -export default HelpButton; diff --git a/packages/shared/components/help-button/HelpButton.stories.tsx b/packages/shared/components/help-button/HelpButton.stories.tsx new file mode 100644 index 0000000000..d40ebc7ca7 --- /dev/null +++ b/packages/shared/components/help-button/HelpButton.stories.tsx @@ -0,0 +1,72 @@ +import React from "react"; +import { Meta, StoryObj } from "@storybook/react"; + +import { Text } from "../text"; +// import { Link } from "../link"; + +import { HelpButton } from "./HelpButton"; +import { HelpButtonProps } from "./HelpButton.types"; + +const meta = { + title: "Components/HelpButton", + component: HelpButton, + // subcomponents: { Text, Link }, + argTypes: {}, + parameters: { + docs: { + description: { + component: "HelpButton is used for a action on a page", + }, + }, + }, +} satisfies Meta; +type Story = StoryObj; + +export default meta; + +const Template = (args: HelpButtonProps) => { + return ( +
+ +
+ ); +}; + +export const Default: Story = { + render: (args) =>