@ziadshalaby/ngx-zs-component 3.1.1 → 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,12 +1264,16 @@ class Form {
|
|
|
1264
1264
|
// ==============================================
|
|
1265
1265
|
// Form State & Validation
|
|
1266
1266
|
// ==============================================
|
|
1267
|
-
allFilled
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
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;
|
|
1276
|
+
}
|
|
1273
1277
|
markAllTouched() {
|
|
1274
1278
|
this.touched.set(true);
|
|
1275
1279
|
}
|
|
@@ -1294,12 +1298,27 @@ class Form {
|
|
|
1294
1298
|
}
|
|
1295
1299
|
return result;
|
|
1296
1300
|
}
|
|
1297
|
-
submit(callback,
|
|
1301
|
+
submit(callback, allowEmptyFields = [], allowInvalidFields = []) {
|
|
1298
1302
|
this.markAllTouched();
|
|
1299
|
-
const
|
|
1303
|
+
const filled = this.allFilled();
|
|
1300
1304
|
const validations = this.getValidations();
|
|
1301
|
-
|
|
1302
|
-
|
|
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
|
+
});
|
|
1321
|
+
if (!allFilled || !allValid)
|
|
1303
1322
|
return;
|
|
1304
1323
|
callback(this.getValues());
|
|
1305
1324
|
}
|
|
@@ -2027,11 +2046,11 @@ class Label {
|
|
|
2027
2046
|
return sizes[this.size()];
|
|
2028
2047
|
}, ...(ngDevMode ? [{ debugName: "sizeClasses" }] : []));
|
|
2029
2048
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: Label, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2030
|
-
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"] }] });
|
|
2031
2050
|
}
|
|
2032
2051
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: Label, decorators: [{
|
|
2033
2052
|
type: Component,
|
|
2034
|
-
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"] }]
|
|
2035
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 }] }] } });
|
|
2036
2055
|
|
|
2037
2056
|
// ==============================================
|