nitro_kit 0.7.0 → 0.8.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: 43de49498356e50a1fbcac794f988fdcb36c4032bea949316aee19483c1b9208
4
- data.tar.gz: 3b4d2a3cdaae5730e46a5880e0ed7d05e0d824bda868d4200d76785c14087ca0
3
+ metadata.gz: 3f96e86485be82839eb17fea8522c31b8bac982f5b9e09a479d159e9f69b59f7
4
+ data.tar.gz: 41814a0fc817bd11dab95a132de45a83c300c52a39cf3d407e0174c0a6af9584
5
5
  SHA512:
6
- metadata.gz: 62f3abbfcc402e5a97b2223f91f95601655ec3a5f6824514ad27e2160d093fb62f458b6caccee302bd948717a29e8d89c248cc0e7f760ec03e870f06bb1dab00
7
- data.tar.gz: f00b678398e9430ca799ca92f5331a1e62a1fb459237929aed658d24a6ec98836adde8617cbc01add48ac7d5bf66834ca5094fb2307378447e265203d2e306a3
6
+ metadata.gz: 73c6883c42f6cab78d4fe6550ea88dda8c0546ae33c6c9f9696b894bbba47d98a381de82385c754f41e56f1971177876c2ca2e1460ee53243ee4eba82f7ddd74
7
+ data.tar.gz: 81998e474d6125fcc2bd6fa094223c3e4470261519049535c0301922873325206c50ad49b6c4756be1914f0a88bb915a7221f1b99c75018120cb6f26dd34f321
@@ -6,7 +6,7 @@ module NitroKit
6
6
  super(
7
7
  attrs,
8
8
  class: item_class,
9
- data: {controller: "nk--accordion"}
9
+ data: { controller: "nk--accordion" }
10
10
  )
11
11
  end
12
12
 
@@ -35,7 +35,7 @@ module NitroKit
35
35
  action: "nk--accordion#toggle",
36
36
  nk__accordion_target: "trigger"
37
37
  },
38
- aria: {expanded: "false"}
38
+ aria: { expanded: "false" }
39
39
  )
40
40
  ) do
41
41
  block_given? ? yield : plain(text)
@@ -53,7 +53,7 @@ module NitroKit
53
53
  data: {
54
54
  nk__accordion_target: "content"
55
55
  },
56
- aria: {hidden: "true"}
56
+ aria: { hidden: "true" }
57
57
  )
58
58
  ) do
59
59
  div(class: "pb-4") { yield }
@@ -10,7 +10,7 @@ module NitroKit
10
10
  super(
11
11
  attrs,
12
12
  role: "alert",
13
- class: [base_class, variant_class]
13
+ class: [ base_class, variant_class ]
14
14
  )
15
15
  end
16
16
 
@@ -10,7 +10,7 @@ module NitroKit
10
10
 
11
11
  super(
12
12
  attrs,
13
- class: [container_class, size_classes]
13
+ class: [ container_class, size_classes ]
14
14
  )
15
15
  end
16
16
 
@@ -22,7 +22,7 @@ module NitroKit
22
22
  end
23
23
  end
24
24
 
25
- builder_method def image
25
+ def image
26
26
  image_tag(src, class: image_class)
27
27
  end
28
28
 
@@ -16,7 +16,7 @@ module NitroKit
16
16
  end
17
17
  end
18
18
 
19
- builder_method def avatar(*args, **attrs, &block)
19
+ def avatar(*args, **attrs, &block)
20
20
  render(Avatar.new(*args, size:, **attrs, &block))
21
21
  end
22
22
  end
@@ -49,7 +49,7 @@ module NitroKit
49
49
 
50
50
  def full_width(**attrs)
51
51
  builder do
52
- div(**mattr(attrs, data: {slot: "full"}, class: "-mx-(--gap)")) do
52
+ div(**mattr(attrs, data: { slot: "full" }, class: "-mx-(--gap)")) do
53
53
  yield
54
54
  end
55
55
  end
@@ -48,7 +48,7 @@ module NitroKit
48
48
  stroke_linecap: "round",
49
49
  stroke_linejoin: "round",
50
50
  stroke_width: 3,
51
- data: {check: ""}
51
+ data: { check: "" }
52
52
  ) do |svg|
53
53
  svg.path(d: "M 3 8 L 6 12 L 13 5")
54
54
  end
