@creative-web-solution/front-library 7.0.7 → 7.1.0

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.
Files changed (141) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/DOM/Class.ts +10 -12
  3. package/DOM/DocumentSize.ts +3 -1
  4. package/DOM/Filter.ts +0 -2
  5. package/DOM/Index.ts +1 -3
  6. package/DOM/Manipulation.ts +0 -3
  7. package/DOM/Matrix.ts +12 -12
  8. package/DOM/Offset.ts +4 -5
  9. package/DOM/OuterSize.ts +12 -12
  10. package/DOM/PageToDOM.ts +2 -2
  11. package/DOM/Position.ts +3 -3
  12. package/DOM/Size.ts +3 -7
  13. package/DOM/StrToDOM.ts +0 -1
  14. package/DOM/Styles.ts +3 -12
  15. package/DOM/Traversing.ts +0 -6
  16. package/DOM/WindowScroll.ts +3 -1
  17. package/DOM/WindowSize.ts +3 -1
  18. package/DOM/Wrap.ts +0 -1
  19. package/Events/DeviceOrientation.ts +27 -31
  20. package/Events/EventsManager.ts +10 -25
  21. package/Events/Gesture.ts +36 -37
  22. package/Events/HistoryController.ts +11 -17
  23. package/Events/ImageLoad.ts +35 -19
  24. package/Events/IntersectObserver.ts +15 -19
  25. package/Events/KeyboardHandler.ts +10 -8
  26. package/Events/MediaQueriesEvents.ts +53 -51
  27. package/Events/OnAnimationEnd.ts +2 -3
  28. package/Events/OnTransitionEnd.ts +3 -3
  29. package/Events/PubSub.ts +5 -8
  30. package/Events/TouchHover.ts +18 -21
  31. package/Events/WindowEvents.ts +26 -30
  32. package/Helpers/Colors.ts +7 -23
  33. package/Helpers/Cookie.ts +5 -12
  34. package/Helpers/Coordinates.ts +0 -7
  35. package/Helpers/Debounce.ts +3 -7
  36. package/Helpers/Defer.ts +1 -1
  37. package/Helpers/GetValue.ts +0 -2
  38. package/Helpers/Insert.ts +0 -1
  39. package/Helpers/Sequential.ts +0 -2
  40. package/Helpers/Slice.ts +0 -3
  41. package/Helpers/Throttle.ts +0 -1
  42. package/Helpers/TransitionHelpers.ts +8 -6
  43. package/Helpers/Type.ts +1 -14
  44. package/Helpers/Unique.ts +3 -3
  45. package/Helpers/UrlParser.ts +13 -22
  46. package/Helpers/Wait.ts +1 -1
  47. package/Modules/Accordion/Tab.ts +18 -16
  48. package/Modules/Accordion/index.ts +24 -16
  49. package/Modules/Autocomplete.ts +95 -101
  50. package/Modules/DragSlider.ts +72 -63
  51. package/Modules/GlobalState.ts +60 -53
  52. package/Modules/LoadGMap.ts +4 -7
  53. package/Modules/Notifications/Notification.ts +28 -32
  54. package/Modules/Notifications/index.ts +43 -36
  55. package/Modules/Popin/Popin.ts +100 -110
  56. package/Modules/Popin/PopinAccessibility.ts +8 -8
  57. package/Modules/Popin/PopinBackground.ts +11 -11
  58. package/Modules/Popin/PopinController.ts +23 -29
  59. package/Modules/Popin/Tools.ts +18 -19
  60. package/Modules/QuickTemplate.ts +4 -6
  61. package/Modules/ScrollSnap.ts +110 -104
  62. package/Modules/SkinCheckbox.ts +51 -37
  63. package/Modules/SkinFile.ts +62 -52
  64. package/Modules/SkinRadio.ts +62 -42
  65. package/Modules/SkinSelect.ts +116 -100
  66. package/Modules/Slider/Slide.ts +49 -52
  67. package/Modules/Slider/Slider.ts +100 -136
  68. package/Modules/Slider/SliderControls.ts +60 -59
  69. package/Modules/Tabs/Tab.ts +27 -23
  70. package/Modules/Tabs/index.ts +35 -25
  71. package/Modules/Validator/Date.ts +2 -1
  72. package/Modules/Validator/Equals.ts +1 -1
  73. package/Modules/Validator/Internal/Input.ts +370 -0
  74. package/Modules/Validator/Internal/InputValidator.ts +99 -0
  75. package/Modules/Validator/Internal/ValidatorFunctionsController.ts +58 -0
  76. package/Modules/Validator/Max.ts +1 -1
  77. package/Modules/Validator/Min.ts +1 -1
  78. package/Modules/Validator/MultiRequired.ts +5 -5
  79. package/Modules/Validator/Number.ts +1 -0
  80. package/Modules/Validator/Pattern.ts +1 -1
  81. package/Modules/Validator/Recaptcha.ts +1 -0
  82. package/Modules/Validator/Required.ts +3 -2
  83. package/Modules/Validator/ServerCheck.ts +23 -15
  84. package/Modules/Validator/Tools/GetQueryFromForm.ts +1 -6
  85. package/Modules/Validator/Tools/IsDate.ts +2 -3
  86. package/Modules/Validator/Tools/IsEmail.ts +2 -5
  87. package/Modules/Validator/Tools/IsEmpty.ts +0 -2
  88. package/Modules/Validator/Tools/IsNumber.ts +0 -2
  89. package/Modules/Validator/Tools/IsUrl.ts +1 -3
  90. package/Modules/Validator/Tools/Label.ts +5 -15
  91. package/Modules/Validator/Tools/RadioButton.ts +4 -10
  92. package/Modules/Validator/Url.ts +1 -0
  93. package/Modules/Validator/index.ts +36 -36
  94. package/Modules/YouTubePlayer.ts +18 -16
  95. package/README.md +1 -1
  96. package/Types/Accordion.d.ts +36 -0
  97. package/Types/Autocomplete.d.ts +95 -0
  98. package/Types/DOM.d.ts +69 -0
  99. package/Types/DragSlider.d.ts +56 -0
  100. package/Types/EventsHelpers.d.ts +390 -0
  101. package/Types/GLImageTransition.d.ts +47 -43
  102. package/Types/GlobalState.d.ts +9 -0
  103. package/Types/Helpers.d.ts +30 -0
  104. package/Types/Notifications.d.ts +48 -44
  105. package/Types/Popin.d.ts +95 -0
  106. package/Types/ScrollSnap.d.ts +66 -0
  107. package/Types/SkinCheckbox.d.ts +26 -0
  108. package/Types/SkinFile.d.ts +38 -0
  109. package/Types/SkinRadio.d.ts +28 -0
  110. package/Types/SkinSelect.d.ts +59 -0
  111. package/Types/Slider.d.ts +106 -0
  112. package/Types/Tabs.d.ts +26 -0
  113. package/Types/Validator.d.ts +72 -0
  114. package/Types/YouTubePlayer.d.ts +27 -0
  115. package/Types/index.d.ts +22 -21
  116. package/WebGL/GLImageTransition/GLImageTransition.ts +83 -80
  117. package/WebGL/GLImageTransition/Presets/Cellular.ts +11 -11
  118. package/WebGL/GLImageTransition/Presets/Fade.ts +2 -3
  119. package/WebGL/GLImageTransition/Presets/HorizontalMovingGrid.ts +9 -9
  120. package/WebGL/GLImageTransition/Presets/PresetSample.ts +11 -9
  121. package/WebGL/GLImageTransition/Presets/Solarisation.ts +7 -12
  122. package/package.json +1 -1
  123. package/Modules/Template.ts +0 -209
  124. package/Types/AccordionTypes.d.ts +0 -29
  125. package/Types/AutocompleteTypes.d.ts +0 -85
  126. package/Types/DOMTypes.d.ts +0 -62
  127. package/Types/DragSliderTypes.d.ts +0 -52
  128. package/Types/EventsHelpersTypes.d.ts +0 -370
  129. package/Types/GlobalStateTypes.d.ts +0 -5
  130. package/Types/HelpersTypes.d.ts +0 -23
  131. package/Types/MediaPreloaderTypes.d.ts +0 -12
  132. package/Types/PopinTypes.d.ts +0 -83
  133. package/Types/ScrollSnapTypes.d.ts +0 -62
  134. package/Types/SkinCheckboxTypes.d.ts +0 -23
  135. package/Types/SkinFileTypes.d.ts +0 -34
  136. package/Types/SkinRadioTypes.d.ts +0 -24
  137. package/Types/SkinSelectTypes.d.ts +0 -48
  138. package/Types/SliderTypes.d.ts +0 -97
  139. package/Types/TabsTypes.d.ts +0 -22
  140. package/Types/ValidatorTypes.d.ts +0 -61
  141. package/Types/YouTubePlayerTypes.d.ts +0 -23
