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
data/lib/react_dom.rb CHANGED
@@ -1,41 +1,41 @@
1
- module ReactDOM
2
- class << self
3
- def create_portal(child, container)
4
- # container is a native DOM node
5
- `Opal.global.ReactDOM.createPortal(child, container)`
6
- end
7
-
8
- def find_dom_node(native_react_component)
9
- `Opal.global.ReactDOM.findDOMNode(native_react_component)`
10
- end
11
-
12
- def hydrate(native_react_element, container, &block)
13
- # container is a native DOM element
14
- if block_given?
15
- `Opal.global.ReactDOM.hydrate(native_react_element, container, function() { block.$call() })`
16
- else
17
- `Opal.global.ReactDOM.hydrate(native_react_element, container)`
18
- end
19
- end
20
-
21
- def render(native_react_element, container, &block)
22
- # container is a native DOM element
23
- if block_given?
24
- `Opal.global.ReactDOM.render(native_react_element, container, function() { block.$call() })`
25
- else
26
- `Opal.global.ReactDOM.render(native_react_element, container)`
27
- end
28
- end
29
-
30
- def unmount_component_at_node(element_or_query)
31
- if `(typeof element_or_query === 'string')` || (`(typeof element_or_query.$class === 'function')` && element_or_query.class == String)
32
- element = `document.body.querySelector(element_or_query)`
33
- elsif `(typeof element_or_query.$is_a === 'function')` && element_or_query.is_a?(Browser::Element)
34
- element = element_or_query.to_n
35
- else
36
- element = element_or_query
37
- end
38
- `Opal.global.ReactDOM.unmountComponentAtNode(element)`
39
- end
40
- end
41
- end
1
+ module ReactDOM
2
+ class << self
3
+ def create_portal(child, container)
4
+ # container is a native DOM node
5
+ `Opal.global.ReactDOM.createPortal(child, container)`
6
+ end
7
+
8
+ def find_dom_node(native_react_component)
9
+ `Opal.global.ReactDOM.findDOMNode(native_react_component)`
10
+ end
11
+
12
+ def hydrate(native_react_element, container, &block)
13
+ # container is a native DOM element
14
+ if block_given?
15
+ `Opal.global.ReactDOM.hydrate(native_react_element, container, function() { block.$call() })`
16
+ else
17
+ `Opal.global.ReactDOM.hydrate(native_react_element, container)`
18
+ end
19
+ end
20
+
21
+ def render(native_react_element, container, &block)
22
+ # container is a native DOM element
23
+ if block_given?
24
+ `Opal.global.ReactDOM.render(native_react_element, container, function() { block.$call() })`
25
+ else
26
+ `Opal.global.ReactDOM.render(native_react_element, container)`
27
+ end
28
+ end
29
+
30
+ def unmount_component_at_node(element_or_query)
31
+ if `(typeof element_or_query === 'string')` || (`(typeof element_or_query.$class === 'function')` && element_or_query.class == String)
32
+ element = `document.body.querySelector(element_or_query)`
33
+ elsif `(typeof element_or_query.$is_a === 'function')` && element_or_query.is_a?(Browser::Element)
34
+ element = element_or_query.to_n
35
+ else
36
+ element = element_or_query
37
+ end
38
+ `Opal.global.ReactDOM.unmountComponentAtNode(element)`
39
+ end
40
+ end
41
+ end
@@ -1,19 +1,19 @@
1
- module ReactDOMServer
2
- class << self
3
- def render_to_string(native_react_element)
4
- `Opal.global.ReactDOMServer.renderToString(native_react_element)`
5
- end
6
-
7
- def render_to_static_markup(native_react_element)
8
- `Opal.global.ReactDOMServer.renderToStaticMarkup(native_react_element)`
9
- end
10
-
11
- def render_to_node_stream(native_react_element)
12
- `Opal.global.ReactDOMServer.renderToNodeStream(native_react_element)`
13
- end
14
-
15
- def render_to_static_node_stream(native_react_element)
16
- `Opal.global.ReactDOMServer.renderToStaticNodeStream(native_react_element)`
17
- end
18
- end
1
+ module ReactDOMServer
2
+ class << self
3
+ def render_to_string(native_react_element)
4
+ `Opal.global.ReactDOMServer.renderToString(native_react_element)`
5
+ end
6
+
7
+ def render_to_static_markup(native_react_element)
8
+ `Opal.global.ReactDOMServer.renderToStaticMarkup(native_react_element)`
9
+ end
10
+
11
+ def render_to_node_stream(native_react_element)
12
+ `Opal.global.ReactDOMServer.renderToNodeStream(native_react_element)`
13
+ end
14
+
15
+ def render_to_static_node_stream(native_react_element)
16
+ `Opal.global.ReactDOMServer.renderToStaticNodeStream(native_react_element)`
17
+ end
18
+ end
19
19
  end