@@ -62,7 +62,7 @@ module NitroKit
62
62
  stroke: "currentColor",
63
63
  stroke_linecap: "round",
64
64
  stroke_width: 3,
65
- data: {indeterminate: ""}
65
+ data: { indeterminate: "" }
66
66
  ) do |svg|
67
67
  svg.line(x1: "3", y1: "8", x2: "13", y2: "8")
68
68
  end
@@ -9,7 +9,7 @@ module NitroKit
9
9
  placement: "bottom",
10
10
  tab_inserts_suggestions: true,
11
11
  first_option_selection_mode: "selected",
12
- scroll_into_view_options: {block: "nearest", inline: "nearest"},
12
+ scroll_into_view_options: { block: "nearest", inline: "nearest" },
13
13
 
14
14
  **attrs
15
15
  )
@@ -77,19 +77,19 @@ module NitroKit
77
77
  type: "hidden",
78
78
  value: attrs[:value],
79
79
  name: attrs[:name],
80
- data: {nk__combobox_target: "hiddenField"}
80
+ data: { nk__combobox_target: "hiddenField" }
81
81
  )
82
82
 
83
83
  ul(
84
84
  role: "listbox",
85
85
  id: id(:listbox),
86
86
  class: list_class,
87
- data: {nk__combobox_target: "list", state: "closed"}
87
+ data: { nk__combobox_target: "list", state: "closed" }
88
88
  ) do
89
89
  options.each do |(key, value)|
90
90
  li(
91
91
  role: "option",
92
- data: {value:},
92
+ data: { value: },
93
93
  class: merge_class(option_class)
94
94
  ) { key }
95
95
  end
@@ -62,7 +62,7 @@ module NitroKit
62
62
  # Concat Stimulus actions
63
63
  case key
64
64
  when :action, :controller
65
- [new_val, old_val].compact.join(" ")
65
+ [ new_val, old_val ].compact.join(" ")
66
66
  else
67
67
  new_val
68
68
  end
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  class Datepicker < Component
5
5
  def view_template
6
- render(Input.new(type: "text", **attrs, data: {controller: "nk--datepicker"}))
6
+ render(Input.new(type: "text", **attrs, data: { controller: "nk--datepicker" }))
7
7
  end
8
8
  end
9
9
  end
@@ -7,7 +7,7 @@ module NitroKit
7
7
 
8
8
  super(
9
9
  attrs,
10
- data: {controller: "nk--dialog", action: "click->nk--dialog#clickOutside"}
10
+ data: { controller: "nk--dialog", action: "click->nk--dialog#clickOutside" }
11
11
  )
12
12
  end
13
13
 
@@ -50,7 +50,7 @@ module NitroKit
50
50
  **mattr(
51
51
  attrs,
52
52
  class: dialog_class,
53
- data: {nk__dialog_target: "dialog"},
53
+ data: { nk__dialog_target: "dialog" },
54
54
  aria: {
55
55
  labelledby: id(:title),
56
56
  describedby: id(:description)
@@ -71,7 +71,7 @@ module NitroKit
71
71
  variant: :ghost,
72
72
  size: :sm,
73
73
  class: "absolute top-2 right-2",
74
- data: {action: "nk--dialog#close"}
74
+ data: { action: "nk--dialog#close" }
75
75
  )
76
76
  )
77
77
  ) do
@@ -30,8 +30,8 @@ module NitroKit
30
30
  builder do
31
31
  trigger_attrs = mattr(
32
32
  attrs,
33
- aria: {haspopup: "true", expanded: "false"},
34
- data: {nk__dropdown_target: "trigger", action: "click->nk--dropdown#toggle"}
33
+ aria: { haspopup: "true", expanded: "false" },
34
+ data: { nk__dropdown_target: "trigger", action: "click->nk--dropdown#toggle" }
35
35
  )
36
36
 
37
37
  case as
@@ -53,9 +53,9 @@ module NitroKit
53
53
  **mattr(
54
54
  attrs,
55
55
  role: "menu",
56
- aria: {hidden: "true"},
56
+ aria: { hidden: "true" },
57
57
  class: content_class,
58
- data: {nk__dropdown_target: "content"},
58
+ data: { nk__dropdown_target: "content" },
59
59
  popover: true
60
60
  )
61
61
  ) do
@@ -78,7 +78,7 @@ module NitroKit
78
78
  attrs,
