@pathscale/ui 0.0.134 → 0.0.136

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
@@ -7229,6 +7229,18 @@ const toRgba = (rgb, alpha)=>{
7229
7229
  return `rgba(${match[1]}, ${match[2]}, ${match[3]}, ${alpha})`;
7230
7230
  };
7231
7231
  const COLORS = [
7232
+ createColorItem("rgb(80,80,80)", 47.631, -27.5),
7233
+ createColorItem("rgb(80,60,50)", 27.5, -47.631),
7234
+ createColorItem("rgb(80,50,50)", 0, -55),
7235
+ createColorItem("rgb(80,50,70)", -27.5, -47.631),
7236
+ createColorItem("rgb(70,50,80)", -47.631, -27.5),
7237
+ createColorItem("rgb(55,50,80)", -55, 0),
7238
+ createColorItem("rgb(50,55,80)", -47.631, 27.5),
7239
+ createColorItem("rgb(50,65,80)", -27.5, 47.631),
7240
+ createColorItem("rgb(50,80,80)", 0, 55),
7241
+ createColorItem("rgb(50,80,65)", 27.5, 47.631),
7242
+ createColorItem("rgb(55,80,50)", 47.631, 27.5),
7243
+ createColorItem("rgb(70,80,50)", 55, 0),
7232
7244
  createColorItem("rgb(245,245,61)", 34.641, -20),
7233
7245
  createColorItem("rgb(245,153,61)", 20, -34.641),
7234
7246
  createColorItem("rgb(245,61,61)", 0, -40),
@@ -7337,7 +7349,7 @@ const ColorWheelFlower = (props)=>{
7337
7349
  setHoveredIndex(null);
7338
7350
  if (void 0 !== pointerTimeout) clearTimeout(pointerTimeout);
7339
7351
  };
7340
- const containerClasses = ()=>twMerge("relative w-[140px] h-[140px] flex items-center justify-center", clsx({
7352
+ const containerClasses = ()=>twMerge("relative w-[190px] h-[190px] flex items-center justify-center", clsx({
7341
7353
  "opacity-50 cursor-not-allowed": context.disabled()
7342
7354
  }), props.class, props.className);
7343
7355
  const outerRingBackground = ()=>{
@@ -12012,6 +12024,9 @@ const LiveChatPanel_LiveChatPanel = (props)=>{
12012
12024
  "messages",
12013
12025
  "onSendMessage",
12014
12026
  "isSending",
12027
+ "autoScrollOnNewMessage",
12028
+ "autoScrollBehavior",
12029
+ "stickToBottomThreshold",
12015
12030
  "class",
12016
12031
  "className",
12017
12032
  "style"
@@ -12019,6 +12034,12 @@ const LiveChatPanel_LiveChatPanel = (props)=>{
12019
12034
  const [internalMessages, setInternalMessages] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)([]);
12020
12035
  const [inputValue, setInputValue] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)("");
12021
12036
  const [sending, setSending] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(false);
12037
+ let scrollContainer;
12038
+ let previousMessageCount = 0;
12039
+ let previousLastMessageId;
12040
+ let hasObservedMessages = false;
12041
+ let scrollRafId;
12042
+ let scrollRafNestedId;
12022
12043
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
12023
12044
  if (local.mockMode) setInternalMessages(getMockMessages());
12024
12045
  else if (local.messages) setInternalMessages(local.messages);
@@ -12027,6 +12048,52 @@ const LiveChatPanel_LiveChatPanel = (props)=>{
12027
12048
  if (!local.mockMode && local.messages) setInternalMessages(local.messages);
12028
12049
  });
12029
12050
  const isSending = ()=>local.isSending ?? sending();
12051
+ const autoScrollOnNewMessage = ()=>local.autoScrollOnNewMessage ?? true;
12052
+ const autoScrollBehavior = ()=>local.autoScrollBehavior ?? "instant";
12053
+ const scrollToBottom = ()=>{
12054
+ if (!scrollContainer) return;
12055
+ if ("smooth" === autoScrollBehavior()) return void scrollContainer.scrollTo({
12056
+ top: scrollContainer.scrollHeight,
12057
+ behavior: "smooth"
12058
+ });
12059
+ scrollContainer.scrollTop = scrollContainer.scrollHeight;
12060
+ };
12061
+ const clearScheduledScroll = ()=>{
12062
+ if ("undefined" == typeof window) return;
12063
+ if (null != scrollRafId) {
12064
+ window.cancelAnimationFrame(scrollRafId);
12065
+ scrollRafId = void 0;
12066
+ }
12067
+ if (null != scrollRafNestedId) {
12068
+ window.cancelAnimationFrame(scrollRafNestedId);
12069
+ scrollRafNestedId = void 0;
12070
+ }
12071
+ };
12072
+ const scheduleScrollToBottom = ()=>{
12073
+ if ("undefined" == typeof window) return void scrollToBottom();
12074
+ clearScheduledScroll();
12075
+ scrollRafId = window.requestAnimationFrame(()=>{
12076
+ scrollRafNestedId = window.requestAnimationFrame(()=>{
12077
+ scrollToBottom();
12078
+ });
12079
+ });
12080
+ };
12081
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
12082
+ const messages = internalMessages();
12083
+ const nextMessageCount = messages.length;
12084
+ const nextLastMessageId = messages[messages.length - 1]?.messageId;
12085
+ const isInitialHydration = !hasObservedMessages && nextMessageCount > 0;
12086
+ const hasAppendedMessage = hasObservedMessages ? nextMessageCount > previousMessageCount || nextMessageCount > 0 && nextLastMessageId !== previousLastMessageId : false;
12087
+ previousMessageCount = nextMessageCount;
12088
+ previousLastMessageId = nextLastMessageId;
12089
+ hasObservedMessages = true;
12090
+ if (!autoScrollOnNewMessage()) return;
12091
+ if (!isInitialHydration && !hasAppendedMessage) return;
12092
+ scheduleScrollToBottom();
12093
+ });
12094
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onCleanup)(()=>{
12095
+ clearScheduledScroll();
12096
+ });
12030
12097
  const handleSend = async ()=>{
12031
12098
  const content = inputValue().trim();
12032
12099
  if (!content || isSending()) return;
@@ -12126,6 +12193,9 @@ const LiveChatPanel_LiveChatPanel = (props)=>{
12126
12193
  }
12127
12194
  }), _el$5);
