matestack-ui-vuejs 3.0.0.rc1

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 (77) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +492 -0
  4. data/Rakefile +64 -0
  5. data/lib/matestack/ui/component.rb +1 -0
  6. data/lib/matestack/ui/isolated_component.rb +1 -0
  7. data/lib/matestack/ui/vue_js/components/action.js +70 -0
  8. data/lib/matestack/ui/vue_js/components/action.rb +46 -0
  9. data/lib/matestack/ui/vue_js/components/app.js +122 -0
  10. data/lib/matestack/ui/vue_js/components/app.rb +46 -0
  11. data/lib/matestack/ui/vue_js/components/async.js +104 -0
  12. data/lib/matestack/ui/vue_js/components/async.rb +84 -0
  13. data/lib/matestack/ui/vue_js/components/cable.js +96 -0
  14. data/lib/matestack/ui/vue_js/components/cable.rb +69 -0
  15. data/lib/matestack/ui/vue_js/components/collection/content.js +96 -0
  16. data/lib/matestack/ui/vue_js/components/collection/content.rb +32 -0
  17. data/lib/matestack/ui/vue_js/components/collection/filter.js +45 -0
  18. data/lib/matestack/ui/vue_js/components/collection/filter.rb +29 -0
  19. data/lib/matestack/ui/vue_js/components/collection/filter_reset.rb +19 -0
  20. data/lib/matestack/ui/vue_js/components/collection/helper.rb +128 -0
  21. data/lib/matestack/ui/vue_js/components/collection/next.rb +19 -0
  22. data/lib/matestack/ui/vue_js/components/collection/order.js +45 -0
  23. data/lib/matestack/ui/vue_js/components/collection/order.rb +28 -0
  24. data/lib/matestack/ui/vue_js/components/collection/order_toggle.rb +21 -0
  25. data/lib/matestack/ui/vue_js/components/collection/order_toggle_indicator.rb +30 -0
  26. data/lib/matestack/ui/vue_js/components/collection/page.rb +21 -0
  27. data/lib/matestack/ui/vue_js/components/collection/previous.rb +19 -0
  28. data/lib/matestack/ui/vue_js/components/form/base.rb +179 -0
  29. data/lib/matestack/ui/vue_js/components/form/checkbox.js +13 -0
  30. data/lib/matestack/ui/vue_js/components/form/checkbox.rb +109 -0
  31. data/lib/matestack/ui/vue_js/components/form/checkbox_mixin.js +90 -0
  32. data/lib/matestack/ui/vue_js/components/form/context.rb +15 -0
  33. data/lib/matestack/ui/vue_js/components/form/fields_for_add_item.js +50 -0
  34. data/lib/matestack/ui/vue_js/components/form/fields_for_add_item.rb +35 -0
  35. data/lib/matestack/ui/vue_js/components/form/fields_for_remove_item.rb +19 -0
  36. data/lib/matestack/ui/vue_js/components/form/form.js +276 -0
  37. data/lib/matestack/ui/vue_js/components/form/form.rb +77 -0
  38. data/lib/matestack/ui/vue_js/components/form/input.js +13 -0
  39. data/lib/matestack/ui/vue_js/components/form/input.rb +54 -0
  40. data/lib/matestack/ui/vue_js/components/form/input_mixin.js +79 -0
  41. data/lib/matestack/ui/vue_js/components/form/nested_form.js +153 -0
  42. data/lib/matestack/ui/vue_js/components/form/nested_form.rb +57 -0
  43. data/lib/matestack/ui/vue_js/components/form/radio.js +13 -0
  44. data/lib/matestack/ui/vue_js/components/form/radio.rb +85 -0
  45. data/lib/matestack/ui/vue_js/components/form/radio_mixin.js +75 -0
  46. data/lib/matestack/ui/vue_js/components/form/select.js +13 -0
  47. data/lib/matestack/ui/vue_js/components/form/select.rb +96 -0
  48. data/lib/matestack/ui/vue_js/components/form/select_mixin.js +76 -0
  49. data/lib/matestack/ui/vue_js/components/form/textarea.js +13 -0
  50. data/lib/matestack/ui/vue_js/components/form/textarea.rb +37 -0
  51. data/lib/matestack/ui/vue_js/components/form/textarea_mixin.js +54 -0
  52. data/lib/matestack/ui/vue_js/components/helpers.js +5 -0
  53. data/lib/matestack/ui/vue_js/components/isolated.js +105 -0
  54. data/lib/matestack/ui/vue_js/components/isolated.rb +86 -0
  55. data/lib/matestack/ui/vue_js/components/mixin.js +66 -0
  56. data/lib/matestack/ui/vue_js/components/onclick.js +18 -0
  57. data/lib/matestack/ui/vue_js/components/onclick.rb +37 -0
  58. data/lib/matestack/ui/vue_js/components/page_switch.js +24 -0
  59. data/lib/matestack/ui/vue_js/components/page_switch.rb +35 -0
  60. data/lib/matestack/ui/vue_js/components/runtime_render.js +17 -0
  61. data/lib/matestack/ui/vue_js/components/toggle.js +70 -0
  62. data/lib/matestack/ui/vue_js/components/toggle.rb +38 -0
  63. data/lib/matestack/ui/vue_js/components/transition.js +44 -0
  64. data/lib/matestack/ui/vue_js/components/transition.rb +40 -0
  65. data/lib/matestack/ui/vue_js/components/transition_handling_mixin.js +100 -0
  66. data/lib/matestack/ui/vue_js/components.rb +118 -0
  67. data/lib/matestack/ui/vue_js/event_hub.js +12 -0
  68. data/lib/matestack/ui/vue_js/helpers/query_params_helper.js +56 -0
  69. data/lib/matestack/ui/vue_js/index.js +94 -0
  70. data/lib/matestack/ui/vue_js/initialize.rb +10 -0
  71. data/lib/matestack/ui/vue_js/utils.rb +67 -0
  72. data/lib/matestack/ui/vue_js/version.rb +7 -0
  73. data/lib/matestack/ui/vue_js/vue.rb +75 -0
  74. data/lib/matestack/ui/vue_js/vue_attributes.rb +13 -0
  75. data/lib/matestack/ui/vue_js.rb +52 -0
  76. data/lib/matestack/ui/vue_js_component.rb +1 -0
  77. metadata +150 -0
