@holyer-lib/ui 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui.cjs.js CHANGED
@@ -14,25 +14,682 @@ function __$styleInject(css) {
14
14
  return css;
15
15
  }
16
16
 
17
+ function __$styleInject$3(css) {
18
+ if (!css) return;
19
+
20
+ if (typeof window == 'undefined') return;
21
+ var style = document.createElement('style');
22
+ style.setAttribute('media', 'screen');
23
+
24
+ style.innerHTML = css;
25
+ document.head.appendChild(style);
26
+ return css;
27
+ }
28
+
29
+ __$styleInject$3(".hi-expand-panel {\n position: relative;\n display: flex;\n transition: flex 0.3s ease;\n}\n.hi-expand-panel:hover .hi-expand-panel--control-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.hi-expand-panel--content {\n height: 100%;\n width: 100%;\n overflow: auto;\n padding: 16px;\n box-sizing: border-box;\n}\n.hi-expand-panel--control-draggable:hover {\n cursor: var(--control-draggable-cursor);\n}\n.hi-expand-panel--control-dragging {\n background-color: var(--control-dragging-bg-color) !important;\n}\n.hi-expand-panel--right .hi-expand-panel--control,\n.hi-expand-panel--left .hi-expand-panel--control {\n position: absolute;\n height: 100%;\n width: 1px;\n background-color: var(--td-gray-color-4);\n}\n.hi-expand-panel--right .hi-expand-panel--control-trigger,\n.hi-expand-panel--left .hi-expand-panel--control-trigger {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n cursor: pointer;\n background-color: var(--td-font-white-1);\n border: 1px solid var(--td-gray-color-4);\n width: 12px;\n height: 56px;\n display: none;\n border-radius: 6px;\n}\n.hi-expand-panel--right {\n flex-direction: row;\n}\n.hi-expand-panel--right .hi-expand-panel--control {\n right: 0;\n}\n.hi-expand-panel--right .hi-expand-panel--control-trigger {\n right: -6px;\n}\n.hi-expand-panel--left {\n flex-direction: row-reverse;\n}\n.hi-expand-panel--left .hi-expand-panel--control {\n left: 0;\n}\n.hi-expand-panel--left .hi-expand-panel--control-trigger {\n left: -6px;\n}\n.hi-expand-panel--top .hi-expand-panel--control,\n.hi-expand-panel--bottom .hi-expand-panel--control {\n position: absolute;\n width: 100%;\n height: 1px;\n background-color: var(--td-gray-color-4);\n}\n.hi-expand-panel--top .hi-expand-panel--control-trigger,\n.hi-expand-panel--bottom .hi-expand-panel--control-trigger {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n cursor: pointer;\n background-color: var(--td-font-white-1);\n border: 1px solid var(--td-gray-color-4);\n width: 56px;\n height: 12px;\n display: none;\n border-radius: 6px;\n}\n.hi-expand-panel--top {\n flex-direction: column-reverse;\n}\n.hi-expand-panel--top .hi-expand-panel--control {\n top: 0;\n}\n.hi-expand-panel--top .hi-expand-panel--control-trigger {\n top: -6px;\n}\n.hi-expand-panel--bottom {\n flex-direction: column;\n}\n.hi-expand-panel--bottom .hi-expand-panel--control {\n bottom: 0;\n}\n.hi-expand-panel--bottom .hi-expand-panel--control-trigger {\n bottom: -6px;\n}\n");
30
+
31
+ /**
32
+ * 类型判断工具
33
+ */
34
+
35
+ /**
36
+ * 将数值或字符串转换为合法的 CSS 长度值(用于 style 绑定)
37
+ * - 若为 number,自动追加 'px' 单位
38
+ * - 若为 string,原样返回(假定用户已提供合法 CSS 长度值)
39
+ * @param {number|string} value - 输入值(如 100, '100%', '50vh', 'auto')
40
+ * @returns {string} 合法的 CSS 长度字符串 默认值为 0
41
+ * @example
42
+ * formatSize(100) // '100px'
43
+ * formatSize('100%') // '100%'
44
+ * formatSize('50vh') // '50vh'
45
+ * formatSize(null) // 0
46
+ * formatSize(undefined) // 0
47
+ */
48
+ function formatSize$1(value) {
49
+ if (typeof value === 'number') {
50
+ return `${value}px`;
51
+ }
52
+ if (typeof value === 'string') {
53
+ if (value.trim() === '') {
54
+ return 0;
55
+ }
56
+ return value;
57
+ }
58
+ return 0;
59
+ }
60
+
17
61
  //
