ariadne_view_components 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ariadne_view_components.js +2 -2
  3. data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
  4. data/app/assets/javascripts/comment-component.d.ts +1 -2
  5. data/app/assets/stylesheets/ariadne_view_components.css +1 -0
  6. data/app/assets/stylesheets/dropdown.css +46 -0
  7. data/app/assets/stylesheets/tooltip-component.css +8 -8
  8. data/app/components/ariadne/ariadne.ts +0 -2
  9. data/app/components/ariadne/avatar_component.rb +81 -0
  10. data/app/components/ariadne/avatar_stack_component.html.erb +12 -0
  11. data/app/components/ariadne/avatar_stack_component.rb +75 -0
  12. data/app/components/ariadne/base_button.rb +13 -4
  13. data/app/components/ariadne/blankslate_component.rb +4 -4
  14. data/app/components/ariadne/button_component.html.erb +1 -1
  15. data/app/components/ariadne/button_component.rb +9 -3
  16. data/app/components/ariadne/comment-component.ts +32 -50
  17. data/app/components/ariadne/comment_component.html.erb +32 -10
  18. data/app/components/ariadne/comment_component.rb +17 -5
  19. data/app/components/ariadne/details_component.html.erb +4 -0
  20. data/app/components/ariadne/details_component.rb +80 -0
  21. data/app/components/ariadne/dropdown/menu_component.html.erb +20 -0
  22. data/app/components/ariadne/dropdown/menu_component.rb +101 -0
  23. data/app/components/ariadne/dropdown/menu_component.ts +1 -0
  24. data/app/components/ariadne/dropdown_component.html.erb +8 -0
  25. data/app/components/ariadne/dropdown_component.rb +172 -0
  26. data/app/components/ariadne/flex_component.rb +1 -1
  27. data/app/components/ariadne/footer_component.html.erb +1 -1
  28. data/app/components/ariadne/header_component.rb +2 -2
  29. data/app/components/ariadne/heroicon_component.rb +6 -4
  30. data/app/components/ariadne/inline_flex_component.html.erb +1 -0
  31. data/app/components/ariadne/inline_flex_component.rb +8 -1
  32. data/app/components/ariadne/link_component.rb +2 -2
  33. data/app/components/ariadne/list_component.html.erb +2 -9
  34. data/app/components/ariadne/list_component.rb +11 -15
  35. data/app/components/ariadne/main_component.rb +1 -1
  36. data/app/components/ariadne/pill_component.rb +19 -5
  37. data/app/components/ariadne/rich-text-area-component.ts +4 -4
  38. data/app/components/ariadne/rich_text_area_component.html.erb +1 -1
  39. data/app/components/ariadne/rich_text_area_component.rb +1 -1
  40. data/app/components/ariadne/slideover_component.html.erb +1 -1
  41. data/app/components/ariadne/tab-container-component.ts +21 -21
  42. data/app/components/ariadne/tab_component.rb +4 -7
  43. data/app/components/ariadne/tab_container_component.rb +8 -2
  44. data/app/components/ariadne/tab_nav_component.html.erb +1 -1
  45. data/app/components/ariadne/tab_nav_component.rb +1 -1
  46. data/app/components/ariadne/table_nav_component.html.erb +52 -0
  47. data/app/components/ariadne/table_nav_component.rb +338 -0
  48. data/app/components/ariadne/tooltip_component.html.erb +1 -1
  49. data/app/components/ariadne/tooltip_component.rb +4 -4
  50. data/app/lib/ariadne/action_view_extensions/form_helper.rb +21 -7
  51. data/app/lib/ariadne/form_builder.rb +2 -2
  52. data/lib/ariadne/view_components/version.rb +1 -1
  53. data/lib/tasks/docs.rake +19 -3
  54. data/static/arguments.yml +103 -11
  55. data/static/audited_at.json +15 -7
  56. data/static/classes.yml +49 -45
  57. data/static/constants.json +179 -51
  58. data/static/statuses.json +15 -7
  59. data/tailwind.config.js +25 -1
  60. metadata +15 -4
  61. data/app/components/ariadne/table_component.html.erb +0 -17
  62. data/app/components/ariadne/table_component.rb +0 -281
@@ -1,6 +1,6 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |slideover| %>
2
2
  <div data-slideover-component-target="expandWrapper" class="ariadne-flex ariadne-flex-col ariadne-z-10">
3
- <div data-slideover-component-target="expandable" class="ariadne-hidden bg-filter-panel ariadne-px-3 ariadne-pb-4">
3
+ <div data-slideover-component-target="expandable" class="ariadne-hidden ariadne-px-3 ariadne-pb-4">
4
4
  <%= content %>
5
5
  </div>
