@ktjs/core 0.8.5 → 0.9.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 CHANGED
@@ -28,8 +28,8 @@ interface KTRef<T> {
28
28
  }
29
29
  declare function ref<T>(value?: T): KTRef<T>;
30
30
 
31
- type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
32
- type KTRawContent = Ctt[] | Ctt;
31
+ type KTAvailableContent = KTRef<any> | HTMLElement | string | number | undefined;
32
+ type KTRawContent = KTAvailableContent[] | KTAvailableContent;
33
33
  type KTRawAttr = KTAttribute | string;
34
34
  type KTRawContents = (HTMLElement | string | undefined)[];
35
35
 
@@ -113,7 +113,7 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
113
113
  * ## About
114
114
  * @package @ktjs/core
115
115
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
116
- * @version 0.8.5 (Last Update: 2025.12.29 10:16:21.619)
116
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
117
117
  * @license MIT
118
118
  * @link https://github.com/baendlorel/kt.js
119
119
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -123,11 +123,11 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
123
123
  declare const h: H;
124
124
 
125
125
  /**
126
- * @param tag html tag
126
+ * @param tag html tag or function component
127
127
  * @param props properties/attributes
128
128
  * @param _metadata metadata is ignored
129
129
  */
130
- declare function jsx<T extends HTMLTag>(tag: T, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T];
130
+ declare function jsx<T extends HTMLTag>(tag: T | Function, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T] | HTMLElement;
131
131
  /**
132
132
  * Fragment support - returns an array of children
133
133
  * Note: kt.js doesn't have a real Fragment concept,
@@ -204,7 +204,7 @@ var __ktjs_core__ = (function (exports) {
204
204
  * ## About
205
205
  * @package @ktjs/core
206
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
207
- * @version 0.8.5 (Last Update: 2025.12.29 10:16:21.619)
207
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
208
208
  * @license MIT
209
209
  * @link https://github.com/baendlorel/kt.js
210
210
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -225,11 +225,18 @@ var __ktjs_core__ = (function (exports) {
225
225
  $mark(h, 'h');
226
226
 
227
227
  /**
228
- * @param tag html tag
228
+ * @param tag html tag or function component
229
229
  * @param props properties/attributes
230
230
  * @param _metadata metadata is ignored
231
231
  */
