better_ui 0.2.0 → 0.6.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 +4 -4
- data/app/components/better_ui/application/main/component.html.erb +1 -1
- data/app/components/better_ui/application/sidebar/component.html.erb +77 -18
- data/app/components/better_ui/application/sidebar/component.rb +63 -5
- data/app/components/better_ui/general/accordion/component.html.erb +5 -0
- data/app/components/better_ui/general/accordion/component.rb +92 -0
- data/app/components/better_ui/general/accordion/item_component.html.erb +12 -0
- data/app/components/better_ui/general/accordion/item_component.rb +176 -0
- data/app/components/better_ui/general/button/component.html.erb +8 -8
- data/app/components/better_ui/general/button/component.rb +11 -11
- data/app/components/better_ui/general/dropdown/component.html.erb +21 -7
- data/app/components/better_ui/general/dropdown/component.rb +27 -54
- data/app/components/better_ui/general/dropdown/item_component.rb +2 -1
- data/app/components/better_ui/general/field/component.html.erb +3 -3
- data/app/components/better_ui/general/field/component.rb +3 -3
- data/app/components/better_ui/general/grid/cell_component.html.erb +3 -0
- data/app/components/better_ui/general/grid/cell_component.rb +390 -0
- data/app/components/better_ui/general/grid/component.html.erb +3 -0
- data/app/components/better_ui/general/grid/component.rb +301 -0
- data/app/components/better_ui/general/heading/component.html.erb +1 -1
- data/app/components/better_ui/general/icon/component.rb +2 -1
- data/app/components/better_ui/general/input/checkbox/component.rb +10 -10
- data/app/components/better_ui/general/input/pin/component.html.erb +1 -0
- data/app/components/better_ui/general/input/pin/component.rb +201 -0
- data/app/components/better_ui/general/input/radio/component.rb +10 -10
- data/app/components/better_ui/general/input/rating/component.html.erb +4 -0
- data/app/components/better_ui/general/input/rating/component.rb +272 -0
- data/app/components/better_ui/general/input/select/component.html.erb +76 -14
- data/app/components/better_ui/general/input/select/component.rb +166 -101
- data/app/components/better_ui/general/input/toggle/component.html.erb +5 -0
- data/app/components/better_ui/general/input/toggle/component.rb +242 -0
- data/app/components/better_ui/general/link/component.rb +1 -1
- data/app/components/better_ui/general/modal/component.html.erb +5 -42
- data/app/components/better_ui/general/modal/component.rb +22 -140
- data/app/components/better_ui/general/modal/modal_component.html.erb +52 -0
- data/app/components/better_ui/general/modal/modal_component.rb +160 -0
- data/app/components/better_ui/general/tabs/component.html.erb +10 -2
- data/app/components/better_ui/general/tabs/component.rb +26 -8
- data/app/components/better_ui/general/tabs/panel_component.rb +1 -1
- data/app/components/better_ui/general/tabs/tab_component.rb +1 -1
- data/app/components/better_ui/general/text/component.html.erb +1 -0
- data/app/components/better_ui/general/text/component.rb +194 -0
- data/app/helpers/better_ui/application_helper.rb +11 -4
- data/app/helpers/better_ui/general/components/accordion/accordion_helper.rb +73 -0
- data/app/helpers/better_ui/general/components/button/button_helper.rb +6 -6
- data/app/helpers/better_ui/general/components/dropdown/dropdown_helper.rb +9 -0
- data/app/helpers/better_ui/general/components/dropdown/item_helper.rb +13 -7
- data/app/helpers/better_ui/general/components/field/field_helper.rb +4 -4
- data/app/helpers/better_ui/general/components/grid/grid_helper.rb +145 -0
- data/app/helpers/better_ui/general/components/input/pin/pin_helper.rb +76 -0
- data/app/helpers/better_ui/general/components/input/rating/rating_helper.rb +70 -0
- data/app/helpers/better_ui/general/components/input/select/select_helper.rb +47 -31
- data/app/helpers/better_ui/general/components/input/toggle/toggle_helper.rb +77 -0
- data/app/helpers/better_ui/general/components/modal/modal_helper.rb +34 -44
- data/app/helpers/better_ui/general/components/tabs/tabs_helper.rb +59 -26
- data/app/helpers/better_ui/general/components/text/text_helper.rb +83 -0
- data/lib/better_ui/version.rb +1 -1
- data/lib/better_ui.rb +1 -0
- metadata +26 -2
@@ -1,13 +1,27 @@
|
|
1
|
-
<div <%=
|
2
|
-
|
1
|
+
<div class="relative <%= @classes %> <%= fullwidth_classes %>"
|
2
|
+
data-controller="bui-dropdown"
|
3
|
+
data-bui-dropdown-open-value="false"
|
4
|
+
data-bui-dropdown-selectable-value="<%= @selectable.to_s %>"
|
5
|
+
<%= tag.attributes(@html_options.except(:class)) %>>
|
6
|
+
|
7
|
+
<button type="button"
|
8
|
+
class="items-center border font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors <%= dynamic_trigger_classes %> <%= fullwidth_classes %>"
|
9
|
+
data-bui-dropdown-target="trigger"
|
10
|
+
data-action="click->bui-dropdown#toggle keydown->bui-dropdown#keydown"
|
11
|
+
aria-expanded="false"
|
12
|
+
aria-haspopup="true">
|
3
13
|
<%= @trigger %>
|
4
|
-
|
5
|
-
|
6
|
-
|
14
|
+
<% if @show_chevron %>
|
15
|
+
<%= bui_icon("chevron-down", size: :small, classes: "ml-2 -mr-1") %>
|
16
|
+
<% end %>
|
7
17
|
</button>
|
8
18
|
|
9
|
-
<div <%=
|
10
|
-
|
19
|
+
<div class="absolute z-[1000] my-2 origin-top-right bg-white border border-gray-200 shadow-lg focus:outline-none <%= dynamic_menu_classes %> <%= fullwidth_classes %>"
|
20
|
+
data-bui-dropdown-target="menu"
|
21
|
+
role="menu"
|
22
|
+
aria-orientation="vertical"
|
23
|
+
style="display: none;">
|
24
|
+
<div class="py-1" role="none" data-action="click->bui-dropdown#itemClick">
|
11
25
|
<%= content %>
|
12
26
|
</div>
|
13
27
|
</div>
|
@@ -4,16 +4,11 @@ module BetterUi
|
|
4
4
|
module General
|
5
5
|
module Dropdown
|
6
6
|
class Component < ViewComponent::Base
|
7
|
-
|
7
|
+
include BetterUi::General::Components::Icon::IconHelper
|
8
|
+
|
9
|
+
attr_reader :trigger, :position, :theme, :size, :rounded, :animation, :fullwidth, :show_chevron, :selectable, :classes, :html_options
|
8
10
|
|
9
|
-
# Classi base per
|
10
|
-
DROPDOWN_CONTAINER_CLASSES = "relative inline-block"
|
11
|
-
|
12
|
-
# Classi base per il pulsante trigger
|
13
|
-
DROPDOWN_TRIGGER_BASE_CLASSES = "inline-flex items-center justify-center border font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors"
|
14
|
-
|
15
|
-
# Classi base per il menu dropdown
|
16
|
-
DROPDOWN_MENU_BASE_CLASSES = "absolute z-50 mt-2 origin-top-right bg-white border border-gray-200 shadow-lg focus:outline-none"
|
11
|
+
# Classi base spostate nel template HTML per migliore leggibilità
|
17
12
|
|
18
13
|
# Temi per il trigger del dropdown con classi Tailwind dirette
|
19
14
|
DROPDOWN_TRIGGER_THEME = {
|
@@ -59,6 +54,12 @@ module BetterUi
|
|
59
54
|
none: ""
|
60
55
|
}.freeze
|
61
56
|
|
57
|
+
# Stili per full-width del trigger
|
58
|
+
DROPDOWN_FULLWIDTH = {
|
59
|
+
true => "w-full text-left justify-start",
|
60
|
+
false => "inline-flex justify-center"
|
61
|
+
}.freeze
|
62
|
+
|
62
63
|
def initialize(
|
63
64
|
trigger:,
|
64
65
|
position: :bottom,
|
@@ -66,6 +67,9 @@ module BetterUi
|
|
66
67
|
size: :medium,
|
67
68
|
rounded: :medium,
|
68
69
|
animation: :fade,
|
70
|
+
fullwidth: false,
|
71
|
+
show_chevron: true,
|
72
|
+
selectable: false,
|
69
73
|
classes: nil,
|
70
74
|
**html_options
|
71
75
|
)
|
@@ -75,75 +79,40 @@ module BetterUi
|
|
75
79
|
@size = size.to_sym
|
76
80
|
@rounded = rounded.to_sym
|
77
81
|
@animation = animation.to_sym
|
82
|
+
@fullwidth = fullwidth
|
83
|
+
@show_chevron = show_chevron
|
84
|
+
@selectable = selectable
|
78
85
|
@classes = classes
|
79
86
|
@html_options = html_options
|
80
87
|
|
81
88
|
validate_params
|
82
89
|
end
|
83
90
|
|
84
|
-
|
85
|
-
def container_classes
|
91
|
+
def fullwidth_classes
|
86
92
|
[
|
87
|
-
|
88
|
-
@classes
|
93
|
+
get_fullwidth_classes
|
89
94
|
].compact.join(" ")
|
90
95
|
end
|
91
96
|
|
92
|
-
#
|
93
|
-
def
|
97
|
+
# Restituisce solo le classi dinamiche per il trigger
|
98
|
+
def dynamic_trigger_classes
|
94
99
|
[
|
95
|
-
DROPDOWN_TRIGGER_BASE_CLASSES,
|
96
100
|
get_trigger_theme_classes,
|
97
101
|
get_trigger_size_classes,
|
98
102
|
get_trigger_rounded_classes
|
99
103
|
].compact.join(" ")
|
100
104
|
end
|
101
105
|
|
102
|
-
#
|
103
|
-
def
|
106
|
+
# Restituisce solo le classi dinamiche per il menu
|
107
|
+
def dynamic_menu_classes
|
104
108
|
[
|
105
|
-
DROPDOWN_MENU_BASE_CLASSES,
|
106
109
|
get_position_classes,
|
107
110
|
get_animation_classes,
|
108
111
|
get_menu_rounded_classes
|
109
112
|
].compact.join(" ")
|
110
113
|
end
|
111
114
|
|
112
|
-
#
|
113
|
-
def container_attributes
|
114
|
-
attrs = {
|
115
|
-
class: container_classes,
|
116
|
-
"data-dropdown": true
|
117
|
-
}
|
118
|
-
|
119
|
-
@html_options.except(:class).each do |key, value|
|
120
|
-
attrs[key] = value
|
121
|
-
end
|
122
|
-
|
123
|
-
attrs
|
124
|
-
end
|
125
|
-
|
126
|
-
# Restituisce gli attributi per il trigger
|
127
|
-
def trigger_attributes
|
128
|
-
{
|
129
|
-
type: "button",
|
130
|
-
class: trigger_classes,
|
131
|
-
"data-dropdown-trigger": true,
|
132
|
-
"aria-expanded": "false",
|
133
|
-
"aria-haspopup": "true"
|
134
|
-
}
|
135
|
-
end
|
136
|
-
|
137
|
-
# Restituisce gli attributi per il menu
|
138
|
-
def menu_attributes
|
139
|
-
{
|
140
|
-
class: menu_classes,
|
141
|
-
"data-dropdown-menu": true,
|
142
|
-
role: "menu",
|
143
|
-
"aria-orientation": "vertical",
|
144
|
-
style: "display: none;"
|
145
|
-
}
|
146
|
-
end
|
115
|
+
# Metodi per attributi rimossi - ora gestiti direttamente nel template HTML
|
147
116
|
|
148
117
|
# Verifica se rendere il componente
|
149
118
|
def render?
|
@@ -176,6 +145,10 @@ module BetterUi
|
|
176
145
|
DROPDOWN_ANIMATION[@animation] || DROPDOWN_ANIMATION[:fade]
|
177
146
|
end
|
178
147
|
|
148
|
+
def get_fullwidth_classes
|
149
|
+
DROPDOWN_FULLWIDTH[@fullwidth] || DROPDOWN_FULLWIDTH[false]
|
150
|
+
end
|
151
|
+
|
179
152
|
def validate_params
|
180
153
|
validate_theme
|
181
154
|
validate_size
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%# Form field component template %>
|
2
2
|
<div class="<%= BASE_CLASSES %>">
|
3
|
-
<% if
|
3
|
+
<% if text.present? %>
|
4
4
|
<label for="<%= id %>" class="<%= LABEL_CLASSES %>">
|
5
|
-
<%=
|
5
|
+
<%= text %>
|
6
6
|
<% if required %>
|
7
7
|
<span class="<%= REQUIRED_CLASSES %>">*</span>
|
8
8
|
<% end %>
|
@@ -24,4 +24,4 @@
|
|
24
24
|
<%= help_text %>
|
25
25
|
</div>
|
26
26
|
<% end %>
|
27
|
-
</div>
|
27
|
+
</div>
|
@@ -4,7 +4,7 @@ module BetterUi
|
|
4
4
|
module General
|
5
5
|
module Field
|
6
6
|
class Component < ViewComponent::Base
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :text, :name, :required, :error, :help_text, :id
|
8
8
|
|
9
9
|
renders_one :input
|
10
10
|
|
@@ -14,8 +14,8 @@ module BetterUi
|
|
14
14
|
ERROR_CLASSES = "text-sm text-red-600 mt-1"
|
15
15
|
HELP_TEXT_CLASSES = "text-sm text-gray-500 mt-1"
|
16
16
|
|
17
|
-
def initialize(
|
18
|
-
@
|
17
|
+
def initialize(text:, name:, required: false, error: nil, help_text: nil, id: nil)
|
18
|
+
@text = text
|
19
19
|
@name = name
|
20
20
|
@required = required
|
21
21
|
@error = error
|
@@ -0,0 +1,390 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Grid
|
6
|
+
class CellComponent < ViewComponent::Base
|
7
|
+
attr_reader :col, :row, :col_start, :col_end, :row_start, :row_end,
|
8
|
+
:justify_self, :align_self, :classes, :id, :html_options
|
9
|
+
|
10
|
+
# Validazione valori supportati
|
11
|
+
VALID_COL_SPANS = (1..12).to_a + [:auto, :full].freeze
|
12
|
+
VALID_ROW_SPANS = (1..6).to_a + [:auto, :full].freeze
|
13
|
+
VALID_COL_POSITIONS = (1..13).to_a + [:auto].freeze
|
14
|
+
VALID_ROW_POSITIONS = (1..7).to_a + [:auto].freeze
|
15
|
+
VALID_BREAKPOINTS = [:sm, :md, :lg, :xl].freeze
|
16
|
+
|
17
|
+
# Justify self options
|
18
|
+
GRID_CELL_JUSTIFY_SELF = {
|
19
|
+
auto: 'justify-self-auto', start: 'justify-self-start',
|
20
|
+
center: 'justify-self-center', end: 'justify-self-end',
|
21
|
+
stretch: 'justify-self-stretch'
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
# Align self options
|
25
|
+
GRID_CELL_ALIGN_SELF = {
|
26
|
+
auto: 'self-auto', start: 'self-start',
|
27
|
+
center: 'self-center', end: 'self-end',
|
28
|
+
stretch: 'self-stretch'
|
29
|
+
}.freeze
|
30
|
+
|
31
|
+
def initialize(
|
32
|
+
col: 1,
|
33
|
+
row: nil,
|
34
|
+
col_start: nil,
|
35
|
+
col_end: nil,
|
36
|
+
row_start: nil,
|
37
|
+
row_end: nil,
|
38
|
+
justify_self: nil,
|
39
|
+
align_self: nil,
|
40
|
+
classes: '',
|
41
|
+
id: nil,
|
42
|
+
**html_options
|
43
|
+
)
|
44
|
+
@col = normalize_cell_col_with_defaults(col)
|
45
|
+
@row = normalize_cell_row_with_defaults(row) if row
|
46
|
+
@col_start = normalize_cell_position_with_defaults(col_start) if col_start
|
47
|
+
@col_end = normalize_cell_position_with_defaults(col_end) if col_end
|
48
|
+
@row_start = normalize_cell_position_with_defaults(row_start) if row_start
|
49
|
+
@row_end = normalize_cell_position_with_defaults(row_end) if row_end
|
50
|
+
@justify_self = justify_self&.to_sym
|
51
|
+
@align_self = align_self&.to_sym
|
52
|
+
@classes = classes
|
53
|
+
@id = id
|
54
|
+
@html_options = html_options
|
55
|
+
|
56
|
+
validate_cell_params
|
57
|
+
end
|
58
|
+
|
59
|
+
def combined_classes
|
60
|
+
[
|
61
|
+
generate_col_classes,
|
62
|
+
generate_row_classes,
|
63
|
+
generate_col_start_classes,
|
64
|
+
generate_col_end_classes,
|
65
|
+
generate_row_start_classes,
|
66
|
+
generate_row_end_classes,
|
67
|
+
@justify_self ? GRID_CELL_JUSTIFY_SELF[@justify_self] : nil,
|
68
|
+
@align_self ? GRID_CELL_ALIGN_SELF[@align_self] : nil,
|
69
|
+
@classes,
|
70
|
+
@html_options[:class]
|
71
|
+
].compact.join(" ")
|
72
|
+
end
|
73
|
+
|
74
|
+
def cell_attributes
|
75
|
+
attrs = {
|
76
|
+
class: combined_classes,
|
77
|
+
id: @id
|
78
|
+
}
|
79
|
+
|
80
|
+
@html_options.except(:class).each do |key, value|
|
81
|
+
attrs[key] = value
|
82
|
+
end
|
83
|
+
|
84
|
+
attrs
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
# Genera classi CSS dinamicamente invece di usare costanti massive
|
90
|
+
def generate_col_span_class(span, breakpoint = nil)
|
91
|
+
prefix = breakpoint ? "#{breakpoint}:" : ""
|
92
|
+
"#{prefix}col-span-#{span}"
|
93
|
+
end
|
94
|
+
|
95
|
+
def generate_row_span_class(span, breakpoint = nil)
|
96
|
+
prefix = breakpoint ? "#{breakpoint}:" : ""
|
97
|
+
"#{prefix}row-span-#{span}"
|
98
|
+
end
|
99
|
+
|
100
|
+
def generate_col_start_class(start, breakpoint = nil)
|
101
|
+
prefix = breakpoint ? "#{breakpoint}:" : ""
|
102
|
+
"#{prefix}col-start-#{start}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def generate_col_end_class(end_val, breakpoint = nil)
|
106
|
+
prefix = breakpoint ? "#{breakpoint}:" : ""
|
107
|
+
"#{prefix}col-end-#{end_val}"
|
108
|
+
end
|
109
|
+
|
110
|
+
def generate_row_start_class(start, breakpoint = nil)
|
111
|
+
prefix = breakpoint ? "#{breakpoint}:" : ""
|
112
|
+
"#{prefix}row-start-#{start}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def generate_row_end_class(end_val, breakpoint = nil)
|
116
|
+
prefix = breakpoint ? "#{breakpoint}:" : ""
|
117
|
+
"#{prefix}row-end-#{end_val}"
|
118
|
+
end
|
119
|
+
|
120
|
+
# Normalizza col con default intelligenti per tutti i breakpoint
|
121
|
+
def normalize_cell_col_with_defaults(col)
|
122
|
+
# Se è un valore semplice, lo usiamo per tutti i breakpoint
|
123
|
+
return col unless col.is_a?(Hash)
|
124
|
+
|
125
|
+
# Se è un hash, riempiamo i breakpoint mancanti con fallback intelligente
|
126
|
+
normalized = {}
|
127
|
+
last_value = 1 # Default base
|
128
|
+
|
129
|
+
# Base (senza breakpoint)
|
130
|
+
normalized[:base] = 1
|
131
|
+
|
132
|
+
# Processa i breakpoint in ordine
|
133
|
+
VALID_BREAKPOINTS.each do |breakpoint|
|
134
|
+
if col.key?(breakpoint)
|
135
|
+
last_value = col[breakpoint]
|
136
|
+
end
|
137
|
+
normalized[breakpoint] = last_value
|
138
|
+
end
|
139
|
+
|
140
|
+
normalized
|
141
|
+
end
|
142
|
+
|
143
|
+
# Normalizza row con default intelligenti (solo se specificato)
|
144
|
+
def normalize_cell_row_with_defaults(row)
|
145
|
+
return row unless row.is_a?(Hash)
|
146
|
+
|
147
|
+
normalized = {}
|
148
|
+
last_value = nil
|
149
|
+
|
150
|
+
VALID_BREAKPOINTS.each do |breakpoint|
|
151
|
+
if row.key?(breakpoint)
|
152
|
+
last_value = row[breakpoint]
|
153
|
+
end
|
154
|
+
normalized[breakpoint] = last_value if last_value
|
155
|
+
end
|
156
|
+
|
157
|
+
normalized
|
158
|
+
end
|
159
|
+
|
160
|
+
# Normalizza posizioni (start/end) con fallback intelligente
|
161
|
+
def normalize_cell_position_with_defaults(position)
|
162
|
+
return position unless position.is_a?(Hash)
|
163
|
+
|
164
|
+
normalized = {}
|
165
|
+
last_value = nil
|
166
|
+
|
167
|
+
VALID_BREAKPOINTS.each do |breakpoint|
|
168
|
+
if position.key?(breakpoint)
|
169
|
+
last_value = position[breakpoint]
|
170
|
+
end
|
171
|
+
normalized[breakpoint] = last_value if last_value
|
172
|
+
end
|
173
|
+
|
174
|
+
normalized
|
175
|
+
end
|
176
|
+
|
177
|
+
def generate_col_classes
|
178
|
+
return nil unless @col
|
179
|
+
|
180
|
+
if @col.is_a?(Hash)
|
181
|
+
classes = []
|
182
|
+
|
183
|
+
# Base class (senza breakpoint)
|
184
|
+
if @col[:base]
|
185
|
+
classes << generate_col_span_class(@col[:base])
|
186
|
+
end
|
187
|
+
|
188
|
+
# Responsive classes
|
189
|
+
VALID_BREAKPOINTS.each do |breakpoint|
|
190
|
+
if @col[breakpoint]
|
191
|
+
classes << generate_col_span_class(@col[breakpoint], breakpoint)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
classes.join(" ")
|
196
|
+
else
|
197
|
+
generate_col_span_class(@col)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def generate_row_classes
|
202
|
+
return nil unless @row
|
203
|
+
|
204
|
+
if @row.is_a?(Hash)
|
205
|
+
@row.map do |breakpoint, row_value|
|
206
|
+
generate_row_span_class(row_value, breakpoint)
|
207
|
+
end.compact.join(" ")
|
208
|
+
else
|
209
|
+
generate_row_span_class(@row)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def generate_col_start_classes
|
214
|
+
return nil unless @col_start
|
215
|
+
|
216
|
+
if @col_start.is_a?(Hash)
|
217
|
+
@col_start.map do |breakpoint, start_value|
|
218
|
+
generate_col_start_class(start_value, breakpoint)
|
219
|
+
end.compact.join(" ")
|
220
|
+
else
|
221
|
+
generate_col_start_class(@col_start)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def generate_col_end_classes
|
226
|
+
return nil unless @col_end
|
227
|
+
|
228
|
+
if @col_end.is_a?(Hash)
|
229
|
+
@col_end.map do |breakpoint, end_value|
|
230
|
+
generate_col_end_class(end_value, breakpoint)
|
231
|
+
end.compact.join(" ")
|
232
|
+
else
|
233
|
+
generate_col_end_class(@col_end)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def generate_row_start_classes
|
238
|
+
return nil unless @row_start
|
239
|
+
|
240
|
+
if @row_start.is_a?(Hash)
|
241
|
+
@row_start.map do |breakpoint, start_value|
|
242
|
+
generate_row_start_class(start_value, breakpoint)
|
243
|
+
end.compact.join(" ")
|
244
|
+
else
|
245
|
+
generate_row_start_class(@row_start)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def generate_row_end_classes
|
250
|
+
return nil unless @row_end
|
251
|
+
|
252
|
+
if @row_end.is_a?(Hash)
|
253
|
+
@row_end.map do |breakpoint, end_value|
|
254
|
+
generate_row_end_class(end_value, breakpoint)
|
255
|
+
end.compact.join(" ")
|
256
|
+
else
|
257
|
+
generate_row_end_class(@row_end)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def validate_cell_params
|
262
|
+
validate_cell_col if @col
|
263
|
+
validate_cell_row if @row
|
264
|
+
validate_cell_col_start if @col_start
|
265
|
+
validate_cell_col_end if @col_end
|
266
|
+
validate_cell_row_start if @row_start
|
267
|
+
validate_cell_row_end if @row_end
|
268
|
+
validate_cell_justify_self if @justify_self
|
269
|
+
validate_cell_align_self if @align_self
|
270
|
+
end
|
271
|
+
|
272
|
+
def validate_cell_col
|
273
|
+
if @col.is_a?(Hash)
|
274
|
+
@col.each do |breakpoint, col_value|
|
275
|
+
next if breakpoint == :base # Skip validation for base
|
276
|
+
|
277
|
+
unless VALID_BREAKPOINTS.include?(breakpoint)
|
278
|
+
raise ArgumentError, "Breakpoint #{breakpoint} non supportato per col"
|
279
|
+
end
|
280
|
+
unless VALID_COL_SPANS.include?(col_value)
|
281
|
+
raise ArgumentError, "Valore col #{col_value} non supportato per breakpoint #{breakpoint}"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
else
|
285
|
+
unless VALID_COL_SPANS.include?(@col)
|
286
|
+
raise ArgumentError, "col deve essere uno tra: #{VALID_COL_SPANS.join(', ')}"
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
def validate_cell_row
|
292
|
+
if @row.is_a?(Hash)
|
293
|
+
@row.each do |breakpoint, row_value|
|
294
|
+
unless VALID_BREAKPOINTS.include?(breakpoint)
|
295
|
+
raise ArgumentError, "Breakpoint #{breakpoint} non supportato per row"
|
296
|
+
end
|
297
|
+
unless VALID_ROW_SPANS.include?(row_value)
|
298
|
+
raise ArgumentError, "Valore row #{row_value} non supportato per breakpoint #{breakpoint}"
|
299
|
+
end
|
300
|
+
end
|
301
|
+
else
|
302
|
+
unless VALID_ROW_SPANS.include?(@row)
|
303
|
+
raise ArgumentError, "row deve essere uno tra: #{VALID_ROW_SPANS.join(', ')}"
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
def validate_cell_col_start
|
309
|
+
if @col_start.is_a?(Hash)
|
310
|
+
@col_start.each do |breakpoint, start_value|
|
311
|
+
unless VALID_BREAKPOINTS.include?(breakpoint)
|
312
|
+
raise ArgumentError, "Breakpoint #{breakpoint} non supportato per col_start"
|
313
|
+
end
|
314
|
+
unless VALID_COL_POSITIONS.include?(start_value)
|
315
|
+
raise ArgumentError, "Valore col_start #{start_value} non supportato per breakpoint #{breakpoint}"
|
316
|
+
end
|
317
|
+
end
|
318
|
+
else
|
319
|
+
unless VALID_COL_POSITIONS.include?(@col_start)
|
320
|
+
raise ArgumentError, "col_start deve essere uno tra: #{VALID_COL_POSITIONS.join(', ')}"
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
def validate_cell_col_end
|
326
|
+
if @col_end.is_a?(Hash)
|
327
|
+
@col_end.each do |breakpoint, end_value|
|
328
|
+
unless VALID_BREAKPOINTS.include?(breakpoint)
|
329
|
+
raise ArgumentError, "Breakpoint #{breakpoint} non supportato per col_end"
|
330
|
+
end
|
331
|
+
unless VALID_COL_POSITIONS.include?(end_value)
|
332
|
+
raise ArgumentError, "Valore col_end #{end_value} non supportato per breakpoint #{breakpoint}"
|
333
|
+
end
|
334
|
+
end
|
335
|
+
else
|
336
|
+
unless VALID_COL_POSITIONS.include?(@col_end)
|
337
|
+
raise ArgumentError, "col_end deve essere uno tra: #{VALID_COL_POSITIONS.join(', ')}"
|
338
|
+
end
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
def validate_cell_row_start
|
343
|
+
if @row_start.is_a?(Hash)
|
344
|
+
@row_start.each do |breakpoint, start_value|
|
345
|
+
unless VALID_BREAKPOINTS.include?(breakpoint)
|
346
|
+
raise ArgumentError, "Breakpoint #{breakpoint} non supportato per row_start"
|
347
|
+
end
|
348
|
+
unless VALID_ROW_POSITIONS.include?(start_value)
|
349
|
+
raise ArgumentError, "Valore row_start #{start_value} non supportato per breakpoint #{breakpoint}"
|
350
|
+
end
|
351
|
+
end
|
352
|
+
else
|
353
|
+
unless VALID_ROW_POSITIONS.include?(@row_start)
|
354
|
+
raise ArgumentError, "row_start deve essere uno tra: #{VALID_ROW_POSITIONS.join(', ')}"
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def validate_cell_row_end
|
360
|
+
if @row_end.is_a?(Hash)
|
361
|
+
@row_end.each do |breakpoint, end_value|
|
362
|
+
unless VALID_BREAKPOINTS.include?(breakpoint)
|
363
|
+
raise ArgumentError, "Breakpoint #{breakpoint} non supportato per row_end"
|
364
|
+
end
|
365
|
+
unless VALID_ROW_POSITIONS.include?(end_value)
|
366
|
+
raise ArgumentError, "Valore row_end #{end_value} non supportato per breakpoint #{breakpoint}"
|
367
|
+
end
|
368
|
+
end
|
369
|
+
else
|
370
|
+
unless VALID_ROW_POSITIONS.include?(@row_end)
|
371
|
+
raise ArgumentError, "row_end deve essere uno tra: #{VALID_ROW_POSITIONS.join(', ')}"
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
def validate_cell_justify_self
|
377
|
+
unless GRID_CELL_JUSTIFY_SELF.keys.include?(@justify_self)
|
378
|
+
raise ArgumentError, "justify_self deve essere uno tra: #{GRID_CELL_JUSTIFY_SELF.keys.join(', ')}"
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
def validate_cell_align_self
|
383
|
+
unless GRID_CELL_ALIGN_SELF.keys.include?(@align_self)
|
384
|
+
raise ArgumentError, "align_self deve essere uno tra: #{GRID_CELL_ALIGN_SELF.keys.join(', ')}"
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|