@creative-web-solution/front-library 7.1.42 → 7.1.44
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/SkinSelect.ts +13 -11
- package/Modules/Validator/MaxFileSize.ts +30 -0
- package/README.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/Modules/SkinSelect.ts
CHANGED
|
@@ -116,6 +116,7 @@ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
|
116
116
|
|
|
117
117
|
on( this.#$parent, {
|
|
118
118
|
"eventsName": "click",
|
|
119
|
+
"selector": `.${ this.#options.itemClassName }`,
|
|
119
120
|
"callback": this.#fakeOptionsClickHandler
|
|
120
121
|
} );
|
|
121
122
|
|
|
@@ -461,6 +462,7 @@ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
|
461
462
|
if ( !$target.matches( '.' + this.#options.itemClassName ) ) {
|
|
462
463
|
return;
|
|
463
464
|
}
|
|
465
|
+
|
|
464
466
|
this.selectByOption( $target );
|
|
465
467
|
}
|
|
466
468
|
|
|
@@ -517,11 +519,11 @@ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
|
517
519
|
|
|
518
520
|
|
|
519
521
|
#onKeydown = ( e: KeyboardEvent ): void => {
|
|
520
|
-
switch ( e.
|
|
521
|
-
case
|
|
522
|
-
case
|
|
523
|
-
case
|
|
524
|
-
case
|
|
522
|
+
switch ( e.key ) {
|
|
523
|
+
case "ArrowUp":
|
|
524
|
+
case "ArrowDown":
|
|
525
|
+
case "Enter":
|
|
526
|
+
case "Escape":
|
|
525
527
|
e.preventDefault();
|
|
526
528
|
break;
|
|
527
529
|
}
|
|
@@ -529,11 +531,11 @@ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
|
529
531
|
|
|
530
532
|
|
|
531
533
|
#onKeyup = ( e: KeyboardEvent ): void => {
|
|
532
|
-
switch ( e.
|
|
533
|
-
case
|
|
534
|
+
switch ( e.key ) {
|
|
535
|
+
case "ArrowUp":
|
|
534
536
|
this.#focusItem( this.#focusedItemIndex - 1 );
|
|
535
537
|
break;
|
|
536
|
-
case
|
|
538
|
+
case "ArrowDown":
|
|
537
539
|
if ( !this.#isListOpened ) {
|
|
538
540
|
this.#openList();
|
|
539
541
|
break;
|
|
@@ -541,8 +543,8 @@ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
|
541
543
|
this.#focusItem( this.#focusedItemIndex + 1 );
|
|
542
544
|
break;
|
|
543
545
|
|
|
544
|
-
case
|
|
545
|
-
case
|
|
546
|
+
case "Enter":
|
|
547
|
+
case " ":
|
|
546
548
|
if ( !this.#isListOpened ) {
|
|
547
549
|
this.#openList();
|
|
548
550
|
break;
|
|
@@ -551,7 +553,7 @@ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
|
551
553
|
this.#closeList();
|
|
552
554
|
break;
|
|
553
555
|
|
|
554
|
-
case
|
|
556
|
+
case "Escape":
|
|
555
557
|
this.#closeList();
|
|
556
558
|
break;
|
|
557
559
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { addValidator } from './index';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* File size validation
|
|
5
|
+
*/
|
|
6
|
+
addValidator( 'maxfilesize', '[data-max-file-size]', ( $input, value, isLiveValidation ) => {
|
|
7
|
+
if (!($input as HTMLInputElement).files?.length) {
|
|
8
|
+
return Promise.resolve({
|
|
9
|
+
$input,
|
|
10
|
+
value,
|
|
11
|
+
"isValid": true,
|
|
12
|
+
"label": "maxfilesize",
|
|
13
|
+
isLiveValidation
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const size = ($input as HTMLInputElement).files![0].size;
|
|
18
|
+
const maxSize = Number($input.getAttribute('data-max-file-size') ?? "0");
|
|
19
|
+
console.log({size, maxSize})
|
|
20
|
+
return Promise.resolve({
|
|
21
|
+
$input,
|
|
22
|
+
value,
|
|
23
|
+
"isValid": ($input as HTMLInputElement).files?.length === 0 ||
|
|
24
|
+
size <= 0 ||
|
|
25
|
+
maxSize <= 0 ||
|
|
26
|
+
size <= maxSize,
|
|
27
|
+
"label": "maxfilesize",
|
|
28
|
+
isLiveValidation
|
|
29
|
+
});
|
|
30
|
+
} );
|
package/README.md
CHANGED
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.44",
|
|
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": [],
|