-
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.
fixup! Feat(web-react): Implement new HelperText component #DS-886
- Loading branch information
1 parent
f1d1d9e
commit a54fde0
Showing
11 changed files
with
117 additions
and
88 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
19 changes: 17 additions & 2 deletions
19
packages/web-react/src/components/Field/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
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,5 +1,5 @@ | ||
export * from './ValidationText'; | ||
export * from './HelperText'; | ||
export * from './useAriaDescribedBy'; | ||
export * from './useAriaIds'; | ||
export { default as ValidationText } from './ValidationText'; | ||
export { default as HelperText } from './HelperText'; |
18 changes: 0 additions & 18 deletions
18
packages/web-react/src/components/Field/useAriaDescribedBy.tsx
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
import { useCallback, useState } from 'react'; | ||
|
||
export type RegisterParams = { add?: string; remove?: string }; | ||
export type RegisterType = (params: RegisterParams) => void; | ||
export type UseAriaIdsHook = (otherAriaIds?: string) => [string[], RegisterType]; | ||
|
||
const useAriaIds: UseAriaIdsHook = (otherAriaIds) => { | ||
const [ids, setIds] = useState<string[]>(otherAriaIds ? otherAriaIds.split(' ') : []); | ||
|
||
const register = useCallback(function registerFn({ add, remove }: RegisterParams) { | ||
setIds((prevIds) => { | ||
let newIds = [...prevIds]; | ||
|
||
if (remove) { | ||
newIds = newIds.filter((item) => item !== remove); | ||
} | ||
|
||
if (add) { | ||
newIds = [...newIds, add]; | ||
} | ||
|
||
return newIds; | ||
}); | ||
}, []); | ||
|
||
return [ids, register]; | ||
}; | ||
|
||
export default 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
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
Oops, something went wrong.