maquina-components 0.7.2 → 0.7.4

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/drawer.css +8 -8
  3. data/app/assets/stylesheets/form.css +58 -4
  4. data/app/assets/stylesheets/separator.css +6 -1
  5. data/app/assets/tailwind/maquina_components_engine/tokens.css +1 -0
  6. data/app/helpers/maquina_components/calendar_helper.rb +32 -0
  7. data/app/helpers/maquina_components/drawer_helper.rb +3 -5
  8. data/app/helpers/maquina_components/dropdown_menu_helper.rb +22 -5
  9. data/app/helpers/maquina_components/empty_helper.rb +3 -3
  10. data/app/helpers/maquina_components/icons_helper.rb +9 -5
  11. data/app/helpers/maquina_components/pagination_helper.rb +27 -5
  12. data/app/javascript/controllers/calendar_controller.js +28 -25
  13. data/app/javascript/controllers/combobox_controller.js +17 -2
  14. data/app/javascript/controllers/date_picker_controller.js +57 -21
  15. data/app/javascript/controllers/drawer_controller.js +66 -44
  16. data/app/javascript/controllers/drawer_trigger_controller.js +13 -0
  17. data/app/javascript/controllers/sidebar_controller.js +84 -42
  18. data/app/javascript/controllers/sidebar_trigger_controller.js +13 -0
  19. data/app/javascript/controllers/toast_controller.js +2 -3
  20. data/app/javascript/controllers/toaster_controller.js +23 -1
  21. data/app/javascript/controllers/toggle_group_controller.js +17 -6
  22. data/app/views/components/_badge.html.erb +1 -1
  23. data/app/views/components/_breadcrumbs.html.erb +7 -7
  24. data/app/views/components/_calendar.html.erb +13 -28
  25. data/app/views/components/_combobox.html.erb +2 -0
  26. data/app/views/components/_date_picker.html.erb +19 -33
  27. data/app/views/components/_drawer.html.erb +1 -1
  28. data/app/views/components/_menu_button.html.erb +1 -1
  29. data/app/views/components/_sidebar.html.erb +1 -1
  30. data/app/views/components/breadcrumbs/_ellipsis.html.erb +1 -1
  31. data/app/views/components/breadcrumbs/_item.html.erb +1 -1
  32. data/app/views/components/breadcrumbs/_link.html.erb +1 -1
  33. data/app/views/components/breadcrumbs/_list.html.erb +1 -1
  34. data/app/views/components/breadcrumbs/_page.html.erb +1 -1
  35. data/app/views/components/breadcrumbs/_separator.html.erb +1 -2
  36. data/app/views/components/calendar/_week.html.erb +7 -4
  37. data/app/views/components/card/_content.html.erb +1 -1
  38. data/app/views/components/card/_footer.html.erb +3 -10
  39. data/app/views/components/card/_header.html.erb +1 -1
  40. data/app/views/components/card/_title.html.erb +1 -1
  41. data/app/views/components/combobox/_option.html.erb +2 -2
  42. data/app/views/components/drawer/_close.html.erb +11 -5
  43. data/app/views/components/drawer/_content.html.erb +1 -1
  44. data/app/views/components/drawer/_footer.html.erb +1 -1
  45. data/app/views/components/drawer/_header.html.erb +1 -1
  46. data/app/views/components/drawer/_provider.html.erb +1 -1
  47. data/app/views/components/drawer/_trigger.html.erb +4 -2
  48. data/app/views/components/pagination/_ellipsis.html.erb +5 -8
  49. data/app/views/components/pagination/_link.html.erb +1 -1
  50. data/app/views/components/pagination/_next.html.erb +6 -7
  51. data/app/views/components/pagination/_previous.html.erb +6 -7
  52. data/app/views/components/sidebar/_content.html.erb +1 -1
  53. data/app/views/components/sidebar/_footer.html.erb +1 -1
  54. data/app/views/components/sidebar/_group.html.erb +1 -1
  55. data/app/views/components/sidebar/_header.html.erb +1 -1
  56. data/app/views/components/sidebar/_inset.html.erb +1 -1
  57. data/app/views/components/sidebar/_menu.html.erb +1 -1
  58. data/app/views/components/sidebar/_menu_button.html.erb +1 -1
  59. data/app/views/components/sidebar/_menu_item.html.erb +1 -1
  60. data/app/views/components/sidebar/_menu_link.html.erb +3 -3
  61. data/app/views/components/sidebar/_provider.html.erb +1 -1
  62. data/app/views/components/sidebar/_trigger.html.erb +1 -1
  63. data/app/views/components/stats/_stats_card.html.erb +7 -6
  64. data/app/views/components/toast/_action.html.erb +2 -1
  65. data/lib/generators/maquina_components/install/templates/theme.css.tt +11 -0
  66. data/lib/maquina_components/doctor.rb +18 -8
  67. data/lib/maquina_components/version.rb +1 -1
  68. metadata +1 -1
