@ktjs/shared 0.20.1 → 0.20.3
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 +75 -2
- package/dist/index.iife.js +10 -1
- package/dist/index.legacy.js +10 -1
- package/dist/index.mjs +10 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,72 @@ declare const $isThenable: (o: any) => o is Promise<any>;
|
|
|
22
22
|
|
|
23
23
|
declare const $throw: (message: string) => never;
|
|
24
24
|
|
|
25
|
+
type otherstring = string & {};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Normal HTML tags like `div`, `span`, `a`, etc.
|
|
29
|
+
*/
|
|
30
|
+
type HTMLTag = keyof HTMLElementTagNameMap;
|
|
31
|
+
type SVGTag = keyof SVGElementTagNameMap;
|
|
32
|
+
type MathMLTag = keyof MathMLElementTagNameMap;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get the tags that makes HTMLElementTagNameMap[tag] = HTMLElement
|
|
36
|
+
*/
|
|
37
|
+
type NonSpecialTags = {
|
|
38
|
+
[K in keyof HTMLElementTagNameMap]: HTMLElement extends HTMLElementTagNameMap[K] ? K : never;
|
|
39
|
+
}[keyof HTMLElementTagNameMap];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* This is tested on 15 browsers (most popular ones)
|
|
43
|
+
* - appending a text node to these tags takes no effect.
|
|
44
|
+
* - No effect means `innerText` does not include the text in the text node.
|
|
45
|
+
* @see {@link src/core/h/no-text-node.ts}
|
|
46
|
+
*/
|
|
47
|
+
type NoTextNodeTag =
|
|
48
|
+
| 'area'
|
|
49
|
+
| 'audio'
|
|
50
|
+
| 'base'
|
|
51
|
+
| 'basefont'
|
|
52
|
+
| 'br'
|
|
53
|
+
| 'canvas'
|
|
54
|
+
| 'datalist'
|
|
55
|
+
| 'details'
|
|
56
|
+
| 'dialog'
|
|
57
|
+
| 'frameset'
|
|
58
|
+
| 'head'
|
|
59
|
+
| 'iframe'
|
|
60
|
+
| 'img'
|
|
61
|
+
| 'input'
|
|
62
|
+
| 'link'
|
|
63
|
+
| 'meta'
|
|
64
|
+
| 'meter'
|
|
65
|
+
| 'noembed'
|
|
66
|
+
| 'noframes'
|
|
67
|
+
| 'noscript'
|
|
68
|
+
| 'optgroup'
|
|
69
|
+
| 'param'
|
|
70
|
+
| 'progress'
|
|
71
|
+
| 'rp'
|
|
72
|
+
| 'select'
|
|
73
|
+
| 'style'
|
|
74
|
+
| 'template'
|
|
75
|
+
| 'textarea'
|
|
76
|
+
| 'title'
|
|
77
|
+
| 'video'
|
|
78
|
+
| 'wbr'
|
|
79
|
+
| 'embed'
|
|
80
|
+
| 'frame'
|
|
81
|
+
| 'keygen'
|
|
82
|
+
| 'option';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* These fields of HTMLElement can trigger `change`.
|
|
86
|
+
*/
|
|
87
|
+
type ChangeTriggerField = 'value' | 'checked' | 'selected' | 'valueAsDate' | 'valueAsNumber';
|
|
88
|
+
|
|
89
|
+
type InputElementTag = 'input' | 'select' | 'textarea';
|
|
90
|
+
|
|
25
91
|
/**
|
|
26
92
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
27
93
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -34,6 +100,13 @@ declare const $buttonDisabledSetter: (v: any) => void;
|
|
|
34
100
|
declare const parseStyle: (style: string | Partial<CSSStyleDeclaration> | undefined) => string;
|
|
35
101
|
type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
|
|
36
102
|
declare const generateHandler: <T = string>(props: any, key: string) => ChangeHandler<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Used for `k-model`
|
|
105
|
+
*/
|
|
106
|
+
declare const applyModel: (element: HTMLElementTagNameMap[InputElementTag], valueRef: {
|
|
107
|
+
value: unknown;
|
|
108
|
+
addOnChange: (fn: (newValue: unknown) => void) => void;
|
|
109
|
+
}, propName: "value" | "checked", eventName: "change" | "input") => void;
|
|
37
110
|
|
|
38
111
|
/**
|
|
39
112
|
* Default empty function
|
|
@@ -63,5 +136,5 @@ declare const emplaceParams: (path: string, params: Record<string, string>) => s
|
|
|
63
136
|
*/
|
|
64
137
|
declare const extractParams: (pattern: string, path: string) => Record<string, string> | null;
|
|
65
138
|
|
|
66
|
-
export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $hasOwn, $is, $isArray, $isThenable, $keys, $throw, $toString, buildQuery, emplaceParams, extractParams, generateHandler, normalizePath, parseQuery, parseStyle };
|
|
67
|
-
export type { ChangeHandler };
|
|
139
|
+
export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $hasOwn, $is, $isArray, $isThenable, $keys, $throw, $toString, applyModel, buildQuery, emplaceParams, extractParams, generateHandler, normalizePath, parseQuery, parseStyle };
|
|
140
|
+
export type { ChangeHandler, ChangeTriggerField, HTMLTag, InputElementTag, MathMLTag, NoTextNodeTag, NonSpecialTags, SVGTag, otherstring };
|
package/dist/index.iife.js
CHANGED
|
@@ -89,6 +89,14 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
89
89
|
}
|
|
90
90
|
return $emptyFn;
|
|
91
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Used for `k-model`
|
|
94
|
+
*/
|
|
95
|
+
const applyModel = (element, valueRef, propName, eventName) => {
|
|
96
|
+
element[propName] = valueRef.value; // initialize
|
|
97
|
+
valueRef.addOnChange((newValue) => (element[propName] = newValue));
|
|
98
|
+
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
99
|
+
};
|
|
92
100
|
|
|
93
101
|
/**
|
|
94
102
|
* Normalize path by joining parts and ensuring leading slash
|
|
@@ -165,7 +173,7 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
165
173
|
|
|
166
174
|
// Shared utilities and cached native methods for kt.js framework
|
|
167
175
|
// Re-export all utilities
|
|
168
|
-
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.
|
|
176
|
+
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.3' });
|
|
169
177
|
|
|
170
178
|
exports.$ArrayFrom = $ArrayFrom;
|
|
171
179
|
exports.$append = $append;
|
|
@@ -184,6 +192,7 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
184
192
|
exports.$keys = $keys;
|
|
185
193
|
exports.$throw = $throw;
|
|
186
194
|
exports.$toString = $toString;
|
|
195
|
+
exports.applyModel = applyModel;
|
|
187
196
|
exports.buildQuery = buildQuery;
|
|
188
197
|
exports.emplaceParams = emplaceParams;
|
|
189
198
|
exports.extractParams = extractParams;
|
package/dist/index.legacy.js
CHANGED
|
@@ -97,6 +97,14 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
97
97
|
}
|
|
98
98
|
return $emptyFn;
|
|
99
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* Used for `k-model`
|
|
102
|
+
*/
|
|
103
|
+
var applyModel = function (element, valueRef, propName, eventName) {
|
|
104
|
+
element[propName] = valueRef.value; // initialize
|
|
105
|
+
valueRef.addOnChange(function (newValue) { return (element[propName] = newValue); });
|
|
106
|
+
element.addEventListener(eventName, function () { return (valueRef.value = element[propName]); });
|
|
107
|
+
};
|
|
100
108
|
|
|
101
109
|
/**
|
|
102
110
|
* Normalize path by joining parts and ensuring leading slash
|
|
@@ -178,7 +186,7 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
178
186
|
|
|
179
187
|
// Shared utilities and cached native methods for kt.js framework
|
|
180
188
|
// Re-export all utilities
|
|
181
|
-
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.
|
|
189
|
+
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.3' });
|
|
182
190
|
|
|
183
191
|
exports.$ArrayFrom = $ArrayFrom;
|
|
184
192
|
exports.$append = $append;
|
|
@@ -197,6 +205,7 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
197
205
|
exports.$keys = $keys;
|
|
198
206
|
exports.$throw = $throw;
|
|
199
207
|
exports.$toString = $toString;
|
|
208
|
+
exports.applyModel = applyModel;
|
|
200
209
|
exports.buildQuery = buildQuery;
|
|
201
210
|
exports.emplaceParams = emplaceParams;
|
|
202
211
|
exports.extractParams = extractParams;
|
package/dist/index.mjs
CHANGED
|
@@ -86,6 +86,14 @@ const generateHandler = (props, key) => {
|
|
|
86
86
|
}
|
|
87
87
|
return $emptyFn;
|
|
88
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Used for `k-model`
|
|
91
|
+
*/
|
|
92
|
+
const applyModel = (element, valueRef, propName, eventName) => {
|
|
93
|
+
element[propName] = valueRef.value; // initialize
|
|
94
|
+
valueRef.addOnChange((newValue) => (element[propName] = newValue));
|
|
95
|
+
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
96
|
+
};
|
|
89
97
|
|
|
90
98
|
/**
|
|
91
99
|
* Normalize path by joining parts and ensuring leading slash
|
|
@@ -162,6 +170,6 @@ const extractParams = (pattern, path) => {
|
|
|
162
170
|
|
|
163
171
|
// Shared utilities and cached native methods for kt.js framework
|
|
164
172
|
// Re-export all utilities
|
|
165
|
-
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.
|
|
173
|
+
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.3' });
|
|
166
174
|
|
|
167
|
-
export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $hasOwn, $is, $isArray, $isThenable, $keys, $throw, $toString, buildQuery, emplaceParams, extractParams, generateHandler, normalizePath, parseQuery, parseStyle };
|
|
175
|
+
export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $hasOwn, $is, $isArray, $isThenable, $keys, $throw, $toString, applyModel, buildQuery, emplaceParams, extractParams, generateHandler, normalizePath, parseQuery, parseStyle };
|