-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor(web-react): Separate HelperText and ValidationText subcompon…
…ents - moved from Field component to their own subcomponents - updated imports and exports
- Loading branch information
1 parent
c1bfd89
commit bae6ed3
Showing
27 changed files
with
60 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1 @@ | ||
# Field | ||
|
||
## ValidationText | ||
|
||
The ValidationText subcomponent displays validation texts for Field components like TextField, TextArea, Checkbox, FileUploader, etc. | ||
|
||
```jsx | ||
import { ValidationText } from '@lmc-eu/spirit-web-react/components'; | ||
``` | ||
|
||
Basic example usage: | ||
|
||
```jsx | ||
<ValidationText className="Component__validationText" validationText="Danger validation text" /> | ||
``` | ||
|
||
Advanced example: | ||
|
||
```jsx | ||
<ValidationText | ||
id="component__validationText" | ||
className="Component__validationText" | ||
elementType="span" | ||
validationText="Danger validation text" | ||
role="alert" | ||
/> | ||
``` | ||
|
||
## Role Attribute | ||
|
||
When displaying text dynamically, set [`role="alert"`][aria-alert-role] on the `ValidationText` component to improve accessibility. This will help screen readers notify users about content updates. | ||
|
||
### API | ||
|
||
| Name | Type | Default | Required | Description | | ||
| ---------------- | ------------------------------- | ------- | -------- | ---------------------------------------------------------------------------------------------- | | ||
| `className` | `string` | — | ✓ | Wrapper custom class name | | ||
| `elementType` | \[`span` \| `div`] | `div` | ✕ | Type of element used as main wrapper (applied only for single validation text, otherwise `ul`) | | ||
| `id` | `string` | — | ✕ | Component id | | ||
| `role` | `string` | - | ✕ | The role attribute that describes the role of an element | | ||
| `validationText` | \[`ReactNode` \| `ReactNode[]`] | — | ✕ | Validation text, only visible if validationState is set | | ||
|
||
## HelperText | ||
|
||
The HelperText subcomponent displays helper texts for Field components like TextField, TextArea, Checkbox, FileUploader, etc. | ||
|
||
```jsx | ||
<HelperText className="Component__helperText" helperText="Helper text" /> | ||
``` | ||
|
||
Advanced example: | ||
|
||
```jsx | ||
<HelperText id="component__helperText" className="Component__helperText" elementType="span" helperText="Helper text" /> | ||
``` | ||
|
||
### API | ||
|
||
| Name | Type | Default | Required | Description | | ||
| ------------- | ------------------------------- | ------- | -------- | ---------------------------------------------------------------------------------------------- | | ||
| `className` | `string` | — | ✓ | Wrapper custom class name | | ||
| `elementType` | \[`span` \| `div`] | `div` | ✕ | Type of element used as main wrapper (applied only for single validation text, otherwise `ul`) | | ||
| `helperText` | \[`ReactNode` \| `ReactNode[]`] | — | ✕ | Validation text, only visible if validationState is | | ||
| `id` | `string` | — | ✕ | Component id | | ||
|
||
[aria-alert-role]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
'use client'; | ||
|
||
export { default as HelperText } from './HelperText'; | ||
export { default as useAriaIds } from './useAriaIds'; | ||
export { default as ValidationText } from './ValidationText'; | ||
export * from './useAriaIds'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...react/src/components/Field/HelperText.tsx → .../src/components/HelperText/HelperText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use client'; | ||
|
||
export { default as HelperText } from './HelperText'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
packages/web-react/src/components/UNSTABLE_Slider/UNSTABLE_Slider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...t/src/components/Field/ValidationText.tsx → ...ponents/ValidationText/ValidationText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/Field/__tests__/ValidationText.test.tsx → ...ionText/__tests__/ValidationText.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const A11Y_ALERT_ROLE = 'alert'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use client'; | ||
|
||
export { default as ValidationText } from './ValidationText'; | ||
export { useValidationTextRole } from './useValidationTextRole'; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ElementType } from 'react'; | ||
import { FieldProps } from 'src/components/Field/types'; | ||
import { HelperTextProps } from './shared'; | ||
|
||
export interface SpiritHelperTextProps<T extends ElementType = 'div'> extends FieldProps<T>, HelperTextProps {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ElementType } from 'react'; | ||
import { FieldProps } from 'src/components/Field/types'; | ||
import { ValidationTextProps } from './shared'; | ||
|
||
export interface SpiritValidationTextProps<T extends ElementType = 'div'> extends FieldProps<T>, ValidationTextProps {} |