@pathscale/ui 0.0.133 → 0.0.135

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.
@@ -17,6 +17,21 @@ export interface LiveChatBubbleProps extends IComponentBaseProps {
17
17
  * @default 0
18
18
  */
19
19
  unreadCount?: number;
20
+ /**
21
+ * Auto-scroll to the latest message when new messages are appended
22
+ * @default true
23
+ */
24
+ autoScrollOnNewMessage?: boolean;
25
+ /**
26
+ * Auto-scroll behavior when moving to the latest message
27
+ * @default "instant"
28
+ */
29
+ autoScrollBehavior?: "instant" | "smooth";
30
+ /**
31
+ * Reserved for backward compatibility.
32
+ * Auto-scroll now always follows new messages when enabled.
33
+ */
34
+ stickToBottomThreshold?: number;
20
35
  /**
21
36
  * Props to pass to the LiveChatPanel when opened
22
37
  */
@@ -49,6 +49,21 @@ export interface LiveChatPanelProps extends IComponentBaseProps {
49
49
  * Whether a message is currently being sent
50
50
  */
51
51
  isSending?: boolean;
52
+ /**
53
+ * Auto-scroll to the latest message when new messages are appended
54
+ * @default true
55
+ */
56
+ autoScrollOnNewMessage?: boolean;
57
+ /**
58
+ * Auto-scroll behavior when moving to the latest message
59
+ * @default "instant"
60
+ */
61
+ autoScrollBehavior?: "instant" | "smooth";
62
+ /**
63
+ * Reserved for backward compatibility.
64
+ * Auto-scroll now always follows new messages when enabled.
65
+ */
66
+ stickToBottomThreshold?: number;
52
67
  }
53
68
  declare const LiveChatPanel: Component<LiveChatPanelProps>;
54
69
  export default LiveChatPanel;
package/dist/index.js CHANGED
@@ -8655,7 +8655,7 @@ const Tooltip = (props)=>{
8655
8655
  "className",
8656
8656
  "style"
8657
8657
  ]);