6
6
  <div data-slideover-component-target="buttonWrapper" data-slideover-component-form-id="<%= @form_id %>" class="ariadne-relative ariadne-flex ariadne-justify-center">
@@ -1,24 +1,24 @@
1
1
  import '@github/tab-container-element'
2
2
 
3
- // // keep in sync with tab_container_component.rb
4
- // const DEFAULT_SELECTED_CLASSES: string[] = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600']
5
- // const DEFAULT_UNSELECTED_CLASSES: string[] = [
6
- // 'ariadne-text-gray-500',
7
- // 'hover:ariadne-text-gray-700',
8
- // 'hover:ariadne-border-gray-300'
9
- // ]
3
+ // keep in sync with tab_container_component.rb
4
+ const DEFAULT_SELECTED_CLASSES: string[] = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600']
5
+ const DEFAULT_UNSELECTED_CLASSES: string[] = [
6
+ 'ariadne-text-gray-500',
7
+ 'hover:ariadne-text-gray-700',
8
+ 'hover:ariadne-border-gray-300'
9
+ ]
10
10
 
11
- // for (const tabContainer of document.getElementsByTagName('tab-container')) {
12
- // tabContainer.addEventListener('tab-container-change', function (event: Event) {
13
- // const newPanel = (event as CustomEvent).detail.relatedTarget as HTMLElement
14
- // const tabContainer = newPanel.closest('tab-container') as HTMLElement
15
- // const tabList = tabContainer.firstElementChild as HTMLElement
16
- // const currentTab = tabList.querySelector('[aria-selected="true"]') as HTMLElement
17
- // const tabId = newPanel.getAttribute('id')?.split('-').slice(1).join('-')
18
- // const newTab = tabList.querySelector(`#${tabId}`) as HTMLElement
19
- // currentTab.classList.remove(...DEFAULT_SELECTED_CLASSES)
20
- // currentTab.classList.add(...DEFAULT_UNSELECTED_CLASSES)
21
- // newTab.classList.add(...DEFAULT_SELECTED_CLASSES)
22
- // newTab.classList.remove(...DEFAULT_UNSELECTED_CLASSES)
23
- // })
24
- // }
11
+ for (const tabContainer of document.getElementsByTagName('tab-container')) {
12
+ tabContainer.addEventListener('tab-container-change', function (event: Event) {
13
+ const newPanel = (event as CustomEvent).detail.relatedTarget as HTMLElement
14
+ const tabContainer = newPanel.closest('tab-container') as HTMLElement
15
+ const tabList = tabContainer.firstElementChild as HTMLElement
16
+ const currentTab = tabList.querySelector('[aria-selected="true"]') as HTMLElement
17
+ const tabId = newPanel.getAttribute('id')?.split('-').slice(1).join('-')
18
+ const newTab = tabList.querySelector(`#${tabId}`) as HTMLElement
19
+ currentTab.classList.remove(...DEFAULT_SELECTED_CLASSES)
20
+ currentTab.classList.add(...DEFAULT_UNSELECTED_CLASSES)
21
+ newTab.classList.add(...DEFAULT_SELECTED_CLASSES)
22
+ newTab.classList.remove(...DEFAULT_UNSELECTED_CLASSES)
23
+ })
24
+ }
@@ -42,7 +42,7 @@ module Ariadne
42
42
  renders_one :text, Ariadne::Text
43
43
  # TODO: test what hapenns with really long inbox names
44
44
 
45
- attr_reader :selected
45
+ attr_reader :selected, :id, :classes, :attributes
46
46
 
47
47
  DEFAULT_CLASSES = "ariadne-border-transparent ariadne-text-gray-500 hover:ariadne-text-gray-700 hover:ariadne-border-gray-300 ariadne-whitespace-nowrap ariadne-py-4 ariadne-px-1 ariadne-border-b-2 ariadne-font-medium ariadne-text-sm"
48
48
 
@@ -58,7 +58,7 @@ module Ariadne
58
58
  # @param href [String] The link to navigate to when the tab is clicked.
59
59
  # @param classes [String] <%= link_to_classes_docs %>
60
60
  # @param attributes [Hash] <%= link_to_attributes_docs %>
61
- def initialize(id: nil, selected: false, with_panel: false, href: "", classes: "", attributes: {})
61
+ def initialize(id: nil, selected: false, with_panel: false, href: nil, classes: "", attributes: {})
62
62
  @id = id
63
63
 
64
64
  @href = href
@@ -78,13 +78,10 @@ module Ariadne
78
78
  end
79
79
 
80
80
  @tag = :button
