headmin 0.3.2 → 0.4.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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +27 -0
  3. data/.gitignore +14 -0
  4. data/.nvmrc +1 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +24 -0
  7. data/Gemfile +8 -5
  8. data/Gemfile.lock +197 -25
  9. data/README.md +9 -1
  10. data/Rakefile +1 -7
  11. data/app/assets/images/document.docx +0 -0
  12. data/app/assets/images/document.pdf +0 -0
  13. data/app/assets/images/image.jpg +0 -0
  14. data/app/assets/images/spreadsheet.xls +0 -0
  15. data/app/assets/images/video.mp4 +0 -0
  16. data/app/assets/javascripts/headmin/config/i18n.js +9 -9
  17. data/app/assets/javascripts/headmin/controllers/autocomplete_controller.js +255 -0
  18. data/app/assets/javascripts/headmin/controllers/blocks_controller.js +74 -79
  19. data/app/assets/javascripts/headmin/controllers/date_range_controller.js +24 -24
  20. data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +23 -25
  21. data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +237 -237
  22. data/app/assets/javascripts/headmin/controllers/filter_controller.js +44 -44
  23. data/app/assets/javascripts/headmin/controllers/filters_controller.js +57 -61
  24. data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +29 -29
  25. data/app/assets/javascripts/headmin/controllers/hello_controller.js +3 -3
  26. data/app/assets/javascripts/headmin/controllers/notification_controller.js +7 -6
  27. data/app/assets/javascripts/headmin/controllers/popup_controller.js +51 -52
  28. data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +36 -9
  29. data/app/assets/javascripts/headmin/controllers/repeater_controller.js +122 -125
  30. data/app/assets/javascripts/headmin/controllers/select_controller.js +40 -39
  31. data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +88 -77
  32. data/app/assets/javascripts/headmin/controllers/table_controller.js +103 -89
  33. data/app/assets/javascripts/headmin/index.js +38 -39
  34. data/app/assets/javascripts/headmin.js +287 -732
  35. data/app/assets/stylesheets/headmin/forms/autocomplete.scss +21 -0
  36. data/app/assets/stylesheets/headmin/forms/file.scss +46 -0
  37. data/app/assets/stylesheets/headmin/forms/repeater.scss +62 -0
  38. data/app/assets/stylesheets/headmin/forms/search.scss +12 -0
  39. data/app/assets/stylesheets/headmin/forms.scss +11 -0
  40. data/app/assets/stylesheets/headmin/general.scss +5 -0
  41. data/app/assets/stylesheets/headmin/overrides/bootstrap.scss +5 -3
  42. data/app/assets/stylesheets/headmin/overrides/redactorx.scss +74 -0
  43. data/app/assets/stylesheets/headmin/popup.scss +1 -0
  44. data/app/assets/stylesheets/headmin/syntax.scss +36 -349
  45. data/app/assets/stylesheets/headmin/table.scss +1 -1
  46. data/app/assets/stylesheets/headmin/utilities/buttons.scss +19 -0
  47. data/app/assets/stylesheets/headmin/utilities/dropzone.scss +72 -0
  48. data/app/assets/stylesheets/headmin/utilities.scss +2 -68
  49. data/app/assets/stylesheets/headmin/vendor/tom-select-bootstrap.css +1 -2
  50. data/app/assets/stylesheets/headmin.css +206 -206
  51. data/app/assets/stylesheets/headmin.scss +1 -1
  52. data/app/controllers/concerns/headmin/authentication.rb +1 -1
  53. data/app/controllers/concerns/headmin/searchable.rb +1 -1
  54. data/app/controllers/concerns/headmin/sortable.rb +7 -7
  55. data/app/helpers/headmin/admin_helper.rb +1 -2
  56. data/app/helpers/headmin/bootstrap_helper.rb +2 -24
  57. data/app/helpers/headmin/filter_helper.rb +1 -1
  58. data/app/helpers/headmin/form_helper.rb +5 -11
  59. data/app/helpers/headmin/notification_helper.rb +21 -21
  60. data/app/helpers/headmin/request_helper.rb +3 -3
  61. data/app/models/concerns/headmin/block.rb +1 -2
  62. data/app/models/concerns/headmin/blockable.rb +2 -2
  63. data/app/models/concerns/headmin/field.rb +2 -1
  64. data/app/models/concerns/headmin/fieldable.rb +8 -8
  65. data/app/models/concerns/headmin/form/autocompletable.rb +38 -0
  66. data/app/models/concerns/headmin/form/hintable.rb +19 -0
  67. data/app/models/concerns/headmin/form/input_groupable.rb +23 -0
  68. data/app/models/concerns/headmin/form/labelable.rb +33 -0
  69. data/app/models/concerns/headmin/form/listable.rb +28 -0
  70. data/app/models/concerns/headmin/form/placeholderable.rb +13 -0
  71. data/app/models/concerns/headmin/form/validatable.rb +40 -0
  72. data/app/models/concerns/headmin/form/wrappable.rb +21 -0
  73. data/app/models/headmin/.DS_Store +0 -0
  74. data/app/models/headmin/blocks_view.rb +15 -0
  75. data/app/models/headmin/form/blocks_view.rb +29 -0
  76. data/app/models/headmin/form/checkbox_view.rb +52 -0
  77. data/app/models/headmin/form/date_range_view.rb +25 -0
  78. data/app/models/headmin/form/date_view.rb +45 -0
  79. data/app/models/headmin/form/email_view.rb +48 -0
  80. data/app/models/headmin/form/file_view.rb +116 -0
  81. data/app/models/headmin/form/flatpickr_range_view.rb +102 -0
  82. data/app/models/headmin/form/flatpickr_view.rb +37 -0
  83. data/app/models/headmin/form/hidden_view.rb +10 -0
  84. data/app/models/headmin/form/hint_view.rb +6 -0
  85. data/app/models/headmin/form/input_group_view.rb +19 -0
  86. data/app/models/headmin/form/label_view.rb +24 -0
  87. data/app/models/headmin/form/number_view.rb +49 -0
  88. data/app/models/headmin/form/password_view.rb +44 -0
  89. data/app/models/headmin/form/redactorx_view.rb +59 -0
  90. data/app/models/headmin/form/search_view.rb +48 -0
  91. data/app/models/headmin/form/select_view.rb +62 -0
  92. data/app/models/headmin/form/switch_view.rb +23 -0
  93. data/app/models/headmin/form/text_view.rb +48 -0
  94. data/app/models/headmin/form/textarea_view.rb +44 -0
  95. data/app/models/headmin/form/url_view.rb +48 -0
  96. data/app/models/headmin/form/wrapper_view.rb +19 -0
  97. data/app/models/headmin/form/wysiwyg_view.rb +17 -0
  98. data/app/models/headmin/thumbnail_view.rb +66 -0
  99. data/app/models/view_model.rb +58 -0
  100. data/app/views/headmin/_blocks.html.erb +13 -9
  101. data/app/views/headmin/_heading.html.erb +7 -1
  102. data/app/views/headmin/_thumbnail.html.erb +5 -39
  103. data/app/views/headmin/dropdown/_item.html.erb +1 -1
  104. data/app/views/headmin/forms/_autocomplete.html.erb +11 -0
  105. data/app/views/headmin/forms/_blocks.html.erb +16 -17
  106. data/app/views/headmin/forms/_checkbox.html.erb +24 -29
  107. data/app/views/headmin/forms/_datalist.html.erb +3 -0
  108. data/app/views/headmin/forms/_date.html.erb +24 -24
  109. data/app/views/headmin/forms/_date_range.html.erb +19 -21
  110. data/app/views/headmin/forms/_email.html.erb +27 -32
  111. data/app/views/headmin/forms/_errors.html.erb +2 -3
  112. data/app/views/headmin/forms/_file.html.erb +84 -181
  113. data/app/views/headmin/forms/_flatpickr.html.erb +19 -20
  114. data/app/views/headmin/forms/_flatpickr_range.html.erb +28 -37
  115. data/app/views/headmin/forms/_hidden.html.erb +9 -10
  116. data/app/views/headmin/forms/_hint.html.erb +16 -0
  117. data/app/views/headmin/forms/_input_group.html.erb +21 -0
  118. data/app/views/headmin/forms/_label.html.erb +5 -13
  119. data/app/views/headmin/forms/_number.html.erb +23 -35
  120. data/app/views/headmin/forms/_password.html.erb +21 -30
  121. data/app/views/headmin/forms/_redactorx.html.erb +21 -40
  122. data/app/views/headmin/forms/_repeater.html.erb +55 -60
  123. data/app/views/headmin/forms/_search.html.erb +43 -0
  124. data/app/views/headmin/forms/_select.html.erb +24 -49
  125. data/app/views/headmin/forms/_switch.html.erb +29 -0
  126. data/app/views/headmin/forms/_text.html.erb +42 -96
  127. data/app/views/headmin/forms/_textarea.html.erb +21 -32
  128. data/app/views/headmin/forms/_url.html.erb +26 -31
  129. data/app/views/headmin/forms/_validation.html.erb +10 -13
  130. data/app/views/headmin/forms/_wrapper.html.erb +9 -0
  131. data/app/views/headmin/forms/_wysiwyg.html.erb +28 -0
  132. data/app/views/headmin/forms/autocomplete/_item.html.erb +3 -0
  133. data/app/views/headmin/forms/autocomplete/_list.html.erb +3 -0
  134. data/app/views/headmin/forms/fields/_group.html.erb +6 -4
  135. data/app/views/headmin/forms/repeater/_row.html.erb +4 -4
  136. data/app/views/headmin/nav/item/_devise.html.erb +1 -1
  137. data/app/views/headmin/table/_actions.html.erb +1 -1
  138. data/app/views/headmin/table/actions/_action.html.erb +2 -1
  139. data/app/views/headmin/table/actions/_delete.html.erb +1 -1
  140. data/app/views/headmin/views/devise/registrations/_edit.html.erb +2 -2
  141. data/bin/console +0 -1
  142. data/config/initializers/customize_input_error.rb +4 -4
  143. data/config/locales/headmin/forms/en.yml +0 -11
  144. data/config/locales/headmin/forms/nl.yml +0 -11
  145. data/esbuild-css.js +18 -18
  146. data/esbuild-js.js +8 -8
  147. data/headmin.gemspec +1 -3
  148. data/lib/generators/headmin/blocks_generator.rb +8 -8
  149. data/lib/generators/headmin/devise_generator.rb +4 -4
  150. data/lib/generators/headmin/fields_generator.rb +9 -9
  151. data/lib/generators/templates/controllers/auth/confirmations_controller.rb +1 -3
  152. data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +1 -3
  153. data/lib/generators/templates/controllers/auth/passwords_controller.rb +1 -3
  154. data/lib/generators/templates/controllers/auth/registrations_controller.rb +1 -3
  155. data/lib/generators/templates/controllers/auth/sessions_controller.rb +1 -3
  156. data/lib/generators/templates/controllers/auth/unlocks_controller.rb +1 -3
  157. data/lib/generators/templates/models/block.rb +1 -1
  158. data/lib/headmin/engine.rb +6 -6
  159. data/lib/headmin/version.rb +1 -3
  160. data/lib/headmin.rb +0 -2
  161. data/package-lock.json +5359 -0
  162. data/package.json +13 -7
  163. data/view_model_benchmark.rb +74 -0
  164. data/yarn-error.log +367 -0
  165. data/yarn.lock +1448 -161
  166. metadata +69 -25
  167. data/.rubocop.yml +0 -13
  168. data/app/assets/stylesheets/headmin/form.scss +0 -132
  169. data/app/assets/stylesheets/headmin/overrides/redactorx.css +0 -3
  170. data/app/helpers/headmin/documentation_helper.rb +0 -35
  171. data/app/models/headmin/documentation_renderer.rb +0 -32
  172. data/app/models/headmin/form/base.rb +0 -79
  173. data/app/models/headmin/form/text.rb +0 -53
  174. data/app/services/block_service.rb +0 -72
  175. data/app/views/headmin/_card.html.erb +0 -52
  176. data/app/views/headmin/forms/_actions.html.erb +0 -28
  177. data/app/views/headmin/forms/_base.html.erb +0 -114
  178. data/app/views/headmin/forms/_image.html.erb +0 -21
  179. data/app/views/headmin/forms/_video.html.erb +0 -21
  180. data/app/views/headmin/forms/actions/_destroy.html.erb +0 -13
  181. data/app/views/headmin/forms/actions/_save.html.erb +0 -12
  182. data/app/views/headmin/forms/actions/_view.html.erb +0 -15
  183. data/docs/blocks-and-fields.md +0 -54
  184. data/docs/blocks.md +0 -48
  185. data/docs/devise.md +0 -41
  186. data/docs/fields.md +0 -79
