nitro_kit 0.5.2 → 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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/nitro_kit/accordion.rb +35 -29
  3. data/app/components/nitro_kit/alert.rb +8 -4
  4. data/app/components/nitro_kit/avatar.rb +4 -2
  5. data/app/components/nitro_kit/avatar_stack.rb +23 -0
  6. data/app/components/nitro_kit/badge.rb +48 -4
  7. data/app/components/nitro_kit/button.rb +8 -2
  8. data/app/components/nitro_kit/card.rb +20 -10
  9. data/app/components/nitro_kit/checkbox.rb +23 -12
  10. data/app/components/nitro_kit/checkbox_group.rb +8 -4
  11. data/app/components/nitro_kit/combobox.rb +11 -2
  12. data/app/components/nitro_kit/component.rb +48 -23
  13. data/app/components/nitro_kit/dialog.rb +61 -38
  14. data/app/components/nitro_kit/dropdown.rb +70 -49
  15. data/app/components/nitro_kit/field.rb +103 -65
  16. data/app/components/nitro_kit/fieldset.rb +13 -6
  17. data/app/components/nitro_kit/form_builder.rb +27 -8
  18. data/app/components/nitro_kit/icon.rb +3 -2
  19. data/app/components/nitro_kit/input.rb +1 -1
  20. data/app/components/nitro_kit/pagination.rb +42 -34
  21. data/app/components/nitro_kit/radio_button.rb +33 -18
  22. data/app/components/nitro_kit/radio_button_group.rb +20 -16
  23. data/app/components/nitro_kit/select.rb +10 -8
  24. data/app/components/nitro_kit/table.rb +38 -11
  25. data/app/components/nitro_kit/tabs.rb +47 -41
  26. data/app/components/nitro_kit/textarea.rb +6 -2
  27. data/app/components/nitro_kit/toast.rb +26 -3
  28. data/app/components/nitro_kit/tooltip.rb +13 -11
  29. data/app/helpers/nitro_kit/accordion_helper.rb +1 -1
  30. data/app/helpers/nitro_kit/alert_helper.rb +1 -1
  31. data/app/helpers/nitro_kit/avatar_helper.rb +5 -1
  32. data/app/helpers/nitro_kit/badge_helper.rb +1 -1
  33. data/app/helpers/nitro_kit/button_group_helper.rb +1 -1
  34. data/app/helpers/nitro_kit/button_helper.rb +3 -3
  35. data/app/helpers/nitro_kit/card_helper.rb +1 -1
  36. data/app/helpers/nitro_kit/checkbox_helper.rb +25 -2
  37. data/app/helpers/nitro_kit/combobox_helper.rb +1 -1
  38. data/app/helpers/nitro_kit/datepicker_helper.rb +1 -1
  39. data/app/helpers/nitro_kit/dialog_helper.rb +1 -1
  40. data/app/helpers/nitro_kit/dropdown_helper.rb +1 -1
  41. data/app/helpers/nitro_kit/field_group_helper.rb +1 -1
  42. data/app/helpers/nitro_kit/field_helper.rb +1 -1
  43. data/app/helpers/nitro_kit/fieldset_helper.rb +1 -1
  44. data/app/helpers/nitro_kit/icon_helper.rb +1 -1
  45. data/app/helpers/nitro_kit/input_helper.rb +1 -1
  46. data/app/helpers/nitro_kit/label_helper.rb +1 -1
  47. data/app/helpers/nitro_kit/pagination_helper.rb +1 -1
  48. data/app/helpers/nitro_kit/radio_button_helper.rb +2 -2
  49. data/app/helpers/nitro_kit/select_helper.rb +1 -1
  50. data/app/helpers/nitro_kit/switch_helper.rb +1 -1
  51. data/app/helpers/nitro_kit/table_helper.rb +1 -1
  52. data/app/helpers/nitro_kit/tabs_helper.rb +1 -1
  53. data/app/helpers/nitro_kit/textarea_helper.rb +1 -1
  54. data/app/helpers/nitro_kit/toast_helper.rb +2 -13
  55. data/app/helpers/nitro_kit/tooltip_helper.rb +1 -1
  56. data/lib/nitro_kit/version.rb +1 -1
  57. metadata +6 -6
  58. data/MIT-LICENSE +0 -20
@@ -17,11 +17,34 @@ 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
+ def nk_checkbox_tag(name, *args)
24
+ if args.length >= 4
25
+ raise ArgumentError, "wrong number of arguments (given #{args.length + 1}, expected 1..4)"
26
+ end
27
+
28
+ options = args.extract_options!
29
+ value, checked = args.empty? ? ["1", false] : [*args, false]
30
+ attrs = {
31
+ type: "checkbox",
32
+ name: name,
33
+ id: sanitize_to_id(name),
34
+ value: value
35
+ }.update(
36
+ options.symbolize_keys
37
+ )
38
+
39
+ attrs[:checked] = "checked" if checked
40
+
41
+ render(Checkbox.from_template(name:, **attrs))
42
+ end
43
+
44
+ alias :nk_check_box_tag :nk_checkbox_tag
45
+
23
46
  def nk_checkbox_group(**attrs, &block)
24
- render(CheckboxGroup.new(**attrs), &block)
47
+ render(CheckboxGroup.from_template(**attrs), &block)
25
48
  end
26
49
  end
27
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,18 +15,7 @@ module NitroKit
15
15
  end
16
16
 
17
17
  def nk_toast_flash_messages
18
- capture do
19
- flash.each do |severity, message|
20
- concat(
21
- render(
22
- Toast::Item.new(
23
- description: message,
24
- variant: severity.to_sym == :alert ? :error : :default
25
- )
26
- )
27
- )
28
- end
29
- end
18
+ render(Toast::FlashMessages.from_template(flash))
30
19
  end
31
20
 
32
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.5.2"
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.5.2
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-02-14 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
@@ -43,14 +43,14 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.0.0.beta2
46
+ version: 2.1.0
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 2.0.0.beta2
53
+ version: 2.1.0
54
54
  description: WIP, not usable yet
55
55
  email:
56
56
  - mikkel@brnbw.com
@@ -58,12 +58,12 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - MIT-LICENSE
62
61
  - README.md
63
62
  - Rakefile
64
63
  - app/components/nitro_kit/accordion.rb
65
64
  - app/components/nitro_kit/alert.rb
66
65
  - app/components/nitro_kit/avatar.rb
66
+ - app/components/nitro_kit/avatar_stack.rb
67
67
  - app/components/nitro_kit/badge.rb
68
68
  - app/components/nitro_kit/button.rb
69
69
  - app/components/nitro_kit/button_group.rb
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
159
  requirements: []
160
- rubygems_version: 3.6.3
160
+ rubygems_version: 3.6.9
161
161
  specification_version: 4
162
162
  summary: WIP, not usable yet
163
163
  test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright Mikkel Malmberg
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.