@t007/input 0.0.20 → 0.0.22
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.d.ts +77 -3
- package/dist/index.global.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,73 +1,147 @@
|
|
|
1
1
|
import "@t007/utils";
|
|
2
2
|
|
|
3
|
+
/** Configuration accepted by the field() helper. */
|
|
3
4
|
export interface FieldOptions extends Partial<
|
|
4
5
|
Omit<HTMLInputElement, "type" | "className" | "children">
|
|
5
6
|
> {
|
|
7
|
+
/** Wrap the field in its own container. */
|
|
6
8
|
isWrapper?: boolean;
|
|
9
|
+
/** Visible label text. */
|
|
7
10
|
label?: string;
|
|
11
|
+
/** Input type to render. */
|
|
8
12
|
type?: string;
|
|
13
|
+
/** Placeholder text. */
|
|
9
14
|
placeholder?: string;
|
|
15
|
+
/** Custom CSS class or class list. */
|
|
10
16
|
custom?: string;
|
|
17
|
+
/** Minimum value length or count. */
|
|
11
18
|
minSize?: number;
|
|
19
|
+
/** Maximum value length or count. */
|
|
12
20
|
maxSize?: number;
|
|
21
|
+
/** Minimum total size allowed across the field value. */
|
|
13
22
|
minTotalSize?: number;
|
|
23
|
+
/** Maximum total size allowed across the field value. */
|
|
14
24
|
maxTotalSize?: number;
|
|
25
|
+
/** Options used by select-like fields. */
|
|
15
26
|
options?: Array<string | { value: string; option: string }>;
|
|
27
|
+
/** Whether the checkbox is partially selected. */
|
|
16
28
|
indeterminate?: boolean;
|
|
29
|
+
/** Show the password visibility toggler. */
|
|
17
30
|
eyeToggler?: boolean;
|
|
31
|
+
/** Enable the password strength meter. */
|
|
18
32
|
passwordMeter?: boolean;
|
|
33
|
+
/** Helper text shown under the field. */
|
|
19
34
|
helperText?: false | Record<string, string>;
|
|
35
|
+
/** Class applied to the root field element. */
|
|
20
36
|
className?: string;
|
|
37
|
+
/** Class applied to the inner field control. */
|
|
21
38
|
fieldClassName?: string;
|
|
39
|
+
/** Optional child element rendered inside the field wrapper. */
|
|
22
40
|
children?: HTMLElement;
|
|
23
|
-
|
|
41
|
+
/** End icon rendered inside the field control. */
|
|
24
42
|
endIcon?: string;
|
|
43
|
+
/** Native icon rendered by the browser control. */
|
|
25
44
|
nativeIcon?: string;
|
|
45
|
+
/** Icon shown when the password is visible. */
|
|
26
46
|
passwordVisibleIcon?: string;
|
|
47
|
+
/** Icon shown when the password is hidden. */
|
|
27
48
|
passwordHiddenIcon?: string;
|
|
28
49
|
}
|
|
29
50
|
|
|
51
|
+
/** Form-level manager used to build and validate inputs. */
|
|
30
52
|
export interface FormManager {
|
|
53
|
+
/** Live collection of managed forms. */
|
|
31
54
|
forms: HTMLCollectionOf<HTMLFormElement>;
|
|
55
|
+
/** Current validation violation keys. */
|
|
32
56
|
violationKeys: string[];
|
|
57
|
+
/** Initialize DOM observers and field bindings. */
|
|
33
58
|
init(): void;
|
|
59
|
+
/** Observe the DOM for field changes. */
|
|
34
60
|
observeDOMForFields(): void;
|
|
61
|
+
/** Normalize and validate uploaded files.
|
|
62
|
+
* @param files Files selected by the user.
|
|
63
|
+
* @param opts Validation options.
|
|
64
|
+
* @returns Violation information and user-facing message.
|
|
65
|
+
*/
|
|
35
66
|
getFilesHelper(
|
|
36
67
|
files: FileList | File[],
|
|
37
68
|
opts: any,
|
|
38
69
|
): { violation: string | null; message: string };
|
|
70
|
+
/** Format a file size for display.
|
|
71
|
+
* @param size Size in bytes.
|
|
72
|
+
* @param decimals Decimal precision.
|
|
73
|
+
* @param base Size base, usually 1000 or 1024.
|
|
74
|
+
* @returns Human-readable size string.
|
|
75
|
+
*/
|
|
39
76
|
formatSize(size: number, decimals?: number, base?: number): string;
|
|
77
|
+
/** Toggle an input between password and text mode.
|
|
78
|
+
* @param input Target password input.
|
|
79
|
+
*/
|
|
40
80
|
togglePasswordType(input: HTMLInputElement): void;
|
|
81
|
+
/** Toggle the filled state on a supported field.
|
|
82
|
+
* @param input Supported form control.
|
|
83
|
+
*/
|
|
41
84
|
toggleFilled(input: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): void;
|
|
85
|
+
/** Attach a fallback helper node.
|
|
86
|
+
* @param field Field wrapper element.
|
|
87
|
+
*/
|
|
42
88
|
setFallbackHelper(field: HTMLElement): void;
|
|
89
|
+
/** Wire listeners onto a managed field.
|
|
90
|
+
* @param field Field wrapper element.
|
|
91
|
+
*/
|
|
43
92
|
setFieldListeners(field: HTMLElement): void;
|
|
93
|
+
/** Normalize field markup before use.
|
|
94
|
+
* @param field Field wrapper element.
|
|
95
|
+
*/
|
|
44
96
|
setUpField(field: HTMLElement): void;
|
|
97
|
+
/** Create a field element from options.
|
|
98
|
+
* @param options Field configuration.
|
|
99
|
+
* @returns Created field element.
|
|
100
|
+
*/
|
|
45
101
|
field(options: FieldOptions): HTMLElement;
|
|
102
|
+
/** Validate a form and attach the proper hooks.
|
|
103
|
+
* @param form Form element to validate.
|
|
104
|
+
*/
|
|
46
105
|
handleFormValidation(form: HTMLFormElement): void;
|
|
47
106
|
}
|
|
48
107
|
|
|
49
108
|
// BUNDLE EXPORTS & GLOBAL DECLARATIONS
|
|
109
|
+
|
|
110
|
+
/** Shared field manager singleton exposed by the bundle. */
|
|
50
111
|
export const formManager: FormManager;
|
|
112
|
+
/** Create a field element from field options.
|
|
113
|
+
* @param options Field configuration.
|
|
114
|
+
* @returns Created field element.
|
|
115
|
+
*/
|
|
51
116
|
export const field = FormManager["field"];
|
|
117
|
+
/** Attach validation hooks to a form element.
|
|
118
|
+
* @param form Form element to validate.
|
|
119
|
+
*/
|
|
52
120
|
export const handleFormValidation = FormManager["handleFormValidation"];
|
|
53
121
|
|
|
54
122
|
declare global {
|
|
55
123
|
interface T007Namespace {
|
|
124
|
+
/** Form manager singleton attached by the bundle. */
|
|
56
125
|
FM: FormManager;
|
|
126
|
+
/** Public form manager singleton. */
|
|
57
127
|
formManager: FormManager;
|
|
128
|
+
/** Public field factory. */
|
|
58
129
|
field?: FormManager["field"];
|
|
130
|
+
/** Public form validation helper. */
|
|
59
131
|
handleFormValidation?: FormManager["handleFormValidation"];
|
|
60
132
|
}
|
|
61
|
-
|
|
62
133
|
interface Window {
|
|
63
134
|
field?: T007Namespace["field"];
|
|
64
135
|
handleFormValidation?: T007Namespace["handleFormValidation"];
|
|
65
136
|
}
|
|
66
|
-
|
|
67
137
|
interface HTMLFormElement {
|
|
138
|
+
/** Client-side submit hook. */
|
|
68
139
|
onSubmit?(): void;
|
|
140
|
+
/** Check validation on the client. */
|
|
69
141
|
validateOnClient?(): boolean;
|
|
142
|
+
/** Check validation on the server. */
|
|
70
143
|
validateOnServer?(): Promise<boolean>;
|
|
144
|
+
/** Toggle the global error state. */
|
|
71
145
|
toggleGlobalError?(bool: boolean): void;
|
|
72
146
|
}
|
|
73
147
|
}
|
package/dist/index.global.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
//
|
|
3
|
+
// ../../node_modules/sia-reactor/dist/chunk-RVYL3OLW.js
|
|
4
4
|
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
5
5
|
return assignEl(el, props, dataset, styles), el;
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/input",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "A lightweight, pure JS input system.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
"monkey-patch"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@t007/utils": "^0.0.
|
|
58
|
+
"@t007/utils": "^0.0.24"
|
|
59
59
|
}
|
|
60
60
|
}
|