matestack-ui-core 0.7.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +8 -0
  3. data/README.md +28 -216
  4. data/app/concepts/matestack/ui/core/abbr/abbr.haml +3 -3
  5. data/app/concepts/matestack/ui/core/abbr/abbr.rb +1 -8
  6. data/app/concepts/matestack/ui/core/action/action.haml +1 -1
  7. data/app/concepts/matestack/ui/core/action/action.js +120 -39
  8. data/app/concepts/matestack/ui/core/action/action.rb +40 -15
  9. data/app/concepts/matestack/ui/core/actionview/dynamic.haml +4 -4
  10. data/app/concepts/matestack/ui/core/address/address.haml +3 -3
  11. data/app/concepts/matestack/ui/core/address/address.rb +1 -1
  12. data/app/concepts/matestack/ui/core/app/app.haml +2 -3
  13. data/app/concepts/matestack/ui/core/app/app.js +6 -3
  14. data/app/concepts/matestack/ui/core/app/app.rb +33 -56
  15. data/app/concepts/matestack/ui/core/app/store.js +28 -2
  16. data/app/concepts/matestack/ui/core/area/area.haml +1 -1
  17. data/app/concepts/matestack/ui/core/area/area.rb +2 -14
  18. data/app/concepts/matestack/ui/core/article/article.haml +3 -3
  19. data/app/concepts/matestack/ui/core/article/article.rb +1 -1
  20. data/app/concepts/matestack/ui/core/aside/aside.haml +1 -1
  21. data/app/concepts/matestack/ui/core/aside/aside.rb +0 -1
  22. data/app/concepts/matestack/ui/core/async/async.haml +6 -2
  23. data/app/concepts/matestack/ui/core/async/async.js +43 -9
  24. data/app/concepts/matestack/ui/core/async/async.rb +29 -4
  25. data/app/concepts/matestack/ui/core/async/children_wrapper.haml +2 -0
  26. data/app/concepts/matestack/ui/core/b/b.haml +3 -3
  27. data/app/concepts/matestack/ui/core/b/b.rb +1 -1
  28. data/app/concepts/matestack/ui/core/bdi/bdi.haml +3 -3
  29. data/app/concepts/matestack/ui/core/bdi/bdi.rb +1 -0
  30. data/app/concepts/matestack/ui/core/bdo/bdo.haml +3 -3
  31. data/app/concepts/matestack/ui/core/bdo/bdo.rb +2 -7
  32. data/app/concepts/matestack/ui/core/blockquote/blockquote.haml +3 -3
  33. data/app/concepts/matestack/ui/core/blockquote/blockquote.rb +2 -7
  34. data/app/concepts/matestack/ui/core/br/br.haml +4 -4
  35. data/app/concepts/matestack/ui/core/br/br.rb +1 -1
  36. data/app/concepts/matestack/ui/core/button/button.haml +3 -3
  37. data/app/concepts/matestack/ui/core/button/button.rb +3 -7
  38. data/app/concepts/matestack/ui/core/cable/cable.haml +4 -0
  39. data/app/concepts/matestack/ui/core/cable/cable.js +100 -0
  40. data/app/concepts/matestack/ui/core/cable/cable.rb +28 -0
  41. data/app/concepts/matestack/ui/core/cable/children_wrapper.haml +2 -0
  42. data/app/concepts/matestack/ui/core/caption/caption.haml +3 -3
  43. data/app/concepts/matestack/ui/core/caption/caption.rb +1 -1
  44. data/app/concepts/matestack/ui/core/cite/cite.haml +3 -3
  45. data/app/concepts/matestack/ui/core/cite/cite.rb +1 -1
  46. data/app/concepts/matestack/ui/core/code/code.haml +3 -3
  47. data/app/concepts/matestack/ui/core/code/code.rb +1 -1
  48. data/app/concepts/matestack/ui/core/collection/content/content.js +2 -2
  49. data/app/concepts/matestack/ui/core/collection/content/content.rb +4 -6
  50. data/app/concepts/matestack/ui/core/collection/content/next/next.haml +1 -1
  51. data/app/concepts/matestack/ui/core/collection/content/page/link/link.haml +1 -1
  52. data/app/concepts/matestack/ui/core/collection/content/page/link/link.rb +5 -3
  53. data/app/concepts/matestack/ui/core/collection/content/previous/previous.haml +1 -1
  54. data/app/concepts/matestack/ui/core/collection/filter/filter.rb +4 -5
  55. data/app/concepts/matestack/ui/core/collection/filter/input/input.rb +11 -8
  56. data/app/concepts/matestack/ui/core/collection/filter/reset/reset.haml +1 -1
  57. data/app/concepts/matestack/ui/core/collection/filter/select/select.haml +10 -0
  58. data/app/concepts/matestack/ui/core/collection/filter/select/select.rb +30 -0
  59. data/app/concepts/matestack/ui/core/collection/filter/submit/submit.haml +1 -1
  60. data/app/concepts/matestack/ui/core/collection/helper.rb +14 -6
  61. data/app/concepts/matestack/ui/core/collection/order/order.js +1 -1
  62. data/app/concepts/matestack/ui/core/collection/order/order.rb +4 -5
  63. data/app/concepts/matestack/ui/core/collection/order/toggle/indicator/indicator.rb +9 -5
  64. data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.haml +1 -1
  65. data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.rb +0 -1
  66. data/app/concepts/matestack/ui/core/component/base.rb +430 -0
  67. data/app/concepts/matestack/ui/core/component/children.haml +2 -2
  68. data/app/concepts/matestack/ui/core/component/component.js +9 -46
  69. data/app/concepts/matestack/ui/core/component/dynamic.haml +1 -1
  70. data/app/concepts/matestack/ui/core/component/dynamic.rb +25 -247
  71. data/app/concepts/matestack/ui/core/component/static.rb +3 -12
  72. data/app/concepts/matestack/ui/core/data/data.haml +3 -3
  73. data/app/concepts/matestack/ui/core/data/data.rb +2 -5
  74. data/app/concepts/matestack/ui/core/datalist/datalist.haml +2 -2
  75. data/app/concepts/matestack/ui/core/datalist/datalist.rb +1 -2
  76. data/app/concepts/matestack/ui/core/dd/dd.haml +3 -3
  77. data/app/concepts/matestack/ui/core/dd/dd.rb +1 -1
  78. data/app/concepts/matestack/ui/core/del/del.haml +3 -3
  79. data/app/concepts/matestack/ui/core/del/del.rb +2 -0
  80. data/app/concepts/matestack/ui/core/details/details.haml +1 -1
  81. data/app/concepts/matestack/ui/core/details/details.rb +1 -1
  82. data/app/concepts/matestack/ui/core/dfn/dfn.haml +3 -3
  83. data/app/concepts/matestack/ui/core/dfn/dfn.rb +1 -1
  84. data/app/concepts/matestack/ui/core/dialog/dialog.haml +3 -3
  85. data/app/concepts/matestack/ui/core/dialog/dialog.rb +2 -5
  86. data/app/concepts/matestack/ui/core/div/div.haml +1 -1
  87. data/app/concepts/matestack/ui/core/div/div.rb +0 -1
  88. data/app/concepts/matestack/ui/core/dl/dl.haml +3 -3
  89. data/app/concepts/matestack/ui/core/dl/dl.rb +2 -2
  90. data/app/concepts/matestack/ui/core/dt/dt.haml +3 -3
  91. data/app/concepts/matestack/ui/core/dt/dt.rb +1 -1
  92. data/app/concepts/matestack/ui/core/em/em.haml +3 -3
  93. data/app/concepts/matestack/ui/core/em/em.rb +1 -1
  94. data/app/concepts/matestack/ui/core/fieldset/fieldset.haml +4 -4
  95. data/app/concepts/matestack/ui/core/fieldset/fieldset.rb +3 -6
  96. data/app/concepts/matestack/ui/core/figure/figure.haml +1 -1
  97. data/app/concepts/matestack/ui/core/figure/figure.rb +0 -1
  98. data/app/concepts/matestack/ui/core/footer/footer.haml +1 -1
  99. data/app/concepts/matestack/ui/core/footer/footer.rb +0 -1
  100. data/app/concepts/matestack/ui/core/form/checkbox/checkbox.rb +79 -0
  101. data/app/concepts/matestack/ui/core/form/form.haml +1 -1
  102. data/app/concepts/matestack/ui/core/form/form.js +257 -123
  103. data/app/concepts/matestack/ui/core/form/form.rb +52 -19
  104. data/app/concepts/matestack/ui/core/form/has_errors.rb +54 -0
  105. data/app/concepts/matestack/ui/core/form/has_input_html_attributes.rb +13 -0
  106. data/app/concepts/matestack/ui/core/form/input/input.rb +32 -52
  107. data/app/concepts/matestack/ui/core/form/radio/radio.rb +71 -0
  108. data/app/concepts/matestack/ui/core/form/select/select.haml +9 -76
  109. data/app/concepts/matestack/ui/core/form/select/select.rb +44 -49
  110. data/app/concepts/matestack/ui/core/form/submit/submit.haml +1 -1
  111. data/app/concepts/matestack/ui/core/form/submit/submit.rb +5 -2
  112. data/app/concepts/matestack/ui/core/form/textarea/textarea.rb +28 -0
  113. data/app/concepts/matestack/ui/core/form/utils.rb +47 -0
  114. data/app/concepts/matestack/ui/core/header/header.haml +1 -1
  115. data/app/concepts/matestack/ui/core/header/header.rb +0 -1
  116. data/app/concepts/matestack/ui/core/heading/heading.haml +4 -49
  117. data/app/concepts/matestack/ui/core/heading/heading.rb +1 -1
  118. data/app/concepts/matestack/ui/core/hr/hr.haml +1 -1
  119. data/app/concepts/matestack/ui/core/hr/hr.rb +0 -1
  120. data/app/concepts/matestack/ui/core/icon/icon.haml +3 -3
  121. data/app/concepts/matestack/ui/core/icon/icon.rb +1 -1
  122. data/app/concepts/matestack/ui/core/iframe/iframe.haml +3 -3
  123. data/app/concepts/matestack/ui/core/iframe/iframe.rb +3 -10
  124. data/app/concepts/matestack/ui/core/img/img.haml +1 -1
  125. data/app/concepts/matestack/ui/core/img/img.rb +8 -8
  126. data/app/concepts/matestack/ui/core/input/input.haml +1 -2
  127. data/app/concepts/matestack/ui/core/input/input.rb +4 -4
  128. data/app/concepts/matestack/ui/core/ins/ins.haml +3 -3
  129. data/app/concepts/matestack/ui/core/ins/ins.rb +2 -6
  130. data/app/concepts/matestack/ui/core/isolated/children_wrapper.haml +2 -0
  131. data/app/concepts/matestack/ui/core/isolated/isolated.haml +10 -0
  132. data/app/concepts/matestack/ui/core/isolated/isolated.js +108 -0
  133. data/app/concepts/matestack/ui/core/isolated/isolated.rb +59 -0
  134. data/app/concepts/matestack/ui/core/js/core.js +6 -4
  135. data/app/concepts/matestack/ui/core/kbd/kbd.haml +3 -3
  136. data/app/concepts/matestack/ui/core/kbd/kbd.rb +1 -0
  137. data/app/concepts/matestack/ui/core/label/label.haml +3 -3
  138. data/app/concepts/matestack/ui/core/label/label.rb +2 -6
  139. data/app/concepts/matestack/ui/core/legend/legend.haml +3 -3
  140. data/app/concepts/matestack/ui/core/legend/legend.rb +1 -1
  141. data/app/concepts/matestack/ui/core/li/li.haml +3 -3
  142. data/app/concepts/matestack/ui/core/li/li.rb +2 -1
  143. data/app/concepts/matestack/ui/core/link/link.haml +3 -3
  144. data/app/concepts/matestack/ui/core/link/link.rb +10 -14
  145. data/app/concepts/matestack/ui/core/main/main.haml +1 -1
  146. data/app/concepts/matestack/ui/core/main/main.rb +0 -1
  147. data/app/concepts/matestack/ui/core/map/map.haml +1 -1
  148. data/app/concepts/matestack/ui/core/map/map.rb +1 -7
  149. data/app/concepts/matestack/ui/core/mark/mark.haml +3 -3
  150. data/app/concepts/matestack/ui/core/mark/mark.rb +1 -0
  151. data/app/concepts/matestack/ui/core/meter/meter.haml +1 -1
  152. data/app/concepts/matestack/ui/core/meter/meter.rb +1 -10
  153. data/app/concepts/matestack/ui/core/nav/nav.haml +1 -1
  154. data/app/concepts/matestack/ui/core/nav/nav.rb +0 -1
  155. data/app/concepts/matestack/ui/core/noscript/noscript.haml +3 -3
  156. data/app/concepts/matestack/ui/core/noscript/noscript.rb +1 -1
  157. data/app/concepts/matestack/ui/core/object/object.haml +1 -1
  158. data/app/concepts/matestack/ui/core/object/object.rb +1 -11
  159. data/app/concepts/matestack/ui/core/ol/ol.haml +1 -1
  160. data/app/concepts/matestack/ui/core/ol/ol.rb +1 -1
  161. data/app/concepts/matestack/ui/core/onclick/onclick.haml +1 -1
  162. data/app/concepts/matestack/ui/core/onclick/onclick.rb +1 -0
  163. data/app/concepts/matestack/ui/core/optgroup/optgroup.haml +1 -1
  164. data/app/concepts/matestack/ui/core/optgroup/optgroup.rb +1 -6
  165. data/app/concepts/matestack/ui/core/option/option.haml +3 -3
  166. data/app/concepts/matestack/ui/core/option/option.rb +2 -8
  167. data/app/concepts/matestack/ui/core/output/output.haml +3 -3
  168. data/app/concepts/matestack/ui/core/output/output.rb +2 -7
  169. data/app/concepts/matestack/ui/core/page/{content.js → content/content.js} +8 -2
  170. data/app/concepts/matestack/ui/core/page/content/content.rb +28 -0
  171. data/app/concepts/matestack/ui/core/page/page.haml +3 -9
  172. data/app/concepts/matestack/ui/core/page/page.rb +15 -175
  173. data/app/concepts/matestack/ui/core/paragraph/paragraph.haml +3 -3
  174. data/app/concepts/matestack/ui/core/paragraph/paragraph.rb +1 -1
  175. data/app/concepts/matestack/ui/core/param/param.haml +1 -1
  176. data/app/concepts/matestack/ui/core/param/param.rb +1 -6
  177. data/app/concepts/matestack/ui/core/partial/partial.rb +0 -1
  178. data/app/concepts/matestack/ui/core/picture/picture.haml +1 -1
  179. data/app/concepts/matestack/ui/core/pre/pre.haml +3 -3
  180. data/app/concepts/matestack/ui/core/pre/pre.rb +1 -1
  181. data/app/concepts/matestack/ui/core/progress/progress.haml +1 -1
  182. data/app/concepts/matestack/ui/core/progress/progress.rb +1 -10
  183. data/app/concepts/matestack/ui/core/q/q.haml +3 -3
  184. data/app/concepts/matestack/ui/core/q/q.rb +2 -7
  185. data/app/concepts/matestack/ui/core/rp/rp.haml +3 -3
  186. data/app/concepts/matestack/ui/core/rp/rp.rb +1 -1
  187. data/app/concepts/matestack/ui/core/rt/rt.haml +3 -3
  188. data/app/concepts/matestack/ui/core/rt/rt.rb +1 -1
  189. data/app/concepts/matestack/ui/core/ruby/ruby.haml +3 -3
  190. data/app/concepts/matestack/ui/core/ruby/ruby.rb +1 -1
  191. data/app/concepts/matestack/ui/core/s/s.haml +3 -3
  192. data/app/concepts/matestack/ui/core/s/s.rb +1 -1
  193. data/app/concepts/matestack/ui/core/samp/samp.haml +3 -3
  194. data/app/concepts/matestack/ui/core/samp/samp.rb +1 -0
  195. data/app/concepts/matestack/ui/core/section/section.haml +1 -1
  196. data/app/concepts/matestack/ui/core/section/section.rb +0 -1
  197. data/app/concepts/matestack/ui/core/slot/slot.rb +1 -2
  198. data/app/concepts/matestack/ui/core/small/small.haml +3 -3
  199. data/app/concepts/matestack/ui/core/small/small.rb +1 -1
  200. data/app/concepts/matestack/ui/core/span/span.haml +3 -3
  201. data/app/concepts/matestack/ui/core/span/span.rb +1 -1
  202. data/app/concepts/matestack/ui/core/strong/strong.haml +3 -3
  203. data/app/concepts/matestack/ui/core/strong/strong.rb +1 -1
  204. data/app/concepts/matestack/ui/core/sub/sub.haml +3 -3
  205. data/app/concepts/matestack/ui/core/sub/sub.rb +1 -1
  206. data/app/concepts/matestack/ui/core/summary/summary.haml +3 -3
  207. data/app/concepts/matestack/ui/core/summary/summary.rb +1 -1
  208. data/app/concepts/matestack/ui/core/sup/sup.haml +3 -3
  209. data/app/concepts/matestack/ui/core/sup/sup.rb +1 -1
  210. data/app/concepts/matestack/ui/core/table/table.haml +1 -1
  211. data/app/concepts/matestack/ui/core/table/table.rb +0 -1
  212. data/app/concepts/matestack/ui/core/tbody/tbody.haml +1 -1
  213. data/app/concepts/matestack/ui/core/tbody/tbody.rb +0 -1
  214. data/app/concepts/matestack/ui/core/td/td.haml +3 -3
  215. data/app/concepts/matestack/ui/core/td/td.rb +2 -1
  216. data/app/concepts/matestack/ui/core/template/template.haml +1 -1
  217. data/app/concepts/matestack/ui/core/textarea/textarea.haml +5 -0
  218. data/app/concepts/matestack/ui/core/textarea/textarea.rb +10 -0
  219. data/app/concepts/matestack/ui/core/tfoot/tfoot.haml +1 -1
  220. data/app/concepts/matestack/ui/core/tfoot/tfoot.rb +0 -1
  221. data/app/concepts/matestack/ui/core/th/th.haml +3 -3
  222. data/app/concepts/matestack/ui/core/th/th.rb +2 -1
  223. data/app/concepts/matestack/ui/core/thead/thead.haml +1 -1
  224. data/app/concepts/matestack/ui/core/thead/thead.rb +0 -1
  225. data/app/concepts/matestack/ui/core/time/time.haml +1 -1
  226. data/app/concepts/matestack/ui/core/time/time.rb +1 -7
  227. data/app/concepts/matestack/ui/core/toggle/toggle.haml +2 -0
  228. data/app/concepts/matestack/ui/core/toggle/toggle.js +71 -0
  229. data/app/concepts/matestack/ui/core/toggle/toggle.rb +13 -0
  230. data/app/concepts/matestack/ui/core/tr/tr.haml +1 -1
  231. data/app/concepts/matestack/ui/core/tr/tr.rb +0 -1
  232. data/app/concepts/matestack/ui/core/transition/transition.haml +3 -3
  233. data/app/concepts/matestack/ui/core/transition/transition.js +17 -1
  234. data/app/concepts/matestack/ui/core/transition/transition.rb +15 -8
  235. data/app/concepts/matestack/ui/core/u/u.haml +3 -3
  236. data/app/concepts/matestack/ui/core/u/u.rb +1 -1
  237. data/app/concepts/matestack/ui/core/ul/ul.haml +1 -1
  238. data/app/concepts/matestack/ui/core/ul/ul.rb +0 -1
  239. data/app/concepts/matestack/ui/core/unescaped/unescaped.rb +3 -1
  240. data/app/concepts/matestack/ui/core/var/var.haml +3 -3
  241. data/app/concepts/matestack/ui/core/var/var.rb +1 -0
  242. data/app/concepts/matestack/ui/core/video/video.haml +2 -2
  243. data/app/concepts/matestack/ui/core/video/video.rb +4 -14
  244. data/app/concepts/matestack/ui/core/view/view.haml +1 -0
  245. data/app/concepts/matestack/ui/core/view/view.rb +30 -0
  246. data/app/concepts/matestack/ui/core/wbr/wbr.haml +5 -1
  247. data/app/concepts/matestack/ui/core/wbr/wbr.rb +1 -0
  248. data/app/concepts/matestack/ui/core/youtube/youtube.haml +1 -1
  249. data/app/concepts/matestack/ui/core/youtube/youtube.rb +18 -16
  250. data/app/helpers/matestack/ui/core/application_helper.rb +94 -20
  251. data/app/lib/matestack/ui/component.rb +1 -0
  252. data/app/lib/matestack/ui/core/has_view_context.rb +4 -4
  253. data/app/lib/matestack/ui/core/html_attributes.rb +43 -0
  254. data/app/lib/matestack/ui/core/properties.rb +161 -0
  255. data/app/lib/matestack/ui/core/rendering/default_renderer_class_determiner.rb +33 -0
  256. data/app/lib/matestack/ui/core/rendering/main_renderer.rb +200 -0
  257. data/app/lib/matestack/ui/isolated_component.rb +1 -0
  258. data/app/lib/matestack/ui/vue_js_component.rb +1 -0
  259. data/lib/matestack/ui/core.rb +4 -2
  260. data/lib/matestack/ui/core/cell.rb +0 -2
  261. data/lib/matestack/ui/core/component/registry.rb +47 -0
  262. data/lib/matestack/ui/core/components.rb +269 -0
  263. data/lib/matestack/ui/core/dsl.rb +6 -0
  264. data/lib/matestack/ui/core/engine.rb +16 -0
  265. data/lib/matestack/ui/core/version.rb +1 -1
  266. data/vendor/assets/javascripts/dist/manifest.json +6 -10
  267. data/vendor/assets/javascripts/dist/matestack-ui-core.js +834 -261
  268. data/vendor/assets/javascripts/dist/matestack-ui-core.js.map +1 -1
  269. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js +1 -1
  270. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.br +0 -0
  271. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.gz +0 -0
  272. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map +1 -1
  273. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.br +0 -0
  274. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.gz +0 -0
  275. metadata +50 -65
  276. data/MIT-LICENSE +0 -20
  277. data/app/concepts/matestack/ui/core/absolute/absolute.haml +0 -3
  278. data/app/concepts/matestack/ui/core/absolute/absolute.rb +0 -17
  279. data/app/concepts/matestack/ui/core/collection/filter/input/input.haml +0 -2
  280. data/app/concepts/matestack/ui/core/component/response.haml +0 -2
  281. data/app/concepts/matestack/ui/core/component/response_dynamic.haml +0 -7
  282. data/app/concepts/matestack/ui/core/component/response_dynamic_without_rerender.haml +0 -3
  283. data/app/concepts/matestack/ui/core/component/static.haml +0 -1
  284. data/app/concepts/matestack/ui/core/form/inline/inline.haml +0 -6
  285. data/app/concepts/matestack/ui/core/form/inline/inline.rb +0 -9
  286. data/app/concepts/matestack/ui/core/form/input/input.haml +0 -38
  287. data/app/concepts/matestack/ui/core/html/html.haml +0 -3
  288. data/app/concepts/matestack/ui/core/html/html.js +0 -10
  289. data/app/concepts/matestack/ui/core/html/html.rb +0 -17
  290. data/app/concepts/matestack/ui/core/isolate/isolate.haml +0 -2
  291. data/app/concepts/matestack/ui/core/isolate/isolate.rb +0 -11
  292. data/app/concepts/matestack/ui/core/page/content.haml +0 -7
  293. data/app/concepts/matestack/ui/core/page/content.rb +0 -5
  294. data/app/concepts/matestack/ui/core/pg/pg.haml +0 -5
  295. data/app/concepts/matestack/ui/core/pg/pg.rb +0 -5
  296. data/app/lib/matestack/ui/core/app_node.rb +0 -53
  297. data/app/lib/matestack/ui/core/component_node.rb +0 -87
  298. data/app/lib/matestack/ui/core/page_node.rb +0 -100
  299. data/app/lib/matestack/ui/core/render.rb +0 -89
  300. data/app/lib/matestack/ui/core/to_cell.rb +0 -129