@@ -1,97 +1,43 @@
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" %>
1
+ <%
2
+ # headmin/forms/text
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/text
21
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
22
+ # https://apidock.com/rails/ActionView/Helpers/FormHelper/text_field
23
+ #
24
+ # ==== Examples
25
+ # Basic version
26
+ # <%= form_with do |form| %#>
27
+ # <%= render "headmin/forms/text", form: form, attribute: :title %#>
28
+ # <% end %#>
29
+
30
+ text = Headmin::Form::TextView.new(local_assigns)
31
+ %>
32
+
33
+ <%= render "headmin/forms/wrapper", text.wrapper_options do %>
34
+ <%= render "headmin/forms/label", text.label_options if text.prepend_label? %>
35
+ <%= render "headmin/forms/input_group", text.input_group_options do %>
36
+ <%= form.text_field(text.attribute, text.input_options) %>
37
+ <%= render "headmin/forms/datalist", text.datalist_options if text.datalist? %>
38
+ <%= render "headmin/forms/autocomplete", text.autocomplete_options if text.autocomplete? %>
59
39
  <% 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)
90
- <% end %>
91
- -->
92
-
93
- <% text = Headmin::Form::Text.new(local_assigns, request) %>
94
-
95
- <%= render "headmin/forms/base", text.local_assigns do |form| %>
96
- <%= form.text_field(text.attribute, text.options) %>
97
- <% end %>
40
+ <%= render "headmin/forms/validation", text.validation_options if text.validate? %>
41
+ <%= render "headmin/forms/hint", text.hint_options if text.hint? %>
42
+ <%= render "headmin/forms/label", text.label_options if text.append_label? %>
43
+ <% end %>
@@ -2,49 +2,38 @@
2
2
  # headmin/forms/textarea