232
232
  function jsx(tag, props, ..._metadata) {
233
+ // Handle function components
234
+ if (typeof tag === 'function') {
235
+ const propObj = typeof props === 'string' ? { class: props } : props || {};
236
+ const children = propObj.children;
237
+ return tag({ ...propObj, children });
238
+ }
239
+ // Handle regular HTML tags
233
240
  const propObj = typeof props === 'string' ? { class: props } : props;
234
241
  if (propObj === undefined || propObj === null) {
235
242
  return h(tag);
@@ -215,7 +215,7 @@ var __ktjs_core__ = (function (exports) {
215
215
  * ## About
216
216
  * @package @ktjs/core
217
217
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
218
- * @version 0.8.5 (Last Update: 2025.12.29 10:16:21.619)
218
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
219
219
  * @license MIT
220
220
  * @link https://github.com/baendlorel/kt.js
221
221
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -254,6 +254,17 @@ var __ktjs_core__ = (function (exports) {
254
254
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
255
255
 
256
256
 
257
+ var __assign = function() {
258
+ __assign = Object.assign || function __assign(t) {
259
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
260
+ s = arguments[i];
261
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
262
+ }
263
+ return t;
264
+ };
265
+ return __assign.apply(this, arguments);
266
+ };
267
+
257
268
  function __spreadArray(to, from, pack) {
258
269
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
259
270
  if (ar || !(i in from)) {
@@ -270,12 +281,19 @@ var __ktjs_core__ = (function (exports) {
270
281
  };
271
282
 
272
283
  /**
273
- * @param tag html tag
284
+ * @param tag html tag or function component
274
285
  * @param props properties/attributes
275
286
  * @param _metadata metadata is ignored
276
287
  */
277
288
  function jsx(tag, props) {
278
289
  var _a;
290
+ // Handle function components
291
+ if (typeof tag === 'function') {
292
+ var propObj_1 = typeof props === 'string' ? { class: props } : props || {};
293
+ var children_1 = propObj_1.children;
294
+ return tag(__assign(__assign({}, propObj_1), { children: children_1 }));
295
+ }
296
+ // Handle regular HTML tags
279
297
  var propObj = typeof props === 'string' ? { class: props } : props;
280
298
  if (propObj === undefined || propObj === null) {
281
299
  return h(tag);
package/dist/index.mjs CHANGED
@@ -201,7 +201,7 @@ function applyContent(element, content) {
201
201
  * ## About
202
202
  * @package @ktjs/core
203
203
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
204
- * @version 0.8.5 (Last Update: 2025.12.29 10:16:21.619)
204
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
205
205
  * @license MIT
206
206
  * @link https://github.com/baendlorel/kt.js
207
207
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -222,11 +222,18 @@ const h = ((tag, attr = '', content = '') => {
222
222
  $mark(h, 'h');
223
223
 
224
224
  /**
225
- * @param tag html tag
225
+ * @param tag html tag or function component
226
226
  * @param props properties/attributes
227
227
  * @param _metadata metadata is ignored
228
228
  */
229
229
  function jsx(tag, props, ..._metadata) {
230
+ // Handle function components
231
+ if (typeof tag === 'function') {
232
+ const propObj = typeof props === 'string' ? { class: props } : props || {};
233
+ const children = propObj.children;
234
+ return tag({ ...propObj, children });
235
+ }
236
+ // Handle regular HTML tags
230
237
  const propObj = typeof props === 'string' ? { class: props } : props;
231
238
  if (propObj === undefined || propObj === null) {
232
239
  return h(tag);
@@ -11,8 +11,8 @@ interface KTRef<T> {
11
11
  }
12
12
  declare function ref<T>(value?: T): KTRef<T>;
13
13
 
14
- type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
15
- type KTRawContent = Ctt[] | Ctt;
14
+ type KTAvailableContent = KTRef<any> | HTMLElement | string | number | undefined;
15
+ type KTRawContent = KTAvailableContent[] | KTAvailableContent;
16
16
  type KTRawAttr = KTAttribute | string;
17
17
 
18
18
  /**
@@ -90,7 +90,7 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
90
90
  * ## About
91
91
  * @package @ktjs/core
92
92
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
93
- * @version 0.8.5 (Last Update: 2025.12.29 10:16:21.619)
93
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
94
94
  * @license MIT
95
95
  * @link https://github.com/baendlorel/kt.js
96
96
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -106,11 +106,11 @@ declare const h: H;
106
106
  declare const ktnull: any;
107
107
 
108
108
  /**
109
- * @param tag html tag
109
+ * @param tag html tag or function component
110
110
  * @param props properties/attributes
111
111
  * @param _metadata metadata is ignored
112
112
  */
113
- declare function jsx<T extends HTMLTag>(tag: T, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T];
113
+ declare function jsx<T extends HTMLTag>(tag: T | Function, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T] | HTMLElement;
114
114
  /**
115
115
  * Fragment support - returns an array of children
116
116
  * Note: kt.js doesn't have a real Fragment concept,
@@ -184,7 +184,7 @@ function applyContent(element, content) {
184
184
  * ## About
185
185
  * @package @ktjs/core
186
186
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
187
- * @version 0.8.5 (Last Update: 2025.12.29 10:16:21.619)
187
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
188
188
  * @license MIT
189
189
  * @link https://github.com/baendlorel/kt.js
190
190
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -205,11 +205,18 @@ const h = ((tag, attr = '', content = '') => {
205
205
  $mark(h, 'h');
206
206
 
207
207
  /**
208
- * @param tag html tag
208
+ * @param tag html tag or function component
209
209
  * @param props properties/attributes
210
210
  * @param _metadata metadata is ignored
211
211
  */
212
212
  function jsx(tag, props, ..._metadata) {
213
+ // Handle function components
214
+ if (typeof tag === 'function') {
215
+ const propObj = typeof props === 'string' ? { class: props } : props || {};
216
+ const children = propObj.children;
217
+ return tag({ ...propObj, children });
218
+ }
219
+ // Handle regular HTML tags
213
220
  const propObj = typeof props === 'string' ? { class: props } : props;
214
221
  if (propObj === undefined || propObj === null) {
215
222
  return h(tag);
@@ -10,8 +10,8 @@ interface KTRef<T> {
10
10
  isKT: true;
11
11
  }
12
12
 
13
- type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
14
- type KTRawContent = Ctt[] | Ctt;
13
+ type KTAvailableContent = KTRef<any> | HTMLElement | string | number | undefined;
14
+ type KTRawContent = KTAvailableContent[] | KTAvailableContent;
15
15
  type KTRawAttr = KTAttribute | string;
16
16
 
17
17
  /**
@@ -89,7 +89,7 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
89
89
  * ## About
90
90
  * @package @ktjs/core
91
91
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
92
- * @version 0.8.5 (Last Update: 2025.12.29 10:16:21.619)
92
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
93
93
  * @license MIT
94
94
  * @link https://github.com/baendlorel/kt.js
95
95
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -105,11 +105,11 @@ declare const h: H;
105
105
  declare const ktnull: any;
106
106
 
107
107
  /**
108
- * @param tag html tag
108
+ * @param tag html tag or function component
109
109
  * @param props properties/attributes
110
110
  * @param _metadata metadata is ignored
111
111
  */
112
- declare function jsx<T extends HTMLTag>(tag: T, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T];
112
+ declare function jsx<T extends HTMLTag>(tag: T | Function, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T] | HTMLElement;
113
113
  /**
114
114
  * Fragment support - returns an array of children
115
115
  * Note: kt.js doesn't have a real Fragment concept,
@@ -184,7 +184,7 @@ function applyContent(element, content) {
184
184
  * ## About
185
185
  * @package @ktjs/core
186
186
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
187
- * @version 0.8.5 (Last Update: 2025.12.29 10:16:21.619)
187
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
188
188
  * @license MIT
189
189
  * @link https://github.com/baendlorel/kt.js
190
190
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -205,11 +205,18 @@ const h = ((tag, attr = '', content = '') => {
205
205
  $mark(h, 'h');
206
206
 
207
207
  /**
208
- * @param tag html tag
208
+ * @param tag html tag or function component
209
209
  * @param props properties/attributes
210
210
  * @param _metadata metadata is ignored
211
211
  */
212
212
  function jsx(tag, props, ..._metadata) {
213
+ // Handle function components
214
+ if (typeof tag === 'function') {
215
+ const propObj = typeof props === 'string' ? { class: props } : props || {};
216
+ const children = propObj.children;
217
+ return tag({ ...propObj, children });
218
+ }
219
+ // Handle regular HTML tags
213
220
  const propObj = typeof props === 'string' ? { class: props } : props;
214
221
  if (propObj === undefined || propObj === null) {
215
222
  return h(tag);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.8.5",
3
+ "version": "0.9.0",
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",