@teambit/react.ui.compositions-app 0.0.25 → 0.0.27

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,15 +1,34 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
3
2
  import type { RenderingContext } from '@teambit/preview';
4
3
 
5
4
  import { CompositionsApp } from './compositions-app';
6
5
 
6
+ type Root = { render: (element: React.ReactElement) => void };
7
+ let root: Root | undefined;
8
+
9
+ function createCompatRoot(container: HTMLElement): Root {
10
+ try {
11
+ // React 18+: react-dom/client exists and exports createRoot
12
+ // eslint-disable-next-line import/no-extraneous-dependencies
13
+ return require('react-dom/client').createRoot(container);
14
+ } catch {
15
+ // React 17 fallback: react-dom/client does not exist
16
+ // eslint-disable-next-line import/no-extraneous-dependencies
17
+ const ReactDOM = require('react-dom');
18
+ return {
19
+ render: (element) => {
20
+ ReactDOM.render(element, container);
21
+ },
22
+ };
23
+ }
24
+ }
25
+
7
26
  /**
8
27
  * mounts compositions into the DOM in the component preview.
9
28
  */
10
29
  export default (Composition: React.ComponentType, previewContext: RenderingContext) => {
11
- ReactDOM.render(
12
- <CompositionsApp Composition={Composition} previewContext={previewContext} />,
13
- document.getElementById('root')
14
- );
30
+ if (!root) {
31
+ root = createCompatRoot(document.getElementById('root')!);
32
+ }
33
+ root.render(<CompositionsApp Composition={Composition} previewContext={previewContext} />);
15
34
  };
@@ -4,12 +4,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const react_dom_1 = __importDefault(require("react-dom"));
8
7
  const compositions_app_1 = require("./compositions-app");
8
+ let root;
9
+ function createCompatRoot(container) {
10
+ try {
11
+ // React 18+: react-dom/client exists and exports createRoot
12
+ // eslint-disable-next-line import/no-extraneous-dependencies
13
+ return require('react-dom/client').createRoot(container);
14
+ }
15
+ catch (_a) {
16
+ // React 17 fallback: react-dom/client does not exist
17
+ // eslint-disable-next-line import/no-extraneous-dependencies
18
+ const ReactDOM = require('react-dom');
19
+ return {
20
+ render: (element) => {
21
+ ReactDOM.render(element, container);
22
+ },
23
+ };
24
+ }
25
+ }
9
26
  /**
10
27
  * mounts compositions into the DOM in the component preview.
11
28
  */
12
29
  exports.default = (Composition, previewContext) => {
13
- react_dom_1.default.render(react_1.default.createElement(compositions_app_1.CompositionsApp, { Composition: Composition, previewContext: previewContext }), document.getElementById('root'));
30
+ if (!root) {
31
+ root = createCompatRoot(document.getElementById('root'));
32
+ }
33
+ root.render(react_1.default.createElement(compositions_app_1.CompositionsApp, { Composition: Composition, previewContext: previewContext }));
14
34
  };
15
35
  //# sourceMappingURL=compositions.app-root.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compositions.app-root.js","sourceRoot":"","sources":["../compositions.app-root.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,0DAAiC;AAGjC,yDAAqD;AAErD;;GAEG;AACH,kBAAe,CAAC,WAAgC,EAAE,cAAgC,EAAE,EAAE;IACpF,mBAAQ,CAAC,MAAM,CACb,8BAAC,kCAAe,IAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,GAAI,EAC7E,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAChC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"compositions.app-root.js","sourceRoot":"","sources":["../compositions.app-root.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAG1B,yDAAqD;AAGrD,IAAI,IAAsB,CAAC;AAE3B,SAAS,gBAAgB,CAAC,SAAsB;IAC9C,IAAI,CAAC;QACH,4DAA4D;QAC5D,6DAA6D;QAC7D,OAAO,OAAO,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IAAC,WAAM,CAAC;QACP,qDAAqD;QACrD,6DAA6D;QAC7D,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO;YACL,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;gBAClB,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACtC,CAAC;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,kBAAe,CAAC,WAAgC,EAAE,cAAgC,EAAE,EAAE;IACpF,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAE,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,8BAAC,kCAAe,IAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,GAAI,CAAC,CAAC;AAC7F,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.react_ui_compositions-app@0.0.25/dist/compositions.compositions.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.react_ui_compositions-app@0.0.25/dist/composition-app.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.react_ui_compositions-app@0.0.27/dist/compositions.compositions.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.react_ui_compositions-app@0.0.27/dist/composition-app.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@teambit/react.ui.compositions-app",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "homepage": "https://bit.cloud/teambit/react/ui/compositions-app",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.react",
8
8
  "name": "ui/compositions-app",
9
- "version": "0.0.25"
9
+ "version": "0.0.27"
10
10
  },
11
11
  "dependencies": {
12
12
  "core-js": "^3.0.0",
13
13
  "@teambit/base-ui.utils.composer": "1.0.0",
14
14
  "@teambit/design.ui.pages.standalone-not-found-page": "0.0.370",
15
- "@teambit/react.ui.loader-fallback": "0.0.112"
15
+ "@teambit/react.ui.loader-fallback": "0.0.114"
16
16
  },
17
17
  "devDependencies": {
18
- "@types/react": "^17.0.8",
19
- "@types/react-dom": "^17.0.5",
18
+ "@types/react": "^19.0.0",
19
+ "@types/react-dom": "^19.0.0",
20
20
  "@types/mocha": "9.1.0",
21
21
  "@types/node": "12.20.4",
22
22
  "@types/jest": "^26.0.0",
@@ -24,8 +24,8 @@
24
24
  "@types/testing-library__jest-dom": "5.9.5"
25
25
  },
26
26
  "peerDependencies": {
27
- "react": "^16.8.0 || ^17.0.0",
28
- "react-dom": "^16.8.0 || ^17.0.0"
27
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
28
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
29
29
  },
30
30
  "license": "Apache-2.0",
31
31
  "optionalDependencies": {},