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