arara 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +38 -0
- data/Rakefile +32 -0
- data/app/assets/config/arara_manifest.js +1 -0
- data/app/assets/javascripts/arara.js +603 -0
- data/app/assets/stylesheets/arara/application.css +15 -0
- data/app/components/arara.rb +2 -0
- data/app/components/arara/base_component.rb +62 -0
- data/app/components/arara/button_component.html.erb +7 -0
- data/app/components/arara/button_component.rb +50 -0
- data/app/components/arara/card_action_buttons_component.html.erb +3 -0
- data/app/components/arara/card_action_buttons_component.rb +15 -0
- data/app/components/arara/card_action_icons_component.html.erb +3 -0
- data/app/components/arara/card_action_icons_component.rb +15 -0
- data/app/components/arara/card_actions_component.html.erb +3 -0
- data/app/components/arara/card_actions_component.rb +15 -0
- data/app/components/arara/card_component.html.erb +3 -0
- data/app/components/arara/card_component.rb +15 -0
- data/app/components/arara/card_media_component.html.erb +3 -0
- data/app/components/arara/card_media_component.rb +20 -0
- data/app/components/arara/card_media_content_component.html.erb +3 -0
- data/app/components/arara/card_media_content_component.rb +15 -0
- data/app/components/arara/card_primary_content_component.html.erb +3 -0
- data/app/components/arara/card_primary_content_component.rb +18 -0
- data/app/components/arara/checkbox_component.html.erb +22 -0
- data/app/components/arara/checkbox_component.rb +25 -0
- data/app/components/arara/chip_component.html.erb +13 -0
- data/app/components/arara/chip_component.rb +22 -0
- data/app/components/arara/chipset_component.html.erb +6 -0
- data/app/components/arara/chipset_component.rb +23 -0
- data/app/components/arara/data_table_body_cell_component.html.erb +3 -0
- data/app/components/arara/data_table_body_cell_component.rb +18 -0
- data/app/components/arara/data_table_body_checkbox_component.html.erb +11 -0
- data/app/components/arara/data_table_body_checkbox_component.rb +25 -0
- data/app/components/arara/data_table_body_component.html.erb +3 -0
- data/app/components/arara/data_table_body_component.rb +15 -0
- data/app/components/arara/data_table_body_row_component.html.erb +3 -0
- data/app/components/arara/data_table_body_row_component.rb +27 -0
- data/app/components/arara/data_table_component.html.erb +5 -0
- data/app/components/arara/data_table_component.rb +36 -0
- data/app/components/arara/data_table_header_cell_component.html.erb +3 -0
- data/app/components/arara/data_table_header_cell_component.rb +24 -0
- data/app/components/arara/data_table_header_checkbox_component.html.erb +11 -0
- data/app/components/arara/data_table_header_checkbox_component.rb +25 -0
- data/app/components/arara/data_table_header_component.html.erb +3 -0
- data/app/components/arara/data_table_header_component.rb +11 -0
- data/app/components/arara/data_table_header_row_component.html.erb +3 -0
- data/app/components/arara/data_table_header_row_component.rb +15 -0
- data/app/components/arara/dialog_button_component.html.erb +4 -0
- data/app/components/arara/dialog_button_component.rb +31 -0
- data/app/components/arara/dialog_component.html.erb +8 -0
- data/app/components/arara/dialog_component.rb +34 -0
- data/app/components/arara/dialog_content_component.html.erb +3 -0
- data/app/components/arara/dialog_content_component.rb +15 -0
- data/app/components/arara/dialog_footer_component.html.erb +3 -0
- data/app/components/arara/dialog_footer_component.rb +15 -0
- data/app/components/arara/dialog_title_component.html.erb +3 -0
- data/app/components/arara/dialog_title_component.rb +16 -0
- data/app/components/arara/elevation_component.html.erb +3 -0
- data/app/components/arara/elevation_component.rb +19 -0
- data/app/components/arara/fab_component.html.erb +13 -0
- data/app/components/arara/fab_component.rb +42 -0
- data/app/components/arara/fab_icon_component.html.erb +3 -0
- data/app/components/arara/fab_icon_component.rb +15 -0
- data/app/components/arara/form_builder.rb +142 -0
- data/app/components/arara/form_field_component.html.erb +3 -0
- data/app/components/arara/form_field_component.rb +15 -0
- data/app/components/arara/google_calendar/menu_item_component.html.erb +11 -0
- data/app/components/arara/google_calendar/menu_item_component.rb +34 -0
- data/app/components/arara/google_calendar/nav_bar_component.html.erb +176 -0
- data/app/components/arara/google_calendar/nav_bar_component.rb +6 -0
- data/app/components/arara/icon_button_component.html.erb +3 -0
- data/app/components/arara/icon_button_component.rb +42 -0
- data/app/components/arara/icon_toggle_component.html.erb +3 -0
- data/app/components/arara/icon_toggle_component.rb +18 -0
- data/app/components/arara/material_icon_component.html.erb +3 -0
- data/app/components/arara/material_icon_component.rb +18 -0
- data/app/components/arara/menu_component.html.erb +5 -0
- data/app/components/arara/menu_component.rb +19 -0
- data/app/components/arara/menu_divider_component.html.erb +1 -0
- data/app/components/arara/menu_divider_component.rb +19 -0
- data/app/components/arara/menu_item_component.html.erb +3 -0
- data/app/components/arara/menu_item_component.rb +22 -0
- data/app/components/arara/nav_bar_component.html.erb +293 -0
- data/app/components/arara/nav_bar_component.rb +7 -0
- data/app/components/arara/radio_button_component.html.erb +8 -0
- data/app/components/arara/radio_button_component.rb +35 -0
- data/app/components/arara/select_component.html.erb +22 -0
- data/app/components/arara/select_component.rb +27 -0
- data/app/components/arara/select_item_component.html.erb +3 -0
- data/app/components/arara/select_item_component.rb +45 -0
- data/app/components/arara/step_component.html.erb +27 -0
- data/app/components/arara/step_component.rb +100 -0
- data/app/components/arara/step_connector_component.html.erb +4 -0
- data/app/components/arara/step_connector_component.rb +31 -0
- data/app/components/arara/stepper_component.html.erb +3 -0
- data/app/components/arara/stepper_component.rb +20 -0
- data/app/components/arara/switch_component.html.erb +8 -0
- data/app/components/arara/switch_component.rb +35 -0
- data/app/components/arara/tags.rb +2 -0
- data/app/components/arara/tags/check_box.rb +63 -0
- data/app/components/arara/tags/chip_choice.rb +81 -0
- data/app/components/arara/tags/chipset.rb +39 -0
- data/app/components/arara/tags/country_select.rb +110 -0
- data/app/components/arara/tags/label.rb +78 -0
- data/app/components/arara/tags/password_field.rb +16 -0
- data/app/components/arara/tags/radio_button.rb +31 -0
- data/app/components/arara/tags/select.rb +120 -0
- data/app/components/arara/tags/text_area.rb +25 -0
- data/app/components/arara/tags/text_field.rb +31 -0
- data/app/components/arara/text_field_component.html.erb +47 -0
- data/app/components/arara/text_field_component.rb +101 -0
- data/app/components/arara/typography_component.html.erb +1 -0
- data/app/components/arara/typography_component.rb +51 -0
- data/app/controllers/arara/application_controller.rb +5 -0
- data/app/helpers/arara/application_helper.rb +4 -0
- data/app/javascript/arara/controllers/body_class_toggler_controller.js +20 -0
- data/app/javascript/arara/controllers/counter_controller.js +22 -0
- data/app/javascript/arara/controllers/demo_dialog_controller.js +24 -0
- data/app/javascript/arara/controllers/mdc_chip_set_controller.js +18 -0
- data/app/javascript/arara/controllers/mdc_data_table_controller.js +18 -0
- data/app/javascript/arara/controllers/mdc_form_field_controller.js +40 -0
- data/app/javascript/arara/controllers/mdc_icon_toggle_controller.js +18 -0
- data/app/javascript/arara/controllers/mdc_linear_progress_controller.js +18 -0
- data/app/javascript/arara/controllers/mdc_list_controller.js +23 -0
- data/app/javascript/arara/controllers/mdc_menu_controller.js +25 -0
- data/app/javascript/arara/controllers/mdc_ripple_controller.js +18 -0
- data/app/javascript/arara/controllers/mdc_select_controller.js +27 -0
- data/app/javascript/arara/controllers/mdc_slider_controller.js +21 -0
- data/app/javascript/arara/controllers/mdc_snackbar_controller.js +38 -0
- data/app/javascript/arara/controllers/mdc_switch_controller.js +18 -0
- data/app/javascript/arara/controllers/mdc_tab_bar_controller.js +18 -0
- data/app/javascript/arara/controllers/mdc_text_field_controller.js +35 -0
- data/app/javascript/arara/controllers/mdc_top_app_bar_controller.js +18 -0
- data/app/javascript/arara/controllers/rails_chip_set_choice_controller.js +31 -0
- data/app/javascript/arara/controllers/rails_chip_set_filter_controller.js +39 -0
- data/app/javascript/arara/controllers/remote_form_controller.js +79 -0
- data/app/javascript/arara/helpers/sum.js +5 -0
- data/app/javascript/arara/index.js +65 -0
- data/app/javascript/arara/scss/_material_design.scss +34 -0
- data/app/javascript/arara/scss/_tailwind.scss +4 -0
- data/app/javascript/arara/scss/arara.scss +5 -0
- data/app/javascript/arara/scss/material_design/_custom.scss +61 -0
- data/app/javascript/arara/scss/tailwind/_ripple_workaround.scss +22 -0
- data/app/jobs/arara/application_job.rb +4 -0
- data/app/mailers/arara/application_mailer.rb +6 -0
- data/app/models/arara/application_record.rb +5 -0
- data/app/views/layouts/arara/application.html.erb +15 -0
- data/config/routes.rb +2 -0
- data/lib/arara.rb +5 -0
- data/lib/arara/engine.rb +7 -0
- data/lib/arara/version.rb +3 -0
- data/lib/tasks/arara_tasks.rake +4 -0
- metadata +238 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
<div data-controller="<%= data_controller %>">
|
2
|
+
<%= content_tag(html_tag, html_options) do %>
|
3
|
+
<%= leading_icon %>
|
4
|
+
<% if textarea %>
|
5
|
+
<% if max_length && textarea %>
|
6
|
+
<div class="mdc-text-field-character-counter">0 / <%= max_length %></div>
|
7
|
+
<% end %>
|
8
|
+
<%= content_tag(html_input_tag, value, html_input_options) %>
|
9
|
+
<% else %>
|
10
|
+
<%= tag(html_input_tag, html_input_options) %>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% if user_variant == "outlined" %>
|
14
|
+
<div class="mdc-notched-outline">
|
15
|
+
<div class="mdc-notched-outline__leading"></div>
|
16
|
+
<div class="mdc-notched-outline__notch">
|
17
|
+
<% if label %>
|
18
|
+
<label class="mdc-floating-label" for="<%= id %>"><%= label %></label>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
<div class="mdc-notched-outline__trailing"></div>
|
22
|
+
</div>
|
23
|
+
<% else %>
|
24
|
+
<div class="mdc-line-ripple"></div>
|
25
|
+
<% if label && !full_width %>
|
26
|
+
<label class="mdc-floating-label" for="<%= id %>"><%= label %></label>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
<%= trailing_icon %>
|
30
|
+
<% end %>
|
31
|
+
<% if !helper_text.blank? || (max_length && !textarea) %>
|
32
|
+
<div class="<%= helper_line_class %>" data-target="<%= data_controller %>.helperLine">
|
33
|
+
<% if helper_text %>
|
34
|
+
<p
|
35
|
+
class="<%= helper_text_class %>"
|
36
|
+
id="<%= id %>-helper"
|
37
|
+
aria-hidden="true"
|
38
|
+
>
|
39
|
+
<%= helper_text %>
|
40
|
+
</p>
|
41
|
+
<% end %>
|
42
|
+
<% if max_length && !textarea %>
|
43
|
+
<div class="mdc-text-field-character-counter">0 / <%= max_length %></div>
|
44
|
+
<% end %>
|
45
|
+
</div>
|
46
|
+
<% end %>
|
47
|
+
</div>
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Arara
|
2
|
+
class TextFieldComponent < ActionView::Component::Base
|
3
|
+
include Arara::BaseComponent
|
4
|
+
|
5
|
+
attr_reader :label, :id, :name, :value, :textarea, :full_width, :helper_text, :type
|
6
|
+
|
7
|
+
with_content_areas :leading_icon, :trailing_icon, :max_length
|
8
|
+
|
9
|
+
def initialize(variant: "default", label: nil, helper_text: nil, max_length: nil, textarea: false, id:, name: nil, value: nil, full_width: false, has_error: false, type: "text", **kw)
|
10
|
+
super(tag: "div", variant: variant, **kw)
|
11
|
+
|
12
|
+
@label = label
|
13
|
+
@helper_text = helper_text
|
14
|
+
@max_length = max_length
|
15
|
+
@textarea = textarea
|
16
|
+
@id = id
|
17
|
+
@name = name
|
18
|
+
@value = value
|
19
|
+
@full_width = full_width
|
20
|
+
@has_error = has_error
|
21
|
+
@user_variant = "outlined" if textarea
|
22
|
+
@type = type
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_error?
|
26
|
+
@has_error
|
27
|
+
end
|
28
|
+
|
29
|
+
def default_html_class
|
30
|
+
classes = ["mdc-text-field"]
|
31
|
+
classes << "mdc-text-field--fullwidth" if full_width
|
32
|
+
classes << "mdc-text-field--textarea" if is_textarea?
|
33
|
+
classes << "mdc-text-field--error" if has_error?
|
34
|
+
classes << "mdc-text-field--outlined" if user_variant == "outlined"
|
35
|
+
classes.join(" ")
|
36
|
+
end
|
37
|
+
|
38
|
+
def html_options
|
39
|
+
opts = super
|
40
|
+
opts.deep_symbolize_keys!
|
41
|
+
opts[:data] = opts.has_key?(:data) ? opts[:data] : {}
|
42
|
+
opts[:data][:target] = opts[:data].has_key?(:target) ? opts[:data][:target] : ""
|
43
|
+
opts[:data][:target].concat(" #{data_controller}.element")
|
44
|
+
opts
|
45
|
+
end
|
46
|
+
|
47
|
+
def html_input_tag
|
48
|
+
return "textarea" if textarea
|
49
|
+
"input"
|
50
|
+
end
|
51
|
+
|
52
|
+
def html_input_options
|
53
|
+
opts = {
|
54
|
+
class: "mdc-text-field__input",
|
55
|
+
id: id,
|
56
|
+
type: type,
|
57
|
+
aria: {
|
58
|
+
labelledby: "#{id}-label",
|
59
|
+
controls: "#{id}-helper",
|
60
|
+
describedby: "#{id}-helper"
|
61
|
+
}
|
62
|
+
}
|
63
|
+
opts.merge!(name: name) if name
|
64
|
+
opts.merge!(value: value) if value
|
65
|
+
opts[:data] = opts.has_key?(:data) ? opts[:data] : {}
|
66
|
+
opts[:data][:action] = "focusin->#{data_controller}#handleFocus"
|
67
|
+
opts.merge!(placeholder: label) if full_width && !is_textarea?
|
68
|
+
# opts.merge!(rows: 4, cols: 40) if textarea
|
69
|
+
opts.merge!(maxlength: max_length) if max_length
|
70
|
+
opts
|
71
|
+
end
|
72
|
+
|
73
|
+
def helper_line_class
|
74
|
+
classes = ["mdc-text-field-helper-line"]
|
75
|
+
classes << "mdc-text-field-helper-line--error" if has_error?
|
76
|
+
classes.join(" ")
|
77
|
+
end
|
78
|
+
|
79
|
+
def helper_text_class
|
80
|
+
classes = ["mdc-text-field-helper-text mdc-text-field-helper-text--persistent mdc-text-field-helper-text--validation-msg"]
|
81
|
+
classes.join(" ")
|
82
|
+
end
|
83
|
+
|
84
|
+
def default_data_controller
|
85
|
+
"mdc-text-field"
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
|
89
|
+
def data_controller
|
90
|
+
"mdc-text-field"
|
91
|
+
end
|
92
|
+
|
93
|
+
def is_outlined?
|
94
|
+
user_variant == "outlined" && is_textarea?
|
95
|
+
end
|
96
|
+
|
97
|
+
def is_textarea?
|
98
|
+
textarea
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= content_tag(html_tag, class: html_class) do %><%= html_content %><% end %>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Arara
|
2
|
+
class TypographyComponent < ActionView::Component::Base
|
3
|
+
VALID_VARIANTS = %w(h1 h2 h3 h4 h5 h6 sub1 sub2 body1 body2 button caption overline)
|
4
|
+
class InvalidVariant < StandardError; end
|
5
|
+
|
6
|
+
include Arara::BaseComponent
|
7
|
+
|
8
|
+
def initialize(variant: "body1", **kw)
|
9
|
+
raise InvalidVariant.new("`#{variant}' is not a valid variant") unless VALID_VARIANTS.include?(variant.to_s)
|
10
|
+
super(variant: variant, **kw)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def default_html_class
|
15
|
+
return "mdc-typography mdc-typography--headline1" if user_variant == "h1"
|
16
|
+
return "mdc-typography mdc-typography--headline2" if user_variant == "h2"
|
17
|
+
return "mdc-typography mdc-typography--headline3" if user_variant == "h3"
|
18
|
+
return "mdc-typography mdc-typography--headline4" if user_variant == "h4"
|
19
|
+
return "mdc-typography mdc-typography--headline5" if user_variant == "h5"
|
20
|
+
return "mdc-typography mdc-typography--headline6" if user_variant == "h6"
|
21
|
+
return "mdc-typography mdc-typography--subtitle1" if user_variant == "sub1"
|
22
|
+
return "mdc-typography mdc-typography--subtitle2" if user_variant == "sub2"
|
23
|
+
return "mdc-typography mdc-typography--body1" if user_variant == "body1"
|
24
|
+
return "mdc-typography mdc-typography--body2" if user_variant == "body2"
|
25
|
+
return "mdc-typography mdc-typography--button" if user_variant == "button"
|
26
|
+
return "mdc-typography mdc-typography--caption" if user_variant == "caption"
|
27
|
+
return "mdc-typography mdc-typography--overline" if user_variant == "overline"
|
28
|
+
end
|
29
|
+
|
30
|
+
def html_tag
|
31
|
+
return user_tag if user_tag
|
32
|
+
return "h1" if user_variant == "h1"
|
33
|
+
return "h2" if user_variant == "h2"
|
34
|
+
return "h3" if user_variant == "h3"
|
35
|
+
return "h4" if user_variant == "h4"
|
36
|
+
return "h5" if user_variant == "h5"
|
37
|
+
return "h6" if user_variant == "h6"
|
38
|
+
return "h6" if user_variant == "sub1"
|
39
|
+
return "h6" if user_variant == "sub2"
|
40
|
+
return "p" if user_variant == "body1"
|
41
|
+
return "p" if user_variant == "body2"
|
42
|
+
return "span" if user_variant == "button"
|
43
|
+
return "span" if user_variant == "caption"
|
44
|
+
return "span" if user_variant == "overline"
|
45
|
+
end
|
46
|
+
|
47
|
+
def default_html_tag
|
48
|
+
html_tag
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
|
12
|
+
export default class extends Controller {
|
13
|
+
connect() {
|
14
|
+
}
|
15
|
+
|
16
|
+
toggle() {
|
17
|
+
const toggleClass = this.data.get("class")
|
18
|
+
document.body.classList.toggle(toggleClass)
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { Controller } from "stimulus"
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ["display"]
|
5
|
+
|
6
|
+
initialize() {
|
7
|
+
this.setCounter(0)
|
8
|
+
}
|
9
|
+
|
10
|
+
increase() {
|
11
|
+
this.setCounter(this.counter + 1)
|
12
|
+
}
|
13
|
+
|
14
|
+
decrease() {
|
15
|
+
this.setCounter(this.counter - 1)
|
16
|
+
}
|
17
|
+
|
18
|
+
setCounter(counter) {
|
19
|
+
this.counter = counter
|
20
|
+
this.displayTarget.textContent = counter
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
import { MDCDialog } from "@material/dialog"
|
12
|
+
|
13
|
+
export default class extends Controller {
|
14
|
+
static targets = ["button", "dialog"]
|
15
|
+
|
16
|
+
connect() {
|
17
|
+
const dialog = new MDCDialog(this.dialogTarget)
|
18
|
+
this.dialog = dialog
|
19
|
+
}
|
20
|
+
|
21
|
+
openDialog() {
|
22
|
+
this.dialog.open()
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
import { MDCChipSet } from "@material/chips"
|
12
|
+
|
13
|
+
export default class extends Controller {
|
14
|
+
connect() {
|
15
|
+
const el = new MDCChipSet(this.element)
|
16
|
+
this.el = el
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
import { MDCDataTable } from "@material/data-table"
|
12
|
+
|
13
|
+
export default class extends Controller {
|
14
|
+
connect() {
|
15
|
+
const el = new MDCDataTable(this.element)
|
16
|
+
this.el = el
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
import { MDCFormField } from "@material/form-field"
|
12
|
+
import { MDCCheckbox } from "@material/checkbox"
|
13
|
+
import { MDCRadio } from "@material/radio"
|
14
|
+
|
15
|
+
export default class extends Controller {
|
16
|
+
connect() {
|
17
|
+
const formField = new MDCFormField(this.element)
|
18
|
+
|
19
|
+
this.checkboxes = [].map.call(this.element.querySelectorAll(".mdc-checkbox"), function (el) {
|
20
|
+
const checkbox = new MDCCheckbox(el)
|
21
|
+
if (el.dataset.indeterminate == "true") {
|
22
|
+
checkbox.indeterminate = true
|
23
|
+
}
|
24
|
+
|
25
|
+
if (el.dataset.checked == "true") {
|
26
|
+
checkbox.checked = true
|
27
|
+
}
|
28
|
+
formField.input = checkbox
|
29
|
+
return checkbox
|
30
|
+
})
|
31
|
+
|
32
|
+
this.radios = [].map.call(this.element.querySelectorAll(".mdc-radio"), function (el) {
|
33
|
+
const radio = new MDCRadio(el)
|
34
|
+
formField.input = radio
|
35
|
+
return radio
|
36
|
+
})
|
37
|
+
|
38
|
+
this.el = formField
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
import { MDCIconButtonToggle } from "@material/icon-button"
|
12
|
+
|
13
|
+
export default class extends Controller {
|
14
|
+
connect() {
|
15
|
+
const el = new MDCIconButtonToggle(this.element)
|
16
|
+
this.el = el
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
import { MDCLinearProgress } from "@material/linear-progress"
|
12
|
+
|
13
|
+
export default class extends Controller {
|
14
|
+
connect() {
|
15
|
+
const el = new MDCLinearProgress(this.element)
|
16
|
+
this.el = el
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
import { MDCRipple } from "@material/ripple"
|
12
|
+
import { MDCList } from "@material/list"
|
13
|
+
|
14
|
+
export default class extends Controller {
|
15
|
+
connect() {
|
16
|
+
const list = new MDCList(this.element)
|
17
|
+
|
18
|
+
const listItemRipples = list.listElements.map((listItemEl) => new MDCRipple(listItemEl))
|
19
|
+
|
20
|
+
this.listItemRipples = listItemRipples
|
21
|
+
this.el = list
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// Visit The Stimulus Handbook for more details
|
2
|
+
// https://stimulusjs.org/handbook/introduction
|
3
|
+
//
|
4
|
+
// This example controller works with specially annotated HTML like:
|
5
|
+
//
|
6
|
+
// <div data-controller="hello">
|
7
|
+
// <h1 data-target="hello.output"></h1>
|
8
|
+
// </div>
|
9
|
+
|
10
|
+
import { Controller } from "stimulus"
|
11
|
+
import { MDCMenu } from "@material/menu"
|
12
|
+
|
13
|
+
export default class extends Controller {
|
14
|
+
static targets = ["button", "menu"]
|
15
|
+
|
16
|
+
connect() {
|
17
|
+
const menu = new MDCMenu(this.menuTarget)
|
18
|
+
this.menu = menu
|
19
|
+
}
|
20
|
+
|
21
|
+
openMenu() {
|
22
|
+
const isOpen = this.menuTarget.classList.contains("mdc-menu-surface--open")
|
23
|
+
this.menu.open = !isOpen
|
24
|
+
}
|
25
|
+
}
|