kt.js 0.22.0 → 0.22.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/jsx-runtime.mjs +29 -22
- package/package.json +2 -2
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
const $isArray = Array.isArray;
|
|
3
3
|
const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
throw new Error('@ktjs/shared: ' + message);
|
|
8
|
-
};
|
|
5
|
+
// DOM manipulation utilities
|
|
6
|
+
// # dom natives
|
|
9
7
|
/**
|
|
10
8
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
11
9
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -42,10 +40,18 @@ const $append = // for ie 9/10/11
|
|
|
42
40
|
}
|
|
43
41
|
};
|
|
44
42
|
const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
43
|
+
/**
|
|
44
|
+
* Used for `k-model`
|
|
45
|
+
*/
|
|
46
|
+
const applyModel = (element, valueRef, propName, eventName) => {
|
|
47
|
+
element[propName] = valueRef.value; // initialize
|
|
48
|
+
valueRef.addOnChange((newValue) => (element[propName] = newValue));
|
|
49
|
+
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
50
|
+
};
|
|
45
51
|
|
|
46
52
|
// Shared utilities and cached native methods for kt.js framework
|
|
47
53
|
// Re-export all utilities
|
|
48
|
-
Object.defineProperty(window, '
|
|
54
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.2' });
|
|
49
55
|
|
|
50
56
|
class KTRef {
|
|
51
57
|
/**
|
|
@@ -200,7 +206,7 @@ function applyAttr(element, attr) {
|
|
|
200
206
|
attrIsObject(element, attr);
|
|
201
207
|
}
|
|
202
208
|
else {
|
|
203
|
-
throw new Error('kt.js
|
|
209
|
+
throw new Error('[kt.js error] attr must be an object.');
|
|
204
210
|
}
|
|
205
211
|
}
|
|
206
212
|
|
|
@@ -255,27 +261,28 @@ function applyContent(element, content) {
|
|
|
255
261
|
}
|
|
256
262
|
}
|
|
257
263
|
|
|
258
|
-
function
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
function applyModel(element, valueRef) {
|
|
264
|
+
function applyKModel(element, valueRef) {
|
|
265
|
+
if (!isKTRef(valueRef)) {
|
|
266
|
+
console.warn('[kt.js warn] k-model value must be a KTRef.');
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
264
269
|
if (element instanceof HTMLInputElement) {
|
|
265
270
|
if (element.type === 'radio' || element.type === 'checkbox') {
|
|
266
|
-
|
|
271
|
+
applyModel(element, valueRef, 'checked', 'change');
|
|
267
272
|
}
|
|
268
273
|
else {
|
|
269
|
-
|
|
274
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
270
275
|
}
|
|
271
276
|
}
|
|
272
277
|
else if (element instanceof HTMLSelectElement) {
|
|
273
|
-
|
|
278
|
+
applyModel(element, valueRef, 'value', 'change');
|
|
274
279
|
}
|
|
275
280
|
else if (element instanceof HTMLTextAreaElement) {
|
|
276
|
-
|
|
281
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
console.warn('[kt.js warn] not supported element for k-model:');
|
|
277
285
|
}
|
|
278
|
-
console.warn('[kt.js warn] not supported element for k-model:', element.tagName);
|
|
279
286
|
}
|
|
280
287
|
|
|
281
288
|
const htmlCreator = (tag) => document.createElement(tag);
|
|
@@ -295,7 +302,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
295
302
|
* ## About
|
|
296
303
|
* @package @ktjs/core
|
|
297
304
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
298
|
-
* @version 0.22.
|
|
305
|
+
* @version 0.22.2 (Last Update: 2026.02.02 20:28:37.901)
|
|
299
306
|
* @license MIT
|
|
300
307
|
* @link https://github.com/baendlorel/kt.js
|
|
301
308
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -304,7 +311,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
304
311
|
*/
|
|
305
312
|
const h = (tag, attr, content) => {
|
|
306
313
|
if (typeof tag !== 'string') {
|
|
307
|
-
|
|
314
|
+
throw new Error('[kt.js error] tagName must be a string.');
|
|
308
315
|
}
|
|
309
316
|
if (attr) {
|
|
310
317
|
if (SVG_ATTR_FLAG in attr) {
|
|
@@ -327,10 +334,10 @@ const h = (tag, attr, content) => {
|
|
|
327
334
|
if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {
|
|
328
335
|
const kmodel = attr['k-model'];
|
|
329
336
|
if (isKTRef(kmodel)) {
|
|
330
|
-
|
|
337
|
+
applyKModel(element, kmodel);
|
|
331
338
|
}
|
|
332
339
|
else {
|
|
333
|
-
|
|
340
|
+
throw new Error('[kt.js error] k-model value must be a KTRef.');
|
|
334
341
|
}
|
|
335
342
|
}
|
|
336
343
|
return element;
|
|
@@ -385,7 +392,7 @@ function jsx(tag, props) {
|
|
|
385
392
|
* Note: kt.js doesn't have a real Fragment concept,
|
|
386
393
|
*/
|
|
387
394
|
function Fragment(_props) {
|
|
388
|
-
throw new Error("kt.js doesn't have a Fragment concept");
|
|
395
|
+
throw new Error("[kt.js error] doesn't have a Fragment concept");
|
|
389
396
|
// const { children } = props ?? {};
|
|
390
397
|
// if (!children) {
|
|
391
398
|
// return ;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kt.js",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Kasukabe Tsumugi",
|
|
6
6
|
"email": "futami16237@gmail.com"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
],
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@ktjs/core": "0.22.
|
|
44
|
+
"@ktjs/core": "0.22.2"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "rollup -c rollup.config.mjs",
|