ruby_ui 1.0.0.pre.alpha.4 → 1.0.0.rc1

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 (227) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -0
  3. data/README.md +85 -0
  4. data/lib/generators/ruby_ui/component_generator.rb +94 -0
  5. data/lib/generators/ruby_ui/dependencies.yml +74 -0
  6. data/lib/generators/ruby_ui/install/install_generator.rb +89 -0
  7. data/lib/generators/ruby_ui/install/templates/ruby_ui.rb.erb +18 -0
  8. data/lib/generators/ruby_ui/install/templates/tailwind.css.erb +156 -0
  9. data/lib/generators/ruby_ui/javascript_utils.rb +57 -0
  10. data/lib/{rbui → ruby_ui}/accordion/accordion.rb +1 -1
  11. data/lib/{rbui → ruby_ui}/accordion/accordion_content.rb +2 -2
  12. data/lib/ruby_ui/accordion/accordion_controller.js +97 -0
  13. data/lib/{rbui → ruby_ui}/accordion/accordion_default_content.rb +1 -1
  14. data/lib/{rbui → ruby_ui}/accordion/accordion_default_trigger.rb +3 -3
  15. data/lib/{rbui → ruby_ui}/accordion/accordion_icon.rb +2 -2
  16. data/lib/{rbui → ruby_ui}/accordion/accordion_item.rb +4 -4
  17. data/lib/{rbui → ruby_ui}/accordion/accordion_trigger.rb +3 -2
  18. data/lib/{rbui → ruby_ui}/alert/alert.rb +3 -3
  19. data/lib/{rbui → ruby_ui}/alert/alert_description.rb +1 -1
  20. data/lib/{rbui → ruby_ui}/alert/alert_title.rb +1 -1
  21. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog.rb +3 -3
  22. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_action.rb +2 -2
  23. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_cancel.rb +3 -3
  24. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_content.rb +5 -5
  25. data/lib/ruby_ui/alert_dialog/alert_dialog_controller.js +31 -0
  26. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_description.rb +1 -1
  27. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_footer.rb +2 -2
  28. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_header.rb +2 -2
  29. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_title.rb +1 -1
  30. data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_trigger.rb +2 -2
  31. data/lib/{rbui → ruby_ui}/aspect_ratio/aspect_ratio.rb +1 -1
  32. data/lib/{rbui → ruby_ui}/avatar/avatar.rb +2 -2
  33. data/lib/{rbui → ruby_ui}/avatar/avatar_fallback.rb +1 -1
  34. data/lib/{rbui → ruby_ui}/avatar/avatar_image.rb +1 -1
  35. data/lib/{rbui → ruby_ui}/badge/badge.rb +2 -2
  36. data/lib/{rbui → ruby_ui}/base.rb +1 -8
  37. data/lib/ruby_ui/breadcrumb/breadcrumb.rb +17 -0
  38. data/lib/ruby_ui/breadcrumb/breadcrumb_ellipsis.rb +39 -0
  39. data/lib/{rbui/typography/typography_list_item.rb → ruby_ui/breadcrumb/breadcrumb_item.rb} +3 -3
  40. data/lib/ruby_ui/breadcrumb/breadcrumb_link.rb +22 -0
  41. data/lib/ruby_ui/breadcrumb/breadcrumb_list.rb +17 -0
  42. data/lib/ruby_ui/breadcrumb/breadcrumb_page.rb +19 -0
  43. data/lib/ruby_ui/breadcrumb/breadcrumb_separator.rb +38 -0
  44. data/lib/{rbui → ruby_ui}/button/button.rb +13 -13
  45. data/lib/ruby_ui/calendar/calendar.rb +39 -0
  46. data/lib/{rbui → ruby_ui}/calendar/calendar_body.rb +2 -2
  47. data/lib/ruby_ui/calendar/calendar_controller.js +249 -0
  48. data/lib/{rbui → ruby_ui}/calendar/calendar_days.rb +14 -14
  49. data/lib/{rbui → ruby_ui}/calendar/calendar_header.rb +1 -1
  50. data/lib/ruby_ui/calendar/calendar_input_controller.js +8 -0
  51. data/lib/{rbui → ruby_ui}/calendar/calendar_next.rb +2 -2
  52. data/lib/{rbui → ruby_ui}/calendar/calendar_prev.rb +2 -2
  53. data/lib/{rbui → ruby_ui}/calendar/calendar_title.rb +2 -2
  54. data/lib/{rbui → ruby_ui}/calendar/calendar_weekdays.rb +2 -2
  55. data/lib/{rbui → ruby_ui}/card/card.rb +1 -1
  56. data/lib/{rbui → ruby_ui}/card/card_content.rb +1 -1
  57. data/lib/{rbui → ruby_ui}/card/card_description.rb +1 -1
  58. data/lib/{rbui → ruby_ui}/card/card_footer.rb +1 -1
  59. data/lib/{rbui → ruby_ui}/card/card_header.rb +1 -1
  60. data/lib/{rbui → ruby_ui}/card/card_title.rb +1 -1
  61. data/lib/ruby_ui/carousel/carousel.rb +44 -0
  62. data/lib/ruby_ui/carousel/carousel_content.rb +23 -0
  63. data/lib/ruby_ui/carousel/carousel_controller.js +60 -0
  64. data/lib/ruby_ui/carousel/carousel_item.rb +23 -0
  65. data/lib/ruby_ui/carousel/carousel_next.rb +48 -0
  66. data/lib/ruby_ui/carousel/carousel_previous.rb +49 -0
  67. data/lib/{rbui → ruby_ui}/chart/chart.rb +3 -3
  68. data/lib/ruby_ui/chart/chart_controller.js +103 -0
  69. data/lib/{rbui → ruby_ui}/checkbox/checkbox.rb +4 -4
  70. data/lib/{rbui → ruby_ui}/checkbox/checkbox_group.rb +2 -2
  71. data/lib/ruby_ui/checkbox/checkbox_group_controller.js +21 -0
  72. data/lib/{rbui → ruby_ui}/clipboard/clipboard.rb +6 -6
  73. data/lib/ruby_ui/clipboard/clipboard_controller.js +54 -0
  74. data/lib/{rbui → ruby_ui}/clipboard/clipboard_popover.rb +2 -2
  75. data/lib/{rbui → ruby_ui}/clipboard/clipboard_source.rb +2 -2
  76. data/lib/{rbui → ruby_ui}/clipboard/clipboard_trigger.rb +3 -3
  77. data/lib/{rbui → ruby_ui}/codeblock/codeblock.rb +7 -10
  78. data/lib/{rbui → ruby_ui}/collapsible/collapsible.rb +3 -3
  79. data/lib/{rbui → ruby_ui}/collapsible/collapsible_content.rb +2 -2
  80. data/lib/ruby_ui/collapsible/collapsible_controller.js +47 -0
  81. data/lib/{rbui → ruby_ui}/collapsible/collapsible_trigger.rb +2 -2
  82. data/lib/ruby_ui/combobox/combobox.rb +26 -0
  83. data/lib/ruby_ui/combobox/combobox_checkbox.rb +25 -0
  84. data/lib/ruby_ui/combobox/combobox_controller.js +176 -0
  85. data/lib/{rbui/combobox/combobox_empty.rb → ruby_ui/combobox/combobox_empty_state.rb} +3 -3
  86. data/lib/ruby_ui/combobox/combobox_item.rb +25 -0
  87. data/lib/ruby_ui/combobox/combobox_list.rb +18 -0
  88. data/lib/ruby_ui/combobox/combobox_list_group.rb +20 -0
  89. data/lib/ruby_ui/combobox/combobox_popover.rb +30 -0
  90. data/lib/ruby_ui/combobox/combobox_radio.rb +26 -0
  91. data/lib/{rbui → ruby_ui}/combobox/combobox_search_input.rb +22 -25
  92. data/lib/ruby_ui/combobox/combobox_toggle_all_checkbox.rb +25 -0
  93. data/lib/{rbui → ruby_ui}/combobox/combobox_trigger.rb +26 -21
  94. data/lib/{rbui → ruby_ui}/command/command.rb +1 -1
  95. data/lib/ruby_ui/command/command_controller.js +136 -0
  96. data/lib/{rbui → ruby_ui}/command/command_dialog.rb +2 -2
  97. data/lib/{rbui → ruby_ui}/command/command_dialog_content.rb +6 -6
  98. data/lib/{rbui → ruby_ui}/command/command_dialog_trigger.rb +3 -3
  99. data/lib/{rbui → ruby_ui}/command/command_empty.rb +2 -2
  100. data/lib/{rbui → ruby_ui}/command/command_group.rb +2 -2
  101. data/lib/{rbui → ruby_ui}/command/command_input.rb +3 -3
  102. data/lib/{rbui → ruby_ui}/command/command_item.rb +2 -2
  103. data/lib/{rbui → ruby_ui}/command/command_list.rb +1 -1
  104. data/lib/{rbui → ruby_ui}/context_menu/context_menu.rb +2 -2
  105. data/lib/{rbui → ruby_ui}/context_menu/context_menu_content.rb +2 -2
  106. data/lib/ruby_ui/context_menu/context_menu_controller.js +144 -0
  107. data/lib/{rbui → ruby_ui}/context_menu/context_menu_item.rb +3 -3
  108. data/lib/{rbui → ruby_ui}/context_menu/context_menu_label.rb +2 -2
  109. data/lib/{rbui → ruby_ui}/context_menu/context_menu_separator.rb +1 -1
  110. data/lib/{rbui → ruby_ui}/context_menu/context_menu_trigger.rb +3 -3
  111. data/lib/{rbui → ruby_ui}/dialog/dialog.rb +3 -3
  112. data/lib/{rbui → ruby_ui}/dialog/dialog_content.rb +9 -9
  113. data/lib/ruby_ui/dialog/dialog_controller.js +32 -0
  114. data/lib/{rbui → ruby_ui}/dialog/dialog_description.rb +1 -1
  115. data/lib/{rbui → ruby_ui}/dialog/dialog_footer.rb +2 -2
  116. data/lib/{rbui → ruby_ui}/dialog/dialog_header.rb +2 -2
  117. data/lib/{rbui → ruby_ui}/dialog/dialog_middle.rb +1 -1
  118. data/lib/{rbui → ruby_ui}/dialog/dialog_title.rb +1 -1
  119. data/lib/{rbui → ruby_ui}/dialog/dialog_trigger.rb +2 -2
  120. data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu.rb +4 -4
  121. data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_content.rb +2 -2
  122. data/lib/ruby_ui/dropdown_menu/dropdown_menu_controller.js +120 -0
  123. data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_item.rb +3 -3
  124. data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_label.rb +1 -1
  125. data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_separator.rb +1 -1
  126. data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_trigger.rb +2 -2
  127. data/lib/{rbui → ruby_ui}/form/form.rb +1 -1
  128. data/lib/{rbui → ruby_ui}/form/form_field.rb +2 -2
  129. data/lib/ruby_ui/form/form_field_controller.js +61 -0
  130. data/lib/{rbui → ruby_ui}/form/form_field_error.rb +2 -2
  131. data/lib/{rbui → ruby_ui}/form/form_field_hint.rb +1 -1
  132. data/lib/{rbui → ruby_ui}/form/form_field_label.rb +1 -1
  133. data/lib/{rbui → ruby_ui}/hover_card/hover_card.rb +3 -3
  134. data/lib/{rbui → ruby_ui}/hover_card/hover_card_content.rb +2 -2
  135. data/lib/ruby_ui/hover_card/hover_card_controller.js +144 -0
  136. data/lib/{rbui → ruby_ui}/hover_card/hover_card_trigger.rb +2 -2
  137. data/lib/{rbui → ruby_ui}/input/input.rb +3 -3
  138. data/lib/{rbui → ruby_ui}/link/link.rb +13 -13
  139. data/lib/ruby_ui/masked_input/masked_input.rb +15 -0
  140. data/lib/ruby_ui/masked_input/masked_input_controller.js +9 -0
  141. data/lib/{rbui → ruby_ui}/pagination/pagination.rb +1 -1
  142. data/lib/{rbui → ruby_ui}/pagination/pagination_content.rb +1 -1
  143. data/lib/{rbui → ruby_ui}/pagination/pagination_ellipsis.rb +1 -1
  144. data/lib/{rbui → ruby_ui}/pagination/pagination_item.rb +4 -4
  145. data/lib/{rbui → ruby_ui}/popover/popover.rb +4 -4
  146. data/lib/{rbui → ruby_ui}/popover/popover_content.rb +2 -2
  147. data/lib/ruby_ui/popover/popover_controller.js +107 -0
  148. data/lib/{rbui → ruby_ui}/popover/popover_trigger.rb +2 -2
  149. data/lib/ruby_ui/progress/progress.rb +37 -0
  150. data/lib/ruby_ui/radio_button/radio_button.rb +25 -0
  151. data/lib/{rbui → ruby_ui}/select/select.rb +5 -5
  152. data/lib/{rbui → ruby_ui}/select/select_content.rb +3 -3
  153. data/lib/ruby_ui/select/select_controller.js +171 -0
  154. data/lib/{rbui → ruby_ui}/select/select_group.rb +1 -1
  155. data/lib/{rbui → ruby_ui}/select/select_input.rb +4 -4
  156. data/lib/{rbui → ruby_ui}/select/select_item.rb +4 -4
  157. data/lib/ruby_ui/select/select_item_controller.js +11 -0
  158. data/lib/{rbui → ruby_ui}/select/select_label.rb +1 -1
  159. data/lib/{rbui → ruby_ui}/select/select_trigger.rb +3 -3
  160. data/lib/{rbui → ruby_ui}/select/select_value.rb +3 -3
  161. data/lib/ruby_ui/separator/separator.rb +38 -0
  162. data/lib/{rbui → ruby_ui}/sheet/sheet.rb +2 -2
  163. data/lib/{rbui → ruby_ui}/sheet/sheet_content.rb +8 -8
  164. data/lib/ruby_ui/sheet/sheet_content_controller.js +7 -0
  165. data/lib/ruby_ui/sheet/sheet_controller.js +9 -0
  166. data/lib/{rbui → ruby_ui}/sheet/sheet_description.rb +1 -1
  167. data/lib/{rbui → ruby_ui}/sheet/sheet_footer.rb +1 -1
  168. data/lib/{rbui → ruby_ui}/sheet/sheet_header.rb +1 -1
  169. data/lib/{rbui → ruby_ui}/sheet/sheet_middle.rb +1 -1
  170. data/lib/{rbui → ruby_ui}/sheet/sheet_title.rb +1 -1
  171. data/lib/{rbui → ruby_ui}/sheet/sheet_trigger.rb +2 -2
  172. data/lib/{rbui → ruby_ui}/shortcut_key/shortcut_key.rb +1 -1
  173. data/lib/ruby_ui/skeleton/skeleton.rb +17 -0
  174. data/lib/ruby_ui/switch/switch.rb +24 -0
  175. data/lib/{rbui → ruby_ui}/table/table.rb +1 -1
  176. data/lib/{rbui → ruby_ui}/table/table_body.rb +1 -1
  177. data/lib/{rbui → ruby_ui}/table/table_caption.rb +1 -1
  178. data/lib/{rbui → ruby_ui}/table/table_cell.rb +1 -1
  179. data/lib/{rbui → ruby_ui}/table/table_footer.rb +1 -1
  180. data/lib/{rbui → ruby_ui}/table/table_head.rb +1 -1
  181. data/lib/{rbui → ruby_ui}/table/table_header.rb +1 -1
  182. data/lib/{rbui → ruby_ui}/table/table_row.rb +1 -1
  183. data/lib/{rbui → ruby_ui}/tabs/tabs.rb +3 -3
  184. data/lib/{rbui → ruby_ui}/tabs/tabs_content.rb +2 -2
  185. data/lib/ruby_ui/tabs/tabs_controller.js +45 -0
  186. data/lib/{rbui → ruby_ui}/tabs/tabs_list.rb +1 -1
  187. data/lib/{rbui → ruby_ui}/tabs/tabs_trigger.rb +3 -3
  188. data/lib/{rbui → ruby_ui}/textarea/textarea.rb +3 -3
  189. data/lib/{rbui → ruby_ui}/theme_toggle/theme_toggle.rb +4 -4
  190. data/lib/ruby_ui/theme_toggle/theme_toggle_controller.js +30 -0
  191. data/lib/{rbui → ruby_ui}/tooltip/tooltip.rb +3 -3
  192. data/lib/{rbui → ruby_ui}/tooltip/tooltip_content.rb +3 -3
  193. data/lib/ruby_ui/tooltip/tooltip_controller.js +37 -0
  194. data/lib/{rbui → ruby_ui}/tooltip/tooltip_trigger.rb +2 -2
  195. data/lib/ruby_ui/typography/heading.rb +60 -0
  196. data/lib/{rbui/typography/typography_inline_code.rb → ruby_ui/typography/inline_code.rb} +2 -2
  197. data/lib/{rbui/typography/typography_inline_link.rb → ruby_ui/typography/inline_link.rb} +2 -2
  198. data/lib/ruby_ui/typography/text.rb +53 -0
  199. data/lib/{rbui → ruby_ui}/typography/typography_blockquote.rb +1 -1
  200. data/lib/ruby_ui.rb +5 -1
  201. metadata +208 -173
  202. data/lib/generators/rbui/base_generator.rb +0 -17
  203. data/lib/generators/rbui/component_generator.rb +0 -137
  204. data/lib/generators/rbui/install/install_generator.rb +0 -194
  205. data/lib/rbui/calendar/calendar.rb +0 -39
  206. data/lib/rbui/combobox/combobox.rb +0 -24
  207. data/lib/rbui/combobox/combobox_content.rb +0 -31
  208. data/lib/rbui/combobox/combobox_group.rb +0 -38
  209. data/lib/rbui/combobox/combobox_input.rb +0 -22
  210. data/lib/rbui/combobox/combobox_item.rb +0 -53
  211. data/lib/rbui/combobox/combobox_list.rb +0 -29
  212. data/lib/rbui/combobox/combobox_separator.rb +0 -15
  213. data/lib/rbui/combobox/combobox_value.rb +0 -27
  214. data/lib/rbui/radio_button/radio_button.rb +0 -22
  215. data/lib/rbui/railtie.rb +0 -52
  216. data/lib/rbui/typography/typography_h1.rb +0 -17
  217. data/lib/rbui/typography/typography_h2.rb +0 -17
  218. data/lib/rbui/typography/typography_h3.rb +0 -17
  219. data/lib/rbui/typography/typography_h4.rb +0 -17
  220. data/lib/rbui/typography/typography_large.rb +0 -17
  221. data/lib/rbui/typography/typography_lead.rb +0 -17
  222. data/lib/rbui/typography/typography_list.rb +0 -47
  223. data/lib/rbui/typography/typography_muted.rb +0 -17
  224. data/lib/rbui/typography/typography_p.rb +0 -17
  225. data/lib/rbui/typography/typography_small.rb +0 -17
  226. data/lib/rbui/version.rb +0 -5
  227. data/lib/rbui.rb +0 -57
