matestack-ui-core 0.7.3 → 0.7.4

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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -4
  3. data/Rakefile +32 -0
  4. data/app/concepts/matestack/ui/core/action/action.js +51 -29
  5. data/app/concepts/matestack/ui/core/action/action.rb +3 -0
  6. data/app/concepts/matestack/ui/core/app/app.js +7 -4
  7. data/app/concepts/matestack/ui/core/app/app.rb +1 -1
  8. data/app/concepts/matestack/ui/core/app/location.js +10 -0
  9. data/app/concepts/matestack/ui/core/app/store.js +1 -1
  10. data/app/concepts/matestack/ui/core/async/async.js +2 -2
  11. data/app/concepts/matestack/ui/core/bdi/bdi.haml +5 -0
  12. data/app/concepts/matestack/ui/core/bdi/bdi.rb +4 -0
  13. data/app/concepts/matestack/ui/core/bdo/bdo.haml +5 -0
  14. data/app/concepts/matestack/ui/core/bdo/bdo.rb +11 -0
  15. data/app/concepts/matestack/ui/core/collection/content/content.js +4 -4
  16. data/app/concepts/matestack/ui/core/collection/filter/filter.js +3 -3
  17. data/app/concepts/matestack/ui/core/collection/order/order.js +3 -3
  18. data/app/concepts/matestack/ui/core/component/anonym-dynamic-component.js +1 -1
  19. data/app/concepts/matestack/ui/core/component/component.js +1 -1
  20. data/app/concepts/matestack/ui/core/component/dynamic.rb +2 -2
  21. data/app/concepts/matestack/ui/core/data/data.haml +5 -0
  22. data/app/concepts/matestack/ui/core/data/data.rb +9 -0
  23. data/app/concepts/matestack/ui/core/del/del.haml +5 -0
  24. data/app/concepts/matestack/ui/core/del/del.rb +4 -0
  25. data/app/concepts/matestack/ui/core/dfn/dfn.haml +5 -0
  26. data/app/concepts/matestack/ui/core/dfn/dfn.rb +6 -0
  27. data/app/concepts/matestack/ui/core/dialog/dialog.haml +5 -0
  28. data/app/concepts/matestack/ui/core/dialog/dialog.rb +9 -0
  29. data/app/concepts/matestack/ui/core/form/form.js +23 -5
  30. data/app/concepts/matestack/ui/core/html/html.js +1 -1
  31. data/app/concepts/matestack/ui/core/iframe/iframe.haml +5 -0
  32. data/app/concepts/matestack/ui/core/iframe/iframe.rb +14 -0
  33. data/app/concepts/matestack/ui/core/js/core.js +15 -14
  34. data/app/concepts/matestack/ui/core/onclick/onclick.js +2 -3
  35. data/app/concepts/matestack/ui/core/optgroup/optgroup.haml +3 -0
  36. data/app/concepts/matestack/ui/core/optgroup/optgroup.rb +10 -0
  37. data/app/concepts/matestack/ui/core/option/option.haml +5 -0
  38. data/app/concepts/matestack/ui/core/option/option.rb +12 -0
  39. data/app/concepts/matestack/ui/core/page/content.js +1 -1
  40. data/app/concepts/matestack/ui/core/page/page.rb +3 -2
  41. data/app/concepts/matestack/ui/core/picture/picture.haml +3 -0
  42. data/app/concepts/matestack/ui/core/picture/picture.rb +4 -0
  43. data/app/concepts/matestack/ui/core/plain/plain.rb +1 -1
  44. data/app/concepts/matestack/ui/core/samp/samp.haml +5 -0
  45. data/app/concepts/matestack/ui/core/samp/samp.rb +4 -0
  46. data/app/concepts/matestack/ui/core/template/template.haml +3 -0
  47. data/app/concepts/matestack/ui/core/template/template.rb +4 -0
  48. data/app/concepts/matestack/ui/core/transition/transition.js +1 -1
  49. data/app/concepts/matestack/ui/core/u/u.haml +5 -0
  50. data/app/concepts/matestack/ui/core/u/u.rb +6 -0
  51. data/app/concepts/matestack/ui/core/unescaped/unescaped.rb +7 -0
  52. data/app/concepts/matestack/ui/core/wbr/wbr.haml +1 -0
  53. data/app/concepts/matestack/ui/core/wbr/wbr.rb +4 -0
  54. data/app/helpers/matestack/ui/core/application_helper.rb +3 -1
  55. data/app/javascript/matestack-ui-core/index.js +22 -0
  56. data/app/javascript/matestack-ui-core/styles/index.scss +5 -0
  57. data/app/javascript/packs/matestack-ui-core.js +8 -0
  58. data/app/lib/matestack/ui/core/component_node.rb +24 -10
  59. data/app/lib/matestack/ui/core/has_view_context.rb +10 -0
  60. data/app/lib/matestack/ui/core/page_node.rb +5 -1
  61. data/app/lib/matestack/ui/core/render.rb +89 -0
  62. data/lib/generators/matestack/core/component/templates/docs/components/%file_name%.md.tt +1 -0
  63. data/lib/generators/matestack/page/templates/app/matestack/pages/%app_name%/%namespace%/%file_name%.rb.tt +2 -1
  64. data/lib/matestack/ui/core.rb +1 -0
  65. data/lib/matestack/ui/core/cell.rb +33 -0
  66. data/lib/matestack/ui/core/version.rb +1 -1
  67. data/vendor/assets/javascripts/dist/manifest.json +18 -0
  68. data/vendor/assets/javascripts/dist/manifest.json.br +0 -0
  69. data/vendor/assets/javascripts/dist/manifest.json.gz +0 -0
  70. data/vendor/assets/javascripts/dist/matestack-ui-core.css +3 -0
  71. data/vendor/assets/javascripts/dist/matestack-ui-core.css.map +1 -0
  72. data/vendor/assets/javascripts/{matestack-ui-core.js → dist/matestack-ui-core.js} +11041 -10808
  73. data/vendor/assets/javascripts/dist/matestack-ui-core.js.map +1 -0
  74. data/vendor/assets/javascripts/dist/matestack-ui-core.min.css +0 -0
  75. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js +3 -0
  76. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.LICENSE.txt +18 -0
  77. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.br +0 -0
  78. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.gz +0 -0
  79. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map +1 -0
  80. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.br +0 -0
  81. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.gz +0 -0
  82. data/vendor/assets/javascripts/matestack-ui-core.js.erb +2 -0
  83. data/vendor/assets/stylesheets/dist +1 -0
  84. data/vendor/assets/stylesheets/matestack-ui-core.css.erb +2 -0
  85. metadata +65 -14
  86. data/vendor/assets/javascripts/manifest.json +0 -4
  87. data/vendor/assets/javascripts/matestack-ui-core.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import Vue from 'vue/dist/vue.esm'
