a11y-form-validator 1.0.0
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/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +390 -0
- package/dist/A11yFormValidator-D0n6br-b.d.ts +335 -0
- package/dist/A11yFormValidator-D0n6br-b.d.ts.map +1 -0
- package/dist/addons/character-count.d.ts +38 -0
- package/dist/addons/character-count.d.ts.map +1 -0
- package/dist/addons/character-count.js +161 -0
- package/dist/addons/character-count.js.map +1 -0
- package/dist/addons/error-summary.d.ts +29 -0
- package/dist/addons/error-summary.d.ts.map +1 -0
- package/dist/addons/error-summary.js +4 -0
- package/dist/default-BHBWPNeK.d.ts +7 -0
- package/dist/default-BHBWPNeK.d.ts.map +1 -0
- package/dist/default-DFnPBuVC.js +18 -0
- package/dist/default-DFnPBuVC.js.map +1 -0
- package/dist/docs.d.ts +66 -0
- package/dist/docs.d.ts.map +1 -0
- package/dist/docs.js +204 -0
- package/dist/docs.js.map +1 -0
- package/dist/error-summary-FnZoUC72.js +99 -0
- package/dist/error-summary-FnZoUC72.js.map +1 -0
- package/dist/helpers-c_THOe-Q.js +150 -0
- package/dist/helpers-c_THOe-Q.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1197 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/locales/ar.json +13 -0
- package/dist/locales/en.json +13 -0
- package/dist/locales/es.json +13 -0
- package/dist/locales/fr.json +13 -0
- package/dist/locales/hi.json +13 -0
- package/dist/locales/it.json +13 -0
- package/dist/locales/ja.json +13 -0
- package/dist/locales/ko.json +13 -0
- package/dist/locales/nl.json +13 -0
- package/dist/locales/pl.json +13 -0
- package/dist/locales/pt-BR.json +13 -0
- package/dist/locales/ru.json +13 -0
- package/dist/locales/tr.json +13 -0
- package/dist/locales/uk.json +13 -0
- package/dist/locales/zh-CN.json +13 -0
- package/dist/minimal-40_EIW9U.d.ts +7 -0
- package/dist/minimal-40_EIW9U.d.ts.map +1 -0
- package/dist/minimal-Bm3pKoN7.js +15 -0
- package/dist/minimal-Bm3pKoN7.js.map +1 -0
- package/dist/no-summary-BI1pTld5.d.ts +7 -0
- package/dist/no-summary-BI1pTld5.d.ts.map +1 -0
- package/dist/no-summary-DQCNtzs6.js +16 -0
- package/dist/no-summary-DQCNtzs6.js.map +1 -0
- package/dist/presets/default.d.ts +3 -0
- package/dist/presets/default.js +5 -0
- package/dist/presets/minimal.d.ts +3 -0
- package/dist/presets/minimal.js +3 -0
- package/dist/presets/no-summary.d.ts +3 -0
- package/dist/presets/no-summary.js +3 -0
- package/dist/styles.css +91 -0
- package/package.json +95 -0
package/dist/docs.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/docs.d.ts
|
|
2
|
+
interface PluginDocs {
|
|
3
|
+
slug: string;
|
|
4
|
+
name: string;
|
|
5
|
+
packageName: string;
|
|
6
|
+
description: string;
|
|
7
|
+
repo?: string;
|
|
8
|
+
npm?: string;
|
|
9
|
+
install: {
|
|
10
|
+
npm: string;
|
|
11
|
+
pnpm: string;
|
|
12
|
+
yarn: string;
|
|
13
|
+
};
|
|
14
|
+
usage: string;
|
|
15
|
+
selectors?: string[];
|
|
16
|
+
keyboard?: Array<{
|
|
17
|
+
key: string;
|
|
18
|
+
description: string;
|
|
19
|
+
}>;
|
|
20
|
+
accessibility?: string[];
|
|
21
|
+
limitations?: string[];
|
|
22
|
+
api: Array<{
|
|
23
|
+
name: string;
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
}>;
|
|
27
|
+
examples?: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
path: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
declare const docs: {
|
|
34
|
+
slug: string;
|
|
35
|
+
name: string;
|
|
36
|
+
packageName: string;
|
|
37
|
+
description: string;
|
|
38
|
+
repo: string;
|
|
39
|
+
npm: string;
|
|
40
|
+
install: {
|
|
41
|
+
npm: string;
|
|
42
|
+
pnpm: string;
|
|
43
|
+
yarn: string;
|
|
44
|
+
};
|
|
45
|
+
usage: string;
|
|
46
|
+
selectors: string[];
|
|
47
|
+
keyboard: {
|
|
48
|
+
key: string;
|
|
49
|
+
description: string;
|
|
50
|
+
}[];
|
|
51
|
+
accessibility: string[];
|
|
52
|
+
limitations: string[];
|
|
53
|
+
api: {
|
|
54
|
+
name: string;
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
}[];
|
|
58
|
+
examples: {
|
|
59
|
+
name: string;
|
|
60
|
+
description: string;
|
|
61
|
+
path: string;
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { PluginDocs, docs };
|
|
66
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","names":[],"sources":["../src/docs.ts"],"sourcesContent":[],"mappings":";UAAiB,UAAA;EAAA,IAAA,EAAA,MAAA;EAcJ,IAAA,EAAA,MAAA;EAMN,WAAA,EAAA,MAAA;EAKM,WAAA,EAAA,MAAA;EAAK,IAAA,CAAA,EAAA,MAAA;EAOL,GAAA,CAAA,EAAA,MAuMS;;;;;;;;aAzNT;;;;;;OAMN;;;;;aAKM;;;;;;cAOA"}
|
package/dist/docs.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
//#region src/docs.ts
|
|
2
|
+
const docs = {
|
|
3
|
+
slug: "a11y-form-validator",
|
|
4
|
+
name: "A11y Form Validator",
|
|
5
|
+
packageName: "a11y-form-validator",
|
|
6
|
+
description: "Accessible, dependency-light progressive enhancement for semantic HTML forms.",
|
|
7
|
+
repo: "https://github.com/vmitsaras/A11y-Form-Validator",
|
|
8
|
+
npm: "https://www.npmjs.com/package/a11y-form-validator",
|
|
9
|
+
install: {
|
|
10
|
+
npm: "npm install a11y-form-validator",
|
|
11
|
+
pnpm: "pnpm add a11y-form-validator",
|
|
12
|
+
yarn: "yarn add a11y-form-validator"
|
|
13
|
+
},
|
|
14
|
+
usage: `import {
|
|
15
|
+
createDefaultPreset,
|
|
16
|
+
createFormValidator
|
|
17
|
+
} from "a11y-form-validator";
|
|
18
|
+
import "a11y-form-validator/styles.css";
|
|
19
|
+
|
|
20
|
+
const form = document.querySelector("[data-a11y-form-validator]");
|
|
21
|
+
if (form instanceof HTMLFormElement) {
|
|
22
|
+
createFormValidator(form, createDefaultPreset());
|
|
23
|
+
}`,
|
|
24
|
+
selectors: [
|
|
25
|
+
"[data-a11y-form-validator]",
|
|
26
|
+
"input, select, textarea",
|
|
27
|
+
"[data-validate]",
|
|
28
|
+
"[data-message-*]",
|
|
29
|
+
"[data-character-count]"
|
|
30
|
+
],
|
|
31
|
+
keyboard: [
|
|
32
|
+
{
|
|
33
|
+
key: "Tab / Shift+Tab",
|
|
34
|
+
description: "Moves through the form controls, generated error summary links, and submit button in document order."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
key: "Enter",
|
|
38
|
+
description: "Submits the form from text fields or activates error summary links."
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: "Space",
|
|
42
|
+
description: "Toggles native checkboxes and radio buttons; the validator preserves native control behavior."
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
accessibility: [
|
|
46
|
+
"Enhances native form controls and keeps existing labels, groups, and fieldsets in place.",
|
|
47
|
+
"Inline errors are associated with fields through aria-describedby and aria-errormessage.",
|
|
48
|
+
"Field-level validation uses polite inline error announcements; blocked submits that focus the summary suppress duplicate inline live-region announcements.",
|
|
49
|
+
"The error summary is focusable and labelled; field errors are field-labelled links that focus invalid controls, while form-level errors render as text.",
|
|
50
|
+
"Focus moves to the summary or first invalid field after blocked submits, depending on focusOnError.",
|
|
51
|
+
"Applications applying server errors with setErrors() should call focusOnError() when the summary or first invalid field should be announced immediately.",
|
|
52
|
+
"Keyboard behavior remains native: Tab moves through controls and summary links; Enter submits forms or activates links; Space toggles native checkboxes and radio buttons."
|
|
53
|
+
],
|
|
54
|
+
limitations: [
|
|
55
|
+
"The plugin validates controls collected by selectors.fields; custom widgets need custom rules, a custom renderer, or extra integration code.",
|
|
56
|
+
"Remote validation is supported through async custom rules, but request cancellation is the application’s responsibility.",
|
|
57
|
+
"Async pending state is exposed through validator state, events, and .is-pending; add an application live status when progress announcements are needed.",
|
|
58
|
+
"The default CSS is intentionally minimal and may need product-specific layout styles.",
|
|
59
|
+
"Native browser validation messages vary by browser and locale when errorMode includes native behavior."
|
|
60
|
+
],
|
|
61
|
+
api: [
|
|
62
|
+
{
|
|
63
|
+
name: "createFormValidator(form, options)",
|
|
64
|
+
type: "(form: HTMLFormElement, options?: A11yFormValidatorOptionsInput) => A11yFormValidatorInstance",
|
|
65
|
+
description: "Initializes accessible validation behavior on a form and reuses an existing instance for duplicate calls."
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "initFormValidators(options, root)",
|
|
69
|
+
type: "(options?: A11yFormValidatorOptionsInput, root?: ParentNode) => A11yFormValidatorInstance[]",
|
|
70
|
+
description: "Initializes every form matching [data-a11y-form-validator] under the provided root."
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "A11yFormValidator",
|
|
74
|
+
type: "class",
|
|
75
|
+
description: "Plugin class for advanced usage; exposes validation, state, rule registration, server errors, and cleanup methods."
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "a11y-form-validator/min",
|
|
79
|
+
type: "package subpath",
|
|
80
|
+
description: "Optional minified ESM entry for direct browser or CDN-style imports. It reuses dist/index.d.ts and does not replace the default package entry."
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "createDefaultPreset()",
|
|
84
|
+
type: "() => A11yFormValidatorOptionsInput",
|
|
85
|
+
description: "Available from the main entry and a11y-form-validator/presets/default. Includes the error summary addon: submit and blur validation, inline and native messages, summary focus after blocked submits, and generated summary UI."
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "createNoSummaryPreset()",
|
|
89
|
+
type: "() => A11yFormValidatorOptionsInput",
|
|
90
|
+
description: "Available from the main entry and a11y-form-validator/presets/no-summary. Matches the default submit and blur validation pattern without importing or installing the error summary addon."
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "createMinimalPreset()",
|
|
94
|
+
type: "() => A11yFormValidatorOptionsInput",
|
|
95
|
+
description: "Available from the main entry and a11y-form-validator/presets/minimal. Returns submit validation, inline errors, native rules, and focus on the first invalid field."
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "createErrorSummaryAddon(options)",
|
|
99
|
+
type: "(options?: ErrorSummaryAddonOptions) => ErrorSummaryAddon",
|
|
100
|
+
description: "Import from a11y-form-validator/addons/error-summary. Creates a labelled, focusable error summary that lists form errors and links field errors back to invalid controls."
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "createCharacterCountAddon(options)",
|
|
104
|
+
type: "(options?: CharacterCountAddonOptions) => CharacterCountAddon",
|
|
105
|
+
description: "Import from a11y-form-validator/addons/character-count. Creates polite character count guidance for controls with maxlength, minlength, or data-character-count."
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "validate(), validateField(), refresh()",
|
|
109
|
+
type: "instance methods",
|
|
110
|
+
description: "Validate the full form, validate one field by name or element, or rescan fields after dynamic markup changes."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "getErrors(), getState(), clearErrors()",
|
|
114
|
+
type: "instance methods",
|
|
115
|
+
description: "Read current field/form errors and validation state, or remove rendered validation messages."
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "setErrors(errors)",
|
|
119
|
+
type: "(errors?: ServerErrors) => A11yFormValidatorInstance",
|
|
120
|
+
description: "Renders server-provided field and form errors without replacing semantic form markup; call focusOnError() afterward when users should be moved to the summary or first invalid field."
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "focusOnError()",
|
|
124
|
+
type: "() => void",
|
|
125
|
+
description: "Moves focus according to focusOnError, usually to the error summary or first invalid field."
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "registerRule(name, rule), unregisterRule(name)",
|
|
129
|
+
type: "instance methods",
|
|
130
|
+
description: "Adds or removes custom validation rules for product-specific, conditional, cross-field, or async validation."
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "reset(), enable(), disable(), destroy()",
|
|
134
|
+
type: "instance methods",
|
|
135
|
+
description: "Reset state, toggle validation, or remove listeners, generated errors, addons, timers, plugin classes, and generated ARIA state."
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
examples: [
|
|
139
|
+
{
|
|
140
|
+
name: "Direct browser minified build",
|
|
141
|
+
description: "Direct browser demo that imports the optional minified ESM build without making it the default bundler entry.",
|
|
142
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/minified.html"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "Basic",
|
|
146
|
+
description: "Semantic contact form with inline errors, an error summary, and character count guidance.",
|
|
147
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/basic.html"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "Contact Form",
|
|
151
|
+
description: "Small form using the minimal preset with native required, email, and minlength checks.",
|
|
152
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/contact.html"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "CMS Markup",
|
|
156
|
+
description: "Data-attribute rules and field-specific messages for markup produced by content systems or templates.",
|
|
157
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/cms-markup.html"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "Error Summary",
|
|
161
|
+
description: "Focusable summary region with links that send users back to invalid fields.",
|
|
162
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/error-summary.html"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "Registration",
|
|
166
|
+
description: "Password confirmation with a custom same-as rule and custom error copy.",
|
|
167
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/registration.html"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "Login / Register",
|
|
171
|
+
description: "Switch between login and registration forms while only the visible form is active and validated.",
|
|
172
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/login-register.html"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "Checkout",
|
|
176
|
+
description: "Conditional billing validation plus required shipping and payment method choices.",
|
|
177
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/checkout.html"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "Remote Validation",
|
|
181
|
+
description: "Username availability checked with an async custom rule and debounced input validation.",
|
|
182
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/remote-validation.html"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "Server Errors",
|
|
186
|
+
description: "Server-provided field and form messages rendered after a failed request.",
|
|
187
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/server-errors.html"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "Localization",
|
|
191
|
+
description: "English fallback, imported locale JSON, and inline locale messages.",
|
|
192
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/localization.html"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "Dynamic Locale",
|
|
196
|
+
description: "Destroy and reinitialize the validator to swap runtime locale packs and regenerate errors.",
|
|
197
|
+
path: "https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/dynamic-locale.html"
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
export { docs };
|
|
204
|
+
//# sourceMappingURL=docs.js.map
|
package/dist/docs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","names":[],"sources":["../src/docs.ts"],"sourcesContent":["export interface PluginDocs {\n slug: string;\n name: string;\n packageName: string;\n description: string;\n repo?: string;\n npm?: string;\n install: {\n npm: string;\n pnpm: string;\n yarn: string;\n };\n usage: string;\n selectors?: string[];\n keyboard?: Array<{\n key: string;\n description: string;\n }>;\n accessibility?: string[];\n limitations?: string[];\n api: Array<{\n name: string;\n type: string;\n description: string;\n }>;\n examples?: Array<{\n name: string;\n description: string;\n path: string;\n }>;\n}\n\nexport const docs = {\n slug: 'a11y-form-validator',\n name: 'A11y Form Validator',\n packageName: 'a11y-form-validator',\n description: 'Accessible, dependency-light progressive enhancement for semantic HTML forms.',\n repo: 'https://github.com/vmitsaras/A11y-Form-Validator',\n npm: 'https://www.npmjs.com/package/a11y-form-validator',\n install: {\n npm: 'npm install a11y-form-validator',\n pnpm: 'pnpm add a11y-form-validator',\n yarn: 'yarn add a11y-form-validator'\n },\n usage: `import {\n createDefaultPreset,\n createFormValidator\n} from \"a11y-form-validator\";\nimport \"a11y-form-validator/styles.css\";\n\nconst form = document.querySelector(\"[data-a11y-form-validator]\");\nif (form instanceof HTMLFormElement) {\n createFormValidator(form, createDefaultPreset());\n}`,\n selectors: [\n '[data-a11y-form-validator]',\n 'input, select, textarea',\n '[data-validate]',\n '[data-message-*]',\n '[data-character-count]'\n ],\n keyboard: [\n {\n key: 'Tab / Shift+Tab',\n description: 'Moves through the form controls, generated error summary links, and submit button in document order.'\n },\n {\n key: 'Enter',\n description: 'Submits the form from text fields or activates error summary links.'\n },\n {\n key: 'Space',\n description: 'Toggles native checkboxes and radio buttons; the validator preserves native control behavior.'\n }\n ],\n accessibility: [\n 'Enhances native form controls and keeps existing labels, groups, and fieldsets in place.',\n 'Inline errors are associated with fields through aria-describedby and aria-errormessage.',\n 'Field-level validation uses polite inline error announcements; blocked submits that focus the summary suppress duplicate inline live-region announcements.',\n 'The error summary is focusable and labelled; field errors are field-labelled links that focus invalid controls, while form-level errors render as text.',\n 'Focus moves to the summary or first invalid field after blocked submits, depending on focusOnError.',\n 'Applications applying server errors with setErrors() should call focusOnError() when the summary or first invalid field should be announced immediately.',\n 'Keyboard behavior remains native: Tab moves through controls and summary links; Enter submits forms or activates links; Space toggles native checkboxes and radio buttons.'\n ],\n limitations: [\n 'The plugin validates controls collected by selectors.fields; custom widgets need custom rules, a custom renderer, or extra integration code.',\n 'Remote validation is supported through async custom rules, but request cancellation is the application’s responsibility.',\n 'Async pending state is exposed through validator state, events, and .is-pending; add an application live status when progress announcements are needed.',\n 'The default CSS is intentionally minimal and may need product-specific layout styles.',\n 'Native browser validation messages vary by browser and locale when errorMode includes native behavior.'\n ],\n api: [\n {\n name: 'createFormValidator(form, options)',\n type: '(form: HTMLFormElement, options?: A11yFormValidatorOptionsInput) => A11yFormValidatorInstance',\n description: 'Initializes accessible validation behavior on a form and reuses an existing instance for duplicate calls.'\n },\n {\n name: 'initFormValidators(options, root)',\n type: '(options?: A11yFormValidatorOptionsInput, root?: ParentNode) => A11yFormValidatorInstance[]',\n description: 'Initializes every form matching [data-a11y-form-validator] under the provided root.'\n },\n {\n name: 'A11yFormValidator',\n type: 'class',\n description: 'Plugin class for advanced usage; exposes validation, state, rule registration, server errors, and cleanup methods.'\n },\n {\n name: 'a11y-form-validator/min',\n type: 'package subpath',\n description: 'Optional minified ESM entry for direct browser or CDN-style imports. It reuses dist/index.d.ts and does not replace the default package entry.'\n },\n {\n name: 'createDefaultPreset()',\n type: '() => A11yFormValidatorOptionsInput',\n description: 'Available from the main entry and a11y-form-validator/presets/default. Includes the error summary addon: submit and blur validation, inline and native messages, summary focus after blocked submits, and generated summary UI.'\n },\n {\n name: 'createNoSummaryPreset()',\n type: '() => A11yFormValidatorOptionsInput',\n description: 'Available from the main entry and a11y-form-validator/presets/no-summary. Matches the default submit and blur validation pattern without importing or installing the error summary addon.'\n },\n {\n name: 'createMinimalPreset()',\n type: '() => A11yFormValidatorOptionsInput',\n description: 'Available from the main entry and a11y-form-validator/presets/minimal. Returns submit validation, inline errors, native rules, and focus on the first invalid field.'\n },\n {\n name: 'createErrorSummaryAddon(options)',\n type: '(options?: ErrorSummaryAddonOptions) => ErrorSummaryAddon',\n description: 'Import from a11y-form-validator/addons/error-summary. Creates a labelled, focusable error summary that lists form errors and links field errors back to invalid controls.'\n },\n {\n name: 'createCharacterCountAddon(options)',\n type: '(options?: CharacterCountAddonOptions) => CharacterCountAddon',\n description: 'Import from a11y-form-validator/addons/character-count. Creates polite character count guidance for controls with maxlength, minlength, or data-character-count.'\n },\n {\n name: 'validate(), validateField(), refresh()',\n type: 'instance methods',\n description: 'Validate the full form, validate one field by name or element, or rescan fields after dynamic markup changes.'\n },\n {\n name: 'getErrors(), getState(), clearErrors()',\n type: 'instance methods',\n description: 'Read current field/form errors and validation state, or remove rendered validation messages.'\n },\n {\n name: 'setErrors(errors)',\n type: '(errors?: ServerErrors) => A11yFormValidatorInstance',\n description: 'Renders server-provided field and form errors without replacing semantic form markup; call focusOnError() afterward when users should be moved to the summary or first invalid field.'\n },\n {\n name: 'focusOnError()',\n type: '() => void',\n description: 'Moves focus according to focusOnError, usually to the error summary or first invalid field.'\n },\n {\n name: 'registerRule(name, rule), unregisterRule(name)',\n type: 'instance methods',\n description: 'Adds or removes custom validation rules for product-specific, conditional, cross-field, or async validation.'\n },\n {\n name: 'reset(), enable(), disable(), destroy()',\n type: 'instance methods',\n description: 'Reset state, toggle validation, or remove listeners, generated errors, addons, timers, plugin classes, and generated ARIA state.'\n }\n ],\n examples: [\n {\n name: 'Direct browser minified build',\n description:\n 'Direct browser demo that imports the optional minified ESM build without making it the default bundler entry.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/minified.html'\n },\n {\n name: 'Basic',\n description: 'Semantic contact form with inline errors, an error summary, and character count guidance.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/basic.html'\n },\n {\n name: 'Contact Form',\n description: 'Small form using the minimal preset with native required, email, and minlength checks.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/contact.html'\n },\n {\n name: 'CMS Markup',\n description: 'Data-attribute rules and field-specific messages for markup produced by content systems or templates.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/cms-markup.html'\n },\n {\n name: 'Error Summary',\n description: 'Focusable summary region with links that send users back to invalid fields.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/error-summary.html'\n },\n {\n name: 'Registration',\n description: 'Password confirmation with a custom same-as rule and custom error copy.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/registration.html'\n },\n {\n name: 'Login / Register',\n description: 'Switch between login and registration forms while only the visible form is active and validated.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/login-register.html'\n },\n {\n name: 'Checkout',\n description: 'Conditional billing validation plus required shipping and payment method choices.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/checkout.html'\n },\n {\n name: 'Remote Validation',\n description: 'Username availability checked with an async custom rule and debounced input validation.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/remote-validation.html'\n },\n {\n name: 'Server Errors',\n description: 'Server-provided field and form messages rendered after a failed request.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/server-errors.html'\n },\n {\n name: 'Localization',\n description: 'English fallback, imported locale JSON, and inline locale messages.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/localization.html'\n },\n {\n name: 'Dynamic Locale',\n description: 'Destroy and reinitialize the validator to swap runtime locale packs and regenerate errors.',\n path: 'https://github.com/vmitsaras/A11y-Form-Validator/blob/main/demo/dynamic-locale.html'\n }\n ]\n} satisfies PluginDocs;\n"],"mappings":";AAgCA,MAAa,OAAO;CAClB,MAAM;CACN,MAAM;CACN,aAAa;CACb,aAAa;CACb,MAAM;CACN,KAAK;CACL,SAAS;EACP,KAAK;EACL,MAAM;EACN,MAAM;EACP;CACD,OAAO;;;;;;;;;;CAUP,WAAW;EACT;EACA;EACA;EACA;EACA;EACD;CACD,UAAU;EACR;GACE,KAAK;GACL,aAAa;GACd;EACD;GACE,KAAK;GACL,aAAa;GACd;EACD;GACE,KAAK;GACL,aAAa;GACd;EACF;CACD,eAAe;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACD,aAAa;EACX;EACA;EACA;EACA;EACA;EACD;CACD,KAAK;EACH;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACD;GACE,MAAM;GACN,MAAM;GACN,aAAa;GACd;EACF;CACD,UAAU;EACR;GACE,MAAM;GACN,aACE;GACF,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACD;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACP;EACF;CACF"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { a as getPreferredScrollBehavior, r as ensureElementId } from "./helpers-c_THOe-Q.js";
|
|
2
|
+
|
|
3
|
+
//#region src/addons/error-summary.ts
|
|
4
|
+
function createErrorSummaryAddon(options = {}) {
|
|
5
|
+
return {
|
|
6
|
+
validator: null,
|
|
7
|
+
options,
|
|
8
|
+
container: null,
|
|
9
|
+
title: null,
|
|
10
|
+
list: null,
|
|
11
|
+
install(validator) {
|
|
12
|
+
this.validator = validator;
|
|
13
|
+
this.options = options;
|
|
14
|
+
const document = validator.form.ownerDocument;
|
|
15
|
+
this.container = document.createElement("section");
|
|
16
|
+
this.container.className = "a11y-form-validator__summary";
|
|
17
|
+
this.container.hidden = true;
|
|
18
|
+
this.container.tabIndex = -1;
|
|
19
|
+
this.title = document.createElement("h2");
|
|
20
|
+
this.title.id = options.titleId || `${ensureElementId(validator.form, "a11y-form-validator-form")}-summary-title`;
|
|
21
|
+
this.title.className = "a11y-form-validator__summary-title";
|
|
22
|
+
this.container.setAttribute("aria-labelledby", this.title.id);
|
|
23
|
+
this.list = document.createElement("ul");
|
|
24
|
+
this.list.className = "a11y-form-validator__summary-list";
|
|
25
|
+
this.container.append(this.title, this.list);
|
|
26
|
+
validator.form.prepend(this.container);
|
|
27
|
+
validator.summaryAddon = this;
|
|
28
|
+
this.unsubscribeAfterValidate = validator.events.on("a11y-form-validator:after-validate", () => this.update());
|
|
29
|
+
this.unsubscribeDestroy = validator.events.on("a11y-form-validator:destroy", () => this.destroy());
|
|
30
|
+
},
|
|
31
|
+
getErrors() {
|
|
32
|
+
if (!this.validator) return [];
|
|
33
|
+
const fieldErrors = this.validator.fields.filter((field) => field.lastError).map((field) => ({
|
|
34
|
+
field,
|
|
35
|
+
message: field.lastError
|
|
36
|
+
}));
|
|
37
|
+
return [...this.validator.formErrors.map((message, index) => ({
|
|
38
|
+
field: null,
|
|
39
|
+
message,
|
|
40
|
+
key: `form-${index}`
|
|
41
|
+
})), ...fieldErrors];
|
|
42
|
+
},
|
|
43
|
+
hasErrors() {
|
|
44
|
+
return this.getErrors().length > 0;
|
|
45
|
+
},
|
|
46
|
+
update() {
|
|
47
|
+
if (!this.container || !this.list || !this.title || !this.validator) return;
|
|
48
|
+
const errors = this.getErrors();
|
|
49
|
+
this.list.replaceChildren();
|
|
50
|
+
if (!errors.length) {
|
|
51
|
+
this.container.hidden = true;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.title.textContent = this.validator.messageResolver.getSummaryTitle(errors.length);
|
|
55
|
+
errors.forEach((entry) => {
|
|
56
|
+
const item = this.validator.form.ownerDocument.createElement("li");
|
|
57
|
+
if (!entry.field) item.textContent = entry.message;
|
|
58
|
+
else {
|
|
59
|
+
const link = this.validator.form.ownerDocument.createElement("a");
|
|
60
|
+
link.className = "a11y-form-validator__summary-link";
|
|
61
|
+
link.href = `#${entry.field.primaryId}`;
|
|
62
|
+
link.textContent = this.validator.messageResolver.getSummaryItem(entry.field, entry.message);
|
|
63
|
+
const field = entry.field;
|
|
64
|
+
link.addEventListener("click", (event) => {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
field.focus();
|
|
67
|
+
});
|
|
68
|
+
item.append(link);
|
|
69
|
+
}
|
|
70
|
+
this.list.append(item);
|
|
71
|
+
});
|
|
72
|
+
this.container.hidden = false;
|
|
73
|
+
},
|
|
74
|
+
focus() {
|
|
75
|
+
if (this.hasErrors() && this.container) {
|
|
76
|
+
this.container.focus({ preventScroll: true });
|
|
77
|
+
this.container.scrollIntoView?.({
|
|
78
|
+
block: "start",
|
|
79
|
+
behavior: getPreferredScrollBehavior(this.container)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
destroy() {
|
|
84
|
+
this.unsubscribeAfterValidate?.();
|
|
85
|
+
this.unsubscribeDestroy?.();
|
|
86
|
+
this.container?.remove();
|
|
87
|
+
if (this.validator) this.validator.summaryAddon = null;
|
|
88
|
+
this.container = null;
|
|
89
|
+
this.title = null;
|
|
90
|
+
this.list = null;
|
|
91
|
+
this.validator = null;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
var error_summary_default = createErrorSummaryAddon;
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
export { error_summary_default as n, createErrorSummaryAddon as t };
|
|
99
|
+
//# sourceMappingURL=error-summary-FnZoUC72.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-summary-FnZoUC72.js","names":[],"sources":["../src/addons/error-summary.ts"],"sourcesContent":["import type { A11yFormValidator, ValidatorAddon } from '../core/A11yFormValidator.js';\nimport type { FieldController } from '../core/FieldController.js';\nimport { ensureElementId, getPreferredScrollBehavior } from '../core/helpers.js';\n\nexport interface ErrorSummaryAddonOptions {\n titleId?: string;\n}\n\nexport interface SummaryEntry {\n field: FieldController | null;\n message: string;\n key?: string;\n}\n\nexport interface ErrorSummaryAddon extends ValidatorAddon {\n validator: A11yFormValidator | null;\n options: ErrorSummaryAddonOptions;\n container: HTMLElement | null;\n title: HTMLHeadingElement | null;\n list: HTMLUListElement | null;\n unsubscribeAfterValidate?: () => void;\n unsubscribeDestroy?: () => void;\n getErrors(): SummaryEntry[];\n update(): void;\n hasErrors(): boolean;\n focus(): void;\n destroy(): void;\n}\n\nexport function createErrorSummaryAddon(options: ErrorSummaryAddonOptions = {}): ErrorSummaryAddon {\n return {\n validator: null,\n options,\n container: null,\n title: null,\n list: null,\n\n install(validator: A11yFormValidator) {\n this.validator = validator;\n this.options = options;\n const document = validator.form.ownerDocument;\n this.container = document.createElement('section');\n this.container.className = 'a11y-form-validator__summary';\n this.container.hidden = true;\n this.container.tabIndex = -1;\n this.title = document.createElement('h2');\n this.title.id = options.titleId || `${ensureElementId(validator.form, 'a11y-form-validator-form')}-summary-title`;\n this.title.className = 'a11y-form-validator__summary-title';\n this.container.setAttribute('aria-labelledby', this.title.id);\n this.list = document.createElement('ul');\n this.list.className = 'a11y-form-validator__summary-list';\n this.container.append(this.title, this.list);\n validator.form.prepend(this.container);\n validator.summaryAddon = this;\n\n this.unsubscribeAfterValidate = validator.events.on('a11y-form-validator:after-validate', () => this.update());\n this.unsubscribeDestroy = validator.events.on('a11y-form-validator:destroy', () => this.destroy());\n },\n\n getErrors(): SummaryEntry[] {\n if (!this.validator) {\n return [];\n }\n\n const fieldErrors = this.validator.fields\n .filter((field) => field.lastError)\n .map((field) => ({\n field,\n message: field.lastError\n }));\n\n const formErrors = this.validator.formErrors.map((message, index) => ({\n field: null,\n message,\n key: `form-${index}`\n }));\n\n return [...formErrors, ...fieldErrors];\n },\n\n hasErrors(): boolean {\n return this.getErrors().length > 0;\n },\n\n update(): void {\n if (!this.container || !this.list || !this.title || !this.validator) {\n return;\n }\n\n const errors = this.getErrors();\n this.list.replaceChildren();\n if (!errors.length) {\n this.container.hidden = true;\n return;\n }\n\n this.title.textContent = this.validator.messageResolver.getSummaryTitle(errors.length);\n errors.forEach((entry) => {\n const item = this.validator!.form.ownerDocument.createElement('li');\n if (!entry.field) {\n item.textContent = entry.message;\n } else {\n const link = this.validator!.form.ownerDocument.createElement('a');\n link.className = 'a11y-form-validator__summary-link';\n link.href = `#${entry.field.primaryId}`;\n link.textContent = this.validator!.messageResolver.getSummaryItem(entry.field, entry.message);\n const field = entry.field;\n link.addEventListener('click', (event) => {\n event.preventDefault();\n field.focus();\n });\n item.append(link);\n }\n this.list!.append(item);\n });\n this.container.hidden = false;\n },\n\n focus(): void {\n if (this.hasErrors() && this.container) {\n this.container.focus({ preventScroll: true });\n this.container.scrollIntoView?.({\n block: 'start',\n behavior: getPreferredScrollBehavior(this.container)\n });\n }\n },\n\n destroy(): void {\n this.unsubscribeAfterValidate?.();\n this.unsubscribeDestroy?.();\n this.container?.remove();\n if (this.validator) {\n this.validator.summaryAddon = null;\n }\n this.container = null;\n this.title = null;\n this.list = null;\n this.validator = null;\n }\n };\n}\n\nexport default createErrorSummaryAddon;\n"],"mappings":";;;AA6BA,SAAgB,wBAAwB,UAAoC,EAAE,EAAqB;AACjG,QAAO;EACL,WAAW;EACX;EACA,WAAW;EACX,OAAO;EACP,MAAM;EAEN,QAAQ,WAA8B;AACpC,QAAK,YAAY;AACjB,QAAK,UAAU;GACf,MAAM,WAAW,UAAU,KAAK;AAChC,QAAK,YAAY,SAAS,cAAc,UAAU;AAClD,QAAK,UAAU,YAAY;AAC3B,QAAK,UAAU,SAAS;AACxB,QAAK,UAAU,WAAW;AAC1B,QAAK,QAAQ,SAAS,cAAc,KAAK;AACzC,QAAK,MAAM,KAAK,QAAQ,WAAW,GAAG,gBAAgB,UAAU,MAAM,2BAA2B,CAAC;AAClG,QAAK,MAAM,YAAY;AACvB,QAAK,UAAU,aAAa,mBAAmB,KAAK,MAAM,GAAG;AAC7D,QAAK,OAAO,SAAS,cAAc,KAAK;AACxC,QAAK,KAAK,YAAY;AACtB,QAAK,UAAU,OAAO,KAAK,OAAO,KAAK,KAAK;AAC5C,aAAU,KAAK,QAAQ,KAAK,UAAU;AACtC,aAAU,eAAe;AAEzB,QAAK,2BAA2B,UAAU,OAAO,GAAG,4CAA4C,KAAK,QAAQ,CAAC;AAC9G,QAAK,qBAAqB,UAAU,OAAO,GAAG,qCAAqC,KAAK,SAAS,CAAC;;EAGpG,YAA4B;AAC1B,OAAI,CAAC,KAAK,UACR,QAAO,EAAE;GAGX,MAAM,cAAc,KAAK,UAAU,OAChC,QAAQ,UAA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QAAK,4BAA4B;AACjC,QAAK,sBAAsB;AAC3B,QAAK,WAAW,QAAQ;AACxB,OAAI,KAAK,UACP,MAAK,UAAU,eAAe;AAEhC,QAAK,YAAY;AACjB,QAAK,QAAQ;AACb,QAAK,OAAO;AACZ,QAAK,YAAY;;EAEpB;;AAGH,4BAAe"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
//#region src/core/helpers.ts
|
|
2
|
+
const RULE_NAME_PATTERN = /([a-z0-9])([A-Z])/g;
|
|
3
|
+
function sanitizeId(value) {
|
|
4
|
+
const input = String(value || "field");
|
|
5
|
+
let output = "";
|
|
6
|
+
let previousWasDash = false;
|
|
7
|
+
for (const character of input) {
|
|
8
|
+
if (character >= "a" && character <= "z" || character >= "A" && character <= "Z" || character >= "0" && character <= "9" || character === "_" || character === "-") {
|
|
9
|
+
output += character;
|
|
10
|
+
previousWasDash = false;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (!previousWasDash) {
|
|
14
|
+
output += "-";
|
|
15
|
+
previousWasDash = true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
while (output.startsWith("-")) output = output.slice(1);
|
|
19
|
+
while (output.endsWith("-")) output = output.slice(0, -1);
|
|
20
|
+
return output || "field";
|
|
21
|
+
}
|
|
22
|
+
function escapeSelectorIdentifier(value) {
|
|
23
|
+
const input = String(value || "");
|
|
24
|
+
if (globalThis.CSS?.escape) return globalThis.CSS.escape(input);
|
|
25
|
+
return input.replace(/[^a-zA-Z0-9_-]/g, (character) => `\\${character}`);
|
|
26
|
+
}
|
|
27
|
+
function ensureElementId(element, prefix = "a11y-form-validator-field") {
|
|
28
|
+
if (element.id) return element.id;
|
|
29
|
+
const rawBase = element.name || element.getAttribute("name") || "";
|
|
30
|
+
const base = rawBase ? sanitizeId(rawBase) : "";
|
|
31
|
+
const root = element.ownerDocument;
|
|
32
|
+
let id = base ? `${prefix}-${base}` : prefix;
|
|
33
|
+
let index = 2;
|
|
34
|
+
while (root.getElementById(id)) {
|
|
35
|
+
id = `${prefix}-${base}-${index}`;
|
|
36
|
+
index += 1;
|
|
37
|
+
}
|
|
38
|
+
element.id = id;
|
|
39
|
+
return id;
|
|
40
|
+
}
|
|
41
|
+
function getPreferredScrollBehavior(element) {
|
|
42
|
+
return (element?.ownerDocument?.defaultView || globalThis).matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
43
|
+
}
|
|
44
|
+
function kebabToCamelCase(value = "") {
|
|
45
|
+
return String(value).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
46
|
+
}
|
|
47
|
+
function camelToKebabCase(value = "") {
|
|
48
|
+
return String(value).replace(RULE_NAME_PATTERN, "$1-$2").toLowerCase();
|
|
49
|
+
}
|
|
50
|
+
function normalizeToArray(value) {
|
|
51
|
+
if (Array.isArray(value)) return value;
|
|
52
|
+
if (value == null || value === false) return [];
|
|
53
|
+
return [value];
|
|
54
|
+
}
|
|
55
|
+
function toSafeInteger(value, fallback, options = {}) {
|
|
56
|
+
const parsed = typeof value === "number" ? value : Number.parseInt(String(value), 10);
|
|
57
|
+
if (!Number.isFinite(parsed)) return fallback;
|
|
58
|
+
if (options.min !== void 0 && parsed < options.min) return fallback;
|
|
59
|
+
if (options.max !== void 0 && parsed > options.max) return fallback;
|
|
60
|
+
return parsed;
|
|
61
|
+
}
|
|
62
|
+
function mergeOptions(defaults, overrides = {}) {
|
|
63
|
+
const output = {
|
|
64
|
+
...defaults,
|
|
65
|
+
...overrides
|
|
66
|
+
};
|
|
67
|
+
output.ignore = {
|
|
68
|
+
...defaults.ignore || {},
|
|
69
|
+
...overrides.ignore || {}
|
|
70
|
+
};
|
|
71
|
+
output.selectors = {
|
|
72
|
+
...defaults.selectors || {},
|
|
73
|
+
...overrides.selectors || {}
|
|
74
|
+
};
|
|
75
|
+
output.messages = overrides?.messages || defaults.messages;
|
|
76
|
+
output.locales = overrides?.locales || defaults.locales;
|
|
77
|
+
output.rules = overrides?.rules || defaults.rules;
|
|
78
|
+
output.addons = normalizeToArray(overrides.addons ?? defaults.addons);
|
|
79
|
+
output.validateOn = normalizeToArray(overrides.validateOn ?? defaults.validateOn);
|
|
80
|
+
output.debounce = Number(overrides.debounce ?? defaults.debounce);
|
|
81
|
+
return output;
|
|
82
|
+
}
|
|
83
|
+
function parseRuleList(value) {
|
|
84
|
+
if (!value) return {};
|
|
85
|
+
if (Array.isArray(value)) return value.reduce((rules, rule) => ({
|
|
86
|
+
...rules,
|
|
87
|
+
...parseRuleList(rule)
|
|
88
|
+
}), {});
|
|
89
|
+
if (typeof value === "object") return { ...value };
|
|
90
|
+
return String(value).split(/\s+/).filter(Boolean).reduce((rules, ruleToken) => {
|
|
91
|
+
const [rawName, rawParam] = ruleToken.split(":");
|
|
92
|
+
const ruleName = kebabToCamelCase(rawName);
|
|
93
|
+
if (!ruleName) return rules;
|
|
94
|
+
if (rawParam == null || rawParam === "") {
|
|
95
|
+
rules[ruleName] = true;
|
|
96
|
+
return rules;
|
|
97
|
+
}
|
|
98
|
+
const numericValue = Number(rawParam);
|
|
99
|
+
rules[ruleName] = Number.isNaN(numericValue) ? rawParam : numericValue;
|
|
100
|
+
return rules;
|
|
101
|
+
}, {});
|
|
102
|
+
}
|
|
103
|
+
function unique(values) {
|
|
104
|
+
return [...new Set(values.filter(Boolean))];
|
|
105
|
+
}
|
|
106
|
+
function isEmptyValue(value) {
|
|
107
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
108
|
+
if (typeof FileList !== "undefined" && value instanceof FileList) return value.length === 0;
|
|
109
|
+
if (value && typeof value === "object" && "length" in value && typeof value.length === "number") return value.length === 0;
|
|
110
|
+
if (typeof value === "boolean") return value === false;
|
|
111
|
+
return String(value ?? "").trim() === "";
|
|
112
|
+
}
|
|
113
|
+
function applyPlaceholders(template, params = {}) {
|
|
114
|
+
const input = String(template);
|
|
115
|
+
let output = "";
|
|
116
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
117
|
+
const character = input[index];
|
|
118
|
+
if (character !== "{") {
|
|
119
|
+
output += character;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const closingIndex = input.indexOf("}", index + 1);
|
|
123
|
+
if (closingIndex === -1) {
|
|
124
|
+
output += character;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const replacement = params[input.slice(index + 1, closingIndex).trim()];
|
|
128
|
+
output += replacement == null ? "" : String(replacement);
|
|
129
|
+
index = closingIndex;
|
|
130
|
+
}
|
|
131
|
+
return output;
|
|
132
|
+
}
|
|
133
|
+
function toRuleOptions(value, key) {
|
|
134
|
+
if (value === true) return {};
|
|
135
|
+
if (value == null || value === false) return {};
|
|
136
|
+
if (typeof value === "object" && !Array.isArray(value)) return value;
|
|
137
|
+
if (typeof value === "number") {
|
|
138
|
+
if (key === "minLength" || key === "min") return { min: value };
|
|
139
|
+
if (key === "maxLength" || key === "max") return { max: value };
|
|
140
|
+
}
|
|
141
|
+
if (typeof value === "string") {
|
|
142
|
+
if (key === "sameAs") return { selector: value };
|
|
143
|
+
if (key === "pattern") return { pattern: value };
|
|
144
|
+
}
|
|
145
|
+
return { value };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//#endregion
|
|
149
|
+
export { getPreferredScrollBehavior as a, normalizeToArray as c, toRuleOptions as d, toSafeInteger as f, escapeSelectorIdentifier as i, parseRuleList as l, camelToKebabCase as n, isEmptyValue as o, unique as p, ensureElementId as r, mergeOptions as s, applyPlaceholders as t, sanitizeId as u };
|
|
150
|
+
//# sourceMappingURL=helpers-c_THOe-Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-c_THOe-Q.js","names":["output: Record<string, unknown>"],"sources":["../src/core/helpers.ts"],"sourcesContent":["const RULE_NAME_PATTERN = /([a-z0-9])([A-Z])/g;\n\nexport type RuleOptions = Record<string, unknown>;\nexport type RuleList = Record<string, true | string | number | RuleOptions>;\n\nexport function sanitizeId(value: unknown): string {\n const input = String(value || 'field');\n let output = '';\n let previousWasDash = false;\n\n for (const character of input) {\n const isSafeCharacter =\n (character >= 'a' && character <= 'z') ||\n (character >= 'A' && character <= 'Z') ||\n (character >= '0' && character <= '9') ||\n character === '_' ||\n character === '-';\n\n if (isSafeCharacter) {\n output += character;\n previousWasDash = false;\n continue;\n }\n\n if (!previousWasDash) {\n output += '-';\n previousWasDash = true;\n }\n }\n\n while (output.startsWith('-')) {\n output = output.slice(1);\n }\n\n while (output.endsWith('-')) {\n output = output.slice(0, -1);\n }\n\n return output || 'field';\n}\n\n\nexport function escapeSelectorIdentifier(value: unknown): string {\n const input = String(value || '');\n if (globalThis.CSS?.escape) {\n return globalThis.CSS.escape(input);\n }\n\n return input.replace(/[^a-zA-Z0-9_-]/g, (character) => `\\\\${character}`);\n}\n\nexport function ensureElementId(element: HTMLElement, prefix = 'a11y-form-validator-field'): string {\n if (element.id) {\n return element.id;\n }\n\n const namedElement = element as HTMLElement & { name?: string };\n const rawBase = namedElement.name || element.getAttribute('name') || '';\n const base = rawBase ? sanitizeId(rawBase) : '';\n const root = element.ownerDocument;\n let id = base ? `${prefix}-${base}` : prefix;\n let index = 2;\n\n while (root.getElementById(id)) {\n id = `${prefix}-${base}-${index}`;\n index += 1;\n }\n\n element.id = id;\n return id;\n}\n\n\nexport function getPreferredScrollBehavior(element: Element): ScrollBehavior {\n const view = element?.ownerDocument?.defaultView || globalThis;\n return view.matchMedia?.('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth';\n}\n\nexport function kebabToCamelCase(value = ''): string {\n return String(value).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport function camelToKebabCase(value = ''): string {\n return String(value).replace(RULE_NAME_PATTERN, '$1-$2').toLowerCase();\n}\n\nexport function normalizeToArray<T>(value: T | T[] | null | undefined | false): T[] {\n if (Array.isArray(value)) {\n return value;\n }\n\n if (value == null || value === false) {\n return [];\n }\n\n return [value];\n}\n\nexport function toSafeBoolean(value: boolean | string | undefined, fallback: boolean): boolean {\n if (value === true || value === 'true') {\n return true;\n }\n\n if (value === false || value === 'false') {\n return false;\n }\n\n return fallback;\n}\n\nexport function toSafeInteger(\n value: number | string | undefined,\n fallback: number,\n options: { min?: number; max?: number } = {}\n): number {\n const parsed = typeof value === 'number' ? value : Number.parseInt(String(value), 10);\n\n if (!Number.isFinite(parsed)) {\n return fallback;\n }\n\n if (options.min !== undefined && parsed < options.min) {\n return fallback;\n }\n\n if (options.max !== undefined && parsed > options.max) {\n return fallback;\n }\n\n return parsed;\n}\n\nexport function toSafeString(value: string | undefined, fallback: string): string {\n const normalized = String(value ?? '').trim();\n return normalized.length > 0 ? normalized : fallback;\n}\n\nexport function mergeOptions(\n defaults: Record<string, unknown>,\n overrides: Record<string, unknown> = {}\n): Record<string, unknown> {\n const output: Record<string, unknown> = { ...defaults, ...overrides };\n\n output.ignore = {\n ...((defaults.ignore as Record<string, unknown>) || {}),\n ...((overrides.ignore as Record<string, unknown>) || {})\n };\n\n output.selectors = {\n ...((defaults.selectors as Record<string, unknown>) || {}),\n ...((overrides.selectors as Record<string, unknown>) || {})\n };\n\n output.messages = overrides?.messages || defaults.messages;\n output.locales = overrides?.locales || defaults.locales;\n output.rules = overrides?.rules || defaults.rules;\n output.addons = normalizeToArray(overrides.addons ?? defaults.addons);\n output.validateOn = normalizeToArray(overrides.validateOn ?? defaults.validateOn);\n output.debounce = Number(overrides.debounce ?? defaults.debounce);\n\n return output;\n}\n\nexport function parseRuleList(value: unknown): RuleList {\n if (!value) {\n return {};\n }\n\n if (Array.isArray(value)) {\n return value.reduce<RuleList>((rules, rule) => ({ ...rules, ...parseRuleList(rule) }), {});\n }\n\n if (typeof value === 'object') {\n return { ...(value as RuleList) };\n }\n\n return String(value)\n .split(/\\s+/)\n .filter(Boolean)\n .reduce<RuleList>((rules, ruleToken) => {\n const [rawName, rawParam] = ruleToken.split(':');\n const ruleName = kebabToCamelCase(rawName);\n if (!ruleName) {\n return rules;\n }\n\n if (rawParam == null || rawParam === '') {\n rules[ruleName] = true;\n return rules;\n }\n\n const numericValue = Number(rawParam);\n rules[ruleName] = Number.isNaN(numericValue) ? rawParam : numericValue;\n return rules;\n }, {});\n}\n\nexport function unique(values: string[]): string[] {\n return [...new Set(values.filter(Boolean))];\n}\n\nexport function isEmptyValue(value: unknown): boolean {\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (typeof FileList !== 'undefined' && value instanceof FileList) {\n return value.length === 0;\n }\n\n if (value && typeof value === 'object' && 'length' in value && typeof value.length === 'number') {\n return value.length === 0;\n }\n\n if (typeof value === 'boolean') {\n return value === false;\n }\n\n return String(value ?? '').trim() === '';\n}\n\nexport function applyPlaceholders(template: string, params: Record<string, unknown> = {}): string {\n const input = String(template);\n let output = '';\n\n for (let index = 0; index < input.length; index += 1) {\n const character = input[index];\n if (character !== '{') {\n output += character;\n continue;\n }\n\n const closingIndex = input.indexOf('}', index + 1);\n if (closingIndex === -1) {\n output += character;\n continue;\n }\n\n const key = input.slice(index + 1, closingIndex).trim();\n const replacement = params[key];\n output += replacement == null ? '' : String(replacement);\n index = closingIndex;\n }\n\n return output;\n}\n\nexport function toRuleOptions(value: unknown, key: string): RuleOptions {\n if (value === true) {\n return {};\n }\n\n if (value == null || value === false) {\n return {};\n }\n\n if (typeof value === 'object' && !Array.isArray(value)) {\n return value as RuleOptions;\n }\n\n if (typeof value === 'number') {\n if (key === 'minLength' || key === 'min') {\n return { min: value };\n }\n\n if (key === 'maxLength' || key === 'max') {\n return { max: value };\n }\n }\n\n if (typeof value === 'string') {\n if (key === 'sameAs') {\n return { selector: value };\n }\n\n if (key === 'pattern') {\n return { pattern: value };\n }\n }\n\n return { value };\n}\n"],"mappings":";AAAA,MAAM,oBAAoB;AAK1B,SAAgB,WAAW,OAAwB;CACjD,MAAM,QAAQ,OAAO,SAAS,QAAQ;CACtC,IAAI,SAAS;CACb,IAAI,kBAAkB;AAEtB,MAAK,MAAM,aAAa,OAAO;AAQ7B,MANG,aAAa,OAAO,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AQ;;AAGV,QAAO;;AAGT,SAAgB,cAAc,OAAgB,KAA0B;AACtE,KAAI,UAAU,KACZ,QAAO,EAAE;AAGX,KAAI,SAAS,QAAQ,UAAU,MAC7B,QAAO,EAAE;AAGX,KAAI,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,CACpD,QAAO;AAGT,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,QAAQ,eAAe,QAAQ,MACjC,QAAO,EAAE,KAAK,OAAO;AAGvB,MAAI,QAAQ,eAAe,QAAQ,MACjC,QAAO,EAAE,KAAK,OAAO;;AAIzB,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,QAAQ,SACV,QAAO,EAAE,UAAU,OAAO;AAG5B,MAAI,QAAQ,UACV,QAAO,EAAE,SAAS,OAAO;;AAI7B,QAAO,EAAE,OAAO"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { A as initFormValidators, B as EventEmitter, C as ValidatorAddon, D as ValidatorRule, E as ValidatorRenderer, F as RuleRegistry, I as MessageResolver, L as FieldController, M as FormValidationState, N as ValidationState, O as ValidatorRuleResult, P as ValidationStateSnapshot, R as FieldType, S as ValidationResult, T as ValidatorMessages, _ as SELECTORS, a as ATTRIBUTES, b as ValidateTrigger, c as DEFAULT_OPTIONS, d as FieldInput, f as FieldValue, g as MessageValue, h as MessageResolverContext, i as A11yFormValidatorOptionsInput, j as FieldValidationState, k as createFormValidator, l as EVENTS, m as LocaleMessages, n as A11yFormValidatorInstance, o as AddonInput, p as FocusOnError, r as A11yFormValidatorOptions, s as CLASSES, t as A11yFormValidator, u as ErrorMode, v as ServerErrors, w as ValidatorErrors, x as ValidationContext, y as ValidateOptions, z as FormControl } from "./A11yFormValidator-D0n6br-b.js";
|
|
2
|
+
import { t as createDefaultPreset } from "./default-BHBWPNeK.js";
|
|
3
|
+
import { t as createNoSummaryPreset } from "./no-summary-BI1pTld5.js";
|
|
4
|
+
import { t as createMinimalPreset } from "./minimal-40_EIW9U.js";
|
|
5
|
+
|
|
6
|
+
//#region src/core/ErrorRenderer.d.ts
|
|
7
|
+
declare class ErrorRenderer implements ValidatorRenderer {
|
|
8
|
+
readonly validator: A11yFormValidator;
|
|
9
|
+
constructor(validator: A11yFormValidator);
|
|
10
|
+
getNode(field: FieldController): HTMLElement | null;
|
|
11
|
+
shouldRenderInline(): boolean;
|
|
12
|
+
syncAnnouncementAttributes(errorNode: HTMLElement): void;
|
|
13
|
+
setNativeMessage(field: FieldController, message: string): void;
|
|
14
|
+
getInsertionTarget(field: FieldController): Element;
|
|
15
|
+
render(field: FieldController, message: string): void;
|
|
16
|
+
clear(field: FieldController): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/locales/en.d.ts
|
|
21
|
+
declare let required: string;
|
|
22
|
+
declare let email: string;
|
|
23
|
+
declare let minLength: string;
|
|
24
|
+
declare let maxLength: string;
|
|
25
|
+
declare let pattern: string;
|
|
26
|
+
declare let checked: string;
|
|
27
|
+
declare let sameAs: string;
|
|
28
|
+
declare let summaryTitleOne: string;
|
|
29
|
+
declare let summaryTitleOther: string;
|
|
30
|
+
declare let summaryItem: string;
|
|
31
|
+
declare let genericFallback: string;
|
|
32
|
+
declare namespace __json_default_export {
|
|
33
|
+
export { required, email, minLength, maxLength, pattern, checked, sameAs, summaryTitleOne, summaryTitleOther, summaryItem, genericFallback };
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { A11yFormValidator, type A11yFormValidatorInstance, type A11yFormValidatorOptions, type A11yFormValidatorOptionsInput, ATTRIBUTES, type AddonInput, CLASSES, DEFAULT_OPTIONS, EVENTS, type ErrorMode, ErrorRenderer, EventEmitter, FieldController, type FieldInput, type FieldType, type FieldValidationState, type FieldValue, type FocusOnError, type FormControl, type FormValidationState, type LocaleMessages, MessageResolver, type MessageResolverContext, type MessageValue, RuleRegistry, SELECTORS, type ServerErrors, type ValidateOptions, type ValidateTrigger, type ValidationContext, type ValidationResult, ValidationState, type ValidationStateSnapshot, type ValidatorAddon, type ValidatorErrors, type ValidatorMessages, type ValidatorRenderer, type ValidatorRule, type ValidatorRuleResult, createDefaultPreset, createFormValidator, createMinimalPreset, createNoSummaryPreset, __json_default_export as enMessages, initFormValidators };
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["required","email","minLength","maxLength","pattern","checked","sameAs","summaryTitleOne","summaryTitleOther","summaryItem","genericFallback","__json_default_export","default"],"sources":["../src/core/ErrorRenderer.ts","../src/locales/en.d.ts"],"sourcesContent":["export let required: string;\nexport let email: string;\nexport let minLength: string;\nexport let maxLength: string;\nexport let pattern: string;\nexport let checked: string;\nexport let sameAs: string;\nexport let summaryTitleOne: string;\nexport let summaryTitleOther: string;\nexport let summaryItem: string;\nexport let genericFallback: string;\n\ndeclare namespace __json_default_export {\n export { required, email, minLength, maxLength, pattern, checked, sameAs, summaryTitleOne, summaryTitleOther, summaryItem, genericFallback }\n}\nexport { __json_default_export as default }"],"mappings":";;;;;;cAGa,aAAA,YAAyB;sBAChB;yBAEG;iBAIR,kBAAkB;EAPtB,kBAAc,CAAA,CAAA,EAAA,OAAA;EACL,0BAAA,CAAA,SAAA,EAckB,WAdlB,CAAA,EAAA,IAAA;EAEG,gBAAA,CAAA,KAAA,EAyBC,eAzBD,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAIR,kBAAA,CAAA,KAAA,EA2BW,eA3BX,CAAA,EA2B6B,OA3B7B;EAAkB,MAAA,CAAA,KAAA,EA2CnB,eA3CmB,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAQK,KAAA,CAAA,KAAA,EA8DzB,eA9DyB,CAAA,EAAA,IAAA;EAad,OAAA,CAAA,CAAA,EAAA,IAAA;;;;YC/BfA;YACAC;YACAC;YACAC;YACAC;YACAC;ADFE,YCGFC,MDHE,EAAA,MAAc;AACL,YCGXC,eDHW,EAAA,MAAA;AAEG,YCEdC,iBDFc,EAAA,MAAA;AAIR,YCDNC,WDCM,EAAA,MAAA;AAAkB,YCAxBC,eDAwB,EAAA,MAAA;kBCEjBC,qBAAAA,CDmBQ;EAME,SCxBjBX,QDwBiB,ECxBPC,KDwBO,ECxBAC,SDwBA,ECxBWC,SDwBX,ECxBsBC,ODwBtB,ECxB+BC,ODwB/B,ECxBwCC,MDwBxC,ECxBgDC,eDwBhD,ECxBiEC,iBDwBjE,ECxBoFC,WDwBpF,ECxBiGC,eDwBjG"}
|