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
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"globals": "16.4.0",
"typescript": "5.9.3",
"typescript-eslint": "8.46.1",
"vite": "7.1.10"
"vite": "7.2.2"
}
}
2 changes: 1 addition & 1 deletion examples/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"@types/react-dom": "19.2.2",
"@vitejs/plugin-react": "5.0.4",
"typescript": "5.9.3",
"vite": "7.1.10"
"vite": "7.2.2"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"@babel/preset-react": "7.27.1",
"@babel/preset-typescript": "7.27.1",
"@babel/runtime": "7.28.4",
"@biomejs/biome": "2.2.7",
"@biomejs/biome": "2.3.6",
"@changesets/changelog-github": "0.5.1",
"@changesets/cli": "2.29.7",
"@commitlint/cli": "20.1.0",
Expand Down Expand Up @@ -148,7 +148,7 @@
"cross-env": "10.1.0",
"cz-conventional-changelog": "3.3.0",
"date-fns": "4.1.0",
"esbuild-plugin-browserslist": "1.0.2",
"esbuild-plugin-browserslist": "2.0.0",
"eslint": "9.39.1",
"eslint-plugin-oxlint": "1.28.0",
"eslint-plugin-storybook": "9.1.13",
Expand Down Expand Up @@ -180,9 +180,9 @@
"svgo": "4.0.0",
"timekeeper": "2.3.1",
"tsx": "4.20.6",
"turbo": "2.5.8",
"turbo": "2.6.1",
"typescript": "5.9.3",
"vite": "7.1.10",
"vite": "7.2.2",
"vitest": "3.2.4",
"vitest-canvas-mock": "0.3.3",
"vitest-localstorage-mock": "0.1.2",
Expand Down
13 changes: 8 additions & 5 deletions packages/ui/src/components/Alert/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ describe('alert', () => {
))

describe(`renders correctly with all sentiments`, () => {
test.each(['danger', 'info', 'success', 'warning', 'neutral'] as const)(
`renders correctly sentiment %o`,
sentiment =>
shouldMatchSnapshot(<Alert sentiment={sentiment}>Sample Alert</Alert>),
)
test.each([
'danger',
'info',
'success',
'warning',
'neutral',
] as const)(`renders correctly sentiment %o`, sentiment =>
shouldMatchSnapshot(<Alert sentiment={sentiment}>Sample Alert</Alert>))
})

test(`should render alert and then close it`, async () => {
Expand Down
146 changes: 69 additions & 77 deletions packages/ui/src/components/Avatar/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,90 +7,82 @@ import { Avatar } from '..'
import support from '../__stories__/assets/avatar.svg'

describe('avatar', () => {
describe.each(['circle', 'square'] as const)(
`renders correctly with shape %s`,
shape => {
describe.each(['xsmall', 'small', 'medium', 'large'] as const)(
`renders correctly with shape ${shape} and size %s`,
size => {
it('renders correctly with variant user', () =>
shouldMatchSnapshot(
<Avatar shape={shape} size={size} variant="user" />,
))
describe.each([
'circle',
'square',
] as const)(`renders correctly with shape %s`, shape => {
describe.each([
'xsmall',
'small',
'medium',
'large',
] as const)(`renders correctly with shape ${shape} and size %s`, size => {
it('renders correctly with variant user', () =>
shouldMatchSnapshot(
<Avatar shape={shape} size={size} variant="user" />,
))

it('renders correctly with variant image', () =>
shouldMatchSnapshot(
<Avatar
image={support}
shape={shape}
size={size}
variant="image"
/>,
))
it('renders correctly with variant image', () =>
shouldMatchSnapshot(
<Avatar image={support} shape={shape} size={size} variant="image" />,
))

it('renders correctly with variant text', () =>
shouldMatchSnapshot(
<Avatar shape={shape} size={size} text="UV" variant="text" />,
))
it('renders correctly with variant text', () =>
shouldMatchSnapshot(
<Avatar shape={shape} size={size} text="UV" variant="text" />,
))

it('renders correctly with variant text and sentiment neutral', () =>
shouldMatchSnapshot(
<Avatar
sentiment="neutral"
shape={shape}
size={size}
text="UV"
variant="text"
/>,
))
it('renders correctly with variant text and sentiment neutral', () =>
shouldMatchSnapshot(
<Avatar
sentiment="neutral"
shape={shape}
size={size}
text="UV"
variant="text"
/>,
))

it('renders correctly with variant icon', () =>
shouldMatchSnapshot(
<Avatar shape={shape} size={size} variant="icon">
<MosaicIcon />
</Avatar>,
))
it('renders correctly with variant icon', () =>
shouldMatchSnapshot(
<Avatar shape={shape} size={size} variant="icon">
<MosaicIcon />
</Avatar>,
))

it('renders correctly with variant icon and sentiment neutral', () =>
shouldMatchSnapshot(
<Avatar
sentiment="neutral"
shape={shape}
size={size}
variant="icon"
>
<MosaicIcon />
</Avatar>,
))
it('renders correctly with variant icon and sentiment neutral', () =>
shouldMatchSnapshot(
<Avatar sentiment="neutral" shape={shape} size={size} variant="icon">
<MosaicIcon />
</Avatar>,
))

it('renders correctly with variant colors', () =>
shouldMatchSnapshot(
<Avatar shape={shape} size={size} variant="colors" />,
))
it('renders correctly with variant colors', () =>
shouldMatchSnapshot(
<Avatar shape={shape} size={size} variant="colors" />,
))

it('renders correctly with variant text and upload', async () => {
const onClick = vi.fn()
const { asFragment } = renderWithTheme(
<Avatar
data-testid="avatar"
onClick={onClick}
shape={shape}
size={size}
text="UV"
upload
variant="text"
/>,
)
const avatar = screen.getByTestId('avatar')
it('renders correctly with variant text and upload', async () => {
const onClick = vi.fn()
const { asFragment } = renderWithTheme(
<Avatar
data-testid="avatar"
onClick={onClick}
shape={shape}
size={size}
text="UV"
upload
variant="text"
/>,
)
const avatar = screen.getByTestId('avatar')

await userEvent.hover(avatar)
expect(asFragment()).toMatchSnapshot()
await userEvent.hover(avatar)
expect(asFragment()).toMatchSnapshot()

await userEvent.click(avatar)
expect(onClick).toHaveBeenCalledOnce()
})
},
)
},
)
await userEvent.click(avatar)
expect(onClick).toHaveBeenCalledOnce()
})
})
})
})
7 changes: 5 additions & 2 deletions packages/ui/src/components/LineChart/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ export const getMinChartValue = (preppedData?: Serie[]): number => {
return Math.floor(minimum - minimum * 0.1)
}

export const getCurrent = (values: number[] = []): number =>
values.length > 0 ? values[values.length - 1] : 0
export const getCurrent = (values: number[] = []): number => {
const val = values.at(-1)

return val ? val : 0
}

export const getSelected = (
label: string,
Expand Down
6 changes: 2 additions & 4 deletions packages/ui/src/components/Link/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ describe('link', () => {
<Link href="/" sentiment={sentiment as 'primary' | 'info'}>
Hello
</Link>,
),
)
))
})