@@ -0,0 +1,97 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+ import { animate } from "motion";
3
+
4
+ // Connects to data-controller="ruby-ui--accordion"
5
+ export default class extends Controller {
6
+ static targets = ["icon", "content"];
7
+ static values = {
8
+ open: {
9
+ type: Boolean,
10
+ default: false,
11
+ },
12
+ animationDuration: {
13
+ type: Number,
14
+ default: 0.15, // Default animation duration (in seconds)
15
+ },
16
+ animationEasing: {
17
+ type: String,
18
+ default: "ease-in-out", // Default animation easing
19
+ },
20
+ rotateIcon: {
21
+ type: Number,
22
+ default: 180, // Default icon rotation (in degrees)
23
+ },
24
+ };
25
+
26
+ connect() {
27
+ // Set the initial state of the accordion
28
+ let originalAnimationDuration = this.animationDurationValue;
29
+ this.animationDurationValue = 0;
30
+ this.openValue ? this.open() : this.close();
31
+ this.animationDurationValue = originalAnimationDuration;
32
+ }
33
+
34
+ // Toggle the 'open' value
35
+ toggle() {
36
+ this.openValue = !this.openValue;
37
+ }
38
+
39
+ // Handle changes in the 'open' value
40
+ openValueChanged(isOpen, wasOpen) {
41
+ if (isOpen) {
42
+ this.open();
43
+ } else {
44
+ this.close();
45
+ }
46
+ }
47
+
48
+ // Open the accordion content
49
+ open() {
50
+ if (this.hasContentTarget) {
51
+ this.revealContent();
52
+ this.hasIconTarget && this.rotateIcon();
53
+ this.openValue = true;
54
+ }
55
+ }
56
+
57
+ // Close the accordion content
58
+ close() {
59
+ if (this.hasContentTarget) {
60
+ this.hideContent();
61
+ this.hasIconTarget && this.rotateIcon();
62
+ this.openValue = false;
63
+ }
64
+ }
65
+
66
+ // Reveal the accordion content with animation
67
+ revealContent() {
68
+ const contentHeight = this.contentTarget.scrollHeight;
69
+ animate(
70
+ this.contentTarget,
71
+ { height: `${contentHeight}px` },
72
+ {
73
+ duration: this.animationDurationValue,
74
+ easing: this.animationEasingValue,
75
+ },
76
+ );
77
+ }
78
+
79
+ // Hide the accordion content with animation
80
+ hideContent() {
81
+ animate(
82
+ this.contentTarget,
83
+ { height: 0 },
84
+ {
85
+ duration: this.animationDurationValue,
86
+ easing: this.animationEasingValue,
87
+ },
88
+ );
89
+ }
90
+
91
+ // Rotate the accordion icon 180deg using animate function
92
+ rotateIcon() {
93
+ animate(this.iconTarget, {
94
+ rotate: `${this.openValue ? this.rotateIconValue : 0}deg`,
95
+ });
96
+ }
97
+ }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AccordionDefaultContent < Base
5
5
  def view_template(&)