package/Helpers/Type.ts CHANGED
@@ -6,9 +6,6 @@ const CORE_HAS_OWN = CLASS_TO_TYPE.hasOwnProperty;
6
6
  /**
7
7
  * Check the type of an object
8
8
  *
9
- * @param obj
10
- * @param type
11
- *
12
9
  * @example
13
10
  * boolean = isType( obj, 'String' )
14
11
  *
@@ -22,8 +19,6 @@ export function isType( obj: any, type: string ): boolean {
22
19
  /**
23
20
  * Return true if the objec is an Array
24
21
  *
25
- * @param obj
26
- *
27
22
  * @example
28
23
  * boolean = isArray( obj )
29
24
  */
@@ -35,8 +30,6 @@ export function isArray( obj: any ): boolean {
35
30
  /**
36
31
  * Return true if the object is a Function
37
32
  *
38
- * @param obj
39
- *
40
33
  * @example
41
34
  * boolean = isFunction( obj )
42
35
  */
@@ -48,8 +41,6 @@ export function isFunction( obj: any ): boolean {
48
41
  /**
49
42
  * Return true if the object is a String
50
43
  *
51
- * @param obj
52
- *
53
44
  * @example
54
45
  * boolean = isString( obj )
55
46
  */
@@ -61,8 +52,6 @@ export function isString( obj: any ): boolean {
61
52
  /**
62
53
  * Return true if the object is a Number
63
54
  *
64
- * @param obj
65
- *
66
55
  * @example
67
56
  * boolean = isNumber( obj )
68
57
  */
@@ -82,9 +71,7 @@ export function isNumber( obj: any ): boolean {
82
71
 
83
72
 
84
73
  /**
85
- * Return true if obj is {} or an object created with "new Object"
86
- *
87
- * @param obj
74
+ * Return true if obj is `{}` or an object created with "new Object"
88
75
  */
89
76
  export function isPlainObject( obj: any ): boolean {
90
77
  // Detect obvious negatives
package/Helpers/Unique.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Remove all duplicate from a list. Doesn't change the original list.
3
3
  *
4
- * @param list
5
- * @param filter - Optionnal, (currentItem, returnArray) => { should return true or false }
4
+ * @param filter - Optionnal, (currentItem, returnArray) => `{` should return true or false `}`
6
5
  *
7
6
  * @example
7
+ * ```ts
8
8
  * // Using the native includes function
9
9
  * modifiedArray = unique( array )
10
10
  *
11
- * @example
12
11
  * // With custom function (here, same as default behaviour)
13
12
  * modifiedArray = unique( array, (currentValue, returnArray) => { return !returnArray.includes(currentValue) } )
13
+ * ```
14
14
  *
15
15
  * @returns Filtered list
16
16
  */
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Parse an URL
3
3
  *
4
- * @param url
5
- *
6
4
  * @example
5
+ * ```ts
7
6
  * let url = new UrlParser( 'https://username:password@demo.domain.com:1337/section/page.html?param=1&param=2#anchor' );
8
7
  *
9
8
  * // Update the anchor and regenerate url
@@ -32,6 +31,7 @@
32
31
  *
33
32
  * // Remove all query param
34
33
  * url.removeAll()
34
+ * ```
35
35
  */
36
36
  export class UrlParser {
37
37
  /** Complete url without userInfo and anchor. Ex: https://demo.domain.com:1337/section/page.html?param=2 */
@@ -40,7 +40,7 @@ export class UrlParser {
40
40
  absolute2 = '';
41
41
  /** Ex: anchor */
42
42
  anchor = '';
43
- /** Ex: username:password@demo.domain.com:1337 */
43
+ /** Ex: username:password\@demo.domain.com:1337 */
44
44
  authority = '';
45
45
  /** Ex: /section/ */
46
46
  directory = '';
@@ -63,8 +63,8 @@ export class UrlParser {
63
63
  protocol = '';
64
64
  /** Ex: param=2 */
65
65
  query = '';
66
- /** Ex: { "param": "2" } */
67
- queryKey: { [ key: string ]: string } = {};
66
+ /** Ex: `{` "param": "2" `}` */
67
+ queryKey: Record<string, string> = {};
68
68
  /** Ex: Url without host, credential and anchor */
69
69
  relative = '';
70
70
  /** Ex: Url without host, credential but with anchor */
@@ -89,7 +89,7 @@ export class UrlParser {
89
89
  /*
90
90
  Rebuild the complete url
91
91
  */
92
- private rebuild() {
92
+ #rebuild = (): void => {
93
93
  let portToAdd, queryToAdd;
94
94
 
95
95
  queryToAdd = '';
@@ -162,7 +162,7 @@ export class UrlParser {
162
162
  /**
163
163
  * Init
164
164
  */
165
- init( url: string ) {
165
+ init( url: string ): void {
166
166
  let location, result;
167
167
 
168
168
  const parseUri = function( str: string ) {
@@ -240,19 +240,17 @@ export class UrlParser {
240
240
  this[ key ] = result[ key ];
241
241
  } );
242
242
 
243
- this.rebuild();
243
+ this.#rebuild();
244
244
  }
245
245
 
246
246
 
247
247
  /**
248
248
  * Change the anchor
249
- *
250
- * @param anchor
251
249
  */
252
250
  setAnchor( anchor: string ): this {
253
251
  this.anchor = anchor;
254
252
 
255
- this.rebuild();
253
+ this.#rebuild();
256
254
 
257
255
  return this;
258
256
  }
@@ -261,8 +259,6 @@ export class UrlParser {
261
259
  /**
262
260
  * Get the value of a query param
263
261
  *
264
- * @param key
265
- *
266
262
  * @returns The parameter value or undefined
267
263
  */
268
264
  getParam( key: string ): string {
@@ -276,11 +272,8 @@ export class UrlParser {
276
272
 
277
273
  /**
278
274
  * Add/modify one or several query param
279
- *
280
- * @param keys
281
- * @param value
282
275
  */
283
- setParam( keys: string | { [ keys: string ]: string }, value?: string ): this {
276
+ setParam( keys: string | Record<string, string>, value?: string ): this {
284
277
  if ( !this.queryKey ) {
285
278
  this.queryKey = {};
286
279
  }
@@ -294,7 +287,7 @@ export class UrlParser {
294
287
  } );
295
288
  }
296
289
 
297
- this.rebuild();
290
+ this.#rebuild();
298
291
 
299
292
  return this;
300
293
  }
@@ -302,8 +295,6 @@ export class UrlParser {
302
295
 
303
296
  /**
304
297
  * Remove one or several query param
305
- *
306
- * @param keys
307
298
  */
308
299
  removeParam( keys: string | string[] ): this {
309
300
  if ( !this.queryKey ) {
@@ -319,7 +310,7 @@ export class UrlParser {
319
310
  } );
320
311
  }
321
312
 
322
- this.rebuild();
313
+ this.#rebuild();
323
314
 
324
315
  return this;
325
316
  }
@@ -331,7 +322,7 @@ export class UrlParser {
331
322
  removeAll(): this {
332
323
  this.queryKey = {};
333
324
 
334
- this.rebuild();
325
+ this.#rebuild();
335
326
 
336
327
  return this;
337
328
  }
package/Helpers/Wait.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Return a promise and wait for 'waitFor' millisecond to resolve it.
3
- * If 'waitFor' < 0 => wait for an animation frame
3
+ * If 'waitFor' &lt; 0 =&gt; wait for an animation frame
4
4
  *
5
5
  * @param waitFor - Number in ms or 'idle'
6
6
  *
@@ -13,7 +13,7 @@ export default class Tab {
13
13
  #$TAB;
14
14
 
15
15
 
16
- constructor( $TAB: HTMLElement, options: AccordionTabOptionsType ) {
16
+ constructor( $TAB: HTMLElement, options: FLib.Accordion.TabOptions ) {
17
17
  this.#options = options;
18
18
  this.#$TAB = $TAB ;
19
19
 
@@ -28,17 +28,17 @@ export default class Tab {
28
28
  } );
29
29
 
30
30
  if ( this.#isOpen ) {
31
- this.openTab( true );
31
+ this.#openTab( true );
32
32
  }
33
33
  }
34
34
 
35
35
 
36
- private changeTabState() {
36
+ #changeTabState = (): void => {
37
37
  this.#$TAB.setAttribute( 'aria-expanded', this.#isOpen ? 'true' : 'false' );
38
38
  }
39
39
 
40
40
 
41
- private openTab( isOpenAtStart?: boolean ) {
41
+ #openTab = ( isOpenAtStart?: boolean ): void => {
42
42
  this.#options.animations
43
43
  .open( this.#$TAB, this.#$TAB_PANNEL )
44
44
  .then( () => {
@@ -55,11 +55,11 @@ export default class Tab {
55
55
  this.#options.onOpenTab( this );
56
56
  }
57
57
  this.#isOpen = true;
58
- this.changeTabState();
58
+ this.#changeTabState();
59
59
  }
60
60
 
61
61
 
62
- private closeTab( autoClose?: boolean ) {
62
+ #closeTab = ( autoClose?: boolean ): void => {
63
63
  this.#options.animations
64
64
  .close( this.#$TAB, this.#$TAB_PANNEL )
65
65
  .then( () => {
@@ -69,32 +69,32 @@ export default class Tab {
69
69
  } );
70
70
 
71
71
  this.#isOpen = false;
72
- this.changeTabState();
72
+ this.#changeTabState();
73
73
  }
74
74
 
75
75
 
76
- #toggleTab = ( e: Event ) => {
76
+ #toggleTab = ( e: Event ): void => {
77
77
  e.preventDefault();
78
78
 
79
79
  if( this.#isOpen && ( !this.#options.atLeastOneOpen || this.#options.allowMultipleTab ) ) {
80
- this.closeTab();
80
+ this.#closeTab();
81
81
  }
82
82
  else if( !this.#isOpen ) {
83
- this.openTab();
83
+ this.#openTab();
84
84
  }
85
85
  }
86
86
 
87
87
 
88
- close( autoClose?: boolean ) {
89
- if( !this.#isOpen ) {
90
- return;
88
+ close( autoClose?: boolean ): this {
89
+ if( this.#isOpen ) {
90
+ this.#closeTab( autoClose );
91
91
  }
92
92
 
93
- this.closeTab( autoClose );
93
+ return this;
94
94
  }
95
95
 
96
96
 
97
- destroy() {
97
+ destroy(): this {
98
98
  this.#options.animations.destroy( this.#$TAB, this.#$TAB_PANNEL );
99
99
 
100
100
  off( this.#$TAB, {
@@ -103,5 +103,7 @@ export default class Tab {
103
103
  } );
104
104
 
105
105
  this.#$TAB.setAttribute( 'aria-expanded', this.#originalOpenedState ? 'true' : 'false' );
106
- };
106
+
107
+ return this;
108
+ }
107
109
  }
@@ -3,7 +3,7 @@ import { extend } from '../../Helpers/Extend';
3
3
  import Tab from './Tab';
4
4
 
5
5
 
6
- const DEFAULT_OPTIONS: AccordionOptionsType = {
6
+ const DEFAULT_OPTIONS = {
7
7
  "tabSelector": "button[aria-expanded]",
8
8
  "allowMultipleTab": false,
9
9
  "atLeastOneOpen": false,
@@ -31,6 +31,7 @@ const DEFAULT_OPTIONS: AccordionOptionsType = {
31
31
  * Accordion
32
32
  *
33
33
  * @example
34
+ * ```ts
34
35
  * new Accordion( document.querySelector( '.accordion' ), {
35
36
  * "tabSelector": ".tab",
36
37
  * "allowMultipleTab": false,
@@ -62,9 +63,11 @@ const DEFAULT_OPTIONS: AccordionOptionsType = {
62
63
  * console.log( 'close: ', $tab, $panel );
63
64
  * }
64
65
  * } );
66
+ * ```
65
67
  *
66
68
  * HTML:
67
69
  *
70
+ * ```html
68
71
  * <div class="accordion">
69
72
  * <button aria-expanded="true" class="tab" aria-controls="panel-1">Button name</button>
70
73
  * <div id="panel-1" class="panel">
@@ -76,12 +79,13 @@ const DEFAULT_OPTIONS: AccordionOptionsType = {
76
79
  * <p>Content</p>
77
80
  * </div>
78
81
  * </div>
82
+ * ```
79
83
  *
80
84
  * Set aria-expanded to "true" on the tab you want open at start
81
85
  */
82
86
  export default class Accordion {
83
- #options: AccordionOptionsType;
84
- #$tabs: NodeList;
87
+ #options: FLib.Accordion.Options;
88
+ #$tabs: NodeListOf<HTMLElement>;
85
89
  #tablist: Tab[];
86
90
  #status: string;
87
91
  #lastOpenedTab: Tab | null = null;
@@ -91,7 +95,7 @@ export default class Accordion {
91
95
  #STATUS_OFF = 'STATUS_OFF';
92
96
 
93
97
 
94
- constructor( $accordionWrapper: HTMLElement, userOptions: AccordionOptionsType ) {
98
+ constructor( $accordionWrapper: HTMLElement, userOptions: FLib.Accordion.OptionsInit ) {
95
99
 
96
100
  this.#options = extend( DEFAULT_OPTIONS, userOptions );
97
101
 
@@ -99,11 +103,11 @@ export default class Accordion {
99
103
  this.#tablist = [];
100
104
  this.#status = this.#STATUS_OFF;
101
105
 
102
- this.on();
106
+ this.#on();
103
107
  }
104
108
 
105
109
 
106
- #onOpenTab = ( tab: Tab ) => {
110
+ #onOpenTab = ( tab: Tab ): void => {
107
111
  if ( this.#lastOpenedTab ) {
108
112
  this.#lastOpenedTab.close( true );
109
113
  }
@@ -112,7 +116,7 @@ export default class Accordion {
112
116
  }
113
117
 
114
118
 
115
- private on(){
119
+ #on = (): void => {
116
120
  if( this.#status === this.#STATUS_ON ){
117
121
  return;
118
122
  }
@@ -120,7 +124,7 @@ export default class Accordion {
120
124
  this.#status = this.#STATUS_ON;
121
125
 
122
126
  this.#$tabs.forEach( ( $tab, index ) => {
123
- this.#tablist.push( new Tab( $tab as HTMLElement, {
127
+ this.#tablist.push( new Tab( $tab, {
124
128
  ...this.#options,
125
129
  index,
126
130
  "onOpenTab": this.#options.allowMultipleTab ? null : this.#onOpenTab
@@ -129,7 +133,7 @@ export default class Accordion {
129
133
  }
130
134
 
131
135
 
132
- private off() {
136
+ #off = (): void => {
133
137
  if( this.#status === this.#STATUS_OFF ){
134
138
  return;
135
139
  }
@@ -147,16 +151,20 @@ export default class Accordion {
147
151
  /**
148
152
  * Remove all events, css class, ...
149
153
  */
150
- destroy() {
151
- this.off();
152
- };
154
+ destroy(): this {
155
+ this.#off();
156
+
157
+ return this;
158
+ }
153
159
 
154
160
 
155
161
  /**
156
162
  * Restart the module
157
163
  */
158
- update() {
159
- this.off();
160
- this.on();
161
- };
164
+ update(): this {
165
+ this.#off();
166
+ this.#on();
167
+
168
+ return this;
169
+ }
162
170
  }