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