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