qidian-vue-ui 1.12.13 → 1.12.15

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.
@@ -6,6 +6,8 @@ import debounce from "../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodas
6
6
  function usePerfectScrollbar(target, options) {
7
7
  const { watch: watchConfig, onScroll, onScrollY, onScrollX, ...scrollOptions } = options || {};
8
8
  const ps = ref();
9
+ const wheelEnabled = scrollOptions.handlers?.includes("wheel") ?? true;
10
+ const shiftKeyDescriptors = /* @__PURE__ */ new WeakMap();
9
11
  let unResize;
10
12
  let unwatchSource;
11
13
  let unwatchCore;
@@ -17,6 +19,26 @@ function usePerfectScrollbar(target, options) {
17
19
  if (typeof t === "string") return document.querySelector(t);
18
20
  return t;
19
21
  });
22
+ function maskShiftWheel(event) {
23
+ if (!event.shiftKey || Math.abs(event.deltaX) <= Math.abs(event.deltaY)) return;
24
+ const descriptor = Object.getOwnPropertyDescriptor(event, "shiftKey");
25
+ try {
26
+ Object.defineProperty(event, "shiftKey", { configurable: true, value: false });
27
+ } catch {
28
+ return;
29
+ }
30
+ shiftKeyDescriptors.set(event, descriptor ?? null);
31
+ }
32
+ function restoreShiftWheel(event) {
33
+ const descriptor = shiftKeyDescriptors.get(event);
34
+ if (descriptor === void 0) return;
35
+ try {
36
+ if (descriptor) Object.defineProperty(event, "shiftKey", descriptor);
37
+ else Reflect.deleteProperty(event, "shiftKey");
38
+ } finally {
39
+ shiftKeyDescriptors.delete(event);
40
+ }
41
+ }
20
42
  function init() {
21
43
  unwatchCore = watch(
22
44
  reTarget,
@@ -35,13 +57,26 @@ function usePerfectScrollbar(target, options) {
35
57
  if (el === ps.value?.element) return;
36
58
  destroyInstance();
37
59
  unResize = useResizeObserver(el, debounceUpdate).stop;
38
- ps.value = new PerfectScrollbar(el, {
39
- wheelPropagation: true,
40
- scrollXMarginOffset: 1,
41
- scrollYMarginOffset: 1,
42
- ...scrollOptions
43
- });
44
60
  listenerController = new AbortController();
61
+ if (wheelEnabled) {
62
+ el.addEventListener("wheel", maskShiftWheel, { signal: listenerController.signal });
63
+ }
64
+ try {
65
+ ps.value = new PerfectScrollbar(el, {
66
+ wheelPropagation: true,
67
+ scrollXMarginOffset: 1,
68
+ scrollYMarginOffset: 1,
69
+ ...scrollOptions
70
+ });
71
+ } catch (error) {
72
+ destroyInstance();
73
+ throw error;
74
+ }
75
+ if (wheelEnabled) {
76
+ ps.value.element.addEventListener("wheel", restoreShiftWheel, {
77
+ signal: listenerController.signal
78
+ });
79
+ }
45
80
  ps.value.element.addEventListener("scroll", onScroll || noop, {
46
81
  signal: listenerController.signal
47
82
  });
@@ -80,6 +80,11 @@ function focusTopOverlay(parentNode) {
80
80
  }
81
81
  function onEscKeyDown(e) {
82
82
  if (e.key !== "Escape") return;
83
+ if (document.activeElement?.closest(
84
+ ".t-image-viewer-preview-image:not(.t-is-hide)"
85
+ )) {
86
+ return;
87
+ }
83
88
  let topClassName;
84
89
  let topTime = -1;
85
90
  escRegistry.forEach((entry, className) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qidian-vue-ui",
3
- "version": "1.12.13",
3
+ "version": "1.12.15",
4
4
  "description": "基于 TDesign 的 QiDian Vue UI 组件库",
5
5
  "author": "qidian",
6
6
  "license": "MIT",
@@ -138,6 +138,7 @@
138
138
  "build": "npm run clean && vue-tsc --noEmit && vite build && vue-tsc && vite build --config vite.autoImportResolver.config.ts",
139
139
  "build-only": "npm run clean && vite build && vite build --config vite.autoImportResolver.config.ts",
140
140
  "type-check": "vue-tsc --noEmit",
141
+ "sync": "cnpm sync qidian-vue-ui",
141
142
  "lint": "eslint --max-warnings 0 \"{src,mock,scripts}/**/*.{vue,ts,tsx,js}\" --fix --cache"
142
143
  }
143
144
  }