81
- @system_arguments[:tag] = :button
82
- @system_arguments[:type] = :button
83
- @system_arguments[:role] = :tab
81
+ @attributes[:type] = :button
82
+ @attributes[:role] = :tab
84
83
  @panel_id = "panel-#{@id}"
85
84
  @attributes[:"aria-controls"] = @panel_id
86
- # https://www.w3.org/TR/wai-aria-practices/#presentation_role
87
- @wrapper_arguments[:role] = :presentation
88
85
  else
89
86
  @tag = :a
90
87
  end
@@ -9,18 +9,20 @@ module Ariadne
9
9
 
10
10
  DEFAULT_CLASSES = ""
11
11
 
12
+ DEFAULT_SELECTED_CLASSES = "ariadne-border-indigo-500 ariadne-text-indigo-600"
13
+ DEFAULT_UNSELECTED_CLASSES = "ariadne-text-gray-500 hover:ariadne-text-gray-700 hover:ariadne-border-gray-300"
14
+
12
15
  # Tabs and panels to be rendered.
13
16
  #
14
17
  # @param id [String] The unique ID of the tab.
15
18
  # @param selected [Boolean] Whether the tab is selected.
16
19
  # @param classes [String] <%= link_to_classes_docs %>
17
20
  # @param attributes [Hash] <%= link_to_attributes_docs %>
