@ziadshalaby/ngx-zs-component 3.1.2 → 3.1.3
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.
|
@@ -1264,13 +1264,15 @@ class Form {
|
|
|
1264
1264
|
// ==============================================
|
|
1265
1265
|
// Form State & Validation
|
|
1266
1266
|
// ==============================================
|
|
1267
|
-
allFilled(
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1267
|
+
allFilled() {
|
|
1268
|
+
const result = {};
|
|
1269
|
+
for (const key in this.fields) {
|
|
1270
|
+
if (this.fields.hasOwnProperty(key)) {
|
|
1271
|
+
const val = this.fields[key]().value;
|
|
1272
|
+
result[key] = val !== null && val !== undefined && val !== '';
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return result;
|
|
1274
1276
|
}
|
|
1275
1277
|
markAllTouched() {
|
|
1276
1278
|
this.touched.set(true);
|
|
@@ -1296,10 +1298,26 @@ class Form {
|
|
|
1296
1298
|
}
|
|
1297
1299
|
return result;
|
|
1298
1300
|
}
|
|
1299
|
-
submit(callback, allowEmptyFields = []) {
|
|
1301
|
+
submit(callback, allowEmptyFields = [], allowInvalidFields = []) {
|
|
1300
1302
|
this.markAllTouched();
|
|
1301
|
-
const
|
|
1302
|
-
const
|
|
1303
|
+
const filled = this.allFilled();
|
|
1304
|
+
const validations = this.getValidations();
|
|
1305
|
+
// =============================
|
|
1306
|
+
// Check FILL
|
|
1307
|
+
// =============================
|
|
1308
|
+
const allFilled = Object.keys(filled).every((key) => {
|
|
1309
|
+
if (allowEmptyFields.includes(key))
|
|
1310
|
+
return true;
|
|
1311
|
+
return filled[key];
|
|
1312
|
+
});
|
|
1313
|
+
// =============================
|
|
1314
|
+
// Check VALID
|
|
1315
|
+
// =============================
|
|
1316
|
+
const allValid = Object.keys(validations).every((key) => {
|
|
1317
|
+
if (allowInvalidFields.includes(key))
|
|
1318
|
+
return true;
|
|
1319
|
+
return validations[key];
|
|
1320
|
+
});
|
|
1303
1321
|
if (!allFilled || !allValid)
|
|
1304
1322
|
return;
|
|
1305
1323
|
callback(this.getValues());
|
|
@@ -2028,11 +2046,11 @@ class Label {
|
|
|
2028
2046
|
return sizes[this.size()];
|
|
2029
2047
|
}, ...(ngDevMode ? [{ debugName: "sizeClasses" }] : []));
|
|
2030
2048
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: Label, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2031
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: Label, isStandalone: true, selector: "ZS-label", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, hintId: { classPropertyName: "hintId", publicName: "hintId", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, for: { classPropertyName: "for", publicName: "for", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<!-- ================= Label Wrapper ================= -->\n@if (label() || hint()) {\n <label \n [for]=\"for()\" \n class=\"zs:flex zs:
|
|
2049
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: Label, isStandalone: true, selector: "ZS-label", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, hintId: { classPropertyName: "hintId", publicName: "hintId", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, for: { classPropertyName: "for", publicName: "for", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<!-- ================= Label Wrapper ================= -->\n@if (label() || hint()) {\n <label \n [for]=\"for()\" \n class=\"zs:flex zs:items-center zs:flex-wrap\"\n >\n <!-- ========== Label Text ========== -->\n @if (label()) {\n <span class=\"zs:font-semibold\" \n [ngClass]=\"[\n sizeClasses().label,\n hint() ? 'zs:mr-1.5' : ''\n ]\">\n {{ label() }}\n\n <!-- Required Indicator -->\n @if (true) {\n <span class=\"zs:text-red-500 zs:ml-1\" aria-hidden=\"true\">*</span>\n <span class=\"sr-only\">(required)</span>\n }\n </span>\n }\n\n <!-- ========== Hint Text ========== -->\n @if (hint()) {\n <small\n [id]=\"hintId()\"\n class=\"zs:text-slate-500 zs:dark:text-slate-400\" \n [ngClass]=\"sizeClasses().hint\"\n >\n {{ hint() }}\n </small>\n }\n <!-- ========== End Hint Text ========== -->\n </label>\n}\n<!-- ================= End Label Wrapper ================= -->", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
2032
2050
|
}
|
|
2033
2051
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: Label, decorators: [{
|
|
2034
2052
|
type: Component,
|
|
2035
|
-
args: [{ selector: 'ZS-label', imports: [CommonModule], template: "<!-- ================= Label Wrapper ================= -->\n@if (label() || hint()) {\n <label \n [for]=\"for()\" \n class=\"zs:flex zs:
|
|
2053
|
+
args: [{ selector: 'ZS-label', imports: [CommonModule], template: "<!-- ================= Label Wrapper ================= -->\n@if (label() || hint()) {\n <label \n [for]=\"for()\" \n class=\"zs:flex zs:items-center zs:flex-wrap\"\n >\n <!-- ========== Label Text ========== -->\n @if (label()) {\n <span class=\"zs:font-semibold\" \n [ngClass]=\"[\n sizeClasses().label,\n hint() ? 'zs:mr-1.5' : ''\n ]\">\n {{ label() }}\n\n <!-- Required Indicator -->\n @if (true) {\n <span class=\"zs:text-red-500 zs:ml-1\" aria-hidden=\"true\">*</span>\n <span class=\"sr-only\">(required)</span>\n }\n </span>\n }\n\n <!-- ========== Hint Text ========== -->\n @if (hint()) {\n <small\n [id]=\"hintId()\"\n class=\"zs:text-slate-500 zs:dark:text-slate-400\" \n [ngClass]=\"sizeClasses().hint\"\n >\n {{ hint() }}\n </small>\n }\n <!-- ========== End Hint Text ========== -->\n </label>\n}\n<!-- ================= End Label Wrapper ================= -->", styles: [":host{display:block}\n"] }]
|
|
2036
2054
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], hintId: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintId", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], for: [{ type: i0.Input, args: [{ isSignal: true, alias: "for", required: false }] }] } });
|
|
2037
2055
|
|
|
2038
2056
|
// ==============================================
|