tramway 2.2.2.3 → 2.2.2.5

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: 16dd741a290fd86958fc3be90dc41cf9f9eccd0dd8c58b207832b60724a82e50
4
+ data.tar.gz: f5b04489412bc28d6d7460c3a11d740817327c6fbec90bcb696aaf618edcdb16
5
5
  SHA512:
6
- metadata.gz: 3d5c8c25e8d045fd09fc0a00fe6ef9481fb1164b115c6d505c2d6f6d3fc4e2dbe08a1decc83f91b8a24b302d4fdf25a425f324cb33001d648ac82ff067589441
7
- data.tar.gz: 353645345db6f6cd632eda339f29770361d87cde6b94b91d886e76eafba6e9f224f1e381498be204641211017d81381dce7e3ed10dc4667d0b1cc8beec8ca79c
6
+ metadata.gz: 75f82780780956fb53acb9e612a610979a6b0a30da5a04e79749384901aeed75c805e6e82ca1d987820ec81ca4ada47f4aea6a77d4ef087e433544c3c1d11037
7
+ data.tar.gz: 75fb50361d50ba1a7c2a30b7871747395ca0bf387378ab962e4da073a07db29d069c44a8d2f70bfedab2bccc27447d47a3c75404ea4860644e4d712a2d124826
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.5'
5
5
  end
metadata CHANGED
@@ -1,15 +1,14 @@
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme
8
8
  - moshiaan
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2026-01-15 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: anyway_config
@@ -159,6 +158,8 @@ files:
159
158
  - app/components/tailwinds/form/builder.rb
160
159
  - app/components/tailwinds/form/date_field_component.html.haml
161
160
  - app/components/tailwinds/form/date_field_component.rb
161
+ - app/components/tailwinds/form/datetime_field_component.html.haml
162
+ - app/components/tailwinds/form/datetime_field_component.rb
162
163
  - app/components/tailwinds/form/file_field_component.html.haml
163
164
  - app/components/tailwinds/form/file_field_component.rb
164
165
  - app/components/tailwinds/form/label_component.html.haml
@@ -281,7 +282,6 @@ metadata:
281
282
  homepage_uri: https://github.com/purple-magic/tramway
282
283
  source_code_uri: https://github.com/purple-magic/tramway
283
284
  changelog_uri: https://github.com/purple-magic/tramway
284
- post_install_message:
285
285
  rdoc_options: []
286
286
  require_paths:
287
287
  - lib
@@ -296,8 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
296
  - !ruby/object:Gem::Version
297
297
  version: '0'
298
298
  requirements: []
299
- rubygems_version: 3.4.6
300
- signing_key:
299
+ rubygems_version: 4.0.3
301
300
  specification_version: 4
302
301
  summary: Tramway Rails Engine
303
302
  test_files: []