@huin-core/react-scroll-area 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +134 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.js +867 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +835 -0
- package/dist/index.mjs.map +7 -0
- package/package.json +3 -2
package/dist/index.d.mts
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import React__default from 'react';
|
3
|
+
import { Primitive } from '@huin-core/react-primitive';
|
4
|
+
|
5
|
+
type Scope<C = any> = {
|
6
|
+
[scopeName: string]: React.Context<C>[];
|
7
|
+
} | undefined;
|
8
|
+
type ScopeHook = (scope: Scope) => {
|
9
|
+
[__scopeProp: string]: Scope;
|
10
|
+
};
|
11
|
+
interface CreateScope {
|
12
|
+
scopeName: string;
|
13
|
+
(): ScopeHook;
|
14
|
+
}
|
15
|
+
|
16
|
+
type ScrollAreaViewportElement = React__default.ElementRef<typeof Primitive.div>;
|
17
|
+
interface ScrollAreaViewportProps extends PrimitiveDivProps {
|
18
|
+
nonce?: string;
|
19
|
+
}
|
20
|
+
declare const ScrollAreaViewport: React__default.ForwardRefExoticComponent<ScrollAreaViewportProps & React__default.RefAttributes<HTMLDivElement>>;
|
21
|
+
|
22
|
+
type ScrollAreaThumbElement = ScrollAreaThumbImplElement;
|
23
|
+
interface ScrollAreaThumbProps extends ScrollAreaThumbImplProps {
|
24
|
+
/**
|
25
|
+
* Used to force mounting when more control is needed. Useful when
|
26
|
+
* controlling animation with React animation libraries.
|
27
|
+
*/
|
28
|
+
forceMount?: true;
|
29
|
+
}
|
30
|
+
declare const ScrollAreaThumb: React__default.ForwardRefExoticComponent<ScrollAreaThumbProps & React__default.RefAttributes<HTMLDivElement>>;
|
31
|
+
type ScrollAreaThumbImplElement = React__default.ElementRef<typeof Primitive.div>;
|
32
|
+
interface ScrollAreaThumbImplProps extends PrimitiveDivProps {
|
33
|
+
}
|
34
|
+
|
35
|
+
type ScrollAreaScrollbarElement = ScrollAreaScrollbarVisibleElement;
|
36
|
+
interface ScrollAreaScrollbarProps extends ScrollAreaScrollbarVisibleProps {
|
37
|
+
forceMount?: true;
|
38
|
+
}
|
39
|
+
declare const ScrollAreaScrollbar: React__default.ForwardRefExoticComponent<ScrollAreaScrollbarProps & React__default.RefAttributes<HTMLDivElement>>;
|
40
|
+
type ScrollAreaScrollbarVisibleElement = ScrollAreaScrollbarAxisElement;
|
41
|
+
interface ScrollAreaScrollbarVisibleProps extends Omit<ScrollAreaScrollbarAxisProps, keyof ScrollAreaScrollbarAxisPrivateProps> {
|
42
|
+
orientation?: "horizontal" | "vertical";
|
43
|
+
}
|
44
|
+
type ScrollAreaScrollbarAxisPrivateProps = {
|
45
|
+
hasThumb: boolean;
|
46
|
+
sizes: Sizes;
|
47
|
+
onSizesChange(sizes: Sizes): void;
|
48
|
+
onThumbChange(thumb: ScrollAreaThumbElement | null): void;
|
49
|
+
onThumbPointerDown(pointerPos: number): void;
|
50
|
+
onThumbPointerUp(): void;
|
51
|
+
onThumbPositionChange(): void;
|
52
|
+
onWheelScroll(scrollPos: number): void;
|
53
|
+
onDragScroll(pointerPos: number): void;
|
54
|
+
};
|
55
|
+
type ScrollAreaScrollbarAxisElement = ScrollAreaScrollbarImplElement;
|
56
|
+
interface ScrollAreaScrollbarAxisProps extends Omit<ScrollAreaScrollbarImplProps, keyof ScrollAreaScrollbarImplPrivateProps>, ScrollAreaScrollbarAxisPrivateProps {
|
57
|
+
}
|
58
|
+
type ScrollbarContext = {
|
59
|
+
hasThumb: boolean;
|
60
|
+
scrollbar: ScrollAreaScrollbarElement | null;
|
61
|
+
onThumbChange(thumb: ScrollAreaThumbElement | null): void;
|
62
|
+
onThumbPointerUp(): void;
|
63
|
+
onThumbPointerDown(pointerPos: {
|
64
|
+
x: number;
|
65
|
+
y: number;
|
66
|
+
}): void;
|
67
|
+
onThumbPositionChange(): void;
|
68
|
+
};
|
69
|
+
type ScrollAreaScrollbarImplElement = React__default.ElementRef<typeof Primitive.div>;
|
70
|
+
type ScrollAreaScrollbarImplPrivateProps = {
|
71
|
+
sizes: Sizes;
|
72
|
+
hasThumb: boolean;
|
73
|
+
onThumbChange: ScrollbarContext["onThumbChange"];
|
74
|
+
onThumbPointerUp: ScrollbarContext["onThumbPointerUp"];
|
75
|
+
onThumbPointerDown: ScrollbarContext["onThumbPointerDown"];
|
76
|
+
onThumbPositionChange: ScrollbarContext["onThumbPositionChange"];
|
77
|
+
onWheelScroll(event: WheelEvent, maxScrollPos: number): void;
|
78
|
+
onDragScroll(pointerPos: {
|
79
|
+
x: number;
|
80
|
+
y: number;
|
81
|
+
}): void;
|
82
|
+
onResize(): void;
|
83
|
+
};
|
84
|
+
interface ScrollAreaScrollbarImplProps extends Omit<PrimitiveDivProps, keyof ScrollAreaScrollbarImplPrivateProps>, ScrollAreaScrollbarImplPrivateProps {
|
85
|
+
}
|
86
|
+
|
87
|
+
type Direction = "ltr" | "rtl";
|
88
|
+
type Sizes = {
|
89
|
+
content: number;
|
90
|
+
viewport: number;
|
91
|
+
scrollbar: {
|
92
|
+
size: number;
|
93
|
+
paddingStart: number;
|
94
|
+
paddingEnd: number;
|
95
|
+
};
|
96
|
+
};
|
97
|
+
declare const createScrollAreaScope: CreateScope;
|
98
|
+
type ScrollAreaContextValue = {
|
99
|
+
type: "auto" | "always" | "scroll" | "hover";
|
100
|
+
dir: Direction;
|
101
|
+
scrollHideDelay: number;
|
102
|
+
scrollArea: ScrollAreaElement | null;
|
103
|
+
viewport: ScrollAreaViewportElement | null;
|
104
|
+
onViewportChange(viewport: ScrollAreaViewportElement | null): void;
|
105
|
+
content: HTMLDivElement | null;
|
106
|
+
onContentChange(content: HTMLDivElement): void;
|
107
|
+
scrollbarX: ScrollAreaScrollbarElement | null;
|
108
|
+
onScrollbarXChange(scrollbar: ScrollAreaScrollbarElement | null): void;
|
109
|
+
scrollbarXEnabled: boolean;
|
110
|
+
onScrollbarXEnabledChange(rendered: boolean): void;
|
111
|
+
scrollbarY: ScrollAreaScrollbarElement | null;
|
112
|
+
onScrollbarYChange(scrollbar: ScrollAreaScrollbarElement | null): void;
|
113
|
+
scrollbarYEnabled: boolean;
|
114
|
+
onScrollbarYEnabledChange(rendered: boolean): void;
|
115
|
+
onCornerWidthChange(width: number): void;
|
116
|
+
onCornerHeightChange(height: number): void;
|
117
|
+
};
|
118
|
+
type ScrollAreaElement = React.ElementRef<typeof Primitive.div>;
|
119
|
+
type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
120
|
+
interface ScrollAreaProps extends PrimitiveDivProps {
|
121
|
+
type?: ScrollAreaContextValue["type"];
|
122
|
+
dir?: ScrollAreaContextValue["dir"];
|
123
|
+
scrollHideDelay?: number;
|
124
|
+
}
|
125
|
+
declare const ScrollArea: React.ForwardRefExoticComponent<ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
|
126
|
+
declare const Root: React.ForwardRefExoticComponent<ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
|
127
|
+
|
128
|
+
interface ScrollAreaCornerProps extends ScrollAreaCornerImplProps {
|
129
|
+
}
|
130
|
+
declare const ScrollAreaCorner: React__default.ForwardRefExoticComponent<ScrollAreaCornerProps & React__default.RefAttributes<HTMLDivElement>>;
|
131
|
+
interface ScrollAreaCornerImplProps extends PrimitiveDivProps {
|
132
|
+
}
|
133
|
+
|
134
|
+
export { Root, ScrollArea, ScrollAreaCorner, type ScrollAreaCornerProps, type ScrollAreaProps, ScrollAreaScrollbar, type ScrollAreaScrollbarProps, ScrollAreaThumb, type ScrollAreaThumbProps, ScrollAreaViewport, type ScrollAreaViewportProps, createScrollAreaScope };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import React__default from 'react';
|
3
|
+
import { Primitive } from '@huin-core/react-primitive';
|
4
|
+
|
5
|
+
type Scope<C = any> = {
|
6
|
+
[scopeName: string]: React.Context<C>[];
|
7
|
+
} | undefined;
|
8
|
+
type ScopeHook = (scope: Scope) => {
|
9
|
+
[__scopeProp: string]: Scope;
|
10
|
+
};
|
11
|
+
interface CreateScope {
|
12
|
+
scopeName: string;
|
13
|
+
(): ScopeHook;
|
14
|
+
}
|
15
|
+
|
16
|
+
type ScrollAreaViewportElement = React__default.ElementRef<typeof Primitive.div>;
|
17
|
+
interface ScrollAreaViewportProps extends PrimitiveDivProps {
|
18
|
+
nonce?: string;
|
19
|
+
}
|
20
|
+
declare const ScrollAreaViewport: React__default.ForwardRefExoticComponent<ScrollAreaViewportProps & React__default.RefAttributes<HTMLDivElement>>;
|
21
|
+
|
22
|
+
type ScrollAreaThumbElement = ScrollAreaThumbImplElement;
|
23
|
+
interface ScrollAreaThumbProps extends ScrollAreaThumbImplProps {
|
24
|
+
/**
|
25
|
+
* Used to force mounting when more control is needed. Useful when
|
26
|
+
* controlling animation with React animation libraries.
|
27
|
+
*/
|
28
|
+
forceMount?: true;
|
29
|
+
}
|
30
|
+
declare const ScrollAreaThumb: React__default.ForwardRefExoticComponent<ScrollAreaThumbProps & React__default.RefAttributes<HTMLDivElement>>;
|
31
|
+
type ScrollAreaThumbImplElement = React__default.ElementRef<typeof Primitive.div>;
|
32
|
+
interface ScrollAreaThumbImplProps extends PrimitiveDivProps {
|
33
|
+
}
|
34
|
+
|
35
|
+
type ScrollAreaScrollbarElement = ScrollAreaScrollbarVisibleElement;
|
36
|
+
interface ScrollAreaScrollbarProps extends ScrollAreaScrollbarVisibleProps {
|
37
|
+
forceMount?: true;
|
38
|
+
}
|
39
|
+
declare const ScrollAreaScrollbar: React__default.ForwardRefExoticComponent<ScrollAreaScrollbarProps & React__default.RefAttributes<HTMLDivElement>>;
|
40
|
+
type ScrollAreaScrollbarVisibleElement = ScrollAreaScrollbarAxisElement;
|
41
|
+
interface ScrollAreaScrollbarVisibleProps extends Omit<ScrollAreaScrollbarAxisProps, keyof ScrollAreaScrollbarAxisPrivateProps> {
|
42
|
+
orientation?: "horizontal" | "vertical";
|
43
|
+
}
|
44
|
+
type ScrollAreaScrollbarAxisPrivateProps = {
|
45
|
+
hasThumb: boolean;
|
46
|
+
sizes: Sizes;
|
47
|
+
onSizesChange(sizes: Sizes): void;
|
48
|
+
onThumbChange(thumb: ScrollAreaThumbElement | null): void;
|
49
|
+
onThumbPointerDown(pointerPos: number): void;
|
50
|
+
onThumbPointerUp(): void;
|
51
|
+
onThumbPositionChange(): void;
|
52
|
+
onWheelScroll(scrollPos: number): void;
|
53
|
+
onDragScroll(pointerPos: number): void;
|
54
|
+
};
|
55
|
+
type ScrollAreaScrollbarAxisElement = ScrollAreaScrollbarImplElement;
|
56
|
+
interface ScrollAreaScrollbarAxisProps extends Omit<ScrollAreaScrollbarImplProps, keyof ScrollAreaScrollbarImplPrivateProps>, ScrollAreaScrollbarAxisPrivateProps {
|
57
|
+
}
|
58
|
+
type ScrollbarContext = {
|
59
|
+
hasThumb: boolean;
|
60
|
+
scrollbar: ScrollAreaScrollbarElement | null;
|
61
|
+
onThumbChange(thumb: ScrollAreaThumbElement | null): void;
|
62
|
+
onThumbPointerUp(): void;
|
63
|
+
onThumbPointerDown(pointerPos: {
|
64
|
+
x: number;
|
65
|
+
y: number;
|
66
|
+
}): void;
|
67
|
+
onThumbPositionChange(): void;
|
68
|
+
};
|
69
|
+
type ScrollAreaScrollbarImplElement = React__default.ElementRef<typeof Primitive.div>;
|
70
|
+
type ScrollAreaScrollbarImplPrivateProps = {
|
71
|
+
sizes: Sizes;
|
72
|
+
hasThumb: boolean;
|
73
|
+
onThumbChange: ScrollbarContext["onThumbChange"];
|
74
|
+
onThumbPointerUp: ScrollbarContext["onThumbPointerUp"];
|
75
|
+
onThumbPointerDown: ScrollbarContext["onThumbPointerDown"];
|
76
|
+
onThumbPositionChange: ScrollbarContext["onThumbPositionChange"];
|
77
|
+
onWheelScroll(event: WheelEvent, maxScrollPos: number): void;
|
78
|
+
onDragScroll(pointerPos: {
|
79
|
+
x: number;
|
80
|
+
y: number;
|
81
|
+
}): void;
|
82
|
+
onResize(): void;
|
83
|
+
};
|
84
|
+
interface ScrollAreaScrollbarImplProps extends Omit<PrimitiveDivProps, keyof ScrollAreaScrollbarImplPrivateProps>, ScrollAreaScrollbarImplPrivateProps {
|
85
|
+
}
|
86
|
+
|
87
|
+
type Direction = "ltr" | "rtl";
|
88
|
+
type Sizes = {
|
89
|
+
content: number;
|
90
|
+
viewport: number;
|
91
|
+
scrollbar: {
|
92
|
+
size: number;
|
93
|
+
paddingStart: number;
|
94
|
+
paddingEnd: number;
|
95
|
+
};
|
96
|
+
};
|
97
|
+
declare const createScrollAreaScope: CreateScope;
|
98
|
+
type ScrollAreaContextValue = {
|
99
|
+
type: "auto" | "always" | "scroll" | "hover";
|
100
|
+
dir: Direction;
|
101
|
+
scrollHideDelay: number;
|
102
|
+
scrollArea: ScrollAreaElement | null;
|
103
|
+
viewport: ScrollAreaViewportElement | null;
|
104
|
+
onViewportChange(viewport: ScrollAreaViewportElement | null): void;
|
105
|
+
content: HTMLDivElement | null;
|
106
|
+
onContentChange(content: HTMLDivElement): void;
|
107
|
+
scrollbarX: ScrollAreaScrollbarElement | null;
|
108
|
+
onScrollbarXChange(scrollbar: ScrollAreaScrollbarElement | null): void;
|
109
|
+
scrollbarXEnabled: boolean;
|
110
|
+
onScrollbarXEnabledChange(rendered: boolean): void;
|
111
|
+
scrollbarY: ScrollAreaScrollbarElement | null;
|
112
|
+
onScrollbarYChange(scrollbar: ScrollAreaScrollbarElement | null): void;
|
113
|
+
scrollbarYEnabled: boolean;
|
114
|
+
onScrollbarYEnabledChange(rendered: boolean): void;
|
115
|
+
onCornerWidthChange(width: number): void;
|
116
|
+
onCornerHeightChange(height: number): void;
|
117
|
+
};
|
118
|
+
type ScrollAreaElement = React.ElementRef<typeof Primitive.div>;
|
119
|
+
type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
120
|
+
interface ScrollAreaProps extends PrimitiveDivProps {
|
121
|
+
type?: ScrollAreaContextValue["type"];
|
122
|
+
dir?: ScrollAreaContextValue["dir"];
|
123
|
+
scrollHideDelay?: number;
|
124
|
+
}
|
125
|
+
declare const ScrollArea: React.ForwardRefExoticComponent<ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
|
126
|
+
declare const Root: React.ForwardRefExoticComponent<ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
|
127
|
+
|
128
|
+
interface ScrollAreaCornerProps extends ScrollAreaCornerImplProps {
|
129
|
+
}
|
130
|
+
declare const ScrollAreaCorner: React__default.ForwardRefExoticComponent<ScrollAreaCornerProps & React__default.RefAttributes<HTMLDivElement>>;
|
131
|
+
interface ScrollAreaCornerImplProps extends PrimitiveDivProps {
|
132
|
+
}
|
133
|
+
|
134
|
+
export { Root, ScrollArea, ScrollAreaCorner, type ScrollAreaCornerProps, type ScrollAreaProps, ScrollAreaScrollbar, type ScrollAreaScrollbarProps, ScrollAreaThumb, type ScrollAreaThumbProps, ScrollAreaViewport, type ScrollAreaViewportProps, createScrollAreaScope };
|