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