foorm 0.0.2-alpha.6 → 0.0.2-alpha.8
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.cjs +4 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +4 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -47,7 +47,7 @@ class Foorm {
|
|
|
47
47
|
title: (_a = this.title) !== null && _a !== void 0 ? _a : '',
|
|
48
48
|
submit: (_b = this.submit) !== null && _b !== void 0 ? _b : { text: 'Submit' },
|
|
49
49
|
context: replaceContext || this.context,
|
|
50
|
-
entries: this.entries.map((e) => (Object.assign(Object.assign({},
|
|
50
|
+
entries: this.entries.map((e) => (Object.assign(Object.assign({}, e), { validators: (e.validators || []).filter((v) => isFtring(v)) }))),
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
normalizeEntry(e) {
|
|
@@ -85,6 +85,9 @@ class Foorm {
|
|
|
85
85
|
validators.unshift(this.fns.getFn('entry.optional || !!v || "Required"'));
|
|
86
86
|
return validators;
|
|
87
87
|
}
|
|
88
|
+
supportsAltAction(altAction) {
|
|
89
|
+
return !!this.entries.find(e => e.altAction === altAction);
|
|
90
|
+
}
|
|
88
91
|
getFormValidator() {
|
|
89
92
|
if (!this.fns)
|
|
90
93
|
this.fns = new ftring$1.FtringsPool();
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ type TFoormFn<T = string, R = string | boolean> = (ctx: TFoormFnScope<T>) => R;
|
|
|
21
21
|
type TRelevantFields = 'field' | 'type' | 'component' | 'name' | 'attrs' | 'length';
|
|
22
22
|
interface TFoormEntry<T = string, O = string, SFTR = TFtring, BFTR = TFtring, FNFTR = TFtring> {
|
|
23
23
|
field: string;
|
|
24
|
+
altAction?: string;
|
|
24
25
|
label?: string | SFTR;
|
|
25
26
|
description?: string | SFTR;
|
|
26
27
|
hint?: string | SFTR;
|
|
@@ -97,13 +98,12 @@ declare class Foorm {
|
|
|
97
98
|
entries: TFoormEntryExecutable[];
|
|
98
99
|
};
|
|
99
100
|
prepareValidators(_validators: TFoormEntry['validators']): TFoormValidatorFn<string>[];
|
|
101
|
+
supportsAltAction(altAction: string): boolean;
|
|
100
102
|
getFormValidator(): (inputs: Record<string, unknown>) => {
|
|
101
103
|
passed: boolean;
|
|
102
104
|
errors: Record<string, string>;
|
|
103
105
|
};
|
|
104
106
|
}
|
|
105
|
-
type TFoormExecutableMeta = ReturnType<Foorm['executable']>;
|
|
106
|
-
type TFoormExecutableEntry = TFoormExecutableMeta['entries'][number];
|
|
107
107
|
declare function validate<T = string>(opts: TFoormFnScope<T> & {
|
|
108
108
|
validators: TFoormValidatorFn<T>[];
|
|
109
109
|
}): {
|
|
@@ -117,4 +117,4 @@ declare function validate<T = string>(opts: TFoormFnScope<T> & {
|
|
|
117
117
|
declare function isFtring(input: unknown): input is TFtring;
|
|
118
118
|
declare function ftring(strings: TemplateStringsArray, __type__?: TFtring['__type__']): TFtring;
|
|
119
119
|
|
|
120
|
-
export { Foorm, type ObjSOF, type StringOrFtring, type TFoormEntry, type TFoormEntryExecutable, type
|
|
120
|
+
export { Foorm, type ObjSOF, type StringOrFtring, type TFoormEntry, type TFoormEntryExecutable, type TFoormFn, type TFoormFnScope, type TFoormOptions, type TFoormSubmit, type TFoormValidatorFn, type TFtring, ftring, isFtring, validate };
|
package/dist/index.mjs
CHANGED
|
@@ -45,7 +45,7 @@ class Foorm {
|
|
|
45
45
|
title: (_a = this.title) !== null && _a !== void 0 ? _a : '',
|
|
46
46
|
submit: (_b = this.submit) !== null && _b !== void 0 ? _b : { text: 'Submit' },
|
|
47
47
|
context: replaceContext || this.context,
|
|
48
|
-
entries: this.entries.map((e) => (Object.assign(Object.assign({},
|
|
48
|
+
entries: this.entries.map((e) => (Object.assign(Object.assign({}, e), { validators: (e.validators || []).filter((v) => isFtring(v)) }))),
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
normalizeEntry(e) {
|
|
@@ -83,6 +83,9 @@ class Foorm {
|
|
|
83
83
|
validators.unshift(this.fns.getFn('entry.optional || !!v || "Required"'));
|
|
84
84
|
return validators;
|
|
85
85
|
}
|
|
86
|
+
supportsAltAction(altAction) {
|
|
87
|
+
return !!this.entries.find(e => e.altAction === altAction);
|
|
88
|
+
}
|
|
86
89
|
getFormValidator() {
|
|
87
90
|
if (!this.fns)
|
|
88
91
|
this.fns = new FtringsPool();
|