8658
- const classes = ()=>twMerge("tooltip", "[&::before]:!z-[9999]", "[&::after]:!z-[9999]", local.class, local.className, clsx({
8658
+ const classes = ()=>twMerge("tooltip", "!z-[9999]", "relative", "[&::before]:!z-[9999]", "[&::after]:!z-[9999]", local.class, local.className, clsx({
8659
8659
  "tooltip-open": local.open,
8660
8660
  "tooltip-primary": "primary" === local.color,
8661
8661
  "tooltip-secondary": "secondary" === local.color,
@@ -9397,7 +9397,7 @@ const DropdownDetails = Object.assign(Details, {
9397
9397
  Toggle: DropdownToggle_Summary
9398
9398
  });
9399
9399
  var DropdownItem_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<li role=menuitem>"), DropdownItem_tmpl$2 = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<a>"), DropdownItem_tmpl$3 = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<button>");
9400
- const DropdownItem = (props)=>{
9400
+ const DropdownItem_DropdownItem = (props)=>{
9401
9401
  const dropdownContext = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.useContext)(DropdownContext);
9402
9402
  const defaultProps = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.mergeProps)({
9403
9403
  closeOnClick: true
@@ -9439,7 +9439,7 @@ const DropdownItem = (props)=>{
9439
9439
  return _el$;
9440
9440
  })();
9441
9441
  };
9442
- const dropdown_DropdownItem = DropdownItem;
9442
+ const DropdownItem = DropdownItem_DropdownItem;
9443
9443
  var DropdownMenu_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<ul>");
9444
9444
  const DropdownMenu = (props)=>{
9445
9445
  const [local, others] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
@@ -9641,7 +9641,7 @@ const dropdown_Dropdown = Object.assign(Dropdown, {
9641
9641
  Details: DropdownDetails,
9642
9642
  Toggle: dropdown_DropdownToggle,
9643
9643
  Menu: dropdown_DropdownMenu,
9644
- Item: dropdown_DropdownItem
9644
+ Item: DropdownItem
9645
9645
  });
9646
9646
  const dropdown = dropdown_Dropdown;
9647
9647
  var FileInput_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<input>");
@@ -12012,6 +12012,9 @@ const LiveChatPanel_LiveChatPanel = (props)=>{
12012
12012
  "messages",
12013
12013
  "onSendMessage",
12014
12014
  "isSending",
12015
+ "autoScrollOnNewMessage",
12016
+ "autoScrollBehavior",
12017
+ "stickToBottomThreshold",
12015
12018
  "class",
12016
12019
  "className",
12017
12020
  "style"
@@ -12019,6 +12022,12 @@ const LiveChatPanel_LiveChatPanel = (props)=>{
12019
12022
  const [internalMessages, setInternalMessages] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)([]);
12020
12023
  const [inputValue, setInputValue] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)("");
12021
12024
  const [sending, setSending] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(false);
12025
+ let scrollContainer;
12026
+ let previousMessageCount = 0;
12027
+ let previousLastMessageId;
12028
+ let hasObservedMessages = false;
12029
+ let scrollRafId;
12030
+ let scrollRafNestedId;
12022
12031
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
12023
12032
  if (local.mockMode) setInternalMessages(getMockMessages());
12024
12033
  else if (local.messages) setInternalMessages(local.messages);
@@ -12027,6 +12036,52 @@ const LiveChatPanel_LiveChatPanel = (props)=>{
12027
12036
  if (!local.mockMode && local.messages) setInternalMessages(local.messages);
12028
12037
  });
12029
12038
  const isSending = ()=>local.isSending ?? sending();
12039
+ const autoScrollOnNewMessage = ()=>local.autoScrollOnNewMessage ?? true;
12040
+ const autoScrollBehavior = ()=>local.autoScrollBehavior ?? "instant";
12041
+ const scrollToBottom = ()=>{
12042
+ if (!scrollContainer) return;
12043
+ if ("smooth" === autoScrollBehavior()) return void scrollContainer.scrollTo({
12044
+ top: scrollContainer.scrollHeight,
12045
+ behavior: "smooth"
12046
+ });
12047
+ scrollContainer.scrollTop = scrollContainer.scrollHeight;
12048
+ };
12049
+ const clearScheduledScroll = ()=>{
12050
+ if ("undefined" == typeof window) return;
12051
+ if (null != scrollRafId) {
12052
+ window.cancelAnimationFrame(scrollRafId);
12053
+ scrollRafId = void 0;
12054
+ }
12055
+ if (null != scrollRafNestedId) {
12056
+ window.cancelAnimationFrame(scrollRafNestedId);
12057
+ scrollRafNestedId = void 0;
12058
+ }
12059
+ };
12060
+ const scheduleScrollToBottom = ()=>{
12061
+ if ("undefined" == typeof window) return void scrollToBottom();
12062
+ clearScheduledScroll();
12063
+ scrollRafId = window.requestAnimationFrame(()=>{
12064
+ scrollRafNestedId = window.requestAnimationFrame(()=>{
12065
+ scrollToBottom();
12066
+ });
12067
+ });
12068
+ };
12069
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
12070
+ const messages = internalMessages();
12071
+ const nextMessageCount = messages.length;
12072
+ const nextLastMessageId = messages[messages.length - 1]?.messageId;
12073
+ const isInitialHydration = !hasObservedMessages && nextMessageCount > 0;
12074
+ const hasAppendedMessage = hasObservedMessages ? nextMessageCount > previousMessageCount || nextMessageCount > 0 && nextLastMessageId !== previousLastMessageId : false;
12075
+ previousMessageCount = nextMessageCount;
12076
+ previousLastMessageId = nextLastMessageId;
12077
+ hasObservedMessages = true;
12078
+ if (!autoScrollOnNewMessage()) return;
12079
+ if (!isInitialHydration && !hasAppendedMessage) return;
12080
+ scheduleScrollToBottom();
12081
+ });
12082
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onCleanup)(()=>{
12083
+ clearScheduledScroll();
12084
+ });
12030
12085
  const handleSend = async ()=>{
12031
12086
  const content = inputValue().trim();
12032
12087
  if (!content || isSending()) return;
@@ -12126,6 +12181,9 @@ const LiveChatPanel_LiveChatPanel = (props)=>{
12126
12181
  }
12127
12182
  }), _el$5);
12128
12183
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.addEventListener)(_el$5, "click", local.onClose, true);
12184
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.use)((element)=>{
12185
+ scrollContainer = element;
12186
+ }, _el$6);
12129
12187
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$6, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(__WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.For, {
12130
12188
  get each () {
12131
12189
  return internalMessages();
@@ -12241,6 +12299,9 @@ const LiveChatBubble = (props)=>{
12241
12299
  "position",
12242
12300
  "aria-label",
12243
12301
  "unreadCount",
12302
+ "autoScrollOnNewMessage",
12303
+ "autoScrollBehavior",
12304
+ "stickToBottomThreshold",
12244
12305
  "panelProps",
12245
12306
  "onOpen",
12246
12307
  "onClose",
@@ -12316,6 +12377,15 @@ const LiveChatBubble = (props)=>{
12316
12377
  },
12317
12378
  get children () {
12318
12379
  return (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(LiveChatPanel, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.mergeProps)(()=>local.panelProps ?? {}, {
12380
+ get autoScrollOnNewMessage () {
12381
+ return local.panelProps?.autoScrollOnNewMessage ?? local.autoScrollOnNewMessage;
12382
+ },
12383
+ get autoScrollBehavior () {
12384
+ return local.panelProps?.autoScrollBehavior ?? local.autoScrollBehavior;
12385
+ },
12386
+ get stickToBottomThreshold () {
12387
+ return local.panelProps?.stickToBottomThreshold ?? local.stickToBottomThreshold;
12388
+ },
12319
12389
  onClose: handleClose
12320
12390
  }));
12321
12391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pathscale/ui",
3
- "version": "0.0.133",
3
+ "version": "0.0.135",
4
4
  "author": "pathscale",
5
5
  "repository": {
6
6
  "type": "git",