@creative-web-solution/front-library 7.1.5 → 7.1.8
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 +16 -0
- package/Events/HistoryController.ts +11 -12
- package/Modules/SkinCheckbox.ts +4 -4
- package/Modules/SkinRadio.ts +5 -5
- package/Modules/SkinSelect.ts +19 -12
- package/README.md +1 -1
- package/Types/EventsHelpers.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## 7.1.8
|
|
5
|
+
|
|
6
|
+
* SelectSkin: Fix templating
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## 7.1.7
|
|
10
|
+
|
|
11
|
+
* Typescript: Fix some type
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 7.1.6
|
|
15
|
+
|
|
16
|
+
* Minor fix
|
|
17
|
+
|
|
18
|
+
|
|
4
19
|
## 7.1.5
|
|
5
20
|
|
|
6
21
|
* Typescript: Fix some type
|
|
@@ -9,6 +24,7 @@
|
|
|
9
24
|
## 7.1.4
|
|
10
25
|
|
|
11
26
|
* Typescript: Fix tsify and browserify compatibility
|
|
27
|
+
* HistoryController: Remove UrlParser for window.URL
|
|
12
28
|
|
|
13
29
|
|
|
14
30
|
## 7.1.3
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { on } from './EventsManager';
|
|
2
|
-
import { UrlParser } from '../Helpers/UrlParser';
|
|
3
2
|
import { slice } from '../Helpers/Slice';
|
|
4
3
|
|
|
5
4
|
|
|
@@ -33,7 +32,7 @@ export default class HistoryController {
|
|
|
33
32
|
#hasPushstate: boolean;
|
|
34
33
|
#hasPopStateEvent: boolean;
|
|
35
34
|
#currentState: FLib.Events.History.StateObject;
|
|
36
|
-
#registeredFunctionList: (( url:
|
|
35
|
+
#registeredFunctionList: (( url: URL, state: any ) => void)[];
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
get state(): FLib.Events.History.StateObject {
|
|
@@ -53,7 +52,7 @@ export default class HistoryController {
|
|
|
53
52
|
this.#defaultTitle = encodeURIComponent( defaultTitle );
|
|
54
53
|
|
|
55
54
|
this.#currentState = {
|
|
56
|
-
"url": new
|
|
55
|
+
"url": new window.URL( window.location.href ),
|
|
57
56
|
"state": {},
|
|
58
57
|
"title": this.#defaultTitle
|
|
59
58
|
};
|
|
@@ -69,7 +68,7 @@ export default class HistoryController {
|
|
|
69
68
|
|
|
70
69
|
|
|
71
70
|
// Call each registered function for popstate event
|
|
72
|
-
#callRegisteredFunction = ( url:
|
|
71
|
+
#callRegisteredFunction = ( url: URL, state: any ): void => {
|
|
73
72
|
if ( !this.#registeredFunctionList.length ) {
|
|
74
73
|
return;
|
|
75
74
|
}
|
|
@@ -87,7 +86,7 @@ export default class HistoryController {
|
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
this.#currentState = {
|
|
90
|
-
"url": new
|
|
89
|
+
"url": new URL( document.location.href ),
|
|
91
90
|
state,
|
|
92
91
|
"title": ""
|
|
93
92
|
};
|
|
@@ -101,15 +100,15 @@ export default class HistoryController {
|
|
|
101
100
|
*
|
|
102
101
|
* @param state - Native browser state object
|
|
103
102
|
*/
|
|
104
|
-
pushState( state: any, title: string, url: string |
|
|
103
|
+
pushState( state: any, title: string, url: string | URL ): this {
|
|
105
104
|
if ( !this.#hasPushstate ) {
|
|
106
105
|
return this;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
url = url instanceof
|
|
108
|
+
url = url instanceof URL ? url : new URL( url as string );
|
|
110
109
|
|
|
111
110
|
this.#currentState = {
|
|
112
|
-
"url": url as
|
|
111
|
+
"url": url as URL,
|
|
113
112
|
state,
|
|
114
113
|
"title": title ? encodeURIComponent( title ) : this.#defaultTitle
|
|
115
114
|
};
|
|
@@ -118,7 +117,7 @@ export default class HistoryController {
|
|
|
118
117
|
window.history.pushState(
|
|
119
118
|
state,
|
|
120
119
|
this.#currentState.title,
|
|
121
|
-
this.#currentState.url.
|
|
120
|
+
this.#currentState.url.href
|
|
122
121
|
);
|
|
123
122
|
}
|
|
124
123
|
catch ( e ) {
|
|
@@ -137,14 +136,14 @@ export default class HistoryController {
|
|
|
137
136
|
return this;
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
anchor = anchor.indexOf( '#' ) === -1 ? anchor : anchor
|
|
139
|
+
anchor = anchor.indexOf( '#' ) === -1 ? `#${ anchor }` : anchor;
|
|
141
140
|
|
|
142
141
|
try {
|
|
143
|
-
this.#currentState.url.
|
|
142
|
+
this.#currentState.url.hash = anchor.indexOf( '#' ) === -1 ? `#${ anchor }` : anchor;
|
|
144
143
|
window.history.pushState(
|
|
145
144
|
this.#currentState.state,
|
|
146
145
|
this.#currentState.title,
|
|
147
|
-
this.#currentState.url.
|
|
146
|
+
this.#currentState.url.href
|
|
148
147
|
);
|
|
149
148
|
}
|
|
150
149
|
catch ( e ) {
|
package/Modules/SkinCheckbox.ts
CHANGED
|
@@ -16,16 +16,16 @@ const defaultOptions: FLib.SkinCheckbox.Options = {
|
|
|
16
16
|
*/
|
|
17
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
24
|
constructor( $checkbox: HTMLInputElement, userOptions: Partial<FLib.SkinCheckbox.Options> = {} ) {
|
|
25
25
|
|
|
26
26
|
// Already skinned
|
|
27
27
|
if ( ($checkbox as FLib.SkinCheckbox.CustomCheckbox).__skinAPI ) {
|
|
28
|
-
|
|
28
|
+
throw 'SkinSelect: Select already skinned';
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
this.#$checkbox = $checkbox;
|
package/Modules/SkinRadio.ts
CHANGED
|
@@ -27,16 +27,16 @@ const defaultOptions = {
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export default class SkinRadioButton implements FLib.SkinRadio.SkinRadio {
|
|
30
|
-
#$radio
|
|
31
|
-
#options
|
|
32
|
-
#$parent
|
|
33
|
-
#$rdGroup
|
|
30
|
+
#$radio: FLib.SkinRadio.CustomRadioButton;
|
|
31
|
+
#options: FLib.SkinRadio.Options;
|
|
32
|
+
#$parent: FLib.SkinRadio.CustomRadioButtonParent;
|
|
33
|
+
#$rdGroup: NodeListOf<FLib.SkinRadio.CustomRadioButton>;
|
|
34
34
|
|
|
35
35
|
constructor( $radio: HTMLInputElement, userOptions?: Partial<FLib.SkinRadio.Options> ) {
|
|
36
36
|
|
|
37
37
|
// Already skinned
|
|
38
38
|
if ( ($radio as FLib.SkinRadio.CustomRadioButton).__skinAPI ) {
|
|
39
|
-
|
|
39
|
+
throw 'SkinSelect: Select already skinned';
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
this.#$radio = $radio;
|
package/Modules/SkinSelect.ts
CHANGED
|
@@ -38,22 +38,26 @@ const defaultOptions: FLib.SkinSelect.Options = {
|
|
|
38
38
|
* You can access the skin API in the __skinAPI property of the $select HTMLElement or its wrapper.
|
|
39
39
|
*/
|
|
40
40
|
export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
41
|
-
#$select
|
|
41
|
+
#$select: FLib.SkinSelect.CustomSelect;
|
|
42
42
|
#loading = false;
|
|
43
|
-
#options
|
|
44
|
-
#extraClass
|
|
45
|
-
#$parent
|
|
46
|
-
#$title
|
|
43
|
+
#options: FLib.SkinSelect.Options;
|
|
44
|
+
#extraClass: string;
|
|
45
|
+
#$parent: FLib.SkinSelect.CustomSelectParent;
|
|
46
|
+
#$title: HTMLElement;
|
|
47
47
|
#isListOpened = false;
|
|
48
48
|
#$options: NodeList | undefined;
|
|
49
49
|
#$lastOption: HTMLElement | null = null;
|
|
50
50
|
#focusedItemIndex = -1;
|
|
51
51
|
#$layer: HTMLElement | undefined;
|
|
52
52
|
|
|
53
|
+
|
|
53
54
|
constructor( $select: FLib.SkinSelect.CustomSelect, userOptions?: Partial<FLib.SkinSelect.Options> ) {
|
|
54
55
|
|
|
55
|
-
if ( $select.hasAttribute( 'multiple' )
|
|
56
|
-
|
|
56
|
+
if ( $select.hasAttribute( 'multiple' ) ) {
|
|
57
|
+
throw 'SkinSelect: This feature doesn\'t work on select with multiple selection';
|
|
58
|
+
}
|
|
59
|
+
else if ( $select.__skinAPI ) {
|
|
60
|
+
throw 'SkinSelect: Select already skinned';
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
this.#$select = $select;
|
|
@@ -146,7 +150,7 @@ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
|
146
150
|
|
|
147
151
|
|
|
148
152
|
#openList = (): void => {
|
|
149
|
-
if ( this.#$select
|
|
153
|
+
if ( this.#$select?.disabled || this.#loading ) {
|
|
150
154
|
return;
|
|
151
155
|
}
|
|
152
156
|
|
|
@@ -385,14 +389,17 @@ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
|
|
|
385
389
|
|
|
386
390
|
for ( const opt of Array.from( this.#$select.options ) ) {
|
|
387
391
|
HTML_LIST.push( quickTemplate( this.#options.listTpl.item, {
|
|
388
|
-
"onClass":
|
|
389
|
-
"text":
|
|
390
|
-
"value":
|
|
392
|
+
"onClass": opt.selected ? " on" : "",
|
|
393
|
+
"text": opt.text,
|
|
394
|
+
"value": opt.value,
|
|
395
|
+
"layerClassName": this.#options.layerClassName,
|
|
396
|
+
"listClassName": this.#options.listClassName
|
|
391
397
|
} ) );
|
|
392
398
|
}
|
|
393
399
|
|
|
394
400
|
this.#$parent.appendChild( strToDOM( quickTemplate( this.#options.listTpl.wrapper, {
|
|
395
|
-
"items":
|
|
401
|
+
"items": HTML_LIST.join( '' ),
|
|
402
|
+
"itemClassName": this.#options.itemClassName
|
|
396
403
|
} ) ) );
|
|
397
404
|
|
|
398
405
|
|
package/README.md
CHANGED
package/Types/EventsHelpers.d.ts
CHANGED
|
@@ -179,12 +179,12 @@ declare namespace FLib {
|
|
|
179
179
|
*/
|
|
180
180
|
namespace History {
|
|
181
181
|
type StateObject = {
|
|
182
|
-
url:
|
|
182
|
+
url: URL;
|
|
183
183
|
state: any;
|
|
184
184
|
title: string;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
type Callback = ( url:
|
|
187
|
+
type Callback = ( url: URL, state: any ) => void;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
|
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.8",
|
|
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": [],
|