@ktjs/jsx 0.6.14 → 0.6.16

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
@@ -14,7 +14,7 @@ Write UI code with JSX syntax while maintaining KT.js's philosophy of direct DOM
14
14
  - 🎯 **Direct DOM Manipulation**: JSX compiles to direct `h()` calls, no virtual DOM
15
15
  - 🔧 **Full TypeScript Support**: Complete type safety with IntelliSense
16
16
  - ⚡ **Zero Runtime Overhead**: JSX is pure syntax sugar over KT.js's `h` function
17
- - 🎨 **Event Handler Syntax**: Support for both function props and `@eventName` syntax
17
+ - 🎨 **Event Handler Syntax**: Support for both function props and `on:eventName` syntax
18
18
  - 📦 **Multiple Runtime Modes**: Support both automatic and classic JSX transforms
19
19
  - 🔌 **Easy Integration**: Works with Babel, TypeScript, and modern build tools
20
20
 
@@ -67,7 +67,7 @@ const greeting = <div class="greeting">Hello, KT.js!</div>;
67
67
  const button = (
68
68
  <button
69
69
  class="btn primary"
70
- @click={() => alert('Clicked!')}
70
+ on:click={() => alert('Clicked!')}
71
71
  >
72
72
  Click me
73
73
  </button>
@@ -97,13 +97,13 @@ You can use event handlers in two ways:
97
97
  // 1. Function props (automatically converted to event listeners)
98
98
  <button click={() => console.log('clicked')}>Button 1</button>
99
99
 
100
- // 2. @-prefixed attributes (explicit event handlers)
101
- <button @click={(e) => console.log('clicked', e)}>Button 2</button>
100
+ // 2. on:-prefixed attributes (explicit event handlers)
101
+ <button on:click={(e) => console.log('clicked', e)}>Button 2</button>
102
102
 
103
103
  // 3. Mix both (regular attribute + event listener)
104
104
  <input
105
105
  change="change-value" // Regular attribute
106
- @change={(e) => console.log(e)} // Event listener
106
+ on:change={(e) => console.log(e)} // Event listener
107
107
  />
108
108
  ```
109
109
 
@@ -240,7 +240,7 @@ const buttonStyle = css`
240
240
  `;
241
241
 
242
242
  const button = (
243
- <button class={buttonStyle} @click={() => alert('Styled!')}>
243
+ <button class={buttonStyle} on:click={() => alert('Styled!')}>
244
244
  Styled Button
245
245
  </button>
246
246
  );
@@ -263,7 +263,7 @@ function Card({ title, content, onClose }: CardProps) {
263
263
  <div class="card-header">
264
264
  <h3>{title}</h3>
265
265
  {onClose && (
266
- <button class="close" @click={onClose}>×</button>
266
+ <button class="close" on:click={onClose}>×</button>
267
267
  )}
268
268
  </div>
269
269
  <div class="card-body">
@@ -336,7 +336,7 @@ declare global {
336
336
  const app = (
337
337
  <div class="container">
338
338
  <h1>Hello</h1>
339
- <button @click={() => alert('Hi')}>Click</button>
339
+ <button on:click={() => alert('Hi')}>Click</button>
340
340
  </div>
341
341
  );
342
342
 
@@ -345,7 +345,7 @@ import { h, div, button } from '@ktjs/core';
345
345
 
346
346
  const app = div({ class: 'container' }, [
347
347
  h('h1', {}, 'Hello'),
348
- button({ '@click': () => alert('Hi') }, 'Click')
348
+ button({ 'on:click': () => alert('Hi') }, 'Click')
349
349
  ]);
350
350
  ```
351
351
 
package/dist/index.cjs CHANGED
@@ -1 +1,120 @@
1
- "use strict";var e=require("@ktjs/core");function t(t,n,...r){const o="string"==typeof n?{class:n}:n;if(null==o)return e.h(t);const s=o.children;delete o.children;const c="ref"in o&&"object"==typeof o.ref&&null!==o.ref,u=c?o.ref:null;c&&delete o.ref;const l=e.h(t,o,s);return c&&(u.value=l),l}const n=t,r=t;Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return e.h}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return e.h}}),exports.Fragment=function(e){window.__ktjs__.throws("kt.js doesn't have a Fragment concept")},exports.jsx=t,exports.jsxDEV=n,exports.jsxs=r,exports.ref=function(){return{value:null}};
1
+ 'use strict';
2
+
3
+ var core = require('@ktjs/core');
4
+
5
+ /**
6
+ * @param tag html tag
7
+ * @param props properties/attributes
8
+ * @param _metadata metadata is ignored
9
+ */
10
+ function jsx(tag, props, ..._metadata) {
11
+ const propObj = typeof props === 'string' ? { class: props } : props;
12
+ if (propObj === undefined || propObj === null) {
13
+ return core.h(tag);
14
+ }
15
+ const children = propObj.children;
16
+ delete propObj.children;
17
+ // deal with ref attribute
18
+ const hasRef = 'ref' in propObj && typeof propObj.ref === 'object' && propObj.ref !== null;
19
+ const ref = hasRef ? propObj.ref : null;
20
+ if (hasRef) {
21
+ delete propObj.ref;
22
+ }
23
+ const el = core.h(tag, propObj, children);
24
+ if (hasRef) {
25
+ ref.value = el;
26
+ }
27
+ return el;
28
+ }
29
+ /**
30
+ * Fragment support - returns an array of children
31
+ * Note: kt.js doesn't have a real Fragment concept,
32
+ * so we return ktnull for empty fragments or flatten children
33
+ */
34
+ function Fragment(props) {
35
+ window.__ktjs__.throws("kt.js doesn't have a Fragment concept");
36
+ // const { children } = props || {};
37
+ // if (!children) {
38
+ // return ktnull;
39
+ // }
40
+ // // If single child, return it directly
41
+ // if (!Array.isArray(children)) {
42
+ // return children as HTMLElement;
43
+ // }
44
+ // // For multiple children, create a document fragment wrapper
45
+ // // This is a limitation - JSX fragments must be wrapped in kt.js
46
+ // const wrapper = document.createElement('div');
47
+ // wrapper.setAttribute('data-kt-fragment', 'true');
48
+ // children.forEach((child) => {
49
+ // if (child && child !== ktnull) {
50
+ // if (typeof child === 'string') {
51
+ // wrapper.appendChild(document.createTextNode(child));
52
+ // } else if (child instanceof HTMLElement) {
53
+ // wrapper.appendChild(child);
54
+ // }
55
+ // }
56
+ // });
57
+ // return wrapper;
58
+ }
59
+ /**
60
+ * JSX Development runtime - same as jsx but with additional dev checks
61
+ */
62
+ const jsxDEV = (...args) => {
63
+ console.log('JSX runtime called:', ...args);
64
+ return jsx(...args);
65
+ };
66
+ /**
67
+ * JSX runtime for React 17+ automatic runtime
68
+ * This is called when using jsx: "react-jsx" or "react-jsxdev"
69
+ */
70
+ const jsxs = jsx;
71
+
72
+ /**
73
+ * @ktjs/jsx - JSX/TSX support for KT.js
74
+ *
75
+ * This package provides JSX transformation support for KT.js,
76
+ * allowing you to write UI code with JSX syntax while maintaining
77
+ * the direct DOM manipulation philosophy of KT.js.
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * import { h } from '@ktjs/jsx';
82
+ *
83
+ * const App = (
84
+ * <div class="app">
85
+ * <h1>Hello KT.js with JSX!</h1>
86
+ * <button @click={() => alert('Clicked!')}>
87
+ * Click me
88
+ * </button>
89
+ * </div>
90
+ * );
91
+ * ```
92
+ *
93
+ * ## About
94
+ * @package @ktjs/jsx
95
+ * @author Kasukabe Tsumugi <futami16237@gmail.com>
96
+ * @version 0.6.16 (Last Update: 2025.12.24 22:11:08.516)
97
+ * @license MIT
98
+ * @link https://github.com/baendlorel/kt.js
99
+ * @link https://baendlorel.github.io/ Welcome to my site!
100
+ * @description JSX/TSX support for KT.js - Build UIs with JSX syntax while keeping direct DOM control
101
+ * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
102
+ */
103
+ // Export JSX runtime functions
104
+ function ref() {
105
+ return { value: null };
106
+ }
107
+
108
+ Object.defineProperty(exports, "createElement", {
109
+ enumerable: true,
110
+ get: function () { return core.h; }
111
+ });
112
+ Object.defineProperty(exports, "h", {
113
+ enumerable: true,
114
+ get: function () { return core.h; }
115
+ });
116
+ exports.Fragment = Fragment;
117
+ exports.jsx = jsx;
118
+ exports.jsxDEV = jsxDEV;
119
+ exports.jsxs = jsxs;
120
+ exports.ref = ref;
package/dist/index.d.ts CHANGED
@@ -68,7 +68,7 @@ declare global {
68
68
  * ## About
69
69
  * @package @ktjs/jsx
70
70
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
71
- * @version 0.6.14 (Last Update: 2025.12.24 21:43:46.263)
71
+ * @version 0.6.16 (Last Update: 2025.12.24 22:11:08.516)
72
72
  * @license MIT
73
73
  * @link https://github.com/baendlorel/kt.js
74
74
  * @link https://baendlorel.github.io/ Welcome to my site!
package/dist/index.mjs CHANGED
@@ -1 +1,107 @@
1
- import{h as t}from"@ktjs/core";export{h as createElement,h}from"@ktjs/core";function e(e,n,...o){const r="string"==typeof n?{class:n}:n;if(null==r)return t(e);const c=r.children;delete r.children;const l="ref"in r&&"object"==typeof r.ref&&null!==r.ref,s=l?r.ref:null;l&&delete r.ref;const u=t(e,r,c);return l&&(s.value=u),u}function n(t){window.__ktjs__.throws("kt.js doesn't have a Fragment concept")}const o=e,r=e;function c(){return{value:null}}export{n as Fragment,e as jsx,o as jsxDEV,r as jsxs,c as ref};
1
+ import { h } from '@ktjs/core';
2
+ export { h as createElement, h } from '@ktjs/core';
3
+
4
+ /**
5
+ * @param tag html tag
6
+ * @param props properties/attributes
7
+ * @param _metadata metadata is ignored
8
+ */
9
+ function jsx(tag, props, ..._metadata) {
10
+ const propObj = typeof props === 'string' ? { class: props } : props;
11
+ if (propObj === undefined || propObj === null) {
12
+ return h(tag);
13
+ }
14
+ const children = propObj.children;
15
+ delete propObj.children;
16
+ // deal with ref attribute
17
+ const hasRef = 'ref' in propObj && typeof propObj.ref === 'object' && propObj.ref !== null;
18
+ const ref = hasRef ? propObj.ref : null;
19
+ if (hasRef) {
20
+ delete propObj.ref;
21
+ }
22
+ const el = h(tag, propObj, children);
23
+ if (hasRef) {
24
+ ref.value = el;
25
+ }
26
+ return el;
27
+ }
28
+ /**
29
+ * Fragment support - returns an array of children
30
+ * Note: kt.js doesn't have a real Fragment concept,
31
+ * so we return ktnull for empty fragments or flatten children
32
+ */
33
+ function Fragment(props) {
34
+ window.__ktjs__.throws("kt.js doesn't have a Fragment concept");
35
+ // const { children } = props || {};
36
+ // if (!children) {
37
+ // return ktnull;
38
+ // }
39
+ // // If single child, return it directly
40
+ // if (!Array.isArray(children)) {
41
+ // return children as HTMLElement;
42
+ // }
43
+ // // For multiple children, create a document fragment wrapper
44
+ // // This is a limitation - JSX fragments must be wrapped in kt.js
45
+ // const wrapper = document.createElement('div');
46
+ // wrapper.setAttribute('data-kt-fragment', 'true');
47
+ // children.forEach((child) => {
48
+ // if (child && child !== ktnull) {
49
+ // if (typeof child === 'string') {
50
+ // wrapper.appendChild(document.createTextNode(child));
51
+ // } else if (child instanceof HTMLElement) {
52
+ // wrapper.appendChild(child);
53
+ // }
54
+ // }
55
+ // });
56
+ // return wrapper;
57
+ }
58
+ /**
59
+ * JSX Development runtime - same as jsx but with additional dev checks
60
+ */
61
+ const jsxDEV = (...args) => {
62
+ console.log('JSX runtime called:', ...args);
63
+ return jsx(...args);
64
+ };
65
+ /**
66
+ * JSX runtime for React 17+ automatic runtime
67
+ * This is called when using jsx: "react-jsx" or "react-jsxdev"
68
+ */
69
+ const jsxs = jsx;
70
+
71
+ /**
72
+ * @ktjs/jsx - JSX/TSX support for KT.js
73
+ *
74
+ * This package provides JSX transformation support for KT.js,
75
+ * allowing you to write UI code with JSX syntax while maintaining
76
+ * the direct DOM manipulation philosophy of KT.js.
77
+ *
78
+ * @example
79
+ * ```tsx
80
+ * import { h } from '@ktjs/jsx';
81
+ *
82
+ * const App = (
83
+ * <div class="app">
84
+ * <h1>Hello KT.js with JSX!</h1>
85
+ * <button @click={() => alert('Clicked!')}>
86
+ * Click me
87
+ * </button>
88
+ * </div>
89
+ * );
90
+ * ```
91
+ *
92
+ * ## About
93
+ * @package @ktjs/jsx
94
+ * @author Kasukabe Tsumugi <futami16237@gmail.com>
95
+ * @version 0.6.16 (Last Update: 2025.12.24 22:11:08.516)
96
+ * @license MIT
97
+ * @link https://github.com/baendlorel/kt.js
98
+ * @link https://baendlorel.github.io/ Welcome to my site!
99
+ * @description JSX/TSX support for KT.js - Build UIs with JSX syntax while keeping direct DOM control
100
+ * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
101
+ */
102
+ // Export JSX runtime functions
103
+ function ref() {
104
+ return { value: null };
105
+ }
106
+
107
+ export { Fragment, jsx, jsxDEV, jsxs, ref };
@@ -8,7 +8,6 @@ var core = require('@ktjs/core');
8
8
  * @param _metadata metadata is ignored
9
9
  */
10
10
  function jsx(tag, props, ..._metadata) {
11
- console.log('JSX runtime called:', tag, props, _metadata);
12
11
  const propObj = typeof props === 'string' ? { class: props } : props;
13
12
  if (propObj === undefined || propObj === null) {
14
13
  return core.h(tag);
@@ -60,7 +59,10 @@ function Fragment(props) {
60
59
  /**
61
60
  * JSX Development runtime - same as jsx but with additional dev checks
62
61
  */
63
- const jsxDEV = jsx;
62
+ const jsxDEV = (...args) => {
63
+ console.log('JSX runtime called:', ...args);
64
+ return jsx(...args);
65
+ };
64
66
  /**
65
67
  * JSX runtime for React 17+ automatic runtime
66
68
  * This is called when using jsx: "react-jsx" or "react-jsxdev"
@@ -7,7 +7,6 @@ export { h as createElement, h } from '@ktjs/core';
7
7
  * @param _metadata metadata is ignored
8
8
  */
9
9
  function jsx(tag, props, ..._metadata) {
10
- console.log('JSX runtime called:', tag, props, _metadata);
11
10
  const propObj = typeof props === 'string' ? { class: props } : props;
12
11
  if (propObj === undefined || propObj === null) {
13
12
  return h(tag);
@@ -59,7 +58,10 @@ function Fragment(props) {
59
58
  /**
60
59
  * JSX Development runtime - same as jsx but with additional dev checks
61
60
  */
62
- const jsxDEV = jsx;
61
+ const jsxDEV = (...args) => {
62
+ console.log('JSX runtime called:', ...args);
63
+ return jsx(...args);
64
+ };
63
65
  /**
64
66
  * JSX runtime for React 17+ automatic runtime
65
67
  * This is called when using jsx: "react-jsx" or "react-jsxdev"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/jsx",
3
- "version": "0.6.14",
3
+ "version": "0.6.16",
4
4
  "description": "JSX/TSX support for KT.js - Build UIs with JSX syntax while keeping direct DOM control",
5
5
  "author": {
6
6
  "name": "Kasukabe Tsumugi",