@uzum-tech/ui 1.10.0 → 1.11.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.
Files changed (91) hide show
  1. package/dist/index.js +1269 -207
  2. package/dist/index.prod.js +3 -3
  3. package/es/_internal/index.d.ts +2 -0
  4. package/es/_internal/index.js +1 -0
  5. package/es/_internal/safe-top-scrollbar/index.d.ts +2 -0
  6. package/es/_internal/safe-top-scrollbar/index.js +1 -0
  7. package/es/_internal/safe-top-scrollbar/src/SafeTopScrollbar.d.ts +356 -0
  8. package/es/_internal/safe-top-scrollbar/src/SafeTopScrollbar.js +708 -0
  9. package/es/_internal/safe-top-scrollbar/src/styles/index.cssr.d.ts +2 -0
  10. package/es/_internal/safe-top-scrollbar/src/styles/index.cssr.js +80 -0
  11. package/es/_internal/safe-top-scrollbar/src/styles/rtl.cssr.d.ts +2 -0
  12. package/es/_internal/safe-top-scrollbar/src/styles/rtl.cssr.js +10 -0
  13. package/es/_internal/safe-top-scrollbar/styles/common.d.ts +7 -0
  14. package/es/_internal/safe-top-scrollbar/styles/common.js +7 -0
  15. package/es/_internal/safe-top-scrollbar/styles/dark.d.ts +3 -0
  16. package/es/_internal/safe-top-scrollbar/styles/dark.js +8 -0
  17. package/es/_internal/safe-top-scrollbar/styles/index.d.ts +4 -0
  18. package/es/_internal/safe-top-scrollbar/styles/index.js +3 -0
  19. package/es/_internal/safe-top-scrollbar/styles/light.d.ts +18 -0
  20. package/es/_internal/safe-top-scrollbar/styles/light.js +12 -0
  21. package/es/_internal/safe-top-scrollbar/styles/rtl.d.ts +3 -0
  22. package/es/_internal/safe-top-scrollbar/styles/rtl.js +6 -0
  23. package/es/chat/src/Chat.d.ts +14 -1
  24. package/es/chat/src/Chat.js +5 -0
  25. package/es/chat/src/ChatListItems.js +16 -1
  26. package/es/chat/src/ChatParts/ChatAttachment.js +31 -3
  27. package/es/chat/src/ChatParts/MainArea.js +68 -62
  28. package/es/chat/src/interface.d.ts +6 -2
  29. package/es/components.d.ts +1 -0
  30. package/es/components.js +1 -0
  31. package/es/config-provider/src/internal-interface.d.ts +2 -0
  32. package/es/drawer/src/Drawer.d.ts +18 -0
  33. package/es/drawer/src/Drawer.js +28 -26
  34. package/es/drawer/src/DrawerBodyWrapper.d.ts +8 -0
  35. package/es/drawer/src/DrawerBodyWrapper.js +36 -8
  36. package/es/infinite-scroll/src/InfiniteScroll.d.ts +16 -0
  37. package/es/infinite-scroll/src/InfiniteScroll.js +48 -12
  38. package/es/safe-top-scrollbar/index.d.ts +2 -0
  39. package/es/safe-top-scrollbar/index.js +1 -0
  40. package/es/safe-top-scrollbar/src/SafeTopScrollbar.d.ts +177 -0
  41. package/es/safe-top-scrollbar/src/SafeTopScrollbar.js +38 -0
  42. package/es/themes/dark.js +2 -0
  43. package/es/themes/light.js +2 -0
  44. package/es/version.d.ts +1 -1
  45. package/es/version.js +1 -1
  46. package/lib/_internal/index.d.ts +2 -0
  47. package/lib/_internal/index.js +4 -1
  48. package/lib/_internal/safe-top-scrollbar/index.d.ts +2 -0
  49. package/lib/_internal/safe-top-scrollbar/index.js +9 -0
  50. package/lib/_internal/safe-top-scrollbar/src/SafeTopScrollbar.d.ts +356 -0
  51. package/lib/_internal/safe-top-scrollbar/src/SafeTopScrollbar.js +714 -0
  52. package/lib/_internal/safe-top-scrollbar/src/styles/index.cssr.d.ts +2 -0
  53. package/lib/_internal/safe-top-scrollbar/src/styles/index.cssr.js +85 -0
  54. package/lib/_internal/safe-top-scrollbar/src/styles/rtl.cssr.d.ts +2 -0
  55. package/lib/_internal/safe-top-scrollbar/src/styles/rtl.cssr.js +15 -0
  56. package/lib/_internal/safe-top-scrollbar/styles/common.d.ts +7 -0
  57. package/lib/_internal/safe-top-scrollbar/styles/common.js +10 -0
  58. package/lib/_internal/safe-top-scrollbar/styles/dark.d.ts +3 -0
  59. package/lib/_internal/safe-top-scrollbar/styles/dark.js +10 -0
  60. package/lib/_internal/safe-top-scrollbar/styles/index.d.ts +4 -0
  61. package/lib/_internal/safe-top-scrollbar/styles/index.js +12 -0
  62. package/lib/_internal/safe-top-scrollbar/styles/light.d.ts +18 -0
  63. package/lib/_internal/safe-top-scrollbar/styles/light.js +16 -0
  64. package/lib/_internal/safe-top-scrollbar/styles/rtl.d.ts +3 -0
  65. package/lib/_internal/safe-top-scrollbar/styles/rtl.js +12 -0
  66. package/lib/chat/src/Chat.d.ts +14 -1
  67. package/lib/chat/src/Chat.js +5 -0
  68. package/lib/chat/src/ChatListItems.js +16 -1
  69. package/lib/chat/src/ChatParts/ChatAttachment.js +30 -2
  70. package/lib/chat/src/ChatParts/MainArea.js +68 -62
  71. package/lib/chat/src/interface.d.ts +6 -2
  72. package/lib/components.d.ts +1 -0
  73. package/lib/components.js +1 -0
  74. package/lib/config-provider/src/internal-interface.d.ts +2 -0
  75. package/lib/drawer/src/Drawer.d.ts +18 -0
  76. package/lib/drawer/src/Drawer.js +28 -26
  77. package/lib/drawer/src/DrawerBodyWrapper.d.ts +8 -0
  78. package/lib/drawer/src/DrawerBodyWrapper.js +36 -8
  79. package/lib/infinite-scroll/src/InfiniteScroll.d.ts +16 -0
  80. package/lib/infinite-scroll/src/InfiniteScroll.js +47 -11
  81. package/lib/safe-top-scrollbar/index.d.ts +2 -0
  82. package/lib/safe-top-scrollbar/index.js +9 -0
  83. package/lib/safe-top-scrollbar/src/SafeTopScrollbar.d.ts +177 -0
  84. package/lib/safe-top-scrollbar/src/SafeTopScrollbar.js +41 -0
  85. package/lib/themes/dark.js +5 -0
  86. package/lib/themes/light.js +5 -0
  87. package/lib/version.d.ts +1 -1
  88. package/lib/version.js +1 -1
  89. package/package.json +6 -6
  90. package/volar.d.ts +1 -0
  91. package/web-types.json +67 -2
