@holyer-lib/ui 0.1.0 → 0.2.1

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