@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
@@ -7,27 +7,19 @@ import { wait } from '../../Helpers/Wait';
7
7
 
8
8
  /**
9
9
  * This is one notification
10
- * @class
11
- * @ignore
12
- *
13
- * @param {String|Element} html
14
- * @param {String} type
15
- * @param {Object} options
16
- * @param {Function} close
17
- * @param {Object} notificationOptions
18
10
  */
19
11
  export default class Notification {
20
- #$notification!: HTMLElement;
21
- #html!: string;
12
+ #$notification: HTMLElement | undefined;
13
+ #html: string | undefined;
22
14
  #type: string;
23
- #autoCloseTimeout!: number;
15
+ #autoCloseTimeout: number | undefined;
24
16
  #closeDelay: boolean | number;
25
- #options: NotificationsOptionsType;
26
- #notificationOptions: NotificationOptionsType;
17
+ #options: FLib.Notifications.Options;
18
+ #notificationOptions: FLib.Notifications.NotificationOptions;
27
19
  #close: ( notification: Notification ) => void;
28
20
 
29
21
 
30
- constructor( htmlOrHTMLElement: string | HTMLElement, type: string, userOptions, close: ( notification: Notification ) => void, notificationOptions?: NotificationOptionsType ) {
22
+ constructor( htmlOrHTMLElement: string | HTMLElement, type: string, userOptions: FLib.Notifications.Options, close: ( notification: Notification ) => void, notificationOptions?: FLib.Notifications.NotificationOptions ) {
31
23
 
32
24
  this.#options = userOptions;
33
25
  this.#closeDelay = false;
@@ -36,10 +28,10 @@ export default class Notification {
36
28
  this.#close = close;
37
29
 
38
30
  if ( !notificationOptions ) {
39
- this.#closeDelay = this.#options.autoCloseDelay!;
31
+ this.#closeDelay = this.#options.autoCloseDelay;
40
32
  }
41
33
  else if ( notificationOptions && notificationOptions.closeDelay !== false ) {
42
- this.#closeDelay = notificationOptions.closeDelay || this.#options.autoCloseDelay!;
34
+ this.#closeDelay = notificationOptions.closeDelay || this.#options.autoCloseDelay;
43
35
  }
44
36
 
45
37
  if ( typeof htmlOrHTMLElement === 'string' ) {
@@ -51,23 +43,23 @@ export default class Notification {
51
43
  }
52
44
 
53
45
 
54
- private onClick = ( e ) => {
46
+ #onClick = ( e: Event ): void => {
55
47
  clearTimeout( this.#autoCloseTimeout );
56
48
 
57
- this.#options.onClick && this.#options.onClick.call( this, e );
58
- this.#notificationOptions && this.#notificationOptions.onClick && this.#notificationOptions.onClick.call( this, e );
49
+ this.#options.onClick?.( this );
50
+ this.#notificationOptions?.onClick?.call( this, e );
59
51
 
60
52
  this.#close( this );
61
53
  }
62
54
 
63
55
 
64
- show( $list ) {
56
+ show( $list: HTMLElement ): Promise<any> {
65
57
  if ( !this.#$notification ) {
66
- this.#$notification = strToDOM( this.#options.templates!.notification ) as HTMLElement;
67
- this.#$notification.innerHTML = this.#html;
58
+ this.#$notification = strToDOM( this.#options.templates.notification ) as HTMLElement;
59
+ ( this.#$notification as HTMLElement ).innerHTML = this.#html || '';
68
60
 
69
- if ( this.#options.cssClass![ this.#type ] ) {
70
- aClass( this.#$notification, this.#options.cssClass![ this.#type ] );
61
+ if ( this.#options.cssClass[ this.#type ] ) {
62
+ aClass( this.#$notification, this.#options.cssClass[ this.#type ] );
71
63
  }
72
64
 
73
65
  append( this.#$notification, $list );
@@ -75,7 +67,7 @@ export default class Notification {
75
67
 
76
68
  one( this.#$notification, {
77
69
  "eventsName": "click",
78
- "callback": this.onClick
70
+ "callback": this.#onClick
79
71
  } );
80
72
 
81
73
  if ( this.#closeDelay ) {
@@ -84,18 +76,22 @@ export default class Notification {
84
76
  }, this.#closeDelay as number * 1000 );
85
77
  }
86
78
 
87
- return wait( 100 ).then( () => this.#options.animations!.show!( this.#$notification, this.#options ) );
88
- };
79
+ return wait( 100 ).then( () => this.#options.animations.show( this.#$notification, this.#options ) );
80
+ }
89
81
 
90
82
 
91
- hide() {
83
+ hide(): Promise<any> {
84
+ if ( !this.#$notification ) {
85
+ return Promise.resolve()
86
+ }
87
+
92
88
  off( this.#$notification, {
93
89
  "eventsName": "click",
94
- "callback": this.onClick
90
+ "callback": this.#onClick
95
91
  } );
96
92
 
97
- return this.#options.animations!.hide!( this.#$notification, this.#options ).then( () => {
98
- remove( this.#$notification );
93
+ return this.#options.animations.hide( this.#$notification, this.#options ).then( () => {
94
+ remove( ( this.#$notification as HTMLElement ) );
99
95
  } );
100
- };
96
+ }
101
97
  }
@@ -34,7 +34,7 @@ const DEFAULT_OPTIONS = {
34
34
  return Promise.resolve();
35
35
  },
36
36
  "hide": ( $notification, options ) => {
37
- let prom = onTransitionEnd( $notification );
37
+ const prom = onTransitionEnd( $notification );
38
38
 
39
39
  wait().then( () => rClass( $notification, options.cssClass.open ) );
40
40
 
@@ -46,45 +46,42 @@ const DEFAULT_OPTIONS = {
46
46
 
47
47
  /**
48
48
  * Manages a list of notifications
49
- * @class
50
49
  *
51
50
  * @example let notifSys = new Notification();
52
51
  * notifSys.add( 'Here is a simple notification' );
53
- *
54
- * @param {Object} [userOptions]
55
52
  */
56
53
  export default class Notifications {
57
54
 
58
- #options: NotificationsOptionsType;
59
- #$list: HTMLElement;
60
- #$notifications: HTMLElement;
55
+ #options: FLib.Notifications.Options;
56
+ #$list: HTMLElement;
57
+ #$notifications: HTMLElement;
61
58
  #notificationsList: Notification[];
62
59
 
63
60
 
64
- constructor( userOptions: NotificationsOptionsType ) {
61
+ constructor( userOptions: Partial<FLib.Notifications.Options> ) {
65
62
 
66
63
  this.#options = extend( {}, DEFAULT_OPTIONS, userOptions );
67
64
  this.#notificationsList = [];
68
65
 
69
- this.#$notifications = document.querySelector( this.#options.selectors!.notifications! )!;
66
+ this.#$notifications = document.querySelector( this.#options.selectors.notifications ) as HTMLElement;
70
67
 
71
68
  if ( !this.#$notifications ) {
72
- this.#$notifications = strToDOM( this.#options.templates!.notifications ) as HTMLElement;
73
- append( this.#$notifications, this.#options.$wrapper! );
69
+ this.#$notifications = strToDOM( this.#options.templates.notifications ) as HTMLElement;
70
+ append( this.#$notifications, this.#options.$wrapper );
74
71
  }
75
72
 
76
73
 
77
- this.#$list = this.#$notifications.querySelector( this.#options.selectors!.list! ) as HTMLElement;
74
+ this.#$list = this.#$notifications.querySelector( this.#options.selectors.list ) as HTMLElement;
78
75
 
79
76
 
80
- this.#$list.querySelectorAll( this.#options.selectors!.notification! ).forEach( $notification => {
81
- this.insertNotification( $notification as HTMLElement );
77
+ this.#$list.querySelectorAll( this.#options.selectors.notification ).forEach( $notification => {
78
+ this.#insertNotification( $notification as HTMLElement );
82
79
  } );
83
80
  }
84
81
 
85
82
 
86
- private insertNotification( htmlOrHTMLElement: string | HTMLElement, type: NotificationType = 'info', notificationOptions?: NotificationOptionsType ) {
87
- let notification = new Notification( htmlOrHTMLElement, type, this.#options, this.close.bind( this ), notificationOptions );
83
+ #insertNotification = ( htmlOrHTMLElement: string | HTMLElement, type: FLib.Notifications.Type = 'info', notificationOptions?: FLib.Notifications.NotificationOptions ): void => {
84
+ const notification = new Notification( htmlOrHTMLElement, type, this.#options, this.#close.bind( this ), notificationOptions );
88
85
  notification.show( this.#$list );
89
86
 
90
87
  if ( !this.#notificationsList.length ) {
@@ -95,7 +92,7 @@ export default class Notifications {
95
92
  }
96
93
 
97
94
 
98
- private close( notification: Notification ) {
95
+ #close = ( notification: Notification ): void => {
99
96
  notification.hide().then( () => {
100
97
  this.#notificationsList = slice( this.#notificationsList, notification );
101
98
 
@@ -109,57 +106,67 @@ export default class Notifications {
109
106
  /**
110
107
  * Add a new notification.
111
108
  */
112
- add( html: string, type?: NotificationType, notificationOptions?: NotificationOptionsType ) {
113
- this.insertNotification( html, type, notificationOptions );
114
- };
109
+ add( html: string, type?: FLib.Notifications.Type, notificationOptions?: FLib.Notifications.NotificationOptions ): this {
110
+ this.#insertNotification( html, type, notificationOptions );
111
+
112
+ return this;
113
+ }
115
114
 
116
115
 
117
116
  /**
118
117
  * Add a new information notification.
119
118
  */
120
- addInfo( html: string, notificationOptions?: NotificationOptionsType ) {
121
- this.insertNotification( html, 'info', notificationOptions );
122
- };
119
+ addInfo( html: string, notificationOptions?: FLib.Notifications.NotificationOptions ): this {
120
+ this.#insertNotification( html, 'info', notificationOptions );
121
+
122
+ return this;
123
+ }
123
124
 
124
125
 
125
126
  /**
126
127
  * Add a new success notification.
127
128
  */
128
- addSuccess( html: string, notificationOptions?: NotificationOptionsType ) {
129
- this.insertNotification( html, 'success', notificationOptions );
130
- };
129
+ addSuccess( html: string, notificationOptions?: FLib.Notifications.NotificationOptions ): this {
130
+ this.#insertNotification( html, 'success', notificationOptions );
131
+
132
+ return this;
133
+ }
131
134
 
132
135
 
133
136
  /**
134
137
  * Add a new warning notification.
135
138
  */
136
- addWarning( html: string, notificationOptions?: NotificationOptionsType ) {
137
- this.insertNotification( html, 'warning', notificationOptions );
138
- };
139
+ addWarning( html: string, notificationOptions?: FLib.Notifications.NotificationOptions ): this {
140
+ this.#insertNotification( html, 'warning', notificationOptions );
141
+
142
+ return this;
143
+ }
139
144
 
140
145
 
141
146
  /**
142
147
  * Add a new error/danger notification.
143
148
  */
144
- addDanger( html: string, notificationOptions?: NotificationOptionsType ) {
145
- this.insertNotification( html, 'danger', notificationOptions );
146
- };
149
+ addDanger( html: string, notificationOptions?: FLib.Notifications.NotificationOptions ): this {
150
+ this.#insertNotification( html, 'danger', notificationOptions );
151
+
152
+ return this;
153
+ }
147
154
 
148
155
 
149
156
  /**
150
157
  * Close all notifications
151
158
  */
152
- closeAll() {
159
+ closeAll(): Promise<any[]> {
153
160
  return Promise.all( this.#notificationsList.map( notification => notification.hide() ) );
154
- };
161
+ }
155
162
 
156
163
 
157
164
  /**
158
165
  * Close all notifications and remove all containers
159
166
  */
160
- clean() {
167
+ clean(): Promise<Element> {
161
168
  return this.closeAll()
162
169
  .then( () => remove( this.#$notifications ) );
163
- };
170
+ }
164
171
  }
165
172