@@ -1,5 +1,5 @@
1
- %var{@tag_attributes}
2
- - if options[:text].nil? && block_given?
1
+ %var{ html_attributes }
2
+ - if text.nil? && block_given?
3
3
  = yield
4
4
  - else
5
- = options[:text]
5
+ = text
@@ -1,4 +1,5 @@
1
1
  module Matestack::Ui::Core::Var
2
2
  class Var < Matestack::Ui::Core::Component::Static
3
+ optional :text
3
4
  end
4
5
  end
@@ -1,3 +1,3 @@
1
- %video{@tag_attributes}
2
- %source{:src => @source, :type => @type}
1
+ %video{ html_attributes }
2
+ %source{ src: @source, type: @type}
3
3
  Your browser does not support the video tag.
@@ -1,22 +1,12 @@
1
1
  module Matestack::Ui::Core::Video
2
2
  class Video < Matestack::Ui::Core::Component::Static
3
+ html_attributes :autoplay, :controls, :height, :loop, :muted, :poster, :preload, :src, :width
3
4
 
4
- REQUIRED_KEYS = [:path, :type]
5
+ requires :path, :type
5
6
 
6
7
  def setup
7
- @tag_attributes.merge!({
8
- autoplay: options[:autoplay],
9
- controls: options[:controls],
10
- height: options[:height],
11
- loop: options[:loop],
12
- muted: options[:muted],
13
- playsinline: options[:playsinline],
14
- preload: options[:preload],
15
- width: options[:width]
16
- })
17
-
18
- @source = ActionController::Base.helpers.asset_path(options[:path])
19
- @type = "video/#{@options[:type]}"
8
+ @source = ActionController::Base.helpers.asset_path(path)
9
+ @type = "video/#{type}"
20
10
  end
