asterui 0.12.0 → 0.12.1
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 +1 -1
- package/dist/components/Form.d.ts +27 -2
- package/dist/components/Radio.d.ts +7 -1
- package/dist/components/Status.d.ts +18 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +61 -59
- package/dist/index.js.map +1 -1
- package/dist/index100.js +7 -12
- package/dist/index100.js.map +1 -1
- package/dist/index101.js +11 -29
- package/dist/index101.js.map +1 -1
- package/dist/index102.js +29 -16
- package/dist/index102.js.map +1 -1
- package/dist/index103.js +17 -10792
- package/dist/index103.js.map +1 -1
- package/dist/index104.js +10793 -5
- package/dist/index104.js.map +1 -1
- package/dist/index105.js +5 -42
- package/dist/index105.js.map +1 -1
- package/dist/index106.js +42 -2
- package/dist/index106.js.map +1 -1
- package/dist/index107.js +2 -7
- package/dist/index107.js.map +1 -1
- package/dist/index108.js +6 -151
- package/dist/index108.js.map +1 -1
- package/dist/index109.js +147 -25
- package/dist/index109.js.map +1 -1
- package/dist/index110.js +28 -28
- package/dist/index110.js.map +1 -1
- package/dist/index111.js +30 -2
- package/dist/index111.js.map +1 -1
- package/dist/index112.js +2 -72
- package/dist/index112.js.map +1 -1
- package/dist/index113.js +71 -38
- package/dist/index113.js.map +1 -1
- package/dist/index114.js +37 -24
- package/dist/index114.js.map +1 -1
- package/dist/index115.js +24 -19
- package/dist/index115.js.map +1 -1
- package/dist/index116.js +20 -23
- package/dist/index116.js.map +1 -1
- package/dist/index117.js +23 -19
- package/dist/index117.js.map +1 -1
- package/dist/index118.js +19 -99
- package/dist/index118.js.map +1 -1
- package/dist/index119.js +98 -358
- package/dist/index119.js.map +1 -1
- package/dist/index120.js +358 -23
- package/dist/index120.js.map +1 -1
- package/dist/index121.js +23 -71
- package/dist/index121.js.map +1 -1
- package/dist/index122.js +72 -15
- package/dist/index122.js.map +1 -1
- package/dist/index123.js +15 -65
- package/dist/index123.js.map +1 -1
- package/dist/index124.js +61 -139
- package/dist/index124.js.map +1 -1
- package/dist/index125.js +144 -2
- package/dist/index125.js.map +1 -1
- package/dist/index126.js +2 -56
- package/dist/index126.js.map +1 -1
- package/dist/index127.js +56 -2
- package/dist/index127.js.map +1 -1
- package/dist/index128.js +2 -2
- package/dist/index131.js +2 -2
- package/dist/index132.js +2 -2
- package/dist/index133.js +2 -2
- package/dist/index134.js +2 -2
- package/dist/index135.js +2 -32
- package/dist/index135.js.map +1 -1
- package/dist/index136.js +32 -2
- package/dist/index136.js.map +1 -1
- package/dist/index137.js +2 -8
- package/dist/index137.js.map +1 -1
- package/dist/index138.js +8 -2
- package/dist/index138.js.map +1 -1
- package/dist/index139.js +2 -2
- package/dist/index140.js +2 -21
- package/dist/index140.js.map +1 -1
- package/dist/index141.js +21 -2
- package/dist/index141.js.map +1 -1
- package/dist/index142.js +2 -24
- package/dist/index142.js.map +1 -1
- package/dist/index143.js +17 -64
- package/dist/index143.js.map +1 -1
- package/dist/index144.js +68 -18
- package/dist/index144.js.map +1 -1
- package/dist/index145.js +18 -31
- package/dist/index145.js.map +1 -1
- package/dist/index146.js +32 -68
- package/dist/index146.js.map +1 -1
- package/dist/index147.js +70 -2
- package/dist/index147.js.map +1 -1
- package/dist/index148.js +2 -22
- package/dist/index148.js.map +1 -1
- package/dist/index149.js +22 -2
- package/dist/index149.js.map +1 -1
- package/dist/index15.js +1 -1
- package/dist/index151.js +2 -2
- package/dist/index152.js +2 -2
- package/dist/index153.js +2 -4
- package/dist/index153.js.map +1 -1
- package/dist/index154.js +7 -0
- package/dist/index154.js.map +1 -0
- package/dist/index31.js +175 -116
- package/dist/index31.js.map +1 -1
- package/dist/index62.js +1 -1
- package/dist/index63.js +24 -24
- package/dist/index63.js.map +1 -1
- package/dist/index75.js +31 -22
- package/dist/index75.js.map +1 -1
- package/dist/index76.js +20 -327
- package/dist/index76.js.map +1 -1
- package/dist/index77.js +323 -50
- package/dist/index77.js.map +1 -1
- package/dist/index78.js +56 -40
- package/dist/index78.js.map +1 -1
- package/dist/index79.js +40 -23
- package/dist/index79.js.map +1 -1
- package/dist/index80.js +21 -93
- package/dist/index80.js.map +1 -1
- package/dist/index81.js +88 -123
- package/dist/index81.js.map +1 -1
- package/dist/index82.js +123 -154
- package/dist/index82.js.map +1 -1
- package/dist/index83.js +159 -63
- package/dist/index83.js.map +1 -1
- package/dist/index84.js +65 -35
- package/dist/index84.js.map +1 -1
- package/dist/index85.js +35 -234
- package/dist/index85.js.map +1 -1
- package/dist/index86.js +231 -31
- package/dist/index86.js.map +1 -1
- package/dist/index87.js +34 -210
- package/dist/index87.js.map +1 -1
- package/dist/index88.js +195 -198
- package/dist/index88.js.map +1 -1
- package/dist/index89.js +159 -241
- package/dist/index89.js.map +1 -1
- package/dist/index90.js +283 -166
- package/dist/index90.js.map +1 -1
- package/dist/index91.js +173 -253
- package/dist/index91.js.map +1 -1
- package/dist/index92.js +258 -14
- package/dist/index92.js.map +1 -1
- package/dist/index93.js +12 -31
- package/dist/index93.js.map +1 -1
- package/dist/index94.js +32 -5
- package/dist/index94.js.map +1 -1
- package/dist/index95.js +5 -13
- package/dist/index95.js.map +1 -1
- package/dist/index96.js +11 -43
- package/dist/index96.js.map +1 -1
- package/dist/index97.js +44 -11
- package/dist/index97.js.map +1 -1
- package/dist/index98.js +10 -12
- package/dist/index98.js.map +1 -1
- package/dist/index99.js +14 -7
- package/dist/index99.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ export default function App() {
|
|
|
102
102
|
|
|
103
103
|
## Components
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
90+ components including forms, data display, navigation, feedback, and layout. See the full list at [asterui.com/components](https://asterui.com/components).
|
|
106
106
|
|
|
107
107
|
## Requirements
|
|
108
108
|
|
|
@@ -5,6 +5,8 @@ export interface FormProps<TFieldValues extends FieldValues = FieldValues> exten
|
|
|
5
5
|
onFinish?: SubmitHandler<TFieldValues>;
|
|
6
6
|
initialValues?: UseFormProps<TFieldValues>['defaultValues'];
|
|
7
7
|
layout?: 'vertical' | 'horizontal' | 'inline';
|
|
8
|
+
/** Label width in pixels for horizontal layout (default: 80) */
|
|
9
|
+
labelWidth?: number;
|
|
8
10
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
11
|
children: React.ReactNode;
|
|
10
12
|
}
|
|
@@ -26,6 +28,7 @@ export interface FormRule {
|
|
|
26
28
|
message?: string;
|
|
27
29
|
validate?: (value: any) => boolean | string | Promise<boolean | string>;
|
|
28
30
|
}
|
|
31
|
+
export type ValidateTrigger = 'onChange' | 'onBlur' | 'onSubmit' | ('onChange' | 'onBlur' | 'onSubmit')[];
|
|
29
32
|
export interface FormItemProps {
|
|
30
33
|
name?: string | string[];
|
|
31
34
|
label?: string;
|
|
@@ -36,6 +39,20 @@ export interface FormItemProps {
|
|
|
36
39
|
inline?: boolean;
|
|
37
40
|
className?: string;
|
|
38
41
|
children: React.ReactElement;
|
|
42
|
+
/** Tooltip text to show next to label */
|
|
43
|
+
tooltip?: string;
|
|
44
|
+
/** Additional content below the form control */
|
|
45
|
+
extra?: React.ReactNode;
|
|
46
|
+
/** Show validation feedback icon */
|
|
47
|
+
hasFeedback?: boolean;
|
|
48
|
+
/** Field names that this field depends on for validation */
|
|
49
|
+
dependencies?: string[];
|
|
50
|
+
/** When to trigger validation */
|
|
51
|
+
validateTrigger?: ValidateTrigger;
|
|
52
|
+
/** Initial value for this field (overrides Form's initialValues) */
|
|
53
|
+
initialValue?: any;
|
|
54
|
+
/** Hide this field (still validates and submits) */
|
|
55
|
+
hidden?: boolean;
|
|
39
56
|
}
|
|
40
57
|
export interface FormListProps<TFieldValues extends FieldValues = FieldValues> {
|
|
41
58
|
name: FieldArrayPath<TFieldValues>;
|
|
@@ -45,8 +62,8 @@ export interface FormListProps<TFieldValues extends FieldValues = FieldValues> {
|
|
|
45
62
|
move: (from: number, to: number) => void;
|
|
46
63
|
}) => React.ReactNode;
|
|
47
64
|
}
|
|
48
|
-
declare function FormRoot<TFieldValues extends FieldValues = FieldValues>({ form: externalForm, onFinish, initialValues, layout, size, children, className, noValidate, ...props }: FormProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
49
|
-
declare function FormItem({ name, label, help, required, rules, valuePropName, inline, className, children, }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
declare function FormRoot<TFieldValues extends FieldValues = FieldValues>({ form: externalForm, onFinish, initialValues, layout, labelWidth, size, children, className, noValidate, ...props }: FormProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
66
|
+
declare function FormItem({ name, label, help, required, rules, valuePropName, inline, className, children, tooltip, extra, hasFeedback, dependencies, validateTrigger, initialValue, hidden, }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
50
67
|
declare function FormList<TFieldValues extends FieldValues = FieldValues>({ name, children, }: FormListProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
51
68
|
export declare function useFormInstance<TFieldValues extends FieldValues = FieldValues>(): UseFormReturn<TFieldValues, any, TFieldValues> & {
|
|
52
69
|
setFieldValue: import('react-hook-form').UseFormSetValue<TFieldValues>;
|
|
@@ -58,9 +75,17 @@ export declare function useFormInstance<TFieldValues extends FieldValues = Field
|
|
|
58
75
|
isFieldTouched: (name: string) => boolean;
|
|
59
76
|
getFieldError: (name: string) => string | undefined;
|
|
60
77
|
};
|
|
78
|
+
export interface FormErrorListProps {
|
|
79
|
+
/** Specific field names to show errors for (shows all errors if not specified) */
|
|
80
|
+
fields?: string[];
|
|
81
|
+
/** Custom className */
|
|
82
|
+
className?: string;
|
|
83
|
+
}
|
|
84
|
+
declare function FormErrorList({ fields, className }: FormErrorListProps): import("react/jsx-runtime").JSX.Element | null;
|
|
61
85
|
export declare const Form: typeof FormRoot & {
|
|
62
86
|
Item: typeof FormItem;
|
|
63
87
|
List: typeof FormList;
|
|
88
|
+
ErrorList: typeof FormErrorList;
|
|
64
89
|
useForm: typeof useFormInstance;
|
|
65
90
|
};
|
|
66
91
|
export type { UseFormReturn as FormInstance };
|
|
@@ -5,11 +5,17 @@ export interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
5
5
|
className?: string;
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
}
|
|
8
|
+
export interface RadioGroupChangeEvent {
|
|
9
|
+
target: {
|
|
10
|
+
value: string | number;
|
|
11
|
+
name?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
8
14
|
export interface RadioGroupProps {
|
|
9
15
|
children: React.ReactNode;
|
|
10
16
|
value?: string | number;
|
|
11
17
|
defaultValue?: string | number;
|
|
12
|
-
onChange?: (
|
|
18
|
+
onChange?: (e: RadioGroupChangeEvent) => void;
|
|
13
19
|
name?: string;
|
|
14
20
|
className?: string;
|
|
15
21
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type StatusType = 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
|
|
3
|
+
export type StatusSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
export interface StatusProps {
|
|
5
|
+
/** Status color type */
|
|
6
|
+
type?: StatusType;
|
|
7
|
+
/** Status size */
|
|
8
|
+
size?: StatusSize;
|
|
9
|
+
/** Ping animation effect */
|
|
10
|
+
ping?: boolean;
|
|
11
|
+
/** Bounce animation effect */
|
|
12
|
+
bounce?: boolean;
|
|
13
|
+
/** Accessibility label */
|
|
14
|
+
label?: string;
|
|
15
|
+
/** Additional CSS classes */
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const Status: React.FC<StatusProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export type { FloatButtonProps, BackTopProps } from './components/FloatButton';
|
|
|
57
57
|
export { Footer } from './components/Footer';
|
|
58
58
|
export type { FooterProps, FooterTitleProps } from './components/Footer';
|
|
59
59
|
export { Form, useFormInstance } from './components/Form';
|
|
60
|
-
export type { FormProps, FormItemProps, FormRule, FormInstance } from './components/Form';
|
|
60
|
+
export type { FormProps, FormItemProps, FormRule, FormInstance, FormErrorListProps, ValidateTrigger } from './components/Form';
|
|
61
61
|
export { Grid, Row, Col } from './components/Grid';
|
|
62
62
|
export type { RowProps, ColProps } from './components/Grid';
|
|
63
63
|
export { Hero } from './components/Hero';
|
|
@@ -121,7 +121,7 @@ export type { ProgressProps } from './components/Progress';
|
|
|
121
121
|
export { QRCode } from './components/QRCode';
|
|
122
122
|
export type { QRCodeProps, QRCodeErrorLevel, QRCodeType, QRCodeStatus } from './components/QRCode';
|
|
123
123
|
export { Radio } from './components/Radio';
|
|
124
|
-
export type { RadioProps, RadioGroupProps } from './components/Radio';
|
|
124
|
+
export type { RadioProps, RadioGroupProps, RadioGroupChangeEvent } from './components/Radio';
|
|
125
125
|
export { RadialProgress } from './components/RadialProgress';
|
|
126
126
|
export type { RadialProgressProps } from './components/RadialProgress';
|
|
127
127
|
export { Range } from './components/Range';
|
|
@@ -144,6 +144,8 @@ export { Stack } from './components/Stack';
|
|
|
144
144
|
export type { StackProps } from './components/Stack';
|
|
145
145
|
export { Stats } from './components/Stat';
|
|
146
146
|
export type { StatsProps, StatProps } from './components/Stat';
|
|
147
|
+
export { Status } from './components/Status';
|
|
148
|
+
export type { StatusProps, StatusType, StatusSize } from './components/Status';
|
|
147
149
|
export { Steps } from './components/Steps';
|
|
148
150
|
export type { StepsProps, StepProps } from './components/Steps';
|
|
149
151
|
export { Table } from './components/Table';
|
package/dist/index.js
CHANGED
|
@@ -71,34 +71,35 @@ import { Space as Nr } from "./index71.js";
|
|
|
71
71
|
import { Splitter as Wr } from "./index72.js";
|
|
72
72
|
import { Stack as Er } from "./index73.js";
|
|
73
73
|
import { Stats as Qr } from "./index74.js";
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import {
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
90
|
-
import {
|
|
91
|
-
import {
|
|
92
|
-
import {
|
|
93
|
-
import {
|
|
94
|
-
import {
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
74
|
+
import { Status as jr } from "./index75.js";
|
|
75
|
+
import { Steps as Vr } from "./index76.js";
|
|
76
|
+
import { Table as Yr } from "./index77.js";
|
|
77
|
+
import { Tabs as _r } from "./index78.js";
|
|
78
|
+
import { Textarea as oe } from "./index79.js";
|
|
79
|
+
import { TextRotate as ee } from "./index80.js";
|
|
80
|
+
import { CheckableTag as pe, Tag as me } from "./index81.js";
|
|
81
|
+
import { ThemeController as xe } from "./index82.js";
|
|
82
|
+
import { TimePicker as ie } from "./index83.js";
|
|
83
|
+
import { Timeline as se } from "./index84.js";
|
|
84
|
+
import { Toggle as le } from "./index85.js";
|
|
85
|
+
import { Tour as ce } from "./index86.js";
|
|
86
|
+
import { Tooltip as Te } from "./index87.js";
|
|
87
|
+
import { Transfer as Pe } from "./index88.js";
|
|
88
|
+
import { Tree as be } from "./index89.js";
|
|
89
|
+
import { TreeSelect as he } from "./index90.js";
|
|
90
|
+
import { Typography as ye } from "./index91.js";
|
|
91
|
+
import { Upload as Re } from "./index92.js";
|
|
92
|
+
import { Hide as Fe, Show as Ie } from "./index93.js";
|
|
93
|
+
import { useBreakpoint as Be } from "./index94.js";
|
|
94
|
+
import { useDisclosure as Me } from "./index95.js";
|
|
95
|
+
import { useClipboard as Ke } from "./index96.js";
|
|
96
|
+
import { useLocalStorage as Ne } from "./index97.js";
|
|
97
|
+
import { useDebounce as We } from "./index98.js";
|
|
98
|
+
import { useClickOutside as Ee } from "./index99.js";
|
|
99
|
+
import { usePrevious as Qe } from "./index100.js";
|
|
100
|
+
import { useHover as je } from "./index101.js";
|
|
101
|
+
import { useKeyPress as Ve, useKeyPressCallback as Xe } from "./index102.js";
|
|
102
|
+
import { useWindowSize as Ze } from "./index103.js";
|
|
102
103
|
export {
|
|
103
104
|
e as Affix,
|
|
104
105
|
f as Alert,
|
|
@@ -115,7 +116,7 @@ export {
|
|
|
115
116
|
R as Cascader,
|
|
116
117
|
F as Chart,
|
|
117
118
|
b as Chat,
|
|
118
|
-
|
|
119
|
+
pe as CheckableTag,
|
|
119
120
|
P as Checkbox,
|
|
120
121
|
Yo as Code,
|
|
121
122
|
no as Col,
|
|
@@ -139,7 +140,7 @@ export {
|
|
|
139
140
|
xo as Form,
|
|
140
141
|
so as Grid,
|
|
141
142
|
co as Hero,
|
|
142
|
-
|
|
143
|
+
Fe as Hide,
|
|
143
144
|
To as Image,
|
|
144
145
|
Po as Indicator,
|
|
145
146
|
yo as Input,
|
|
@@ -171,43 +172,44 @@ export {
|
|
|
171
172
|
uo as Row,
|
|
172
173
|
Mr as Segmented,
|
|
173
174
|
Br as Select,
|
|
174
|
-
|
|
175
|
+
Ie as Show,
|
|
175
176
|
Kr as Skeleton,
|
|
176
177
|
Nr as Space,
|
|
177
178
|
Wr as Splitter,
|
|
178
179
|
Er as Stack,
|
|
179
180
|
Qr as Stats,
|
|
180
|
-
jr as
|
|
181
|
-
Vr as
|
|
182
|
-
Yr as
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
xe as
|
|
188
|
-
ie as
|
|
189
|
-
se as
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
Pe as
|
|
194
|
-
be as
|
|
195
|
-
he as
|
|
196
|
-
ye as
|
|
181
|
+
jr as Status,
|
|
182
|
+
Vr as Steps,
|
|
183
|
+
Yr as Table,
|
|
184
|
+
_r as Tabs,
|
|
185
|
+
me as Tag,
|
|
186
|
+
ee as TextRotate,
|
|
187
|
+
oe as Textarea,
|
|
188
|
+
xe as ThemeController,
|
|
189
|
+
ie as TimePicker,
|
|
190
|
+
se as Timeline,
|
|
191
|
+
le as Toggle,
|
|
192
|
+
Te as Tooltip,
|
|
193
|
+
ce as Tour,
|
|
194
|
+
Pe as Transfer,
|
|
195
|
+
be as Tree,
|
|
196
|
+
he as TreeSelect,
|
|
197
|
+
ye as Typography,
|
|
198
|
+
Re as Upload,
|
|
197
199
|
or as Window,
|
|
198
200
|
fr as notification,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
Be as useBreakpoint,
|
|
202
|
+
Ee as useClickOutside,
|
|
203
|
+
Ke as useClipboard,
|
|
204
|
+
We as useDebounce,
|
|
205
|
+
Me as useDisclosure,
|
|
204
206
|
ao as useFormInstance,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
je as useHover,
|
|
208
|
+
Ve as useKeyPress,
|
|
209
|
+
Xe as useKeyPressCallback,
|
|
210
|
+
Ne as useLocalStorage,
|
|
211
|
+
Qe as usePrevious,
|
|
210
212
|
Ko as useSiderContext,
|
|
211
|
-
|
|
213
|
+
Ze as useWindowSize
|
|
212
214
|
};
|
|
213
215
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index100.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function f() {
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const r = () => t(!0), s = () => t(!1);
|
|
8
|
-
return e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", s), () => {
|
|
9
|
-
e.removeEventListener("mouseenter", r), e.removeEventListener("mouseleave", s);
|
|
10
|
-
};
|
|
11
|
-
}, []), { ref: n, isHovered: o };
|
|
1
|
+
import { useRef as t, useEffect as o } from "react";
|
|
2
|
+
function f(r) {
|
|
3
|
+
const e = t(void 0);
|
|
4
|
+
return o(() => {
|
|
5
|
+
e.current = r;
|
|
6
|
+
}, [r]), e.current;
|
|
12
7
|
}
|
|
13
8
|
export {
|
|
14
|
-
f as
|
|
9
|
+
f as usePrevious
|
|
15
10
|
};
|
|
16
11
|
//# sourceMappingURL=index100.js.map
|
package/dist/index100.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index100.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index100.js","sources":["../src/hooks/usePrevious.ts"],"sourcesContent":["import { useRef, useEffect } from 'react'\n\n/**\n * Hook that returns the previous value of a variable.\n * Useful for comparing current and previous values in effects.\n *\n * @param value - Current value\n * @returns Previous value (undefined on first render)\n *\n * @example\n * const [count, setCount] = useState(0)\n * const prevCount = usePrevious(count)\n *\n * // prevCount is the value from previous render\n * console.log(`Changed from ${prevCount} to ${count}`)\n */\nexport function usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T | undefined>(undefined)\n\n useEffect(() => {\n ref.current = value\n }, [value])\n\n return ref.current\n}\n"],"names":["usePrevious","value","ref","useRef","useEffect"],"mappings":";AAgBO,SAASA,EAAeC,GAAyB;AACtD,QAAMC,IAAMC,EAAsB,MAAS;AAE3C,SAAAC,EAAU,MAAM;AACd,IAAAF,EAAI,UAAUD;AAAA,EAChB,GAAG,CAACA,CAAK,CAAC,GAEHC,EAAI;AACb;"}
|
package/dist/index101.js
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
e.key === n && d(!1);
|
|
11
|
-
},
|
|
12
|
-
[n]
|
|
13
|
-
);
|
|
14
|
-
return l(() => {
|
|
15
|
-
const e = u ?? window;
|
|
16
|
-
return o === "keydown" ? (e.addEventListener("keydown", t), e.addEventListener("keyup", s)) : e.addEventListener("keyup", t), () => {
|
|
17
|
-
e.removeEventListener("keydown", t), e.removeEventListener("keyup", s);
|
|
1
|
+
import { useState as u, useRef as v, useEffect as a } from "react";
|
|
2
|
+
function f() {
|
|
3
|
+
const [o, t] = u(!1), n = v(null);
|
|
4
|
+
return a(() => {
|
|
5
|
+
const e = n.current;
|
|
6
|
+
if (!e) return;
|
|
7
|
+
const r = () => t(!0), s = () => t(!1);
|
|
8
|
+
return e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", s), () => {
|
|
9
|
+
e.removeEventListener("mouseenter", r), e.removeEventListener("mouseleave", s);
|
|
18
10
|
};
|
|
19
|
-
}, [
|
|
20
|
-
}
|
|
21
|
-
function y(n, f, u = {}) {
|
|
22
|
-
const { target: o, event: r = "keydown", preventDefault: a = !1 } = u;
|
|
23
|
-
l(() => {
|
|
24
|
-
const d = o ?? window, t = (s) => {
|
|
25
|
-
s.key === n && (a && s.preventDefault(), f(s));
|
|
26
|
-
};
|
|
27
|
-
return d.addEventListener(r, t), () => d.removeEventListener(r, t);
|
|
28
|
-
}, [o, n, f, r, a]);
|
|
11
|
+
}, []), { ref: n, isHovered: o };
|
|
29
12
|
}
|
|
30
13
|
export {
|
|
31
|
-
|
|
32
|
-
y as useKeyPressCallback
|
|
14
|
+
f as useHover
|
|
33
15
|
};
|
|
34
16
|
//# sourceMappingURL=index101.js.map
|
package/dist/index101.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index101.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index101.js","sources":["../src/hooks/useHover.ts"],"sourcesContent":["import { useState, useRef, useEffect, type RefObject } from 'react'\n\nexport interface UseHoverReturn<T extends HTMLElement> {\n ref: RefObject<T | null>\n isHovered: boolean\n}\n\n/**\n * Hook that tracks hover state of an element.\n *\n * @returns Object with ref and isHovered state\n *\n * @example\n * const { ref, isHovered } = useHover<HTMLDivElement>()\n *\n * <div ref={ref} className={isHovered ? 'bg-blue-500' : 'bg-gray-500'}>\n * Hover me!\n * </div>\n */\nexport function useHover<T extends HTMLElement = HTMLElement>(): UseHoverReturn<T> {\n const [isHovered, setIsHovered] = useState(false)\n const ref = useRef<T>(null)\n\n useEffect(() => {\n const node = ref.current\n if (!node) return\n\n const handleMouseEnter = () => setIsHovered(true)\n const handleMouseLeave = () => setIsHovered(false)\n\n node.addEventListener('mouseenter', handleMouseEnter)\n node.addEventListener('mouseleave', handleMouseLeave)\n\n return () => {\n node.removeEventListener('mouseenter', handleMouseEnter)\n node.removeEventListener('mouseleave', handleMouseLeave)\n }\n }, [])\n\n return { ref, isHovered }\n}\n"],"names":["useHover","isHovered","setIsHovered","useState","ref","useRef","useEffect","node","handleMouseEnter","handleMouseLeave"],"mappings":";AAmBO,SAASA,IAAmE;AACjF,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1CC,IAAMC,EAAU,IAAI;AAE1B,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,EAAI;AACjB,QAAI,CAACG,EAAM;AAEX,UAAMC,IAAmB,MAAMN,EAAa,EAAI,GAC1CO,IAAmB,MAAMP,EAAa,EAAK;AAEjD,WAAAK,EAAK,iBAAiB,cAAcC,CAAgB,GACpDD,EAAK,iBAAiB,cAAcE,CAAgB,GAE7C,MAAM;AACX,MAAAF,EAAK,oBAAoB,cAAcC,CAAgB,GACvDD,EAAK,oBAAoB,cAAcE,CAAgB;AAAA,IACzD;AAAA,EACF,GAAG,CAAA,CAAE,GAEE,EAAE,KAAAL,GAAK,WAAAH,EAAA;AAChB;"}
|
package/dist/index102.js
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
n(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { useState as v, useCallback as i, useEffect as l } from "react";
|
|
2
|
+
function c(n, f = {}) {
|
|
3
|
+
const { target: u, event: o = "keydown", preventDefault: r = !1 } = f, [a, d] = v(!1), t = i(
|
|
4
|
+
(e) => {
|
|
5
|
+
e.key === n && (r && e.preventDefault(), d(!0));
|
|
6
|
+
},
|
|
7
|
+
[n, r]
|
|
8
|
+
), s = i(
|
|
9
|
+
(e) => {
|
|
10
|
+
e.key === n && d(!1);
|
|
11
|
+
},
|
|
12
|
+
[n]
|
|
13
|
+
);
|
|
14
|
+
return l(() => {
|
|
15
|
+
const e = u ?? window;
|
|
16
|
+
return o === "keydown" ? (e.addEventListener("keydown", t), e.addEventListener("keyup", s)) : e.addEventListener("keyup", t), () => {
|
|
17
|
+
e.removeEventListener("keydown", t), e.removeEventListener("keyup", s);
|
|
14
18
|
};
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
}, [u, o, t, s]), a;
|
|
20
|
+
}
|
|
21
|
+
function y(n, f, u = {}) {
|
|
22
|
+
const { target: o, event: r = "keydown", preventDefault: a = !1 } = u;
|
|
23
|
+
l(() => {
|
|
24
|
+
const d = o ?? window, t = (s) => {
|
|
25
|
+
s.key === n && (a && s.preventDefault(), f(s));
|
|
26
|
+
};
|
|
27
|
+
return d.addEventListener(r, t), () => d.removeEventListener(r, t);
|
|
28
|
+
}, [o, n, f, r, a]);
|
|
17
29
|
}
|
|
18
30
|
export {
|
|
19
|
-
|
|
31
|
+
c as useKeyPress,
|
|
32
|
+
y as useKeyPressCallback
|
|
20
33
|
};
|
|
21
34
|
//# sourceMappingURL=index102.js.map
|
package/dist/index102.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index102.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index102.js","sources":["../src/hooks/useKeyPress.ts"],"sourcesContent":["import { useState, useEffect, useCallback } from 'react'\n\nexport interface UseKeyPressOptions {\n /** Target element (default: window) */\n target?: HTMLElement | Window | null\n /** Event type: 'keydown' | 'keyup' (default: 'keydown') */\n event?: 'keydown' | 'keyup'\n /** Prevent default browser behavior */\n preventDefault?: boolean\n}\n\n/**\n * Hook that detects when a specific key is pressed.\n *\n * @param targetKey - Key to detect (e.g., 'Enter', 'Escape', 'a')\n * @param options - Configuration options\n * @returns Whether the key is currently pressed\n *\n * @example\n * const enterPressed = useKeyPress('Enter')\n * const escapePressed = useKeyPress('Escape')\n *\n * useEffect(() => {\n * if (escapePressed) closeModal()\n * }, [escapePressed])\n *\n * @example\n * // With callback for immediate action\n * useKeyPress('Escape', { preventDefault: true })\n */\nexport function useKeyPress(\n targetKey: string,\n options: UseKeyPressOptions = {}\n): boolean {\n const { target, event = 'keydown', preventDefault = false } = options\n const [keyPressed, setKeyPressed] = useState(false)\n\n const downHandler = useCallback(\n (e: KeyboardEvent) => {\n if (e.key === targetKey) {\n if (preventDefault) e.preventDefault()\n setKeyPressed(true)\n }\n },\n [targetKey, preventDefault]\n )\n\n const upHandler = useCallback(\n (e: KeyboardEvent) => {\n if (e.key === targetKey) {\n setKeyPressed(false)\n }\n },\n [targetKey]\n )\n\n useEffect(() => {\n const targetElement = target ?? window\n\n if (event === 'keydown') {\n targetElement.addEventListener('keydown', downHandler as EventListener)\n targetElement.addEventListener('keyup', upHandler as EventListener)\n } else {\n targetElement.addEventListener('keyup', downHandler as EventListener)\n }\n\n return () => {\n targetElement.removeEventListener('keydown', downHandler as EventListener)\n targetElement.removeEventListener('keyup', upHandler as EventListener)\n }\n }, [target, event, downHandler, upHandler])\n\n return keyPressed\n}\n\n/**\n * Hook that calls a callback when a specific key is pressed.\n *\n * @param targetKey - Key to detect\n * @param callback - Function to call when key is pressed\n * @param options - Configuration options\n *\n * @example\n * useKeyPressCallback('Escape', () => closeModal())\n * useKeyPressCallback('Enter', () => submitForm(), { preventDefault: true })\n */\nexport function useKeyPressCallback(\n targetKey: string,\n callback: (event: KeyboardEvent) => void,\n options: UseKeyPressOptions = {}\n): void {\n const { target, event = 'keydown', preventDefault = false } = options\n\n useEffect(() => {\n const targetElement = target ?? window\n\n const handler = (e: KeyboardEvent) => {\n if (e.key === targetKey) {\n if (preventDefault) e.preventDefault()\n callback(e)\n }\n }\n\n targetElement.addEventListener(event, handler as EventListener)\n return () => targetElement.removeEventListener(event, handler as EventListener)\n }, [target, targetKey, callback, event, preventDefault])\n}\n"],"names":["useKeyPress","targetKey","options","target","event","preventDefault","keyPressed","setKeyPressed","useState","downHandler","useCallback","upHandler","useEffect","targetElement","useKeyPressCallback","callback","handler","e"],"mappings":";AA8BO,SAASA,EACdC,GACAC,IAA8B,IACrB;AACT,QAAM,EAAE,QAAAC,GAAQ,OAAAC,IAAQ,WAAW,gBAAAC,IAAiB,OAAUH,GACxD,CAACI,GAAYC,CAAa,IAAIC,EAAS,EAAK,GAE5CC,IAAcC;AAAA,IAClB,CAAC,MAAqB;AACpB,MAAI,EAAE,QAAQT,MACRI,OAAkB,eAAA,GACtBE,EAAc,EAAI;AAAA,IAEtB;AAAA,IACA,CAACN,GAAWI,CAAc;AAAA,EAAA,GAGtBM,IAAYD;AAAA,IAChB,CAAC,MAAqB;AACpB,MAAI,EAAE,QAAQT,KACZM,EAAc,EAAK;AAAA,IAEvB;AAAA,IACA,CAACN,CAAS;AAAA,EAAA;AAGZ,SAAAW,EAAU,MAAM;AACd,UAAMC,IAAgBV,KAAU;AAEhC,WAAIC,MAAU,aACZS,EAAc,iBAAiB,WAAWJ,CAA4B,GACtEI,EAAc,iBAAiB,SAASF,CAA0B,KAElEE,EAAc,iBAAiB,SAASJ,CAA4B,GAG/D,MAAM;AACX,MAAAI,EAAc,oBAAoB,WAAWJ,CAA4B,GACzEI,EAAc,oBAAoB,SAASF,CAA0B;AAAA,IACvE;AAAA,EACF,GAAG,CAACR,GAAQC,GAAOK,GAAaE,CAAS,CAAC,GAEnCL;AACT;AAaO,SAASQ,EACdb,GACAc,GACAb,IAA8B,CAAA,GACxB;AACN,QAAM,EAAE,QAAAC,GAAQ,OAAAC,IAAQ,WAAW,gBAAAC,IAAiB,OAAUH;AAE9D,EAAAU,EAAU,MAAM;AACd,UAAMC,IAAgBV,KAAU,QAE1Ba,IAAU,CAACC,MAAqB;AACpC,MAAIA,EAAE,QAAQhB,MACRI,OAAkB,eAAA,GACtBU,EAASE,CAAC;AAAA,IAEd;AAEA,WAAAJ,EAAc,iBAAiBT,GAAOY,CAAwB,GACvD,MAAMH,EAAc,oBAAoBT,GAAOY,CAAwB;AAAA,EAChF,GAAG,CAACb,GAAQF,GAAWc,GAAUX,GAAOC,CAAc,CAAC;AACzD;"}
|