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
1 change: 1 addition & 0 deletions .storybook/storybook.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '*.scss';
4 changes: 2 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export default defineConfig([
{
files: ['**/*.{js,mjs,ts,tsx}'],
extends: [
configPrettier,
eslint.configs.recommended,
pluginTypeScript.configs.recommended,
pluginImport.flatConfigs.recommended,
pluginImport.flatConfigs.typescript,
pluginTypeScript.configs.recommended,
configPrettier,
],
languageOptions: {
parser: pluginTypeScript.parser,
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/eslint": "^9.6.1",
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
"@types/jest": "^30.0.0",
"@types/jest-axe": "^3.5.9",
"@types/node": "^24.12.0",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"babel-jest": "^30.3.0",
"babel-plugin-module-resolver": "^5.0.2",
"babel-plugin-module-resolver": "^5.0.3",
"babel-plugin-replace-import-extension": "^1.1.5",
"classnames": "^2.5.1",
"eslint": "^9.39.4",
Expand All @@ -111,8 +112,8 @@
"sass-embedded": "^1.97.2",
"storybook": "^10.2.14",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.57.1",
"typescript": "^6.0.2",
"typescript-eslint": "^8.58.0",
"vite": "^7.3.1",
"vite-tsconfig-paths": "^6.1.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/form-elements/checkboxes/Checkboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const CheckboxesComponent = forwardRef<HTMLDivElement, CheckboxesProps>((props,
const [instance, setInstance] = useState<CheckboxesModule>();

const _boxReferences: string[] = [];
let _boxCount: number = 0;
let _boxCount = 0;
let _boxIds: Record<string, string> = {};

useImperativeHandle(forwardedRef, () => moduleRef.current!, [moduleRef]);
Expand All @@ -61,7 +61,7 @@ const CheckboxesComponent = forwardRef<HTMLDivElement, CheckboxesProps>((props,
};

const leaseReference = (): string => {
let reference: string = '';
let reference = '';
do {
reference = generateRandomName();
} while (_boxReferences.includes(reference));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type FC } from 'react';

export type CheckboxesDividerProps = {
export interface CheckboxesDividerProps {
dividerText?: string;
};
}

export const CheckboxesDivider: FC<CheckboxesDividerProps> = ({ dividerText = 'or' }) => (
<div className="nhsuk-checkboxes__divider">{dividerText}</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/form-elements/date-input/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { DateInputDay, DateInputMonth, DateInputYear } from './components/index.
import { FormGroup } from '#components/utils/index.js';
import { type FormElementProps } from '#util/types/FormTypes.js';

export type DateInputValue = {
export interface DateInputValue {
day: string;
month: string;
year: string;
};
}

export interface DateInputChangeEvent extends Omit<
ChangeEvent<DateInputElement>,
Expand Down
4 changes: 2 additions & 2 deletions src/components/form-elements/date-input/DateInputContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import { createContext, type ChangeEvent, type ReactElement } from 'react';

export type IDateInputContext = {
export interface IDateInputContext {
id: string;
name: string;
error: string | ReactElement | undefined;
value?: { day?: string; month?: string; year?: string };
defaultValue?: { day?: string; month?: string; year?: string };
handleChange: (inputType: 'day' | 'month' | 'year', event: ChangeEvent<HTMLInputElement>) => void;
};
}

export const DateInputContext = createContext<IDateInputContext>({
id: '',
Expand Down
4 changes: 2 additions & 2 deletions src/components/form-elements/radios/Radios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const RadiosComponent = forwardRef<HTMLDivElement, RadiosProps>((props, forwarde
const [instance, setInstance] = useState<RadiosModule>();
const [selectedRadio, setSelectedRadio] = useState<string>();

const _radioReferences: Array<string> = [];
const _radioReferences: string[] = [];
let _radioCount = 0;
let _radioIds: Record<string, string> = {};

Expand Down Expand Up @@ -63,7 +63,7 @@ const RadiosComponent = forwardRef<HTMLDivElement, RadiosProps>((props, forwarde
};

const leaseReference = (): string => {
let reference: string = '';
let reference = '';
do {
reference = generateRandomName();
} while (_radioReferences.includes(reference));
Expand Down
4 changes: 2 additions & 2 deletions src/components/form-elements/radios/RadiosContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import { createContext } from 'react';

export type IRadiosContext = {
export interface IRadiosContext {
name: string;
selectedRadio?: string;
getRadioId: (reference: string) => string;
setSelected: (radioRef: string) => void;
leaseReference: () => string;
unleaseReference: (reference: string) => void;
};
}

export const RadiosContext = createContext<IRadiosContext>({
name: '',
Expand Down
4 changes: 2 additions & 2 deletions src/components/navigation/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const BreadcrumbComponent = forwardRef<HTMLElement, BreadcrumbProps>((props, for

// Split off any "Item" components
const { ItemChildren, OtherChildren } = Children.toArray(children).reduce<{
ItemChildren: Array<ReactNode>;
OtherChildren: Array<ReactNode>;
ItemChildren: ReactNode[];
OtherChildren: ReactNode[];
}>(
(prev, child) => {
if (childIsOfComponentType(child, BreadcrumbItem)) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/typography/__tests__/Heading.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Heading', () => {
});

it('console.warn when headingLevel is invalid', () => {
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
// @ts-expect-error - testing invalid prop
render(<Heading headingLevel="h7" />);

Expand Down
4 changes: 2 additions & 2 deletions src/components/utils/FormGroupContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import { createContext } from 'react';

export type IFormGroupContext = {
export interface IFormGroupContext {
passError: (componentId: string, error: boolean) => void;
registerComponent: (componentId: string, deregister?: boolean) => void;
};
}

export const FormGroupContext = createContext<IFormGroupContext>({
passError: () => {},
Expand Down
4 changes: 2 additions & 2 deletions src/components/utils/__tests__/FormGroup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('FormGroup', () => {

expect(renderProps?.id).toHaveLength(11);
expect(renderProps?.id).toContain('input');
expect(renderProps!['aria-describedby']).toBe(`${renderProps?.id}--error-message`);
expect(renderProps?.['aria-describedby']).toBe(`${renderProps?.id}--error-message`);

expect(container.querySelector('.nhsuk-error-message')?.getAttribute('id')).toBe(
`${renderProps?.id}--error-message`,
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('FormGroup', () => {
);

expect(renderProps?.id).toBe('testID');
expect(renderProps!['aria-describedby']).toBe(`testID--error-message`);
expect(renderProps?.['aria-describedby']).toBe(`testID--error-message`);

expect(container.querySelector('.nhsuk-error-message')?.getAttribute('id')).toBe(
'testID--error-message',
Expand Down
12 changes: 6 additions & 6 deletions src/patterns/nav-a-z/NavAZ.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const processLetters = (
children: ReactNode,
fullAlphabet: boolean | undefined,
removedLetters: Array<string> | undefined,
disabledLetters: Array<string> | undefined,
letters: Array<string> | undefined,
removedLetters: string[] | undefined,
disabledLetters: string[] | undefined,
letters: string[] | undefined,
) => {
const letterMap = (letter: string) => {
if (removedLetters && removedLetters.includes(letter)) {
Expand Down Expand Up @@ -39,9 +39,9 @@ const processLetters = (

export interface NavAZProps extends ComponentPropsWithoutRef<'div'> {
fullAlphabet?: boolean;
removedLetters?: Array<string>;
disabledLetters?: Array<string>;
letters?: Array<string>;
removedLetters?: string[];
disabledLetters?: string[];
letters?: string[];
}

const NavAZComponent = forwardRef<HTMLElement, NavAZProps>((props, forwardedRef) => {
Expand Down
10 changes: 5 additions & 5 deletions stories/Form Elements/Checkboxes.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const meta: Meta<typeof Checkboxes> = {
export default meta;
type Story = StoryObj<typeof Checkboxes>;

type CheckboxState = {
interface CheckboxState {
box1: { name?: string; id?: string };
box2: { name?: string; id?: string };
box3: { name?: string; id?: string };
};
}

export const Standard: Story = {
name: 'Checkboxes default',
Expand Down Expand Up @@ -838,9 +838,9 @@ export const OnChangeAndOnInputHandlers: Story = {
},
},
render: function OnChangeAndOnInputHandlersRender() {
const [changeEventLog, setChangeEventLog] = useState<Array<string>>([]);
const [inputEventLog, setInputEventLog] = useState<Array<string>>([]);
const [currentValue, setCurrentValue] = useState<Array<string>>([]);
const [changeEventLog, setChangeEventLog] = useState<string[]>([]);
const [inputEventLog, setInputEventLog] = useState<string[]>([]);
const [currentValue, setCurrentValue] = useState<string[]>([]);

const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
const target = e.target as HTMLInputElement;
Expand Down
7 changes: 5 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"module": "NodeNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"resolveJsonModule": true,
"resolvePackageJsonImports": true,
"skipLibCheck": true,
"strict": false,
"strict": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
Expand Down
1 change: 0 additions & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"lib": ["ESNext", "DOM"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"sourceMap": true,
"target": "ES2015",
"types": ["node"]
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsxdev",
"module": "ESNext",
"moduleResolution": "Node",
"types": ["jest", "node"]
},
"include": [
Expand Down
Loading