6
6
  div(**attrs, &)
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AccordionDefaultTrigger < Base
5
5
  def view_template(&block)
6
6
  div(class: "flex items-center justify-between w-full") do
7
7
  p(&block)
8
- RBUI.AccordionIcon
8
+ RubyUI.AccordionIcon
9
9
  end
10
10
  end
11
11
 
12
12
  def default_attrs
13
13
  {
14
- data: {action: "click->rbui--accordion#toggle"},
14
+ data: {action: "click->ruby-ui--accordion#toggle"},
15
15
  class: "w-full flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline"
16
16
  }
17
17
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AccordionIcon < Base
5
5
  def view_template(&block)
6
6
  span(**attrs) do
@@ -31,7 +31,7 @@ module RBUI
31
31
  def default_attrs
32
32
  {
33
33
  class: "opacity-50",
34
- data: {rbui__accordion_target: "icon"}
34
+ data: {ruby_ui__accordion_target: "icon"}
35
35
  }
36
36
  end
37
37
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AccordionItem < Base
5
5
  def initialize(open: false, rotate_icon: 180, **attrs)
6
6
  @open = open
@@ -17,9 +17,9 @@ module RBUI
17
17
  def default_attrs
18
18
  {
19
19
  data: {
20
- controller: "rbui--accordion",
21
- rbui__accordion_open_value: @open,
22
- rbui__accordion_rotate_icon_value: @rotate_icon
20
+ controller: "ruby-ui--accordion",
21
+ ruby_ui__accordion_open_value: @open,
22
+ ruby_ui__accordion_rotate_icon_value: @rotate_icon
23
23
  },
24
24
  class: "border-b"
25
25
  }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AccordionTrigger < Base
