Module: ViewComponent::InputComponent
- Included in:
- UiHelper
- Defined in:
- app/helpers/view_component/input_component.rb,
app/helpers/view_component/input_component/dropdown_component.rb,
app/helpers/view_component/input_component/textarea_component.rb,
app/helpers/view_component/input_component/input_text_component.rb,
app/helpers/view_component/input_component/date_picker_component.rb,
app/helpers/view_component/input_component/input_radio_component.rb,
app/helpers/view_component/input_component/input_mobile_component.rb,
app/helpers/view_component/input_component/file_selector_component.rb,
app/helpers/view_component/input_component/input_checkbox_component.rb
Defined Under Namespace
Classes: DatePickerComponent, DropdownComponent, FileSelectorComponent, InputCheckboxComponent, InputMobileComponent, InputRadioComponent, InputTextComponent, TextareaComponent
Instance Method Summary collapse
- #date_picker_component(form: nil, name: nil, label: nil, value: nil, placeholder: nil, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {}) ⇒ Object
-
#date_select_component(form:, field_name:, min: nil, max: nil, placeholder: 'YYYY-MM-DD') ⇒ Object
form component date_select_component.
- #dropdown_component(form: nil, name: nil, label: nil, options: [], value: nil, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {}, prompt: nil) ⇒ Object
- #file_selector_component(type:, form: nil, name: nil, label: nil, support_text: nil, support_text_two: nil, error: nil, disabled: false, html_options: {}) ⇒ Object
- #input_checkbox(form: nil, field_name: nil, label: nil, width: 'w-56', value: nil, allow_multiple: false) ⇒ Object
- #input_checkbox_component(form: nil, name: nil, label: nil, value: nil, disabled: false, error: nil, label_position: 'right', html_options: {}) ⇒ Object
- #input_dropdown(form: nil, field_name: nil, label: nil, width: 'w-56', height: nil, placeholder: nil, options: [], value: nil, html_options: {}) ⇒ Object
- #input_field(form: nil, field_name: nil, label: nil, placeholder: nil, width: 'w-56', height: nil, left_icon: nil, right_icon: nil, type: 'text', options: [], value: nil, rows: '5', option: nil, html_options: {}) ⇒ Object
- #input_mobile(form:, field_name:, placeholder: 'Enter 10-digit mobile number', value: nil, label: nil, flag: nil, html_options: {}) ⇒ Object
- #input_mobile_component(form: nil, name: nil, label: nil, placeholder: 'Enter your mobile number', country_code: '', value: '', subtext: nil, error: nil, icon_name: nil, icon_position: 'right', disabled: false, size: 'md', html_options: {}) ⇒ Object
- #input_otp(form:, field_prefix: 'otp', count: 4, input_options: {}, wrapper_options: {}) ⇒ Object
- #input_radio(form: nil, field_name: nil, label: nil, placeholder: 'Enter text', width: 'w-56', height: nil, value: nil, option: nil, html_options: {}) ⇒ Object
- #input_radio_component(form: nil, name: nil, label: nil, value: nil, disabled: false, error: nil, label_position: 'right', html_options: {}) ⇒ Object
- #input_text_component(form: nil, name: nil, label: nil, type: 'text', placeholder: 'Placeholder', value: '', subtext: nil, error: nil, icon_name: nil, icon_position: 'right', disabled: false, size: 'md', html_options: {}) ⇒ Object
- #textarea_component(name:, placeholder:, form: nil, label: nil, value: nil, rows: 1, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {}) ⇒ Object
Instance Method Details
#date_picker_component(form: nil, name: nil, label: nil, value: nil, placeholder: nil, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {}) ⇒ Object
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'app/helpers/view_component/input_component.rb', line 261 def date_picker_component( form: nil, name: nil, label: nil, value: nil, placeholder: nil, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {} ) date_picker = DatePickerComponent.new( form:, name:, label:, value:, placeholder:, size:, support_text:, error:, disabled:, html_options: ) render partial: 'view_components/inputs/date_picker_component/date_picker', locals: { date_picker: } end |
#date_select_component(form:, field_name:, min: nil, max: nil, placeholder: 'YYYY-MM-DD') ⇒ Object
form component date_select_component
115 116 117 118 |
# File 'app/helpers/view_component/input_component.rb', line 115 def date_select_component(form:, field_name:, min: nil, max: nil, placeholder: 'YYYY-MM-DD') render partial: 'view_components/inputs/date_select_component', locals: { form:, field_name:, min:, max:, placeholder: } end |
#dropdown_component(form: nil, name: nil, label: nil, options: [], value: nil, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {}, prompt: nil) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'app/helpers/view_component/input_component.rb', line 230 def dropdown_component( form: nil, name: nil, label: nil, options: [], value: nil, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {}, prompt: nil ) dropdown = DropdownComponent.new( form:, name:, label:, options:, value:, size:, support_text:, error:, disabled:, html_options:, prompt: ) render partial: 'view_components/inputs/dropdown_component/dropdown', locals: { dropdown: } end |
#file_selector_component(type:, form: nil, name: nil, label: nil, support_text: nil, support_text_two: nil, error: nil, disabled: false, html_options: {}) ⇒ Object
166 167 168 169 170 171 172 173 174 |
# File 'app/helpers/view_component/input_component.rb', line 166 def file_selector_component(type:, form: nil, name: nil, label: nil, support_text: nil, support_text_two: nil, error: nil, disabled: false, html_options: {}) file_selector = FileSelectorComponent.new( form:, name:, label:, support_text:, support_text_two:, error:, disabled:, html_options:, type: ) render partial: 'view_components/inputs/file_selector', locals: { file_selector: } end |
#input_checkbox(form: nil, field_name: nil, label: nil, width: 'w-56', value: nil, allow_multiple: false) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/helpers/view_component/input_component.rb', line 62 def input_checkbox(form: nil, field_name: nil, label: nil, width: 'w-56', value: nil, allow_multiple: false) render partial: 'view_components/inputs/checkbox_field', locals: { form:, field_name:, label:, width:, value:, allow_multiple: } end |
#input_checkbox_component(form: nil, name: nil, label: nil, value: nil, disabled: false, error: nil, label_position: 'right', html_options: {}) ⇒ Object
155 156 157 158 159 160 161 162 163 164 |
# File 'app/helpers/view_component/input_component.rb', line 155 def input_checkbox_component(form: nil, name: nil, label: nil, value: nil, disabled: false, error: nil, label_position: 'right', html_options: {}) input = InputCheckboxComponent.new( form:, name:, label:, value:, disabled:, error:, label_position:, html_options: ) render partial: 'view_components/inputs/input_checkbox_component', locals: { input: } end |
#input_dropdown(form: nil, field_name: nil, label: nil, width: 'w-56', height: nil, placeholder: nil, options: [], value: nil, html_options: {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/view_component/input_component.rb', line 46 def input_dropdown(form: nil, field_name: nil, label: nil, width: 'w-56', height: nil, placeholder: nil, options: [], value: nil, html_options: {}) render partial: 'view_components/inputs/dropdown_field', locals: { form:, field_name:, label:, width:, height:, placeholder:, options:, value:, html_options: } end |
#input_field(form: nil, field_name: nil, label: nil, placeholder: nil, width: 'w-56', height: nil, left_icon: nil, right_icon: nil, type: 'text', options: [], value: nil, rows: '5', option: nil, html_options: {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/view_component/input_component.rb', line 5 def input_field(form: nil, field_name: nil, label: nil, placeholder: nil, width: 'w-56', height: nil, left_icon: nil, right_icon: nil, type: 'text', options: [], value: nil, rows: '5', option: nil, html_options: {}) partial_path = 'view_components/inputs/text_field' unless lookup_context.exists?(partial_path, [], true) [:data] ||= {} render partial: partial_path, locals: { form:, field_name:, label:, placeholder:, width:, height:, left_icon:, right_icon:, type:, options:, value:, rows:, option:, html_options: } end |
#input_mobile(form:, field_name:, placeholder: 'Enter 10-digit mobile number', value: nil, label: nil, flag: nil, html_options: {}) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/helpers/view_component/input_component.rb', line 74 def input_mobile(form:, field_name:, placeholder: 'Enter 10-digit mobile number', value: nil, label: nil, flag: nil, html_options: {}) value ||= form.object.public_send(field_name) if form.object.respond_to?(field_name) render partial: 'view_components/inputs/mobile_field', locals: { form:, field_name:, placeholder:, value:, label:, flag:, html_options: } end |
#input_mobile_component(form: nil, name: nil, label: nil, placeholder: 'Enter your mobile number', country_code: '', value: '', subtext: nil, error: nil, icon_name: nil, icon_position: 'right', disabled: false, size: 'md', html_options: {}) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'app/helpers/view_component/input_component.rb', line 176 def input_mobile_component( form: nil, name: nil, label: nil, placeholder: 'Enter your mobile number', country_code: '', value: '', subtext: nil, error: nil, icon_name: nil, icon_position: 'right', disabled: false, size: 'md', html_options: {} ) input = InputMobileComponent.new( form:, name:, label:, type: 'number', placeholder:, code_value: country_code, value:, subtext:, error:, icon_name:, icon_position:, disabled:, size:, html_options: ) render partial: 'view_components/inputs/input_mobile_component', locals: { input: } end |
#input_otp(form:, field_prefix: 'otp', count: 4, input_options: {}, wrapper_options: {}) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/helpers/view_component/input_component.rb', line 89 def input_otp(form:, field_prefix: 'otp', count: 4, input_options: {}, wrapper_options: {}) content_tag(:div, class: 'flex justify-between gap-6 w-full', **( || {}).except(:data)) do safe_join( count.times.map do |i| field_name = "#{field_prefix}_#{number_to_human(i + 1)}" input_field( form:, field_name:, type: 'text', width: 'min-w-16', html_options: { class: 'input-text-otp', maxlength: 1, inputmode: 'numeric', pattern: '[0-9]*' }.merge() ) end ) end end |
#input_radio(form: nil, field_name: nil, label: nil, placeholder: 'Enter text', width: 'w-56', height: nil, value: nil, option: nil, html_options: {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/view_component/input_component.rb', line 30 def input_radio(form: nil, field_name: nil, label: nil, placeholder: 'Enter text', width: 'w-56', height: nil, value: nil, option: nil, html_options: {}) render partial: 'view_components/inputs/radio_field', locals: { form:, field_name:, label:, placeholder:, width:, height:, value:, option:, html_options: } end |
#input_radio_component(form: nil, name: nil, label: nil, value: nil, disabled: false, error: nil, label_position: 'right', html_options: {}) ⇒ Object
144 145 146 147 148 149 150 151 152 153 |
# File 'app/helpers/view_component/input_component.rb', line 144 def input_radio_component(form: nil, name: nil, label: nil, value: nil, disabled: false, error: nil, label_position: 'right', html_options: {}) input = InputRadioComponent.new( form:, name:, label:, value:, disabled:, error:, label_position:, html_options: ) render partial: 'view_components/inputs/input_radio_component', locals: { input: } end |
#input_text_component(form: nil, name: nil, label: nil, type: 'text', placeholder: 'Placeholder', value: '', subtext: nil, error: nil, icon_name: nil, icon_position: 'right', disabled: false, size: 'md', html_options: {}) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'app/helpers/view_component/input_component.rb', line 120 def input_text_component( form: nil, name: nil, label: nil, type: 'text', placeholder: 'Placeholder', value: '', subtext: nil, error: nil, icon_name: nil, icon_position: 'right', disabled: false, size: 'md', html_options: {} ) input = InputTextComponent.new( form:, name:, label:, type:, placeholder:, value:, subtext:, error:, icon_name:, icon_position:, disabled:, size:, html_options: ) render partial: 'view_components/inputs/input_text_component', locals: { input: } end |
#textarea_component(name:, placeholder:, form: nil, label: nil, value: nil, rows: 1, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {}) ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'app/helpers/view_component/input_component.rb', line 200 def textarea_component( name:, placeholder:, form: nil, label: nil, value: nil, rows: 1, size: 'md', support_text: nil, error: nil, disabled: false, html_options: {} ) textarea = TextareaComponent.new( form:, name:, label:, placeholder:, value:, rows:, size:, support_text:, error:, disabled:, html_options: ) render partial: 'view_components/inputs/textarea_component/textarea', locals: { textarea: } end |