21
11
 
22
12
  end
@@ -0,0 +1 @@
1
+ = include_partial
@@ -0,0 +1,30 @@
1
+ require_dependency "cell/partial"
2
+
3
+ module Matestack::Ui::Core::View
4
+ class View < Matestack::Ui::Core::Component::Static
5
+ include Cell::ViewModel::Partial
6
+ view_paths << "#{::Rails.root}/app/views"
7
+
8
+ # Only one option should be set at a time. If view is set partial will be ignored.
9
+ optional view: { as: :view_path } # Specify a view path to render
10
+ optional partial: { as: :partial_path } # Specifiy a partial to render
11
+
12
+ def include_partial
13
+ controller = @view_context.present? ? @view_context.controller : options[:matestack_context][:controller]
14
+ if view_path
15
+ controller.render_to_string view_path, layout: false, locals: locals
16
+ elsif partial_path
17
+ controller.render_to_string partial: partial_path, layout: false, locals: locals
18
+ else
19
+ raise 'view or partial param missing for RailsView Component'
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def locals
26
+ options.except(:matestack_context, :partial, :view, :partial_path, :view_path, :included_config, :context)
27
+ end
28
+
29
+ end
30
+ end
@@ -1 +1,5 @@
1
- %wbr{@tag_attributes}
1
+ %wbr{ html_attributes }
2
+ - if text.nil? && block_given?
3
+ = yield
4
+ - else
5
+ = text
@@ -1,4 +1,5 @@
1
1
  module Matestack::Ui::Core::Wbr
