isomorfeus-react 16.13.11 → 16.13.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/lib/isomorfeus/react/config.rb +189 -189
  4. data/lib/isomorfeus/react/memcached_component_cache.rb +19 -19
  5. data/lib/isomorfeus/react/redis_component_cache.rb +19 -19
  6. data/lib/isomorfeus/react/thread_local_component_cache.rb +15 -15
  7. data/lib/isomorfeus/react_view_helper.rb +231 -231
  8. data/lib/isomorfeus/top_level.rb +103 -103
  9. data/lib/isomorfeus/top_level_ssr.rb +42 -42
  10. data/lib/isomorfeus-react-material-ui.rb +4 -4
  11. data/lib/isomorfeus-react-native.rb +5 -5
  12. data/lib/isomorfeus-react-paper.rb +4 -4
  13. data/lib/isomorfeus-react.rb +120 -120
  14. data/lib/isomorfeus_react/lucid_app/api.rb +26 -26
  15. data/lib/isomorfeus_react/lucid_app/base.rb +7 -7
  16. data/lib/isomorfeus_react/lucid_app/mixin.rb +23 -23
  17. data/lib/isomorfeus_react/lucid_app/native_component_constructor.rb +48 -48
  18. data/lib/isomorfeus_react/lucid_app/native_lucid_component_constructor.rb +94 -95
  19. data/lib/isomorfeus_react/lucid_component/api.rb +75 -75
  20. data/lib/isomorfeus_react/lucid_component/app_store_proxy.rb +37 -37
  21. data/lib/isomorfeus_react/lucid_component/base.rb +7 -7
  22. data/lib/isomorfeus_react/lucid_component/class_store_proxy.rb +44 -44
  23. data/lib/isomorfeus_react/lucid_component/initializer.rb +14 -14
  24. data/lib/isomorfeus_react/lucid_component/instance_store_proxy.rb +44 -44
  25. data/lib/isomorfeus_react/lucid_component/mixin.rb +22 -22
  26. data/lib/isomorfeus_react/lucid_component/native_component_constructor.rb +35 -35
  27. data/lib/isomorfeus_react/lucid_component/native_lucid_component_constructor.rb +82 -83
  28. data/lib/isomorfeus_react/lucid_component/styles_api.rb +34 -34
  29. data/lib/isomorfeus_react/lucid_func/base.rb +7 -7
  30. data/lib/isomorfeus_react/lucid_func/initializer.rb +11 -11
  31. data/lib/isomorfeus_react/lucid_func/mixin.rb +18 -18
  32. data/lib/isomorfeus_react/lucid_func/native_component_constructor.rb +81 -81
  33. data/lib/isomorfeus_react/react/function_component/api.rb +105 -105
  34. data/lib/isomorfeus_react/react/function_component/base.rb +8 -8
  35. data/lib/isomorfeus_react/react/function_component/initializer.rb +10 -10
  36. data/lib/isomorfeus_react/react/function_component/mixin.rb +17 -17
  37. data/lib/isomorfeus_react/react/function_component/native_component_constructor.rb +48 -48
  38. data/lib/isomorfeus_react/react/memo_component/base.rb +8 -8
  39. data/lib/isomorfeus_react/react/memo_component/mixin.rb +17 -17
  40. data/lib/isomorfeus_react/react/memo_component/native_component_constructor.rb +49 -49
  41. data/lib/isomorfeus_react_material/lucid_material/app/base.rb +8 -8
  42. data/lib/isomorfeus_react_material/lucid_material/app/mixin.rb +20 -20
  43. data/lib/isomorfeus_react_material/lucid_material/app/native_component_constructor.rb +50 -50
  44. data/lib/isomorfeus_react_material/lucid_material/component/base.rb +9 -9
  45. data/lib/isomorfeus_react_material/lucid_material/component/mixin.rb +19 -19
  46. data/lib/isomorfeus_react_material/lucid_material/component/native_component_constructor.rb +36 -36
  47. data/lib/isomorfeus_react_material/lucid_material/func/base.rb +9 -9
  48. data/lib/isomorfeus_react_material/lucid_material/func/mixin.rb +15 -15
  49. data/lib/isomorfeus_react_material/lucid_material/func/native_component_constructor.rb +83 -83
  50. data/lib/isomorfeus_react_paper/lucid_paper/app/base.rb +9 -9
  51. data/lib/isomorfeus_react_paper/lucid_paper/app/mixin.rb +19 -19
  52. data/lib/isomorfeus_react_paper/lucid_paper/app/native_component_constructor.rb +32 -32
  53. data/lib/isomorfeus_react_paper/lucid_paper/component/base.rb +9 -9
  54. data/lib/isomorfeus_react_paper/lucid_paper/component/mixin.rb +18 -18
  55. data/lib/isomorfeus_react_paper/lucid_paper/component/native_component_constructor.rb +25 -25
  56. data/lib/isomorfeus_react_paper/lucid_paper/func/base.rb +9 -9
  57. data/lib/isomorfeus_react_paper/lucid_paper/func/mixin.rb +14 -14
  58. data/lib/isomorfeus_react_paper/lucid_paper/func/native_component_constructor.rb +71 -71
  59. data/lib/lucid_app/context.rb +7 -7
  60. data/lib/lucid_prop_declaration/mixin.rb +126 -126
  61. data/lib/react/children.rb +34 -34
  62. data/lib/react/component/api.rb +134 -134
  63. data/lib/react/component/base.rb +8 -8
  64. data/lib/react/component/callbacks.rb +115 -115
  65. data/lib/react/component/elements.rb +60 -60
  66. data/lib/react/component/features.rb +48 -48
  67. data/lib/react/component/history.rb +69 -65
  68. data/lib/react/component/initializer.rb +11 -11
  69. data/lib/react/component/location.rb +19 -15
  70. data/lib/react/component/match.rb +35 -31
  71. data/lib/react/component/mixin.rb +20 -20
  72. data/lib/react/component/native_component_constructor.rb +69 -70
  73. data/lib/react/component/props.rb +83 -83
  74. data/lib/react/component/resolution.rb +97 -97
  75. data/lib/react/component/state.rb +58 -54
  76. data/lib/react/component/styles.rb +66 -66
  77. data/lib/react/context_wrapper.rb +48 -44
  78. data/lib/react/native_constant_wrapper.rb +29 -29
  79. data/lib/react/ref.rb +16 -12
  80. data/lib/react/synthetic_event.rb +52 -52
  81. data/lib/react/version.rb +3 -3
  82. data/lib/react.rb +296 -296
  83. data/lib/react_dom.rb +41 -41
  84. data/lib/react_dom_server.rb +18 -18
  85. data/lib/react_native/component/elements.rb +203 -203
  86. data/lib/react_native/lucid_app/react_native_component_constructor.rb +51 -51
  87. data/lib/react_native/lucid_component/react_native_component_constructor.rb +37 -37
  88. data/lib/react_native/lucid_func/react_native_component_constructor.rb +82 -82
  89. data/lib/react_native/react.rb +120 -120
  90. metadata +23 -17
