ziko 0.50.1 → 0.51.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.
- package/dist/ziko.cjs +772 -898
- package/dist/ziko.js +509 -240
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +506 -241
- package/package.json +1 -1
- package/src/__helpers__/checkers/index.js +1 -0
- package/src/data/api/fetchdom.js +27 -11
- package/src/events/binders/coordinates-based-event.js +25 -0
- package/src/events/binders/custom-event.js +1 -1
- package/src/events/binders/index.js +45 -12
- 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/customizers/normalise-coordinates.js +0 -0
- package/src/events/details-setter/index.js +3 -1
- package/src/events/details-setter/mouse.js +35 -0
- package/src/events/details-setter/pointer.js +33 -31
- package/src/events/details-setter/touch.js +37 -0
- 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/router/file-based-router/index.js +46 -0
- package/src/router/index.js +2 -0
- package/src/router/utils/dynamic-routes-parser.js +76 -0
- package/src/router/utils/get-root.js +16 -0
- package/src/router/utils/index.js +5 -0
- package/src/router/utils/normalize-path.js +17 -0
- package/src/router/utils/routes-grouper.js +22 -0
- package/src/router/utils/routes-matcher.js +60 -0
- 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 +3 -1
- package/types/router/file-based-router/index.d.ts +20 -0
- package/types/router/index.d.ts +2 -0
- package/types/router/utils/dynamic-routes-parser.d.ts +14 -0
- package/types/router/utils/get-root.d.ts +11 -0
- package/types/router/utils/index.d.ts +5 -0
- package/types/router/utils/normalize-path.d.ts +15 -0
- package/types/router/utils/routes-grouper.d.ts +29 -0
- package/types/router/utils/routes-matcher.d.ts +1 -0
|
@@ -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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// createSPAFileBasedRouter.d.ts
|
|
2
|
+
|
|
3
|
+
import { UIElement } from '../../../src/ui/constructors/UIElement.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a SPA (Single Page Application) file-based router.
|
|
7
|
+
* Automatically loads and mounts the component corresponding to the current path.
|
|
8
|
+
* Supports dynamic routes and parameter extraction.
|
|
9
|
+
*
|
|
10
|
+
* @param pages - An object mapping route paths to async module functions that return a component.
|
|
11
|
+
* Example: { "/user/[id]": () => import("./pages/user/[id].js") }
|
|
12
|
+
* @param target - Optional DOM element to mount the component. Defaults to `document.body`.
|
|
13
|
+
*/
|
|
14
|
+
export function createSPAFileBasedRouter(
|
|
15
|
+
pages: Record<
|
|
16
|
+
string,
|
|
17
|
+
() => Promise<{ default: (param? : Record<string, string>) => UIElement }>
|
|
18
|
+
>,
|
|
19
|
+
target?: HTMLElement | UIElement
|
|
20
|
+
): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// dynamic_routes_parser.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses a route according to a dynamic mask and returns extracted parameters.
|
|
5
|
+
*
|
|
6
|
+
* @param mask - The dynamic route mask (e.g., "/user/[id]+", "/blog/[...slug]").
|
|
7
|
+
* @param route - The actual route to parse (e.g., "/user/42", "/blog/2025/oct/post").
|
|
8
|
+
* @returns An object mapping parameter names to their corresponding values.
|
|
9
|
+
* Returns an empty object if the route does not match the mask.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dynamic_routes_parser(
|
|
12
|
+
mask: string,
|
|
13
|
+
route: string
|
|
14
|
+
): Record<string, string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// get_root.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Finds the common root path among an array of paths.
|
|
5
|
+
* Dynamic segments (e.g., `[id]`) are considered as matching any segment.
|
|
6
|
+
*
|
|
7
|
+
* @param paths - An array of route paths (e.g., ["/user/42", "/user/99"]).
|
|
8
|
+
* @returns The common root path as a string (e.g., "/user/").
|
|
9
|
+
* Returns an empty string if no common root exists.
|
|
10
|
+
*/
|
|
11
|
+
export declare function get_root(paths: string[]): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// normalize_path.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a file path into a route path.
|
|
5
|
+
*
|
|
6
|
+
* @param inputPath - The file path to normalize (e.g., "./src/pages/user/[id].ts").
|
|
7
|
+
* @param root - The root directory to consider as the base (default: "./src/pages").
|
|
8
|
+
* @param extensions - Array of valid file extensions (default: ["js", "ts"]).
|
|
9
|
+
* @returns A normalized route path (e.g., "/user/[id]") or an empty string if it cannot be normalized.
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalize_path(
|
|
12
|
+
inputPath: string,
|
|
13
|
+
root?: string,
|
|
14
|
+
extensions?: string[]
|
|
15
|
+
): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// routes_utils.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a route path is dynamic.
|
|
5
|
+
* Dynamic segments include:
|
|
6
|
+
* - Parameters like "[id]"
|
|
7
|
+
* - Catch-all segments like "[...slug]"
|
|
8
|
+
* - Optional segments like "[id]+"
|
|
9
|
+
*
|
|
10
|
+
* @param path - The route path to check.
|
|
11
|
+
* @returns `true` if the path is dynamic, otherwise `false`.
|
|
12
|
+
*/
|
|
13
|
+
export function is_dynamic(path: string): boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Groups routes into static and dynamic categories.
|
|
17
|
+
* Throws an error if an optional parameter appears anywhere but the end of the path.
|
|
18
|
+
*
|
|
19
|
+
* @param routeMap - An object mapping route paths to their handlers/values.
|
|
20
|
+
* @returns An object with two properties:
|
|
21
|
+
* - `static`: Routes with no dynamic segments.
|
|
22
|
+
* - `dynamic`: Routes with dynamic segments.
|
|
23
|
+
*/
|
|
24
|
+
export function routes_grouper<T>(
|
|
25
|
+
routeMap: Record<string, T>
|
|
26
|
+
): {
|
|
27
|
+
static: Record<string, T>;
|
|
28
|
+
dynamic: Record<string, T>;
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function routes_matcher(mask: string, route: string): boolean;
|