2
2
  class Wbr < Matestack::Ui::Core::Component::Static
3
+ optional :text
3
4
  end
4
5
  end
@@ -1 +1 @@
1
- %iframe{@tag_attributes}
1
+ %iframe{ youtube_attributes }
@@ -1,25 +1,27 @@
1
1
  module Matestack::Ui::Core::Youtube
2
2
  class Youtube < Matestack::Ui::Core::Component::Static
3
+ html_attributes :allow, :allowfullscreen, :allowpaymentrequest, :height, :name,
4
+ :referrerpolicy, :sandbox, :src, :srcdoc, :width
3
5
 
4
- REQUIRED_KEYS = [:yt_id, :height, :width]
6
+ requires :youtube_id
7
+ optional :privacy_mode, :no_controls, :start_at
5
8
 
6
9
  def setup
7
- url = 'https://www.youtube.com/embed/'
8
- url = 'https://www.youtube-nocookie.com/embed/' if options[:privacy_mode] == true
9
- url << options[:yt_id]
10
- url << '?' unless options[:no_controls] != true and options[:start_at].nil?
11
- url << 'controls=0' if options[:no_controls] == true
12
- url << '&amp;' if (options[:no_controls] != nil) and (options[:start_at] != nil)
13
- url << "start=#{options[:start_at]}" unless options[:start_at].nil?
10
+ url = privacy_mode ? 'https://www.youtube-nocookie.com/embed/' : 'https://www.youtube.com/embed/'
11
+ @uri = URI("#{url}#{youtube_id}")
12
+ @uri.query = {
13
+ controls: (no_controls ? 0 : 1),
14
+ start: start_at
15
+ }.to_query
16
+ end
14
17
 