18
- renders_many :tabs, lambda { |id:, selected: false, href: "", classes: "", attributes: {}|
21
+ renders_many :tabs, lambda { |id: "", selected: false, classes: "", attributes: {}|
19
22
  actual_classes = class_names(selected ? DEFAULT_SELECTED_CLASSES : DEFAULT_UNSELECTED_CLASSES, classes)
20
23
  Ariadne::TabComponent.new(
21
24
  id: id,
22
25
  selected: selected,
23
- href: href,
24
26
  with_panel: true,
25
27
 
26
28
  classes: actual_classes,
@@ -57,5 +59,9 @@ module Ariadne
57
59
  @attributes[:"aria-label"] = sr_label
58
60
  @attributes[:role] = :presentation
59
61
  end
62
+
63
+ def render?
64
+ tabs.present?
65
+ end
60
66
  end
61
67
  end
@@ -1,7 +1,7 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |component| %>
2
2
  <ul class="ariadne-list-none">
3
3
  <% tabs.each do |tab| %>
4
- <li class="inline-flex"><%= tab %></li>
4
+ <li class="ariadne-inline-flex"><%= tab %></li>
5
5
  <% end %>
6
6
  </ul>
7
7
  <% end %>
@@ -29,7 +29,7 @@ module Ariadne
29
29
  # @param selected [Boolean] Whether the tab is selected.
30
30
  # @param classes [String] <%= link_to_classes_docs %>
31
31
  # @param attributes [Hash] <%= link_to_attributes_docs %>
32
- renders_many :tabs, lambda { |selected: false, href: "", classes: "", attributes: {}|
32
+ renders_many :tabs, lambda { |selected: false, href: nil, classes: "", attributes: {}|
33
33
  attributes[:href] = href
34
34
  attributes[:"data-tab-nav-component-target"] = "tab"
35
35
  attributes[:"data-action"] = "click->tab-nav-component#toggle"
@@ -0,0 +1,52 @@
1
+ <div class="ariadne-inline-block ariadne-min-w-full ariadne-py-2 ariadne-align-middle md:ariadne-px-6 lg:ariadne-px-8">
2
+ <div class="ariadne-overflow-hidden ariadne-shadow ariadne-ring-1 ariadne-ring-black ariadne-ring-opacity-5 md:ariadne-rounded-lg">
3
+ <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do |table| %>
4
+ <% if has_header_row? %>
5
+ <thead>
6
+ <%= render(Ariadne::BaseComponent.new(tag: :tr, classes: header_row.classes, attributes: header_row.attributes)) do %>
7
+ <%= header_row.selection_cell %>
8
+ <%= header_row.main_cell %>
9
+ <% header_row.action_cells.each_with_index do |action_cell, idx| %>
10
+ <% if idx.zero? %>
11
+ <%= action_cell %>
12
+ <% elsif idx == header_row.action_cells.size - 1 %>
13
+ <%= action_cell %>
14
+ <% else %>
15
+ <%= action_cell %>
16
+ <% end %>
17
+ <% end %>
18
+ <% end %>
19
+ </thead>
20
+ <% end %>
21
+ <tbody>
22
+ <% rows.each do |row| %>
23
+ <%= render(Ariadne::BaseComponent.new(tag: :tr, classes: row.classes, attributes: row.attributes)) do %>
24
+ <%= row.selection_cell %>
25
+ <%= row.main_cell %>
26
+ <% row.metadata_cells.each_with_index do |metadata_cell, idx| %>
27
+ <% if idx.zero? %>
28
+ <%= metadata_cell %>
29
+ <% elsif idx == row.metadata_cells.size - 1 %>
30
+ <%= metadata_cell %>
31
+ <% else %>
32
+ <%= metadata_cell %>
33
+ <% end %>
34
+ <% end %>
35
+ <% end %>
36
+ <% end %>
37
+ </tbody>
38
+ <% end %>
39
+ </div>
40
+ <% if has_footer? %>
41
+ <%= render(Ariadne::BaseComponent.new(tag: :div, classes: footer.classes, attributes: footer.attributes)) do %>
42
+ <%= footer.records_info %>
43
+ <%= render(Ariadne::BaseComponent.new(tag: :nav, classes: footer.pagination_bar.classes, attributes: footer.pagination_bar.attributes)) do %>
44
+ <%= footer.pagination_bar.prev_page %>
45
+ <% footer.pagination_bar.items.each do |item| %>
46
+ <%= item %>
47
+ <% end %>
48
+ <%= footer.pagination_bar.next_page %>
49
+ <% end %>
50
+ <% end %>
51
+ <% end %>
52
+ </div>
@@ -0,0 +1,338 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ariadne
4
+ # The `TableNavComponent` is used to render a table navigation.
5
+ class TableNavComponent < Ariadne::Component
6
+ DEFAULT_CLASSES = "ariadne-min-w-full ariadne-divide-y ariadne-divide-gray-300"
7
+
8
+ renders_one :header_row, "BaseRowItem::HeaderRowItem"
9
+
10
+ renders_many :rows, "BaseRowItem::RowItem"
11
+
12
+ renders_one :footer, "FooterItem"
13
+
14
+ DEFAULT_TAG = :table
15
+
16
+ # @example Default
17
+ #
18
+ # <%= render(Ariadne::TableNavComponent.new) do |table| %>
19
+ # <%= table.header_row do |header_row| %>
20
+ # <% header_row.selection_cell do %>
21
+ # Status
22
+ # <% end %>
23
+ # <% header_row.main_cell do %>
24
+ # State
25
+ # <% end %>
26
+ # <% header_row.action_cell do %>
27
+ # Labels
28
+ # <% end %>
29
+ # <% end %>
30
+ # <%= table.row do |row| %>
31
+ # <% row.selection_cell do %>
32
+ # G
33
+ # <% end %>
34
+ # <% row.main_cell do %>
35
+ # "California"
36
+ # <% end %>
37
+ # <% row.metadata_cell do %>
38
+ # Labels
39
+ # <% end %>
40
+ # <% end %>
41
+ # <%= table.row do |row| %>
42
+ # <% row.selection_cell do %>
43
+ # V
44
+ # <% end %>
45
+ # <% row.main_cell do %>
46
+ # "New York"
47
+ # <% end %>
48
+ # <% row.metadata_cell do %>
49
+ # Labels
50
+ # <% end %>
51
+ # <% end %>
52
+ # <%= table.row do |row| %>
53
+ # <% row.cell do %>
54
+ # D
55
+ # <% end %>
56
+ # <% row.selection_cell do %>
57
+ # "Texas"
58
+ # <% end %>
59
+ # <% row.metadata_cell do %>
60
+ # Labels
61
+ # <% end %>
62
+ # <% end %>
63
+ # <% end %>
64
+ #
65
+ # @param classes [String] <%= link_to_classes_docs %>
66
+ # @param attributes [Hash] <%= link_to_attributes_docs %>
67
+ def initialize(classes: "", attributes: {})
68
+ @tag = DEFAULT_TAG
69
+ @classes = class_names(
70
+ DEFAULT_CLASSES,
71
+ classes,
72
+ )
73
+
74
+ @attributes = attributes
75
+ end
76
+
77
+ def has_header_row?
78
+ header_row.present?
79
+ end
80
+
81
+ def has_footer?
82
+ footer.present?
83
+ end
84
+
85
+ # This component is part of `TableNavComponent` and should not be
86
+ # used as a standalone component.
87
+ class BaseRowItem < Ariadne::TableNavComponent
88
+ BASE_ROW_CLASSES = ""
89
+
90
+ DEFAULT_TAG = :tr
91
+
92
+ BASE_SELECTION_CLASSES = ""
93
+ renders_one :selection_cell, lambda { |classes: "", attributes: {}|
94
+ actual_classes = class_names(BASE_SELECTION_CLASSES, classes)
95
+ if header?
96
+ Ariadne::TableNavComponent::BaseCellItem::HeaderCellItem.new(classes: actual_classes, attributes: attributes)
97
+ else
98
+ Ariadne::TableNavComponent::BaseCellItem::CellItem.new(classes: actual_classes, attributes: attributes)
99
+ end
100
+ }
101
+
102
+ BASE_MAIN_CLASSES = "ariadne-pr-5"
103
+ renders_one :main_cell, lambda { |classes: "", attributes: {}|
104
+ actual_classes = class_names(BASE_MAIN_CLASSES, classes)
105
+ if header?
106
+ Ariadne::TableNavComponent::BaseCellItem::HeaderCellItem.new(classes: actual_classes, attributes: attributes)
107
+ else
108
+ Ariadne::TableNavComponent::BaseCellItem::CellItem.new(classes: actual_classes, attributes: attributes)
109
+ end
110
+ }
111
+
112
+ attr_reader :classes, :attributes
113
+
114
+ def initialize(classes: "", attributes: {})
115
+ @tag = DEFAULT_TAG
116
+ @classes = class_names(BASE_ROW_CLASSES, classes)
117
+
118
+ @attributes = attributes
119
+ end
120
+
121
+ private def linked?
122
+ @href.present?
123
+ end
124
+
125
+ private def header?
126
+ @header.present?
127
+ end
128
+
129
+ def call
130
+ Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)
131
+ end
132
+
133
+ # This component is part of `TableNavComponent` and should not be
134
+ # used as a standalone component.
135
+ class RowItem < Ariadne::TableNavComponent::BaseRowItem
136
+ DEFAULT_ROW_CLASSES = "ariadne-bg-white"
137
+ DEFAULT_METADATA_CLASSES = ""
138
+ renders_many :metadata_cells, lambda { |classes: "", attributes: {}|
139
+ actual_classes = class_names(DEFAULT_METADATA_CLASSES, classes)
140
+ Ariadne::TableNavComponent::BaseCellItem::CellItem.new(classes: actual_classes, attributes: attributes)
141
+ }
142
+
143
+ attr_reader :href
144
+
145
+ def initialize(classes: "", attributes: {})
146
+ @header = false
147
+
148
+ actual_classes = class_names(DEFAULT_ROW_CLASSES, classes)
149
+
150
+ super(classes: actual_classes, attributes: attributes)
151
+ end
152
+ end
153
+
154
+ # This component is part of `TableNavComponent` and should not be
155
+ # used as a standalone component.
156
+ class HeaderRowItem < Ariadne::TableNavComponent::BaseRowItem
157
+ DEFAULT_HEADER_ROW_CLASSES = "ariadne-bg-gray-50 ariadne-text-left"
158
+
159
+ renders_many :action_cells, lambda { |classes: "", attributes: {}|
160
+ Ariadne::TableNavComponent::BaseCellItem::HeaderCellItem.new(classes: classes, attributes: attributes)
161
+ }
162
+
163
+ def initialize(classes: "", attributes: {})
164
+ @header = true
165
+
166
+ actual_classes = class_names(
167
+ DEFAULT_HEADER_ROW_CLASSES,
168
+ classes,
169
+ )
170
+
171
+ super(classes: actual_classes, attributes: attributes)
172
+ end
173
+ end
174
+ end
175
+
176
+ # This component is part of `TableNavComponent` and should not be
177
+ # used as a standalone component.
178
+ class BaseCellItem < Ariadne::TableNavComponent
179
+ DEFAULT_CELL_CLASSES = "ariadne-py-3.5 ariadne-pl-4 ariadne-pr-3 ariadne-text-left ariadne-text-sm ariadne-text-gray-900"
180
+
181
+ attr_writer :first, :last
182
+
183
+ def initialize(classes: "", attributes: {})
184
+ @classes = class_names(
185
+ DEFAULT_CELL_CLASSES,
186
+ classes,
187
+ )
188
+
189
+ @attributes = attributes
190
+ end
191
+
192
+ def call
193
+ render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do
194
+ content
195
+ end
196
+ end
197
+
198
+ # This component is part of `TableNavComponent` and should not be
199
+ # used as a standalone component.
200
+ class HeaderCellItem < Ariadne::TableNavComponent::BaseCellItem
201
+ DEFAULT_HEADER_CELL_CLASSES = "ariadne-py-3.5 ariadne-pl-4 ariadne-pr-3 ariadne-text-left ariadne-text-sm ariadne-font-semibold ariadne-text-gray-900 sm:ariadne-pl-6 md:ariadne-pl-0"
202
+
203
+ DEFAULT_TAG = :th
204
+
205
+ WIDTH_CLASSES = {
206
+ none: "ariadne-flex-none ariadne-w-14 ariadne-px-4",
207
+ default: "ariadne-flex-initial",
208
+ narrow: "ariadne-flex-initial ariadne-w-1/5 ariadne-text-right",
209
+ wide: "ariadne-flex-grow ariadne-w-3/5 sm:ariadne-pl-6",
210
+ }
211
+
212
+ # TODO: add one_of check for width
213
+ def initialize(classes: "", attributes: {})
214
+ @tag = DEFAULT_TAG
215
+ actual_classes = class_names(DEFAULT_HEADER_CELL_CLASSES, classes)
216
+ attributes["scope"] = "col"
217
+ super(classes: actual_classes, attributes: attributes)
218
+ end
219
+ end
220
+
221
+ # This component is part of `TableNavComponent` and should not be
222
+ # used as a standalone component.
223
+ class CellItem < Ariadne::TableNavComponent::BaseCellItem
224
+ DEFAULT_CELL_CLASSES = ""
225
+
226
+ DEFAULT_TAG = :td
227
+
228
+ # TODO: add one_of check for width
229
+ def initialize(classes: "", attributes: {})
230
+ @tag = DEFAULT_TAG
231
+ actual_classes = class_names(DEFAULT_CELL_CLASSES, classes)
232
+ super(classes: actual_classes, attributes: attributes)
233
+ end
234
+ end
235
+ end
236
+
237
+ # This component is part of `TableNavComponent` and should not be
238
+ # used as a standalone component.
239
+ class FooterItem < Ariadne::TableNavComponent
240
+ DEFAULT_FOOTER_CLASSES = "ariadne-border-none ariadne-flex ariadne-items-center ariadne-justify-between ariadne-px-4 ariadne-py-3 sm:ariadne-px-6"
241
+
242
+ DEFAULT_RESULT_CLASSES = "ariadne-text-sm ariadne-text-gray-700"
243
+ renders_one :records_info, lambda { |classes: "", attributes: {}|
244
+ actual_classes = class_names(DEFAULT_RESULT_CLASSES, classes)
245
+ Ariadne::BaseComponent.new(tag: :p, classes: actual_classes, attributes: attributes)
246
+ }
247
+
248
+ renders_one :pagination_bar, "Ariadne::TableNavComponent::PaginationBarItem"
249
+
250
+ attr_reader :classes, :attributes
251
+
252
+ def initialize(classes: "", attributes: {})
253
+ @classes = class_names(
254
+ DEFAULT_FOOTER_CLASSES,
255
+ classes,
256
+ )
257
+
258
+ @attributes = attributes
259
+ end
260
+
261
+ def call
262
+ render(Ariadne::BaseComponent.new(tag: :div, classes: @classes, attributes: @attributes)) do
263
+ records_info.to_s + pagination_bar.to_s
264
+ end
265
+ end
266
+ end
267
+
268
+ # This component is part of `TableNavComponent` and should not be
269
+ # used as a standalone component.
270
+ class PaginationBarItem < Ariadne::FooterComponent
271
+ DEFAULT_PREV_PAGE_CLASSES = "ariadne-relative ariadne-inline-flex ariadne-items-center ariadne-rounded-l-md ariadne-border ariadne-border-gray-300 ariadne-bg-white ariadne-px-2 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-500 hover:ariadne-bg-gray-50 focus:ariadne-z-20"
272
+ renders_one :prev_page, lambda { |disabled: false, href:, classes: "", attributes: {}|
273
+ if disabled
274
+ actual_classes = class_names(DEFAULT_PREV_PAGE_CLASSES, "ariadne-bg-gray-50", classes)
275
+
276
+ render(Ariadne::BaseComponent.new(tag: :span, classes: actual_classes, attributes: attributes)) do
277
+ render(Ariadne::HeroiconComponent.new(icon: "chevron-left", size: :sm, variant: :mini, text_attributes: { "aria-hidden": true }, text_classes: "ariadne-sr-only"))
278
+ end
279
+ else
280
+ actual_classes = class_names(DEFAULT_PREV_PAGE_CLASSES, "hover:ariadne-bg-gray-50", classes)
281
+ attributes[:"aria-label"] = "previous"
282
+
283
+ render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) do
284
+ render(Ariadne::HeroiconComponent.new(icon: "chevron-left", size: :sm, variant: :mini, text_attributes: { "aria-hidden": true }, text_classes: "ariadne-sr-only"))
285
+ end
286
+ end
287
+ }
288
+
289
+ DEFAULT_PAGE_CLASSES = "ariadne-relative ariadne-inline-flex ariadne-items-center ariadne-border ariadne-border-gray-300 ariadne-bg-white ariadne-px-4 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-500 hover:ariadne-bg-gray-50 focus:ariadne-z-20"
290
+ DEFAULT_CURRENT_PAGE_CLASSES = "ariadne-relative ariadne-z-10 ariadne-inline-flex ariadne-items-center ariadne-border ariadne-border-indigo-500 ariadne-bg-indigo-50 ariadne-px-4 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-indigo-600 focus:ariadne-z-20"
291
+ DEFAULT_GAP_CLASSES = " ariadne-relative ariadne-inline-flex ariadne-items-center ariadne-border ariadne-border-gray-300 ariadne-bg-white ariadne-px-4 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-700"
292
+ renders_many :items, lambda { |link:, classes: "", attributes: {}|
293
+ page, href = link
294
+ if page.is_a?(Integer)
295
+ actual_classes = class_names(DEFAULT_PAGE_CLASSES, classes)
296
+ render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) { page.to_s }
297
+ elsif page.is_a?(String)
298
+ actual_classes = class_names(DEFAULT_CURRENT_PAGE_CLASSES, classes)
299
+ render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) { page.to_s }
300
+ elsif page == :gap
301
+ actual_classes = class_names(DEFAULT_GAP_CLASSES, classes)
302
+ render(Ariadne::BaseComponent.new(tag: :span, classes: actual_classes, attributes: attributes)) { h(href.to_s) }
303
+ end
304
+ }
305
+
306
+ DEFAULT_NEXT_PAGE_CLASSES = "ariadne-relative ariadne-inline-flex ariadne-items-center ariadne-rounded-r-md ariadne-border ariadne-border-gray-300 ariadne-bg-white ariadne-px-2 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-500 hover:ariadne-bg-gray-50 focus:ariadne-z-20"
307
+ renders_one :next_page, lambda { |disabled: false, href:, classes: "", attributes: {}|
308
+ if disabled
309
+ actual_classes = class_names(DEFAULT_NEXT_PAGE_CLASSES, "ariadne-bg-gray-50", classes)
310
+
311
+ render(Ariadne::BaseComponent.new(tag: :span, classes: actual_classes, attributes: attributes)) do
312
+ render(Ariadne::HeroiconComponent.new(icon: "chevron-right", size: :sm, variant: :mini, text_attributes: { "aria-hidden": true }, text_classes: "ariadne-sr-only"))
313
+ end
314
+ else
315
+ actual_classes = class_names(DEFAULT_NEXT_PAGE_CLASSES, "hover:ariadne-bg-gray-50", classes)
316
+ attributes[:"aria-label"] = "next"
317
+
318
+ render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) do
319
+ render(Ariadne::HeroiconComponent.new(icon: "chevron-right", size: :sm, variant: :mini, text_attributes: { "aria-hidden": true }, text_classes: "ariadne-sr-only"))
320
+ end
321
+ end
322
+ }
323
+
324
+ attr_reader :classes, :attributes
325
+
326
+ DEFAULT_PAGINATOR_CLASSES = "ariadne-flex ariadne-items-center ariadne-justify-between ariadne-m-10"
327
+ def initialize(classes: "", attributes: {})
328
+ @classes = class_names(
329
+ DEFAULT_PAGINATOR_CLASSES,
330
+ classes,
331
+ )
332
+
333
+ @attributes = attributes
334
+ @attributes[:"aria-label"] ||= "paginator"
335
+ end
336
+ end
337
+ end
338
+ end
@@ -1,4 +1,4 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do %>
2
2
  <span><%= @text %></span>