@@ -0,0 +1,38 @@
1
+ module Matestack
2
+ module Ui
3
+ module VueJs
4
+ module Components
5
+ class Toggle < Matestack::Ui::VueJs::Vue
6
+ vue_name 'matestack-ui-core-toggle'
7
+
8
+ optional :show_on, :hide_on, :hide_after, :init_show
9
+
10
+ def response
11
+ div toggle_attributes do
12
+ yield
13
+ end
14
+ end
15
+
16
+ def toggle_attributes
17
+ options.merge({
18
+ class: "matestack-toggle-component-root",
19
+ 'v-if': 'vc.showing'
20
+ })
21
+ end
22
+
23
+ protected
24
+
25
+ def vue_props
26
+ {
27
+ show_on: ctx.show_on,
28
+ hide_on: ctx.hide_on,
29
+ hide_after: ctx.hide_after,
30
+ init_show: ctx.init_show,
31
+ }
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,44 @@
1
+ import matestackEventHub from '../event_hub'
2
+ import componentMixin from './mixin'
3
+ import componentHelpers from './helpers'
4
+
5
+ const componentDef = {
6
+ mixins: [componentMixin],
7
+ template: componentHelpers.inlineTemplate,
8
+ data: function(){
9
+ return {}
10
+ },
11
+ inject: [
12
+ 'appNavigateTo',
13
+ 'currentPathName',
14
+ 'setPageLoading',
15
+ 'pageLoading'
16
+ ],
17
+ computed: {
18
+ isActive () {
19
+ return (this.props["link_path"].split("?")[0]) === this.currentPathName
20
+ },
21
+ isChildActive () {
22
+ return ((this.props["link_path"].split("?")[0]) !== this.currentPathName) && (this.currentPathName.indexOf(this.props["link_path"].split("?")[0]) !== -1)
23
+ }
24
+ },
25
+ methods: {
26
+ navigateTo: function(url){
27
+ const self = this
28
+ matestackEventHub.$emit("page_loading_triggered", url);
29
+ this.setPageLoading(true)
30
+ if (self.props["delay"] != undefined) {
31
+ setTimeout(function () {
32
+ self.performNavigation(url)
33
+ }, parseInt(self.props["delay"]));
34
+ } else {
35
+ this.performNavigation(url)
36
+ }
37
+ },
38
+ performNavigation: function(url){
39
+ this.appNavigateTo({url: url, backwards: false})
40
+ }
41
+ }
42
+ }
43
+
44
+ export default componentDef
@@ -0,0 +1,40 @@
1
+ module Matestack
2
+ module Ui
3
+ module VueJs
4
+ module Components
5
+ class Transition < Matestack::Ui::VueJs::Vue
6
+ vue_name 'matestack-ui-core-transition'
7
+
8
+ optional :path, :delay
9
+
10
+ def response
11
+ a attributes do
12
+ if block_given?
13
+ yield
14
+ end
15
+ plain self.text if self.text
16
+ end
17
+ end
18
+
19
+ protected
20
+
21
+ def attributes
22
+ options.merge({
23
+ href: ctx.path,
24
+ 'v-on:click.prevent': "vc.navigateTo(\"#{ctx.path}\")",
25
+ "v-bind:class": "{ active: vc.isActive, 'active-child': vc.isChildActive }"
26
+ })
27
+ end
28
+
29
+ def vue_props
30
+ {
31
+ link_path: ctx.path,
32
+ delay: ctx.delay,
33
+ }
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,100 @@
1
+ import matestackEventHub from '../event_hub'
2
+
3
+ const transitionHandlingMixin = {
4
+ methods: {
5
+ successTransitionHandling: function(response){
6
+ const self = this
7
+ if (self.props["success"] != undefined
8
+ && self.props["success"]["transition"] != undefined
9
+ && (
10
+ self.props["success"]["transition"]["follow_response"] == undefined
11
+ ||
12
+ self.props["success"]["transition"]["follow_response"] === false
13
+ )
14
+ && self.appNavigateTo != undefined
15
+ ) {
16
+ let path = self.props["success"]["transition"]["path"]
17
+ self.appNavigateTo({url: path, backwards: false})
18
+ return;
19
+ }
20
+ if (self.props["success"] != undefined
21
+ && self.props["success"]["transition"] != undefined
22
+ && self.props["success"]["transition"]["follow_response"] === true
23
+ && self.appNavigateTo != undefined
24
+ ) {
25
+ let path = response.data["transition_to"] || response.request.responseURL
26
+ self.appNavigateTo({url: path, backwards: false})
27
+ return;
28
+ }
29
+ // redirect handling
30
+ if (self.props["success"] != undefined
31
+ && self.props["success"]["redirect"] != undefined
32
+ && (
33
+ self.props["success"]["redirect"]["follow_response"] == undefined
34
+ ||
35
+ self.props["success"]["redirect"]["follow_response"] === false
36
+ )
37
+ ) {
38
+ let path = self.props["success"]["redirect"]["path"]
39
+ window.location.href = path
40
+ return;
41
+ }
42
+ if (self.props["success"] != undefined
43
+ && self.props["success"]["redirect"] != undefined
44
+ && self.props["success"]["redirect"]["follow_response"] === true
45
+ ) {
46
+ let path = response.data["redirect_to"] || response.request.responseURL
47
+ window.location.href = path
48
+ return;
49
+ }
50
+ },
51
+ failureTransitionHandling: function(error){
52
+ const self = this
53
+ if (self.props["failure"] != undefined
54
+ && self.props["failure"]["transition"] != undefined
55
+ && (
56
+ self.props["failure"]["transition"]["follow_response"] == undefined
57
+ ||
58
+ self.props["failure"]["transition"]["follow_response"] === false
59
+ )
60
+ && self.appNavigateTo != undefined
61
+ ) {
62
+ let path = self.props["failure"]["transition"]["path"]
63
+ self.appNavigateTo({url: path, backwards: false})
64
+ return;
65
+ }
66
+ if (self.props["failure"] != undefined
67
+ && self.props["failure"]["transition"] != undefined
68
+ && self.props["failure"]["transition"]["follow_response"] === true
69
+ && self.appNavigateTo != undefined
70
+ ) {
71
+ let path = error.response.data["transition_to"] || response.request.responseURL
72
+ self.appNavigateTo({url: path, backwards: false})
73
+ return;
74
+ }
75
+ // redirect handling
76
+ if (self.props["failure"] != undefined
77
+ && self.props["failure"]["redirect"] != undefined
78
+ && (
79
+ self.props["failure"]["redirect"]["follow_response"] == undefined
80
+ ||
81
+ self.props["failure"]["redirect"]["follow_response"] === false
82
+ )
83
+ ) {
84
+ let path = self.props["failure"]["redirect"]["path"]
85
+ window.location.href = path
86
+ return;
87
+ }
88
+ if (self.props["failure"] != undefined
89
+ && self.props["failure"]["redirect"] != undefined
90
+ && self.props["failure"]["redirect"]["follow_response"] === true
91
+ ) {
92
+ let path = error.response.data["redirect_to"] || response.request.responseURL
93
+ window.location.href = path
94
+ return;
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ export default transitionHandlingMixin
@@ -0,0 +1,118 @@
1
+ module Matestack
2
+ module Ui
3
+ module VueJs
4
+ module Components
5
+
6
+ def matestack_vue_js_app(text=nil, options=nil, &block)
7
+ Matestack::Ui::VueJs::Components::App.(text, options, &block)
8
+ end
9
+
10
+ def page_switch(text=nil, options=nil, &block)
11
+ Matestack::Ui::VueJs::Components::PageSwitch.(text, options, &block)
12
+ end
13
+
14
+ def toggle(text=nil, options=nil, &block)
15
+ Matestack::Ui::VueJs::Components::Toggle.(text, options, &block)
16
+ end
17
+
18
+ def onclick(text=nil, options=nil, &block)
19
+ Matestack::Ui::VueJs::Components::Onclick.(text, options, &block)
20
+ end
21
+
22
+ def transition(text=nil, options=nil, &block)
23
+ Matestack::Ui::VueJs::Components::Transition.(text, options, &block)
24
+ end
25
+
26
+ def async(text=nil, options=nil, &block)
27
+ Matestack::Ui::VueJs::Components::Async.(text, options, &block)
28
+ end
29
+
30
+ def action(text=nil, options=nil, &block)
31
+ Matestack::Ui::VueJs::Components::Action.(text, options, &block)
32
+ end
33
+
34
+ def cable(text=nil, options=nil, &block)
35
+ Matestack::Ui::VueJs::Components::Cable.(text, options, &block)
36
+ end
37
+
38
+ def matestack_form(text=nil, options=nil, &block)
39
+ Matestack::Ui::VueJs::Components::Form::Form.(text, options, &block)
40
+ end
41
+
42
+ def form_fields_for(text=nil, options=nil, &block)
43
+ # in order to provide a more intuitiv API while calling the default
44
+ # form, we transform the arguments a bit:
45
+ options[:for] = text
46
+ options[:fields_for] = options.delete(:key)
47
+ text = nil
48
+ Matestack::Ui::VueJs::Components::Form::NestedForm.(text, options, &block)
49
+ end
50
+
51
+ def form_fields_for_remove_item(text=nil, options=nil, &block)
52
+ Matestack::Ui::VueJs::Components::Form::FieldsForRemoveItem.(text, options, &block)
53
+ end
54
+
55
+ def form_fields_for_add_item(text=nil, options=nil, &block)
56
+ Matestack::Ui::VueJs::Components::Form::FieldsForAddItem.(text, options, &block)
57
+ end
58
+
59
+ def form_input(text=nil, options=nil, &block)
60
+ Matestack::Ui::VueJs::Components::Form::Input.(text, options, &block)
61
+ end
62
+
63
+ def form_textarea(text=nil, options=nil, &block)
64
+ Matestack::Ui::VueJs::Components::Form::Textarea.(text, options, &block)
65
+ end
66
+
67
+ def form_checkbox(text=nil, options=nil, &block)
68
+ Matestack::Ui::VueJs::Components::Form::Checkbox.(text, options, &block)
69
+ end
70
+
71
+ def form_radio(text=nil, options=nil, &block)
72
+ Matestack::Ui::VueJs::Components::Form::Radio.(text, options, &block)
73
+ end
74
+
75
+ def form_select(text=nil, options=nil, &block)
76
+ Matestack::Ui::VueJs::Components::Form::Select.(text, options, &block)
77
+ end
78
+
79
+ def collection_content(text=nil, options=nil, &block)
80
+ Matestack::Ui::VueJs::Components::Collection::Content.(text, options, &block)
81
+ end
82
+
83
+ def collection_filter(text=nil, options=nil, &block)
84
+ Matestack::Ui::VueJs::Components::Collection::Filter.(text, options, &block)
85
+ end
86
+
87
+ def collection_filter_reset(text=nil, options=nil, &block)
88
+ Matestack::Ui::VueJs::Components::Collection::FilterReset.(text, options, &block)
89
+ end
90
+
91
+ def collection_order(text=nil, options=nil, &block)
92
+ Matestack::Ui::VueJs::Components::Collection::Order.(text, options, &block)
93
+ end
94
+
95
+ def collection_order_toggle(text=nil, options=nil, &block)
96
+ Matestack::Ui::VueJs::Components::Collection::OrderToggle.(text, options, &block)
97
+ end
98
+
99
+ def collection_order_toggle_indicator(text=nil, options=nil, &block)
100
+ Matestack::Ui::VueJs::Components::Collection::OrderToggleIndicator.(text, options, &block)
101
+ end
102
+
103
+ def collection_content_next(text=nil, options=nil, &block)
104
+ Matestack::Ui::VueJs::Components::Collection::Next.(text, options, &block)
105
+ end
106
+
107
+ def collection_content_previous(text=nil, options=nil, &block)
108
+ Matestack::Ui::VueJs::Components::Collection::Previous.(text, options, &block)
109
+ end
110
+
111
+ def collection_content_page_link(text=nil, options=nil, &block)
112
+ Matestack::Ui::VueJs::Components::Collection::Page.(text, options, &block)
113
+ end
114
+
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,12 @@
1
+ import mitt from 'mitt'
2
+
3
+ const emitter = mitt()
4
+
5
+ const eventHub = {
6
+ $on: (...args) => emitter.on(...args),
7
+ $once: (...args) => emitter.once(...args),
8
+ $off: (...args) => emitter.off(...args),
9
+ $emit: (...args) => emitter.emit(...args)
10
+ }
11
+
12
+ export default eventHub
@@ -0,0 +1,56 @@
1
+ const updateQueryParams = (key, value, url) => {
2
+ if (!url) url = window.location.href;
3
+ let re = new RegExp(`([?&])${key}=.*?(&|#|$)(.*)`, "gi"), hash;
4
+
5
+ if (re.test(url)) {
6
+ if (typeof value !== 'undefined' && value !== null)
7
+ return url.replace(re, `$1${key}=${value}$2$3`);
8
+ else {
9
+ hash = url.split('#');
10
+ url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, '');
11
+ if (typeof hash[1] !== 'undefined' && hash[1] !== null)
12
+ url += `#${hash[1]}`;
13
+ return url;
14
+ }
15
+ }
16
+ else {
17
+ if (typeof value !== 'undefined' && value !== null) {
18
+ const separator = url.indexOf('?') !== -1 ? '&' : '?';
19
+ hash = url.split('#');
20
+ url = `${hash[0]}${separator}${key}=${value}`;
21
+ if (typeof hash[1] !== 'undefined' && hash[1] !== null)
22
+ url += `#${hash[1]}`;
23
+ return url;
24
+ }
25
+ else
26
+ return url;
27
+ }
28
+ };
29
+
30
+ const getQueryParam = (name, url) => {
31
+ if (!url) url = window.location.href;
32
+ name = name.replace(/[\[\]]/g, '\\$&');
33
+ const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`), results = regex.exec(url);
34
+ if (!results) return null;
35
+ if (!results[2]) return '';
36
+ return decodeURIComponent(results[2].replace(/\+/g, ' '));
37
+ };
38
+
39
+ const queryParamsToObject = () => {
40
+ const search = window.location.search.substring(1);
41
+ if(search.length === 0){
42
+ return {}
43
+ } else {
44
+ const result = JSON.parse(
45
+ `{"${search.replace(/&/g, '","').replace(/=/g,'":"')}"}`,
46
+ (key, value) => { return key===""?value:decodeURIComponent(value) }
47
+ );
48
+ return result;
49
+ }
50
+ };
51
+
52
+ export default {
53
+ updateQueryParams: updateQueryParams,
54
+ getQueryParam: getQueryParam,
55
+ queryParamsToObject: queryParamsToObject
56
+ }
@@ -0,0 +1,94 @@
1
+ import Vue from 'vue'
2
+
3
+ import eventHub from './event_hub'
4
+ const matestackEventHub = eventHub // for compatibility with 1.x
5
+
6
+ import componentMixin from './components/mixin'
7
+ import componentHelpers from './components/helpers'
8
+
9
+ import app from './components/app'
10
+
11
+ import pageSwitch from './components/page_switch'
12
+
13
+ import runtimeRender from './components/runtime_render'
14
+
15
+ import collectionContent from './components/collection/content'
16
+ import collectionFilter from './components/collection/filter'
17
+ import collectionOrder from './components/collection/order'
18
+
19
+ import toggle from './components/toggle'
20
+ import onclick from './components/onclick'
21
+ import transition from './components/transition'
22
+ import async from './components/async'
23
+ import action from './components/action'
24
+ import cable from './components/cable'
25
+ import isolate from './components/isolated'
26
+ import form from './components/form/form'
27
+ import nestedForm from './components/form/nested_form'
28
+ import fieldsForAddItem from './components/form/fields_for_add_item'
29
+ import formCheckbox from './components/form/checkbox'
30
+ import formInput from './components/form/input'
31
+ import formRadio from './components/form/radio'
32
+ import formSelect from './components/form/select'
33
+ import formTextarea from './components/form/textarea'
34
+
35
+ import formInputMixin from './components/form/input_mixin'
36
+ import formSelectMixin from './components/form/select_mixin'
37
+ import formRadioMixin from './components/form/radio_mixin'
38
+ import formCheckboxMixin from './components/form/checkbox_mixin'
39
+ import formTextareaMixin from './components/form/textarea_mixin'
40
+
41
+ const registerComponents = function(appInstance){
42
+ appInstance.config.compilerOptions.whitespace = "preserve"
43
+ appInstance.config.compilerOptions.isCustomElement = tag => tag === 'matestack-component-template'
44
+ appInstance.config.unwrapInjectedRef = true
45
+
46
+ appInstance.component('matestack-ui-core-runtime-render', runtimeRender)
47
+
48
+ appInstance.component('matestack-ui-core-app', app)
49
+ appInstance.component('matestack-ui-core-page-switch', pageSwitch)
50
+ appInstance.component('matestack-ui-core-collection-content', collectionContent)
51
+ appInstance.component('matestack-ui-core-collection-filter', collectionFilter)
52
+ appInstance.component('matestack-ui-core-collection-order', collectionOrder)
53
+ appInstance.component('matestack-ui-core-toggle', toggle)
54
+ appInstance.component('matestack-ui-core-onclick', onclick)
55
+ appInstance.component('matestack-ui-core-transition', transition)
56
+ appInstance.component('matestack-ui-core-async', async)
57
+ appInstance.component('matestack-ui-core-action', action)
58
+ appInstance.component('matestack-ui-core-cable', cable)
59
+ appInstance.component('matestack-ui-core-isolate', isolate)
60
+ appInstance.component('matestack-ui-core-form', form)
61
+ appInstance.component('matestack-ui-core-form-checkbox', formCheckbox)
62
+ appInstance.component('matestack-ui-core-form-input', formInput)
63
+ appInstance.component('matestack-ui-core-form-radio', formRadio)
64
+ appInstance.component('matestack-ui-core-form-select', formSelect)
65
+ appInstance.component('matestack-ui-core-form-textarea', formTextarea)
66
+ appInstance.component('matestack-ui-core-form-nested-form', nestedForm)
67
+ appInstance.component('matestack-ui-core-form-fields-for-add-item', fieldsForAddItem)
68
+
69
+ return appInstance
70
+ }
71
+
72
+ const mount = function(appInstance, elementId='#matestack-ui'){
73
+ registerComponents(appInstance)
74
+
75
+ appInstance.mount(elementId)
76
+
77
+ return appInstance
78
+ }
79
+
80
+ const MatestackUiVueJs = {
81
+ eventHub,
82
+ matestackEventHub, // for compatibility with 1.x
83
+ componentMixin,
84
+ componentHelpers,
85
+ formInputMixin,
86
+ formSelectMixin,
87
+ formCheckboxMixin,
88
+ formTextareaMixin,
89
+ formRadioMixin,
90
+ registerComponents,
91
+ mount
92
+ }
93
+
94
+ export default MatestackUiVueJs
@@ -0,0 +1,10 @@
1
+ class Matestack::Ui::Core::Base
2
+
3
+ include Matestack::Ui::VueJs::Components
4
+
5
+ # give easy access to vue data attributes
6
+ def vue
7
+ Matestack::Ui::VueJs::VueAttributes
8
+ end
9
+
10
+ end
@@ -0,0 +1,67 @@
1
+ module Matestack
2
+ module Ui
3
+ module VueJs
4
+ module Utils
5
+
6
+ def self.included(base)
7
+ base.extend(ClassMethods)
8
+ end
9
+ module ClassMethods
10
+ def vue_name(name = nil)
11
+ name ? @vue_name = name : @vue_name
12
+ end
13
+
14
+ def inherited(subclass)
15
+ subclass.vue_name(self.vue_name)
16
+ super
17
+ end
18
+ end
19
+
20
+ def vue_component(&block)
21
+ Matestack::Ui::Core::Base.new(:component, component_attributes) do
22
+ Matestack::Ui::Core::Base.new("matestack-component-template", 'id': "uid-#{component_uid}") do
23
+ yield
24
+ end
25
+ end
26
+ end
27
+
28
+ def component_attributes
29
+ {
30
+ is: vue_name,
31
+ ref: component_id,
32
+ ':params': params.to_json,
33
+ ':props': base_vue_props.merge(vue_props)&.to_json,
34
+ 'v-slot': "{ vc }"
35
+ }
36
+ end
37
+
38
+ def component_id
39
+ options[:id] || nil
40
+ end
41
+
42
+ def component_uid
43
+ @component_uid ||= SecureRandom.hex
44
+ end
45
+
46
+ def base_vue_props
47
+ { component_uid: component_uid }
48
+ end
49
+
50
+ def vue_props
51
+ {} # can be overwritten in sub class
52
+ end
53
+ alias :config :vue_props
54
+
55
+ def scoped_ref(value)
56
+ return "#{component_uid}-#{value}" unless value.nil?
57
+ end
58
+
59
+ def vue_name
60
+ raise "vue_name missing for #{self.class}" unless self.class.vue_name
61
+ self.class.vue_name
62
+ end
63
+
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,7 @@
1
+ module Matestack
2
+ module Ui
3
+ module VueJs
4
+ VERSION = '3.0.0.rc1'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,75 @@
1
+ module Matestack
2
+ module Ui
3
+ module VueJs
4
+ class Vue < Matestack::Ui::Component
5
+
6
+ def initialize(html_tag = nil, text = nil, options = {}, &block)
7
+ extract_options(text, options)
8
+ super(html_tag, text, options, &block)
9
+ end
10
+
11
+ def create_children(&block)
12
+ vue_component do
13
+ self.response do
14
+ block.call if block_given?
15
+ end
16
+ end
17
+ end
18
+
19
+ def vue_component(&block)
20
+ Matestack::Ui::Core::Base.new(:component, component_attributes) do
21
+ Matestack::Ui::Core::Base.new("matestack-component-template", 'id': "uid-#{component_uid}") do
22
+ yield
23
+ end
24
+ end
25
+ end
26
+
27
+ def component_attributes
28
+ {
29
+ is: vue_name,
30
+ ref: component_id,
31
+ ':params': params.to_json,
32
+ ':props': base_vue_props.merge(vue_props)&.to_json,
33
+ 'v-slot': "{ vc }"
34
+ }
35
+ end
36
+
37
+ def component_id
38
+ options[:id] || nil
39
+ end
40
+
41
+ def component_uid
42
+ @component_uid ||= SecureRandom.hex
43
+ end
44
+
45
+ def base_vue_props
46
+ { component_uid: component_uid }
47
+ end
48
+
49
+ def vue_props
50
+ {} # can be overwritten in sub class
51
+ end
52
+ alias :config :vue_props
53
+
54
+ def scoped_ref(value)
55
+ return "#{component_uid}-#{value}" unless value.nil?
56
+ end
57
+
58
+ def self.vue_name(name = nil)
59
+ name ? @vue_name = name : @vue_name
60
+ end
61
+
62
+ def vue_name
63
+ raise "vue_name missing for #{self.class}" unless self.class.vue_name
64
+ self.class.vue_name
65
+ end
66
+
67
+ def self.inherited(subclass)
68
+ subclass.vue_name(self.vue_name)
69
+ super
70
+ end
71
+
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,13 @@
1
+ module Matestack
2
+ module Ui
3
+ module VueJs
4
+ class VueAttributes
5
+
6
+ def self.method_missing(message, *args, &block)
7
+ return "{{ #{message} }}"
8
+ end
9
+
10
+ end
11
+ end
12
+ end
13
+ end