tramway 2.2.2.3 → 2.2.2.4

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: f7dc23649cf71859ef570754234ae5c20fbbec5e8ad893c125baad0e2b6cae0b
4
- data.tar.gz: c796ca8d1c82ecfd99395b3385c1a717fbd0309c00723f6e674fe1c2893ed94b
3
+ metadata.gz: e81cf65bb271f4465d65bc87d4442bdca475343ece460dde20b9e9888a97a661
4
+ data.tar.gz: 4d6a4dd2aebc663424d04b17eb36a2b37e55e8cf5b79d4ef2b8b3f3689650000
5
5
  SHA512:
6
- metadata.gz: 3d5c8c25e8d045fd09fc0a00fe6ef9481fb1164b115c6d505c2d6f6d3fc4e2dbe08a1decc83f91b8a24b302d4fdf25a425f324cb33001d648ac82ff067589441
7
- data.tar.gz: 353645345db6f6cd632eda339f29770361d87cde6b94b91d886e76eafba6e9f224f1e381498be204641211017d81381dce7e3ed10dc4667d0b1cc8beec8ca79c
6
+ metadata.gz: b619049a42a58e38ef99a7fe1a1c66ccb10787aa5887918fbfb579ee4e92fb8fd757cc152cefc107955fad080845b608ad541fd3eaa6b5ef1b644fa2c8a6eebd
7
+ data.tar.gz: 7bdb58593b90cb685eb73e5b570ee36a32eecaf9f0c0c1118d99994318085d31d5829d8bdb056e323d0592c2c538ac3bc91f182e47ee601773c1721a3d569340
data/README.md CHANGED
@@ -977,6 +977,7 @@ Tramway provides `tramway_form_for` helper that renders Tailwind-styled forms by
977
977
  <%= f.password_field :password %>
978
978
  <%= f.select :role, [:admin, :user] %>
979
979
  <%= f.date_field :birth_date %>
980
+ <%= f.datetime_field :confirmed_at %>
980
981
  <%= f.multiselect :permissions, [['Create User', 'create_user'], ['Update user', 'update_user']] %>
981
982
  <%= f.file_field :file %>
982
983
  <%= f.submit 'Create User' %>
@@ -1002,6 +1003,7 @@ Available form helpers:
1002
1003
  * file_field
1003
1004
  * select
1004
1005
  * date_field