79
79
  role: "menuitem",
80
80
  tabindex: "-1",
81
- class: [item_class, item_variant_class(variant)]
81
+ class: [ item_class, item_variant_class(variant) ]
82
82
  )
83
83
 
84
84
  if href
@@ -11,6 +11,8 @@ module NitroKit
11
11
  errors: nil,
12
12
  wrapper: {},
13
13
  options: nil,
14
+ include_blank: nil,
15
+ prompt: nil,
14
16
  **attrs
15
17
  )
16
18
  @form = form
@@ -22,6 +24,8 @@ module NitroKit
22
24
 
23
25
  # select, radio group
24
26
  @options = options
27
+ @include_blank = include_blank
28
+ @prompt = prompt
25
29
 
26
30
  @field_attrs = attrs
27
31
  @field_label = label.nil? ? field_name.to_s.humanize : label
@@ -32,7 +36,7 @@ module NitroKit
32
36
 
33
37
  super(
34
38
  wrapper,
35
- data: {as: @as.to_s},
39
+ data: { as: @as.to_s },
36
40
  class: base_class
37
41
  )
38
42
  end
@@ -66,7 +70,7 @@ module NitroKit
66
70
 
67
71
  return unless text
68
72
 
69
- render(Label.new(**mattr(attrs, for: id, data: {slot: "label"}))) do
73
+ render(Label.new(**mattr(attrs, for: id, data: { slot: "label" }))) do
70
74
  text
71
75
  end
72
76
  end
@@ -78,7 +82,7 @@ module NitroKit
78
82
 
79
83
  return unless text || block_given?
80
84
 
81
- div(**mattr(attrs, data: {slot: "description"}, class: description_class)) do
85
+ div(**mattr(attrs, data: { slot: "description" }, class: description_class)) do
82
86
  text_or_block(text, &block)
83
87
  end
84
88
  end
@@ -90,7 +94,7 @@ module NitroKit
90
94
 
91
95
  return unless error_messages&.any?
92
96
 
93
- ul(**mattr(attrs, data: {slot: "error"}, class: error_class)) do |msg|
97
+ ul(**mattr(attrs, data: { slot: "error" }, class: error_class)) do |msg|
94
98
  error_messages.each do |msg|
95
99
  li { msg }
96
100
  end
@@ -166,7 +170,7 @@ module NitroKit
166
170
  name:,
167
171
  id:,
168
172
  value: value_before_typecast,
169
- data: {slot: "control"}
173
+ data: { slot: "control" }
170
174
  )
171
175
  end
172
176
 
@@ -185,10 +189,17 @@ module NitroKit
185
189
 
186
190
  alias :html_select :select
187
191
 