3
3
  #
4
4
  # ==== Required parameters
5
- # * +form+ - Form object
6
5
  # * +attribute+ - Name of the attribute of the form model
6
+ # * +form+ - Form object
7
7
  #
8
8
  # ==== Optional parameters
9
- # * +aria+ - Provide a hash to define all aria attributes
10
- # * +autocomplete+ - Value to be autofilled by the browser
11
- # * +autofocus+ - Value to be autofilled by the browser
12
- # * +cols+ - Visible width in average charachter width (default = 20)
13
- # * +data+ - Provide a hash to define all data attributes
14
- # * +disabled+ - Sets the placeholder of the field
15
- # * +id+ - Input identifier
16
- # * +maxlength+ - Maximum amount of characters to be used
17
- # * +minlength+ - Minimum amount of characters to be used
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
- # * +rows+ - Visible text lines
22
- # * +spellcheck+ - Indicate whether or not to enable spell checking by the browser
23
- # * +value+ - Overrides the value of the form
24
- # * +wrap+ - How to wrap text. Soft (default), hard, or off
25
- #
26
- # ==== Extra parameters
27
- # Listed in 'headmin/forms/base'
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
28
16
  #
29
17
  # ==== References
18
+ # https://headmin.dev/docs/forms/textarea
30
19
  # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