1006
+ * datetime_field
1005
1007
  * multiselect ([Stimulus-based](https://github.com/Purple-Magic/tramway#stimulus-based-inputs))
1006
1008
  * submit
1007
1009
 
@@ -10,7 +10,7 @@ class TailwindComponent < Tramway::BaseComponent
10
10
  option :options
11
11
  option :label
12
12
  option :for
13
- option :size, default: -> { :middle }
13
+ option :size, default: -> { :medium }
14
14
 
15
15
  SIZE_CLASSES = {
16
16
  small: {
@@ -20,7 +20,7 @@ class TailwindComponent < Tramway::BaseComponent
20
20
  submit_button: 'text-sm px-3 py-1',
21
21
  multiselect_input: 'text-sm px-2 py-1'
22
22
  },
23
- middle: {
23
+ medium: {
24
24
  text_input: 'text-base px-3 py-2',
25
25
  select_input: 'text-base px-3 py-2',
26
26
  file_button: 'text-base px-4 py-2',
@@ -74,7 +74,7 @@ class TailwindComponent < Tramway::BaseComponent
74
74
  end
75
75
 
76
76
  def size_class(key)
77
- size_classes = SIZE_CLASSES.fetch(size) { SIZE_CLASSES[:middle] }
78
- size_classes.fetch(key) { SIZE_CLASSES[:middle].fetch(key) }
77
+ size_classes = SIZE_CLASSES.fetch(size) { SIZE_CLASSES[:medium] }
78
+ size_classes.fetch(key) { SIZE_CLASSES[:medium].fetch(key) }
79
79
  end
80
80
  end
@@ -15,6 +15,10 @@ module Tailwinds
15
15
  option :form_options, optional: true, default: -> { {} }
16
16
 
17
17
  def size_classes
18
+ unless size.in?(%i[small medium large])
19
+ raise ArgumentError, "Invalid size: #{size}. Valid sizes are :small, :medium, :large."
20
+ end
21
+
18
22
  {
19
23
  small: 'text-sm py-1 px-2 rounded',
20
24
  medium: 'py-2 px-4 h-10',
@@ -11,7 +11,7 @@ module Tailwinds
11
11
  def initialize(object_name, object, template, options)
12
12
  super
13
13
 
14
- @form_size = options[:size] || options['size'] || :middle
14
+ @form_size = options[:size] || options['size'] || :medium
15
15
  end
16
16
 
17
17
  def common_field(component_name, input_method, attribute, **options, &)
@@ -56,6 +56,10 @@ module Tailwinds
56
56
  common_field(:date_field, :date_field, attribute, **, &)
57
57
  end
58
58
 
59
+ def datetime_field(attribute, **, &)
60
+ common_field(:datetime_field, :datetime_field, attribute, **, &)
61
+ end
62
+
59
63
  def file_field(attribute, **options, &)
60
64
  sanitized_options = sanitize_options(options)
61
65
  input = super(attribute, **sanitized_options.merge(class: :hidden))
@@ -0,0 +1,6 @@
1
+ .mb-4
2
+ - if @label
3
+ = component('tailwinds/form/label', for: @for) do
4
+ = @label
5
+ - classes = "#{size_class(:text_input)} #{text_input_base_classes}"
6
+ = @input.call @attribute, **@options.merge(class: classes), value: @value
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tailwinds
4
+ module Form
5
+ # Tailwind-styled datetime field
6
+ class DatetimeFieldComponent < TailwindComponent
7
+ end
8
+ end
9
+ end
@@ -4,18 +4,14 @@ module Tailwinds
4
4
  module Form
5
5
  # Tailwind-styled submit button
6
6
  class SubmitButtonComponent < TailwindComponent
7
- def initialize(action, size: :middle, **options)
7
+ def initialize(action, size: :medium, **options)
8
+ unless size.in?(%i[small medium large])
9
+ raise ArgumentError, "Invalid size: #{size}. Valid sizes are :small, :medium, :large."
10
+ end
11
+
8
12
  @text = action.is_a?(String) ? action : action.to_s.capitalize
9
13
 
10
- super(
11
- input: nil,
12
- attribute: nil,
13
- value: nil,
14
- options: options.except(:type),
15
- label: nil,
16
- for: nil,
17
- size:,
18
- )
14
+ super(input: nil, attribute: nil, value: nil, options: options.except(:type), label: nil, for: nil, size:)
19
15
  end
20
16
  end
21
17
  end
@@ -6,9 +6,9 @@ module Tramway
6
6
  module ViewsHelper
7
7
  include Tramway::Helpers::ComponentHelper
8
8
 
9
- FORM_SIZES = %i[small middle large].freeze
9
+ FORM_SIZES = %i[small medium large].freeze
10
10
 
11
- def tramway_form_for(object, *, size: :middle, **options, &)
11
+ def tramway_form_for(object, *, size: :medium, **options, &)
12
12
  form_for(
13
13
  object,
14
14
  *,
@@ -81,7 +81,7 @@ module Tramway
81
81
  private
82
82
 
83
83
  def normalize_form_size(size)
84
- FORM_SIZES.include?(size) ? size : :middle
84
+ FORM_SIZES.include?(size) ? size : :medium
85
85
  end
86
86
  end
87
87
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '2.2.2.3'
4
+ VERSION = '2.2.2.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2.3
4
+ version: 2.2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme
@@ -159,6 +159,8 @@ files:
159
159
  - app/components/tailwinds/form/builder.rb
160
160
  - app/components/tailwinds/form/date_field_component.html.haml
161
161
  - app/components/tailwinds/form/date_field_component.rb
162
+ - app/components/tailwinds/form/datetime_field_component.html.haml
163
+ - app/components/tailwinds/form/datetime_field_component.rb
162
164
  - app/components/tailwinds/form/file_field_component.html.haml
163
165
  - app/components/tailwinds/form/file_field_component.rb
164
166
  - app/components/tailwinds/form/label_component.html.haml