@ktjs/core 0.19.1 → 0.20.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/README.md CHANGED
@@ -21,17 +21,16 @@ KT.js is now a **monorepo** containing multiple packages:
21
21
  - **[kt.js](./packages/kt.js)**: Main entry package that re-exports all functionality
22
22
  - **[@ktjs/core](./packages/core)**: Core DOM manipulation utilities and the `h` function. SX/TSX support with full TypeScript integration (included in kt.js package)
23
23
  - **[@ktjs/router](./packages/router)**: Client-side routing with navigation guards (not included in kt.js package)
24
- - **[@ktjs/shortcuts](./packages/shortcuts)**: Convenient shortcut functions for common operations
25
24
 
26
25
  You can install the full package or individual packages as needed:
27
26
 
28
27
  ```bash
29
- # Install the main package (includes core + jsx + shortcuts)
30
28
  pnpm add kt.js
31
29
 
32
30
  # Or install individual packages
33
31
  pnpm add @ktjs/core # Core DOM utilities (independent)
34
- pnpm add @ktjs/router # Client-side router (independent)
32
+ pnpm add @ktjs/router # Client-side router (requires @ktjs/core)
33
+ pnpm add @ktjs/mui # Material UI components (requires @ktjs/core)
35
34
  pnpm add @ktjs/shortcuts # Shortcuts (requires @ktjs/core)
36
35
  ```
37
36
 
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ type otherstring = string & {};
5
5
  */
6
6
  type HTMLTag = keyof HTMLElementTagNameMap;
7
7
  type SVGTag = keyof SVGElementTagNameMap;
8
+ type MathMLTag = keyof MathMLElementTagNameMap;
8
9
 
9
10
  type RefChangeHandler<T> = (newValue: T, oldValue: T) => void;