5
5
  def view_template(&)
6
6
  button(**attrs, &)
@@ -8,7 +8,8 @@ module RBUI
8
8
 
9
9
  def default_attrs
10
10
  {
11
- data: {action: "click->rbui--accordion#toggle"},
11
+ type: "button",
12
+ data: {action: "click->ruby-ui--accordion#toggle"},
12
13
  class: "w-full flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline"
13
14
  }
14
15
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class Alert < Base
5
5
  def initialize(variant: nil, **attrs)
6
6
  @variant = variant
@@ -27,9 +27,9 @@ module RBUI
27
27
  end
28
28
 
29
29
  def default_attrs
30
- base_classes = "backdrop-blur relative w-full ring-1 ring-inset rounded-lg px-4 py-4 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg~*]:pl-8"
30
+ base_classes = "backdrop-blur relative w-full ring-1 ring-inset rounded-lg px-4 py-4 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:start-4 [&>svg]:top-4 [&>svg~*]:ps-8"
31
31
  {
32
- class: tokens(base_classes, colors)
32
+ class: [base_classes, colors]
33
33
  }
34
34
  end
35
35
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDescription < Base
5
5
  def view_template(&)
6
6
  div(**attrs, &)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertTitle < Base
5
5
  def view_template(&)
6
6
  h5(**attrs, &)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialog < Base
