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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02a760c7e31fcd4fc03396b90831133ff8bfc02bf7602bd337ebe554b3778150
|
4
|
+
data.tar.gz: a87209a7b20d8b88b5d9ea4f2a1306edcec75a090ecc38578ee697ad2e3139bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4fa758232d69952fffa9f6c0e586cb96ae537232d788018cc13c6e64f636945566fae50d9cfc4befb83a69d7d3adfd74c8ced3b452b256ad8f64d5e24285538
|
7
|
+
data.tar.gz: 836d76d4dd5522925cbae401283757d59969c512e71e7992602c98e4ed69918047addf7ebc6e661c5ac6153bcfae3747fc03b1533140f29244ea243bdfe61c55
|
data/README.md
CHANGED
@@ -3,21 +3,13 @@
|
|
3
3
|
Develop React components for Opal Ruby along with very easy to use and advanced React-Redux Components.
|
4
4
|
|
5
5
|
## Community and Support
|
6
|
-
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
6
|
+
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
7
7
|
|
8
8
|
## Versioning and Compatibility
|
9
9
|
isomorfeus-react version follows the React version which features and API it implements.
|
10
10
|
|
11
11
|
### React
|
12
|
-
Isomorfeus-react 16.
|
13
|
-
|
14
|
-
### Preact
|
15
|
-
isomorfeus-react works with preact version 10.1.x.
|
16
|
-
|
17
|
-
### Nerv
|
18
|
-
isomorfeus-react works in general with nervjs 1.5.x. with some issues:
|
19
|
-
- Server Side Rendering does currently not work at all.
|
20
|
-
- Some specs with respect to callbacks (component_will_unmount) and styles fail.
|
12
|
+
Isomorfeus-react 16.13.x implements features and the API of React 16.13 and should be used with React 16.13
|
21
13
|
|
22
14
|
## Documentation
|
23
15
|
|
@@ -0,0 +1,5 @@
|
|
1
|
+
require 'react_native/react'
|
2
|
+
require 'react_native/component/elements'
|
3
|
+
require 'react_native/lucid_app/react_native_component_constructor'
|
4
|
+
require 'react_native/lucid_component/react_native_component_constructor'
|
5
|
+
require 'react_native/lucid_func/react_native_component_constructor'
|
data/lib/isomorfeus-react.rb
CHANGED
@@ -3,17 +3,17 @@ if RUBY_ENGINE == 'opal'
|
|
3
3
|
require 'active_support/core_ext/string'
|
4
4
|
require 'zeitwerk'
|
5
5
|
|
6
|
-
if
|
6
|
+
if on_browser?
|
7
7
|
require 'browser/event'
|
8
8
|
require 'browser/event_target'
|
9
9
|
require 'browser/delegate_native'
|
10
10
|
require 'browser/element'
|
11
11
|
end
|
12
12
|
|
13
|
-
require 'isomorfeus/
|
13
|
+
require 'isomorfeus/react/config'
|
14
14
|
|
15
15
|
# allow mounting of components
|
16
|
-
if
|
16
|
+
if on_browser?
|
17
17
|
require 'isomorfeus/top_level'
|
18
18
|
else
|
19
19
|
require 'isomorfeus/top_level_ssr'
|
@@ -25,7 +25,7 @@ if RUBY_ENGINE == 'opal'
|
|
25
25
|
require 'react/synthetic_event'
|
26
26
|
require 'react/ref'
|
27
27
|
require 'react/children'
|
28
|
-
if
|
28
|
+
if on_browser?
|
29
29
|
require 'react_dom'
|
30
30
|
else
|
31
31
|
require 'react_dom_server'
|
@@ -83,7 +83,7 @@ else
|
|
83
83
|
require 'isomorfeus-redux'
|
84
84
|
require 'isomorfeus-speednode'
|
85
85
|
require 'react/version'
|
86
|
-
require 'isomorfeus/
|
86
|
+
require 'isomorfeus/react/config'
|
87
87
|
|
88
88
|
# props
|
89
89
|
require 'isomorfeus/props/validate_hash_proxy'
|
@@ -99,8 +99,10 @@ else
|
|
99
99
|
|
100
100
|
Isomorfeus.server_side_rendering = true
|
101
101
|
|
102
|
-
#
|
103
|
-
require 'isomorfeus/thread_local_component_cache'
|
102
|
+
# caches
|
103
|
+
require 'isomorfeus/react/thread_local_component_cache'
|
104
|
+
require 'isomorfeus/react/memcached_component_cache'
|
105
|
+
require 'isomorfeus/react/redis_component_cache'
|
104
106
|
require 'isomorfeus/react_view_helper'
|
105
107
|
|
106
108
|
Isomorfeus.component_cache_init do
|
@@ -139,7 +139,7 @@ module Isomorfeus
|
|
139
139
|
Isomorfeus.raise_error(message: "#{@c}: #{@p} must be a String") unless @v.class == String
|
140
140
|
case @o[:type]
|
141
141
|
when :email
|
142
|
-
Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid email address") unless @v.match?
|
142
|
+
Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid email address") unless @v.match?(/\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/)
|
143
143
|
when :uri
|
144
144
|
if RUBY_ENGINE == 'opal'
|
145
145
|
%x{
|
@@ -150,7 +150,7 @@ module Isomorfeus
|
|
150
150
|
}
|
151
151
|
}
|
152
152
|
else
|
153
|
-
Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid uri") unless @v.match?
|
153
|
+
Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid uri") unless @v.match?(/\A#{URI.regexp}\z/)
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
@@ -88,7 +88,7 @@ module Isomorfeus
|
|
88
88
|
def force_render
|
89
89
|
begin
|
90
90
|
if Isomorfeus.top_component
|
91
|
-
ReactDOM.find_dom_node(Isomorfeus.top_component) # if not mounted will raise
|
91
|
+
ReactDOM.find_dom_node(Isomorfeus.top_component) if on_browser? || on_desktop? # if not mounted will raise
|
92
92
|
if `typeof Opal.global.deepForceUpdate === 'undefined'`
|
93
93
|
Isomorfeus.top_component.JS.forceUpdate()
|
94
94
|
else
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Professional
|
3
|
+
class MemcachedComponentCache
|
4
|
+
def initialize(*args)
|
5
|
+
@dalli_client = Dalli::Client.new(*args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def fetch(key)
|
9
|
+
json = @dalli_client.get(key)
|
10
|
+
Oj.load(json, mode: :strict)
|
11
|
+
end
|
12
|
+
|
13
|
+
def store(key, rendered_tree, response_status, styles)
|
14
|
+
json = Oj.dump([rendered_tree, response_status, styles], mode: :strict)
|
15
|
+
@dalli_client.set(key, json)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Professional
|
3
|
+
class RedisComponentCache
|
4
|
+
def initialize(*args)
|
5
|
+
@redis_client = Redis.new(@args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def fetch(key)
|
9
|
+
json = @redis_client.get(key)
|
10
|
+
Oj.load(json, mode: :strict)
|
11
|
+
end
|
12
|
+
|
13
|
+
def store(key, rendered_tree, response_status, styles)
|
14
|
+
json = Oj.dump([rendered_tree, response_status, styles], mode: :strict)
|
15
|
+
@redis_client.set(key, json)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/isomorfeus/{thread_local_component_cache.rb → react/thread_local_component_cache.rb}
RENAMED
File without changes
|
data/lib/isomorfeus/top_level.rb
CHANGED
@@ -72,13 +72,6 @@ module Isomorfeus
|
|
72
72
|
}
|
73
73
|
ready_fun(run);
|
74
74
|
}
|
75
|
-
# %x{
|
76
|
-
# function run() { block.$call() };
|
77
|
-
# function ready_fun() {
|
78
|
-
# /in/.test(document.readyState) ? setTimeout(ready_fun,5) : run();
|
79
|
-
# }
|
80
|
-
# ready_fun();
|
81
|
-
# }
|
82
75
|
end
|
83
76
|
|
84
77
|
def on_ready_mount(component, props = nil, element_query = nil)
|
@@ -3,12 +3,18 @@ module LucidApp
|
|
3
3
|
def self.included(base)
|
4
4
|
base.include(::Native::Wrapper)
|
5
5
|
base.extend(::LucidApp::NativeLucidComponentConstructor)
|
6
|
-
|
6
|
+
if on_browser? || on_ssr?
|
7
|
+
base.extend(::LucidApp::NativeComponentConstructor)
|
8
|
+
base.include(::React::Component::Elements)
|
9
|
+
elsif on_mobile?
|
10
|
+
base.extend(::LucidApp::ReactNativeComponentConstructor)
|
11
|
+
base.include(::ReactNative::Component::Elements)
|
12
|
+
end
|
7
13
|
base.extend(::LucidPropDeclaration::Mixin)
|
8
|
-
base.include(::React::Component::Elements)
|
9
14
|
base.include(::React::Component::Api)
|
10
15
|
base.include(::React::Component::Callbacks)
|
11
16
|
base.include(::LucidComponent::Api)
|
17
|
+
base.include(::LucidComponent::StylesApi)
|
12
18
|
base.include(::LucidApp::Api)
|
13
19
|
base.include(::LucidComponent::Initializer)
|
14
20
|
base.include(::React::Component::Features)
|
@@ -4,7 +4,6 @@ module LucidApp
|
|
4
4
|
# to do so, we convert the props to ruby hashes and then compare
|
5
5
|
# this makes sure, that for example rubys Nil object gets handled properly
|
6
6
|
def self.extended(base)
|
7
|
-
component_name = base.to_s + 'Wrapper'
|
8
7
|
theme_component_name = base.to_s + 'ThemeWrapper'
|
9
8
|
# language=JS
|
10
9
|
%x{
|
@@ -14,7 +13,7 @@ module LucidApp
|
|
14
13
|
let classes = null;
|
15
14
|
let theme = opag.ReactJSS.useTheme();
|
16
15
|
if (base.jss_styles) {
|
17
|
-
if (!base.use_styles || (Opal.Isomorfeus.development
|
16
|
+
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
18
17
|
let styles;
|
19
18
|
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
20
19
|
else { styles = base.jss_styles; }
|
@@ -24,13 +23,25 @@ module LucidApp
|
|
24
23
|
}
|
25
24
|
let themed_classes_props = Object.assign({}, props, { classes: classes, theme: theme });
|
26
25
|
return opag.React.createElement(base.lucid_react_component, themed_classes_props);
|
27
|
-
}
|
26
|
+
};
|
28
27
|
base.themed_react_component.displayName = #{theme_component_name};
|
29
|
-
base.react_component =
|
30
|
-
|
31
|
-
|
28
|
+
base.react_component = class extends Opal.global.React.Component {
|
29
|
+
constructor(props) {
|
30
|
+
super(props);
|
31
|
+
if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
|
32
|
+
}
|
33
|
+
static get displayName() {
|
34
|
+
return "IsomorfeusTopLevelComponent";
|
35
|
+
}
|
36
|
+
static set displayName(new_name) {
|
37
|
+
// dont do anything here except returning the set value
|
38
|
+
return new_name;
|
39
|
+
}
|
40
|
+
render() {
|
41
|
+
let themed_component = Opal.global.React.createElement(base.themed_react_component, this.props);
|
42
|
+
return Opal.global.React.createElement(Opal.global.ReactJSS.ThemeProvider, { theme: base.jss_theme }, themed_component);
|
43
|
+
}
|
32
44
|
}
|
33
|
-
base.react_component.displayName = #{component_name};
|
34
45
|
}
|
35
46
|
end
|
36
47
|
end
|
@@ -26,7 +26,6 @@ module LucidApp
|
|
26
26
|
this.state.class_state[#{component_name}] = {};
|
27
27
|
};
|
28
28
|
this.__ruby_instance = base.$new(this);
|
29
|
-
if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
|
30
29
|
var defined_refs = #{base.defined_refs};
|
31
30
|
for (var ref in defined_refs) {
|
32
31
|
if (defined_refs[ref] != null) {
|
@@ -63,7 +62,7 @@ module LucidApp
|
|
63
62
|
let block_result;
|
64
63
|
if (base.while_loading_block && !this.state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
|
65
64
|
else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
|
66
|
-
if (block_result &&
|
65
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
67
66
|
oper.active_redux_components.pop();
|
68
67
|
oper.active_components.pop();
|
69
68
|
let children = oper.render_buffer.pop();
|
@@ -18,28 +18,6 @@ module LucidComponent
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
# styles
|
22
|
-
def styles(styles_hash = nil, &block)
|
23
|
-
if block_given?
|
24
|
-
%x{
|
25
|
-
base.jss_styles = function(theme) {
|
26
|
-
let wrapped_theme = Opal.React.Component.Styles.$new(theme);
|
27
|
-
var result = block.$call(wrapped_theme);
|
28
|
-
return result.$to_n();
|
29
|
-
}
|
30
|
-
}
|
31
|
-
nil
|
32
|
-
elsif styles_hash
|
33
|
-
`base.jss_styles = #{styles_hash.to_n}` if styles_hash
|
34
|
-
styles_hash
|
35
|
-
elsif `typeof base.jss_styles === 'object'`
|
36
|
-
`Opal.Hash.$new(base.jss_styles)`
|
37
|
-
else
|
38
|
-
nil
|
39
|
-
end
|
40
|
-
end
|
41
|
-
alias_method :styles=, :styles
|
42
|
-
|
43
21
|
# preloading
|
44
22
|
def preload(&block)
|
45
23
|
`base.preload_block = block`
|
@@ -74,11 +52,6 @@ module LucidComponent
|
|
74
52
|
SessionStore
|
75
53
|
end
|
76
54
|
|
77
|
-
# styles
|
78
|
-
def styles
|
79
|
-
props.classes
|
80
|
-
end
|
81
|
-
|
82
55
|
def theme
|
83
56
|
props.theme
|
84
57
|
end
|
@@ -3,12 +3,18 @@ module LucidComponent
|
|
3
3
|
def self.included(base)
|
4
4
|
base.include(::Native::Wrapper)
|
5
5
|
base.extend(::LucidComponent::NativeLucidComponentConstructor)
|
6
|
-
|
6
|
+
if on_browser? || on_ssr?
|
7
|
+
base.extend(::LucidComponent::NativeComponentConstructor)
|
8
|
+
base.include(::React::Component::Elements)
|
9
|
+
elsif on_mobile?
|
10
|
+
base.extend(::LucidComponent::ReactNativeComponentConstructor)
|
11
|
+
base.include(::ReactNative::Component::Elements)
|
12
|
+
end
|
7
13
|
base.extend(::LucidPropDeclaration::Mixin)
|
8
|
-
base.include(::React::Component::Elements)
|
9
14
|
base.include(::React::Component::Api)
|
10
15
|
base.include(::React::Component::Callbacks)
|
11
16
|
base.include(::LucidComponent::Api)
|
17
|
+
base.include(::LucidComponent::StylesApi)
|
12
18
|
base.include(::LucidComponent::Initializer)
|
13
19
|
base.include(::React::Component::Features)
|
14
20
|
end
|
@@ -7,14 +7,14 @@ module LucidComponent
|
|
7
7
|
component_name = base.to_s + 'Wrapper'
|
8
8
|
# language=JS
|
9
9
|
%x{
|
10
|
-
base.react_component = function(props) {
|
10
|
+
base.react_component = Opal.global.React.memo(function(props) {
|
11
11
|
let opag = Opal.global;
|
12
|
-
let classes
|
12
|
+
let classes;
|
13
13
|
let store;
|
14
14
|
if (base.store_updates) { store = opag.React.useContext(opag.LucidApplicationContext); }
|
15
15
|
let theme = opag.ReactJSS.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 LucidComponent
|
|
27
27
|
new_props.theme = theme;
|
28
28
|
new_props.store = store;
|
29
29
|
return opag.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
|
@@ -51,43 +51,19 @@ module LucidComponent
|
|
51
51
|
let block_result;
|
52
52
|
if (base.while_loading_block && !this.state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
|
53
53
|
else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
|
54
|
-
if (block_result &&
|
54
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
55
55
|
oper.active_redux_components.pop();
|
56
56
|
oper.active_components.pop();
|
57
57
|
// console.log("lucid component popping", oper.render_buffer, oper.render_buffer.toString());
|
58
58
|
let result = oper.render_buffer.pop();
|
59
|
-
|
60
|
-
return result;
|
59
|
+
return (result.length === 1) ? result[0] : result;
|
61
60
|
}
|
62
61
|
data_access() {
|
63
62
|
return this.props.store;
|
64
63
|
}
|
65
64
|
shouldComponentUpdate(next_props, next_state) {
|
66
|
-
|
67
|
-
|
68
|
-
counter++;
|
69
|
-
if (next_props.hasOwnProperty(property)) {
|
70
|
-
if (!this.props.hasOwnProperty(property)) { return true; };
|
71
|
-
if (property === "children") { if (next_props.children !== this.props.children) { return true; }}
|
72
|
-
else if (typeof next_props[property] !== "undefined" && next_props[property] !== null && typeof next_props[property]['$!='] === "function" &&
|
73
|
-
typeof this.props[property] !== "undefined" && this.props[property] !== null ) {
|
74
|
-
if (#{ !! (`next_props[property]` != `this.props[property]`) }) { return true; }
|
75
|
-
} else if (next_props[property] !== this.props[property]) { return true; }
|
76
|
-
}
|
77
|
-
}
|
78
|
-
if (counter !== Object.keys(this.props).length) { return true; }
|
79
|
-
counter = 0;
|
80
|
-
for (var property in next_state) {
|
81
|
-
counter++;
|
82
|
-
if (next_state.hasOwnProperty(property)) {
|
83
|
-
if (!this.state.hasOwnProperty(property)) { return true; };
|
84
|
-
if (typeof next_state[property] !== "undefined" && next_state[property] !== null && typeof next_state[property]['$!='] === "function" &&
|
85
|
-
typeof this.state[property] !== "undefined" && this.state[property] !== null) {
|
86
|
-
if (#{ !! (`next_state[property]` != `this.state[property]`) }) { return true }
|
87
|
-
} else if (next_state[property] !== this.state[property]) { return true }
|
88
|
-
}
|
89
|
-
}
|
90
|
-
if (counter !== Object.keys(this.state).length) { return true; }
|
65
|
+
if (!Opal.React.props_are_equal(this.props, next_props)) { return true; }
|
66
|
+
if (Opal.React.state_is_not_equal(this.state, next_state)) { return true; }
|
91
67
|
return false;
|
92
68
|
}
|
93
69
|
validateProp(props, propName, componentName) {
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module LucidComponent
|
2
|
+
module StylesApi
|
3
|
+
def self.included(base)
|
4
|
+
base.instance_exec do
|
5
|
+
# styles
|
6
|
+
def styles(styles_hash = nil, &block)
|
7
|
+
if block_given?
|
8
|
+
%x{
|
9
|
+
base.jss_styles = function(theme) {
|
10
|
+
let wrapped_theme = Opal.React.Component.Styles.$new(theme);
|
11
|
+
var result = block.$call(wrapped_theme);
|
12
|
+
return result.$to_n();
|
13
|
+
}
|
14
|
+
}
|
15
|
+
nil
|
16
|
+
elsif styles_hash
|
17
|
+
`base.jss_styles = #{styles_hash.to_n}` if styles_hash
|
18
|
+
styles_hash
|
19
|
+
elsif `typeof base.jss_styles === 'object'`
|
20
|
+
`Opal.Hash.$new(base.jss_styles)`
|
21
|
+
else
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
alias_method :styles=, :styles
|
26
|
+
end
|
27
|
+
|
28
|
+
# styles
|
29
|
+
def styles
|
30
|
+
props.classes
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|