15
- @tag_attributes.merge!({
16
- 'src': url,
17
- 'allow': 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture',
18
- 'allowfullscreen': '',
19
- 'frameborder': 0,
20
- 'height': options[:height],
21
- 'width': options[:width]
22
- })
18
+ def youtube_attributes
19
+ html_attributes.merge(
20
+ src: @uri.to_s,
21
+ allow: 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture',
22
+ allowfullscreen: '',
23
+ frameborder: 0,
24
+ )
23
25
  end
24
26
 
25
27
  end
@@ -1,36 +1,110 @@
1
1
  module Matestack
2
2
  module Ui
3
3
  module Core
4
+ # We're called ApplicationHelper but all we do so far is rendering.
4
5
  module ApplicationHelper
5
- include Matestack::Ui::Core::Render
6
-
7
- def render_page(page_class, only_page=false)
8
- page_class.new(nil, context: {
9
- params: params,
10
- request: request,
11
- view_context: view_context
12
- }, controller_instance: self).call(:show, nil, only_page)
6
+
7
+ # Allow the definition of a controller wide get_matestack_app_class
8
+ #
9
+ # class SomeController < ActionController::Base
10
+ # matestack_app MyAppClass
11
+ # #...
12
+ # end
13
+ #
14
+ def self.included(base)
15
+ base.extend(ClassMethods)
13
16
  end
