Skip to content

Commit 6466161

Browse files
committed
chore: add documentation to adapter props interfaces
1 parent 8b23051 commit 6466161

File tree

24 files changed

+516
-10
lines changed

24 files changed

+516
-10
lines changed

src/components/Common/FieldLayout/FieldLayoutTypes.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,52 @@ import type { ReactNode } from 'react'
22
import type { DataAttributes } from '@/types/Helpers'
33

44
export interface SharedFieldLayoutProps extends DataAttributes {
5+
/**
6+
* Optional description text for the field
7+
*/
58
description?: ReactNode
9+
/**
10+
* Error message to display when the field is invalid
11+
*/
612
errorMessage?: string
13+
/**
14+
* Indicates if the field is required
15+
*/
716
isRequired?: boolean
17+
/**
18+
* Label text for the field
19+
*/
820
label: ReactNode
21+
/**
22+
* Hides the label visually while keeping it accessible to screen readers
23+
*/
924
shouldVisuallyHideLabel?: boolean
1025
}
1126

1227
export interface InternalFieldLayoutProps {
28+
/**
29+
* Content to be rendered inside the field layout
30+
*/
1331
children: React.ReactNode
32+
/**
33+
* ID of the form control that this label is associated with
34+
*/
1435
htmlFor: string
36+
/**
37+
* ID of the error message element
38+
*/
1539
errorMessageId: string
40+
/**
41+
* ID of the description element
42+
*/
1643
descriptionId: string
44+
/**
45+
* Additional CSS class name
46+
*/
1747
className?: string
48+
/**
49+
* Whether to show the error icon
50+
*/
1851
withErrorIcon?: boolean
1952
}
2053

src/components/Common/HorizontalFieldLayout/HorizontalFieldLayoutTypes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import type {
33
SharedFieldLayoutProps,
44
} from '../FieldLayout/FieldLayoutTypes'
55

6+
/**
7+
* Props shared by all horizontal field layouts
8+
* Extends SharedFieldLayoutProps to include common field properties
9+
*/
610
export type SharedHorizontalFieldLayoutProps = SharedFieldLayoutProps
711

12+
/**
13+
* Props for the horizontal field layout component
14+
* Combines shared field layout props with internal layout props
15+
*/
816
export type HorizontalFieldLayoutProps = SharedHorizontalFieldLayoutProps & InternalFieldLayoutProps

src/components/Common/UI/Alert/Alert.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { useEffect, useId, useRef } from 'react'
2+
import classNames from 'classnames'
23
import { type AlertProps } from './AlertTypes'
34
import styles from './Alert.module.scss'
45
import InfoIcon from '@/assets/icons/info.svg?react'
56
import SuccessIcon from '@/assets/icons/success_check.svg?react'
67
import WarningIcon from '@/assets/icons/warning.svg?react'
78
import ErrorIcon from '@/assets/icons/error.svg?react'
89