3
- <span class="tooltip-arrow ariadne-absolute ariadne-block" data-popper-arrow></span>
3
+ <span class="ariadne-tooltip-arrow ariadne-absolute ariadne-block" data-popper-arrow></span>
4
4
  <% end %>
@@ -28,13 +28,13 @@ module Ariadne
28
28
  DEFAULT_PLACEMENT = :top
29
29
  VALID_PLACEMENTS = [DEFAULT_PLACEMENT, :right, :bottom, :left].freeze
30
30
 
31
- DEFAULT_CLASSES = "ariadne-invisible ariadne-absolute ariadne-bg-slate-900 ariadne-text-white ariadne-font-semibold ariadne-max-w-xs ariadne-py-1 ariadne-px-2 ariadne-rounded z-max"
31
+ DEFAULT_CLASSES = "ariadne-invisible ariadne-absolute ariadne-bg-slate-900 ariadne-text-white ariadne-font-semibold ariadne-max-w-xs ariadne-py-1 ariadne-px-2 ariadne-rounded ariadne-z-max"
32
32
 
33
33
  DATA_CONTROLLER = "tooltip-component"
34
34
  DATA_ACTION = "mouseover->tooltip-component#show mouseout->tooltip-component#hide"
35
35
 
36
36
  TYPE_DEFAULT = :description
