qidian-vue-ui 1.4.0 → 1.4.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.
@@ -1,25 +1,25 @@
1
- .qd-service-table[data-v-5806889d] {
1
+ .qd-service-table[data-v-c2177f89] {
2
2
  height: 100%;
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  }
6
- .qd-service-table[data-v-5806889d] > .t-table__content {
6
+ .qd-service-table[data-v-c2177f89] > .t-table__content {
7
7
  flex: 1;
8
8
  }
9
- .qd-service-table[data-v-5806889d] .t-table__tree-col:not(:has(.t-table__tree-op-icon)) {
9
+ .qd-service-table[data-v-c2177f89] .t-table__tree-col:not(:has(.t-table__tree-op-icon)) {
10
10
  margin-left: calc(var(--td-font-size-body-large) + var(--td-comp-margin-s));
11
11
  }
12
- .qd-service-table[data-v-5806889d] .t-table__tree-leaf-node .t-table__tree-op-icon:empty {
12
+ .qd-service-table[data-v-c2177f89] .t-table__tree-leaf-node .t-table__tree-op-icon:empty {
13
13
  width: calc(var(--td-font-size-body-large) + var(--td-comp-margin-s));
14
14
  }
15
- .qd-service-table[data-v-5806889d] .t-affix {
16
- transform: var(--v5ea6151a);
15
+ .qd-service-table[data-v-c2177f89] .t-affix {
16
+ transform: var(--v072441ea);
17
17
  }
18
- .qd-service-table--ps-x-fixed[data-v-5806889d] .ps__rail-x {
18
+ .qd-service-table--ps-x-fixed[data-v-c2177f89] .ps__rail-x {
19
19
  position: fixed;
20
- left: var(--v60ce71c8) !important;
21
- bottom: var(--v6db618c6) !important;
20
+ left: var(--ac91cc66) !important;
21
+ bottom: var(--v79d9a896) !important;
22
22
  }
23
- .qd-service-table--disable-horizontal-scroll[data-v-5806889d] colgroup > col {
23
+ .qd-service-table--disable-horizontal-scroll[data-v-c2177f89] colgroup > col {
24
24
  width: auto !important;
25
25
  }
@@ -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-5806889d"]]);
5
+ const QdServiceTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c2177f89"]]);
6
6
  export {
7
7
  QdServiceTable as default
8
8
  };
@@ -307,9 +307,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
307
307
  emit: __emit
308
308
  }) {
309
309
  useCssVars((_ctx) => ({
310
- "v5ea6151a": affixedHeaderTransform.value,
311
- "v60ce71c8": tableContentLeft.value,
312
- "v6db618c6": outsideBottom.value
310
+ "v072441ea": affixedHeaderTransform.value,
311
+ "ac91cc66": tableContentLeft.value,
312
+ "v79d9a896": outsideBottom.value
313
313
  }));
314
314
  const props = __props;
315
315
  const emit = __emit;
@@ -357,17 +357,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
357
357
  const tableContentRect = reactive(useElementBounding(tableContentEl));
358
358
  const tableContentLeft = computed(() => `${tableContentRect.left - affixedRailOffsetX.value}px`);
359
359
  const outsideScrollRect = reactive(useElementBounding(outsideScrollEl));
360
- const outsideBottom = computed(() => outsideScrollEl.value ? `${window.innerHeight - outsideScrollRect.bottom}px` : "0");
360
+ const affixBottomOffset = ref(0);
361
+ let probeRafId = 0;
362
+ let animatingAncestorCleanup = null;
363
+ const outsideBottom = computed(() => {
364
+ if (!outsideScrollEl.value) return "0";
365
+ return `${Math.max(0, window.innerHeight - outsideScrollRect.bottom + affixBottomOffset.value)}px`;
366
+ });
361
367
  const tableHeaderHalfVisible = computed(() => {
362
368
  if (!tableContentVisible.value) return false;
363
369
  return tableContentRect.top + tableHeaderH.value * 0.5 <= outsideScrollRect.bottom;
364
370
  });
365
371
  const tableContentFullVisible = computed(() => {
366
372
  if (!tableContentVisible.value) return false;
367
- const contentBottom = tableContentRect.bottom;
368
- const containerBottom = outsideScrollRect.bottom;
369
- return contentBottom <= containerBottom;
373
+ return tableContentRect.bottom <= outsideScrollRect.bottom - affixBottomOffset.value;
370
374
  });
375
+ const isPsXFixed = computed(() => tableContentVisible.value && tableHeaderHalfVisible.value && !tableContentFullVisible.value);
371
376
  const {
372
377
  ps: tablePs
373
378
  } = usePerfectScrollbar(tableContentEl, {
@@ -827,11 +832,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
827
832
  return keys;
828
833
  }, []);
829
834
  }
835
+ function refreshAffixedMetrics() {
836
+ tableContentRect.update();
837
+ outsideScrollRect.update();
838
+ affixedRailOffsetX.value = getTransformOffset(affixBaseEl.value).x;
839
+ }
830
840
  function onResize(entries) {
831
841
  const el = entries[0].target;
832
842
  outsideScrollEl.value = getScrollEl(el);
833
- outsideScrollRect.update();
834
- affixedRailOffsetX.value = getTransformOffset(affixBaseEl.value).x;
843
+ refreshAffixedMetrics();
835
844
  const headerEl = el.querySelector(".t-table__header");
836
845
  tableHeaderEl.value = headerEl;
837
846
  let headerH = 0;
@@ -839,6 +848,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
839
848
  tableHeaderH.value = headerH;
840
849
  const contentEl = el.querySelector(".t-table__content");
841
850
  tableContentEl.value = contentEl;
851
+ probeBottomBlockHeight();
842
852
  }
843
853
  function isTransformAnimating(node) {
844
854
  return node.getAnimations().length > 0;
@@ -853,6 +863,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
853
863
  }
854
864
  return null;
855
865
  }
866
+ function watchAnimatingTransformAncestor() {
867
+ animatingAncestorCleanup?.();
868
+ const animatingNode = findAnimatingTransformAncestor(affixBaseEl.value);
869
+ if (!animatingNode) return;
870
+ const cleanup = () => {
871
+ animatingNode.removeEventListener("transitionend", onEnd);
872
+ animatingNode.removeEventListener("animationend", onEnd);
873
+ animatingAncestorCleanup = null;
874
+ };
875
+ const onEnd = () => {
876
+ cleanup();
877
+ refreshAffixedMetrics();
878
+ };
879
+ animatingNode.addEventListener("transitionend", onEnd);
880
+ animatingNode.addEventListener("animationend", onEnd);
881
+ animatingAncestorCleanup = cleanup;
882
+ }
856
883
  async function applyAffixedTransform() {
857
884
  const el = affixBaseEl.value;
858
885
  if (!el) return;
@@ -863,6 +890,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
863
890
  });
864
891
  affixedHeaderTransform.value = `translateY(-${y}px)`;
865
892
  }
893
+ function scheduleProbeBottomBlock() {
894
+ if (probeRafId) return;
895
+ probeRafId = requestAnimationFrame(() => {
896
+ probeRafId = 0;
897
+ probeBottomBlockHeight();
898
+ });
899
+ }
900
+ function probeBottomBlockHeight() {
901
+ const scrollEl = outsideScrollEl.value;
902
+ const tableEl = tableRef.value?.$el;
903
+ if (!scrollEl || !tableEl) return;
904
+ const sRect = scrollEl.getBoundingClientRect();
905
+ const stack = document.elementsFromPoint(sRect.left + sRect.width / 2, sRect.bottom - 1);
906
+ let blockHeight = 0;
907
+ for (const el of stack) {
908
+ if (tableEl.contains(el)) continue;
909
+ if (el === scrollEl || el.contains(scrollEl)) continue;
910
+ const {
911
+ position
912
+ } = getComputedStyle(el);
913
+ if (position !== "fixed" && position !== "sticky") continue;
914
+ const rect = el.getBoundingClientRect();
915
+ if (rect.top < sRect.top) continue;
916
+ blockHeight = Math.max(blockHeight, sRect.bottom - rect.top);
917
+ }
918
+ affixBottomOffset.value = blockHeight;
919
+ }
866
920
  watch(columnControllerVisible, (visible) => {
867
921
  const {
868
922
  columns
@@ -881,6 +935,31 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
881
935
  requestAnimationFrame(() => {
882
936
  tablePs.value?.update();
883
937
  });
938
+ watchAnimatingTransformAncestor();
939
+ nextTick(() => {
940
+ setTimeout(refreshAffixedMetrics, 320);
941
+ });
942
+ });
943
+ watch(isOutsideTableContent, (outside) => {
944
+ if (outside) return;
945
+ refreshAffixedMetrics();
946
+ });
947
+ watch(outsideScrollEl, (el, _old, onCleanup) => {
948
+ if (!el) return;
949
+ probeBottomBlockHeight();
950
+ const onScroll = () => scheduleProbeBottomBlock();
951
+ el.addEventListener("scroll", onScroll, {
952
+ passive: true
953
+ });
954
+ onCleanup(() => {
955
+ el.removeEventListener("scroll", onScroll);
956
+ if (probeRafId) {
957
+ cancelAnimationFrame(probeRafId);
958
+ probeRafId = 0;
959
+ }
960
+ });
961
+ }, {
962
+ immediate: true
884
963
  });
885
964
  onActivated(() => {
886
965
  setScrollElTo();
@@ -892,6 +971,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
892
971
  onBeforeUnmount(() => {
893
972
  tableContentStop();
894
973
  outsideTableContentStop();
974
+ if (probeRafId) cancelAnimationFrame(probeRafId);
975
+ animatingAncestorCleanup?.();
895
976
  });
896
977
  __expose(createExposeProxy({
897
978
  data,
@@ -919,7 +1000,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
919
1000
  return (_ctx, _cache) => {
920
1001
  return withDirectives((openBlock(), createBlock(resolveDynamicComponent(reProps.value.tableOptions.tree ? unref(EnhancedTable) : unref(Table)), mergeProps({
921
1002
  ref: "table",
922
- class: ["qd-service-table", __props.headerBg ? "" : "t-table--header-bg-inherit", unref(isOutsideTableContent) ? "" : "qd-service-table--inside-table-content", tableContentVisible.value && tableHeaderHalfVisible.value && !tableContentFullVisible.value ? "qd-service-table--ps-x-fixed" : "", __props.disableHorizontalScroll ? "qd-service-table--disable-horizontal-scroll" : ""],
1003
+ class: ["qd-service-table", __props.headerBg ? "" : "t-table--header-bg-inherit", unref(isOutsideTableContent) ? "" : "qd-service-table--inside-table-content", isPsXFixed.value ? "qd-service-table--ps-x-fixed" : "", __props.disableHorizontalScroll ? "qd-service-table--disable-horizontal-scroll" : ""],
923
1004
  "selected-row-keys": unref(selectedRowKeys),
924
1005
  "onUpdate:selectedRowKeys": _cache[0] || (_cache[0] = ($event) => isRef(selectedRowKeys) ? selectedRowKeys.value = $event : null),
925
1006
  "active-row-keys": unref(activeRowKeys),
@@ -33,6 +33,11 @@ export declare function getTransformOffset(el?: HTMLElement | null, options?: {
33
33
  }): {
34
34
  x: number;
35
35
  y: number;
36
+ node: HTMLElement;
37
+ } | {
38
+ x: number;
39
+ y: number;
40
+ node: null | undefined;
36
41
  };
37
42
  export declare const IMAGE_REGEXP: RegExp;
38
43
  export declare function isImage(value: string): boolean;
@@ -13,11 +13,11 @@ function getTransformOffset(el, options) {
13
13
  while (node) {
14
14
  if (getComputedStyle(node).transform !== "none" && !skip?.(node)) {
15
15
  const { x, y } = node.getBoundingClientRect();
16
- return { x, y };
16
+ return { x, y, node };
17
17
  }
18
18
  node = node.parentElement;
19
19
  }
20
- return { x: 0, y: 0 };
20
+ return { x: 0, y: 0, node };
21
21
  }
22
22
  const IMAGE_REGEXP = /(.png|.jpg|.jpeg|.jpe|.webp|.avif|.heic|.heif|.svg|.gif|.bmp)/i;
23
23
  function isImage(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qidian-vue-ui",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "基于 TDesign 的 QiDian Vue UI 组件库",
5
5
  "author": "qidian",
6
6
  "license": "MIT",