headmin 0.2.5 → 0.3.1

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 (264) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -3
  3. data/Gemfile.lock +13 -2
  4. data/README.md +64 -57
  5. data/app/assets/config/headmin_manifest.js +2 -0
  6. data/app/assets/javascripts/headmin/config/i18n.js +11 -0
  7. data/{src/js → app/assets/javascripts}/headmin/controllers/blocks_controller.js +1 -2
  8. data/app/assets/javascripts/headmin/controllers/date_range_controller.js +32 -0
  9. data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +33 -0
  10. data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +244 -0
  11. data/{src/js → app/assets/javascripts}/headmin/controllers/filter_controller.js +13 -7
  12. data/{src/js → app/assets/javascripts}/headmin/controllers/filters_controller.js +1 -1
  13. data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +39 -0
  14. data/app/assets/javascripts/headmin/controllers/hello_controller.js +7 -0
  15. data/app/assets/javascripts/headmin/controllers/notification_controller.js +8 -0
  16. data/{src/js → app/assets/javascripts}/headmin/controllers/popup_controller.js +1 -2
  17. data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +13 -0
  18. data/{src/js → app/assets/javascripts}/headmin/controllers/repeater_controller.js +8 -9
  19. data/app/assets/javascripts/headmin/controllers/select_controller.js +48 -0
  20. data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +98 -0
  21. data/app/assets/javascripts/headmin/controllers/table_controller.js +110 -0
  22. data/app/assets/javascripts/headmin/index.js +41 -0
  23. data/app/assets/javascripts/headmin.js +15934 -0
  24. data/{src/scss → app/assets/stylesheets}/headmin/filter.scss +0 -0
  25. data/{src/scss → app/assets/stylesheets}/headmin/filters.scss +0 -0
  26. data/{src/scss → app/assets/stylesheets}/headmin/form.scss +55 -2
  27. data/{src/scss → app/assets/stylesheets}/headmin/general.scss +0 -0
  28. data/{src/scss → app/assets/stylesheets}/headmin/layout/body.scss +0 -0
  29. data/{src/scss → app/assets/stylesheets}/headmin/layout/sidebar.scss +0 -0
  30. data/{src/scss → app/assets/stylesheets}/headmin/layout.scss +0 -0
  31. data/{src/scss → app/assets/stylesheets}/headmin/login.scss +0 -0
  32. data/{src/scss/vendor/bootstrap/variables.scss → app/assets/stylesheets/headmin/overrides/bootstrap.scss} +0 -0
  33. data/{src/scss/vendor/redactorx/override.css → app/assets/stylesheets/headmin/overrides/redactorx.css} +0 -0
  34. data/{src/scss → app/assets/stylesheets}/headmin/popup.scss +0 -0
  35. data/app/assets/stylesheets/headmin/syntax.scss +349 -0
  36. data/{src/scss → app/assets/stylesheets}/headmin/table.scss +1 -0
  37. data/app/assets/stylesheets/headmin/thumbnail.scss +20 -0
  38. data/app/assets/stylesheets/headmin/utilities.scss +68 -0
  39. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_accordion.scss +118 -0
  40. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_alert.scss +57 -0
  41. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_badge.scss +29 -0
  42. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_breadcrumb.scss +28 -0
  43. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_button-group.scss +139 -0
  44. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_buttons.scss +111 -0
  45. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_card.scss +216 -0
  46. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_carousel.scss +229 -0
  47. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_close.scss +40 -0
  48. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_containers.scss +41 -0
  49. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_dropdown.scss +240 -0
  50. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_forms.scss +9 -0
  51. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_functions.scss +302 -0
  52. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_grid.scss +33 -0
  53. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_helpers.scss +9 -0
  54. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_images.scss +42 -0
  55. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_list-group.scss +174 -0
  56. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_mixins.scss +43 -0
  57. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_modal.scss +209 -0
  58. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_nav.scss +139 -0
  59. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_navbar.scss +335 -0
  60. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_offcanvas.scss +83 -0
  61. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_pagination.scss +64 -0
  62. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_placeholders.scss +51 -0
  63. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_popover.scss +158 -0
  64. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_progress.scss +48 -0
  65. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_reboot.scss +625 -0
  66. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_root.scss +54 -0
  67. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_spinners.scss +69 -0
  68. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_tables.scss +155 -0
  69. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_toasts.scss +51 -0
  70. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_tooltip.scss +115 -0
  71. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_transitions.scss +27 -0
  72. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_type.scss +104 -0
  73. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_utilities.scss +630 -0
  74. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_variables.scss +1641 -0
  75. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-grid.scss +67 -0
  76. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-reboot.scss +13 -0
  77. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-utilities.scss +18 -0
  78. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap.scss +53 -0
  79. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_floating-labels.scss +63 -0
  80. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-check.scss +152 -0
  81. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-control.scss +219 -0
  82. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-range.scss +91 -0
  83. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-select.scss +72 -0
  84. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-text.scss +11 -0
  85. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_input-group.scss +121 -0
  86. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_labels.scss +36 -0
  87. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_validation.scss +12 -0
  88. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_clearfix.scss +3 -0
  89. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_colored-links.scss +12 -0
  90. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_position.scss +30 -0
  91. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_ratio.scss +26 -0
  92. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_stacks.scss +15 -0
  93. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_stretched-link.scss +15 -0
  94. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_text-truncation.scss +7 -0
  95. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
  96. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_vr.scss +8 -0
  97. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_alert.scss +11 -0
  98. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_backdrop.scss +14 -0
  99. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_border-radius.scss +78 -0
  100. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_box-shadow.scss +18 -0
  101. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_breakpoints.scss +127 -0
  102. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_buttons.scss +133 -0
  103. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_caret.scss +64 -0
  104. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_clearfix.scss +9 -0
  105. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_color-scheme.scss +7 -0
  106. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_container.scss +9 -0
  107. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_deprecate.scss +10 -0
  108. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_forms.scss +144 -0
  109. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_gradients.scss +47 -0
  110. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_grid.scss +151 -0
  111. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_image.scss +16 -0
  112. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_list-group.scss +24 -0
  113. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_lists.scss +7 -0
  114. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_pagination.scss +31 -0
  115. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_reset-text.scss +17 -0
  116. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_resize.scss +6 -0
  117. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_table-variants.scss +21 -0
  118. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_text-truncate.scss +8 -0
  119. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_transition.scss +26 -0
  120. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_utilities.scss +89 -0
  121. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_visually-hidden.scss +29 -0
  122. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/utilities/_api.scss +47 -0
  123. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/vendor/_rfs.scss +354 -0
  124. data/app/assets/stylesheets/headmin/vendor/flatpickr.css +903 -0
  125. data/{src/scss/vendor/redactorx → app/assets/stylesheets/headmin/vendor}/redactorx.css +0 -0
  126. data/app/assets/stylesheets/headmin/vendor/tom-select-bootstrap.css +537 -0
  127. data/app/assets/stylesheets/headmin.css +13454 -0
  128. data/app/assets/stylesheets/headmin.scss +65 -0
  129. data/app/helpers/headmin/admin_helper.rb +4 -59
  130. data/app/helpers/headmin/bootstrap_helper.rb +31 -0
  131. data/app/helpers/headmin/documentation_helper.rb +35 -0
  132. data/app/helpers/headmin/filter_helper.rb +7 -3
  133. data/app/helpers/headmin/form_helper.rb +40 -0
  134. data/app/helpers/headmin/request_helper.rb +34 -0
  135. data/app/models/concerns/headmin/fieldable.rb +3 -1
  136. data/app/models/headmin/documentation_renderer.rb +32 -0
  137. data/app/models/headmin/form/base.rb +79 -0
  138. data/app/models/headmin/form/text.rb +53 -0
  139. data/app/services/block_service.rb +8 -4
  140. data/app/views/examples/admin.html.erb +1 -1
  141. data/app/views/headmin/_blocks.html.erb +2 -2
  142. data/app/views/headmin/_breadcrumbs.html.erb +1 -1
  143. data/app/views/headmin/_card.html.erb +10 -6
  144. data/app/views/headmin/_dropdown.html.erb +1 -1
  145. data/app/views/headmin/_filters.html.erb +23 -11
  146. data/app/views/headmin/_form.html.erb +14 -14
  147. data/app/views/headmin/_heading.html.erb +1 -1
  148. data/app/views/headmin/_notifications.html.erb +1 -1
  149. data/app/views/headmin/_pagination.html.erb +3 -2
  150. data/app/views/headmin/_popup.html.erb +10 -4
  151. data/app/views/headmin/_table.html.erb +10 -4
  152. data/app/views/headmin/_thumbnail.html.erb +47 -0
  153. data/app/views/headmin/dropdown/_devise.html.erb +20 -10
  154. data/app/views/headmin/dropdown/_list.html.erb +14 -7
  155. data/app/views/headmin/filters/_date.html.erb +9 -13
  156. data/app/views/headmin/filters/_flatpickr.html.erb +57 -0
  157. data/app/views/headmin/filters/_search.html.erb +5 -5
  158. data/app/views/headmin/filters/_select.html.erb +6 -6
  159. data/app/views/headmin/filters/filter/_button.html.erb +7 -7
  160. data/app/views/headmin/filters/filter/_template.html.erb +1 -1
  161. data/app/views/headmin/forms/_actions.html.erb +1 -1
  162. data/app/views/headmin/forms/_base.html.erb +100 -46
  163. data/app/views/headmin/forms/_blocks.html.erb +14 -7
  164. data/app/views/headmin/forms/_checkbox.html.erb +3 -3
  165. data/app/views/headmin/forms/_date.html.erb +30 -34
  166. data/app/views/headmin/forms/_date_range.html.erb +42 -0
  167. data/app/views/headmin/forms/_email.html.erb +35 -26
  168. data/app/views/headmin/forms/_file.html.erb +186 -34
  169. data/app/views/headmin/forms/_flatpickr.html.erb +34 -0
  170. data/app/views/headmin/forms/_flatpickr_range.html.erb +50 -0
  171. data/app/views/headmin/forms/_hidden.html.erb +24 -0
  172. data/app/views/headmin/forms/_image.html.erb +11 -45
  173. data/app/views/headmin/forms/_label.html.erb +18 -12
  174. data/app/views/headmin/forms/_number.html.erb +40 -37
  175. data/app/views/headmin/forms/_password.html.erb +37 -58
  176. data/app/views/headmin/forms/_redactorx.html.erb +8 -7
  177. data/app/views/headmin/forms/_repeater.html.erb +11 -14
  178. data/app/views/headmin/forms/_select.html.erb +43 -45
  179. data/app/views/headmin/forms/_text.html.erb +94 -59
  180. data/app/views/headmin/forms/_textarea.html.erb +37 -26
  181. data/app/views/headmin/forms/_url.html.erb +35 -26
  182. data/app/views/headmin/forms/_validation.html.erb +3 -3
  183. data/app/views/headmin/forms/_video.html.erb +21 -0
  184. data/app/views/headmin/forms/fields/_base.html.erb +3 -3
  185. data/app/views/headmin/forms/fields/_file.html.erb +2 -2
  186. data/app/views/headmin/forms/fields/_group.html.erb +3 -3
  187. data/app/views/headmin/forms/fields/_image.html.erb +2 -2
  188. data/app/views/headmin/forms/fields/_list.html.erb +3 -3
  189. data/app/views/headmin/forms/fields/_text.html.erb +2 -2
  190. data/app/views/headmin/forms/repeater/_row.html.erb +1 -1
  191. data/app/views/headmin/heading/_title.html.erb +1 -1
  192. data/app/views/headmin/layout/_body.html.erb +1 -1
  193. data/app/views/headmin/layout/_content.html.erb +1 -1
  194. data/app/views/headmin/layout/_footer.html.erb +1 -1
  195. data/app/views/headmin/layout/_header.html.erb +1 -1
  196. data/app/views/headmin/layout/_main.html.erb +12 -6
  197. data/app/views/headmin/layout/_sidebar.html.erb +3 -3
  198. data/app/views/headmin/layout/sidebar/_bottom.html.erb +1 -1
  199. data/app/views/headmin/layout/sidebar/_nav.html.erb +1 -1
  200. data/app/views/headmin/nav/_dropdown.html.erb +34 -0
  201. data/app/views/headmin/nav/_item.html.erb +22 -13
  202. data/app/views/headmin/table/_actions.html.erb +35 -11
  203. data/app/views/headmin/table/_body.html.erb +1 -1
  204. data/app/views/headmin/table/_foot.html.erb +1 -1
  205. data/app/views/headmin/table/_footer.html.erb +1 -1
  206. data/app/views/headmin/table/_head.html.erb +1 -1
  207. data/app/views/headmin/table/_header.html.erb +1 -1
  208. data/app/views/headmin/table/actions/_action.html.erb +4 -4
  209. data/app/views/headmin/table/actions/_delete.html.erb +1 -1
  210. data/app/views/headmin/table/actions/_export.html.erb +1 -1
  211. data/app/views/headmin/table/body/_row.html.erb +15 -7
  212. data/app/views/headmin/views/devise/confirmations/_new.html.erb +1 -1
  213. data/app/views/headmin/views/devise/passwords/_edit.html.erb +2 -2
  214. data/app/views/headmin/views/devise/passwords/_new.html.erb +1 -1
  215. data/app/views/headmin/views/devise/registrations/_edit.html.erb +4 -4
  216. data/app/views/headmin/views/devise/registrations/_new.html.erb +3 -3
  217. data/app/views/headmin/views/devise/shared/_links.html.erb +7 -7
  218. data/app/views/headmin/views/devise/unlocks/_new.html.erb +1 -1
  219. data/config/importmap.rb +2 -0
  220. data/config/locales/activerecord/en.yml +9 -0
  221. data/config/locales/activerecord/nl.yml +9 -0
  222. data/config/locales/en.yml +0 -3
  223. data/config/locales/headmin/forms/en.yml +5 -0
  224. data/config/locales/headmin/forms/nl.yml +5 -0
  225. data/config/locales/headmin/popup/en.yml +4 -0
  226. data/config/locales/headmin/popup/nl.yml +4 -0
  227. data/config/locales/headmin/table/en.yml +5 -1
  228. data/config/locales/headmin/table/nl.yml +5 -1
  229. data/config/locales/headmin/thumbnail/en.yml +4 -0
  230. data/config/locales/headmin/thumbnail/nl.yml +4 -0
  231. data/config/locales/headmin/views/en.yml +1 -1
  232. data/config/locales/headmin/views/nl.yml +14 -14
  233. data/config/locales/nl.yml +0 -3
  234. data/docs/blocks.md +0 -7
  235. data/esbuild-css.js +25 -0
  236. data/esbuild-js.js +11 -0
  237. data/headmin.gemspec +4 -1
  238. data/lib/generators/headmin/blocks_generator.rb +4 -1
  239. data/lib/generators/headmin/devise_generator.rb +5 -1
  240. data/lib/generators/headmin/fields_generator.rb +4 -1
  241. data/lib/generators/templates/controllers/auth/confirmations_controller.rb +31 -0
  242. data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +31 -0
  243. data/lib/generators/templates/controllers/auth/passwords_controller.rb +35 -0
  244. data/lib/generators/templates/controllers/auth/registrations_controller.rb +63 -0
  245. data/lib/generators/templates/controllers/auth/sessions_controller.rb +28 -0
  246. data/lib/generators/templates/controllers/auth/unlocks_controller.rb +31 -0
  247. data/lib/headmin/engine.rb +15 -0
  248. data/lib/headmin/version.rb +1 -1
  249. data/lib/headmin.rb +1 -1
  250. data/package.json +20 -35
  251. data/src/js/headmin.js +1 -1
  252. data/src/scss/headmin.scss +1 -61
  253. data/yarn.lock +443 -5345
  254. metadata +198 -30
  255. data/.nvmrc +0 -1
  256. data/app/controllers/concerns/headmin/ckeditor.rb +0 -27
  257. data/app/views/headmin/forms/_ckeditor.html.erb +0 -42
  258. data/dist/css/headmin.css +0 -12313
  259. data/dist/js/headmin.js +0 -1548
  260. data/src/js/headmin/controllers/table_actions_controller.js +0 -33
  261. data/src/js/headmin/controllers/table_controller.js +0 -119
  262. data/src/js/headmin/headmin.js +0 -141
  263. data/src/scss/headmin/utilities.scss +0 -19
  264. data/webpack.config.js +0 -30