31
20
  # https://apidock.com/rails/ActionView/Helpers/FormHelper/text_area
32
21
  #
33
22
  # ==== Examples
34
23
  # Basic version
35
- # <%= render 'headmin/forms/textarea', form: form, attribute: :title %#>
36
-
37
- placeholder = local_assigns[:float] ? local_assigns[:placeholder] || attribute : local_assigns[:placeholder]
24
+ # <%= form_with do |form| %#>
25
+ # <%= render "headmin/forms/textarea", form: form, attribute: :text %#>
26
+ # <% end %#>
38
27
 
39
- option_keys = %i(aria autocomplete autofocus cols data disabled id maxlength minlength placeholder readonly required rows spellcheck value wrap)
40
- options = local_assigns.slice(*option_keys).merge(
41
- aria: { describedby: form_field_validation_id(form, attribute) },
42
- class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
43
- list: local_assigns[:list] ? "#{attribute}_list" : nil,
44
- placeholder: placeholder
45
- )
28
+ textarea = Headmin::Form::TextareaView.new(local_assigns)
46
29
  %>
47
30
 
48
- <%= render 'headmin/forms/base', local_assigns do |form| %>
49
- <%= form.text_area(attribute, options) %>
31
+ <%= render "headmin/forms/wrapper", textarea.wrapper_options do %>
32
+ <%= render "headmin/forms/label", textarea.label_options if textarea.prepend_label? %>
33
+ <%= render "headmin/forms/input_group", textarea.input_group_options do %>
34
+ <%= form.text_area(textarea.attribute, textarea.input_options) %>
35
+ <% end %>
36
+ <%= render "headmin/forms/validation", textarea.validation_options if textarea.validate? %>
37
+ <%= render "headmin/forms/hint", textarea.hint_options if textarea.hint? %>
38
+ <%= render "headmin/forms/label", textarea.label_options if textarea.append_label? %>
50
39
  <% end %>