12128
12195
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.addEventListener)(_el$5, "click", local.onClose, true);
12196
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.use)((element)=>{
12197
+ scrollContainer = element;
12198
+ }, _el$6);
12129
12199
  (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
12200
  get each () {
12131
12201
  return internalMessages();
@@ -12241,6 +12311,9 @@ const LiveChatBubble = (props)=>{
12241
12311
  "position",
12242
12312
  "aria-label",
12243
12313
  "unreadCount",
12314
+ "autoScrollOnNewMessage",
12315
+ "autoScrollBehavior",
12316
+ "stickToBottomThreshold",
12244
12317
  "panelProps",
12245
12318
  "onOpen",
12246
12319
  "onClose",
@@ -12316,6 +12389,15 @@ const LiveChatBubble = (props)=>{
12316
12389
  },
12317
12390
  get children () {
12318
12391
  return (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(LiveChatPanel, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.mergeProps)(()=>local.panelProps ?? {}, {
12392
+ get autoScrollOnNewMessage () {
12393
+ return local.panelProps?.autoScrollOnNewMessage ?? local.autoScrollOnNewMessage;
12394
+ },
12395
+ get autoScrollBehavior () {
12396
+ return local.panelProps?.autoScrollBehavior ?? local.autoScrollBehavior;
12397
+ },
12398
+ get stickToBottomThreshold () {
12399
+ return local.panelProps?.stickToBottomThreshold ?? local.stickToBottomThreshold;
12400
+ },
12319
12401
  onClose: handleClose
12320
12402
  }));
12321
12403
  }
@@ -16770,7 +16852,7 @@ function getDefaultHueShiftStore() {
16770
16852
  if (!defaultStore) defaultStore = createHueShiftStore("theme");
16771
16853
  return defaultStore;
16772
16854
  }
16773
- var ThemeColorPicker_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)('<div class="absolute right-0 mt-2 p-4 bg-base-100 rounded-lg shadow-xl border border-base-300 z-50">'), ThemeColorPicker_tmpl$2 = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<div>");
16855
+ var ThemeColorPicker_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)('<div class="absolute right-0 mt-2 p-6 bg-base-100 rounded-lg shadow-xl border border-base-300 z-50">'), ThemeColorPicker_tmpl$2 = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<div>");
16774
16856
  function hueToColorValue(hue, sat) {
16775
16857
  const h = hue ?? 0;
16776
16858
  const s = null === hue ? 0 : sat;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pathscale/ui",
3
- "version": "0.0.134",
3
+ "version": "0.0.136",
4
4
  "author": "pathscale",
5
5
  "repository": {
6
6
  "type": "git",