@uipath/apollo-wind 2.66.1 → 2.67.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/dist/components/ui/attachment.cjs +174 -0
- package/dist/components/ui/attachment.d.ts +39 -0
- package/dist/components/ui/attachment.js +113 -0
- package/dist/components/ui/bubble.cjs +123 -0
- package/dist/components/ui/bubble.d.ts +28 -0
- package/dist/components/ui/bubble.js +77 -0
- package/dist/components/ui/index.cjs +268 -213
- package/dist/components/ui/index.d.ts +6 -1
- package/dist/components/ui/index.js +6 -1
- package/dist/components/ui/marker.cjs +89 -0
- package/dist/components/ui/marker.d.ts +16 -0
- package/dist/components/ui/marker.js +46 -0
- package/dist/components/ui/message-scroller/index.cjs +58 -0
- package/dist/components/ui/message-scroller/index.d.ts +1 -0
- package/dist/components/ui/message-scroller/index.js +1 -0
- package/dist/components/ui/message-scroller/message-scroller.cjs +137 -0
- package/dist/components/ui/message-scroller/message-scroller.d.ts +60 -0
- package/dist/components/ui/message-scroller/message-scroller.js +73 -0
- package/dist/components/ui/message-scroller/primitive/components.cjs +357 -0
- package/dist/components/ui/message-scroller/primitive/components.d.ts +28 -0
- package/dist/components/ui/message-scroller/primitive/components.js +299 -0
- package/dist/components/ui/message-scroller/primitive/geometry.cjs +232 -0
- package/dist/components/ui/message-scroller/primitive/geometry.d.ts +54 -0
- package/dist/components/ui/message-scroller/primitive/geometry.js +153 -0
- package/dist/components/ui/message-scroller/primitive/index.cjs +53 -0
- package/dist/components/ui/message-scroller/primitive/index.d.ts +23 -0
- package/dist/components/ui/message-scroller/primitive/index.js +10 -0
- package/dist/components/ui/message-scroller/primitive/stores.cjs +81 -0
- package/dist/components/ui/message-scroller/primitive/stores.d.ts +6 -0
- package/dist/components/ui/message-scroller/primitive/stores.js +38 -0
- package/dist/components/ui/message-scroller/primitive/types.cjs +82 -0
- package/dist/components/ui/message-scroller/primitive/types.d.ts +89 -0
- package/dist/components/ui/message-scroller/primitive/types.js +24 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-commands.cjs +213 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-commands.d.ts +18 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-commands.js +179 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-controller.cjs +474 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-controller.d.ts +6 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-controller.js +440 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-refs.cjs +124 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-refs.d.ts +52 -0
- package/dist/components/ui/message-scroller/primitive/use-message-scroller-refs.js +84 -0
- package/dist/components/ui/message-scroller/primitive/use-render.cjs +116 -0
- package/dist/components/ui/message-scroller/primitive/use-render.d.ts +21 -0
- package/dist/components/ui/message-scroller/primitive/use-render.js +76 -0
- package/dist/components/ui/message-scroller/primitive/utils.cjs +41 -0
- package/dist/components/ui/message-scroller/primitive/utils.d.ts +3 -0
- package/dist/components/ui/message-scroller/primitive/utils.js +7 -0
- package/dist/components/ui/message.cjs +96 -0
- package/dist/components/ui/message.d.ts +17 -0
- package/dist/components/ui/message.js +47 -0
- package/dist/index.cjs +164 -51
- package/dist/index.d.ts +10 -0
- package/dist/index.js +6 -1
- package/dist/styles.css +720 -0
- package/dist/tailwind.utilities.css +223 -0
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
AUTOSCROLLING_CLEAR_DELAY: ()=>AUTOSCROLLING_CLEAR_DELAY,
|
|
28
|
+
DEFAULT_SCROLL_EDGE_THRESHOLD: ()=>DEFAULT_SCROLL_EDGE_THRESHOLD,
|
|
29
|
+
DEFAULT_SCROLL_MARGIN: ()=>DEFAULT_SCROLL_MARGIN,
|
|
30
|
+
DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK: ()=>DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK,
|
|
31
|
+
EMPTY_MESSAGE_SCROLLER_SCROLLABLE: ()=>EMPTY_MESSAGE_SCROLLER_SCROLLABLE,
|
|
32
|
+
EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE: ()=>EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE,
|
|
33
|
+
EMPTY_VISIBLE_MESSAGE_IDS: ()=>EMPTY_VISIBLE_MESSAGE_IDS,
|
|
34
|
+
SCROLL_POSITION_EPSILON: ()=>SCROLL_POSITION_EPSILON,
|
|
35
|
+
USER_SCROLL_KEYS: ()=>USER_SCROLL_KEYS
|
|
36
|
+
});
|
|
37
|
+
const DEFAULT_SCROLL_EDGE_THRESHOLD = 8;
|
|
38
|
+
const DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK = 64;
|
|
39
|
+
const DEFAULT_SCROLL_MARGIN = 0;
|
|
40
|
+
const SCROLL_POSITION_EPSILON = 0.5;
|
|
41
|
+
const AUTOSCROLLING_CLEAR_DELAY = 180;
|
|
42
|
+
const USER_SCROLL_KEYS = new Set([
|
|
43
|
+
'ArrowDown',
|
|
44
|
+
'ArrowUp',
|
|
45
|
+
'End',
|
|
46
|
+
'Home',
|
|
47
|
+
'PageDown',
|
|
48
|
+
'PageUp',
|
|
49
|
+
' '
|
|
50
|
+
]);
|
|
51
|
+
const EMPTY_MESSAGE_SCROLLER_SCROLLABLE = {
|
|
52
|
+
start: false,
|
|
53
|
+
end: false
|
|
54
|
+
};
|
|
55
|
+
const EMPTY_VISIBLE_MESSAGE_IDS = [];
|
|
56
|
+
const EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE = {
|
|
57
|
+
currentAnchorId: null,
|
|
58
|
+
visibleMessageIds: EMPTY_VISIBLE_MESSAGE_IDS
|
|
59
|
+
};
|
|
60
|
+
exports.AUTOSCROLLING_CLEAR_DELAY = __webpack_exports__.AUTOSCROLLING_CLEAR_DELAY;
|
|
61
|
+
exports.DEFAULT_SCROLL_EDGE_THRESHOLD = __webpack_exports__.DEFAULT_SCROLL_EDGE_THRESHOLD;
|
|
62
|
+
exports.DEFAULT_SCROLL_MARGIN = __webpack_exports__.DEFAULT_SCROLL_MARGIN;
|
|
63
|
+
exports.DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK = __webpack_exports__.DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK;
|
|
64
|
+
exports.EMPTY_MESSAGE_SCROLLER_SCROLLABLE = __webpack_exports__.EMPTY_MESSAGE_SCROLLER_SCROLLABLE;
|
|
65
|
+
exports.EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE = __webpack_exports__.EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE;
|
|
66
|
+
exports.EMPTY_VISIBLE_MESSAGE_IDS = __webpack_exports__.EMPTY_VISIBLE_MESSAGE_IDS;
|
|
67
|
+
exports.SCROLL_POSITION_EPSILON = __webpack_exports__.SCROLL_POSITION_EPSILON;
|
|
68
|
+
exports.USER_SCROLL_KEYS = __webpack_exports__.USER_SCROLL_KEYS;
|
|
69
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
70
|
+
"AUTOSCROLLING_CLEAR_DELAY",
|
|
71
|
+
"DEFAULT_SCROLL_EDGE_THRESHOLD",
|
|
72
|
+
"DEFAULT_SCROLL_MARGIN",
|
|
73
|
+
"DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK",
|
|
74
|
+
"EMPTY_MESSAGE_SCROLLER_SCROLLABLE",
|
|
75
|
+
"EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE",
|
|
76
|
+
"EMPTY_VISIBLE_MESSAGE_IDS",
|
|
77
|
+
"SCROLL_POSITION_EPSILON",
|
|
78
|
+
"USER_SCROLL_KEYS"
|
|
79
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
80
|
+
Object.defineProperty(exports, '__esModule', {
|
|
81
|
+
value: true
|
|
82
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { UseRenderComponentProps } from './use-render';
|
|
3
|
+
declare const DEFAULT_SCROLL_EDGE_THRESHOLD = 8;
|
|
4
|
+
declare const DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK = 64;
|
|
5
|
+
declare const DEFAULT_SCROLL_MARGIN = 0;
|
|
6
|
+
declare const SCROLL_POSITION_EPSILON = 0.5;
|
|
7
|
+
declare const AUTOSCROLLING_CLEAR_DELAY = 180;
|
|
8
|
+
declare const USER_SCROLL_KEYS: Set<string>;
|
|
9
|
+
type MessageScrollerMode = 'following-bottom' | 'free-scrolling' | 'anchored-to-message' | 'settling-jump';
|
|
10
|
+
type MessageScrollerDefaultScrollPosition = 'start' | 'end' | 'last-anchor';
|
|
11
|
+
type MessageScrollerButtonDirection = 'start' | 'end';
|
|
12
|
+
type MessageScrollerScrollAlign = 'start' | 'center' | 'end' | 'nearest';
|
|
13
|
+
type MessageScrollerScrollOptions = {
|
|
14
|
+
align?: MessageScrollerScrollAlign;
|
|
15
|
+
behavior?: ScrollBehavior;
|
|
16
|
+
scrollMargin?: number;
|
|
17
|
+
};
|
|
18
|
+
type MessageScrollerScrollable = {
|
|
19
|
+
start: boolean;
|
|
20
|
+
end: boolean;
|
|
21
|
+
};
|
|
22
|
+
type MessageScrollerVisibilityState = {
|
|
23
|
+
currentAnchorId: string | null;
|
|
24
|
+
visibleMessageIds: string[];
|
|
25
|
+
};
|
|
26
|
+
type MessageScrollerProviderProps = {
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
autoScroll?: boolean;
|
|
29
|
+
defaultScrollPosition?: MessageScrollerDefaultScrollPosition;
|
|
30
|
+
scrollEdgeThreshold?: number;
|
|
31
|
+
scrollPreviousItemPeek?: number;
|
|
32
|
+
scrollMargin?: number;
|
|
33
|
+
};
|
|
34
|
+
type MessageScrollerProps = React.ComponentPropsWithoutRef<'div'>;
|
|
35
|
+
type MessageScrollerViewportProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
36
|
+
preserveScrollOnPrepend?: boolean;
|
|
37
|
+
};
|
|
38
|
+
type MessageScrollerContentProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
39
|
+
spacerClassName?: string;
|
|
40
|
+
};
|
|
41
|
+
type MessageScrollerItemProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
42
|
+
messageId?: string;
|
|
43
|
+
scrollAnchor?: boolean;
|
|
44
|
+
};
|
|
45
|
+
type MessageScrollerButtonRenderState = {
|
|
46
|
+
active: boolean;
|
|
47
|
+
direction: MessageScrollerButtonDirection;
|
|
48
|
+
};
|
|
49
|
+
type MessageScrollerButtonProps = UseRenderComponentProps<'button', MessageScrollerButtonRenderState> & {
|
|
50
|
+
behavior?: ScrollBehavior;
|
|
51
|
+
direction?: MessageScrollerButtonDirection;
|
|
52
|
+
};
|
|
53
|
+
type MessageScrollerStore<T> = {
|
|
54
|
+
getSnapshot: () => T;
|
|
55
|
+
setSnapshot: (nextSnapshot: T) => void;
|
|
56
|
+
subscribe: (listener: () => void) => () => void;
|
|
57
|
+
};
|
|
58
|
+
type MessageScrollerVisibilityStore = {
|
|
59
|
+
getSnapshot: () => MessageScrollerVisibilityState;
|
|
60
|
+
hasListeners: () => boolean;
|
|
61
|
+
setSnapshot: (nextSnapshot: MessageScrollerVisibilityState) => void;
|
|
62
|
+
subscribe: (listener: () => void, onFirstSubscribe: () => void, onLastUnsubscribe: () => void) => () => void;
|
|
63
|
+
};
|
|
64
|
+
type MessageScrollerRegisterMessage = (messageId: string, element: HTMLElement | null, removedElement?: HTMLElement | null) => void;
|
|
65
|
+
type MessageScrollerContextValue = {
|
|
66
|
+
handleContentChange: () => void;
|
|
67
|
+
handleResize: () => void;
|
|
68
|
+
observeVisibility: () => void;
|
|
69
|
+
preserveScrollOnPrependRef: React.RefObject<boolean>;
|
|
70
|
+
scrollToEnd: (options?: MessageScrollerScrollOptions) => boolean;
|
|
71
|
+
scrollToMessage: (messageId: string, options?: MessageScrollerScrollOptions) => boolean;
|
|
72
|
+
scrollToStart: (options?: MessageScrollerScrollOptions) => boolean;
|
|
73
|
+
setContentElement: (element: HTMLDivElement | null) => void;
|
|
74
|
+
setRootElement: (element: HTMLDivElement | null) => void;
|
|
75
|
+
setSpacerElement: (element: HTMLDivElement | null) => void;
|
|
76
|
+
setViewportElement: (element: HTMLDivElement | null) => void;
|
|
77
|
+
pendingDefaultScrollStore: MessageScrollerStore<boolean>;
|
|
78
|
+
stateStore: MessageScrollerStore<MessageScrollerScrollable>;
|
|
79
|
+
syncAfterScroll: () => void;
|
|
80
|
+
unobserveVisibility: () => void;
|
|
81
|
+
userScrollIntent: () => void;
|
|
82
|
+
viewportRef: React.RefObject<HTMLDivElement | null>;
|
|
83
|
+
visibilityStore: MessageScrollerVisibilityStore;
|
|
84
|
+
};
|
|
85
|
+
declare const EMPTY_MESSAGE_SCROLLER_SCROLLABLE: MessageScrollerScrollable;
|
|
86
|
+
declare const EMPTY_VISIBLE_MESSAGE_IDS: string[];
|
|
87
|
+
declare const EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE: MessageScrollerVisibilityState;
|
|
88
|
+
export { AUTOSCROLLING_CLEAR_DELAY, DEFAULT_SCROLL_EDGE_THRESHOLD, DEFAULT_SCROLL_MARGIN, DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK, EMPTY_MESSAGE_SCROLLER_SCROLLABLE, EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE, EMPTY_VISIBLE_MESSAGE_IDS, SCROLL_POSITION_EPSILON, USER_SCROLL_KEYS, };
|
|
89
|
+
export type { MessageScrollerButtonDirection, MessageScrollerButtonProps, MessageScrollerButtonRenderState, MessageScrollerContentProps, MessageScrollerContextValue, MessageScrollerDefaultScrollPosition, MessageScrollerItemProps, MessageScrollerMode, MessageScrollerProps, MessageScrollerProviderProps, MessageScrollerRegisterMessage, MessageScrollerScrollAlign, MessageScrollerScrollOptions, MessageScrollerScrollable, MessageScrollerStore, MessageScrollerViewportProps, MessageScrollerVisibilityState, MessageScrollerVisibilityStore, };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const DEFAULT_SCROLL_EDGE_THRESHOLD = 8;
|
|
2
|
+
const DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK = 64;
|
|
3
|
+
const DEFAULT_SCROLL_MARGIN = 0;
|
|
4
|
+
const SCROLL_POSITION_EPSILON = 0.5;
|
|
5
|
+
const AUTOSCROLLING_CLEAR_DELAY = 180;
|
|
6
|
+
const USER_SCROLL_KEYS = new Set([
|
|
7
|
+
'ArrowDown',
|
|
8
|
+
'ArrowUp',
|
|
9
|
+
'End',
|
|
10
|
+
'Home',
|
|
11
|
+
'PageDown',
|
|
12
|
+
'PageUp',
|
|
13
|
+
' '
|
|
14
|
+
]);
|
|
15
|
+
const EMPTY_MESSAGE_SCROLLER_SCROLLABLE = {
|
|
16
|
+
start: false,
|
|
17
|
+
end: false
|
|
18
|
+
};
|
|
19
|
+
const EMPTY_VISIBLE_MESSAGE_IDS = [];
|
|
20
|
+
const EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE = {
|
|
21
|
+
currentAnchorId: null,
|
|
22
|
+
visibleMessageIds: EMPTY_VISIBLE_MESSAGE_IDS
|
|
23
|
+
};
|
|
24
|
+
export { AUTOSCROLLING_CLEAR_DELAY, DEFAULT_SCROLL_EDGE_THRESHOLD, DEFAULT_SCROLL_MARGIN, DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK, EMPTY_MESSAGE_SCROLLER_SCROLLABLE, EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE, EMPTY_VISIBLE_MESSAGE_IDS, SCROLL_POSITION_EPSILON, USER_SCROLL_KEYS };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
useMessageScrollerCommands: ()=>useMessageScrollerCommands
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const external_geometry_cjs_namespaceObject = require("./geometry.cjs");
|
|
31
|
+
const external_types_cjs_namespaceObject = require("./types.cjs");
|
|
32
|
+
const external_use_message_scroller_refs_cjs_namespaceObject = require("./use-message-scroller-refs.cjs");
|
|
33
|
+
function useMessageScrollerCommands({ refs, commitScrollState, scheduleStateCommit, scheduleVisibilitySync }) {
|
|
34
|
+
const { streamingTurnRef, autoScrollRef, autoscrollingRef, autoscrollingTimeoutRef, contentRef, itemCountRef, messageElementsRef, modeRef, pendingScrollToMessageRef, prependRestoreRef, scrollMarginRef, scrollPreviousItemPeekRef, spacerGapRef, spacerHeightRef, spacerRef, viewportRef } = refs;
|
|
35
|
+
const setAutoScrolling = external_react_namespaceObject.useCallback((autoscrolling)=>{
|
|
36
|
+
if (null !== autoscrollingTimeoutRef.current) {
|
|
37
|
+
window.clearTimeout(autoscrollingTimeoutRef.current);
|
|
38
|
+
autoscrollingTimeoutRef.current = null;
|
|
39
|
+
}
|
|
40
|
+
if (autoscrollingRef.current !== autoscrolling) {
|
|
41
|
+
autoscrollingRef.current = autoscrolling;
|
|
42
|
+
commitScrollState();
|
|
43
|
+
}
|
|
44
|
+
if (autoscrolling) autoscrollingTimeoutRef.current = window.setTimeout(()=>{
|
|
45
|
+
autoscrollingTimeoutRef.current = null;
|
|
46
|
+
autoscrollingRef.current = false;
|
|
47
|
+
commitScrollState();
|
|
48
|
+
}, external_types_cjs_namespaceObject.AUTOSCROLLING_CLEAR_DELAY);
|
|
49
|
+
}, [
|
|
50
|
+
commitScrollState
|
|
51
|
+
]);
|
|
52
|
+
const setTailSpacerHeight = external_react_namespaceObject.useCallback((height)=>{
|
|
53
|
+
const spacer = spacerRef.current;
|
|
54
|
+
if (!spacer) return;
|
|
55
|
+
const nextHeight = Math.max(0, Math.ceil(height));
|
|
56
|
+
if (spacerHeightRef.current === nextHeight) return;
|
|
57
|
+
spacerHeightRef.current = nextHeight;
|
|
58
|
+
spacer.hidden = 0 === nextHeight;
|
|
59
|
+
spacer.style.height = `${nextHeight}px`;
|
|
60
|
+
spacer.style.marginTop = nextHeight > 0 ? `${-spacerGapRef.current}px` : '';
|
|
61
|
+
}, []);
|
|
62
|
+
const scrollToPosition = external_react_namespaceObject.useCallback((scrollTop, { behavior = 'auto', autoscrolling = false } = {})=>{
|
|
63
|
+
const viewport = viewportRef.current;
|
|
64
|
+
if (!viewport) return;
|
|
65
|
+
const nextScrollTop = Math.max(0, scrollTop);
|
|
66
|
+
if (Math.abs(viewport.scrollTop - nextScrollTop) <= external_types_cjs_namespaceObject.SCROLL_POSITION_EPSILON) {
|
|
67
|
+
viewport.scrollTop = nextScrollTop;
|
|
68
|
+
commitScrollState();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (autoscrolling) setAutoScrolling(true);
|
|
72
|
+
viewport.scrollTo({
|
|
73
|
+
top: nextScrollTop,
|
|
74
|
+
behavior
|
|
75
|
+
});
|
|
76
|
+
scheduleStateCommit();
|
|
77
|
+
}, [
|
|
78
|
+
commitScrollState,
|
|
79
|
+
scheduleStateCommit,
|
|
80
|
+
setAutoScrolling
|
|
81
|
+
]);
|
|
82
|
+
const scrollToStart = external_react_namespaceObject.useCallback(({ behavior = 'auto' } = {})=>{
|
|
83
|
+
if (!viewportRef.current) return false;
|
|
84
|
+
setTailSpacerHeight(0);
|
|
85
|
+
streamingTurnRef.current = null;
|
|
86
|
+
modeRef.current = 'free-scrolling';
|
|
87
|
+
scrollToPosition(0, {
|
|
88
|
+
behavior
|
|
89
|
+
});
|
|
90
|
+
scheduleVisibilitySync();
|
|
91
|
+
return true;
|
|
92
|
+
}, [
|
|
93
|
+
scheduleVisibilitySync,
|
|
94
|
+
scrollToPosition,
|
|
95
|
+
setTailSpacerHeight
|
|
96
|
+
]);
|
|
97
|
+
const scrollToEnd = external_react_namespaceObject.useCallback(({ behavior = 'auto' } = {})=>{
|
|
98
|
+
const viewport = viewportRef.current;
|
|
99
|
+
if (!viewport) return false;
|
|
100
|
+
setTailSpacerHeight(0);
|
|
101
|
+
streamingTurnRef.current = null;
|
|
102
|
+
modeRef.current = autoScrollRef.current ? 'following-bottom' : 'free-scrolling';
|
|
103
|
+
scrollToPosition((0, external_geometry_cjs_namespaceObject.getMaxScrollTop)(viewport), {
|
|
104
|
+
autoscrolling: true,
|
|
105
|
+
behavior
|
|
106
|
+
});
|
|
107
|
+
scheduleVisibilitySync();
|
|
108
|
+
return true;
|
|
109
|
+
}, [
|
|
110
|
+
scheduleVisibilitySync,
|
|
111
|
+
scrollToPosition,
|
|
112
|
+
setTailSpacerHeight
|
|
113
|
+
]);
|
|
114
|
+
const scrollToElement = external_react_namespaceObject.useCallback((element, { align = 'start', behavior = 'auto', scrollMargin = scrollMarginRef.current } = {}, { keepPreviousPeek = false } = {})=>{
|
|
115
|
+
const content = contentRef.current;
|
|
116
|
+
const viewport = viewportRef.current;
|
|
117
|
+
if (!content || !viewport || !content.contains(element)) return false;
|
|
118
|
+
const scrollTop = (0, external_geometry_cjs_namespaceObject.getElementScrollTop)({
|
|
119
|
+
align,
|
|
120
|
+
element,
|
|
121
|
+
scrollMargin: keepPreviousPeek ? scrollMargin + scrollPreviousItemPeekRef.current : scrollMargin,
|
|
122
|
+
spacer: spacerRef.current,
|
|
123
|
+
viewport
|
|
124
|
+
});
|
|
125
|
+
const nextSpacerHeight = (0, external_geometry_cjs_namespaceObject.getTailSpacerHeight)({
|
|
126
|
+
content,
|
|
127
|
+
scrollTop,
|
|
128
|
+
spacer: spacerRef.current,
|
|
129
|
+
viewport
|
|
130
|
+
});
|
|
131
|
+
setTailSpacerHeight(nextSpacerHeight);
|
|
132
|
+
prependRestoreRef.current = {
|
|
133
|
+
element,
|
|
134
|
+
viewportTop: (0, external_geometry_cjs_namespaceObject.getElementViewportTop)(element, viewport)
|
|
135
|
+
};
|
|
136
|
+
modeRef.current = keepPreviousPeek ? 'anchored-to-message' : 'settling-jump';
|
|
137
|
+
streamingTurnRef.current = keepPreviousPeek ? element : null;
|
|
138
|
+
scrollToPosition(scrollTop, {
|
|
139
|
+
behavior
|
|
140
|
+
});
|
|
141
|
+
scheduleVisibilitySync();
|
|
142
|
+
return true;
|
|
143
|
+
}, [
|
|
144
|
+
scheduleVisibilitySync,
|
|
145
|
+
scrollToPosition,
|
|
146
|
+
setTailSpacerHeight
|
|
147
|
+
]);
|
|
148
|
+
const reanchorToAnchoredMessage = external_react_namespaceObject.useCallback(()=>{
|
|
149
|
+
const element = streamingTurnRef.current;
|
|
150
|
+
if (!element || !element.isConnected || 'anchored-to-message' !== modeRef.current) return false;
|
|
151
|
+
return scrollToElement(element, {
|
|
152
|
+
align: 'start'
|
|
153
|
+
}, {
|
|
154
|
+
keepPreviousPeek: true
|
|
155
|
+
});
|
|
156
|
+
}, [
|
|
157
|
+
scrollToElement
|
|
158
|
+
]);
|
|
159
|
+
const scrollToMessage = external_react_namespaceObject.useCallback((messageId, options)=>{
|
|
160
|
+
const element = messageElementsRef.current.get(messageId);
|
|
161
|
+
if (!element) {
|
|
162
|
+
if (0 === itemCountRef.current) {
|
|
163
|
+
pendingScrollToMessageRef.current = {
|
|
164
|
+
messageId,
|
|
165
|
+
options
|
|
166
|
+
};
|
|
167
|
+
(0, external_use_message_scroller_refs_cjs_namespaceObject.markDefaultScrollPositionApplied)(refs);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
(0, external_use_message_scroller_refs_cjs_namespaceObject.markDefaultScrollPositionApplied)(refs);
|
|
173
|
+
if (scrollToElement(element, options)) {
|
|
174
|
+
pendingScrollToMessageRef.current = null;
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
pendingScrollToMessageRef.current = {
|
|
178
|
+
messageId,
|
|
179
|
+
options
|
|
180
|
+
};
|
|
181
|
+
return true;
|
|
182
|
+
}, [
|
|
183
|
+
scrollToElement
|
|
184
|
+
]);
|
|
185
|
+
const flushPendingScrollToMessage = external_react_namespaceObject.useCallback(()=>{
|
|
186
|
+
const pending = pendingScrollToMessageRef.current;
|
|
187
|
+
if (!pending) return false;
|
|
188
|
+
const element = messageElementsRef.current.get(pending.messageId);
|
|
189
|
+
if (!element) return false;
|
|
190
|
+
const handled = scrollToElement(element, pending.options);
|
|
191
|
+
if (!handled) return false;
|
|
192
|
+
pendingScrollToMessageRef.current = null;
|
|
193
|
+
(0, external_use_message_scroller_refs_cjs_namespaceObject.markDefaultScrollPositionApplied)(refs);
|
|
194
|
+
return true;
|
|
195
|
+
}, [
|
|
196
|
+
scrollToElement
|
|
197
|
+
]);
|
|
198
|
+
return {
|
|
199
|
+
flushPendingScrollToMessage,
|
|
200
|
+
reanchorToAnchoredMessage,
|
|
201
|
+
scrollToElement,
|
|
202
|
+
scrollToEnd,
|
|
203
|
+
scrollToMessage,
|
|
204
|
+
scrollToStart
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
exports.useMessageScrollerCommands = __webpack_exports__.useMessageScrollerCommands;
|
|
208
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
209
|
+
"useMessageScrollerCommands"
|
|
210
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
211
|
+
Object.defineProperty(exports, '__esModule', {
|
|
212
|
+
value: true
|
|
213
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MessageScrollerScrollOptions } from './types';
|
|
2
|
+
import { type MessageScrollerRefs } from './use-message-scroller-refs';
|
|
3
|
+
declare function useMessageScrollerCommands({ refs, commitScrollState, scheduleStateCommit, scheduleVisibilitySync, }: {
|
|
4
|
+
refs: MessageScrollerRefs;
|
|
5
|
+
commitScrollState: () => void;
|
|
6
|
+
scheduleStateCommit: () => void;
|
|
7
|
+
scheduleVisibilitySync: () => void;
|
|
8
|
+
}): {
|
|
9
|
+
flushPendingScrollToMessage: () => boolean;
|
|
10
|
+
reanchorToAnchoredMessage: () => boolean;
|
|
11
|
+
scrollToElement: (element: HTMLElement, { align, behavior, scrollMargin, }?: MessageScrollerScrollOptions, { keepPreviousPeek, }?: {
|
|
12
|
+
keepPreviousPeek?: boolean;
|
|
13
|
+
}) => boolean;
|
|
14
|
+
scrollToEnd: ({ behavior }?: MessageScrollerScrollOptions) => boolean;
|
|
15
|
+
scrollToMessage: (messageId: string, options?: MessageScrollerScrollOptions) => boolean;
|
|
16
|
+
scrollToStart: ({ behavior }?: MessageScrollerScrollOptions) => boolean;
|
|
17
|
+
};
|
|
18
|
+
export { useMessageScrollerCommands };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { getElementScrollTop, getElementViewportTop, getMaxScrollTop, getTailSpacerHeight } from "./geometry.js";
|
|
3
|
+
import { AUTOSCROLLING_CLEAR_DELAY, SCROLL_POSITION_EPSILON } from "./types.js";
|
|
4
|
+
import { markDefaultScrollPositionApplied } from "./use-message-scroller-refs.js";
|
|
5
|
+
function useMessageScrollerCommands({ refs, commitScrollState, scheduleStateCommit, scheduleVisibilitySync }) {
|
|
6
|
+
const { streamingTurnRef, autoScrollRef, autoscrollingRef, autoscrollingTimeoutRef, contentRef, itemCountRef, messageElementsRef, modeRef, pendingScrollToMessageRef, prependRestoreRef, scrollMarginRef, scrollPreviousItemPeekRef, spacerGapRef, spacerHeightRef, spacerRef, viewportRef } = refs;
|
|
7
|
+
const setAutoScrolling = useCallback((autoscrolling)=>{
|
|
8
|
+
if (null !== autoscrollingTimeoutRef.current) {
|
|
9
|
+
window.clearTimeout(autoscrollingTimeoutRef.current);
|
|
10
|
+
autoscrollingTimeoutRef.current = null;
|
|
11
|
+
}
|
|
12
|
+
if (autoscrollingRef.current !== autoscrolling) {
|
|
13
|
+
autoscrollingRef.current = autoscrolling;
|
|
14
|
+
commitScrollState();
|
|
15
|
+
}
|
|
16
|
+
if (autoscrolling) autoscrollingTimeoutRef.current = window.setTimeout(()=>{
|
|
17
|
+
autoscrollingTimeoutRef.current = null;
|
|
18
|
+
autoscrollingRef.current = false;
|
|
19
|
+
commitScrollState();
|
|
20
|
+
}, AUTOSCROLLING_CLEAR_DELAY);
|
|
21
|
+
}, [
|
|
22
|
+
commitScrollState
|
|
23
|
+
]);
|
|
24
|
+
const setTailSpacerHeight = useCallback((height)=>{
|
|
25
|
+
const spacer = spacerRef.current;
|
|
26
|
+
if (!spacer) return;
|
|
27
|
+
const nextHeight = Math.max(0, Math.ceil(height));
|
|
28
|
+
if (spacerHeightRef.current === nextHeight) return;
|
|
29
|
+
spacerHeightRef.current = nextHeight;
|
|
30
|
+
spacer.hidden = 0 === nextHeight;
|
|
31
|
+
spacer.style.height = `${nextHeight}px`;
|
|
32
|
+
spacer.style.marginTop = nextHeight > 0 ? `${-spacerGapRef.current}px` : '';
|
|
33
|
+
}, []);
|
|
34
|
+
const scrollToPosition = useCallback((scrollTop, { behavior = 'auto', autoscrolling = false } = {})=>{
|
|
35
|
+
const viewport = viewportRef.current;
|
|
36
|
+
if (!viewport) return;
|
|
37
|
+
const nextScrollTop = Math.max(0, scrollTop);
|
|
38
|
+
if (Math.abs(viewport.scrollTop - nextScrollTop) <= SCROLL_POSITION_EPSILON) {
|
|
39
|
+
viewport.scrollTop = nextScrollTop;
|
|
40
|
+
commitScrollState();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (autoscrolling) setAutoScrolling(true);
|
|
44
|
+
viewport.scrollTo({
|
|
45
|
+
top: nextScrollTop,
|
|
46
|
+
behavior
|
|
47
|
+
});
|
|
48
|
+
scheduleStateCommit();
|
|
49
|
+
}, [
|
|
50
|
+
commitScrollState,
|
|
51
|
+
scheduleStateCommit,
|
|
52
|
+
setAutoScrolling
|
|
53
|
+
]);
|
|
54
|
+
const scrollToStart = useCallback(({ behavior = 'auto' } = {})=>{
|
|
55
|
+
if (!viewportRef.current) return false;
|
|
56
|
+
setTailSpacerHeight(0);
|
|
57
|
+
streamingTurnRef.current = null;
|
|
58
|
+
modeRef.current = 'free-scrolling';
|
|
59
|
+
scrollToPosition(0, {
|
|
60
|
+
behavior
|
|
61
|
+
});
|
|
62
|
+
scheduleVisibilitySync();
|
|
63
|
+
return true;
|
|
64
|
+
}, [
|
|
65
|
+
scheduleVisibilitySync,
|
|
66
|
+
scrollToPosition,
|
|
67
|
+
setTailSpacerHeight
|
|
68
|
+
]);
|
|
69
|
+
const scrollToEnd = useCallback(({ behavior = 'auto' } = {})=>{
|
|
70
|
+
const viewport = viewportRef.current;
|
|
71
|
+
if (!viewport) return false;
|
|
72
|
+
setTailSpacerHeight(0);
|
|
73
|
+
streamingTurnRef.current = null;
|
|
74
|
+
modeRef.current = autoScrollRef.current ? 'following-bottom' : 'free-scrolling';
|
|
75
|
+
scrollToPosition(getMaxScrollTop(viewport), {
|
|
76
|
+
autoscrolling: true,
|
|
77
|
+
behavior
|
|
78
|
+
});
|
|
79
|
+
scheduleVisibilitySync();
|
|
80
|
+
return true;
|
|
81
|
+
}, [
|
|
82
|
+
scheduleVisibilitySync,
|
|
83
|
+
scrollToPosition,
|
|
84
|
+
setTailSpacerHeight
|
|
85
|
+
]);
|
|
86
|
+
const scrollToElement = useCallback((element, { align = 'start', behavior = 'auto', scrollMargin = scrollMarginRef.current } = {}, { keepPreviousPeek = false } = {})=>{
|
|
87
|
+
const content = contentRef.current;
|
|
88
|
+
const viewport = viewportRef.current;
|
|
89
|
+
if (!content || !viewport || !content.contains(element)) return false;
|
|
90
|
+
const scrollTop = getElementScrollTop({
|
|
91
|
+
align,
|
|
92
|
+
element,
|
|
93
|
+
scrollMargin: keepPreviousPeek ? scrollMargin + scrollPreviousItemPeekRef.current : scrollMargin,
|
|
94
|
+
spacer: spacerRef.current,
|
|
95
|
+
viewport
|
|
96
|
+
});
|
|
97
|
+
const nextSpacerHeight = getTailSpacerHeight({
|
|
98
|
+
content,
|
|
99
|
+
scrollTop,
|
|
100
|
+
spacer: spacerRef.current,
|
|
101
|
+
viewport
|
|
102
|
+
});
|
|
103
|
+
setTailSpacerHeight(nextSpacerHeight);
|
|
104
|
+
prependRestoreRef.current = {
|
|
105
|
+
element,
|
|
106
|
+
viewportTop: getElementViewportTop(element, viewport)
|
|
107
|
+
};
|
|
108
|
+
modeRef.current = keepPreviousPeek ? 'anchored-to-message' : 'settling-jump';
|
|
109
|
+
streamingTurnRef.current = keepPreviousPeek ? element : null;
|
|
110
|
+
scrollToPosition(scrollTop, {
|
|
111
|
+
behavior
|
|
112
|
+
});
|
|
113
|
+
scheduleVisibilitySync();
|
|
114
|
+
return true;
|
|
115
|
+
}, [
|
|
116
|
+
scheduleVisibilitySync,
|
|
117
|
+
scrollToPosition,
|
|
118
|
+
setTailSpacerHeight
|
|
119
|
+
]);
|
|
120
|
+
const reanchorToAnchoredMessage = useCallback(()=>{
|
|
121
|
+
const element = streamingTurnRef.current;
|
|
122
|
+
if (!element || !element.isConnected || 'anchored-to-message' !== modeRef.current) return false;
|
|
123
|
+
return scrollToElement(element, {
|
|
124
|
+
align: 'start'
|
|
125
|
+
}, {
|
|
126
|
+
keepPreviousPeek: true
|
|
127
|
+
});
|
|
128
|
+
}, [
|
|
129
|
+
scrollToElement
|
|
130
|
+
]);
|
|
131
|
+
const scrollToMessage = useCallback((messageId, options)=>{
|
|
132
|
+
const element = messageElementsRef.current.get(messageId);
|
|
133
|
+
if (!element) {
|
|
134
|
+
if (0 === itemCountRef.current) {
|
|
135
|
+
pendingScrollToMessageRef.current = {
|
|
136
|
+
messageId,
|
|
137
|
+
options
|
|
138
|
+
};
|
|
139
|
+
markDefaultScrollPositionApplied(refs);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
markDefaultScrollPositionApplied(refs);
|
|
145
|
+
if (scrollToElement(element, options)) {
|
|
146
|
+
pendingScrollToMessageRef.current = null;
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
pendingScrollToMessageRef.current = {
|
|
150
|
+
messageId,
|
|
151
|
+
options
|
|
152
|
+
};
|
|
153
|
+
return true;
|
|
154
|
+
}, [
|
|
155
|
+
scrollToElement
|
|
156
|
+
]);
|
|
157
|
+
const flushPendingScrollToMessage = useCallback(()=>{
|
|
158
|
+
const pending = pendingScrollToMessageRef.current;
|
|
159
|
+
if (!pending) return false;
|
|
160
|
+
const element = messageElementsRef.current.get(pending.messageId);
|
|
161
|
+
if (!element) return false;
|
|
162
|
+
const handled = scrollToElement(element, pending.options);
|
|
163
|
+
if (!handled) return false;
|
|
164
|
+
pendingScrollToMessageRef.current = null;
|
|
165
|
+
markDefaultScrollPositionApplied(refs);
|
|
166
|
+
return true;
|
|
167
|
+
}, [
|
|
168
|
+
scrollToElement
|
|
169
|
+
]);
|
|
170
|
+
return {
|
|
171
|
+
flushPendingScrollToMessage,
|
|
172
|
+
reanchorToAnchoredMessage,
|
|
173
|
+
scrollToElement,
|
|
174
|
+
scrollToEnd,
|
|
175
|
+
scrollToMessage,
|
|
176
|
+
scrollToStart
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export { useMessageScrollerCommands };
|