188
- def select(options: nil, **attrs)
192
+ def select(options: nil, include_blank: nil, prompt: nil, **attrs)
193
+ collection = options || @options || []
194
+ blank_option = include_blank || @include_blank
195
+ prompt_text = prompt || @prompt
196
+
189
197
  render(
190
198
  Select.new(
191
- options || @options || [],
199
+ collection,
200
+ value: value,
201
+ include_empty: blank_option,
202
+ prompt: prompt_text,
192
203
  **control_attrs(
193
204
  **field_attrs,
194
205
  **attrs
@@ -3,7 +3,7 @@
3
3
  module NitroKit
4
4
  class FieldGroup < Component
5
5
  def initialize(**attrs)
6
- super(attrs, class: base_class, data: {slot: "control"})
6
+ super(attrs, class: base_class, data: { slot: "control" })
7
7
  end
8
8
 
9
9
  def view_template(&block)
@@ -32,7 +32,7 @@ module NitroKit
32
32
 
33
33
  def description(text = nil, **attrs, &block)
34
34
  builder do
35
- div(**mattr(attrs, class: description_class, data: {slot: "text"})) do
35
+ div(**mattr(attrs, class: description_class, data: { slot: "text" })) do
36
36
  text_or_block(text, &block)
37
37
  end
38
38
  end
@@ -86,5 +86,18 @@ module NitroKit
86
86
 
87
87
  @template.render(NitroKit::Button.new(value, **attrs), &block)
88
88
  end
89
+
90
+ def select(method, choices = nil, options = {}, html_options = {}, &block)
91
+ field_options = {
92
+ as: :select,
93
+ options: choices,
94
+ include_blank: options[:include_blank],
95
+ prompt: options[:prompt]
96
+ }.compact
97
+
98
+ field_attributes = options.except(:include_blank, :prompt, :selected)
99
+
100
+ field(method, **field_options, **field_attributes, **html_options, &block)
101
+ end
89
102
  end
90
103
  end
@@ -8,7 +8,7 @@ module NitroKit
8
8
  super(
9
9
  attrs,
10
10
  class: "text-sm font-medium select-none",
11
- data: {slot: "label"}
11
+ data: { slot: "label" }
12
12
  )
13
13
  end
14
14
 
@@ -6,7 +6,7 @@ module NitroKit
6
6
  super(
7
7
  attrs,
8
8
  class: merge_class(nav_class, attrs[:class]),
9
- aria: {label: "Pagination"}
9
+ aria: { label: "Pagination" }
10
10
  )
11
11
  end
12
12
 
@@ -18,7 +18,7 @@ module NitroKit
18
18
 
19
19
  def prev(text = nil, **attrs, &block)
20
20
  builder do
21
- page_link(**mattr(attrs, aria: {label: "Previous page"})) do
21
+ page_link(**mattr(attrs, aria: { label: "Previous page" })) do
22
22
  if text || block_given?
23
23
  text_or_block(text, &block)
24
24
  else
@@ -31,7 +31,7 @@ module NitroKit
31
31
 
32
32
  def next(text = nil, **attrs, &block)
33
33
  builder do
34
- page_link(**mattr(attrs, aria: {label: "Next page"})) do
34
+ page_link(**mattr(attrs, aria: { label: "Next page" })) do
35
35
  if text || block_given?
36
36
  text_or_block(text, &block)
37
37
  else
@@ -51,7 +51,7 @@ module NitroKit
51
51
  current: current ? "page" : nil
52
52
  },
53
53
  disabled: current,
54
- class: [page_class, current && "bg-zinc-200/50 dark:bg-zinc-800/50"]
54
+ class: [ page_class, current && "bg-zinc-200/50 dark:bg-zinc-800/50" ]
55
55
  )
56
56
  ) do
57
57
  text_or_block(text, &block)
@@ -83,7 +83,7 @@ module NitroKit
83
83
  **mattr(
84
84
  attrs,
85
85
  role: "link",
86
- aria: {disabled: disabled.to_s},
86
+ aria: { disabled: disabled.to_s },
87
87
  class: link_class
88
88
  )
89
89
  ) do
@@ -4,7 +4,7 @@ module NitroKit
4
4
  class Select < Component
5
5
  def initialize(options = nil, value: nil, include_empty: false, prompt: nil, index: nil, **attrs)
6
6
  @options = options
7
- @value = value.to_s
7
+ @value = value&.to_s
8
8
  @include_empty = include_empty
9
9
  @prompt = prompt
10
10
  @index = index
@@ -18,10 +18,32 @@ module NitroKit
18
18
  attr_reader :value, :options, :include_empty, :prompts, :index
19
19
 
20
20
  def view_template
21
- span(class: wrapper_class, data: {slot: "control"}) do
21
+ span(class: wrapper_class, data: { slot: "control" }) do
22
22
  select(**attrs, class: select_class) do
23
- option if include_empty
24
- options ? options.map { |o| option(*o) } : yield
23
+ if include_empty
24
+ blank_text = if include_empty.is_a?(String)
25
+ include_empty
26
+ elsif @prompt
27
+ @prompt
28
+ else
29
+ ""
30
+ end
31
+
32
+ html_option(value: "", selected: @value == "") { blank_text }
33
+ end
34
+
35
+ if options
36
+ options.each do |opt|
37
+ if opt.is_a?(Array) && opt.length >= 2
38
+ html_option(value: opt[1], selected: @value == opt[1].to_s) { opt[0] }
39
+ else
40
+ # Handle simple strings - use as both label and value
41
+ html_option(value: opt.to_s, selected: @value == opt.to_s) { opt.to_s }
42
+ end
43
+ end
44
+ else
45
+ yield if block_given?
46
+ end
25
47
  end
26
48
 
27
49
  chevron_icon
@@ -30,15 +52,15 @@ module NitroKit
30
52
 
31
53
  alias :html_option :option
32
54
 
33
- def option(key_or_value = nil, value = nil, **attrs, &block)
55
+ def option(text = nil, value = nil, **attrs, &block)
34
56
  builder do
