-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: private hooks directory #1091
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7829ef7
refactor: move few hooks in hooks/private
NikitaCG 2dd1c72
refactor: move internal hooks in hooks/private directory
NikitaCG ddc2887
refactor: drop unused hooks
NikitaCG 76ca74e
refactor: fix types
NikitaCG 25d4164
refactor: fix md for private hooks
NikitaCG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this private hook? It's general, it can be used by any app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was not exported outside
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok ✅
Seems like it will be good to make it public.