10
11
  declare class KTRef<T> {
@@ -28,7 +29,156 @@ declare class KTRef<T> {
28
29
  * - can alse be used to store normal values, but it is not reactive.
29
30
  * @param value mostly an HTMLElement
30
31
  */
31
- declare function ref<T = HTMLElement>(value?: T, onChange?: RefChangeHandler<T>): KTRef<T>;
32
+ declare function ref<T = JSX.Element>(value?: T, onChange?: RefChangeHandler<T>): KTRef<T>;
33
+
34
+ type SingleContent = KTRef<any> | HTMLElement | Element | Node | string | number | boolean | null | undefined;
35
+ type KTAvailableContent = SingleContent | KTAvailableContent[];
36
+ type KTRawContent = KTAvailableContent | Promise<KTAvailableContent>;
37
+ type KTRawAttr = KTAttribute | null | undefined | '' | false;
38
+ type KTRawContents = KTAvailableContent;
39
+
40
+ /**
41
+ * Event handler type for DOM events
42
+ */
43
+ type EventHandler<T extends Event = Event> = (this: HTMLElement, ev: T) => any;
44
+
45
+ /**
46
+ * Used to create enhanced HTML elements
47
+ */
48
+ interface KTBaseAttribute {
49
+ [k: string]: any;
50
+
51
+ // # kt-specific attributes
52
+ ref?: KTRef<JSX.Element>;
53
+ 'k-if'?: any;
54
+
55
+ // # normal HTML attributes
56
+ id?: string;
57
+ class?: string;
58
+ className?: string;
59
+ style?: string | Partial<CSSStyleDeclaration>;
60
+
61
+ type?:
62
+ | 'text'
63
+ | 'password'
64
+ | 'email'
65
+ | 'number'
66
+ | 'tel'
67
+ | 'url'
68
+ | 'search'
69
+ | 'date'
70
+ | 'datetime-local'
71
+ | 'time'
72
+ | 'month'
73
+ | 'week'
74
+ | 'color'
75
+ | 'range'
76
+ | 'file'
77
+ | 'checkbox'
78
+ | 'radio'
79
+ | 'hidden'
80
+ | 'submit'
81
+ | 'reset'
82
+ | 'button'
83
+ | 'image'
84
+ | otherstring;
85
+ for?: string;
86
+
87
+ name?: string;
88
+ title?: string;
89
+ placeholder?: string;
90
+ contenteditable?: boolean;
91
+ value?: any;
92
+ valueAsDate?: Date;
93
+ valueAsNumber?: number;
94
+ label?: string;
95
+ disabled?: boolean;
96
+
97
+ min?: string | number;
98
+ max?: string | number;
99
+ step?: string | number;
100
+
101
+ selected?: boolean;
102
+ checked?: boolean;
103
+
104
+ action?: string;
105
+ method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
106
+ }
107
+
108
+ type KTPrefixedEventHandlers = {
109
+ [EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
110
+ };
111
+
112
+ type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
113
+
114
+ type KTComponent = (
115
+ props: {
116
+ ref?: KTRef<JSX.Element>;
117
+ children?: KTRawContent;
118
+ } & KTAttribute &
119
+ any,
120
+ ) => JSX.Element | Promise<JSX.Element> | any;
121
+
122
+ type HTML<T extends (HTMLTag | SVGTag | MathMLTag) & otherstring> = T extends SVGTag ? SVGElementTagNameMap[T] : T extends HTMLTag ? HTMLElementTagNameMap[T] : T extends MathMLTag ? MathMLElementTagNameMap[T] : HTMLElement;
123
+ /**
124
+ * Create an enhanced HTMLElement.
125
+ * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
126
+ * @param tag tag of an `HTMLElement`
127
+ * @param attr attribute object or className
128
+ * @param content a string or an array of HTMLEnhancedElement as child nodes
129
+ *
130
+ * ## About
131
+ * @package @ktjs/core
132
+ * @author Kasukabe Tsumugi <futami16237@gmail.com>
133
+ * @version 0.20.1 (Last Update: 2026.02.01 16:38:49.148)
134
+ * @license MIT
135
+ * @link https://github.com/baendlorel/kt.js
136
+ * @link https://baendlorel.github.io/ Welcome to my site!
137
+ * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
138
+ * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
139
+ */
140
+ declare const h: <T extends HTMLTag | SVGTag | MathMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
141
+
142
+ type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>);
143
+ /**
144
+ * @param tag html tag or function component
145
+ * @param props properties/attributes
146
+ */
147
+ declare function jsx(tag: JSXTag, props: KTAttribute): JSX.Element;
148
+ /**
149
+ * Fragment support - returns an array of children
150
+ * Note: kt.js doesn't have a real Fragment concept,
151
+ */
152
+ declare function Fragment(_props: {
153
+ children?: KTRawContent;
154
+ }): HTMLElement;
155
+ /**
156
+ * JSX Development runtime - same as jsx but with additional dev checks
157
+ */
158
+ declare const jsxDEV: typeof jsx;
159
+ /**
160
+ * JSX runtime for React 17+ automatic runtime
161
+ * This is called when using jsx: "react-jsx" or "react-jsxdev"
162
+ */
163
+ declare const jsxs: typeof jsx;
164
+
165
+ /**
166
+ * A helper to create redrawable elements
167
+ * ```tsx
168
+ * export function MyComponent() {
169
+ * let aa = 10;
170
+ * // ...
171
+ * // aa might be changed
172
+ * return createRedrawable(() => <div>{aa}</div>);
173
+ * }
174
+ * ```
175
+ * Then the returned element has a `redraw` method to redraw itself with new values.
176
+ * @param creator a simple creator function that returns an element
177
+ * @returns created element's ref
178
+ */
179
+ declare function createRedrawable<T>(creator: () => T): KTRef<T> & {
180
+ redraw: () => T;
181
+ };
32
182
 
33
183
  // Base events available to all HTML elements
34
184
  interface BaseAttr {
@@ -1009,19 +1159,13 @@ interface SVGAttributesMap {
1009
1159
  view: AttributesMap['svg'] & { viewBox?: string; preserveAspectRatio?: string };
1010
1160
  }
1011
1161
 
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
1162
  declare global {
1021
1163
  namespace JSX {
1022
- type Element = KTHTMLElement;
1164
+ type Element = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
1023
1165
 
1024
1166
  interface IntrinsicElements {
1167
+ [k: string]: AttributesMap['div']; // Allow any element with div attributes as fallback
1168
+
1025
1169
  // Document-level & metadata
1026
1170
  html: AttributesMap['html'];
1027
1171
  head: AttributesMap['head'];
@@ -1190,10 +1334,71 @@ declare global {
1190
1334
  tspan: SVGAttributesMap['tspan'];
1191
1335
  use: SVGAttributesMap['use'];
1192
1336
  view: SVGAttributesMap['view'];
1337
+
1338
+ // 'svg:svg': AttributesMap['svg'];
1339
+ // 'svg:a': SVGAttributesMap['a'];
1340
+ // 'svg:animate': SVGAttributesMap['animate'];
1341
+ // 'svg:animateMotion': SVGAttributesMap['animateMotion'];
1342
+ // 'svg:animateTransform': SVGAttributesMap['animateTransform'];
1343
+ // 'svg:circle': SVGAttributesMap['circle'];
1344
+ // 'svg:clipPath': SVGAttributesMap['clipPath'];
1345
+ // 'svg:defs': SVGAttributesMap['defs'];
1346
+ // 'svg:desc': SVGAttributesMap['desc'];
1347
+ // 'svg:ellipse': SVGAttributesMap['ellipse'];
1348
+ // 'svg:feBlend': SVGAttributesMap['feBlend'];
1349
+ // 'svg:feColorMatrix': SVGAttributesMap['feColorMatrix'];
1350
+ // 'svg:feComponentTransfer': SVGAttributesMap['feComponentTransfer'];
1351
+ // 'svg:feComposite': SVGAttributesMap['feComposite'];
1352
+ // 'svg:feConvolveMatrix': SVGAttributesMap['feConvolveMatrix'];
1353
+ // 'svg:feDiffuseLighting': SVGAttributesMap['feDiffuseLighting'];
1354
+ // 'svg:feDisplacementMap': SVGAttributesMap['feDisplacementMap'];
1355
+ // 'svg:feDistantLight': SVGAttributesMap['feDistantLight'];
1356
+ // 'svg:feDropShadow': SVGAttributesMap['feDropShadow'];
1357
+ // 'svg:feFlood': SVGAttributesMap['feFlood'];
1358
+ // 'svg:feFuncA': SVGAttributesMap['feFuncA'];
1359
+ // 'svg:feFuncB': SVGAttributesMap['feFuncB'];
1360
+ // 'svg:feFuncG': SVGAttributesMap['feFuncG'];
1361
+ // 'svg:feFuncR': SVGAttributesMap['feFuncR'];
1362
+ // 'svg:feGaussianBlur': SVGAttributesMap['feGaussianBlur'];
1363
+ // 'svg:feImage': SVGAttributesMap['feImage'];
1364
+ // 'svg:feMerge': SVGAttributesMap['feMerge'];
1365
+ // 'svg:feMergeNode': SVGAttributesMap['feMergeNode'];
1366
+ // 'svg:feMorphology': SVGAttributesMap['feMorphology'];
1367
+ // 'svg:feOffset': SVGAttributesMap['feOffset'];
1368
+ // 'svg:fePointLight': SVGAttributesMap['fePointLight'];
1369
+ // 'svg:feSpecularLighting': SVGAttributesMap['feSpecularLighting'];
1370
+ // 'svg:feSpotLight': SVGAttributesMap['feSpotLight'];
1371
+ // 'svg:feTile': SVGAttributesMap['feTile'];
1372
+ // 'svg:feTurbulence': SVGAttributesMap['feTurbulence'];
1373
+ // 'svg:filter': SVGAttributesMap['filter'];
1374
+ // 'svg:foreignObject': SVGAttributesMap['foreignObject'];
1375
+ // 'svg:g': SVGAttributesMap['g'];
1376
+ // 'svg:image': SVGAttributesMap['image'];
1377
+ // 'svg:line': SVGAttributesMap['line'];
1378
+ // 'svg:linearGradient': SVGAttributesMap['linearGradient'];
1379
+ // 'svg:marker': SVGAttributesMap['marker'];
1380
+ // 'svg:mask': SVGAttributesMap['mask'];
1381
+ // 'svg:metadata': SVGAttributesMap['metadata'];
1382
+ // 'svg:mpath': SVGAttributesMap['mpath'];
1383
+ // 'svg:path': SVGAttributesMap['path'];
1384
+ // 'svg:pattern': SVGAttributesMap['pattern'];
1385
+ // 'svg:polygon': SVGAttributesMap['polygon'];
1386
+ // 'svg:polyline': SVGAttributesMap['polyline'];
1387
+ // 'svg:radialGradient': SVGAttributesMap['radialGradient'];
1388
+ // 'svg:rect': SVGAttributesMap['rect'];
1389
+ // 'svg:set': SVGAttributesMap['set'];
1390
+ // 'svg:stop': SVGAttributesMap['stop'];
1391
+ // 'svg:switch': SVGAttributesMap['switch'];
1392
+ // 'svg:symbol': SVGAttributesMap['symbol'];
1393
+ // 'svg:text': SVGAttributesMap['text'];
1394
+ // 'svg:textPath': SVGAttributesMap['textPath'];
1395
+ // 'svg:tspan': SVGAttributesMap['tspan'];
1396
+ // 'svg:use': SVGAttributesMap['use'];
1397
+ // 'svg:view': SVGAttributesMap['view'];
1193
1398
  }
1194
1399
 
1195
1400
  interface IntrinsicAttributes {
1196
- ref?: KTRef<HTMLElement>;
1401
+ ref?: KTRef<any>;
1197
1402
  'k-if'?: any;
1198
1403
  children?: KTRawContent;
1199
1404
  }
@@ -1204,184 +1409,22 @@ declare global {
1204
1409
  }
1205
1410
  }
1206
1411
 
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
1412
  /**
1370
1413
  * Extract component props type (excluding ref and children)
1371
1414
  */
1372
1415
  type ExtractComponentProps<T> = T extends (props: infer P) => any ? Omit<P, 'ref' | 'children'> : {};
1373
1416
  declare function KTAsync<T extends KTComponent>(props: {
1374
- ref?: KTRef<KTHTMLElement>;
1375
- skeleton?: KTHTMLElement;
1417
+ ref?: KTRef<JSX.Element>;
1418
+ skeleton?: JSX.Element;
1376
1419
  component: T;
1377
1420
  children?: KTRawContent;
1378
- } & ExtractComponentProps<T>): KTHTMLElement;
1421
+ } & ExtractComponentProps<T>): JSX.Element;
1379
1422
 
1380
- type KForElement = KTHTMLElement & {
1423
+ type KTForElement = JSX.Element & {
1381
1424
  redraw: (newProps?: KTAttribute) => void;
1382
1425
  };
1383
1426
  interface KTForProps<T> {
1384
- ref?: KTRef<KForElement>;
1427
+ ref?: KTRef<KTForElement>;
1385
1428
  list: T[];
1386
1429
  key?: (item: T, index: number, array: T[]) => any;
1387
1430
  map: (item: T, index: number, array: T[]) => HTMLElement;
@@ -1390,7 +1433,7 @@ interface KTForProps<T> {
1390
1433
  * KTFor - List rendering component with key-based optimization
1391
1434
  * Returns a Comment anchor node with rendered elements in __kt_for_list__
1392
1435
  */
1393
- declare function KTFor<T>(props: KTForProps<T>): KForElement;
1436
+ declare function KTFor<T>(props: KTForProps<T>): KTForElement;
1394
1437
 
1395
- export { Fragment, KTAsync, KTFor, KTRef, h as createElement, createRedrawable, createRedrawableNoref, h, jsx, jsxDEV, jsxs, ref };
1396
- export type { EventHandler, HTMLTag, KTAttribute, KTForProps, KTHTMLElement, KTRawAttr, KTRawContent, KTRawContents };
1438
+ export { Fragment, KTAsync, KTFor, KTRef, h as createElement, createRedrawable, h, jsx, jsxDEV, jsxs, ref };
1439
+ export type { EventHandler, HTMLTag, KTAttribute, KTForElement, KTForProps, KTRawAttr, KTRawContent, KTRawContents };
@@ -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.19.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) {
@@ -192,7 +194,14 @@ var __ktjs_core__ = (function (exports) {
192
194
  }
193
195
  }
194
196
 
195
- const svgTempWrapper = document.createElement('div');
197
+ document.createElement('div');
198
+ const htmlCreator = (tag) => document.createElement(tag);
199
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/2000/svg', tag);
200
+ const mathMLCreator = (tag) => document.createElementNS('http://www.w3.org/1998/Math/MathML', tag);
201
+ let creator = htmlCreator;
202
+ // # consts
203
+ const SVG_ATTR_FLAG = '__kt_svg__';
204
+ const MATHML_ATTR_FLAG = '__kt_mathml__';
196
205
  /**
197
206
  * Create an enhanced HTMLElement.
198
207
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -203,7 +212,7 @@ var __ktjs_core__ = (function (exports) {
203
212
  * ## About
204
213
  * @package @ktjs/core
205
214
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
206
- * @version 0.19.1 (Last Update: 2026.01.31 23:07:55.249)
215
+ * @version 0.20.1 (Last Update: 2026.02.01 16:38:49.148)
207
216
  * @license MIT
208
217
  * @link https://github.com/baendlorel/kt.js
209
218
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -214,15 +223,32 @@ var __ktjs_core__ = (function (exports) {
214
223
  if (typeof tag !== 'string') {
215
224
  $throw('tagName must be a string.');
216
225
  }
226
+ if (attr) {
227
+ if (SVG_ATTR_FLAG in attr) {
228
+ delete attr[SVG_ATTR_FLAG];
229
+ creator = svgCreator;
230
+ }
231
+ else if (MATHML_ATTR_FLAG in attr) {
232
+ delete attr[MATHML_ATTR_FLAG];
233
+ creator = mathMLCreator;
234
+ }
235
+ else {
236
+ creator = htmlCreator;
237
+ }
238
+ }
217
239
  // * start creating the element
218
- const element = document.createElement(tag);
240
+ const element = creator(tag);
219
241
  // * Handle content
220
242
  applyAttr(element, attr);
221
243
  applyContent(element, content);
222
- if (tag === 'svg') {
223
- svgTempWrapper.innerHTML = element.outerHTML;
224
- return svgTempWrapper.firstChild;
225
- }
244
+ // if (tag === 'svg') {
245
+ // tempWrapper.innerHTML = element.outerHTML;
246
+ // return tempWrapper.firstChild as HTML<T>;
247
+ // }
248
+ // if (tag === 'math') {
249
+ // tempWrapper.innerHTML = element.outerHTML;
250
+ // return tempWrapper.firstChild as HTML<T>;
251
+ // }
226
252
  return element;
227
253
  };
228
254
 
@@ -287,21 +313,13 @@ var __ktjs_core__ = (function (exports) {
287
313
  * @param tag html tag or function component
288
314
  * @param props properties/attributes
289
315
  */
290
- function jsx(tag, props = {}) {
316
+ function jsx(tag, props) {
291
317
  const ref = props.ref?.isKT ? props.ref : dummyRef;
292
318
  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
319
  if ('k-if' in props && !props['k-if']) {
320
+ // & make comment placeholder in case that ref might be redrawn later
302
321
  el = document.createComment('k-if');
303
- ref.value = el; // & ref setter automatically replaces old element in DOM
304
- el.redraw = redraw;
322
+ ref.value = el;
305
323
  return el;
306
324
  }
307
325
  // Handle function components
@@ -311,7 +329,6 @@ var __ktjs_core__ = (function (exports) {
311
329
  else {
312
330
  el = h(tag, props, props.children);
313
331
  }
314
- el.redraw ??= redraw;
315
332
  ref.value = el;
316
333
  return el;
317
334
  }
@@ -355,32 +372,6 @@ var __ktjs_core__ = (function (exports) {
355
372
  * This is called when using jsx: "react-jsx" or "react-jsxdev"
356
373
  */
357
374
  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
375
  /**
385
376
  * A helper to create redrawable elements
386
377
  * ```tsx
@@ -397,13 +388,12 @@ var __ktjs_core__ = (function (exports) {
397
388
  */
398
389
  function createRedrawable(creator) {
399
390
  const elRef = ref();
400
- elRef.value = creator();
401
391
  const redraw = () => {
402
392
  elRef.value = creator(); // ref setter automatically calls replaceWith
403
- elRef.value.redraw = redraw;
393
+ elRef.redraw = redraw;
404
394
  return elRef.value;
405
395
  };
406
- elRef.value.redraw = redraw;
396
+ redraw();
407
397
  return elRef;
408
398
  }
409
399
 
@@ -637,7 +627,6 @@ var __ktjs_core__ = (function (exports) {
637
627
  exports.KTRef = KTRef;
638
628
  exports.createElement = h;
639
629
  exports.createRedrawable = createRedrawable;
640
- exports.createRedrawableNoref = createRedrawableNoref;
641
630
  exports.h = h;
642
631
  exports.jsx = jsx;
643
632
  exports.jsxDEV = jsxDEV;