@ktjs/jsx 0.6.2 → 0.6.3

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.
@@ -1 +1,62 @@
1
- "use strict";var t=require("@ktjs/core");function e(e,r,...n){const o="string"==typeof r?{class:r}:r;return t.h(e,o,n)}const r=e,n=e;Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return t.h}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return t.h}}),exports.Fragment=function(e){const{children:r}=e||{};if(!r)return t.ktnull;if(!Array.isArray(r))return r;const n=document.createElement("div");return n.setAttribute("data-kt-fragment","true"),r.forEach(e=>{e&&e!==t.ktnull&&("string"==typeof e?n.appendChild(document.createTextNode(e)):e instanceof HTMLElement&&n.appendChild(e))}),n},exports.jsx=e,exports.jsxDEV=r,exports.jsxs=n;
1
+ 'use strict';
2
+
3
+ var core = require('@ktjs/core');
4
+
5
+ function jsx(tag, props, ...children) {
6
+ const propObj = typeof props === 'string' ? { class: props } : props;
7
+ console.log('jsx tag', tag, 'props', props, 'rest children', children);
8
+ return core.h(tag, propObj, children);
9
+ }
10
+ /**
11
+ * Fragment support - returns an array of children
12
+ * Note: kt.js doesn't have a real Fragment concept,
13
+ * so we return ktnull for empty fragments or flatten children
14
+ */
15
+ // todo 实在不需要也可以在此函数内直接报错说自己不支持
16
+ function Fragment(props) {
17
+ const { children } = props || {};
18
+ if (!children) {
19
+ return core.ktnull;
20
+ }
21
+ // If single child, return it directly
22
+ if (!Array.isArray(children)) {
23
+ return children;
24
+ }
25
+ // For multiple children, create a document fragment wrapper
26
+ // This is a limitation - JSX fragments must be wrapped in kt.js
27
+ const wrapper = document.createElement('div');
28
+ wrapper.setAttribute('data-kt-fragment', 'true');
29
+ children.forEach((child) => {
30
+ if (child && child !== core.ktnull) {
31
+ if (typeof child === 'string') {
32
+ wrapper.appendChild(document.createTextNode(child));
33
+ }
34
+ else if (child instanceof HTMLElement) {
35
+ wrapper.appendChild(child);
36
+ }
37
+ }
38
+ });
39
+ return wrapper;
40
+ }
41
+ /**
42
+ * JSX Development runtime - same as jsx but with additional dev checks
43
+ */
44
+ const jsxDEV = jsx;
45
+ /**
46
+ * JSX runtime for React 17+ automatic runtime
47
+ * This is called when using jsx: "react-jsx" or "react-jsxdev"
48
+ */
49
+ const jsxs = jsx;
50
+
51
+ Object.defineProperty(exports, "createElement", {
52
+ enumerable: true,
53
+ get: function () { return core.h; }
54
+ });
55
+ Object.defineProperty(exports, "h", {
56
+ enumerable: true,
57
+ get: function () { return core.h; }
58
+ });
59
+ exports.Fragment = Fragment;
60
+ exports.jsx = jsx;
61
+ exports.jsxDEV = jsxDEV;
62
+ exports.jsxs = jsxs;
@@ -1 +1,50 @@
1
- import{h as t,ktnull as r}from"@ktjs/core";export{h as createElement,h}from"@ktjs/core";function e(r,e,...n){return t(r,"string"==typeof e?{class:e}:e,n)}function n(t){const{children:e}=t||{};if(!e)return r;if(!Array.isArray(e))return e;const n=document.createElement("div");return n.setAttribute("data-kt-fragment","true"),e.forEach(t=>{t&&t!==r&&("string"==typeof t?n.appendChild(document.createTextNode(t)):t instanceof HTMLElement&&n.appendChild(t))}),n}const o=e,c=e;export{n as Fragment,e as jsx,o as jsxDEV,c as jsxs};
1
+ import { h, ktnull } from '@ktjs/core';
2
+ export { h as createElement, h } from '@ktjs/core';
3
+
4
+ function jsx(tag, props, ...children) {
5
+ const propObj = typeof props === 'string' ? { class: props } : props;
6
+ console.log('jsx tag', tag, 'props', props, 'rest children', children);
7
+ return h(tag, propObj, children);
8
+ }
9
+ /**
10
+ * Fragment support - returns an array of children
11
+ * Note: kt.js doesn't have a real Fragment concept,
12
+ * so we return ktnull for empty fragments or flatten children
13
+ */
14
+ // todo 实在不需要也可以在此函数内直接报错说自己不支持
15
+ function Fragment(props) {
16
+ const { children } = props || {};
17
+ if (!children) {
18
+ return ktnull;
19
+ }
20
+ // If single child, return it directly
21
+ if (!Array.isArray(children)) {
22
+ return children;
23
+ }
24
+ // For multiple children, create a document fragment wrapper
25
+ // This is a limitation - JSX fragments must be wrapped in kt.js
26
+ const wrapper = document.createElement('div');
27
+ wrapper.setAttribute('data-kt-fragment', 'true');
28
+ children.forEach((child) => {
29
+ if (child && child !== ktnull) {
30
+ if (typeof child === 'string') {
31
+ wrapper.appendChild(document.createTextNode(child));
32
+ }
33
+ else if (child instanceof HTMLElement) {
34
+ wrapper.appendChild(child);
35
+ }
36
+ }
37
+ });
38
+ return wrapper;
39
+ }
40
+ /**
41
+ * JSX Development runtime - same as jsx but with additional dev checks
42
+ */
43
+ const jsxDEV = jsx;
44
+ /**
45
+ * JSX runtime for React 17+ automatic runtime
46
+ * This is called when using jsx: "react-jsx" or "react-jsxdev"
47
+ */
48
+ const jsxs = jsx;
49
+
50
+ export { Fragment, jsx, jsxDEV, jsxs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/jsx",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
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",