Skip to content

Fix: file item export #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 30, 2025
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
2 changes: 1 addition & 1 deletion exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"./FileItem": {
"require": "./dist/cjs/components/Form/File/FileItem.js",
"module": "./dist/esm/components/Form/File/FileItem.js",
"default": "./dist/esm/components/Form/File/FileList.js"
"default": "./dist/esm/components/Form/File/FileItem.js"
},
"./FileImageItem": {
"require": "./dist/cjs/components/Form/File/FileImageItem.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
"./FileItem": {
"require": "./dist/cjs/components/Form/File/FileItem.js",
"module": "./dist/esm/components/Form/File/FileItem.js",
"default": "./dist/esm/components/Form/File/FileList.js"
"default": "./dist/esm/components/Form/File/FileItem.js"
},
"./FileImageItem": {
"require": "./dist/cjs/components/Form/File/FileImageItem.js",
Expand Down
6 changes: 0 additions & 6 deletions src/components/Form/File/FileItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ describe('<FileItem>', () => {
expect(getByRole('file-item')).toBeDefined()
})

it('displays file size when provided', () => {
const { getByRole } = render(<FileItem {...defaultProps} />)

expect(getByRole('file-size')).toBeDefined()
})

it('renders children components', () => {
const { getByTestId } = render(
<FileItem {...defaultProps}>
Expand Down
45 changes: 26 additions & 19 deletions src/components/Form/File/FileItem.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CSSProperties, ReactNode } from 'react'
import { composeClasses } from 'lib/classes'
import { Flex } from 'components/Layout'
import ToolTipHover from 'components/ToolTipHover'
import Text from 'components/Typography'
import Tooltip from 'components/Tooltip'
import FileItemButton from './FileItemButton'
import FileItemDropdown from './FileItemDropdown'

Expand Down Expand Up @@ -54,22 +54,32 @@ export const FileItem = ({
}}
>
<Flex alignItems="center" gap="2" className="mr-auto overflow-hidden">
<ToolTipHover
variantPopup="dark"
complementPosition={{ top: -15, left: 0 }}
element={
<Flex alignItems="center" justifyContent="start">
<div className="truncate">
<Text role="file-title" size="xs">
{name}
</Text>
</div>
{fileSize && (
<Text role="file-size" className="mt-0.5 ml-0.5" size="xs">
{fileSize} KB
<Tooltip
variant="primary"
content={
<>
<Flex alignItems="center" justifyContent="start">
<div className="truncate">
<Text role="file-title" size="xs">
{name}
</Text>
</div>
{fileSize && (
<Text role="file-size" className="mt-0.5 ml-0.5" size="xs">
{fileSize} KB
</Text>
)}
</Flex>
{type && (
<Text
role="file-type"
variant="small"
className="block text-left"
>
{type}
</Text>
)}
</Flex>
</>
}
>
<Text
Expand All @@ -79,10 +89,7 @@ export const FileItem = ({
>
{name}
</Text>
<Text role="file-type" variant="small" className="block text-left">
{type}
</Text>
</ToolTipHover>
</Tooltip>
</Flex>
<div
role="file-actions"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/File/FileItemButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactNode } from 'react'
import { composeClasses } from 'lib/classes'
import { Button, IButtonProps } from 'components/Buttons'

export interface FileItemButtonProps {
export interface FileItemButtonProps extends Omit<IButtonProps, 'children'> {
/**
* Content to display inside the button
*/
Expand Down
1 change: 0 additions & 1 deletion src/stories/InputFile.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type Story = StoryObj<typeof InputFile>

export const Default: Story = {
args: {
hintText: 'Subir en formato XML - PDF',
progressIndicator: 0,
dragMessage: 'Suelta aquí',
id: 'upload',
Expand Down