5
5
  def initialize(open: false, **attrs)
6
6
  @open = open
@@ -16,8 +16,8 @@ module RBUI
16
16
  def default_attrs
17
17
  {
18
18
  data: {
19
- controller: "rbui--alert-dialog",
20
- rbui__alert_dialog_open_value: @open.to_s
19
+ controller: "ruby-ui--alert-dialog",
20
+ ruby_ui__alert_dialog_open_value: @open.to_s
21
21
  },
22
22
  class: "inline-block"
23
23
  }
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialogAction < Base
5
5
  def view_template(&)
6
- render RBUI::Button.new(**attrs, &)
6
+ render RubyUI::Button.new(**attrs, &)
7
7
  end
8
8
 
9
9
  private
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialogCancel < Base
5
5
  def view_template(&)
6
- render RBUI::Button.new(**attrs, &)
6
+ render RubyUI::Button.new(**attrs, &)
7
7
  end
8
8
 
9
9
  private
@@ -12,7 +12,7 @@ module RBUI
12
12
  {
13
13
  variant: :outline,
14
14
  data: {
15
- action: "click->rbui--alert-dialog#dismiss"
15
+ action: "click->ruby-ui--alert-dialog#dismiss"
16
16
  },
17
17
  class: "mt-2 sm:mt-0"
18
18
  }
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialogContent < Base
5
5
  def view_template(&block)