@@ -5,7 +5,7 @@
5
5
  active: (active ? true : nil)
6
6
  ) %>
7
7
 
8
- <%= link_to url, class: css_classes, data: merged_data,
8
+ <%= link_to url, class: css_classes.presence, data: merged_data,
9
9
  "aria-current": (active ? "page" : nil), **html_options do %>
10
10
  <% if icon_name.present? %>
11
11
  <%= icon_for(icon_name) %>
@@ -2,6 +2,6 @@
2
2
  <% merged_data =
3
3
  merge_component_data(html_options, sidebar_part: "menu-item") %>
4
4
 
5
- <%= content_tag :li, class: "group/menu-item #{css_classes}", data: merged_data, **html_options do %>
5
+ <%= content_tag :li, class: class_names("group/menu-item", css_classes), data: merged_data, **html_options do %>
6
6
  <%= yield %>
7
7
  <% end %>
@@ -4,14 +4,14 @@
4
4
  active: (active ? true : nil)
5
5
  ) %>
6
6
 
7
- <%= link_to url, class: css_classes, data: merged_data,
7
+ <%= link_to url, class: css_classes.presence, data: merged_data,
8
8
  "aria-current": (active ? "page" : nil), **html_options do %>
9
9
  <% if icon.present? || text_icon.present? %>
10
10
  <div data-sidebar-part="menu-avatar">
11
11
  <% if icon.present? %>
12
- <%= image_tag icon, class: icon_classes %>
12
+ <%= image_tag icon, class: icon_classes.presence %>
13
13
  <% elsif text_icon.present? %>
14
- <span class="<%= icon_classes %>"><%= text_icon %></span>
14
+ <%= tag.span text_icon, class: icon_classes.presence %>
15
15
  <% end %>
16
16
  </div>
17
17
  <% end %>
@@ -11,6 +11,6 @@
11
11
  action: "keydown.meta+#{keyboard_shortcut}@window->sidebar#toggleWithKeyboard keydown.ctrl+#{keyboard_shortcut}@window->sidebar#toggleWithKeyboard"
12
12
  ) %>
13
13
 
14
- <%= content_tag :div, id: id || "sidebar-provider", class: css_classes, data: merged_data, **html_options do %>
14
+ <%= content_tag :div, id: id || "sidebar-provider", class: css_classes.presence, data: merged_data, **html_options do %>
15
15
  <%= yield %>
16
16
  <% end %>
@@ -6,7 +6,7 @@
6
6
  sidebar_trigger_sidebar_outlet: "[data-outlet='sidebar']"
7
7
  ) %>
8
8
 
9
- <%= button_tag type: :button, class: css_classes, data: merged_data, **html_options do %>
9
+ <%= button_tag type: :button, class: css_classes.presence, data: merged_data, **html_options do %>
10
10
  <%= icon_for(icon_name) %>
11
11
  <span class="sr-only">Toggle Sidebar</span>
12
12
  <% end %>
@@ -5,8 +5,9 @@
5
5
  icon_classes = icon_classes.presence || icon_class
6
6
  value_classes = value_classes.presence || value_class
7
7
 
