qidian-vue-ui 2.0.9 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
- .qd-dict-tag[data-v-b88cab23] {
1
+ .qd-dict-tag[data-v-e8a6ce9c] {
2
2
  display: inline-flex;
3
3
  align-items: center;
4
4
  flex-wrap: wrap;
5
5
  }
6
+ .qd-dict-tag[data-v-e8a6ce9c] > .t-loading {
7
+ position: static;
8
+ }
@@ -2,7 +2,7 @@ import './index.css'
2
2
  import _sfc_main from "./index.vue2.mjs";
3
3
  /* empty css */
4
4
  import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.mjs";
5
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b88cab23"]]);
5
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-e8a6ce9c"]]);
6
6
  export {
7
7
  index as default
8
8
  };
@@ -1,66 +1,66 @@
1
- .qd-service-table[data-v-ee419bfb] {
1
+ .qd-service-table[data-v-98a1baeb] {
2
2
  height: 100%;
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  }
6
- .qd-service-table[data-v-ee419bfb] > .t-table__content {
6
+ .qd-service-table[data-v-98a1baeb] > .t-table__content {
7
7
  flex: 1;
8
8
  }
9
- .qd-service-table--mini[data-v-ee419bfb] {
9
+ .qd-service-table--mini[data-v-98a1baeb] {
10
10
  font: var(--td-font-body-small);
11
11
  }
12
- .qd-service-table--mini[data-v-ee419bfb] th,
13
- .qd-service-table--mini[data-v-ee419bfb] tr:not(.t-table__expanded-row) > td {
12
+ .qd-service-table--mini[data-v-98a1baeb] th,
13
+ .qd-service-table--mini[data-v-98a1baeb] tr:not(.t-table__expanded-row) > td {
14
14
  padding: var(--td-comp-paddingTB-xxs) var(--td-comp-paddingLR-xxs);
15
15
  line-height: var(--td-line-height-body-small);
16
16
  }
17
- .qd-service-table[data-v-ee419bfb] .t-table__tree-col:not(:has(.t-table__tree-op-icon)) {
17
+ .qd-service-table[data-v-98a1baeb] .t-table__tree-col:not(:has(.t-table__tree-op-icon)) {
18
18
  margin-left: calc(var(--td-font-size-body-large) + var(--td-comp-margin-s));
19
19
  }
20
- .qd-service-table[data-v-ee419bfb] .t-table__tree-leaf-node .t-table__tree-op-icon:empty {
20
+ .qd-service-table[data-v-98a1baeb] .t-table__tree-leaf-node .t-table__tree-op-icon:empty {
21
21
  width: calc(var(--td-font-size-body-large) + var(--td-comp-margin-s));
22
22
  }
23
- .qd-service-table[data-v-ee419bfb] .t-affix > .t-table__affixed-header-elm-wrap,
24
- .qd-service-table[data-v-ee419bfb] .t-affix > .t-table__scrollbar--obvious {
25
- transform: var(--v5f2dd170);
23
+ .qd-service-table[data-v-98a1baeb] .t-affix > .t-table__affixed-header-elm-wrap,
24
+ .qd-service-table[data-v-98a1baeb] .t-affix > .t-table__scrollbar--obvious {
25
+ transform: var(--dfe9a5de);
26
26
  }
27
- .qd-service-table--horizontal-bar-static[data-v-ee419bfb] .t-table__scrollbar--obvious {
27
+ .qd-service-table--horizontal-bar-static[data-v-98a1baeb] .t-table__scrollbar--obvious {
28
28
  visibility: hidden;
29
29
  pointer-events: none;
30
30
  }
31
- .qd-service-table[data-v-ee419bfb] .t-table__affixed-header-elm-wrap {
31
+ .qd-service-table[data-v-98a1baeb] .t-table__affixed-header-elm-wrap {
32
32
  height: auto !important;
33
33
  }
34
- .qd-service-table[data-v-ee419bfb] .t-table__affixed-header-elm {
34
+ .qd-service-table[data-v-98a1baeb] .t-table__affixed-header-elm {
35
35
  position: relative;
36
36
  scrollbar-width: none;
37
37
  }
38
- .qd-service-table[data-v-ee419bfb] .t-table__affixed-header-elm::-webkit-scrollbar {
38
+ .qd-service-table[data-v-98a1baeb] .t-table__affixed-header-elm::-webkit-scrollbar {
39
39
  display: none;
40
40
  width: 0;
41
41
  height: 0;
42
42
  }
43
- .qd-service-table[data-v-ee419bfb] .t-table__virtual-scroll-cursor + table {
43
+ .qd-service-table[data-v-98a1baeb] .t-table__virtual-scroll-cursor + table {
44
44
  border-collapse: separate;
45
45
  }
46
- .qd-service-table[data-v-ee419bfb] .t-table__expanded-row-inner {
46
+ .qd-service-table[data-v-98a1baeb] .t-table__expanded-row-inner {
47
47
  position: sticky;
48
48
  left: 0;
49
- width: var(--v1d473786) !important;
49
+ width: var(--v7ade7674) !important;
50
50
  }
51
- .qd-service-table[data-v-ee419bfb] .t-table__cell-wrap > *:not(.t-switch):not(.t-tag):not(.t-icon):not(.qd-file-icon) {
51
+ .qd-service-table[data-v-98a1baeb] .t-table__cell-wrap > *:not(.t-switch):not(.t-tag):not(.t-icon):not(.qd-file-icon) {
52
52
  width: 100%;
53
53
  }
54
- .qd-service-table[data-v-ee419bfb] .qd-service-table__non-editable-col {
54
+ .qd-service-table[data-v-98a1baeb] .qd-service-table__non-editable-col {
55
55
  background-color: color-mix(in srgb, var(--td-bg-color-component) 50%, transparent);
56
56
  }
57
- .qd-service-table[data-v-ee419bfb] .qd-service-table__non-editable-col:is(
57
+ .qd-service-table[data-v-98a1baeb] .qd-service-table__non-editable-col:is(
58
58
  .t-table__cell--fixed-left,
59
59
  .t-table__cell--fixed-right
60
60
  ) {
61
61
  background-color: inherit;
62
62
  background-image: linear-gradient(color-mix(in srgb, var(--td-bg-color-secondarycontainer) 50%, transparent), color-mix(in srgb, var(--td-bg-color-secondarycontainer) 50%, transparent));
63
63
  }
64
- .qd-service-table--disable-horizontal-scroll[data-v-ee419bfb] colgroup > col {
64
+ .qd-service-table--disable-horizontal-scroll[data-v-98a1baeb] colgroup > col {
65
65
  width: auto !important;
66
66
  }
@@ -2,7 +2,7 @@ import './index.css'
2
2
  import _sfc_main from "./index.vue2.mjs";
3
3
  /* empty css */
4
4
  import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.mjs";
5
- const QdServiceTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ee419bfb"]]);
5
+ const QdServiceTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-98a1baeb"]]);
6
6
  export {
7
7
  QdServiceTable as default
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import './index.css'
2
2
  import { defineComponent, mergeDefaults, useCssVars, computed, ref, useSlots, useTemplateRef, shallowRef, inject, getCurrentInstance, reactive, createVNode, watch, nextTick, onMounted, onActivated, onDeactivated, onBeforeUnmount, withDirectives, createBlock, openBlock, resolveDynamicComponent, unref, mergeProps, isRef, createSlots, withCtx, renderList, renderSlot, normalizeProps, guardReactiveProps, render, h } from "vue";
3
3
  import { useVModels, useElementSize, useElementBounding, useIntersectionObserver } from "../../../node_modules/.pnpm/@vueuse_core@14.2.0_vue@3.5.26_typescript@5.9.3_/node_modules/@vueuse/core/dist/index.mjs";
4
- import { useActivated, useTimer, easyCopy, isEmpty, suspectedWrapperPromise, useServicePagination, createExposeProxy, resizeDirective, getScrollEl } from "qidian-shared";
4
+ import { useActivated, useTimer, easyCopy, isEmpty, suspectedWrapperPromise, getScrollEl, useServicePagination, createExposeProxy, resizeDirective } from "qidian-shared";
5
5
  import { LoadingIcon, AddRectangleIcon, MinusRectangleIcon } from "tdesign-icons-vue-next";
6
6
  import { EnhancedTable, Table, Empty } from "tdesign-vue-next";
7
7
  import { validate } from "tdesign-vue-next/es/form/utils/form-model.mjs";
@@ -19,6 +19,7 @@ const defaultMinWidth = 80;
19
19
  const defaultVirtualScrollBufferSize = 2;
20
20
  const defaultVirtualScrollUpdateInterval = 16;
21
21
  const minVirtualScrollUpdateInterval = 8;
22
+ const scrollRestoreMaxAttempts = 4;
22
23
  const _sfc_main = /* @__PURE__ */ defineComponent({
23
24
  ...{
24
25
  name: "QdServiceTable"
@@ -320,8 +321,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
320
321
  emit: __emit
321
322
  }) {
322
323
  useCssVars((_ctx) => ({
323
- "v5f2dd170": affixedHeaderTransform.value,
324
- "v1d473786": expandedRowWidth.value
324
+ "dfe9a5de": affixedHeaderTransform.value,
325
+ "v7ade7674": expandedRowWidth.value
325
326
  }));
326
327
  const props = __props;
327
328
  const emit = __emit;
@@ -413,8 +414,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
413
414
  let offscreenInstance = null;
414
415
  const scrollRecord = {
415
416
  top: 0,
416
- left: 0
417
+ left: 0,
418
+ bottom: false
417
419
  };
420
+ let scrollRestoreRafId = 0;
418
421
  const outsideScrollEl = ref(null);
419
422
  const tableHeaderEl = ref(null);
420
423
  const tableContentEl = ref(null);
@@ -431,10 +434,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
431
434
  return width > 0 ? `${width}px` : "auto";
432
435
  });
433
436
  const affixBottomOffset = ref(0);
434
- const horizontalAffixBottomOffset = computed(() => {
435
- if (!outsideScrollEl.value) return affixBottomOffset.value;
436
- return Math.max(0, window.innerHeight - outsideScrollRect.bottom + affixBottomOffset.value);
437
- });
438
437
  const {
439
438
  timer: probeDelayTimer,
440
439
  clearTimer: clearProbeDelayTimer
@@ -649,12 +648,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
649
648
  onScroll?.(params);
650
649
  const target = params.e.target;
651
650
  if (!target) return;
651
+ if (!activated.value) return;
652
652
  const {
653
653
  scrollTop,
654
- scrollLeft
654
+ scrollLeft,
655
+ scrollHeight,
656
+ clientHeight
655
657
  } = target;
656
658
  scrollRecord.top = scrollTop;
657
659
  scrollRecord.left = scrollLeft;
660
+ scrollRecord.bottom = !isVirtualScroll.value && Math.abs(scrollHeight - clientHeight - scrollTop) <= 1;
658
661
  };
659
662
  const reOnCellClick = (context) => {
660
663
  handleCellClick(context);
@@ -678,11 +681,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
678
681
  ...horizontalScrollAffixProps
679
682
  } = typeof horizontalScrollAffixedBottom === "object" ? horizontalScrollAffixedBottom : {};
680
683
  const reHorizontalScrollAffixedBottom = horizontalScrollAffixedBottom === false ? false : {
681
- ...outsideScrollEl.value ? {
682
- container: () => outsideScrollEl.value
683
- } : {},
684
+ container: () => outsideScrollEl.value ?? getScrollEl(tableRef.value?.$el),
684
685
  ...horizontalScrollAffixProps,
685
- offsetBottom: horizontalScrollOffsetBottom + horizontalAffixBottomOffset.value,
686
+ offsetBottom: horizontalScrollOffsetBottom + affixBottomOffset.value,
686
687
  onFixedChange: (...args) => {
687
688
  const [affixed, context] = args;
688
689
  onHorizontalScrollFixedChange?.(affixed, context);
@@ -705,9 +706,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
705
706
  ...headerAffixProps
706
707
  } = headerAffixOptions;
707
708
  const reHeaderAffixedTop = headerAffixedTop && headerAffixedNeeded.value ? {
708
- ...outsideScrollEl.value ? {
709
- container: () => outsideScrollEl.value
710
- } : {},
709
+ container: () => outsideScrollEl.value ?? getScrollEl(tableRef.value?.$el),
711
710
  ...headerAffixProps,
712
711
  onFixedChange: (...args) => {
713
712
  const [affixed, context] = args;
@@ -1585,25 +1584,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1585
1584
  return reColumn;
1586
1585
  });
1587
1586
  }
1588
- function setScrollElTo() {
1589
- const el = tableRef.value?.$el;
1590
- if (!el) return;
1591
- const scrollEl = tableContentEl.value;
1587
+ function getCurrentTableContentEl() {
1588
+ const rootEl = tableRef.value?.$el ?? currentInstance?.proxy?.$el;
1589
+ if (!(rootEl instanceof HTMLElement)) return tableContentEl.value;
1590
+ return rootEl.querySelector(".t-table__content") ?? tableContentEl.value;
1591
+ }
1592
+ function setScrollElTo(position = scrollRecord) {
1593
+ const scrollEl = getCurrentTableContentEl();
1592
1594
  if (!scrollEl) return;
1593
1595
  const {
1594
1596
  scrollTop,
1595
1597
  scrollLeft
1596
1598
  } = scrollEl;
1597
1599
  const {
1598
- top,
1599
1600
  left
1600
- } = scrollRecord;
1601
+ } = position;
1602
+ const top = position.bottom && !isVirtualScroll.value ? Math.max(scrollEl.scrollHeight - scrollEl.clientHeight, 0) : position.top;
1601
1603
  if (top === scrollTop && left === scrollLeft) return;
1602
1604
  scrollEl.scrollTo({
1603
1605
  top,
1604
1606
  left
1605
1607
  });
1606
1608
  }
1609
+ function cancelScrollRestore() {
1610
+ if (!scrollRestoreRafId) return;
1611
+ cancelAnimationFrame(scrollRestoreRafId);
1612
+ scrollRestoreRafId = 0;
1613
+ }
1614
+ function scheduleScrollRestore(position, attempts = scrollRestoreMaxAttempts) {
1615
+ scrollRestoreRafId = requestAnimationFrame(() => {
1616
+ scrollRestoreRafId = 0;
1617
+ if (!activated.value) return;
1618
+ setScrollElTo(position);
1619
+ if (attempts <= 1) return;
1620
+ scheduleScrollRestore(position, attempts - 1);
1621
+ });
1622
+ }
1607
1623
  async function triggerAffixedRefresh() {
1608
1624
  if (!outsideScrollEl.value) return;
1609
1625
  outsideScrollEl.value.scrollTo({
@@ -1836,14 +1852,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1836
1852
  document.addEventListener("click", handleDocumentClick);
1837
1853
  document.addEventListener("keydown", handleDocumentKeydown);
1838
1854
  });
1839
- onActivated(() => {
1840
- setScrollElTo();
1855
+ onActivated(async () => {
1856
+ const position = {
1857
+ ...scrollRecord
1858
+ };
1841
1859
  tableContentResume();
1860
+ await nextTick();
1861
+ if (!activated.value) return;
1862
+ cancelScrollRestore();
1863
+ scheduleScrollRestore(position);
1842
1864
  });
1843
1865
  onDeactivated(() => {
1866
+ cancelScrollRestore();
1844
1867
  tableContentPause();
1845
1868
  });
1846
1869
  onBeforeUnmount(() => {
1870
+ cancelScrollRestore();
1847
1871
  tableContentStop();
1848
1872
  if (probeRafId) cancelAnimationFrame(probeRafId);
1849
1873
  if (affixRefreshRafId) cancelAnimationFrame(affixRefreshRafId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qidian-vue-ui",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "description": "基于 TDesign 的 QiDian Vue UI 组件库",
5
5
  "author": "qidian",
6
6
  "license": "MIT",
@@ -130,7 +130,7 @@
130
130
  "vue-codemirror": "^6.1.1",
131
131
  "vue-echarts": "^8.0.1",
132
132
  "vue-stream-markdown": "1.0.1-beta.1",
133
- "qidian-shared": "1.2.3"
133
+ "qidian-shared": "1.2.4"
134
134
  },
135
135
  "scripts": {
136
136
  "clean": "rm -rf dist",