35
- value ||= key_or_value
57
+ value ||= text
36
58
 
37
59
  html_option(value:, selected: @value == value.to_s, **attrs) do
38
60
  if block_given?
39
61
  yield
40
62
  else
41
- key_or_value
63
+ text
42
64
  end
43
65
  end
44
66
  end
@@ -22,10 +22,10 @@ module NitroKit
22
22
  **mattr(
23
23
  **attrs,
24
24
  type: "button",
25
- class: [base_class, size_class],
26
- data: {controller: "nk--switch", action: "nk--switch#toggle"},
25
+ class: [ base_class, size_class ],
26
+ data: { controller: "nk--switch", action: "nk--switch#toggle" },
27
27
  role: "switch",
28
- aria: {checked: checked.to_s}
28
+ aria: { checked: checked.to_s }
29
29
  )
30
30
  ) do
31
31
  span(class: "sr-only") { description }
@@ -36,7 +36,7 @@ module NitroKit
36
36
  private
37
37
 
38
38
  def handle
39
- span(aria: {hidden: true}, class: handle_class, data: {slot: "handle"})
39
+ span(aria: { hidden: true }, class: handle_class, data: { slot: "handle" })
40
40
  end
41
41
 
42
42
  def base_class
@@ -2,16 +2,21 @@
2
2
 
3
3
  module NitroKit
4
4
  class Table < Component
5
- def initialize(**attrs)
6
- super(
7
- attrs,
8
- class: "w-full caption-bottom text-sm divide-y"
9
- )
5
+ def initialize(wrapper: {}, **attrs)
6
+ super(attrs)
7
+ @wrapper = wrapper
10
8
  end
11
9
 
10
+ attr_reader :wrapper
11
+
12
12
  def view_template
13
- div(class: "w-full overflow-x-scroll") do
14
- table(**attrs) do
13
+ div(**mattr(wrapper, class: "w-full overflow-x-scroll")) do
14
+ table(
15
+ **mattr(
16
+ attrs,
17
+ class: "w-full caption-bottom text-sm divide-y"
18
+ )
19
+ ) do
15
20
  yield
16
21
  end
17
22
  end
@@ -43,7 +48,7 @@ module NitroKit
43
48
 
44
49
  def th(text = nil, align: :left, **attrs, &block)
45
50
  builder do
46
- html_th(**mattr(attrs, class: [header_cell_classes, cell_classes, align_classes(align), "font-medium"])) do
51
+ html_th(**mattr(attrs, class: [ header_cell_classes, cell_classes, align_classes(align), "font-medium" ])) do
47
52
  text_or_block(text, &block)
48
53
  end
49
54
  end
@@ -51,7 +56,7 @@ module NitroKit
51
56
 
52
57
  def td(text = nil, align: nil, **attrs, &block)
53
58
  builder do
54
- html_td(**mattr(attrs, class: [cell_classes, align_classes(align)])) do
59
+ html_td(**mattr(attrs, class: [ cell_classes, align_classes(align) ])) do
55
60
  text_or_block(text, &block)
56
61
  end
57
62
  end
@@ -64,7 +69,7 @@ module NitroKit
64
69
  end
65
70
 
66
71
  def cell_classes
67
- "whitespace-nowrap py-2 min-h-10 px-2"
72
+ "py-2 min-h-10 px-2"
68
73
  end
69
74
 
70
75
  def align_classes(align = nil)
@@ -8,7 +8,7 @@ module NitroKit
8
8
 
9
9
  super(
10
10
  attrs,
11
- data: {controller: "nk--tabs", nk__tabs_active_value: default},
11
+ data: { controller: "nk--tabs", nk__tabs_active_value: default },
12
12
  class: base_class
13
13
  )
14
14
  end
@@ -37,9 +37,9 @@ module NitroKit
37
37
  variant_class
38
38
  ],
39
39
  role: "status",
40
- aria: {live: "off", atomic: "true"},
40
+ aria: { live: "off", atomic: "true" },
41
41
  tabindex: "0",
42
- data: {state: "closed"}
42
+ data: { state: "closed" }
43
43
  )
44
44
  )
45
45
  end
@@ -49,11 +49,11 @@ module NitroKit
49
49
  def view_template(&block)
50
50
  li(**attrs) do