9-
export function Alert({ label, children, status = 'info', icon }: AlertProps) {
10+
export function Alert({ label, children, status = 'info', icon, className }: AlertProps) {
1011
const id = useId()
1112
const alertRef = useRef<HTMLDivElement>(null)
1213
const defaultIcon =
@@ -25,7 +26,7 @@ export function Alert({ label, children, status = 'info', icon }: AlertProps) {
2526
}, [])
2627

2728
return (
28-
<div className={styles.root}>
29+
<div className={classNames(styles.root, className)}>
2930
<div
3031
className={styles.alert}
3132
role="alert"
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import type { ReactNode } from 'react'
22

33
export interface AlertProps {
4-
/** The variant of the alert */
4+
/**
5+
* The visual status that the alert should convey
6+
*/
57
status?: 'info' | 'success' | 'warning' | 'error'
6-
/** The label text for the alert */
8+
/**
9+
* The label text for the alert
10+
*/
711
label: string
8-
/** Optional children to be rendered inside the alert */
12+
/**
13+
* Optional children to be rendered inside the alert
14+
*/
915
children?: ReactNode
10-
/** Optional custom icon component to override the default icon */
16+
/**
17+
* Optional custom icon component to override the default icon
18+
*/
1119
icon?: ReactNode
20+
/**
21+
* CSS className to be applied
22+
*/
23+
className?: string
1224
}

src/components/Common/UI/Badge/BadgeTypes.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import type { HTMLAttributes, ReactNode } from 'react'
22

33
export interface BadgeProps
44
extends Pick<HTMLAttributes<HTMLSpanElement>, 'className' | 'id' | 'aria-label'> {
5+
/**
6+
* Content to be displayed inside the badge
7+
*/
58
children: ReactNode
9+
/**
10+
* Visual style variant of the badge
11+
*/
612
status?: 'success' | 'warning' | 'error' | 'info'
713
}

src/components/Common/UI/Button/ButtonTypes.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,43 @@ export interface ButtonProps
2020
| 'title'
2121
| 'tabIndex'
2222
> {
23+
/**
24+
* React ref for the button element
25+
*/
2326
ref?: Ref<HTMLButtonElement>
27+
/**
28+
* Visual style variant of the button
29+
*/
2430
variant?: 'primary' | 'secondary' | 'tertiary' | 'icon'
31+
/**
32+
* Indicates if the button is in an error state
33+
*/
2534
isError?: boolean
35+
/**
36+
* Shows a loading spinner and disables the button
37+
*/
2638
isLoading?: boolean
39+
/**
40+
* Disables the button and prevents interaction
41+
*/
2742
isDisabled?: boolean
43+
/**
44+
* Content to be rendered inside the button
45+
*/
2846
children?: ReactNode
47+
/**
48+
* Handler for blur events
49+
*/
2950
onBlur?: ButtonFocusHandler
51+
/**
52+
* Handler for focus events
53+
*/
3054
onFocus?: ButtonFocusHandler
3155
}
3256

3357
export type ButtonIconProps = Omit<ButtonProps, 'variant'> & {
58+
/**
59+
* Required aria-label for icon buttons to ensure accessibility
60+
*/
3461
'aria-label': string
3562
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
11
export type CalendarPreviewProps = {
2+
/**
3+
* Array of dates to highlight with custom colors and labels
4+
*/
25
highlightDates?: Array<{
6+
/**
7+
* Date to highlight
8+
*/
39
date: Date
10+
/**
11+
* Color to use for highlighting
12+
*/
413
highlightColor: 'primary' | 'secondary'
14+
/**
15+
* Label text for the highlighted date
16+
*/
517
label: string
618
}>
19+
/**
20+
* Date range to display in the calendar preview
21+
*/
722
dateRange: {
23+
/**
24+
* Start date of the range
25+
*/
826
start: Date
27+
/**
28+
* End date of the range
29+
*/
930
end: Date
31+
/**
32+
* Label text for the date range
33+
*/
1034
label: string
1135
}
1236
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import type { ReactNode } from 'react'
22

33
export interface CardProps {
4-
/** Callback function when the card is selected */
4+
/**
5+
* Callback function when the card is selected
6+
*/
57
onSelect?: (checked: boolean) => void
6-
/** Content to be displayed inside the card */
8+
/**
9+
* Content to be displayed inside the card
10+
*/
711
children: ReactNode
8-
/** Optional menu component to be displayed on the right side of the card */
12+
/**
13+
* Optional menu component to be displayed on the right side of the card
14+
*/
915
menu?: ReactNode
10-
/** Additional CSS class name */
16+
/**
17+
* CSS className to be applied
18+
*/
1119
className?: string
1220
}

src/components/Common/UI/Checkbox/CheckboxTypes.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,24 @@ import type { SharedHorizontalFieldLayoutProps } from '@/components/Common/Horiz
44
export interface CheckboxProps
55
extends SharedHorizontalFieldLayoutProps,
66
Pick<InputHTMLAttributes<HTMLInputElement>, 'name' | 'id' | 'className' | 'onBlur'> {
7+
/**
8+
* Current checked state of the checkbox
9+
*/
710
value?: boolean
11+
/**
12+
* Callback when checkbox state changes
13+
*/
814
onChange?: (value: boolean) => void
15+
/**
16+
* React ref for the checkbox input element
17+
*/
918
inputRef?: Ref<HTMLInputElement>
19+
/**
20+
* Indicates if the checkbox is in an invalid state
21+
*/
1022
isInvalid?: boolean
23+
/**
24+
* Disables the checkbox and prevents interaction
25+
*/
1126
isDisabled?: boolean
1227
}

src/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,49 @@ import type { FieldsetHTMLAttributes, Ref } from 'react'
22
import type { SharedFieldLayoutProps } from '@/components/Common/FieldLayout/FieldLayoutTypes'
33

44
export type CheckboxGroupOption = {
5+
/**
6+
* Label text or content for the checkbox option
7+
*/
58
label: React.ReactNode
9+
/**
10+
* Value of the option that will be passed to onChange
11+
*/
612
value: string
13+
/**
14+
* Disables this specific checkbox option
15+
*/
716
isDisabled?: boolean
17+
/**
18+
* Optional description text for the checkbox option
19+
*/
820
description?: React.ReactNode
921
}
1022

1123
export interface CheckboxGroupProps
1224
extends SharedFieldLayoutProps,
1325
Pick<FieldsetHTMLAttributes<HTMLFieldSetElement>, 'className'> {
26+
/**
27+
* Indicates if the checkbox group is in an invalid state
28+
*/
1429
isInvalid?: boolean
30+
/**
31+
* Disables all checkbox options in the group
32+
*/
1533
isDisabled?: boolean
34+
/**
35+
* Array of checkbox options to display
36+
*/
1637
options: Array<CheckboxGroupOption>
38+
/**
39+
* Array of currently selected values
40+
*/
1741
value?: string[]
42+
/**
43+
* Callback when selection changes
44+
*/
1845
onChange?: (value: string[]) => void
46+
/**
47+
* React ref for the first checkbox input element
48+
*/
1949
inputRef?: Ref<HTMLInputElement>
2050
}

src/components/Common/UI/ComboBox/ComboBoxTypes.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,49 @@ import type { InputHTMLAttributes, Ref, FocusEvent } from 'react'
22
import type { SharedFieldLayoutProps } from '@/components/Common/FieldLayout/FieldLayoutTypes'
33

44
export interface ComboBoxOption {
5+
/**
6+
* Display text for the option
7+
*/
58
label: string
9+
/**
10+
* Value of the option that will be passed to onChange
11+
*/
612
value: string
713
}
814

915
export interface ComboBoxProps
1016
extends SharedFieldLayoutProps,
1117
Pick<InputHTMLAttributes<HTMLInputElement>, 'className' | 'id' | 'name' | 'placeholder'> {
18+
/**
19+
* Disables the combo box and prevents interaction
20+
*/
1221
isDisabled?: boolean
22+
/**
23+
* Indicates if the combo box is in an invalid state
24+
*/
1325
isInvalid?: boolean
26+
/**
27+
* Label text for the combo box field
28+
*/
1429
label: string
30+
/**
31+
* Callback when selection changes
32+
*/
1533
onChange?: (value: string) => void
34+
/**
35+
* Handler for blur events
36+
*/
1637
onBlur?: (e: FocusEvent) => void
38+
/**
39+
* Array of options to display in the dropdown
40+
*/
1741
options: ComboBoxOption[]
42+
/**
43+
* Currently selected value
44+
*/
1845
value?: string
46+
/**
47+
* React ref for the combo box input element
48+
*/
1949
inputRef?: Ref<HTMLInputElement>
2050
}

0 commit comments

Comments
 (0)