headmin 0.3.4 → 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 (157) 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/CHANGELOG.md +24 -0
  6. data/Gemfile +7 -4
  7. data/Gemfile.lock +171 -3
  8. data/README.md +7 -0
  9. data/Rakefile +1 -7
  10. data/app/assets/javascripts/headmin/config/i18n.js +9 -9
  11. data/app/assets/javascripts/headmin/controllers/autocomplete_controller.js +255 -0
  12. data/app/assets/javascripts/headmin/controllers/blocks_controller.js +74 -79
  13. data/app/assets/javascripts/headmin/controllers/date_range_controller.js +24 -24
  14. data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +23 -25
  15. data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +237 -237
  16. data/app/assets/javascripts/headmin/controllers/filter_controller.js +44 -44
  17. data/app/assets/javascripts/headmin/controllers/filters_controller.js +57 -61
  18. data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +29 -29
  19. data/app/assets/javascripts/headmin/controllers/hello_controller.js +3 -3
  20. data/app/assets/javascripts/headmin/controllers/notification_controller.js +7 -6
  21. data/app/assets/javascripts/headmin/controllers/popup_controller.js +51 -52
  22. data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +36 -9
  23. data/app/assets/javascripts/headmin/controllers/repeater_controller.js +122 -125
  24. data/app/assets/javascripts/headmin/controllers/select_controller.js +40 -39
  25. data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +100 -101
  26. data/app/assets/javascripts/headmin/controllers/table_controller.js +115 -115
  27. data/app/assets/javascripts/headmin/index.js +38 -35
  28. data/app/assets/javascripts/headmin.js +243 -34
  29. data/app/assets/stylesheets/headmin/forms/autocomplete.scss +21 -0
  30. data/app/assets/stylesheets/headmin/forms/file.scss +46 -0
  31. data/app/assets/stylesheets/headmin/forms/repeater.scss +62 -0
  32. data/app/assets/stylesheets/headmin/forms/search.scss +12 -0
  33. data/app/assets/stylesheets/headmin/forms.scss +11 -0
  34. data/app/assets/stylesheets/headmin/general.scss +5 -0
  35. data/app/assets/stylesheets/headmin/overrides/bootstrap.scss +5 -3
  36. data/app/assets/stylesheets/headmin/overrides/redactorx.scss +74 -0
  37. data/app/assets/stylesheets/headmin/popup.scss +1 -0
  38. data/app/assets/stylesheets/headmin/syntax.scss +36 -349
  39. data/app/assets/stylesheets/headmin/table.scss +1 -1
  40. data/app/assets/stylesheets/headmin/utilities/buttons.scss +19 -0
  41. data/app/assets/stylesheets/headmin/utilities/dropzone.scss +72 -0
  42. data/app/assets/stylesheets/headmin/utilities.scss +2 -68
  43. data/app/assets/stylesheets/headmin.css +205 -205
  44. data/app/assets/stylesheets/headmin.scss +1 -1
  45. data/app/helpers/headmin/admin_helper.rb +0 -1
  46. data/app/helpers/headmin/form_helper.rb +2 -8
  47. data/app/models/concerns/headmin/blockable.rb +1 -1
  48. data/app/models/concerns/headmin/field.rb +1 -0
  49. data/app/models/concerns/headmin/form/autocompletable.rb +38 -0
  50. data/app/models/concerns/headmin/form/hintable.rb +19 -0
  51. data/app/models/concerns/headmin/form/input_groupable.rb +23 -0
  52. data/app/models/concerns/headmin/form/labelable.rb +33 -0
  53. data/app/models/concerns/headmin/form/listable.rb +28 -0
  54. data/app/models/concerns/headmin/form/placeholderable.rb +13 -0
  55. data/app/models/concerns/headmin/form/validatable.rb +40 -0
  56. data/app/models/concerns/headmin/form/wrappable.rb +21 -0
  57. data/app/models/headmin/.DS_Store +0 -0
  58. data/app/models/headmin/blocks_view.rb +15 -0
  59. data/app/models/headmin/form/blocks_view.rb +29 -0
  60. data/app/models/headmin/form/checkbox_view.rb +52 -0
  61. data/app/models/headmin/form/date_range_view.rb +25 -0
  62. data/app/models/headmin/form/date_view.rb +45 -0
  63. data/app/models/headmin/form/email_view.rb +48 -0
  64. data/app/models/headmin/form/file_view.rb +116 -0
  65. data/app/models/headmin/form/flatpickr_range_view.rb +102 -0
  66. data/app/models/headmin/form/flatpickr_view.rb +37 -0
  67. data/app/models/headmin/form/hidden_view.rb +10 -0
  68. data/app/models/headmin/form/hint_view.rb +6 -0
  69. data/app/models/headmin/form/input_group_view.rb +19 -0
  70. data/app/models/headmin/form/label_view.rb +24 -0
  71. data/app/models/headmin/form/number_view.rb +49 -0
  72. data/app/models/headmin/form/password_view.rb +44 -0
  73. data/app/models/headmin/form/redactorx_view.rb +59 -0
  74. data/app/models/headmin/form/search_view.rb +48 -0
  75. data/app/models/headmin/form/select_view.rb +62 -0
  76. data/app/models/headmin/form/switch_view.rb +23 -0
  77. data/app/models/headmin/form/text_view.rb +48 -0
  78. data/app/models/headmin/form/textarea_view.rb +44 -0
  79. data/app/models/headmin/form/url_view.rb +48 -0
  80. data/app/models/headmin/form/wrapper_view.rb +19 -0
  81. data/app/models/headmin/form/wysiwyg_view.rb +17 -0
  82. data/app/models/headmin/{thumbnail.rb → thumbnail_view.rb} +6 -1
  83. data/app/models/view_model.rb +58 -0
  84. data/app/views/headmin/_blocks.html.erb +13 -9
  85. data/app/views/headmin/_heading.html.erb +7 -1
  86. data/app/views/headmin/_thumbnail.html.erb +1 -37
  87. data/app/views/headmin/forms/_autocomplete.html.erb +11 -0
  88. data/app/views/headmin/forms/_blocks.html.erb +16 -17
  89. data/app/views/headmin/forms/_checkbox.html.erb +24 -29
  90. data/app/views/headmin/forms/_datalist.html.erb +3 -0
  91. data/app/views/headmin/forms/_date.html.erb +24 -24
  92. data/app/views/headmin/forms/_date_range.html.erb +19 -21
  93. data/app/views/headmin/forms/_email.html.erb +27 -32
  94. data/app/views/headmin/forms/_errors.html.erb +2 -3
  95. data/app/views/headmin/forms/_file.html.erb +84 -181
  96. data/app/views/headmin/forms/_flatpickr.html.erb +19 -20
  97. data/app/views/headmin/forms/_flatpickr_range.html.erb +28 -37
  98. data/app/views/headmin/forms/_hidden.html.erb +9 -10
  99. data/app/views/headmin/forms/_hint.html.erb +16 -0
  100. data/app/views/headmin/forms/_input_group.html.erb +21 -0
  101. data/app/views/headmin/forms/_label.html.erb +5 -13
  102. data/app/views/headmin/forms/_number.html.erb +23 -35
  103. data/app/views/headmin/forms/_password.html.erb +21 -30
  104. data/app/views/headmin/forms/_redactorx.html.erb +21 -40
  105. data/app/views/headmin/forms/_repeater.html.erb +55 -60
  106. data/app/views/headmin/forms/_search.html.erb +43 -0
  107. data/app/views/headmin/forms/_select.html.erb +24 -49
  108. data/app/views/headmin/forms/_switch.html.erb +29 -0
  109. data/app/views/headmin/forms/_text.html.erb +42 -96
  110. data/app/views/headmin/forms/_textarea.html.erb +21 -32
  111. data/app/views/headmin/forms/_url.html.erb +26 -31
  112. data/app/views/headmin/forms/_validation.html.erb +10 -13
  113. data/app/views/headmin/forms/_wrapper.html.erb +9 -0
  114. data/app/views/headmin/forms/_wysiwyg.html.erb +28 -0
  115. data/app/views/headmin/forms/autocomplete/_item.html.erb +3 -0
  116. data/app/views/headmin/forms/autocomplete/_list.html.erb +3 -0
  117. data/app/views/headmin/forms/fields/_group.html.erb +5 -3
  118. data/app/views/headmin/forms/repeater/_row.html.erb +4 -4
  119. data/bin/console +0 -1
  120. data/config/locales/headmin/forms/en.yml +0 -11
  121. data/config/locales/headmin/forms/nl.yml +0 -11
  122. data/esbuild-css.js +18 -18
  123. data/esbuild-js.js +8 -8
  124. data/headmin.gemspec +1 -3
  125. data/lib/generators/templates/controllers/auth/confirmations_controller.rb +0 -2
  126. data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +0 -2
  127. data/lib/generators/templates/controllers/auth/passwords_controller.rb +0 -2
  128. data/lib/generators/templates/controllers/auth/registrations_controller.rb +0 -2
  129. data/lib/generators/templates/controllers/auth/sessions_controller.rb +0 -2
  130. data/lib/generators/templates/controllers/auth/unlocks_controller.rb +0 -2
  131. data/lib/headmin/version.rb +1 -3
  132. data/lib/headmin.rb +0 -2
  133. data/package-lock.json +5359 -0
  134. data/package.json +12 -4
  135. data/view_model_benchmark.rb +74 -0
  136. data/yarn-error.log +17 -12
  137. data/yarn.lock +1575 -31
  138. metadata +62 -24
  139. data/app/assets/stylesheets/headmin/form.scss +0 -132
  140. data/app/assets/stylesheets/headmin/overrides/redactorx.css +0 -3
  141. data/app/helpers/headmin/documentation_helper.rb +0 -35
  142. data/app/models/headmin/documentation_renderer.rb +0 -32
  143. data/app/models/headmin/form/base.rb +0 -78
  144. data/app/models/headmin/form/text.rb +0 -51
  145. data/app/services/block_service.rb +0 -72
  146. data/app/views/headmin/_card.html.erb +0 -52
  147. data/app/views/headmin/forms/_actions.html.erb +0 -28
  148. data/app/views/headmin/forms/_base.html.erb +0 -114
  149. data/app/views/headmin/forms/_image.html.erb +0 -21
  150. data/app/views/headmin/forms/_video.html.erb +0 -21
  151. data/app/views/headmin/forms/actions/_destroy.html.erb +0 -13
  152. data/app/views/headmin/forms/actions/_save.html.erb +0 -12
  153. data/app/views/headmin/forms/actions/_view.html.erb +0 -15
  154. data/docs/blocks-and-fields.md +0 -54
  155. data/docs/blocks.md +0 -48
  156. data/docs/devise.md +0 -41
  157. data/docs/fields.md +0 -79