@@ -1,203 +1,203 @@
1
- module ReactNative
2
- module Component
3
- module Elements
4
- # https://www.w3.org/TR/html52/fullindex.html#index-elements
5
- # https://www.w3.org/TR/SVG11/eltindex.html
6
- UNSUPPORTED_HTML_AND_SVG_ELEMENTS = %w[
7
- a abbr address area article aside audio
8
- base bdi bdo blockquote body br
9
- canvas caption cite col colgroup
10
- data datalist dd del details dfn dialog dl dt
11
- em embed
12
- fieldset figcaption figure footer form
13
- head header hr html
14
- iframe ins
15
- kbd
16
- label legend li link
17
- main map mark meta meter
18
- nav noscript
19
- object ol optgroup option output
20
- param picture progress
21
- q
22
- rp rt rtc ruby
23
- s samp script section select small source span strong style sub summary sup
24
- table tbody td template textarea tfoot th thead time title tr track
25
- ul
26
- var video
27
- wbr
28
-
29
- altGlyph altGlyphDef altGlyphItem animate animateColor animateMotion animateTransform
30
- color-profile cursor
31
- desc
32
- feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting
33
- feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur
34
- feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting
35
- feSpotLight feTile feTurbulence
36
- filter font font-face font-face-format font-face-name font-face-src font-face-uri
37
- glyph glyphRef
38
- hkern
39
- metadata missing-glyph mpath
40
- script set style switch
41
- tref
42
- view vkern
43
- ]
44
-
45
- UNSUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element|
46
- define_method(element) do |*args, &block|
47
- `console.warn("Element " + element + " is not yet supported, using a Text component as substitute!")`
48
- `Opal.React.internal_prepare_args_and_render(Opal.global.Text, args, block)`
49
- end
50
- define_method(`element.toUpperCase()`) do |*args, &block|
51
- `console.warn("Element " + element + " is not yet supported, using a Text component as substitute!")`
52
- `Opal.React.internal_prepare_args_and_render(Opal.global.Text, args, block)`
53
- end
54
- end
55
-
56
- # button
57
- %x{
58
- self['supported_button'] = function(props) {
59
- let theme = Opal.global.React.useContext(Opal.global.ThemeContext);
60
- let style = {};
61
- if (theme && typeof theme['button'] !== 'undefined') { style = theme['button']; }
62
- if (typeof props.style !== 'undefined') {
63
- style = Opal.React.merge_deep(style, props.style);
64
- }
65
- let new_props = Object.assign({}, props, { style: style });
66
- if (typeof props.title === 'undefined') {
67
- try {
68
- new_props.title = props.children.props.children;
69
- } catch (e) {
70
- console.error("BUTTON accepts only one string child!")
71
- }
72
- }
73
- return Opal.global.React.createElement(Opal.global.Button, new_props);
74
- }
75
- self['supported_button'].displayName = 'BUTTON';
76
- }
77
- define_method('button') do |*args, &block|
78
- `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements.supported_button, args, block)`
79
- end
80
- define_method('BUTTON') do |*args, &block|
81
- `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements.supported_button, args, block)`
82
- end
83
-
84
- # img
85
- define_method('img') do |*args, &block|
86
- `Opal.React.internal_prepare_args_and_render(Opal.global.Image, args, block)`
87
- end
88
- define_method('IMG') do |*args, &block|
89
- `Opal.React.internal_prepare_args_and_render(Opal.global.Image, args, block)`
90
- end
91
-
92
- # input
93
- %x{
94
- self.supported_input = function(props) {
95
- Opal.React.render_buffer.push([]);
96
- if (typeof props.type !== 'undefined') {
97
- if (props.type === 'text') { return Opal.React.internal_prepare_args_and_render(Opal.global.TextInput, props); }
98
- else if (props.type === 'checkbox') { return Opal.React.internal_prepare_args_and_render(Opal.global.InputSwitch, props); }
99
- else {
100
- console.warn("Input type " + props.type + " not supported. Using TextInput as substitute!");
101
- return Opal.React.internal_prepare_args_and_render(Opal.global.TextInput, props);
102
- }
103
- }
104
- Opal.React.internal_prepare_args_and_render(Opal.global.TextInput, props);
105
- return Opal.React.render_buffer.pop();
106
- }
107
- }
108
- define_method('input') do |*args, &block|
109
- `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements.supported_input, args, block)`
110
- end
111
- define_method('INPUT') do |*args, &block|
112
- `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements.supported_input, args, block)`
113
- end
114
-
115
- # elements that map to Text with style
116
- SUPPORTED_TEXT_HTML_ELEMENTS = %w[
117
- b
118
- code
119
- h1 h2 h3 h4 h5 h6
120
- i
121
- pre
122
- span
123
- u
124
- ]
125
-
126
- SUPPORTED_TEXT_HTML_ELEMENTS.each do |element|
127
- fun_name = 'supported_' + element
128
- %x{
129
- self[fun_name] = function(props) {
130
- let theme = Opal.global.React.useContext(Opal.global.ThemeContext);
131
- let style = {};
132
- if (theme && typeof theme[element] !== 'undefined') { style = theme[element]; }
133
- if (typeof props.style !== 'undefined') {
134
- style = Opal.React.merge_deep(style, props.style);
135
- }
136
- let new_props = Object.assign({}, props, { style: style });
137
- return Opal.global.React.createElement(Opal.global.Text, new_props);
138
- }
139
- self[fun_name].displayName = element.toUpperCase();
140
- }
141
- define_method(`element.toLowerCase()`) do |*args, &block|
142
- `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements[fun_name], args, block)`
143
- end
144
- define_method(`element.toUpperCase()`) do |*args, &block|
145
- `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements[fun_name], args, block)`
146
- end
147
- end
148
-
149
- SUPPORTED_VIEW_HTML_ELEMENTS = %w[
150
- div
151
- p
152
- ]
153
-
154
- SUPPORTED_VIEW_HTML_ELEMENTS.each do |element|
155
- fun_name = 'supported_' + element
156
- %x{
157
- self[fun_name] = function(props) {
158
- let theme = Opal.global.React.useContext(Opal.global.ThemeContext);
159
- let style = {};
160
- if (theme && typeof theme[element] !== 'undefined') { style = theme[element]; }
161
- if (typeof props.style !== 'undefined') {
162
- style = Opal.React.merge_deep(style, props.style);
163
- }
164
- let new_props = Object.assign({}, props, { style: style });
165
- return Opal.global.React.createElement(Opal.global.View, new_props);
166
- }
167
- self[fun_name].displayName = element.toUpperCase();
168
- }
169
- define_method(`element.toLowerCase()`) do |*args, &block|
170
- `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements[fun_name], args, block)`
171
- end
172
- define_method(`element.toUpperCase()`) do |*args, &block|
173
- `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements[fun_name], args, block)`
174
- end
175
- end
176
-
177
- SUPPORTED_SVG_ELEMENTS = %w[
178
- Circle ClipPath
179
- Defs
180
- Ellipse
181
- ForeignObject
182
- G
183
- Image
184
- Line LinearGradient
185
- Marker Mask
186
- Path Pattern Polygon Polyline
187
- RadialGradient Rect
188
- Stop Svg Symbol
189
- Text TextPath TSpan
190
- Use
191
- ]
192
-
193
- SUPPORTED_SVG_ELEMENTS.each do |element|
194
- define_method(`element.toLowerCase()`) do |*args, &block|
195
- `Opal.React.internal_prepare_args_and_render(Opal.global.ReactNativeSvg[element], args, block)`
196
- end
197
- define_method(`element.toUpperCase()`) do |*args, &block|
198
- `Opal.React.internal_prepare_args_and_render(Opal.global.ReactNativeSvg[element], args, block)`
199
- end
200
- end
201
- end
202
- end
203
- end
1
+ module ReactNative
2
+ module Component
3
+ module Elements
4
+ # https://www.w3.org/TR/html52/fullindex.html#index-elements
5
+ # https://www.w3.org/TR/SVG11/eltindex.html
6
+ UNSUPPORTED_HTML_AND_SVG_ELEMENTS = %w[
7
+ a abbr address area article aside audio
8
+ base bdi bdo blockquote body br
9
+ canvas caption cite col colgroup
10
+ data datalist dd del details dfn dialog dl dt
11
+ em embed
12
+ fieldset figcaption figure footer form
13
+ head header hr html
14
+ iframe ins
15
+ kbd
16
+ label legend li link
17
+ main map mark meta meter
18
+ nav noscript
19
+ object ol optgroup option output
20
+ param picture progress
21
+ q
22
+ rp rt rtc ruby
23
+ s samp script section select small source span strong style sub summary sup
24
+ table tbody td template textarea tfoot th thead time title tr track
25
+ ul
26
+ var video
27
+ wbr
28
+
29
+ altGlyph altGlyphDef altGlyphItem animate animateColor animateMotion animateTransform
30
+ color-profile cursor
31
+ desc
32
+ feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting
33
+ feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur
34
+ feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting
35
+ feSpotLight feTile feTurbulence
36
+ filter font font-face font-face-format font-face-name font-face-src font-face-uri
37
+ glyph glyphRef
38
+ hkern
39
+ metadata missing-glyph mpath
40
+ script set style switch
41
+ tref
42
+ view vkern
43
+ ]
44
+
45
+ UNSUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element|
46
+ define_method(element) do |*args, &block|
47
+ `console.warn("Element " + element + " is not yet supported, using a Text component as substitute!")`
48
+ `Opal.React.internal_prepare_args_and_render(Opal.global.Text, args, block)`
49
+ end
50
+ define_method(`element.toUpperCase()`) do |*args, &block|
51
+ `console.warn("Element " + element + " is not yet supported, using a Text component as substitute!")`
52
+ `Opal.React.internal_prepare_args_and_render(Opal.global.Text, args, block)`
53
+ end
54
+ end
55
+
56
+ # button
57
+ %x{
58
+ self['supported_button'] = function(props) {
59
+ let theme = Opal.global.React.useContext(Opal.global.ThemeContext);
60
+ let style = {};
61
+ if (theme && typeof theme['button'] !== 'undefined') { style = theme['button']; }
62
+ if (typeof props.style !== 'undefined') {
63
+ style = Opal.React.merge_deep(style, props.style);
64
+ }
65
+ let new_props = Object.assign({}, props, { style: style });
66
+ if (typeof props.title === 'undefined') {
67
+ try {
68
+ new_props.title = props.children.props.children;
69
+ } catch (e) {
70
+ console.error("BUTTON accepts only one string child!")
71
+ }
72
+ }
73
+ return Opal.global.React.createElement(Opal.global.Button, new_props);
74
+ }
75
+ self['supported_button'].displayName = 'BUTTON';
76
+ }
77
+ define_method('button') do |*args, &block|
78
+ `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements.supported_button, args, block)`
79
+ end
80
+ define_method('BUTTON') do |*args, &block|
81
+ `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements.supported_button, args, block)`
82
+ end
83
+
84
+ # img
85
+ define_method('img') do |*args, &block|
86
+ `Opal.React.internal_prepare_args_and_render(Opal.global.Image, args, block)`
87
+ end
88
+ define_method('IMG') do |*args, &block|
89
+ `Opal.React.internal_prepare_args_and_render(Opal.global.Image, args, block)`
90
+ end
91
+
92
+ # input
93
+ %x{
94
+ self.supported_input = function(props) {
95
+ Opal.React.render_buffer.push([]);
96
+ if (typeof props.type !== 'undefined') {
97
+ if (props.type === 'text') { return Opal.React.internal_prepare_args_and_render(Opal.global.TextInput, props); }
98
+ else if (props.type === 'checkbox') { return Opal.React.internal_prepare_args_and_render(Opal.global.InputSwitch, props); }
99
+ else {
100
+ console.warn("Input type " + props.type + " not supported. Using TextInput as substitute!");
101
+ return Opal.React.internal_prepare_args_and_render(Opal.global.TextInput, props);
102
+ }
103
+ }
104
+ Opal.React.internal_prepare_args_and_render(Opal.global.TextInput, props);
105
+ return Opal.React.render_buffer.pop();
106
+ }
107
+ }
108
+ define_method('input') do |*args, &block|
109
+ `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements.supported_input, args, block)`
110
+ end
111
+ define_method('INPUT') do |*args, &block|
112
+ `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements.supported_input, args, block)`
113
+ end
114
+
115
+ # elements that map to Text with style
116
+ SUPPORTED_TEXT_HTML_ELEMENTS = %w[
117
+ b
118
+ code
119
+ h1 h2 h3 h4 h5 h6
120
+ i
121
+ pre
122
+ span
123
+ u
124
+ ]
125
+
126
+ SUPPORTED_TEXT_HTML_ELEMENTS.each do |element|
127
+ fun_name = 'supported_' + element
128
+ %x{
129
+ self[fun_name] = function(props) {
130
+ let theme = Opal.global.React.useContext(Opal.global.ThemeContext);
131
+ let style = {};
132
+ if (theme && typeof theme[element] !== 'undefined') { style = theme[element]; }
133
+ if (typeof props.style !== 'undefined') {
134
+ style = Opal.React.merge_deep(style, props.style);
135
+ }
136
+ let new_props = Object.assign({}, props, { style: style });
137
+ return Opal.global.React.createElement(Opal.global.Text, new_props);
138
+ }
139
+ self[fun_name].displayName = element.toUpperCase();
140
+ }
141
+ define_method(`element.toLowerCase()`) do |*args, &block|
142
+ `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements[fun_name], args, block)`
143
+ end
144
+ define_method(`element.toUpperCase()`) do |*args, &block|
145
+ `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements[fun_name], args, block)`
146
+ end
147
+ end
148
+
149
+ SUPPORTED_VIEW_HTML_ELEMENTS = %w[
150
+ div
151
+ p
152
+ ]
153
+
154
+ SUPPORTED_VIEW_HTML_ELEMENTS.each do |element|
155
+ fun_name = 'supported_' + element
156
+ %x{
157
+ self[fun_name] = function(props) {
158
+ let theme = Opal.global.React.useContext(Opal.global.ThemeContext);
159
+ let style = {};
160
+ if (theme && typeof theme[element] !== 'undefined') { style = theme[element]; }
161
+ if (typeof props.style !== 'undefined') {
162
+ style = Opal.React.merge_deep(style, props.style);
163
+ }
164
+ let new_props = Object.assign({}, props, { style: style });
165
+ return Opal.global.React.createElement(Opal.global.View, new_props);
166
+ }
167
+ self[fun_name].displayName = element.toUpperCase();
168
+ }
169
+ define_method(`element.toLowerCase()`) do |*args, &block|
170
+ `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements[fun_name], args, block)`
171
+ end
172
+ define_method(`element.toUpperCase()`) do |*args, &block|
173
+ `Opal.React.internal_prepare_args_and_render(Opal.ReactNative.Component.Elements[fun_name], args, block)`
174
+ end
175
+ end
176
+
177
+ SUPPORTED_SVG_ELEMENTS = %w[
178
+ Circle ClipPath
179
+ Defs
180
+ Ellipse
181
+ ForeignObject
182
+ G
183
+ Image
184
+ Line LinearGradient
185
+ Marker Mask
186
+ Path Pattern Polygon Polyline
187
+ RadialGradient Rect
188
+ Stop Svg Symbol
189
+ Text TextPath TSpan
190
+ Use
191
+ ]
192
+
193
+ SUPPORTED_SVG_ELEMENTS.each do |element|
194
+ define_method(`element.toLowerCase()`) do |*args, &block|
195
+ `Opal.React.internal_prepare_args_and_render(Opal.global.ReactNativeSvg[element], args, block)`
196
+ end
197
+ define_method(`element.toUpperCase()`) do |*args, &block|
198
+ `Opal.React.internal_prepare_args_and_render(Opal.global.ReactNativeSvg[element], args, block)`
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end
@@ -1,51 +1,51 @@
1
- module LucidApp
2
- module ReactNativeComponentConstructor
3
- # for should_component_update we apply ruby semantics for comparing props
4
- # to do so, we convert the props to ruby hashes and then compare
5
- # this makes sure, that for example rubys Nil object gets handled properly
6
- def self.extended(base)
7
- component_name = base.to_s + 'Wrapper'
8
- theme_component_name = base.to_s + 'ThemeWrapper'
9
- # language=JS
10
- %x{
11
- base.jss_theme = {};
12
- base.themed_react_component = function(props) {
13
- const opag = Opal.global;
14
- const theme = opag.React.useContext(opag.ThemeContext);
15
- let classes;
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.React.merge_deep(theme, opag.StyleSheet.create(styles));
22
- }
23
- classes = base.use_styles;
24
- } else {
25
- classes = theme;
26
- }
27
- let themed_classes_props = Object.assign({}, props, { classes: classes, theme: theme });
28
- return opag.React.createElement(base.lucid_react_component, themed_classes_props);
29
- };
30
- base.themed_react_component.displayName = #{theme_component_name};
31
- base.react_component = class extends Opal.global.React.Component {
32
- constructor(props) {
33
- super(props);
34
- if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
35
- }
36
- static get displayName() {
37
- return "IsomorfeusTopLevelComponent";
38
- }
39
- static set displayName(new_name) {
40
- // dont do anything here except returning the set value
41
- return new_name;
42
- }
43
- render() {
44
- let themed_component = Opal.global.React.createElement(base.themed_react_component, this.props);
45
- return Opal.global.React.createElement(Opal.global.ThemeContext.Provider, { value: Opal.global.DefaultTheme }, themed_component);
46
- }
47
- }
48
- }
49
- end
50
- end
51
- end
1
+ module LucidApp
2
+ module ReactNativeComponentConstructor
3
+ # for should_component_update we apply ruby semantics for comparing props
4
+ # to do so, we convert the props to ruby hashes and then compare
5
+ # this makes sure, that for example rubys Nil object gets handled properly
6
+ def self.extended(base)
7
+ component_name = base.to_s + 'Wrapper'
8
+ theme_component_name = base.to_s + 'ThemeWrapper'
9
+ # language=JS
10
+ %x{
11
+ base.jss_theme = {};
12
+ base.themed_react_component = function(props) {
13
+ const opag = Opal.global;
14
+ const theme = opag.React.useContext(opag.ThemeContext);
15
+ let classes;
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.React.merge_deep(theme, opag.StyleSheet.create(styles));
22
+ }
23
+ classes = base.use_styles;
24
+ } else {
25
+ classes = theme;
26
+ }
27
+ let themed_classes_props = Object.assign({}, props, { classes: classes, theme: theme });
28
+ return opag.React.createElement(base.lucid_react_component, themed_classes_props);
29
+ };
30
+ base.themed_react_component.displayName = #{theme_component_name};
31
+ base.react_component = class extends Opal.global.React.Component {
32
+ constructor(props) {
33
+ super(props);
34
+ if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
35
+ }
36
+ static get displayName() {
37
+ return "IsomorfeusTopLevelComponent";
38
+ }
39
+ static set displayName(new_name) {
40
+ // dont do anything here except returning the set value
41
+ return new_name;
42
+ }
43
+ render() {
44
+ let themed_component = Opal.global.React.createElement(base.themed_react_component, this.props);
45
+ return Opal.global.React.createElement(Opal.global.ThemeContext.Provider, { value: Opal.global.DefaultTheme }, themed_component);
46
+ }
47
+ }
48
+ }
49
+ end
50
+ end
51
+ end