@@ -1,24 +1,30 @@
1
1
  <%
2
2
  # name: headmin/forms/label
3
3
  #
4
+ # ==== Required parameters
5
+ # * +form+ - Form object
6
+ # * +attribute+ - Name of the attribute of the form model
7
+ #
4
8
  # ==== Options
5
- # * <tt>form<tt> - Form object
6
- # * <tt>attribute<tt> - Name of the attribute of the form model
7
- # * <tt>name<tt> - Custom label to be used instead of the attribute
8
- # * <tt>required<tt> - Set to true if you want to highlight the requirement
9
+ # * +class+ - Optional HTML class attribute
10
+ # * +for+ - Set reference to the input id
11
+ # * +required+ - Set to true if you want to highlight the requirement
12
+ # * +text+ - Custom label to be used instead of the attribute
13
+ #
14
+ # ==== References
15
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
16
+ # https://apidock.com/rails/v5.2.3/ActionView/Helpers/FormHelper/label
9
17
  #
10
18
  # ==== Examples
11
19
  # Basic version
12
20
  # <%= render 'headmin/forms/label', form: form, attribute: :image %#>
13
21
 
14
- class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
15
- name = local_assigns.has_key?(:name) && name ? name.to_s.humanize : attribute
16
- required = local_assigns.has_key?(:required) ? required : false
17
-
18
- options = {
19
- class: "form-label #{class_names}",
20
- required: required,
22
+ text = local_assigns[:text]
23
+ default_options = {
24
+ class: ['form-label', local_assigns[:class]].join(' '),
25
+ form: form.options[:id],
21
26
  }
27
+ options = default_options.merge(local_assigns.slice(*%i(for required)).compact)
22
28
  %>
23
29
 
24
- <%= form.label name, options %>
30
+ <%= form.label attribute, text, options %>
@@ -1,50 +1,53 @@
1
1
  <%
2
2
  # headmin/forms/number
3
3
  #
4
- # ==== Options
5
- # * <tt>form<tt> - Form object
6
- # * <tt>attribute<tt> - Name of the attribute of the form model
7
- # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
8
- # * <tt>float<tt> - Set to true if you want to show floating labels
9
- # * <tt>collection<tt> - Add array of options to show in a data list
10
- # * <tt>append<tt> - Text or icon to be shown on the left hand side of the input, Doesn't work with float
11
- # * <tt>prepend<tt> - Text or icon to be shown on the right hand side of the input, Doesn't work with float
4
+ # ==== Required parameters
5
+ # * +form+ - Form object
6
+ # * +attribute+ - Name of the attribute of the form model
7
+ #
8
+ # ==== Optional parameters
9
+ # * +aria+ - Provide a hash to define all aria attributes
10
+ # * +autocomplete+ - Value to be autofilled by the browser
11
+ # * +autofocus+ - Set to true to focus on this field when the page renders
12
+ # * +data+ - Provide a hash to define all data attributes
13
+ # * +disabled+ - Sets the placeholder of the field
14
+ # * +id+ - Input identifier
15
+ # * +in+ - Range specifying the +min+ and +max+ values
16
+ # * +list+ - Add array of options to show in a data list
17
+ # * +max+ - The maximum acceptable value
18
+ # * +min+ - The minimum acceptable value
19
+ # * +placeholder+ - Sets the placeholder of the field
20
+ # * +readonly+ - Sets the placeholder of the field
21
+ # * +required+ - Set to true to mark as required
22
+ # * +step+ - The acceptable value granularity
23
+ # * +value+ - Overrides the value of the form
24
+ # * +within+ - Same as +in+
25
+ #
26
+ # ==== Extra parameters
27
+ # Listed in 'headmin/forms/base'
28
+ #
29
+ # ==== References
30
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
31
+ # https://apidock.com/rails/ActionView/Helpers/FormHelper/number_field
12
32
  #
13
33
  # ==== Examples
14
34
  # Basic version
15
35
  # <%= render 'headmin/forms/number', form: form, attribute: :amount %#>
36
+ #
37
+ # With data-list
38
+ # <%= render 'headmin/forms/number', form: form, attribute: :amount, list: [2,4,6,8,10] %#>
16
39
 
17
- append = local_assigns.has_key?(:append) ? append : nil
18
- class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
19
- collection = local_assigns.has_key?(:collection) ? collection : nil
20
- data = local_assigns.has_key?(:data) ? data : nil
21
- disabled = local_assigns.has_key?(:disabled) ? disabled : false
22
- float = local_assigns.has_key?(:float) ? float : false
23
- label = local_assigns.has_key?(:label) ? label : nil
24
- prepend = local_assigns.has_key?(:prepend) ? prepend : nil
25
- readonly = local_assigns.has_key?(:readonly) ? readonly : false
26
- required = local_assigns.has_key?(:required) ? required : false
40
+ placeholder = local_assigns[:float] ? local_assigns[:placeholder] || attribute : local_assigns[:placeholder]
27
41
 
28
- options = {
29
- 'aria-describedby': form_field_validation_id(form, attribute),
30
- class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
31
- data: data,
32
- disabled: disabled,
33
- list: collection ? attribute : nil,
34
- placeholder: attribute,
35
- readonly: readonly,
36
- required: required,
37
- }
42
+ option_keys = %i(aria autocomplete autofocus data disabled id in list max min placeholder readonly required step value within)
43
+ options = local_assigns.slice(*option_keys).merge(
44
+ aria: { describedby: form_field_validation_id(form, attribute) },
45
+ class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
46
+ list: local_assigns[:list] ? "#{attribute}_list" : nil,
47
+ placeholder: placeholder
48
+ )
38
49
  %>
39
50
 
40
- <%= render 'headmin/forms/base', form: form, attribute: attribute, append: append, prepend: prepend, float: float, label: label, required: required do |form| %>
51
+ <%= render 'headmin/forms/base', local_assigns do |form| %>
41
52
  <%= form.number_field(attribute, options) %>
42
53
  <% end %>
43
-
44
- <% if collection %>
45
- <datalist id="<%= attribute %>">
46
- <% collection.each do |key, value| %>
47
- <option value="<%= value %>"><%= key %></option>
48
- <% end %>
49
- </datalist>
50
- <% end %>
@@ -1,69 +1,48 @@
1
1
  <%
2
2
  # headmin/forms/password
3
3
  #
4
- # ==== Options
5
- # * <tt>form<tt> - Form object
6
- # * <tt>attribute<tt> - Name of the attribute of the form model
7
- # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
8
- # * <tt>float<tt> - Set to true if you want to show floating labels
9
- # * <tt>append<tt> - Text or icon to be shown on the left hand side of the input, Doesn't work with float
10
- # * <tt>prepend<tt> - Text or icon to be shown on the right hand side of the input, Doesn't work with float
4
+ # ==== Required parameters
5
+ # * +form+ - Form object
6
+ # * +attribute+ - Name of the attribute of the form model
7
+ #
8
+ # ==== Optional parameters
9
+ # * +aria+ - Provide a hash to define all aria attributes
10
+ # * +autocomplete+ - Value to be autofilled by the browser
11
+ # * +autofocus+ - Set to true to focus on this field when the page renders
12
+ # * +data+ - Provide a hash to define all data attributes
13
+ # * +disabled+ - Sets the placeholder of the field
14
+ # * +id+ - Input identifier
15
+ # * +list+ - Add array of options to show in a data list
16
+ # * +maxlength+ - The maximum number of characters that the browser will allow the user to enter.
17
+ # * +minlength+ - The minimum number of characters that the browser will allow the user to enter.
18
+ # * +placeholder+ - Sets the placeholder of the field
19
+ # * +readonly+ - Sets the placeholder of the field
20
+ # * +required+ - Set to true to mark as required
21
+ # * +size+ - The number of visible characters that will fit in the input
22
+ # * +value+ - Overrides the value of the form
23
+ #
24
+ # ==== Extra parameters
25
+ # Listed in 'headmin/forms/base'
26
+ #
27
+ # ==== References
28
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password
29
+ # https://apidock.com/rails/ActionView/Helpers/FormHelper/password_field
11
30
  #
12
31
  # ==== Examples
13
32
  # Basic version
14
33
  # <%= render 'headmin/forms/password', form: form, attribute: :password %#>
15
34
 
16
- append = local_assigns.has_key?(:append) ? append : nil
17
- class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
18
- data = local_assigns.has_key?(:data) ? data : nil
19
- disabled = local_assigns.has_key?(:disabled) ? disabled : false
20
- float = local_assigns.has_key?(:float) ? float : false
21
- label = local_assigns.has_key?(:label) ? label : nil
22
- prepend = local_assigns.has_key?(:prepend) ? prepend : nil
23
- readonly = local_assigns.has_key?(:readonly) ? readonly : false
24
- required = local_assigns.has_key?(:required) ? required : false
25
-
26
- options = {
27
- 'aria-describedby': form_field_validation_id(form, attribute),
28
- class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
29
- data: data,
30
- disabled: disabled,
31
- placeholder: attribute,
32
- readonly: readonly,
33
- required: required,
34
- }
35
+ placeholder = local_assigns[:float] ? local_assigns[:placeholder] || attribute : local_assigns[:placeholder]
35
36
 
36
- show_label = label != false
37
+ option_keys = %i(aria autocomplete autofocus data disabled id list maxlength minlength placeholder readonly required size value)
38
+ options = local_assigns.slice(*option_keys).merge(
39
+ autocomplete: true,
40
+ aria: { describedby: form_field_validation_id(form, attribute) },
41
+ class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
42
+ placeholder: placeholder
43
+ )
37
44
  %>
38
45
 
39
- <div class="<%= 'form-floating' if float %> <%= ('mb-3 text-start' if show_label) %>">
40
- <% if show_label && !float %>
41
- <%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
42
- <% end %>
43
-
44
- <% if float %>
45
- <%= form.password_field(attribute, options) %>
46
- <%= render 'headmin/forms/validation', form: form, attribute: attribute %>
47
- <% else %>
48
- <div class="input-group">
49
- <% if prepend %>
50
- <span class="input-group-text">
51
- <%= prepend %>
52
- </span>
53
- <% end %>
54
-
55
- <%= form.password_field(attribute, options) %>
56
- <%= render 'headmin/forms/validation', form: form, attribute: attribute %>
57
-
58
- <% if append %>
59
- <span class="input-group-text">
60
- <%= append %>
61
- </span>
62
- <% end %>
63
- </div>
64
- <% end %>
65
-
66
- <% if show_label && float %>
67
- <%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
68
- <% end %>
69
- </div>
46
+ <%= render 'headmin/forms/base', local_assigns do |form| %>
47
+ <%= form.password_field(attribute, options) %>
48
+ <% end %>
@@ -2,16 +2,16 @@
2
2
  # headmin/forms/redactorx
3
3
  #
4
4
  # ==== Options
5
- # * <tt>form<tt> - Form object
6
- # * <tt>attribute<tt> - Name of the attribute of the form model
7
- # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
8
- # * <tt>addbar<tt> - Items to show in the addbar
9
- # * <tt>topbar<tt> - Items to show in the topbar
10
- # * <tt>plugins<tt> - Plugin items to work with
5
+ # * +form+ - Form object
6
+ # * +attribute+ - Name of the attribute of the form model
7
+ # * +label+ - Text to show as label. Label will be hidden if value is false
8
+ # * +addbar+ - Items to show in the addbar
9
+ # * +topbar+ - Items to show in the topbar
10
+ # * +plugins+ - Plugin items to work with
11
11
  #
12
12
  # ==== Examples
13
13
  # Basic version
14
- # <%= render 'headmin/forms/textarea', form: form, attribute: :title %#>
14
+ # <%= render 'headmin/forms/redactorx', form: form, attribute: :title %#>
15
15
 
16
16
  class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
17
17
  data = local_assigns.has_key?(:data) ? data : {}
@@ -24,6 +24,7 @@
24
24
  topbar = local_assigns.has_key?(:topbar) ? topbar : []
25
25
 
26
26
  data = data.merge(
27
+ controller: 'redactorx',
27
28
  'redactor-options': {
28
29
  buttons: {
29
30
  addbar: addbar,
@@ -2,12 +2,12 @@
2
2
  # headmin/forms/repeater
3
3
  #
4
4
  # ==== Options
5
- # * <tt>form</tt> - Form object
6
- # * <tt>attribute</tt> - Name of the attribute of the form model
7
- # * <tt>header</tt> - Name of the template to use as header
8
- # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
9
- # * <tt>templates</tt> - List of all views that can be used as a template for a new block
10
- # * <tt>flush</tt> - Set to true if you want the list items to sit flush with its parent.
5
+ # * +form</tt> - Form object
6
+ # * +attribute</tt> - Name of the attribute of the form model
7
+ # * +header</tt> - Name of the template to use as header
8
+ # * +label+ - Text to show as label. Label will be hidden if value is false
9
+ # * +templates</tt> - List of all views that can be used as a template for a new block
10
+ # * +flush</tt> - Set to true if you want the list items to sit flush with its parent.
11
11
  #
12
12
  # ==== Examples
13
13
  # # Basic version
@@ -41,7 +41,8 @@
41
41
  template_names = template_names.any? ? template_names : ['new']
42
42
  object_model = form.object.class
43
43
  association_model = object_model.reflect_on_association(attribute).class_name.constantize
44
- with_positions = association_model.new.attributes.keys.include?('position')
44
+ association_object = association_model.new
45
+ with_positions = association_object.attributes.keys.include?('position')
45
46
  associations = form.object.send(attribute)
46
47
  associations = with_positions ? associations.order(:position) : associations
47
48
  repeater_id = form.object_id
@@ -114,15 +115,11 @@
114
115
 
115
116
  <!-- Templates -->
116
117
  <% template_names.each do |name| %>
117
- <template data-repeater-target="template" data-template-name="<%= name %>">
118
- <%= form.fields_for attribute, association_model.new, child_index: 'template_id' do |ff| %>
118
+ <template data-repeater-target="template" data-template-name="<%= name %>" data-template-id-regex="<%= association_object.object_id %>">
119
+ <%= form.fields_for attribute, association_object, child_index: association_object.object_id do |ff| %>
119
120
  <%= render 'headmin/forms/repeater/row', form: ff, pass_thru: pass_thru, repeater_id: repeater_id do %>
120
121
  <% template = templates.detect { |t| t.include?("/#{name}.") } %>
121
- <% if template %>
122
- <%= render(template.gsub('/_', '/'), form: ff) %>
123
- <% else %>
124
- <% yield(ff) %>
125
- <% end %>
122
+ <% yield(ff, template&.gsub('/_', '/')) %>
126
123
  <% end %>
127
124
  <% end %>
128
125
  </template>
@@ -1,31 +1,45 @@
1
1
  <%
2
2
  # headmin/forms/select
3
3
  #
4
- # ==== Options
5
- # * <tt>form<tt> - Form object
6
- # * <tt>attribute<tt> - Name of the attribute of the form model
7
- # * <tt>collection<tt> - Values to create option tags for
8
- # * <tt>multiple<tt> - Set to true if multiple selections are allowed
9
- # * <tt>tags<tt> - Set to true if new options are allowed to be created
10
- # * <tt>disabled<tt> - One or more values to be disabled in the option tags
11
- # * <tt>selected<tt> - Value to be marked as "selected"
12
- # * <tt>include_blank<tt> - Set to true or prompt string if the first option tag is a blank
13
- # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
14
- # * <tt>float<tt> - Set to true if you want to show floating labels
15
- # * <tt>append<tt> - Text or icon to be shown on the left hand side of the input, Doesn't work with float
16
- # * <tt>prepend<tt> - Text or icon to be shown on the right hand side of the input, Doesn't work with float
4
+ # ==== Required parameters
5
+ # * +form+ - Form object
6
+ # * +attribute+ - Name of the attribute of the form model
7
+ # * +collection+ - Values to create option tags for
8
+ #
9
+ # ==== Optional parameters
10
+ # * +aria+ - Provide a hash to define all aria attributes
11
+ # * +autocomplete+ - Value to be autofilled by the browser
12
+ # * +autofocus+ - Set to true to focus on this field when the page renders
13
+ # * +data+ - Optional HTML data attributes
14
+ # * +disabled+ - One or more values to be disabled in the option tags
15
+ # * +include_blank+ - Set to true or prompt string if the first option tag is a blank
16
+ # * +multiple+ - Set to true if multiple selections are allowed
17
+ # * +required+ - Set to true to mark as required
18
+ # * +selected+ - Value to be marked as "selected"
19
+ # * +size+ - The number of visible rows in a multiple select field
20
+ # * +tags+ - Set to true if new options are allowed to be created
21
+ #
22
+ # ==== Extra parameters
23
+ # Listed in 'headmin/forms/base'
24
+ #
25
+ # ==== References
26
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
27
+ # https://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/select
17
28
  #
18
29
  # ==== Examples
19
30
  # Basic version
20
31
  # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'] %#>
21
32
  #
22
- # Specify options to be disabled
33
+ # Disabled
34
+ # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], disabled: true %#>
35
+ #
36
+ # Disable specific options
23
37
  # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], disabled: ['red'] %#>
24
38
  #
25
39
  # Show blank option
26
40
  # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], include_blank: 'Pick a color' %#>
27
41
  #
28
- # Select a given option by default
42
+ # Select a default option
29
43
  # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], selected: 'green' %#>
30
44
  #
31
45
  # Allow multiple options to be selected
@@ -34,37 +48,21 @@
34
48
  # Allow multiple options to be selected and new options to be created
35
49
  # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], tags: true %#>
36
50
 
37
- append = local_assigns.has_key?(:append) ? append : nil
38
- class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
39
- data = local_assigns.has_key?(:data) ? data : {}
40
- disabled = local_assigns.has_key?(:disabled) ? disabled : false
41
- float = local_assigns.has_key?(:float) ? float : false
42
- include_blank = local_assigns.has_key?(:include_blank) ? include_blank : nil
43
- label = local_assigns.has_key?(:label) ? label : nil
44
- prepend = local_assigns.has_key?(:prepend) ? prepend : nil
45
- multiple = local_assigns.has_key?(:multiple) ? multiple : false
46
- required = local_assigns.has_key?(:required) ? required : false
47
- selected = local_assigns.has_key?(:selected) ? selected : nil
48
- tags = local_assigns.has_key?(:tags) ? tags : false
49
-
50
- data = data.merge({ tags: true }) if tags
51
-
52
- choices = options_for_select(collection, form.object.send(attribute))
53
- options = {
54
- include_blank: include_blank,
55
- disabled: disabled,
56
- selected: selected
57
- }
58
- html_options = {
59
- 'aria-describedby': form_field_validation_id(form, attribute),
60
- class: "form-select #{form_field_validation_class(form, attribute)} #{class_names}",
61
- data: data,
62
- multiple: tags ? true : multiple,
63
- required: required,
64
- }
51
+ options_keys = %i(include_blank selected disabled)
52
+ options = local_assigns.slice(*options_keys).merge(
53
+ selected: form.object&.send(attribute),
54
+ )
65
55
 
56
+ html_option_keys = %i(aria autocomplete autofocus data disabled id multiple required size)
57
+ html_options = local_assigns.slice(*html_option_keys).merge(
58
+ aria: { describedby: form_field_validation_id(form, attribute) },
59
+ class: ['form-select', form_field_validation_class(form, attribute)].join(' '),
60
+ data: { tags: local_assigns[:tags], controller: 'select'},
61
+ disabled: local_assigns[:disabled] == true,
62
+ multiple: local_assigns[:multiple] || local_assigns[:tags],
63
+ )
66
64
  %>
67
65
 
68
- <%= render 'headmin/forms/base', form: form, attribute: attribute, append: append, prepend: prepend, float: float, label: label, required: required do |form| %>
69
- <%= form.select(attribute, choices, options, html_options) %>
66
+ <%= render 'headmin/forms/base', local_assigns do |form| %>
67
+ <%= form.select(attribute, collection, options, html_options) %>
70
68
  <% end %>
@@ -1,62 +1,97 @@
1
- <%
2
- # headmin/forms/text
3
- #
4
- # ==== Options
5
- # * <tt>form<tt> - Form object
6
- # * <tt>attribute<tt> - Name of the attribute of the form model
7
- # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
8
- # * <tt>float<tt> - Set to true if you want to show floating labels
9
- # * <tt>collection<tt> - Add array of options to show in a data list
10
- # * <tt>append<tt> - Text or icon to be shown on the left hand side of the input, Doesn't work with float
11
- # * <tt>prepend<tt> - Text or icon to be shown on the right hand side of the input, Doesn't work with float
12
- #
13
- # ==== Examples
14
- # Basic version
15
- # <%= render 'headmin/forms/text', form: form, attribute: :title %#>
16
- #
17
- # Input without label
18
- # <%= render 'headmin/forms/text', form: form, attribute: :title, label: false %#>
19
- #
20
- # Input with custom label
21
- # <%= render 'headmin/forms/text', form: form, attribute: :title, label: 'Intro' %#>
22
- #
23
- # Input with floating label
24
- # <%= render 'headmin/forms/text', form: form, attribute: :title, float: true %#>
25
- #
26
- # Provide a data-list
27
- # <%= render 'headmin/forms/text', form: form, attribute: :title, collection: ['option 1', 'option 2', 'options 3'] %#>
28
-
29
- append = local_assigns.has_key?(:append) ? append : nil
30
- class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
31
- collection = local_assigns.has_key?(:collection) ? collection : nil
32
- data = local_assigns.has_key?(:data) ? data : nil
33
- disabled = local_assigns.has_key?(:disabled) ? disabled : false
34
- float = local_assigns.has_key?(:float) ? float : false
35
- label = local_assigns.has_key?(:label) ? label : nil
36
- prepend = local_assigns.has_key?(:prepend) ? prepend : nil
37
- readonly = local_assigns.has_key?(:readonly) ? readonly : false
38
- required = local_assigns.has_key?(:required) ? required : false
39
-
40
- options = {
41
- 'aria-describedby': form_field_validation_id(form, attribute),
42
- class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
43
- data: data,
44
- disabled: disabled,
45
- list: collection ? attribute : nil,
46
- placeholder: attribute,
47
- readonly: readonly,
48
- required: required,
49
- }
50
- %>
51
-
52
- <%= render 'headmin/forms/base', form: form, attribute: attribute, append: append, prepend: prepend, float: float, label: label, required: required do |form| %>
53
- <%= form.text_field(attribute, options) %>
1
+ <!--
2
+ <% documentation do %>
3
+ # Text
4
+ This is a wrapper around the form helper `text_field()`.
5
+ You can pass all valid input attributes as parameters to this template and
6
+ they will be added directly to the input field.
7
+
8
+ ```erbx
9
+ <%= form_with do |form| %>
10
+ <%= render "headmin/forms/text", form: form, attribute: "basic_example" %>
11
+ <% end %>
12
+ ```
13
+
14
+ ## Parameters
15
+ | Name | Required | Type | Description |
16
+ | ------------ | -------- | ---------------- | ----------- |
17
+ | form | yes | Object | Form object |
18
+ | attribute | yes | String, Symbol | Name of the attribute of the form model |
19
+ | aria | no | Hash | Provide a hash to define all aria attributes |
20
+ | autocomplete | no | String | Hint for form autofill feature |
21
+ | autofocus | no | Boolean | Automatically focus the form control when the page is loaded |
22
+ | data | no | Hash | Provide a hash to define all data attributes |
23
+ | disabled | no | Boolean | Whether the form control is disabled |
24
+ | dirname | no | String | Name of form field to use for sending the element"s directionality in form submission |
25
+ | id | no | String | Input identifier |
26
+ | list | no | Array | Add array of options to show in a data list |
27
+ | maxlength | no | Integer | Maximum length (number of characters) of value |
28
+ | minlength | no | Integer | Minimum length (number of characters) of value |
29
+ | pattern | no | String | Pattern the value must match to be valid |
30
+ | placeholder | no | String | Text that appears in the form control when it has no value set |
31
+ | readonly | no | Boolean | The value is not editable |
32
+ | required | no | Boolean | A value is required or must be check for the form to be submittable |
33
+ | size | no | Integer | Size of the control |
34
+ | spellcheck | no | Boolean | Indicate whether or not to enable spell checking by the browser |
35
+ | value | no | String | The initial value of the control |
36
+
37
+ **Additional parameters**
38
+
39
+ This view makes use of [headmin/forms/base](https://headmin.test/forms/base) for labels and appendages.
40
+ Take a look at its documentation to get a complete overview of all additional parameters.
41
+
42
+ ## Examples
43
+
44
+ ### Sizing
45
+ ```erbx
46
+ <%= form_with do |form| %>
47
+ <%= render "headmin/forms/text", form: form, attribute: "Small", class: "input-group-sm", placeholder: ".input-group-sm" %>
48
+ <%= render "headmin/forms/text", form: form, attribute: "Medium", class: "input-group-md", placeholder: 'default size' %>
49
+ <%= render "headmin/forms/text", form: form, attribute: "Large", class: "input-group-lg", placeholder: ".input-group-lg" %>
50
+ <% end %>
51
+ ```
52
+
53
+ ### Labels
54
+ ```erbx
55
+ <%= form_with do |form| %>
56
+ <%= render "headmin/forms/text", form: form, attribute: "no_label", label: false, placeholder: "Without label" %>
57
+ <%= render "headmin/forms/text", form: form, attribute: "floating_label", float: true %>
58
+ <%= render "headmin/forms/text", form: form, attribute: "custom_label", label: "Custom label" %>
59
+ <% end %>
60
+ ```
61
+
62
+ ### Appendages
63
+ ```erbx
64
+ <%= form_with do |form| %>
65
+ <%= render "headmin/forms/text", form: form, attribute: "prepend", prepend: "€" %>
66
+ <%= render "headmin/forms/text", form: form, attribute: "append", append: "m²" %>
67
+ <%= render "headmin/forms/text", form: form, attribute: "prepend_and_append", prepend: "€", append: "m²" %>
68
+ <% end %>
69
+ ```
70
+
71
+ ### List
72
+ ```erbx
73
+ <%= form_with do |form| %>
74
+ <%= render "headmin/forms/text", form: form, attribute: "list", list: %w[red green blue], placeholder: "With data list" %>
75
+ <% end %>
76
+ ```
77
+
78
+ ### States
79
+ ```erbx
80
+ <%= form_with do |form| %>
81
+ <%= render "headmin/forms/text", form: form, attribute: "disabled", disabled: true, placeholder: "Disabled" %>
82
+ <%= render "headmin/forms/text", form: form, attribute: "readonly", readonly: true, placeholder: "Readonly" %>
83
+ <%= render "headmin/forms/text", form: form, attribute: "disabled_and_readonly", disabled: true, readonly: true, placeholder: "Disabled and readonly" %>
84
+ <% end %>
85
+ ```
86
+
87
+ ## References
88
+ - [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text)
89
+ - [APIdock](https://apidock.com/rails/ActionView/Helpers/FormHelper/text_field)
54
90
  <% end %>
91
+ -->
92
+
93
+ <% text = Headmin::Form::Text.new(local_assigns) %>
55
94
 
56
- <% if collection %>
57
- <datalist id="<%= attribute %>">
58
- <% collection.each do |key, value| %>
59
- <option value="<%= value %>"><%= key %></option>
60
- <% end %>
61
- </datalist>
95
+ <%= render "headmin/forms/base", text.local_assigns do |form| %>
96
+ <%= form.text_field(text.attribute, text.options) %>
62
97
  <% end %>