51
51
  div(class: "grid gap-1") do
52
- div(class: "text-sm font-semibold", data: {slot: "title"}) do
52
+ div(class: "text-sm font-semibold", data: { slot: "title" }) do
53
53
  title && plain(title)
54
54
  end
55
55
 
56
- div(class: "text-sm opacity-90", data: {slot: "description"}) do
56
+ div(class: "text-sm opacity-90", data: { slot: "description" }) do
57
57
  text_or_block(description, &block)
58
58
  end
59
59
  end
@@ -87,34 +87,30 @@ module NitroKit
87
87
  attrs,
88
88
  role: "region",
89
89
  tabindex: "-1",
90
- aria: {label: "Notifications"},
90
+ aria: { label: "Notifications" },
91
91
  class: "pointer-events-none"
92
92
  )
93
93
  end
94
94
 
95
95
  def view_template
96
96
  div(**attrs) do
97
- ol(class: list_class, data: {nk__toast_target: "list"})
97
+ ol(class: list_class, data: { nk__toast_target: "list" })
98
98
  end
99
99
 
100
100
  flash_sink
101
101
 
102
- template(data: {nk__toast_target: "template"}) do
102
+ template(data: { nk__toast_target: "template" }) do
103
103
  item
104
104
  end
105
105
  end
106
106
 
107
107
  def item(title: nil, description: nil, **attrs, &block)
108
- builder do
109
- render(Item.new(title:, description:, **attrs), &block)
110
- end
108
+ render(Item.new(title:, description:, **attrs), &block)
111
109
  end
112
110
 
113
111
  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
112
+ div(id: "nk--toast-sink", data: { nk__toast_target: "sink" }, hidden: true) do
113
+ render(FlashMessages.new(view_context.flash))
118
114
  end
119
115
  end
120
116
 
@@ -26,7 +26,7 @@ module NitroKit
26
26
  end
27
27
 
28
28
  options = args.extract_options!
