formstrap 0.1.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/.DS_Store +0 -0
- data/.gitignore +33 -0
- data/CHANGELOG.md +1 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +28 -0
- data/LICENSE.txt +21 -0
- data/README.md +118 -0
- data/Rakefile +10 -0
- data/app/assets/config/headmin_manifest.js +2 -0
- data/app/assets/images/avatar.jpg +0 -0
- data/app/assets/images/document.docx +0 -0
- data/app/assets/images/document.pdf +0 -0
- data/app/assets/images/image.jpg +0 -0
- data/app/assets/images/spreadsheet.xls +0 -0
- data/app/assets/images/video.mp4 +0 -0
- data/app/assets/javascripts/formstrap/config/i18n.js +11 -0
- data/app/assets/javascripts/formstrap/controllers/autocomplete_controller.js +318 -0
- data/app/assets/javascripts/formstrap/controllers/date_range_controller.js +38 -0
- data/app/assets/javascripts/formstrap/controllers/dropzone_controller.js +31 -0
- data/app/assets/javascripts/formstrap/controllers/file_preview_controller.js +244 -0
- data/app/assets/javascripts/formstrap/controllers/flatpickr_controller.js +35 -0
- data/app/assets/javascripts/formstrap/controllers/infinite_scroller_controller.js +28 -0
- data/app/assets/javascripts/formstrap/controllers/media_controller.js +252 -0
- data/app/assets/javascripts/formstrap/controllers/media_modal_controller.js +147 -0
- data/app/assets/javascripts/formstrap/controllers/redactorx_controller.js +40 -0
- data/app/assets/javascripts/formstrap/controllers/repeater_controller.js +148 -0
- data/app/assets/javascripts/formstrap/controllers/select_controller.js +49 -0
- data/app/assets/javascripts/formstrap/controllers/textarea_controller.js +48 -0
- data/app/assets/javascripts/formstrap/index.js +32 -0
- data/app/assets/javascripts/formstrap.js +11515 -0
- data/app/assets/stylesheets/formstrap/forms/autocomplete.scss +27 -0
- data/app/assets/stylesheets/formstrap/forms/file.scss +83 -0
- data/app/assets/stylesheets/formstrap/forms/media.scss +10 -0
- data/app/assets/stylesheets/formstrap/forms/repeater.scss +62 -0
- data/app/assets/stylesheets/formstrap/forms/search.scss +12 -0
- data/app/assets/stylesheets/formstrap/forms.scss +12 -0
- data/app/assets/stylesheets/formstrap/general.scss +18 -0
- data/app/assets/stylesheets/formstrap/media/index.scss +9 -0
- data/app/assets/stylesheets/formstrap/media.scss +1 -0
- data/app/assets/stylesheets/formstrap/utilities/buttons.scss +27 -0
- data/app/assets/stylesheets/formstrap/utilities/dropzone.scss +72 -0
- data/app/assets/stylesheets/formstrap/utilities.scss +2 -0
- data/app/assets/stylesheets/formstrap/vendor/flatpickr.css +903 -0
- data/app/assets/stylesheets/formstrap/vendor/tom-select-bootstrap.scss +535 -0
- data/app/assets/stylesheets/formstrap.css +1559 -0
- data/app/assets/stylesheets/formstrap.scss +11 -0
- data/app/controllers/concerns/formstrap/pagination.rb +27 -0
- data/app/controllers/formstrap/media_controller.rb +68 -0
- data/app/controllers/formstrap_controller.rb +2 -0
- data/app/models/concerns/formstrap/autocompletable.rb +36 -0
- data/app/models/concerns/formstrap/hintable.rb +22 -0
- data/app/models/concerns/formstrap/input_groupable.rb +21 -0
- data/app/models/concerns/formstrap/labelable.rb +31 -0
- data/app/models/concerns/formstrap/listable.rb +26 -0
- data/app/models/concerns/formstrap/placeholderable.rb +11 -0
- data/app/models/concerns/formstrap/validatable.rb +38 -0
- data/app/models/concerns/formstrap/wrappable.rb +19 -0
- data/app/models/formstrap/.DS_Store +0 -0
- data/app/models/formstrap/association_view.rb +100 -0
- data/app/models/formstrap/blocks_view.rb +43 -0
- data/app/models/formstrap/checkbox_view.rb +50 -0
- data/app/models/formstrap/color_view.rb +45 -0
- data/app/models/formstrap/date_range_view.rb +23 -0
- data/app/models/formstrap/date_view.rb +43 -0
- data/app/models/formstrap/datetime_range_view.rb +23 -0
- data/app/models/formstrap/datetime_view.rb +43 -0
- data/app/models/formstrap/email_view.rb +46 -0
- data/app/models/formstrap/file_view.rb +106 -0
- data/app/models/formstrap/flatpickr_range_view.rb +89 -0
- data/app/models/formstrap/flatpickr_view.rb +27 -0
- data/app/models/formstrap/hidden_view.rb +8 -0
- data/app/models/formstrap/hint_view.rb +4 -0
- data/app/models/formstrap/input_group_view.rb +17 -0
- data/app/models/formstrap/label_view.rb +22 -0
- data/app/models/formstrap/media_item_view.rb +41 -0
- data/app/models/formstrap/media_view.rb +143 -0
- data/app/models/formstrap/number_view.rb +47 -0
- data/app/models/formstrap/password_view.rb +42 -0
- data/app/models/formstrap/redactorx_view.rb +57 -0
- data/app/models/formstrap/search_view.rb +46 -0
- data/app/models/formstrap/select_view.rb +61 -0
- data/app/models/formstrap/switch_view.rb +21 -0
- data/app/models/formstrap/text_view.rb +46 -0
- data/app/models/formstrap/textarea_view.rb +47 -0
- data/app/models/formstrap/url_view.rb +46 -0
- data/app/models/formstrap/wrapper_view.rb +17 -0
- data/app/models/formstrap/wysiwyg_view.rb +15 -0
- data/app/models/view_model.rb +62 -0
- data/app/views/formstrap/_association.html.erb +30 -0
- data/app/views/formstrap/_autocomplete.html.erb +11 -0
- data/app/views/formstrap/_blocks.html.erb +45 -0
- data/app/views/formstrap/_checkbox.html.erb +34 -0
- data/app/views/formstrap/_color.html.erb +32 -0
- data/app/views/formstrap/_datalist.html.erb +3 -0
- data/app/views/formstrap/_date.html.erb +41 -0
- data/app/views/formstrap/_date_range.html.erb +40 -0
- data/app/views/formstrap/_datetime.html.erb +41 -0
- data/app/views/formstrap/_datetime_range.html.erb +40 -0
- data/app/views/formstrap/_email.html.erb +43 -0
- data/app/views/formstrap/_errors.html.erb +19 -0
- data/app/views/formstrap/_file.html.erb +94 -0
- data/app/views/formstrap/_flatpickr.html.erb +33 -0
- data/app/views/formstrap/_flatpickr_range.html.erb +40 -0
- data/app/views/formstrap/_hidden.html.erb +23 -0
- data/app/views/formstrap/_hint.html.erb +21 -0
- data/app/views/formstrap/_input_group.html.erb +21 -0
- data/app/views/formstrap/_label.html.erb +22 -0
- data/app/views/formstrap/_media.html.erb +60 -0
- data/app/views/formstrap/_number.html.erb +41 -0
- data/app/views/formstrap/_password.html.erb +39 -0
- data/app/views/formstrap/_redactorx.html.erb +31 -0
- data/app/views/formstrap/_repeater.html.erb +128 -0
- data/app/views/formstrap/_search.html.erb +43 -0
- data/app/views/formstrap/_select.html.erb +43 -0
- data/app/views/formstrap/_switch.html.erb +29 -0
- data/app/views/formstrap/_text.html.erb +42 -0
- data/app/views/formstrap/_textarea.html.erb +39 -0
- data/app/views/formstrap/_to_ary.html.erb +0 -0
- data/app/views/formstrap/_url.html.erb +43 -0
- data/app/views/formstrap/_validation.html.erb +18 -0
- data/app/views/formstrap/_wrapper.html.erb +8 -0
- data/app/views/formstrap/_wysiwyg.html.erb +28 -0
- data/app/views/formstrap/autocomplete/_item.html.erb +3 -0
- data/app/views/formstrap/autocomplete/_list.html.erb +3 -0
- data/app/views/formstrap/blocks/_modal.html.erb +20 -0
- data/app/views/formstrap/fields/_base.html.erb +25 -0
- data/app/views/formstrap/fields/_file.html.erb +17 -0
- data/app/views/formstrap/fields/_files.html.erb +17 -0
- data/app/views/formstrap/fields/_group.html.erb +52 -0
- data/app/views/formstrap/fields/_list.html.erb +31 -0
- data/app/views/formstrap/fields/_text.html.erb +17 -0
- data/app/views/formstrap/media/_item.html.erb +38 -0
- data/app/views/formstrap/media/_media_item_modal.html.erb +77 -0
- data/app/views/formstrap/media/_modal.html.erb +40 -0
- data/app/views/formstrap/media/_thumbnail.html.erb +20 -0
- data/app/views/formstrap/media/_validation.html.erb +10 -0
- data/app/views/formstrap/media/create.turbo_stream.erb +5 -0
- data/app/views/formstrap/media/index.html.erb +3 -0
- data/app/views/formstrap/media/index.turbo_stream.erb +11 -0
- data/app/views/formstrap/media/show.html.erb +9 -0
- data/app/views/formstrap/media/thumbnail.html.erb +3 -0
- data/app/views/formstrap/media/update.turbo_stream.erb +3 -0
- data/app/views/formstrap/pagination/_infinite.html.erb +7 -0
- data/app/views/formstrap/repeater/_row.html.erb +53 -0
- data/app/views/formstrap/shared/_notifications.html.erb +20 -0
- data/app/views/formstrap/shared/_popup.html.erb +32 -0
- data/app/views/formstrap/shared/_thumbnail.html.erb +35 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/importmap.rb +2 -0
- data/config/locales/activerecord/en.yml +12 -0
- data/config/locales/activerecord/nl.yml +13 -0
- data/config/locales/defaults/en.yml +215 -0
- data/config/locales/defaults/nl.yml +213 -0
- data/config/locales/devise/en.yml +65 -0
- data/config/locales/devise/nl.yml +85 -0
- data/config/locales/en.yml +6 -0
- data/config/locales/formstrap/forms/en.yml +39 -0
- data/config/locales/formstrap/forms/nl.yml +39 -0
- data/config/locales/formstrap/media/en.yml +24 -0
- data/config/locales/formstrap/media/nl.yml +24 -0
- data/config/locales/formstrap/thumbnail/en.yml +4 -0
- data/config/locales/formstrap/thumbnail/nl.yml +4 -0
- data/config/locales/nl.yml +6 -0
- data/config/routes.rb +11 -0
- data/esbuild-css.js +25 -0
- data/esbuild-js.js +11 -0
- data/formstrap.gemspec +37 -0
- data/formstrap.iml +34 -0
- data/lib/formstrap/engine.rb +27 -0
- data/lib/formstrap/form_builder.rb +177 -0
- data/lib/formstrap/form_helper.rb +19 -0
- data/lib/formstrap/version.rb +3 -0
- data/lib/formstrap.rb +6 -0
- data/package.json +54 -0
- data/src/js/formstrap.js +1 -0
- data/src/scss/formstrap.scss +1 -0
- data/yarn.lock +1998 -0
- metadata +224 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/datetime_range
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +start+ - Hash with all options for the start date input (:attribute is required)
|
7
|
+
# * +end+ - Hash with all options for the end date input (:attribute is required)
|
8
|
+
#
|
9
|
+
# ==== Optional parameters
|
10
|
+
# * +append+ - Display as input group with text on the right-hand side
|
11
|
+
# * +float+ - Use floating labels. Defaults to false
|
12
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
13
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
14
|
+
# * +plaintext+ - Render input as plain text.
|
15
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
16
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
17
|
+
#
|
18
|
+
# ==== References
|
19
|
+
# https://headmin.dev/docs/forms/datetime_range
|
20
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datetime-local
|
21
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/datetime_field
|
22
|
+
#
|
23
|
+
# ==== Examples
|
24
|
+
# Basic version
|
25
|
+
# <%= form_with do |form| %#>
|
26
|
+
# <%= render "formstrap/datetime_range", form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
|
27
|
+
# <% end %#>
|
28
|
+
|
29
|
+
datetime_range = Formstrap::DatetimeRangeView.new(local_assigns)
|
30
|
+
%>
|
31
|
+
|
32
|
+
<div class="row">
|
33
|
+
<div class="col">
|
34
|
+
<%= render "formstrap/datetime", datetime_range.start_options %>
|
35
|
+
</div>
|
36
|
+
<div class="col">
|
37
|
+
<%= render "formstrap/datetime", datetime_range.end_options %>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/email
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +append+ - Display as input group with text on the right-hand side
|
10
|
+
# * +collection+ - Values to be suggested while typing. Can be an collection array or a remote URL.
|
11
|
+
# * +float+ - Use floating labels. Defaults to false
|
12
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
13
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
14
|
+
# * +list+ - Options are passed through options_for_select
|
15
|
+
# * +plaintext+ - Render input as plain text.
|
16
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
17
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
18
|
+
#
|
19
|
+
# ==== References
|
20
|
+
# https://headmin.dev/docs/forms/email
|
21
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email
|
22
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/email_field
|
23
|
+
#
|
24
|
+
# ==== Examples
|
25
|
+
# Basic version
|
26
|
+
# <%= form_with do |form| %#>
|
27
|
+
# <%= render "formstrap/email", form: form, attribute: :email_address %#>
|
28
|
+
# <% end %#>
|
29
|
+
|
30
|
+
email = Formstrap::EmailView.new(local_assigns)
|
31
|
+
%>
|
32
|
+
|
33
|
+
<%= render "formstrap/wrapper", email.wrapper_options do %>
|
34
|
+
<%= render "formstrap/label", email.label_options if email.prepend_label? %>
|
35
|
+
<%= render "formstrap/input_group", email.input_group_options do %>
|
36
|
+
<%= form.email_field(email.attribute, email.input_options) %>
|
37
|
+
<%= render "formstrap/datalist", email.datalist_options if email.datalist? %>
|
38
|
+
<%= render "formstrap/autocomplete", email.autocomplete_options if email.autocomplete? %>
|
39
|
+
<% end %>
|
40
|
+
<%= render "formstrap/validation", email.validation_options if email.validate? %>
|
41
|
+
<%= render "formstrap/hint", email.hint_options if email.hint? %>
|
42
|
+
<%= render "formstrap/label", email.label_options if email.append_label? %>
|
43
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%#
|
2
|
+
name: formstrap/errors
|
3
|
+
accepts block: false
|
4
|
+
parameters:
|
5
|
+
form: (string) Form object
|
6
|
+
%>
|
7
|
+
|
8
|
+
<% if form.object.errors.any? %>
|
9
|
+
<div class="alert alert-danger" role="alert">
|
10
|
+
<h5 class="alert-heading d-flex align-items-center">
|
11
|
+
<%= t("errors.template.header", count: form.object.errors.size, model: form.object.model_name.human) %>
|
12
|
+
</h5>
|
13
|
+
<ul class="mb-0">
|
14
|
+
<% form.object.errors.full_messages.each do |message| %>
|
15
|
+
<li><%= message %></li>
|
16
|
+
<% end %>
|
17
|
+
</ul>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/file
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +append+ - Display as input group with text on the right-hand side
|
10
|
+
# * +destroy+ - Adds delete buttons to the preview thumbnails
|
11
|
+
# * +dropzone+ - Add drag&drop interface. This setting automatically enables previews
|
12
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
13
|
+
# * +multiple+ - Add drag&drop interface. This setting automatically enables previews
|
14
|
+
# * +preview+ - Show file previews after selection and after upload
|
15
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
16
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
17
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
18
|
+
#
|
19
|
+
# ==== References
|
20
|
+
# https://headmin.dev/docs/forms/file
|
21
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
|
22
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/file_field
|
23
|
+
#
|
24
|
+
# ==== Examples
|
25
|
+
# Basic version
|
26
|
+
# <%= form_with do |form| %#>
|
27
|
+
# <%= render "formstrap/file", form: form, attribute: :file %#>
|
28
|
+
# <% end %#>
|
29
|
+
|
30
|
+
file = Formstrap::FileView.new(local_assigns)
|
31
|
+
%>
|
32
|
+
|
33
|
+
<%= render "formstrap/wrapper", file.wrapper_options do %>
|
34
|
+
<%= render "formstrap/label", file.label_options if file.prepend_label? %>
|
35
|
+
<div <%= tag.attributes(file.dropzone_options) %>>
|
36
|
+
<%= render "formstrap/input_group", file.input_group_options do %>
|
37
|
+
|
38
|
+
<% if file.preview %>
|
39
|
+
<div class="h-form-file-thumbnails" data-file-preview-target="thumbnails">
|
40
|
+
|
41
|
+
<!-- Render previews for attachments -->
|
42
|
+
<%= form.fields_for(file.nested_attribute) do |ff| %>
|
43
|
+
<%
|
44
|
+
attachment = ff.object
|
45
|
+
next unless attachment
|
46
|
+
filename = attachment.blob.filename.to_s
|
47
|
+
size = number_to_human_size(attachment.blob.byte_size)
|
48
|
+
%>
|
49
|
+
<div class="h-form-file-thumbnail" title="<%= "#{filename} (#{size})" %>" data-file-preview-target="thumbnail">
|
50
|
+
<%= ff.hidden_field(:id, disabled: !file.destroy) %>
|
51
|
+
<%= ff.hidden_field(:_destroy, data: {"file-preview-target": "thumbnailDestroy"}, disabled: !file.destroy) %>
|
52
|
+
<%= render "formstrap/shared/thumbnail", file: attachment %>
|
53
|
+
|
54
|
+
<% if file.destroy %>
|
55
|
+
<div class="h-form-file-thumbnail-remove" data-action="click->file-preview#remove" data-file-preview-name-param="<%= filename %>">
|
56
|
+
<%= bootstrap_icon("x") %>
|
57
|
+
</div>
|
58
|
+
<% end %>
|
59
|
+
</div>
|
60
|
+
<% end %>
|
61
|
+
|
62
|
+
<!-- Placeholder -->
|
63
|
+
<% if file.dropzone %>
|
64
|
+
<div class="h-dropzone-placeholder <%= "d-none" if file.attachments.any? %>" data-file-preview-target="placeholder" style="height: 100px;">
|
65
|
+
<%= t("headmin.forms.file.placeholder", count: file.number_of_files) %>
|
66
|
+
</div>
|
67
|
+
<% else %>
|
68
|
+
<div class="h-form-file-thumbnail <%= "d-none" if file.attachments.any? %>" title="<%= t("headmin.forms.file.not_found") %>" data-file-preview-target="placeholder">
|
69
|
+
<%= render "formstrap/shared/thumbnail", icon: "plus" %>
|
70
|
+
</div>
|
71
|
+
<% end %>
|
72
|
+
</div>
|
73
|
+
<% end %>
|
74
|
+
|
75
|
+
<!-- Template -->
|
76
|
+
<template data-file-preview-target="template">
|
77
|
+
<div class="h-form-file-thumbnail" title="" data-file-preview-target="thumbnail">
|
78
|
+
<%= render "formstrap/shared/thumbnail" %>
|
79
|
+
|
80
|
+
<% if file.destroy %>
|
81
|
+
<div class="h-form-file-thumbnail-remove" data-action="click->file-preview#remove">
|
82
|
+
<%= bootstrap_icon("x") %>
|
83
|
+
</div>
|
84
|
+
<% end %>
|
85
|
+
</div>
|
86
|
+
</template>
|
87
|
+
|
88
|
+
<%= form.file_field(attribute, file.input_options) %>
|
89
|
+
<% end %>
|
90
|
+
</div>
|
91
|
+
<%= render "formstrap/validation", file.validation_options if file.validate? %>
|
92
|
+
<%= render "formstrap/hint", file.hint_options if file.hint? %>
|
93
|
+
<%= render "formstrap/label", file.label_options if file.append_label? %>
|
94
|
+
<% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/flatpickr
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +append+ - Display as input group with text on the right-hand side
|
10
|
+
# * +float+ - Use floating labels. Defaults to false
|
11
|
+
# * +flatpickr+ - Hash with all options you can pass to flatpickr JS config
|
12
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
13
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
14
|
+
# * +list+ - Options are passed through options_for_select
|
15
|
+
# * +plaintext+ - Render input as plain text.
|
16
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
17
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
18
|
+
#
|
19
|
+
# ==== References
|
20
|
+
# https://headmin.dev/docs/forms/date
|
21
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
|
22
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/date_field
|
23
|
+
#
|
24
|
+
# ==== Examples
|
25
|
+
# Basic version
|
26
|
+
# <%= form_with do |form| %#>
|
27
|
+
# <%= render "formstrap/date", form: form, attribute: :date_of_birth %#>
|
28
|
+
# <% end %#>
|
29
|
+
|
30
|
+
flatpickr = Formstrap::FlatpickrView.new(local_assigns)
|
31
|
+
%>
|
32
|
+
|
33
|
+
<%= render "formstrap/date", flatpickr.options %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/flatpickr_range
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +start+ - Hash with all options for the start date input (:attribute is required)
|
7
|
+
# * +end+ - Hash with all options for the end date input (:attribute is required)
|
8
|
+
#
|
9
|
+
# ==== Optional parameters
|
10
|
+
# * +append+ - Display as input group with text on the right-hand side
|
11
|
+
# * +float+ - Use floating labels. Defaults to false
|
12
|
+
# * +flatpickr+ - Hash with all options you can pass to flatpickr JS config
|
13
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
14
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
15
|
+
# * +list+ - Options are passed through options_for_select
|
16
|
+
# * +plaintext+ - Render input as plain text.
|
17
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
18
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
19
|
+
#
|
20
|
+
# ==== Examples
|
21
|
+
# Basic version
|
22
|
+
# <%= form_with do |form| %#>
|
23
|
+
# <%= render "formstrap/flatpickr_range", form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
|
24
|
+
# <% end %#>
|
25
|
+
|
26
|
+
flatpickr_range = Formstrap::FlatpickrRangeView.new(local_assigns)
|
27
|
+
%>
|
28
|
+
|
29
|
+
<%= render "formstrap/wrapper", flatpickr_range.wrapper_options do %>
|
30
|
+
<%= render "formstrap/label", flatpickr_range.label_options if flatpickr_range.prepend_label? %>
|
31
|
+
<%= render "formstrap/input_group", flatpickr_range.input_group_options do %>
|
32
|
+
<%= form.date_field(flatpickr_range.attribute, flatpickr_range.input_options) %>
|
33
|
+
<%= form.hidden_field(flatpickr_range.start[:attribute], flatpickr_range.start_options) %>
|
34
|
+
<%= form.hidden_field(flatpickr_range.end[:attribute], flatpickr_range.end_options) %>
|
35
|
+
<% end %>
|
36
|
+
<%= render "formstrap/validation", flatpickr_range.validation_options if flatpickr_range.validate? %>
|
37
|
+
<%= render "formstrap/hint", flatpickr_range.hint_options if flatpickr_range.hint? %>
|
38
|
+
<%= render "formstrap/datalist", flatpickr_range.datalist_options if flatpickr_range.datalist? %>
|
39
|
+
<%= render "formstrap/label", flatpickr_range.label_options if flatpickr_range.append_label? %>
|
40
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/hidden
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== References
|
9
|
+
# https://headmin.dev/docs/forms/hidden
|
10
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden
|
11
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/hidden_field
|
12
|
+
#
|
13
|
+
# ==== Examples
|
14
|
+
# Basic version
|
15
|
+
# <%= form_with do |form| %#>
|
16
|
+
# <%= render "formstrap/hidden", form: form, attribute: :id %#>
|
17
|
+
# <% end %#>
|
18
|
+
|
19
|
+
hidden = Formstrap::HiddenView.new(local_assigns)
|
20
|
+
%>
|
21
|
+
|
22
|
+
<%= form.hidden_field(attribute, hidden.input_options) %>
|
23
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/hint
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +content+ - Content to be displayed as input hint
|
6
|
+
#
|
7
|
+
# ==== Examples
|
8
|
+
# Basic version
|
9
|
+
# <%= form_with do |form| %#>
|
10
|
+
# <%= render "formstrap/hint", content: "Hello" %#>
|
11
|
+
# <% end %#>
|
12
|
+
|
13
|
+
hint = Formstrap::HintView.new(local_assigns)
|
14
|
+
%>
|
15
|
+
|
16
|
+
<div class="form-text d-flex justify-content-between">
|
17
|
+
<div><%= raw(hint.content) %></div>
|
18
|
+
<% if hint.maxlength %>
|
19
|
+
<div data-textarea-target="count"></div>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<% input_group = Formstrap::InputGroupView.new(local_assigns) %>
|
2
|
+
|
3
|
+
<% if input_group.bypass %>
|
4
|
+
<%= yield %>
|
5
|
+
<% else %>
|
6
|
+
<div <%= tag.attributes(input_group.options) %>>
|
7
|
+
<% if input_group.prepend %>
|
8
|
+
<span class="input-group-text">
|
9
|
+
<%= input_group.prepend %>
|
10
|
+
</span>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
|
15
|
+
<% if input_group.append %>
|
16
|
+
<span class="input-group-text">
|
17
|
+
<%= input_group.append %>
|
18
|
+
</span>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%
|
2
|
+
# name: formstrap/label
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +attribute+ - Name of the attribute of the form model
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +text+ - Custom label to be used instead of the attribute
|
10
|
+
#
|
11
|
+
# ==== References
|
12
|
+
# https://headmin.dev/docs/forms/label
|
13
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
|
14
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/label
|
15
|
+
#
|
16
|
+
# ==== Examples
|
17
|
+
# Basic version
|
18
|
+
# <%= render "formstrap/label", form: form, attribute: :image %#>
|
19
|
+
%>
|
20
|
+
|
21
|
+
<% label = Formstrap::LabelView.new(local_assigns) %>
|
22
|
+
<%= form.label label.attribute, label.text, label.options %>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/media
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +destroy+ - Adds delete buttons to the preview thumbnails
|
10
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed
|
11
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label
|
12
|
+
# * +min+ - Limit the selection to a minimum amount of items
|
13
|
+
# * +max+ - Limit the selection to a maximum amount of items
|
14
|
+
# * +sort+ - Allow sorting by dragging items. `active_storage_attachments` must have a position column
|
15
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
16
|
+
# * +width+ - Width of the thumbnail
|
17
|
+
# * +height+ - Height of the thumbnail
|
18
|
+
#
|
19
|
+
# ==== References
|
20
|
+
# https://headmin.dev/docs/forms/media
|
21
|
+
#
|
22
|
+
# ==== Examples
|
23
|
+
# Basic version
|
24
|
+
# <%= form_with do |form| %#>
|
25
|
+
# <%= render "formstrap/media", form: form, attribute: :file %#>
|
26
|
+
# <% end %#>
|
27
|
+
|
28
|
+
media = Formstrap::MediaView.new(local_assigns)
|
29
|
+
%>
|
30
|
+
|
31
|
+
<%= render "formstrap/wrapper", media.wrapper_options do %>
|
32
|
+
<%= render "formstrap/label", media.label_options if media.prepend_label? %>
|
33
|
+
<div class="h-form-file-thumbnails" data-media-target="thumbnails">
|
34
|
+
<%= render "formstrap/media/validation", media.custom_validation_options %>
|
35
|
+
|
36
|
+
<!-- Render previews for attachments -->
|
37
|
+
<%= form.fields_for(media.nested_attribute, media.association_object) do |ff| %>
|
38
|
+
<%= render "formstrap/media/item", media.item_options.merge(form: ff, url: formstrap_media_url(name: media.name, ids: media.blob_ids, min: media.min, max: media.max, mimetype: media.accept)) %>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
<!-- Placeholder -->
|
42
|
+
<div class="<%= "d-none" if media.attachments.any? %>" data-media-target="placeholder">
|
43
|
+
<a href="<%= formstrap_media_url(name: media.name, ids: media.blob_ids, min: media.min, max: media.max, mimetype: media.accept) %>" data-turbo-frame="remote_modal" data-media-target="modalButton">
|
44
|
+
<%= render "formstrap/shared/thumbnail", media.thumbnail_options %>
|
45
|
+
</a>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
<!-- Template -->
|
50
|
+
<% association_object = ActiveStorage::Attachment.new %>
|
51
|
+
<template data-media-target="template" data-template-id-regex="<%= association_object.object_id %>">
|
52
|
+
<%= form.fields_for(media.nested_attribute, ActiveStorage::Attachment.new, child_index: association_object.object_id) do |ff| %>
|
53
|
+
<%= render "formstrap/media/item", media.item_options.merge(form: ff, url: formstrap_media_url(name: media.name, ids: media.blob_ids, min: media.min, max: media.max, mimetype: media.accept)) %>
|
54
|
+
<% end %>
|
55
|
+
</template>
|
56
|
+
|
57
|
+
<%= render "formstrap/validation", media.validation_options if media.validate? %>
|
58
|
+
<%= render "formstrap/hint", media.hint_options if media.hint? %>
|
59
|
+
<%= render "formstrap/label", media.label_options if media.append_label? %>
|
60
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/number
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +append+ - Display as input group with text on the right-hand side
|
10
|
+
# * +float+ - Use floating labels. Defaults to false
|
11
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
12
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
13
|
+
# * +list+ - Options are passed through options_for_select
|
14
|
+
# * +plaintext+ - Render input as plain text.
|
15
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
16
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
17
|
+
#
|
18
|
+
# ==== References
|
19
|
+
# https://headmin.dev/docs/forms/number
|
20
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
|
21
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/number_field
|
22
|
+
#
|
23
|
+
# ==== Examples
|
24
|
+
# Basic version
|
25
|
+
# <%= form_with do |form| %#>
|
26
|
+
# <%= render "formstrap/number", form: form, attribute: :number %#>
|
27
|
+
# <% end %#>
|
28
|
+
|
29
|
+
number = Formstrap::NumberView.new(local_assigns)
|
30
|
+
%>
|
31
|
+
|
32
|
+
<%= render "formstrap/wrapper", number.wrapper_options do %>
|
33
|
+
<%= render "formstrap/label", number.label_options if number.prepend_label? %>
|
34
|
+
<%= render "formstrap/input_group", number.input_group_options do %>
|
35
|
+
<%= form.number_field(number.attribute, number.input_options) %>
|
36
|
+
<%= render "formstrap/datalist", number.datalist_options if number.datalist? %>
|
37
|
+
<% end %>
|
38
|
+
<%= render "formstrap/validation", number.validation_options if number.validate? %>
|
39
|
+
<%= render "formstrap/hint", number.hint_options if number.hint? %>
|
40
|
+
<%= render "formstrap/label", number.label_options if number.append_label? %>
|
41
|
+
<% end %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/password
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +append+ - Display as input group with text on the right-hand side
|
10
|
+
# * +float+ - Use floating labels. Defaults to false
|
11
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
12
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
13
|
+
# * +plaintext+ - Render input as plain text.
|
14
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
15
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
16
|
+
#
|
17
|
+
# ==== References
|
18
|
+
# https://headmin.dev/docs/forms/password
|
19
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password
|
20
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/password_field
|
21
|
+
#
|
22
|
+
# ==== Examples
|
23
|
+
# Basic version
|
24
|
+
# <%= form_with do |form| %#>
|
25
|
+
# <%= render "formstrap/password", form: form, attribute: :password %#>
|
26
|
+
# <% end %#>
|
27
|
+
|
28
|
+
password = Formstrap::PasswordView.new(local_assigns)
|
29
|
+
%>
|
30
|
+
|
31
|
+
<%= render "formstrap/wrapper", password.wrapper_options do %>
|
32
|
+
<%= render "formstrap/label", password.label_options if password.prepend_label? %>
|
33
|
+
<%= render "formstrap/input_group", password.input_group_options do %>
|
34
|
+
<%= form.password_field(password.attribute, password.input_options) %>
|
35
|
+
<% end %>
|
36
|
+
<%= render "formstrap/validation", password.validation_options if password.validate? %>
|
37
|
+
<%= render "formstrap/hint", password.hint_options if password.hint? %>
|
38
|
+
<%= render "formstrap/label", password.label_options if password.append_label? %>
|
39
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<%
|
2
|
+
# formstrap/redactorx
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +append+ - Display as input group with text on the right-hand side
|
10
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
11
|
+
# * +hybrid+ - Enables hybrid mode when set to true (default = false)
|
12
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
13
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
14
|
+
# * +redactor+ - Hash with all options you can pass to redactor JS config
|
15
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
16
|
+
#
|
17
|
+
# ==== References
|
18
|
+
# https://headmin.dev/docs/forms/redactorx
|
19
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
|
20
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/text_area
|
21
|
+
#
|
22
|
+
# ==== Examples
|
23
|
+
# Basic version
|
24
|
+
# <%= form_with do |form| %#>
|
25
|
+
# <%= render "formstrap/redactorx", form: form, attribute: :text %#>
|
26
|
+
# <% end %#>
|
27
|
+
|
28
|
+
redactor = Formstrap::RedactorxView.new(local_assigns)
|
29
|
+
%>
|
30
|
+
|
31
|
+
<%= render "formstrap/textarea", redactor.options %>
|