diff --git a/packages/ui-client/.babelrc.json b/packages/ui-client/.babelrc.json deleted file mode 100644 index f474986efbca9..0000000000000 --- a/packages/ui-client/.babelrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "presets": [ - "@babel/preset-env", - ["@babel/preset-react", { - "runtime": "automatic" - }], - "@babel/preset-typescript" - ] -} diff --git a/packages/ui-client/.eslintignore b/packages/ui-client/.eslintignore deleted file mode 100644 index 608841ff3853c..0000000000000 --- a/packages/ui-client/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -!.storybook diff --git a/packages/ui-client/.eslintrc.json b/packages/ui-client/.eslintrc.json index d5db8560f3e86..6e0406abd46a7 100644 --- a/packages/ui-client/.eslintrc.json +++ b/packages/ui-client/.eslintrc.json @@ -1,65 +1,4 @@ { - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/eslint-recommended", - "@rocket.chat/eslint-config/original", - "@rocket.chat/eslint-config/react", - "prettier", - "plugin:anti-trojan-source/recommended", - "plugin:react/jsx-runtime", - "plugin:storybook/recommended" - ], - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "prettier"], - "rules": { - "func-call-spacing": "off", - "import/named": "error", - "import/order": [ - "error", - { - "newlines-between": "always", - "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]], - "alphabetize": { - "order": "asc" - } - } - ], - "indent": "off", - "jsx-quotes": ["error", "prefer-single"], - "new-cap": ["error"], - "no-extra-parens": "off", - "no-spaced-func": "off", - "no-undef": "off", - "no-unused-vars": "off", - "no-useless-constructor": "off", - "no-use-before-define": "off", - "prefer-arrow-callback": ["error", { "allowNamedFunctions": true }], - "prettier/prettier": 2 - }, - "settings": { - "import/resolver": { - "node": { - "extensions": [".js", ".ts", ".tsx"] - } - } - }, - "ignorePatterns": ["**/dist"], - "overrides": [ - { - "files": ["*.ts", "*.tsx"], - "rules": { - "@typescript-eslint/ban-ts-ignore": "off", - "@typescript-eslint/indent": "off", - "@typescript-eslint/no-extra-parens": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_" - } - ], - "@typescript-eslint/prefer-optional-chain": "warn" - } - } - ] + "extends": ["@rocket.chat/eslint-config", "@rocket.chat/eslint-config/react", "plugin:storybook/recommended"], + "ignorePatterns": ["dist", "storybook-static", "!.storybook"] } diff --git a/packages/ui-client/package.json b/packages/ui-client/package.json index 1da04ff1f3c77..9cd3f1cb1e484 100644 --- a/packages/ui-client/package.json +++ b/packages/ui-client/package.json @@ -17,8 +17,10 @@ "testunit": "jest", "typecheck": "tsc --noEmit" }, + "dependencies": { + "dompurify": "~3.2.7" + }, "devDependencies": { - "@babel/core": "~7.28.5", "@react-aria/toolbar": "^3.0.0-nightly.5042", "@rocket.chat/core-typings": "workspace:~", "@rocket.chat/css-in-js": "~0.31.25", @@ -68,8 +70,5 @@ }, "volta": { "extends": "../../package.json" - }, - "dependencies": { - "dompurify": "~3.2.7" } } diff --git a/packages/ui-client/src/components/AnchorPortal.tsx b/packages/ui-client/src/components/AnchorPortal.tsx index c0d01122c2cf8..83a4bd2a46162 100644 --- a/packages/ui-client/src/components/AnchorPortal.tsx +++ b/packages/ui-client/src/components/AnchorPortal.tsx @@ -1,4 +1,5 @@ -import { ReactNode, useLayoutEffect } from 'react'; +import type { ReactNode } from 'react'; +import { useLayoutEffect } from 'react'; import { createPortal } from 'react-dom'; import { ensureAnchorElement, refAnchorElement, unrefAnchorElement } from '../helpers/anchors'; diff --git a/packages/ui-client/src/components/AnnouncementBanner/AnnouncementBanner.stories.tsx b/packages/ui-client/src/components/AnnouncementBanner/AnnouncementBanner.stories.tsx index 165c0154d3361..4459c7d419c25 100644 --- a/packages/ui-client/src/components/AnnouncementBanner/AnnouncementBanner.stories.tsx +++ b/packages/ui-client/src/components/AnnouncementBanner/AnnouncementBanner.stories.tsx @@ -1,5 +1,5 @@ import { action } from '@storybook/addon-actions'; -import { Meta, StoryFn } from '@storybook/react'; +import type { Meta, StoryFn } from '@storybook/react'; import AnnouncementBanner from './AnnouncementBanner'; diff --git a/packages/ui-client/src/components/DotLeader.stories.tsx b/packages/ui-client/src/components/DotLeader.stories.tsx index 658ffc8131527..5bac732351f56 100644 --- a/packages/ui-client/src/components/DotLeader.stories.tsx +++ b/packages/ui-client/src/components/DotLeader.stories.tsx @@ -1,7 +1,7 @@ import { Box } from '@rocket.chat/fuselage'; import type { Meta, StoryFn } from '@storybook/react'; -import { DotLeader } from './DotLeader'; +import DotLeader from './DotLeader'; export default { title: 'Components/DotLeader', diff --git a/packages/ui-client/src/components/DotLeader.tsx b/packages/ui-client/src/components/DotLeader.tsx index 8340ba22d65e1..5a9b1db5fb568 100644 --- a/packages/ui-client/src/components/DotLeader.tsx +++ b/packages/ui-client/src/components/DotLeader.tsx @@ -1,11 +1,13 @@ import { Box } from '@rocket.chat/fuselage'; -import type { FC, CSSProperties } from 'react'; +import type { CSSProperties } from 'react'; -type DotLeaderProps = { +export type DotLeaderProps = { color?: CSSProperties['borderColor']; dotSize?: CSSProperties['borderBlockEndWidth']; }; -export const DotLeader: FC = ({ color = 'neutral-300', dotSize = 'x2' }) => ( +const DotLeader = ({ color = 'neutral-300', dotSize = 'x2' }: DotLeaderProps) => ( ); + +export default DotLeader; diff --git a/packages/ui-client/src/components/EmojiPicker/EmojiPickerCategoryHeader.tsx b/packages/ui-client/src/components/EmojiPicker/EmojiPickerCategoryHeader.tsx index 509af85c68fe0..2a85ad0ba1e87 100644 --- a/packages/ui-client/src/components/EmojiPicker/EmojiPickerCategoryHeader.tsx +++ b/packages/ui-client/src/components/EmojiPicker/EmojiPickerCategoryHeader.tsx @@ -1,7 +1,9 @@ import { ButtonGroup, Box } from '@rocket.chat/fuselage'; -import type { ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const EmojiPickerCategoryHeader = (props: ComponentProps) => ( +export type EmojiPickerCategoryHeaderProps = ComponentPropsWithoutRef; + +const EmojiPickerCategoryHeader = (props: EmojiPickerCategoryHeaderProps) => ( diff --git a/packages/ui-client/src/components/EmojiPicker/EmojiPickerCategoryWrapper.tsx b/packages/ui-client/src/components/EmojiPicker/EmojiPickerCategoryWrapper.tsx index 306fc7203bffb..6093f6ea7e0ec 100644 --- a/packages/ui-client/src/components/EmojiPicker/EmojiPickerCategoryWrapper.tsx +++ b/packages/ui-client/src/components/EmojiPicker/EmojiPickerCategoryWrapper.tsx @@ -1,6 +1,8 @@ import { Box } from '@rocket.chat/fuselage'; -import type { ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const EmojiPickerCategoryWrapper = (props: ComponentProps) => ; +export type EmojiPickerCategoryWrapperProps = ComponentPropsWithoutRef; + +const EmojiPickerCategoryWrapper = (props: EmojiPickerCategoryWrapperProps) => ; export default EmojiPickerCategoryWrapper; diff --git a/packages/ui-client/src/components/ExternalLink.tsx b/packages/ui-client/src/components/ExternalLink.tsx index 0e7ef7a56148b..65eb688085b15 100644 --- a/packages/ui-client/src/components/ExternalLink.tsx +++ b/packages/ui-client/src/components/ExternalLink.tsx @@ -1,11 +1,11 @@ import { Box } from '@rocket.chat/fuselage'; -import type { ComponentProps, FC } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; type ExternalLinkProps = { to: string; -} & ComponentProps; +} & ComponentPropsWithoutRef; -export const ExternalLink: FC = ({ children, to, ...props }) => ( +export const ExternalLink = ({ children, to, ...props }: ExternalLinkProps) => ( {children || to} diff --git a/packages/ui-client/src/components/FeaturePreview/FeaturePreview.spec.tsx b/packages/ui-client/src/components/FeaturePreview/FeaturePreview.spec.tsx index 615887e10402c..14a8eb4dfdccb 100644 --- a/packages/ui-client/src/components/FeaturePreview/FeaturePreview.spec.tsx +++ b/packages/ui-client/src/components/FeaturePreview/FeaturePreview.spec.tsx @@ -1,7 +1,9 @@ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { render, screen } from '@testing-library/react'; -import { FeaturePreview, FeaturePreviewOff, FeaturePreviewOn } from './FeaturePreview'; +import FeaturePreview from './FeaturePreview'; +import FeaturePreviewOff from './FeaturePreviewOff'; +import FeaturePreviewOn from './FeaturePreviewOn'; test('should renders off if the feature is disabled', async () => { render( diff --git a/packages/ui-client/src/components/FeaturePreview/FeaturePreview.tsx b/packages/ui-client/src/components/FeaturePreview/FeaturePreview.tsx index 1f537ef9d3897..1d40e89a07854 100644 --- a/packages/ui-client/src/components/FeaturePreview/FeaturePreview.tsx +++ b/packages/ui-client/src/components/FeaturePreview/FeaturePreview.tsx @@ -1,19 +1,16 @@ -/* eslint-disable react/no-multi-comp */ -import type { ReactElement, ReactNode } from 'react'; +import type { ReactElement } from 'react'; import { Children, Suspense, cloneElement } from 'react'; import { useFeaturePreview } from '../../hooks/useFeaturePreview'; -import { FeaturesAvailable } from '../../hooks/useFeaturePreviewList'; +import type { FeaturesAvailable } from '../../hooks/useFeaturePreviewList'; -export const FeaturePreview = ({ - feature, - disabled = false, - children, -}: { - disabled?: boolean; +export type FeaturePreviewProps = { feature: FeaturesAvailable; + disabled?: boolean; children: ReactElement<{ featureToggleEnabled?: boolean }>[]; -}) => { +}; + +const FeaturePreview = ({ feature, disabled = false, children }: FeaturePreviewProps) => { const featureToggleEnabled = useFeaturePreview(feature) && !disabled; const toggledChildren = Children.map(children, (child) => @@ -25,10 +22,4 @@ export const FeaturePreview = ({ return {toggledChildren}; }; -export const FeaturePreviewOn = ({ children, featureToggleEnabled }: { children: ReactNode; featureToggleEnabled?: boolean }) => ( - <>{featureToggleEnabled && children} -); - -export const FeaturePreviewOff = ({ children, featureToggleEnabled }: { children: ReactNode; featureToggleEnabled?: boolean }) => ( - <>{!featureToggleEnabled && children} -); +export default FeaturePreview; diff --git a/packages/ui-client/src/components/FeaturePreview/FeaturePreviewOff.tsx b/packages/ui-client/src/components/FeaturePreview/FeaturePreviewOff.tsx new file mode 100644 index 0000000000000..3b7ac103b47fe --- /dev/null +++ b/packages/ui-client/src/components/FeaturePreview/FeaturePreviewOff.tsx @@ -0,0 +1,10 @@ +import type { ReactNode } from 'react'; + +export type FeaturePreviewOnProps = { + children: ReactNode; + featureToggleEnabled?: boolean; +}; + +const FeaturePreviewOff = ({ children, featureToggleEnabled }: FeaturePreviewOnProps) => <>{!featureToggleEnabled && children}; + +export default FeaturePreviewOff; diff --git a/packages/ui-client/src/components/FeaturePreview/FeaturePreviewOn.tsx b/packages/ui-client/src/components/FeaturePreview/FeaturePreviewOn.tsx new file mode 100644 index 0000000000000..a6fc6c3b284b9 --- /dev/null +++ b/packages/ui-client/src/components/FeaturePreview/FeaturePreviewOn.tsx @@ -0,0 +1,10 @@ +import type { ReactNode } from 'react'; + +export type FeaturePreviewOnProps = { + children: ReactNode; + featureToggleEnabled?: boolean; +}; + +const FeaturePreviewOn = ({ children, featureToggleEnabled }: FeaturePreviewOnProps) => <>{featureToggleEnabled && children}; + +export default FeaturePreviewOn; diff --git a/packages/ui-client/src/components/FeaturePreview/index.ts b/packages/ui-client/src/components/FeaturePreview/index.ts index f6b8e5f2071e7..9d23e58b4e050 100644 --- a/packages/ui-client/src/components/FeaturePreview/index.ts +++ b/packages/ui-client/src/components/FeaturePreview/index.ts @@ -1,2 +1,4 @@ -export { FeaturePreview, FeaturePreviewOn, FeaturePreviewOff } from './FeaturePreview'; +export { default as FeaturePreview } from './FeaturePreview'; export { default as FeaturePreviewBadge } from './FeaturePreviewBadge'; +export { default as FeaturePreviewOn } from './FeaturePreviewOn'; +export { default as FeaturePreviewOff } from './FeaturePreviewOff'; diff --git a/packages/ui-client/src/components/Header/Header.stories.tsx b/packages/ui-client/src/components/Header/Header.stories.tsx index cb3b006cc82bf..60bd3732722b3 100644 --- a/packages/ui-client/src/components/Header/Header.stories.tsx +++ b/packages/ui-client/src/components/Header/Header.stories.tsx @@ -3,7 +3,7 @@ import { Avatar, IconButton } from '@rocket.chat/fuselage'; import { SettingsContext } from '@rocket.chat/ui-contexts'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { ComponentType } from 'react'; +import type { ComponentType } from 'react'; import { Header, diff --git a/packages/ui-client/src/components/Header/Header.tsx b/packages/ui-client/src/components/Header/Header.tsx index c204b4d4bc0d9..df8026b356bba 100644 --- a/packages/ui-client/src/components/Header/Header.tsx +++ b/packages/ui-client/src/components/Header/Header.tsx @@ -1,10 +1,12 @@ import { Box } from '@rocket.chat/fuselage'; import { useLayout } from '@rocket.chat/ui-contexts'; -import type { FC, ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; import HeaderDivider from './HeaderDivider'; -const Header: FC> = (props) => { +export type HeaderProps = ComponentPropsWithoutRef; + +const Header = (props: HeaderProps) => { const { isMobile } = useLayout(); return ( diff --git a/packages/ui-client/src/components/Header/HeaderAvatar.tsx b/packages/ui-client/src/components/Header/HeaderAvatar.tsx index b650a1c898dad..c70660324fde1 100644 --- a/packages/ui-client/src/components/Header/HeaderAvatar.tsx +++ b/packages/ui-client/src/components/Header/HeaderAvatar.tsx @@ -1,6 +1,8 @@ import { Box } from '@rocket.chat/fuselage'; -import type { FC, ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const HeaderAvatar: FC> = (props) => ; +export type HeaderAvatarProps = ComponentPropsWithoutRef; + +const HeaderAvatar = (props: HeaderAvatarProps) => ; export default HeaderAvatar; diff --git a/packages/ui-client/src/components/Header/HeaderContent.tsx b/packages/ui-client/src/components/Header/HeaderContent.tsx index 2b3fe0e369cdc..bd94ade6999bf 100644 --- a/packages/ui-client/src/components/Header/HeaderContent.tsx +++ b/packages/ui-client/src/components/Header/HeaderContent.tsx @@ -1,7 +1,9 @@ import { Box } from '@rocket.chat/fuselage'; -import type { FC, ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const HeaderContent: FC> = (props) => ( +export type HeaderContentProps = ComponentPropsWithoutRef; + +const HeaderContent = (props: HeaderContentProps) => ( ); diff --git a/packages/ui-client/src/components/Header/HeaderContentRow.tsx b/packages/ui-client/src/components/Header/HeaderContentRow.tsx index 22f879f1e2c1e..1df01a9785e9a 100644 --- a/packages/ui-client/src/components/Header/HeaderContentRow.tsx +++ b/packages/ui-client/src/components/Header/HeaderContentRow.tsx @@ -1,7 +1,9 @@ import { Box } from '@rocket.chat/fuselage'; -import type { FC, ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const HeaderContentRow: FC> = (props) => ( +export type HeaderContentRowProps = ComponentPropsWithoutRef; + +const HeaderContentRow = (props: HeaderContentRowProps) => ( ); diff --git a/packages/ui-client/src/components/Header/HeaderDivider.tsx b/packages/ui-client/src/components/Header/HeaderDivider.tsx index e9932f44a6a8f..2beadec2d0882 100644 --- a/packages/ui-client/src/components/Header/HeaderDivider.tsx +++ b/packages/ui-client/src/components/Header/HeaderDivider.tsx @@ -1,6 +1,5 @@ import { Divider } from '@rocket.chat/fuselage'; -import type { FC } from 'react'; -const HeaderDivider: FC = () => ; +const HeaderDivider = () => ; export default HeaderDivider; diff --git a/packages/ui-client/src/components/Header/HeaderIcon.tsx b/packages/ui-client/src/components/Header/HeaderIcon.tsx index 82545aafe429c..c811c3c7b7404 100644 --- a/packages/ui-client/src/components/Header/HeaderIcon.tsx +++ b/packages/ui-client/src/components/Header/HeaderIcon.tsx @@ -1,8 +1,8 @@ import { Box, Icon } from '@rocket.chat/fuselage'; -import type { ComponentProps, ReactElement } from 'react'; +import type { ComponentPropsWithoutRef, ReactElement } from 'react'; import { isValidElement } from 'react'; -type HeaderIconProps = { icon: ReactElement | ComponentProps | null }; +export type HeaderIconProps = { icon: ReactElement | ComponentPropsWithoutRef | null }; const HeaderIcon = ({ icon }: HeaderIconProps) => icon && ( diff --git a/packages/ui-client/src/components/Header/HeaderState.tsx b/packages/ui-client/src/components/Header/HeaderState.tsx index 3a21eb949550e..0368175d08f7c 100644 --- a/packages/ui-client/src/components/Header/HeaderState.tsx +++ b/packages/ui-client/src/components/Header/HeaderState.tsx @@ -1,8 +1,8 @@ import { Icon, IconButton } from '@rocket.chat/fuselage'; import type { Keys as IconName } from '@rocket.chat/icons'; -import type { AllHTMLAttributes, ComponentPropsWithoutRef, FC, MouseEventHandler } from 'react'; +import type { AllHTMLAttributes, ComponentPropsWithoutRef, MouseEventHandler } from 'react'; -type HeaderStateProps = +export type HeaderStateProps = | (Pick, 'color' | 'title' | 'icon'> & { onClick: MouseEventHandler; } & Omit, 'is'>) @@ -11,7 +11,7 @@ type HeaderStateProps = onClick?: undefined; }); -const HeaderState: FC = (props) => +const HeaderState = (props: HeaderStateProps) => props.onClick ? : ; export default HeaderState; diff --git a/packages/ui-client/src/components/Header/HeaderSubtitle.tsx b/packages/ui-client/src/components/Header/HeaderSubtitle.tsx index facaadf599c0b..eef2190739743 100644 --- a/packages/ui-client/src/components/Header/HeaderSubtitle.tsx +++ b/packages/ui-client/src/components/Header/HeaderSubtitle.tsx @@ -1,6 +1,8 @@ import { Box } from '@rocket.chat/fuselage'; -import type { FC, ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const HeaderSubtitle: FC> = (props) => ; +export type HeaderSubtitleProps = ComponentPropsWithoutRef; + +const HeaderSubtitle = (props: HeaderSubtitleProps) => ; export default HeaderSubtitle; diff --git a/packages/ui-client/src/components/Header/HeaderTag/HeaderTag.tsx b/packages/ui-client/src/components/Header/HeaderTag/HeaderTag.tsx index afbad5d734340..2123e2c360c8d 100644 --- a/packages/ui-client/src/components/Header/HeaderTag/HeaderTag.tsx +++ b/packages/ui-client/src/components/Header/HeaderTag/HeaderTag.tsx @@ -1,7 +1,9 @@ import { Box, Tag } from '@rocket.chat/fuselage'; -import type { ComponentProps, FC } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const HeaderTag: FC> = ({ children, ...props }) => ( +export type HeaderTagProps = ComponentPropsWithoutRef; + +const HeaderTag = ({ children, ...props }: HeaderTagProps) => ( {children} diff --git a/packages/ui-client/src/components/Header/HeaderTag/HeaderTagIcon.tsx b/packages/ui-client/src/components/Header/HeaderTag/HeaderTagIcon.tsx index b2115aad3d470..f17f1317bb933 100644 --- a/packages/ui-client/src/components/Header/HeaderTag/HeaderTagIcon.tsx +++ b/packages/ui-client/src/components/Header/HeaderTag/HeaderTagIcon.tsx @@ -1,12 +1,12 @@ import { Box, Icon } from '@rocket.chat/fuselage'; -import type { ComponentProps, FC, ReactElement } from 'react'; +import type { ComponentPropsWithoutRef, ReactElement } from 'react'; import { isValidElement } from 'react'; -type HeaderIconProps = { - icon: ReactElement | Pick, 'name' | 'color'> | null; +export type HeaderIconProps = { + icon: ReactElement | Pick, 'name' | 'color'> | null; }; -const HeaderTagIcon: FC = ({ icon }) => { +const HeaderTagIcon = ({ icon }: HeaderIconProps) => { if (!icon) { return null; } diff --git a/packages/ui-client/src/components/Header/HeaderTag/HeaderTagSkeleton.tsx b/packages/ui-client/src/components/Header/HeaderTag/HeaderTagSkeleton.tsx index d22c4c1a642ad..14fecc6c194be 100644 --- a/packages/ui-client/src/components/Header/HeaderTag/HeaderTagSkeleton.tsx +++ b/packages/ui-client/src/components/Header/HeaderTag/HeaderTagSkeleton.tsx @@ -1,6 +1,5 @@ import { Skeleton } from '@rocket.chat/fuselage'; -import type { FC } from 'react'; -const HeaderTagSkeleton: FC = () => ; +const HeaderTagSkeleton = () => ; export default HeaderTagSkeleton; diff --git a/packages/ui-client/src/components/Header/HeaderTitle.tsx b/packages/ui-client/src/components/Header/HeaderTitle.tsx index bf2fce7b4e677..ad5e1023521fe 100644 --- a/packages/ui-client/src/components/Header/HeaderTitle.tsx +++ b/packages/ui-client/src/components/Header/HeaderTitle.tsx @@ -1,8 +1,8 @@ import { Box } from '@rocket.chat/fuselage'; -import type { FC, ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const HeaderTitle: FC> = (props) => ( - -); +export type HeaderTitleProps = ComponentPropsWithoutRef; + +const HeaderTitle = (props: HeaderTitleProps) => ; export default HeaderTitle; diff --git a/packages/ui-client/src/components/Header/HeaderTitleButton.tsx b/packages/ui-client/src/components/Header/HeaderTitleButton.tsx index cdfad6c88f06d..69adba8879b08 100644 --- a/packages/ui-client/src/components/Header/HeaderTitleButton.tsx +++ b/packages/ui-client/src/components/Header/HeaderTitleButton.tsx @@ -1,8 +1,10 @@ import { css } from '@rocket.chat/css-in-js'; import { Box, Palette } from '@rocket.chat/fuselage'; -import type { ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const HeaderTitleButton = ({ className, ...props }: { className?: string } & ComponentProps) => { +export type HeaderTitleButtonProps = { className?: string } & ComponentPropsWithoutRef; + +const HeaderTitleButton = ({ className, ...props }: HeaderTitleButtonProps) => { const customClass = css` border-width: 1px; border-style: solid; diff --git a/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbar.tsx b/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbar.tsx index 909814926c553..a8776ba2acbdd 100644 --- a/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbar.tsx +++ b/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbar.tsx @@ -1,8 +1,10 @@ import { useToolbar } from '@react-aria/toolbar'; import { ButtonGroup } from '@rocket.chat/fuselage'; -import { type ComponentProps, useRef } from 'react'; +import { type ComponentPropsWithoutRef, useRef } from 'react'; -const HeaderToolbar = (props: ComponentProps) => { +export type HeaderToolbarProps = ComponentPropsWithoutRef; + +const HeaderToolbar = (props: HeaderToolbarProps) => { const ref = useRef(null); const { toolbarProps } = useToolbar(props, ref); diff --git a/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarAction.tsx b/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarAction.tsx index 26d476e67a17b..7e66fa84595a8 100644 --- a/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarAction.tsx +++ b/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarAction.tsx @@ -1,7 +1,8 @@ import { IconButton } from '@rocket.chat/fuselage'; -import { ComponentProps, forwardRef } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; +import { forwardRef } from 'react'; -type HeaderToolbarActionProps = ComponentProps & { +type HeaderToolbarActionProps = ComponentPropsWithoutRef & { tooltip?: string; }; diff --git a/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarActionBadge.tsx b/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarActionBadge.tsx index 57f26b06bfd7e..682f04e978970 100644 --- a/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarActionBadge.tsx +++ b/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarActionBadge.tsx @@ -1,8 +1,10 @@ import { css } from '@rocket.chat/css-in-js'; import { Box, Badge } from '@rocket.chat/fuselage'; -import type { ComponentProps, FC } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -const HeaderToolbarActionActionBadge: FC> = (props) => ( +export type HeaderToolbarActionBadgeProps = ComponentPropsWithoutRef; + +const HeaderToolbarActionBadge = (props: HeaderToolbarActionBadgeProps) => ( > = (props) ); -export default HeaderToolbarActionActionBadge; +export default HeaderToolbarActionBadge; diff --git a/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarDivider.tsx b/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarDivider.tsx index 52bb2d21222f2..f3823002e88e1 100644 --- a/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarDivider.tsx +++ b/packages/ui-client/src/components/Header/HeaderToolbar/HeaderToolbarDivider.tsx @@ -1,6 +1,5 @@ import { Divider } from '@rocket.chat/fuselage'; -import type { ReactElement } from 'react'; -const HeaderToolbarDivider = (): ReactElement => ; +const HeaderToolbarDivider = () => ; export default HeaderToolbarDivider; diff --git a/packages/ui-client/src/components/HeaderV2/Header.stories.tsx b/packages/ui-client/src/components/HeaderV2/Header.stories.tsx index 62b1e6abb40a3..840e0f1b873c8 100644 --- a/packages/ui-client/src/components/HeaderV2/Header.stories.tsx +++ b/packages/ui-client/src/components/HeaderV2/Header.stories.tsx @@ -3,7 +3,7 @@ import { Avatar, Box, IconButton } from '@rocket.chat/fuselage'; import { SettingsContext } from '@rocket.chat/ui-contexts'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { ComponentProps, ComponentType } from 'react'; +import type { ComponentPropsWithoutRef, ComponentType } from 'react'; import { HeaderV2 as Header, @@ -87,7 +87,7 @@ const room: IRoom = { _updatedAt: new Date(), } as const; -const CustomAvatar = (props: Omit, 'url'>) => ; +const CustomAvatar = (props: Omit, 'url'>) => ; const icon = { name: 'hash' } as const; export const Default = () => ( diff --git a/packages/ui-client/src/components/HeaderV2/HeaderIcon.tsx b/packages/ui-client/src/components/HeaderV2/HeaderIcon.tsx index 31f3f1733d6e9..9175b66257d32 100644 --- a/packages/ui-client/src/components/HeaderV2/HeaderIcon.tsx +++ b/packages/ui-client/src/components/HeaderV2/HeaderIcon.tsx @@ -1,8 +1,8 @@ import { Box, Icon } from '@rocket.chat/fuselage'; -import type { ComponentProps, ReactElement } from 'react'; +import type { ComponentPropsWithoutRef, ReactElement } from 'react'; import { isValidElement } from 'react'; -type HeaderIconProps = { icon: ReactElement | ComponentProps | null }; +type HeaderIconProps = { icon: ReactElement | ComponentPropsWithoutRef | null }; const HeaderIcon = ({ icon }: HeaderIconProps) => icon && ( diff --git a/packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTag.tsx b/packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTag.tsx index 222a01dcf4daa..8ea2d6895bfc1 100644 --- a/packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTag.tsx +++ b/packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTag.tsx @@ -1,7 +1,7 @@ import { Box, Tag } from '@rocket.chat/fuselage'; -import type { ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -type HeaderTagProps = ComponentProps; +type HeaderTagProps = ComponentPropsWithoutRef; const HeaderTag = ({ children, ...props }: HeaderTagProps) => ( diff --git a/packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTagIcon.tsx b/packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTagIcon.tsx index fd124ea09a10f..3f46570719498 100644 --- a/packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTagIcon.tsx +++ b/packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTagIcon.tsx @@ -1,9 +1,9 @@ import { Box, Icon } from '@rocket.chat/fuselage'; -import type { ComponentProps, ReactElement } from 'react'; +import type { ComponentPropsWithoutRef, ReactElement } from 'react'; import { isValidElement } from 'react'; type HeaderIconProps = { - icon: ReactElement | Pick, 'name' | 'color'> | null; + icon: ReactElement | Pick, 'name' | 'color'> | null; }; const HeaderTagIcon = ({ icon }: HeaderIconProps) => { diff --git a/packages/ui-client/src/components/HeaderV2/HeaderToolbar/HeaderToolbar.tsx b/packages/ui-client/src/components/HeaderV2/HeaderToolbar/HeaderToolbar.tsx index 2c2377a5778aa..df8b1e5b2ad17 100644 --- a/packages/ui-client/src/components/HeaderV2/HeaderToolbar/HeaderToolbar.tsx +++ b/packages/ui-client/src/components/HeaderV2/HeaderToolbar/HeaderToolbar.tsx @@ -1,8 +1,9 @@ import { useToolbar } from '@react-aria/toolbar'; import { ButtonGroup } from '@rocket.chat/fuselage'; -import { type ComponentProps, useRef } from 'react'; +import { useRef } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -type HeaderToolbarProps = ComponentProps; +type HeaderToolbarProps = ComponentPropsWithoutRef; const HeaderToolbar = (props: HeaderToolbarProps) => { const ref = useRef(null); diff --git a/packages/ui-client/src/components/HeaderV2/HeaderToolbar/HeaderToolbarAction.tsx b/packages/ui-client/src/components/HeaderV2/HeaderToolbar/HeaderToolbarAction.tsx index 26d476e67a17b..7e66fa84595a8 100644 --- a/packages/ui-client/src/components/HeaderV2/HeaderToolbar/HeaderToolbarAction.tsx +++ b/packages/ui-client/src/components/HeaderV2/HeaderToolbar/HeaderToolbarAction.tsx @@ -1,7 +1,8 @@ import { IconButton } from '@rocket.chat/fuselage'; -import { ComponentProps, forwardRef } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; +import { forwardRef } from 'react'; -type HeaderToolbarActionProps = ComponentProps & { +type HeaderToolbarActionProps = ComponentPropsWithoutRef & { tooltip?: string; }; diff --git a/packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx b/packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx index 8fe78ae7fa788..68d63088383b4 100644 --- a/packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx +++ b/packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx @@ -14,7 +14,7 @@ import { } from '@rocket.chat/fuselage'; import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; import type { Keys as IconName } from '@rocket.chat/icons'; -import type { ComponentProps, ReactElement, ReactNode, ComponentPropsWithoutRef } from 'react'; +import type { ReactElement, ReactNode, ComponentPropsWithoutRef } from 'react'; import { useId, useEffect, useRef } from 'react'; import { useTranslation } from 'react-i18next'; @@ -46,7 +46,7 @@ const iconMap: Record = { success: 'check', }; -const getButtonProps = (variant: VariantType): ComponentProps => { +const getButtonProps = (variant: VariantType): ComponentPropsWithoutRef => { switch (variant) { case 'danger': return { danger: true }; diff --git a/packages/ui-client/src/components/Modal/GenericModal/GenericModalSkeleton.tsx b/packages/ui-client/src/components/Modal/GenericModal/GenericModalSkeleton.tsx index db08f9273fe39..60d35c3adcb74 100644 --- a/packages/ui-client/src/components/Modal/GenericModal/GenericModalSkeleton.tsx +++ b/packages/ui-client/src/components/Modal/GenericModal/GenericModalSkeleton.tsx @@ -1,9 +1,9 @@ import { Skeleton } from '@rocket.chat/fuselage'; -import type { ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; import GenericModal from './GenericModal'; -const GenericModalSkeleton = (props: ComponentProps) => ( +const GenericModalSkeleton = (props: ComponentPropsWithoutRef) => ( }> diff --git a/packages/ui-client/src/components/Modal/GenericModal/withDoNotAskAgain.tsx b/packages/ui-client/src/components/Modal/GenericModal/withDoNotAskAgain.tsx index 3d0f988953b36..86e73bd53730b 100644 --- a/packages/ui-client/src/components/Modal/GenericModal/withDoNotAskAgain.tsx +++ b/packages/ui-client/src/components/Modal/GenericModal/withDoNotAskAgain.tsx @@ -18,7 +18,10 @@ export type RequiredModalProps = { dontAskAgain?: ReactElement; }; -function withDoNotAskAgain(Component: ComponentType) { +function withDoNotAskAgain( + // eslint-disable-next-line @typescript-eslint/naming-convention + Component: ComponentType, +) { type WrappedComponentProps = DoNotAskAgainProps & Omit; const WrappedComponent = function ({ onConfirm, dontAskAgain, ...props }: WrappedComponentProps) { const t = useTranslation(); diff --git a/packages/ui-client/src/components/Modal/ModalBackdrop.tsx b/packages/ui-client/src/components/Modal/ModalBackdrop.tsx index c70124ad02841..4a11349d10796 100644 --- a/packages/ui-client/src/components/Modal/ModalBackdrop.tsx +++ b/packages/ui-client/src/components/Modal/ModalBackdrop.tsx @@ -1,5 +1,5 @@ import { Box } from '@rocket.chat/fuselage'; -import type { MouseEvent, ReactElement, ReactNode, RefObject } from 'react'; +import type { MouseEvent, ReactNode, RefObject } from 'react'; import { useCallback, useEffect, useRef } from 'react'; const useEscapeKey = (onDismiss: (() => void) | undefined): void => { @@ -72,7 +72,7 @@ type ModalBackdropProps = { onDismiss?: () => void; }; -const ModalBackdrop = ({ children, onDismiss }: ModalBackdropProps): ReactElement => { +const ModalBackdrop = ({ children, onDismiss }: ModalBackdropProps) => { const ref = useRef(null); useEscapeKey(onDismiss); diff --git a/packages/ui-client/src/components/Modal/ModalRegion.tsx b/packages/ui-client/src/components/Modal/ModalRegion.tsx index 76bcc23b48e72..3cafd84ca0157 100644 --- a/packages/ui-client/src/components/Modal/ModalRegion.tsx +++ b/packages/ui-client/src/components/Modal/ModalRegion.tsx @@ -1,14 +1,13 @@ import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; import { useCurrentModal, useModal } from '@rocket.chat/ui-contexts'; -import type { ReactElement } from 'react'; import { lazy, Suspense } from 'react'; import ModalBackdrop from './ModalBackdrop'; import ModalPortal from './ModalPortal'; -const FocusScope = lazy(() => import('react-aria').then(({ FocusScope }) => ({ default: FocusScope }))); +const FocusScope = lazy(() => import('react-aria').then((module) => ({ default: module.FocusScope }))); -const ModalRegion = (): ReactElement | null => { +const ModalRegion = () => { const currentModal = useCurrentModal(); const { setModal } = useModal(); const handleDismiss = useEffectEvent(() => { diff --git a/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustom.tsx b/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustom.tsx index a6e348ef82e27..4e2b2d053daa8 100644 --- a/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustom.tsx +++ b/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustom.tsx @@ -1,6 +1,7 @@ -import { Box, Button } from '@rocket.chat/fuselage'; +import type { Button } from '@rocket.chat/fuselage'; +import { Box } from '@rocket.chat/fuselage'; import { useButtonPattern, useOutsideClick, useToggle } from '@rocket.chat/fuselage-hooks'; -import type { ComponentProps, FormEvent, ReactElement, RefObject } from 'react'; +import type { ComponentPropsWithoutRef, FormEvent, RefObject } from 'react'; import { useCallback, useRef } from 'react'; import MultiSelectCustomAnchor from './MultiSelectCustomAnchor'; @@ -47,7 +48,7 @@ type DropDownProps = { selectedOptions: OptionProp[]; setSelectedOptions: (roles: OptionProp[]) => void; searchBarText?: string; -} & ComponentProps; +} & ComponentPropsWithoutRef; export const MultiSelectCustom = ({ dropdownOptions, @@ -57,7 +58,7 @@ export const MultiSelectCustom = ({ setSelectedOptions, searchBarText, ...props -}: DropDownProps): ReactElement => { +}: DropDownProps) => { const reference = useRef(null); const target = useRef(null); const [collapsed, toggleCollapsed] = useToggle(false); diff --git a/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomAnchor.tsx b/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomAnchor.tsx index e28c0a7ad452c..c480bdfdb72e4 100644 --- a/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomAnchor.tsx +++ b/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomAnchor.tsx @@ -1,7 +1,7 @@ import { css } from '@rocket.chat/css-in-js'; import { Box, Icon } from '@rocket.chat/fuselage'; import type { TranslationKey } from '@rocket.chat/ui-contexts'; -import type { ComponentProps } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; import { forwardRef } from 'react'; import { useTranslation } from 'react-i18next'; @@ -11,7 +11,7 @@ type MultiSelectCustomAnchorProps = { selectedOptionsTitle: string; selectedOptionsCount: number; maxCount: number; -} & ComponentProps; +} & ComponentPropsWithoutRef; const MultiSelectCustomAnchor = forwardRef(function MultiSelectCustomAnchor( { className, collapsed, selectedOptionsCount, selectedOptionsTitle, defaultTitle, maxCount, ...props }, diff --git a/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomListWrapper.tsx b/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomListWrapper.tsx index 51ebd06c37c07..f0c63486ed8bd 100644 --- a/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomListWrapper.tsx +++ b/packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomListWrapper.tsx @@ -1,8 +1,8 @@ import { Box } from '@rocket.chat/fuselage'; -import { forwardRef, type ComponentProps } from 'react'; +import { forwardRef } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; -// eslint-disable-next-line @typescript-eslint/no-empty-interface -interface MultiSelectCustomListWrapperProps extends ComponentProps {} +export type MultiSelectCustomListWrapperProps = ComponentPropsWithoutRef; const MultiSelectCustomListWrapper = forwardRef(function MultiSelectCustomListWrapper( { children }, diff --git a/packages/ui-client/src/components/TextSeparator.stories.tsx b/packages/ui-client/src/components/TextSeparator.stories.tsx index 2a4c9e708eef5..7ed0ddda9193f 100644 --- a/packages/ui-client/src/components/TextSeparator.stories.tsx +++ b/packages/ui-client/src/components/TextSeparator.stories.tsx @@ -1,5 +1,4 @@ import type { Meta, StoryFn } from '@storybook/react'; -import type { ReactElement } from 'react'; import TextSeparator from './TextSeparator'; @@ -9,7 +8,7 @@ export default { parameters: { layout: 'centered', }, - decorators: [(fn): ReactElement =>
{fn()}
], + decorators: [(fn) =>
{fn()}
], } satisfies Meta; const Template: StoryFn = (args) => ; diff --git a/packages/ui-client/src/components/TextSeparator.tsx b/packages/ui-client/src/components/TextSeparator.tsx index 978804a7f7da5..f4a2635570f84 100644 --- a/packages/ui-client/src/components/TextSeparator.tsx +++ b/packages/ui-client/src/components/TextSeparator.tsx @@ -1,14 +1,14 @@ import { Box } from '@rocket.chat/fuselage'; -import type { ReactElement, ReactNode } from 'react'; +import type { ReactNode } from 'react'; -import { DotLeader } from './DotLeader'; +import DotLeader from './DotLeader'; type TextSeparatorProps = { label: ReactNode; value: ReactNode; }; -const TextSeparator = ({ label, value }: TextSeparatorProps): ReactElement => ( +const TextSeparator = ({ label, value }: TextSeparatorProps) => ( {label} diff --git a/packages/ui-client/src/components/TooltipComponent.tsx b/packages/ui-client/src/components/TooltipComponent.tsx index 4a46e5536a530..e65c95c063233 100644 --- a/packages/ui-client/src/components/TooltipComponent.tsx +++ b/packages/ui-client/src/components/TooltipComponent.tsx @@ -1,5 +1,5 @@ import { Tooltip, PositionAnimated, AnimatedVisibility } from '@rocket.chat/fuselage'; -import type { ReactElement, ReactNode } from 'react'; +import type { ReactNode } from 'react'; import { useRef } from 'react'; type TooltipComponentProps = { @@ -7,7 +7,7 @@ type TooltipComponentProps = { anchor: Element; }; -export const TooltipComponent = ({ title, anchor }: TooltipComponentProps): ReactElement => { +export const TooltipComponent = ({ title, anchor }: TooltipComponentProps) => { const ref = useRef(anchor); return ( diff --git a/packages/ui-client/src/components/UserAutoComplete/UserAutoComplete.tsx b/packages/ui-client/src/components/UserAutoComplete/UserAutoComplete.tsx index 9673d716193da..bc1b89f122e46 100644 --- a/packages/ui-client/src/components/UserAutoComplete/UserAutoComplete.tsx +++ b/packages/ui-client/src/components/UserAutoComplete/UserAutoComplete.tsx @@ -3,7 +3,7 @@ import { useDebouncedValue } from '@rocket.chat/fuselage-hooks'; import { UserAvatar } from '@rocket.chat/ui-avatar'; import { useEndpoint } from '@rocket.chat/ui-contexts'; import { useQuery } from '@tanstack/react-query'; -import type { ComponentProps, ReactElement } from 'react'; +import type { ComponentPropsWithoutRef } from 'react'; import { memo, useMemo, useState } from 'react'; const query = ( @@ -13,11 +13,11 @@ const query = ( selector: string; } => ({ selector: JSON.stringify({ term, conditions }) }); -type UserAutoCompleteProps = Omit, 'filter'> & { +type UserAutoCompleteProps = Omit, 'filter'> & { conditions?: { [key: string]: unknown }; }; -const UserAutoComplete = ({ value, onChange, ...props }: UserAutoCompleteProps): ReactElement => { +const UserAutoComplete = ({ value, onChange, ...props }: UserAutoCompleteProps) => { const { conditions = {} } = props; const [filter, setFilter] = useState(''); const debouncedFilter = useDebouncedValue(filter, 1000); @@ -38,7 +38,7 @@ const UserAutoComplete = ({ value, onChange, ...props }: UserAutoCompleteProps): filter={filter} setFilter={setFilter} data-qa-id='UserAutoComplete' - renderSelected={({ selected: { value, label } }): ReactElement | null => ( + renderSelected={({ selected: { value, label } }) => ( @@ -46,7 +46,7 @@ const UserAutoComplete = ({ value, onChange, ...props }: UserAutoCompleteProps): )} - renderItem={({ value, label, ...props }): ReactElement => ( + renderItem={({ value, label, ...props }) => (