@@ -2,67 +2,42 @@
2
2
  # headmin/forms/select
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
  # * +collection+ - Values to create option tags for
8
8
  #
9
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'
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
+ # * +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
+ # * +tags+ - Allow options to be created dynamically. This will set the multiple attribute to true
18
+ # * +wrapper+ - Hash with all options for the surrounding html tag
24
19
  #
25
20
  # ==== References
21
+ # https://headmin.dev/docs/forms/select
26
22
  # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
27
23
  # https://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/select
28
24
  #
29
25
  # ==== Examples
30
26
  # Basic version
31
- # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'] %#>
32
- #
33
- # Disabled
34
- # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], disabled: true %#>
35
- #
36
- # Disable specific options
37
- # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], disabled: ['red'] %#>
38
- #
39
- # Show blank option
40
- # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], include_blank: 'Pick a color' %#>
41
- #
42
- # Select a default option
43
- # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], selected: 'green' %#>
44
- #
45
- # Allow multiple options to be selected
46
- # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], multiple: true %#>
47
- #
48
- # Allow multiple options to be selected and new options to be created
49
- # <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], tags: true %#>
50
-
51
- options_keys = %i(include_blank selected disabled)
52
- options = local_assigns.slice(*options_keys).merge(
53
- selected: form.object&.send(attribute),
54
- )
27
+ # <%= form_with do |form| %#>
28
+ # <%= render "headmin/forms/select", form: form, attribute: :color, collection: %w[red green blue] %#>
29
+ # <% end %#>
55
30
 
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
- )
31
+ select = Headmin::Form::SelectView.new(local_assigns)
64
32
  %>
