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,24 +1,27 @@
1
1
  module Matestack::Ui::Core::Collection::Filter::Input
2
2
  class Input < Matestack::Ui::Core::Component::Static
3
+ include Matestack::Ui::Core::Form::HasInputHtmlAttributes
3
4
 
4
- def setup
5
- @tag_attributes.merge!({
6
- "v-model#{'.number' if options[:type] == :number}": input_key,
7
- type: options[:type],
8
- class: options[:class],
5
+ requires :key, :type
6
+ optional :placeholder, class: { as: :klass }
7
+
8
+ def response
9
+ input html_attributes.merge(attributes: {
10
+ "v-model#{'.number' if type == :number}": input_key,
11
+ type: type,
9
12
  id: component_id,
10
13
  "@keyup.enter": "submitFilter()",
11
14
  ref: "filter.#{attr_key}",
12
- placeholder: options[:placeholder]
15
+ placeholder: placeholder
13
16
  })
14
17
  end
15
18
 
16
19
  def input_key
17
- 'filter["' + options[:key].to_s + '"]'
20
+ 'filter["' + key.to_s + '"]'
18
21
  end
19
22
 
20
23
  def attr_key
21
- return options[:key].to_s
24
+ key.to_s
22
25
  end
23
26
 
24
27
  end
@@ -1,3 +1,3 @@
1
- %a{@tag_attributes, "@click": "resetFilter()"}
1
+ %a{ html_attributes , "@click": "resetFilter()"}
2
2
  - if block_given?
3
3
  = yield
@@ -0,0 +1,10 @@
1
+ - if options[:type] == :dropdown
2
+
3
+ %select{ select_attributes }
4
+ %option{disabled: true}= placeholder
5
+ - if select_options.is_a?(Hash)
6
+ - select_options.each do |key, value|
7
+ %option{value: key}=value
8
+ - if select_options.is_a?(Array)
9
+ - select_options.each do |option|
10
+ %option{value: option}=option
@@ -0,0 +1,30 @@
1
+ module Matestack::Ui::Core::Collection::Filter::Select
2
+ class Select < Matestack::Ui::Core::Component::Static
3
+
4
+ requires :key
5
+ optional :placeholder, options: { as: :select_options }
6
+
7
+ def setup
8
+ if options[:type].nil?
9
+ options[:type] = :dropdown #nothing else supported at the moment
10
+ end
11
+ end
12
+
13
+ def select_attributes
14
+ html_attributes.merge!({
15
+ "v-model#{'.number' if options[:type] == :number}": input_key,
16
+ type: options[:type],
17
+ id: component_id,
18
+ "@keyup.enter": "submitFilter()",
19
+ "@change": "$forceUpdate()",
20
+ ref: "filter.#{key.to_s}",
21
+ placeholder: placeholder
22
+ })
23
+ end
24
+
25
+ def input_key
26
+ 'filter["' + key.to_s + '"]'
27
+ end
28
+
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
- %a{@tag_attributes, "@click": "submitFilter()"}
1
+ %a{ html_attributes, "@click": "submitFilter()" }
2
2
  - if block_given?
3
3
  = yield
@@ -1,6 +1,6 @@
1
1
  module Matestack::Ui::Core::Collection
2
2
 
3
- CollectionConfig = Struct.new(:id, :init_offset, :init_limit, :filtered_count, :base_count, :data, :context) do
3
+ CollectionConfig = Struct.new(:id, :init_offset, :init_limit, :filtered_count, :base_count, :data, :params) do
4
4
 
5
5
  def paginated_data
6
6
  resulting_data = data
@@ -11,11 +11,11 @@ module Matestack::Ui::Core::Collection
11
11
  end
12
12
 
13
13
  def get_collection_offset
14
- (context[:params]["#{id}-offset".to_sym] ||= init_offset).to_i
14
+ (params["#{id}-offset".to_sym] ||= init_offset).to_i
15
15
  end
16
16
 
17
17
  def get_collection_limit
18
- (context[:params]["#{id}-limit".to_sym] ||= init_limit).to_i
18
+ (params["#{id}-limit".to_sym] ||= init_limit).to_i
19
19
  end
20
20
 
21
21
  def pages
@@ -63,7 +63,7 @@ module Matestack::Ui::Core::Collection
63
63
 
64
64
  def get_collection_filter collection_id, key=nil
65
65
  filter_hash = {}
66
- context[:params].each do |param_key, param_value|
66
+ controller_params.each do |param_key, param_value|
67
67
  if param_key.start_with?("#{collection_id}-filter-")
68
68
  param_key.gsub("#{collection_id}-filter-", "")
69
69
  filter_hash[param_key.gsub("#{collection_id}-filter-", "").to_sym] = param_value
@@ -78,7 +78,7 @@ module Matestack::Ui::Core::Collection
78
78
 
79
79
  def get_collection_order collection_id, key=nil
80
80
  order_hash = {}
81
- context[:params].each do |param_key, param_value|
81
+ controller_params.each do |param_key, param_value|
82
82
  if param_key.start_with?("#{collection_id}-order-")
83
83
  param_key.gsub("#{collection_id}-order-", "")
84
84
  order_hash[param_key.gsub("#{collection_id}-order-", "").to_sym] = param_value
@@ -101,7 +101,7 @@ module Matestack::Ui::Core::Collection
101
101
  filtered_count,
102
102
  base_count,
103
103
  data,
104
- context
104
+ controller_params,
105
105
  )
106
106
 
107
107
  @collections[id.to_sym] = collection_config
@@ -109,5 +109,13 @@ module Matestack::Ui::Core::Collection
109
109
  return collection_config
110
110
  end
111
111
 
112
+ # try to get params from either controller params, when called in a rails legacy view or
113
+ # from cells context when called in a matestack app/page/component
114
+ def controller_params
115
+ return context[:params] if defined? context
116
+ return params.to_unsafe_h if defined? params
117
+ raise 'collection component is missing access to params or context'
118
+ end
119
+
112
120
  end
113
121
  end
@@ -16,7 +16,7 @@ const componentDef = {
16
16
  this.ordering[key] = "asc"
17
17
  } else if (this.ordering[key] == "asc") {
18
18
  this.ordering[key] = "desc"
19
- } else if (this.ordering[key] = "desc") {
19
+ } else if (this.ordering[key] == "desc") {
20
20
  this.ordering[key] = undefined
21
21
  }
22
22
  var url;
@@ -1,16 +1,15 @@
1
1
  module Matestack::Ui::Core::Collection::Order
2
2
  class Order < Matestack::Ui::Core::Component::Dynamic
3
+ vue_js_component_name 'matestack-ui-core-collection-order'
3
4
 
4
5
  def setup
5
6
  @component_config = @component_config.except(:data, :paginated_data)
6
7
  end
7
8
 
8
9
  def response
9
- components {
10
- div @tag_attributes do
11
- yield_components
12
- end
13
- }
10
+ div html_attributes do
11
+ yield_components
12
+ end
14
13
  end
15
14
 
16
15
  end
@@ -2,11 +2,15 @@ module Matestack::Ui::Core::Collection::Order::Toggle::Indicator
2
2
  class Indicator < Matestack::Ui::Core::Component::Static
3
3
 
4
4
  def response
5
- components {
6
- span @tag_attributes do
7
- plain "{{orderIndicator( '#{@component_config[:key]}', {asc: '#{@component_config[:asc]}', desc: '#{@component_config[:desc]}'} ) }}"
8
- end
9
- }
5
+ span html_attributes do
6
+ span attributes: {"v-if": "ordering['#{@component_config[:key]}'] === undefined"}, text: @component_config[:default]
7
+ unescaped "{{
8
+ orderIndicator(
9
+ '#{@component_config[:key]}',
10
+ { asc: '#{@component_config[:asc]}', desc: '#{@component_config[:desc]}'}
11
+ )
12
+ }}"
13
+ end
10
14
  end
