@creative-web-solution/front-library 7.1.40 → 7.1.42
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 +8 -0
- package/Modules/Popin/Popin.ts +4 -4
- package/Modules/Validator/Internal/Input.ts +3 -1
- package/Modules/Validator/index.ts +1 -0
- package/README.md +1 -1
- package/Types/Popin.d.ts +4 -4
- package/Types/Validator.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 7.1.42
|
|
4
|
+
|
|
5
|
+
* [Popin]: Add popin element in callback function param
|
|
6
|
+
|
|
7
|
+
## 7.1.41
|
|
8
|
+
|
|
9
|
+
* [Validator]: Add feature to cancel validation on a field. Do not validate a disabled field.
|
|
10
|
+
|
|
3
11
|
## 7.1.40
|
|
4
12
|
|
|
5
13
|
* [Slider]: Improve auto slide function
|
package/Modules/Popin/Popin.ts
CHANGED
|
@@ -342,7 +342,7 @@ export default class Popin {
|
|
|
342
342
|
data => {
|
|
343
343
|
const [ body, response ] = data;
|
|
344
344
|
const isHttpError = response.status < 200 || response.status >= 300;
|
|
345
|
-
const normResponse = this.#options.normalize( body, response, isHttpError );
|
|
345
|
+
const normResponse = this.#options.normalize( body, response, isHttpError, this.#$popin );
|
|
346
346
|
|
|
347
347
|
if ( normResponse.success ) {
|
|
348
348
|
this.#setPopin( normResponse.data ).then( () => {
|
|
@@ -378,7 +378,7 @@ export default class Popin {
|
|
|
378
378
|
#_loadLink = ( $link: HTMLAnchorElement ): Promise<void> => {
|
|
379
379
|
return this.#_load(
|
|
380
380
|
$link.href,
|
|
381
|
-
this.#options.setLinkResponseType( $link.href, $link ),
|
|
381
|
+
this.#options.setLinkResponseType( $link.href, $link, this.#$popin ),
|
|
382
382
|
);
|
|
383
383
|
}
|
|
384
384
|
|
|
@@ -387,7 +387,7 @@ export default class Popin {
|
|
|
387
387
|
let validationResult;
|
|
388
388
|
|
|
389
389
|
if ( this.#options.checkValidity ) {
|
|
390
|
-
validationResult = this.#options.checkValidity( $form );
|
|
390
|
+
validationResult = this.#options.checkValidity( $form, this.#$popin );
|
|
391
391
|
if ( validationResult === false ) {
|
|
392
392
|
return Promise.reject();
|
|
393
393
|
}
|
|
@@ -400,7 +400,7 @@ export default class Popin {
|
|
|
400
400
|
.then( () => {
|
|
401
401
|
return this.#_load(
|
|
402
402
|
$form.action,
|
|
403
|
-
this.#options.setFormResponseType( $form ),
|
|
403
|
+
this.#options.setFormResponseType( $form, this.#$popin ),
|
|
404
404
|
{
|
|
405
405
|
"body": new FormData( $form ),
|
|
406
406
|
"method": $form.method || 'POST'
|
|
@@ -159,8 +159,10 @@ export default class Input implements FLib.Validator.Input {
|
|
|
159
159
|
this.#hasError = false;
|
|
160
160
|
this.#isLiveValidation = isLiveValidation;
|
|
161
161
|
|
|
162
|
+
const mustCancelValidation = (this.#$input as HTMLInputElement).disabled || this.#$input.hasAttribute(this.#options.cancelFieldValidationAttribute) || this.#$input.closest(`[${ this.#options.cancelFieldValidationAttribute }]`);
|
|
163
|
+
|
|
162
164
|
// This input has no (known) validation
|
|
163
|
-
if ( !this.#hasValidator ) {
|
|
165
|
+
if ( !this.#hasValidator || mustCancelValidation ) {
|
|
164
166
|
return Promise.resolve();
|
|
165
167
|
}
|
|
166
168
|
|
package/README.md
CHANGED
package/Types/Popin.d.ts
CHANGED
|
@@ -83,13 +83,13 @@ declare namespace FLib {
|
|
|
83
83
|
onClose?: ( $popin: HTMLElement ) => void;
|
|
84
84
|
onLoad: ( $popin: HTMLElement ) => Promise<void>;
|
|
85
85
|
/** @defaultValue `() => 'text'` */
|
|
86
|
-
setLinkResponseType: ( url: string, $link: HTMLAnchorElement ) => ResponseType;
|
|
86
|
+
setLinkResponseType: ( url: string, $link: HTMLAnchorElement, $popin: HTMLElement ) => ResponseType;
|
|
87
87
|
/** @defaultValue `() => 'text'` */
|
|
88
|
-
setFormResponseType: ( $form: HTMLElement ) => ResponseType;
|
|
88
|
+
setFormResponseType: ( $form: HTMLElement, $popin: HTMLElement ) => ResponseType;
|
|
89
89
|
/** @defaultValue `() => true` */
|
|
90
|
-
checkValidity: ( $form: HTMLElement ) => boolean | Promise<void>;
|
|
90
|
+
checkValidity: ( $form: HTMLElement, $popin: HTMLElement ) => boolean | Promise<void>;
|
|
91
91
|
/** @defaultValue `(body) => { return { success: true, data: body }` */
|
|
92
|
-
normalize: ( body, response, isHttpError: boolean ) => { success: boolean, data };
|
|
92
|
+
normalize: ( body, response, isHttpError: boolean, $popin: HTMLElement ) => { success: boolean, data };
|
|
93
93
|
/**
|
|
94
94
|
* If false, ajax http error (404, 500, ...) should be handled in the normalize function
|
|
95
95
|
* @defaultValue true
|
package/Types/Validator.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ declare namespace FLib {
|
|
|
69
69
|
filter: string;
|
|
70
70
|
/** @defaultValue data-error-label */
|
|
71
71
|
customErrorLabelPrefix: string;
|
|
72
|
+
/** @defaultValue data-cancel-validation */
|
|
73
|
+
cancelFieldValidationAttribute: string;
|
|
72
74
|
/** @defaultValue `{}` */
|
|
73
75
|
errorMessages: { [ key: string ]: string };
|
|
74
76
|
validatorsOptions?: { [ key: string ]: any };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@creative-web-solution/front-library",
|
|
3
3
|
"title": "Frontend library",
|
|
4
4
|
"description": "Frontend functions and modules",
|
|
5
|
-
"version": "7.1.
|
|
5
|
+
"version": "7.1.42",
|
|
6
6
|
"homepage": "https://github.com/creative-web-solution/front-library",
|
|
7
7
|
"author": "Creative Web Solution <contact@cws-studio.com> (https://www.cws-studio.com)",
|
|
8
8
|
"keywords": [],
|