@@ -2,47 +2,42 @@
2
2
  # headmin/forms/url
3
3
  #
4
4
  # ==== Required parameters
5
- # * +form+ - Form object
6
5
  # * +attribute+ - Name of the attribute of the form model
6
+ # * +form+ - Form object
7
7
  #
8
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
- # * +maxlength+ - Maximum amount of characters to be used
16
- # * +minlength+ - Minimum amount of characters to be used
17
- # * +list+ - Add array of options to show in a data list
18
- # * +pattern+ -a A regular expression that the input's value must match
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
- # * +size+ - How much of the input should be shown
23
- # * +value+ - Overrides the value of the form
24
- #
25
- # ==== Extra parameters
26
- # Listed in 'headmin/forms/base'
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
27
18
  #
28
19
  # ==== References
29
- # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
20
+ # https://headmin.dev/docs/forms/url
21
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url
30
22
  # https://apidock.com/rails/ActionView/Helpers/FormHelper/url_field
31
23
  #
32
24
  # ==== Examples
33
25
  # Basic version
34
- # <%= render 'headmin/forms/url', form: form, attribute: :website_url %#>
35
-
36
- placeholder = local_assigns[:float] ? local_assigns[:placeholder] || attribute : local_assigns[:placeholder]
26
+ # <%= form_with do |form| %#>
27
+ # <%= render "headmin/forms/url", form: form, attribute: :website_url %#>
28
+ # <% end %#>
37
29
 
38
- option_keys = %i(aria autocomplete autofocus data disabled id list placeholder maxlength minlength pattern readonly required size value)
39
- options = local_assigns.slice(*option_keys).merge(
40
- aria: { describedby: form_field_validation_id(form, attribute) },
41
- class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
42
- placeholder: placeholder
43
- )
30
+ url = Headmin::Form::UrlView.new(local_assigns)
44
31
  %>
45
32
 
46
- <%= render 'headmin/forms/base', local_assigns do |form| %>
47
- <%= form.url_field(attribute, options) %>
33
+ <%= render "headmin/forms/wrapper", url.wrapper_options do %>
34
+ <%= render "headmin/forms/label", url.label_options if url.prepend_label? %>
35
+ <%= render "headmin/forms/input_group", url.input_group_options do %>
36
+ <%= form.url_field(url.attribute, url.input_options) %>
37
+ <%= render "headmin/forms/datalist", url.datalist_options if url.datalist? %>
38
+ <%= render "headmin/forms/autocomplete", url.autocomplete_options if url.autocomplete? %>
39
+ <% end %>
40
+ <%= render "headmin/forms/validation", url.validation_options if url.validate? %>
41
+ <%= render "headmin/forms/hint", url.hint_options if url.hint? %>
42
+ <%= render "headmin/forms/label", url.label_options if url.append_label? %>
48
43
  <% end %>
@@ -1,21 +1,18 @@
1
1
  <%
2
2
  # headmin/forms/validation
3
3
  #
4
- # ==== Options
5
- # * +form+ - Form object
6
- # * +attribute+ - Name of the attribute of the form model
4
+ # ==== Required parameters
5
+ # * +id+ - Form object
6
+ # * +message+ - Name of the attribute of the form model
7
+ #
8
+ # ==== Optional parameters
9
+ # * +valid+ - Show success message when true, failure message when false (default: true)
7
10
  #
