form_components 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +32 -24
- data/app/components/form_components/check_box/component.html.erb +16 -0
- data/app/components/form_components/collection/component.html.erb +13 -0
- data/app/components/form_components/color_field/component.html.erb +10 -0
- data/app/components/form_components/combobox/component.html.erb +10 -0
- data/app/components/form_components/file_field/component.html.erb +13 -0
- data/app/components/form_components/nested_form/component.html.erb +19 -0
- data/app/components/form_components/nested_form/component.rb +12 -8
- data/app/components/form_components/radio_button/component.html.erb +14 -0
- data/app/components/form_components/select/component.html.erb +10 -0
- data/app/components/form_components/text_area/component.html.erb +20 -0
- data/app/components/form_components/text_field/component.html.erb +23 -0
- data/app/form_builders/form_components/form_builder.rb +14 -9
- data/lib/form_components/version.rb +1 -1
- data/lib/form_components.rb +0 -1
- metadata +11 -25
- data/app/components/form_components/check_box/component.html.slim +0 -13
- data/app/components/form_components/collection/component.html.slim +0 -10
- data/app/components/form_components/color_field/component.html.slim +0 -8
- data/app/components/form_components/combobox/component.html.slim +0 -8
- data/app/components/form_components/file_field/component.html.slim +0 -10
- data/app/components/form_components/nested_form/component.html.slim +0 -20
- data/app/components/form_components/radio_button/component.html.slim +0 -12
- data/app/components/form_components/select/component.html.slim +0 -8
- data/app/components/form_components/text_area/component.html.slim +0 -14
- data/app/components/form_components/text_field/component.html.slim +0 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb4d786c398395142f8b487666fc51999ef5a58ec727eb53af5abe6e71ae2e2b
|
|
4
|
+
data.tar.gz: 77c200345adba5f4e75a9eac9a1dc146176fafc29e6229ed0eced8c37787cd32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b3ca6d9bc89211b163ca6c1aebc54ebbe516368597e2e6e2928cf075be0a62307aa692669d7217e379b5ce85a9b378eff0cb7449fc1a1b5f5bcd796515abeac
|
|
7
|
+
data.tar.gz: 5a575a867ca65b1e9f25f5ac2c9d761d46908829f82963f979213a6dd0f4e717dc8a5831969362ddef44d05f3794094e511aa0b9fb2ff9ca922b748a89d48186
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
- The templates are ERB; slim-rails is no longer a dependency. They render
|
|
6
|
+
the same HTML as the Slim ones did, apart from whitespace between tags.
|
|
7
|
+
|
|
8
|
+
## 0.1.1
|
|
4
9
|
|
|
5
10
|
- Every helper takes Rails' arguments and renders Rails' own input, so
|
|
6
11
|
names, ids, values and options are Rails' (with `index:`, `namespace:`,
|
data/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# Form components
|
|
2
2
|
|
|
3
3
|
A form builder for Rails whose fields are view components (ViewComponent,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
color and file fields, a submit button and
|
|
4
|
+
Stimulus, Tailwind CSS v4), as a Rails engine: labels, text fields of every
|
|
5
|
+
type, text areas, check boxes, radio buttons and their collections, selects,
|
|
6
|
+
a combobox, ratings, scales, color and file fields, a submit button and
|
|
7
|
+
nested forms. Each field has its
|
|
7
8
|
label (marked when the attribute is required), a description, and its errors.
|
|
8
9
|
|
|
9
10
|
The fields are Rails' own: every helper takes the arguments Rails' form
|
|
@@ -62,16 +63,19 @@ Instead of the importmap, a bundler resolves these imports to the gem:
|
|
|
62
63
|
|
|
63
64
|
## Usage
|
|
64
65
|
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
```erb
|
|
67
|
+
<%= form_with model: @post, builder: FormComponents::FormBuilder do |f| %>
|
|
68
|
+
<%= f.text_field :title, placeholder: "A title", description: "Shown on top", leading_icon: "fas fa-heading" %>
|
|
69
|
+
<%= f.email_field :email, corner_hint: "Optional" %>
|
|
70
|
+
<%= f.text_area :body, label: false %>
|
|
71
|
+
<%= f.check_box :published %>
|
|
72
|
+
<%= f.collection_radio_buttons :kind, Kind.all, :id, :name, {description_method: :hint}, {class: "mine"} %>
|
|
73
|
+
<%= f.select :category, Post::CATEGORIES, {include_blank: true}, description: "Where it goes" %>
|
|
74
|
+
<%= f.rating_field :rating %>
|
|
75
|
+
<%= f.color_field :color, swatches: ["#e6007e", "#1e40af"], default: "#e6007e" %>
|
|
76
|
+
<%= f.file_field :logo, accept: "image/*", preview: @post.logo %>
|
|
77
|
+
<%= f.submit %>
|
|
78
|
+
<% end %>
|
|
75
79
|
```
|
|
76
80
|
|
|
77
81
|
### As the default form builder
|
|
@@ -144,23 +148,27 @@ place (`.form-component .field_with_errors { display: contents }`).
|
|
|
144
148
|
A field's label is marked when its attribute has a presence validator. Pass
|
|
145
149
|
the validation context to the form to count those `on:` it:
|
|
146
150
|
|
|
147
|
-
```
|
|
148
|
-
|
|
151
|
+
```erb
|
|
152
|
+
<%= form_with model: @post, builder: FormComponents::FormBuilder, validation_context: :publish do |f| %>
|
|
149
153
|
```
|
|
150
154
|
|
|
151
155
|
### Nested forms
|
|
152
156
|
|
|
153
157
|
For a has_many association with `accepts_nested_attributes_for`:
|
|
154
158
|
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
button type="button" data-action="form-components--nested-form#remove"
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
```erb
|
|
160
|
+
<%= f.nested_form :sections do |nf| %>
|
|
161
|
+
<% nf.with_item do |sf| %>
|
|
162
|
+
<div class="section-wrapper" data-new-record="<%= sf.object.new_record? %>">
|
|
163
|
+
<%= sf.hidden_field :_destroy %>
|
|
164
|
+
<%= sf.text_field :title %>
|
|
165
|
+
<button type="button" data-action="form-components--nested-form#remove">Remove</button>
|
|
166
|
+
</div>
|
|
167
|
+
<% end %>
|
|
168
|
+
<% nf.with_add_button do %>
|
|
169
|
+
<button type="button">Add section</button>
|
|
170
|
+
<% end %>
|
|
171
|
+
<% end %>
|
|
164
172
|
```
|
|
165
173
|
|
|
166
174
|
The add button adds a new item from a template, the remove button removes a
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div class="form-component flex gap-3">
|
|
2
|
+
<div class="flex h-6 shrink-0 items-center">
|
|
3
|
+
<div class="group grid size-4 grid-cols-1"><%= input %></div>
|
|
4
|
+
</div>
|
|
5
|
+
<div class="text-sm/6">
|
|
6
|
+
<% if label != false %>
|
|
7
|
+
<div class="flex justify-between"><%= field_label(input_id, value: (checked_value if html_options[:multiple])) %></div>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% if description.present? %>
|
|
10
|
+
<label class="text-gray-500 auto-dark:text-gray-400" for="<%= input_id %>" id="<%= input_id %>_description"><%= description %></label>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% if has_error? %>
|
|
13
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= input_id %>_error"><%= all_errors.join(", ") %></p>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<fieldset <%= tag.attributes("aria-describedby": aria_described_by, class: "form-component") %>>
|
|
2
|
+
<% if label != false %>
|
|
3
|
+
<legend class="<%= legend_classes %>"><%= legend %></legend>
|
|
4
|
+
<% end %>
|
|
5
|
+
<% if description.present? %>
|
|
6
|
+
<p class="<%= class_names("text-sm/6 text-gray-500 auto-dark:text-gray-400", "mt-1" => label != false) %>" id="<%= tag_id %>_description"><%= description %></p>
|
|
7
|
+
<% end %>
|
|
8
|
+
<div class="<%= class_names(items_classes, "mt-2" => label != false || description.present?) %>"><%= items %></div>
|
|
9
|
+
<%= after_items %>
|
|
10
|
+
<% if has_error? %>
|
|
11
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= tag_id %>_error"><%= all_errors.join(", ") %></p>
|
|
12
|
+
<% end %>
|
|
13
|
+
</fieldset>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<div class="form-component">
|
|
2
|
+
<%= field_label %>
|
|
3
|
+
<div <%= tag.attributes(class: class_names("form-color-field mt-2", "form-color-field--error" => has_error?, "form-color-field--default" => default_color), "data-controller": "form-components--color-field", "data-form-components--color-field-swatches-value": swatches.to_json, style: (default_color && "--color-field-default: #{default_color}")) %>><%= input %></div>
|
|
4
|
+
<% if description.present? %>
|
|
5
|
+
<p class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" id="<%= tag_id %>_description"><%= description %></p>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% if has_error? %>
|
|
8
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= tag_id %>_error"><%= all_errors.join(", ") %></p>
|
|
9
|
+
<% end %>
|
|
10
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<div class="form-component">
|
|
2
|
+
<%= field_label %>
|
|
3
|
+
<div class="mt-2"><%= input %></div>
|
|
4
|
+
<% if description.present? %>
|
|
5
|
+
<p class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" id="<%= tag_id %>_description"><%= description %></p>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% if has_error? %>
|
|
8
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= tag_id %>_error"><%= all_errors.join(", ") %></p>
|
|
9
|
+
<% end %>
|
|
10
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<div class="form-component">
|
|
2
|
+
<%= field_label %>
|
|
3
|
+
<% if preview? %>
|
|
4
|
+
<%= image_tag helpers.main_app.url_for(preview.representation(resize_to_limit: [300, 120])), class: "mt-2 max-h-20 rounded", alt: "" %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<div class="mt-2"><%= input %></div>
|
|
7
|
+
<% if description.present? %>
|
|
8
|
+
<p class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" id="<%= tag_id %>_description"><%= description %></p>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% if has_error? %>
|
|
11
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= tag_id %>_error"><%= all_errors.join(", ") %></p>
|
|
12
|
+
<% end %>
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<%# Stimulus form-components--nested-form controller:
|
|
2
|
+
data-form-components--nested-form-placeholder-value — token replaced with a timestamp on "Add"
|
|
3
|
+
data-form-components--nested-form-wrapper-selector-value — CSS selector for remove-button scope %>
|
|
4
|
+
<div data-controller="form-components--nested-form" data-form-components--nested-form-placeholder-value="<%= placeholder %>" data-form-components--nested-form-wrapper-selector-value="<%= wrapper_selector %>">
|
|
5
|
+
<template data-form-components--nested-form-target="template"><%= form.fields_for(method, new_record_object, child_index: placeholder, &item_block) %></template>
|
|
6
|
+
|
|
7
|
+
<%# The collection %>
|
|
8
|
+
<%= form.fields_for(method, &item_block) %>
|
|
9
|
+
|
|
10
|
+
<div data-form-components--nested-form-target="insertion"></div>
|
|
11
|
+
|
|
12
|
+
<span data-action="click->form-components--nested-form#add">
|
|
13
|
+
<% if add_button? %>
|
|
14
|
+
<%= add_button %>
|
|
15
|
+
<% else %>
|
|
16
|
+
<button class="mt-4 inline-flex items-center gap-x-2 rounded-md border border-dashed border-primary-300 px-4 py-3 text-sm font-medium text-primary-600 hover:border-primary-500 hover:bg-primary-50" type="button"><i class="fal fa-plus"></i><span><%= add_label %></span></button>
|
|
17
|
+
<% end %>
|
|
18
|
+
</span>
|
|
19
|
+
</div>
|
|
@@ -4,15 +4,19 @@ module FormComponents
|
|
|
4
4
|
module NestedForm
|
|
5
5
|
# ViewComponent that encapsulates the Stimulus-driven nested-form pattern.
|
|
6
6
|
#
|
|
7
|
-
# Usage (
|
|
7
|
+
# Usage (with a FormComponents::FormBuilder):
|
|
8
8
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
9
|
+
# <%= f.nested_form :sections do |nf| %>
|
|
10
|
+
# <% nf.with_item do |sf| %>
|
|
11
|
+
# <div class="section-wrapper" data-new-record="<%= sf.object.new_record? %>">
|
|
12
|
+
# <%= sf.hidden_field :_destroy %>
|
|
13
|
+
# <%= sf.text_field :title %>
|
|
14
|
+
# </div>
|
|
15
|
+
# <% end %>
|
|
16
|
+
# <% nf.with_add_button do %>
|
|
17
|
+
# <button type="button" data-action="form-components--nested-form#add">Add section</button>
|
|
18
|
+
# <% end %>
|
|
19
|
+
# <% end %>
|
|
16
20
|
#
|
|
17
21
|
# The same +with_item+ block is used for both:
|
|
18
22
|
# • the hidden HTML <template> tag (rendered with a new record so that
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<div class="form-component relative flex items-start">
|
|
2
|
+
<div class="flex h-6 items-center"><%= input %></div>
|
|
3
|
+
<div class="ml-3 text-sm/6">
|
|
4
|
+
<% if label != false %>
|
|
5
|
+
<div class="flex justify-between"><%= field_label(input_id, value: tag_value) %></div>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% if description.present? %>
|
|
8
|
+
<label class="text-gray-500 auto-dark:text-gray-400" for="<%= input_id %>" id="<%= input_id %>_description"><%= description %></label>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% if has_error? %>
|
|
11
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= input_id %>_error"><%= all_errors.join(", ") %></p>
|
|
12
|
+
<% end %>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<div class="form-component">
|
|
2
|
+
<%= field_label %>
|
|
3
|
+
<div class="mt-2"><%= input %></div>
|
|
4
|
+
<% if description.present? %>
|
|
5
|
+
<p class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" id="<%= tag_id %>_description"><%= description %></p>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% if has_error? %>
|
|
8
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= tag_id %>_error"><%= all_errors.join(", ") %></p>
|
|
9
|
+
<% end %>
|
|
10
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<div class="form-component">
|
|
2
|
+
<% if label != false || corner_hint.present? %>
|
|
3
|
+
<div class="flex justify-between">
|
|
4
|
+
<%= field_label %>
|
|
5
|
+
<span class="text-sm/6 text-gray-500 auto-dark:text-gray-400"><%= corner_hint %></span>
|
|
6
|
+
</div>
|
|
7
|
+
<% end %>
|
|
8
|
+
<div class="mt-2 grid grid-cols-1">
|
|
9
|
+
<%= input %>
|
|
10
|
+
<% if has_error? %>
|
|
11
|
+
<div class="fas fa-circle-exclamation pointer-events-none col-start-1 row-start-1 mr-3 size-5 self-center justify-self-end text-red-500 sm:size-4"></div>
|
|
12
|
+
<% end %>
|
|
13
|
+
</div>
|
|
14
|
+
<% if description.present? %>
|
|
15
|
+
<p class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" id="<%= tag_id %>_description"><%= description %></p>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% if has_error? %>
|
|
18
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= tag_id %>_error"><%= all_errors.join(", ") %></p>
|
|
19
|
+
<% end %>
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<div class="form-component">
|
|
2
|
+
<% if label != false || corner_hint.present? %>
|
|
3
|
+
<div class="flex justify-between">
|
|
4
|
+
<%= field_label %>
|
|
5
|
+
<span class="text-sm/6 text-gray-500 auto-dark:text-gray-400"><%= corner_hint %></span>
|
|
6
|
+
</div>
|
|
7
|
+
<% end %>
|
|
8
|
+
<div class="mt-2 grid grid-cols-1">
|
|
9
|
+
<%= input %>
|
|
10
|
+
<% if leading_icon.present? %>
|
|
11
|
+
<span class="<%= class_names("pointer-events-none col-start-1 row-start-1 ml-3 size-5 self-center text-gray-400 sm:size-4", leading_icon) %>"></span>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% if has_error? %>
|
|
14
|
+
<div class="fas fa-circle-exclamation pointer-events-none col-start-1 row-start-1 mr-3 size-5 self-center justify-self-end text-red-500 sm:size-4"></div>
|
|
15
|
+
<% end %>
|
|
16
|
+
</div>
|
|
17
|
+
<% if description.present? %>
|
|
18
|
+
<p class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" id="<%= tag_id %>_description"><%= description %></p>
|
|
19
|
+
<% end %>
|
|
20
|
+
<% if has_error? %>
|
|
21
|
+
<p class="mt-2 text-sm text-red-600 auto-dark:text-red-400" id="<%= tag_id %>_error"><%= all_errors.join(", ") %></p>
|
|
22
|
+
<% end %>
|
|
23
|
+
</div>
|
|
@@ -9,8 +9,9 @@ module FormComponents
|
|
|
9
9
|
# get. Helpers without a component here, such as hidden_field or date_select,
|
|
10
10
|
# are Rails'.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
12
|
+
# <%= form_with model: @post, builder: FormComponents::FormBuilder do |f| %>
|
|
13
|
+
# <%= f.text_field :title %>
|
|
14
|
+
# <% end %>
|
|
14
15
|
class FormBuilder < ActionView::Helpers::FormBuilder
|
|
15
16
|
include FormComponents::ValidationContext
|
|
16
17
|
|
|
@@ -107,13 +108,17 @@ module FormComponents
|
|
|
107
108
|
# Renders a Stimulus-driven nested form for a has_many association.
|
|
108
109
|
# The block receives the component (nf) so you can declare slots:
|
|
109
110
|
#
|
|
110
|
-
#
|
|
111
|
-
#
|
|
112
|
-
#
|
|
113
|
-
#
|
|
114
|
-
#
|
|
115
|
-
#
|
|
116
|
-
#
|
|
111
|
+
# <%= f.nested_form :sections do |nf| %>
|
|
112
|
+
# <% nf.with_item do |sf| %>
|
|
113
|
+
# <div class="section-wrapper" data-new-record="<%= sf.object.new_record? %>">
|
|
114
|
+
# <%= sf.hidden_field :_destroy %>
|
|
115
|
+
# <%= sf.text_field :title %>
|
|
116
|
+
# </div>
|
|
117
|
+
# <% end %>
|
|
118
|
+
# <% nf.with_add_button do %>
|
|
119
|
+
# <button type="button" data-action="form-components--nested-form#add">Add section</button>
|
|
120
|
+
# <% end %>
|
|
121
|
+
# <% end %>
|
|
117
122
|
#
|
|
118
123
|
# Options (keyword arguments):
|
|
119
124
|
# placeholder: – Stimulus token replaced on clone, default "NEW_<SINGULAR>"
|
data/lib/form_components.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: form_components
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tom de Grunt
|
|
@@ -37,20 +37,6 @@ dependencies:
|
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '3'
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: slim-rails
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '3'
|
|
47
|
-
type: :runtime
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - ">="
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '3'
|
|
54
40
|
- !ruby/object:Gem::Dependency
|
|
55
41
|
name: importmap-rails
|
|
56
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -80,35 +66,35 @@ files:
|
|
|
80
66
|
- app/assets/stylesheets/form_components/application.css
|
|
81
67
|
- app/assets/tailwind/form_components/engine.css
|
|
82
68
|
- app/components/form_components/base/component.rb
|
|
83
|
-
- app/components/form_components/check_box/component.html.
|
|
69
|
+
- app/components/form_components/check_box/component.html.erb
|
|
84
70
|
- app/components/form_components/check_box/component.rb
|
|
85
|
-
- app/components/form_components/collection/component.html.
|
|
71
|
+
- app/components/form_components/collection/component.html.erb
|
|
86
72
|
- app/components/form_components/collection/component.rb
|
|
87
73
|
- app/components/form_components/collection_check_boxes/component.rb
|
|
88
74
|
- app/components/form_components/collection_radio_buttons/component.rb
|
|
89
75
|
- app/components/form_components/color_field/component.css
|
|
90
|
-
- app/components/form_components/color_field/component.html.
|
|
76
|
+
- app/components/form_components/color_field/component.html.erb
|
|
91
77
|
- app/components/form_components/color_field/component.rb
|
|
92
78
|
- app/components/form_components/color_field/component_controller.js
|
|
93
|
-
- app/components/form_components/combobox/component.html.
|
|
79
|
+
- app/components/form_components/combobox/component.html.erb
|
|
94
80
|
- app/components/form_components/combobox/component.rb
|
|
95
81
|
- app/components/form_components/field/component.rb
|
|
96
|
-
- app/components/form_components/file_field/component.html.
|
|
82
|
+
- app/components/form_components/file_field/component.html.erb
|
|
97
83
|
- app/components/form_components/file_field/component.rb
|
|
98
84
|
- app/components/form_components/label/component.rb
|
|
99
|
-
- app/components/form_components/nested_form/component.html.
|
|
85
|
+
- app/components/form_components/nested_form/component.html.erb
|
|
100
86
|
- app/components/form_components/nested_form/component.rb
|
|
101
87
|
- app/components/form_components/nested_form/component_controller.js
|
|
102
|
-
- app/components/form_components/radio_button/component.html.
|
|
88
|
+
- app/components/form_components/radio_button/component.html.erb
|
|
103
89
|
- app/components/form_components/radio_button/component.rb
|
|
104
90
|
- app/components/form_components/rating_field/component.rb
|
|
105
91
|
- app/components/form_components/scale_field/component.rb
|
|
106
|
-
- app/components/form_components/select/component.html.
|
|
92
|
+
- app/components/form_components/select/component.html.erb
|
|
107
93
|
- app/components/form_components/select/component.rb
|
|
108
94
|
- app/components/form_components/submit/component.rb
|
|
109
|
-
- app/components/form_components/text_area/component.html.
|
|
95
|
+
- app/components/form_components/text_area/component.html.erb
|
|
110
96
|
- app/components/form_components/text_area/component.rb
|
|
111
|
-
- app/components/form_components/text_field/component.html.
|
|
97
|
+
- app/components/form_components/text_field/component.html.erb
|
|
112
98
|
- app/components/form_components/text_field/component.rb
|
|
113
99
|
- app/components/form_components/validation.rb
|
|
114
100
|
- app/form_builders/form_components/form_builder.rb
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
.form-component.flex.gap-3
|
|
2
|
-
.flex.h-6.shrink-0.items-center
|
|
3
|
-
.group.grid.size-4.grid-cols-1
|
|
4
|
-
= input
|
|
5
|
-
.text-sm/6
|
|
6
|
-
- if label != false
|
|
7
|
-
div.flex.justify-between
|
|
8
|
-
= field_label(input_id, value: (checked_value if html_options[:multiple]))
|
|
9
|
-
- if description.present?
|
|
10
|
-
label for=input_id class="text-gray-500 auto-dark:text-gray-400" id=input_id+"_description"
|
|
11
|
-
= description
|
|
12
|
-
- if has_error?
|
|
13
|
-
p id=input_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
fieldset.form-component aria-describedby=aria_described_by
|
|
2
|
-
- if label != false
|
|
3
|
-
legend class=legend_classes = legend
|
|
4
|
-
- if description.present?
|
|
5
|
-
p id=tag_id+"_description" class=class_names("text-sm/6 text-gray-500 auto-dark:text-gray-400", "mt-1" => label != false) = description
|
|
6
|
-
div class=class_names(items_classes, "mt-2" => label != false || description.present?)
|
|
7
|
-
= items
|
|
8
|
-
= after_items
|
|
9
|
-
- if has_error?
|
|
10
|
-
p id=tag_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
.form-component
|
|
2
|
-
= field_label
|
|
3
|
-
.form-color-field.mt-2 class=class_names("form-color-field--error" => has_error?, "form-color-field--default" => default_color) style=(default_color && "--color-field-default: #{default_color}") data-controller="form-components--color-field" data-form-components--color-field-swatches-value=swatches.to_json
|
|
4
|
-
= input
|
|
5
|
-
- if description.present?
|
|
6
|
-
p id=tag_id+"_description" class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" = description
|
|
7
|
-
- if has_error?
|
|
8
|
-
p id=tag_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
.form-component
|
|
2
|
-
= field_label
|
|
3
|
-
div.mt-2
|
|
4
|
-
= input
|
|
5
|
-
- if description.present?
|
|
6
|
-
p id=tag_id+"_description" class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" = description
|
|
7
|
-
- if has_error?
|
|
8
|
-
p id=tag_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
.form-component
|
|
2
|
-
= field_label
|
|
3
|
-
- if preview?
|
|
4
|
-
= image_tag helpers.main_app.url_for(preview.representation(resize_to_limit: [300, 120])), class: "mt-2 max-h-20 rounded", alt: ""
|
|
5
|
-
.mt-2
|
|
6
|
-
= input
|
|
7
|
-
- if description.present?
|
|
8
|
-
p id=tag_id+"_description" class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" = description
|
|
9
|
-
- if has_error?
|
|
10
|
-
p id=tag_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/ ─── Stimulus form-components--nested-form controller ─────────────────────
|
|
2
|
-
/ data-form-components--nested-form-placeholder-value — token replaced with a timestamp on "Add"
|
|
3
|
-
/ data-form-components--nested-form-wrapper-selector-value — CSS selector for remove-button scope
|
|
4
|
-
div data-controller="form-components--nested-form" data-form-components--nested-form-placeholder-value=placeholder data-form-components--nested-form-wrapper-selector-value=wrapper_selector
|
|
5
|
-
|
|
6
|
-
template data-form-components--nested-form-target="template"
|
|
7
|
-
= form.fields_for(method, new_record_object, child_index: placeholder, &item_block)
|
|
8
|
-
|
|
9
|
-
/ ── Collection ──────────────────────────────────────────────────────────────
|
|
10
|
-
= form.fields_for(method, &item_block)
|
|
11
|
-
|
|
12
|
-
div data-form-components--nested-form-target="insertion"
|
|
13
|
-
|
|
14
|
-
span data-action="click->form-components--nested-form#add"
|
|
15
|
-
- if add_button?
|
|
16
|
-
= add_button
|
|
17
|
-
- else
|
|
18
|
-
button.mt-4.inline-flex.items-center.gap-x-2.rounded-md.border.border-dashed.border-primary-300.px-4.py-3.text-sm.font-medium.text-primary-600.hover:border-primary-500.hover:bg-primary-50 type="button"
|
|
19
|
-
i.fal.fa-plus
|
|
20
|
-
span = add_label
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
.form-component.relative.flex.items-start
|
|
2
|
-
.flex.h-6.items-center
|
|
3
|
-
= input
|
|
4
|
-
.ml-3.text-sm/6
|
|
5
|
-
- if label != false
|
|
6
|
-
div.flex.justify-between
|
|
7
|
-
= field_label(input_id, value: tag_value)
|
|
8
|
-
- if description.present?
|
|
9
|
-
label.text-gray-500.auto-dark:text-gray-400 for=input_id id=input_id+"_description"
|
|
10
|
-
= description
|
|
11
|
-
- if has_error?
|
|
12
|
-
p id=input_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
.form-component
|
|
2
|
-
= field_label
|
|
3
|
-
div.mt-2
|
|
4
|
-
= input
|
|
5
|
-
- if description.present?
|
|
6
|
-
p id=tag_id+"_description" class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" = description
|
|
7
|
-
- if has_error?
|
|
8
|
-
p id=tag_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
.form-component
|
|
2
|
-
- if label != false || corner_hint.present?
|
|
3
|
-
div.flex.justify-between
|
|
4
|
-
= field_label
|
|
5
|
-
span.text-sm/6.text-gray-500.auto-dark:text-gray-400
|
|
6
|
-
= corner_hint
|
|
7
|
-
div.mt-2 class="grid grid-cols-1"
|
|
8
|
-
= input
|
|
9
|
-
- if has_error?
|
|
10
|
-
.fas.fa-circle-exclamation class="pointer-events-none col-start-1 row-start-1 mr-3 size-5 self-center justify-self-end text-red-500 sm:size-4"
|
|
11
|
-
- if description.present?
|
|
12
|
-
p id=tag_id+"_description" class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" = description
|
|
13
|
-
- if has_error?
|
|
14
|
-
p id=tag_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
.form-component
|
|
2
|
-
- if label != false || corner_hint.present?
|
|
3
|
-
div.flex.justify-between
|
|
4
|
-
= field_label
|
|
5
|
-
span.text-sm/6.text-gray-500.auto-dark:text-gray-400
|
|
6
|
-
= corner_hint
|
|
7
|
-
div.mt-2 class="grid grid-cols-1"
|
|
8
|
-
= input
|
|
9
|
-
- if leading_icon.present?
|
|
10
|
-
span class=class_names("pointer-events-none col-start-1 row-start-1 ml-3 size-5 self-center text-gray-400 sm:size-4", leading_icon)
|
|
11
|
-
- if has_error?
|
|
12
|
-
.fas.fa-circle-exclamation class="pointer-events-none col-start-1 row-start-1 mr-3 size-5 self-center justify-self-end text-red-500 sm:size-4"
|
|
13
|
-
- if description.present?
|
|
14
|
-
p id=tag_id+"_description" class="mt-2 text-sm text-gray-500 auto-dark:text-gray-400" = description
|
|
15
|
-
- if has_error?
|
|
16
|
-
p id=tag_id+"_error" class="mt-2 text-sm text-red-600 auto-dark:text-red-400" = all_errors.join(", ")
|