6
- template_tag(**attrs) do
7
- div(data: {controller: "rbui--alert-dialog"}) do
6
+ template(**attrs) do
7
+ div(data: {controller: "ruby-ui--alert-dialog"}) do
8
8
  background
9
9
  container(&block)
10
10
  end
@@ -26,7 +26,7 @@ module RBUI
26
26
  div(
27
27
  role: "alertdialog",
28
28
  data_state: "open",
29
- class: "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",
29
+ class: "flex flex-col fixed left-[50%] top-[50%] z-50 w-full max-w-lg max-h-screen overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",
30
30
  style: "pointer-events:auto",
31
31
  &
32
32
  )
@@ -37,7 +37,7 @@ module RBUI
37
37
  def default_attrs
38
38
  {
39
39
  data: {
40
- rbui__alert_dialog_target: "content"
40
+ ruby_ui__alert_dialog_target: "content"
41
41
  }
42
42
  }
43
43
  end
@@ -0,0 +1,31 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ // Connects to data-controller="ruby-ui--alert-dialog"
4
+ export default class extends Controller {
5
+ static targets = ["content"];
6
+ static values = {
7
+ open: {
8
+ type: Boolean,
9
+ default: false,
10
+ },
11
+ };
12
+
13
+ connect() {
14
+ if (this.openValue) {
15
+ this.open();
16
+ }
17
+ }
18
+
19
+ open() {
20
+ document.body.insertAdjacentHTML("beforeend", this.contentTarget.innerHTML);
21
+ // prevent scroll on body
22
+ document.body.classList.add("overflow-hidden");
23
+ }
24
+
25
+ dismiss(e) {
26
+ // allow scroll on body
27
+ document.body.classList.remove("overflow-hidden");
28
+ // remove the element
29
+ this.element.remove();
30
+ }
31
+ }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialogDescription < Base
5
5
  def view_template(&)
