Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions packages/ui-client/.babelrc.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/ui-client/.eslintignore

This file was deleted.

65 changes: 2 additions & 63 deletions packages/ui-client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"]
}
7 changes: 3 additions & 4 deletions packages/ui-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -68,8 +70,5 @@
},
"volta": {
"extends": "../../package.json"
},
"dependencies": {
"dompurify": "~3.2.7"
}
}
3 changes: 2 additions & 1 deletion packages/ui-client/src/components/AnchorPortal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/ui-client/src/components/DotLeader.stories.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
8 changes: 5 additions & 3 deletions packages/ui-client/src/components/DotLeader.tsx
Original file line number Diff line number Diff line change
@@ -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<DotLeaderProps> = ({ color = 'neutral-300', dotSize = 'x2' }) => (
const DotLeader = ({ color = 'neutral-300', dotSize = 'x2' }: DotLeaderProps) => (
<Box flexGrow={1} h='full' alignSelf='flex-end' borderBlockEndStyle='dotted' borderBlockEndWidth={dotSize} m={2} borderColor={color} />
);

export default DotLeader;
Original file line number Diff line number Diff line change
@@ -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<typeof ButtonGroup>) => (
export type EmojiPickerCategoryHeaderProps = ComponentPropsWithoutRef<typeof ButtonGroup>;

const EmojiPickerCategoryHeader = (props: EmojiPickerCategoryHeaderProps) => (
<Box mbs={12} mi={12}>
<ButtonGroup small stretch {...props} />
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Box } from '@rocket.chat/fuselage';
import type { ComponentProps } from 'react';
import type { ComponentPropsWithoutRef } from 'react';

const EmojiPickerCategoryWrapper = (props: ComponentProps<typeof Box>) => <Box {...props} display='flex' flexWrap='wrap' />;
export type EmojiPickerCategoryWrapperProps = ComponentPropsWithoutRef<typeof Box>;

const EmojiPickerCategoryWrapper = (props: EmojiPickerCategoryWrapperProps) => <Box {...props} display='flex' flexWrap='wrap' />;

export default EmojiPickerCategoryWrapper;
6 changes: 3 additions & 3 deletions packages/ui-client/src/components/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -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<typeof Box>;
} & ComponentPropsWithoutRef<typeof Box>;

