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