@jnrs/vue-core 1.2.24 → 1.2.26

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,4 +1,4 @@
1
- import { c as _, u as j } from "../useMouseSelection-BYwoK2fm.js";
1
+ import { c as _, u as j } from "../useMouseSelection-WAwkGh9a.js";
2
2
  import { ref as p, onDeactivated as J, onActivated as x, onUnmounted as D } from "vue";
3
3
  import { ElMessage as v } from "element-plus";
4
4
  function H(w) {
@@ -1,19 +1,18 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : useReactivityTableHeight.ts
5
- * @Date : 2025/12/10
6
- * @Desc. : 响应式根据视口动态计算表格高度
7
- */
1
+ import { Ref } from 'vue';
8
2
  export interface UseReactivityTableHeightOptions {
9
3
  className?: string;
10
4
  bottomGap?: number;
5
+ elementRef?: Ref<HTMLElement | undefined>;
11
6
  }
12
7
  /**
13
- * @param className 表格类名,默认值 el-table,如果页面存在多个表格,则必须分别传入自定义类名
14
- * @param bottomGap 底部间隔,默认值 77
8
+ * 响应式表格高度计算
9
+ *
10
+ * @param className 表格类名,默认值 el-table。多表格场景下由 JnTable 自动生成唯一类名,避免全局查询冲突
11
+ * @param bottomGap 底部间隔,默认值 80
12
+ * @param elementRef 表格 DOM 元素引用,优先级高于 className
15
13
  * @return maxHeight 表格高度
16
14
  */
17
- export declare function useReactivityTableHeight({ className, bottomGap }?: UseReactivityTableHeightOptions): {
18
- maxHeight: import('vue').Ref<number, number>;
15
+ export declare function useReactivityTableHeight({ className, bottomGap, elementRef }?: UseReactivityTableHeightOptions): {
16
+ maxHeight: Ref<number, number>;
17
+ uniqueClass: string;
19
18
  };
@@ -0,0 +1,221 @@
1
+ import { ref as P, onMounted as _, nextTick as D, onActivated as L, onDeactivated as $, onUnmounted as N } from "vue";
2
+ var F = typeof global == "object" && global && global.Object === Object && global, W = typeof self == "object" && self && self.Object === Object && self, A = F || W || Function("return this")(), T = A.Symbol, C = Object.prototype, G = C.hasOwnProperty, U = C.toString, h = T ? T.toStringTag : void 0;
3
+ function z(e) {
4
+ var t = G.call(e, h), s = e[h];
5
+ try {
6
+ e[h] = void 0;
7
+ var c = !0;
8
+ } catch {
9
+ }
10
+ var n = U.call(e);
11
+ return c && (t ? e[h] = s : delete e[h]), n;
12
+ }
13
+ var X = Object.prototype, Y = X.toString;
14
+ function J(e) {
15
+ return Y.call(e);
16
+ }
17
+ var K = "[object Null]", Q = "[object Undefined]", I = T ? T.toStringTag : void 0;
18
+ function V(e) {
19
+ return e == null ? e === void 0 ? Q : K : I && I in Object(e) ? z(e) : J(e);
20
+ }
21
+ function Z(e) {
22
+ return e != null && typeof e == "object";
23
+ }
24
+ var ee = "[object Symbol]";
25
+ function te(e) {
26
+ return typeof e == "symbol" || Z(e) && V(e) == ee;
27
+ }
28
+ var ne = /\s/;
29
+ function ie(e) {
30
+ for (var t = e.length; t-- && ne.test(e.charAt(t)); )
31
+ ;
32
+ return t;
33
+ }
34
+ var oe = /^\s+/;
35
+ function re(e) {
36
+ return e && e.slice(0, ie(e) + 1).replace(oe, "");
37
+ }
38
+ function M(e) {
39
+ var t = typeof e;
40
+ return e != null && (t == "object" || t == "function");
41
+ }
42
+ var R = NaN, ce = /^[-+]0x[0-9a-f]+$/i, se = /^0b[01]+$/i, ae = /^0o[0-7]+$/i, ue = parseInt;
43
+ function k(e) {
44
+ if (typeof e == "number")
45
+ return e;
46
+ if (te(e))
47
+ return R;
48
+ if (M(e)) {
49
+ var t = typeof e.valueOf == "function" ? e.valueOf() : e;
50
+ e = M(t) ? t + "" : t;
51
+ }
52
+ if (typeof e != "string")
53
+ return e === 0 ? e : +e;
54
+ e = re(e);
55
+ var s = se.test(e);
56
+ return s || ae.test(e) ? ue(e.slice(2), s ? 2 : 8) : ce.test(e) ? R : +e;
57
+ }
58
+ var j = function() {
59
+ return A.Date.now();
60
+ }, le = "Expected a function", fe = Math.max, de = Math.min;
61
+ function me(e, t, s) {
62
+ var c, n, i, u, o, l, f = 0, x = !1, d = !1, a = !0;
63
+ if (typeof e != "function")
64
+ throw new TypeError(le);
65
+ t = k(t) || 0, M(s) && (x = !!s.leading, d = "maxWait" in s, i = d ? fe(k(s.maxWait) || 0, t) : i, a = "trailing" in s ? !!s.trailing : a);
66
+ function m(r) {
67
+ var b = c, y = n;
68
+ return c = n = void 0, f = r, u = e.apply(y, b), u;
69
+ }
70
+ function g(r) {
71
+ return f = r, o = setTimeout(S, t), x ? m(r) : u;
72
+ }
73
+ function p(r) {
74
+ var b = r - l, y = r - f, O = t - b;
75
+ return d ? de(O, i - y) : O;
76
+ }
77
+ function v(r) {
78
+ var b = r - l, y = r - f;
79
+ return l === void 0 || b >= t || b < 0 || d && y >= i;
80
+ }
81
+ function S() {
82
+ var r = j();
83
+ if (v(r))
84
+ return E(r);
85
+ o = setTimeout(S, p(r));
86
+ }
87
+ function E(r) {
88
+ return o = void 0, a && c ? m(r) : (c = n = void 0, u);
89
+ }
90
+ function H() {
91
+ o !== void 0 && clearTimeout(o), f = 0, c = l = n = o = void 0;
92
+ }
93
+ function q() {
94
+ return o === void 0 ? u : E(j());
95
+ }
96
+ function w() {
97
+ var r = j(), b = v(r);
98
+ if (c = arguments, n = this, l = r, b) {
99
+ if (o === void 0)
100
+ return g(l);
101
+ if (d)
102
+ return clearTimeout(o), o = setTimeout(S, t), m(l);
103
+ }
104
+ return o === void 0 && (o = setTimeout(S, t)), u;
105
+ }
106
+ return w.cancel = H, w.flush = q, w;
107
+ }
108
+ const ge = 40, be = 40;
109
+ let xe = 0;
110
+ function ve({
111
+ className: e = "el-table",
112
+ bottomGap: t = ge + be,
113
+ elementRef: s
114
+ } = {}) {
115
+ const c = P(500), n = `jn_auto_height_${++xe}`, i = () => {
116
+ if (s?.value) return s.value;
117
+ const o = document.querySelector(`.${n}`);
118
+ return o || document.querySelector(`.${e}`);
119
+ }, u = me(
120
+ () => {
121
+ requestAnimationFrame(() => {
122
+ const o = i();
123
+ if (o) {
124
+ const l = o.getBoundingClientRect(), f = window.innerHeight, x = l.top + t, d = f - x;
125
+ c.value = d > 100 ? d : 100;
126
+ }
127
+ });
128
+ },
129
+ 300,
130
+ { leading: !1 }
131
+ );
132
+ return _(() => {
133
+ D(() => {
134
+ u();
135
+ });
136
+ }), L(() => {
137
+ u(), window.addEventListener("resize", u);
138
+ }), $(() => {
139
+ window.removeEventListener("resize", u);
140
+ }), { maxHeight: c, uniqueClass: n };
141
+ }
142
+ function Se({
143
+ containerClass: e = "jn_table",
144
+ rowClass: t = "el-table__row",
145
+ callback: s = ye
146
+ } = {}) {
147
+ let c = !1, n = { x: 0, y: 0 }, i = { x: 0, y: 0 }, u = null;
148
+ _(() => {
149
+ window.addEventListener("mouseup", f);
150
+ }), N(() => {
151
+ window.removeEventListener("mouseup", f), B();
152
+ }), L(() => {
153
+ window.addEventListener("mouseup", f);
154
+ }), $(() => {
155
+ window.removeEventListener("mouseup", f), B();
156
+ });
157
+ const o = (a) => {
158
+ window.addEventListener("mousemove", l), c = !1, n = { x: a.clientX, y: a.clientY }, i = { ...n }, u = a.currentTarget?.closest(`.${e}`), he();
159
+ }, l = (a) => {
160
+ i = { x: a.clientX, y: a.clientY }, Math.abs(i.x - n.x) > 5 && Math.abs(i.y - n.y) > 24 && (c = !0), c && x(), d();
161
+ }, f = () => {
162
+ window.removeEventListener("mousemove", l), c && (c = !1), d();
163
+ }, x = () => {
164
+ if (!u)
165
+ return !1;
166
+ const a = u.querySelectorAll(`.${t}`);
167
+ if (!a)
168
+ return !1;
169
+ a.forEach((m) => {
170
+ const g = m.getBoundingClientRect();
171
+ g.right > Math.min(n.x, i.x) && g.left < Math.max(n.x, i.x) && g.bottom > Math.min(n.y, i.y) && g.top < Math.max(n.y, i.y) && s && s(m);
172
+ });
173
+ }, d = () => {
174
+ const a = document.querySelector(".useMouseSelection_fixedRectBox");
175
+ if (a) {
176
+ const m = Math.min(n.x, i.x) + "px", g = Math.min(n.y, i.y) + "px", p = Math.abs(i.x - n.x) + "px", v = Math.abs(i.y - n.y) + "px";
177
+ Object.assign(a.style, {
178
+ display: c ? "block" : "none",
179
+ left: m,
180
+ top: g,
181
+ width: p,
182
+ height: v
183
+ });
184
+ }
185
+ };
186
+ return {
187
+ handleMouseDown: o
188
+ };
189
+ }
190
+ const ye = (e) => {
191
+ const t = e.querySelector(".el-checkbox input[type='checkbox']");
192
+ t && !t.checked && t.click(), window.getSelection()?.removeAllRanges();
193
+ }, he = () => {
194
+ if (!document.querySelector(".useMouseSelection_fixedRectBox")) {
195
+ const t = document.createElement("div");
196
+ t.className = "useMouseSelection_fixedRectBox", Object.assign(t.style, {
197
+ display: "none",
198
+ position: "fixed",
199
+ "z-index": 1e4,
200
+ // 确保在其他元素之上,如在弹窗中的表格中使用时
201
+ border: "2px dashed #409eff",
202
+ "background-color": "rgba(64, 158, 255, 0.2)",
203
+ "pointer-events": "none",
204
+ "will-change": "transform"
205
+ }), document.body.appendChild(t);
206
+ }
207
+ }, B = () => {
208
+ const e = document.querySelector(".useMouseSelection_fixedRectBox");
209
+ e && document.body.removeChild(e);
210
+ };
211
+ export {
212
+ T as S,
213
+ Z as a,
214
+ V as b,
215
+ Se as c,
216
+ me as d,
217
+ F as f,
218
+ M as i,
219
+ A as r,
220
+ ve as u
221
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jnrs/vue-core",
3
- "version": "1.2.24",
4
- "description": "巨能前端工程化开发,Vue 专用核心功能包。",
3
+ "version": "1.2.26",
4
+ "description": "巨能(JNRS)前端工程化开发,Vue 专用核心功能包。",
5
5
  "keywords": [
6
6
  "jnrs",
7
7
  "vue-core"
@@ -60,7 +60,7 @@
60
60
  "vue": "^3.5.22",
61
61
  "vue-i18n": "^11.2.8",
62
62
  "vue-router": "^4.5.1",
63
- "@jnrs/shared": "1.1.30"
63
+ "@jnrs/shared": "1.1.32"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@vitejs/plugin-vue": "^6.0.1",
@@ -1,208 +0,0 @@
1
- import { ref as P, onActivated as L, onDeactivated as _, onMounted as D, onUnmounted as N } from "vue";
2
- var q = typeof global == "object" && global && global.Object === Object && global, W = typeof self == "object" && self && self.Object === Object && self, A = q || W || Function("return this")(), T = A.Symbol, H = Object.prototype, F = H.hasOwnProperty, G = H.toString, y = T ? T.toStringTag : void 0;
3
- function U(e) {
4
- var t = F.call(e, y), c = e[y];
5
- try {
6
- e[y] = void 0;
7
- var o = !0;
8
- } catch {
9
- }
10
- var n = G.call(e);
11
- return o && (t ? e[y] = c : delete e[y]), n;
12
- }
13
- var z = Object.prototype, X = z.toString;
14
- function Y(e) {
15
- return X.call(e);
16
- }
17
- var J = "[object Null]", K = "[object Undefined]", I = T ? T.toStringTag : void 0;
18
- function Q(e) {
19
- return e == null ? e === void 0 ? K : J : I && I in Object(e) ? U(e) : Y(e);
20
- }
21
- function V(e) {
22
- return e != null && typeof e == "object";
23
- }
24
- var Z = "[object Symbol]";
25
- function ee(e) {
26
- return typeof e == "symbol" || V(e) && Q(e) == Z;
27
- }
28
- var te = /\s/;
29
- function ne(e) {
30
- for (var t = e.length; t-- && te.test(e.charAt(t)); )
31
- ;
32
- return t;
33
- }
34
- var ie = /^\s+/;
35
- function oe(e) {
36
- return e && e.slice(0, ne(e) + 1).replace(ie, "");
37
- }
38
- function M(e) {
39
- var t = typeof e;
40
- return e != null && (t == "object" || t == "function");
41
- }
42
- var R = NaN, re = /^[-+]0x[0-9a-f]+$/i, ce = /^0b[01]+$/i, se = /^0o[0-7]+$/i, ae = parseInt;
43
- function k(e) {
44
- if (typeof e == "number")
45
- return e;
46
- if (ee(e))
47
- return R;
48
- if (M(e)) {
49
- var t = typeof e.valueOf == "function" ? e.valueOf() : e;
50
- e = M(t) ? t + "" : t;
51
- }
52
- if (typeof e != "string")
53
- return e === 0 ? e : +e;
54
- e = oe(e);
55
- var c = ce.test(e);
56
- return c || se.test(e) ? ae(e.slice(2), c ? 2 : 8) : re.test(e) ? R : +e;
57
- }
58
- var j = function() {
59
- return A.Date.now();
60
- }, le = "Expected a function", ue = Math.max, fe = Math.min;
61
- function de(e, t, c) {
62
- var o, n, i, u, s, l, f = 0, h = !1, m = !1, a = !0;
63
- if (typeof e != "function")
64
- throw new TypeError(le);
65
- t = k(t) || 0, M(c) && (h = !!c.leading, m = "maxWait" in c, i = m ? ue(k(c.maxWait) || 0, t) : i, a = "trailing" in c ? !!c.trailing : a);
66
- function d(r) {
67
- var b = o, x = n;
68
- return o = n = void 0, f = r, u = e.apply(x, b), u;
69
- }
70
- function g(r) {
71
- return f = r, s = setTimeout(S, t), h ? d(r) : u;
72
- }
73
- function p(r) {
74
- var b = r - l, x = r - f, O = t - b;
75
- return m ? fe(O, i - x) : O;
76
- }
77
- function v(r) {
78
- var b = r - l, x = r - f;
79
- return l === void 0 || b >= t || b < 0 || m && x >= i;
80
- }
81
- function S() {
82
- var r = j();
83
- if (v(r))
84
- return E(r);
85
- s = setTimeout(S, p(r));
86
- }
87
- function E(r) {
88
- return s = void 0, a && o ? d(r) : (o = n = void 0, u);
89
- }
90
- function $() {
91
- s !== void 0 && clearTimeout(s), f = 0, o = l = n = s = void 0;
92
- }
93
- function C() {
94
- return s === void 0 ? u : E(j());
95
- }
96
- function w() {
97
- var r = j(), b = v(r);
98
- if (o = arguments, n = this, l = r, b) {
99
- if (s === void 0)
100
- return g(l);
101
- if (m)
102
- return clearTimeout(s), s = setTimeout(S, t), d(l);
103
- }
104
- return s === void 0 && (s = setTimeout(S, t)), u;
105
- }
106
- return w.cancel = $, w.flush = C, w;
107
- }
108
- const me = 40, ge = 40;
109
- function he({
110
- className: e = "el-table",
111
- bottomGap: t = me + ge
112
- } = {}) {
113
- const c = P(500), o = de(
114
- () => {
115
- const n = document.querySelector(`.${e}`);
116
- if (n) {
117
- const i = n.getBoundingClientRect(), u = window.innerHeight, s = i.top + t, l = u - s;
118
- c.value = l > 100 ? l : 100;
119
- }
120
- },
121
- 300,
122
- { leading: !1 }
123
- );
124
- return L(() => {
125
- o(), window.addEventListener("resize", o);
126
- }), _(() => {
127
- window.removeEventListener("resize", o);
128
- }), { maxHeight: c };
129
- }
130
- function pe({
131
- containerClass: e = "jn_table",
132
- rowClass: t = "el-table__row",
133
- callback: c = be
134
- } = {}) {
135
- let o = !1, n = { x: 0, y: 0 }, i = { x: 0, y: 0 }, u = null;
136
- D(() => {
137
- window.addEventListener("mouseup", f);
138
- }), N(() => {
139
- window.removeEventListener("mouseup", f), B();
140
- }), L(() => {
141
- window.addEventListener("mouseup", f);
142
- }), _(() => {
143
- window.removeEventListener("mouseup", f), B();
144
- });
145
- const s = (a) => {
146
- window.addEventListener("mousemove", l), o = !1, n = { x: a.clientX, y: a.clientY }, i = { ...n }, u = a.currentTarget?.closest(`.${e}`), xe();
147
- }, l = (a) => {
148
- i = { x: a.clientX, y: a.clientY }, Math.abs(i.x - n.x) > 5 && Math.abs(i.y - n.y) > 24 && (o = !0), o && h(), m();
149
- }, f = () => {
150
- window.removeEventListener("mousemove", l), o && (o = !1), m();
151
- }, h = () => {
152
- if (!u)
153
- return !1;
154
- const a = u.querySelectorAll(`.${t}`);
155
- if (!a)
156
- return !1;
157
- a.forEach((d) => {
158
- const g = d.getBoundingClientRect();
159
- g.right > Math.min(n.x, i.x) && g.left < Math.max(n.x, i.x) && g.bottom > Math.min(n.y, i.y) && g.top < Math.max(n.y, i.y) && c && c(d);
160
- });
161
- }, m = () => {
162
- const a = document.querySelector(".useMouseSelection_fixedRectBox");
163
- if (a) {
164
- const d = Math.min(n.x, i.x) + "px", g = Math.min(n.y, i.y) + "px", p = Math.abs(i.x - n.x) + "px", v = Math.abs(i.y - n.y) + "px";
165
- Object.assign(a.style, {
166
- display: o ? "block" : "none",
167
- left: d,
168
- top: g,
169
- width: p,
170
- height: v
171
- });
172
- }
173
- };
174
- return {
175
- handleMouseDown: s
176
- };
177
- }
178
- const be = (e) => {
179
- const t = e.querySelector(".el-checkbox input[type='checkbox']");
180
- t && !t.checked && t.click(), window.getSelection()?.removeAllRanges();
181
- }, xe = () => {
182
- if (!document.querySelector(".useMouseSelection_fixedRectBox")) {
183
- const t = document.createElement("div");
184
- t.className = "useMouseSelection_fixedRectBox", Object.assign(t.style, {
185
- display: "none",
186
- position: "fixed",
187
- "z-index": 100,
188
- border: "2px dashed #409eff",
189
- "background-color": "rgba(64, 158, 255, 0.2)",
190
- "pointer-events": "none",
191
- "will-change": "transform"
192
- }), document.body.appendChild(t);
193
- }
194
- }, B = () => {
195
- const e = document.querySelector(".useMouseSelection_fixedRectBox");
196
- e && document.body.removeChild(e);
197
- };
198
- export {
199
- T as S,
200
- V as a,
201
- Q as b,
202
- pe as c,
203
- de as d,
204
- q as f,
205
- M as i,
206
- A as r,
207
- he as u
208
- };