package/es/components.js CHANGED
@@ -69,6 +69,7 @@ export * from './radio';
69
69
  export * from './rate';
70
70
  export * from './result';
71
71
  export * from './scrollbar';
72
+ export * from './safe-top-scrollbar';
72
73
  export * from './select';
73
74
  export * from './skeleton';
74
75
  export * from './slider';
@@ -104,6 +104,7 @@ import { ActionCardTheme } from '../../action-card';
104
104
  import { ChatTheme } from '../../chat/styles';
105
105
  import { ModalFullscreenTheme } from '../../modal-fullscreen/styles';
106
106
  import { CropTheme } from '../../crop/styles';
107
+ import { SafeTopScrollbarTheme } from '../../_internal/safe-top-scrollbar/styles';
107
108
  export interface GlobalThemeWithoutCommon {
108
109
  Alert?: AlertTheme;
109
110
  Anchor?: AnchorTheme;
@@ -165,6 +166,7 @@ export interface GlobalThemeWithoutCommon {
165
166
  Rate?: RateTheme;
166
167
  Result?: ResultTheme;
167
168
  Scrollbar?: ScrollbarTheme;
169
+ SafeTopScrollbar?: SafeTopScrollbarTheme;
168
170
  Select?: SelectTheme;
169
171
  Skeleton?: SkeletonTheme;
170
172
  Slider?: SliderTheme;
@@ -65,6 +65,12 @@ export declare const drawerProps: {
65
65
  readonly minHeight: NumberConstructor;
66
66
  readonly resizable: BooleanConstructor;
67
67
  readonly fullscreen: BooleanConstructor;
68
+ readonly defaultWidth: {
69
+ readonly type: PropType<string | number>;
70
+ };
71
+ readonly defaultHeight: {
72
+ readonly type: PropType<string | number>;
73
+ };
68
74
  readonly onUpdateWidth: PropType<MaybeArray<(value: number) => void>>;
69
75
  readonly onUpdateHeight: PropType<MaybeArray<(value: number) => void>>;
70
76
  readonly 'onUpdate:width': PropType<MaybeArray<(value: number) => void>>;
@@ -282,6 +288,12 @@ declare const _default: import("vue").DefineComponent<{
282
288
  readonly minHeight: NumberConstructor;
283
289
  readonly resizable: BooleanConstructor;
284
290
  readonly fullscreen: BooleanConstructor;
291
+ readonly defaultWidth: {
292
+ readonly type: PropType<string | number>;
293
+ };
294
+ readonly defaultHeight: {
295
+ readonly type: PropType<string | number>;
296
+ };
285
297
  readonly onUpdateWidth: PropType<MaybeArray<(value: number) => void>>;
286
298
  readonly onUpdateHeight: PropType<MaybeArray<(value: number) => void>>;
287
299
  readonly 'onUpdate:width': PropType<MaybeArray<(value: number) => void>>;
@@ -597,6 +609,12 @@ declare const _default: import("vue").DefineComponent<{
597
609
  readonly minHeight: NumberConstructor;
598
610
  readonly resizable: BooleanConstructor;
599
611
  readonly fullscreen: BooleanConstructor;
612
+ readonly defaultWidth: {
613
+ readonly type: PropType<string | number>;
614
+ };
615
+ readonly defaultHeight: {
616
+ readonly type: PropType<string | number>;
617
+ };
600
618
  readonly onUpdateWidth: PropType<MaybeArray<(value: number) => void>>;
601
619
  readonly onUpdateHeight: PropType<MaybeArray<(value: number) => void>>;
602
620
  readonly 'onUpdate:width': PropType<MaybeArray<(value: number) => void>>;
@@ -51,7 +51,11 @@ export const drawerProps = Object.assign(Object.assign({}, useTheme.props), { sh
51
51
  }, blockScroll: {
52
52
  type: Boolean,
53
53
  default: true
54
- }, maxWidth: Number, maxHeight: Number, minWidth: Number, minHeight: Number, resizable: Boolean, fullscreen: Boolean, onUpdateWidth: [Function, Array], onUpdateHeight: [Function, Array], 'onUpdate:width': [Function, Array], 'onUpdate:height': [Function, Array], 'onUpdate:show': [Function, Array], onUpdateShow: [Function, Array], onAfterEnter: Function, onAfterLeave: Function,
54
+ }, maxWidth: Number, maxHeight: Number, minWidth: Number, minHeight: Number, resizable: Boolean, fullscreen: Boolean, defaultWidth: {
55
+ type: [Number, String]
56
+ }, defaultHeight: {
57
+ type: [Number, String]
58
+ }, onUpdateWidth: [Function, Array], onUpdateHeight: [Function, Array], 'onUpdate:width': [Function, Array], 'onUpdate:height': [Function, Array], 'onUpdate:show': [Function, Array], onUpdateShow: [Function, Array], onAfterEnter: Function, onAfterLeave: Function,
55
59
  /** @deprecated */
56
60
  drawerStyle: [String, Object],
57
61
  /** @deprecated */
@@ -89,8 +93,8 @@ export default defineComponent({
89
93
  const { mergedClsPrefixRef, namespaceRef, inlineThemeDisabled } = useConfig(props);
90
94
  const isMountedRef = useIsMounted();
91
95
  const themeRef = useTheme('Drawer', '-drawer', style, drawerLight, props, mergedClsPrefixRef);
92
- const uncontrolledWidthRef = ref(sizesWidth[props.size]);
93
- const uncontrolledHeightRef = ref(sizesHeight[props.size]);
96
+ const uncontrolledWidthRef = ref(props.defaultWidth || sizesWidth[props.size]);
97
+ const uncontrolledHeightRef = ref(props.defaultHeight || sizesHeight[props.size]);
94
98
  const mergedWidthRef = useMergedState(toRef(props, 'width'), uncontrolledWidthRef);
95
99
  const mergedHeightRef = useMergedState(toRef(props, 'height'), uncontrolledHeightRef);
96
100
  const styleWidthRef = computed(() => {
@@ -109,31 +113,29 @@ export default defineComponent({
109
113
  return '';
110
114
  return formatLength(mergedHeightRef.value);
111
115
  });
112
- const doUpdate = (isHeight, value) => {
113
- let { onUpdateWidth: onUpdate, 'onUpdate:width': _onUpdate, maxWidth: max, minWidth: min } = props;
114
- let _ref = uncontrolledWidthRef;
115
- if (isHeight) {
116
- onUpdate = props.onUpdateHeight;
117
- _onUpdate = props['onUpdate:height'];
118
- max = props.maxHeight;
119
- min = props.minHeight;
120
- _ref = uncontrolledHeightRef;
116
+ const doUpdateWidth = (value) => {
117
+ const { onUpdateWidth, 'onUpdate:width': _onUpdateWidth } = props;
118
+ if (onUpdateWidth) {
119
+ call(onUpdateWidth, value);
121
120
  }
122
- if (max && value > max)
123
- value = max;
124
- if (min && value < min)
125
- value = min;
126
- if (onUpdate)
127
- call(onUpdate, value);
128
- if (_onUpdate)
129
- call(_onUpdate, value);
130
- _ref.value = value;
121
+ if (_onUpdateWidth) {
122
+ call(_onUpdateWidth, value);
123
+ }
124
+ uncontrolledWidthRef.value = value;
125
+ };
126
+ const doUpdateHeight = (value) => {
127
+ const { onUpdateHeight, 'onUpdate:width': _onUpdateHeight } = props;
128
+ if (onUpdateHeight) {
129
+ call(onUpdateHeight, value);
130
+ }
131
+ if (_onUpdateHeight) {
132
+ call(_onUpdateHeight, value);
133
+ }
134
+ uncontrolledHeightRef.value = value;
131
135
  };
132
- const doUpdateWidth = doUpdate.bind(null, false);
133
- const doUpdateHeight = doUpdate.bind(null, true);
134
136
  watchEffect(() => {
135
- doUpdateWidth(sizesWidth[props.size]);
136
- doUpdateHeight(sizesHeight[props.size]);
137
+ doUpdateWidth(Number(props.defaultWidth || sizesWidth[props.size]));
138
+ doUpdateHeight(Number(props.defaultHeight || sizesHeight[props.size]));
137
139
  });
138
140
  const mergedBodyStyleRef = computed(() => {
139
141
  return [
@@ -262,7 +264,7 @@ export default defineComponent({
262
264
  `${mergedClsPrefix}-drawer-mask--invisible`
263
265
  ], onClick: this.handleMaskClick })) : null
264
266
  })) : null,
265
- h(UDrawerBodyWrapper, Object.assign({}, this.$attrs, { class: [this.drawerClass, this.$attrs.class], style: [this.mergedBodyStyle, this.$attrs.style], blockScroll: this.blockScroll, contentStyle: this.contentStyle, placement: this.placement, rounded: this.rounded, scrollbarProps: this.scrollbarProps, show: this.show, displayDirective: this.displayDirective, nativeScrollbar: this.nativeScrollbar, onAfterEnter: this.onAfterEnter, onAfterLeave: this.onAfterLeave, trapFocus: this.trapFocus, autoFocus: this.autoFocus, resizable: this.resizable, showMask: this.showMask, onEsc: this.handleEsc, onClickoutside: this.handleMaskClick }), this.$slots)), [[zindexable, { zIndex: this.zIndex, enabled: this.show }]]);
267
+ h(UDrawerBodyWrapper, Object.assign({}, this.$attrs, { class: [this.drawerClass, this.$attrs.class], style: [this.mergedBodyStyle, this.$attrs.style], blockScroll: this.blockScroll, contentStyle: this.contentStyle, placement: this.placement, rounded: this.rounded, scrollbarProps: this.scrollbarProps, show: this.show, displayDirective: this.displayDirective, nativeScrollbar: this.nativeScrollbar, onAfterEnter: this.onAfterEnter, onAfterLeave: this.onAfterLeave, trapFocus: this.trapFocus, autoFocus: this.autoFocus, resizable: this.resizable, maxHeight: this.maxHeight, minHeight: this.minHeight, maxWidth: this.maxWidth, minWidth: this.minWidth, showMask: this.showMask, onEsc: this.handleEsc, onClickoutside: this.handleMaskClick }), this.$slots)), [[zindexable, { zIndex: this.zIndex, enabled: this.show }]]);
266
268
  }
267
269
  }));
268
270
  }