18
- //
19
- //
20
- //
21
- //
62
+
63
+ const validateSize = val => {
64
+ if (typeof val === 'number') {
65
+ return val >= 0;
66
+ }
67
+ return true;
68
+ };
69
+
70
+ var script$3 = {
71
+ name: 'HiExpandPanel',
72
+ model: {
73
+ prop: 'expanded',
74
+ event: 'update:expanded'
75
+ },
76
+ props: {
77
+ // 支持受控和非受控两种模式
78
+ expanded: {
79
+ type: Boolean,
80
+ default: undefined
81
+ },
82
+
83
+ placement: {
84
+ type: String,
85
+ default: 'right',
86
+ validator: v => ['left', 'right', 'top', 'bottom'].includes(v)
87
+ },
88
+
89
+ size: {
90
+ type: [Number, String],
91
+ default: 280,
92
+ validator: validateSize
93
+ },
94
+
95
+ minSize: {
96
+ type: [Number, String],
97
+ default: 240,
98
+ validator: validateSize
99
+ },
100
+
101
+ maxSize: {
102
+ type: [Number, String],
103
+ default: 480,
104
+ validator: validateSize
105
+ },
106
+
107
+ collapsedSize: {
108
+ type: [String, Number],
109
+ default: 24,
110
+ validator: validateSize
111
+ },
112
+
113
+ draggable: {
114
+ type: Boolean,
115
+ default: true
116
+ },
117
+
118
+ showTrigger: {
119
+ type: Boolean,
120
+ default: true
121
+ },
122
+
123
+ cacheKey: {
124
+ type: String,
125
+ default: ''
126
+ },
127
+
128
+ cacheVersion: {
129
+ type: String,
130
+ default: ''
131
+ },
132
+
133
+ draggingBgColor: {
134
+ type: String,
135
+ default: 'var(--td-gray-color-6)'
136
+ }
137
+ },
138
+ data() {
139
+ let cachedData = {};
140
+ if (this.cacheKey) {
141
+ try {
142
+ const stored = localStorage.getItem(`${this.cacheKey}${this.cacheVersion}`);
143
+ if (stored) {
144
+ cachedData = JSON.parse(stored);
145
+ }
146
+ } catch (e) {
147
+ // eslint-disable-next-line no-console
148
+ console.warn(`HiExpandPanel: Failed to parse cache for key "${this.cacheKey}"`, e);
149
+ cachedData = {};
150
+ }
151
+ }
152
+
153
+ // 核心逻辑:有外部控制就用外部控制,否则用缓存
154
+ const useExternal = this.expanded !== undefined;
155
+ const initialExpanded = useExternal
156
+ ? this.expanded
157
+ : cachedData.cachedExpanded !== undefined
158
+ ? cachedData.cachedExpanded
159
+ : true;
160
+ const initialSize = useExternal
161
+ ? this.size
162
+ : cachedData.cachedSize !== undefined
163
+ ? cachedData.cachedSize
164
+ : this.size;
165
+
166
+ return {
167
+ innerExpanded: initialExpanded,
168
+ clientSize: initialSize,
169
+ isDragging: false,
170
+ startX: 0,
171
+ startY: 0,
172
+ startWidth: 0,
173
+ startHeight: 0,
174
+ hasExternalControl: useExternal
175
+ };
176
+ },
177
+ computed: {
178
+ isHorizontal() {
179
+ return ['left', 'right'].includes(this.placement);
180
+ },
181
+
182
+ // 根据展开状态和方向动态计算面板尺寸限制
183
+ getContainerStyles() {
184
+ // 如果未展开,直接返回空对象,不设置min/max尺寸
185
+ if (!this.innerExpanded) return {};
186
+ // 展开时根据方向设置对应的min/max尺寸
187
+ return this.isHorizontal
188
+ ? {
189
+ minWidth: formatSize$1(this.minSize),
190
+ maxWidth: formatSize$1(this.maxSize)
191
+ }
192
+ : {
193
+ minHeight: formatSize$1(this.minSize),
194
+ maxHeight: formatSize$1(this.maxSize)
195
+ };
196
+ },
197
+ panelStyle() {
198
+ const getWidth = () => {
199
+ if (this.isHorizontal) {
200
+ return this.innerExpanded ? formatSize$1(this.clientSize) : formatSize$1(this.collapsedSize) || 0;
201
+ }
202
+ return '100%';
203
+ };
204
+
205
+ const getHeight = () => {
206
+ if (this.isHorizontal) {
207
+ return '100%';
208
+ }
209
+ return this.innerExpanded ? formatSize$1(this.clientSize) : formatSize$1(this.collapsedSize) || 0;
210
+ };
211
+
212
+ return {
213
+ width: getWidth(),
214
+ height: getHeight(),
215
+ ...this.getContainerStyles,
216
+ transition: this.isDragging ? 'none' : 'flex 0.3s ease',
217
+ '--control-draggable-cursor': this.isHorizontal ? 'col-resize' : 'row-resize',
218
+ '--control-dragging-bg-color': this.draggingBgColor
219
+ };
220
+ }
221
+ },
222
+ watch: {
223
+ expanded(newVal) {
224
+ // 只有在组件是受控时才更新状态
225
+ if (this.hasExternalControl) {
226
+ if (newVal !== this.innerExpanded) {
227
+ this.innerExpanded = newVal;
228
+ }
229
+ }
230
+ },
231
+
232
+ innerExpanded(newVal) {
233
+ this.$emit('update:expanded', newVal);
234
+ this.$emit('expand-change', newVal);
235
+ if (this.cacheKey) {
236
+ this.handleSaveCache();
237
+ }
238
+ }
239
+ },
240
+ methods: {
241
+ handleToggle() {
242
+ this.innerExpanded = !this.innerExpanded;
243
+ },
244
+
245
+ handleSaveCache() {
246
+ if (this.cacheKey) {
247
+ localStorage.setItem(
248
+ `${this.cacheKey}${this.cacheVersion}`,
249
+ JSON.stringify({
250
+ cachedSize: this.clientSize,
251
+ cachedExpanded: this.innerExpanded
252
+ })
253
+ );
254
+ }
255
+ },
256
+
257
+ handleDragMousedown(e) {
258
+ if (!this.draggable) return;
259
+ e.preventDefault();
260
+ this.isDragging = true;
261
+ this.startX = e.clientX;
262
+ this.startY = e.clientY;
263
+
264
+ const panelRect = this.$refs.hiExpandPanelRef.getBoundingClientRect();
265
+ this.startWidth = panelRect.width;
266
+ this.startHeight = panelRect.height;
267
+
268
+ this.handleCreateMousemoveListener();
269
+ // 添加全局样式防止选中文本
270
+ document.body.style.userSelect = 'none';
271
+ },
272
+
273
+ // 核心逻辑:根据鼠标移动计算新的尺寸
274
+ handleDragMousemove(e) {
275
+ if (!this.isDragging) return;
276
+ // 只在需要阻止默认行为时调用 preventDefault
277
+ e.preventDefault();
278
+
279
+ let newSize;
280
+ if (this.isHorizontal) {
281
+ // 根据放置位置决定宽度变化的方向
282
+ const moveWidth = this.placement === 'left' ? this.startX - e.clientX : e.clientX - this.startX;
283
+ newSize = this.startWidth + moveWidth;
284
+ } else {
285
+ // 根据放置位置决定高度变化的方向
286
+ const moveHeight = this.placement === 'top' ? this.startY - e.clientY : e.clientY - this.startY;
287
+ newSize = this.startHeight + moveHeight;
288
+ }
289
+
290
+ // minSize 和 maxSize 已经限制了最大宽高,直接取 newSize 设置 clientSize 即可
291
+ this.clientSize = newSize;
292
+ },
293
+
294
+ // 鼠标松开结束拖动
295
+ handleDragMouseup() {
296
+ if (!this.isDragging) return;
297
+ this.isDragging = false;
298
+ this.handleSaveCache();
299
+ // 清理事件监听
300
+ this.handleClearMousemoveListener();
301
+ this.$emit('drag-end', {
302
+ size: this.clientSize,
303
+ expanded: this.innerExpanded
304
+ });
305
+
306
+ // 恢复全局样式
307
+ document.body.style.userSelect = '';
308
+ },
309
+
310
+ // 添加拖拽事件监听
311
+ handleCreateMousemoveListener() {
312
+ document.addEventListener('mousemove', this.handleDragMousemove);
313
+ document.addEventListener('mouseup', this.handleDragMouseup);
314
+ },
315
+
316
+ // 移除拖拽事件监听
317
+ handleClearMousemoveListener() {
318
+ document.removeEventListener('mousemove', this.handleDragMousemove);
319
+ document.removeEventListener('mouseup', this.handleDragMouseup);
320
+ }
321
+ }
322
+ };
323
+
324
+ function normalizeComponent$3(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
325
+ if (typeof shadowMode !== 'boolean') {
326
+ createInjectorSSR = createInjector;
327
+ createInjector = shadowMode;
328
+ shadowMode = false;
329
+ }
330
+ // Vue.extend constructor export interop.
331
+ const options = typeof script === 'function' ? script.options : script;
332
+ // render functions
333
+ if (template && template.render) {
334
+ options.render = template.render;
335
+ options.staticRenderFns = template.staticRenderFns;
336
+ options._compiled = true;
337
+ // functional template
338
+ if (isFunctionalTemplate) {
339
+ options.functional = true;
340
+ }
341
+ }
342
+ // scopedId
343
+ if (scopeId) {
344
+ options._scopeId = scopeId;
345
+ }
346
+ let hook;
347
+ if (moduleIdentifier) {
348
+ // server build
349
+ hook = function (context) {
350
+ // 2.3 injection
351
+ context =
352
+ context || // cached call
353
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
354
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
355
+ // 2.2 with runInNewContext: true
356
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
357
+ context = __VUE_SSR_CONTEXT__;
358
+ }
359
+ // inject component styles
360
+ if (style) {
361
+ style.call(this, createInjectorSSR(context));
362
+ }
363
+ // register component module identifier for async chunk inference
364
+ if (context && context._registeredComponents) {
365
+ context._registeredComponents.add(moduleIdentifier);
366
+ }
367
+ };
368
+ // used by ssr in case component is cached and beforeCreate
369
+ // never gets called
370
+ options._ssrRegister = hook;
371
+ }
372
+ else if (style) {
373
+ hook = shadowMode
374
+ ? function (context) {
375
+ style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
376
+ }
377
+ : function (context) {
378
+ style.call(this, createInjector(context));
379
+ };
380
+ }
381
+ if (hook) {
382
+ if (options.functional) {
383
+ // register for functional component in vue file
384
+ const originalRender = options.render;
385
+ options.render = function renderWithStyleInjection(h, context) {
386
+ hook.call(context);
387
+ return originalRender(h, context);
388
+ };
389
+ }
390
+ else {
391
+ // inject component registration as beforeCreate hook
392
+ const existing = options.beforeCreate;
393
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
394
+ }
395
+ }
396
+ return script;
397
+ }
398
+
399
+ /* script */
400
+ const __vue_script__$3 = script$3;
401
+
402
+ /* template */
403
+ var __vue_render__$3 = function () {
404
+ var _vm = this;
405
+ var _h = _vm.$createElement;
406
+ var _c = _vm._self._c || _h;
407
+ return _c(
408
+ "div",
409
+ {
410
+ ref: "hiExpandPanelRef",
411
+ class: ["hi-expand-panel", "hi-expand-panel--" + _vm.placement],
412
+ style: _vm.panelStyle,
413
+ },
414
+ [
415
+ _c(
416
+ "div",
417
+ {
418
+ directives: [
419
+ {
420
+ name: "show",
421
+ rawName: "v-show",
422
+ value: _vm.innerExpanded,
423
+ expression: "innerExpanded",
424
+ },
425
+ ],
426
+ staticClass: "hi-expand-panel--content",
427
+ },
428
+ [_vm._t("default")],
429
+ 2
430
+ ),
431
+ _vm._v(" "),
432
+ _c(
433
+ "div",
434
+ {
435
+ class: [
436
+ "hi-expand-panel--control",
437
+ {
438
+ "hi-expand-panel--control-draggable":
439
+ _vm.draggable && _vm.innerExpanded,
440
+ "hi-expand-panel--control-dragging":
441
+ _vm.isDragging && _vm.innerExpanded,
442
+ },
443
+ ],
444
+ on: {
445
+ mousedown: _vm.handleDragMousedown,
446
+ mousemove: _vm.handleDragMousemove,
447
+ mouseup: _vm.handleDragMouseup,
448
+ },
449
+ },
450
+ [
451
+ _vm.$slots.trigger || _vm.showTrigger
452
+ ? _c(
453
+ "div",
454
+ {
455
+ staticClass: "hi-expand-panel--control-trigger",
456
+ on: {
457
+ click: function ($event) {
458
+ $event.stopPropagation();
459
+ return _vm.handleToggle.apply(null, arguments)
460
+ },
461
+ mousedown: function ($event) {
462
+ $event.stopPropagation();
463
+ },
464
+ },
465
+ },
466
+ [
467
+ _vm._t("trigger", function () {
468
+ return [
469
+ _vm.isHorizontal
470
+ ? [
471
+ _vm.placement === "right"
472
+ ? _c("span", [
473
+ _vm._v(_vm._s(_vm.innerExpanded ? "◂" : "▸")),
474
+ ])
475
+ : _c("span", [
476
+ _vm._v(_vm._s(_vm.innerExpanded ? "▸" : "◂")),
477
+ ]),
478
+ ]
479
+ : [
480
+ _vm.placement === "top"
481
+ ? _c("span", [
482
+ _vm._v(_vm._s(_vm.innerExpanded ? "▾" : "▴")),
483
+ ])
484
+ : _c("span", [
485
+ _vm._v(_vm._s(_vm.innerExpanded ? "▴" : "▾")),
486
+ ]),
487
+ ],
488
+ ]
489
+ }),
490
+ ],
491
+ 2
492
+ )
493
+ : _vm._e(),
494
+ ]
495
+ ),
496
+ ]
497
+ )
498
+ };
499
+ var __vue_staticRenderFns__$3 = [];
500
+ __vue_render__$3._withStripped = true;
501
+
502
+ /* style */
503
+ const __vue_inject_styles__$3 = undefined;
504
+ /* scoped */
505
+ const __vue_scope_id__$3 = undefined;
506
+ /* module identifier */
507
+ const __vue_module_identifier__$3 = undefined;
508
+ /* functional template */
509
+ const __vue_is_functional_template__$3 = false;
510
+ /* style inject */
511
+
512
+ /* style inject SSR */
513
+
514
+ /* style inject shadow dom */
515
+
516
+
517
+
518
+ const __vue_component__$3 = /*#__PURE__*/normalizeComponent$3(
519
+ { render: __vue_render__$3, staticRenderFns: __vue_staticRenderFns__$3 },
520
+ __vue_inject_styles__$3,
521
+ __vue_script__$3,
522
+ __vue_scope_id__$3,
523
+ __vue_is_functional_template__$3,
524
+ __vue_module_identifier__$3,
525
+ false,
526
+ undefined,
527
+ undefined,
528
+ undefined
529
+ );
530
+
531
+ __vue_component__$3.name = 'HiExpandPanel';
532
+
533
+ // 添加 install
534
+ __vue_component__$3.install = Vue => {
535
+ Vue.component(__vue_component__$3.name, __vue_component__$3);
536
+ };
537
+
538
+ function __$styleInject$2(css) {
539
+ if (!css) return;
540
+
541
+ if (typeof window == 'undefined') return;
542
+ var style = document.createElement('style');
543
+ style.setAttribute('media', 'screen');
544
+
545
+ style.innerHTML = css;
546
+ document.head.appendChild(style);
547
+ return css;
548
+ }
549
+
550
+ __$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");
551
+
22
552
  //