29
- value, checked = args.empty? ? ["1", false] : [*args, false]
29
+ value, checked = args.empty? ? [ "1", false ] : [ *args, false ]
30
30
  attrs = {
31
31
  type: "checkbox",
32
32
  name: name,
@@ -9,7 +9,7 @@ module NitroKit
9
9
  end
10
10
 
11
11
  def nk_pagy_nav(pagy, id: nil, aria_label: nil, **attrs)
12
- attrs[:aria] ||= {label: aria_label}
12
+ attrs[:aria] ||= { label: aria_label }
13
13
 
14
14
  nk_pagination(id:, **attrs) do |p|
15
15
  if prev_page = pagy.prev
@@ -18,7 +18,7 @@ module NitroKit
18
18
 
19
19
  # TODO: support index
20
20
 
21
- render(Select.from_template(options, value:, include_blank:, prompt:, **compat_options, **attrs), &block)
21
+ render(Select.from_template(options, value:, include_blank:, prompt:, name:, **compat_options, **attrs), &block)
22
22
  end
23
23
  end
24
24
  end
@@ -7,8 +7,6 @@ export default class extends Controller {
7
7
  };
8
8
 
9
9
  connect() {
10
- this.#flushSink();
11
-
12
10
  if (this.hasSinkTarget) {
13
11
  this.mutationObserver = new MutationObserver(([event]) => {
14
12
  if (event.addedNodes.length === 0) return;
@@ -16,6 +14,8 @@ export default class extends Controller {
16
14
  });
17
15
  this.mutationObserver.observe(this.sinkTarget, { childList: true });
18
16
  }
17
+
18
+ this.#flushSink();
19
19
  }
20
20
 
21
21
  disconnect() {
@@ -60,6 +60,8 @@ export default class extends Controller {
60
60
  }
61
61
 
62
62
  #flushSink() {
63
+ if (!this.hasSinkTarget) return;
64
+
63
65
  for (const li of this.sinkTarget.children) {
64
66
  this.show(li.cloneNode(true));
65
67
  li.remove();
@@ -50,7 +50,7 @@ module NitroKit
50
50
  def components
51
51
  return @components if @components
52
52
 
53
- if component_names == ["all"]
53
+ if component_names == [ "all" ]
54
54
  return @components = SCHEMA.all
55
55
  end
56
56
 
@@ -58,7 +58,7 @@ module NitroKit
58
58
  @components = component_names
59
59
  .flat_map do |name|
60
60
  component = SCHEMA.find(name)
61
- [component] + component.dependencies
61
+ [ component ] + component.dependencies
62
62
  end
63
63
  end
64
64
 
@@ -71,8 +71,8 @@ module NitroKit
71
71
  gems: []
72
72
  )
73
73
  # Default is one component, one helper with same name
74
- components ||= [name]
75
- helpers ||= [name]
74
+ components ||= [ name ]
75
+ helpers ||= [ name ]
76
76
 
77
77
  files = [
78
78
  components.map { |c| "app/components/nitro_kit/#{c}.rb" },
@@ -1,3 +1,3 @@
1
1
  module NitroKit
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/nitro_kit.rb CHANGED
@@ -10,37 +10,37 @@ module NitroKit
10
10
  extend SchemaBuilder
11
11
 
12
12
  SCHEMA = build_schema do |s|
13
- s.add(:accordion, js: [:accordion])
13
+ s.add(:accordion, js: [ :accordion ])
14
14
  s.add(:alert)
15
15
  s.add(:avatar)
16
16
  s.add(:badge)
17
- s.add(:button, [:icon], components: [:button, :button_group], helpers: [:button, :button_group])
17
+ s.add(:button, [ :icon ], components: [ :button, :button_group ], helpers: [ :button, :button_group ])
18
18
  s.add(:card)
19
- s.add(:checkbox, [:label], components: [:checkbox, :checkbox_group])
19
+ s.add(:checkbox, [ :label ], components: [ :checkbox, :checkbox_group ])
20
20
  s.add(
21
21
  :combobox,
22
- [:input],
23
- js: [:combobox],
24
- modules: ["@floating-ui/core", "@floating-ui/dom", "@github/combobox-nav"]
22
+ [ :input ],
23
+ js: [ :combobox ],
24
+ modules: [ "@floating-ui/core", "@floating-ui/dom", "@github/combobox-nav" ]
25
25
  )
26
26
  s.add(:datepicker)
27
- s.add(:dialog, [:button, :icon], js: [:dialog])
28
- s.add(:dropdown, [:button], js: [:dropdown], modules: ["@floating-ui/core", "@floating-ui/dom"])
29
- s.add(:field, [:label, :checkbox, :combobox, :label, :radio_button, :select, :switch, :textarea])
27
+ s.add(:dialog, [ :button, :icon ], js: [ :dialog ])
28
+ s.add(:dropdown, [ :button ], js: [ :dropdown ], modules: [ "@floating-ui/core", "@floating-ui/dom" ])
29
+ s.add(:field, [ :label, :checkbox, :combobox, :label, :radio_button, :select, :switch, :textarea ])
30
30
  s.add(:field_group)
31
- s.add(:fieldset, [:field_group])
32
- s.add(:form_builder, [:field], helpers: [:form])
33
- s.add(:icon, gems: ["lucide-rails"])
31
+ s.add(:fieldset, [ :field_group ])
32
+ s.add(:form_builder, [ :field ], helpers: [ :form ])
33
+ s.add(:icon, gems: [ "lucide-rails" ])
34
34
  s.add(:input)
35
35
  s.add(:label)
36
- s.add(:pagination, [:icon, :button])
37
- s.add(:radio_button, [:label], components: [:radio_button, :radio_button_group])
36
+ s.add(:pagination, [ :icon, :button ])
37
+ s.add(:radio_button, [ :label ], components: [ :radio_button, :radio_button_group ])
38
38
  s.add(:select)
39
- s.add(:switch, js: [:switch])
39
+ s.add(:switch, js: [ :switch ])
40
40
  s.add(:table)
41
- s.add(:tabs, js: [:tabs])
41
+ s.add(:tabs, js: [ :tabs ])
42
42
  s.add(:textarea)
43
- s.add(:toast, js: [:toast])
44
- s.add(:tooltip, js: [:tooltip], modules: ["@floating-ui/core", "@floating-ui/dom"])
43
+ s.add(:toast, js: [ :toast ])
44
+ s.add(:tooltip, js: [ :tooltip ], modules: [ "@floating-ui/core", "@floating-ui/dom" ])
45
45
  end
46
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nitro_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
@@ -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.9
160
+ rubygems_version: 3.7.1
161
161
  specification_version: 4
162
162
  summary: WIP, not usable yet
163
163
  test_files: []