diff --git a/packages/ui/package.json b/packages/ui/package.json index da614c6..b0bfa34 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -88,9 +88,7 @@ "default": "./dist/FormField/FormField.js" } }, - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "build": "NODE_OPTIONS='--max-old-space-size=4096' tsup", "dev": "tsup --watch", diff --git a/packages/ui/src/Checkbox/Checkbox.test.tsx b/packages/ui/src/Checkbox/Checkbox.test.tsx index efa3ed6..7f9983a 100644 --- a/packages/ui/src/Checkbox/Checkbox.test.tsx +++ b/packages/ui/src/Checkbox/Checkbox.test.tsx @@ -107,9 +107,7 @@ describe('Checkbox', () => { const wrapper = container.querySelector('div'); const children = Array.from(wrapper?.children || []); const labelIndex = children.findIndex((child) => child.tagName === 'LABEL'); - const inputWrapperIndex = children.findIndex((child) => - child.querySelector('input') - ); + const inputWrapperIndex = children.findIndex((child) => child.querySelector('input')); expect(inputWrapperIndex).toBeLessThan(labelIndex); }); @@ -123,9 +121,7 @@ describe('Checkbox', () => { const wrapper = container.querySelector('div'); const children = Array.from(wrapper?.children || []); const labelIndex = children.findIndex((child) => child.tagName === 'LABEL'); - const inputWrapperIndex = children.findIndex((child) => - child.querySelector('input') - ); + const inputWrapperIndex = children.findIndex((child) => child.querySelector('input')); expect(labelIndex).toBeLessThan(inputWrapperIndex); }); }); @@ -251,18 +247,12 @@ describe('Checkbox', () => { it('should support aria-describedby', () => { render(); - expect(screen.getByRole('checkbox')).toHaveAttribute( - 'aria-describedby', - 'description' - ); + expect(screen.getByRole('checkbox')).toHaveAttribute('aria-describedby', 'description'); }); it('should support aria-labelledby', () => { render(); - expect(screen.getByRole('checkbox')).toHaveAttribute( - 'aria-labelledby', - 'label-id' - ); + expect(screen.getByRole('checkbox')).toHaveAttribute('aria-labelledby', 'label-id'); }); it('should support aria-required', () => { @@ -519,9 +509,7 @@ describe('Checkbox', () => { const user = userEvent.setup(); const ControlledCheckbox = () => { const [checked, setChecked] = React.useState(false); - return ( - setChecked(e.target.checked)} /> - ); + return setChecked(e.target.checked)} />; }; render(); diff --git a/packages/ui/src/Checkbox/Checkbox.tsx b/packages/ui/src/Checkbox/Checkbox.tsx index 953fce0..daef4df 100644 --- a/packages/ui/src/Checkbox/Checkbox.tsx +++ b/packages/ui/src/Checkbox/Checkbox.tsx @@ -120,12 +120,7 @@ export const Checkbox = forwardRef( xmlns="http://www.w3.org/2000/svg" aria-hidden="true" > - + ); @@ -133,10 +128,7 @@ export const Checkbox = forwardRef( const labelElement = label ? ( diff --git a/packages/ui/src/FormField/FormField.test.tsx b/packages/ui/src/FormField/FormField.test.tsx index d57097a..447c105 100644 --- a/packages/ui/src/FormField/FormField.test.tsx +++ b/packages/ui/src/FormField/FormField.test.tsx @@ -191,10 +191,7 @@ describe('FormField', () => { it('should hide helper text when error is present', () => { render( - + ); @@ -390,11 +387,7 @@ describe('FormField', () => { it('should work with success state and helper text', () => { render( - + ); diff --git a/packages/ui/src/FormField/FormField.tsx b/packages/ui/src/FormField/FormField.tsx index 92fcb08..d523196 100644 --- a/packages/ui/src/FormField/FormField.tsx +++ b/packages/ui/src/FormField/FormField.tsx @@ -126,10 +126,7 @@ export function FormField({ {/* Helper text (shown only if no error) */} {!error && helperText && ( -
+
{helperText}
)} diff --git a/packages/ui/src/Radio/Radio.test.tsx b/packages/ui/src/Radio/Radio.test.tsx index 46c7fa8..8bd9569 100644 --- a/packages/ui/src/Radio/Radio.test.tsx +++ b/packages/ui/src/Radio/Radio.test.tsx @@ -1,10 +1,10 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { createRef } from 'react'; +import React from 'react'; import { describe, expect, it, vi } from 'vitest'; import { Radio } from './Radio'; import { RadioGroup } from './RadioGroup'; -import React from 'react'; describe('Radio', () => { describe('Rendering', () => { @@ -347,10 +347,7 @@ describe('Radio', () => { ); - expect(screen.getByRole('radio')).toHaveAttribute( - 'aria-describedby', - 'description' - ); + expect(screen.getByRole('radio')).toHaveAttribute('aria-describedby', 'description'); }); it('should support aria-labelledby', () => { @@ -573,10 +570,7 @@ describe('RadioGroup', () => { ); - expect(screen.getByRole('radiogroup')).toHaveAttribute( - 'aria-label', - 'Choose size' - ); + expect(screen.getByRole('radiogroup')).toHaveAttribute('aria-label', 'Choose size'); }); it('should support aria-labelledby', () => { @@ -585,10 +579,7 @@ describe('RadioGroup', () => { ); - expect(screen.getByRole('radiogroup')).toHaveAttribute( - 'aria-labelledby', - 'label-id' - ); + expect(screen.getByRole('radiogroup')).toHaveAttribute('aria-labelledby', 'label-id'); }); it('should support aria-describedby', () => { @@ -597,10 +588,7 @@ describe('RadioGroup', () => { ); - expect(screen.getByRole('radiogroup')).toHaveAttribute( - 'aria-describedby', - 'description-id' - ); + expect(screen.getByRole('radiogroup')).toHaveAttribute('aria-describedby', 'description-id'); }); it('should support aria-required', () => { diff --git a/packages/ui/src/Radio/Radio.tsx b/packages/ui/src/Radio/Radio.tsx index 2174bde..ac8d1b7 100644 --- a/packages/ui/src/Radio/Radio.tsx +++ b/packages/ui/src/Radio/Radio.tsx @@ -89,10 +89,7 @@ export const Radio = forwardRef( const labelElement = label ? ( diff --git a/packages/ui/src/Radio/types.ts b/packages/ui/src/Radio/types.ts index 863d118..85854f3 100644 --- a/packages/ui/src/Radio/types.ts +++ b/packages/ui/src/Radio/types.ts @@ -3,8 +3,7 @@ import type { InputHTMLAttributes } from 'react'; /** * Radio component props */ -export interface RadioProps - extends Omit, 'size' | 'type'> { +export interface RadioProps extends Omit, 'size' | 'type'> { /** * Visual state of the radio button * @default 'default' diff --git a/packages/ui/src/Select/Select.test.tsx b/packages/ui/src/Select/Select.test.tsx index 75772f6..feb92e3 100644 --- a/packages/ui/src/Select/Select.test.tsx +++ b/packages/ui/src/Select/Select.test.tsx @@ -231,9 +231,7 @@ describe('Select', () => { }); it('should apply correct spinner size based on select size', () => { - const { container, rerender } = render( - ); let spinner = container.querySelector('svg.animate-spin'); expect(spinner).toHaveAttribute('width', '14'); @@ -300,18 +298,12 @@ describe('Select', () => { it('should support aria-describedby', () => { render(); - expect(screen.getByRole('combobox')).toHaveAttribute( - 'aria-labelledby', - 'label-id' - ); + expect(screen.getByRole('combobox')).toHaveAttribute('aria-labelledby', 'label-id'); }); it('should support aria-required', () => { @@ -506,9 +498,7 @@ describe('Select', () => { }); it('should work with loading and disabled states', () => { - const { container } = render( - ); const select = screen.getByRole('combobox'); expect(select).toBeDisabled(); expect(container.querySelector('svg.animate-spin')).toBeInTheDocument(); diff --git a/packages/ui/src/Select/Select.tsx b/packages/ui/src/Select/Select.tsx index 6dbeeb7..01eab5f 100644 --- a/packages/ui/src/Select/Select.tsx +++ b/packages/ui/src/Select/Select.tsx @@ -98,27 +98,22 @@ export const Select = forwardRef( {hasChildren && children} {/* Render simple options if provided */} - {!hasChildren && hasOptions && + {!hasChildren && + hasOptions && options.map((option) => ( - ))} {/* Render option groups if provided */} - {!hasChildren && !hasOptions && hasOptionGroups && + {!hasChildren && + !hasOptions && + hasOptionGroups && optionGroups.map((group) => ( {group.options.map((option) => ( - ))} diff --git a/packages/ui/src/Select/types.ts b/packages/ui/src/Select/types.ts index 2c64f26..84ffe27 100644 --- a/packages/ui/src/Select/types.ts +++ b/packages/ui/src/Select/types.ts @@ -39,8 +39,7 @@ export interface SelectOptionGroup { /** * Select component props */ -export interface SelectProps - extends Omit, 'size'> { +export interface SelectProps extends Omit, 'size'> { /** * Visual state of the select * @default 'default' diff --git a/packages/ui/src/Slider/Slider.test.tsx b/packages/ui/src/Slider/Slider.test.tsx index 98ac596..a96e5bd 100644 --- a/packages/ui/src/Slider/Slider.test.tsx +++ b/packages/ui/src/Slider/Slider.test.tsx @@ -159,10 +159,7 @@ describe('Slider', () => { }); it('should show marks without labels (just values)', () => { - const marks = [ - { value: 0 }, - { value: 50 }, - ]; + const marks = [{ value: 0 }, { value: 50 }]; render(); expect(screen.getByText('0')).toBeInTheDocument(); @@ -282,18 +279,12 @@ describe('Slider', () => { it('should support aria-labelledby', () => { render(); - expect(screen.getByRole('slider')).toHaveAttribute( - 'aria-labelledby', - 'volume-label' - ); + expect(screen.getByRole('slider')).toHaveAttribute('aria-labelledby', 'volume-label'); }); it('should support aria-describedby', () => { render(); - expect(screen.getByRole('slider')).toHaveAttribute( - 'aria-describedby', - 'volume-description' - ); + expect(screen.getByRole('slider')).toHaveAttribute('aria-describedby', 'volume-description'); }); }); @@ -446,7 +437,10 @@ describe('Slider', () => { }); it('should work with all props combined', () => { - const marks = [{ value: 0, label: 'Low' }, { value: 100, label: 'High' }]; + const marks = [ + { value: 0, label: 'Low' }, + { value: 100, label: 'High' }, + ]; render( , 'type' | 'size'> { +export interface SliderProps extends Omit, 'type' | 'size'> { /** * Minimum value * @default 0 diff --git a/packages/ui/src/Switch/Switch.test.tsx b/packages/ui/src/Switch/Switch.test.tsx index 2039931..a93468e 100644 --- a/packages/ui/src/Switch/Switch.test.tsx +++ b/packages/ui/src/Switch/Switch.test.tsx @@ -1,9 +1,9 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { createRef } from 'react'; +import React from 'react'; import { describe, expect, it, vi } from 'vitest'; import { Switch } from './Switch'; -import React from 'react'; describe('Switch', () => { describe('Rendering', () => { @@ -248,9 +248,7 @@ describe('Switch', () => { it('should sync hidden input checked state', async () => { const user = userEvent.setup(); const { container } = render(); - const hiddenInput = container.querySelector( - 'input[name="test"]' - ) as HTMLInputElement; + const hiddenInput = container.querySelector('input[name="test"]') as HTMLInputElement; const switchEl = screen.getByRole('switch'); expect(hiddenInput?.checked).toBe(false); @@ -296,10 +294,7 @@ describe('Switch', () => { it('should support custom aria-labelledby', () => { render(); - expect(screen.getByRole('switch')).toHaveAttribute( - 'aria-labelledby', - 'custom-label' - ); + expect(screen.getByRole('switch')).toHaveAttribute('aria-labelledby', 'custom-label'); }); it('should set aria-hidden on thumb', () => { diff --git a/packages/ui/src/Switch/variants.ts b/packages/ui/src/Switch/variants.ts index 1d60ffb..150d51e 100644 --- a/packages/ui/src/Switch/variants.ts +++ b/packages/ui/src/Switch/variants.ts @@ -102,10 +102,7 @@ export const switchThumbVariants = createVariants({ * Loading spinner variants */ export const switchSpinnerVariants = createVariants({ - base: [ - 'absolute inset-0 flex items-center justify-center', - 'pointer-events-none', - ].join(' '), + base: ['absolute inset-0 flex items-center justify-center', 'pointer-events-none'].join(' '), variants: { size: { diff --git a/packages/ui/src/Textarea/Textarea.test.tsx b/packages/ui/src/Textarea/Textarea.test.tsx index 8c5e834..9e323cf 100644 --- a/packages/ui/src/Textarea/Textarea.test.tsx +++ b/packages/ui/src/Textarea/Textarea.test.tsx @@ -162,7 +162,9 @@ describe('Textarea', () => { }); it('shows character count with max length', () => { - const { container } = render(