14
17
 
15
- def render_component(page_class, component_key)
16
- page_class.new(nil, context: {
17
- params: params,
18
- request: request
19
- }, controller_instance: self).call(:show, component_key)
18
+ module ClassMethods
19
+ def matestack_app _class
20
+ @matestack_app_class = _class
21
+ end
22
+
23
+ def get_matestack_app_class
24
+ if defined?(@matestack_app_class)
25
+ @matestack_app_class
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
20
31
  end
21
32
 
22
- def responder_for(page_class, options = {})
23
- unless params[:component_key].blank?
24
- render plain: render_component(page_class, params[:component_key])
25
- return
33
+ # Matestack allows you to use `render` to render matestack pages.
34
+ #
35
+ # render Pages::Member::Bookings::Index
36
+ # render matestack: Pages::Member::Bookings::Index
37
+ #
38
+ def render(*args)
39
+ if (matestack_class = args.first).is_a?(Class) && (matestack_class < Matestack::Ui::Page)
40
+ options_hash = args[1].is_a?(Hash) ? args[1] : {}
41
+ Rendering::MainRenderer.render(self, matestack_class, options_hash)
42
+ elsif (options = args.first).is_a?(Hash) &&
43
+ (matestack_arg = options[:matestack]) &&
44
+ matestack_arg.is_a?(Class) &&
45
+ (matestack_arg < Matestack::Ui::Page)
46
+ Rendering::MainRenderer.render(self, matestack_arg, options)
47
+ else
48
+ if params[:component_class].present? && !((options = args.first).is_a?(Hash) && options[:html].present?)
49
+ Rendering::MainRenderer.render(self, Matestack::Ui::Page, {})
50
+ else
51
+ super
52
+ end
26
53
  end
