feat(core): add FileSizeFormatter utility and hook (DS-5343)#427
Conversation
|
Visit the preview URL for this PR (updated for commit be66a82): https://react-koobiq-next--prs-427-c0cd70m9.web.app (expires Wed, 22 Jul 2026 15:41:59 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: fc29847d4a9e5cb1adf458c76a9b681c76e2eeff |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new locale-aware FileSizeFormatter utility to @koobiq/react-core along with a useFileSizeFormatter hook that binds the formatter to the current React Aria locale. It also reorganizes existing DateFormatter docs/stories into the Utilities/ Storybook group for consistency.
Changes:
- Add
FileSizeFormatterutility (SI/IEC support, localization, configurable precision) and export it from core utils/public API. - Add
useFileSizeFormatterhook (memoized by locale + config) and export it from core hooks/public API. - Normalize DateFormatter docs/stories location in Storybook under
Utilities/DateFormatter.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/public_api_guard/react-core.api.md | Updates public API surface to include FileSizeFormatter + useFileSizeFormatter |
| packages/core/src/utils/index.ts | Re-exports FileSizeFormatter from the core utils barrel |
| packages/core/src/utils/FileSizeFormatter/index.ts | Barrel export for the new FileSizeFormatter utility |
| packages/core/src/utils/FileSizeFormatter/FileSizeFormatter.ts | Implements localized SI/IEC file size formatting + precision handling |
| packages/core/src/utils/FileSizeFormatter/FileSizeFormatter.test.ts | Adds unit tests for formatting behavior, localization, rounding, precision clamping |
| packages/core/src/utils/FileSizeFormatter/FileSizeFormatter.stories.tsx | Adds Storybook stories for utility visualization |
| packages/core/src/utils/FileSizeFormatter/FileSizeFormatter.mdx | Adds documentation page for the new utility + hook |
| packages/core/src/hooks/useFileSizeFormatter/useFileSizeFormatter.ts | Adds hook to memoize formatter using the current locale |
| packages/core/src/hooks/useFileSizeFormatter/useFileSizeFormatter.test.tsx | Adds tests for locale binding, config application, memoization |
| packages/core/src/hooks/useFileSizeFormatter/index.ts | Barrel export for the new hook |
| packages/core/src/hooks/index.ts | Re-exports useFileSizeFormatter from the hooks barrel |
| docs/date-formatting.stories.tsx | Moves DateFormatter story into Utilities/DateFormatter and aligns table props |
| docs/11-date-formatting.mdx | Updates MDX meta/title to match the new Storybook location |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.