@holyer-lib/ui 0.0.10 → 0.0.11
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/ui.cjs.js +462 -31
- package/dist/ui.esm.js +462 -31
- package/dist/ui.umd.js +462 -31
- package/package.json +1 -1
package/dist/ui.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ function __$styleInject(css) {
|
|
|
14
14
|
return css;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function __$styleInject$
|
|
17
|
+
function __$styleInject$2(css) {
|
|
18
18
|
if (!css) return;
|
|
19
19
|
|
|
20
20
|
if (typeof window == 'undefined') return;
|
|
@@ -26,11 +26,11 @@ function __$styleInject$1(css) {
|
|
|
26
26
|
return css;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
__$styleInject$
|
|
29
|
+
__$styleInject$2(".hi-expand-text {\n display: flex;\n width: 100%;\n line-height: 1.5;\n}\n.hi-expand-text--content {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n word-break: break-word;\n -webkit-line-clamp: var(--hi-expand-text-line-clamp);\n line-clamp: var(--hi-expand-text-line-clamp);\n}\n.hi-expand-text--content.hi-expand-text--content__show-toggle::before {\n content: '';\n float: right;\n height: 100%;\n margin-bottom: calc(-1em * 1.5);\n}\n.hi-expand-text--content__expanded {\n display: block;\n overflow: visible;\n -webkit-line-clamp: unset;\n line-clamp: unset;\n}\n.hi-expand-text--toggle {\n color: var(--td-brand-color);\n float: right;\n clear: both;\n cursor: pointer;\n}\n");
|
|
30
30
|
|
|
31
31
|
//
|
|
32
32
|
|
|
33
|
-
var script$
|
|
33
|
+
var script$2 = {
|
|
34
34
|
name: 'HiExpandText',
|
|
35
35
|
props: {
|
|
36
36
|
content: {
|
|
@@ -168,7 +168,7 @@ var script$1 = {
|
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
function normalizeComponent$
|
|
171
|
+
function normalizeComponent$2(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
172
172
|
if (typeof shadowMode !== 'boolean') {
|
|
173
173
|
createInjectorSSR = createInjector;
|
|
174
174
|
createInjector = shadowMode;
|
|
@@ -244,10 +244,10 @@ function normalizeComponent$1(template, style, script, scopeId, isFunctionalTemp
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/* script */
|
|
247
|
-
const __vue_script__$
|
|
247
|
+
const __vue_script__$2 = script$2;
|
|
248
248
|
|
|
249
249
|
/* template */
|
|
250
|
-
var __vue_render__$
|
|
250
|
+
var __vue_render__$2 = function () {
|
|
251
251
|
var _vm = this;
|
|
252
252
|
var _h = _vm.$createElement;
|
|
253
253
|
var _c = _vm._self._c || _h;
|
|
@@ -287,17 +287,17 @@ var __vue_render__$1 = function () {
|
|
|
287
287
|
]
|
|
288
288
|
)
|
|
289
289
|
};
|
|
290
|
-
var __vue_staticRenderFns__$
|
|
291
|
-
__vue_render__$
|
|
290
|
+
var __vue_staticRenderFns__$2 = [];
|
|
291
|
+
__vue_render__$2._withStripped = true;
|
|
292
292
|
|
|
293
293
|
/* style */
|
|
294
|
-
const __vue_inject_styles__$
|
|
294
|
+
const __vue_inject_styles__$2 = undefined;
|
|
295
295
|
/* scoped */
|
|
296
|
-
const __vue_scope_id__$
|
|
296
|
+
const __vue_scope_id__$2 = undefined;
|
|
297
297
|
/* module identifier */
|
|
298
|
-
const __vue_module_identifier__$
|
|
298
|
+
const __vue_module_identifier__$2 = undefined;
|
|
299
299
|
/* functional template */
|
|
300
|
-
const __vue_is_functional_template__$
|
|
300
|
+
const __vue_is_functional_template__$2 = false;
|
|
301
301
|
/* style inject */
|
|
302
302
|
|
|
303
303
|
/* style inject SSR */
|
|
@@ -306,27 +306,27 @@ __vue_render__$1._withStripped = true;
|
|
|
306
306
|
|
|
307
307
|
|
|
308
308
|
|
|
309
|
-
const __vue_component__$
|
|
310
|
-
{ render: __vue_render__$
|
|
311
|
-
__vue_inject_styles__$
|
|
312
|
-
__vue_script__$
|
|
313
|
-
__vue_scope_id__$
|
|
314
|
-
__vue_is_functional_template__$
|
|
315
|
-
__vue_module_identifier__$
|
|
309
|
+
const __vue_component__$2 = /*#__PURE__*/normalizeComponent$2(
|
|
310
|
+
{ render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 },
|
|
311
|
+
__vue_inject_styles__$2,
|
|
312
|
+
__vue_script__$2,
|
|
313
|
+
__vue_scope_id__$2,
|
|
314
|
+
__vue_is_functional_template__$2,
|
|
315
|
+
__vue_module_identifier__$2,
|
|
316
316
|
false,
|
|
317
317
|
undefined,
|
|
318
318
|
undefined,
|
|
319
319
|
undefined
|
|
320
320
|
);
|
|
321
321
|
|
|
322
|
-
__vue_component__$
|
|
322
|
+
__vue_component__$2.name = 'HiExpandText';
|
|
323
323
|
|
|
324
324
|
// 添加 install
|
|
325
|
-
__vue_component__$
|
|
326
|
-
Vue.component(__vue_component__$
|
|
325
|
+
__vue_component__$2.install = Vue => {
|
|
326
|
+
Vue.component(__vue_component__$2.name, __vue_component__$2);
|
|
327
327
|
};
|
|
328
328
|
|
|
329
|
-
function __$styleInject(css) {
|
|
329
|
+
function __$styleInject$1(css) {
|
|
330
330
|
if (!css) return;
|
|
331
331
|
|
|
332
332
|
if (typeof window == 'undefined') return;
|
|
@@ -338,7 +338,7 @@ function __$styleInject(css) {
|
|
|
338
338
|
return css;
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
__$styleInject(".hi-title {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.hi-title--small {\n gap: 2px;\n}\n.hi-title--large {\n gap: 6px;\n}\n.hi-title__header {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n.hi-title__prefix {\n flex-shrink: 0;\n display: flex;\n align-items: center;\n}\n.hi-title__bar {\n width: 4px;\n background-color: var(--td-brand-color);\n flex-shrink: 0;\n}\n.hi-title__icon {\n flex-shrink: 0;\n line-height: 1;\n}\n.hi-title__text {\n margin: 0;\n font-weight: 600;\n color: var(--td-text-color-primary);\n}\n.hi-title__description {\n margin: 0;\n font-size: 12px;\n color: var(--td-text-color-secondary);\n}\n");
|
|
341
|
+
__$styleInject$1(".hi-title {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.hi-title--small {\n gap: 2px;\n}\n.hi-title--large {\n gap: 6px;\n}\n.hi-title__header {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n.hi-title__prefix {\n flex-shrink: 0;\n display: flex;\n align-items: center;\n}\n.hi-title__bar {\n width: 4px;\n background-color: var(--td-brand-color);\n flex-shrink: 0;\n}\n.hi-title__icon {\n flex-shrink: 0;\n line-height: 1;\n}\n.hi-title__text {\n margin: 0;\n font-weight: 600;\n color: var(--td-text-color-primary);\n}\n.hi-title__description {\n margin: 0;\n font-size: 12px;\n color: var(--td-text-color-secondary);\n}\n");
|
|
342
342
|
|
|
343
343
|
//
|
|
344
344
|
const TITILE_SIZE_MAP = {
|
|
@@ -346,7 +346,7 @@ const TITILE_SIZE_MAP = {
|
|
|
346
346
|
medium: '16px',
|
|
347
347
|
large: '18px'
|
|
348
348
|
};
|
|
349
|
-
var script = {
|
|
349
|
+
var script$1 = {
|
|
350
350
|
name: 'HiTitle',
|
|
351
351
|
inheritAttrs: false,
|
|
352
352
|
props: {
|
|
@@ -425,7 +425,7 @@ var script = {
|
|
|
425
425
|
}
|
|
426
426
|
};
|
|
427
427
|
|
|
428
|
-
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
428
|
+
function normalizeComponent$1(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
429
429
|
if (typeof shadowMode !== 'boolean') {
|
|
430
430
|
createInjectorSSR = createInjector;
|
|
431
431
|
createInjector = shadowMode;
|
|
@@ -501,10 +501,10 @@ function normalizeComponent(template, style, script, scopeId, isFunctionalTempla
|
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
/* script */
|
|
504
|
-
const __vue_script__ = script;
|
|
504
|
+
const __vue_script__$1 = script$1;
|
|
505
505
|
|
|
506
506
|
/* template */
|
|
507
|
-
var __vue_render__ = function () {
|
|
507
|
+
var __vue_render__$1 = function () {
|
|
508
508
|
var _vm = this;
|
|
509
509
|
var _h = _vm.$createElement;
|
|
510
510
|
var _c = _vm._self._c || _h;
|
|
@@ -570,6 +570,435 @@ var __vue_render__ = function () {
|
|
|
570
570
|
]
|
|
571
571
|
)
|
|
572
572
|
};
|
|
573
|
+
var __vue_staticRenderFns__$1 = [];
|
|
574
|
+
__vue_render__$1._withStripped = true;
|
|
575
|
+
|
|
576
|
+
/* style */
|
|
577
|
+
const __vue_inject_styles__$1 = undefined;
|
|
578
|
+
/* scoped */
|
|
579
|
+
const __vue_scope_id__$1 = undefined;
|
|
580
|
+
/* module identifier */
|
|
581
|
+
const __vue_module_identifier__$1 = undefined;
|
|
582
|
+
/* functional template */
|
|
583
|
+
const __vue_is_functional_template__$1 = false;
|
|
584
|
+
/* style inject */
|
|
585
|
+
|
|
586
|
+
/* style inject SSR */
|
|
587
|
+
|
|
588
|
+
/* style inject shadow dom */
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
const __vue_component__$1 = /*#__PURE__*/normalizeComponent$1(
|
|
593
|
+
{ render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
|
|
594
|
+
__vue_inject_styles__$1,
|
|
595
|
+
__vue_script__$1,
|
|
596
|
+
__vue_scope_id__$1,
|
|
597
|
+
__vue_is_functional_template__$1,
|
|
598
|
+
__vue_module_identifier__$1,
|
|
599
|
+
false,
|
|
600
|
+
undefined,
|
|
601
|
+
undefined,
|
|
602
|
+
undefined
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
// 显式设置 name(避免 .vue 丢失)
|
|
606
|
+
__vue_component__$1.name = 'HiTitle';
|
|
607
|
+
|
|
608
|
+
// 添加 install
|
|
609
|
+
__vue_component__$1.install = Vue => {
|
|
610
|
+
Vue.component(__vue_component__$1.name, __vue_component__$1);
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
function __$styleInject(css) {
|
|
614
|
+
if (!css) return;
|
|
615
|
+
|
|
616
|
+
if (typeof window == 'undefined') return;
|
|
617
|
+
var style = document.createElement('style');
|
|
618
|
+
style.setAttribute('media', 'screen');
|
|
619
|
+
|
|
620
|
+
style.innerHTML = css;
|
|
621
|
+
document.head.appendChild(style);
|
|
622
|
+
return css;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
__$styleInject(".hi-virtual-list {\n overflow-y: auto;\n overflow-x: hidden;\n position: relative;\n will-change: scroll-position;\n}\n.hi-virtual-list--placeholder {\n pointer-events: none;\n}\n.hi-virtual-list--item-wrapper {\n box-sizing: border-box;\n}\n");
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* 类型判断工具
|
|
629
|
+
*/
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* 将数值或字符串转换为合法的 CSS 长度值(用于 style 绑定)
|
|
633
|
+
* - 若为 number,自动追加 'px' 单位
|
|
634
|
+
* - 若为 string,原样返回(假定用户已提供合法 CSS 长度值)
|
|
635
|
+
* @param {number|string} value - 输入值(如 100, '100%', '50vh', 'auto')
|
|
636
|
+
* @returns {string} 合法的 CSS 长度字符串 默认值为 0
|
|
637
|
+
* @example
|
|
638
|
+
* formatSize(100) // '100px'
|
|
639
|
+
* formatSize('100%') // '100%'
|
|
640
|
+
* formatSize('50vh') // '50vh'
|
|
641
|
+
* formatSize(null) // 0
|
|
642
|
+
* formatSize(undefined) // 0
|
|
643
|
+
*/
|
|
644
|
+
function formatSize(value) {
|
|
645
|
+
if (typeof value === 'number') {
|
|
646
|
+
return `${value}px`;
|
|
647
|
+
}
|
|
648
|
+
if (typeof value === 'string') {
|
|
649
|
+
if (value.trim() === '') {
|
|
650
|
+
return 0;
|
|
651
|
+
}
|
|
652
|
+
return value;
|
|
653
|
+
}
|
|
654
|
+
return 0;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
//
|
|
658
|
+
|
|
659
|
+
var script = {
|
|
660
|
+
name: 'HiVirtualList',
|
|
661
|
+
props: {
|
|
662
|
+
items: {
|
|
663
|
+
type: Array,
|
|
664
|
+
required: true,
|
|
665
|
+
default: () => []
|
|
666
|
+
},
|
|
667
|
+
itemHeight: {
|
|
668
|
+
type: Number,
|
|
669
|
+
required: true,
|
|
670
|
+
validator(value) {
|
|
671
|
+
if (value <= 0) {
|
|
672
|
+
// eslint-disable-next-line no-console
|
|
673
|
+
console.error('[HiVirtualList] itemHeight must be a positive number.');
|
|
674
|
+
return false;
|
|
675
|
+
}
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
height: {
|
|
680
|
+
type: [Number, String],
|
|
681
|
+
required: true
|
|
682
|
+
},
|
|
683
|
+
buffer: {
|
|
684
|
+
type: Number,
|
|
685
|
+
default: 50
|
|
686
|
+
},
|
|
687
|
+
nodeKey: {
|
|
688
|
+
type: String,
|
|
689
|
+
default: undefined
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
data() {
|
|
693
|
+
return {
|
|
694
|
+
scrollTop: 0,
|
|
695
|
+
clientHeight: 0,
|
|
696
|
+
resizeObserver: null,
|
|
697
|
+
resizeTimer: null
|
|
698
|
+
};
|
|
699
|
+
},
|
|
700
|
+
computed: {
|
|
701
|
+
styles() {
|
|
702
|
+
return {
|
|
703
|
+
height: formatSize(this.height)
|
|
704
|
+
};
|
|
705
|
+
},
|
|
706
|
+
renderItemHeight() {
|
|
707
|
+
return formatSize(this.itemHeight);
|
|
708
|
+
},
|
|
709
|
+
total() {
|
|
710
|
+
return this.items.length;
|
|
711
|
+
},
|
|
712
|
+
visibleCount() {
|
|
713
|
+
if (!this.clientHeight || !this.itemHeight) return 20;
|
|
714
|
+
return Math.ceil(this.clientHeight / this.itemHeight) + this.buffer * 2;
|
|
715
|
+
},
|
|
716
|
+
startIndex() {
|
|
717
|
+
return Math.max(0, Math.floor(this.scrollTop / this.itemHeight));
|
|
718
|
+
},
|
|
719
|
+
endIndex() {
|
|
720
|
+
return Math.min(this.total, this.startIndex + this.visibleCount);
|
|
721
|
+
},
|
|
722
|
+
visibleItems() {
|
|
723
|
+
return this.items.slice(this.startIndex, this.endIndex);
|
|
724
|
+
},
|
|
725
|
+
topPlaceholderHeight() {
|
|
726
|
+
return formatSize(this.startIndex * this.itemHeight);
|
|
727
|
+
},
|
|
728
|
+
bottomPlaceholderHeight() {
|
|
729
|
+
return formatSize((this.total - this.endIndex) * this.itemHeight);
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
mounted() {
|
|
733
|
+
this.updateClientHeight();
|
|
734
|
+
this.setupResizeListener();
|
|
735
|
+
},
|
|
736
|
+
beforeDestroy() {
|
|
737
|
+
this.cleanupResizeListener();
|
|
738
|
+
},
|
|
739
|
+
methods: {
|
|
740
|
+
/**
|
|
741
|
+
* 判断是否应使用 nodeKey 字段
|
|
742
|
+
*/
|
|
743
|
+
_shouldUseNodeKey() {
|
|
744
|
+
return this.nodeKey && typeof this.nodeKey === 'string' && this.nodeKey.trim() !== '';
|
|
745
|
+
},
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* 获取 item 的唯一 key(用于 v-for)
|
|
749
|
+
*/
|
|
750
|
+
getNodeKey(item, index) {
|
|
751
|
+
if (this._shouldUseNodeKey() && item != null && typeof item === 'object') {
|
|
752
|
+
const key = item[this.nodeKey];
|
|
753
|
+
if (key != null) {
|
|
754
|
+
return key;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
return index;
|
|
758
|
+
},
|
|
759
|
+
|
|
760
|
+
updateClientHeight() {
|
|
761
|
+
if (this.$refs.rootRef) {
|
|
762
|
+
this.clientHeight = this.$refs.rootRef.clientHeight;
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
|
|
766
|
+
setupResizeListener() {
|
|
767
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
768
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
769
|
+
this.updateClientHeight();
|
|
770
|
+
});
|
|
771
|
+
this.resizeObserver.observe(this.$refs.rootRef);
|
|
772
|
+
} else {
|
|
773
|
+
window.addEventListener('resize', this.handleWindowResize);
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
|
|
777
|
+
cleanupResizeListener() {
|
|
778
|
+
if (this.resizeObserver) {
|
|
779
|
+
this.resizeObserver.disconnect();
|
|
780
|
+
this.resizeObserver = null;
|
|
781
|
+
}
|
|
782
|
+
if (this.resizeTimer) {
|
|
783
|
+
clearTimeout(this.resizeTimer);
|
|
784
|
+
this.resizeTimer = null;
|
|
785
|
+
}
|
|
786
|
+
window.removeEventListener('resize', this.handleWindowResize);
|
|
787
|
+
},
|
|
788
|
+
|
|
789
|
+
handleWindowResize() {
|
|
790
|
+
if (this.resizeTimer) {
|
|
791
|
+
clearTimeout(this.resizeTimer);
|
|
792
|
+
}
|
|
793
|
+
this.resizeTimer = setTimeout(() => {
|
|
794
|
+
this.updateClientHeight();
|
|
795
|
+
}, 100);
|
|
796
|
+
},
|
|
797
|
+
|
|
798
|
+
handleScroll(e) {
|
|
799
|
+
this.scrollTop = e.target.scrollTop;
|
|
800
|
+
this.$emit('scroll', e);
|
|
801
|
+
|
|
802
|
+
const { scrollHeight, clientHeight, scrollTop } = e.target;
|
|
803
|
+
if (scrollTop === 0) this.$emit('reach-top');
|
|
804
|
+
if (scrollHeight - clientHeight - scrollTop < 100) this.$emit('reach-bottom');
|
|
805
|
+
this.$emit('visible-change', { startIndex: this.startIndex, endIndex: this.endIndex });
|
|
806
|
+
},
|
|
807
|
+
|
|
808
|
+
refresh() {
|
|
809
|
+
this.updateClientHeight();
|
|
810
|
+
},
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* 内部滚动方法(仅设置 DOM scrollTop,状态由 handleScroll 同步)
|
|
814
|
+
*/
|
|
815
|
+
_setScrollTop(scrollTop) {
|
|
816
|
+
if (this.$refs.rootRef) {
|
|
817
|
+
this.$refs.rootRef.scrollTop = scrollTop;
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* 滚动到指定目标
|
|
823
|
+
* - 若启用了有效的 nodeKey,则 target 视为 keyValue
|
|
824
|
+
* - 否则,target 必须是 number(index)
|
|
825
|
+
*/
|
|
826
|
+
scrollTo(target) {
|
|
827
|
+
if (target == null) {
|
|
828
|
+
// eslint-disable-next-line no-console
|
|
829
|
+
console.warn('[HiVirtualList] scrollTo: target cannot be null or undefined');
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
let index = -1;
|
|
834
|
+
|
|
835
|
+
// 使用 getNodeKey 生成的 key 进行匹配(严格对齐)
|
|
836
|
+
if (this._shouldUseNodeKey()) {
|
|
837
|
+
index = this.items.findIndex((item, i) => {
|
|
838
|
+
return this.getNodeKey(item, i) === target;
|
|
839
|
+
});
|
|
840
|
+
} else {
|
|
841
|
+
// 降级到 index 模式
|
|
842
|
+
if (typeof target === 'number' && target >= 0 && target < this.total) {
|
|
843
|
+
index = target;
|
|
844
|
+
} else {
|
|
845
|
+
// eslint-disable-next-line no-console
|
|
846
|
+
console.warn(
|
|
847
|
+
'[HiVirtualList] scrollTo: when nodeKey is not provided, target must be a valid index (number).'
|
|
848
|
+
);
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (index < 0 || index >= this.total) {
|
|
854
|
+
if (this._shouldUseNodeKey()) {
|
|
855
|
+
// eslint-disable-next-line no-console
|
|
856
|
+
console.warn(`[HiVirtualList] scrollTo: item with key "${target}" not found`);
|
|
857
|
+
} else {
|
|
858
|
+
// eslint-disable-next-line no-console
|
|
859
|
+
console.warn(`[HiVirtualList] scrollTo: index ${target} is out of range [0, ${this.total})`);
|
|
860
|
+
}
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
this._setScrollTop(index * this.itemHeight);
|
|
865
|
+
},
|
|
866
|
+
|
|
867
|
+
scrollToTop() {
|
|
868
|
+
this._setScrollTop(0);
|
|
869
|
+
},
|
|
870
|
+
|
|
871
|
+
scrollToBottom() {
|
|
872
|
+
this._setScrollTop(this.total * this.itemHeight);
|
|
873
|
+
},
|
|
874
|
+
|
|
875
|
+
getVisibleRange() {
|
|
876
|
+
return {
|
|
877
|
+
startIndex: this.startIndex,
|
|
878
|
+
endIndex: this.endIndex
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
885
|
+
if (typeof shadowMode !== 'boolean') {
|
|
886
|
+
createInjectorSSR = createInjector;
|
|
887
|
+
createInjector = shadowMode;
|
|
888
|
+
shadowMode = false;
|
|
889
|
+
}
|
|
890
|
+
// Vue.extend constructor export interop.
|
|
891
|
+
const options = typeof script === 'function' ? script.options : script;
|
|
892
|
+
// render functions
|
|
893
|
+
if (template && template.render) {
|
|
894
|
+
options.render = template.render;
|
|
895
|
+
options.staticRenderFns = template.staticRenderFns;
|
|
896
|
+
options._compiled = true;
|
|
897
|
+
// functional template
|
|
898
|
+
if (isFunctionalTemplate) {
|
|
899
|
+
options.functional = true;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
// scopedId
|
|
903
|
+
if (scopeId) {
|
|
904
|
+
options._scopeId = scopeId;
|
|
905
|
+
}
|
|
906
|
+
let hook;
|
|
907
|
+
if (moduleIdentifier) {
|
|
908
|
+
// server build
|
|
909
|
+
hook = function (context) {
|
|
910
|
+
// 2.3 injection
|
|
911
|
+
context =
|
|
912
|
+
context || // cached call
|
|
913
|
+
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
914
|
+
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
|
|
915
|
+
// 2.2 with runInNewContext: true
|
|
916
|
+
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
917
|
+
context = __VUE_SSR_CONTEXT__;
|
|
918
|
+
}
|
|
919
|
+
// inject component styles
|
|
920
|
+
if (style) {
|
|
921
|
+
style.call(this, createInjectorSSR(context));
|
|
922
|
+
}
|
|
923
|
+
// register component module identifier for async chunk inference
|
|
924
|
+
if (context && context._registeredComponents) {
|
|
925
|
+
context._registeredComponents.add(moduleIdentifier);
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
// used by ssr in case component is cached and beforeCreate
|
|
929
|
+
// never gets called
|
|
930
|
+
options._ssrRegister = hook;
|
|
931
|
+
}
|
|
932
|
+
else if (style) {
|
|
933
|
+
hook = shadowMode
|
|
934
|
+
? function (context) {
|
|
935
|
+
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
|
|
936
|
+
}
|
|
937
|
+
: function (context) {
|
|
938
|
+
style.call(this, createInjector(context));
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
if (hook) {
|
|
942
|
+
if (options.functional) {
|
|
943
|
+
// register for functional component in vue file
|
|
944
|
+
const originalRender = options.render;
|
|
945
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
946
|
+
hook.call(context);
|
|
947
|
+
return originalRender(h, context);
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
else {
|
|
951
|
+
// inject component registration as beforeCreate hook
|
|
952
|
+
const existing = options.beforeCreate;
|
|
953
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
return script;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/* script */
|
|
960
|
+
const __vue_script__ = script;
|
|
961
|
+
|
|
962
|
+
/* template */
|
|
963
|
+
var __vue_render__ = function () {
|
|
964
|
+
var _vm = this;
|
|
965
|
+
var _h = _vm.$createElement;
|
|
966
|
+
var _c = _vm._self._c || _h;
|
|
967
|
+
return _c(
|
|
968
|
+
"div",
|
|
969
|
+
{
|
|
970
|
+
ref: "rootRef",
|
|
971
|
+
staticClass: "hi-virtual-list",
|
|
972
|
+
style: _vm.styles,
|
|
973
|
+
on: { scroll: _vm.handleScroll },
|
|
974
|
+
},
|
|
975
|
+
[
|
|
976
|
+
_c("div", {
|
|
977
|
+
staticClass: "hi-virtual-list--placeholder",
|
|
978
|
+
style: { height: _vm.topPlaceholderHeight },
|
|
979
|
+
}),
|
|
980
|
+
_vm._v(" "),
|
|
981
|
+
_vm._l(_vm.visibleItems, function (item, i) {
|
|
982
|
+
return _c(
|
|
983
|
+
"div",
|
|
984
|
+
{
|
|
985
|
+
key: _vm.getNodeKey(item, _vm.startIndex + i),
|
|
986
|
+
staticClass: "hi-virtual-list--item-wrapper",
|
|
987
|
+
style: { height: _vm.renderItemHeight },
|
|
988
|
+
},
|
|
989
|
+
[_vm._t("default", null, { item: item, index: _vm.startIndex + i })],
|
|
990
|
+
2
|
|
991
|
+
)
|
|
992
|
+
}),
|
|
993
|
+
_vm._v(" "),
|
|
994
|
+
_c("div", {
|
|
995
|
+
staticClass: "hi-virtual-list--placeholder",
|
|
996
|
+
style: { height: _vm.bottomPlaceholderHeight },
|
|
997
|
+
}),
|
|
998
|
+
],
|
|
999
|
+
2
|
|
1000
|
+
)
|
|
1001
|
+
};
|
|
573
1002
|
var __vue_staticRenderFns__ = [];
|
|
574
1003
|
__vue_render__._withStripped = true;
|
|
575
1004
|
|
|
@@ -603,7 +1032,7 @@ __vue_render__._withStripped = true;
|
|
|
603
1032
|
);
|
|
604
1033
|
|
|
605
1034
|
// 显式设置 name(避免 .vue 丢失)
|
|
606
|
-
__vue_component__.name = '
|
|
1035
|
+
__vue_component__.name = 'HiVirtualList';
|
|
607
1036
|
|
|
608
1037
|
// 添加 install
|
|
609
1038
|
__vue_component__.install = Vue => {
|
|
@@ -612,6 +1041,7 @@ __vue_component__.install = Vue => {
|
|
|
612
1041
|
|
|
613
1042
|
// eslint-disable-next-line prettier/prettier
|
|
614
1043
|
const components = [
|
|
1044
|
+
__vue_component__$2,
|
|
615
1045
|
__vue_component__$1,
|
|
616
1046
|
__vue_component__
|
|
617
1047
|
];
|
|
@@ -624,8 +1054,9 @@ const install = function (Vue) {
|
|
|
624
1054
|
|
|
625
1055
|
var index = {
|
|
626
1056
|
install,
|
|
627
|
-
HiExpandText: __vue_component__$
|
|
628
|
-
HiTitle: __vue_component__
|
|
1057
|
+
HiExpandText: __vue_component__$2,
|
|
1058
|
+
HiTitle: __vue_component__$1,
|
|
1059
|
+
HiVirtualList: __vue_component__
|
|
629
1060
|
};
|
|
630
1061
|
|
|
631
1062
|
module.exports = index;
|