11
15
 
12
16
  end
@@ -1,3 +1,3 @@
1
- %a{@tag_attributes, "@click": "toggleOrder(\"#{@component_config[:key]}\")"}
1
+ %a{ html_attributes, "@click": "toggleOrder(\"#{@component_config[:key]}\")" }
2
2
  - if block_given?
3
3
  = yield
@@ -1,5 +1,4 @@
1
1
  module Matestack::Ui::Core::Collection::Order::Toggle
2
2
  class Toggle < Matestack::Ui::Core::Component::Static
3
-
4
3
  end
5
4
  end
@@ -0,0 +1,430 @@
1
+ module Matestack::Ui::Core::Component
2
+ class Base < Trailblazer::Cell
3
+ include Matestack::Ui::Core::Cell
4
+ include Matestack::Ui::Core::HasViewContext
5
+ include Matestack::Ui::Core::HtmlAttributes
6
+ include Matestack::Ui::Core::Properties
7
+ include Matestack::Ui::Core::DSL
8
+
9
+ # define html global attributes
10
+ html_attributes *HTML_GLOBAL_ATTRIBUTES, *HTML_EVENT_ATTRIBUTES
11
+
12
+
13
+ view_paths << "#{Matestack::Ui::Core::Engine.root}/app/concepts"
14
+ view_paths << "#{::Rails.root}#{'/' unless ::Rails.root.nil?}app/matestack"
15
+
16
+ extend ViewName::Flat
17
+
18
+ attr_reader :children, :yield_components_to, :argument, :options
19
+
20
+ # TODO: Seems the `context` method is defined in Cells, would be
21
+ # easy to move up - question really is how much of cells we're still using?
22
+ def initialize(model = nil, options = {})
23
+ # @model also exists with the same content? Is there any reason we wouldn't
24
+ # wanna use it instead of @argument? There's even a `model` accessor for it
25
+ # TODO
26
+ @argument = model
27
+ @options = options
28
+
29
+ # TODO works around a semantic where if just a hash is passed apparently
30
+ # those are the options
31
+ @options = model.dup if @options.empty? && model.is_a?(Hash)
32
+
33
+ super(model, @options)
34
+ # DSL-relevant
35
+ @children = []
36
+ @current_parent_context = self
37
+ # remember where we need to insert components on yield_components_for usage
38
+ @yield_components_to = nil
39
+
40
+ # TODO: everything beyond this point is probably not needed for the
41
+ # Page subclass
42
+
43
+ # TODO: potentially only used in form like components
44
+ # Suggestion: Introduce a new super class to remove this complexity
45
+ # from the base class.
46
+ @included_config = @options[:included_config]
47
+ # p self.class.name
48
+ # p @included_config
49
+
50
+ # TODO seemingly never accessed? (at least by us)
51
+ # but probably good to expose to have access to current_user & friends
52
+ # #context is defined in `Cell::ViewModel`
53
+ # and it just grabs @options[:context]
54
+ @controller_context = context&.fetch(:controller_context, nil)
55
+
56
+ # Add matestack context, containing controller etc.
57
+ @matestack_context = options.dig(:matestack_context)
58
+
59
+ # TODO: technically only relevant for Dynamic, however it relies on
60
+ # @options being set but must be set before `setup` is called.
61
+ # As both happen in this controller it isn't possible to squeeze
62
+ # it inbetween the super calls in the Dynamic super class.
63
+ #
64
+ # This is the configuration for the VueJS component
65
+ @component_config = @options.except(:context, :children, :url_params, :included_config, :matestack_context, :slots)
66
+
67
+ # TODO: no idea why this is called `url_params` it contains
68
+ # much more than this e.g. almost all params so maybe rename it?
69
+ # will be deprecated in future releases. use the `params` method in order to access query params
70
+ @url_params = context&.[](:params)&.except(:action, :controller, :component_key, :matestack_context)
71
+
72
+ # used when creating the child component tree
73
+ # if true, the block of an async component with a defer value will not be processed
74
+ # this saves serverside computation time on initial page requests where some components
75
+ # should only be resolved in a subsequent component rendering call
76
+ # whithin this subsequent component rendering call, the value is set to false via
77
+ # matestack_set_skip_defer(false)
78
+ @matestack_skip_defer = true
79
+
80
+ # TODO: do we realy have to call this every time on initialize or should
81
+ # it maybe be called more dynamically like its dynamic_tag_attributes
82
+ # equivalent in Dynamic?
83
+ set_tag_attributes
84
+ setup
85
+ validate_options
86
+ end
87
+
88
+ # whithin subsequent component rendering calls, the value is set to false in order to render
89
+ # the content of deferred components
90
+ def matestack_set_skip_defer bool
91
+ @matestack_skip_defer = bool
92
+ end
93
+
94
+ def set_included_config config
95
+ @included_config = config
96
+ end
97
+
98
+ def get_included_config
99
+ @included_config
100
+ end
101
+ alias :included_config :get_included_config
102
+
103
+ def component_config
104
+ @component_config
105
+ end
106
+
107
+ # TODO: modifies/recreates view lookup paths on every invocation?!
108
+ # At least memoize it I guess...
109
+ # better even maybe/probably give a component an (automatic) way to know
110
+ # exactly where its template is probably based on its own file location.
111
+ # Then no lookup/search has to happen.
112
+ def self.prefixes
113
+ _prefixes = super
114
+ modified_prefixes = _prefixes.map do |prefix|
115
+ prefix_parts = prefix.split("/")
116
+ if prefix_parts.last.include?(self.name.split("::")[-1].underscore)
117
+ prefix_parts[0..-2].join("/") + '/'
118
+ else
119
+ prefix
120
+ end
121
+ end
122
+ return modified_prefixes + _prefixes
123
+ end
124
+
125
+ def self.views_dir
126
+ return ""
127
+ end
128
+
129
+ # Special validation logic
130
+ def validate_options
131
+ if defined? self.class::REQUIRED_KEYS
132
+ ActiveSupport::Deprecation.warn("REQUIRED_KEYS is deprecated. Use `require :foo` instead.")
133
+ self.class::REQUIRED_KEYS.each do |key|
134
+ raise "#{self.class.name}: required key '#{key}' is missing" if options[key].nil?
135
+ end
136
+ end
137
+ custom_options_validation
138
+ end
139
+
140
+ def custom_options_validation
141
+ true
142
+ end
143
+
144
+ # custom component setup that doesn't seem to be documented
145
+ # but lots of components use it
146
+ def setup
147
+ true
148
+ end
149
+
150
+ # Setup meant to be overridden to setup data from DB or what not
151
+ # why not just call these functions at the beginning of whatever
152
+ # we'll call the method like:
153
+ #
154
+ # def respone
155
+ # result = i_call_stuff
156
+ # plain result
157
+ # end
158
+ #
159
+ # Seems like it might be more complicated? Not sure probably missing something.
160
+ def prepare
161
+ true
162
+ end
163
+
164
+ # access params like you would do on rails views and controllers
165
+ def params
166
+ if @matestack_context.present? && @matestack_context[:controller].present?
167
+ @matestack_context[:controller].params
168
+ elsif context.present? && context[:params]
169
+ context[:params]
170
+ else
171
+ ActionController::Parameters.new({})
172
+ end
173
+ end
174
+
175
+ ## ------------------ Rendering ----------------
176
+ # Invoked by Cell::ViewModel from Rendering#call
177
+ #
178
+ def show
179
+ raise "subclass responsibility"
180
+ end
181
+
182
+ def to_html
183
+ show
184
+ end
185
+
186
+ def render_content
187
+ # When/if we implement response then our display purely relies on that
188
+ # of our children
189
+ # TODO: this might be another sub class or module for the difference
190
+ # Like Native Component vs. composed component? Unsure. Might also not be worth it.
191
+ if respond_to? :response
192
+ render :children
193
+ else
194
+ # We got a template render it around our children
195
+ render do
196
+ render :children
197
+ end
198
+ end
199
+ end
200
+
201
+ def component_id
202
+ options[:id] ||= nil
203
+ end
204
+
205
+ def js_action name, arguments
206
+ argumentString = arguments.join('", "')
207
+ argumentString = '"' + argumentString + '"'
208
+ [name, '(', argumentString, ')'].join("")
209
+ end
210
+
211
+ def navigate_to path
212
+ js_action("navigateTo", [path])
213
+ end
214
+
215
+ def get_children
216
+ return options[:children]
217
+ end
218
+
219
+ ## ---------------------- DSL ------------------------------
220
+ # Add a new child when building the component tree.
221
+ #
222
+ # Invoked in 2 ways
223
+ # * directly ass add_child class, args, block
224
+ # * as defined by the DSL methods in `Matestack::Ui::Core::Component::Registry`
225
+ # which does the same but allows the nicer DSL methods on top of it
226
+ #
227
+ # add_child only builds up the whole ruby component structure. Rendering is done
228
+ # in a later step by calling `#show` on the component where you want to start
229
+ # rendering.
230
+ def add_child(child_class, *args, &block)
231
+
232
+ # when the child is an async or isolate component like shown below, only render its wrapper
233
+ # and skip its content on normal page rendering call indicated by @matestack_skip_defer == true
234
+ # Example: async defer: 1000 { plain "I should be deferred" }
235
+ # the component will triger a subsequent component rendering call after 1000ms
236
+ # the main renderer will then set @matestack_skip_defer to false which allows processing
237
+ # the childs content in order to respond to the subsequent component rendering call with
238
+ # the childs content. In this case: "I should be deferred"
239
+ skip_deferred_child_response = false
240
+ if child_class <= Matestack::Ui::Core::Async::Async || child_class < Matestack::Ui::Core::Isolated::Isolated
241
+ if args.any? { |arg| arg[:defer].present? } && @matestack_skip_defer == true
242
+ skip_deferred_child_response = true
243
+ end
244
+ end
245
+
246
+ # check only allowed keys are passed to isolated components
247
+ if child_class < Matestack::Ui::Core::Isolated::Isolated
248
+ unless args.empty? || args[0].keys.all? { |key| [:defer, :public_options, :rerender_on, :init_on, :rerender_delay, :matestack_context].include? key }
249
+ raise "isolated components can only take params in a public_options hash, which will be exposed to the client side in order to perform an async request with these params."
250
+ end
251
+ if args.any? { |arg| arg[:init_on].present? } && @matestack_skip_defer == true
252
+ skip_deferred_child_response = true
253
+ end
254
+ end
255
+
256
+ if self.class < Matestack::Ui::Core::Isolated::Isolated
257
+ parent_context_included_config = @current_parent_context.get_included_config || {}
258
+ parent_context_included_config.merge!({ isolated_parent_class: self.class.name })
259
+ args_with_context = add_context_to_options(args,parent_context_included_config)
260
+ else
261
+ args_with_context = add_context_to_options(args, @current_parent_context.get_included_config)
262
+ end
263
+
264
+ child = child_class.new(*args_with_context)
265
+
266
+ # set the current @matestack_skip_defer state on the child instance
267
+ # otherwise nested deferred components would never be rendered as
268
+ # @matestack_skip_defer is true by default
269
+ child.matestack_set_skip_defer(@matestack_skip_defer)
270
+
271
+ @current_parent_context.children << child
272
+
273
+ # skip childs body if it should be deferred
274
+ # only the wrapping structure is rendered in this case
275
+ unless skip_deferred_child_response
276
+ child.prepare
277
+ child.response if child.respond_to?(:response)
278
+
279
+ if child_class == Matestack::Ui::Core::Form::Form
280
+ included_config = args.select { |arg| arg.is_a?(Hash) ? arg[:for] : nil }[0]
281
+ end
282
+ execute_child_block(child, included_config, block) if block
283
+ end
284
+
285
+ child
286
+ end
287
+
288
+ # compatibility layer to old-school (not needed anymore)
289
+ def components(&block)
290
+ instance_eval &block
291
+ end
292
+
293
+ # TODO: partial is weird, I highly recommend removing it
294
+ # it exists in basically 2 forms, one that is basically `send`
295
+ # the other just executes the block it's given.
296
+ # Same thing can now be achieved through simple method calls
297
+ def partial(*args)
298
+ if block_given?
299
+ yield
300
+ else
301
+ send(*args)
302
+ end
303
+ end
304
+
305
+ # slot allows generating content in one component and passing it to another
306
+ #
307
+ # It's a 2 purpose method (might be redone):
308
+ # * with a block creates the children to be inserted
309
+ # * without a block it inserts the children at the current point
310
+ #
311
+ #
312
+ def slot(slot_content = [], &block)
313
+ if block_given?
314
+ create_slot_children_to_be_inserted(block)
315
+ else
316
+ # at this point the children are completely built, we just need
317
+ # to insert them into the tree at the right spot (which is marked
318
+ # by where we are currently called hence @current_parent_context)
319
+ @current_parent_context.children.concat(slot_content)
320
+ end
321
+ end
322
+
323
+ # TODO the implementation is simple, but reasoning about is quite
324
+ # complex imo. The main reason is that `yield_components` has no
325
+ # access to the block. Of course that could be solved by making
326
+ # it an instance variable. Might be nicer if we could do
327
+ # `def response(&block)`
328
+ # Also:
329
+ # * right now only works with one yield_components, would break with
330
+ # two that might be nice to raise/warn about
331
+ #
332
+ # The biggest trick this pulls is in execte_child_block where the
333
+ # parent context is shifted to whatever this points to, so that it's
334
+ # inserted at the right point.
335
+ def yield_components
336
+ @yield_components_to = @current_parent_context
337
+ end
338
+
339
+ private
340
+
341
+ # This should be simpler, all it does is try to figure out where the hash/option
342
+ # argument goes and put context in it
343
+ # Partially caused by the behavior that we have 2 initialize args and it's unclear
344
+ # which one should be an options hash as both `plain "hello"` and `div id: "lala"`
345
+ # should work currently
346
+ def add_context_to_options(args, included_config=nil)
347
+ case args.size
348
+ when 0 then [
349
+ {
350
+ context: context,
351
+ included_config: included_config,
352
+ }
353
+ ]
354
+ when 1 then
355
+ arg = args.first
356
+ if arg.is_a?(Hash)
357
+ arg[:context] = context
358
+ arg[:included_config] = included_config
359
+ arg[:matestack_context] = @matestack_context
360
+ [arg]
361
+ else
362
+ [arg, {context: context, included_config: included_config, matestack_context: @matestack_context}]
363
+ end
364
+ when 2 then
365
+ if args[1] == :include
366
+ if args.first.is_a?(Hash)
367
+ args.first[:context] = context
368
+ args.first[:included_config] = included_config
369
+ args.first[:matestack_context] = @matestack_context
370
+ [args.first]
371
+ end
372
+ else
373
+ args[1][:context] = context
374
+ args[1][:included_config] = included_config
375
+ args[1][:matestack_context] = @matestack_context
376
+ [args.first, args[1]]
377
+ end
378
+ else
379
+ raise "too many child arguments what are you doing?"
380
+ end
381
+ end
382
+
383
+ def execute_child_block(child, included_config=nil, block)
384
+ previous_parent_context = @current_parent_context
385
+ begin
386
+ @current_parent_context = child.yield_components_to || child
387
+ @current_parent_context.set_included_config(included_config) if included_config.present?
388
+ instance_eval(&block)
389
+ ensure
390
+ @current_parent_context = previous_parent_context
391
+ end
392
+ end
393
+
394
+ def create_slot_children_to_be_inserted(block)
395
+ # Basically works through:
396
+ # 1. create a fake parent (execution_parent_proxy)
397
+ # 2. set it as the current parrent
398
+ # 3. evaluate the block in the context in which it was defined
399
+ # to have access to methods/instance variables
400
+ # 4. make sure parent context is the previous one again
401
+ # 5. return the children we added to our "fake parent" so
402
+ # that they can be inserted wherever again
403
+ execution_parent_proxy = Base.new()
404
+ previous_parent_context = @current_parent_context
405
+ @current_parent_context = execution_parent_proxy
406
+
407
+ begin
408
+ instance_eval(&block)
409
+ ensure
410
+ @current_parent_context = previous_parent_context
411
+ end
412
+
413
+ execution_parent_proxy.children
414
+ end
415
+
416
+ ## ------------------------ Also Rendering ---------------------
417
+ # common attribute handling for tags/components
418
+ def set_tag_attributes
419
+ default_attributes = {
420
+ id: component_id,
421
+ class: options[:class]
422
+ }
423
+ unless options[:attributes].nil?
424
+ default_attributes.merge!(options[:attributes])
425
+ end
426
+
427
+ @tag_attributes = default_attributes
428
+ end
429
+ end
430
+ end