@devua-lab/ui-utils
v2.2.7
Published
A collection of utilities, decorators, React hooks, and TypeScript types for building consistent, predictable application layers.
Readme
@devua-lab/ui-utils
A collection of utilities, decorators, React hooks, and TypeScript types for building consistent, predictable application layers.
Installation
npm install @devua-lab/ui-utilsyarn add @devua-lab/ui-utilspnpm add @devua-lab/ui-utilsUtils
| Name | Description |
| :--- | :--- |
| CleanSense | Recursive empty-value filter with context-aware rule overrides. |
| diff | Structural diff that returns only what changed, keeping arrays whole. |
| Enums | Extracts a TypeScript enum into a clean { key, value }[] without reverse-mapping noise. |
| error-serialization | Standardized error serialization pipeline for Zod, Axios, and native errors. |
| Money | Cents ↔ float conversion — precise, nullish-safe, string-aware. |
| DateTime | Format a date as an absolute string or a relative time — timezone-aware, nullish-safe. |
React
| Name | Description |
| :--- | :--- |
| useContract | Runs an async procedure as a tracked unit with automatic error serialization. |
| useDebounce | Debounced state — an immediate value plus a copy that lags behind until updates pause. |
| useEvent | A tiny keyed event bus on zustand to emit payloads from anywhere and subscribe in React. |
| usePing | Payload-less event bus to bump a counter so consumers re-run, refetch, or re-render. |
| useThrottle | Throttled state — an immediate value plus a copy that updates at most once per interval. |
| useViewport | Reactive mobile breakpoint — returns true when the viewport is at or below a given width. |
Decorator
| Name | Description |
| :--- | :--- |
| @Tracked | Tags a function with a stable contract ID and serializer for useContract integration. |
| @Validate | Validates a method's arguments positionally against Zod schemas before execution. |
Types
| Name | Description |
| :--- | :--- |
| DeepPartial | Recursively makes every property optional, preserving arrays and tuples whole. |
| ExpectedAny | An intentional, lint-safe escape hatch for any. |
| Nullable | A value that may be of type T or explicitly null. |
| Nullish | A value that may be of type T, null, or undefined. |