6
6
  p(**attrs, &)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialogFooter < Base
5
5
  def view_template(&)
6
6
  div(**attrs, &)
@@ -10,7 +10,7 @@ module RBUI
10
10
 
11
11
  def default_attrs
12
12
  {
13
- class: "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2"
13
+ class: "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 rtl:space-x-reverse"
14
14
  }
15
15
  end
16
16
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialogHeader < Base
5
5
  def view_template(&)
6
6
  div(**attrs, &)
@@ -10,7 +10,7 @@ module RBUI
10
10
 
11
11
  def default_attrs
12
12
  {
13
- class: "flex flex-col space-y-2 text-center sm:text-left"
13
+ class: "flex flex-col space-y-2 text-center sm:text-left rtl:sm:text-right"
14
14
  }
15
15
  end
16
16
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialogTitle < Base
5
5
  def view_template(&)
6
6
  h2(**attrs, &)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AlertDialogTrigger < Base
5
5
  def view_template(&)
6
6
  div(**attrs, &)
@@ -10,7 +10,7 @@ module RBUI
10
10
 
11
11
  def default_attrs
12
12
  {
13
- data: {action: "click->rbui--alert-dialog#open"},
13
+ data: {action: "click->ruby-ui--alert-dialog#open"},
14
14
  class: "inline-block"
15
15
  }
16
16
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AspectRatio < Base
5
5
  def initialize(aspect_ratio: "16/9", **attrs)
6
6
  raise "aspect_ratio must be in the format of a string with a slash in the middle (eg. '16/9', '1/1')" unless aspect_ratio.is_a?(String) && aspect_ratio.include?("/")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class Avatar < Base