2
- import componentMixin from 'component/component'
2
+ import componentMixin from '../component/component'
3
3
 
4
4
  const componentDef = {
5
5
  mixins: [componentMixin]
@@ -0,0 +1,5 @@
1
+ %iframe{@tag_attributes}
2
+ - if options[:text].nil? && block_given?
3
+ = yield
4
+ - else
5
+ = options[:text]
@@ -0,0 +1,14 @@
1
+ module Matestack::Ui::Core::Iframe
2
+ class Iframe < Matestack::Ui::Core::Component::Static
3
+
4
+ def setup
5
+ @tag_attributes.merge!({
6
+ src: options[:src],
7
+ height: options[:height],
8
+ width: options[:width],
9
+ srcdoc: options[:srcdoc]
10
+ })
11
+ end
12
+
13
+ end
14
+ end
@@ -1,19 +1,20 @@
1
1
  import Vue from 'vue/dist/vue.esm'
2
2
 
3
- import app from 'app/app'
4
- import async from 'async/async'
5
- import pageContent from 'page/content'
6
- import store from 'app/store'
7
- import component from 'component/component'
8
- import anonymDynamicComponent from 'component/anonym-dynamic-component'
9
- import html from 'html/html'
10
- import transition from 'transition/transition'
11
- import action from 'action/action'
12
- import form from 'form/form'
13
- import onclick from 'onclick/onclick'
14
- import collectionContent from 'collection/content/content'
15
- import collectionFilter from 'collection/filter/filter'
16
- import collectionOrder from 'collection/order/order'
3
+ // Import from app/concepts/matestack/ui/core:
4
+ import app from '../app/app'
5
+ import async from '../async/async'
6
+ import pageContent from '../page/content'
7
+ import store from '../app/store'
8
+ import component from '../component/component'
9
+ import anonymDynamicComponent from '../component/anonym-dynamic-component'
10
+ import html from '../html/html'
11
+ import transition from '../transition/transition'
12
+ import action from '../action/action'
13
+ import form from '../form/form'
14
+ import onclick from '../onclick/onclick'
15
+ import collectionContent from '../collection/content/content'
16
+ import collectionFilter from '../collection/filter/filter'
17
+ import collectionOrder from '../collection/order/order'
17
18
 
18
19
  let matestackUiApp = undefined
19
20
 
@@ -1,8 +1,7 @@
1
1
  import Vue from 'vue/dist/vue.esm'
2
2
 
3
- import matestackEventHub from 'js/event-hub'
4
-
5
- import componentMixin from 'component/component'
3
+ import matestackEventHub from '../js/event-hub'
4
+ import componentMixin from '../component/component'
6
5
 
7
6
  const componentDef = {
8
7
  mixins: [componentMixin],
@@ -0,0 +1,3 @@
1
+ %optgroup{@tag_attributes}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,10 @@
1
+ module Matestack::Ui::Core::Optgroup
2
+ class Optgroup < Matestack::Ui::Core::Component::Static
3
+ def setup
4
+ @tag_attributes.merge!(
5
+ disabled: options[:disabled] ||= nil,
6
+ label: options[:label]
7
+ )
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ %option{@tag_attributes}
2
+ - if options[:text].blank? && block_given?
3
+ = yield
4
+ - else
5
+ = options[:text]
@@ -0,0 +1,12 @@
1
+ module Matestack::Ui::Core::Option
2
+ class Option < Matestack::Ui::Core::Component::Static
3
+ def setup
4
+ @tag_attributes.merge!(
5
+ disabled: options[:disabled] ||= nil,
6
+ selected: options[:selected] ||= nil,
7
+ label: options[:label],
8
+ value: options[:value]
9
+ )
10
+ end
11
+ end
12
+ end
@@ -1,6 +1,6 @@
1
1
  import Vue from 'vue/dist/vue.esm'
2
2
  import Vuex from 'vuex'
3
- import componentMixin from 'component/component'
3
+ import componentMixin from '../component/component'
4
4
 
5
5
  const componentDef = {
6
6
  mixins: [componentMixin],
@@ -2,9 +2,10 @@ module Matestack::Ui::Core::Page
2
2
  class Page < Trailblazer::Cell
3
3
 
4
4
  include ActionView::Helpers::TranslationHelper
5
- include ::Cell::Haml
5
+ include Matestack::Ui::Core::Cell
6
6
  include Matestack::Ui::Core::ApplicationHelper
7
7
  include Matestack::Ui::Core::ToCell
8
+ include Matestack::Ui::Core::HasViewContext
8
9
 
9
10
  view_paths << "#{Matestack::Ui::Core::Engine.root}/app/concepts"
10
11
 
@@ -93,7 +94,7 @@ module Matestack::Ui::Core::Page
93
94
  begin
94
95
  render_child_component component_key
95
96
  rescue => e
96
- raise "Component '#{component_key}' could not be resolved."
97
+ raise "Component '#{component_key}' could not be resolved, because of #{e},\n#{e.backtrace.join("\n")}"
97
98
  end
98
99
  end
99
100
  end
@@ -0,0 +1,3 @@
1
+ %picture{@tag_attributes}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,4 @@
1
+ module Matestack::Ui::Core::Picture
2
+ class Picture < Matestack::Ui::Core::Component::Static
3
+ end
4
+ end
@@ -2,7 +2,7 @@ module Matestack::Ui::Core::Plain
2
2
  class Plain < Matestack::Ui::Core::Component::Static
3
3
 
4
4
  def show
5
- @argument
5
+ html_escape @argument
6
6
  end
7
7
 
8
8
  end
@@ -0,0 +1,5 @@
1
+ %samp{@tag_attributes}
2
+ - if options[:text].blank? && block_given?
3
+ = yield
4
+ - else
5
+ = options[:text]
@@ -0,0 +1,4 @@
1
+ module Matestack::Ui::Core::Samp
2
+ class Samp < Matestack::Ui::Core::Component::Static
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ %template{@tag_attributes}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,4 @@
1
+ module Matestack::Ui::Core::Template
2
+ class Template < Matestack::Ui::Core::Component::Static
3
+ end
4
+ end
@@ -1,6 +1,6 @@
1
1
  import Vue from 'vue/dist/vue.esm'
2
2
  import Vuex from 'vuex'
3
- import componentMixin from 'component/component'
3
+ import componentMixin from '../component/component'
4
4
 
5
5
  const componentDef = {
6
6
  mixins: [componentMixin],
@@ -0,0 +1,5 @@
1
+ %u{@tag_attributes}
2
+ - if options[:text].nil? && block_given?
3
+ = yield
4
+ - else
5
+ = options[:text]
@@ -0,0 +1,6 @@
1
+ module Matestack::Ui::Core::U
2
+ class U < Matestack::Ui::Core::Component::Static
3
+
4
+ end
5
+ end
6
+
@@ -0,0 +1,7 @@
1
+ module Matestack::Ui::Core::Unescaped
2
+ class Unescaped < Matestack::Ui::Core::Component::Static
3
+ def show
4
+ @argument
5
+ end
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ %wbr{@tag_attributes}
@@ -0,0 +1,4 @@
1
+ module Matestack::Ui::Core::Wbr
2
+ class Wbr < Matestack::Ui::Core::Component::Static
3
+ end
4
+ end
@@ -2,11 +2,13 @@ module Matestack
2
2
  module Ui
3
3
  module Core
4
4
  module ApplicationHelper
5
+ include Matestack::Ui::Core::Render
5
6
 
6
7
  def render_page(page_class, only_page=false)
7
8
  page_class.new(nil, context: {
8
9
  params: params,
9
- request: request
10
+ request: request,
11
+ view_context: view_context
10
12
  }, controller_instance: self).call(:show, nil, only_page)
11
13
  end
12
14
 
@@ -0,0 +1,22 @@
1
+ import Vue from 'vue/dist/vue.esm'
2
+ import Vuex from 'vuex'
3
+ import axios from 'axios'
4
+
5
+ // Import from app/concepts/matestack/ui/core:
6
+ import matestackEventHub from '../../../app/concepts/matestack/ui/core/js/event-hub'
7
+ import componentMixin from '../../../app/concepts/matestack/ui/core/component/component'
8
+ import matestackUiCore from '../../../app/concepts/matestack/ui/core/js/core'
9
+
10
+ import styles from './styles/index.scss'
11
+
12
+ const MatestackUiCore = {
13
+ Vue,
14
+ Vuex,
15
+ axios,
16
+ matestackEventHub,
17
+ componentMixin
18
+ }
19
+
20
+ window.MatestackUiCore = MatestackUiCore
21
+
22
+ export default MatestackUiCore
@@ -0,0 +1,5 @@
1
+ // glob imports are not supported out of the box.
2
+ //
3
+ // @import "../../../concepts/matestack/ui/core/**/*.scss";
4
+ // @import "../../../concepts/matestack/ui/core/**/*.sass";
5
+ // @import "../../../concepts/matestack/ui/core/**/*.css";
@@ -0,0 +1,8 @@
1
+ // // Add polyfills for the asset pipeline
2
+ // // https://github.com/matestack/matestack-ui-core/issues/238#issuecomment-583905838
3
+ //
4
+ // import 'core-js/stable'
5
+ // import 'regenerator-runtime/runtime'
6
+
7
+ import '../matestack-ui-core/index'
8
+ export default MatestackUiCore
@@ -21,7 +21,11 @@ module Matestack::Ui::Core
21
21
 
22
22
  def method_missing meth, *args, &block
23
23
  begin
24
- @component_instance.send(meth, *args, &block)
24
+ if (result = @component_instance.send(meth, *args, &block)).kind_of? ActiveSupport::SafeBuffer
25
+ plain result
26
+ else
27
+ result
28
+ end
25
29
  rescue
26
30
  node_id = @node_start_id + 1
27
31
  @node_start_id = node_id
@@ -32,6 +36,16 @@ module Matestack::Ui::Core
32
36
  @hash[current_node]["argument"] = nil
33
37
  @hash[current_node]["included_config"] = @included_config
34
38
 
39
+ if args.second == :include
40
+ included = args.first
41
+ else
42
+ unless @included_config.nil?
43
+ included = @included_config
44
+ else
45
+ included = nil
46
+ end
47
+ end
48
+
35
49
  if meth == :isolate
36
50
  raise("isolate > only works on page level currently. component support is comming soon!")
37
51
  end
@@ -48,15 +62,15 @@ module Matestack::Ui::Core
48
62
  @hash[current_node]["argument"] = args.first
49
63
  end
50
64
 
51
- if args.second == :include
52
- included = args.first
53
- else
54
- unless @included_config.nil?
55
- included = @included_config
56
- else
57
- included = nil
58
- end
59
- end
65
+ # if args.second == :include
66
+ # included = args.first
67
+ # else
68
+ # unless @included_config.nil?
69
+ # included = @included_config
70
+ # else
71
+ # included = nil
72
+ # end
73
+ # end
60
74
 
61
75
  if block_given?
62
76
  @hash[current_node]["components"] = ComponentNode.build(@component_instance, included, &block)
@@ -0,0 +1,10 @@
1
+ module Matestack::Ui::Core::HasViewContext
2
+ def initialize(model = nil, options = {})
3
+ @view_context = options[:context][:view_context]
4
+ super
5
+ end
6
+
7
+ def method_missing(*args, &block)
8
+ @view_context.send(*args, &block)
9
+ end
10
+ end
@@ -22,7 +22,11 @@ module Matestack::Ui::Core
22
22
 
23
23
  def method_missing meth, *args, &block
24
24
  begin
25
- @page_instance.send(meth, *args, &block)
25
+ if (result = @page_instance.send(meth, *args, &block)).kind_of? ActiveSupport::SafeBuffer
26
+ plain result
27
+ else
28
+ result
29
+ end
26
30
  rescue
27
31
  node_id = @node_start_id + 1
28
32
  @node_start_id = node_id
@@ -0,0 +1,89 @@
1
+ module Matestack::Ui::Core::Render
2
+
3
+ # Matestack allows you to use `render` to render matestack pages.
4
+ #
5
+ # render Pages::Member::Bookings::Index
6
+ # render matestack: Pages::Member::Bookings::Index
7
+ # render matestack: 'member/bookings/index'
8
+ #
9
+ def render(*args)
10
+ if (matestack_class = args.first).is_a?(Class) && (matestack_class < Matestack::Ui::Page)
11
+ responder_for matestack_class
12
+ elsif (options = args.first).kind_of?(Hash) && (matestack_arg = options[:matestack]).present?
13
+ if (matestack_path = matestack_arg).kind_of? String
14
+ matestack_path = "pages/#{matestack_path}" unless matestack_path.start_with?("pages/") or matestack_path.start_with?("components/")
15
+ matestack_class = matestack_path.split("/").collect { |str| str.camelcase }.join("::").constantize
16
+ elsif matestack_arg.is_a?(Class) && (matestack_arg < Matestack::Ui::Page)
17
+ matestack_class = matestack_arg
18
+ end
19
+ responder_for matestack_class
20
+ else
21
+ super
22
+ end
23
+ end
24
+
25
+ # Matestack allows implicit rendering. The matestack page class name is inferred from the
26
+ # controller path and action name.
27
+ #
28
+ # class Clients::BookingsController < ApplicationController
29
+ # def index
30
+ # @bookings = Booking.all
31
+ # # looks for Pages::Clients::Bookings::Index
32
+ # end
33
+ #
34
+ # def show
35
+ # @booking = Booking.find params[:id]
36
+ # # looks for Pages::Clients::Bookings::Show
37
+ # end
38
+ # end
39
+ #
40
+ # In this example, `clients/bookings#index` will render `Pages::Clients::Bookings::Index`,
41
+ # `clients/bookings#show` will render `Pages::Clients::Bookings::Show`.
42
+ #
43
+ # Custom action names translate also into page names.
44
+ #
45
+ # class Clients::BookingsController < ApplicationController
46
+ # def step1
47
+ # # looks for Pages::Clients::Bookings::Step1
48
+ # end
49
+ # end
50
+ #
51
+ # In this example, the `clients/bookings#step1` action will render
52
+ # `Pages::Clients::Bookings::Step1`.
53
+ #
54
+ def default_render(*args)
55
+ if matestack_page_class = default_render_matestack_page_class
56
+ render matestack: matestack_page_class
57
+ else
58
+ super
59
+ end
60
+ end
61
+
62
+ def possible_default_render_matestack_page_paths
63
+ paths = []
64
+ paths << "pages/#{controller_path}/#{action_name}"
65
+ paths << "pages/#{controller_path}" if action_name == "index"
66
+ paths << "pages/#{controller_path.singularize}" if action_name == "show"
67
+ paths << "#{controller_path}/#{action_name}_page"
68
+ paths << "#{controller_path}_page" if action_name == "index"
69
+ paths << "#{controller_path.singularize}_page" if action_name == "show"
70
+ paths
71
+ end
72
+
73
+ def possible_default_render_matestack_page_class_names
74
+ possible_default_render_matestack_page_paths.collect { |page_path|
75
+ page_path.split("/").collect { |str| str.camelcase }.join("::")
76
+ }
77
+ end
78
+
79
+ def default_render_matestack_page_class
80
+ possible_default_render_matestack_page_class_names.each do |class_name|
81
+ begin
82
+ return matestack_class = class_name.constantize
83
+ rescue NameError
84
+ end
85
+ end
86
+ return nil
87
+ end
88
+
89
+ end