@med_ghoul/forge-shared 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.d.cts +19 -0
- package/dist/hooks/index.d.ts +19 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/use-back-to-top/index.cjs +1 -0
- package/dist/hooks/use-back-to-top/index.d.cts +2 -0
- package/dist/hooks/use-back-to-top/index.d.ts +2 -0
- package/dist/hooks/use-back-to-top/index.js +1 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.cjs +1 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.d.cts +33 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.d.ts +33 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.js +1 -0
- package/dist/hooks/use-boolean/index.cjs +1 -0
- package/dist/hooks/use-boolean/index.d.cts +2 -0
- package/dist/hooks/use-boolean/index.d.ts +2 -0
- package/dist/hooks/use-boolean/index.js +1 -0
- package/dist/hooks/use-boolean/use-boolean.cjs +1 -0
- package/dist/hooks/use-boolean/use-boolean.d.cts +29 -0
- package/dist/hooks/use-boolean/use-boolean.d.ts +29 -0
- package/dist/hooks/use-boolean/use-boolean.js +1 -0
- package/dist/hooks/use-client-rect/index.cjs +1 -0
- package/dist/hooks/use-client-rect/index.d.cts +2 -0
- package/dist/hooks/use-client-rect/index.d.ts +2 -0
- package/dist/hooks/use-client-rect/index.js +1 -0
- package/dist/hooks/use-client-rect/use-client-rect.cjs +1 -0
- package/dist/hooks/use-client-rect/use-client-rect.d.cts +29 -0
- package/dist/hooks/use-client-rect/use-client-rect.d.ts +29 -0
- package/dist/hooks/use-client-rect/use-client-rect.js +1 -0
- package/dist/hooks/use-cookies/index.cjs +1 -0
- package/dist/hooks/use-cookies/index.d.cts +2 -0
- package/dist/hooks/use-cookies/index.d.ts +2 -0
- package/dist/hooks/use-cookies/index.js +1 -0
- package/dist/hooks/use-cookies/use-cookies.cjs +1 -0
- package/dist/hooks/use-cookies/use-cookies.d.cts +40 -0
- package/dist/hooks/use-cookies/use-cookies.d.ts +40 -0
- package/dist/hooks/use-cookies/use-cookies.js +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.cjs +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.d.cts +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.d.ts +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.js +1 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.cjs +1 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.d.cts +26 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.d.ts +26 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.js +1 -0
- package/dist/hooks/use-countdown-date/index.cjs +1 -0
- package/dist/hooks/use-countdown-date/index.d.cts +1 -0
- package/dist/hooks/use-countdown-date/index.d.ts +1 -0
- package/dist/hooks/use-countdown-date/index.js +1 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.cjs +1 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.d.cts +29 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.d.ts +29 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.js +1 -0
- package/dist/hooks/use-countdown-seconds/index.cjs +1 -0
- package/dist/hooks/use-countdown-seconds/index.d.cts +2 -0
- package/dist/hooks/use-countdown-seconds/index.d.ts +2 -0
- package/dist/hooks/use-countdown-seconds/index.js +1 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.cjs +1 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.d.cts +35 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.d.ts +35 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.js +1 -0
- package/dist/hooks/use-debounce/index.cjs +1 -0
- package/dist/hooks/use-debounce/index.d.cts +1 -0
- package/dist/hooks/use-debounce/index.d.ts +1 -0
- package/dist/hooks/use-debounce/index.js +1 -0
- package/dist/hooks/use-debounce/use-debounce.cjs +1 -0
- package/dist/hooks/use-debounce/use-debounce.d.cts +21 -0
- package/dist/hooks/use-debounce/use-debounce.d.ts +21 -0
- package/dist/hooks/use-debounce/use-debounce.js +1 -0
- package/dist/hooks/use-double-click/index.cjs +1 -0
- package/dist/hooks/use-double-click/index.d.cts +2 -0
- package/dist/hooks/use-double-click/index.d.ts +2 -0
- package/dist/hooks/use-double-click/index.js +1 -0
- package/dist/hooks/use-double-click/use-double-click.cjs +1 -0
- package/dist/hooks/use-double-click/use-double-click.d.cts +28 -0
- package/dist/hooks/use-double-click/use-double-click.d.ts +28 -0
- package/dist/hooks/use-double-click/use-double-click.js +1 -0
- package/dist/hooks/use-is-client/index.cjs +1 -0
- package/dist/hooks/use-is-client/index.d.cts +1 -0
- package/dist/hooks/use-is-client/index.d.ts +1 -0
- package/dist/hooks/use-is-client/index.js +1 -0
- package/dist/hooks/use-is-client/use-is-client.cjs +1 -0
- package/dist/hooks/use-is-client/use-is-client.d.cts +18 -0
- package/dist/hooks/use-is-client/use-is-client.d.ts +18 -0
- package/dist/hooks/use-is-client/use-is-client.js +1 -0
- package/dist/hooks/use-local-storage/index.cjs +1 -0
- package/dist/hooks/use-local-storage/index.d.cts +1 -0
- package/dist/hooks/use-local-storage/index.d.ts +1 -0
- package/dist/hooks/use-local-storage/index.js +1 -0
- package/dist/hooks/use-local-storage/use-local-storage.cjs +1 -0
- package/dist/hooks/use-local-storage/use-local-storage.d.cts +38 -0
- package/dist/hooks/use-local-storage/use-local-storage.d.ts +38 -0
- package/dist/hooks/use-local-storage/use-local-storage.js +1 -0
- package/dist/hooks/use-multi-select/index.cjs +1 -0
- package/dist/hooks/use-multi-select/index.d.cts +2 -0
- package/dist/hooks/use-multi-select/index.d.ts +2 -0
- package/dist/hooks/use-multi-select/index.js +1 -0
- package/dist/hooks/use-multi-select/use-multi-select.cjs +1 -0
- package/dist/hooks/use-multi-select/use-multi-select.d.cts +55 -0
- package/dist/hooks/use-multi-select/use-multi-select.d.ts +55 -0
- package/dist/hooks/use-multi-select/use-multi-select.js +1 -0
- package/dist/hooks/use-popover/index.cjs +1 -0
- package/dist/hooks/use-popover/index.d.cts +2 -0
- package/dist/hooks/use-popover/index.d.ts +2 -0
- package/dist/hooks/use-popover/index.js +1 -0
- package/dist/hooks/use-popover/use-popover.cjs +1 -0
- package/dist/hooks/use-popover/use-popover.d.cts +35 -0
- package/dist/hooks/use-popover/use-popover.d.ts +35 -0
- package/dist/hooks/use-popover/use-popover.js +1 -0
- package/dist/hooks/use-popover-hover/index.cjs +1 -0
- package/dist/hooks/use-popover-hover/index.d.cts +2 -0
- package/dist/hooks/use-popover-hover/index.d.ts +2 -0
- package/dist/hooks/use-popover-hover/index.js +1 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.cjs +1 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.d.cts +41 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.d.ts +41 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.js +1 -0
- package/dist/hooks/use-scroll-offset-top/index.cjs +1 -0
- package/dist/hooks/use-scroll-offset-top/index.d.cts +2 -0
- package/dist/hooks/use-scroll-offset-top/index.d.ts +2 -0
- package/dist/hooks/use-scroll-offset-top/index.js +1 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.cjs +1 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.d.cts +28 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.d.ts +28 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.js +1 -0
- package/dist/hooks/use-set-state/index.cjs +1 -0
- package/dist/hooks/use-set-state/index.d.cts +1 -0
- package/dist/hooks/use-set-state/index.d.ts +1 -0
- package/dist/hooks/use-set-state/index.js +1 -0
- package/dist/hooks/use-set-state/use-set-state.cjs +1 -0
- package/dist/hooks/use-set-state/use-set-state.d.cts +32 -0
- package/dist/hooks/use-set-state/use-set-state.d.ts +32 -0
- package/dist/hooks/use-set-state/use-set-state.js +1 -0
- package/dist/hooks/use-tabs/index.cjs +1 -0
- package/dist/hooks/use-tabs/index.d.cts +2 -0
- package/dist/hooks/use-tabs/index.d.ts +2 -0
- package/dist/hooks/use-tabs/index.js +1 -0
- package/dist/hooks/use-tabs/use-tabs.cjs +1 -0
- package/dist/hooks/use-tabs/use-tabs.d.cts +58 -0
- package/dist/hooks/use-tabs/use-tabs.d.ts +58 -0
- package/dist/hooks/use-tabs/use-tabs.js +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +2 -0
- package/dist/utils/active-link/active-link.cjs +1 -0
- package/dist/utils/active-link/active-link.d.cts +27 -0
- package/dist/utils/active-link/active-link.d.ts +27 -0
- package/dist/utils/active-link/active-link.js +1 -0
- package/dist/utils/active-link/index.cjs +1 -0
- package/dist/utils/active-link/index.d.cts +1 -0
- package/dist/utils/active-link/index.d.ts +1 -0
- package/dist/utils/active-link/index.js +1 -0
- package/dist/utils/classes/classes.cjs +1 -0
- package/dist/utils/classes/classes.d.cts +25 -0
- package/dist/utils/classes/classes.d.ts +25 -0
- package/dist/utils/classes/classes.js +1 -0
- package/dist/utils/classes/index.cjs +1 -0
- package/dist/utils/classes/index.d.cts +1 -0
- package/dist/utils/classes/index.d.ts +1 -0
- package/dist/utils/classes/index.js +1 -0
- package/dist/utils/color/color.cjs +2 -0
- package/dist/utils/color/color.d.cts +52 -0
- package/dist/utils/color/color.d.ts +52 -0
- package/dist/utils/color/color.js +2 -0
- package/dist/utils/color/index.cjs +2 -0
- package/dist/utils/color/index.d.cts +1 -0
- package/dist/utils/color/index.d.ts +1 -0
- package/dist/utils/color/index.js +2 -0
- package/dist/utils/cookies/cookies.cjs +1 -0
- package/dist/utils/cookies/cookies.d.cts +42 -0
- package/dist/utils/cookies/cookies.d.ts +42 -0
- package/dist/utils/cookies/cookies.js +1 -0
- package/dist/utils/cookies/index.cjs +1 -0
- package/dist/utils/cookies/index.d.cts +1 -0
- package/dist/utils/cookies/index.d.ts +1 -0
- package/dist/utils/cookies/index.js +1 -0
- package/dist/utils/css-variables/css-variables.cjs +1 -0
- package/dist/utils/css-variables/css-variables.d.cts +14 -0
- package/dist/utils/css-variables/css-variables.d.ts +14 -0
- package/dist/utils/css-variables/css-variables.js +1 -0
- package/dist/utils/css-variables/index.cjs +1 -0
- package/dist/utils/css-variables/index.d.cts +1 -0
- package/dist/utils/css-variables/index.d.ts +1 -0
- package/dist/utils/css-variables/index.js +1 -0
- package/dist/utils/font/font.cjs +1 -0
- package/dist/utils/font/font.d.cts +37 -0
- package/dist/utils/font/font.d.ts +37 -0
- package/dist/utils/font/font.js +1 -0
- package/dist/utils/font/index.cjs +1 -0
- package/dist/utils/font/index.d.cts +1 -0
- package/dist/utils/font/index.d.ts +1 -0
- package/dist/utils/font/index.js +1 -0
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.d.cts +13 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/local-storage/index.cjs +1 -0
- package/dist/utils/local-storage/index.d.cts +1 -0
- package/dist/utils/local-storage/index.d.ts +1 -0
- package/dist/utils/local-storage/index.js +1 -0
- package/dist/utils/local-storage/local-storage.cjs +1 -0
- package/dist/utils/local-storage/local-storage.d.cts +43 -0
- package/dist/utils/local-storage/local-storage.d.ts +43 -0
- package/dist/utils/local-storage/local-storage.js +1 -0
- package/dist/utils/object/index.cjs +1 -0
- package/dist/utils/object/index.d.cts +1 -0
- package/dist/utils/object/index.d.ts +1 -0
- package/dist/utils/object/index.js +1 -0
- package/dist/utils/object/object.cjs +1 -0
- package/dist/utils/object/object.d.cts +26 -0
- package/dist/utils/object/object.d.ts +26 -0
- package/dist/utils/object/object.js +1 -0
- package/dist/utils/refs/index.cjs +1 -0
- package/dist/utils/refs/index.d.cts +1 -0
- package/dist/utils/refs/index.d.ts +1 -0
- package/dist/utils/refs/index.js +1 -0
- package/dist/utils/refs/refs.cjs +1 -0
- package/dist/utils/refs/refs.d.cts +3 -0
- package/dist/utils/refs/refs.d.ts +3 -0
- package/dist/utils/refs/refs.js +1 -0
- package/dist/utils/right-to-left/index.cjs +1 -0
- package/dist/utils/right-to-left/index.d.cts +1 -0
- package/dist/utils/right-to-left/index.d.ts +1 -0
- package/dist/utils/right-to-left/index.js +1 -0
- package/dist/utils/right-to-left/right-to-left.cjs +1 -0
- package/dist/utils/right-to-left/right-to-left.d.cts +13 -0
- package/dist/utils/right-to-left/right-to-left.d.ts +13 -0
- package/dist/utils/right-to-left/right-to-left.js +1 -0
- package/dist/utils/transform-number/index.cjs +1 -0
- package/dist/utils/transform-number/index.d.cts +1 -0
- package/dist/utils/transform-number/index.d.ts +1 -0
- package/dist/utils/transform-number/index.js +1 -0
- package/dist/utils/transform-number/transform-number.cjs +1 -0
- package/dist/utils/transform-number/transform-number.d.cts +31 -0
- package/dist/utils/transform-number/transform-number.d.ts +31 -0
- package/dist/utils/transform-number/transform-number.js +1 -0
- package/dist/utils/url/index.cjs +1 -0
- package/dist/utils/url/index.d.cts +1 -0
- package/dist/utils/url/index.d.ts +1 -0
- package/dist/utils/url/index.js +1 -0
- package/dist/utils/url/url.cjs +1 -0
- package/dist/utils/url/url.d.cts +74 -0
- package/dist/utils/url/url.d.ts +74 -0
- package/dist/utils/url/url.js +1 -0
- package/dist/utils/uuidv4/index.cjs +1 -0
- package/dist/utils/uuidv4/index.d.cts +1 -0
- package/dist/utils/uuidv4/index.d.ts +1 -0
- package/dist/utils/uuidv4/index.js +1 -0
- package/dist/utils/uuidv4/uuidv4.cjs +1 -0
- package/dist/utils/uuidv4/uuidv4.d.cts +12 -0
- package/dist/utils/uuidv4/uuidv4.d.ts +12 -0
- package/dist/utils/uuidv4/uuidv4.js +1 -0
- package/package.json +113 -0
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# forge-shared
|
|
2
|
+
|
|
3
|
+
A collection of reusable React hooks and utility functions for modern web development.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎣 **React Hooks** - Custom hooks for common patterns
|
|
8
|
+
- 🛠️ **Utilities** - Helper functions for everyday tasks
|
|
9
|
+
- 📦 **Tree-shakeable** - Import only what you need
|
|
10
|
+
- 🔒 **Type-safe** - Full TypeScript support
|
|
11
|
+
- ✅ **Well-tested** - Comprehensive test coverage
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
This package requires **Bun** (v1.1+) as the package manager.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bun install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Import Everything
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { useBoolean, useDebounce, classes, cookies } from 'forge-shared';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Import Specific Modules
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// Hooks only
|
|
33
|
+
import { useBoolean, useDebounce } from 'forge-shared/hooks';
|
|
34
|
+
|
|
35
|
+
// Utils only
|
|
36
|
+
import { classes, cookies } from 'forge-shared/utils';
|
|
37
|
+
|
|
38
|
+
// Specific hook
|
|
39
|
+
import { useBoolean } from 'forge-shared/hooks/use-boolean';
|
|
40
|
+
|
|
41
|
+
// Specific util
|
|
42
|
+
import { classes } from 'forge-shared/utils/classes';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Available Hooks
|
|
46
|
+
|
|
47
|
+
- `use-back-to-top` - Scroll to top functionality
|
|
48
|
+
- `use-boolean` - Boolean state management
|
|
49
|
+
- `use-client-rect` - Get client rectangle dimensions
|
|
50
|
+
- `use-cookies` - Cookie management
|
|
51
|
+
- `use-copy-to-clipboard` - Copy text to clipboard
|
|
52
|
+
- `use-countdown-date` - Countdown to a specific date
|
|
53
|
+
- `use-countdown-seconds` - Countdown timer in seconds
|
|
54
|
+
- `use-debounce` - Debounce values
|
|
55
|
+
- `use-double-click` - Handle double click events
|
|
56
|
+
- `use-is-client` - Check if running on client
|
|
57
|
+
- `use-local-storage` - LocalStorage management
|
|
58
|
+
- `use-multi-select` - Multi-select state management
|
|
59
|
+
- `use-popover` - Popover state management
|
|
60
|
+
- `use-popover-hover` - Hover-based popover
|
|
61
|
+
- `use-scroll-offset-top` - Track scroll offset from top
|
|
62
|
+
- `use-set-state` - SetState-like hook
|
|
63
|
+
- `use-tabs` - Tab state management
|
|
64
|
+
|
|
65
|
+
## Available Utils
|
|
66
|
+
|
|
67
|
+
- `active-link` - Active link detection
|
|
68
|
+
- `classes` - CSS class name utilities
|
|
69
|
+
- `color` - Color manipulation utilities
|
|
70
|
+
- `cookies` - Cookie utilities
|
|
71
|
+
- `css-variables` - CSS variable utilities
|
|
72
|
+
- `font` - Font utilities
|
|
73
|
+
- `local-storage` - LocalStorage utilities
|
|
74
|
+
- `object` - Object manipulation utilities
|
|
75
|
+
- `refs` - Ref utilities
|
|
76
|
+
- `right-to-left` - RTL support utilities
|
|
77
|
+
- `transform-number` - Number transformation utilities
|
|
78
|
+
- `url` - URL utilities
|
|
79
|
+
- `uuidv4` - UUID v4 generation
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
### Prerequisites
|
|
84
|
+
|
|
85
|
+
- [Bun](https://bun.sh) v1.1.38 or higher
|
|
86
|
+
- Node.js (for npm publishing if needed)
|
|
87
|
+
|
|
88
|
+
### Setup
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Install dependencies
|
|
92
|
+
bun install
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Scripts
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Development (watch mode)
|
|
99
|
+
bun run dev
|
|
100
|
+
|
|
101
|
+
# Build
|
|
102
|
+
bun run build
|
|
103
|
+
|
|
104
|
+
# Run tests
|
|
105
|
+
bun run test
|
|
106
|
+
|
|
107
|
+
# Watch tests
|
|
108
|
+
bun run test:watch
|
|
109
|
+
|
|
110
|
+
# Lint
|
|
111
|
+
bun run lint
|
|
112
|
+
|
|
113
|
+
# Fix linting issues
|
|
114
|
+
bun run lint:fix
|
|
115
|
+
|
|
116
|
+
# Format code
|
|
117
|
+
bun run fm:fix
|
|
118
|
+
|
|
119
|
+
# Check formatting
|
|
120
|
+
bun run fm:check
|
|
121
|
+
|
|
122
|
+
# Type checking
|
|
123
|
+
bun run check-types
|
|
124
|
+
|
|
125
|
+
# Clean build artifacts
|
|
126
|
+
bun run clean
|
|
127
|
+
|
|
128
|
+
# Rebuild from scratch
|
|
129
|
+
bun run re:build
|
|
130
|
+
|
|
131
|
+
# Update dependencies
|
|
132
|
+
bun run check:update
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Project Structure
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
forge-shared/
|
|
139
|
+
├── src/
|
|
140
|
+
│ ├── hooks/ # React hooks
|
|
141
|
+
│ └── utils/ # Utility functions
|
|
142
|
+
├── dist/ # Build output
|
|
143
|
+
├── package.json
|
|
144
|
+
├── tsconfig.json
|
|
145
|
+
├── eslint.config.mjs
|
|
146
|
+
├── tsup.config.ts
|
|
147
|
+
└── vitest.config.ts
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Requirements
|
|
151
|
+
|
|
152
|
+
- React ^18.0.0 || ^19.0.0
|
|
153
|
+
- React DOM ^18.0.0 || ^19.0.0
|
|
154
|
+
- TypeScript ^5.0.0
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT © MedOx
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var L=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var W=(e,t)=>{for(var o in t)L(e,o,{get:t[o],enumerable:!0})},N=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _(t))!$.call(e,n)&&n!==o&&L(e,n,{get:()=>t[n],enumerable:!(r=B(t,n))||r.enumerable});return e};var J=e=>N(L({},"__esModule",{value:!0}),e);var de={};W(de,{updateSelectedItems:()=>j,useBackToTop:()=>ee,useBoolean:()=>G,useClientRect:()=>oe,useCookies:()=>K,useCopyToClipboard:()=>fe,useCountdownDate:()=>ae,useCountdownSeconds:()=>pe,useDebounce:()=>Q,useDoubleClick:()=>re,useIsClient:()=>Z,useLocalStorage:()=>ie,useMultiSelect:()=>ne,usePopover:()=>q,usePopoverHover:()=>le,useScrollOffsetTop:()=>ue,useSetState:()=>X,useTabs:()=>Y});module.exports=J(de);var k=require("react");function Y(e=!1){let[t,o]=(0,k.useState)(e),r=(0,k.useCallback)((i,s)=>{o(s)},[]),n=(0,k.useCallback)(()=>{o(e)},[e]);return{value:t,setValue:o,onChange:r,reset:n}}var x=require("react");function G(e=!1){let[t,o]=(0,x.useState)(e),r=(0,x.useCallback)(()=>{o(!0)},[]),n=(0,x.useCallback)(()=>{o(!1)},[]),i=(0,x.useCallback)(()=>{o(s=>!s)},[]);return{value:t,onTrue:r,onFalse:n,onToggle:i,setValue:o}}var E=require("react");function q(){let[e,t]=(0,E.useState)(null),o=(0,E.useCallback)(n=>{t(n.currentTarget)},[]),r=(0,E.useCallback)(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:o,onClose:r,setAnchorEl:t}}var m=require("react");function A(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,n=decodeURIComponent(document.cookie).split("; ").find(s=>s.startsWith(t));if(!n)return null;let i=n.substring(t.length);try{return JSON.parse(i)}catch{return i}}catch(t){return console.error("Error retrieving cookie:",t),null}}function U(e,t,o){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:n="Strict",secure:i=!1,path:s="/",domain:a}=o??{};try{let l=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),u=[`${e}=${l}`,`path=${s}`,n&&`SameSite=${n}`,i&&"Secure",a&&`domain=${a}`];if(r>0){let p=new Date(Date.now()+r*24*60*60*1e3);u.push(`expires=${p.toUTCString()}`)}document.cookie=u.filter(Boolean).join("; ")}catch(l){console.error("Error setting cookie:",l)}}function P(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:o="/",domain:r}=t??{};try{let n=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${o}`,r&&`domain=${r}`,"Secure"];document.cookie=n.filter(Boolean).join("; ")}catch(n){console.error("Error removing cookie:",n)}}function K(e,t,o){let{initializeWithValue:r=!0,...n}=o??{},i=t&&typeof t=="object",[s,a]=(0,m.useState)(t);(0,m.useEffect)(()=>{let c=A(e);c?a(i?S=>({...S,...c}):c):t&&r&&U(e,t,n)},[]);let l=(0,m.useCallback)(c=>{i?a(S=>{let I={...S,...c};return U(e,I,n),I}):(U(e,c,n),a(c))},[n,i,e]),u=(0,m.useCallback)((c,S)=>{i&&l({[c]:S})},[i,l]),p=(0,m.useCallback)(c=>{a(c??t),P(e)},[t,e]);return(0,m.useMemo)(()=>({state:s,setState:l,setField:u,resetState:p}),[p,u,l,s])}var M=require("react");function Q(e,t=1e3){let[o,r]=(0,M.useState)(e);return(0,M.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),o}var C=require("react");function X(e){let[t,o]=(0,C.useState)(e),r=(0,C.useCallback)(s=>{o(a=>({...a,...s}))},[]),n=(0,C.useCallback)((s,a)=>{r({[s]:a})},[r]),i=(0,C.useCallback)(s=>{o(s??e)},[e]);return{state:t,setState:r,setField:n,resetState:i}}var O=require("react");function Z(){let[e,t]=(0,O.useState)(!1);return(0,O.useEffect)(()=>{t(!0)},[]),e}var g=require("react");function ee(e,t){let[o,r]=(0,g.useState)(!1),n=te(e),i=(0,g.useCallback)(()=>{let l=window.innerHeight,u=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(u/(p-l)*100);if(n.type==="percentage")r(f>=n.value);else{let c=p-l-u;r(n.value>=c)}},[n.type,n.value]),s=(0,g.useMemo)(()=>{let l;return()=>{clearTimeout(l),l=setTimeout(i,100)}},[i]);return(0,g.useEffect)(()=>{let l=t?s:i;return window.addEventListener("scroll",l),()=>{window.removeEventListener("scroll",l)}},[s,i,t]),{isVisible:o,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:r}}function te(e){let t,o;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");o="percentage"}else throw new Error("String input must end with %");else t=e,o="number";return{value:t,type:o}}var d=require("react");function oe(e,t){let o=(0,d.useRef)(null),r=e||o,[n,i]=(0,d.useState)(void 0),[s,a]=(0,d.useState)(void 0),l=typeof window<"u"?d.useLayoutEffect:d.useEffect,u=(0,d.useCallback)(()=>{if(r.current){let c=r.current.getBoundingClientRect();i(c),a({scrollWidth:r.current.scrollWidth,scrollHeight:r.current.scrollHeight})}},[r]);l(()=>{u()},[u]),(0,d.useEffect)(()=>{let c=t||"resize";return window.addEventListener(c,u),()=>{window.removeEventListener(c,u)}},[t,u]);let p=(0,d.useMemo)(()=>n,[n]),f=(0,d.useMemo)(()=>s,[s]);return{elementRef:r,top:p?.top??0,right:p?.right??0,bottom:p?.bottom??0,left:p?.left??0,x:p?.x??0,y:p?.y??0,width:p?.width??0,height:p?.height??0,scrollWidth:f?.scrollWidth??0,scrollHeight:f?.scrollHeight??0}}var h=require("react");function ne(e,t){let[o,r]=(0,h.useState)(t??[]),n=(0,h.useCallback)(l=>{r(u=>j(u,l))},[]),i=(0,h.useCallback)(()=>{r(l=>l.length===e.length?[]:e)},[e]),s=(0,h.useCallback)(()=>{r([])},[]),a=(0,h.useMemo)(()=>o.length===0?"unchecked":o.length===e.length?"checked":"indeterminate",[e.length,o.length]);return{values:o,status:a,setValues:r,onSelectAllItems:i,onDeSelectAllItems:s,onToggleSelectItem:n}}function j(e,t){return e.includes(t)?e.filter(o=>o!==t):[...e,t]}var w=require("react");function re({click:e,doubleClick:t,timeout:o=250}){let r=(0,w.useRef)(null),n=(0,w.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return(0,w.useCallback)(s=>{n(),e&&s.detail===1&&(r.current=setTimeout(()=>{e(s)},o)),s.detail%2===0&&t(s)},[e,t,o,n])}var T=require("react");function F(e,t){if(!se())return t??null;let o=localStorage.getItem(e);if(o!=="undefined"){if(o)try{return JSON.parse(o)}catch{return o??t??null}return t??null}}function D(e,t){try{let o=JSON.stringify(t);window.localStorage.setItem(e,o)}catch(o){console.error("Error while setting storage:",o)}}function z(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function se(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function ie(e,t,o){let{initializeWithValue:r=!0}=o??{},n=t&&typeof t=="object",[i,s]=(0,T.useState)(t);(0,T.useEffect)(()=>{let f=F(e);f?s(n?c=>({...c,...f}):f):t&&r&&D(e,t)},[]);let a=(0,T.useCallback)(f=>{n?s(c=>{let S={...c,...f};return D(e,S),S}):(D(e,f),s(f))},[e,n]),l=(0,T.useCallback)((f,c)=>{n&&a({[f]:c})},[n,a]),u=(0,T.useCallback)(f=>{s(f??t),z(e)},[t,e]);return(0,T.useMemo)(()=>({state:i,setState:a,setField:l,resetState:u}),[u,l,a,i])}var y=require("react");function le(e){let t=(0,y.useRef)(null),o=e||t,[r,n]=(0,y.useState)(!1),i=(0,y.useCallback)(()=>{n(!0)},[]),s=(0,y.useCallback)(()=>{n(!1)},[]);return{elementRef:o,anchorEl:o.current,open:r,onOpen:i,onClose:s,setOpen:n}}var R=require("react");function ae(e,t="- -"){let[o,r]=(0,R.useState)({days:t,hours:t,minutes:t,seconds:t}),n=(0,R.useCallback)(()=>{let i=new Date,{days:s,hours:a,minutes:l,seconds:u}=ce(e,i);r({days:V(s),hours:V(a),minutes:V(l),seconds:V(u)})},[e]);return(0,R.useEffect)(()=>{n();let i=setInterval(n,1e3);return()=>clearInterval(i)},[]),o}function V(e){return String(e).length===1?`0${e}`:`${e}`}function ce(e,t){let o=e.getTime()-t.getTime();return{days:Math.floor(o/(1e3*60*60*24)),hours:Math.floor(o%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(o%(1e3*60*60)/(1e3*60)),seconds:Math.floor(o%(1e3*60)/1e3)}}var b=require("react");function ue(e=0){let t=(0,b.useRef)(null),[o,r]=(0,b.useState)(!1),n=(0,b.useCallback)(()=>{let i=window.scrollY;if(t.current){let s=t.current.offsetTop;r(i>s-e)}else r(i>e)},[e]);return(0,b.useEffect)(()=>(n(),window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[n]),{elementRef:t,offsetTop:o}}var v=require("react");function pe(e){let[t,o]=(0,v.useState)(e),[r,n]=(0,v.useState)(!1),i=(0,v.useCallback)(()=>{n(!0)},[]),s=(0,v.useCallback)(()=>{n(!1),o(e)},[e]);return(0,v.useEffect)(()=>{let a=null;return r&&t>0?a=setInterval(()=>{o(l=>l-1)},1e3):t<=0&&n(!1),()=>{a&&clearInterval(a)}},[r,t]),{value:t,setValue:o,isCounting:r,start:i,reset:s}}var H=require("react");function fe(){let[e,t]=(0,H.useState)(null);return{copy:(0,H.useCallback)(async r=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),t(r),!0}catch(n){return console.warn("Copy failed",n),t(null),!1}},[t]),copiedText:e}}0&&(module.exports={updateSelectedItems,useBackToTop,useBoolean,useClientRect,useCookies,useCopyToClipboard,useCountdownDate,useCountdownSeconds,useDebounce,useDoubleClick,useIsClient,useLocalStorage,useMultiSelect,usePopover,usePopoverHover,useScrollOffsetTop,useSetState,useTabs});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { UseTabsReturn, useTabs } from './use-tabs/use-tabs.cjs';
|
|
2
|
+
export { UseBooleanReturn, useBoolean } from './use-boolean/use-boolean.cjs';
|
|
3
|
+
export { UsePopoverReturn, usePopover } from './use-popover/use-popover.cjs';
|
|
4
|
+
export { UseCookiesOptions, UseCookiesReturn, useCookies } from './use-cookies/use-cookies.cjs';
|
|
5
|
+
export { UseDebounceReturn, useDebounce } from './use-debounce/use-debounce.cjs';
|
|
6
|
+
export { UseSetStateReturn, useSetState } from './use-set-state/use-set-state.cjs';
|
|
7
|
+
export { UseIsClientReturn, useIsClient } from './use-is-client/use-is-client.cjs';
|
|
8
|
+
export { UseBackToTopReturn, useBackToTop } from './use-back-to-top/use-back-to-top.cjs';
|
|
9
|
+
export { UseClientRectReturn, useClientRect } from './use-client-rect/use-client-rect.cjs';
|
|
10
|
+
export { UseMultiSelectReturn, updateSelectedItems, useMultiSelect } from './use-multi-select/use-multi-select.cjs';
|
|
11
|
+
export { UseDoubleClickReturn, useDoubleClick } from './use-double-click/use-double-click.cjs';
|
|
12
|
+
export { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from './use-local-storage/use-local-storage.cjs';
|
|
13
|
+
export { usePopoverHover } from './use-popover-hover/use-popover-hover.cjs';
|
|
14
|
+
export { UseCountdownDateReturn, useCountdownDate } from './use-countdown-date/use-countdown-date.cjs';
|
|
15
|
+
export { UseScrollOffsetTopReturn, useScrollOffsetTop } from './use-scroll-offset-top/use-scroll-offset-top.cjs';
|
|
16
|
+
export { UseCountdownSecondsReturn, useCountdownSeconds } from './use-countdown-seconds/use-countdown-seconds.cjs';
|
|
17
|
+
export { CopiedValue, CopyFn, UseCopyToClipboardReturn, useCopyToClipboard } from './use-copy-to-clipboard/use-copy-to-clipboard.cjs';
|
|
18
|
+
import 'react';
|
|
19
|
+
import '../utils/cookies/cookies.cjs';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { UseTabsReturn, useTabs } from './use-tabs/use-tabs.js';
|
|
2
|
+
export { UseBooleanReturn, useBoolean } from './use-boolean/use-boolean.js';
|
|
3
|
+
export { UsePopoverReturn, usePopover } from './use-popover/use-popover.js';
|
|
4
|
+
export { UseCookiesOptions, UseCookiesReturn, useCookies } from './use-cookies/use-cookies.js';
|
|
5
|
+
export { UseDebounceReturn, useDebounce } from './use-debounce/use-debounce.js';
|
|
6
|
+
export { UseSetStateReturn, useSetState } from './use-set-state/use-set-state.js';
|
|
7
|
+
export { UseIsClientReturn, useIsClient } from './use-is-client/use-is-client.js';
|
|
8
|
+
export { UseBackToTopReturn, useBackToTop } from './use-back-to-top/use-back-to-top.js';
|
|
9
|
+
export { UseClientRectReturn, useClientRect } from './use-client-rect/use-client-rect.js';
|
|
10
|
+
export { UseMultiSelectReturn, updateSelectedItems, useMultiSelect } from './use-multi-select/use-multi-select.js';
|
|
11
|
+
export { UseDoubleClickReturn, useDoubleClick } from './use-double-click/use-double-click.js';
|
|
12
|
+
export { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from './use-local-storage/use-local-storage.js';
|
|
13
|
+
export { usePopoverHover } from './use-popover-hover/use-popover-hover.js';
|
|
14
|
+
export { UseCountdownDateReturn, useCountdownDate } from './use-countdown-date/use-countdown-date.js';
|
|
15
|
+
export { UseScrollOffsetTopReturn, useScrollOffsetTop } from './use-scroll-offset-top/use-scroll-offset-top.js';
|
|
16
|
+
export { UseCountdownSecondsReturn, useCountdownSeconds } from './use-countdown-seconds/use-countdown-seconds.js';
|
|
17
|
+
export { CopiedValue, CopyFn, UseCopyToClipboardReturn, useCopyToClipboard } from './use-copy-to-clipboard/use-copy-to-clipboard.js';
|
|
18
|
+
import 'react';
|
|
19
|
+
import '../utils/cookies/cookies.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as C,useState as A}from"react";function Ce(e=!1){let[t,o]=A(e),r=C((i,s)=>{o(s)},[]),n=C(()=>{o(e)},[e]);return{value:t,setValue:o,onChange:r,reset:n}}import{useCallback as g,useState as P}from"react";function Ee(e=!1){let[t,o]=P(e),r=g(()=>{o(!0)},[]),n=g(()=>{o(!1)},[]),i=g(()=>{o(s=>!s)},[]);return{value:t,onTrue:r,onFalse:n,onToggle:i,setValue:o}}import{useCallback as R,useState as j}from"react";function Me(){let[e,t]=j(null),o=R(n=>{t(n.currentTarget)},[]),r=R(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:o,onClose:r,setAnchorEl:t}}import{useCallback as h,useEffect as F,useMemo as z,useState as B}from"react";function k(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,n=decodeURIComponent(document.cookie).split("; ").find(s=>s.startsWith(t));if(!n)return null;let i=n.substring(t.length);try{return JSON.parse(i)}catch{return i}}catch(t){return console.error("Error retrieving cookie:",t),null}}function m(e,t,o){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:n="Strict",secure:i=!1,path:s="/",domain:a}=o??{};try{let l=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),u=[`${e}=${l}`,`path=${s}`,n&&`SameSite=${n}`,i&&"Secure",a&&`domain=${a}`];if(r>0){let p=new Date(Date.now()+r*24*60*60*1e3);u.push(`expires=${p.toUTCString()}`)}document.cookie=u.filter(Boolean).join("; ")}catch(l){console.error("Error setting cookie:",l)}}function E(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:o="/",domain:r}=t??{};try{let n=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${o}`,r&&`domain=${r}`,"Secure"];document.cookie=n.filter(Boolean).join("; ")}catch(n){console.error("Error removing cookie:",n)}}function Le(e,t,o){let{initializeWithValue:r=!0,...n}=o??{},i=t&&typeof t=="object",[s,a]=B(t);F(()=>{let c=k(e);c?a(i?d=>({...d,...c}):c):t&&r&&m(e,t,n)},[]);let l=h(c=>{i?a(d=>{let x={...d,...c};return m(e,x,n),x}):(m(e,c,n),a(c))},[n,i,e]),u=h((c,d)=>{i&&l({[c]:d})},[i,l]),p=h(c=>{a(c??t),E(e)},[t,e]);return z(()=>({state:s,setState:l,setField:u,resetState:p}),[p,u,l,s])}import{useEffect as _,useState as $}from"react";function Pe(e,t=1e3){let[o,r]=$(e);return _(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),o}import{useCallback as b,useState as W}from"react";function ze(e){let[t,o]=W(e),r=b(s=>{o(a=>({...a,...s}))},[]),n=b((s,a)=>{r({[s]:a})},[r]),i=b(s=>{o(s??e)},[e]);return{state:t,setState:r,setField:n,resetState:i}}import{useEffect as N,useState as J}from"react";function $e(){let[e,t]=J(!1);return N(()=>{t(!0)},[]),e}import{useCallback as Y,useEffect as G,useMemo as q,useState as K}from"react";function Je(e,t){let[o,r]=K(!1),n=Q(e),i=Y(()=>{let l=window.innerHeight,u=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(u/(p-l)*100);if(n.type==="percentage")r(f>=n.value);else{let c=p-l-u;r(n.value>=c)}},[n.type,n.value]),s=q(()=>{let l;return()=>{clearTimeout(l),l=setTimeout(i,100)}},[i]);return G(()=>{let l=t?s:i;return window.addEventListener("scroll",l),()=>{window.removeEventListener("scroll",l)}},[s,i,t]),{isVisible:o,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:r}}function Q(e){let t,o;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");o="percentage"}else throw new Error("String input must end with %");else t=e,o="number";return{value:t,type:o}}import{useCallback as X,useEffect as w,useLayoutEffect as Z,useMemo as U,useRef as ee,useState as M}from"react";function qe(e,t){let o=ee(null),r=e||o,[n,i]=M(void 0),[s,a]=M(void 0),l=typeof window<"u"?Z:w,u=X(()=>{if(r.current){let c=r.current.getBoundingClientRect();i(c),a({scrollWidth:r.current.scrollWidth,scrollHeight:r.current.scrollHeight})}},[r]);l(()=>{u()},[u]),w(()=>{let c=t||"resize";return window.addEventListener(c,u),()=>{window.removeEventListener(c,u)}},[t,u]);let p=U(()=>n,[n]),f=U(()=>s,[s]);return{elementRef:r,top:p?.top??0,right:p?.right??0,bottom:p?.bottom??0,left:p?.left??0,x:p?.x??0,y:p?.y??0,width:p?.width??0,height:p?.height??0,scrollWidth:f?.scrollWidth??0,scrollHeight:f?.scrollHeight??0}}import{useCallback as v,useMemo as te,useState as oe}from"react";function Xe(e,t){let[o,r]=oe(t??[]),n=v(l=>{r(u=>ne(u,l))},[]),i=v(()=>{r(l=>l.length===e.length?[]:e)},[e]),s=v(()=>{r([])},[]),a=te(()=>o.length===0?"unchecked":o.length===e.length?"checked":"indeterminate",[e.length,o.length]);return{values:o,status:a,setValues:r,onSelectAllItems:i,onDeSelectAllItems:s,onToggleSelectItem:n}}function ne(e,t){return e.includes(t)?e.filter(o=>o!==t):[...e,t]}import{useCallback as O,useRef as re}from"react";function tt({click:e,doubleClick:t,timeout:o=250}){let r=re(null),n=O(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return O(s=>{n(),e&&s.detail===1&&(r.current=setTimeout(()=>{e(s)},o)),s.detail%2===0&&t(s)},[e,t,o,n])}import{useCallback as y,useEffect as ie,useMemo as le,useState as ae}from"react";function D(e,t){if(!se())return t??null;let o=localStorage.getItem(e);if(o!=="undefined"){if(o)try{return JSON.parse(o)}catch{return o??t??null}return t??null}}function T(e,t){try{let o=JSON.stringify(t);window.localStorage.setItem(e,o)}catch(o){console.error("Error while setting storage:",o)}}function V(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function se(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function it(e,t,o){let{initializeWithValue:r=!0}=o??{},n=t&&typeof t=="object",[i,s]=ae(t);ie(()=>{let f=D(e);f?s(n?c=>({...c,...f}):f):t&&r&&T(e,t)},[]);let a=y(f=>{n?s(c=>{let d={...c,...f};return T(e,d),d}):(T(e,f),s(f))},[e,n]),l=y((f,c)=>{n&&a({[f]:c})},[n,a]),u=y(f=>{s(f??t),V(e)},[t,e]);return le(()=>({state:i,setState:a,setField:l,resetState:u}),[u,l,a,i])}import{useCallback as H,useRef as ce,useState as ue}from"react";function ct(e){let t=ce(null),o=e||t,[r,n]=ue(!1),i=H(()=>{n(!0)},[]),s=H(()=>{n(!1)},[]);return{elementRef:o,anchorEl:o.current,open:r,onOpen:i,onClose:s,setOpen:n}}import{useCallback as pe,useEffect as fe,useState as de}from"react";function ft(e,t="- -"){let[o,r]=de({days:t,hours:t,minutes:t,seconds:t}),n=pe(()=>{let i=new Date,{days:s,hours:a,minutes:l,seconds:u}=me(e,i);r({days:S(s),hours:S(a),minutes:S(l),seconds:S(u)})},[e]);return fe(()=>{n();let i=setInterval(n,1e3);return()=>clearInterval(i)},[]),o}function S(e){return String(e).length===1?`0${e}`:`${e}`}function me(e,t){let o=e.getTime()-t.getTime();return{days:Math.floor(o/(1e3*60*60*24)),hours:Math.floor(o%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(o%(1e3*60*60)/(1e3*60)),seconds:Math.floor(o%(1e3*60)/1e3)}}import{useCallback as Te,useEffect as Se,useRef as ge,useState as he}from"react";function Tt(e=0){let t=ge(null),[o,r]=he(!1),n=Te(()=>{let i=window.scrollY;if(t.current){let s=t.current.offsetTop;r(i>s-e)}else r(i>e)},[e]);return Se(()=>(n(),window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[n]),{elementRef:t,offsetTop:o}}import{useCallback as L,useEffect as be,useState as I}from"react";function ht(e){let[t,o]=I(e),[r,n]=I(!1),i=L(()=>{n(!0)},[]),s=L(()=>{n(!1),o(e)},[e]);return be(()=>{let a=null;return r&&t>0?a=setInterval(()=>{o(l=>l-1)},1e3):t<=0&&n(!1),()=>{a&&clearInterval(a)}},[r,t]),{value:t,setValue:o,isCounting:r,start:i,reset:s}}import{useCallback as ve,useState as ye}from"react";function yt(){let[e,t]=ye(null);return{copy:ve(async r=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),t(r),!0}catch(n){return console.warn("Copy failed",n),t(null),!1}},[t]),copiedText:e}}export{ne as updateSelectedItems,Je as useBackToTop,Ee as useBoolean,qe as useClientRect,Le as useCookies,yt as useCopyToClipboard,ft as useCountdownDate,ht as useCountdownSeconds,Pe as useDebounce,tt as useDoubleClick,$e as useIsClient,it as useLocalStorage,Xe as useMultiSelect,Me as usePopover,ct as usePopoverHover,Tt as useScrollOffsetTop,ze as useSetState,Ce as useTabs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var T=(t,e)=>{for(var n in e)c(t,n,{get:e[n],enumerable:!0})},h=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of f(e))!b.call(t,o)&&o!==n&&c(t,o,{get:()=>e[o],enumerable:!(i=w(e,o))||i.enumerable});return t};var g=t=>h(c({},"__esModule",{value:!0}),t);var S={};T(S,{useBackToTop:()=>v});module.exports=g(S);var s=require("react");function v(t,e){let[n,i]=(0,s.useState)(!1),o=y(t),l=(0,s.useCallback)(()=>{let r=window.innerHeight,u=Math.round(window.scrollY),p=document.body.offsetHeight,d=Math.round(u/(p-r)*100);if(o.type==="percentage")i(d>=o.value);else{let m=p-r-u;i(o.value>=m)}},[o.type,o.value]),a=(0,s.useMemo)(()=>{let r;return()=>{clearTimeout(r),r=setTimeout(l,100)}},[l]);return(0,s.useEffect)(()=>{let r=e?a:l;return window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}},[a,l,e]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:i}}function y(t){let e,n;if(typeof t=="string")if(t.endsWith("%")){if(e=Number(t.slice(0,-1)),isNaN(e))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else e=t,n="number";return{value:e,type:n}}0&&(module.exports={useBackToTop});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as d,useEffect as m,useMemo as w,useState as f}from"react";function g(o,t){let[n,i]=f(!1),r=b(o),s=d(()=>{let e=window.innerHeight,c=Math.round(window.scrollY),a=document.body.offsetHeight,u=Math.round(c/(a-e)*100);if(r.type==="percentage")i(u>=r.value);else{let p=a-e-c;i(r.value>=p)}},[r.type,r.value]),l=w(()=>{let e;return()=>{clearTimeout(e),e=setTimeout(s,100)}},[s]);return m(()=>{let e=t?l:s;return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[l,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:i}}function b(o){let t,n;if(typeof o=="string")if(o.endsWith("%")){if(t=Number(o.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else t=o,n="number";return{value:t,type:n}}export{g as useBackToTop};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var T=(t,e)=>{for(var n in e)c(t,n,{get:e[n],enumerable:!0})},h=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of b(e))!f.call(t,o)&&o!==n&&c(t,o,{get:()=>e[o],enumerable:!(i=w(e,o))||i.enumerable});return t};var g=t=>h(c({},"__esModule",{value:!0}),t);var S={};T(S,{useBackToTop:()=>v});module.exports=g(S);var s=require("react");function v(t,e){let[n,i]=(0,s.useState)(!1),o=y(t),l=(0,s.useCallback)(()=>{let r=window.innerHeight,u=Math.round(window.scrollY),p=document.body.offsetHeight,d=Math.round(u/(p-r)*100);if(o.type==="percentage")i(d>=o.value);else{let m=p-r-u;i(o.value>=m)}},[o.type,o.value]),a=(0,s.useMemo)(()=>{let r;return()=>{clearTimeout(r),r=setTimeout(l,100)}},[l]);return(0,s.useEffect)(()=>{let r=e?a:l;return window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}},[a,l,e]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:i}}function y(t){let e,n;if(typeof t=="string")if(t.endsWith("%")){if(e=Number(t.slice(0,-1)),isNaN(e))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else e=t,n="number";return{value:e,type:n}}0&&(module.exports={useBackToTop});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to manage the visibility of a "Back to Top" button based on scroll position.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | number} defaultValue - The scroll progress percentage (e.g., '90%') or distance in pixels (e.g., 80) at which the button becomes visible.
|
|
7
|
+
* - If `defaultValue` is a percentage string (e.g., '90%'), the button becomes visible when the scroll distance is that percentage from the top.
|
|
8
|
+
* - If `defaultValue` is a number (e.g., 80), the button becomes visible when the scroll distance is that many pixels from the bottom.
|
|
9
|
+
* @param {boolean} [isDebounce=false] - Whether to debounce the scroll handler to improve performance.
|
|
10
|
+
*
|
|
11
|
+
* @returns {UseBackToTopReturn} - An object containing:
|
|
12
|
+
* - `isVisible`: A boolean indicating whether the "Back to Top" button should be visible.
|
|
13
|
+
* - `onBackToTop`: A function to scroll the window back to the top smoothly.
|
|
14
|
+
* - `setIsVisible`: A function to manually set the visibility of the "Back to Top" button.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const { isVisible, onBackToTop } = useBackToTop('90%');
|
|
18
|
+
* const { isVisible, onBackToTop } = useBackToTop(80);
|
|
19
|
+
*
|
|
20
|
+
* return (
|
|
21
|
+
* <button onClick={onBackToTop} style={{ display: isVisible ? 'block' : 'none' }}>
|
|
22
|
+
* Back to Top
|
|
23
|
+
* </button>
|
|
24
|
+
* );
|
|
25
|
+
*/
|
|
26
|
+
type UseBackToTopReturn = {
|
|
27
|
+
isVisible: boolean;
|
|
28
|
+
onBackToTop: () => void;
|
|
29
|
+
setIsVisible: Dispatch<SetStateAction<boolean>>;
|
|
30
|
+
};
|
|
31
|
+
declare function useBackToTop(defaultValue: string | number, isDebounce?: boolean): UseBackToTopReturn;
|
|
32
|
+
|
|
33
|
+
export { type UseBackToTopReturn, useBackToTop };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to manage the visibility of a "Back to Top" button based on scroll position.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | number} defaultValue - The scroll progress percentage (e.g., '90%') or distance in pixels (e.g., 80) at which the button becomes visible.
|
|
7
|
+
* - If `defaultValue` is a percentage string (e.g., '90%'), the button becomes visible when the scroll distance is that percentage from the top.
|
|
8
|
+
* - If `defaultValue` is a number (e.g., 80), the button becomes visible when the scroll distance is that many pixels from the bottom.
|
|
9
|
+
* @param {boolean} [isDebounce=false] - Whether to debounce the scroll handler to improve performance.
|
|
10
|
+
*
|
|
11
|
+
* @returns {UseBackToTopReturn} - An object containing:
|
|
12
|
+
* - `isVisible`: A boolean indicating whether the "Back to Top" button should be visible.
|
|
13
|
+
* - `onBackToTop`: A function to scroll the window back to the top smoothly.
|
|
14
|
+
* - `setIsVisible`: A function to manually set the visibility of the "Back to Top" button.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const { isVisible, onBackToTop } = useBackToTop('90%');
|
|
18
|
+
* const { isVisible, onBackToTop } = useBackToTop(80);
|
|
19
|
+
*
|
|
20
|
+
* return (
|
|
21
|
+
* <button onClick={onBackToTop} style={{ display: isVisible ? 'block' : 'none' }}>
|
|
22
|
+
* Back to Top
|
|
23
|
+
* </button>
|
|
24
|
+
* );
|
|
25
|
+
*/
|
|
26
|
+
type UseBackToTopReturn = {
|
|
27
|
+
isVisible: boolean;
|
|
28
|
+
onBackToTop: () => void;
|
|
29
|
+
setIsVisible: Dispatch<SetStateAction<boolean>>;
|
|
30
|
+
};
|
|
31
|
+
declare function useBackToTop(defaultValue: string | number, isDebounce?: boolean): UseBackToTopReturn;
|
|
32
|
+
|
|
33
|
+
export { type UseBackToTopReturn, useBackToTop };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as d,useEffect as m,useMemo as w,useState as b}from"react";function g(o,t){let[n,i]=b(!1),r=f(o),s=d(()=>{let e=window.innerHeight,c=Math.round(window.scrollY),a=document.body.offsetHeight,u=Math.round(c/(a-e)*100);if(r.type==="percentage")i(u>=r.value);else{let p=a-e-c;i(r.value>=p)}},[r.type,r.value]),l=w(()=>{let e;return()=>{clearTimeout(e),e=setTimeout(s,100)}},[s]);return m(()=>{let e=t?l:s;return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[l,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:i}}function f(o){let t,n;if(typeof o=="string")if(o.endsWith("%")){if(t=Number(o.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else t=o,n="number";return{value:t,type:n}}export{g as useBackToTop};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var t in e)s(o,t,{get:e[t],enumerable:!0})},m=(o,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!p.call(o,n)&&n!==t&&s(o,n,{get:()=>e[n],enumerable:!(l=c(e,n))||l.enumerable});return o};var v=o=>m(s({},"__esModule",{value:!0}),o);var b={};f(b,{useBoolean:()=>S});module.exports=v(b);var a=require("react");function S(o=!1){let[e,t]=(0,a.useState)(o),l=(0,a.useCallback)(()=>{t(!0)},[]),n=(0,a.useCallback)(()=>{t(!1)},[]),r=(0,a.useCallback)(()=>{t(u=>!u)},[]);return{value:e,onTrue:l,onFalse:n,onToggle:r,setValue:t}}0&&(module.exports={useBoolean});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as o,useState as u}from"react";function i(t=!1){let[n,e]=u(t),a=o(()=>{e(!0)},[]),l=o(()=>{e(!1)},[]),s=o(()=>{e(r=>!r)},[]);return{value:n,onTrue:a,onFalse:l,onToggle:s,setValue:e}}export{i as useBoolean};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var t in e)s(o,t,{get:e[t],enumerable:!0})},v=(o,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!p.call(o,n)&&n!==t&&s(o,n,{get:()=>e[n],enumerable:!(l=c(e,n))||l.enumerable});return o};var S=o=>v(s({},"__esModule",{value:!0}),o);var g={};f(g,{useBoolean:()=>b});module.exports=S(g);var a=require("react");function b(o=!1){let[e,t]=(0,a.useState)(o),l=(0,a.useCallback)(()=>{t(!0)},[]),n=(0,a.useCallback)(()=>{t(!1)},[]),r=(0,a.useCallback)(()=>{t(u=>!u)},[]);return{value:e,onTrue:l,onFalse:n,onToggle:r,setValue:t}}0&&(module.exports={useBoolean});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to manage a boolean state with utility functions to set it to true, false, or toggle its value.
|
|
5
|
+
*
|
|
6
|
+
* @param {boolean} [defaultValue=false] - The initial value of the boolean state.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const { value, onTrue, onFalse, onToggle } = useBoolean(false);
|
|
10
|
+
*
|
|
11
|
+
* return (
|
|
12
|
+
* <div>
|
|
13
|
+
* <p>Value: {value.toString()}</p>
|
|
14
|
+
* <button onClick={onTrue}>Set True</button>
|
|
15
|
+
* <button onClick={onFalse}>Set False</button>
|
|
16
|
+
* <button onClick={onToggle}>Toggle</button>
|
|
17
|
+
* </div>
|
|
18
|
+
* );
|
|
19
|
+
*/
|
|
20
|
+
type UseBooleanReturn = {
|
|
21
|
+
value: boolean;
|
|
22
|
+
onTrue: () => void;
|
|
23
|
+
onFalse: () => void;
|
|
24
|
+
onToggle: () => void;
|
|
25
|
+
setValue: Dispatch<SetStateAction<boolean>>;
|
|
26
|
+
};
|
|
27
|
+
declare function useBoolean(defaultValue?: boolean): UseBooleanReturn;
|
|
28
|
+
|
|
29
|
+
export { type UseBooleanReturn, useBoolean };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to manage a boolean state with utility functions to set it to true, false, or toggle its value.
|
|
5
|
+
*
|
|
6
|
+
* @param {boolean} [defaultValue=false] - The initial value of the boolean state.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const { value, onTrue, onFalse, onToggle } = useBoolean(false);
|
|
10
|
+
*
|
|
11
|
+
* return (
|
|
12
|
+
* <div>
|
|
13
|
+
* <p>Value: {value.toString()}</p>
|
|
14
|
+
* <button onClick={onTrue}>Set True</button>
|
|
15
|
+
* <button onClick={onFalse}>Set False</button>
|
|
16
|
+
* <button onClick={onToggle}>Toggle</button>
|
|
17
|
+
* </div>
|
|
18
|
+
* );
|
|
19
|
+
*/
|
|
20
|
+
type UseBooleanReturn = {
|
|
21
|
+
value: boolean;
|
|
22
|
+
onTrue: () => void;
|
|
23
|
+
onFalse: () => void;
|
|
24
|
+
onToggle: () => void;
|
|
25
|
+
setValue: Dispatch<SetStateAction<boolean>>;
|
|
26
|
+
};
|
|
27
|
+
declare function useBoolean(defaultValue?: boolean): UseBooleanReturn;
|
|
28
|
+
|
|
29
|
+
export { type UseBooleanReturn, useBoolean };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as o,useState as u}from"react";function i(t=!1){let[n,e]=u(t),a=o(()=>{e(!0)},[]),l=o(()=>{e(!1)},[]),s=o(()=>{e(r=>!r)},[]);return{value:n,onTrue:a,onFalse:l,onToggle:s,setValue:e}}export{i as useBoolean};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(n,t)=>{for(var c in t)s(n,c,{get:t[c],enumerable:!0})},E=(n,t,c,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of a(t))!g.call(n,o)&&o!==c&&s(n,o,{get:()=>t[o],enumerable:!(l=b(t,o))||l.enumerable});return n};var T=n=>E(s({},"__esModule",{value:!0}),n);var y={};p(y,{useClientRect:()=>w});module.exports=T(y);var e=require("react");function w(n,t){let c=(0,e.useRef)(null),l=n||c,[o,f]=(0,e.useState)(void 0),[m,h]=(0,e.useState)(void 0),R=typeof window<"u"?e.useLayoutEffect:e.useEffect,i=(0,e.useCallback)(()=>{if(l.current){let u=l.current.getBoundingClientRect();f(u),h({scrollWidth:l.current.scrollWidth,scrollHeight:l.current.scrollHeight})}},[l]);R(()=>{i()},[i]),(0,e.useEffect)(()=>{let u=t||"resize";return window.addEventListener(u,i),()=>{window.removeEventListener(u,i)}},[t,i]);let r=(0,e.useMemo)(()=>o,[o]),d=(0,e.useMemo)(()=>m,[m]);return{elementRef:l,top:r?.top??0,right:r?.right??0,bottom:r?.bottom??0,left:r?.left??0,x:r?.x??0,y:r?.y??0,width:r?.width??0,height:r?.height??0,scrollWidth:d?.scrollWidth??0,scrollHeight:d?.scrollHeight??0}}0&&(module.exports={useClientRect});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as a,useEffect as u,useLayoutEffect as g,useMemo as s,useRef as p,useState as m}from"react";function T(d,o){let f=p(null),t=d||f,[r,h]=m(void 0),[c,R]=m(void 0),b=typeof window<"u"?g:u,n=a(()=>{if(t.current){let l=t.current.getBoundingClientRect();h(l),R({scrollWidth:t.current.scrollWidth,scrollHeight:t.current.scrollHeight})}},[t]);b(()=>{n()},[n]),u(()=>{let l=o||"resize";return window.addEventListener(l,n),()=>{window.removeEventListener(l,n)}},[o,n]);let e=s(()=>r,[r]),i=s(()=>c,[c]);return{elementRef:t,top:e?.top??0,right:e?.right??0,bottom:e?.bottom??0,left:e?.left??0,x:e?.x??0,y:e?.y??0,width:e?.width??0,height:e?.height??0,scrollWidth:i?.scrollWidth??0,scrollHeight:i?.scrollHeight??0}}export{T as useClientRect};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(n,t)=>{for(var c in t)s(n,c,{get:t[c],enumerable:!0})},E=(n,t,c,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of a(t))!g.call(n,o)&&o!==c&&s(n,o,{get:()=>t[o],enumerable:!(l=b(t,o))||l.enumerable});return n};var T=n=>E(s({},"__esModule",{value:!0}),n);var y={};p(y,{useClientRect:()=>w});module.exports=T(y);var e=require("react");function w(n,t){let c=(0,e.useRef)(null),l=n||c,[o,f]=(0,e.useState)(void 0),[d,h]=(0,e.useState)(void 0),R=typeof window<"u"?e.useLayoutEffect:e.useEffect,i=(0,e.useCallback)(()=>{if(l.current){let u=l.current.getBoundingClientRect();f(u),h({scrollWidth:l.current.scrollWidth,scrollHeight:l.current.scrollHeight})}},[l]);R(()=>{i()},[i]),(0,e.useEffect)(()=>{let u=t||"resize";return window.addEventListener(u,i),()=>{window.removeEventListener(u,i)}},[t,i]);let r=(0,e.useMemo)(()=>o,[o]),m=(0,e.useMemo)(()=>d,[d]);return{elementRef:l,top:r?.top??0,right:r?.right??0,bottom:r?.bottom??0,left:r?.left??0,x:r?.x??0,y:r?.y??0,width:r?.width??0,height:r?.height??0,scrollWidth:m?.scrollWidth??0,scrollHeight:m?.scrollHeight??0}}0&&(module.exports={useClientRect});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to get the bounding client rect and scroll dimensions of a DOM element.
|
|
5
|
+
*
|
|
6
|
+
* @param {RefObject<T | null>} [inputRef] - Optional ref object to the target element.
|
|
7
|
+
* @param {string} [eventType] - Optional event type to trigger updates (e.g., 'scroll', 'resize').
|
|
8
|
+
* @returns {UseClientRectReturn<T>} - Object containing the bounding rect, scroll dimensions, and ref to the element.
|
|
9
|
+
*/
|
|
10
|
+
type ScrollElValue = {
|
|
11
|
+
scrollWidth: number;
|
|
12
|
+
scrollHeight: number;
|
|
13
|
+
};
|
|
14
|
+
type DOMRectValue = {
|
|
15
|
+
top: number;
|
|
16
|
+
right: number;
|
|
17
|
+
bottom: number;
|
|
18
|
+
left: number;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
};
|
|
24
|
+
type UseClientRectReturn<T extends HTMLElement = HTMLElement> = DOMRectValue & ScrollElValue & {
|
|
25
|
+
elementRef: RefObject<T>;
|
|
26
|
+
};
|
|
27
|
+
declare function useClientRect<T extends HTMLElement = HTMLElement>(inputRef?: RefObject<T | null>, eventType?: string): UseClientRectReturn<T>;
|
|
28
|
+
|
|
29
|
+
export { type UseClientRectReturn, useClientRect };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to get the bounding client rect and scroll dimensions of a DOM element.
|
|
5
|
+
*
|
|
6
|
+
* @param {RefObject<T | null>} [inputRef] - Optional ref object to the target element.
|
|
7
|
+
* @param {string} [eventType] - Optional event type to trigger updates (e.g., 'scroll', 'resize').
|
|
8
|
+
* @returns {UseClientRectReturn<T>} - Object containing the bounding rect, scroll dimensions, and ref to the element.
|
|
9
|
+
*/
|
|
10
|
+
type ScrollElValue = {
|
|
11
|
+
scrollWidth: number;
|
|
12
|
+
scrollHeight: number;
|
|
13
|
+
};
|
|
14
|
+
type DOMRectValue = {
|
|
15
|
+
top: number;
|
|
16
|
+
right: number;
|
|
17
|
+
bottom: number;
|
|
18
|
+
left: number;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
};
|
|
24
|
+
type UseClientRectReturn<T extends HTMLElement = HTMLElement> = DOMRectValue & ScrollElValue & {
|
|
25
|
+
elementRef: RefObject<T>;
|
|
26
|
+
};
|
|
27
|
+
declare function useClientRect<T extends HTMLElement = HTMLElement>(inputRef?: RefObject<T | null>, eventType?: string): UseClientRectReturn<T>;
|
|
28
|
+
|
|
29
|
+
export { type UseClientRectReturn, useClientRect };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as a,useEffect as u,useLayoutEffect as g,useMemo as s,useRef as p,useState as d}from"react";function T(m,o){let f=p(null),t=m||f,[r,h]=d(void 0),[c,R]=d(void 0),b=typeof window<"u"?g:u,n=a(()=>{if(t.current){let l=t.current.getBoundingClientRect();h(l),R({scrollWidth:t.current.scrollWidth,scrollHeight:t.current.scrollHeight})}},[t]);b(()=>{n()},[n]),u(()=>{let l=o||"resize";return window.addEventListener(l,n),()=>{window.removeEventListener(l,n)}},[o,n]);let e=s(()=>r,[r]),i=s(()=>c,[c]);return{elementRef:t,top:e?.top??0,right:e?.right??0,bottom:e?.bottom??0,left:e?.left??0,x:e?.x??0,y:e?.y??0,width:e?.width??0,height:e?.height??0,scrollWidth:i?.scrollWidth??0,scrollHeight:i?.scrollHeight??0}}export{T as useClientRect};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var k=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var S=(e,o)=>{for(var r in o)k(e,r,{get:o[r],enumerable:!0})},v=(e,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of x(o))!y.call(e,t)&&t!==r&&k(e,t,{get:()=>o[t],enumerable:!(i=h(o,t))||i.enumerable});return e};var O=e=>v(k({},"__esModule",{value:!0}),e);var U={};S(U,{useCookies:()=>$});module.exports=O(U);var a=require("react");function C(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let o=`${e}=`,t=decodeURIComponent(document.cookie).split("; ").find(p=>p.startsWith(o));if(!t)return null;let s=t.substring(o.length);try{return JSON.parse(s)}catch{return s}}catch(o){return console.error("Error retrieving cookie:",o),null}}function f(e,o,r){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:i=0,sameSite:t="Strict",secure:s=!1,path:p="/",domain:c}=r??{};try{let d=encodeURIComponent(typeof o=="string"?o:JSON.stringify(o)),u=[`${e}=${d}`,`path=${p}`,t&&`SameSite=${t}`,s&&"Secure",c&&`domain=${c}`];if(i>0){let T=new Date(Date.now()+i*24*60*60*1e3);u.push(`expires=${T.toUTCString()}`)}document.cookie=u.filter(Boolean).join("; ")}catch(d){console.error("Error setting cookie:",d)}}function g(e,o){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:r="/",domain:i}=o??{};try{let t=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${r}`,i&&`domain=${i}`,"Secure"];document.cookie=t.filter(Boolean).join("; ")}catch(t){console.error("Error removing cookie:",t)}}function $(e,o,r){let{initializeWithValue:i=!0,...t}=r??{},s=o&&typeof o=="object",[p,c]=(0,a.useState)(o);(0,a.useEffect)(()=>{let n=C(e);n?c(s?l=>({...l,...n}):n):o&&i&&f(e,o,t)},[]);let d=(0,a.useCallback)(n=>{s?c(l=>{let m={...l,...n};return f(e,m,t),m}):(f(e,n,t),c(n))},[t,s,e]),u=(0,a.useCallback)((n,l)=>{s&&d({[n]:l})},[s,d]),T=(0,a.useCallback)(n=>{c(n??o),g(e)},[o,e]);return(0,a.useMemo)(()=>({state:p,setState:d,setField:u,resetState:T}),[T,u,d,p])}0&&(module.exports={useCookies});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as f,useEffect as g,useMemo as h,useState as x}from"react";function m(o){if(!o||typeof o!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${o}=`,t=decodeURIComponent(document.cookie).split("; ").find(d=>d.startsWith(e));if(!t)return null;let i=t.substring(e.length);try{return JSON.parse(i)}catch{return i}}catch(e){return console.error("Error retrieving cookie:",e),null}}function T(o,e,c){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:n=0,sameSite:t="Strict",secure:i=!1,path:d="/",domain:s}=c??{};try{let a=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),p=[`${o}=${a}`,`path=${d}`,t&&`SameSite=${t}`,i&&"Secure",s&&`domain=${s}`];if(n>0){let l=new Date(Date.now()+n*24*60*60*1e3);p.push(`expires=${l.toUTCString()}`)}document.cookie=p.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function C(o,e){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{path:c="/",domain:n}=e??{};try{let t=[`${o}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${c}`,n&&`domain=${n}`,"Secure"];document.cookie=t.filter(Boolean).join("; ")}catch(t){console.error("Error removing cookie:",t)}}function $(o,e,c){let{initializeWithValue:n=!0,...t}=c??{},i=e&&typeof e=="object",[d,s]=x(e);g(()=>{let r=m(o);r?s(i?u=>({...u,...r}):r):e&&n&&T(o,e,t)},[]);let a=f(r=>{i?s(u=>{let k={...u,...r};return T(o,k,t),k}):(T(o,r,t),s(r))},[t,i,o]),p=f((r,u)=>{i&&a({[r]:u})},[i,a]),l=f(r=>{s(r??e),C(o)},[e,o]);return h(()=>({state:d,setState:a,setField:p,resetState:l}),[l,p,a,d])}export{$ as useCookies};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var k=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var v=(o,e)=>{for(var i in e)k(o,i,{get:e[i],enumerable:!0})},x=(o,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of y(e))!S.call(o,t)&&t!==i&&k(o,t,{get:()=>e[t],enumerable:!(r=h(e,t))||r.enumerable});return o};var O=o=>x(k({},"__esModule",{value:!0}),o);var U={};v(U,{useCookies:()=>$});module.exports=O(U);var a=require("react");function C(o){if(!o||typeof o!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${o}=`,t=decodeURIComponent(document.cookie).split("; ").find(p=>p.startsWith(e));if(!t)return null;let s=t.substring(e.length);try{return JSON.parse(s)}catch{return s}}catch(e){return console.error("Error retrieving cookie:",e),null}}function f(o,e,i){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:t="Strict",secure:s=!1,path:p="/",domain:c}=i??{};try{let d=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),u=[`${o}=${d}`,`path=${p}`,t&&`SameSite=${t}`,s&&"Secure",c&&`domain=${c}`];if(r>0){let T=new Date(Date.now()+r*24*60*60*1e3);u.push(`expires=${T.toUTCString()}`)}document.cookie=u.filter(Boolean).join("; ")}catch(d){console.error("Error setting cookie:",d)}}function g(o,e){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{path:i="/",domain:r}=e??{};try{let t=[`${o}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${i}`,r&&`domain=${r}`,"Secure"];document.cookie=t.filter(Boolean).join("; ")}catch(t){console.error("Error removing cookie:",t)}}function $(o,e,i){let{initializeWithValue:r=!0,...t}=i??{},s=e&&typeof e=="object",[p,c]=(0,a.useState)(e);(0,a.useEffect)(()=>{let n=C(o);n?c(s?l=>({...l,...n}):n):e&&r&&f(o,e,t)},[]);let d=(0,a.useCallback)(n=>{s?c(l=>{let m={...l,...n};return f(o,m,t),m}):(f(o,n,t),c(n))},[t,s,o]),u=(0,a.useCallback)((n,l)=>{s&&d({[n]:l})},[s,d]),T=(0,a.useCallback)(n=>{c(n??e),g(o)},[e,o]);return(0,a.useMemo)(()=>({state:p,setState:d,setField:u,resetState:T}),[T,u,d,p])}0&&(module.exports={useCookies});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CookieOptions } from '../../utils/cookies/cookies.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to manage state with cookies.
|
|
5
|
+
*
|
|
6
|
+
* @template T
|
|
7
|
+
* @param {string} key - The key for the cookie.
|
|
8
|
+
* @param {T} initialState - The initial state value.
|
|
9
|
+
* @param {UseCookiesOptions} [options] - Optional settings.
|
|
10
|
+
*
|
|
11
|
+
* @returns {UseCookiesReturn<T>} - An object containing:
|
|
12
|
+
* - `state`: The current state.
|
|
13
|
+
* - `resetState`: A function to reset the state to the initial value and remove the cookie.
|
|
14
|
+
* - `setState`: A function to update the state and save it to the cookie.
|
|
15
|
+
* - `setField`: A function to update a specific field in the state and save it to the cookie.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const { state, setState, setField, resetState } = useCookies('user', { name: '', age: 0 });
|
|
19
|
+
*
|
|
20
|
+
* return (
|
|
21
|
+
* <div>
|
|
22
|
+
* <p>Name: {state.name}</p>
|
|
23
|
+
* <p>Age: {state.age}</p>
|
|
24
|
+
* <button onClick={() => setField('name', 'John')}>Set Name</button>
|
|
25
|
+
* <button onClick={resetState}>Reset</button>
|
|
26
|
+
* </div>
|
|
27
|
+
* );
|
|
28
|
+
*/
|
|
29
|
+
type UseCookiesOptions = CookieOptions & {
|
|
30
|
+
initializeWithValue?: boolean;
|
|
31
|
+
};
|
|
32
|
+
type UseCookiesReturn<T> = {
|
|
33
|
+
state: T;
|
|
34
|
+
resetState: (defaultState?: T) => void;
|
|
35
|
+
setState: (updateState: T | Partial<T>) => void;
|
|
36
|
+
setField: (name: keyof T, updateValue: T[keyof T]) => void;
|
|
37
|
+
};
|
|
38
|
+
declare function useCookies<T>(key: string, initialState?: T, options?: UseCookiesOptions): UseCookiesReturn<T>;
|
|
39
|
+
|
|
40
|
+
export { type UseCookiesOptions, type UseCookiesReturn, useCookies };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CookieOptions } from '../../utils/cookies/cookies.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to manage state with cookies.
|
|
5
|
+
*
|
|
6
|
+
* @template T
|
|
7
|
+
* @param {string} key - The key for the cookie.
|
|
8
|
+
* @param {T} initialState - The initial state value.
|
|
9
|
+
* @param {UseCookiesOptions} [options] - Optional settings.
|
|
10
|
+
*
|
|
11
|
+
* @returns {UseCookiesReturn<T>} - An object containing:
|
|
12
|
+
* - `state`: The current state.
|
|
13
|
+
* - `resetState`: A function to reset the state to the initial value and remove the cookie.
|
|
14
|
+
* - `setState`: A function to update the state and save it to the cookie.
|
|
15
|
+
* - `setField`: A function to update a specific field in the state and save it to the cookie.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const { state, setState, setField, resetState } = useCookies('user', { name: '', age: 0 });
|
|
19
|
+
*
|
|
20
|
+
* return (
|
|
21
|
+
* <div>
|
|
22
|
+
* <p>Name: {state.name}</p>
|
|
23
|
+
* <p>Age: {state.age}</p>
|
|
24
|
+
* <button onClick={() => setField('name', 'John')}>Set Name</button>
|
|
25
|
+
* <button onClick={resetState}>Reset</button>
|
|
26
|
+
* </div>
|
|
27
|
+
* );
|
|
28
|
+
*/
|
|
29
|
+
type UseCookiesOptions = CookieOptions & {
|
|
30
|
+
initializeWithValue?: boolean;
|
|
31
|
+
};
|
|
32
|
+
type UseCookiesReturn<T> = {
|
|
33
|
+
state: T;
|
|
34
|
+
resetState: (defaultState?: T) => void;
|
|
35
|
+
setState: (updateState: T | Partial<T>) => void;
|
|
36
|
+
setField: (name: keyof T, updateValue: T[keyof T]) => void;
|
|
37
|
+
};
|
|
38
|
+
declare function useCookies<T>(key: string, initialState?: T, options?: UseCookiesOptions): UseCookiesReturn<T>;
|
|
39
|
+
|
|
40
|
+
export { type UseCookiesOptions, type UseCookiesReturn, useCookies };
|