@ktjs/core 0.19.1 → 0.20.0
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 +159 -180
- package/dist/index.iife.js +8 -43
- package/dist/index.legacy.js +9 -77
- package/dist/index.mjs +9 -43
- package/dist/jsx/index.d.ts +138 -160
- package/dist/jsx/index.mjs +9 -43
- package/dist/jsx/jsx-runtime.d.ts +8 -1195
- package/dist/jsx/jsx-runtime.mjs +9 -43
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,155 @@ declare class KTRef<T> {
|
|
|
30
30
|
*/
|
|
31
31
|
declare function ref<T = HTMLElement>(value?: T, onChange?: RefChangeHandler<T>): KTRef<T>;
|
|
32
32
|
|
|
33
|
+
type SingleContent = KTRef<any> | HTMLElement | Element | Node | string | number | boolean | null | undefined;
|
|
34
|
+
type KTAvailableContent = SingleContent | KTAvailableContent[];
|
|
35
|
+
type KTRawContent = KTAvailableContent | Promise<KTAvailableContent>;
|
|
36
|
+
type KTRawAttr = KTAttribute | null | undefined | '' | false;
|
|
37
|
+
type KTRawContents = KTAvailableContent;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Event handler type for DOM events
|
|
41
|
+
*/
|
|
42
|
+
type EventHandler<T extends Event = Event> = (this: HTMLElement, ev: T) => any;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Used to create enhanced HTML elements
|
|
46
|
+
*/
|
|
47
|
+
interface KTBaseAttribute {
|
|
48
|
+
[k: string]: any;
|
|
49
|
+
|
|
50
|
+
// # kt-specific attributes
|
|
51
|
+
ref?: KTRef<JSX.Element>;
|
|
52
|
+
'k-if'?: any;
|
|
53
|
+
|
|
54
|
+
// # normal HTML attributes
|
|
55
|
+
id?: string;
|
|
56
|
+
class?: string;
|
|
57
|
+
className?: string;
|
|
58
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
59
|
+
|
|
60
|
+
type?:
|
|
61
|
+
| 'text'
|
|
62
|
+
| 'password'
|
|
63
|
+
| 'email'
|
|
64
|
+
| 'number'
|
|
65
|
+
| 'tel'
|
|
66
|
+
| 'url'
|
|
67
|
+
| 'search'
|
|
68
|
+
| 'date'
|
|
69
|
+
| 'datetime-local'
|
|
70
|
+
| 'time'
|
|
71
|
+
| 'month'
|
|
72
|
+
| 'week'
|
|
73
|
+
| 'color'
|
|
74
|
+
| 'range'
|
|
75
|
+
| 'file'
|
|
76
|
+
| 'checkbox'
|
|
77
|
+
| 'radio'
|
|
78
|
+
| 'hidden'
|
|
79
|
+
| 'submit'
|
|
80
|
+
| 'reset'
|
|
81
|
+
| 'button'
|
|
82
|
+
| 'image'
|
|
83
|
+
| otherstring;
|
|
84
|
+
for?: string;
|
|
85
|
+
|
|
86
|
+
name?: string;
|
|
87
|
+
title?: string;
|
|
88
|
+
placeholder?: string;
|
|
89
|
+
contenteditable?: boolean;
|
|
90
|
+
value?: any;
|
|
91
|
+
valueAsDate?: Date;
|
|
92
|
+
valueAsNumber?: number;
|
|
93
|
+
label?: string;
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
|
|
96
|
+
min?: string | number;
|
|
97
|
+
max?: string | number;
|
|
98
|
+
step?: string | number;
|
|
99
|
+
|
|
100
|
+
selected?: boolean;
|
|
101
|
+
checked?: boolean;
|
|
102
|
+
|
|
103
|
+
action?: string;
|
|
104
|
+
method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type KTPrefixedEventHandlers = {
|
|
108
|
+
[EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
|
|
112
|
+
|
|
113
|
+
type KTComponent = (
|
|
114
|
+
props: {
|
|
115
|
+
ref?: KTRef<JSX.Element>;
|
|
116
|
+
children?: KTRawContent;
|
|
117
|
+
} & KTAttribute &
|
|
118
|
+
any,
|
|
119
|
+
) => JSX.Element | Promise<JSX.Element> | any;
|
|
120
|
+
|
|
121
|
+
type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGElementTagNameMap[T] : T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
|
|
122
|
+
/**
|
|
123
|
+
* Create an enhanced HTMLElement.
|
|
124
|
+
* - Only supports HTMLElements, **NOT** SVGElements or other Elements.
|
|
125
|
+
* @param tag tag of an `HTMLElement`
|
|
126
|
+
* @param attr attribute object or className
|
|
127
|
+
* @param content a string or an array of HTMLEnhancedElement as child nodes
|
|
128
|
+
*
|
|
129
|
+
* ## About
|
|
130
|
+
* @package @ktjs/core
|
|
131
|
+
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
132
|
+
* @version 0.20.0 (Last Update: 2026.02.01 00:47:09.995)
|
|
133
|
+
* @license MIT
|
|
134
|
+
* @link https://github.com/baendlorel/kt.js
|
|
135
|
+
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
136
|
+
* @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
|
|
137
|
+
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
|
|
138
|
+
*/
|
|
139
|
+
declare const h: <T extends HTMLTag | SVGTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
|
|
140
|
+
|
|
141
|
+
type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>);
|
|
142
|
+
/**
|
|
143
|
+
* @param tag html tag or function component
|
|
144
|
+
* @param props properties/attributes
|
|
145
|
+
*/
|
|
146
|
+
declare function jsx(tag: JSXTag, props?: KTAttribute): HTMLElement;
|
|
147
|
+
/**
|
|
148
|
+
* Fragment support - returns an array of children
|
|
149
|
+
* Note: kt.js doesn't have a real Fragment concept,
|
|
150
|
+
*/
|
|
151
|
+
declare function Fragment(_props: {
|
|
152
|
+
children?: KTRawContent;
|
|
153
|
+
}): HTMLElement;
|
|
154
|
+
/**
|
|
155
|
+
* JSX Development runtime - same as jsx but with additional dev checks
|
|
156
|
+
*/
|
|
157
|
+
declare const jsxDEV: typeof jsx;
|
|
158
|
+
/**
|
|
159
|
+
* JSX runtime for React 17+ automatic runtime
|
|
160
|
+
* This is called when using jsx: "react-jsx" or "react-jsxdev"
|
|
161
|
+
*/
|
|
162
|
+
declare const jsxs: typeof jsx;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A helper to create redrawable elements
|
|
166
|
+
* ```tsx
|
|
167
|
+
* export function MyComponent() {
|
|
168
|
+
* let aa = 10;
|
|
169
|
+
* // ...
|
|
170
|
+
* // aa might be changed
|
|
171
|
+
* return createRedrawable(() => <div>{aa}</div>);
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
* Then the returned element has a `redraw` method to redraw itself with new values.
|
|
175
|
+
* @param creator a simple creator function that returns an element
|
|
176
|
+
* @returns created element's ref
|
|
177
|
+
*/
|
|
178
|
+
declare function createRedrawable<T>(creator: () => T): KTRef<T> & {
|
|
179
|
+
redraw: () => T;
|
|
180
|
+
};
|
|
181
|
+
|
|
33
182
|
// Base events available to all HTML elements
|
|
34
183
|
interface BaseAttr {
|
|
35
184
|
[k: string]: any;
|
|
@@ -1009,17 +1158,9 @@ interface SVGAttributesMap {
|
|
|
1009
1158
|
view: AttributesMap['svg'] & { viewBox?: string; preserveAspectRatio?: string };
|
|
1010
1159
|
}
|
|
1011
1160
|
|
|
1012
|
-
type KTHTMLElement<El extends HTMLElement = HTMLElement> = El & {
|
|
1013
|
-
/**
|
|
1014
|
-
* Automically generate a redraw function if it is not provided
|
|
1015
|
-
* @param props
|
|
1016
|
-
*/
|
|
1017
|
-
redraw: (props?: KTAttribute, ...args: any[]) => KTHTMLElement;
|
|
1018
|
-
};
|
|
1019
|
-
|
|
1020
1161
|
declare global {
|
|
1021
1162
|
namespace JSX {
|
|
1022
|
-
type Element =
|
|
1163
|
+
type Element = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
|
1023
1164
|
|
|
1024
1165
|
interface IntrinsicElements {
|
|
1025
1166
|
// Document-level & metadata
|
|
@@ -1193,7 +1334,7 @@ declare global {
|
|
|
1193
1334
|
}
|
|
1194
1335
|
|
|
1195
1336
|
interface IntrinsicAttributes {
|
|
1196
|
-
ref?: KTRef<
|
|
1337
|
+
ref?: KTRef<any>;
|
|
1197
1338
|
'k-if'?: any;
|
|
1198
1339
|
children?: KTRawContent;
|
|
1199
1340
|
}
|
|
@@ -1204,184 +1345,22 @@ declare global {
|
|
|
1204
1345
|
}
|
|
1205
1346
|
}
|
|
1206
1347
|
|
|
1207
|
-
type SingleContent = KTRef<any> | HTMLElement | Element | Node | string | number | boolean | null | undefined;
|
|
1208
|
-
type KTAvailableContent = SingleContent | KTAvailableContent[];
|
|
1209
|
-
type KTRawContent = KTAvailableContent | Promise<KTAvailableContent>;
|
|
1210
|
-
type KTRawAttr = KTAttribute | null | undefined | '' | false;
|
|
1211
|
-
type KTRawContents = KTAvailableContent;
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* Event handler type for DOM events
|
|
1215
|
-
*/
|
|
1216
|
-
type EventHandler<T extends Event = Event> = (this: HTMLElement, ev: T) => any;
|
|
1217
|
-
|
|
1218
|
-
/**
|
|
1219
|
-
* Used to create enhanced HTML elements
|
|
1220
|
-
*/
|
|
1221
|
-
interface KTBaseAttribute {
|
|
1222
|
-
[k: string]: any;
|
|
1223
|
-
|
|
1224
|
-
// # kt-specific attributes
|
|
1225
|
-
ref?: KTRef<KTHTMLElement>;
|
|
1226
|
-
'k-if'?: any;
|
|
1227
|
-
|
|
1228
|
-
// # normal HTML attributes
|
|
1229
|
-
id?: string;
|
|
1230
|
-
class?: string;
|
|
1231
|
-
className?: string;
|
|
1232
|
-
style?: string | Partial<CSSStyleDeclaration>;
|
|
1233
|
-
|
|
1234
|
-
type?:
|
|
1235
|
-
| 'text'
|
|
1236
|
-
| 'password'
|
|
1237
|
-
| 'email'
|
|
1238
|
-
| 'number'
|
|
1239
|
-
| 'tel'
|
|
1240
|
-
| 'url'
|
|
1241
|
-
| 'search'
|
|
1242
|
-
| 'date'
|
|
1243
|
-
| 'datetime-local'
|
|
1244
|
-
| 'time'
|
|
1245
|
-
| 'month'
|
|
1246
|
-
| 'week'
|
|
1247
|
-
| 'color'
|
|
1248
|
-
| 'range'
|
|
1249
|
-
| 'file'
|
|
1250
|
-
| 'checkbox'
|
|
1251
|
-
| 'radio'
|
|
1252
|
-
| 'hidden'
|
|
1253
|
-
| 'submit'
|
|
1254
|
-
| 'reset'
|
|
1255
|
-
| 'button'
|
|
1256
|
-
| 'image'
|
|
1257
|
-
| otherstring;
|
|
1258
|
-
for?: string;
|
|
1259
|
-
|
|
1260
|
-
name?: string;
|
|
1261
|
-
title?: string;
|
|
1262
|
-
placeholder?: string;
|
|
1263
|
-
contenteditable?: boolean;
|
|
1264
|
-
value?: any;
|
|
1265
|
-
valueAsDate?: Date;
|
|
1266
|
-
valueAsNumber?: number;
|
|
1267
|
-
label?: string;
|
|
1268
|
-
disabled?: boolean;
|
|
1269
|
-
|
|
1270
|
-
min?: string | number;
|
|
1271
|
-
max?: string | number;
|
|
1272
|
-
step?: string | number;
|
|
1273
|
-
|
|
1274
|
-
selected?: boolean;
|
|
1275
|
-
checked?: boolean;
|
|
1276
|
-
|
|
1277
|
-
action?: string;
|
|
1278
|
-
method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
type KTPrefixedEventHandlers = {
|
|
1282
|
-
[EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
|
|
1283
|
-
};
|
|
1284
|
-
|
|
1285
|
-
type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
|
|
1286
|
-
|
|
1287
|
-
type KTComponent = (
|
|
1288
|
-
props: {
|
|
1289
|
-
ref?: KTRef<KTHTMLElement>;
|
|
1290
|
-
children?: KTRawContent;
|
|
1291
|
-
} & KTAttribute &
|
|
1292
|
-
any,
|
|
1293
|
-
) => KTHTMLElement | Promise<KTHTMLElement> | any;
|
|
1294
|
-
|
|
1295
|
-
type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGElementTagNameMap[T] : T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
|
|
1296
|
-
/**
|
|
1297
|
-
* Create an enhanced HTMLElement.
|
|
1298
|
-
* - Only supports HTMLElements, **NOT** SVGElements or other Elements.
|
|
1299
|
-
* @param tag tag of an `HTMLElement`
|
|
1300
|
-
* @param attr attribute object or className
|
|
1301
|
-
* @param content a string or an array of HTMLEnhancedElement as child nodes
|
|
1302
|
-
*
|
|
1303
|
-
* ## About
|
|
1304
|
-
* @package @ktjs/core
|
|
1305
|
-
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
1306
|
-
* @version 0.19.1 (Last Update: 2026.01.31 23:07:55.249)
|
|
1307
|
-
* @license MIT
|
|
1308
|
-
* @link https://github.com/baendlorel/kt.js
|
|
1309
|
-
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
1310
|
-
* @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
|
|
1311
|
-
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
|
|
1312
|
-
*/
|
|
1313
|
-
declare const h: <T extends HTMLTag | SVGTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
|
|
1314
|
-
|
|
1315
|
-
type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>) | ((props?: any) => KTHTMLElement) | ((props?: any) => Promise<KTHTMLElement>);
|
|
1316
|
-
/**
|
|
1317
|
-
* @param tag html tag or function component
|
|
1318
|
-
* @param props properties/attributes
|
|
1319
|
-
*/
|
|
1320
|
-
declare function jsx(tag: JSXTag, props?: KTAttribute): KTHTMLElement;
|
|
1321
|
-
/**
|
|
1322
|
-
* Fragment support - returns an array of children
|
|
1323
|
-
* Note: kt.js doesn't have a real Fragment concept,
|
|
1324
|
-
*/
|
|
1325
|
-
declare function Fragment(_props: {
|
|
1326
|
-
children?: KTRawContent;
|
|
1327
|
-
}): HTMLElement;
|
|
1328
|
-
/**
|
|
1329
|
-
* JSX Development runtime - same as jsx but with additional dev checks
|
|
1330
|
-
*/
|
|
1331
|
-
declare const jsxDEV: typeof jsx;
|
|
1332
|
-
/**
|
|
1333
|
-
* JSX runtime for React 17+ automatic runtime
|
|
1334
|
-
* This is called when using jsx: "react-jsx" or "react-jsxdev"
|
|
1335
|
-
*/
|
|
1336
|
-
declare const jsxs: typeof jsx;
|
|
1337
|
-
|
|
1338
|
-
/**
|
|
1339
|
-
* A helper to create redrawable elements
|
|
1340
|
-
* ```tsx
|
|
1341
|
-
* export function MyComponent() {
|
|
1342
|
-
* let aa = 10;
|
|
1343
|
-
* // ...
|
|
1344
|
-
* // aa might be changed
|
|
1345
|
-
* return createRedrawableNoref(() => <div>{aa}</div>);
|
|
1346
|
-
* }
|
|
1347
|
-
* ```
|
|
1348
|
-
* Then the returned element has a `redraw` method to redraw itself with new values.
|
|
1349
|
-
* @param creator a simple creator function that returns an element
|
|
1350
|
-
* @returns created element
|
|
1351
|
-
*/
|
|
1352
|
-
declare function createRedrawableNoref<T extends KTHTMLElement>(creator: () => T): T;
|
|
1353
|
-
/**
|
|
1354
|
-
* A helper to create redrawable elements
|
|
1355
|
-
* ```tsx
|
|
1356
|
-
* export function MyComponent() {
|
|
1357
|
-
* let aa = 10;
|
|
1358
|
-
* // ...
|
|
1359
|
-
* // aa might be changed
|
|
1360
|
-
* return createRedrawable(() => <div>{aa}</div>);
|
|
1361
|
-
* }
|
|
1362
|
-
* ```
|
|
1363
|
-
* Then the returned element has a `redraw` method to redraw itself with new values.
|
|
1364
|
-
* @param creator a simple creator function that returns an element
|
|
1365
|
-
* @returns created element's ref
|
|
1366
|
-
*/
|
|
1367
|
-
declare function createRedrawable<T extends KTHTMLElement>(creator: () => T): KTRef<T>;
|
|
1368
|
-
|
|
1369
1348
|
/**
|
|
1370
1349
|
* Extract component props type (excluding ref and children)
|
|
1371
1350
|
*/
|
|
1372
1351
|
type ExtractComponentProps<T> = T extends (props: infer P) => any ? Omit<P, 'ref' | 'children'> : {};
|
|
1373
1352
|
declare function KTAsync<T extends KTComponent>(props: {
|
|
1374
|
-
ref?: KTRef<
|
|
1375
|
-
skeleton?:
|
|
1353
|
+
ref?: KTRef<JSX.Element>;
|
|
1354
|
+
skeleton?: JSX.Element;
|
|
1376
1355
|
component: T;
|
|
1377
1356
|
children?: KTRawContent;
|
|
1378
|
-
} & ExtractComponentProps<T>):
|
|
1357
|
+
} & ExtractComponentProps<T>): JSX.Element;
|
|
1379
1358
|
|
|
1380
|
-
type
|
|
1359
|
+
type KTForElement = JSX.Element & {
|
|
1381
1360
|
redraw: (newProps?: KTAttribute) => void;
|
|
1382
1361
|
};
|
|
1383
1362
|
interface KTForProps<T> {
|
|
1384
|
-
ref?: KTRef<
|
|
1363
|
+
ref?: KTRef<KTForElement>;
|
|
1385
1364
|
list: T[];
|
|
1386
1365
|
key?: (item: T, index: number, array: T[]) => any;
|
|
1387
1366
|
map: (item: T, index: number, array: T[]) => HTMLElement;
|
|
@@ -1390,7 +1369,7 @@ interface KTForProps<T> {
|
|
|
1390
1369
|
* KTFor - List rendering component with key-based optimization
|
|
1391
1370
|
* Returns a Comment anchor node with rendered elements in __kt_for_list__
|
|
1392
1371
|
*/
|
|
1393
|
-
declare function KTFor<T>(props: KTForProps<T>):
|
|
1372
|
+
declare function KTFor<T>(props: KTForProps<T>): KTForElement;
|
|
1394
1373
|
|
|
1395
|
-
export { Fragment, KTAsync, KTFor, KTRef, h as createElement, createRedrawable,
|
|
1396
|
-
export type { EventHandler, HTMLTag, KTAttribute,
|
|
1374
|
+
export { Fragment, KTAsync, KTFor, KTRef, h as createElement, createRedrawable, h, jsx, jsxDEV, jsxs, ref };
|
|
1375
|
+
export type { EventHandler, HTMLTag, KTAttribute, KTForElement, KTForProps, KTRawAttr, KTRawContent, KTRawContents };
|
package/dist/index.iife.js
CHANGED
|
@@ -11,6 +11,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// DOM manipulation utilities
|
|
14
|
+
// # dom natives
|
|
14
15
|
/**
|
|
15
16
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
16
17
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -46,10 +47,11 @@ var __ktjs_core__ = (function (exports) {
|
|
|
46
47
|
$appendChild.call(this, fragment);
|
|
47
48
|
}
|
|
48
49
|
};
|
|
50
|
+
const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
49
51
|
|
|
50
52
|
// Shared utilities and cached native methods for kt.js framework
|
|
51
53
|
// Re-export all utilities
|
|
52
|
-
Object.defineProperty(window, '@ktjs/shared', { value: '0.
|
|
54
|
+
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.0' });
|
|
53
55
|
|
|
54
56
|
const booleanHandler = (element, key, value) => {
|
|
55
57
|
if (key in element) {
|
|
@@ -203,7 +205,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
203
205
|
* ## About
|
|
204
206
|
* @package @ktjs/core
|
|
205
207
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
206
|
-
* @version 0.
|
|
208
|
+
* @version 0.20.0 (Last Update: 2026.02.01 00:47:09.995)
|
|
207
209
|
* @license MIT
|
|
208
210
|
* @link https://github.com/baendlorel/kt.js
|
|
209
211
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -290,18 +292,10 @@ var __ktjs_core__ = (function (exports) {
|
|
|
290
292
|
function jsx(tag, props = {}) {
|
|
291
293
|
const ref = props.ref?.isKT ? props.ref : dummyRef;
|
|
292
294
|
let el;
|
|
293
|
-
const redraw = (newProps) => {
|
|
294
|
-
props = newProps ? { ...props, ...newProps } : props;
|
|
295
|
-
el = jsx(tag, props);
|
|
296
|
-
if (ref !== dummyRef) {
|
|
297
|
-
ref.value = el; // & ref setter automatically replaces old element in DOM
|
|
298
|
-
}
|
|
299
|
-
return el;
|
|
300
|
-
};
|
|
301
295
|
if ('k-if' in props && !props['k-if']) {
|
|
296
|
+
// & make comment placeholder in case that ref might be redrawn later
|
|
302
297
|
el = document.createComment('k-if');
|
|
303
|
-
ref.value = el;
|
|
304
|
-
el.redraw = redraw;
|
|
298
|
+
ref.value = el;
|
|
305
299
|
return el;
|
|
306
300
|
}
|
|
307
301
|
// Handle function components
|
|
@@ -311,7 +305,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
311
305
|
else {
|
|
312
306
|
el = h(tag, props, props.children);
|
|
313
307
|
}
|
|
314
|
-
el.redraw ??= redraw;
|
|
315
308
|
ref.value = el;
|
|
316
309
|
return el;
|
|
317
310
|
}
|
|
@@ -355,32 +348,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
355
348
|
* This is called when using jsx: "react-jsx" or "react-jsxdev"
|
|
356
349
|
*/
|
|
357
350
|
const jsxs = jsx;
|
|
358
|
-
/**
|
|
359
|
-
* A helper to create redrawable elements
|
|
360
|
-
* ```tsx
|
|
361
|
-
* export function MyComponent() {
|
|
362
|
-
* let aa = 10;
|
|
363
|
-
* // ...
|
|
364
|
-
* // aa might be changed
|
|
365
|
-
* return createRedrawableNoref(() => <div>{aa}</div>);
|
|
366
|
-
* }
|
|
367
|
-
* ```
|
|
368
|
-
* Then the returned element has a `redraw` method to redraw itself with new values.
|
|
369
|
-
* @param creator a simple creator function that returns an element
|
|
370
|
-
* @returns created element
|
|
371
|
-
*/
|
|
372
|
-
function createRedrawableNoref(creator) {
|
|
373
|
-
let el = creator();
|
|
374
|
-
const redraw = () => {
|
|
375
|
-
const old = el;
|
|
376
|
-
el = creator();
|
|
377
|
-
old.replaceWith(el);
|
|
378
|
-
el.redraw = redraw;
|
|
379
|
-
return el;
|
|
380
|
-
};
|
|
381
|
-
el.redraw = redraw;
|
|
382
|
-
return el;
|
|
383
|
-
}
|
|
384
351
|
/**
|
|
385
352
|
* A helper to create redrawable elements
|
|
386
353
|
* ```tsx
|
|
@@ -397,13 +364,12 @@ var __ktjs_core__ = (function (exports) {
|
|
|
397
364
|
*/
|
|
398
365
|
function createRedrawable(creator) {
|
|
399
366
|
const elRef = ref();
|
|
400
|
-
elRef.value = creator();
|
|
401
367
|
const redraw = () => {
|
|
402
368
|
elRef.value = creator(); // ref setter automatically calls replaceWith
|
|
403
|
-
elRef.
|
|
369
|
+
elRef.redraw = redraw;
|
|
404
370
|
return elRef.value;
|
|
405
371
|
};
|
|
406
|
-
|
|
372
|
+
redraw();
|
|
407
373
|
return elRef;
|
|
408
374
|
}
|
|
409
375
|
|
|
@@ -637,7 +603,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
637
603
|
exports.KTRef = KTRef;
|
|
638
604
|
exports.createElement = h;
|
|
639
605
|
exports.createRedrawable = createRedrawable;
|
|
640
|
-
exports.createRedrawableNoref = createRedrawableNoref;
|
|
641
606
|
exports.h = h;
|
|
642
607
|
exports.jsx = jsx;
|
|
643
608
|
exports.jsxDEV = jsxDEV;
|
package/dist/index.legacy.js
CHANGED
|
@@ -11,6 +11,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// DOM manipulation utilities
|
|
14
|
+
// # dom natives
|
|
14
15
|
/**
|
|
15
16
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
16
17
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -46,10 +47,11 @@ var __ktjs_core__ = (function (exports) {
|
|
|
46
47
|
$appendChild.call(this, fragment);
|
|
47
48
|
}
|
|
48
49
|
};
|
|
50
|
+
const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
49
51
|
|
|
50
52
|
// Shared utilities and cached native methods for kt.js framework
|
|
51
53
|
// Re-export all utilities
|
|
52
|
-
Object.defineProperty(window, '@ktjs/shared', { value: '0.
|
|
54
|
+
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.0' });
|
|
53
55
|
|
|
54
56
|
var booleanHandler = function (element, key, value) {
|
|
55
57
|
if (key in element) {
|
|
@@ -206,7 +208,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
206
208
|
* ## About
|
|
207
209
|
* @package @ktjs/core
|
|
208
210
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
209
|
-
* @version 0.
|
|
211
|
+
* @version 0.20.0 (Last Update: 2026.02.01 00:47:09.995)
|
|
210
212
|
* @license MIT
|
|
211
213
|
* @link https://github.com/baendlorel/kt.js
|
|
212
214
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -229,39 +231,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
229
231
|
return element;
|
|
230
232
|
};
|
|
231
233
|
|
|
232
|
-
/******************************************************************************
|
|
233
|
-
Copyright (c) Microsoft Corporation.
|
|
234
|
-
|
|
235
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
236
|
-
purpose with or without fee is hereby granted.
|
|
237
|
-
|
|
238
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
239
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
240
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
241
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
242
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
243
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
244
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
245
|
-
***************************************************************************** */
|
|
246
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
var __assign = function() {
|
|
250
|
-
__assign = Object.assign || function __assign(t) {
|
|
251
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
252
|
-
s = arguments[i];
|
|
253
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
254
|
-
}
|
|
255
|
-
return t;
|
|
256
|
-
};
|
|
257
|
-
return __assign.apply(this, arguments);
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
261
|
-
var e = new Error(message);
|
|
262
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
234
|
var KTRef = /** @class */ (function () {
|
|
266
235
|
function KTRef(_value, _onChanges) {
|
|
267
236
|
/**
|
|
@@ -327,22 +296,14 @@ var __ktjs_core__ = (function (exports) {
|
|
|
327
296
|
* @param props properties/attributes
|
|
328
297
|
*/
|
|
329
298
|
function jsx(tag, props) {
|
|
330
|
-
var _a
|
|
299
|
+
var _a;
|
|
331
300
|
if (props === void 0) { props = {}; }
|
|
332
301
|
var ref = ((_a = props.ref) === null || _a === void 0 ? void 0 : _a.isKT) ? props.ref : dummyRef;
|
|
333
302
|
var el;
|
|
334
|
-
var redraw = function (newProps) {
|
|
335
|
-
props = newProps ? __assign(__assign({}, props), newProps) : props;
|
|
336
|
-
el = jsx(tag, props);
|
|
337
|
-
if (ref !== dummyRef) {
|
|
338
|
-
ref.value = el; // & ref setter automatically replaces old element in DOM
|
|
339
|
-
}
|
|
340
|
-
return el;
|
|
341
|
-
};
|
|
342
303
|
if ('k-if' in props && !props['k-if']) {
|
|
304
|
+
// & make comment placeholder in case that ref might be redrawn later
|
|
343
305
|
el = document.createComment('k-if');
|
|
344
|
-
ref.value = el;
|
|
345
|
-
el.redraw = redraw;
|
|
306
|
+
ref.value = el;
|
|
346
307
|
return el;
|
|
347
308
|
}
|
|
348
309
|
// Handle function components
|
|
@@ -352,7 +313,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
352
313
|
else {
|
|
353
314
|
el = h(tag, props, props.children);
|
|
354
315
|
}
|
|
355
|
-
(_b = el.redraw) !== null && _b !== void 0 ? _b : (el.redraw = redraw);
|
|
356
316
|
ref.value = el;
|
|
357
317
|
return el;
|
|
358
318
|
}
|
|
@@ -400,32 +360,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
400
360
|
* This is called when using jsx: "react-jsx" or "react-jsxdev"
|
|
401
361
|
*/
|
|
402
362
|
var jsxs = jsx;
|
|
403
|
-
/**
|
|
404
|
-
* A helper to create redrawable elements
|
|
405
|
-
* ```tsx
|
|
406
|
-
* export function MyComponent() {
|
|
407
|
-
* let aa = 10;
|
|
408
|
-
* // ...
|
|
409
|
-
* // aa might be changed
|
|
410
|
-
* return createRedrawableNoref(() => <div>{aa}</div>);
|
|
411
|
-
* }
|
|
412
|
-
* ```
|
|
413
|
-
* Then the returned element has a `redraw` method to redraw itself with new values.
|
|
414
|
-
* @param creator a simple creator function that returns an element
|
|
415
|
-
* @returns created element
|
|
416
|
-
*/
|
|
417
|
-
function createRedrawableNoref(creator) {
|
|
418
|
-
var el = creator();
|
|
419
|
-
var redraw = function () {
|
|
420
|
-
var old = el;
|
|
421
|
-
el = creator();
|
|
422
|
-
old.replaceWith(el);
|
|
423
|
-
el.redraw = redraw;
|
|
424
|
-
return el;
|
|
425
|
-
};
|
|
426
|
-
el.redraw = redraw;
|
|
427
|
-
return el;
|
|
428
|
-
}
|
|
429
363
|
/**
|
|
430
364
|
* A helper to create redrawable elements
|
|
431
365
|
* ```tsx
|
|
@@ -442,13 +376,12 @@ var __ktjs_core__ = (function (exports) {
|
|
|
442
376
|
*/
|
|
443
377
|
function createRedrawable(creator) {
|
|
444
378
|
var elRef = ref();
|
|
445
|
-
elRef.value = creator();
|
|
446
379
|
var redraw = function () {
|
|
447
380
|
elRef.value = creator(); // ref setter automatically calls replaceWith
|
|
448
|
-
elRef.
|
|
381
|
+
elRef.redraw = redraw;
|
|
449
382
|
return elRef.value;
|
|
450
383
|
};
|
|
451
|
-
|
|
384
|
+
redraw();
|
|
452
385
|
return elRef;
|
|
453
386
|
}
|
|
454
387
|
|
|
@@ -685,7 +618,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
685
618
|
exports.KTRef = KTRef;
|
|
686
619
|
exports.createElement = h;
|
|
687
620
|
exports.createRedrawable = createRedrawable;
|
|
688
|
-
exports.createRedrawableNoref = createRedrawableNoref;
|
|
689
621
|
exports.h = h;
|
|
690
622
|
exports.jsx = jsx;
|
|
691
623
|
exports.jsxDEV = jsxDEV;
|