isomorfeus-react 16.13.6 → 16.13.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -10
- data/lib/isomorfeus-react-native.rb +5 -0
- data/lib/isomorfeus-react-paper.rb +4 -0
- data/lib/isomorfeus-react.rb +9 -7
- data/lib/isomorfeus/props/validator.rb +2 -2
- data/lib/isomorfeus/{react_config.rb → react/config.rb} +1 -1
- data/lib/isomorfeus/react/memcached_component_cache.rb +19 -0
- data/lib/isomorfeus/react/redis_component_cache.rb +19 -0
- data/lib/isomorfeus/{thread_local_component_cache.rb → react/thread_local_component_cache.rb} +0 -0
- data/lib/isomorfeus/top_level.rb +0 -7
- data/lib/isomorfeus_react/lucid_app/mixin.rb +8 -2
- data/lib/isomorfeus_react/lucid_app/native_component_constructor.rb +18 -7
- data/lib/isomorfeus_react/lucid_app/native_lucid_component_constructor.rb +1 -2
- data/lib/isomorfeus_react/lucid_component/api.rb +0 -27
- data/lib/isomorfeus_react/lucid_component/mixin.rb +8 -2
- data/lib/isomorfeus_react/lucid_component/native_component_constructor.rb +4 -4
- data/lib/isomorfeus_react/lucid_component/native_lucid_component_constructor.rb +4 -28
- data/lib/isomorfeus_react/lucid_component/styles_api.rb +34 -0
- data/lib/isomorfeus_react/lucid_func/mixin.rb +8 -2
- data/lib/isomorfeus_react/lucid_func/native_component_constructor.rb +3 -4
- data/lib/isomorfeus_react/react/function_component/api.rb +7 -6
- data/lib/isomorfeus_react/react/function_component/mixin.rb +5 -1
- data/lib/isomorfeus_react/react/function_component/native_component_constructor.rb +3 -2
- data/lib/isomorfeus_react/react/memo_component/mixin.rb +5 -1
- data/lib/isomorfeus_react/react/memo_component/native_component_constructor.rb +2 -3
- data/lib/isomorfeus_react_material/lucid_material/app/mixin.rb +1 -0
- data/lib/isomorfeus_react_material/lucid_material/app/native_component_constructor.rb +17 -6
- data/lib/isomorfeus_react_material/lucid_material/component/mixin.rb +1 -0
- data/lib/isomorfeus_react_material/lucid_material/component/native_component_constructor.rb +3 -3
- data/lib/isomorfeus_react_material/lucid_material/func/mixin.rb +1 -0
- data/lib/isomorfeus_react_material/lucid_material/func/native_component_constructor.rb +3 -4
- data/lib/isomorfeus_react_paper/lucid_paper/app/base.rb +9 -0
- data/lib/isomorfeus_react_paper/lucid_paper/app/mixin.rb +19 -0
- data/lib/isomorfeus_react_paper/lucid_paper/app/native_component_constructor.rb +32 -0
- data/lib/isomorfeus_react_paper/lucid_paper/component/base.rb +9 -0
- data/lib/isomorfeus_react_paper/lucid_paper/component/mixin.rb +18 -0
- data/lib/isomorfeus_react_paper/lucid_paper/component/native_component_constructor.rb +25 -0
- data/lib/isomorfeus_react_paper/lucid_paper/func/base.rb +9 -0
- data/lib/isomorfeus_react_paper/lucid_paper/func/mixin.rb +14 -0
- data/lib/isomorfeus_react_paper/lucid_paper/func/native_component_constructor.rb +71 -0
- data/lib/react.rb +159 -97
- data/lib/react/component/api.rb +5 -4
- data/lib/react/component/features.rb +1 -3
- data/lib/react/component/mixin.rb +5 -1
- data/lib/react/component/native_component_constructor.rb +4 -28
- data/lib/react/component/props.rb +4 -3
- data/lib/react/component/resolution.rb +47 -63
- data/lib/react/component/state.rb +4 -2
- data/lib/react/component/styles.rb +2 -23
- data/lib/react/context_wrapper.rb +3 -5
- data/lib/react/native_constant_wrapper.rb +0 -1
- data/lib/react/version.rb +1 -1
- data/lib/react_native/component/elements.rb +203 -0
- data/lib/react_native/lucid_app/react_native_component_constructor.rb +51 -0
- data/lib/react_native/lucid_component/react_native_component_constructor.rb +37 -0
- data/lib/react_native/lucid_func/react_native_component_constructor.rb +82 -0
- data/lib/react_native/react.rb +120 -0
- metadata +69 -23
- data/lib/isomorfeus/vivify_module.rb +0 -43
@@ -1,12 +1,18 @@
|
|
1
1
|
module LucidFunc
|
2
2
|
module Mixin
|
3
3
|
def self.included(base)
|
4
|
-
base.include(::React::Component::Elements)
|
5
4
|
base.include(::React::Component::Features)
|
6
5
|
base.include(::LucidFunc::Initializer)
|
7
6
|
base.include(::React::FunctionComponent::Api)
|
8
|
-
|
7
|
+
if on_browser? || on_ssr?
|
8
|
+
base.extend(::LucidFunc::NativeComponentConstructor)
|
9
|
+
base.include(::React::Component::Elements)
|
10
|
+
elsif on_mobile?
|
11
|
+
base.extend(::LucidFunc::ReactNativeComponentConstructor)
|
12
|
+
base.include(::ReactNative::Component::Elements)
|
13
|
+
end
|
9
14
|
base.include(::LucidComponent::Api)
|
15
|
+
base.include(::LucidComponent::StylesApi)
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
@@ -24,7 +24,7 @@ module LucidFunc
|
|
24
24
|
if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
|
25
25
|
let theme = og.ReactJSS.useTheme();
|
26
26
|
if (base.jss_styles) {
|
27
|
-
if (!base.use_styles || (Opal.Isomorfeus.development
|
27
|
+
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
28
28
|
let styles;
|
29
29
|
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
30
30
|
else { styles = base.jss_styles; }
|
@@ -42,13 +42,12 @@ module LucidFunc
|
|
42
42
|
oper.active_components.push(__ruby_instance);
|
43
43
|
oper.active_redux_components.push(__ruby_instance);
|
44
44
|
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
45
|
-
if (block_result &&
|
45
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
46
46
|
oper.active_redux_components.pop();
|
47
47
|
oper.active_components.pop();
|
48
48
|
// console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
|
49
49
|
let result = oper.render_buffer.pop();
|
50
|
-
|
51
|
-
return result;
|
50
|
+
return (result.length === 1) ? result[0] : result;
|
52
51
|
}, base.equality_checker);
|
53
52
|
base.react_component.displayName = #{component_name};
|
54
53
|
}
|
@@ -18,8 +18,8 @@ module React
|
|
18
18
|
`Opal.global.React.useDebugValue(value)`
|
19
19
|
end
|
20
20
|
|
21
|
-
def use_effect(&block)
|
22
|
-
`Opal.global.React.useEffect(function() { #{block.call} })`
|
21
|
+
def use_effect(*args, &block)
|
22
|
+
`Opal.global.React.useEffect(function() { #{block.call} }, args)`
|
23
23
|
end
|
24
24
|
|
25
25
|
def use_imperative_handle(ref, *deps, &block)
|
@@ -86,12 +86,13 @@ module React
|
|
86
86
|
end
|
87
87
|
alias rre render_react_element
|
88
88
|
|
89
|
-
def method_ref(method_symbol)
|
89
|
+
def method_ref(method_symbol, *args)
|
90
|
+
method_key = "#{method_symbol}#{args}"
|
90
91
|
%x{
|
91
|
-
if (#{self}.method_refs && #{self}.method_refs[#{
|
92
|
+
if (#{self}.method_refs && #{self}.method_refs[#{method_key}]) { return #{self}.method_refs[#{method_key}]; }
|
92
93
|
if (!#{self}.method_refs) { #{self}.method_refs = {}; }
|
93
|
-
#{self}.method_refs[#{
|
94
|
-
return #{self}.method_refs[#{
|
94
|
+
#{self}.method_refs[#{method_key}] = { m: #{method(method_symbol)}, a: args };
|
95
|
+
return #{self}.method_refs[#{method_key}];
|
95
96
|
}
|
96
97
|
end
|
97
98
|
alias m_ref method_ref
|
@@ -2,7 +2,11 @@ module React
|
|
2
2
|
module FunctionComponent
|
3
3
|
module Mixin
|
4
4
|
def self.included(base)
|
5
|
-
|
5
|
+
if on_browser? || on_ssr?
|
6
|
+
base.include(::React::Component::Elements)
|
7
|
+
elsif on_mobile?
|
8
|
+
base.include(::ReactNative::Component::Elements)
|
9
|
+
end
|
6
10
|
base.include(::React::Component::Features)
|
7
11
|
base.include(::React::FunctionComponent::Initializer)
|
8
12
|
base.include(::React::FunctionComponent::Api)
|
@@ -19,10 +19,11 @@ module React
|
|
19
19
|
__ruby_instance.props = props;
|
20
20
|
oper.active_components.push(__ruby_instance);
|
21
21
|
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
22
|
-
if (block_result &&
|
22
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
23
23
|
oper.active_components.pop();
|
24
24
|
// console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
|
25
|
-
|
25
|
+
let result = oper.render_buffer.pop();
|
26
|
+
return (result.length === 1) ? result[0] : result;
|
26
27
|
}
|
27
28
|
base.react_component.displayName = #{component_name};
|
28
29
|
}
|
@@ -2,7 +2,11 @@ module React
|
|
2
2
|
module MemoComponent
|
3
3
|
module Mixin
|
4
4
|
def self.included(base)
|
5
|
-
|
5
|
+
if on_browser? || on_ssr?
|
6
|
+
base.include(::React::Component::Elements)
|
7
|
+
elsif on_mobile?
|
8
|
+
base.include(::ReactNative::Component::Elements)
|
9
|
+
end
|
6
10
|
base.include(::React::Component::Features)
|
7
11
|
base.include(::React::FunctionComponent::Initializer)
|
8
12
|
base.include(::React::FunctionComponent::Api)
|
@@ -20,12 +20,11 @@ module React
|
|
20
20
|
__ruby_instance.props = props;
|
21
21
|
oper.active_components.push(__ruby_instance);
|
22
22
|
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
23
|
-
if (block_result &&
|
23
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
24
24
|
oper.active_components.pop();
|
25
25
|
// console.log("memo popping", oper.render_buffer, oper.render_buffer.toString());
|
26
26
|
let result = oper.render_buffer.pop();
|
27
|
-
|
28
|
-
return result;
|
27
|
+
return (result.length === 1) ? result[0] : result;
|
29
28
|
}, base.equality_checker);
|
30
29
|
base.react_component.displayName = #{component_name};
|
31
30
|
}
|
@@ -10,6 +10,7 @@ module LucidMaterial
|
|
10
10
|
base.include(::React::Component::Api)
|
11
11
|
base.include(::React::Component::Callbacks)
|
12
12
|
base.include(::LucidComponent::Api)
|
13
|
+
base.include(::LucidComponent::StylesApi)
|
13
14
|
base.include(::LucidApp::Api)
|
14
15
|
base.include(::LucidComponent::Initializer)
|
15
16
|
base.include(::React::Component::Features)
|
@@ -5,7 +5,6 @@ module LucidMaterial
|
|
5
5
|
# to do so, we convert the props to ruby hashes and then compare
|
6
6
|
# this makes sure, that for example rubys Nil object gets handled properly
|
7
7
|
def self.extended(base)
|
8
|
-
component_name = base.to_s + 'Wrapper'
|
9
8
|
theme_component_name = base.to_s + 'ThemeWrapper'
|
10
9
|
# language=JS
|
11
10
|
%x{
|
@@ -15,7 +14,7 @@ module LucidMaterial
|
|
15
14
|
let classes = null;
|
16
15
|
let theme = opag.MuiStyles.useTheme();
|
17
16
|
if (base.jss_styles) {
|
18
|
-
if (!base.use_styles || (Opal.Isomorfeus.development
|
17
|
+
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
19
18
|
let styles;
|
20
19
|
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
21
20
|
else { styles = base.jss_styles; }
|
@@ -27,11 +26,23 @@ module LucidMaterial
|
|
27
26
|
return opag.React.createElement(base.lucid_react_component, themed_classes_props);
|
28
27
|
}
|
29
28
|
base.themed_react_component.displayName = #{theme_component_name};
|
30
|
-
base.react_component =
|
31
|
-
|
32
|
-
|
29
|
+
base.react_component = class extends Opal.global.React.Component {
|
30
|
+
constructor(props) {
|
31
|
+
super(props);
|
32
|
+
if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
|
33
|
+
}
|
34
|
+
static get displayName() {
|
35
|
+
return "IsomorfeusTopLevelComponent";
|
36
|
+
}
|
37
|
+
static set displayName(new_name) {
|
38
|
+
// dont do anything here except returning the set value
|
39
|
+
return new_name;
|
40
|
+
}
|
41
|
+
render() {
|
42
|
+
let themed_component = Opal.global.React.createElement(base.themed_react_component, this.props);
|
43
|
+
return Opal.global.React.createElement(Opal.global.MuiStyles.ThemeProvider, { theme: base.jss_theme }, themed_component);
|
44
|
+
}
|
33
45
|
}
|
34
|
-
base.react_component.displayName = #{component_name};
|
35
46
|
}
|
36
47
|
end
|
37
48
|
end
|
@@ -10,6 +10,7 @@ module LucidMaterial
|
|
10
10
|
base.include(::React::Component::Api)
|
11
11
|
base.include(::React::Component::Callbacks)
|
12
12
|
base.include(::LucidComponent::Api)
|
13
|
+
base.include(::LucidComponent::StylesApi)
|
13
14
|
base.include(::LucidComponent::Initializer)
|
14
15
|
base.include(::React::Component::Features)
|
15
16
|
end
|
@@ -8,13 +8,13 @@ module LucidMaterial
|
|
8
8
|
component_name = base.to_s + 'Wrapper'
|
9
9
|
# language=JS
|
10
10
|
%x{
|
11
|
-
base.react_component = function(props) {
|
11
|
+
base.react_component = Opal.global.React.memo(function(props) {
|
12
12
|
let classes = null;
|
13
13
|
let store;
|
14
14
|
if (base.store_updates) { store = Opal.global.React.useContext(Opal.global.LucidApplicationContext); }
|
15
15
|
let theme = Opal.global.MuiStyles.useTheme();
|
16
16
|
if (base.jss_styles) {
|
17
|
-
if (!base.use_styles || (Opal.Isomorfeus.development
|
17
|
+
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
18
18
|
let styles;
|
19
19
|
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
20
20
|
else { styles = base.jss_styles; }
|
@@ -27,7 +27,7 @@ module LucidMaterial
|
|
27
27
|
new_props.theme = theme;
|
28
28
|
new_props.store = store;
|
29
29
|
return Opal.global.React.createElement(base.lucid_react_component, new_props);
|
30
|
-
}
|
30
|
+
}, Opal.React.props_are_equal);
|
31
31
|
base.react_component.displayName = #{component_name};
|
32
32
|
}
|
33
33
|
end
|
@@ -25,7 +25,7 @@ module LucidMaterial
|
|
25
25
|
if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
|
26
26
|
let theme = og.MuiStyles.useTheme();
|
27
27
|
if (base.jss_styles) {
|
28
|
-
if (!base.use_styles || (Opal.Isomorfeus.development
|
28
|
+
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
29
29
|
let styles;
|
30
30
|
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
31
31
|
else { styles = base.jss_styles; }
|
@@ -43,13 +43,12 @@ module LucidMaterial
|
|
43
43
|
oper.active_components.push(__ruby_instance);
|
44
44
|
oper.active_redux_components.push(__ruby_instance);
|
45
45
|
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
46
|
-
if (block_result &&
|
46
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
47
47
|
oper.active_redux_components.pop();
|
48
48
|
oper.active_components.pop();
|
49
49
|
// console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
|
50
50
|
let result = oper.render_buffer.pop();
|
51
|
-
|
52
|
-
return result;
|
51
|
+
return (result.length === 1) ? result[0] : result;
|
53
52
|
}, base.equality_checker);
|
54
53
|
base.react_component.displayName = #{component_name};
|
55
54
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module LucidPaper
|
2
|
+
module App
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
base.include(::Native::Wrapper)
|
6
|
+
base.extend(::LucidApp::NativeLucidComponentConstructor)
|
7
|
+
base.extend(::LucidPaper::App::NativeComponentConstructor)
|
8
|
+
base.extend(::LucidPropDeclaration::Mixin)
|
9
|
+
base.include(::React::Component::Elements)
|
10
|
+
base.include(::React::Component::Api)
|
11
|
+
base.include(::React::Component::Callbacks)
|
12
|
+
base.include(::LucidComponent::Api)
|
13
|
+
base.include(::LucidApp::Api)
|
14
|
+
base.include(::LucidComponent::Initializer)
|
15
|
+
base.include(::React::Component::Features)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module LucidPaper
|
2
|
+
module App
|
3
|
+
module NativeComponentConstructor
|
4
|
+
# for should_component_update we apply ruby semantics for comparing props
|
5
|
+
# to do so, we convert the props to ruby hashes and then compare
|
6
|
+
# this makes sure, that for example rubys Nil object gets handled properly
|
7
|
+
def self.extended(base)
|
8
|
+
%x{
|
9
|
+
base.jss_theme = Opal.global.Paper.DefaultTheme;
|
10
|
+
base.themed_component = Opal.global.Paper.withTheme(base.lucid_react_component);
|
11
|
+
base.react_component = class extends Opal.global.React.Component {
|
12
|
+
constructor(props) {
|
13
|
+
super(props);
|
14
|
+
if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
|
15
|
+
}
|
16
|
+
static get displayName() {
|
17
|
+
return "IsomorfeusTopLevelComponent";
|
18
|
+
}
|
19
|
+
static set displayName(new_name) {
|
20
|
+
// dont do anything here except returning the set value
|
21
|
+
return new_name;
|
22
|
+
}
|
23
|
+
render() {
|
24
|
+
let themed_component = Opal.global.React.createElement(base.themed_component, this.props);
|
25
|
+
return Opal.global.React.createElement(Opal.global.Paper.Provider, { theme: base.jss_theme }, themed_component);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module LucidPaper
|
2
|
+
module Component
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
base.include(::Native::Wrapper)
|
6
|
+
base.extend(::LucidComponent::NativeLucidComponentConstructor)
|
7
|
+
base.extend(::LucidPaper::Component::NativeComponentConstructor)
|
8
|
+
base.extend(::LucidPropDeclaration::Mixin)
|
9
|
+
base.include(::React::Component::Elements)
|
10
|
+
base.include(::React::Component::Api)
|
11
|
+
base.include(::React::Component::Callbacks)
|
12
|
+
base.include(::LucidComponent::Api)
|
13
|
+
base.include(::LucidComponent::Initializer)
|
14
|
+
base.include(::React::Component::Features)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module LucidPaper
|
2
|
+
module Component
|
3
|
+
module NativeComponentConstructor
|
4
|
+
# for should_component_update we apply ruby semantics for comparing props
|
5
|
+
# to do so, we convert the props to ruby hashes and then compare
|
6
|
+
# this makes sure, that for example rubys Nil object gets handled properly
|
7
|
+
def self.extended(base)
|
8
|
+
component_name = base.to_s + 'Wrapper'
|
9
|
+
# language=JS
|
10
|
+
%x{
|
11
|
+
base.react_component = Opal.global.React.memo(function(props) {
|
12
|
+
let classes = null;
|
13
|
+
let store;
|
14
|
+
if (base.store_updates) { store = Opal.global.React.useContext(Opal.global.LucidApplicationContext); }
|
15
|
+
let new_props = Object.assign({}, props)
|
16
|
+
new_props.store = store;
|
17
|
+
new_props.theme = Opal.global.Paper.useTheme();
|
18
|
+
return Opal.global.React.createElement(base.lucid_react_component, new_props);
|
19
|
+
}, Opal.React.props_are_equal);
|
20
|
+
base.react_component.displayName = #{component_name};
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module LucidPaper
|
2
|
+
module Func
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
base.include(::React::Component::Elements)
|
6
|
+
base.include(::React::Component::Features)
|
7
|
+
base.include(::LucidFunc::Initializer)
|
8
|
+
base.include(::React::FunctionComponent::Api)
|
9
|
+
base.extend(::LucidPaper::Func::NativeComponentConstructor)
|
10
|
+
base.include(::LucidComponent::Api)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module LucidPaper
|
2
|
+
module Func
|
3
|
+
module NativeComponentConstructor
|
4
|
+
def self.extended(base)
|
5
|
+
component_name = "#{base.to_s}Wrapper"
|
6
|
+
%x{
|
7
|
+
base.store_updates = true;
|
8
|
+
base.equality_checker = null;
|
9
|
+
base.instance_init = function(initial) {
|
10
|
+
let ruby_state = { instance: #{base.new(`{}`)} };
|
11
|
+
ruby_state.instance.__ruby_instance = ruby_state.instance;
|
12
|
+
ruby_state.instance.data_access = function() { return this.props.store; }
|
13
|
+
ruby_state.instance.data_access.bind(ruby_state.instance);
|
14
|
+
return ruby_state;
|
15
|
+
}
|
16
|
+
base.instance_reducer = function(state, action) { return state; }
|
17
|
+
base.react_component = Opal.global.React.memo(function(props) {
|
18
|
+
const og = Opal.global;
|
19
|
+
const oper = Opal.React;
|
20
|
+
oper.render_buffer.push([]);
|
21
|
+
// console.log("function pushed", oper.render_buffer, oper.render_buffer.toString());
|
22
|
+
// Lucid functionality
|
23
|
+
let store;
|
24
|
+
if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
|
25
|
+
// prepare Ruby instance
|
26
|
+
const [__ruby_state, __ruby_dispatch] = og.React.useReducer(base.instance_reducer, null, base.instance_init);
|
27
|
+
const __ruby_instance = __ruby_state.instance;
|
28
|
+
__ruby_instance.props = Object.assign({}, props);
|
29
|
+
__ruby_instance.props.store = store;
|
30
|
+
__ruby_instance.props.theme = Opal.global.Paper.useTheme();
|
31
|
+
oper.active_components.push(__ruby_instance);
|
32
|
+
oper.active_redux_components.push(__ruby_instance);
|
33
|
+
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
34
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
35
|
+
oper.active_redux_components.pop();
|
36
|
+
oper.active_components.pop();
|
37
|
+
// console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
|
38
|
+
let result = oper.render_buffer.pop();
|
39
|
+
return (result.length === 1) ? result[0] : result;
|
40
|
+
}, base.equality_checker);
|
41
|
+
base.react_component.displayName = #{component_name};
|
42
|
+
}
|
43
|
+
|
44
|
+
base_module = base.to_s.deconstantize
|
45
|
+
if base_module != ''
|
46
|
+
base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
|
47
|
+
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
48
|
+
end
|
49
|
+
else
|
50
|
+
Object.define_method(base.to_s) do |*args, &block|
|
51
|
+
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def props_are_equal?(&block)
|
56
|
+
%x{
|
57
|
+
base.equality_checker = function (prev_props, next_props) {
|
58
|
+
var prev_ruby_props = Opal.React.Component.Props.$new({props: prev_props});
|
59
|
+
var next_ruby_props = Opal.React.Component.Props.$new({props: next_props});
|
60
|
+
return #{block.call(`prev_ruby_props`, `next_ruby_props`)};
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def render(&block)
|
66
|
+
`base.render_block = #{block}`
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|