forked from gravity-ui/uikit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: private hooks directory (gravity-ui#1091)
- Loading branch information
1 parent
fcab088
commit 38eb167
Showing
56 changed files
with
358 additions
and
71 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
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
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
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 was deleted.
Oops, something went wrong.
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
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,11 @@ | ||
export * from './useBoolean'; | ||
export * from './useCheckbox'; | ||
export * from './useCloseOnTimeout'; | ||
export * from './useConditionallyControlledState'; | ||
export * from './useElementSize'; | ||
export * from './useHover'; | ||
export * from './usePopper'; | ||
export * from './useRadio'; | ||
export * from './useRadioGroup'; | ||
export * from './useRestoreFocus'; | ||
export * from './useUpdateEffect'; |
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,20 @@ | ||
# useBoolean | ||
|
||
The `useBoolean` hook makes typical handlers for boolean state | ||
|
||
## Properties | ||
|
||
| Name | Description | Type | Default | | ||
| :----------- | :------------ | :------------------------: | :-----: | | ||
| initialState | Boolean state | `boolean - (() => boolean` | | | ||
|
||
## Result | ||
|
||
``` | ||
[ | ||
value, // boolean | ||
setTrueCallback, // () => void | ||
setFalseCallback, // () => void | ||
toggleBooleanStateCallback, // () => void | ||
] | ||
``` |
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,2 @@ | ||
export {useBoolean} from './useBoolean'; | ||
export type {UseBooleanResult} from './useBoolean'; |
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,28 @@ | ||
# useCheckbox | ||
|
||
The `useCheckbox` hook need to generate props for checkbox control | ||
|
||
## Properties | ||
|
||
| Name | Description | Type | Default | | ||
| :------------- | :-------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----: | | ||
| name | Name | `string` | | | ||
| value | Value | `string` | | | ||
| checked | Checked flag | `boolean` | | | ||
| defaultChecked | Default checked value | `boolean` | | | ||
| indeterminate | Indeterminate flag | `boolean` | | | ||
| controlRef | Ref-link on control element | `React.Ref` | | | ||
| controlProps | Another control props | `Omit<React.InputHTMLAttributes, 'name', 'value', 'id', 'onFocus', 'onBlur', 'disabled', 'type', 'onChange', 'defaultChecked', 'checked', 'aria-checked'>` | | | ||
| disabled | Disabled flag | `boolean` | | | ||
| onUpdate | OnUpdate callback | `(checked: boolean) => void` | | | ||
| onChange | OnChange callback | `(event: React.ChangeEvent) => void` | | | ||
| onFocus | OnFocus callback | `(event: React.FocusEvent) => void` | | | ||
| onBlur | OnBlur callback | `(event: React.FocusEvent) => void` | | | ||
| id | ID attribute | `(event: React.FocusEvent) => void` | | | ||
|
||
## Result | ||
|
||
| Name | Description | Type | | ||
| :--------- | :--------------------------------- | :-----------------------------------------------: | | ||
| checked | Checked state | `boolean` | | ||
| inputProps | Props to pass to the input element | `React.InputHTMLAttributes & React.RefAttributes` | |
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,2 @@ | ||
export {useCheckbox} from './useCheckbox'; | ||
export type {UseCheckboxProps, UseCheckboxResult} from './useCheckbox'; |
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,17 @@ | ||
# useCloseOnTimeout | ||
|
||
The `useCloseOnTimeout` hook invokes callback after given amount of time unless mouse is on the element | ||
|
||
## Properties | ||
|
||
| Name | Description | Type | Default | | ||
| :------ | :---------------- | :------------: | :-----: | | ||
| onClose | On close callback | `VoidFunction` | | | ||
| timeout | Timeout | `number` | | | ||
|
||
## Result | ||
|
||
| Name | Description | Type | | ||
| :----------- | :------------------- | :-----------------------: | | ||
| onMouseOver | OnMouseOver handler | `React.MouseEventHandler` | | ||
| onMouseLeave | OnMouseLeave handler | `React.MouseEventHandler` | |
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,2 @@ | ||
export {useCloseOnTimeout} from './useCloseOnTimeout'; | ||
export type {UseCloseOnTimeoutProps, UseCloseOnTimeoutResult} from './useCloseOnTimeout'; |
14 changes: 10 additions & 4 deletions
14
src/components/utils/useCloseOnTimeout.ts → ...te/useCloseOnTimeout/useCloseOnTimeout.ts
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,2 @@ | ||
export {useConditionallyControlledState} from './useConditionallyControlledState'; | ||
export type {UseConditionallyControlledStateResult} from './useConditionallyControlledState'; |
2 changes: 1 addition & 1 deletion
2
...dState/useConditionallyControlledState.ts → ...dState/useConditionallyControlledState.ts
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.