@ni/spright-components 6.22.5 → 6.22.7
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/all-components-bundle.js +33 -24
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +12 -10
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/chat/conversation/models/auto-scroll-manager.d.ts +4 -2
- package/dist/esm/chat/conversation/models/auto-scroll-manager.js +33 -24
- package/dist/esm/chat/conversation/models/auto-scroll-manager.js.map +1 -1
- package/dist/esm/chat/conversation/testing/chat-conversation.pageobject.d.ts +2 -0
- package/dist/esm/chat/conversation/testing/chat-conversation.pageobject.js +6 -0
- package/dist/esm/chat/conversation/testing/chat-conversation.pageobject.js.map +1 -1
- package/package.json +3 -3
|
@@ -103900,8 +103900,30 @@ focus outline in that case.
|
|
|
103900
103900
|
this.onMessagesChanged();
|
|
103901
103901
|
}
|
|
103902
103902
|
}
|
|
103903
|
+
/** @internal */
|
|
103904
|
+
smoothScrollTo(scrollTop) {
|
|
103905
|
+
const container = this.conversation.messagesContainer;
|
|
103906
|
+
if (Math.abs(container.scrollTop - scrollTop) <= 1) {
|
|
103907
|
+
// No movement is needed, so `scrollTo` would not emit a scroll event
|
|
103908
|
+
// to clear the programmatic guard. Snap to the exact target and
|
|
103909
|
+
// leave the guard clear so streamed content keeps being followed.
|
|
103910
|
+
this.programmaticScrollTarget = undefined;
|
|
103911
|
+
container.scrollTop = scrollTop;
|
|
103912
|
+
return;
|
|
103913
|
+
}
|
|
103914
|
+
this.programmaticScrollTarget = scrollTop;
|
|
103915
|
+
container.scrollTo({
|
|
103916
|
+
top: scrollTop,
|
|
103917
|
+
behavior: 'smooth'
|
|
103918
|
+
});
|
|
103919
|
+
}
|
|
103920
|
+
/** @internal */
|
|
103921
|
+
instantScrollTo(scrollTop) {
|
|
103922
|
+
this.conversation.messagesContainer.scrollTop = scrollTop;
|
|
103923
|
+
}
|
|
103903
103924
|
onMessagesChanged() {
|
|
103904
103925
|
const current = this.getOrderedMessages();
|
|
103926
|
+
const isInitialContent = this.previousMessages.length === 0;
|
|
103905
103927
|
const previousSet = new Set(this.previousMessages);
|
|
103906
103928
|
const addedMessages = current.filter(message => !previousSet.has(message));
|
|
103907
103929
|
this.previousMessages = current;
|
|
@@ -103910,7 +103932,7 @@ focus outline in that case.
|
|
|
103910
103932
|
return;
|
|
103911
103933
|
}
|
|
103912
103934
|
const hasAnchorMessage = addedMessages.some(message => message.messageInternals.anchorOnInsert);
|
|
103913
|
-
this.scheduleScrollUpdate(hasAnchorMessage);
|
|
103935
|
+
this.scheduleScrollUpdate(hasAnchorMessage, isInitialContent);
|
|
103914
103936
|
}
|
|
103915
103937
|
repartition(messages) {
|
|
103916
103938
|
const anchorIndex = this.findLatestAnchorIndex(messages);
|
|
@@ -103926,18 +103948,19 @@ focus outline in that case.
|
|
|
103926
103948
|
message.messageInternals.slot = undefined;
|
|
103927
103949
|
}
|
|
103928
103950
|
}
|
|
103929
|
-
scheduleScrollUpdate(hasAnchorMessage) {
|
|
103951
|
+
scheduleScrollUpdate(hasAnchorMessage, isInitialContent) {
|
|
103930
103952
|
this.pendingAnchorInsert = this.pendingAnchorInsert || hasAnchorMessage;
|
|
103931
103953
|
if (this.scrollUpdatePending) {
|
|
103932
103954
|
return;
|
|
103933
103955
|
}
|
|
103956
|
+
const shouldAnimate = !isInitialContent;
|
|
103934
103957
|
this.scrollUpdatePending = true;
|
|
103935
103958
|
requestAnimationFrame(() => {
|
|
103936
103959
|
this.scrollUpdatePending = false;
|
|
103937
103960
|
const anchorInsert = this.pendingAnchorInsert;
|
|
103938
103961
|
this.pendingAnchorInsert = false;
|
|
103939
103962
|
if (anchorInsert) {
|
|
103940
|
-
this.anchorToLastInsertedMessage();
|
|
103963
|
+
this.anchorToLastInsertedMessage(shouldAnimate);
|
|
103941
103964
|
}
|
|
103942
103965
|
else if (this.autoScrollEngaged) {
|
|
103943
103966
|
this.followContent();
|
|
@@ -103948,14 +103971,19 @@ focus outline in that case.
|
|
|
103948
103971
|
* Pins the most recently inserted anchor message near the top of the
|
|
103949
103972
|
* viewport.
|
|
103950
103973
|
*/
|
|
103951
|
-
anchorToLastInsertedMessage() {
|
|
103974
|
+
anchorToLastInsertedMessage(animate) {
|
|
103952
103975
|
const message = this.getLastAnchorMessage();
|
|
103953
103976
|
if (message === undefined) {
|
|
103954
103977
|
return;
|
|
103955
103978
|
}
|
|
103956
103979
|
this.setScrollAnchorMessage(message);
|
|
103957
103980
|
this.autoScrollEngaged = true;
|
|
103958
|
-
|
|
103981
|
+
if (animate) {
|
|
103982
|
+
this.smoothScrollTo(this.getMaxScrollTop());
|
|
103983
|
+
}
|
|
103984
|
+
else {
|
|
103985
|
+
this.instantScrollTo(this.getMaxScrollTop());
|
|
103986
|
+
}
|
|
103959
103987
|
}
|
|
103960
103988
|
followContent() {
|
|
103961
103989
|
this.instantScrollTo(this.getMaxScrollTop());
|
|
@@ -103980,25 +104008,6 @@ focus outline in that case.
|
|
|
103980
104008
|
const { scrollHeight, clientHeight } = this.conversation.messagesContainer;
|
|
103981
104009
|
return Math.max(0, scrollHeight - clientHeight);
|
|
103982
104010
|
}
|
|
103983
|
-
smoothScrollTo(scrollTop) {
|
|
103984
|
-
const container = this.conversation.messagesContainer;
|
|
103985
|
-
if (Math.abs(container.scrollTop - scrollTop) <= 1) {
|
|
103986
|
-
// No movement is needed, so `scrollTo` would not emit a scroll event
|
|
103987
|
-
// to clear the programmatic guard. Snap to the exact target and
|
|
103988
|
-
// leave the guard clear so streamed content keeps being followed.
|
|
103989
|
-
this.programmaticScrollTarget = undefined;
|
|
103990
|
-
container.scrollTop = scrollTop;
|
|
103991
|
-
return;
|
|
103992
|
-
}
|
|
103993
|
-
this.programmaticScrollTarget = scrollTop;
|
|
103994
|
-
container.scrollTo({
|
|
103995
|
-
top: scrollTop,
|
|
103996
|
-
behavior: 'smooth'
|
|
103997
|
-
});
|
|
103998
|
-
}
|
|
103999
|
-
instantScrollTo(scrollTop) {
|
|
104000
|
-
this.conversation.messagesContainer.scrollTop = scrollTop;
|
|
104001
|
-
}
|
|
104002
104011
|
setScrollAnchorMessage(message) {
|
|
104003
104012
|
if (this.scrollAnchorMessage === message) {
|
|
104004
104013
|
return;
|