@ktjs/shared 0.23.11 → 0.23.12
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/index.d.ts +199 -179
- package/dist/index.mjs +109 -172
- package/package.json +1 -1
- package/LICENSE +0 -21
- package/dist/index.iife.js +0 -263
- package/dist/index.legacy.js +0 -348
package/dist/index.d.ts
CHANGED
|
@@ -1,179 +1,199 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
declare const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<T>(
|
|
19
|
-
<T, U>(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<T extends {}, U
|
|
26
|
-
(target:
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
declare const $
|
|
32
|
-
|
|
33
|
-
declare const $
|
|
34
|
-
|
|
35
|
-
declare const $
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
*/
|
|
107
|
-
declare const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
declare
|
|
115
|
-
|
|
116
|
-
declare
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
*/
|
|
141
|
-
declare const
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
*
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
1
|
+
export declare const $append: typeof originAppend;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* & Remove `bind` because it is shockingly slower than wrapper
|
|
5
|
+
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
6
|
+
*/
|
|
7
|
+
export declare const $appendChild: <T extends Node>(node: T) => T;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Used for `k-model`
|
|
11
|
+
*/
|
|
12
|
+
export declare const $applyModel: (element: HTMLElementTagNameMap[InputElementTag], valueRef: {
|
|
13
|
+
value: unknown;
|
|
14
|
+
addOnChange: (fn: (newValue: unknown) => void) => void;
|
|
15
|
+
}, propName: "value" | "checked", eventName: "change" | "input") => void;
|
|
16
|
+
|
|
17
|
+
export declare const $ArrayFrom: {
|
|
18
|
+
<T>(arrayLike: ArrayLike<T>): T[];
|
|
19
|
+
<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
20
|
+
<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
21
|
+
<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export declare const $assign: {
|
|
25
|
+
<T extends {}, U>(target: T, source: U): T & U;
|
|
26
|
+
<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
|
|
27
|
+
<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
|
28
|
+
(target: object, ...sources: any[]): any;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export declare const $buttonDisabledGetter: () => any;
|
|
32
|
+
|
|
33
|
+
export declare const $buttonDisabledSetter: (v: any) => void;
|
|
34
|
+
|
|
35
|
+
export declare const $define: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
|
|
36
|
+
|
|
37
|
+
export declare const $defines: <T>(o: T, properties: PropertyDescriptorMap & ThisType<any>) => T;
|
|
38
|
+
|
|
39
|
+
export declare const $emptyArray: any[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Default empty function
|
|
43
|
+
*/
|
|
44
|
+
export declare const $emptyFn: (...args: any[]) => any;
|
|
45
|
+
|
|
46
|
+
export declare const $emptyObject: any;
|
|
47
|
+
|
|
48
|
+
export declare const $entries: <T>(o: T) => Array<[keyof T, T[keyof T]]>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Safe and quick forEach implementation that works with array-like objects and handles sparse arrays.
|
|
52
|
+
*/
|
|
53
|
+
export declare const $forEach: (array: unknown[], callback: (item: unknown, index: number, array: unknown[]) => void) => void;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Async version of $forEach that allows for asynchronous callbacks. It processes items sequentially, awaiting each callback before moving to the next.
|
|
57
|
+
*/
|
|
58
|
+
export declare const $forEachAsync: (array: unknown[], callback: (item: unknown, index: number, array: unknown[]) => void) => Promise<void>;
|
|
59
|
+
|
|
60
|
+
export declare const $hasOwn: (v: PropertyKey) => boolean;
|
|
61
|
+
|
|
62
|
+
export declare const $is: (value1: any, value2: any) => boolean;
|
|
63
|
+
|
|
64
|
+
export declare const $isArray: (arg: any) => arg is any[];
|
|
65
|
+
|
|
66
|
+
export declare const $isNode: (x: any) => x is ChildNode;
|
|
67
|
+
|
|
68
|
+
export declare const $isSame: (a: unknown, b: unknown) => boolean;
|
|
69
|
+
|
|
70
|
+
export declare const $isThenable: (o: any) => o is Promise<any>;
|
|
71
|
+
|
|
72
|
+
export declare const $keys: <T>(o: T) => Array<keyof T>;
|
|
73
|
+
|
|
74
|
+
export declare const $parseStyle: (style: unknown) => string;
|
|
75
|
+
|
|
76
|
+
export declare const $random: () => number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Safe replace `oldNode` With `newNode`
|
|
80
|
+
*/
|
|
81
|
+
export declare const $replaceNode: (oldNode: unknown, newNode: unknown) => void;
|
|
82
|
+
|
|
83
|
+
export declare const $toString: () => string;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Build query string from object
|
|
87
|
+
*/
|
|
88
|
+
export declare const buildQuery: (query: Record<string, string>) => string;
|
|
89
|
+
|
|
90
|
+
export declare type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* These fields of HTMLElement can trigger `change`.
|
|
94
|
+
*/
|
|
95
|
+
export declare type ChangeTriggerField = 'value' | 'checked' | 'selected' | 'valueAsDate' | 'valueAsNumber';
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Substitute params into path pattern
|
|
99
|
+
* @example '/user/:id' + {id: '123'} => '/user/123'
|
|
100
|
+
*/
|
|
101
|
+
export declare const emplaceParams: (path: string, params: Record<string, string>) => string;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Extract dynamic params from path using pattern
|
|
105
|
+
* @example pattern: '/user/:id', path: '/user/123' => {id: '123'}
|
|
106
|
+
*/
|
|
107
|
+
export declare const extractParams: (pattern: string, path: string) => Record<string, string> | null;
|
|
108
|
+
|
|
109
|
+
export declare type HTMLJSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Normal HTML tags like `div`, `span`, `a`, etc.
|
|
113
|
+
*/
|
|
114
|
+
export declare type HTMLTag = keyof HTMLElementTagNameMap;
|
|
115
|
+
|
|
116
|
+
export declare type InputElementTag = 'input' | 'select' | 'textarea';
|
|
117
|
+
|
|
118
|
+
export declare type JSXTag = HTMLJSXTag | SVGJSXTag | MathMLJSXTag;
|
|
119
|
+
|
|
120
|
+
export declare interface KTReactiveLike<T = unknown> {
|
|
121
|
+
isKT: true;
|
|
122
|
+
value: T;
|
|
123
|
+
addOnChange(fn: (newValue: T, oldValue: T) => void): void;
|
|
124
|
+
removeOnChange?(fn: (newValue: T, oldValue: T) => void): boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export declare type MathMLJSXTag = HTMLTag | ((props?: any) => MathMLElement) | ((props?: any) => Promise<MathMLElement>);
|
|
128
|
+
|
|
129
|
+
export declare type MathMLTag = keyof MathMLElementTagNameMap;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Get the tags that makes HTMLElementTagNameMap[tag] = HTMLElement
|
|
133
|
+
*/
|
|
134
|
+
export declare type NonSpecialTags = {
|
|
135
|
+
[K in keyof HTMLElementTagNameMap]: HTMLElement extends HTMLElementTagNameMap[K] ? K : never;
|
|
136
|
+
}[keyof HTMLElementTagNameMap];
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Normalize path by joining parts and ensuring leading slash
|
|
140
|
+
*/
|
|
141
|
+
export declare const normalizePath: (...paths: string[]) => string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* This is tested on 15 browsers (most popular ones)
|
|
145
|
+
* - appending a text node to these tags takes no effect.
|
|
146
|
+
* - No effect means `innerText` does not include the text in the text node.
|
|
147
|
+
* @see {@link src/core/h/no-text-node.ts}
|
|
148
|
+
*/
|
|
149
|
+
export declare type NoTextNodeTag =
|
|
150
|
+
| 'area'
|
|
151
|
+
| 'audio'
|
|
152
|
+
| 'base'
|
|
153
|
+
| 'basefont'
|
|
154
|
+
| 'br'
|
|
155
|
+
| 'canvas'
|
|
156
|
+
| 'datalist'
|
|
157
|
+
| 'details'
|
|
158
|
+
| 'dialog'
|
|
159
|
+
| 'frameset'
|
|
160
|
+
| 'head'
|
|
161
|
+
| 'iframe'
|
|
162
|
+
| 'img'
|
|
163
|
+
| 'input'
|
|
164
|
+
| 'link'
|
|
165
|
+
| 'meta'
|
|
166
|
+
| 'meter'
|
|
167
|
+
| 'noembed'
|
|
168
|
+
| 'noframes'
|
|
169
|
+
| 'noscript'
|
|
170
|
+
| 'optgroup'
|
|
171
|
+
| 'param'
|
|
172
|
+
| 'progress'
|
|
173
|
+
| 'rp'
|
|
174
|
+
| 'select'
|
|
175
|
+
| 'style'
|
|
176
|
+
| 'template'
|
|
177
|
+
| 'textarea'
|
|
178
|
+
| 'title'
|
|
179
|
+
| 'video'
|
|
180
|
+
| 'wbr'
|
|
181
|
+
| 'embed'
|
|
182
|
+
| 'frame'
|
|
183
|
+
| 'keygen'
|
|
184
|
+
| 'option';
|
|
185
|
+
|
|
186
|
+
declare const originAppend: (...nodes: (Node | string)[]) => void;
|
|
187
|
+
|
|
188
|
+
export declare type otherstring = string & {};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Parse query string into object
|
|
192
|
+
*/
|
|
193
|
+
export declare const parseQuery: (queryString: string) => Record<string, string>;
|
|
194
|
+
|
|
195
|
+
export declare type SVGJSXTag = HTMLTag | ((props?: any) => SVGElement) | ((props?: any) => Promise<SVGElement>);
|
|
196
|
+
|
|
197
|
+
export declare type SVGTag = keyof SVGElementTagNameMap;
|
|
198
|
+
|
|
199
|
+
export { }
|