23
553
 
24
- var script = {
25
- name: 'HiTitle',
554
+ var script$2 = {
555
+ name: 'HiExpandText',
26
556
  props: {
27
557
  content: {
28
558
  type: String,
29
- default: '标题'
559
+ default: ''
560
+ },
561
+
562
+ /**
563
+ * [0]: 展开时显示的文本,[1]: 收起时显示的文本
564
+ */
565
+ label: {
566
+ type: Array,
567
+ default: () => ['展开', '收起'],
568
+ validator: arr => {
569
+ return arr.length === 2 && arr.every(s => typeof s === 'string');
570
+ }
571
+ },
572
+
573
+ lineClamp: {
574
+ type: Number,
575
+ default: 2
576
+ }
577
+ },
578
+ data() {
579
+ return {
580
+ showToggle: false,
581
+ isExpanded: false,
582
+ resizeTimer: null,
583
+ resizeObserver: null
584
+ };
585
+ },
586
+ computed: {
587
+ expandText() {
588
+ return this.isExpanded ? this.label[1] : this.label[0];
589
+ },
590
+
591
+ textClass() {
592
+ return {
593
+ 'hi-expand-text--content': true,
594
+ 'hi-expand-text--content__show-toggle': this.showToggle,
595
+ 'hi-expand-text--content__expanded': this.isExpanded
596
+ };
597
+ }
598
+ },
599
+
600
+ watch: {
601
+ content() {
602
+ this.$nextTick(this.checkEllipsis);
30
603
  }
31
604
  },
32
- data() {}
605
+ mounted() {
606
+ this.checkEllipsis();
607
+ window.addEventListener('resize', this.handleResize);
608
+ if (window.ResizeObserver && this.$el) {
609
+ this.resizeObserver = new ResizeObserver(() => {
610
+ this.handleResize();
611
+ });
612
+ this.resizeObserver.observe(this.$el);
613
+ }
614
+ },
615
+ beforeDestroy() {
616
+ window.removeEventListener('resize', this.handleResize);
617
+ if (this.resizeObserver) this.resizeObserver.disconnect();
618
+ if (this.resizeTimer) clearTimeout(this.resizeTimer);
619
+ },
620
+
621
+ methods: {
622
+ handleResize() {
623
+ if (this.resizeTimer) clearTimeout(this.resizeTimer);
624
+ this.resizeTimer = setTimeout(() => {
625
+ this.checkEllipsis();
626
+ }, 100);
627
+ },
628
+
629
+ /**
630
+ * @Description 检查是否存在溢出情况,兼容展开和收起两种状态
631
+ * @Author holyer
632
+ * @Date 2026/02/08 17:01:51
633
+ */
634
+ checkEllipsis() {
635
+ const textEl = this.$refs.textRef;
636
+ if (!textEl || !textEl.offsetParent) {
637
+ this.showToggle = false;
638
+ return;
639
+ }
640
+
641
+ if (this.isExpanded) {
642
+ // 展开状态下:模拟收起状态,检测是否需要 toggle
643
+ this.showToggle = this.wouldOverflowIfCollapsed(textEl);
644
+ } else {
645
+ // 收起状态下:直接检测是否溢出
646
+ this.showToggle = textEl.scrollHeight - textEl.clientHeight > 2;
647
+ }
648
+ },
649
+
650
+ /**
651
+ * 模拟收起状态,检测内容是否会溢出
652
+ */
653
+ wouldOverflowIfCollapsed(el) {
654
+ // 1. 保存原始状态
655
+ const originalDisplay = el.style.display;
656
+ const originalWebkitLineClamp = el.style.webkitLineClamp;
657
+ const originalClassList = el.className;
658
+
659
+ try {
660
+ // 2. 临时应用“收起”样式,移除 --expanded 和 --show-toggle
661
+ el.className = 'hi-expand-text--content';
662
+ el.style.display = '-webkit-box';
663
+ el.style.webkitBoxOrient = 'vertical';
664
+ el.style.overflow = 'hidden';
665
+ el.style.webkitLineClamp = this.lineClamp;
666
+
667
+ // 3. 强制 reflow(触发 layout)
668
+ const { scrollHeight, clientHeight } = el;
669
+
670
+ // 4. 判断是否溢出
671
+ return scrollHeight - clientHeight > 2;
672
+ } finally {
673
+ // 5. 恢复原始状态(确保无副作用)
674
+ el.className = originalClassList;
675
+ el.style.display = originalDisplay;
676
+ el.style.webkitLineClamp = originalWebkitLineClamp;
677
+ }
678
+ },
679
+
680
+ handleToggle() {
681
+ this.isExpanded = !this.isExpanded;
682
+ this.$emit('toggle', this.isExpanded);
683
+ },
684
+
685
+ // 供外部手动更新
686
+ update() {
687
+ this.$nextTick(this.checkEllipsis);
688
+ }
689
+ }
33
690
  };
34
691
 
35
- function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
692
+ function normalizeComponent$2(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
36
693
  if (typeof shadowMode !== 'boolean') {
37
694
  createInjectorSSR = createInjector;
38
695
  createInjector = shadowMode;
@@ -107,57 +764,717 @@ function normalizeComponent(template, style, script, scopeId, isFunctionalTempla
107
764
  return script;
108
765
  }
109
766
 
110
- const isOldIE = typeof navigator !== 'undefined' &&
111
- /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
112
- function createInjector(context) {
113
- return (id, style) => addStyle(id, style);
114
- }
115
- let HEAD;
116
- const styles = {};
117
- function addStyle(id, css) {
118
- const group = isOldIE ? css.media || 'default' : id;
119
- const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
120
- if (!style.ids.has(id)) {
121
- style.ids.add(id);
122
- let code = css.source;
123
- if (css.map) {
124
- // https://developer.chrome.com/devtools/docs/javascript-debugging
125
- // this makes source maps inside style tags work properly in Chrome
126
- code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
127
- // http://stackoverflow.com/a/26603875
128
- code +=
129
- '\n/*# sourceMappingURL=data:application/json;base64,' +
130
- btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
131
- ' */';
767
+ /* script */
768
+ const __vue_script__$2 = script$2;
769
+
770
+ /* template */
771
+ var __vue_render__$2 = function () {
772
+ var _vm = this;
773
+ var _h = _vm.$createElement;
774
+ var _c = _vm._self._c || _h;
775
+ return _c(
776
+ "div",
777
+ {
778
+ staticClass: "hi-expand-text",
779
+ style: { "--hi-expand-text-line-clamp": _vm.lineClamp },
780
+ },
781
+ [
782
+ _c(
783
+ "div",
784
+ { ref: "textRef", class: _vm.textClass },
785
+ [
786
+ _vm.showToggle
787
+ ? _c(
788
+ "div",
789
+ {
790
+ staticClass: "hi-expand-text--toggle",
791
+ on: { click: _vm.handleToggle },
792
+ },
793
+ [
794
+ _vm._t("toggleText", function () {
795
+ return [_vm._v(_vm._s(_vm.expandText))]
796
+ }),
797
+ ],
798
+ 2
799
+ )
800
+ : _vm._e(),
801
+ _vm._v(" "),
802
+ _vm._t("default", function () {
803
+ return [_vm._v(_vm._s(_vm.content))]
804
+ }),
805
+ ],
806
+ 2
807
+ ),
808
+ ]
809
+ )
810
+ };
811
+ var __vue_staticRenderFns__$2 = [];
812
+ __vue_render__$2._withStripped = true;
813
+
814
+ /* style */
815
+ const __vue_inject_styles__$2 = undefined;
816
+ /* scoped */
817
+ const __vue_scope_id__$2 = undefined;
818
+ /* module identifier */
819
+ const __vue_module_identifier__$2 = undefined;
820
+ /* functional template */
821
+ const __vue_is_functional_template__$2 = false;
822
+ /* style inject */
823
+
824
+ /* style inject SSR */
825
+
826
+ /* style inject shadow dom */
827
+
828
+
829
+
830
+ const __vue_component__$2 = /*#__PURE__*/normalizeComponent$2(
831
+ { render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 },
832
+ __vue_inject_styles__$2,
833
+ __vue_script__$2,
834
+ __vue_scope_id__$2,
835
+ __vue_is_functional_template__$2,
836
+ __vue_module_identifier__$2,
837
+ false,
838
+ undefined,
839
+ undefined,
840
+ undefined
841
+ );
842
+
843
+ __vue_component__$2.name = 'HiExpandText';
844
+
845
+ // 添加 install
846
+ __vue_component__$2.install = Vue => {
847
+ Vue.component(__vue_component__$2.name, __vue_component__$2);
848
+ };
849
+
850
+ function __$styleInject$1(css) {
851
+ if (!css) return;
852
+
853
+ if (typeof window == 'undefined') return;
854
+ var style = document.createElement('style');
855
+ style.setAttribute('media', 'screen');
856
+
857
+ style.innerHTML = css;
858
+ document.head.appendChild(style);
859
+ return css;
860
+ }
861
+
862
+ __$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");
863
+
864
+ //
865
+ const TITILE_SIZE_MAP = {
866
+ small: '14px',
867
+ medium: '16px',
868
+ large: '18px'
869
+ };
870
+ var script$1 = {
871
+ name: 'HiTitle',
872
+ inheritAttrs: false,
873
+ props: {
874
+ // 自定义图标类名
875
+ iconClass: {
876
+ type: String,
877
+ default: ''
878
+ },
879
+ // 主标题文本(优先级低于 default slot)
880
+ content: {
881
+ type: String,
882
+ default: ''
883
+ },
884
+ // 描述文本(优先级低于 description slot)
885
+ description: {
886
+ type: String,
887
+ default: ''
888
+ },
889
+ // 尺寸:控制整体大小(影响文字、图标、bar 高度)
890
+ size: {
891
+ type: String,
892
+ default: 'medium',
893
+ validator: val => ['small', 'medium', 'large'].includes(val)
894
+ },
895
+ // 主标题颜色(支持自定义)
896
+ color: {
897
+ type: String,
898
+ default: ''
899
+ },
900
+ // 自定义前缀图标组件
901
+ prefixIcon: {
902
+ type: [Object, Function],
903
+ default: null
904
+ },
905
+ // 自定义 bar 类名(用于覆盖样式)
906
+ barClass: {
907
+ type: String,
908
+ default: ''
909
+ },
910
+ // 自定义标题文字类名
911
+ textClass: {
912
+ type: String,
913
+ default: ''
914
+ },
915
+ // 自定义描述文字类名
916
+ descClass: {
917
+ type: String,
918
+ default: ''
919
+ }
920
+ },
921
+ computed: {
922
+ titleClass() {
923
+ return ['hi-title', `hi-title--${this.size}`, { 'hi-title--has-desc': this.hasDescription }];
924
+ },
925
+ // 根据 size 计算文字大小
926
+ textSize() {
927
+ return TITILE_SIZE_MAP[this.size] || TITILE_SIZE_MAP.medium;
928
+ },
929
+ // 图标大小 = 文字大小(保持视觉一致)
930
+ iconSize() {
931
+ return this.textSize;
932
+ },
933
+ // 装饰条高度 = 文字行高 ≈ 文字大小 * 1.2~1.5
934
+ barHeight() {
935
+ const base = parseFloat(TITILE_SIZE_MAP[this.size] || '16');
936
+ return `${base * 1.2}px`;
937
+ },
938
+ // 主标题颜色(props 优先,否则继承)
939
+ textColor() {
940
+ return this.color || 'inherit';
941
+ },
942
+ // 是否存在描述内容(用于控制布局)
943
+ hasDescription() {
944
+ return this.description || this.$slots.description;
945
+ }
946
+ }
947
+ };
948
+
949
+ function normalizeComponent$1(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
950
+ if (typeof shadowMode !== 'boolean') {
951
+ createInjectorSSR = createInjector;
952
+ createInjector = shadowMode;
953
+ shadowMode = false;
954
+ }
955
+ // Vue.extend constructor export interop.
956
+ const options = typeof script === 'function' ? script.options : script;
957
+ // render functions
958
+ if (template && template.render) {
959
+ options.render = template.render;
960
+ options.staticRenderFns = template.staticRenderFns;
961
+ options._compiled = true;
962
+ // functional template
963
+ if (isFunctionalTemplate) {
964
+ options.functional = true;
965
+ }
966
+ }
967
+ // scopedId
968
+ if (scopeId) {
969
+ options._scopeId = scopeId;
970
+ }
971
+ let hook;
972
+ if (moduleIdentifier) {
973
+ // server build
974
+ hook = function (context) {
975
+ // 2.3 injection
976
+ context =
977
+ context || // cached call
978
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
979
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
980
+ // 2.2 with runInNewContext: true
981
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
982
+ context = __VUE_SSR_CONTEXT__;
983
+ }
984
+ // inject component styles
985
+ if (style) {
986
+ style.call(this, createInjectorSSR(context));
987
+ }
988
+ // register component module identifier for async chunk inference
989
+ if (context && context._registeredComponents) {
990
+ context._registeredComponents.add(moduleIdentifier);
991
+ }
992
+ };
993
+ // used by ssr in case component is cached and beforeCreate
994
+ // never gets called
995
+ options._ssrRegister = hook;
996
+ }
997
+ else if (style) {
998
+ hook = shadowMode
999
+ ? function (context) {
1000
+ style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
1001
+ }
1002
+ : function (context) {
1003
+ style.call(this, createInjector(context));
1004
+ };
1005
+ }
1006
+ if (hook) {
1007
+ if (options.functional) {
1008
+ // register for functional component in vue file
1009
+ const originalRender = options.render;
1010
+ options.render = function renderWithStyleInjection(h, context) {
1011
+ hook.call(context);
1012
+ return originalRender(h, context);
1013
+ };
132
1014
  }
133
- if (!style.element) {
134
- style.element = document.createElement('style');
135
- style.element.type = 'text/css';
136
- if (css.media)
137
- style.element.setAttribute('media', css.media);
138
- if (HEAD === undefined) {
139
- HEAD = document.head || document.getElementsByTagName('head')[0];
140
- }
141
- HEAD.appendChild(style.element);
1015
+ else {
1016
+ // inject component registration as beforeCreate hook
1017
+ const existing = options.beforeCreate;
1018
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
1019
+ }
1020
+ }
1021
+ return script;
1022
+ }
1023
+
1024
+ /* script */
1025
+ const __vue_script__$1 = script$1;
1026
+
1027
+ /* template */
1028
+ var __vue_render__$1 = function () {
1029
+ var _vm = this;
1030
+ var _h = _vm.$createElement;
1031
+ var _c = _vm._self._c || _h;
1032
+ return _c(
1033
+ "div",
1034
+ _vm._b({ class: _vm.titleClass }, "div", _vm.$attrs, false),
1035
+ [
1036
+ _c("div", { staticClass: "hi-title__header" }, [
1037
+ _c(
1038
+ "div",
1039
+ { staticClass: "hi-title__prefix" },
1040
+ [
1041
+ _vm._t("prefix", function () {
1042
+ return [
1043
+ _vm.prefixIcon
1044
+ ? _c(_vm.prefixIcon, {
1045
+ tag: "component",
1046
+ class: ["hi-title__icon", _vm.iconClass],
1047
+ style: { fontSize: _vm.iconSize },
1048
+ })
1049
+ : _c("div", {
1050
+ class: ["hi-title__bar", _vm.barClass],
1051
+ style: { height: _vm.barHeight },
1052
+ }),
1053
+ ]
1054
+ }),
1055
+ ],
1056
+ 2
1057
+ ),
1058
+ _vm._v(" "),
1059
+ _vm.content || _vm.$slots.default
1060
+ ? _c(
1061
+ "div",
1062
+ {
1063
+ class: ["hi-title__text", _vm.textClass],
1064
+ style: {
1065
+ color: _vm.textColor,
1066
+ fontSize: _vm.textSize,
1067
+ },
1068
+ },
1069
+ [
1070
+ _vm._t("default", function () {
1071
+ return [_vm._v(_vm._s(_vm.content))]
1072
+ }),
1073
+ ],
1074
+ 2
1075
+ )
1076
+ : _vm._e(),
1077
+ ]),
1078
+ _vm._v(" "),
1079
+ _vm.hasDescription
1080
+ ? _c(
1081
+ "p",
1082
+ { class: ["hi-title__description", _vm.descClass] },
1083
+ [
1084
+ _vm._t("description", function () {
1085
+ return [_vm._v(_vm._s(_vm.description))]
1086
+ }),
1087
+ ],
1088
+ 2
1089
+ )
1090
+ : _vm._e(),
1091
+ ]
1092
+ )
1093
+ };
1094
+ var __vue_staticRenderFns__$1 = [];
1095
+ __vue_render__$1._withStripped = true;
1096
+
1097
+ /* style */
1098
+ const __vue_inject_styles__$1 = undefined;
1099
+ /* scoped */
1100
+ const __vue_scope_id__$1 = undefined;
1101
+ /* module identifier */
1102
+ const __vue_module_identifier__$1 = undefined;
1103
+ /* functional template */
1104
+ const __vue_is_functional_template__$1 = false;
1105
+ /* style inject */
1106
+
1107
+ /* style inject SSR */
1108
+
1109
+ /* style inject shadow dom */
1110
+
1111
+
1112
+
1113
+ const __vue_component__$1 = /*#__PURE__*/normalizeComponent$1(
1114
+ { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
1115
+ __vue_inject_styles__$1,
1116
+ __vue_script__$1,
1117
+ __vue_scope_id__$1,
1118
+ __vue_is_functional_template__$1,
1119
+ __vue_module_identifier__$1,
1120
+ false,
1121
+ undefined,
1122
+ undefined,
1123
+ undefined
1124
+ );
1125
+
1126
+ // 显式设置 name(避免 .vue 丢失)
1127
+ __vue_component__$1.name = 'HiTitle';
1128
+
1129
+ // 添加 install
1130
+ __vue_component__$1.install = Vue => {
1131
+ Vue.component(__vue_component__$1.name, __vue_component__$1);
1132
+ };
1133
+
1134
+ function __$styleInject(css) {
1135
+ if (!css) return;
1136
+
1137
+ if (typeof window == 'undefined') return;
1138
+ var style = document.createElement('style');
1139
+ style.setAttribute('media', 'screen');
1140
+
1141
+ style.innerHTML = css;
1142
+ document.head.appendChild(style);
1143
+ return css;
1144
+ }
1145
+
1146
+ __$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");
1147
+
1148
+ /**
1149
+ * 类型判断工具
1150
+ */
1151
+
1152
+ /**
1153
+ * 将数值或字符串转换为合法的 CSS 长度值(用于 style 绑定)
1154
+ * - 若为 number,自动追加 'px' 单位
1155
+ * - 若为 string,原样返回(假定用户已提供合法 CSS 长度值)
1156
+ * @param {number|string} value - 输入值(如 100, '100%', '50vh', 'auto')
1157
+ * @returns {string} 合法的 CSS 长度字符串 默认值为 0
1158
+ * @example
1159
+ * formatSize(100) // '100px'
1160
+ * formatSize('100%') // '100%'
1161
+ * formatSize('50vh') // '50vh'
1162
+ * formatSize(null) // 0
1163
+ * formatSize(undefined) // 0
1164
+ */
1165
+ function formatSize(value) {
1166
+ if (typeof value === 'number') {
1167
+ return `${value}px`;
1168
+ }
1169
+ if (typeof value === 'string') {
1170
+ if (value.trim() === '') {
1171
+ return 0;
1172
+ }
1173
+ return value;
1174
+ }
1175
+ return 0;
1176
+ }
1177
+
1178
+ //
1179
+
1180
+ var script = {
1181
+ name: 'HiVirtualList',
1182
+ props: {
1183
+ items: {
1184
+ type: Array,
1185
+ required: true,
1186
+ default: () => []
1187
+ },
1188
+ itemHeight: {
1189
+ type: Number,
1190
+ required: true,
1191
+ validator(value) {
1192
+ if (value <= 0) {
1193
+ // eslint-disable-next-line no-console
1194
+ console.error('[HiVirtualList] itemHeight must be a positive number.');
1195
+ return false;
1196
+ }
1197
+ return true;
1198
+ }
1199
+ },
1200
+ height: {
1201
+ type: [Number, String],
1202
+ required: true
1203
+ },
1204
+ buffer: {
1205
+ type: Number,
1206
+ default: 50
1207
+ },
1208
+ nodeKey: {
1209
+ type: String,
1210
+ default: undefined
1211
+ }
1212
+ },
1213
+ data() {
1214
+ return {
1215
+ scrollTop: 0,
1216
+ clientHeight: 0,
1217
+ resizeObserver: null,
1218
+ resizeTimer: null
1219
+ };
1220
+ },
1221
+ computed: {
1222
+ styles() {
1223
+ return {
1224
+ height: formatSize(this.height)
1225
+ };
1226
+ },
1227
+ renderItemHeight() {
1228
+ return formatSize(this.itemHeight);
1229
+ },
1230
+ total() {
1231
+ return this.items.length;
1232
+ },
1233
+ visibleCount() {
1234
+ if (!this.clientHeight || !this.itemHeight) return 20;
1235
+ return Math.ceil(this.clientHeight / this.itemHeight) + this.buffer * 2;
1236
+ },
1237
+ startIndex() {
1238
+ return Math.max(0, Math.floor(this.scrollTop / this.itemHeight));
1239
+ },
1240
+ endIndex() {
1241
+ return Math.min(this.total, this.startIndex + this.visibleCount);
1242
+ },
1243
+ visibleItems() {
1244
+ return this.items.slice(this.startIndex, this.endIndex);
1245
+ },
1246
+ topPlaceholderHeight() {
1247
+ return formatSize(this.startIndex * this.itemHeight);
1248
+ },
1249
+ bottomPlaceholderHeight() {
1250
+ return formatSize((this.total - this.endIndex) * this.itemHeight);
1251
+ }
1252
+ },
1253
+ mounted() {
1254
+ this.updateClientHeight();
1255
+ this.setupResizeListener();
1256
+ },
1257
+ beforeDestroy() {
1258
+ this.cleanupResizeListener();
1259
+ },
1260
+ methods: {
1261
+ /**
1262
+ * 判断是否应使用 nodeKey 字段
1263
+ */
1264
+ _shouldUseNodeKey() {
1265
+ return this.nodeKey && typeof this.nodeKey === 'string' && this.nodeKey.trim() !== '';
1266
+ },
1267
+
1268
+ /**
1269
+ * 获取 item 的唯一 key(用于 v-for)
1270
+ */
1271
+ getNodeKey(item, index) {
1272
+ if (this._shouldUseNodeKey() && item != null && typeof item === 'object') {
1273
+ const key = item[this.nodeKey];
1274
+ if (key != null) {
1275
+ return key;
1276
+ }
1277
+ }
1278
+ return index;
1279
+ },
1280
+
1281
+ updateClientHeight() {
1282
+ if (this.$refs.rootRef) {
1283
+ this.clientHeight = this.$refs.rootRef.clientHeight;
1284
+ }
1285
+ },
1286
+
1287
+ setupResizeListener() {
1288
+ if (typeof ResizeObserver !== 'undefined') {
1289
+ this.resizeObserver = new ResizeObserver(() => {
1290
+ this.updateClientHeight();
1291
+ });
1292
+ this.resizeObserver.observe(this.$refs.rootRef);
1293
+ } else {
1294
+ window.addEventListener('resize', this.handleWindowResize);
1295
+ }
1296
+ },
1297
+
1298
+ cleanupResizeListener() {
1299
+ if (this.resizeObserver) {
1300
+ this.resizeObserver.disconnect();
1301
+ this.resizeObserver = null;
1302
+ }
1303
+ if (this.resizeTimer) {
1304
+ clearTimeout(this.resizeTimer);
1305
+ this.resizeTimer = null;
1306
+ }
1307
+ window.removeEventListener('resize', this.handleWindowResize);
1308
+ },
1309
+
1310
+ handleWindowResize() {
1311
+ if (this.resizeTimer) {
1312
+ clearTimeout(this.resizeTimer);
1313
+ }
1314
+ this.resizeTimer = setTimeout(() => {
1315
+ this.updateClientHeight();
1316
+ }, 100);
1317
+ },
1318
+
1319
+ handleScroll(e) {
1320
+ this.scrollTop = e.target.scrollTop;
1321
+ this.$emit('scroll', e);
1322
+
1323
+ const { scrollHeight, clientHeight, scrollTop } = e.target;
1324
+ if (scrollTop === 0) this.$emit('reach-top');
1325
+ if (scrollHeight - clientHeight - scrollTop < 100) this.$emit('reach-bottom');
1326
+ this.$emit('visible-change', { startIndex: this.startIndex, endIndex: this.endIndex });
1327
+ },
1328
+
1329
+ refresh() {
1330
+ this.updateClientHeight();
1331
+ },
1332
+
1333
+ /**
1334
+ * 内部滚动方法(仅设置 DOM scrollTop,状态由 handleScroll 同步)
1335
+ */
1336
+ _setScrollTop(scrollTop) {
1337
+ if (this.$refs.rootRef) {
1338
+ this.$refs.rootRef.scrollTop = scrollTop;
1339
+ }
1340
+ },
1341
+
1342
+ /**
1343
+ * 滚动到指定目标
1344
+ * - 若启用了有效的 nodeKey,则 target 视为 keyValue
1345
+ * - 否则,target 必须是 number(index)
1346
+ */
1347
+ scrollTo(target) {
1348
+ if (target == null) {
1349
+ // eslint-disable-next-line no-console
1350
+ console.warn('[HiVirtualList] scrollTo: target cannot be null or undefined');
1351
+ return;
1352
+ }
1353
+
1354
+ let index = -1;
1355
+
1356
+ // 使用 getNodeKey 生成的 key 进行匹配(严格对齐)
1357
+ if (this._shouldUseNodeKey()) {
1358
+ index = this.items.findIndex((item, i) => {
1359
+ return this.getNodeKey(item, i) === target;
1360
+ });
1361
+ } else {
1362
+ // 降级到 index 模式
1363
+ if (typeof target === 'number' && target >= 0 && target < this.total) {
1364
+ index = target;
1365
+ } else {
1366
+ // eslint-disable-next-line no-console
1367
+ console.warn(
1368
+ '[HiVirtualList] scrollTo: when nodeKey is not provided, target must be a valid index (number).'
1369
+ );
1370
+ return;
1371
+ }
1372
+ }
1373
+
1374
+ if (index < 0 || index >= this.total) {
1375
+ if (this._shouldUseNodeKey()) {
1376
+ // eslint-disable-next-line no-console
1377
+ console.warn(`[HiVirtualList] scrollTo: item with key "${target}" not found`);
1378
+ } else {
1379
+ // eslint-disable-next-line no-console
1380
+ console.warn(`[HiVirtualList] scrollTo: index ${target} is out of range [0, ${this.total})`);
1381
+ }
1382
+ return;
1383
+ }
1384
+
1385
+ this._setScrollTop(index * this.itemHeight);
1386
+ },
1387
+
1388
+ scrollToTop() {
1389
+ this._setScrollTop(0);
1390
+ },
1391
+
1392
+ scrollToBottom() {
1393
+ this._setScrollTop(this.total * this.itemHeight);
1394
+ },
1395
+
1396
+ getVisibleRange() {
1397
+ return {
1398
+ startIndex: this.startIndex,
1399
+ endIndex: this.endIndex
1400
+ };
1401
+ }
1402
+ }
1403
+ };
1404
+
1405
+ function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
1406
+ if (typeof shadowMode !== 'boolean') {
1407
+ createInjectorSSR = createInjector;
1408
+ createInjector = shadowMode;
1409
+ shadowMode = false;
1410
+ }
1411
+ // Vue.extend constructor export interop.
1412
+ const options = typeof script === 'function' ? script.options : script;
1413
+ // render functions
1414
+ if (template && template.render) {
1415
+ options.render = template.render;
1416
+ options.staticRenderFns = template.staticRenderFns;
1417
+ options._compiled = true;
1418
+ // functional template
1419
+ if (isFunctionalTemplate) {
1420
+ options.functional = true;
142
1421
  }
143
- if ('styleSheet' in style.element) {
144
- style.styles.push(code);
145
- style.element.styleSheet.cssText = style.styles
146
- .filter(Boolean)
147
- .join('\n');
1422
+ }
1423
+ // scopedId
1424
+ if (scopeId) {
1425
+ options._scopeId = scopeId;
1426
+ }
1427
+ let hook;
1428
+ if (moduleIdentifier) {
1429
+ // server build
1430
+ hook = function (context) {
1431
+ // 2.3 injection
1432
+ context =
1433
+ context || // cached call
1434
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
1435
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
1436
+ // 2.2 with runInNewContext: true
1437
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
1438
+ context = __VUE_SSR_CONTEXT__;
1439
+ }
1440
+ // inject component styles
1441
+ if (style) {
1442
+ style.call(this, createInjectorSSR(context));
1443
+ }
1444
+ // register component module identifier for async chunk inference
1445
+ if (context && context._registeredComponents) {
1446
+ context._registeredComponents.add(moduleIdentifier);
1447
+ }
1448
+ };
1449
+ // used by ssr in case component is cached and beforeCreate
1450
+ // never gets called
1451
+ options._ssrRegister = hook;
1452
+ }
1453
+ else if (style) {
1454
+ hook = shadowMode
1455
+ ? function (context) {
1456
+ style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
1457
+ }
1458
+ : function (context) {
1459
+ style.call(this, createInjector(context));
1460
+ };
1461
+ }
1462
+ if (hook) {
1463
+ if (options.functional) {
1464
+ // register for functional component in vue file
1465
+ const originalRender = options.render;
1466
+ options.render = function renderWithStyleInjection(h, context) {
1467
+ hook.call(context);
1468
+ return originalRender(h, context);
1469
+ };
148
1470
  }
149
1471
  else {
150
- const index = style.ids.size - 1;
151
- const textNode = document.createTextNode(code);
152
- const nodes = style.element.childNodes;
153
- if (nodes[index])
154
- style.element.removeChild(nodes[index]);
155
- if (nodes.length)
156
- style.element.insertBefore(textNode, nodes[index]);
157
- else
158
- style.element.appendChild(textNode);
1472
+ // inject component registration as beforeCreate hook
1473
+ const existing = options.beforeCreate;
1474
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
159
1475
  }
160
1476
  }
1477
+ return script;
161
1478
  }
162
1479
 
163
1480
  /* script */
@@ -168,25 +1485,54 @@ var __vue_render__ = function () {
168
1485
  var _vm = this;
169
1486
  var _h = _vm.$createElement;
170
1487
  var _c = _vm._self._c || _h;
171
- return _c("div", { staticClass: "hi-title" }, [
172
- _vm._v("\n " + _vm._s(_vm.content) + "\n"),
173
- ])
1488
+ return _c(
1489
+ "div",
1490
+ {
1491
+ ref: "rootRef",
1492
+ staticClass: "hi-virtual-list",
1493
+ style: _vm.styles,
1494
+ on: { scroll: _vm.handleScroll },
1495
+ },
1496
+ [
1497
+ _c("div", {
1498
+ staticClass: "hi-virtual-list--placeholder",
1499
+ style: { height: _vm.topPlaceholderHeight },
1500
+ }),
1501
+ _vm._v(" "),
1502
+ _vm._l(_vm.visibleItems, function (item, i) {
1503
+ return _c(
1504
+ "div",
1505
+ {
1506
+ key: _vm.getNodeKey(item, _vm.startIndex + i),
1507
+ staticClass: "hi-virtual-list--item-wrapper",
1508
+ style: { height: _vm.renderItemHeight },
1509
+ },
1510
+ [_vm._t("default", null, { item: item, index: _vm.startIndex + i })],
1511
+ 2
1512
+ )
1513
+ }),
1514
+ _vm._v(" "),
1515
+ _c("div", {
1516
+ staticClass: "hi-virtual-list--placeholder",
1517
+ style: { height: _vm.bottomPlaceholderHeight },
1518
+ }),
1519
+ ],
1520
+ 2
1521
+ )
174
1522
  };
175
1523
  var __vue_staticRenderFns__ = [];
176
1524
  __vue_render__._withStripped = true;
177
1525
 
178
1526
  /* style */
179
- const __vue_inject_styles__ = function (inject) {
180
- if (!inject) return
181
- inject("data-v-03a3ffda_0", { source: "\n.title[data-v-03a3ffda] {\n text-align: center;\n margin: 20px 0;\n}\n", map: {"version":3,"sources":["/home/runner/work/holyer-lib/holyer-lib/packages/ui/title/src/index.vue"],"names":[],"mappings":";AAoBA;EACA,kBAAA;EACA,cAAA;AACA","file":"index.vue","sourcesContent":["<template>\n <div class=\"hi-title\">\n {{ content }}\n </div>\n</template>\n\n<script>\nexport default {\n name: 'HiTitle',\n props: {\n content: {\n type: String,\n default: '标题'\n }\n },\n data() {}\n};\n</script>\n\n<style scoped>\n.title {\n text-align: center;\n margin: 20px 0;\n}\n</style>\n"]}, media: undefined });
182
-
183
- };
1527
+ const __vue_inject_styles__ = undefined;
184
1528
  /* scoped */
185
- const __vue_scope_id__ = "data-v-03a3ffda";
1529
+ const __vue_scope_id__ = undefined;
186
1530
  /* module identifier */
187
1531
  const __vue_module_identifier__ = undefined;
188
1532
  /* functional template */
189
1533
  const __vue_is_functional_template__ = false;
1534
+ /* style inject */
1535
+
190
1536
  /* style inject SSR */
191
1537
 
192
1538
  /* style inject shadow dom */
@@ -201,12 +1547,26 @@ __vue_render__._withStripped = true;
201
1547
  __vue_is_functional_template__,
202
1548
  __vue_module_identifier__,
203
1549
  false,
204
- createInjector,
1550
+ undefined,
205
1551
  undefined,
206
1552
  undefined
207
1553
  );
208
1554
 
209
- const components = [__vue_component__];
1555
+ // 显式设置 name(避免 .vue 丢失)
1556
+ __vue_component__.name = 'HiVirtualList';
1557
+
1558
+ // 添加 install
1559
+ __vue_component__.install = Vue => {
1560
+ Vue.component(__vue_component__.name, __vue_component__);
1561
+ };
1562
+
1563
+ // eslint-disable-next-line prettier/prettier
1564
+ const components = [
1565
+ __vue_component__$3,
1566
+ __vue_component__$2,
1567
+ __vue_component__$1,
1568
+ __vue_component__
1569
+ ];
210
1570
 
211
1571
  const install = function (Vue) {
212
1572
  components.forEach(component => {
@@ -214,6 +1574,12 @@ const install = function (Vue) {
214
1574
  });
215
1575
  };
216
1576
 
217
- var index = { install, HiTitle: __vue_component__ };
1577
+ var index = {
1578
+ install,
1579
+ HiExpandPanel: __vue_component__$3,
1580
+ HiExpandText: __vue_component__$2,
1581
+ HiTitle: __vue_component__$1,
1582
+ HiVirtualList: __vue_component__
1583
+ };
218
1584
 
219
1585
  module.exports = index;