37
- TYPE_OPTIONS = [:label, TYPE_DEFAULT].freeze
37
+ VALID_TYPES = [:label, TYPE_DEFAULT].freeze
38
38
 
39
39
  # DEFAULT_DATA_ATTRIBUTES = {
40
40
  # "data-controller": DATA_CONTROLLER,
@@ -85,7 +85,7 @@ module Ariadne
85
85
  # @param tag [Symbol, String] The rendered tag name
86
86
  # @param for_id [String] The ID of the element that the tooltip should be attached to.
87
87
  # @param text [String] The text content of the tooltip. This should be brief and no longer than a sentence.
88
- # @param type [Symbol] <%= one_of(Ariadne::TooltipComponent::TYPE_OPTIONS) %>
88
+ # @param type [Symbol] <%= one_of(Ariadne::TooltipComponent::VALID_TYPES) %>
89
89
  # @param direction [Symbol] <%= one_of(Ariadne::TooltipComponent::VALID_PLACEMENTS) %>
90
90
  # @param classes [String] <%= link_to_classes_docs %>
91
91
  # @param attributes [Hash] <%= link_to_attributes_docs %>
@@ -101,7 +101,7 @@ module Ariadne
101
101
  @attributes[:for] = for_id
102
102
 
103
103
  @attributes[:"data-tooltip-component-placement"] = fetch_or_raise(VALID_PLACEMENTS, direction)
