@creative-web-solution/front-library 7.0.7 → 7.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.
- package/CHANGELOG.md +29 -0
- package/DOM/Class.ts +10 -12
- package/DOM/DocumentSize.ts +3 -1
- package/DOM/Filter.ts +0 -2
- package/DOM/Index.ts +1 -3
- package/DOM/Manipulation.ts +0 -3
- package/DOM/Matrix.ts +12 -12
- package/DOM/Offset.ts +4 -5
- package/DOM/OuterSize.ts +12 -12
- package/DOM/PageToDOM.ts +2 -2
- package/DOM/Position.ts +3 -3
- package/DOM/Size.ts +3 -7
- package/DOM/StrToDOM.ts +0 -1
- package/DOM/Styles.ts +3 -12
- package/DOM/Traversing.ts +0 -6
- package/DOM/WindowScroll.ts +3 -1
- package/DOM/WindowSize.ts +3 -1
- package/DOM/Wrap.ts +0 -1
- package/Events/DeviceOrientation.ts +27 -31
- package/Events/EventsManager.ts +10 -25
- package/Events/Gesture.ts +36 -37
- package/Events/HistoryController.ts +12 -18
- package/Events/ImageLoad.ts +35 -19
- package/Events/IntersectObserver.ts +15 -19
- package/Events/KeyboardHandler.ts +10 -8
- package/Events/MediaQueriesEvents.ts +53 -51
- package/Events/OnAnimationEnd.ts +2 -3
- package/Events/OnTransitionEnd.ts +3 -3
- package/Events/PubSub.ts +5 -8
- package/Events/TouchHover.ts +18 -21
- package/Events/WindowEvents.ts +26 -30
- package/Helpers/Colors.ts +7 -23
- package/Helpers/Cookie.ts +5 -12
- package/Helpers/Coordinates.ts +0 -7
- package/Helpers/Debounce.ts +3 -7
- package/Helpers/Defer.ts +1 -1
- package/Helpers/GetValue.ts +0 -2
- package/Helpers/Insert.ts +0 -1
- package/Helpers/Sequential.ts +0 -2
- package/Helpers/Slice.ts +0 -3
- package/Helpers/Throttle.ts +0 -1
- package/Helpers/TransitionHelpers.ts +8 -6
- package/Helpers/Type.ts +1 -14
- package/Helpers/Unique.ts +3 -3
- package/Helpers/UrlParser.ts +14 -23
- package/Helpers/Wait.ts +1 -1
- package/Modules/Accordion/Tab.ts +19 -17
- package/Modules/Accordion/index.ts +27 -19
- package/Modules/Autocomplete.ts +95 -101
- package/Modules/DragSlider.ts +72 -63
- package/Modules/GlobalState.ts +60 -53
- package/Modules/LoadGMap.ts +4 -7
- package/Modules/Notifications/Notification.ts +28 -32
- package/Modules/Notifications/index.ts +43 -36
- package/Modules/Popin/Popin.ts +100 -110
- package/Modules/Popin/PopinAccessibility.ts +8 -8
- package/Modules/Popin/PopinBackground.ts +12 -12
- package/Modules/Popin/PopinController.ts +24 -30
- package/Modules/Popin/Tools.ts +18 -19
- package/Modules/QuickTemplate.ts +4 -6
- package/Modules/ScrollSnap.ts +110 -104
- package/Modules/SkinCheckbox.ts +52 -38
- package/Modules/SkinFile.ts +63 -53
- package/Modules/SkinRadio.ts +63 -43
- package/Modules/SkinSelect.ts +117 -101
- package/Modules/Slider/Slide.ts +49 -52
- package/Modules/Slider/Slider.ts +100 -136
- package/Modules/Slider/SliderControls.ts +60 -59
- package/Modules/Tabs/Tab.ts +28 -24
- package/Modules/Tabs/index.ts +36 -26
- package/Modules/Validator/Date.ts +2 -1
- package/Modules/Validator/Equals.ts +1 -1
- package/Modules/Validator/Internal/Input.ts +366 -0
- package/Modules/Validator/Internal/InputValidator.ts +99 -0
- package/Modules/Validator/Internal/ValidatorFunctionsController.ts +58 -0
- package/Modules/Validator/Max.ts +1 -1
- package/Modules/Validator/Min.ts +1 -1
- package/Modules/Validator/MultiRequired.ts +5 -5
- package/Modules/Validator/Number.ts +1 -0
- package/Modules/Validator/Pattern.ts +1 -1
- package/Modules/Validator/Recaptcha.ts +1 -0
- package/Modules/Validator/Required.ts +3 -2
- package/Modules/Validator/ServerCheck.ts +23 -15
- package/Modules/Validator/Tools/GetQueryFromForm.ts +1 -6
- package/Modules/Validator/Tools/IsDate.ts +2 -3
- package/Modules/Validator/Tools/IsEmail.ts +2 -5
- package/Modules/Validator/Tools/IsEmpty.ts +0 -2
- package/Modules/Validator/Tools/IsNumber.ts +0 -2
- package/Modules/Validator/Tools/IsUrl.ts +1 -3
- package/Modules/Validator/Tools/Label.ts +5 -15
- package/Modules/Validator/Tools/RadioButton.ts +4 -10
- package/Modules/Validator/Url.ts +1 -0
- package/Modules/Validator/index.ts +36 -36
- package/Modules/YouTubePlayer.ts +18 -16
- package/README.md +1 -1
- package/Types/Accordion.d.ts +41 -0
- package/Types/Autocomplete.d.ts +94 -0
- package/Types/DOM.d.ts +69 -0
- package/Types/DragSlider.d.ts +56 -0
- package/Types/EventsHelpers.d.ts +390 -0
- package/Types/GLImageTransition.d.ts +47 -43
- package/Types/GlobalState.d.ts +9 -0
- package/Types/Helpers.d.ts +63 -0
- package/Types/Notifications.d.ts +48 -44
- package/Types/Popin.d.ts +113 -0
- package/Types/ScrollSnap.d.ts +66 -0
- package/Types/SkinCheckbox.d.ts +35 -0
- package/Types/SkinFile.d.ts +45 -0
- package/Types/SkinRadio.d.ts +37 -0
- package/Types/SkinSelect.d.ts +72 -0
- package/Types/Slider.d.ts +106 -0
- package/Types/Tabs.d.ts +33 -0
- package/Types/Validator.d.ts +99 -0
- package/Types/YouTubePlayer.d.ts +27 -0
- package/Types/index.d.ts +22 -21
- package/WebGL/GLImageTransition/GLImageTransition.ts +83 -80
- package/WebGL/GLImageTransition/Presets/Cellular.ts +11 -11
- package/WebGL/GLImageTransition/Presets/Fade.ts +2 -3
- package/WebGL/GLImageTransition/Presets/HorizontalMovingGrid.ts +9 -9
- package/WebGL/GLImageTransition/Presets/PresetSample.ts +11 -9
- package/WebGL/GLImageTransition/Presets/Solarisation.ts +7 -12
- package/package.json +1 -1
- package/Modules/Template.ts +0 -209
- package/Types/AccordionTypes.d.ts +0 -29
- package/Types/AutocompleteTypes.d.ts +0 -85
- package/Types/DOMTypes.d.ts +0 -62
- package/Types/DragSliderTypes.d.ts +0 -52
- package/Types/EventsHelpersTypes.d.ts +0 -370
- package/Types/GlobalStateTypes.d.ts +0 -5
- package/Types/HelpersTypes.d.ts +0 -23
- package/Types/MediaPreloaderTypes.d.ts +0 -12
- package/Types/PopinTypes.d.ts +0 -83
- package/Types/ScrollSnapTypes.d.ts +0 -62
- package/Types/SkinCheckboxTypes.d.ts +0 -23
- package/Types/SkinFileTypes.d.ts +0 -34
- package/Types/SkinRadioTypes.d.ts +0 -24
- package/Types/SkinSelectTypes.d.ts +0 -48
- package/Types/SliderTypes.d.ts +0 -97
- package/Types/TabsTypes.d.ts +0 -22
- package/Types/ValidatorTypes.d.ts +0 -61
- package/Types/YouTubePlayerTypes.d.ts +0 -23
package/Modules/SkinCheckbox.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { extend } from '../Helpers/Extend';
|
|
|
2
2
|
import { wrap } from '../DOM/Wrap';
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
const defaultOptions:
|
|
5
|
+
const defaultOptions: FLib.SkinCheckbox.Options = {
|
|
6
6
|
"wrap": "<span class=\"cb-skin\"></span>",
|
|
7
7
|
"invalidClass": "invalid",
|
|
8
8
|
"disabledClass": "disabled",
|
|
@@ -14,17 +14,17 @@ const defaultOptions: SkinCheckboxOptionsType = {
|
|
|
14
14
|
* Skin an HTML input checkbox element.
|
|
15
15
|
* You can access the skin API in the __skinAPI property of the $checkbox HTMLElement or its wrapper.
|
|
16
16
|
*/
|
|
17
|
-
export default class SkinCheckbox {
|
|
17
|
+
export default class SkinCheckbox implements FLib.SkinCheckbox.SkinCheckbox {
|
|
18
18
|
|
|
19
|
-
#$checkbox!:
|
|
20
|
-
#options!:
|
|
21
|
-
#$parent!:
|
|
19
|
+
#$checkbox!: FLib.SkinCheckbox.CustomCheckbox;
|
|
20
|
+
#options!: FLib.SkinCheckbox.Options;
|
|
21
|
+
#$parent!: FLib.SkinCheckbox.CustomCheckboxParent;
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
constructor( $checkbox: HTMLInputElement, userOptions:
|
|
24
|
+
constructor( $checkbox: HTMLInputElement, userOptions: Partial<FLib.SkinCheckbox.Options> = {} ) {
|
|
25
25
|
|
|
26
26
|
// Already skinned
|
|
27
|
-
if ( ($checkbox as
|
|
27
|
+
if ( ($checkbox as FLib.SkinCheckbox.CustomCheckbox).__skinAPI ) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -33,9 +33,9 @@ const defaultOptions: SkinCheckboxOptionsType = {
|
|
|
33
33
|
this.#options = extend( defaultOptions, userOptions );
|
|
34
34
|
|
|
35
35
|
// Add the skin
|
|
36
|
-
wrap( this.#$checkbox, this.#options.wrap
|
|
36
|
+
wrap( this.#$checkbox, this.#options.wrap );
|
|
37
37
|
|
|
38
|
-
this.#$parent = this.#$checkbox.parentNode as
|
|
38
|
+
this.#$parent = this.#$checkbox.parentNode as FLib.SkinCheckbox.CustomCheckboxParent;
|
|
39
39
|
|
|
40
40
|
this.#$parent.__skinAPI = this.#$checkbox.__skinAPI = this;
|
|
41
41
|
|
|
@@ -45,34 +45,34 @@ const defaultOptions: SkinCheckboxOptionsType = {
|
|
|
45
45
|
|
|
46
46
|
this.#$checkbox.addEventListener( 'click', this.#changeHandler );
|
|
47
47
|
|
|
48
|
-
this
|
|
48
|
+
this.#update();
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
// Change the display
|
|
53
|
-
|
|
53
|
+
#update = (): void => {
|
|
54
54
|
this.#$checkbox.__skinAPI?.[ this.#$checkbox.checked ? 'check' : 'uncheck' ]();
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
#changeHandler = () => {
|
|
59
|
-
this
|
|
58
|
+
#changeHandler = (): void => {
|
|
59
|
+
this.#update();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
#checkUncheck = ( fnName: string, checked: boolean ): void => {
|
|
64
64
|
this.#$checkbox.checked = checked;
|
|
65
65
|
this.#$parent.classList[ fnName ]( this.#options.checkedClass );
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
#enableDisable = ( fnName: string, disabled: boolean ): void => {
|
|
70
70
|
this.#$checkbox.disabled = disabled;
|
|
71
71
|
this.#$parent.classList[ fnName ]( this.#options.disabledClass );
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
#validInvalid = ( fnName: string ): void => {
|
|
76
76
|
this.#$parent.classList[ fnName ]( this.#options.invalidClass );
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -80,49 +80,61 @@ const defaultOptions: SkinCheckboxOptionsType = {
|
|
|
80
80
|
/**
|
|
81
81
|
* Force the checkbox to be check
|
|
82
82
|
*/
|
|
83
|
-
check() {
|
|
84
|
-
this
|
|
83
|
+
check(): this {
|
|
84
|
+
this.#checkUncheck( 'add', true );
|
|
85
|
+
|
|
86
|
+
return this;
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
|
|
88
90
|
/**
|
|
89
91
|
* Force the checkbox to be uncheck
|
|
90
92
|
*/
|
|
91
|
-
uncheck() {
|
|
92
|
-
this
|
|
93
|
+
uncheck(): this {
|
|
94
|
+
this.#checkUncheck( 'remove', false );
|
|
95
|
+
|
|
96
|
+
return this;
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
|
|
96
100
|
/**
|
|
97
101
|
* Force the checkbox to be enable
|
|
98
102
|
*/
|
|
99
|
-
enable() {
|
|
100
|
-
this
|
|
101
|
-
|
|
103
|
+
enable(): this {
|
|
104
|
+
this.#enableDisable( 'remove', false );
|
|
105
|
+
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
102
108
|
|
|
103
109
|
|
|
104
110
|
/**
|
|
105
111
|
* Force the checkbox to be disable
|
|
106
112
|
*/
|
|
107
|
-
disable() {
|
|
108
|
-
this
|
|
109
|
-
|
|
113
|
+
disable(): this {
|
|
114
|
+
this.#enableDisable( 'add', true );
|
|
115
|
+
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
110
118
|
|
|
111
119
|
|
|
112
120
|
/**
|
|
113
121
|
* Force the state of the checkbox to invalid
|
|
114
122
|
*/
|
|
115
|
-
setInvalid() {
|
|
116
|
-
this
|
|
117
|
-
|
|
123
|
+
setInvalid(): this {
|
|
124
|
+
this.#validInvalid( 'add' );
|
|
125
|
+
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
118
128
|
|
|
119
129
|
|
|
120
130
|
/**
|
|
121
131
|
* Force the state of the checkbox to valid
|
|
122
132
|
*/
|
|
123
|
-
setValid() {
|
|
124
|
-
this
|
|
125
|
-
|
|
133
|
+
setValid(): this {
|
|
134
|
+
this.#validInvalid( 'remove' );
|
|
135
|
+
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
126
138
|
}
|
|
127
139
|
|
|
128
140
|
|
|
@@ -130,17 +142,17 @@ const defaultOptions: SkinCheckboxOptionsType = {
|
|
|
130
142
|
* Skin a checkbox DOM element
|
|
131
143
|
*
|
|
132
144
|
* @example
|
|
145
|
+
* ```ts
|
|
133
146
|
* // Call with default options:
|
|
134
147
|
* skinCheckbox( $input, {
|
|
135
|
-
* "wrap": "
|
|
148
|
+
* "wrap": "<span class=\"cb-skin\"></span>",
|
|
136
149
|
* "invalidClass": "invalid",
|
|
137
150
|
* "disabledClass": "disabled",
|
|
138
151
|
* "checkedClass": "checked"
|
|
139
152
|
* });
|
|
140
|
-
*
|
|
141
|
-
* @returns {SkinCheckbox}
|
|
153
|
+
* ```
|
|
142
154
|
*/
|
|
143
|
-
export function skinCheckbox( $checkbox: HTMLInputElement, options?:
|
|
155
|
+
export function skinCheckbox( $checkbox: HTMLInputElement, options?: Partial<FLib.SkinCheckbox.Options> ): SkinCheckbox {
|
|
144
156
|
return new SkinCheckbox( $checkbox, options );
|
|
145
157
|
}
|
|
146
158
|
|
|
@@ -149,16 +161,18 @@ export function skinCheckbox( $checkbox: HTMLInputElement, options?: SkinCheckbo
|
|
|
149
161
|
* Skin all checkbox DOM element in a wrapper
|
|
150
162
|
*
|
|
151
163
|
* @example
|
|
164
|
+
* ```ts
|
|
152
165
|
* // Call with default options:
|
|
153
166
|
* skinCheckboxAll( $wrapper,
|
|
154
167
|
* "selector": "input[type="checkbox"]",
|
|
155
|
-
* "wrap": "
|
|
168
|
+
* "wrap": "<span class=\"cb-skin\"></span>",
|
|
156
169
|
* "invalidClass": "invalid",
|
|
157
170
|
* "disabledClass": "disabled",
|
|
158
171
|
* "checkedClass": "checked"
|
|
159
172
|
* });
|
|
173
|
+
* ```
|
|
160
174
|
*/
|
|
161
|
-
export function skinCheckboxAll( $wrapper: HTMLElement, options:
|
|
175
|
+
export function skinCheckboxAll( $wrapper: HTMLElement, options: Partial<FLib.SkinCheckbox.AllOptions> = {} ): SkinCheckbox[] {
|
|
162
176
|
|
|
163
177
|
const $checkboxes = $wrapper.querySelectorAll( options.selector || 'input[type="checkbox"]' );
|
|
164
178
|
|
package/Modules/SkinFile.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { insertAfter, append } from '../DOM/Manipulation';
|
|
|
4
4
|
import { on } from '../Events/EventsManager';
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
const defaultOptions:
|
|
7
|
+
const defaultOptions: FLib.SkinFile.Options = {
|
|
8
8
|
"selector": ".file-skin",
|
|
9
9
|
"wrap": "<div class=\"file-skin\"></div>",
|
|
10
10
|
"fileInfoSelector": ".file-info",
|
|
@@ -20,36 +20,35 @@ const defaultOptions: SkinFileOptionsType = {
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Skin an HTML input file element.
|
|
23
|
-
* @class
|
|
24
23
|
*/
|
|
25
|
-
export default class SkinFile {
|
|
24
|
+
export default class SkinFile implements FLib.SkinFile.SkinFile {
|
|
26
25
|
|
|
27
|
-
#options:
|
|
28
|
-
#$parent:
|
|
29
|
-
#$resetButton
|
|
30
|
-
#$fileInfo
|
|
31
|
-
#fileInfoId
|
|
32
|
-
#$input:
|
|
26
|
+
#options: FLib.SkinFile.Options;
|
|
27
|
+
#$parent: FLib.SkinFile.CustomInputFileParent;
|
|
28
|
+
#$resetButton: HTMLElement | undefined;
|
|
29
|
+
#$fileInfo: HTMLElement | undefined;
|
|
30
|
+
#fileInfoId = '';
|
|
31
|
+
#$input: FLib.SkinFile.CustomInputFile;
|
|
33
32
|
|
|
34
33
|
#originalFileInfoText = '';
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
constructor( $input: HTMLInputElement, userOptions?:
|
|
36
|
+
constructor( $input: HTMLInputElement, userOptions?: Partial<FLib.SkinFile.Options> ) {
|
|
38
37
|
|
|
39
38
|
this.#$input = $input;
|
|
40
39
|
this.#options = extend( defaultOptions, userOptions );
|
|
41
40
|
|
|
42
|
-
const $PARENT = this.#$input.closest( this.#options.selector
|
|
41
|
+
const $PARENT = this.#$input.closest( this.#options.selector );
|
|
43
42
|
|
|
44
43
|
// The html skin is already done. Just selecting elements for the initialistion
|
|
45
44
|
if ( $PARENT ) {
|
|
46
|
-
this.#$parent = $PARENT as
|
|
47
|
-
this.#$resetButton = this.#$parent.querySelector( this.#options.resetButtonSelector
|
|
45
|
+
this.#$parent = $PARENT as FLib.SkinFile.CustomInputFileParent;
|
|
46
|
+
this.#$resetButton = this.#$parent.querySelector( this.#options.resetButtonSelector ) as HTMLElement;
|
|
48
47
|
if ( !this.#$resetButton ) {
|
|
49
48
|
throw `[SkinFile]: "${ this.#options.resetButtonSelector }" not found`;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
this.#$fileInfo = this.#$parent.querySelector( this.#options.fileInfoSelector
|
|
51
|
+
this.#$fileInfo = this.#$parent.querySelector( this.#options.fileInfoSelector ) as HTMLElement;
|
|
53
52
|
if ( !this.#$fileInfo ) {
|
|
54
53
|
throw `[SkinFile]: "${ this.#options.fileInfoSelector }" not found`;
|
|
55
54
|
}
|
|
@@ -59,7 +58,7 @@ const defaultOptions: SkinFileOptionsType = {
|
|
|
59
58
|
}
|
|
60
59
|
// No HTML skin, just input:file alone. Create the whole skin here:
|
|
61
60
|
else {
|
|
62
|
-
this.#$parent = strToDOM( this.#options.wrap
|
|
61
|
+
this.#$parent = strToDOM( this.#options.wrap ) as HTMLElement;
|
|
63
62
|
|
|
64
63
|
insertAfter( this.#$parent, this.#$input );
|
|
65
64
|
|
|
@@ -67,15 +66,15 @@ const defaultOptions: SkinFileOptionsType = {
|
|
|
67
66
|
|
|
68
67
|
if ( this.#$input.hasAttribute( 'data-file-info' ) ) {
|
|
69
68
|
this.#fileInfoId = this.#$input.getAttribute( 'data-file-info' ) || '';
|
|
70
|
-
this.#$fileInfo = document.getElementById( this.#fileInfoId );
|
|
69
|
+
this.#$fileInfo = document.getElementById( this.#fileInfoId ) as HTMLElement;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
if ( this.#$fileInfo
|
|
72
|
+
if ( this.#$fileInfo ) {
|
|
74
73
|
this.#originalFileInfoText = this.#$fileInfo.innerHTML;
|
|
75
74
|
this.#originalFileInfoText = this.#originalFileInfoText.trim();
|
|
76
75
|
}
|
|
77
76
|
else {
|
|
78
|
-
this.#$fileInfo = strToDOM( this.#options.fileInfo
|
|
77
|
+
this.#$fileInfo = strToDOM( this.#options.fileInfo ) as HTMLElement;
|
|
79
78
|
append( this.#$fileInfo, this.#$parent );
|
|
80
79
|
}
|
|
81
80
|
|
|
@@ -105,56 +104,55 @@ const defaultOptions: SkinFileOptionsType = {
|
|
|
105
104
|
} );
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
this
|
|
107
|
+
this.#changeState();
|
|
109
108
|
|
|
110
109
|
this.#$input.__skinAPI = this.#$parent.__skinAPI = this;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
|
|
114
|
-
|
|
115
|
-
let aValue;
|
|
113
|
+
#changeState = (): void => {
|
|
116
114
|
|
|
117
115
|
if ( !this.#$input.value ) {
|
|
118
|
-
this.#$fileInfo
|
|
116
|
+
( this.#$fileInfo as HTMLElement ).innerHTML = this.#originalFileInfoText;
|
|
119
117
|
|
|
120
118
|
if ( this.#options.autoHideFileInfo && !this.#originalFileInfoText ) {
|
|
121
|
-
this.#$fileInfo
|
|
119
|
+
( this.#$fileInfo as HTMLElement ).style.display = 'none';
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
this.#$parent.classList.remove( this.#options.selectedClass
|
|
122
|
+
this.#$parent.classList.remove( this.#options.selectedClass );
|
|
125
123
|
|
|
126
124
|
return;
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
aValue = this.#$input.value.split( /(\\|\/)/ );
|
|
127
|
+
const aValue = this.#$input.value.split( /(\\|\/)/ );
|
|
130
128
|
|
|
131
|
-
this.#$fileInfo
|
|
129
|
+
( this.#$fileInfo as HTMLElement ).innerHTML = aValue[ aValue.length - 1 ];
|
|
132
130
|
|
|
133
|
-
this.#$parent.classList.add( this.#options.selectedClass
|
|
131
|
+
this.#$parent.classList.add( this.#options.selectedClass );
|
|
134
132
|
|
|
135
133
|
if ( this.#options.autoHideFileInfo ) {
|
|
136
|
-
this.#$fileInfo
|
|
134
|
+
( this.#$fileInfo as HTMLElement ).style.display = '';
|
|
137
135
|
}
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
|
|
141
|
-
#changeHandler = () => {
|
|
142
|
-
this
|
|
139
|
+
#changeHandler = (): void => {
|
|
140
|
+
this.#changeState();
|
|
143
141
|
}
|
|
144
142
|
|
|
145
143
|
|
|
146
|
-
#clickHandler = () => {
|
|
144
|
+
#clickHandler = (): void => {
|
|
147
145
|
this.#$input.click();
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
|
|
151
|
-
#resetHandler = () => {
|
|
149
|
+
#resetHandler = (): void => {
|
|
152
150
|
this.#$input.value = '';
|
|
153
|
-
this
|
|
151
|
+
this.#changeState();
|
|
154
152
|
}
|
|
155
153
|
|
|
156
154
|
|
|
157
|
-
|
|
155
|
+
#enableDisable = ( fnName: string, disabled: boolean ): void => {
|
|
158
156
|
this.#$input.disabled = disabled;
|
|
159
157
|
this.#$parent.classList[ fnName ]( this.#options.disabledClass );
|
|
160
158
|
}
|
|
@@ -163,20 +161,24 @@ const defaultOptions: SkinFileOptionsType = {
|
|
|
163
161
|
/**
|
|
164
162
|
* Force the select to be enable
|
|
165
163
|
*/
|
|
166
|
-
enable() {
|
|
167
|
-
this
|
|
164
|
+
enable(): this {
|
|
165
|
+
this.#enableDisable( 'remove', false );
|
|
166
|
+
|
|
167
|
+
return this;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* Force the select to be disable
|
|
173
173
|
*/
|
|
174
|
-
disable() {
|
|
175
|
-
this
|
|
174
|
+
disable(): this {
|
|
175
|
+
this.#enableDisable( 'add', true );
|
|
176
|
+
|
|
177
|
+
return this;
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
|
|
179
|
-
|
|
181
|
+
#validInvalid = ( fnName: string ): void => {
|
|
180
182
|
this.#$parent.classList[ fnName ]( this.#options.invalidClass );
|
|
181
183
|
}
|
|
182
184
|
|
|
@@ -184,17 +186,21 @@ const defaultOptions: SkinFileOptionsType = {
|
|
|
184
186
|
/**
|
|
185
187
|
* Force the state of the select to invalid
|
|
186
188
|
*/
|
|
187
|
-
setInvalid() {
|
|
188
|
-
this
|
|
189
|
-
|
|
189
|
+
setInvalid(): this {
|
|
190
|
+
this.#validInvalid( 'add' );
|
|
191
|
+
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
190
194
|
|
|
191
195
|
|
|
192
196
|
/**
|
|
193
197
|
* Force the state of the select to valid
|
|
194
198
|
*/
|
|
195
|
-
setValid() {
|
|
196
|
-
this
|
|
197
|
-
|
|
199
|
+
setValid(): this {
|
|
200
|
+
this.#validInvalid( 'remove' );
|
|
201
|
+
|
|
202
|
+
return this;
|
|
203
|
+
}
|
|
198
204
|
}
|
|
199
205
|
|
|
200
206
|
|
|
@@ -203,21 +209,23 @@ const defaultOptions: SkinFileOptionsType = {
|
|
|
203
209
|
*
|
|
204
210
|
*
|
|
205
211
|
* @example
|
|
212
|
+
* ```ts
|
|
206
213
|
* // Call with default options:
|
|
207
214
|
* skinInputFile( $input, {
|
|
208
215
|
* "selector": ".file-skin",
|
|
209
|
-
* "wrap": "
|
|
216
|
+
* "wrap": "<div class=\"file-skin\"></div>",
|
|
210
217
|
* "fileInfoSelector": ".file-info",
|
|
211
|
-
* "fileInfo": "
|
|
218
|
+
* "fileInfo": "<div class=\"file-info\"></div>",
|
|
212
219
|
* "autoHideFileInfo": true,
|
|
213
220
|
* "resetButtonSelector": ".file-reset",
|
|
214
|
-
* "resetButton": "
|
|
221
|
+
* "resetButton": "<span class=\"file-reset\">×</span>",
|
|
215
222
|
* "disabledClass": "disabled",
|
|
216
223
|
* "invalidClass": "invalid",
|
|
217
224
|
* "selectedClass": "selected"
|
|
218
225
|
* } );
|
|
226
|
+
* ```
|
|
219
227
|
*/
|
|
220
|
-
export function skinInputFile( $input: HTMLInputElement, options:
|
|
228
|
+
export function skinInputFile( $input: HTMLInputElement, options: Partial<FLib.SkinFile.Options> ): SkinFile {
|
|
221
229
|
return new SkinFile( $input, options );
|
|
222
230
|
}
|
|
223
231
|
|
|
@@ -226,21 +234,23 @@ export function skinInputFile( $input: HTMLInputElement, options: SkinFileOption
|
|
|
226
234
|
* Skin all input file DOM element in a wrapper
|
|
227
235
|
*
|
|
228
236
|
* @example
|
|
237
|
+
* ```ts
|
|
229
238
|
* // Call with default options:
|
|
230
239
|
* skinInputFileAll( $wrapper, {
|
|
231
240
|
* "selector": ".file-skin",
|
|
232
|
-
* "wrap": "
|
|
241
|
+
* "wrap": "<div class=\"file-skin\"></div>",
|
|
233
242
|
* "fileInfoSelector": ".file-info",
|
|
234
|
-
* "fileInfo": "
|
|
243
|
+
* "fileInfo": "<div class=\"file-info\"></div>",
|
|
235
244
|
* "autoHideFileInfo": true,
|
|
236
245
|
* "resetButtonSelector": ".file-reset",
|
|
237
|
-
* "resetButton": "
|
|
246
|
+
* "resetButton": "<span class=\"file-reset\">×</span>",
|
|
238
247
|
* "disabledClass": "disabled",
|
|
239
248
|
* "invalidClass": "invalid",
|
|
240
249
|
* "selectedClass": "selected"
|
|
241
250
|
* } );
|
|
251
|
+
* ```
|
|
242
252
|
*/
|
|
243
|
-
export function skinInputFileAll( $wrapper: HTMLElement, options:
|
|
253
|
+
export function skinInputFileAll( $wrapper: HTMLElement, options: Partial<FLib.SkinFile.AllOptions> = {} ): SkinFile[] {
|
|
244
254
|
const skinList: SkinFile[] = [];
|
|
245
255
|
|
|
246
256
|
const $inputs = $wrapper.querySelectorAll( options.selector || 'input[type="file"]' );
|