@@ -37,6 +37,10 @@ declare const _default: import("vue").DefineComponent<{
37
37
  type: PropType<boolean | "transparent">;
38
38
  required: true;
39
39
  };
40
+ maxWidth: NumberConstructor;
41
+ maxHeight: NumberConstructor;
42
+ minWidth: NumberConstructor;
43
+ minHeight: NumberConstructor;
40
44
  resizable: BooleanConstructor;
41
45
  onClickoutside: PropType<(e: MouseEvent) => void>;
42
46
  onAfterLeave: PropType<() => void>;
@@ -148,6 +152,10 @@ declare const _default: import("vue").DefineComponent<{
148
152
  type: PropType<boolean | "transparent">;
149
153
  required: true;
150
154
  };
155
+ maxWidth: NumberConstructor;
156
+ maxHeight: NumberConstructor;
157
+ minWidth: NumberConstructor;
158
+ minHeight: NumberConstructor;
151
159
  resizable: BooleanConstructor;
152
160
  onClickoutside: PropType<(e: MouseEvent) => void>;
153
161
  onAfterLeave: PropType<() => void>;
@@ -46,6 +46,10 @@ export default defineComponent({
46
46
  type: [Boolean, String],
47
47
  required: true
48
48
  },
49
+ maxWidth: Number,
50
+ maxHeight: Number,
51
+ minWidth: Number,
52
+ minHeight: Number,
49
53
  resizable: Boolean,
50
54
  onClickoutside: Function,
51
55
  onAfterLeave: Function,
@@ -72,9 +76,9 @@ export default defineComponent({
72
76
  startPosition = isVertical.value ? e.clientY : e.clientX;
73
77
  memoizedBodyStyleCursor = document.body.style.cursor;
74
78
  document.body.style.cursor = isVertical.value ? 'ns-resize' : 'ew-resize';
75
- window.addEventListener('mousemove', handleBodyMousemove);
76
- window.addEventListener('mouseleave', handleBodyMouseleave);
77
- window.addEventListener('mouseup', handleBodyMouseup);
79
+ document.body.addEventListener('mousemove', handleBodyMousemove);
80
+ document.body.addEventListener('mouseleave', handleBodyMouseleave);
81
+ document.body.addEventListener('mouseup', handleBodyMouseup);
78
82
  };
79
83
  const handleMouseenterResizeTrigger = () => {
80
84
  if (hoverTimerId !== null) {
@@ -98,13 +102,36 @@ export default defineComponent({
98
102
  isHoverOnResizeTriggerRef.value = false;
99
103
  };
100
104
  const { doUpdateHeight, doUpdateWidth } = UDrawer;
101
- const handleBodyMousemove = (e) => {
105
+ const regulateWidth = (size) => {
106
+ const { maxWidth } = props;
107
+ if (maxWidth && size > maxWidth) {
108
+ return maxWidth;
109
+ }
110
+ const { minWidth } = props;
111
+ if (minWidth && size < minWidth) {
112
+ return minWidth;
113
+ }
114
+ return size;
115
+ };
116
+ const regulateHeight = (size) => {
117
+ const { maxHeight } = props;
118
+ if (maxHeight && size > maxHeight) {
119
+ return maxHeight;
120
+ }
121
+ const { minHeight } = props;
122
+ if (minHeight && size < minHeight) {
123
+ return minHeight;
124
+ }
125
+ return size;
126
+ };
127
+ function handleBodyMousemove(e) {
102
128
  var _a, _b;
103
129
  if (isDraggingRef.value) {
104
130
  if (isVertical.value) {
105
131
  let height = ((_a = bodyRef.value) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
106
132
  const increment = startPosition - e.clientY;
107
133
  height += props.placement === 'bottom' ? increment : -increment;
134
+ height = regulateHeight(height);
108
135
  doUpdateHeight(height);
109
136
  startPosition = e.clientY;
110
137
  }
@@ -112,19 +139,20 @@ export default defineComponent({
112
139
  let width = ((_b = bodyRef.value) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0;
113
140
  const increment = startPosition - e.clientX;
114
141
  width += props.placement === 'right' ? increment : -increment;
142
+ width = regulateWidth(width);
115
143
  doUpdateWidth(width);
116
144
  startPosition = e.clientX;
117
145
  }
118
146
  }
119
- };
147
+ }
120
148
  const handleBodyMouseup = () => {
121
149
  if (isDraggingRef.value) {
122
150
  startPosition = 0;
123
151
  isDraggingRef.value = false;
124
152
  document.body.style.cursor = memoizedBodyStyleCursor;
125
- window.removeEventListener('mousemove', handleBodyMousemove);
126
- window.removeEventListener('mouseup', handleBodyMouseup);
127
- window.removeEventListener('mouseleave', handleBodyMouseleave);
153
+ document.body.removeEventListener('mousemove', handleBodyMousemove);
154
+ document.body.removeEventListener('mouseup', handleBodyMouseup);
155
+ document.body.removeEventListener('mouseleave', handleBodyMouseleave);
128
156
  }
129
157
  };
130
158
  const handleBodyMouseleave = handleBodyMouseup;
@@ -6,7 +6,12 @@ export declare const infiniteScrollProps: {
6
6
  readonly type: NumberConstructor;
7
7
  readonly default: 0;
8
8
  };
9
+ readonly topDistance: {
10
+ readonly type: NumberConstructor;
11
+ readonly default: 0;
12
+ };
9
13
  readonly onLoad: PropType<() => Promise<void> | void>;
14
+ readonly onLoadTop: PropType<() => Promise<void> | void>;
10
15
  readonly scrollbarProps: PropType<ScrollbarProps>;
11
16
  };
12
17
  export type InfiniteScrollProps = ExtractPublicPropTypes<typeof infiniteScrollProps>;
@@ -15,7 +20,12 @@ declare const _default: import("vue").DefineComponent<{
15
20
  readonly type: NumberConstructor;
16
21
  readonly default: 0;
17
22
  };
23
+ readonly topDistance: {
24
+ readonly type: NumberConstructor;
25
+ readonly default: 0;
26
+ };
18
27
  readonly onLoad: PropType<() => Promise<void> | void>;
28
+ readonly onLoadTop: PropType<() => Promise<void> | void>;
19
29
  readonly scrollbarProps: PropType<ScrollbarProps>;
20
30
  }, {
21
31
  scrollbarInstRef: import("vue").Ref<{
@@ -37,9 +47,15 @@ declare const _default: import("vue").DefineComponent<{
37
47
  readonly type: NumberConstructor;
38
48
  readonly default: 0;
39
49
  };
50
+ readonly topDistance: {
51
+ readonly type: NumberConstructor;
52
+ readonly default: 0;
53
+ };
40
54
  readonly onLoad: PropType<() => Promise<void> | void>;
55
+ readonly onLoadTop: PropType<() => Promise<void> | void>;
41
56
  readonly scrollbarProps: PropType<ScrollbarProps>;
42
57
  }>>, {
43
58
  readonly distance: number;
59
+ readonly topDistance: number;
44
60
  }, {}>;
45
61
  export default _default;
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { defineComponent, h, ref } from 'vue';
10
+ import { defineComponent, h, ref, nextTick } from 'vue';
11
11
  import { UxScrollbar } from '../../_internal';
12
12
  import { resolveSlot } from '../../_utils';
13
13
  export const infiniteScrollProps = {
@@ -15,7 +15,12 @@ export const infiniteScrollProps = {
15
15
  type: Number,
16
16
  default: 0
17
17
  },
18
+ topDistance: {
19
+ type: Number,
20
+ default: 0
21
+ },
18
22
  onLoad: Function,
23
+ onLoadTop: Function,
19
24
  scrollbarProps: Object
20
25
  };
21
26
  export default defineComponent({
@@ -23,7 +28,8 @@ export default defineComponent({
23
28
  props: infiniteScrollProps,
24
29
  setup(props) {
25
30
  const scrollbarInstRef = ref(null);
26
- let loading = false;
31
+ let loadingBottom = false;
32
+ let loadingTop = false;
27
33
  const handleCheckBottom = () => __awaiter(this, void 0, void 0, function* () {
28
34
  var _a;
29
35
  const { value: scrollbarInst } = scrollbarInstRef;
@@ -37,27 +43,57 @@ export default defineComponent({
37
43
  clientHeight !== undefined &&
38
44
  scrollTop !== undefined) {
39
45
  if (scrollTop + clientHeight >= scrollHeight - props.distance) {
40
- loading = true;
46
+ loadingBottom = true;
41
47
  try {
42
48
  yield ((_a = props.onLoad) === null || _a === void 0 ? void 0 : _a.call(props));
43
49
  }
44
50
  catch (_b) { }
45
- loading = false;
51
+ loadingBottom = false;
52
+ }
53
+ }
54
+ }
55
+ });
56
+ const handleCheckTop = () => __awaiter(this, void 0, void 0, function* () {
57
+ var _a;
58
+ const { value: scrollbarInst } = scrollbarInstRef;
59
+ if (scrollbarInst) {
60
+ const { containerRef } = scrollbarInst;
61
+ const scrollTop = containerRef === null || containerRef === void 0 ? void 0 : containerRef.scrollTop;
62
+ if (containerRef && scrollTop !== undefined) {
63
+ if (scrollTop <= props.topDistance) {
64
+ loadingTop = true;
65
+ const oldScrollHeight = containerRef.scrollHeight;
66
+ const oldScrollTop = containerRef.scrollTop;
67
+ try {
68
+ yield ((_a = props.onLoadTop) === null || _a === void 0 ? void 0 : _a.call(props));
69
+ yield nextTick();
70
+ const newScrollHeight = containerRef.scrollHeight;
71
+ const heightDiff = newScrollHeight - oldScrollHeight;
72
+ if (heightDiff > 0) {
73
+ containerRef.scrollTop = oldScrollTop + heightDiff;
74
+ }
75
+ }
76
+ catch (_b) { }
77
+ loadingTop = false;
46
78
  }
47
79
  }
48
80
  }
49
81
  });
50
82
  const handleScroll = () => {
51
- if (loading)
52
- return;
53
- void handleCheckBottom();
83
+ if (!loadingBottom) {
84
+ void handleCheckBottom();
85
+ }
86
+ if (!loadingTop) {
87
+ void handleCheckTop();
88
+ }
54
89
  };
55
90
  const handleWheel = (e) => {
56
- if (e.deltaY <= 0)
57
- return;
58
- if (loading)
59
- return;
60
- void handleCheckBottom();
91
+ if (e.deltaY > 0 && !loadingBottom) {
92
+ void handleCheckBottom();
93
+ }
94
+ if (e.deltaY < 0 && !loadingTop) {
95
+ void handleCheckTop();
96
+ }
61
97
  };
62
98
  return {
63
99
  scrollbarInstRef,
@@ -0,0 +1,2 @@
1
+ export { default as USafeTopScrollbar, safeTopScrollbarProps } from './src/SafeTopScrollbar';
2
+ export type { SafeTopScrollbarInst, SafeTopScrollbarProps } from './src/SafeTopScrollbar';
@@ -0,0 +1 @@
1
+ export { default as USafeTopScrollbar, safeTopScrollbarProps } from './src/SafeTopScrollbar';
@@ -0,0 +1,177 @@
1
+ import { type PropType } from 'vue';
2
+ import type { ExtractPublicPropTypes } from '../../_utils';
3
+ export interface ScrollTo {
4
+ (x: number, y: number): void;
5
+ (options: {
6
+ left?: number;
7
+ top?: number;
8
+ behavior?: ScrollBehavior;
9
+ }): void;
10
+ }
11
+ export type ScrollBy = ScrollTo;
12
+ export interface SafeTopScrollbarInst {
13
+ scrollTo: ScrollTo;
14
+ scrollBy: ScrollBy;
15
+ getScrollState: () => {
16
+ scrollHeight: number;
17
+ scrollTop: number;
18
+ clientHeight: number;
19
+ };
20
+ adjustScrollTop: (heightDiff: number) => void;
21
+ }
22
+ export declare const safeTopScrollbarProps: {
23
+ readonly trigger: PropType<"none" | "hover">;
24
+ readonly xScrollable: BooleanConstructor;
25
+ readonly onScroll: PropType<(e: Event) => void>;
26
+ readonly size: NumberConstructor;
27
+ readonly theme: PropType<import("../../_mixins").Theme<"SafeTopScrollbar", {
28
+ height: string;
29
+ width: string;
30
+ borderRadius: string;
31
+ color: string;
32
+ colorHover: string;
33
+ railInsetHorizontalBottom: string;
34
+ railInsetHorizontalTop: string;
35
+ railInsetVerticalRight: string;
36
+ railInsetVerticalLeft: string;
37
+ railColor: string;
38
+ }, any>>;
39
+ readonly themeOverrides: PropType<import("../../_mixins/use-theme").ExtractThemeOverrides<import("../../_mixins").Theme<"SafeTopScrollbar", {
40
+ height: string;
41
+ width: string;
42
+ borderRadius: string;
43
+ color: string;
44
+ colorHover: string;
45
+ railInsetHorizontalBottom: string;
46
+ railInsetHorizontalTop: string;
47
+ railInsetVerticalRight: string;
48
+ railInsetVerticalLeft: string;
49
+ railColor: string;
50
+ }, any>>>;
51
+ readonly builtinThemeOverrides: PropType<import("../../_mixins/use-theme").ExtractThemeOverrides<import("../../_mixins").Theme<"SafeTopScrollbar", {
52
+ height: string;
53
+ width: string;
54
+ borderRadius: string;
55
+ color: string;
56
+ colorHover: string;
57
+ railInsetHorizontalBottom: string;
58
+ railInsetHorizontalTop: string;
59
+ railInsetVerticalRight: string;
60
+ railInsetVerticalLeft: string;
61
+ railColor: string;
62
+ }, any>>>;
63
+ };
64
+ export type SafeTopScrollbarProps = ExtractPublicPropTypes<typeof safeTopScrollbarProps>;
65
+ declare const SafeTopScrollbar: import("vue").DefineComponent<{
66
+ readonly trigger: PropType<"none" | "hover">;
67
+ readonly xScrollable: BooleanConstructor;
68
+ readonly onScroll: PropType<(e: Event) => void>;
69
+ readonly size: NumberConstructor;
70
+ readonly theme: PropType<import("../../_mixins").Theme<"SafeTopScrollbar", {
71
+ height: string;
72
+ width: string;
73
+ borderRadius: string;
74
+ color: string;
75
+ colorHover: string;
76
+ railInsetHorizontalBottom: string;
77
+ railInsetHorizontalTop: string;
78
+ railInsetVerticalRight: string;
79
+ railInsetVerticalLeft: string;
80
+ railColor: string;
81
+ }, any>>;
82
+ readonly themeOverrides: PropType<import("../../_mixins/use-theme").ExtractThemeOverrides<import("../../_mixins").Theme<"SafeTopScrollbar", {
83
+ height: string;
84
+ width: string;
85
+ borderRadius: string;
86
+ color: string;
87
+ colorHover: string;
88
+ railInsetHorizontalBottom: string;
89
+ railInsetHorizontalTop: string;
90
+ railInsetVerticalRight: string;
91
+ railInsetVerticalLeft: string;
92
+ railColor: string;
93
+ }, any>>>;
94
+ readonly builtinThemeOverrides: PropType<import("../../_mixins/use-theme").ExtractThemeOverrides<import("../../_mixins").Theme<"SafeTopScrollbar", {
95
+ height: string;
96
+ width: string;
97
+ borderRadius: string;
98
+ color: string;
99
+ colorHover: string;
100
+ railInsetHorizontalBottom: string;
101
+ railInsetHorizontalTop: string;
102
+ railInsetVerticalRight: string;
103
+ railInsetVerticalLeft: string;
104
+ railColor: string;
105
+ }, any>>>;
106
+ }, {
107
+ scrollbarInstRef: import("vue").Ref<{
108
+ $el: HTMLElement;
109
+ containerRef: HTMLElement | null;
110
+ contentRef: HTMLElement | null;
111
+ containerScrollTop: number;
112
+ syncUnifiedContainer: () => void;
113
+ scrollTo: import("../../_internal/safe-top-scrollbar/src/SafeTopScrollbar").ScrollTo;
114
+ scrollBy: import("../../_internal/safe-top-scrollbar/src/SafeTopScrollbar").ScrollBy;
115
+ sync: () => void;
116
+ handleMouseEnterWrapper: () => void;
117
+ handleMouseLeaveWrapper: () => void;
118
+ getScrollState: () => {
119
+ scrollHeight: number;
120
+ scrollTop: number;
121
+ clientHeight: number;
122
+ };
123
+ adjustScrollTop: (heightDiff: number) => void;
124
+ } | null>;
125
+ scrollTo: ScrollTo;
126
+ scrollBy: ScrollBy;
127
+ getScrollState: () => {
128
+ scrollHeight: number;
129
+ scrollTop: number;
130
+ clientHeight: number;
131
+ };
132
+ adjustScrollTop: (heightDiff: number) => void;
133
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
134
+ readonly trigger: PropType<"none" | "hover">;
135
+ readonly xScrollable: BooleanConstructor;
136
+ readonly onScroll: PropType<(e: Event) => void>;
137
+ readonly size: NumberConstructor;
138
+ readonly theme: PropType<import("../../_mixins").Theme<"SafeTopScrollbar", {
139
+ height: string;
140
+ width: string;
141
+ borderRadius: string;
142
+ color: string;
143
+ colorHover: string;
144
+ railInsetHorizontalBottom: string;
145
+ railInsetHorizontalTop: string;
146
+ railInsetVerticalRight: string;
147
+ railInsetVerticalLeft: string;
148
+ railColor: string;
149
+ }, any>>;
150
+ readonly themeOverrides: PropType<import("../../_mixins/use-theme").ExtractThemeOverrides<import("../../_mixins").Theme<"SafeTopScrollbar", {
151
+ height: string;
152
+ width: string;
153
+ borderRadius: string;
154
+ color: string;
155
+ colorHover: string;
156
+ railInsetHorizontalBottom: string;
157
+ railInsetHorizontalTop: string;
158
+ railInsetVerticalRight: string;
159
+ railInsetVerticalLeft: string;
160
+ railColor: string;
161
+ }, any>>>;
162
+ readonly builtinThemeOverrides: PropType<import("../../_mixins/use-theme").ExtractThemeOverrides<import("../../_mixins").Theme<"SafeTopScrollbar", {
163
+ height: string;
164
+ width: string;
165
+ borderRadius: string;
166
+ color: string;
167
+ colorHover: string;
168
+ railInsetHorizontalBottom: string;
169
+ railInsetHorizontalTop: string;
170
+ railInsetVerticalRight: string;
171
+ railInsetVerticalLeft: string;
172
+ railColor: string;
173
+ }, any>>>;
174
+ }>>, {
175
+ readonly xScrollable: boolean;
176
+ }, {}>;
177
+ export default SafeTopScrollbar;
@@ -0,0 +1,38 @@
1
+ import { h, defineComponent, ref } from 'vue';
2
+ import { USafeTopScrollbar } from '../../_internal';
3
+ import { useTheme } from '../../_mixins';
4
+ export const safeTopScrollbarProps = Object.assign(Object.assign({}, useTheme.props), { trigger: String, xScrollable: Boolean, onScroll: Function, size: Number });
5
+ const SafeTopScrollbar = defineComponent({
6
+ name: 'SafeTopScrollbar',
7
+ props: safeTopScrollbarProps,
8
+ setup() {
9
+ const scrollbarInstRef = ref(null);
10
+ const exposedMethods = {
11
+ scrollTo: (...args) => {
12
+ var _a;
13
+ (_a = scrollbarInstRef.value) === null || _a === void 0 ? void 0 : _a.scrollTo(args[0], args[1]);
14
+ },
15
+ scrollBy: (...args) => {
16
+ var _a;
17
+ (_a = scrollbarInstRef.value) === null || _a === void 0 ? void 0 : _a.scrollBy(args[0], args[1]);
18
+ },
19
+ getScrollState: () => {
20
+ var _a;
21
+ return (((_a = scrollbarInstRef.value) === null || _a === void 0 ? void 0 : _a.getScrollState()) || {
22
+ scrollHeight: 0,
23
+ scrollTop: 0,
24
+ clientHeight: 0
25
+ });
26
+ },
27
+ adjustScrollTop: (heightDiff) => {
28
+ var _a;
29
+ (_a = scrollbarInstRef.value) === null || _a === void 0 ? void 0 : _a.adjustScrollTop(heightDiff);
30
+ }
31
+ };
32
+ return Object.assign(Object.assign({}, exposedMethods), { scrollbarInstRef });
33
+ },
34
+ render() {
35
+ return (h(USafeTopScrollbar, Object.assign({ ref: "scrollbarInstRef" }, this.$props), this.$slots));
36
+ }
37
+ });
38
+ export default SafeTopScrollbar;
package/es/themes/dark.js CHANGED
@@ -90,6 +90,7 @@ import { inputOtpDark } from '../styles';
90
90
  import { chatDark } from '../chat/styles';
91
91
  import { modalFullscreenDark } from '../modal-fullscreen/styles';
92
92
  import { cropDark } from '../crop/styles';
93
+ import safeTopScrollbarDark from '../_internal/safe-top-scrollbar/styles/dark';
93
94
  export const darkTheme = {
94
95
  name: 'dark',
95
96
  common: commonDark,
@@ -157,6 +158,7 @@ export const darkTheme = {
157
158
  Result: resultDark,
158
159
  Row: rowDark,
159
160
  Scrollbar: scrollbarDark,
161
+ SafeTopScrollbar: safeTopScrollbarDark,
160
162
  Select: selectDark,
161
163
  Skeleton: skeletonDark,
162
164
  Slider: sliderDark,
@@ -92,6 +92,7 @@ import { inputOtpLight } from '../input-otp/styles';
92
92
  import { chatLight } from '../chat/styles';
93
93
  import { modalFullscreenLight } from '../modal-fullscreen/styles';
94
94
  import { cropLight } from '../crop/styles';
95
+ import safeTopScrollbarLight from '../_internal/safe-top-scrollbar/styles/light';
95
96
  export const lightTheme = {
96
97
  name: 'light',
97
98
  common: commonLight,
@@ -159,6 +160,7 @@ export const lightTheme = {
159
160
  Row: rowLight,
160
161
  Result: resultLight,
161
162
  Scrollbar: scrollbarLight,
163
+ SafeTopScrollbar: safeTopScrollbarLight,
162
164
  Skeleton: skeletonLight,
163
165
  Select: selectLight,
164
166
  Slider: sliderLight,
package/es/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.10.0";
1
+ declare const _default: "1.11.0";
2
2
  export default _default;
package/es/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.10.0';
1
+ export default '1.11.0';