asterui 0.10.2 → 0.11.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 +12 -9
- package/dist/components/Segmented.d.ts +37 -0
- package/dist/components/Tour.d.ts +61 -0
- package/dist/hooks/useClickOutside.d.ts +17 -0
- package/dist/hooks/useClipboard.d.ts +20 -0
- package/dist/hooks/useDebounce.d.ts +18 -0
- package/dist/hooks/useDisclosure.d.ts +20 -0
- package/dist/hooks/useHover.d.ts +18 -0
- package/dist/hooks/useKeyPress.d.ts +40 -0
- package/dist/hooks/useLocalStorage.d.ts +12 -0
- package/dist/hooks/usePrevious.d.ts +15 -0
- package/dist/hooks/useWindowSize.d.ts +21 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +143 -120
- package/dist/index.js.map +1 -1
- package/dist/index100.js +5 -21
- package/dist/index100.js.map +1 -1
- package/dist/index101.js +41 -23
- package/dist/index101.js.map +1 -1
- package/dist/index102.js +2 -20
- package/dist/index102.js.map +1 -1
- package/dist/index103.js +6 -99
- package/dist/index103.js.map +1 -1
- package/dist/index104.js +149 -357
- package/dist/index104.js.map +1 -1
- package/dist/index105.js +28 -23
- package/dist/index105.js.map +1 -1
- package/dist/index106.js +28 -71
- package/dist/index106.js.map +1 -1
- package/dist/index107.js +2 -16
- package/dist/index107.js.map +1 -1
- package/dist/index108.js +71 -65
- package/dist/index108.js.map +1 -1
- package/dist/index109.js +34 -139
- package/dist/index109.js.map +1 -1
- package/dist/index110.js +26 -2
- package/dist/index110.js.map +1 -1
- package/dist/index111.js +20 -55
- package/dist/index111.js.map +1 -1
- package/dist/index112.js +24 -2
- package/dist/index112.js.map +1 -1
- package/dist/index113.js +20 -2
- package/dist/index113.js.map +1 -1
- package/dist/index114.js +100 -2
- package/dist/index114.js.map +1 -1
- package/dist/index115.js +360 -2
- package/dist/index115.js.map +1 -1
- package/dist/index116.js +25 -2
- package/dist/index116.js.map +1 -1
- package/dist/index117.js +73 -2
- package/dist/index117.js.map +1 -1
- package/dist/index118.js +16 -2
- package/dist/index118.js.map +1 -1
- package/dist/index119.js +66 -2
- package/dist/index119.js.map +1 -1
- package/dist/index120.js +140 -28
- package/dist/index120.js.map +1 -1
- package/dist/index121.js +2 -2
- package/dist/index122.js +55 -7
- package/dist/index122.js.map +1 -1
- package/dist/index123.js +2 -2
- package/dist/index124.js +2 -2
- package/dist/index125.js +2 -21
- package/dist/index125.js.map +1 -1
- package/dist/index126.js +2 -2
- package/dist/index127.js +2 -24
- package/dist/index127.js.map +1 -1
- package/dist/index128.js +2 -71
- package/dist/index128.js.map +1 -1
- package/dist/index129.js +2 -21
- package/dist/index129.js.map +1 -1
- package/dist/index130.js +31 -33
- package/dist/index130.js.map +1 -1
- package/dist/index131.js +2 -70
- package/dist/index131.js.map +1 -1
- package/dist/index132.js +8 -2
- package/dist/index132.js.map +1 -1
- package/dist/index133.js +2 -22
- package/dist/index133.js.map +1 -1
- package/dist/index135.js +21 -2
- package/dist/index135.js.map +1 -1
- package/dist/index137.js +24 -2
- package/dist/index137.js.map +1 -1
- package/dist/index138.js +70 -3
- package/dist/index138.js.map +1 -1
- package/dist/index139.js +24 -0
- package/dist/index139.js.map +1 -0
- package/dist/index14.js +1 -1
- package/dist/index140.js +37 -0
- package/dist/index140.js.map +1 -0
- package/dist/index141.js +73 -0
- package/dist/index141.js.map +1 -0
- package/dist/index142.js +5 -0
- package/dist/index142.js.map +1 -0
- package/dist/index143.js +5 -0
- package/dist/index143.js.map +1 -0
- package/dist/index144.js +25 -0
- package/dist/index144.js.map +1 -0
- package/dist/index145.js +5 -0
- package/dist/index145.js.map +1 -0
- package/dist/index146.js +5 -0
- package/dist/index146.js.map +1 -0
- package/dist/index147.js +5 -0
- package/dist/index147.js.map +1 -0
- package/dist/index148.js +5 -0
- package/dist/index148.js.map +1 -0
- package/dist/index149.js +7 -0
- package/dist/index149.js.map +1 -0
- package/dist/index59.js +1 -1
- package/dist/index66.js +66 -19
- package/dist/index66.js.map +1 -1
- package/dist/index67.js +18 -43
- package/dist/index67.js.map +1 -1
- package/dist/index68.js +44 -132
- package/dist/index68.js.map +1 -1
- package/dist/index69.js +132 -50
- package/dist/index69.js.map +1 -1
- package/dist/index70.js +51 -21
- package/dist/index70.js.map +1 -1
- package/dist/index71.js +19 -19
- package/dist/index71.js.map +1 -1
- package/dist/index72.js +20 -327
- package/dist/index72.js.map +1 -1
- package/dist/index73.js +323 -50
- package/dist/index73.js.map +1 -1
- package/dist/index74.js +56 -40
- package/dist/index74.js.map +1 -1
- package/dist/index75.js +40 -95
- package/dist/index75.js.map +1 -1
- package/dist/index76.js +88 -123
- package/dist/index76.js.map +1 -1
- package/dist/index77.js +123 -154
- package/dist/index77.js.map +1 -1
- package/dist/index78.js +159 -63
- package/dist/index78.js.map +1 -1
- package/dist/index79.js +65 -35
- package/dist/index79.js.map +1 -1
- package/dist/index80.js +35 -34
- package/dist/index80.js.map +1 -1
- package/dist/index81.js +222 -198
- package/dist/index81.js.map +1 -1
- package/dist/index82.js +34 -213
- package/dist/index82.js.map +1 -1
- package/dist/index83.js +190 -275
- package/dist/index83.js.map +1 -1
- package/dist/index84.js +202 -167
- package/dist/index84.js.map +1 -1
- package/dist/index85.js +263 -226
- package/dist/index85.js.map +1 -1
- package/dist/index86.js +176 -12
- package/dist/index86.js.map +1 -1
- package/dist/index87.js +257 -32
- package/dist/index87.js.map +1 -1
- package/dist/index88.js +13 -10792
- package/dist/index88.js.map +1 -1
- package/dist/index89.js +33 -5
- package/dist/index89.js.map +1 -1
- package/dist/index90.js +5 -41
- package/dist/index90.js.map +1 -1
- package/dist/index91.js +14 -2
- package/dist/index91.js.map +1 -1
- package/dist/index92.js +45 -6
- package/dist/index92.js.map +1 -1
- package/dist/index93.js +11 -150
- package/dist/index93.js.map +1 -1
- package/dist/index94.js +13 -28
- package/dist/index94.js.map +1 -1
- package/dist/index95.js +7 -29
- package/dist/index95.js.map +1 -1
- package/dist/index96.js +13 -2
- package/dist/index96.js.map +1 -1
- package/dist/index97.js +30 -71
- package/dist/index97.js.map +1 -1
- package/dist/index98.js +16 -37
- package/dist/index98.js.map +1 -1
- package/dist/index99.js +10792 -25
- package/dist/index99.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AsterUI
|
|
2
2
|
|
|
3
3
|
A comprehensive React component library built with [DaisyUI](https://daisyui.com) and [Tailwind CSS](https://tailwindcss.com).
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
AsterUI requires Tailwind CSS v4 and DaisyUI v5 to be configured in your project.
|
|
8
8
|
|
|
9
9
|
Install Tailwind and DaisyUI:
|
|
10
10
|
|
|
@@ -29,25 +29,25 @@ Configure your CSS file (e.g., `src/index.css`):
|
|
|
29
29
|
```css
|
|
30
30
|
@import "tailwindcss";
|
|
31
31
|
@plugin "daisyui";
|
|
32
|
-
@source "../node_modules
|
|
32
|
+
@source "../node_modules/asterui";
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
The `@source` directive tells Tailwind to scan the
|
|
35
|
+
The `@source` directive tells Tailwind to scan the AsterUI package for classes to include in your build.
|
|
36
36
|
|
|
37
37
|
## Installation
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
npm install
|
|
40
|
+
npm install asterui
|
|
41
41
|
# or
|
|
42
|
-
pnpm add
|
|
42
|
+
pnpm add asterui
|
|
43
43
|
# or
|
|
44
|
-
yarn add
|
|
44
|
+
yarn add asterui
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
## Usage
|
|
48
48
|
|
|
49
49
|
```tsx
|
|
50
|
-
import { Form, Input, Checkbox, Button, Modal, Card, Space, Flex, Typography } from '
|
|
50
|
+
import { Form, Input, Checkbox, Button, Modal, Card, Space, Flex, Typography } from 'asterui'
|
|
51
51
|
|
|
52
52
|
const { Link, Paragraph } = Typography
|
|
53
53
|
|
|
@@ -124,9 +124,11 @@ export default function App() {
|
|
|
124
124
|
- **InputNumber** - Numeric input with increment/decrement controls
|
|
125
125
|
- **Label** - Form labels with required indicator and floating labels
|
|
126
126
|
- **Mention** - Input with @mention support for tagging users
|
|
127
|
+
- **OTPInput** - One-time password input with auto-focus
|
|
127
128
|
- **Radio** - Radio buttons with group support
|
|
128
129
|
- **Range** - Range slider with min, max, and step support
|
|
129
130
|
- **Rating** - Star rating component
|
|
131
|
+
- **Segmented** - Inline toggle for switching between mutually exclusive options
|
|
130
132
|
- **Select** - Select dropdown with sizes and colors
|
|
131
133
|
- **Textarea** - Multiline text input
|
|
132
134
|
- **TimePicker** - Time input with hour and minute selection
|
|
@@ -192,6 +194,7 @@ export default function App() {
|
|
|
192
194
|
- **Result** - Result pages for operation outcomes
|
|
193
195
|
- **Skeleton** - Loading placeholder with animated shimmer effect
|
|
194
196
|
- **Tooltip** - Tooltips with multiple placements
|
|
197
|
+
- **Tour** - Guided tour with spotlight and step navigation
|
|
195
198
|
|
|
196
199
|
### Mockup
|
|
197
200
|
- **Browser** - Browser window mockup with URL bar
|
|
@@ -201,7 +204,7 @@ export default function App() {
|
|
|
201
204
|
|
|
202
205
|
## Demo
|
|
203
206
|
|
|
204
|
-
View live examples and documentation at [https://
|
|
207
|
+
View live examples and documentation at [https://asterui.com](https://asterui.com)
|
|
205
208
|
|
|
206
209
|
## Requirements
|
|
207
210
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type SegmentedValue = string | number;
|
|
3
|
+
export interface SegmentedItemProps {
|
|
4
|
+
/** Option value */
|
|
5
|
+
value: SegmentedValue;
|
|
6
|
+
/** Disable this option */
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** Icon to display before label */
|
|
9
|
+
icon?: React.ReactNode;
|
|
10
|
+
/** Label content */
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
/** Additional CSS class */
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const SegmentedItem: React.FC<SegmentedItemProps>;
|
|
16
|
+
export interface SegmentedProps {
|
|
17
|
+
/** Currently selected value (controlled) */
|
|
18
|
+
value?: SegmentedValue;
|
|
19
|
+
/** Default selected value (uncontrolled) */
|
|
20
|
+
defaultValue?: SegmentedValue;
|
|
21
|
+
/** Callback when selection changes */
|
|
22
|
+
onChange?: (value: SegmentedValue) => void;
|
|
23
|
+
/** Size variant */
|
|
24
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
25
|
+
/** Take full width of container */
|
|
26
|
+
block?: boolean;
|
|
27
|
+
/** Disable all options */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** Additional CSS class */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** Segmented.Item children */
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
export declare const Segmented: React.FC<SegmentedProps> & {
|
|
35
|
+
Item: typeof SegmentedItem;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type TourPlacement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight' | 'left' | 'leftTop' | 'leftBottom' | 'right' | 'rightTop' | 'rightBottom' | 'center';
|
|
3
|
+
export interface TourStepProps {
|
|
4
|
+
/** Target element ref or function returning element */
|
|
5
|
+
target?: React.RefObject<HTMLElement | null> | (() => HTMLElement | null) | null;
|
|
6
|
+
/** Step title */
|
|
7
|
+
title: React.ReactNode;
|
|
8
|
+
/** Step description */
|
|
9
|
+
description?: React.ReactNode;
|
|
10
|
+
/** Cover image or content above title */
|
|
11
|
+
cover?: React.ReactNode;
|
|
12
|
+
/** Placement of popover relative to target */
|
|
13
|
+
placement?: TourPlacement;
|
|
14
|
+
/** Custom class for this step's popover */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Called when this step becomes active */
|
|
17
|
+
onOpen?: () => void;
|
|
18
|
+
/** Called when leaving this step */
|
|
19
|
+
onClose?: () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface TourProps {
|
|
22
|
+
/** Whether tour is visible */
|
|
23
|
+
open?: boolean;
|
|
24
|
+
/** Callback when tour closes */
|
|
25
|
+
onClose?: () => void;
|
|
26
|
+
/** Callback when tour finishes (last step completed) */
|
|
27
|
+
onFinish?: () => void;
|
|
28
|
+
/** Tour steps */
|
|
29
|
+
steps: TourStepProps[];
|
|
30
|
+
/** Current step (controlled) */
|
|
31
|
+
current?: number;
|
|
32
|
+
/** Callback when step changes */
|
|
33
|
+
onChange?: (current: number) => void;
|
|
34
|
+
/** Show mask overlay */
|
|
35
|
+
mask?: boolean;
|
|
36
|
+
/** Type affects styling */
|
|
37
|
+
type?: 'default' | 'primary';
|
|
38
|
+
/** Gap between highlight and target [radius, offset] or single number */
|
|
39
|
+
gap?: number | [number, number];
|
|
40
|
+
/** Text for prev button */
|
|
41
|
+
prevButtonText?: React.ReactNode;
|
|
42
|
+
/** Text for next button */
|
|
43
|
+
nextButtonText?: React.ReactNode;
|
|
44
|
+
/** Text for finish button */
|
|
45
|
+
finishButtonText?: React.ReactNode;
|
|
46
|
+
/** Text for skip button */
|
|
47
|
+
skipButtonText?: React.ReactNode;
|
|
48
|
+
/** Show skip button */
|
|
49
|
+
showSkip?: boolean;
|
|
50
|
+
/** Show step indicators */
|
|
51
|
+
showIndicators?: boolean;
|
|
52
|
+
/** Close on mask click */
|
|
53
|
+
closeOnMaskClick?: boolean;
|
|
54
|
+
/** Close on escape key */
|
|
55
|
+
closeOnEscape?: boolean;
|
|
56
|
+
/** Scroll target into view */
|
|
57
|
+
scrollIntoView?: boolean;
|
|
58
|
+
/** Z-index for tour overlay */
|
|
59
|
+
zIndex?: number;
|
|
60
|
+
}
|
|
61
|
+
export declare const Tour: React.FC<TourProps>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that detects clicks outside of a referenced element.
|
|
4
|
+
* Useful for closing dropdowns, modals, or menus.
|
|
5
|
+
*
|
|
6
|
+
* @param handler - Callback when click outside is detected
|
|
7
|
+
* @param enabled - Whether the listener is active (default: true)
|
|
8
|
+
* @returns Ref to attach to the element
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const ref = useClickOutside(() => setIsOpen(false))
|
|
12
|
+
*
|
|
13
|
+
* <div ref={ref}>
|
|
14
|
+
* <Dropdown>...</Dropdown>
|
|
15
|
+
* </div>
|
|
16
|
+
*/
|
|
17
|
+
export declare function useClickOutside<T extends HTMLElement = HTMLElement>(handler: (event: MouseEvent | TouchEvent) => void, enabled?: boolean): RefObject<T | null>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface UseClipboardReturn {
|
|
2
|
+
copy: (text: string) => Promise<boolean>;
|
|
3
|
+
copied: boolean;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
reset: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Hook for copying text to clipboard with success/error state.
|
|
9
|
+
*
|
|
10
|
+
* @param timeout - Duration in ms to show copied state (default: 2000)
|
|
11
|
+
* @returns Object with copy function and state
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const { copy, copied } = useClipboard()
|
|
15
|
+
*
|
|
16
|
+
* <Button onClick={() => copy('Hello!')}>
|
|
17
|
+
* {copied ? 'Copied!' : 'Copy'}
|
|
18
|
+
* </Button>
|
|
19
|
+
*/
|
|
20
|
+
export declare function useClipboard(timeout?: number): UseClipboardReturn;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook that delays updating a value until after a specified delay.
|
|
3
|
+
* Useful for search inputs to avoid excessive API calls.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Value to debounce
|
|
6
|
+
* @param delay - Delay in milliseconds (default: 300)
|
|
7
|
+
* @returns Debounced value
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const [search, setSearch] = useState('')
|
|
11
|
+
* const debouncedSearch = useDebounce(search, 500)
|
|
12
|
+
*
|
|
13
|
+
* useEffect(() => {
|
|
14
|
+
* // This runs 500ms after user stops typing
|
|
15
|
+
* fetchResults(debouncedSearch)
|
|
16
|
+
* }, [debouncedSearch])
|
|
17
|
+
*/
|
|
18
|
+
export declare function useDebounce<T>(value: T, delay?: number): T;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface UseDisclosureReturn {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onOpen: () => void;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onToggle: () => void;
|
|
6
|
+
setIsOpen: (value: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Hook for managing open/close state of modals, drawers, dropdowns, etc.
|
|
10
|
+
*
|
|
11
|
+
* @param defaultIsOpen - Initial open state (default: false)
|
|
12
|
+
* @returns Object with isOpen state and control functions
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const { isOpen, onOpen, onClose } = useDisclosure()
|
|
16
|
+
*
|
|
17
|
+
* <Button onClick={onOpen}>Open Modal</Button>
|
|
18
|
+
* <Modal open={isOpen} onClose={onClose}>Content</Modal>
|
|
19
|
+
*/
|
|
20
|
+
export declare function useDisclosure(defaultIsOpen?: boolean): UseDisclosureReturn;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export interface UseHoverReturn<T extends HTMLElement> {
|
|
3
|
+
ref: RefObject<T | null>;
|
|
4
|
+
isHovered: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Hook that tracks hover state of an element.
|
|
8
|
+
*
|
|
9
|
+
* @returns Object with ref and isHovered state
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const { ref, isHovered } = useHover<HTMLDivElement>()
|
|
13
|
+
*
|
|
14
|
+
* <div ref={ref} className={isHovered ? 'bg-blue-500' : 'bg-gray-500'}>
|
|
15
|
+
* Hover me!
|
|
16
|
+
* </div>
|
|
17
|
+
*/
|
|
18
|
+
export declare function useHover<T extends HTMLElement = HTMLElement>(): UseHoverReturn<T>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface UseKeyPressOptions {
|
|
2
|
+
/** Target element (default: window) */
|
|
3
|
+
target?: HTMLElement | Window | null;
|
|
4
|
+
/** Event type: 'keydown' | 'keyup' (default: 'keydown') */
|
|
5
|
+
event?: 'keydown' | 'keyup';
|
|
6
|
+
/** Prevent default browser behavior */
|
|
7
|
+
preventDefault?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook that detects when a specific key is pressed.
|
|
11
|
+
*
|
|
12
|
+
* @param targetKey - Key to detect (e.g., 'Enter', 'Escape', 'a')
|
|
13
|
+
* @param options - Configuration options
|
|
14
|
+
* @returns Whether the key is currently pressed
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const enterPressed = useKeyPress('Enter')
|
|
18
|
+
* const escapePressed = useKeyPress('Escape')
|
|
19
|
+
*
|
|
20
|
+
* useEffect(() => {
|
|
21
|
+
* if (escapePressed) closeModal()
|
|
22
|
+
* }, [escapePressed])
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // With callback for immediate action
|
|
26
|
+
* useKeyPress('Escape', { preventDefault: true })
|
|
27
|
+
*/
|
|
28
|
+
export declare function useKeyPress(targetKey: string, options?: UseKeyPressOptions): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Hook that calls a callback when a specific key is pressed.
|
|
31
|
+
*
|
|
32
|
+
* @param targetKey - Key to detect
|
|
33
|
+
* @param callback - Function to call when key is pressed
|
|
34
|
+
* @param options - Configuration options
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* useKeyPressCallback('Escape', () => closeModal())
|
|
38
|
+
* useKeyPressCallback('Enter', () => submitForm(), { preventDefault: true })
|
|
39
|
+
*/
|
|
40
|
+
export declare function useKeyPressCallback(targetKey: string, callback: (event: KeyboardEvent) => void, options?: UseKeyPressOptions): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for persisting state to localStorage.
|
|
3
|
+
*
|
|
4
|
+
* @param key - localStorage key
|
|
5
|
+
* @param initialValue - Initial value if key doesn't exist
|
|
6
|
+
* @returns [value, setValue, removeValue] tuple
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const [theme, setTheme] = useLocalStorage('theme', 'light')
|
|
10
|
+
* const [user, setUser, removeUser] = useLocalStorage('user', null)
|
|
11
|
+
*/
|
|
12
|
+
export declare function useLocalStorage<T>(key: string, initialValue: T): [T, (value: T | ((prev: T) => T)) => void, () => void];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook that returns the previous value of a variable.
|
|
3
|
+
* Useful for comparing current and previous values in effects.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Current value
|
|
6
|
+
* @returns Previous value (undefined on first render)
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const [count, setCount] = useState(0)
|
|
10
|
+
* const prevCount = usePrevious(count)
|
|
11
|
+
*
|
|
12
|
+
* // prevCount is the value from previous render
|
|
13
|
+
* console.log(`Changed from ${prevCount} to ${count}`)
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePrevious<T>(value: T): T | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface WindowSize {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Hook that tracks window dimensions.
|
|
7
|
+
* Updates on window resize.
|
|
8
|
+
*
|
|
9
|
+
* @returns Object with current width and height
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const { width, height } = useWindowSize()
|
|
13
|
+
*
|
|
14
|
+
* return (
|
|
15
|
+
* <div>
|
|
16
|
+
* Window: {width} x {height}
|
|
17
|
+
* {width < 768 && <MobileNav />}
|
|
18
|
+
* </div>
|
|
19
|
+
* )
|
|
20
|
+
*/
|
|
21
|
+
export declare function useWindowSize(): WindowSize;
|
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,8 @@ export { Result } from './components/Result';
|
|
|
126
126
|
export type { ResultProps, ResultStatus } from './components/Result';
|
|
127
127
|
export { Select } from './components/Select';
|
|
128
128
|
export type { SelectProps } from './components/Select';
|
|
129
|
+
export { Segmented } from './components/Segmented';
|
|
130
|
+
export type { SegmentedProps, SegmentedItemProps, SegmentedValue } from './components/Segmented';
|
|
129
131
|
export { Skeleton } from './components/Skeleton';
|
|
130
132
|
export type { SkeletonProps } from './components/Skeleton';
|
|
131
133
|
export { Space } from './components/Space';
|
|
@@ -154,6 +156,8 @@ export { Timeline } from './components/Timeline';
|
|
|
154
156
|
export type { TimelineProps, TimelineItemProps } from './components/Timeline';
|
|
155
157
|
export { Toggle } from './components/Toggle';
|
|
156
158
|
export type { ToggleProps } from './components/Toggle';
|
|
159
|
+
export { Tour } from './components/Tour';
|
|
160
|
+
export type { TourProps, TourStepProps, TourPlacement } from './components/Tour';
|
|
157
161
|
export { Tooltip } from './components/Tooltip';
|
|
158
162
|
export type { TooltipProps } from './components/Tooltip';
|
|
159
163
|
export { Transfer } from './components/Transfer';
|
|
@@ -170,3 +174,17 @@ export { Show, Hide } from './components/Responsive';
|
|
|
170
174
|
export type { ShowProps, HideProps } from './components/Responsive';
|
|
171
175
|
export { useBreakpoint } from './hooks/useBreakpoint';
|
|
172
176
|
export type { Breakpoint, UseBreakpointReturn } from './hooks/useBreakpoint';
|
|
177
|
+
export { useDisclosure } from './hooks/useDisclosure';
|
|
178
|
+
export type { UseDisclosureReturn } from './hooks/useDisclosure';
|
|
179
|
+
export { useClipboard } from './hooks/useClipboard';
|
|
180
|
+
export type { UseClipboardReturn } from './hooks/useClipboard';
|
|
181
|
+
export { useLocalStorage } from './hooks/useLocalStorage';
|
|
182
|
+
export { useDebounce } from './hooks/useDebounce';
|
|
183
|
+
export { useClickOutside } from './hooks/useClickOutside';
|
|
184
|
+
export { usePrevious } from './hooks/usePrevious';
|
|
185
|
+
export { useHover } from './hooks/useHover';
|
|
186
|
+
export type { UseHoverReturn } from './hooks/useHover';
|
|
187
|
+
export { useKeyPress, useKeyPressCallback } from './hooks/useKeyPress';
|
|
188
|
+
export type { UseKeyPressOptions } from './hooks/useKeyPress';
|
|
189
|
+
export { useWindowSize } from './hooks/useWindowSize';
|
|
190
|
+
export type { WindowSize } from './hooks/useWindowSize';
|