govuk_design_system_formbuilder 6.0.0 → 6.1.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 59950d2e47e3ad35319e27cdb1e17e2df0564801a7e826baa688535549c5bdc5
|
|
4
|
+
data.tar.gz: 1e929e58ae4f08ba5a38a74c5719609fb7e53b365bbd86e6e41100adba40ac41
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f548176983fcaa0ca23708f7cf56244a1e1b0f70501ad48ee5b6461baf3381b088c329cd5140fdd534a765ae673cba564ce6af5d943abc3b05027478c4958536
|
|
7
|
+
data.tar.gz: 4ae536feca91926575a076231a3029b2ee962dffc4614ae7186d77c103fe8fccfcc411dfc6ad335df1f33eca979973d863531801a46659b73c2f69205a26ac05
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://badge.fury.io/rb/govuk_design_system_formbuilder)
|
|
5
5
|
[](https://rubygems.org/gems/govuk_design_system_formbuilder)
|
|
6
6
|

|
|
7
|
-
[](https://design-system.service.gov.uk)
|
|
8
8
|
[](https://weblog.rubyonrails.org/releases/)
|
|
9
9
|
[](https://www.ruby-lang.org/en/downloads/)
|
|
10
10
|
|
|
@@ -1119,6 +1119,12 @@ module GOVUKDesignSystemFormBuilder
|
|
|
1119
1119
|
# @param javascript [Boolean] Configures whether to add HTML for the javascript-enhanced version of the component
|
|
1120
1120
|
# @param before_input [String,Proc] the content injected before the input. No content will be added if left +nil+
|
|
1121
1121
|
# @param after_input [String,Proc] the content injected after the input. No content will be added if left +nil+
|
|
1122
|
+
# @param choose_files_button_text [String] The text of the button that opens the file picker. Default is "Choose file". If javascript is not provided, this option will be ignored.
|
|
1123
|
+
# @param drop_instruction_text [String] The text informing users they can drop files. Default is "or drop file". If javascript is not provided, this option will be ignored.
|
|
1124
|
+
# @param multiple_files_chosen_text [Hash] The text displayed when multiple files have been chosen by the user. The component will replace the %{count} placeholder with the number of files selected. This uses the govuk-frontend pluralisation rules. If javascript is not provided, this option will be ignored.
|
|
1125
|
+
# @param no_file_chosen_text [String] The text displayed when no file has been chosen by the user. Default is "No file chosen". If javascript is not provided, this option will be ignored.
|
|
1126
|
+
# @param entered_drop_zone_text [String] The text announced by assistive technology when user drags files and enters the drop zone. Default is "Entered drop zone". If javascript is not provided, this option will be ignored.
|
|
1127
|
+
# @param left_drop_zone_text [String] The text announced by assistive technology when user drags files and leaves the drop zone without dropping. Default is "Left drop zone". If javascript is not provided, this option will be ignored.
|
|
1122
1128
|
# @param block [Block] arbitrary HTML that will be rendered between the hint and the input
|
|
1123
1129
|
#
|
|
1124
1130
|
# @example A photo upload field with file type specifier and injected content
|
|
@@ -1137,8 +1143,44 @@ module GOVUKDesignSystemFormBuilder
|
|
|
1137
1143
|
# @note Remember to set +multipart: true+ when creating a form with file
|
|
1138
1144
|
# uploads, {https://guides.rubyonrails.org/form_helpers.html#uploading-files see
|
|
1139
1145
|
# the Rails documentation} for more information
|
|
1140
|
-
def govuk_file_field(
|
|
1141
|
-
|
|
1146
|
+
def govuk_file_field(
|
|
1147
|
+
attribute_name,
|
|
1148
|
+
label: {},
|
|
1149
|
+
caption: {},
|
|
1150
|
+
hint: {},
|
|
1151
|
+
form_group: {},
|
|
1152
|
+
javascript: false,
|
|
1153
|
+
before_input: nil,
|
|
1154
|
+
after_input: nil,
|
|
1155
|
+
choose_files_button_text: nil,
|
|
1156
|
+
drop_instruction_text: nil,
|
|
1157
|
+
multiple_files_chosen_text: nil,
|
|
1158
|
+
no_file_chosen_text: nil,
|
|
1159
|
+
entered_drop_zone_text: nil,
|
|
1160
|
+
left_drop_zone_text: nil,
|
|
1161
|
+
**kwargs,
|
|
1162
|
+
&block
|
|
1163
|
+
)
|
|
1164
|
+
Elements::File.new(
|
|
1165
|
+
self,
|
|
1166
|
+
object_name,
|
|
1167
|
+
attribute_name,
|
|
1168
|
+
label:,
|
|
1169
|
+
caption:,
|
|
1170
|
+
hint:,
|
|
1171
|
+
form_group:,
|
|
1172
|
+
javascript:,
|
|
1173
|
+
before_input:,
|
|
1174
|
+
after_input:,
|
|
1175
|
+
choose_files_button_text:,
|
|
1176
|
+
drop_instruction_text:,
|
|
1177
|
+
multiple_files_chosen_text:,
|
|
1178
|
+
no_file_chosen_text:,
|
|
1179
|
+
entered_drop_zone_text:,
|
|
1180
|
+
left_drop_zone_text:,
|
|
1181
|
+
**kwargs,
|
|
1182
|
+
&block
|
|
1183
|
+
).html
|
|
1142
1184
|
end
|
|
1143
1185
|
end
|
|
1144
1186
|
end
|
|
@@ -11,17 +11,24 @@ module GOVUKDesignSystemFormBuilder
|
|
|
11
11
|
include Traits::HTMLClasses
|
|
12
12
|
include Traits::ContentBeforeAndAfter
|
|
13
13
|
|
|
14
|
-
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, javascript:, before_input:, after_input:, **kwargs, &block)
|
|
14
|
+
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, javascript:, before_input:, after_input:, choose_files_button_text:, drop_instruction_text:, multiple_files_chosen_text:, no_file_chosen_text:, entered_drop_zone_text:, left_drop_zone_text:, **kwargs, &block)
|
|
15
15
|
super(builder, object_name, attribute_name, &block)
|
|
16
16
|
|
|
17
|
-
@label
|
|
18
|
-
@caption
|
|
19
|
-
@hint
|
|
17
|
+
@label = label
|
|
18
|
+
@caption = caption
|
|
19
|
+
@hint = hint
|
|
20
20
|
@html_attributes = kwargs
|
|
21
|
-
@form_group
|
|
22
|
-
@javascript
|
|
23
|
-
@before_input
|
|
24
|
-
@after_input
|
|
21
|
+
@form_group = form_group
|
|
22
|
+
@javascript = javascript
|
|
23
|
+
@before_input = before_input
|
|
24
|
+
@after_input = after_input
|
|
25
|
+
|
|
26
|
+
@choose_files_button_text = choose_files_button_text
|
|
27
|
+
@drop_instruction_text = drop_instruction_text
|
|
28
|
+
@multiple_files_chosen_text = multiple_files_chosen_text
|
|
29
|
+
@no_file_chosen_text = no_file_chosen_text
|
|
30
|
+
@entered_drop_zone_text = entered_drop_zone_text
|
|
31
|
+
@left_drop_zone_text = left_drop_zone_text
|
|
25
32
|
end
|
|
26
33
|
|
|
27
34
|
def html
|
|
@@ -41,7 +48,7 @@ module GOVUKDesignSystemFormBuilder
|
|
|
41
48
|
end
|
|
42
49
|
|
|
43
50
|
def file_with_javascript_markup
|
|
44
|
-
tag.div(class: "#{brand}-drop-zone", data: { module: "#{brand}-file-upload" }) { file }
|
|
51
|
+
tag.div(class: "#{brand}-drop-zone", data: { module: "#{brand}-file-upload" }, **i18n_data) { file }
|
|
45
52
|
end
|
|
46
53
|
|
|
47
54
|
def options
|
|
@@ -55,6 +62,24 @@ module GOVUKDesignSystemFormBuilder
|
|
|
55
62
|
def classes
|
|
56
63
|
build_classes(%(file-upload), %(file-upload--error) => has_errors?).prefix(brand)
|
|
57
64
|
end
|
|
65
|
+
|
|
66
|
+
def i18n_data
|
|
67
|
+
data = {
|
|
68
|
+
"data-i18n.choose-files-button" => @choose_files_button_text,
|
|
69
|
+
"data-i18n.drop-instruction" => @drop_instruction_text,
|
|
70
|
+
"data-i18n.no-file-chosen" => @no_file_chosen_text,
|
|
71
|
+
"data-i18n.entered-drop-zone" => @entered_drop_zone_text,
|
|
72
|
+
"data-i18n.left-drop-zone" => @left_drop_zone_text,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if @multiple_files_chosen_text.is_a?(Hash)
|
|
76
|
+
@multiple_files_chosen_text.each do |key, value|
|
|
77
|
+
data["data-i18n.multiple-files-chosen.#{key}"] = value
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
data.compact
|
|
82
|
+
end
|
|
58
83
|
end
|
|
59
84
|
end
|
|
60
85
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: govuk_design_system_formbuilder
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Yates
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: html-attributes-utils
|
|
@@ -254,14 +254,14 @@ dependencies:
|
|
|
254
254
|
requirements:
|
|
255
255
|
- - "~>"
|
|
256
256
|
- !ruby/object:Gem::Version
|
|
257
|
-
version: 0.
|
|
257
|
+
version: 0.34.0
|
|
258
258
|
type: :development
|
|
259
259
|
prerelease: false
|
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
|
261
261
|
requirements:
|
|
262
262
|
- - "~>"
|
|
263
263
|
- !ruby/object:Gem::Version
|
|
264
|
-
version: 0.
|
|
264
|
+
version: 0.34.0
|
|
265
265
|
- !ruby/object:Gem::Dependency
|
|
266
266
|
name: webrick
|
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|