nitro_kit 0.6.0 → 0.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/nitro_kit/accordion.rb +36 -30
  3. data/app/components/nitro_kit/alert.rb +10 -6
  4. data/app/components/nitro_kit/avatar_stack.rb +23 -0
  5. data/app/components/nitro_kit/button.rb +6 -0
  6. data/app/components/nitro_kit/card.rb +25 -15
  7. data/app/components/nitro_kit/checkbox.rb +2 -0
  8. data/app/components/nitro_kit/checkbox_group.rb +10 -6
  9. data/app/components/nitro_kit/component.rb +16 -19
  10. data/app/components/nitro_kit/dialog.rb +63 -53
  11. data/app/components/nitro_kit/dropdown.rb +76 -59
  12. data/app/components/nitro_kit/field.rb +82 -65
  13. data/app/components/nitro_kit/fieldset.rb +14 -7
  14. data/app/components/nitro_kit/form_builder.rb +13 -10
  15. data/app/components/nitro_kit/input.rb +1 -1
  16. data/app/components/nitro_kit/pagination.rb +45 -37
  17. data/app/components/nitro_kit/radio_button.rb +1 -1
  18. data/app/components/nitro_kit/radio_button_group.rb +22 -18
  19. data/app/components/nitro_kit/select.rb +9 -7
  20. data/app/components/nitro_kit/table.rb +22 -12
  21. data/app/components/nitro_kit/tabs.rb +49 -43
  22. data/app/components/nitro_kit/textarea.rb +6 -2
  23. data/app/components/nitro_kit/toast.rb +9 -5
  24. data/app/components/nitro_kit/tooltip.rb +14 -12
  25. data/app/helpers/nitro_kit/accordion_helper.rb +1 -1
  26. data/app/helpers/nitro_kit/alert_helper.rb +1 -1
  27. data/app/helpers/nitro_kit/avatar_helper.rb +5 -1
  28. data/app/helpers/nitro_kit/badge_helper.rb +1 -1
  29. data/app/helpers/nitro_kit/button_group_helper.rb +1 -1
  30. data/app/helpers/nitro_kit/button_helper.rb +3 -3
  31. data/app/helpers/nitro_kit/card_helper.rb +1 -1
  32. data/app/helpers/nitro_kit/checkbox_helper.rb +3 -3
  33. data/app/helpers/nitro_kit/combobox_helper.rb +1 -1
  34. data/app/helpers/nitro_kit/datepicker_helper.rb +1 -1
  35. data/app/helpers/nitro_kit/dialog_helper.rb +1 -1
  36. data/app/helpers/nitro_kit/dropdown_helper.rb +1 -1
  37. data/app/helpers/nitro_kit/field_group_helper.rb +1 -1
  38. data/app/helpers/nitro_kit/field_helper.rb +1 -1
  39. data/app/helpers/nitro_kit/fieldset_helper.rb +1 -1
  40. data/app/helpers/nitro_kit/icon_helper.rb +1 -1
  41. data/app/helpers/nitro_kit/input_helper.rb +1 -1
  42. data/app/helpers/nitro_kit/label_helper.rb +1 -1
  43. data/app/helpers/nitro_kit/pagination_helper.rb +1 -1
  44. data/app/helpers/nitro_kit/radio_button_helper.rb +2 -2
  45. data/app/helpers/nitro_kit/select_helper.rb +1 -1
  46. data/app/helpers/nitro_kit/switch_helper.rb +1 -1
  47. data/app/helpers/nitro_kit/table_helper.rb +1 -1
  48. data/app/helpers/nitro_kit/tabs_helper.rb +1 -1
  49. data/app/helpers/nitro_kit/textarea_helper.rb +1 -1
  50. data/app/helpers/nitro_kit/toast_helper.rb +2 -2
  51. data/app/helpers/nitro_kit/tooltip_helper.rb +1 -1
  52. data/lib/nitro_kit/version.rb +1 -1
  53. metadata +4 -3
@@ -104,13 +104,17 @@ module NitroKit
104
104
  end
105
105
  end
106
106
 
107
- builder_method def item(title: nil, description: nil, **attrs, &block)
108
- render(Item.new(title:, description:, **attrs), &block)
107
+ def item(title: nil, description: nil, **attrs, &block)
108
+ builder do
109
+ render(Item.new(title:, description:, **attrs), &block)
110
+ end
109
111
  end
110
112
 
111
- builder_method def flash_sink
112
- div(id: "nk--toast-sink", data: {nk__toast_target: "sink"}, hidden: true) do
113
- render(FlashMessages.new(view_context.flash))
113
+ def flash_sink
114
+ builder do
115
+ div(id: "nk--toast-sink", data: {nk__toast_target: "sink"}, hidden: true) do
116
+ render(FlashMessages.new(view_context.flash))
117
+ end
114
118
  end
115
119
  end
116
120
 
@@ -25,18 +25,20 @@ module NitroKit
25
25
  end
26
26
  end
27
27
 