8
11
  # ==== Examples
9
12
  # Basic version
10
- # <%= render 'headmin/forms/validation', form: form, attribute: attribute %#>
11
-
12
- show_feedback = form.object && !form_field_valid?(form, attribute)
13
- id = form_field_validation_id(form, attribute)
14
- message = form.object&.errors[attribute]&.join(', ')
13
+ # <%= render "headmin/forms/validation", id: id, message: message %#>
15
14
  %>
16
15
 
17
- <% if show_feedback %>
18
- <div class="invalid-feedback" id="<%= id %>">
19
- <%= message %>
20
- </div>
21
- <% end %>
16
+ <div class="<%= valid ? "valid-feedback" : "invalid-feedback" %>" id="<%= id %>">
17
+ <%= message %>
18
+ </div>
@@ -0,0 +1,9 @@
1
+ <% wrapper = Headmin::Form::WrapperView.new(local_assigns) %>
2
+
3
+ <% if wrapper.bypass %>
4
+ <%= yield %>
5
+ <% else %>
6
+ <div <%= tag.attributes(wrapper.options) %>>
7
+ <%= yield %>
8
+ </div>
9
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <%
2
+ # headmin/forms/wysiwyg
3
+ #
4
+ # ==== Required parameters
5
+ # * +attribute+ - Name of the attribute of the form model
6
+ # * +form+ - Form object
7
+ #
8
+ # ==== Optional parameters
9
+ # * +hint+ - Informative text to assist with data input. HTML markup is allowed.
10
+ # * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
11
+ # * +toolbar+ - Show toolbar (default true)
12
+ # * +wrapper+ - Hash with all options for the surrounding html tag
13
+ #
14
+ # ==== References
15
+ # https://headmin.dev/docs/forms/redactorx
16
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
17
+ # https://apidock.com/rails/ActionView/Helpers/FormHelper/text_area
18
+ #
19
+ # ==== Examples
20
+ # Basic version
21
+ # <%= form_with do |form| %#>
22
+ # <%= render "headmin/forms/redactorx", form: form, attribute: :text %#>
23
+ # <% end %#>
24
+
25
+ wysiwyg = Headmin::Form::WysiwygView.new(local_assigns)
26
+ %>
27
+
28
+ <%= render "headmin/forms/redactorx", wysiwyg.options %>
@@ -0,0 +1,3 @@
1
+ <li class="list-group-item list-group-item-action" data-autocomplete-target="dropdownItem" value="<%= value %>" data-action="click->autocomplete#select">
2
+ <%= yield %>
3
+ </li>
@@ -0,0 +1,3 @@
1
+ <ul class="list-group-flush">
2
+ <%= yield %>
3
+ </ul>
@@ -29,10 +29,12 @@
29
29
 
30
30
  <%= render 'headmin/forms/fields/base', form: form, name: name, field_type: :group do |group, field_label| %>
31
31
  <% if show_label %>
32
- <%= render 'headmin/forms/label', form: form, attribute: :value, name: label || field_label %>
32
+ <%= render 'headmin/forms/label', form: form, attribute: :value, text: label || field_label %>
33
33
  <% end %>
34
34
 
35
- <li class="list-group-item mb-3">
36
- <%= yield group %>
37
- </li>
35
+ <ul class="list-group mb-3">
36
+ <li class="list-group-item">
37
+ <%= yield group %>
38
+ </li>
39
+ </ul>
38
40
  <% end %>
@@ -28,7 +28,7 @@
28
28
  <% end %>
29
29
 
30
30
  <!-- Add button-->
31
- <a href="#"
31
+ <div
32
32
  class="repeater-row-add btn btn-link"
33
33
  title="<%= t('.add') %>"
34
34
  data-repeater-target="addButton"
@@ -38,14 +38,14 @@
38
38
  data-action="click->repeater#resetButtonIndices click->popup#open"
39
39
  >
40
40
  <%= bootstrap_icon('plus-circle') %>
41
- </a>
41
+ </div>
42
42
 
43
43
  <!-- Remove button-->
44
- <a href="#"
44
+ <div
45
45
  class="repeater-row-remove btn btn-link"
46
46
  title="<%= t('.remove') %>"
47
47
  data-action="click->repeater#removeRow"
48
48
  >
49
49
  <%= bootstrap_icon('dash-circle') %>