65
33
 
66
- <%= render 'headmin/forms/base', local_assigns do |form| %>
67
- <%= form.select(attribute, collection, options, html_options) %>
34
+ <%= render "headmin/forms/wrapper", select.wrapper_options do %>
35
+ <%= render "headmin/forms/label", select.label_options if select.prepend_label? %>
36
+ <%= render "headmin/forms/input_group", select.input_group_options do %>
37
+ <%= form.select(select.attribute, select.collection, select.select_options, select.input_options) %>
38
+ <% end %>
39
+ <%= render "headmin/forms/validation", select.validation_options if select.validate? %>
40
+ <%= render "headmin/forms/hint", select.hint_options if select.hint? %>
41
+ <%= render "headmin/forms/datalist", select.datalist_options if select.datalist? %>
42
+ <%= render "headmin/forms/label", select.label_options if select.append_label? %>
68
43
  <% end %>
@@ -0,0 +1,29 @@
1
+ <%
2
+ # headmin/forms/switch
3
+ #
4
+ # ==== Required parameters
5
+ # * +attribute+ - Name of the attribute of the form model
6
+ # * +form+ - Form object
7
+ #
8
+ # ==== Optional parameters
9
+ # * +checked_value+ - Value for checked state
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
+ # * +unchecked_value+ - Value for unchecked state
13
+ # * +wrapper+ - Hash with all options for the surrounding html tag
14
+ #
15
+ # ==== References
16
+ # https://headmin.dev/docs/forms/switch
17
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox
18
+ # https://apidock.com/rails/ActionView/Helpers/FormHelper/check_box
19
+ #
20
+ # ==== Examples
21
+ # Basic version
22
+ # <%= form_with do |form| %#>
23
+ # <%= render "headmin/forms/switch", form: form, attribute: :active %#>
24
+ # <% end %#>
25
+
26
+ switch = Headmin::Form::SwitchView.new(local_assigns)
27
+ %>
28
+
29
+ <%= render "headmin/forms/checkbox", switch.options %>
@@ -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>
@@ -32,7 +32,9 @@
32
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>
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,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))