8
- # Legacy string icon names map to built-in icons; symbols pass straight
9
- # through; anything else renders as custom icon markup.
8
+ # Symbols resolve through icon_for (app icons first, then built-ins);
9
+ # legacy kebab-case strings map to built-in names; anything else renders
10
+ # as custom icon markup.
10
11
  legacy_icons = {
11
12
  "message-square" => :message_square,
12
13
  "arrow-up" => :arrow_up,
@@ -25,16 +26,16 @@
25
26
  <div data-stats-part="body">
26
27
  <div data-stats-part="text">
27
28
  <p data-stats-part="title"><%= title %></p>
28
- <p data-stats-part="value" class="<%= value_classes.presence %>"><%= value %></p>
29
+ <%= tag.p value, class: value_classes.presence, data: {stats_part: "value"} %>
29
30
  <% if subtitle.present? %>
30
31
  <p data-stats-part="subtitle"><%= subtitle %></p>
31
32
  <% end %>
32
33
  </div>
33
34
 
34
35
  <% if icon.present? %>
35
- <div data-stats-part="icon" class="<%= icon_classes.presence %>">
36
- <%= icon_name ? builtin_icon_for(icon_name, class: "size-8") : icon %>
37
- </div>
36
+ <%= tag.div class: icon_classes.presence, data: {stats_part: "icon"} do %>
37
+ <%= icon_name ? icon_for(icon_name, class: "size-8") : icon %>
38
+ <% end %>
38
39
  <% end %>
39
40
  </div>
40
41
  <% end %>
@@ -1,6 +1,7 @@
1
1
  <%# locals: (label:, href: nil, method: nil, css_classes: "", **html_options) %>
2
2
  <% merged_data = merge_component_data(html_options,
3
- toast_part: "action"
3
+ toast_part: "action",
4
+ action: ("toast#handleAction" if href.blank?)
4
5
  ) %>
5
6
 
6
7
  <% merged_data["turbo-method"] = method if method.present? %>
@@ -155,6 +155,17 @@
155
155
  --color-destructive: var(--destructive);
156
156
  --color-destructive-foreground: var(--destructive-foreground);
157
157
 
158
+ --color-success: var(--success);
159
+ --color-success-foreground: var(--success-foreground);
160
+
161
+ --color-warning: var(--warning);
162
+ --color-warning-foreground: var(--warning-foreground);
163
+
164
+ /* --info and --info-foreground are declared in the shape/state token block
165
+ the installer appends below this palette. */
166
+ --color-info: var(--info);
167
+ --color-info-foreground: var(--info-foreground);
168
+
158
169
  --color-input: var(--input);
159
170
  --color-border: var(--border);
160
171
  --color-ring: var(--ring);
@@ -54,6 +54,13 @@ module MaquinaComponents
54
54
  # Assigning a data URI to one of the five mark properties IS the 0.6.0
55
55
  # pattern, so it must not be reported as a restated rule.
56
56
  MARK_TOKEN_ASSIGNMENT = /--(?:checkbox-mark|checkbox-indeterminate|radio-mark|switch-thumb|select-chevron)-image\s*:/
57
+ RESTATED_SVG_SUGGESTION =
58
+ "0.6.0 exposes these marks as overridable custom properties:\n" \
59
+ "--checkbox-mark-image, --checkbox-indeterminate-image, --radio-mark-image,\n" \
60
+ "--switch-thumb-image, --select-chevron-image. Assign your SVG to the token\n" \
61
+ "instead of restating the engine's rule."
62
+ # A component hook in markup: data-component="..." or a helper's component: key.
63
+ MARKUP_COMPONENT_HOOK = /data-component=|\bcomponent:\s*[:"']/
57
64
  RADIUS_DECL = /(?:border-radius\s*:|@apply[^;{}]*\brounded(?:-[a-z0-9\[\].\/-]+)?\b)/
58
65
  SHADOW_DECL = /(?:box-shadow\s*:|@apply[^;{}]*\b(?:shadow|ring)(?:-[a-z0-9\[\].\/-]+)?\b)/
59
66
  FOCUS_SELECTOR = /:focus(-visible|-within)?\b/
@@ -238,6 +245,13 @@ module MaquinaComponents
238
245
 
239
246
  return unless component_selector?(chain)
240
247
 
248
+ # Only here, under a component selector, does an SVG restate an engine
249
+ # mark. Anywhere else it is the app's own artwork -- Rails' actiontext.css
250
+ # carries fifteen for the Trix editor.
251
+ if SVG_DATA_URI.match?(declaration) && !MARK_TOKEN_ASSIGNMENT.match?(declaration)
252
+ add(path, index, declaration, :breaking, "restated-svg-uri", RESTATED_SVG_SUGGESTION)
253
+ end
254
+
241
255
  if RADIUS_DECL.match?(declaration)
242
256
  add(path, index, declaration, :review, "hardcoded-radius",
243
257
  "0.6.0 reads --control-radius / --surface-radius / --mark-radius / --pill-radius.\n" \
@@ -319,20 +333,16 @@ module MaquinaComponents
319
333
  "Use the value form of the variant: data-[active=true]:... - the bare\n" \
320
334
  "data-[active] variant relies on an attribute 0.6.0 no longer emits when false.")
321
335
  end
322
-
323
- if SVG_DATA_URI.match?(line) && !MARK_TOKEN_ASSIGNMENT.match?(line)
324
- add(path, index, line, :breaking, "restated-svg-uri",
325
- "0.6.0 exposes these marks as overridable custom properties:\n" \
326
- "--checkbox-mark-image, --checkbox-indeterminate-image, --radio-mark-image,\n" \
327
- "--switch-thumb-image, --select-chevron-image. Assign your SVG to the token\n" \
328
- "instead of restating the engine's rule.")
329
- end
330
336
  end
331
337
 
332
338
  def scan_markup(path)
333
339
  read(path).each_with_index do |line, index|
334
340
  scan_shared(path, index, line)
335
341
 
342
+ if SVG_DATA_URI.match?(line) && MARKUP_COMPONENT_HOOK.match?(line)
343
+ add(path, index, line, :breaking, "restated-svg-uri", RESTATED_SVG_SUGGESTION)
344
+ end
345
+
336
346
  # Cross-file signals for check_invalid_without_aria.
337
347
  @aria_invalid_seen ||= ARIA_INVALID.match?(line)
338
348
  if ERROR_PART.match?(line) || FIELD_WITH_ERRORS.match?(line)
@@ -1,3 +1,3 @@
1
1
  module MaquinaComponents
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maquina-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Alberto Chávez