@ktjs/core 0.6.17 → 0.7.1
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 +4 -7
- package/dist/index.iife.js +19 -5
- package/dist/index.legacy.js +19 -5
- package/dist/index.mjs +19 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ type otherstring = string & {};
|
|
|
22
22
|
*/
|
|
23
23
|
type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
|
|
24
24
|
|
|
25
|
-
type
|
|
25
|
+
type Ctt = HTMLElement | string | number | undefined;
|
|
26
|
+
type KTRawContent = (Ctt | (() => Ctt))[] | Ctt;
|
|
26
27
|
type KTRawAttr = KTAttribute | string;
|
|
27
28
|
type KTRawContents = (HTMLElement | string | undefined)[];
|
|
28
29
|
|
|
@@ -85,15 +86,11 @@ interface KTBaseAttribute {
|
|
|
85
86
|
method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
type KTEventHandlersOrAttribute = {
|
|
89
|
-
[EventName in keyof HTMLElementEventMap]?: ((ev: HTMLElementEventMap[EventName]) => void) | string;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
89
|
type KTPrefixedEventHandlers = {
|
|
93
90
|
[EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
|
|
94
91
|
};
|
|
95
92
|
|
|
96
|
-
type KTAttribute = KTBaseAttribute &
|
|
93
|
+
type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
|
|
97
94
|
|
|
98
95
|
type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
|
|
99
96
|
/**
|
|
@@ -106,7 +103,7 @@ type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagN
|
|
|
106
103
|
* ## About
|
|
107
104
|
* @package @ktjs/core
|
|
108
105
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
109
|
-
* @version 0.
|
|
106
|
+
* @version 0.7.1 (Last Update: 2025.12.25 09:44:03.948)
|
|
110
107
|
* @license MIT
|
|
111
108
|
* @link https://github.com/baendlorel/kt.js
|
|
112
109
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.iife.js
CHANGED
|
@@ -149,11 +149,11 @@ var __ktjs_core__ = (function (exports) {
|
|
|
149
149
|
element.addEventListener(key.slice(3), o); // chop off the `@`
|
|
150
150
|
continue;
|
|
151
151
|
}
|
|
152
|
-
if (typeof o
|
|
153
|
-
(handlers[key] || defaultHandler)(element, key, o);
|
|
152
|
+
if (typeof o === 'function') {
|
|
153
|
+
(handlers[key] || defaultHandler)(element, key, o());
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
|
-
|
|
156
|
+
(handlers[key] || defaultHandler)(element, key, o);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
if (classValue !== undefined) {
|
|
@@ -176,8 +176,22 @@ var __ktjs_core__ = (function (exports) {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
function applyContent(element, content) {
|
|
179
|
+
if (typeof content === 'function') {
|
|
180
|
+
content = content();
|
|
181
|
+
}
|
|
179
182
|
if ($isArray(content)) {
|
|
180
|
-
|
|
183
|
+
for (let i = 0; i < content.length; i++) {
|
|
184
|
+
let c = content[i];
|
|
185
|
+
if (typeof c === 'function') {
|
|
186
|
+
c = c();
|
|
187
|
+
}
|
|
188
|
+
else if (typeof c === 'number') {
|
|
189
|
+
$append.call(element, c.toString());
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
$append.call(element, c);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
181
195
|
}
|
|
182
196
|
else {
|
|
183
197
|
if (typeof content === 'number') {
|
|
@@ -199,7 +213,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
199
213
|
* ## About
|
|
200
214
|
* @package @ktjs/core
|
|
201
215
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
202
|
-
* @version 0.
|
|
216
|
+
* @version 0.7.1 (Last Update: 2025.12.25 09:44:03.948)
|
|
203
217
|
* @license MIT
|
|
204
218
|
* @link https://github.com/baendlorel/kt.js
|
|
205
219
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.legacy.js
CHANGED
|
@@ -160,11 +160,11 @@ var __ktjs_core__ = (function (exports) {
|
|
|
160
160
|
element.addEventListener(key.slice(3), o); // chop off the `@`
|
|
161
161
|
continue;
|
|
162
162
|
}
|
|
163
|
-
if (typeof o
|
|
164
|
-
(handlers[key] || defaultHandler)(element, key, o);
|
|
163
|
+
if (typeof o === 'function') {
|
|
164
|
+
(handlers[key] || defaultHandler)(element, key, o());
|
|
165
165
|
}
|
|
166
166
|
else {
|
|
167
|
-
|
|
167
|
+
(handlers[key] || defaultHandler)(element, key, o);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
if (classValue !== undefined) {
|
|
@@ -187,8 +187,22 @@ var __ktjs_core__ = (function (exports) {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
function applyContent(element, content) {
|
|
190
|
+
if (typeof content === 'function') {
|
|
191
|
+
content = content();
|
|
192
|
+
}
|
|
190
193
|
if ($isArray(content)) {
|
|
191
|
-
|
|
194
|
+
for (var i = 0; i < content.length; i++) {
|
|
195
|
+
var c = content[i];
|
|
196
|
+
if (typeof c === 'function') {
|
|
197
|
+
c = c();
|
|
198
|
+
}
|
|
199
|
+
else if (typeof c === 'number') {
|
|
200
|
+
$append.call(element, c.toString());
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
$append.call(element, c);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
192
206
|
}
|
|
193
207
|
else {
|
|
194
208
|
if (typeof content === 'number') {
|
|
@@ -210,7 +224,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
210
224
|
* ## About
|
|
211
225
|
* @package @ktjs/core
|
|
212
226
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
213
|
-
* @version 0.
|
|
227
|
+
* @version 0.7.1 (Last Update: 2025.12.25 09:44:03.948)
|
|
214
228
|
* @license MIT
|
|
215
229
|
* @link https://github.com/baendlorel/kt.js
|
|
216
230
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.mjs
CHANGED
|
@@ -146,11 +146,11 @@ function attrIsObject(element, attr) {
|
|
|
146
146
|
element.addEventListener(key.slice(3), o); // chop off the `@`
|
|
147
147
|
continue;
|
|
148
148
|
}
|
|
149
|
-
if (typeof o
|
|
150
|
-
(handlers[key] || defaultHandler)(element, key, o);
|
|
149
|
+
if (typeof o === 'function') {
|
|
150
|
+
(handlers[key] || defaultHandler)(element, key, o());
|
|
151
151
|
}
|
|
152
152
|
else {
|
|
153
|
-
|
|
153
|
+
(handlers[key] || defaultHandler)(element, key, o);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
if (classValue !== undefined) {
|
|
@@ -173,8 +173,22 @@ function applyAttr(element, attr) {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
function applyContent(element, content) {
|
|
176
|
+
if (typeof content === 'function') {
|
|
177
|
+
content = content();
|
|
178
|
+
}
|
|
176
179
|
if ($isArray(content)) {
|
|
177
|
-
|
|
180
|
+
for (let i = 0; i < content.length; i++) {
|
|
181
|
+
let c = content[i];
|
|
182
|
+
if (typeof c === 'function') {
|
|
183
|
+
c = c();
|
|
184
|
+
}
|
|
185
|
+
else if (typeof c === 'number') {
|
|
186
|
+
$append.call(element, c.toString());
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
$append.call(element, c);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
178
192
|
}
|
|
179
193
|
else {
|
|
180
194
|
if (typeof content === 'number') {
|
|
@@ -196,7 +210,7 @@ function applyContent(element, content) {
|
|
|
196
210
|
* ## About
|
|
197
211
|
* @package @ktjs/core
|
|
198
212
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
199
|
-
* @version 0.
|
|
213
|
+
* @version 0.7.1 (Last Update: 2025.12.25 09:44:03.948)
|
|
200
214
|
* @license MIT
|
|
201
215
|
* @link https://github.com/baendlorel/kt.js
|
|
202
216
|
* @link https://baendlorel.github.io/ Welcome to my site!
|