ziko 0.50.1 → 0.50.2
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/dist/ziko.cjs +772 -898
- package/dist/ziko.js +377 -207
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +374 -208
- package/package.json +1 -1
- package/src/data/api/fetchdom.js +27 -11
- package/src/events/binders/custom-event.js +1 -1
- package/src/events/binders/index.js +34 -6
- package/src/events/custom-events-registry/index.js +3 -1
- package/src/events/custom-events-registry/swipe.js +41 -23
- package/src/events/custom-events-registry/view.js +50 -19
- package/src/events/events-map/index.js +13 -5
- package/src/events/utils.js +31 -0
- package/src/events/ziko-event.js +59 -117
- package/src/ui/__methods__/dom.js +0 -20
- package/src/ui/__methods__/events.js +8 -4
- package/src/ui/__methods__/index.js +3 -0
- package/src/ui/__methods__/lifecycle.js +54 -0
- package/src/ui/constructors/UIElement.js +4 -30
- package/src/ui/{constructors/UIElement-lite.js → mini/UIElement.js} +1 -1
- package/src/ui/suspense/index.js +1 -2
- package/types/data/api/index.d.ts +15 -0
- package/types/data/index.d.ts +1 -0
- package/types/data/string/checkers.d.ts +51 -0
- package/types/data/string/converters.d.ts +101 -0
- package/types/data/string/index.d.ts +2 -0
- package/types/index.d.ts +2 -1
|
@@ -35,18 +35,6 @@ export function clear(){
|
|
|
35
35
|
this.element.innerHTML = "";
|
|
36
36
|
return this;
|
|
37
37
|
}
|
|
38
|
-
export function mount(target = this.target) {
|
|
39
|
-
if(this.isBody)return ;
|
|
40
|
-
if(target?.isUIElement)target=target.element;
|
|
41
|
-
this.target=target;
|
|
42
|
-
this.target?.appendChild(this.element);
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
export function unmount(){
|
|
46
|
-
if(this.cache.parent)this.cache.parent.remove(this);
|
|
47
|
-
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
38
|
export function replaceElementWith(new_element){
|
|
51
39
|
this.cache.element.replaceWith(new_element)
|
|
52
40
|
this.cache.element = new_element;
|
|
@@ -54,14 +42,6 @@ export function replaceElementWith(new_element){
|
|
|
54
42
|
// To do : Dispose Events and States
|
|
55
43
|
return this
|
|
56
44
|
}
|
|
57
|
-
export function renderAfter(t = 1) {
|
|
58
|
-
setTimeout(() => this.mount(), t);
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
export function unrenderAfter(t = 1) {
|
|
62
|
-
setTimeout(() => this.unmount(), t);
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
45
|
export function after(ui){
|
|
66
46
|
if(ui?.isUIElement) ui=ui.element;
|
|
67
47
|
this.element?.after(ui)
|
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
bind_drag_event,
|
|
8
8
|
bind_clipboard_event,
|
|
9
9
|
bind_focus_event,
|
|
10
|
-
bind_wheel_event
|
|
10
|
+
bind_wheel_event,
|
|
11
|
+
bind_view_event,
|
|
12
|
+
bind_swipe_event
|
|
11
13
|
} from "../../events/binders/index.js";
|
|
12
14
|
|
|
13
15
|
import { bind_custom_event } from "../../events/binders/custom-event.js";
|
|
@@ -20,7 +22,9 @@ const binderMap = {
|
|
|
20
22
|
drag : bind_drag_event,
|
|
21
23
|
clipboard : bind_clipboard_event,
|
|
22
24
|
focus : bind_focus_event,
|
|
23
|
-
wheel : bind_wheel_event
|
|
25
|
+
wheel : bind_wheel_event,
|
|
26
|
+
view : bind_view_event,
|
|
27
|
+
swipe : bind_swipe_event
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
const EventsMethodes = {
|
|
@@ -40,9 +44,9 @@ Object.entries(EventsMap).forEach(([name, eventList]) => {
|
|
|
40
44
|
const lname = name.toLowerCase()
|
|
41
45
|
eventList.forEach(event => {
|
|
42
46
|
const methodName = `on${event}`;
|
|
43
|
-
EventsMethodes[methodName] = function (
|
|
47
|
+
EventsMethodes[methodName] = function (callbacks) {
|
|
44
48
|
if (!this.events[lname]) this.events[lname] = binderMap[lname](this);
|
|
45
|
-
this.events[lname][methodName](
|
|
49
|
+
this.events[lname][methodName](callbacks);
|
|
46
50
|
return this;
|
|
47
51
|
};
|
|
48
52
|
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// export function mount(target = this.target) {
|
|
2
|
+
// if(this.isBody) return ;
|
|
3
|
+
// if(target?.isUIElement)target=target.element;
|
|
4
|
+
// this.target=target;
|
|
5
|
+
// this.target?.appendChild(this.element);
|
|
6
|
+
// return this;
|
|
7
|
+
// }
|
|
8
|
+
// export function unmount(){
|
|
9
|
+
// if(this.cache.parent)this.cache.parent.remove(this);
|
|
10
|
+
// else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
11
|
+
// return this;
|
|
12
|
+
// }
|
|
13
|
+
|
|
14
|
+
// export function mountAfter(target = this.target, t = 1) {
|
|
15
|
+
// setTimeout(() => this.mount(), t);
|
|
16
|
+
// return this;
|
|
17
|
+
// }
|
|
18
|
+
// export function unmountAfter(t = 1) {
|
|
19
|
+
// setTimeout(() => this.unmount(), t);
|
|
20
|
+
// return this;
|
|
21
|
+
// }
|
|
22
|
+
|
|
23
|
+
export function mount(target = this.target, delay = 0) {
|
|
24
|
+
if (delay > 0) {
|
|
25
|
+
setTimeout(() => this.mount(target, 0), delay);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (this.isBody) return this;
|
|
30
|
+
|
|
31
|
+
if (target?.isUIElement) target = target.element;
|
|
32
|
+
this.target = target;
|
|
33
|
+
|
|
34
|
+
this.target?.appendChild(this.element);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function unmount(delay = 0) {
|
|
39
|
+
if (delay > 0) {
|
|
40
|
+
setTimeout(() => this.unmount(0), delay);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (this.cache.parent) {
|
|
45
|
+
this.cache.parent.remove(this);
|
|
46
|
+
} else if (
|
|
47
|
+
this.target?.children?.length &&
|
|
48
|
+
[...this.target.children].includes(this.element)
|
|
49
|
+
) {
|
|
50
|
+
this.target.removeChild(this.element);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UIElementCore } from "./UIElementCore.js";
|
|
2
2
|
import { register_to_class } from "../../__helpers__/register/register-to-class.js";
|
|
3
3
|
import {
|
|
4
|
+
LifecycleMethods,
|
|
4
5
|
AttrsMethods,
|
|
5
6
|
DomMethods,
|
|
6
7
|
IndexingMethods,
|
|
@@ -22,6 +23,7 @@ class UIElement extends UIElementCore{
|
|
|
22
23
|
// console.log(this)
|
|
23
24
|
register_to_class(
|
|
24
25
|
this,
|
|
26
|
+
LifecycleMethods,
|
|
25
27
|
AttrsMethods,
|
|
26
28
|
DomMethods,
|
|
27
29
|
StyleMethods,
|
|
@@ -151,32 +153,12 @@ class UIElement extends UIElementCore{
|
|
|
151
153
|
// get id() {
|
|
152
154
|
// return this.element.getAttribute("id");
|
|
153
155
|
// }
|
|
154
|
-
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
155
|
-
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
156
|
-
// this.events.swipe.onSwipe(...callbacks);
|
|
157
|
-
// return this;
|
|
158
|
-
// }
|
|
159
156
|
// To Fix
|
|
160
157
|
// onKeysDown({keys=[],callback}={}){
|
|
161
158
|
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
162
159
|
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
163
160
|
// return this;
|
|
164
161
|
// }
|
|
165
|
-
// onSelect(...callbacks){
|
|
166
|
-
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
167
|
-
// this.events.clipboard.onSelect(...callbacks);
|
|
168
|
-
// return this;
|
|
169
|
-
// }
|
|
170
|
-
// on(event_name,...callbacks){
|
|
171
|
-
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
172
|
-
// this.events.custom.on(event_name,...callbacks);
|
|
173
|
-
// return this;
|
|
174
|
-
// }
|
|
175
|
-
// emit(event_name,detail={}){
|
|
176
|
-
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
177
|
-
// this.events.custom.emit(event_name,detail);
|
|
178
|
-
// return this;
|
|
179
|
-
// }
|
|
180
162
|
// watchAttr(callback){
|
|
181
163
|
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
182
164
|
// return this;
|
|
@@ -185,16 +167,8 @@ class UIElement extends UIElementCore{
|
|
|
185
167
|
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
186
168
|
// return this;
|
|
187
169
|
// }
|
|
188
|
-
// watchSize(callback)
|
|
189
|
-
//
|
|
190
|
-
// this.observer.resize.start();
|
|
191
|
-
// return this;
|
|
192
|
-
// }
|
|
193
|
-
// watchIntersection(callback,config){
|
|
194
|
-
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
195
|
-
// this.observer.intersection.start();
|
|
196
|
-
// return this;
|
|
197
|
-
// }
|
|
170
|
+
// watchSize(callback)Remplaced By on onViewResize
|
|
171
|
+
// watchIntersection(callback,config) Remplaced By onViewEnter and onViewExit
|
|
198
172
|
|
|
199
173
|
}
|
|
200
174
|
export { UIElement }
|
package/src/ui/suspense/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {UIElement} from "../
|
|
1
|
+
import {UIElement} from "../mini/UIElement.js";
|
|
2
2
|
class ZikoUISuspense extends UIElement{
|
|
3
3
|
constructor(fallback_ui, callback){
|
|
4
4
|
super({element : "div", name : "suspense"})
|
|
@@ -12,7 +12,6 @@ class ZikoUISuspense extends UIElement{
|
|
|
12
12
|
const ui = await callback()
|
|
13
13
|
fallback_ui.unmount()
|
|
14
14
|
this.append(ui)
|
|
15
|
-
// console.log(content)
|
|
16
15
|
}
|
|
17
16
|
catch(error){
|
|
18
17
|
console.log({error})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// fetchdom.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fetches a URL and parses it into a DOM Document asynchronously.
|
|
5
|
+
* @param url The URL to fetch. Defaults to 'https://github.com/zakarialaoui10'.
|
|
6
|
+
* @returns A Promise resolving to the root element of the parsed DOM.
|
|
7
|
+
*/
|
|
8
|
+
export function fetchdom(url?: string): Promise<Element>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Fetches a URL synchronously (using `preload`) and parses it into a DOM Document.
|
|
12
|
+
* @param url The URL to fetch. Defaults to 'https://github.com/zakarialaoui10'.
|
|
13
|
+
* @returns The root element of the parsed DOM.
|
|
14
|
+
*/
|
|
15
|
+
export function fetchdomSync(url?: string): Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './api/index.d.ts'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// stringUtils.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a string is in camelCase.
|
|
5
|
+
* @param text The string to check. Defaults to empty string.
|
|
6
|
+
* @returns True if the string is camelCase, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export function is_camelcase(text?: string): boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a string contains hyphens (hyphen-case).
|
|
12
|
+
* @param text The string to check. Defaults to empty string.
|
|
13
|
+
* @returns True if the string contains hyphens, false otherwise.
|
|
14
|
+
*/
|
|
15
|
+
export function is_hyphencase(text?: string): boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a string contains underscores (snake_case).
|
|
19
|
+
* @param text The string to check. Defaults to empty string.
|
|
20
|
+
* @returns True if the string contains underscores, false otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export function is_snakeCase(text?: string): boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a string is in PascalCase.
|
|
26
|
+
* @param text The string to check. Defaults to empty string.
|
|
27
|
+
* @returns True if the string is PascalCase, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
export function is_pascalcalse(text?: string): boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a string is a palindrome (case-insensitive).
|
|
33
|
+
* @param text The string to check.
|
|
34
|
+
* @returns True if the string is a palindrome, false otherwise.
|
|
35
|
+
*/
|
|
36
|
+
export function is_palindrome(text: string): boolean;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Checks if two words are anagrams of each other.
|
|
40
|
+
* @param word The first word.
|
|
41
|
+
* @param words The second word.
|
|
42
|
+
* @returns True if the words are anagrams, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
export function is_anagram(word: string, words: string): boolean;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Checks if a string is an isogram (no repeating letters, case-insensitive).
|
|
48
|
+
* @param text The string to check. Defaults to empty string.
|
|
49
|
+
* @returns True if the string is an isogram, false otherwise.
|
|
50
|
+
*/
|
|
51
|
+
export function is_isogram(text?: string): boolean;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts camelCase to hyphen-case.
|
|
3
|
+
* @param text The camelCase string. Defaults to ''.
|
|
4
|
+
* @returns The converted hyphen-case string.
|
|
5
|
+
*/
|
|
6
|
+
export function camel2hyphencase(text?: string): string;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Converts camelCase to snake_case.
|
|
10
|
+
*/
|
|
11
|
+
export function camel2snakecase(text?: string): string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Converts camelCase to PascalCase.
|
|
15
|
+
*/
|
|
16
|
+
export function camel2pascalcase(text?: string): string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Converts camelCase to CONSTANT_CASE.
|
|
20
|
+
*/
|
|
21
|
+
export function camel2constantcase(text?: string): string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Converts PascalCase to snake_case.
|
|
25
|
+
*/
|
|
26
|
+
export function pascal2snakecase(text?: string): string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Converts PascalCase to hyphen-case.
|
|
30
|
+
*/
|
|
31
|
+
export function pascal2hyphencase(text?: string): string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Converts PascalCase to camelCase.
|
|
35
|
+
*/
|
|
36
|
+
export function pascal2camelcase(text?: string): string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Converts PascalCase to CONSTANT_CASE.
|
|
40
|
+
*/
|
|
41
|
+
export function pascal2constantcase(text?: string): string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Converts snake_case to camelCase.
|
|
45
|
+
*/
|
|
46
|
+
export function snake2camelcase(text?: string): string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Converts snake_case to hyphen-case.
|
|
50
|
+
*/
|
|
51
|
+
export function snake2hyphencase(text?: string): string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Converts snake_case to PascalCase.
|
|
55
|
+
*/
|
|
56
|
+
export function snake2pascalcase(text?: string): string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Converts snake_case to CONSTANT_CASE.
|
|
60
|
+
*/
|
|
61
|
+
export function snake2constantcase(text?: string): string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Converts hyphen-case to camelCase.
|
|
65
|
+
*/
|
|
66
|
+
export function hyphen2camelcase(text?: string): string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Converts hyphen-case to snake_case.
|
|
70
|
+
*/
|
|
71
|
+
export function hyphen2snakecase(text?: string): string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Converts hyphen-case to PascalCase.
|
|
75
|
+
*/
|
|
76
|
+
export function hyphen2pascalcase(text?: string): string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Converts hyphen-case to CONSTANT_CASE.
|
|
80
|
+
*/
|
|
81
|
+
export function hyphen2constantcase(text?: string): string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Converts CONSTANT_CASE to camelCase.
|
|
85
|
+
*/
|
|
86
|
+
export function constant2camelcase(text?: string): string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Converts CONSTANT_CASE to snake_case.
|
|
90
|
+
*/
|
|
91
|
+
export function constant2snakecase(text?: string): string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Converts CONSTANT_CASE to PascalCase.
|
|
95
|
+
*/
|
|
96
|
+
export function constant2pascalcase(text?: string): string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Converts CONSTANT_CASE to hyphen-case.
|
|
100
|
+
*/
|
|
101
|
+
export function constant2hyphencase(text?: string): string;
|
package/types/index.d.ts
CHANGED