arara 0.2.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.
- 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,22 @@
|
|
|
1
|
+
<%= content_tag(html_tag, html_options) do %>
|
|
2
|
+
<%= tag(:input, type: :hidden, id: id, name: name, value: selected_value, data: { target: 'mdc-select.input' }) %>
|
|
3
|
+
<div class="mdc-select__anchor custom-enhanced-select-width">
|
|
4
|
+
<i class="mdc-select__dropdown-icon"></i>
|
|
5
|
+
<div class="mdc-select__selected-text" tabindex="0" aria-disabled="false"><%= selected_label %></div>
|
|
6
|
+
<% if user_variant == "outlined" %>
|
|
7
|
+
<div class="mdc-notched-outline mdc-notched-outline--upgraded">
|
|
8
|
+
<div class="mdc-notched-outline__leading"></div>
|
|
9
|
+
<div class="mdc-notched-outline__notch"><label id="outlined-label" class="mdc-floating-label" style=""><%= label %></label></div>
|
|
10
|
+
<div class="mdc-notched-outline__trailing"></div>
|
|
11
|
+
</div>
|
|
12
|
+
<% else %>
|
|
13
|
+
<span class="mdc-floating-label"><%= label %></span>
|
|
14
|
+
<div class="mdc-line-ripple"></div>
|
|
15
|
+
<% end %>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="mdc-select__menu mdc-menu mdc-menu-surface demo-enhanced-select custom-enhanced-select-width">
|
|
18
|
+
<ul class="mdc-list">
|
|
19
|
+
<%= content %>
|
|
20
|
+
</ul>
|
|
21
|
+
</div>
|
|
22
|
+
<% end %>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Arara
|
|
2
|
+
class SelectComponent < ActionView::Component::Base
|
|
3
|
+
include Arara::BaseComponent
|
|
4
|
+
attr_reader :label, :id, :name, :selected_value, :selected_label
|
|
5
|
+
|
|
6
|
+
validates :content, presence: true
|
|
7
|
+
|
|
8
|
+
def initialize(variant: "default", id: nil, name: nil, label:, selected_value: nil, selected_label: nil, **kw)
|
|
9
|
+
super(tag: "div", variant: variant, **kw)
|
|
10
|
+
|
|
11
|
+
@id = id
|
|
12
|
+
@name = name
|
|
13
|
+
@label = label
|
|
14
|
+
@selected_value = selected_value
|
|
15
|
+
@selected_label = selected_label
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def default_data_controller
|
|
19
|
+
"mdc-select"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def default_html_class
|
|
23
|
+
return "mdc-select mdc-select--outlined" if user_variant == "outlined"
|
|
24
|
+
"mdc-select"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Arara
|
|
2
|
+
class SelectItemComponent < ActionView::Component::Base
|
|
3
|
+
include Arara::BaseComponent
|
|
4
|
+
attr_reader :value, :label, :blank, :selected, :disabled
|
|
5
|
+
|
|
6
|
+
with_options if: -> { blank == false } do |extended|
|
|
7
|
+
extended.validates :value, presence: true
|
|
8
|
+
extended.validates :label, presence: true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def initialize(value: nil, label: nil, blank: false, selected: false, disabled: false, **kw)
|
|
12
|
+
super(tag: "li", **kw)
|
|
13
|
+
|
|
14
|
+
@value = value
|
|
15
|
+
@label = label
|
|
16
|
+
@blank = blank
|
|
17
|
+
@disabled = disabled
|
|
18
|
+
@selected = selected
|
|
19
|
+
if blank
|
|
20
|
+
@value = ""
|
|
21
|
+
label = nil
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def default_html_class
|
|
26
|
+
return "mdc-list-item mdc-list-item--selected" if selected
|
|
27
|
+
"mdc-list-item"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def html_options
|
|
31
|
+
opts = super
|
|
32
|
+
|
|
33
|
+
opts[:data] ||= {}
|
|
34
|
+
opts[:aria] ||= {}
|
|
35
|
+
|
|
36
|
+
opts[:role] = "option"
|
|
37
|
+
opts[:aria][:selected] = selected
|
|
38
|
+
opts[:tabindex] = "-1"
|
|
39
|
+
opts[:data][:value] = value
|
|
40
|
+
|
|
41
|
+
opts[:disabled] = "" if disabled
|
|
42
|
+
opts
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<%= content_tag(html_tag, html_options) do %>
|
|
2
|
+
<% if has_connector? %>
|
|
3
|
+
<%= content_tag(:div, connector_root_options) do %>
|
|
4
|
+
<% content_tag(:span, nil, connector_line_options) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<%= content_tag(:span, label_root_options) do %>
|
|
8
|
+
<%= content_tag(:span, icon_container_options) do %>
|
|
9
|
+
<%= content_tag(:svg, icon_options) do %>
|
|
10
|
+
<%= icon_tag %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<span class="MuiStepLabel-labelContainer">
|
|
14
|
+
<%= content_tag(:span, step_label_options) do %>
|
|
15
|
+
<%= title %>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% if sub_title %>
|
|
18
|
+
<span class="MuiTypography-root MuiTypography-caption"><%= sub_title %></span>
|
|
19
|
+
<% end %>
|
|
20
|
+
</span>
|
|
21
|
+
<% end %>
|
|
22
|
+
<div class="MuiStepContent-root" icon="1">
|
|
23
|
+
<% if has_vertical_content? %>
|
|
24
|
+
<%= html_content %>
|
|
25
|
+
<% end %>
|
|
26
|
+
</div>
|
|
27
|
+
<% end %>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
class Arara::StepComponent < ActionView::Component::Base
|
|
2
|
+
include Arara::BaseComponent
|
|
3
|
+
attr_reader :title, :sub_title, :orientation, :alternative_label, :active, :completed, :disabled, :editable, :link, :order, :connector
|
|
4
|
+
|
|
5
|
+
def initialize(title: "", sub_title: nil, orientation: "horizontal", alternative_label: false, active: false, completed: false, disabled: false, editable: false, link: nil, order: 0, connector: false, **kw)
|
|
6
|
+
@orientation = orientation
|
|
7
|
+
@alternative_label = alternative_label
|
|
8
|
+
@active = active
|
|
9
|
+
@completed = completed
|
|
10
|
+
@disabled = disabled
|
|
11
|
+
@editable = editable
|
|
12
|
+
@link = link
|
|
13
|
+
@title = title
|
|
14
|
+
@sub_title = sub_title
|
|
15
|
+
@order = order
|
|
16
|
+
@connector = connector
|
|
17
|
+
super(tag: "div", **kw)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def default_html_class
|
|
21
|
+
classes = %w(MuiStep-root)
|
|
22
|
+
classes.push("MuiStep-horizontal") if orientation == "horizontal"
|
|
23
|
+
classes.push("MuiStep-vertical") if orientation == "vertical"
|
|
24
|
+
classes.push("MuiStep-alternativeLabel") if alternative_label
|
|
25
|
+
classes.push("MuiStep-completed") if completed
|
|
26
|
+
classes.join(" ")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def label_root_options
|
|
30
|
+
classes = %w(MuiStepLabel-root)
|
|
31
|
+
classes.push("MuiStepLabel-horizontal") if orientation == "horizontal"
|
|
32
|
+
classes.push("MuiStepLabel-vertical") if orientation == "vertical"
|
|
33
|
+
classes.push("MuiStepLabel-alternativeLabel") if alternative_label
|
|
34
|
+
{
|
|
35
|
+
class: classes.join(" ")
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def icon_container_options
|
|
40
|
+
classes = %w(MuiStepLabel-iconContainer)
|
|
41
|
+
classes.push("MuiStepLabel-alternativeLabel") if alternative_label
|
|
42
|
+
{
|
|
43
|
+
class: classes.join(" "),
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def icon_options
|
|
48
|
+
classes = %w(MuiSvgIcon-root MuiStepIcon-root)
|
|
49
|
+
classes.push("MuiStepIcon-completed") if completed
|
|
50
|
+
classes.push("MuiStepIcon-active") if active
|
|
51
|
+
{
|
|
52
|
+
class: classes.join(" "),
|
|
53
|
+
focusable: false,
|
|
54
|
+
'view-box': "0 0 24 24",
|
|
55
|
+
'aria-hidden': true,
|
|
56
|
+
role: "presentation"
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def icon_tag
|
|
61
|
+
if completed
|
|
62
|
+
return content_tag(:path, nil, d: "M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24zm-2 17l-5-5 1.4-1.4 3.6 3.6 7.6-7.6L19 8l-9 9z")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
content_tag(:circle, nil, cx: 12, cy: 12, r: 12) +
|
|
66
|
+
content_tag(:text, order, class: "MuiStepIcon-text", x: "12", y: "16", 'text-anchor': "middle")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def step_label_options
|
|
70
|
+
classes = %w(MuiTypography-root MuiStepLabel-label)
|
|
71
|
+
classes.push('MuiStepLabel-alternativeLabel') if alternative_label
|
|
72
|
+
classes.push('MuiStepLabel-completed') if completed
|
|
73
|
+
classes.push('MuiStepLabel-active') if active
|
|
74
|
+
classes.push('MuiTypography-body2 MuiTypography-displayBlock')
|
|
75
|
+
{ class: classes.join(" ") }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def has_connector?
|
|
79
|
+
connector
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def connector_root_options
|
|
83
|
+
classes = %w(MuiStepConnector-root)
|
|
84
|
+
classes.push('MuiStepConnector-horizontal') if orientation == "horizontal"
|
|
85
|
+
classes.push('MuiStepConnector-vertical') if orientation == "vertical"
|
|
86
|
+
classes.push('MuiStepConnector-alternativeLabel') if alternative_label
|
|
87
|
+
classes.push('MuiStepConnector-active')
|
|
88
|
+
{ class: classes.join(" ") }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def connector_line_options
|
|
92
|
+
classes = %w(MuiStepConnector-line)
|
|
93
|
+
classes.push('MuiStepConnector-lineHorizontal') if orientation == "horizontal"
|
|
94
|
+
{ class: classes.join(" ") }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def has_vertical_content?
|
|
98
|
+
orientation == "vertical" && active && !html_content.empty?
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class Arara::StepConnectorComponent < ActionView::Component::Base
|
|
2
|
+
include Arara::BaseComponent
|
|
3
|
+
attr_reader :orientation, :active, :alternative_label
|
|
4
|
+
|
|
5
|
+
def initialize(orientation: 'horizontal', active: false, alternative_label: false, **kw)
|
|
6
|
+
@orientation = orientation
|
|
7
|
+
@active = active
|
|
8
|
+
@alternative_label = alternative_label
|
|
9
|
+
|
|
10
|
+
super(tag: 'div', **kw)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def default_html_class
|
|
14
|
+
classes = %w(MuiStepConnector-root)
|
|
15
|
+
classes.push("MuiStepConnector-horizontal") if orientation == "horizontal"
|
|
16
|
+
classes.push("MuiStepConnector-vertical") if orientation == "vertical"
|
|
17
|
+
classes.push("MuiStepConnector-active") if active
|
|
18
|
+
classes.push("Mui-disabled") unless active
|
|
19
|
+
classes.push("MuiStepConnector-alternativeLabel") if alternative_label
|
|
20
|
+
classes.join(" ")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def line_options
|
|
24
|
+
classes = %w(MuiStepConnector-line)
|
|
25
|
+
classes.push("MuiStepConnector-lineHorizontal") if orientation == "horizontal"
|
|
26
|
+
classes.push("MuiStepConnector-lineVertical") if orientation == "vertical"
|
|
27
|
+
{
|
|
28
|
+
class: classes.join(" ")
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class Arara::StepperComponent < ActionView::Component::Base
|
|
2
|
+
include Arara::BaseComponent
|
|
3
|
+
attr_reader :orientation, :alternative_label
|
|
4
|
+
|
|
5
|
+
validates :content, presence: true
|
|
6
|
+
|
|
7
|
+
def initialize(orientation: "horizontal", alternative_label: false, **kw)
|
|
8
|
+
@orientation = orientation
|
|
9
|
+
@alternative_label = alternative_label
|
|
10
|
+
super(tag: "div", **kw)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def default_html_class
|
|
14
|
+
classes = %w(MuiStepper-root)
|
|
15
|
+
classes.push("MuiStepper-horizontal") if orientation == "horizontal"
|
|
16
|
+
classes.push("MuiStepper-vertical") if orientation == "vertical"
|
|
17
|
+
classes.push("MuiStepper-alternativeLabel") if alternative_label
|
|
18
|
+
classes.join(" ")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Arara
|
|
2
|
+
class SwitchComponent < ActionView::Component::Base
|
|
3
|
+
include Arara::BaseComponent
|
|
4
|
+
attr_reader :id, :checked
|
|
5
|
+
|
|
6
|
+
def initialize(id:, checked: false, **kw)
|
|
7
|
+
super(tag: "div", **kw)
|
|
8
|
+
@id = id
|
|
9
|
+
@checked = checked
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def default_html_class
|
|
13
|
+
return "mdc-switch mdc-switch--checked" if checked
|
|
14
|
+
"mdc-switch"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def default_data_controller
|
|
18
|
+
"mdc-switch"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def input_options
|
|
22
|
+
opts = {
|
|
23
|
+
type: "checkbox",
|
|
24
|
+
id: id,
|
|
25
|
+
class: "mdc-switch__native-control",
|
|
26
|
+
role: "switch",
|
|
27
|
+
aria: {
|
|
28
|
+
checked: checked
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
opts[:checked] = "" if checked
|
|
32
|
+
opts
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "action_view/helpers/tags/checkable"
|
|
4
|
+
|
|
5
|
+
module Arara
|
|
6
|
+
module Tags # :nodoc:
|
|
7
|
+
class CheckBox < ActionView::Helpers::Tags::Base # :nodoc:
|
|
8
|
+
include ActionView::Helpers::Tags::Checkable
|
|
9
|
+
|
|
10
|
+
def initialize(object_name, method_name, template_object, checked_value, unchecked_value, options)
|
|
11
|
+
@checked_value = checked_value
|
|
12
|
+
@unchecked_value = unchecked_value
|
|
13
|
+
super(object_name, method_name, template_object, options)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def render
|
|
17
|
+
options = @options.stringify_keys
|
|
18
|
+
options["type"] = "checkbox"
|
|
19
|
+
options["value"] = @checked_value
|
|
20
|
+
options["checked"] = "checked" if input_checked?(options)
|
|
21
|
+
|
|
22
|
+
if options["multiple"]
|
|
23
|
+
add_default_name_and_id_for_value(@checked_value, options)
|
|
24
|
+
options.delete("multiple")
|
|
25
|
+
else
|
|
26
|
+
add_default_name_and_id(options)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
include_hidden = options.delete("include_hidden") { true }
|
|
30
|
+
checkbox = @template_object.template.render(Arara::CheckboxComponent, options.symbolize_keys)
|
|
31
|
+
|
|
32
|
+
if include_hidden
|
|
33
|
+
hidden = hidden_field_for_checkbox(options)
|
|
34
|
+
hidden + checkbox
|
|
35
|
+
else
|
|
36
|
+
checkbox
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
def checked?(value)
|
|
42
|
+
case value
|
|
43
|
+
when TrueClass, FalseClass
|
|
44
|
+
value == !!@checked_value
|
|
45
|
+
when NilClass
|
|
46
|
+
false
|
|
47
|
+
when String
|
|
48
|
+
value == @checked_value
|
|
49
|
+
else
|
|
50
|
+
if value.respond_to?(:include?)
|
|
51
|
+
value.include?(@checked_value)
|
|
52
|
+
else
|
|
53
|
+
value.to_i == @checked_value.to_i
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def hidden_field_for_checkbox(options)
|
|
59
|
+
@unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value)) : "".html_safe
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "action_view/helpers/tags/checkable"
|
|
4
|
+
|
|
5
|
+
module Arara
|
|
6
|
+
module Tags # :nodoc:
|
|
7
|
+
class ChipChoice < ActionView::Helpers::Tags::Base # :nodoc:
|
|
8
|
+
def initialize(object_name, method_name, template_object, checked_value, unchecked_value, options)
|
|
9
|
+
@checked_value = checked_value
|
|
10
|
+
@unchecked_value = unchecked_value
|
|
11
|
+
super(object_name, method_name, template_object, options)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def render
|
|
15
|
+
options = @options.stringify_keys
|
|
16
|
+
options["type"] = "checkbox"
|
|
17
|
+
options["value"] = @checked_value
|
|
18
|
+
options["checked"] = "checked" if input_checked?(options)
|
|
19
|
+
options["selected"] = !!options["checked"]
|
|
20
|
+
|
|
21
|
+
if options["multiple"]
|
|
22
|
+
add_default_name_and_id_for_value(@checked_value, options)
|
|
23
|
+
options.delete("multiple")
|
|
24
|
+
else
|
|
25
|
+
add_default_name_and_id(options)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
include_hidden = options.delete("include_hidden") { true }
|
|
29
|
+
|
|
30
|
+
options["data"] ||= {}
|
|
31
|
+
options["data"]["rails-chip-set-filter-target"] = "rails-chip-set-filter.#{options["id"].camelize(:lower)}"
|
|
32
|
+
checkbox = @template_object.template.render(Arara::ChipComponent, options.symbolize_keys)
|
|
33
|
+
|
|
34
|
+
if include_hidden
|
|
35
|
+
hidden = hidden_field_for_checkbox(options)
|
|
36
|
+
hidden + checkbox
|
|
37
|
+
else
|
|
38
|
+
checkbox
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
def input_checked?(options)
|
|
44
|
+
if options.has_key?("checked")
|
|
45
|
+
checked = options.delete "checked"
|
|
46
|
+
checked == true || checked == "checked"
|
|
47
|
+
else
|
|
48
|
+
checked?(value_before_type_cast)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def checked?(value)
|
|
53
|
+
case value
|
|
54
|
+
when TrueClass, FalseClass
|
|
55
|
+
value == !!@checked_value
|
|
56
|
+
when NilClass
|
|
57
|
+
false
|
|
58
|
+
when String
|
|
59
|
+
value == @checked_value
|
|
60
|
+
else
|
|
61
|
+
if value.respond_to?(:include?)
|
|
62
|
+
value.include?(@checked_value)
|
|
63
|
+
else
|
|
64
|
+
value.to_i == @checked_value.to_i
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def hidden_field_for_checkbox(options)
|
|
70
|
+
value = options["selected"] ? options["value"] : "0"
|
|
71
|
+
tag(
|
|
72
|
+
"input", options.slice("name", "disabled", "form").
|
|
73
|
+
merge!(
|
|
74
|
+
"type" => "hidden", "value" => value,
|
|
75
|
+
"data": { "target": "rails-chip-set-filter.#{options["id"].camelize(:lower)}"
|
|
76
|
+
})
|
|
77
|
+
)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|