Skip to content

feat: export hooks from primitives & DS #1622

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

Merged
merged 1 commit into from
Mar 5, 2024
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
6 changes: 6 additions & 0 deletions .changeset/smart-buttons-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@strapi/design-system': minor
'@strapi/ui-primitives': minor
---

feat: export helpful hooks
17 changes: 17 additions & 0 deletions packages/primitives/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ import { Select } from '@strapi/ui-primitives';
};
```

## Hook Documentation

### useCallbackRef

Converts a callback to a ref to avoid triggering re-renders when passed as a prop or avoid re-executing
effects when passed as a dependency

### useCollator

Provides localized string collation for the current locale. Automatically updates when the locale changes,
and handles caching of the collator for performance.

### useFilter

Provides localized string search functionality that is useful for filtering or matching items
in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.

## Contributing

Please follow our [CONTRIBUTING](https://github.com/strapi/design-system/blob/main/CONTRIBUTING.md) guidelines.
Expand Down
2 changes: 2 additions & 0 deletions packages/primitives/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ export * from './helpers/events';
* Hooks
* ---------------------------------------------------------------------------------------------*/
export * from './hooks/useCallbackRef';
export * from './hooks/useCollator';
export * from './hooks/useFilter';
5 changes: 5 additions & 0 deletions packages/strapi-design-system/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ export * from './Tooltip';
export * from './Typography';
export * from './VisuallyHidden';
export * from './themes';

export * from './hooks/useComposeRefs';
export * from './hooks/useDateFormatter';

export { useFilter, useCollator, type Filter, useCallbackRef, composeEventHandlers } from '@strapi/ui-primitives';