28
- builder_method def content(text = nil, **attrs, &block)
29
- div(
30
- **mattr(
31
- attrs,
32
- class: tooltip_class,
33
- data: {
34
- state: "closed",
35
- nk__tooltip_target: "content"
36
- }
37
- )
38
- ) do
39
- text_or_block(text, &block)
28
+ def content(text = nil, **attrs, &block)
29
+ builder do
30
+ div(
31
+ **mattr(
32
+ attrs,
33
+ class: tooltip_class,
34
+ data: {
35
+ state: "closed",
36
+ nk__tooltip_target: "content"
37
+ }
38
+ )
39
+ ) do
40
+ text_or_block(text, &block)
41
+ end
40
42
  end
41
43
  end
42
44
 
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module AccordionHelper
5
5
  def nk_accordion(**attrs, &block)
6
- render(Accordion.new(**attrs), &block)
6
+ render(Accordion.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ module NitroKit
3
3
  include Variants
4
4
 
5
5
  def nk_alert(**attrs, &block)
6
- render(Alert.new(**attrs), &block)
6
+ render(Alert.from_template(**attrs), &block)
7
7
  end
8
8
 
9
9
  automatic_variants(Alert::VARIANTS, :nk_alert)
@@ -3,7 +3,11 @@
3
3
  module NitroKit
4
4
  module AvatarHelper
5
5
  def nk_avatar(src = nil, **attrs, &block)
6
- render(Avatar.new(src, **attrs), &block)
6
+ render(Avatar.from_template(src, **attrs), &block)
7
+ end
8
+
9
+ def nk_avatar_stack(**attrs, &block)
10
+ render(AvatarStack.from_template(**attrs), &block)
7
11
  end
8
12
  end
9
13
  end
@@ -7,7 +7,7 @@ module NitroKit
7
7
  automatic_variants(Badge::VARIANTS, :nk_badge)
8
8
 
9
9
  def nk_badge(text = nil, **attrs, &block)
10
- render(NitroKit::Badge.new(text, **attrs), &block)
10
+ render(NitroKit::Badge.from_template(text, **attrs), &block)
11
11
  end
12
12
  end
13
13
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module ButtonGroupHelper
5
5
  def nk_button_group(**attrs, &block)
6
- render(ButtonGroup.new(**attrs), &block)
6
+ render(ButtonGroup.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -5,7 +5,7 @@ module NitroKit
5
5
  include Variants
6
6
 
7
7
  def nk_button(text = nil, **attrs, &block)
8
- render(NitroKit::Button.new(text, **attrs), &block)
8
+ render(NitroKit::Button.from_template(text, **attrs), &block)
9
9
  end
10
10
 
11
11
  automatic_variants(Button::VARIANTS, :nk_button)
@@ -37,13 +37,13 @@ module NitroKit
37
37
 
38
38
  href = attrs[:href] || url_target(text, options)
39
39
 
40
- render(NitroKit::Button.new(text, **attrs, href:), &block)
40
+ render(NitroKit::Button.from_template(text, **attrs, href:), &block)
41
41
  end
42
42
 
43
43
  automatic_variants(Button::VARIANTS, :nk_button_link_to)
44
44
 
45
45
  def nk_button_group(**attrs, &block)
46
- render(ButtonGroup.new(**attrs), &block)
46
+ render(ButtonGroup.from_template(**attrs), &block)
47
47
  end
48
48
  end
49
49
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module CardHelper
5
5
  def nk_card(**attrs, &block)
6
- render(Card.new(**attrs), &block)
6
+ render(Card.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -17,7 +17,7 @@ module NitroKit
17
17
 
18
18
  # TODO: multiple, unchecked hidden field
19
19
 
20
- render(Checkbox.new(name:, label:, value: compat_checked_value, checked:, **attrs))
20
+ render(Checkbox.from_template(name:, label:, value: compat_checked_value, checked:, **attrs))
21
21
  end
22
22
 
23
23
  def nk_checkbox_tag(name, *args)
@@ -38,13 +38,13 @@ module NitroKit
38
38
 
39
39
  attrs[:checked] = "checked" if checked
40
40
 
41
- render(Checkbox.new(name:, **attrs))
41
+ render(Checkbox.from_template(name:, **attrs))
42
42
  end
43
43
 
44
44
  alias :nk_check_box_tag :nk_checkbox_tag
45
45
 
46
46
  def nk_checkbox_group(**attrs, &block)
47
- render(CheckboxGroup.new(**attrs), &block)
47
+ render(CheckboxGroup.from_template(**attrs), &block)
48
48
  end
49
49
  end
50
50
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module ComboboxHelper
5
5
  def nk_combobox(name = nil, options = [], **attrs)
6
- render(NitroKit::Combobox.new(name:, options:, **attrs))
6
+ render(NitroKit::Combobox.from_template(name:, options:, **attrs))
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module DatepickerHelper
5
5
  def nk_datepicker(**attrs, &block)
6
- render(Datepicker.new(**attrs), &block)
6
+ render(Datepicker.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module DialogHelper
5
5
  def nk_dialog(**attrs, &block)
6
- render(Dialog.new(**attrs), &block)
6
+ render(Dialog.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module DropdownHelper
5
5
  def nk_dropdown(**attrs, &block)
6
- render(Dropdown.new(**attrs), &block)
6
+ render(Dropdown.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module FieldGroupHelper
5
5
  def nk_field_group(**attrs)
6
- render(NitroKit::FieldGroup.new(**attrs)) { yield }
6
+ render(NitroKit::FieldGroup.from_template(**attrs)) { yield }
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module FieldHelper
5
5
  def nk_field(*args, **attrs, &block)
6
- render(NitroKit::Field.new(*args, **attrs), &block)
6
+ render(NitroKit::Field.from_template(*args, **attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module FieldsetHelper
5
5
  def nk_fieldset(**attrs, &block)
6
- render(NitroKit::Fieldset.new(**attrs), &block)
6
+ render(NitroKit::Fieldset.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module IconHelper
5
5
  def nk_icon(name, **attrs)
6
- render(NitroKit::Icon.new(name, **attrs))
6
+ render(NitroKit::Icon.from_template(name, **attrs))
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module InputHelper
5
5
  def nk_input(**attrs)
6
- render(Input.new(**attrs))
6
+ render(Input.from_template(**attrs))
7
7
  end
8
8
 
9
9
  %w[
@@ -13,7 +13,7 @@ module NitroKit
13
13
  attrs.merge!(content_or_options)
14
14
  end
15
15
 
16
- render(Label.new(text, for: name, **attrs), &block)
16
+ render(Label.from_template(text, for: name, **attrs), &block)
17
17
  end
18
18
  end
19
19
  end
@@ -5,7 +5,7 @@ module NitroKit
5
5
  include Pagy::UrlHelpers if defined?(Pagy)
6
6
 
7
7
  def nk_pagination(**attrs, &block)
8
- render(Pagination.new(**attrs), &block)
8
+ render(Pagination.from_template(**attrs), &block)
9
9
  end
10
10
 
11
11
  def nk_pagy_nav(pagy, id: nil, aria_label: nil, **attrs)
@@ -13,11 +13,11 @@ module NitroKit
13
13
  name = field_name(compat_object_name, compat_method)
14
14
  value = compat_tag_value || attrs[:value]
15
15
 
16
- render(RadioButton.new(label:, name:, value:, **attrs))
16
+ render(RadioButton.from_template(label:, name:, value:, **attrs))
17
17
  end
18
18
 
19
19
  def nk_radio_button_group(**attrs, &block)
20
- render(RadioButtonGroup.new(**attrs), &block)
20
+ render(RadioButtonGroup.from_template(**attrs), &block)
21
21
  end
22
22
  end
23
23
  end
@@ -18,7 +18,7 @@ module NitroKit
18
18
 
19
19
  # TODO: support index
20
20
 
21
- render(Select.new(options, value:, include_blank:, prompt:, **compat_options, **attrs), &block)
21
+ render(Select.from_template(options, value:, include_blank:, prompt:, **compat_options, **attrs), &block)
22
22
  end
23
23
  end
24
24
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module SwitchHelper
5
5
  def nk_switch(**attrs, &block)
6
- render(Switch.new(**attrs), &block)
6
+ render(Switch.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module TableHelper
5
5
  def nk_table(**attrs, &block)
6
- render(Table.new(**attrs), &block)
6
+ render(Table.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module TabsHelper
5
5
  def nk_tabs(**attrs, &block)
6
- render(Tabs.new(**attrs), &block)
6
+ render(Tabs.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module TextareaHelper
5
5
  def nk_textarea(**attrs)
6
- render(Textarea.new(**attrs))
6
+ render(Textarea.from_template(**attrs))
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module ToastHelper
5
5
  def nk_toast(**attrs, &block)
6
- render(Toast.new(**attrs), &block)
6
+ render(Toast.from_template(**attrs), &block)
7
7
  end
8
8
 
9
9
  def nk_toast_action(title: nil, description: nil, event: nil)
@@ -15,7 +15,7 @@ module NitroKit
15
15
  end
16
16
 
17
17
  def nk_toast_flash_messages
18
- render(Toast::FlashMessages.new(flash))
18
+ render(Toast::FlashMessages.from_template(flash))
19
19
  end
20
20
 
21
21
  def nk_toast_turbo_stream_refresh
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  module TooltipHelper
5
5
  def nk_tooltip(**attrs, &block)
6
- render(Tooltip.new(**attrs), &block)
6
+ render(Tooltip.from_template(**attrs), &block)
7
7
  end
8
8
  end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module NitroKit
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nitro_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -63,6 +63,7 @@ files:
63
63
  - app/components/nitro_kit/accordion.rb
64
64
  - app/components/nitro_kit/alert.rb
65
65
  - app/components/nitro_kit/avatar.rb
66
+ - app/components/nitro_kit/avatar_stack.rb
66
67
  - app/components/nitro_kit/badge.rb
67
68
  - app/components/nitro_kit/button.rb
68
69
  - app/components/nitro_kit/button_group.rb
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  - !ruby/object:Gem::Version
157
158
  version: '0'
158
159
  requirements: []
159
- rubygems_version: 3.6.6
160
+ rubygems_version: 3.6.9
160
161
  specification_version: 4
161
162
  summary: WIP, not usable yet
162
163
  test_files: []