File tree 6 files changed +50
-2
lines changed
packages/sui-widget-embedder
6 files changed +50
-2
lines changed Original file line number Diff line number Diff line change
1
+ react /
Original file line number Diff line number Diff line change
1
+ src-react
Original file line number Diff line number Diff line change 6
6
"sui-widget-embedder" : " ./bin/sui-widget-embedder.js"
7
7
},
8
8
"main" : " index.js" ,
9
- "scripts" : {},
9
+ "scripts" : {
10
+ "prepublish" : " babel --presets sui ./src-react --out-dir ./react"
11
+ },
10
12
"keywords" : [],
11
13
"author" : " " ,
12
14
"license" : " ISC" ,
13
15
"devDependencies" : {
14
16
"@s-ui/bundler" : " 2" ,
15
- "@s-ui/lint" : " 2"
17
+ "@s-ui/lint" : " 2" ,
18
+ "babel-cli" : " 6.26.0"
16
19
},
17
20
"dependencies" : {
21
+ "@s-ui/component-peer-dependencies" : " 1" ,
22
+ "@s-ui/react-domain-connector" : " 1" ,
18
23
"commander" : " 2.11.0" ,
19
24
"express" : " 4.16.2" ,
20
25
"http-proxy" : " 1.16.2" ,
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import ReactDOM from 'react-dom'
4
+
5
+ import { Provider } from '@s-ui/react-domain-connector'
6
+
7
+ export default class Widget extends Component {
8
+ static propTypes = {
9
+ children : PropTypes . element ,
10
+ node : PropTypes . string ,
11
+ i18n : PropTypes . object ,
12
+ domain : PropTypes . object
13
+ }
14
+
15
+ componentDidMount ( ) {
16
+ const node = document . querySelector ( this . props . node )
17
+ const { children, i18n, domain} = this . props
18
+ ReactDOM . render (
19
+ < Provider i18n = { i18n } domain = { domain } >
20
+ { children }
21
+ </ Provider > ,
22
+ node
23
+ )
24
+ }
25
+
26
+ render ( ) { return null }
27
+ }
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ export default function Widgets ( props ) {
5
+ return < div key = { Math . random ( ) } > { props . children } </ div >
6
+ }
7
+ Widgets . propTypes = { children : PropTypes . node }
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom'
3
+
4
+ document . body . innerHTML += '<div id="root"></div>'
5
+ export default function render ( root ) {
6
+ ReactDOM . render ( < div > { root } </ div > , document . querySelector ( '#root' ) )
7
+ }
You can’t perform that action at this time.
0 commit comments