@dark-engine/core
Version:
The lightweight and powerful UI rendering engine without dependencies and written in TypeScript (Browser, Node.js, Android, iOS, Windows, Linux, macOS)
27 lines (26 loc) • 954 B
JavaScript
import { detectIsString, detectIsFunction, detectIsEmpty, detectIsArray, detectIsUndefined } from './utils';
import { View } from './view';
import { KEY_ATTR } from './constants';
import { Fragment } from './fragment';
function jsx(element, props, key) {
const { children, slot: $slot, ...$props } = props;
const content = !detectIsUndefined(children) ? children : !detectIsUndefined($slot) ? $slot : [];
const slot = detectIsArray(content) ? content : [content];
if (key || !detectIsEmpty(key)) {
$props[KEY_ATTR] = key;
}
if (detectIsString(element)) {
const options = $props || {};
options.as = element;
options.slot = slot;
return View(options);
}
if (detectIsFunction(element)) {
const options = $props || {};
options.slot = slot.length === 1 ? slot[0] : slot;
return element(options);
}
return null;
}
export { jsx, jsx as jsxs, jsx as jsxDEV, Fragment };
//# sourceMappingURL=jsx-runtime.js.map