@gateweb/react-utils
v2.7.4
Published
React Utils for GateWeb
Readme
@gateweb/react-utils
@gateweb/react-utils 是 GateWeb 的 TypeScript-first utility library,包含常用的 functions / hooks / types(日期、格式化、轉換、驗證、web、React hooks 等),並且有測試與自動化文件。
This repo also provides a docs site + auto-generated API reference.
✨ Features
- React Hooks: A collection of useful hooks like
useCountdownanduseValue. - Date Utilities: Powerful and flexible functions for handling dates and time periods, built on top of
dayjs. - Core Helpers: A wide range of utilities for type conversion (
bytes,searchParams), case style formatting, object manipulation, and more. - Web APIs: Simplified functions for common web tasks like file downloads (
download) and managing browser storage (webStorage). - Validation: A set of predefined regex patterns and validation functions for common data types.
- TypeScript First: Fully written in TypeScript, providing excellent type safety and autocompletion out of the box.
- Lightweight & Tree-Shakable: Built with
buncheeto ensure minimal bundle size.
📦 Installation
# With pnpm (recommended)
pnpm add @gateweb/react-utils
# With npm
npm install @gateweb/react-utils
# With yarn
yarn add @gateweb/react-utils🚀 快速開始(Quick Start)
import { bytesToSize } from '@gateweb/react-utils';
bytesToSize(1024);更多範例與用法請看 react-utils docs
🤝 Contributing
Contributions are welcome! To ensure a smooth development process, please follow these steps:
Fork & Clone: Fork the repository and clone it to your local machine.
Set Up: This project uses
pnpmas the package manager. Install dependencies with:pnpm installDevelop: Create a new branch for your feature or bug fix.
Test: Write tests for your changes and ensure all existing tests pass.
# Run all tests pnpm test # Run tests in watch mode pnpm test:watchSubmit a Pull Request: Push your changes to your fork and open a pull request to the
mainbranch. Your code will be automatically linted and formatted upon commit.
Publishing (For Maintainers)
Manual Release
- Update the version in
package.json. - Install dependencies and build the package:
pnpm install && pnpm build - Log in to npm:
pnpm login - Publish the package:
pnpm publish --access public --no-git-checks
Automatic Release
When a pull request is merged into the main branch, the release GitHub Action will automatically bump the version, create a changelog, and publish the new version to npm. The version bump follows Semantic Versioning based on the commit messages (e.g., feat: for minor, fix: for patch).
