@uzum-tech/ui 1.10.0 → 1.10.1

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/index.js CHANGED
@@ -60909,13 +60909,25 @@
60909
60909
  const handleChatSelect = (chatId) => {
60910
60910
  props.onChatSelect?.(chatId);
60911
60911
  };
60912
+ const toKeyString = (value) => {
60913
+ if (typeof value === "symbol") return value.toString();
60914
+ if (typeof value === "function") {
60915
+ const result = value();
60916
+ return typeof result === "string" || typeof result === "number" ? String(result) : "";
60917
+ }
60918
+ return value != null ? String(value) : "";
60919
+ };
60912
60920
  const renderChatItem = (item) => {
60913
60921
  const isSelected = props.selectedChatId === item.id;
60914
60922
  const isTyping = props.typingChatIds?.includes(item.id) ?? false;
60923
+ const { id, title, subtitle } = item;
60924
+ const keyId = toKeyString(id);
60925
+ const keyTitle = toKeyString(title);
60926
+ const keySubtitle = toKeyString(subtitle);
60915
60927
  return /* @__PURE__ */ vue.h(
60916
60928
  UListItem,
60917
60929
  {
60918
- key: item.id,
60930
+ key: `${keyId}-${keyTitle}-${keySubtitle}`,
60919
60931
  showIcon: false,
60920
60932
  onClick: () => {
60921
60933
  handleChatSelect(item.id);
@@ -65747,50 +65759,62 @@
65747
65759
  el.scrollTop = el.scrollHeight;
65748
65760
  }
65749
65761
  };
65762
+ const toKeyString = (value) => {
65763
+ if (typeof value === "symbol") return value.toString();
65764
+ if (typeof value === "function") {
65765
+ const result = value();
65766
+ return typeof result === "string" || typeof result === "number" ? String(result) : "";
65767
+ }
65768
+ return value != null ? String(value) : "";
65769
+ };
65750
65770
  const renderHeader = () => {
65751
65771
  return /* @__PURE__ */ vue.h("div", { class: `${mergedClsPrefixRef.value}-chat-main__header` }, /* @__PURE__ */ vue.h(UFlex, { justify: "space-between", align: "flex-start", wrap: false }, {
65752
- default: () => /* @__PURE__ */ vue.h(vue.Fragment, null, /* @__PURE__ */ vue.h(
65753
- UText,
65754
- {
65755
- variant: "heading-s-bold",
65756
- class: `${mergedClsPrefixRef.value}-chat-main__header-title`,
65757
- theme: mergedThemeRef.value.peers.Typography,
65758
- themeOverrides: mergedThemeRef.value.peerOverrides.Typography
65759
- },
65760
- {
65761
- default: () => selectedChatRef.value?.title ?? ""
65762
- }
65763
- ), /* @__PURE__ */ vue.h(
65764
- UFlex,
65765
- {
65766
- align: "center",
65767
- size: "small",
65768
- class: `${mergedClsPrefixRef.value}-chat-main__header-actions`
65769
- },
65770
- {
65771
- default: () => resolveSlot(slots.headerActions, () => {
65772
- const shareButtonProps = {
65773
- ...headerButtonPropsRef.value,
65774
- ...headerShareButtonPropsRef.value
65775
- };
65776
- const profileButtonProps = {
65777
- ...headerButtonPropsRef.value,
65778
- ...headerProfileButtonPropsRef.value
65779
- };
65780
- const closeButtonProps = {
65781
- ...headerButtonPropsRef.value,
65782
- ...headerCloseButtonPropsRef.value
65783
- };
65784
- const shareIconProps = {
65785
- ...headerIconPropsRef.value,
65786
- ...headerShareIconPropsRef.value
65787
- };
65788
- const profileIconProps = {
65789
- ...headerIconPropsRef.value,
65790
- ...headerProfileIconPropsRef.value
65791
- };
65792
- const buttons = [];
65793
- if (shareButtonProps.disabled !== true) {
65772
+ default: () => {
65773
+ const chat = selectedChatRef.value;
65774
+ const keyId = toKeyString(chat?.id);
65775
+ const keyTitle = toKeyString(chat?.title);
65776
+ return /* @__PURE__ */ vue.h(vue.Fragment, null, /* @__PURE__ */ vue.h(
65777
+ UText,
65778
+ {
65779
+ key: `${keyId}-${keyTitle}`,
65780
+ variant: "heading-s-bold",
65781
+ class: `${mergedClsPrefixRef.value}-chat-main__header-title`,
65782
+ theme: mergedThemeRef.value.peers.Typography,
65783
+ themeOverrides: mergedThemeRef.value.peerOverrides.Typography
65784
+ },
65785
+ {
65786
+ default: () => selectedChatRef.value?.title ?? ""
65787
+ }
65788
+ ), /* @__PURE__ */ vue.h(
65789
+ UFlex,
65790
+ {
65791
+ align: "center",
65792
+ size: "small",
65793
+ class: `${mergedClsPrefixRef.value}-chat-main__header-actions`
65794
+ },
65795
+ {
65796
+ default: () => resolveSlot(slots.headerActions, () => {
65797
+ const shareButtonProps = {
65798
+ ...headerButtonPropsRef.value,
65799
+ ...headerShareButtonPropsRef.value
65800
+ };
65801
+ const profileButtonProps = {
65802
+ ...headerButtonPropsRef.value,
65803
+ ...headerProfileButtonPropsRef.value
65804
+ };
65805
+ const closeButtonProps = {
65806
+ ...headerButtonPropsRef.value,
65807
+ ...headerCloseButtonPropsRef.value
65808
+ };
65809
+ const shareIconProps = {
65810
+ ...headerIconPropsRef.value,
65811
+ ...headerShareIconPropsRef.value
65812
+ };
65813
+ const profileIconProps = {
65814
+ ...headerIconPropsRef.value,
65815
+ ...headerProfileIconPropsRef.value
65816
+ };
65817
+ const buttons = [];
65794
65818
  buttons.push(
65795
65819
  /* @__PURE__ */ vue.h(UTooltip, null, {
65796
65820
  trigger: () => /* @__PURE__ */ vue.h(
@@ -65822,8 +65846,6 @@
65822
65846
  default: () => shareButtonTooltipRef.value
65823
65847
  })
65824
65848
  );
65825
- }
65826
- if (profileButtonProps.disabled !== true) {
65827
65849
  buttons.push(
65828
65850
  /* @__PURE__ */ vue.h(UTooltip, null, {
65829
65851
  trigger: () => /* @__PURE__ */ vue.h(
@@ -65855,8 +65877,6 @@
65855
65877
  default: () => profileButtonTooltipRef.value
65856
65878
  })
65857
65879
  );
65858
- }
65859
- if (closeButtonProps.disabled !== true) {
65860
65880
  buttons.push(
65861
65881
  /* @__PURE__ */ vue.h(
65862
65882
  Button,
@@ -65874,11 +65894,11 @@
65874
65894
  }
65875
65895
  )
65876
65896
  );
65877
- }
65878
- return buttons;
65879
- })
65880
- }
65881
- ))
65897
+ return buttons;
65898
+ })
65899
+ }
65900
+ ));
65901
+ }
65882
65902
  }));
65883
65903
  };
65884
65904
  const renderMessages = () => {
@@ -113250,7 +113270,12 @@
113250
113270
  type: Number,
113251
113271
  default: 0
113252
113272
  },
113273
+ topDistance: {
113274
+ type: Number,
113275
+ default: 0
113276
+ },
113253
113277
  onLoad: Function,
113278
+ onLoadTop: Function,
113254
113279
  scrollbarProps: Object
113255
113280
  };
113256
113281
  var InfiniteScroll = vue.defineComponent({
@@ -113258,7 +113283,8 @@
113258
113283
  props: infiniteScrollProps,
113259
113284
  setup(props) {
113260
113285
  const scrollbarInstRef = vue.ref(null);
113261
- let loading = false;
113286
+ let loadingBottom = false;
113287
+ let loadingTop = false;
113262
113288
  const handleCheckBottom = async () => {
113263
113289
  const { value: scrollbarInst } = scrollbarInstRef;
113264
113290
  if (scrollbarInst) {
@@ -113268,24 +113294,56 @@
113268
113294
  const scrollTop = containerRef?.scrollTop;
113269
113295
  if (containerRef && scrollHeight !== void 0 && clientHeight !== void 0 && scrollTop !== void 0) {
113270
113296
  if (scrollTop + clientHeight >= scrollHeight - props.distance) {
113271
- loading = true;
113297
+ loadingBottom = true;
113272
113298
  try {
113273
113299
  await props.onLoad?.();
113274
113300
  } catch {
113275
113301
  }
113276
- loading = false;
113302
+ loadingBottom = false;
113303
+ }
113304
+ }
113305
+ }
113306
+ };
113307
+ const handleCheckTop = async () => {
113308
+ const { value: scrollbarInst } = scrollbarInstRef;
113309
+ if (scrollbarInst) {
113310
+ const { containerRef } = scrollbarInst;
113311
+ const scrollTop = containerRef?.scrollTop;
113312
+ if (containerRef && scrollTop !== void 0) {
113313
+ if (scrollTop <= props.topDistance) {
113314
+ loadingTop = true;
113315
+ const oldScrollHeight = containerRef.scrollHeight;
113316
+ const oldScrollTop = containerRef.scrollTop;
113317
+ try {
113318
+ await props.onLoadTop?.();
113319
+ await vue.nextTick();
113320
+ const newScrollHeight = containerRef.scrollHeight;
113321
+ const heightDiff = newScrollHeight - oldScrollHeight;
113322
+ if (heightDiff > 0) {
113323
+ containerRef.scrollTop = oldScrollTop + heightDiff;
113324
+ }
113325
+ } catch {
113326
+ }
113327
+ loadingTop = false;
113277
113328
  }
113278
113329
  }
113279
113330
  }
113280
113331
  };
113281
113332
  const handleScroll = () => {
113282
- if (loading) return;
113283
- void handleCheckBottom();
113333
+ if (!loadingBottom) {
113334
+ void handleCheckBottom();
113335
+ }
113336
+ if (!loadingTop) {
113337
+ void handleCheckTop();
113338
+ }
113284
113339
  };
113285
113340
  const handleWheel = (e) => {
113286
- if (e.deltaY <= 0) return;
113287
- if (loading) return;
113288
- void handleCheckBottom();
113341
+ if (e.deltaY > 0 && !loadingBottom) {
113342
+ void handleCheckBottom();
113343
+ }
113344
+ if (e.deltaY < 0 && !loadingTop) {
113345
+ void handleCheckTop();
113346
+ }
113289
113347
  };
113290
113348
  return {
113291
113349
  scrollbarInstRef,
@@ -135129,7 +135187,7 @@
135129
135187
  watermarkProps: watermarkProps
135130
135188
  });
135131
135189
 
135132
- var version = "1.10.0";
135190
+ var version = "1.10.1";
135133
135191
 
135134
135192
  function create({
135135
135193
  componentPrefix = "U",