katalyst-govuk-formbuilder 1.21.1 → 1.22.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: f00959f1768249d99d69e4d492dd9cf62158c0ffcbad3678c4217b9bb55857b6
4
- data.tar.gz: 85d1fd29983d9c4fe35af50a70bedd043e38a328a8db1f25a9411af546cef13c
3
+ metadata.gz: 7e8a404c5a4d6164193e63c33a4e1f418544d22f73641461a37f5f4db27c5a5e
4
+ data.tar.gz: d0bc19a8376c942a170596b5c790acab1415e5d8455e1a69b653f889b977c4b6
5
5
  SHA512:
6
- metadata.gz: 84faeab7a88f4f97d844020a3998926a75de6f89265e5bcff7ba95aa466a44c2d1870d69ace02a72a3fb67189c3523233c50d00be15d2b2f2c3b9502914ce6a2
7
- data.tar.gz: 13738c0739b4e0af4b0f8989fc219632c2cd24719c0c6e0407e47d689f19c8a9b4a7f203f6f35296ba35bf4fa2f4280119bc19ba0091fc92de56ef6b1e038c47
6
+ metadata.gz: 5aab818761b6138c58eb45c9126c037294434fb23beb41f1c31e1573498fbce83df7a47372d75b73db1ec79dbfab6468f476ab7db0c68377a12aa5e242bb12fc
7
+ data.tar.gz: cab0ba669c000a4239b7eb4e8d22ca45ceb051e736982bbffc8d0cdc4eec2ab745fef2cd0608c834f265adde01accb716f08393c6d34ebbd9fa8571eaec99038
@@ -91,6 +91,51 @@ module Katalyst
91
91
  end
92
92
  end
93
93
 
94
+ # Generates a input of type +time+
95
+ #
96
+ # @param attribute_name [Symbol] The name of the attribute
97
+ # @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+
98
+ # is supplied the hint will be wrapped in a +div+ instead of a +span+
99
+ # @option hint text [String] the hint text
100
+ # @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
101
+ # @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
102
+ # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
103
+ # @param extra_letter_spacing [Boolean] when true adds space between characters to increase the readability of
104
+ # sequences of letters and numbers. Defaults to +false+.
105
+ # @param label [Hash,Proc] configures or sets the associated label content
106
+ # @option label text [String] the label text
107
+ # @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
108
+ # @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
109
+ # @option label hidden [Boolean] control the visability of the label. Hidden labels are read by screenreaders.
110
+ # @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
111
+ # @param caption [Hash] configures or sets the caption content which is inserted above the label
112
+ # @option caption text [String] the caption text
113
+ # @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
114
+ # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
115
+ # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
116
+ # @param form_group [Hash] configures the form group
117
+ # @option form_group kwargs [Hash] additional attributes added to the form group
118
+ # @param prefix_text [String] the text placed before the input. No prefix will be added if left +nil+
119
+ # @param suffix_text [String] the text placed after the input. No suffix will be added if left +nil+
120
+ # @param block [Block] arbitrary HTML that will be rendered between the hint and the input
121
+ # @return [ActiveSupport::SafeBuffer] HTML output
122
+ # @see https://design-system.service.gov.uk/components/text-input/ GOV.UK Text input
123
+ # @see https://design-system.service.gov.uk/styles/typography/#headings-with-captions Headings with captions
124
+ #
125
+ # @example A required time field with a placeholder
126
+ # = f.govuk_time_field :time,
127
+ # label: { text: 'Event time' },
128
+ # hint: { text: 'Assumes the server timezone' },
129
+ # required: true,
130
+ # placeholder: '08:00am'
131
+ #
132
+ def govuk_time_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false,
133
+ form_group: {}, prefix_text: nil, suffix_text: nil, **, &)
134
+ Elements::Time.new(self, object_name, attribute_name,
135
+ hint:, label:, caption:, width:, extra_letter_spacing:, form_group:, prefix_text:,
136
+ suffix_text:, **, &).html
137
+ end
138
+
94
139
  # Generates a check box within a fieldset to be used as a boolean toggle for a single attribute.
95
140
  # The values are 1 (toggled on), and 0 (toggled off).
96
141
  #
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "govuk_design_system_formbuilder"
4
+
5
+ module Katalyst
6
+ module GOVUK
7
+ module FormBuilder
8
+ module Elements
9
+ class Time < GOVUKDesignSystemFormBuilder::Base
10
+ include GOVUKDesignSystemFormBuilder::Traits::Input
11
+ include GOVUKDesignSystemFormBuilder::Traits::Error
12
+ include GOVUKDesignSystemFormBuilder::Traits::Hint
13
+ include GOVUKDesignSystemFormBuilder::Traits::Label
14
+ include GOVUKDesignSystemFormBuilder::Traits::Supplemental
15
+ include GOVUKDesignSystemFormBuilder::Traits::HTMLAttributes
16
+
17
+ private
18
+
19
+ def builder_method
20
+ :time_field
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-govuk-formbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.1
4
+ version: 1.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
@@ -52,6 +52,7 @@ files:
52
52
  - lib/katalyst/govuk/form_builder/elements/label.rb
53
53
  - lib/katalyst/govuk/form_builder/elements/legend.rb
54
54
  - lib/katalyst/govuk/form_builder/elements/rich_text_area.rb
55
+ - lib/katalyst/govuk/form_builder/elements/time.rb
55
56
  - lib/katalyst/govuk/form_builder/engine.rb
56
57
  - lib/katalyst/govuk/form_builder/extensions.rb
57
58
  - lib/katalyst/govuk/form_builder/frontend.rb