@protontech/autofill 0.0.22991789 → 0.0.33690782
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/constants/features.d.ts +1 -0
- package/constants/features.js +1 -0
- package/constants/heuristics.d.ts +5 -4
- package/constants/heuristics.js +5 -10
- package/constants/selectors.d.ts +13 -7
- package/constants/selectors.js +29 -17
- package/debug.d.ts +24 -1
- package/debug.js +15 -13
- package/dictionary/generate.js +30 -21
- package/dictionary/generated/dictionary.d.ts +18 -4
- package/dictionary/generated/dictionary.js +31 -17
- package/dictionary/source/dictionary.d.ts +4 -3
- package/dictionary/source/dictionary.js +155 -89
- package/dictionary/source/patterns.js +2 -2
- package/features/feature.d.ts +17 -0
- package/features/feature.js +72 -0
- package/features/feature.spec.d.ts +1 -0
- package/features/feature.spec.js +55 -0
- package/features/v1/abstract.field.d.ts +20401 -0
- package/features/v1/abstract.field.js +95 -0
- package/features/v1/abstract.form.d.ts +1226 -0
- package/features/v1/abstract.form.js +336 -0
- package/features/v1/field.email.d.ts +62 -0
- package/features/v1/field.email.js +27 -0
- package/features/v1/field.otp.d.ts +142 -0
- package/features/v1/field.otp.js +105 -0
- package/features/v1/field.password.d.ts +162 -0
- package/features/v1/field.password.js +81 -0
- package/features/v1/field.username-hidden.d.ts +62 -0
- package/features/v1/field.username-hidden.js +25 -0
- package/features/v1/field.username.d.ts +72 -0
- package/features/v1/field.username.js +31 -0
- package/features/v1/index.d.ts +4427 -0
- package/features/v1/index.js +22 -0
- package/features/v1/index.spec.d.ts +1 -0
- package/features/v1/index.spec.js +30 -0
- package/index.d.ts +5 -2
- package/index.js +10 -3
- package/models/perceptron/index.d.ts +2 -0
- package/models/perceptron/index.js +27 -0
- package/models/perceptron/params/email-model.json +53 -0
- package/models/perceptron/params/login-model.json +465 -0
- package/models/perceptron/params/new-password-model.json +133 -0
- package/models/perceptron/params/otp-model.json +117 -0
- package/models/perceptron/params/password-change-model.json +465 -0
- package/models/perceptron/params/password-model.json +133 -0
- package/models/perceptron/params/recovery-model.json +465 -0
- package/models/perceptron/params/register-model.json +465 -0
- package/models/perceptron/params/username-hidden-model.json +53 -0
- package/models/perceptron/params/username-model.json +61 -0
- package/models/prod_20240829/index.d.ts +2 -0
- package/models/prod_20240829/index.js +27 -0
- package/models/prod_20240829/params/email-model.json +45 -0
- package/models/prod_20240829/params/login-model.json +421 -0
- package/models/prod_20240829/params/new-password-model.json +125 -0
- package/models/prod_20240829/params/otp-model.json +153 -0
- package/models/prod_20240829/params/password-change-model.json +421 -0
- package/models/prod_20240829/params/password-model.json +125 -0
- package/models/prod_20240829/params/recovery-model.json +421 -0
- package/models/prod_20240829/params/register-model.json +421 -0
- package/models/prod_20240829/params/username-hidden-model.json +41 -0
- package/models/prod_20240829/params/username-model.json +45 -0
- package/models/random_forest/index.d.ts +2 -0
- package/models/random_forest/index.js +27 -0
- package/models/random_forest/params/email-model.json +1456 -0
- package/models/random_forest/params/login-model.json +4194 -0
- package/models/random_forest/params/new-password-model.json +1448 -0
- package/models/random_forest/params/otp-model.json +2004 -0
- package/models/random_forest/params/password-change-model.json +1422 -0
- package/models/random_forest/params/password-model.json +1292 -0
- package/models/random_forest/params/recovery-model.json +2754 -0
- package/models/random_forest/params/register-model.json +3678 -0
- package/models/random_forest/params/username-hidden-model.json +1108 -0
- package/models/random_forest/params/username-model.json +1052 -0
- package/models/v1/index.d.ts +2 -0
- package/models/v1/index.js +35 -0
- package/package.json +14 -15
- package/rules/v1/index.d.ts +3 -0
- package/rules/v1/index.js +69 -0
- package/rulesets.d.ts +2 -2
- package/rulesets.js +11 -10
- package/types/index.d.ts +72 -17
- package/types/index.js +35 -2
- package/utils/attributes.js +1 -1
- package/utils/clustering.js +18 -5
- package/utils/credit-card.d.ts +32 -0
- package/utils/credit-card.js +259 -0
- package/utils/credit-card.samples.spec.d.ts +1 -0
- package/utils/credit-card.samples.spec.js +452 -0
- package/utils/credit-card.spec.d.ts +1 -0
- package/utils/credit-card.spec.js +296 -0
- package/utils/dom.d.ts +3 -2
- package/utils/dom.js +12 -7
- package/utils/exclusion.d.ts +1 -0
- package/utils/exclusion.js +22 -10
- package/utils/extract.d.ts +1 -0
- package/utils/extract.js +26 -7
- package/utils/fathom.d.ts +10 -23
- package/utils/fathom.js +7 -12
- package/utils/field.d.ts +12 -4
- package/utils/field.js +25 -14
- package/utils/flags.d.ts +9 -3
- package/utils/flags.js +27 -9
- package/utils/form.d.ts +16 -5
- package/utils/form.js +35 -14
- package/utils/identity.d.ts +12 -21
- package/utils/identity.js +66 -41
- package/utils/identity.samples.spec.d.ts +1 -0
- package/utils/identity.samples.spec.js +28 -0
- package/utils/iframe.d.ts +2 -0
- package/utils/iframe.js +22 -0
- package/utils/overrides.d.ts +19 -0
- package/utils/overrides.js +40 -0
- package/utils/prepass.js +6 -4
- package/utils/re.d.ts +19 -4
- package/utils/re.js +22 -7
- package/utils/re.spec.d.ts +1 -0
- package/utils/re.spec.js +62 -0
- package/utils/shadow-dom.d.ts +8 -0
- package/utils/shadow-dom.js +53 -0
- package/utils/shadow-dom.spec.d.ts +1 -0
- package/utils/shadow-dom.spec.js +215 -0
- package/utils/visible.d.ts +3 -2
- package/utils/visible.js +42 -22
- package/cli.d.ts +0 -2
- package/cli.js +0 -128
- package/features/abstract.field.d.ts +0 -123
- package/features/abstract.field.js +0 -63
- package/features/abstract.form.d.ts +0 -98
- package/features/abstract.form.js +0 -281
- package/features/field.email.d.ts +0 -18
- package/features/field.email.js +0 -43
- package/features/field.otp.d.ts +0 -36
- package/features/field.otp.js +0 -116
- package/features/field.password.d.ts +0 -35
- package/features/field.password.js +0 -104
- package/features/field.username-hidden.d.ts +0 -15
- package/features/field.username-hidden.js +0 -40
- package/features/field.username.d.ts +0 -16
- package/features/field.username.js +0 -41
- package/features/form.combined.d.ts +0 -1
- package/features/form.combined.js +0 -6
- package/trainees/field.email.d.ts +0 -2
- package/trainees/field.email.js +0 -16
- package/trainees/field.identity.d.ts +0 -2
- package/trainees/field.identity.js +0 -9
- package/trainees/field.otp.d.ts +0 -2
- package/trainees/field.otp.js +0 -16
- package/trainees/field.password.current.d.ts +0 -2
- package/trainees/field.password.current.js +0 -16
- package/trainees/field.password.new.d.ts +0 -2
- package/trainees/field.password.new.js +0 -16
- package/trainees/field.username-hidden.d.ts +0 -2
- package/trainees/field.username-hidden.js +0 -22
- package/trainees/field.username.d.ts +0 -2
- package/trainees/field.username.js +0 -16
- package/trainees/form.login.d.ts +0 -2
- package/trainees/form.login.js +0 -16
- package/trainees/form.noop.d.ts +0 -1
- package/trainees/form.noop.js +0 -7
- package/trainees/form.password-change.d.ts +0 -2
- package/trainees/form.password-change.js +0 -16
- package/trainees/form.recovery.d.ts +0 -2
- package/trainees/form.recovery.js +0 -16
- package/trainees/form.register.d.ts +0 -2
- package/trainees/form.register.js +0 -16
- package/trainees/index.d.ts +0 -9
- package/trainees/index.js +0 -72
- package/trainees/results/result.email.d.ts +0 -2
- package/trainees/results/result.email.js +0 -17
- package/trainees/results/result.login.d.ts +0 -2
- package/trainees/results/result.login.js +0 -110
- package/trainees/results/result.new-password.d.ts +0 -2
- package/trainees/results/result.new-password.js +0 -36
- package/trainees/results/result.otp.d.ts +0 -2
- package/trainees/results/result.otp.js +0 -43
- package/trainees/results/result.password-change.d.ts +0 -2
- package/trainees/results/result.password-change.js +0 -110
- package/trainees/results/result.password.d.ts +0 -2
- package/trainees/results/result.password.js +0 -36
- package/trainees/results/result.recovery.d.ts +0 -2
- package/trainees/results/result.recovery.js +0 -110
- package/trainees/results/result.register.d.ts +0 -2
- package/trainees/results/result.register.js +0 -110
- package/trainees/results/result.username-hidden.d.ts +0 -2
- package/trainees/results/result.username-hidden.js +0 -15
- package/trainees/results/result.username.d.ts +0 -2
- package/trainees/results/result.username.js +0 -16
- package/utils/memoize.d.ts +0 -5
- package/utils/memoize.js +0 -12
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { ccFields, CCFieldType } from "@protontech/autofill/types";
|
|
2
|
+
import { not, or } from "./combinators";
|
|
3
|
+
import { getLabelFor } from "./dom";
|
|
4
|
+
import { getAutocompletes } from "./extract";
|
|
5
|
+
import { getCachedSubType, isClassifiable, setCachedSubType } from "./flags";
|
|
6
|
+
import { matchCCExp, matchCCExpMonth, matchCCExpYear, matchCCFirstName, matchCCLastName, matchCCName, matchCCNumber, matchCCOutlier, matchCCSecurityCode, matchCCV } from "./re";
|
|
7
|
+
import { sanitizeString, sanitizeStringWithSpaces } from "./text";
|
|
8
|
+
import { isVisible } from "./visible";
|
|
9
|
+
export const CC_ATTRIBUTES = ["autocomplete", "name", "id", "class", "form", "aria-label", "aria-labelledby", "placeholder", "data-testid", "data-stripe", "data-recurly", "data-encrypted-name"];
|
|
10
|
+
export const CC_INPUT_TYPES = ["tel", "phone", "text", "number", "password"];
|
|
11
|
+
const CC_EXP_YEAR_FORMAT = ["YYYY", "AAAA", "YY", "AA"];
|
|
12
|
+
const CC_EXP_MONTH_FORMAT = ["MM", "LL"];
|
|
13
|
+
const CC_EXP_FULL_RE = /(mmyy|mmaa|yymm|aamm)/;
|
|
14
|
+
const CC_EXP_SEPARATOR = ["", "/", "-"];
|
|
15
|
+
const CC_EXP_DEFAULT_FORMAT = { separator: "/", fullYear: false, monthFirst: true };
|
|
16
|
+
const CC_EXP_FORMATS = [
|
|
17
|
+
{ fullYear: true, monthFirst: true },
|
|
18
|
+
{ fullYear: false, monthFirst: true },
|
|
19
|
+
{ fullYear: true, monthFirst: false },
|
|
20
|
+
{ fullYear: false, monthFirst: false },
|
|
21
|
+
];
|
|
22
|
+
const MAX_LENGTH_FORMAT_MAP = {
|
|
23
|
+
4: { separator: "", fullYear: false, monthFirst: true },
|
|
24
|
+
5: { separator: "/", fullYear: false, monthFirst: true },
|
|
25
|
+
6: { separator: "", fullYear: true, monthFirst: true },
|
|
26
|
+
7: { separator: "/", fullYear: true, monthFirst: true },
|
|
27
|
+
};
|
|
28
|
+
const YEAR_OPTION = (new Date().getFullYear() + 1).toString();
|
|
29
|
+
const generateExpirationString = ({ fullYear, separator, monthFirst }) => {
|
|
30
|
+
const month = "01";
|
|
31
|
+
const year = fullYear ? "2025" : "25";
|
|
32
|
+
return monthFirst ? `${month}${separator}${year}` : `${year}${separator}${month}`;
|
|
33
|
+
};
|
|
34
|
+
const getExpirationFormatFromPattern = (pattern) => {
|
|
35
|
+
try {
|
|
36
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
37
|
+
for (const format of CC_EXP_FORMATS) {
|
|
38
|
+
for (const separator of CC_EXP_SEPARATOR) {
|
|
39
|
+
const testString = generateExpirationString({ ...format, separator });
|
|
40
|
+
if (regex.test(testString)) {
|
|
41
|
+
return {
|
|
42
|
+
separator,
|
|
43
|
+
fullYear: format.fullYear,
|
|
44
|
+
monthFirst: format.monthFirst,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (_a) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const getCCFormatHaystack = (input) => {
|
|
55
|
+
var _a;
|
|
56
|
+
const { placeholder, className, id, name } = input;
|
|
57
|
+
const ariaLabel = input.getAttribute("aria-label");
|
|
58
|
+
const label = (_a = getLabelFor(input)) === null || _a === void 0 ? void 0 : _a.innerText;
|
|
59
|
+
return [className, id, name, ariaLabel, placeholder.replace(/\s/g, ""), label === null || label === void 0 ? void 0 : label.replace(/\s/g, "")].filter(Boolean).join(" ").toUpperCase();
|
|
60
|
+
};
|
|
61
|
+
const getExpirationFormatFromMaxLength = (maxLength) => MAX_LENGTH_FORMAT_MAP[maxLength];
|
|
62
|
+
const getExpirationFormatFromAttributes = (input) => {
|
|
63
|
+
const haystack = getCCFormatHaystack(input);
|
|
64
|
+
for (const separator of CC_EXP_SEPARATOR) {
|
|
65
|
+
for (const year of CC_EXP_YEAR_FORMAT) {
|
|
66
|
+
for (const monthFirst of [true, false]) {
|
|
67
|
+
if (haystack.includes(monthFirst ? `MM${separator}${year}` : `${year}${separator}MM`)) {
|
|
68
|
+
return {
|
|
69
|
+
separator,
|
|
70
|
+
fullYear: year.length === 4,
|
|
71
|
+
monthFirst,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const getExpirationFormat = (field, allowFallback = true) => {
|
|
79
|
+
if (field instanceof HTMLInputElement) {
|
|
80
|
+
const validMaxLength = field.maxLength >= 4;
|
|
81
|
+
const validPattern = field.pattern && (field.maxLength === -1 || validMaxLength);
|
|
82
|
+
return (getExpirationFormatFromAttributes(field) ||
|
|
83
|
+
(validPattern && getExpirationFormatFromPattern(field.pattern)) ||
|
|
84
|
+
(validMaxLength && getExpirationFormatFromMaxLength(field.maxLength)) ||
|
|
85
|
+
(allowFallback ? CC_EXP_DEFAULT_FORMAT : undefined));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
export const formatExpirationDate = (month, year, { fullYear, separator, monthFirst }) => {
|
|
89
|
+
const formattedYear = fullYear ? year.slice(0, 4) : year.slice(-2);
|
|
90
|
+
const formattedMonth = month.padStart(2, "0");
|
|
91
|
+
const components = monthFirst ? [formattedMonth, formattedYear] : [formattedYear, formattedMonth];
|
|
92
|
+
return components.join(separator);
|
|
93
|
+
};
|
|
94
|
+
const getSelectOptions = (el) => Array.from(el.options)
|
|
95
|
+
.map((opt) => opt.value)
|
|
96
|
+
.filter(Boolean);
|
|
97
|
+
export const getInputExpirationMonthFormat = (input) => {
|
|
98
|
+
const haystack = getCCFormatHaystack(input);
|
|
99
|
+
if (CC_EXP_MONTH_FORMAT.some((pattern) => haystack.includes(pattern)))
|
|
100
|
+
return { padding: true };
|
|
101
|
+
return { padding: input.minLength === 2 || input.maxLength === 2 };
|
|
102
|
+
};
|
|
103
|
+
export const getInputExpirationYearFormat = (input) => {
|
|
104
|
+
if (input.minLength === 4)
|
|
105
|
+
return { fullYear: true };
|
|
106
|
+
const haystack = getCCFormatHaystack(input);
|
|
107
|
+
for (const year of CC_EXP_YEAR_FORMAT) {
|
|
108
|
+
if (haystack.includes(year))
|
|
109
|
+
return { fullYear: year.length === 4 };
|
|
110
|
+
}
|
|
111
|
+
return { fullYear: false };
|
|
112
|
+
};
|
|
113
|
+
export const getSelectExpirationYearFormat = (select) => {
|
|
114
|
+
const options = getSelectOptions(select);
|
|
115
|
+
if (options.some((value) => /^\d{4}$/.test(value)))
|
|
116
|
+
return { fullYear: true };
|
|
117
|
+
if (options.some((value) => /^\d{2}$/.test(value)))
|
|
118
|
+
return { fullYear: false };
|
|
119
|
+
};
|
|
120
|
+
export const getSelectExpirationMonthFormat = (select) => {
|
|
121
|
+
const options = getSelectOptions(select);
|
|
122
|
+
if (options.some((value) => /^0[1-9]$/.test(value)))
|
|
123
|
+
return { padding: true };
|
|
124
|
+
if (options.some((value) => /^([1-9]|1[0-2])$/.test(value)))
|
|
125
|
+
return { padding: false };
|
|
126
|
+
};
|
|
127
|
+
const AUTOCOMPLETE_OUTLIERS = ["given-name", "additional-name", "family-name", "name"];
|
|
128
|
+
const guard = (options, predicate) => (field, autocompletes, haystack) => {
|
|
129
|
+
if (!options.password && field.getAttribute("type") === "password")
|
|
130
|
+
return false;
|
|
131
|
+
if (autocompletes.includes(options.autocomplete))
|
|
132
|
+
return true;
|
|
133
|
+
if (autocompletes.some((autocomplete) => AUTOCOMPLETE_OUTLIERS.includes(autocomplete)))
|
|
134
|
+
return false;
|
|
135
|
+
return predicate(field, autocompletes, haystack) && not(matchCCOutlier)(haystack);
|
|
136
|
+
};
|
|
137
|
+
const notCCIdentityOutlier = (autocompletes) => {
|
|
138
|
+
if (autocompletes.includes("billing"))
|
|
139
|
+
return false;
|
|
140
|
+
if (autocompletes.includes("shipping"))
|
|
141
|
+
return false;
|
|
142
|
+
return true;
|
|
143
|
+
};
|
|
144
|
+
const isCCFirstName = (_, autocompletes, haystack) => matchCCFirstName(haystack) && notCCIdentityOutlier(autocompletes);
|
|
145
|
+
const isCCLastName = (_, autocompletes, haystack) => matchCCLastName(haystack) && notCCIdentityOutlier(autocompletes);
|
|
146
|
+
const isCCName = (_, autocomplete, haystack) => matchCCName(haystack) && notCCIdentityOutlier(autocomplete);
|
|
147
|
+
const isCCSecurityCode = (_, _auto, haystack) => or(matchCCV, matchCCSecurityCode)(haystack);
|
|
148
|
+
const isCCNumber = (_, __, haystack) => matchCCNumber(haystack);
|
|
149
|
+
const isCCExp = (field, _, haystack) => field instanceof HTMLInputElement && matchCCExp(haystack);
|
|
150
|
+
const isCCExpMonth = (field, autocompletes, haystack) => {
|
|
151
|
+
if (autocompletes.includes("cc-exp"))
|
|
152
|
+
return false;
|
|
153
|
+
if (CC_EXP_FULL_RE.test(haystack))
|
|
154
|
+
return false;
|
|
155
|
+
if (matchCCExpMonth(haystack))
|
|
156
|
+
return true;
|
|
157
|
+
if (field instanceof HTMLSelectElement && matchCCExp(haystack)) {
|
|
158
|
+
return field.options.length >= 12 && field.options.length <= 14;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
};
|
|
162
|
+
const isCCExpYear = (field, autocompletes, haystack) => {
|
|
163
|
+
if (autocompletes.includes("cc-exp"))
|
|
164
|
+
return false;
|
|
165
|
+
if (CC_EXP_FULL_RE.test(haystack))
|
|
166
|
+
return false;
|
|
167
|
+
if (matchCCExpYear(haystack))
|
|
168
|
+
return true;
|
|
169
|
+
if (field instanceof HTMLSelectElement && matchCCExp(haystack)) {
|
|
170
|
+
for (const option of field.options) {
|
|
171
|
+
if (option.innerText === YEAR_OPTION)
|
|
172
|
+
return true;
|
|
173
|
+
if (option.value === YEAR_OPTION)
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
};
|
|
179
|
+
const CC_MATCHERS = [
|
|
180
|
+
[CCFieldType.FIRSTNAME, guard({ autocomplete: "cc-given-name" }, isCCFirstName)],
|
|
181
|
+
[CCFieldType.LASTNAME, guard({ autocomplete: "cc-family-name" }, isCCLastName)],
|
|
182
|
+
[CCFieldType.NAME, guard({ autocomplete: "cc-name" }, isCCName)],
|
|
183
|
+
[CCFieldType.EXP_YEAR, guard({ autocomplete: "cc-exp-year" }, isCCExpYear)],
|
|
184
|
+
[CCFieldType.EXP_MONTH, guard({ autocomplete: "cc-exp-month" }, isCCExpMonth)],
|
|
185
|
+
[CCFieldType.EXP, guard({ autocomplete: "cc-exp" }, isCCExp)],
|
|
186
|
+
[CCFieldType.CSC, guard({ autocomplete: "cc-csc", password: true }, isCCSecurityCode)],
|
|
187
|
+
[CCFieldType.NUMBER, guard({ autocomplete: "cc-number", password: true }, isCCNumber)],
|
|
188
|
+
];
|
|
189
|
+
export const getCCHaystack = (field) => {
|
|
190
|
+
const attrs = CC_ATTRIBUTES.map((attr) => { var _a; return (_a = field === null || field === void 0 ? void 0 : field.getAttribute(attr)) !== null && _a !== void 0 ? _a : ""; });
|
|
191
|
+
const labelEl = getLabelFor(field);
|
|
192
|
+
const label = sanitizeString((() => {
|
|
193
|
+
if (!labelEl)
|
|
194
|
+
return "";
|
|
195
|
+
if (labelEl.innerText)
|
|
196
|
+
return labelEl.innerText;
|
|
197
|
+
if (labelEl.childElementCount === 0)
|
|
198
|
+
return "";
|
|
199
|
+
return Array.from(labelEl.children)
|
|
200
|
+
.map((el) => { var _a; return (_a = el === null || el === void 0 ? void 0 : el.innerText) !== null && _a !== void 0 ? _a : ""; })
|
|
201
|
+
.join(" ");
|
|
202
|
+
})());
|
|
203
|
+
return sanitizeStringWithSpaces(attrs.join(" ")) + " " + label;
|
|
204
|
+
};
|
|
205
|
+
export const getCachedCCSubtype = (el) => {
|
|
206
|
+
const subType = getCachedSubType(el);
|
|
207
|
+
if (subType && ccFields.has(subType))
|
|
208
|
+
return subType;
|
|
209
|
+
};
|
|
210
|
+
export const getCCFieldType = (field) => {
|
|
211
|
+
var _a;
|
|
212
|
+
const cachedSubType = getCachedCCSubtype(field);
|
|
213
|
+
if (cachedSubType)
|
|
214
|
+
return cachedSubType;
|
|
215
|
+
const type = field.getAttribute("type");
|
|
216
|
+
if (field.tagName === "INPUT" && type && !CC_INPUT_TYPES.includes(type))
|
|
217
|
+
return;
|
|
218
|
+
const haystack = getCCHaystack(field);
|
|
219
|
+
const autocompletes = getAutocompletes(field);
|
|
220
|
+
if (haystack) {
|
|
221
|
+
const ccType = (_a = CC_MATCHERS.find(([, test]) => test(field, autocompletes, haystack))) === null || _a === void 0 ? void 0 : _a[0];
|
|
222
|
+
if (ccType)
|
|
223
|
+
setCachedSubType(field, ccType);
|
|
224
|
+
return ccType;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
export const matchCCFieldCandidate = (input, { visible }) => {
|
|
228
|
+
if (getCachedCCSubtype(input))
|
|
229
|
+
return true;
|
|
230
|
+
if (!visible)
|
|
231
|
+
return false;
|
|
232
|
+
const ccType = getCCFieldType(input);
|
|
233
|
+
if (ccType)
|
|
234
|
+
setCachedSubType(input, ccType);
|
|
235
|
+
return ccType !== undefined;
|
|
236
|
+
};
|
|
237
|
+
export const isCCInputField = (fnode) => {
|
|
238
|
+
const { isCC, visible } = fnode.noteFor("field");
|
|
239
|
+
if (!visible)
|
|
240
|
+
return false;
|
|
241
|
+
return isCC;
|
|
242
|
+
};
|
|
243
|
+
export const isCCSelectField = (fnode) => {
|
|
244
|
+
const select = fnode.element;
|
|
245
|
+
if (!(select instanceof HTMLSelectElement))
|
|
246
|
+
return false;
|
|
247
|
+
if (getCachedCCSubtype(select))
|
|
248
|
+
return true;
|
|
249
|
+
const visible = isVisible(select, { opacity: false });
|
|
250
|
+
if (!visible)
|
|
251
|
+
return false;
|
|
252
|
+
const isProcessable = isClassifiable(select);
|
|
253
|
+
if (!isProcessable)
|
|
254
|
+
return false;
|
|
255
|
+
const ccType = getCCFieldType(select);
|
|
256
|
+
if (ccType)
|
|
257
|
+
setCachedSubType(select, ccType);
|
|
258
|
+
return ccType !== undefined;
|
|
259
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|