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.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +33 -0
  4. data/CHANGELOG.md +1 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +28 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +118 -0
  9. data/Rakefile +10 -0
  10. data/app/assets/config/headmin_manifest.js +2 -0
  11. data/app/assets/images/avatar.jpg +0 -0
  12. data/app/assets/images/document.docx +0 -0
  13. data/app/assets/images/document.pdf +0 -0
  14. data/app/assets/images/image.jpg +0 -0
  15. data/app/assets/images/spreadsheet.xls +0 -0
  16. data/app/assets/images/video.mp4 +0 -0
  17. data/app/assets/javascripts/formstrap/config/i18n.js +11 -0
  18. data/app/assets/javascripts/formstrap/controllers/autocomplete_controller.js +318 -0
  19. data/app/assets/javascripts/formstrap/controllers/date_range_controller.js +38 -0
  20. data/app/assets/javascripts/formstrap/controllers/dropzone_controller.js +31 -0
  21. data/app/assets/javascripts/formstrap/controllers/file_preview_controller.js +244 -0
  22. data/app/assets/javascripts/formstrap/controllers/flatpickr_controller.js +35 -0
  23. data/app/assets/javascripts/formstrap/controllers/infinite_scroller_controller.js +28 -0
  24. data/app/assets/javascripts/formstrap/controllers/media_controller.js +252 -0
  25. data/app/assets/javascripts/formstrap/controllers/media_modal_controller.js +147 -0
  26. data/app/assets/javascripts/formstrap/controllers/redactorx_controller.js +40 -0
  27. data/app/assets/javascripts/formstrap/controllers/repeater_controller.js +148 -0
  28. data/app/assets/javascripts/formstrap/controllers/select_controller.js +49 -0
  29. data/app/assets/javascripts/formstrap/controllers/textarea_controller.js +48 -0
  30. data/app/assets/javascripts/formstrap/index.js +32 -0
  31. data/app/assets/javascripts/formstrap.js +11515 -0
  32. data/app/assets/stylesheets/formstrap/forms/autocomplete.scss +27 -0
  33. data/app/assets/stylesheets/formstrap/forms/file.scss +83 -0
  34. data/app/assets/stylesheets/formstrap/forms/media.scss +10 -0
  35. data/app/assets/stylesheets/formstrap/forms/repeater.scss +62 -0
  36. data/app/assets/stylesheets/formstrap/forms/search.scss +12 -0
  37. data/app/assets/stylesheets/formstrap/forms.scss +12 -0
  38. data/app/assets/stylesheets/formstrap/general.scss +18 -0
  39. data/app/assets/stylesheets/formstrap/media/index.scss +9 -0
  40. data/app/assets/stylesheets/formstrap/media.scss +1 -0
  41. data/app/assets/stylesheets/formstrap/utilities/buttons.scss +27 -0
  42. data/app/assets/stylesheets/formstrap/utilities/dropzone.scss +72 -0
  43. data/app/assets/stylesheets/formstrap/utilities.scss +2 -0
  44. data/app/assets/stylesheets/formstrap/vendor/flatpickr.css +903 -0
  45. data/app/assets/stylesheets/formstrap/vendor/tom-select-bootstrap.scss +535 -0
  46. data/app/assets/stylesheets/formstrap.css +1559 -0
  47. data/app/assets/stylesheets/formstrap.scss +11 -0
  48. data/app/controllers/concerns/formstrap/pagination.rb +27 -0
  49. data/app/controllers/formstrap/media_controller.rb +68 -0
  50. data/app/controllers/formstrap_controller.rb +2 -0
  51. data/app/models/concerns/formstrap/autocompletable.rb +36 -0
  52. data/app/models/concerns/formstrap/hintable.rb +22 -0
  53. data/app/models/concerns/formstrap/input_groupable.rb +21 -0
  54. data/app/models/concerns/formstrap/labelable.rb +31 -0
  55. data/app/models/concerns/formstrap/listable.rb +26 -0
  56. data/app/models/concerns/formstrap/placeholderable.rb +11 -0
  57. data/app/models/concerns/formstrap/validatable.rb +38 -0
  58. data/app/models/concerns/formstrap/wrappable.rb +19 -0
  59. data/app/models/formstrap/.DS_Store +0 -0
  60. data/app/models/formstrap/association_view.rb +100 -0
  61. data/app/models/formstrap/blocks_view.rb +43 -0
  62. data/app/models/formstrap/checkbox_view.rb +50 -0
  63. data/app/models/formstrap/color_view.rb +45 -0
  64. data/app/models/formstrap/date_range_view.rb +23 -0
  65. data/app/models/formstrap/date_view.rb +43 -0
  66. data/app/models/formstrap/datetime_range_view.rb +23 -0
  67. data/app/models/formstrap/datetime_view.rb +43 -0
  68. data/app/models/formstrap/email_view.rb +46 -0
  69. data/app/models/formstrap/file_view.rb +106 -0
  70. data/app/models/formstrap/flatpickr_range_view.rb +89 -0
  71. data/app/models/formstrap/flatpickr_view.rb +27 -0
  72. data/app/models/formstrap/hidden_view.rb +8 -0
  73. data/app/models/formstrap/hint_view.rb +4 -0
  74. data/app/models/formstrap/input_group_view.rb +17 -0
  75. data/app/models/formstrap/label_view.rb +22 -0
  76. data/app/models/formstrap/media_item_view.rb +41 -0
  77. data/app/models/formstrap/media_view.rb +143 -0
  78. data/app/models/formstrap/number_view.rb +47 -0
  79. data/app/models/formstrap/password_view.rb +42 -0
  80. data/app/models/formstrap/redactorx_view.rb +57 -0
  81. data/app/models/formstrap/search_view.rb +46 -0
  82. data/app/models/formstrap/select_view.rb +61 -0
  83. data/app/models/formstrap/switch_view.rb +21 -0
  84. data/app/models/formstrap/text_view.rb +46 -0
  85. data/app/models/formstrap/textarea_view.rb +47 -0
  86. data/app/models/formstrap/url_view.rb +46 -0
  87. data/app/models/formstrap/wrapper_view.rb +17 -0
  88. data/app/models/formstrap/wysiwyg_view.rb +15 -0
  89. data/app/models/view_model.rb +62 -0
  90. data/app/views/formstrap/_association.html.erb +30 -0
  91. data/app/views/formstrap/_autocomplete.html.erb +11 -0
  92. data/app/views/formstrap/_blocks.html.erb +45 -0
  93. data/app/views/formstrap/_checkbox.html.erb +34 -0
  94. data/app/views/formstrap/_color.html.erb +32 -0
  95. data/app/views/formstrap/_datalist.html.erb +3 -0
  96. data/app/views/formstrap/_date.html.erb +41 -0
  97. data/app/views/formstrap/_date_range.html.erb +40 -0
  98. data/app/views/formstrap/_datetime.html.erb +41 -0
  99. data/app/views/formstrap/_datetime_range.html.erb +40 -0
  100. data/app/views/formstrap/_email.html.erb +43 -0
  101. data/app/views/formstrap/_errors.html.erb +19 -0
  102. data/app/views/formstrap/_file.html.erb +94 -0
  103. data/app/views/formstrap/_flatpickr.html.erb +33 -0
  104. data/app/views/formstrap/_flatpickr_range.html.erb +40 -0
  105. data/app/views/formstrap/_hidden.html.erb +23 -0
  106. data/app/views/formstrap/_hint.html.erb +21 -0
  107. data/app/views/formstrap/_input_group.html.erb +21 -0
  108. data/app/views/formstrap/_label.html.erb +22 -0
  109. data/app/views/formstrap/_media.html.erb +60 -0
  110. data/app/views/formstrap/_number.html.erb +41 -0
  111. data/app/views/formstrap/_password.html.erb +39 -0
  112. data/app/views/formstrap/_redactorx.html.erb +31 -0
  113. data/app/views/formstrap/_repeater.html.erb +128 -0
  114. data/app/views/formstrap/_search.html.erb +43 -0
  115. data/app/views/formstrap/_select.html.erb +43 -0
  116. data/app/views/formstrap/_switch.html.erb +29 -0
  117. data/app/views/formstrap/_text.html.erb +42 -0
  118. data/app/views/formstrap/_textarea.html.erb +39 -0
  119. data/app/views/formstrap/_to_ary.html.erb +0 -0
  120. data/app/views/formstrap/_url.html.erb +43 -0
  121. data/app/views/formstrap/_validation.html.erb +18 -0
  122. data/app/views/formstrap/_wrapper.html.erb +8 -0
  123. data/app/views/formstrap/_wysiwyg.html.erb +28 -0
  124. data/app/views/formstrap/autocomplete/_item.html.erb +3 -0
  125. data/app/views/formstrap/autocomplete/_list.html.erb +3 -0
  126. data/app/views/formstrap/blocks/_modal.html.erb +20 -0
  127. data/app/views/formstrap/fields/_base.html.erb +25 -0
  128. data/app/views/formstrap/fields/_file.html.erb +17 -0
  129. data/app/views/formstrap/fields/_files.html.erb +17 -0
  130. data/app/views/formstrap/fields/_group.html.erb +52 -0
  131. data/app/views/formstrap/fields/_list.html.erb +31 -0
  132. data/app/views/formstrap/fields/_text.html.erb +17 -0
  133. data/app/views/formstrap/media/_item.html.erb +38 -0
  134. data/app/views/formstrap/media/_media_item_modal.html.erb +77 -0
  135. data/app/views/formstrap/media/_modal.html.erb +40 -0
  136. data/app/views/formstrap/media/_thumbnail.html.erb +20 -0
  137. data/app/views/formstrap/media/_validation.html.erb +10 -0
  138. data/app/views/formstrap/media/create.turbo_stream.erb +5 -0
  139. data/app/views/formstrap/media/index.html.erb +3 -0
  140. data/app/views/formstrap/media/index.turbo_stream.erb +11 -0
  141. data/app/views/formstrap/media/show.html.erb +9 -0
  142. data/app/views/formstrap/media/thumbnail.html.erb +3 -0
  143. data/app/views/formstrap/media/update.turbo_stream.erb +3 -0
  144. data/app/views/formstrap/pagination/_infinite.html.erb +7 -0
  145. data/app/views/formstrap/repeater/_row.html.erb +53 -0
  146. data/app/views/formstrap/shared/_notifications.html.erb +20 -0
  147. data/app/views/formstrap/shared/_popup.html.erb +32 -0
  148. data/app/views/formstrap/shared/_thumbnail.html.erb +35 -0
  149. data/bin/console +14 -0
  150. data/bin/setup +8 -0
  151. data/config/importmap.rb +2 -0
  152. data/config/locales/activerecord/en.yml +12 -0
  153. data/config/locales/activerecord/nl.yml +13 -0
  154. data/config/locales/defaults/en.yml +215 -0
  155. data/config/locales/defaults/nl.yml +213 -0
  156. data/config/locales/devise/en.yml +65 -0
  157. data/config/locales/devise/nl.yml +85 -0
  158. data/config/locales/en.yml +6 -0
  159. data/config/locales/formstrap/forms/en.yml +39 -0
  160. data/config/locales/formstrap/forms/nl.yml +39 -0
  161. data/config/locales/formstrap/media/en.yml +24 -0
  162. data/config/locales/formstrap/media/nl.yml +24 -0
  163. data/config/locales/formstrap/thumbnail/en.yml +4 -0
  164. data/config/locales/formstrap/thumbnail/nl.yml +4 -0
  165. data/config/locales/nl.yml +6 -0
  166. data/config/routes.rb +11 -0
  167. data/esbuild-css.js +25 -0
  168. data/esbuild-js.js +11 -0
  169. data/formstrap.gemspec +37 -0
  170. data/formstrap.iml +34 -0
  171. data/lib/formstrap/engine.rb +27 -0
  172. data/lib/formstrap/form_builder.rb +177 -0
  173. data/lib/formstrap/form_helper.rb +19 -0
  174. data/lib/formstrap/version.rb +3 -0
  175. data/lib/formstrap.rb +6 -0
  176. data/package.json +54 -0
  177. data/src/js/formstrap.js +1 -0
  178. data/src/scss/formstrap.scss +1 -0
  179. data/yarn.lock +1998 -0
  180. 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 %>