@kc-one/smart-fill-sdk 0.0.5 → 0.0.6
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/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (e, t, n) =>
|
|
4
|
-
const
|
|
1
|
+
var Wt = Object.defineProperty;
|
|
2
|
+
var Xt = (e, t, n) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var d = (e, t, n) => Xt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
const Io = {
|
|
5
5
|
name: "native",
|
|
6
6
|
/** 匹配 input / textarea / select 原生控件 */
|
|
7
7
|
match: (e) => e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement,
|
|
@@ -14,7 +14,7 @@ const Ao = {
|
|
|
14
14
|
const n = e.element;
|
|
15
15
|
n instanceof HTMLInputElement && n.type === "checkbox" ? n.checked = !!t : (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement) && (n.value = String(t ?? "")), n == null || n.dispatchEvent(new Event("input", { bubbles: !0 })), n == null || n.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
16
16
|
}
|
|
17
|
-
},
|
|
17
|
+
}, lt = [
|
|
18
18
|
// Element Plus / Element UI
|
|
19
19
|
{ framework: "element", selectors: ".el-select,.el-select-v2", type: "select", kind: "input" },
|
|
20
20
|
{ framework: "element", selectors: ".el-cascader", type: "cascader", kind: "input" },
|
|
@@ -59,7 +59,7 @@ const Ao = {
|
|
|
59
59
|
{ framework: "vant", selectors: ".van-checkbox-group", type: "checkbox", kind: "checkboxGroup", optionSelector: '.van-checkbox,[role="checkbox"],input[type="checkbox"]' },
|
|
60
60
|
// 通用 ARIA 下拉(无框架 class 或作为内层触发器)
|
|
61
61
|
{ framework: "generic", selectors: '[role="combobox"]', type: "select", kind: "input" }
|
|
62
|
-
],
|
|
62
|
+
], Zt = [
|
|
63
63
|
"is-disabled",
|
|
64
64
|
"ant-select-disabled",
|
|
65
65
|
"n-select--disabled",
|
|
@@ -68,7 +68,7 @@ const Ao = {
|
|
|
68
68
|
"van-switch--disabled",
|
|
69
69
|
"van-stepper--disabled",
|
|
70
70
|
"van-dropdown-menu--disabled"
|
|
71
|
-
],
|
|
71
|
+
], ut = lt.map((e) => e.selectors).join(", "), Jt = [
|
|
72
72
|
".form-item",
|
|
73
73
|
".ant-form-item",
|
|
74
74
|
".el-form-item",
|
|
@@ -78,7 +78,7 @@ const Ao = {
|
|
|
78
78
|
".van-field",
|
|
79
79
|
".field",
|
|
80
80
|
".form-row"
|
|
81
|
-
].join(", "),
|
|
81
|
+
].join(", "), Qt = [
|
|
82
82
|
"label",
|
|
83
83
|
".ant-form-item-label",
|
|
84
84
|
".el-form-item__label",
|
|
@@ -105,7 +105,7 @@ const Ao = {
|
|
|
105
105
|
".van-action-sheet",
|
|
106
106
|
".popup",
|
|
107
107
|
".drawer"
|
|
108
|
-
].join(", "),
|
|
108
|
+
].join(", "), en = [
|
|
109
109
|
"is-checked",
|
|
110
110
|
"ant-switch-checked",
|
|
111
111
|
"n-switch--active",
|
|
@@ -114,20 +114,20 @@ const Ao = {
|
|
|
114
114
|
"van-radio--checked",
|
|
115
115
|
"van-checkbox--checked"
|
|
116
116
|
];
|
|
117
|
-
function
|
|
118
|
-
return
|
|
117
|
+
function O(e) {
|
|
118
|
+
return lt.find((t) => e.matches(t.selectors)) || null;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
return !!
|
|
120
|
+
function dt(e) {
|
|
121
|
+
return !!O(e);
|
|
122
122
|
}
|
|
123
123
|
function Te(e) {
|
|
124
124
|
for (let t = e; t; t = t.parentElement)
|
|
125
|
-
if (
|
|
125
|
+
if (dt(t)) return t;
|
|
126
126
|
return null;
|
|
127
127
|
}
|
|
128
128
|
function ce(e) {
|
|
129
129
|
var n;
|
|
130
|
-
const t =
|
|
130
|
+
const t = O(e);
|
|
131
131
|
if (!t) return null;
|
|
132
132
|
if (e.matches(".van-field")) {
|
|
133
133
|
if (e.querySelector("textarea")) return "textarea";
|
|
@@ -146,29 +146,29 @@ function ce(e) {
|
|
|
146
146
|
}
|
|
147
147
|
return t.type;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
const t =
|
|
149
|
+
function pt(e) {
|
|
150
|
+
const t = O(e);
|
|
151
151
|
if (t != null && t.optionSelector)
|
|
152
|
-
return Array.from(e.querySelectorAll(t.optionSelector)).map((n) =>
|
|
152
|
+
return Array.from(e.querySelectorAll(t.optionSelector)).map((n) => tn(n)).filter((n) => !!(n.label || n.value));
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function tn(e) {
|
|
155
155
|
const t = e instanceof HTMLInputElement ? e : e.querySelector('input[type="radio"],input[type="checkbox"]'), n = p(e.textContent || e.getAttribute("aria-label") || e.getAttribute("title") || ""), r = e.getAttribute("value") || (t == null ? void 0 : t.value) || n;
|
|
156
156
|
return { label: n, value: r };
|
|
157
157
|
}
|
|
158
158
|
function U(e) {
|
|
159
|
-
return
|
|
159
|
+
return en.some((t) => e.classList.contains(t)) || e.getAttribute("aria-checked") === "true" || !!e.querySelector("input:checked");
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function F(e) {
|
|
162
162
|
return e.querySelector('input:not([type="hidden"]), textarea');
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function ft(e) {
|
|
165
165
|
var t, n, r;
|
|
166
|
-
return e.getAttribute("name") || ((t =
|
|
166
|
+
return e.getAttribute("name") || ((t = F(e)) == null ? void 0 : t.getAttribute("name")) || e.getAttribute("data-smart-fill-key") || ((n = F(e)) == null ? void 0 : n.getAttribute("data-smart-fill-key")) || ((r = e.querySelector("[data-smart-fill-key]")) == null ? void 0 : r.getAttribute("data-smart-fill-key"));
|
|
167
167
|
}
|
|
168
168
|
function p(e) {
|
|
169
169
|
return e.replace(/[*::]/g, "").replace(/\s+/g, " ").trim();
|
|
170
170
|
}
|
|
171
|
-
const Le = "data-smart-fill-hide-dropdown-mode", Be = "smart-fill-hide-dropdown-style",
|
|
171
|
+
const Le = "data-smart-fill-hide-dropdown-mode", Be = "smart-fill-hide-dropdown-style", ht = [
|
|
172
172
|
"[role='combobox']",
|
|
173
173
|
"[aria-haspopup='listbox']",
|
|
174
174
|
".el-cascader",
|
|
@@ -191,7 +191,7 @@ const Le = "data-smart-fill-hide-dropdown-mode", Be = "smart-fill-hide-dropdown-
|
|
|
191
191
|
".van-dropdown-menu__bar",
|
|
192
192
|
".van-field--picker",
|
|
193
193
|
".van-field--clickable"
|
|
194
|
-
].join(", "),
|
|
194
|
+
].join(", "), nn = [
|
|
195
195
|
".ant-select-selection-item",
|
|
196
196
|
".el-select__selected-item",
|
|
197
197
|
".el-select-v2__selected-item",
|
|
@@ -253,7 +253,7 @@ const Le = "data-smart-fill-hide-dropdown-mode", Be = "smart-fill-hide-dropdown-
|
|
|
253
253
|
".van-dropdown-item",
|
|
254
254
|
".van-picker",
|
|
255
255
|
"[role='listbox']"
|
|
256
|
-
].join(", "),
|
|
256
|
+
].join(", "), gt = [
|
|
257
257
|
".el-select-dropdown",
|
|
258
258
|
".el-select__popper",
|
|
259
259
|
".el-select-v2__popper",
|
|
@@ -270,7 +270,7 @@ const Le = "data-smart-fill-hide-dropdown-mode", Be = "smart-fill-hide-dropdown-
|
|
|
270
270
|
".van-dropdown-item",
|
|
271
271
|
".van-picker",
|
|
272
272
|
"[role='listbox']"
|
|
273
|
-
].join(", "),
|
|
273
|
+
].join(", "), yt = [
|
|
274
274
|
".el-cascader__dropdown",
|
|
275
275
|
".el-cascader-panel",
|
|
276
276
|
".el-popper.el-cascader__dropdown",
|
|
@@ -279,9 +279,9 @@ const Le = "data-smart-fill-hide-dropdown-mode", Be = "smart-fill-hide-dropdown-
|
|
|
279
279
|
".arco-cascader-panel",
|
|
280
280
|
".van-cascader",
|
|
281
281
|
".van-cascader__options"
|
|
282
|
-
].join(", "),
|
|
282
|
+
].join(", "), rn = /(?:省|市|自治区|特别行政区|自治州|地区|盟|县|区)$/, on = /地址|省|市|区|县|地区|籍贯|户籍|居住地|所在地|区域/, sn = /* @__PURE__ */ new Set(["select", "cascader", "date"]);
|
|
283
283
|
function C(e) {
|
|
284
|
-
return !
|
|
284
|
+
return !Ct(e) || wt(e) ? !1 : !!e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader");
|
|
285
285
|
}
|
|
286
286
|
function E(e) {
|
|
287
287
|
var n;
|
|
@@ -301,7 +301,7 @@ function E(e) {
|
|
|
301
301
|
return !1;
|
|
302
302
|
}
|
|
303
303
|
function j(e) {
|
|
304
|
-
return !
|
|
304
|
+
return !Ct(e) || wt(e) || e instanceof HTMLSelectElement || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement ? !1 : e.matches(ht) || e.getAttribute("role") === "combobox" || e.getAttribute("aria-haspopup") === "listbox" || e.classList.contains("el-select__wrapper") || e.classList.contains("el-select-v2__wrapper") || E(e);
|
|
305
305
|
}
|
|
306
306
|
function G(e) {
|
|
307
307
|
const t = e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader");
|
|
@@ -342,17 +342,17 @@ function Re(e) {
|
|
|
342
342
|
const t = G(e);
|
|
343
343
|
return t || (e.matches(".van-field") && E(e) ? e : null);
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function bt(e) {
|
|
346
346
|
if (C(e)) return "cascader";
|
|
347
347
|
if (j(e) || E(e)) return "select";
|
|
348
348
|
const t = ce(e);
|
|
349
349
|
return t || (e instanceof HTMLSelectElement ? "select" : null);
|
|
350
350
|
}
|
|
351
|
-
function
|
|
352
|
-
const n = t ||
|
|
353
|
-
return n != null &&
|
|
351
|
+
function Fe(e, t) {
|
|
352
|
+
const n = t || bt(e);
|
|
353
|
+
return n != null && sn.has(n);
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function an(e) {
|
|
356
356
|
const t = e.matches(".van-field") ? e : e.closest(".van-field");
|
|
357
357
|
if (t instanceof HTMLElement && E(t)) {
|
|
358
358
|
const i = t.querySelector(".van-field__control");
|
|
@@ -361,7 +361,7 @@ function sn(e) {
|
|
|
361
361
|
const s = p((i == null ? void 0 : i.textContent) || "");
|
|
362
362
|
return s && s !== "请选择" ? s : "";
|
|
363
363
|
}
|
|
364
|
-
const n = e.querySelector(
|
|
364
|
+
const n = e.querySelector(nn);
|
|
365
365
|
if (n instanceof HTMLInputElement)
|
|
366
366
|
return p(n.value);
|
|
367
367
|
const r = p((n == null ? void 0 : n.textContent) || "");
|
|
@@ -369,46 +369,46 @@ function sn(e) {
|
|
|
369
369
|
const o = e.querySelector('input:not([type="hidden"])');
|
|
370
370
|
return o != null && o.value ? p(o.value) : r;
|
|
371
371
|
}
|
|
372
|
-
function
|
|
373
|
-
const t =
|
|
372
|
+
function mt(e) {
|
|
373
|
+
const t = hn(e);
|
|
374
374
|
if (!t.length) return;
|
|
375
|
-
const n =
|
|
375
|
+
const n = gn(t);
|
|
376
376
|
return n.length ? n : void 0;
|
|
377
377
|
}
|
|
378
378
|
function ne(e) {
|
|
379
379
|
var t;
|
|
380
|
-
return !((t = e.options) != null && t.length) || e.type === "cascader" ||
|
|
380
|
+
return !((t = e.options) != null && t.length) || e.type === "cascader" || on.test(e.label || "") ? !1 : Sn(e.options);
|
|
381
381
|
}
|
|
382
|
-
async function
|
|
382
|
+
async function cn(e) {
|
|
383
383
|
if (e instanceof HTMLSelectElement)
|
|
384
384
|
return Array.from(e.options).map((s) => ({ value: s.value, label: p(s.textContent || s.label) })).filter((s) => s.label || s.value);
|
|
385
|
-
const t =
|
|
385
|
+
const t = mt(e);
|
|
386
386
|
if (t != null && t.length) return t;
|
|
387
387
|
const n = G(e) || e;
|
|
388
388
|
if (!j(n) && !C(n) && !E(n))
|
|
389
389
|
return;
|
|
390
|
-
const r =
|
|
390
|
+
const r = _n(), o = En(), i = new Set(o.getTrackedDropdowns());
|
|
391
391
|
try {
|
|
392
|
-
if (!(C(n) ? await
|
|
393
|
-
const a = await
|
|
392
|
+
if (!(C(n) ? await un(n, o, i) : await ln(n, o, i))) return;
|
|
393
|
+
const a = await pn(o, i, n);
|
|
394
394
|
if (!a.length) return;
|
|
395
|
-
const c =
|
|
395
|
+
const c = dn(a);
|
|
396
396
|
return c.length ? c : void 0;
|
|
397
397
|
} finally {
|
|
398
|
-
await
|
|
398
|
+
await kn(n, o), await M(60), o.restore(), r();
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function wt(e) {
|
|
402
402
|
return e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true";
|
|
403
403
|
}
|
|
404
|
-
async function
|
|
404
|
+
async function ln(e, t, n) {
|
|
405
405
|
const r = Y(e);
|
|
406
406
|
if (!r.length) return !1;
|
|
407
407
|
for (const o of r)
|
|
408
|
-
if (
|
|
408
|
+
if (kt(o), xt(o), await M(160), Ue(e, t, n) || (_t(o), await M(180), Ue(e, t, n))) return !0;
|
|
409
409
|
return !1;
|
|
410
410
|
}
|
|
411
|
-
async function
|
|
411
|
+
async function un(e, t, n) {
|
|
412
412
|
const r = [
|
|
413
413
|
e,
|
|
414
414
|
e.querySelector(".el-input__wrapper"),
|
|
@@ -417,10 +417,10 @@ async function ln(e, t, n) {
|
|
|
417
417
|
e.querySelector("input")
|
|
418
418
|
].filter((o) => o instanceof HTMLElement);
|
|
419
419
|
for (const o of r)
|
|
420
|
-
if (
|
|
420
|
+
if (kt(o), xt(o), await M(180), ue(t, n, e).length || (_t(o), await M(180), ue(t, n, e).length)) return !0;
|
|
421
421
|
return !1;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function dn(e) {
|
|
424
424
|
var r;
|
|
425
425
|
const t = /* @__PURE__ */ new Set(), n = [];
|
|
426
426
|
for (const o of e) {
|
|
@@ -438,7 +438,7 @@ function un(e) {
|
|
|
438
438
|
}
|
|
439
439
|
return n;
|
|
440
440
|
}
|
|
441
|
-
async function
|
|
441
|
+
async function pn(e, t, n) {
|
|
442
442
|
for (let r = 0; r < 8; r += 1) {
|
|
443
443
|
const o = ue(e, t, n);
|
|
444
444
|
if (o.length) return o;
|
|
@@ -449,38 +449,38 @@ async function dn(e, t, n) {
|
|
|
449
449
|
function Ue(e, t, n) {
|
|
450
450
|
return ue(t, n, e).length > 0 ? !0 : Y(e).some((r) => r.getAttribute("aria-expanded") === "true" || r.classList.contains("is-focus") || r.classList.contains("is-focused"));
|
|
451
451
|
}
|
|
452
|
-
function
|
|
453
|
-
const r = t.filter((c) =>
|
|
452
|
+
function fn(e, t, n) {
|
|
453
|
+
const r = t.filter((c) => Oe(e, c)), o = r.filter((c) => yn(e, c)), i = o.filter((c) => !n.has(c));
|
|
454
454
|
if (i.length)
|
|
455
455
|
return i.sort((c, l) => R(l, e) - R(c, e));
|
|
456
|
-
const s =
|
|
456
|
+
const s = vt(e);
|
|
457
457
|
if (s.size) {
|
|
458
458
|
const c = o.filter((l) => l.id && s.has(l.id));
|
|
459
459
|
if (c.length) return c;
|
|
460
460
|
}
|
|
461
461
|
if (o.length)
|
|
462
462
|
return o.sort((c, l) => R(l, e) - R(c, e)).slice(0, 1);
|
|
463
|
-
const a = r.filter((c) =>
|
|
463
|
+
const a = r.filter((c) => vn(c) && St(e)).sort((c, l) => R(l, e) - R(c, e)).slice(0, 1);
|
|
464
464
|
return a.length ? a : [];
|
|
465
465
|
}
|
|
466
466
|
function ue(e, t, n) {
|
|
467
|
-
return
|
|
467
|
+
return fn(n, e.getTrackedDropdowns(), t);
|
|
468
468
|
}
|
|
469
469
|
function R(e, t) {
|
|
470
470
|
const n = e.getBoundingClientRect(), r = Number.parseInt(window.getComputedStyle(e).zIndex || "0", 10);
|
|
471
471
|
let o = (Number.isNaN(r) ? 0 : r) * 10 + n.width * n.height;
|
|
472
|
-
return t && (o +=
|
|
472
|
+
return t && (o += Et(t, e)), o;
|
|
473
473
|
}
|
|
474
|
-
function
|
|
475
|
-
const t = C(e) ?
|
|
474
|
+
function hn(e) {
|
|
475
|
+
const t = C(e) ? yt : gt, n = /* @__PURE__ */ new Set();
|
|
476
476
|
e.matches(t) && n.add(e);
|
|
477
477
|
for (const r of e.querySelectorAll(t))
|
|
478
|
-
|
|
478
|
+
Oe(e, r) && n.add(r);
|
|
479
479
|
for (const r of e.querySelectorAll("[role='listbox']"))
|
|
480
|
-
e.contains(r) &&
|
|
480
|
+
e.contains(r) && Oe(e, r) && n.add(r);
|
|
481
481
|
return [...n];
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function gn(e) {
|
|
484
484
|
const t = /* @__PURE__ */ new Set(), n = [];
|
|
485
485
|
for (const r of e) {
|
|
486
486
|
const o = r.matches(Ie) ? [r] : Array.from(r.querySelectorAll(Ie));
|
|
@@ -495,35 +495,35 @@ function hn(e) {
|
|
|
495
495
|
}
|
|
496
496
|
return n;
|
|
497
497
|
}
|
|
498
|
-
function
|
|
498
|
+
function vt(e) {
|
|
499
499
|
return new Set(
|
|
500
500
|
Y(e).flatMap((t) => [t.getAttribute("aria-controls"), t.getAttribute("aria-owns")]).filter((t) => !!t)
|
|
501
501
|
);
|
|
502
502
|
}
|
|
503
|
-
function
|
|
504
|
-
const n =
|
|
505
|
-
return n.size && t.id && n.has(t.id) || e.contains(t) ? !0 :
|
|
506
|
-
}
|
|
507
|
-
function Fe(e, t) {
|
|
508
|
-
const n = C(e), r = yn(t);
|
|
509
|
-
return n ? r : r ? !1 : bn(t);
|
|
503
|
+
function yn(e, t) {
|
|
504
|
+
const n = vt(e);
|
|
505
|
+
return n.size && t.id && n.has(t.id) || e.contains(t) ? !0 : wn(t) ? St(e) : n.size > 0 || Y(e).some((o) => o.getAttribute("aria-controls") || o.getAttribute("aria-owns")) ? !1 : Et(e, t) > 0;
|
|
510
506
|
}
|
|
511
|
-
function
|
|
512
|
-
|
|
507
|
+
function Oe(e, t) {
|
|
508
|
+
const n = C(e), r = bn(t);
|
|
509
|
+
return n ? r : r ? !1 : mn(t);
|
|
513
510
|
}
|
|
514
511
|
function bn(e) {
|
|
515
|
-
return e.matches(
|
|
512
|
+
return e.matches(yt) || !!e.querySelector(".el-cascader-node, .ant-cascader-menu-item, .van-cascader__option, .n-cascader-node, .arco-cascader-option");
|
|
516
513
|
}
|
|
517
514
|
function mn(e) {
|
|
515
|
+
return e.matches(gt) || !!e.querySelector('.el-select-dropdown__item, .ant-select-item-option, .van-picker-column__item, .van-action-sheet__item, .van-dropdown-item__option, [role="option"]');
|
|
516
|
+
}
|
|
517
|
+
function wn(e) {
|
|
518
518
|
return e.matches(".van-popup, .van-action-sheet, .van-picker, .van-dropdown-item__content, .van-dropdown-item");
|
|
519
519
|
}
|
|
520
|
-
function
|
|
520
|
+
function St(e) {
|
|
521
521
|
return Y(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused") || e.contains(document.activeElement));
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function vn(e) {
|
|
524
524
|
return e.matches(le) || !!e.querySelector(le);
|
|
525
525
|
}
|
|
526
|
-
function
|
|
526
|
+
function Et(e, t) {
|
|
527
527
|
const n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
528
528
|
if (!n.width || !n.height || !r.width || !r.height)
|
|
529
529
|
return 0;
|
|
@@ -532,9 +532,9 @@ function St(e, t) {
|
|
|
532
532
|
const i = r.top >= n.bottom ? r.top - n.bottom : n.top - r.bottom;
|
|
533
533
|
return i > 320 ? 0 : Math.max(0, 400 - i) + o;
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function Sn(e) {
|
|
536
536
|
const t = e.slice(0, 8).map((r) => p(String(r.label || r.value || ""))).filter(Boolean);
|
|
537
|
-
return t.length < 4 ? !1 : t.filter((r) =>
|
|
537
|
+
return t.length < 4 ? !1 : t.filter((r) => rn.test(r)).length / t.length >= 0.75;
|
|
538
538
|
}
|
|
539
539
|
function Y(e) {
|
|
540
540
|
return [
|
|
@@ -561,9 +561,9 @@ function Y(e) {
|
|
|
561
561
|
e.querySelector(".select__wrapper")
|
|
562
562
|
].filter((n) => n instanceof HTMLElement).filter((n, r, o) => o.indexOf(n) === r);
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function En() {
|
|
565
565
|
const e = /* @__PURE__ */ new Map();
|
|
566
|
-
|
|
566
|
+
xn(), document.documentElement.setAttribute(Le, "true");
|
|
567
567
|
const t = () => {
|
|
568
568
|
for (const r of document.querySelectorAll(Me))
|
|
569
569
|
e.has(r) || e.set(r, {
|
|
@@ -589,7 +589,7 @@ function Sn() {
|
|
|
589
589
|
}
|
|
590
590
|
};
|
|
591
591
|
}
|
|
592
|
-
function
|
|
592
|
+
function xn() {
|
|
593
593
|
if (document.getElementById(Be)) return;
|
|
594
594
|
const e = document.createElement("style");
|
|
595
595
|
e.id = Be, e.textContent = `
|
|
@@ -603,27 +603,27 @@ function En() {
|
|
|
603
603
|
}
|
|
604
604
|
`, document.head.appendChild(e);
|
|
605
605
|
}
|
|
606
|
-
async function
|
|
606
|
+
async function kn(e, t) {
|
|
607
607
|
e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await M(120);
|
|
608
608
|
for (const n of t.getTrackedDropdowns())
|
|
609
609
|
n.isConnected && (n.style.display = "none", n.setAttribute("aria-hidden", "true"));
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function xt(e) {
|
|
612
612
|
window.PointerEvent && (e.dispatchEvent(new PointerEvent("pointerdown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new PointerEvent("pointerup", { bubbles: !0, composed: !0, button: 0 }))), e.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, composed: !0, button: 0 })), e.click();
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function kt(e) {
|
|
615
615
|
e.focus({ preventScroll: !0 });
|
|
616
616
|
const t = e instanceof HTMLInputElement ? e : e.querySelector("input");
|
|
617
617
|
t instanceof HTMLElement && t.focus({ preventScroll: !0 });
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function _t(e) {
|
|
620
620
|
for (const t of [{ key: "ArrowDown", code: "ArrowDown" }, { key: "Enter", code: "Enter" }, { key: " ", code: "Space" }])
|
|
621
621
|
e.dispatchEvent(new KeyboardEvent("keydown", { ...t, bubbles: !0, composed: !0 })), e.dispatchEvent(new KeyboardEvent("keyup", { ...t, bubbles: !0, composed: !0 }));
|
|
622
622
|
}
|
|
623
623
|
function M(e) {
|
|
624
624
|
return new Promise((t) => window.setTimeout(t, e));
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function _n() {
|
|
627
627
|
const e = /* @__PURE__ */ new Map();
|
|
628
628
|
e.set(window, { left: window.scrollX, top: window.scrollY });
|
|
629
629
|
for (const t of document.querySelectorAll("*"))
|
|
@@ -633,7 +633,7 @@ function kn() {
|
|
|
633
633
|
t === window ? window.scrollTo(n.left, n.top) : t instanceof HTMLElement && (t.scrollLeft = n.left, t.scrollTop = n.top);
|
|
634
634
|
};
|
|
635
635
|
}
|
|
636
|
-
function
|
|
636
|
+
function Ct(e) {
|
|
637
637
|
const t = window.getComputedStyle(e);
|
|
638
638
|
if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0)
|
|
639
639
|
return !1;
|
|
@@ -686,22 +686,22 @@ const de = [
|
|
|
686
686
|
".van-dropdown-item__option",
|
|
687
687
|
".van-radio",
|
|
688
688
|
"[role='option']"
|
|
689
|
-
].join(", "),
|
|
689
|
+
].join(", "), Cn = [
|
|
690
690
|
".el-cascader-panel .el-cascader-menu",
|
|
691
691
|
".ant-cascader-menu",
|
|
692
692
|
".van-cascader__options",
|
|
693
693
|
".n-cascader-menu",
|
|
694
694
|
".arco-cascader-list"
|
|
695
|
-
].join(", "),
|
|
695
|
+
].join(", "), An = [
|
|
696
696
|
".el-cascader-node",
|
|
697
697
|
".ant-cascader-menu-item",
|
|
698
698
|
".van-cascader__option",
|
|
699
699
|
".n-cascader-node",
|
|
700
700
|
".arco-cascader-option"
|
|
701
|
-
].join(", "),
|
|
702
|
-
async function
|
|
703
|
-
const o =
|
|
704
|
-
return e instanceof HTMLSelectElement ?
|
|
701
|
+
].join(", "), Tn = ".van-picker__confirm, .van-picker__toolbar .van-picker__confirm";
|
|
702
|
+
async function Ln(e, t, n, r) {
|
|
703
|
+
const o = At(t, r);
|
|
704
|
+
return e instanceof HTMLSelectElement ? In(e, o) : C(e) || n === "cascader" ? Mn(e, o) : (j(e) || E(e) || n === "select" || n === "date", je(e, o));
|
|
705
705
|
}
|
|
706
706
|
function $e(e) {
|
|
707
707
|
if (e instanceof HTMLSelectElement) {
|
|
@@ -715,11 +715,11 @@ function $e(e) {
|
|
|
715
715
|
return p((r == null ? void 0 : r.textContent) || "");
|
|
716
716
|
}
|
|
717
717
|
if (j(e) || E(e))
|
|
718
|
-
return
|
|
718
|
+
return an(e);
|
|
719
719
|
const t = e.querySelector("input, textarea");
|
|
720
720
|
return p((t == null ? void 0 : t.value) || e.textContent || "");
|
|
721
721
|
}
|
|
722
|
-
async function
|
|
722
|
+
async function In(e, t) {
|
|
723
723
|
const n = Array.from(e.options).map((o) => ({
|
|
724
724
|
source: o,
|
|
725
725
|
value: o.value,
|
|
@@ -737,34 +737,34 @@ async function je(e, t) {
|
|
|
737
737
|
if (Se(n, t.searchValue)) return;
|
|
738
738
|
const r = new Set(W());
|
|
739
739
|
try {
|
|
740
|
-
if (!await
|
|
740
|
+
if (!await Rn(n)) {
|
|
741
741
|
if (V(n, t)) return;
|
|
742
742
|
throw new Error("自定义下拉框未能成功展开");
|
|
743
743
|
}
|
|
744
|
-
const i = await
|
|
744
|
+
const i = await Kn(n, r), s = await On(t.searchValue, i, !0);
|
|
745
745
|
if (!(s != null && s.source)) {
|
|
746
746
|
if (await fe(n), V(n, t)) return;
|
|
747
747
|
throw new Error("自定义下拉框展开后未找到匹配选项");
|
|
748
748
|
}
|
|
749
|
-
if (X(s.source), await y(120),
|
|
749
|
+
if (X(s.source), await y(120), Bn(), _(n), await y(120), Se(n, t.searchValue) || V(n, t) && Se(n, t.searchValue))
|
|
750
750
|
return;
|
|
751
751
|
throw new Error("自定义下拉框点击选项后未成功回填");
|
|
752
752
|
} finally {
|
|
753
753
|
await fe(n), await y(80);
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
|
-
async function
|
|
756
|
+
async function Mn(e, t) {
|
|
757
757
|
const n = e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader") || e;
|
|
758
758
|
if (!ve(n, t.searchValue)) {
|
|
759
759
|
try {
|
|
760
|
-
if (await
|
|
761
|
-
const o = await
|
|
760
|
+
if (await Fn(n)) {
|
|
761
|
+
const o = await Pn(t.searchValue);
|
|
762
762
|
if (await y(180), await fe(n), await y(120), o && ve(n, t.searchValue)) {
|
|
763
763
|
_(n);
|
|
764
764
|
return;
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
|
-
if (
|
|
767
|
+
if (Hn(n, t.fillValue) && ve(n, t.searchValue))
|
|
768
768
|
return;
|
|
769
769
|
} finally {
|
|
770
770
|
await fe(n), await y(80);
|
|
@@ -772,7 +772,7 @@ async function In(e, t) {
|
|
|
772
772
|
throw new Error("级联选择框匹配失败");
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
|
-
function
|
|
775
|
+
function At(e, t) {
|
|
776
776
|
var s;
|
|
777
777
|
const n = (s = t == null ? void 0 : t.options) != null && s.length ? be(
|
|
778
778
|
t.options.map((a) => ({
|
|
@@ -787,13 +787,13 @@ function Ct(e, t) {
|
|
|
787
787
|
displayValue: o
|
|
788
788
|
};
|
|
789
789
|
}
|
|
790
|
-
async function
|
|
790
|
+
async function Rn(e) {
|
|
791
791
|
const t = Ne(e);
|
|
792
792
|
for (const n of t)
|
|
793
|
-
if (
|
|
793
|
+
if (Lt(n), X(n), await y(160), Ge(e) || (It(n), await y(180), Ge(e))) return !0;
|
|
794
794
|
return !1;
|
|
795
795
|
}
|
|
796
|
-
async function
|
|
796
|
+
async function Fn(e) {
|
|
797
797
|
const t = [
|
|
798
798
|
e,
|
|
799
799
|
e.querySelector(".el-input__wrapper"),
|
|
@@ -802,16 +802,16 @@ async function Rn(e) {
|
|
|
802
802
|
e.querySelector("input")
|
|
803
803
|
].filter((n) => n instanceof HTMLElement);
|
|
804
804
|
for (const n of t)
|
|
805
|
-
if (
|
|
805
|
+
if (Lt(n), X(n), await y(180), pe().length || (It(n), await y(180), pe().length)) return !0;
|
|
806
806
|
return !1;
|
|
807
807
|
}
|
|
808
808
|
async function On(e, t, n = !1) {
|
|
809
809
|
for (let r = 0; r < 12; r += 1) {
|
|
810
810
|
const o = be(
|
|
811
|
-
|
|
811
|
+
Tt(t, n).map((i) => ({
|
|
812
812
|
source: i,
|
|
813
|
-
value:
|
|
814
|
-
label:
|
|
813
|
+
value: qn(i),
|
|
814
|
+
label: Dn(i)
|
|
815
815
|
})),
|
|
816
816
|
e
|
|
817
817
|
);
|
|
@@ -820,22 +820,22 @@ async function On(e, t, n = !1) {
|
|
|
820
820
|
}
|
|
821
821
|
return null;
|
|
822
822
|
}
|
|
823
|
-
function
|
|
823
|
+
function qn(e) {
|
|
824
824
|
return e.getAttribute("data-value") || e.getAttribute("data-name") || e.getAttribute("value") || e.getAttribute("name") || e.textContent || "";
|
|
825
825
|
}
|
|
826
|
-
function
|
|
826
|
+
function Dn(e) {
|
|
827
827
|
var t;
|
|
828
828
|
return p(
|
|
829
829
|
((t = e.querySelector(".van-action-sheet__name, .el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label")) == null ? void 0 : t.textContent) || e.textContent || ""
|
|
830
830
|
);
|
|
831
831
|
}
|
|
832
|
-
async function
|
|
833
|
-
const t =
|
|
832
|
+
async function Pn(e) {
|
|
833
|
+
const t = jn(e);
|
|
834
834
|
if (!t.length) return !1;
|
|
835
835
|
for (let n = 0; n < t.length; n += 1) {
|
|
836
836
|
const r = pe();
|
|
837
837
|
if (!r.length) return n > 0;
|
|
838
|
-
const o = r[r.length - 1], i = Array.from(o.querySelectorAll(
|
|
838
|
+
const o = r[r.length - 1], i = Array.from(o.querySelectorAll(An)).filter((a) => !a.classList.contains("is-disabled") && a.getAttribute("aria-disabled") !== "true"), s = be(
|
|
839
839
|
i.map((a) => {
|
|
840
840
|
var c;
|
|
841
841
|
return {
|
|
@@ -852,11 +852,11 @@ async function Dn(e) {
|
|
|
852
852
|
return !pe().length || !0;
|
|
853
853
|
}
|
|
854
854
|
function V(e, t) {
|
|
855
|
-
const n =
|
|
855
|
+
const n = Vn(t) ? t : At(t), r = n.displayValue || A(t), o = n.fillValue || r;
|
|
856
856
|
if (!r && !o) return !1;
|
|
857
857
|
const i = G(e) || e;
|
|
858
858
|
if (E(i))
|
|
859
|
-
return
|
|
859
|
+
return $n(i, r, o);
|
|
860
860
|
if (e instanceof HTMLSelectElement) {
|
|
861
861
|
let l = Array.from(e.options).find((u) => u.dataset.smartFillFallbackOption === "true");
|
|
862
862
|
return l || (l = document.createElement("option"), l.dataset.smartFillFallbackOption = "true", e.appendChild(l)), l.value = o, l.textContent = r || o, l.selected = !0, he(e, o), _(e), !0;
|
|
@@ -877,7 +877,7 @@ function V(e, t) {
|
|
|
877
877
|
a && (s.readOnly = !0, c && s.setAttribute("readonly", ""));
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
|
-
function
|
|
880
|
+
function Hn(e, t) {
|
|
881
881
|
const n = e.querySelector("input"), r = A(t);
|
|
882
882
|
return !(n instanceof HTMLInputElement) || !r || n.disabled ? !1 : V(e, {
|
|
883
883
|
searchValue: t,
|
|
@@ -885,8 +885,8 @@ function Pn(e, t) {
|
|
|
885
885
|
displayValue: r
|
|
886
886
|
});
|
|
887
887
|
}
|
|
888
|
-
function
|
|
889
|
-
|
|
888
|
+
function $n(e, t, n) {
|
|
889
|
+
Nn(e);
|
|
890
890
|
const r = e.querySelector(".van-field__control"), o = Array.from(e.querySelectorAll('input[type="hidden"]')), i = Array.from(e.querySelectorAll('input:not([type="hidden"])'));
|
|
891
891
|
r instanceof HTMLInputElement ? K(r, t || n) : r instanceof HTMLElement && (r.textContent = t || n);
|
|
892
892
|
for (const s of o)
|
|
@@ -895,7 +895,7 @@ function Hn(e, t, n) {
|
|
|
895
895
|
r !== s && K(s, t || n);
|
|
896
896
|
return _(e), !0;
|
|
897
897
|
}
|
|
898
|
-
function
|
|
898
|
+
function Nn(e) {
|
|
899
899
|
const t = e.querySelector(".van-field__control");
|
|
900
900
|
t instanceof HTMLInputElement ? K(t, "") : t instanceof HTMLElement && (t.textContent = "");
|
|
901
901
|
for (const n of e.querySelectorAll("input"))
|
|
@@ -915,7 +915,7 @@ function K(e, t) {
|
|
|
915
915
|
n && (e.readOnly = !0, r && e.setAttribute("readonly", ""));
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
|
-
function
|
|
918
|
+
function Vn(e) {
|
|
919
919
|
return typeof e == "object" && e != null && "searchValue" in e && "fillValue" in e && "displayValue" in e;
|
|
920
920
|
}
|
|
921
921
|
function Ne(e) {
|
|
@@ -938,21 +938,21 @@ function Ne(e) {
|
|
|
938
938
|
e.querySelector(".select__wrapper")
|
|
939
939
|
].filter((n) => n instanceof HTMLElement).filter((n, r, o) => o.indexOf(n) === r);
|
|
940
940
|
}
|
|
941
|
-
function
|
|
941
|
+
function Tt(e, t) {
|
|
942
942
|
return (e.length ? e : W()).flatMap((o) => o.matches(de) ? [o] : Array.from(o.querySelectorAll(de))).filter((o, i, s) => s.indexOf(o) === i).filter((o) => t ? !o.classList.contains("is-disabled") && !o.classList.contains("ant-select-item-option-disabled") && o.getAttribute("aria-disabled") !== "true" : D(o) && !o.classList.contains("is-disabled") && !o.classList.contains("ant-select-item-option-disabled") && o.getAttribute("aria-disabled") !== "true");
|
|
943
943
|
}
|
|
944
944
|
function pe() {
|
|
945
|
-
return Array.from(document.querySelectorAll(
|
|
945
|
+
return Array.from(document.querySelectorAll(Cn)).filter(D);
|
|
946
946
|
}
|
|
947
|
-
async function
|
|
947
|
+
async function Kn(e, t) {
|
|
948
948
|
for (let n = 0; n < 10; n += 1) {
|
|
949
|
-
const r =
|
|
949
|
+
const r = zn(e, t);
|
|
950
950
|
if (r.length) return r;
|
|
951
951
|
await y(80);
|
|
952
952
|
}
|
|
953
953
|
return W().filter(D);
|
|
954
954
|
}
|
|
955
|
-
function
|
|
955
|
+
function zn(e, t) {
|
|
956
956
|
const n = W(), r = n.filter((i) => !t.has(i));
|
|
957
957
|
if (r.length)
|
|
958
958
|
return r.sort((i, s) => oe(s) - oe(i));
|
|
@@ -966,7 +966,7 @@ function Kn(e, t) {
|
|
|
966
966
|
return n.filter((i) => D(i) && (i.querySelector(de) || i.matches(de))).sort((i, s) => oe(s) - oe(i)).slice(0, 1);
|
|
967
967
|
}
|
|
968
968
|
function Ge(e) {
|
|
969
|
-
return
|
|
969
|
+
return Tt(W().filter(D), !1).length > 0 ? !0 : Ne(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused"));
|
|
970
970
|
}
|
|
971
971
|
function ve(e, t) {
|
|
972
972
|
const n = w($e(e)), r = w(A(t));
|
|
@@ -985,21 +985,21 @@ function Se(e, t) {
|
|
|
985
985
|
return !!i && (n === i || n.includes(i) || i.includes(n));
|
|
986
986
|
});
|
|
987
987
|
}
|
|
988
|
-
function
|
|
989
|
-
const e = document.querySelector(
|
|
988
|
+
function Bn() {
|
|
989
|
+
const e = document.querySelector(Tn);
|
|
990
990
|
e && D(e) && X(e);
|
|
991
991
|
}
|
|
992
992
|
async function fe(e) {
|
|
993
993
|
e == null || e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await y(120);
|
|
994
994
|
}
|
|
995
995
|
function W() {
|
|
996
|
-
return Array.from(document.querySelectorAll(
|
|
996
|
+
return Array.from(document.querySelectorAll(Un()));
|
|
997
997
|
}
|
|
998
998
|
function oe(e) {
|
|
999
999
|
const t = e.getBoundingClientRect(), n = Number.parseInt(window.getComputedStyle(e).zIndex || "0", 10);
|
|
1000
1000
|
return (Number.isNaN(n) ? 0 : n) * 10 + t.width * t.height;
|
|
1001
1001
|
}
|
|
1002
|
-
function
|
|
1002
|
+
function Un() {
|
|
1003
1003
|
return [
|
|
1004
1004
|
".el-select-dropdown",
|
|
1005
1005
|
".el-cascader__dropdown",
|
|
@@ -1040,7 +1040,7 @@ function A(e) {
|
|
|
1040
1040
|
}
|
|
1041
1041
|
return p(String(e));
|
|
1042
1042
|
}
|
|
1043
|
-
function
|
|
1043
|
+
function jn(e) {
|
|
1044
1044
|
const t = A(e);
|
|
1045
1045
|
if (!t) return [];
|
|
1046
1046
|
if (t.includes("/") || t.includes("、"))
|
|
@@ -1059,12 +1059,12 @@ function _(e) {
|
|
|
1059
1059
|
function X(e) {
|
|
1060
1060
|
window.PointerEvent && (e.dispatchEvent(new PointerEvent("pointerdown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new PointerEvent("pointerup", { bubbles: !0, composed: !0, button: 0 }))), e.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, composed: !0, button: 0 })), e.click();
|
|
1061
1061
|
}
|
|
1062
|
-
function
|
|
1062
|
+
function Lt(e) {
|
|
1063
1063
|
e.focus({ preventScroll: !0 });
|
|
1064
1064
|
const t = e instanceof HTMLInputElement ? e : e.querySelector("input");
|
|
1065
1065
|
t instanceof HTMLElement && t.focus({ preventScroll: !0 });
|
|
1066
1066
|
}
|
|
1067
|
-
function
|
|
1067
|
+
function It(e) {
|
|
1068
1068
|
for (const t of [{ key: "ArrowDown", code: "ArrowDown" }, { key: "Enter", code: "Enter" }, { key: " ", code: "Space" }])
|
|
1069
1069
|
e.dispatchEvent(new KeyboardEvent("keydown", { ...t, bubbles: !0, composed: !0 })), e.dispatchEvent(new KeyboardEvent("keyup", { ...t, bubbles: !0, composed: !0 }));
|
|
1070
1070
|
}
|
|
@@ -1077,58 +1077,58 @@ function D(e) {
|
|
|
1077
1077
|
function y(e) {
|
|
1078
1078
|
return new Promise((t) => window.setTimeout(t, e));
|
|
1079
1079
|
}
|
|
1080
|
-
const Ye = /* @__PURE__ */ new Set(["select", "cascader", "date"]),
|
|
1080
|
+
const Ye = /* @__PURE__ */ new Set(["select", "cascader", "date"]), Mt = {
|
|
1081
1081
|
name: "ui-framework",
|
|
1082
|
-
match: (e) => e.matches(
|
|
1082
|
+
match: (e) => e.matches(ut) || dt(e) || !Gn(e) && Fe(e),
|
|
1083
1083
|
getValue: (e) => {
|
|
1084
1084
|
var o, i;
|
|
1085
1085
|
const t = e.element;
|
|
1086
1086
|
if (!t) return;
|
|
1087
|
-
const n =
|
|
1087
|
+
const n = O(t);
|
|
1088
1088
|
if ((n == null ? void 0 : n.kind) === "switch") return U(t);
|
|
1089
|
-
if ((n == null ? void 0 : n.kind) === "radioGroup") return
|
|
1090
|
-
if ((n == null ? void 0 : n.kind) === "checkboxGroup") return
|
|
1089
|
+
if ((n == null ? void 0 : n.kind) === "radioGroup") return Zn(t);
|
|
1090
|
+
if ((n == null ? void 0 : n.kind) === "checkboxGroup") return Jn(t);
|
|
1091
1091
|
const r = e.type || ce(t) || (n == null ? void 0 : n.type);
|
|
1092
|
-
return r && Ye.has(r) ? $e(t) : n ? ((i =
|
|
1092
|
+
return r && Ye.has(r) ? $e(t) : n ? ((i = F(t)) == null ? void 0 : i.value) || t.textContent || void 0 : (o = F(t)) == null ? void 0 : o.value;
|
|
1093
1093
|
},
|
|
1094
1094
|
setValue: async (e, t) => {
|
|
1095
1095
|
const n = e.element;
|
|
1096
1096
|
if (!n) return;
|
|
1097
|
-
const r =
|
|
1097
|
+
const r = O(n);
|
|
1098
1098
|
if ((r == null ? void 0 : r.kind) === "switch") {
|
|
1099
|
-
|
|
1099
|
+
Yn(n, t);
|
|
1100
1100
|
return;
|
|
1101
1101
|
}
|
|
1102
1102
|
if ((r == null ? void 0 : r.kind) === "radioGroup") {
|
|
1103
|
-
|
|
1103
|
+
Xn(n, t);
|
|
1104
1104
|
return;
|
|
1105
1105
|
}
|
|
1106
1106
|
if ((r == null ? void 0 : r.kind) === "checkboxGroup") {
|
|
1107
|
-
|
|
1107
|
+
Wn(n, t);
|
|
1108
1108
|
return;
|
|
1109
1109
|
}
|
|
1110
1110
|
const o = e.type || ce(n) || (r == null ? void 0 : r.type);
|
|
1111
|
-
if (o && Ye.has(o) ||
|
|
1112
|
-
await
|
|
1111
|
+
if (o && Ye.has(o) || Fe(n, o || void 0)) {
|
|
1112
|
+
await Ln(n, t, o || "select", e);
|
|
1113
1113
|
return;
|
|
1114
1114
|
}
|
|
1115
|
-
const i =
|
|
1115
|
+
const i = F(n);
|
|
1116
1116
|
if (i) {
|
|
1117
|
-
|
|
1117
|
+
Qn(i, t);
|
|
1118
1118
|
return;
|
|
1119
1119
|
}
|
|
1120
1120
|
n.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1121
1121
|
}
|
|
1122
|
-
},
|
|
1123
|
-
function
|
|
1122
|
+
}, Mo = Mt;
|
|
1123
|
+
function Gn(e) {
|
|
1124
1124
|
return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement;
|
|
1125
1125
|
}
|
|
1126
|
-
function Gn(e, t) {
|
|
1127
|
-
U(e) !== Qn(t) && ge(e);
|
|
1128
|
-
}
|
|
1129
1126
|
function Yn(e, t) {
|
|
1127
|
+
U(e) !== er(t) && ge(e);
|
|
1128
|
+
}
|
|
1129
|
+
function Wn(e, t) {
|
|
1130
1130
|
var o;
|
|
1131
|
-
const n = new Set(
|
|
1131
|
+
const n = new Set(tr(t).map(k)), r = pt(e) || [];
|
|
1132
1132
|
for (const i of B(e)) {
|
|
1133
1133
|
const s = Z(i.textContent || ""), a = i.getAttribute("value") || ((o = i.querySelector("input")) == null ? void 0 : o.value) || s, c = U(i), l = n.has(k(String(a))) || n.has(k(s));
|
|
1134
1134
|
c !== l && ge(i);
|
|
@@ -1137,7 +1137,7 @@ function Yn(e, t) {
|
|
|
1137
1137
|
for (const i of r)
|
|
1138
1138
|
(n.has(k(String(i.value))) || n.has(k(i.label))) && ge(e);
|
|
1139
1139
|
}
|
|
1140
|
-
function
|
|
1140
|
+
function Xn(e, t) {
|
|
1141
1141
|
const n = k(String(t ?? "")), r = B(e).find((o) => {
|
|
1142
1142
|
var a;
|
|
1143
1143
|
const i = Z(o.textContent || ""), s = o.getAttribute("value") || ((a = o.querySelector("input")) == null ? void 0 : a.value) || i;
|
|
@@ -1145,32 +1145,32 @@ function Wn(e, t) {
|
|
|
1145
1145
|
});
|
|
1146
1146
|
r && ge(r);
|
|
1147
1147
|
}
|
|
1148
|
-
function
|
|
1148
|
+
function Zn(e) {
|
|
1149
1149
|
var n;
|
|
1150
1150
|
const t = B(e).find((r) => U(r));
|
|
1151
1151
|
if (t)
|
|
1152
1152
|
return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) || Z(t.textContent || "");
|
|
1153
1153
|
}
|
|
1154
|
-
function
|
|
1154
|
+
function Jn(e) {
|
|
1155
1155
|
return B(e).filter((t) => U(t)).map((t) => {
|
|
1156
1156
|
var n;
|
|
1157
1157
|
return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) || Z(t.textContent || "");
|
|
1158
1158
|
});
|
|
1159
1159
|
}
|
|
1160
1160
|
function B(e) {
|
|
1161
|
-
const t =
|
|
1161
|
+
const t = O(e);
|
|
1162
1162
|
return t != null && t.optionSelector ? Array.from(e.querySelectorAll(t.optionSelector)) : [];
|
|
1163
1163
|
}
|
|
1164
|
-
function
|
|
1164
|
+
function Qn(e, t) {
|
|
1165
1165
|
e.value = String(t ?? ""), e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 })), e.dispatchEvent(new Event("blur", { bubbles: !0 }));
|
|
1166
1166
|
}
|
|
1167
1167
|
function ge(e) {
|
|
1168
1168
|
e.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window }));
|
|
1169
1169
|
}
|
|
1170
|
-
function
|
|
1170
|
+
function er(e) {
|
|
1171
1171
|
return typeof e == "boolean" ? e : ["true", "1", "是", "开启", "启用", "yes", "y"].includes(String(e ?? "").trim().toLowerCase());
|
|
1172
1172
|
}
|
|
1173
|
-
function
|
|
1173
|
+
function tr(e) {
|
|
1174
1174
|
return Array.isArray(e) ? e.map(String) : String(e ?? "").split(/[,,;;、]/).map((t) => t.trim()).filter(Boolean);
|
|
1175
1175
|
}
|
|
1176
1176
|
function k(e) {
|
|
@@ -1179,8 +1179,8 @@ function k(e) {
|
|
|
1179
1179
|
function Z(e) {
|
|
1180
1180
|
return e.replace(/\s+/g, " ").trim();
|
|
1181
1181
|
}
|
|
1182
|
-
const
|
|
1183
|
-
class
|
|
1182
|
+
const nr = "https://uat.kingdeefin.com";
|
|
1183
|
+
class Rt extends Error {
|
|
1184
1184
|
constructor(n) {
|
|
1185
1185
|
super(n.message);
|
|
1186
1186
|
/** 结构化错误信息,含 code / stage / retryable */
|
|
@@ -1189,10 +1189,10 @@ class Mt extends Error {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
1191
1191
|
function b(e, t, n, r = {}) {
|
|
1192
|
-
return new
|
|
1192
|
+
return new Rt({ code: e, message: t, stage: n, ...r });
|
|
1193
1193
|
}
|
|
1194
1194
|
function We(e, t, n = "RECOGNIZE_FAILED") {
|
|
1195
|
-
return e instanceof
|
|
1195
|
+
return e instanceof Rt ? e.smartFillError : {
|
|
1196
1196
|
code: n,
|
|
1197
1197
|
message: e instanceof Error ? e.message : String(e || "智能录入异常"),
|
|
1198
1198
|
stage: t,
|
|
@@ -1202,12 +1202,12 @@ function We(e, t, n = "RECOGNIZE_FAILED") {
|
|
|
1202
1202
|
function ye(e = "sf") {
|
|
1203
1203
|
return `${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1204
1204
|
}
|
|
1205
|
-
class
|
|
1205
|
+
class rr {
|
|
1206
1206
|
constructor(t) {
|
|
1207
1207
|
/** 会话 accessToken,写入请求头 seToken */
|
|
1208
1208
|
d(this, "seToken", "");
|
|
1209
1209
|
/** 网关根地址,见 config/defaults.ts */
|
|
1210
|
-
d(this, "baseURL",
|
|
1210
|
+
d(this, "baseURL", nr);
|
|
1211
1211
|
this.config = t;
|
|
1212
1212
|
}
|
|
1213
1213
|
/** 设置会话 token,后续 request 自动携带 seToken 请求头 */
|
|
@@ -1270,7 +1270,7 @@ class nr {
|
|
|
1270
1270
|
userInputMsg: r || ""
|
|
1271
1271
|
})
|
|
1272
1272
|
}
|
|
1273
|
-
), i =
|
|
1273
|
+
), i = ir(o, t.fields, t.scanToken);
|
|
1274
1274
|
return console.log("suggestions", i), {
|
|
1275
1275
|
scanToken: t.scanToken,
|
|
1276
1276
|
suggestions: i,
|
|
@@ -1294,7 +1294,7 @@ class nr {
|
|
|
1294
1294
|
method: "POST",
|
|
1295
1295
|
body: n
|
|
1296
1296
|
}
|
|
1297
|
-
), o =
|
|
1297
|
+
), o = ar(r);
|
|
1298
1298
|
if (!o)
|
|
1299
1299
|
throw b("RECOGNIZE_FAILED", "图片识别未提取到文本内容。", "recognize");
|
|
1300
1300
|
return o;
|
|
@@ -1310,7 +1310,7 @@ class nr {
|
|
|
1310
1310
|
signal: r.signal
|
|
1311
1311
|
});
|
|
1312
1312
|
if (!s.ok)
|
|
1313
|
-
throw b(
|
|
1313
|
+
throw b(cr(s.status), await s.text(), t.includes("session") ? "setup" : "recognize", {
|
|
1314
1314
|
retryable: s.status >= 500 || s.status === 429
|
|
1315
1315
|
});
|
|
1316
1316
|
return s.json();
|
|
@@ -1321,8 +1321,8 @@ class nr {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
}
|
|
1323
1323
|
}
|
|
1324
|
-
const
|
|
1325
|
-
function
|
|
1324
|
+
const or = 0.95;
|
|
1325
|
+
function ir(e, t, n) {
|
|
1326
1326
|
var i;
|
|
1327
1327
|
const r = new Map(t.map((s) => [s.fieldId, s]));
|
|
1328
1328
|
return (((i = e.data) == null ? void 0 : i.fieldValues) || []).filter((s) => !!(s != null && s.fieldId)).map((s) => {
|
|
@@ -1333,24 +1333,24 @@ function or(e, t, n) {
|
|
|
1333
1333
|
label: s.label || (a == null ? void 0 : a.label) || s.fieldId,
|
|
1334
1334
|
value: s.value,
|
|
1335
1335
|
displayValue: s.value == null ? "" : String(s.value),
|
|
1336
|
-
confidence:
|
|
1336
|
+
confidence: sr(s.confidence),
|
|
1337
1337
|
source: s.source || "ai",
|
|
1338
1338
|
warnings: s.warnings
|
|
1339
1339
|
};
|
|
1340
1340
|
});
|
|
1341
1341
|
}
|
|
1342
|
-
function ir(e) {
|
|
1343
|
-
return typeof e != "number" || Number.isNaN(e) ? rr : e < 0 ? 0 : e > 1 ? 1 : e;
|
|
1344
|
-
}
|
|
1345
1342
|
function sr(e) {
|
|
1343
|
+
return typeof e != "number" || Number.isNaN(e) ? or : e < 0 ? 0 : e > 1 ? 1 : e;
|
|
1344
|
+
}
|
|
1345
|
+
function ar(e) {
|
|
1346
1346
|
var n;
|
|
1347
1347
|
const t = typeof e.data == "string" ? e.data : ((n = e.data) == null ? void 0 : n.text) || e.text || "";
|
|
1348
1348
|
return String(t || "").trim();
|
|
1349
1349
|
}
|
|
1350
|
-
function
|
|
1350
|
+
function cr(e) {
|
|
1351
1351
|
return e === 401 ? "TOKEN_EXPIRED" : e === 403 ? "API_KEY_FORBIDDEN" : e === 404 ? "FORM_CONFIG_NOT_FOUND" : "RECOGNIZE_FAILED";
|
|
1352
1352
|
}
|
|
1353
|
-
class
|
|
1353
|
+
class Ft {
|
|
1354
1354
|
constructor() {
|
|
1355
1355
|
d(this, "handlers", /* @__PURE__ */ new Map());
|
|
1356
1356
|
}
|
|
@@ -1371,7 +1371,7 @@ class Rt {
|
|
|
1371
1371
|
this.handlers.clear();
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
|
-
class
|
|
1374
|
+
class lr {
|
|
1375
1375
|
constructor() {
|
|
1376
1376
|
/** 当前页面所有存活实例 */
|
|
1377
1377
|
d(this, "instances", /* @__PURE__ */ new Set());
|
|
@@ -1395,14 +1395,14 @@ class cr {
|
|
|
1395
1395
|
this.instances.forEach((t) => t.destroy()), this.instances.clear(), this.active = null;
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
|
-
const
|
|
1398
|
+
const ur = [
|
|
1399
1399
|
/^(el|rc|ant|radix|headlessui|mui|chakra)-/i,
|
|
1400
1400
|
/[0-9a-f]{8,}/i,
|
|
1401
1401
|
/\d{6,}/
|
|
1402
1402
|
];
|
|
1403
1403
|
function S(e) {
|
|
1404
1404
|
const t = String(e || "").trim();
|
|
1405
|
-
return !t ||
|
|
1405
|
+
return !t || ur.some((n) => n.test(t)) ? "" : t;
|
|
1406
1406
|
}
|
|
1407
1407
|
function z(e) {
|
|
1408
1408
|
const t = (e.options || []).slice(0, 20).map((n) => `${n.label}:${String(n.value)}`).join("|");
|
|
@@ -1423,7 +1423,41 @@ function z(e) {
|
|
|
1423
1423
|
function q(e) {
|
|
1424
1424
|
return String(e ?? "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
1425
1425
|
}
|
|
1426
|
-
const
|
|
1426
|
+
const Xe = "smart-fill-highlight-style", dr = `
|
|
1427
|
+
[data-smart-fill-highlighted="true"] {
|
|
1428
|
+
background: #eaf3ff !important;
|
|
1429
|
+
box-shadow: 0 0 0 1px #91caff inset !important;
|
|
1430
|
+
transition: background-color 0.2s ease, box-shadow 0.2s ease !important;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
[data-smart-fill-highlighted="true"] input:not([type="hidden"]),
|
|
1434
|
+
[data-smart-fill-highlighted="true"] textarea {
|
|
1435
|
+
background: #eaf3ff !important;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
[data-smart-fill-highlighted="true"].el-select,
|
|
1439
|
+
[data-smart-fill-highlighted="true"].el-select-v2,
|
|
1440
|
+
[data-smart-fill-highlighted="true"] .el-select__wrapper,
|
|
1441
|
+
[data-smart-fill-highlighted="true"] .el-select-v2__wrapper,
|
|
1442
|
+
[data-smart-fill-highlighted="true"] .el-input__wrapper,
|
|
1443
|
+
[data-smart-fill-highlighted="true"] .el-date-editor,
|
|
1444
|
+
[data-smart-fill-highlighted="true"] .ant-select-selector,
|
|
1445
|
+
[data-smart-fill-highlighted="true"] .ant-picker,
|
|
1446
|
+
[data-smart-fill-highlighted="true"] .n-base-selection,
|
|
1447
|
+
[data-smart-fill-highlighted="true"] .arco-select-view,
|
|
1448
|
+
[data-smart-fill-highlighted="true"] .van-field__body,
|
|
1449
|
+
[data-smart-fill-highlighted="true"] .van-field__control {
|
|
1450
|
+
background: #eaf3ff !important;
|
|
1451
|
+
box-shadow: 0 0 0 1px #91caff inset !important;
|
|
1452
|
+
}
|
|
1453
|
+
`.trim();
|
|
1454
|
+
function pr() {
|
|
1455
|
+
if (typeof document > "u" || document.getElementById(Xe))
|
|
1456
|
+
return;
|
|
1457
|
+
const e = document.createElement("style");
|
|
1458
|
+
e.id = Xe, e.textContent = dr, document.head.appendChild(e);
|
|
1459
|
+
}
|
|
1460
|
+
const Ee = /* @__PURE__ */ new WeakMap(), fr = [
|
|
1427
1461
|
'input:not([type="hidden"])',
|
|
1428
1462
|
"textarea",
|
|
1429
1463
|
"select",
|
|
@@ -1444,7 +1478,7 @@ const Ee = /* @__PURE__ */ new WeakMap(), ur = [
|
|
|
1444
1478
|
".van-field__body",
|
|
1445
1479
|
"[role='combobox']"
|
|
1446
1480
|
].join(", ");
|
|
1447
|
-
class
|
|
1481
|
+
class Ze {
|
|
1448
1482
|
constructor(t, n, r = []) {
|
|
1449
1483
|
this.fields = t, this.schemas = n, this.adapters = r;
|
|
1450
1484
|
}
|
|
@@ -1465,7 +1499,7 @@ class Xe {
|
|
|
1465
1499
|
r.push(se(i.fieldId, i.label, o.value, "页面扫描已过期,请重新扫描", "SCAN_TOKEN_EXPIRED"));
|
|
1466
1500
|
continue;
|
|
1467
1501
|
}
|
|
1468
|
-
const s =
|
|
1502
|
+
const s = wr(this.schemas, o.fieldId), a = s != null && s.transform ? s.transform(o.value) : o.value, c = await this.getValue(i, s);
|
|
1469
1503
|
try {
|
|
1470
1504
|
const l = s != null && s.validate ? await s.validate(a) : !0;
|
|
1471
1505
|
if (l !== !0) {
|
|
@@ -1516,7 +1550,7 @@ class Xe {
|
|
|
1516
1550
|
await i.setValue(t, n), xe(o, t);
|
|
1517
1551
|
return;
|
|
1518
1552
|
}
|
|
1519
|
-
|
|
1553
|
+
gr(o, n), xe(o, t);
|
|
1520
1554
|
}
|
|
1521
1555
|
/** 匹配第一个适用的组件库适配器 */
|
|
1522
1556
|
matchAdapter(t, n) {
|
|
@@ -1527,10 +1561,10 @@ class Xe {
|
|
|
1527
1561
|
function ie(e, t) {
|
|
1528
1562
|
var r;
|
|
1529
1563
|
if ((r = e.element) != null && r.isConnected) return e.element;
|
|
1530
|
-
const n =
|
|
1564
|
+
const n = hr(t == null ? void 0 : t.element);
|
|
1531
1565
|
return n || document.querySelector(`[data-smart-fill-id="${qe(e.fieldId)}"]`);
|
|
1532
1566
|
}
|
|
1533
|
-
function
|
|
1567
|
+
function hr(e) {
|
|
1534
1568
|
if (e instanceof HTMLElement)
|
|
1535
1569
|
return e.isConnected ? e : null;
|
|
1536
1570
|
if (typeof e == "string")
|
|
@@ -1542,7 +1576,7 @@ function dr(e) {
|
|
|
1542
1576
|
}
|
|
1543
1577
|
return null;
|
|
1544
1578
|
}
|
|
1545
|
-
function
|
|
1579
|
+
function gr(e, t) {
|
|
1546
1580
|
if (e instanceof HTMLInputElement && e.type === "checkbox")
|
|
1547
1581
|
e.checked = !!t;
|
|
1548
1582
|
else if (e instanceof HTMLInputElement && e.type === "radio") {
|
|
@@ -1552,32 +1586,36 @@ function pr(e, t) {
|
|
|
1552
1586
|
e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1553
1587
|
}
|
|
1554
1588
|
function xe(e, t) {
|
|
1555
|
-
|
|
1556
|
-
|
|
1589
|
+
pr();
|
|
1590
|
+
const n = yr(e, t), r = () => {
|
|
1591
|
+
for (const o of n)
|
|
1592
|
+
o.isConnected && br(o);
|
|
1593
|
+
};
|
|
1594
|
+
typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => requestAnimationFrame(r)) : r();
|
|
1557
1595
|
}
|
|
1558
|
-
function
|
|
1596
|
+
function yr(e, t) {
|
|
1559
1597
|
if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement)
|
|
1560
1598
|
return [e];
|
|
1561
|
-
const n =
|
|
1562
|
-
Array.from(n.querySelectorAll(
|
|
1599
|
+
const n = Fe(e, t == null ? void 0 : t.type) && G(e) || e, r = mr(
|
|
1600
|
+
Array.from(n.querySelectorAll(fr)).filter(Je)
|
|
1563
1601
|
);
|
|
1564
1602
|
if (r.length)
|
|
1565
1603
|
return r;
|
|
1566
|
-
const o =
|
|
1567
|
-
return o &&
|
|
1604
|
+
const o = F(n);
|
|
1605
|
+
return o && Je(o) ? [o] : [n];
|
|
1568
1606
|
}
|
|
1569
|
-
function
|
|
1607
|
+
function br(e) {
|
|
1570
1608
|
var r;
|
|
1571
1609
|
e.setAttribute("data-smart-fill-highlighted", "true"), (r = Ee.get(e)) == null || r.abort();
|
|
1572
1610
|
const t = new AbortController(), n = (o) => {
|
|
1573
1611
|
o && "isTrusted" in o && !o.isTrusted || (e.removeAttribute("data-smart-fill-highlighted"), t.abort(), Ee.delete(e));
|
|
1574
1612
|
};
|
|
1575
|
-
Ee.set(e, t), e.addEventListener("
|
|
1613
|
+
Ee.set(e, t), e.addEventListener("pointerdown", n, { signal: t.signal }), e.addEventListener("mousedown", n, { signal: t.signal }), e.addEventListener("keydown", n, { signal: t.signal }), e.addEventListener("input", n, { signal: t.signal }), e.addEventListener("change", n, { signal: t.signal });
|
|
1576
1614
|
}
|
|
1577
|
-
function
|
|
1615
|
+
function mr(e) {
|
|
1578
1616
|
return e.filter((t) => !e.some((n) => n !== t && n.contains(t)));
|
|
1579
1617
|
}
|
|
1580
|
-
function
|
|
1618
|
+
function Je(e) {
|
|
1581
1619
|
const t = window.getComputedStyle(e);
|
|
1582
1620
|
if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0)
|
|
1583
1621
|
return !1;
|
|
@@ -1590,14 +1628,14 @@ function se(e, t, n, r, o) {
|
|
|
1590
1628
|
function qe(e) {
|
|
1591
1629
|
return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
1592
1630
|
}
|
|
1593
|
-
function
|
|
1631
|
+
function wr(e, t) {
|
|
1594
1632
|
const n = e.find((o) => o.fieldId === t);
|
|
1595
1633
|
if (n) return n;
|
|
1596
1634
|
const r = t.includes(":") ? t.slice(t.lastIndexOf(":") + 1) : "";
|
|
1597
1635
|
if (r)
|
|
1598
1636
|
return e.find((o) => o.rowKey != null && String(o.rowKey) === r && `${o.fieldId}:${o.rowKey}` === t);
|
|
1599
1637
|
}
|
|
1600
|
-
const
|
|
1638
|
+
const vr = [
|
|
1601
1639
|
{ key: "mobile", pattern: new RegExp("(?<!\\d)1[3-9]\\d{9}(?!\\d)", "g"), confidence: 0.98, reason: "手机号正则命中" },
|
|
1602
1640
|
{ key: "idCard", pattern: new RegExp("(?<!\\d)\\d{17}[\\dXx](?!\\d)", "g"), confidence: 0.96, reason: "身份证号正则命中" },
|
|
1603
1641
|
{ key: "email", pattern: /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, confidence: 0.95, reason: "邮箱正则命中" },
|
|
@@ -1664,20 +1702,20 @@ const br = [
|
|
|
1664
1702
|
amount: "amount",
|
|
1665
1703
|
date: "date"
|
|
1666
1704
|
};
|
|
1667
|
-
class
|
|
1705
|
+
class Sr {
|
|
1668
1706
|
/**
|
|
1669
1707
|
* 从文本中提取事实并匹配到 scan 字段。
|
|
1670
1708
|
* 按 confidence 降序分配,每个 fieldId 仅匹配一次(usedFieldIds 去重)。
|
|
1671
1709
|
*/
|
|
1672
1710
|
recognize(t, n, r) {
|
|
1673
|
-
const o =
|
|
1711
|
+
const o = Ir([...Er(t), ...xr(t)]), i = /* @__PURE__ */ new Set(), s = [];
|
|
1674
1712
|
for (const a of o.sort((c, l) => l.confidence - c.confidence)) {
|
|
1675
|
-
const c =
|
|
1713
|
+
const c = _r(a, n, i);
|
|
1676
1714
|
c && (s.push({
|
|
1677
1715
|
fieldId: c.fieldId,
|
|
1678
1716
|
scanToken: r,
|
|
1679
1717
|
label: c.label,
|
|
1680
|
-
value:
|
|
1718
|
+
value: Ar(a.value, c),
|
|
1681
1719
|
displayValue: a.value,
|
|
1682
1720
|
confidence: a.confidence,
|
|
1683
1721
|
source: "local_rule",
|
|
@@ -1687,11 +1725,11 @@ class mr {
|
|
|
1687
1725
|
return s;
|
|
1688
1726
|
}
|
|
1689
1727
|
}
|
|
1690
|
-
function
|
|
1728
|
+
function Er(e) {
|
|
1691
1729
|
const t = [];
|
|
1692
|
-
for (const n of
|
|
1730
|
+
for (const n of vr)
|
|
1693
1731
|
for (const r of e.matchAll(n.pattern)) {
|
|
1694
|
-
const o =
|
|
1732
|
+
const o = qt(r[1] || r[0]);
|
|
1695
1733
|
t.push({
|
|
1696
1734
|
key: n.key,
|
|
1697
1735
|
value: o,
|
|
@@ -1702,21 +1740,21 @@ function wr(e) {
|
|
|
1702
1740
|
}
|
|
1703
1741
|
return t;
|
|
1704
1742
|
}
|
|
1705
|
-
function
|
|
1743
|
+
function xr(e) {
|
|
1706
1744
|
const t = [], n = e.split(/\r?\n|[;,;]/).map((r) => r.trim()).filter(Boolean);
|
|
1707
1745
|
for (const r of n) {
|
|
1708
1746
|
const o = r.match(/^[“"'`]?([^::=]{2,30})[”"'`]?[::=]\s*(.+)$/);
|
|
1709
1747
|
if (!o) continue;
|
|
1710
|
-
const i =
|
|
1748
|
+
const i = Lr(o[1]), s = qt(o[2]);
|
|
1711
1749
|
if (!(!i || !s))
|
|
1712
|
-
for (const a of
|
|
1750
|
+
for (const a of kr(i, s))
|
|
1713
1751
|
t.push(a);
|
|
1714
1752
|
}
|
|
1715
1753
|
return t;
|
|
1716
1754
|
}
|
|
1717
|
-
function
|
|
1718
|
-
const n = q(e), r =
|
|
1719
|
-
return (x(n, I.mobile) || r === "mobile") && o.push("mobile"), (x(n, I.idCard) || r === "idCard") && o.push("idCard"), (x(n, I.email) || r === "email") && o.push("email"), (x(n, I.bankCard) || r === "bankCard") && o.push("bankCard"), (x(n, I.amount) || r === "amount") && o.push("amount"), (x(n, I.date) || r === "date") && o.push("date"),
|
|
1755
|
+
function kr(e, t) {
|
|
1756
|
+
const n = q(e), r = Tr(t), o = [];
|
|
1757
|
+
return (x(n, I.mobile) || r === "mobile") && o.push("mobile"), (x(n, I.idCard) || r === "idCard") && o.push("idCard"), (x(n, I.email) || r === "email") && o.push("email"), (x(n, I.bankCard) || r === "bankCard") && o.push("bankCard"), (x(n, I.amount) || r === "amount") && o.push("amount"), (x(n, I.date) || r === "date") && o.push("date"), Mr(o).map((i, s) => ({
|
|
1720
1758
|
key: i,
|
|
1721
1759
|
value: t,
|
|
1722
1760
|
confidence: Math.max(0.84, 0.96 - s * 0.04),
|
|
@@ -1724,39 +1762,39 @@ function Sr(e, t) {
|
|
|
1724
1762
|
baseKey: Ot[i]
|
|
1725
1763
|
}));
|
|
1726
1764
|
}
|
|
1727
|
-
function
|
|
1765
|
+
function _r(e, t, n) {
|
|
1728
1766
|
let r = null;
|
|
1729
1767
|
for (const o of t) {
|
|
1730
1768
|
if (n.has(o.fieldId)) continue;
|
|
1731
|
-
const i =
|
|
1769
|
+
const i = Cr(e, o);
|
|
1732
1770
|
i > ((r == null ? void 0 : r.score) ?? 0) && (r = { field: o, score: i });
|
|
1733
1771
|
}
|
|
1734
1772
|
return r && r.score >= 0.45 ? r.field : null;
|
|
1735
1773
|
}
|
|
1736
|
-
function
|
|
1774
|
+
function Cr(e, t) {
|
|
1737
1775
|
const n = q([t.fieldId, t.label, t.placeholder, t.name, t.id, t.section].join(" ")), r = I[e.key] || [e.key];
|
|
1738
1776
|
let o = 0;
|
|
1739
1777
|
return x(n, r) ? o += 0.95 : x(n, [e.key]) && (o += 0.82), n.includes(q(e.key)) && (o += 0.22), t.required && (o += 0.05), e.baseKey === "amount" && (t.type === "amount" || t.type === "number") && (o += 0.18), e.baseKey === "date" && t.type === "date" && (o += 0.18), ["email", "mobile", "idCard", "bankCard"].includes(e.baseKey) && t.type === "text" && (o += 0.08), Math.min(o, 1);
|
|
1740
1778
|
}
|
|
1741
|
-
function
|
|
1779
|
+
function Ar(e, t) {
|
|
1742
1780
|
var n;
|
|
1743
1781
|
return t.type === "date" ? e.replace(/[年月/.]/g, "-").replace(/日/g, "").replace(/--/g, "-") : t.type === "number" || t.type === "amount" ? ((n = e.match(/[0-9]+(?:\.[0-9]+)?/)) == null ? void 0 : n[0]) ?? e : t.name && /mobile|phone|idcard|bankcard/i.test(t.name) || t.id && /mobile|phone|idcard|bankcard/i.test(t.id) || /mobile|phone|idcard|bankcard/i.test(t.fieldId) ? e.replace(/\s+/g, "") : e;
|
|
1744
1782
|
}
|
|
1745
|
-
function
|
|
1783
|
+
function Tr(e) {
|
|
1746
1784
|
const t = e.replace(/\s+/g, "");
|
|
1747
1785
|
return /^1[3-9]\d{9}$/.test(t) ? "mobile" : /^\d{17}[\dXx]$/.test(t) ? "idCard" : /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(e) ? "email" : /^\d{16,19}$/.test(t) ? "bankCard" : /^\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?$/.test(e) ? "date" : /^[0-9]+(?:\.[0-9]{1,2})?$/.test(t) ? "amount" : "unknown";
|
|
1748
1786
|
}
|
|
1749
|
-
function
|
|
1787
|
+
function Lr(e) {
|
|
1750
1788
|
return e.replace(/[“”"'`]/g, "").replace(/\s+/g, " ").trim();
|
|
1751
1789
|
}
|
|
1752
|
-
function
|
|
1790
|
+
function qt(e) {
|
|
1753
1791
|
return e.replace(/[,。;;]+$/g, "").replace(/^[“”"'`\s]+|[“”"'`\s]+$/g, "").trim();
|
|
1754
1792
|
}
|
|
1755
1793
|
function x(e, t) {
|
|
1756
1794
|
const n = q(e);
|
|
1757
1795
|
return t.some((r) => n.includes(q(r)));
|
|
1758
1796
|
}
|
|
1759
|
-
function
|
|
1797
|
+
function Ir(e) {
|
|
1760
1798
|
const t = /* @__PURE__ */ new Map();
|
|
1761
1799
|
for (const n of e) {
|
|
1762
1800
|
const r = `${n.key}::${n.value}`, o = t.get(r);
|
|
@@ -1764,16 +1802,16 @@ function Ar(e) {
|
|
|
1764
1802
|
}
|
|
1765
1803
|
return [...t.values()];
|
|
1766
1804
|
}
|
|
1767
|
-
function
|
|
1805
|
+
function Mr(e) {
|
|
1768
1806
|
return [...new Set(e)];
|
|
1769
1807
|
}
|
|
1770
|
-
const
|
|
1808
|
+
const Qe = [
|
|
1771
1809
|
"input",
|
|
1772
1810
|
"textarea",
|
|
1773
1811
|
"select",
|
|
1774
1812
|
"[contenteditable]:not([contenteditable='false'])"
|
|
1775
|
-
].join(", "),
|
|
1776
|
-
class
|
|
1813
|
+
].join(", "), Rr = /* @__PURE__ */ new Set(["hidden", "submit", "button", "image", "reset", "file", "password"]);
|
|
1814
|
+
class Fr {
|
|
1777
1815
|
constructor(t = document) {
|
|
1778
1816
|
this.root = t;
|
|
1779
1817
|
}
|
|
@@ -1809,7 +1847,7 @@ class Ir {
|
|
|
1809
1847
|
r.push(s);
|
|
1810
1848
|
continue;
|
|
1811
1849
|
}
|
|
1812
|
-
const c = await
|
|
1850
|
+
const c = await cn(s.element), l = c != null && c.length && !ne({ ...s, options: c }) ? c : void 0;
|
|
1813
1851
|
if (!(l != null && l.length)) {
|
|
1814
1852
|
r.push({ ...s, options: ne(s) ? void 0 : s.options });
|
|
1815
1853
|
continue;
|
|
@@ -1824,7 +1862,7 @@ class Ir {
|
|
|
1824
1862
|
}
|
|
1825
1863
|
/** FieldSchema → FieldDescriptor,解析 element 并生成 fingerprint */
|
|
1826
1864
|
fromSchema(t, n) {
|
|
1827
|
-
const r =
|
|
1865
|
+
const r = zr(t.element, this.root), o = r ? Re(r) || Te(r) || r : null, i = {
|
|
1828
1866
|
fieldId: t.rowKey == null ? t.fieldId : `${t.fieldId}:${t.rowKey}`,
|
|
1829
1867
|
label: t.label,
|
|
1830
1868
|
type: t.type,
|
|
@@ -1845,20 +1883,20 @@ class Ir {
|
|
|
1845
1883
|
}
|
|
1846
1884
|
/** DOM 元素 → FieldDescriptor,自动推断 label/type 并写入 data-smart-fill-id */
|
|
1847
1885
|
fromElement(t, n, r, o = this.root) {
|
|
1848
|
-
const i =
|
|
1886
|
+
const i = Or(t, n), s = Pr(t, o), a = {
|
|
1849
1887
|
fieldId: i,
|
|
1850
1888
|
fingerprint: "",
|
|
1851
1889
|
scanToken: r,
|
|
1852
|
-
type:
|
|
1890
|
+
type: qr(t),
|
|
1853
1891
|
localRuleMode: "inherit",
|
|
1854
|
-
label:
|
|
1855
|
-
placeholder:
|
|
1856
|
-
name: S(
|
|
1892
|
+
label: Dt(t),
|
|
1893
|
+
placeholder: Ht(t),
|
|
1894
|
+
name: S(ft(t)) || void 0,
|
|
1857
1895
|
id: S(t.id) || void 0,
|
|
1858
|
-
section:
|
|
1896
|
+
section: Dr(t),
|
|
1859
1897
|
options: s,
|
|
1860
|
-
required:
|
|
1861
|
-
readonly:
|
|
1898
|
+
required: Nr(t),
|
|
1899
|
+
readonly: $r(t),
|
|
1862
1900
|
disabled: ke(t),
|
|
1863
1901
|
source: "form_scan",
|
|
1864
1902
|
element: t
|
|
@@ -1871,7 +1909,7 @@ class Ir {
|
|
|
1871
1909
|
/** 解析扫描根节点,scanContainer 为 CSS 选择器 */
|
|
1872
1910
|
resolveRoot(t) {
|
|
1873
1911
|
if (t) {
|
|
1874
|
-
const n =
|
|
1912
|
+
const n = $t(this.root, t);
|
|
1875
1913
|
if (n)
|
|
1876
1914
|
return n;
|
|
1877
1915
|
}
|
|
@@ -1879,14 +1917,14 @@ class Ir {
|
|
|
1879
1917
|
}
|
|
1880
1918
|
/** 收集 root 下可见且可编辑的表单控件 */
|
|
1881
1919
|
collectVisibleFields(t) {
|
|
1882
|
-
const n = /* @__PURE__ */ new Set(), r = [
|
|
1920
|
+
const n = /* @__PURE__ */ new Set(), r = [Qe, ht, ut, ".van-field"].join(", ");
|
|
1883
1921
|
for (const s of t.querySelectorAll(r)) {
|
|
1884
1922
|
if (!(s instanceof HTMLElement)) continue;
|
|
1885
1923
|
const a = Re(s) || Te(s);
|
|
1886
1924
|
!a || !De(a) || ke(a) || n.add(a);
|
|
1887
1925
|
}
|
|
1888
|
-
const o = [...n], i = Array.from(t.querySelectorAll(
|
|
1889
|
-
return
|
|
1926
|
+
const o = [...n], i = Array.from(t.querySelectorAll(Qe)).filter((s) => !(s instanceof HTMLElement) || !De(s) || Vr(s) || s instanceof HTMLInputElement && Rr.has((s.type || "").toLowerCase()) ? !1 : !ke(s) && !s.hasAttribute("readonly"));
|
|
1927
|
+
return Kr([...i, ...o]);
|
|
1890
1928
|
}
|
|
1891
1929
|
/**
|
|
1892
1930
|
* 检测最应优先扫描的容器。
|
|
@@ -1900,15 +1938,15 @@ class Ir {
|
|
|
1900
1938
|
return o.length ? o.sort((i, s) => t.filter((a) => s.contains(a)).length - t.filter((a) => i.contains(a)).length)[0] : document.body;
|
|
1901
1939
|
}
|
|
1902
1940
|
}
|
|
1903
|
-
function
|
|
1941
|
+
function Or(e, t) {
|
|
1904
1942
|
const n = e.getAttribute("data-smart-fill-id");
|
|
1905
1943
|
if (n)
|
|
1906
1944
|
return n;
|
|
1907
|
-
const o = S(e.getAttribute("name")) || S(e.getAttribute("data-smart-fill-key")) || S(
|
|
1945
|
+
const o = S(e.getAttribute("name")) || S(e.getAttribute("data-smart-fill-key")) || S(ft(e)) || S(e.id) || S(Dt(e)) || `smart-fill-${Date.now()}-${t}`;
|
|
1908
1946
|
return e.setAttribute("data-smart-fill-id", o), o;
|
|
1909
1947
|
}
|
|
1910
|
-
function
|
|
1911
|
-
const t =
|
|
1948
|
+
function qr(e) {
|
|
1949
|
+
const t = bt(e);
|
|
1912
1950
|
if (t) return t;
|
|
1913
1951
|
const n = ce(e);
|
|
1914
1952
|
if (n) return n;
|
|
@@ -1923,23 +1961,23 @@ function Rr(e) {
|
|
|
1923
1961
|
}
|
|
1924
1962
|
return "text";
|
|
1925
1963
|
}
|
|
1926
|
-
function
|
|
1964
|
+
function Dt(e) {
|
|
1927
1965
|
const t = e.getAttribute("aria-label");
|
|
1928
1966
|
if (t) return t.trim();
|
|
1929
1967
|
if (e.id) {
|
|
1930
1968
|
const i = document.querySelector(`label[for="${Ve(e.id)}"]`);
|
|
1931
1969
|
if (i != null && i.textContent) return p(i.textContent);
|
|
1932
1970
|
}
|
|
1933
|
-
const n = e.closest(
|
|
1971
|
+
const n = e.closest(Jt), r = n == null ? void 0 : n.querySelector(Qt);
|
|
1934
1972
|
if (r != null && r.textContent) return p(r.textContent);
|
|
1935
1973
|
const o = e.closest("label");
|
|
1936
1974
|
if (o) {
|
|
1937
|
-
const i =
|
|
1975
|
+
const i = Pt(o, e);
|
|
1938
1976
|
if (i) return i;
|
|
1939
1977
|
}
|
|
1940
|
-
return
|
|
1978
|
+
return Ht(e) || e.getAttribute("name") || e.id || "未命名字段";
|
|
1941
1979
|
}
|
|
1942
|
-
function
|
|
1980
|
+
function Pt(e, t) {
|
|
1943
1981
|
const n = e.cloneNode(!0);
|
|
1944
1982
|
for (const o of n.querySelectorAll('input, textarea, select, button, [role="combobox"], [role="listbox"]'))
|
|
1945
1983
|
o.remove();
|
|
@@ -1947,18 +1985,18 @@ function Dt(e, t) {
|
|
|
1947
1985
|
if (r)
|
|
1948
1986
|
return t instanceof HTMLInputElement && t.value && r.includes(t.value) ? p(r.replace(t.value, "")) || void 0 : r;
|
|
1949
1987
|
}
|
|
1950
|
-
function
|
|
1988
|
+
function Ht(e) {
|
|
1951
1989
|
var t;
|
|
1952
1990
|
return e.getAttribute("placeholder") || e.getAttribute("aria-placeholder") || ((t = e.querySelector("[placeholder]")) == null ? void 0 : t.getAttribute("placeholder")) || void 0;
|
|
1953
1991
|
}
|
|
1954
|
-
function
|
|
1992
|
+
function Dr(e) {
|
|
1955
1993
|
const t = e.closest("fieldset, section, .panel, .card, .form-section"), n = t == null ? void 0 : t.querySelector("legend, h1, h2, h3, .title, .section-title");
|
|
1956
1994
|
return n != null && n.textContent ? p(n.textContent) : void 0;
|
|
1957
1995
|
}
|
|
1958
|
-
function
|
|
1959
|
-
const n =
|
|
1996
|
+
function Pr(e, t = document) {
|
|
1997
|
+
const n = mt(e);
|
|
1960
1998
|
if (n != null && n.length) return n;
|
|
1961
|
-
const r =
|
|
1999
|
+
const r = pt(e);
|
|
1962
2000
|
if (r != null && r.length) return r;
|
|
1963
2001
|
if (e instanceof HTMLSelectElement)
|
|
1964
2002
|
return Array.from(e.options).map((o) => ({
|
|
@@ -1967,18 +2005,18 @@ function Fr(e, t = document) {
|
|
|
1967
2005
|
}));
|
|
1968
2006
|
if (e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && e.name)
|
|
1969
2007
|
return Array.from(t.querySelectorAll(`input[name="${Ve(e.name)}"]`)).filter((o) => o.type === e.type && De(o)).map((o) => ({
|
|
1970
|
-
label:
|
|
2008
|
+
label: Hr(o),
|
|
1971
2009
|
value: o.value || !0
|
|
1972
2010
|
}));
|
|
1973
2011
|
}
|
|
1974
|
-
function
|
|
2012
|
+
function Hr(e) {
|
|
1975
2013
|
if (e.id) {
|
|
1976
2014
|
const n = document.querySelector(`label[for="${Ve(e.id)}"]`);
|
|
1977
2015
|
if (n != null && n.textContent) return p(n.textContent);
|
|
1978
2016
|
}
|
|
1979
2017
|
const t = e.closest("label");
|
|
1980
2018
|
if (t) {
|
|
1981
|
-
const n =
|
|
2019
|
+
const n = Pt(t, e);
|
|
1982
2020
|
if (n) return n;
|
|
1983
2021
|
}
|
|
1984
2022
|
return p(e.getAttribute("aria-label") || e.value || "");
|
|
@@ -1988,27 +2026,27 @@ function De(e) {
|
|
|
1988
2026
|
return t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0 ? !1 : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1989
2027
|
}
|
|
1990
2028
|
function ke(e) {
|
|
1991
|
-
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof HTMLButtonElement ? e.disabled || e.getAttribute("aria-disabled") === "true" : e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true" ||
|
|
2029
|
+
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof HTMLButtonElement ? e.disabled || e.getAttribute("aria-disabled") === "true" : e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true" || Zt.some((t) => e.classList.contains(t));
|
|
1992
2030
|
}
|
|
1993
|
-
function
|
|
2031
|
+
function $r(e) {
|
|
1994
2032
|
return e.hasAttribute("readonly") || !!e.querySelector("[readonly]");
|
|
1995
2033
|
}
|
|
1996
|
-
function
|
|
2034
|
+
function Nr(e) {
|
|
1997
2035
|
return e.hasAttribute("required") || e.getAttribute("aria-required") === "true" || !!e.querySelector('[required], [aria-required="true"]');
|
|
1998
2036
|
}
|
|
1999
|
-
function
|
|
2037
|
+
function Vr(e) {
|
|
2000
2038
|
return Re(e) != null || Te(e) != null;
|
|
2001
2039
|
}
|
|
2002
|
-
function
|
|
2040
|
+
function Kr(e) {
|
|
2003
2041
|
const t = [];
|
|
2004
2042
|
for (const n of e)
|
|
2005
2043
|
t.some((r) => r === n || r.contains(n) || n.contains(r)) || t.push(n);
|
|
2006
2044
|
return t;
|
|
2007
2045
|
}
|
|
2008
|
-
function
|
|
2009
|
-
return e instanceof HTMLElement ? e : typeof e == "string" ?
|
|
2046
|
+
function zr(e, t) {
|
|
2047
|
+
return e instanceof HTMLElement ? e : typeof e == "string" ? $t(t, e) : null;
|
|
2010
2048
|
}
|
|
2011
|
-
function
|
|
2049
|
+
function $t(e, t) {
|
|
2012
2050
|
try {
|
|
2013
2051
|
const n = e.querySelector(t);
|
|
2014
2052
|
return n instanceof HTMLElement ? n : null;
|
|
@@ -2019,8 +2057,8 @@ function Ht(e, t) {
|
|
|
2019
2057
|
function Ve(e) {
|
|
2020
2058
|
return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
2021
2059
|
}
|
|
2022
|
-
const _e = 5,
|
|
2023
|
-
class
|
|
2060
|
+
const _e = 5, Br = 10 * 1024 * 1024, Ur = 50 * 1024 * 1024;
|
|
2061
|
+
class jr {
|
|
2024
2062
|
constructor(t) {
|
|
2025
2063
|
/** 面板宿主元素,挂载到 container 下 */
|
|
2026
2064
|
d(this, "host", null);
|
|
@@ -2056,7 +2094,7 @@ class zr {
|
|
|
2056
2094
|
});
|
|
2057
2095
|
/** 面板聚焦或鼠标悬浮在图片区时接管全局粘贴图片 */
|
|
2058
2096
|
d(this, "handleDocumentPaste", (t) => {
|
|
2059
|
-
const n =
|
|
2097
|
+
const n = Yr(t);
|
|
2060
2098
|
if (!n.length || !this.isOpen || !this.host)
|
|
2061
2099
|
return;
|
|
2062
2100
|
const r = document.activeElement, o = this.root instanceof ShadowRoot ? this.root.activeElement : null;
|
|
@@ -2109,7 +2147,7 @@ class zr {
|
|
|
2109
2147
|
}
|
|
2110
2148
|
render(t) {
|
|
2111
2149
|
this.root && (this.root.innerHTML = `
|
|
2112
|
-
<style>${
|
|
2150
|
+
<style>${Wr}</style>
|
|
2113
2151
|
${this.options.mode === "floating" ? `<button class="sf-float" type="button" data-role="open">${this.t("entry", "智能录入")}</button>` : ""}
|
|
2114
2152
|
<section class="sf-panel ${t ? "is-open" : ""} ${this.options.mode === "inline" ? "is-inline" : "is-floating"}" aria-label="智能录入面板">
|
|
2115
2153
|
<header class="sf-header" data-role="close" >
|
|
@@ -2126,7 +2164,7 @@ class zr {
|
|
|
2126
2164
|
</label>
|
|
2127
2165
|
<div class="sf-entry-grid">
|
|
2128
2166
|
<div class="sf-textarea-wrap">
|
|
2129
|
-
<textarea class="sf-textarea" data-role="text" placeholder="${this.t("placeholder", "粘贴文本,如:姓名:张三 手机号:13800000000")}">${
|
|
2167
|
+
<textarea class="sf-textarea" data-role="text" placeholder="${this.t("placeholder", "粘贴文本,如:姓名:张三 手机号:13800000000")}">${Gr(this.inputText)}</textarea>
|
|
2130
2168
|
<div class="sf-textarea-actions">
|
|
2131
2169
|
<button class="sf-btn sf-btn-secondary" type="button" data-role="clear">${this.t("clear", "清空")}</button>
|
|
2132
2170
|
<button class="sf-btn sf-btn-primary" type="button" data-role="recognize">${this.t("recognize", "智能识别")}</button>
|
|
@@ -2221,11 +2259,11 @@ class zr {
|
|
|
2221
2259
|
this.resetSelectedFiles(), this.setError(this.t("maxFilesError", `最多上传 ${_e} 张图片。`));
|
|
2222
2260
|
return;
|
|
2223
2261
|
}
|
|
2224
|
-
if (n.find((i) => i.size >
|
|
2262
|
+
if (n.find((i) => i.size > Br)) {
|
|
2225
2263
|
this.resetSelectedFiles(), this.setError(this.t("maxSingleFileSizeError", "单张图片不能超过 10MB。"));
|
|
2226
2264
|
return;
|
|
2227
2265
|
}
|
|
2228
|
-
if (n.reduce((i, s) => i + s.size, 0) >
|
|
2266
|
+
if (n.reduce((i, s) => i + s.size, 0) > Ur) {
|
|
2229
2267
|
this.resetSelectedFiles(), this.setError(this.t("maxTotalFileSizeError", "上传图片总大小不能超过 50MB。"));
|
|
2230
2268
|
return;
|
|
2231
2269
|
}
|
|
@@ -2264,7 +2302,7 @@ class zr {
|
|
|
2264
2302
|
return ((r = this.options.messages) == null ? void 0 : r[t]) || n;
|
|
2265
2303
|
}
|
|
2266
2304
|
}
|
|
2267
|
-
function
|
|
2305
|
+
function Gr(e) {
|
|
2268
2306
|
return e.replace(/[&<>"']/g, (t) => ({
|
|
2269
2307
|
"&": "&",
|
|
2270
2308
|
"<": "<",
|
|
@@ -2276,11 +2314,11 @@ function Br(e) {
|
|
|
2276
2314
|
function ae(e, t, n) {
|
|
2277
2315
|
return Math.min(Math.max(e, t), n);
|
|
2278
2316
|
}
|
|
2279
|
-
function
|
|
2317
|
+
function Yr(e) {
|
|
2280
2318
|
var n;
|
|
2281
2319
|
return Array.from(((n = e.clipboardData) == null ? void 0 : n.items) || []).filter((r) => r.kind === "file" && r.type.startsWith("image/")).map((r) => r.getAsFile()).filter((r) => !!r);
|
|
2282
2320
|
}
|
|
2283
|
-
const
|
|
2321
|
+
const Wr = `
|
|
2284
2322
|
:host, .sf-panel { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
2285
2323
|
:host(.sf-sdk-host-floating), .sf-sdk-host-floating { position: fixed; top: 30px; right: 30px; z-index: 2147483647; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; width: min(450px, calc(100vw - 32px)); pointer-events: none; }
|
|
2286
2324
|
.sf-float { font-size: 15px; align-self: flex-end; border: 0; border-radius: 999px; padding: 10px 30px; color: #fff; background: linear-gradient(to right, #FF7E49, #FFA34E); box-shadow: 0 10px 24px rgba(37,99,235,.3); cursor: move; user-select: none; touch-action: none; pointer-events: auto; }
|
|
@@ -2350,23 +2388,23 @@ const jr = `
|
|
|
2350
2388
|
width: min(450px, calc(100vw - 32px))
|
|
2351
2389
|
}
|
|
2352
2390
|
}
|
|
2353
|
-
`,
|
|
2391
|
+
`, Xr = 0.75, Zr = 1800, H = /* @__PURE__ */ new Map();
|
|
2354
2392
|
let $ = 0;
|
|
2355
|
-
const Pe = "smart-fill:routechange",
|
|
2356
|
-
let
|
|
2357
|
-
const
|
|
2358
|
-
let
|
|
2359
|
-
function
|
|
2360
|
-
H.clear(),
|
|
2361
|
-
}
|
|
2362
|
-
class
|
|
2393
|
+
const Pe = "smart-fill:routechange", Nt = "smart-fill:session-scan:";
|
|
2394
|
+
let et = !1;
|
|
2395
|
+
const tt = /* @__PURE__ */ new WeakMap();
|
|
2396
|
+
let Jr = 0;
|
|
2397
|
+
function Vt() {
|
|
2398
|
+
H.clear(), Gt(), $ += 1;
|
|
2399
|
+
}
|
|
2400
|
+
class Qr {
|
|
2363
2401
|
constructor(t, n) {
|
|
2364
2402
|
/** 实例级事件总线,对应 instance.on(...) */
|
|
2365
|
-
d(this, "events", new
|
|
2403
|
+
d(this, "events", new Ft());
|
|
2366
2404
|
/** 页面字段扫描器,root 来自 SmartFill.create({ root }) */
|
|
2367
2405
|
d(this, "scanner");
|
|
2368
2406
|
/** 浏览器端本地规则引擎,用于文本正则/键值对提取 */
|
|
2369
|
-
d(this, "ruleEngine", new
|
|
2407
|
+
d(this, "ruleEngine", new Sr());
|
|
2370
2408
|
/** Shadow DOM 面板,mount / mountFloatingButton 后可用(指向最后挂载的面板,用于状态展示) */
|
|
2371
2409
|
d(this, "panel", null);
|
|
2372
2410
|
/** 已挂载的全部面板(inline / floating 可同时存在),用于本地优先开关广播与销毁 */
|
|
@@ -2376,7 +2414,7 @@ class Xr {
|
|
|
2376
2414
|
/** 业务方 registerFields 注册的字段;非空时 rescan 仅扫描这些字段 */
|
|
2377
2415
|
d(this, "registeredFields", []);
|
|
2378
2416
|
/** 组件库回填适配器链,如 AntD / Element 自定义控件 */
|
|
2379
|
-
d(this, "adapters", [
|
|
2417
|
+
d(this, "adapters", [Mt]);
|
|
2380
2418
|
/** 最近一次 rescan 结果;scanToken 用于识别/回填防过期校验 */
|
|
2381
2419
|
d(this, "scanResult", null);
|
|
2382
2420
|
/** recognize 完成后生成的自动回填候选,供面板展示与 applyAutoItems 使用 */
|
|
@@ -2395,7 +2433,7 @@ class Xr {
|
|
|
2395
2433
|
d(this, "floatingLifecycleCleanup", null);
|
|
2396
2434
|
/** mount 后预扫描定时器 */
|
|
2397
2435
|
d(this, "preScanTimer", null);
|
|
2398
|
-
this.config = t, this.context = n, this.scanner = new
|
|
2436
|
+
this.config = t, this.context = n, this.scanner = new Fr(t.root || document), this.localPriorityEnabled = ko(), this.context.manager.add(this);
|
|
2399
2437
|
}
|
|
2400
2438
|
/** 订阅实例事件,返回取消订阅函数 */
|
|
2401
2439
|
on(t, n) {
|
|
@@ -2431,13 +2469,13 @@ class Xr {
|
|
|
2431
2469
|
const n = typeof t == "string" ? document.querySelector(t) : t;
|
|
2432
2470
|
if (!n)
|
|
2433
2471
|
throw b("UNSUPPORTED_PAGE", "未找到智能录入挂载点。", "ui");
|
|
2434
|
-
const r =
|
|
2472
|
+
const r = it("inline", xo(t, n)), o = st(r, !0);
|
|
2435
2473
|
return this.createPanel("inline", r, o).mount(n), this.schedulePreScan(), this;
|
|
2436
2474
|
}
|
|
2437
2475
|
/** 挂载右下角悬浮按钮 + 弹框(floating 模式),优先挂到当前子路由页面顶层容器 */
|
|
2438
2476
|
mountFloatingButton() {
|
|
2439
2477
|
this.assertAlive();
|
|
2440
|
-
const t =
|
|
2478
|
+
const t = fo(this.config), n = it("floating"), r = st(n, !1);
|
|
2441
2479
|
return this.createPanel("floating", n, r).mount(t), this.bindFloatingLifecycle(t), this.schedulePreScan(), this;
|
|
2442
2480
|
}
|
|
2443
2481
|
/**
|
|
@@ -2446,7 +2484,7 @@ class Xr {
|
|
|
2446
2484
|
*/
|
|
2447
2485
|
createPanel(t, n, r) {
|
|
2448
2486
|
let o;
|
|
2449
|
-
return o = new
|
|
2487
|
+
return o = new jr({
|
|
2450
2488
|
mode: t,
|
|
2451
2489
|
initialOpen: r,
|
|
2452
2490
|
messages: this.config.messages,
|
|
@@ -2459,17 +2497,17 @@ class Xr {
|
|
|
2459
2497
|
}
|
|
2460
2498
|
/** 同步本地优先开关:更新内存态、写入 localStorage,并广播到其他已挂载面板 */
|
|
2461
2499
|
handleLocalPriorityChange(t, n) {
|
|
2462
|
-
this.localPriorityEnabled = t,
|
|
2500
|
+
this.localPriorityEnabled = t, _o(t);
|
|
2463
2501
|
for (const r of this.panels)
|
|
2464
2502
|
r !== n && r.setLocalPriorityEnabled(t);
|
|
2465
2503
|
}
|
|
2466
2504
|
/** 打开面板并触发 rescan,同时激活当前实例(关闭其他实例面板) */
|
|
2467
2505
|
async open(t = this.panel) {
|
|
2468
|
-
this.assertAlive(), this.syncScanCacheVersion(), t && (this.context.manager.activate(this), this.panel = t, t.setOpen(!0),
|
|
2506
|
+
this.assertAlive(), this.syncScanCacheVersion(), t && (this.context.manager.activate(this), this.panel = t, t.setOpen(!0), at(this.panelStorageKeys.get(t), !0), this.scanResult || await this.rescan());
|
|
2469
2507
|
}
|
|
2470
2508
|
/** 关闭面板(不销毁实例) */
|
|
2471
2509
|
close(t = this.panel) {
|
|
2472
|
-
t && (this.panel = t, t.setOpen(!1),
|
|
2510
|
+
t && (this.panel = t, t.setOpen(!1), at(this.panelStorageKeys.get(t), !1));
|
|
2473
2511
|
}
|
|
2474
2512
|
/**
|
|
2475
2513
|
* 扫描页面可回填字段。
|
|
@@ -2509,7 +2547,7 @@ class Xr {
|
|
|
2509
2547
|
this.destroyed || !this.panels.length || (this.preScanTimer != null && window.clearTimeout(this.preScanTimer), this.preScanTimer = window.setTimeout(() => {
|
|
2510
2548
|
this.preScanTimer = null, !(this.destroyed || this.scanResult) && this.preScan().catch(() => {
|
|
2511
2549
|
});
|
|
2512
|
-
},
|
|
2550
|
+
}, Zr));
|
|
2513
2551
|
}
|
|
2514
2552
|
cancelPreScan() {
|
|
2515
2553
|
this.preScanTimer != null && (window.clearTimeout(this.preScanTimer), this.preScanTimer = null);
|
|
@@ -2530,7 +2568,7 @@ class Xr {
|
|
|
2530
2568
|
const n = await this.rescan(), r = ye("trace"), o = performance.now();
|
|
2531
2569
|
this.events.emit("recognizing", { scanToken: n.scanToken, traceId: r }), (a = this.panel) == null || a.setBusy(!0, "识别中...");
|
|
2532
2570
|
try {
|
|
2533
|
-
const h = n.fields.filter((g) =>
|
|
2571
|
+
const h = n.fields.filter((g) => oo(g.localRuleMode, this.localPriorityEnabled)), T = n.fields.filter((g) => g.localRuleMode !== "only"), { text: P, usedOcr: J } = await this.context.client.resolveInputText({
|
|
2534
2572
|
text: t.text,
|
|
2535
2573
|
images: t.images,
|
|
2536
2574
|
onStatusChange: (g) => {
|
|
@@ -2548,7 +2586,7 @@ class Xr {
|
|
|
2548
2586
|
}), Q = P ? this.ruleEngine.recognize(P, h, n.scanToken) : [];
|
|
2549
2587
|
let v;
|
|
2550
2588
|
if (!T.length)
|
|
2551
|
-
v =
|
|
2589
|
+
v = nt(n.scanToken, r, Q, o, void 0, J);
|
|
2552
2590
|
else
|
|
2553
2591
|
try {
|
|
2554
2592
|
const g = await this.context.client.recognize({
|
|
@@ -2564,7 +2602,7 @@ class Xr {
|
|
|
2564
2602
|
}
|
|
2565
2603
|
});
|
|
2566
2604
|
g.trace.durationMs = g.trace.durationMs || Math.round(performance.now() - o);
|
|
2567
|
-
const ee =
|
|
2605
|
+
const ee = ro(
|
|
2568
2606
|
Q,
|
|
2569
2607
|
g.suggestions.filter((L) => T.some((te) => te.fieldId === L.fieldId))
|
|
2570
2608
|
);
|
|
@@ -2572,7 +2610,7 @@ class Xr {
|
|
|
2572
2610
|
} catch (g) {
|
|
2573
2611
|
if (!Q.length)
|
|
2574
2612
|
throw g;
|
|
2575
|
-
v =
|
|
2613
|
+
v = nt(
|
|
2576
2614
|
n.scanToken,
|
|
2577
2615
|
r,
|
|
2578
2616
|
Q,
|
|
@@ -2581,14 +2619,14 @@ class Xr {
|
|
|
2581
2619
|
J
|
|
2582
2620
|
);
|
|
2583
2621
|
}
|
|
2584
|
-
if (this.autoApplyState =
|
|
2622
|
+
if (this.autoApplyState = to(
|
|
2585
2623
|
v.scanToken,
|
|
2586
2624
|
v.trace.traceId,
|
|
2587
2625
|
v.suggestions,
|
|
2588
2626
|
n,
|
|
2589
2627
|
this.registeredFields
|
|
2590
2628
|
), this.events.emit("recognized", v), (c = this.panel) == null || c.setAutoApplyState(this.autoApplyState), this.config.apiEnable) {
|
|
2591
|
-
const g =
|
|
2629
|
+
const g = eo(v, this.autoApplyState, n);
|
|
2592
2630
|
this.config.apiCallback && await Promise.resolve(this.config.apiCallback(g)), (l = this.panel) == null || l.setStatus(`识别完成,已返回 ${g.fields.length} 个字段。`);
|
|
2593
2631
|
} else
|
|
2594
2632
|
await this.applyAutoItems(this.autoApplyState);
|
|
@@ -2609,7 +2647,7 @@ class Xr {
|
|
|
2609
2647
|
if (this.assertAlive(), this.syncScanCacheVersion(), !this.scanResult)
|
|
2610
2648
|
throw b("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
|
|
2611
2649
|
this.events.emit("applying", { scanToken: t.scanToken, count: t.values.length });
|
|
2612
|
-
const r = await new
|
|
2650
|
+
const r = await new Ze(this.scanResult.fields, this.registeredFields, this.adapters).apply(t);
|
|
2613
2651
|
return this.events.emit("applied", r), (o = this.panel) == null || o.setApplyResult(r), r;
|
|
2614
2652
|
}
|
|
2615
2653
|
/**
|
|
@@ -2620,9 +2658,9 @@ class Xr {
|
|
|
2620
2658
|
var a, c;
|
|
2621
2659
|
if (!this.scanResult)
|
|
2622
2660
|
throw b("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
|
|
2623
|
-
const n =
|
|
2661
|
+
const n = no(t), r = t.items.filter((l) => Kt(l)).map((l) => ({ fieldId: l.fieldId, value: l.value, source: l.source }));
|
|
2624
2662
|
this.events.emit("applying", { scanToken: t.scanToken, count: r.length }), (a = this.panel) == null || a.setStatus("识别完成,正在自动回填...");
|
|
2625
|
-
const i = await new
|
|
2663
|
+
const i = await new Ze(this.scanResult.fields, this.registeredFields, this.adapters).apply({ scanToken: t.scanToken, values: r }), s = {
|
|
2626
2664
|
...i,
|
|
2627
2665
|
skipped: [...n, ...i.skipped],
|
|
2628
2666
|
warnings: [
|
|
@@ -2654,7 +2692,7 @@ class Xr {
|
|
|
2654
2692
|
if (!n) return null;
|
|
2655
2693
|
const r = H.get(n);
|
|
2656
2694
|
if (r && (!t || r.dynamicOptionsReady)) {
|
|
2657
|
-
const i =
|
|
2695
|
+
const i = so(r.scanResult);
|
|
2658
2696
|
if (!i)
|
|
2659
2697
|
H.delete(n);
|
|
2660
2698
|
else
|
|
@@ -2673,13 +2711,13 @@ class Xr {
|
|
|
2673
2711
|
}), this.persistPageScanResult(t, (o == null ? void 0 : o.dynamicOptionsReady) || n));
|
|
2674
2712
|
}
|
|
2675
2713
|
getPageScanCacheKey() {
|
|
2676
|
-
return this.registeredFields.length ? null :
|
|
2714
|
+
return this.registeredFields.length ? null : lo(this.config);
|
|
2677
2715
|
}
|
|
2678
2716
|
getSessionPageScanCacheKey() {
|
|
2679
|
-
return this.registeredFields.length || !this.config.formCode ? null :
|
|
2717
|
+
return this.registeredFields.length || !this.config.formCode ? null : uo(this.config);
|
|
2680
2718
|
}
|
|
2681
2719
|
clearScanStateOnTokenExpired(t) {
|
|
2682
|
-
We(t, "recognize").code === "TOKEN_EXPIRED" && (
|
|
2720
|
+
We(t, "recognize").code === "TOKEN_EXPIRED" && (Vt(), this.scanCacheVersion = $, this.scanResult = null, this.autoApplyState = null);
|
|
2683
2721
|
}
|
|
2684
2722
|
syncScanCacheVersion() {
|
|
2685
2723
|
this.scanCacheVersion !== $ && (this.scanCacheVersion = $, this.scanResult = null, this.autoApplyState = null);
|
|
@@ -2687,26 +2725,26 @@ class Xr {
|
|
|
2687
2725
|
getPersistedPageScanResult(t) {
|
|
2688
2726
|
const n = this.getSessionPageScanCacheKey();
|
|
2689
2727
|
if (!n) return null;
|
|
2690
|
-
const r =
|
|
2728
|
+
const r = So(n);
|
|
2691
2729
|
if (!r || t && !r.dynamicOptionsReady) return null;
|
|
2692
|
-
const o = this.scanner.scan({ maxFields: this.config.maxFields }), i =
|
|
2730
|
+
const o = this.scanner.scan({ maxFields: this.config.maxFields }), i = ao(r, o);
|
|
2693
2731
|
return i ? {
|
|
2694
2732
|
scanResult: i,
|
|
2695
2733
|
dynamicOptionsReady: r.dynamicOptionsReady
|
|
2696
|
-
} : (
|
|
2734
|
+
} : (Gt(n), null);
|
|
2697
2735
|
}
|
|
2698
2736
|
persistPageScanResult(t, n) {
|
|
2699
2737
|
const r = this.getSessionPageScanCacheKey();
|
|
2700
|
-
!r || !t.fields.length ||
|
|
2738
|
+
!r || !t.fields.length || Eo(r, {
|
|
2701
2739
|
version: 1,
|
|
2702
2740
|
dynamicOptionsReady: n,
|
|
2703
2741
|
fields: t.fields.map(({ element: o, scanToken: i, ...s }) => s)
|
|
2704
2742
|
});
|
|
2705
2743
|
}
|
|
2706
2744
|
bindFloatingLifecycle(t) {
|
|
2707
|
-
this.clearFloatingLifecycle(), this.floatingRouteSnapshot =
|
|
2745
|
+
this.clearFloatingLifecycle(), this.floatingRouteSnapshot = ot(), po();
|
|
2708
2746
|
const n = () => {
|
|
2709
|
-
this.destroyed ||
|
|
2747
|
+
this.destroyed || ot() !== this.floatingRouteSnapshot && this.destroy();
|
|
2710
2748
|
};
|
|
2711
2749
|
window.addEventListener(Pe, n);
|
|
2712
2750
|
const r = new MutationObserver(() => {
|
|
@@ -2721,7 +2759,7 @@ class Xr {
|
|
|
2721
2759
|
(t = this.floatingLifecycleCleanup) == null || t.call(this);
|
|
2722
2760
|
}
|
|
2723
2761
|
}
|
|
2724
|
-
function
|
|
2762
|
+
function eo(e, t, n) {
|
|
2725
2763
|
return {
|
|
2726
2764
|
scanToken: e.scanToken,
|
|
2727
2765
|
trace: e.trace,
|
|
@@ -2742,12 +2780,12 @@ function Zr(e, t, n) {
|
|
|
2742
2780
|
})
|
|
2743
2781
|
};
|
|
2744
2782
|
}
|
|
2745
|
-
function
|
|
2783
|
+
function to(e, t, n, r, o) {
|
|
2746
2784
|
return {
|
|
2747
2785
|
scanToken: e,
|
|
2748
2786
|
traceId: t,
|
|
2749
2787
|
items: n.map((i) => {
|
|
2750
|
-
const s = r.fields.find((l) => l.fieldId === i.fieldId), a = o.find((l) => l.fieldId === i.fieldId), c = a != null && a.getValue ? a.getValue() :
|
|
2788
|
+
const s = r.fields.find((l) => l.fieldId === i.fieldId), a = o.find((l) => l.fieldId === i.fieldId), c = a != null && a.getValue ? a.getValue() : io(s == null ? void 0 : s.element);
|
|
2751
2789
|
return {
|
|
2752
2790
|
applyItemId: `${i.fieldId}_${Math.random().toString(36).slice(2, 8)}`,
|
|
2753
2791
|
fieldId: i.fieldId,
|
|
@@ -2765,12 +2803,12 @@ function Jr(e, t, n, r, o) {
|
|
|
2765
2803
|
})
|
|
2766
2804
|
};
|
|
2767
2805
|
}
|
|
2768
|
-
function
|
|
2806
|
+
function Kt(e) {
|
|
2769
2807
|
var t;
|
|
2770
|
-
return e.confidence >=
|
|
2808
|
+
return e.confidence >= Xr && !((t = e.warnings) != null && t.length);
|
|
2771
2809
|
}
|
|
2772
|
-
function
|
|
2773
|
-
return e.items.filter((t) => !
|
|
2810
|
+
function no(e) {
|
|
2811
|
+
return e.items.filter((t) => !Kt(t)).map((t) => {
|
|
2774
2812
|
var n, r;
|
|
2775
2813
|
return {
|
|
2776
2814
|
fieldId: t.fieldId,
|
|
@@ -2781,7 +2819,7 @@ function Qr(e) {
|
|
|
2781
2819
|
};
|
|
2782
2820
|
});
|
|
2783
2821
|
}
|
|
2784
|
-
function
|
|
2822
|
+
function ro(e, t) {
|
|
2785
2823
|
const n = /* @__PURE__ */ new Map();
|
|
2786
2824
|
for (const r of t)
|
|
2787
2825
|
n.set(r.fieldId, r);
|
|
@@ -2789,10 +2827,10 @@ function eo(e, t) {
|
|
|
2789
2827
|
n.has(r.fieldId) || n.set(r.fieldId, r);
|
|
2790
2828
|
return [...n.values()];
|
|
2791
2829
|
}
|
|
2792
|
-
function
|
|
2830
|
+
function oo(e, t) {
|
|
2793
2831
|
return e === "only" ? !0 : e === "off" ? !1 : t;
|
|
2794
2832
|
}
|
|
2795
|
-
function
|
|
2833
|
+
function nt(e, t, n, r, o, i = !1) {
|
|
2796
2834
|
return {
|
|
2797
2835
|
scanToken: e,
|
|
2798
2836
|
suggestions: n,
|
|
@@ -2805,15 +2843,15 @@ function tt(e, t, n, r, o, i = !1) {
|
|
|
2805
2843
|
}
|
|
2806
2844
|
};
|
|
2807
2845
|
}
|
|
2808
|
-
function
|
|
2846
|
+
function io(e) {
|
|
2809
2847
|
if (e)
|
|
2810
2848
|
return e instanceof HTMLInputElement && e.type === "checkbox" ? e.checked : e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value : e.textContent;
|
|
2811
2849
|
}
|
|
2812
|
-
function
|
|
2850
|
+
function so(e) {
|
|
2813
2851
|
const t = e.fields.map((n) => {
|
|
2814
2852
|
if (n.source === "registered")
|
|
2815
2853
|
return n;
|
|
2816
|
-
const r =
|
|
2854
|
+
const r = co(n);
|
|
2817
2855
|
return r ? { ...n, element: r } : null;
|
|
2818
2856
|
});
|
|
2819
2857
|
return t.some((n) => !n) ? null : {
|
|
@@ -2821,7 +2859,7 @@ function ro(e) {
|
|
|
2821
2859
|
fields: t
|
|
2822
2860
|
};
|
|
2823
2861
|
}
|
|
2824
|
-
function
|
|
2862
|
+
function ao(e, t) {
|
|
2825
2863
|
var s, a;
|
|
2826
2864
|
const n = new Map(t.fields.map((c) => [c.fieldId, c])), r = [], o = /* @__PURE__ */ new Set();
|
|
2827
2865
|
for (const c of e.fields) {
|
|
@@ -2853,77 +2891,77 @@ function oo(e, t) {
|
|
|
2853
2891
|
fields: [...r, ...i]
|
|
2854
2892
|
};
|
|
2855
2893
|
}
|
|
2856
|
-
function
|
|
2894
|
+
function co(e) {
|
|
2857
2895
|
var t;
|
|
2858
2896
|
if ((t = e.element) != null && t.isConnected) return e.element;
|
|
2859
2897
|
try {
|
|
2860
|
-
return document.querySelector(`[data-smart-fill-id="${
|
|
2898
|
+
return document.querySelector(`[data-smart-fill-id="${Co(e.fieldId)}"]`);
|
|
2861
2899
|
} catch {
|
|
2862
2900
|
return null;
|
|
2863
2901
|
}
|
|
2864
2902
|
}
|
|
2865
|
-
function
|
|
2866
|
-
const t = typeof location < "u" ? `${location.origin}${location.pathname}${location.search}` : "unknown-page", n =
|
|
2903
|
+
function lo(e) {
|
|
2904
|
+
const t = typeof location < "u" ? `${location.origin}${location.pathname}${location.search}` : "unknown-page", n = zt(e.root || document);
|
|
2867
2905
|
return `smart-fill:${t}:${e.formCode || "default-form"}:${n}:${e.maxFields ?? 200}:scan`;
|
|
2868
2906
|
}
|
|
2869
|
-
function
|
|
2870
|
-
const t =
|
|
2871
|
-
return `${
|
|
2907
|
+
function uo(e) {
|
|
2908
|
+
const t = zt(e.root || document);
|
|
2909
|
+
return `${Nt}${e.formCode || "default-form"}:${t}:${e.maxFields ?? 200}`;
|
|
2872
2910
|
}
|
|
2873
|
-
function
|
|
2911
|
+
function zt(e) {
|
|
2874
2912
|
if (e === document) return "document";
|
|
2875
|
-
const t =
|
|
2913
|
+
const t = tt.get(e);
|
|
2876
2914
|
if (t) return t;
|
|
2877
|
-
const n = e instanceof HTMLElement && e.id ? `el:${e.id}` : `root:${++
|
|
2878
|
-
return
|
|
2915
|
+
const n = e instanceof HTMLElement && e.id ? `el:${e.id}` : `root:${++Jr}`;
|
|
2916
|
+
return tt.set(e, n), n;
|
|
2879
2917
|
}
|
|
2880
|
-
function
|
|
2881
|
-
if (
|
|
2882
|
-
|
|
2918
|
+
function po() {
|
|
2919
|
+
if (et || typeof window > "u") return;
|
|
2920
|
+
et = !0;
|
|
2883
2921
|
const e = () => {
|
|
2884
2922
|
window.dispatchEvent(new Event(Pe));
|
|
2885
2923
|
};
|
|
2886
|
-
window.addEventListener("popstate", e), window.addEventListener("hashchange", e),
|
|
2924
|
+
window.addEventListener("popstate", e), window.addEventListener("hashchange", e), rt("pushState", e), rt("replaceState", e);
|
|
2887
2925
|
}
|
|
2888
|
-
function
|
|
2926
|
+
function rt(e, t) {
|
|
2889
2927
|
const n = window.history[e];
|
|
2890
2928
|
window.history[e] = function(...o) {
|
|
2891
2929
|
const i = n.apply(this, o);
|
|
2892
2930
|
return t(), i;
|
|
2893
2931
|
};
|
|
2894
2932
|
}
|
|
2895
|
-
function
|
|
2933
|
+
function ot() {
|
|
2896
2934
|
return typeof location > "u" ? "unknown-route" : `${location.pathname}${location.search}${location.hash}`;
|
|
2897
2935
|
}
|
|
2898
|
-
function
|
|
2899
|
-
const t =
|
|
2936
|
+
function fo(e) {
|
|
2937
|
+
const t = ho(e.floatingContainer);
|
|
2900
2938
|
if (t)
|
|
2901
2939
|
return t;
|
|
2902
|
-
const n =
|
|
2903
|
-
return n ||
|
|
2940
|
+
const n = go(e.routeContainerSelector);
|
|
2941
|
+
return n || yo() || document.body;
|
|
2904
2942
|
}
|
|
2905
|
-
function
|
|
2943
|
+
function ho(e) {
|
|
2906
2944
|
return e ? e instanceof HTMLElement ? e : He(e) : null;
|
|
2907
2945
|
}
|
|
2908
|
-
function
|
|
2946
|
+
function go(e) {
|
|
2909
2947
|
if (!e) return null;
|
|
2910
|
-
const t =
|
|
2948
|
+
const t = Bt(), n = t ? He(e, t) : null;
|
|
2911
2949
|
return n || He(e);
|
|
2912
2950
|
}
|
|
2913
|
-
function
|
|
2914
|
-
const e =
|
|
2951
|
+
function yo() {
|
|
2952
|
+
const e = Bt();
|
|
2915
2953
|
if (!e)
|
|
2916
2954
|
return null;
|
|
2917
|
-
const t =
|
|
2955
|
+
const t = bo(e);
|
|
2918
2956
|
if (t)
|
|
2919
2957
|
return t;
|
|
2920
|
-
const n =
|
|
2958
|
+
const n = mo(e);
|
|
2921
2959
|
if (n)
|
|
2922
2960
|
return n;
|
|
2923
|
-
const r =
|
|
2961
|
+
const r = wo(e);
|
|
2924
2962
|
return r !== e ? r : null;
|
|
2925
2963
|
}
|
|
2926
|
-
function
|
|
2964
|
+
function Bt() {
|
|
2927
2965
|
const e = [
|
|
2928
2966
|
"#app",
|
|
2929
2967
|
"#root",
|
|
@@ -2942,11 +2980,11 @@ function zt() {
|
|
|
2942
2980
|
}
|
|
2943
2981
|
return null;
|
|
2944
2982
|
}
|
|
2945
|
-
function
|
|
2946
|
-
const t = m(e), n =
|
|
2983
|
+
function bo(e) {
|
|
2984
|
+
const t = m(e), n = Ut(e).filter((o) => !Ke(o)).filter((o) => m(o) >= Math.max(t * 0.2, 48e3)), r = n.filter((o) => vo(o));
|
|
2947
2985
|
return r.length ? r.sort((o, i) => m(i) - m(o))[0] : n.length === 1 ? n[0] : null;
|
|
2948
2986
|
}
|
|
2949
|
-
function
|
|
2987
|
+
function mo(e) {
|
|
2950
2988
|
const t = [
|
|
2951
2989
|
"[data-route-root]",
|
|
2952
2990
|
"[data-router-view]",
|
|
@@ -2962,13 +3000,13 @@ function go(e) {
|
|
|
2962
3000
|
".app-content",
|
|
2963
3001
|
"main",
|
|
2964
3002
|
'[role="main"]'
|
|
2965
|
-
], n =
|
|
3003
|
+
], n = jt(e), r = m(e);
|
|
2966
3004
|
return t.flatMap((i) => Array.from(e.querySelectorAll(i))).filter((i) => we(i) && !Ke(i)).filter((i) => Ce(i, n) <= 3).filter((i) => m(i) >= Math.max(r * 0.2, 48e3)).sort((i, s) => Ce(i, n) - Ce(s, n) || m(s) - m(i))[0] || null;
|
|
2967
3005
|
}
|
|
2968
|
-
function
|
|
3006
|
+
function wo(e) {
|
|
2969
3007
|
let t = e;
|
|
2970
3008
|
for (; ; ) {
|
|
2971
|
-
const n =
|
|
3009
|
+
const n = Ut(t).filter((o) => !Ke(o));
|
|
2972
3010
|
if (n.length !== 1)
|
|
2973
3011
|
return t;
|
|
2974
3012
|
const [r] = n;
|
|
@@ -2977,7 +3015,7 @@ function yo(e) {
|
|
|
2977
3015
|
t = r;
|
|
2978
3016
|
}
|
|
2979
3017
|
}
|
|
2980
|
-
function
|
|
3018
|
+
function Ut(e) {
|
|
2981
3019
|
return Array.from(e.children).filter((t) => t instanceof HTMLElement).filter((t) => we(t));
|
|
2982
3020
|
}
|
|
2983
3021
|
function He(e, t = document) {
|
|
@@ -2999,7 +3037,7 @@ function Ke(e) {
|
|
|
2999
3037
|
const t = window.getComputedStyle(e);
|
|
3000
3038
|
return t.position === "fixed" || t.position === "sticky" ? !0 : m(e) < 24e3;
|
|
3001
3039
|
}
|
|
3002
|
-
function
|
|
3040
|
+
function vo(e) {
|
|
3003
3041
|
if (e.tagName.toLowerCase() === "main" || e.getAttribute("role") === "main")
|
|
3004
3042
|
return !0;
|
|
3005
3043
|
const t = e.id || "", n = typeof e.className == "string" ? e.className : "", r = `${t} ${n}`.toLowerCase();
|
|
@@ -3009,16 +3047,16 @@ function m(e) {
|
|
|
3009
3047
|
const t = e.getBoundingClientRect();
|
|
3010
3048
|
return Math.max(0, t.width) * Math.max(0, t.height);
|
|
3011
3049
|
}
|
|
3012
|
-
function
|
|
3050
|
+
function jt(e) {
|
|
3013
3051
|
let t = 0, n = e;
|
|
3014
3052
|
for (; n && n !== document.body; )
|
|
3015
3053
|
t += 1, n = n.parentElement;
|
|
3016
3054
|
return t;
|
|
3017
3055
|
}
|
|
3018
3056
|
function Ce(e, t) {
|
|
3019
|
-
return Math.max(0,
|
|
3057
|
+
return Math.max(0, jt(e) - t);
|
|
3020
3058
|
}
|
|
3021
|
-
function
|
|
3059
|
+
function So(e) {
|
|
3022
3060
|
try {
|
|
3023
3061
|
const t = window.sessionStorage.getItem(e);
|
|
3024
3062
|
if (!t) return null;
|
|
@@ -3028,13 +3066,13 @@ function mo(e) {
|
|
|
3028
3066
|
return null;
|
|
3029
3067
|
}
|
|
3030
3068
|
}
|
|
3031
|
-
function
|
|
3069
|
+
function Eo(e, t) {
|
|
3032
3070
|
try {
|
|
3033
3071
|
window.sessionStorage.setItem(e, JSON.stringify(t));
|
|
3034
3072
|
} catch {
|
|
3035
3073
|
}
|
|
3036
3074
|
}
|
|
3037
|
-
function
|
|
3075
|
+
function Gt(e) {
|
|
3038
3076
|
try {
|
|
3039
3077
|
if (e) {
|
|
3040
3078
|
window.sessionStorage.removeItem(e);
|
|
@@ -3043,24 +3081,24 @@ function jt(e) {
|
|
|
3043
3081
|
const t = [];
|
|
3044
3082
|
for (let n = 0; n < window.sessionStorage.length; n += 1) {
|
|
3045
3083
|
const r = window.sessionStorage.key(n);
|
|
3046
|
-
r != null && r.startsWith(
|
|
3084
|
+
r != null && r.startsWith(Nt) && t.push(r);
|
|
3047
3085
|
}
|
|
3048
3086
|
for (const n of t)
|
|
3049
3087
|
window.sessionStorage.removeItem(n);
|
|
3050
3088
|
} catch {
|
|
3051
3089
|
}
|
|
3052
3090
|
}
|
|
3053
|
-
function
|
|
3091
|
+
function it(e, t = "default") {
|
|
3054
3092
|
const n = typeof location < "u" ? location.pathname : "unknown-page", r = t.replace(/[^\w-]/g, "_") || "default";
|
|
3055
3093
|
return `smart-fill:${e}:${n}:${r}:open`;
|
|
3056
3094
|
}
|
|
3057
|
-
function
|
|
3095
|
+
function xo(e, t) {
|
|
3058
3096
|
if (typeof e == "string") return e;
|
|
3059
3097
|
if (t.id) return `#${t.id}`;
|
|
3060
3098
|
const n = typeof t.className == "string" ? t.className.trim().split(/\s+/).filter(Boolean)[0] : "";
|
|
3061
3099
|
return n ? `.${n}` : t.tagName.toLowerCase();
|
|
3062
3100
|
}
|
|
3063
|
-
function
|
|
3101
|
+
function st(e, t) {
|
|
3064
3102
|
try {
|
|
3065
3103
|
const n = window.localStorage.getItem(e);
|
|
3066
3104
|
return n == null ? t : n === "1";
|
|
@@ -3068,44 +3106,44 @@ function it(e, t) {
|
|
|
3068
3106
|
return t;
|
|
3069
3107
|
}
|
|
3070
3108
|
}
|
|
3071
|
-
function
|
|
3109
|
+
function at(e, t) {
|
|
3072
3110
|
if (e)
|
|
3073
3111
|
try {
|
|
3074
3112
|
window.localStorage.setItem(e, t ? "1" : "0");
|
|
3075
3113
|
} catch {
|
|
3076
3114
|
}
|
|
3077
3115
|
}
|
|
3078
|
-
function
|
|
3116
|
+
function Yt() {
|
|
3079
3117
|
return `smart-fill:${typeof location < "u" ? location.pathname : "unknown-page"}:local-priority`;
|
|
3080
3118
|
}
|
|
3081
|
-
function
|
|
3119
|
+
function ko() {
|
|
3082
3120
|
try {
|
|
3083
|
-
return window.localStorage.getItem(
|
|
3121
|
+
return window.localStorage.getItem(Yt()) === "1";
|
|
3084
3122
|
} catch {
|
|
3085
3123
|
return !1;
|
|
3086
3124
|
}
|
|
3087
3125
|
}
|
|
3088
|
-
function
|
|
3126
|
+
function _o(e) {
|
|
3089
3127
|
try {
|
|
3090
|
-
window.localStorage.setItem(
|
|
3128
|
+
window.localStorage.setItem(Yt(), e ? "1" : "0");
|
|
3091
3129
|
} catch {
|
|
3092
3130
|
}
|
|
3093
3131
|
}
|
|
3094
|
-
function
|
|
3132
|
+
function Co(e) {
|
|
3095
3133
|
return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
3096
3134
|
}
|
|
3097
|
-
const f = { status: "idle" }, Ae = new
|
|
3098
|
-
class
|
|
3135
|
+
const f = { status: "idle" }, Ae = new Ft(), ct = new lr();
|
|
3136
|
+
class Ao {
|
|
3099
3137
|
/** 初始化 SDK:校验 apiKey、创建会话、获取 accessToken */
|
|
3100
3138
|
static async setup(t) {
|
|
3101
3139
|
if (typeof window > "u")
|
|
3102
|
-
return f.status = "ready",
|
|
3140
|
+
return f.status = "ready", To();
|
|
3103
3141
|
if (f.status === "ready" && f.apiKey === t.apiKey && f.session)
|
|
3104
3142
|
return f.session;
|
|
3105
3143
|
if (f.status === "loading" && f.apiKey === t.apiKey && f.promise)
|
|
3106
3144
|
return f.promise;
|
|
3107
|
-
f.apiKey && f.apiKey !== t.apiKey && (
|
|
3108
|
-
const n = new
|
|
3145
|
+
f.apiKey && f.apiKey !== t.apiKey && (Vt(), ct.destroyAll());
|
|
3146
|
+
const n = new rr(t);
|
|
3109
3147
|
return f.status = "loading", f.apiKey = t.apiKey, f.client = n, f.promise = n.createSession().then((r) => (console.log("SmartFill session created:", r), n.setAccessToken(r.apiKey), f.status = "ready", f.session = r, Ae.emit("ready", { apiKey: t.apiKey }), r)).catch((r) => {
|
|
3110
3148
|
throw f.status = "error", r;
|
|
3111
3149
|
}), f.promise;
|
|
@@ -3116,15 +3154,15 @@ class ko {
|
|
|
3116
3154
|
return N();
|
|
3117
3155
|
if (f.status !== "ready" || !f.client)
|
|
3118
3156
|
throw b("SDK_NOT_READY", "请先 await SmartFill.setup({ apiKey })。", "setup");
|
|
3119
|
-
return new
|
|
3157
|
+
return new Qr(t, {
|
|
3120
3158
|
client: f.client,
|
|
3121
|
-
manager:
|
|
3159
|
+
manager: ct
|
|
3122
3160
|
});
|
|
3123
3161
|
}
|
|
3124
3162
|
}
|
|
3125
3163
|
/** 订阅全局事件(目前仅 ready) */
|
|
3126
|
-
d(
|
|
3127
|
-
function
|
|
3164
|
+
d(Ao, "on", Ae.on.bind(Ae));
|
|
3165
|
+
function To() {
|
|
3128
3166
|
return {
|
|
3129
3167
|
apiKey: "server-mock",
|
|
3130
3168
|
accessToken: "server-mock",
|
|
@@ -3161,14 +3199,14 @@ function N(e) {
|
|
|
3161
3199
|
};
|
|
3162
3200
|
}
|
|
3163
3201
|
export {
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3202
|
+
nr as DEFAULT_BASE_URL,
|
|
3203
|
+
Ze as DomFiller,
|
|
3204
|
+
Fr as DomScanner,
|
|
3205
|
+
Mo as ElementAdapter,
|
|
3206
|
+
Ft as EventBus,
|
|
3207
|
+
Sr as LocalRuleEngine,
|
|
3208
|
+
Io as NativeAdapter,
|
|
3209
|
+
Ao as SmartFill,
|
|
3210
|
+
Qr as SmartFillInstance,
|
|
3211
|
+
Mt as UiFrameworkAdapter
|
|
3174
3212
|
};
|