export const ExternalLink: FC<ExternalLinkProps> = ({ children, to, ...props }) => (
export const ExternalLink = ({ children, to, ...props }: ExternalLinkProps) => (
<Box is='a' href={to} target='_blank' rel='noopener noreferrer' {...props}>
{children || to}
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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) =>
Expand All @@ -25,10 +22,4 @@ export const FeaturePreview = ({
return <Suspense fallback={null}>{toggledChildren}</Suspense>;
};

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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 3 additions & 1 deletion packages/ui-client/src/components/FeaturePreview/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions packages/ui-client/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -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<ComponentProps<typeof Box>> = (props) => {
export type HeaderProps = ComponentPropsWithoutRef<typeof Box>;

const Header = (props: HeaderProps) => {
const { isMobile } = useLayout();

return (
Expand Down
6 changes: 4 additions & 2 deletions packages/ui-client/src/components/Header/HeaderAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Box } from '@rocket.chat/fuselage';
import type { FC, ComponentProps } from 'react';
import type { ComponentPropsWithoutRef } from 'react';

const HeaderAvatar: FC<ComponentProps<typeof Box>> = (props) => <Box mi={4} display='flex' alignItems='center' {...props} />;
export type HeaderAvatarProps = ComponentPropsWithoutRef<typeof Box>;

const HeaderAvatar = (props: HeaderAvatarProps) => <Box mi={4} display='flex' alignItems='center' {...props} />;

export default HeaderAvatar;
6 changes: 4 additions & 2 deletions packages/ui-client/src/components/Header/HeaderContent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Box } from '@rocket.chat/fuselage';
import type { FC, ComponentProps } from 'react';
import type { ComponentPropsWithoutRef } from 'react';

const HeaderContent: FC<ComponentProps<typeof Box>> = (props) => (
export type HeaderContentProps = ComponentPropsWithoutRef<typeof Box>;

const HeaderContent = (props: HeaderContentProps) => (
<Box flexGrow={1} width={1} flexShrink={1} mi={4} display='flex' justifyContent='center' flexDirection='column' {...props} />
);

Expand Down
6 changes: 4 additions & 2 deletions packages/ui-client/src/components/Header/HeaderContentRow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Box } from '@rocket.chat/fuselage';
import type { FC, ComponentProps } from 'react';
import type { ComponentPropsWithoutRef } from 'react';

const HeaderContentRow: FC<ComponentProps<typeof Box>> = (props) => (
export type HeaderContentRowProps = ComponentPropsWithoutRef<typeof Box>;

const HeaderContentRow = (props: HeaderContentRowProps) => (
<Box alignItems='center' flexShrink={1} flexGrow={1} display='flex' {...props} />
);

Expand Down
3 changes: 1 addition & 2 deletions packages/ui-client/src/components/Header/HeaderDivider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Divider } from '@rocket.chat/fuselage';
import type { FC } from 'react';

const HeaderDivider: FC = () => <Divider mbs={-2} mbe={0} />;
const HeaderDivider = () => <Divider mbs={-2} mbe={0} />;

export default HeaderDivider;
4 changes: 2 additions & 2 deletions packages/ui-client/src/components/Header/HeaderIcon.tsx
Original file line number Diff line number Diff line change
@@ -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<typeof Icon> | null };
export type HeaderIconProps = { icon: ReactElement | ComponentPropsWithoutRef<typeof Icon> | null };

const HeaderIcon = ({ icon }: HeaderIconProps) =>
icon && (
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-client/src/components/Header/HeaderState.tsx
Original file line number Diff line number Diff line change
@@ -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<ComponentPropsWithoutRef<typeof IconButton>, 'color' | 'title' | 'icon'> & {
onClick: MouseEventHandler;
} & Omit<AllHTMLAttributes<HTMLButtonElement>, 'is'>)
Expand All @@ -11,7 +11,7 @@ type HeaderStateProps =
onClick?: undefined;
});

const HeaderState: FC<HeaderStateProps> = (props) =>
const HeaderState = (props: HeaderStateProps) =>
props.onClick ? <IconButton tiny mie={4} {...props} /> : <Icon size='x16' mie={8} name={props.icon} {...props} />;

export default HeaderState;
6 changes: 4 additions & 2 deletions packages/ui-client/src/components/Header/HeaderSubtitle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Box } from '@rocket.chat/fuselage';
import type { FC, ComponentProps } from 'react';
import type { ComponentPropsWithoutRef } from 'react';

const HeaderSubtitle: FC<ComponentProps<typeof Box>> = (props) => <Box color='hint' fontScale='p2' withTruncatedText {...props} />;
export type HeaderSubtitleProps = ComponentPropsWithoutRef<typeof Box>;

const HeaderSubtitle = (props: HeaderSubtitleProps) => <Box color='hint' fontScale='p2' withTruncatedText {...props} />;

export default HeaderSubtitle;
Original file line number Diff line number Diff line change
@@ -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<ComponentProps<typeof Tag>> = ({ children, ...props }) => (
export type HeaderTagProps = ComponentPropsWithoutRef<typeof Tag>;

const HeaderTag = ({ children, ...props }: HeaderTagProps) => (
<Box p={4} withTruncatedText minWidth='x32'>
<Tag medium {...props}>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ComponentProps<typeof Icon>, 'name' | 'color'> | null;
export type HeaderIconProps = {
icon: ReactElement | Pick<ComponentPropsWithoutRef<typeof Icon>, 'name' | 'color'> | null;
};

const HeaderTagIcon: FC<HeaderIconProps> = ({ icon }) => {
const HeaderTagIcon = ({ icon }: HeaderIconProps) => {
if (!icon) {
return null;
}
Expand Down
Loading
Loading