104
- @attributes[:"data-type"] = fetch_or_raise(TYPE_OPTIONS, type)
104
+ @attributes[:"data-type"] = fetch_or_raise(VALID_TYPES, type)
105
105
  @attributes[:"data-tooltip-component-target"] = "tooltip"
106
106
  end
107
107
  end
@@ -6,16 +6,30 @@ module Ariadne
6
6
  module FormHelper
7
7
  include ClassNameHelper
8
8
 
9
- DEFAULT_FORM_CLASSES = "space-y-8 divide-y divide-gray-200 sm:space-y-5"
10
- def ariadne_form_with(model: nil, scope: nil, url: nil, format: nil, classes: {}, attributes: {}, **options, &block)
9
+ DEFAULT_FORM_CLASSES = "ariadne-space-y-8 ariadne-divide-y ariadne-divide-gray-200 sm:ariadne-space-y-5"
10
+ def ariadne_form_with(model: nil, scope: nil, url: nil, format: nil, classes: "", attributes: {}, **options, &block)
11
11
  options[:class] = class_names(DEFAULT_FORM_CLASSES, options[:class])
12
12
  options[:builder] ||= Ariadne::FormBuilder
13
13
  options[:html] ||= {}
14
- options = options.merge(attributes)
15
- data = {
16
- controller: "ariadne-form",
17
- }
18
- form_with(model: model, scope: scope, url: url, format: format, data: data, **options, &block)
14
+
15
+ data = options.delete(:data) || {}
16
+ attributes = attributes.delete_if do |key, value|
17
+ key_name = key.to_s
18
+ if key_name.start_with?("data-")
19
+ data[key_name.sub(/^data-/, "").to_sym] = value
20
+ true
21
+ else
22
+ false
23
+ end
24
+ end
25
+
26
+ data[:controller] = if data.fetch(:controller, {}).present?
27
+ "#{data[:controller]} ariadne-form"
28
+ else
29
+ "ariadne-form"
30
+ end
31
+
32
+ form_with(model: model, scope: scope, url: url, format: format, data: data, attributes: attributes, **options, &block)
19
33
  end