describe('prominence', () => {
Expand All @@ -31,8 +30,7 @@ describe('link', () => {
<Link href="/" prominence={prominence as ProminenceProps}>
Hello
</Link>,
),
)
))
})

test(`render correctly with target blank`, () =>
Expand Down
40 changes: 23 additions & 17 deletions packages/ui/src/components/Modal/components/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,39 @@ export const Dialog = ({
return
}

const focusableEls =
dialogRef.current?.querySelectorAll(
'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled])',
) ?? []
const focusableEls = dialogRef.current?.querySelectorAll(
'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled])',
)

// Handle case when no interactive element are within the modal (including close icon)
if (focusableEls.length === 0) {
if (focusableEls?.length === 0) {
event.preventDefault()
}

const firstFocusableEl = focusableEls[0] as HTMLElement
const lastFocusableEl = focusableEls[focusableEls.length - 1] as HTMLElement
if (focusableEls) {
const elems = [...focusableEls]
const firstFocusableEl = elems[0]
const lastFocusableEl = elems.at(-1)

if (event.shiftKey) {
if (
document.activeElement === firstFocusableEl ||
if (event.shiftKey) {
if (
document.activeElement === firstFocusableEl ||
document.activeElement === dialogRef.current
) {
if (lastFocusableEl instanceof HTMLElement) {
lastFocusableEl.focus()
}
event.preventDefault()
}
} else if (
document.activeElement === lastFocusableEl ||
document.activeElement === dialogRef.current
) {
lastFocusableEl.focus()
if (firstFocusableEl instanceof HTMLElement) {
firstFocusableEl.focus()
}
event.preventDefault()
}
} else if (
document.activeElement === lastFocusableEl ||
document.activeElement === dialogRef.current
) {
firstFocusableEl.focus()
event.preventDefault()
}
}, [])

Expand Down
44 changes: 24 additions & 20 deletions packages/ui/src/components/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -452,35 +452,39 @@ export const Popup = forwardRef(
}
event.stopPropagation()

const focusableEls =
innerPopupRef.current?.querySelectorAll(
'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled])',
) ?? []
const focusableEls = innerPopupRef.current?.querySelectorAll(
'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled])',
)

// Handle case when no interactive element are within the modal (including close icon)
if (focusableEls.length === 0) {
if (focusableEls?.length === 0) {
event.preventDefault()
}

const firstFocusableEl = focusableEls[0] as HTMLElement
const lastFocusableEl = focusableEls[
focusableEls.length - 1
] as HTMLElement

if (event.shiftKey) {
if (
document.activeElement === firstFocusableEl ||
if (focusableEls) {
const elems = [...focusableEls]
const firstFocusableEl = elems[0]
const lastFocusableEl = elems.at(-1)

if (event.shiftKey) {
if (
document.activeElement === firstFocusableEl ||
document.activeElement === innerPopupRef.current
) {
if (lastFocusableEl instanceof HTMLElement) {
lastFocusableEl.focus()
}
event.preventDefault()
}
} else if (
document.activeElement === lastFocusableEl ||
document.activeElement === innerPopupRef.current
) {
lastFocusableEl.focus()
if (firstFocusableEl instanceof HTMLElement) {
firstFocusableEl.focus()
}
event.preventDefault()
}
} else if (
document.activeElement === lastFocusableEl ||
document.activeElement === innerPopupRef.current
) {
firstFocusableEl.focus()
event.preventDefault()
}
}, [])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { SENTIMENTS } from '../constant'

describe('status', () => {
test.each(SENTIMENTS)('renders correctly with type="%s"', sentiment =>
shouldMatchSnapshot(<Status sentiment={sentiment} />),
)
shouldMatchSnapshot(<Status sentiment={sentiment} />))

test(`render animated`, () =>
shouldMatchSnapshot(<Status animated sentiment="success" />))
Expand Down
Loading
Loading