bullet_train-themes-tailwind_css 1.6.38 → 1.7.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.
- checksums.yaml +4 -4
- data/app/views/themes/tailwind_css/fields/_active_storage_image.html.erb +13 -4
- data/app/views/themes/tailwind_css/fields/_address_field.html.erb +4 -2
- data/app/views/themes/tailwind_css/fields/_buttons.html.erb +44 -10
- data/app/views/themes/tailwind_css/fields/_cloudinary_image.html.erb +6 -2
- data/app/views/themes/tailwind_css/fields/_color_picker.html.erb +38 -8
- data/app/views/themes/tailwind_css/fields/_date_and_time_field.html.erb +8 -4
- data/app/views/themes/tailwind_css/fields/_date_field.html.erb +8 -6
- data/app/views/themes/tailwind_css/fields/_file_field.html.erb +19 -4
- data/app/views/themes/tailwind_css/fields/_option.html.erb +23 -16
- data/app/views/themes/tailwind_css/fields/_options.html.erb +43 -18
- data/lib/bullet_train/themes/tailwind_css/version.rb +1 -1
- metadata +2 -3
- data/app/views/themes/tailwind_css/fields/_field.html.erb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c03249dc4fdf9bcb0cf87aef4d44e03e064ad1183194aef1aa552d361a238440
|
4
|
+
data.tar.gz: 60ab86ae88a37794b16ca76ddab70348e1589be200458d7a860207e35b781913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ce6fe94bd5b7bef00a10c2bfa1fe93db6bd9570d12e3cf5676045e6cbb517cb35de2a1ec42bddba0b1f0a736305ce50d5671eae4696eb911e65b65d57642c3d
|
7
|
+
data.tar.gz: f895c50f950cfa261aef28294653452f27f3804781e670c66752f13f359a87c48e639c9772489a212d6f75a5dd5b982badbf45a6a3552285ec85494d7dd78720
|
@@ -7,8 +7,17 @@
|
|
7
7
|
form ||= current_fields_form
|
8
8
|
options ||= {}
|
9
9
|
other_options ||= {}
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
options[:multiple] ||= false
|
12
|
+
if defined?(multiple)
|
13
|
+
options[:multiple] = multiple
|
14
|
+
ActiveSupport::Deprecation.new.warn(
|
15
|
+
"The `multiple` attribute will be removed in a later version. " \
|
16
|
+
"Please pass `options: {multiple: true}` to `render` instead."
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
persisted_files = options[:multiple] ? form.object.send(method) : [form.object.send(method)]
|
12
21
|
|
13
22
|
options[:width] ||= 100
|
14
23
|
options[:height] ||= 100
|
@@ -19,13 +28,13 @@ options[:height] ||= 100
|
|
19
28
|
<%= render 'shared/fields/field', form: form, method: method, helper: :file_field, options: options, other_options: other_options do %>
|
20
29
|
<% content_for :field do %>
|
21
30
|
<div class="file-field" data-controller="fields--file-field">
|
22
|
-
<%= form.file_field method, class: 'file-upload hidden', multiple: multiple, direct_upload: true, data: {'fields--file-field-target': 'fileField', action: 'change->fields--file-field#handleFileSelected'} %>
|
31
|
+
<%= form.file_field method, class: 'file-upload hidden', multiple: options[:multiple], direct_upload: true, data: {'fields--file-field-target': 'fileField', action: 'change->fields--file-field#handleFileSelected'} %>
|
23
32
|
<div>
|
24
33
|
<% if form.object.send(method).attached? %>
|
25
34
|
<div class="divide-y-2 divide-dashed">
|
26
35
|
<% persisted_files.each do |file| %>
|
27
36
|
<div data-controller="fields--file-item" data-fields--file-item-id-value="<%= file.id %>">
|
28
|
-
<%= form.hidden_field "#{method}_removal".to_sym, multiple: multiple, value: nil, data: {'fields--file-item-target': 'removeFileFlag'} %>
|
37
|
+
<%= form.hidden_field "#{method}_removal".to_sym, multiple: options[:multiple], value: nil, data: {'fields--file-item-target': 'removeFileFlag'} %>
|
29
38
|
<%= image_tag photo_url_for_active_storage_attachment(file, options), class: 'mb-1.5', data: {'fields--file-item-target': "fileName"} %>
|
30
39
|
|
31
40
|
<%= link_to url_for(file), class: 'button download-file mr-3', data: {'fields--file-item-target': 'downloadFileButton'} do %>
|
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
<%
|
4
4
|
form ||= current_fields_form
|
5
|
-
|
6
|
-
other_options
|
5
|
+
|
6
|
+
# TODO: All options and other_options below are written inline. Do we need these?
|
7
|
+
# options ||= {}
|
8
|
+
# other_options ||= {}
|
7
9
|
%>
|
8
10
|
|
9
11
|
<%= form.fields_for(method) do |address_form| %>
|
@@ -1,23 +1,57 @@
|
|
1
1
|
<%
|
2
2
|
stimulus_controller = 'fields--button-toggle'
|
3
3
|
form ||= current_fields_form
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
|
5
|
+
# TODO: We need to do this because `options` is currently an array of strings.
|
6
|
+
# i.e. - ["One", "Two", "Three"]
|
7
|
+
if defined?(options) && options.is_a?(Array)
|
8
|
+
button_field_buttons = options
|
9
|
+
options = defined?(html_options) ? html_options : {}
|
10
|
+
ActiveSupport::Deprecation.new.warn(
|
11
|
+
"`options` will be replaced with `button_field_options` in a later version. " \
|
12
|
+
"Please pass all of the strings you want to appear in your buttons to `button_field_buttons`."
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
options ||= {}
|
17
|
+
button_field_buttons ||= {}
|
7
18
|
other_options ||= {}
|
8
|
-
|
19
|
+
|
20
|
+
if defined?(html_options)
|
21
|
+
# From the Rails documentation concerning `options`:
|
22
|
+
# Any standard HTML attributes for the tag can be passed in, for example :class
|
23
|
+
# https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-check_box
|
24
|
+
ActiveSupport::Deprecation.new.warn(
|
25
|
+
"The `html_options` attribute for checkboxes and radio buttons will be removed in a later version. " \
|
26
|
+
"Pass all of your html options like `class` to `options` instead."
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
button_field_options = options_for(form, method) if button_field_buttons.empty?
|
31
|
+
|
32
|
+
options[:data] ||= {}
|
33
|
+
options[:data]["#{stimulus_controller}-target"] = 'shadowField'
|
34
|
+
|
35
|
+
options[:multiple] ||= false
|
36
|
+
if defined?(multiple)
|
37
|
+
options[:multiple] = multiple
|
38
|
+
ActiveSupport::Deprecation.new.warn(
|
39
|
+
"The `multiple` attribute will be removed in a later version. " \
|
40
|
+
"Please pass `options: {multiple: true}` to `render` instead."
|
41
|
+
)
|
42
|
+
end
|
9
43
|
%>
|
10
44
|
|
11
|
-
<% content = render 'shared/fields/field', form: form, method: method, options:
|
45
|
+
<% content = render 'shared/fields/field', form: form, method: method, options: options, other_options: other_options do %>
|
12
46
|
<% content_for :field do %>
|
13
47
|
<div>
|
14
|
-
<%
|
15
|
-
<% checked = form.object.send(method).is_a?(Array) ? form.object.send(method).map(&:to_s).include?(value.to_s) : form.object.send(method).to_s == value.to_s %>
|
48
|
+
<% button_field_options.each do |value, label| %>
|
49
|
+
<% options[:checked] = form.object.send(method).is_a?(Array) ? form.object.send(method).map(&:to_s).include?(value.to_s) : form.object.send(method).to_s == value.to_s %>
|
16
50
|
<label class="btn-toggle" data-controller="<%= stimulus_controller %>">
|
17
|
-
<% if multiple %>
|
18
|
-
<%= form.check_box method,
|
51
|
+
<% if options[:multiple] %>
|
52
|
+
<%= form.check_box method, options, value, "" %>
|
19
53
|
<% else %>
|
20
|
-
<%= form.radio_button method, value,
|
54
|
+
<%= form.radio_button method, value, options %>
|
21
55
|
<% end %>
|
22
56
|
<button type="button" class="button-alternative mb-1.5 mr-1" data-action="<%= stimulus_controller %>#clickShadowField">
|
23
57
|
<%= label %>
|
@@ -5,13 +5,14 @@ stimulus_controller = 'fields--cloudinary-image'
|
|
5
5
|
|
6
6
|
form ||= current_fields_form
|
7
7
|
options ||= {}
|
8
|
+
other_options ||= {}
|
9
|
+
|
8
10
|
options[:id] ||= form.field_id(method)
|
9
11
|
options[:width] ||= 100
|
10
12
|
options[:height] ||= 100
|
11
13
|
options[:cloud_name] ||= Cloudinary.config.cloud_name
|
12
14
|
options[:api_key] ||= Cloudinary.config.api_key
|
13
15
|
options[:google_search_key] ||= ENV['CLOUDINARY_GOOGLE_API_KEY']
|
14
|
-
other_options ||= {}
|
15
16
|
%>
|
16
17
|
|
17
18
|
<%
|
@@ -19,6 +20,9 @@ cloudinary_id = if_present(form.object.send(method))
|
|
19
20
|
preview_image_options = {width: options[:width], height: options[:height], crop: :fill}
|
20
21
|
cloudinary_url = cl_image_path(cloudinary_id, preview_image_options) if cloudinary_id
|
21
22
|
cloudinary_url_format = cl_image_path('CLOUDINARY_ID', preview_image_options)
|
23
|
+
|
24
|
+
options[:data] ||= {}
|
25
|
+
options[:data]["#{stimulus_controller}-target"] = 'thumbnail'
|
22
26
|
%>
|
23
27
|
|
24
28
|
<%
|
@@ -46,7 +50,7 @@ wrapper_options[:data]["#{stimulus_controller}-google-api-key-value"] = options[
|
|
46
50
|
data-<%= stimulus_controller %>-target="uploadButton"
|
47
51
|
data-action="<%= stimulus_controller %>#pickImageAndUpload"
|
48
52
|
>
|
49
|
-
<%= image_tag cloudinary_url,
|
53
|
+
<%= image_tag cloudinary_url, options if cloudinary_url %>
|
50
54
|
<i class="ti ti-cloud-up"></i>
|
51
55
|
</button>
|
52
56
|
<button type="button" class="clear" data-action="<%= stimulus_controller %>#clearImage">
|
@@ -1,18 +1,48 @@
|
|
1
1
|
<%
|
2
2
|
stimulus_controller = 'fields--color-picker'
|
3
|
-
|
4
3
|
form ||= current_fields_form
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
|
5
|
+
if defined?(options) && options.is_a?(Array)
|
6
|
+
color_picker_field_options = options
|
7
|
+
options = defined?(html_options) ? html_options : {}
|
8
|
+
ActiveSupport::Deprecation.new.warn(
|
9
|
+
"`options` will be replaced with `color_picker_field_options` in a later version. " \
|
10
|
+
"Please pass all of the colors you want as strings to `color_picker_field_options`."
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
options ||= {}
|
15
|
+
color_picker_field_options ||= options_for(form, method)
|
16
|
+
options.delete(:color_picker_options)
|
17
|
+
|
18
|
+
if defined?(html_options)
|
19
|
+
ActiveSupport::Deprecation.new.warn(
|
20
|
+
"The `html_options` attribute for color pickers will be removed in a later version. " \
|
21
|
+
"Pass all of your html options like `class` to `options` instead."
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
8
25
|
other_options ||= {}
|
9
|
-
|
26
|
+
|
27
|
+
options[:id] ||= form.field_id(method)
|
28
|
+
|
29
|
+
# TODO: I don't think multiple is even used for this attribute,
|
30
|
+
# we should probably delete this altogether.
|
31
|
+
options[:multiple] ||= false
|
32
|
+
if defined?(multiple)
|
33
|
+
options[:multiple] = multiple
|
34
|
+
ActiveSupport::Deprecation.new.warn(
|
35
|
+
"The `multiple` attribute will be removed in a later version. " \
|
36
|
+
"Please pass `options: {multiple: true}` to `render` instead."
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
10
40
|
value = form.object.send(method)
|
11
41
|
|
12
42
|
color_selected_classes = "ring-2 ring-offset-2"
|
13
43
|
%>
|
14
44
|
|
15
|
-
<% content = render 'shared/fields/field', form: form, method: method, options:
|
45
|
+
<% content = render 'shared/fields/field', form: form, method: method, options: options, other_options: other_options do %>
|
16
46
|
<% content_for :field do %>
|
17
47
|
<div class="space-x-1"
|
18
48
|
data-controller="<%= stimulus_controller %>"
|
@@ -21,14 +51,14 @@ color_selected_classes = "ring-2 ring-offset-2"
|
|
21
51
|
>
|
22
52
|
<%= form.hidden_field method, value: value, data: {"#{stimulus_controller}-target": "colorPickerValue"} %>
|
23
53
|
<div class="inline space-x-1" data-<%= stimulus_controller %>-target="colorOptions">
|
24
|
-
<%
|
54
|
+
<% color_picker_field_options.each do |color| %>
|
25
55
|
<label class="btn-toggle btn-color-picker">
|
26
56
|
<button type="button" class="button-color mb-1.5 dark:ring-offset-slate-700 <%= color == value ? color_selected_classes : '' %>" style="background-color: <%= color %>; --tw-ring-color: <%= color %>" data-action="<%= stimulus_controller %>#pickColor" data-<%= stimulus_controller %>-target="colorButton" data-color="<%= color %>"> </button>
|
27
57
|
</label>
|
28
58
|
<% end %>
|
29
59
|
</div>
|
30
60
|
<label class="btn-toggle btn-color-picker">
|
31
|
-
<button type="button" class="button-color mr-1 dark:ring-offset-slate-700 <%= value.blank? ||
|
61
|
+
<button type="button" class="button-color mr-1 dark:ring-offset-slate-700 <%= value.blank? || color_picker_field_options.include?(value) ? 'hidden' : color_selected_classes %>" data-action="<%= stimulus_controller %>#pickColor" data-<%= stimulus_controller %>-target="userSelectedColor colorButton" data-color="<%= value %>" style="background-color: <%= value %>; --tw-ring-color: <%= value %>"> </button>
|
32
62
|
</label>
|
33
63
|
<span class="relative">
|
34
64
|
<input type="text" disabled="disabled" class="rounded-md shadow-sm font-light font-mono text-sm focus:ring-blue focus:border-blue border-slate-300 w-48 dark:bg-slate-800 dark:border-slate-900" value="<%= value %>" data-<%= stimulus_controller %>-target="colorInput"/>
|
@@ -1,8 +1,7 @@
|
|
1
1
|
<%
|
2
2
|
stimulus_controller = 'fields--date'
|
3
|
-
|
4
3
|
form ||= current_fields_form
|
5
|
-
|
4
|
+
|
6
5
|
user_tz = defined?(current_user.time_zone) ? ActiveSupport::TimeZone.find_tzinfo(current_user.time_zone).name : nil
|
7
6
|
|
8
7
|
current_team_time_zone = if current_user&.respond_to?(:current_team)
|
@@ -12,8 +11,12 @@ else
|
|
12
11
|
end
|
13
12
|
team_tz = ActiveSupport::TimeZone.find_tzinfo(current_team_time_zone)&.name
|
14
13
|
|
15
|
-
|
14
|
+
options ||= {}
|
16
15
|
data_options ||= {}
|
16
|
+
other_options ||= {}
|
17
|
+
|
18
|
+
# data_options represents the iso8601 date and time value in a hidden input field.
|
19
|
+
# The value we display on screen is in options[:value].
|
17
20
|
data_options[:id] ||= form.field_id(method)
|
18
21
|
data_options[:class] = "hidden"
|
19
22
|
data_options[:value] = form.object.send(method)&.in_time_zone(current_time_zone)&.iso8601
|
@@ -26,9 +29,10 @@ raw_value = form.object.send(method)&.in_time_zone(current_user&.time_zone || cu
|
|
26
29
|
options[:value] = raw_value && I18n.l(raw_value, format: :date_and_time_field)
|
27
30
|
options = options.merge({ data: {"#{stimulus_controller}-target": 'displayField' }})
|
28
31
|
|
29
|
-
other_options ||= {}
|
30
32
|
%>
|
31
33
|
|
34
|
+
<%# Although we pass options below to `text_field`, we need to pass options here %>
|
35
|
+
<%# too because the id we set earlier is not the usual `form.field_id(method)`. %>
|
32
36
|
<%= render 'shared/fields/field', form: form, method: method, options: options, other_options: other_options do %>
|
33
37
|
<% content_for :field do %>
|
34
38
|
<div
|
@@ -1,11 +1,13 @@
|
|
1
1
|
<%
|
2
2
|
stimulus_controller = 'fields--date'
|
3
|
-
|
4
3
|
form ||= current_fields_form
|
5
|
-
options ||= {}
|
6
4
|
|
7
|
-
|
5
|
+
options ||= {}
|
8
6
|
data_options ||= {}
|
7
|
+
other_options ||= {}
|
8
|
+
|
9
|
+
# data_options represents the iso8601 date value in a hidden input field.
|
10
|
+
# The value we display on screen is in options[:value].
|
9
11
|
data_options[:id] ||= form.field_id(method)
|
10
12
|
data_options[:class] = "hidden"
|
11
13
|
data_options[:value] = form.object.send(method)&.strftime("%Y-%m-%d")
|
@@ -16,10 +18,10 @@ options[:id] ||= "#{form.field_id(method)}_display"
|
|
16
18
|
options[:class] = "form-control single-daterange w-full border-slate-300 dark:bg-slate-800 dark:border-slate-900 #{options[:class]}".strip
|
17
19
|
options[:value] = form.object.send(method) && I18n.l(form.object.send(method), format: :date_field)
|
18
20
|
options = options.merge({ data: {"#{stimulus_controller}-target": 'displayField' }})
|
19
|
-
|
20
|
-
other_options ||= {}
|
21
|
-
|
22
21
|
%>
|
22
|
+
|
23
|
+
<%# Although we pass options below to `text_field`, we need to pass options here %>
|
24
|
+
<%# too because the id we set earlier is not the usual `form.field_id(method)`. %>
|
23
25
|
<%= render 'shared/fields/field', form: form, method: method, options: options, other_options: other_options do %>
|
24
26
|
<% content_for :field do %>
|
25
27
|
<div
|
@@ -2,20 +2,35 @@
|
|
2
2
|
form ||= current_fields_form
|
3
3
|
options ||= {}
|
4
4
|
other_options ||= {}
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
options[:multiple] ||= false
|
7
|
+
if defined?(multiple)
|
8
|
+
options[:multiple] = multiple
|
9
|
+
ActiveSupport::Deprecation.new.warn(
|
10
|
+
"The `multiple` attribute will be removed in a later version. " \
|
11
|
+
"Please pass `options: {multiple: true}` to `render` instead."
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
options[:class] = "file-upload hidden #{options[:class]}"
|
16
|
+
options[:direct_upload] = true
|
17
|
+
options[:data] ||= {}
|
18
|
+
options[:data]['fields--file-field-target'] = "fileField"
|
19
|
+
options[:data][:action] = "change->fields--file-field#handleFileSelected"
|
20
|
+
|
21
|
+
persisted_files = options[:multiple] ? form.object.send(method) : [form.object.send(method)]
|
7
22
|
%>
|
8
23
|
|
9
24
|
<%= render 'shared/fields/field', form: form, method: method, helper: :file_field, options: options, other_options: other_options do %>
|
10
25
|
<% content_for :field do %>
|
11
26
|
<div class="file-field" data-controller="fields--file-field">
|
12
|
-
<%= form.file_field method,
|
27
|
+
<%= form.file_field method, options %>
|
13
28
|
<div>
|
14
29
|
<% if form.object.send(method).attached? %>
|
15
30
|
<div class="divide-y-2 divide-dashed">
|
16
31
|
<% persisted_files.each do |file| %>
|
17
32
|
<div data-controller="fields--file-item" data-fields--file-item-id-value="<%= file.id %>">
|
18
|
-
<%= form.hidden_field "#{method}_removal".to_sym, multiple: multiple, value: nil, data: {'fields--file-item-target': 'removeFileFlag'} %>
|
33
|
+
<%= form.hidden_field "#{method}_removal".to_sym, multiple: options[:multiple], value: nil, data: {'fields--file-item-target': 'removeFileFlag'} %>
|
19
34
|
<span data-fields--file-item-target="fileName" %>
|
20
35
|
<%= file.blob.filename %>
|
21
36
|
</span>
|
@@ -1,44 +1,51 @@
|
|
1
1
|
<%
|
2
2
|
form ||= current_fields_form
|
3
3
|
single_check_box ||= false
|
4
|
-
multiple ||= false
|
5
|
-
option_field_options ||= {}
|
6
4
|
append_class ||= ''
|
7
5
|
labels = labels_for(form, method) if form
|
8
6
|
|
7
|
+
options ||= {}
|
8
|
+
|
9
|
+
options[:multiple] ||= false
|
10
|
+
if defined?(multiple)
|
11
|
+
options[:multiple] = multiple
|
12
|
+
ActiveSupport::Deprecation.new.warn(
|
13
|
+
"The `multiple` attribute will be removed in a later version. " \
|
14
|
+
"Please pass `options: {multiple: true}` to `render` instead."
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
9
18
|
# Since we don't know at this point which tag we'll be using, we specify
|
10
19
|
# the class only once here for simplicity and apply it to one of the following tags:
|
11
20
|
# 1. form.check_box
|
12
21
|
# 2. check_box
|
13
|
-
#
|
22
|
+
# 3. form.radio_button
|
14
23
|
#
|
15
24
|
# the `append_class` local can be used to append any other styles desired for the element.
|
16
|
-
|
17
|
-
|
25
|
+
options[:class] ||= "focus:ring-primary-500 h-4 w-4 text-primary-500 border-slate-300 dark:bg-slate-800 dark:border-slate-900 #{"rounded" if options[:multiple] || single_check_box}"
|
26
|
+
options[:class] += " #{append_class}"
|
18
27
|
%>
|
19
28
|
|
20
29
|
<% if single_check_box %>
|
21
30
|
<% if form %>
|
22
31
|
<div class="flex items-center">
|
23
|
-
<%= form.check_box method,
|
32
|
+
<%= form.check_box method, options %>
|
24
33
|
<%= form.label method, class: 'ml-2' %>
|
25
34
|
</div>
|
26
35
|
<% else %>
|
27
|
-
<% value =
|
28
|
-
<% checked =
|
29
|
-
<%= check_box_tag method, value, checked,
|
36
|
+
<% value = options.delete(:value) %>
|
37
|
+
<% checked = options.delete(:checked) %>
|
38
|
+
<%= check_box_tag method, value, checked, options %>
|
30
39
|
<% end %>
|
31
40
|
<% else %>
|
32
|
-
<%
|
41
|
+
<% option_field_options.each do |value, label| %>
|
33
42
|
<label class="relative flex items-start mb-3">
|
34
43
|
<div class="flex items-center h-5">
|
35
|
-
<% if multiple %>
|
36
|
-
<%
|
37
|
-
<%= form.check_box method,
|
38
|
-
multiple: multiple, checked: checked_value, data: option_field_options[:data], class: option_field_options[:class]
|
39
|
-
}, value, "" %>
|
44
|
+
<% if options[:multiple] %>
|
45
|
+
<% options[:checked] = form.object.send(method).nil? ? nil : form.object.send(method).map(&:to_s).include?(value.to_s) %>
|
46
|
+
<%= form.check_box method, options, value, "" %>
|
40
47
|
<% else %>
|
41
|
-
<%= form.radio_button method, value,
|
48
|
+
<%= form.radio_button method, value, options %>
|
42
49
|
<% end %>
|
43
50
|
</div>
|
44
51
|
<div class="ml-2.5 text-sm">
|
@@ -9,27 +9,52 @@ end
|
|
9
9
|
|
10
10
|
<%
|
11
11
|
form ||= current_fields_form
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
if defined?(options) && options.is_a?(Array)
|
14
|
+
option_field_options = options
|
15
|
+
options = defined?(html_options) ? html_options : {}
|
16
|
+
ActiveSupport::Deprecation.new.warn(
|
17
|
+
"`options` will be replaced with `option_field_options` in a later version. " \
|
18
|
+
"Please pass all of the options you want as strings to ``."
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
options ||= {}
|
23
|
+
option_field_options ||= options_for(form, method)
|
24
|
+
other_options ||= {}
|
25
|
+
|
26
|
+
if defined?(html_options)
|
27
|
+
ActiveSupport::Deprecation.new.warn(
|
28
|
+
"The `html_options` attribute for checkboxes and radio buttons will be removed in a later version " \
|
29
|
+
"Pass all of your html options like `class` to `options` instead."
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
options[:multiple] ||= false
|
34
|
+
if defined?(multiple)
|
35
|
+
options[:multiple] = multiple
|
36
|
+
ActiveSupport::Deprecation.new.warn(
|
37
|
+
"The `multiple` attribute will be removed in a later version. " \
|
38
|
+
"Please pass `options: {multiple: true}` to `render` instead."
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
options[:id] ||= form.field_id(method)
|
15
43
|
show_select_all_top ||= false
|
16
44
|
show_select_all_bottom ||= false
|
17
45
|
use_columns ||= false
|
18
|
-
other_options ||= {}
|
19
|
-
options ||= options_for(form, method)
|
20
46
|
labels = labels_for(form, method)
|
21
47
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
option_field_options[:data][:controller] += " fields--field"
|
48
|
+
options[:data] ||= {}
|
49
|
+
options[:data][:controller] ||= ""
|
50
|
+
options[:data][:controller] += " fields--field"
|
26
51
|
|
27
|
-
if multiple
|
28
|
-
|
52
|
+
if options[:multiple]
|
53
|
+
options[:data] = options[:data].merge({
|
29
54
|
"select-all-target": 'checkbox'
|
30
55
|
})
|
31
|
-
|
32
|
-
|
56
|
+
options[:data][:action] ||= ""
|
57
|
+
options[:data][:action] += " select-all#updateToggle"
|
33
58
|
end
|
34
59
|
|
35
60
|
%>
|
@@ -38,7 +63,7 @@ end
|
|
38
63
|
# TODO: We should either remove this, or move the Action Models `bulk_action_select`
|
39
64
|
# partial here to bullet_train-core because this cannot work with the setup we currently have.
|
40
65
|
%>
|
41
|
-
<% if multiple && (show_select_all_top || show_select_all_bottom) %>
|
66
|
+
<% if options[:multiple] && (show_select_all_top || show_select_all_bottom) %>
|
42
67
|
<% select_all = capture do %>
|
43
68
|
<div class="flex">
|
44
69
|
<%= tag.div class: [
|
@@ -66,22 +91,22 @@ end
|
|
66
91
|
<% end %>
|
67
92
|
<% end %>
|
68
93
|
|
69
|
-
<%= render 'shared/fields/field', form: form, method: method, options:
|
94
|
+
<%= render 'shared/fields/field', form: form, method: method, options: options, other_options: other_options do %>
|
70
95
|
<% content_for :field do %>
|
71
96
|
<%= tag.div class: "pt-1.5 pb-1 sm:col-span-2", data: {
|
72
97
|
controller: "select-all",
|
73
98
|
"select-all-unavailable-class": "hidden"
|
74
99
|
} do %>
|
75
100
|
|
76
|
-
<% if multiple && show_select_all_top && !show_select_all_bottom %>
|
101
|
+
<% if options[:multiple] && show_select_all_top && !show_select_all_bottom %>
|
77
102
|
<%= select_all %>
|
78
103
|
<% end %>
|
79
104
|
|
80
105
|
<%= tag.div class: ["max-w-lg": !use_columns, "max-w-3xl": use_columns, "columns-[var(--column-width,_15ch)_3]": use_columns] do %>
|
81
|
-
<%= render 'shared/fields/option', method: method, form: form, option_field_options: option_field_options,
|
106
|
+
<%= render 'shared/fields/option', method: method, form: form, option_field_options: option_field_options, options: options %>
|
82
107
|
<% end %>
|
83
108
|
|
84
|
-
<% if multiple && !show_select_all_top && show_select_all_bottom %>
|
109
|
+
<% if options[:multiple] && !show_select_all_top && show_select_all_bottom %>
|
85
110
|
<%= select_all %>
|
86
111
|
<% end %>
|
87
112
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train-themes-tailwind_css
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -76,7 +76,6 @@ files:
|
|
76
76
|
- app/views/themes/tailwind_css/fields/_date_and_time_field.html.erb
|
77
77
|
- app/views/themes/tailwind_css/fields/_date_field.html.erb
|
78
78
|
- app/views/themes/tailwind_css/fields/_dependent_fields_frame.html.erb
|
79
|
-
- app/views/themes/tailwind_css/fields/_field.html.erb
|
80
79
|
- app/views/themes/tailwind_css/fields/_file_field.html.erb
|
81
80
|
- app/views/themes/tailwind_css/fields/_image.html.erb
|
82
81
|
- app/views/themes/tailwind_css/fields/_option.html.erb
|
@@ -1,80 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
%i[label field error help after_help].each do |key|
|
3
|
-
if (content = content_for(key).presence)
|
4
|
-
flush_content_for key
|
5
|
-
partial.section key, content
|
6
|
-
end
|
7
|
-
end
|
8
|
-
%>
|
9
|
-
|
10
|
-
<%
|
11
|
-
form ||= current_fields_form
|
12
|
-
# returns a struct with `label`, `placeholder`, and `help` methods.
|
13
|
-
labels = labels_for(form, method)
|
14
|
-
options ||= {}
|
15
|
-
options[:id] ||= form.field_id(method)
|
16
|
-
# options[:disabled] ||= !field_editable?(form.object, method) if user_signed_in?
|
17
|
-
options[:placeholder] ||= labels.placeholder if labels.placeholder
|
18
|
-
other_options ||= {}
|
19
|
-
other_options[:help] = [other_options[:help], labels.help].compact.join(" ")
|
20
|
-
|
21
|
-
errors = [method, method.to_s.delete_suffix("_id").to_sym].uniq.map { |attribute| form.object.errors.full_messages_for(attribute) }.flatten
|
22
|
-
has_errors = errors.any? || partial.error? || other_options[:error].present?
|
23
|
-
|
24
|
-
options[:class] = "#{options[:class]} block w-full rounded-md shadow-sm font-light"
|
25
|
-
options[:class] += " text-base md:text-sm" # default to 16px on mobile to prevent zooming
|
26
|
-
|
27
|
-
options[:class] += if has_errors
|
28
|
-
" pr-10 border-red text-red-700 placeholder-red focus:outline-none focus:ring-red focus:border-red"
|
29
|
-
else
|
30
|
-
" focus:ring-blue focus:border-blue border-slate-300"
|
31
|
-
end
|
32
|
-
|
33
|
-
%>
|
34
|
-
|
35
|
-
<div class="<%= 'required' if presence_validated?(form.object, method) %>">
|
36
|
-
|
37
|
-
<% # the label. %>
|
38
|
-
<% unless other_options[:hide_label] == true %>
|
39
|
-
<% if partial.label? %>
|
40
|
-
<%= partial.label %>
|
41
|
-
<% else %>
|
42
|
-
<% # allow the label to be defined via an inline option or else one of the locale yaml definitions. %>
|
43
|
-
<% label = (other_options[:label].presence || labels.label || legacy_label_for(form, method)) %>
|
44
|
-
<%= form.label method, label&.html_safe, class: 'block', for: options[:id] %>
|
45
|
-
<% end %>
|
46
|
-
<% end %>
|
47
|
-
|
48
|
-
<div class="mt-1.5">
|
49
|
-
<% # the actual field. %>
|
50
|
-
<% if partial.field? %>
|
51
|
-
<%= partial.field %>
|
52
|
-
<% else %>
|
53
|
-
<% # e.g. form.text_field(method, options) %>
|
54
|
-
<%= form.send(helper, method, options) %>
|
55
|
-
<% end %>
|
56
|
-
</div>
|
57
|
-
|
58
|
-
<% # any error messages. %>
|
59
|
-
<% if has_errors %>
|
60
|
-
<p class="mt-1.5 text-xs text-red">
|
61
|
-
<%= errors.map { |error| error + ". " }.join %>
|
62
|
-
<%= partial.error %>
|
63
|
-
<%= other_options[:error]&.html_safe %>
|
64
|
-
</p>
|
65
|
-
<% end %>
|
66
|
-
|
67
|
-
<% # any help text. %>
|
68
|
-
<% if partial.help? || other_options[:help] || partial.after_help? %>
|
69
|
-
<p class="mt-1.5 text-xs text-slate-500">
|
70
|
-
<%= partial.help %>
|
71
|
-
<%= other_options[:help]&.html_safe %>
|
72
|
-
<%= partial.after_help %>
|
73
|
-
</p>
|
74
|
-
<% end %>
|
75
|
-
|
76
|
-
<% if other_options[:icon] %>
|
77
|
-
<div class="pre-icon os-icon <%= other_options[:icon] %>"></div>
|
78
|
-
<% end %>
|
79
|
-
|
80
|
-
</div>
|