20
34
  end
21
35
  end
@@ -27,7 +27,7 @@ module Ariadne
27
27
  end
28
28
 
29
29
  DEFAULT_LABEL_CLASSES = "ariadne-block ariadne-text-sm ariadne-font-medium ariadne-text-gray-700 ariadne-pl-2"
30
- def label(object_name, content, ptions = {}, &block)
30
+ def label(object_name, content, options = {}, &block)
31
31
  options[:class] = class_names(DEFAULT_LABEL_CLASSES, options.delete(:classes))
32
32
  super(object_name, content, options, &block)
33
33
  end
@@ -39,7 +39,7 @@ module Ariadne
39
39
  end
40
40
 
41
41
  DEFAULT_CHECKBOX_CLASSES = "focus:ariadne-ring-indigo-500 ariadne-h-4 ariadne-w-4 ariadne-text-indigo-600 ariadne-border-gray-300 ariadne-rounded"
42
- def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
42
+ def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
43
43
  options[:class] = class_names(DEFAULT_CHECKBOX_CLASSES, options.delete(:classes))
44
44
  super(method, options, checked_value, unchecked_value)
45
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ariadne
4
4
  module ViewComponents
5
- VERSION = "0.0.13"
5
+ VERSION = "0.0.14"
6
6
  end
7
7
  end