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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CheckOption, Option, PaginatedMultiSelectFiltered } from '@rocket.chat/fuselage';
import type { PaginatedMultiSelectOption } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import type { ComponentProps, ComponentPropsWithoutRef, ReactElement } from 'react';
import type { ComponentProps } from 'react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -53,20 +53,6 @@ const AutoCompleteDepartmentMultiple = ({
return [...departmentsItems, ...pending];
}, [departmentsItems, value]);

const renderItem = ({ label, value, ...props }: ComponentPropsWithoutRef<typeof Option>): ReactElement => {
if (withCheckbox) {
return (
<CheckOption
{...props}
label={<span style={{ whiteSpace: 'normal' }}>{label}</span>}
selected={value ? selectedValues.has(value) : false}
/>
);
}

return <Option {...props} label={label} />;
};

return (
<PaginatedMultiSelectFiltered
withTitle
Expand All @@ -80,7 +66,19 @@ const AutoCompleteDepartmentMultiple = ({
flexShrink={0}
flexGrow={0}
placeholder={t('Select_an_option')}
renderItem={renderItem}
renderItem={({ label, value, ref: _ref, ...props }) => {
if (withCheckbox) {
return (
<CheckOption
{...props}
label={<span style={{ whiteSpace: 'normal' }}>{label}</span>}
selected={value ? selectedValues.has(value) : false}
/>
);
}

return <Option {...props} label={label} />;
}}
endReached={() => fetchNextPage()}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Option } from '@rocket.chat/fuselage';
import { CheckOption, PaginatedMultiSelectFiltered } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import type { ComponentProps, ComponentPropsWithoutRef, ReactElement } from 'react';
import type { ComponentProps, ReactElement } from 'react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -32,7 +31,7 @@ const AutoCompleteMonitors = ({ value = [], onBlur, onChange, ...props }: AutoCo
endReached={() => fetchNextPage()}
onBlur={onBlur}
onChange={onChange}
renderItem={({ label, value, ...props }: ComponentPropsWithoutRef<typeof Option>) => (
renderItem={({ label, value, ref: _ref, ...props }) => (
<CheckOption {...props} label={label} selected={value ? selectedValues.has(value) : false} />
)}
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/fuselage-ui-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
Firstly, install the peer dependencies (prerequisites):

```sh
npm i @rocket.chat/fuselage @rocket.chat/fuselage-hooks @rocket.chat/fuselage-polyfills @rocket.chat/icons @rocket.chat/styled react react-dom
npm i @rocket.chat/fuselage @rocket.chat/fuselage-hooks @rocket.chat/icons @rocket.chat/styled react react-dom

# or, if you are using yarn:

yarn add @rocket.chat/fuselage @rocket.chat/fuselage-hooks @rocket.chat/fuselage-polyfills @rocket.chat/icons @rocket.chat/styled react react-dom
yarn add @rocket.chat/fuselage @rocket.chat/fuselage-hooks @rocket.chat/icons @rocket.chat/styled react react-dom
```

Add `@rocket.chat/fuselage-ui-kit` as a dependency:
Expand Down
8 changes: 3 additions & 5 deletions packages/fuselage-ui-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "~0.31.25",
"@rocket.chat/eslint-config": "workspace:^",
"@rocket.chat/fuselage": "^0.68.1",
"@rocket.chat/fuselage-hooks": "~0.37.2",
"@rocket.chat/fuselage-polyfills": "~0.31.25",
"@rocket.chat/fuselage": "~0.68.1",
"@rocket.chat/fuselage-hooks": "~0.38.1",
"@rocket.chat/fuselage-tokens": "~0.33.2",
"@rocket.chat/icons": "^0.45.0",
"@rocket.chat/icons": "~0.45.0",
"@rocket.chat/jest-presets": "workspace:~",
"@rocket.chat/mock-providers": "workspace:^",
"@rocket.chat/styled": "~0.32.0",
Expand Down Expand Up @@ -102,7 +101,6 @@
"@rocket.chat/eslint-config": "0.7.0",
"@rocket.chat/fuselage": "*",
"@rocket.chat/fuselage-hooks": "*",
"@rocket.chat/fuselage-polyfills": "*",
"@rocket.chat/icons": "*",
"@rocket.chat/styled": "*",
"@rocket.chat/ui-avatar": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ChannelsSelectElement = ({ block, context }: ChannelsSelectElementProps) =
setFilter={setFilter}
renderSelected={({ selected: { value, label } }) => (
<Chip height='x20' value={value} mie={4}>
<RoomAvatar size='x20' room={{ type: label?.type || 'c', _id: value, ...label }} />
<RoomAvatar size='x20' room={{ _id: value, ...label, type: label?.type || 'c' }} />
<Box verticalAlign='middle' is='span' margin='none' mi={4}>
{label.name}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const MultiChannelsSelectElement = ({ block, context }: MultiChannelsSelectProps
multiple
renderSelected={({ selected: { value, label }, onRemove, ...props }) => (
<Chip key={value} {...props} value={value} onClick={onRemove}>
<RoomAvatar size='x20' room={{ type: label?.type || 'c', _id: value, ...label }} />
<RoomAvatar size='x20' room={{ _id: value, ...label, type: label?.type || 'c' }} />
<Box is='span' margin='none' mis={4}>
{label?.name}
</Box>
Expand All @@ -46,7 +46,7 @@ const MultiChannelsSelectElement = ({ block, context }: MultiChannelsSelectProps
key={value}
{...props}
label={label.name}
avatar={<RoomAvatar size='x20' room={{ type: label?.type || 'c', _id: value, ...label }} />}
avatar={<RoomAvatar size='x20' room={{ _id: value, ...label, type: label?.type || 'c' }} />}
/>
)}
options={options}
Expand Down
Loading