27
- if params[:only_page]
28
- render html: render_page(page_class, true)
54
+ end
55
+
56
+ # TODO: maybe/Axe remove this?
57
+ # Matestack allows implicit rendering. The matestack page class name is inferred from the
58
+ # controller path and action name.
59
+ #
60
+ # class Clients::BookingsController < ApplicationController
61
+ # def index
62
+ # @bookings = Booking.all
63
+ # # looks for Pages::Clients::Bookings::Index
64
+ # end
65
+ #
66
+ # def show
67
+ # @booking = Booking.find params[:id]
68
+ # # looks for Pages::Clients::Bookings::Show
69
+ # end
70
+ # end
71
+ #
72
+ # In this example, `clients/bookings#index` will render `Pages::Clients::Bookings::Index`,
73
+ # `clients/bookings#show` will render `Pages::Clients::Bookings::Show`.
74
+ #
75
+ # Custom action names translate also into page names.
76
+ #
77
+ # class Clients::BookingsController < ApplicationController
78
+ # def step1
79
+ # # looks for Pages::Clients::Bookings::Step1
80
+ # end
81
+ # end
82
+ #
83
+ # In this example, the `clients/bookings#step1` action will render
84
+ # `Pages::Clients::Bookings::Step1`.
85
+ #
86
+ def default_render(*args)
87
+ matestack_page_class =
88
+ Rendering::DefaultRendererClassDeterminer.determine_class(controller_path, action_name)
89
+ if matestack_page_class
90
+ render matestack_page_class
29
91
  else
30
- render html: render_page(page_class), layout: true
92
+ super
31
93
  end
32
94
  end
33
95
 
96
+ # Kept around for compatibility. Probably worth removing.
97
+ def responder_for(*args)
98
+ render(*args)
99
+ end
100
+
101
+ def matestack_component(component, options = {}, &block)
102
+ controller = (self.class <= ActionController::Base) ? self : @_controller
103
+ context = (options[:matestack_context] ||= {}).merge(controller: controller)
104
+ Matestack::Ui::Core::Component::Base
105
+ .new(options.merge(matestack_context: context))
106
+ .send(component, options.merge(matestack_context: context), &block).to_s
107
+ end
34
108
  end
35
109
  end
36
110
  end
@@ -0,0 +1 @@
1
+ Matestack::Ui::Component = Matestack::Ui::Core::Component::Static
@@ -1,14 +1,14 @@
1
1
  module Matestack::Ui::Core::HasViewContext
2
- def initialize(model = nil, options = {})
3
- @view_context = options[:context][:view_context]
2
+ def initialize(*args)
4
3
  super
4
+ @view_context = @options.dig(:context, :view_context)
5
5
  end
6
6
 
7
7
  def method_missing(*args, &block)
8
8
  if @view_context.respond_to? args.first
9
9
  @view_context.send(*args, &block)
10
10
  else
