@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 +119 -61
- package/dist/index.prod.js +3 -3
- package/es/chat/src/ChatListItems.js +16 -1
- package/es/chat/src/ChatParts/MainArea.js +31 -21
- package/es/infinite-scroll/src/InfiniteScroll.d.ts +16 -0
- package/es/infinite-scroll/src/InfiniteScroll.js +48 -12
- package/es/version.d.ts +1 -1
- package/es/version.js +1 -1
- package/lib/chat/src/ChatListItems.js +16 -1
- package/lib/chat/src/ChatParts/MainArea.js +31 -21
- package/lib/infinite-scroll/src/InfiniteScroll.d.ts +16 -0
- package/lib/infinite-scroll/src/InfiniteScroll.js +47 -11
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +6 -6
- package/web-types.json +10 -1
|
@@ -90,11 +90,26 @@ export default defineComponent({
|
|
|
90
90
|
var _a;
|
|
91
91
|
(_a = props.onChatSelect) === null || _a === void 0 ? void 0 : _a.call(props, chatId);
|
|
92
92
|
};
|
|
93
|
+
const toKeyString = (value) => {
|
|
94
|
+
if (typeof value === 'symbol')
|
|
95
|
+
return value.toString();
|
|
96
|
+
if (typeof value === 'function') {
|
|
97
|
+
const result = value();
|
|
98
|
+
return typeof result === 'string' || typeof result === 'number'
|
|
99
|
+
? String(result)
|
|
100
|
+
: '';
|
|
101
|
+
}
|
|
102
|
+
return value != null ? String(value) : '';
|
|
103
|
+
};
|
|
93
104
|
const renderChatItem = (item) => {
|
|
94
105
|
var _a, _b;
|
|
95
106
|
const isSelected = props.selectedChatId === item.id;
|
|
96
107
|
const isTyping = (_b = (_a = props.typingChatIds) === null || _a === void 0 ? void 0 : _a.includes(item.id)) !== null && _b !== void 0 ? _b : false;
|
|
97
|
-
|
|
108
|
+
const { id, title, subtitle } = item;
|
|
109
|
+
const keyId = toKeyString(id);
|
|
110
|
+
const keyTitle = toKeyString(title);
|
|
111
|
+
const keySubtitle = toKeyString(subtitle);
|
|
112
|
+
return (h(UListItem, { key: `${keyId}-${keyTitle}-${keySubtitle}`, showIcon: false, onClick: () => {
|
|
98
113
|
handleChatSelect(item.id);
|
|
99
114
|
}, class: [
|
|
100
115
|
`${mergedClsPrefixRef.value}-chat-sidebar__item`,
|
|
@@ -153,22 +153,36 @@ export default defineComponent({
|
|
|
153
153
|
el.scrollTop = el.scrollHeight;
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
|
+
const toKeyString = (value) => {
|
|
157
|
+
if (typeof value === 'symbol')
|
|
158
|
+
return value.toString();
|
|
159
|
+
if (typeof value === 'function') {
|
|
160
|
+
const result = value();
|
|
161
|
+
return typeof result === 'string' || typeof result === 'number'
|
|
162
|
+
? String(result)
|
|
163
|
+
: '';
|
|
164
|
+
}
|
|
165
|
+
return value != null ? String(value) : '';
|
|
166
|
+
};
|
|
156
167
|
const renderHeader = () => {
|
|
157
168
|
return (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__header` },
|
|
158
169
|
h(UFlex, { justify: "space-between", align: "flex-start", wrap: false }, {
|
|
159
|
-
default: () =>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
h(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
default: () => {
|
|
171
|
+
const chat = selectedChatRef.value;
|
|
172
|
+
const keyId = toKeyString(chat === null || chat === void 0 ? void 0 : chat.id);
|
|
173
|
+
const keyTitle = toKeyString(chat === null || chat === void 0 ? void 0 : chat.title);
|
|
174
|
+
return (h(Fragment, null,
|
|
175
|
+
h(UText, { key: `${keyId}-${keyTitle}`, variant: "heading-s-bold", class: `${mergedClsPrefixRef.value}-chat-main__header-title`, theme: mergedThemeRef.value.peers.Typography, themeOverrides: mergedThemeRef.value.peerOverrides.Typography }, {
|
|
176
|
+
default: () => { var _a, _b; return (_b = (_a = selectedChatRef.value) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : ''; }
|
|
177
|
+
}),
|
|
178
|
+
h(UFlex, { align: "center", size: "small", class: `${mergedClsPrefixRef.value}-chat-main__header-actions` }, {
|
|
179
|
+
default: () => resolveSlot(slots.headerActions, () => {
|
|
180
|
+
const shareButtonProps = Object.assign(Object.assign({}, headerButtonPropsRef.value), headerShareButtonPropsRef.value);
|
|
181
|
+
const profileButtonProps = Object.assign(Object.assign({}, headerButtonPropsRef.value), headerProfileButtonPropsRef.value);
|
|
182
|
+
const closeButtonProps = Object.assign(Object.assign({}, headerButtonPropsRef.value), headerCloseButtonPropsRef.value);
|
|
183
|
+
const shareIconProps = Object.assign(Object.assign({}, headerIconPropsRef.value), headerShareIconPropsRef.value);
|
|
184
|
+
const profileIconProps = Object.assign(Object.assign({}, headerIconPropsRef.value), headerProfileIconPropsRef.value);
|
|
185
|
+
const buttons = [];
|
|
172
186
|
buttons.push(h(UTooltip, null, {
|
|
173
187
|
trigger: () => (h(UButton, Object.assign({ secondary: true, circle: true, size: "large" }, shareButtonProps, { theme: mergedThemeRef.value.peers.Button, themeOverrides: mergedThemeRef.value.peerOverrides
|
|
174
188
|
.Button, onClick: () => { var _a; return (_a = onChatShare === null || onChatShare === void 0 ? void 0 : onChatShare.value) === null || _a === void 0 ? void 0 : _a.call(onChatShare); } }), {
|
|
@@ -179,8 +193,6 @@ export default defineComponent({
|
|
|
179
193
|
})),
|
|
180
194
|
default: () => shareButtonTooltipRef.value
|
|
181
195
|
}));
|
|
182
|
-
}
|
|
183
|
-
if (profileButtonProps.disabled !== true) {
|
|
184
196
|
buttons.push(h(UTooltip, null, {
|
|
185
197
|
trigger: () => (h(UButton, Object.assign({ secondary: true, circle: true, size: "large" }, profileButtonProps, { theme: mergedThemeRef.value.peers.Button, themeOverrides: mergedThemeRef.value.peerOverrides
|
|
186
198
|
.Button, onClick: () => { var _a; return (_a = onUserProfile === null || onUserProfile === void 0 ? void 0 : onUserProfile.value) === null || _a === void 0 ? void 0 : _a.call(onUserProfile); } }), {
|
|
@@ -191,15 +203,13 @@ export default defineComponent({
|
|
|
191
203
|
})),
|
|
192
204
|
default: () => profileButtonTooltipRef.value
|
|
193
205
|
}));
|
|
194
|
-
}
|
|
195
|
-
if (closeButtonProps.disabled !== true) {
|
|
196
206
|
buttons.push(h(UButton, Object.assign({ type: "primary", size: "large", round: true }, closeButtonProps, { theme: mergedThemeRef.value.peers.Button, themeOverrides: mergedThemeRef.value.peerOverrides.Button, onClick: () => { var _a; return (_a = onChatClose === null || onChatClose === void 0 ? void 0 : onChatClose.value) === null || _a === void 0 ? void 0 : _a.call(onChatClose); } }), {
|
|
197
207
|
default: () => closeButtonTextRef.value
|
|
198
208
|
}));
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
})
|
|
202
|
-
|
|
209
|
+
return buttons;
|
|
210
|
+
})
|
|
211
|
+
})));
|
|
212
|
+
}
|
|
203
213
|
})));
|
|
204
214
|
};
|
|
205
215
|
const renderMessages = () => {
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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,
|
package/es/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.10.
|
|
1
|
+
declare const _default: "1.10.1";
|
|
2
2
|
export default _default;
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.10.
|
|
1
|
+
export default '1.10.1';
|
|
@@ -96,11 +96,26 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
96
96
|
var _a;
|
|
97
97
|
(_a = props.onChatSelect) === null || _a === void 0 ? void 0 : _a.call(props, chatId);
|
|
98
98
|
};
|
|
99
|
+
const toKeyString = (value) => {
|
|
100
|
+
if (typeof value === 'symbol')
|
|
101
|
+
return value.toString();
|
|
102
|
+
if (typeof value === 'function') {
|
|
103
|
+
const result = value();
|
|
104
|
+
return typeof result === 'string' || typeof result === 'number'
|
|
105
|
+
? String(result)
|
|
106
|
+
: '';
|
|
107
|
+
}
|
|
108
|
+
return value != null ? String(value) : '';
|
|
109
|
+
};
|
|
99
110
|
const renderChatItem = (item) => {
|
|
100
111
|
var _a, _b;
|
|
101
112
|
const isSelected = props.selectedChatId === item.id;
|
|
102
113
|
const isTyping = (_b = (_a = props.typingChatIds) === null || _a === void 0 ? void 0 : _a.includes(item.id)) !== null && _b !== void 0 ? _b : false;
|
|
103
|
-
|
|
114
|
+
const { id, title, subtitle } = item;
|
|
115
|
+
const keyId = toKeyString(id);
|
|
116
|
+
const keyTitle = toKeyString(title);
|
|
117
|
+
const keySubtitle = toKeyString(subtitle);
|
|
118
|
+
return ((0, vue_1.h)(list_1.UListItem, { key: `${keyId}-${keyTitle}-${keySubtitle}`, showIcon: false, onClick: () => {
|
|
104
119
|
handleChatSelect(item.id);
|
|
105
120
|
}, class: [
|
|
106
121
|
`${mergedClsPrefixRef.value}-chat-sidebar__item`,
|
|
@@ -158,22 +158,36 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
158
158
|
el.scrollTop = el.scrollHeight;
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
+
const toKeyString = (value) => {
|
|
162
|
+
if (typeof value === 'symbol')
|
|
163
|
+
return value.toString();
|
|
164
|
+
if (typeof value === 'function') {
|
|
165
|
+
const result = value();
|
|
166
|
+
return typeof result === 'string' || typeof result === 'number'
|
|
167
|
+
? String(result)
|
|
168
|
+
: '';
|
|
169
|
+
}
|
|
170
|
+
return value != null ? String(value) : '';
|
|
171
|
+
};
|
|
161
172
|
const renderHeader = () => {
|
|
162
173
|
return ((0, vue_1.h)("div", { class: `${mergedClsPrefixRef.value}-chat-main__header` },
|
|
163
174
|
(0, vue_1.h)(flex_1.UFlex, { justify: "space-between", align: "flex-start", wrap: false }, {
|
|
164
|
-
default: () =>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
(0, vue_1.h)(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
default: () => {
|
|
176
|
+
const chat = selectedChatRef.value;
|
|
177
|
+
const keyId = toKeyString(chat === null || chat === void 0 ? void 0 : chat.id);
|
|
178
|
+
const keyTitle = toKeyString(chat === null || chat === void 0 ? void 0 : chat.title);
|
|
179
|
+
return ((0, vue_1.h)(vue_1.Fragment, null,
|
|
180
|
+
(0, vue_1.h)(typography_1.UText, { key: `${keyId}-${keyTitle}`, variant: "heading-s-bold", class: `${mergedClsPrefixRef.value}-chat-main__header-title`, theme: mergedThemeRef.value.peers.Typography, themeOverrides: mergedThemeRef.value.peerOverrides.Typography }, {
|
|
181
|
+
default: () => { var _a, _b; return (_b = (_a = selectedChatRef.value) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : ''; }
|
|
182
|
+
}),
|
|
183
|
+
(0, vue_1.h)(flex_1.UFlex, { align: "center", size: "small", class: `${mergedClsPrefixRef.value}-chat-main__header-actions` }, {
|
|
184
|
+
default: () => (0, _utils_1.resolveSlot)(slots.headerActions, () => {
|
|
185
|
+
const shareButtonProps = Object.assign(Object.assign({}, headerButtonPropsRef.value), headerShareButtonPropsRef.value);
|
|
186
|
+
const profileButtonProps = Object.assign(Object.assign({}, headerButtonPropsRef.value), headerProfileButtonPropsRef.value);
|
|
187
|
+
const closeButtonProps = Object.assign(Object.assign({}, headerButtonPropsRef.value), headerCloseButtonPropsRef.value);
|
|
188
|
+
const shareIconProps = Object.assign(Object.assign({}, headerIconPropsRef.value), headerShareIconPropsRef.value);
|
|
189
|
+
const profileIconProps = Object.assign(Object.assign({}, headerIconPropsRef.value), headerProfileIconPropsRef.value);
|
|
190
|
+
const buttons = [];
|
|
177
191
|
buttons.push((0, vue_1.h)(tooltip_1.UTooltip, null, {
|
|
178
192
|
trigger: () => ((0, vue_1.h)(button_1.UButton, Object.assign({ secondary: true, circle: true, size: "large" }, shareButtonProps, { theme: mergedThemeRef.value.peers.Button, themeOverrides: mergedThemeRef.value.peerOverrides
|
|
179
193
|
.Button, onClick: () => { var _a; return (_a = onChatShare === null || onChatShare === void 0 ? void 0 : onChatShare.value) === null || _a === void 0 ? void 0 : _a.call(onChatShare); } }), {
|
|
@@ -184,8 +198,6 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
184
198
|
})),
|
|
185
199
|
default: () => shareButtonTooltipRef.value
|
|
186
200
|
}));
|
|
187
|
-
}
|
|
188
|
-
if (profileButtonProps.disabled !== true) {
|
|
189
201
|
buttons.push((0, vue_1.h)(tooltip_1.UTooltip, null, {
|
|
190
202
|
trigger: () => ((0, vue_1.h)(button_1.UButton, Object.assign({ secondary: true, circle: true, size: "large" }, profileButtonProps, { theme: mergedThemeRef.value.peers.Button, themeOverrides: mergedThemeRef.value.peerOverrides
|
|
191
203
|
.Button, onClick: () => { var _a; return (_a = onUserProfile === null || onUserProfile === void 0 ? void 0 : onUserProfile.value) === null || _a === void 0 ? void 0 : _a.call(onUserProfile); } }), {
|
|
@@ -196,15 +208,13 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
196
208
|
})),
|
|
197
209
|
default: () => profileButtonTooltipRef.value
|
|
198
210
|
}));
|
|
199
|
-
}
|
|
200
|
-
if (closeButtonProps.disabled !== true) {
|
|
201
211
|
buttons.push((0, vue_1.h)(button_1.UButton, Object.assign({ type: "primary", size: "large", round: true }, closeButtonProps, { theme: mergedThemeRef.value.peers.Button, themeOverrides: mergedThemeRef.value.peerOverrides.Button, onClick: () => { var _a; return (_a = onChatClose === null || onChatClose === void 0 ? void 0 : onChatClose.value) === null || _a === void 0 ? void 0 : _a.call(onChatClose); } }), {
|
|
202
212
|
default: () => closeButtonTextRef.value
|
|
203
213
|
}));
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
})
|
|
207
|
-
|
|
214
|
+
return buttons;
|
|
215
|
+
})
|
|
216
|
+
})));
|
|
217
|
+
}
|
|
208
218
|
})));
|
|
209
219
|
};
|
|
210
220
|
const renderMessages = () => {
|
|
@@ -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;
|
|
@@ -18,7 +18,12 @@ exports.infiniteScrollProps = {
|
|
|
18
18
|
type: Number,
|
|
19
19
|
default: 0
|
|
20
20
|
},
|
|
21
|
+
topDistance: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: 0
|
|
24
|
+
},
|
|
21
25
|
onLoad: Function,
|
|
26
|
+
onLoadTop: Function,
|
|
22
27
|
scrollbarProps: Object
|
|
23
28
|
};
|
|
24
29
|
exports.default = (0, vue_1.defineComponent)({
|
|
@@ -26,7 +31,8 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
26
31
|
props: exports.infiniteScrollProps,
|
|
27
32
|
setup(props) {
|
|
28
33
|
const scrollbarInstRef = (0, vue_1.ref)(null);
|
|
29
|
-
let
|
|
34
|
+
let loadingBottom = false;
|
|
35
|
+
let loadingTop = false;
|
|
30
36
|
const handleCheckBottom = () => __awaiter(this, void 0, void 0, function* () {
|
|
31
37
|
var _a;
|
|
32
38
|
const { value: scrollbarInst } = scrollbarInstRef;
|
|
@@ -40,27 +46,57 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
40
46
|
clientHeight !== undefined &&
|
|
41
47
|
scrollTop !== undefined) {
|
|
42
48
|
if (scrollTop + clientHeight >= scrollHeight - props.distance) {
|
|
43
|
-
|
|
49
|
+
loadingBottom = true;
|
|
44
50
|
try {
|
|
45
51
|
yield ((_a = props.onLoad) === null || _a === void 0 ? void 0 : _a.call(props));
|
|
46
52
|
}
|
|
47
53
|
catch (_b) { }
|
|
48
|
-
|
|
54
|
+
loadingBottom = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const handleCheckTop = () => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
var _a;
|
|
61
|
+
const { value: scrollbarInst } = scrollbarInstRef;
|
|
62
|
+
if (scrollbarInst) {
|
|
63
|
+
const { containerRef } = scrollbarInst;
|
|
64
|
+
const scrollTop = containerRef === null || containerRef === void 0 ? void 0 : containerRef.scrollTop;
|
|
65
|
+
if (containerRef && scrollTop !== undefined) {
|
|
66
|
+
if (scrollTop <= props.topDistance) {
|
|
67
|
+
loadingTop = true;
|
|
68
|
+
const oldScrollHeight = containerRef.scrollHeight;
|
|
69
|
+
const oldScrollTop = containerRef.scrollTop;
|
|
70
|
+
try {
|
|
71
|
+
yield ((_a = props.onLoadTop) === null || _a === void 0 ? void 0 : _a.call(props));
|
|
72
|
+
yield (0, vue_1.nextTick)();
|
|
73
|
+
const newScrollHeight = containerRef.scrollHeight;
|
|
74
|
+
const heightDiff = newScrollHeight - oldScrollHeight;
|
|
75
|
+
if (heightDiff > 0) {
|
|
76
|
+
containerRef.scrollTop = oldScrollTop + heightDiff;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (_b) { }
|
|
80
|
+
loadingTop = false;
|
|
49
81
|
}
|
|
50
82
|
}
|
|
51
83
|
}
|
|
52
84
|
});
|
|
53
85
|
const handleScroll = () => {
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
86
|
+
if (!loadingBottom) {
|
|
87
|
+
void handleCheckBottom();
|
|
88
|
+
}
|
|
89
|
+
if (!loadingTop) {
|
|
90
|
+
void handleCheckTop();
|
|
91
|
+
}
|
|
57
92
|
};
|
|
58
93
|
const handleWheel = (e) => {
|
|
59
|
-
if (e.deltaY
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
94
|
+
if (e.deltaY > 0 && !loadingBottom) {
|
|
95
|
+
void handleCheckBottom();
|
|
96
|
+
}
|
|
97
|
+
if (e.deltaY < 0 && !loadingTop) {
|
|
98
|
+
void handleCheckTop();
|
|
99
|
+
}
|
|
64
100
|
};
|
|
65
101
|
return {
|
|
66
102
|
scrollbarInstRef,
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.10.
|
|
1
|
+
declare const _default: "1.10.1";
|
|
2
2
|
export default _default;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uzum-tech/ui",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "A Vue 3 Component Library. Fairly Complete, Theme Customizable, Uses TypeScript, Fast",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"format": "pnpm run format:code && pnpm run format:md && pnpm run lint:fix",
|
|
25
25
|
"format:code": "prettier --write \"(src|demo)/**/*.(vue|js)\"",
|
|
26
26
|
"format:md": "prettier --write --parser markdown --prose-wrap never \"(src|demo)/**/*.md\"",
|
|
27
|
-
"test": "cross-env NODE_ENV=test jest
|
|
28
|
-
"test:single": "cross-env NODE_ENV=test jest --
|
|
29
|
-
"test:update": "cross-env NODE_ENV=test jest -u
|
|
30
|
-
"test:cov": "cross-env NODE_ENV=test NODE_OPTIONS=--unhandled-rejections=warn jest",
|
|
27
|
+
"test": "cross-env NODE_ENV=test jest",
|
|
28
|
+
"test:single": "cross-env NODE_ENV=test jest --testMatch=\"<rootDir>/src/list/tests/**.*\"",
|
|
29
|
+
"test:update": "cross-env NODE_ENV=test jest -u",
|
|
30
|
+
"test:cov": "cross-env NODE_ENV=test NODE_OPTIONS=--unhandled-rejections=warn jest --collectCoverage=true",
|
|
31
31
|
"test:watch": "cross-env NODE_ENV=test jest ---watch --verbose --coverage",
|
|
32
|
-
"test:umd": "jest --
|
|
32
|
+
"test:umd": "jest --testMatch=\"<rootDir>/umd-test/index.spec.js\"",
|
|
33
33
|
"gen-version": "node scripts/gen-version",
|
|
34
34
|
"gen-volar-dts": "esbuild scripts/gen-component-declaration.js --bundle --platform=node --tsconfig=tsconfig.esbuild.json | node",
|
|
35
35
|
"build:site:ts": "./scripts/pre-build-site/pre-build-site.sh && cross-env TUSIMPLE=true NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 vite build && ./scripts/post-build-site/post-build-site.sh",
|
package/web-types.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
|
|
3
3
|
"framework": "vue",
|
|
4
4
|
"name": "@uzum-tech/ui",
|
|
5
|
-
"version": "1.10.
|
|
5
|
+
"version": "1.10.1",
|
|
6
6
|
"js-types-syntax": "typescript",
|
|
7
7
|
"contributions": {
|
|
8
8
|
"html": {
|
|
@@ -7875,6 +7875,11 @@
|
|
|
7875
7875
|
"doc-url": "https://www.naiveui.com/en-US/os-theme/components/infinite-scroll",
|
|
7876
7876
|
"type": "number"
|
|
7877
7877
|
},
|
|
7878
|
+
{
|
|
7879
|
+
"name": "top-distance",
|
|
7880
|
+
"doc-url": "https://www.naiveui.com/en-US/os-theme/components/infinite-scroll",
|
|
7881
|
+
"type": "number"
|
|
7882
|
+
},
|
|
7878
7883
|
{
|
|
7879
7884
|
"name": "scrollbar-props",
|
|
7880
7885
|
"doc-url": "https://www.naiveui.com/en-US/os-theme/components/infinite-scroll",
|
|
@@ -7886,6 +7891,10 @@
|
|
|
7886
7891
|
{
|
|
7887
7892
|
"name": "load",
|
|
7888
7893
|
"doc-url": "https://www.naiveui.com/en-US/os-theme/components/infinite-scroll"
|
|
7894
|
+
},
|
|
7895
|
+
{
|
|
7896
|
+
"name": "load-top",
|
|
7897
|
+
"doc-url": "https://www.naiveui.com/en-US/os-theme/components/infinite-scroll"
|
|
7889
7898
|
}
|
|
7890
7899
|
]
|
|
7891
7900
|
}
|