@ktjs/jsx 0.6.4 → 0.6.6
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.cjs +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.cjs +34 -27
- package/dist/jsx-runtime.d.ts +6 -1
- package/dist/jsx-runtime.mjs +35 -28
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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;return delete o.children,e.h(t,o,s)}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;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { HTMLTag, KTRawAttr, KTRawContent, ktnull, KTAttribute } from '@ktjs/core';
|
|
2
2
|
export { h as createElement, h } from '@ktjs/core';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @param tag html tag
|
|
6
|
+
* @param props properties/attributes
|
|
7
|
+
* @param _metadata metadata is ignored
|
|
8
|
+
*/
|
|
9
|
+
declare function jsx<T extends HTMLTag>(tag: T, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T];
|
|
5
10
|
/**
|
|
6
11
|
* Fragment support - returns an array of children
|
|
7
12
|
* Note: kt.js doesn't have a real Fragment concept,
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as t
|
|
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;return delete r.children,t(e,r,c)}function n(t){window.__ktjs__.throws("kt.js doesn't have a Fragment concept")}const o=e,r=e;export{n as Fragment,e as jsx,o as jsxDEV,r as jsxs};
|
package/dist/jsx-runtime.cjs
CHANGED
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@ktjs/core');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @param tag html tag
|
|
7
|
+
* @param props properties/attributes
|
|
8
|
+
* @param _metadata metadata is ignored
|
|
9
|
+
*/
|
|
10
|
+
function jsx(tag, props, ..._metadata) {
|
|
6
11
|
const propObj = typeof props === 'string' ? { class: props } : props;
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
if (propObj === undefined || propObj === null) {
|
|
13
|
+
return core.h(tag);
|
|
14
|
+
}
|
|
15
|
+
const children = propObj.children;
|
|
16
|
+
delete propObj.children;
|
|
9
17
|
return core.h(tag, propObj, children);
|
|
10
18
|
}
|
|
11
19
|
/**
|
|
@@ -13,31 +21,30 @@ function jsx(tag, props, ...metadata) {
|
|
|
13
21
|
* Note: kt.js doesn't have a real Fragment concept,
|
|
14
22
|
* so we return ktnull for empty fragments or flatten children
|
|
15
23
|
*/
|
|
16
|
-
// todo 实在不需要也可以在此函数内直接报错说自己不支持
|
|
17
24
|
function Fragment(props) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
wrapper.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
return wrapper;
|
|
25
|
+
window.__ktjs__.throws("kt.js doesn't have a Fragment concept");
|
|
26
|
+
// const { children } = props || {};
|
|
27
|
+
// if (!children) {
|
|
28
|
+
// return ktnull;
|
|
29
|
+
// }
|
|
30
|
+
// // If single child, return it directly
|
|
31
|
+
// if (!Array.isArray(children)) {
|
|
32
|
+
// return children as HTMLElement;
|
|
33
|
+
// }
|
|
34
|
+
// // For multiple children, create a document fragment wrapper
|
|
35
|
+
// // This is a limitation - JSX fragments must be wrapped in kt.js
|
|
36
|
+
// const wrapper = document.createElement('div');
|
|
37
|
+
// wrapper.setAttribute('data-kt-fragment', 'true');
|
|
38
|
+
// children.forEach((child) => {
|
|
39
|
+
// if (child && child !== ktnull) {
|
|
40
|
+
// if (typeof child === 'string') {
|
|
41
|
+
// wrapper.appendChild(document.createTextNode(child));
|
|
42
|
+
// } else if (child instanceof HTMLElement) {
|
|
43
|
+
// wrapper.appendChild(child);
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// });
|
|
47
|
+
// return wrapper;
|
|
41
48
|
}
|
|
42
49
|
/**
|
|
43
50
|
* JSX Development runtime - same as jsx but with additional dev checks
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { HTMLTag, KTRawAttr, KTRawContent, ktnull } from '@ktjs/core';
|
|
2
2
|
export { h as createElement, h } from '@ktjs/core';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @param tag html tag
|
|
6
|
+
* @param props properties/attributes
|
|
7
|
+
* @param _metadata metadata is ignored
|
|
8
|
+
*/
|
|
9
|
+
declare function jsx<T extends HTMLTag>(tag: T, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T];
|
|
5
10
|
/**
|
|
6
11
|
* Fragment support - returns an array of children
|
|
7
12
|
* Note: kt.js doesn't have a real Fragment concept,
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { h
|
|
1
|
+
import { h } from '@ktjs/core';
|
|
2
2
|
export { h as createElement, h } from '@ktjs/core';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @param tag html tag
|
|
6
|
+
* @param props properties/attributes
|
|
7
|
+
* @param _metadata metadata is ignored
|
|
8
|
+
*/
|
|
9
|
+
function jsx(tag, props, ..._metadata) {
|
|
5
10
|
const propObj = typeof props === 'string' ? { class: props } : props;
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
if (propObj === undefined || propObj === null) {
|
|
12
|
+
return h(tag);
|
|
13
|
+
}
|
|
14
|
+
const children = propObj.children;
|
|
15
|
+
delete propObj.children;
|
|
8
16
|
return h(tag, propObj, children);
|
|
9
17
|
}
|
|
10
18
|
/**
|
|
@@ -12,31 +20,30 @@ function jsx(tag, props, ...metadata) {
|
|
|
12
20
|
* Note: kt.js doesn't have a real Fragment concept,
|
|
13
21
|
* so we return ktnull for empty fragments or flatten children
|
|
14
22
|
*/
|
|
15
|
-
// todo 实在不需要也可以在此函数内直接报错说自己不支持
|
|
16
23
|
function Fragment(props) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
wrapper.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
return wrapper;
|
|
24
|
+
window.__ktjs__.throws("kt.js doesn't have a Fragment concept");
|
|
25
|
+
// const { children } = props || {};
|
|
26
|
+
// if (!children) {
|
|
27
|
+
// return ktnull;
|
|
28
|
+
// }
|
|
29
|
+
// // If single child, return it directly
|
|
30
|
+
// if (!Array.isArray(children)) {
|
|
31
|
+
// return children as HTMLElement;
|
|
32
|
+
// }
|
|
33
|
+
// // For multiple children, create a document fragment wrapper
|
|
34
|
+
// // This is a limitation - JSX fragments must be wrapped in kt.js
|
|
35
|
+
// const wrapper = document.createElement('div');
|
|
36
|
+
// wrapper.setAttribute('data-kt-fragment', 'true');
|
|
37
|
+
// children.forEach((child) => {
|
|
38
|
+
// if (child && child !== ktnull) {
|
|
39
|
+
// if (typeof child === 'string') {
|
|
40
|
+
// wrapper.appendChild(document.createTextNode(child));
|
|
41
|
+
// } else if (child instanceof HTMLElement) {
|
|
42
|
+
// wrapper.appendChild(child);
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
// });
|
|
46
|
+
// return wrapper;
|
|
40
47
|
}
|
|
41
48
|
/**
|
|
42
49
|
* JSX Development runtime - same as jsx but with additional dev checks
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ktjs/jsx",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
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",
|
|
@@ -37,12 +37,6 @@
|
|
|
37
37
|
"README.md",
|
|
38
38
|
"LICENSE"
|
|
39
39
|
],
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "rollup -c rollup.config.mjs",
|
|
42
|
-
"dev": "rollup -c rollup.config.mjs -w",
|
|
43
|
-
"check": "tsc --noEmit",
|
|
44
|
-
"test": "vitest"
|
|
45
|
-
},
|
|
46
40
|
"keywords": [
|
|
47
41
|
"ktjs",
|
|
48
42
|
"jsx",
|
|
@@ -60,6 +54,12 @@
|
|
|
60
54
|
"@ktjs/core": "^0.5.0"
|
|
61
55
|
},
|
|
62
56
|
"devDependencies": {
|
|
63
|
-
"@ktjs/core": "
|
|
57
|
+
"@ktjs/core": "0.6.6"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "rollup -c rollup.config.mjs",
|
|
61
|
+
"dev": "rollup -c rollup.config.mjs -w",
|
|
62
|
+
"check": "tsc --noEmit",
|
|
63
|
+
"test": "vitest"
|
|
64
64
|
}
|
|
65
65
|
}
|