50
- </a>
50
+ </div>
51
51
  </div>
@@ -16,6 +16,6 @@
16
16
  <%= render 'headmin/dropdown/list', id: 'nav-item-devise' do %>
17
17
  <%= render 'headmin/dropdown/item', name: t('.edit_profile'), url: polymorphic_path([:edit, singular, :registration]) %>
18
18
  <%= render 'headmin/dropdown/divider' %>
19
- <%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), method: :delete %>
19
+ <%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), data: { "turbo-method": "delete" } %>
20
20
  <% end %>
21
21
  <% end %>
@@ -13,7 +13,7 @@
13
13
 
14
14
  <% content_for :table_actions do %>
15
15
  <th class="h-table-actions d-none" data-controller="table-actions" data-table-actions-target="wrapper" data-table-target="actions">
16
- <%= form_with url: '', data: { 'table-actions-target': 'form' } do |form| %>
16
+ <%= form_with url: '', data: { "table-actions-target": 'form' } do |form| %>
17
17
  <%= form.hidden_field :authenticity_token, value: form_authenticity_token %>
18
18
  <%= form.hidden_field :_method, value: 'POST', 'data-table-actions-target': 'method' %>
19
19
  <%= query_parameter_fields(form) %>
@@ -20,8 +20,9 @@
20
20
  url = local_assigns.has_key?(:url) ? local_assigns[:url] : request.path
21
21
  method = local_assigns.has_key?(:method) ? local_assigns[:method] : 'GET'
22
22
  confirm = local_assigns.has_key?(:confirm) ? local_assigns[:confirm] : nil
23
+ turbo = confirm ? true : false
23
24
  %>
24
25
 
25
- <option value="<%= url %>" data-method="<%= method %>" <% if confirm %>data-confirm="<%= confirm %>"<%end %>>
26
+ <option value="<%= url %>" data-method="<%= method %>" <% if confirm %>data-turbo-confirm="<%= confirm %>"<% end %> <% unless turbo %>data-turbo="false"<%end %>>
26
27
  <%= name %>
27
28
  </option>
@@ -9,4 +9,4 @@
9
9
  # <%= render "headmin/table/actions/delete", url: delete_admin_products_path %#>
10
10
  %>
11
11
 
12
- <%= render 'headmin/table/actions/action', name: t('.button'), url: url, method: :delete, confirm: t('.confirm') %>
12
+ <%= render "headmin/table/actions/action", name: t(".button"), url: url, method: "DELETE", confirm: t(".confirm") %>
@@ -1,5 +1,5 @@
1
1
  <div>
2
- <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put}) do |f| %>
2
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
3
3
  <%= render "headmin/views/devise/shared/error_messages", resource: resource %>
4
4
 
5
5
  <%= render 'headmin/forms/email', form: f, attribute: :email, required: true, float: true %>
@@ -19,6 +19,6 @@
19
19
  <h4><%= t('.cancel') %></h4>
20
20
 
21
21
  <p><%= t('.unhappy') %></p>
22
- <%= button_to t('.cancel'), registration_path(resource_name), class: 'btn btn-lg btn-danger w-100', data: {confirm: "Are you sure?"}, method: :delete %>
22
+ <%= button_to t('.cancel'), registration_path(resource_name), class: 'btn btn-lg btn-danger w-100', "data-turbo-confirm": "Are you sure?", "data-turbo-method": "delete" %>
23
23
  </div>
24
24
  </div>
data/bin/console CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
2
 
4
3
  require "bundler/setup"
5
4
  require "headmin"
@@ -1,9 +1,9 @@
1
- ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
1
+ ActionView::Base.field_error_proc = proc do |html_tag, instance|
2
2
  class_attr_index = html_tag.index 'class="'
3
3
 
4
4
  if class_attr_index
5
- html_tag.insert class_attr_index+7, 'error '
5
+ html_tag.insert class_attr_index + 7, "error "
6
6
  else
7
- html_tag.insert html_tag.index('>'), ' class="error"'
7
+ html_tag.insert html_tag.index(">"), ' class="error"'
8
8
  end
9
- end
9
+ end
@@ -1,17 +1,6 @@
1
1
  en:
2
2
  headmin:
3
3
  forms:
4
- actions:
5
- description: Status & visibility
6
- destroy:
7
- title: Delete
8
- confirm: Are you sure you want to delete this?
9
- format: '%m-%d-%Y %H:%M'
10
- save:
11
- title: Save
12
- title: Status
13
- view:
14
- title: View
15
4
  file:
16
5
  not_found: Not available
17
6
  placeholder:
@@ -1,17 +1,6 @@
1
1
  nl:
2
2
  headmin:
3
3
  forms:
4
- actions:
5
- description: Status & zichtbaarheid
6
- destroy:
7
- title: Verwijderen
8
- confirm: Ben je zeker dat je dit wil verwijderen?
9
- format: '%d-%m-%Y %H:%M'
10
- save:
11
- title: Opslaan
12
- title: Status
13
- view:
14
- title: Bekijken
15
4
  file:
16
5
  not_found: Niet beschikbaar
17
6
  placeholder:
data/esbuild-css.js CHANGED
@@ -1,25 +1,25 @@
1
- const esbuild = require("esbuild");
2
- const sassPlugin = require("esbuild-sass-plugin").sassPlugin;
1
+ const esbuild = require('esbuild')
2
+ const sassPlugin = require('esbuild-sass-plugin').sassPlugin
3
3
  const watch = process.argv.includes('-w')
4
4
 
5
5
  // Used to skip external URLs in scss files
6
6
  const externalUrlPlugin = {
7
- name: "custom-resolver",
8
- setup(build) {
9
- build.onResolve({filter: /^https?:\/\//}, ({path}) => {
10
- return {path, external: true, namespace: "provided"};
11
- });
12
- }
7
+ name: 'custom-resolver',
8
+ setup (build) {
9
+ build.onResolve({ filter: /^https?:\/\// }, ({ path }) => {
10
+ return { path, external: true, namespace: 'provided' }
11
+ })
12
+ }
13
13
  }
14
14
 
15
15
  esbuild.build({
16
- entryPoints: ['src/scss/headmin.scss'],
17
- outfile: 'app/assets/stylesheets/headmin.css',
18
- bundle: true,
19
- watch: watch,
20
- allowOverwrite: true,
21
- plugins: [
22
- externalUrlPlugin,
23
- sassPlugin()
24
- ]
25
- }).catch((e) => console.error(e.message));
16
+ entryPoints: ['src/scss/headmin.scss'],
17
+ outfile: 'app/assets/stylesheets/headmin.css',
18
+ bundle: true,
19
+ watch: watch,
20
+ allowOverwrite: true,
21
+ plugins: [
22
+ externalUrlPlugin,
23
+ sassPlugin()
24
+ ]
25
+ }).catch((e) => console.error(e.message))
data/esbuild-js.js CHANGED
@@ -1,11 +1,11 @@
1
- const esbuild = require("esbuild");
1
+ const esbuild = require('esbuild')
2
2
  const watch = process.argv.includes('-w')
3
3
 
4
4
  esbuild.build({
5
- entryPoints: ['src/js/headmin.js'],
6
- outfile: 'app/assets/javascripts/headmin.js',
7
- bundle: true,
8
- allowOverwrite: true,
9
- format: 'esm',
10
- watch: watch
11
- }).catch((e) => console.error(e.message));
5
+ entryPoints: ['src/js/headmin.js'],
6
+ outfile: 'app/assets/javascripts/headmin.js',
7
+ bundle: true,
8
+ allowOverwrite: true,
9
+ format: 'esm',
10
+ watch: watch
11
+ }).catch((e) => console.error(e.message))
data/headmin.gemspec CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require_relative "lib/headmin/version"
4
2
 
5
3
  Gem::Specification.new do |spec|
@@ -32,7 +30,7 @@ Gem::Specification.new do |spec|
32
30
  spec.add_runtime_dependency "closure_tree", "~> 7.4"
33
31
  spec.add_runtime_dependency "inline_svg", "~> 1.7"
34
32
  spec.add_runtime_dependency "redcarpet", "~> 3.5"
35
- spec.add_runtime_dependency "rouge", "~> 3.27"
33
+ spec.add_runtime_dependency "rouge", "~> 3.28"
36
34
 
37
35
  # For more information and examples about making a new gem, checkout our
38
36
  # guide at: https://bundler.io/guides/creating_gem.html