5
5
  SIZES = {
6
6
  xs: "h-4 w-4 text-[0.5rem]",
@@ -24,7 +24,7 @@ module RBUI
24
24
 
25
25
  def default_attrs
26
26
  {
27
- class: tokens("relative flex shrink-0 overflow-hidden rounded-full", @size_classes)
27
+ class: ["relative flex shrink-0 overflow-hidden rounded-full", @size_classes]
28
28
  }
29
29
  end
30
30
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AvatarFallback < Base
5
5
  def view_template(&)
6
6
  span(**attrs, &)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class AvatarImage < Base
5
5
  def initialize(src:, alt: "", **attrs)
6
6
  @src = src
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
3
+ module RubyUI
4
4
  class Badge < Base
5
5
  SIZES = {
6
6
  sm: "px-1.5 py-0.5 text-xs",
@@ -53,7 +53,7 @@ module RBUI
53
53
 
54
54
  def default_attrs
55
55
  {
56
- class: tokens("inline-flex items-center rounded-md font-medium ring-1 ring-inset", SIZES[@size], COLORS[@variant])
56
+ class: ["inline-flex items-center rounded-md font-medium ring-1 ring-inset", SIZES[@size], COLORS[@variant]]
57
57
  }
58
58
  end
59
59
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "tailwind_merge"
4
4
 
5
- module RBUI
5
+ module RubyUI
6
6
  class Base < Phlex::HTML
7
7
  TAILWIND_MERGER = ::TailwindMerge::Merger.new.freeze unless defined?(TAILWIND_MERGER)
8
8
 
@@ -13,13 +13,6 @@ module RBUI
13
13
  @attrs[:class] = TAILWIND_MERGER.merge(@attrs[:class]) if @attrs[:class]
14
14
  end
15
15
 
16
- if defined?(Rails) && Rails.env.development?
17
- def before_template
18
- comment { "Before #{self.class.name}" }
19
- super
20
- end
21
- end
22
-
23
16
  private
24
17
 
25
18
  def default_attrs
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyUI
4
+ class Breadcrumb < Base
5
+ def view_template(&)
6
+ nav(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ aria: {label: "breadcrumb"}
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyUI
4
+ class BreadcrumbEllipsis < Base
5
+ def view_template(&)
6
+ span(**attrs) do
7
+ icon
8
+ span(class: "sr-only") { "More" }
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def icon
15
+ svg(
16
+ xmlns: "http://www.w3.org/2000/svg",
17
+ class: "w-4 h-4",
18
+ viewbox: "0 0 24 24",
19
+ fill: "none",
20
+ stroke: "currentColor",
21
+ stroke_width: "2",
22
+ stroke_linecap: "round",
23
+ stroke_linejoin: "round"
24
+ ) do |s|
25
+ s.circle(cx: "12", cy: "12", r: "1")
26
+ s.circle(cx: "19", cy: "12", r: "1")
27
+ s.circle(cx: "5", cy: "12", r: "1")
28
+ end
29
+ end
30
+
31
+ def default_attrs
32
+ {
33
+ aria: {hidden: true},
34
+ class: "flex h-9 w-9 items-center justify-center",
35
+ role: "presentation"
36
+ }
37
+ end
38
+ end
39
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RBUI
4
- class TypographyListItem < Base
3
+ module RubyUI
4
+ class BreadcrumbItem < Base
5
5
  def view_template(&)
6
6
  li(**attrs, &)
7
7
  end
@@ -10,7 +10,7 @@ module RBUI
10
10
 
11
11
  def default_attrs
12
12
  {
13
- class: "leading-7"
13
+ class: "inline-flex items-center gap-1.5"
14
14
  }
15
15
  end
16
16
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyUI
4
+ class BreadcrumbLink < Base
5
+ def initialize(href: "#", **attrs)
6
+ @href = href
7
+ super(**attrs)
8
+ end
9
+
10
+ def view_template(&)
11
+ a(href: @href, **attrs, &)
12
+ end
13
+
14
+ private
15
+
16
+ def default_attrs
17
+ {
18
+ class: "transition-colors hover:text-foreground"
19
+ }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyUI
4
+ class BreadcrumbList < Base
5
+ def view_template(&)
6
+ ol(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ class: "flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5"
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyUI
4
+ class BreadcrumbPage < Base
5
+ def view_template(&)
6
+ span(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ aria: {disabled: true, current: "page"},
14
+ class: "font-normal text-foreground",
15
+ role: "link"
16
+ }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyUI
4
+ class BreadcrumbSeparator < Base
5
+ def view_template(&block)
6
+ li(**attrs) do
7
+ if block
8
+ block.call
9
+ else
10
+ icon
11
+ end
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def icon
18
+ svg(
19
+ xmlns: "http://www.w3.org/2000/svg",
20
+ class: "w-4 h-4",
21
+ viewbox: "0 0 24 24",
22
+ fill: "none",
23
+ stroke: "currentColor",
24
+ stroke_width: "2",
25
+ stroke_linecap: "round",
26
+ stroke_linejoin: "round"
27
+ ) { |s| s.path(d: "m9 18 6-6-6-6") }
28
+ end
29
+
30
+ def default_attrs
31
+ {
32
+ aria: {hidden: true},
33
+ class: "[&>svg]:w-3.5 [&>svg]:h-3.5",
34
+ role: "presentation"
35
+ }
36
+ end
37
+ end
38
+ end