@ktjs/core 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/index.d.ts +4 -2
- package/dist/index.iife.js +29 -22
- package/dist/index.legacy.js +29 -22
- package/dist/index.mjs +29 -22
- package/dist/jsx/index.d.ts +1 -1
- package/dist/jsx/index.mjs +29 -22
- package/dist/jsx/jsx-runtime.d.ts +1 -1
- package/dist/jsx/jsx-runtime.mjs +29 -22
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ type HTMLTag = keyof HTMLElementTagNameMap;
|
|
|
7
7
|
type SVGTag = keyof SVGElementTagNameMap;
|
|
8
8
|
type MathMLTag = keyof MathMLElementTagNameMap;
|
|
9
9
|
|
|
10
|
+
type InputElementTag = 'input' | 'select' | 'textarea';
|
|
11
|
+
|
|
10
12
|
type RefChangeHandler<T> = (newValue: T, oldValue: T) => void;
|
|
11
13
|
declare class KTRef<T> {
|
|
12
14
|
/**
|
|
@@ -160,7 +162,7 @@ type KTComponent = (
|
|
|
160
162
|
* ## About
|
|
161
163
|
* @package @ktjs/core
|
|
162
164
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
163
|
-
* @version 0.22.
|
|
165
|
+
* @version 0.22.2 (Last Update: 2026.02.02 20:28:37.901)
|
|
164
166
|
* @license MIT
|
|
165
167
|
* @link https://github.com/baendlorel/kt.js
|
|
166
168
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -1466,4 +1468,4 @@ interface KTForProps<T> {
|
|
|
1466
1468
|
declare function KTFor<T>(props: KTForProps<T>): KTForElement;
|
|
1467
1469
|
|
|
1468
1470
|
export { Fragment, KTAsync, KTFor, KTRef, h as createElement, createRedrawable, h, isKTRef, jsx, jsxDEV, jsxs, ref, surfaceRef };
|
|
1469
|
-
export type { EventHandler, HTMLTag, KTAttribute, KTForElement, KTForProps, KTRawAttr, KTRawContent, KTRawContents, KTSurfaceRef };
|
|
1471
|
+
export type { EventHandler, HTMLTag, InputElementTag, KTAttribute, KTForElement, KTForProps, KTRawAttr, KTRawContent, KTRawContents, KTSurfaceRef, MathMLTag, SVGTag };
|
package/dist/index.iife.js
CHANGED
|
@@ -6,10 +6,8 @@ var __ktjs_core__ = (function (exports) {
|
|
|
6
6
|
const $entries = Object.entries;
|
|
7
7
|
const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
throw new Error('@ktjs/shared: ' + message);
|
|
12
|
-
};
|
|
9
|
+
// DOM manipulation utilities
|
|
10
|
+
// # dom natives
|
|
13
11
|
/**
|
|
14
12
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
15
13
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -46,10 +44,18 @@ var __ktjs_core__ = (function (exports) {
|
|
|
46
44
|
}
|
|
47
45
|
};
|
|
48
46
|
const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
47
|
+
/**
|
|
48
|
+
* Used for `k-model`
|
|
49
|
+
*/
|
|
50
|
+
const applyModel = (element, valueRef, propName, eventName) => {
|
|
51
|
+
element[propName] = valueRef.value; // initialize
|
|
52
|
+
valueRef.addOnChange((newValue) => (element[propName] = newValue));
|
|
53
|
+
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
54
|
+
};
|
|
49
55
|
|
|
50
56
|
// Shared utilities and cached native methods for kt.js framework
|
|
51
57
|
// Re-export all utilities
|
|
52
|
-
Object.defineProperty(window, '
|
|
58
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.2' });
|
|
53
59
|
|
|
54
60
|
class KTRef {
|
|
55
61
|
/**
|
|
@@ -228,7 +234,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
228
234
|
attrIsObject(element, attr);
|
|
229
235
|
}
|
|
230
236
|
else {
|
|
231
|
-
throw new Error('kt.js
|
|
237
|
+
throw new Error('[kt.js error] attr must be an object.');
|
|
232
238
|
}
|
|
233
239
|
}
|
|
234
240
|
|
|
@@ -283,27 +289,28 @@ var __ktjs_core__ = (function (exports) {
|
|
|
283
289
|
}
|
|
284
290
|
}
|
|
285
291
|
|
|
286
|
-
function
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
function applyModel(element, valueRef) {
|
|
292
|
+
function applyKModel(element, valueRef) {
|
|
293
|
+
if (!isKTRef(valueRef)) {
|
|
294
|
+
console.warn('[kt.js warn] k-model value must be a KTRef.');
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
292
297
|
if (element instanceof HTMLInputElement) {
|
|
293
298
|
if (element.type === 'radio' || element.type === 'checkbox') {
|
|
294
|
-
|
|
299
|
+
applyModel(element, valueRef, 'checked', 'change');
|
|
295
300
|
}
|
|
296
301
|
else {
|
|
297
|
-
|
|
302
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
298
303
|
}
|
|
299
304
|
}
|
|
300
305
|
else if (element instanceof HTMLSelectElement) {
|
|
301
|
-
|
|
306
|
+
applyModel(element, valueRef, 'value', 'change');
|
|
302
307
|
}
|
|
303
308
|
else if (element instanceof HTMLTextAreaElement) {
|
|
304
|
-
|
|
309
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
console.warn('[kt.js warn] not supported element for k-model:');
|
|
305
313
|
}
|
|
306
|
-
console.warn('[kt.js warn] not supported element for k-model:', element.tagName);
|
|
307
314
|
}
|
|
308
315
|
|
|
309
316
|
const htmlCreator = (tag) => document.createElement(tag);
|
|
@@ -323,7 +330,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
323
330
|
* ## About
|
|
324
331
|
* @package @ktjs/core
|
|
325
332
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
326
|
-
* @version 0.22.
|
|
333
|
+
* @version 0.22.2 (Last Update: 2026.02.02 20:28:37.901)
|
|
327
334
|
* @license MIT
|
|
328
335
|
* @link https://github.com/baendlorel/kt.js
|
|
329
336
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -332,7 +339,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
332
339
|
*/
|
|
333
340
|
const h = (tag, attr, content) => {
|
|
334
341
|
if (typeof tag !== 'string') {
|
|
335
|
-
|
|
342
|
+
throw new Error('[kt.js error] tagName must be a string.');
|
|
336
343
|
}
|
|
337
344
|
if (attr) {
|
|
338
345
|
if (SVG_ATTR_FLAG in attr) {
|
|
@@ -355,10 +362,10 @@ var __ktjs_core__ = (function (exports) {
|
|
|
355
362
|
if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {
|
|
356
363
|
const kmodel = attr['k-model'];
|
|
357
364
|
if (isKTRef(kmodel)) {
|
|
358
|
-
|
|
365
|
+
applyKModel(element, kmodel);
|
|
359
366
|
}
|
|
360
367
|
else {
|
|
361
|
-
|
|
368
|
+
throw new Error('[kt.js error] k-model value must be a KTRef.');
|
|
362
369
|
}
|
|
363
370
|
}
|
|
364
371
|
return element;
|
|
@@ -413,7 +420,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
413
420
|
* Note: kt.js doesn't have a real Fragment concept,
|
|
414
421
|
*/
|
|
415
422
|
function Fragment(_props) {
|
|
416
|
-
throw new Error("kt.js doesn't have a Fragment concept");
|
|
423
|
+
throw new Error("[kt.js error] doesn't have a Fragment concept");
|
|
417
424
|
// const { children } = props ?? {};
|
|
418
425
|
// if (!children) {
|
|
419
426
|
// return ;
|
package/dist/index.legacy.js
CHANGED
|
@@ -6,10 +6,8 @@ var __ktjs_core__ = (function (exports) {
|
|
|
6
6
|
const $entries = Object.entries;
|
|
7
7
|
const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
throw new Error('@ktjs/shared: ' + message);
|
|
12
|
-
};
|
|
9
|
+
// DOM manipulation utilities
|
|
10
|
+
// # dom natives
|
|
13
11
|
/**
|
|
14
12
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
15
13
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -46,10 +44,18 @@ var __ktjs_core__ = (function (exports) {
|
|
|
46
44
|
}
|
|
47
45
|
};
|
|
48
46
|
const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
47
|
+
/**
|
|
48
|
+
* Used for `k-model`
|
|
49
|
+
*/
|
|
50
|
+
const applyModel = (element, valueRef, propName, eventName) => {
|
|
51
|
+
element[propName] = valueRef.value; // initialize
|
|
52
|
+
valueRef.addOnChange((newValue) => (element[propName] = newValue));
|
|
53
|
+
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
54
|
+
};
|
|
49
55
|
|
|
50
56
|
// Shared utilities and cached native methods for kt.js framework
|
|
51
57
|
// Re-export all utilities
|
|
52
|
-
Object.defineProperty(window, '
|
|
58
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.2' });
|
|
53
59
|
|
|
54
60
|
var KTRef = /** @class */ (function () {
|
|
55
61
|
function KTRef(_value, _onChanges) {
|
|
@@ -227,7 +233,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
227
233
|
attrIsObject(element, attr);
|
|
228
234
|
}
|
|
229
235
|
else {
|
|
230
|
-
throw new Error('kt.js
|
|
236
|
+
throw new Error('[kt.js error] attr must be an object.');
|
|
231
237
|
}
|
|
232
238
|
}
|
|
233
239
|
|
|
@@ -285,27 +291,28 @@ var __ktjs_core__ = (function (exports) {
|
|
|
285
291
|
}
|
|
286
292
|
}
|
|
287
293
|
|
|
288
|
-
function
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
function applyModel(element, valueRef) {
|
|
294
|
+
function applyKModel(element, valueRef) {
|
|
295
|
+
if (!isKTRef(valueRef)) {
|
|
296
|
+
console.warn('[kt.js warn] k-model value must be a KTRef.');
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
294
299
|
if (element instanceof HTMLInputElement) {
|
|
295
300
|
if (element.type === 'radio' || element.type === 'checkbox') {
|
|
296
|
-
|
|
301
|
+
applyModel(element, valueRef, 'checked', 'change');
|
|
297
302
|
}
|
|
298
303
|
else {
|
|
299
|
-
|
|
304
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
300
305
|
}
|
|
301
306
|
}
|
|
302
307
|
else if (element instanceof HTMLSelectElement) {
|
|
303
|
-
|
|
308
|
+
applyModel(element, valueRef, 'value', 'change');
|
|
304
309
|
}
|
|
305
310
|
else if (element instanceof HTMLTextAreaElement) {
|
|
306
|
-
|
|
311
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
console.warn('[kt.js warn] not supported element for k-model:');
|
|
307
315
|
}
|
|
308
|
-
console.warn('[kt.js warn] not supported element for k-model:', element.tagName);
|
|
309
316
|
}
|
|
310
317
|
|
|
311
318
|
var htmlCreator = function (tag) { return document.createElement(tag); };
|
|
@@ -325,7 +332,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
325
332
|
* ## About
|
|
326
333
|
* @package @ktjs/core
|
|
327
334
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
328
|
-
* @version 0.22.
|
|
335
|
+
* @version 0.22.2 (Last Update: 2026.02.02 20:28:37.901)
|
|
329
336
|
* @license MIT
|
|
330
337
|
* @link https://github.com/baendlorel/kt.js
|
|
331
338
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -334,7 +341,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
334
341
|
*/
|
|
335
342
|
var h = function (tag, attr, content) {
|
|
336
343
|
if (typeof tag !== 'string') {
|
|
337
|
-
|
|
344
|
+
throw new Error('[kt.js error] tagName must be a string.');
|
|
338
345
|
}
|
|
339
346
|
if (attr) {
|
|
340
347
|
if (SVG_ATTR_FLAG in attr) {
|
|
@@ -357,10 +364,10 @@ var __ktjs_core__ = (function (exports) {
|
|
|
357
364
|
if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {
|
|
358
365
|
var kmodel = attr['k-model'];
|
|
359
366
|
if (isKTRef(kmodel)) {
|
|
360
|
-
|
|
367
|
+
applyKModel(element, kmodel);
|
|
361
368
|
}
|
|
362
369
|
else {
|
|
363
|
-
|
|
370
|
+
throw new Error('[kt.js error] k-model value must be a KTRef.');
|
|
364
371
|
}
|
|
365
372
|
}
|
|
366
373
|
return element;
|
|
@@ -415,7 +422,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
415
422
|
* Note: kt.js doesn't have a real Fragment concept,
|
|
416
423
|
*/
|
|
417
424
|
function Fragment(_props) {
|
|
418
|
-
throw new Error("kt.js doesn't have a Fragment concept");
|
|
425
|
+
throw new Error("[kt.js error] doesn't have a Fragment concept");
|
|
419
426
|
// const { children } = props ?? {};
|
|
420
427
|
// if (!children) {
|
|
421
428
|
// return ;
|
package/dist/index.mjs
CHANGED
|
@@ -3,10 +3,8 @@ const $isArray = Array.isArray;
|
|
|
3
3
|
const $entries = Object.entries;
|
|
4
4
|
const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
throw new Error('@ktjs/shared: ' + message);
|
|
9
|
-
};
|
|
6
|
+
// DOM manipulation utilities
|
|
7
|
+
// # dom natives
|
|
10
8
|
/**
|
|
11
9
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
12
10
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -43,10 +41,18 @@ const $append = // for ie 9/10/11
|
|
|
43
41
|
}
|
|
44
42
|
};
|
|
45
43
|
const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
44
|
+
/**
|
|
45
|
+
* Used for `k-model`
|
|
46
|
+
*/
|
|
47
|
+
const applyModel = (element, valueRef, propName, eventName) => {
|
|
48
|
+
element[propName] = valueRef.value; // initialize
|
|
49
|
+
valueRef.addOnChange((newValue) => (element[propName] = newValue));
|
|
50
|
+
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
51
|
+
};
|
|
46
52
|
|
|
47
53
|
// Shared utilities and cached native methods for kt.js framework
|
|
48
54
|
// Re-export all utilities
|
|
49
|
-
Object.defineProperty(window, '
|
|
55
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.2' });
|
|
50
56
|
|
|
51
57
|
class KTRef {
|
|
52
58
|
/**
|
|
@@ -225,7 +231,7 @@ function applyAttr(element, attr) {
|
|
|
225
231
|
attrIsObject(element, attr);
|
|
226
232
|
}
|
|
227
233
|
else {
|
|
228
|
-
throw new Error('kt.js
|
|
234
|
+
throw new Error('[kt.js error] attr must be an object.');
|
|
229
235
|
}
|
|
230
236
|
}
|
|
231
237
|
|
|
@@ -280,27 +286,28 @@ function applyContent(element, content) {
|
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
288
|
|
|
283
|
-
function
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
function applyModel(element, valueRef) {
|
|
289
|
+
function applyKModel(element, valueRef) {
|
|
290
|
+
if (!isKTRef(valueRef)) {
|
|
291
|
+
console.warn('[kt.js warn] k-model value must be a KTRef.');
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
289
294
|
if (element instanceof HTMLInputElement) {
|
|
290
295
|
if (element.type === 'radio' || element.type === 'checkbox') {
|
|
291
|
-
|
|
296
|
+
applyModel(element, valueRef, 'checked', 'change');
|
|
292
297
|
}
|
|
293
298
|
else {
|
|
294
|
-
|
|
299
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
295
300
|
}
|
|
296
301
|
}
|
|
297
302
|
else if (element instanceof HTMLSelectElement) {
|
|
298
|
-
|
|
303
|
+
applyModel(element, valueRef, 'value', 'change');
|
|
299
304
|
}
|
|
300
305
|
else if (element instanceof HTMLTextAreaElement) {
|
|
301
|
-
|
|
306
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
console.warn('[kt.js warn] not supported element for k-model:');
|
|
302
310
|
}
|
|
303
|
-
console.warn('[kt.js warn] not supported element for k-model:', element.tagName);
|
|
304
311
|
}
|
|
305
312
|
|
|
306
313
|
const htmlCreator = (tag) => document.createElement(tag);
|
|
@@ -320,7 +327,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
320
327
|
* ## About
|
|
321
328
|
* @package @ktjs/core
|
|
322
329
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
323
|
-
* @version 0.22.
|
|
330
|
+
* @version 0.22.2 (Last Update: 2026.02.02 20:28:37.901)
|
|
324
331
|
* @license MIT
|
|
325
332
|
* @link https://github.com/baendlorel/kt.js
|
|
326
333
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -329,7 +336,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
329
336
|
*/
|
|
330
337
|
const h = (tag, attr, content) => {
|
|
331
338
|
if (typeof tag !== 'string') {
|
|
332
|
-
|
|
339
|
+
throw new Error('[kt.js error] tagName must be a string.');
|
|
333
340
|
}
|
|
334
341
|
if (attr) {
|
|
335
342
|
if (SVG_ATTR_FLAG in attr) {
|
|
@@ -352,10 +359,10 @@ const h = (tag, attr, content) => {
|
|
|
352
359
|
if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {
|
|
353
360
|
const kmodel = attr['k-model'];
|
|
354
361
|
if (isKTRef(kmodel)) {
|
|
355
|
-
|
|
362
|
+
applyKModel(element, kmodel);
|
|
356
363
|
}
|
|
357
364
|
else {
|
|
358
|
-
|
|
365
|
+
throw new Error('[kt.js error] k-model value must be a KTRef.');
|
|
359
366
|
}
|
|
360
367
|
}
|
|
361
368
|
return element;
|
|
@@ -410,7 +417,7 @@ function jsx(tag, props) {
|
|
|
410
417
|
* Note: kt.js doesn't have a real Fragment concept,
|
|
411
418
|
*/
|
|
412
419
|
function Fragment(_props) {
|
|
413
|
-
throw new Error("kt.js doesn't have a Fragment concept");
|
|
420
|
+
throw new Error("[kt.js error] doesn't have a Fragment concept");
|
|
414
421
|
// const { children } = props ?? {};
|
|
415
422
|
// if (!children) {
|
|
416
423
|
// return ;
|
package/dist/jsx/index.d.ts
CHANGED
|
@@ -146,7 +146,7 @@ type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
|
|
|
146
146
|
* ## About
|
|
147
147
|
* @package @ktjs/core
|
|
148
148
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
149
|
-
* @version 0.22.
|
|
149
|
+
* @version 0.22.2 (Last Update: 2026.02.02 20:28:37.901)
|
|
150
150
|
* @license MIT
|
|
151
151
|
* @link https://github.com/baendlorel/kt.js
|
|
152
152
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/jsx/index.mjs
CHANGED
|
@@ -3,10 +3,8 @@ const $isArray = Array.isArray;
|
|
|
3
3
|
const $entries = Object.entries;
|
|
4
4
|
const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
throw new Error('@ktjs/shared: ' + message);
|
|
9
|
-
};
|
|
6
|
+
// DOM manipulation utilities
|
|
7
|
+
// # dom natives
|
|
10
8
|
/**
|
|
11
9
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
12
10
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -43,10 +41,18 @@ const $append = // for ie 9/10/11
|
|
|
43
41
|
}
|
|
44
42
|
};
|
|
45
43
|
const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
44
|
+
/**
|
|
45
|
+
* Used for `k-model`
|
|
46
|
+
*/
|
|
47
|
+
const applyModel = (element, valueRef, propName, eventName) => {
|
|
48
|
+
element[propName] = valueRef.value; // initialize
|
|
49
|
+
valueRef.addOnChange((newValue) => (element[propName] = newValue));
|
|
50
|
+
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
51
|
+
};
|
|
46
52
|
|
|
47
53
|
// Shared utilities and cached native methods for kt.js framework
|
|
48
54
|
// Re-export all utilities
|
|
49
|
-
Object.defineProperty(window, '
|
|
55
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.2' });
|
|
50
56
|
|
|
51
57
|
class KTRef {
|
|
52
58
|
/**
|
|
@@ -225,7 +231,7 @@ function applyAttr(element, attr) {
|
|
|
225
231
|
attrIsObject(element, attr);
|
|
226
232
|
}
|
|
227
233
|
else {
|
|
228
|
-
throw new Error('kt.js
|
|
234
|
+
throw new Error('[kt.js error] attr must be an object.');
|
|
229
235
|
}
|
|
230
236
|
}
|
|
231
237
|
|
|
@@ -280,27 +286,28 @@ function applyContent(element, content) {
|
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
288
|
|
|
283
|
-
function
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
function applyModel(element, valueRef) {
|
|
289
|
+
function applyKModel(element, valueRef) {
|
|
290
|
+
if (!isKTRef(valueRef)) {
|
|
291
|
+
console.warn('[kt.js warn] k-model value must be a KTRef.');
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
289
294
|
if (element instanceof HTMLInputElement) {
|
|
290
295
|
if (element.type === 'radio' || element.type === 'checkbox') {
|
|
291
|
-
|
|
296
|
+
applyModel(element, valueRef, 'checked', 'change');
|
|
292
297
|
}
|
|
293
298
|
else {
|
|
294
|
-
|
|
299
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
295
300
|
}
|
|
296
301
|
}
|
|
297
302
|
else if (element instanceof HTMLSelectElement) {
|
|
298
|
-
|
|
303
|
+
applyModel(element, valueRef, 'value', 'change');
|
|
299
304
|
}
|
|
300
305
|
else if (element instanceof HTMLTextAreaElement) {
|
|
301
|
-
|
|
306
|
+
applyModel(element, valueRef, 'value', 'input');
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
console.warn('[kt.js warn] not supported element for k-model:');
|
|
302
310
|
}
|
|
303
|
-
console.warn('[kt.js warn] not supported element for k-model:', element.tagName);
|
|
304
311
|
}
|
|
305
312
|
|
|
306
313
|
const htmlCreator = (tag) => document.createElement(tag);
|
|
@@ -320,7 +327,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
320
327
|
* ## About
|
|
321
328
|
* @package @ktjs/core
|
|
322
329
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
323
|
-
* @version 0.22.
|
|
330
|
+
* @version 0.22.2 (Last Update: 2026.02.02 20:28:37.901)
|
|
324
331
|
* @license MIT
|
|
325
332
|
* @link https://github.com/baendlorel/kt.js
|
|
326
333
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -329,7 +336,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
329
336
|
*/
|
|
330
337
|
const h = (tag, attr, content) => {
|
|
331
338
|
if (typeof tag !== 'string') {
|
|
332
|
-
|
|
339
|
+
throw new Error('[kt.js error] tagName must be a string.');
|
|
333
340
|
}
|
|
334
341
|
if (attr) {
|
|
335
342
|
if (SVG_ATTR_FLAG in attr) {
|
|
@@ -352,10 +359,10 @@ const h = (tag, attr, content) => {
|
|
|
352
359
|
if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {
|
|
353
360
|
const kmodel = attr['k-model'];
|
|
354
361
|
if (isKTRef(kmodel)) {
|
|
355
|
-
|
|
362
|
+
applyKModel(element, kmodel);
|
|
356
363
|
}
|
|
357
364
|
else {
|
|
358
|
-
|
|
365
|
+
throw new Error('[kt.js error] k-model value must be a KTRef.');
|
|
359
366
|
}
|
|
360
367
|
}
|
|
361
368
|
return element;
|
|
@@ -410,7 +417,7 @@ function jsx(tag, props) {
|
|
|
410
417
|
* Note: kt.js doesn't have a real Fragment concept,
|
|
411
418
|
*/
|
|
412
419
|
function Fragment(_props) {
|
|
413
|
-
throw new Error("kt.js doesn't have a Fragment concept");
|
|
420
|
+
throw new Error("[kt.js error] doesn't have a Fragment concept");
|
|
414
421
|
// const { children } = props ?? {};
|
|
415
422
|
// if (!children) {
|
|
416
423
|
// return ;
|
|
@@ -125,7 +125,7 @@ type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
|
|
|
125
125
|
* ## About
|
|
126
126
|
* @package @ktjs/core
|
|
127
127
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
128
|
-
* @version 0.22.
|
|
128
|
+
* @version 0.22.2 (Last Update: 2026.02.02 20:28:37.901)
|
|
129
129
|
* @license MIT
|
|
130
130
|
* @link https://github.com/baendlorel/kt.js
|
|
131
131
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/jsx/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": "@ktjs/core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"directory": "packages/core"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@ktjs/shared": "0.
|
|
47
|
+
"@ktjs/shared": "0.22.2"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup -c rollup.config.mjs",
|