11
- super
11
+ raise NameError, "NameError: undefined method or local variable `#{args.first}' for #{self.class.name}"
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -0,0 +1,43 @@
1
+ module Matestack::Ui::Core::HtmlAttributes
2
+
3
+ HTML_GLOBAL_ATTRIBUTES = [
4
+ :accesskey, :class, :contenteditable, :data, :dir, :draggable,
5
+ :hidden, :id, :lang, :spellcheck, :style, :tabindex, :title, :translate
6
+ ]
7
+
8
+ HTML_EVENT_ATTRIBUTES = [
9
+ :onafterprint, :onbeforeprint, :onbeforeunload, :onerror, :onhashchange, :onload, :onmessage,
10
+ :onoffline, :ononline, :onpagehide, :onpageshow, :onpopstate, :onresize, :onstorage, :onunload
11
+ ]
12
+
13
+ def self.included(base)
14
+ base.class_eval do
15
+ extend ClassMethods
16
+ end
17
+ end
18
+
19
+ module ClassMethods
20
+
21
+ def inherited(subclass)
22
+ super
23
+ subclass.html_attributes *self.allowed_html_attributes
24
+ end
25
+
26
+ def html_attributes(*attributes)
27
+ attributes.each do |attribute|
28
+ allowed_html_attributes.push(attribute)
29
+ end
30
+ end
31
+
32
+ def allowed_html_attributes
33
+ @allowed_html_attributes.flatten!&.uniq! if defined? @allowed_html_attributes
34
+ @allowed_html_attributes ||= []
35
+ end
36
+
37
+ end
38
+
39
+ def html_attributes
40
+ options.slice(*self.class.allowed_html_attributes).merge((options[:attributes] || {}))
41
+ end
42
+
43
+ end
@@ -0,0 +1,161 @@
1
+ module Matestack::Ui::Core::Properties
2
+
3
+ class PropertyMissingException < StandardError
4
+ end
5
+
6
+ class PropertyOverwritingExistingMethodException < StandardError
7
+ end
8
+
9
+ # prepend the initializer and add class methods
10
+ def self.included(base)
11
+ base.class_eval do
12
+ extend ClassMethods
13
+ end
14
+ base.send :prepend, Initializer
15
+ end
16
+
17
+ # initializer calls super and creates instance methods for defined required and optional properties afterwards
18
+ module Initializer
19
+ def initialize(model=nil, options={})
20
+ options = model.dup if options.empty? && model.is_a?(Hash)
21
+ # required_hooks(options)
22
+ # optional_hooks(options)
23
+ set_values(options) unless options[:skip_set_values]
24
+ super
25
+ end
26
+ end
27
+
28
+ module ClassMethods
29
+
30
+ def inherited(subclass)
31
+ super
32
+ # self.new(nil, skip_set_values: true)
33
+ subclass.property_keys *self.all_property_keys
34
+ subclass.all_required_properties.concat(self.all_required_properties)
35
+ subclass.created_properties.concat(self.created_properties)
36
+ end
37
+
38
+ # contains all property keys, or property hashes regardless of wheter they are optional or required
39
+ # used in order to initialize values of properties correctly for subclasses and make properties inheritable
40
+ def all_property_keys
41
+ @all_properties.flatten!&.uniq! if defined? @all_properties
42
+ @all_properties ||= []
43
+ end
44
+
45
+ def all_required_properties
46
+ @all_required_properties ||= []
47
+ end
48
+
49
+ def created_properties
50
+ @created_properties ||= []
51
+ end
52
+
53
+ # add property keys to array containing all property keys
54
+ def property_keys(*attributes)
55
+ attributes.each do |attribute|
56
+ if attribute.is_a?(Hash)
57
+ attribute.each do |temp|
58
+ all_property_keys.push({ "#{temp.first}": temp.last})
59
+ end
60
+ else
61
+ all_property_keys.push(attribute)
62
+ end
63
+ end
64
+ end
65
+
66
+ # define optinoal properties for custom components with `optional :foo, :bar`
67
+ def optional(*properties)
68
+ property_keys *properties
69
+ add_properties_to_list(optional_properties, properties)
70
+ optional_hooks
71
+ end
72
+
73
+ # define required properties for custom components with `requires :title, :foo, :bar`
74
+ def requires(*properties)
75
+ property_keys *properties
76
+ add_properties_to_list(requires_properties, properties)
77
+ required_hooks
78
+ end
79
+
80
+ def add_properties_to_list(list, properties)
81
+ properties.each do |property|
82
+ if property.is_a? Hash
83
+ property.each { |tmp_property| list.push(tmp_property) }
84
+ else
85
+ list.push(property)
86
+ end
87
+ end
88
+ end
89
+
90
+ # array of properties created from the component
91
+ def optional_properties
92
+ @optional_properties ||= []
93
+ end
94
+
95
+ # array of required properties from the component
96
+ def requires_properties
97
+ @requires_properties ||= []
98
+ end
99
+
100
+ def optional_hooks
101
+ self.optional_properties.compact.each do |prop|
102
+ prop = extract_property_key({}, prop)
103
+ define_getter_and_setter_for_property(prop)
104
+ end
105
+ end
106
+
107
+ def required_hooks
108
+ self.requires_properties.compact.each do |prop|
109
+ prop = extract_property_key({}, prop)
110
+ self.all_required_properties.push(prop).uniq!
111
+ define_getter_and_setter_for_property(prop)
112
+ end
113
+ end
114
+
115
+ def extract_property_key(options, prop)
116
+ if prop.is_a?(Array) || prop.is_a?(Hash)
117
+ hash = prop.flatten
118
+ prop = hash.last[:as]
119
+ end
120
+ prop
121
+ end
122
+
123
+ def define_getter_and_setter_for_property(prop)
124
+ self.created_properties.push(prop)
125
+ self.send(:define_method, prop) do
126
+ self.instance_variable_get(:"@#{prop}")
127
+ end
128
+ self.send(:define_method, :"#{prop}=") do |value|
129
+ self.instance_variable_set(:"@#{prop}", value)
130
+ end
131
+ end
132
+
133
+ def method_added(name)
134
+ if all_property_keys.include?(name) && !created_properties.include?(name)
135
+ raise PropertyOverwritingExistingMethodException, "Property \"#{name}\" would overwrite already defined instance method for #{self}"
136
+ end
137
+ end
138
+ end
139
+
140
+ def set_values(options)
141
+ self.class.all_property_keys.compact.each do |prop|
142
+ value_key = prop
143
+ prop = extract_property_key(options, prop)
144
+ if self.class.all_required_properties.include?(prop) && options[prop].nil?
145
+ raise PropertyMissingException, "Required property #{prop} is missing for #{self.class}"
146
+ end
147
+ send(:"#{prop}=", options[prop])
148
+ end
149
+ end
150
+
151
+ # returns property key and sets alias if hash with as option is given
152
+ def extract_property_key(options, prop)
153
+ if prop.is_a?(Array) || prop.is_a?(Hash)
154
+ hash = prop.flatten
155
+ options[hash.last[:as]] = options[hash.first]
156
+ prop = hash.last[:as]
157
+ end
158
+ prop
159
+ end
160
+
161
+ end