Skip to content
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

fix: start refactor hooks: useOutsideClick #1035

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
/src/components/Toaster @ogonkov
/src/components/theme @resure
/src/components/Pagination @jhoncool

/src/hooks/useOutsideClick @NikitaCG

# Allow everyone to update dependencies
/package.json
/package-lock.json
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"lint:js": "eslint --ext .js,.jsx,.ts,.tsx .",
"lint:styles": "stylelint '{styles,src}/**/*.scss'",
"lint:prettier": "prettier --check '**/*.md'",
"lint:prettier:fix": "prettier --write '**/*.md'",
"lint": "run-p lint:*",
"typecheck": "tsc --noEmit",
"prepublishOnly": "npm run build"
Expand Down
1 change: 0 additions & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,3 @@ export * from './utils/useFileInput/useFileInput';
export {useActionHandlers} from './utils/useActionHandlers';
export {useUniqId} from './utils/useUniqId';
export {getLayersCount} from './utils/LayerManager';
export * from './utils/useOutsideClick';
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './useOutsideClick';
18 changes: 18 additions & 0 deletions src/hooks/useOutsideClick/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--GITHUB_BLOCK-->

# useOutsideClick

<!--/GITHUB_BLOCK-->

```tsx
import {useOutsideClick} from '@gravity-ui/uikit';
```

The `useOutsideClick` hook helps to track the click outside of the tracked element.

## Properties

| Name | Description | Type | Default |
| :------ | :---------------------------------------------------------------- | :---------------: | :-----: |
| ref | Ref-link to target of observation | `React.RefObject` | |
| handler | Callback when a click is triggered outside the observation target | `() => void` | |
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './components';
export * from './hooks';
Loading