tdesign-react
Version:
TDesign Component for React
111 lines (107 loc) • 4.4 kB
JavaScript
/**
* tdesign v1.15.1
* (c) 2025 tdesign
* @license MIT
*/
import { _ as _asyncToGenerator, r as regenerator } from '../_chunks/dep-a74cc5e4.js';
import { _ as _typeof } from '../_chunks/dep-eca3a3de.js';
import { _ as _defineProperty } from '../_chunks/dep-cb0a3966.js';
import * as ReactDOM from 'react-dom';
import '../_chunks/dep-e29214cb.js';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var fullClone = _objectSpread({}, ReactDOM);
var version = fullClone.version,
reactRender = fullClone.render,
unmountComponentAtNode = fullClone.unmountComponentAtNode;
var legacyCreateRoot;
var mainVersion = Number((version || "").split(".")[0]);
try {
if (mainVersion >= 18 && mainVersion < 19) {
legacyCreateRoot = fullClone.createRoot;
}
} catch (e) {}
function toggleWarning(skip) {
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = fullClone.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && _typeof(__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === "object") {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
}
}
function react19AdapterWarn() {
if (process.env.NODE_ENV === "development" && mainVersion >= 19 && !legacyCreateRoot) {
console.warn("TDesign warning: Please import react-19-adapter in React 19, See link: https://github.com/Tencent/tdesign-react/blob/develop/packages/tdesign-react/site/docs/getting-started.md#\u5982\u4F55\u5728-react-19-\u4E2D\u4F7F\u7528");
}
}
var MARK = "__td_react_root__";
function modernRender(node, container) {
toggleWarning(true);
var root = container[MARK] || legacyCreateRoot(container);
toggleWarning(false);
root.render(node);
container[MARK] = root;
}
function legacyRender(node, container) {
reactRender(node, container);
}
function render(node, container) {
react19AdapterWarn();
if (legacyCreateRoot) {
modernRender(node, container);
return;
}
legacyRender === null || legacyRender === void 0 || legacyRender(node, container);
}
function modernUnmount(_x) {
return _modernUnmount.apply(this, arguments);
}
function _modernUnmount() {
_modernUnmount = _asyncToGenerator(/*#__PURE__*/regenerator.mark(function _callee(container) {
return regenerator.wrap(function (_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", Promise.resolve().then(function () {
var _container$MARK;
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 || _container$MARK.unmount();
delete container[MARK];
}));
case 1:
case "end":
return _context.stop();
}
}, _callee);
}));
return _modernUnmount.apply(this, arguments);
}
function legacyUnmount(container) {
unmountComponentAtNode(container);
}
function unmount(_x2) {
return _unmount.apply(this, arguments);
}
function _unmount() {
_unmount = _asyncToGenerator(/*#__PURE__*/regenerator.mark(function _callee2(container) {
return regenerator.wrap(function (_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
if (!(legacyCreateRoot !== void 0)) {
_context2.next = 1;
break;
}
return _context2.abrupt("return", modernUnmount(container));
case 1:
legacyUnmount(container);
case 2:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return _unmount.apply(this, arguments);
}
function renderAdapter(render2) {
if (render2) {
legacyCreateRoot = render2;
}
}
export { render, renderAdapter, unmount };
//# sourceMappingURL=react-render.js.map