@@ -1,49 +1,49 @@
1
- module React
2
- module MemoComponent
3
- module NativeComponentConstructor
4
- def self.extended(base)
5
- component_name = base.to_s
6
- %x{
7
- base.instance_init = function(initial) {
8
- let ruby_state = { instance: #{base.new(`{}`)} };
9
- ruby_state.instance.__ruby_instance = ruby_state.instance;
10
- return ruby_state;
11
- }
12
- base.instance_reducer = function(state, action) { return state; }
13
- base.equality_checker = null;
14
- base.react_component = Opal.global.React.memo(function(props) {
15
- const oper = Opal.React;
16
- oper.render_buffer.push([]);
17
- // console.log("memo pushed", oper.render_buffer, oper.render_buffer.toString());
18
- const [__ruby_state, __ruby_dispatch] = Opal.global.React.useReducer(base.instance_reducer, null, base.instance_init);
19
- const __ruby_instance = __ruby_state.instance;
20
- __ruby_instance.props = props;
21
- oper.active_components.push(__ruby_instance);
22
- let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
23
- if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
24
- oper.active_components.pop();
25
- // console.log("memo popping", oper.render_buffer, oper.render_buffer.toString());
26
- let result = oper.render_buffer.pop();
27
- return (result.length === 1) ? result[0] : result;
28
- }, base.equality_checker);
29
- base.react_component.displayName = #{component_name};
30
- }
31
-
32
- base_module = base.to_s.deconstantize
33
- if base_module != ''
34
- base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
35
- `Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
36
- end
37
- else
38
- Object.define_method(base.to_s) do |*args, &block|
39
- `Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
40
- end
41
- end
42
-
43
- def render(&block)
44
- `base.render_block = #{block}`
45
- end
46
- end
47
- end
48
- end
49
- end
1
+ module React
2
+ module MemoComponent
3
+ module NativeComponentConstructor
4
+ def self.extended(base)
5
+ component_name = base.to_s
6
+ %x{
7
+ base.instance_init = function(initial) {
8
+ let ruby_state = { instance: #{base.new(`{}`)} };
9
+ ruby_state.instance.__ruby_instance = ruby_state.instance;
10
+ return ruby_state;
11
+ }
12
+ base.instance_reducer = function(state, action) { return state; }
13
+ base.equality_checker = null;
14
+ base.react_component = Opal.global.React.memo(function(props) {
15
+ const oper = Opal.React;
16
+ oper.render_buffer.push([]);
17
+ // console.log("memo pushed", oper.render_buffer, oper.render_buffer.toString());
18
+ const [__ruby_state, __ruby_dispatch] = Opal.global.React.useReducer(base.instance_reducer, null, base.instance_init);
19
+ const __ruby_instance = __ruby_state.instance;
20
+ __ruby_instance.props = props;
21
+ oper.active_components.push(__ruby_instance);
22
+ let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
23
+ if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
24
+ oper.active_components.pop();
25
+ // console.log("memo popping", oper.render_buffer, oper.render_buffer.toString());
26
+ let result = oper.render_buffer.pop();
27
+ return (result.length === 1) ? result[0] : result;
28
+ }, base.equality_checker);
29
+ base.react_component.displayName = #{component_name};
30
+ }
31
+
32
+ base_module = base.to_s.deconstantize
33
+ if base_module != ''
34
+ base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
35
+ `Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
36
+ end
37
+ else
38
+ Object.define_method(base.to_s) do |*args, &block|
39
+ `Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
40
+ end
41
+ end
42
+
43
+ def render(&block)
44
+ `base.render_block = #{block}`
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,9 +1,9 @@
1
- module LucidMaterial
2
- module App
3
- class Base
4
- def self.inherited(base)
5
- base.include(::LucidMaterial::App::Mixin)
6
- end
7
- end
8
- end
1
+ module LucidMaterial
2
+ module App
3
+ class Base
4
+ def self.inherited(base)
5
+ base.include(::LucidMaterial::App::Mixin)
6
+ end
7
+ end
8
+ end
9
9
  end
@@ -1,20 +1,20 @@
1
- module LucidMaterial
2
- module App
3
- module Mixin
4
- def self.included(base)
5
- base.include(::Native::Wrapper)
6
- base.extend(::LucidApp::NativeLucidComponentConstructor)
7
- base.extend(::LucidMaterial::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(::LucidComponent::StylesApi)
14
- base.include(::LucidApp::Api)
15
- base.include(::LucidComponent::Initializer)
16
- base.include(::React::Component::Features)
17
- end
18
- end
19
- end
20
- end
1
+ module LucidMaterial
2
+ module App
3
+ module Mixin
4
+ def self.included(base)
5
+ base.include(::Native::Wrapper)
6
+ base.extend(::LucidApp::NativeLucidComponentConstructor)
7
+ base.extend(::LucidMaterial::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(::LucidComponent::StylesApi)
14
+ base.include(::LucidApp::Api)
15
+ base.include(::LucidComponent::Initializer)
16
+ base.include(::React::Component::Features)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,50 +1,50 @@
1
- module LucidMaterial
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
- theme_component_name = base.to_s + 'ThemeWrapper'
9
- # language=JS
10
- %x{
11
- base.jss_theme = Opal.global.Mui.createMuiTheme();
12
- base.themed_react_component = function(props) {
13
- let opag = Opal.global;
14
- let classes = null;
15
- let theme = opag.MuiStyles.useTheme();
16
- if (base.jss_styles) {
17
- if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
18
- let styles;
19
- if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
20
- else { styles = base.jss_styles; }
21
- base.use_styles = opag.MuiStyles.makeStyles(styles);
22
- }
23
- classes = base.use_styles();
24
- }
25
- let themed_classes_props = Object.assign({}, props, { classes: classes, theme: theme });
26
- return opag.React.createElement(base.lucid_react_component, themed_classes_props);
27
- }
28
- base.themed_react_component.displayName = #{theme_component_name};
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
- }
45
- }
46
- }
47
- end
48
- end
49
- end
50
- end
1
+ module LucidMaterial
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
+ theme_component_name = base.to_s + 'ThemeWrapper'
9
+ # language=JS
10
+ %x{
11
+ base.jss_theme = Opal.global.Mui.createTheme();
12
+ base.themed_react_component = function(props) {
13
+ let opag = Opal.global;
14
+ let classes = null;
15
+ let theme = opag.MuiStyles.useTheme();
16
+ if (base.jss_styles) {
17
+ if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
18
+ let styles;
19
+ if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
20
+ else { styles = base.jss_styles; }
21
+ base.use_styles = opag.MuiStyles.makeStyles(styles);
22
+ }
23
+ classes = base.use_styles();
24
+ }
25
+ let themed_classes_props = Object.assign({}, props, { classes: classes, theme: theme });
26
+ return opag.React.createElement(base.lucid_react_component, themed_classes_props);
27
+ }
28
+ base.themed_react_component.displayName = #{theme_component_name};
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
+ }
45
+ }
46
+ }
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,9 +1,9 @@
1
- module LucidMaterial
2
- module Component
3
- class Base
4
- def self.inherited(base)
5
- base.include(::LucidMaterial::Component::Mixin)
6
- end
7
- end
8
- end
9
- end
1
+ module LucidMaterial
2
+ module Component
3
+ class Base
4
+ def self.inherited(base)
5
+ base.include(::LucidMaterial::Component::Mixin)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,19 +1,19 @@
1
- module LucidMaterial
2
- module Component
3
- module Mixin
4
- def self.included(base)
5
- base.include(::Native::Wrapper)
6
- base.extend(::LucidComponent::NativeLucidComponentConstructor)
7
- base.extend(::LucidMaterial::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::StylesApi)
14
- base.include(::LucidComponent::Initializer)
15
- base.include(::React::Component::Features)
16
- end
17
- end
18
- end
19
- end
1
+ module LucidMaterial
2
+ module Component
3
+ module Mixin
4
+ def self.included(base)
5
+ base.include(::Native::Wrapper)
6
+ base.extend(::LucidComponent::NativeLucidComponentConstructor)
7
+ base.extend(::LucidMaterial::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::StylesApi)
14
+ base.include(::LucidComponent::Initializer)
15
+ base.include(::React::Component::Features)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,36 +1,36 @@
1
- module LucidMaterial
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 theme = Opal.global.MuiStyles.useTheme();
16
- if (base.jss_styles) {
17
- if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
18
- let styles;
19
- if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
20
- else { styles = base.jss_styles; }
21
- base.use_styles = Opal.global.MuiStyles.makeStyles(styles);
22
- }
23
- classes = base.use_styles();
24
- }
25
- let new_props = Object.assign({}, props)
26
- new_props.classes = classes;
27
- new_props.theme = theme;
28
- new_props.store = store;
29
- return Opal.global.React.createElement(base.lucid_react_component, new_props);
30
- }, Opal.React.props_are_equal);
31
- base.react_component.displayName = #{component_name};
32
- }
33
- end
34
- end
35
- end
36
- end
1
+ module LucidMaterial
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 theme = Opal.global.MuiStyles.useTheme();
16
+ if (base.jss_styles) {
17
+ if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
18
+ let styles;
19
+ if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
20
+ else { styles = base.jss_styles; }
21
+ base.use_styles = Opal.global.MuiStyles.makeStyles(styles);
22
+ }
23
+ classes = base.use_styles();
24
+ }
25
+ let new_props = Object.assign({}, props)
26
+ new_props.classes = classes;
27
+ new_props.theme = theme;
28
+ new_props.store = store;
29
+ return Opal.global.React.createElement(base.lucid_react_component, new_props);
30
+ }, Opal.React.props_are_equal);
31
+ base.react_component.displayName = #{component_name};
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,9 +1,9 @@
1
- module LucidMaterial
2
- module Func
3
- class Base
4
- def self.inherited(base)
5
- base.include(::LucidMaterial::Func::Mixin)
6
- end
7
- end
8
- end
9
- end
1
+ module LucidMaterial
2
+ module Func
3
+ class Base
4
+ def self.inherited(base)
5
+ base.include(::LucidMaterial::Func::Mixin)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,15 +1,15 @@
1
- module LucidMaterial
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(::LucidMaterial::Func::NativeComponentConstructor)
10
- base.include(::LucidComponent::Api)
11
- base.include(::LucidComponent::StylesApi)
12
- end
13
- end
14
- end
15
- end
1
+ module LucidMaterial
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(::LucidMaterial::Func::NativeComponentConstructor)
10
+ base.include(::LucidComponent::Api)
11
+ base.include(::LucidComponent::StylesApi)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,83 +1,83 @@
1
- module LucidMaterial
2
- module Func
3
- module NativeComponentConstructor
4
- def self.extended(base)
5
- component_name = base.to_s
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 classes = null;
24
- let store;
25
- if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
26
- let theme = og.MuiStyles.useTheme();
27
- if (base.jss_styles) {
28
- if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
29
- let styles;
30
- if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
31
- else { styles = base.jss_styles; }
32
- base.use_styles = og.MuiStyles.makeStyles(styles);
33
- }
34
- classes = base.use_styles();
35
- }
36
- // prepare Ruby instance
37
- const [__ruby_state, __ruby_dispatch] = og.React.useReducer(base.instance_reducer, null, base.instance_init);
38
- const __ruby_instance = __ruby_state.instance;
39
- __ruby_instance.props = Object.assign({}, props);
40
- __ruby_instance.props.store = store;
41
- __ruby_instance.props.theme = theme;
42
- __ruby_instance.props.classes = classes;
43
- oper.active_components.push(__ruby_instance);
44
- oper.active_redux_components.push(__ruby_instance);
45
- let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
46
- if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
47
- oper.active_redux_components.pop();
48
- oper.active_components.pop();
49
- // console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
50
- let result = oper.render_buffer.pop();
51
- return (result.length === 1) ? result[0] : result;
52
- }, base.equality_checker);
53
- base.react_component.displayName = #{component_name};
54
- }
55
-
56
- base_module = base.to_s.deconstantize
57
- if base_module != ''
58
- base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
59
- `Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
60
- end
61
- else
62
- Object.define_method(base.to_s) do |*args, &block|
63
- `Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
64
- end
65
- end
66
-
67
- def props_are_equal?(&block)
68
- %x{
69
- base.equality_checker = function (prev_props, next_props) {
70
- var prev_ruby_props = Opal.React.Component.Props.$new({props: prev_props});
71
- var next_ruby_props = Opal.React.Component.Props.$new({props: next_props});
72
- return #{block.call(`prev_ruby_props`, `next_ruby_props`)};
73
- }
74
- }
75
- end
76
-
77
- def render(&block)
78
- `base.render_block = #{block}`
79
- end
80
- end
81
- end
82
- end
83
- end
1
+ module LucidMaterial
2
+ module Func
3
+ module NativeComponentConstructor
4
+ def self.extended(base)
5
+ component_name = base.to_s
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 classes = null;
24
+ let store;
25
+ if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
26
+ let theme = og.MuiStyles.useTheme();
27
+ if (base.jss_styles) {
28
+ if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
29
+ let styles;
30
+ if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
31
+ else { styles = base.jss_styles; }
32
+ base.use_styles = og.MuiStyles.makeStyles(styles);
33
+ }
34
+ classes = base.use_styles();
35
+ }
36
+ // prepare Ruby instance
37
+ const [__ruby_state, __ruby_dispatch] = og.React.useReducer(base.instance_reducer, null, base.instance_init);
38
+ const __ruby_instance = __ruby_state.instance;
39
+ __ruby_instance.props = Object.assign({}, props);
40
+ __ruby_instance.props.store = store;
41
+ __ruby_instance.props.theme = theme;
42
+ __ruby_instance.props.classes = classes;
43
+ oper.active_components.push(__ruby_instance);
44
+ oper.active_redux_components.push(__ruby_instance);
45
+ let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
46
+ if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
47
+ oper.active_redux_components.pop();
48
+ oper.active_components.pop();
49
+ // console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
50
+ let result = oper.render_buffer.pop();
51
+ return (result.length === 1) ? result[0] : result;
52
+ }, base.equality_checker);
53
+ base.react_component.displayName = #{component_name};
54
+ }
55
+
56
+ base_module = base.to_s.deconstantize
57
+ if base_module != ''
58
+ base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
59
+ `Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
60
+ end
61
+ else
62
+ Object.define_method(base.to_s) do |*args, &block|
63
+ `Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
64
+ end
65
+ end
66
+
67
+ def props_are_equal?(&block)
68
+ %x{
69
+ base.equality_checker = function (prev_props, next_props) {
70
+ var prev_ruby_props = Opal.React.Component.Props.$new({props: prev_props});
71
+ var next_ruby_props = Opal.React.Component.Props.$new({props: next_props});
72
+ return #{block.call(`prev_ruby_props`, `next_ruby_props`)};
73
+ }
74
+ }
75
+ end
76
+
77
+ def render(&block)
78
+ `base.render_block = #{block}`
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -1,9 +1,9 @@
1
- module LucidPaper
2
- module App
3
- class Base
4
- def self.inherited(base)
5
- base.include(::LucidPaper::App::Mixin)
6
- end
7
- end
8
- end
9
- end
1
+ module LucidPaper
2
+ module App
3
+ class Base
4
+ def self.inherited(base)
5
+ base.include(::LucidPaper::App::Mixin)
6
+ end
7
+ end
8
+ end
9
+ end