jb-select 5.1.0 → 5.3.1
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/README.md +7 -1
- package/dist/jb-select.cjs.js +1 -1
- package/dist/jb-select.cjs.js.br +0 -0
- package/dist/jb-select.cjs.js.gz +0 -0
- package/dist/jb-select.cjs.js.map +1 -1
- package/dist/jb-select.js +1 -1
- package/dist/jb-select.js.br +0 -0
- package/dist/jb-select.js.gz +0 -0
- package/dist/jb-select.js.map +1 -1
- package/dist/jb-select.umd.js +1 -1
- package/dist/jb-select.umd.js.br +0 -0
- package/dist/jb-select.umd.js.gz +0 -0
- package/dist/jb-select.umd.js.map +1 -1
- package/dist/web-component/jb-select/lib/jb-select.d.ts +2 -2
- package/lib/jb-select.ts +17 -13
- package/package.json +3 -3
- package/dist/modules/jb-validation/types.d.ts +0 -1
- package/dist/web-component/jb-form/lib/types.d.ts +0 -28
- package/dist/web-component/jb-form/types.d.ts +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JBSelectCallbacks, JBSelectElements, ValidationValue } from "./types";
|
|
2
|
-
import { ValidationHelper, type WithValidation } from "jb-validation";
|
|
2
|
+
import { ShowValidationErrorInput, ValidationHelper, type WithValidation } from "jb-validation";
|
|
3
3
|
import { JBFormInputStandards } from 'jb-form';
|
|
4
4
|
export declare class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLElement implements WithValidation<ValidationValue<TOption, TValue>>, JBFormInputStandards<TValue> {
|
|
5
5
|
#private;
|
|
@@ -43,7 +43,7 @@ export declare class JBSelectWebComponent<TOption = any, TValue = TOption> exten
|
|
|
43
43
|
* @description show given string as a error in message place
|
|
44
44
|
* @public
|
|
45
45
|
*/
|
|
46
|
-
showValidationError(
|
|
46
|
+
showValidationError(error: ShowValidationErrorInput | string): void;
|
|
47
47
|
clearValidationError(): void;
|
|
48
48
|
/**
|
|
49
49
|
* @public
|
package/lib/jb-select.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
JBSelectOptionElement,
|
|
7
7
|
ValidationValue,
|
|
8
8
|
} from "./types";
|
|
9
|
-
import {ValidationHelper, type ValidationItem, type ValidationResult, type WithValidation} from "jb-validation";
|
|
9
|
+
import {ShowValidationErrorInput, ValidationHelper, type ValidationItem, type ValidationResult, type WithValidation} from "jb-validation";
|
|
10
10
|
import { isMobile } from "../../../common/scripts/device-detection";
|
|
11
11
|
import {JBFormInputStandards} from 'jb-form';
|
|
12
12
|
//TOption is the type of option, TValue is the type of value we extract from option
|
|
@@ -123,7 +123,14 @@ export class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLE
|
|
|
123
123
|
value:this.value
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
#validation = new ValidationHelper<ValidationValue<TOption,TValue>>(
|
|
126
|
+
#validation = new ValidationHelper<ValidationValue<TOption,TValue>>({
|
|
127
|
+
clearValidationError:this.clearValidationError.bind(this),
|
|
128
|
+
showValidationError:this.showValidationError.bind(this),
|
|
129
|
+
getInputtedValue:()=>this.#ValidationValue,
|
|
130
|
+
getInsideValidations:this.#getInsideValidation.bind(this),
|
|
131
|
+
getValueString:()=>this.#textValue,
|
|
132
|
+
setValidationResult:this.#setValidationResult.bind(this)
|
|
133
|
+
});
|
|
127
134
|
get validation(){
|
|
128
135
|
return this.#validation;
|
|
129
136
|
}
|
|
@@ -144,7 +151,7 @@ export class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLE
|
|
|
144
151
|
#required = false;
|
|
145
152
|
set required(value:boolean){
|
|
146
153
|
this.#required = value;
|
|
147
|
-
this.#validation.
|
|
154
|
+
this.#validation.checkValiditySync({showError:false});
|
|
148
155
|
}
|
|
149
156
|
get required() {
|
|
150
157
|
return this.#required;
|
|
@@ -376,7 +383,7 @@ export class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLE
|
|
|
376
383
|
const inputtedText = (e.target as HTMLInputElement).value;
|
|
377
384
|
this.textValue = inputtedText;
|
|
378
385
|
this.#handleSelectedValueDisplay(inputtedText);
|
|
379
|
-
this.#validation.checkValidity(false);
|
|
386
|
+
this.#validation.checkValidity({showError:false});
|
|
380
387
|
this.#dispatchInputEvent(e);
|
|
381
388
|
}
|
|
382
389
|
#dispatchInputEvent(e: InputEvent) {
|
|
@@ -464,7 +471,7 @@ export class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLE
|
|
|
464
471
|
this.textValue = "";
|
|
465
472
|
this.#handleSelectedValueDisplay("");
|
|
466
473
|
this.#hideOptionList();
|
|
467
|
-
this.#validation.checkValidity(true);
|
|
474
|
+
this.#validation.checkValidity({showError:true});
|
|
468
475
|
if (this.isMobileDevice) {
|
|
469
476
|
if (this.value) {
|
|
470
477
|
this.elements.input.placeholder = "";
|
|
@@ -558,11 +565,8 @@ export class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLE
|
|
|
558
565
|
* @description show given string as a error in message place
|
|
559
566
|
* @public
|
|
560
567
|
*/
|
|
561
|
-
showValidationError(
|
|
562
|
-
|
|
563
|
-
// const label = this.getAttribute("label") || "";
|
|
564
|
-
// this.elements.messageBox.innerHTML = `${label} حتما باید انتخاب شود`;
|
|
565
|
-
// }
|
|
568
|
+
showValidationError(error: ShowValidationErrorInput | string) {
|
|
569
|
+
const message = typeof error == "string"?error:error.message;
|
|
566
570
|
this.elements.messageBox.innerHTML = message;
|
|
567
571
|
this.elements.messageBox.classList.add("--error");
|
|
568
572
|
}
|
|
@@ -647,7 +651,7 @@ export class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLE
|
|
|
647
651
|
//
|
|
648
652
|
#checkValidity(showError: boolean) {
|
|
649
653
|
if (!this.isAutoValidationDisabled) {
|
|
650
|
-
return this.#validation.checkValidity(showError);
|
|
654
|
+
return this.#validation.checkValidity({showError});
|
|
651
655
|
}
|
|
652
656
|
}
|
|
653
657
|
/**
|
|
@@ -656,7 +660,7 @@ export class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLE
|
|
|
656
660
|
* this method used by #internal of component
|
|
657
661
|
*/
|
|
658
662
|
checkValidity(): boolean {
|
|
659
|
-
const validationResult = this.#validation.
|
|
663
|
+
const validationResult = this.#validation.checkValiditySync({showError:false});
|
|
660
664
|
if (!validationResult.isAllValid) {
|
|
661
665
|
const event = new CustomEvent('invalid');
|
|
662
666
|
this.dispatchEvent(event);
|
|
@@ -668,7 +672,7 @@ export class JBSelectWebComponent<TOption = any, TValue = TOption> extends HTMLE
|
|
|
668
672
|
* @description this method used to check for validity and show error to user
|
|
669
673
|
*/
|
|
670
674
|
reportValidity(): boolean {
|
|
671
|
-
const validationResult = this.#validation.
|
|
675
|
+
const validationResult = this.#validation.checkValiditySync({showError:true});
|
|
672
676
|
if (!validationResult.isAllValid) {
|
|
673
677
|
const event = new CustomEvent('invalid');
|
|
674
678
|
this.dispatchEvent(event);
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"select",
|
|
13
13
|
"web component"
|
|
14
14
|
],
|
|
15
|
-
"version": "5.1
|
|
15
|
+
"version": "5.3.1",
|
|
16
16
|
"bugs": "https://github.com/javadbat/jb-select/issues",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"files": [
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"url": "git@github.com:javadbat/jb-select.git"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"jb-validation": ">=0.0
|
|
31
|
+
"jb-validation": ">=0.1.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"jb-form":">=0.
|
|
34
|
+
"jb-form":">=0.3.5"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/modules/jb-validation/lib/types.js';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ValidationResult, ValidationResultSummary, WithValidation } from "jb-validation/types";
|
|
2
|
-
export interface JBFormInputStandards<TValue = string> {
|
|
3
|
-
disabled: boolean;
|
|
4
|
-
required: boolean;
|
|
5
|
-
name: string;
|
|
6
|
-
value: TValue;
|
|
7
|
-
/**
|
|
8
|
-
* @description check if user change the value of component based on value provided from outside and return true if user change a initial value
|
|
9
|
-
*/
|
|
10
|
-
readonly isDirty: boolean;
|
|
11
|
-
initialValue: TValue;
|
|
12
|
-
}
|
|
13
|
-
export type TraverseResult<T> = {
|
|
14
|
-
[key: string]: T;
|
|
15
|
-
};
|
|
16
|
-
export type FormValidationMessages = {
|
|
17
|
-
[key: string]: string;
|
|
18
|
-
};
|
|
19
|
-
export type FormValidationSummary = {
|
|
20
|
-
[key: string]: ValidationResultSummary | null;
|
|
21
|
-
};
|
|
22
|
-
export type FormValidationResult = {
|
|
23
|
-
[key: string]: ValidationResult<any> | null;
|
|
24
|
-
};
|
|
25
|
-
export type FormValues<TValue = any> = {
|
|
26
|
-
[key: string]: TValue;
|
|
27
|
-
};
|
|
28
|
-
export type ExtractFunction<T> = (formElement: Partial<WithValidation & JBFormInputStandards>) => T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/web-component/jb-form/lib/types';
|